@ox0/ui 3.20.0 → 3.21.1
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog.d.ts","sourceRoot":"","sources":["../../src/components/dialog.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,SAAS,EAQf,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"dialog.d.ts","sourceRoot":"","sources":["../../src/components/dialog.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,SAAS,EAQf,MAAM,OAAO,CAAA;AAyBd,MAAM,MAAM,WAAW,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;AACnD,MAAM,MAAM,eAAe,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;AAEvD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;IAC7B,uEAAuE;IACvE,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAA;IAC9B,mFAAmF;IACnF,QAAQ,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAA;IACpC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;IACxB,8EAA8E;IAC9E,QAAQ,CAAC,SAAS,CAAC,EAAE,eAAe,GAAG,SAAS,CAAA;IAChD,QAAQ,CAAC,OAAO,EAAE,MAAM,IAAI,CAAA;IAC5B,oEAAoE;IACpE,QAAQ,CAAC,KAAK,CAAC,EAAE,WAAW,GAAG,SAAS,CAAA;CACzC;AAED,iBAAS,UAAU,CAAC,EAClB,QAAQ,EACR,iBAAiB,EACjB,WAAW,EACX,MAAM,EACN,SAAS,EACT,OAAO,EACP,KAAK,GACN,EAAE,WAAW,GAAG,SAAS,CAkGzB;AAID,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;CAC9B;AAED,iBAAS,YAAY,CAAC,EAAE,QAAQ,EAAE,EAAE,iBAAiB,GAAG,SAAS,CAEhE;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;CAC9B;AAED,iBAAS,WAAW,CAAC,EAAE,QAAQ,EAAE,EAAE,gBAAgB,GAAG,SAAS,CAO9D;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;CAC9B;AAED,iBAAS,UAAU,CAAC,EAAE,QAAQ,EAAE,EAAE,eAAe,GAAG,SAAS,CAE5D;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;CAC9B;AAED,iBAAS,YAAY,CAAC,EAAE,QAAQ,EAAE,EAAE,iBAAiB,GAAG,SAAS,CAEhE;AAID,eAAO,MAAM,MAAM;;;;;;CAMjB,CAAA"}
|
|
@@ -12,6 +12,7 @@ export interface DrawerProps {
|
|
|
12
12
|
* in normal layout flow — a flex sibling that grows/shrinks the space it occupies, pushing
|
|
13
13
|
* adjacent content rather than covering it. Pick "push" when the drawer lives beside content
|
|
14
14
|
* the user still needs (e.g. a data grid's row-detail panel); "overlay" for everything else.
|
|
15
|
+
* "overlay" keeps Tab inside the drawer, as a dialog does; "push" lets Tab move on to the page.
|
|
15
16
|
*/
|
|
16
17
|
readonly variant?: DrawerVariant;
|
|
17
18
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drawer.d.ts","sourceRoot":"","sources":["../../src/components/drawer.tsx"],"names":[],"mappings":"AAEA,OAAO,EAWL,KAAK,SAAS,EACf,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"drawer.d.ts","sourceRoot":"","sources":["../../src/components/drawer.tsx"],"names":[],"mappings":"AAEA,OAAO,EAWL,KAAK,SAAS,EACf,MAAM,OAAO,CAAA;AAgCd,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W,gBAAgB;IAC/B,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;CAC9B;AAED,iBAAS,WAAW,CAAC,EAAE,QAAQ,EAAE,EAAE,gBAAgB,GAAG,SAAS,CAO9D;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;CAC9B;AAED,iBAAS,UAAU,CAAC,EAAE,QAAQ,EAAE,EAAE,eAAe,GAAG,SAAS,CAE5D;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;CAC9B;AAED,iBAAS,YAAY,CAAC,EAAE,QAAQ,EAAE,EAAE,iBAAiB,GAAG,SAAS,CAEhE;AAID,eAAO,MAAM,MAAM;;;;;;CAMjB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focusable.d.ts","sourceRoot":"","sources":["../../src/components/focusable.ts"],"names":[],"mappings":"AASA,mEAAmE;AACnE,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,GAAG,WAAW,EAAE,CAItD"}
|
package/dist/index.js
CHANGED
|
@@ -2440,6 +2440,10 @@ label:hover > .control-TGnWDN[aria-invalid="true"]:not(:disabled) {
|
|
|
2440
2440
|
pointer-events: auto;
|
|
2441
2441
|
}
|
|
2442
2442
|
|
|
2443
|
+
.panel-DuK_1B:focus {
|
|
2444
|
+
outline: none;
|
|
2445
|
+
}
|
|
2446
|
+
|
|
2443
2447
|
.panel-DuK_1B[data-variant="overlay"][data-placement="right"] {
|
|
2444
2448
|
border-left: 1px solid var(--ox0-color-border);
|
|
2445
2449
|
}
|
|
@@ -7236,6 +7240,10 @@ function CalendarGlyph({ size = 16 }) {
|
|
|
7236
7240
|
]
|
|
7237
7241
|
});
|
|
7238
7242
|
}
|
|
7243
|
+
const FOCUSABLE_SELECTOR = "a[href], button:not([disabled]), input:not([disabled]):not([type='hidden']), select:not([disabled]), textarea:not([disabled]), [tabindex]";
|
|
7244
|
+
function tabbables(root) {
|
|
7245
|
+
return Array.from(root.querySelectorAll(FOCUSABLE_SELECTOR)).filter((el)=>el.tabIndex >= 0 && !el.closest("[inert]"));
|
|
7246
|
+
}
|
|
7239
7247
|
const stack = [];
|
|
7240
7248
|
function useLayer(isOpen) {
|
|
7241
7249
|
const layerRef = useRef({});
|
|
@@ -7341,6 +7349,32 @@ function DrawerRoot({ children, isOpen, onClose, placement = "right", variant =
|
|
|
7341
7349
|
onClose,
|
|
7342
7350
|
variant
|
|
7343
7351
|
]);
|
|
7352
|
+
const keyInsideRef = useRef(false);
|
|
7353
|
+
useEffect(()=>{
|
|
7354
|
+
if (!isOpen || "overlay" !== variant) return;
|
|
7355
|
+
const reset = ()=>{
|
|
7356
|
+
keyInsideRef.current = false;
|
|
7357
|
+
};
|
|
7358
|
+
const handler = (e)=>{
|
|
7359
|
+
const keyInside = keyInsideRef.current;
|
|
7360
|
+
keyInsideRef.current = false;
|
|
7361
|
+
const panel = panelRef.current;
|
|
7362
|
+
if ("Tab" !== e.key || keyInside || e.defaultPrevented || !panel || !isTopLayer()) return;
|
|
7363
|
+
e.preventDefault();
|
|
7364
|
+
const focusable = tabbables(panel);
|
|
7365
|
+
((e.shiftKey ? focusable.at(-1) : focusable[0]) ?? panel).focus();
|
|
7366
|
+
};
|
|
7367
|
+
document.addEventListener("keydown", reset, true);
|
|
7368
|
+
document.addEventListener("keydown", handler);
|
|
7369
|
+
return ()=>{
|
|
7370
|
+
document.removeEventListener("keydown", reset, true);
|
|
7371
|
+
document.removeEventListener("keydown", handler);
|
|
7372
|
+
};
|
|
7373
|
+
}, [
|
|
7374
|
+
isOpen,
|
|
7375
|
+
isTopLayer,
|
|
7376
|
+
variant
|
|
7377
|
+
]);
|
|
7344
7378
|
if ("closed" === phase) return null;
|
|
7345
7379
|
function clampWidth(next) {
|
|
7346
7380
|
return Math.min(maxWidth, Math.max(minWidth, next));
|
|
@@ -7373,6 +7407,23 @@ function DrawerRoot({ children, isOpen, onClose, placement = "right", variant =
|
|
|
7373
7407
|
setWidth(clampWidth(width + directionSign * KEYBOARD_RESIZE_STEP));
|
|
7374
7408
|
}
|
|
7375
7409
|
}
|
|
7410
|
+
function handlePanelKeyDown(event) {
|
|
7411
|
+
const panel = panelRef.current;
|
|
7412
|
+
if ("overlay" !== variant || "Tab" !== event.key || !panel || !isTopLayer()) return;
|
|
7413
|
+
const focusable = tabbables(panel);
|
|
7414
|
+
const first = focusable[0];
|
|
7415
|
+
const last = focusable.at(-1);
|
|
7416
|
+
const active = document.activeElement;
|
|
7417
|
+
if (first && last) {
|
|
7418
|
+
if (event.shiftKey && (active === first || active === panel)) {
|
|
7419
|
+
event.preventDefault();
|
|
7420
|
+
last.focus();
|
|
7421
|
+
} else if (!event.shiftKey && active === last) {
|
|
7422
|
+
event.preventDefault();
|
|
7423
|
+
first.focus();
|
|
7424
|
+
}
|
|
7425
|
+
} else event.preventDefault();
|
|
7426
|
+
}
|
|
7376
7427
|
const panelStyle = {
|
|
7377
7428
|
width,
|
|
7378
7429
|
"--ox0-drawer-width": `${width}px`
|
|
@@ -7387,6 +7438,11 @@ function DrawerRoot({ children, isOpen, onClose, placement = "right", variant =
|
|
|
7387
7438
|
"data-variant": variant,
|
|
7388
7439
|
ref: panelRef,
|
|
7389
7440
|
style: panelStyle,
|
|
7441
|
+
tabIndex: "overlay" === variant ? -1 : void 0,
|
|
7442
|
+
onKeyDown: handlePanelKeyDown,
|
|
7443
|
+
onKeyDownCapture: ()=>{
|
|
7444
|
+
keyInsideRef.current = true;
|
|
7445
|
+
},
|
|
7390
7446
|
onPointerDownCapture: ()=>{
|
|
7391
7447
|
pressedInsideRef.current = true;
|
|
7392
7448
|
},
|
|
@@ -9805,7 +9861,6 @@ dialog_module_options.domAPI = styleDomAPI_default();
|
|
|
9805
9861
|
dialog_module_options.insertStyleElement = insertStyleElement_default();
|
|
9806
9862
|
injectStylesIntoStyleTag_default()(dialog_module_0.A, dialog_module_options);
|
|
9807
9863
|
const dialog_module = dialog_module_0.A && dialog_module_0.A.locals ? dialog_module_0.A.locals : void 0;
|
|
9808
|
-
const FOCUSABLE_SELECTOR = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
9809
9864
|
const DialogContext = /*#__PURE__*/ createContext(null);
|
|
9810
9865
|
function useDialogContext() {
|
|
9811
9866
|
const ctx = useContext(DialogContext);
|
|
@@ -9835,7 +9890,7 @@ function DialogRoot({ children, isDismissDisabled, isEphemeral, isOpen, maxHeigh
|
|
|
9835
9890
|
const previouslyFocused = document.activeElement;
|
|
9836
9891
|
const el = dialogRef.current;
|
|
9837
9892
|
if (el) {
|
|
9838
|
-
const first = el
|
|
9893
|
+
const first = tabbables(el)[0];
|
|
9839
9894
|
(first ?? el).focus();
|
|
9840
9895
|
}
|
|
9841
9896
|
return ()=>{
|
|
@@ -9863,7 +9918,7 @@ function DialogRoot({ children, isDismissDisabled, isEphemeral, isOpen, maxHeigh
|
|
|
9863
9918
|
if (!isVisible) return null;
|
|
9864
9919
|
const handleKeyDown = (e)=>{
|
|
9865
9920
|
if ("Tab" !== e.key) return;
|
|
9866
|
-
const focusable =
|
|
9921
|
+
const focusable = dialogRef.current ? tabbables(dialogRef.current) : [];
|
|
9867
9922
|
if (0 === focusable.length) return;
|
|
9868
9923
|
const first = focusable[0];
|
|
9869
9924
|
const last = focusable[focusable.length - 1];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ox0/ui",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.21.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/esturcke/ox0-platform.git",
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"@internationalized/date": "^3.12.4",
|
|
26
26
|
"react-aria": "^3.53.1",
|
|
27
27
|
"react-stately": "^3.51.0",
|
|
28
|
-
"@ox0/hooks": "0.4.0",
|
|
29
28
|
"@ox0/i18n": "0.5.0",
|
|
30
|
-
"@ox0/
|
|
29
|
+
"@ox0/hooks": "0.4.0",
|
|
30
|
+
"@ox0/tokens": "0.8.1"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"react-intl": "^12.1.5"
|