@x-plat/design-system 0.16.2 → 0.16.3
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/Tour/index.cjs +66 -19
- package/dist/components/Tour/index.css +28 -5
- package/dist/components/Tour/index.d.cts +6 -0
- package/dist/components/Tour/index.d.ts +6 -0
- package/dist/components/Tour/index.js +66 -19
- package/dist/components/index.cjs +86 -37
- package/dist/components/index.css +28 -5
- package/dist/components/index.js +86 -37
- package/dist/index.cjs +91 -42
- package/dist/index.css +28 -5
- package/dist/index.js +91 -42
- package/guidelines/components/tour.md +20 -3
- package/package.json +1 -1
|
@@ -35,7 +35,7 @@ __export(Tour_exports, {
|
|
|
35
35
|
module.exports = __toCommonJS(Tour_exports);
|
|
36
36
|
|
|
37
37
|
// src/components/Tour/Tour.tsx
|
|
38
|
-
var
|
|
38
|
+
var import_react4 = __toESM(require("react"), 1);
|
|
39
39
|
|
|
40
40
|
// src/tokens/hooks/Portal.tsx
|
|
41
41
|
var import_react_dom = __toESM(require("react-dom"), 1);
|
|
@@ -160,6 +160,48 @@ var useFocusTrap = (containerRef, enabled, options = {}) => {
|
|
|
160
160
|
}, [enabled, trap, containerRef]);
|
|
161
161
|
};
|
|
162
162
|
|
|
163
|
+
// src/tokens/hooks/useScrollLock.ts
|
|
164
|
+
var import_react3 = __toESM(require("react"), 1);
|
|
165
|
+
var SCROLL_KEYS = /* @__PURE__ */ new Set([
|
|
166
|
+
" ",
|
|
167
|
+
"PageUp",
|
|
168
|
+
"PageDown",
|
|
169
|
+
"Home",
|
|
170
|
+
"End",
|
|
171
|
+
"ArrowUp",
|
|
172
|
+
"ArrowDown",
|
|
173
|
+
"ArrowLeft",
|
|
174
|
+
"ArrowRight"
|
|
175
|
+
]);
|
|
176
|
+
var useScrollLock = (enabled, allowRef) => {
|
|
177
|
+
import_react3.default.useEffect(() => {
|
|
178
|
+
if (!enabled) return;
|
|
179
|
+
const allowed = (target) => target instanceof Node && !!allowRef?.current?.contains(target);
|
|
180
|
+
const block = (e) => {
|
|
181
|
+
if (allowed(e.target)) return;
|
|
182
|
+
e.preventDefault();
|
|
183
|
+
};
|
|
184
|
+
const onKey = (e) => {
|
|
185
|
+
if (!SCROLL_KEYS.has(e.key)) return;
|
|
186
|
+
if (allowed(e.target)) return;
|
|
187
|
+
const el = e.target;
|
|
188
|
+
const tag = el?.tagName;
|
|
189
|
+
if (tag === "INPUT" || tag === "TEXTAREA" || el?.isContentEditable) return;
|
|
190
|
+
e.preventDefault();
|
|
191
|
+
};
|
|
192
|
+
const opts = { passive: false, capture: true };
|
|
193
|
+
window.addEventListener("wheel", block, opts);
|
|
194
|
+
window.addEventListener("touchmove", block, opts);
|
|
195
|
+
window.addEventListener("keydown", onKey, opts);
|
|
196
|
+
return () => {
|
|
197
|
+
window.removeEventListener("wheel", block, true);
|
|
198
|
+
window.removeEventListener("touchmove", block, true);
|
|
199
|
+
window.removeEventListener("keydown", onKey, true);
|
|
200
|
+
};
|
|
201
|
+
}, [enabled, allowRef]);
|
|
202
|
+
};
|
|
203
|
+
var useScrollLock_default = useScrollLock;
|
|
204
|
+
|
|
163
205
|
// ../../node_modules/clsx/dist/clsx.mjs
|
|
164
206
|
function r(e) {
|
|
165
207
|
var t, f, n = "";
|
|
@@ -192,19 +234,20 @@ var Tour = (props) => {
|
|
|
192
234
|
onClose,
|
|
193
235
|
current,
|
|
194
236
|
onStepChange,
|
|
237
|
+
width = 380,
|
|
195
238
|
nextLabel = "\uB2E4\uC74C",
|
|
196
239
|
prevLabel = "\uC774\uC804",
|
|
197
240
|
skipLabel = "\uAC74\uB108\uB6F0\uAE30",
|
|
198
241
|
doneLabel = "\uB2E4 \uBD24\uC5B4\uC694"
|
|
199
242
|
} = props;
|
|
200
|
-
const [uncontrolled, setUncontrolled] =
|
|
243
|
+
const [uncontrolled, setUncontrolled] = import_react4.default.useState(0);
|
|
201
244
|
const index = current ?? uncontrolled;
|
|
202
245
|
const step = steps[index];
|
|
203
246
|
const isLast = index === steps.length - 1;
|
|
204
|
-
const spotRef =
|
|
205
|
-
const cardRef =
|
|
206
|
-
const [targetFound, setTargetFound] =
|
|
207
|
-
const goTo =
|
|
247
|
+
const spotRef = import_react4.default.useRef(null);
|
|
248
|
+
const cardRef = import_react4.default.useRef(null);
|
|
249
|
+
const [targetFound, setTargetFound] = import_react4.default.useState(true);
|
|
250
|
+
const goTo = import_react4.default.useCallback(
|
|
208
251
|
(next) => {
|
|
209
252
|
if (current === void 0) setUncontrolled(next);
|
|
210
253
|
onStepChange?.(next);
|
|
@@ -213,9 +256,10 @@ var Tour = (props) => {
|
|
|
213
256
|
);
|
|
214
257
|
useEscapeKey(open, () => onClose("skip"));
|
|
215
258
|
useFocusTrap(cardRef, open, { trap: true });
|
|
216
|
-
|
|
259
|
+
useScrollLock_default(open, cardRef);
|
|
260
|
+
const stepsRef = import_react4.default.useRef(steps);
|
|
217
261
|
stepsRef.current = steps;
|
|
218
|
-
|
|
262
|
+
import_react4.default.useEffect(() => {
|
|
219
263
|
if (!open) return;
|
|
220
264
|
const target = stepsRef.current[index]?.target;
|
|
221
265
|
if (!target) return;
|
|
@@ -240,7 +284,7 @@ var Tour = (props) => {
|
|
|
240
284
|
stop = true;
|
|
241
285
|
};
|
|
242
286
|
}, [open, index]);
|
|
243
|
-
const place =
|
|
287
|
+
const place = import_react4.default.useCallback(() => {
|
|
244
288
|
const spot = spotRef.current;
|
|
245
289
|
const card = cardRef.current;
|
|
246
290
|
if (!spot || !card || !step) return;
|
|
@@ -281,13 +325,13 @@ var Tour = (props) => {
|
|
|
281
325
|
}
|
|
282
326
|
);
|
|
283
327
|
const limit = window.innerHeight - VIEWPORT_MARGIN * 2;
|
|
284
|
-
const cardH = Math.min(
|
|
328
|
+
const cardH = Math.min(card.scrollHeight, limit);
|
|
285
329
|
const cardW = card.offsetWidth;
|
|
286
|
-
card.style.maxHeight = `${
|
|
330
|
+
card.style.maxHeight = `${limit}px`;
|
|
287
331
|
card.style.top = `${clamp(placed.top, VIEWPORT_MARGIN, window.innerHeight - VIEWPORT_MARGIN - cardH)}px`;
|
|
288
332
|
card.style.left = `${clamp(placed.left, VIEWPORT_MARGIN, window.innerWidth - VIEWPORT_MARGIN - cardW)}px`;
|
|
289
333
|
}, [step]);
|
|
290
|
-
|
|
334
|
+
import_react4.default.useLayoutEffect(() => {
|
|
291
335
|
if (!open) return;
|
|
292
336
|
place();
|
|
293
337
|
let raf = 0;
|
|
@@ -304,7 +348,7 @@ var Tour = (props) => {
|
|
|
304
348
|
raf = requestAnimationFrame(follow);
|
|
305
349
|
return () => cancelAnimationFrame(raf);
|
|
306
350
|
}, [open, index, place]);
|
|
307
|
-
|
|
351
|
+
import_react4.default.useEffect(() => {
|
|
308
352
|
if (!open) return;
|
|
309
353
|
const onMove = () => place();
|
|
310
354
|
window.addEventListener("scroll", onMove, { passive: true, capture: true });
|
|
@@ -323,17 +367,20 @@ var Tour = (props) => {
|
|
|
323
367
|
{
|
|
324
368
|
ref: cardRef,
|
|
325
369
|
className: "lib-xplat-tour-card",
|
|
370
|
+
style: { "--tour-card-width": typeof width === "number" ? `${width}px` : width },
|
|
326
371
|
role: "dialog",
|
|
327
372
|
"aria-modal": "true",
|
|
328
373
|
"aria-label": typeof step.title === "string" ? step.title : "\uD654\uBA74 \uC548\uB0B4",
|
|
329
374
|
children: [
|
|
330
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "tour-card-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
375
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "tour-card-head", children: [
|
|
376
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "tour-card-progress", "aria-hidden": true, children: [
|
|
377
|
+
index + 1,
|
|
378
|
+
" / ",
|
|
379
|
+
steps.length
|
|
380
|
+
] }),
|
|
381
|
+
step.title && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "tour-card-title", children: step.title })
|
|
334
382
|
] }),
|
|
335
|
-
step.
|
|
336
|
-
step.description && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "tour-card-description", children: step.description }),
|
|
383
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "tour-card-body", children: step.description && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "tour-card-description", children: step.description }) }),
|
|
337
384
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "tour-card-actions", children: [
|
|
338
385
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "tour-skip", onClick: () => onClose("skip"), children: skipLabel }),
|
|
339
386
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "tour-card-nav", children: [
|
|
@@ -28,14 +28,39 @@
|
|
|
28
28
|
position: fixed;
|
|
29
29
|
pointer-events: auto;
|
|
30
30
|
box-sizing: border-box;
|
|
31
|
-
width:
|
|
31
|
+
width: var(--tour-card-width, 380px);
|
|
32
32
|
max-width: calc(100vw - var(--spacing-space-8));
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
display: flex;
|
|
34
|
+
flex-direction: column;
|
|
35
|
+
overflow: hidden;
|
|
35
36
|
border-radius: var(--spacing-radius-md);
|
|
36
37
|
background-color: var(--semantic-surface-neutral-primary);
|
|
37
38
|
box-shadow: var(--semantic-shadow-lg);
|
|
38
39
|
}
|
|
40
|
+
.lib-xplat-tour-card > .tour-card-head,
|
|
41
|
+
.lib-xplat-tour-card > .tour-card-body,
|
|
42
|
+
.lib-xplat-tour-card > .tour-card-actions {
|
|
43
|
+
padding-left: var(--spacing-space-4);
|
|
44
|
+
padding-right: var(--spacing-space-4);
|
|
45
|
+
}
|
|
46
|
+
.lib-xplat-tour-card > .tour-card-head {
|
|
47
|
+
padding-top: var(--spacing-space-4);
|
|
48
|
+
flex: 0 0 auto;
|
|
49
|
+
}
|
|
50
|
+
.lib-xplat-tour-card {
|
|
51
|
+
}
|
|
52
|
+
.lib-xplat-tour-card > .tour-card-body {
|
|
53
|
+
flex: 1 1 auto;
|
|
54
|
+
min-height: 0;
|
|
55
|
+
overflow-y: auto;
|
|
56
|
+
padding-top: var(--spacing-space-2);
|
|
57
|
+
padding-bottom: var(--spacing-space-2);
|
|
58
|
+
}
|
|
59
|
+
.lib-xplat-tour-card > .tour-card-actions {
|
|
60
|
+
flex: 0 0 auto;
|
|
61
|
+
padding-bottom: var(--spacing-space-4);
|
|
62
|
+
padding-top: var(--spacing-space-2);
|
|
63
|
+
}
|
|
39
64
|
.lib-xplat-tour-card .tour-card-progress {
|
|
40
65
|
font-family: var(--semantic-typo-caption-2-r-font);
|
|
41
66
|
font-size: var(--semantic-typo-caption-2-r-size);
|
|
@@ -52,7 +77,6 @@
|
|
|
52
77
|
font-weight: var(--semantic-typo-label-1-sb-weight);
|
|
53
78
|
letter-spacing: var(--semantic-typo-label-1-sb-ls);
|
|
54
79
|
color: var(--semantic-text-primary);
|
|
55
|
-
margin-bottom: var(--spacing-space-2);
|
|
56
80
|
}
|
|
57
81
|
.lib-xplat-tour-card .tour-card-description {
|
|
58
82
|
font-family: var(--semantic-typo-caption-1-r-font);
|
|
@@ -68,7 +92,6 @@
|
|
|
68
92
|
align-items: center;
|
|
69
93
|
justify-content: space-between;
|
|
70
94
|
gap: var(--spacing-space-2);
|
|
71
|
-
margin-top: var(--spacing-space-4);
|
|
72
95
|
}
|
|
73
96
|
.lib-xplat-tour-card .tour-card-nav {
|
|
74
97
|
display: flex;
|
|
@@ -30,6 +30,12 @@ interface TourProps {
|
|
|
30
30
|
current?: number;
|
|
31
31
|
/** 단계가 바뀔 때 */
|
|
32
32
|
onStepChange?: (index: number) => void;
|
|
33
|
+
/**
|
|
34
|
+
* 말풍선 너비. 숫자면 px, 문자열이면 그대로 쓴다. 기본 `380`.
|
|
35
|
+
*
|
|
36
|
+
* 화면이 좁으면 그만큼 줄어든다(`max-width`).
|
|
37
|
+
*/
|
|
38
|
+
width?: number | string;
|
|
33
39
|
/** 버튼 글자 */
|
|
34
40
|
nextLabel?: string;
|
|
35
41
|
prevLabel?: string;
|
|
@@ -30,6 +30,12 @@ interface TourProps {
|
|
|
30
30
|
current?: number;
|
|
31
31
|
/** 단계가 바뀔 때 */
|
|
32
32
|
onStepChange?: (index: number) => void;
|
|
33
|
+
/**
|
|
34
|
+
* 말풍선 너비. 숫자면 px, 문자열이면 그대로 쓴다. 기본 `380`.
|
|
35
|
+
*
|
|
36
|
+
* 화면이 좁으면 그만큼 줄어든다(`max-width`).
|
|
37
|
+
*/
|
|
38
|
+
width?: number | string;
|
|
33
39
|
/** 버튼 글자 */
|
|
34
40
|
nextLabel?: string;
|
|
35
41
|
prevLabel?: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/components/Tour/Tour.tsx
|
|
2
|
-
import
|
|
2
|
+
import React4 from "react";
|
|
3
3
|
|
|
4
4
|
// src/tokens/hooks/Portal.tsx
|
|
5
5
|
import ReactDOM from "react-dom";
|
|
@@ -124,6 +124,48 @@ var useFocusTrap = (containerRef, enabled, options = {}) => {
|
|
|
124
124
|
}, [enabled, trap, containerRef]);
|
|
125
125
|
};
|
|
126
126
|
|
|
127
|
+
// src/tokens/hooks/useScrollLock.ts
|
|
128
|
+
import React3 from "react";
|
|
129
|
+
var SCROLL_KEYS = /* @__PURE__ */ new Set([
|
|
130
|
+
" ",
|
|
131
|
+
"PageUp",
|
|
132
|
+
"PageDown",
|
|
133
|
+
"Home",
|
|
134
|
+
"End",
|
|
135
|
+
"ArrowUp",
|
|
136
|
+
"ArrowDown",
|
|
137
|
+
"ArrowLeft",
|
|
138
|
+
"ArrowRight"
|
|
139
|
+
]);
|
|
140
|
+
var useScrollLock = (enabled, allowRef) => {
|
|
141
|
+
React3.useEffect(() => {
|
|
142
|
+
if (!enabled) return;
|
|
143
|
+
const allowed = (target) => target instanceof Node && !!allowRef?.current?.contains(target);
|
|
144
|
+
const block = (e) => {
|
|
145
|
+
if (allowed(e.target)) return;
|
|
146
|
+
e.preventDefault();
|
|
147
|
+
};
|
|
148
|
+
const onKey = (e) => {
|
|
149
|
+
if (!SCROLL_KEYS.has(e.key)) return;
|
|
150
|
+
if (allowed(e.target)) return;
|
|
151
|
+
const el = e.target;
|
|
152
|
+
const tag = el?.tagName;
|
|
153
|
+
if (tag === "INPUT" || tag === "TEXTAREA" || el?.isContentEditable) return;
|
|
154
|
+
e.preventDefault();
|
|
155
|
+
};
|
|
156
|
+
const opts = { passive: false, capture: true };
|
|
157
|
+
window.addEventListener("wheel", block, opts);
|
|
158
|
+
window.addEventListener("touchmove", block, opts);
|
|
159
|
+
window.addEventListener("keydown", onKey, opts);
|
|
160
|
+
return () => {
|
|
161
|
+
window.removeEventListener("wheel", block, true);
|
|
162
|
+
window.removeEventListener("touchmove", block, true);
|
|
163
|
+
window.removeEventListener("keydown", onKey, true);
|
|
164
|
+
};
|
|
165
|
+
}, [enabled, allowRef]);
|
|
166
|
+
};
|
|
167
|
+
var useScrollLock_default = useScrollLock;
|
|
168
|
+
|
|
127
169
|
// ../../node_modules/clsx/dist/clsx.mjs
|
|
128
170
|
function r(e) {
|
|
129
171
|
var t, f, n = "";
|
|
@@ -156,19 +198,20 @@ var Tour = (props) => {
|
|
|
156
198
|
onClose,
|
|
157
199
|
current,
|
|
158
200
|
onStepChange,
|
|
201
|
+
width = 380,
|
|
159
202
|
nextLabel = "\uB2E4\uC74C",
|
|
160
203
|
prevLabel = "\uC774\uC804",
|
|
161
204
|
skipLabel = "\uAC74\uB108\uB6F0\uAE30",
|
|
162
205
|
doneLabel = "\uB2E4 \uBD24\uC5B4\uC694"
|
|
163
206
|
} = props;
|
|
164
|
-
const [uncontrolled, setUncontrolled] =
|
|
207
|
+
const [uncontrolled, setUncontrolled] = React4.useState(0);
|
|
165
208
|
const index = current ?? uncontrolled;
|
|
166
209
|
const step = steps[index];
|
|
167
210
|
const isLast = index === steps.length - 1;
|
|
168
|
-
const spotRef =
|
|
169
|
-
const cardRef =
|
|
170
|
-
const [targetFound, setTargetFound] =
|
|
171
|
-
const goTo =
|
|
211
|
+
const spotRef = React4.useRef(null);
|
|
212
|
+
const cardRef = React4.useRef(null);
|
|
213
|
+
const [targetFound, setTargetFound] = React4.useState(true);
|
|
214
|
+
const goTo = React4.useCallback(
|
|
172
215
|
(next) => {
|
|
173
216
|
if (current === void 0) setUncontrolled(next);
|
|
174
217
|
onStepChange?.(next);
|
|
@@ -177,9 +220,10 @@ var Tour = (props) => {
|
|
|
177
220
|
);
|
|
178
221
|
useEscapeKey(open, () => onClose("skip"));
|
|
179
222
|
useFocusTrap(cardRef, open, { trap: true });
|
|
180
|
-
|
|
223
|
+
useScrollLock_default(open, cardRef);
|
|
224
|
+
const stepsRef = React4.useRef(steps);
|
|
181
225
|
stepsRef.current = steps;
|
|
182
|
-
|
|
226
|
+
React4.useEffect(() => {
|
|
183
227
|
if (!open) return;
|
|
184
228
|
const target = stepsRef.current[index]?.target;
|
|
185
229
|
if (!target) return;
|
|
@@ -204,7 +248,7 @@ var Tour = (props) => {
|
|
|
204
248
|
stop = true;
|
|
205
249
|
};
|
|
206
250
|
}, [open, index]);
|
|
207
|
-
const place =
|
|
251
|
+
const place = React4.useCallback(() => {
|
|
208
252
|
const spot = spotRef.current;
|
|
209
253
|
const card = cardRef.current;
|
|
210
254
|
if (!spot || !card || !step) return;
|
|
@@ -245,13 +289,13 @@ var Tour = (props) => {
|
|
|
245
289
|
}
|
|
246
290
|
);
|
|
247
291
|
const limit = window.innerHeight - VIEWPORT_MARGIN * 2;
|
|
248
|
-
const cardH = Math.min(
|
|
292
|
+
const cardH = Math.min(card.scrollHeight, limit);
|
|
249
293
|
const cardW = card.offsetWidth;
|
|
250
|
-
card.style.maxHeight = `${
|
|
294
|
+
card.style.maxHeight = `${limit}px`;
|
|
251
295
|
card.style.top = `${clamp(placed.top, VIEWPORT_MARGIN, window.innerHeight - VIEWPORT_MARGIN - cardH)}px`;
|
|
252
296
|
card.style.left = `${clamp(placed.left, VIEWPORT_MARGIN, window.innerWidth - VIEWPORT_MARGIN - cardW)}px`;
|
|
253
297
|
}, [step]);
|
|
254
|
-
|
|
298
|
+
React4.useLayoutEffect(() => {
|
|
255
299
|
if (!open) return;
|
|
256
300
|
place();
|
|
257
301
|
let raf = 0;
|
|
@@ -268,7 +312,7 @@ var Tour = (props) => {
|
|
|
268
312
|
raf = requestAnimationFrame(follow);
|
|
269
313
|
return () => cancelAnimationFrame(raf);
|
|
270
314
|
}, [open, index, place]);
|
|
271
|
-
|
|
315
|
+
React4.useEffect(() => {
|
|
272
316
|
if (!open) return;
|
|
273
317
|
const onMove = () => place();
|
|
274
318
|
window.addEventListener("scroll", onMove, { passive: true, capture: true });
|
|
@@ -287,17 +331,20 @@ var Tour = (props) => {
|
|
|
287
331
|
{
|
|
288
332
|
ref: cardRef,
|
|
289
333
|
className: "lib-xplat-tour-card",
|
|
334
|
+
style: { "--tour-card-width": typeof width === "number" ? `${width}px` : width },
|
|
290
335
|
role: "dialog",
|
|
291
336
|
"aria-modal": "true",
|
|
292
337
|
"aria-label": typeof step.title === "string" ? step.title : "\uD654\uBA74 \uC548\uB0B4",
|
|
293
338
|
children: [
|
|
294
|
-
/* @__PURE__ */ jsxs("div", { className: "tour-card-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
339
|
+
/* @__PURE__ */ jsxs("div", { className: "tour-card-head", children: [
|
|
340
|
+
/* @__PURE__ */ jsxs("div", { className: "tour-card-progress", "aria-hidden": true, children: [
|
|
341
|
+
index + 1,
|
|
342
|
+
" / ",
|
|
343
|
+
steps.length
|
|
344
|
+
] }),
|
|
345
|
+
step.title && /* @__PURE__ */ jsx("div", { className: "tour-card-title", children: step.title })
|
|
298
346
|
] }),
|
|
299
|
-
step.
|
|
300
|
-
step.description && /* @__PURE__ */ jsx("div", { className: "tour-card-description", children: step.description }),
|
|
347
|
+
/* @__PURE__ */ jsx("div", { className: "tour-card-body", children: step.description && /* @__PURE__ */ jsx("div", { className: "tour-card-description", children: step.description }) }),
|
|
301
348
|
/* @__PURE__ */ jsxs("div", { className: "tour-card-actions", children: [
|
|
302
349
|
/* @__PURE__ */ jsx("button", { type: "button", className: "tour-skip", onClick: () => onClose("skip"), children: skipLabel }),
|
|
303
350
|
/* @__PURE__ */ jsxs("div", { className: "tour-card-nav", children: [
|
|
@@ -7707,7 +7707,51 @@ Tooltip.displayName = "Tooltip";
|
|
|
7707
7707
|
var Tooltip_default = Tooltip;
|
|
7708
7708
|
|
|
7709
7709
|
// src/components/Tour/Tour.tsx
|
|
7710
|
+
var import_react45 = __toESM(require("react"), 1);
|
|
7711
|
+
|
|
7712
|
+
// src/tokens/hooks/useScrollLock.ts
|
|
7710
7713
|
var import_react44 = __toESM(require("react"), 1);
|
|
7714
|
+
var SCROLL_KEYS = /* @__PURE__ */ new Set([
|
|
7715
|
+
" ",
|
|
7716
|
+
"PageUp",
|
|
7717
|
+
"PageDown",
|
|
7718
|
+
"Home",
|
|
7719
|
+
"End",
|
|
7720
|
+
"ArrowUp",
|
|
7721
|
+
"ArrowDown",
|
|
7722
|
+
"ArrowLeft",
|
|
7723
|
+
"ArrowRight"
|
|
7724
|
+
]);
|
|
7725
|
+
var useScrollLock = (enabled, allowRef) => {
|
|
7726
|
+
import_react44.default.useEffect(() => {
|
|
7727
|
+
if (!enabled) return;
|
|
7728
|
+
const allowed = (target) => target instanceof Node && !!allowRef?.current?.contains(target);
|
|
7729
|
+
const block = (e) => {
|
|
7730
|
+
if (allowed(e.target)) return;
|
|
7731
|
+
e.preventDefault();
|
|
7732
|
+
};
|
|
7733
|
+
const onKey = (e) => {
|
|
7734
|
+
if (!SCROLL_KEYS.has(e.key)) return;
|
|
7735
|
+
if (allowed(e.target)) return;
|
|
7736
|
+
const el = e.target;
|
|
7737
|
+
const tag = el?.tagName;
|
|
7738
|
+
if (tag === "INPUT" || tag === "TEXTAREA" || el?.isContentEditable) return;
|
|
7739
|
+
e.preventDefault();
|
|
7740
|
+
};
|
|
7741
|
+
const opts = { passive: false, capture: true };
|
|
7742
|
+
window.addEventListener("wheel", block, opts);
|
|
7743
|
+
window.addEventListener("touchmove", block, opts);
|
|
7744
|
+
window.addEventListener("keydown", onKey, opts);
|
|
7745
|
+
return () => {
|
|
7746
|
+
window.removeEventListener("wheel", block, true);
|
|
7747
|
+
window.removeEventListener("touchmove", block, true);
|
|
7748
|
+
window.removeEventListener("keydown", onKey, true);
|
|
7749
|
+
};
|
|
7750
|
+
}, [enabled, allowRef]);
|
|
7751
|
+
};
|
|
7752
|
+
var useScrollLock_default = useScrollLock;
|
|
7753
|
+
|
|
7754
|
+
// src/components/Tour/Tour.tsx
|
|
7711
7755
|
var import_jsx_runtime355 = require("react/jsx-runtime");
|
|
7712
7756
|
var VIEWPORT_MARGIN = 16;
|
|
7713
7757
|
var DEFAULT_PADDING = 8;
|
|
@@ -7723,19 +7767,20 @@ var Tour = (props) => {
|
|
|
7723
7767
|
onClose,
|
|
7724
7768
|
current,
|
|
7725
7769
|
onStepChange,
|
|
7770
|
+
width = 380,
|
|
7726
7771
|
nextLabel = "\uB2E4\uC74C",
|
|
7727
7772
|
prevLabel = "\uC774\uC804",
|
|
7728
7773
|
skipLabel = "\uAC74\uB108\uB6F0\uAE30",
|
|
7729
7774
|
doneLabel = "\uB2E4 \uBD24\uC5B4\uC694"
|
|
7730
7775
|
} = props;
|
|
7731
|
-
const [uncontrolled, setUncontrolled] =
|
|
7776
|
+
const [uncontrolled, setUncontrolled] = import_react45.default.useState(0);
|
|
7732
7777
|
const index = current ?? uncontrolled;
|
|
7733
7778
|
const step = steps[index];
|
|
7734
7779
|
const isLast = index === steps.length - 1;
|
|
7735
|
-
const spotRef =
|
|
7736
|
-
const cardRef =
|
|
7737
|
-
const [targetFound, setTargetFound] =
|
|
7738
|
-
const goTo =
|
|
7780
|
+
const spotRef = import_react45.default.useRef(null);
|
|
7781
|
+
const cardRef = import_react45.default.useRef(null);
|
|
7782
|
+
const [targetFound, setTargetFound] = import_react45.default.useState(true);
|
|
7783
|
+
const goTo = import_react45.default.useCallback(
|
|
7739
7784
|
(next) => {
|
|
7740
7785
|
if (current === void 0) setUncontrolled(next);
|
|
7741
7786
|
onStepChange?.(next);
|
|
@@ -7744,9 +7789,10 @@ var Tour = (props) => {
|
|
|
7744
7789
|
);
|
|
7745
7790
|
useEscapeKey(open, () => onClose("skip"));
|
|
7746
7791
|
useFocusTrap(cardRef, open, { trap: true });
|
|
7747
|
-
|
|
7792
|
+
useScrollLock_default(open, cardRef);
|
|
7793
|
+
const stepsRef = import_react45.default.useRef(steps);
|
|
7748
7794
|
stepsRef.current = steps;
|
|
7749
|
-
|
|
7795
|
+
import_react45.default.useEffect(() => {
|
|
7750
7796
|
if (!open) return;
|
|
7751
7797
|
const target = stepsRef.current[index]?.target;
|
|
7752
7798
|
if (!target) return;
|
|
@@ -7771,7 +7817,7 @@ var Tour = (props) => {
|
|
|
7771
7817
|
stop = true;
|
|
7772
7818
|
};
|
|
7773
7819
|
}, [open, index]);
|
|
7774
|
-
const place =
|
|
7820
|
+
const place = import_react45.default.useCallback(() => {
|
|
7775
7821
|
const spot = spotRef.current;
|
|
7776
7822
|
const card = cardRef.current;
|
|
7777
7823
|
if (!spot || !card || !step) return;
|
|
@@ -7812,13 +7858,13 @@ var Tour = (props) => {
|
|
|
7812
7858
|
}
|
|
7813
7859
|
);
|
|
7814
7860
|
const limit = window.innerHeight - VIEWPORT_MARGIN * 2;
|
|
7815
|
-
const cardH = Math.min(
|
|
7861
|
+
const cardH = Math.min(card.scrollHeight, limit);
|
|
7816
7862
|
const cardW = card.offsetWidth;
|
|
7817
|
-
card.style.maxHeight = `${
|
|
7863
|
+
card.style.maxHeight = `${limit}px`;
|
|
7818
7864
|
card.style.top = `${clamp(placed.top, VIEWPORT_MARGIN, window.innerHeight - VIEWPORT_MARGIN - cardH)}px`;
|
|
7819
7865
|
card.style.left = `${clamp(placed.left, VIEWPORT_MARGIN, window.innerWidth - VIEWPORT_MARGIN - cardW)}px`;
|
|
7820
7866
|
}, [step]);
|
|
7821
|
-
|
|
7867
|
+
import_react45.default.useLayoutEffect(() => {
|
|
7822
7868
|
if (!open) return;
|
|
7823
7869
|
place();
|
|
7824
7870
|
let raf = 0;
|
|
@@ -7835,7 +7881,7 @@ var Tour = (props) => {
|
|
|
7835
7881
|
raf = requestAnimationFrame(follow);
|
|
7836
7882
|
return () => cancelAnimationFrame(raf);
|
|
7837
7883
|
}, [open, index, place]);
|
|
7838
|
-
|
|
7884
|
+
import_react45.default.useEffect(() => {
|
|
7839
7885
|
if (!open) return;
|
|
7840
7886
|
const onMove = () => place();
|
|
7841
7887
|
window.addEventListener("scroll", onMove, { passive: true, capture: true });
|
|
@@ -7854,17 +7900,20 @@ var Tour = (props) => {
|
|
|
7854
7900
|
{
|
|
7855
7901
|
ref: cardRef,
|
|
7856
7902
|
className: "lib-xplat-tour-card",
|
|
7903
|
+
style: { "--tour-card-width": typeof width === "number" ? `${width}px` : width },
|
|
7857
7904
|
role: "dialog",
|
|
7858
7905
|
"aria-modal": "true",
|
|
7859
7906
|
"aria-label": typeof step.title === "string" ? step.title : "\uD654\uBA74 \uC548\uB0B4",
|
|
7860
7907
|
children: [
|
|
7861
|
-
/* @__PURE__ */ (0, import_jsx_runtime355.jsxs)("div", { className: "tour-card-
|
|
7862
|
-
|
|
7863
|
-
|
|
7864
|
-
|
|
7908
|
+
/* @__PURE__ */ (0, import_jsx_runtime355.jsxs)("div", { className: "tour-card-head", children: [
|
|
7909
|
+
/* @__PURE__ */ (0, import_jsx_runtime355.jsxs)("div", { className: "tour-card-progress", "aria-hidden": true, children: [
|
|
7910
|
+
index + 1,
|
|
7911
|
+
" / ",
|
|
7912
|
+
steps.length
|
|
7913
|
+
] }),
|
|
7914
|
+
step.title && /* @__PURE__ */ (0, import_jsx_runtime355.jsx)("div", { className: "tour-card-title", children: step.title })
|
|
7865
7915
|
] }),
|
|
7866
|
-
step.
|
|
7867
|
-
step.description && /* @__PURE__ */ (0, import_jsx_runtime355.jsx)("div", { className: "tour-card-description", children: step.description }),
|
|
7916
|
+
/* @__PURE__ */ (0, import_jsx_runtime355.jsx)("div", { className: "tour-card-body", children: step.description && /* @__PURE__ */ (0, import_jsx_runtime355.jsx)("div", { className: "tour-card-description", children: step.description }) }),
|
|
7868
7917
|
/* @__PURE__ */ (0, import_jsx_runtime355.jsxs)("div", { className: "tour-card-actions", children: [
|
|
7869
7918
|
/* @__PURE__ */ (0, import_jsx_runtime355.jsx)("button", { type: "button", className: "tour-skip", onClick: () => onClose("skip"), children: skipLabel }),
|
|
7870
7919
|
/* @__PURE__ */ (0, import_jsx_runtime355.jsxs)("div", { className: "tour-card-nav", children: [
|
|
@@ -7897,7 +7946,7 @@ Tour.displayName = "Tour";
|
|
|
7897
7946
|
var Tour_default = Tour;
|
|
7898
7947
|
|
|
7899
7948
|
// src/components/Video/Video.tsx
|
|
7900
|
-
var
|
|
7949
|
+
var import_react46 = __toESM(require("react"), 1);
|
|
7901
7950
|
var import_jsx_runtime356 = require("react/jsx-runtime");
|
|
7902
7951
|
var PipIcon = () => /* @__PURE__ */ (0, import_jsx_runtime356.jsxs)("svg", { viewBox: "0 0 24 24", width: "1em", height: "1em", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
|
|
7903
7952
|
/* @__PURE__ */ (0, import_jsx_runtime356.jsx)("rect", { x: "3", y: "5", width: "18", height: "14", rx: "2" }),
|
|
@@ -7909,7 +7958,7 @@ var formatTime = (sec) => {
|
|
|
7909
7958
|
const s = Math.floor(sec % 60);
|
|
7910
7959
|
return `${m}:${s.toString().padStart(2, "0")}`;
|
|
7911
7960
|
};
|
|
7912
|
-
var Video =
|
|
7961
|
+
var Video = import_react46.default.forwardRef((props, ref) => {
|
|
7913
7962
|
const {
|
|
7914
7963
|
src,
|
|
7915
7964
|
poster,
|
|
@@ -7933,21 +7982,21 @@ var Video = import_react45.default.forwardRef((props, ref) => {
|
|
|
7933
7982
|
children,
|
|
7934
7983
|
...rest
|
|
7935
7984
|
} = props;
|
|
7936
|
-
const containerRef =
|
|
7937
|
-
const videoRef =
|
|
7938
|
-
const [isPlaying, setIsPlaying] =
|
|
7939
|
-
const [isLoaded, setIsLoaded] =
|
|
7940
|
-
const [currentTime, setCurrentTime] =
|
|
7941
|
-
const [duration, setDuration] =
|
|
7942
|
-
const [buffered, setBuffered] =
|
|
7943
|
-
const [volume, setVolume] =
|
|
7944
|
-
const [isMuted, setIsMuted] =
|
|
7945
|
-
const [isFullscreen, setIsFullscreen] =
|
|
7946
|
-
const [playbackRate, setPlaybackRate] =
|
|
7947
|
-
const [rateMenuOpen, setRateMenuOpen] =
|
|
7948
|
-
const [captionsOn, setCaptionsOn] =
|
|
7949
|
-
const [isPip, setIsPip] =
|
|
7950
|
-
const setRefs =
|
|
7985
|
+
const containerRef = import_react46.default.useRef(null);
|
|
7986
|
+
const videoRef = import_react46.default.useRef(null);
|
|
7987
|
+
const [isPlaying, setIsPlaying] = import_react46.default.useState(Boolean(autoPlay));
|
|
7988
|
+
const [isLoaded, setIsLoaded] = import_react46.default.useState(false);
|
|
7989
|
+
const [currentTime, setCurrentTime] = import_react46.default.useState(0);
|
|
7990
|
+
const [duration, setDuration] = import_react46.default.useState(0);
|
|
7991
|
+
const [buffered, setBuffered] = import_react46.default.useState(0);
|
|
7992
|
+
const [volume, setVolume] = import_react46.default.useState(1);
|
|
7993
|
+
const [isMuted, setIsMuted] = import_react46.default.useState(Boolean(muted));
|
|
7994
|
+
const [isFullscreen, setIsFullscreen] = import_react46.default.useState(false);
|
|
7995
|
+
const [playbackRate, setPlaybackRate] = import_react46.default.useState(1);
|
|
7996
|
+
const [rateMenuOpen, setRateMenuOpen] = import_react46.default.useState(false);
|
|
7997
|
+
const [captionsOn, setCaptionsOn] = import_react46.default.useState(false);
|
|
7998
|
+
const [isPip, setIsPip] = import_react46.default.useState(false);
|
|
7999
|
+
const setRefs = import_react46.default.useCallback(
|
|
7951
8000
|
(el) => {
|
|
7952
8001
|
videoRef.current = el;
|
|
7953
8002
|
if (typeof ref === "function") ref(el);
|
|
@@ -7955,14 +8004,14 @@ var Video = import_react45.default.forwardRef((props, ref) => {
|
|
|
7955
8004
|
},
|
|
7956
8005
|
[ref]
|
|
7957
8006
|
);
|
|
7958
|
-
|
|
8007
|
+
import_react46.default.useEffect(() => {
|
|
7959
8008
|
const onFsChange = () => {
|
|
7960
8009
|
setIsFullscreen(document.fullscreenElement === containerRef.current);
|
|
7961
8010
|
};
|
|
7962
8011
|
document.addEventListener("fullscreenchange", onFsChange);
|
|
7963
8012
|
return () => document.removeEventListener("fullscreenchange", onFsChange);
|
|
7964
8013
|
}, []);
|
|
7965
|
-
|
|
8014
|
+
import_react46.default.useEffect(() => {
|
|
7966
8015
|
const v = videoRef.current;
|
|
7967
8016
|
if (!v) return;
|
|
7968
8017
|
const onEnter = () => setIsPip(true);
|