feat(MultiSelect): add selectedOnly and combineValues props

The MultiSelect wasn't rendering form-submittable inputs. This fix adds two new props to help customize how the hidden inputs render.

See #1742
This commit is contained in:
Enrico Sacchetti 2023-10-25 21:56:52 -04:00
commit 276465aa9d
5 changed files with 167 additions and 44 deletions

View file

@ -27,15 +27,30 @@ export interface MultiSelectProps extends RestProps {
itemToString?: (item: MultiSelectItem) => any;
/**
* Override the item name, title, labelText passed to the checkbox input
* Override the item name, title, labelText, or value passed to the user-selectable checkbox input as well as the hidden inputs.
* @default (item) => {}
*/
itemToInput?: (item: MultiSelectItem) => {
name?: string;
labelText?: any;
title?: string;
value?: string;
};
/**
* Set to `true` to only render selected options as hidden inputs for form submission.
* @default false
*/
selectedOnly?: boolean;
/**
* Combine selected items as comma-separated values when submitted in a form.
* If set to `true`, the default separator is a comma `,`.
* Pass in a string to override the separator.
* @default false
*/
combineValues?: false | true | string;
/**
* Set the selected ids
* @default []