@ampproject/amp-accordion
Advanced tools
Comparing version 1.2109032350.0 to 1.2109102127.0
@@ -1,2 +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,{Accordion:function(){return Accordion},AccordionContent:function(){return AccordionContent},AccordionHeader:function(){return AccordionHeader},AccordionSection:function(){return AccordionSection}});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 AccordionWithRef(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 Accordion=forwardRef2(AccordionWithRef);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 AccordionSection(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 AccordionHeader(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 AccordionContent(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))}Accordion.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 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"; |
@@ -34,13 +34,13 @@ var __create = Object.create; | ||
__export(exports, { | ||
Accordion: function() { | ||
return Accordion; | ||
BentoAccordion: function() { | ||
return BentoAccordion; | ||
}, | ||
AccordionContent: function() { | ||
return AccordionContent; | ||
BentoAccordionContent: function() { | ||
return BentoAccordionContent; | ||
}, | ||
AccordionHeader: function() { | ||
return AccordionHeader; | ||
BentoAccordionHeader: function() { | ||
return BentoAccordionHeader; | ||
}, | ||
AccordionSection: function() { | ||
return AccordionSection; | ||
BentoAccordionSection: function() { | ||
return BentoAccordionSection; | ||
} | ||
@@ -392,3 +392,3 @@ }); | ||
var generateRandomId = randomIdGenerator(1e5); | ||
function AccordionWithRef(_ref, ref) { | ||
function BentoAccordionWithRef(_ref, ref) { | ||
var _ref$animate = _ref.animate, animate2 = _ref$animate === void 0 ? false : _ref$animate, _ref$as = _ref.as, Comp = _ref$as === void 0 ? "section" : _ref$as, children = _ref.children, _ref$expandSingleSect = _ref.expandSingleSection, expandSingleSection = _ref$expandSingleSect === void 0 ? false : _ref$expandSingleSect, id = _ref.id, rest = _objectWithoutPropertiesLoose(_ref, _excluded); | ||
@@ -508,4 +508,4 @@ var _useState = useState2(EMPTY_EXPANDED_MAP), expandedMap = _useState[0], setExpandedMap = _useState[1]; | ||
} | ||
var Accordion = forwardRef2(AccordionWithRef); | ||
Accordion.displayName = "Accordion"; | ||
var BentoAccordion = forwardRef2(BentoAccordionWithRef); | ||
BentoAccordion.displayName = "Accordion"; | ||
function setExpanded(id, value, expandedMap, expandSingleSection) { | ||
@@ -527,3 +527,3 @@ var newExpandedMap; | ||
} | ||
function AccordionSection(_ref3) { | ||
function BentoAccordionSection(_ref3) { | ||
var _ref3$animate = _ref3.animate, defaultAnimate = _ref3$animate === void 0 ? false : _ref3$animate, _ref3$as = _ref3.as, Comp = _ref3$as === void 0 ? "section" : _ref3$as, children = _ref3.children, _ref3$expanded = _ref3.expanded, defaultExpanded = _ref3$expanded === void 0 ? false : _ref3$expanded, propId = _ref3.id, onExpandStateChange = _ref3.onExpandStateChange, rest = _objectWithoutPropertiesLoose(_ref3, _excluded2); | ||
@@ -581,3 +581,3 @@ var _useState3 = useState2(generateSectionId), genId = _useState3[0]; | ||
} | ||
function AccordionHeader(_ref4) { | ||
function BentoAccordionHeader(_ref4) { | ||
var _ref4$as = _ref4.as, Comp = _ref4$as === void 0 ? "div" : _ref4$as, children = _ref4.children, _ref4$class = _ref4["class"], className = _ref4$class === void 0 ? "" : _ref4$class, id = _ref4.id, _ref4$role = _ref4.role, role = _ref4$role === void 0 ? "button" : _ref4$role, _ref4$tabIndex = _ref4.tabIndex, tabIndex = _ref4$tabIndex === void 0 ? 0 : _ref4$tabIndex, rest = _objectWithoutPropertiesLoose(_ref4, _excluded3); | ||
@@ -602,3 +602,3 @@ var _useContext2 = useContext2(SectionContext), contentId = _useContext2.contentId, expanded = _useContext2.expanded, headerId = _useContext2.headerId, setHeaderId = _useContext2.setHeaderId, toggleHandler = _useContext2.toggleHandler; | ||
} | ||
function AccordionContent(_ref5) { | ||
function BentoAccordionContent(_ref5) { | ||
var _objstr; | ||
@@ -605,0 +605,0 @@ var _ref5$as = _ref5.as, Comp = _ref5$as === void 0 ? "div" : _ref5$as, children = _ref5.children, _ref5$class = _ref5["class"], className = _ref5$class === void 0 ? "" : _ref5$class, id = _ref5.id, _ref5$role = _ref5.role, role = _ref5$role === void 0 ? "region" : _ref5$role, rest = _objectWithoutPropertiesLoose(_ref5, _excluded4); |
@@ -363,3 +363,3 @@ // extensions/amp-accordion/1.0/component.jss.js | ||
var generateRandomId = randomIdGenerator(1e5); | ||
function AccordionWithRef(_ref, ref) { | ||
function BentoAccordionWithRef(_ref, ref) { | ||
let { | ||
@@ -481,4 +481,4 @@ animate: animate2 = false, | ||
} | ||
var Accordion = forwardRef2(AccordionWithRef); | ||
Accordion.displayName = "Accordion"; | ||
var BentoAccordion = forwardRef2(BentoAccordionWithRef); | ||
BentoAccordion.displayName = "Accordion"; | ||
function setExpanded(id, value, expandedMap, expandSingleSection) { | ||
@@ -502,3 +502,3 @@ let newExpandedMap; | ||
} | ||
function AccordionSection(_ref2) { | ||
function BentoAccordionSection(_ref2) { | ||
let { | ||
@@ -567,3 +567,3 @@ animate: defaultAnimate = false, | ||
} | ||
function AccordionHeader(_ref3) { | ||
function BentoAccordionHeader(_ref3) { | ||
let { | ||
@@ -599,3 +599,3 @@ as: Comp = "div", | ||
} | ||
function AccordionContent(_ref4) { | ||
function BentoAccordionContent(_ref4) { | ||
let { | ||
@@ -649,7 +649,7 @@ as: Comp = "div", | ||
export { | ||
Accordion, | ||
AccordionContent, | ||
AccordionHeader, | ||
AccordionSection | ||
BentoAccordion, | ||
BentoAccordionContent, | ||
BentoAccordionHeader, | ||
BentoAccordionSection | ||
}; | ||
//# sourceMappingURL=component-preact.max.module.js.map |
@@ -1,2 +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 Accordion,de as AccordionContent,ue as AccordionHeader,le as AccordionSection}; | ||
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}; |
@@ -1,2 +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,{Accordion:function(){return Accordion},AccordionContent:function(){return AccordionContent},AccordionHeader:function(){return AccordionHeader},AccordionSection:function(){return AccordionSection}});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 AccordionWithRef(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 Accordion=forwardRef2(AccordionWithRef);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 AccordionSection(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 AccordionHeader(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 AccordionContent(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))}Accordion.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 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"; |
@@ -34,13 +34,13 @@ var __create = Object.create; | ||
__export(exports, { | ||
Accordion: function() { | ||
return Accordion; | ||
BentoAccordion: function() { | ||
return BentoAccordion; | ||
}, | ||
AccordionContent: function() { | ||
return AccordionContent; | ||
BentoAccordionContent: function() { | ||
return BentoAccordionContent; | ||
}, | ||
AccordionHeader: function() { | ||
return AccordionHeader; | ||
BentoAccordionHeader: function() { | ||
return BentoAccordionHeader; | ||
}, | ||
AccordionSection: function() { | ||
return AccordionSection; | ||
BentoAccordionSection: function() { | ||
return BentoAccordionSection; | ||
} | ||
@@ -392,3 +392,3 @@ }); | ||
var generateRandomId = randomIdGenerator(1e5); | ||
function AccordionWithRef(_ref, ref) { | ||
function BentoAccordionWithRef(_ref, ref) { | ||
var _ref$animate = _ref.animate, animate2 = _ref$animate === void 0 ? false : _ref$animate, _ref$as = _ref.as, Comp = _ref$as === void 0 ? "section" : _ref$as, children = _ref.children, _ref$expandSingleSect = _ref.expandSingleSection, expandSingleSection = _ref$expandSingleSect === void 0 ? false : _ref$expandSingleSect, id = _ref.id, rest = _objectWithoutPropertiesLoose(_ref, _excluded); | ||
@@ -508,4 +508,4 @@ var _useState = useState2(EMPTY_EXPANDED_MAP), expandedMap = _useState[0], setExpandedMap = _useState[1]; | ||
} | ||
var Accordion = forwardRef2(AccordionWithRef); | ||
Accordion.displayName = "Accordion"; | ||
var BentoAccordion = forwardRef2(BentoAccordionWithRef); | ||
BentoAccordion.displayName = "Accordion"; | ||
function setExpanded(id, value, expandedMap, expandSingleSection) { | ||
@@ -527,3 +527,3 @@ var newExpandedMap; | ||
} | ||
function AccordionSection(_ref3) { | ||
function BentoAccordionSection(_ref3) { | ||
var _ref3$animate = _ref3.animate, defaultAnimate = _ref3$animate === void 0 ? false : _ref3$animate, _ref3$as = _ref3.as, Comp = _ref3$as === void 0 ? "section" : _ref3$as, children = _ref3.children, _ref3$expanded = _ref3.expanded, defaultExpanded = _ref3$expanded === void 0 ? false : _ref3$expanded, propId = _ref3.id, onExpandStateChange = _ref3.onExpandStateChange, rest = _objectWithoutPropertiesLoose(_ref3, _excluded2); | ||
@@ -581,3 +581,3 @@ var _useState3 = useState2(generateSectionId), genId = _useState3[0]; | ||
} | ||
function AccordionHeader(_ref4) { | ||
function BentoAccordionHeader(_ref4) { | ||
var _ref4$as = _ref4.as, Comp = _ref4$as === void 0 ? "div" : _ref4$as, children = _ref4.children, _ref4$class = _ref4["class"], className = _ref4$class === void 0 ? "" : _ref4$class, id = _ref4.id, _ref4$role = _ref4.role, role = _ref4$role === void 0 ? "button" : _ref4$role, _ref4$tabIndex = _ref4.tabIndex, tabIndex = _ref4$tabIndex === void 0 ? 0 : _ref4$tabIndex, rest = _objectWithoutPropertiesLoose(_ref4, _excluded3); | ||
@@ -602,3 +602,3 @@ var _useContext2 = useContext2(SectionContext), contentId = _useContext2.contentId, expanded = _useContext2.expanded, headerId = _useContext2.headerId, setHeaderId = _useContext2.setHeaderId, toggleHandler = _useContext2.toggleHandler; | ||
} | ||
function AccordionContent(_ref5) { | ||
function BentoAccordionContent(_ref5) { | ||
var _objstr; | ||
@@ -605,0 +605,0 @@ var _ref5$as = _ref5.as, Comp = _ref5$as === void 0 ? "div" : _ref5$as, children = _ref5.children, _ref5$class = _ref5["class"], className = _ref5$class === void 0 ? "" : _ref5$class, id = _ref5.id, _ref5$role = _ref5.role, role = _ref5$role === void 0 ? "region" : _ref5$role, rest = _objectWithoutPropertiesLoose(_ref5, _excluded4); |
@@ -363,3 +363,3 @@ // extensions/amp-accordion/1.0/component.jss.js | ||
var generateRandomId = randomIdGenerator(1e5); | ||
function AccordionWithRef(_ref, ref) { | ||
function BentoAccordionWithRef(_ref, ref) { | ||
let { | ||
@@ -481,4 +481,4 @@ animate: animate2 = false, | ||
} | ||
var Accordion = forwardRef2(AccordionWithRef); | ||
Accordion.displayName = "Accordion"; | ||
var BentoAccordion = forwardRef2(BentoAccordionWithRef); | ||
BentoAccordion.displayName = "Accordion"; | ||
function setExpanded(id, value, expandedMap, expandSingleSection) { | ||
@@ -502,3 +502,3 @@ let newExpandedMap; | ||
} | ||
function AccordionSection(_ref2) { | ||
function BentoAccordionSection(_ref2) { | ||
let { | ||
@@ -567,3 +567,3 @@ animate: defaultAnimate = false, | ||
} | ||
function AccordionHeader(_ref3) { | ||
function BentoAccordionHeader(_ref3) { | ||
let { | ||
@@ -599,3 +599,3 @@ as: Comp = "div", | ||
} | ||
function AccordionContent(_ref4) { | ||
function BentoAccordionContent(_ref4) { | ||
let { | ||
@@ -649,7 +649,7 @@ as: Comp = "div", | ||
export { | ||
Accordion, | ||
AccordionContent, | ||
AccordionHeader, | ||
AccordionSection | ||
BentoAccordion, | ||
BentoAccordionContent, | ||
BentoAccordionHeader, | ||
BentoAccordionSection | ||
}; | ||
//# sourceMappingURL=component-react.max.module.js.map |
@@ -1,2 +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 Accordion,de as AccordionContent,ue as AccordionHeader,le as AccordionSection}; | ||
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}; |
{ | ||
"name": "@ampproject/amp-accordion", | ||
"version": "1.2109032350.0", | ||
"version": "1.2109102127.0", | ||
"description": "AMP HTML amp-accordion Component", | ||
@@ -5,0 +5,0 @@ "author": "The AMP HTML Authors", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
416323
20
1
626
2522