@lumx/react 3.20.1-alpha.36 → 3.20.1-alpha.37

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 (105) hide show
  1. package/index.js +13990 -64
  2. package/index.js.map +1 -0
  3. package/package.json +3 -3
  4. package/utils/index.js +159 -3
  5. package/utils/index.js.map +1 -0
  6. package/_internal/035c132d.js +0 -314
  7. package/_internal/0b9c76cb.js +0 -5
  8. package/_internal/0ea95af1.js +0 -819
  9. package/_internal/230173a8.js +0 -12
  10. package/_internal/2a3d237c.js +0 -11
  11. package/_internal/2c2b6a89.js +0 -51
  12. package/_internal/3181f000.js +0 -13
  13. package/_internal/36bd7352.js +0 -218
  14. package/_internal/3864a6c1.js +0 -436
  15. package/_internal/3a1facc0.js +0 -17
  16. package/_internal/49bbeed3.js +0 -5
  17. package/_internal/4daccdd5.js +0 -24
  18. package/_internal/4f4c0582.js +0 -2169
  19. package/_internal/5cef5e8c.js +0 -74
  20. package/_internal/6a60381c.js +0 -117
  21. package/_internal/6f084a40.js +0 -111
  22. package/_internal/76ddefd4.js +0 -61
  23. package/_internal/78df9309.js +0 -19
  24. package/_internal/7ad474e4.js +0 -98
  25. package/_internal/7b293665.js +0 -19
  26. package/_internal/7daf0f24.js +0 -76
  27. package/_internal/825ac334.js +0 -129
  28. package/_internal/827b804a.js +0 -5
  29. package/_internal/8bce732e.js +0 -8
  30. package/_internal/9d1336a1.js +0 -18
  31. package/_internal/a38bdcd0.js +0 -49
  32. package/_internal/b326655a.js +0 -682
  33. package/_internal/b83e864b.js +0 -76
  34. package/_internal/bace1bf1.js +0 -103
  35. package/_internal/c57190eb.js +0 -146
  36. package/_internal/components/alert-dialog/index-284fed80.js +0 -163
  37. package/_internal/components/autocomplete/__mockData__/index-96fc7ea7.js +0 -27
  38. package/_internal/components/autocomplete/index-27a49d5d.js +0 -261
  39. package/_internal/components/avatar/index-b8bc3cae.js +0 -83
  40. package/_internal/components/badge/index-9880f056.js +0 -81
  41. package/_internal/components/button/index-d919f96d.js +0 -47
  42. package/_internal/components/checkbox/index-dd478de9.js +0 -143
  43. package/_internal/components/chip/index-7f84cdbd.js +0 -102
  44. package/_internal/components/comment-block/index-e942de30.js +0 -138
  45. package/_internal/components/date-picker/index-a258d3ce.js +0 -596
  46. package/_internal/components/dialog/index-c7066813.js +0 -238
  47. package/_internal/components/divider/index-b6934baf.js +0 -50
  48. package/_internal/components/drag-handle/index-80e5af6c.js +0 -52
  49. package/_internal/components/dropdown/index-cebfc268.js +0 -147
  50. package/_internal/components/expansion-panel/index-9d45a211.js +0 -167
  51. package/_internal/components/flag/index-33e9d909.js +0 -59
  52. package/_internal/components/flex-box/index-0d6b6b43.js +0 -56
  53. package/_internal/components/generic-block/index-836c4352.js +0 -124
  54. package/_internal/components/grid/index-8c16a4f1.js +0 -104
  55. package/_internal/components/grid-column/index-4a2f56bb.js +0 -59
  56. package/_internal/components/heading/index-fd558a9a.js +0 -53
  57. package/_internal/components/icon/index-e7b9b40e.js +0 -1
  58. package/_internal/components/image-block/index-7021c2f1.js +0 -110
  59. package/_internal/components/image-lightbox/index-27017547.js +0 -759
  60. package/_internal/components/inline-list/index-52efec7f.js +0 -74
  61. package/_internal/components/input-helper/index-5a837e7c.js +0 -71
  62. package/_internal/components/input-label/index-0113f382.js +0 -59
  63. package/_internal/components/lightbox/index-fad5a9f2.js +0 -155
  64. package/_internal/components/link/index-008bae4b.js +0 -72
  65. package/_internal/components/link-preview/index-3e9c32f2.js +0 -117
  66. package/_internal/components/list/index-da88c6e9.js +0 -71
  67. package/_internal/components/message/index-17b568f2.js +0 -98
  68. package/_internal/components/mosaic/index-2d40e01c.js +0 -95
  69. package/_internal/components/navigation/index-dc17c639.js +0 -225
  70. package/_internal/components/notification/index-a1101015.js +0 -146
  71. package/_internal/components/popover/index-dbca63f1.js +0 -2
  72. package/_internal/components/popover-dialog/index-654d2abc.js +0 -66
  73. package/_internal/components/post-block/index-4b6b4dcb.js +0 -109
  74. package/_internal/components/progress/index-6f578c31.js +0 -182
  75. package/_internal/components/progress-tracker/index-700bc4c2.js +0 -309
  76. package/_internal/components/radio-button/index-89b725af.js +0 -149
  77. package/_internal/components/select/index-2755aa32.js +0 -458
  78. package/_internal/components/side-navigation/index-0bbe1fdd.js +0 -165
  79. package/_internal/components/skeleton/index-b2f8501c.js +0 -166
  80. package/_internal/components/slider/index-4f9b891b.js +0 -311
  81. package/_internal/components/slideshow/index-d4604589.js +0 -150
  82. package/_internal/components/switch/index-58fe0f0c.js +0 -122
  83. package/_internal/components/table/index-d541aa88.js +0 -297
  84. package/_internal/components/tabs/index-af1538d6.js +0 -298
  85. package/_internal/components/text/index-5bfc6d5e.js +0 -1
  86. package/_internal/components/text-field/index-47c98d09.js +0 -360
  87. package/_internal/components/thumbnail/index-71545d95.js +0 -41
  88. package/_internal/components/toolbar/index-7041a5a6.js +0 -61
  89. package/_internal/components/tooltip/index-8bb97e60.js +0 -327
  90. package/_internal/components/uploader/index-8f6f55de.js +0 -153
  91. package/_internal/components/user-block/index-70d4ce8f.js +0 -145
  92. package/_internal/d0e3f49e.js +0 -23
  93. package/_internal/de24f857.js +0 -3
  94. package/_internal/e806b848.js +0 -8
  95. package/_internal/e913a3af.js +0 -117
  96. package/_internal/ea04260d.js +0 -28
  97. package/_internal/eaf6c45a.js +0 -3
  98. package/_internal/ebdcb0c7.js +0 -60
  99. package/_internal/ef5d1aac.js +0 -3
  100. package/_internal/f0d7d6ea.js +0 -29
  101. package/_internal/utils/ClickAwayProvider/index-1234ce76.js +0 -94
  102. package/_internal/utils/MaterialThemeSwitcher/index-8d22de5a.js +0 -48
  103. package/_internal/utils/Portal/index-6e0a7404.js +0 -44
  104. package/_internal/utils/disabled/index-075b99c3.js +0 -36
  105. package/_internal/utils/type/index-ea9fc197.js +0 -2
@@ -1,149 +0,0 @@
1
- import classNames from 'classnames';
2
- import { getRootClassName, handleBasicClasses } from '@lumx/core/js/utils/className';
3
- import { u as useId } from '../../3a1facc0.js';
4
- import { u as useTheme } from '../../3181f000.js';
5
- import { f as forwardRef } from '../../8bce732e.js';
6
- import { useDisableStateProps } from '../../utils/disabled/index-075b99c3.js';
7
- import { jsxs, jsx } from 'react/jsx-runtime';
8
- import { Theme } from '@lumx/core/js/constants';
9
- import { InputLabel } from '../input-label/index-0113f382.js';
10
- import { InputHelper } from '../input-helper/index-5a837e7c.js';
11
-
12
- /**
13
- * Component display name.
14
- */
15
- const COMPONENT_NAME$1 = 'RadioButton';
16
-
17
- /**
18
- * Component default class name and class prefix.
19
- */
20
- const CLASSNAME$1 = getRootClassName(COMPONENT_NAME$1);
21
-
22
- /**
23
- * Component default props.
24
- */
25
- const DEFAULT_PROPS = {};
26
-
27
- /**
28
- * RadioButton component.
29
- *
30
- * @param props Component props.
31
- * @param ref Component ref.
32
- * @return React element.
33
- */
34
- const RadioButton = forwardRef((props, ref) => {
35
- const {
36
- isAnyDisabled,
37
- disabledStateProps,
38
- otherProps
39
- } = useDisableStateProps(props);
40
- const defaultTheme = useTheme() || Theme.light;
41
- const {
42
- checked,
43
- className,
44
- helper,
45
- id,
46
- inputRef,
47
- isChecked = checked,
48
- label,
49
- name,
50
- onChange,
51
- theme = defaultTheme,
52
- value,
53
- inputProps,
54
- ...forwardedProps
55
- } = otherProps;
56
- const generatedInputId = useId();
57
- const inputId = id || generatedInputId;
58
- const handleChange = event => {
59
- if (onChange) {
60
- onChange(value, name, event);
61
- }
62
- };
63
- return /*#__PURE__*/jsxs("div", {
64
- ref: ref,
65
- ...forwardedProps,
66
- className: classNames(className, handleBasicClasses({
67
- isChecked,
68
- isDisabled: isAnyDisabled,
69
- isUnchecked: !isChecked,
70
- prefix: CLASSNAME$1,
71
- theme
72
- })),
73
- children: [/*#__PURE__*/jsxs("div", {
74
- className: `${CLASSNAME$1}__input-wrapper`,
75
- children: [/*#__PURE__*/jsx("input", {
76
- ref: inputRef,
77
- className: `${CLASSNAME$1}__input-native`,
78
- ...disabledStateProps,
79
- id: inputId,
80
- type: "radio",
81
- name: name,
82
- value: value,
83
- checked: isChecked,
84
- onChange: handleChange,
85
- readOnly: inputProps?.readOnly || isAnyDisabled,
86
- "aria-describedby": helper ? `${inputId}-helper` : undefined,
87
- ...inputProps
88
- }), /*#__PURE__*/jsxs("div", {
89
- className: `${CLASSNAME$1}__input-placeholder`,
90
- children: [/*#__PURE__*/jsx("div", {
91
- className: `${CLASSNAME$1}__input-background`
92
- }), /*#__PURE__*/jsx("div", {
93
- className: `${CLASSNAME$1}__input-indicator`
94
- })]
95
- })]
96
- }), /*#__PURE__*/jsxs("div", {
97
- className: `${CLASSNAME$1}__content`,
98
- children: [label && /*#__PURE__*/jsx(InputLabel, {
99
- htmlFor: inputId,
100
- theme: theme,
101
- className: `${CLASSNAME$1}__label`,
102
- children: label
103
- }), helper && /*#__PURE__*/jsx(InputHelper, {
104
- id: `${inputId}-helper`,
105
- theme: theme,
106
- className: `${CLASSNAME$1}__helper`,
107
- children: helper
108
- })]
109
- })]
110
- });
111
- });
112
- RadioButton.displayName = COMPONENT_NAME$1;
113
- RadioButton.className = CLASSNAME$1;
114
- RadioButton.defaultProps = DEFAULT_PROPS;
115
-
116
- /**
117
- * Component display name.
118
- */
119
- const COMPONENT_NAME = 'RadioGroup';
120
-
121
- /**
122
- * Component default class name and class prefix.
123
- */
124
- const CLASSNAME = getRootClassName(COMPONENT_NAME);
125
-
126
- /**
127
- * RadioGroup component.
128
- *
129
- * @param props Component props.
130
- * @param ref Component ref.
131
- * @return React element.
132
- */
133
- const RadioGroup = forwardRef((props, ref) => {
134
- const {
135
- children,
136
- className,
137
- ...forwardedProps
138
- } = props;
139
- return /*#__PURE__*/jsx("div", {
140
- ref: ref,
141
- ...forwardedProps,
142
- className: classNames(className, CLASSNAME),
143
- children: children
144
- });
145
- });
146
- RadioGroup.displayName = COMPONENT_NAME;
147
- RadioGroup.className = CLASSNAME;
148
-
149
- export { RadioButton, RadioGroup };
@@ -1,458 +0,0 @@
1
- import classNames from 'classnames';
2
- import isEmpty from 'lodash/isEmpty';
3
- import { Theme, Kind, Size, Emphasis } from '@lumx/core/js/constants';
4
- import { I as IconButton } from '../../b83e864b.js';
5
- import { C as Chip } from '../../c57190eb.js';
6
- import { I as Icon, m as mdiAlertCircle } from '../../bace1bf1.js';
7
- import { InputLabel } from '../input-label/index-0113f382.js';
8
- import { getRootClassName, handleBasicClasses } from '@lumx/core/js/utils/className';
9
- import { m as mergeRefs } from '../../f0d7d6ea.js';
10
- import { f as forwardRef } from '../../8bce732e.js';
11
- import { u as useTheme } from '../../3181f000.js';
12
- import { useState, useEffect, useRef, useCallback } from 'react';
13
- import { Dropdown } from '../dropdown/index-cebfc268.js';
14
- import { InputHelper } from '../input-helper/index-5a837e7c.js';
15
- import { u as useFocusTrap } from '../../6f084a40.js';
16
- import { u as useId } from '../../3a1facc0.js';
17
- import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
18
- import { P as Placement } from '../../4f4c0582.js';
19
- import { m as mdiCloseCircle } from '../../ef5d1aac.js';
20
- import { m as mdiCheckCircle } from '../../de24f857.js';
21
- import { m as mdiClose } from '../../eaf6c45a.js';
22
-
23
- const mdiMenuDown = 'm7 10 5 5 5-5z';
24
-
25
- /**
26
- * Listen on element focus to store the focus status.
27
- */
28
- function useListenFocus(ref) {
29
- const [isFocus, setFocus] = useState(false);
30
- useEffect(() => {
31
- const {
32
- current: element
33
- } = ref;
34
- if (!element) {
35
- return undefined;
36
- }
37
- const onFocus = () => setFocus(true);
38
- const onBlur = () => setFocus(false);
39
- element.addEventListener('focus', onFocus);
40
- element.addEventListener('blur', onBlur);
41
- return () => {
42
- element.removeEventListener('focus', onFocus);
43
- element.removeEventListener('blur', onBlur);
44
- };
45
- }, [ref, setFocus]);
46
- return isFocus;
47
- }
48
-
49
- /** The display name of the component. */
50
- const COMPONENT_NAME$2 = 'Select';
51
-
52
- /** The default class name and classes prefix for this component. */
53
- const CLASSNAME$2 = getRootClassName(COMPONENT_NAME$2);
54
- const WithSelectContext = (SelectElement, props, ref) => {
55
- const defaultTheme = useTheme() || Theme.light;
56
- const {
57
- children,
58
- className,
59
- focusElement,
60
- isMultiple,
61
- closeOnClick = !isMultiple,
62
- disabled,
63
- error,
64
- hasError,
65
- helper,
66
- id,
67
- isDisabled = disabled,
68
- isEmpty,
69
- isOpen,
70
- isRequired,
71
- isValid,
72
- label,
73
- onClear,
74
- onDropdownClose,
75
- onInfiniteScroll,
76
- onInputClick,
77
- placeholder,
78
- theme = defaultTheme,
79
- value,
80
- variant,
81
- ...forwardedProps
82
- } = props;
83
- const generatedSelectId = useId();
84
- const selectId = id || generatedSelectId;
85
- const anchorRef = useRef(null);
86
- const selectRef = useRef(null);
87
- const dropdownRef = useRef(null);
88
- const isFocus = useListenFocus(anchorRef);
89
- const handleKeyboardNav = useCallback(evt => {
90
- if ((evt.key === 'Enter' || evt.key === ' ' || evt.key === 'ArrowDown') && onInputClick) {
91
- evt.preventDefault();
92
- onInputClick();
93
- }
94
- }, [onInputClick]);
95
- const onClose = () => {
96
- if (onDropdownClose) {
97
- onDropdownClose();
98
- }
99
- anchorRef?.current?.blur();
100
- };
101
-
102
- // Handle focus trap.
103
- useFocusTrap(isOpen && dropdownRef.current, focusElement?.current);
104
- return /*#__PURE__*/jsxs("div", {
105
- ref: mergeRefs(ref, selectRef),
106
- className: classNames(className, handleBasicClasses({
107
- hasError,
108
- hasLabel: Boolean(label),
109
- hasPlaceholder: Boolean(placeholder),
110
- hasValue: !isEmpty,
111
- isDisabled,
112
- isEmpty,
113
- isFocus,
114
- isOpen,
115
- isValid,
116
- prefix: CLASSNAME$2,
117
- theme: theme === Theme.light ? Theme.light : Theme.dark
118
- })),
119
- children: [/*#__PURE__*/jsx(SelectElement, {
120
- ...forwardedProps,
121
- anchorRef: anchorRef,
122
- "aria-disabled": isDisabled,
123
- handleKeyboardNav: handleKeyboardNav,
124
- hasError: hasError,
125
- isDisabled: isDisabled,
126
- isEmpty: isEmpty,
127
- isRequired: isRequired,
128
- isValid: isValid,
129
- label: label,
130
- placeholder: placeholder,
131
- id: selectId,
132
- theme: theme,
133
- value: value,
134
- variant: variant,
135
- onClear: onClear,
136
- onInputClick: onInputClick
137
- }), /*#__PURE__*/jsx(Dropdown, {
138
- anchorRef: anchorRef,
139
- closeOnClick: closeOnClick,
140
- closeOnClickAway: true,
141
- closeOnEscape: true,
142
- isOpen: !!isOpen,
143
- placement: Placement.BOTTOM_START,
144
- onClose: onClose,
145
- onInfiniteScroll: onInfiniteScroll,
146
- ref: dropdownRef,
147
- children: children
148
- }), hasError && error && /*#__PURE__*/jsx(InputHelper, {
149
- className: `${CLASSNAME$2}__helper`,
150
- kind: Kind.error,
151
- theme: theme,
152
- children: error
153
- }), helper && /*#__PURE__*/jsx(InputHelper, {
154
- className: `${CLASSNAME$2}__helper`,
155
- theme: theme,
156
- children: helper
157
- })]
158
- });
159
- };
160
-
161
- /**
162
- * Select variants.
163
- */
164
- const SelectVariant = {
165
- input: 'input',
166
- chip: 'chip'
167
- };
168
-
169
- /** The display name of the component. */
170
- const COMPONENT_NAME$1 = 'Select';
171
-
172
- /** The default class name and classes prefix for this component. */
173
- const CLASSNAME$1 = getRootClassName(COMPONENT_NAME$1);
174
-
175
- /** The default value of props. */
176
- const DEFAULT_PROPS$1 = {
177
- selectedValueRender: choice => choice,
178
- variant: SelectVariant.input
179
- };
180
- const stopPropagation = evt => evt.stopPropagation();
181
-
182
- /**
183
- * Select component.
184
- */
185
- const SelectField = props => {
186
- const defaultTheme = useTheme();
187
- const {
188
- anchorRef,
189
- clearButtonProps,
190
- handleKeyboardNav,
191
- hasError,
192
- hasInputClear,
193
- icon,
194
- id,
195
- isDisabled,
196
- isEmpty,
197
- isRequired,
198
- isValid,
199
- label,
200
- onClear,
201
- onInputClick,
202
- placeholder,
203
- selectedValueRender,
204
- theme = defaultTheme,
205
- value,
206
- variant,
207
- selectElementRef,
208
- ...forwardedProps
209
- } = props;
210
- return /*#__PURE__*/jsxs(Fragment, {
211
- children: [variant === SelectVariant.input && /*#__PURE__*/jsxs(Fragment, {
212
- children: [label && /*#__PURE__*/jsx("div", {
213
- className: `${CLASSNAME$1}__header`,
214
- children: /*#__PURE__*/jsx(InputLabel, {
215
- htmlFor: id,
216
- className: `${CLASSNAME$1}__label`,
217
- isRequired: isRequired,
218
- theme: theme,
219
- children: label
220
- })
221
- }), /*#__PURE__*/jsxs("div", {
222
- ref: mergeRefs(anchorRef, selectElementRef),
223
- id: id,
224
- className: `${CLASSNAME$1}__wrapper`,
225
- onClick: onInputClick,
226
- onKeyDown: handleKeyboardNav,
227
- tabIndex: isDisabled ? undefined : 0,
228
- "aria-disabled": isDisabled || undefined,
229
- ...forwardedProps,
230
- children: [icon && /*#__PURE__*/jsx(Icon, {
231
- className: `${CLASSNAME$1}__input-icon`,
232
- color: theme === Theme.dark ? 'light' : undefined,
233
- icon: icon,
234
- size: Size.xs
235
- }), /*#__PURE__*/jsxs("div", {
236
- className: classNames([`${CLASSNAME$1}__input-native`, isEmpty && placeholder && `${CLASSNAME$1}__input-native--placeholder`]),
237
- children: [!isEmpty && /*#__PURE__*/jsx("span", {
238
- children: selectedValueRender?.(value)
239
- }), isEmpty && placeholder && /*#__PURE__*/jsx("span", {
240
- children: placeholder
241
- })]
242
- }), (isValid || hasError) && /*#__PURE__*/jsx("div", {
243
- className: `${CLASSNAME$1}__input-validity`,
244
- children: /*#__PURE__*/jsx(Icon, {
245
- icon: isValid ? mdiCheckCircle : mdiAlertCircle,
246
- size: Size.xxs
247
- })
248
- }), hasInputClear && clearButtonProps && /*#__PURE__*/jsx(IconButton, {
249
- ...clearButtonProps,
250
- className: `${CLASSNAME$1}__input-clear`,
251
- icon: mdiCloseCircle,
252
- emphasis: Emphasis.low,
253
- size: Size.s,
254
- theme: theme,
255
- onClick: onClear,
256
- onKeyDown: stopPropagation
257
- }), /*#__PURE__*/jsx("div", {
258
- className: `${CLASSNAME$1}__input-indicator`,
259
- children: /*#__PURE__*/jsx(Icon, {
260
- icon: mdiMenuDown,
261
- size: Size.s
262
- })
263
- })]
264
- })]
265
- }), variant === SelectVariant.chip && /*#__PURE__*/jsxs(Chip, {
266
- id: id,
267
- isSelected: !isEmpty,
268
- isDisabled: isDisabled,
269
- after: /*#__PURE__*/jsx(Icon, {
270
- icon: isEmpty ? mdiMenuDown : mdiCloseCircle
271
- }),
272
- onAfterClick: isEmpty ? onInputClick : onClear,
273
- onClick: onInputClick,
274
- ref: mergeRefs(anchorRef, selectElementRef),
275
- theme: theme,
276
- ...forwardedProps,
277
- children: [isEmpty && /*#__PURE__*/jsx("span", {
278
- children: label
279
- }), !isEmpty && /*#__PURE__*/jsx("span", {
280
- children: selectedValueRender?.(value)
281
- })]
282
- })]
283
- });
284
- };
285
-
286
- /**
287
- * Select component.
288
- *
289
- * @param props Component props.
290
- * @param ref Component ref.
291
- * @return React element.
292
- */
293
- const Select = forwardRef((props, ref) => {
294
- const isEmpty$1 = isEmpty(props.value);
295
- const hasInputClear = props.onClear && props.clearButtonProps && !isEmpty$1;
296
- return WithSelectContext(SelectField, {
297
- ...DEFAULT_PROPS$1,
298
- ...props,
299
- className: classNames(props.className, handleBasicClasses({
300
- hasInputClear,
301
- hasUnique: !props.isEmpty,
302
- prefix: CLASSNAME$1
303
- })),
304
- hasInputClear,
305
- isEmpty: isEmpty$1
306
- }, ref);
307
- });
308
- Select.displayName = COMPONENT_NAME$1;
309
- Select.className = CLASSNAME$1;
310
- Select.defaultProps = DEFAULT_PROPS$1;
311
- Select.className = CLASSNAME$1;
312
-
313
- /** The display name of the component. */
314
- const COMPONENT_NAME = 'Select';
315
-
316
- /** The default class name and classes prefix for this component. */
317
- const CLASSNAME = getRootClassName(COMPONENT_NAME);
318
-
319
- /** The default value of props. */
320
- const DEFAULT_PROPS = {
321
- selectedChipRender(choice, index, onClear, isDisabled, theme) {
322
- const onClick = event => onClear && onClear(event, choice);
323
- return /*#__PURE__*/jsx(Chip, {
324
- after: onClear && /*#__PURE__*/jsx(Icon, {
325
- icon: mdiClose,
326
- size: Size.xxs
327
- }),
328
- isDisabled: isDisabled,
329
- size: Size.s,
330
- onAfterClick: onClick,
331
- onClick: onClick,
332
- theme: theme,
333
- children: choice
334
- }, index);
335
- },
336
- selectedValueRender: choice => choice,
337
- variant: SelectVariant.input
338
- };
339
- const SelectMultipleField = props => {
340
- const defaultTheme = useTheme();
341
- const {
342
- anchorRef,
343
- handleKeyboardNav,
344
- hasError,
345
- icon,
346
- id,
347
- isDisabled,
348
- isEmpty,
349
- isRequired,
350
- isValid,
351
- label,
352
- onClear,
353
- onInputClick,
354
- placeholder,
355
- selectedChipRender,
356
- selectedValueRender,
357
- theme = defaultTheme,
358
- value,
359
- variant,
360
- selectElementRef,
361
- ...forwardedProps
362
- } = props;
363
- return /*#__PURE__*/jsxs(Fragment, {
364
- children: [variant === SelectVariant.input && /*#__PURE__*/jsxs(Fragment, {
365
- children: [label && /*#__PURE__*/jsx("div", {
366
- className: `${CLASSNAME}__header`,
367
- children: /*#__PURE__*/jsx(InputLabel, {
368
- htmlFor: id,
369
- className: `${CLASSNAME}__label`,
370
- isRequired: isRequired,
371
- theme: theme,
372
- children: label
373
- })
374
- }), /*#__PURE__*/jsxs("div", {
375
- ref: mergeRefs(anchorRef, selectElementRef),
376
- id: id,
377
- className: `${CLASSNAME}__wrapper`,
378
- onClick: onInputClick,
379
- onKeyDown: handleKeyboardNav,
380
- tabIndex: isDisabled ? undefined : 0,
381
- "aria-disabled": isDisabled || undefined,
382
- ...forwardedProps,
383
- children: [icon && /*#__PURE__*/jsx(Icon, {
384
- className: `${CLASSNAME}__input-icon`,
385
- color: theme === Theme.dark ? 'light' : undefined,
386
- icon: icon,
387
- size: Size.xs
388
- }), /*#__PURE__*/jsx("div", {
389
- className: `${CLASSNAME}__chips`,
390
- children: !isEmpty && value.map((val, index) => selectedChipRender?.(val, index, onClear, isDisabled, theme))
391
- }), isEmpty && placeholder && /*#__PURE__*/jsx("div", {
392
- className: classNames([`${CLASSNAME}__input-native`, `${CLASSNAME}__input-native--placeholder`]),
393
- children: /*#__PURE__*/jsx("span", {
394
- children: placeholder
395
- })
396
- }), (isValid || hasError) && /*#__PURE__*/jsx("div", {
397
- className: `${CLASSNAME}__input-validity`,
398
- children: /*#__PURE__*/jsx(Icon, {
399
- icon: isValid ? mdiCheckCircle : mdiAlertCircle,
400
- size: Size.xxs
401
- })
402
- }), /*#__PURE__*/jsx("div", {
403
- className: `${CLASSNAME}__input-indicator`,
404
- children: /*#__PURE__*/jsx(Icon, {
405
- icon: mdiMenuDown,
406
- size: Size.s
407
- })
408
- })]
409
- })]
410
- }), variant === SelectVariant.chip && /*#__PURE__*/jsxs(Chip, {
411
- id: id,
412
- isSelected: !isEmpty,
413
- isDisabled: isDisabled,
414
- after: /*#__PURE__*/jsx(Icon, {
415
- icon: isEmpty ? mdiMenuDown : mdiCloseCircle
416
- }),
417
- onAfterClick: isEmpty ? onInputClick : onClear,
418
- onClick: onInputClick,
419
- ref: mergeRefs(anchorRef, selectElementRef),
420
- theme: theme,
421
- ...forwardedProps,
422
- children: [isEmpty && /*#__PURE__*/jsx("span", {
423
- children: label
424
- }), !isEmpty && /*#__PURE__*/jsxs("span", {
425
- children: [/*#__PURE__*/jsx("span", {
426
- children: selectedValueRender?.(value[0])
427
- }), value.length > 1 && /*#__PURE__*/jsxs("span", {
428
- children: ["\xA0+", value.length - 1]
429
- })]
430
- })]
431
- })]
432
- });
433
- };
434
-
435
- /**
436
- * SelectMultiple component.
437
- *
438
- * @param props Component props.
439
- * @param ref Component ref.
440
- * @return React element.
441
- */
442
- const SelectMultiple = forwardRef((props, ref) => {
443
- return WithSelectContext(SelectMultipleField, {
444
- ...DEFAULT_PROPS,
445
- ...props,
446
- className: classNames(props.className, handleBasicClasses({
447
- hasMultiple: !props.isEmpty,
448
- prefix: CLASSNAME
449
- })),
450
- isEmpty: props.value.length === 0,
451
- isMultiple: true
452
- }, ref);
453
- });
454
- SelectMultiple.displayName = COMPONENT_NAME;
455
- SelectMultiple.className = CLASSNAME;
456
- SelectMultiple.defaultProps = DEFAULT_PROPS;
457
-
458
- export { Select, SelectMultiple, SelectMultipleField, SelectVariant };