@x-plat/design-system 0.5.12 → 0.5.13

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.
@@ -443,12 +443,8 @@ var PortalContainerContext = import_react4.default.createContext(null);
443
443
  var PortalProvider = ({ container, children }) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(PortalContainerContext.Provider, { value: container, children });
444
444
  var Portal = ({ children }) => {
445
445
  const contextContainer = import_react4.default.useContext(PortalContainerContext);
446
- const [fallback, setFallback] = import_react4.default.useState(null);
447
- import_react4.default.useEffect(() => {
448
- if (!contextContainer) setFallback(document.body);
449
- }, [contextContainer]);
450
- const container = contextContainer ?? fallback;
451
- if (!container) return null;
446
+ if (typeof document === "undefined") return null;
447
+ const container = contextContainer ?? document.body;
452
448
  return import_react_dom.default.createPortal(children, container);
453
449
  };
454
450
  Portal.displayName = "Portal";
@@ -404,12 +404,8 @@ var PortalContainerContext = React3.createContext(null);
404
404
  var PortalProvider = ({ container, children }) => /* @__PURE__ */ jsx10(PortalContainerContext.Provider, { value: container, children });
405
405
  var Portal = ({ children }) => {
406
406
  const contextContainer = React3.useContext(PortalContainerContext);
407
- const [fallback, setFallback] = React3.useState(null);
408
- React3.useEffect(() => {
409
- if (!contextContainer) setFallback(document.body);
410
- }, [contextContainer]);
411
- const container = contextContainer ?? fallback;
412
- if (!container) return null;
407
+ if (typeof document === "undefined") return null;
408
+ const container = contextContainer ?? document.body;
413
409
  return ReactDOM.createPortal(children, container);
414
410
  };
415
411
  Portal.displayName = "Portal";
@@ -68,15 +68,15 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
68
68
  direction
69
69
  });
70
70
  }, [triggerRef, popRef]);
71
+ import_react.default.useLayoutEffect(() => {
72
+ if (!enabled) return;
73
+ calculatePosition();
74
+ }, [calculatePosition, enabled]);
71
75
  import_react.default.useEffect(() => {
72
76
  if (!enabled) return;
73
- const raf = requestAnimationFrame(() => {
74
- calculatePosition();
75
- });
76
77
  window.addEventListener("resize", calculatePosition);
77
78
  window.addEventListener("scroll", calculatePosition, true);
78
79
  return () => {
79
- cancelAnimationFrame(raf);
80
80
  window.removeEventListener("resize", calculatePosition);
81
81
  window.removeEventListener("scroll", calculatePosition, true);
82
82
  };
@@ -117,12 +117,8 @@ var import_jsx_runtime = require("react/jsx-runtime");
117
117
  var PortalContainerContext = import_react3.default.createContext(null);
118
118
  var Portal = ({ children }) => {
119
119
  const contextContainer = import_react3.default.useContext(PortalContainerContext);
120
- const [fallback, setFallback] = import_react3.default.useState(null);
121
- import_react3.default.useEffect(() => {
122
- if (!contextContainer) setFallback(document.body);
123
- }, [contextContainer]);
124
- const container = contextContainer ?? fallback;
125
- if (!container) return null;
120
+ if (typeof document === "undefined") return null;
121
+ const container = contextContainer ?? document.body;
126
122
  return import_react_dom.default.createPortal(children, container);
127
123
  };
128
124
  Portal.displayName = "Portal";
@@ -32,15 +32,15 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
32
32
  direction
33
33
  });
34
34
  }, [triggerRef, popRef]);
35
+ React.useLayoutEffect(() => {
36
+ if (!enabled) return;
37
+ calculatePosition();
38
+ }, [calculatePosition, enabled]);
35
39
  React.useEffect(() => {
36
40
  if (!enabled) return;
37
- const raf = requestAnimationFrame(() => {
38
- calculatePosition();
39
- });
40
41
  window.addEventListener("resize", calculatePosition);
41
42
  window.addEventListener("scroll", calculatePosition, true);
42
43
  return () => {
43
- cancelAnimationFrame(raf);
44
44
  window.removeEventListener("resize", calculatePosition);
45
45
  window.removeEventListener("scroll", calculatePosition, true);
46
46
  };
@@ -81,12 +81,8 @@ import { jsx } from "react/jsx-runtime";
81
81
  var PortalContainerContext = React3.createContext(null);
82
82
  var Portal = ({ children }) => {
83
83
  const contextContainer = React3.useContext(PortalContainerContext);
84
- const [fallback, setFallback] = React3.useState(null);
85
- React3.useEffect(() => {
86
- if (!contextContainer) setFallback(document.body);
87
- }, [contextContainer]);
88
- const container = contextContainer ?? fallback;
89
- if (!container) return null;
84
+ if (typeof document === "undefined") return null;
85
+ const container = contextContainer ?? document.body;
90
86
  return ReactDOM.createPortal(children, container);
91
87
  };
92
88
  Portal.displayName = "Portal";
@@ -46,12 +46,8 @@ var PortalContainerContext = import_react.default.createContext(null);
46
46
  var PortalProvider = ({ container, children }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PortalContainerContext.Provider, { value: container, children });
47
47
  var Portal = ({ children }) => {
48
48
  const contextContainer = import_react.default.useContext(PortalContainerContext);
49
- const [fallback, setFallback] = import_react.default.useState(null);
50
- import_react.default.useEffect(() => {
51
- if (!contextContainer) setFallback(document.body);
52
- }, [contextContainer]);
53
- const container = contextContainer ?? fallback;
54
- if (!container) return null;
49
+ if (typeof document === "undefined") return null;
50
+ const container = contextContainer ?? document.body;
55
51
  return import_react_dom.default.createPortal(children, container);
56
52
  };
57
53
  Portal.displayName = "Portal";
@@ -10,12 +10,8 @@ var PortalContainerContext = React.createContext(null);
10
10
  var PortalProvider = ({ container, children }) => /* @__PURE__ */ jsx(PortalContainerContext.Provider, { value: container, children });
11
11
  var Portal = ({ children }) => {
12
12
  const contextContainer = React.useContext(PortalContainerContext);
13
- const [fallback, setFallback] = React.useState(null);
14
- React.useEffect(() => {
15
- if (!contextContainer) setFallback(document.body);
16
- }, [contextContainer]);
17
- const container = contextContainer ?? fallback;
18
- if (!container) return null;
13
+ if (typeof document === "undefined") return null;
14
+ const container = contextContainer ?? document.body;
19
15
  return ReactDOM.createPortal(children, container);
20
16
  };
21
17
  Portal.displayName = "Portal";
@@ -68,15 +68,15 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
68
68
  direction
69
69
  });
70
70
  }, [triggerRef, popRef]);
71
+ import_react.default.useLayoutEffect(() => {
72
+ if (!enabled) return;
73
+ calculatePosition();
74
+ }, [calculatePosition, enabled]);
71
75
  import_react.default.useEffect(() => {
72
76
  if (!enabled) return;
73
- const raf = requestAnimationFrame(() => {
74
- calculatePosition();
75
- });
76
77
  window.addEventListener("resize", calculatePosition);
77
78
  window.addEventListener("scroll", calculatePosition, true);
78
79
  return () => {
79
- cancelAnimationFrame(raf);
80
80
  window.removeEventListener("resize", calculatePosition);
81
81
  window.removeEventListener("scroll", calculatePosition, true);
82
82
  };
@@ -117,12 +117,8 @@ var import_jsx_runtime = require("react/jsx-runtime");
117
117
  var PortalContainerContext = import_react3.default.createContext(null);
118
118
  var Portal = ({ children }) => {
119
119
  const contextContainer = import_react3.default.useContext(PortalContainerContext);
120
- const [fallback, setFallback] = import_react3.default.useState(null);
121
- import_react3.default.useEffect(() => {
122
- if (!contextContainer) setFallback(document.body);
123
- }, [contextContainer]);
124
- const container = contextContainer ?? fallback;
125
- if (!container) return null;
120
+ if (typeof document === "undefined") return null;
121
+ const container = contextContainer ?? document.body;
126
122
  return import_react_dom.default.createPortal(children, container);
127
123
  };
128
124
  Portal.displayName = "Portal";
@@ -32,15 +32,15 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
32
32
  direction
33
33
  });
34
34
  }, [triggerRef, popRef]);
35
+ React.useLayoutEffect(() => {
36
+ if (!enabled) return;
37
+ calculatePosition();
38
+ }, [calculatePosition, enabled]);
35
39
  React.useEffect(() => {
36
40
  if (!enabled) return;
37
- const raf = requestAnimationFrame(() => {
38
- calculatePosition();
39
- });
40
41
  window.addEventListener("resize", calculatePosition);
41
42
  window.addEventListener("scroll", calculatePosition, true);
42
43
  return () => {
43
- cancelAnimationFrame(raf);
44
44
  window.removeEventListener("resize", calculatePosition);
45
45
  window.removeEventListener("scroll", calculatePosition, true);
46
46
  };
@@ -81,12 +81,8 @@ import { jsx } from "react/jsx-runtime";
81
81
  var PortalContainerContext = React3.createContext(null);
82
82
  var Portal = ({ children }) => {
83
83
  const contextContainer = React3.useContext(PortalContainerContext);
84
- const [fallback, setFallback] = React3.useState(null);
85
- React3.useEffect(() => {
86
- if (!contextContainer) setFallback(document.body);
87
- }, [contextContainer]);
88
- const container = contextContainer ?? fallback;
89
- if (!container) return null;
84
+ if (typeof document === "undefined") return null;
85
+ const container = contextContainer ?? document.body;
90
86
  return ReactDOM.createPortal(children, container);
91
87
  };
92
88
  Portal.displayName = "Portal";
@@ -69,15 +69,15 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
69
69
  direction
70
70
  });
71
71
  }, [triggerRef, popRef]);
72
+ import_react.default.useLayoutEffect(() => {
73
+ if (!enabled) return;
74
+ calculatePosition();
75
+ }, [calculatePosition, enabled]);
72
76
  import_react.default.useEffect(() => {
73
77
  if (!enabled) return;
74
- const raf = requestAnimationFrame(() => {
75
- calculatePosition();
76
- });
77
78
  window.addEventListener("resize", calculatePosition);
78
79
  window.addEventListener("scroll", calculatePosition, true);
79
80
  return () => {
80
- cancelAnimationFrame(raf);
81
81
  window.removeEventListener("resize", calculatePosition);
82
82
  window.removeEventListener("scroll", calculatePosition, true);
83
83
  };
@@ -118,12 +118,8 @@ var import_jsx_runtime = require("react/jsx-runtime");
118
118
  var PortalContainerContext = import_react3.default.createContext(null);
119
119
  var Portal = ({ children }) => {
120
120
  const contextContainer = import_react3.default.useContext(PortalContainerContext);
121
- const [fallback, setFallback] = import_react3.default.useState(null);
122
- import_react3.default.useEffect(() => {
123
- if (!contextContainer) setFallback(document.body);
124
- }, [contextContainer]);
125
- const container = contextContainer ?? fallback;
126
- if (!container) return null;
121
+ if (typeof document === "undefined") return null;
122
+ const container = contextContainer ?? document.body;
127
123
  return import_react_dom.default.createPortal(children, container);
128
124
  };
129
125
  Portal.displayName = "Portal";
@@ -32,15 +32,15 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
32
32
  direction
33
33
  });
34
34
  }, [triggerRef, popRef]);
35
+ React.useLayoutEffect(() => {
36
+ if (!enabled) return;
37
+ calculatePosition();
38
+ }, [calculatePosition, enabled]);
35
39
  React.useEffect(() => {
36
40
  if (!enabled) return;
37
- const raf = requestAnimationFrame(() => {
38
- calculatePosition();
39
- });
40
41
  window.addEventListener("resize", calculatePosition);
41
42
  window.addEventListener("scroll", calculatePosition, true);
42
43
  return () => {
43
- cancelAnimationFrame(raf);
44
44
  window.removeEventListener("resize", calculatePosition);
45
45
  window.removeEventListener("scroll", calculatePosition, true);
46
46
  };
@@ -81,12 +81,8 @@ import { jsx } from "react/jsx-runtime";
81
81
  var PortalContainerContext = React3.createContext(null);
82
82
  var Portal = ({ children }) => {
83
83
  const contextContainer = React3.useContext(PortalContainerContext);
84
- const [fallback, setFallback] = React3.useState(null);
85
- React3.useEffect(() => {
86
- if (!contextContainer) setFallback(document.body);
87
- }, [contextContainer]);
88
- const container = contextContainer ?? fallback;
89
- if (!container) return null;
84
+ if (typeof document === "undefined") return null;
85
+ const container = contextContainer ?? document.body;
90
86
  return ReactDOM.createPortal(children, container);
91
87
  };
92
88
  Portal.displayName = "Portal";
@@ -2764,12 +2764,8 @@ var PortalContainerContext = import_react9.default.createContext(null);
2764
2764
  var PortalProvider = ({ container, children }) => /* @__PURE__ */ (0, import_jsx_runtime311.jsx)(PortalContainerContext.Provider, { value: container, children });
2765
2765
  var Portal = ({ children }) => {
2766
2766
  const contextContainer = import_react9.default.useContext(PortalContainerContext);
2767
- const [fallback, setFallback] = import_react9.default.useState(null);
2768
- import_react9.default.useEffect(() => {
2769
- if (!contextContainer) setFallback(document.body);
2770
- }, [contextContainer]);
2771
- const container = contextContainer ?? fallback;
2772
- if (!container) return null;
2767
+ if (typeof document === "undefined") return null;
2768
+ const container = contextContainer ?? document.body;
2773
2769
  return import_react_dom.default.createPortal(children, container);
2774
2770
  };
2775
2771
  Portal.displayName = "Portal";
@@ -3397,15 +3393,15 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
3397
3393
  direction
3398
3394
  });
3399
3395
  }, [triggerRef, popRef]);
3396
+ import_react18.default.useLayoutEffect(() => {
3397
+ if (!enabled) return;
3398
+ calculatePosition();
3399
+ }, [calculatePosition, enabled]);
3400
3400
  import_react18.default.useEffect(() => {
3401
3401
  if (!enabled) return;
3402
- const raf = requestAnimationFrame(() => {
3403
- calculatePosition();
3404
- });
3405
3402
  window.addEventListener("resize", calculatePosition);
3406
3403
  window.addEventListener("scroll", calculatePosition, true);
3407
3404
  return () => {
3408
- cancelAnimationFrame(raf);
3409
3405
  window.removeEventListener("resize", calculatePosition);
3410
3406
  window.removeEventListener("scroll", calculatePosition, true);
3411
3407
  };
@@ -2676,12 +2676,8 @@ var PortalContainerContext = React8.createContext(null);
2676
2676
  var PortalProvider = ({ container, children }) => /* @__PURE__ */ jsx311(PortalContainerContext.Provider, { value: container, children });
2677
2677
  var Portal = ({ children }) => {
2678
2678
  const contextContainer = React8.useContext(PortalContainerContext);
2679
- const [fallback, setFallback] = React8.useState(null);
2680
- React8.useEffect(() => {
2681
- if (!contextContainer) setFallback(document.body);
2682
- }, [contextContainer]);
2683
- const container = contextContainer ?? fallback;
2684
- if (!container) return null;
2679
+ if (typeof document === "undefined") return null;
2680
+ const container = contextContainer ?? document.body;
2685
2681
  return ReactDOM.createPortal(children, container);
2686
2682
  };
2687
2683
  Portal.displayName = "Portal";
@@ -3309,15 +3305,15 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
3309
3305
  direction
3310
3306
  });
3311
3307
  }, [triggerRef, popRef]);
3308
+ React17.useLayoutEffect(() => {
3309
+ if (!enabled) return;
3310
+ calculatePosition();
3311
+ }, [calculatePosition, enabled]);
3312
3312
  React17.useEffect(() => {
3313
3313
  if (!enabled) return;
3314
- const raf = requestAnimationFrame(() => {
3315
- calculatePosition();
3316
- });
3317
3314
  window.addEventListener("resize", calculatePosition);
3318
3315
  window.addEventListener("scroll", calculatePosition, true);
3319
3316
  return () => {
3320
- cancelAnimationFrame(raf);
3321
3317
  window.removeEventListener("resize", calculatePosition);
3322
3318
  window.removeEventListener("scroll", calculatePosition, true);
3323
3319
  };
package/dist/index.cjs CHANGED
@@ -7188,12 +7188,8 @@ var PortalContainerContext = import_react9.default.createContext(null);
7188
7188
  var PortalProvider = ({ container, children }) => /* @__PURE__ */ (0, import_jsx_runtime311.jsx)(PortalContainerContext.Provider, { value: container, children });
7189
7189
  var Portal = ({ children }) => {
7190
7190
  const contextContainer = import_react9.default.useContext(PortalContainerContext);
7191
- const [fallback, setFallback] = import_react9.default.useState(null);
7192
- import_react9.default.useEffect(() => {
7193
- if (!contextContainer) setFallback(document.body);
7194
- }, [contextContainer]);
7195
- const container = contextContainer ?? fallback;
7196
- if (!container) return null;
7191
+ if (typeof document === "undefined") return null;
7192
+ const container = contextContainer ?? document.body;
7197
7193
  return import_react_dom.default.createPortal(children, container);
7198
7194
  };
7199
7195
  Portal.displayName = "Portal";
@@ -7821,15 +7817,15 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
7821
7817
  direction
7822
7818
  });
7823
7819
  }, [triggerRef, popRef]);
7820
+ import_react18.default.useLayoutEffect(() => {
7821
+ if (!enabled) return;
7822
+ calculatePosition();
7823
+ }, [calculatePosition, enabled]);
7824
7824
  import_react18.default.useEffect(() => {
7825
7825
  if (!enabled) return;
7826
- const raf = requestAnimationFrame(() => {
7827
- calculatePosition();
7828
- });
7829
7826
  window.addEventListener("resize", calculatePosition);
7830
7827
  window.addEventListener("scroll", calculatePosition, true);
7831
7828
  return () => {
7832
- cancelAnimationFrame(raf);
7833
7829
  window.removeEventListener("resize", calculatePosition);
7834
7830
  window.removeEventListener("scroll", calculatePosition, true);
7835
7831
  };
package/dist/index.js CHANGED
@@ -6791,12 +6791,8 @@ var PortalContainerContext = React8.createContext(null);
6791
6791
  var PortalProvider = ({ container, children }) => /* @__PURE__ */ jsx311(PortalContainerContext.Provider, { value: container, children });
6792
6792
  var Portal = ({ children }) => {
6793
6793
  const contextContainer = React8.useContext(PortalContainerContext);
6794
- const [fallback, setFallback] = React8.useState(null);
6795
- React8.useEffect(() => {
6796
- if (!contextContainer) setFallback(document.body);
6797
- }, [contextContainer]);
6798
- const container = contextContainer ?? fallback;
6799
- if (!container) return null;
6794
+ if (typeof document === "undefined") return null;
6795
+ const container = contextContainer ?? document.body;
6800
6796
  return ReactDOM.createPortal(children, container);
6801
6797
  };
6802
6798
  Portal.displayName = "Portal";
@@ -7424,15 +7420,15 @@ var useAutoPosition = (triggerRef, popRef, enabled = true) => {
7424
7420
  direction
7425
7421
  });
7426
7422
  }, [triggerRef, popRef]);
7423
+ React17.useLayoutEffect(() => {
7424
+ if (!enabled) return;
7425
+ calculatePosition();
7426
+ }, [calculatePosition, enabled]);
7427
7427
  React17.useEffect(() => {
7428
7428
  if (!enabled) return;
7429
- const raf = requestAnimationFrame(() => {
7430
- calculatePosition();
7431
- });
7432
7429
  window.addEventListener("resize", calculatePosition);
7433
7430
  window.addEventListener("scroll", calculatePosition, true);
7434
7431
  return () => {
7435
- cancelAnimationFrame(raf);
7436
7432
  window.removeEventListener("resize", calculatePosition);
7437
7433
  window.removeEventListener("scroll", calculatePosition, true);
7438
7434
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@x-plat/design-system",
3
- "version": "0.5.12",
3
+ "version": "0.5.13",
4
4
  "description": "XPLAT UI Design System",
5
5
  "author": "XPLAT WOONG",
6
6
  "main": "dist/index.cjs",