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