@dotss/ui 1.7.1 → 1.8.0
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/Button/Button.cjs +10 -8
- package/Button/Button.d.ts +1 -0
- package/Button/Button.es.js +28 -22
- package/Button/Button.stories.d.ts +1 -0
- package/CHANGELOG.md +12 -0
- package/Icon/Icon.cjs +5 -3
- package/Icon/Icon.es.js +10 -8
- package/hooks/interactions/useCollapse/useCollapse.cjs +1 -1
- package/hooks/interactions/useCollapse/useCollapse.es.js +28 -29
- package/package.json +1 -1
package/Button/Button.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("@emotion/react/jsx-runtime"),M=require("react"),j=require("../Box/Box.cjs"),E=require("../CircularProgressIndicator/CircularProgressIndicator.cjs"),T=require("../hooks/useCheckHoverPossible/useCheckHoverPossible.cjs"),F=require("../utils/getIconLabel/getIconLabel.cjs"),V=require("@emotion/styled"),a=require("../utils/getContrastingTextColor/getContrastingTextColor.cjs"),D=p=>p&&p.__esModule?p:{default:p},G=D(V),J=G.default.button`
|
|
2
2
|
display: inline-flex;
|
|
3
3
|
align-items: center;
|
|
4
4
|
justify-content: center;
|
|
@@ -7,19 +7,21 @@
|
|
|
7
7
|
color: inherit;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
${({theme:{palette:{brand:
|
|
10
|
+
${({theme:{palette:{brand:p,grey:e}},variant:t,color:u})=>{let l={backgroundColor:p.primary.main,color:a.default(p.primary.main,[e.white,e[100]])};return t==="filled"&&u==="secondary"&&(l={backgroundColor:p.secondary,color:a.default(p.secondary,[e.white,e[100]])}),t==="filled"&&u==="tertiary"&&(l={backgroundColor:p.tertiary,color:a.default(p.tertiary,[e.white,e[100]])}),t==="outlined"&&(l={borderColor:e[50],backgroundColor:e.white,color:a.default(e.white,[e.white,e[100]])}),t==="text"&&u==="primary"&&(l={backgroundColor:"transparent",color:a.default("transparent",[e.white,e[100]])}),t==="text"&&u==="secondary"&&(l={backgroundColor:"transparent",color:e[70]}),l}};
|
|
11
11
|
|
|
12
|
-
${({theme:{spacing:
|
|
12
|
+
${({theme:{spacing:p,typography:e},variant:t,size:u,startAdornment:l,endAdornment:o,iconOnly:f})=>{let r={gap:p.content(1),padding:10,borderRadius:8,fontSize:e.b4M.size,fontWeight:e.b4M.weight,lineHeight:e.b4M.lineHeight,letterSpacing:e.b4M.letterSpacing,"& svg":{width:20,height:20}};if(u==="2xLarge"){const{h0B:i}=e;let x="26px 24px";l&&(x=t==="text"?"26px 16px 26px 12px":"26px 36px 26px 24px"),o&&(x=t==="text"?"26px 12px 26px 16px":"26px 24px 26px 36px"),l&&o&&(x=t==="text"?"26px 12px":"26px 24px"),f&&(x="26px 25px"),r={gap:p.content(3),maxHeight:100,padding:x,borderRadius:20,fontSize:i.size,fontWeight:i.weight,lineHeight:i.lineHeight,letterSpacing:i.letterSpacing,"& svg":{width:48,height:48}}}if(u==="xLarge"){const{h4B:i}=e;let x="16px 12px";l&&(x=t==="text"?"16px 8px 16px 4px":"16px 16px 16px 12px"),o&&(x=t==="text"?"16px 4px 16px 8px":"16px 12px 16px 16px"),l&&o&&(x=t==="text"?"16px 4px":"16px 12px"),f&&(x="16px 15px"),r={gap:p.content(2),maxHeight:56,padding:x,borderRadius:12,fontSize:i.size,fontWeight:i.weight,lineHeight:i.lineHeight,letterSpacing:i.letterSpacing,"& svg":{width:24,height:24}}}if(u==="large"){const{b2M:i}=e;let x="12px 8px";l&&(x=t==="text"?"12px 8px 12px 4px":"12px 12px 12px 8px"),o&&(x=t==="text"?"12px 4px 12px 8px":"12px 8px 12px 12px"),l&&o&&(x=t==="text"?"12px 4px":"12px 8px"),f&&(x="12px 11px"),r={gap:6,maxHeight:48,padding:x,borderRadius:10,fontSize:i.size,fontWeight:i.weight,lineHeight:i.lineHeight,letterSpacing:i.letterSpacing,"& svg":{width:24,height:24}}}if(u==="medium"){const{b4M:i}=e;let x="10px 8px";l&&(x=t==="text"?"10px 8px 10px 4px":"10px 10px 10px 8px"),o&&(x=t==="text"?"10px 4px 10px 8px":"10px 8px 10px 10px"),l&&o&&(x=t==="text"?"10px 4px":"10px 8px"),f&&(x="10px 9px"),r={gap:p.content(1),maxHeight:40,padding:x,borderRadius:8,fontSize:i.size,fontWeight:i.weight,lineHeight:i.lineHeight,letterSpacing:i.letterSpacing,"& svg":{width:20,height:20}}}if(u==="small"){const{c3M:i}=e;let x="8px 6px";l&&(x=t==="text"?"8px 8px 8px 4px":"8px 8px 8px 6px"),o&&(x=t==="text"?"8px 4px 8px 8px":"8px 6px 8px 8px"),l&&o&&(x=t==="text"?"8px 6px":"8px 4px"),f&&(x="8px 7px"),r={gap:p.content(1),maxHeight:32,padding:x,borderRadius:6,fontSize:i.size,fontWeight:i.weight,lineHeight:i.lineHeight,letterSpacing:i.letterSpacing,"& svg":{width:16,height:16}}}if(u==="xSmall"){const{c3M:i}=e;let x="4px 6px";l&&(x=t==="text"?"4px 8px 4px 4px":"4px 8px 4px 6px"),o&&(x=t==="text"?"4px 4px 4px 8px":"4px 6px 4px 8px"),l&&o&&(x=t==="text"?"4px":"4px 6px"),f&&(x="4px 3px"),f?r={gap:p.content(1),maxHeight:24,width:24,height:24,borderRadius:6,fontSize:i.size,fontWeight:i.weight,lineHeight:i.lineHeight,letterSpacing:i.letterSpacing,"& svg":{width:16,height:16}}:r={gap:p.content(1),maxHeight:24,padding:x,borderRadius:6,fontSize:i.size,fontWeight:i.weight,lineHeight:i.lineHeight,letterSpacing:i.letterSpacing,"& svg":{width:16,height:16}}}return t==="text"&&u==="xLarge"&&(r={...r,borderWidth:1.5}),r}};
|
|
13
13
|
|
|
14
|
-
${({rounded:
|
|
14
|
+
${({rounded:p})=>p?{}:{borderRadius:"unset"}}
|
|
15
15
|
|
|
16
|
-
${({
|
|
16
|
+
${({underlined:p})=>p?{textDecoration:"underline"}:{}}
|
|
17
|
+
|
|
18
|
+
${({theme:{palette:{brand:p,grey:e}},variant:t,color:u,isHoverPossible:l})=>{let o={'&:active:not([aria-disabled="true"])':{backgroundColor:p.primary.press},...l?{'&:hover:not([aria-disabled="true"])':{backgroundColor:p.primary.press}}:{}};return t==="filled"&&u==="secondary"&&(o={'&:active:not([aria-disabled="true"])':{backgroundColor:e[100]},...l?{'&:hover:not([aria-disabled="true"])':{backgroundColor:e[100]}}:{}}),t==="filled"&&u==="tertiary"&&(o={'&:active:not([aria-disabled="true"])':{backgroundColor:e[70]},...l?{'&:hover:not([aria-disabled="true"])':{backgroundColor:e[70]}}:{}}),(t==="outlined"||t==="text")&&(o={'&:active:not([aria-disabled="true"])':{backgroundColor:e[10]},...l?{'&:hover:not([aria-disabled="true"])':{backgroundColor:e[10]}}:{}}),o}}
|
|
17
19
|
|
|
18
20
|
&[aria-disabled="true"], &[aria-busy="true"] {
|
|
19
21
|
cursor: not-allowed;
|
|
20
22
|
|
|
21
|
-
${({theme:{palette:{brand:
|
|
23
|
+
${({theme:{palette:{brand:p,grey:e}},variant:t,color:u})=>{let l={backgroundColor:p.primary.disable,color:a.default(p.primary.disable,[e[30],e.white])};return t==="filled"&&u==="secondary"&&(l={backgroundColor:e[10],color:a.default(e[10],[e[30],e.white])}),t==="outlined"&&(l={borderColor:e[30],backgroundColor:e[10],color:a.default(e[30],[e[30],e.white])}),t==="text"&&(l={color:a.default(e[30],[e[30],e.white])}),l}};
|
|
22
24
|
}
|
|
23
25
|
|
|
24
|
-
${({fullWidth:
|
|
25
|
-
`,P=M.forwardRef(function({tag:e="button",children:t,variant:u="filled",size:
|
|
26
|
+
${({fullWidth:p})=>p?{width:"100%"}:null};
|
|
27
|
+
`,P=M.forwardRef(function({tag:e="button",children:t,variant:u="filled",size:l="medium",color:o="primary",startAdornment:f,endAdornment:r,iconOnly:i,fullWidth:x,inlineCSS:z,rounded:W=!0,underlined:q=!1,disabled:w,onClick:S,onKeyDown:H,loading:c,loadingPosition:R,loadingIndicator:h,...C},$){const{isHoverPossible:m}=T.default(),_=()=>{if(!i)return;if(C["aria-label"])return C["aria-label"];const d=f||r||t;if(M.isValidElement(d))return F.default(d.props.name)},B=d=>{w||c||S==null||S(d)},L=d=>{w||c||H==null||H(d)},N=!!c,k=h?s.jsx(s.Fragment,{children:h}):s.jsx(E.default,{loop:!0});let g=f,b=i?null:t,n=r;return N&&(R?R==="start"?(g=s.jsx(j.default,{children:k}),n=h?null:r,b=i||h?null:t):(g=h?null:f,n=s.jsx(j.default,{children:k}),b=i||h?null:t):(g=null,n=null,b=i?null:k)),s.jsxs(J,{as:e,ref:$,type:e==="button"?"button":void 0,variant:u,size:l,color:o,fullWidth:x,rounded:W,underlined:q,startAdornment:f,endAdornment:r,iconOnly:i,isHoverPossible:m,"aria-disabled":w||c,"aria-busy":c,"aria-label":_(),onClick:B,onKeyDown:L,...C,css:z,children:[g,b,n,c&&s.jsx(j.default,{visuallyHidden:!0,role:"status","aria-live":"polite","aria-atomic":"true",children:typeof t=="string"?`${t} 중`:"로딩 중"})]})});exports.default=P;
|
package/Button/Button.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export type ButtonProps<T extends ElementType = 'button'> = PolymorphicComponent
|
|
|
11
11
|
iconOnly?: boolean;
|
|
12
12
|
fullWidth?: boolean;
|
|
13
13
|
rounded?: boolean;
|
|
14
|
+
underlined?: boolean;
|
|
14
15
|
loading?: boolean;
|
|
15
16
|
loadingPosition?: 'start' | 'end';
|
|
16
17
|
loadingIndicator?: ReactNode;
|
package/Button/Button.es.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { forwardRef as
|
|
1
|
+
import { jsxs as F, jsx as g, Fragment as T } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { forwardRef as V, isValidElement as q } from "react";
|
|
3
3
|
import k from "../Box/Box.es.js";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
4
|
+
import G from "../CircularProgressIndicator/CircularProgressIndicator.es.js";
|
|
5
|
+
import J from "../hooks/useCheckHoverPossible/useCheckHoverPossible.es.js";
|
|
6
|
+
import Q from "../utils/getIconLabel/getIconLabel.es.js";
|
|
7
|
+
import U from "@emotion/styled";
|
|
8
8
|
import h from "../utils/getContrastingTextColor/getContrastingTextColor.es.js";
|
|
9
|
-
const
|
|
9
|
+
const X = U.button`
|
|
10
10
|
display: inline-flex;
|
|
11
11
|
align-items: center;
|
|
12
12
|
justify-content: center;
|
|
@@ -198,6 +198,10 @@ const U = Q.button`
|
|
|
198
198
|
borderRadius: "unset"
|
|
199
199
|
}}
|
|
200
200
|
|
|
201
|
+
${({ underlined: l }) => l ? {
|
|
202
|
+
textDecoration: "underline"
|
|
203
|
+
} : {}}
|
|
204
|
+
|
|
201
205
|
${({
|
|
202
206
|
theme: {
|
|
203
207
|
palette: { brand: l, grey: e }
|
|
@@ -252,7 +256,7 @@ const U = Q.button`
|
|
|
252
256
|
${({ fullWidth: l }) => l ? {
|
|
253
257
|
width: "100%"
|
|
254
258
|
} : null};
|
|
255
|
-
`,
|
|
259
|
+
`, O = V(function({
|
|
256
260
|
tag: e = "button",
|
|
257
261
|
children: t,
|
|
258
262
|
variant: o = "filled",
|
|
@@ -264,6 +268,7 @@ const U = Q.button`
|
|
|
264
268
|
fullWidth: x,
|
|
265
269
|
inlineCSS: R,
|
|
266
270
|
rounded: W = !0,
|
|
271
|
+
underlined: M = !1,
|
|
267
272
|
disabled: w,
|
|
268
273
|
onClick: S,
|
|
269
274
|
onKeyDown: H,
|
|
@@ -271,39 +276,40 @@ const U = Q.button`
|
|
|
271
276
|
loadingPosition: z,
|
|
272
277
|
loadingIndicator: c,
|
|
273
278
|
...m
|
|
274
|
-
},
|
|
275
|
-
const { isHoverPossible: j } =
|
|
279
|
+
}, $) {
|
|
280
|
+
const { isHoverPossible: j } = J(), B = () => {
|
|
276
281
|
if (!i) return;
|
|
277
282
|
if (m["aria-label"]) return m["aria-label"];
|
|
278
283
|
const a = u || f || t;
|
|
279
|
-
if (
|
|
280
|
-
return
|
|
281
|
-
}, B = (a) => {
|
|
282
|
-
w || s || S == null || S(a);
|
|
284
|
+
if (q(a))
|
|
285
|
+
return Q(a.props.name);
|
|
283
286
|
}, L = (a) => {
|
|
287
|
+
w || s || S == null || S(a);
|
|
288
|
+
}, N = (a) => {
|
|
284
289
|
w || s || H == null || H(a);
|
|
285
|
-
},
|
|
290
|
+
}, E = !!s, C = c ? /* @__PURE__ */ g(T, { children: c }) : /* @__PURE__ */ g(G, { loop: !0 });
|
|
286
291
|
let d = u, b = i ? null : t, n = f;
|
|
287
|
-
return
|
|
288
|
-
|
|
292
|
+
return E && (z ? z === "start" ? (d = /* @__PURE__ */ g(k, { children: C }), n = c ? null : f, b = i || c ? null : t) : (d = c ? null : u, n = /* @__PURE__ */ g(k, { children: C }), b = i || c ? null : t) : (d = null, n = null, b = i ? null : C)), /* @__PURE__ */ F(
|
|
293
|
+
X,
|
|
289
294
|
{
|
|
290
295
|
as: e,
|
|
291
|
-
ref:
|
|
296
|
+
ref: $,
|
|
292
297
|
type: e === "button" ? "button" : void 0,
|
|
293
298
|
variant: o,
|
|
294
299
|
size: p,
|
|
295
300
|
color: r,
|
|
296
301
|
fullWidth: x,
|
|
297
302
|
rounded: W,
|
|
303
|
+
underlined: M,
|
|
298
304
|
startAdornment: u,
|
|
299
305
|
endAdornment: f,
|
|
300
306
|
iconOnly: i,
|
|
301
307
|
isHoverPossible: j,
|
|
302
308
|
"aria-disabled": w || s,
|
|
303
309
|
"aria-busy": s,
|
|
304
|
-
"aria-label":
|
|
305
|
-
onClick:
|
|
306
|
-
onKeyDown:
|
|
310
|
+
"aria-label": B(),
|
|
311
|
+
onClick: L,
|
|
312
|
+
onKeyDown: N,
|
|
307
313
|
...m,
|
|
308
314
|
css: R,
|
|
309
315
|
children: [
|
|
@@ -317,5 +323,5 @@ const U = Q.button`
|
|
|
317
323
|
);
|
|
318
324
|
});
|
|
319
325
|
export {
|
|
320
|
-
|
|
326
|
+
O as default
|
|
321
327
|
};
|
|
@@ -30,6 +30,7 @@ type Story = StoryObj<typeof meta>;
|
|
|
30
30
|
export declare const Filled: Story;
|
|
31
31
|
export declare const Outlined: Story;
|
|
32
32
|
export declare const Text: Story;
|
|
33
|
+
export declare const Underlined: Story;
|
|
33
34
|
export declare const FullWidth: Story;
|
|
34
35
|
export declare const StartAdornment: Story;
|
|
35
36
|
export declare const EndAdornment: Story;
|
package/CHANGELOG.md
CHANGED
package/Icon/Icon.cjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const h=require("@emotion/react/jsx-runtime"),t=require("react"),y=require("../resources/tictoccroc/icons/index.ts-B8qwAe9y.cjs"),S=require("@emotion/styled"),b=require("../utils/getPaletteColor/getPaletteColor.cjs"),I=r=>r&&r.__esModule?r:{default:r},w=I(S),$=r=>w.default(r)`
|
|
2
|
+
flex-shrink: 0;
|
|
3
|
+
|
|
2
4
|
${({size:o,width:s,height:a})=>{let n={width:s,height:a};switch(o){case"large":n={width:32,height:32};break;case"medium":n={width:24,height:24};break;case"small":n={width:20,height:20};break;case"xSmall":n={width:16,height:16};break}return n}};
|
|
3
5
|
|
|
4
|
-
color: ${({theme:o,color:s="grey.100"})=>
|
|
5
|
-
`,q=t.forwardRef(function({id:o,name:s,width:a=24,height:n=24,size:i,color:p="grey.100",inlineCSS:d,...f},m){const
|
|
6
|
+
color: ${({theme:o,color:s="grey.100"})=>b.default(s,{theme:o})};
|
|
7
|
+
`,q=t.forwardRef(function({id:o,name:s,width:a=24,height:n=24,size:i,color:p="grey.100",inlineCSS:d,...f},m){const k=$(_=>t.Children.map(y.SvgIcons[s](),c=>t.isValidElement(c)?t.cloneElement(c,{focusable:!1,"aria-hidden":!0,...c.props,..._,children:t.Children.map(c.props.children,e=>{var l;if(!t.isValidElement(e))return null;if(e.type==="mask"){const u=`${e.props.id}-${o||0}`;return t.cloneElement(e,{...e.props,id:u})}return e.type==="path"&&!!e.props.mask?t.cloneElement(e,{...e.props,mask:`${(l=e.props.mask)==null?void 0:l.replace(/\)$/,`-${o||0})`)}`}):e})}):null));return h.jsx(k,{ref:m,width:a,height:n,size:i,color:p,...f,css:d})});exports.default=q;
|
package/Icon/Icon.es.js
CHANGED
|
@@ -4,6 +4,8 @@ import { S as $ } from "../resources/tictoccroc/icons/index.ts-B4Sh1uNq.js";
|
|
|
4
4
|
import b from "@emotion/styled";
|
|
5
5
|
import x from "../utils/getPaletteColor/getPaletteColor.es.js";
|
|
6
6
|
const g = (p) => b(p)`
|
|
7
|
+
flex-shrink: 0;
|
|
8
|
+
|
|
7
9
|
${({ size: t, width: o, height: a }) => {
|
|
8
10
|
let r = {
|
|
9
11
|
width: o,
|
|
@@ -41,12 +43,12 @@ const g = (p) => b(p)`
|
|
|
41
43
|
color: ${({ theme: t, color: o = "grey.100" }) => x(o, {
|
|
42
44
|
theme: t
|
|
43
45
|
})};
|
|
44
|
-
`, V = y(function({ id: t, name: o, width: a = 24, height: r = 24, size:
|
|
45
|
-
const
|
|
46
|
+
`, V = y(function({ id: t, name: o, width: a = 24, height: r = 24, size: l, color: u = "grey.100", inlineCSS: k, ...h }, I) {
|
|
47
|
+
const S = g((d) => f.map($[o](), (n) => i(n) ? s(n, {
|
|
46
48
|
focusable: !1,
|
|
47
49
|
"aria-hidden": !0,
|
|
48
50
|
...n.props,
|
|
49
|
-
...
|
|
51
|
+
...d,
|
|
50
52
|
children: f.map(n.props.children, (e) => {
|
|
51
53
|
var c;
|
|
52
54
|
if (!i(e))
|
|
@@ -65,14 +67,14 @@ const g = (p) => b(p)`
|
|
|
65
67
|
})
|
|
66
68
|
}) : null));
|
|
67
69
|
return /* @__PURE__ */ w(
|
|
68
|
-
|
|
70
|
+
S,
|
|
69
71
|
{
|
|
70
|
-
ref:
|
|
72
|
+
ref: I,
|
|
71
73
|
width: a,
|
|
72
74
|
height: r,
|
|
73
|
-
size:
|
|
74
|
-
color:
|
|
75
|
-
...
|
|
75
|
+
size: l,
|
|
76
|
+
color: u,
|
|
77
|
+
...h,
|
|
76
78
|
css: k
|
|
77
79
|
}
|
|
78
80
|
);
|
|
@@ -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
|
};
|