@xanui/core 1.2.22 → 1.2.25
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.d.ts +10 -30
- package/Transition/index.js +7 -92
- package/Transition/index.js.map +1 -1
- package/Transition/index.mjs +7 -92
- package/Transition/index.mjs.map +1 -1
- package/css/getProps.js +3 -1
- package/css/getProps.js.map +1 -1
- package/css/getProps.mjs +3 -1
- package/css/getProps.mjs.map +1 -1
- package/hooks/useAnimation.d.ts +4 -5
- package/hooks/useAnimation.js +15 -8
- package/hooks/useAnimation.js.map +1 -1
- package/hooks/useAnimation.mjs +15 -8
- package/hooks/useAnimation.mjs.map +1 -1
- package/hooks/useTransition/index.d.ts +36 -0
- package/hooks/useTransition/index.js +88 -0
- package/hooks/useTransition/index.js.map +1 -0
- package/hooks/useTransition/index.mjs +88 -0
- package/hooks/useTransition/index.mjs.map +1 -0
- package/{Transition → hooks/useTransition}/variants.d.ts +17 -19
- package/hooks/useTransition/variants.js +158 -0
- package/hooks/useTransition/variants.js.map +1 -0
- package/hooks/useTransition/variants.mjs +158 -0
- package/hooks/useTransition/variants.mjs.map +1 -0
- package/index.d.ts +2 -1
- package/index.js +1 -1
- package/index.mjs +1 -1
- package/package.json +3 -3
- package/Transition/variants.js +0 -158
- package/Transition/variants.js.map +0 -1
- package/Transition/variants.mjs +0 -158
- package/Transition/variants.mjs.map +0 -1
package/Transition/index.d.ts
CHANGED
|
@@ -1,34 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { CSSProps } from '../css/types.js';
|
|
4
|
-
import * as variants from './variants.js';
|
|
1
|
+
import * as React$1 from 'react';
|
|
2
|
+
import { UseTransitionProps } from '../hooks/useTransition/index.js';
|
|
5
3
|
|
|
6
|
-
type
|
|
7
|
-
|
|
8
|
-
height: number;
|
|
9
|
-
width: number;
|
|
10
|
-
rect: DOMRect | null;
|
|
4
|
+
type TransitionProps = UseTransitionProps & {
|
|
5
|
+
children: React.ReactElement;
|
|
11
6
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
from: CSSProps;
|
|
18
|
-
to: CSSProps;
|
|
19
|
-
} | TransitionVariantTypes;
|
|
20
|
-
ease?: string;
|
|
21
|
-
easing?: keyof typeof animationEases;
|
|
22
|
-
duration?: number;
|
|
23
|
-
delay?: number;
|
|
24
|
-
disableInitialTransition?: boolean;
|
|
25
|
-
onOpen?: () => void;
|
|
26
|
-
onOpened?: () => void;
|
|
27
|
-
onClose?: () => void;
|
|
28
|
-
onClosed?: () => void;
|
|
29
|
-
onState?: (state: TransitionState) => void;
|
|
30
|
-
};
|
|
31
|
-
declare const Transition: ({ children, open, ...props }: TransitionProps) => React__default.JSX.Element;
|
|
7
|
+
declare const Transition: ({ children, ...options }: TransitionProps) => React$1.DetailedReactHTMLElement<{
|
|
8
|
+
id: string;
|
|
9
|
+
'data-transition': string;
|
|
10
|
+
'data-transition-state': string;
|
|
11
|
+
}, HTMLElement> | null;
|
|
32
12
|
|
|
33
13
|
export { Transition as default };
|
|
34
|
-
export type {
|
|
14
|
+
export type { TransitionProps };
|
package/Transition/index.js
CHANGED
|
@@ -1,93 +1,8 @@
|
|
|
1
|
-
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var tslib=require('tslib'),
|
|
2
|
-
var { children
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const id = React.useId().replace(/:/g, "");
|
|
9
|
-
const [rendered, setRendered] = React.useState(false);
|
|
10
|
-
const [initial, setInitial] = React.useState(false);
|
|
11
|
-
const [transitionState, setTransitionState] = React.useState(open ? (disableInitialTransition ? "opened" : "open") : "closed");
|
|
12
|
-
const [element, setElement] = React.useState({
|
|
13
|
-
height: 0,
|
|
14
|
-
width: 0,
|
|
15
|
-
rect: null
|
|
16
|
-
});
|
|
17
|
-
if (typeof variant === 'string') {
|
|
18
|
-
variant = variants[variant](element);
|
|
19
|
-
}
|
|
20
|
-
let from = variant.from;
|
|
21
|
-
let to = variant.to;
|
|
22
|
-
const [_css, setCss] = React.useState(open ? to : from);
|
|
23
|
-
React.useEffect(() => {
|
|
24
|
-
const ele = document.querySelector(`.trans-${id}`);
|
|
25
|
-
if (ele) {
|
|
26
|
-
setRendered(true);
|
|
27
|
-
setElement({
|
|
28
|
-
height: ele.clientHeight,
|
|
29
|
-
width: ele.clientWidth,
|
|
30
|
-
rect: ele.getBoundingClientRect()
|
|
31
|
-
});
|
|
32
|
-
if (!disableInitialTransition && open) {
|
|
33
|
-
setCss(from);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}, []);
|
|
37
|
-
React.useEffect(() => {
|
|
38
|
-
const ele = document.querySelector(`.trans-${id}`);
|
|
39
|
-
if (rendered && ele) {
|
|
40
|
-
let stimer = null;
|
|
41
|
-
let etimer = null;
|
|
42
|
-
ele.ontransitionstart = () => {
|
|
43
|
-
clearTimeout(stimer);
|
|
44
|
-
stimer = setTimeout(() => {
|
|
45
|
-
const isOpen = Array.from(ele.classList).includes("trans-open");
|
|
46
|
-
(onOpen && isOpen) && onOpen();
|
|
47
|
-
(onClose && !isOpen) && onClose();
|
|
48
|
-
onState && onState(isOpen ? "open" : "close");
|
|
49
|
-
setTransitionState(isOpen ? "open" : "close");
|
|
50
|
-
}, 1);
|
|
51
|
-
};
|
|
52
|
-
ele.ontransitionend = () => {
|
|
53
|
-
clearTimeout(etimer);
|
|
54
|
-
etimer = setTimeout(() => {
|
|
55
|
-
const isOpen = Array.from(ele.classList).includes("trans-open");
|
|
56
|
-
(onOpened && isOpen) && onOpened();
|
|
57
|
-
(onClosed && !isOpen) && onClosed();
|
|
58
|
-
onState && onState(isOpen ? "opened" : "closed");
|
|
59
|
-
setTransitionState(isOpen ? "opened" : "closed");
|
|
60
|
-
}, 1);
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
}, [rendered]);
|
|
64
|
-
React.useEffect(() => {
|
|
65
|
-
if (rendered) {
|
|
66
|
-
if (!initial) {
|
|
67
|
-
setInitial(true);
|
|
68
|
-
setTimeout(() => {
|
|
69
|
-
setCss(open ? to : from);
|
|
70
|
-
}, 50);
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
setCss(open ? to : from);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}, [rendered, open, JSON.stringify(from), JSON.stringify(to)]);
|
|
77
|
-
let _ = {};
|
|
78
|
-
if (rendered) {
|
|
79
|
-
let trans = ` ${duration}ms ${_ease} ${delay || 0}ms`;
|
|
80
|
-
_ = Object.assign(Object.assign({}, _css), { transition: Object.keys(_css || {}).map(k => oncss.formatCSSProp(k)).join(trans + ", ") + trans });
|
|
81
|
-
}
|
|
82
|
-
const cls = index.css(_);
|
|
83
|
-
if (!children || Array.isArray(children))
|
|
84
|
-
throw new Error("Invalid children in Transition");
|
|
85
|
-
const first = React.Children.toArray(children).shift();
|
|
86
|
-
let classname = `${cls.classname} trans-${id} trans-${(open ? "open" : "close")} trans-state-${transitionState}`;
|
|
87
|
-
const child = React.cloneElement(first, { classNames: [classname] });
|
|
88
|
-
if (rendered)
|
|
89
|
-
return child;
|
|
90
|
-
if (!rendered && disableInitialTransition && open)
|
|
91
|
-
return child;
|
|
92
|
-
return (jsxRuntime.jsx(index$1.default, { height: 0, overflow: 'hidden', position: "fixed", visibility: "hidden", children: child }));
|
|
1
|
+
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var tslib=require('tslib'),React=require('react'),index=require('../hooks/useTransition/index.js');const Transition = (_a) => {
|
|
2
|
+
var { children } = _a, options = tslib.__rest(_a, ["children"]);
|
|
3
|
+
const { props, exited } = index.default(options);
|
|
4
|
+
if (exited)
|
|
5
|
+
return null;
|
|
6
|
+
const clone = React.Children.only(children);
|
|
7
|
+
return React.cloneElement(clone, props);
|
|
93
8
|
};exports.default=Transition;//# sourceMappingURL=index.js.map
|
package/Transition/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/Transition/index.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/Transition/index.tsx"],"sourcesContent":["import { cloneElement, Children } from 'react';\nimport useTransition, { UseTransitionProps } from '../hooks/useTransition';\n\nexport type TransitionProps = UseTransitionProps & {\n children: React.ReactElement;\n}\n\nconst Transition = ({ children, ...options }: TransitionProps) => {\n const { props, exited } = useTransition(options);\n if (exited) return null;\n const clone: any = Children.only(children);\n return cloneElement(clone, props);\n}\n\n\nexport default Transition"],"names":["__rest","useTransition","Children","cloneElement"],"mappings":"yKAOA,MAAM,UAAU,GAAG,CAAC,EAAyC,KAAI;AAA7C,IAAA,IAAA,EAAE,QAAQ,EAAA,GAAA,EAA+B,EAA1B,OAAO,GAAAA,YAAA,CAAA,EAAA,EAAtB,YAAwB,CAAF;IACtC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAGC,aAAa,CAAC,OAAO,CAAC;AAChD,IAAA,IAAI,MAAM;AAAE,QAAA,OAAO,IAAI;IACvB,MAAM,KAAK,GAAQC,cAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC;AAC1C,IAAA,OAAOC,kBAAY,CAAC,KAAK,EAAE,KAAK,CAAC;AACrC"}
|
package/Transition/index.mjs
CHANGED
|
@@ -1,93 +1,8 @@
|
|
|
1
|
-
import {__rest}from'tslib';import {
|
|
2
|
-
var { children
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const id = useId().replace(/:/g, "");
|
|
9
|
-
const [rendered, setRendered] = useState(false);
|
|
10
|
-
const [initial, setInitial] = useState(false);
|
|
11
|
-
const [transitionState, setTransitionState] = useState(open ? (disableInitialTransition ? "opened" : "open") : "closed");
|
|
12
|
-
const [element, setElement] = useState({
|
|
13
|
-
height: 0,
|
|
14
|
-
width: 0,
|
|
15
|
-
rect: null
|
|
16
|
-
});
|
|
17
|
-
if (typeof variant === 'string') {
|
|
18
|
-
variant = variants[variant](element);
|
|
19
|
-
}
|
|
20
|
-
let from = variant.from;
|
|
21
|
-
let to = variant.to;
|
|
22
|
-
const [_css, setCss] = useState(open ? to : from);
|
|
23
|
-
useEffect(() => {
|
|
24
|
-
const ele = document.querySelector(`.trans-${id}`);
|
|
25
|
-
if (ele) {
|
|
26
|
-
setRendered(true);
|
|
27
|
-
setElement({
|
|
28
|
-
height: ele.clientHeight,
|
|
29
|
-
width: ele.clientWidth,
|
|
30
|
-
rect: ele.getBoundingClientRect()
|
|
31
|
-
});
|
|
32
|
-
if (!disableInitialTransition && open) {
|
|
33
|
-
setCss(from);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}, []);
|
|
37
|
-
useEffect(() => {
|
|
38
|
-
const ele = document.querySelector(`.trans-${id}`);
|
|
39
|
-
if (rendered && ele) {
|
|
40
|
-
let stimer = null;
|
|
41
|
-
let etimer = null;
|
|
42
|
-
ele.ontransitionstart = () => {
|
|
43
|
-
clearTimeout(stimer);
|
|
44
|
-
stimer = setTimeout(() => {
|
|
45
|
-
const isOpen = Array.from(ele.classList).includes("trans-open");
|
|
46
|
-
(onOpen && isOpen) && onOpen();
|
|
47
|
-
(onClose && !isOpen) && onClose();
|
|
48
|
-
onState && onState(isOpen ? "open" : "close");
|
|
49
|
-
setTransitionState(isOpen ? "open" : "close");
|
|
50
|
-
}, 1);
|
|
51
|
-
};
|
|
52
|
-
ele.ontransitionend = () => {
|
|
53
|
-
clearTimeout(etimer);
|
|
54
|
-
etimer = setTimeout(() => {
|
|
55
|
-
const isOpen = Array.from(ele.classList).includes("trans-open");
|
|
56
|
-
(onOpened && isOpen) && onOpened();
|
|
57
|
-
(onClosed && !isOpen) && onClosed();
|
|
58
|
-
onState && onState(isOpen ? "opened" : "closed");
|
|
59
|
-
setTransitionState(isOpen ? "opened" : "closed");
|
|
60
|
-
}, 1);
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
}, [rendered]);
|
|
64
|
-
useEffect(() => {
|
|
65
|
-
if (rendered) {
|
|
66
|
-
if (!initial) {
|
|
67
|
-
setInitial(true);
|
|
68
|
-
setTimeout(() => {
|
|
69
|
-
setCss(open ? to : from);
|
|
70
|
-
}, 50);
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
setCss(open ? to : from);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}, [rendered, open, JSON.stringify(from), JSON.stringify(to)]);
|
|
77
|
-
let _ = {};
|
|
78
|
-
if (rendered) {
|
|
79
|
-
let trans = ` ${duration}ms ${_ease} ${delay || 0}ms`;
|
|
80
|
-
_ = Object.assign(Object.assign({}, _css), { transition: Object.keys(_css || {}).map(k => formatCSSProp(k)).join(trans + ", ") + trans });
|
|
81
|
-
}
|
|
82
|
-
const cls = css(_);
|
|
83
|
-
if (!children || Array.isArray(children))
|
|
84
|
-
throw new Error("Invalid children in Transition");
|
|
85
|
-
const first = Children.toArray(children).shift();
|
|
86
|
-
let classname = `${cls.classname} trans-${id} trans-${(open ? "open" : "close")} trans-state-${transitionState}`;
|
|
87
|
-
const child = cloneElement(first, { classNames: [classname] });
|
|
88
|
-
if (rendered)
|
|
89
|
-
return child;
|
|
90
|
-
if (!rendered && disableInitialTransition && open)
|
|
91
|
-
return child;
|
|
92
|
-
return (jsx(Tag, { height: 0, overflow: 'hidden', position: "fixed", visibility: "hidden", children: child }));
|
|
1
|
+
import {__rest}from'tslib';import {Children,cloneElement}from'react';import useTransition from'../hooks/useTransition/index.mjs';const Transition = (_a) => {
|
|
2
|
+
var { children } = _a, options = __rest(_a, ["children"]);
|
|
3
|
+
const { props, exited } = useTransition(options);
|
|
4
|
+
if (exited)
|
|
5
|
+
return null;
|
|
6
|
+
const clone = Children.only(children);
|
|
7
|
+
return cloneElement(clone, props);
|
|
93
8
|
};export{Transition as default};//# sourceMappingURL=index.mjs.map
|
package/Transition/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/Transition/index.tsx"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/Transition/index.tsx"],"sourcesContent":["import { cloneElement, Children } from 'react';\nimport useTransition, { UseTransitionProps } from '../hooks/useTransition';\n\nexport type TransitionProps = UseTransitionProps & {\n children: React.ReactElement;\n}\n\nconst Transition = ({ children, ...options }: TransitionProps) => {\n const { props, exited } = useTransition(options);\n if (exited) return null;\n const clone: any = Children.only(children);\n return cloneElement(clone, props);\n}\n\n\nexport default Transition"],"names":[],"mappings":"iIAOA,MAAM,UAAU,GAAG,CAAC,EAAyC,KAAI;AAA7C,IAAA,IAAA,EAAE,QAAQ,EAAA,GAAA,EAA+B,EAA1B,OAAO,GAAA,MAAA,CAAA,EAAA,EAAtB,YAAwB,CAAF;IACtC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,aAAa,CAAC,OAAO,CAAC;AAChD,IAAA,IAAI,MAAM;AAAE,QAAA,OAAO,IAAI;IACvB,MAAM,KAAK,GAAQ,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC;AAC1C,IAAA,OAAO,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC;AACrC"}
|
package/css/getProps.js
CHANGED
|
@@ -23,10 +23,12 @@
|
|
|
23
23
|
}
|
|
24
24
|
if (prop === "spacing" && typeof value === "number") {
|
|
25
25
|
const val = value * 8;
|
|
26
|
+
const hasWidth = "width" in _css;
|
|
27
|
+
const width = `calc(${hasWidth ? _css.width : "100%"} + ${val}px)`;
|
|
26
28
|
return {
|
|
27
29
|
marginLeft: `-${val}px`,
|
|
28
30
|
marginTop: `-${val}px`,
|
|
29
|
-
width:
|
|
31
|
+
width: width,
|
|
30
32
|
"& > *": {
|
|
31
33
|
paddingLeft: `${val}px`,
|
|
32
34
|
paddingTop: `${val}px`,
|
package/css/getProps.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getProps.js","sources":["../../src/css/getProps.ts"],"sourcesContent":["import { CSSProps } from \"./types\";\n\nconst getProps = (prop: string, value: string, _css: CSSProps) => {\n let important;\n if (typeof value === 'string') {\n const split = value.split(\"!\")\n important = split[1] ? \"!important\" : \"\"\n value = split[0]\n }\n\n if (prop === 'disabled') {\n if ((value as any) === true) {\n let c: any = {\n pointerEvents: \"none!important\",\n cursor: \"default!important\",\n userSelect: \"none!important\",\n opacity: \"0.5!important\",\n color: `text.primary!important`,\n borderColor: `divider.secondary!important`,\n }\n\n if ((_css as any).bgcolor && (_css as any).bgcolor !== 'transparent') {\n c.bgcolor = `divider.primary!important`\n }\n return c\n }\n return {}\n }\n\n\n if (prop === \"spacing\" && typeof value === \"number\") {\n const val = value * 8;\n\n return {\n marginLeft: `-${val}px`,\n marginTop: `-${val}px`,\n width:
|
|
1
|
+
{"version":3,"file":"getProps.js","sources":["../../src/css/getProps.ts"],"sourcesContent":["import { CSSProps } from \"./types\";\n\nconst getProps = (prop: string, value: string, _css: CSSProps) => {\n let important;\n if (typeof value === 'string') {\n const split = value.split(\"!\")\n important = split[1] ? \"!important\" : \"\"\n value = split[0]\n }\n\n if (prop === 'disabled') {\n if ((value as any) === true) {\n let c: any = {\n pointerEvents: \"none!important\",\n cursor: \"default!important\",\n userSelect: \"none!important\",\n opacity: \"0.5!important\",\n color: `text.primary!important`,\n borderColor: `divider.secondary!important`,\n }\n\n if ((_css as any).bgcolor && (_css as any).bgcolor !== 'transparent') {\n c.bgcolor = `divider.primary!important`\n }\n return c\n }\n return {}\n }\n\n\n if (prop === \"spacing\" && typeof value === \"number\") {\n const val = value * 8;\n const hasWidth = \"width\" in _css;\n const width = `calc(${hasWidth ? _css.width : \"100%\"} + ${val}px)`;\n return {\n marginLeft: `-${val}px`,\n marginTop: `-${val}px`,\n width: width,\n\n \"& > *\": {\n paddingLeft: `${val}px`,\n paddingTop: `${val}px`,\n },\n } as any;\n }\n\n\n\n // if (value && typeof value === \"number\" && [\"border\", \"borderRight\", \"borderLeft\", \"borderTop\", \"borderBottom\"].includes(prop as any)) {\n // const keys: any = Object.keys(_css)\n // let p: any = {\n // [`${prop}Width`]: value + 'px' + (important || \"\"),\n // }\n // // if (!keys.includes(`${prop}Color`)) {\n // // p[`${prop}Color`] = \"divider.primary\"\n // // }\n // if (!keys.includes(`${prop}Style`)) {\n // p[`${prop}Style`] = \"solid\"\n // }\n // return p\n // }\n}\n\nexport default getProps"],"names":[],"mappings":"sEAEA,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,KAAa,EAAE,IAAc,KAAI;AAE7D,IAAA,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC3B,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;AAC9B,QAAY,KAAK,CAAC,CAAC,CAAC,GAAG,YAAY,GAAG,EAAE;AACxC,QAAA,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC;IACpB;AAEA,IAAA,IAAI,IAAI,KAAK,UAAU,EAAE;AACrB,QAAA,IAAK,KAAa,KAAK,IAAI,EAAE;AACzB,YAAA,IAAI,CAAC,GAAQ;AACT,gBAAA,aAAa,EAAE,gBAAgB;AAC/B,gBAAA,MAAM,EAAE,mBAAmB;AAC3B,gBAAA,UAAU,EAAE,gBAAgB;AAC5B,gBAAA,OAAO,EAAE,eAAe;AACxB,gBAAA,KAAK,EAAE,CAAA,sBAAA,CAAwB;AAC/B,gBAAA,WAAW,EAAE,CAAA,2BAAA,CAA6B;aAC7C;YAED,IAAK,IAAY,CAAC,OAAO,IAAK,IAAY,CAAC,OAAO,KAAK,aAAa,EAAE;AAClE,gBAAA,CAAC,CAAC,OAAO,GAAG,CAAA,yBAAA,CAA2B;YAC3C;AACA,YAAA,OAAO,CAAC;QACZ;AACA,QAAA,OAAO,EAAE;IACb;IAGA,IAAI,IAAI,KAAK,SAAS,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;AACjD,QAAA,MAAM,GAAG,GAAG,KAAK,GAAG,CAAC;AACrB,QAAA,MAAM,QAAQ,GAAG,OAAO,IAAI,IAAI;AAChC,QAAA,MAAM,KAAK,GAAG,CAAA,KAAA,EAAQ,QAAQ,GAAG,IAAI,CAAC,KAAK,GAAG,MAAM,CAAA,GAAA,EAAM,GAAG,KAAK;QAClE,OAAO;YACH,UAAU,EAAE,CAAA,CAAA,EAAI,GAAG,CAAA,EAAA,CAAI;YACvB,SAAS,EAAE,CAAA,CAAA,EAAI,GAAG,CAAA,EAAA,CAAI;AACtB,YAAA,KAAK,EAAE,KAAK;AAEZ,YAAA,OAAO,EAAE;gBACL,WAAW,EAAE,CAAA,EAAG,GAAG,CAAA,EAAA,CAAI;gBACvB,UAAU,EAAE,CAAA,EAAG,GAAG,CAAA,EAAA,CAAI;AACzB,aAAA;SACG;IACZ;;;;;;;;;;;;;;AAiBJ"}
|
package/css/getProps.mjs
CHANGED
|
@@ -23,10 +23,12 @@ const getProps = (prop, value, _css) => {
|
|
|
23
23
|
}
|
|
24
24
|
if (prop === "spacing" && typeof value === "number") {
|
|
25
25
|
const val = value * 8;
|
|
26
|
+
const hasWidth = "width" in _css;
|
|
27
|
+
const width = `calc(${hasWidth ? _css.width : "100%"} + ${val}px)`;
|
|
26
28
|
return {
|
|
27
29
|
marginLeft: `-${val}px`,
|
|
28
30
|
marginTop: `-${val}px`,
|
|
29
|
-
width:
|
|
31
|
+
width: width,
|
|
30
32
|
"& > *": {
|
|
31
33
|
paddingLeft: `${val}px`,
|
|
32
34
|
paddingTop: `${val}px`,
|
package/css/getProps.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getProps.mjs","sources":["../../src/css/getProps.ts"],"sourcesContent":["import { CSSProps } from \"./types\";\n\nconst getProps = (prop: string, value: string, _css: CSSProps) => {\n let important;\n if (typeof value === 'string') {\n const split = value.split(\"!\")\n important = split[1] ? \"!important\" : \"\"\n value = split[0]\n }\n\n if (prop === 'disabled') {\n if ((value as any) === true) {\n let c: any = {\n pointerEvents: \"none!important\",\n cursor: \"default!important\",\n userSelect: \"none!important\",\n opacity: \"0.5!important\",\n color: `text.primary!important`,\n borderColor: `divider.secondary!important`,\n }\n\n if ((_css as any).bgcolor && (_css as any).bgcolor !== 'transparent') {\n c.bgcolor = `divider.primary!important`\n }\n return c\n }\n return {}\n }\n\n\n if (prop === \"spacing\" && typeof value === \"number\") {\n const val = value * 8;\n\n return {\n marginLeft: `-${val}px`,\n marginTop: `-${val}px`,\n width:
|
|
1
|
+
{"version":3,"file":"getProps.mjs","sources":["../../src/css/getProps.ts"],"sourcesContent":["import { CSSProps } from \"./types\";\n\nconst getProps = (prop: string, value: string, _css: CSSProps) => {\n let important;\n if (typeof value === 'string') {\n const split = value.split(\"!\")\n important = split[1] ? \"!important\" : \"\"\n value = split[0]\n }\n\n if (prop === 'disabled') {\n if ((value as any) === true) {\n let c: any = {\n pointerEvents: \"none!important\",\n cursor: \"default!important\",\n userSelect: \"none!important\",\n opacity: \"0.5!important\",\n color: `text.primary!important`,\n borderColor: `divider.secondary!important`,\n }\n\n if ((_css as any).bgcolor && (_css as any).bgcolor !== 'transparent') {\n c.bgcolor = `divider.primary!important`\n }\n return c\n }\n return {}\n }\n\n\n if (prop === \"spacing\" && typeof value === \"number\") {\n const val = value * 8;\n const hasWidth = \"width\" in _css;\n const width = `calc(${hasWidth ? _css.width : \"100%\"} + ${val}px)`;\n return {\n marginLeft: `-${val}px`,\n marginTop: `-${val}px`,\n width: width,\n\n \"& > *\": {\n paddingLeft: `${val}px`,\n paddingTop: `${val}px`,\n },\n } as any;\n }\n\n\n\n // if (value && typeof value === \"number\" && [\"border\", \"borderRight\", \"borderLeft\", \"borderTop\", \"borderBottom\"].includes(prop as any)) {\n // const keys: any = Object.keys(_css)\n // let p: any = {\n // [`${prop}Width`]: value + 'px' + (important || \"\"),\n // }\n // // if (!keys.includes(`${prop}Color`)) {\n // // p[`${prop}Color`] = \"divider.primary\"\n // // }\n // if (!keys.includes(`${prop}Style`)) {\n // p[`${prop}Style`] = \"solid\"\n // }\n // return p\n // }\n}\n\nexport default getProps"],"names":[],"mappings":"AAEA,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,KAAa,EAAE,IAAc,KAAI;AAE7D,IAAA,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC3B,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;AAC9B,QAAY,KAAK,CAAC,CAAC,CAAC,GAAG,YAAY,GAAG,EAAE;AACxC,QAAA,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC;IACpB;AAEA,IAAA,IAAI,IAAI,KAAK,UAAU,EAAE;AACrB,QAAA,IAAK,KAAa,KAAK,IAAI,EAAE;AACzB,YAAA,IAAI,CAAC,GAAQ;AACT,gBAAA,aAAa,EAAE,gBAAgB;AAC/B,gBAAA,MAAM,EAAE,mBAAmB;AAC3B,gBAAA,UAAU,EAAE,gBAAgB;AAC5B,gBAAA,OAAO,EAAE,eAAe;AACxB,gBAAA,KAAK,EAAE,CAAA,sBAAA,CAAwB;AAC/B,gBAAA,WAAW,EAAE,CAAA,2BAAA,CAA6B;aAC7C;YAED,IAAK,IAAY,CAAC,OAAO,IAAK,IAAY,CAAC,OAAO,KAAK,aAAa,EAAE;AAClE,gBAAA,CAAC,CAAC,OAAO,GAAG,CAAA,yBAAA,CAA2B;YAC3C;AACA,YAAA,OAAO,CAAC;QACZ;AACA,QAAA,OAAO,EAAE;IACb;IAGA,IAAI,IAAI,KAAK,SAAS,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;AACjD,QAAA,MAAM,GAAG,GAAG,KAAK,GAAG,CAAC;AACrB,QAAA,MAAM,QAAQ,GAAG,OAAO,IAAI,IAAI;AAChC,QAAA,MAAM,KAAK,GAAG,CAAA,KAAA,EAAQ,QAAQ,GAAG,IAAI,CAAC,KAAK,GAAG,MAAM,CAAA,GAAA,EAAM,GAAG,KAAK;QAClE,OAAO;YACH,UAAU,EAAE,CAAA,CAAA,EAAI,GAAG,CAAA,EAAA,CAAI;YACvB,SAAS,EAAE,CAAA,CAAA,EAAI,GAAG,CAAA,EAAA,CAAI;AACtB,YAAA,KAAK,EAAE,KAAK;AAEZ,YAAA,OAAO,EAAE;gBACL,WAAW,EAAE,CAAA,EAAG,GAAG,CAAA,EAAA,CAAI;gBACvB,UAAU,EAAE,CAAA,EAAG,GAAG,CAAA,EAAA,CAAI;AACzB,aAAA;SACG;IACZ;;;;;;;;;;;;;;AAiBJ"}
|
package/hooks/useAnimation.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { CSSProps } from '../css/types.js';
|
|
2
2
|
|
|
3
3
|
declare const animationEases: {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
sharp: string;
|
|
4
|
+
standard: string;
|
|
5
|
+
fast: string;
|
|
6
|
+
smooth: string;
|
|
8
7
|
linear: string;
|
|
9
|
-
|
|
8
|
+
bounce: string;
|
|
10
9
|
};
|
|
11
10
|
interface UseAnimationProps {
|
|
12
11
|
delay?: number;
|
package/hooks/useAnimation.js
CHANGED
|
@@ -1,21 +1,28 @@
|
|
|
1
|
-
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var index=require('../css/index.js'),React=require('react')
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var index=require('../css/index.js'),React=require('react');// export const animationEases = {
|
|
2
|
+
// easeInOut: "cubic-bezier(0.4, 0, 0.2, 1)",
|
|
3
|
+
// easeOut: "cubic-bezier(0.0, 0, 0.2, 1)",
|
|
4
|
+
// easeIn: "cubic-bezier(0.4, 0, 1, 1)",
|
|
5
|
+
// sharp: "cubic-bezier(0.4, 0, 0.6, 1)",
|
|
6
|
+
// linear: "cubic-bezier(0, 0, 1, 1)",
|
|
7
|
+
// easeBounceOut: "cubic-bezier(0.68, -0.55, 0.265, 1.55)"
|
|
8
|
+
// }
|
|
9
|
+
const animationEases = {
|
|
10
|
+
standard: "cubic-bezier(0.4, 0, 0.2, 1)",
|
|
11
|
+
fast: "cubic-bezier(0.2, 0, 0, 1)",
|
|
12
|
+
smooth: "cubic-bezier(0.25, 0.46, 0.45, 0.94)",
|
|
6
13
|
linear: "cubic-bezier(0, 0, 1, 1)",
|
|
7
|
-
|
|
14
|
+
bounce: "cubic-bezier(0.34, 1.50, 0.64, 1)",
|
|
8
15
|
};
|
|
9
16
|
const useAnimation = ({ from, to, delay, ease, duration }) => {
|
|
10
17
|
let _delay = delay || 0;
|
|
11
18
|
let _duration = duration || 600;
|
|
12
|
-
let _ease = ease || "
|
|
19
|
+
let _ease = ease || "standard";
|
|
13
20
|
const id = "anim" + React.useId().replace(/:/g, "");
|
|
14
21
|
const anim = index.css({
|
|
15
22
|
animationName: id,
|
|
16
23
|
animationDelay: _delay + "ms",
|
|
17
24
|
animationDuration: _duration + "ms",
|
|
18
|
-
animationTimingFunction: animationEases[_ease] || animationEases.
|
|
25
|
+
animationTimingFunction: animationEases[_ease] || animationEases.standard,
|
|
19
26
|
[`@keyframes ${id}`]: {
|
|
20
27
|
from: from,
|
|
21
28
|
to: to
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAnimation.js","sources":["../../src/hooks/useAnimation.ts"],"sourcesContent":["import { css } from '../css'\nimport { useId } from 'react'\nimport { CSSProps } from '../css/types'\n\
|
|
1
|
+
{"version":3,"file":"useAnimation.js","sources":["../../src/hooks/useAnimation.ts"],"sourcesContent":["import { css } from '../css'\nimport { useId } from 'react'\nimport { CSSProps } from '../css/types'\n\n// export const animationEases = {\n// easeInOut: \"cubic-bezier(0.4, 0, 0.2, 1)\",\n// easeOut: \"cubic-bezier(0.0, 0, 0.2, 1)\",\n// easeIn: \"cubic-bezier(0.4, 0, 1, 1)\",\n// sharp: \"cubic-bezier(0.4, 0, 0.6, 1)\",\n// linear: \"cubic-bezier(0, 0, 1, 1)\",\n// easeBounceOut: \"cubic-bezier(0.68, -0.55, 0.265, 1.55)\"\n// }\n\nexport const animationEases = {\n standard: \"cubic-bezier(0.4, 0, 0.2, 1)\",\n fast: \"cubic-bezier(0.2, 0, 0, 1)\",\n smooth: \"cubic-bezier(0.25, 0.46, 0.45, 0.94)\",\n linear: \"cubic-bezier(0, 0, 1, 1)\",\n bounce: \"cubic-bezier(0.34, 1.50, 0.64, 1)\",\n};\n\n\n\nexport interface UseAnimationProps {\n delay?: number;\n duration?: number;\n from: CSSProps;\n to: CSSProps;\n ease?: keyof typeof animationEases;\n}\n\nconst useAnimation = ({ from, to, delay, ease, duration }: UseAnimationProps) => {\n let _delay = delay || 0;\n let _duration = duration || 600;\n let _ease = ease || \"standard\"\n const id = \"anim\" + useId().replace(/:/g, \"\")\n const anim = css({\n animationName: id,\n animationDelay: _delay + \"ms\",\n animationDuration: _duration + \"ms\",\n animationTimingFunction: animationEases[_ease] || animationEases.standard,\n [`@keyframes ${id}`]: {\n from: from as any,\n to: to as any\n }\n })\n return anim.classname\n}\n\nexport default useAnimation"],"names":["useId","css"],"mappings":"kIAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEO,MAAM,cAAc,GAAG;AAC1B,IAAA,QAAQ,EAAE,8BAA8B;AACxC,IAAA,IAAI,EAAE,4BAA4B;AAClC,IAAA,MAAM,EAAE,sCAAsC;AAC9C,IAAA,MAAM,EAAE,0BAA0B;AAClC,IAAA,MAAM,EAAE,mCAAmC;;AAa/C,MAAM,YAAY,GAAG,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAqB,KAAI;AAC5E,IAAA,IAAI,MAAM,GAAG,KAAK,IAAI,CAAC;AACvB,IAAA,IAAI,SAAS,GAAG,QAAQ,IAAI,GAAG;AAC/B,IAAA,IAAI,KAAK,GAAG,IAAI,IAAI,UAAU;AAC9B,IAAA,MAAM,EAAE,GAAG,MAAM,GAAGA,WAAK,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;IAC7C,MAAM,IAAI,GAAGC,SAAG,CAAC;AACb,QAAA,aAAa,EAAE,EAAE;QACjB,cAAc,EAAE,MAAM,GAAG,IAAI;QAC7B,iBAAiB,EAAE,SAAS,GAAG,IAAI;QACnC,uBAAuB,EAAE,cAAc,CAAC,KAAK,CAAC,IAAI,cAAc,CAAC,QAAQ;AACzE,QAAA,CAAC,CAAA,WAAA,EAAc,EAAE,CAAA,CAAE,GAAG;AAClB,YAAA,IAAI,EAAE,IAAW;AACjB,YAAA,EAAE,EAAE;AACP;AACJ,KAAA,CAAC;IACF,OAAO,IAAI,CAAC,SAAS;AACzB"}
|
package/hooks/useAnimation.mjs
CHANGED
|
@@ -1,21 +1,28 @@
|
|
|
1
|
-
import {css}from'../css/index.mjs';import {useId}from'react'
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import {css}from'../css/index.mjs';import {useId}from'react';// export const animationEases = {
|
|
2
|
+
// easeInOut: "cubic-bezier(0.4, 0, 0.2, 1)",
|
|
3
|
+
// easeOut: "cubic-bezier(0.0, 0, 0.2, 1)",
|
|
4
|
+
// easeIn: "cubic-bezier(0.4, 0, 1, 1)",
|
|
5
|
+
// sharp: "cubic-bezier(0.4, 0, 0.6, 1)",
|
|
6
|
+
// linear: "cubic-bezier(0, 0, 1, 1)",
|
|
7
|
+
// easeBounceOut: "cubic-bezier(0.68, -0.55, 0.265, 1.55)"
|
|
8
|
+
// }
|
|
9
|
+
const animationEases = {
|
|
10
|
+
standard: "cubic-bezier(0.4, 0, 0.2, 1)",
|
|
11
|
+
fast: "cubic-bezier(0.2, 0, 0, 1)",
|
|
12
|
+
smooth: "cubic-bezier(0.25, 0.46, 0.45, 0.94)",
|
|
6
13
|
linear: "cubic-bezier(0, 0, 1, 1)",
|
|
7
|
-
|
|
14
|
+
bounce: "cubic-bezier(0.34, 1.50, 0.64, 1)",
|
|
8
15
|
};
|
|
9
16
|
const useAnimation = ({ from, to, delay, ease, duration }) => {
|
|
10
17
|
let _delay = delay || 0;
|
|
11
18
|
let _duration = duration || 600;
|
|
12
|
-
let _ease = ease || "
|
|
19
|
+
let _ease = ease || "standard";
|
|
13
20
|
const id = "anim" + useId().replace(/:/g, "");
|
|
14
21
|
const anim = css({
|
|
15
22
|
animationName: id,
|
|
16
23
|
animationDelay: _delay + "ms",
|
|
17
24
|
animationDuration: _duration + "ms",
|
|
18
|
-
animationTimingFunction: animationEases[_ease] || animationEases.
|
|
25
|
+
animationTimingFunction: animationEases[_ease] || animationEases.standard,
|
|
19
26
|
[`@keyframes ${id}`]: {
|
|
20
27
|
from: from,
|
|
21
28
|
to: to
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAnimation.mjs","sources":["../../src/hooks/useAnimation.ts"],"sourcesContent":["import { css } from '../css'\nimport { useId } from 'react'\nimport { CSSProps } from '../css/types'\n\
|
|
1
|
+
{"version":3,"file":"useAnimation.mjs","sources":["../../src/hooks/useAnimation.ts"],"sourcesContent":["import { css } from '../css'\nimport { useId } from 'react'\nimport { CSSProps } from '../css/types'\n\n// export const animationEases = {\n// easeInOut: \"cubic-bezier(0.4, 0, 0.2, 1)\",\n// easeOut: \"cubic-bezier(0.0, 0, 0.2, 1)\",\n// easeIn: \"cubic-bezier(0.4, 0, 1, 1)\",\n// sharp: \"cubic-bezier(0.4, 0, 0.6, 1)\",\n// linear: \"cubic-bezier(0, 0, 1, 1)\",\n// easeBounceOut: \"cubic-bezier(0.68, -0.55, 0.265, 1.55)\"\n// }\n\nexport const animationEases = {\n standard: \"cubic-bezier(0.4, 0, 0.2, 1)\",\n fast: \"cubic-bezier(0.2, 0, 0, 1)\",\n smooth: \"cubic-bezier(0.25, 0.46, 0.45, 0.94)\",\n linear: \"cubic-bezier(0, 0, 1, 1)\",\n bounce: \"cubic-bezier(0.34, 1.50, 0.64, 1)\",\n};\n\n\n\nexport interface UseAnimationProps {\n delay?: number;\n duration?: number;\n from: CSSProps;\n to: CSSProps;\n ease?: keyof typeof animationEases;\n}\n\nconst useAnimation = ({ from, to, delay, ease, duration }: UseAnimationProps) => {\n let _delay = delay || 0;\n let _duration = duration || 600;\n let _ease = ease || \"standard\"\n const id = \"anim\" + useId().replace(/:/g, \"\")\n const anim = css({\n animationName: id,\n animationDelay: _delay + \"ms\",\n animationDuration: _duration + \"ms\",\n animationTimingFunction: animationEases[_ease] || animationEases.standard,\n [`@keyframes ${id}`]: {\n from: from as any,\n to: to as any\n }\n })\n return anim.classname\n}\n\nexport default useAnimation"],"names":[],"mappings":"6DAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEO,MAAM,cAAc,GAAG;AAC1B,IAAA,QAAQ,EAAE,8BAA8B;AACxC,IAAA,IAAI,EAAE,4BAA4B;AAClC,IAAA,MAAM,EAAE,sCAAsC;AAC9C,IAAA,MAAM,EAAE,0BAA0B;AAClC,IAAA,MAAM,EAAE,mCAAmC;;AAa/C,MAAM,YAAY,GAAG,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAqB,KAAI;AAC5E,IAAA,IAAI,MAAM,GAAG,KAAK,IAAI,CAAC;AACvB,IAAA,IAAI,SAAS,GAAG,QAAQ,IAAI,GAAG;AAC/B,IAAA,IAAI,KAAK,GAAG,IAAI,IAAI,UAAU;AAC9B,IAAA,MAAM,EAAE,GAAG,MAAM,GAAG,KAAK,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;IAC7C,MAAM,IAAI,GAAG,GAAG,CAAC;AACb,QAAA,aAAa,EAAE,EAAE;QACjB,cAAc,EAAE,MAAM,GAAG,IAAI;QAC7B,iBAAiB,EAAE,SAAS,GAAG,IAAI;QACnC,uBAAuB,EAAE,cAAc,CAAC,KAAK,CAAC,IAAI,cAAc,CAAC,QAAQ;AACzE,QAAA,CAAC,CAAA,WAAA,EAAc,EAAE,CAAA,CAAE,GAAG;AAClB,YAAA,IAAI,EAAE,IAAW;AACjB,YAAA,EAAE,EAAE;AACP;AACJ,KAAA,CAAC;IACF,OAAO,IAAI,CAAC,SAAS;AACzB"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { animationEases } from '../useAnimation.js';
|
|
2
|
+
import { CSSProps } from '../../css/types.js';
|
|
3
|
+
import * as variants from './variants.js';
|
|
4
|
+
|
|
5
|
+
type UseTransitionVariantTypes = keyof typeof variants;
|
|
6
|
+
type UseTransitionState = "open" | "opened" | "close" | "closed";
|
|
7
|
+
type UseTransitionVariant = (rect: DOMRect) => ({
|
|
8
|
+
from: CSSProps;
|
|
9
|
+
to: CSSProps;
|
|
10
|
+
});
|
|
11
|
+
type UseTransitionProps = {
|
|
12
|
+
open: boolean;
|
|
13
|
+
variant: UseTransitionVariant | UseTransitionVariantTypes;
|
|
14
|
+
ease?: string;
|
|
15
|
+
easing?: keyof typeof animationEases;
|
|
16
|
+
duration?: number;
|
|
17
|
+
delay?: number;
|
|
18
|
+
disableInitialTransition?: boolean;
|
|
19
|
+
exitOnUnmount?: boolean;
|
|
20
|
+
onOpen?: () => void;
|
|
21
|
+
onOpened?: () => void;
|
|
22
|
+
onClose?: () => void;
|
|
23
|
+
onClosed?: () => void;
|
|
24
|
+
onState?: (state: UseTransitionState) => void;
|
|
25
|
+
};
|
|
26
|
+
declare const useTransition: ({ open, ...props }: UseTransitionProps) => {
|
|
27
|
+
exited: boolean;
|
|
28
|
+
props: {
|
|
29
|
+
id: string;
|
|
30
|
+
'data-transition': string;
|
|
31
|
+
'data-transition-state': string;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export { useTransition as default };
|
|
36
|
+
export type { UseTransitionProps, UseTransitionState, UseTransitionVariant, UseTransitionVariantTypes };
|