@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,239 @@
1
+ import React__default, { useState, useEffect, useRef, useMemo, Children } from 'react';
2
+ import classNames from 'classnames';
3
+ import { D as DOCUMENT } from '../constants-d0e3f49e.js';
4
+ import { u as useCallbackOnEscape } from '../useCallbackOnEscape-b956a85d.js';
5
+ import { u as useFocusTrap } from '../useFocusTrap-2dbae79e.js';
6
+ import { i as isComponent } from '../isComponent-b9762ff1.js';
7
+ import { partitionMulti } from '@lumx/core/js/utils/collection/partitionMulti';
8
+ import { getRootClassName, handleBasicClasses } from '@lumx/core/js/utils/className';
9
+ import { C as ClickAwayProvider } from '../ClickAwayProvider-1204f237.js';
10
+ import { m as mergeRefs } from '../mergeRefs-f0d7d6ea.js';
11
+ import { f as forwardRef } from '../forwardRef-8bce732e.js';
12
+ import { u as useDisableBodyScroll } from '../useDisableBodyScroll-36bd7352.js';
13
+ import { u as useTransitionVisibility } from '../useTransitionVisibility-321fdbfa.js';
14
+ import { T as ThemeProvider } from '../ThemeContext-3181f000.js';
15
+ import { jsx, jsxs } from 'react/jsx-runtime';
16
+ import { P as Portal } from '../Portal-3f86608e.js';
17
+ import { H as HeadingLevelProvider } from '../HeadingLevelProvider-ebdcb0c7.js';
18
+ import { Progress, ProgressVariant } from './progress-44bb0301.js';
19
+ import { Size, DIALOG_TRANSITION_DURATION } from '@lumx/core/js/constants';
20
+
21
+ /**
22
+ * Convenient hook to create interaction observers.
23
+ *
24
+ * @param elements Elements to observe.
25
+ * @param options IntersectionObserver options.
26
+ * @return Map of intersections.
27
+ */
28
+ function useIntersectionObserver(elements, options) {
29
+ const [intersections, setIntersections] = useState(() => new Map());
30
+ useEffect(() => {
31
+ if (elements.length < 1 || !elements.some(Boolean)) {
32
+ return undefined;
33
+ }
34
+ const observer = new IntersectionObserver(entries => {
35
+ for (const entry of entries) {
36
+ intersections.set(entry.target, entry);
37
+ }
38
+ setIntersections(new Map(intersections));
39
+ }, options);
40
+ for (const element of elements) {
41
+ if (element) {
42
+ observer.observe(element);
43
+ }
44
+ }
45
+ return () => observer.disconnect();
46
+ },
47
+ // eslint-disable-next-line react-hooks/exhaustive-deps
48
+ [...elements]);
49
+ return intersections;
50
+ }
51
+
52
+ const isHeader = isComponent('header');
53
+ const isFooter = isComponent('footer');
54
+
55
+ /**
56
+ * Component display name.
57
+ */
58
+ const COMPONENT_NAME = 'Dialog';
59
+
60
+ /**
61
+ * Component default class name and class prefix.
62
+ */
63
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
64
+
65
+ /**
66
+ * Component default props.
67
+ */
68
+ const DEFAULT_PROPS = {
69
+ size: Size.big,
70
+ disableBodyScroll: true
71
+ };
72
+
73
+ /**
74
+ * Dialog component.
75
+ *
76
+ * @param props Component props.
77
+ * @param ref Component ref.
78
+ * @return React element.
79
+ */
80
+ const Dialog = forwardRef((props, ref) => {
81
+ if (!DOCUMENT) {
82
+ // Can't render in SSR.
83
+ return null;
84
+ }
85
+ const {
86
+ children,
87
+ className,
88
+ header,
89
+ focusElement,
90
+ forceFooterDivider,
91
+ forceHeaderDivider,
92
+ footer,
93
+ isLoading,
94
+ isOpen,
95
+ onClose,
96
+ parentElement,
97
+ contentRef,
98
+ preventAutoClose,
99
+ size = DEFAULT_PROPS.size,
100
+ zIndex,
101
+ dialogProps,
102
+ onVisibilityChange,
103
+ disableBodyScroll = DEFAULT_PROPS.disableBodyScroll,
104
+ preventCloseOnClick,
105
+ preventCloseOnEscape,
106
+ ...forwardedProps
107
+ } = props;
108
+
109
+ // eslint-disable-next-line react-hooks/rules-of-hooks
110
+ const previousOpen = React__default.useRef(isOpen);
111
+ // eslint-disable-next-line react-hooks/rules-of-hooks
112
+ React__default.useEffect(() => {
113
+ if (isOpen !== previousOpen.current) {
114
+ previousOpen.current = isOpen;
115
+
116
+ // Focus the parent element on close.
117
+ if (!isOpen && parentElement && parentElement.current) {
118
+ parentElement.current.focus();
119
+ }
120
+ }
121
+ }, [isOpen, parentElement]);
122
+ const shouldPreventCloseOnEscape = preventAutoClose || preventCloseOnEscape;
123
+
124
+ // eslint-disable-next-line react-hooks/rules-of-hooks
125
+ useCallbackOnEscape(onClose, isOpen && !shouldPreventCloseOnEscape);
126
+
127
+ // eslint-disable-next-line react-hooks/rules-of-hooks
128
+ const wrapperRef = useRef(null);
129
+ /**
130
+ * Since the `contentRef` comes from the parent and is optional,
131
+ * we need to create a stable contentRef that will always be available.
132
+ */
133
+ // eslint-disable-next-line react-hooks/rules-of-hooks
134
+ const localContentRef = useRef(null);
135
+ // Handle focus trap.
136
+ // eslint-disable-next-line react-hooks/rules-of-hooks
137
+ useFocusTrap(isOpen && wrapperRef.current, focusElement?.current);
138
+
139
+ // eslint-disable-next-line react-hooks/rules-of-hooks
140
+ useDisableBodyScroll(disableBodyScroll && isOpen && localContentRef.current);
141
+
142
+ // eslint-disable-next-line react-hooks/rules-of-hooks
143
+ const [sentinelTop, setSentinelTop] = useState(null);
144
+ // eslint-disable-next-line react-hooks/rules-of-hooks
145
+ const [sentinelBottom, setSentinelBottom] = useState(null);
146
+ // eslint-disable-next-line react-hooks/rules-of-hooks
147
+ const intersections = useIntersectionObserver([sentinelTop, sentinelBottom], {
148
+ threshold: [0, 1]
149
+ });
150
+ const hasTopIntersection = sentinelTop && !(intersections.get(sentinelTop)?.isIntersecting ?? true);
151
+ const hasBottomIntersection = sentinelBottom && !(intersections.get(sentinelBottom)?.isIntersecting ?? true);
152
+
153
+ // Separate header, footer and dialog content from children.
154
+ // eslint-disable-next-line react-hooks/rules-of-hooks
155
+ const [[headerChild], [footerChild], content] = useMemo(() => partitionMulti(Children.toArray(children), [isHeader, isFooter]), [children]);
156
+ const headerChildProps = headerChild?.props;
157
+ const headerChildContent = headerChildProps?.children;
158
+ const footerChildProps = footerChild?.props;
159
+ const footerChildContent = footerChildProps?.children;
160
+
161
+ // eslint-disable-next-line react-hooks/rules-of-hooks
162
+ const clickAwayRefs = useRef([wrapperRef]);
163
+
164
+ // eslint-disable-next-line react-hooks/rules-of-hooks
165
+ const rootRef = useRef(null);
166
+
167
+ // eslint-disable-next-line react-hooks/rules-of-hooks
168
+ const isVisible = useTransitionVisibility(rootRef, Boolean(isOpen), DIALOG_TRANSITION_DURATION, onVisibilityChange);
169
+ const shouldPreventCloseOnClickAway = preventAutoClose || preventCloseOnClick;
170
+ return isOpen || isVisible ? /*#__PURE__*/jsx(Portal, {
171
+ children: /*#__PURE__*/jsxs("div", {
172
+ ref: mergeRefs(rootRef, ref),
173
+ ...forwardedProps,
174
+ className: classNames(className, handleBasicClasses({
175
+ isHidden: !isOpen,
176
+ isLoading,
177
+ isShown: isOpen || isVisible,
178
+ prefix: CLASSNAME,
179
+ size
180
+ })),
181
+ style: {
182
+ zIndex
183
+ },
184
+ children: [/*#__PURE__*/jsx("div", {
185
+ className: `${CLASSNAME}__overlay`
186
+ }), /*#__PURE__*/jsx(HeadingLevelProvider, {
187
+ level: 2,
188
+ children: /*#__PURE__*/jsx(ThemeProvider, {
189
+ value: undefined,
190
+ children: /*#__PURE__*/jsx("div", {
191
+ className: `${CLASSNAME}__container`,
192
+ role: "dialog",
193
+ "aria-modal": "true",
194
+ ...dialogProps,
195
+ children: /*#__PURE__*/jsx(ClickAwayProvider, {
196
+ callback: !shouldPreventCloseOnClickAway && onClose,
197
+ childrenRefs: clickAwayRefs,
198
+ parentRef: rootRef,
199
+ children: /*#__PURE__*/jsxs("section", {
200
+ className: `${CLASSNAME}__wrapper`,
201
+ ref: wrapperRef,
202
+ children: [(header || headerChildContent) && /*#__PURE__*/jsxs("header", {
203
+ ...headerChildProps,
204
+ className: classNames(`${CLASSNAME}__header`, (forceHeaderDivider || hasTopIntersection) && `${CLASSNAME}__header--has-divider`, headerChildProps?.className),
205
+ children: [header, headerChildContent]
206
+ }), /*#__PURE__*/jsxs("div", {
207
+ ref: mergeRefs(contentRef, localContentRef),
208
+ className: `${CLASSNAME}__content`,
209
+ children: [/*#__PURE__*/jsx("div", {
210
+ className: `${CLASSNAME}__sentinel ${CLASSNAME}__sentinel--top`,
211
+ ref: setSentinelTop
212
+ }), content, /*#__PURE__*/jsx("div", {
213
+ className: `${CLASSNAME}__sentinel ${CLASSNAME}__sentinel--bottom`,
214
+ ref: setSentinelBottom
215
+ })]
216
+ }), (footer || footerChildContent) && /*#__PURE__*/jsxs("footer", {
217
+ ...footerChildProps,
218
+ className: classNames(`${CLASSNAME}__footer`, (forceFooterDivider || hasBottomIntersection) && `${CLASSNAME}__footer--has-divider`, footerChildProps?.className),
219
+ children: [footer, footerChildContent]
220
+ }), isLoading && /*#__PURE__*/jsx("div", {
221
+ className: `${CLASSNAME}__progress-overlay`,
222
+ children: /*#__PURE__*/jsx(Progress, {
223
+ variant: ProgressVariant.circular
224
+ })
225
+ })]
226
+ })
227
+ })
228
+ })
229
+ })
230
+ })]
231
+ })
232
+ }) : null;
233
+ });
234
+ Dialog.displayName = COMPONENT_NAME;
235
+ Dialog.className = CLASSNAME;
236
+ Dialog.defaultProps = DEFAULT_PROPS;
237
+
238
+ export { Dialog };
239
+ //# sourceMappingURL=dialog-30336ccb.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dialog-30336ccb.js","sources":["../../../src/hooks/useIntersectionObserver.tsx","../../../src/components/dialog/Dialog.tsx"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nexport type Intersections<T> = Map<T, IntersectionObserverEntry>;\n\n/**\n * Convenient hook to create interaction observers.\n *\n * @param elements Elements to observe.\n * @param options IntersectionObserver options.\n * @return Map of intersections.\n */\nexport function useIntersectionObserver<T extends Element>(\n elements: Array<T | null | undefined>,\n options?: IntersectionObserverInit,\n): Intersections<T> {\n const [intersections, setIntersections] = useState<Intersections<T>>(() => new Map());\n\n useEffect(\n () => {\n if (elements.length < 1 || !elements.some(Boolean)) {\n return undefined;\n }\n\n const observer = new IntersectionObserver((entries) => {\n for (const entry of entries) {\n intersections.set(entry.target as T, entry);\n }\n setIntersections(new Map(intersections));\n }, options);\n\n for (const element of elements) {\n if (element) {\n observer.observe(element);\n }\n }\n return () => observer.disconnect();\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [...elements],\n );\n\n return intersections;\n}\n","import React, { Children, ReactElement, ReactNode, Ref, RefObject, useMemo, useRef, useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport { HeadingLevelProvider, Progress, ProgressVariant, Size } from '@lumx/react';\n\nimport { DIALOG_TRANSITION_DURATION, DOCUMENT } from '@lumx/react/constants';\nimport { useCallbackOnEscape } from '@lumx/react/hooks/useCallbackOnEscape';\nimport { useFocusTrap } from '@lumx/react/hooks/useFocusTrap';\nimport { useIntersectionObserver } from '@lumx/react/hooks/useIntersectionObserver';\n\nimport { GenericProps, isComponent } from '@lumx/react/utils/type';\nimport { partitionMulti } from '@lumx/core/js/utils/collection/partitionMulti';\nimport { getRootClassName, handleBasicClasses } from '@lumx/core/js/utils/className';\nimport { ClickAwayProvider } from '@lumx/react/utils/ClickAwayProvider';\nimport { mergeRefs } from '@lumx/react/utils/react/mergeRefs';\nimport { forwardRef } from '@lumx/react/utils/react/forwardRef';\n\nimport { useDisableBodyScroll } from '@lumx/react/hooks/useDisableBodyScroll';\nimport { useTransitionVisibility } from '@lumx/react/hooks/useTransitionVisibility';\nimport { ThemeProvider } from '@lumx/react/utils/theme/ThemeContext';\n\nimport { Portal } from '@lumx/react/utils';\n\n/**\n * Defines the props of the component.\n */\nexport interface DialogProps extends GenericProps {\n /** Footer content. */\n footer?: ReactNode;\n /** Whether the divider between the dialog content and the footer is always displayed (instead of showing it on scroll). */\n forceFooterDivider?: boolean;\n /** Header content. */\n header?: ReactNode;\n /** Whether the divider between the dialog content and the footer is always displayed (instead of showing it on scroll). */\n forceHeaderDivider?: boolean;\n /** Whether the indefinite progress indicator over the dialog content is displayed or not. */\n isLoading?: boolean;\n /** Whether the component is open or not. */\n isOpen?: boolean;\n /** Reference to the parent element that triggered modal opening (will get back focus on close). */\n parentElement?: RefObject<HTMLElement>;\n /** Reference to the dialog content element. */\n contentRef?: Ref<HTMLDivElement>;\n /** Reference to the of the element that should get the focus when the dialogs opens. By default, the first child will take focus. */\n focusElement?: RefObject<HTMLElement>;\n /** Whether to keep the dialog open on clickaway or escape press. */\n preventAutoClose?: boolean;\n /** Whether to keep the dialog open on escape press. */\n preventCloseOnEscape?: boolean;\n /** Whether to keep the dialog open on clickaway. */\n preventCloseOnClick?: boolean;\n /** Size variant. */\n size?: DialogSizes;\n /** Z-axis position. */\n zIndex?: number;\n /** Z-axis position. */\n dialogProps?: GenericProps;\n /** On close callback. */\n onClose?(): void;\n /** Callback called when the open animation starts and the close animation finishes. */\n onVisibilityChange?(isVisible: boolean): void;\n /** whether to disable the scroll on the body or not */\n disableBodyScroll?: boolean;\n /** Children */\n children?: React.ReactNode;\n}\n\nexport type DialogSizes = Extract<Size, 'tiny' | 'regular' | 'big' | 'huge'>;\n\nconst isHeader = isComponent('header');\nconst isFooter = isComponent('footer');\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'Dialog';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * Component default props.\n */\nconst DEFAULT_PROPS: Partial<DialogProps> = {\n size: Size.big,\n disableBodyScroll: true,\n};\n\n/**\n * Dialog component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const Dialog = forwardRef<DialogProps, HTMLDivElement>((props, ref) => {\n if (!DOCUMENT) {\n // Can't render in SSR.\n return null;\n }\n\n const {\n children,\n className,\n header,\n focusElement,\n forceFooterDivider,\n forceHeaderDivider,\n footer,\n isLoading,\n isOpen,\n onClose,\n parentElement,\n contentRef,\n preventAutoClose,\n size = DEFAULT_PROPS.size,\n zIndex,\n dialogProps,\n onVisibilityChange,\n disableBodyScroll = DEFAULT_PROPS.disableBodyScroll,\n preventCloseOnClick,\n preventCloseOnEscape,\n ...forwardedProps\n } = props;\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const previousOpen = React.useRef(isOpen);\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useEffect(() => {\n if (isOpen !== previousOpen.current) {\n previousOpen.current = isOpen;\n\n // Focus the parent element on close.\n if (!isOpen && parentElement && parentElement.current) {\n parentElement.current.focus();\n }\n }\n }, [isOpen, parentElement]);\n\n const shouldPreventCloseOnEscape = preventAutoClose || preventCloseOnEscape;\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useCallbackOnEscape(onClose, isOpen && !shouldPreventCloseOnEscape);\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const wrapperRef = useRef<HTMLDivElement>(null);\n /**\n * Since the `contentRef` comes from the parent and is optional,\n * we need to create a stable contentRef that will always be available.\n */\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const localContentRef = useRef<HTMLDivElement>(null);\n // Handle focus trap.\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useFocusTrap(isOpen && wrapperRef.current, focusElement?.current);\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n useDisableBodyScroll(disableBodyScroll && isOpen && localContentRef.current);\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const [sentinelTop, setSentinelTop] = useState<Element | null>(null);\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const [sentinelBottom, setSentinelBottom] = useState<Element | null>(null);\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const intersections = useIntersectionObserver([sentinelTop, sentinelBottom], {\n threshold: [0, 1],\n });\n\n const hasTopIntersection = sentinelTop && !(intersections.get(sentinelTop)?.isIntersecting ?? true);\n const hasBottomIntersection = sentinelBottom && !(intersections.get(sentinelBottom)?.isIntersecting ?? true);\n\n // Separate header, footer and dialog content from children.\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const [[headerChild], [footerChild], content] = useMemo(\n () => partitionMulti(Children.toArray(children), [isHeader, isFooter]),\n [children],\n );\n const headerChildProps = (headerChild as ReactElement)?.props;\n const headerChildContent = headerChildProps?.children;\n const footerChildProps = (footerChild as ReactElement)?.props;\n const footerChildContent = footerChildProps?.children;\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const clickAwayRefs = useRef([wrapperRef]);\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const rootRef = useRef<HTMLDivElement>(null);\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const isVisible = useTransitionVisibility(rootRef, Boolean(isOpen), DIALOG_TRANSITION_DURATION, onVisibilityChange);\n\n const shouldPreventCloseOnClickAway = preventAutoClose || preventCloseOnClick;\n\n return isOpen || isVisible ? (\n <Portal>\n <div\n ref={mergeRefs(rootRef, ref)}\n {...forwardedProps}\n className={classNames(\n className,\n handleBasicClasses({\n isHidden: !isOpen,\n isLoading,\n isShown: isOpen || isVisible,\n prefix: CLASSNAME,\n size,\n }),\n )}\n style={{ zIndex }}\n >\n <div className={`${CLASSNAME}__overlay`} />\n\n <HeadingLevelProvider level={2}>\n <ThemeProvider value={undefined}>\n <div className={`${CLASSNAME}__container`} role=\"dialog\" aria-modal=\"true\" {...dialogProps}>\n <ClickAwayProvider\n callback={!shouldPreventCloseOnClickAway && onClose}\n childrenRefs={clickAwayRefs}\n parentRef={rootRef}\n >\n <section className={`${CLASSNAME}__wrapper`} ref={wrapperRef}>\n {(header || headerChildContent) && (\n <header\n {...headerChildProps}\n className={classNames(\n `${CLASSNAME}__header`,\n (forceHeaderDivider || hasTopIntersection) &&\n `${CLASSNAME}__header--has-divider`,\n headerChildProps?.className,\n )}\n >\n {header}\n {headerChildContent}\n </header>\n )}\n\n <div\n ref={mergeRefs(contentRef, localContentRef)}\n className={`${CLASSNAME}__content`}\n >\n <div\n className={`${CLASSNAME}__sentinel ${CLASSNAME}__sentinel--top`}\n ref={setSentinelTop}\n />\n\n {content}\n\n <div\n className={`${CLASSNAME}__sentinel ${CLASSNAME}__sentinel--bottom`}\n ref={setSentinelBottom}\n />\n </div>\n\n {(footer || footerChildContent) && (\n <footer\n {...footerChildProps}\n className={classNames(\n `${CLASSNAME}__footer`,\n (forceFooterDivider || hasBottomIntersection) &&\n `${CLASSNAME}__footer--has-divider`,\n footerChildProps?.className,\n )}\n >\n {footer}\n {footerChildContent}\n </footer>\n )}\n\n {isLoading && (\n <div className={`${CLASSNAME}__progress-overlay`}>\n <Progress variant={ProgressVariant.circular} />\n </div>\n )}\n </section>\n </ClickAwayProvider>\n </div>\n </ThemeProvider>\n </HeadingLevelProvider>\n </div>\n </Portal>\n ) : null;\n});\nDialog.displayName = COMPONENT_NAME;\nDialog.className = CLASSNAME;\nDialog.defaultProps = DEFAULT_PROPS;\n"],"names":["useIntersectionObserver","elements","options","intersections","setIntersections","useState","Map","useEffect","length","some","Boolean","undefined","observer","IntersectionObserver","entries","entry","set","target","element","observe","disconnect","isHeader","isComponent","isFooter","COMPONENT_NAME","CLASSNAME","getRootClassName","DEFAULT_PROPS","size","Size","big","disableBodyScroll","Dialog","forwardRef","props","ref","DOCUMENT","children","className","header","focusElement","forceFooterDivider","forceHeaderDivider","footer","isLoading","isOpen","onClose","parentElement","contentRef","preventAutoClose","zIndex","dialogProps","onVisibilityChange","preventCloseOnClick","preventCloseOnEscape","forwardedProps","previousOpen","React","useRef","current","focus","shouldPreventCloseOnEscape","useCallbackOnEscape","wrapperRef","localContentRef","useFocusTrap","useDisableBodyScroll","sentinelTop","setSentinelTop","sentinelBottom","setSentinelBottom","threshold","hasTopIntersection","get","isIntersecting","hasBottomIntersection","headerChild","footerChild","content","useMemo","partitionMulti","Children","toArray","headerChildProps","headerChildContent","footerChildProps","footerChildContent","clickAwayRefs","rootRef","isVisible","useTransitionVisibility","DIALOG_TRANSITION_DURATION","shouldPreventCloseOnClickAway","_jsx","Portal","_jsxs","mergeRefs","classNames","handleBasicClasses","isHidden","isShown","prefix","style","HeadingLevelProvider","level","ThemeProvider","value","role","ClickAwayProvider","callback","childrenRefs","parentRef","Progress","variant","ProgressVariant","circular","displayName","defaultProps"],"mappings":";;;;;;;;;;;;;;;;;;;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,uBAAuBA,CACnCC,QAAqC,EACrCC,OAAkC,EAClB;AAChB,EAAA,MAAM,CAACC,aAAa,EAAEC,gBAAgB,CAAC,GAAGC,QAAQ,CAAmB,MAAM,IAAIC,GAAG,EAAE,CAAC,CAAA;AAErFC,EAAAA,SAAS,CACL,MAAM;AACF,IAAA,IAAIN,QAAQ,CAACO,MAAM,GAAG,CAAC,IAAI,CAACP,QAAQ,CAACQ,IAAI,CAACC,OAAO,CAAC,EAAE;AAChD,MAAA,OAAOC,SAAS,CAAA;AACpB,KAAA;AAEA,IAAA,MAAMC,QAAQ,GAAG,IAAIC,oBAAoB,CAAEC,OAAO,IAAK;AACnD,MAAA,KAAK,MAAMC,KAAK,IAAID,OAAO,EAAE;QACzBX,aAAa,CAACa,GAAG,CAACD,KAAK,CAACE,MAAM,EAAOF,KAAK,CAAC,CAAA;AAC/C,OAAA;AACAX,MAAAA,gBAAgB,CAAC,IAAIE,GAAG,CAACH,aAAa,CAAC,CAAC,CAAA;KAC3C,EAAED,OAAO,CAAC,CAAA;AAEX,IAAA,KAAK,MAAMgB,OAAO,IAAIjB,QAAQ,EAAE;AAC5B,MAAA,IAAIiB,OAAO,EAAE;AACTN,QAAAA,QAAQ,CAACO,OAAO,CAACD,OAAO,CAAC,CAAA;AAC7B,OAAA;AACJ,KAAA;AACA,IAAA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EACN2C,kBAAkB,CAAA;AAAA,iBACf,CACX,EAEA1C,SAAS,iBACNiD,GAAA,CAAA,KAAA,EAAA;kBAAKvD,SAAS,EAAE,CAAGb,EAAAA,SAAS,CAAqB,kBAAA,CAAA;kBAAAY,QAAA,eAC7CwD,GAAA,CAACmB,QAAQ,EAAA;oBAACC,OAAO,EAAEC,eAAe,CAACC,QAAAA;mBAAW,CAAA;AAAC,iBAC9C,CACR,CAAA;eACI,CAAA;aACM,CAAA;WAClB,CAAA;SACM,CAAA;AAAC,OACE,CAAC,CAAA;KACtB,CAAA;GACD,CAAC,GACT,IAAI,CAAA;AACZ,CAAC,EAAC;AACFnF,MAAM,CAACoF,WAAW,GAAG5F,cAAc,CAAA;AACnCQ,MAAM,CAACM,SAAS,GAAGb,SAAS,CAAA;AAC5BO,MAAM,CAACqF,YAAY,GAAG1F,aAAa;;;;"}
@@ -0,0 +1,51 @@
1
+ import classNames from 'classnames';
2
+ import { getRootClassName, handleBasicClasses } from '@lumx/core/js/utils/className';
3
+ import { u as useTheme } from '../ThemeContext-3181f000.js';
4
+ import { f as forwardRef } from '../forwardRef-8bce732e.js';
5
+ import { jsx } from 'react/jsx-runtime';
6
+ import { Theme } from '@lumx/core/js/constants';
7
+
8
+ /**
9
+ * Component display name.
10
+ */
11
+ const COMPONENT_NAME = 'Divider';
12
+
13
+ /**
14
+ * Component default class name and class prefix.
15
+ */
16
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
17
+
18
+ /**
19
+ * Component default props.
20
+ */
21
+ const DEFAULT_PROPS = {};
22
+
23
+ /**
24
+ * Divider component.
25
+ *
26
+ * @param props Component props.
27
+ * @param ref Component ref.
28
+ * @return React element.
29
+ */
30
+ const Divider = forwardRef((props, ref) => {
31
+ const defaultTheme = useTheme() || Theme.light;
32
+ const {
33
+ className,
34
+ theme = defaultTheme,
35
+ ...forwardedProps
36
+ } = props;
37
+ return /*#__PURE__*/jsx("hr", {
38
+ ref: ref,
39
+ ...forwardedProps,
40
+ className: classNames(className, handleBasicClasses({
41
+ prefix: CLASSNAME,
42
+ theme
43
+ }))
44
+ });
45
+ });
46
+ Divider.displayName = COMPONENT_NAME;
47
+ Divider.className = CLASSNAME;
48
+ Divider.defaultProps = DEFAULT_PROPS;
49
+
50
+ export { Divider };
51
+ //# sourceMappingURL=divider-0e93aa3d.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"divider-0e93aa3d.js","sources":["../../../src/components/divider/Divider.tsx"],"sourcesContent":["import classNames from 'classnames';\n\nimport { Theme } from '@lumx/react';\nimport { GenericProps, HasTheme } from '@lumx/react/utils/type';\nimport { getRootClassName, handleBasicClasses } from '@lumx/core/js/utils/className';\nimport { useTheme } from '@lumx/react/utils/theme/ThemeContext';\nimport { forwardRef } from '@lumx/react/utils/react/forwardRef';\n\n/**\n * Defines the props of the component.\n */\nexport interface DividerProps extends GenericProps, HasTheme {}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'Divider';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * Component default props.\n */\nconst DEFAULT_PROPS: Partial<DividerProps> = {};\n\n/**\n * Divider component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const Divider = forwardRef<DividerProps, HTMLHRElement>((props, ref) => {\n const defaultTheme = useTheme() || Theme.light;\n const { className, theme = defaultTheme, ...forwardedProps } = props;\n\n return (\n <hr\n ref={ref}\n {...forwardedProps}\n className={classNames(className, handleBasicClasses({ prefix: CLASSNAME, theme }))}\n />\n );\n});\nDivider.displayName = COMPONENT_NAME;\nDivider.className = CLASSNAME;\nDivider.defaultProps = DEFAULT_PROPS;\n"],"names":["COMPONENT_NAME","CLASSNAME","getRootClassName","DEFAULT_PROPS","Divider","forwardRef","props","ref","defaultTheme","useTheme","Theme","light","className","theme","forwardedProps","_jsx","classNames","handleBasicClasses","prefix","displayName","defaultProps"],"mappings":";;;;;;;AAaA;AACA;AACA;AACA,MAAMA,cAAc,GAAG,SAAS,CAAA;;AAEhC;AACA;AACA;AACA,MAAMC,SAAS,GAAGC,gBAAgB,CAACF,cAAc,CAAC,CAAA;;AAElD;AACA;AACA;AACA,MAAMG,aAAoC,GAAG,EAAE,CAAA;;AAE/C;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,OAAO,GAAGC,UAAU,CAA8B,CAACC,KAAK,EAAEC,GAAG,KAAK;EAC3E,MAAMC,YAAY,GAAGC,QAAQ,EAAE,IAAIC,KAAK,CAACC,KAAK,CAAA;EAC9C,MAAM;IAAEC,SAAS;AAAEC,IAAAA,KAAK,GAAGL,YAAY;IAAE,GAAGM,cAAAA;AAAe,GAAC,GAAGR,KAAK,CAAA;AAEpE,EAAA,oBACIS,GAAA,CAAA,IAAA,EAAA;AACIR,IAAAA,GAAG,EAAEA,GAAI;AAAA,IAAA,GACLO,cAAc;AAClBF,IAAAA,SAAS,EAAEI,UAAU,CAACJ,SAAS,EAAEK,kBAAkB,CAAC;AAAEC,MAAAA,MAAM,EAAEjB,SAAS;AAAEY,MAAAA,KAAAA;AAAM,KAAC,CAAC,CAAA;AAAE,GACtF,CAAC,CAAA;AAEV,CAAC,EAAC;AACFT,OAAO,CAACe,WAAW,GAAGnB,cAAc,CAAA;AACpCI,OAAO,CAACQ,SAAS,GAAGX,SAAS,CAAA;AAC7BG,OAAO,CAACgB,YAAY,GAAGjB,aAAa;;;;"}
@@ -0,0 +1,52 @@
1
+ import classNames from 'classnames';
2
+ import { mdiDragVertical } from '@lumx/icons/esm/drag-vertical';
3
+ import { getRootClassName, handleBasicClasses } from '@lumx/core/js/utils/className';
4
+ import { u as useTheme } from '../ThemeContext-3181f000.js';
5
+ import { f as forwardRef } from '../forwardRef-8bce732e.js';
6
+ import { jsx } from 'react/jsx-runtime';
7
+ import { Icon } from './icon-ee15673b.js';
8
+ import { Theme, ColorPalette, Size } from '@lumx/core/js/constants';
9
+
10
+ /**
11
+ * Component display name.
12
+ */
13
+ const COMPONENT_NAME = 'DragHandle';
14
+
15
+ /**
16
+ * Component default class name and class prefix.
17
+ */
18
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
19
+
20
+ /**
21
+ * DragHandle component.
22
+ *
23
+ * @param props Component props.
24
+ * @param ref Component ref.
25
+ * @return React element.
26
+ */
27
+ const DragHandle = forwardRef((props, ref) => {
28
+ const defaultTheme = useTheme();
29
+ const {
30
+ className,
31
+ theme = defaultTheme,
32
+ ...forwardedProps
33
+ } = props;
34
+ return /*#__PURE__*/jsx("div", {
35
+ ref: ref,
36
+ ...forwardedProps,
37
+ className: classNames(className, handleBasicClasses({
38
+ prefix: CLASSNAME,
39
+ theme
40
+ })),
41
+ children: /*#__PURE__*/jsx(Icon, {
42
+ icon: mdiDragVertical,
43
+ color: theme === Theme.dark ? ColorPalette.light : ColorPalette.dark,
44
+ size: Size.xs
45
+ })
46
+ });
47
+ });
48
+ DragHandle.displayName = COMPONENT_NAME;
49
+ DragHandle.className = CLASSNAME;
50
+
51
+ export { DragHandle };
52
+ //# sourceMappingURL=drag-handle-ba2e7e67.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drag-handle-ba2e7e67.js","sources":["../../../src/components/drag-handle/DragHandle.tsx"],"sourcesContent":["import classNames from 'classnames';\n\nimport { mdiDragVertical } from '@lumx/icons/esm/drag-vertical';\nimport { ColorPalette, Icon, Size, Theme } from '@lumx/react';\nimport { GenericProps, HasTheme } from '@lumx/react/utils/type';\nimport { getRootClassName, handleBasicClasses } from '@lumx/core/js/utils/className';\nimport { useTheme } from '@lumx/react/utils/theme/ThemeContext';\nimport { forwardRef } from '@lumx/react/utils/react/forwardRef';\n\n/**\n * Defines the props of the component.\n */\nexport interface DragHandleProps extends GenericProps, HasTheme {}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'DragHandle';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * DragHandle component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const DragHandle = forwardRef<DragHandleProps, HTMLDivElement>((props, ref) => {\n const defaultTheme = useTheme();\n const { className, theme = defaultTheme, ...forwardedProps } = props;\n\n return (\n <div\n ref={ref}\n {...forwardedProps}\n className={classNames(className, handleBasicClasses({ prefix: CLASSNAME, theme }))}\n >\n <Icon\n icon={mdiDragVertical}\n color={theme === Theme.dark ? ColorPalette.light : ColorPalette.dark}\n size={Size.xs}\n />\n </div>\n );\n});\nDragHandle.displayName = COMPONENT_NAME;\nDragHandle.className = CLASSNAME;\n"],"names":["COMPONENT_NAME","CLASSNAME","getRootClassName","DragHandle","forwardRef","props","ref","defaultTheme","useTheme","className","theme","forwardedProps","_jsx","classNames","handleBasicClasses","prefix","children","Icon","icon","mdiDragVertical","color","Theme","dark","ColorPalette","light","size","Size","xs","displayName"],"mappings":";;;;;;;;;AAcA;AACA;AACA;AACA,MAAMA,cAAc,GAAG,YAAY,CAAA;;AAEnC;AACA;AACA;AACA,MAAMC,SAAS,GAAGC,gBAAgB,CAACF,cAAc,CAAC,CAAA;;AAElD;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMG,UAAU,GAAGC,UAAU,CAAkC,CAACC,KAAK,EAAEC,GAAG,KAAK;AAClF,EAAA,MAAMC,YAAY,GAAGC,QAAQ,EAAE,CAAA;EAC/B,MAAM;IAAEC,SAAS;AAAEC,IAAAA,KAAK,GAAGH,YAAY;IAAE,GAAGI,cAAAA;AAAe,GAAC,GAAGN,KAAK,CAAA;AAEpE,EAAA,oBACIO,GAAA,CAAA,KAAA,EAAA;AACIN,IAAAA,GAAG,EAAEA,GAAI;AAAA,IAAA,GACLK,cAAc;AAClBF,IAAAA,SAAS,EAAEI,UAAU,CAACJ,SAAS,EAAEK,kBAAkB,CAAC;AAAEC,MAAAA,MAAM,EAAEd,SAAS;AAAES,MAAAA,KAAAA;AAAM,KAAC,CAAC,CAAE;IAAAM,QAAA,eAEnFJ,GAAA,CAACK,IAAI,EAAA;AACDC,MAAAA,IAAI,EAAEC,eAAgB;AACtBC,MAAAA,KAAK,EAAEV,KAAK,KAAKW,KAAK,CAACC,IAAI,GAAGC,YAAY,CAACC,KAAK,GAAGD,YAAY,CAACD,IAAK;MACrEG,IAAI,EAAEC,IAAI,CAACC,EAAAA;KACd,CAAA;AAAC,GACD,CAAC,CAAA;AAEd,CAAC,EAAC;AACFxB,UAAU,CAACyB,WAAW,GAAG5B,cAAc,CAAA;AACvCG,UAAU,CAACM,SAAS,GAAGR,SAAS;;;;"}
@@ -0,0 +1,148 @@
1
+ import { useEffect, useRef, useMemo, cloneElement } from 'react';
2
+ import classNames from 'classnames';
3
+ import { L as List } from '../List-c75646f2.js';
4
+ import { P as Popover } from '../index-25d2a45e.js';
5
+ import { i as isComponent } from '../isComponent-b9762ff1.js';
6
+ import { getRootClassName } from '@lumx/core/js/utils/className';
7
+ import { P as Placement } from '../constants-43721918.js';
8
+ import { f as forwardRef } from '../forwardRef-8bce732e.js';
9
+ import { jsx } from 'react/jsx-runtime';
10
+
11
+ // The error margin in px we want to have for triggering infinite scroll
12
+ const SCROLL_TRIGGER_MARGIN = 5;
13
+
14
+ /**
15
+ * Listen to clicks away from a given element and callback the passed in function.
16
+ *
17
+ * @param ref A reference to the element on which you want to listen scroll event.
18
+ * @param [callback] A callback function to call when the bottom of the reference element is reached.
19
+ * @param [callbackOnMount] A callback function to call when the component is mounted.
20
+ */
21
+ const useInfiniteScroll = (ref, callback, callbackOnMount = false, scrollTriggerMargin = SCROLL_TRIGGER_MARGIN) => {
22
+ useEffect(() => {
23
+ const {
24
+ current
25
+ } = ref;
26
+ if (!callback || !current) {
27
+ return undefined;
28
+ }
29
+ const isAtBottom = () => Boolean(current && current.scrollHeight - (current.scrollTop + current.clientHeight) <= scrollTriggerMargin);
30
+ const onScroll = e => {
31
+ if (isAtBottom()) {
32
+ callback(e);
33
+ }
34
+ };
35
+ if (isAtBottom()) {
36
+ onScroll();
37
+ }
38
+ current.addEventListener('scroll', onScroll);
39
+ current.addEventListener('resize', onScroll);
40
+ return () => {
41
+ current.removeEventListener('scroll', onScroll);
42
+ current.removeEventListener('resize', onScroll);
43
+ };
44
+ }, [ref, callback, scrollTriggerMargin]);
45
+ useEffect(() => {
46
+ if (callback && callbackOnMount) {
47
+ callback();
48
+ }
49
+ }, [callback, callbackOnMount]);
50
+ };
51
+
52
+ /**
53
+ * Component display name.
54
+ */
55
+ const COMPONENT_NAME = 'Dropdown';
56
+
57
+ /**
58
+ * Component default class name and class prefix.
59
+ */
60
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
61
+
62
+ /**
63
+ * Component default props.
64
+ */
65
+ const DEFAULT_PROPS = {
66
+ closeOnClick: true,
67
+ closeOnClickAway: true,
68
+ closeOnEscape: true,
69
+ fitToAnchorWidth: true,
70
+ fitWithinViewportHeight: true,
71
+ placement: Placement.BOTTOM_START,
72
+ shouldFocusOnOpen: true,
73
+ focusAnchorOnClose: true
74
+ };
75
+
76
+ /**
77
+ * Dropdown component.
78
+ *
79
+ * @param props Component props.
80
+ * @param ref Component ref.
81
+ * @return React element.
82
+ */
83
+ const Dropdown = forwardRef((props, ref) => {
84
+ const {
85
+ anchorRef,
86
+ children,
87
+ className,
88
+ closeOnClick = DEFAULT_PROPS.closeOnClick,
89
+ closeOnClickAway = DEFAULT_PROPS.closeOnClickAway,
90
+ closeOnEscape = DEFAULT_PROPS.closeOnEscape,
91
+ fitToAnchorWidth = DEFAULT_PROPS.fitToAnchorWidth,
92
+ fitWithinViewportHeight = DEFAULT_PROPS.fitWithinViewportHeight,
93
+ isOpen,
94
+ offset,
95
+ focusAnchorOnClose = DEFAULT_PROPS.focusAnchorOnClose,
96
+ onClose,
97
+ onInfiniteScroll,
98
+ placement = DEFAULT_PROPS.placement,
99
+ shouldFocusOnOpen = DEFAULT_PROPS.shouldFocusOnOpen,
100
+ zIndex,
101
+ ...forwardedProps
102
+ } = props;
103
+ const innerRef = useRef(null);
104
+ const listElement = useRef(null);
105
+ useInfiniteScroll(innerRef, onInfiniteScroll);
106
+ const popperElement = useMemo(() => {
107
+ return !Array.isArray(children) && isComponent(List)(children) ? /*#__PURE__*/cloneElement(children, {
108
+ ...children.props,
109
+ ref: listElement,
110
+ onClick(evt) {
111
+ children.props.onClick?.(evt);
112
+ if (closeOnClick) {
113
+ onClose?.();
114
+ }
115
+ },
116
+ isClickable: true
117
+ }) : children;
118
+ }, [children, closeOnClick, onClose]);
119
+ return isOpen ? /*#__PURE__*/jsx(Popover, {
120
+ ref: ref,
121
+ ...forwardedProps,
122
+ focusAnchorOnClose: focusAnchorOnClose,
123
+ anchorRef: anchorRef,
124
+ className: classNames(className, CLASSNAME),
125
+ elevation: 0,
126
+ closeOnClickAway: closeOnClickAway,
127
+ closeOnEscape: closeOnEscape,
128
+ fitToAnchorWidth: fitToAnchorWidth,
129
+ fitWithinViewportHeight: fitWithinViewportHeight,
130
+ focusElement: shouldFocusOnOpen ? listElement : undefined,
131
+ isOpen: isOpen,
132
+ offset: offset,
133
+ onClose: onClose,
134
+ placement: placement,
135
+ zIndex: zIndex,
136
+ children: /*#__PURE__*/jsx("div", {
137
+ className: `${CLASSNAME}__menu`,
138
+ ref: innerRef,
139
+ children: popperElement
140
+ })
141
+ }) : null;
142
+ });
143
+ Dropdown.displayName = COMPONENT_NAME;
144
+ Dropdown.className = CLASSNAME;
145
+ Dropdown.defaultProps = DEFAULT_PROPS;
146
+
147
+ export { Dropdown };
148
+ //# sourceMappingURL=dropdown-d18122d7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dropdown-d18122d7.js","sources":["../../../src/hooks/useInfiniteScroll.tsx","../../../src/components/dropdown/Dropdown.tsx"],"sourcesContent":["import { useEffect } from 'react';\n\ntype useInfiniteScrollType = (\n ref: React.RefObject<HTMLElement>,\n callback?: EventCallback,\n callbackOnMount?: boolean,\n) => void;\ntype EventCallback = (evt?: Event) => void;\n\n// The error margin in px we want to have for triggering infinite scroll\nconst SCROLL_TRIGGER_MARGIN = 5;\n\n/**\n * Listen to clicks away from a given element and callback the passed in function.\n *\n * @param ref A reference to the element on which you want to listen scroll event.\n * @param [callback] A callback function to call when the bottom of the reference element is reached.\n * @param [callbackOnMount] A callback function to call when the component is mounted.\n */\nexport const useInfiniteScroll: useInfiniteScrollType = (\n ref,\n callback,\n callbackOnMount = false,\n scrollTriggerMargin = SCROLL_TRIGGER_MARGIN,\n) => {\n useEffect(() => {\n const { current } = ref;\n if (!callback || !current) {\n return undefined;\n }\n\n const isAtBottom = () =>\n Boolean(\n current && current.scrollHeight - (current.scrollTop + current.clientHeight) <= scrollTriggerMargin,\n );\n\n const onScroll = (e?: Event): void => {\n if (isAtBottom()) {\n callback(e);\n }\n };\n\n if (isAtBottom()) {\n onScroll();\n }\n\n current.addEventListener('scroll', onScroll);\n current.addEventListener('resize', onScroll);\n return () => {\n current.removeEventListener('scroll', onScroll);\n current.removeEventListener('resize', onScroll);\n };\n }, [ref, callback, scrollTriggerMargin]);\n\n useEffect(() => {\n if (callback && callbackOnMount) {\n callback();\n }\n }, [callback, callbackOnMount]);\n};\n","import { cloneElement, useMemo, useRef } from 'react';\n\nimport classNames from 'classnames';\n\nimport { List, ListProps } from '@lumx/react/components/list/List';\nimport { Popover, PopoverProps } from '@lumx/react/components/popover/Popover';\nimport { useInfiniteScroll } from '@lumx/react/hooks/useInfiniteScroll';\nimport { GenericProps, isComponent } from '@lumx/react/utils/type';\nimport { getRootClassName } from '@lumx/core/js/utils/className';\nimport { Offset, Placement } from '@lumx/react/components/popover/constants';\nimport { forwardRef } from '@lumx/react/utils/react/forwardRef';\n\n/**\n * Defines the props of the component.\n */\nexport interface DropdownProps extends GenericProps {\n /**\n * Reference to the element around which the dropdown is placed.\n * @see {@link PopoverProps#anchorRef}\n */\n anchorRef: PopoverProps['anchorRef'];\n /** Dropdown content. */\n children: React.ReactNode;\n /**\n * Whether a click anywhere out of the Dropdown would close it or not.\n * @see {@link PopoverProps#closeOnClickAway}\n */\n closeOnClickAway?: boolean;\n /**\n * Whether to close the Dropdown when clicking in it or not.\n */\n closeOnClick?: boolean;\n /**\n * Whether an escape key press would close the Dropdown or not.\n * @see {@link PopoverProps#closeOnEscape}\n */\n closeOnEscape?: boolean;\n /**\n * Manage dropdown width:\n * - `maxWidth`: dropdown not bigger than anchor\n * - `minWidth` or `true`: dropdown not smaller than anchor\n * - `width`: dropdown equal to the anchor.\n * @see {@link PopoverProps#fitToAnchorWidth}\n */\n fitToAnchorWidth?: PopoverProps['fitToAnchorWidth'];\n /**\n * Whether the dropdown should shrink to fit within the viewport height or not.\n * @see {@link PopoverProps#fitWithinViewportHeight}\n */\n fitWithinViewportHeight?: boolean;\n /**\n * Whether the dropdown should be displayed or not. Useful to control the Dropdown from outside the component.\n * @see {@link PopoverProps#isOpen}\n */\n isOpen: boolean;\n /**\n * Offset applied to the Dropdown position.\n * @see {@link PopoverProps#offset}\n */\n offset?: Offset;\n /**\n * Preferred Dropdown placement against the anchor element.\n * @see {@link PopoverProps#placement}\n */\n placement?: Placement;\n /** Whether the focus should be set on the list when the dropdown is open or not. */\n shouldFocusOnOpen?: boolean;\n /** Whether the dropdown should be rendered into a DOM node that exists outside the DOM hierarchy of the parent component. */\n usePortal?: boolean;\n /** Whether the focus should go back on the anchor when dropdown closes and focus is within. */\n focusAnchorOnClose?: boolean;\n /**\n * Z-axis position.\n * @see {@link PopoverProps#zIndex}\n */\n zIndex?: number;\n /**\n * On close callback.\n * @see {@link PopoverProps#onClose}\n */\n onClose?(): void;\n /** On scroll end callback. */\n onInfiniteScroll?(): void;\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'Dropdown';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * Component default props.\n */\nconst DEFAULT_PROPS: Partial<DropdownProps> = {\n closeOnClick: true,\n closeOnClickAway: true,\n closeOnEscape: true,\n fitToAnchorWidth: true,\n fitWithinViewportHeight: true,\n placement: Placement.BOTTOM_START,\n shouldFocusOnOpen: true,\n focusAnchorOnClose: true,\n};\n\n/**\n * Dropdown component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const Dropdown = forwardRef<DropdownProps, HTMLDivElement>((props, ref) => {\n const {\n anchorRef,\n children,\n className,\n closeOnClick = DEFAULT_PROPS.closeOnClick,\n closeOnClickAway = DEFAULT_PROPS.closeOnClickAway,\n closeOnEscape = DEFAULT_PROPS.closeOnEscape,\n fitToAnchorWidth = DEFAULT_PROPS.fitToAnchorWidth,\n fitWithinViewportHeight = DEFAULT_PROPS.fitWithinViewportHeight,\n isOpen,\n offset,\n focusAnchorOnClose = DEFAULT_PROPS.focusAnchorOnClose,\n onClose,\n onInfiniteScroll,\n placement = DEFAULT_PROPS.placement,\n shouldFocusOnOpen = DEFAULT_PROPS.shouldFocusOnOpen,\n zIndex,\n ...forwardedProps\n } = props;\n const innerRef = useRef<HTMLDivElement>(null);\n const listElement = useRef(null);\n\n useInfiniteScroll(innerRef, onInfiniteScroll);\n\n const popperElement = useMemo(() => {\n return !Array.isArray(children) && isComponent(List)(children)\n ? cloneElement<ListProps>(children, {\n ...children.props,\n ref: listElement,\n onClick(evt: MouseEvent) {\n children.props.onClick?.(evt);\n\n if (closeOnClick) {\n onClose?.();\n }\n },\n isClickable: true,\n })\n : children;\n }, [children, closeOnClick, onClose]);\n\n return isOpen ? (\n <Popover\n ref={ref}\n {...forwardedProps}\n focusAnchorOnClose={focusAnchorOnClose}\n anchorRef={anchorRef}\n className={classNames(className, CLASSNAME)}\n elevation={0 as any}\n closeOnClickAway={closeOnClickAway}\n closeOnEscape={closeOnEscape}\n fitToAnchorWidth={fitToAnchorWidth}\n fitWithinViewportHeight={fitWithinViewportHeight}\n focusElement={shouldFocusOnOpen ? listElement : undefined}\n isOpen={isOpen}\n offset={offset}\n onClose={onClose}\n placement={placement}\n zIndex={zIndex}\n >\n <div className={`${CLASSNAME}__menu`} ref={innerRef}>\n {popperElement}\n </div>\n </Popover>\n ) : null;\n});\nDropdown.displayName = COMPONENT_NAME;\nDropdown.className = CLASSNAME;\nDropdown.defaultProps = DEFAULT_PROPS;\n"],"names":["SCROLL_TRIGGER_MARGIN","useInfiniteScroll","ref","callback","callbackOnMount","scrollTriggerMargin","useEffect","current","undefined","isAtBottom","Boolean","scrollHeight","scrollTop","clientHeight","onScroll","e","addEventListener","removeEventListener","COMPONENT_NAME","CLASSNAME","getRootClassName","DEFAULT_PROPS","closeOnClick","closeOnClickAway","closeOnEscape","fitToAnchorWidth","fitWithinViewportHeight","placement","Placement","BOTTOM_START","shouldFocusOnOpen","focusAnchorOnClose","Dropdown","forwardRef","props","anchorRef","children","className","isOpen","offset","onClose","onInfiniteScroll","zIndex","forwardedProps","innerRef","useRef","listElement","popperElement","useMemo","Array","isArray","isComponent","List","cloneElement","onClick","evt","isClickable","_jsx","Popover","classNames","elevation","focusElement","displayName","defaultProps"],"mappings":";;;;;;;;;;AASA;AACA,MAAMA,qBAAqB,GAAG,CAAC,CAAA;;AAE/B;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,iBAAwC,GAAGA,CACpDC,GAAG,EACHC,QAAQ,EACRC,eAAe,GAAG,KAAK,EACvBC,mBAAmB,GAAGL,qBAAqB,KAC1C;AACDM,EAAAA,SAAS,CAAC,MAAM;IACZ,MAAM;AAAEC,MAAAA,OAAAA;AAAQ,KAAC,GAAGL,GAAG,CAAA;AACvB,IAAA,IAAI,CAACC,QAAQ,IAAI,CAACI,OAAO,EAAE;AACvB,MAAA,OAAOC,SAAS,CAAA;AACpB,KAAA;IAEA,MAAMC,UAAU,GAAGA,MACfC,OAAO,CACHH,OAAO,IAAIA,OAAO,CAACI,YAAY,IAAIJ,OAAO,CAACK,SAAS,GAAGL,OAAO,CAACM,YAAY,CAAC,IAAIR,mBACpF,CAAC,CAAA;IAEL,MAAMS,QAAQ,GAAIC,CAAS,IAAW;MAClC,IAAIN,UAAU,EAAE,EAAE;QACdN,QAAQ,CAACY,CAAC,CAAC,CA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