@xanui/core 1.2.65 → 1.2.67

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/AppRoot/index.cjs CHANGED
@@ -14,6 +14,7 @@ var index = require('../Document/index.cjs');
14
14
  var AppRootProvider = require('./AppRootProvider.cjs');
15
15
  var useMergeRefs = require('../hooks/useMergeRefs.cjs');
16
16
  var CSSCacheProvider = require('../css/CSSCacheProvider.cjs');
17
+ var cookie = require('../cookie.cjs');
17
18
 
18
19
  const AppRoot = React.forwardRef((_a, ref) => {
19
20
  var { children, defaultBreakpoint, noScrollbarCss, CSSCacheId, theme, onThemeChange, disableRenderar, selectionColor, document: _document } = _a, props = tslib.__rest(_a, ["children", "defaultBreakpoint", "noScrollbarCss", "CSSCacheId", "theme", "onThemeChange", "disableRenderar", "selectionColor", "document"]);
@@ -35,7 +36,9 @@ const AppRoot = React.forwardRef((_a, ref) => {
35
36
  React.useEffect(() => {
36
37
  if (typeof _document === 'undefined')
37
38
  return;
38
- document.cookie = `xuitm=${theme.name};path=/`;
39
+ if (!cookie.exists("xuitm")) {
40
+ cookie.set("xuitm", theme.name);
41
+ }
39
42
  const styles = Array.from(_document.querySelectorAll('body style[data-oncss]'));
40
43
  styles.forEach((style) => {
41
44
  _document.head.appendChild(style);
@@ -52,7 +55,7 @@ const AppRoot = React.forwardRef((_a, ref) => {
52
55
  }
53
56
  return (jsxRuntime.jsx(index.DocumentProvider, { value: _document ? { document: _document, id: docid } : undefined, children: jsxRuntime.jsx(CSSCacheProvider.CSSCacheProvider, { cacheId: CSSCacheId, children: jsxRuntime.jsx(AppRootProvider.AppRootProvider, { element: () => rootRef.current, children: jsxRuntime.jsx(ThemeProvider, Object.assign({ theme: theme, onThemeChange: (t) => {
54
57
  onThemeChange && onThemeChange(t);
55
- document.cookie = `xuitm=${t.name};path=/`;
58
+ cookie.set("xuitm", t.name);
56
59
  } }, props, { ref: mergeRef, isRoot: true, sx: Object.assign(Object.assign(Object.assign({}, props.sx), (visibility === "hidden" ? { visibility: "hidden" } : {})), selection), children: jsxRuntime.jsxs(BreakpointProvider.BreakpointProvider, { defaultKey: defaultBreakpoint !== null && defaultBreakpoint !== void 0 ? defaultBreakpoint : "xl", children: [children, !disableRenderar && jsxRuntime.jsx(Renderar.RenderRenderar, {})] }) })) }) }) }));
57
60
  });
58
61
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../src/AppRoot/index.tsx"],"sourcesContent":["\"use client\";\nimport React, { useEffect, useId, useLayoutEffect, useRef } from 'react';\nimport { TagComponentType } from '../Tag/types';\nimport { ThemeProvider, ThemeProviderProps } from '../theme';\nimport { BreakpointProvider } from '../breakpoint';\nimport { RenderRenderar } from './Renderar';\nimport { DocumentProvider } from '../Document';\nimport { AppRootProvider } from './AppRootProvider';\nimport useMergeRefs from '../hooks/useMergeRefs';\nimport { CSSCacheProvider } from '../css/CSSCacheProvider';\nimport { BreakpointKeys } from '../css/types';\n\nexport type AppRootProps<T extends TagComponentType = \"div\"> = ThemeProviderProps<T> & {\n noScrollbarCss?: boolean;\n document?: Document;\n CSSCacheId?: string;\n disableRenderar?: boolean;\n defaultBreakpoint?: BreakpointKeys\n selectionColor?: \"default\" | \"brand\" | \"accent\" | \"success\" | \"info\" | \"warning\" | \"danger\";\n}\n\nconst AppRoot = React.forwardRef(<T extends TagComponentType = \"div\">({ children, defaultBreakpoint, noScrollbarCss, CSSCacheId, theme, onThemeChange, disableRenderar, selectionColor, document: _document, ...props }: AppRootProps<T>, ref: React.Ref<any>) => {\n\n noScrollbarCss ??= false\n selectionColor ??= \"brand\"\n if (typeof window !== \"undefined\") {\n _document ??= document\n }\n disableRenderar ??= false\n const docid = useId()\n const csscacheId = useId()\n CSSCacheId ??= csscacheId\n\n const [visibility, setVisibility] = React.useState<string>(!defaultBreakpoint ? \"hidden\" : \"\");\n const rootRef = useRef(null)\n const mergeRef = useMergeRefs(rootRef, ref)\n\n useLayoutEffect(() => {\n !defaultBreakpoint && setVisibility(\"\");\n }, [])\n\n useEffect(() => {\n if (typeof _document === 'undefined') return;\n document.cookie = `xuitm=${theme.name};path=/`\n const styles = Array.from(_document.querySelectorAll('body style[data-oncss]'));\n styles.forEach((style) => {\n _document.head.appendChild(style);\n });\n }, [])\n\n let selection: any = {}\n if (selectionColor && selectionColor !== 'default') {\n selection = {\n \"&::selection\": {\n bgcolor: `${selectionColor}.primary`,\n color: `${selectionColor}.text`\n }\n }\n }\n\n return (\n <DocumentProvider value={_document ? { document: _document, id: docid } : undefined}>\n <CSSCacheProvider cacheId={CSSCacheId}>\n <AppRootProvider element={() => rootRef.current}>\n <ThemeProvider\n theme={theme}\n onThemeChange={(t) => {\n onThemeChange && onThemeChange(t)\n document.cookie = `xuitm=${t.name};path=/`\n }}\n {...props}\n ref={mergeRef}\n isRoot\n sx={{\n ...props.sx,\n ...(visibility === \"hidden\" ? { visibility: \"hidden\" } : {}),\n ...selection\n }}\n >\n <BreakpointProvider defaultKey={defaultBreakpoint ?? \"xl\"}>\n {children}\n {!disableRenderar && <RenderRenderar />}\n </BreakpointProvider>\n </ThemeProvider>\n </AppRootProvider>\n </CSSCacheProvider>\n </DocumentProvider>\n )\n})\n\nexport default AppRoot\n\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAqBA;;;;AAIG;;;;AAIA;AACA;;;AAIA;;;AAIG;;;;;;AAMA;AACA;AACG;AACH;;;AAIH;AACG;AACG;;;AAGC;;;;AAWW;;AAEH;AAmBlB;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../../src/AppRoot/index.tsx"],"sourcesContent":["\"use client\";\nimport React, { useEffect, useId, useLayoutEffect, useRef } from 'react';\nimport { TagComponentType } from '../Tag/types';\nimport { ThemeProvider, ThemeProviderProps } from '../theme';\nimport { BreakpointProvider } from '../breakpoint';\nimport { RenderRenderar } from './Renderar';\nimport { DocumentProvider } from '../Document';\nimport { AppRootProvider } from './AppRootProvider';\nimport useMergeRefs from '../hooks/useMergeRefs';\nimport { CSSCacheProvider } from '../css/CSSCacheProvider';\nimport { BreakpointKeys } from '../css/types';\nimport Cookie from '../cookie';\n\nexport type AppRootProps<T extends TagComponentType = \"div\"> = ThemeProviderProps<T> & {\n noScrollbarCss?: boolean;\n document?: Document;\n CSSCacheId?: string;\n disableRenderar?: boolean;\n defaultBreakpoint?: BreakpointKeys\n selectionColor?: \"default\" | \"brand\" | \"accent\" | \"success\" | \"info\" | \"warning\" | \"danger\";\n}\n\nconst AppRoot = React.forwardRef(<T extends TagComponentType = \"div\">({ children, defaultBreakpoint, noScrollbarCss, CSSCacheId, theme, onThemeChange, disableRenderar, selectionColor, document: _document, ...props }: AppRootProps<T>, ref: React.Ref<any>) => {\n\n noScrollbarCss ??= false\n selectionColor ??= \"brand\"\n if (typeof window !== \"undefined\") {\n _document ??= document\n }\n disableRenderar ??= false\n const docid = useId()\n const csscacheId = useId()\n CSSCacheId ??= csscacheId\n\n const [visibility, setVisibility] = React.useState<string>(!defaultBreakpoint ? \"hidden\" : \"\");\n const rootRef = useRef(null)\n const mergeRef = useMergeRefs(rootRef, ref)\n\n useLayoutEffect(() => {\n !defaultBreakpoint && setVisibility(\"\");\n }, [])\n\n useEffect(() => {\n if (typeof _document === 'undefined') return;\n if (!Cookie.exists(\"xuitm\")) {\n Cookie.set(\"xuitm\", theme.name)\n }\n\n const styles = Array.from(_document.querySelectorAll('body style[data-oncss]'));\n styles.forEach((style) => {\n _document.head.appendChild(style);\n });\n }, [])\n\n let selection: any = {}\n if (selectionColor && selectionColor !== 'default') {\n selection = {\n \"&::selection\": {\n bgcolor: `${selectionColor}.primary`,\n color: `${selectionColor}.text`\n }\n }\n }\n\n return (\n <DocumentProvider value={_document ? { document: _document, id: docid } : undefined}>\n <CSSCacheProvider cacheId={CSSCacheId}>\n <AppRootProvider element={() => rootRef.current}>\n <ThemeProvider\n theme={theme}\n onThemeChange={(t) => {\n onThemeChange && onThemeChange(t)\n Cookie.set(\"xuitm\", t.name)\n }}\n {...props}\n ref={mergeRef}\n isRoot\n sx={{\n ...props.sx,\n ...(visibility === \"hidden\" ? { visibility: \"hidden\" } : {}),\n ...selection\n }}\n >\n <BreakpointProvider defaultKey={defaultBreakpoint ?? \"xl\"}>\n {children}\n {!disableRenderar && <RenderRenderar />}\n </BreakpointProvider>\n </ThemeProvider>\n </AppRootProvider>\n </CSSCacheProvider>\n </DocumentProvider>\n )\n})\n\nexport default AppRoot\n\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAsBA;;;;AAIG;;;;AAIA;AACA;;;AAIA;;;AAIG;;;;;;;;AASA;AACA;AACG;AACH;;;AAIH;AACG;AACG;;;AAGC;;;;AAWW;;AAEH;AAmBlB;;"}
package/AppRoot/index.js CHANGED
@@ -12,6 +12,7 @@ import { DocumentProvider } from '../Document/index.js';
12
12
  import { AppRootProvider } from './AppRootProvider.js';
13
13
  import useMergeRefs from '../hooks/useMergeRefs.js';
14
14
  import { CSSCacheProvider } from '../css/CSSCacheProvider.js';
15
+ import Cookie from '../cookie.js';
15
16
 
16
17
  const AppRoot = React__default.forwardRef((_a, ref) => {
17
18
  var { children, defaultBreakpoint, noScrollbarCss, CSSCacheId, theme, onThemeChange, disableRenderar, selectionColor, document: _document } = _a, props = __rest(_a, ["children", "defaultBreakpoint", "noScrollbarCss", "CSSCacheId", "theme", "onThemeChange", "disableRenderar", "selectionColor", "document"]);
@@ -33,7 +34,9 @@ const AppRoot = React__default.forwardRef((_a, ref) => {
33
34
  useEffect(() => {
34
35
  if (typeof _document === 'undefined')
35
36
  return;
36
- document.cookie = `xuitm=${theme.name};path=/`;
37
+ if (!Cookie.exists("xuitm")) {
38
+ Cookie.set("xuitm", theme.name);
39
+ }
37
40
  const styles = Array.from(_document.querySelectorAll('body style[data-oncss]'));
38
41
  styles.forEach((style) => {
39
42
  _document.head.appendChild(style);
@@ -50,7 +53,7 @@ const AppRoot = React__default.forwardRef((_a, ref) => {
50
53
  }
51
54
  return (jsx(DocumentProvider, { value: _document ? { document: _document, id: docid } : undefined, children: jsx(CSSCacheProvider, { cacheId: CSSCacheId, children: jsx(AppRootProvider, { element: () => rootRef.current, children: jsx(ThemeProvider, Object.assign({ theme: theme, onThemeChange: (t) => {
52
55
  onThemeChange && onThemeChange(t);
53
- document.cookie = `xuitm=${t.name};path=/`;
56
+ Cookie.set("xuitm", t.name);
54
57
  } }, props, { ref: mergeRef, isRoot: true, sx: Object.assign(Object.assign(Object.assign({}, props.sx), (visibility === "hidden" ? { visibility: "hidden" } : {})), selection), children: jsxs(BreakpointProvider, { defaultKey: defaultBreakpoint !== null && defaultBreakpoint !== void 0 ? defaultBreakpoint : "xl", children: [children, !disableRenderar && jsx(RenderRenderar, {})] }) })) }) }) }));
55
58
  });
56
59
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/AppRoot/index.tsx"],"sourcesContent":["\"use client\";\nimport React, { useEffect, useId, useLayoutEffect, useRef } from 'react';\nimport { TagComponentType } from '../Tag/types';\nimport { ThemeProvider, ThemeProviderProps } from '../theme';\nimport { BreakpointProvider } from '../breakpoint';\nimport { RenderRenderar } from './Renderar';\nimport { DocumentProvider } from '../Document';\nimport { AppRootProvider } from './AppRootProvider';\nimport useMergeRefs from '../hooks/useMergeRefs';\nimport { CSSCacheProvider } from '../css/CSSCacheProvider';\nimport { BreakpointKeys } from '../css/types';\n\nexport type AppRootProps<T extends TagComponentType = \"div\"> = ThemeProviderProps<T> & {\n noScrollbarCss?: boolean;\n document?: Document;\n CSSCacheId?: string;\n disableRenderar?: boolean;\n defaultBreakpoint?: BreakpointKeys\n selectionColor?: \"default\" | \"brand\" | \"accent\" | \"success\" | \"info\" | \"warning\" | \"danger\";\n}\n\nconst AppRoot = React.forwardRef(<T extends TagComponentType = \"div\">({ children, defaultBreakpoint, noScrollbarCss, CSSCacheId, theme, onThemeChange, disableRenderar, selectionColor, document: _document, ...props }: AppRootProps<T>, ref: React.Ref<any>) => {\n\n noScrollbarCss ??= false\n selectionColor ??= \"brand\"\n if (typeof window !== \"undefined\") {\n _document ??= document\n }\n disableRenderar ??= false\n const docid = useId()\n const csscacheId = useId()\n CSSCacheId ??= csscacheId\n\n const [visibility, setVisibility] = React.useState<string>(!defaultBreakpoint ? \"hidden\" : \"\");\n const rootRef = useRef(null)\n const mergeRef = useMergeRefs(rootRef, ref)\n\n useLayoutEffect(() => {\n !defaultBreakpoint && setVisibility(\"\");\n }, [])\n\n useEffect(() => {\n if (typeof _document === 'undefined') return;\n document.cookie = `xuitm=${theme.name};path=/`\n const styles = Array.from(_document.querySelectorAll('body style[data-oncss]'));\n styles.forEach((style) => {\n _document.head.appendChild(style);\n });\n }, [])\n\n let selection: any = {}\n if (selectionColor && selectionColor !== 'default') {\n selection = {\n \"&::selection\": {\n bgcolor: `${selectionColor}.primary`,\n color: `${selectionColor}.text`\n }\n }\n }\n\n return (\n <DocumentProvider value={_document ? { document: _document, id: docid } : undefined}>\n <CSSCacheProvider cacheId={CSSCacheId}>\n <AppRootProvider element={() => rootRef.current}>\n <ThemeProvider\n theme={theme}\n onThemeChange={(t) => {\n onThemeChange && onThemeChange(t)\n document.cookie = `xuitm=${t.name};path=/`\n }}\n {...props}\n ref={mergeRef}\n isRoot\n sx={{\n ...props.sx,\n ...(visibility === \"hidden\" ? { visibility: \"hidden\" } : {}),\n ...selection\n }}\n >\n <BreakpointProvider defaultKey={defaultBreakpoint ?? \"xl\"}>\n {children}\n {!disableRenderar && <RenderRenderar />}\n </BreakpointProvider>\n </ThemeProvider>\n </AppRootProvider>\n </CSSCacheProvider>\n </DocumentProvider>\n )\n})\n\nexport default AppRoot\n\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAqBA;;;;AAIG;;;;AAIA;AACA;;;AAIA;;;AAIG;;;;;;AAMA;AACA;AACG;AACH;;;AAIH;AACG;AACG;;;AAGC;;;;AAWW;;AAEH;AAmBlB;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/AppRoot/index.tsx"],"sourcesContent":["\"use client\";\nimport React, { useEffect, useId, useLayoutEffect, useRef } from 'react';\nimport { TagComponentType } from '../Tag/types';\nimport { ThemeProvider, ThemeProviderProps } from '../theme';\nimport { BreakpointProvider } from '../breakpoint';\nimport { RenderRenderar } from './Renderar';\nimport { DocumentProvider } from '../Document';\nimport { AppRootProvider } from './AppRootProvider';\nimport useMergeRefs from '../hooks/useMergeRefs';\nimport { CSSCacheProvider } from '../css/CSSCacheProvider';\nimport { BreakpointKeys } from '../css/types';\nimport Cookie from '../cookie';\n\nexport type AppRootProps<T extends TagComponentType = \"div\"> = ThemeProviderProps<T> & {\n noScrollbarCss?: boolean;\n document?: Document;\n CSSCacheId?: string;\n disableRenderar?: boolean;\n defaultBreakpoint?: BreakpointKeys\n selectionColor?: \"default\" | \"brand\" | \"accent\" | \"success\" | \"info\" | \"warning\" | \"danger\";\n}\n\nconst AppRoot = React.forwardRef(<T extends TagComponentType = \"div\">({ children, defaultBreakpoint, noScrollbarCss, CSSCacheId, theme, onThemeChange, disableRenderar, selectionColor, document: _document, ...props }: AppRootProps<T>, ref: React.Ref<any>) => {\n\n noScrollbarCss ??= false\n selectionColor ??= \"brand\"\n if (typeof window !== \"undefined\") {\n _document ??= document\n }\n disableRenderar ??= false\n const docid = useId()\n const csscacheId = useId()\n CSSCacheId ??= csscacheId\n\n const [visibility, setVisibility] = React.useState<string>(!defaultBreakpoint ? \"hidden\" : \"\");\n const rootRef = useRef(null)\n const mergeRef = useMergeRefs(rootRef, ref)\n\n useLayoutEffect(() => {\n !defaultBreakpoint && setVisibility(\"\");\n }, [])\n\n useEffect(() => {\n if (typeof _document === 'undefined') return;\n if (!Cookie.exists(\"xuitm\")) {\n Cookie.set(\"xuitm\", theme.name)\n }\n\n const styles = Array.from(_document.querySelectorAll('body style[data-oncss]'));\n styles.forEach((style) => {\n _document.head.appendChild(style);\n });\n }, [])\n\n let selection: any = {}\n if (selectionColor && selectionColor !== 'default') {\n selection = {\n \"&::selection\": {\n bgcolor: `${selectionColor}.primary`,\n color: `${selectionColor}.text`\n }\n }\n }\n\n return (\n <DocumentProvider value={_document ? { document: _document, id: docid } : undefined}>\n <CSSCacheProvider cacheId={CSSCacheId}>\n <AppRootProvider element={() => rootRef.current}>\n <ThemeProvider\n theme={theme}\n onThemeChange={(t) => {\n onThemeChange && onThemeChange(t)\n Cookie.set(\"xuitm\", t.name)\n }}\n {...props}\n ref={mergeRef}\n isRoot\n sx={{\n ...props.sx,\n ...(visibility === \"hidden\" ? { visibility: \"hidden\" } : {}),\n ...selection\n }}\n >\n <BreakpointProvider defaultKey={defaultBreakpoint ?? \"xl\"}>\n {children}\n {!disableRenderar && <RenderRenderar />}\n </BreakpointProvider>\n </ThemeProvider>\n </AppRootProvider>\n </CSSCacheProvider>\n </DocumentProvider>\n )\n})\n\nexport default AppRoot\n\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAsBA;;;;AAIG;;;;AAIA;AACA;;;AAIA;;;AAIG;;;;;;;;AASA;AACA;AACG;AACH;;;AAIH;AACG;AACG;;;AAGC;;;;AAWW;;AAEH;AAmBlB;;"}
@@ -19,6 +19,8 @@ const getVariant = (rect, variant) => {
19
19
  function Transition(_a) {
20
20
  var { children } = _a, options = tslib.__rest(_a, ["children"]);
21
21
  let { disableInitialTransition = false, variant = "fade", duration = 400, delay, ease, easing, open, onOpen, onOpened, onClose, onClosed, onState } = options;
22
+ const endTimer = React.useRef(null);
23
+ const animId = React.useRef(0);
22
24
  const [rect, setRect] = React.useState();
23
25
  const [isDisableInitial, setIsDisableInitial] = React.useState(disableInitialTransition);
24
26
  const ref = React.useRef(null);
@@ -30,59 +32,92 @@ function Transition(_a) {
30
32
  };
31
33
  let [cls, setCls] = React.useState(() => {
32
34
  let props = {};
33
- if (!isDisableInitial) {
34
- props.visibility = 'hidden';
35
- }
36
- else if (isDisableInitial && !open) {
37
- props.visibility = 'hidden';
35
+ if (!isDisableInitial || (isDisableInitial && !open)) {
36
+ props.opacity = 0;
37
+ props.pointerEvents = 'none';
38
+ props.transition = 'none';
38
39
  }
39
40
  return style(props);
40
41
  });
41
42
  React.useEffect(() => {
42
- var _a;
43
- const rect = (_a = ref.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
44
- const v = getVariant(rect, variant);
45
- setCls(style(open ? v.from : v.to));
46
- setRect(rect);
43
+ let frame;
44
+ const measure = () => {
45
+ const node = ref.current;
46
+ if (!node) {
47
+ frame = requestAnimationFrame(measure); // ⬅️ retry next frame
48
+ return;
49
+ }
50
+ const rect = node.getBoundingClientRect();
51
+ const v = getVariant(rect, variant);
52
+ const initial = isDisableInitial
53
+ ? (open ? v.to : v.from)
54
+ : (open ? v.from : v.to);
55
+ setCls(style(Object.assign(Object.assign({}, initial), { transition: 'none' })));
56
+ setRect(rect);
57
+ };
58
+ frame = requestAnimationFrame(measure);
59
+ return () => {
60
+ if (endTimer.current) {
61
+ clearTimeout(endTimer.current);
62
+ }
63
+ cancelAnimationFrame(frame);
64
+ };
47
65
  }, []);
48
- React.useLayoutEffect(() => {
66
+ React.useEffect(() => {
49
67
  if (rect) {
50
- const v = getVariant(rect, variant);
51
- let _css = open ? v.to : v.from;
52
- let trans = ` ${duration}ms ${_ease} ${delay || 0}ms`;
68
+ let _duration = isDisableInitial ? 0 : duration;
69
+ let _delay = isDisableInitial ? 0 : (delay || 0);
53
70
  if (isDisableInitial) {
54
- trans = '';
55
71
  setIsDisableInitial(false);
56
72
  }
57
- let _ = Object.assign(Object.assign({}, _css), { transition: Object.keys(_css || {}).map(k => oncss.formatCSSProp(k)).join(trans + ", ") + trans });
73
+ const v = getVariant(rect, variant);
74
+ let _css = open ? v.to : v.from;
75
+ let _ = Object.assign(Object.assign({}, _css), { transition: Object.keys(_css || {})
76
+ .map(k => `${oncss.formatCSSProp(k)} ${_duration}ms ${_ease} ${_delay}ms`)
77
+ .join(", "), willChange: Object.keys(_css || {})
78
+ .map(oncss.formatCSSProp)
79
+ .join(", ") });
80
+ if (open) {
81
+ onOpen === null || onOpen === void 0 ? void 0 : onOpen();
82
+ onState === null || onState === void 0 ? void 0 : onState("open");
83
+ }
84
+ else {
85
+ onClose === null || onClose === void 0 ? void 0 : onClose();
86
+ onState === null || onState === void 0 ? void 0 : onState("close");
87
+ }
58
88
  setCls(style(_));
59
- const ele = ref.current;
60
- let stimer = null;
61
- let etimer = null;
62
- ele.ontransitionstart = () => {
63
- clearTimeout(stimer);
64
- stimer = setTimeout(() => {
65
- (onOpen && open) && onOpen();
66
- (onClose && !open) && onClose();
67
- onState && onState(open ? "open" : "close");
68
- }, 1);
69
- };
70
- ele.ontransitionend = () => {
71
- clearTimeout(etimer);
72
- etimer = setTimeout(() => {
73
- if (onOpened && open)
74
- onOpened();
75
- if (onClosed && !open)
76
- onClosed();
77
- onState && onState(open ? "opened" : "closed");
78
- }, 1);
79
- };
89
+ if (endTimer.current) {
90
+ clearTimeout(endTimer.current);
91
+ }
92
+ animId.current++;
93
+ const id = animId.current;
94
+ endTimer.current = setTimeout(() => {
95
+ if (id !== animId.current)
96
+ return;
97
+ if (open) {
98
+ onOpened === null || onOpened === void 0 ? void 0 : onOpened();
99
+ onState === null || onState === void 0 ? void 0 : onState("opened");
100
+ }
101
+ else {
102
+ onClosed === null || onClosed === void 0 ? void 0 : onClosed();
103
+ onState === null || onState === void 0 ? void 0 : onState("closed");
104
+ }
105
+ }, _duration + _delay);
80
106
  }
81
107
  }, [rect, open, variant]);
82
108
  const clone = React.Children.only(children);
83
109
  return React.cloneElement(clone, {
84
110
  className: cls,
85
- ref
111
+ ref: (node) => {
112
+ ref.current = node;
113
+ const childRef = clone.ref;
114
+ if (typeof childRef === "function") {
115
+ childRef(node);
116
+ }
117
+ else if (childRef) {
118
+ childRef.current = node;
119
+ }
120
+ }
86
121
  });
87
122
  }
88
123
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../src/Transition/index.tsx"],"sourcesContent":["\"use client\";\nimport React, { cloneElement, Children, useState, useLayoutEffect, useEffect, useRef } from 'react';\nimport * as variants from './variants'\nimport { css } from '../css';\nimport { useDocument } from '../Document';\nimport { useCSSCacheId } from '../css/CSSCacheProvider';\nimport { animationEases } from '../hooks/useAnimation';\nimport { formatCSSProp } from 'oncss';\nimport { CSSProps } from '../css/types';\n\nexport type TransitionVariantTypes = keyof typeof variants\nexport type TransitionVariant = TransitionVariantTypes | ((rect: DOMRect) => ({ from: CSSProps, to: CSSProps }))\nexport type TransitionState = \"open\" | \"opened\" | \"close\" | \"closed\"\n\nexport type TransitionProps = {\n children: React.ReactElement;\n open: boolean;\n variant: TransitionVariant\n ease?: string;\n easing?: keyof typeof animationEases;\n duration?: number;\n delay?: number;\n disableInitialTransition?: boolean;\n onOpen?: () => void;\n onOpened?: () => void;\n onClose?: () => void;\n onClosed?: () => void;\n onState?: (state: TransitionState) => void;\n}\n\nconst getVariant = (rect: DOMRect, variant: TransitionVariant) => {\n let fn = typeof variant === 'string' ? variants[variant] : variant\n if (!fn) throw new Error(`Transition variant \"${variant}\" not found.`)\n return fn(rect as DOMRect);\n}\n\nfunction Transition({ children, ...options }: TransitionProps) {\n let {\n disableInitialTransition = false,\n variant = \"fade\",\n duration = 400,\n delay,\n ease,\n easing,\n open,\n onOpen,\n onOpened,\n onClose,\n onClosed,\n onState\n } = options\n\n const [rect, setRect] = useState<DOMRect>()\n const [isDisableInitial, setIsDisableInitial] = useState(disableInitialTransition)\n const ref = useRef<HTMLElement>(null)\n const doc = useDocument();\n const cacheId = useCSSCacheId()\n let _ease = ease || (animationEases as any)[easing as any] || animationEases.bounce\n\n const style = (obj = {}) => {\n return css(obj, { container: doc?.document, cacheId }).classname;\n }\n\n let [cls, setCls] = useState(() => {\n let props: any = {}\n if (!isDisableInitial) {\n props.visibility = 'hidden'\n } else if (isDisableInitial && !open) {\n props.visibility = 'hidden'\n }\n return style(props)\n })\n\n\n useEffect(() => {\n const rect = ref.current?.getBoundingClientRect() as DOMRect\n const v = getVariant(rect, variant)\n setCls(style(open ? v.from : v.to))\n setRect(rect)\n }, [])\n\n useLayoutEffect(() => {\n if (rect) {\n const v = getVariant(rect, variant)\n let _css: any = open ? v.to : v.from\n let trans = ` ${duration}ms ${_ease} ${delay || 0}ms`\n if (isDisableInitial) {\n trans = ''\n setIsDisableInitial(false)\n }\n let _ = {\n ..._css,\n transition: Object.keys(_css || {}).map(k => formatCSSProp(k)).join(trans + \", \") + trans,\n }\n\n setCls(style(_))\n\n const ele = ref.current as HTMLElement\n let stimer: any = null\n let etimer: any = null\n ele.ontransitionstart = () => {\n clearTimeout(stimer)\n stimer = setTimeout(() => {\n (onOpen && open) && onOpen();\n (onClose && !open) && onClose()\n onState && onState(open ? \"open\" : \"close\")\n }, 1)\n }\n ele.ontransitionend = () => {\n clearTimeout(etimer)\n etimer = setTimeout(() => {\n if (onOpened && open) onOpened();\n if (onClosed && !open) onClosed();\n onState && onState(open ? \"opened\" : \"closed\")\n }, 1)\n }\n }\n }, [rect, open, variant])\n\n const clone: any = Children.only(children);\n return cloneElement(clone, {\n className: cls,\n ref\n });\n}\n\nexport default Transition"],"names":[],"mappings":";;;;;;;;;;;;AA8BA;AACI;AACA;AAAS;AACT;AACJ;AAEA;AAAoB;AAChB;;;AAiBA;AACA;AACA;AACA;AAEA;;AAEA;;;;AAKQ;;AACG;AACH;;AAEJ;AACJ;;;;;AAMI;;;;;;AAOI;;;;;;AAMA;AAKA;AAEA;;;AAGA;;AAEI;AACI;;AAEA;;AAER;AACA;;AAEI;;AAC0B;;AACC;AACvB;;AAER;;;;;AAMJ;;AAEH;AACL;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../../src/Transition/index.tsx"],"sourcesContent":["\"use client\";\nimport React, { cloneElement, Children, useState, useEffect, useRef } from 'react';\nimport * as variants from './variants'\nimport { css } from '../css';\nimport { useDocument } from '../Document';\nimport { useCSSCacheId } from '../css/CSSCacheProvider';\nimport { animationEases } from '../hooks/useAnimation';\nimport { formatCSSProp } from 'oncss';\nimport { CSSProps } from '../css/types';\n\nexport type TransitionVariantTypes = keyof typeof variants\nexport type TransitionVariant = TransitionVariantTypes | ((rect: DOMRect) => ({ from: CSSProps, to: CSSProps }))\nexport type TransitionState = \"open\" | \"opened\" | \"close\" | \"closed\"\n\nexport type TransitionProps = {\n children: React.ReactElement;\n open: boolean;\n variant: TransitionVariant\n ease?: string;\n easing?: keyof typeof animationEases;\n duration?: number;\n delay?: number;\n disableInitialTransition?: boolean;\n onOpen?: () => void;\n onOpened?: () => void;\n onClose?: () => void;\n onClosed?: () => void;\n onState?: (state: TransitionState) => void;\n}\n\nconst getVariant = (rect: DOMRect, variant: TransitionVariant) => {\n let fn = typeof variant === 'string' ? variants[variant] : variant\n if (!fn) throw new Error(`Transition variant \"${variant}\" not found.`)\n return fn(rect as DOMRect);\n}\n\nfunction Transition({ children, ...options }: TransitionProps) {\n let {\n disableInitialTransition = false,\n variant = \"fade\",\n duration = 400,\n delay,\n ease,\n easing,\n open,\n onOpen,\n onOpened,\n onClose,\n onClosed,\n onState\n } = options\n\n const endTimer = useRef<any>(null)\n const animId = useRef(0)\n const [rect, setRect] = useState<DOMRect>()\n const [isDisableInitial, setIsDisableInitial] = useState(disableInitialTransition)\n const ref = useRef<HTMLElement>(null)\n const doc = useDocument();\n const cacheId = useCSSCacheId()\n let _ease = ease || (animationEases as any)[easing as any] || animationEases.bounce\n\n const style = (obj = {}) => {\n return css(obj, { container: doc?.document, cacheId }).classname;\n }\n\n let [cls, setCls] = useState(() => {\n let props: any = {}\n if (!isDisableInitial || (isDisableInitial && !open)) {\n props.opacity = 0\n props.pointerEvents = 'none'\n props.transition = 'none'\n }\n return style(props)\n })\n\n\n useEffect(() => {\n let frame: any\n const measure = () => {\n const node = ref.current\n if (!node) {\n frame = requestAnimationFrame(measure) // ⬅️ retry next frame\n return\n }\n\n const rect = node.getBoundingClientRect()\n const v = getVariant(rect, variant)\n const initial = isDisableInitial\n ? (open ? v.to : v.from)\n : (open ? v.from : v.to)\n\n setCls(style({\n ...initial,\n transition: 'none'\n }))\n setRect(rect)\n }\n\n frame = requestAnimationFrame(measure)\n\n return () => {\n if (endTimer.current) {\n clearTimeout(endTimer.current)\n }\n cancelAnimationFrame(frame)\n }\n\n }, [])\n\n useEffect(() => {\n if (rect) {\n let _duration = isDisableInitial ? 0 : duration\n let _delay = isDisableInitial ? 0 : (delay || 0)\n\n if (isDisableInitial) {\n setIsDisableInitial(false)\n }\n const v = getVariant(rect, variant)\n let _css: any = open ? v.to : v.from\n\n let _ = {\n ..._css,\n transition: Object.keys(_css || {})\n .map(k => `${formatCSSProp(k)} ${_duration}ms ${_ease} ${_delay}ms`)\n .join(\", \"),\n willChange: Object.keys(_css || {})\n .map(formatCSSProp)\n .join(\", \"),\n }\n\n if (open) {\n onOpen?.();\n onState?.(\"open\");\n } else {\n onClose?.();\n onState?.(\"close\");\n }\n\n setCls(style(_))\n if (endTimer.current) {\n clearTimeout(endTimer.current)\n }\n animId.current++\n const id = animId.current\n endTimer.current = setTimeout(() => {\n if (id !== animId.current) return\n if (open) {\n onOpened?.();\n onState?.(\"opened\");\n } else {\n onClosed?.();\n onState?.(\"closed\");\n }\n }, _duration + _delay)\n }\n }, [rect, open, variant])\n\n const clone: any = Children.only(children);\n\n return cloneElement(clone, {\n className: cls,\n ref: (node: HTMLElement) => {\n ref.current = node;\n\n const childRef = (clone as any).ref;\n if (typeof childRef === \"function\") {\n childRef(node);\n } else if (childRef) {\n childRef.current = node;\n }\n }\n });\n}\n\nexport default Transition"],"names":[],"mappings":";;;;;;;;;;;;AA8BA;AACI;AACA;AAAS;AACT;AACJ;AAEA;AAAoB;AAChB;AAeA;AACA;;;AAGA;AACA;AACA;AACA;AAEA;;AAEA;;;;AAKQ;AACA;AACA;;AAEJ;AACJ;;AAII;;AAEI;;AAEI;;;AAIJ;;;AAGI;AACA;;;AAOR;AAEA;AAEA;AACI;AACI;;;AAGR;;;;;AAOI;;;;;AAMA;AAEA;AAGS;AACA;;AAGA;;AAIL;AACA;;;AAEA;AACA;;AAGJ;AACA;AACI;;;AAGJ;AACA;AACI;;;AAEI;AACA;;;AAEA;AACA;;AAER;;;;;AAOJ;AACA;AACI;AAEA;AACA;;;;AAGI;;;AAGX;AACL;;"}
@@ -26,7 +26,7 @@ type TransitionProps = {
26
26
  };
27
27
  declare function Transition({ children, ...options }: TransitionProps): React__default.DetailedReactHTMLElement<{
28
28
  className: string;
29
- ref: React__default.RefObject<HTMLElement | null>;
29
+ ref: (node: HTMLElement) => void;
30
30
  }, HTMLElement>;
31
31
 
32
32
  export { Transition as default };
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { __rest } from 'tslib';
3
- import { useState, useRef, useEffect, useLayoutEffect, Children, cloneElement } from 'react';
3
+ import { useRef, useState, useEffect, Children, cloneElement } from 'react';
4
4
  import * as variants from './variants.js';
5
5
  import { css } from '../css/index.js';
6
6
  import { useDocument } from '../Document/index.js';
@@ -17,6 +17,8 @@ const getVariant = (rect, variant) => {
17
17
  function Transition(_a) {
18
18
  var { children } = _a, options = __rest(_a, ["children"]);
19
19
  let { disableInitialTransition = false, variant = "fade", duration = 400, delay, ease, easing, open, onOpen, onOpened, onClose, onClosed, onState } = options;
20
+ const endTimer = useRef(null);
21
+ const animId = useRef(0);
20
22
  const [rect, setRect] = useState();
21
23
  const [isDisableInitial, setIsDisableInitial] = useState(disableInitialTransition);
22
24
  const ref = useRef(null);
@@ -28,59 +30,92 @@ function Transition(_a) {
28
30
  };
29
31
  let [cls, setCls] = useState(() => {
30
32
  let props = {};
31
- if (!isDisableInitial) {
32
- props.visibility = 'hidden';
33
- }
34
- else if (isDisableInitial && !open) {
35
- props.visibility = 'hidden';
33
+ if (!isDisableInitial || (isDisableInitial && !open)) {
34
+ props.opacity = 0;
35
+ props.pointerEvents = 'none';
36
+ props.transition = 'none';
36
37
  }
37
38
  return style(props);
38
39
  });
39
40
  useEffect(() => {
40
- var _a;
41
- const rect = (_a = ref.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
42
- const v = getVariant(rect, variant);
43
- setCls(style(open ? v.from : v.to));
44
- setRect(rect);
41
+ let frame;
42
+ const measure = () => {
43
+ const node = ref.current;
44
+ if (!node) {
45
+ frame = requestAnimationFrame(measure); // ⬅️ retry next frame
46
+ return;
47
+ }
48
+ const rect = node.getBoundingClientRect();
49
+ const v = getVariant(rect, variant);
50
+ const initial = isDisableInitial
51
+ ? (open ? v.to : v.from)
52
+ : (open ? v.from : v.to);
53
+ setCls(style(Object.assign(Object.assign({}, initial), { transition: 'none' })));
54
+ setRect(rect);
55
+ };
56
+ frame = requestAnimationFrame(measure);
57
+ return () => {
58
+ if (endTimer.current) {
59
+ clearTimeout(endTimer.current);
60
+ }
61
+ cancelAnimationFrame(frame);
62
+ };
45
63
  }, []);
46
- useLayoutEffect(() => {
64
+ useEffect(() => {
47
65
  if (rect) {
48
- const v = getVariant(rect, variant);
49
- let _css = open ? v.to : v.from;
50
- let trans = ` ${duration}ms ${_ease} ${delay || 0}ms`;
66
+ let _duration = isDisableInitial ? 0 : duration;
67
+ let _delay = isDisableInitial ? 0 : (delay || 0);
51
68
  if (isDisableInitial) {
52
- trans = '';
53
69
  setIsDisableInitial(false);
54
70
  }
55
- let _ = Object.assign(Object.assign({}, _css), { transition: Object.keys(_css || {}).map(k => formatCSSProp(k)).join(trans + ", ") + trans });
71
+ const v = getVariant(rect, variant);
72
+ let _css = open ? v.to : v.from;
73
+ let _ = Object.assign(Object.assign({}, _css), { transition: Object.keys(_css || {})
74
+ .map(k => `${formatCSSProp(k)} ${_duration}ms ${_ease} ${_delay}ms`)
75
+ .join(", "), willChange: Object.keys(_css || {})
76
+ .map(formatCSSProp)
77
+ .join(", ") });
78
+ if (open) {
79
+ onOpen === null || onOpen === void 0 ? void 0 : onOpen();
80
+ onState === null || onState === void 0 ? void 0 : onState("open");
81
+ }
82
+ else {
83
+ onClose === null || onClose === void 0 ? void 0 : onClose();
84
+ onState === null || onState === void 0 ? void 0 : onState("close");
85
+ }
56
86
  setCls(style(_));
57
- const ele = ref.current;
58
- let stimer = null;
59
- let etimer = null;
60
- ele.ontransitionstart = () => {
61
- clearTimeout(stimer);
62
- stimer = setTimeout(() => {
63
- (onOpen && open) && onOpen();
64
- (onClose && !open) && onClose();
65
- onState && onState(open ? "open" : "close");
66
- }, 1);
67
- };
68
- ele.ontransitionend = () => {
69
- clearTimeout(etimer);
70
- etimer = setTimeout(() => {
71
- if (onOpened && open)
72
- onOpened();
73
- if (onClosed && !open)
74
- onClosed();
75
- onState && onState(open ? "opened" : "closed");
76
- }, 1);
77
- };
87
+ if (endTimer.current) {
88
+ clearTimeout(endTimer.current);
89
+ }
90
+ animId.current++;
91
+ const id = animId.current;
92
+ endTimer.current = setTimeout(() => {
93
+ if (id !== animId.current)
94
+ return;
95
+ if (open) {
96
+ onOpened === null || onOpened === void 0 ? void 0 : onOpened();
97
+ onState === null || onState === void 0 ? void 0 : onState("opened");
98
+ }
99
+ else {
100
+ onClosed === null || onClosed === void 0 ? void 0 : onClosed();
101
+ onState === null || onState === void 0 ? void 0 : onState("closed");
102
+ }
103
+ }, _duration + _delay);
78
104
  }
79
105
  }, [rect, open, variant]);
80
106
  const clone = Children.only(children);
81
107
  return cloneElement(clone, {
82
108
  className: cls,
83
- ref
109
+ ref: (node) => {
110
+ ref.current = node;
111
+ const childRef = clone.ref;
112
+ if (typeof childRef === "function") {
113
+ childRef(node);
114
+ }
115
+ else if (childRef) {
116
+ childRef.current = node;
117
+ }
118
+ }
84
119
  });
85
120
  }
86
121
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/Transition/index.tsx"],"sourcesContent":["\"use client\";\nimport React, { cloneElement, Children, useState, useLayoutEffect, useEffect, useRef } from 'react';\nimport * as variants from './variants'\nimport { css } from '../css';\nimport { useDocument } from '../Document';\nimport { useCSSCacheId } from '../css/CSSCacheProvider';\nimport { animationEases } from '../hooks/useAnimation';\nimport { formatCSSProp } from 'oncss';\nimport { CSSProps } from '../css/types';\n\nexport type TransitionVariantTypes = keyof typeof variants\nexport type TransitionVariant = TransitionVariantTypes | ((rect: DOMRect) => ({ from: CSSProps, to: CSSProps }))\nexport type TransitionState = \"open\" | \"opened\" | \"close\" | \"closed\"\n\nexport type TransitionProps = {\n children: React.ReactElement;\n open: boolean;\n variant: TransitionVariant\n ease?: string;\n easing?: keyof typeof animationEases;\n duration?: number;\n delay?: number;\n disableInitialTransition?: boolean;\n onOpen?: () => void;\n onOpened?: () => void;\n onClose?: () => void;\n onClosed?: () => void;\n onState?: (state: TransitionState) => void;\n}\n\nconst getVariant = (rect: DOMRect, variant: TransitionVariant) => {\n let fn = typeof variant === 'string' ? variants[variant] : variant\n if (!fn) throw new Error(`Transition variant \"${variant}\" not found.`)\n return fn(rect as DOMRect);\n}\n\nfunction Transition({ children, ...options }: TransitionProps) {\n let {\n disableInitialTransition = false,\n variant = \"fade\",\n duration = 400,\n delay,\n ease,\n easing,\n open,\n onOpen,\n onOpened,\n onClose,\n onClosed,\n onState\n } = options\n\n const [rect, setRect] = useState<DOMRect>()\n const [isDisableInitial, setIsDisableInitial] = useState(disableInitialTransition)\n const ref = useRef<HTMLElement>(null)\n const doc = useDocument();\n const cacheId = useCSSCacheId()\n let _ease = ease || (animationEases as any)[easing as any] || animationEases.bounce\n\n const style = (obj = {}) => {\n return css(obj, { container: doc?.document, cacheId }).classname;\n }\n\n let [cls, setCls] = useState(() => {\n let props: any = {}\n if (!isDisableInitial) {\n props.visibility = 'hidden'\n } else if (isDisableInitial && !open) {\n props.visibility = 'hidden'\n }\n return style(props)\n })\n\n\n useEffect(() => {\n const rect = ref.current?.getBoundingClientRect() as DOMRect\n const v = getVariant(rect, variant)\n setCls(style(open ? v.from : v.to))\n setRect(rect)\n }, [])\n\n useLayoutEffect(() => {\n if (rect) {\n const v = getVariant(rect, variant)\n let _css: any = open ? v.to : v.from\n let trans = ` ${duration}ms ${_ease} ${delay || 0}ms`\n if (isDisableInitial) {\n trans = ''\n setIsDisableInitial(false)\n }\n let _ = {\n ..._css,\n transition: Object.keys(_css || {}).map(k => formatCSSProp(k)).join(trans + \", \") + trans,\n }\n\n setCls(style(_))\n\n const ele = ref.current as HTMLElement\n let stimer: any = null\n let etimer: any = null\n ele.ontransitionstart = () => {\n clearTimeout(stimer)\n stimer = setTimeout(() => {\n (onOpen && open) && onOpen();\n (onClose && !open) && onClose()\n onState && onState(open ? \"open\" : \"close\")\n }, 1)\n }\n ele.ontransitionend = () => {\n clearTimeout(etimer)\n etimer = setTimeout(() => {\n if (onOpened && open) onOpened();\n if (onClosed && !open) onClosed();\n onState && onState(open ? \"opened\" : \"closed\")\n }, 1)\n }\n }\n }, [rect, open, variant])\n\n const clone: any = Children.only(children);\n return cloneElement(clone, {\n className: cls,\n ref\n });\n}\n\nexport default Transition"],"names":[],"mappings":";;;;;;;;;;AA8BA;AACI;AACA;AAAS;AACT;AACJ;AAEA;AAAoB;AAChB;;;AAiBA;AACA;AACA;AACA;AAEA;;AAEA;;;;AAKQ;;AACG;AACH;;AAEJ;AACJ;;;;;AAMI;;;;;;AAOI;;;;;;AAMA;AAKA;AAEA;;;AAGA;;AAEI;AACI;;AAEA;;AAER;AACA;;AAEI;;AAC0B;;AACC;AACvB;;AAER;;;;;AAMJ;;AAEH;AACL;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/Transition/index.tsx"],"sourcesContent":["\"use client\";\nimport React, { cloneElement, Children, useState, useEffect, useRef } from 'react';\nimport * as variants from './variants'\nimport { css } from '../css';\nimport { useDocument } from '../Document';\nimport { useCSSCacheId } from '../css/CSSCacheProvider';\nimport { animationEases } from '../hooks/useAnimation';\nimport { formatCSSProp } from 'oncss';\nimport { CSSProps } from '../css/types';\n\nexport type TransitionVariantTypes = keyof typeof variants\nexport type TransitionVariant = TransitionVariantTypes | ((rect: DOMRect) => ({ from: CSSProps, to: CSSProps }))\nexport type TransitionState = \"open\" | \"opened\" | \"close\" | \"closed\"\n\nexport type TransitionProps = {\n children: React.ReactElement;\n open: boolean;\n variant: TransitionVariant\n ease?: string;\n easing?: keyof typeof animationEases;\n duration?: number;\n delay?: number;\n disableInitialTransition?: boolean;\n onOpen?: () => void;\n onOpened?: () => void;\n onClose?: () => void;\n onClosed?: () => void;\n onState?: (state: TransitionState) => void;\n}\n\nconst getVariant = (rect: DOMRect, variant: TransitionVariant) => {\n let fn = typeof variant === 'string' ? variants[variant] : variant\n if (!fn) throw new Error(`Transition variant \"${variant}\" not found.`)\n return fn(rect as DOMRect);\n}\n\nfunction Transition({ children, ...options }: TransitionProps) {\n let {\n disableInitialTransition = false,\n variant = \"fade\",\n duration = 400,\n delay,\n ease,\n easing,\n open,\n onOpen,\n onOpened,\n onClose,\n onClosed,\n onState\n } = options\n\n const endTimer = useRef<any>(null)\n const animId = useRef(0)\n const [rect, setRect] = useState<DOMRect>()\n const [isDisableInitial, setIsDisableInitial] = useState(disableInitialTransition)\n const ref = useRef<HTMLElement>(null)\n const doc = useDocument();\n const cacheId = useCSSCacheId()\n let _ease = ease || (animationEases as any)[easing as any] || animationEases.bounce\n\n const style = (obj = {}) => {\n return css(obj, { container: doc?.document, cacheId }).classname;\n }\n\n let [cls, setCls] = useState(() => {\n let props: any = {}\n if (!isDisableInitial || (isDisableInitial && !open)) {\n props.opacity = 0\n props.pointerEvents = 'none'\n props.transition = 'none'\n }\n return style(props)\n })\n\n\n useEffect(() => {\n let frame: any\n const measure = () => {\n const node = ref.current\n if (!node) {\n frame = requestAnimationFrame(measure) // ⬅️ retry next frame\n return\n }\n\n const rect = node.getBoundingClientRect()\n const v = getVariant(rect, variant)\n const initial = isDisableInitial\n ? (open ? v.to : v.from)\n : (open ? v.from : v.to)\n\n setCls(style({\n ...initial,\n transition: 'none'\n }))\n setRect(rect)\n }\n\n frame = requestAnimationFrame(measure)\n\n return () => {\n if (endTimer.current) {\n clearTimeout(endTimer.current)\n }\n cancelAnimationFrame(frame)\n }\n\n }, [])\n\n useEffect(() => {\n if (rect) {\n let _duration = isDisableInitial ? 0 : duration\n let _delay = isDisableInitial ? 0 : (delay || 0)\n\n if (isDisableInitial) {\n setIsDisableInitial(false)\n }\n const v = getVariant(rect, variant)\n let _css: any = open ? v.to : v.from\n\n let _ = {\n ..._css,\n transition: Object.keys(_css || {})\n .map(k => `${formatCSSProp(k)} ${_duration}ms ${_ease} ${_delay}ms`)\n .join(\", \"),\n willChange: Object.keys(_css || {})\n .map(formatCSSProp)\n .join(\", \"),\n }\n\n if (open) {\n onOpen?.();\n onState?.(\"open\");\n } else {\n onClose?.();\n onState?.(\"close\");\n }\n\n setCls(style(_))\n if (endTimer.current) {\n clearTimeout(endTimer.current)\n }\n animId.current++\n const id = animId.current\n endTimer.current = setTimeout(() => {\n if (id !== animId.current) return\n if (open) {\n onOpened?.();\n onState?.(\"opened\");\n } else {\n onClosed?.();\n onState?.(\"closed\");\n }\n }, _duration + _delay)\n }\n }, [rect, open, variant])\n\n const clone: any = Children.only(children);\n\n return cloneElement(clone, {\n className: cls,\n ref: (node: HTMLElement) => {\n ref.current = node;\n\n const childRef = (clone as any).ref;\n if (typeof childRef === \"function\") {\n childRef(node);\n } else if (childRef) {\n childRef.current = node;\n }\n }\n });\n}\n\nexport default Transition"],"names":[],"mappings":";;;;;;;;;;AA8BA;AACI;AACA;AAAS;AACT;AACJ;AAEA;AAAoB;AAChB;AAeA;AACA;;;AAGA;AACA;AACA;AACA;AAEA;;AAEA;;;;AAKQ;AACA;AACA;;AAEJ;AACJ;;AAII;;AAEI;;AAEI;;;AAIJ;;;AAGI;AACA;;;AAOR;AAEA;AAEA;AACI;AACI;;;AAGR;;;;;AAOI;;;;;AAMA;AAEA;AAGS;AACA;;AAGA;;AAIL;AACA;;;AAEA;AACA;;AAGJ;AACA;AACI;;;AAGJ;AACA;AACI;;;AAEI;AACA;;;AAEA;AACA;;AAER;;;;;AAOJ;AACA;AACI;AAEA;AACA;;;;AAGI;;;AAGX;AACL;;"}
@@ -50,6 +50,7 @@ const scaleYDown = () => ({
50
50
  from: {
51
51
  transform: "scaleY(0.8)",
52
52
  opacity: 0,
53
+ pointerEvents: 'none',
53
54
  transformOrigin: "top"
54
55
  },
55
56
  to: {
@@ -62,7 +63,8 @@ const scaleYUp = () => ({
62
63
  from: {
63
64
  transform: "scaleY(0.8)",
64
65
  transformOrigin: "bottom",
65
- opacity: 0
66
+ opacity: 0,
67
+ pointerEvents: 'none'
66
68
  },
67
69
  to: {
68
70
  transform: "scaleY(1)",
@@ -73,7 +75,8 @@ const scaleYUp = () => ({
73
75
  const fade = () => {
74
76
  return {
75
77
  from: {
76
- opacity: 0
78
+ opacity: 0,
79
+ pointerEvents: 'none'
77
80
  },
78
81
  to: {
79
82
  opacity: 1
@@ -85,7 +88,8 @@ const fadeDown = (rect) => {
85
88
  return {
86
89
  from: {
87
90
  transform: `translateY(-${y}px) scale(0.98)`,
88
- opacity: 0
91
+ opacity: 0,
92
+ pointerEvents: 'none'
89
93
  },
90
94
  to: {
91
95
  transform: `translateY(0) scale(1)`,
@@ -98,7 +102,8 @@ const fadeUp = (rect) => {
98
102
  return {
99
103
  from: {
100
104
  transform: `translateY(${y}px) scale(0.98)`,
101
- opacity: 0
105
+ opacity: 0,
106
+ pointerEvents: 'none'
102
107
  },
103
108
  to: {
104
109
  transform: `translateY(0) scale(1)`,
@@ -111,7 +116,8 @@ const fadeRight = (rect) => {
111
116
  return {
112
117
  from: {
113
118
  transform: `translateX(-${x}px) scale(0.98)`,
114
- opacity: 0
119
+ opacity: 0,
120
+ pointerEvents: 'none'
115
121
  },
116
122
  to: {
117
123
  transform: `translateX(0) scale(1)`,
@@ -124,7 +130,8 @@ const fadeLeft = (rect) => {
124
130
  return {
125
131
  from: {
126
132
  transform: `translateX(${x}px) scale(0.98)`,
127
- opacity: 0
133
+ opacity: 0,
134
+ pointerEvents: 'none'
128
135
  },
129
136
  to: {
130
137
  transform: `translateX(0) scale(1)`,
@@ -136,7 +143,8 @@ const grow = () => {
136
143
  return {
137
144
  from: {
138
145
  transform: "scale(.8, .6)",
139
- opacity: 0
146
+ opacity: 0,
147
+ pointerEvents: 'none'
140
148
  },
141
149
  to: {
142
150
  transform: "scale(1)",
@@ -149,7 +157,8 @@ const zoom = () => {
149
157
  from: {
150
158
  transform: "scale(.8)",
151
159
  transformOrigin: "center",
152
- opacity: 0
160
+ opacity: 0,
161
+ pointerEvents: 'none'
153
162
  },
154
163
  to: {
155
164
  transform: "scale(1)",
@@ -163,7 +172,8 @@ const zoomOver = () => {
163
172
  from: {
164
173
  transform: "scale(1.2)",
165
174
  transformOrigin: "center",
166
- opacity: 0
175
+ opacity: 0,
176
+ pointerEvents: 'none'
167
177
  },
168
178
  to: {
169
179
  transform: "scale(1)",
@@ -1 +1 @@
1
- {"version":3,"file":"variants.cjs","sources":["../../src/Transition/variants.ts"],"sourcesContent":["\nconst getY = (rect?: DOMRect) =>\n rect ? Math.min(rect.height / 2, 40) : 20\n\nconst getX = (rect?: DOMRect) =>\n rect ? Math.min(rect.width / 2, 40) : 20\n\n\n\nexport const slideDown = (rect?: DOMRect) => {\n const y = getY(rect)\n\n return {\n from: {\n transform: `translateY(-${y}px)`,\n },\n to: {\n transform: `translateY(0)`,\n }\n }\n}\n\nexport const slideUp = (rect?: DOMRect) => {\n const y = getY(rect)\n\n return {\n from: {\n transform: `translateY(${y}px)`,\n },\n to: {\n transform: `translateY(0)`,\n }\n }\n}\n\nexport const slideRight = (rect?: DOMRect) => {\n const x = getX(rect)\n\n return {\n from: {\n transform: `translateX(-${x}px)`,\n },\n to: {\n transform: `translateX(0)`,\n }\n }\n}\n\nexport const slideLeft = (rect?: DOMRect) => {\n const x = getX(rect)\n\n return {\n from: {\n transform: `translateX(${x}px)`,\n },\n to: {\n transform: `translateX(0)`,\n }\n }\n}\n\nexport const scaleYDown = () => ({\n from: {\n transform: \"scaleY(0.8)\",\n opacity: 0,\n transformOrigin: \"top\"\n },\n to: {\n transform: \"scaleY(1)\",\n opacity: 1,\n transformOrigin: \"top\"\n }\n})\n\nexport const scaleYUp = () => ({\n from: {\n transform: \"scaleY(0.8)\",\n transformOrigin: \"bottom\",\n opacity: 0\n },\n to: {\n transform: \"scaleY(1)\",\n transformOrigin: \"bottom\",\n opacity: 1\n }\n})\n\nexport const fade = () => {\n return {\n from: {\n opacity: 0\n },\n to: {\n opacity: 1\n }\n }\n}\n\n\nexport const fadeDown = (rect?: DOMRect) => {\n const y = getY(rect)\n\n return {\n from: {\n transform: `translateY(-${y}px) scale(0.98)`,\n opacity: 0\n },\n to: {\n transform: `translateY(0) scale(1)`,\n opacity: 1\n }\n }\n}\n\nexport const fadeUp = (rect?: DOMRect) => {\n const y = getY(rect)\n\n return {\n from: {\n transform: `translateY(${y}px) scale(0.98)`,\n opacity: 0\n },\n to: {\n transform: `translateY(0) scale(1)`,\n opacity: 1\n }\n }\n}\n\nexport const fadeRight = (rect?: DOMRect) => {\n const x = getX(rect)\n\n return {\n from: {\n transform: `translateX(-${x}px) scale(0.98)`,\n opacity: 0\n },\n to: {\n transform: `translateX(0) scale(1)`,\n opacity: 1\n }\n }\n}\n\nexport const fadeLeft = (rect?: DOMRect) => {\n const x = getX(rect)\n\n return {\n from: {\n transform: `translateX(${x}px) scale(0.98)`,\n opacity: 0\n },\n to: {\n transform: `translateX(0) scale(1)`,\n opacity: 1\n }\n }\n}\n\nexport const grow = () => {\n return {\n from: {\n transform: \"scale(.8, .6)\",\n opacity: 0\n },\n to: {\n transform: \"scale(1)\",\n opacity: 1\n }\n }\n}\n\nexport const zoom = () => {\n return {\n from: {\n transform: \"scale(.8)\",\n transformOrigin: \"center\",\n opacity: 0\n },\n to: {\n transform: \"scale(1)\",\n transformOrigin: \"center\",\n opacity: 1\n }\n }\n}\n\nexport const zoomOver = () => {\n return {\n from: {\n transform: \"scale(1.2)\",\n transformOrigin: \"center\",\n opacity: 0\n },\n to: {\n transform: \"scale(1)\",\n transformOrigin: \"center\",\n opacity: 1\n }\n }\n}\n\nexport const collapseVertical = (rect: DOMRect) => {\n return {\n from: {\n maxHeight: \"0px\",\n overflow: \"hidden\"\n },\n to: {\n maxHeight: rect.height + \"px\",\n overflow: \"hidden\"\n }\n }\n}\n\n\nexport const collapseHorizontal = (rect: DOMRect) => {\n return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;;;;;;;;;"}
1
+ {"version":3,"file":"variants.cjs","sources":["../../src/Transition/variants.ts"],"sourcesContent":["\nconst getY = (rect?: DOMRect) =>\n rect ? Math.min(rect.height / 2, 40) : 20\n\nconst getX = (rect?: DOMRect) =>\n rect ? Math.min(rect.width / 2, 40) : 20\n\n\n\nexport const slideDown = (rect?: DOMRect) => {\n const y = getY(rect)\n\n return {\n from: {\n transform: `translateY(-${y}px)`,\n },\n to: {\n transform: `translateY(0)`,\n }\n }\n}\n\nexport const slideUp = (rect?: DOMRect) => {\n const y = getY(rect)\n\n return {\n from: {\n transform: `translateY(${y}px)`,\n },\n to: {\n transform: `translateY(0)`,\n }\n }\n}\n\nexport const slideRight = (rect?: DOMRect) => {\n const x = getX(rect)\n\n return {\n from: {\n transform: `translateX(-${x}px)`,\n },\n to: {\n transform: `translateX(0)`,\n }\n }\n}\n\nexport const slideLeft = (rect?: DOMRect) => {\n const x = getX(rect)\n\n return {\n from: {\n transform: `translateX(${x}px)`,\n },\n to: {\n transform: `translateX(0)`,\n }\n }\n}\n\nexport const scaleYDown = () => ({\n from: {\n transform: \"scaleY(0.8)\",\n opacity: 0,\n pointerEvents: 'none',\n transformOrigin: \"top\"\n },\n to: {\n transform: \"scaleY(1)\",\n opacity: 1,\n transformOrigin: \"top\"\n }\n})\n\nexport const scaleYUp = () => ({\n from: {\n transform: \"scaleY(0.8)\",\n transformOrigin: \"bottom\",\n opacity: 0,\n pointerEvents: 'none'\n },\n to: {\n transform: \"scaleY(1)\",\n transformOrigin: \"bottom\",\n opacity: 1\n }\n})\n\nexport const fade = () => {\n return {\n from: {\n opacity: 0,\n pointerEvents: 'none'\n },\n to: {\n opacity: 1\n }\n }\n}\n\n\nexport const fadeDown = (rect?: DOMRect) => {\n const y = getY(rect)\n\n return {\n from: {\n transform: `translateY(-${y}px) scale(0.98)`,\n opacity: 0,\n pointerEvents: 'none'\n },\n to: {\n transform: `translateY(0) scale(1)`,\n opacity: 1\n }\n }\n}\n\nexport const fadeUp = (rect?: DOMRect) => {\n const y = getY(rect)\n\n return {\n from: {\n transform: `translateY(${y}px) scale(0.98)`,\n opacity: 0,\n pointerEvents: 'none'\n },\n to: {\n transform: `translateY(0) scale(1)`,\n opacity: 1\n }\n }\n}\n\nexport const fadeRight = (rect?: DOMRect) => {\n const x = getX(rect)\n\n return {\n from: {\n transform: `translateX(-${x}px) scale(0.98)`,\n opacity: 0,\n pointerEvents: 'none'\n },\n to: {\n transform: `translateX(0) scale(1)`,\n opacity: 1\n }\n }\n}\n\nexport const fadeLeft = (rect?: DOMRect) => {\n const x = getX(rect)\n\n return {\n from: {\n transform: `translateX(${x}px) scale(0.98)`,\n opacity: 0,\n pointerEvents: 'none'\n },\n to: {\n transform: `translateX(0) scale(1)`,\n opacity: 1\n }\n }\n}\n\nexport const grow = () => {\n return {\n from: {\n transform: \"scale(.8, .6)\",\n opacity: 0,\n pointerEvents: 'none'\n },\n to: {\n transform: \"scale(1)\",\n opacity: 1\n }\n }\n}\n\nexport const zoom = () => {\n return {\n from: {\n transform: \"scale(.8)\",\n transformOrigin: \"center\",\n opacity: 0,\n pointerEvents: 'none'\n },\n to: {\n transform: \"scale(1)\",\n transformOrigin: \"center\",\n opacity: 1\n }\n }\n}\n\nexport const zoomOver = () => {\n return {\n from: {\n transform: \"scale(1.2)\",\n transformOrigin: \"center\",\n opacity: 0,\n pointerEvents: 'none'\n },\n to: {\n transform: \"scale(1)\",\n transformOrigin: \"center\",\n opacity: 1\n }\n }\n}\n\nexport const collapseVertical = (rect: DOMRect) => {\n return {\n from: {\n maxHeight: \"0px\",\n overflow: \"hidden\"\n },\n to: {\n maxHeight: rect.height + \"px\",\n overflow: \"hidden\"\n }\n }\n}\n\n\nexport const collapseHorizontal = (rect: DOMRect) => {\n return {\n from: {\n width: \"0px\",\n overflow: \"hidden\"\n },\n to: {\n width: rect.width + \"px\",\n overflow: \"hidden\"\n }\n }\n}\n\n\n\n\n"],"names":[],"mappings":";;AACA,MAAM,IAAI,GAAG,CA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Q,EAAE;AACb,SAAA;AACD,QAAA,EAAE,EAAE;AACA,YAAA,KAAK,EAAE,IAAI,CAAC,KAAK,GAAG,IAAI;AACxB,YAAA,QAAQ,EAAE;AACb;KACJ;AACL;;;;;;;;;;;;;;;;;;;"}
@@ -34,6 +34,7 @@ declare const scaleYDown: () => {
34
34
  from: {
35
35
  transform: string;
36
36
  opacity: number;
37
+ pointerEvents: string;
37
38
  transformOrigin: string;
38
39
  };
39
40
  to: {
@@ -47,6 +48,7 @@ declare const scaleYUp: () => {
47
48
  transform: string;
48
49
  transformOrigin: string;
49
50
  opacity: number;
51
+ pointerEvents: string;
50
52
  };
51
53
  to: {
52
54
  transform: string;
@@ -57,6 +59,7 @@ declare const scaleYUp: () => {
57
59
  declare const fade: () => {
58
60
  from: {
59
61
  opacity: number;
62
+ pointerEvents: string;
60
63
  };
61
64
  to: {
62
65
  opacity: number;
@@ -66,6 +69,7 @@ declare const fadeDown: (rect?: DOMRect) => {
66
69
  from: {
67
70
  transform: string;
68
71
  opacity: number;
72
+ pointerEvents: string;
69
73
  };
70
74
  to: {
71
75
  transform: string;
@@ -76,6 +80,7 @@ declare const fadeUp: (rect?: DOMRect) => {
76
80
  from: {
77
81
  transform: string;
78
82
  opacity: number;
83
+ pointerEvents: string;
79
84
  };
80
85
  to: {
81
86
  transform: string;
@@ -86,6 +91,7 @@ declare const fadeRight: (rect?: DOMRect) => {
86
91
  from: {
87
92
  transform: string;
88
93
  opacity: number;
94
+ pointerEvents: string;
89
95
  };
90
96
  to: {
91
97
  transform: string;
@@ -96,6 +102,7 @@ declare const fadeLeft: (rect?: DOMRect) => {
96
102
  from: {
97
103
  transform: string;
98
104
  opacity: number;
105
+ pointerEvents: string;
99
106
  };
100
107
  to: {
101
108
  transform: string;
@@ -106,6 +113,7 @@ declare const grow: () => {
106
113
  from: {
107
114
  transform: string;
108
115
  opacity: number;
116
+ pointerEvents: string;
109
117
  };
110
118
  to: {
111
119
  transform: string;
@@ -117,6 +125,7 @@ declare const zoom: () => {
117
125
  transform: string;
118
126
  transformOrigin: string;
119
127
  opacity: number;
128
+ pointerEvents: string;
120
129
  };
121
130
  to: {
122
131
  transform: string;
@@ -129,6 +138,7 @@ declare const zoomOver: () => {
129
138
  transform: string;
130
139
  transformOrigin: string;
131
140
  opacity: number;
141
+ pointerEvents: string;
132
142
  };
133
143
  to: {
134
144
  transform: string;
@@ -48,6 +48,7 @@ const scaleYDown = () => ({
48
48
  from: {
49
49
  transform: "scaleY(0.8)",
50
50
  opacity: 0,
51
+ pointerEvents: 'none',
51
52
  transformOrigin: "top"
52
53
  },
53
54
  to: {
@@ -60,7 +61,8 @@ const scaleYUp = () => ({
60
61
  from: {
61
62
  transform: "scaleY(0.8)",
62
63
  transformOrigin: "bottom",
63
- opacity: 0
64
+ opacity: 0,
65
+ pointerEvents: 'none'
64
66
  },
65
67
  to: {
66
68
  transform: "scaleY(1)",
@@ -71,7 +73,8 @@ const scaleYUp = () => ({
71
73
  const fade = () => {
72
74
  return {
73
75
  from: {
74
- opacity: 0
76
+ opacity: 0,
77
+ pointerEvents: 'none'
75
78
  },
76
79
  to: {
77
80
  opacity: 1
@@ -83,7 +86,8 @@ const fadeDown = (rect) => {
83
86
  return {
84
87
  from: {
85
88
  transform: `translateY(-${y}px) scale(0.98)`,
86
- opacity: 0
89
+ opacity: 0,
90
+ pointerEvents: 'none'
87
91
  },
88
92
  to: {
89
93
  transform: `translateY(0) scale(1)`,
@@ -96,7 +100,8 @@ const fadeUp = (rect) => {
96
100
  return {
97
101
  from: {
98
102
  transform: `translateY(${y}px) scale(0.98)`,
99
- opacity: 0
103
+ opacity: 0,
104
+ pointerEvents: 'none'
100
105
  },
101
106
  to: {
102
107
  transform: `translateY(0) scale(1)`,
@@ -109,7 +114,8 @@ const fadeRight = (rect) => {
109
114
  return {
110
115
  from: {
111
116
  transform: `translateX(-${x}px) scale(0.98)`,
112
- opacity: 0
117
+ opacity: 0,
118
+ pointerEvents: 'none'
113
119
  },
114
120
  to: {
115
121
  transform: `translateX(0) scale(1)`,
@@ -122,7 +128,8 @@ const fadeLeft = (rect) => {
122
128
  return {
123
129
  from: {
124
130
  transform: `translateX(${x}px) scale(0.98)`,
125
- opacity: 0
131
+ opacity: 0,
132
+ pointerEvents: 'none'
126
133
  },
127
134
  to: {
128
135
  transform: `translateX(0) scale(1)`,
@@ -134,7 +141,8 @@ const grow = () => {
134
141
  return {
135
142
  from: {
136
143
  transform: "scale(.8, .6)",
137
- opacity: 0
144
+ opacity: 0,
145
+ pointerEvents: 'none'
138
146
  },
139
147
  to: {
140
148
  transform: "scale(1)",
@@ -147,7 +155,8 @@ const zoom = () => {
147
155
  from: {
148
156
  transform: "scale(.8)",
149
157
  transformOrigin: "center",
150
- opacity: 0
158
+ opacity: 0,
159
+ pointerEvents: 'none'
151
160
  },
152
161
  to: {
153
162
  transform: "scale(1)",
@@ -161,7 +170,8 @@ const zoomOver = () => {
161
170
  from: {
162
171
  transform: "scale(1.2)",
163
172
  transformOrigin: "center",
164
- opacity: 0
173
+ opacity: 0,
174
+ pointerEvents: 'none'
165
175
  },
166
176
  to: {
167
177
  transform: "scale(1)",
@@ -1 +1 @@
1
- {"version":3,"file":"variants.js","sources":["../../src/Transition/variants.ts"],"sourcesContent":["\nconst getY = (rect?: DOMRect) =>\n rect ? Math.min(rect.height / 2, 40) : 20\n\nconst getX = (rect?: DOMRect) =>\n rect ? Math.min(rect.width / 2, 40) : 20\n\n\n\nexport const slideDown = (rect?: DOMRect) => {\n const y = getY(rect)\n\n return {\n from: {\n transform: `translateY(-${y}px)`,\n },\n to: {\n transform: `translateY(0)`,\n }\n }\n}\n\nexport const slideUp = (rect?: DOMRect) => {\n const y = getY(rect)\n\n return {\n from: {\n transform: `translateY(${y}px)`,\n },\n to: {\n transform: `translateY(0)`,\n }\n }\n}\n\nexport const slideRight = (rect?: DOMRect) => {\n const x = getX(rect)\n\n return {\n from: {\n transform: `translateX(-${x}px)`,\n },\n to: {\n transform: `translateX(0)`,\n }\n }\n}\n\nexport const slideLeft = (rect?: DOMRect) => {\n const x = getX(rect)\n\n return {\n from: {\n transform: `translateX(${x}px)`,\n },\n to: {\n transform: `translateX(0)`,\n }\n }\n}\n\nexport const scaleYDown = () => ({\n from: {\n transform: \"scaleY(0.8)\",\n opacity: 0,\n transformOrigin: \"top\"\n },\n to: {\n transform: \"scaleY(1)\",\n opacity: 1,\n transformOrigin: \"top\"\n }\n})\n\nexport const scaleYUp = () => ({\n from: {\n transform: \"scaleY(0.8)\",\n transformOrigin: \"bottom\",\n opacity: 0\n },\n to: {\n transform: \"scaleY(1)\",\n transformOrigin: \"bottom\",\n opacity: 1\n }\n})\n\nexport const fade = () => {\n return {\n from: {\n opacity: 0\n },\n to: {\n opacity: 1\n }\n }\n}\n\n\nexport const fadeDown = (rect?: DOMRect) => {\n const y = getY(rect)\n\n return {\n from: {\n transform: `translateY(-${y}px) scale(0.98)`,\n opacity: 0\n },\n to: {\n transform: `translateY(0) scale(1)`,\n opacity: 1\n }\n }\n}\n\nexport const fadeUp = (rect?: DOMRect) => {\n const y = getY(rect)\n\n return {\n from: {\n transform: `translateY(${y}px) scale(0.98)`,\n opacity: 0\n },\n to: {\n transform: `translateY(0) scale(1)`,\n opacity: 1\n }\n }\n}\n\nexport const fadeRight = (rect?: DOMRect) => {\n const x = getX(rect)\n\n return {\n from: {\n transform: `translateX(-${x}px) scale(0.98)`,\n opacity: 0\n },\n to: {\n transform: `translateX(0) scale(1)`,\n opacity: 1\n }\n }\n}\n\nexport const fadeLeft = (rect?: DOMRect) => {\n const x = getX(rect)\n\n return {\n from: {\n transform: `translateX(${x}px) scale(0.98)`,\n opacity: 0\n },\n to: {\n transform: `translateX(0) scale(1)`,\n opacity: 1\n }\n }\n}\n\nexport const grow = () => {\n return {\n from: {\n transform: \"scale(.8, .6)\",\n opacity: 0\n },\n to: {\n transform: \"scale(1)\",\n opacity: 1\n }\n }\n}\n\nexport const zoom = () => {\n return {\n from: {\n transform: \"scale(.8)\",\n transformOrigin: \"center\",\n opacity: 0\n },\n to: {\n transform: \"scale(1)\",\n transformOrigin: \"center\",\n opacity: 1\n }\n }\n}\n\nexport const zoomOver = () => {\n return {\n from: {\n transform: \"scale(1.2)\",\n transformOrigin: \"center\",\n opacity: 0\n },\n to: {\n transform: \"scale(1)\",\n transformOrigin: \"center\",\n opacity: 1\n }\n }\n}\n\nexport const collapseVertical = (rect: DOMRect) => {\n return {\n from: {\n maxHeight: \"0px\",\n overflow: \"hidden\"\n },\n to: {\n maxHeight: rect.height + \"px\",\n overflow: \"hidden\"\n }\n }\n}\n\n\nexport const collapseHorizontal = (rect: DOMRect) => {\n return {\n from: {\n width: \"0px\",\n overflow: \"hidden\"\n },\n to: {\n width: rect.width + \"px\",\n overflow: \"hidden\"\n }\n }\n}\n\n\n\n\n"],"names":[],"mappings":"AACA,MAAM,IAAI,GAAG,CAAC,IAAc,KACxB,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,EAAE;AAE7C,MAAM,IAAI,GAAG,CAAC,IAAc,KACxB,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,EAAE;AAIrC,MAAM,SAAS,GAAG,CAAC,IAAc,KAAI;AACxC,IAAA,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC;IAEpB,OAAO;AACH,QAAA,IAAI,EAAE;YACF,SAAS,EAAE,CAAA,YAAA,EAAe,CAAC,CAAA,GAAA,CAAK;AACnC,SAAA;AACD,QAAA,EAAE,EAAE;AACA,YAAA,SAAS,EAAE,CAAA,aAAA,CAAe;AAC7B;KACJ;AACL;AAEO,MAAM,OAAO,GAAG,CAAC,IAAc,KAAI;AACtC,IAAA,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC;IAEpB,OAAO;AACH,QAAA,IAAI,EAAE;YACF,SAAS,EAAE,CAAA,WAAA,EA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ACD,QAAA,EAAE,EAAE;AACA,YAAA,SAAS,EAAE,IAAI,CAAC,MAAM,GAAG,IAAI;AAC7B,YAAA,QAAQ,EAAE;AACb;KACJ;AACL;AAGO,MAAM,kBAAkB,GAAG,CAAC,IAAa,KAAI;IAChD,OAAO;AACH,QAAA,IAAI,EAAE;AACF,YAAA,KAAK,EAAE,KAAK;AACZ,YAAA,QAAQ,EAAE;AACb,SAAA;AACD,QAAA,EAAE,EAAE;AACA,YAAA,KAAK,EAAE,IAAI,CAAC,KAAK,GAAG,IAAI;AACxB,YAAA,QAAQ,EAAE;AACb;KACJ;AACL;;;;"}
1
+ {"version":3,"file":"variants.js","sources":["../../src/Transition/variants.ts"],"sourcesContent":["\nconst getY = (rect?: DOMRect) =>\n rect ? Math.min(rect.height / 2, 40) : 20\n\nconst getX = (rect?: DOMRect) =>\n rect ? Math.min(rect.width / 2, 40) : 20\n\n\n\nexport const slideDown = (rect?: DOMRect) => {\n const y = getY(rect)\n\n return {\n from: {\n transform: `translateY(-${y}px)`,\n },\n to: {\n transform: `translateY(0)`,\n }\n }\n}\n\nexport const slideUp = (rect?: DOMRect) => {\n const y = getY(rect)\n\n return {\n from: {\n transform: `translateY(${y}px)`,\n },\n to: {\n transform: `translateY(0)`,\n }\n }\n}\n\nexport const slideRight = (rect?: DOMRect) => {\n const x = getX(rect)\n\n return {\n from: {\n transform: `translateX(-${x}px)`,\n },\n to: {\n transform: `translateX(0)`,\n }\n }\n}\n\nexport const slideLeft = (rect?: DOMRect) => {\n const x = getX(rect)\n\n return {\n from: {\n transform: `translateX(${x}px)`,\n },\n to: {\n transform: `translateX(0)`,\n }\n }\n}\n\nexport const scaleYDown = () => ({\n from: {\n transform: \"scaleY(0.8)\",\n opacity: 0,\n pointerEvents: 'none',\n transformOrigin: \"top\"\n },\n to: {\n transform: \"scaleY(1)\",\n opacity: 1,\n transformOrigin: \"top\"\n }\n})\n\nexport const scaleYUp = () => ({\n from: {\n transform: \"scaleY(0.8)\",\n transformOrigin: \"bottom\",\n opacity: 0,\n pointerEvents: 'none'\n },\n to: {\n transform: \"scaleY(1)\",\n transformOrigin: \"bottom\",\n opacity: 1\n }\n})\n\nexport const fade = () => {\n return {\n from: {\n opacity: 0,\n pointerEvents: 'none'\n },\n to: {\n opacity: 1\n }\n }\n}\n\n\nexport const fadeDown = (rect?: DOMRect) => {\n const y = getY(rect)\n\n return {\n from: {\n transform: `translateY(-${y}px) scale(0.98)`,\n opacity: 0,\n pointerEvents: 'none'\n },\n to: {\n transform: `translateY(0) scale(1)`,\n opacity: 1\n }\n }\n}\n\nexport const fadeUp = (rect?: DOMRect) => {\n const y = getY(rect)\n\n return {\n from: {\n transform: `translateY(${y}px) scale(0.98)`,\n opacity: 0,\n pointerEvents: 'none'\n },\n to: {\n transform: `translateY(0) scale(1)`,\n opacity: 1\n }\n }\n}\n\nexport const fadeRight = (rect?: DOMRect) => {\n const x = getX(rect)\n\n return {\n from: {\n transform: `translateX(-${x}px) scale(0.98)`,\n opacity: 0,\n pointerEvents: 'none'\n },\n to: {\n transform: `translateX(0) scale(1)`,\n opacity: 1\n }\n }\n}\n\nexport const fadeLeft = (rect?: DOMRect) => {\n const x = getX(rect)\n\n return {\n from: {\n transform: `translateX(${x}px) scale(0.98)`,\n opacity: 0,\n pointerEvents: 'none'\n },\n to: {\n transform: `translateX(0) scale(1)`,\n opacity: 1\n }\n }\n}\n\nexport const grow = () => {\n return {\n from: {\n transform: \"scale(.8, .6)\",\n opacity: 0,\n pointerEvents: 'none'\n },\n to: {\n transform: \"scale(1)\",\n opacity: 1\n }\n }\n}\n\nexport const zoom = () => {\n return {\n from: {\n transform: \"scale(.8)\",\n transformOrigin: \"center\",\n opacity: 0,\n pointerEvents: 'none'\n },\n to: {\n transform: \"scale(1)\",\n transformOrigin: \"center\",\n opacity: 1\n }\n }\n}\n\nexport const zoomOver = () => {\n return {\n from: {\n transform: \"scale(1.2)\",\n transformOrigin: \"center\",\n opacity: 0,\n pointerEvents: 'none'\n },\n to: {\n transform: \"scale(1)\",\n transformOrigin: \"center\",\n opacity: 1\n }\n }\n}\n\nexport const collapseVertical = (rect: DOMRect) => {\n return {\n from: {\n maxHeight: \"0px\",\n overflow: \"hidden\"\n },\n to: {\n maxHeight: rect.height + \"px\",\n overflow: \"hidden\"\n }\n }\n}\n\n\nexport const collapseHorizontal = (rect: DOMRect) => {\n return {\n from: {\n width: \"0px\",\n overflow: \"hidden\"\n },\n to: {\n width: rect.width + \"px\",\n overflow: \"hidden\"\n }\n }\n}\n\n\n\n\n"],"names":[],"mappings":"AACA,MAAM,IAAI,GAAG,CAAC,IAAc,KACxB,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,EAAE;AAE7C,MAAM,IAAI,GAAG,CAAC,IAAc,KACxB,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,EAAE;AAIrC,MAAM,SAAS,GAAG,CAAC,IAAc,KAAI;AACxC,IAAA,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC;IAEpB,OAAO;AACH,QAAA,IAAI,EAAE;YACF,SAAS,EAAE,CAAA,YAAA,EAAe,CAAC,CAAA,GAAA,CAAK;AACnC,SAAA;AACD,QAAA,EAAE,EAAE;AACA,YAAA,SAAS,EAAE,CAAA,aAAA,CAAe;AAC7B;KACJ;AACL;AAEO,MAAM,OAAO,GAAG,CAAC,IAAc,KAAI;AACtC,IAAA,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC;IAEpB,OAAO;AACH,QAAA,IAAI,EAAE;YACF,SAAS,EAAE,CAAA,WAAA,EAAc,CAAC,CAAA,GAAA,CAAK;AAClC,SAAA;AACD,QAAA,EAAE,EAAE;AACA,YAAA,SAAS,EAAE,CAAA,aAAA,CAAe;AAC7B;KACJ;AACL;AAEO,MAAM,UAAU,GAAG,CAAC,IAAc,KAAI;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GAAG,CAAC,IAAa,KAAI;IAC9C,OAAO;AACH,QAAA,IAAI,EAAE;AACF,YAAA,SAAS,EAAE,KAAK;AAChB,YAAA,QAAQ,EAAE;AACb,SAAA;AACD,QAAA,EAAE,EAAE;AACA,YAAA,SAAS,EAAE,IAAI,CAAC,MAAM,GAAG,IAAI;AAC7B,YAAA,QAAQ,EAAE;AACb;KACJ;AACL;AAGO,MAAM,kBAAkB,GAAG,CAAC,IAAa,KAAI;IAChD,OAAO;AACH,QAAA,IAAI,EAAE;AACF,YAAA,KAAK,EAAE,KAAK;AACZ,YAAA,QAAQ,EAAE;AACb,SAAA;AACD,QAAA,EAAE,EAAE;AACA,YAAA,KAAK,EAAE,IAAI,CAAC,KAAK,GAAG,IAAI;AACxB,YAAA,QAAQ,EAAE;AACb;KACJ;AACL;;;;"}
@@ -4,6 +4,7 @@
4
4
  var jsxRuntime = require('react/jsx-runtime');
5
5
  var React = require('react');
6
6
  var index = require('../css/index.cjs');
7
+ var cookie = require('../cookie.cjs');
7
8
 
8
9
  const BreakpointCtx = React.createContext(null);
9
10
  const queries = {
@@ -29,13 +30,13 @@ const BreakpointProvider = ({ children, defaultKey }) => {
29
30
  React.useEffect(() => {
30
31
  const current = getCurrent(defaultKey);
31
32
  setCurrent(current);
32
- document.cookie = `xuibp=${current};path=/`;
33
+ cookie.set("xuibp", current);
33
34
  const mqls = Object.entries(queries).map(([key, query]) => {
34
35
  const mql = window.matchMedia(query);
35
36
  const handler = () => {
36
37
  if (mql.matches) {
37
38
  setCurrent(key);
38
- document.cookie = `xuibp=${key};path=/`;
39
+ cookie.set("xuibp", key);
39
40
  }
40
41
  };
41
42
  mql.addEventListener("change", handler);
@@ -1 +1 @@
1
- {"version":3,"file":"BreakpointProvider.cjs","sources":["../../src/breakpoint/BreakpointProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport React, { ReactNode, useEffect, useState } from \"react\";\nimport { breakpoints } from \"../css\";\nimport { BreakpointKeys } from \"../css/types\";\n\nexport const BreakpointCtx = React.createContext<BreakpointKeys | null>(null);\n\nconst queries: Record<BreakpointKeys, string> = {\n xs: `(max-width:${breakpoints.sm - 0.02}px)`,\n sm: `(min-width:${breakpoints.sm}px) and (max-width:${breakpoints.md - 0.02}px)`,\n md: `(min-width:${breakpoints.md}px) and (max-width:${breakpoints.lg - 0.02}px)`,\n lg: `(min-width:${breakpoints.lg}px) and (max-width:${breakpoints.xl - 0.02}px)`,\n xl: `(min-width:${breakpoints.xl}px)`\n};\n\nconst getCurrent = (def: BreakpointKeys): BreakpointKeys => {\n if (typeof window === \"undefined\") return def;\n const entries = Object.entries(queries) as [BreakpointKeys, string][];\n for (const [key, query] of entries) {\n if (window.matchMedia(query).matches) {\n return key;\n }\n }\n return def;\n};\n\nexport const BreakpointProvider = ({ children, defaultKey }: { children?: ReactNode, defaultKey: BreakpointKeys }) => {\n const [current, setCurrent] = useState<BreakpointKeys>(defaultKey);\n\n useEffect(() => {\n const current = getCurrent(defaultKey)\n setCurrent(current)\n document.cookie = `xuibp=${current};path=/`\n const mqls = Object.entries(queries).map(([key, query]) => {\n const mql = window.matchMedia(query);\n const handler = () => {\n if (mql.matches) {\n setCurrent(key as BreakpointKeys);\n document.cookie = `xuibp=${key};path=/`\n }\n };\n\n mql.addEventListener(\"change\", handler);\n\n return () => mql.removeEventListener(\"change\", handler);\n });\n\n return () => {\n mqls.forEach(fn => fn());\n };\n }, []);\n\n return (\n <BreakpointCtx.Provider value={current}>\n {children}\n </BreakpointCtx.Provider>\n );\n};"],"names":[],"mappings":";;;;;;;AAMO;AAEP;AACI;;;;AAIA;;AAGJ;;AACuC;;;;AAI3B;;;AAGR;AACJ;AAEO;;;AAIC;;AAEA;AACA;;;AAGQ;;AAEI;;AAER;AAEA;;AAGJ;AAEA;;AAEA;;AAGJ;AAKJ;;;"}
1
+ {"version":3,"file":"BreakpointProvider.cjs","sources":["../../src/breakpoint/BreakpointProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport React, { ReactNode, useEffect, useState } from \"react\";\nimport { breakpoints } from \"../css\";\nimport { BreakpointKeys } from \"../css/types\";\nimport Cookie from \"../cookie\";\n\nexport const BreakpointCtx = React.createContext<BreakpointKeys | null>(null);\n\nconst queries: Record<BreakpointKeys, string> = {\n xs: `(max-width:${breakpoints.sm - 0.02}px)`,\n sm: `(min-width:${breakpoints.sm}px) and (max-width:${breakpoints.md - 0.02}px)`,\n md: `(min-width:${breakpoints.md}px) and (max-width:${breakpoints.lg - 0.02}px)`,\n lg: `(min-width:${breakpoints.lg}px) and (max-width:${breakpoints.xl - 0.02}px)`,\n xl: `(min-width:${breakpoints.xl}px)`\n};\n\nconst getCurrent = (def: BreakpointKeys): BreakpointKeys => {\n if (typeof window === \"undefined\") return def;\n const entries = Object.entries(queries) as [BreakpointKeys, string][];\n for (const [key, query] of entries) {\n if (window.matchMedia(query).matches) {\n return key;\n }\n }\n return def;\n};\n\nexport const BreakpointProvider = ({ children, defaultKey }: { children?: ReactNode, defaultKey: BreakpointKeys }) => {\n const [current, setCurrent] = useState<BreakpointKeys>(defaultKey);\n\n useEffect(() => {\n const current = getCurrent(defaultKey)\n setCurrent(current)\n Cookie.set(\"xuibp\", current)\n const mqls = Object.entries(queries).map(([key, query]) => {\n const mql = window.matchMedia(query);\n const handler = () => {\n if (mql.matches) {\n setCurrent(key as BreakpointKeys);\n Cookie.set(\"xuibp\", key)\n }\n };\n\n mql.addEventListener(\"change\", handler);\n\n return () => mql.removeEventListener(\"change\", handler);\n });\n\n return () => {\n mqls.forEach(fn => fn());\n };\n }, []);\n\n return (\n <BreakpointCtx.Provider value={current}>\n {children}\n </BreakpointCtx.Provider>\n );\n};"],"names":[],"mappings":";;;;;;;;AAOO;AAEP;AACI;;;;AAIA;;AAGJ;;AACuC;;;;AAI3B;;;AAGR;AACJ;AAEO;;;AAIC;;AAEA;AACA;;;AAGQ;;AAEI;;AAER;AAEA;;AAGJ;AAEA;;AAEA;;AAGJ;AAKJ;;;"}
@@ -2,6 +2,7 @@
2
2
  import { jsx } from 'react/jsx-runtime';
3
3
  import React__default, { useState, useEffect } from 'react';
4
4
  import { breakpoints } from '../css/index.js';
5
+ import Cookie from '../cookie.js';
5
6
 
6
7
  const BreakpointCtx = React__default.createContext(null);
7
8
  const queries = {
@@ -27,13 +28,13 @@ const BreakpointProvider = ({ children, defaultKey }) => {
27
28
  useEffect(() => {
28
29
  const current = getCurrent(defaultKey);
29
30
  setCurrent(current);
30
- document.cookie = `xuibp=${current};path=/`;
31
+ Cookie.set("xuibp", current);
31
32
  const mqls = Object.entries(queries).map(([key, query]) => {
32
33
  const mql = window.matchMedia(query);
33
34
  const handler = () => {
34
35
  if (mql.matches) {
35
36
  setCurrent(key);
36
- document.cookie = `xuibp=${key};path=/`;
37
+ Cookie.set("xuibp", key);
37
38
  }
38
39
  };
39
40
  mql.addEventListener("change", handler);
@@ -1 +1 @@
1
- {"version":3,"file":"BreakpointProvider.js","sources":["../../src/breakpoint/BreakpointProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport React, { ReactNode, useEffect, useState } from \"react\";\nimport { breakpoints } from \"../css\";\nimport { BreakpointKeys } from \"../css/types\";\n\nexport const BreakpointCtx = React.createContext<BreakpointKeys | null>(null);\n\nconst queries: Record<BreakpointKeys, string> = {\n xs: `(max-width:${breakpoints.sm - 0.02}px)`,\n sm: `(min-width:${breakpoints.sm}px) and (max-width:${breakpoints.md - 0.02}px)`,\n md: `(min-width:${breakpoints.md}px) and (max-width:${breakpoints.lg - 0.02}px)`,\n lg: `(min-width:${breakpoints.lg}px) and (max-width:${breakpoints.xl - 0.02}px)`,\n xl: `(min-width:${breakpoints.xl}px)`\n};\n\nconst getCurrent = (def: BreakpointKeys): BreakpointKeys => {\n if (typeof window === \"undefined\") return def;\n const entries = Object.entries(queries) as [BreakpointKeys, string][];\n for (const [key, query] of entries) {\n if (window.matchMedia(query).matches) {\n return key;\n }\n }\n return def;\n};\n\nexport const BreakpointProvider = ({ children, defaultKey }: { children?: ReactNode, defaultKey: BreakpointKeys }) => {\n const [current, setCurrent] = useState<BreakpointKeys>(defaultKey);\n\n useEffect(() => {\n const current = getCurrent(defaultKey)\n setCurrent(current)\n document.cookie = `xuibp=${current};path=/`\n const mqls = Object.entries(queries).map(([key, query]) => {\n const mql = window.matchMedia(query);\n const handler = () => {\n if (mql.matches) {\n setCurrent(key as BreakpointKeys);\n document.cookie = `xuibp=${key};path=/`\n }\n };\n\n mql.addEventListener(\"change\", handler);\n\n return () => mql.removeEventListener(\"change\", handler);\n });\n\n return () => {\n mqls.forEach(fn => fn());\n };\n }, []);\n\n return (\n <BreakpointCtx.Provider value={current}>\n {children}\n </BreakpointCtx.Provider>\n );\n};"],"names":[],"mappings":";;;;;AAMO;AAEP;AACI;;;;AAIA;;AAGJ;;AACuC;;;;AAI3B;;;AAGR;AACJ;AAEO;;;AAIC;;AAEA;AACA;;;AAGQ;;AAEI;;AAER;AAEA;;AAGJ;AAEA;;AAEA;;AAGJ;AAKJ;;"}
1
+ {"version":3,"file":"BreakpointProvider.js","sources":["../../src/breakpoint/BreakpointProvider.tsx"],"sourcesContent":["\"use client\";\n\nimport React, { ReactNode, useEffect, useState } from \"react\";\nimport { breakpoints } from \"../css\";\nimport { BreakpointKeys } from \"../css/types\";\nimport Cookie from \"../cookie\";\n\nexport const BreakpointCtx = React.createContext<BreakpointKeys | null>(null);\n\nconst queries: Record<BreakpointKeys, string> = {\n xs: `(max-width:${breakpoints.sm - 0.02}px)`,\n sm: `(min-width:${breakpoints.sm}px) and (max-width:${breakpoints.md - 0.02}px)`,\n md: `(min-width:${breakpoints.md}px) and (max-width:${breakpoints.lg - 0.02}px)`,\n lg: `(min-width:${breakpoints.lg}px) and (max-width:${breakpoints.xl - 0.02}px)`,\n xl: `(min-width:${breakpoints.xl}px)`\n};\n\nconst getCurrent = (def: BreakpointKeys): BreakpointKeys => {\n if (typeof window === \"undefined\") return def;\n const entries = Object.entries(queries) as [BreakpointKeys, string][];\n for (const [key, query] of entries) {\n if (window.matchMedia(query).matches) {\n return key;\n }\n }\n return def;\n};\n\nexport const BreakpointProvider = ({ children, defaultKey }: { children?: ReactNode, defaultKey: BreakpointKeys }) => {\n const [current, setCurrent] = useState<BreakpointKeys>(defaultKey);\n\n useEffect(() => {\n const current = getCurrent(defaultKey)\n setCurrent(current)\n Cookie.set(\"xuibp\", current)\n const mqls = Object.entries(queries).map(([key, query]) => {\n const mql = window.matchMedia(query);\n const handler = () => {\n if (mql.matches) {\n setCurrent(key as BreakpointKeys);\n Cookie.set(\"xuibp\", key)\n }\n };\n\n mql.addEventListener(\"change\", handler);\n\n return () => mql.removeEventListener(\"change\", handler);\n });\n\n return () => {\n mqls.forEach(fn => fn());\n };\n }, []);\n\n return (\n <BreakpointCtx.Provider value={current}>\n {children}\n </BreakpointCtx.Provider>\n );\n};"],"names":[],"mappings":";;;;;;AAOO;AAEP;AACI;;;;AAIA;;AAGJ;;AACuC;;;;AAI3B;;;AAGR;AACJ;AAEO;;;AAIC;;AAEA;AACA;;;AAGQ;;AAEI;;AAER;AAEA;;AAGJ;AAEA;;AAEA;;AAGJ;AAKJ;;"}
package/cookie.cjs ADDED
@@ -0,0 +1,43 @@
1
+ 'use strict';
2
+
3
+ // cookieUtils.ts
4
+ const Cookie = {
5
+ /**
6
+ * Set a cookie
7
+ * @param name - cookie name
8
+ * @param value - cookie value
9
+ * @param days - optional, number of days to expire, default 36500 (~100 years)
10
+ */
11
+ set: (name, value, days = 36500) => {
12
+ const expires = new Date();
13
+ expires.setTime(expires.getTime() + days * 24 * 60 * 60 * 1000);
14
+ document.cookie = `${name}=${encodeURIComponent(value)}; expires=${expires.toUTCString()}; path=/`;
15
+ },
16
+ /**
17
+ * Get a cookie by name
18
+ * @param name - cookie name
19
+ * @returns value or null
20
+ */
21
+ // get: (name: string) => {
22
+ // const match = document.cookie.match(new RegExp(`(?:^|; )${name}=([^;]*)`));
23
+ // return match ? decodeURIComponent(match[1]) : null;
24
+ // },
25
+ /**
26
+ * Delete a cookie
27
+ * @param name - cookie name
28
+ */
29
+ // delete: (name: string) => {
30
+ // document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/`;
31
+ // },
32
+ /**
33
+ * Check if a cookie exists
34
+ * @param name - cookie name
35
+ * @returns boolean
36
+ */
37
+ exists: (name) => {
38
+ return document.cookie.split("; ").some(c => c.startsWith(`${name}=`));
39
+ }
40
+ };
41
+
42
+ module.exports = Cookie;
43
+ //# sourceMappingURL=cookie.cjs.map
package/cookie.cjs.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cookie.cjs","sources":["../src/cookie.ts"],"sourcesContent":["// cookieUtils.ts\nconst Cookie = {\n /**\n * Set a cookie\n * @param name - cookie name\n * @param value - cookie value\n * @param days - optional, number of days to expire, default 36500 (~100 years)\n */\n set: (name: string, value: string, days = 36500) => {\n const expires = new Date();\n expires.setTime(expires.getTime() + days * 24 * 60 * 60 * 1000);\n document.cookie = `${name}=${encodeURIComponent(value)}; expires=${expires.toUTCString()}; path=/`;\n },\n\n /**\n * Get a cookie by name\n * @param name - cookie name\n * @returns value or null\n */\n // get: (name: string) => {\n // const match = document.cookie.match(new RegExp(`(?:^|; )${name}=([^;]*)`));\n // return match ? decodeURIComponent(match[1]) : null;\n // },\n\n /**\n * Delete a cookie\n * @param name - cookie name\n */\n // delete: (name: string) => {\n // document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/`;\n // },\n\n /**\n * Check if a cookie exists\n * @param name - cookie name\n * @returns boolean\n */\n exists: (name: string) => {\n return document.cookie.split(\"; \").some(c => c.startsWith(`${name}=`));\n }\n};\n\nexport default Cookie"],"names":[],"mappings":";;AAAA;AACA,MAAM,MAAM,GAAG;AACZ;;;;;AAKG;IACH,GAAG,EAAE,CAAC,IAAY,EAAE,KAAa,EAAE,IAAI,GAAG,KAAK,KAAI;AAChD,QAAA,MAAM,OAAO,GAAG,IAAI,IAAI,EAAE;AAC1B,QAAA,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAC/D,QAAA,QAAQ,CAAC,MAAM,GAAG,CAAA,EAAG,IAAI,IAAI,kBAAkB,CAAC,KAAK,CAAC,aAAa,OAAO,CAAC,WAAW,EAAE,UAAU;IACrG,CAAC;AAED;;;;AAIG;;;;;AAMH;;;AAGG;;;;AAKH;;;;AAIG;AACH,IAAA,MAAM,EAAE,CAAC,IAAY,KAAI;QACtB,OAAO,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,GAAG,IAAI,CAAA,CAAA,CAAG,CAAC,CAAC;IACzE;;;;;"}
package/cookie.js ADDED
@@ -0,0 +1,41 @@
1
+ // cookieUtils.ts
2
+ const Cookie = {
3
+ /**
4
+ * Set a cookie
5
+ * @param name - cookie name
6
+ * @param value - cookie value
7
+ * @param days - optional, number of days to expire, default 36500 (~100 years)
8
+ */
9
+ set: (name, value, days = 36500) => {
10
+ const expires = new Date();
11
+ expires.setTime(expires.getTime() + days * 24 * 60 * 60 * 1000);
12
+ document.cookie = `${name}=${encodeURIComponent(value)}; expires=${expires.toUTCString()}; path=/`;
13
+ },
14
+ /**
15
+ * Get a cookie by name
16
+ * @param name - cookie name
17
+ * @returns value or null
18
+ */
19
+ // get: (name: string) => {
20
+ // const match = document.cookie.match(new RegExp(`(?:^|; )${name}=([^;]*)`));
21
+ // return match ? decodeURIComponent(match[1]) : null;
22
+ // },
23
+ /**
24
+ * Delete a cookie
25
+ * @param name - cookie name
26
+ */
27
+ // delete: (name: string) => {
28
+ // document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/`;
29
+ // },
30
+ /**
31
+ * Check if a cookie exists
32
+ * @param name - cookie name
33
+ * @returns boolean
34
+ */
35
+ exists: (name) => {
36
+ return document.cookie.split("; ").some(c => c.startsWith(`${name}=`));
37
+ }
38
+ };
39
+
40
+ export { Cookie as default };
41
+ //# sourceMappingURL=cookie.js.map
package/cookie.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cookie.js","sources":["../src/cookie.ts"],"sourcesContent":["// cookieUtils.ts\nconst Cookie = {\n /**\n * Set a cookie\n * @param name - cookie name\n * @param value - cookie value\n * @param days - optional, number of days to expire, default 36500 (~100 years)\n */\n set: (name: string, value: string, days = 36500) => {\n const expires = new Date();\n expires.setTime(expires.getTime() + days * 24 * 60 * 60 * 1000);\n document.cookie = `${name}=${encodeURIComponent(value)}; expires=${expires.toUTCString()}; path=/`;\n },\n\n /**\n * Get a cookie by name\n * @param name - cookie name\n * @returns value or null\n */\n // get: (name: string) => {\n // const match = document.cookie.match(new RegExp(`(?:^|; )${name}=([^;]*)`));\n // return match ? decodeURIComponent(match[1]) : null;\n // },\n\n /**\n * Delete a cookie\n * @param name - cookie name\n */\n // delete: (name: string) => {\n // document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/`;\n // },\n\n /**\n * Check if a cookie exists\n * @param name - cookie name\n * @returns boolean\n */\n exists: (name: string) => {\n return document.cookie.split(\"; \").some(c => c.startsWith(`${name}=`));\n }\n};\n\nexport default Cookie"],"names":[],"mappings":"AAAA;AACA,MAAM,MAAM,GAAG;AACZ;;;;;AAKG;IACH,GAAG,EAAE,CAAC,IAAY,EAAE,KAAa,EAAE,IAAI,GAAG,KAAK,KAAI;AAChD,QAAA,MAAM,OAAO,GAAG,IAAI,IAAI,EAAE;AAC1B,QAAA,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAC/D,QAAA,QAAQ,CAAC,MAAM,GAAG,CAAA,EAAG,IAAI,IAAI,kBAAkB,CAAC,KAAK,CAAC,aAAa,OAAO,CAAC,WAAW,EAAE,UAAU;IACrG,CAAC;AAED;;;;AAIG;;;;;AAMH;;;AAGG;;;;AAKH;;;;AAIG;AACH,IAAA,MAAM,EAAE,CAAC,IAAY,KAAI;QACtB,OAAO,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,GAAG,IAAI,CAAA,CAAA,CAAG,CAAC,CAAC;IACzE;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xanui/core",
3
- "version": "1.2.65",
3
+ "version": "1.2.67",
4
4
  "description": "Xanui Core Library",
5
5
  "private": false,
6
6
  "main": "./index.cjs",