UNPKG

joomla-ui-custom-elements

Version:
2 lines (1 loc) 4.47 kB
function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,r(o.key),o)}}function r(e){var r=function(e,r){if("object"!=t(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,r||"default");if("object"!=t(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}(e,"string");return"symbol"==t(r)?r:r+""}function n(e,r,n){return r=u(r),function(e,r){if(r&&("object"==t(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(e)}(e,i()?Reflect.construct(r,n||[],u(e).constructor):r.apply(e,n))}function o(t){var e="function"==typeof Map?new Map:void 0;return o=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return function(t,e,r){if(i())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,e);var o=new(t.bind.apply(t,n));return r&&a(o,r.prototype),o}(t,arguments,u(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),a(r,t)},o(t)}function i(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(i=function(){return!!t})()}function a(t,e){return a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},a(t,e)}function u(t){return u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},u(t)}customElements.define("joomla-collapse",function(){function t(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),n(this,t,arguments)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&a(t,e)}(t,o(HTMLElement)),r=t,u=[{key:"observedAttributes",get:function(){return["state"]}}],(i=[{key:"state",get:function(){return this.getAttribute("state")},set:function(t){this.setAttribute("state",t)}},{key:"connectedCallback",value:function(){var t=this;this.id&&[].slice.call(document.querySelectorAll('[href="#'.concat(this.id,'"],[data-target="#').concat(this.id,'"]'))).forEach((function(e){!t.state||t.state&&"closed"===t.state?(t.state="closed",e.setAttribute("aria-expanded","false"),e.setAttribute("aria-controls",t.id)):(e.setAttribute("aria-expanded","true"),e.setAttribute("aria-controls",t.id)),e.addEventListener("click",(function(t){var e="";t.target.hasAttribute("data-target")||(e=t.target.getAttribute("href").replace("#","")),t.target.hasAttribute("href")||(e=t.target.getAttribute("data-target").replace("#","")),t.preventDefault(),t.stopPropagation(),document.getElementById(e).toggle()}))}))}},{key:"disconnectedCallback",value:function(){var t=document.querySelector('[href="#'.concat(this.id,'"]'));t||(t=document.querySelector('[data-target="#'.concat(this.id,'"]'))),t&&t.removeEventListener("click",this)}},{key:"attributeChangedCallback",value:function(t,e,r){var n=document.querySelector('[href="#'.concat(this.id,'"]'));"state"===t&&("closed"===r?n.setAttribute("aria-expanded","false"):"open"===r&&n.setAttribute("aria-expanded","true"))}},{key:"toggle",value:function(){var t=document.querySelector('[href="#'.concat(this.id,'"]'));t||(t=document.querySelector('[data-target="#'.concat(this.id,'"]'))),"closed"===this.state?(this.state="open",t.setAttribute("aria-expanded","true")):(this.state="closed",t.setAttribute("aria-expanded","false"))}}])&&e(r.prototype,i),u&&e(r,u),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,i,u}());