@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/index.js CHANGED
@@ -11707,7 +11707,51 @@ Tooltip.displayName = "Tooltip";
11707
11707
  var Tooltip_default = Tooltip;
11708
11708
 
11709
11709
  // src/components/Tour/Tour.tsx
11710
+ import React45 from "react";
11711
+
11712
+ // src/tokens/hooks/useScrollLock.ts
11710
11713
  import React44 from "react";
11714
+ var SCROLL_KEYS = /* @__PURE__ */ new Set([
11715
+ " ",
11716
+ "PageUp",
11717
+ "PageDown",
11718
+ "Home",
11719
+ "End",
11720
+ "ArrowUp",
11721
+ "ArrowDown",
11722
+ "ArrowLeft",
11723
+ "ArrowRight"
11724
+ ]);
11725
+ var useScrollLock = (enabled, allowRef) => {
11726
+ React44.useEffect(() => {
11727
+ if (!enabled) return;
11728
+ const allowed = (target) => target instanceof Node && !!allowRef?.current?.contains(target);
11729
+ const block = (e) => {
11730
+ if (allowed(e.target)) return;
11731
+ e.preventDefault();
11732
+ };
11733
+ const onKey = (e) => {
11734
+ if (!SCROLL_KEYS.has(e.key)) return;
11735
+ if (allowed(e.target)) return;
11736
+ const el = e.target;
11737
+ const tag = el?.tagName;
11738
+ if (tag === "INPUT" || tag === "TEXTAREA" || el?.isContentEditable) return;
11739
+ e.preventDefault();
11740
+ };
11741
+ const opts = { passive: false, capture: true };
11742
+ window.addEventListener("wheel", block, opts);
11743
+ window.addEventListener("touchmove", block, opts);
11744
+ window.addEventListener("keydown", onKey, opts);
11745
+ return () => {
11746
+ window.removeEventListener("wheel", block, true);
11747
+ window.removeEventListener("touchmove", block, true);
11748
+ window.removeEventListener("keydown", onKey, true);
11749
+ };
11750
+ }, [enabled, allowRef]);
11751
+ };
11752
+ var useScrollLock_default = useScrollLock;
11753
+
11754
+ // src/components/Tour/Tour.tsx
11711
11755
  import { jsx as jsx355, jsxs as jsxs225 } from "react/jsx-runtime";
11712
11756
  var VIEWPORT_MARGIN = 16;
11713
11757
  var DEFAULT_PADDING = 8;
@@ -11723,19 +11767,20 @@ var Tour = (props) => {
11723
11767
  onClose,
11724
11768
  current,
11725
11769
  onStepChange,
11770
+ width = 380,
11726
11771
  nextLabel = "\uB2E4\uC74C",
11727
11772
  prevLabel = "\uC774\uC804",
11728
11773
  skipLabel = "\uAC74\uB108\uB6F0\uAE30",
11729
11774
  doneLabel = "\uB2E4 \uBD24\uC5B4\uC694"
11730
11775
  } = props;
11731
- const [uncontrolled, setUncontrolled] = React44.useState(0);
11776
+ const [uncontrolled, setUncontrolled] = React45.useState(0);
11732
11777
  const index = current ?? uncontrolled;
11733
11778
  const step = steps[index];
11734
11779
  const isLast = index === steps.length - 1;
11735
- const spotRef = React44.useRef(null);
11736
- const cardRef = React44.useRef(null);
11737
- const [targetFound, setTargetFound] = React44.useState(true);
11738
- const goTo = React44.useCallback(
11780
+ const spotRef = React45.useRef(null);
11781
+ const cardRef = React45.useRef(null);
11782
+ const [targetFound, setTargetFound] = React45.useState(true);
11783
+ const goTo = React45.useCallback(
11739
11784
  (next) => {
11740
11785
  if (current === void 0) setUncontrolled(next);
11741
11786
  onStepChange?.(next);
@@ -11744,9 +11789,10 @@ var Tour = (props) => {
11744
11789
  );
11745
11790
  useEscapeKey(open, () => onClose("skip"));
11746
11791
  useFocusTrap(cardRef, open, { trap: true });
11747
- const stepsRef = React44.useRef(steps);
11792
+ useScrollLock_default(open, cardRef);
11793
+ const stepsRef = React45.useRef(steps);
11748
11794
  stepsRef.current = steps;
11749
- React44.useEffect(() => {
11795
+ React45.useEffect(() => {
11750
11796
  if (!open) return;
11751
11797
  const target = stepsRef.current[index]?.target;
11752
11798
  if (!target) return;
@@ -11771,7 +11817,7 @@ var Tour = (props) => {
11771
11817
  stop = true;
11772
11818
  };
11773
11819
  }, [open, index]);
11774
- const place = React44.useCallback(() => {
11820
+ const place = React45.useCallback(() => {
11775
11821
  const spot = spotRef.current;
11776
11822
  const card = cardRef.current;
11777
11823
  if (!spot || !card || !step) return;
@@ -11812,13 +11858,13 @@ var Tour = (props) => {
11812
11858
  }
11813
11859
  );
11814
11860
  const limit = window.innerHeight - VIEWPORT_MARGIN * 2;
11815
- const cardH = Math.min(placed.maxHeight ?? card.offsetHeight, limit);
11861
+ const cardH = Math.min(card.scrollHeight, limit);
11816
11862
  const cardW = card.offsetWidth;
11817
- card.style.maxHeight = `${cardH}px`;
11863
+ card.style.maxHeight = `${limit}px`;
11818
11864
  card.style.top = `${clamp(placed.top, VIEWPORT_MARGIN, window.innerHeight - VIEWPORT_MARGIN - cardH)}px`;
11819
11865
  card.style.left = `${clamp(placed.left, VIEWPORT_MARGIN, window.innerWidth - VIEWPORT_MARGIN - cardW)}px`;
11820
11866
  }, [step]);
11821
- React44.useLayoutEffect(() => {
11867
+ React45.useLayoutEffect(() => {
11822
11868
  if (!open) return;
11823
11869
  place();
11824
11870
  let raf = 0;
@@ -11835,7 +11881,7 @@ var Tour = (props) => {
11835
11881
  raf = requestAnimationFrame(follow);
11836
11882
  return () => cancelAnimationFrame(raf);
11837
11883
  }, [open, index, place]);
11838
- React44.useEffect(() => {
11884
+ React45.useEffect(() => {
11839
11885
  if (!open) return;
11840
11886
  const onMove = () => place();
11841
11887
  window.addEventListener("scroll", onMove, { passive: true, capture: true });
@@ -11854,17 +11900,20 @@ var Tour = (props) => {
11854
11900
  {
11855
11901
  ref: cardRef,
11856
11902
  className: "lib-xplat-tour-card",
11903
+ style: { "--tour-card-width": typeof width === "number" ? `${width}px` : width },
11857
11904
  role: "dialog",
11858
11905
  "aria-modal": "true",
11859
11906
  "aria-label": typeof step.title === "string" ? step.title : "\uD654\uBA74 \uC548\uB0B4",
11860
11907
  children: [
11861
- /* @__PURE__ */ jsxs225("div", { className: "tour-card-progress", "aria-hidden": true, children: [
11862
- index + 1,
11863
- " / ",
11864
- steps.length
11908
+ /* @__PURE__ */ jsxs225("div", { className: "tour-card-head", children: [
11909
+ /* @__PURE__ */ jsxs225("div", { className: "tour-card-progress", "aria-hidden": true, children: [
11910
+ index + 1,
11911
+ " / ",
11912
+ steps.length
11913
+ ] }),
11914
+ step.title && /* @__PURE__ */ jsx355("div", { className: "tour-card-title", children: step.title })
11865
11915
  ] }),
11866
- step.title && /* @__PURE__ */ jsx355("div", { className: "tour-card-title", children: step.title }),
11867
- step.description && /* @__PURE__ */ jsx355("div", { className: "tour-card-description", children: step.description }),
11916
+ /* @__PURE__ */ jsx355("div", { className: "tour-card-body", children: step.description && /* @__PURE__ */ jsx355("div", { className: "tour-card-description", children: step.description }) }),
11868
11917
  /* @__PURE__ */ jsxs225("div", { className: "tour-card-actions", children: [
11869
11918
  /* @__PURE__ */ jsx355("button", { type: "button", className: "tour-skip", onClick: () => onClose("skip"), children: skipLabel }),
11870
11919
  /* @__PURE__ */ jsxs225("div", { className: "tour-card-nav", children: [
@@ -11897,7 +11946,7 @@ Tour.displayName = "Tour";
11897
11946
  var Tour_default = Tour;
11898
11947
 
11899
11948
  // src/components/Video/Video.tsx
11900
- import React45 from "react";
11949
+ import React46 from "react";
11901
11950
  import { jsx as jsx356, jsxs as jsxs226 } from "react/jsx-runtime";
11902
11951
  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: [
11903
11952
  /* @__PURE__ */ jsx356("rect", { x: "3", y: "5", width: "18", height: "14", rx: "2" }),
@@ -11909,7 +11958,7 @@ var formatTime = (sec) => {
11909
11958
  const s = Math.floor(sec % 60);
11910
11959
  return `${m}:${s.toString().padStart(2, "0")}`;
11911
11960
  };
11912
- var Video = React45.forwardRef((props, ref) => {
11961
+ var Video = React46.forwardRef((props, ref) => {
11913
11962
  const {
11914
11963
  src,
11915
11964
  poster,
@@ -11933,21 +11982,21 @@ var Video = React45.forwardRef((props, ref) => {
11933
11982
  children,
11934
11983
  ...rest
11935
11984
  } = props;
11936
- const containerRef = React45.useRef(null);
11937
- const videoRef = React45.useRef(null);
11938
- const [isPlaying, setIsPlaying] = React45.useState(Boolean(autoPlay));
11939
- const [isLoaded, setIsLoaded] = React45.useState(false);
11940
- const [currentTime, setCurrentTime] = React45.useState(0);
11941
- const [duration, setDuration] = React45.useState(0);
11942
- const [buffered, setBuffered] = React45.useState(0);
11943
- const [volume, setVolume] = React45.useState(1);
11944
- const [isMuted, setIsMuted] = React45.useState(Boolean(muted));
11945
- const [isFullscreen, setIsFullscreen] = React45.useState(false);
11946
- const [playbackRate, setPlaybackRate] = React45.useState(1);
11947
- const [rateMenuOpen, setRateMenuOpen] = React45.useState(false);
11948
- const [captionsOn, setCaptionsOn] = React45.useState(false);
11949
- const [isPip, setIsPip] = React45.useState(false);
11950
- const setRefs = React45.useCallback(
11985
+ const containerRef = React46.useRef(null);
11986
+ const videoRef = React46.useRef(null);
11987
+ const [isPlaying, setIsPlaying] = React46.useState(Boolean(autoPlay));
11988
+ const [isLoaded, setIsLoaded] = React46.useState(false);
11989
+ const [currentTime, setCurrentTime] = React46.useState(0);
11990
+ const [duration, setDuration] = React46.useState(0);
11991
+ const [buffered, setBuffered] = React46.useState(0);
11992
+ const [volume, setVolume] = React46.useState(1);
11993
+ const [isMuted, setIsMuted] = React46.useState(Boolean(muted));
11994
+ const [isFullscreen, setIsFullscreen] = React46.useState(false);
11995
+ const [playbackRate, setPlaybackRate] = React46.useState(1);
11996
+ const [rateMenuOpen, setRateMenuOpen] = React46.useState(false);
11997
+ const [captionsOn, setCaptionsOn] = React46.useState(false);
11998
+ const [isPip, setIsPip] = React46.useState(false);
11999
+ const setRefs = React46.useCallback(
11951
12000
  (el) => {
11952
12001
  videoRef.current = el;
11953
12002
  if (typeof ref === "function") ref(el);
@@ -11955,14 +12004,14 @@ var Video = React45.forwardRef((props, ref) => {
11955
12004
  },
11956
12005
  [ref]
11957
12006
  );
11958
- React45.useEffect(() => {
12007
+ React46.useEffect(() => {
11959
12008
  const onFsChange = () => {
11960
12009
  setIsFullscreen(document.fullscreenElement === containerRef.current);
11961
12010
  };
11962
12011
  document.addEventListener("fullscreenchange", onFsChange);
11963
12012
  return () => document.removeEventListener("fullscreenchange", onFsChange);
11964
12013
  }, []);
11965
- React45.useEffect(() => {
12014
+ React46.useEffect(() => {
11966
12015
  const v = videoRef.current;
11967
12016
  if (!v) return;
11968
12017
  const onEnter = () => setIsPip(true);
@@ -12352,13 +12401,13 @@ Layout.displayName = "Layout";
12352
12401
  var Layout_default = Layout;
12353
12402
 
12354
12403
  // src/layout/SideBar/SideBar.tsx
12355
- import React47 from "react";
12404
+ import React48 from "react";
12356
12405
 
12357
12406
  // src/layout/SideBar/SideBarContext.tsx
12358
- import React46 from "react";
12359
- var SideBarContext = React46.createContext(null);
12407
+ import React47 from "react";
12408
+ var SideBarContext = React47.createContext(null);
12360
12409
  var useSideBarContext = () => {
12361
- const ctx = React46.useContext(SideBarContext);
12410
+ const ctx = React47.useContext(SideBarContext);
12362
12411
  if (!ctx) throw new Error("Error");
12363
12412
  return ctx;
12364
12413
  };
@@ -12368,7 +12417,7 @@ var SideBarContext_default = SideBarContext;
12368
12417
  import { jsx as jsx362 } from "react/jsx-runtime";
12369
12418
  var SideBar = (props) => {
12370
12419
  const { children, className } = props;
12371
- const [isOpen, setIsOpen] = React47.useState(true);
12420
+ const [isOpen, setIsOpen] = React48.useState(true);
12372
12421
  const handleSwitchSideBar = () => {
12373
12422
  setIsOpen((prev) => !prev);
12374
12423
  };
@@ -34,6 +34,7 @@ const [guide, setGuide] = useState(true);
34
34
  | prevLabel | `string` | `"이전"` | |
35
35
  | skipLabel | `string` | `"건너뛰기"` | |
36
36
  | doneLabel | `string` | `"다 봤어요"` | |
37
+ | width | `number \| string` | `380` | 말풍선 너비. 숫자면 px. 화면이 좁으면 그만큼 줄어든다 |
37
38
 
38
39
  ### TourStep
39
40
 
@@ -77,10 +78,26 @@ const [guide, setGuide] = useState(true);
77
78
  (건너뜀) 인지만 알려 주고, 저장할지·어디에 할지는 쓰는 쪽이 정한다 —
78
79
  화면마다 다르고 저장 자리(로컬·서버)도 제각각이다.
79
80
 
80
- ## 눌림
81
+ ## 말풍선
81
82
 
82
- 안내 중에는 **아무것도 안 눌린다** — 구멍 안쪽까지 포함해서. 가리키는 것만
83
- 보여 주고, 실제로 누르는 것은 안내가 끝난 뒤다.
83
+ 설명이 길면 **설명 칸만 구른다.** 머리말(차례·제목)과 버튼은 제자리에 있다.
84
+
85
+ 크기는 **내용만큼** 잡고 화면보다 길 때만 화면에 맞춘다. 대상 둘레에 자리가
86
+ 모자라도 말풍선을 줄이지 않는다 — 자리를 옮겨서 피한다. 줄이면 읽을 수가 없다.
87
+
88
+ 너비는 `width` 로 바꾼다.
89
+
90
+ ## 눌림과 스크롤
91
+
92
+ 안내 중에는 **아무것도 안 눌리고 굴러가지도 않는다** — 구멍 안쪽까지 포함해서.
93
+ 가리키는 것만 보여 주고, 실제로 만지는 것은 안내가 끝난 뒤다.
94
+
95
+ 막는 것은 **사용자가 직접 구르는 것**(휠·손가락·키)뿐이다. `body` 에
96
+ `overflow: hidden` 을 거는 흔한 방법은 페이지만 막아서, DS `Layout` 처럼 본문만
97
+ 구르는 화면에서는 아무것도 안 막힌다. 입력을 막으면 어느 상자가 구르든 걸린다.
98
+
99
+ 투어가 대상을 데려오는 스크롤은 **그대로 돈다** — 입력만 막기 때문이다.
100
+ 말풍선 안 설명도 구를 수 있다.
84
101
 
85
102
  ## 키보드
86
103
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@x-plat/design-system",
3
- "version": "0.16.2",
3
+ "version": "0.16.3",
4
4
  "description": "XPLAT UI Design System",
5
5
  "author": "XPLAT WOONG",
6
6
  "main": "dist/index.cjs",