@xanui/core 1.0.11 → 1.0.13
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/cjs/Transition/index.js +1 -1
- package/cjs/Transition/index.js.map +2 -2
- package/cjs/css/index.js +1 -1
- package/cjs/css/index.js.map +3 -3
- package/cjs/useAnimation.js +1 -1
- package/cjs/useAnimation.js.map +2 -2
- package/esm/Transition/index.js +1 -1
- package/esm/Transition/index.js.map +2 -2
- package/esm/css/index.js +1 -1
- package/esm/css/index.js.map +3 -3
- package/esm/useAnimation.js +1 -1
- package/esm/useAnimation.js.map +2 -2
- package/package.json +2 -2
package/cjs/Transition/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";"use client";var z=Object.create;var f=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var K=Object.getPrototypeOf,Q=Object.prototype.hasOwnProperty;var U=(t,e)=>{for(var i in e)f(t,i,{get:e[i],enumerable:!0})},
|
|
1
|
+
"use strict";"use client";var z=Object.create;var f=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var K=Object.getPrototypeOf,Q=Object.prototype.hasOwnProperty;var U=(t,e)=>{for(var i in e)f(t,i,{get:e[i],enumerable:!0})},x=(t,e,i,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of G(e))!Q.call(t,o)&&o!==i&&f(t,o,{get:()=>e[o],enumerable:!(r=F(e,o))||r.enumerable});return t};var S=(t,e,i)=>(i=t!=null?z(K(t)):{},x(e||!t||!t.__esModule?f(i,"default",{value:t,enumerable:!0}):i,t)),X=t=>x(f({},"__esModule",{value:!0}),t);var te={};U(te,{default:()=>ee});module.exports=X(te);var n=S(require("react")),A=S(require("../Tag")),h=require("../useAnimation"),I=require("../css"),R=require("oncss"),Y=S(require("./variants"));const Z=({children:t,open:e,...i})=>{let{disableInitialTransition:r,variant:o,duration:g,delay:L,ease:k,easing:H,onOpen:E,onOpened:v,onClose:C,onClosed:O,onState:m}=i,M=k||h.animationEases[H]||h.animationEases.easeBounceOut;r??=!1,g??=400,o??="fade";const u=(0,n.useId)().replace(/:/g,""),[l,N]=(0,n.useState)(!1),[_,j]=(0,n.useState)(!1),[q,b]=(0,n.useState)(e?r?"opened":"open":"closed"),[B,J]=(0,n.useState)({height:0,width:0,rect:null});typeof o=="string"&&(o=Y[o](B));let c=o.from,d=o.to;const[P,y]=(0,n.useState)(e?d:c);(0,n.useEffect)(()=>{const s=document.querySelector(`.trans-${u}`);s&&(N(!0),J({height:s.clientHeight,width:s.clientWidth,rect:s.getBoundingClientRect()}),!r&&e&&y(c))},[]),(0,n.useEffect)(()=>{const s=document.querySelector(`.trans-${u}`);if(l&&s){let p=null,w=null;s.ontransitionstart=()=>{clearTimeout(p),p=setTimeout(()=>{const a=Array.from(s.classList).includes("trans-open");E&&a&&E(),C&&!a&&C(),m&&m(a?"open":"close"),b(a?"open":"close")},1)},s.ontransitionend=()=>{clearTimeout(w),w=setTimeout(()=>{const a=Array.from(s.classList).includes("trans-open");v&&a&&v(),O&&!a&&O(),m&&m(a?"opened":"closed"),b(a?"opened":"closed")},1)}}},[l]),(0,n.useEffect)(()=>{l&&(_?y(e?d:c):(j(!0),setTimeout(()=>{y(e?d:c)},50)))},[l,e,JSON.stringify(c),JSON.stringify(d)]);let $={};if(l){let s=` ${g}ms ${M} ${L||0}ms`;$={...P,transition:Object.keys(P||{}).map(p=>(0,R.formatCSSProp)(p)).join(s+", ")+s}}const V=(0,I.css)($);if(!t||Array.isArray(t))throw new Error("Invalid children in Transition");const D=n.Children.toArray(t).shift();let W=`${V.classname} trans-${u} trans-${e?"open":"close"} trans-state-${q}`;const T=(0,n.cloneElement)(D,{classNames:[W]});return l||!l&&r&&e?T:n.default.createElement(A.default,{height:0,overflow:"hidden"},T)};var ee=Z;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/Transition/index.tsx"],
|
|
4
|
-
"sourcesContent": ["'use client'\nimport React, { ReactElement, cloneElement, Children, useState, useEffect, useId } from 'react';\nimport Tag from '../Tag';\nimport { animationEases } from '../useAnimation';\nimport { css } from '../css';\nimport { formatCSSProp } from 'oncss';\nimport { CSSProps } from '../css/types';\nimport * as variants from './variants'\nexport type TransitionVariantTypes = keyof typeof variants\n\nexport type TransitionElementProps = {\n height: number;\n width: number;\n rect: DOMRect | null\n}\n\nexport type TransitionState = \"open\" | \"opened\" | \"close\" | \"closed\"\n\nexport type TransitionProps = {\n children: ReactElement;\n open: boolean;\n variant: {\n from: CSSProps;\n to: CSSProps;\n } | TransitionVariantTypes;\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 Transition = ({ children, open, ...props }: TransitionProps) => {\n let { disableInitialTransition, variant, duration, delay, ease, easing, onOpen, onOpened, onClose, onClosed, onState } = props as TransitionProps\n let _ease = ease || (animationEases as any)[easing as any] || animationEases.easeBounceOut\n disableInitialTransition ??= false\n duration ??= 400\n variant ??= \"fade\"\n\n const id = useId().
|
|
5
|
-
"mappings": "ukBAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,aAAAE,KAAA,eAAAC,EAAAH,IACA,IAAAI,EAAwF,oBACxFC,EAAgB,qBAChBC,EAA+B,2BAC/BC,EAAoB,kBACpBC,EAA8B,iBAE9BC,EAA0B,yBA8B1B,MAAMC,EAAa,CAAC,CAAE,SAAAC,EAAU,KAAAC,EAAM,GAAGC,CAAM,IAAuB,CAClE,GAAI,CAAE,yBAAAC,EAA0B,QAAAC,EAAS,SAAAC,EAAU,MAAAC,EAAO,KAAAC,EAAM,OAAAC,EAAQ,OAAAC,EAAQ,SAAAC,EAAU,QAAAC,EAAS,SAAAC,EAAU,QAAAC,CAAQ,EAAIX,EACrHY,EAAQP,GAAS,iBAAuBC,CAAa,GAAK,iBAAe,cAC7EL,IAA6B,GAC7BE,IAAa,IACbD,IAAY,OAEZ,MAAMW,KAAK,SAAM,EAAE,
|
|
4
|
+
"sourcesContent": ["'use client'\nimport React, { ReactElement, cloneElement, Children, useState, useEffect, useId } from 'react';\nimport Tag from '../Tag';\nimport { animationEases } from '../useAnimation';\nimport { css } from '../css';\nimport { formatCSSProp } from 'oncss';\nimport { CSSProps } from '../css/types';\nimport * as variants from './variants'\nexport type TransitionVariantTypes = keyof typeof variants\n\nexport type TransitionElementProps = {\n height: number;\n width: number;\n rect: DOMRect | null\n}\n\nexport type TransitionState = \"open\" | \"opened\" | \"close\" | \"closed\"\n\nexport type TransitionProps = {\n children: ReactElement;\n open: boolean;\n variant: {\n from: CSSProps;\n to: CSSProps;\n } | TransitionVariantTypes;\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 Transition = ({ children, open, ...props }: TransitionProps) => {\n let { disableInitialTransition, variant, duration, delay, ease, easing, onOpen, onOpened, onClose, onClosed, onState } = props as TransitionProps\n let _ease = ease || (animationEases as any)[easing as any] || animationEases.easeBounceOut\n disableInitialTransition ??= false\n duration ??= 400\n variant ??= \"fade\"\n\n const id = useId().replace(/:/g, \"\")\n const [rendered, setRendered] = useState(false)\n const [initial, setInitial] = useState(false)\n const [transitionState, setTransitionState] = useState<TransitionState>(open ? (disableInitialTransition ? \"opened\" : \"open\") : \"closed\")\n const [element, setElement] = useState<TransitionElementProps>({\n height: 0,\n width: 0,\n rect: null\n });\n\n if (typeof variant === 'string') {\n variant = (variants as any)[variant](element)\n }\n\n let from = (variant as any).from\n let to = (variant as any).to\n\n const [_css, setCss] = useState(open ? to : from)\n\n useEffect(() => {\n const ele: HTMLElement = document.querySelector(`.trans-${id}`) as any\n if (ele) {\n setRendered(true)\n setElement({\n height: ele.clientHeight,\n width: ele.clientWidth,\n rect: ele.getBoundingClientRect()\n })\n if (!disableInitialTransition && open) {\n setCss(from)\n }\n }\n }, [])\n\n useEffect(() => {\n const ele: HTMLElement = document.querySelector(`.trans-${id}`) as any\n if (rendered && ele) {\n let stimer: any = null\n let etimer: any = null\n ele.ontransitionstart = () => {\n clearTimeout(stimer)\n stimer = setTimeout(() => {\n const isOpen = Array.from(ele.classList).includes(\"trans-open\");\n (onOpen && isOpen) && onOpen();\n (onClose && !isOpen) && onClose()\n onState && onState(isOpen ? \"open\" : \"close\")\n setTransitionState(isOpen ? \"open\" : \"close\")\n }, 1)\n }\n ele.ontransitionend = () => {\n clearTimeout(etimer)\n etimer = setTimeout(() => {\n const isOpen = Array.from(ele.classList).includes(\"trans-open\");\n (onOpened && isOpen) && onOpened();\n (onClosed && !isOpen) && onClosed();\n onState && onState(isOpen ? \"opened\" : \"closed\")\n setTransitionState(isOpen ? \"opened\" : \"closed\")\n }, 1)\n }\n }\n }, [rendered])\n\n useEffect(() => {\n if (rendered) {\n if (!initial) {\n setInitial(true)\n setTimeout(() => {\n setCss(open ? to : from)\n }, 50);\n } else {\n setCss(open ? to : from)\n }\n }\n }, [rendered, open, JSON.stringify(from), JSON.stringify(to)])\n\n let _: any = {}\n if (rendered) {\n let trans = ` ${duration}ms ${_ease} ${delay || 0}ms`\n _ = {\n ..._css,\n transition: Object.keys(_css || {}).map(k => formatCSSProp(k)).join(trans + \", \") + trans,\n }\n }\n\n const cls = css(_)\n if (!children || Array.isArray(children)) throw new Error(\"Invalid children in Transition\")\n const first: any = Children.toArray(children).shift();\n let classname = `${cls.classname} trans-${id} trans-${(open ? \"open\" : \"close\")} trans-state-${transitionState}`\n const child = cloneElement(first, { classNames: [classname] })\n if (rendered) return child\n if (!rendered && disableInitialTransition && open) return child\n\n return (\n <Tag\n height={0}\n overflow=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CAAC,KACjD0B,EAAI,CACA,GAAGN,EACH,WAAY,OAAO,KAAKA,GAAQ,CAAC,CAAC,EAAE,IAAIQ,MAAK,iBAAcA,CAAC,CAAC,EAAE,KAAKD,EAAQ,IAAI,EAAIA,CACxF,CACJ,CAEA,MAAME,KAAM,OAAIH,CAAC,EACjB,GAAI,CAAChC,GAAY,MAAM,QAAQA,CAAQ,EAAG,MAAM,IAAI,MAAM,gCAAgC,EAC1F,MAAMoC,EAAa,WAAS,QAAQpC,CAAQ,EAAE,MAAM,EACpD,IAAIqC,EAAY,GAAGF,EAAI,SAAS,UAAUpB,CAAE,UAAWd,EAAO,OAAS,OAAQ,gBAAgBmB,CAAe,GAC9G,MAAMkB,KAAQ,gBAAaF,EAAO,CAAE,WAAY,CAACC,CAAS,CAAE,CAAC,EAE7D,OADIrB,GACA,CAACA,GAAYb,GAA4BF,EAAaqC,EAGtD,EAAAC,QAAA,cAAC,EAAAC,QAAA,CACG,OAAQ,EACR,SAAS,UAERF,CACL,CAER,EAGA,IAAO/C,GAAQQ",
|
|
6
6
|
"names": ["Transition_exports", "__export", "Transition_default", "__toCommonJS", "import_react", "import_Tag", "import_useAnimation", "import_css", "import_oncss", "variants", "Transition", "children", "open", "props", "disableInitialTransition", "variant", "duration", "delay", "ease", "easing", "onOpen", "onOpened", "onClose", "onClosed", "onState", "_ease", "id", "rendered", "setRendered", "initial", "setInitial", "transitionState", "setTransitionState", "element", "setElement", "from", "to", "_css", "setCss", "ele", "stimer", "etimer", "isOpen", "_", "trans", "k", "cls", "first", "classname", "child", "React", "Tag"]
|
|
7
7
|
}
|
package/cjs/css/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var h=Object.create;var i=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var y=Object.getPrototypeOf,P=Object.prototype.hasOwnProperty;var C=(t,r)=>{for(var e in r)i(t,e,{get:r[e],enumerable:!0})},g=(t,r,e,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of x(r))!P.call(t,s)&&s!==e&&i(t,s,{get:()=>r[s],enumerable:!(a=M(r,s))||a.enumerable});return t};var u=(t,r,e)=>(e=t!=null?h(y(t)):{},g(r||!t||!t.__esModule?i(e,"default",{value:t,enumerable:!0}):e,t)),d=t=>g(i({},"__esModule",{value:!0}),t);var V={};C(V,{adjustColor:()=>F,adjustTextContrast:()=>I,alpha:()=>O,breakpoints:()=>f,css:()=>b,getProps:()=>l.default,getValue:()=>p.default});module.exports=d(V);var p=u(require("./getValue")),l=u(require("./getProps")),S=u(require("./aliases")),c=require("oncss");const f={xs:0,sm:600,md:900,lg:1200,xl:1536},b=(t,r)=>{const e={...r,breakpoints:f,aliases:S.default,getValue:(a,s,n,m)=>{if(r?.getValue){let o=r?.getValue(a,s,n,m);if(o)return o}return(0,p.default)(a,s,n)},getProps:(a,s,n,m)=>{if(r?.getProps){let o=r?.getProps(a,s,n,m);if(o)return o}return(0,l.default)(a,s,n)}};return(0,c.css)(t,e)},F=(t,r)=>{t=t.replace(/^#/,"");let e=parseInt(t.slice(0,2),16),a=parseInt(t.slice(2,4),16),s=parseInt(t.slice(4,6),16);return e=Math.floor(e*r),a=Math.floor(a*r),s=Math.floor(s*r),e=Math.min(255,Math.max(0,e)),a=Math.min(255,Math.max(0,a)),s=Math.min(255,Math.max(0,s)),`#${e.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}`},I=t=>{t=t.replace(/^#/,"");const r=parseInt(t.slice(0,2),16),e=parseInt(t.slice(2,4),16),a=parseInt(t.slice(4,6),16);return(.299*r+.587*e+.114*a)/255>.5?"#111111":"#FFFFFF"},O=(t,r=1)=>{if(typeof r!="number")return t;let e=r*100;if(!t.startsWith("#"))throw new Error("color must be hex");return(t+`0${Math.round(255/100*e).toString(16)}`.slice(-2)).toUpperCase()};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/cjs/css/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/css/index.ts"],
|
|
4
|
-
"sourcesContent": ["import getValue from \"./getValue\"\nimport getProps from \"./getProps\"\nimport aliases from \"./aliases\"\nimport { Aliases, BreakpointKeys, CSSOptionProps, CSSProps } from './types'\nimport { css as _css } from \"oncss\"\n\nexport {\n getValue,\n getProps\n}\n\nexport const breakpoints = {\n xs: 0,\n sm: 600,\n md: 900,\n lg: 1200,\n xl: 1536\n}\n\nexport const css = (props: CSSProps, options?: CSSOptionProps) => {\n const cssOptions: CSSOptionProps = {\n ...options,\n breakpoints,\n aliases,\n getValue: (p: any, v: any, _c: any,) => {\n if (options?.getValue) {\n let _val = options?.getValue(p, v, _c)\n if (_val) return _val\n }\n return getValue(p, v, _c)\n },\n getProps: (p: any, v: any, _c: any) => {\n if (options?.getProps) {\n let _p = options?.getProps(p, v, _c)\n if (_p) return _p\n }\n return getProps(p, v, _c)\n },\n }\n return _css<Aliases, BreakpointKeys>(props, cssOptions)\n}\n\nexport const adjustColor = (hex: string, factor: number) => {\n\n hex = hex.replace(/^#/, '')\n\n let r = parseInt(hex.slice(0, 2), 16)\n let g = parseInt(hex.slice(2, 4), 16)\n let b = parseInt(hex.slice(4, 6), 16)\n\n r = Math.floor(r * factor)\n g = Math.floor(g * factor)\n b = Math.floor(b * factor)\n\n r = Math.min(255, Math.max(0, r))\n g = Math.min(255, Math.max(0, g))\n b = Math.min(255, Math.max(0, b))\n\n return `#${r.toString(16).padStart(2, '0')}${g.toString(16).padStart(2, '0')}${b.toString(16).padStart(2, '0')}`;\n}\n\nexport const adjustTextContrast = (color: string) => {\n color = color.replace(/^#/, '')\n const r = parseInt(color.slice(0, 2), 16);\n const g = parseInt(color.slice(2, 4), 16);\n const b = parseInt(color.slice(4, 6), 16);\n\n const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;\n return luminance > 0.5 ? '#111111' : '#FFFFFF';\n}\n\nexport const alpha = (color: string, opacity = 1) => {\n if (typeof opacity !== 'number') return color\n let _opacity = opacity * 100\n if (!color.startsWith(\"#\")) throw new Error(`color must be hex`)\n return (color + (`0${Math.round((255 / 100) * _opacity).toString(16)}`.slice(-2))).toUpperCase();\n};\n\n"],
|
|
5
|
-
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iBAAAE,EAAA,uBAAAC,EAAA,UAAAC,EAAA,gBAAAC,EAAA,QAAAC,EAAA,eAAAC,QAAA,eAAAC,UAAA,eAAAC,EAAAT,GAAA,IAAAU,EAAqB,yBACrBC,EAAqB,yBACrBC,EAAoB,wBAEpBC,EAA4B,iBAOrB,MAAMR,EAAc,CACvB,GAAI,EACJ,GAAI,IACJ,GAAI,IACJ,GAAI,KACJ,GAAI,IACR,EAEaC,EAAM,CAACQ,EAAiBC,IAA6B,CAC9D,MAAMC,EAA6B,CAC/B,GAAGD,EACH,YAAAV,EACA,UAAAY,QACA,SAAU,CAACC,EAAQC,EAAQC,
|
|
6
|
-
"names": ["css_exports", "__export", "adjustColor", "adjustTextContrast", "alpha", "breakpoints", "css", "getProps", "getValue", "__toCommonJS", "import_getValue", "import_getProps", "import_aliases", "import_oncss", "props", "options", "cssOptions", "aliases", "p", "v", "_c", "_val", "_p", "_css", "hex", "factor", "r", "g", "b", "color", "opacity", "_opacity"]
|
|
4
|
+
"sourcesContent": ["import getValue from \"./getValue\"\nimport getProps from \"./getProps\"\nimport aliases from \"./aliases\"\nimport { Aliases, BreakpointKeys, CSSOptionProps, CSSProps } from './types'\nimport { css as _css } from \"oncss\"\n\nexport {\n getValue,\n getProps\n}\n\nexport const breakpoints = {\n xs: 0,\n sm: 600,\n md: 900,\n lg: 1200,\n xl: 1536\n}\n\nexport const css = (props: CSSProps, options?: CSSOptionProps) => {\n const cssOptions: CSSOptionProps = {\n ...options,\n breakpoints,\n aliases,\n getValue: (p: any, v: any, _c: any, dept) => {\n if (options?.getValue) {\n let _val = options?.getValue(p, v, _c, dept)\n if (_val) return _val\n }\n return getValue(p, v, _c)\n },\n getProps: (p: any, v: any, _c: any, dept) => {\n if (options?.getProps) {\n let _p = options?.getProps(p, v, _c, dept)\n if (_p) return _p\n }\n return getProps(p, v, _c)\n },\n }\n return _css<Aliases, BreakpointKeys>(props, cssOptions)\n}\n\nexport const adjustColor = (hex: string, factor: number) => {\n\n hex = hex.replace(/^#/, '')\n\n let r = parseInt(hex.slice(0, 2), 16)\n let g = parseInt(hex.slice(2, 4), 16)\n let b = parseInt(hex.slice(4, 6), 16)\n\n r = Math.floor(r * factor)\n g = Math.floor(g * factor)\n b = Math.floor(b * factor)\n\n r = Math.min(255, Math.max(0, r))\n g = Math.min(255, Math.max(0, g))\n b = Math.min(255, Math.max(0, b))\n\n return `#${r.toString(16).padStart(2, '0')}${g.toString(16).padStart(2, '0')}${b.toString(16).padStart(2, '0')}`;\n}\n\nexport const adjustTextContrast = (color: string) => {\n color = color.replace(/^#/, '')\n const r = parseInt(color.slice(0, 2), 16);\n const g = parseInt(color.slice(2, 4), 16);\n const b = parseInt(color.slice(4, 6), 16);\n\n const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;\n return luminance > 0.5 ? '#111111' : '#FFFFFF';\n}\n\nexport const alpha = (color: string, opacity = 1) => {\n if (typeof opacity !== 'number') return color\n let _opacity = opacity * 100\n if (!color.startsWith(\"#\")) throw new Error(`color must be hex`)\n return (color + (`0${Math.round((255 / 100) * _opacity).toString(16)}`.slice(-2))).toUpperCase();\n};\n\n"],
|
|
5
|
+
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iBAAAE,EAAA,uBAAAC,EAAA,UAAAC,EAAA,gBAAAC,EAAA,QAAAC,EAAA,eAAAC,QAAA,eAAAC,UAAA,eAAAC,EAAAT,GAAA,IAAAU,EAAqB,yBACrBC,EAAqB,yBACrBC,EAAoB,wBAEpBC,EAA4B,iBAOrB,MAAMR,EAAc,CACvB,GAAI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,SAAS,EAAG,GAAG,CAAC,GAAGC,EAAE,SAAS,EAAE,EAAE,SAAS,EAAG,GAAG,CAAC,GAAGC,EAAE,SAAS,EAAE,EAAE,SAAS,EAAG,GAAG,CAAC,EAClH,EAEa1B,EAAsB2B,GAAkB,CACjDA,EAAQA,EAAM,QAAQ,KAAM,EAAE,EAC9B,MAAM,EAAI,SAASA,EAAM,MAAM,EAAG,CAAC,EAAG,EAAE,EAClCF,EAAI,SAASE,EAAM,MAAM,EAAG,CAAC,EAAG,EAAE,EAClCD,EAAI,SAASC,EAAM,MAAM,EAAG,CAAC,EAAG,EAAE,EAGxC,OADmB,KAAQ,EAAI,KAAQF,EAAI,KAAQC,GAAK,IACrC,GAAM,UAAY,SACzC,EAEazB,EAAQ,CAAC0B,EAAeC,EAAU,IAAM,CACjD,GAAI,OAAOA,GAAY,SAAU,OAAOD,EACxC,IAAIE,EAAWD,EAAU,IACzB,GAAI,CAACD,EAAM,WAAW,GAAG,EAAG,MAAM,IAAI,MAAM,mBAAmB,EAC/D,OAAQA,EAAS,IAAI,KAAK,MAAO,IAAM,IAAOE,CAAQ,EAAE,SAAS,EAAE,CAAC,GAAG,MAAM,EAAE,GAAI,YAAY,CACnG",
|
|
6
|
+
"names": ["css_exports", "__export", "adjustColor", "adjustTextContrast", "alpha", "breakpoints", "css", "getProps", "getValue", "__toCommonJS", "import_getValue", "import_getProps", "import_aliases", "import_oncss", "props", "options", "cssOptions", "aliases", "p", "v", "_c", "dept", "_val", "_p", "_css", "hex", "factor", "r", "g", "b", "color", "opacity", "_opacity"]
|
|
7
7
|
}
|
package/cjs/useAnimation.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var t=Object.defineProperty;var
|
|
1
|
+
"use strict";var t=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var d=(a,e)=>{for(var n in e)t(a,n,{get:e[n],enumerable:!0})},z=(a,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of l(e))!y.call(a,i)&&i!==n&&t(a,i,{get:()=>e[i],enumerable:!(o=f(e,i))||o.enumerable});return a};var S=a=>z(t({},"__esModule",{value:!0}),a);var x={};d(x,{animationEases:()=>s,default:()=>P});module.exports=S(x);var m=require("./css"),c=require("react");const s={easeInOut:"cubic-bezier(0.4, 0, 0.2, 1)",easeOut:"cubic-bezier(0.0, 0, 0.2, 1)",easeIn:"cubic-bezier(0.4, 0, 1, 1)",sharp:"cubic-bezier(0.4, 0, 0.6, 1)",linear:"cubic-bezier(0, 0, 1, 1)",easeBounceOut:"cubic-bezier(0.68, -0.55, 0.265, 1.55)"},O=({from:a,to:e,delay:n,ease:o,duration:i})=>{let u=n||0,b=i||600,p=o||"easeBounceOut";const r="anim"+(0,c.useId)().replace(/:/g,"");return(0,m.css)({animationName:r,animationDelay:u+"ms",animationDuration:b+"ms",animationTimingFunction:s[p]||s.easeBounceOut,[`@keyframes ${r}`]:{from:a,to:e}}).classname};var P=O;
|
|
2
2
|
//# sourceMappingURL=useAnimation.js.map
|
package/cjs/useAnimation.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/useAnimation.ts"],
|
|
4
|
-
"sourcesContent": ["import { css } from './css'\nimport { useId } from 'react'\nimport { CSSProps } from './css/types'\n\nexport 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 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 || \"easeBounceOut\"\n const id = \"anim\" + useId().
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oBAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GAAA,IAAAK,EAAoB,iBACpBC,EAAsB,iBAGf,MAAMJ,EAAiB,CAC1B,UAAW,+BACX,QAAS,+BACT,OAAQ,6BACR,MAAO,+BACP,OAAQ,2BACR,cAAe,wCACnB,EAUMK,EAAe,CAAC,CAAE,KAAAC,EAAM,GAAAC,EAAI,MAAAC,EAAO,KAAAC,EAAM,SAAAC,CAAS,IAAyB,CAC7E,IAAIC,EAASH,GAAS,EAClBI,EAAYF,GAAY,IACxBG,EAAQJ,GAAQ,gBACpB,MAAMK,EAAK,UAAS,SAAM,EAAE,
|
|
4
|
+
"sourcesContent": ["import { css } from './css'\nimport { useId } from 'react'\nimport { CSSProps } from './css/types'\n\nexport 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 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 || \"easeBounceOut\"\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.easeBounceOut,\n [`@keyframes ${id}`]: {\n from: from as any,\n to: to as any\n }\n })\n return anim.classname\n}\n\nexport default useAnimation"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oBAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GAAA,IAAAK,EAAoB,iBACpBC,EAAsB,iBAGf,MAAMJ,EAAiB,CAC1B,UAAW,+BACX,QAAS,+BACT,OAAQ,6BACR,MAAO,+BACP,OAAQ,2BACR,cAAe,wCACnB,EAUMK,EAAe,CAAC,CAAE,KAAAC,EAAM,GAAAC,EAAI,MAAAC,EAAO,KAAAC,EAAM,SAAAC,CAAS,IAAyB,CAC7E,IAAIC,EAASH,GAAS,EAClBI,EAAYF,GAAY,IACxBG,EAAQJ,GAAQ,gBACpB,MAAMK,EAAK,UAAS,SAAM,EAAE,QAAQ,KAAM,EAAE,EAW5C,SAVa,OAAI,CACb,cAAeA,EACf,eAAgBH,EAAS,KACzB,kBAAmBC,EAAY,KAC/B,wBAAyBZ,EAAea,CAAK,GAAKb,EAAe,cACjE,CAAC,cAAcc,CAAE,EAAE,EAAG,CAClB,KAAMR,EACN,GAAIC,CACR,CACJ,CAAC,EACW,SAChB,EAEA,IAAON,EAAQI",
|
|
6
6
|
"names": ["useAnimation_exports", "__export", "animationEases", "useAnimation_default", "__toCommonJS", "import_css", "import_react", "useAnimation", "from", "to", "delay", "ease", "duration", "_delay", "_duration", "_ease", "id"]
|
|
7
7
|
}
|
package/esm/Transition/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import B,{cloneElement as J,Children as V,useState as a,useEffect as y,useId as D}from"react";import W from"../Tag";import{animationEases as P}from"../useAnimation";import{css as z}from"../css";import{formatCSSProp as F}from"oncss";import*as G from"./variants";const K=({children:d,open:n,...$})=>{let{disableInitialTransition:r,variant:o,duration:T,delay:w,ease:
|
|
1
|
+
"use client";import B,{cloneElement as J,Children as V,useState as a,useEffect as y,useId as D}from"react";import W from"../Tag";import{animationEases as P}from"../useAnimation";import{css as z}from"../css";import{formatCSSProp as F}from"oncss";import*as G from"./variants";const K=({children:d,open:n,...$})=>{let{disableInitialTransition:r,variant:o,duration:T,delay:w,ease:x,easing:A,onOpen:S,onOpened:h,onClose:g,onClosed:E,onState:l}=$,I=x||P[A]||P.easeBounceOut;r??=!1,T??=400,o??="fade";const p=D().replace(/:/g,""),[s,R]=a(!1),[L,k]=a(!1),[H,v]=a(n?r?"opened":"open":"closed"),[M,N]=a({height:0,width:0,rect:null});typeof o=="string"&&(o=G[o](M));let i=o.from,c=o.to;const[C,f]=a(n?c:i);y(()=>{const e=document.querySelector(`.trans-${p}`);e&&(R(!0),N({height:e.clientHeight,width:e.clientWidth,rect:e.getBoundingClientRect()}),!r&&n&&f(i))},[]),y(()=>{const e=document.querySelector(`.trans-${p}`);if(s&&e){let m=null,b=null;e.ontransitionstart=()=>{clearTimeout(m),m=setTimeout(()=>{const t=Array.from(e.classList).includes("trans-open");S&&t&&S(),g&&!t&&g(),l&&l(t?"open":"close"),v(t?"open":"close")},1)},e.ontransitionend=()=>{clearTimeout(b),b=setTimeout(()=>{const t=Array.from(e.classList).includes("trans-open");h&&t&&h(),E&&!t&&E(),l&&l(t?"opened":"closed"),v(t?"opened":"closed")},1)}}},[s]),y(()=>{s&&(L?f(n?c:i):(k(!0),setTimeout(()=>{f(n?c:i)},50)))},[s,n,JSON.stringify(i),JSON.stringify(c)]);let O={};if(s){let e=` ${T}ms ${I} ${w||0}ms`;O={...C,transition:Object.keys(C||{}).map(m=>F(m)).join(e+", ")+e}}const _=z(O);if(!d||Array.isArray(d))throw new Error("Invalid children in Transition");const j=V.toArray(d).shift();let q=`${_.classname} trans-${p} trans-${n?"open":"close"} trans-state-${H}`;const u=J(j,{classNames:[q]});return s||!s&&r&&n?u:B.createElement(W,{height:0,overflow:"hidden"},u)};var se=K;export{se as default};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/Transition/index.tsx"],
|
|
4
|
-
"sourcesContent": ["'use client'\nimport React, { ReactElement, cloneElement, Children, useState, useEffect, useId } from 'react';\nimport Tag from '../Tag';\nimport { animationEases } from '../useAnimation';\nimport { css } from '../css';\nimport { formatCSSProp } from 'oncss';\nimport { CSSProps } from '../css/types';\nimport * as variants from './variants'\nexport type TransitionVariantTypes = keyof typeof variants\n\nexport type TransitionElementProps = {\n height: number;\n width: number;\n rect: DOMRect | null\n}\n\nexport type TransitionState = \"open\" | \"opened\" | \"close\" | \"closed\"\n\nexport type TransitionProps = {\n children: ReactElement;\n open: boolean;\n variant: {\n from: CSSProps;\n to: CSSProps;\n } | TransitionVariantTypes;\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 Transition = ({ children, open, ...props }: TransitionProps) => {\n let { disableInitialTransition, variant, duration, delay, ease, easing, onOpen, onOpened, onClose, onClosed, onState } = props as TransitionProps\n let _ease = ease || (animationEases as any)[easing as any] || animationEases.easeBounceOut\n disableInitialTransition ??= false\n duration ??= 400\n variant ??= \"fade\"\n\n const id = useId().
|
|
5
|
-
"mappings": "aACA,OAAOA,GAAuB,gBAAAC,EAAc,YAAAC,EAAU,YAAAC,EAAU,aAAAC,EAAW,SAAAC,MAAa,QACxF,OAAOC,MAAS,SAChB,OAAS,kBAAAC,MAAsB,kBAC/B,OAAS,OAAAC,MAAW,SACpB,OAAS,iBAAAC,MAAqB,QAE9B,UAAYC,MAAc,aA8B1B,MAAMC,EAAa,CAAC,CAAE,SAAAC,EAAU,KAAAC,EAAM,GAAGC,CAAM,IAAuB,CAClE,GAAI,CAAE,yBAAAC,EAA0B,QAAAC,EAAS,SAAAC,EAAU,MAAAC,EAAO,KAAAC,EAAM,OAAAC,EAAQ,OAAAC,EAAQ,SAAAC,EAAU,QAAAC,EAAS,SAAAC,EAAU,QAAAC,CAAQ,EAAIX,EACrHY,EAAQP,GAASZ,EAAuBa,CAAa,GAAKb,EAAe,cAC7EQ,IAA6B,GAC7BE,IAAa,IACbD,IAAY,OAEZ,MAAMW,EAAKtB,EAAM,EAAE,
|
|
4
|
+
"sourcesContent": ["'use client'\nimport React, { ReactElement, cloneElement, Children, useState, useEffect, useId } from 'react';\nimport Tag from '../Tag';\nimport { animationEases } from '../useAnimation';\nimport { css } from '../css';\nimport { formatCSSProp } from 'oncss';\nimport { CSSProps } from '../css/types';\nimport * as variants from './variants'\nexport type TransitionVariantTypes = keyof typeof variants\n\nexport type TransitionElementProps = {\n height: number;\n width: number;\n rect: DOMRect | null\n}\n\nexport type TransitionState = \"open\" | \"opened\" | \"close\" | \"closed\"\n\nexport type TransitionProps = {\n children: ReactElement;\n open: boolean;\n variant: {\n from: CSSProps;\n to: CSSProps;\n } | TransitionVariantTypes;\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 Transition = ({ children, open, ...props }: TransitionProps) => {\n let { disableInitialTransition, variant, duration, delay, ease, easing, onOpen, onOpened, onClose, onClosed, onState } = props as TransitionProps\n let _ease = ease || (animationEases as any)[easing as any] || animationEases.easeBounceOut\n disableInitialTransition ??= false\n duration ??= 400\n variant ??= \"fade\"\n\n const id = useId().replace(/:/g, \"\")\n const [rendered, setRendered] = useState(false)\n const [initial, setInitial] = useState(false)\n const [transitionState, setTransitionState] = useState<TransitionState>(open ? (disableInitialTransition ? \"opened\" : \"open\") : \"closed\")\n const [element, setElement] = useState<TransitionElementProps>({\n height: 0,\n width: 0,\n rect: null\n });\n\n if (typeof variant === 'string') {\n variant = (variants as any)[variant](element)\n }\n\n let from = (variant as any).from\n let to = (variant as any).to\n\n const [_css, setCss] = useState(open ? to : from)\n\n useEffect(() => {\n const ele: HTMLElement = document.querySelector(`.trans-${id}`) as any\n if (ele) {\n setRendered(true)\n setElement({\n height: ele.clientHeight,\n width: ele.clientWidth,\n rect: ele.getBoundingClientRect()\n })\n if (!disableInitialTransition && open) {\n setCss(from)\n }\n }\n }, [])\n\n useEffect(() => {\n const ele: HTMLElement = document.querySelector(`.trans-${id}`) as any\n if (rendered && ele) {\n let stimer: any = null\n let etimer: any = null\n ele.ontransitionstart = () => {\n clearTimeout(stimer)\n stimer = setTimeout(() => {\n const isOpen = Array.from(ele.classList).includes(\"trans-open\");\n (onOpen && isOpen) && onOpen();\n (onClose && !isOpen) && onClose()\n onState && onState(isOpen ? \"open\" : \"close\")\n setTransitionState(isOpen ? \"open\" : \"close\")\n }, 1)\n }\n ele.ontransitionend = () => {\n clearTimeout(etimer)\n etimer = setTimeout(() => {\n const isOpen = Array.from(ele.classList).includes(\"trans-open\");\n (onOpened && isOpen) && onOpened();\n (onClosed && !isOpen) && onClosed();\n onState && onState(isOpen ? \"opened\" : \"closed\")\n setTransitionState(isOpen ? \"opened\" : \"closed\")\n }, 1)\n }\n }\n }, [rendered])\n\n useEffect(() => {\n if (rendered) {\n if (!initial) {\n setInitial(true)\n setTimeout(() => {\n setCss(open ? to : from)\n }, 50);\n } else {\n setCss(open ? to : from)\n }\n }\n }, [rendered, open, JSON.stringify(from), JSON.stringify(to)])\n\n let _: any = {}\n if (rendered) {\n let trans = ` ${duration}ms ${_ease} ${delay || 0}ms`\n _ = {\n ..._css,\n transition: Object.keys(_css || {}).map(k => formatCSSProp(k)).join(trans + \", \") + trans,\n }\n }\n\n const cls = css(_)\n if (!children || Array.isArray(children)) throw new Error(\"Invalid children in Transition\")\n const first: any = Children.toArray(children).shift();\n let classname = `${cls.classname} trans-${id} trans-${(open ? \"open\" : \"close\")} trans-state-${transitionState}`\n const child = cloneElement(first, { classNames: [classname] })\n if (rendered) return child\n if (!rendered && disableInitialTransition && open) return child\n\n return (\n <Tag\n height={0}\n overflow=\"hidden\"\n >\n {child}\n </Tag>\n )\n}\n\n\nexport default Transition"],
|
|
5
|
+
"mappings": "aACA,OAAOA,GAAuB,gBAAAC,EAAc,YAAAC,EAAU,YAAAC,EAAU,aAAAC,EAAW,SAAAC,MAAa,QACxF,OAAOC,MAAS,SAChB,OAAS,kBAAAC,MAAsB,kBAC/B,OAAS,OAAAC,MAAW,SACpB,OAAS,iBAAAC,MAAqB,QAE9B,UAAYC,MAAc,aA8B1B,MAAMC,EAAa,CAAC,CAAE,SAAAC,EAAU,KAAAC,EAAM,GAAGC,CAAM,IAAuB,CAClE,GAAI,CAAE,yBAAAC,EAA0B,QAAAC,EAAS,SAAAC,EAAU,MAAAC,EAAO,KAAAC,EAAM,OAAAC,EAAQ,OAAAC,EAAQ,SAAAC,EAAU,QAAAC,EAAS,SAAAC,EAAU,QAAAC,CAAQ,EAAIX,EACrHY,EAAQP,GAASZ,EAAuBa,CAAa,GAAKb,EAAe,cAC7EQ,IAA6B,GAC7BE,IAAa,IACbD,IAAY,OAEZ,MAAMW,EAAKtB,EAAM,EAAE,QAAQ,KAAM,EAAE,EAC7B,CAACuB,EAAUC,CAAW,EAAI1B,EAAS,EAAK,EACxC,CAAC2B,EAASC,CAAU,EAAI5B,EAAS,EAAK,EACtC,CAAC6B,EAAiBC,CAAkB,EAAI9B,EAA0BU,EAAQE,EAA2B,SAAW,OAAU,QAAQ,EAClI,CAACmB,EAASC,CAAU,EAAIhC,EAAiC,CAC3D,OAAQ,EACR,MAAO,EACP,KAAM,IACV,CAAC,EAEG,OAAOa,GAAY,WACnBA,EAAWN,EAAiBM,CAAO,EAAEkB,CAAO,GAGhD,IAAIE,EAAQpB,EAAgB,KACxBqB,EAAMrB,EAAgB,GAE1B,KAAM,CAACsB,EAAMC,CAAM,EAAIpC,EAASU,EAAOwB,EAAKD,CAAI,EAEhDhC,EAAU,IAAM,CACZ,MAAMoC,EAAmB,SAAS,c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AC,EAE7D,IAAIO,EAAS,CAAC,EACd,GAAIhB,EAAU,CACV,IAAIiB,EAAQ,IAAI5B,CAAQ,MAAMS,CAAK,IAAIR,GAAS,CAAC,KACjD0B,EAAI,CACA,GAAGN,EACH,WAAY,OAAO,KAAKA,GAAQ,CAAC,CAAC,EAAE,IAAIQ,GAAKrC,EAAcqC,CAAC,CAAC,EAAE,KAAKD,EAAQ,IAAI,EAAIA,CACxF,CACJ,CAEA,MAAME,EAAMvC,EAAIoC,CAAC,EACjB,GAAI,CAAChC,GAAY,MAAM,QAAQA,CAAQ,EAAG,MAAM,IAAI,MAAM,gCAAgC,EAC1F,MAAMoC,EAAa9C,EAAS,QAAQU,CAAQ,EAAE,MAAM,EACpD,IAAIqC,EAAY,GAAGF,EAAI,SAAS,UAAUpB,CAAE,UAAWd,EAAO,OAAS,OAAQ,gBAAgBmB,CAAe,GAC9G,MAAMkB,EAAQjD,EAAa+C,EAAO,CAAE,WAAY,CAACC,CAAS,CAAE,CAAC,EAE7D,OADIrB,GACA,CAACA,GAAYb,GAA4BF,EAAaqC,EAGtDlD,EAAA,cAACM,EAAA,CACG,OAAQ,EACR,SAAS,UAER4C,CACL,CAER,EAGA,IAAOC,GAAQxC",
|
|
6
6
|
"names": ["React", "cloneElement", "Children", "useState", "useEffect", "useId", "Tag", "animationEases", "css", "formatCSSProp", "variants", "Transition", "children", "open", "props", "disableInitialTransition", "variant", "duration", "delay", "ease", "easing", "onOpen", "onOpened", "onClose", "onClosed", "onState", "_ease", "id", "rendered", "setRendered", "initial", "setInitial", "transitionState", "setTransitionState", "element", "setElement", "from", "to", "_css", "setCss", "ele", "stimer", "etimer", "isOpen", "_", "trans", "k", "cls", "first", "classname", "child", "Transition_default"]
|
|
7
7
|
}
|
package/esm/css/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import p from"./getValue";import l from"./getProps";import m from"./aliases";import{css as u}from"oncss";const g={xs:0,sm:600,md:900,lg:1200,xl:1536},d=(t,r)=>{const a={...r,breakpoints:g,aliases:m,getValue:(e,s,n,i)=>{if(r?.getValue){let o=r?.getValue(e,s,n,i);if(o)return o}return p(e,s,n)},getProps:(e,s,n,i)=>{if(r?.getProps){let o=r?.getProps(e,s,n,i);if(o)return o}return l(e,s,n)}};return u(t,a)},b=(t,r)=>{t=t.replace(/^#/,"");let a=parseInt(t.slice(0,2),16),e=parseInt(t.slice(2,4),16),s=parseInt(t.slice(4,6),16);return a=Math.floor(a*r),e=Math.floor(e*r),s=Math.floor(s*r),a=Math.min(255,Math.max(0,a)),e=Math.min(255,Math.max(0,e)),s=Math.min(255,Math.max(0,s)),`#${a.toString(16).padStart(2,"0")}${e.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}`},F=t=>{t=t.replace(/^#/,"");const r=parseInt(t.slice(0,2),16),a=parseInt(t.slice(2,4),16),e=parseInt(t.slice(4,6),16);return(.299*r+.587*a+.114*e)/255>.5?"#111111":"#FFFFFF"},I=(t,r=1)=>{if(typeof r!="number")return t;let a=r*100;if(!t.startsWith("#"))throw new Error("color must be hex");return(t+`0${Math.round(255/100*a).toString(16)}`.slice(-2)).toUpperCase()};export{b as adjustColor,F as adjustTextContrast,I as alpha,g as breakpoints,d as css,l as getProps,p as getValue};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/esm/css/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/css/index.ts"],
|
|
4
|
-
"sourcesContent": ["import getValue from \"./getValue\"\nimport getProps from \"./getProps\"\nimport aliases from \"./aliases\"\nimport { Aliases, BreakpointKeys, CSSOptionProps, CSSProps } from './types'\nimport { css as _css } from \"oncss\"\n\nexport {\n getValue,\n getProps\n}\n\nexport const breakpoints = {\n xs: 0,\n sm: 600,\n md: 900,\n lg: 1200,\n xl: 1536\n}\n\nexport const css = (props: CSSProps, options?: CSSOptionProps) => {\n const cssOptions: CSSOptionProps = {\n ...options,\n breakpoints,\n aliases,\n getValue: (p: any, v: any, _c: any,) => {\n if (options?.getValue) {\n let _val = options?.getValue(p, v, _c)\n if (_val) return _val\n }\n return getValue(p, v, _c)\n },\n getProps: (p: any, v: any, _c: any) => {\n if (options?.getProps) {\n let _p = options?.getProps(p, v, _c)\n if (_p) return _p\n }\n return getProps(p, v, _c)\n },\n }\n return _css<Aliases, BreakpointKeys>(props, cssOptions)\n}\n\nexport const adjustColor = (hex: string, factor: number) => {\n\n hex = hex.replace(/^#/, '')\n\n let r = parseInt(hex.slice(0, 2), 16)\n let g = parseInt(hex.slice(2, 4), 16)\n let b = parseInt(hex.slice(4, 6), 16)\n\n r = Math.floor(r * factor)\n g = Math.floor(g * factor)\n b = Math.floor(b * factor)\n\n r = Math.min(255, Math.max(0, r))\n g = Math.min(255, Math.max(0, g))\n b = Math.min(255, Math.max(0, b))\n\n return `#${r.toString(16).padStart(2, '0')}${g.toString(16).padStart(2, '0')}${b.toString(16).padStart(2, '0')}`;\n}\n\nexport const adjustTextContrast = (color: string) => {\n color = color.replace(/^#/, '')\n const r = parseInt(color.slice(0, 2), 16);\n const g = parseInt(color.slice(2, 4), 16);\n const b = parseInt(color.slice(4, 6), 16);\n\n const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;\n return luminance > 0.5 ? '#111111' : '#FFFFFF';\n}\n\nexport const alpha = (color: string, opacity = 1) => {\n if (typeof opacity !== 'number') return color\n let _opacity = opacity * 100\n if (!color.startsWith(\"#\")) throw new Error(`color must be hex`)\n return (color + (`0${Math.round((255 / 100) * _opacity).toString(16)}`.slice(-2))).toUpperCase();\n};\n\n"],
|
|
5
|
-
"mappings": "AAAA,OAAOA,MAAc,aACrB,OAAOC,MAAc,aACrB,OAAOC,MAAa,YAEpB,OAAS,OAAOC,MAAY,QAOrB,MAAMC,EAAc,CACvB,GAAI,EACJ,GAAI,IACJ,GAAI,IACJ,GAAI,KACJ,GAAI,IACR,EAEaC,EAAM,CAACC,EAAiBC,IAA6B,CAC9D,MAAMC,EAA6B,CAC/B,GAAGD,EACH,YAAAH,EACA,QAAAF,EACA,SAAU,CAACO,EAAQC,EAAQC,
|
|
6
|
-
"names": ["getValue", "getProps", "aliases", "_css", "breakpoints", "css", "props", "options", "cssOptions", "p", "v", "_c", "_val", "_p", "adjustColor", "hex", "factor", "r", "g", "b", "adjustTextContrast", "color", "alpha", "opacity", "_opacity"]
|
|
4
|
+
"sourcesContent": ["import getValue from \"./getValue\"\nimport getProps from \"./getProps\"\nimport aliases from \"./aliases\"\nimport { Aliases, BreakpointKeys, CSSOptionProps, CSSProps } from './types'\nimport { css as _css } from \"oncss\"\n\nexport {\n getValue,\n getProps\n}\n\nexport const breakpoints = {\n xs: 0,\n sm: 600,\n md: 900,\n lg: 1200,\n xl: 1536\n}\n\nexport const css = (props: CSSProps, options?: CSSOptionProps) => {\n const cssOptions: CSSOptionProps = {\n ...options,\n breakpoints,\n aliases,\n getValue: (p: any, v: any, _c: any, dept) => {\n if (options?.getValue) {\n let _val = options?.getValue(p, v, _c, dept)\n if (_val) return _val\n }\n return getValue(p, v, _c)\n },\n getProps: (p: any, v: any, _c: any, dept) => {\n if (options?.getProps) {\n let _p = options?.getProps(p, v, _c, dept)\n if (_p) return _p\n }\n return getProps(p, v, _c)\n },\n }\n return _css<Aliases, BreakpointKeys>(props, cssOptions)\n}\n\nexport const adjustColor = (hex: string, factor: number) => {\n\n hex = hex.replace(/^#/, '')\n\n let r = parseInt(hex.slice(0, 2), 16)\n let g = parseInt(hex.slice(2, 4), 16)\n let b = parseInt(hex.slice(4, 6), 16)\n\n r = Math.floor(r * factor)\n g = Math.floor(g * factor)\n b = Math.floor(b * factor)\n\n r = Math.min(255, Math.max(0, r))\n g = Math.min(255, Math.max(0, g))\n b = Math.min(255, Math.max(0, b))\n\n return `#${r.toString(16).padStart(2, '0')}${g.toString(16).padStart(2, '0')}${b.toString(16).padStart(2, '0')}`;\n}\n\nexport const adjustTextContrast = (color: string) => {\n color = color.replace(/^#/, '')\n const r = parseInt(color.slice(0, 2), 16);\n const g = parseInt(color.slice(2, 4), 16);\n const b = parseInt(color.slice(4, 6), 16);\n\n const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;\n return luminance > 0.5 ? '#111111' : '#FFFFFF';\n}\n\nexport const alpha = (color: string, opacity = 1) => {\n if (typeof opacity !== 'number') return color\n let _opacity = opacity * 100\n if (!color.startsWith(\"#\")) throw new Error(`color must be hex`)\n return (color + (`0${Math.round((255 / 100) * _opacity).toString(16)}`.slice(-2))).toUpperCase();\n};\n\n"],
|
|
5
|
+
"mappings": "AAAA,OAAOA,MAAc,aACrB,OAAOC,MAAc,aACrB,OAAOC,MAAa,YAEpB,OAAS,OAAOC,MAAY,QAOrB,MAAMC,EAAc,CACvB,GAAI,EACJ,GAAI,IACJ,GAAI,IACJ,GAAI,KACJ,GAAI,IACR,EAEaC,EAAM,CAACC,EAAiBC,IAA6B,CAC9D,MAAMC,EAA6B,CAC/B,GAAGD,EACH,YAAAH,EACA,QAAAF,EACA,SAAU,CAACO,EAAQC,EAAQC,EAASC,IAAS,CACzC,GAAIL,GAAS,SAAU,CACnB,IAAIM,EAAON,GAAS,SAASE,EAAGC,EAAGC,EAAIC,CAAI,EAC3C,GAAIC,EAAM,OAAOA,CACrB,CACA,OAAOb,EAASS,EAAGC,EAAGC,CAAE,CAC5B,EACA,SAAU,CAACF,EAAQC,EAAQC,EAASC,IAAS,CACzC,GAAIL,GAAS,SAAU,CACnB,IAAIO,EAAKP,GAAS,SAASE,EAAGC,EAAGC,EAAIC,CAAI,EACzC,GAAIE,EAAI,OAAOA,CACnB,CACA,OAAOb,EAASQ,EAAGC,EAAGC,CAAE,CAC5B,CACJ,EACA,OAAOR,EAA8BG,EAAOE,CAAU,CAC1D,EAEaO,EAAc,CAACC,EAAaC,IAAmB,CAExDD,EAAMA,EAAI,QAAQ,KAAM,EAAE,EAE1B,IAAIE,EAAI,SAASF,EAAI,MAAM,EAAG,C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6
|
+
"names": ["getValue", "getProps", "aliases", "_css", "breakpoints", "css", "props", "options", "cssOptions", "p", "v", "_c", "dept", "_val", "_p", "adjustColor", "hex", "factor", "r", "g", "b", "adjustTextContrast", "color", "alpha", "opacity", "_opacity"]
|
|
7
7
|
}
|
package/esm/useAnimation.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{css as u}from"./css";import{useId as b}from"react";const a={easeInOut:"cubic-bezier(0.4, 0, 0.2, 1)",easeOut:"cubic-bezier(0.0, 0, 0.2, 1)",easeIn:"cubic-bezier(0.4, 0, 1, 1)",sharp:"cubic-bezier(0.4, 0, 0.6, 1)",linear:"cubic-bezier(0, 0, 1, 1)",easeBounceOut:"cubic-bezier(0.68, -0.55, 0.265, 1.55)"},p=({from:i,to:n,delay:o,ease:t,duration:s})=>{let r=o||0,m=s||600,c=t||"easeBounceOut";const e="anim"+b().
|
|
1
|
+
import{css as u}from"./css";import{useId as b}from"react";const a={easeInOut:"cubic-bezier(0.4, 0, 0.2, 1)",easeOut:"cubic-bezier(0.0, 0, 0.2, 1)",easeIn:"cubic-bezier(0.4, 0, 1, 1)",sharp:"cubic-bezier(0.4, 0, 0.6, 1)",linear:"cubic-bezier(0, 0, 1, 1)",easeBounceOut:"cubic-bezier(0.68, -0.55, 0.265, 1.55)"},p=({from:i,to:n,delay:o,ease:t,duration:s})=>{let r=o||0,m=s||600,c=t||"easeBounceOut";const e="anim"+b().replace(/:/g,"");return u({animationName:e,animationDelay:r+"ms",animationDuration:m+"ms",animationTimingFunction:a[c]||a.easeBounceOut,[`@keyframes ${e}`]:{from:i,to:n}}).classname};var S=p;export{a as animationEases,S as default};
|
|
2
2
|
//# sourceMappingURL=useAnimation.js.map
|
package/esm/useAnimation.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/useAnimation.ts"],
|
|
4
|
-
"sourcesContent": ["import { css } from './css'\nimport { useId } from 'react'\nimport { CSSProps } from './css/types'\n\nexport 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 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 || \"easeBounceOut\"\n const id = \"anim\" + useId().
|
|
5
|
-
"mappings": "AAAA,OAAS,OAAAA,MAAW,QACpB,OAAS,SAAAC,MAAa,QAGf,MAAMC,EAAiB,CAC1B,UAAW,+BACX,QAAS,+BACT,OAAQ,6BACR,MAAO,+BACP,OAAQ,2BACR,cAAe,wCACnB,EAUMC,EAAe,CAAC,CAAE,KAAAC,EAAM,GAAAC,EAAI,MAAAC,EAAO,KAAAC,EAAM,SAAAC,CAAS,IAAyB,CAC7E,IAAIC,EAASH,GAAS,EAClBI,EAAYF,GAAY,IACxBG,EAAQJ,GAAQ,gBACpB,MAAMK,EAAK,OAASX,EAAM,EAAE,
|
|
4
|
+
"sourcesContent": ["import { css } from './css'\nimport { useId } from 'react'\nimport { CSSProps } from './css/types'\n\nexport 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 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 || \"easeBounceOut\"\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.easeBounceOut,\n [`@keyframes ${id}`]: {\n from: from as any,\n to: to as any\n }\n })\n return anim.classname\n}\n\nexport default useAnimation"],
|
|
5
|
+
"mappings": "AAAA,OAAS,OAAAA,MAAW,QACpB,OAAS,SAAAC,MAAa,QAGf,MAAMC,EAAiB,CAC1B,UAAW,+BACX,QAAS,+BACT,OAAQ,6BACR,MAAO,+BACP,OAAQ,2BACR,cAAe,wCACnB,EAUMC,EAAe,CAAC,CAAE,KAAAC,EAAM,GAAAC,EAAI,MAAAC,EAAO,KAAAC,EAAM,SAAAC,CAAS,IAAyB,CAC7E,IAAIC,EAASH,GAAS,EAClBI,EAAYF,GAAY,IACxBG,EAAQJ,GAAQ,gBACpB,MAAMK,EAAK,OAASX,EAAM,EAAE,QAAQ,KAAM,EAAE,EAW5C,OAVaD,EAAI,CACb,cAAeY,EACf,eAAgBH,EAAS,KACzB,kBAAmBC,EAAY,KAC/B,wBAAyBR,EAAeS,CAAK,GAAKT,EAAe,cACjE,CAAC,cAAcU,CAAE,EAAE,EAAG,CAClB,KAAMR,EACN,GAAIC,CACR,CACJ,CAAC,EACW,SAChB,EAEA,IAAOQ,EAAQV",
|
|
6
6
|
"names": ["css", "useId", "animationEases", "useAnimation", "from", "to", "delay", "ease", "duration", "_delay", "_duration", "_ease", "id", "useAnimation_default"]
|
|
7
7
|
}
|