|
| 1 | +import type { Meta, StoryObj } from '@storybook/react'; |
| 2 | +import { SelectMultiple } from 'grommet'; |
| 3 | +import { |
| 4 | + a11yTitleArg, |
| 5 | + disabledArg, |
| 6 | + placeholderArg, |
| 7 | + marginArg, |
| 8 | +} from '../utils/commonArgs'; |
| 9 | + |
| 10 | +const meta = { |
| 11 | + title: 'Components/SelectMultiple', |
| 12 | + component: SelectMultiple, |
| 13 | + argTypes: { |
| 14 | + a11yTitle: a11yTitleArg, |
| 15 | + disabled: disabledArg, |
| 16 | + help: { |
| 17 | + control: { type: 'text' }, |
| 18 | + description: |
| 19 | + 'Optional help text to display above the options in the drop.', |
| 20 | + }, |
| 21 | + limit: { |
| 22 | + control: { type: 'number' }, |
| 23 | + description: 'The maximum number of options that can be selected.', |
| 24 | + }, |
| 25 | + margin: marginArg, |
| 26 | + onSearch: { |
| 27 | + action: 'searched', |
| 28 | + description: |
| 29 | + 'Function that will be called when the user types in the search input.', |
| 30 | + }, |
| 31 | + open: { |
| 32 | + control: { type: 'boolean' }, |
| 33 | + }, |
| 34 | + options: { |
| 35 | + control: { type: 'object' }, |
| 36 | + }, |
| 37 | + placeholder: placeholderArg, |
| 38 | + searchPlaceholder: { |
| 39 | + control: { type: 'text' }, |
| 40 | + description: |
| 41 | + 'Placeholder text to use in the search box when the search input is empty.', |
| 42 | + }, |
| 43 | + showSelectedInline: { |
| 44 | + control: { type: 'boolean' }, |
| 45 | + description: |
| 46 | + 'Whether selections should be displayed at the input level of the component.', |
| 47 | + }, |
| 48 | + sortSelectedOnClose: { |
| 49 | + control: { type: 'boolean' }, |
| 50 | + description: |
| 51 | + 'Whether selections should be sorted with selected items displayed at the top of the list after closing and reopening the drop.', |
| 52 | + }, |
| 53 | + }, |
| 54 | +} satisfies Meta<typeof SelectMultiple>; |
| 55 | + |
| 56 | +export default meta; |
| 57 | +type Story = StoryObj<typeof meta>; |
| 58 | + |
| 59 | +export const Default = { |
| 60 | + name: 'SelectMultiple', |
| 61 | + render: args => <SelectMultiple {...args} />, |
| 62 | + args: { |
| 63 | + a11yTitle: 'Multiple selection', |
| 64 | + disabled: false, |
| 65 | + help: undefined, |
| 66 | + limit: undefined, |
| 67 | + margin: undefined, |
| 68 | + onOpen: undefined, |
| 69 | + onSearch: undefined, |
| 70 | + open: false, |
| 71 | + options: [ |
| 72 | + 'Extra Small', |
| 73 | + 'Small', |
| 74 | + 'Medium', |
| 75 | + 'Large', |
| 76 | + 'Extra Large', |
| 77 | + 'XXL', |
| 78 | + '3XL', |
| 79 | + '4XL', |
| 80 | + ], |
| 81 | + placeholder: 'Select multiple options', |
| 82 | + searchPlaceholder: 'Search options', |
| 83 | + showSelectedInline: true, |
| 84 | + sortSelectedOnClose: false, |
| 85 | + }, |
| 86 | +} satisfies Story; |
0 commit comments