@lumx/react 4.20.0-next.4 → 4.20.0
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 +85 -66
- package/index.js +828 -380
- package/index.js.map +1 -1
- package/package.json +7 -6
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ColorVariant as ColorVariant$1, Size as Size$1, VISUALLY_HIDDEN, Theme as Theme$1, AspectRatio as AspectRatio$1, DOCUMENT, IS_BROWSER as IS_BROWSER$1, Emphasis as Emphasis$1, WINDOW, DIALOG_TRANSITION_DURATION, Orientation as Orientation$1, NOTIFICATION_TRANSITION_DURATION, Kind as Kind$1, Alignment as Alignment$1, ColorPalette as ColorPalette$1 } from '@lumx/core/js/constants';
|
|
1
|
+
import { ColorVariant as ColorVariant$1, Size as Size$1, VISUALLY_HIDDEN, Theme as Theme$1, AspectRatio as AspectRatio$1, DOCUMENT, IS_BROWSER as IS_BROWSER$1, Emphasis as Emphasis$1, WINDOW, DIALOG_TRANSITION_DURATION, Typography as Typography$1, Orientation as Orientation$1, NOTIFICATION_TRANSITION_DURATION, Kind as Kind$1, Alignment as Alignment$1, ColorPalette as ColorPalette$1 } from '@lumx/core/js/constants';
|
|
2
2
|
export * from '@lumx/core/js/constants';
|
|
3
3
|
export * from '@lumx/core/js/types';
|
|
4
4
|
import * as React from 'react';
|
|
@@ -6415,29 +6415,6 @@ function setupListbox(handle, signal, notify, options) {
|
|
|
6415
6415
|
return focusNav;
|
|
6416
6416
|
}
|
|
6417
6417
|
|
|
6418
|
-
/**
|
|
6419
|
-
* Wrap `fn` so that, no matter how many times the returned function is called within the same
|
|
6420
|
-
* microtask cycle, `fn` only runs once at the end of that cycle.
|
|
6421
|
-
*/
|
|
6422
|
-
function debounceMicrotask(fn) {
|
|
6423
|
-
let running = false;
|
|
6424
|
-
const debounced = () => {
|
|
6425
|
-
if (!running) {
|
|
6426
|
-
running = true;
|
|
6427
|
-
queueMicrotask(() => {
|
|
6428
|
-
if (running) {
|
|
6429
|
-
running = false;
|
|
6430
|
-
fn();
|
|
6431
|
-
}
|
|
6432
|
-
});
|
|
6433
|
-
}
|
|
6434
|
-
};
|
|
6435
|
-
debounced.cancel = () => {
|
|
6436
|
-
running = false;
|
|
6437
|
-
};
|
|
6438
|
-
return debounced;
|
|
6439
|
-
}
|
|
6440
|
-
|
|
6441
6418
|
/** Options for configuring the shared combobox behavior. */
|
|
6442
6419
|
|
|
6443
6420
|
/**
|
|
@@ -6498,8 +6475,18 @@ function setupCombobox(callbacks, options, onTriggerAttach) {
|
|
|
6498
6475
|
loadingAnnouncement: new Set()
|
|
6499
6476
|
};
|
|
6500
6477
|
|
|
6478
|
+
/**
|
|
6479
|
+
* Last value dispatched for each event. Kept in sync so pull-based subscribers — React's
|
|
6480
|
+
* `useSyncExternalStore` via {@link ComboboxHandle.getSnapshot} — can read the current value
|
|
6481
|
+
* during their own render/commit. This lets React catch changes that happened between a
|
|
6482
|
+
* consumer's render and its subscription (e.g. options registered by child effects before the
|
|
6483
|
+
* consumer subscribed, since `optionsChange` is not replayed on subscribe).
|
|
6484
|
+
*/
|
|
6485
|
+
const latestValues = {};
|
|
6486
|
+
|
|
6501
6487
|
/** Notify all subscribers for a given event. */
|
|
6502
6488
|
function notify(event, value) {
|
|
6489
|
+
latestValues[event] = value;
|
|
6503
6490
|
subscribers[event].forEach(cb => cb(value));
|
|
6504
6491
|
}
|
|
6505
6492
|
|
|
@@ -6522,9 +6509,8 @@ function setupCombobox(callbacks, options, onTriggerAttach) {
|
|
|
6522
6509
|
* or if the input value changed while the list is empty (so `emptyMessage` callbacks get
|
|
6523
6510
|
* the updated query string).
|
|
6524
6511
|
* Called whenever the set of visible options may have changed (option register/unregister, filter change).
|
|
6525
|
-
* (debounced in a microtask)
|
|
6526
6512
|
*/
|
|
6527
|
-
|
|
6513
|
+
function notifyVisibilityChange() {
|
|
6528
6514
|
for (const [sectionElement] of sectionRegistrations) {
|
|
6529
6515
|
notifySection(sectionElement, sectionRegistrations, optionRegistrations);
|
|
6530
6516
|
}
|
|
@@ -6545,7 +6531,7 @@ function setupCombobox(callbacks, options, onTriggerAttach) {
|
|
|
6545
6531
|
if (isOpenState) {
|
|
6546
6532
|
trigger?.setAttribute('aria-expanded', String(hasVisibleContent()));
|
|
6547
6533
|
}
|
|
6548
|
-
}
|
|
6534
|
+
}
|
|
6549
6535
|
|
|
6550
6536
|
// ── Skeleton loading tracking ──────────────────────────────
|
|
6551
6537
|
|
|
@@ -6931,6 +6917,9 @@ function setupCombobox(callbacks, options, onTriggerAttach) {
|
|
|
6931
6917
|
subscribers[event].delete(callback);
|
|
6932
6918
|
};
|
|
6933
6919
|
},
|
|
6920
|
+
getSnapshot(event) {
|
|
6921
|
+
return latestValues[event];
|
|
6922
|
+
},
|
|
6934
6923
|
destroy() {
|
|
6935
6924
|
detach();
|
|
6936
6925
|
trigger = null;
|
|
@@ -6939,10 +6928,13 @@ function setupCombobox(callbacks, options, onTriggerAttach) {
|
|
|
6939
6928
|
lastOptionsLength = 0;
|
|
6940
6929
|
lastInputValue = '';
|
|
6941
6930
|
lastLoadingState = false;
|
|
6931
|
+
// Drop cached snapshots so `getSnapshot` doesn't return stale values after destroy.
|
|
6932
|
+
for (const key of Object.keys(latestValues)) {
|
|
6933
|
+
delete latestValues[key];
|
|
6934
|
+
}
|
|
6942
6935
|
optionRegistrations.clear();
|
|
6943
6936
|
sectionRegistrations.clear();
|
|
6944
6937
|
skeletonCount = 0;
|
|
6945
|
-
notifyVisibilityChange.cancel();
|
|
6946
6938
|
clearTimeout(loadingTimer);
|
|
6947
6939
|
announcementSent = false;
|
|
6948
6940
|
// Clear all subscribers
|
|
@@ -7267,6 +7259,203 @@ const ComboboxButton$1 = (props, {
|
|
|
7267
7259
|
/** Same as `React.forwardRef` but inferring Ref type from the `as` prop. */
|
|
7268
7260
|
const forwardRefPolymorphic = React__default.forwardRef;
|
|
7269
7261
|
|
|
7262
|
+
var shim = {exports: {}};
|
|
7263
|
+
|
|
7264
|
+
var useSyncExternalStoreShim_production = {};
|
|
7265
|
+
|
|
7266
|
+
/**
|
|
7267
|
+
* @license React
|
|
7268
|
+
* use-sync-external-store-shim.production.js
|
|
7269
|
+
*
|
|
7270
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
7271
|
+
*
|
|
7272
|
+
* This source code is licensed under the MIT license found in the
|
|
7273
|
+
* LICENSE file in the root directory of this source tree.
|
|
7274
|
+
*/
|
|
7275
|
+
|
|
7276
|
+
var hasRequiredUseSyncExternalStoreShim_production;
|
|
7277
|
+
|
|
7278
|
+
function requireUseSyncExternalStoreShim_production () {
|
|
7279
|
+
if (hasRequiredUseSyncExternalStoreShim_production) return useSyncExternalStoreShim_production;
|
|
7280
|
+
hasRequiredUseSyncExternalStoreShim_production = 1;
|
|
7281
|
+
var React = React__default;
|
|
7282
|
+
function is(x, y) {
|
|
7283
|
+
return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y);
|
|
7284
|
+
}
|
|
7285
|
+
var objectIs = "function" === typeof Object.is ? Object.is : is,
|
|
7286
|
+
useState = React.useState,
|
|
7287
|
+
useEffect = React.useEffect,
|
|
7288
|
+
useLayoutEffect = React.useLayoutEffect,
|
|
7289
|
+
useDebugValue = React.useDebugValue;
|
|
7290
|
+
function useSyncExternalStore$2(subscribe, getSnapshot) {
|
|
7291
|
+
var value = getSnapshot(),
|
|
7292
|
+
_useState = useState({ inst: { value: value, getSnapshot: getSnapshot } }),
|
|
7293
|
+
inst = _useState[0].inst,
|
|
7294
|
+
forceUpdate = _useState[1];
|
|
7295
|
+
useLayoutEffect(
|
|
7296
|
+
function () {
|
|
7297
|
+
inst.value = value;
|
|
7298
|
+
inst.getSnapshot = getSnapshot;
|
|
7299
|
+
checkIfSnapshotChanged(inst) && forceUpdate({ inst: inst });
|
|
7300
|
+
},
|
|
7301
|
+
[subscribe, value, getSnapshot]
|
|
7302
|
+
);
|
|
7303
|
+
useEffect(
|
|
7304
|
+
function () {
|
|
7305
|
+
checkIfSnapshotChanged(inst) && forceUpdate({ inst: inst });
|
|
7306
|
+
return subscribe(function () {
|
|
7307
|
+
checkIfSnapshotChanged(inst) && forceUpdate({ inst: inst });
|
|
7308
|
+
});
|
|
7309
|
+
},
|
|
7310
|
+
[subscribe]
|
|
7311
|
+
);
|
|
7312
|
+
useDebugValue(value);
|
|
7313
|
+
return value;
|
|
7314
|
+
}
|
|
7315
|
+
function checkIfSnapshotChanged(inst) {
|
|
7316
|
+
var latestGetSnapshot = inst.getSnapshot;
|
|
7317
|
+
inst = inst.value;
|
|
7318
|
+
try {
|
|
7319
|
+
var nextValue = latestGetSnapshot();
|
|
7320
|
+
return !objectIs(inst, nextValue);
|
|
7321
|
+
} catch (error) {
|
|
7322
|
+
return true;
|
|
7323
|
+
}
|
|
7324
|
+
}
|
|
7325
|
+
function useSyncExternalStore$1(subscribe, getSnapshot) {
|
|
7326
|
+
return getSnapshot();
|
|
7327
|
+
}
|
|
7328
|
+
var shim =
|
|
7329
|
+
"undefined" === typeof window ||
|
|
7330
|
+
"undefined" === typeof window.document ||
|
|
7331
|
+
"undefined" === typeof window.document.createElement
|
|
7332
|
+
? useSyncExternalStore$1
|
|
7333
|
+
: useSyncExternalStore$2;
|
|
7334
|
+
useSyncExternalStoreShim_production.useSyncExternalStore =
|
|
7335
|
+
void 0 !== React.useSyncExternalStore ? React.useSyncExternalStore : shim;
|
|
7336
|
+
return useSyncExternalStoreShim_production;
|
|
7337
|
+
}
|
|
7338
|
+
|
|
7339
|
+
var useSyncExternalStoreShim_development = {};
|
|
7340
|
+
|
|
7341
|
+
/**
|
|
7342
|
+
* @license React
|
|
7343
|
+
* use-sync-external-store-shim.development.js
|
|
7344
|
+
*
|
|
7345
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
7346
|
+
*
|
|
7347
|
+
* This source code is licensed under the MIT license found in the
|
|
7348
|
+
* LICENSE file in the root directory of this source tree.
|
|
7349
|
+
*/
|
|
7350
|
+
|
|
7351
|
+
var hasRequiredUseSyncExternalStoreShim_development;
|
|
7352
|
+
|
|
7353
|
+
function requireUseSyncExternalStoreShim_development () {
|
|
7354
|
+
if (hasRequiredUseSyncExternalStoreShim_development) return useSyncExternalStoreShim_development;
|
|
7355
|
+
hasRequiredUseSyncExternalStoreShim_development = 1;
|
|
7356
|
+
"production" !== process.env.NODE_ENV &&
|
|
7357
|
+
(function () {
|
|
7358
|
+
function is(x, y) {
|
|
7359
|
+
return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y);
|
|
7360
|
+
}
|
|
7361
|
+
function useSyncExternalStore$2(subscribe, getSnapshot) {
|
|
7362
|
+
didWarnOld18Alpha ||
|
|
7363
|
+
void 0 === React.startTransition ||
|
|
7364
|
+
((didWarnOld18Alpha = true),
|
|
7365
|
+
console.error(
|
|
7366
|
+
"You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."
|
|
7367
|
+
));
|
|
7368
|
+
var value = getSnapshot();
|
|
7369
|
+
if (!didWarnUncachedGetSnapshot) {
|
|
7370
|
+
var cachedValue = getSnapshot();
|
|
7371
|
+
objectIs(value, cachedValue) ||
|
|
7372
|
+
(console.error(
|
|
7373
|
+
"The result of getSnapshot should be cached to avoid an infinite loop"
|
|
7374
|
+
),
|
|
7375
|
+
(didWarnUncachedGetSnapshot = true));
|
|
7376
|
+
}
|
|
7377
|
+
cachedValue = useState({
|
|
7378
|
+
inst: { value: value, getSnapshot: getSnapshot }
|
|
7379
|
+
});
|
|
7380
|
+
var inst = cachedValue[0].inst,
|
|
7381
|
+
forceUpdate = cachedValue[1];
|
|
7382
|
+
useLayoutEffect(
|
|
7383
|
+
function () {
|
|
7384
|
+
inst.value = value;
|
|
7385
|
+
inst.getSnapshot = getSnapshot;
|
|
7386
|
+
checkIfSnapshotChanged(inst) && forceUpdate({ inst: inst });
|
|
7387
|
+
},
|
|
7388
|
+
[subscribe, value, getSnapshot]
|
|
7389
|
+
);
|
|
7390
|
+
useEffect(
|
|
7391
|
+
function () {
|
|
7392
|
+
checkIfSnapshotChanged(inst) && forceUpdate({ inst: inst });
|
|
7393
|
+
return subscribe(function () {
|
|
7394
|
+
checkIfSnapshotChanged(inst) && forceUpdate({ inst: inst });
|
|
7395
|
+
});
|
|
7396
|
+
},
|
|
7397
|
+
[subscribe]
|
|
7398
|
+
);
|
|
7399
|
+
useDebugValue(value);
|
|
7400
|
+
return value;
|
|
7401
|
+
}
|
|
7402
|
+
function checkIfSnapshotChanged(inst) {
|
|
7403
|
+
var latestGetSnapshot = inst.getSnapshot;
|
|
7404
|
+
inst = inst.value;
|
|
7405
|
+
try {
|
|
7406
|
+
var nextValue = latestGetSnapshot();
|
|
7407
|
+
return !objectIs(inst, nextValue);
|
|
7408
|
+
} catch (error) {
|
|
7409
|
+
return true;
|
|
7410
|
+
}
|
|
7411
|
+
}
|
|
7412
|
+
function useSyncExternalStore$1(subscribe, getSnapshot) {
|
|
7413
|
+
return getSnapshot();
|
|
7414
|
+
}
|
|
7415
|
+
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
|
|
7416
|
+
"function" ===
|
|
7417
|
+
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart &&
|
|
7418
|
+
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
7419
|
+
var React = React__default,
|
|
7420
|
+
objectIs = "function" === typeof Object.is ? Object.is : is,
|
|
7421
|
+
useState = React.useState,
|
|
7422
|
+
useEffect = React.useEffect,
|
|
7423
|
+
useLayoutEffect = React.useLayoutEffect,
|
|
7424
|
+
useDebugValue = React.useDebugValue,
|
|
7425
|
+
didWarnOld18Alpha = false,
|
|
7426
|
+
didWarnUncachedGetSnapshot = false,
|
|
7427
|
+
shim =
|
|
7428
|
+
"undefined" === typeof window ||
|
|
7429
|
+
"undefined" === typeof window.document ||
|
|
7430
|
+
"undefined" === typeof window.document.createElement
|
|
7431
|
+
? useSyncExternalStore$1
|
|
7432
|
+
: useSyncExternalStore$2;
|
|
7433
|
+
useSyncExternalStoreShim_development.useSyncExternalStore =
|
|
7434
|
+
void 0 !== React.useSyncExternalStore ? React.useSyncExternalStore : shim;
|
|
7435
|
+
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
|
|
7436
|
+
"function" ===
|
|
7437
|
+
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
|
|
7438
|
+
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
7439
|
+
})();
|
|
7440
|
+
return useSyncExternalStoreShim_development;
|
|
7441
|
+
}
|
|
7442
|
+
|
|
7443
|
+
var hasRequiredShim;
|
|
7444
|
+
|
|
7445
|
+
function requireShim () {
|
|
7446
|
+
if (hasRequiredShim) return shim.exports;
|
|
7447
|
+
hasRequiredShim = 1;
|
|
7448
|
+
|
|
7449
|
+
if (process.env.NODE_ENV === 'production') {
|
|
7450
|
+
shim.exports = requireUseSyncExternalStoreShim_production();
|
|
7451
|
+
} else {
|
|
7452
|
+
shim.exports = requireUseSyncExternalStoreShim_development();
|
|
7453
|
+
}
|
|
7454
|
+
return shim.exports;
|
|
7455
|
+
}
|
|
7456
|
+
|
|
7457
|
+
var shimExports = requireShim();
|
|
7458
|
+
|
|
7270
7459
|
/** Context value shared between Combobox sub-components. */
|
|
7271
7460
|
|
|
7272
7461
|
const ComboboxContext = /*#__PURE__*/createContext(undefined);
|
|
@@ -7286,17 +7475,30 @@ function useComboboxContext() {
|
|
|
7286
7475
|
|
|
7287
7476
|
/**
|
|
7288
7477
|
* Hook to subscribe to a combobox event via the handle's subscriber system.
|
|
7289
|
-
*
|
|
7478
|
+
*
|
|
7479
|
+
* Uses `useSyncExternalStore` (shim, for React 17 support) reading the handle's synchronous
|
|
7480
|
+
* `getSnapshot` — the correct pattern for an external (non-React) store. It reads the current
|
|
7481
|
+
* value during commit, so a consumer doesn't miss changes that happened between its render and its
|
|
7482
|
+
* subscription (e.g. options registered by child effects before this consumer subscribed, since
|
|
7483
|
+
* `optionsChange` is not replayed on subscribe), and it is tearing-safe under concurrent rendering.
|
|
7484
|
+
*
|
|
7485
|
+
* The handle dispatches synchronously, so the store update fires within the triggering render/event
|
|
7486
|
+
* (inside React's `act` in tests) rather than a deferred microtask. Re-subscribes when the handle
|
|
7487
|
+
* changes (e.g. trigger mount/unmount).
|
|
7290
7488
|
*/
|
|
7291
7489
|
function useComboboxEvent(event, initialValue) {
|
|
7292
7490
|
const {
|
|
7293
7491
|
handle
|
|
7294
7492
|
} = useComboboxContext();
|
|
7295
|
-
|
|
7296
|
-
|
|
7297
|
-
|
|
7493
|
+
|
|
7494
|
+
// Stable fallback used until the event has fired at least once (or while there is no handle).
|
|
7495
|
+
const initialValueRef = useRef(initialValue);
|
|
7496
|
+
const subscribe = useCallback(onStoreChange => handle?.subscribe(event, onStoreChange) ?? (() => undefined), [handle, event]);
|
|
7497
|
+
const getSnapshot = useCallback(() => {
|
|
7498
|
+
const value = handle?.getSnapshot(event);
|
|
7499
|
+
return value === undefined ? initialValueRef.current : value;
|
|
7298
7500
|
}, [handle, event]);
|
|
7299
|
-
return
|
|
7501
|
+
return shimExports.useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
7300
7502
|
}
|
|
7301
7503
|
|
|
7302
7504
|
/**
|
|
@@ -11850,13 +12052,23 @@ const useTransitionVisibility = (ref, isComponentVisible, timeout, onVisibilityC
|
|
|
11850
12052
|
return isVisible || isComponentVisible;
|
|
11851
12053
|
};
|
|
11852
12054
|
|
|
12055
|
+
/**
|
|
12056
|
+
* Dialog label id key in IdsRegistry
|
|
12057
|
+
*/
|
|
12058
|
+
const DIALOG_LABEL_KEY = 'dialog-label';
|
|
12059
|
+
|
|
11853
12060
|
/**
|
|
11854
12061
|
* Component display name.
|
|
11855
12062
|
*/
|
|
11856
12063
|
const COMPONENT_NAME$$ = 'Dialog';
|
|
11857
12064
|
|
|
11858
12065
|
/**
|
|
11859
|
-
*
|
|
12066
|
+
* `DialogHeading` component display name.
|
|
12067
|
+
*/
|
|
12068
|
+
const DIALOG_HEADING_COMPONENT_NAME = 'DialogHeading';
|
|
12069
|
+
|
|
12070
|
+
/**
|
|
12071
|
+
* Component default class name and class prefix. Shared by the shell and the container modules.
|
|
11860
12072
|
*/
|
|
11861
12073
|
const CLASSNAME$_ = 'lumx-dialog';
|
|
11862
12074
|
const {
|
|
@@ -11872,46 +12084,25 @@ const DEFAULT_PROPS$T = {
|
|
|
11872
12084
|
};
|
|
11873
12085
|
|
|
11874
12086
|
/**
|
|
11875
|
-
* Dialog
|
|
12087
|
+
* Dialog shell: overlay + context providers (theme, heading level, ids registry).
|
|
11876
12088
|
*
|
|
11877
12089
|
* @param props Component props.
|
|
11878
|
-
* @param ref Component ref.
|
|
11879
12090
|
* @return React element.
|
|
11880
12091
|
*/
|
|
11881
|
-
const
|
|
12092
|
+
const DialogShell = props => {
|
|
11882
12093
|
const {
|
|
11883
12094
|
className,
|
|
11884
12095
|
ref,
|
|
11885
|
-
header,
|
|
11886
|
-
forceFooterDivider,
|
|
11887
|
-
forceHeaderDivider,
|
|
11888
|
-
footer,
|
|
11889
|
-
isLoading,
|
|
11890
12096
|
isOpen,
|
|
11891
|
-
|
|
11892
|
-
|
|
12097
|
+
isLoading,
|
|
12098
|
+
isVisible,
|
|
11893
12099
|
size = DEFAULT_PROPS$T.size,
|
|
11894
12100
|
zIndex,
|
|
11895
|
-
|
|
11896
|
-
headerChildContent,
|
|
11897
|
-
isVisible,
|
|
12101
|
+
children,
|
|
11898
12102
|
Portal,
|
|
11899
12103
|
HeadingLevelProvider,
|
|
11900
12104
|
ThemeProvider,
|
|
11901
|
-
|
|
11902
|
-
shouldPreventCloseOnClickAway,
|
|
11903
|
-
clickAwayRefs,
|
|
11904
|
-
rootRef,
|
|
11905
|
-
wrapperRef,
|
|
11906
|
-
hasTopIntersection,
|
|
11907
|
-
headerChildProps,
|
|
11908
|
-
setSentinelTop,
|
|
11909
|
-
content,
|
|
11910
|
-
setSentinelBottom,
|
|
11911
|
-
footerChildContent,
|
|
11912
|
-
footerChildProps,
|
|
11913
|
-
ProgressCircular,
|
|
11914
|
-
hasBottomIntersection,
|
|
12105
|
+
IdsRegistryProvider,
|
|
11915
12106
|
...forwardedProps
|
|
11916
12107
|
} = props;
|
|
11917
12108
|
return /*#__PURE__*/jsx(Portal, {
|
|
@@ -11933,50 +12124,8 @@ const Dialog$1 = props => {
|
|
|
11933
12124
|
level: 2,
|
|
11934
12125
|
children: /*#__PURE__*/jsx(ThemeProvider, {
|
|
11935
12126
|
value: undefined,
|
|
11936
|
-
children: /*#__PURE__*/jsx(
|
|
11937
|
-
|
|
11938
|
-
role: "dialog",
|
|
11939
|
-
"aria-modal": "true",
|
|
11940
|
-
...dialogProps,
|
|
11941
|
-
children: /*#__PURE__*/jsx(ClickAwayProvider, {
|
|
11942
|
-
callback: !shouldPreventCloseOnClickAway && handleClose,
|
|
11943
|
-
childrenRefs: clickAwayRefs,
|
|
11944
|
-
parentRef: rootRef,
|
|
11945
|
-
children: /*#__PURE__*/jsxs("section", {
|
|
11946
|
-
className: element$B('wrapper'),
|
|
11947
|
-
ref: wrapperRef,
|
|
11948
|
-
children: [(header || headerChildContent) && /*#__PURE__*/jsxs("header", {
|
|
11949
|
-
...headerChildProps,
|
|
11950
|
-
className: classnames(element$B('header', {
|
|
11951
|
-
'has-divider': Boolean(forceHeaderDivider || hasTopIntersection)
|
|
11952
|
-
}), headerChildProps?.className),
|
|
11953
|
-
children: [header, headerChildContent]
|
|
11954
|
-
}), /*#__PURE__*/jsxs("div", {
|
|
11955
|
-
ref: contentRef,
|
|
11956
|
-
className: element$B('content'),
|
|
11957
|
-
children: [/*#__PURE__*/jsx("div", {
|
|
11958
|
-
className: element$B('sentinel', {
|
|
11959
|
-
top: true
|
|
11960
|
-
}),
|
|
11961
|
-
ref: setSentinelTop
|
|
11962
|
-
}), content, /*#__PURE__*/jsx("div", {
|
|
11963
|
-
className: element$B('sentinel', {
|
|
11964
|
-
bottom: true
|
|
11965
|
-
}),
|
|
11966
|
-
ref: setSentinelBottom
|
|
11967
|
-
})]
|
|
11968
|
-
}), (footer || footerChildContent) && /*#__PURE__*/jsxs("footer", {
|
|
11969
|
-
...footerChildProps,
|
|
11970
|
-
className: classnames(element$B('footer', {
|
|
11971
|
-
'has-divider': Boolean(forceFooterDivider || hasBottomIntersection)
|
|
11972
|
-
}), footerChildProps?.className),
|
|
11973
|
-
children: [footer, footerChildContent]
|
|
11974
|
-
}), isLoading && /*#__PURE__*/jsx("div", {
|
|
11975
|
-
className: element$B('progress-overlay'),
|
|
11976
|
-
children: /*#__PURE__*/jsx(ProgressCircular, {})
|
|
11977
|
-
})]
|
|
11978
|
-
})
|
|
11979
|
-
})
|
|
12127
|
+
children: /*#__PURE__*/jsx(IdsRegistryProvider, {
|
|
12128
|
+
children: children
|
|
11980
12129
|
})
|
|
11981
12130
|
})
|
|
11982
12131
|
})]
|
|
@@ -11985,8 +12134,257 @@ const Dialog$1 = props => {
|
|
|
11985
12134
|
};
|
|
11986
12135
|
|
|
11987
12136
|
/**
|
|
11988
|
-
*
|
|
12137
|
+
* Picks the accessible-name prop (`aria-label` or `aria-labelledby`).
|
|
12138
|
+
*/
|
|
12139
|
+
function resolveAccessibleNameProps(ariaLabel, ariaLabelledBy) {
|
|
12140
|
+
if (ariaLabel) {
|
|
12141
|
+
return {
|
|
12142
|
+
'aria-label': ariaLabel
|
|
12143
|
+
};
|
|
12144
|
+
}
|
|
12145
|
+
if (ariaLabelledBy) {
|
|
12146
|
+
return {
|
|
12147
|
+
'aria-labelledby': ariaLabelledBy
|
|
12148
|
+
};
|
|
12149
|
+
}
|
|
12150
|
+
return undefined;
|
|
12151
|
+
}
|
|
12152
|
+
|
|
12153
|
+
/**
|
|
12154
|
+
* Props of the dialog content: the `role="dialog"` element (which carries `aria-labelledby`) and
|
|
12155
|
+
* everything inside it (header, body, footer). It is meant to be rendered by a framework component
|
|
12156
|
+
* that has resolved `labelId` from the ids registry.
|
|
12157
|
+
*/
|
|
12158
|
+
|
|
12159
|
+
/**
|
|
12160
|
+
* Dialog content: the `role="dialog"` element + header/body/footer.
|
|
12161
|
+
*
|
|
12162
|
+
* @param props Component props.
|
|
12163
|
+
* @return React element.
|
|
12164
|
+
*/
|
|
12165
|
+
const DialogContent$1 = props => {
|
|
12166
|
+
const {
|
|
12167
|
+
labelId,
|
|
12168
|
+
dialogProps,
|
|
12169
|
+
handleClose,
|
|
12170
|
+
shouldPreventCloseOnClickAway,
|
|
12171
|
+
clickAwayRefs,
|
|
12172
|
+
rootRef,
|
|
12173
|
+
wrapperRef,
|
|
12174
|
+
contentRef,
|
|
12175
|
+
header,
|
|
12176
|
+
headerChildProps,
|
|
12177
|
+
headerChildContent,
|
|
12178
|
+
forceHeaderDivider,
|
|
12179
|
+
hasTopIntersection,
|
|
12180
|
+
content,
|
|
12181
|
+
setSentinelTop,
|
|
12182
|
+
setSentinelBottom,
|
|
12183
|
+
footer,
|
|
12184
|
+
footerChildProps,
|
|
12185
|
+
footerChildContent,
|
|
12186
|
+
forceFooterDivider,
|
|
12187
|
+
hasBottomIntersection,
|
|
12188
|
+
isLoading,
|
|
12189
|
+
ProgressCircular,
|
|
12190
|
+
ClickAwayProvider
|
|
12191
|
+
} = props;
|
|
12192
|
+
|
|
12193
|
+
// Strip both out of `dialogProps` before spreading it: `resolveAccessibleNameProps` picks at most one, and
|
|
12194
|
+
// leaving the other in place would let it survive underneath the spread below.
|
|
12195
|
+
const {
|
|
12196
|
+
'aria-label': dialogAriaLabel,
|
|
12197
|
+
'aria-labelledby': dialogAriaLabelledBy,
|
|
12198
|
+
...restDialogProps
|
|
12199
|
+
} = dialogProps ?? {};
|
|
12200
|
+
return /*#__PURE__*/jsx("div", {
|
|
12201
|
+
className: element$B('container'),
|
|
12202
|
+
role: "dialog",
|
|
12203
|
+
"aria-modal": "true",
|
|
12204
|
+
...restDialogProps,
|
|
12205
|
+
...resolveAccessibleNameProps(dialogAriaLabel, dialogAriaLabelledBy || labelId),
|
|
12206
|
+
children: /*#__PURE__*/jsx(ClickAwayProvider, {
|
|
12207
|
+
callback: !shouldPreventCloseOnClickAway && handleClose,
|
|
12208
|
+
childrenRefs: clickAwayRefs,
|
|
12209
|
+
parentRef: rootRef,
|
|
12210
|
+
children: /*#__PURE__*/jsxs("section", {
|
|
12211
|
+
className: element$B('wrapper'),
|
|
12212
|
+
ref: wrapperRef,
|
|
12213
|
+
children: [(header || headerChildContent) && /*#__PURE__*/jsxs("header", {
|
|
12214
|
+
...headerChildProps,
|
|
12215
|
+
className: classnames(element$B('header', {
|
|
12216
|
+
'has-divider': Boolean(forceHeaderDivider || hasTopIntersection)
|
|
12217
|
+
}), headerChildProps?.className),
|
|
12218
|
+
children: [header, headerChildContent]
|
|
12219
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
12220
|
+
ref: contentRef,
|
|
12221
|
+
className: element$B('content'),
|
|
12222
|
+
children: [/*#__PURE__*/jsx("div", {
|
|
12223
|
+
className: element$B('sentinel', {
|
|
12224
|
+
top: true
|
|
12225
|
+
}),
|
|
12226
|
+
ref: setSentinelTop
|
|
12227
|
+
}), content, /*#__PURE__*/jsx("div", {
|
|
12228
|
+
className: element$B('sentinel', {
|
|
12229
|
+
bottom: true
|
|
12230
|
+
}),
|
|
12231
|
+
ref: setSentinelBottom
|
|
12232
|
+
})]
|
|
12233
|
+
}), (footer || footerChildContent) && /*#__PURE__*/jsxs("footer", {
|
|
12234
|
+
...footerChildProps,
|
|
12235
|
+
className: classnames(element$B('footer', {
|
|
12236
|
+
'has-divider': Boolean(forceFooterDivider || hasBottomIntersection)
|
|
12237
|
+
}), footerChildProps?.className),
|
|
12238
|
+
children: [footer, footerChildContent]
|
|
12239
|
+
}), isLoading && /*#__PURE__*/jsx("div", {
|
|
12240
|
+
className: element$B('progress-overlay'),
|
|
12241
|
+
children: /*#__PURE__*/jsx(ProgressCircular, {})
|
|
12242
|
+
})]
|
|
12243
|
+
})
|
|
12244
|
+
})
|
|
12245
|
+
});
|
|
12246
|
+
};
|
|
12247
|
+
|
|
12248
|
+
/**
|
|
12249
|
+
* Internal "ids registry" contract shared between framework wrappers (`@lumx/react`, `@lumx/vue`).
|
|
12250
|
+
*/
|
|
12251
|
+
|
|
12252
|
+
/**
|
|
12253
|
+
* Create a standalone ids registry.
|
|
12254
|
+
*
|
|
12255
|
+
* Can be used to store ids for 'aria-labelledby' or 'aria-describedby'. Registrations under the same key are
|
|
12256
|
+
* kept as a stack (most recently registered wins); a registrant clearing itself only affects the top of the
|
|
12257
|
+
* stack if it put itself there, so an older still-registered registrant is restored instead of the key going
|
|
12258
|
+
* empty.
|
|
12259
|
+
*/
|
|
12260
|
+
function createIdsRegistry() {
|
|
12261
|
+
const stacks = new Map();
|
|
12262
|
+
const listeners = new Map();
|
|
12263
|
+
const topId = key => {
|
|
12264
|
+
const stack = stacks.get(key);
|
|
12265
|
+
return stack?.[stack.length - 1]?.id;
|
|
12266
|
+
};
|
|
12267
|
+
return {
|
|
12268
|
+
getId: topId,
|
|
12269
|
+
setId(key, token, id) {
|
|
12270
|
+
const previousTopId = topId(key);
|
|
12271
|
+
const stack = stacks.get(key) ?? [];
|
|
12272
|
+
const index = stack.findIndex(entry => entry.token === token);
|
|
12273
|
+
if (index !== -1) stack.splice(index, 1);
|
|
12274
|
+
if (id !== undefined) stack.push({
|
|
12275
|
+
token,
|
|
12276
|
+
id
|
|
12277
|
+
});
|
|
12278
|
+
if (stack.length) {
|
|
12279
|
+
stacks.set(key, stack);
|
|
12280
|
+
} else {
|
|
12281
|
+
stacks.delete(key);
|
|
12282
|
+
}
|
|
12283
|
+
if (topId(key) === previousTopId) return;
|
|
12284
|
+
const set = listeners.get(key);
|
|
12285
|
+
if (set) {
|
|
12286
|
+
// Copy: a listener may unsubscribe (e.g. on unmount) during this loop.
|
|
12287
|
+
const frozenListeners = [...set];
|
|
12288
|
+
for (const listener of frozenListeners) {
|
|
12289
|
+
listener(key);
|
|
12290
|
+
}
|
|
12291
|
+
}
|
|
12292
|
+
},
|
|
12293
|
+
subscribe(key, listener) {
|
|
12294
|
+
let set = listeners.get(key);
|
|
12295
|
+
if (!set) {
|
|
12296
|
+
set = new Set();
|
|
12297
|
+
listeners.set(key, set);
|
|
12298
|
+
}
|
|
12299
|
+
set.add(listener);
|
|
12300
|
+
return () => {
|
|
12301
|
+
set.delete(listener);
|
|
12302
|
+
if (set.size === 0) listeners.delete(key);
|
|
12303
|
+
};
|
|
12304
|
+
}
|
|
12305
|
+
};
|
|
12306
|
+
}
|
|
12307
|
+
|
|
12308
|
+
/**
|
|
12309
|
+
* Internal "ids registry" context.
|
|
12310
|
+
*
|
|
12311
|
+
* Not exported from the package barrel - lets a container expose ids registered by its descendants
|
|
12312
|
+
* under well-known names, without either side knowing about the other upfront (e.g. to wire up
|
|
12313
|
+
* `aria-labelledby`/`aria-describedby` between components that don't know about each other).
|
|
12314
|
+
*
|
|
12315
|
+
* `undefined` outside of any provider - `useRegisterId`/`useRegisteredId` are no-ops in that case.
|
|
12316
|
+
*
|
|
12317
|
+
* See `IdsRegistry` in `@lumx/core` for the shared contract.
|
|
12318
|
+
*/
|
|
12319
|
+
const IdsRegistryContext = /*#__PURE__*/createContext(undefined);
|
|
12320
|
+
|
|
12321
|
+
/**
|
|
12322
|
+
* Provides a fresh ids registry to its subtree. The registry instance is stable for the lifetime of
|
|
12323
|
+
* the provider, so registering/reading an id never re-renders the whole subtree - only the
|
|
12324
|
+
* components subscribed (via `useRegisteredId`) to the name that changed.
|
|
12325
|
+
*/
|
|
12326
|
+
const IdsRegistryProvider = ({
|
|
12327
|
+
children
|
|
12328
|
+
}) => {
|
|
12329
|
+
const [registry] = useState(createIdsRegistry);
|
|
12330
|
+
return /*#__PURE__*/jsx(IdsRegistryContext.Provider, {
|
|
12331
|
+
value: registry,
|
|
12332
|
+
children: children
|
|
12333
|
+
});
|
|
12334
|
+
};
|
|
12335
|
+
|
|
12336
|
+
/**
|
|
12337
|
+
* Register `id` under `key` in the enclosing ids registry on mount, and clear it on unmount.
|
|
12338
|
+
* Last registered wins; if another registrant is still mounted under the same key, clearing this
|
|
12339
|
+
* one falls back to it instead of leaving the key empty.
|
|
12340
|
+
*
|
|
12341
|
+
* @param key Registry key to store the id under.
|
|
12342
|
+
* @param id Id of the element to register.
|
|
12343
|
+
*/
|
|
12344
|
+
function useRegisterId(key, id) {
|
|
12345
|
+
const registry = useContext(IdsRegistryContext);
|
|
12346
|
+
const token = useRef({}).current;
|
|
12347
|
+
useEffect(() => {
|
|
12348
|
+
registry?.setId(key, token, id);
|
|
12349
|
+
return () => registry?.setId(key, token, undefined);
|
|
12350
|
+
}, [registry, key, id, token]);
|
|
12351
|
+
}
|
|
12352
|
+
|
|
12353
|
+
/**
|
|
12354
|
+
* Subscribe to the id currently registered under `key` in the enclosing ids registry. Re-renders
|
|
12355
|
+
* the calling component only when that key's id changes.
|
|
12356
|
+
*
|
|
12357
|
+
* Re-reads the registry's `getId` snapshot on mount/update (in case an id was registered between
|
|
12358
|
+
* render and commit, e.g. by a descendant in the same commit) before subscribing for later changes.
|
|
12359
|
+
*
|
|
12360
|
+
* @param key Registry key to read.
|
|
12361
|
+
* @return The registered id, or `undefined` when none is registered / outside any provider.
|
|
12362
|
+
*/
|
|
12363
|
+
function useRegisteredId(key) {
|
|
12364
|
+
const registry = useContext(IdsRegistryContext);
|
|
12365
|
+
const [id, setId] = useState(() => registry?.getId(key));
|
|
12366
|
+
useEffect(() => {
|
|
12367
|
+
setId(registry?.getId(key));
|
|
12368
|
+
return registry?.subscribe(key, () => setId(registry.getId(key)));
|
|
12369
|
+
}, [registry, key]);
|
|
12370
|
+
return id;
|
|
12371
|
+
}
|
|
12372
|
+
|
|
12373
|
+
/**
|
|
12374
|
+
* Renders the core `DialogContent`, resolving its `aria-labelledby` from the ids registry.
|
|
12375
|
+
*
|
|
12376
|
+
* Must render as a descendant of the `IdsRegistryProvider` set up by the core `DialogShell` (which is
|
|
12377
|
+
* why it is its own component: the subscription hook needs to run below the provider). Internal to the
|
|
12378
|
+
* dialog family - not exported from the package barrel.
|
|
11989
12379
|
*/
|
|
12380
|
+
const DialogContent = props => {
|
|
12381
|
+
const labelId = useRegisteredId(DIALOG_LABEL_KEY);
|
|
12382
|
+
return DialogContent$1({
|
|
12383
|
+
...props,
|
|
12384
|
+
labelId
|
|
12385
|
+
});
|
|
12386
|
+
};
|
|
12387
|
+
DialogContent.displayName = 'DialogContent';
|
|
11990
12388
|
|
|
11991
12389
|
const isHeader$1 = isComponent('header');
|
|
11992
12390
|
const isFooter$1 = isComponent('footer');
|
|
@@ -12007,11 +12405,7 @@ const DEFAULT_PROPS$S = {
|
|
|
12007
12405
|
* @param ref Component ref.
|
|
12008
12406
|
* @return React element.
|
|
12009
12407
|
*/
|
|
12010
|
-
const
|
|
12011
|
-
if (!DOCUMENT) {
|
|
12012
|
-
// Can't render in SSR.
|
|
12013
|
-
return null;
|
|
12014
|
-
}
|
|
12408
|
+
const DialogBody = forwardRef((props, ref) => {
|
|
12015
12409
|
const {
|
|
12016
12410
|
children,
|
|
12017
12411
|
className,
|
|
@@ -12036,10 +12430,7 @@ const Dialog = forwardRef((props, ref) => {
|
|
|
12036
12430
|
preventCloseOnEscape,
|
|
12037
12431
|
...forwardedProps
|
|
12038
12432
|
} = props;
|
|
12039
|
-
|
|
12040
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
12041
12433
|
const previousOpen = React__default.useRef(isOpen);
|
|
12042
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
12043
12434
|
React__default.useEffect(() => {
|
|
12044
12435
|
if (isOpen !== previousOpen.current) {
|
|
12045
12436
|
previousOpen.current = isOpen;
|
|
@@ -12051,30 +12442,18 @@ const Dialog = forwardRef((props, ref) => {
|
|
|
12051
12442
|
}
|
|
12052
12443
|
}, [isOpen, parentElement]);
|
|
12053
12444
|
const shouldPreventCloseOnEscape = preventAutoClose || preventCloseOnEscape;
|
|
12054
|
-
|
|
12055
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
12056
12445
|
useCallbackOnEscape(onClose, isOpen && !shouldPreventCloseOnEscape);
|
|
12057
|
-
|
|
12058
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
12059
12446
|
const wrapperRef = useRef(null);
|
|
12060
12447
|
/**
|
|
12061
12448
|
* Since the `contentRef` comes from the parent and is optional,
|
|
12062
12449
|
* we need to create a stable contentRef that will always be available.
|
|
12063
12450
|
*/
|
|
12064
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
12065
12451
|
const localContentRef = useRef(null);
|
|
12066
12452
|
// Handle focus trap.
|
|
12067
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
12068
12453
|
useFocusTrap(isOpen && wrapperRef.current, focusElement?.current);
|
|
12069
|
-
|
|
12070
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
12071
12454
|
useDisableBodyScroll(disableBodyScroll && isOpen && localContentRef.current);
|
|
12072
|
-
|
|
12073
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
12074
12455
|
const [sentinelTop, setSentinelTop] = useState(null);
|
|
12075
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
12076
12456
|
const [sentinelBottom, setSentinelBottom] = useState(null);
|
|
12077
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
12078
12457
|
const intersections = useIntersectionObserver([sentinelTop, sentinelBottom], {
|
|
12079
12458
|
threshold: [0, 1]
|
|
12080
12459
|
});
|
|
@@ -12082,75 +12461,252 @@ const Dialog = forwardRef((props, ref) => {
|
|
|
12082
12461
|
const hasBottomIntersection = sentinelBottom && !(intersections.get(sentinelBottom)?.isIntersecting ?? true);
|
|
12083
12462
|
|
|
12084
12463
|
// Separate header, footer and dialog content from children.
|
|
12085
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
12086
12464
|
const [[headerChild], [footerChild], content] = useMemo(() => partitionMulti(Children.toArray(children), [isHeader$1, isFooter$1]), [children]);
|
|
12087
12465
|
const headerChildProps = headerChild?.props;
|
|
12088
12466
|
const headerChildContent = headerChildProps?.children;
|
|
12089
12467
|
const footerChildProps = footerChild?.props;
|
|
12090
12468
|
const footerChildContent = footerChildProps?.children;
|
|
12091
|
-
|
|
12092
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
12093
12469
|
const clickAwayRefs = useRef([wrapperRef]);
|
|
12094
|
-
|
|
12095
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
12096
12470
|
const rootRef = useRef(null);
|
|
12097
|
-
|
|
12098
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
12099
12471
|
const isVisible = useTransitionVisibility(rootRef, Boolean(isOpen), DIALOG_TRANSITION_DURATION, onVisibilityChange);
|
|
12100
12472
|
const shouldPreventCloseOnClickAway = preventAutoClose || preventCloseOnClick;
|
|
12101
12473
|
const isMounted = isOpen || isVisible || closeMode === 'hide';
|
|
12102
|
-
|
|
12103
|
-
|
|
12104
|
-
HeadingLevelProvider,
|
|
12474
|
+
if (!isMounted) return null;
|
|
12475
|
+
return DialogShell({
|
|
12105
12476
|
Portal,
|
|
12477
|
+
HeadingLevelProvider,
|
|
12106
12478
|
ThemeProvider,
|
|
12479
|
+
IdsRegistryProvider,
|
|
12107
12480
|
className,
|
|
12108
|
-
clickAwayRefs,
|
|
12109
|
-
content,
|
|
12110
|
-
contentRef: mergeRefs(localContentRef, contentRef),
|
|
12111
|
-
dialogProps,
|
|
12112
|
-
footer,
|
|
12113
|
-
footerChildContent,
|
|
12114
|
-
footerChildProps,
|
|
12115
|
-
forceFooterDivider,
|
|
12116
|
-
forceHeaderDivider,
|
|
12117
|
-
handleClose: onClose,
|
|
12118
|
-
hasBottomIntersection,
|
|
12119
|
-
hasTopIntersection,
|
|
12120
|
-
header,
|
|
12121
|
-
headerChildContent,
|
|
12122
|
-
ProgressCircular,
|
|
12123
|
-
headerChildProps,
|
|
12124
12481
|
isLoading,
|
|
12125
12482
|
isOpen,
|
|
12126
12483
|
isVisible,
|
|
12127
|
-
ref: mergeRefs(rootRef, ref),
|
|
12128
|
-
rootRef,
|
|
12129
|
-
setSentinelBottom,
|
|
12130
|
-
setSentinelTop,
|
|
12131
|
-
shouldPreventCloseOnClickAway,
|
|
12132
12484
|
size,
|
|
12133
|
-
wrapperRef,
|
|
12134
12485
|
zIndex,
|
|
12135
|
-
|
|
12136
|
-
|
|
12486
|
+
ref: mergeRefs(rootRef, ref),
|
|
12487
|
+
...forwardedProps,
|
|
12488
|
+
children: /*#__PURE__*/jsx(DialogContent, {
|
|
12489
|
+
ClickAwayProvider: ClickAwayProvider,
|
|
12490
|
+
ProgressCircular: ProgressCircular,
|
|
12491
|
+
clickAwayRefs: clickAwayRefs,
|
|
12492
|
+
content: content,
|
|
12493
|
+
contentRef: mergeRefs(localContentRef, contentRef),
|
|
12494
|
+
dialogProps: dialogProps,
|
|
12495
|
+
footer: footer,
|
|
12496
|
+
footerChildContent: footerChildContent,
|
|
12497
|
+
footerChildProps: footerChildProps,
|
|
12498
|
+
forceFooterDivider: forceFooterDivider,
|
|
12499
|
+
forceHeaderDivider: forceHeaderDivider,
|
|
12500
|
+
handleClose: onClose,
|
|
12501
|
+
hasBottomIntersection: hasBottomIntersection,
|
|
12502
|
+
hasTopIntersection: hasTopIntersection,
|
|
12503
|
+
header: header,
|
|
12504
|
+
headerChildContent: headerChildContent,
|
|
12505
|
+
headerChildProps: headerChildProps,
|
|
12506
|
+
isLoading: isLoading,
|
|
12507
|
+
rootRef: rootRef,
|
|
12508
|
+
setSentinelBottom: setSentinelBottom,
|
|
12509
|
+
setSentinelTop: setSentinelTop,
|
|
12510
|
+
shouldPreventCloseOnClickAway: shouldPreventCloseOnClickAway,
|
|
12511
|
+
wrapperRef: wrapperRef
|
|
12512
|
+
})
|
|
12513
|
+
});
|
|
12514
|
+
});
|
|
12515
|
+
DialogBody.displayName = 'DialogBody';
|
|
12516
|
+
const Dialog = forwardRef((props, ref) => {
|
|
12517
|
+
if (!DOCUMENT) {
|
|
12518
|
+
// Can't render in SSR.
|
|
12519
|
+
return null;
|
|
12520
|
+
}
|
|
12521
|
+
return /*#__PURE__*/jsx(DialogBody, {
|
|
12522
|
+
...props,
|
|
12523
|
+
ref: ref
|
|
12524
|
+
});
|
|
12137
12525
|
});
|
|
12138
12526
|
Dialog.displayName = COMPONENT_NAME$$;
|
|
12139
12527
|
Dialog.className = CLASSNAME$_;
|
|
12140
12528
|
Dialog.defaultProps = DEFAULT_PROPS$S;
|
|
12141
12529
|
|
|
12530
|
+
/** The maximum authorized heading level. */
|
|
12531
|
+
const MAX_HEADING_LEVEL = 6;
|
|
12532
|
+
|
|
12142
12533
|
/**
|
|
12143
|
-
*
|
|
12534
|
+
* Typography to use by default depending on the heading level.
|
|
12144
12535
|
*/
|
|
12145
|
-
const
|
|
12536
|
+
const DEFAULT_TYPOGRAPHY_BY_LEVEL = {
|
|
12537
|
+
h1: Typography.display1,
|
|
12538
|
+
h2: Typography.headline,
|
|
12539
|
+
h3: Typography.title,
|
|
12540
|
+
h4: Typography.subtitle2,
|
|
12541
|
+
h5: Typography.subtitle1,
|
|
12542
|
+
h6: Typography.body2
|
|
12543
|
+
};
|
|
12544
|
+
const defaultContext = {
|
|
12545
|
+
level: 1,
|
|
12546
|
+
headingElement: 'h1'
|
|
12547
|
+
};
|
|
12146
12548
|
|
|
12147
12549
|
/**
|
|
12148
|
-
*
|
|
12550
|
+
* Defines the props of the component.
|
|
12149
12551
|
*/
|
|
12150
|
-
|
|
12552
|
+
|
|
12553
|
+
/**
|
|
12554
|
+
* Component display name.
|
|
12555
|
+
*/
|
|
12556
|
+
const COMPONENT_NAME$_ = 'Heading';
|
|
12557
|
+
|
|
12558
|
+
/**
|
|
12559
|
+
* Component default class name and class prefix.
|
|
12560
|
+
*/
|
|
12561
|
+
const CLASSNAME$Z = 'lumx-heading';
|
|
12562
|
+
|
|
12563
|
+
/**
|
|
12564
|
+
* Component default props.
|
|
12565
|
+
*/
|
|
12566
|
+
const DEFAULT_PROPS$R = {};
|
|
12567
|
+
|
|
12568
|
+
/**
|
|
12569
|
+
* Get Heading component common props
|
|
12570
|
+
*
|
|
12571
|
+
* @param props Component props.
|
|
12572
|
+
* @param contextHeadingElement Heading element from context.
|
|
12573
|
+
* @return Common Props
|
|
12574
|
+
*/
|
|
12575
|
+
const getHeadingProps = (props, contextHeadingElement) => {
|
|
12576
|
+
const {
|
|
12577
|
+
as,
|
|
12578
|
+
className,
|
|
12579
|
+
typography,
|
|
12580
|
+
...otherProps
|
|
12581
|
+
} = props;
|
|
12582
|
+
const computedHeadingElement = as || contextHeadingElement || 'h1';
|
|
12583
|
+
return {
|
|
12584
|
+
...otherProps,
|
|
12585
|
+
as: computedHeadingElement,
|
|
12586
|
+
className: classnames(className, CLASSNAME$Z),
|
|
12587
|
+
typography: typography || DEFAULT_TYPOGRAPHY_BY_LEVEL[computedHeadingElement]
|
|
12588
|
+
};
|
|
12589
|
+
};
|
|
12590
|
+
|
|
12591
|
+
const HeadingLevelContext = /*#__PURE__*/createContext(defaultContext);
|
|
12592
|
+
|
|
12593
|
+
const useHeadingLevel = () => {
|
|
12594
|
+
const {
|
|
12595
|
+
level = 1,
|
|
12596
|
+
headingElement = 'h1'
|
|
12597
|
+
} = React__default.useContext(HeadingLevelContext);
|
|
12598
|
+
return {
|
|
12599
|
+
level,
|
|
12600
|
+
headingElement
|
|
12601
|
+
};
|
|
12602
|
+
};
|
|
12603
|
+
|
|
12604
|
+
/**
|
|
12605
|
+
* Renders a heading component.
|
|
12606
|
+
* Extends the `Text` Component with the heading level automatically computed based on
|
|
12607
|
+
* the current level provided by the context.
|
|
12608
|
+
*/
|
|
12609
|
+
const Heading = forwardRef((props, ref) => {
|
|
12610
|
+
const {
|
|
12611
|
+
children,
|
|
12612
|
+
...otherProps
|
|
12613
|
+
} = props;
|
|
12614
|
+
const {
|
|
12615
|
+
headingElement
|
|
12616
|
+
} = useHeadingLevel();
|
|
12617
|
+
const headingProps = getHeadingProps(otherProps, headingElement);
|
|
12618
|
+
return /*#__PURE__*/jsx(Text, {
|
|
12619
|
+
ref: ref,
|
|
12620
|
+
...headingProps,
|
|
12621
|
+
children: children
|
|
12622
|
+
});
|
|
12623
|
+
});
|
|
12624
|
+
Heading.displayName = COMPONENT_NAME$_;
|
|
12625
|
+
Heading.className = CLASSNAME$Z;
|
|
12626
|
+
Heading.defaultProps = DEFAULT_PROPS$R;
|
|
12627
|
+
|
|
12628
|
+
/**
|
|
12629
|
+
* Computes the next heading level based on the optional prop level or the parent context level.
|
|
12630
|
+
*
|
|
12631
|
+
* @param levelProp - The explicit level provided via props (optional).
|
|
12632
|
+
* @param parentLevel - The level from the parent context.
|
|
12633
|
+
* @returns The calculated heading level, clamped to the maximum allowed level.
|
|
12634
|
+
*/
|
|
12635
|
+
const computeHeadingLevel = (levelProp, parentLevel) => {
|
|
12636
|
+
const nextLevel = levelProp || parentLevel + 1;
|
|
12637
|
+
return nextLevel > MAX_HEADING_LEVEL ? MAX_HEADING_LEVEL : nextLevel;
|
|
12638
|
+
};
|
|
12639
|
+
|
|
12640
|
+
/**
|
|
12641
|
+
* Provide a new heading level context.
|
|
12642
|
+
*/
|
|
12643
|
+
const HeadingLevelProvider = ({
|
|
12644
|
+
children,
|
|
12645
|
+
level
|
|
12646
|
+
}) => {
|
|
12647
|
+
const {
|
|
12648
|
+
level: contextLevel
|
|
12649
|
+
} = useHeadingLevel();
|
|
12650
|
+
const nextLevel = computeHeadingLevel(level, contextLevel);
|
|
12651
|
+
const headingElement = `h${nextLevel}`;
|
|
12652
|
+
return /*#__PURE__*/jsx(HeadingLevelContext.Provider, {
|
|
12653
|
+
value: {
|
|
12654
|
+
level: nextLevel,
|
|
12655
|
+
headingElement
|
|
12656
|
+
},
|
|
12657
|
+
children: children
|
|
12658
|
+
});
|
|
12659
|
+
};
|
|
12660
|
+
|
|
12661
|
+
/**
|
|
12662
|
+
* Names the enclosing dialog-like container (`Dialog`, `Lightbox`, `PopoverDialog`, ...).
|
|
12663
|
+
*
|
|
12664
|
+
* Thin wrapper over `Heading` that generates its own id (or uses the consumer-supplied `id`),
|
|
12665
|
+
* and registers it with the nearest ids registry on mount so the container can link itself to
|
|
12666
|
+
* this heading via `aria-labelledby`. Deregisters on unmount.
|
|
12667
|
+
*
|
|
12668
|
+
* Defaults its typography to `Typography.title` (overridable via the `typography` prop).
|
|
12669
|
+
*
|
|
12670
|
+
* If two `DialogHeading`s are rendered within the same container, the last one registered wins.
|
|
12671
|
+
*
|
|
12672
|
+
* @example
|
|
12673
|
+
* <Dialog isOpen={isOpen}>
|
|
12674
|
+
* <header>
|
|
12675
|
+
* <Toolbar label={<DialogHeading>My dialog</DialogHeading>} />
|
|
12676
|
+
* </header>
|
|
12677
|
+
* ...
|
|
12678
|
+
* </Dialog>
|
|
12679
|
+
*/
|
|
12680
|
+
const DialogHeading = forwardRef((props, ref) => {
|
|
12681
|
+
const {
|
|
12682
|
+
id,
|
|
12683
|
+
typography = Typography$1.title,
|
|
12684
|
+
...forwardedProps
|
|
12685
|
+
} = props;
|
|
12686
|
+
const generatedId = useId();
|
|
12687
|
+
const headingId = id || generatedId;
|
|
12688
|
+
useRegisterId(DIALOG_LABEL_KEY, headingId);
|
|
12689
|
+
return /*#__PURE__*/jsx(Heading, {
|
|
12690
|
+
ref: ref,
|
|
12691
|
+
id: headingId,
|
|
12692
|
+
typography: typography,
|
|
12693
|
+
...forwardedProps
|
|
12694
|
+
});
|
|
12695
|
+
});
|
|
12696
|
+
DialogHeading.displayName = DIALOG_HEADING_COMPONENT_NAME;
|
|
12697
|
+
|
|
12698
|
+
/**
|
|
12699
|
+
* Component display name.
|
|
12700
|
+
*/
|
|
12701
|
+
const COMPONENT_NAME$Z = 'Divider';
|
|
12702
|
+
|
|
12703
|
+
/**
|
|
12704
|
+
* Component default class name and class prefix.
|
|
12705
|
+
*/
|
|
12706
|
+
const CLASSNAME$Y = 'lumx-divider';
|
|
12151
12707
|
const {
|
|
12152
12708
|
block: block$L
|
|
12153
|
-
} = bem(CLASSNAME$
|
|
12709
|
+
} = bem(CLASSNAME$Y);
|
|
12154
12710
|
|
|
12155
12711
|
/**
|
|
12156
12712
|
* Divider component.
|
|
@@ -12181,7 +12737,7 @@ const Divider$1 = props => {
|
|
|
12181
12737
|
/**
|
|
12182
12738
|
* Component default props.
|
|
12183
12739
|
*/
|
|
12184
|
-
const DEFAULT_PROPS$
|
|
12740
|
+
const DEFAULT_PROPS$Q = {};
|
|
12185
12741
|
|
|
12186
12742
|
/**
|
|
12187
12743
|
* Divider component.
|
|
@@ -12202,22 +12758,22 @@ const Divider = forwardRef((props, ref) => {
|
|
|
12202
12758
|
...otherProps
|
|
12203
12759
|
});
|
|
12204
12760
|
});
|
|
12205
|
-
Divider.displayName = COMPONENT_NAME$
|
|
12206
|
-
Divider.className = CLASSNAME$
|
|
12207
|
-
Divider.defaultProps = DEFAULT_PROPS$
|
|
12761
|
+
Divider.displayName = COMPONENT_NAME$Z;
|
|
12762
|
+
Divider.className = CLASSNAME$Y;
|
|
12763
|
+
Divider.defaultProps = DEFAULT_PROPS$Q;
|
|
12208
12764
|
|
|
12209
12765
|
/**
|
|
12210
12766
|
* Component display name.
|
|
12211
12767
|
*/
|
|
12212
|
-
const COMPONENT_NAME$
|
|
12768
|
+
const COMPONENT_NAME$Y = 'DragHandle';
|
|
12213
12769
|
|
|
12214
12770
|
/**
|
|
12215
12771
|
* Component default class name and class prefix.
|
|
12216
12772
|
*/
|
|
12217
|
-
const CLASSNAME$
|
|
12773
|
+
const CLASSNAME$X = 'lumx-drag-handle';
|
|
12218
12774
|
const {
|
|
12219
12775
|
block: block$K
|
|
12220
|
-
} = bem(CLASSNAME$
|
|
12776
|
+
} = bem(CLASSNAME$X);
|
|
12221
12777
|
|
|
12222
12778
|
/**
|
|
12223
12779
|
* DragHandle component.
|
|
@@ -12253,7 +12809,7 @@ const DragHandle$1 = props => {
|
|
|
12253
12809
|
/**
|
|
12254
12810
|
* Component default props.
|
|
12255
12811
|
*/
|
|
12256
|
-
const DEFAULT_PROPS$
|
|
12812
|
+
const DEFAULT_PROPS$P = {};
|
|
12257
12813
|
|
|
12258
12814
|
/**
|
|
12259
12815
|
* DragHandle component.
|
|
@@ -12274,9 +12830,9 @@ const DragHandle = forwardRef((props, ref) => {
|
|
|
12274
12830
|
...otherProps
|
|
12275
12831
|
});
|
|
12276
12832
|
});
|
|
12277
|
-
DragHandle.displayName = COMPONENT_NAME$
|
|
12278
|
-
DragHandle.className = CLASSNAME$
|
|
12279
|
-
DragHandle.defaultProps = DEFAULT_PROPS$
|
|
12833
|
+
DragHandle.displayName = COMPONENT_NAME$Y;
|
|
12834
|
+
DragHandle.className = CLASSNAME$X;
|
|
12835
|
+
DragHandle.defaultProps = DEFAULT_PROPS$P;
|
|
12280
12836
|
|
|
12281
12837
|
const INITIAL_INDEX = -1;
|
|
12282
12838
|
|
|
@@ -12521,21 +13077,21 @@ const useInfiniteScroll = (ref, callback, callbackOnMount = false, scrollTrigger
|
|
|
12521
13077
|
/**
|
|
12522
13078
|
* Component display name.
|
|
12523
13079
|
*/
|
|
12524
|
-
const COMPONENT_NAME$
|
|
13080
|
+
const COMPONENT_NAME$X = 'Dropdown';
|
|
12525
13081
|
|
|
12526
13082
|
/**
|
|
12527
13083
|
* Component default class name and class prefix.
|
|
12528
13084
|
*/
|
|
12529
|
-
const CLASSNAME$
|
|
13085
|
+
const CLASSNAME$W = 'lumx-dropdown';
|
|
12530
13086
|
const {
|
|
12531
13087
|
block: block$J,
|
|
12532
13088
|
element: element$A
|
|
12533
|
-
} = classNames.bem(CLASSNAME$
|
|
13089
|
+
} = classNames.bem(CLASSNAME$W);
|
|
12534
13090
|
|
|
12535
13091
|
/**
|
|
12536
13092
|
* Component default props.
|
|
12537
13093
|
*/
|
|
12538
|
-
const DEFAULT_PROPS$
|
|
13094
|
+
const DEFAULT_PROPS$O = {
|
|
12539
13095
|
closeOnClick: true,
|
|
12540
13096
|
closeOnClickAway: true,
|
|
12541
13097
|
closeOnEscape: true,
|
|
@@ -12559,18 +13115,18 @@ const Dropdown = forwardRef((props, ref) => {
|
|
|
12559
13115
|
anchorRef,
|
|
12560
13116
|
children,
|
|
12561
13117
|
className,
|
|
12562
|
-
closeOnClick = DEFAULT_PROPS$
|
|
12563
|
-
closeOnClickAway = DEFAULT_PROPS$
|
|
12564
|
-
closeOnEscape = DEFAULT_PROPS$
|
|
12565
|
-
fitToAnchorWidth = DEFAULT_PROPS$
|
|
12566
|
-
fitWithinViewportHeight = DEFAULT_PROPS$
|
|
13118
|
+
closeOnClick = DEFAULT_PROPS$O.closeOnClick,
|
|
13119
|
+
closeOnClickAway = DEFAULT_PROPS$O.closeOnClickAway,
|
|
13120
|
+
closeOnEscape = DEFAULT_PROPS$O.closeOnEscape,
|
|
13121
|
+
fitToAnchorWidth = DEFAULT_PROPS$O.fitToAnchorWidth,
|
|
13122
|
+
fitWithinViewportHeight = DEFAULT_PROPS$O.fitWithinViewportHeight,
|
|
12567
13123
|
isOpen,
|
|
12568
13124
|
offset,
|
|
12569
|
-
focusAnchorOnClose = DEFAULT_PROPS$
|
|
13125
|
+
focusAnchorOnClose = DEFAULT_PROPS$O.focusAnchorOnClose,
|
|
12570
13126
|
onClose,
|
|
12571
13127
|
onInfiniteScroll,
|
|
12572
|
-
placement = DEFAULT_PROPS$
|
|
12573
|
-
shouldFocusOnOpen = DEFAULT_PROPS$
|
|
13128
|
+
placement = DEFAULT_PROPS$O.placement,
|
|
13129
|
+
shouldFocusOnOpen = DEFAULT_PROPS$O.shouldFocusOnOpen,
|
|
12574
13130
|
zIndex,
|
|
12575
13131
|
...forwardedProps
|
|
12576
13132
|
} = props;
|
|
@@ -12614,28 +13170,28 @@ const Dropdown = forwardRef((props, ref) => {
|
|
|
12614
13170
|
})
|
|
12615
13171
|
}) : null;
|
|
12616
13172
|
});
|
|
12617
|
-
Dropdown.displayName = COMPONENT_NAME$
|
|
12618
|
-
Dropdown.className = CLASSNAME$
|
|
12619
|
-
Dropdown.defaultProps = DEFAULT_PROPS$
|
|
13173
|
+
Dropdown.displayName = COMPONENT_NAME$X;
|
|
13174
|
+
Dropdown.className = CLASSNAME$W;
|
|
13175
|
+
Dropdown.defaultProps = DEFAULT_PROPS$O;
|
|
12620
13176
|
|
|
12621
13177
|
/**
|
|
12622
13178
|
* Component display name.
|
|
12623
13179
|
*/
|
|
12624
|
-
const COMPONENT_NAME$
|
|
13180
|
+
const COMPONENT_NAME$W = 'ExpansionPanel';
|
|
12625
13181
|
|
|
12626
13182
|
/**
|
|
12627
13183
|
* Component default class name and class prefix.
|
|
12628
13184
|
*/
|
|
12629
|
-
const CLASSNAME$
|
|
13185
|
+
const CLASSNAME$V = 'lumx-expansion-panel';
|
|
12630
13186
|
const {
|
|
12631
13187
|
block: block$I,
|
|
12632
13188
|
element: element$z
|
|
12633
|
-
} = bem(CLASSNAME$
|
|
13189
|
+
} = bem(CLASSNAME$V);
|
|
12634
13190
|
|
|
12635
13191
|
/**
|
|
12636
13192
|
* Component default props.
|
|
12637
13193
|
*/
|
|
12638
|
-
const DEFAULT_PROPS$
|
|
13194
|
+
const DEFAULT_PROPS$N = {
|
|
12639
13195
|
closeMode: 'unmount'
|
|
12640
13196
|
};
|
|
12641
13197
|
|
|
@@ -12748,7 +13304,7 @@ const isFooter = isComponent('footer');
|
|
|
12748
13304
|
const ExpansionPanel = forwardRef((props, ref) => {
|
|
12749
13305
|
const defaultTheme = useTheme() || Theme$1.light;
|
|
12750
13306
|
const {
|
|
12751
|
-
closeMode = DEFAULT_PROPS$
|
|
13307
|
+
closeMode = DEFAULT_PROPS$N.closeMode,
|
|
12752
13308
|
children: anyChildren,
|
|
12753
13309
|
isOpen,
|
|
12754
13310
|
label,
|
|
@@ -12819,17 +13375,17 @@ const ExpansionPanel = forwardRef((props, ref) => {
|
|
|
12819
13375
|
...forwardedProps
|
|
12820
13376
|
});
|
|
12821
13377
|
});
|
|
12822
|
-
ExpansionPanel.displayName = COMPONENT_NAME$
|
|
12823
|
-
ExpansionPanel.className = CLASSNAME$
|
|
12824
|
-
ExpansionPanel.defaultProps = DEFAULT_PROPS$
|
|
13378
|
+
ExpansionPanel.displayName = COMPONENT_NAME$W;
|
|
13379
|
+
ExpansionPanel.className = CLASSNAME$V;
|
|
13380
|
+
ExpansionPanel.defaultProps = DEFAULT_PROPS$N;
|
|
12825
13381
|
|
|
12826
|
-
const COMPONENT_NAME$
|
|
12827
|
-
const CLASSNAME$
|
|
12828
|
-
const DEFAULT_PROPS$
|
|
13382
|
+
const COMPONENT_NAME$V = 'Flag';
|
|
13383
|
+
const CLASSNAME$U = 'lumx-flag';
|
|
13384
|
+
const DEFAULT_PROPS$M = {};
|
|
12829
13385
|
const {
|
|
12830
13386
|
block: block$H,
|
|
12831
13387
|
element: element$y
|
|
12832
|
-
} = bem(CLASSNAME$
|
|
13388
|
+
} = bem(CLASSNAME$U);
|
|
12833
13389
|
|
|
12834
13390
|
/**
|
|
12835
13391
|
* Flag component.
|
|
@@ -12887,140 +13443,9 @@ const Flag = forwardRef((props, ref) => {
|
|
|
12887
13443
|
Text
|
|
12888
13444
|
});
|
|
12889
13445
|
});
|
|
12890
|
-
Flag.displayName = COMPONENT_NAME$
|
|
12891
|
-
Flag.className = CLASSNAME$
|
|
12892
|
-
Flag.defaultProps = DEFAULT_PROPS$
|
|
12893
|
-
|
|
12894
|
-
/** The maximum authorized heading level. */
|
|
12895
|
-
const MAX_HEADING_LEVEL = 6;
|
|
12896
|
-
|
|
12897
|
-
/**
|
|
12898
|
-
* Typography to use by default depending on the heading level.
|
|
12899
|
-
*/
|
|
12900
|
-
const DEFAULT_TYPOGRAPHY_BY_LEVEL = {
|
|
12901
|
-
h1: Typography.display1,
|
|
12902
|
-
h2: Typography.headline,
|
|
12903
|
-
h3: Typography.title,
|
|
12904
|
-
h4: Typography.subtitle2,
|
|
12905
|
-
h5: Typography.subtitle1,
|
|
12906
|
-
h6: Typography.body2
|
|
12907
|
-
};
|
|
12908
|
-
const defaultContext = {
|
|
12909
|
-
level: 1,
|
|
12910
|
-
headingElement: 'h1'
|
|
12911
|
-
};
|
|
12912
|
-
|
|
12913
|
-
/**
|
|
12914
|
-
* Defines the props of the component.
|
|
12915
|
-
*/
|
|
12916
|
-
|
|
12917
|
-
/**
|
|
12918
|
-
* Component display name.
|
|
12919
|
-
*/
|
|
12920
|
-
const COMPONENT_NAME$V = 'Heading';
|
|
12921
|
-
|
|
12922
|
-
/**
|
|
12923
|
-
* Component default class name and class prefix.
|
|
12924
|
-
*/
|
|
12925
|
-
const CLASSNAME$U = 'lumx-heading';
|
|
12926
|
-
|
|
12927
|
-
/**
|
|
12928
|
-
* Component default props.
|
|
12929
|
-
*/
|
|
12930
|
-
const DEFAULT_PROPS$M = {};
|
|
12931
|
-
|
|
12932
|
-
/**
|
|
12933
|
-
* Get Heading component common props
|
|
12934
|
-
*
|
|
12935
|
-
* @param props Component props.
|
|
12936
|
-
* @param contextHeadingElement Heading element from context.
|
|
12937
|
-
* @return Common Props
|
|
12938
|
-
*/
|
|
12939
|
-
const getHeadingProps = (props, contextHeadingElement) => {
|
|
12940
|
-
const {
|
|
12941
|
-
as,
|
|
12942
|
-
className,
|
|
12943
|
-
typography,
|
|
12944
|
-
...otherProps
|
|
12945
|
-
} = props;
|
|
12946
|
-
const computedHeadingElement = as || contextHeadingElement || 'h1';
|
|
12947
|
-
return {
|
|
12948
|
-
...otherProps,
|
|
12949
|
-
as: computedHeadingElement,
|
|
12950
|
-
className: classnames(className, CLASSNAME$U),
|
|
12951
|
-
typography: typography || DEFAULT_TYPOGRAPHY_BY_LEVEL[computedHeadingElement]
|
|
12952
|
-
};
|
|
12953
|
-
};
|
|
12954
|
-
|
|
12955
|
-
const HeadingLevelContext = /*#__PURE__*/createContext(defaultContext);
|
|
12956
|
-
|
|
12957
|
-
const useHeadingLevel = () => {
|
|
12958
|
-
const {
|
|
12959
|
-
level = 1,
|
|
12960
|
-
headingElement = 'h1'
|
|
12961
|
-
} = React__default.useContext(HeadingLevelContext);
|
|
12962
|
-
return {
|
|
12963
|
-
level,
|
|
12964
|
-
headingElement
|
|
12965
|
-
};
|
|
12966
|
-
};
|
|
12967
|
-
|
|
12968
|
-
/**
|
|
12969
|
-
* Renders a heading component.
|
|
12970
|
-
* Extends the `Text` Component with the heading level automatically computed based on
|
|
12971
|
-
* the current level provided by the context.
|
|
12972
|
-
*/
|
|
12973
|
-
const Heading = forwardRef((props, ref) => {
|
|
12974
|
-
const {
|
|
12975
|
-
children,
|
|
12976
|
-
...otherProps
|
|
12977
|
-
} = props;
|
|
12978
|
-
const {
|
|
12979
|
-
headingElement
|
|
12980
|
-
} = useHeadingLevel();
|
|
12981
|
-
const headingProps = getHeadingProps(otherProps, headingElement);
|
|
12982
|
-
return /*#__PURE__*/jsx(Text, {
|
|
12983
|
-
ref: ref,
|
|
12984
|
-
...headingProps,
|
|
12985
|
-
children: children
|
|
12986
|
-
});
|
|
12987
|
-
});
|
|
12988
|
-
Heading.displayName = COMPONENT_NAME$V;
|
|
12989
|
-
Heading.className = CLASSNAME$U;
|
|
12990
|
-
Heading.defaultProps = DEFAULT_PROPS$M;
|
|
12991
|
-
|
|
12992
|
-
/**
|
|
12993
|
-
* Computes the next heading level based on the optional prop level or the parent context level.
|
|
12994
|
-
*
|
|
12995
|
-
* @param levelProp - The explicit level provided via props (optional).
|
|
12996
|
-
* @param parentLevel - The level from the parent context.
|
|
12997
|
-
* @returns The calculated heading level, clamped to the maximum allowed level.
|
|
12998
|
-
*/
|
|
12999
|
-
const computeHeadingLevel = (levelProp, parentLevel) => {
|
|
13000
|
-
const nextLevel = levelProp || parentLevel + 1;
|
|
13001
|
-
return nextLevel > MAX_HEADING_LEVEL ? MAX_HEADING_LEVEL : nextLevel;
|
|
13002
|
-
};
|
|
13003
|
-
|
|
13004
|
-
/**
|
|
13005
|
-
* Provide a new heading level context.
|
|
13006
|
-
*/
|
|
13007
|
-
const HeadingLevelProvider = ({
|
|
13008
|
-
children,
|
|
13009
|
-
level
|
|
13010
|
-
}) => {
|
|
13011
|
-
const {
|
|
13012
|
-
level: contextLevel
|
|
13013
|
-
} = useHeadingLevel();
|
|
13014
|
-
const nextLevel = computeHeadingLevel(level, contextLevel);
|
|
13015
|
-
const headingElement = `h${nextLevel}`;
|
|
13016
|
-
return /*#__PURE__*/jsx(HeadingLevelContext.Provider, {
|
|
13017
|
-
value: {
|
|
13018
|
-
level: nextLevel,
|
|
13019
|
-
headingElement
|
|
13020
|
-
},
|
|
13021
|
-
children: children
|
|
13022
|
-
});
|
|
13023
|
-
};
|
|
13446
|
+
Flag.displayName = COMPONENT_NAME$V;
|
|
13447
|
+
Flag.className = CLASSNAME$U;
|
|
13448
|
+
Flag.defaultProps = DEFAULT_PROPS$M;
|
|
13024
13449
|
|
|
13025
13450
|
/**
|
|
13026
13451
|
* Component display name.
|
|
@@ -14127,7 +14552,7 @@ const Inner = forwardRef((props, ref) => {
|
|
|
14127
14552
|
focusElement: currentPaginationItemRef,
|
|
14128
14553
|
...forwardedProps,
|
|
14129
14554
|
// Disable the close on click away as we want a custom one here
|
|
14130
|
-
|
|
14555
|
+
preventCloseOnClick: true,
|
|
14131
14556
|
children: /*#__PURE__*/jsx(ClickAwayProvider, {
|
|
14132
14557
|
childrenRefs: clickAwayChildrenRefs,
|
|
14133
14558
|
callback: onClickAway,
|
|
@@ -14328,7 +14753,9 @@ const Lightbox$1 = props => {
|
|
|
14328
14753
|
handleClose,
|
|
14329
14754
|
parentElement,
|
|
14330
14755
|
focusElement,
|
|
14756
|
+
labelId,
|
|
14331
14757
|
preventAutoClose,
|
|
14758
|
+
preventCloseOnClick,
|
|
14332
14759
|
theme,
|
|
14333
14760
|
zIndex,
|
|
14334
14761
|
isVisible,
|
|
@@ -14348,8 +14775,7 @@ const Lightbox$1 = props => {
|
|
|
14348
14775
|
children: /*#__PURE__*/jsxs("div", {
|
|
14349
14776
|
ref: ref,
|
|
14350
14777
|
...forwardedProps,
|
|
14351
|
-
|
|
14352
|
-
"aria-labelledby": ariaLabelledBy,
|
|
14778
|
+
...resolveAccessibleNameProps(ariaLabel, ariaLabelledBy || labelId),
|
|
14353
14779
|
"aria-modal": "true",
|
|
14354
14780
|
role: "dialog",
|
|
14355
14781
|
tabIndex: -1,
|
|
@@ -14378,7 +14804,7 @@ const Lightbox$1 = props => {
|
|
|
14378
14804
|
children: /*#__PURE__*/jsx(ThemeProvider, {
|
|
14379
14805
|
value: undefined,
|
|
14380
14806
|
children: /*#__PURE__*/jsx(ClickAwayProvider, {
|
|
14381
|
-
callback: !preventAutoClose && handleClose,
|
|
14807
|
+
callback: !preventAutoClose && !preventCloseOnClick && handleClose,
|
|
14382
14808
|
childrenRefs: clickAwayRefs,
|
|
14383
14809
|
children: /*#__PURE__*/jsx("div", {
|
|
14384
14810
|
ref: childrenRef,
|
|
@@ -14398,13 +14824,13 @@ const Lightbox$1 = props => {
|
|
|
14398
14824
|
*/
|
|
14399
14825
|
|
|
14400
14826
|
/**
|
|
14401
|
-
* Lightbox
|
|
14827
|
+
* Renders the core Lightbox UI, resolving its `aria-labelledby` from the ids registry.
|
|
14402
14828
|
*
|
|
14403
|
-
*
|
|
14404
|
-
*
|
|
14405
|
-
*
|
|
14829
|
+
* Must render as a descendant of the `IdsRegistryProvider` set up by `Lightbox` (which is why it is
|
|
14830
|
+
* its own component: the subscription hook needs to run below the provider). Internal to the
|
|
14831
|
+
* lightbox family - not exported from the package barrel.
|
|
14406
14832
|
*/
|
|
14407
|
-
const
|
|
14833
|
+
const LightboxContent = forwardRef((props, ref) => {
|
|
14408
14834
|
const {
|
|
14409
14835
|
children,
|
|
14410
14836
|
className,
|
|
@@ -14418,36 +14844,19 @@ const Lightbox = forwardRef((props, ref) => {
|
|
|
14418
14844
|
zIndex,
|
|
14419
14845
|
...forwardedProps
|
|
14420
14846
|
} = props;
|
|
14421
|
-
if (!DOCUMENT) {
|
|
14422
|
-
// Can't render in SSR.
|
|
14423
|
-
return null;
|
|
14424
|
-
}
|
|
14425
|
-
|
|
14426
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
14427
14847
|
const childrenRef = useRef(null);
|
|
14428
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
14429
14848
|
const wrapperRef = useRef(null);
|
|
14430
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
14431
14849
|
const closeButtonRef = useRef(null);
|
|
14432
|
-
|
|
14433
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
14434
14850
|
useDisableBodyScroll(isOpen && wrapperRef.current);
|
|
14435
|
-
|
|
14436
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
14437
14851
|
const isVisible = useTransitionVisibility(wrapperRef, !!isOpen, DIALOG_TRANSITION_DURATION);
|
|
14438
14852
|
|
|
14439
14853
|
// Handle focus trap.
|
|
14440
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
14441
14854
|
useFocusTrap(
|
|
14442
14855
|
// Focus trap zone
|
|
14443
14856
|
isOpen && wrapperRef.current,
|
|
14444
14857
|
// Focus element (fallback on close button and then on the dialog)
|
|
14445
14858
|
focusElement?.current || closeButtonRef.current || wrapperRef.current);
|
|
14446
|
-
|
|
14447
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
14448
14859
|
const previousOpen = useRef(isOpen);
|
|
14449
|
-
|
|
14450
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
14451
14860
|
useEffect(() => {
|
|
14452
14861
|
if (isOpen !== previousOpen.current) {
|
|
14453
14862
|
previousOpen.current = isOpen;
|
|
@@ -14460,11 +14869,9 @@ const Lightbox = forwardRef((props, ref) => {
|
|
|
14460
14869
|
}, [isOpen, parentElement]);
|
|
14461
14870
|
|
|
14462
14871
|
// Close lightbox on escape key pressed.
|
|
14463
|
-
|
|
14464
|
-
useCallbackOnEscape(onClose);
|
|
14465
|
-
|
|
14466
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
14872
|
+
useCallbackOnEscape(onClose, isOpen && !preventAutoClose);
|
|
14467
14873
|
const clickAwayRefs = useRef([wrapperRef]);
|
|
14874
|
+
const labelId = useRegisteredId(DIALOG_LABEL_KEY);
|
|
14468
14875
|
if (!isOpen && !isVisible) return null;
|
|
14469
14876
|
return Lightbox$1({
|
|
14470
14877
|
ClickAwayProvider,
|
|
@@ -14482,6 +14889,7 @@ const Lightbox = forwardRef((props, ref) => {
|
|
|
14482
14889
|
focusElement,
|
|
14483
14890
|
isOpen,
|
|
14484
14891
|
isVisible,
|
|
14892
|
+
labelId,
|
|
14485
14893
|
ref: mergeRefs(ref, wrapperRef),
|
|
14486
14894
|
theme,
|
|
14487
14895
|
zIndex,
|
|
@@ -14490,6 +14898,26 @@ const Lightbox = forwardRef((props, ref) => {
|
|
|
14490
14898
|
...forwardedProps
|
|
14491
14899
|
});
|
|
14492
14900
|
});
|
|
14901
|
+
|
|
14902
|
+
/**
|
|
14903
|
+
* Lightbox component.
|
|
14904
|
+
*
|
|
14905
|
+
* @param props Component props.
|
|
14906
|
+
* @param ref Component ref.
|
|
14907
|
+
* @return React element.
|
|
14908
|
+
*/
|
|
14909
|
+
const Lightbox = forwardRef((props, ref) => {
|
|
14910
|
+
if (!DOCUMENT) {
|
|
14911
|
+
// Can't render in SSR.
|
|
14912
|
+
return null;
|
|
14913
|
+
}
|
|
14914
|
+
return /*#__PURE__*/jsx(IdsRegistryProvider, {
|
|
14915
|
+
children: /*#__PURE__*/jsx(LightboxContent, {
|
|
14916
|
+
...props,
|
|
14917
|
+
ref: ref
|
|
14918
|
+
})
|
|
14919
|
+
});
|
|
14920
|
+
});
|
|
14493
14921
|
Lightbox.displayName = COMPONENT_NAME$O;
|
|
14494
14922
|
Lightbox.className = CLASSNAME$N;
|
|
14495
14923
|
|
|
@@ -16300,7 +16728,10 @@ Notification.defaultProps = DEFAULT_PROPS$C;
|
|
|
16300
16728
|
|
|
16301
16729
|
/**
|
|
16302
16730
|
* PopoverDialog props.
|
|
16303
|
-
* The PopoverDialog has the same props as the Popover
|
|
16731
|
+
* The PopoverDialog has the same props as the Popover, plus optional accessible-name props.
|
|
16732
|
+
* An accessible name can be provided via `label`, `aria-label`, `aria-labelledby`, or by
|
|
16733
|
+
* rendering a `DialogHeading` inside the dialog (which names it via the internal label
|
|
16734
|
+
* registry) - at least one of these should be used.
|
|
16304
16735
|
*/
|
|
16305
16736
|
|
|
16306
16737
|
/**
|
|
@@ -16319,21 +16750,22 @@ const CLASSNAME$A = 'lumx-popover-dialog';
|
|
|
16319
16750
|
const DEFAULT_PROPS$B = {};
|
|
16320
16751
|
|
|
16321
16752
|
/**
|
|
16322
|
-
*
|
|
16323
|
-
*
|
|
16324
|
-
*
|
|
16325
|
-
*
|
|
16326
|
-
* -
|
|
16327
|
-
* - Resets heading level context to 2
|
|
16753
|
+
* Renders the core Popover as a dialog, resolving its `aria-labelledby` from the ids registry.
|
|
16754
|
+
*
|
|
16755
|
+
* Must render as a descendant of the `IdsRegistryProvider` set up by `PopoverDialog` (which is why it
|
|
16756
|
+
* is its own component: the subscription hook needs to run below the provider). Internal to the
|
|
16757
|
+
* popover-dialog family - not exported from the package barrel.
|
|
16328
16758
|
*/
|
|
16329
|
-
const
|
|
16759
|
+
const PopoverDialogContent = forwardRef((props, ref) => {
|
|
16330
16760
|
const {
|
|
16331
16761
|
children,
|
|
16332
|
-
'aria-label':
|
|
16333
|
-
|
|
16762
|
+
'aria-label': ariaLabelAttr,
|
|
16763
|
+
'aria-labelledby': ariaLabelledByAttr,
|
|
16764
|
+
label = ariaLabelAttr,
|
|
16334
16765
|
className,
|
|
16335
16766
|
...forwardedProps
|
|
16336
16767
|
} = props;
|
|
16768
|
+
const labelId = useRegisteredId(DIALOG_LABEL_KEY);
|
|
16337
16769
|
return /*#__PURE__*/jsx(Popover, {
|
|
16338
16770
|
...forwardedProps,
|
|
16339
16771
|
ref: ref,
|
|
@@ -16342,9 +16774,10 @@ const PopoverDialog = forwardRef((props, ref) => {
|
|
|
16342
16774
|
"aria-modal": "true"
|
|
16343
16775
|
/**
|
|
16344
16776
|
* If a label is set, set as aria-label.
|
|
16345
|
-
* If it is undefined, the label can be set using the `aria-label` and `aria-labelledby` props
|
|
16777
|
+
* If it is undefined, the label can be set using the `aria-label` and `aria-labelledby` props,
|
|
16778
|
+
* or by rendering a `DialogHeading` inside the dialog (linked via the internal ids registry).
|
|
16346
16779
|
*/,
|
|
16347
|
-
|
|
16780
|
+
...resolveAccessibleNameProps(label, ariaLabelledByAttr || labelId),
|
|
16348
16781
|
closeOnClickAway: true,
|
|
16349
16782
|
closeOnEscape: true,
|
|
16350
16783
|
withFocusTrap: true,
|
|
@@ -16354,6 +16787,21 @@ const PopoverDialog = forwardRef((props, ref) => {
|
|
|
16354
16787
|
})
|
|
16355
16788
|
});
|
|
16356
16789
|
});
|
|
16790
|
+
|
|
16791
|
+
/**
|
|
16792
|
+
* PopoverDialog component.
|
|
16793
|
+
* Defines a popover that acts like a dialog:
|
|
16794
|
+
* - Has a dialog aria role
|
|
16795
|
+
* - Sets a focus trap within the popover
|
|
16796
|
+
* - Closes on click away and escape
|
|
16797
|
+
* - Resets heading level context to 2
|
|
16798
|
+
*/
|
|
16799
|
+
const PopoverDialog = forwardRef((props, ref) => /*#__PURE__*/jsx(IdsRegistryProvider, {
|
|
16800
|
+
children: /*#__PURE__*/jsx(PopoverDialogContent, {
|
|
16801
|
+
...props,
|
|
16802
|
+
ref: ref
|
|
16803
|
+
})
|
|
16804
|
+
}));
|
|
16357
16805
|
PopoverDialog.displayName = COMPONENT_NAME$A;
|
|
16358
16806
|
PopoverDialog.className = CLASSNAME$A;
|
|
16359
16807
|
PopoverDialog.defaultProps = DEFAULT_PROPS$B;
|
|
@@ -22599,5 +23047,5 @@ UserBlock.displayName = COMPONENT_NAME;
|
|
|
22599
23047
|
UserBlock.className = CLASSNAME;
|
|
22600
23048
|
UserBlock.defaultProps = DEFAULT_PROPS;
|
|
22601
23049
|
|
|
22602
|
-
export { AlertDialog, Autocomplete, AutocompleteMultiple, Avatar, Badge, BadgeWrapper, Button, ButtonGroup, CLASSNAME$1w as CLASSNAME, COMPONENT_NAME$1z as COMPONENT_NAME, Checkbox, Chip, ChipGroup, Combobox, CommentBlock, CommentBlockVariant, DEFAULT_PROPS$1e as DEFAULT_PROPS, DatePicker, DatePickerControlled, DatePickerField, Dialog, Divider, DragHandle, Dropdown, ExpansionPanel, Flag, FlexBox, GenericBlock, GenericBlockGapSize, Grid, GridColumn, GridItem, Heading, HeadingLevelProvider, Icon, IconButton, ImageBlock, ImageBlockCaptionPosition, ImageLightbox, InlineList, InputHelper, InputLabel, Lightbox, Link, LinkPreview, List, ListDivider, ListItem, ListSection, ListSubheader, MenuButton, ListDivider as MenuDivider, MenuItem, Message, Mosaic, Navigation, Notification, Placement, Popover, PopoverDialog, PostBlock, Progress, ProgressCircular, ProgressLinear, ProgressTracker, ProgressTrackerProvider, ProgressTrackerStep, ProgressTrackerStepPanel, ProgressVariant, RadioButton, RadioGroup, RawInputText, RawInputTextarea, Select, SelectButton, SelectMultiple, SelectMultipleField, SelectTextField, SelectVariant, SelectionChipGroup, SideNavigation, SideNavigationItem, SkeletonCircle, SkeletonRectangle, SkeletonRectangleVariant, SkeletonTypography, Slider, Slides, Slideshow, SlideshowControls, SlideshowItem, Switch, CLASSNAME$3 as TIME_PICKER_FIELD_CLASSNAME, COMPONENT_NAME$3 as TIME_PICKER_FIELD_COMPONENT_NAME, Tab, TabList, TabListLayout, TabPanel, TabProvider, Table, TableBody, TableCell, TableCellVariant, TableHeader, TableRow, Text, TextField, ThOrder, ThemeProvider, Thumbnail, ThumbnailAspectRatio, ThumbnailObjectFit, ThumbnailVariant, TimePickerField, Toolbar, Tooltip, Uploader, UploaderVariant, UserBlock, clamp, useFocusPointStyle, useHeadingLevel, useTheme };
|
|
23050
|
+
export { AlertDialog, Autocomplete, AutocompleteMultiple, Avatar, Badge, BadgeWrapper, Button, ButtonGroup, CLASSNAME$1w as CLASSNAME, COMPONENT_NAME$1z as COMPONENT_NAME, Checkbox, Chip, ChipGroup, Combobox, CommentBlock, CommentBlockVariant, DEFAULT_PROPS$1e as DEFAULT_PROPS, DatePicker, DatePickerControlled, DatePickerField, Dialog, DialogHeading, Divider, DragHandle, Dropdown, ExpansionPanel, Flag, FlexBox, GenericBlock, GenericBlockGapSize, Grid, GridColumn, GridItem, Heading, HeadingLevelProvider, Icon, IconButton, ImageBlock, ImageBlockCaptionPosition, ImageLightbox, InlineList, InputHelper, InputLabel, Lightbox, Link, LinkPreview, List, ListDivider, ListItem, ListSection, ListSubheader, MenuButton, ListDivider as MenuDivider, MenuItem, Message, Mosaic, Navigation, Notification, Placement, Popover, PopoverDialog, PostBlock, Progress, ProgressCircular, ProgressLinear, ProgressTracker, ProgressTrackerProvider, ProgressTrackerStep, ProgressTrackerStepPanel, ProgressVariant, RadioButton, RadioGroup, RawInputText, RawInputTextarea, Select, SelectButton, SelectMultiple, SelectMultipleField, SelectTextField, SelectVariant, SelectionChipGroup, SideNavigation, SideNavigationItem, SkeletonCircle, SkeletonRectangle, SkeletonRectangleVariant, SkeletonTypography, Slider, Slides, Slideshow, SlideshowControls, SlideshowItem, Switch, CLASSNAME$3 as TIME_PICKER_FIELD_CLASSNAME, COMPONENT_NAME$3 as TIME_PICKER_FIELD_COMPONENT_NAME, Tab, TabList, TabListLayout, TabPanel, TabProvider, Table, TableBody, TableCell, TableCellVariant, TableHeader, TableRow, Text, TextField, ThOrder, ThemeProvider, Thumbnail, ThumbnailAspectRatio, ThumbnailObjectFit, ThumbnailVariant, TimePickerField, Toolbar, Tooltip, Uploader, UploaderVariant, UserBlock, clamp, useFocusPointStyle, useHeadingLevel, useTheme };
|
|
22603
23051
|
//# sourceMappingURL=index.js.map
|