@dotss/ui 1.7.1 → 1.7.2
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/CHANGELOG.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("react"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("react"),P=require("../../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.cjs"),q=require("../../usePrefersReducedMotion/usePrefersReducedMotion.cjs");function y({isCollapsed:t=!0,duration:f=200,delay:o=0,easing:s="ease-in-out",onTransitionStart:i,onTransitionEnd:h}={}){const{prefersReducedMotion:p}=q.default(),l=r.useRef(null),e=r.useRef(null),u=r.useRef(i),c=r.useRef(h),a=r.useRef(t);u.current=i,c.current=h;const[g,v]=r.useState(t?"0px":"auto");return P.default(()=>{var m;if(a.current===t)return;a.current=t;const n=l.current;if(!n)return;e.current&&(e.current.cancel(),e.current=null);const R=n.scrollHeight,H=t?[{height:`${R}px`},{height:"0px"}]:[{height:"0px"},{height:`${R}px`}],M=t?"0px":"auto";return(m=u.current)==null||m.call(u),e.current=n.animate(H,{duration:p?0:f,easing:s,delay:o,fill:"forwards"}),e.current.onfinish=()=>{var x,d;(x=e.current)==null||x.commitStyles(),v(M),(d=c.current)==null||d.call(c),e.current=null},()=>{e.current&&(e.current.cancel(),e.current=null)}},[t,f,o,s]),{targetRef:l,isCollapsed:t,height:g,style:{height:g,overflow:"hidden"},ariaProps:{"aria-hidden":t}}}exports.default=y;
|
|
@@ -1,51 +1,50 @@
|
|
|
1
|
-
import { useRef as
|
|
2
|
-
import
|
|
1
|
+
import { useRef as t, useState as y } from "react";
|
|
2
|
+
import M from "../../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.es.js";
|
|
3
3
|
import $ from "../../usePrefersReducedMotion/usePrefersReducedMotion.es.js";
|
|
4
|
-
function
|
|
5
|
-
isCollapsed:
|
|
4
|
+
function d({
|
|
5
|
+
isCollapsed: r = !0,
|
|
6
6
|
duration: o = 200,
|
|
7
7
|
delay: f = 0,
|
|
8
|
-
easing:
|
|
9
|
-
onTransitionStart:
|
|
10
|
-
onTransitionEnd:
|
|
8
|
+
easing: h = "ease-in-out",
|
|
9
|
+
onTransitionStart: i,
|
|
10
|
+
onTransitionEnd: m
|
|
11
11
|
} = {}) {
|
|
12
|
-
const { prefersReducedMotion:
|
|
13
|
-
u.current =
|
|
14
|
-
const [
|
|
15
|
-
return
|
|
16
|
-
var
|
|
17
|
-
if (
|
|
18
|
-
m.current = !1;
|
|
12
|
+
const { prefersReducedMotion: R } = $(), s = t(null), e = t(null), u = t(i), c = t(m), g = t(r);
|
|
13
|
+
u.current = i, c.current = m;
|
|
14
|
+
const [l, P] = y(r ? "0px" : "auto");
|
|
15
|
+
return M(() => {
|
|
16
|
+
var x;
|
|
17
|
+
if (g.current === r)
|
|
19
18
|
return;
|
|
20
|
-
|
|
21
|
-
const n =
|
|
19
|
+
g.current = r;
|
|
20
|
+
const n = s.current;
|
|
22
21
|
if (!n) return;
|
|
23
22
|
e.current && (e.current.cancel(), e.current = null);
|
|
24
|
-
const
|
|
25
|
-
return (
|
|
26
|
-
duration:
|
|
27
|
-
easing:
|
|
23
|
+
const p = n.scrollHeight, v = r ? [{ height: `${p}px` }, { height: "0px" }] : [{ height: "0px" }, { height: `${p}px` }], w = r ? "0px" : "auto";
|
|
24
|
+
return (x = u.current) == null || x.call(u), e.current = n.animate(v, {
|
|
25
|
+
duration: R ? 0 : o,
|
|
26
|
+
easing: h,
|
|
28
27
|
delay: f,
|
|
29
28
|
fill: "forwards"
|
|
30
29
|
}), e.current.onfinish = () => {
|
|
31
|
-
var
|
|
32
|
-
(
|
|
30
|
+
var a, H;
|
|
31
|
+
(a = e.current) == null || a.commitStyles(), P(w), (H = c.current) == null || H.call(c), e.current = null;
|
|
33
32
|
}, () => {
|
|
34
33
|
e.current && (e.current.cancel(), e.current = null);
|
|
35
34
|
};
|
|
36
|
-
}, [
|
|
37
|
-
targetRef:
|
|
38
|
-
isCollapsed:
|
|
39
|
-
height:
|
|
35
|
+
}, [r, o, f, h]), {
|
|
36
|
+
targetRef: s,
|
|
37
|
+
isCollapsed: r,
|
|
38
|
+
height: l,
|
|
40
39
|
style: {
|
|
41
|
-
height:
|
|
40
|
+
height: l,
|
|
42
41
|
overflow: "hidden"
|
|
43
42
|
},
|
|
44
43
|
ariaProps: {
|
|
45
|
-
"aria-hidden":
|
|
44
|
+
"aria-hidden": r
|
|
46
45
|
}
|
|
47
46
|
};
|
|
48
47
|
}
|
|
49
48
|
export {
|
|
50
|
-
|
|
49
|
+
d as default
|
|
51
50
|
};
|