@x-plat/design-system 0.16.1 → 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 +105 -26
- 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 +105 -26
- package/dist/components/index.cjs +125 -44
- package/dist/components/index.css +28 -5
- package/dist/components/index.js +125 -44
- package/dist/index.cjs +130 -49
- package/dist/index.css +28 -5
- package/dist/index.js +130 -49
- package/guidelines/components/tour.md +31 -7
- 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,13 +256,35 @@ var Tour = (props) => {
|
|
|
213
256
|
);
|
|
214
257
|
useEscapeKey(open, () => onClose("skip"));
|
|
215
258
|
useFocusTrap(cardRef, open, { trap: true });
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
259
|
+
useScrollLock_default(open, cardRef);
|
|
260
|
+
const stepsRef = import_react4.default.useRef(steps);
|
|
261
|
+
stepsRef.current = steps;
|
|
262
|
+
import_react4.default.useEffect(() => {
|
|
263
|
+
if (!open) return;
|
|
264
|
+
const target = stepsRef.current[index]?.target;
|
|
265
|
+
if (!target) return;
|
|
266
|
+
let stop = false;
|
|
267
|
+
let tries = 0;
|
|
268
|
+
const look = () => {
|
|
269
|
+
if (stop) return;
|
|
270
|
+
const el = resolve(target);
|
|
271
|
+
if (el) {
|
|
272
|
+
setTargetFound(true);
|
|
273
|
+
el.scrollIntoView({ block: "center", inline: "nearest", behavior: "smooth" });
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
setTargetFound(false);
|
|
277
|
+
if (tries < 60) {
|
|
278
|
+
tries += 1;
|
|
279
|
+
requestAnimationFrame(look);
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
look();
|
|
283
|
+
return () => {
|
|
284
|
+
stop = true;
|
|
285
|
+
};
|
|
286
|
+
}, [open, index]);
|
|
287
|
+
const place = import_react4.default.useCallback(() => {
|
|
223
288
|
const spot = spotRef.current;
|
|
224
289
|
const card = cardRef.current;
|
|
225
290
|
if (!spot || !card || !step) return;
|
|
@@ -260,19 +325,30 @@ var Tour = (props) => {
|
|
|
260
325
|
}
|
|
261
326
|
);
|
|
262
327
|
const limit = window.innerHeight - VIEWPORT_MARGIN * 2;
|
|
263
|
-
const cardH = Math.min(
|
|
328
|
+
const cardH = Math.min(card.scrollHeight, limit);
|
|
264
329
|
const cardW = card.offsetWidth;
|
|
265
|
-
card.style.maxHeight = `${
|
|
330
|
+
card.style.maxHeight = `${limit}px`;
|
|
266
331
|
card.style.top = `${clamp(placed.top, VIEWPORT_MARGIN, window.innerHeight - VIEWPORT_MARGIN - cardH)}px`;
|
|
267
332
|
card.style.left = `${clamp(placed.left, VIEWPORT_MARGIN, window.innerWidth - VIEWPORT_MARGIN - cardW)}px`;
|
|
268
333
|
}, [step]);
|
|
269
|
-
|
|
334
|
+
import_react4.default.useLayoutEffect(() => {
|
|
270
335
|
if (!open) return;
|
|
271
336
|
place();
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
337
|
+
let raf = 0;
|
|
338
|
+
let settled = 0;
|
|
339
|
+
let last = "";
|
|
340
|
+
const follow = () => {
|
|
341
|
+
const el = resolve(stepsRef.current[index]?.target ?? "");
|
|
342
|
+
const now = el ? JSON.stringify(el.getBoundingClientRect()) : "";
|
|
343
|
+
settled = now === last ? settled + 1 : 0;
|
|
344
|
+
last = now;
|
|
345
|
+
place();
|
|
346
|
+
if (settled < 3) raf = requestAnimationFrame(follow);
|
|
347
|
+
};
|
|
348
|
+
raf = requestAnimationFrame(follow);
|
|
349
|
+
return () => cancelAnimationFrame(raf);
|
|
350
|
+
}, [open, index, place]);
|
|
351
|
+
import_react4.default.useEffect(() => {
|
|
276
352
|
if (!open) return;
|
|
277
353
|
const onMove = () => place();
|
|
278
354
|
window.addEventListener("scroll", onMove, { passive: true, capture: true });
|
|
@@ -291,17 +367,20 @@ var Tour = (props) => {
|
|
|
291
367
|
{
|
|
292
368
|
ref: cardRef,
|
|
293
369
|
className: "lib-xplat-tour-card",
|
|
370
|
+
style: { "--tour-card-width": typeof width === "number" ? `${width}px` : width },
|
|
294
371
|
role: "dialog",
|
|
295
372
|
"aria-modal": "true",
|
|
296
373
|
"aria-label": typeof step.title === "string" ? step.title : "\uD654\uBA74 \uC548\uB0B4",
|
|
297
374
|
children: [
|
|
298
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "tour-card-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
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 })
|
|
302
382
|
] }),
|
|
303
|
-
step.
|
|
304
|
-
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 }) }),
|
|
305
384
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "tour-card-actions", children: [
|
|
306
385
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "tour-skip", onClick: () => onClose("skip"), children: skipLabel }),
|
|
307
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,13 +220,35 @@ var Tour = (props) => {
|
|
|
177
220
|
);
|
|
178
221
|
useEscapeKey(open, () => onClose("skip"));
|
|
179
222
|
useFocusTrap(cardRef, open, { trap: true });
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
223
|
+
useScrollLock_default(open, cardRef);
|
|
224
|
+
const stepsRef = React4.useRef(steps);
|
|
225
|
+
stepsRef.current = steps;
|
|
226
|
+
React4.useEffect(() => {
|
|
227
|
+
if (!open) return;
|
|
228
|
+
const target = stepsRef.current[index]?.target;
|
|
229
|
+
if (!target) return;
|
|
230
|
+
let stop = false;
|
|
231
|
+
let tries = 0;
|
|
232
|
+
const look = () => {
|
|
233
|
+
if (stop) return;
|
|
234
|
+
const el = resolve(target);
|
|
235
|
+
if (el) {
|
|
236
|
+
setTargetFound(true);
|
|
237
|
+
el.scrollIntoView({ block: "center", inline: "nearest", behavior: "smooth" });
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
setTargetFound(false);
|
|
241
|
+
if (tries < 60) {
|
|
242
|
+
tries += 1;
|
|
243
|
+
requestAnimationFrame(look);
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
look();
|
|
247
|
+
return () => {
|
|
248
|
+
stop = true;
|
|
249
|
+
};
|
|
250
|
+
}, [open, index]);
|
|
251
|
+
const place = React4.useCallback(() => {
|
|
187
252
|
const spot = spotRef.current;
|
|
188
253
|
const card = cardRef.current;
|
|
189
254
|
if (!spot || !card || !step) return;
|
|
@@ -224,19 +289,30 @@ var Tour = (props) => {
|
|
|
224
289
|
}
|
|
225
290
|
);
|
|
226
291
|
const limit = window.innerHeight - VIEWPORT_MARGIN * 2;
|
|
227
|
-
const cardH = Math.min(
|
|
292
|
+
const cardH = Math.min(card.scrollHeight, limit);
|
|
228
293
|
const cardW = card.offsetWidth;
|
|
229
|
-
card.style.maxHeight = `${
|
|
294
|
+
card.style.maxHeight = `${limit}px`;
|
|
230
295
|
card.style.top = `${clamp(placed.top, VIEWPORT_MARGIN, window.innerHeight - VIEWPORT_MARGIN - cardH)}px`;
|
|
231
296
|
card.style.left = `${clamp(placed.left, VIEWPORT_MARGIN, window.innerWidth - VIEWPORT_MARGIN - cardW)}px`;
|
|
232
297
|
}, [step]);
|
|
233
|
-
|
|
298
|
+
React4.useLayoutEffect(() => {
|
|
234
299
|
if (!open) return;
|
|
235
300
|
place();
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
301
|
+
let raf = 0;
|
|
302
|
+
let settled = 0;
|
|
303
|
+
let last = "";
|
|
304
|
+
const follow = () => {
|
|
305
|
+
const el = resolve(stepsRef.current[index]?.target ?? "");
|
|
306
|
+
const now = el ? JSON.stringify(el.getBoundingClientRect()) : "";
|
|
307
|
+
settled = now === last ? settled + 1 : 0;
|
|
308
|
+
last = now;
|
|
309
|
+
place();
|
|
310
|
+
if (settled < 3) raf = requestAnimationFrame(follow);
|
|
311
|
+
};
|
|
312
|
+
raf = requestAnimationFrame(follow);
|
|
313
|
+
return () => cancelAnimationFrame(raf);
|
|
314
|
+
}, [open, index, place]);
|
|
315
|
+
React4.useEffect(() => {
|
|
240
316
|
if (!open) return;
|
|
241
317
|
const onMove = () => place();
|
|
242
318
|
window.addEventListener("scroll", onMove, { passive: true, capture: true });
|
|
@@ -255,17 +331,20 @@ var Tour = (props) => {
|
|
|
255
331
|
{
|
|
256
332
|
ref: cardRef,
|
|
257
333
|
className: "lib-xplat-tour-card",
|
|
334
|
+
style: { "--tour-card-width": typeof width === "number" ? `${width}px` : width },
|
|
258
335
|
role: "dialog",
|
|
259
336
|
"aria-modal": "true",
|
|
260
337
|
"aria-label": typeof step.title === "string" ? step.title : "\uD654\uBA74 \uC548\uB0B4",
|
|
261
338
|
children: [
|
|
262
|
-
/* @__PURE__ */ jsxs("div", { className: "tour-card-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
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 })
|
|
266
346
|
] }),
|
|
267
|
-
step.
|
|
268
|
-
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 }) }),
|
|
269
348
|
/* @__PURE__ */ jsxs("div", { className: "tour-card-actions", children: [
|
|
270
349
|
/* @__PURE__ */ jsx("button", { type: "button", className: "tour-skip", onClick: () => onClose("skip"), children: skipLabel }),
|
|
271
350
|
/* @__PURE__ */ jsxs("div", { className: "tour-card-nav", children: [
|