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

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 (106) hide show
  1. package/index.d.ts +4 -15
  2. package/index.js +13966 -64
  3. package/index.js.map +1 -0
  4. package/package.json +3 -3
  5. package/utils/index.js +159 -3
  6. package/utils/index.js.map +1 -0
  7. package/_internal/035c132d.js +0 -314
  8. package/_internal/0b9c76cb.js +0 -5
  9. package/_internal/0ea95af1.js +0 -819
  10. package/_internal/230173a8.js +0 -12
  11. package/_internal/2a3d237c.js +0 -11
  12. package/_internal/2c2b6a89.js +0 -51
  13. package/_internal/3181f000.js +0 -13
  14. package/_internal/36bd7352.js +0 -218
  15. package/_internal/3864a6c1.js +0 -436
  16. package/_internal/3a1facc0.js +0 -17
  17. package/_internal/49bbeed3.js +0 -5
  18. package/_internal/4daccdd5.js +0 -24
  19. package/_internal/4f4c0582.js +0 -2169
  20. package/_internal/5cef5e8c.js +0 -74
  21. package/_internal/6a60381c.js +0 -117
  22. package/_internal/6f084a40.js +0 -111
  23. package/_internal/76ddefd4.js +0 -61
  24. package/_internal/78df9309.js +0 -19
  25. package/_internal/7ad474e4.js +0 -98
  26. package/_internal/7b293665.js +0 -19
  27. package/_internal/7daf0f24.js +0 -76
  28. package/_internal/825ac334.js +0 -129
  29. package/_internal/827b804a.js +0 -5
  30. package/_internal/8bce732e.js +0 -8
  31. package/_internal/9d1336a1.js +0 -18
  32. package/_internal/a38bdcd0.js +0 -49
  33. package/_internal/b326655a.js +0 -682
  34. package/_internal/b83e864b.js +0 -76
  35. package/_internal/bace1bf1.js +0 -103
  36. package/_internal/c57190eb.js +0 -146
  37. package/_internal/components/alert-dialog/index-284fed80.js +0 -163
  38. package/_internal/components/autocomplete/__mockData__/index-96fc7ea7.js +0 -27
  39. package/_internal/components/autocomplete/index-27a49d5d.js +0 -261
  40. package/_internal/components/avatar/index-b8bc3cae.js +0 -83
  41. package/_internal/components/badge/index-9880f056.js +0 -81
  42. package/_internal/components/button/index-d919f96d.js +0 -47
  43. package/_internal/components/checkbox/index-dd478de9.js +0 -143
  44. package/_internal/components/chip/index-7f84cdbd.js +0 -102
  45. package/_internal/components/comment-block/index-e942de30.js +0 -138
  46. package/_internal/components/date-picker/index-a258d3ce.js +0 -596
  47. package/_internal/components/dialog/index-c7066813.js +0 -238
  48. package/_internal/components/divider/index-b6934baf.js +0 -50
  49. package/_internal/components/drag-handle/index-80e5af6c.js +0 -52
  50. package/_internal/components/dropdown/index-cebfc268.js +0 -147
  51. package/_internal/components/expansion-panel/index-9d45a211.js +0 -167
  52. package/_internal/components/flag/index-33e9d909.js +0 -59
  53. package/_internal/components/flex-box/index-0d6b6b43.js +0 -56
  54. package/_internal/components/generic-block/index-836c4352.js +0 -124
  55. package/_internal/components/grid/index-8c16a4f1.js +0 -104
  56. package/_internal/components/grid-column/index-4a2f56bb.js +0 -59
  57. package/_internal/components/heading/index-fd558a9a.js +0 -53
  58. package/_internal/components/icon/index-e7b9b40e.js +0 -1
  59. package/_internal/components/image-block/index-7021c2f1.js +0 -110
  60. package/_internal/components/image-lightbox/index-27017547.js +0 -759
  61. package/_internal/components/inline-list/index-52efec7f.js +0 -74
  62. package/_internal/components/input-helper/index-5a837e7c.js +0 -71
  63. package/_internal/components/input-label/index-0113f382.js +0 -59
  64. package/_internal/components/lightbox/index-fad5a9f2.js +0 -155
  65. package/_internal/components/link/index-008bae4b.js +0 -72
  66. package/_internal/components/link-preview/index-3e9c32f2.js +0 -117
  67. package/_internal/components/list/index-da88c6e9.js +0 -71
  68. package/_internal/components/message/index-17b568f2.js +0 -98
  69. package/_internal/components/mosaic/index-2d40e01c.js +0 -95
  70. package/_internal/components/navigation/index-dc17c639.js +0 -225
  71. package/_internal/components/notification/index-a1101015.js +0 -146
  72. package/_internal/components/popover/index-dbca63f1.js +0 -2
  73. package/_internal/components/popover-dialog/index-654d2abc.js +0 -66
  74. package/_internal/components/post-block/index-4b6b4dcb.js +0 -109
  75. package/_internal/components/progress/index-6f578c31.js +0 -182
  76. package/_internal/components/progress-tracker/index-700bc4c2.js +0 -309
  77. package/_internal/components/radio-button/index-89b725af.js +0 -149
  78. package/_internal/components/select/index-2755aa32.js +0 -458
  79. package/_internal/components/side-navigation/index-0bbe1fdd.js +0 -165
  80. package/_internal/components/skeleton/index-b2f8501c.js +0 -166
  81. package/_internal/components/slider/index-4f9b891b.js +0 -311
  82. package/_internal/components/slideshow/index-d4604589.js +0 -150
  83. package/_internal/components/switch/index-58fe0f0c.js +0 -122
  84. package/_internal/components/table/index-d541aa88.js +0 -297
  85. package/_internal/components/tabs/index-af1538d6.js +0 -298
  86. package/_internal/components/text/index-5bfc6d5e.js +0 -1
  87. package/_internal/components/text-field/index-47c98d09.js +0 -360
  88. package/_internal/components/thumbnail/index-71545d95.js +0 -41
  89. package/_internal/components/toolbar/index-7041a5a6.js +0 -61
  90. package/_internal/components/tooltip/index-8bb97e60.js +0 -327
  91. package/_internal/components/uploader/index-8f6f55de.js +0 -153
  92. package/_internal/components/user-block/index-70d4ce8f.js +0 -145
  93. package/_internal/d0e3f49e.js +0 -23
  94. package/_internal/de24f857.js +0 -3
  95. package/_internal/e806b848.js +0 -8
  96. package/_internal/e913a3af.js +0 -117
  97. package/_internal/ea04260d.js +0 -28
  98. package/_internal/eaf6c45a.js +0 -3
  99. package/_internal/ebdcb0c7.js +0 -60
  100. package/_internal/ef5d1aac.js +0 -3
  101. package/_internal/f0d7d6ea.js +0 -29
  102. package/_internal/utils/ClickAwayProvider/index-1234ce76.js +0 -94
  103. package/_internal/utils/MaterialThemeSwitcher/index-8d22de5a.js +0 -48
  104. package/_internal/utils/Portal/index-6e0a7404.js +0 -44
  105. package/_internal/utils/disabled/index-075b99c3.js +0 -36
  106. package/_internal/utils/type/index-ea9fc197.js +0 -2
@@ -1,261 +0,0 @@
1
- import { useRef } from 'react';
2
- import classNames from 'classnames';
3
- import { getRootClassName } from '@lumx/core/js/utils/className';
4
- import { u as useFocus } from '../../3864a6c1.js';
5
- import { m as mergeRefs } from '../../f0d7d6ea.js';
6
- import { u as useTheme } from '../../3181f000.js';
7
- import { f as forwardRef } from '../../8bce732e.js';
8
- import { useDisableStateProps } from '../../utils/disabled/index-075b99c3.js';
9
- import { jsxs, jsx } from 'react/jsx-runtime';
10
- import { TextField } from '../text-field/index-47c98d09.js';
11
- import { Dropdown } from '../dropdown/index-cebfc268.js';
12
- import { C as Chip } from '../../c57190eb.js';
13
- import { m as mdiClose } from '../../eaf6c45a.js';
14
- import { I as Icon } from '../../bace1bf1.js';
15
- import { Size } from '@lumx/core/js/constants';
16
-
17
- /**
18
- * Component display name.
19
- */
20
- const COMPONENT_NAME$1 = 'Autocomplete';
21
-
22
- /**
23
- * Component default class name and class prefix.
24
- */
25
- const CLASSNAME$1 = getRootClassName(COMPONENT_NAME$1);
26
-
27
- /**
28
- * Component default props.
29
- */
30
- const DEFAULT_PROPS$1 = {
31
- anchorToInput: false,
32
- closeOnClick: false,
33
- closeOnClickAway: true,
34
- closeOnEscape: true,
35
- shouldFocusOnClose: false
36
- };
37
-
38
- /**
39
- * Autocomplete component.
40
- *
41
- * @param props Component props.
42
- * @param ref Component ref.
43
- * @return React element.
44
- */
45
- const Autocomplete = forwardRef((props, ref) => {
46
- const defaultTheme = useTheme();
47
- const {
48
- disabledStateProps,
49
- otherProps
50
- } = useDisableStateProps(props);
51
- const {
52
- anchorToInput = DEFAULT_PROPS$1.anchorToInput,
53
- children,
54
- chips,
55
- className,
56
- closeOnClick = DEFAULT_PROPS$1.closeOnClick,
57
- closeOnClickAway = DEFAULT_PROPS$1.closeOnClickAway,
58
- closeOnEscape = DEFAULT_PROPS$1.closeOnEscape,
59
- error,
60
- fitToAnchorWidth,
61
- hasError,
62
- helper,
63
- icon,
64
- inputRef,
65
- clearButtonProps,
66
- isRequired,
67
- isOpen,
68
- isValid,
69
- label,
70
- name,
71
- offset,
72
- onBlur,
73
- onChange,
74
- onClose,
75
- onFocus,
76
- onInfiniteScroll,
77
- placeholder,
78
- placement,
79
- shouldFocusOnClose = DEFAULT_PROPS$1.shouldFocusOnClose,
80
- theme = defaultTheme,
81
- value,
82
- textFieldProps = {},
83
- focusAnchorOnClose,
84
- ...forwardedProps
85
- } = otherProps;
86
- const inputAnchorRef = useRef(null);
87
- const textFieldRef = useRef(null);
88
- useFocus(inputAnchorRef.current, !isOpen && shouldFocusOnClose);
89
- return /*#__PURE__*/jsxs("div", {
90
- ref: ref,
91
- ...forwardedProps,
92
- className: classNames(className, CLASSNAME$1),
93
- children: [/*#__PURE__*/jsx(TextField, {
94
- ...textFieldProps,
95
- chips: chips,
96
- error: error,
97
- hasError: hasError,
98
- helper: helper,
99
- icon: icon,
100
- inputRef: mergeRefs(inputAnchorRef, inputRef),
101
- clearButtonProps: clearButtonProps,
102
- ...disabledStateProps,
103
- isRequired: isRequired,
104
- isValid: isValid,
105
- label: label,
106
- name: name,
107
- onBlur: onBlur,
108
- onChange: onChange,
109
- onFocus: onFocus,
110
- placeholder: placeholder,
111
- textFieldRef: textFieldRef,
112
- theme: theme,
113
- value: value
114
- }), /*#__PURE__*/jsx(Dropdown, {
115
- anchorRef: anchorToInput ? inputAnchorRef : textFieldRef,
116
- closeOnClick: closeOnClick,
117
- closeOnClickAway: closeOnClickAway,
118
- closeOnEscape: closeOnEscape,
119
- focusAnchorOnClose: focusAnchorOnClose,
120
- fitToAnchorWidth: fitToAnchorWidth,
121
- isOpen: isOpen,
122
- offset: offset,
123
- onClose: onClose,
124
- onInfiniteScroll: onInfiniteScroll,
125
- placement: placement,
126
- shouldFocusOnOpen: false,
127
- theme: theme,
128
- children: children
129
- })]
130
- });
131
- });
132
- Autocomplete.displayName = COMPONENT_NAME$1;
133
- Autocomplete.className = CLASSNAME$1;
134
- Autocomplete.defaultProps = DEFAULT_PROPS$1;
135
-
136
- /**
137
- * Component display name.
138
- */
139
- const COMPONENT_NAME = 'AutocompleteMultiple';
140
-
141
- /**
142
- * Component default class name and class prefix.
143
- */
144
- const CLASSNAME = getRootClassName(COMPONENT_NAME);
145
-
146
- /**
147
- * Component default props.
148
- */
149
- const DEFAULT_PROPS = {
150
- closeOnClickAway: true,
151
- closeOnEscape: true,
152
- selectedChipRender(choice, index, onClear, isDisabled) {
153
- const onClick = event => onClear && onClear(event, choice);
154
- return /*#__PURE__*/jsx(Chip, {
155
- after: onClear && /*#__PURE__*/jsx(Icon, {
156
- icon: mdiClose,
157
- size: Size.xxs
158
- }),
159
- isDisabled: isDisabled,
160
- size: Size.s,
161
- onAfterClick: onClick,
162
- onClick: onClick,
163
- children: choice
164
- }, index);
165
- },
166
- values: []
167
- };
168
-
169
- /**
170
- * AutocompleteMultiple component.
171
- *
172
- * @param props Component props.
173
- * @param ref Component ref.
174
- * @return React element.
175
- */
176
- const AutocompleteMultiple = forwardRef((props, ref) => {
177
- const defaultTheme = useTheme();
178
- const {
179
- disabledStateProps,
180
- otherProps
181
- } = useDisableStateProps(props);
182
- const {
183
- anchorToInput,
184
- children,
185
- // `chipsAlignment` needs to be here to remove it from `forwardedProps`.
186
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
187
- chipsAlignment,
188
- className,
189
- closeOnClickAway = DEFAULT_PROPS.closeOnClickAway,
190
- closeOnEscape = DEFAULT_PROPS.closeOnEscape,
191
- fitToAnchorWidth,
192
- hasError,
193
- helper,
194
- icon,
195
- inputRef,
196
- clearButtonProps,
197
- isRequired,
198
- isOpen,
199
- isValid,
200
- label,
201
- name,
202
- offset,
203
- onBlur,
204
- onChange,
205
- onClear,
206
- onClose,
207
- onFocus,
208
- onInfiniteScroll,
209
- onKeyDown,
210
- placeholder,
211
- placement,
212
- selectedChipRender = DEFAULT_PROPS.selectedChipRender,
213
- shouldFocusOnClose,
214
- theme = defaultTheme,
215
- type,
216
- value,
217
- values = DEFAULT_PROPS.values,
218
- ...forwardedProps
219
- } = otherProps;
220
- return /*#__PURE__*/jsx(Autocomplete, {
221
- ref: ref,
222
- ...forwardedProps,
223
- anchorToInput: anchorToInput,
224
- className: classNames(className, CLASSNAME),
225
- name: name,
226
- value: value,
227
- onChange: onChange,
228
- onKeyDown: onKeyDown,
229
- onBlur: onBlur,
230
- shouldFocusOnClose: shouldFocusOnClose,
231
- onFocus: onFocus,
232
- hasError: hasError,
233
- helper: helper,
234
- icon: icon,
235
- inputRef: inputRef,
236
- chips: values && values.map((chip, index) => selectedChipRender?.(chip, index, onClear)),
237
- ...disabledStateProps,
238
- isRequired: isRequired,
239
- clearButtonProps: clearButtonProps,
240
- isValid: isValid,
241
- label: label,
242
- placeholder: placeholder,
243
- theme: theme,
244
- type: type,
245
- isOpen: isOpen,
246
- closeOnClick: false,
247
- closeOnClickAway: closeOnClickAway,
248
- closeOnEscape: closeOnEscape,
249
- onClose: onClose,
250
- offset: offset,
251
- placement: placement,
252
- fitToAnchorWidth: fitToAnchorWidth,
253
- onInfiniteScroll: onInfiniteScroll,
254
- children: children
255
- });
256
- });
257
- AutocompleteMultiple.displayName = COMPONENT_NAME;
258
- AutocompleteMultiple.className = CLASSNAME;
259
- AutocompleteMultiple.defaultProps = DEFAULT_PROPS;
260
-
261
- export { Autocomplete, AutocompleteMultiple };
@@ -1,83 +0,0 @@
1
- import classNames from 'classnames';
2
- import { getRootClassName, handleBasicClasses } from '@lumx/core/js/utils/className';
3
- import { u as useTheme } from '../../3181f000.js';
4
- import { f as forwardRef } from '../../8bce732e.js';
5
- import { jsxs, jsx } from 'react/jsx-runtime';
6
- import { T as Thumbnail } from '../../035c132d.js';
7
- import { Size, Theme, AspectRatio } from '@lumx/core/js/constants';
8
-
9
- /**
10
- * Component display name.
11
- */
12
- const COMPONENT_NAME = 'Avatar';
13
-
14
- /**
15
- * Component default class name and class prefix.
16
- */
17
- const CLASSNAME = getRootClassName(COMPONENT_NAME);
18
-
19
- /**
20
- * Component default props.
21
- */
22
- const DEFAULT_PROPS = {
23
- size: Size.m
24
- };
25
-
26
- /**
27
- * Avatar component.
28
- *
29
- * @param props Component props.
30
- * @param ref Component ref.
31
- * @return React element.
32
- */
33
- const Avatar = forwardRef((props, ref) => {
34
- const defaultTheme = useTheme() || Theme.light;
35
- const {
36
- actions,
37
- alt,
38
- badge,
39
- className,
40
- image,
41
- linkProps,
42
- linkAs,
43
- onClick,
44
- onKeyPress,
45
- size = DEFAULT_PROPS.size,
46
- theme = defaultTheme,
47
- thumbnailProps,
48
- ...forwardedProps
49
- } = props;
50
- return /*#__PURE__*/jsxs("div", {
51
- ref: ref,
52
- ...forwardedProps,
53
- className: classNames(className, handleBasicClasses({
54
- prefix: CLASSNAME,
55
- size,
56
- theme
57
- })),
58
- children: [/*#__PURE__*/jsx(Thumbnail, {
59
- linkProps: linkProps,
60
- linkAs: linkAs,
61
- className: `${CLASSNAME}__thumbnail`,
62
- onClick: onClick,
63
- onKeyPress: onKeyPress,
64
- ...thumbnailProps,
65
- aspectRatio: AspectRatio.square,
66
- size: size,
67
- image: image,
68
- alt: alt,
69
- theme: theme
70
- }), actions && /*#__PURE__*/jsx("div", {
71
- className: `${CLASSNAME}__actions`,
72
- children: actions
73
- }), badge && /*#__PURE__*/jsx("div", {
74
- className: `${CLASSNAME}__badge`,
75
- children: badge
76
- })]
77
- });
78
- });
79
- Avatar.displayName = COMPONENT_NAME;
80
- Avatar.className = CLASSNAME;
81
- Avatar.defaultProps = DEFAULT_PROPS;
82
-
83
- export { Avatar };
@@ -1,81 +0,0 @@
1
- import classNames from 'classnames';
2
- import { getRootClassName, handleBasicClasses } from '@lumx/core/js/utils/className';
3
- import { f as forwardRef } from '../../8bce732e.js';
4
- import { jsx, jsxs } from 'react/jsx-runtime';
5
- import { ColorPalette } from '@lumx/core/js/constants';
6
-
7
- /**
8
- * Component display name.
9
- */
10
- const COMPONENT_NAME$1 = 'Badge';
11
-
12
- /**
13
- * Component default class name and class prefix.
14
- */
15
- const CLASSNAME$1 = getRootClassName(COMPONENT_NAME$1);
16
-
17
- /**
18
- * Component default props.
19
- */
20
- const DEFAULT_PROPS = {
21
- color: ColorPalette.primary
22
- };
23
-
24
- /**
25
- * Badge component.
26
- *
27
- * @param props Component props.
28
- * @param ref Component ref.
29
- * @return React element.
30
- */
31
- const Badge = forwardRef((props, ref) => {
32
- const {
33
- children,
34
- className,
35
- color = DEFAULT_PROPS.color,
36
- ...forwardedProps
37
- } = props;
38
- return /*#__PURE__*/jsx("div", {
39
- ref: ref,
40
- ...forwardedProps,
41
- className: classNames(className, handleBasicClasses({
42
- prefix: CLASSNAME$1,
43
- color
44
- })),
45
- children: children
46
- });
47
- });
48
- Badge.displayName = COMPONENT_NAME$1;
49
- Badge.className = CLASSNAME$1;
50
- Badge.defaultProps = DEFAULT_PROPS;
51
-
52
- /**
53
- * Component display name.
54
- */
55
- const COMPONENT_NAME = 'BadgeWrapper';
56
-
57
- /**
58
- * Component default class name and class prefix.
59
- */
60
- const CLASSNAME = getRootClassName(COMPONENT_NAME);
61
- const BadgeWrapper = forwardRef((props, ref) => {
62
- const {
63
- badge,
64
- children,
65
- className,
66
- ...forwardedProps
67
- } = props;
68
- return /*#__PURE__*/jsxs("div", {
69
- ref: ref,
70
- ...forwardedProps,
71
- className: classNames(className, CLASSNAME),
72
- children: [children, badge && /*#__PURE__*/jsx("div", {
73
- className: `${CLASSNAME}__badge`,
74
- children: badge
75
- })]
76
- });
77
- });
78
- BadgeWrapper.displayName = 'BadgeWrapper';
79
- BadgeWrapper.className = CLASSNAME;
80
-
81
- export { Badge, BadgeWrapper };
@@ -1,47 +0,0 @@
1
- export { a as Button, B as ButtonEmphasis } from '../../7ad474e4.js';
2
- export { I as IconButton } from '../../b83e864b.js';
3
- import classNames from 'classnames';
4
- import { getRootClassName } from '@lumx/core/js/utils/className';
5
- import { f as forwardRef } from '../../8bce732e.js';
6
- import { jsx } from 'react/jsx-runtime';
7
-
8
- /**
9
- * Component display name.
10
- */
11
- const COMPONENT_NAME = 'ButtonGroup';
12
-
13
- /**
14
- * Component default class name and class prefix.
15
- */
16
- const CLASSNAME = getRootClassName(COMPONENT_NAME);
17
-
18
- /**
19
- * Component default props.
20
- */
21
- const DEFAULT_PROPS = {};
22
-
23
- /**
24
- * ButtonGroup component.
25
- *
26
- * @param props Component props.
27
- * @param ref Component ref.
28
- * @return React element.
29
- */
30
- const ButtonGroup = forwardRef((props, ref) => {
31
- const {
32
- children,
33
- className,
34
- ...forwardedProps
35
- } = props;
36
- return /*#__PURE__*/jsx("div", {
37
- ref: ref,
38
- ...forwardedProps,
39
- className: classNames(className, CLASSNAME),
40
- children: children
41
- });
42
- });
43
- ButtonGroup.displayName = COMPONENT_NAME;
44
- ButtonGroup.className = CLASSNAME;
45
- ButtonGroup.defaultProps = DEFAULT_PROPS;
46
-
47
- export { ButtonGroup };
@@ -1,143 +0,0 @@
1
- import React__default from 'react';
2
- import classNames from 'classnames';
3
- import { getRootClassName, handleBasicClasses } from '@lumx/core/js/utils/className';
4
- import { u as useId } from '../../3a1facc0.js';
5
- import { u as useMergeRefs } from '../../f0d7d6ea.js';
6
- import { u as useTheme } from '../../3181f000.js';
7
- import { f as forwardRef } from '../../8bce732e.js';
8
- import { useDisableStateProps } from '../../utils/disabled/index-075b99c3.js';
9
- import { jsxs, jsx } from 'react/jsx-runtime';
10
- import { InputLabel } from '../input-label/index-0113f382.js';
11
- import { InputHelper } from '../input-helper/index-5a837e7c.js';
12
- import { Theme } from '@lumx/core/js/constants';
13
- import { I as Icon } from '../../bace1bf1.js';
14
-
15
- const mdiCheck = 'M21 7 9 19l-5.5-5.5 1.41-1.41L9 16.17 19.59 5.59z';
16
-
17
- const mdiMinus = 'M19 13H5v-2h14z';
18
-
19
- /**
20
- * Intermediate state of checkbox.
21
- */
22
- const INTERMEDIATE_STATE = 'intermediate';
23
-
24
- /**
25
- * Defines the props of the component.
26
- */
27
-
28
- /**
29
- * Component display name.
30
- */
31
- const COMPONENT_NAME = 'Checkbox';
32
-
33
- /**
34
- * Component default class name and class prefix.
35
- */
36
- const CLASSNAME = getRootClassName(COMPONENT_NAME);
37
-
38
- /**
39
- * Component default props.
40
- */
41
- const DEFAULT_PROPS = {};
42
-
43
- /**
44
- * Checkbox component.
45
- *
46
- * @param props Component props.
47
- * @param ref Component ref.
48
- * @return React element.
49
- */
50
- const Checkbox = forwardRef((props, ref) => {
51
- const {
52
- isAnyDisabled,
53
- disabledStateProps,
54
- otherProps
55
- } = useDisableStateProps(props);
56
- const defaultTheme = useTheme() || Theme.light;
57
- const {
58
- checked,
59
- className,
60
- helper,
61
- id,
62
- inputRef,
63
- isChecked = checked,
64
- label,
65
- name,
66
- onChange,
67
- theme = defaultTheme,
68
- value,
69
- inputProps = {},
70
- ...forwardedProps
71
- } = otherProps;
72
- const localInputRef = React__default.useRef(null);
73
- const generatedInputId = useId();
74
- const inputId = id || generatedInputId;
75
- const handleChange = event => {
76
- if (onChange) {
77
- onChange(!isChecked, value, name, event);
78
- }
79
- };
80
- const intermediateState = isChecked === INTERMEDIATE_STATE;
81
- React__default.useEffect(() => {
82
- const input = localInputRef.current;
83
- if (input) input.indeterminate = intermediateState;
84
- }, [intermediateState]);
85
- return /*#__PURE__*/jsxs("div", {
86
- ref: ref,
87
- ...forwardedProps,
88
- className: classNames(className, handleBasicClasses({
89
- // Whether state is intermediate class name will "-checked"
90
- isChecked: intermediateState ? true : isChecked,
91
- isDisabled: isAnyDisabled,
92
- isUnchecked: !isChecked,
93
- prefix: CLASSNAME,
94
- theme
95
- })),
96
- children: [/*#__PURE__*/jsxs("div", {
97
- className: `${CLASSNAME}__input-wrapper`,
98
- children: [/*#__PURE__*/jsx("input", {
99
- ref: useMergeRefs(inputRef, localInputRef),
100
- type: "checkbox",
101
- id: inputId,
102
- className: `${CLASSNAME}__input-native`,
103
- ...disabledStateProps,
104
- name: name,
105
- value: value,
106
- checked: isChecked,
107
- onChange: handleChange,
108
- "aria-describedby": helper ? `${inputId}-helper` : undefined,
109
- "aria-checked": intermediateState ? 'mixed' : Boolean(isChecked),
110
- readOnly: inputProps.readOnly || disabledStateProps['aria-disabled'],
111
- ...inputProps
112
- }), /*#__PURE__*/jsxs("div", {
113
- className: `${CLASSNAME}__input-placeholder`,
114
- children: [/*#__PURE__*/jsx("div", {
115
- className: `${CLASSNAME}__input-background`
116
- }), /*#__PURE__*/jsx("div", {
117
- className: `${CLASSNAME}__input-indicator`,
118
- children: /*#__PURE__*/jsx(Icon, {
119
- icon: intermediateState ? mdiMinus : mdiCheck
120
- })
121
- })]
122
- })]
123
- }), /*#__PURE__*/jsxs("div", {
124
- className: `${CLASSNAME}__content`,
125
- children: [label && /*#__PURE__*/jsx(InputLabel, {
126
- htmlFor: inputId,
127
- className: `${CLASSNAME}__label`,
128
- theme: theme,
129
- children: label
130
- }), helper && /*#__PURE__*/jsx(InputHelper, {
131
- id: `${inputId}-helper`,
132
- className: `${CLASSNAME}__helper`,
133
- theme: theme,
134
- children: helper
135
- })]
136
- })]
137
- });
138
- });
139
- Checkbox.displayName = COMPONENT_NAME;
140
- Checkbox.className = CLASSNAME;
141
- Checkbox.defaultProps = DEFAULT_PROPS;
142
-
143
- export { Checkbox };
@@ -1,102 +0,0 @@
1
- export { C as Chip } from '../../c57190eb.js';
2
- import classNames from 'classnames';
3
- import { getRootClassName } from '@lumx/core/js/utils/className';
4
- import { f as forwardRef } from '../../8bce732e.js';
5
- import { useState } from 'react';
6
- import { jsx } from 'react/jsx-runtime';
7
-
8
- const INITIAL_STATE_ACTIVE_CHIP = -1;
9
-
10
- /**
11
- * Hook that provides the necessary information to manage chips navigation.
12
- * @param chips List of chips selected.
13
- * @param onChipDeleted Callback executed when a chip must be eliminated.
14
- * @param initialActiveChip Initial active chip index.
15
- *
16
- * @return chip navigation tools.
17
- */
18
- const useChipGroupNavigation = (chips, onChipDeleted, initialActiveChip = INITIAL_STATE_ACTIVE_CHIP) => {
19
- const [wasBackspacePressed, setWasBackspacePressed] = useState(false);
20
- const [activeChip, setActiveChip] = useState(initialActiveChip);
21
-
22
- /**
23
- * Resets the active index and backspace control to their initial state
24
- */
25
- const resetChipNavigation = () => {
26
- setWasBackspacePressed(false);
27
- setActiveChip(initialActiveChip);
28
- };
29
-
30
- /**
31
- * Callback to be executed when the backspace was pressed. If there are no chips
32
- * selected, it will return immediately. If there are it will check if the
33
- * backspace was already pressed. if it was, it means that the user wants to eliminate
34
- * the chip, so we execute the `onChipDeleted` function and reset internal state.
35
- *
36
- * If it was not pressed before, we set the `wasBackspacePressed` flag to true and
37
- * highlight the last chip.
38
- */
39
- const onBackspacePressed = () => {
40
- if (chips.length === 0) {
41
- return;
42
- }
43
- if (wasBackspacePressed) {
44
- const chipDeleted = chips[chips.length - 1];
45
- onChipDeleted(chipDeleted);
46
- resetChipNavigation();
47
- } else {
48
- setActiveChip(chips.length - 1);
49
- setWasBackspacePressed(true);
50
- }
51
- };
52
- return {
53
- activeChip,
54
- onBackspacePressed,
55
- resetChipNavigation
56
- };
57
- };
58
-
59
- /**
60
- * Component default props.
61
- */
62
- const DEFAULT_PROPS = {};
63
-
64
- /**
65
- * Component display name.
66
- */
67
- const COMPONENT_NAME = 'ChipGroup';
68
-
69
- /**
70
- * Component default class name and class prefix.
71
- */
72
- const CLASSNAME = getRootClassName(COMPONENT_NAME);
73
-
74
- /**
75
- * ChipGroup component.
76
- *
77
- * @param props Component props.
78
- * @param ref Component ref.
79
- * @return React element.
80
- */
81
- const InternalChipGroup = forwardRef((props, ref) => {
82
- const {
83
- align,
84
- children,
85
- className,
86
- ...forwardedProps
87
- } = props;
88
- return /*#__PURE__*/jsx("div", {
89
- ref: ref,
90
- ...forwardedProps,
91
- className: classNames(className, CLASSNAME),
92
- children: children
93
- });
94
- });
95
- InternalChipGroup.displayName = COMPONENT_NAME;
96
- InternalChipGroup.className = CLASSNAME;
97
- InternalChipGroup.defaultProps = DEFAULT_PROPS;
98
- const ChipGroup = Object.assign(InternalChipGroup, {
99
- useChipGroupNavigation
100
- });
101
-
102
- export { ChipGroup };