@xanui/core 1.3.3 → 1.3.4
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/Transition/index.cjs +0 -16
- package/Transition/index.cjs.map +1 -1
- package/Transition/index.js +1 -17
- package/Transition/index.js.map +1 -1
- package/package.json +1 -1
package/Transition/index.cjs
CHANGED
|
@@ -59,22 +59,6 @@ function TransitionBase(_a) {
|
|
|
59
59
|
trans.exit(isnot ? false : true);
|
|
60
60
|
}
|
|
61
61
|
}, [open]);
|
|
62
|
-
React.useEffect(() => {
|
|
63
|
-
if (!ref.current)
|
|
64
|
-
return;
|
|
65
|
-
const ele = ref.current;
|
|
66
|
-
const observer = new ResizeObserver(() => {
|
|
67
|
-
const _rect = ele.getBoundingClientRect();
|
|
68
|
-
const current = rect.current;
|
|
69
|
-
if (!current || (_rect.width !== current.width || _rect.height !== current.height)) {
|
|
70
|
-
rect.current = _rect;
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
observer.observe(ele);
|
|
74
|
-
return () => {
|
|
75
|
-
observer.disconnect();
|
|
76
|
-
};
|
|
77
|
-
}, []);
|
|
78
62
|
if (exitOnUnmount && trans.status === "exited")
|
|
79
63
|
return;
|
|
80
64
|
const childs = React.Children.toArray(children);
|
package/Transition/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/Transition/index.tsx"],"sourcesContent":["\"use client\";\nimport React, { cloneElement, Children, useRef, isValidElement, useLayoutEffect, useEffect } from 'react';\nimport * as variants from './variants'\nimport { Easing } from '../animate';\nimport useTransition from '../hooks/useTransition';\n\nexport type TransitionVariantTypes = keyof typeof variants\nexport type TransitionProps = {\n children: React.ReactElement;\n open: boolean;\n variant: TransitionVariantTypes\n easing?: keyof typeof Easing\n duration?: number;\n delay?: number;\n initialTransition?: boolean;\n\n exitOnUnmount?: boolean;\n\n onEnter?: () => void\n onEntered?: () => void\n onExit?: () => void\n onExited?: () => void\n onUpdate?: (value: Record<string, number>, progress: number) => void;\n onDone?: () => void;\n}\n\n\nfunction TransitionBase({ children, ...options }: TransitionProps) {\n let {\n open,\n variant = \"fade\",\n duration = 450,\n delay,\n easing,\n exitOnUnmount = false,\n initialTransition = true,\n onEnter,\n onEntered,\n onExit,\n onExited,\n onUpdate,\n onDone,\n\n } = options\n\n easing ??= \"default\"\n\n const variantCb = variants[variant]\n const ref = useRef<HTMLElement>(null)\n const init = useRef(false)\n const rect = useRef<DOMRect>(null)\n\n const trans = useTransition({\n delay,\n duration,\n easing: Easing[easing],\n onEnter,\n onEntered,\n onExit,\n onExited,\n onDone,\n from: () => {\n if (!rect.current) {\n rect.current = ref.current?.getBoundingClientRect() as DOMRect\n }\n const v = variantCb(ref.current as HTMLElement, rect.current)\n return v.from\n },\n to: () => {\n if (!rect.current) {\n rect.current = ref.current?.getBoundingClientRect() as DOMRect\n }\n const v = variantCb(ref.current as HTMLElement, rect.current)\n return v.to\n },\n onUpdate: (val, prograss) => {\n if (!ref.current || !rect.current) return\n const vc = variantCb(ref.current, rect.current)\n onUpdate?.(val, prograss)\n return vc.onUpdate(val)\n },\n })\n\n\n useLayoutEffect(() => {\n const isnot = !init.current && !initialTransition\n init.current = true\n if (open) {\n trans.enter(isnot ? false : true)\n } else {\n trans.exit(isnot ? false : true)\n }\n }, [open])\n\n
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/Transition/index.tsx"],"sourcesContent":["\"use client\";\nimport React, { cloneElement, Children, useRef, isValidElement, useLayoutEffect, useEffect } from 'react';\nimport * as variants from './variants'\nimport { Easing } from '../animate';\nimport useTransition from '../hooks/useTransition';\n\nexport type TransitionVariantTypes = keyof typeof variants\nexport type TransitionProps = {\n children: React.ReactElement;\n open: boolean;\n variant: TransitionVariantTypes\n easing?: keyof typeof Easing\n duration?: number;\n delay?: number;\n initialTransition?: boolean;\n\n exitOnUnmount?: boolean;\n\n onEnter?: () => void\n onEntered?: () => void\n onExit?: () => void\n onExited?: () => void\n onUpdate?: (value: Record<string, number>, progress: number) => void;\n onDone?: () => void;\n}\n\n\nfunction TransitionBase({ children, ...options }: TransitionProps) {\n let {\n open,\n variant = \"fade\",\n duration = 450,\n delay,\n easing,\n exitOnUnmount = false,\n initialTransition = true,\n onEnter,\n onEntered,\n onExit,\n onExited,\n onUpdate,\n onDone,\n\n } = options\n\n easing ??= \"default\"\n\n const variantCb = variants[variant]\n const ref = useRef<HTMLElement>(null)\n const init = useRef(false)\n const rect = useRef<DOMRect>(null)\n\n const trans = useTransition({\n delay,\n duration,\n easing: Easing[easing],\n onEnter,\n onEntered,\n onExit,\n onExited,\n onDone,\n from: () => {\n if (!rect.current) {\n rect.current = ref.current?.getBoundingClientRect() as DOMRect\n }\n const v = variantCb(ref.current as HTMLElement, rect.current)\n return v.from\n },\n to: () => {\n if (!rect.current) {\n rect.current = ref.current?.getBoundingClientRect() as DOMRect\n }\n const v = variantCb(ref.current as HTMLElement, rect.current)\n return v.to\n },\n onUpdate: (val, prograss) => {\n if (!ref.current || !rect.current) return\n const vc = variantCb(ref.current, rect.current)\n onUpdate?.(val, prograss)\n return vc.onUpdate(val)\n },\n })\n\n\n useLayoutEffect(() => {\n const isnot = !init.current && !initialTransition\n init.current = true\n if (open) {\n trans.enter(isnot ? false : true)\n } else {\n trans.exit(isnot ? false : true)\n }\n }, [open])\n\n\n if (exitOnUnmount && trans.status === \"exited\") return\n\n const childs = Children.toArray(children)\n if (childs.length !== 1) {\n throw new Error(\"Transition expects exactly one child.\");\n }\n const child = childs[0]\n if (!isValidElement(child)) {\n throw new Error(\"Transition expects a valid React element.\");\n }\n\n return cloneElement(child, {\n ref: (node: HTMLElement) => {\n ref.current = node;\n\n const childRef = (child as any).ref;\n if (typeof childRef === \"function\") {\n childRef(node);\n } else if (childRef) {\n childRef.current = node;\n }\n }\n } as any);\n}\n\n\nconst Transition = (props: any) => {\n return (\n <TransitionBase\n key={props.variant}\n {...props}\n />\n )\n}\nexport default Transition"],"names":[],"mappings":";;;;;;;;;;AA2BA;AAAwB;AACpB;;AAmBA;AACA;AACA;AACA;;;;AAKI;;;;;;;;AAOI;;;AAGA;;;;;AAIA;;;AAGA;;;AAGJ;;;AAEI;;AAEA;;AAEP;;;AAKG;;AAEI;;;AAEA;;AAER;AAGA;;;AAGA;AACI;;AAEJ;AACA;AACI;;;AAIA;AACI;AAEA;AACA;;;;AAGI;;;AAGJ;AACZ;AAGA;;AAOA;;"}
|
package/Transition/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { __rest } from 'tslib';
|
|
3
3
|
import { jsx } from 'react/jsx-runtime';
|
|
4
|
-
import { useRef, useLayoutEffect,
|
|
4
|
+
import { useRef, useLayoutEffect, Children, isValidElement, cloneElement } from 'react';
|
|
5
5
|
import * as variants from './variants.js';
|
|
6
6
|
import Easing from '../animate/easing.js';
|
|
7
7
|
import useTransition from '../hooks/useTransition.js';
|
|
@@ -57,22 +57,6 @@ function TransitionBase(_a) {
|
|
|
57
57
|
trans.exit(isnot ? false : true);
|
|
58
58
|
}
|
|
59
59
|
}, [open]);
|
|
60
|
-
useEffect(() => {
|
|
61
|
-
if (!ref.current)
|
|
62
|
-
return;
|
|
63
|
-
const ele = ref.current;
|
|
64
|
-
const observer = new ResizeObserver(() => {
|
|
65
|
-
const _rect = ele.getBoundingClientRect();
|
|
66
|
-
const current = rect.current;
|
|
67
|
-
if (!current || (_rect.width !== current.width || _rect.height !== current.height)) {
|
|
68
|
-
rect.current = _rect;
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
observer.observe(ele);
|
|
72
|
-
return () => {
|
|
73
|
-
observer.disconnect();
|
|
74
|
-
};
|
|
75
|
-
}, []);
|
|
76
60
|
if (exitOnUnmount && trans.status === "exited")
|
|
77
61
|
return;
|
|
78
62
|
const childs = Children.toArray(children);
|
package/Transition/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/Transition/index.tsx"],"sourcesContent":["\"use client\";\nimport React, { cloneElement, Children, useRef, isValidElement, useLayoutEffect, useEffect } from 'react';\nimport * as variants from './variants'\nimport { Easing } from '../animate';\nimport useTransition from '../hooks/useTransition';\n\nexport type TransitionVariantTypes = keyof typeof variants\nexport type TransitionProps = {\n children: React.ReactElement;\n open: boolean;\n variant: TransitionVariantTypes\n easing?: keyof typeof Easing\n duration?: number;\n delay?: number;\n initialTransition?: boolean;\n\n exitOnUnmount?: boolean;\n\n onEnter?: () => void\n onEntered?: () => void\n onExit?: () => void\n onExited?: () => void\n onUpdate?: (value: Record<string, number>, progress: number) => void;\n onDone?: () => void;\n}\n\n\nfunction TransitionBase({ children, ...options }: TransitionProps) {\n let {\n open,\n variant = \"fade\",\n duration = 450,\n delay,\n easing,\n exitOnUnmount = false,\n initialTransition = true,\n onEnter,\n onEntered,\n onExit,\n onExited,\n onUpdate,\n onDone,\n\n } = options\n\n easing ??= \"default\"\n\n const variantCb = variants[variant]\n const ref = useRef<HTMLElement>(null)\n const init = useRef(false)\n const rect = useRef<DOMRect>(null)\n\n const trans = useTransition({\n delay,\n duration,\n easing: Easing[easing],\n onEnter,\n onEntered,\n onExit,\n onExited,\n onDone,\n from: () => {\n if (!rect.current) {\n rect.current = ref.current?.getBoundingClientRect() as DOMRect\n }\n const v = variantCb(ref.current as HTMLElement, rect.current)\n return v.from\n },\n to: () => {\n if (!rect.current) {\n rect.current = ref.current?.getBoundingClientRect() as DOMRect\n }\n const v = variantCb(ref.current as HTMLElement, rect.current)\n return v.to\n },\n onUpdate: (val, prograss) => {\n if (!ref.current || !rect.current) return\n const vc = variantCb(ref.current, rect.current)\n onUpdate?.(val, prograss)\n return vc.onUpdate(val)\n },\n })\n\n\n useLayoutEffect(() => {\n const isnot = !init.current && !initialTransition\n init.current = true\n if (open) {\n trans.enter(isnot ? false : true)\n } else {\n trans.exit(isnot ? false : true)\n }\n }, [open])\n\n
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/Transition/index.tsx"],"sourcesContent":["\"use client\";\nimport React, { cloneElement, Children, useRef, isValidElement, useLayoutEffect, useEffect } from 'react';\nimport * as variants from './variants'\nimport { Easing } from '../animate';\nimport useTransition from '../hooks/useTransition';\n\nexport type TransitionVariantTypes = keyof typeof variants\nexport type TransitionProps = {\n children: React.ReactElement;\n open: boolean;\n variant: TransitionVariantTypes\n easing?: keyof typeof Easing\n duration?: number;\n delay?: number;\n initialTransition?: boolean;\n\n exitOnUnmount?: boolean;\n\n onEnter?: () => void\n onEntered?: () => void\n onExit?: () => void\n onExited?: () => void\n onUpdate?: (value: Record<string, number>, progress: number) => void;\n onDone?: () => void;\n}\n\n\nfunction TransitionBase({ children, ...options }: TransitionProps) {\n let {\n open,\n variant = \"fade\",\n duration = 450,\n delay,\n easing,\n exitOnUnmount = false,\n initialTransition = true,\n onEnter,\n onEntered,\n onExit,\n onExited,\n onUpdate,\n onDone,\n\n } = options\n\n easing ??= \"default\"\n\n const variantCb = variants[variant]\n const ref = useRef<HTMLElement>(null)\n const init = useRef(false)\n const rect = useRef<DOMRect>(null)\n\n const trans = useTransition({\n delay,\n duration,\n easing: Easing[easing],\n onEnter,\n onEntered,\n onExit,\n onExited,\n onDone,\n from: () => {\n if (!rect.current) {\n rect.current = ref.current?.getBoundingClientRect() as DOMRect\n }\n const v = variantCb(ref.current as HTMLElement, rect.current)\n return v.from\n },\n to: () => {\n if (!rect.current) {\n rect.current = ref.current?.getBoundingClientRect() as DOMRect\n }\n const v = variantCb(ref.current as HTMLElement, rect.current)\n return v.to\n },\n onUpdate: (val, prograss) => {\n if (!ref.current || !rect.current) return\n const vc = variantCb(ref.current, rect.current)\n onUpdate?.(val, prograss)\n return vc.onUpdate(val)\n },\n })\n\n\n useLayoutEffect(() => {\n const isnot = !init.current && !initialTransition\n init.current = true\n if (open) {\n trans.enter(isnot ? false : true)\n } else {\n trans.exit(isnot ? false : true)\n }\n }, [open])\n\n\n if (exitOnUnmount && trans.status === \"exited\") return\n\n const childs = Children.toArray(children)\n if (childs.length !== 1) {\n throw new Error(\"Transition expects exactly one child.\");\n }\n const child = childs[0]\n if (!isValidElement(child)) {\n throw new Error(\"Transition expects a valid React element.\");\n }\n\n return cloneElement(child, {\n ref: (node: HTMLElement) => {\n ref.current = node;\n\n const childRef = (child as any).ref;\n if (typeof childRef === \"function\") {\n childRef(node);\n } else if (childRef) {\n childRef.current = node;\n }\n }\n } as any);\n}\n\n\nconst Transition = (props: any) => {\n return (\n <TransitionBase\n key={props.variant}\n {...props}\n />\n )\n}\nexport default Transition"],"names":[],"mappings":";;;;;;;;AA2BA;AAAwB;AACpB;;AAmBA;AACA;AACA;AACA;;;;AAKI;;;;;;;;AAOI;;;AAGA;;;;;AAIA;;;AAGA;;;AAGJ;;;AAEI;;AAEA;;AAEP;;;AAKG;;AAEI;;;AAEA;;AAER;AAGA;;;AAGA;AACI;;AAEJ;AACA;AACI;;;AAIA;AACI;AAEA;AACA;;;;AAGI;;;AAGJ;AACZ;AAGA;;AAOA;;"}
|