@lumx/react 3.20.1-alpha.29 → 3.20.1-alpha.30

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 (183) hide show
  1. package/_internal/Button-4b67daa8.js +98 -0
  2. package/_internal/Button-4b67daa8.js.map +1 -0
  3. package/_internal/ButtonRoot-a70baf82.js +118 -0
  4. package/_internal/ButtonRoot-a70baf82.js.map +1 -0
  5. package/_internal/Chip-70af04b4.js +144 -0
  6. package/_internal/Chip-70af04b4.js.map +1 -0
  7. package/_internal/ClickAwayProvider-1204f237.js +95 -0
  8. package/_internal/ClickAwayProvider-1204f237.js.map +1 -0
  9. package/_internal/DisabledStateContext-ea04260d.js +29 -0
  10. package/_internal/DisabledStateContext-ea04260d.js.map +1 -0
  11. package/_internal/HeadingLevelProvider-ebdcb0c7.js +61 -0
  12. package/_internal/HeadingLevelProvider-ebdcb0c7.js.map +1 -0
  13. package/_internal/IconButton-8d61f5be.js +77 -0
  14. package/_internal/IconButton-8d61f5be.js.map +1 -0
  15. package/_internal/ImageCaption-db44ec9e.js +75 -0
  16. package/_internal/ImageCaption-db44ec9e.js.map +1 -0
  17. package/_internal/List-c75646f2.js +818 -0
  18. package/_internal/List-c75646f2.js.map +1 -0
  19. package/_internal/PopoverDialog-35b2d87d.js +657 -0
  20. package/_internal/PopoverDialog-35b2d87d.js.map +1 -0
  21. package/_internal/Portal-3f86608e.js +45 -0
  22. package/_internal/Portal-3f86608e.js.map +1 -0
  23. package/_internal/RawClickable-2c2b6a89.js +52 -0
  24. package/_internal/RawClickable-2c2b6a89.js.map +1 -0
  25. package/_internal/Slides-ce641b5f.js +679 -0
  26. package/_internal/Slides-ce641b5f.js.map +1 -0
  27. package/_internal/ThemeContext-3181f000.js +14 -0
  28. package/_internal/ThemeContext-3181f000.js.map +1 -0
  29. package/_internal/Thumbnail-02bd6869.js +314 -0
  30. package/_internal/Thumbnail-02bd6869.js.map +1 -0
  31. package/_internal/components/alert-dialog-a24330ed.js +166 -0
  32. package/_internal/components/alert-dialog-a24330ed.js.map +1 -0
  33. package/_internal/components/autocomplete-70749e51.js +262 -0
  34. package/_internal/components/autocomplete-70749e51.js.map +1 -0
  35. package/_internal/components/avatar-ed9f4869.js +84 -0
  36. package/_internal/components/avatar-ed9f4869.js.map +1 -0
  37. package/_internal/components/badge-ccf47147.js +82 -0
  38. package/_internal/components/badge-ccf47147.js.map +1 -0
  39. package/_internal/components/button-9f710830.js +48 -0
  40. package/_internal/components/button-9f710830.js.map +1 -0
  41. package/_internal/components/checkbox-8ab51ef9.js +142 -0
  42. package/_internal/components/checkbox-8ab51ef9.js.map +1 -0
  43. package/_internal/components/chip-19e40755.js +103 -0
  44. package/_internal/components/chip-19e40755.js.map +1 -0
  45. package/_internal/components/comment-block-bb6a0603.js +139 -0
  46. package/_internal/components/comment-block-bb6a0603.js.map +1 -0
  47. package/_internal/components/date-picker-e4209b01.js +2 -0
  48. package/_internal/components/date-picker-e4209b01.js.map +1 -0
  49. package/_internal/components/dialog-30336ccb.js +239 -0
  50. package/_internal/components/dialog-30336ccb.js.map +1 -0
  51. package/_internal/components/divider-0e93aa3d.js +51 -0
  52. package/_internal/components/divider-0e93aa3d.js.map +1 -0
  53. package/_internal/components/drag-handle-ba2e7e67.js +52 -0
  54. package/_internal/components/drag-handle-ba2e7e67.js.map +1 -0
  55. package/_internal/components/dropdown-d18122d7.js +148 -0
  56. package/_internal/components/dropdown-d18122d7.js.map +1 -0
  57. package/_internal/components/expansion-panel-0b263437.js +169 -0
  58. package/_internal/components/expansion-panel-0b263437.js.map +1 -0
  59. package/_internal/components/flag-8f9a498a.js +60 -0
  60. package/_internal/components/flag-8f9a498a.js.map +1 -0
  61. package/_internal/components/flex-box-15be92f6.js +57 -0
  62. package/_internal/components/flex-box-15be92f6.js.map +1 -0
  63. package/_internal/components/generic-block-5d843f1e.js +128 -0
  64. package/_internal/components/generic-block-5d843f1e.js.map +1 -0
  65. package/_internal/components/grid-8c08dc4b.js +105 -0
  66. package/_internal/components/grid-8c08dc4b.js.map +1 -0
  67. package/_internal/components/grid-column-85e305e7.js +59 -0
  68. package/_internal/components/grid-column-85e305e7.js.map +1 -0
  69. package/_internal/components/heading-7bfafd7d.js +54 -0
  70. package/_internal/components/heading-7bfafd7d.js.map +1 -0
  71. package/_internal/components/icon-ee15673b.js +103 -0
  72. package/_internal/components/icon-ee15673b.js.map +1 -0
  73. package/_internal/components/image-block-3479abda.js +111 -0
  74. package/_internal/components/image-block-3479abda.js.map +1 -0
  75. package/_internal/components/image-lightbox-1d7ca133.js +758 -0
  76. package/_internal/components/image-lightbox-1d7ca133.js.map +1 -0
  77. package/_internal/components/inline-list-5ba8bb0f.js +75 -0
  78. package/_internal/components/inline-list-5ba8bb0f.js.map +1 -0
  79. package/_internal/components/input-helper-2e4e49fd.js +72 -0
  80. package/_internal/components/input-helper-2e4e49fd.js.map +1 -0
  81. package/_internal/components/input-label-30d199c3.js +60 -0
  82. package/_internal/components/input-label-30d199c3.js.map +1 -0
  83. package/_internal/components/lightbox-c5f9afd0.js +156 -0
  84. package/_internal/components/lightbox-c5f9afd0.js.map +1 -0
  85. package/_internal/components/link-43ee103e.js +73 -0
  86. package/_internal/components/link-43ee103e.js.map +1 -0
  87. package/_internal/components/link-preview-db0ee2d6.js +118 -0
  88. package/_internal/components/link-preview-db0ee2d6.js.map +1 -0
  89. package/_internal/components/list-2f256244.js +72 -0
  90. package/_internal/components/list-2f256244.js.map +1 -0
  91. package/_internal/components/message-f7674e0e.js +101 -0
  92. package/_internal/components/message-f7674e0e.js.map +1 -0
  93. package/_internal/components/mosaic-3effd0cf.js +95 -0
  94. package/_internal/components/mosaic-3effd0cf.js.map +1 -0
  95. package/_internal/components/navigation-3a5dc270.js +227 -0
  96. package/_internal/components/navigation-3a5dc270.js.map +1 -0
  97. package/_internal/components/notification-098c5600.js +146 -0
  98. package/_internal/components/notification-098c5600.js.map +1 -0
  99. package/_internal/components/popover-dfcddda4.js +3 -0
  100. package/_internal/components/popover-dfcddda4.js.map +1 -0
  101. package/_internal/components/post-block-69797e4d.js +110 -0
  102. package/_internal/components/post-block-69797e4d.js.map +1 -0
  103. package/_internal/components/progress-44bb0301.js +183 -0
  104. package/_internal/components/progress-44bb0301.js.map +1 -0
  105. package/_internal/components/progress-tracker-e0981fcc.js +309 -0
  106. package/_internal/components/progress-tracker-e0981fcc.js.map +1 -0
  107. package/_internal/components/radio-button-929c7bee.js +150 -0
  108. package/_internal/components/radio-button-929c7bee.js.map +1 -0
  109. package/_internal/components/select-64bc72a0.js +458 -0
  110. package/_internal/components/select-64bc72a0.js.map +1 -0
  111. package/_internal/components/side-navigation-c610c689.js +166 -0
  112. package/_internal/components/side-navigation-c610c689.js.map +1 -0
  113. package/_internal/components/skeleton-1ea8c82a.js +167 -0
  114. package/_internal/components/skeleton-1ea8c82a.js.map +1 -0
  115. package/_internal/components/slider-78cfaa67.js +312 -0
  116. package/_internal/components/slider-78cfaa67.js.map +1 -0
  117. package/_internal/components/slideshow-d8a943a7.js +151 -0
  118. package/_internal/components/slideshow-d8a943a7.js.map +1 -0
  119. package/_internal/components/switch-25b65051.js +122 -0
  120. package/_internal/components/switch-25b65051.js.map +1 -0
  121. package/_internal/components/table-ec20c66c.js +296 -0
  122. package/_internal/components/table-ec20c66c.js.map +1 -0
  123. package/_internal/components/tabs-89c055bd.js +299 -0
  124. package/_internal/components/tabs-89c055bd.js.map +1 -0
  125. package/_internal/components/text-d04d0f1b.js +2 -0
  126. package/_internal/components/text-d04d0f1b.js.map +1 -0
  127. package/_internal/components/text-field-8f13957e.js +361 -0
  128. package/_internal/components/text-field-8f13957e.js.map +1 -0
  129. package/_internal/components/thumbnail-1255957f.js +42 -0
  130. package/_internal/components/thumbnail-1255957f.js.map +1 -0
  131. package/_internal/components/toolbar-e7c984e6.js +62 -0
  132. package/_internal/components/toolbar-e7c984e6.js.map +1 -0
  133. package/_internal/components/tooltip-dcb43bbe.js +328 -0
  134. package/_internal/components/tooltip-dcb43bbe.js.map +1 -0
  135. package/_internal/components/uploader-7ef4db39.js +154 -0
  136. package/_internal/components/uploader-7ef4db39.js.map +1 -0
  137. package/_internal/components/user-block-24d97650.js +145 -0
  138. package/_internal/components/user-block-24d97650.js.map +1 -0
  139. package/_internal/constants-43721918.js +2170 -0
  140. package/_internal/constants-43721918.js.map +1 -0
  141. package/_internal/constants-d0e3f49e.js +24 -0
  142. package/_internal/constants-d0e3f49e.js.map +1 -0
  143. package/_internal/context-9d1336a1.js +19 -0
  144. package/_internal/context-9d1336a1.js.map +1 -0
  145. package/_internal/forwardRef-8bce732e.js +9 -0
  146. package/_internal/forwardRef-8bce732e.js.map +1 -0
  147. package/_internal/getFocusableElements-230173a8.js +13 -0
  148. package/_internal/getFocusableElements-230173a8.js.map +1 -0
  149. package/_internal/index-25c9e8c2.js +118 -0
  150. package/_internal/index-25c9e8c2.js.map +1 -0
  151. package/_internal/index-25d2a45e.js +437 -0
  152. package/_internal/index-25d2a45e.js.map +1 -0
  153. package/_internal/isComponent-b9762ff1.js +18 -0
  154. package/_internal/isComponent-b9762ff1.js.map +1 -0
  155. package/_internal/isComponentType-e806b848.js +9 -0
  156. package/_internal/isComponentType-e806b848.js.map +1 -0
  157. package/_internal/mergeRefs-f0d7d6ea.js +30 -0
  158. package/_internal/mergeRefs-f0d7d6ea.js.map +1 -0
  159. package/_internal/state-db358714.js +130 -0
  160. package/_internal/state-db358714.js.map +1 -0
  161. package/_internal/useBooleanState-2a3d237c.js +12 -0
  162. package/_internal/useBooleanState-2a3d237c.js.map +1 -0
  163. package/_internal/useCallbackOnEscape-b956a85d.js +64 -0
  164. package/_internal/useCallbackOnEscape-b956a85d.js.map +1 -0
  165. package/_internal/useDisableBodyScroll-36bd7352.js +219 -0
  166. package/_internal/useDisableBodyScroll-36bd7352.js.map +1 -0
  167. package/_internal/useDisableStateProps-69e16b7c.js +36 -0
  168. package/_internal/useDisableStateProps-69e16b7c.js.map +1 -0
  169. package/_internal/useFocusTrap-2dbae79e.js +112 -0
  170. package/_internal/useFocusTrap-2dbae79e.js.map +1 -0
  171. package/_internal/useId-3a1facc0.js +18 -0
  172. package/_internal/useId-3a1facc0.js.map +1 -0
  173. package/_internal/useRovingTabIndex-7daf0f24.js +77 -0
  174. package/_internal/useRovingTabIndex-7daf0f24.js.map +1 -0
  175. package/_internal/useTransitionVisibility-321fdbfa.js +50 -0
  176. package/_internal/useTransitionVisibility-321fdbfa.js.map +1 -0
  177. package/_internal/wrapChildrenIconWithSpaces-50d705e6.js +20 -0
  178. package/_internal/wrapChildrenIconWithSpaces-50d705e6.js.map +1 -0
  179. package/index.js +63 -14033
  180. package/index.js.map +1 -1
  181. package/package.json +3 -3
  182. package/utils/index.js +3 -158
  183. package/utils/index.js.map +1 -1
@@ -0,0 +1,818 @@
1
+ import React__default, { useState, useEffect, useMemo, Children, isValidElement, cloneElement, useRef } from 'react';
2
+ import classNames from 'classnames';
3
+ import { getRootClassName, handleBasicClasses } from '@lumx/core/js/utils/className';
4
+ import { m as mergeRefs } from './mergeRefs-f0d7d6ea.js';
5
+ import { f as forwardRef } from './forwardRef-8bce732e.js';
6
+ import { onEnterPressed, onButtonPressed } from '@lumx/core/js/utils';
7
+ import { u as useDisableStateProps } from './useDisableStateProps-69e16b7c.js';
8
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
9
+ import { Size } from '@lumx/core/js/constants';
10
+ import { i as isComponent } from './isComponent-b9762ff1.js';
11
+
12
+ const INITIAL_INDEX$1 = -1;
13
+
14
+ /**
15
+ * This custom hook provides the necessary set of functions and values to properly navigate
16
+ * a list using the keyboard.
17
+ *
18
+ * @param items the list of items that will be navigated using the keyboard.
19
+ * @param ref A reference to the element that is controlling the navigation.
20
+ * @param onListItemSelected callback to be executed when the ENTER key is pressed on an item.
21
+ * @param onListItemNavigated callback to be executed when the Arrow keys are pressed.
22
+ * @param onEnterPressed callback to be executed when the ENTER key is pressed.
23
+ * @param onBackspacePressed callback to be executed when the BACKSPACE key is pressed.
24
+ * @param keepFocusAfterSelection determines whether after selecting an item, the focus should be maintained on the current target or not.
25
+ * @param initialIndex where should the navigation start from. it defaults to `-1`, so the first item navigated is the item on position `0`.
26
+ * @param preventTabOnEnteredValue determines whether upon TAB, if there is a value entered, the event is prevented or not.
27
+ * @return useKeyboardListNavigation helpers.
28
+ */
29
+ const useKeyboardListNavigation = (items, ref, onListItemSelected, onListItemNavigated, onEnterPressed, onBackspacePressed, keepFocusAfterSelection = false, initialIndex = INITIAL_INDEX$1, preventTabOnEnteredValue = true) => {
30
+ const [activeItemIndex, setActiveItemIndex] = useState(initialIndex);
31
+
32
+ /**
33
+ * This function calculates the next index in the list to be highlighted
34
+ * @param key - key code pressed
35
+ * @return next active index
36
+ */
37
+ const calculateActiveIndex = key => {
38
+ switch (key) {
39
+ case 'ArrowDown':
40
+ return activeItemIndex + 1 < items.length ? activeItemIndex + 1 : 0;
41
+ case 'ArrowUp':
42
+ return activeItemIndex - 1 >= 0 ? activeItemIndex - 1 : items.length - 1;
43
+ default:
44
+ return initialIndex;
45
+ }
46
+ };
47
+
48
+ /**
49
+ * Resets the active index to the initial state
50
+ */
51
+ const resetActiveIndex = () => {
52
+ setActiveItemIndex(initialIndex);
53
+ };
54
+
55
+ /**
56
+ * Prevents the default event and stops the propagation of said event
57
+ * @param evt - key pressed event
58
+ */
59
+ const preventDefaultAndStopPropagation = evt => {
60
+ evt.preventDefault();
61
+ evt.stopPropagation();
62
+ };
63
+
64
+ /**
65
+ * Handles navigation with the arrows using the keyboard
66
+ * @param evt - key pressed event
67
+ */
68
+ const onArrowPressed = evt => {
69
+ const {
70
+ key
71
+ } = evt;
72
+ const nextActiveIndex = calculateActiveIndex(key);
73
+ setActiveItemIndex(nextActiveIndex);
74
+ preventDefaultAndStopPropagation(evt);
75
+ if (onListItemNavigated) {
76
+ const selectedItem = items[nextActiveIndex];
77
+ onListItemNavigated(selectedItem);
78
+ }
79
+ };
80
+
81
+ /**
82
+ * Handles the event when the backspace key is pressed
83
+ * @param evt - key pressed event
84
+ */
85
+ const onBackspaceKeyPressed = evt => {
86
+ if (onBackspacePressed) {
87
+ onBackspacePressed(evt);
88
+ }
89
+ };
90
+
91
+ /**
92
+ * Handles when the ENTER key is pressed
93
+ * @param evt - key pressed event
94
+ */
95
+ const onEnterKeyPressed = evt => {
96
+ if (!onListItemSelected) {
97
+ return;
98
+ }
99
+ preventDefaultAndStopPropagation(evt);
100
+ if (!keepFocusAfterSelection) {
101
+ evt.currentTarget.blur();
102
+ }
103
+ const selectedItem = items[activeItemIndex];
104
+ if (selectedItem) {
105
+ onListItemSelected(selectedItem);
106
+ resetActiveIndex();
107
+ } else if (activeItemIndex === initialIndex && onEnterPressed) {
108
+ const value = evt.target?.value;
109
+ onEnterPressed(value);
110
+ resetActiveIndex();
111
+ }
112
+ };
113
+
114
+ /**
115
+ * Handles when the TAB key is pressed
116
+ * @param evt - key pressed event
117
+ */
118
+ const onTabKeyPressed = evt => {
119
+ const value = evt.target?.value;
120
+ if (preventTabOnEnteredValue && value && value.length > 0) {
121
+ preventDefaultAndStopPropagation(evt);
122
+ }
123
+ };
124
+
125
+ /**
126
+ * In order to make it easier in the future to add new events depending on the key
127
+ * a map was created to add these handlers. In the future, if there is another event
128
+ * that we need to manage depending on a specific key, we just need to add the key code
129
+ * here, and as a value, the handler for said key.
130
+ */
131
+ const eventsForKeyPressed = {
132
+ ArrowDown: onArrowPressed,
133
+ Tab: onTabKeyPressed,
134
+ ArrowUp: onArrowPressed,
135
+ Enter: onEnterKeyPressed,
136
+ Backspace: onBackspaceKeyPressed
137
+ };
138
+
139
+ /**
140
+ * Calculates the next active item index depending on the key pressed.
141
+ * If the key pressed was ENTER, the function executes the callback `onListItemSelected`
142
+ * and resets the active index, since an item was selected.
143
+ * @param evt - key pressed or key down event
144
+ */
145
+ const onKeyboardNavigation = evt => {
146
+ const {
147
+ key
148
+ } = evt;
149
+ const handler = eventsForKeyPressed[key];
150
+ if (handler) {
151
+ handler(evt);
152
+ }
153
+ };
154
+ useEffect(() => {
155
+ const {
156
+ current: currentElement
157
+ } = ref;
158
+ if (!currentElement) {
159
+ return undefined;
160
+ }
161
+ currentElement.addEventListener('focus', resetActiveIndex);
162
+ currentElement.addEventListener('keydown', onKeyboardNavigation);
163
+ return () => {
164
+ currentElement.removeEventListener('focus', resetActiveIndex);
165
+ currentElement.removeEventListener('keydown', onKeyboardNavigation);
166
+ };
167
+ });
168
+ return {
169
+ activeItemIndex,
170
+ onKeyboardNavigation,
171
+ resetActiveIndex,
172
+ setActiveItemIndex
173
+ };
174
+ };
175
+
176
+ /**
177
+ * Render link with default <a> HTML component or a custom one provided by `linkAs`.
178
+ *
179
+ * Can be used to inject the `Link` component from `react-router` and provide better a11y on LumX components.
180
+ *
181
+ * @param linkAs Custom link component.
182
+ * @param children Link children.
183
+ * @return A link.
184
+ */
185
+ const renderLink = ({
186
+ linkAs,
187
+ ...forwardedProps
188
+ }, ...children) => /*#__PURE__*/React__default.createElement(linkAs || 'a', forwardedProps, ...children);
189
+
190
+ /**
191
+ * Component display name.
192
+ */
193
+ const COMPONENT_NAME$1 = 'ListItem';
194
+
195
+ /**
196
+ * Component default class name and class prefix.
197
+ */
198
+ const CLASSNAME$1 = getRootClassName(COMPONENT_NAME$1);
199
+
200
+ /**
201
+ * Component default props.
202
+ */
203
+ const DEFAULT_PROPS$1 = {
204
+ size: Size.regular
205
+ };
206
+
207
+ /**
208
+ * Check if the list item is clickable.
209
+ * @return `true` if the list item is clickable; `false` otherwise.
210
+ */
211
+ function isClickable({
212
+ linkProps,
213
+ onItemSelected
214
+ }) {
215
+ return !!linkProps?.href || !!onItemSelected;
216
+ }
217
+
218
+ /**
219
+ * ListItem component.
220
+ *
221
+ * @param props Component props.
222
+ * @param ref Component ref.
223
+ * @return React element.
224
+ */
225
+ const ListItem = forwardRef((props, ref) => {
226
+ const {
227
+ isAnyDisabled,
228
+ disabledStateProps,
229
+ otherProps
230
+ } = useDisableStateProps(props);
231
+ const {
232
+ after,
233
+ before,
234
+ children,
235
+ className,
236
+ isHighlighted,
237
+ isSelected,
238
+ linkAs,
239
+ linkProps = {},
240
+ linkRef,
241
+ onItemSelected,
242
+ size = DEFAULT_PROPS$1.size,
243
+ ...forwardedProps
244
+ } = otherProps;
245
+ const role = linkAs || linkProps.href ? 'link' : 'button';
246
+ const onKeyDown = useMemo(() => {
247
+ if (onItemSelected && role === 'link') return onEnterPressed(onItemSelected);
248
+ if (onItemSelected && role === 'button') return onButtonPressed(onItemSelected);
249
+ return undefined;
250
+ }, [role, onItemSelected]);
251
+ const content = /*#__PURE__*/jsxs(Fragment, {
252
+ children: [before && /*#__PURE__*/jsx("div", {
253
+ className: `${CLASSNAME$1}__before`,
254
+ children: before
255
+ }), /*#__PURE__*/jsx("div", {
256
+ className: `${CLASSNAME$1}__content`,
257
+ children: children
258
+ }), after && /*#__PURE__*/jsx("div", {
259
+ className: `${CLASSNAME$1}__after`,
260
+ children: after
261
+ })]
262
+ });
263
+ return /*#__PURE__*/jsx("li", {
264
+ ref: ref,
265
+ ...forwardedProps,
266
+ className: classNames(className, handleBasicClasses({
267
+ prefix: CLASSNAME$1,
268
+ size
269
+ })),
270
+ children: isClickable({
271
+ linkProps,
272
+ onItemSelected
273
+ }) ? (/* Clickable list item */
274
+ renderLink({
275
+ linkAs,
276
+ tabIndex: !disabledStateProps.disabled ? 0 : undefined,
277
+ role,
278
+ 'aria-disabled': isAnyDisabled,
279
+ ...linkProps,
280
+ href: isAnyDisabled ? undefined : linkProps.href,
281
+ className: classNames(handleBasicClasses({
282
+ prefix: `${CLASSNAME$1}__link`,
283
+ isHighlighted,
284
+ isSelected,
285
+ isDisabled: isAnyDisabled
286
+ })),
287
+ onClick: isAnyDisabled ? undefined : onItemSelected,
288
+ onKeyDown: isAnyDisabled ? undefined : onKeyDown,
289
+ ref: linkRef
290
+ }, content)) :
291
+ /*#__PURE__*/
292
+ /* Non clickable list item */
293
+ jsx("div", {
294
+ className: `${CLASSNAME$1}__wrapper`,
295
+ children: content
296
+ })
297
+ });
298
+ });
299
+ ListItem.displayName = COMPONENT_NAME$1;
300
+ ListItem.className = CLASSNAME$1;
301
+ ListItem.defaultProps = DEFAULT_PROPS$1;
302
+
303
+ var reactIs = {exports: {}};
304
+
305
+ var reactIs_production_min = {};
306
+
307
+ /**
308
+ * @license React
309
+ * react-is.production.min.js
310
+ *
311
+ * Copyright (c) Facebook, Inc. and its affiliates.
312
+ *
313
+ * This source code is licensed under the MIT license found in the
314
+ * LICENSE file in the root directory of this source tree.
315
+ */
316
+
317
+ var hasRequiredReactIs_production_min;
318
+
319
+ function requireReactIs_production_min () {
320
+ if (hasRequiredReactIs_production_min) return reactIs_production_min;
321
+ hasRequiredReactIs_production_min = 1;
322
+ var b=Symbol.for("react.element"),c=Symbol.for("react.portal"),d=Symbol.for("react.fragment"),e=Symbol.for("react.strict_mode"),f=Symbol.for("react.profiler"),g=Symbol.for("react.provider"),h=Symbol.for("react.context"),k=Symbol.for("react.server_context"),l=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),n=Symbol.for("react.suspense_list"),p=Symbol.for("react.memo"),q=Symbol.for("react.lazy"),t=Symbol.for("react.offscreen"),u;u=Symbol.for("react.module.reference");
323
+ function v(a){if("object"===typeof a&&null!==a){var r=a.$$typeof;switch(r){case b:switch(a=a.type,a){case d:case f:case e:case m:case n:return a;default:switch(a=a&&a.$$typeof,a){case k:case h:case l:case q:case p:case g:return a;default:return r}}case c:return r}}}reactIs_production_min.ContextConsumer=h;reactIs_production_min.ContextProvider=g;reactIs_production_min.Element=b;reactIs_production_min.ForwardRef=l;reactIs_production_min.Fragment=d;reactIs_production_min.Lazy=q;reactIs_production_min.Memo=p;reactIs_production_min.Portal=c;reactIs_production_min.Profiler=f;reactIs_production_min.StrictMode=e;reactIs_production_min.Suspense=m;
324
+ reactIs_production_min.SuspenseList=n;reactIs_production_min.isAsyncMode=function(){return !1};reactIs_production_min.isConcurrentMode=function(){return !1};reactIs_production_min.isContextConsumer=function(a){return v(a)===h};reactIs_production_min.isContextProvider=function(a){return v(a)===g};reactIs_production_min.isElement=function(a){return "object"===typeof a&&null!==a&&a.$$typeof===b};reactIs_production_min.isForwardRef=function(a){return v(a)===l};reactIs_production_min.isFragment=function(a){return v(a)===d};reactIs_production_min.isLazy=function(a){return v(a)===q};reactIs_production_min.isMemo=function(a){return v(a)===p};
325
+ reactIs_production_min.isPortal=function(a){return v(a)===c};reactIs_production_min.isProfiler=function(a){return v(a)===f};reactIs_production_min.isStrictMode=function(a){return v(a)===e};reactIs_production_min.isSuspense=function(a){return v(a)===m};reactIs_production_min.isSuspenseList=function(a){return v(a)===n};
326
+ reactIs_production_min.isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===d||a===f||a===e||a===m||a===n||a===t||"object"===typeof a&&null!==a&&(a.$$typeof===q||a.$$typeof===p||a.$$typeof===g||a.$$typeof===h||a.$$typeof===l||a.$$typeof===u||void 0!==a.getModuleId)?!0:!1};reactIs_production_min.typeOf=v;
327
+ return reactIs_production_min;
328
+ }
329
+
330
+ var reactIs_development = {};
331
+
332
+ /**
333
+ * @license React
334
+ * react-is.development.js
335
+ *
336
+ * Copyright (c) Facebook, Inc. and its affiliates.
337
+ *
338
+ * This source code is licensed under the MIT license found in the
339
+ * LICENSE file in the root directory of this source tree.
340
+ */
341
+
342
+ var hasRequiredReactIs_development;
343
+
344
+ function requireReactIs_development () {
345
+ if (hasRequiredReactIs_development) return reactIs_development;
346
+ hasRequiredReactIs_development = 1;
347
+
348
+ if (process.env.NODE_ENV !== "production") {
349
+ (function() {
350
+
351
+ // ATTENTION
352
+ // When adding new symbols to this file,
353
+ // Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
354
+ // The Symbol used to tag the ReactElement-like types.
355
+ var REACT_ELEMENT_TYPE = Symbol.for('react.element');
356
+ var REACT_PORTAL_TYPE = Symbol.for('react.portal');
357
+ var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');
358
+ var REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode');
359
+ var REACT_PROFILER_TYPE = Symbol.for('react.profiler');
360
+ var REACT_PROVIDER_TYPE = Symbol.for('react.provider');
361
+ var REACT_CONTEXT_TYPE = Symbol.for('react.context');
362
+ var REACT_SERVER_CONTEXT_TYPE = Symbol.for('react.server_context');
363
+ var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');
364
+ var REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');
365
+ var REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list');
366
+ var REACT_MEMO_TYPE = Symbol.for('react.memo');
367
+ var REACT_LAZY_TYPE = Symbol.for('react.lazy');
368
+ var REACT_OFFSCREEN_TYPE = Symbol.for('react.offscreen');
369
+
370
+ // -----------------------------------------------------------------------------
371
+
372
+ var enableScopeAPI = false; // Experimental Create Event Handle API.
373
+ var enableCacheElement = false;
374
+ var enableTransitionTracing = false; // No known bugs, but needs performance testing
375
+
376
+ var enableLegacyHidden = false; // Enables unstable_avoidThisFallback feature in Fiber
377
+ // stuff. Intended to enable React core members to more easily debug scheduling
378
+ // issues in DEV builds.
379
+
380
+ var enableDebugTracing = false; // Track which Fiber(s) schedule render work.
381
+
382
+ var REACT_MODULE_REFERENCE;
383
+
384
+ {
385
+ REACT_MODULE_REFERENCE = Symbol.for('react.module.reference');
386
+ }
387
+
388
+ function isValidElementType(type) {
389
+ if (typeof type === 'string' || typeof type === 'function') {
390
+ return true;
391
+ } // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
392
+
393
+
394
+ if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing ) {
395
+ return true;
396
+ }
397
+
398
+ if (typeof type === 'object' && type !== null) {
399
+ if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object
400
+ // types supported by any Flight configuration anywhere since
401
+ // we don't know which Flight build this will end up being used
402
+ // with.
403
+ type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== undefined) {
404
+ return true;
405
+ }
406
+ }
407
+
408
+ return false;
409
+ }
410
+
411
+ function typeOf(object) {
412
+ if (typeof object === 'object' && object !== null) {
413
+ var $$typeof = object.$$typeof;
414
+
415
+ switch ($$typeof) {
416
+ case REACT_ELEMENT_TYPE:
417
+ var type = object.type;
418
+
419
+ switch (type) {
420
+ case REACT_FRAGMENT_TYPE:
421
+ case REACT_PROFILER_TYPE:
422
+ case REACT_STRICT_MODE_TYPE:
423
+ case REACT_SUSPENSE_TYPE:
424
+ case REACT_SUSPENSE_LIST_TYPE:
425
+ return type;
426
+
427
+ default:
428
+ var $$typeofType = type && type.$$typeof;
429
+
430
+ switch ($$typeofType) {
431
+ case REACT_SERVER_CONTEXT_TYPE:
432
+ case REACT_CONTEXT_TYPE:
433
+ case REACT_FORWARD_REF_TYPE:
434
+ case REACT_LAZY_TYPE:
435
+ case REACT_MEMO_TYPE:
436
+ case REACT_PROVIDER_TYPE:
437
+ return $$typeofType;
438
+
439
+ default:
440
+ return $$typeof;
441
+ }
442
+
443
+ }
444
+
445
+ case REACT_PORTAL_TYPE:
446
+ return $$typeof;
447
+ }
448
+ }
449
+
450
+ return undefined;
451
+ }
452
+ var ContextConsumer = REACT_CONTEXT_TYPE;
453
+ var ContextProvider = REACT_PROVIDER_TYPE;
454
+ var Element = REACT_ELEMENT_TYPE;
455
+ var ForwardRef = REACT_FORWARD_REF_TYPE;
456
+ var Fragment = REACT_FRAGMENT_TYPE;
457
+ var Lazy = REACT_LAZY_TYPE;
458
+ var Memo = REACT_MEMO_TYPE;
459
+ var Portal = REACT_PORTAL_TYPE;
460
+ var Profiler = REACT_PROFILER_TYPE;
461
+ var StrictMode = REACT_STRICT_MODE_TYPE;
462
+ var Suspense = REACT_SUSPENSE_TYPE;
463
+ var SuspenseList = REACT_SUSPENSE_LIST_TYPE;
464
+ var hasWarnedAboutDeprecatedIsAsyncMode = false;
465
+ var hasWarnedAboutDeprecatedIsConcurrentMode = false; // AsyncMode should be deprecated
466
+
467
+ function isAsyncMode(object) {
468
+ {
469
+ if (!hasWarnedAboutDeprecatedIsAsyncMode) {
470
+ hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint
471
+
472
+ console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 18+.');
473
+ }
474
+ }
475
+
476
+ return false;
477
+ }
478
+ function isConcurrentMode(object) {
479
+ {
480
+ if (!hasWarnedAboutDeprecatedIsConcurrentMode) {
481
+ hasWarnedAboutDeprecatedIsConcurrentMode = true; // Using console['warn'] to evade Babel and ESLint
482
+
483
+ console['warn']('The ReactIs.isConcurrentMode() alias has been deprecated, ' + 'and will be removed in React 18+.');
484
+ }
485
+ }
486
+
487
+ return false;
488
+ }
489
+ function isContextConsumer(object) {
490
+ return typeOf(object) === REACT_CONTEXT_TYPE;
491
+ }
492
+ function isContextProvider(object) {
493
+ return typeOf(object) === REACT_PROVIDER_TYPE;
494
+ }
495
+ function isElement(object) {
496
+ return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
497
+ }
498
+ function isForwardRef(object) {
499
+ return typeOf(object) === REACT_FORWARD_REF_TYPE;
500
+ }
501
+ function isFragment(object) {
502
+ return typeOf(object) === REACT_FRAGMENT_TYPE;
503
+ }
504
+ function isLazy(object) {
505
+ return typeOf(object) === REACT_LAZY_TYPE;
506
+ }
507
+ function isMemo(object) {
508
+ return typeOf(object) === REACT_MEMO_TYPE;
509
+ }
510
+ function isPortal(object) {
511
+ return typeOf(object) === REACT_PORTAL_TYPE;
512
+ }
513
+ function isProfiler(object) {
514
+ return typeOf(object) === REACT_PROFILER_TYPE;
515
+ }
516
+ function isStrictMode(object) {
517
+ return typeOf(object) === REACT_STRICT_MODE_TYPE;
518
+ }
519
+ function isSuspense(object) {
520
+ return typeOf(object) === REACT_SUSPENSE_TYPE;
521
+ }
522
+ function isSuspenseList(object) {
523
+ return typeOf(object) === REACT_SUSPENSE_LIST_TYPE;
524
+ }
525
+
526
+ reactIs_development.ContextConsumer = ContextConsumer;
527
+ reactIs_development.ContextProvider = ContextProvider;
528
+ reactIs_development.Element = Element;
529
+ reactIs_development.ForwardRef = ForwardRef;
530
+ reactIs_development.Fragment = Fragment;
531
+ reactIs_development.Lazy = Lazy;
532
+ reactIs_development.Memo = Memo;
533
+ reactIs_development.Portal = Portal;
534
+ reactIs_development.Profiler = Profiler;
535
+ reactIs_development.StrictMode = StrictMode;
536
+ reactIs_development.Suspense = Suspense;
537
+ reactIs_development.SuspenseList = SuspenseList;
538
+ reactIs_development.isAsyncMode = isAsyncMode;
539
+ reactIs_development.isConcurrentMode = isConcurrentMode;
540
+ reactIs_development.isContextConsumer = isContextConsumer;
541
+ reactIs_development.isContextProvider = isContextProvider;
542
+ reactIs_development.isElement = isElement;
543
+ reactIs_development.isForwardRef = isForwardRef;
544
+ reactIs_development.isFragment = isFragment;
545
+ reactIs_development.isLazy = isLazy;
546
+ reactIs_development.isMemo = isMemo;
547
+ reactIs_development.isPortal = isPortal;
548
+ reactIs_development.isProfiler = isProfiler;
549
+ reactIs_development.isStrictMode = isStrictMode;
550
+ reactIs_development.isSuspense = isSuspense;
551
+ reactIs_development.isSuspenseList = isSuspenseList;
552
+ reactIs_development.isValidElementType = isValidElementType;
553
+ reactIs_development.typeOf = typeOf;
554
+ })();
555
+ }
556
+ return reactIs_development;
557
+ }
558
+
559
+ var hasRequiredReactIs;
560
+
561
+ function requireReactIs () {
562
+ if (hasRequiredReactIs) return reactIs.exports;
563
+ hasRequiredReactIs = 1;
564
+
565
+ if (process.env.NODE_ENV === 'production') {
566
+ reactIs.exports = requireReactIs_production_min();
567
+ } else {
568
+ reactIs.exports = requireReactIs_development();
569
+ }
570
+ return reactIs.exports;
571
+ }
572
+
573
+ var reactIsExports = requireReactIs();
574
+
575
+ /**
576
+ * Flatten list of react nodes removing fragments and adding keys.
577
+ * based on: https://github.com/grrowl/react-keyed-flatten-children/blob/5d421644a449765ddd62b659946196b4b5d7b135/index.ts
578
+ *
579
+ * @param children React nodes to flatten.
580
+ * @return Flattened react nodes.
581
+ * @deprecated This function was used to develop keyboard navigation in the List component,
582
+ * but we will replace this with a better method that does not require to hack the children inspection
583
+ *
584
+ * TODO: remove List keyboard navigation once we have provided alternative component (Menu, Combobox, etc.),
585
+ * remove this function and then remove react-is from the dependencies
586
+ */
587
+ function flattenChildren(children) {
588
+ function recur(nodes, keys = []) {
589
+ return Children.toArray(nodes).reduce((acc, node, index) => {
590
+ const nodeKeys = keys.concat(node?.key ?? index);
591
+ if (reactIsExports.isFragment(node)) {
592
+ acc.push(...recur(node.props.children, nodeKeys));
593
+ } else if (/*#__PURE__*/isValidElement(node)) {
594
+ acc.push(/*#__PURE__*/cloneElement(node, {
595
+ key: nodeKeys.join('.')
596
+ }));
597
+ } else if (typeof node === 'string' || typeof node === 'number') {
598
+ acc.push(node);
599
+ }
600
+ return acc;
601
+ }, []);
602
+ }
603
+ return recur(children);
604
+ }
605
+
606
+ const INITIAL_INDEX = -1;
607
+ function onKeyboardFocus(props, handler) {
608
+ let isMouseDown = false;
609
+ return {
610
+ onFocus(evt) {
611
+ props.onFocus?.(evt);
612
+ if (!isMouseDown) {
613
+ handler(evt);
614
+ }
615
+ },
616
+ onMouseDown(evt) {
617
+ props.onMouseDown?.(evt);
618
+ isMouseDown = true;
619
+ },
620
+ onMouseUp(evt) {
621
+ props.onMouseUp?.(evt);
622
+ isMouseDown = false;
623
+ }
624
+ };
625
+ }
626
+ const isNavigableItem = node => {
627
+ return isComponent('ListItem')(node) && isClickable(node.props) && !node.props.isDisabled;
628
+ };
629
+
630
+ /**
631
+ * This custom hook detects clickable list item in a list and make them navigable with the keyboard.
632
+ *
633
+ * @param options See {@link Options}
634
+ * @return See {@link Output}
635
+ */
636
+ const useInteractiveList = options => {
637
+ const {
638
+ ref,
639
+ onListItemSelected,
640
+ onListItemNavigated
641
+ } = options;
642
+ const items = useMemo(() => flattenChildren(options.items), [options.items]);
643
+ const [activeItemIndex, setActiveItemIndex] = useState(INITIAL_INDEX);
644
+
645
+ // Attach listeners to the list.
646
+ useEffect(() => {
647
+ const {
648
+ current: listElement
649
+ } = ref;
650
+ if (!listElement) {
651
+ return undefined;
652
+ }
653
+
654
+ /**
655
+ * This function calculates the next index in the list to be active
656
+ * @param index current index
657
+ * @param code key code pressed
658
+ * @return next index
659
+ */
660
+ const getNextIndex = (index, key) => {
661
+ switch (key) {
662
+ case 'ArrowDown':
663
+ return index + 1 < items.length ? index + 1 : 0;
664
+ case 'ArrowUp':
665
+ return index - 1 >= 0 ? index - 1 : items.length - 1;
666
+ default:
667
+ return INITIAL_INDEX;
668
+ }
669
+ };
670
+
671
+ /**
672
+ * Resets the active index to the initial state
673
+ */
674
+ const resetActiveIndex = () => {
675
+ setActiveItemIndex(INITIAL_INDEX);
676
+ };
677
+
678
+ /**
679
+ * Handles navigation with the arrows using the keyboard
680
+ * @param evt Key event
681
+ */
682
+ const onArrowPressed = evt => {
683
+ const {
684
+ key
685
+ } = evt;
686
+ if (key !== 'ArrowUp' && key !== 'ArrowDown') {
687
+ return;
688
+ }
689
+ let nextIndex = activeItemIndex;
690
+ let iterations = 0;
691
+
692
+ // Move to next navigable item.
693
+ do {
694
+ nextIndex = getNextIndex(nextIndex, key);
695
+ iterations += 1;
696
+ } while (nextIndex !== INITIAL_INDEX && nextIndex !== activeItemIndex && !isNavigableItem(items[nextIndex]) && iterations < items.length);
697
+ setActiveItemIndex(nextIndex);
698
+ evt.preventDefault();
699
+ evt.stopPropagation();
700
+ onListItemNavigated?.(nextIndex, items[nextIndex]?.key);
701
+ };
702
+
703
+ /**
704
+ * Reset active list item index when focusing outside the list.
705
+ * @param evt Focus out event
706
+ */
707
+ const onFocusOut = evt => {
708
+ if (!evt.relatedTarget || !listElement.contains(evt.relatedTarget)) {
709
+ resetActiveIndex();
710
+ }
711
+ };
712
+ listElement.addEventListener('focusout', onFocusOut);
713
+ listElement.addEventListener('keydown', onArrowPressed);
714
+ return () => {
715
+ listElement.removeEventListener('focusout', onFocusOut);
716
+ listElement.removeEventListener('keydown', onArrowPressed);
717
+ };
718
+ }, [ref, activeItemIndex, items, onListItemNavigated]);
719
+ return useMemo(() => {
720
+ let hasClickableItem = false;
721
+ const transformedItems = items.map((item, index) => {
722
+ // Ignore if list not clickable or item is not a simple list item.
723
+ if (!isNavigableItem(item)) {
724
+ return item;
725
+ }
726
+ hasClickableItem = true;
727
+ const isHighlighted = index === activeItemIndex;
728
+
729
+ // Clone list item: inject ref, add tab index and active state.
730
+ return /*#__PURE__*/cloneElement(item, {
731
+ ...item.props,
732
+ isHighlighted: item.props.isHighlighted ?? isHighlighted,
733
+ linkRef: mergeRefs(item.props.linkRef, element => {
734
+ if (isHighlighted) {
735
+ element?.focus();
736
+ }
737
+ }),
738
+ onItemSelected(evt) {
739
+ item.props.onItemSelected?.();
740
+ onListItemSelected?.(index, item.key, evt);
741
+ },
742
+ ...onKeyboardFocus(item.props, () => {
743
+ setActiveItemIndex(index);
744
+ })
745
+ });
746
+ });
747
+ return {
748
+ items: transformedItems,
749
+ hasClickableItem
750
+ };
751
+ }, [items, activeItemIndex, onListItemSelected]);
752
+ };
753
+
754
+ /**
755
+ * Component display name.
756
+ */
757
+ const COMPONENT_NAME = 'List';
758
+
759
+ /**
760
+ * Component default class name and class prefix.
761
+ */
762
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
763
+
764
+ /**
765
+ * Component default props.
766
+ */
767
+ const DEFAULT_PROPS = {
768
+ tabIndex: -1
769
+ };
770
+
771
+ /* eslint-disable jsx-a11y/no-noninteractive-tabindex */
772
+ /**
773
+ * List component.
774
+ *
775
+ * @param props Component props.
776
+ * @param ref Component ref.
777
+ * @return React element.
778
+ */
779
+ const InternalList = forwardRef((props, ref) => {
780
+ const {
781
+ children,
782
+ className,
783
+ isClickable,
784
+ itemPadding,
785
+ onListItemSelected,
786
+ tabIndex = DEFAULT_PROPS.tabIndex,
787
+ ...forwardedProps
788
+ } = props;
789
+ const listElementRef = useRef(null);
790
+ const {
791
+ items,
792
+ hasClickableItem
793
+ } = useInteractiveList({
794
+ items: children,
795
+ ref: listElementRef,
796
+ onListItemSelected
797
+ });
798
+ const clickable = hasClickableItem || isClickable;
799
+ return /*#__PURE__*/jsx("ul", {
800
+ ...forwardedProps,
801
+ className: classNames(className, handleBasicClasses({
802
+ prefix: CLASSNAME,
803
+ itemPadding: itemPadding ?? (clickable ? Size.big : undefined)
804
+ })),
805
+ tabIndex: tabIndex,
806
+ ref: mergeRefs(ref, listElementRef),
807
+ children: items
808
+ });
809
+ });
810
+ InternalList.displayName = COMPONENT_NAME;
811
+ InternalList.className = CLASSNAME;
812
+ InternalList.defaultProps = DEFAULT_PROPS;
813
+ const List = Object.assign(InternalList, {
814
+ useKeyboardListNavigation
815
+ });
816
+
817
+ export { List as L, ListItem as a, isClickable as i };
818
+ //# sourceMappingURL=List-c75646f2.js.map