@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
|
@@ -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,13 +7789,35 @@ var Tour = (props) => {
|
|
|
7744
7789
|
);
|
|
7745
7790
|
useEscapeKey(open, () => onClose("skip"));
|
|
7746
7791
|
useFocusTrap(cardRef, open, { trap: true });
|
|
7747
|
-
|
|
7748
|
-
|
|
7749
|
-
|
|
7750
|
-
|
|
7751
|
-
|
|
7752
|
-
|
|
7753
|
-
|
|
7792
|
+
useScrollLock_default(open, cardRef);
|
|
7793
|
+
const stepsRef = import_react45.default.useRef(steps);
|
|
7794
|
+
stepsRef.current = steps;
|
|
7795
|
+
import_react45.default.useEffect(() => {
|
|
7796
|
+
if (!open) return;
|
|
7797
|
+
const target = stepsRef.current[index]?.target;
|
|
7798
|
+
if (!target) return;
|
|
7799
|
+
let stop = false;
|
|
7800
|
+
let tries = 0;
|
|
7801
|
+
const look = () => {
|
|
7802
|
+
if (stop) return;
|
|
7803
|
+
const el = resolve(target);
|
|
7804
|
+
if (el) {
|
|
7805
|
+
setTargetFound(true);
|
|
7806
|
+
el.scrollIntoView({ block: "center", inline: "nearest", behavior: "smooth" });
|
|
7807
|
+
return;
|
|
7808
|
+
}
|
|
7809
|
+
setTargetFound(false);
|
|
7810
|
+
if (tries < 60) {
|
|
7811
|
+
tries += 1;
|
|
7812
|
+
requestAnimationFrame(look);
|
|
7813
|
+
}
|
|
7814
|
+
};
|
|
7815
|
+
look();
|
|
7816
|
+
return () => {
|
|
7817
|
+
stop = true;
|
|
7818
|
+
};
|
|
7819
|
+
}, [open, index]);
|
|
7820
|
+
const place = import_react45.default.useCallback(() => {
|
|
7754
7821
|
const spot = spotRef.current;
|
|
7755
7822
|
const card = cardRef.current;
|
|
7756
7823
|
if (!spot || !card || !step) return;
|
|
@@ -7791,19 +7858,30 @@ var Tour = (props) => {
|
|
|
7791
7858
|
}
|
|
7792
7859
|
);
|
|
7793
7860
|
const limit = window.innerHeight - VIEWPORT_MARGIN * 2;
|
|
7794
|
-
const cardH = Math.min(
|
|
7861
|
+
const cardH = Math.min(card.scrollHeight, limit);
|
|
7795
7862
|
const cardW = card.offsetWidth;
|
|
7796
|
-
card.style.maxHeight = `${
|
|
7863
|
+
card.style.maxHeight = `${limit}px`;
|
|
7797
7864
|
card.style.top = `${clamp(placed.top, VIEWPORT_MARGIN, window.innerHeight - VIEWPORT_MARGIN - cardH)}px`;
|
|
7798
7865
|
card.style.left = `${clamp(placed.left, VIEWPORT_MARGIN, window.innerWidth - VIEWPORT_MARGIN - cardW)}px`;
|
|
7799
7866
|
}, [step]);
|
|
7800
|
-
|
|
7867
|
+
import_react45.default.useLayoutEffect(() => {
|
|
7801
7868
|
if (!open) return;
|
|
7802
7869
|
place();
|
|
7803
|
-
|
|
7804
|
-
|
|
7805
|
-
|
|
7806
|
-
|
|
7870
|
+
let raf = 0;
|
|
7871
|
+
let settled = 0;
|
|
7872
|
+
let last = "";
|
|
7873
|
+
const follow = () => {
|
|
7874
|
+
const el = resolve(stepsRef.current[index]?.target ?? "");
|
|
7875
|
+
const now = el ? JSON.stringify(el.getBoundingClientRect()) : "";
|
|
7876
|
+
settled = now === last ? settled + 1 : 0;
|
|
7877
|
+
last = now;
|
|
7878
|
+
place();
|
|
7879
|
+
if (settled < 3) raf = requestAnimationFrame(follow);
|
|
7880
|
+
};
|
|
7881
|
+
raf = requestAnimationFrame(follow);
|
|
7882
|
+
return () => cancelAnimationFrame(raf);
|
|
7883
|
+
}, [open, index, place]);
|
|
7884
|
+
import_react45.default.useEffect(() => {
|
|
7807
7885
|
if (!open) return;
|
|
7808
7886
|
const onMove = () => place();
|
|
7809
7887
|
window.addEventListener("scroll", onMove, { passive: true, capture: true });
|
|
@@ -7822,17 +7900,20 @@ var Tour = (props) => {
|
|
|
7822
7900
|
{
|
|
7823
7901
|
ref: cardRef,
|
|
7824
7902
|
className: "lib-xplat-tour-card",
|
|
7903
|
+
style: { "--tour-card-width": typeof width === "number" ? `${width}px` : width },
|
|
7825
7904
|
role: "dialog",
|
|
7826
7905
|
"aria-modal": "true",
|
|
7827
7906
|
"aria-label": typeof step.title === "string" ? step.title : "\uD654\uBA74 \uC548\uB0B4",
|
|
7828
7907
|
children: [
|
|
7829
|
-
/* @__PURE__ */ (0, import_jsx_runtime355.jsxs)("div", { className: "tour-card-
|
|
7830
|
-
|
|
7831
|
-
|
|
7832
|
-
|
|
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 })
|
|
7833
7915
|
] }),
|
|
7834
|
-
step.
|
|
7835
|
-
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 }) }),
|
|
7836
7917
|
/* @__PURE__ */ (0, import_jsx_runtime355.jsxs)("div", { className: "tour-card-actions", children: [
|
|
7837
7918
|
/* @__PURE__ */ (0, import_jsx_runtime355.jsx)("button", { type: "button", className: "tour-skip", onClick: () => onClose("skip"), children: skipLabel }),
|
|
7838
7919
|
/* @__PURE__ */ (0, import_jsx_runtime355.jsxs)("div", { className: "tour-card-nav", children: [
|
|
@@ -7865,7 +7946,7 @@ Tour.displayName = "Tour";
|
|
|
7865
7946
|
var Tour_default = Tour;
|
|
7866
7947
|
|
|
7867
7948
|
// src/components/Video/Video.tsx
|
|
7868
|
-
var
|
|
7949
|
+
var import_react46 = __toESM(require("react"), 1);
|
|
7869
7950
|
var import_jsx_runtime356 = require("react/jsx-runtime");
|
|
7870
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: [
|
|
7871
7952
|
/* @__PURE__ */ (0, import_jsx_runtime356.jsx)("rect", { x: "3", y: "5", width: "18", height: "14", rx: "2" }),
|
|
@@ -7877,7 +7958,7 @@ var formatTime = (sec) => {
|
|
|
7877
7958
|
const s = Math.floor(sec % 60);
|
|
7878
7959
|
return `${m}:${s.toString().padStart(2, "0")}`;
|
|
7879
7960
|
};
|
|
7880
|
-
var Video =
|
|
7961
|
+
var Video = import_react46.default.forwardRef((props, ref) => {
|
|
7881
7962
|
const {
|
|
7882
7963
|
src,
|
|
7883
7964
|
poster,
|
|
@@ -7901,21 +7982,21 @@ var Video = import_react45.default.forwardRef((props, ref) => {
|
|
|
7901
7982
|
children,
|
|
7902
7983
|
...rest
|
|
7903
7984
|
} = props;
|
|
7904
|
-
const containerRef =
|
|
7905
|
-
const videoRef =
|
|
7906
|
-
const [isPlaying, setIsPlaying] =
|
|
7907
|
-
const [isLoaded, setIsLoaded] =
|
|
7908
|
-
const [currentTime, setCurrentTime] =
|
|
7909
|
-
const [duration, setDuration] =
|
|
7910
|
-
const [buffered, setBuffered] =
|
|
7911
|
-
const [volume, setVolume] =
|
|
7912
|
-
const [isMuted, setIsMuted] =
|
|
7913
|
-
const [isFullscreen, setIsFullscreen] =
|
|
7914
|
-
const [playbackRate, setPlaybackRate] =
|
|
7915
|
-
const [rateMenuOpen, setRateMenuOpen] =
|
|
7916
|
-
const [captionsOn, setCaptionsOn] =
|
|
7917
|
-
const [isPip, setIsPip] =
|
|
7918
|
-
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(
|
|
7919
8000
|
(el) => {
|
|
7920
8001
|
videoRef.current = el;
|
|
7921
8002
|
if (typeof ref === "function") ref(el);
|
|
@@ -7923,14 +8004,14 @@ var Video = import_react45.default.forwardRef((props, ref) => {
|
|
|
7923
8004
|
},
|
|
7924
8005
|
[ref]
|
|
7925
8006
|
);
|
|
7926
|
-
|
|
8007
|
+
import_react46.default.useEffect(() => {
|
|
7927
8008
|
const onFsChange = () => {
|
|
7928
8009
|
setIsFullscreen(document.fullscreenElement === containerRef.current);
|
|
7929
8010
|
};
|
|
7930
8011
|
document.addEventListener("fullscreenchange", onFsChange);
|
|
7931
8012
|
return () => document.removeEventListener("fullscreenchange", onFsChange);
|
|
7932
8013
|
}, []);
|
|
7933
|
-
|
|
8014
|
+
import_react46.default.useEffect(() => {
|
|
7934
8015
|
const v = videoRef.current;
|
|
7935
8016
|
if (!v) return;
|
|
7936
8017
|
const onEnter = () => setIsPip(true);
|
|
@@ -5899,14 +5899,39 @@
|
|
|
5899
5899
|
position: fixed;
|
|
5900
5900
|
pointer-events: auto;
|
|
5901
5901
|
box-sizing: border-box;
|
|
5902
|
-
width:
|
|
5902
|
+
width: var(--tour-card-width, 380px);
|
|
5903
5903
|
max-width: calc(100vw - var(--spacing-space-8));
|
|
5904
|
-
|
|
5905
|
-
|
|
5904
|
+
display: flex;
|
|
5905
|
+
flex-direction: column;
|
|
5906
|
+
overflow: hidden;
|
|
5906
5907
|
border-radius: var(--spacing-radius-md);
|
|
5907
5908
|
background-color: var(--semantic-surface-neutral-primary);
|
|
5908
5909
|
box-shadow: var(--semantic-shadow-lg);
|
|
5909
5910
|
}
|
|
5911
|
+
.lib-xplat-tour-card > .tour-card-head,
|
|
5912
|
+
.lib-xplat-tour-card > .tour-card-body,
|
|
5913
|
+
.lib-xplat-tour-card > .tour-card-actions {
|
|
5914
|
+
padding-left: var(--spacing-space-4);
|
|
5915
|
+
padding-right: var(--spacing-space-4);
|
|
5916
|
+
}
|
|
5917
|
+
.lib-xplat-tour-card > .tour-card-head {
|
|
5918
|
+
padding-top: var(--spacing-space-4);
|
|
5919
|
+
flex: 0 0 auto;
|
|
5920
|
+
}
|
|
5921
|
+
.lib-xplat-tour-card {
|
|
5922
|
+
}
|
|
5923
|
+
.lib-xplat-tour-card > .tour-card-body {
|
|
5924
|
+
flex: 1 1 auto;
|
|
5925
|
+
min-height: 0;
|
|
5926
|
+
overflow-y: auto;
|
|
5927
|
+
padding-top: var(--spacing-space-2);
|
|
5928
|
+
padding-bottom: var(--spacing-space-2);
|
|
5929
|
+
}
|
|
5930
|
+
.lib-xplat-tour-card > .tour-card-actions {
|
|
5931
|
+
flex: 0 0 auto;
|
|
5932
|
+
padding-bottom: var(--spacing-space-4);
|
|
5933
|
+
padding-top: var(--spacing-space-2);
|
|
5934
|
+
}
|
|
5910
5935
|
.lib-xplat-tour-card .tour-card-progress {
|
|
5911
5936
|
font-family: var(--semantic-typo-caption-2-r-font);
|
|
5912
5937
|
font-size: var(--semantic-typo-caption-2-r-size);
|
|
@@ -5923,7 +5948,6 @@
|
|
|
5923
5948
|
font-weight: var(--semantic-typo-label-1-sb-weight);
|
|
5924
5949
|
letter-spacing: var(--semantic-typo-label-1-sb-ls);
|
|
5925
5950
|
color: var(--semantic-text-primary);
|
|
5926
|
-
margin-bottom: var(--spacing-space-2);
|
|
5927
5951
|
}
|
|
5928
5952
|
.lib-xplat-tour-card .tour-card-description {
|
|
5929
5953
|
font-family: var(--semantic-typo-caption-1-r-font);
|
|
@@ -5939,7 +5963,6 @@
|
|
|
5939
5963
|
align-items: center;
|
|
5940
5964
|
justify-content: space-between;
|
|
5941
5965
|
gap: var(--spacing-space-2);
|
|
5942
|
-
margin-top: var(--spacing-space-4);
|
|
5943
5966
|
}
|
|
5944
5967
|
.lib-xplat-tour-card .tour-card-nav {
|
|
5945
5968
|
display: flex;
|
package/dist/components/index.js
CHANGED
|
@@ -7604,7 +7604,51 @@ Tooltip.displayName = "Tooltip";
|
|
|
7604
7604
|
var Tooltip_default = Tooltip;
|
|
7605
7605
|
|
|
7606
7606
|
// src/components/Tour/Tour.tsx
|
|
7607
|
+
import React45 from "react";
|
|
7608
|
+
|
|
7609
|
+
// src/tokens/hooks/useScrollLock.ts
|
|
7607
7610
|
import React44 from "react";
|
|
7611
|
+
var SCROLL_KEYS = /* @__PURE__ */ new Set([
|
|
7612
|
+
" ",
|
|
7613
|
+
"PageUp",
|
|
7614
|
+
"PageDown",
|
|
7615
|
+
"Home",
|
|
7616
|
+
"End",
|
|
7617
|
+
"ArrowUp",
|
|
7618
|
+
"ArrowDown",
|
|
7619
|
+
"ArrowLeft",
|
|
7620
|
+
"ArrowRight"
|
|
7621
|
+
]);
|
|
7622
|
+
var useScrollLock = (enabled, allowRef) => {
|
|
7623
|
+
React44.useEffect(() => {
|
|
7624
|
+
if (!enabled) return;
|
|
7625
|
+
const allowed = (target) => target instanceof Node && !!allowRef?.current?.contains(target);
|
|
7626
|
+
const block = (e) => {
|
|
7627
|
+
if (allowed(e.target)) return;
|
|
7628
|
+
e.preventDefault();
|
|
7629
|
+
};
|
|
7630
|
+
const onKey = (e) => {
|
|
7631
|
+
if (!SCROLL_KEYS.has(e.key)) return;
|
|
7632
|
+
if (allowed(e.target)) return;
|
|
7633
|
+
const el = e.target;
|
|
7634
|
+
const tag = el?.tagName;
|
|
7635
|
+
if (tag === "INPUT" || tag === "TEXTAREA" || el?.isContentEditable) return;
|
|
7636
|
+
e.preventDefault();
|
|
7637
|
+
};
|
|
7638
|
+
const opts = { passive: false, capture: true };
|
|
7639
|
+
window.addEventListener("wheel", block, opts);
|
|
7640
|
+
window.addEventListener("touchmove", block, opts);
|
|
7641
|
+
window.addEventListener("keydown", onKey, opts);
|
|
7642
|
+
return () => {
|
|
7643
|
+
window.removeEventListener("wheel", block, true);
|
|
7644
|
+
window.removeEventListener("touchmove", block, true);
|
|
7645
|
+
window.removeEventListener("keydown", onKey, true);
|
|
7646
|
+
};
|
|
7647
|
+
}, [enabled, allowRef]);
|
|
7648
|
+
};
|
|
7649
|
+
var useScrollLock_default = useScrollLock;
|
|
7650
|
+
|
|
7651
|
+
// src/components/Tour/Tour.tsx
|
|
7608
7652
|
import { jsx as jsx355, jsxs as jsxs225 } from "react/jsx-runtime";
|
|
7609
7653
|
var VIEWPORT_MARGIN = 16;
|
|
7610
7654
|
var DEFAULT_PADDING = 8;
|
|
@@ -7620,19 +7664,20 @@ var Tour = (props) => {
|
|
|
7620
7664
|
onClose,
|
|
7621
7665
|
current,
|
|
7622
7666
|
onStepChange,
|
|
7667
|
+
width = 380,
|
|
7623
7668
|
nextLabel = "\uB2E4\uC74C",
|
|
7624
7669
|
prevLabel = "\uC774\uC804",
|
|
7625
7670
|
skipLabel = "\uAC74\uB108\uB6F0\uAE30",
|
|
7626
7671
|
doneLabel = "\uB2E4 \uBD24\uC5B4\uC694"
|
|
7627
7672
|
} = props;
|
|
7628
|
-
const [uncontrolled, setUncontrolled] =
|
|
7673
|
+
const [uncontrolled, setUncontrolled] = React45.useState(0);
|
|
7629
7674
|
const index = current ?? uncontrolled;
|
|
7630
7675
|
const step = steps[index];
|
|
7631
7676
|
const isLast = index === steps.length - 1;
|
|
7632
|
-
const spotRef =
|
|
7633
|
-
const cardRef =
|
|
7634
|
-
const [targetFound, setTargetFound] =
|
|
7635
|
-
const goTo =
|
|
7677
|
+
const spotRef = React45.useRef(null);
|
|
7678
|
+
const cardRef = React45.useRef(null);
|
|
7679
|
+
const [targetFound, setTargetFound] = React45.useState(true);
|
|
7680
|
+
const goTo = React45.useCallback(
|
|
7636
7681
|
(next) => {
|
|
7637
7682
|
if (current === void 0) setUncontrolled(next);
|
|
7638
7683
|
onStepChange?.(next);
|
|
@@ -7641,13 +7686,35 @@ var Tour = (props) => {
|
|
|
7641
7686
|
);
|
|
7642
7687
|
useEscapeKey(open, () => onClose("skip"));
|
|
7643
7688
|
useFocusTrap(cardRef, open, { trap: true });
|
|
7644
|
-
|
|
7645
|
-
|
|
7646
|
-
|
|
7647
|
-
|
|
7648
|
-
|
|
7649
|
-
|
|
7650
|
-
|
|
7689
|
+
useScrollLock_default(open, cardRef);
|
|
7690
|
+
const stepsRef = React45.useRef(steps);
|
|
7691
|
+
stepsRef.current = steps;
|
|
7692
|
+
React45.useEffect(() => {
|
|
7693
|
+
if (!open) return;
|
|
7694
|
+
const target = stepsRef.current[index]?.target;
|
|
7695
|
+
if (!target) return;
|
|
7696
|
+
let stop = false;
|
|
7697
|
+
let tries = 0;
|
|
7698
|
+
const look = () => {
|
|
7699
|
+
if (stop) return;
|
|
7700
|
+
const el = resolve(target);
|
|
7701
|
+
if (el) {
|
|
7702
|
+
setTargetFound(true);
|
|
7703
|
+
el.scrollIntoView({ block: "center", inline: "nearest", behavior: "smooth" });
|
|
7704
|
+
return;
|
|
7705
|
+
}
|
|
7706
|
+
setTargetFound(false);
|
|
7707
|
+
if (tries < 60) {
|
|
7708
|
+
tries += 1;
|
|
7709
|
+
requestAnimationFrame(look);
|
|
7710
|
+
}
|
|
7711
|
+
};
|
|
7712
|
+
look();
|
|
7713
|
+
return () => {
|
|
7714
|
+
stop = true;
|
|
7715
|
+
};
|
|
7716
|
+
}, [open, index]);
|
|
7717
|
+
const place = React45.useCallback(() => {
|
|
7651
7718
|
const spot = spotRef.current;
|
|
7652
7719
|
const card = cardRef.current;
|
|
7653
7720
|
if (!spot || !card || !step) return;
|
|
@@ -7688,19 +7755,30 @@ var Tour = (props) => {
|
|
|
7688
7755
|
}
|
|
7689
7756
|
);
|
|
7690
7757
|
const limit = window.innerHeight - VIEWPORT_MARGIN * 2;
|
|
7691
|
-
const cardH = Math.min(
|
|
7758
|
+
const cardH = Math.min(card.scrollHeight, limit);
|
|
7692
7759
|
const cardW = card.offsetWidth;
|
|
7693
|
-
card.style.maxHeight = `${
|
|
7760
|
+
card.style.maxHeight = `${limit}px`;
|
|
7694
7761
|
card.style.top = `${clamp(placed.top, VIEWPORT_MARGIN, window.innerHeight - VIEWPORT_MARGIN - cardH)}px`;
|
|
7695
7762
|
card.style.left = `${clamp(placed.left, VIEWPORT_MARGIN, window.innerWidth - VIEWPORT_MARGIN - cardW)}px`;
|
|
7696
7763
|
}, [step]);
|
|
7697
|
-
|
|
7764
|
+
React45.useLayoutEffect(() => {
|
|
7698
7765
|
if (!open) return;
|
|
7699
7766
|
place();
|
|
7700
|
-
|
|
7701
|
-
|
|
7702
|
-
|
|
7703
|
-
|
|
7767
|
+
let raf = 0;
|
|
7768
|
+
let settled = 0;
|
|
7769
|
+
let last = "";
|
|
7770
|
+
const follow = () => {
|
|
7771
|
+
const el = resolve(stepsRef.current[index]?.target ?? "");
|
|
7772
|
+
const now = el ? JSON.stringify(el.getBoundingClientRect()) : "";
|
|
7773
|
+
settled = now === last ? settled + 1 : 0;
|
|
7774
|
+
last = now;
|
|
7775
|
+
place();
|
|
7776
|
+
if (settled < 3) raf = requestAnimationFrame(follow);
|
|
7777
|
+
};
|
|
7778
|
+
raf = requestAnimationFrame(follow);
|
|
7779
|
+
return () => cancelAnimationFrame(raf);
|
|
7780
|
+
}, [open, index, place]);
|
|
7781
|
+
React45.useEffect(() => {
|
|
7704
7782
|
if (!open) return;
|
|
7705
7783
|
const onMove = () => place();
|
|
7706
7784
|
window.addEventListener("scroll", onMove, { passive: true, capture: true });
|
|
@@ -7719,17 +7797,20 @@ var Tour = (props) => {
|
|
|
7719
7797
|
{
|
|
7720
7798
|
ref: cardRef,
|
|
7721
7799
|
className: "lib-xplat-tour-card",
|
|
7800
|
+
style: { "--tour-card-width": typeof width === "number" ? `${width}px` : width },
|
|
7722
7801
|
role: "dialog",
|
|
7723
7802
|
"aria-modal": "true",
|
|
7724
7803
|
"aria-label": typeof step.title === "string" ? step.title : "\uD654\uBA74 \uC548\uB0B4",
|
|
7725
7804
|
children: [
|
|
7726
|
-
/* @__PURE__ */ jsxs225("div", { className: "tour-card-
|
|
7727
|
-
|
|
7728
|
-
|
|
7729
|
-
|
|
7805
|
+
/* @__PURE__ */ jsxs225("div", { className: "tour-card-head", children: [
|
|
7806
|
+
/* @__PURE__ */ jsxs225("div", { className: "tour-card-progress", "aria-hidden": true, children: [
|
|
7807
|
+
index + 1,
|
|
7808
|
+
" / ",
|
|
7809
|
+
steps.length
|
|
7810
|
+
] }),
|
|
7811
|
+
step.title && /* @__PURE__ */ jsx355("div", { className: "tour-card-title", children: step.title })
|
|
7730
7812
|
] }),
|
|
7731
|
-
step.
|
|
7732
|
-
step.description && /* @__PURE__ */ jsx355("div", { className: "tour-card-description", children: step.description }),
|
|
7813
|
+
/* @__PURE__ */ jsx355("div", { className: "tour-card-body", children: step.description && /* @__PURE__ */ jsx355("div", { className: "tour-card-description", children: step.description }) }),
|
|
7733
7814
|
/* @__PURE__ */ jsxs225("div", { className: "tour-card-actions", children: [
|
|
7734
7815
|
/* @__PURE__ */ jsx355("button", { type: "button", className: "tour-skip", onClick: () => onClose("skip"), children: skipLabel }),
|
|
7735
7816
|
/* @__PURE__ */ jsxs225("div", { className: "tour-card-nav", children: [
|
|
@@ -7762,7 +7843,7 @@ Tour.displayName = "Tour";
|
|
|
7762
7843
|
var Tour_default = Tour;
|
|
7763
7844
|
|
|
7764
7845
|
// src/components/Video/Video.tsx
|
|
7765
|
-
import
|
|
7846
|
+
import React46 from "react";
|
|
7766
7847
|
import { jsx as jsx356, jsxs as jsxs226 } from "react/jsx-runtime";
|
|
7767
7848
|
var PipIcon = () => /* @__PURE__ */ jsxs226("svg", { viewBox: "0 0 24 24", width: "1em", height: "1em", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
|
|
7768
7849
|
/* @__PURE__ */ jsx356("rect", { x: "3", y: "5", width: "18", height: "14", rx: "2" }),
|
|
@@ -7774,7 +7855,7 @@ var formatTime = (sec) => {
|
|
|
7774
7855
|
const s = Math.floor(sec % 60);
|
|
7775
7856
|
return `${m}:${s.toString().padStart(2, "0")}`;
|
|
7776
7857
|
};
|
|
7777
|
-
var Video =
|
|
7858
|
+
var Video = React46.forwardRef((props, ref) => {
|
|
7778
7859
|
const {
|
|
7779
7860
|
src,
|
|
7780
7861
|
poster,
|
|
@@ -7798,21 +7879,21 @@ var Video = React45.forwardRef((props, ref) => {
|
|
|
7798
7879
|
children,
|
|
7799
7880
|
...rest
|
|
7800
7881
|
} = props;
|
|
7801
|
-
const containerRef =
|
|
7802
|
-
const videoRef =
|
|
7803
|
-
const [isPlaying, setIsPlaying] =
|
|
7804
|
-
const [isLoaded, setIsLoaded] =
|
|
7805
|
-
const [currentTime, setCurrentTime] =
|
|
7806
|
-
const [duration, setDuration] =
|
|
7807
|
-
const [buffered, setBuffered] =
|
|
7808
|
-
const [volume, setVolume] =
|
|
7809
|
-
const [isMuted, setIsMuted] =
|
|
7810
|
-
const [isFullscreen, setIsFullscreen] =
|
|
7811
|
-
const [playbackRate, setPlaybackRate] =
|
|
7812
|
-
const [rateMenuOpen, setRateMenuOpen] =
|
|
7813
|
-
const [captionsOn, setCaptionsOn] =
|
|
7814
|
-
const [isPip, setIsPip] =
|
|
7815
|
-
const setRefs =
|
|
7882
|
+
const containerRef = React46.useRef(null);
|
|
7883
|
+
const videoRef = React46.useRef(null);
|
|
7884
|
+
const [isPlaying, setIsPlaying] = React46.useState(Boolean(autoPlay));
|
|
7885
|
+
const [isLoaded, setIsLoaded] = React46.useState(false);
|
|
7886
|
+
const [currentTime, setCurrentTime] = React46.useState(0);
|
|
7887
|
+
const [duration, setDuration] = React46.useState(0);
|
|
7888
|
+
const [buffered, setBuffered] = React46.useState(0);
|
|
7889
|
+
const [volume, setVolume] = React46.useState(1);
|
|
7890
|
+
const [isMuted, setIsMuted] = React46.useState(Boolean(muted));
|
|
7891
|
+
const [isFullscreen, setIsFullscreen] = React46.useState(false);
|
|
7892
|
+
const [playbackRate, setPlaybackRate] = React46.useState(1);
|
|
7893
|
+
const [rateMenuOpen, setRateMenuOpen] = React46.useState(false);
|
|
7894
|
+
const [captionsOn, setCaptionsOn] = React46.useState(false);
|
|
7895
|
+
const [isPip, setIsPip] = React46.useState(false);
|
|
7896
|
+
const setRefs = React46.useCallback(
|
|
7816
7897
|
(el) => {
|
|
7817
7898
|
videoRef.current = el;
|
|
7818
7899
|
if (typeof ref === "function") ref(el);
|
|
@@ -7820,14 +7901,14 @@ var Video = React45.forwardRef((props, ref) => {
|
|
|
7820
7901
|
},
|
|
7821
7902
|
[ref]
|
|
7822
7903
|
);
|
|
7823
|
-
|
|
7904
|
+
React46.useEffect(() => {
|
|
7824
7905
|
const onFsChange = () => {
|
|
7825
7906
|
setIsFullscreen(document.fullscreenElement === containerRef.current);
|
|
7826
7907
|
};
|
|
7827
7908
|
document.addEventListener("fullscreenchange", onFsChange);
|
|
7828
7909
|
return () => document.removeEventListener("fullscreenchange", onFsChange);
|
|
7829
7910
|
}, []);
|
|
7830
|
-
|
|
7911
|
+
React46.useEffect(() => {
|
|
7831
7912
|
const v = videoRef.current;
|
|
7832
7913
|
if (!v) return;
|
|
7833
7914
|
const onEnter = () => setIsPip(true);
|