se-design 1.0.73-dev2 → 1.0.73-dev3
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/components/CustomModal/index.d.ts +18 -0
- package/dist/components/Modal/index.d.ts +1 -0
- package/dist/index11.js +53 -38
- package/dist/index11.js.map +1 -1
- package/dist/index12.js.map +1 -1
- package/dist/index15.js +1 -1
- package/dist/index18.js +1 -1
- package/dist/index188.js +5 -5
- package/dist/index192.js +43 -0
- package/dist/index192.js.map +1 -0
- package/dist/{index194.js → index195.js} +1 -1
- package/dist/{index194.js.map → index195.js.map} +1 -1
- package/dist/{index196.js → index197.js} +3 -3
- package/dist/{index196.js.map → index197.js.map} +1 -1
- package/dist/{index198.js → index199.js} +1 -1
- package/dist/{index198.js.map → index199.js.map} +1 -1
- package/dist/{index206.js → index207.js} +1 -1
- package/dist/{index206.js.map → index207.js.map} +1 -1
- package/dist/{index214.js → index215.js} +1 -1
- package/dist/{index214.js.map → index215.js.map} +1 -1
- package/dist/{index217.js → index218.js} +1 -1
- package/dist/{index217.js.map → index218.js.map} +1 -1
- package/dist/{index226.js → index227.js} +1 -1
- package/dist/{index226.js.map → index227.js.map} +1 -1
- package/dist/index229.js +57 -20
- package/dist/index229.js.map +1 -1
- package/dist/index230.js +20 -52
- package/dist/index230.js.map +1 -1
- package/dist/index231.js +51 -16
- package/dist/index231.js.map +1 -1
- package/dist/index232.js +18 -9
- package/dist/index232.js.map +1 -1
- package/dist/index233.js +9 -9
- package/dist/index233.js.map +1 -1
- package/dist/index234.js +9 -4
- package/dist/index234.js.map +1 -1
- package/dist/index235.js +5 -170
- package/dist/index235.js.map +1 -1
- package/dist/index236.js +170 -11
- package/dist/index236.js.map +1 -1
- package/dist/index237.js +11 -6
- package/dist/index237.js.map +1 -1
- package/dist/index238.js +5 -5
- package/dist/index238.js.map +1 -1
- package/dist/index239.js +5 -37
- package/dist/index239.js.map +1 -1
- package/dist/index24.js +1 -1
- package/dist/index240.js +38 -2
- package/dist/index240.js.map +1 -1
- package/dist/index241.js +2 -8
- package/dist/index241.js.map +1 -1
- package/dist/index242.js +7 -326
- package/dist/index242.js.map +1 -1
- package/dist/index243.js +324 -47
- package/dist/index243.js.map +1 -1
- package/dist/index244.js +50 -2
- package/dist/index244.js.map +1 -1
- package/dist/index245.js +2 -76
- package/dist/index245.js.map +1 -1
- package/dist/index246.js +65 -82
- package/dist/index246.js.map +1 -1
- package/dist/index247.js +89 -48
- package/dist/index247.js.map +1 -1
- package/dist/index248.js +51 -7
- package/dist/index248.js.map +1 -1
- package/dist/index249.js +7 -4
- package/dist/index249.js.map +1 -1
- package/dist/index250.js +4 -51
- package/dist/index250.js.map +1 -1
- package/dist/index251.js +52 -2
- package/dist/index251.js.map +1 -1
- package/dist/index252.js +2 -2
- package/dist/index253.js +5 -0
- package/dist/index253.js.map +1 -0
- package/dist/index27.js +1 -1
- package/dist/index37.js +1 -1
- package/dist/index39.js +1 -1
- package/dist/index44.js +1 -1
- package/dist/index45.js +2 -2
- package/dist/index48.js +1 -1
- package/dist/index52.js +1 -1
- package/dist/index62.js +1 -1
- package/dist/index64.js +1 -1
- package/package.json +1 -1
- package/dist/index228.js +0 -62
- package/dist/index228.js.map +0 -1
package/dist/index251.js
CHANGED
|
@@ -1,5 +1,55 @@
|
|
|
1
|
-
|
|
1
|
+
import { __require as E } from "./index249.js";
|
|
2
|
+
import { __require as _ } from "./index250.js";
|
|
3
|
+
var f, v;
|
|
4
|
+
function P() {
|
|
5
|
+
if (v) return f;
|
|
6
|
+
v = 1;
|
|
7
|
+
var o = function() {
|
|
8
|
+
};
|
|
9
|
+
if (process.env.NODE_ENV !== "production") {
|
|
10
|
+
var y = E(), t = {}, d = _();
|
|
11
|
+
o = function(n) {
|
|
12
|
+
var a = "Warning: " + n;
|
|
13
|
+
typeof console < "u" && console.error(a);
|
|
14
|
+
try {
|
|
15
|
+
throw new Error(a);
|
|
16
|
+
} catch {
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function u(n, a, i, s, c) {
|
|
21
|
+
if (process.env.NODE_ENV !== "production") {
|
|
22
|
+
for (var e in n)
|
|
23
|
+
if (d(n, e)) {
|
|
24
|
+
var r;
|
|
25
|
+
try {
|
|
26
|
+
if (typeof n[e] != "function") {
|
|
27
|
+
var h = Error(
|
|
28
|
+
(s || "React class") + ": " + i + " type `" + e + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof n[e] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`."
|
|
29
|
+
);
|
|
30
|
+
throw h.name = "Invariant Violation", h;
|
|
31
|
+
}
|
|
32
|
+
r = n[e](a, e, s, i, null, y);
|
|
33
|
+
} catch (l) {
|
|
34
|
+
r = l;
|
|
35
|
+
}
|
|
36
|
+
if (r && !(r instanceof Error) && o(
|
|
37
|
+
(s || "React class") + ": type specification of " + i + " `" + e + "` is invalid; the type checker function must return `null` or an `Error` but returned a " + typeof r + ". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."
|
|
38
|
+
), r instanceof Error && !(r.message in t)) {
|
|
39
|
+
t[r.message] = !0;
|
|
40
|
+
var p = c ? c() : "";
|
|
41
|
+
o(
|
|
42
|
+
"Failed " + i + " type: " + r.message + (p ?? "")
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return u.resetWarningCache = function() {
|
|
49
|
+
process.env.NODE_ENV !== "production" && (t = {});
|
|
50
|
+
}, f = u, f;
|
|
51
|
+
}
|
|
2
52
|
export {
|
|
3
|
-
|
|
53
|
+
P as __require
|
|
4
54
|
};
|
|
5
55
|
//# sourceMappingURL=index251.js.map
|
package/dist/index251.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index251.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
1
|
+
{"version":3,"file":"index251.js","sources":["../node_modules/prop-types/checkPropTypes.js"],"sourcesContent":["/**\n * Copyright (c) 2013-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\nvar printWarning = function() {};\n\nif (process.env.NODE_ENV !== 'production') {\n var ReactPropTypesSecret = require('./lib/ReactPropTypesSecret');\n var loggedTypeFailures = {};\n var has = require('./lib/has');\n\n printWarning = function(text) {\n var message = 'Warning: ' + text;\n if (typeof console !== 'undefined') {\n console.error(message);\n }\n try {\n // --- Welcome to debugging React ---\n // This error was thrown as a convenience so that you can use this stack\n // to find the callsite that caused this warning to fire.\n throw new Error(message);\n } catch (x) { /**/ }\n };\n}\n\n/**\n * Assert that the values match with the type specs.\n * Error messages are memorized and will only be shown once.\n *\n * @param {object} typeSpecs Map of name to a ReactPropType\n * @param {object} values Runtime values that need to be type-checked\n * @param {string} location e.g. \"prop\", \"context\", \"child context\"\n * @param {string} componentName Name of the component for error messages.\n * @param {?Function} getStack Returns the component stack.\n * @private\n */\nfunction checkPropTypes(typeSpecs, values, location, componentName, getStack) {\n if (process.env.NODE_ENV !== 'production') {\n for (var typeSpecName in typeSpecs) {\n if (has(typeSpecs, typeSpecName)) {\n var error;\n // Prop type validation may throw. In case they do, we don't want to\n // fail the render phase where it didn't fail before. So we log it.\n // After these have been cleaned up, we'll let them throw.\n try {\n // This is intentionally an invariant that gets caught. It's the same\n // behavior as without this statement except with a better message.\n if (typeof typeSpecs[typeSpecName] !== 'function') {\n var err = Error(\n (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +\n 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' +\n 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.'\n );\n err.name = 'Invariant Violation';\n throw err;\n }\n error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);\n } catch (ex) {\n error = ex;\n }\n if (error && !(error instanceof Error)) {\n printWarning(\n (componentName || 'React class') + ': type specification of ' +\n location + ' `' + typeSpecName + '` is invalid; the type checker ' +\n 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +\n 'You may have forgotten to pass an argument to the type checker ' +\n 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +\n 'shape all require an argument).'\n );\n }\n if (error instanceof Error && !(error.message in loggedTypeFailures)) {\n // Only monitor this failure once because there tends to be a lot of the\n // same error.\n loggedTypeFailures[error.message] = true;\n\n var stack = getStack ? getStack() : '';\n\n printWarning(\n 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')\n );\n }\n }\n }\n }\n}\n\n/**\n * Resets warning cache when testing.\n *\n * @private\n */\ncheckPropTypes.resetWarningCache = function() {\n if (process.env.NODE_ENV !== 'production') {\n loggedTypeFailures = {};\n }\n}\n\nmodule.exports = checkPropTypes;\n"],"names":["printWarning","ReactPropTypesSecret","require$$0","loggedTypeFailures","has","require$$1","text","message","checkPropTypes","typeSpecs","values","location","componentName","getStack","typeSpecName","error","err","ex","stack","checkPropTypes_1"],"mappings":";;;;;;AASA,MAAIA,IAAe,WAAW;AAAA,EAAA;AAE9B,MAAI,QAAQ,IAAI,aAAa,cAAc;AACzC,QAAIC,IAAuBC,EAAA,GACvBC,IAAqB,CAAA,GACrBC,IAAMC,EAAA;AAEV,IAAAL,IAAe,SAASM,GAAM;AAC5B,UAAIC,IAAU,cAAcD;AAC5B,MAAI,OAAO,UAAY,OACrB,QAAQ,MAAMC,CAAO;AAEvB,UAAI;AAIF,cAAM,IAAI,MAAMA,CAAO;AAAA,MAC7B,QAAgB;AAAA,MAAA;AAAA,IAChB;AAAA,EACA;AAaA,WAASC,EAAeC,GAAWC,GAAQC,GAAUC,GAAeC,GAAU;AAC5E,QAAI,QAAQ,IAAI,aAAa;AAC3B,eAASC,KAAgBL;AACvB,YAAIL,EAAIK,GAAWK,CAAY,GAAG;AAChC,cAAIC;AAIJ,cAAI;AAGF,gBAAI,OAAON,EAAUK,CAAY,KAAM,YAAY;AACjD,kBAAIE,IAAM;AAAA,iBACPJ,KAAiB,iBAAiB,OAAOD,IAAW,YAAYG,IAAe,+FACC,OAAOL,EAAUK,CAAY,IAAI;AAAA,cAEhI;AACY,oBAAAE,EAAI,OAAO,uBACLA;AAAA,YAClB;AACU,YAAAD,IAAQN,EAAUK,CAAY,EAAEJ,GAAQI,GAAcF,GAAeD,GAAU,MAAMV,CAAoB;AAAA,UACnH,SAAiBgB,GAAI;AACX,YAAAF,IAAQE;AAAA,UAClB;AAWQ,cAVIF,KAAS,EAAEA,aAAiB,UAC9Bf;AAAA,aACGY,KAAiB,iBAAiB,6BACnCD,IAAW,OAAOG,IAAe,6FAC6B,OAAOC,IAAQ;AAAA,UAIzF,GAEYA,aAAiB,SAAS,EAAEA,EAAM,WAAWZ,IAAqB;AAGpE,YAAAA,EAAmBY,EAAM,OAAO,IAAI;AAEpC,gBAAIG,IAAQL,IAAWA,EAAQ,IAAK;AAEpC,YAAAb;AAAA,cACE,YAAYW,IAAW,YAAYI,EAAM,WAAWG,KAAwB;AAAA,YACxF;AAAA,UACA;AAAA,QACA;AAAA;AAAA,EAGA;AAOA,SAAAV,EAAe,oBAAoB,WAAW;AAC5C,IAAI,QAAQ,IAAI,aAAa,iBAC3BL,IAAqB,CAAA;AAAA,EAEzB,GAEAgB,IAAiBX;;","x_google_ignoreList":[0]}
|
package/dist/index252.js
CHANGED
package/dist/index253.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index253.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
package/dist/index27.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import d, { useMemo as S, useRef as D, useEffect as c } from "react";
|
|
2
2
|
import { Icon as j } from "./index5.js";
|
|
3
3
|
import { getA11yNameAttributes as B } from "./index71.js";
|
|
4
|
-
import { useDismissOnEscape as M } from "./
|
|
4
|
+
import { useDismissOnEscape as M } from "./index199.js";
|
|
5
5
|
/* empty css */
|
|
6
6
|
function m() {
|
|
7
7
|
return m = Object.assign ? Object.assign.bind() : function(r) {
|
package/dist/index37.js
CHANGED
|
@@ -3,7 +3,7 @@ import { Popover as ve } from "./index18.js";
|
|
|
3
3
|
import { Icon as we } from "./index5.js";
|
|
4
4
|
import { Checkbox as Ee } from "./index22.js";
|
|
5
5
|
import { Button as G } from "./index3.js";
|
|
6
|
-
import { useCombobox as ke } from "./
|
|
6
|
+
import { useCombobox as ke } from "./index197.js";
|
|
7
7
|
import { useStableId as be } from "./index190.js";
|
|
8
8
|
/* empty css */
|
|
9
9
|
function g() {
|
package/dist/index39.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import a, { useState as d, useRef as $, useEffect as r, useMemo as D } from "react";
|
|
2
2
|
import { Icon as g } from "./index5.js";
|
|
3
3
|
import { LabelChip as F } from "./index10.js";
|
|
4
|
-
import { debounce as L } from "./
|
|
4
|
+
import { debounce as L } from "./index207.js";
|
|
5
5
|
/* empty css */
|
|
6
6
|
function z(p) {
|
|
7
7
|
const {
|
package/dist/index44.js
CHANGED
|
@@ -3,7 +3,7 @@ import e, { useState as S, useRef as k, useCallback as P, useEffect as Y } from
|
|
|
3
3
|
import { Icon as x } from "./index5.js";
|
|
4
4
|
import { useStableId as Z } from "./index190.js";
|
|
5
5
|
import { getA11yNameAttributes as L } from "./index71.js";
|
|
6
|
-
import { useCombobox as ee } from "./
|
|
6
|
+
import { useCombobox as ee } from "./index197.js";
|
|
7
7
|
function u() {
|
|
8
8
|
return u = Object.assign ? Object.assign.bind() : function(o) {
|
|
9
9
|
for (var s = 1; s < arguments.length; s++) {
|
package/dist/index45.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import t, { useState as m, useRef as h, useCallback as f, useEffect as x } from "react";
|
|
2
2
|
/* empty css */
|
|
3
|
-
import g from "./
|
|
3
|
+
import g from "./index215.js";
|
|
4
4
|
import { Icon as T } from "./index5.js";
|
|
5
5
|
import { useStableId as E } from "./index190.js";
|
|
6
6
|
import { getA11yNameAttributes as ce } from "./index71.js";
|
|
7
|
-
import { useCombobox as se } from "./
|
|
7
|
+
import { useCombobox as se } from "./index197.js";
|
|
8
8
|
function c() {
|
|
9
9
|
return c = Object.assign ? Object.assign.bind() : function(s) {
|
|
10
10
|
for (var i = 1; i < arguments.length; i++) {
|
package/dist/index48.js
CHANGED
|
@@ -28,7 +28,7 @@ import { Popover as $ } from "./index18.js";
|
|
|
28
28
|
/* empty css */
|
|
29
29
|
/* empty css */
|
|
30
30
|
/* empty css */
|
|
31
|
-
import { TabButton as j } from "./
|
|
31
|
+
import { TabButton as j } from "./index218.js";
|
|
32
32
|
/* empty css */
|
|
33
33
|
/* empty css */
|
|
34
34
|
/* empty css */
|
package/dist/index52.js
CHANGED
package/dist/index62.js
CHANGED
|
@@ -2,7 +2,7 @@ import F, { useState as ot, useRef as X, useEffect as $ } from "react";
|
|
|
2
2
|
import { createPortal as nt } from "react-dom";
|
|
3
3
|
import { Icon as it } from "./index5.js";
|
|
4
4
|
import { Button as rt } from "./index3.js";
|
|
5
|
-
import { debounce as lt } from "./
|
|
5
|
+
import { debounce as lt } from "./index207.js";
|
|
6
6
|
const q = 500, S = 50, U = 150, st = {
|
|
7
7
|
"top-left": {
|
|
8
8
|
rotate: "315",
|
package/dist/index64.js
CHANGED
|
@@ -4,7 +4,7 @@ import { Badge as J } from "./index9.js";
|
|
|
4
4
|
import { Icon as K } from "./index5.js";
|
|
5
5
|
import { Link as E } from "./index63.js";
|
|
6
6
|
import { CustomModal as O } from "./index12.js";
|
|
7
|
-
import { useFocusTrap as Q } from "./
|
|
7
|
+
import { useFocusTrap as Q } from "./index229.js";
|
|
8
8
|
import { useStableId as T } from "./index190.js";
|
|
9
9
|
/* empty css */
|
|
10
10
|
const U = {
|
package/package.json
CHANGED
package/dist/index228.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { useRef as E, useLayoutEffect as f } from "react";
|
|
2
|
-
import { getFirstFocusableElement as d, getFocusableElements as g } from "./index229.js";
|
|
3
|
-
function y(e, t) {
|
|
4
|
-
return t === "first" ? d({
|
|
5
|
-
container: e
|
|
6
|
-
}) || e : t === "container" ? e : typeof t == "string" ? e.querySelector(t) : t instanceof HTMLElement ? t : null;
|
|
7
|
-
}
|
|
8
|
-
function L({
|
|
9
|
-
enabled: e,
|
|
10
|
-
containerRef: t,
|
|
11
|
-
restoreFocus: i = !0,
|
|
12
|
-
initialFocus: l = "first"
|
|
13
|
-
}) {
|
|
14
|
-
const s = E(null), m = E(null);
|
|
15
|
-
return f(() => {
|
|
16
|
-
if (!e) {
|
|
17
|
-
i && s.current && requestAnimationFrame(() => {
|
|
18
|
-
s.current?.focus(), s.current = null;
|
|
19
|
-
});
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
const r = t.current;
|
|
23
|
-
r && (s.current = document.activeElement, requestAnimationFrame(() => {
|
|
24
|
-
y(r, l)?.focus();
|
|
25
|
-
}));
|
|
26
|
-
}, [e, t, i, l]), f(() => {
|
|
27
|
-
if (!e) return;
|
|
28
|
-
const r = t.current;
|
|
29
|
-
if (!r) return;
|
|
30
|
-
const c = (n) => {
|
|
31
|
-
if (n.key === "Tab") {
|
|
32
|
-
const u = g({
|
|
33
|
-
container: r
|
|
34
|
-
});
|
|
35
|
-
if (u.length === 0) {
|
|
36
|
-
n.preventDefault(), r.focus();
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
const o = u[0], a = u[u.length - 1], v = document.activeElement;
|
|
40
|
-
n.shiftKey && v === o ? (n.preventDefault(), a.focus()) : !n.shiftKey && v === a && (n.preventDefault(), o.focus());
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
return document.addEventListener("keydown", c, !0), () => document.removeEventListener("keydown", c, !0);
|
|
44
|
-
}, [e, t]), f(() => {
|
|
45
|
-
if (!e) return;
|
|
46
|
-
const r = t.current;
|
|
47
|
-
if (!r) return;
|
|
48
|
-
const c = (n) => {
|
|
49
|
-
const u = n.target;
|
|
50
|
-
r.contains(u) ? m.current = u : (m.current || d({
|
|
51
|
-
container: r
|
|
52
|
-
}) || r).focus();
|
|
53
|
-
};
|
|
54
|
-
return document.addEventListener("focusin", c, !0), () => document.removeEventListener("focusin", c, !0);
|
|
55
|
-
}, [e, t]), {
|
|
56
|
-
triggerRef: s
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
export {
|
|
60
|
-
L as useFocusTrap
|
|
61
|
-
};
|
|
62
|
-
//# sourceMappingURL=index228.js.map
|
package/dist/index228.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index228.js","sources":["../src/utils/a11y/useFocusTrap.ts"],"sourcesContent":["import { useLayoutEffect, useRef } from 'react';\nimport { getFocusableElements, getFirstFocusableElement } from './focusableElements';\n\nexport interface UseFocusTrapOptions<T extends HTMLElement = HTMLElement> {\n /**\n * Whether the focus trap is active.\n */\n enabled: boolean;\n /**\n * Container element ref to trap focus within.\n */\n containerRef: React.RefObject<T | null>;\n /**\n * Whether to restore focus to the element that had focus before trap activated.\n * Default: true\n */\n restoreFocus?: boolean;\n /**\n * Initial focus target when trap activates.\n * - 'first': Focus first focusable element (default)\n * - 'container': Focus the container itself\n * - CSS selector: Focus element matching selector\n * - HTMLElement: Focus this specific element\n */\n initialFocus?: 'first' | 'container' | string | HTMLElement;\n}\n\nexport interface UseFocusTrapReturn {\n /**\n * Ref to the element that had focus before trap activated.\n * Useful for manual focus restoration if needed.\n */\n triggerRef: React.MutableRefObject<HTMLElement | null>;\n}\n\n/**\n * Hook to trap focus within a container (for modals, dialogs, drawers).\n * \n * Implements WCAG 2.1 focus trap pattern:\n * - Moves focus into container on activation\n * - Wraps Tab/Shift+Tab navigation within container\n * - Restores focus to trigger element on deactivation\n * - Safety net: catches focus escaping via other means\n * \n * Note: For Escape key handling, use `useDismissOnEscape` hook separately.\n * This keeps focus trap (accessibility) separate from Escape handling (UX).\n * \n * @example\n * ```tsx\n * const MyModal = ({ isOpen, onClose }) => {\n * const containerRef = useRef<HTMLDivElement>(null);\n * \n * // Escape handling (UX)\n * useDismissOnEscape({\n * containerRef,\n * onDismiss: onClose,\n * enabled: isOpen\n * });\n * \n * // Focus trap (accessibility)\n * const { triggerRef } = useFocusTrap({\n * enabled: isOpen,\n * containerRef,\n * restoreFocus: true\n * });\n * \n * return (\n * <div ref={containerRef}>\n * <button>First</button>\n * <button>Second</button>\n * </div>\n * );\n * };\n * ```\n */\n/**\n * Resolve the initial focus target based on the initialFocus option.\n */\nfunction resolveInitialFocusTarget(\n container: HTMLElement,\n initialFocus: 'first' | 'container' | string | HTMLElement\n): HTMLElement | null {\n if (initialFocus === 'first') {\n return getFirstFocusableElement({ container }) || container;\n }\n if (initialFocus === 'container') {\n return container;\n }\n if (typeof initialFocus === 'string') {\n return container.querySelector<HTMLElement>(initialFocus);\n }\n if (initialFocus instanceof HTMLElement) {\n return initialFocus;\n }\n return null;\n}\n\nexport function useFocusTrap<T extends HTMLElement = HTMLElement>({\n enabled,\n containerRef,\n restoreFocus = true,\n initialFocus = 'first'\n}: UseFocusTrapOptions<T>): UseFocusTrapReturn {\n const triggerRef = useRef<HTMLElement | null>(null);\n const lastFocusedInContainer = useRef<HTMLElement | null>(null);\n\n // Focus management: save trigger, move focus into container on activate, restore on deactivate\n useLayoutEffect(() => {\n if (!enabled) {\n // Restore focus to trigger when trap deactivates\n if (restoreFocus && triggerRef.current) {\n requestAnimationFrame(() => {\n triggerRef.current?.focus();\n triggerRef.current = null;\n });\n }\n return;\n }\n\n const container = containerRef.current;\n if (!container) return;\n\n // Save the element that had focus before trap activated\n triggerRef.current = document.activeElement as HTMLElement;\n\n // Focus initial target\n requestAnimationFrame(() => {\n resolveInitialFocusTarget(container, initialFocus)?.focus();\n });\n }, [enabled, containerRef, restoreFocus, initialFocus]);\n\n // Focus trap: Tab wrapping (only when enabled)\n useLayoutEffect(() => {\n if (!enabled) return;\n \n const container = containerRef.current;\n if (!container) return;\n\n const handleKeyDown = (e: KeyboardEvent) => {\n // Tab wrapping\n if (e.key === 'Tab') {\n const focusables = getFocusableElements({ container });\n\n if (focusables.length === 0) {\n e.preventDefault();\n container.focus();\n return;\n }\n\n const first = focusables[0];\n const last = focusables[focusables.length - 1];\n const activeElement = document.activeElement;\n\n if (e.shiftKey && activeElement === first) {\n e.preventDefault();\n last.focus();\n } else if (!e.shiftKey && activeElement === last) {\n e.preventDefault();\n first.focus();\n }\n }\n };\n\n document.addEventListener('keydown', handleKeyDown, true);\n return () => document.removeEventListener('keydown', handleKeyDown, true);\n }, [enabled, containerRef]);\n\n // Focus trap safety net: catch focus escaping\n useLayoutEffect(() => {\n if (!enabled) return;\n \n const container = containerRef.current;\n if (!container) return;\n\n const handleFocusIn = (e: FocusEvent) => {\n const target = e.target as Node;\n \n if (container.contains(target)) {\n lastFocusedInContainer.current = target as HTMLElement;\n } else {\n // Focus escaped - redirect back\n const fallback = lastFocusedInContainer.current \n || getFirstFocusableElement({ container }) \n || container;\n fallback.focus();\n }\n };\n\n document.addEventListener('focusin', handleFocusIn, true);\n return () => document.removeEventListener('focusin', handleFocusIn, true);\n }, [enabled, containerRef]);\n\n return { triggerRef };\n}\n"],"names":["useRef","useLayoutEffect","getFirstFocusableElement","getFocusableElements","resolveInitialFocusTarget","container","initialFocus","querySelector","HTMLElement","useFocusTrap","enabled","containerRef","restoreFocus","triggerRef","lastFocusedInContainer","current","requestAnimationFrame","focus","document","activeElement","handleKeyDown","e","key","focusables","length","preventDefault","first","last","shiftKey","addEventListener","removeEventListener","handleFocusIn","target","contains"],"mappings":"AA8EA,SAAA,UAAAA,GAAA,mBAAAC,SAAA;AAAA,SAAA,4BAAAC,GAAA,wBAAAC,SAAA;AAAA,SAASC,EACPC,GACAC,GACoB;AACpB,SAAIA,MAAiB,UACZJ,EAAyB;AAAA,IAAEG,WAAAA;AAAAA,EAAAA,CAAW,KAAKA,IAEhDC,MAAiB,cACZD,IAEL,OAAO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