@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.
- package/index.js +13990 -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,61 +0,0 @@
|
|
|
1
|
-
import classNames from 'classnames';
|
|
2
|
-
import { getRootClassName, handleBasicClasses } from '@lumx/core/js/utils/className';
|
|
3
|
-
import { f as forwardRef } from '../../8bce732e.js';
|
|
4
|
-
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Component display name.
|
|
8
|
-
*/
|
|
9
|
-
const COMPONENT_NAME = 'Toolbar';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Component default class name and class prefix.
|
|
13
|
-
*/
|
|
14
|
-
const CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Component default props.
|
|
18
|
-
*/
|
|
19
|
-
const DEFAULT_PROPS = {};
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Toolbar component.
|
|
23
|
-
*
|
|
24
|
-
* @param props Component props.
|
|
25
|
-
* @param ref Component ref.
|
|
26
|
-
* @return React element.
|
|
27
|
-
*/
|
|
28
|
-
const Toolbar = forwardRef((props, ref) => {
|
|
29
|
-
const {
|
|
30
|
-
after,
|
|
31
|
-
before,
|
|
32
|
-
className,
|
|
33
|
-
label,
|
|
34
|
-
...forwardedProps
|
|
35
|
-
} = props;
|
|
36
|
-
return /*#__PURE__*/jsxs("div", {
|
|
37
|
-
ref: ref,
|
|
38
|
-
...forwardedProps,
|
|
39
|
-
className: classNames(className, handleBasicClasses({
|
|
40
|
-
hasAfter: Boolean(after),
|
|
41
|
-
hasBefore: Boolean(before),
|
|
42
|
-
hasLabel: Boolean(label),
|
|
43
|
-
prefix: CLASSNAME
|
|
44
|
-
})),
|
|
45
|
-
children: [before && /*#__PURE__*/jsx("div", {
|
|
46
|
-
className: `${CLASSNAME}__before`,
|
|
47
|
-
children: before
|
|
48
|
-
}), label && /*#__PURE__*/jsx("div", {
|
|
49
|
-
className: `${CLASSNAME}__label`,
|
|
50
|
-
children: label
|
|
51
|
-
}), after && /*#__PURE__*/jsx("div", {
|
|
52
|
-
className: `${CLASSNAME}__after`,
|
|
53
|
-
children: after
|
|
54
|
-
})]
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
Toolbar.displayName = COMPONENT_NAME;
|
|
58
|
-
Toolbar.className = CLASSNAME;
|
|
59
|
-
Toolbar.defaultProps = DEFAULT_PROPS;
|
|
60
|
-
|
|
61
|
-
export { Toolbar };
|
|
@@ -1,327 +0,0 @@
|
|
|
1
|
-
import React__default, { useMemo, cloneElement, useState, useRef, useEffect } from 'react';
|
|
2
|
-
import classNames from 'classnames';
|
|
3
|
-
import { I as IS_BROWSER, D as DOCUMENT, V as VISUALLY_HIDDEN } from '../../d0e3f49e.js';
|
|
4
|
-
import { getRootClassName, handleBasicClasses } from '@lumx/core/js/utils/className';
|
|
5
|
-
import { m as mergeRefs, u as useMergeRefs } from '../../f0d7d6ea.js';
|
|
6
|
-
import { T as TooltipContextProvider } from '../../9d1336a1.js';
|
|
7
|
-
import { u as useId } from '../../3a1facc0.js';
|
|
8
|
-
import { a as POPOVER_ZINDEX, P as Placement, u as usePopper } from '../../4f4c0582.js';
|
|
9
|
-
import { f as forwardRef } from '../../8bce732e.js';
|
|
10
|
-
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
11
|
-
import { u as useCallbackOnEscape } from '../../76ddefd4.js';
|
|
12
|
-
import { TOOLTIP_LONG_PRESS_DELAY, TOOLTIP_HOVER_DELAY } from '@lumx/core/js/constants';
|
|
13
|
-
import { Portal } from '../../utils/Portal/index-6e0a7404.js';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Make sure tooltip appear above popovers.
|
|
17
|
-
*/
|
|
18
|
-
const TOOLTIP_ZINDEX = POPOVER_ZINDEX + 1;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Add ref and ARIA attribute(s) in tooltip children or wrapped children.
|
|
22
|
-
* Button, IconButton, Icon and React HTML elements don't need to be wrapped but any other kind of children (array, fragment, custom components)
|
|
23
|
-
* will be wrapped in a <span>.
|
|
24
|
-
*/
|
|
25
|
-
const useInjectTooltipRef = options => {
|
|
26
|
-
const {
|
|
27
|
-
children,
|
|
28
|
-
setAnchorElement,
|
|
29
|
-
isMounted,
|
|
30
|
-
id,
|
|
31
|
-
label,
|
|
32
|
-
ariaLinkMode
|
|
33
|
-
} = options;
|
|
34
|
-
// Only add link when mounted
|
|
35
|
-
const linkId = isMounted ? id : undefined;
|
|
36
|
-
return useMemo(() => {
|
|
37
|
-
if (!label) return children;
|
|
38
|
-
|
|
39
|
-
// Non-disabled element
|
|
40
|
-
if (/*#__PURE__*/React__default.isValidElement(children) && children.props.disabled !== true && children.props.isDisabled !== true) {
|
|
41
|
-
const ref = mergeRefs(children.ref, setAnchorElement);
|
|
42
|
-
const props = {
|
|
43
|
-
...children.props,
|
|
44
|
-
ref
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
// Do not add label/description if the tooltip label is already in aria-label
|
|
48
|
-
if (linkId && label !== props['aria-label']) {
|
|
49
|
-
if (props[ariaLinkMode]) props[ariaLinkMode] += ' ';else props[ariaLinkMode] = '';
|
|
50
|
-
props[ariaLinkMode] += linkId;
|
|
51
|
-
}
|
|
52
|
-
return /*#__PURE__*/cloneElement(children, props);
|
|
53
|
-
}
|
|
54
|
-
const aria = linkId ? {
|
|
55
|
-
[ariaLinkMode]: linkId
|
|
56
|
-
} : undefined;
|
|
57
|
-
return /*#__PURE__*/jsx("div", {
|
|
58
|
-
className: "lumx-tooltip-anchor-wrapper",
|
|
59
|
-
ref: setAnchorElement,
|
|
60
|
-
...aria,
|
|
61
|
-
children: children
|
|
62
|
-
});
|
|
63
|
-
}, [label, children, setAnchorElement, linkId, ariaLinkMode]);
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
/** Return true if the browser does not support pointer hover */
|
|
67
|
-
const isHoverNotSupported = () => !!window.matchMedia?.('(hover: none)').matches;
|
|
68
|
-
|
|
69
|
-
/** Check if the focus is visible on the given element */
|
|
70
|
-
const isFocusVisible = element => {
|
|
71
|
-
try {
|
|
72
|
-
return element?.matches?.(':focus-visible, [data-focus-visible-added]');
|
|
73
|
-
} catch (_ignored) {
|
|
74
|
-
// Can fail on non browser env
|
|
75
|
-
return true;
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Hook controlling tooltip visibility using mouse hover the anchor and delay.
|
|
81
|
-
*
|
|
82
|
-
* @param delay Delay in millisecond to display the tooltip.
|
|
83
|
-
* @param anchorElement Tooltip anchor element.
|
|
84
|
-
* @return whether or not to show the tooltip.
|
|
85
|
-
*/
|
|
86
|
-
function useTooltipOpen(delay, anchorElement) {
|
|
87
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
88
|
-
const onPopperMount = useRef(null);
|
|
89
|
-
|
|
90
|
-
// Global close on escape
|
|
91
|
-
const [closeCallback, setCloseCallback] = useState(undefined);
|
|
92
|
-
useCallbackOnEscape(isOpen ? closeCallback : undefined);
|
|
93
|
-
useEffect(() => {
|
|
94
|
-
if (!anchorElement) {
|
|
95
|
-
return undefined;
|
|
96
|
-
}
|
|
97
|
-
let timer;
|
|
98
|
-
let openStartTime;
|
|
99
|
-
let shouldOpen;
|
|
100
|
-
|
|
101
|
-
// Run timer to defer updating the isOpen state.
|
|
102
|
-
const deferUpdate = duration => {
|
|
103
|
-
if (timer) clearTimeout(timer);
|
|
104
|
-
const update = () => {
|
|
105
|
-
setIsOpen(!!shouldOpen);
|
|
106
|
-
};
|
|
107
|
-
// Skip timeout in fake browsers
|
|
108
|
-
if (!IS_BROWSER) update();else timer = setTimeout(update, duration);
|
|
109
|
-
};
|
|
110
|
-
const hoverNotSupported = isHoverNotSupported();
|
|
111
|
-
const hasTouch = 'ontouchstart' in window;
|
|
112
|
-
|
|
113
|
-
// Adapt open/close delay
|
|
114
|
-
const openDelay = delay || (hoverNotSupported ? TOOLTIP_LONG_PRESS_DELAY.open : TOOLTIP_HOVER_DELAY.open);
|
|
115
|
-
const closeDelay = hoverNotSupported ? TOOLTIP_LONG_PRESS_DELAY.close : TOOLTIP_HOVER_DELAY.close;
|
|
116
|
-
|
|
117
|
-
// Open (or/and cancel closing) of tooltip.
|
|
118
|
-
const open = () => {
|
|
119
|
-
if (shouldOpen && !timer) return;
|
|
120
|
-
shouldOpen = true;
|
|
121
|
-
openStartTime = Date.now();
|
|
122
|
-
deferUpdate(openDelay);
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
// Close or cancel opening of tooltip
|
|
126
|
-
const getClose = (overrideDelay = closeDelay) => {
|
|
127
|
-
if (!shouldOpen && !timer) return;
|
|
128
|
-
shouldOpen = false;
|
|
129
|
-
deferUpdate(overrideDelay);
|
|
130
|
-
};
|
|
131
|
-
const close = () => getClose(closeDelay);
|
|
132
|
-
const closeImmediately = () => getClose(0);
|
|
133
|
-
setCloseCallback(() => closeImmediately);
|
|
134
|
-
|
|
135
|
-
// Adapt event to browsers with or without `hover` support.
|
|
136
|
-
const events = [];
|
|
137
|
-
if (hoverNotSupported) {
|
|
138
|
-
/**
|
|
139
|
-
* Handle touchend event
|
|
140
|
-
* If end comes before the open delay => cancel tooltip (close immediate).
|
|
141
|
-
* Else if end comes after the open delay => tooltip takes priority, the anchor's default touch end event is prevented.
|
|
142
|
-
*/
|
|
143
|
-
const longPressEnd = evt => {
|
|
144
|
-
if (!openStartTime) return;
|
|
145
|
-
if (Date.now() - openStartTime >= openDelay) {
|
|
146
|
-
// Tooltip take priority, event prevented.
|
|
147
|
-
evt.stopPropagation();
|
|
148
|
-
evt.preventDefault();
|
|
149
|
-
anchorElement.focus();
|
|
150
|
-
// Close with delay.
|
|
151
|
-
close();
|
|
152
|
-
} else {
|
|
153
|
-
// Close immediately.
|
|
154
|
-
closeImmediately();
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
events.push([anchorElement, hasTouch ? 'touchstart' : 'mousedown', open], [anchorElement, hasTouch ? 'touchend' : 'mouseup', longPressEnd]);
|
|
158
|
-
} else {
|
|
159
|
-
events.push([anchorElement, 'mouseenter', open], [anchorElement, 'mouseleave', close], [anchorElement, 'mouseup', closeImmediately]);
|
|
160
|
-
onPopperMount.current = popperElement => {
|
|
161
|
-
if (!popperElement) return;
|
|
162
|
-
// Popper element hover
|
|
163
|
-
popperElement.addEventListener('mouseenter', open);
|
|
164
|
-
popperElement.addEventListener('mouseleave', close);
|
|
165
|
-
// Add to event list to remove on unmount
|
|
166
|
-
events.push([popperElement, 'mouseenter', open], [popperElement, 'mouseleave', close]);
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
// Events always applied no matter the browser:.
|
|
171
|
-
events.push(
|
|
172
|
-
// Open on focus (only if focus is visible).
|
|
173
|
-
[anchorElement, 'focusin', e => {
|
|
174
|
-
// Skip if focus is not visible
|
|
175
|
-
if (!isFocusVisible(e.target)) return;
|
|
176
|
-
open();
|
|
177
|
-
}],
|
|
178
|
-
// Close on lost focus.
|
|
179
|
-
[anchorElement, 'focusout', closeImmediately]);
|
|
180
|
-
|
|
181
|
-
// Attach events
|
|
182
|
-
for (const [node, eventType, eventHandler] of events) {
|
|
183
|
-
node.addEventListener(eventType, eventHandler);
|
|
184
|
-
}
|
|
185
|
-
return () => {
|
|
186
|
-
// Clear pending timers.
|
|
187
|
-
if (timer) clearTimeout(timer);
|
|
188
|
-
|
|
189
|
-
// Detach events.
|
|
190
|
-
for (const [node, eventType, eventHandler] of events) {
|
|
191
|
-
node.removeEventListener(eventType, eventHandler);
|
|
192
|
-
}
|
|
193
|
-
};
|
|
194
|
-
}, [anchorElement, delay]);
|
|
195
|
-
return {
|
|
196
|
-
isOpen,
|
|
197
|
-
onPopperMount: onPopperMount.current
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
/* eslint-disable react-hooks/rules-of-hooks */
|
|
202
|
-
/**
|
|
203
|
-
* Component display name.
|
|
204
|
-
*/
|
|
205
|
-
const COMPONENT_NAME = 'Tooltip';
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* Component default class name and class prefix.
|
|
209
|
-
*/
|
|
210
|
-
const CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* Component default props.
|
|
214
|
-
*/
|
|
215
|
-
const DEFAULT_PROPS = {
|
|
216
|
-
placement: Placement.BOTTOM,
|
|
217
|
-
closeMode: 'unmount',
|
|
218
|
-
ariaLinkMode: 'aria-describedby',
|
|
219
|
-
zIndex: TOOLTIP_ZINDEX
|
|
220
|
-
};
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* Arrow size (in pixel).
|
|
224
|
-
*/
|
|
225
|
-
const ARROW_SIZE = 8;
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* Tooltip component.
|
|
229
|
-
*
|
|
230
|
-
* @param props Component props.
|
|
231
|
-
* @param ref Component ref.
|
|
232
|
-
* @return React element.
|
|
233
|
-
*/
|
|
234
|
-
const Tooltip = forwardRef((props, ref) => {
|
|
235
|
-
const {
|
|
236
|
-
label,
|
|
237
|
-
children,
|
|
238
|
-
className,
|
|
239
|
-
delay,
|
|
240
|
-
placement = DEFAULT_PROPS.placement,
|
|
241
|
-
forceOpen,
|
|
242
|
-
closeMode = DEFAULT_PROPS.closeMode,
|
|
243
|
-
ariaLinkMode = DEFAULT_PROPS.ariaLinkMode,
|
|
244
|
-
zIndex = DEFAULT_PROPS.zIndex,
|
|
245
|
-
...forwardedProps
|
|
246
|
-
} = props;
|
|
247
|
-
// Disable in SSR.
|
|
248
|
-
if (!DOCUMENT) {
|
|
249
|
-
return /*#__PURE__*/jsx(Fragment, {
|
|
250
|
-
children: children
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
const id = useId();
|
|
254
|
-
const [popperElement, setPopperElement] = useState(null);
|
|
255
|
-
const [anchorElement, setAnchorElement] = useState(null);
|
|
256
|
-
const {
|
|
257
|
-
styles,
|
|
258
|
-
attributes,
|
|
259
|
-
update
|
|
260
|
-
} = usePopper(anchorElement, popperElement, {
|
|
261
|
-
placement,
|
|
262
|
-
modifiers: [{
|
|
263
|
-
name: 'offset',
|
|
264
|
-
options: {
|
|
265
|
-
offset: [0, ARROW_SIZE]
|
|
266
|
-
}
|
|
267
|
-
}]
|
|
268
|
-
});
|
|
269
|
-
const position = attributes?.popper?.['data-popper-placement'] ?? placement;
|
|
270
|
-
const {
|
|
271
|
-
isOpen: isActivated,
|
|
272
|
-
onPopperMount
|
|
273
|
-
} = useTooltipOpen(delay, anchorElement);
|
|
274
|
-
const isOpen = (isActivated || forceOpen) && !!label;
|
|
275
|
-
const isMounted = !!label && (isOpen || closeMode === 'hide');
|
|
276
|
-
const isHidden = !isOpen && closeMode === 'hide';
|
|
277
|
-
const wrappedChildren = useInjectTooltipRef({
|
|
278
|
-
children,
|
|
279
|
-
setAnchorElement,
|
|
280
|
-
isMounted,
|
|
281
|
-
id,
|
|
282
|
-
label,
|
|
283
|
-
ariaLinkMode: ariaLinkMode
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
// Update on open
|
|
287
|
-
React__default.useEffect(() => {
|
|
288
|
-
if (isOpen || popperElement) update?.();
|
|
289
|
-
}, [isOpen, update, popperElement]);
|
|
290
|
-
const labelLines = label ? label.split('\n') : [];
|
|
291
|
-
const tooltipRef = useMergeRefs(ref, setPopperElement, onPopperMount);
|
|
292
|
-
return /*#__PURE__*/jsxs(Fragment, {
|
|
293
|
-
children: [/*#__PURE__*/jsx(TooltipContextProvider, {
|
|
294
|
-
children: wrappedChildren
|
|
295
|
-
}), isMounted && /*#__PURE__*/jsx(Portal, {
|
|
296
|
-
children: /*#__PURE__*/jsxs("div", {
|
|
297
|
-
ref: tooltipRef,
|
|
298
|
-
...forwardedProps,
|
|
299
|
-
id: id,
|
|
300
|
-
role: "tooltip",
|
|
301
|
-
className: classNames(className, handleBasicClasses({
|
|
302
|
-
prefix: CLASSNAME,
|
|
303
|
-
position,
|
|
304
|
-
isInitializing: !styles.popper?.transform
|
|
305
|
-
}), isHidden && VISUALLY_HIDDEN),
|
|
306
|
-
style: {
|
|
307
|
-
...(isHidden ? undefined : styles.popper),
|
|
308
|
-
zIndex
|
|
309
|
-
},
|
|
310
|
-
...attributes.popper,
|
|
311
|
-
children: [/*#__PURE__*/jsx("div", {
|
|
312
|
-
className: `${CLASSNAME}__arrow`
|
|
313
|
-
}), /*#__PURE__*/jsx("div", {
|
|
314
|
-
className: `${CLASSNAME}__inner`,
|
|
315
|
-
children: labelLines.map(line => /*#__PURE__*/jsx("p", {
|
|
316
|
-
children: line
|
|
317
|
-
}, line))
|
|
318
|
-
})]
|
|
319
|
-
})
|
|
320
|
-
})]
|
|
321
|
-
});
|
|
322
|
-
});
|
|
323
|
-
Tooltip.displayName = COMPONENT_NAME;
|
|
324
|
-
Tooltip.className = CLASSNAME;
|
|
325
|
-
Tooltip.defaultProps = DEFAULT_PROPS;
|
|
326
|
-
|
|
327
|
-
export { Tooltip };
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import React__default from 'react';
|
|
2
|
-
import classNames from 'classnames';
|
|
3
|
-
import { getRootClassName, handleBasicClasses } from '@lumx/core/js/utils/className';
|
|
4
|
-
import { u as useBooleanState } from '../../2a3d237c.js';
|
|
5
|
-
import { u as useId } from '../../3a1facc0.js';
|
|
6
|
-
import { u as useTheme } from '../../3181f000.js';
|
|
7
|
-
import { f as forwardRef } from '../../8bce732e.js';
|
|
8
|
-
import { V as VISUALLY_HIDDEN } from '../../d0e3f49e.js';
|
|
9
|
-
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
10
|
-
import { useDisableStateProps } from '../../utils/disabled/index-075b99c3.js';
|
|
11
|
-
import { AspectRatio, Size, Theme } from '@lumx/core/js/constants';
|
|
12
|
-
import { I as Icon } from '../../bace1bf1.js';
|
|
13
|
-
|
|
14
|
-
const UploaderVariant = {
|
|
15
|
-
square: 'square',
|
|
16
|
-
rounded: 'rounded',
|
|
17
|
-
circle: 'circle'
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Uploader sizes.
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Extend native HTML input props with specialized `onChange` providing the a `File` array.
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Defines the props of the component.
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Component display name.
|
|
34
|
-
*/
|
|
35
|
-
const COMPONENT_NAME = 'Uploader';
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Component default class name and class prefix.
|
|
39
|
-
*/
|
|
40
|
-
const CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Component default props.
|
|
44
|
-
*/
|
|
45
|
-
const DEFAULT_PROPS = {
|
|
46
|
-
aspectRatio: AspectRatio.horizontal,
|
|
47
|
-
size: Size.xl,
|
|
48
|
-
variant: UploaderVariant.square
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Uploader component.
|
|
53
|
-
*
|
|
54
|
-
* @param props Component props.
|
|
55
|
-
* @param ref Component ref.
|
|
56
|
-
* @return React element.
|
|
57
|
-
*/
|
|
58
|
-
const Uploader = forwardRef((props, ref) => {
|
|
59
|
-
const {
|
|
60
|
-
disabledStateProps,
|
|
61
|
-
otherProps,
|
|
62
|
-
isAnyDisabled
|
|
63
|
-
} = useDisableStateProps(props);
|
|
64
|
-
const defaultTheme = useTheme() || Theme.light;
|
|
65
|
-
const {
|
|
66
|
-
aspectRatio = DEFAULT_PROPS.aspectRatio,
|
|
67
|
-
className,
|
|
68
|
-
label,
|
|
69
|
-
icon,
|
|
70
|
-
size = DEFAULT_PROPS.size,
|
|
71
|
-
theme = defaultTheme,
|
|
72
|
-
variant = DEFAULT_PROPS.variant,
|
|
73
|
-
fileInputProps,
|
|
74
|
-
onClick,
|
|
75
|
-
...forwardedProps
|
|
76
|
-
} = otherProps;
|
|
77
|
-
// Adjust to square aspect ratio when using circle variants.
|
|
78
|
-
const adjustedAspectRatio = variant === UploaderVariant.circle ? AspectRatio.square : aspectRatio;
|
|
79
|
-
const handleClick = React__default.useCallback(evt => {
|
|
80
|
-
if (isAnyDisabled) {
|
|
81
|
-
evt.preventDefault();
|
|
82
|
-
} else {
|
|
83
|
-
onClick?.(evt);
|
|
84
|
-
}
|
|
85
|
-
}, [isAnyDisabled, onClick]);
|
|
86
|
-
const generatedInputId = useId();
|
|
87
|
-
const inputId = fileInputProps?.id || generatedInputId;
|
|
88
|
-
const [isDragHovering, unsetDragHovering, setDragHovering] = useBooleanState(false);
|
|
89
|
-
const wrapper = fileInputProps ? {
|
|
90
|
-
Component: 'label',
|
|
91
|
-
props: {
|
|
92
|
-
htmlFor: inputId
|
|
93
|
-
}
|
|
94
|
-
} : {
|
|
95
|
-
Component: 'button',
|
|
96
|
-
props: {
|
|
97
|
-
type: 'button',
|
|
98
|
-
...disabledStateProps
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
const onChange = React__default.useMemo(() => {
|
|
102
|
-
if (isAnyDisabled || !fileInputProps?.onChange) return undefined;
|
|
103
|
-
return evt => {
|
|
104
|
-
const fileList = evt.target.files;
|
|
105
|
-
const files = fileList ? Array.from(fileList) : [];
|
|
106
|
-
fileInputProps.onChange(files, evt);
|
|
107
|
-
};
|
|
108
|
-
}, [isAnyDisabled, fileInputProps]);
|
|
109
|
-
return /*#__PURE__*/jsxs(wrapper.Component, {
|
|
110
|
-
ref: ref,
|
|
111
|
-
...wrapper.props,
|
|
112
|
-
...forwardedProps,
|
|
113
|
-
onClick: handleClick,
|
|
114
|
-
className: classNames(className, handleBasicClasses({
|
|
115
|
-
aspectRatio: adjustedAspectRatio,
|
|
116
|
-
prefix: CLASSNAME,
|
|
117
|
-
size,
|
|
118
|
-
theme,
|
|
119
|
-
variant,
|
|
120
|
-
isDragHovering,
|
|
121
|
-
isDisabled: isAnyDisabled
|
|
122
|
-
})),
|
|
123
|
-
children: [/*#__PURE__*/jsx("span", {
|
|
124
|
-
className: `${CLASSNAME}__background`
|
|
125
|
-
}), /*#__PURE__*/jsxs("span", {
|
|
126
|
-
className: `${CLASSNAME}__wrapper`,
|
|
127
|
-
children: [icon && /*#__PURE__*/jsx(Icon, {
|
|
128
|
-
className: `${CLASSNAME}__icon`,
|
|
129
|
-
icon: icon,
|
|
130
|
-
size: Size.s
|
|
131
|
-
}), label && /*#__PURE__*/jsx("span", {
|
|
132
|
-
className: `${CLASSNAME}__label`,
|
|
133
|
-
children: label
|
|
134
|
-
})]
|
|
135
|
-
}), fileInputProps && /*#__PURE__*/jsx("input", {
|
|
136
|
-
type: "file",
|
|
137
|
-
id: inputId,
|
|
138
|
-
className: `${CLASSNAME}__input ${VISUALLY_HIDDEN}`,
|
|
139
|
-
...disabledStateProps,
|
|
140
|
-
...fileInputProps,
|
|
141
|
-
readOnly: isAnyDisabled,
|
|
142
|
-
onChange: onChange,
|
|
143
|
-
onDragEnter: setDragHovering,
|
|
144
|
-
onDragLeave: unsetDragHovering,
|
|
145
|
-
onDrop: unsetDragHovering
|
|
146
|
-
})]
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
Uploader.displayName = COMPONENT_NAME;
|
|
150
|
-
Uploader.className = CLASSNAME;
|
|
151
|
-
Uploader.defaultProps = DEFAULT_PROPS;
|
|
152
|
-
|
|
153
|
-
export { Uploader, UploaderVariant };
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import React__default from 'react';
|
|
2
|
-
import classNames from 'classnames';
|
|
3
|
-
import isEmpty from 'lodash/isEmpty';
|
|
4
|
-
import set from 'lodash/set';
|
|
5
|
-
import { getRootClassName, handleBasicClasses } from '@lumx/core/js/utils/className';
|
|
6
|
-
import { f as forwardRef } from '../../8bce732e.js';
|
|
7
|
-
import { u as useTheme } from '../../3181f000.js';
|
|
8
|
-
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
9
|
-
import { Orientation, Size, Theme, ColorPalette } from '@lumx/core/js/constants';
|
|
10
|
-
import { Avatar } from '../avatar/index-b8bc3cae.js';
|
|
11
|
-
import { Link } from '../link/index-008bae4b.js';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Component display name.
|
|
15
|
-
*/
|
|
16
|
-
const COMPONENT_NAME = 'UserBlock';
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Component default class name and class prefix.
|
|
20
|
-
*/
|
|
21
|
-
const CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Component default props.
|
|
25
|
-
*/
|
|
26
|
-
const DEFAULT_PROPS = {
|
|
27
|
-
orientation: Orientation.horizontal,
|
|
28
|
-
size: Size.m
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* UserBlock component.
|
|
33
|
-
*
|
|
34
|
-
* @param props Component props.
|
|
35
|
-
* @param ref Component ref.
|
|
36
|
-
* @return React element.
|
|
37
|
-
*/
|
|
38
|
-
const UserBlock = forwardRef((props, ref) => {
|
|
39
|
-
const defaultTheme = useTheme() || Theme.light;
|
|
40
|
-
const {
|
|
41
|
-
avatarProps,
|
|
42
|
-
className,
|
|
43
|
-
fields,
|
|
44
|
-
linkProps,
|
|
45
|
-
linkAs,
|
|
46
|
-
multipleActions,
|
|
47
|
-
name,
|
|
48
|
-
nameProps,
|
|
49
|
-
onClick,
|
|
50
|
-
onMouseEnter,
|
|
51
|
-
onMouseLeave,
|
|
52
|
-
orientation = DEFAULT_PROPS.orientation,
|
|
53
|
-
simpleAction,
|
|
54
|
-
size = DEFAULT_PROPS.size,
|
|
55
|
-
theme = defaultTheme,
|
|
56
|
-
children,
|
|
57
|
-
additionalFields,
|
|
58
|
-
after,
|
|
59
|
-
...forwardedProps
|
|
60
|
-
} = props;
|
|
61
|
-
let componentSize = size;
|
|
62
|
-
|
|
63
|
-
// Special case - When using vertical orientation force the size to be Sizes.l.
|
|
64
|
-
if (orientation === Orientation.vertical) {
|
|
65
|
-
componentSize = Size.l;
|
|
66
|
-
}
|
|
67
|
-
const shouldDisplayActions = orientation === Orientation.vertical;
|
|
68
|
-
const isLink = Boolean(linkProps?.href || linkAs);
|
|
69
|
-
const isClickable = !!onClick || isLink;
|
|
70
|
-
const nameBlock = React__default.useMemo(() => {
|
|
71
|
-
if (isEmpty(name)) {
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
let NameComponent = 'span';
|
|
75
|
-
const nProps = {
|
|
76
|
-
...nameProps,
|
|
77
|
-
className: classNames(`${CLASSNAME}__name`, linkProps?.className, nameProps?.className)
|
|
78
|
-
};
|
|
79
|
-
if (isClickable) {
|
|
80
|
-
NameComponent = Link;
|
|
81
|
-
Object.assign(nProps, {
|
|
82
|
-
...linkProps,
|
|
83
|
-
onClick,
|
|
84
|
-
linkAs,
|
|
85
|
-
color: ColorPalette.dark
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
// Disable avatar focus since the name block is the same link / same button.
|
|
89
|
-
if (avatarProps) {
|
|
90
|
-
set(avatarProps, ['thumbnailProps', 'tabIndex'], -1);
|
|
91
|
-
}
|
|
92
|
-
return /*#__PURE__*/jsx(NameComponent, {
|
|
93
|
-
...nProps,
|
|
94
|
-
children: name
|
|
95
|
-
});
|
|
96
|
-
}, [avatarProps, isClickable, linkAs, linkProps, name, nameProps, onClick]);
|
|
97
|
-
const shouldDisplayFields = componentSize !== Size.s && componentSize !== Size.xs;
|
|
98
|
-
const fieldsBlock = fields && shouldDisplayFields && /*#__PURE__*/jsx("div", {
|
|
99
|
-
className: `${CLASSNAME}__fields`,
|
|
100
|
-
children: fields.map((field, idx) => /*#__PURE__*/jsx("span", {
|
|
101
|
-
className: `${CLASSNAME}__field`,
|
|
102
|
-
children: field
|
|
103
|
-
}, idx))
|
|
104
|
-
});
|
|
105
|
-
return /*#__PURE__*/jsxs("div", {
|
|
106
|
-
ref: ref,
|
|
107
|
-
...forwardedProps,
|
|
108
|
-
className: classNames(className, handleBasicClasses({
|
|
109
|
-
prefix: CLASSNAME,
|
|
110
|
-
orientation,
|
|
111
|
-
size: componentSize,
|
|
112
|
-
theme,
|
|
113
|
-
isClickable
|
|
114
|
-
})),
|
|
115
|
-
onMouseLeave: onMouseLeave,
|
|
116
|
-
onMouseEnter: onMouseEnter,
|
|
117
|
-
children: [avatarProps && /*#__PURE__*/jsx(Avatar, {
|
|
118
|
-
linkAs: linkAs,
|
|
119
|
-
linkProps: linkProps,
|
|
120
|
-
alt: "",
|
|
121
|
-
...avatarProps,
|
|
122
|
-
className: classNames(`${CLASSNAME}__avatar`, avatarProps.className),
|
|
123
|
-
size: componentSize,
|
|
124
|
-
onClick: onClick,
|
|
125
|
-
theme: theme
|
|
126
|
-
}), (fields || name || children || additionalFields) && /*#__PURE__*/jsxs("div", {
|
|
127
|
-
className: `${CLASSNAME}__wrapper`,
|
|
128
|
-
children: [children || nameBlock, fieldsBlock, shouldDisplayFields ? additionalFields : null]
|
|
129
|
-
}), shouldDisplayActions && simpleAction && /*#__PURE__*/jsx("div", {
|
|
130
|
-
className: `${CLASSNAME}__action`,
|
|
131
|
-
children: simpleAction
|
|
132
|
-
}), shouldDisplayActions && multipleActions && /*#__PURE__*/jsx("div", {
|
|
133
|
-
className: `${CLASSNAME}__actions`,
|
|
134
|
-
children: multipleActions
|
|
135
|
-
}), after ? /*#__PURE__*/jsx("div", {
|
|
136
|
-
className: `${CLASSNAME}__after`,
|
|
137
|
-
children: after
|
|
138
|
-
}) : null]
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
UserBlock.displayName = COMPONENT_NAME;
|
|
142
|
-
UserBlock.className = CLASSNAME;
|
|
143
|
-
UserBlock.defaultProps = DEFAULT_PROPS;
|
|
144
|
-
|
|
145
|
-
export { UserBlock };
|
package/_internal/d0e3f49e.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import '@lumx/core/js/constants';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Optional global `window` instance (not defined when running SSR).
|
|
5
|
-
*/
|
|
6
|
-
const WINDOW = typeof window !== 'undefined' ? window : undefined;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Optional global `document` instance (not defined when running SSR).
|
|
10
|
-
*/
|
|
11
|
-
const DOCUMENT = typeof document !== 'undefined' ? document : undefined;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Check if we are running in a true browser
|
|
15
|
-
*/
|
|
16
|
-
const IS_BROWSER = typeof navigator !== 'undefined' && !navigator.userAgent.includes('jsdom');
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Visually hidden a11y utility class name
|
|
20
|
-
*/
|
|
21
|
-
const VISUALLY_HIDDEN = 'visually-hidden';
|
|
22
|
-
|
|
23
|
-
export { DOCUMENT as D, IS_BROWSER as I, VISUALLY_HIDDEN as V, WINDOW as W };
|