@ampproject/amp-accordion
Advanced tools
Comparing version 1.2108132216.0 to 1.2108170213.0
; | ||
var e;function n(){return e||(e=Promise.resolve(void 0))}bent;var{hasOwnProperty:t,toString:r}=Object.prototype;function o(e,n){return Object.keys(e).reduce(((t,r)=>(n.includes(r)||(t[r]=e[r]),t)),{})}import{cloneElement as i,createContext as a,createElement as c,createRef as l}from"preact";import{hydrate as u,render as d}from"preact";import{useCallback as s,useContext as f,useEffect as p,useImperativeHandle as h,useLayoutEffect as g,useMemo as b,useRef as y,useState as m}from"preact/hooks";function v(e,n,t){return c.apply(void 0,arguments)}function O(e){return a(e,void 0)}function x(e){return m(e)}function w(e){return y(e)}function j(e,n){p(e,n)}function P(e,n){g(e,n)}function S(e){return f(e)}function I(e,n){return b(e,n)}function E(e,n){return s(e,n)}import{Children as $,createPortal as k,forwardRef as z}from"preact/compat";var H,M,N=["auto","lazy","eager","unload"],Y={auto:0,lazy:1,eager:2,unload:3};function C(e,n){const t=Y[e]||0,r=Y[n]||0,o=Math.max(t,r);return N[o]}function D(){return H||(H=O({renderable:!0,playable:!0,loading:"auto"}))}function A({children:e,loading:n="auto",notify:t,playable:r=!0,renderable:o=!0}){let i=n,a=r,c=o;const l=S(D()),u=c&&l.renderable,d=u&&a&&l.playable,s=C(u?"auto":"lazy",C(i,l.loading)),f=t||l.notify,p=I((()=>({renderable:u,playable:d,loading:s,notify:f})),[u,d,s,f]);return v(D().Provider,{children:e,value:p})}var L=["Webkit","webkit","Moz","moz","ms","O","o"];function W(e,n,t){if(B(n))return n;M||(M=Object.create(null));let r=M[n];if(!r||t){if(r=n,void 0===e[n]){const t=function(e,n){for(let t=0;t<L.length;t++){const r=L[t]+n;if(void 0!==e[r])return r}return""}(e,function(e){return e.charAt(0).toUpperCase()+e.slice(1)}(n));void 0!==e[t]&&(r=t)}t||(M[n]=r)}return r}function U(e,n,t,r,o){const i=W(e.style,n,o);if(!i)return;const a=r?t+r:t;B(i)?e.style.setProperty(i,a):e.style[i]=a}function V(e,n,t){const r=W(e.style,n,t);if(r)return B(r)?e.style.getPropertyValue(r):e.style[r]}function q(e,n){for(const t in n)U(e,t,n[t])}function B(e){return e.startsWith("--")}function F(e,n,t){let r=t;e.classList.add("i-amphtml-animating");let o=n();return o.onfinish=o.oncancel=()=>{o=null,r&&r(),e.classList.remove("i-amphtml-animating")},()=>{o&&o.cancel()}}function G(e){const n=window.innerHeight,t=Math.abs(e)/n*500;return Math.min(Math.max(t,200),500)}var J=["animate","as","children","expandSingleSection","id"],K=["animate","as","children","expanded","id","onExpandStateChange"],Q=["as","children","className","id","role","tabIndex"],R=["as","children","className","id","role"];function T(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function X(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?T(Object(t),!0).forEach((function(n){Z(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):T(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}function Z(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function _(e,n){if(null==e)return{};var t,r,o=function(e,n){if(null==e)return{};var t,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)t=i[r],n.indexOf(t)>=0||(o[t]=e[t]);return o}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)t=i[r],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var ee=O({}),ne=O({}),te={},re={},oe=function(){let e=0;return()=>String(++e)}(),ie=()=>String(Math.floor(1e5*Math.random())),ae=z((function(e,t){let{animate:r=!1,as:i="section",children:a,expandSingleSection:c=!1,id:l}=e,u=_(e,J);const{0:d,1:s}=x(te),f=w(re),{0:p}=x(ie),g=l||`a${p}`;j((()=>{c&&s((e=>{const n={};let t=0;for(const r in e)n[r]=e[r]&&0==t++;return n}))}),[c]);const b=E(((e,n,{current:t})=>(s((t=>ce(e,n,t,c))),f.current=X(X({},f.current),{},{[e]:t}),()=>{s((n=>o(n,e))),f.current=o(f.current,e)})),[c]),y=E(((e,t)=>{s((r=>{const o=null!=t?t:!r[e],i=ce(e,o,r,c);return n().then((()=>{for(const e in r){const n=f.current[e];n&&r[e]!=i[e]&&n(i[e])}})),i}))}),[c]),m=E(((e,n)=>{var t;return null!==(t=d[e])&&void 0!==t?t:n}),[d]),O=E((e=>{if(e)e in d&&y(e);else if(!c)for(const e in d)y(e)}),[d,y,c]),P=E((e=>{if(e)m(e,!0)||y(e);else if(!c)for(const e in d)m(e,!0)||y(e)}),[d,y,m,c]),S=E((e=>{if(e)m(e,!1)&&y(e);else for(const e in d)m(e,!1)&&y(e)}),[d,y,m]);!function(e,n,t){h(e,(()=>({toggle:O,expand:P,collapse:S})),t)}(t,0,[O,S,P]);const $=I((()=>({registerSection:b,toggleExpanded:y,isExpanded:m,animate:r,prefix:g})),[b,y,m,r,g]);return v(i,X({id:l},u),v(ee.Provider,{value:$},a))}));function ce(e,n,t,r){let o;if(r&&n){o={[e]:n};for(const n in t)n!=e&&(o[n]=!1)}else o=X(X({},t),{},{[e]:n});return o}function le(e){let{animate:t=!1,as:r="section",children:o,expanded:i=!1,id:a,onExpandStateChange:c}=e,l=_(e,K);const{0:u}=x(oe),d=a||u,{0:s}=x(ie),{0:f,1:p}=x(i),{0:h,1:g}=x(null),{0:b,1:y}=x(null),{animate:m,isExpanded:O,prefix:j,registerSection:$,toggleExpanded:k}=S(ee),z=O?O(d,i):f,H=null!=m?m:t,M=h||`${j||"a"}-content-${d}-${s}`,N=b||`${j||"a"}-header-${d}-${s}`,Y=w(null);Y.current=c,P((()=>{if($)return $(d,i,Y)}),[$,d,i]);const C=E((e=>{k?k(d,e):p((t=>{const r=null!=e?e:!t;return n().then((()=>{const e=Y.current;e&&e(r)})),r}))}),[d,k]),D=I((()=>({animate:H,contentId:M,headerId:N,expanded:z,toggleHandler:C,setContentId:g,setHeaderId:y})),[H,M,N,z,C]);return v(r,X(X({},l),{},{expanded:z}),v(ne.Provider,{value:D},o))}function ue(e){let{as:n="div",children:t,className:r="",id:o,role:i="button",tabIndex:a=0}=e,c=_(e,Q);const{contentId:l,expanded:u,headerId:d,setHeaderId:s,toggleHandler:f}=S(ne);return P((()=>{s&&s(o)}),[s,o]),v(n,X(X({},c),{},{id:d,role:i,className:`${r} section-child-00fce3c header-00fce3c`,tabIndex:a,"aria-controls":l,onClick:()=>f(),"aria-expanded":String(u)}),t)}function de(e){let{as:n="div",children:t,className:r="",id:o,role:i="region"}=e,a=_(e,R);const c=w(null),l=w(!1),{animate:u,contentId:d,expanded:s,headerId:f,setContentId:p}=S(ne);return j((()=>(l.current=!0,()=>l.current=!1)),[]),P((()=>{p&&p(o)}),[p,o]),P((()=>{const e=l.current,n=c.current;if(u&&e&&n&&n.animate)return s?function(e){return F(e,(()=>{const n=V(e,"height"),t=V(e,"opacity"),r=V(e,"overflowY");q(e,{height:0,opacity:0,overflowY:"auto"});const o=e.scrollHeight;q(e,{height:n,opacity:t,overflowY:r});const i=G(o);return e.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})}))}(n):function(e){return F(e,(()=>{const n=e.offsetHeight,t=G(n);return e.animate([{height:n+"px",opacity:1,overflowY:"hidden"},{height:"0",opacity:0,overflowY:"hidden"}],{easing:"cubic-bezier(0.39, 0.575, 0.565, 1)",duration:t})}))}(n)}),[s,u]),v(A,{renderable:s},v(n,X(X({},a),{},{ref:c,className:r+" section-child-00fce3c"+(s?"":" content-hidden-00fce3c"),id:d,"aria-labelledby":f,role:i}),t))}ae.displayName="Accordion";export{ae as Accordion,de as AccordionContent,ue as AccordionHeader,le as AccordionSection}; | ||
var e;function n(){return e||(e=Promise.resolve(void 0))}bent;var{hasOwnProperty:t,toString:r}=Object.prototype;function o(e,n){return Object.keys(e).reduce(((t,r)=>(n.includes(r)||(t[r]=e[r]),t)),{})}import{cloneElement as i,createContext as a,createElement as c,createRef as l}from"preact";import{hydrate as u,render as d}from"preact";import{useCallback as s,useContext as f,useEffect as p,useImperativeHandle as h,useLayoutEffect as g,useMemo as b,useRef as y,useState as m}from"preact/hooks";function v(e,n,t){return c.apply(void 0,arguments)}function O(e){return a(e,void 0)}function x(e){return m(e)}function w(e){return y(e)}function j(e,n){p(e,n)}function P(e,n){g(e,n)}function S(e){return f(e)}function I(e,n){return b(e,n)}function E(e,n){return s(e,n)}import{Children as $,createPortal as k,forwardRef as z}from"preact/compat";var H,M,N=["auto","lazy","eager","unload"],Y={auto:0,lazy:1,eager:2,unload:3};function C(e,n){const t=Y[e]||0,r=Y[n]||0,o=Math.max(t,r);return N[o]}function D(){return H||(H=O({renderable:!0,playable:!0,loading:"auto"}))}function A({children:e,loading:n="auto",notify:t,playable:r=!0,renderable:o=!0}){let i=n,a=r,c=o;const l=S(D()),u=c&&l.renderable,d=u&&a&&l.playable,s=C(u?"auto":"lazy",C(i,l.loading)),f=t||l.notify,p=I((()=>({renderable:u,playable:d,loading:s,notify:f})),[u,d,s,f]);return v(D().Provider,{children:e,value:p})}var L=["Webkit","webkit","Moz","moz","ms","O","o"];function W(e,n,t){if(B(n))return n;M||(M=Object.create(null));let r=M[n];if(!r||t){if(r=n,void 0===e[n]){const t=function(e,n){for(let t=0;t<L.length;t++){const r=L[t]+n;if(void 0!==e[r])return r}return""}(e,function(e){return e.charAt(0).toUpperCase()+e.slice(1)}(n));void 0!==e[t]&&(r=t)}t||(M[n]=r)}return r}function U(e,n,t,r,o){const i=W(e.style,n,o);if(!i)return;const a=r?t+r:t;B(i)?e.style.setProperty(i,a):e.style[i]=a}function V(e,n,t){const r=W(e.style,n,t);if(r)return B(r)?e.style.getPropertyValue(r):e.style[r]}function q(e,n){for(const t in n)U(e,t,n[t])}function B(e){return e.startsWith("--")}function F(e,n,t){let r=t;e.classList.add("i-amphtml-animating");let o=n();return o.onfinish=o.oncancel=()=>{o=null,r&&r(),e.classList.remove("i-amphtml-animating")},()=>{o&&o.cancel()}}function G(e){const n=window.innerHeight,t=Math.abs(e)/n*500;return Math.min(Math.max(t,200),500)}var J=["animate","as","children","expandSingleSection","id"],K=["animate","as","children","expanded","id","onExpandStateChange"],Q=["as","children","className","id","role","tabIndex"],R=["as","children","className","id","role"];function T(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function X(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?T(Object(t),!0).forEach((function(n){Z(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):T(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}function Z(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function _(e,n){if(null==e)return{};var t,r,o=function(e,n){if(null==e)return{};var t,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)t=i[r],n.indexOf(t)>=0||(o[t]=e[t]);return o}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)t=i[r],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var ee=O({}),ne=O({}),te={},re={},oe=function(){let e=0;return()=>String(++e)}(),ie=()=>String(Math.floor(1e5*Math.random())),ae=z((function(e,t){let{animate:r=!1,as:i="section",children:a,expandSingleSection:c=!1,id:l}=e,u=_(e,J);const[d,s]=x(te),f=w(re),[p]=x(ie),g=l||`a${p}`;j((()=>{c&&s((e=>{const n={};let t=0;for(const r in e)n[r]=e[r]&&0==t++;return n}))}),[c]);const b=E(((e,n,{current:t})=>(s((t=>ce(e,n,t,c))),f.current=X(X({},f.current),{},{[e]:t}),()=>{s((n=>o(n,e))),f.current=o(f.current,e)})),[c]),y=E(((e,t)=>{s((r=>{const o=null!=t?t:!r[e],i=ce(e,o,r,c);return n().then((()=>{for(const e in r){const n=f.current[e];n&&r[e]!=i[e]&&n(i[e])}})),i}))}),[c]),m=E(((e,n)=>{var t;return null!==(t=d[e])&&void 0!==t?t:n}),[d]),O=E((e=>{if(e)e in d&&y(e);else if(!c)for(const e in d)y(e)}),[d,y,c]),P=E((e=>{if(e)m(e,!0)||y(e);else if(!c)for(const e in d)m(e,!0)||y(e)}),[d,y,m,c]),S=E((e=>{if(e)m(e,!1)&&y(e);else for(const e in d)m(e,!1)&&y(e)}),[d,y,m]);!function(e,n,t){h(e,(()=>({toggle:O,expand:P,collapse:S})),t)}(t,0,[O,S,P]);const $=I((()=>({registerSection:b,toggleExpanded:y,isExpanded:m,animate:r,prefix:g})),[b,y,m,r,g]);return v(i,X({id:l},u),v(ee.Provider,{value:$},a))}));function ce(e,n,t,r){let o;if(r&&n){o={[e]:n};for(const n in t)n!=e&&(o[n]=!1)}else o=X(X({},t),{},{[e]:n});return o}function le(e){let{animate:t=!1,as:r="section",children:o,expanded:i=!1,id:a,onExpandStateChange:c}=e,l=_(e,K);const[u]=x(oe),d=a||u,[s]=x(ie),[f,p]=x(i),[h,g]=x(null),[b,y]=x(null),{animate:m,isExpanded:O,prefix:j,registerSection:$,toggleExpanded:k}=S(ee),z=O?O(d,i):f,H=null!=m?m:t,M=h||`${j||"a"}-content-${d}-${s}`,N=b||`${j||"a"}-header-${d}-${s}`,Y=w(null);Y.current=c,P((()=>{if($)return $(d,i,Y)}),[$,d,i]);const C=E((e=>{k?k(d,e):p((t=>{const r=null!=e?e:!t;return n().then((()=>{const e=Y.current;e&&e(r)})),r}))}),[d,k]),D=I((()=>({animate:H,contentId:M,headerId:N,expanded:z,toggleHandler:C,setContentId:g,setHeaderId:y})),[H,M,N,z,C]);return v(r,X(X({},l),{},{expanded:z}),v(ne.Provider,{value:D},o))}function ue(e){let{as:n="div",children:t,className:r="",id:o,role:i="button",tabIndex:a=0}=e,c=_(e,Q);const{contentId:l,expanded:u,headerId:d,setHeaderId:s,toggleHandler:f}=S(ne);return P((()=>{s&&s(o)}),[s,o]),v(n,X(X({},c),{},{id:d,role:i,className:`${r} section-child-00fce3c header-00fce3c`,tabIndex:a,"aria-controls":l,onClick:()=>f(),"aria-expanded":String(u)}),t)}function de(e){let{as:n="div",children:t,className:r="",id:o,role:i="region"}=e,a=_(e,R);const c=w(null),l=w(!1),{animate:u,contentId:d,expanded:s,headerId:f,setContentId:p}=S(ne);return j((()=>(l.current=!0,()=>l.current=!1)),[]),P((()=>{p&&p(o)}),[p,o]),P((()=>{const e=l.current,n=c.current;if(u&&e&&n&&n.animate)return s?function(e){return F(e,(()=>{const n=V(e,"height"),t=V(e,"opacity"),r=V(e,"overflowY");q(e,{height:0,opacity:0,overflowY:"auto"});const o=e.scrollHeight;q(e,{height:n,opacity:t,overflowY:r});const i=G(o);return e.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})}))}(n):function(e){return F(e,(()=>{const n=e.offsetHeight,t=G(n);return e.animate([{height:n+"px",opacity:1,overflowY:"hidden"},{height:"0",opacity:0,overflowY:"hidden"}],{easing:"cubic-bezier(0.39, 0.575, 0.565, 1)",duration:t})}))}(n)}),[s,u]),v(A,{renderable:s},v(n,X(X({},a),{},{ref:c,className:r+" section-child-00fce3c"+(s?"":" content-hidden-00fce3c"),id:d,"aria-labelledby":f,role:i}),t))}ae.displayName="Accordion";export{ae as Accordion,de as AccordionContent,ue as AccordionHeader,le as AccordionSection}; |
; | ||
var e;function n(){return e||(e=Promise.resolve(void 0))}bent;var{hasOwnProperty:t,toString:r}=Object.prototype;function o(e,n){return Object.keys(e).reduce(((t,r)=>(n.includes(r)||(t[r]=e[r]),t)),{})}import{cloneElement as i,createContext as a,createElement as c,createRef as l}from"react";import{hydrate as u,render as d}from"react-dom";import{useCallback as s,useContext as f,useEffect as p,useImperativeHandle as h,useLayoutEffect as g,useMemo as b,useRef as y,useState as m}from"react";function v(e,n,t){return c.apply(void 0,arguments)}function O(e){return a(e,void 0)}function x(e){return m(e)}function w(e){return y(e)}function j(e,n){p(e,n)}function P(e,n){g(e,n)}function S(e){return f(e)}function I(e,n){return b(e,n)}function E(e,n){return s(e,n)}import{Children as $,createPortal as z,forwardRef as H}from"react";var M,N,Y=["auto","lazy","eager","unload"],k={auto:0,lazy:1,eager:2,unload:3};function C(e,n){const t=k[e]||0,r=k[n]||0,o=Math.max(t,r);return Y[o]}function D(){return M||(M=O({renderable:!0,playable:!0,loading:"auto"}))}function A({children:e,loading:n="auto",notify:t,playable:r=!0,renderable:o=!0}){let i=n,a=r,c=o;const l=S(D()),u=c&&l.renderable,d=u&&a&&l.playable,s=C(u?"auto":"lazy",C(i,l.loading)),f=t||l.notify,p=I((()=>({renderable:u,playable:d,loading:s,notify:f})),[u,d,s,f]);return v(D().Provider,{children:e,value:p})}var L=["Webkit","webkit","Moz","moz","ms","O","o"];function W(e,n,t){if(B(n))return n;N||(N=Object.create(null));let r=N[n];if(!r||t){if(r=n,void 0===e[n]){const t=function(e,n){for(let t=0;t<L.length;t++){const r=L[t]+n;if(void 0!==e[r])return r}return""}(e,function(e){return e.charAt(0).toUpperCase()+e.slice(1)}(n));void 0!==e[t]&&(r=t)}t||(N[n]=r)}return r}function U(e,n,t,r,o){const i=W(e.style,n,o);if(!i)return;const a=r?t+r:t;B(i)?e.style.setProperty(i,a):e.style[i]=a}function V(e,n,t){const r=W(e.style,n,t);if(r)return B(r)?e.style.getPropertyValue(r):e.style[r]}function q(e,n){for(const t in n)U(e,t,n[t])}function B(e){return e.startsWith("--")}function F(e,n,t){let r=t;e.classList.add("i-amphtml-animating");let o=n();return o.onfinish=o.oncancel=()=>{o=null,r&&r(),e.classList.remove("i-amphtml-animating")},()=>{o&&o.cancel()}}function G(e){const n=window.innerHeight,t=Math.abs(e)/n*500;return Math.min(Math.max(t,200),500)}var J=["animate","as","children","expandSingleSection","id"],K=["animate","as","children","expanded","id","onExpandStateChange"],Q=["as","children","className","id","role","tabIndex"],R=["as","children","className","id","role"];function T(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function X(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?T(Object(t),!0).forEach((function(n){Z(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):T(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}function Z(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function _(e,n){if(null==e)return{};var t,r,o=function(e,n){if(null==e)return{};var t,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)t=i[r],n.indexOf(t)>=0||(o[t]=e[t]);return o}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)t=i[r],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var ee=O({}),ne=O({}),te={},re={},oe=function(){let e=0;return()=>String(++e)}(),ie=()=>String(Math.floor(1e5*Math.random())),ae=H((function(e,t){let{animate:r=!1,as:i="section",children:a,expandSingleSection:c=!1,id:l}=e,u=_(e,J);const{0:d,1:s}=x(te),f=w(re),{0:p}=x(ie),g=l||`a${p}`;j((()=>{c&&s((e=>{const n={};let t=0;for(const r in e)n[r]=e[r]&&0==t++;return n}))}),[c]);const b=E(((e,n,{current:t})=>(s((t=>ce(e,n,t,c))),f.current=X(X({},f.current),{},{[e]:t}),()=>{s((n=>o(n,e))),f.current=o(f.current,e)})),[c]),y=E(((e,t)=>{s((r=>{const o=null!=t?t:!r[e],i=ce(e,o,r,c);return n().then((()=>{for(const e in r){const n=f.current[e];n&&r[e]!=i[e]&&n(i[e])}})),i}))}),[c]),m=E(((e,n)=>{var t;return null!==(t=d[e])&&void 0!==t?t:n}),[d]),O=E((e=>{if(e)e in d&&y(e);else if(!c)for(const e in d)y(e)}),[d,y,c]),P=E((e=>{if(e)m(e,!0)||y(e);else if(!c)for(const e in d)m(e,!0)||y(e)}),[d,y,m,c]),S=E((e=>{if(e)m(e,!1)&&y(e);else for(const e in d)m(e,!1)&&y(e)}),[d,y,m]);!function(e,n,t){h(e,(()=>({toggle:O,expand:P,collapse:S})),t)}(t,0,[O,S,P]);const $=I((()=>({registerSection:b,toggleExpanded:y,isExpanded:m,animate:r,prefix:g})),[b,y,m,r,g]);return v(i,X({id:l},u),v(ee.Provider,{value:$},a))}));function ce(e,n,t,r){let o;if(r&&n){o={[e]:n};for(const n in t)n!=e&&(o[n]=!1)}else o=X(X({},t),{},{[e]:n});return o}function le(e){let{animate:t=!1,as:r="section",children:o,expanded:i=!1,id:a,onExpandStateChange:c}=e,l=_(e,K);const{0:u}=x(oe),d=a||u,{0:s}=x(ie),{0:f,1:p}=x(i),{0:h,1:g}=x(null),{0:b,1:y}=x(null),{animate:m,isExpanded:O,prefix:j,registerSection:$,toggleExpanded:z}=S(ee),H=O?O(d,i):f,M=null!=m?m:t,N=h||`${j||"a"}-content-${d}-${s}`,Y=b||`${j||"a"}-header-${d}-${s}`,k=w(null);k.current=c,P((()=>{if($)return $(d,i,k)}),[$,d,i]);const C=E((e=>{z?z(d,e):p((t=>{const r=null!=e?e:!t;return n().then((()=>{const e=k.current;e&&e(r)})),r}))}),[d,z]),D=I((()=>({animate:M,contentId:N,headerId:Y,expanded:H,toggleHandler:C,setContentId:g,setHeaderId:y})),[M,N,Y,H,C]);return v(r,X(X({},l),{},{expanded:H}),v(ne.Provider,{value:D},o))}function ue(e){let{as:n="div",children:t,className:r="",id:o,role:i="button",tabIndex:a=0}=e,c=_(e,Q);const{contentId:l,expanded:u,headerId:d,setHeaderId:s,toggleHandler:f}=S(ne);return P((()=>{s&&s(o)}),[s,o]),v(n,X(X({},c),{},{id:d,role:i,className:`${r} section-child-00fce3c header-00fce3c`,tabIndex:a,"aria-controls":l,onClick:()=>f(),"aria-expanded":String(u)}),t)}function de(e){let{as:n="div",children:t,className:r="",id:o,role:i="region"}=e,a=_(e,R);const c=w(null),l=w(!1),{animate:u,contentId:d,expanded:s,headerId:f,setContentId:p}=S(ne);return j((()=>(l.current=!0,()=>l.current=!1)),[]),P((()=>{p&&p(o)}),[p,o]),P((()=>{const e=l.current,n=c.current;if(u&&e&&n&&n.animate)return s?function(e){return F(e,(()=>{const n=V(e,"height"),t=V(e,"opacity"),r=V(e,"overflowY");q(e,{height:0,opacity:0,overflowY:"auto"});const o=e.scrollHeight;q(e,{height:n,opacity:t,overflowY:r});const i=G(o);return e.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})}))}(n):function(e){return F(e,(()=>{const n=e.offsetHeight,t=G(n);return e.animate([{height:n+"px",opacity:1,overflowY:"hidden"},{height:"0",opacity:0,overflowY:"hidden"}],{easing:"cubic-bezier(0.39, 0.575, 0.565, 1)",duration:t})}))}(n)}),[s,u]),v(A,{renderable:s},v(n,X(X({},a),{},{ref:c,className:r+" section-child-00fce3c"+(s?"":" content-hidden-00fce3c"),id:d,"aria-labelledby":f,role:i}),t))}ae.displayName="Accordion";export{ae as Accordion,de as AccordionContent,ue as AccordionHeader,le as AccordionSection}; | ||
var e;function n(){return e||(e=Promise.resolve(void 0))}bent;var{hasOwnProperty:t,toString:r}=Object.prototype;function o(e,n){return Object.keys(e).reduce(((t,r)=>(n.includes(r)||(t[r]=e[r]),t)),{})}import{cloneElement as i,createContext as a,createElement as c,createRef as l}from"react";import{hydrate as u,render as d}from"react-dom";import{useCallback as s,useContext as f,useEffect as p,useImperativeHandle as h,useLayoutEffect as g,useMemo as b,useRef as y,useState as m}from"react";function v(e,n,t){return c.apply(void 0,arguments)}function O(e){return a(e,void 0)}function x(e){return m(e)}function w(e){return y(e)}function j(e,n){p(e,n)}function P(e,n){g(e,n)}function S(e){return f(e)}function I(e,n){return b(e,n)}function E(e,n){return s(e,n)}import{Children as $,createPortal as z,forwardRef as H}from"react";var M,N,Y=["auto","lazy","eager","unload"],k={auto:0,lazy:1,eager:2,unload:3};function C(e,n){const t=k[e]||0,r=k[n]||0,o=Math.max(t,r);return Y[o]}function D(){return M||(M=O({renderable:!0,playable:!0,loading:"auto"}))}function A({children:e,loading:n="auto",notify:t,playable:r=!0,renderable:o=!0}){let i=n,a=r,c=o;const l=S(D()),u=c&&l.renderable,d=u&&a&&l.playable,s=C(u?"auto":"lazy",C(i,l.loading)),f=t||l.notify,p=I((()=>({renderable:u,playable:d,loading:s,notify:f})),[u,d,s,f]);return v(D().Provider,{children:e,value:p})}var L=["Webkit","webkit","Moz","moz","ms","O","o"];function W(e,n,t){if(B(n))return n;N||(N=Object.create(null));let r=N[n];if(!r||t){if(r=n,void 0===e[n]){const t=function(e,n){for(let t=0;t<L.length;t++){const r=L[t]+n;if(void 0!==e[r])return r}return""}(e,function(e){return e.charAt(0).toUpperCase()+e.slice(1)}(n));void 0!==e[t]&&(r=t)}t||(N[n]=r)}return r}function U(e,n,t,r,o){const i=W(e.style,n,o);if(!i)return;const a=r?t+r:t;B(i)?e.style.setProperty(i,a):e.style[i]=a}function V(e,n,t){const r=W(e.style,n,t);if(r)return B(r)?e.style.getPropertyValue(r):e.style[r]}function q(e,n){for(const t in n)U(e,t,n[t])}function B(e){return e.startsWith("--")}function F(e,n,t){let r=t;e.classList.add("i-amphtml-animating");let o=n();return o.onfinish=o.oncancel=()=>{o=null,r&&r(),e.classList.remove("i-amphtml-animating")},()=>{o&&o.cancel()}}function G(e){const n=window.innerHeight,t=Math.abs(e)/n*500;return Math.min(Math.max(t,200),500)}var J=["animate","as","children","expandSingleSection","id"],K=["animate","as","children","expanded","id","onExpandStateChange"],Q=["as","children","className","id","role","tabIndex"],R=["as","children","className","id","role"];function T(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function X(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?T(Object(t),!0).forEach((function(n){Z(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):T(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}function Z(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function _(e,n){if(null==e)return{};var t,r,o=function(e,n){if(null==e)return{};var t,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)t=i[r],n.indexOf(t)>=0||(o[t]=e[t]);return o}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)t=i[r],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var ee=O({}),ne=O({}),te={},re={},oe=function(){let e=0;return()=>String(++e)}(),ie=()=>String(Math.floor(1e5*Math.random())),ae=H((function(e,t){let{animate:r=!1,as:i="section",children:a,expandSingleSection:c=!1,id:l}=e,u=_(e,J);const[d,s]=x(te),f=w(re),[p]=x(ie),g=l||`a${p}`;j((()=>{c&&s((e=>{const n={};let t=0;for(const r in e)n[r]=e[r]&&0==t++;return n}))}),[c]);const b=E(((e,n,{current:t})=>(s((t=>ce(e,n,t,c))),f.current=X(X({},f.current),{},{[e]:t}),()=>{s((n=>o(n,e))),f.current=o(f.current,e)})),[c]),y=E(((e,t)=>{s((r=>{const o=null!=t?t:!r[e],i=ce(e,o,r,c);return n().then((()=>{for(const e in r){const n=f.current[e];n&&r[e]!=i[e]&&n(i[e])}})),i}))}),[c]),m=E(((e,n)=>{var t;return null!==(t=d[e])&&void 0!==t?t:n}),[d]),O=E((e=>{if(e)e in d&&y(e);else if(!c)for(const e in d)y(e)}),[d,y,c]),P=E((e=>{if(e)m(e,!0)||y(e);else if(!c)for(const e in d)m(e,!0)||y(e)}),[d,y,m,c]),S=E((e=>{if(e)m(e,!1)&&y(e);else for(const e in d)m(e,!1)&&y(e)}),[d,y,m]);!function(e,n,t){h(e,(()=>({toggle:O,expand:P,collapse:S})),t)}(t,0,[O,S,P]);const $=I((()=>({registerSection:b,toggleExpanded:y,isExpanded:m,animate:r,prefix:g})),[b,y,m,r,g]);return v(i,X({id:l},u),v(ee.Provider,{value:$},a))}));function ce(e,n,t,r){let o;if(r&&n){o={[e]:n};for(const n in t)n!=e&&(o[n]=!1)}else o=X(X({},t),{},{[e]:n});return o}function le(e){let{animate:t=!1,as:r="section",children:o,expanded:i=!1,id:a,onExpandStateChange:c}=e,l=_(e,K);const[u]=x(oe),d=a||u,[s]=x(ie),[f,p]=x(i),[h,g]=x(null),[b,y]=x(null),{animate:m,isExpanded:O,prefix:j,registerSection:$,toggleExpanded:z}=S(ee),H=O?O(d,i):f,M=null!=m?m:t,N=h||`${j||"a"}-content-${d}-${s}`,Y=b||`${j||"a"}-header-${d}-${s}`,k=w(null);k.current=c,P((()=>{if($)return $(d,i,k)}),[$,d,i]);const C=E((e=>{z?z(d,e):p((t=>{const r=null!=e?e:!t;return n().then((()=>{const e=k.current;e&&e(r)})),r}))}),[d,z]),D=I((()=>({animate:M,contentId:N,headerId:Y,expanded:H,toggleHandler:C,setContentId:g,setHeaderId:y})),[M,N,Y,H,C]);return v(r,X(X({},l),{},{expanded:H}),v(ne.Provider,{value:D},o))}function ue(e){let{as:n="div",children:t,className:r="",id:o,role:i="button",tabIndex:a=0}=e,c=_(e,Q);const{contentId:l,expanded:u,headerId:d,setHeaderId:s,toggleHandler:f}=S(ne);return P((()=>{s&&s(o)}),[s,o]),v(n,X(X({},c),{},{id:d,role:i,className:`${r} section-child-00fce3c header-00fce3c`,tabIndex:a,"aria-controls":l,onClick:()=>f(),"aria-expanded":String(u)}),t)}function de(e){let{as:n="div",children:t,className:r="",id:o,role:i="region"}=e,a=_(e,R);const c=w(null),l=w(!1),{animate:u,contentId:d,expanded:s,headerId:f,setContentId:p}=S(ne);return j((()=>(l.current=!0,()=>l.current=!1)),[]),P((()=>{p&&p(o)}),[p,o]),P((()=>{const e=l.current,n=c.current;if(u&&e&&n&&n.animate)return s?function(e){return F(e,(()=>{const n=V(e,"height"),t=V(e,"opacity"),r=V(e,"overflowY");q(e,{height:0,opacity:0,overflowY:"auto"});const o=e.scrollHeight;q(e,{height:n,opacity:t,overflowY:r});const i=G(o);return e.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})}))}(n):function(e){return F(e,(()=>{const n=e.offsetHeight,t=G(n);return e.animate([{height:n+"px",opacity:1,overflowY:"hidden"},{height:"0",opacity:0,overflowY:"hidden"}],{easing:"cubic-bezier(0.39, 0.575, 0.565, 1)",duration:t})}))}(n)}),[s,u]),v(A,{renderable:s},v(n,X(X({},a),{},{ref:c,className:r+" section-child-00fce3c"+(s?"":" content-hidden-00fce3c"),id:d,"aria-labelledby":f,role:i}),t))}ae.displayName="Accordion";export{ae as Accordion,de as AccordionContent,ue as AccordionHeader,le as AccordionSection}; |
{ | ||
"name": "@ampproject/amp-accordion", | ||
"version": "1.2108132216.0", | ||
"version": "1.2108170213.0", | ||
"description": "AMP HTML amp-accordion Component", | ||
@@ -5,0 +5,0 @@ "author": "The AMP HTML Authors", |
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
660950