@x-plat/design-system 0.16.2 → 0.17.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.
@@ -57,13 +57,17 @@ var Table = (props) => {
57
57
  rowBorderUse = true,
58
58
  colBorderUse = true,
59
59
  headerSticky = false,
60
- stickyShadow = true
60
+ stickyShadow = true,
61
+ minWidth
61
62
  } = props;
62
63
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
63
64
  "div",
64
65
  {
65
66
  className: `lib-xplat-table-wrapper ${size}`,
66
67
  "data-xplat-overlay-escape": "",
68
+ style: minWidth === void 0 ? void 0 : {
69
+ "--table-min-width": typeof minWidth === "number" ? `${minWidth}px` : minWidth
70
+ },
67
71
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
68
72
  TableContext_default.Provider,
69
73
  {
@@ -47,7 +47,7 @@
47
47
  }
48
48
  .lib-xplat-table-wrapper > .lib-xplat-table {
49
49
  width: 100%;
50
- min-width: 600px;
50
+ min-width: var(--table-min-width, 600px);
51
51
  }
52
52
  .lib-xplat-table-wrapper > .lib-xplat-table > thead.table-sticky {
53
53
  position: sticky;
@@ -9,6 +9,16 @@ interface TableProps {
9
9
  colBorderUse?: boolean;
10
10
  headerSticky?: boolean;
11
11
  stickyShadow?: boolean;
12
+ /**
13
+ * 표가 줄어들 수 있는 **최소 너비**. 숫자면 px. 기본 `600`.
14
+ *
15
+ * 그보다 좁은 자리에 넣으면 표가 쪼그라드는 대신 **가로로 밀린다.** 칸 하나가
16
+ * 최소 80px 이라 600px 은 "칸 일고여덟은 들어가야 표답다" 는 뜻이다.
17
+ *
18
+ * 그런데 칸이 서넛뿐인 표에는 과하다 — 반쪽 카드에 넣으면 밀려서 오른쪽이
19
+ * 안 보인다. 칸 수에 맞춰 낮추면 된다 (칸 3개면 `240` 쯤).
20
+ */
21
+ minWidth?: number | string;
12
22
  }
13
23
  declare const Table: {
14
24
  (props: TableProps): react_jsx_runtime.JSX.Element;
@@ -9,6 +9,16 @@ interface TableProps {
9
9
  colBorderUse?: boolean;
10
10
  headerSticky?: boolean;
11
11
  stickyShadow?: boolean;
12
+ /**
13
+ * 표가 줄어들 수 있는 **최소 너비**. 숫자면 px. 기본 `600`.
14
+ *
15
+ * 그보다 좁은 자리에 넣으면 표가 쪼그라드는 대신 **가로로 밀린다.** 칸 하나가
16
+ * 최소 80px 이라 600px 은 "칸 일고여덟은 들어가야 표답다" 는 뜻이다.
17
+ *
18
+ * 그런데 칸이 서넛뿐인 표에는 과하다 — 반쪽 카드에 넣으면 밀려서 오른쪽이
19
+ * 안 보인다. 칸 수에 맞춰 낮추면 된다 (칸 3개면 `240` 쯤).
20
+ */
21
+ minWidth?: number | string;
12
22
  }
13
23
  declare const Table: {
14
24
  (props: TableProps): react_jsx_runtime.JSX.Element;
@@ -17,13 +17,17 @@ var Table = (props) => {
17
17
  rowBorderUse = true,
18
18
  colBorderUse = true,
19
19
  headerSticky = false,
20
- stickyShadow = true
20
+ stickyShadow = true,
21
+ minWidth
21
22
  } = props;
22
23
  return /* @__PURE__ */ jsx(
23
24
  "div",
24
25
  {
25
26
  className: `lib-xplat-table-wrapper ${size}`,
26
27
  "data-xplat-overlay-escape": "",
28
+ style: minWidth === void 0 ? void 0 : {
29
+ "--table-min-width": typeof minWidth === "number" ? `${minWidth}px` : minWidth
30
+ },
27
31
  children: /* @__PURE__ */ jsx(
28
32
  TableContext_default.Provider,
29
33
  {
@@ -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 import_react3 = __toESM(require("react"), 1);
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] = import_react3.default.useState(0);
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 = import_react3.default.useRef(null);
205
- const cardRef = import_react3.default.useRef(null);
206
- const [targetFound, setTargetFound] = import_react3.default.useState(true);
207
- const goTo = import_react3.default.useCallback(
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
- const stepsRef = import_react3.default.useRef(steps);
259
+ useScrollLock_default(open, cardRef);
260
+ const stepsRef = import_react4.default.useRef(steps);
217
261
  stepsRef.current = steps;
218
- import_react3.default.useEffect(() => {
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 = import_react3.default.useCallback(() => {
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(placed.maxHeight ?? card.offsetHeight, limit);
328
+ const cardH = Math.min(card.scrollHeight, limit);
285
329
  const cardW = card.offsetWidth;
286
- card.style.maxHeight = `${cardH}px`;
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
- import_react3.default.useLayoutEffect(() => {
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
- import_react3.default.useEffect(() => {
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-progress", "aria-hidden": true, children: [
331
- index + 1,
332
- " / ",
333
- steps.length
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.title && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "tour-card-title", children: step.title }),
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: 320px;
31
+ width: var(--tour-card-width, 380px);
32
32
  max-width: calc(100vw - var(--spacing-space-8));
33
- overflow-y: auto;
34
- padding: var(--spacing-space-4);
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 React3 from "react";
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] = React3.useState(0);
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 = React3.useRef(null);
169
- const cardRef = React3.useRef(null);
170
- const [targetFound, setTargetFound] = React3.useState(true);
171
- const goTo = React3.useCallback(
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
- const stepsRef = React3.useRef(steps);
223
+ useScrollLock_default(open, cardRef);
224
+ const stepsRef = React4.useRef(steps);
181
225
  stepsRef.current = steps;
182
- React3.useEffect(() => {
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 = React3.useCallback(() => {
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(placed.maxHeight ?? card.offsetHeight, limit);
292
+ const cardH = Math.min(card.scrollHeight, limit);
249
293
  const cardW = card.offsetWidth;
250
- card.style.maxHeight = `${cardH}px`;
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
- React3.useLayoutEffect(() => {
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
- React3.useEffect(() => {
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-progress", "aria-hidden": true, children: [
295
- index + 1,
296
- " / ",
297
- steps.length
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.title && /* @__PURE__ */ jsx("div", { className: "tour-card-title", children: step.title }),
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: [