@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,436 +0,0 @@
1
- import React__default, { useState, useEffect, useLayoutEffect, useMemo, useRef } from 'react';
2
- import classNames from 'classnames';
3
- import { u as useCallbackOnEscape } from './76ddefd4.js';
4
- import { D as DOCUMENT, W as WINDOW } from './d0e3f49e.js';
5
- import { getRootClassName, handleBasicClasses } from '@lumx/core/js/utils/className';
6
- import { u as useMergeRefs } from './f0d7d6ea.js';
7
- import { g as getFirstAndLastFocusable, u as useFocusTrap } from './6f084a40.js';
8
- import { jsx, jsxs } from 'react/jsx-runtime';
9
- import { f as forwardRef } from './8bce732e.js';
10
- import { T as ThemeProvider } from './3181f000.js';
11
- import memoize from 'lodash/memoize';
12
- import { A as ARROW_SIZE, u as usePopper, d as detectOverflow, F as FitAnchorWidth, P as Placement, a as POPOVER_ZINDEX } from './4f4c0582.js';
13
- import { Portal } from './utils/Portal/index-6e0a7404.js';
14
- import { ClickAwayProvider } from './utils/ClickAwayProvider/index-1234ce76.js';
15
-
16
- /**
17
- * Hook focusing an element when defined and `focus` boolean `true`.
18
- *
19
- * @param element Element to focus.
20
- * @param shouldFocus Boolean flag to trigger the focus
21
- */
22
- function useFocus(element, shouldFocus = true) {
23
- const [wasFocus, setWasFocus] = useState(false);
24
- useEffect(() => {
25
- if (shouldFocus && wasFocus !== shouldFocus && element) {
26
- element.focus();
27
- setWasFocus(shouldFocus);
28
- }
29
- },
30
- // eslint-disable-next-line react-hooks/exhaustive-deps
31
- [element, shouldFocus]);
32
- }
33
-
34
- /**
35
- * HOC component wrapping a component to skip render if predicate return falsy
36
- */
37
- const skipRender = (predicate, Component) => {
38
- const Wrapper = /*#__PURE__*/React__default.forwardRef((props, ref) => {
39
- if (!DOCUMENT) {
40
- // Can't render in SSR.
41
- return null;
42
- }
43
- return /*#__PURE__*/jsx(Component, {
44
- ref: ref,
45
- ...props
46
- });
47
- });
48
- Wrapper.displayName = Component.displayName;
49
- return Wrapper;
50
- };
51
-
52
- /**
53
- * Helper component using useLayoutEffect to trigger a callback on before unmount.
54
- *
55
- * The callback must be wrapped in a React ref to avoid updating the `useLayoutEffect` before the un-mount
56
- */
57
- const OnBeforeUnmount = ({
58
- callbackRef
59
- }) => {
60
- useLayoutEffect(() => {
61
- return () => {
62
- // On unmount
63
- // eslint-disable-next-line react-hooks/exhaustive-deps
64
- callbackRef.current?.();
65
- };
66
- },
67
- // eslint-disable-next-line react-hooks/exhaustive-deps
68
- []);
69
- return null;
70
- };
71
-
72
- /**
73
- * Provides an unmount sentinel to inject in the popover to detect when it closes and restore the focus to the
74
- * anchor if needed.
75
- */
76
- function useRestoreFocusOnClose({
77
- focusAnchorOnClose,
78
- anchorRef,
79
- parentElement
80
- }, popoverElement) {
81
- const onBeforeUnmountRef = React__default.useRef();
82
- React__default.useEffect(() => {
83
- if (!popoverElement || !focusAnchorOnClose) {
84
- onBeforeUnmountRef.current = undefined;
85
- return;
86
- }
87
- onBeforeUnmountRef.current = () => {
88
- const isFocusWithin = popoverElement?.contains(document.activeElement);
89
- if (!isFocusWithin) return;
90
-
91
- // On next render
92
- setTimeout(() => {
93
- const anchor = anchorRef.current;
94
- const elementToFocus =
95
- // Provided parent element
96
- parentElement?.current || (
97
- // Or first focusable element in anchor
98
- anchor ? getFirstAndLastFocusable(anchor).first : undefined) ||
99
- // Fallback to anchor
100
- anchor;
101
- elementToFocus?.focus({
102
- preventScroll: true
103
- });
104
- }, 0);
105
- };
106
- }, [anchorRef, focusAnchorOnClose, parentElement, popoverElement]);
107
- return /*#__PURE__*/jsx(OnBeforeUnmount, {
108
- callbackRef: onBeforeUnmountRef
109
- });
110
- }
111
-
112
- /**
113
- * Popper js modifier to fit popover min width to the anchor width.
114
- */
115
- const sameWidth = memoize(anchorWidthOption => ({
116
- name: 'sameWidth',
117
- enabled: true,
118
- phase: 'beforeWrite',
119
- requires: ['computeStyles'],
120
- fn({
121
- state
122
- }) {
123
- // eslint-disable-next-line no-param-reassign
124
- state.styles.popper[anchorWidthOption] = `${state.rects.reference.width}px`;
125
- },
126
- effect({
127
- state
128
- }) {
129
- // eslint-disable-next-line no-param-reassign
130
- state.elements.popper.style[anchorWidthOption] = `${state.elements.reference.offsetWidth}px`;
131
- }
132
- }));
133
-
134
- /**
135
- * Popper js modifier to compute max size of the popover.
136
- */
137
- const maxSize = {
138
- name: 'maxSize',
139
- enabled: true,
140
- phase: 'main',
141
- requiresIfExists: ['offset', 'preventOverflow', 'flip'],
142
- fn({
143
- state,
144
- name,
145
- options
146
- }) {
147
- const overflow = detectOverflow(state, options);
148
- const {
149
- y = 0,
150
- x = 0
151
- } = state.modifiersData.preventOverflow;
152
- const {
153
- width,
154
- height
155
- } = state.rects.popper;
156
- const [basePlacement] = state.placement.split('-');
157
- const widthProp = basePlacement === 'left' ? 'left' : 'right';
158
- const heightProp = basePlacement === 'top' ? 'top' : 'bottom';
159
- // eslint-disable-next-line no-param-reassign
160
- state.modifiersData[name] = {
161
- width: width - overflow[widthProp] - x,
162
- height: height - overflow[heightProp] - y
163
- };
164
- }
165
- };
166
-
167
- /**
168
- * Popper js modifier to apply the max height.
169
- */
170
- const applyMaxHeight = {
171
- name: 'applyMaxHeight',
172
- enabled: true,
173
- phase: 'beforeWrite',
174
- requires: ['maxSize'],
175
- fn({
176
- state
177
- }) {
178
- const {
179
- height
180
- } = state.modifiersData.maxSize;
181
- // eslint-disable-next-line no-param-reassign
182
- state.elements.popper.style.maxHeight = `${height - ARROW_SIZE}px`;
183
- }
184
- };
185
- function usePopoverStyle({
186
- offset,
187
- hasArrow,
188
- fitToAnchorWidth,
189
- fitWithinViewportHeight,
190
- boundaryRef,
191
- anchorRef,
192
- placement,
193
- style,
194
- zIndex
195
- }) {
196
- const [popperElement, setPopperElement] = useState(null);
197
- const [arrowElement, setArrowElement] = useState(null);
198
- const actualOffset = [offset?.along ?? 0, (offset?.away ?? 0) + (hasArrow ? ARROW_SIZE : 0)];
199
- const modifiers = [{
200
- name: 'offset',
201
- options: {
202
- offset: actualOffset
203
- }
204
- }];
205
- if (hasArrow && arrowElement) {
206
- modifiers.push({
207
- name: 'arrow',
208
- options: {
209
- element: arrowElement,
210
- padding: ARROW_SIZE / 2
211
- }
212
- });
213
- }
214
- if (fitToAnchorWidth) {
215
- const fitWidth = typeof fitToAnchorWidth === 'string' ? fitToAnchorWidth : FitAnchorWidth.MIN_WIDTH;
216
- modifiers.push(sameWidth(fitWidth));
217
- }
218
- if (fitWithinViewportHeight) {
219
- modifiers.push({
220
- ...maxSize,
221
- options: {
222
- boundary: boundaryRef?.current
223
- }
224
- }, applyMaxHeight);
225
- }
226
- if (boundaryRef) {
227
- modifiers.push({
228
- name: 'flip',
229
- options: {
230
- boundary: boundaryRef.current
231
- }
232
- }, {
233
- name: 'preventOverflow',
234
- options: {
235
- boundary: boundaryRef.current
236
- }
237
- });
238
- }
239
- const {
240
- styles,
241
- attributes,
242
- state,
243
- update
244
- } = usePopper(anchorRef.current, popperElement, {
245
- placement,
246
- modifiers
247
- });
248
-
249
- // Auto update popover
250
- useEffect(() => {
251
- const {
252
- current: anchorElement
253
- } = anchorRef;
254
- if (!update || !popperElement || !anchorElement || !WINDOW?.ResizeObserver) {
255
- return undefined;
256
- }
257
- let running;
258
- function updateRateLimited() {
259
- if (running) return;
260
- update?.();
261
- running = setTimeout(() => {
262
- running = undefined;
263
- }, 100);
264
- }
265
- updateRateLimited();
266
-
267
- // On anchor or popover resize
268
- const resizeObserver = new ResizeObserver(updateRateLimited);
269
- resizeObserver.observe(anchorElement);
270
- resizeObserver.observe(popperElement);
271
- return () => {
272
- resizeObserver.disconnect();
273
- };
274
- }, [anchorRef, popperElement, update]);
275
- const position = state?.placement ?? placement;
276
- const popoverStyle = useMemo(() => {
277
- const newStyles = {
278
- ...style,
279
- ...styles.popper,
280
- zIndex
281
- };
282
- if (fitWithinViewportHeight && !newStyles.maxHeight) {
283
- newStyles.maxHeight = WINDOW?.innerHeight || DOCUMENT?.documentElement.clientHeight;
284
- }
285
- return newStyles;
286
- }, [style, styles.popper, zIndex, fitWithinViewportHeight]);
287
- return {
288
- styles: {
289
- arrow: styles.arrow,
290
- popover: popoverStyle
291
- },
292
- attributes,
293
- isPositioned: (state?.rects?.popper?.y ?? -1) >= 0,
294
- position,
295
- setArrowElement,
296
- setPopperElement,
297
- popperElement
298
- };
299
- }
300
-
301
- /**
302
- * Component display name.
303
- */
304
- const COMPONENT_NAME = 'Popover';
305
-
306
- /**
307
- * Component default class name and class prefix.
308
- */
309
- const CLASSNAME = getRootClassName(COMPONENT_NAME);
310
-
311
- /**
312
- * Component default props.
313
- */
314
- const DEFAULT_PROPS = {
315
- elevation: 3,
316
- placement: Placement.AUTO,
317
- focusAnchorOnClose: true,
318
- usePortal: true,
319
- zIndex: POPOVER_ZINDEX
320
- };
321
-
322
- // Inner component (must be wrapped before export)
323
- const _InnerPopover = forwardRef((props, ref) => {
324
- const {
325
- anchorRef,
326
- as: Component = 'div',
327
- children,
328
- className,
329
- closeOnClickAway,
330
- closeOnEscape,
331
- elevation = DEFAULT_PROPS.elevation,
332
- focusElement,
333
- hasArrow,
334
- isOpen,
335
- onClose,
336
- parentElement,
337
- usePortal = DEFAULT_PROPS.usePortal,
338
- focusAnchorOnClose = DEFAULT_PROPS.focusAnchorOnClose,
339
- withFocusTrap,
340
- boundaryRef,
341
- fitToAnchorWidth,
342
- fitWithinViewportHeight,
343
- focusTrapZoneElement,
344
- offset,
345
- placement = DEFAULT_PROPS.placement,
346
- style,
347
- theme,
348
- zIndex = DEFAULT_PROPS.zIndex,
349
- ...forwardedProps
350
- } = props;
351
- const popoverRef = useRef(null);
352
- const {
353
- styles,
354
- attributes,
355
- isPositioned,
356
- position,
357
- setArrowElement,
358
- setPopperElement,
359
- popperElement
360
- } = usePopoverStyle({
361
- offset,
362
- hasArrow,
363
- fitToAnchorWidth,
364
- fitWithinViewportHeight,
365
- boundaryRef,
366
- anchorRef,
367
- placement,
368
- style,
369
- zIndex
370
- });
371
- const unmountSentinel = useRestoreFocusOnClose({
372
- focusAnchorOnClose,
373
- anchorRef,
374
- parentElement
375
- }, popperElement);
376
- const focusZoneElement = focusTrapZoneElement?.current || popoverRef?.current;
377
- useCallbackOnEscape(onClose, isOpen && closeOnEscape);
378
-
379
- /** Only set focus within if the focus trap is disabled as they interfere with one another. */
380
- useFocus(focusElement?.current, !withFocusTrap && isOpen && isPositioned);
381
- useFocusTrap(withFocusTrap && isOpen && focusZoneElement, focusElement?.current);
382
- const clickAwayRefs = useRef([popoverRef, anchorRef]);
383
- const mergedRefs = useMergeRefs(setPopperElement, ref, popoverRef);
384
- return isOpen ? /*#__PURE__*/jsx(Portal, {
385
- enabled: usePortal,
386
- children: /*#__PURE__*/jsxs(Component, {
387
- ...forwardedProps,
388
- ref: mergedRefs,
389
- className: classNames(className, handleBasicClasses({
390
- prefix: CLASSNAME,
391
- theme,
392
- elevation: Math.min(elevation || 0, 5),
393
- position,
394
- isInitializing: !styles.popover?.transform
395
- })),
396
- style: styles.popover,
397
- ...attributes.popper,
398
- children: [unmountSentinel, /*#__PURE__*/jsxs(ClickAwayProvider, {
399
- callback: closeOnClickAway && onClose,
400
- childrenRefs: clickAwayRefs,
401
- children: [hasArrow && /*#__PURE__*/jsx("div", {
402
- ref: setArrowElement,
403
- className: `${CLASSNAME}__arrow`,
404
- style: styles.arrow,
405
- children: /*#__PURE__*/jsx("svg", {
406
- viewBox: "0 0 14 14",
407
- "aria-hidden": true,
408
- children: /*#__PURE__*/jsx("path", {
409
- d: "M8 3.49C7.62 2.82 6.66 2.82 6.27 3.48L.04 14 14.04 14 8 3.49Z"
410
- })
411
- })
412
- }), /*#__PURE__*/jsx(ThemeProvider, {
413
- value: theme,
414
- children: children
415
- })]
416
- })]
417
- })
418
- }) : null;
419
- });
420
- _InnerPopover.displayName = COMPONENT_NAME;
421
-
422
- /**
423
- * Popover component.
424
- *
425
- * @param props Component props.
426
- * @param ref Component ref.
427
- * @return React element.
428
- */
429
- const Popover = skipRender(
430
- // Skip render in SSR
431
- () => Boolean(DOCUMENT), _InnerPopover);
432
- Popover.displayName = COMPONENT_NAME;
433
- Popover.className = CLASSNAME;
434
- Popover.defaultProps = DEFAULT_PROPS;
435
-
436
- export { Popover as P, useFocus as u };
@@ -1,17 +0,0 @@
1
- import React__default from 'react';
2
-
3
- let i = 0;
4
-
5
- /**
6
- * Generate a unique id (for use in a11y or other id based DOM linking).
7
- *
8
- * (Tries to emulate React 18 useId hook, to remove once we upgrade React)
9
- */
10
- function useId() {
11
- return React__default.useMemo(() => {
12
- i += 1;
13
- return `:lumx${i}:`;
14
- }, []);
15
- }
16
-
17
- export { useId as u };
@@ -1,5 +0,0 @@
1
- const mdiAlert = 'M13 14h-2V9h2m0 9h-2v-2h2M1 21h22L12 2z';
2
-
3
- const mdiInformation = 'M13 9h-2V7h2m0 10h-2v-6h2m-1-9A10 10 0 0 0 2 12a10 10 0 0 0 10 10 10 10 0 0 0 10-10A10 10 0 0 0 12 2';
4
-
5
- export { mdiInformation as a, mdiAlert as m };
@@ -1,24 +0,0 @@
1
- import concat from 'lodash/concat';
2
- import dropRight from 'lodash/dropRight';
3
- import last from 'lodash/last';
4
- import partition from 'lodash/partition';
5
- import reduce from 'lodash/reduce';
6
-
7
- /**
8
- * Similar to lodash `partition` function but working with multiple predicates.
9
- *
10
- * @example
11
- * const isString = (s) => typeof s === 'string'
12
- * const isNumber = (s) => typeof s === 'number'
13
- * const [strings, numbers, others] = partitionMulti(['a', 1, 'b', false], [isString, isNumber])
14
- * //=> [['a', 'b'], [1], [false]]
15
- *
16
- * @param elements array of elements
17
- * @param predicates array of predicates to apply on elements
18
- * @return partitioned elements by the given predicates
19
- */
20
- function partitionMulti(elements, predicates) {
21
- return reduce(predicates, (partitioned, predicate) => concat(dropRight(partitioned), partition(last(partitioned), predicate)), [elements]);
22
- }
23
-
24
- export { partitionMulti as p };