@ampproject/amp-accordion
Advanced tools
Comparing version 1.2110192227.0 to 1.2110202310.0
@@ -1,1 +0,1 @@ | ||
var n;function e(){return n||(n=Promise.resolve(void 0))}function t(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function r(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),t.push.apply(t,r)}return t}function o(n){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?r(Object(i),!0).forEach((function(e){t(n,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(i)):r(Object(i)).forEach((function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(i,e))}))}return n}function i(n,e){if(null==n)return{};var t,r,i={},o=Object.keys(n);for(r=0;r<o.length;r++)t=o[r],e.indexOf(t)>=0||(i[t]=n[t]);return i}var{hasOwnProperty:c,toString:a}=Object.prototype;function u(n,e){return Object.keys(n).reduce(((t,r)=>(e.includes(r)||(t[r]=n[r]),t)),{})}import{cloneElement as l,createContext as d,createElement as f,createRef as s}from"react";import{hydrate as h,render as p}from"react-dom";import{useCallback as b,useContext as g,useEffect as v,useImperativeHandle as m,useLayoutEffect as x,useMemo as O,useRef as y,useState as j}from"react";function I(n,e,t){return f.apply(void 0,arguments)}function w(n){return d(n,void 0)}function S(n){return j(n)}function $(n){return y(n)}function z(n,e){v(n,e)}function M(n,e){x(n,e)}function Y(n){return g(n)}function E(n,e){return O(n,e)}function C(n,e){return b(n,e)}import{Children as k,createPortal as H,forwardRef as P}from"react";var A,W,q=["auto","lazy","eager","unload"],B={auto:0,lazy:1,eager:2,unload:3};function D(n,e){const t=B[n]||0,r=B[e]||0,i=Math.max(t,r);return q[i]}function F(){return A||(A=w({renderable:!0,playable:!0,loading:"auto"}))}function G({children:n,loading:e="auto",notify:t,playable:r=!0,renderable:i=!0}){const o=Y(F()),c=i&&o.renderable,a=c&&r&&o.playable,u=D(c?"auto":"lazy",D(e,o.loading)),l=t||o.notify,d=E((()=>({renderable:c,playable:a,loading:u,notify:l})),[c,a,u,l]);return I(F().Provider,{children:n,value:d})}var J=["Webkit","webkit","Moz","moz","ms","O","o"];function K(n,e,t){if(R(e))return e;W||(W=Object.create(null));let r=W[e];if(!r||t){if(r=e,void 0===n[e]){const t=function(n){return n.charAt(0).toUpperCase()+n.slice(1)}(e),i=function(n,e){for(let t=0;t<J.length;t++){const r=J[t]+e;if(void 0!==n[r])return r}return""}(n,t);void 0!==n[i]&&(r=i)}t||(W[e]=r)}return r}function L(n,e,t,r,i){const o=K(n.style,e,i);if(!o)return;const c=r?t+r:t;R(o)?n.style.setProperty(o,c):n.style[o]=c}function N(n,e,t){const r=K(n.style,e,t);if(r)return R(r)?n.style.getPropertyValue(r):n.style[r]}function Q(n,e){for(const t in e)L(n,t,e[t])}function R(n){return n.startsWith("--")}function T(n,e,t){n.classList.add("i-amphtml-animating");let r=e();return r.onfinish=r.oncancel=()=>{r=null,t&&t(),n.classList.remove("i-amphtml-animating")},()=>{r&&r.cancel()}}function U(n){const e=window.innerHeight,t=Math.abs(n)/e*500;return Math.min(Math.max(t,200),500)}var V=["animate","as","children","expandSingleSection","id"],X=["animate","as","children","expanded","id","onExpandStateChange"],Z=["as","children","class","id","role","tabIndex"],_=["as","children","class","id","role"],nn=w({}),en=w({}),tn={},rn={},on=function(){let n=0;return()=>String(++n)}(),cn=()=>String(Math.floor(1e5*Math.random())),an=P((function(n,t){let{animate:r=!1,as:c="section",children:a,expandSingleSection:l=!1,id:d}=n,f=i(n,V);const[s,h]=S(tn),b=$(rn),[g]=S(cn),p=d||`a${g}`;z((()=>{l&&h((n=>{const e={};let t=0;for(const r in n)e[r]=n[r]&&0==t++;return e}))}),[l]);const v=C(((n,e,{current:t})=>(h((t=>un(n,e,t,l))),b.current=o(o({},b.current),{},{[n]:t}),()=>{h((e=>u(e,n))),b.current=u(b.current,n)})),[l]),x=C(((n,t)=>{h((r=>{const i=null!=t?t:!r[n],o=un(n,i,r,l);return e().then((()=>{for(const n in r){const e=b.current[n];e&&r[n]!=o[n]&&e(o[n])}})),o}))}),[l]),O=C(((n,e)=>{var t;return null!==(t=s[n])&&void 0!==t?t:e}),[s]),y=C((n=>{if(n)n in s&&x(n);else if(!l)for(const n in s)x(n)}),[s,x,l]),j=C((n=>{if(n)O(n,!0)||x(n);else if(!l)for(const n in s)O(n,!0)||x(n)}),[s,x,O,l]),w=C((n=>{if(n)O(n,!1)&&x(n);else for(const n in s)O(n,!1)&&x(n)}),[s,x,O]);!function(n,e,t){m(n,(()=>({toggle:y,expand:j,collapse:w})),t)}(t,0,[y,w,j]);const M=E((()=>({registerSection:v,toggleExpanded:x,isExpanded:O,animate:r,prefix:p})),[v,x,O,r,p]);return I(c,o({id:d},f),I(nn.Provider,{value:M},a))}));function un(n,e,t,r){let i;if(r&&e){i={[n]:e};for(const e in t)e!=n&&(i[e]=!1)}else i=o(o({},t),{},{[n]:e});return i}function ln(n){let{animate:t=!1,as:r="section",children:c,expanded:a=!1,id:u,onExpandStateChange:l}=n,d=i(n,X);const[f]=S(on),s=u||f,[h]=S(cn),[b,g]=S(a),[p,v]=S(null),[m,x]=S(null),{animate:O,isExpanded:y,prefix:j,registerSection:w,toggleExpanded:z}=Y(nn),H=y?y(s,a):b,k=null!=O?O:t,P=p||`${j||"a"}-content-${s}-${h}`,A=m||`${j||"a"}-header-${s}-${h}`,W=$(null);W.current=l,M((()=>{if(w)return w(s,a,W)}),[w,s,a]);const q=C((n=>{z?z(s,n):g((t=>{const r=null!=n?n:!t;return e().then((()=>{const n=W.current;n&&n(r)})),r}))}),[s,z]),B=E((()=>({animate:k,contentId:P,headerId:A,expanded:H,toggleHandler:q,setContentId:v,setHeaderId:x})),[k,P,A,H,q]);return I(r,o({},d),I(en.Provider,{value:B},c))}function dn(n){let{as:e="div",children:t,"class":r="",id:c,role:a="button",tabIndex:u=0}=n,l=i(n,Z);const{contentId:d,expanded:f,headerId:s,setHeaderId:h,toggleHandler:b}=Y(en);return M((()=>{h&&h(c)}),[h,c]),I(e,o(o({},l),{},{id:s,role:a,class:`${r} section-child-00fce3c header-00fce3c`,tabIndex:u,"aria-controls":d,onClick:()=>b(),"aria-expanded":String(f)}),t)}function fn(n){let{as:e="div",children:t,"class":r="",id:c,role:a="region"}=n,u=i(n,_);const l=$(null),d=$(!1),{animate:f,contentId:s,expanded:h,headerId:b,setContentId:g}=Y(en);return z((()=>(d.current=!0,()=>d.current=!1)),[]),M((()=>{g&&g(c)}),[g,c]),M((()=>{const n=d.current,e=l.current;if(f&&n&&e&&e.animate)return h?function(n){return T(n,(()=>{const e=N(n,"height"),t=N(n,"opacity"),r=N(n,"overflowY");Q(n,{height:0,opacity:0,overflowY:"auto"});const i=n.scrollHeight;Q(n,{height:e,opacity:t,overflowY:r});const o=U(i);return n.animate([{height:0,opacity:0,overflowY:"hidden"},{height:i+"px",opacity:1,overflowY:"hidden"}],{easing:"cubic-bezier(0.47, 0, 0.745, 0.715)",duration:o})}))}(e):function(n){return T(n,(()=>{const e=n.offsetHeight,t=U(e);return n.animate([{height:e+"px",opacity:1,overflowY:"hidden"},{height:"0",opacity:0,overflowY:"hidden"}],{easing:"cubic-bezier(0.39, 0.575, 0.565, 1)",duration:t})}))}(e)}),[h,f]),I(G,{renderable:h},I(e,o(o({},u),{},{ref:l,class:r+" section-child-00fce3c"+(h?"":" content-hidden-00fce3c"),id:s,"aria-labelledby":b,role:a}),t))}an.displayName="Accordion";export{an as BentoAccordion,fn as BentoAccordionContent,dn as BentoAccordionHeader,ln as BentoAccordionSection}; | ||
var n;function e(){return n||(n=Promise.resolve(void 0))}function t(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function r(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),t.push.apply(t,r)}return t}function i(n){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?r(Object(i),!0).forEach((function(e){t(n,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(i)):r(Object(i)).forEach((function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(i,e))}))}return n}function o(n,e){if(null==n)return{};var t,r,i={},o=Object.keys(n);for(r=0;r<o.length;r++)t=o[r],e.indexOf(t)>=0||(i[t]=n[t]);return i}var{hasOwnProperty:c,toString:a}=Object.prototype;function u(n,e){return Object.keys(n).reduce(((t,r)=>(e.includes(r)||(t[r]=n[r]),t)),{})}import{cloneElement as l,createContext as d,createElement as f,createRef as s}from"react";import{hydrate as h,render as b}from"react-dom";import{useCallback as g,useContext as p,useEffect as v,useImperativeHandle as m,useLayoutEffect as x,useMemo as O,useRef as y,useState as j}from"react";function I(n,e,t){return f.apply(void 0,arguments)}function w(n){return d(n,void 0)}function S(n){return j(n)}function $(n){return y(n)}function z(n,e){v(n,e)}function M(n,e){x(n,e)}function Y(n){return p(n)}function E(n,e){return O(n,e)}function C(n,e){return g(n,e)}import{Children as H,createPortal as k,forwardRef as P}from"react";var A,W,q=["auto","lazy","eager","unload"],B={auto:0,lazy:1,eager:2,unload:3};function D(n,e){const t=B[n]||0,r=B[e]||0,i=Math.max(t,r);return q[i]}function F(){return A||(A=w({renderable:!0,playable:!0,loading:"auto"}))}function G({children:n,loading:e="auto",notify:t,playable:r=!0,renderable:i=!0}){const o=Y(F()),c=i&&o.renderable,a=c&&r&&o.playable,u=D(c?"auto":"lazy",D(e,o.loading)),l=t||o.notify,d=E((()=>({renderable:c,playable:a,loading:u,notify:l})),[c,a,u,l]);return I(F().Provider,{children:n,value:d})}var J=["Webkit","webkit","Moz","moz","ms","O","o"];function K(n,e,t){if(R(e))return e;W||(W=Object.create(null));let r=W[e];if(!r||t){if(r=e,void 0===n[e]){const t=function(n){return n.charAt(0).toUpperCase()+n.slice(1)}(e),i=function(n,e){for(let t=0;t<J.length;t++){const r=J[t]+e;if(void 0!==n[r])return r}return""}(n,t);void 0!==n[i]&&(r=i)}t||(W[e]=r)}return r}function L(n,e,t,r,i){const o=K(n.style,e,i);if(!o)return;const c=r?t+r:t;R(o)?n.style.setProperty(o,c):n.style[o]=c}function N(n,e,t){const r=K(n.style,e,t);if(r)return R(r)?n.style.getPropertyValue(r):n.style[r]}function Q(n,e){for(const t in e)L(n,t,e[t])}function R(n){return n.startsWith("--")}function T(n,e,t){n.classList.add("i-amphtml-animating");let r=e();return r.onfinish=r.oncancel=()=>{r=null,t&&t(),n.classList.remove("i-amphtml-animating")},()=>{r&&r.cancel()}}function U(n){const e=window.innerHeight,t=Math.abs(n)/e*500;return Math.min(Math.max(t,200),500)}var V=["animate","as","children","expandSingleSection","id"],X=["animate","as","children","expanded","id","onExpandStateChange"],Z=["as","children","class","id","role","tabIndex"],_=["as","children","class","id","role"],nn=w({}),en=w({}),tn={},rn={},on=function(){let n=0;return()=>String(++n)}(),cn=()=>String(Math.floor(1e5*Math.random())),an=P((function(n,t){let{animate:r=!1,as:c="section",children:a,expandSingleSection:l=!1,id:d}=n,f=o(n,V);const[s,h]=S(tn),b=$(rn),[g]=S(cn),p=d||`a${g}`;z((()=>{l&&h((n=>{const e={};let t=0;for(const r in n)e[r]=n[r]&&0==t++;return e}))}),[l]);const v=C(((n,e,{current:t})=>(h((t=>un(n,e,t,l))),b.current=i(i({},b.current),{},{[n]:t}),()=>{h((e=>u(e,n))),b.current=u(b.current,n)})),[l]),x=C(((n,t)=>{h((r=>{const i=null!=t?t:!r[n],o=un(n,i,r,l);return e().then((()=>{for(const n in r){const e=b.current[n];e&&r[n]!=o[n]&&e(o[n])}})),o}))}),[l]),O=C(((n,e)=>{var t;return null!==(t=s[n])&&void 0!==t?t:e}),[s]),y=C((n=>{if(n)n in s&&x(n);else if(!l)for(const n in s)x(n)}),[s,x,l]),j=C((n=>{if(n)O(n,!0)||x(n);else if(!l)for(const n in s)O(n,!0)||x(n)}),[s,x,O,l]),w=C((n=>{if(n)O(n,!1)&&x(n);else for(const n in s)O(n,!1)&&x(n)}),[s,x,O]);!function(n,e,t){m(n,(()=>({toggle:y,expand:j,collapse:w})),t)}(t,0,[y,w,j]);const M=E((()=>({registerSection:v,toggleExpanded:x,isExpanded:O,animate:r,prefix:p})),[v,x,O,r,p]);return I(c,i({id:d},f),I(nn.Provider,{value:M},a))}));function un(n,e,t,r){let o;if(r&&e){o={[n]:e};for(const e in t)e!=n&&(o[e]=!1)}else o=i(i({},t),{},{[n]:e});return o}function ln(n){let{animate:t=!1,as:r="section",children:c,expanded:a=!1,id:u,onExpandStateChange:l}=n,d=o(n,X);const[f]=S(on),s=u||f,[h]=S(cn),[b,g]=S(a),[p,v]=S(null),[m,x]=S(null),{animate:O,isExpanded:y,prefix:j,registerSection:w,toggleExpanded:z}=Y(nn),H=y?y(s,a):b,k=null!=O?O:t,P=p||`${j||"a"}-content-${s}-${h}`,A=m||`${j||"a"}-header-${s}-${h}`,W=$(null);W.current=l,M((()=>{if(w)return w(s,a,W)}),[w,s,a]);const q=C((n=>{z?z(s,n):g((t=>{const r=null!=n?n:!t;return e().then((()=>{const n=W.current;n&&n(r)})),r}))}),[s,z]),B=E((()=>({animate:k,contentId:P,headerId:A,expanded:H,toggleHandler:q,setContentId:v,setHeaderId:x})),[k,P,A,H,q]);return I(r,i({},d),I(en.Provider,{value:B},c))}function dn(n){let{as:e="div",children:t,"class":r="",id:c,role:a="button",tabIndex:u=0}=n,l=o(n,Z);const{contentId:d,expanded:f,headerId:s,setHeaderId:h,toggleHandler:b}=Y(en);return M((()=>{h&&h(c)}),[h,c]),I(e,i(i({},l),{},{id:s,role:a,class:`${r} section-child-00fce3c header-00fce3c`,tabIndex:u,"aria-controls":d,onClick:()=>b(),"aria-expanded":String(f)}),t)}function fn(n){let{as:e="div",children:t,"class":r="",id:c,role:a="region"}=n,u=o(n,_);const l=$(null),d=$(!1),{animate:f,contentId:s,expanded:h,headerId:b,setContentId:g}=Y(en);return z((()=>(d.current=!0,()=>d.current=!1)),[]),M((()=>{g&&g(c)}),[g,c]),M((()=>{const n=d.current,e=l.current;if(f&&n&&e&&e.animate)return h?function(n){return T(n,(()=>{const e=N(n,"height"),t=N(n,"opacity"),r=N(n,"overflowY");Q(n,{height:0,opacity:0,overflowY:"auto"});const i=n.scrollHeight;Q(n,{height:e,opacity:t,overflowY:r});const o=U(i);return n.animate([{height:0,opacity:0,overflowY:"hidden"},{height:i+"px",opacity:1,overflowY:"hidden"}],{easing:"cubic-bezier(0.47, 0, 0.745, 0.715)",duration:o})}))}(e):function(n){return T(n,(()=>{const e=n.offsetHeight,t=U(e);return n.animate([{height:e+"px",opacity:1,overflowY:"hidden"},{height:"0",opacity:0,overflowY:"hidden"}],{easing:"cubic-bezier(0.39, 0.575, 0.565, 1)",duration:t})}))}(e)}),[h,f]),I(G,{renderable:h},I(e,i(i({},u),{},{ref:l,class:r+" section-child-00fce3c"+(h?"":" content-hidden-00fce3c"),id:s,"aria-labelledby":b,role:a}),t))}an.displayName="Accordion";export{an as BentoAccordion,fn as BentoAccordionContent,dn as BentoAccordionHeader,ln as BentoAccordionSection}; |
{ | ||
"name": "@ampproject/amp-accordion", | ||
"version": "1.2110192227.0", | ||
"version": "1.2110202310.0", | ||
"description": "AMP HTML amp-accordion Component", | ||
@@ -5,0 +5,0 @@ "author": "The AMP HTML Authors", |
@@ -55,3 +55,3 @@ # Bento Accordion | ||
<head> | ||
<script src="https://cdn.ampproject.org/custom-elements-polyfill.js"></script> | ||
<script async src="https://cdn.ampproject.org/bento.js"></script> | ||
<script async src="https://cdn.ampproject.org/v0/bento-accordion-1.0.js"></script> | ||
@@ -58,0 +58,0 @@ <link rel="stylesheet" type="text/css" href="https://cdn.ampproject.org/v0/amp-accordion-1.0.css"> |
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
415772