uikit-react-public 0.51.0 → 0.52.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/dist/components/MultiSelect/MultiSelect.d.ts +4 -0
  2. package/dist/components/MultiSelect/MultiSelect.stories.d.ts +206 -0
  3. package/dist/components/MultiSelect/MultiSelect.types.d.ts +128 -0
  4. package/dist/components/MultiSelect/__tests__/MultiSelect.test.d.ts +1 -0
  5. package/dist/components/MultiSelect/index.d.ts +2 -0
  6. package/dist/components/MultiSelect/subcomponents/CustomOption.d.ts +3 -0
  7. package/dist/components/MultiSelect/subcomponents/CustomSelect.d.ts +4 -0
  8. package/dist/components/MultiSelect/subcomponents/FilterInput.d.ts +16 -0
  9. package/dist/components/MultiSelect/subcomponents/Panel.d.ts +8 -0
  10. package/dist/components/MultiSelect/subcomponents/VisibleField.d.ts +17 -0
  11. package/dist/components/MultiSelect/subcomponents/index.d.ts +5 -0
  12. package/dist/components/index.d.ts +2 -0
  13. package/dist/index.js +963 -498
  14. package/lib/components/MultiSelect/MultiSelect.mdx +151 -0
  15. package/lib/components/MultiSelect/MultiSelect.stories.tsx +308 -0
  16. package/lib/components/MultiSelect/MultiSelect.tsx +24 -0
  17. package/lib/components/MultiSelect/MultiSelect.types.ts +142 -0
  18. package/lib/components/MultiSelect/__tests__/MultiSelect.test.tsx +1300 -0
  19. package/lib/components/MultiSelect/__tests__/__snapshots__/MultiSelect.test.tsx.snap +44 -0
  20. package/lib/components/MultiSelect/index.ts +2 -0
  21. package/lib/components/MultiSelect/subcomponents/CustomOption.tsx +107 -0
  22. package/lib/components/MultiSelect/subcomponents/CustomSelect.tsx +701 -0
  23. package/lib/components/MultiSelect/subcomponents/FilterInput.tsx +90 -0
  24. package/lib/components/MultiSelect/subcomponents/Panel.tsx +69 -0
  25. package/lib/components/MultiSelect/subcomponents/VisibleField.tsx +147 -0
  26. package/lib/components/MultiSelect/subcomponents/index.tsx +5 -0
  27. package/lib/components/index.ts +3 -0
  28. package/package.json +1 -1
@@ -0,0 +1,4 @@
1
+ import { MultiSelectProps } from './MultiSelect.types';
2
+ type MultiSelectComponent = <T extends string | number = string>(props: MultiSelectProps<T>) => React.JSX.Element;
3
+ declare const MultiSelect: MultiSelectComponent;
4
+ export default MultiSelect;
@@ -0,0 +1,206 @@
1
+ import { StoryObj } from '@storybook/react-vite';
2
+ declare const meta: {
3
+ title: string;
4
+ component: <T extends string | number = string>(props: import('./MultiSelect.types.ts').MultiSelectProps<T>) => React.JSX.Element;
5
+ argTypes: {
6
+ options: {
7
+ description: string;
8
+ control: {
9
+ type: "object";
10
+ };
11
+ table: {
12
+ type: {
13
+ summary: string;
14
+ };
15
+ };
16
+ };
17
+ value: {
18
+ description: string;
19
+ control: {
20
+ type: "object";
21
+ };
22
+ table: {
23
+ type: {
24
+ summary: string;
25
+ };
26
+ };
27
+ };
28
+ onValueChange: {
29
+ description: string;
30
+ control: false;
31
+ table: {
32
+ type: {
33
+ summary: string;
34
+ };
35
+ };
36
+ };
37
+ disabled: {
38
+ description: string;
39
+ control: {
40
+ type: "boolean";
41
+ };
42
+ table: {
43
+ type: {
44
+ summary: string;
45
+ };
46
+ };
47
+ };
48
+ placeholder: {
49
+ description: string;
50
+ control: {
51
+ type: "text";
52
+ };
53
+ table: {
54
+ type: {
55
+ summary: string;
56
+ };
57
+ };
58
+ };
59
+ selectionCountLabel: {
60
+ description: string;
61
+ control: {
62
+ type: "text";
63
+ };
64
+ table: {
65
+ type: {
66
+ summary: string;
67
+ };
68
+ };
69
+ };
70
+ filterable: {
71
+ description: string;
72
+ control: {
73
+ type: "boolean";
74
+ };
75
+ table: {
76
+ type: {
77
+ summary: string;
78
+ };
79
+ };
80
+ };
81
+ clearable: {
82
+ description: string;
83
+ control: {
84
+ type: "boolean";
85
+ };
86
+ table: {
87
+ type: {
88
+ summary: string;
89
+ };
90
+ };
91
+ };
92
+ filterInputProps: {
93
+ description: string;
94
+ control: {
95
+ type: "object";
96
+ };
97
+ table: {
98
+ type: {
99
+ summary: string;
100
+ };
101
+ };
102
+ };
103
+ id: {
104
+ description: string;
105
+ control: {
106
+ type: "text";
107
+ };
108
+ table: {
109
+ type: {
110
+ summary: string;
111
+ };
112
+ };
113
+ };
114
+ title: {
115
+ description: string;
116
+ control: {
117
+ type: "text";
118
+ };
119
+ table: {
120
+ type: {
121
+ summary: string;
122
+ };
123
+ };
124
+ };
125
+ lineBreak: {
126
+ description: string;
127
+ control: {
128
+ type: "boolean";
129
+ };
130
+ table: {
131
+ type: {
132
+ summary: string;
133
+ };
134
+ };
135
+ };
136
+ dropdownWidth: {
137
+ description: string;
138
+ control: {
139
+ type: "radio";
140
+ };
141
+ options: string[];
142
+ table: {
143
+ type: {
144
+ summary: string;
145
+ };
146
+ };
147
+ };
148
+ panelClassName: {
149
+ description: string;
150
+ control: {
151
+ type: "text";
152
+ };
153
+ table: {
154
+ type: {
155
+ summary: string;
156
+ };
157
+ };
158
+ };
159
+ className: {
160
+ description: string;
161
+ control: {
162
+ type: "text";
163
+ };
164
+ table: {
165
+ type: {
166
+ summary: string;
167
+ };
168
+ };
169
+ };
170
+ testId: {
171
+ description: string;
172
+ control: {
173
+ type: "text";
174
+ };
175
+ table: {
176
+ type: {
177
+ summary: string;
178
+ };
179
+ };
180
+ };
181
+ };
182
+ args: {
183
+ value: undefined;
184
+ selectionCountLabel: string;
185
+ options: {
186
+ label: string;
187
+ value: string;
188
+ }[];
189
+ };
190
+ parameters: {
191
+ docs: {
192
+ story: {
193
+ inline: boolean;
194
+ };
195
+ };
196
+ };
197
+ };
198
+ export default meta;
199
+ type Story = StoryObj<typeof meta>;
200
+ export declare const Default: Story;
201
+ export declare const Disabled: Story;
202
+ export declare const WithPlaceholder: Story;
203
+ export declare const SingleLongOption: Story;
204
+ export declare const ManyOptions: Story;
205
+ export declare const filterable: Story;
206
+ export declare const Clearable: Story;
@@ -0,0 +1,128 @@
1
+ /**
2
+ * Represents an 'option' in the <Select>
3
+ * Maps to a native <option> element in <NativeSelect>
4
+ * or a <CustomOption> in <CustomSelect>
5
+ */
6
+ export type OptionData<T> = {
7
+ /**
8
+ * Display text shown to the user
9
+ */
10
+ label: string;
11
+ /**
12
+ * Data-friendly value that is returned when the option is selected
13
+ * We assume this will be submitted to a server or used in some other way
14
+ */
15
+ value: T;
16
+ /**
17
+ * Apply additional props to a select option component.
18
+ */
19
+ optionProps?: Record<string, unknown>;
20
+ /**
21
+ Deprecated
22
+ */
23
+ icon?: React.ReactNode;
24
+ };
25
+ /**
26
+ * Additional props forwarded to the filter input when `filterable` is true
27
+ */
28
+ export type FilterInputProps = Omit<React.InputHTMLAttributes<HTMLInputElement>, 'value' | 'onChange' | 'disabled' | 'ref' | 'role' | 'aria-autocomplete'>;
29
+ export type SelectDropdownWidth = 'content' | 'match-select';
30
+ type MultiSelectBaseProps<T = string | number> = Omit<React.HTMLAttributes<HTMLElement>, 'onChange'> & {
31
+ /**
32
+ * An array of option data, to be rendered either natively or custom
33
+ */
34
+ options: OptionData<T>[];
35
+ /**
36
+ * Placeholder text shown when no option is selected
37
+ * Displayed in visible field of custom implementation
38
+ * or as a disabled option in the native implementation
39
+ */
40
+ placeholder?: string;
41
+ /**
42
+ * Specify a specific width if the default (325px) is not suitable
43
+ */
44
+ width?: number;
45
+ /**
46
+ * Test ID for testing purposes
47
+ * This is passed to the root element of the component
48
+ * as `data-testid`
49
+ */
50
+ testId?: string;
51
+ /**
52
+ * Adds a text input to filter options in the custom variant;
53
+ */
54
+ filterable?: boolean;
55
+ /**
56
+ * Extra props to apply to the filter input when `filterable` is true
57
+ */
58
+ filterInputProps?: FilterInputProps;
59
+ /** * Noun used in the selection summary shown when 3 or more options are selected, * e.g. passing "items" shows "3 items selected" * @default 'selected' */
60
+ selectionCountLabel?: string;
61
+ /**
62
+ * Disable interaction
63
+ */
64
+ disabled?: boolean;
65
+ /**
66
+ * Allow long option labels to wrap instead of truncating
67
+ */
68
+ lineBreak?: boolean;
69
+ /**
70
+ * Controls the width of the custom options panel.
71
+ * - `content` (default): panel is at least the Select width and can grow to fit option labels.
72
+ * - `match-select`: panel width is capped to the Select width.
73
+ */
74
+ dropdownWidth?: SelectDropdownWidth;
75
+ /**
76
+ * Custom className for the root element
77
+ */
78
+ className?: string;
79
+ /**
80
+ * Custom className for the options panel
81
+ */
82
+ panelClassName?: string;
83
+ /**
84
+ * Custom className for the custom select visible field
85
+ */
86
+ visibleFieldClassName?: string;
87
+ /**
88
+ * Custom className for each custom select option
89
+ */
90
+ optionClassName?: string;
91
+ /**
92
+ * Custom className for the custom select chevron icon
93
+ */
94
+ chevronIconClassName?: string;
95
+ /**
96
+ * Ref forwarded to the rendered element
97
+ * (div for custom)
98
+ */
99
+ ref?: React.Ref<HTMLDivElement | HTMLSelectElement | null>;
100
+ };
101
+ export type MultiSelectProps<T = string | number> = MultiSelectBaseProps<T> & {
102
+ /**
103
+ * Current value (controlled) - array of selected values
104
+ */
105
+ value?: T[];
106
+ /**
107
+ * Show a clear action in the custom variant when a value is selected
108
+ */
109
+ clearable?: boolean;
110
+ /**
111
+ * Change handler for the custom variant
112
+ */
113
+ onValueChange?: (value: T[], ev: React.SyntheticEvent) => void;
114
+ };
115
+ export type InternalMultiSelectProps<T = string | number> = MultiSelectProps<T>;
116
+ /**
117
+ * Each option as displayed in the Panel of <CustomSelect>
118
+ * Roughly equivalent to a custom version of <option>
119
+ */
120
+ export interface CustomOptionProps<T> extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onSelect'> {
121
+ value: T;
122
+ testId?: string;
123
+ isSelected?: boolean;
124
+ isActive?: boolean;
125
+ onSelect: (event: React.MouseEvent, value: T) => void;
126
+ lineBreak?: boolean;
127
+ }
128
+ export {};
@@ -0,0 +1,2 @@
1
+ export { default } from './MultiSelect.tsx';
2
+ export type { MultiSelectProps, OptionData } from './MultiSelect.types';
@@ -0,0 +1,3 @@
1
+ import { CustomOptionProps } from '../MultiSelect.types';
2
+ declare const CustomOption: <T extends string | number>({ value, isSelected, isActive, onSelect, lineBreak, testId, className, children, ...props }: CustomOptionProps<T>) => import('react').JSX.Element;
3
+ export default CustomOption;
@@ -0,0 +1,4 @@
1
+ import { InternalMultiSelectProps } from '../MultiSelect.types';
2
+ type CustomSelectProps<T> = InternalMultiSelectProps<T>;
3
+ declare const CustomSelect: <T extends string | number>({ value, options, onValueChange, disabled, width, clearable, placeholder, selectionCountLabel, lineBreak, dropdownWidth, filterInputProps, testId, className, panelClassName, visibleFieldClassName, optionClassName, chevronIconClassName, filterable, ref, ...props }: CustomSelectProps<T>) => import('react').JSX.Element;
4
+ export default CustomSelect;
@@ -0,0 +1,16 @@
1
+ import { FilterInputProps } from '../MultiSelect.types';
2
+ type FilterInputComponentProps = {
3
+ value: string;
4
+ onChange: (value: string) => void;
5
+ onBlur?: (event: React.FocusEvent<HTMLInputElement>) => void;
6
+ onTabOut?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
7
+ placeholder?: string;
8
+ disabled?: boolean;
9
+ inputRef?: React.RefObject<HTMLInputElement | null>;
10
+ className?: string;
11
+ ariaControls?: string;
12
+ ariaExpanded?: boolean;
13
+ ariaActiveDescendant?: string;
14
+ } & FilterInputProps;
15
+ declare const FilterInput: ({ value, onChange, onBlur, onTabOut, placeholder, disabled, inputRef, className, ariaControls, ariaExpanded, ariaActiveDescendant, ...rest }: FilterInputComponentProps) => import('react').JSX.Element;
16
+ export default FilterInput;
@@ -0,0 +1,8 @@
1
+ import { SelectDropdownWidth } from '../MultiSelect.types';
2
+ type PanelProps = React.ComponentPropsWithoutRef<'div'> & {
3
+ dropdownWidth?: SelectDropdownWidth;
4
+ referenceWidth?: number;
5
+ maxWidth?: number;
6
+ };
7
+ declare const Panel: ({ className, dropdownWidth, referenceWidth, maxWidth, ...props }: PanelProps) => import('react').JSX.Element;
8
+ export default Panel;
@@ -0,0 +1,17 @@
1
+ import { OptionData } from '../MultiSelect.types';
2
+ interface VisibleFieldProps<T> {
3
+ isOpen?: boolean;
4
+ disabled?: boolean;
5
+ selectedOptions: OptionData<T>[];
6
+ placeholder?: string;
7
+ selectionCountLabel?: string;
8
+ filterable?: boolean;
9
+ clearable?: boolean;
10
+ onClear?: (event: React.MouseEvent | React.KeyboardEvent) => void;
11
+ clearButtonRef?: React.RefObject<HTMLButtonElement | null>;
12
+ className?: string;
13
+ chevronIconClassName?: string;
14
+ children?: React.ReactNode;
15
+ }
16
+ declare const VisibleField: <T extends string | number>({ selectedOptions, isOpen, placeholder, selectionCountLabel, disabled, filterable, clearable, onClear, clearButtonRef, className, chevronIconClassName, children, }: VisibleFieldProps<T>) => import('react').JSX.Element;
17
+ export default VisibleField;
@@ -0,0 +1,5 @@
1
+ export { default as CustomSelect } from './CustomSelect';
2
+ export { default as CustomOption } from './CustomOption';
3
+ export { default as Panel } from './Panel';
4
+ export { default as VisibleField } from './VisibleField';
5
+ export { default as FilterInput } from './FilterInput';
@@ -91,6 +91,8 @@ export { default as MenuNew } from './MenuNew';
91
91
  export type { MenuProps as MenuNewProps } from './MenuNew';
92
92
  export { default as Select } from './Select';
93
93
  export type { SelectProps } from './Select';
94
+ export { default as MultiSelect } from './MultiSelect';
95
+ export type { MultiSelectProps } from './MultiSelect';
94
96
  export { default as Footer } from './Footer';
95
97
  export type { FooterProps } from './Footer';
96
98
  export { default as FooterNew } from './FooterNew';