@ox0/ui 0.2.3 → 0.4.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/LICENSE +21 -0
- package/dist/components/box.d.ts +2 -3
- package/dist/components/box.d.ts.map +1 -1
- package/dist/components/button.d.ts +0 -1
- package/dist/components/button.d.ts.map +1 -1
- package/dist/components/card.d.ts +2 -3
- package/dist/components/card.d.ts.map +1 -1
- package/dist/components/checkbox.d.ts +2 -1
- package/dist/components/checkbox.d.ts.map +1 -1
- package/dist/components/checkbox.test.d.ts +2 -0
- package/dist/components/checkbox.test.d.ts.map +1 -0
- package/dist/components/dialog.d.ts +33 -5
- package/dist/components/dialog.d.ts.map +1 -1
- package/dist/components/dialog.test.d.ts +2 -0
- package/dist/components/dialog.test.d.ts.map +1 -0
- package/dist/components/heading.d.ts.map +1 -1
- package/dist/components/icon-button.d.ts +1 -1
- package/dist/components/icon-button.d.ts.map +1 -1
- package/dist/components/menu.d.ts +28 -0
- package/dist/components/menu.d.ts.map +1 -0
- package/dist/components/menu.test.d.ts +2 -0
- package/dist/components/menu.test.d.ts.map +1 -0
- package/dist/components/select.d.ts.map +1 -1
- package/dist/components/select.test.d.ts +2 -0
- package/dist/components/select.test.d.ts.map +1 -0
- package/dist/components/surface.d.ts +2 -3
- package/dist/components/surface.d.ts.map +1 -1
- package/dist/components/switch.d.ts +2 -1
- package/dist/components/switch.d.ts.map +1 -1
- package/dist/components/switch.test.d.ts +2 -0
- package/dist/components/switch.test.d.ts.map +1 -0
- package/dist/components/text-field.d.ts +1 -1
- package/dist/components/text-field.d.ts.map +1 -1
- package/dist/components/text-field.test.d.ts +2 -0
- package/dist/components/text-field.test.d.ts.map +1 -0
- package/dist/components/toast.d.ts.map +1 -1
- package/dist/components/tooltip.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +628 -74
- package/dist/messages.d.ts +8 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/mixins/borders.d.ts +1 -1
- package/dist/mixins/borders.d.ts.map +1 -1
- package/package.json +4 -3
package/dist/index.js
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
2
2
|
import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__ from "react/jsx-runtime";
|
|
3
3
|
import * as __WEBPACK_EXTERNAL_MODULE__ox0_hooks_ab75bf8c__ from "@ox0/hooks";
|
|
4
|
-
import * as
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE_react_dom_7136dc57__ from "react-dom";
|
|
5
5
|
import * as __WEBPACK_EXTERNAL_MODULE__ox0_i18n_ad8e896a__ from "@ox0/i18n";
|
|
6
|
+
import * as __WEBPACK_EXTERNAL_MODULE__floating_ui_react_3ddd630a__ from "@floating-ui/react";
|
|
6
7
|
import * as __WEBPACK_EXTERNAL_MODULE__ox0_tokens_b8bc2fee__ from "@ox0/tokens";
|
|
7
8
|
import "@ox0/tokens/styles.css";
|
|
9
|
+
const defaultUiMessages = {
|
|
10
|
+
"ox0.heading.anchorLabel": "Link to {id}",
|
|
11
|
+
"ox0.heading.anchorMarker": "#",
|
|
12
|
+
"ox0.toast.dismiss": "Dismiss notification",
|
|
13
|
+
"ox0.toast.region": "Notifications"
|
|
14
|
+
};
|
|
8
15
|
const radiusMap = {
|
|
9
16
|
none: "0",
|
|
17
|
+
"2xs": "var(--ox0-radius-2xs)",
|
|
10
18
|
xs: "var(--ox0-radius-xs)",
|
|
11
19
|
sm: "var(--ox0-radius-sm)",
|
|
12
20
|
md: "var(--ox0-radius-md)",
|
|
@@ -721,7 +729,7 @@ const badge_Badge = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react__.forwardR
|
|
|
721
729
|
]
|
|
722
730
|
});
|
|
723
731
|
});
|
|
724
|
-
const box_Box = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react__.forwardRef)(function({
|
|
732
|
+
const box_Box = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react__.forwardRef)(function({ as: Tag = "div", gap, padding, paddingX, paddingY, paddingTop, paddingRight, paddingBottom, paddingLeft, borderRadius, shadow, border, borderTop, borderRight, borderBottom, borderLeft, surface, gridArea, ...rest }, ref) {
|
|
725
733
|
const { style: gridItemStyle } = useGridItem({
|
|
726
734
|
gridArea
|
|
727
735
|
});
|
|
@@ -749,14 +757,13 @@ const box_Box = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react__.forwardRef)(
|
|
|
749
757
|
});
|
|
750
758
|
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(Tag, {
|
|
751
759
|
ref: ref,
|
|
752
|
-
className: className,
|
|
753
760
|
style: {
|
|
754
761
|
...gridItemStyle,
|
|
755
762
|
...spacingStyle,
|
|
756
763
|
...bordersStyle,
|
|
757
764
|
...surfaceStyle
|
|
758
765
|
},
|
|
759
|
-
|
|
766
|
+
...rest
|
|
760
767
|
});
|
|
761
768
|
});
|
|
762
769
|
const card_module = {
|
|
@@ -765,21 +772,26 @@ const card_module = {
|
|
|
765
772
|
body: "body-UmIYhr",
|
|
766
773
|
footer: "footer-zBL2Cb"
|
|
767
774
|
};
|
|
768
|
-
const card_Card = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react__.forwardRef)(function({ children,
|
|
775
|
+
const card_Card = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react__.forwardRef)(function({ children, footer, header, padding = "lg", surface = "surface", borderRadius = "lg", shadow = "sm", as: Tag = "div", ...rest }, ref) {
|
|
776
|
+
const { style: bordersStyle } = useBorders({
|
|
777
|
+
borderRadius,
|
|
778
|
+
shadow,
|
|
779
|
+
border: true
|
|
780
|
+
});
|
|
781
|
+
const { style: surfaceStyle } = useSurface({
|
|
782
|
+
surface
|
|
783
|
+
});
|
|
769
784
|
const sectionStyle = {
|
|
770
785
|
padding: "none" === padding ? "0" : `var(--ox0-space-${padding})`
|
|
771
786
|
};
|
|
772
|
-
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)(
|
|
787
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)(Tag, {
|
|
773
788
|
ref: ref,
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
shadow: shadow,
|
|
781
|
-
surface: surface,
|
|
782
|
-
as: as,
|
|
789
|
+
className: card_module.card,
|
|
790
|
+
style: {
|
|
791
|
+
...bordersStyle,
|
|
792
|
+
...surfaceStyle
|
|
793
|
+
},
|
|
794
|
+
...rest,
|
|
783
795
|
children: [
|
|
784
796
|
null != header && /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
|
|
785
797
|
className: card_module.header,
|
|
@@ -799,19 +811,18 @@ const card_Card = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react__.forwardRef
|
|
|
799
811
|
]
|
|
800
812
|
});
|
|
801
813
|
});
|
|
802
|
-
const surface_Surface = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react__.forwardRef)(function({
|
|
814
|
+
const surface_Surface = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react__.forwardRef)(function({ surface, borderRadius, shadow, border, padding, paddingX, paddingY, as, ...rest }, ref) {
|
|
803
815
|
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(box_Box, {
|
|
804
816
|
ref: ref,
|
|
805
817
|
border: border,
|
|
806
818
|
borderRadius: borderRadius,
|
|
807
|
-
className: className,
|
|
808
819
|
padding: padding,
|
|
809
820
|
paddingX: paddingX,
|
|
810
821
|
paddingY: paddingY,
|
|
811
822
|
shadow: shadow,
|
|
812
823
|
surface: surface,
|
|
813
824
|
as: as,
|
|
814
|
-
|
|
825
|
+
...rest
|
|
815
826
|
});
|
|
816
827
|
});
|
|
817
828
|
const text_module = {
|
|
@@ -916,7 +927,7 @@ const keyboard_Keyboard = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react__.fo
|
|
|
916
927
|
background: "var(--ox0-color-surface)",
|
|
917
928
|
border: "1px solid var(--ox0-color-border)",
|
|
918
929
|
borderBottomWidth: "2px",
|
|
919
|
-
borderRadius: "var(--ox0-radius-
|
|
930
|
+
borderRadius: "var(--ox0-radius-xs)",
|
|
920
931
|
color: "var(--ox0-color-foreground)",
|
|
921
932
|
whiteSpace: "nowrap"
|
|
922
933
|
},
|
|
@@ -1224,12 +1235,18 @@ const checkbox_module = {
|
|
|
1224
1235
|
label: "label-NpcnDS",
|
|
1225
1236
|
disabled: "disabled-37Ma1q",
|
|
1226
1237
|
input: "input-LnwEg8",
|
|
1238
|
+
description: "description-MXg1q9",
|
|
1227
1239
|
error: "error-HlZR91"
|
|
1228
1240
|
};
|
|
1229
|
-
|
|
1241
|
+
const checkbox_Checkbox = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react__.forwardRef)(function({ label, description, isDisabled, isInvalid, isSelected, defaultSelected, errorMessage, onChange, id: idProp, ...props }, ref) {
|
|
1230
1242
|
const generatedId = (0, __WEBPACK_EXTERNAL_MODULE_react__.useId)();
|
|
1231
1243
|
const id = idProp ?? generatedId;
|
|
1244
|
+
const descriptionId = description ? `${id}-description` : void 0;
|
|
1232
1245
|
const errorId = errorMessage ? `${id}-error` : void 0;
|
|
1246
|
+
const describedBy = [
|
|
1247
|
+
descriptionId,
|
|
1248
|
+
errorId
|
|
1249
|
+
].filter(Boolean).join(" ") || void 0;
|
|
1233
1250
|
const invalid = isInvalid || !!errorMessage;
|
|
1234
1251
|
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("div", {
|
|
1235
1252
|
className: checkbox_module.root,
|
|
@@ -1239,7 +1256,8 @@ function Checkbox({ label, isDisabled, isInvalid, isSelected, defaultSelected, e
|
|
|
1239
1256
|
children: [
|
|
1240
1257
|
/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("input", {
|
|
1241
1258
|
...props,
|
|
1242
|
-
|
|
1259
|
+
ref: ref,
|
|
1260
|
+
"aria-describedby": describedBy,
|
|
1243
1261
|
"aria-invalid": invalid || void 0,
|
|
1244
1262
|
checked: isSelected,
|
|
1245
1263
|
className: checkbox_module.input,
|
|
@@ -1249,9 +1267,18 @@ function Checkbox({ label, isDisabled, isInvalid, isSelected, defaultSelected, e
|
|
|
1249
1267
|
onChange: (e)=>onChange?.(e.target.checked),
|
|
1250
1268
|
type: "checkbox"
|
|
1251
1269
|
}),
|
|
1252
|
-
|
|
1253
|
-
children:
|
|
1254
|
-
|
|
1270
|
+
/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("span", {
|
|
1271
|
+
children: [
|
|
1272
|
+
label ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("span", {
|
|
1273
|
+
children: label
|
|
1274
|
+
}) : null,
|
|
1275
|
+
description ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("span", {
|
|
1276
|
+
className: checkbox_module.description,
|
|
1277
|
+
id: descriptionId,
|
|
1278
|
+
children: description
|
|
1279
|
+
}) : null
|
|
1280
|
+
]
|
|
1281
|
+
})
|
|
1255
1282
|
]
|
|
1256
1283
|
}),
|
|
1257
1284
|
errorMessage ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("span", {
|
|
@@ -1261,35 +1288,149 @@ function Checkbox({ label, isDisabled, isInvalid, isSelected, defaultSelected, e
|
|
|
1261
1288
|
}) : null
|
|
1262
1289
|
]
|
|
1263
1290
|
});
|
|
1264
|
-
}
|
|
1291
|
+
});
|
|
1265
1292
|
const dialog_module = {
|
|
1266
1293
|
overlay: "overlay-KCSdjX",
|
|
1294
|
+
overlayShow: "overlayShow-lH7CfL",
|
|
1295
|
+
overlayHide: "overlayHide-F4Gj2F",
|
|
1296
|
+
backdrop: "backdrop-DQalCV",
|
|
1267
1297
|
dialog: "dialog-WXDUzL",
|
|
1268
|
-
|
|
1298
|
+
dialogShow: "dialogShow-YtVdkm",
|
|
1299
|
+
dialogHide: "dialogHide-uSvQPq",
|
|
1300
|
+
header: "header-ogdbpL",
|
|
1301
|
+
title: "title-uK_Bbe",
|
|
1302
|
+
body: "body-j8xBuG",
|
|
1303
|
+
footer: "footer-w0_Blm"
|
|
1269
1304
|
};
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1305
|
+
const FOCUSABLE_SELECTOR = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
1306
|
+
const DialogContext = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react__.createContext)(null);
|
|
1307
|
+
function useDialogContext() {
|
|
1308
|
+
const ctx = (0, __WEBPACK_EXTERNAL_MODULE_react__.useContext)(DialogContext);
|
|
1309
|
+
if (!ctx) throw new Error("Dialog subcomponents must be used inside <Dialog>");
|
|
1310
|
+
return ctx;
|
|
1311
|
+
}
|
|
1312
|
+
function DialogRoot({ children, isDismissDisabled, isEphemeral, isOpen, onClose }) {
|
|
1313
|
+
const titleId = (0, __WEBPACK_EXTERNAL_MODULE_react__.useId)();
|
|
1314
|
+
const dialogRef = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)(null);
|
|
1315
|
+
const [isVisible, setIsVisible] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(isOpen);
|
|
1316
|
+
(0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
|
|
1317
|
+
if (isOpen) setIsVisible(true);
|
|
1318
|
+
}, [
|
|
1319
|
+
isOpen
|
|
1320
|
+
]);
|
|
1321
|
+
const isExiting = isVisible && !isOpen;
|
|
1322
|
+
const contextValue = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>({
|
|
1323
|
+
onClose,
|
|
1324
|
+
titleId
|
|
1325
|
+
}), [
|
|
1326
|
+
onClose,
|
|
1327
|
+
titleId
|
|
1328
|
+
]);
|
|
1329
|
+
(0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
|
|
1330
|
+
if (!isOpen) return;
|
|
1331
|
+
const previouslyFocused = document.activeElement;
|
|
1332
|
+
const first = dialogRef.current?.querySelector(FOCUSABLE_SELECTOR);
|
|
1333
|
+
first?.focus();
|
|
1334
|
+
return ()=>{
|
|
1335
|
+
if (previouslyFocused instanceof HTMLElement) previouslyFocused.focus();
|
|
1336
|
+
};
|
|
1337
|
+
}, [
|
|
1338
|
+
isOpen
|
|
1339
|
+
]);
|
|
1340
|
+
(0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
|
|
1341
|
+
if (!isOpen) return;
|
|
1342
|
+
const handler = (e)=>{
|
|
1343
|
+
if ("Escape" === e.key) {
|
|
1344
|
+
e.preventDefault();
|
|
1345
|
+
if (!isDismissDisabled) onClose();
|
|
1346
|
+
}
|
|
1347
|
+
};
|
|
1348
|
+
document.addEventListener("keydown", handler);
|
|
1349
|
+
return ()=>document.removeEventListener("keydown", handler);
|
|
1350
|
+
}, [
|
|
1351
|
+
isDismissDisabled,
|
|
1352
|
+
isOpen,
|
|
1353
|
+
onClose
|
|
1354
|
+
]);
|
|
1355
|
+
if (!isVisible) return null;
|
|
1356
|
+
const handleKeyDown = (e)=>{
|
|
1357
|
+
if ("Tab" !== e.key) return;
|
|
1358
|
+
const focusable = Array.from(dialogRef.current?.querySelectorAll(FOCUSABLE_SELECTOR) ?? []);
|
|
1359
|
+
if (0 === focusable.length) return;
|
|
1360
|
+
const first = focusable[0];
|
|
1361
|
+
const last = focusable[focusable.length - 1];
|
|
1362
|
+
if (e.shiftKey) {
|
|
1363
|
+
if (document.activeElement === first) {
|
|
1364
|
+
e.preventDefault();
|
|
1365
|
+
last?.focus();
|
|
1366
|
+
}
|
|
1367
|
+
} else if (document.activeElement === last) {
|
|
1368
|
+
e.preventDefault();
|
|
1369
|
+
first?.focus();
|
|
1370
|
+
}
|
|
1371
|
+
};
|
|
1372
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_dom_7136dc57__.createPortal)(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("div", {
|
|
1273
1373
|
className: dialog_module.overlay,
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1374
|
+
"data-exiting": isExiting || void 0,
|
|
1375
|
+
onAnimationEnd: (e)=>{
|
|
1376
|
+
if (e.target === e.currentTarget && isExiting) setIsVisible(false);
|
|
1377
|
+
},
|
|
1378
|
+
children: [
|
|
1379
|
+
/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
|
|
1380
|
+
"aria-hidden": "true",
|
|
1381
|
+
className: dialog_module.backdrop,
|
|
1382
|
+
onClick: ()=>{
|
|
1383
|
+
if (isEphemeral && !isExiting) onClose();
|
|
1384
|
+
}
|
|
1385
|
+
}),
|
|
1386
|
+
/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(DialogContext.Provider, {
|
|
1387
|
+
value: contextValue,
|
|
1388
|
+
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("dialog", {
|
|
1389
|
+
ref: dialogRef,
|
|
1390
|
+
"aria-labelledby": titleId,
|
|
1391
|
+
"aria-modal": "true",
|
|
1392
|
+
className: dialog_module.dialog,
|
|
1393
|
+
open: true,
|
|
1394
|
+
onKeyDown: handleKeyDown,
|
|
1284
1395
|
children: children
|
|
1285
|
-
})
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1396
|
+
})
|
|
1397
|
+
})
|
|
1398
|
+
]
|
|
1399
|
+
}), document.body);
|
|
1400
|
+
}
|
|
1401
|
+
function DialogHeader({ children }) {
|
|
1402
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
|
|
1403
|
+
className: dialog_module.header,
|
|
1404
|
+
children: children
|
|
1405
|
+
});
|
|
1406
|
+
}
|
|
1407
|
+
function DialogTitle({ children }) {
|
|
1408
|
+
const { titleId } = useDialogContext();
|
|
1409
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("h2", {
|
|
1410
|
+
id: titleId,
|
|
1411
|
+
className: dialog_module.title,
|
|
1412
|
+
children: children
|
|
1291
1413
|
});
|
|
1292
1414
|
}
|
|
1415
|
+
function DialogBody({ children }) {
|
|
1416
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
|
|
1417
|
+
className: dialog_module.body,
|
|
1418
|
+
children: children
|
|
1419
|
+
});
|
|
1420
|
+
}
|
|
1421
|
+
function DialogFooter({ children }) {
|
|
1422
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
|
|
1423
|
+
className: dialog_module.footer,
|
|
1424
|
+
children: children
|
|
1425
|
+
});
|
|
1426
|
+
}
|
|
1427
|
+
const Dialog = Object.assign(DialogRoot, {
|
|
1428
|
+
displayName: "Dialog",
|
|
1429
|
+
Header: DialogHeader,
|
|
1430
|
+
Title: DialogTitle,
|
|
1431
|
+
Body: DialogBody,
|
|
1432
|
+
Footer: DialogFooter
|
|
1433
|
+
});
|
|
1293
1434
|
const divider_module = {
|
|
1294
1435
|
divider: "divider-kFs3jn",
|
|
1295
1436
|
vertical: "vertical-zScVIz",
|
|
@@ -1321,6 +1462,10 @@ const levelClass = {
|
|
|
1321
1462
|
3: heading_module.h3 ?? ""
|
|
1322
1463
|
};
|
|
1323
1464
|
const heading_Heading = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react__.forwardRef)(function({ children, className, id, level = 2 }, ref) {
|
|
1465
|
+
const anchorLabel = (0, __WEBPACK_EXTERNAL_MODULE__ox0_i18n_ad8e896a__.useMessage)("ox0.heading.anchorLabel", "Link to {id}", id ? {
|
|
1466
|
+
id
|
|
1467
|
+
} : {});
|
|
1468
|
+
const anchorMarker = (0, __WEBPACK_EXTERNAL_MODULE__ox0_i18n_ad8e896a__.useMessage)("ox0.heading.anchorMarker", "#");
|
|
1324
1469
|
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react__.createElement)(`h${level}`, {
|
|
1325
1470
|
ref,
|
|
1326
1471
|
id,
|
|
@@ -1335,10 +1480,10 @@ const heading_Heading = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react__.forw
|
|
|
1335
1480
|
children: children
|
|
1336
1481
|
}),
|
|
1337
1482
|
id ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("a", {
|
|
1338
|
-
"aria-label":
|
|
1483
|
+
"aria-label": anchorLabel,
|
|
1339
1484
|
className: heading_module.anchor,
|
|
1340
1485
|
href: `#${id}`,
|
|
1341
|
-
children:
|
|
1486
|
+
children: anchorMarker
|
|
1342
1487
|
}) : null
|
|
1343
1488
|
]
|
|
1344
1489
|
}));
|
|
@@ -1454,9 +1599,14 @@ function Tooltip({ content, placement = "top", children, isDisabled = false }) {
|
|
|
1454
1599
|
tryClose();
|
|
1455
1600
|
}
|
|
1456
1601
|
});
|
|
1602
|
+
const childRef = children.props.ref ?? null;
|
|
1603
|
+
const composedRef = (0, __WEBPACK_EXTERNAL_MODULE__floating_ui_react_3ddd630a__.useMergeRefs)([
|
|
1604
|
+
refs.setReference,
|
|
1605
|
+
childRef
|
|
1606
|
+
]);
|
|
1457
1607
|
if (isDisabled) return children;
|
|
1458
1608
|
const trigger = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react__.cloneElement)(children, {
|
|
1459
|
-
ref:
|
|
1609
|
+
ref: composedRef,
|
|
1460
1610
|
...referenceProps
|
|
1461
1611
|
});
|
|
1462
1612
|
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.Fragment, {
|
|
@@ -1474,21 +1624,27 @@ function Tooltip({ content, placement = "top", children, isDisabled = false }) {
|
|
|
1474
1624
|
]
|
|
1475
1625
|
});
|
|
1476
1626
|
}
|
|
1477
|
-
|
|
1627
|
+
const icon_button_iconSize = {
|
|
1628
|
+
sm: 14,
|
|
1629
|
+
md: 16,
|
|
1630
|
+
lg: 20
|
|
1631
|
+
};
|
|
1632
|
+
const icon_button_IconButton = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react__.forwardRef)(function({ icon: Icon, label, size = "md", tooltipPlacement, variant = "circle", ...props }, ref) {
|
|
1478
1633
|
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(Tooltip, {
|
|
1479
1634
|
content: label,
|
|
1480
1635
|
placement: tooltipPlacement,
|
|
1481
1636
|
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(button_Button, {
|
|
1482
1637
|
...props,
|
|
1638
|
+
ref: ref,
|
|
1483
1639
|
"aria-label": label,
|
|
1484
1640
|
size: size,
|
|
1485
1641
|
variant: variant,
|
|
1486
1642
|
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(Icon, {
|
|
1487
|
-
size:
|
|
1643
|
+
size: icon_button_iconSize[size]
|
|
1488
1644
|
})
|
|
1489
1645
|
})
|
|
1490
1646
|
});
|
|
1491
|
-
}
|
|
1647
|
+
});
|
|
1492
1648
|
const icon_label_IconLabel = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react__.forwardRef)(function({ icon: Icon, children }, ref) {
|
|
1493
1649
|
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("span", {
|
|
1494
1650
|
ref: ref,
|
|
@@ -1573,6 +1729,371 @@ const spinner_Spinner = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react__.forw
|
|
|
1573
1729
|
]
|
|
1574
1730
|
});
|
|
1575
1731
|
});
|
|
1732
|
+
const menu_module = {
|
|
1733
|
+
panel: "panel-Wzy_zi",
|
|
1734
|
+
list: "list-le5LXO",
|
|
1735
|
+
row: "row-qrs18w",
|
|
1736
|
+
item: "item-IFgseY",
|
|
1737
|
+
itemIcon: "itemIcon-wBLUSc",
|
|
1738
|
+
itemMain: "itemMain-brNNFH",
|
|
1739
|
+
itemLabel: "itemLabel-rwh31y",
|
|
1740
|
+
itemHint: "itemHint-yCr5IQ",
|
|
1741
|
+
itemChevron: "itemChevron-PhcQi_"
|
|
1742
|
+
};
|
|
1743
|
+
const VIEWPORT_MARGIN = 16;
|
|
1744
|
+
function firstEnabled(items) {
|
|
1745
|
+
const i = items.findIndex((item)=>!item.isDisabled);
|
|
1746
|
+
return -1 === i ? 0 : i;
|
|
1747
|
+
}
|
|
1748
|
+
function lastEnabled(items) {
|
|
1749
|
+
for(let i = items.length - 1; i >= 0; i--)if (!items[i]?.isDisabled) return i;
|
|
1750
|
+
return 0;
|
|
1751
|
+
}
|
|
1752
|
+
function nextEnabled(items, from, delta) {
|
|
1753
|
+
let i = from + delta;
|
|
1754
|
+
while(i >= 0 && i < items.length){
|
|
1755
|
+
if (!items[i]?.isDisabled) return i;
|
|
1756
|
+
i += delta;
|
|
1757
|
+
}
|
|
1758
|
+
return from;
|
|
1759
|
+
}
|
|
1760
|
+
function itemAtPath(root, path) {
|
|
1761
|
+
let items = root;
|
|
1762
|
+
let item = null;
|
|
1763
|
+
for (const idx of path){
|
|
1764
|
+
item = items[idx] ?? null;
|
|
1765
|
+
if (!item?.items?.length) return null;
|
|
1766
|
+
items = item.items;
|
|
1767
|
+
}
|
|
1768
|
+
return item;
|
|
1769
|
+
}
|
|
1770
|
+
function buildLevels(root, openPath, activeIndices) {
|
|
1771
|
+
const levels = [
|
|
1772
|
+
{
|
|
1773
|
+
depth: 0,
|
|
1774
|
+
items: root,
|
|
1775
|
+
activeIndex: activeIndices[0] ?? firstEnabled(root)
|
|
1776
|
+
}
|
|
1777
|
+
];
|
|
1778
|
+
let items = root;
|
|
1779
|
+
for(let d = 0; d < openPath.length; d++){
|
|
1780
|
+
const parent = items[openPath[d]];
|
|
1781
|
+
if (!parent?.items?.length) break;
|
|
1782
|
+
items = parent.items;
|
|
1783
|
+
levels.push({
|
|
1784
|
+
depth: d + 1,
|
|
1785
|
+
items,
|
|
1786
|
+
activeIndex: activeIndices[d + 1] ?? firstEnabled(items),
|
|
1787
|
+
label: "string" == typeof parent.label ? parent.label : void 0
|
|
1788
|
+
});
|
|
1789
|
+
}
|
|
1790
|
+
return levels;
|
|
1791
|
+
}
|
|
1792
|
+
function MenuPanel({ activeIndex, ariaLabel, depth, items, onActivate, onBack, onClose, onOpenChild, onSelect, referenceEl, registerBtn }) {
|
|
1793
|
+
const { refs, floatingStyles } = (0, __WEBPACK_EXTERNAL_MODULE__floating_ui_react_3ddd630a__.useFloating)({
|
|
1794
|
+
placement: 0 === depth ? "bottom-end" : "right-start",
|
|
1795
|
+
middleware: [
|
|
1796
|
+
(0, __WEBPACK_EXTERNAL_MODULE__floating_ui_react_3ddd630a__.offset)(0 === depth ? 10 : 8),
|
|
1797
|
+
(0, __WEBPACK_EXTERNAL_MODULE__floating_ui_react_3ddd630a__.flip)({
|
|
1798
|
+
padding: VIEWPORT_MARGIN,
|
|
1799
|
+
fallbackPlacements: 0 === depth ? [
|
|
1800
|
+
"bottom-start",
|
|
1801
|
+
"top-end",
|
|
1802
|
+
"top-start"
|
|
1803
|
+
] : [
|
|
1804
|
+
"left-start",
|
|
1805
|
+
"right-start"
|
|
1806
|
+
]
|
|
1807
|
+
}),
|
|
1808
|
+
(0, __WEBPACK_EXTERNAL_MODULE__floating_ui_react_3ddd630a__.shift)({
|
|
1809
|
+
padding: VIEWPORT_MARGIN
|
|
1810
|
+
})
|
|
1811
|
+
],
|
|
1812
|
+
whileElementsMounted: __WEBPACK_EXTERNAL_MODULE__floating_ui_react_3ddd630a__.autoUpdate
|
|
1813
|
+
});
|
|
1814
|
+
(0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
|
|
1815
|
+
refs.setReference(referenceEl);
|
|
1816
|
+
}, [
|
|
1817
|
+
referenceEl,
|
|
1818
|
+
refs
|
|
1819
|
+
]);
|
|
1820
|
+
const onKeyDown = (0, __WEBPACK_EXTERNAL_MODULE_react__.useCallback)((e)=>{
|
|
1821
|
+
if ("ArrowDown" === e.key) {
|
|
1822
|
+
e.preventDefault();
|
|
1823
|
+
onActivate(depth, e.altKey ? lastEnabled(items) : nextEnabled(items, activeIndex, 1));
|
|
1824
|
+
} else if ("ArrowUp" === e.key) {
|
|
1825
|
+
e.preventDefault();
|
|
1826
|
+
onActivate(depth, e.altKey ? firstEnabled(items) : nextEnabled(items, activeIndex, -1));
|
|
1827
|
+
} else if ("Home" === e.key) {
|
|
1828
|
+
e.preventDefault();
|
|
1829
|
+
onActivate(depth, firstEnabled(items));
|
|
1830
|
+
} else if ("End" === e.key) {
|
|
1831
|
+
e.preventDefault();
|
|
1832
|
+
onActivate(depth, lastEnabled(items));
|
|
1833
|
+
} else if ("ArrowRight" === e.key) {
|
|
1834
|
+
e.preventDefault();
|
|
1835
|
+
if (items[activeIndex]?.items?.length) onOpenChild(depth, activeIndex);
|
|
1836
|
+
} else if ("ArrowLeft" === e.key) {
|
|
1837
|
+
if (depth > 0) {
|
|
1838
|
+
e.preventDefault();
|
|
1839
|
+
onBack(depth - 1);
|
|
1840
|
+
}
|
|
1841
|
+
} else if ("Escape" === e.key) {
|
|
1842
|
+
e.preventDefault();
|
|
1843
|
+
onClose();
|
|
1844
|
+
} else if ("Enter" === e.key || " " === e.key) {
|
|
1845
|
+
e.preventDefault();
|
|
1846
|
+
const item = items[activeIndex];
|
|
1847
|
+
if (item) onSelect(depth, item);
|
|
1848
|
+
}
|
|
1849
|
+
}, [
|
|
1850
|
+
activeIndex,
|
|
1851
|
+
depth,
|
|
1852
|
+
items,
|
|
1853
|
+
onActivate,
|
|
1854
|
+
onBack,
|
|
1855
|
+
onClose,
|
|
1856
|
+
onOpenChild,
|
|
1857
|
+
onSelect
|
|
1858
|
+
]);
|
|
1859
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
|
|
1860
|
+
className: menu_module.panel,
|
|
1861
|
+
onKeyDown: onKeyDown,
|
|
1862
|
+
ref: refs.setFloating,
|
|
1863
|
+
role: "presentation",
|
|
1864
|
+
style: floatingStyles,
|
|
1865
|
+
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("ul", {
|
|
1866
|
+
"aria-label": ariaLabel,
|
|
1867
|
+
className: menu_module.list,
|
|
1868
|
+
role: "menu",
|
|
1869
|
+
children: items.map((item, index)=>{
|
|
1870
|
+
const hasChildren = Boolean(item.items?.length);
|
|
1871
|
+
const isActive = index === activeIndex;
|
|
1872
|
+
const Icon = item.icon;
|
|
1873
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("li", {
|
|
1874
|
+
className: menu_module.row,
|
|
1875
|
+
role: "none",
|
|
1876
|
+
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("button", {
|
|
1877
|
+
"aria-disabled": item.isDisabled || void 0,
|
|
1878
|
+
"aria-expanded": hasChildren && isActive ? true : void 0,
|
|
1879
|
+
"aria-haspopup": hasChildren ? "menu" : void 0,
|
|
1880
|
+
className: menu_module.item,
|
|
1881
|
+
"data-active": isActive || void 0,
|
|
1882
|
+
"data-disabled": item.isDisabled || void 0,
|
|
1883
|
+
onClick: ()=>onSelect(depth, item),
|
|
1884
|
+
onFocus: ()=>{
|
|
1885
|
+
onBack(depth);
|
|
1886
|
+
onActivate(depth, index);
|
|
1887
|
+
},
|
|
1888
|
+
onMouseEnter: ()=>onActivate(depth, index),
|
|
1889
|
+
ref: (node)=>registerBtn(depth, index, node),
|
|
1890
|
+
role: "menuitem",
|
|
1891
|
+
type: "button",
|
|
1892
|
+
children: [
|
|
1893
|
+
/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("span", {
|
|
1894
|
+
className: menu_module.itemIcon,
|
|
1895
|
+
children: Icon ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(Icon, {
|
|
1896
|
+
size: 15
|
|
1897
|
+
}) : null
|
|
1898
|
+
}),
|
|
1899
|
+
/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("span", {
|
|
1900
|
+
className: menu_module.itemMain,
|
|
1901
|
+
children: [
|
|
1902
|
+
/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("span", {
|
|
1903
|
+
className: menu_module.itemLabel,
|
|
1904
|
+
children: item.label
|
|
1905
|
+
}),
|
|
1906
|
+
item.hint ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("span", {
|
|
1907
|
+
className: menu_module.itemHint,
|
|
1908
|
+
children: item.hint
|
|
1909
|
+
}) : null
|
|
1910
|
+
]
|
|
1911
|
+
}),
|
|
1912
|
+
/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("span", {
|
|
1913
|
+
className: menu_module.itemChevron,
|
|
1914
|
+
"aria-hidden": "true",
|
|
1915
|
+
children: hasChildren ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("svg", {
|
|
1916
|
+
"aria-hidden": "true",
|
|
1917
|
+
fill: "none",
|
|
1918
|
+
height: 15,
|
|
1919
|
+
stroke: "currentColor",
|
|
1920
|
+
strokeLinecap: "round",
|
|
1921
|
+
strokeLinejoin: "round",
|
|
1922
|
+
strokeWidth: 2,
|
|
1923
|
+
viewBox: "0 0 24 24",
|
|
1924
|
+
width: 15,
|
|
1925
|
+
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("path", {
|
|
1926
|
+
d: "m9 18 6-6-6-6"
|
|
1927
|
+
})
|
|
1928
|
+
}) : null
|
|
1929
|
+
})
|
|
1930
|
+
]
|
|
1931
|
+
})
|
|
1932
|
+
}, `${depth}-${item.id}`);
|
|
1933
|
+
})
|
|
1934
|
+
})
|
|
1935
|
+
});
|
|
1936
|
+
}
|
|
1937
|
+
function Menu({ ariaLabel, items, trigger }) {
|
|
1938
|
+
const triggerRef = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)(null);
|
|
1939
|
+
const panelRef = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)(null);
|
|
1940
|
+
const buttonRefs = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)([]);
|
|
1941
|
+
const [isOpen, setIsOpen] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(false);
|
|
1942
|
+
const [openPath, setOpenPath] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)([]);
|
|
1943
|
+
const [activeIndices, setActiveIndices] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)([
|
|
1944
|
+
firstEnabled(items)
|
|
1945
|
+
]);
|
|
1946
|
+
const [focusDepth, setFocusDepth] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(0);
|
|
1947
|
+
const levels = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>buildLevels(items, openPath, activeIndices), [
|
|
1948
|
+
activeIndices,
|
|
1949
|
+
items,
|
|
1950
|
+
openPath
|
|
1951
|
+
]);
|
|
1952
|
+
const close = (0, __WEBPACK_EXTERNAL_MODULE_react__.useCallback)(()=>{
|
|
1953
|
+
setIsOpen(false);
|
|
1954
|
+
setOpenPath([]);
|
|
1955
|
+
setActiveIndices([
|
|
1956
|
+
firstEnabled(items)
|
|
1957
|
+
]);
|
|
1958
|
+
setFocusDepth(0);
|
|
1959
|
+
triggerRef.current?.focus();
|
|
1960
|
+
}, [
|
|
1961
|
+
items
|
|
1962
|
+
]);
|
|
1963
|
+
const open = (0, __WEBPACK_EXTERNAL_MODULE_react__.useCallback)(()=>{
|
|
1964
|
+
setOpenPath([]);
|
|
1965
|
+
setActiveIndices([
|
|
1966
|
+
firstEnabled(items)
|
|
1967
|
+
]);
|
|
1968
|
+
setFocusDepth(0);
|
|
1969
|
+
setIsOpen(true);
|
|
1970
|
+
}, [
|
|
1971
|
+
items
|
|
1972
|
+
]);
|
|
1973
|
+
const activateIndex = (0, __WEBPACK_EXTERNAL_MODULE_react__.useCallback)((depth, index)=>{
|
|
1974
|
+
setActiveIndices((prev)=>{
|
|
1975
|
+
const next = [
|
|
1976
|
+
...prev
|
|
1977
|
+
];
|
|
1978
|
+
next[depth] = index;
|
|
1979
|
+
return next.slice(0, depth + 2);
|
|
1980
|
+
});
|
|
1981
|
+
setFocusDepth(depth);
|
|
1982
|
+
}, []);
|
|
1983
|
+
const openChild = (0, __WEBPACK_EXTERNAL_MODULE_react__.useCallback)((depth, index)=>{
|
|
1984
|
+
const levelItems = levels[depth]?.items ?? [];
|
|
1985
|
+
if (!levelItems[index]?.items?.length) {
|
|
1986
|
+
setOpenPath((p)=>p.slice(0, depth));
|
|
1987
|
+
return;
|
|
1988
|
+
}
|
|
1989
|
+
const nextPath = [
|
|
1990
|
+
...openPath.slice(0, depth),
|
|
1991
|
+
index
|
|
1992
|
+
];
|
|
1993
|
+
setOpenPath(nextPath);
|
|
1994
|
+
setActiveIndices((prev)=>{
|
|
1995
|
+
const next = [
|
|
1996
|
+
...prev
|
|
1997
|
+
];
|
|
1998
|
+
if (void 0 === next[depth + 1]) {
|
|
1999
|
+
const child = itemAtPath(items, nextPath);
|
|
2000
|
+
next[depth + 1] = firstEnabled(child?.items ?? []);
|
|
2001
|
+
}
|
|
2002
|
+
return next;
|
|
2003
|
+
});
|
|
2004
|
+
setFocusDepth(depth + 1);
|
|
2005
|
+
}, [
|
|
2006
|
+
items,
|
|
2007
|
+
levels,
|
|
2008
|
+
openPath
|
|
2009
|
+
]);
|
|
2010
|
+
const closeToDepth = (0, __WEBPACK_EXTERNAL_MODULE_react__.useCallback)((depth)=>{
|
|
2011
|
+
setOpenPath((p)=>p.slice(0, depth));
|
|
2012
|
+
setActiveIndices((prev)=>prev.slice(0, depth + 1));
|
|
2013
|
+
setFocusDepth(depth);
|
|
2014
|
+
}, []);
|
|
2015
|
+
const handleSelect = (0, __WEBPACK_EXTERNAL_MODULE_react__.useCallback)((depth, item)=>{
|
|
2016
|
+
if (item.isDisabled) return;
|
|
2017
|
+
if (item.items?.length) {
|
|
2018
|
+
const index = levels[depth]?.items.findIndex((e)=>e.id === item.id) ?? -1;
|
|
2019
|
+
if (-1 !== index) openChild(depth, index);
|
|
2020
|
+
return;
|
|
2021
|
+
}
|
|
2022
|
+
item.onSelect?.();
|
|
2023
|
+
close();
|
|
2024
|
+
}, [
|
|
2025
|
+
close,
|
|
2026
|
+
levels,
|
|
2027
|
+
openChild
|
|
2028
|
+
]);
|
|
2029
|
+
const registerBtn = (0, __WEBPACK_EXTERNAL_MODULE_react__.useCallback)((depth, index, node)=>{
|
|
2030
|
+
if (!buttonRefs.current[depth]) buttonRefs.current[depth] = [];
|
|
2031
|
+
buttonRefs.current[depth][index] = node;
|
|
2032
|
+
}, []);
|
|
2033
|
+
(0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
|
|
2034
|
+
if (!isOpen) return;
|
|
2035
|
+
buttonRefs.current[focusDepth]?.[activeIndices[focusDepth] ?? 0]?.focus();
|
|
2036
|
+
}, [
|
|
2037
|
+
activeIndices,
|
|
2038
|
+
focusDepth,
|
|
2039
|
+
isOpen
|
|
2040
|
+
]);
|
|
2041
|
+
(0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
|
|
2042
|
+
if (!isOpen) return;
|
|
2043
|
+
const handlePointerDown = (e)=>{
|
|
2044
|
+
if (!(e.target instanceof Node)) return;
|
|
2045
|
+
if (panelRef.current?.contains(e.target)) return;
|
|
2046
|
+
if (triggerRef.current?.contains(e.target)) return;
|
|
2047
|
+
close();
|
|
2048
|
+
};
|
|
2049
|
+
document.addEventListener("pointerdown", handlePointerDown);
|
|
2050
|
+
return ()=>document.removeEventListener("pointerdown", handlePointerDown);
|
|
2051
|
+
}, [
|
|
2052
|
+
close,
|
|
2053
|
+
isOpen
|
|
2054
|
+
]);
|
|
2055
|
+
const triggerEl = __WEBPACK_EXTERNAL_MODULE_react__.Children.only(trigger);
|
|
2056
|
+
const enhancedTrigger = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react__.cloneElement)(triggerEl, {
|
|
2057
|
+
ref: triggerRef,
|
|
2058
|
+
"aria-expanded": isOpen,
|
|
2059
|
+
"aria-haspopup": "menu",
|
|
2060
|
+
onPointerDown: (e)=>{
|
|
2061
|
+
e.preventDefault();
|
|
2062
|
+
if (isOpen) close();
|
|
2063
|
+
else open();
|
|
2064
|
+
},
|
|
2065
|
+
onKeyDown: (e)=>{
|
|
2066
|
+
if ("Enter" === e.key || " " === e.key || "ArrowDown" === e.key) {
|
|
2067
|
+
e.preventDefault();
|
|
2068
|
+
if (!isOpen) open();
|
|
2069
|
+
}
|
|
2070
|
+
if ("Escape" === e.key && isOpen) close();
|
|
2071
|
+
}
|
|
2072
|
+
});
|
|
2073
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.Fragment, {
|
|
2074
|
+
children: [
|
|
2075
|
+
enhancedTrigger,
|
|
2076
|
+
isOpen ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__floating_ui_react_3ddd630a__.FloatingPortal, {
|
|
2077
|
+
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
|
|
2078
|
+
ref: panelRef,
|
|
2079
|
+
children: levels.map((level)=>/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(MenuPanel, {
|
|
2080
|
+
activeIndex: level.activeIndex,
|
|
2081
|
+
ariaLabel: level.label ?? ariaLabel,
|
|
2082
|
+
depth: level.depth,
|
|
2083
|
+
items: level.items,
|
|
2084
|
+
onActivate: activateIndex,
|
|
2085
|
+
onBack: closeToDepth,
|
|
2086
|
+
onClose: close,
|
|
2087
|
+
onOpenChild: openChild,
|
|
2088
|
+
onSelect: handleSelect,
|
|
2089
|
+
referenceEl: 0 === level.depth ? triggerRef.current : buttonRefs.current[level.depth - 1]?.[openPath[level.depth - 1]] ?? null,
|
|
2090
|
+
registerBtn: registerBtn
|
|
2091
|
+
}, level.depth))
|
|
2092
|
+
})
|
|
2093
|
+
}) : null
|
|
2094
|
+
]
|
|
2095
|
+
});
|
|
2096
|
+
}
|
|
1576
2097
|
const popover_module = {
|
|
1577
2098
|
popover: "popover-ufn1fo"
|
|
1578
2099
|
};
|
|
@@ -1707,19 +2228,18 @@ function ToastProvider({ children }) {
|
|
|
1707
2228
|
value: contextValue,
|
|
1708
2229
|
children: [
|
|
1709
2230
|
children,
|
|
1710
|
-
/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
})
|
|
1716
|
-
})
|
|
2231
|
+
/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_dom_7136dc57__.createPortal)(/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(ToastRegion, {
|
|
2232
|
+
toasts: toasts,
|
|
2233
|
+
onStartExit: startExit,
|
|
2234
|
+
onRemove: removeToast
|
|
2235
|
+
}), document.body)
|
|
1717
2236
|
]
|
|
1718
2237
|
});
|
|
1719
2238
|
}
|
|
1720
2239
|
function ToastRegion({ toasts, onStartExit, onRemove }) {
|
|
2240
|
+
const regionLabel = (0, __WEBPACK_EXTERNAL_MODULE__ox0_i18n_ad8e896a__.useMessage)("ox0.toast.region", "Notifications");
|
|
1721
2241
|
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("section", {
|
|
1722
|
-
"aria-label":
|
|
2242
|
+
"aria-label": regionLabel,
|
|
1723
2243
|
"aria-live": "polite",
|
|
1724
2244
|
className: toast_module.region,
|
|
1725
2245
|
children: toasts.map((toast)=>/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(ToastItem, {
|
|
@@ -1838,7 +2358,7 @@ function ToastItem({ toast, onStartExit, onRemove }) {
|
|
|
1838
2358
|
children: action.label
|
|
1839
2359
|
}),
|
|
1840
2360
|
/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("button", {
|
|
1841
|
-
"aria-label": "Dismiss notification",
|
|
2361
|
+
"aria-label": (0, __WEBPACK_EXTERNAL_MODULE__ox0_i18n_ad8e896a__.useMessage)("ox0.toast.dismiss", "Dismiss notification"),
|
|
1842
2362
|
className: toast_module.closeButton,
|
|
1843
2363
|
type: "button",
|
|
1844
2364
|
onClick: remove,
|
|
@@ -1878,6 +2398,7 @@ const select_module = {
|
|
|
1878
2398
|
root: "root-FHU2Km",
|
|
1879
2399
|
label: "label-QcwXLk",
|
|
1880
2400
|
select: "select-gSATBt",
|
|
2401
|
+
focusVisible: "focusVisible-jXb33t",
|
|
1881
2402
|
invalid: "invalid-KfZYsG",
|
|
1882
2403
|
error: "error-j2vRdG"
|
|
1883
2404
|
};
|
|
@@ -1891,6 +2412,8 @@ const select_Select = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react__.forwar
|
|
|
1891
2412
|
const firstValue = options[0]?.value ?? "";
|
|
1892
2413
|
const [uncontrolled, setUncontrolled] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(defaultValue ?? firstValue);
|
|
1893
2414
|
const value = isControlled ? valueProp ?? firstValue : uncontrolled;
|
|
2415
|
+
const [isFocusVisible, setIsFocusVisible] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(false);
|
|
2416
|
+
const pointerDown = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)(false);
|
|
1894
2417
|
const hasPlaceholder = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>Boolean(placeholder && !options.some((o)=>"" === o.value)), [
|
|
1895
2418
|
options,
|
|
1896
2419
|
placeholder
|
|
@@ -1912,11 +2435,20 @@ const select_Select = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react__.forwar
|
|
|
1912
2435
|
className: [
|
|
1913
2436
|
select_module.select,
|
|
1914
2437
|
invalid ? select_module.invalid : null,
|
|
2438
|
+
isFocusVisible ? select_module.focusVisible : null,
|
|
1915
2439
|
className
|
|
1916
2440
|
].filter(Boolean).join(" "),
|
|
1917
2441
|
disabled: isDisabled,
|
|
1918
2442
|
id: controlId,
|
|
1919
2443
|
value: value,
|
|
2444
|
+
onPointerDown: ()=>{
|
|
2445
|
+
pointerDown.current = true;
|
|
2446
|
+
},
|
|
2447
|
+
onFocus: ()=>{
|
|
2448
|
+
if (!pointerDown.current) setIsFocusVisible(true);
|
|
2449
|
+
pointerDown.current = false;
|
|
2450
|
+
},
|
|
2451
|
+
onBlur: ()=>setIsFocusVisible(false),
|
|
1920
2452
|
onChange: (e)=>{
|
|
1921
2453
|
const next = e.target.value;
|
|
1922
2454
|
if (!isControlled) setUncontrolled(next);
|
|
@@ -1950,14 +2482,22 @@ const switch_module = {
|
|
|
1950
2482
|
input: "input-VfbfH9",
|
|
1951
2483
|
track: "track-Bj1t0E",
|
|
1952
2484
|
thumb: "thumb-HnOuup",
|
|
2485
|
+
description: "description-lsb4Km",
|
|
1953
2486
|
error: "error-MpcTPC"
|
|
1954
2487
|
};
|
|
1955
|
-
|
|
2488
|
+
const switch_Switch = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react__.forwardRef)(function({ label, description, isDisabled, isInvalid, isSelected, defaultSelected, errorMessage, onChange, id: idProp, ...props }, ref) {
|
|
1956
2489
|
const generatedId = (0, __WEBPACK_EXTERNAL_MODULE_react__.useId)();
|
|
1957
2490
|
const id = idProp ?? generatedId;
|
|
2491
|
+
const descriptionId = description ? `${id}-description` : void 0;
|
|
1958
2492
|
const errorId = errorMessage ? `${id}-error` : void 0;
|
|
1959
|
-
const
|
|
2493
|
+
const describedBy = [
|
|
2494
|
+
descriptionId,
|
|
2495
|
+
errorId
|
|
2496
|
+
].filter(Boolean).join(" ") || void 0;
|
|
1960
2497
|
const invalid = isInvalid || !!errorMessage;
|
|
2498
|
+
const isControlled = "boolean" == typeof isSelected;
|
|
2499
|
+
const [uncontrolledChecked, setUncontrolledChecked] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(defaultSelected ?? false);
|
|
2500
|
+
const ariaChecked = isControlled ? isSelected : uncontrolledChecked;
|
|
1961
2501
|
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("div", {
|
|
1962
2502
|
className: switch_module.root,
|
|
1963
2503
|
children: [
|
|
@@ -1966,15 +2506,19 @@ function Switch({ label, isDisabled, isInvalid, isSelected, defaultSelected, err
|
|
|
1966
2506
|
children: [
|
|
1967
2507
|
/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("input", {
|
|
1968
2508
|
...props,
|
|
2509
|
+
ref: ref,
|
|
1969
2510
|
"aria-checked": ariaChecked,
|
|
1970
|
-
"aria-describedby":
|
|
2511
|
+
"aria-describedby": describedBy,
|
|
1971
2512
|
"aria-invalid": invalid || void 0,
|
|
1972
2513
|
checked: isSelected,
|
|
1973
2514
|
className: switch_module.input,
|
|
1974
2515
|
defaultChecked: defaultSelected,
|
|
1975
2516
|
disabled: isDisabled,
|
|
1976
2517
|
id: id,
|
|
1977
|
-
onChange: (e)=>
|
|
2518
|
+
onChange: (e)=>{
|
|
2519
|
+
if (!isControlled) setUncontrolledChecked(e.target.checked);
|
|
2520
|
+
onChange?.(e.target.checked);
|
|
2521
|
+
},
|
|
1978
2522
|
role: "switch",
|
|
1979
2523
|
type: "checkbox"
|
|
1980
2524
|
}),
|
|
@@ -1984,8 +2528,17 @@ function Switch({ label, isDisabled, isInvalid, isSelected, defaultSelected, err
|
|
|
1984
2528
|
className: switch_module.thumb
|
|
1985
2529
|
})
|
|
1986
2530
|
}),
|
|
1987
|
-
label ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.
|
|
1988
|
-
children:
|
|
2531
|
+
label || description ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("span", {
|
|
2532
|
+
children: [
|
|
2533
|
+
label ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("span", {
|
|
2534
|
+
children: label
|
|
2535
|
+
}) : null,
|
|
2536
|
+
description ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("span", {
|
|
2537
|
+
className: switch_module.description,
|
|
2538
|
+
id: descriptionId,
|
|
2539
|
+
children: description
|
|
2540
|
+
}) : null
|
|
2541
|
+
]
|
|
1989
2542
|
}) : null
|
|
1990
2543
|
]
|
|
1991
2544
|
}),
|
|
@@ -1996,7 +2549,7 @@ function Switch({ label, isDisabled, isInvalid, isSelected, defaultSelected, err
|
|
|
1996
2549
|
}) : null
|
|
1997
2550
|
]
|
|
1998
2551
|
});
|
|
1999
|
-
}
|
|
2552
|
+
});
|
|
2000
2553
|
const text_field_module = {
|
|
2001
2554
|
root: "root-EDj_sz",
|
|
2002
2555
|
label: "label-S2rwc9",
|
|
@@ -2084,7 +2637,7 @@ const text_area_TextArea = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react__.f
|
|
|
2084
2637
|
]
|
|
2085
2638
|
});
|
|
2086
2639
|
});
|
|
2087
|
-
|
|
2640
|
+
const text_field_TextField = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react__.forwardRef)(function({ className, description, errorMessage, id: idProp, isDisabled, isInvalid, label, onChange, ...props }, ref) {
|
|
2088
2641
|
const generatedId = (0, __WEBPACK_EXTERNAL_MODULE_react__.useId)();
|
|
2089
2642
|
const id = idProp ?? generatedId;
|
|
2090
2643
|
const descriptionId = description ? `${id}-description` : void 0;
|
|
@@ -2104,6 +2657,7 @@ function TextField({ className, description, errorMessage, id: idProp, isDisable
|
|
|
2104
2657
|
}) : null,
|
|
2105
2658
|
/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("input", {
|
|
2106
2659
|
...props,
|
|
2660
|
+
ref: ref,
|
|
2107
2661
|
"aria-describedby": describedBy,
|
|
2108
2662
|
"aria-invalid": invalid || void 0,
|
|
2109
2663
|
className: [
|
|
@@ -2127,7 +2681,7 @@ function TextField({ className, description, errorMessage, id: idProp, isDisable
|
|
|
2127
2681
|
}) : null
|
|
2128
2682
|
]
|
|
2129
2683
|
});
|
|
2130
|
-
}
|
|
2684
|
+
});
|
|
2131
2685
|
function resolveTrack(value) {
|
|
2132
2686
|
if ("number" == typeof value) return `repeat(${value}, 1fr)`;
|
|
2133
2687
|
if (Array.isArray(value)) return value.join(" ");
|
|
@@ -2242,10 +2796,10 @@ function Ox0Provider({ children, colorScheme, density, locale, messages, navigat
|
|
|
2242
2796
|
const routerValue = navigate ? {
|
|
2243
2797
|
navigate
|
|
2244
2798
|
} : null;
|
|
2245
|
-
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2799
|
+
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__ox0_i18n_ad8e896a__.Ox0I18nProvider, {
|
|
2800
|
+
locale: locale,
|
|
2801
|
+
messages: messages,
|
|
2802
|
+
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(ToastProvider, {
|
|
2249
2803
|
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(RouterContext.Provider, {
|
|
2250
2804
|
value: routerValue,
|
|
2251
2805
|
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)("div", {
|
|
@@ -2263,4 +2817,4 @@ function Ox0Provider({ children, colorScheme, density, locale, messages, navigat
|
|
|
2263
2817
|
})
|
|
2264
2818
|
});
|
|
2265
2819
|
}
|
|
2266
|
-
export { Accordion, AccordionHeader, AccordionItem, AccordionPanel, badge_Badge as Badge, banner_Banner as Banner, box_Box as Box, button_Button as Button, button_group_ButtonGroup as ButtonGroup, caption_Caption as Caption, card_Card as Card, Checkbox, code_Code as Code, code_block_CodeBlock as CodeBlock, Dialog, disclosure_triangle_DisclosureTriangle as DisclosureTriangle, divider_Divider as Divider, grid_Grid as Grid, heading_Heading as Heading, IconButton, icon_label_IconLabel as IconLabel, inline_Inline as Inline, keyboard_Keyboard as Keyboard, label_Label as Label, link_Link as Link, numeric_Numeric as Numeric, Ox0Provider, Popover, select_Select as Select, spinner_Spinner as Spinner, split_Split as Split, stack_Stack as Stack, surface_Surface as Surface, Switch, text_Text as Text, text_area_TextArea as TextArea, TextField, ToastProvider, Tooltip, createTextStyles,
|
|
2820
|
+
export { Accordion, AccordionHeader, AccordionItem, AccordionPanel, badge_Badge as Badge, banner_Banner as Banner, box_Box as Box, button_Button as Button, button_group_ButtonGroup as ButtonGroup, caption_Caption as Caption, card_Card as Card, checkbox_Checkbox as Checkbox, code_Code as Code, code_block_CodeBlock as CodeBlock, Dialog, disclosure_triangle_DisclosureTriangle as DisclosureTriangle, divider_Divider as Divider, grid_Grid as Grid, heading_Heading as Heading, icon_button_IconButton as IconButton, icon_label_IconLabel as IconLabel, inline_Inline as Inline, keyboard_Keyboard as Keyboard, label_Label as Label, link_Link as Link, Menu, numeric_Numeric as Numeric, Ox0Provider, Popover, select_Select as Select, spinner_Spinner as Spinner, split_Split as Split, stack_Stack as Stack, surface_Surface as Surface, switch_Switch as Switch, text_Text as Text, text_area_TextArea as TextArea, text_field_TextField as TextField, ToastProvider, Tooltip, createTextStyles, defaultUiMessages, useBorders, useFlexItem, useGridItem, usePlacement, useSizing, useSpacing, useSurface, useToast };
|