@ampproject/amp-accordion
Advanced tools
Comparing version 1.2109222204.0 to 1.2110011758.0
@@ -1,1 +0,1 @@ | ||
var __create=Object.create,__defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty,__markAsModule=function(e){return __defProp(e,"__esModule",{value:!0})},__export=function(e,t){for(var r in __markAsModule(e),t)__defProp(e,r,{get:t[r],enumerable:!0})},__reExport=function(e,t,r){if(t&&"object"==typeof t||"function"==typeof t)for(var n,o=__getOwnPropNames(t),a=0,i=o.length;a<i;a++)n=o[a],__hasOwnProp.call(e,n)||"default"===n||__defProp(e,n,{get:function(e){return t[e]}.bind(null,n),enumerable:!(r=__getOwnPropDesc(t,n))||r.enumerable});return e},__toModule=function(e){return __reExport(__markAsModule(__defProp(null!=e?__create(__getProtoOf(e)):{},"default",e&&e.__esModule&&"default"in e?{get:function(){return e.default},enumerable:!0}:{value:e,enumerable:!0})),e)};__export(exports,{BentoAccordion:function(){return BentoAccordion},BentoAccordionContent:function(){return BentoAccordionContent},BentoAccordionHeader:function(){return BentoAccordionHeader},BentoAccordionSection:function(){return BentoAccordionSection}});var resolved,$sectionChild="section-child-00fce3c",$header="header-00fce3c",$contentHidden="content-hidden-00fce3c";function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function resolvedPromise(){return resolved||(resolved=Promise.resolve(void 0))}function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function _objectSpread2(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _iterableToArrayLimit(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a=[],i=!0,c=!1;try{for(r=r.call(e);!(i=(n=r.next()).done)&&(a.push(n.value),!t||a.length!==t);i=!0);}catch(e){c=!0,o=e}finally{try{i||null==r.return||r.return()}finally{if(c)throw o}}return a}}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray(e,t)||_nonIterableRest()}function _objectWithoutPropertiesLoose(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}function sequentialIdGenerator(){var e=0;return function(){return String(++e)}}function randomIdGenerator(e){return function(){return String(Math.floor(Math.random()*e))}}var _Object$prototype=Object.prototype,hasOwn_=_Object$prototype.hasOwnProperty,toString_=_Object$prototype.toString;function map(e){var t=Object.create(null);return e&&Object.assign(t,e),t}function omit(e,t){return Object.keys(e).reduce((function(r,n){return t.includes(n)||(r[n]=e[n]),r}),{})}var preact=__toModule(require("preact")),preactDOM=__toModule(require("preact")),hooks=__toModule(require("preact/hooks"));function createElement2(e,t,r){return preact.createElement.apply(void 0,arguments)}function createContext2(e){return preact.createContext(e,void 0)}function useState2(e){return hooks.useState(e)}function useRef2(e){return hooks.useRef(e)}function useEffect2(e,t){hooks.useEffect(e,t)}function useLayoutEffect2(e,t){hooks.useLayoutEffect(e,t)}function useContext2(e){return hooks.useContext(e)}function useMemo2(e,t){return hooks.useMemo(e,t)}function useCallback2(e,t){return hooks.useCallback(e,t)}function useImperativeHandle2(e,t,r){return hooks.useImperativeHandle(e,t,r)}var _MAP,compat=__toModule(require("preact/compat"));function forwardRef2(e){return compat.forwardRef(e)}var context,Loading={AUTO:"auto",LAZY:"lazy",EAGER:"eager",UNLOAD:"unload"},ORDER=[Loading.AUTO,Loading.LAZY,Loading.EAGER,Loading.UNLOAD],MAP=(_defineProperty(_MAP={},Loading.AUTO,0),_defineProperty(_MAP,Loading.LAZY,1),_defineProperty(_MAP,Loading.EAGER,2),_defineProperty(_MAP,Loading.UNLOAD,3),_MAP);function reducer(e,t){var r=MAP[e]||0,n=MAP[t]||0,o=Math.max(r,n);return ORDER[o]}function getAmpContext(){return context||(context=createContext2({renderable:!0,playable:!0,loading:Loading.AUTO}))}function WithAmpContext(e){var t=e.children,r=e.loading,n=void 0===r?"auto":r,o=e.notify,a=e.playable,i=void 0===a||a,c=e.renderable,u=void 0===c||c,d=useAmpContext(),l=u&&d.renderable,s=l&&i&&d.playable,f=reducer(l?Loading.AUTO:Loading.LAZY,reducer(n,d.loading)),p=o||d.notify,_=useMemo2((function(){return{renderable:l,playable:s,loading:f,notify:p}}),[l,s,f,p]);return createElement2(getAmpContext().Provider,{children:t,value:_})}function useAmpContext(){return useContext2(getAmpContext())}var propertyNameCache,isArray=Array.isArray,vendorPrefixes=["Webkit","webkit","Moz","moz","ms","O","o"];function camelCaseToTitleCase(e){return e.charAt(0).toUpperCase()+e.slice(1)}function getVendorJsPropertyName_(e,t){for(var r=0;r<vendorPrefixes.length;r++){var n=vendorPrefixes[r]+t;if(void 0!==e[n])return n}return""}function getVendorJsPropertyName(e,t,r){if(isVar(t))return t;propertyNameCache||(propertyNameCache=map());var n=propertyNameCache[t];if(!n||r){if(n=t,void 0===e[t]){var o=getVendorJsPropertyName_(e,camelCaseToTitleCase(t));void 0!==e[o]&&(n=o)}r||(propertyNameCache[t]=n)}return n}function setStyle(e,t,r,n,o){var a=getVendorJsPropertyName(e.style,t,o);if(a){var i=n?r+n:r;isVar(a)?e.style.setProperty(a,i):e.style[a]=i}}function getStyle(e,t,r){var n=getVendorJsPropertyName(e.style,t,r);if(n)return isVar(n)?e.style.getPropertyValue(n):e.style[n]}function setStyles(e,t){for(var r in t)setStyle(e,r,t[r])}function isVar(e){return e.startsWith("--")}var MAX_TRANSITION_DURATION=500,MIN_TRANSITION_DURATION=200,EXPAND_CURVE="cubic-bezier(0.47, 0, 0.745, 0.715)",COLLAPSE_CURVE="cubic-bezier(0.39, 0.575, 0.565, 1)";function animateExpand(e){return animate(e,(function(){var t=getStyle(e,"height"),r=getStyle(e,"opacity"),n=getStyle(e,"overflowY");setStyles(e,{height:0,opacity:0,overflowY:"auto"});var o=e.scrollHeight;setStyles(e,{height:t,opacity:r,overflowY:n});var a=getTransitionDuration(o);return e.animate([{height:0,opacity:0,overflowY:"hidden"},{height:o+"px",opacity:1,overflowY:"hidden"}],{easing:EXPAND_CURVE,duration:a})}))}function animateCollapse(e){return animate(e,(function(){var t=e.offsetHeight,r=getTransitionDuration(t);return e.animate([{height:t+"px",opacity:1,overflowY:"hidden"},{height:"0",opacity:0,overflowY:"hidden"}],{easing:COLLAPSE_CURVE,duration:r})}))}function animate(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;e.classList.add("i-amphtml-animating");var n=t();return n.onfinish=n.oncancel=function(){n=null,r&&r(),e.classList.remove("i-amphtml-animating")},function(){n&&n.cancel()}}function getTransitionDuration(e){var t=window.innerHeight,r=Math.abs(e)/t*MAX_TRANSITION_DURATION;return Math.min(Math.max(r,MIN_TRANSITION_DURATION),MAX_TRANSITION_DURATION)}var _excluded=["animate","as","children","expandSingleSection","id"],_excluded2=["animate","as","children","expanded","id","onExpandStateChange"],_excluded3=["as","children","class","id","role","tabIndex"],_excluded4=["as","children","class","id","role"],AccordionContext=createContext2({}),SectionContext=createContext2({}),EMPTY_EXPANDED_MAP={},EMPTY_EVENT_MAP={},generateSectionId=sequentialIdGenerator(),generateRandomId=randomIdGenerator(1e5);function BentoAccordionWithRef(e,t){var r=e.animate,n=void 0!==r&&r,o=e.as,a=void 0===o?"section":o,i=e.children,c=e.expandSingleSection,u=void 0!==c&&c,d=e.id,l=_objectWithoutPropertiesLoose(e,_excluded),s=_slicedToArray(useState2(EMPTY_EXPANDED_MAP),2),f=s[0],p=s[1],_=useRef2(EMPTY_EVENT_MAP),y=_slicedToArray(useState2(generateRandomId),1)[0],v=d||"a".concat(y);useEffect2((function(){u&&p((function(e){var t={},r=0;for(var n in e)t[n]=e[n]&&0==r++;return t}))}),[u]);var m=useCallback2((function(e,t,r){var n=r.current;return p((function(r){return setExpanded(e,t,r,u)})),_.current=_objectSpread2(_objectSpread2({},_.current),{},_defineProperty({},e,n)),function(){p((function(t){return omit(t,e)})),_.current=omit(_.current,e)}}),[u]),h=useCallback2((function(e,t){p((function(r){var n=null!=t?t:!r[e],o=setExpanded(e,n,r,u);return resolvedPromise().then((function(){for(var e in r){var t=_.current[e];t&&r[e]!=o[e]&&t(o[e])}})),o}))}),[u]),g=useCallback2((function(e,t){var r;return null!==(r=f[e])&&void 0!==r?r:t}),[f]),b=useCallback2((function(e){if(e)e in f&&h(e);else if(!u)for(var t in f)h(t)}),[f,h,u]),A=useCallback2((function(e){if(e)g(e,!0)||h(e);else if(!u)for(var t in f)g(t,!0)||h(t)}),[f,h,g,u]),P=useCallback2((function(e){if(e)g(e,!1)&&h(e);else for(var t in f)g(t,!1)&&h(t)}),[f,h,g]);useImperativeHandle2(t,(function(){return{toggle:b,expand:A,collapse:P}}),[b,P,A]);var x=useMemo2((function(){return{registerSection:m,toggleExpanded:h,isExpanded:g,animate:n,prefix:v}}),[m,h,g,n,v]);return createElement2(a,_objectSpread2({id:d},l),createElement2(AccordionContext.Provider,{value:x},i))}var BentoAccordion=forwardRef2(BentoAccordionWithRef);function setExpanded(e,t,r,n){var o;if(n&&t)for(var a in o=_defineProperty({},e,t),r)a!=e&&(o[a]=!1);else o=_objectSpread2(_objectSpread2({},r),{},_defineProperty({},e,t));return o}function BentoAccordionSection(e){var t=e.animate,r=void 0!==t&&t,n=e.as,o=void 0===n?"section":n,a=e.children,i=e.expanded,c=void 0!==i&&i,u=e.id,d=e.onExpandStateChange,l=_objectWithoutPropertiesLoose(e,_excluded2),s=_slicedToArray(useState2(generateSectionId),1)[0],f=u||s,p=_slicedToArray(useState2(generateRandomId),1)[0],_=_slicedToArray(useState2(c),2),y=_[0],v=_[1],m=_slicedToArray(useState2(null),2),h=m[0],g=m[1],b=_slicedToArray(useState2(null),2),A=b[0],P=b[1],x=useContext2(AccordionContext),O=x.animate,S=x.isExpanded,C=x.prefix,E=x.registerSection,I=x.toggleExpanded,T=S?S(f,c):y,j=null!=O?O:r,M=h||"".concat(C||"a","-content-").concat(f,"-").concat(p),L=A||"".concat(C||"a","-header-").concat(f,"-").concat(p),N=useRef2(null);N.current=d,useLayoutEffect2((function(){if(E)return E(f,c,N)}),[E,f,c]);var w=useCallback2((function(e){I?I(f,e):v((function(t){var r=null!=e?e:!t;return resolvedPromise().then((function(){var e=N.current;e&&e(r)})),r}))}),[f,I]),R=useMemo2((function(){return{animate:j,contentId:M,headerId:L,expanded:T,toggleHandler:w,setContentId:g,setHeaderId:P}}),[j,M,L,T,w]);return createElement2(o,_objectSpread2(_objectSpread2({},l),{},{expanded:T}),createElement2(SectionContext.Provider,{value:R},a))}function BentoAccordionHeader(e){var t=e.as,r=void 0===t?"div":t,n=e.children,o=e.class,a=void 0===o?"":o,i=e.id,c=e.role,u=void 0===c?"button":c,d=e.tabIndex,l=void 0===d?0:d,s=_objectWithoutPropertiesLoose(e,_excluded3),f=useContext2(SectionContext),p=f.contentId,_=f.expanded,y=f.headerId,v=f.setHeaderId,m=f.toggleHandler;return useLayoutEffect2((function(){v&&v(i)}),[v,i]),createElement2(r,_objectSpread2(_objectSpread2({},s),{},{id:y,role:u,class:"".concat(a," ").concat($sectionChild," ").concat($header),tabIndex:l,"aria-controls":p,onClick:function(){return m()},"aria-expanded":String(_)}),n)}function BentoAccordionContent(e){var t=e.as,r=void 0===t?"div":t,n=e.children,o=e.class,a=void 0===o?"":o,i=e.id,c=e.role,u=void 0===c?"region":c,d=_objectWithoutPropertiesLoose(e,_excluded4),l=useRef2(null),s=useRef2(!1),f=useContext2(SectionContext),p=f.animate,_=f.contentId,y=f.expanded,v=f.headerId,m=f.setContentId;return useEffect2((function(){return s.current=!0,function(){return s.current=!1}}),[]),useLayoutEffect2((function(){m&&m(i)}),[m,i]),useLayoutEffect2((function(){var e=s.current,t=l.current;if(p&&e&&t&&t.animate)return y?animateExpand(t):animateCollapse(t)}),[y,p]),createElement2(WithAmpContext,{renderable:y},createElement2(r,_objectSpread2(_objectSpread2({},d),{},{ref:l,class:a+" "+$sectionChild+(y?"":" "+$contentHidden),id:_,"aria-labelledby":v,role:u}),n))}BentoAccordion.displayName="Accordion"; | ||
var __create=Object.create,__defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty,__markAsModule=function(e){return __defProp(e,"__esModule",{value:!0})},__export=function(e,t){for(var n in __markAsModule(e),t)__defProp(e,n,{get:t[n],enumerable:!0})},__reExport=function(e,t,n){if(t&&"object"==typeof t||"function"==typeof t)for(var r,o=__getOwnPropNames(t),a=0,i=o.length;a<i;a++)r=o[a],__hasOwnProp.call(e,r)||"default"===r||__defProp(e,r,{get:function(e){return t[e]}.bind(null,r),enumerable:!(n=__getOwnPropDesc(t,r))||n.enumerable});return e},__toModule=function(e){return __reExport(__markAsModule(__defProp(null!=e?__create(__getProtoOf(e)):{},"default",e&&e.__esModule&&"default"in e?{get:function(){return e.default},enumerable:!0}:{value:e,enumerable:!0})),e)};__export(exports,{BentoAccordion:function(){return BentoAccordion},BentoAccordionContent:function(){return BentoAccordionContent},BentoAccordionHeader:function(){return BentoAccordionHeader},BentoAccordionSection:function(){return BentoAccordionSection}});var resolved,$sectionChild="section-child-00fce3c",$header="header-00fce3c",$contentHidden="content-hidden-00fce3c";function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(e,t):void 0}}function resolvedPromise(){return resolved||(resolved=Promise.resolve(void 0))}function _defineProperty(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ownKeys(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function _objectSpread2(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(n),!0).forEach((function(t){_defineProperty(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ownKeys(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _iterableToArrayLimit(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,a=[],i=!0,c=!1;try{for(n=n.call(e);!(i=(r=n.next()).done)&&(a.push(r.value),!t||a.length!==t);i=!0);}catch(e){c=!0,o=e}finally{try{i||null==n.return||n.return()}finally{if(c)throw o}}return a}}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray(e,t)||_nonIterableRest()}function _objectWithoutPropertiesLoose(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}function sequentialIdGenerator(){var e=0;return function(){return String(++e)}}function randomIdGenerator(e){return function(){return String(Math.floor(Math.random()*e))}}var _Object$prototype=Object.prototype,hasOwn_=_Object$prototype.hasOwnProperty,toString_=_Object$prototype.toString;function map(e){var t=Object.create(null);return e&&Object.assign(t,e),t}function omit(e,t){return Object.keys(e).reduce((function(n,r){return t.includes(r)||(n[r]=e[r]),n}),{})}var preact=__toModule(require("preact")),preactDOM=__toModule(require("preact")),hooks=__toModule(require("preact/hooks"));function createElement2(e,t,n){return preact.createElement.apply(void 0,arguments)}function createContext2(e){return preact.createContext(e,void 0)}function useState2(e){return hooks.useState(e)}function useRef2(e){return hooks.useRef(e)}function useEffect2(e,t){hooks.useEffect(e,t)}function useLayoutEffect2(e,t){hooks.useLayoutEffect(e,t)}function useContext2(e){return hooks.useContext(e)}function useMemo2(e,t){return hooks.useMemo(e,t)}function useCallback2(e,t){return hooks.useCallback(e,t)}function useImperativeHandle2(e,t,n){return hooks.useImperativeHandle(e,t,n)}var _MAP,compat=__toModule(require("preact/compat"));function forwardRef2(e){return compat.forwardRef(e)}var context,Loading={AUTO:"auto",LAZY:"lazy",EAGER:"eager",UNLOAD:"unload"},ORDER=[Loading.AUTO,Loading.LAZY,Loading.EAGER,Loading.UNLOAD],MAP=(_defineProperty(_MAP={},Loading.AUTO,0),_defineProperty(_MAP,Loading.LAZY,1),_defineProperty(_MAP,Loading.EAGER,2),_defineProperty(_MAP,Loading.UNLOAD,3),_MAP);function reducer(e,t){var n=MAP[e]||0,r=MAP[t]||0,o=Math.max(n,r);return ORDER[o]}function getAmpContext(){return context||(context=createContext2({renderable:!0,playable:!0,loading:Loading.AUTO}))}function WithAmpContext(e){var t=e.children,n=e.loading,r=void 0===n?"auto":n,o=e.notify,a=e.playable,i=void 0===a||a,c=e.renderable,u=void 0===c||c,d=useAmpContext(),l=u&&d.renderable,f=l&&i&&d.playable,s=reducer(l?Loading.AUTO:Loading.LAZY,reducer(r,d.loading)),_=o||d.notify,p=useMemo2((function(){return{renderable:l,playable:f,loading:s,notify:_}}),[l,f,s,_]);return createElement2(getAmpContext().Provider,{children:t,value:p})}function useAmpContext(){return useContext2(getAmpContext())}var propertyNameCache,isArray=Array.isArray,vendorPrefixes=["Webkit","webkit","Moz","moz","ms","O","o"];function camelCaseToTitleCase(e){return e.charAt(0).toUpperCase()+e.slice(1)}function getVendorJsPropertyName_(e,t){for(var n=0;n<vendorPrefixes.length;n++){var r=vendorPrefixes[n]+t;if(void 0!==e[r])return r}return""}function getVendorJsPropertyName(e,t,n){if(isVar(t))return t;propertyNameCache||(propertyNameCache=map());var r=propertyNameCache[t];if(!r||n){if(r=t,void 0===e[t]){var o=getVendorJsPropertyName_(e,camelCaseToTitleCase(t));void 0!==e[o]&&(r=o)}n||(propertyNameCache[t]=r)}return r}function setStyle(e,t,n,r,o){var a=getVendorJsPropertyName(e.style,t,o);if(a){var i=r?n+r:n;isVar(a)?e.style.setProperty(a,i):e.style[a]=i}}function getStyle(e,t,n){var r=getVendorJsPropertyName(e.style,t,n);if(r)return isVar(r)?e.style.getPropertyValue(r):e.style[r]}function setStyles(e,t){for(var n in t)setStyle(e,n,t[n])}function isVar(e){return e.startsWith("--")}var MAX_TRANSITION_DURATION=500,MIN_TRANSITION_DURATION=200,EXPAND_CURVE="cubic-bezier(0.47, 0, 0.745, 0.715)",COLLAPSE_CURVE="cubic-bezier(0.39, 0.575, 0.565, 1)";function animateExpand(e){return animate(e,(function(){var t=getStyle(e,"height"),n=getStyle(e,"opacity"),r=getStyle(e,"overflowY");setStyles(e,{height:0,opacity:0,overflowY:"auto"});var o=e.scrollHeight;setStyles(e,{height:t,opacity:n,overflowY:r});var a=getTransitionDuration(o);return e.animate([{height:0,opacity:0,overflowY:"hidden"},{height:o+"px",opacity:1,overflowY:"hidden"}],{easing:EXPAND_CURVE,duration:a})}))}function animateCollapse(e){return animate(e,(function(){var t=e.offsetHeight,n=getTransitionDuration(t);return e.animate([{height:t+"px",opacity:1,overflowY:"hidden"},{height:"0",opacity:0,overflowY:"hidden"}],{easing:COLLAPSE_CURVE,duration:n})}))}function animate(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;e.classList.add("i-amphtml-animating");var r=t();return r.onfinish=r.oncancel=function(){r=null,n&&n(),e.classList.remove("i-amphtml-animating")},function(){r&&r.cancel()}}function getTransitionDuration(e){var t=window.innerHeight,n=Math.abs(e)/t*MAX_TRANSITION_DURATION;return Math.min(Math.max(n,MIN_TRANSITION_DURATION),MAX_TRANSITION_DURATION)}var _excluded=["animate","as","children","expandSingleSection","id"],_excluded2=["animate","as","children","expanded","id","onExpandStateChange"],_excluded3=["as","children","class","id","role","tabIndex"],_excluded4=["as","children","class","id","role"],AccordionContext=createContext2({}),SectionContext=createContext2({}),EMPTY_EXPANDED_MAP={},EMPTY_EVENT_MAP={},generateSectionId=sequentialIdGenerator(),generateRandomId=randomIdGenerator(1e5);function BentoAccordionWithRef(e,t){var n=e.animate,r=void 0!==n&&n,o=e.as,a=void 0===o?"section":o,i=e.children,c=e.expandSingleSection,u=void 0!==c&&c,d=e.id,l=_objectWithoutPropertiesLoose(e,_excluded),f=_slicedToArray(useState2(EMPTY_EXPANDED_MAP),2),s=f[0],_=f[1],p=useRef2(EMPTY_EVENT_MAP),v=_slicedToArray(useState2(generateRandomId),1)[0],m=d||"a".concat(v);useEffect2((function(){u&&_((function(e){var t={},n=0;for(var r in e)t[r]=e[r]&&0==n++;return t}))}),[u]);var y=useCallback2((function(e,t,n){var r=n.current;return _((function(n){return setExpanded(e,t,n,u)})),p.current=_objectSpread2(_objectSpread2({},p.current),{},_defineProperty({},e,r)),function(){_((function(t){return omit(t,e)})),p.current=omit(p.current,e)}}),[u]),b=useCallback2((function(e,t){_((function(n){var r=null!=t?t:!n[e],o=setExpanded(e,r,n,u);return resolvedPromise().then((function(){for(var e in n){var t=p.current[e];t&&n[e]!=o[e]&&t(o[e])}})),o}))}),[u]),A=useCallback2((function(e,t){var n;return null!==(n=s[e])&&void 0!==n?n:t}),[s]),h=useCallback2((function(e){if(e)e in s&&b(e);else if(!u)for(var t in s)b(t)}),[s,b,u]),g=useCallback2((function(e){if(e)A(e,!0)||b(e);else if(!u)for(var t in s)A(t,!0)||b(t)}),[s,b,A,u]),P=useCallback2((function(e){if(e)A(e,!1)&&b(e);else for(var t in s)A(t,!1)&&b(t)}),[s,b,A]);useImperativeHandle2(t,(function(){return{toggle:h,expand:g,collapse:P}}),[h,P,g]);var x=useMemo2((function(){return{registerSection:y,toggleExpanded:b,isExpanded:A,animate:r,prefix:m}}),[y,b,A,r,m]);return createElement2(a,_objectSpread2({id:d},l),createElement2(AccordionContext.Provider,{value:x},i))}var BentoAccordion=forwardRef2(BentoAccordionWithRef);function setExpanded(e,t,n,r){var o;if(r&&t)for(var a in o=_defineProperty({},e,t),n)a!=e&&(o[a]=!1);else o=_objectSpread2(_objectSpread2({},n),{},_defineProperty({},e,t));return o}function BentoAccordionSection(e){var t=e.animate,n=void 0!==t&&t,r=e.as,o=void 0===r?"section":r,a=e.children,i=e.expanded,c=void 0!==i&&i,u=e.id,d=e.onExpandStateChange,l=_objectWithoutPropertiesLoose(e,_excluded2),f=_slicedToArray(useState2(generateSectionId),1)[0],s=u||f,_=_slicedToArray(useState2(generateRandomId),1)[0],p=_slicedToArray(useState2(c),2),v=p[0],m=p[1],y=_slicedToArray(useState2(null),2),b=y[0],A=y[1],h=_slicedToArray(useState2(null),2),g=h[0],P=h[1],x=useContext2(AccordionContext),C=x.animate,S=x.isExpanded,O=x.prefix,E=x.registerSection,j=x.toggleExpanded,T=S?S(s,c):v,M=null!=C?C:n,I=b||"".concat(O||"a","-content-").concat(s,"-").concat(_),N=g||"".concat(O||"a","-header-").concat(s,"-").concat(_),L=useRef2(null);L.current=d,useLayoutEffect2((function(){if(E)return E(s,c,L)}),[E,s,c]);var R=useCallback2((function(e){j?j(s,e):m((function(t){var n=null!=e?e:!t;return resolvedPromise().then((function(){var e=L.current;e&&e(n)})),n}))}),[s,j]),k=useMemo2((function(){return{animate:M,contentId:I,headerId:N,expanded:T,toggleHandler:R,setContentId:A,setHeaderId:P}}),[M,I,N,T,R]);return createElement2(o,_objectSpread2({},l),createElement2(SectionContext.Provider,{value:k},a))}function BentoAccordionHeader(e){var t=e.as,n=void 0===t?"div":t,r=e.children,o=e.class,a=void 0===o?"":o,i=e.id,c=e.role,u=void 0===c?"button":c,d=e.tabIndex,l=void 0===d?0:d,f=_objectWithoutPropertiesLoose(e,_excluded3),s=useContext2(SectionContext),_=s.contentId,p=s.expanded,v=s.headerId,m=s.setHeaderId,y=s.toggleHandler;return useLayoutEffect2((function(){m&&m(i)}),[m,i]),createElement2(n,_objectSpread2(_objectSpread2({},f),{},{id:v,role:u,class:"".concat(a," ").concat($sectionChild," ").concat($header),tabIndex:l,"aria-controls":_,onClick:function(){return y()},"aria-expanded":String(p)}),r)}function BentoAccordionContent(e){var t=e.as,n=void 0===t?"div":t,r=e.children,o=e.class,a=void 0===o?"":o,i=e.id,c=e.role,u=void 0===c?"region":c,d=_objectWithoutPropertiesLoose(e,_excluded4),l=useRef2(null),f=useRef2(!1),s=useContext2(SectionContext),_=s.animate,p=s.contentId,v=s.expanded,m=s.headerId,y=s.setContentId;return useEffect2((function(){return f.current=!0,function(){return f.current=!1}}),[]),useLayoutEffect2((function(){y&&y(i)}),[y,i]),useLayoutEffect2((function(){var e=f.current,t=l.current;if(_&&e&&t&&t.animate)return v?animateExpand(t):animateCollapse(t)}),[v,_]),createElement2(WithAmpContext,{renderable:v},createElement2(n,_objectSpread2(_objectSpread2({},d),{},{ref:l,class:a+" "+$sectionChild+(v?"":" "+$contentHidden),id:p,"aria-labelledby":m,role:u}),r))}BentoAccordion.displayName="Accordion"; |
@@ -571,5 +571,3 @@ var __create = Object.create; | ||
}, [animate2, contentId, headerId, expanded, toggleHandler]); | ||
return createElement2(Comp, _extends({}, rest, { | ||
expanded: expanded | ||
}), createElement2(SectionContext.Provider, { | ||
return createElement2(Comp, _extends({}, rest), createElement2(SectionContext.Provider, { | ||
value: context2 | ||
@@ -576,0 +574,0 @@ }, children)); |
@@ -558,5 +558,3 @@ // extensions/amp-accordion/1.0/component.jss.js | ||
}), [animate2, contentId, headerId, expanded, toggleHandler]); | ||
return createElement2(Comp, _extends({}, rest, { | ||
expanded | ||
}), createElement2(SectionContext.Provider, { | ||
return createElement2(Comp, _extends({}, rest), createElement2(SectionContext.Provider, { | ||
value: context2 | ||
@@ -563,0 +561,0 @@ }, children)); |
@@ -1,1 +0,1 @@ | ||
var e;function n(){return e||(e=Promise.resolve(void 0))}function t(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function r(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 o(e){for(var n=1;n<arguments.length;n++){var o=null!=arguments[n]?arguments[n]:{};n%2?r(Object(o),!0).forEach((function(n){t(e,n,o[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):r(Object(o)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(o,n))}))}return e}function i(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}var{hasOwnProperty:c,toString:a}=Object.prototype;function l(e,n){return Object.keys(e).reduce(((t,r)=>(n.includes(r)||(t[r]=e[r]),t)),{})}import{cloneElement as u,createContext as d,createElement as s,createRef as f}from"preact";import{hydrate as p,render as h}from"preact";import{useCallback as g,useContext as b,useEffect as y,useImperativeHandle as m,useLayoutEffect as v,useMemo as x,useRef as O,useState as w}from"preact/hooks";function j(e,n,t){return s.apply(void 0,arguments)}function P(e){return d(e,void 0)}function S(e){return w(e)}function I(e){return O(e)}function E(e,n){y(e,n)}function $(e,n){v(e,n)}function k(e){return b(e)}function z(e,n){return x(e,n)}function H(e,n){return g(e,n)}import{Children as M,createPortal as Y,forwardRef as C}from"preact/compat";var D,A,L=["auto","lazy","eager","unload"],W={auto:0,lazy:1,eager:2,unload:3};function N(e,n){const t=W[e]||0,r=W[n]||0,o=Math.max(t,r);return L[o]}function U(){return D||(D=P({renderable:!0,playable:!0,loading:"auto"}))}function V({children:e,loading:n="auto",notify:t,playable:r=!0,renderable:o=!0}){const i=k(U()),c=o&&i.renderable,a=c&&r&&i.playable,l=N(c?"auto":"lazy",N(n,i.loading)),u=t||i.notify,d=z((()=>({renderable:c,playable:a,loading:l,notify:u})),[c,a,l,u]);return j(U().Provider,{children:e,value:d})}var q=["Webkit","webkit","Moz","moz","ms","O","o"];function B(e,n,t){if(K(n))return n;A||(A=Object.create(null));let r=A[n];if(!r||t){if(r=n,void 0===e[n]){const t=function(e,n){for(let t=0;t<q.length;t++){const r=q[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||(A[n]=r)}return r}function F(e,n,t,r,o){const i=B(e.style,n,o);if(!i)return;const c=r?t+r:t;K(i)?e.style.setProperty(i,c):e.style[i]=c}function G(e,n,t){const r=B(e.style,n,t);if(r)return K(r)?e.style.getPropertyValue(r):e.style[r]}function J(e,n){for(const t in n)F(e,t,n[t])}function K(e){return e.startsWith("--")}function Q(e,n,t){e.classList.add("i-amphtml-animating");let r=n();return r.onfinish=r.oncancel=()=>{r=null,t&&t(),e.classList.remove("i-amphtml-animating")},()=>{r&&r.cancel()}}function R(e){const n=window.innerHeight,t=Math.abs(e)/n*500;return Math.min(Math.max(t,200),500)}var T=["animate","as","children","expandSingleSection","id"],X=["animate","as","children","expanded","id","onExpandStateChange"],Z=["as","children","class","id","role","tabIndex"],_=["as","children","class","id","role"],ee=P({}),ne=P({}),te={},re={},oe=function(){let e=0;return()=>String(++e)}(),ie=()=>String(Math.floor(1e5*Math.random())),ce=C((function(e,t){let{animate:r=!1,as:c="section",children:a,expandSingleSection:u=!1,id:d}=e,s=i(e,T);const[f,p]=S(te),h=I(re),[g]=S(ie),b=d||`a${g}`;E((()=>{u&&p((e=>{const n={};let t=0;for(const r in e)n[r]=e[r]&&0==t++;return n}))}),[u]);const y=H(((e,n,{current:t})=>(p((t=>ae(e,n,t,u))),h.current=o(o({},h.current),{},{[e]:t}),()=>{p((n=>l(n,e))),h.current=l(h.current,e)})),[u]),v=H(((e,t)=>{p((r=>{const o=null!=t?t:!r[e],i=ae(e,o,r,u);return n().then((()=>{for(const e in r){const n=h.current[e];n&&r[e]!=i[e]&&n(i[e])}})),i}))}),[u]),x=H(((e,n)=>{var t;return null!==(t=f[e])&&void 0!==t?t:n}),[f]),O=H((e=>{if(e)e in f&&v(e);else if(!u)for(const e in f)v(e)}),[f,v,u]),w=H((e=>{if(e)x(e,!0)||v(e);else if(!u)for(const e in f)x(e,!0)||v(e)}),[f,v,x,u]),P=H((e=>{if(e)x(e,!1)&&v(e);else for(const e in f)x(e,!1)&&v(e)}),[f,v,x]);!function(e,n,t){m(e,(()=>({toggle:O,expand:w,collapse:P})),t)}(t,0,[O,P,w]);const $=z((()=>({registerSection:y,toggleExpanded:v,isExpanded:x,animate:r,prefix:b})),[y,v,x,r,b]);return j(c,o({id:d},s),j(ee.Provider,{value:$},a))}));function ae(e,n,t,r){let i;if(r&&n){i={[e]:n};for(const n in t)n!=e&&(i[n]=!1)}else i=o(o({},t),{},{[e]:n});return i}function le(e){let{animate:t=!1,as:r="section",children:c,expanded:a=!1,id:l,onExpandStateChange:u}=e,d=i(e,X);const[s]=S(oe),f=l||s,[p]=S(ie),[h,g]=S(a),[b,y]=S(null),[m,v]=S(null),{animate:x,isExpanded:O,prefix:w,registerSection:P,toggleExpanded:E}=k(ee),M=O?O(f,a):h,Y=null!=x?x:t,C=b||`${w||"a"}-content-${f}-${p}`,D=m||`${w||"a"}-header-${f}-${p}`,A=I(null);A.current=u,$((()=>{if(P)return P(f,a,A)}),[P,f,a]);const L=H((e=>{E?E(f,e):g((t=>{const r=null!=e?e:!t;return n().then((()=>{const e=A.current;e&&e(r)})),r}))}),[f,E]),W=z((()=>({animate:Y,contentId:C,headerId:D,expanded:M,toggleHandler:L,setContentId:y,setHeaderId:v})),[Y,C,D,M,L]);return j(r,o(o({},d),{},{expanded:M}),j(ne.Provider,{value:W},c))}function ue(e){let{as:n="div",children:t,"class":r="",id:c,role:a="button",tabIndex:l=0}=e,u=i(e,Z);const{contentId:d,expanded:s,headerId:f,setHeaderId:p,toggleHandler:h}=k(ne);return $((()=>{p&&p(c)}),[p,c]),j(n,o(o({},u),{},{id:f,role:a,class:`${r} section-child-00fce3c header-00fce3c`,tabIndex:l,"aria-controls":d,onClick:()=>h(),"aria-expanded":String(s)}),t)}function de(e){let{as:n="div",children:t,"class":r="",id:c,role:a="region"}=e,l=i(e,_);const u=I(null),d=I(!1),{animate:s,contentId:f,expanded:p,headerId:h,setContentId:g}=k(ne);return E((()=>(d.current=!0,()=>d.current=!1)),[]),$((()=>{g&&g(c)}),[g,c]),$((()=>{const e=d.current,n=u.current;if(s&&e&&n&&n.animate)return p?function(e){return Q(e,(()=>{const n=G(e,"height"),t=G(e,"opacity"),r=G(e,"overflowY");J(e,{height:0,opacity:0,overflowY:"auto"});const o=e.scrollHeight;J(e,{height:n,opacity:t,overflowY:r});const i=R(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 Q(e,(()=>{const n=e.offsetHeight,t=R(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)}),[p,s]),j(V,{renderable:p},j(n,o(o({},l),{},{ref:u,class:r+" section-child-00fce3c"+(p?"":" content-hidden-00fce3c"),id:f,"aria-labelledby":h,role:a}),t))}ce.displayName="Accordion";export{ce as BentoAccordion,de as BentoAccordionContent,ue as BentoAccordionHeader,le 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 o(n){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{};e%2?r(Object(o),!0).forEach((function(e){t(n,e,o[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(o)):r(Object(o)).forEach((function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(o,e))}))}return n}function i(n,e){if(null==n)return{};var t,r,o={},i=Object.keys(n);for(r=0;r<i.length;r++)t=i[r],e.indexOf(t)>=0||(o[t]=n[t]);return o}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"preact";import{hydrate as h,render as p}from"preact";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"preact/hooks";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"preact/compat";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,o=Math.max(t,r);return q[o]}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:o=!0}){const i=Y(F()),c=o&&i.renderable,a=c&&r&&i.playable,u=D(c?"auto":"lazy",D(e,i.loading)),l=t||i.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),o=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[o]&&(r=o)}t||(W[e]=r)}return r}function L(n,e,t,r,o){const i=K(n.style,e,o);if(!i)return;const c=r?t+r:t;R(i)?n.style.setProperty(i,c):n.style[i]=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),p=$(rn),[b]=S(cn),g=d||`a${b}`;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))),p.current=o(o({},p.current),{},{[n]:t}),()=>{h((e=>u(e,n))),p.current=u(p.current,n)})),[l]),x=C(((n,t)=>{h((r=>{const o=null!=t?t:!r[n],i=un(n,o,r,l);return e().then((()=>{for(const n in r){const e=p.current[n];e&&r[n]!=i[n]&&e(i[n])}})),i}))}),[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:g})),[v,x,O,r,g]);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),[p,b]=S(a),[g,v]=S(null),[m,x]=S(null),{animate:O,isExpanded:y,prefix:j,registerSection:w,toggleExpanded:z}=Y(nn),k=y?y(s,a):p,H=null!=O?O:t,P=g||`${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):b((t=>{const r=null!=n?n:!t;return e().then((()=>{const n=W.current;n&&n(r)})),r}))}),[s,z]),B=E((()=>({animate:H,contentId:P,headerId:A,expanded:k,toggleHandler:q,setContentId:v,setHeaderId:x})),[H,P,A,k,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:p}=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:()=>p(),"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:p,setContentId:b}=Y(en);return z((()=>(d.current=!0,()=>d.current=!1)),[]),M((()=>{b&&b(c)}),[b,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 o=n.scrollHeight;Q(n,{height:e,opacity:t,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})}))}(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":p,role:a}),t))}an.displayName="Accordion";export{an as BentoAccordion,fn as BentoAccordionContent,dn as BentoAccordionHeader,ln as BentoAccordionSection}; |
@@ -1,1 +0,1 @@ | ||
var __create=Object.create,__defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty,__markAsModule=function(e){return __defProp(e,"__esModule",{value:!0})},__export=function(e,t){for(var r in __markAsModule(e),t)__defProp(e,r,{get:t[r],enumerable:!0})},__reExport=function(e,t,r){if(t&&"object"==typeof t||"function"==typeof t)for(var n,o=__getOwnPropNames(t),a=0,i=o.length;a<i;a++)n=o[a],__hasOwnProp.call(e,n)||"default"===n||__defProp(e,n,{get:function(e){return t[e]}.bind(null,n),enumerable:!(r=__getOwnPropDesc(t,n))||r.enumerable});return e},__toModule=function(e){return __reExport(__markAsModule(__defProp(null!=e?__create(__getProtoOf(e)):{},"default",e&&e.__esModule&&"default"in e?{get:function(){return e.default},enumerable:!0}:{value:e,enumerable:!0})),e)};__export(exports,{BentoAccordion:function(){return BentoAccordion},BentoAccordionContent:function(){return BentoAccordionContent},BentoAccordionHeader:function(){return BentoAccordionHeader},BentoAccordionSection:function(){return BentoAccordionSection}});var resolved,$sectionChild="section-child-00fce3c",$header="header-00fce3c",$contentHidden="content-hidden-00fce3c";function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function resolvedPromise(){return resolved||(resolved=Promise.resolve(void 0))}function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function _objectSpread2(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _iterableToArrayLimit(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a=[],i=!0,c=!1;try{for(r=r.call(e);!(i=(n=r.next()).done)&&(a.push(n.value),!t||a.length!==t);i=!0);}catch(e){c=!0,o=e}finally{try{i||null==r.return||r.return()}finally{if(c)throw o}}return a}}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray(e,t)||_nonIterableRest()}function _objectWithoutPropertiesLoose(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}function sequentialIdGenerator(){var e=0;return function(){return String(++e)}}function randomIdGenerator(e){return function(){return String(Math.floor(Math.random()*e))}}var _Object$prototype=Object.prototype,hasOwn_=_Object$prototype.hasOwnProperty,toString_=_Object$prototype.toString;function map(e){var t=Object.create(null);return e&&Object.assign(t,e),t}function omit(e,t){return Object.keys(e).reduce((function(r,n){return t.includes(n)||(r[n]=e[n]),r}),{})}var preact=__toModule(require("react")),preactDOM=__toModule(require("react-dom")),hooks=__toModule(require("react"));function createElement2(e,t,r){return preact.createElement.apply(void 0,arguments)}function createContext2(e){return preact.createContext(e,void 0)}function useState2(e){return hooks.useState(e)}function useRef2(e){return hooks.useRef(e)}function useEffect2(e,t){hooks.useEffect(e,t)}function useLayoutEffect2(e,t){hooks.useLayoutEffect(e,t)}function useContext2(e){return hooks.useContext(e)}function useMemo2(e,t){return hooks.useMemo(e,t)}function useCallback2(e,t){return hooks.useCallback(e,t)}function useImperativeHandle2(e,t,r){return hooks.useImperativeHandle(e,t,r)}var _MAP,compat=__toModule(require("react"));function forwardRef2(e){return compat.forwardRef(e)}var context,Loading={AUTO:"auto",LAZY:"lazy",EAGER:"eager",UNLOAD:"unload"},ORDER=[Loading.AUTO,Loading.LAZY,Loading.EAGER,Loading.UNLOAD],MAP=(_defineProperty(_MAP={},Loading.AUTO,0),_defineProperty(_MAP,Loading.LAZY,1),_defineProperty(_MAP,Loading.EAGER,2),_defineProperty(_MAP,Loading.UNLOAD,3),_MAP);function reducer(e,t){var r=MAP[e]||0,n=MAP[t]||0,o=Math.max(r,n);return ORDER[o]}function getAmpContext(){return context||(context=createContext2({renderable:!0,playable:!0,loading:Loading.AUTO}))}function WithAmpContext(e){var t=e.children,r=e.loading,n=void 0===r?"auto":r,o=e.notify,a=e.playable,i=void 0===a||a,c=e.renderable,u=void 0===c||c,d=useAmpContext(),l=u&&d.renderable,s=l&&i&&d.playable,f=reducer(l?Loading.AUTO:Loading.LAZY,reducer(n,d.loading)),p=o||d.notify,_=useMemo2((function(){return{renderable:l,playable:s,loading:f,notify:p}}),[l,s,f,p]);return createElement2(getAmpContext().Provider,{children:t,value:_})}function useAmpContext(){return useContext2(getAmpContext())}var propertyNameCache,isArray=Array.isArray,vendorPrefixes=["Webkit","webkit","Moz","moz","ms","O","o"];function camelCaseToTitleCase(e){return e.charAt(0).toUpperCase()+e.slice(1)}function getVendorJsPropertyName_(e,t){for(var r=0;r<vendorPrefixes.length;r++){var n=vendorPrefixes[r]+t;if(void 0!==e[n])return n}return""}function getVendorJsPropertyName(e,t,r){if(isVar(t))return t;propertyNameCache||(propertyNameCache=map());var n=propertyNameCache[t];if(!n||r){if(n=t,void 0===e[t]){var o=getVendorJsPropertyName_(e,camelCaseToTitleCase(t));void 0!==e[o]&&(n=o)}r||(propertyNameCache[t]=n)}return n}function setStyle(e,t,r,n,o){var a=getVendorJsPropertyName(e.style,t,o);if(a){var i=n?r+n:r;isVar(a)?e.style.setProperty(a,i):e.style[a]=i}}function getStyle(e,t,r){var n=getVendorJsPropertyName(e.style,t,r);if(n)return isVar(n)?e.style.getPropertyValue(n):e.style[n]}function setStyles(e,t){for(var r in t)setStyle(e,r,t[r])}function isVar(e){return e.startsWith("--")}var MAX_TRANSITION_DURATION=500,MIN_TRANSITION_DURATION=200,EXPAND_CURVE="cubic-bezier(0.47, 0, 0.745, 0.715)",COLLAPSE_CURVE="cubic-bezier(0.39, 0.575, 0.565, 1)";function animateExpand(e){return animate(e,(function(){var t=getStyle(e,"height"),r=getStyle(e,"opacity"),n=getStyle(e,"overflowY");setStyles(e,{height:0,opacity:0,overflowY:"auto"});var o=e.scrollHeight;setStyles(e,{height:t,opacity:r,overflowY:n});var a=getTransitionDuration(o);return e.animate([{height:0,opacity:0,overflowY:"hidden"},{height:o+"px",opacity:1,overflowY:"hidden"}],{easing:EXPAND_CURVE,duration:a})}))}function animateCollapse(e){return animate(e,(function(){var t=e.offsetHeight,r=getTransitionDuration(t);return e.animate([{height:t+"px",opacity:1,overflowY:"hidden"},{height:"0",opacity:0,overflowY:"hidden"}],{easing:COLLAPSE_CURVE,duration:r})}))}function animate(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;e.classList.add("i-amphtml-animating");var n=t();return n.onfinish=n.oncancel=function(){n=null,r&&r(),e.classList.remove("i-amphtml-animating")},function(){n&&n.cancel()}}function getTransitionDuration(e){var t=window.innerHeight,r=Math.abs(e)/t*MAX_TRANSITION_DURATION;return Math.min(Math.max(r,MIN_TRANSITION_DURATION),MAX_TRANSITION_DURATION)}var _excluded=["animate","as","children","expandSingleSection","id"],_excluded2=["animate","as","children","expanded","id","onExpandStateChange"],_excluded3=["as","children","class","id","role","tabIndex"],_excluded4=["as","children","class","id","role"],AccordionContext=createContext2({}),SectionContext=createContext2({}),EMPTY_EXPANDED_MAP={},EMPTY_EVENT_MAP={},generateSectionId=sequentialIdGenerator(),generateRandomId=randomIdGenerator(1e5);function BentoAccordionWithRef(e,t){var r=e.animate,n=void 0!==r&&r,o=e.as,a=void 0===o?"section":o,i=e.children,c=e.expandSingleSection,u=void 0!==c&&c,d=e.id,l=_objectWithoutPropertiesLoose(e,_excluded),s=_slicedToArray(useState2(EMPTY_EXPANDED_MAP),2),f=s[0],p=s[1],_=useRef2(EMPTY_EVENT_MAP),y=_slicedToArray(useState2(generateRandomId),1)[0],v=d||"a".concat(y);useEffect2((function(){u&&p((function(e){var t={},r=0;for(var n in e)t[n]=e[n]&&0==r++;return t}))}),[u]);var m=useCallback2((function(e,t,r){var n=r.current;return p((function(r){return setExpanded(e,t,r,u)})),_.current=_objectSpread2(_objectSpread2({},_.current),{},_defineProperty({},e,n)),function(){p((function(t){return omit(t,e)})),_.current=omit(_.current,e)}}),[u]),g=useCallback2((function(e,t){p((function(r){var n=null!=t?t:!r[e],o=setExpanded(e,n,r,u);return resolvedPromise().then((function(){for(var e in r){var t=_.current[e];t&&r[e]!=o[e]&&t(o[e])}})),o}))}),[u]),h=useCallback2((function(e,t){var r;return null!==(r=f[e])&&void 0!==r?r:t}),[f]),b=useCallback2((function(e){if(e)e in f&&g(e);else if(!u)for(var t in f)g(t)}),[f,g,u]),A=useCallback2((function(e){if(e)h(e,!0)||g(e);else if(!u)for(var t in f)h(t,!0)||g(t)}),[f,g,h,u]),P=useCallback2((function(e){if(e)h(e,!1)&&g(e);else for(var t in f)h(t,!1)&&g(t)}),[f,g,h]);useImperativeHandle2(t,(function(){return{toggle:b,expand:A,collapse:P}}),[b,P,A]);var x=useMemo2((function(){return{registerSection:m,toggleExpanded:g,isExpanded:h,animate:n,prefix:v}}),[m,g,h,n,v]);return createElement2(a,_objectSpread2({id:d},l),createElement2(AccordionContext.Provider,{value:x},i))}var BentoAccordion=forwardRef2(BentoAccordionWithRef);function setExpanded(e,t,r,n){var o;if(n&&t)for(var a in o=_defineProperty({},e,t),r)a!=e&&(o[a]=!1);else o=_objectSpread2(_objectSpread2({},r),{},_defineProperty({},e,t));return o}function BentoAccordionSection(e){var t=e.animate,r=void 0!==t&&t,n=e.as,o=void 0===n?"section":n,a=e.children,i=e.expanded,c=void 0!==i&&i,u=e.id,d=e.onExpandStateChange,l=_objectWithoutPropertiesLoose(e,_excluded2),s=_slicedToArray(useState2(generateSectionId),1)[0],f=u||s,p=_slicedToArray(useState2(generateRandomId),1)[0],_=_slicedToArray(useState2(c),2),y=_[0],v=_[1],m=_slicedToArray(useState2(null),2),g=m[0],h=m[1],b=_slicedToArray(useState2(null),2),A=b[0],P=b[1],x=useContext2(AccordionContext),O=x.animate,S=x.isExpanded,C=x.prefix,E=x.registerSection,I=x.toggleExpanded,T=S?S(f,c):y,j=null!=O?O:r,M=g||"".concat(C||"a","-content-").concat(f,"-").concat(p),L=A||"".concat(C||"a","-header-").concat(f,"-").concat(p),N=useRef2(null);N.current=d,useLayoutEffect2((function(){if(E)return E(f,c,N)}),[E,f,c]);var w=useCallback2((function(e){I?I(f,e):v((function(t){var r=null!=e?e:!t;return resolvedPromise().then((function(){var e=N.current;e&&e(r)})),r}))}),[f,I]),R=useMemo2((function(){return{animate:j,contentId:M,headerId:L,expanded:T,toggleHandler:w,setContentId:h,setHeaderId:P}}),[j,M,L,T,w]);return createElement2(o,_objectSpread2(_objectSpread2({},l),{},{expanded:T}),createElement2(SectionContext.Provider,{value:R},a))}function BentoAccordionHeader(e){var t=e.as,r=void 0===t?"div":t,n=e.children,o=e.class,a=void 0===o?"":o,i=e.id,c=e.role,u=void 0===c?"button":c,d=e.tabIndex,l=void 0===d?0:d,s=_objectWithoutPropertiesLoose(e,_excluded3),f=useContext2(SectionContext),p=f.contentId,_=f.expanded,y=f.headerId,v=f.setHeaderId,m=f.toggleHandler;return useLayoutEffect2((function(){v&&v(i)}),[v,i]),createElement2(r,_objectSpread2(_objectSpread2({},s),{},{id:y,role:u,class:"".concat(a," ").concat($sectionChild," ").concat($header),tabIndex:l,"aria-controls":p,onClick:function(){return m()},"aria-expanded":String(_)}),n)}function BentoAccordionContent(e){var t=e.as,r=void 0===t?"div":t,n=e.children,o=e.class,a=void 0===o?"":o,i=e.id,c=e.role,u=void 0===c?"region":c,d=_objectWithoutPropertiesLoose(e,_excluded4),l=useRef2(null),s=useRef2(!1),f=useContext2(SectionContext),p=f.animate,_=f.contentId,y=f.expanded,v=f.headerId,m=f.setContentId;return useEffect2((function(){return s.current=!0,function(){return s.current=!1}}),[]),useLayoutEffect2((function(){m&&m(i)}),[m,i]),useLayoutEffect2((function(){var e=s.current,t=l.current;if(p&&e&&t&&t.animate)return y?animateExpand(t):animateCollapse(t)}),[y,p]),createElement2(WithAmpContext,{renderable:y},createElement2(r,_objectSpread2(_objectSpread2({},d),{},{ref:l,class:a+" "+$sectionChild+(y?"":" "+$contentHidden),id:_,"aria-labelledby":v,role:u}),n))}BentoAccordion.displayName="Accordion"; | ||
var __create=Object.create,__defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty,__markAsModule=function(e){return __defProp(e,"__esModule",{value:!0})},__export=function(e,t){for(var n in __markAsModule(e),t)__defProp(e,n,{get:t[n],enumerable:!0})},__reExport=function(e,t,n){if(t&&"object"==typeof t||"function"==typeof t)for(var r,o=__getOwnPropNames(t),a=0,i=o.length;a<i;a++)r=o[a],__hasOwnProp.call(e,r)||"default"===r||__defProp(e,r,{get:function(e){return t[e]}.bind(null,r),enumerable:!(n=__getOwnPropDesc(t,r))||n.enumerable});return e},__toModule=function(e){return __reExport(__markAsModule(__defProp(null!=e?__create(__getProtoOf(e)):{},"default",e&&e.__esModule&&"default"in e?{get:function(){return e.default},enumerable:!0}:{value:e,enumerable:!0})),e)};__export(exports,{BentoAccordion:function(){return BentoAccordion},BentoAccordionContent:function(){return BentoAccordionContent},BentoAccordionHeader:function(){return BentoAccordionHeader},BentoAccordionSection:function(){return BentoAccordionSection}});var resolved,$sectionChild="section-child-00fce3c",$header="header-00fce3c",$contentHidden="content-hidden-00fce3c";function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(e,t):void 0}}function resolvedPromise(){return resolved||(resolved=Promise.resolve(void 0))}function _defineProperty(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ownKeys(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function _objectSpread2(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(n),!0).forEach((function(t){_defineProperty(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ownKeys(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _iterableToArrayLimit(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,a=[],i=!0,c=!1;try{for(n=n.call(e);!(i=(r=n.next()).done)&&(a.push(r.value),!t||a.length!==t);i=!0);}catch(e){c=!0,o=e}finally{try{i||null==n.return||n.return()}finally{if(c)throw o}}return a}}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray(e,t)||_nonIterableRest()}function _objectWithoutPropertiesLoose(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}function sequentialIdGenerator(){var e=0;return function(){return String(++e)}}function randomIdGenerator(e){return function(){return String(Math.floor(Math.random()*e))}}var _Object$prototype=Object.prototype,hasOwn_=_Object$prototype.hasOwnProperty,toString_=_Object$prototype.toString;function map(e){var t=Object.create(null);return e&&Object.assign(t,e),t}function omit(e,t){return Object.keys(e).reduce((function(n,r){return t.includes(r)||(n[r]=e[r]),n}),{})}var preact=__toModule(require("react")),preactDOM=__toModule(require("react-dom")),hooks=__toModule(require("react"));function createElement2(e,t,n){return preact.createElement.apply(void 0,arguments)}function createContext2(e){return preact.createContext(e,void 0)}function useState2(e){return hooks.useState(e)}function useRef2(e){return hooks.useRef(e)}function useEffect2(e,t){hooks.useEffect(e,t)}function useLayoutEffect2(e,t){hooks.useLayoutEffect(e,t)}function useContext2(e){return hooks.useContext(e)}function useMemo2(e,t){return hooks.useMemo(e,t)}function useCallback2(e,t){return hooks.useCallback(e,t)}function useImperativeHandle2(e,t,n){return hooks.useImperativeHandle(e,t,n)}var _MAP,compat=__toModule(require("react"));function forwardRef2(e){return compat.forwardRef(e)}var context,Loading={AUTO:"auto",LAZY:"lazy",EAGER:"eager",UNLOAD:"unload"},ORDER=[Loading.AUTO,Loading.LAZY,Loading.EAGER,Loading.UNLOAD],MAP=(_defineProperty(_MAP={},Loading.AUTO,0),_defineProperty(_MAP,Loading.LAZY,1),_defineProperty(_MAP,Loading.EAGER,2),_defineProperty(_MAP,Loading.UNLOAD,3),_MAP);function reducer(e,t){var n=MAP[e]||0,r=MAP[t]||0,o=Math.max(n,r);return ORDER[o]}function getAmpContext(){return context||(context=createContext2({renderable:!0,playable:!0,loading:Loading.AUTO}))}function WithAmpContext(e){var t=e.children,n=e.loading,r=void 0===n?"auto":n,o=e.notify,a=e.playable,i=void 0===a||a,c=e.renderable,u=void 0===c||c,d=useAmpContext(),l=u&&d.renderable,f=l&&i&&d.playable,s=reducer(l?Loading.AUTO:Loading.LAZY,reducer(r,d.loading)),_=o||d.notify,p=useMemo2((function(){return{renderable:l,playable:f,loading:s,notify:_}}),[l,f,s,_]);return createElement2(getAmpContext().Provider,{children:t,value:p})}function useAmpContext(){return useContext2(getAmpContext())}var propertyNameCache,isArray=Array.isArray,vendorPrefixes=["Webkit","webkit","Moz","moz","ms","O","o"];function camelCaseToTitleCase(e){return e.charAt(0).toUpperCase()+e.slice(1)}function getVendorJsPropertyName_(e,t){for(var n=0;n<vendorPrefixes.length;n++){var r=vendorPrefixes[n]+t;if(void 0!==e[r])return r}return""}function getVendorJsPropertyName(e,t,n){if(isVar(t))return t;propertyNameCache||(propertyNameCache=map());var r=propertyNameCache[t];if(!r||n){if(r=t,void 0===e[t]){var o=getVendorJsPropertyName_(e,camelCaseToTitleCase(t));void 0!==e[o]&&(r=o)}n||(propertyNameCache[t]=r)}return r}function setStyle(e,t,n,r,o){var a=getVendorJsPropertyName(e.style,t,o);if(a){var i=r?n+r:n;isVar(a)?e.style.setProperty(a,i):e.style[a]=i}}function getStyle(e,t,n){var r=getVendorJsPropertyName(e.style,t,n);if(r)return isVar(r)?e.style.getPropertyValue(r):e.style[r]}function setStyles(e,t){for(var n in t)setStyle(e,n,t[n])}function isVar(e){return e.startsWith("--")}var MAX_TRANSITION_DURATION=500,MIN_TRANSITION_DURATION=200,EXPAND_CURVE="cubic-bezier(0.47, 0, 0.745, 0.715)",COLLAPSE_CURVE="cubic-bezier(0.39, 0.575, 0.565, 1)";function animateExpand(e){return animate(e,(function(){var t=getStyle(e,"height"),n=getStyle(e,"opacity"),r=getStyle(e,"overflowY");setStyles(e,{height:0,opacity:0,overflowY:"auto"});var o=e.scrollHeight;setStyles(e,{height:t,opacity:n,overflowY:r});var a=getTransitionDuration(o);return e.animate([{height:0,opacity:0,overflowY:"hidden"},{height:o+"px",opacity:1,overflowY:"hidden"}],{easing:EXPAND_CURVE,duration:a})}))}function animateCollapse(e){return animate(e,(function(){var t=e.offsetHeight,n=getTransitionDuration(t);return e.animate([{height:t+"px",opacity:1,overflowY:"hidden"},{height:"0",opacity:0,overflowY:"hidden"}],{easing:COLLAPSE_CURVE,duration:n})}))}function animate(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;e.classList.add("i-amphtml-animating");var r=t();return r.onfinish=r.oncancel=function(){r=null,n&&n(),e.classList.remove("i-amphtml-animating")},function(){r&&r.cancel()}}function getTransitionDuration(e){var t=window.innerHeight,n=Math.abs(e)/t*MAX_TRANSITION_DURATION;return Math.min(Math.max(n,MIN_TRANSITION_DURATION),MAX_TRANSITION_DURATION)}var _excluded=["animate","as","children","expandSingleSection","id"],_excluded2=["animate","as","children","expanded","id","onExpandStateChange"],_excluded3=["as","children","class","id","role","tabIndex"],_excluded4=["as","children","class","id","role"],AccordionContext=createContext2({}),SectionContext=createContext2({}),EMPTY_EXPANDED_MAP={},EMPTY_EVENT_MAP={},generateSectionId=sequentialIdGenerator(),generateRandomId=randomIdGenerator(1e5);function BentoAccordionWithRef(e,t){var n=e.animate,r=void 0!==n&&n,o=e.as,a=void 0===o?"section":o,i=e.children,c=e.expandSingleSection,u=void 0!==c&&c,d=e.id,l=_objectWithoutPropertiesLoose(e,_excluded),f=_slicedToArray(useState2(EMPTY_EXPANDED_MAP),2),s=f[0],_=f[1],p=useRef2(EMPTY_EVENT_MAP),v=_slicedToArray(useState2(generateRandomId),1)[0],m=d||"a".concat(v);useEffect2((function(){u&&_((function(e){var t={},n=0;for(var r in e)t[r]=e[r]&&0==n++;return t}))}),[u]);var y=useCallback2((function(e,t,n){var r=n.current;return _((function(n){return setExpanded(e,t,n,u)})),p.current=_objectSpread2(_objectSpread2({},p.current),{},_defineProperty({},e,r)),function(){_((function(t){return omit(t,e)})),p.current=omit(p.current,e)}}),[u]),b=useCallback2((function(e,t){_((function(n){var r=null!=t?t:!n[e],o=setExpanded(e,r,n,u);return resolvedPromise().then((function(){for(var e in n){var t=p.current[e];t&&n[e]!=o[e]&&t(o[e])}})),o}))}),[u]),A=useCallback2((function(e,t){var n;return null!==(n=s[e])&&void 0!==n?n:t}),[s]),h=useCallback2((function(e){if(e)e in s&&b(e);else if(!u)for(var t in s)b(t)}),[s,b,u]),g=useCallback2((function(e){if(e)A(e,!0)||b(e);else if(!u)for(var t in s)A(t,!0)||b(t)}),[s,b,A,u]),P=useCallback2((function(e){if(e)A(e,!1)&&b(e);else for(var t in s)A(t,!1)&&b(t)}),[s,b,A]);useImperativeHandle2(t,(function(){return{toggle:h,expand:g,collapse:P}}),[h,P,g]);var x=useMemo2((function(){return{registerSection:y,toggleExpanded:b,isExpanded:A,animate:r,prefix:m}}),[y,b,A,r,m]);return createElement2(a,_objectSpread2({id:d},l),createElement2(AccordionContext.Provider,{value:x},i))}var BentoAccordion=forwardRef2(BentoAccordionWithRef);function setExpanded(e,t,n,r){var o;if(r&&t)for(var a in o=_defineProperty({},e,t),n)a!=e&&(o[a]=!1);else o=_objectSpread2(_objectSpread2({},n),{},_defineProperty({},e,t));return o}function BentoAccordionSection(e){var t=e.animate,n=void 0!==t&&t,r=e.as,o=void 0===r?"section":r,a=e.children,i=e.expanded,c=void 0!==i&&i,u=e.id,d=e.onExpandStateChange,l=_objectWithoutPropertiesLoose(e,_excluded2),f=_slicedToArray(useState2(generateSectionId),1)[0],s=u||f,_=_slicedToArray(useState2(generateRandomId),1)[0],p=_slicedToArray(useState2(c),2),v=p[0],m=p[1],y=_slicedToArray(useState2(null),2),b=y[0],A=y[1],h=_slicedToArray(useState2(null),2),g=h[0],P=h[1],x=useContext2(AccordionContext),C=x.animate,S=x.isExpanded,O=x.prefix,E=x.registerSection,j=x.toggleExpanded,T=S?S(s,c):v,M=null!=C?C:n,I=b||"".concat(O||"a","-content-").concat(s,"-").concat(_),N=g||"".concat(O||"a","-header-").concat(s,"-").concat(_),L=useRef2(null);L.current=d,useLayoutEffect2((function(){if(E)return E(s,c,L)}),[E,s,c]);var R=useCallback2((function(e){j?j(s,e):m((function(t){var n=null!=e?e:!t;return resolvedPromise().then((function(){var e=L.current;e&&e(n)})),n}))}),[s,j]),w=useMemo2((function(){return{animate:M,contentId:I,headerId:N,expanded:T,toggleHandler:R,setContentId:A,setHeaderId:P}}),[M,I,N,T,R]);return createElement2(o,_objectSpread2({},l),createElement2(SectionContext.Provider,{value:w},a))}function BentoAccordionHeader(e){var t=e.as,n=void 0===t?"div":t,r=e.children,o=e.class,a=void 0===o?"":o,i=e.id,c=e.role,u=void 0===c?"button":c,d=e.tabIndex,l=void 0===d?0:d,f=_objectWithoutPropertiesLoose(e,_excluded3),s=useContext2(SectionContext),_=s.contentId,p=s.expanded,v=s.headerId,m=s.setHeaderId,y=s.toggleHandler;return useLayoutEffect2((function(){m&&m(i)}),[m,i]),createElement2(n,_objectSpread2(_objectSpread2({},f),{},{id:v,role:u,class:"".concat(a," ").concat($sectionChild," ").concat($header),tabIndex:l,"aria-controls":_,onClick:function(){return y()},"aria-expanded":String(p)}),r)}function BentoAccordionContent(e){var t=e.as,n=void 0===t?"div":t,r=e.children,o=e.class,a=void 0===o?"":o,i=e.id,c=e.role,u=void 0===c?"region":c,d=_objectWithoutPropertiesLoose(e,_excluded4),l=useRef2(null),f=useRef2(!1),s=useContext2(SectionContext),_=s.animate,p=s.contentId,v=s.expanded,m=s.headerId,y=s.setContentId;return useEffect2((function(){return f.current=!0,function(){return f.current=!1}}),[]),useLayoutEffect2((function(){y&&y(i)}),[y,i]),useLayoutEffect2((function(){var e=f.current,t=l.current;if(_&&e&&t&&t.animate)return v?animateExpand(t):animateCollapse(t)}),[v,_]),createElement2(WithAmpContext,{renderable:v},createElement2(n,_objectSpread2(_objectSpread2({},d),{},{ref:l,class:a+" "+$sectionChild+(v?"":" "+$contentHidden),id:p,"aria-labelledby":m,role:u}),r))}BentoAccordion.displayName="Accordion"; |
@@ -571,5 +571,3 @@ var __create = Object.create; | ||
}, [animate2, contentId, headerId, expanded, toggleHandler]); | ||
return createElement2(Comp, _extends({}, rest, { | ||
expanded: expanded | ||
}), createElement2(SectionContext.Provider, { | ||
return createElement2(Comp, _extends({}, rest), createElement2(SectionContext.Provider, { | ||
value: context2 | ||
@@ -576,0 +574,0 @@ }, children)); |
@@ -558,5 +558,3 @@ // extensions/amp-accordion/1.0/component.jss.js | ||
}), [animate2, contentId, headerId, expanded, toggleHandler]); | ||
return createElement2(Comp, _extends({}, rest, { | ||
expanded | ||
}), createElement2(SectionContext.Provider, { | ||
return createElement2(Comp, _extends({}, rest), createElement2(SectionContext.Provider, { | ||
value: context2 | ||
@@ -563,0 +561,0 @@ }, children)); |
@@ -1,1 +0,1 @@ | ||
var e;function n(){return e||(e=Promise.resolve(void 0))}function t(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function r(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 o(e){for(var n=1;n<arguments.length;n++){var o=null!=arguments[n]?arguments[n]:{};n%2?r(Object(o),!0).forEach((function(n){t(e,n,o[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):r(Object(o)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(o,n))}))}return e}function i(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}var{hasOwnProperty:c,toString:a}=Object.prototype;function l(e,n){return Object.keys(e).reduce(((t,r)=>(n.includes(r)||(t[r]=e[r]),t)),{})}import{cloneElement as u,createContext as d,createElement as s,createRef as f}from"react";import{hydrate as p,render as h}from"react-dom";import{useCallback as g,useContext as b,useEffect as y,useImperativeHandle as m,useLayoutEffect as v,useMemo as x,useRef as O,useState as w}from"react";function j(e,n,t){return s.apply(void 0,arguments)}function P(e){return d(e,void 0)}function S(e){return w(e)}function I(e){return O(e)}function E(e,n){y(e,n)}function $(e,n){v(e,n)}function z(e){return b(e)}function H(e,n){return x(e,n)}function M(e,n){return g(e,n)}import{Children as Y,createPortal as k,forwardRef as C}from"react";var D,A,L=["auto","lazy","eager","unload"],W={auto:0,lazy:1,eager:2,unload:3};function N(e,n){const t=W[e]||0,r=W[n]||0,o=Math.max(t,r);return L[o]}function U(){return D||(D=P({renderable:!0,playable:!0,loading:"auto"}))}function V({children:e,loading:n="auto",notify:t,playable:r=!0,renderable:o=!0}){const i=z(U()),c=o&&i.renderable,a=c&&r&&i.playable,l=N(c?"auto":"lazy",N(n,i.loading)),u=t||i.notify,d=H((()=>({renderable:c,playable:a,loading:l,notify:u})),[c,a,l,u]);return j(U().Provider,{children:e,value:d})}var q=["Webkit","webkit","Moz","moz","ms","O","o"];function B(e,n,t){if(K(n))return n;A||(A=Object.create(null));let r=A[n];if(!r||t){if(r=n,void 0===e[n]){const t=function(e,n){for(let t=0;t<q.length;t++){const r=q[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||(A[n]=r)}return r}function F(e,n,t,r,o){const i=B(e.style,n,o);if(!i)return;const c=r?t+r:t;K(i)?e.style.setProperty(i,c):e.style[i]=c}function G(e,n,t){const r=B(e.style,n,t);if(r)return K(r)?e.style.getPropertyValue(r):e.style[r]}function J(e,n){for(const t in n)F(e,t,n[t])}function K(e){return e.startsWith("--")}function Q(e,n,t){e.classList.add("i-amphtml-animating");let r=n();return r.onfinish=r.oncancel=()=>{r=null,t&&t(),e.classList.remove("i-amphtml-animating")},()=>{r&&r.cancel()}}function R(e){const n=window.innerHeight,t=Math.abs(e)/n*500;return Math.min(Math.max(t,200),500)}var T=["animate","as","children","expandSingleSection","id"],X=["animate","as","children","expanded","id","onExpandStateChange"],Z=["as","children","class","id","role","tabIndex"],_=["as","children","class","id","role"],ee=P({}),ne=P({}),te={},re={},oe=function(){let e=0;return()=>String(++e)}(),ie=()=>String(Math.floor(1e5*Math.random())),ce=C((function(e,t){let{animate:r=!1,as:c="section",children:a,expandSingleSection:u=!1,id:d}=e,s=i(e,T);const[f,p]=S(te),h=I(re),[g]=S(ie),b=d||`a${g}`;E((()=>{u&&p((e=>{const n={};let t=0;for(const r in e)n[r]=e[r]&&0==t++;return n}))}),[u]);const y=M(((e,n,{current:t})=>(p((t=>ae(e,n,t,u))),h.current=o(o({},h.current),{},{[e]:t}),()=>{p((n=>l(n,e))),h.current=l(h.current,e)})),[u]),v=M(((e,t)=>{p((r=>{const o=null!=t?t:!r[e],i=ae(e,o,r,u);return n().then((()=>{for(const e in r){const n=h.current[e];n&&r[e]!=i[e]&&n(i[e])}})),i}))}),[u]),x=M(((e,n)=>{var t;return null!==(t=f[e])&&void 0!==t?t:n}),[f]),O=M((e=>{if(e)e in f&&v(e);else if(!u)for(const e in f)v(e)}),[f,v,u]),w=M((e=>{if(e)x(e,!0)||v(e);else if(!u)for(const e in f)x(e,!0)||v(e)}),[f,v,x,u]),P=M((e=>{if(e)x(e,!1)&&v(e);else for(const e in f)x(e,!1)&&v(e)}),[f,v,x]);!function(e,n,t){m(e,(()=>({toggle:O,expand:w,collapse:P})),t)}(t,0,[O,P,w]);const $=H((()=>({registerSection:y,toggleExpanded:v,isExpanded:x,animate:r,prefix:b})),[y,v,x,r,b]);return j(c,o({id:d},s),j(ee.Provider,{value:$},a))}));function ae(e,n,t,r){let i;if(r&&n){i={[e]:n};for(const n in t)n!=e&&(i[n]=!1)}else i=o(o({},t),{},{[e]:n});return i}function le(e){let{animate:t=!1,as:r="section",children:c,expanded:a=!1,id:l,onExpandStateChange:u}=e,d=i(e,X);const[s]=S(oe),f=l||s,[p]=S(ie),[h,g]=S(a),[b,y]=S(null),[m,v]=S(null),{animate:x,isExpanded:O,prefix:w,registerSection:P,toggleExpanded:E}=z(ee),Y=O?O(f,a):h,k=null!=x?x:t,C=b||`${w||"a"}-content-${f}-${p}`,D=m||`${w||"a"}-header-${f}-${p}`,A=I(null);A.current=u,$((()=>{if(P)return P(f,a,A)}),[P,f,a]);const L=M((e=>{E?E(f,e):g((t=>{const r=null!=e?e:!t;return n().then((()=>{const e=A.current;e&&e(r)})),r}))}),[f,E]),W=H((()=>({animate:k,contentId:C,headerId:D,expanded:Y,toggleHandler:L,setContentId:y,setHeaderId:v})),[k,C,D,Y,L]);return j(r,o(o({},d),{},{expanded:Y}),j(ne.Provider,{value:W},c))}function ue(e){let{as:n="div",children:t,"class":r="",id:c,role:a="button",tabIndex:l=0}=e,u=i(e,Z);const{contentId:d,expanded:s,headerId:f,setHeaderId:p,toggleHandler:h}=z(ne);return $((()=>{p&&p(c)}),[p,c]),j(n,o(o({},u),{},{id:f,role:a,class:`${r} section-child-00fce3c header-00fce3c`,tabIndex:l,"aria-controls":d,onClick:()=>h(),"aria-expanded":String(s)}),t)}function de(e){let{as:n="div",children:t,"class":r="",id:c,role:a="region"}=e,l=i(e,_);const u=I(null),d=I(!1),{animate:s,contentId:f,expanded:p,headerId:h,setContentId:g}=z(ne);return E((()=>(d.current=!0,()=>d.current=!1)),[]),$((()=>{g&&g(c)}),[g,c]),$((()=>{const e=d.current,n=u.current;if(s&&e&&n&&n.animate)return p?function(e){return Q(e,(()=>{const n=G(e,"height"),t=G(e,"opacity"),r=G(e,"overflowY");J(e,{height:0,opacity:0,overflowY:"auto"});const o=e.scrollHeight;J(e,{height:n,opacity:t,overflowY:r});const i=R(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 Q(e,(()=>{const n=e.offsetHeight,t=R(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)}),[p,s]),j(V,{renderable:p},j(n,o(o({},l),{},{ref:u,class:r+" section-child-00fce3c"+(p?"":" content-hidden-00fce3c"),id:f,"aria-labelledby":h,role:a}),t))}ce.displayName="Accordion";export{ce as BentoAccordion,de as BentoAccordionContent,ue as BentoAccordionHeader,le 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.2109222204.0", | ||
"version": "1.2110011758.0", | ||
"description": "AMP HTML amp-accordion Component", | ||
@@ -18,3 +18,4 @@ "author": "The AMP HTML Authors", | ||
"require": "./dist/component-react.js" | ||
} | ||
}, | ||
"./styles.css": "./dist/styles.css" | ||
}, | ||
@@ -21,0 +22,0 @@ "files": [ |
@@ -10,3 +10,3 @@ # Bento Accordion | ||
Use Bento Accordion as a web component ([`<bento-accordion>`](#web-component)), or a Preact/React functional component ([`<BentoAccordion>`](#preact/react-component)). | ||
Use Bento Accordion as a web component ([`<bento-accordion>`](#web-component)), or a Preact/React functional component ([`<BentoAccordion>`](#preactreact-component)). | ||
@@ -13,0 +13,0 @@ - A Bento Accordion accepts one or more `<section>` elements as its direct |
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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
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
415785
49
2514
1