@lumx/react 3.20.1-alpha.36 → 3.20.1-alpha.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +4 -15
- package/index.js +13966 -64
- package/index.js.map +1 -0
- package/package.json +3 -3
- package/utils/index.js +159 -3
- package/utils/index.js.map +1 -0
- package/_internal/035c132d.js +0 -314
- package/_internal/0b9c76cb.js +0 -5
- package/_internal/0ea95af1.js +0 -819
- package/_internal/230173a8.js +0 -12
- package/_internal/2a3d237c.js +0 -11
- package/_internal/2c2b6a89.js +0 -51
- package/_internal/3181f000.js +0 -13
- package/_internal/36bd7352.js +0 -218
- package/_internal/3864a6c1.js +0 -436
- package/_internal/3a1facc0.js +0 -17
- package/_internal/49bbeed3.js +0 -5
- package/_internal/4daccdd5.js +0 -24
- package/_internal/4f4c0582.js +0 -2169
- package/_internal/5cef5e8c.js +0 -74
- package/_internal/6a60381c.js +0 -117
- package/_internal/6f084a40.js +0 -111
- package/_internal/76ddefd4.js +0 -61
- package/_internal/78df9309.js +0 -19
- package/_internal/7ad474e4.js +0 -98
- package/_internal/7b293665.js +0 -19
- package/_internal/7daf0f24.js +0 -76
- package/_internal/825ac334.js +0 -129
- package/_internal/827b804a.js +0 -5
- package/_internal/8bce732e.js +0 -8
- package/_internal/9d1336a1.js +0 -18
- package/_internal/a38bdcd0.js +0 -49
- package/_internal/b326655a.js +0 -682
- package/_internal/b83e864b.js +0 -76
- package/_internal/bace1bf1.js +0 -103
- package/_internal/c57190eb.js +0 -146
- package/_internal/components/alert-dialog/index-284fed80.js +0 -163
- package/_internal/components/autocomplete/__mockData__/index-96fc7ea7.js +0 -27
- package/_internal/components/autocomplete/index-27a49d5d.js +0 -261
- package/_internal/components/avatar/index-b8bc3cae.js +0 -83
- package/_internal/components/badge/index-9880f056.js +0 -81
- package/_internal/components/button/index-d919f96d.js +0 -47
- package/_internal/components/checkbox/index-dd478de9.js +0 -143
- package/_internal/components/chip/index-7f84cdbd.js +0 -102
- package/_internal/components/comment-block/index-e942de30.js +0 -138
- package/_internal/components/date-picker/index-a258d3ce.js +0 -596
- package/_internal/components/dialog/index-c7066813.js +0 -238
- package/_internal/components/divider/index-b6934baf.js +0 -50
- package/_internal/components/drag-handle/index-80e5af6c.js +0 -52
- package/_internal/components/dropdown/index-cebfc268.js +0 -147
- package/_internal/components/expansion-panel/index-9d45a211.js +0 -167
- package/_internal/components/flag/index-33e9d909.js +0 -59
- package/_internal/components/flex-box/index-0d6b6b43.js +0 -56
- package/_internal/components/generic-block/index-836c4352.js +0 -124
- package/_internal/components/grid/index-8c16a4f1.js +0 -104
- package/_internal/components/grid-column/index-4a2f56bb.js +0 -59
- package/_internal/components/heading/index-fd558a9a.js +0 -53
- package/_internal/components/icon/index-e7b9b40e.js +0 -1
- package/_internal/components/image-block/index-7021c2f1.js +0 -110
- package/_internal/components/image-lightbox/index-27017547.js +0 -759
- package/_internal/components/inline-list/index-52efec7f.js +0 -74
- package/_internal/components/input-helper/index-5a837e7c.js +0 -71
- package/_internal/components/input-label/index-0113f382.js +0 -59
- package/_internal/components/lightbox/index-fad5a9f2.js +0 -155
- package/_internal/components/link/index-008bae4b.js +0 -72
- package/_internal/components/link-preview/index-3e9c32f2.js +0 -117
- package/_internal/components/list/index-da88c6e9.js +0 -71
- package/_internal/components/message/index-17b568f2.js +0 -98
- package/_internal/components/mosaic/index-2d40e01c.js +0 -95
- package/_internal/components/navigation/index-dc17c639.js +0 -225
- package/_internal/components/notification/index-a1101015.js +0 -146
- package/_internal/components/popover/index-dbca63f1.js +0 -2
- package/_internal/components/popover-dialog/index-654d2abc.js +0 -66
- package/_internal/components/post-block/index-4b6b4dcb.js +0 -109
- package/_internal/components/progress/index-6f578c31.js +0 -182
- package/_internal/components/progress-tracker/index-700bc4c2.js +0 -309
- package/_internal/components/radio-button/index-89b725af.js +0 -149
- package/_internal/components/select/index-2755aa32.js +0 -458
- package/_internal/components/side-navigation/index-0bbe1fdd.js +0 -165
- package/_internal/components/skeleton/index-b2f8501c.js +0 -166
- package/_internal/components/slider/index-4f9b891b.js +0 -311
- package/_internal/components/slideshow/index-d4604589.js +0 -150
- package/_internal/components/switch/index-58fe0f0c.js +0 -122
- package/_internal/components/table/index-d541aa88.js +0 -297
- package/_internal/components/tabs/index-af1538d6.js +0 -298
- package/_internal/components/text/index-5bfc6d5e.js +0 -1
- package/_internal/components/text-field/index-47c98d09.js +0 -360
- package/_internal/components/thumbnail/index-71545d95.js +0 -41
- package/_internal/components/toolbar/index-7041a5a6.js +0 -61
- package/_internal/components/tooltip/index-8bb97e60.js +0 -327
- package/_internal/components/uploader/index-8f6f55de.js +0 -153
- package/_internal/components/user-block/index-70d4ce8f.js +0 -145
- package/_internal/d0e3f49e.js +0 -23
- package/_internal/de24f857.js +0 -3
- package/_internal/e806b848.js +0 -8
- package/_internal/e913a3af.js +0 -117
- package/_internal/ea04260d.js +0 -28
- package/_internal/eaf6c45a.js +0 -3
- package/_internal/ebdcb0c7.js +0 -60
- package/_internal/ef5d1aac.js +0 -3
- package/_internal/f0d7d6ea.js +0 -29
- package/_internal/utils/ClickAwayProvider/index-1234ce76.js +0 -94
- package/_internal/utils/MaterialThemeSwitcher/index-8d22de5a.js +0 -48
- package/_internal/utils/Portal/index-6e0a7404.js +0 -44
- package/_internal/utils/disabled/index-075b99c3.js +0 -36
- package/_internal/utils/type/index-ea9fc197.js +0 -2
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
import React__default, { useState, useEffect, useRef, useMemo, Children } from 'react';
|
|
2
|
-
import classNames from 'classnames';
|
|
3
|
-
import { D as DOCUMENT } from '../../d0e3f49e.js';
|
|
4
|
-
import { u as useCallbackOnEscape } from '../../76ddefd4.js';
|
|
5
|
-
import { u as useFocusTrap } from '../../6f084a40.js';
|
|
6
|
-
import { p as partitionMulti } from '../../4daccdd5.js';
|
|
7
|
-
import { getRootClassName, handleBasicClasses } from '@lumx/core/js/utils/className';
|
|
8
|
-
import { m as mergeRefs } from '../../f0d7d6ea.js';
|
|
9
|
-
import { f as forwardRef } from '../../8bce732e.js';
|
|
10
|
-
import { u as useDisableBodyScroll } from '../../36bd7352.js';
|
|
11
|
-
import { u as useTransitionVisibility } from '../../a38bdcd0.js';
|
|
12
|
-
import { T as ThemeProvider } from '../../3181f000.js';
|
|
13
|
-
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
14
|
-
import { Portal } from '../../utils/Portal/index-6e0a7404.js';
|
|
15
|
-
import { H as HeadingLevelProvider } from '../../ebdcb0c7.js';
|
|
16
|
-
import { ClickAwayProvider } from '../../utils/ClickAwayProvider/index-1234ce76.js';
|
|
17
|
-
import { Progress, ProgressVariant } from '../progress/index-6f578c31.js';
|
|
18
|
-
import { i as isComponent } from '../../78df9309.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 };
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import classNames from 'classnames';
|
|
2
|
-
import { getRootClassName, handleBasicClasses } from '@lumx/core/js/utils/className';
|
|
3
|
-
import { u as useTheme } from '../../3181f000.js';
|
|
4
|
-
import { f as forwardRef } from '../../8bce732e.js';
|
|
5
|
-
import { 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 };
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import classNames from 'classnames';
|
|
2
|
-
import { getRootClassName, handleBasicClasses } from '@lumx/core/js/utils/className';
|
|
3
|
-
import { u as useTheme } from '../../3181f000.js';
|
|
4
|
-
import { f as forwardRef } from '../../8bce732e.js';
|
|
5
|
-
import { jsx } from 'react/jsx-runtime';
|
|
6
|
-
import { I as Icon } from '../../bace1bf1.js';
|
|
7
|
-
import { Theme, ColorPalette, Size } from '@lumx/core/js/constants';
|
|
8
|
-
|
|
9
|
-
const mdiDragVertical = 'M9 3h2v2H9zm4 0h2v2h-2zM9 7h2v2H9zm4 0h2v2h-2zm-4 4h2v2H9zm4 0h2v2h-2zm-4 4h2v2H9zm4 0h2v2h-2zm-4 4h2v2H9zm4 0h2v2h-2z';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Component display name.
|
|
13
|
-
*/
|
|
14
|
-
const COMPONENT_NAME = 'DragHandle';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Component default class name and class prefix.
|
|
18
|
-
*/
|
|
19
|
-
const CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* DragHandle component.
|
|
23
|
-
*
|
|
24
|
-
* @param props Component props.
|
|
25
|
-
* @param ref Component ref.
|
|
26
|
-
* @return React element.
|
|
27
|
-
*/
|
|
28
|
-
const DragHandle = forwardRef((props, ref) => {
|
|
29
|
-
const defaultTheme = useTheme();
|
|
30
|
-
const {
|
|
31
|
-
className,
|
|
32
|
-
theme = defaultTheme,
|
|
33
|
-
...forwardedProps
|
|
34
|
-
} = props;
|
|
35
|
-
return /*#__PURE__*/jsx("div", {
|
|
36
|
-
ref: ref,
|
|
37
|
-
...forwardedProps,
|
|
38
|
-
className: classNames(className, handleBasicClasses({
|
|
39
|
-
prefix: CLASSNAME,
|
|
40
|
-
theme
|
|
41
|
-
})),
|
|
42
|
-
children: /*#__PURE__*/jsx(Icon, {
|
|
43
|
-
icon: mdiDragVertical,
|
|
44
|
-
color: theme === Theme.dark ? ColorPalette.light : ColorPalette.dark,
|
|
45
|
-
size: Size.xs
|
|
46
|
-
})
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
DragHandle.displayName = COMPONENT_NAME;
|
|
50
|
-
DragHandle.className = CLASSNAME;
|
|
51
|
-
|
|
52
|
-
export { DragHandle };
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef, useMemo, cloneElement } from 'react';
|
|
2
|
-
import classNames from 'classnames';
|
|
3
|
-
import { L as List } from '../../0ea95af1.js';
|
|
4
|
-
import { P as Popover } from '../../3864a6c1.js';
|
|
5
|
-
import { getRootClassName } from '@lumx/core/js/utils/className';
|
|
6
|
-
import { P as Placement } from '../../4f4c0582.js';
|
|
7
|
-
import { f as forwardRef } from '../../8bce732e.js';
|
|
8
|
-
import { jsx } from 'react/jsx-runtime';
|
|
9
|
-
import { i as isComponent } from '../../78df9309.js';
|
|
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 };
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import React__default, { Children, useRef } from 'react';
|
|
2
|
-
import classNames from 'classnames';
|
|
3
|
-
import isEmpty from 'lodash/isEmpty';
|
|
4
|
-
import { getRootClassName, handleBasicClasses } from '@lumx/core/js/utils/className';
|
|
5
|
-
import { p as partitionMulti } from '../../4daccdd5.js';
|
|
6
|
-
import { u as useTheme } from '../../3181f000.js';
|
|
7
|
-
import { f as forwardRef } from '../../8bce732e.js';
|
|
8
|
-
import { I as IS_BROWSER } from '../../d0e3f49e.js';
|
|
9
|
-
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
10
|
-
import { m as mdiChevronUp, a as mdiChevronDown } from '../../0b9c76cb.js';
|
|
11
|
-
import { i as isComponent } from '../../78df9309.js';
|
|
12
|
-
import { DragHandle } from '../drag-handle/index-80e5af6c.js';
|
|
13
|
-
import { Theme, ColorPalette, Emphasis } from '@lumx/core/js/constants';
|
|
14
|
-
import { I as IconButton } from '../../b83e864b.js';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Component display name.
|
|
18
|
-
*/
|
|
19
|
-
const COMPONENT_NAME = 'ExpansionPanel';
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Component default class name and class prefix.
|
|
23
|
-
*/
|
|
24
|
-
const CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Component default props.
|
|
28
|
-
*/
|
|
29
|
-
const DEFAULT_PROPS = {
|
|
30
|
-
closeMode: 'unmount'
|
|
31
|
-
};
|
|
32
|
-
const isDragHandle = isComponent(DragHandle);
|
|
33
|
-
const isHeader = isComponent('header');
|
|
34
|
-
const isFooter = isComponent('footer');
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* ExpansionPanel component.
|
|
38
|
-
*
|
|
39
|
-
* @param props Component props.
|
|
40
|
-
* @param ref Component ref.
|
|
41
|
-
* @return React element.
|
|
42
|
-
*/
|
|
43
|
-
const ExpansionPanel = forwardRef((props, ref) => {
|
|
44
|
-
const defaultTheme = useTheme() || Theme.light;
|
|
45
|
-
const {
|
|
46
|
-
className,
|
|
47
|
-
closeMode = DEFAULT_PROPS.closeMode,
|
|
48
|
-
children: anyChildren,
|
|
49
|
-
hasBackground,
|
|
50
|
-
hasHeaderDivider,
|
|
51
|
-
isOpen,
|
|
52
|
-
label,
|
|
53
|
-
onClose,
|
|
54
|
-
onOpen,
|
|
55
|
-
onToggleOpen,
|
|
56
|
-
theme = defaultTheme,
|
|
57
|
-
toggleButtonProps,
|
|
58
|
-
...forwardedProps
|
|
59
|
-
} = props;
|
|
60
|
-
const children = Children.toArray(anyChildren);
|
|
61
|
-
|
|
62
|
-
// Partition children by types.
|
|
63
|
-
const [[dragHandle], [header], [footer], content] = partitionMulti(children, [isDragHandle, isHeader, isFooter]);
|
|
64
|
-
|
|
65
|
-
// Either take the header in children or create one with the label.
|
|
66
|
-
const headerProps = /*#__PURE__*/React__default.isValidElement(header) ? header.props : {};
|
|
67
|
-
const headerContent = !isEmpty(headerProps.children) ? headerProps.children : /*#__PURE__*/jsx("span", {
|
|
68
|
-
className: `${CLASSNAME}__label`,
|
|
69
|
-
children: label
|
|
70
|
-
});
|
|
71
|
-
const toggleOpen = event => {
|
|
72
|
-
const shouldOpen = !isOpen;
|
|
73
|
-
if (onOpen && shouldOpen) {
|
|
74
|
-
onOpen(event);
|
|
75
|
-
}
|
|
76
|
-
if (onClose && !shouldOpen) {
|
|
77
|
-
onClose(event);
|
|
78
|
-
}
|
|
79
|
-
if (onToggleOpen) {
|
|
80
|
-
onToggleOpen(shouldOpen, event);
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
const color = theme === Theme.dark ? ColorPalette.light : ColorPalette.dark;
|
|
84
|
-
const rootClassName = classNames(className, handleBasicClasses({
|
|
85
|
-
hasBackground,
|
|
86
|
-
hasHeader: Boolean(!isEmpty(headerProps.children)),
|
|
87
|
-
hasHeaderDivider,
|
|
88
|
-
isClose: !isOpen,
|
|
89
|
-
isDraggable: Boolean(dragHandle),
|
|
90
|
-
isOpen,
|
|
91
|
-
prefix: CLASSNAME,
|
|
92
|
-
theme
|
|
93
|
-
}));
|
|
94
|
-
const wrapperRef = useRef(null);
|
|
95
|
-
|
|
96
|
-
// Children stay visible while the open/close transition is running
|
|
97
|
-
const [isChildrenVisible, setChildrenVisible] = React__default.useState(isOpen);
|
|
98
|
-
const isOpenRef = React__default.useRef(isOpen);
|
|
99
|
-
React__default.useEffect(() => {
|
|
100
|
-
if (isOpen || closeMode === 'hide') {
|
|
101
|
-
setChildrenVisible(true);
|
|
102
|
-
} else if (!IS_BROWSER) {
|
|
103
|
-
// Outside a browser we can't wait for the transition
|
|
104
|
-
setChildrenVisible(false);
|
|
105
|
-
}
|
|
106
|
-
isOpenRef.current = isOpen;
|
|
107
|
-
}, [closeMode, isOpen]);
|
|
108
|
-
|
|
109
|
-
// Change children's visibility on the transition end
|
|
110
|
-
React__default.useEffect(() => {
|
|
111
|
-
const {
|
|
112
|
-
current: wrapper
|
|
113
|
-
} = wrapperRef;
|
|
114
|
-
if (!IS_BROWSER || !wrapper) {
|
|
115
|
-
return undefined;
|
|
116
|
-
}
|
|
117
|
-
const onTransitionEnd = () => {
|
|
118
|
-
setChildrenVisible(isOpenRef.current || closeMode === 'hide');
|
|
119
|
-
};
|
|
120
|
-
wrapper.addEventListener('transitionend', onTransitionEnd);
|
|
121
|
-
return () => wrapper.removeEventListener('transitionend', onTransitionEnd);
|
|
122
|
-
}, [closeMode]);
|
|
123
|
-
return /*#__PURE__*/jsxs("section", {
|
|
124
|
-
ref: ref,
|
|
125
|
-
...forwardedProps,
|
|
126
|
-
className: rootClassName,
|
|
127
|
-
children: [/*#__PURE__*/jsxs("header", {
|
|
128
|
-
className: `${CLASSNAME}__header`,
|
|
129
|
-
onClick: toggleOpen,
|
|
130
|
-
children: [dragHandle && /*#__PURE__*/jsx("div", {
|
|
131
|
-
className: `${CLASSNAME}__header-drag`,
|
|
132
|
-
children: dragHandle
|
|
133
|
-
}), /*#__PURE__*/jsx("div", {
|
|
134
|
-
...headerProps,
|
|
135
|
-
className: `${CLASSNAME}__header-content`,
|
|
136
|
-
children: headerContent
|
|
137
|
-
}), /*#__PURE__*/jsx("div", {
|
|
138
|
-
className: `${CLASSNAME}__header-toggle`,
|
|
139
|
-
children: /*#__PURE__*/jsx(IconButton, {
|
|
140
|
-
...toggleButtonProps,
|
|
141
|
-
color: color,
|
|
142
|
-
emphasis: Emphasis.low,
|
|
143
|
-
icon: isOpen ? mdiChevronUp : mdiChevronDown,
|
|
144
|
-
"aria-expanded": isOpen || 'false'
|
|
145
|
-
})
|
|
146
|
-
})]
|
|
147
|
-
}), /*#__PURE__*/jsx("div", {
|
|
148
|
-
className: `${CLASSNAME}__wrapper`,
|
|
149
|
-
ref: wrapperRef,
|
|
150
|
-
children: (isOpen || isChildrenVisible) && /*#__PURE__*/jsxs("div", {
|
|
151
|
-
className: `${CLASSNAME}__container`,
|
|
152
|
-
children: [/*#__PURE__*/jsx("div", {
|
|
153
|
-
className: `${CLASSNAME}__content`,
|
|
154
|
-
children: content
|
|
155
|
-
}), footer && /*#__PURE__*/jsx("div", {
|
|
156
|
-
className: `${CLASSNAME}__footer`,
|
|
157
|
-
children: footer
|
|
158
|
-
})]
|
|
159
|
-
})
|
|
160
|
-
})]
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
ExpansionPanel.displayName = COMPONENT_NAME;
|
|
164
|
-
ExpansionPanel.className = CLASSNAME;
|
|
165
|
-
ExpansionPanel.defaultProps = DEFAULT_PROPS;
|
|
166
|
-
|
|
167
|
-
export { ExpansionPanel };
|