@x-plat/design-system 0.20.0 → 0.21.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/dist/chunk-2EGVOUGV.cjs +93 -0
- package/dist/chunk-2T3BVV7R.js +0 -0
- package/dist/chunk-3FYYFDKQ.js +159 -0
- package/dist/chunk-3M3GFSHJ.js +67 -0
- package/dist/chunk-3WBHUFOA.cjs +48 -0
- package/dist/chunk-3XYYZQR5.cjs +22 -0
- package/dist/chunk-4EF7NVAL.js +67 -0
- package/dist/chunk-4ISERXK2.cjs +1 -0
- package/dist/chunk-4KYHHJ6Z.cjs +250 -0
- package/dist/chunk-4NSRDRXC.cjs +70 -0
- package/dist/chunk-4OXMRSVE.cjs +99 -0
- package/dist/chunk-55EPYLXN.js +30 -0
- package/dist/chunk-5CE3ADO5.js +254 -0
- package/dist/chunk-5F6Y2JD6.cjs +1 -0
- package/dist/chunk-5FMTMXSP.cjs +127 -0
- package/dist/chunk-5POCKDDY.js +36 -0
- package/dist/chunk-5VDI56BV.js +33 -0
- package/dist/chunk-5WLBUPSK.js +77 -0
- package/dist/chunk-5WNNWQHD.cjs +272 -0
- package/dist/chunk-66STZB6I.cjs +404 -0
- package/dist/chunk-6AIKCZN7.js +1455 -0
- package/dist/chunk-6IUJJUVP.js +18 -0
- package/dist/chunk-6P2B3ZGP.js +79 -0
- package/dist/chunk-764ILIDG.cjs +22 -0
- package/dist/chunk-7B44DWC4.js +0 -0
- package/dist/chunk-7BE6ETFY.js +18 -0
- package/dist/chunk-7BSUS5A4.js +97 -0
- package/dist/chunk-7RPWCDEW.cjs +20 -0
- package/dist/chunk-7ULXHGLO.cjs +77 -0
- package/dist/chunk-7YOI5XOW.js +55 -0
- package/dist/chunk-AFVTM5CP.js +0 -0
- package/dist/chunk-AN2WSL3B.cjs +1 -0
- package/dist/chunk-AT5Y5GLS.cjs +118 -0
- package/dist/chunk-AWPO2FI7.js +404 -0
- package/dist/chunk-BGXHIDUR.js +103 -0
- package/dist/chunk-BPZXL5TP.js +99 -0
- package/dist/chunk-BRTS5GWV.js +275 -0
- package/dist/chunk-BS3MLZCK.cjs +97 -0
- package/dist/chunk-BSPYYE2U.js +36 -0
- package/dist/chunk-BWJAEB42.js +48 -0
- package/dist/chunk-C4RMTISI.cjs +18 -0
- package/dist/chunk-C6M4XVR7.cjs +36 -0
- package/dist/chunk-CGC4D5MP.cjs +89 -0
- package/dist/chunk-CIRQYSQW.js +70 -0
- package/dist/chunk-CLOTWJNP.cjs +310 -0
- package/dist/chunk-CS7ZY35M.cjs +49 -0
- package/dist/chunk-CUV4RLDE.js +89 -0
- package/dist/chunk-CZAMLFSE.cjs +275 -0
- package/dist/chunk-D7QZLJ3Z.cjs +18 -0
- package/dist/chunk-DMSAAZ3M.cjs +92 -0
- package/dist/chunk-DUIZC7VJ.cjs +36 -0
- package/dist/chunk-DVBF4BDH.js +43 -0
- package/dist/chunk-EETYMP6K.cjs +584 -0
- package/dist/chunk-EFQL7JPX.js +0 -0
- package/dist/chunk-EFU7IAF5.cjs +12 -0
- package/dist/chunk-F3M2H5EX.cjs +79 -0
- package/dist/chunk-F436V2SX.cjs +254 -0
- package/dist/chunk-F664X2OY.js +250 -0
- package/dist/chunk-FF7ELUQW.cjs +1 -0
- package/dist/chunk-G3HE4S3Q.cjs +296 -0
- package/dist/chunk-GOPD5KUK.js +23 -0
- package/dist/chunk-GYTB24V6.cjs +107 -0
- package/dist/chunk-GZ657SGO.js +310 -0
- package/dist/chunk-H2QN65L6.cjs +1 -0
- package/dist/chunk-H6WUT7CK.js +22 -0
- package/dist/chunk-H76OQ75T.js +49 -0
- package/dist/chunk-HA3XONYI.js +18 -0
- package/dist/chunk-HF3UFXEU.js +296 -0
- package/dist/chunk-HGA47QVV.cjs +55 -0
- package/dist/chunk-HHPPAMXF.cjs +674 -0
- package/dist/chunk-HLV2XIE2.cjs +385 -0
- package/dist/chunk-HNQGIL45.cjs +96 -0
- package/dist/chunk-HQ37R7T3.js +53 -0
- package/dist/chunk-HXUGW4RR.js +187 -0
- package/dist/chunk-HYPRLWD3.js +272 -0
- package/dist/chunk-I7TLJUTP.cjs +6 -0
- package/dist/chunk-ICTWDTKC.cjs +1 -0
- package/dist/chunk-IPYKHDP4.cjs +187 -0
- package/dist/chunk-IRKREQ2X.cjs +18 -0
- package/dist/chunk-IVJJBMRY.js +92 -0
- package/dist/chunk-JPVIVOFG.js +26 -0
- package/dist/chunk-JYNBNSNF.js +151 -0
- package/dist/chunk-JZC3BXAC.js +93 -0
- package/dist/chunk-K5XPQWXN.cjs +92 -0
- package/dist/chunk-KQ3GOMHL.js +31 -0
- package/dist/chunk-KUJH72U6.cjs +159 -0
- package/dist/chunk-KVUXLC6M.cjs +479 -0
- package/dist/chunk-KZOJN57Q.js +19 -0
- package/dist/chunk-L3XPL4NP.cjs +53 -0
- package/dist/chunk-LOEMSXYB.js +0 -0
- package/dist/chunk-LU4KBPNG.cjs +23 -0
- package/dist/chunk-MWWWPQDB.js +26 -0
- package/dist/chunk-NCBB3WUJ.js +562 -0
- package/dist/chunk-NGCZTZST.cjs +562 -0
- package/dist/chunk-NSDKALIS.cjs +67 -0
- package/dist/chunk-NZHCRLNB.cjs +26 -0
- package/dist/chunk-OL4NANHB.js +0 -0
- package/dist/chunk-OTJRNKLR.js +96 -0
- package/dist/chunk-OWWFKTSK.js +0 -0
- package/dist/chunk-P2E3PB62.cjs +99 -0
- package/dist/chunk-P2QVFR7S.js +20 -0
- package/dist/chunk-P6ZGIYY7.cjs +18 -0
- package/dist/chunk-PFGSJJRY.cjs +19 -0
- package/dist/chunk-PNIUW7AJ.cjs +32 -0
- package/dist/chunk-Q2M2ONGO.js +70 -0
- package/dist/chunk-Q4PGP5KE.cjs +562 -0
- package/dist/chunk-QAI2YQPY.cjs +51 -0
- package/dist/chunk-QCD7UEZ3.cjs +59 -0
- package/dist/chunk-QEZ4R3SK.js +6 -0
- package/dist/chunk-QKDCPM2D.cjs +23 -0
- package/dist/chunk-QRGG3V7W.cjs +59 -0
- package/dist/chunk-QURIHUEC.js +107 -0
- package/dist/chunk-QY742LWN.js +30 -0
- package/dist/chunk-QYMRGYTN.js +127 -0
- package/dist/chunk-RLKJ2RZG.js +23 -0
- package/dist/chunk-RRR5BUOM.cjs +30 -0
- package/dist/chunk-RU3FCVXM.cjs +1 -0
- package/dist/chunk-RYTDVTV2.js +32 -0
- package/dist/chunk-RYYGUYDE.js +92 -0
- package/dist/chunk-SGLP4U3Y.cjs +67 -0
- package/dist/chunk-SJC543ZK.js +71 -0
- package/dist/chunk-SLYQK4SC.js +20 -0
- package/dist/chunk-SMLCOMLS.js +2888 -0
- package/dist/chunk-SNMOPLMH.cjs +372 -0
- package/dist/chunk-TRJUJYW7.cjs +151 -0
- package/dist/chunk-TTY5PE3P.js +30 -0
- package/dist/chunk-TXARYG3J.js +22 -0
- package/dist/chunk-TYXJU4EF.js +18 -0
- package/dist/chunk-U3PC7FYZ.cjs +26 -0
- package/dist/chunk-U67JM2WL.cjs +34 -0
- package/dist/chunk-UARGO5UG.js +59 -0
- package/dist/chunk-UCYE3H3F.cjs +43 -0
- package/dist/chunk-UGEGN35F.js +118 -0
- package/dist/chunk-UHUA3GQC.cjs +30 -0
- package/dist/chunk-UJQN477L.js +59 -0
- package/dist/chunk-UMX7DTFZ.cjs +70 -0
- package/dist/chunk-UT42P54P.js +372 -0
- package/dist/chunk-V76ZRGHQ.cjs +1 -0
- package/dist/chunk-VCIK366Y.cjs +1455 -0
- package/dist/chunk-VMA74ABT.cjs +137 -0
- package/dist/chunk-VSA62N2O.js +12 -0
- package/dist/chunk-WDAFLVQK.js +479 -0
- package/dist/chunk-WHMLMAMO.js +674 -0
- package/dist/chunk-WNBLKKLM.js +0 -0
- package/dist/chunk-WQ2GY7F3.js +46 -0
- package/dist/chunk-WRLCCK3M.cjs +30 -0
- package/dist/chunk-WVCZIOLY.js +562 -0
- package/dist/chunk-WZLGJQLW.js +385 -0
- package/dist/chunk-XB6FEBK6.js +34 -0
- package/dist/chunk-XMERDSRE.js +75 -0
- package/dist/chunk-XMLFKZYY.js +137 -0
- package/dist/chunk-XMM52J3T.js +584 -0
- package/dist/chunk-XZ7C5CGB.cjs +103 -0
- package/dist/chunk-YGFBAOKX.js +51 -0
- package/dist/chunk-YIN552MF.cjs +20 -0
- package/dist/chunk-YLC42E65.cjs +31 -0
- package/dist/chunk-YOTXRYJL.cjs +46 -0
- package/dist/chunk-ZAUGJZK7.js +99 -0
- package/dist/chunk-ZIZOQTDG.cjs +75 -0
- package/dist/chunk-ZMSV5VZI.cjs +2888 -0
- package/dist/chunk-ZN6MLZAE.cjs +71 -0
- package/dist/chunk-ZNCT6HXA.cjs +33 -0
- package/dist/components/Accordion/index.cjs +5 -1036
- package/dist/components/Accordion/index.js +5 -999
- package/dist/components/Alert/index.cjs +4 -69
- package/dist/components/Alert/index.js +4 -42
- package/dist/components/AutoResizeTextArea/index.cjs +6 -260
- package/dist/components/AutoResizeTextArea/index.js +6 -223
- package/dist/components/Avatar/index.cjs +4 -65
- package/dist/components/Avatar/index.js +4 -38
- package/dist/components/Badge/index.cjs +6 -69
- package/dist/components/Badge/index.js +5 -40
- package/dist/components/Box/index.cjs +4 -58
- package/dist/components/Box/index.js +4 -31
- package/dist/components/Breadcrumb/index.cjs +4 -42
- package/dist/components/Breadcrumb/index.js +3 -14
- package/dist/components/Button/index.cjs +5 -65
- package/dist/components/Button/index.js +5 -38
- package/dist/components/Calendar/index.cjs +6 -1317
- package/dist/components/Calendar/index.js +10 -1281
- package/dist/components/CardTab/index.cjs +4 -120
- package/dist/components/CardTab/index.js +4 -83
- package/dist/components/Chart/index.cjs +5 -708
- package/dist/components/Chart/index.js +4 -670
- package/dist/components/ChatInput/index.cjs +9 -390
- package/dist/components/ChatInput/index.js +9 -353
- package/dist/components/CheckBox/index.cjs +20 -1125
- package/dist/components/CheckBox/index.js +17 -1095
- package/dist/components/Chip/index.cjs +5 -55
- package/dist/components/Chip/index.js +5 -28
- package/dist/components/DatePicker/index.cjs +16 -2136
- package/dist/components/DatePicker/index.js +19 -2099
- package/dist/components/Divider/index.cjs +4 -58
- package/dist/components/Divider/index.js +4 -31
- package/dist/components/Drawer/index.cjs +5 -190
- package/dist/components/Drawer/index.js +5 -153
- package/dist/components/Dropdown/index.cjs +7 -375
- package/dist/components/Dropdown/index.js +7 -338
- package/dist/components/Editor/index.cjs +6 -1486
- package/dist/components/Editor/index.css +53 -0
- package/dist/components/Editor/index.d.cts +13 -0
- package/dist/components/Editor/index.d.ts +13 -0
- package/dist/components/Editor/index.js +6 -1453
- package/dist/components/EmptyState/index.cjs +4 -42
- package/dist/components/EmptyState/index.js +3 -14
- package/dist/components/FieldMessage/index.cjs +7 -182
- package/dist/components/FieldMessage/index.js +8 -154
- package/dist/components/FileUpload/index.cjs +7 -1171
- package/dist/components/FileUpload/index.js +7 -1134
- package/dist/components/HtmlTypeWriter/index.cjs +3 -171
- package/dist/components/HtmlTypeWriter/index.js +3 -133
- package/dist/components/IconButton/index.cjs +4 -65
- package/dist/components/IconButton/index.js +4 -38
- package/dist/components/ImageSelector/index.cjs +8 -1214
- package/dist/components/ImageSelector/index.js +8 -1177
- package/dist/components/Input/index.cjs +7 -429
- package/dist/components/Input/index.js +8 -392
- package/dist/components/Link/index.cjs +4 -61
- package/dist/components/Link/index.js +4 -34
- package/dist/components/LinkButton/index.cjs +5 -61
- package/dist/components/LinkButton/index.js +5 -34
- package/dist/components/Modal/index.cjs +5 -190
- package/dist/components/Modal/index.js +5 -153
- package/dist/components/NotificationBadge/index.cjs +5 -68
- package/dist/components/NotificationBadge/index.js +5 -40
- package/dist/components/Pagination/index.cjs +6 -1034
- package/dist/components/Pagination/index.js +6 -1007
- package/dist/components/PopOver/index.cjs +7 -363
- package/dist/components/PopOver/index.js +7 -326
- package/dist/components/Progress/index.cjs +5 -84
- package/dist/components/Progress/index.js +5 -57
- package/dist/components/Radio/index.cjs +7 -274
- package/dist/components/Radio/index.js +8 -237
- package/dist/components/Select/index.cjs +10 -1577
- package/dist/components/Select/index.js +11 -1540
- package/dist/components/Skeleton/index.cjs +4 -71
- package/dist/components/Skeleton/index.js +4 -44
- package/dist/components/Spinner/index.cjs +5 -88
- package/dist/components/Spinner/index.js +5 -61
- package/dist/components/Stat/index.cjs +5 -81
- package/dist/components/Stat/index.js +5 -54
- package/dist/components/Steps/index.cjs +7 -968
- package/dist/components/Steps/index.js +7 -941
- package/dist/components/Swiper/index.cjs +4 -357
- package/dist/components/Swiper/index.js +4 -320
- package/dist/components/Switch/index.cjs +7 -252
- package/dist/components/Switch/index.js +7 -215
- package/dist/components/Tab/index.cjs +4 -144
- package/dist/components/Tab/index.js +4 -107
- package/dist/components/Table/index.cjs +4 -337
- package/dist/components/Table/index.js +8 -300
- package/dist/components/Tag/index.cjs +6 -969
- package/dist/components/Tag/index.js +6 -942
- package/dist/components/TextArea/index.cjs +6 -229
- package/dist/components/TextArea/index.js +6 -192
- package/dist/components/TimePicker/index.cjs +9 -579
- package/dist/components/TimePicker/index.js +9 -542
- package/dist/components/Toast/index.cjs +5 -146
- package/dist/components/Toast/index.js +5 -108
- package/dist/components/ToggleChip/index.cjs +5 -66
- package/dist/components/ToggleChip/index.js +5 -39
- package/dist/components/Tooltip/index.cjs +6 -204
- package/dist/components/Tooltip/index.js +6 -167
- package/dist/components/Tour/index.cjs +6 -414
- package/dist/components/Tour/index.js +6 -377
- package/dist/components/Video/index.cjs +7 -796
- package/dist/components/Video/index.js +7 -759
- package/dist/components/index.cjs +140 -8342
- package/dist/components/index.js +190 -8288
- package/dist/index.cjs +903 -13318
- package/dist/index.js +524 -12526
- package/dist/layout/Grid/FullGrid/index.cjs +4 -46
- package/dist/layout/Grid/FullGrid/index.js +3 -18
- package/dist/layout/Grid/FullScreen/index.cjs +4 -46
- package/dist/layout/Grid/FullScreen/index.js +3 -18
- package/dist/layout/Grid/Item/index.cjs +5 -68
- package/dist/layout/Grid/Item/index.js +5 -41
- package/dist/layout/Grid/index.cjs +14 -109
- package/dist/layout/Grid/index.js +14 -79
- package/dist/layout/Header/index.cjs +4 -44
- package/dist/layout/Header/index.js +3 -16
- package/dist/layout/Layout/index.cjs +4 -42
- package/dist/layout/Layout/index.js +3 -14
- package/dist/layout/SideBar/index.cjs +6 -96
- package/dist/layout/SideBar/index.js +6 -57
- package/dist/layout/index.cjs +38 -209
- package/dist/layout/index.js +27 -153
- package/dist/tokens/index.cjs +627 -6119
- package/dist/tokens/index.js +324 -5489
- package/guidelines/components/editor.md +3 -0
- package/guidelines/setup.md +7 -0
- package/package.json +6 -3
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var _chunkHGA47QVVcjs = require('./chunk-HGA47QVV.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _chunkPFGSJJRYcjs = require('./chunk-PFGSJJRY.cjs');
|
|
8
|
+
|
|
9
|
+
// src/components/AutoResizeTextArea/AutoResizeTextArea.tsx
|
|
10
|
+
var _react = require('react'); var _react2 = _interopRequireDefault(_react);
|
|
11
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
12
|
+
var MAX_HEIGHT = 400;
|
|
13
|
+
var AutoResizeTextArea = _react2.default.forwardRef(
|
|
14
|
+
(props, ref) => {
|
|
15
|
+
const { value, className, onChange, disabled, bare = false, validations, label, required, ...textareaProps } = props;
|
|
16
|
+
const autoId = _react2.default.useId();
|
|
17
|
+
const fieldId = _nullishCoalesce(props.id, () => ( autoId));
|
|
18
|
+
const localRef = _react2.default.useRef(null);
|
|
19
|
+
const setRefs = (el) => {
|
|
20
|
+
localRef.current = el;
|
|
21
|
+
if (!ref) return;
|
|
22
|
+
if (typeof ref === "function") ref(el);
|
|
23
|
+
else if (ref && "current" in ref)
|
|
24
|
+
ref.current = el;
|
|
25
|
+
};
|
|
26
|
+
const updateHeight = () => {
|
|
27
|
+
const el = localRef.current;
|
|
28
|
+
if (!el) return;
|
|
29
|
+
el.style.height = "0px";
|
|
30
|
+
el.style.height = `${Math.min(el.scrollHeight, MAX_HEIGHT)}px`;
|
|
31
|
+
};
|
|
32
|
+
const handleChange = (e) => {
|
|
33
|
+
if (onChange) {
|
|
34
|
+
const event = {
|
|
35
|
+
...e,
|
|
36
|
+
target: { value: e.target.value }
|
|
37
|
+
};
|
|
38
|
+
onChange(event);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
_react2.default.useEffect(() => {
|
|
42
|
+
updateHeight();
|
|
43
|
+
}, [value]);
|
|
44
|
+
if (bare) {
|
|
45
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
46
|
+
"textarea",
|
|
47
|
+
{
|
|
48
|
+
"aria-invalid": _chunkHGA47QVVcjs.hasError.call(void 0, validations) || void 0,
|
|
49
|
+
...textareaProps,
|
|
50
|
+
ref: setRefs,
|
|
51
|
+
id: fieldId,
|
|
52
|
+
className,
|
|
53
|
+
disabled,
|
|
54
|
+
value,
|
|
55
|
+
onChange: handleChange
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
const control = /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: _chunkPFGSJJRYcjs.clsx_default.call(void 0, "lib-xplat-auto-resize-textarea-wrapper", className), children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: _chunkPFGSJJRYcjs.clsx_default.call(void 0, "lib-xplat-auto-resize-textarea", disabled && "disabled"), children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
60
|
+
"textarea",
|
|
61
|
+
{
|
|
62
|
+
"aria-invalid": _chunkHGA47QVVcjs.hasError.call(void 0, validations) || void 0,
|
|
63
|
+
...textareaProps,
|
|
64
|
+
ref: setRefs,
|
|
65
|
+
id: fieldId,
|
|
66
|
+
disabled,
|
|
67
|
+
value,
|
|
68
|
+
onChange: handleChange
|
|
69
|
+
}
|
|
70
|
+
) }) });
|
|
71
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkHGA47QVVcjs.Field, { validations, label, required, htmlFor: fieldId, children: control });
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
AutoResizeTextArea.displayName = "AutoResizeTextArea";
|
|
75
|
+
var AutoResizeTextArea_default = AutoResizeTextArea;
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
exports.AutoResizeTextArea_default = AutoResizeTextArea_default;
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
var _chunkEFU7IAF5cjs = require('./chunk-EFU7IAF5.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
var _chunk4KYHHJ6Zcjs = require('./chunk-4KYHHJ6Z.cjs');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
var _chunkPFGSJJRYcjs = require('./chunk-PFGSJJRY.cjs');
|
|
12
|
+
|
|
13
|
+
// src/components/Tour/Tour.tsx
|
|
14
|
+
var _react = require('react'); var _react2 = _interopRequireDefault(_react);
|
|
15
|
+
|
|
16
|
+
// src/tokens/hooks/useScrollLock.ts
|
|
17
|
+
|
|
18
|
+
var SCROLL_KEYS = /* @__PURE__ */ new Set([
|
|
19
|
+
" ",
|
|
20
|
+
"PageUp",
|
|
21
|
+
"PageDown",
|
|
22
|
+
"Home",
|
|
23
|
+
"End",
|
|
24
|
+
"ArrowUp",
|
|
25
|
+
"ArrowDown",
|
|
26
|
+
"ArrowLeft",
|
|
27
|
+
"ArrowRight"
|
|
28
|
+
]);
|
|
29
|
+
var useScrollLock = (enabled, allowRef) => {
|
|
30
|
+
_react2.default.useEffect(() => {
|
|
31
|
+
if (!enabled) return;
|
|
32
|
+
const allowed = (target) => target instanceof Node && !!_optionalChain([allowRef, 'optionalAccess', _ => _.current, 'optionalAccess', _2 => _2.contains, 'call', _3 => _3(target)]);
|
|
33
|
+
const block = (e) => {
|
|
34
|
+
if (allowed(e.target)) return;
|
|
35
|
+
e.preventDefault();
|
|
36
|
+
};
|
|
37
|
+
const onKey = (e) => {
|
|
38
|
+
if (!SCROLL_KEYS.has(e.key)) return;
|
|
39
|
+
if (allowed(e.target)) return;
|
|
40
|
+
const el = e.target;
|
|
41
|
+
const tag = _optionalChain([el, 'optionalAccess', _4 => _4.tagName]);
|
|
42
|
+
if (tag === "INPUT" || tag === "TEXTAREA" || _optionalChain([el, 'optionalAccess', _5 => _5.isContentEditable])) return;
|
|
43
|
+
e.preventDefault();
|
|
44
|
+
};
|
|
45
|
+
const opts = { passive: false, capture: true };
|
|
46
|
+
window.addEventListener("wheel", block, opts);
|
|
47
|
+
window.addEventListener("touchmove", block, opts);
|
|
48
|
+
window.addEventListener("keydown", onKey, opts);
|
|
49
|
+
return () => {
|
|
50
|
+
window.removeEventListener("wheel", block, true);
|
|
51
|
+
window.removeEventListener("touchmove", block, true);
|
|
52
|
+
window.removeEventListener("keydown", onKey, true);
|
|
53
|
+
};
|
|
54
|
+
}, [enabled, allowRef]);
|
|
55
|
+
};
|
|
56
|
+
var useScrollLock_default = useScrollLock;
|
|
57
|
+
|
|
58
|
+
// src/components/Tour/Tour.tsx
|
|
59
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
60
|
+
var VIEWPORT_MARGIN = 16;
|
|
61
|
+
var DEFAULT_PADDING = 8;
|
|
62
|
+
var clamp = (v, min, max) => Math.max(min, Math.min(v, max));
|
|
63
|
+
var resolve = (target) => {
|
|
64
|
+
if (typeof target === "string") return document.querySelector(target);
|
|
65
|
+
return target.current;
|
|
66
|
+
};
|
|
67
|
+
var Tour = (props) => {
|
|
68
|
+
const {
|
|
69
|
+
open,
|
|
70
|
+
steps,
|
|
71
|
+
onClose,
|
|
72
|
+
current,
|
|
73
|
+
onStepChange,
|
|
74
|
+
width = 380,
|
|
75
|
+
nextLabel = "\uB2E4\uC74C",
|
|
76
|
+
prevLabel = "\uC774\uC804",
|
|
77
|
+
skipLabel = "\uAC74\uB108\uB6F0\uAE30",
|
|
78
|
+
doneLabel = "\uB2E4 \uBD24\uC5B4\uC694"
|
|
79
|
+
} = props;
|
|
80
|
+
const [uncontrolled, setUncontrolled] = _react2.default.useState(0);
|
|
81
|
+
const index = _nullishCoalesce(current, () => ( uncontrolled));
|
|
82
|
+
const step = steps[index];
|
|
83
|
+
const isLast = index === steps.length - 1;
|
|
84
|
+
const spotRef = _react2.default.useRef(null);
|
|
85
|
+
const cardRef = _react2.default.useRef(null);
|
|
86
|
+
const [targetFound, setTargetFound] = _react2.default.useState(true);
|
|
87
|
+
const goTo = _react2.default.useCallback(
|
|
88
|
+
(next) => {
|
|
89
|
+
if (current === void 0) setUncontrolled(next);
|
|
90
|
+
_optionalChain([onStepChange, 'optionalCall', _6 => _6(next)]);
|
|
91
|
+
},
|
|
92
|
+
[current, onStepChange]
|
|
93
|
+
);
|
|
94
|
+
_chunk4KYHHJ6Zcjs.useEscapeKey.call(void 0, open, () => onClose("skip"));
|
|
95
|
+
_chunk4KYHHJ6Zcjs.useFocusTrap.call(void 0, cardRef, open, { trap: true });
|
|
96
|
+
useScrollLock_default(open, cardRef);
|
|
97
|
+
const stepsRef = _react2.default.useRef(steps);
|
|
98
|
+
stepsRef.current = steps;
|
|
99
|
+
_react2.default.useEffect(() => {
|
|
100
|
+
if (!open) return;
|
|
101
|
+
const target = _optionalChain([stepsRef, 'access', _7 => _7.current, 'access', _8 => _8[index], 'optionalAccess', _9 => _9.target]);
|
|
102
|
+
if (!target) return;
|
|
103
|
+
let stop = false;
|
|
104
|
+
let tries = 0;
|
|
105
|
+
const look = () => {
|
|
106
|
+
if (stop) return;
|
|
107
|
+
const el = resolve(target);
|
|
108
|
+
if (el) {
|
|
109
|
+
setTargetFound(true);
|
|
110
|
+
el.scrollIntoView({ block: "center", inline: "nearest", behavior: "smooth" });
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
setTargetFound(false);
|
|
114
|
+
if (tries < 60) {
|
|
115
|
+
tries += 1;
|
|
116
|
+
requestAnimationFrame(look);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
look();
|
|
120
|
+
return () => {
|
|
121
|
+
stop = true;
|
|
122
|
+
};
|
|
123
|
+
}, [open, index]);
|
|
124
|
+
const place = _react2.default.useCallback(() => {
|
|
125
|
+
const spot = spotRef.current;
|
|
126
|
+
const card = cardRef.current;
|
|
127
|
+
if (!spot || !card || !step) return;
|
|
128
|
+
const el = resolve(step.target);
|
|
129
|
+
const pad = _nullishCoalesce(step.padding, () => ( DEFAULT_PADDING));
|
|
130
|
+
let hole;
|
|
131
|
+
if (el) {
|
|
132
|
+
const r = el.getBoundingClientRect();
|
|
133
|
+
hole = {
|
|
134
|
+
top: r.top - pad,
|
|
135
|
+
left: r.left - pad,
|
|
136
|
+
width: r.width + pad * 2,
|
|
137
|
+
height: r.height + pad * 2
|
|
138
|
+
};
|
|
139
|
+
spot.style.visibility = "visible";
|
|
140
|
+
} else {
|
|
141
|
+
hole = { top: window.innerHeight / 2, left: window.innerWidth / 2, width: 0, height: 0 };
|
|
142
|
+
spot.style.visibility = "hidden";
|
|
143
|
+
}
|
|
144
|
+
spot.style.top = `${hole.top}px`;
|
|
145
|
+
spot.style.left = `${hole.left}px`;
|
|
146
|
+
spot.style.width = `${hole.width}px`;
|
|
147
|
+
spot.style.height = `${hole.height}px`;
|
|
148
|
+
const placed = _chunk4KYHHJ6Zcjs.computePlacement.call(void 0,
|
|
149
|
+
{
|
|
150
|
+
top: hole.top,
|
|
151
|
+
bottom: hole.top + hole.height,
|
|
152
|
+
left: hole.left,
|
|
153
|
+
right: hole.left + hole.width
|
|
154
|
+
},
|
|
155
|
+
card.offsetWidth,
|
|
156
|
+
Math.max(card.offsetHeight, card.scrollHeight),
|
|
157
|
+
{
|
|
158
|
+
top: VIEWPORT_MARGIN,
|
|
159
|
+
bottom: window.innerHeight - VIEWPORT_MARGIN,
|
|
160
|
+
left: VIEWPORT_MARGIN,
|
|
161
|
+
right: window.innerWidth - VIEWPORT_MARGIN
|
|
162
|
+
}
|
|
163
|
+
);
|
|
164
|
+
const limit = window.innerHeight - VIEWPORT_MARGIN * 2;
|
|
165
|
+
const cardH = Math.min(card.scrollHeight, limit);
|
|
166
|
+
const cardW = card.offsetWidth;
|
|
167
|
+
card.style.maxHeight = `${limit}px`;
|
|
168
|
+
card.style.top = `${clamp(placed.top, VIEWPORT_MARGIN, window.innerHeight - VIEWPORT_MARGIN - cardH)}px`;
|
|
169
|
+
card.style.left = `${clamp(placed.left, VIEWPORT_MARGIN, window.innerWidth - VIEWPORT_MARGIN - cardW)}px`;
|
|
170
|
+
}, [step]);
|
|
171
|
+
_react2.default.useLayoutEffect(() => {
|
|
172
|
+
if (!open) return;
|
|
173
|
+
place();
|
|
174
|
+
let raf = 0;
|
|
175
|
+
let settled = 0;
|
|
176
|
+
let last = "";
|
|
177
|
+
const follow = () => {
|
|
178
|
+
const el = resolve(_nullishCoalesce(_optionalChain([stepsRef, 'access', _10 => _10.current, 'access', _11 => _11[index], 'optionalAccess', _12 => _12.target]), () => ( "")));
|
|
179
|
+
const now = el ? JSON.stringify(el.getBoundingClientRect()) : "";
|
|
180
|
+
settled = now === last ? settled + 1 : 0;
|
|
181
|
+
last = now;
|
|
182
|
+
place();
|
|
183
|
+
if (settled < 3) raf = requestAnimationFrame(follow);
|
|
184
|
+
};
|
|
185
|
+
raf = requestAnimationFrame(follow);
|
|
186
|
+
return () => cancelAnimationFrame(raf);
|
|
187
|
+
}, [open, index, place]);
|
|
188
|
+
_react2.default.useEffect(() => {
|
|
189
|
+
if (!open) return;
|
|
190
|
+
const onMove = () => place();
|
|
191
|
+
window.addEventListener("scroll", onMove, { passive: true, capture: true });
|
|
192
|
+
window.addEventListener("resize", onMove, { passive: true });
|
|
193
|
+
return () => {
|
|
194
|
+
window.removeEventListener("scroll", onMove, true);
|
|
195
|
+
window.removeEventListener("resize", onMove);
|
|
196
|
+
};
|
|
197
|
+
}, [open, place]);
|
|
198
|
+
if (!open || !step) return null;
|
|
199
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkEFU7IAF5cjs.Portal_default, { children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "lib-xplat-tour", role: "presentation", children: [
|
|
200
|
+
!targetFound && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "lib-xplat-tour-dim" }),
|
|
201
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { ref: spotRef, className: "lib-xplat-tour-spotlight", "aria-hidden": true }),
|
|
202
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
203
|
+
"div",
|
|
204
|
+
{
|
|
205
|
+
ref: cardRef,
|
|
206
|
+
className: "lib-xplat-tour-card",
|
|
207
|
+
style: { "--tour-card-width": typeof width === "number" ? `${width}px` : width },
|
|
208
|
+
role: "dialog",
|
|
209
|
+
"aria-modal": "true",
|
|
210
|
+
"aria-label": typeof step.title === "string" ? step.title : "\uD654\uBA74 \uC548\uB0B4",
|
|
211
|
+
children: [
|
|
212
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "tour-card-head", children: [
|
|
213
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "tour-card-progress", "aria-hidden": true, children: [
|
|
214
|
+
index + 1,
|
|
215
|
+
" / ",
|
|
216
|
+
steps.length
|
|
217
|
+
] }),
|
|
218
|
+
step.title && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tour-card-title", children: step.title })
|
|
219
|
+
] }),
|
|
220
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tour-card-body", children: step.description && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tour-card-description", children: step.description }) }),
|
|
221
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "tour-card-actions", children: [
|
|
222
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { type: "button", className: "tour-skip", onClick: () => onClose("skip"), children: skipLabel }),
|
|
223
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "tour-card-nav", children: [
|
|
224
|
+
index > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
225
|
+
"button",
|
|
226
|
+
{
|
|
227
|
+
type: "button",
|
|
228
|
+
className: _chunkPFGSJJRYcjs.clsx_default.call(void 0, "tour-nav", "secondary"),
|
|
229
|
+
onClick: () => goTo(index - 1),
|
|
230
|
+
children: prevLabel
|
|
231
|
+
}
|
|
232
|
+
),
|
|
233
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
234
|
+
"button",
|
|
235
|
+
{
|
|
236
|
+
type: "button",
|
|
237
|
+
className: _chunkPFGSJJRYcjs.clsx_default.call(void 0, "tour-nav", "primary"),
|
|
238
|
+
onClick: () => isLast ? onClose("done") : goTo(index + 1),
|
|
239
|
+
children: isLast ? doneLabel : nextLabel
|
|
240
|
+
}
|
|
241
|
+
)
|
|
242
|
+
] })
|
|
243
|
+
] })
|
|
244
|
+
]
|
|
245
|
+
}
|
|
246
|
+
)
|
|
247
|
+
] }) });
|
|
248
|
+
};
|
|
249
|
+
Tour.displayName = "Tour";
|
|
250
|
+
var Tour_default = Tour;
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
exports.Tour_default = Tour_default;
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
// src/tokens/hooks/useAutoPosition.ts
|
|
2
|
+
import React from "react";
|
|
3
|
+
var findScrollParent = (el) => {
|
|
4
|
+
for (let p = el.parentElement; p; p = p.parentElement) {
|
|
5
|
+
if (p.dataset.xplatOverlayEscape !== void 0) continue;
|
|
6
|
+
const { overflowY } = getComputedStyle(p);
|
|
7
|
+
if (!/(auto|scroll)/.test(overflowY)) continue;
|
|
8
|
+
if (p.scrollHeight > p.clientHeight) return p;
|
|
9
|
+
}
|
|
10
|
+
return null;
|
|
11
|
+
};
|
|
12
|
+
var TRIGGER_GAP = 8;
|
|
13
|
+
var computePlacement = (triggerRect, popW, popH, clip) => {
|
|
14
|
+
const roomBelow = clip.bottom - triggerRect.bottom - TRIGGER_GAP;
|
|
15
|
+
const roomAbove = triggerRect.top - clip.top - TRIGGER_GAP;
|
|
16
|
+
let direction;
|
|
17
|
+
let top;
|
|
18
|
+
let maxHeight = null;
|
|
19
|
+
if (popH <= roomBelow) {
|
|
20
|
+
direction = "bottom";
|
|
21
|
+
top = triggerRect.bottom + TRIGGER_GAP;
|
|
22
|
+
} else if (popH <= roomAbove) {
|
|
23
|
+
direction = "top";
|
|
24
|
+
top = triggerRect.top - TRIGGER_GAP - popH;
|
|
25
|
+
} else {
|
|
26
|
+
const room = Math.max(roomBelow, roomAbove, 0);
|
|
27
|
+
if (roomBelow >= roomAbove) {
|
|
28
|
+
direction = "bottom";
|
|
29
|
+
top = triggerRect.bottom + TRIGGER_GAP;
|
|
30
|
+
} else {
|
|
31
|
+
direction = "top";
|
|
32
|
+
top = triggerRect.top - TRIGGER_GAP - room;
|
|
33
|
+
}
|
|
34
|
+
maxHeight = room;
|
|
35
|
+
}
|
|
36
|
+
let left = triggerRect.left;
|
|
37
|
+
if (left + popW > clip.right - 8) {
|
|
38
|
+
left = triggerRect.right - popW;
|
|
39
|
+
}
|
|
40
|
+
if (left < clip.left + 8) left = clip.left + 8;
|
|
41
|
+
return {
|
|
42
|
+
direction,
|
|
43
|
+
top,
|
|
44
|
+
left,
|
|
45
|
+
maxHeight
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
var useAutoPosition = (triggerRef, popRef, enabled = true) => {
|
|
49
|
+
const directionRef = React.useRef("bottom");
|
|
50
|
+
const sizeRef = React.useRef(null);
|
|
51
|
+
const scrollParentRef = React.useRef(null);
|
|
52
|
+
const placedRef = React.useRef(false);
|
|
53
|
+
const frozenMaxRef = React.useRef(void 0);
|
|
54
|
+
const cssCapRef = React.useRef(void 0);
|
|
55
|
+
const calculatePosition = React.useCallback((remeasure = false) => {
|
|
56
|
+
const pop = popRef.current;
|
|
57
|
+
if (!triggerRef.current || !pop) return;
|
|
58
|
+
if (remeasure) frozenMaxRef.current = void 0;
|
|
59
|
+
if (cssCapRef.current === void 0) {
|
|
60
|
+
pop.style.maxHeight = "";
|
|
61
|
+
const raw = getComputedStyle(pop).maxHeight;
|
|
62
|
+
cssCapRef.current = raw === "none" ? null : Number.parseFloat(raw) || null;
|
|
63
|
+
}
|
|
64
|
+
if (remeasure || !sizeRef.current) {
|
|
65
|
+
sizeRef.current = {
|
|
66
|
+
w: pop.offsetWidth,
|
|
67
|
+
h: Math.max(pop.offsetHeight, pop.scrollHeight)
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
const { w: popW, h: popH } = sizeRef.current;
|
|
71
|
+
const triggerRect = triggerRef.current.getBoundingClientRect();
|
|
72
|
+
if (popH === 0 || popW === 0) {
|
|
73
|
+
sizeRef.current = null;
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const parentRect = scrollParentRef.current?.getBoundingClientRect();
|
|
77
|
+
const clip = {
|
|
78
|
+
top: Math.max(parentRect?.top ?? 0, 0),
|
|
79
|
+
bottom: Math.min(parentRect?.bottom ?? window.innerHeight, window.innerHeight),
|
|
80
|
+
left: Math.max(parentRect?.left ?? 0, 0),
|
|
81
|
+
right: Math.min(parentRect?.right ?? window.innerWidth, window.innerWidth)
|
|
82
|
+
};
|
|
83
|
+
const first = !placedRef.current;
|
|
84
|
+
if (first) pop.style.transition = "none";
|
|
85
|
+
const cap = cssCapRef.current;
|
|
86
|
+
const desiredH = cap == null ? popH : Math.min(popH, cap);
|
|
87
|
+
const frozen = frozenMaxRef.current;
|
|
88
|
+
const effectiveH = frozen == null ? desiredH : Math.min(desiredH, frozen);
|
|
89
|
+
const { direction: next, top, left, maxHeight: suggested } = computePlacement(
|
|
90
|
+
triggerRect,
|
|
91
|
+
popW,
|
|
92
|
+
effectiveH,
|
|
93
|
+
clip
|
|
94
|
+
);
|
|
95
|
+
if (frozenMaxRef.current === void 0) frozenMaxRef.current = suggested;
|
|
96
|
+
const maxHeight = frozenMaxRef.current;
|
|
97
|
+
const hostRect = (pop.offsetParent ?? pop.parentElement)?.getBoundingClientRect();
|
|
98
|
+
pop.style.top = `${top - (hostRect?.top ?? 0)}px`;
|
|
99
|
+
pop.style.left = `${left - (hostRect?.left ?? 0)}px`;
|
|
100
|
+
pop.style.maxHeight = maxHeight === null ? "" : `${maxHeight}px`;
|
|
101
|
+
directionRef.current = next;
|
|
102
|
+
pop.classList.toggle("top", next === "top");
|
|
103
|
+
pop.classList.toggle("bottom", next === "bottom");
|
|
104
|
+
if (first) {
|
|
105
|
+
void pop.offsetHeight;
|
|
106
|
+
pop.style.transition = "";
|
|
107
|
+
placedRef.current = true;
|
|
108
|
+
}
|
|
109
|
+
}, [triggerRef, popRef]);
|
|
110
|
+
React.useLayoutEffect(() => {
|
|
111
|
+
if (!enabled) {
|
|
112
|
+
sizeRef.current = null;
|
|
113
|
+
scrollParentRef.current = null;
|
|
114
|
+
placedRef.current = false;
|
|
115
|
+
frozenMaxRef.current = void 0;
|
|
116
|
+
cssCapRef.current = void 0;
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
if (triggerRef.current) {
|
|
120
|
+
scrollParentRef.current = findScrollParent(triggerRef.current);
|
|
121
|
+
}
|
|
122
|
+
calculatePosition(true);
|
|
123
|
+
const raf = requestAnimationFrame(() => calculatePosition(true));
|
|
124
|
+
return () => cancelAnimationFrame(raf);
|
|
125
|
+
}, [calculatePosition, enabled, triggerRef]);
|
|
126
|
+
React.useEffect(() => {
|
|
127
|
+
if (!enabled || !popRef.current) return;
|
|
128
|
+
const observer = new ResizeObserver(() => {
|
|
129
|
+
calculatePosition(true);
|
|
130
|
+
});
|
|
131
|
+
observer.observe(popRef.current);
|
|
132
|
+
return () => observer.disconnect();
|
|
133
|
+
}, [calculatePosition, enabled, popRef]);
|
|
134
|
+
React.useEffect(() => {
|
|
135
|
+
if (!enabled) return;
|
|
136
|
+
const onScroll = () => calculatePosition();
|
|
137
|
+
const onResize = () => calculatePosition(true);
|
|
138
|
+
window.addEventListener("resize", onResize, { passive: true });
|
|
139
|
+
window.addEventListener("scroll", onScroll, { passive: true, capture: true });
|
|
140
|
+
return () => {
|
|
141
|
+
window.removeEventListener("resize", onResize);
|
|
142
|
+
window.removeEventListener("scroll", onScroll, true);
|
|
143
|
+
};
|
|
144
|
+
}, [calculatePosition, enabled]);
|
|
145
|
+
};
|
|
146
|
+
var useAutoPosition_default = useAutoPosition;
|
|
147
|
+
|
|
148
|
+
// src/tokens/hooks/useOverlayKeyboard.ts
|
|
149
|
+
import React2 from "react";
|
|
150
|
+
var FOCUSABLE = [
|
|
151
|
+
"a[href]",
|
|
152
|
+
"button:not([disabled])",
|
|
153
|
+
"input:not([disabled]):not([type='hidden'])",
|
|
154
|
+
"select:not([disabled])",
|
|
155
|
+
"textarea:not([disabled])",
|
|
156
|
+
"[tabindex]:not([tabindex='-1'])"
|
|
157
|
+
].join(",");
|
|
158
|
+
var focusableIn = (el) => Array.from(el.querySelectorAll(FOCUSABLE)).filter(
|
|
159
|
+
// 화면에 없는 것은 제외 (display:none 등)
|
|
160
|
+
(n) => n.offsetWidth > 0 || n.offsetHeight > 0 || n === document.activeElement
|
|
161
|
+
);
|
|
162
|
+
var useEscapeKey = (enabled, onEscape) => {
|
|
163
|
+
React2.useEffect(() => {
|
|
164
|
+
if (!enabled) return;
|
|
165
|
+
const onKey = (e) => {
|
|
166
|
+
if (e.key !== "Escape") return;
|
|
167
|
+
if (e.defaultPrevented) return;
|
|
168
|
+
e.preventDefault();
|
|
169
|
+
onEscape();
|
|
170
|
+
};
|
|
171
|
+
document.addEventListener("keydown", onKey);
|
|
172
|
+
return () => document.removeEventListener("keydown", onKey);
|
|
173
|
+
}, [enabled, onEscape]);
|
|
174
|
+
};
|
|
175
|
+
var useFocusTrap = (containerRef, enabled, options = {}) => {
|
|
176
|
+
const { trap = false, initialFocus } = options;
|
|
177
|
+
const restoreRef = React2.useRef(null);
|
|
178
|
+
React2.useEffect(() => {
|
|
179
|
+
if (!enabled) return;
|
|
180
|
+
restoreRef.current = document.activeElement;
|
|
181
|
+
const raf = requestAnimationFrame(() => {
|
|
182
|
+
const el = containerRef.current;
|
|
183
|
+
if (!el) return;
|
|
184
|
+
const target = initialFocus?.current ?? focusableIn(el)[0] ?? el;
|
|
185
|
+
if (!target.hasAttribute("tabindex") && !focusableIn(el).includes(target)) {
|
|
186
|
+
target.setAttribute("tabindex", "-1");
|
|
187
|
+
}
|
|
188
|
+
target.focus({ preventScroll: true });
|
|
189
|
+
});
|
|
190
|
+
return () => {
|
|
191
|
+
cancelAnimationFrame(raf);
|
|
192
|
+
const prev = restoreRef.current;
|
|
193
|
+
if (prev && document.contains(prev)) prev.focus({ preventScroll: true });
|
|
194
|
+
};
|
|
195
|
+
}, [enabled, containerRef, initialFocus]);
|
|
196
|
+
React2.useEffect(() => {
|
|
197
|
+
if (!enabled || !trap) return;
|
|
198
|
+
const onKey = (e) => {
|
|
199
|
+
if (e.key !== "Tab") return;
|
|
200
|
+
const el = containerRef.current;
|
|
201
|
+
if (!el) return;
|
|
202
|
+
const items = focusableIn(el);
|
|
203
|
+
if (items.length === 0) {
|
|
204
|
+
e.preventDefault();
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
const first = items[0];
|
|
208
|
+
const last = items[items.length - 1];
|
|
209
|
+
const active = document.activeElement;
|
|
210
|
+
if (e.shiftKey && (active === first || !el.contains(active))) {
|
|
211
|
+
e.preventDefault();
|
|
212
|
+
last.focus();
|
|
213
|
+
} else if (!e.shiftKey && (active === last || !el.contains(active))) {
|
|
214
|
+
e.preventDefault();
|
|
215
|
+
first.focus();
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
document.addEventListener("keydown", onKey);
|
|
219
|
+
return () => document.removeEventListener("keydown", onKey);
|
|
220
|
+
}, [enabled, trap, containerRef]);
|
|
221
|
+
};
|
|
222
|
+
var useCloseWhenFocusHidden = (enabled, triggerRef, popRef, onClose) => {
|
|
223
|
+
const onCloseRef = React2.useRef(onClose);
|
|
224
|
+
onCloseRef.current = onClose;
|
|
225
|
+
React2.useEffect(() => {
|
|
226
|
+
const trigger = triggerRef.current;
|
|
227
|
+
if (!enabled || !trigger) return;
|
|
228
|
+
const observer = new IntersectionObserver(
|
|
229
|
+
([entry]) => {
|
|
230
|
+
if (entry.isIntersecting) return;
|
|
231
|
+
if (!popRef.current?.contains(document.activeElement)) return;
|
|
232
|
+
onCloseRef.current();
|
|
233
|
+
trigger.focus({ preventScroll: true });
|
|
234
|
+
},
|
|
235
|
+
// 그릇이 없으면 root: null → 뷰포트 기준
|
|
236
|
+
{ root: findScrollParent(trigger), threshold: 0 }
|
|
237
|
+
);
|
|
238
|
+
observer.observe(trigger);
|
|
239
|
+
return () => observer.disconnect();
|
|
240
|
+
}, [enabled, triggerRef, popRef]);
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
export {
|
|
244
|
+
findScrollParent,
|
|
245
|
+
computePlacement,
|
|
246
|
+
useAutoPosition_default,
|
|
247
|
+
useEscapeKey,
|
|
248
|
+
useFocusTrap,
|
|
249
|
+
useCloseWhenFocusHidden
|
|
250
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|