@bentoproject/accordion
Advanced tools
Comparing version 1.2112032204.0 to 1.2112062322.0
@@ -63,4 +63,3 @@ // extensions/amp-accordion/1.0/component.jss.js | ||
createElement, | ||
createRef, | ||
toChildArray | ||
createRef | ||
} from "preact"; | ||
@@ -113,3 +112,3 @@ import { | ||
// src/preact/compat.js | ||
import { options } from "preact"; | ||
import { options, toChildArray } from "preact"; | ||
@@ -116,0 +115,0 @@ // src/core/mode/prod.js |
@@ -1,1 +0,1 @@ | ||
var n;function t(n){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(n){return typeof n}:function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n})(n)}function e(n){var e=function(n,e){if("object"!==t(n)||null===n)return n;var r=n[Symbol.toPrimitive];if(void 0!==r){var o=r.call(n,"string");if("object"!==t(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(n);return"symbol"===t(e)?e:String(e)}function r(){return n||(n=Promise.resolve(void 0))}function o(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}function i(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),e.push.apply(e,r)}return e}function c(n){for(var t=1;t<arguments.length;t++){var e=null!=arguments[t]?arguments[t]:{};t%2?i(Object(e),!0).forEach((function(t){o(n,t,e[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):i(Object(e)).forEach((function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(e,t))}))}return n}function a(n,t){if(null==n)return{};var e,r,o={},i=Object.keys(n);for(r=0;r<i.length;r++)e=i[r],t.indexOf(e)>=0||(o[e]=n[e]);return o}var{hasOwnProperty:u,toString:l}=Object.prototype;function f(n,t){return Object.keys(n).reduce(((e,r)=>(t.includes(r)||(e[r]=n[r]),e)),{})}import{cloneElement as d,createContext as s,createElement as b,createRef as p,toChildArray as h}from"preact";import{hydrate as v,render as g}from"preact";import{useCallback as m,useContext as y,useEffect as S,useImperativeHandle as x,useLayoutEffect as j,useMemo as O,useRef as w,useState as I}from"preact/hooks";function $(n,t,e){return b.apply(void 0,arguments)}function z(n){return s(n,void 0)}function E(n){return I(n)}function M(n){return w(n)}function Y(n,t){S(n,t)}function C(n,t){j(n,t)}function k(n){return y(n)}function H(n,t){return O(n,t)}function P(n,t){return m(n,t)}import{options as A}from"preact";var T,W=["ref"],_="undefined"!=typeof Symbol&&(null===(T=Symbol.for)||void 0===T?void 0:T.call(Symbol,"react.forward_ref"))||3911,q=A.__b;A.__b=function(n){var t;null!==(t=n.type)&&void 0!==t&&t.mf&&n.ref&&(n.props.ref=n.ref,n.ref=null),null==q||q(n)};var B,D,F=["auto","lazy","eager","unload"],G={auto:0,lazy:1,eager:2,unload:3};function J(n,t){const e=G[n]||0,r=G[t]||0,o=Math.max(e,r);return F[o]}function K(){return B||(B=z({renderable:!0,playable:!0,loading:"auto"}))}function L({children:n,loading:t="auto",notify:e,playable:r=!0,renderable:o=!0}){const i=k(K()),c=o&&i.renderable,a=c&&r&&i.playable,u=J(c?"auto":"lazy",J(t,i.loading)),l=e||i.notify,f=H((()=>({renderable:c,playable:a,loading:u,notify:l})),[c,a,u,l]);return $(K().Provider,{children:n,value:f})}var N=["Webkit","webkit","Moz","moz","ms","O","o"];function Q(n,t,e){if(X(t))return t;D||(D=Object.create(null));let r=D[t];if(!r||e){if(r=t,void 0===n[t]){const e=function(n){return n.charAt(0).toUpperCase()+n.slice(1)}(t),o=function(n,t){for(let e=0;e<N.length;e++){const r=N[e]+t;if(void 0!==n[r])return r}return""}(n,e);void 0!==n[o]&&(r=o)}e||(D[t]=r)}return r}function R(n,t,e,r,o){const i=Q(n.style,t,o);if(!i)return;const c=r?e+r:e;X(i)?n.style.setProperty(i,c):n.style[i]=c}function U(n,t,e){const r=Q(n.style,t,e);if(r)return X(r)?n.style.getPropertyValue(r):n.style[r]}function V(n,t){for(const e in t)R(n,e,t[e])}function X(n){return n.startsWith("--")}function Z(n,t,e){n.classList.add("i-amphtml-animating");let r=t();return r.onfinish=r.oncancel=()=>{r=null,e&&e(),n.classList.remove("i-amphtml-animating")},()=>{r&&r.cancel()}}function nn(n){const t=window.innerHeight,e=Math.abs(n)/t*500;return Math.min(Math.max(e,200),500)}var tn=["animate","as","children","expandSingleSection","id"],en=["animate","as","children","expanded","id","onExpandStateChange"],rn=z({}),on=z({}),cn={},an={},un=function(){let n=0;return()=>String(++n)}(),ln=()=>String(Math.floor(1e5*Math.random())),fn=function(n){function t(n){const{ref:t}=n;return function(n,t){let{animate:e=!1,as:o="section",children:i,expandSingleSection:u=!1,id:l}=n,d=a(n,tn);const[s,b]=E(cn),p=M(an),[h]=E(ln),v=l||`a${h}`;Y((()=>{u&&b((n=>{const t={};let e=0;for(const r in n)t[r]=n[r]&&0==e++;return t}))}),[u]);const g=P(((n,t,{current:e})=>(b((e=>dn(n,t,e,u))),p.current=c(c({},p.current),{},{[n]:e}),()=>{b((t=>f(t,n))),p.current=f(p.current,n)})),[u]),m=P(((n,t)=>{b((e=>{const o=null!=t?t:!e[n],i=dn(n,o,e,u);return r().then((()=>{for(const n in e){const t=p.current[n];t&&e[n]!=i[n]&&t(i[n])}})),i}))}),[u]),y=P(((n,t)=>{var e;return null!==(e=s[n])&&void 0!==e?e:t}),[s]),S=P((n=>{if(n)n in s&&m(n);else if(!u)for(const n in s)m(n)}),[s,m,u]),j=P((n=>{if(n)y(n,!0)||m(n);else if(!u)for(const n in s)y(n,!0)||m(n)}),[s,m,y,u]),O=P((n=>{if(n)y(n,!1)&&m(n);else for(const n in s)y(n,!1)&&m(n)}),[s,m,y]);!function(n,t,e){x(n,(()=>({toggle:S,expand:j,collapse:O})),e)}(t,0,[S,O,j]);const w=H((()=>({registerSection:g,toggleExpanded:m,isExpanded:y,animate:e,prefix:v})),[g,m,y,e,v]);return $(o,c({id:l},d),$(rn.Provider,{value:w},i))}(a(n,W),t)}return t.$$typeof=_,t.render=t,t.prototype.isReactComponent=!0,t.mf=!0,t}();function dn(n,t,e,r){let o;if(r&&t){o={[n]:t};for(const t in e)t!=n&&(o[t]=!1)}else o=c(c({},e),{},{[n]:t});return o}function sn(n){let{animate:t=!1,as:e="section",children:o,expanded:i=!1,id:u,onExpandStateChange:l}=n,f=a(n,en);const[d]=E(un),s=u||d,[b]=E(ln),[p,h]=E(i),[v,g]=E(null),[m,y]=E(null),{animate:S,isExpanded:x,prefix:j,registerSection:O,toggleExpanded:w}=k(rn),I=x?x(s,i):p,z=null!=S?S:t,Y=v||`${j||"a"}-content-${s}-${b}`,A=m||`${j||"a"}-header-${s}-${b}`,T=M(null);T.current=l,C((()=>{if(O)return O(s,i,T)}),[O,s,i]);const W=P((n=>{w?w(s,n):h((t=>{const e=null!=n?n:!t;return r().then((()=>{const n=T.current;n&&n(e)})),e}))}),[s,w]),_=H((()=>({animate:z,contentId:Y,headerId:A,expanded:I,toggleHandler:W,setContentId:g,setHeaderId:y})),[z,Y,A,I,W]);return $(e,c({},f),$(on.Provider,{value:_},o))}function bn(n){let t="class",r="tabIndex",{as:o="div",children:i,id:u,role:l="button",[t]:f="",[r]:d=0}=n,s=a(n,["as","children","id","role",t,r].map(e));const{contentId:b,expanded:p,headerId:h,setHeaderId:v,toggleHandler:g}=k(on);return C((()=>{v&&v(u)}),[v,u]),$(o,c(c({},s),{},{id:h,role:l,class:`${f} section-child-00fce3c header-00fce3c`,tabIndex:d,"aria-controls":b,onClick:()=>g(),"aria-expanded":String(p)}),i)}function pn(n){let t="class",{as:r="div",children:o,id:i,role:u="region",[t]:l=""}=n,f=a(n,["as","children","id","role",t].map(e));const d=M(null),s=M(!1),{animate:b,contentId:p,expanded:h,headerId:v,setContentId:g}=k(on);return Y((()=>(s.current=!0,()=>s.current=!1)),[]),C((()=>{g&&g(i)}),[g,i]),C((()=>{const n=s.current,t=d.current;if(b&&n&&t&&t.animate)return h?function(n){return Z(n,(()=>{const t=U(n,"height"),e=U(n,"opacity"),r=U(n,"overflowY");V(n,{height:0,opacity:0,overflowY:"auto"});const o=n.scrollHeight;V(n,{height:t,opacity:e,overflowY:r});const i=nn(o);return n.animate([{height:0,opacity:0,overflowY:"hidden"},{height:o+"px",opacity:1,overflowY:"hidden"}],{easing:"cubic-bezier(0.47, 0, 0.745, 0.715)",duration:i})}))}(t):function(n){return Z(n,(()=>{const t=n.offsetHeight,e=nn(t);return n.animate([{height:t+"px",opacity:1,overflowY:"hidden"},{height:"0",opacity:0,overflowY:"hidden"}],{easing:"cubic-bezier(0.39, 0.575, 0.565, 1)",duration:e})}))}(t)}),[h,b]),$(L,{renderable:h},$(r,c(c({},f),{},{ref:d,class:l+" section-child-00fce3c"+(h?"":" content-hidden-00fce3c"),id:p,"aria-labelledby":v,role:u}),o))}fn.displayName="Accordion";export{fn as BentoAccordion,pn as BentoAccordionContent,bn as BentoAccordionHeader,sn as BentoAccordionSection}; | ||
var n;function t(n){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(n){return typeof n}:function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n})(n)}function e(n){var e=function(n,e){if("object"!==t(n)||null===n)return n;var r=n[Symbol.toPrimitive];if(void 0!==r){var o=r.call(n,"string");if("object"!==t(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(n);return"symbol"===t(e)?e:String(e)}function r(){return n||(n=Promise.resolve(void 0))}function o(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}function i(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),e.push.apply(e,r)}return e}function c(n){for(var t=1;t<arguments.length;t++){var e=null!=arguments[t]?arguments[t]:{};t%2?i(Object(e),!0).forEach((function(t){o(n,t,e[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):i(Object(e)).forEach((function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(e,t))}))}return n}function a(n,t){if(null==n)return{};var e,r,o={},i=Object.keys(n);for(r=0;r<i.length;r++)e=i[r],t.indexOf(e)>=0||(o[e]=n[e]);return o}var{hasOwnProperty:u,toString:l}=Object.prototype;function f(n,t){return Object.keys(n).reduce(((e,r)=>(t.includes(r)||(e[r]=n[r]),e)),{})}import{cloneElement as d,createContext as s,createElement as b,createRef as p}from"preact";import{hydrate as h,render as v}from"preact";import{useCallback as g,useContext as m,useEffect as y,useImperativeHandle as S,useLayoutEffect as x,useMemo as j,useRef as O,useState as w}from"preact/hooks";function I(n,t,e){return b.apply(void 0,arguments)}function $(n){return s(n,void 0)}function z(n){return w(n)}function E(n){return O(n)}function M(n,t){y(n,t)}function Y(n,t){x(n,t)}function C(n){return m(n)}function k(n,t){return j(n,t)}function H(n,t){return g(n,t)}import{options as P,toChildArray as A}from"preact";var T,W=["ref"],_="undefined"!=typeof Symbol&&(null===(T=Symbol.for)||void 0===T?void 0:T.call(Symbol,"react.forward_ref"))||3911,q=P.__b;P.__b=function(n){var t;null!==(t=n.type)&&void 0!==t&&t.mf&&n.ref&&(n.props.ref=n.ref,n.ref=null),null==q||q(n)};var B,D,F=["auto","lazy","eager","unload"],G={auto:0,lazy:1,eager:2,unload:3};function J(n,t){const e=G[n]||0,r=G[t]||0,o=Math.max(e,r);return F[o]}function K(){return B||(B=$({renderable:!0,playable:!0,loading:"auto"}))}function L({children:n,loading:t="auto",notify:e,playable:r=!0,renderable:o=!0}){const i=C(K()),c=o&&i.renderable,a=c&&r&&i.playable,u=J(c?"auto":"lazy",J(t,i.loading)),l=e||i.notify,f=k((()=>({renderable:c,playable:a,loading:u,notify:l})),[c,a,u,l]);return I(K().Provider,{children:n,value:f})}var N=["Webkit","webkit","Moz","moz","ms","O","o"];function Q(n,t,e){if(X(t))return t;D||(D=Object.create(null));let r=D[t];if(!r||e){if(r=t,void 0===n[t]){const e=function(n){return n.charAt(0).toUpperCase()+n.slice(1)}(t),o=function(n,t){for(let e=0;e<N.length;e++){const r=N[e]+t;if(void 0!==n[r])return r}return""}(n,e);void 0!==n[o]&&(r=o)}e||(D[t]=r)}return r}function R(n,t,e,r,o){const i=Q(n.style,t,o);if(!i)return;const c=r?e+r:e;X(i)?n.style.setProperty(i,c):n.style[i]=c}function U(n,t,e){const r=Q(n.style,t,e);if(r)return X(r)?n.style.getPropertyValue(r):n.style[r]}function V(n,t){for(const e in t)R(n,e,t[e])}function X(n){return n.startsWith("--")}function Z(n,t,e){n.classList.add("i-amphtml-animating");let r=t();return r.onfinish=r.oncancel=()=>{r=null,e&&e(),n.classList.remove("i-amphtml-animating")},()=>{r&&r.cancel()}}function nn(n){const t=window.innerHeight,e=Math.abs(n)/t*500;return Math.min(Math.max(e,200),500)}var tn=["animate","as","children","expandSingleSection","id"],en=["animate","as","children","expanded","id","onExpandStateChange"],rn=$({}),on=$({}),cn={},an={},un=function(){let n=0;return()=>String(++n)}(),ln=()=>String(Math.floor(1e5*Math.random())),fn=function(n){function t(n){const{ref:t}=n;return function(n,t){let{animate:e=!1,as:o="section",children:i,expandSingleSection:u=!1,id:l}=n,d=a(n,tn);const[s,b]=z(cn),p=E(an),[h]=z(ln),v=l||`a${h}`;M((()=>{u&&b((n=>{const t={};let e=0;for(const r in n)t[r]=n[r]&&0==e++;return t}))}),[u]);const g=H(((n,t,{current:e})=>(b((e=>dn(n,t,e,u))),p.current=c(c({},p.current),{},{[n]:e}),()=>{b((t=>f(t,n))),p.current=f(p.current,n)})),[u]),m=H(((n,t)=>{b((e=>{const o=null!=t?t:!e[n],i=dn(n,o,e,u);return r().then((()=>{for(const n in e){const t=p.current[n];t&&e[n]!=i[n]&&t(i[n])}})),i}))}),[u]),y=H(((n,t)=>{var e;return null!==(e=s[n])&&void 0!==e?e:t}),[s]),x=H((n=>{if(n)n in s&&m(n);else if(!u)for(const n in s)m(n)}),[s,m,u]),j=H((n=>{if(n)y(n,!0)||m(n);else if(!u)for(const n in s)y(n,!0)||m(n)}),[s,m,y,u]),O=H((n=>{if(n)y(n,!1)&&m(n);else for(const n in s)y(n,!1)&&m(n)}),[s,m,y]);!function(n,t,e){S(n,(()=>({toggle:x,expand:j,collapse:O})),e)}(t,0,[x,O,j]);const w=k((()=>({registerSection:g,toggleExpanded:m,isExpanded:y,animate:e,prefix:v})),[g,m,y,e,v]);return I(o,c({id:l},d),I(rn.Provider,{value:w},i))}(a(n,W),t)}return t.$$typeof=_,t.render=t,t.prototype.isReactComponent=!0,t.mf=!0,t}();function dn(n,t,e,r){let o;if(r&&t){o={[n]:t};for(const t in e)t!=n&&(o[t]=!1)}else o=c(c({},e),{},{[n]:t});return o}function sn(n){let{animate:t=!1,as:e="section",children:o,expanded:i=!1,id:u,onExpandStateChange:l}=n,f=a(n,en);const[d]=z(un),s=u||d,[b]=z(ln),[p,h]=z(i),[v,g]=z(null),[m,y]=z(null),{animate:S,isExpanded:x,prefix:j,registerSection:O,toggleExpanded:w}=C(rn),$=x?x(s,i):p,M=null!=S?S:t,P=v||`${j||"a"}-content-${s}-${b}`,A=m||`${j||"a"}-header-${s}-${b}`,T=E(null);T.current=l,Y((()=>{if(O)return O(s,i,T)}),[O,s,i]);const W=H((n=>{w?w(s,n):h((t=>{const e=null!=n?n:!t;return r().then((()=>{const n=T.current;n&&n(e)})),e}))}),[s,w]),_=k((()=>({animate:M,contentId:P,headerId:A,expanded:$,toggleHandler:W,setContentId:g,setHeaderId:y})),[M,P,A,$,W]);return I(e,c({},f),I(on.Provider,{value:_},o))}function bn(n){let t="class",r="tabIndex",{as:o="div",children:i,id:u,role:l="button",[t]:f="",[r]:d=0}=n,s=a(n,["as","children","id","role",t,r].map(e));const{contentId:b,expanded:p,headerId:h,setHeaderId:v,toggleHandler:g}=C(on);return Y((()=>{v&&v(u)}),[v,u]),I(o,c(c({},s),{},{id:h,role:l,class:`${f} section-child-00fce3c header-00fce3c`,tabIndex:d,"aria-controls":b,onClick:()=>g(),"aria-expanded":String(p)}),i)}function pn(n){let t="class",{as:r="div",children:o,id:i,role:u="region",[t]:l=""}=n,f=a(n,["as","children","id","role",t].map(e));const d=E(null),s=E(!1),{animate:b,contentId:p,expanded:h,headerId:v,setContentId:g}=C(on);return M((()=>(s.current=!0,()=>s.current=!1)),[]),Y((()=>{g&&g(i)}),[g,i]),Y((()=>{const n=s.current,t=d.current;if(b&&n&&t&&t.animate)return h?function(n){return Z(n,(()=>{const t=U(n,"height"),e=U(n,"opacity"),r=U(n,"overflowY");V(n,{height:0,opacity:0,overflowY:"auto"});const o=n.scrollHeight;V(n,{height:t,opacity:e,overflowY:r});const i=nn(o);return n.animate([{height:0,opacity:0,overflowY:"hidden"},{height:o+"px",opacity:1,overflowY:"hidden"}],{easing:"cubic-bezier(0.47, 0, 0.745, 0.715)",duration:i})}))}(t):function(n){return Z(n,(()=>{const t=n.offsetHeight,e=nn(t);return n.animate([{height:t+"px",opacity:1,overflowY:"hidden"},{height:"0",opacity:0,overflowY:"hidden"}],{easing:"cubic-bezier(0.39, 0.575, 0.565, 1)",duration:e})}))}(t)}),[h,b]),I(L,{renderable:h},I(r,c(c({},f),{},{ref:d,class:l+" section-child-00fce3c"+(h?"":" content-hidden-00fce3c"),id:p,"aria-labelledby":v,role:u}),o))}fn.displayName="Accordion";export{fn as BentoAccordion,pn as BentoAccordionContent,bn as BentoAccordionHeader,sn as BentoAccordionSection}; |
@@ -63,4 +63,3 @@ // extensions/amp-accordion/1.0/component.jss.js | ||
createElement, | ||
createRef, | ||
toChildArray | ||
createRef | ||
} from "react"; | ||
@@ -67,0 +66,0 @@ import { |
@@ -1,1 +0,1 @@ | ||
var n;function t(n){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(n){return typeof n}:function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n})(n)}function e(n){var e=function(n,e){if("object"!==t(n)||null===n)return n;var r=n[Symbol.toPrimitive];if(void 0!==r){var o=r.call(n,"string");if("object"!==t(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(n);return"symbol"===t(e)?e:String(e)}function r(){return n||(n=Promise.resolve(void 0))}function o(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}function i(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),e.push.apply(e,r)}return e}function c(n){for(var t=1;t<arguments.length;t++){var e=null!=arguments[t]?arguments[t]:{};t%2?i(Object(e),!0).forEach((function(t){o(n,t,e[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):i(Object(e)).forEach((function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(e,t))}))}return n}function a(n,t){if(null==n)return{};var e,r,o={},i=Object.keys(n);for(r=0;r<i.length;r++)e=i[r],t.indexOf(e)>=0||(o[e]=n[e]);return o}var{hasOwnProperty:u,toString:l}=Object.prototype;function d(n,t){return Object.keys(n).reduce(((e,r)=>(t.includes(r)||(e[r]=n[r]),e)),{})}import{cloneElement as f,createContext as s,createElement as b,createRef as h,toChildArray as p}from"react";import{hydrate as m,render as g}from"react-dom";import{useCallback as v,useContext as y,useEffect as x,useImperativeHandle as S,useLayoutEffect as j,useMemo as O,useRef as w,useState as I}from"react";function $(n,t,e){return b.apply(void 0,arguments)}function z(n){return s(n,void 0)}function E(n){return I(n)}function M(n){return w(n)}function Y(n,t){x(n,t)}function C(n,t){j(n,t)}function H(n){return y(n)}function N(n,t){return O(n,t)}function k(n,t){return v(n,t)}import{forwardRef as P}from"react";var A,T,W=["auto","lazy","eager","unload"],q={auto:0,lazy:1,eager:2,unload:3};function B(n,t){const e=q[n]||0,r=q[t]||0,o=Math.max(e,r);return W[o]}function D(){return A||(A=z({renderable:!0,playable:!0,loading:"auto"}))}function F({children:n,loading:t="auto",notify:e,playable:r=!0,renderable:o=!0}){const i=H(D()),c=o&&i.renderable,a=c&&r&&i.playable,u=B(c?"auto":"lazy",B(t,i.loading)),l=e||i.notify,d=N((()=>({renderable:c,playable:a,loading:u,notify:l})),[c,a,u,l]);return $(D().Provider,{children:n,value:d})}var G=["Webkit","webkit","Moz","moz","ms","O","o"];function J(n,t,e){if(R(t))return t;T||(T=Object.create(null));let r=T[t];if(!r||e){if(r=t,void 0===n[t]){const e=function(n){return n.charAt(0).toUpperCase()+n.slice(1)}(t),o=function(n,t){for(let e=0;e<G.length;e++){const r=G[e]+t;if(void 0!==n[r])return r}return""}(n,e);void 0!==n[o]&&(r=o)}e||(T[t]=r)}return r}function K(n,t,e,r,o){const i=J(n.style,t,o);if(!i)return;const c=r?e+r:e;R(i)?n.style.setProperty(i,c):n.style[i]=c}function L(n,t,e){const r=J(n.style,t,e);if(r)return R(r)?n.style.getPropertyValue(r):n.style[r]}function Q(n,t){for(const e in t)K(n,e,t[e])}function R(n){return n.startsWith("--")}function U(n,t,e){n.classList.add("i-amphtml-animating");let r=t();return r.onfinish=r.oncancel=()=>{r=null,e&&e(),n.classList.remove("i-amphtml-animating")},()=>{r&&r.cancel()}}function V(n){const t=window.innerHeight,e=Math.abs(n)/t*500;return Math.min(Math.max(e,200),500)}var X=["animate","as","children","expandSingleSection","id"],Z=["animate","as","children","expanded","id","onExpandStateChange"],_=z({}),nn=z({}),tn={},en={},rn=function(){let n=0;return()=>String(++n)}(),on=()=>String(Math.floor(1e5*Math.random())),cn=P((function(n,t){let{animate:e=!1,as:o="section",children:i,expandSingleSection:u=!1,id:l}=n,f=a(n,X);const[s,b]=E(tn),h=M(en),[p]=E(on),m=l||`a${p}`;Y((()=>{u&&b((n=>{const t={};let e=0;for(const r in n)t[r]=n[r]&&0==e++;return t}))}),[u]);const g=k(((n,t,{current:e})=>(b((e=>an(n,t,e,u))),h.current=c(c({},h.current),{},{[n]:e}),()=>{b((t=>d(t,n))),h.current=d(h.current,n)})),[u]),v=k(((n,t)=>{b((e=>{const o=null!=t?t:!e[n],i=an(n,o,e,u);return r().then((()=>{for(const n in e){const t=h.current[n];t&&e[n]!=i[n]&&t(i[n])}})),i}))}),[u]),y=k(((n,t)=>{var e;return null!==(e=s[n])&&void 0!==e?e:t}),[s]),x=k((n=>{if(n)n in s&&v(n);else if(!u)for(const n in s)v(n)}),[s,v,u]),j=k((n=>{if(n)y(n,!0)||v(n);else if(!u)for(const n in s)y(n,!0)||v(n)}),[s,v,y,u]),O=k((n=>{if(n)y(n,!1)&&v(n);else for(const n in s)y(n,!1)&&v(n)}),[s,v,y]);!function(n,t,e){S(n,(()=>({toggle:x,expand:j,collapse:O})),e)}(t,0,[x,O,j]);const w=N((()=>({registerSection:g,toggleExpanded:v,isExpanded:y,animate:e,prefix:m})),[g,v,y,e,m]);return $(o,c({id:l},f),$(_.Provider,{value:w},i))}));function an(n,t,e,r){let o;if(r&&t){o={[n]:t};for(const t in e)t!=n&&(o[t]=!1)}else o=c(c({},e),{},{[n]:t});return o}function un(n){let{animate:t=!1,as:e="section",children:o,expanded:i=!1,id:u,onExpandStateChange:l}=n,d=a(n,Z);const[f]=E(rn),s=u||f,[b]=E(on),[h,p]=E(i),[m,g]=E(null),[v,y]=E(null),{animate:x,isExpanded:S,prefix:j,registerSection:O,toggleExpanded:w}=H(_),I=S?S(s,i):h,z=null!=x?x:t,Y=m||`${j||"a"}-content-${s}-${b}`,P=v||`${j||"a"}-header-${s}-${b}`,A=M(null);A.current=l,C((()=>{if(O)return O(s,i,A)}),[O,s,i]);const T=k((n=>{w?w(s,n):p((t=>{const e=null!=n?n:!t;return r().then((()=>{const n=A.current;n&&n(e)})),e}))}),[s,w]),W=N((()=>({animate:z,contentId:Y,headerId:P,expanded:I,toggleHandler:T,setContentId:g,setHeaderId:y})),[z,Y,P,I,T]);return $(e,c({},d),$(nn.Provider,{value:W},o))}function ln(n){let t="className",r="tabindex",{as:o="div",children:i,id:u,role:l="button",[t]:d="",[r]:f=0}=n,s=a(n,["as","children","id","role",t,r].map(e));const{contentId:b,expanded:h,headerId:p,setHeaderId:m,toggleHandler:g}=H(nn);return C((()=>{m&&m(u)}),[m,u]),$(o,c(c({},s),{},{id:p,role:l,className:`${d} section-child-00fce3c header-00fce3c`,tabindex:f,"aria-controls":b,onClick:()=>g(),"aria-expanded":String(h)}),i)}function dn(n){let t="className",{as:r="div",children:o,id:i,role:u="region",[t]:l=""}=n,d=a(n,["as","children","id","role",t].map(e));const f=M(null),s=M(!1),{animate:b,contentId:h,expanded:p,headerId:m,setContentId:g}=H(nn);return Y((()=>(s.current=!0,()=>s.current=!1)),[]),C((()=>{g&&g(i)}),[g,i]),C((()=>{const n=s.current,t=f.current;if(b&&n&&t&&t.animate)return p?function(n){return U(n,(()=>{const t=L(n,"height"),e=L(n,"opacity"),r=L(n,"overflowY");Q(n,{height:0,opacity:0,overflowY:"auto"});const o=n.scrollHeight;Q(n,{height:t,opacity:e,overflowY:r});const i=V(o);return n.animate([{height:0,opacity:0,overflowY:"hidden"},{height:o+"px",opacity:1,overflowY:"hidden"}],{easing:"cubic-bezier(0.47, 0, 0.745, 0.715)",duration:i})}))}(t):function(n){return U(n,(()=>{const t=n.offsetHeight,e=V(t);return n.animate([{height:t+"px",opacity:1,overflowY:"hidden"},{height:"0",opacity:0,overflowY:"hidden"}],{easing:"cubic-bezier(0.39, 0.575, 0.565, 1)",duration:e})}))}(t)}),[p,b]),$(F,{renderable:p},$(r,c(c({},d),{},{ref:f,className:l+" section-child-00fce3c"+(p?"":" content-hidden-00fce3c"),id:h,"aria-labelledby":m,role:u}),o))}cn.displayName="Accordion";export{cn as BentoAccordion,dn as BentoAccordionContent,ln as BentoAccordionHeader,un as BentoAccordionSection}; | ||
var n;function t(n){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(n){return typeof n}:function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n})(n)}function e(n){var e=function(n,e){if("object"!==t(n)||null===n)return n;var r=n[Symbol.toPrimitive];if(void 0!==r){var o=r.call(n,"string");if("object"!==t(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(n);return"symbol"===t(e)?e:String(e)}function r(){return n||(n=Promise.resolve(void 0))}function o(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}function i(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),e.push.apply(e,r)}return e}function c(n){for(var t=1;t<arguments.length;t++){var e=null!=arguments[t]?arguments[t]:{};t%2?i(Object(e),!0).forEach((function(t){o(n,t,e[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):i(Object(e)).forEach((function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(e,t))}))}return n}function a(n,t){if(null==n)return{};var e,r,o={},i=Object.keys(n);for(r=0;r<i.length;r++)e=i[r],t.indexOf(e)>=0||(o[e]=n[e]);return o}var{hasOwnProperty:u,toString:l}=Object.prototype;function d(n,t){return Object.keys(n).reduce(((e,r)=>(t.includes(r)||(e[r]=n[r]),e)),{})}import{cloneElement as f,createContext as s,createElement as b,createRef as h}from"react";import{hydrate as p,render as m}from"react-dom";import{useCallback as g,useContext as v,useEffect as y,useImperativeHandle as x,useLayoutEffect as S,useMemo as j,useRef as O,useState as w}from"react";function I(n,t,e){return b.apply(void 0,arguments)}function $(n){return s(n,void 0)}function z(n){return w(n)}function E(n){return O(n)}function M(n,t){y(n,t)}function Y(n,t){S(n,t)}function C(n){return v(n)}function H(n,t){return j(n,t)}function N(n,t){return g(n,t)}import{forwardRef as k}from"react";var P,A,T=["auto","lazy","eager","unload"],W={auto:0,lazy:1,eager:2,unload:3};function q(n,t){const e=W[n]||0,r=W[t]||0,o=Math.max(e,r);return T[o]}function B(){return P||(P=$({renderable:!0,playable:!0,loading:"auto"}))}function D({children:n,loading:t="auto",notify:e,playable:r=!0,renderable:o=!0}){const i=C(B()),c=o&&i.renderable,a=c&&r&&i.playable,u=q(c?"auto":"lazy",q(t,i.loading)),l=e||i.notify,d=H((()=>({renderable:c,playable:a,loading:u,notify:l})),[c,a,u,l]);return I(B().Provider,{children:n,value:d})}var F=["Webkit","webkit","Moz","moz","ms","O","o"];function G(n,t,e){if(Q(t))return t;A||(A=Object.create(null));let r=A[t];if(!r||e){if(r=t,void 0===n[t]){const e=function(n){return n.charAt(0).toUpperCase()+n.slice(1)}(t),o=function(n,t){for(let e=0;e<F.length;e++){const r=F[e]+t;if(void 0!==n[r])return r}return""}(n,e);void 0!==n[o]&&(r=o)}e||(A[t]=r)}return r}function J(n,t,e,r,o){const i=G(n.style,t,o);if(!i)return;const c=r?e+r:e;Q(i)?n.style.setProperty(i,c):n.style[i]=c}function K(n,t,e){const r=G(n.style,t,e);if(r)return Q(r)?n.style.getPropertyValue(r):n.style[r]}function L(n,t){for(const e in t)J(n,e,t[e])}function Q(n){return n.startsWith("--")}function R(n,t,e){n.classList.add("i-amphtml-animating");let r=t();return r.onfinish=r.oncancel=()=>{r=null,e&&e(),n.classList.remove("i-amphtml-animating")},()=>{r&&r.cancel()}}function U(n){const t=window.innerHeight,e=Math.abs(n)/t*500;return Math.min(Math.max(e,200),500)}var V=["animate","as","children","expandSingleSection","id"],X=["animate","as","children","expanded","id","onExpandStateChange"],Z=$({}),_=$({}),nn={},tn={},en=function(){let n=0;return()=>String(++n)}(),rn=()=>String(Math.floor(1e5*Math.random())),on=k((function(n,t){let{animate:e=!1,as:o="section",children:i,expandSingleSection:u=!1,id:l}=n,f=a(n,V);const[s,b]=z(nn),h=E(tn),[p]=z(rn),m=l||`a${p}`;M((()=>{u&&b((n=>{const t={};let e=0;for(const r in n)t[r]=n[r]&&0==e++;return t}))}),[u]);const g=N(((n,t,{current:e})=>(b((e=>cn(n,t,e,u))),h.current=c(c({},h.current),{},{[n]:e}),()=>{b((t=>d(t,n))),h.current=d(h.current,n)})),[u]),v=N(((n,t)=>{b((e=>{const o=null!=t?t:!e[n],i=cn(n,o,e,u);return r().then((()=>{for(const n in e){const t=h.current[n];t&&e[n]!=i[n]&&t(i[n])}})),i}))}),[u]),y=N(((n,t)=>{var e;return null!==(e=s[n])&&void 0!==e?e:t}),[s]),S=N((n=>{if(n)n in s&&v(n);else if(!u)for(const n in s)v(n)}),[s,v,u]),j=N((n=>{if(n)y(n,!0)||v(n);else if(!u)for(const n in s)y(n,!0)||v(n)}),[s,v,y,u]),O=N((n=>{if(n)y(n,!1)&&v(n);else for(const n in s)y(n,!1)&&v(n)}),[s,v,y]);!function(n,t,e){x(n,(()=>({toggle:S,expand:j,collapse:O})),e)}(t,0,[S,O,j]);const w=H((()=>({registerSection:g,toggleExpanded:v,isExpanded:y,animate:e,prefix:m})),[g,v,y,e,m]);return I(o,c({id:l},f),I(Z.Provider,{value:w},i))}));function cn(n,t,e,r){let o;if(r&&t){o={[n]:t};for(const t in e)t!=n&&(o[t]=!1)}else o=c(c({},e),{},{[n]:t});return o}function an(n){let{animate:t=!1,as:e="section",children:o,expanded:i=!1,id:u,onExpandStateChange:l}=n,d=a(n,X);const[f]=z(en),s=u||f,[b]=z(rn),[h,p]=z(i),[m,g]=z(null),[v,y]=z(null),{animate:x,isExpanded:S,prefix:j,registerSection:O,toggleExpanded:w}=C(Z),$=S?S(s,i):h,M=null!=x?x:t,k=m||`${j||"a"}-content-${s}-${b}`,P=v||`${j||"a"}-header-${s}-${b}`,A=E(null);A.current=l,Y((()=>{if(O)return O(s,i,A)}),[O,s,i]);const T=N((n=>{w?w(s,n):p((t=>{const e=null!=n?n:!t;return r().then((()=>{const n=A.current;n&&n(e)})),e}))}),[s,w]),W=H((()=>({animate:M,contentId:k,headerId:P,expanded:$,toggleHandler:T,setContentId:g,setHeaderId:y})),[M,k,P,$,T]);return I(e,c({},d),I(_.Provider,{value:W},o))}function un(n){let t="className",r="tabindex",{as:o="div",children:i,id:u,role:l="button",[t]:d="",[r]:f=0}=n,s=a(n,["as","children","id","role",t,r].map(e));const{contentId:b,expanded:h,headerId:p,setHeaderId:m,toggleHandler:g}=C(_);return Y((()=>{m&&m(u)}),[m,u]),I(o,c(c({},s),{},{id:p,role:l,className:`${d} section-child-00fce3c header-00fce3c`,tabindex:f,"aria-controls":b,onClick:()=>g(),"aria-expanded":String(h)}),i)}function ln(n){let t="className",{as:r="div",children:o,id:i,role:u="region",[t]:l=""}=n,d=a(n,["as","children","id","role",t].map(e));const f=E(null),s=E(!1),{animate:b,contentId:h,expanded:p,headerId:m,setContentId:g}=C(_);return M((()=>(s.current=!0,()=>s.current=!1)),[]),Y((()=>{g&&g(i)}),[g,i]),Y((()=>{const n=s.current,t=f.current;if(b&&n&&t&&t.animate)return p?function(n){return R(n,(()=>{const t=K(n,"height"),e=K(n,"opacity"),r=K(n,"overflowY");L(n,{height:0,opacity:0,overflowY:"auto"});const o=n.scrollHeight;L(n,{height:t,opacity:e,overflowY:r});const i=U(o);return n.animate([{height:0,opacity:0,overflowY:"hidden"},{height:o+"px",opacity:1,overflowY:"hidden"}],{easing:"cubic-bezier(0.47, 0, 0.745, 0.715)",duration:i})}))}(t):function(n){return R(n,(()=>{const t=n.offsetHeight,e=U(t);return n.animate([{height:t+"px",opacity:1,overflowY:"hidden"},{height:"0",opacity:0,overflowY:"hidden"}],{easing:"cubic-bezier(0.39, 0.575, 0.565, 1)",duration:e})}))}(t)}),[p,b]),I(D,{renderable:p},I(r,c(c({},d),{},{ref:f,className:l+" section-child-00fce3c"+(p?"":" content-hidden-00fce3c"),id:h,"aria-labelledby":m,role:u}),o))}on.displayName="Accordion";export{on as BentoAccordion,ln as BentoAccordionContent,un as BentoAccordionHeader,an as BentoAccordionSection}; |
{ | ||
"name": "@bentoproject/accordion", | ||
"version": "1.2112032204.0", | ||
"version": "1.2112062322.0", | ||
"description": "Displays content sections that can be collapsed and expanded.", | ||
@@ -5,0 +5,0 @@ "author": "Bento Authors", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1885519
11683