@x-plat/design-system 0.16.0 → 0.16.1

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.
@@ -85,8 +85,7 @@ var computePlacement = (triggerRect, popW, popH, clip) => {
85
85
  if (left + popW > clip.right - 8) {
86
86
  left = triggerRect.right - popW;
87
87
  }
88
- left = Math.min(left, clip.right - 8 - popW);
89
- left = Math.max(left, clip.left + 8);
88
+ if (left < clip.left + 8) left = clip.left + 8;
90
89
  return {
91
90
  direction,
92
91
  top,
@@ -49,8 +49,7 @@ var computePlacement = (triggerRect, popW, popH, clip) => {
49
49
  if (left + popW > clip.right - 8) {
50
50
  left = triggerRect.right - popW;
51
51
  }
52
- left = Math.min(left, clip.right - 8 - popW);
53
- left = Math.max(left, clip.left + 8);
52
+ if (left < clip.left + 8) left = clip.left + 8;
54
53
  return {
55
54
  direction,
56
55
  top,
@@ -85,8 +85,7 @@ var computePlacement = (triggerRect, popW, popH, clip) => {
85
85
  if (left + popW > clip.right - 8) {
86
86
  left = triggerRect.right - popW;
87
87
  }
88
- left = Math.min(left, clip.right - 8 - popW);
89
- left = Math.max(left, clip.left + 8);
88
+ if (left < clip.left + 8) left = clip.left + 8;
90
89
  return {
91
90
  direction,
92
91
  top,
@@ -49,8 +49,7 @@ var computePlacement = (triggerRect, popW, popH, clip) => {
49
49
  if (left + popW > clip.right - 8) {
50
50
  left = triggerRect.right - popW;
51
51
  }
52
- left = Math.min(left, clip.right - 8 - popW);
53
- left = Math.max(left, clip.left + 8);
52
+ if (left < clip.left + 8) left = clip.left + 8;
54
53
  return {
55
54
  direction,
56
55
  top,
@@ -86,8 +86,7 @@ var computePlacement = (triggerRect, popW, popH, clip) => {
86
86
  if (left + popW > clip.right - 8) {
87
87
  left = triggerRect.right - popW;
88
88
  }
89
- left = Math.min(left, clip.right - 8 - popW);
90
- left = Math.max(left, clip.left + 8);
89
+ if (left < clip.left + 8) left = clip.left + 8;
91
90
  return {
92
91
  direction,
93
92
  top,
@@ -49,8 +49,7 @@ var computePlacement = (triggerRect, popW, popH, clip) => {
49
49
  if (left + popW > clip.right - 8) {
50
50
  left = triggerRect.right - popW;
51
51
  }
52
- left = Math.min(left, clip.right - 8 - popW);
53
- left = Math.max(left, clip.left + 8);
52
+ if (left < clip.left + 8) left = clip.left + 8;
54
53
  return {
55
54
  direction,
56
55
  top,
@@ -85,8 +85,7 @@ var computePlacement = (triggerRect, popW, popH, clip) => {
85
85
  if (left + popW > clip.right - 8) {
86
86
  left = triggerRect.right - popW;
87
87
  }
88
- left = Math.min(left, clip.right - 8 - popW);
89
- left = Math.max(left, clip.left + 8);
88
+ if (left < clip.left + 8) left = clip.left + 8;
90
89
  return {
91
90
  direction,
92
91
  top,
@@ -49,8 +49,7 @@ var computePlacement = (triggerRect, popW, popH, clip) => {
49
49
  if (left + popW > clip.right - 8) {
50
50
  left = triggerRect.right - popW;
51
51
  }
52
- left = Math.min(left, clip.right - 8 - popW);
53
- left = Math.max(left, clip.left + 8);
52
+ if (left < clip.left + 8) left = clip.left + 8;
54
53
  return {
55
54
  direction,
56
55
  top,
@@ -76,8 +76,7 @@ var computePlacement = (triggerRect, popW, popH, clip) => {
76
76
  if (left + popW > clip.right - 8) {
77
77
  left = triggerRect.right - popW;
78
78
  }
79
- left = Math.min(left, clip.right - 8 - popW);
80
- left = Math.max(left, clip.left + 8);
79
+ if (left < clip.left + 8) left = clip.left + 8;
81
80
  return {
82
81
  direction,
83
82
  top,
@@ -181,6 +180,7 @@ var clsx_default = clsx;
181
180
  var import_jsx_runtime = require("react/jsx-runtime");
182
181
  var VIEWPORT_MARGIN = 16;
183
182
  var DEFAULT_PADDING = 8;
183
+ var clamp = (v, min, max) => Math.max(min, Math.min(v, max));
184
184
  var resolve = (target) => {
185
185
  if (typeof target === "string") return document.querySelector(target);
186
186
  return target.current;
@@ -259,9 +259,12 @@ var Tour = (props) => {
259
259
  right: window.innerWidth - VIEWPORT_MARGIN
260
260
  }
261
261
  );
262
- card.style.top = `${placed.top}px`;
263
- card.style.left = `${placed.left}px`;
264
- card.style.maxHeight = placed.maxHeight === null ? "" : `${placed.maxHeight}px`;
262
+ const limit = window.innerHeight - VIEWPORT_MARGIN * 2;
263
+ const cardH = Math.min(placed.maxHeight ?? card.offsetHeight, limit);
264
+ const cardW = card.offsetWidth;
265
+ card.style.maxHeight = `${cardH}px`;
266
+ card.style.top = `${clamp(placed.top, VIEWPORT_MARGIN, window.innerHeight - VIEWPORT_MARGIN - cardH)}px`;
267
+ card.style.left = `${clamp(placed.left, VIEWPORT_MARGIN, window.innerWidth - VIEWPORT_MARGIN - cardW)}px`;
265
268
  }, [step]);
266
269
  import_react3.default.useLayoutEffect(() => {
267
270
  if (!open) return;
@@ -40,8 +40,7 @@ var computePlacement = (triggerRect, popW, popH, clip) => {
40
40
  if (left + popW > clip.right - 8) {
41
41
  left = triggerRect.right - popW;
42
42
  }
43
- left = Math.min(left, clip.right - 8 - popW);
44
- left = Math.max(left, clip.left + 8);
43
+ if (left < clip.left + 8) left = clip.left + 8;
45
44
  return {
46
45
  direction,
47
46
  top,
@@ -145,6 +144,7 @@ var clsx_default = clsx;
145
144
  import { jsx, jsxs } from "react/jsx-runtime";
146
145
  var VIEWPORT_MARGIN = 16;
147
146
  var DEFAULT_PADDING = 8;
147
+ var clamp = (v, min, max) => Math.max(min, Math.min(v, max));
148
148
  var resolve = (target) => {
149
149
  if (typeof target === "string") return document.querySelector(target);
150
150
  return target.current;
@@ -223,9 +223,12 @@ var Tour = (props) => {
223
223
  right: window.innerWidth - VIEWPORT_MARGIN
224
224
  }
225
225
  );
226
- card.style.top = `${placed.top}px`;
227
- card.style.left = `${placed.left}px`;
228
- card.style.maxHeight = placed.maxHeight === null ? "" : `${placed.maxHeight}px`;
226
+ const limit = window.innerHeight - VIEWPORT_MARGIN * 2;
227
+ const cardH = Math.min(placed.maxHeight ?? card.offsetHeight, limit);
228
+ const cardW = card.offsetWidth;
229
+ card.style.maxHeight = `${cardH}px`;
230
+ card.style.top = `${clamp(placed.top, VIEWPORT_MARGIN, window.innerHeight - VIEWPORT_MARGIN - cardH)}px`;
231
+ card.style.left = `${clamp(placed.left, VIEWPORT_MARGIN, window.innerWidth - VIEWPORT_MARGIN - cardW)}px`;
229
232
  }, [step]);
230
233
  React3.useLayoutEffect(() => {
231
234
  if (!open) return;
@@ -3272,8 +3272,7 @@ var computePlacement = (triggerRect, popW, popH, clip) => {
3272
3272
  if (left + popW > clip.right - 8) {
3273
3273
  left = triggerRect.right - popW;
3274
3274
  }
3275
- left = Math.min(left, clip.right - 8 - popW);
3276
- left = Math.max(left, clip.left + 8);
3275
+ if (left < clip.left + 8) left = clip.left + 8;
3277
3276
  return {
3278
3277
  direction,
3279
3278
  top,
@@ -7590,7 +7589,7 @@ var Tooltip = (props) => {
7590
7589
  const delayTimer = import_react43.default.useRef(0);
7591
7590
  const rafRef = import_react43.default.useRef(0);
7592
7591
  const cursor = import_react43.default.useRef(null);
7593
- const clamp = import_react43.default.useCallback((left, top, w, h) => {
7592
+ const clamp2 = import_react43.default.useCallback((left, top, w, h) => {
7594
7593
  const vw = window.innerWidth;
7595
7594
  const vh = window.innerHeight;
7596
7595
  return {
@@ -7607,8 +7606,8 @@ var Tooltip = (props) => {
7607
7606
  let top = y - h - OFFSET;
7608
7607
  if (left + w > window.innerWidth - GAP) left = x - w - OFFSET;
7609
7608
  if (top < GAP) top = y + OFFSET;
7610
- setPos(clamp(left, top, w, h));
7611
- }, [clamp]);
7609
+ setPos(clamp2(left, top, w, h));
7610
+ }, [clamp2]);
7612
7611
  const placeAtTrigger = import_react43.default.useCallback(() => {
7613
7612
  const el = tooltipRef.current;
7614
7613
  const trigger = triggerRef.current;
@@ -7619,8 +7618,8 @@ var Tooltip = (props) => {
7619
7618
  let top = rect.top - h - GAP;
7620
7619
  if (top < GAP) top = rect.bottom + GAP;
7621
7620
  const left = rect.left + rect.width / 2 - w / 2;
7622
- setPos(clamp(left, top, w, h));
7623
- }, [clamp]);
7621
+ setPos(clamp2(left, top, w, h));
7622
+ }, [clamp2]);
7624
7623
  const reposition = import_react43.default.useCallback(() => {
7625
7624
  if (follow && cursor.current) {
7626
7625
  placeAtCursor(cursor.current.x, cursor.current.y);
@@ -7712,6 +7711,7 @@ var import_react44 = __toESM(require("react"), 1);
7712
7711
  var import_jsx_runtime355 = require("react/jsx-runtime");
7713
7712
  var VIEWPORT_MARGIN = 16;
7714
7713
  var DEFAULT_PADDING = 8;
7714
+ var clamp = (v, min, max) => Math.max(min, Math.min(v, max));
7715
7715
  var resolve = (target) => {
7716
7716
  if (typeof target === "string") return document.querySelector(target);
7717
7717
  return target.current;
@@ -7790,9 +7790,12 @@ var Tour = (props) => {
7790
7790
  right: window.innerWidth - VIEWPORT_MARGIN
7791
7791
  }
7792
7792
  );
7793
- card.style.top = `${placed.top}px`;
7794
- card.style.left = `${placed.left}px`;
7795
- card.style.maxHeight = placed.maxHeight === null ? "" : `${placed.maxHeight}px`;
7793
+ const limit = window.innerHeight - VIEWPORT_MARGIN * 2;
7794
+ const cardH = Math.min(placed.maxHeight ?? card.offsetHeight, limit);
7795
+ const cardW = card.offsetWidth;
7796
+ card.style.maxHeight = `${cardH}px`;
7797
+ card.style.top = `${clamp(placed.top, VIEWPORT_MARGIN, window.innerHeight - VIEWPORT_MARGIN - cardH)}px`;
7798
+ card.style.left = `${clamp(placed.left, VIEWPORT_MARGIN, window.innerWidth - VIEWPORT_MARGIN - cardW)}px`;
7796
7799
  }, [step]);
7797
7800
  import_react44.default.useLayoutEffect(() => {
7798
7801
  if (!open) return;
@@ -3169,8 +3169,7 @@ var computePlacement = (triggerRect, popW, popH, clip) => {
3169
3169
  if (left + popW > clip.right - 8) {
3170
3170
  left = triggerRect.right - popW;
3171
3171
  }
3172
- left = Math.min(left, clip.right - 8 - popW);
3173
- left = Math.max(left, clip.left + 8);
3172
+ if (left < clip.left + 8) left = clip.left + 8;
3174
3173
  return {
3175
3174
  direction,
3176
3175
  top,
@@ -7487,7 +7486,7 @@ var Tooltip = (props) => {
7487
7486
  const delayTimer = React43.useRef(0);
7488
7487
  const rafRef = React43.useRef(0);
7489
7488
  const cursor = React43.useRef(null);
7490
- const clamp = React43.useCallback((left, top, w, h) => {
7489
+ const clamp2 = React43.useCallback((left, top, w, h) => {
7491
7490
  const vw = window.innerWidth;
7492
7491
  const vh = window.innerHeight;
7493
7492
  return {
@@ -7504,8 +7503,8 @@ var Tooltip = (props) => {
7504
7503
  let top = y - h - OFFSET;
7505
7504
  if (left + w > window.innerWidth - GAP) left = x - w - OFFSET;
7506
7505
  if (top < GAP) top = y + OFFSET;
7507
- setPos(clamp(left, top, w, h));
7508
- }, [clamp]);
7506
+ setPos(clamp2(left, top, w, h));
7507
+ }, [clamp2]);
7509
7508
  const placeAtTrigger = React43.useCallback(() => {
7510
7509
  const el = tooltipRef.current;
7511
7510
  const trigger = triggerRef.current;
@@ -7516,8 +7515,8 @@ var Tooltip = (props) => {
7516
7515
  let top = rect.top - h - GAP;
7517
7516
  if (top < GAP) top = rect.bottom + GAP;
7518
7517
  const left = rect.left + rect.width / 2 - w / 2;
7519
- setPos(clamp(left, top, w, h));
7520
- }, [clamp]);
7518
+ setPos(clamp2(left, top, w, h));
7519
+ }, [clamp2]);
7521
7520
  const reposition = React43.useCallback(() => {
7522
7521
  if (follow && cursor.current) {
7523
7522
  placeAtCursor(cursor.current.x, cursor.current.y);
@@ -7609,6 +7608,7 @@ import React44 from "react";
7609
7608
  import { jsx as jsx355, jsxs as jsxs225 } from "react/jsx-runtime";
7610
7609
  var VIEWPORT_MARGIN = 16;
7611
7610
  var DEFAULT_PADDING = 8;
7611
+ var clamp = (v, min, max) => Math.max(min, Math.min(v, max));
7612
7612
  var resolve = (target) => {
7613
7613
  if (typeof target === "string") return document.querySelector(target);
7614
7614
  return target.current;
@@ -7687,9 +7687,12 @@ var Tour = (props) => {
7687
7687
  right: window.innerWidth - VIEWPORT_MARGIN
7688
7688
  }
7689
7689
  );
7690
- card.style.top = `${placed.top}px`;
7691
- card.style.left = `${placed.left}px`;
7692
- card.style.maxHeight = placed.maxHeight === null ? "" : `${placed.maxHeight}px`;
7690
+ const limit = window.innerHeight - VIEWPORT_MARGIN * 2;
7691
+ const cardH = Math.min(placed.maxHeight ?? card.offsetHeight, limit);
7692
+ const cardW = card.offsetWidth;
7693
+ card.style.maxHeight = `${cardH}px`;
7694
+ card.style.top = `${clamp(placed.top, VIEWPORT_MARGIN, window.innerHeight - VIEWPORT_MARGIN - cardH)}px`;
7695
+ card.style.left = `${clamp(placed.left, VIEWPORT_MARGIN, window.innerWidth - VIEWPORT_MARGIN - cardW)}px`;
7693
7696
  }, [step]);
7694
7697
  React44.useLayoutEffect(() => {
7695
7698
  if (!open) return;
package/dist/index.cjs CHANGED
@@ -7684,8 +7684,7 @@ var computePlacement = (triggerRect, popW, popH, clip) => {
7684
7684
  if (left + popW > clip.right - 8) {
7685
7685
  left = triggerRect.right - popW;
7686
7686
  }
7687
- left = Math.min(left, clip.right - 8 - popW);
7688
- left = Math.max(left, clip.left + 8);
7687
+ if (left < clip.left + 8) left = clip.left + 8;
7689
7688
  return {
7690
7689
  direction,
7691
7690
  top,
@@ -12002,7 +12001,7 @@ var Tooltip = (props) => {
12002
12001
  const delayTimer = import_react43.default.useRef(0);
12003
12002
  const rafRef = import_react43.default.useRef(0);
12004
12003
  const cursor = import_react43.default.useRef(null);
12005
- const clamp = import_react43.default.useCallback((left, top, w, h) => {
12004
+ const clamp2 = import_react43.default.useCallback((left, top, w, h) => {
12006
12005
  const vw = window.innerWidth;
12007
12006
  const vh = window.innerHeight;
12008
12007
  return {
@@ -12019,8 +12018,8 @@ var Tooltip = (props) => {
12019
12018
  let top = y - h - OFFSET;
12020
12019
  if (left + w > window.innerWidth - GAP) left = x - w - OFFSET;
12021
12020
  if (top < GAP) top = y + OFFSET;
12022
- setPos(clamp(left, top, w, h));
12023
- }, [clamp]);
12021
+ setPos(clamp2(left, top, w, h));
12022
+ }, [clamp2]);
12024
12023
  const placeAtTrigger = import_react43.default.useCallback(() => {
12025
12024
  const el = tooltipRef.current;
12026
12025
  const trigger = triggerRef.current;
@@ -12031,8 +12030,8 @@ var Tooltip = (props) => {
12031
12030
  let top = rect.top - h - GAP;
12032
12031
  if (top < GAP) top = rect.bottom + GAP;
12033
12032
  const left = rect.left + rect.width / 2 - w / 2;
12034
- setPos(clamp(left, top, w, h));
12035
- }, [clamp]);
12033
+ setPos(clamp2(left, top, w, h));
12034
+ }, [clamp2]);
12036
12035
  const reposition = import_react43.default.useCallback(() => {
12037
12036
  if (follow && cursor.current) {
12038
12037
  placeAtCursor(cursor.current.x, cursor.current.y);
@@ -12124,6 +12123,7 @@ var import_react44 = __toESM(require("react"), 1);
12124
12123
  var import_jsx_runtime355 = require("react/jsx-runtime");
12125
12124
  var VIEWPORT_MARGIN = 16;
12126
12125
  var DEFAULT_PADDING = 8;
12126
+ var clamp = (v, min, max) => Math.max(min, Math.min(v, max));
12127
12127
  var resolve = (target) => {
12128
12128
  if (typeof target === "string") return document.querySelector(target);
12129
12129
  return target.current;
@@ -12202,9 +12202,12 @@ var Tour = (props) => {
12202
12202
  right: window.innerWidth - VIEWPORT_MARGIN
12203
12203
  }
12204
12204
  );
12205
- card.style.top = `${placed.top}px`;
12206
- card.style.left = `${placed.left}px`;
12207
- card.style.maxHeight = placed.maxHeight === null ? "" : `${placed.maxHeight}px`;
12205
+ const limit = window.innerHeight - VIEWPORT_MARGIN * 2;
12206
+ const cardH = Math.min(placed.maxHeight ?? card.offsetHeight, limit);
12207
+ const cardW = card.offsetWidth;
12208
+ card.style.maxHeight = `${cardH}px`;
12209
+ card.style.top = `${clamp(placed.top, VIEWPORT_MARGIN, window.innerHeight - VIEWPORT_MARGIN - cardH)}px`;
12210
+ card.style.left = `${clamp(placed.left, VIEWPORT_MARGIN, window.innerWidth - VIEWPORT_MARGIN - cardW)}px`;
12208
12211
  }, [step]);
12209
12212
  import_react44.default.useLayoutEffect(() => {
12210
12213
  if (!open) return;
package/dist/index.js CHANGED
@@ -7272,8 +7272,7 @@ var computePlacement = (triggerRect, popW, popH, clip) => {
7272
7272
  if (left + popW > clip.right - 8) {
7273
7273
  left = triggerRect.right - popW;
7274
7274
  }
7275
- left = Math.min(left, clip.right - 8 - popW);
7276
- left = Math.max(left, clip.left + 8);
7275
+ if (left < clip.left + 8) left = clip.left + 8;
7277
7276
  return {
7278
7277
  direction,
7279
7278
  top,
@@ -11590,7 +11589,7 @@ var Tooltip = (props) => {
11590
11589
  const delayTimer = React43.useRef(0);
11591
11590
  const rafRef = React43.useRef(0);
11592
11591
  const cursor = React43.useRef(null);
11593
- const clamp = React43.useCallback((left, top, w, h) => {
11592
+ const clamp2 = React43.useCallback((left, top, w, h) => {
11594
11593
  const vw = window.innerWidth;
11595
11594
  const vh = window.innerHeight;
11596
11595
  return {
@@ -11607,8 +11606,8 @@ var Tooltip = (props) => {
11607
11606
  let top = y - h - OFFSET;
11608
11607
  if (left + w > window.innerWidth - GAP) left = x - w - OFFSET;
11609
11608
  if (top < GAP) top = y + OFFSET;
11610
- setPos(clamp(left, top, w, h));
11611
- }, [clamp]);
11609
+ setPos(clamp2(left, top, w, h));
11610
+ }, [clamp2]);
11612
11611
  const placeAtTrigger = React43.useCallback(() => {
11613
11612
  const el = tooltipRef.current;
11614
11613
  const trigger = triggerRef.current;
@@ -11619,8 +11618,8 @@ var Tooltip = (props) => {
11619
11618
  let top = rect.top - h - GAP;
11620
11619
  if (top < GAP) top = rect.bottom + GAP;
11621
11620
  const left = rect.left + rect.width / 2 - w / 2;
11622
- setPos(clamp(left, top, w, h));
11623
- }, [clamp]);
11621
+ setPos(clamp2(left, top, w, h));
11622
+ }, [clamp2]);
11624
11623
  const reposition = React43.useCallback(() => {
11625
11624
  if (follow && cursor.current) {
11626
11625
  placeAtCursor(cursor.current.x, cursor.current.y);
@@ -11712,6 +11711,7 @@ import React44 from "react";
11712
11711
  import { jsx as jsx355, jsxs as jsxs225 } from "react/jsx-runtime";
11713
11712
  var VIEWPORT_MARGIN = 16;
11714
11713
  var DEFAULT_PADDING = 8;
11714
+ var clamp = (v, min, max) => Math.max(min, Math.min(v, max));
11715
11715
  var resolve = (target) => {
11716
11716
  if (typeof target === "string") return document.querySelector(target);
11717
11717
  return target.current;
@@ -11790,9 +11790,12 @@ var Tour = (props) => {
11790
11790
  right: window.innerWidth - VIEWPORT_MARGIN
11791
11791
  }
11792
11792
  );
11793
- card.style.top = `${placed.top}px`;
11794
- card.style.left = `${placed.left}px`;
11795
- card.style.maxHeight = placed.maxHeight === null ? "" : `${placed.maxHeight}px`;
11793
+ const limit = window.innerHeight - VIEWPORT_MARGIN * 2;
11794
+ const cardH = Math.min(placed.maxHeight ?? card.offsetHeight, limit);
11795
+ const cardW = card.offsetWidth;
11796
+ card.style.maxHeight = `${cardH}px`;
11797
+ card.style.top = `${clamp(placed.top, VIEWPORT_MARGIN, window.innerHeight - VIEWPORT_MARGIN - cardH)}px`;
11798
+ card.style.left = `${clamp(placed.left, VIEWPORT_MARGIN, window.innerWidth - VIEWPORT_MARGIN - cardW)}px`;
11796
11799
  }, [step]);
11797
11800
  React44.useLayoutEffect(() => {
11798
11801
  if (!open) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@x-plat/design-system",
3
- "version": "0.16.0",
3
+ "version": "0.16.1",
4
4
  "description": "XPLAT UI Design System",
5
5
  "author": "XPLAT WOONG",
6
6
  "main": "dist/index.cjs",