@kjun-ui/react 0.12.0 → 0.12.2
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/dist/index.cjs
CHANGED
|
@@ -432,19 +432,25 @@ function usePopupFocusGuard(trigger) {
|
|
|
432
432
|
function currentFocus() {
|
|
433
433
|
return typeof document === "undefined" ? null : document.activeElement;
|
|
434
434
|
}
|
|
435
|
+
function domElement(target) {
|
|
436
|
+
const node = target;
|
|
437
|
+
return typeof (node == null ? void 0 : node.matches) === "function" && typeof node.closest === "function" && typeof node.querySelector === "function";
|
|
438
|
+
}
|
|
435
439
|
function focusTrigger(target) {
|
|
436
|
-
if (
|
|
440
|
+
if (domElement(target)) {
|
|
437
441
|
return target.matches("button,input,[href],[tabindex]") ? target : target.querySelector("button,input,[href],[tabindex]") || target;
|
|
438
442
|
}
|
|
439
443
|
return target;
|
|
440
444
|
}
|
|
445
|
+
function isRestorableFocus(item) {
|
|
446
|
+
return (item == null ? void 0 : item.isConnected) !== false && !(domElement(item) && item.closest("[inert]"));
|
|
447
|
+
}
|
|
441
448
|
function restoreFocus(target, state, id, fallback2) {
|
|
442
|
-
const usable = (item) => (item == null ? void 0 : item.isConnected) !== false && !(typeof HTMLElement !== "undefined" && item instanceof HTMLElement && item.closest("[inert]"));
|
|
443
449
|
const restore = () => {
|
|
444
450
|
var _a, _b, _c, _d, _e;
|
|
445
451
|
if (state.entries.has(id)) return;
|
|
446
|
-
if (
|
|
447
|
-
else if (fallback2 && fallback2 !== target &&
|
|
452
|
+
if (isRestorableFocus(target)) (_a = target == null ? void 0 : target.focus) == null ? void 0 : _a.call(target, { preventScroll: true });
|
|
453
|
+
else if (fallback2 && fallback2 !== target && isRestorableFocus(fallback2)) (_b = fallback2.focus) == null ? void 0 : _b.call(fallback2, { preventScroll: true });
|
|
448
454
|
else (_e = (_d = (_c = state.topWindow()) == null ? void 0 : _c.root) == null ? void 0 : _d.focus) == null ? void 0 : _e.call(_d, { preventScroll: true });
|
|
449
455
|
};
|
|
450
456
|
if (typeof requestAnimationFrame !== "undefined") requestAnimationFrame(restore);
|
package/dist/index.js
CHANGED
|
@@ -315,19 +315,25 @@ function usePopupFocusGuard(trigger) {
|
|
|
315
315
|
function currentFocus() {
|
|
316
316
|
return typeof document === "undefined" ? null : document.activeElement;
|
|
317
317
|
}
|
|
318
|
+
function domElement(target) {
|
|
319
|
+
const node = target;
|
|
320
|
+
return typeof (node == null ? void 0 : node.matches) === "function" && typeof node.closest === "function" && typeof node.querySelector === "function";
|
|
321
|
+
}
|
|
318
322
|
function focusTrigger(target) {
|
|
319
|
-
if (
|
|
323
|
+
if (domElement(target)) {
|
|
320
324
|
return target.matches("button,input,[href],[tabindex]") ? target : target.querySelector("button,input,[href],[tabindex]") || target;
|
|
321
325
|
}
|
|
322
326
|
return target;
|
|
323
327
|
}
|
|
328
|
+
function isRestorableFocus(item) {
|
|
329
|
+
return (item == null ? void 0 : item.isConnected) !== false && !(domElement(item) && item.closest("[inert]"));
|
|
330
|
+
}
|
|
324
331
|
function restoreFocus(target, state, id, fallback2) {
|
|
325
|
-
const usable = (item) => (item == null ? void 0 : item.isConnected) !== false && !(typeof HTMLElement !== "undefined" && item instanceof HTMLElement && item.closest("[inert]"));
|
|
326
332
|
const restore = () => {
|
|
327
333
|
var _a, _b, _c, _d, _e;
|
|
328
334
|
if (state.entries.has(id)) return;
|
|
329
|
-
if (
|
|
330
|
-
else if (fallback2 && fallback2 !== target &&
|
|
335
|
+
if (isRestorableFocus(target)) (_a = target == null ? void 0 : target.focus) == null ? void 0 : _a.call(target, { preventScroll: true });
|
|
336
|
+
else if (fallback2 && fallback2 !== target && isRestorableFocus(fallback2)) (_b = fallback2.focus) == null ? void 0 : _b.call(fallback2, { preventScroll: true });
|
|
331
337
|
else (_e = (_d = (_c = state.topWindow()) == null ? void 0 : _c.root) == null ? void 0 : _d.focus) == null ? void 0 : _e.call(_d, { preventScroll: true });
|
|
332
338
|
};
|
|
333
339
|
if (typeof requestAnimationFrame !== "undefined") requestAnimationFrame(restore);
|
|
@@ -35,6 +35,7 @@ export declare function usePopupFocusGuard(trigger: {
|
|
|
35
35
|
};
|
|
36
36
|
export declare function useActiveLayerScope(): boolean;
|
|
37
37
|
export declare function focusTrigger(target: FocusTarget | null | undefined): FocusTarget | HTMLElement | null | undefined;
|
|
38
|
+
export declare function isRestorableFocus(item: FocusTarget | null | undefined): boolean;
|
|
38
39
|
export declare function useLayer(open: boolean, present: boolean, kind: LayerKind, close: () => void, trigger?: {
|
|
39
40
|
current: FocusTarget | null;
|
|
40
41
|
}, returnFocus?: () => FocusTarget | null | false | undefined): {
|
|
@@ -35,6 +35,7 @@ export declare function usePopupFocusGuard(trigger: {
|
|
|
35
35
|
};
|
|
36
36
|
export declare function useActiveLayerScope(): boolean;
|
|
37
37
|
export declare function focusTrigger(target: FocusTarget | null | undefined): FocusTarget | HTMLElement | null | undefined;
|
|
38
|
+
export declare function isRestorableFocus(item: FocusTarget | null | undefined): boolean;
|
|
38
39
|
export declare function useLayer(open: boolean, present: boolean, kind: LayerKind, close: () => void, trigger?: {
|
|
39
40
|
current: FocusTarget | null;
|
|
40
41
|
}, returnFocus?: () => FocusTarget | null | false | undefined): {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kjun-ui/react",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"homepage": "https://ui.kjun.dev",
|
|
6
6
|
"repository": {
|
|
@@ -41,9 +41,9 @@
|
|
|
41
41
|
"./package.json": "./package.json"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@kjun-ui/tokens": "0.12.
|
|
44
|
+
"@kjun-ui/tokens": "0.12.2",
|
|
45
45
|
"react-aria-components": "1.21.1",
|
|
46
|
-
"@kjun-ui/icons": "0.12.
|
|
46
|
+
"@kjun-ui/icons": "0.12.2"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
49
|
"react": "^19.2.3",
|