mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-19 20:09:35 +00:00
chore(multi-select): keep checkboxes rendered in DOM
Display ListBox via CSS
This commit is contained in:
parent
276465aa9d
commit
43ac7a811f
5 changed files with 44 additions and 133 deletions
|
@ -7007,7 +7007,7 @@
|
|||
"name": "itemToInput",
|
||||
"kind": "let",
|
||||
"description": "Override the item name, title, labelText, or value passed to the user-selectable checkbox input as well as the hidden inputs.",
|
||||
"type": "(item: MultiSelectItem) => { name?: string; labelText?: any; title?:\nstring; value?: string }",
|
||||
"type": "(item: MultiSelectItem) => { name?: string; labelText?: any; title?: string; value?: string }",
|
||||
"value": "(item) => {}",
|
||||
"isFunction": true,
|
||||
"isFunctionDeclaration": false,
|
||||
|
@ -7015,30 +7015,6 @@
|
|||
"constant": false,
|
||||
"reactive": false
|
||||
},
|
||||
{
|
||||
"name": "selectedOnly",
|
||||
"kind": "let",
|
||||
"description": "Set to `true` to only render selected options as hidden inputs for form submission.",
|
||||
"type": "boolean",
|
||||
"value": "false",
|
||||
"isFunction": false,
|
||||
"isFunctionDeclaration": false,
|
||||
"isRequired": false,
|
||||
"constant": false,
|
||||
"reactive": false
|
||||
},
|
||||
{
|
||||
"name": "combineValues",
|
||||
"kind": "let",
|
||||
"description": "Combine selected items as comma-separated values when submitted in a form.\nIf set to `true`, the default separator is a comma `,`.\nPass in a string to override the separator.",
|
||||
"type": "false | true | string",
|
||||
"value": "false",
|
||||
"isFunction": false,
|
||||
"isFunctionDeclaration": false,
|
||||
"isRequired": false,
|
||||
"constant": false,
|
||||
"reactive": false
|
||||
},
|
||||
{
|
||||
"name": "selectedIds",
|
||||
"kind": "let",
|
||||
|
|
|
@ -14,10 +14,9 @@
|
|||
By default, items will be ordered alphabetically based on the `item.text` value.
|
||||
To prevent this, see [#no-alphabetical-ordering](#no-alphabetical-ordering).
|
||||
|
||||
Hidden inputs will be rendered based on user selection, such as `<input type="hidden"
|
||||
name="0" value="true" />` to mirror checkbox values and to allow MultiSelect to
|
||||
be submittable within forms. These hidden inputs can be customized with
|
||||
the `combineValues` or `itemToInput` props.
|
||||
MultiSelect provides interactivity for a list of checkbox inputs. Those
|
||||
checkboxes will remain rendered in the DOM and are submittable within forms.
|
||||
Checkbox attributes can be adjusted via the `itemToInput` prop.
|
||||
|
||||
<MultiSelect titleText="Contact" label="Select contact methods..."
|
||||
items="{[{id: "0", text: "Slack"},
|
||||
|
@ -96,30 +95,8 @@ The above function sets the `name` attribute to
|
|||
`Contact_0` (respective to each item's `id`) for every hidden input that
|
||||
renders, along with each respective item's `id` set to the `value` attribute.
|
||||
|
||||
When using with the `selectedOnly` prop, you can override every hidden input to
|
||||
use the same `name` attribute. This may be useful if you
|
||||
wish to use `formData.getAll('contact')` in your server-side form handler.
|
||||
|
||||
<MultiSelect
|
||||
itemToInput={(item) => ({name: 'contact', value: item.id})}
|
||||
selectedOnly
|
||||
titleText="Contact"
|
||||
label="Select contact methods..."
|
||||
items="{[
|
||||
{id: "0", text: "Slack"},
|
||||
{id: "1", text: "Email"},
|
||||
{id: "2", text: "Fax"}
|
||||
]}"
|
||||
/>
|
||||
|
||||
## Combine values into a single input
|
||||
|
||||
With the `combineValues` prop, all selected items' values will render as a
|
||||
comma-separated string within a single hidden input. A custom delimiter can
|
||||
alternatively be passed in.
|
||||
|
||||
<MultiSelect
|
||||
combineValues
|
||||
titleText="Contact"
|
||||
label="Select contact methods..."
|
||||
items="{[
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue