@preline/accordion 1.2.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Html Stream
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/index.d.ts ADDED
@@ -0,0 +1,55 @@
1
+ export interface IAccordion {
2
+ options?: {};
3
+ show(): void;
4
+ hide(): void;
5
+ }
6
+ export interface IBasePlugin<O, E> {
7
+ el: E;
8
+ options?: O;
9
+ events?: {};
10
+ }
11
+ declare class HSBasePlugin<O, E = HTMLElement> implements IBasePlugin<O, E> {
12
+ el: E;
13
+ options: O;
14
+ events?: any;
15
+ constructor(el: E, options: O, events?: any);
16
+ isIOS(): boolean;
17
+ isIpadOS(): boolean;
18
+ createCollection(collection: any[], element: any): void;
19
+ fireEvent(evt: string, payload?: any): any;
20
+ dispatch(evt: string, element: any, payload?: any): void;
21
+ on(evt: string, cb: Function): void;
22
+ afterTransition(el: HTMLElement, callback: Function): void;
23
+ onTransitionEnd(el: HTMLElement, cb: Function): void;
24
+ getClassProperty(el: HTMLElement, prop: string, val?: string): string;
25
+ getClassPropertyAlt(el: HTMLElement, prop?: string, val?: string): string;
26
+ htmlToElement(html: string): HTMLElement;
27
+ classToClassList(classes: string, target: HTMLElement, splitter?: string): void;
28
+ debounce(func: Function, timeout?: number): (...args: any[]) => void;
29
+ checkIfFormElement(target: HTMLElement): boolean;
30
+ static isEnoughSpace(el: HTMLElement, toggle: HTMLElement, preferredPosition?: "top" | "bottom" | "auto", space?: number, wrapper?: HTMLElement | null): boolean;
31
+ static isParentOrElementHidden(element: any): any;
32
+ }
33
+ declare class HSAccordion extends HSBasePlugin<{}> implements IAccordion {
34
+ private readonly toggle;
35
+ content: HTMLElement | null;
36
+ private readonly group;
37
+ private readonly isAlwaysOpened;
38
+ constructor(el: HTMLElement, options?: {}, events?: {});
39
+ private init;
40
+ show(): boolean;
41
+ hide(): boolean;
42
+ static getInstance(target: HTMLElement | string, isInstance?: boolean): HTMLElement | {
43
+ id: number;
44
+ element: HSAccordion;
45
+ };
46
+ static show(target: HTMLElement): void;
47
+ static hide(target: HTMLElement): void;
48
+ static on(evt: string, target: HTMLElement, cb: Function): void;
49
+ }
50
+
51
+ export {
52
+ HSAccordion as default,
53
+ };
54
+
55
+ export {};
package/index.js CHANGED
@@ -1,2 +1,2 @@
1
- /*! For license information please see hs-accordion.js.LICENSE.txt */
2
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var o in n)("object"==typeof exports?exports:e)[o]=n[o]}}(self,(function(){return(()=>{"use strict";var e={765:(e,t,n)=>{function o(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}n.d(t,{Z:()=>r});var r=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.$collection=[],this.selector=t,this.config=n,this.events={}}var t,n;return t=e,n=[{key:"_fireEvent",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.events.hasOwnProperty(e)&&this.events[e](t)}},{key:"_dispatch",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,o=new CustomEvent(e,{detail:{payload:n},bubbles:!0,cancelable:!0,composed:!1});t.dispatchEvent(o)}},{key:"on",value:function(e,t){this.events[e]=t}},{key:"afterTransition",value:function(e,t){"all 0s ease 0s"!==window.getComputedStyle(e,null).getPropertyValue("transition")?e.addEventListener("transitionend",(function n(){t(),e.removeEventListener("transitionend",n,!0)}),!0):t()}},{key:"getClassProperty",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",o=(window.getComputedStyle(e).getPropertyValue(t)||n).replace(" ","");return o}}],n&&o(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),e}()}},t={};function n(o){var r=t[o];if(void 0!==r)return r.exports;var i=t[o]={exports:{}};return e[o](i,i.exports,n),i.exports}n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return(()=>{function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function r(e,t){return r=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},r(e,t)}function i(t,n){if(n&&("object"===e(n)||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(t)}function c(e){return c=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},c(e)}n.r(o);var a=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&r(e,t)}(u,e);var n,o,a,s,l=(a=u,s=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=c(a);if(s){var n=c(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return i(this,e)});function u(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,u),l.call(this,".hs-accordion")}return n=u,(o=[{key:"init",value:function(){var e=this;document.addEventListener("click",(function(t){var n=t.target,o=n.closest(e.selector),r=n.closest(".hs-accordion-toggle"),i=n.closest(".hs-accordion-group");o&&i&&r&&(e._hideAll(o),e.show(o))}))}},{key:"show",value:function(e){var t=this;if(e.classList.contains("active"))return this.hide(e);e.classList.add("active");var n=e.querySelector(".hs-accordion-content");n.style.display="block",n.style.height=0,setTimeout((function(){n.style.height="".concat(n.scrollHeight,"px")})),this.afterTransition(n,(function(){e.classList.contains("active")&&(n.style.height="",t._fireEvent("open",e),t._dispatch("open.hs.accordion",e,e))}))}},{key:"hide",value:function(e){var t=this,n=e.querySelector(".hs-accordion-content");n.style.height="".concat(n.scrollHeight,"px"),setTimeout((function(){n.style.height=0})),this.afterTransition(n,(function(){e.classList.contains("active")||(n.style.display="",t._fireEvent("hide",e),t._dispatch("hide.hs.accordion",e,e))})),e.classList.remove("active")}},{key:"_hideAll",value:function(e){var t=this,n=e.closest(".hs-accordion-group");n.hasAttribute("data-hs-accordion-always-open")||n.querySelectorAll(this.selector).forEach((function(n){e!==n&&t.hide(n)}))}}])&&t(n.prototype,o),Object.defineProperty(n,"prototype",{writable:!1}),u}(n(765).Z);window.HSAccordion=new a,document.addEventListener("load",window.HSAccordion.init())})(),o})()}));
1
+ /*! For license information please see LICENSE */
2
+ !function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n=e();for(var o in n)("object"==typeof exports?exports:t)[o]=n[o]}}(self,(()=>(()=>{"use strict";var t={460:function(t,e,n){var o,i=this&&this.__extends||(o=function(t,e){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},o(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var r=function(t){function e(e,n,o){var i=t.call(this,e,n,o)||this;return i.toggle=i.el.querySelector(".hs-accordion-toggle")||null,i.content=i.el.querySelector(".hs-accordion-content")||null,i.group=i.el.closest(".hs-accordion-group")||null,i.isAlwaysOpened=i.group.hasAttribute("data-hs-accordion-always-open")||!1,i.toggle&&i.content&&i.init(),i}return i(e,t),e.prototype.init=function(){var t=this;this.createCollection(window.$hsAccordionCollection,this),this.toggle.addEventListener("click",(function(){t.el.classList.contains("active")?t.hide():t.show()}))},e.prototype.show=function(){var t=this;if(this.group&&!this.isAlwaysOpened&&this.group.querySelector(".hs-accordion.active")&&this.group.querySelector(".hs-accordion.active")!==this.el&&window.$hsAccordionCollection.find((function(e){return e.element.el===t.group.querySelector(".hs-accordion.active")})).element.hide(),this.el.classList.contains("active"))return!1;this.el.classList.add("active"),this.content.style.display="block",this.content.style.height="0",setTimeout((function(){t.content.style.height="".concat(t.content.scrollHeight,"px")})),this.afterTransition(this.content,(function(){t.content.style.height="",t.fireEvent("open",t.el),t.dispatch("open.hs.accordion",t.el,t.el)}))},e.prototype.hide=function(){var t=this;if(!this.el.classList.contains("active"))return!1;this.el.classList.remove("active"),this.content.style.height="".concat(this.content.scrollHeight,"px"),setTimeout((function(){t.content.style.height="0"})),this.afterTransition(this.content,(function(){t.content.style.display="",t.fireEvent("close",t.el),t.dispatch("close.hs.accordion",t.el,t.el)}))},e.getInstance=function(t,e){var n=window.$hsAccordionCollection.find((function(e){return e.element.el===("string"==typeof t?document.querySelector(t):t)}));return n?e?n:n.element.el:null},e.show=function(t){var e=window.$hsAccordionCollection.find((function(e){return e.element.el===("string"==typeof t?document.querySelector(t):t)}));e&&"block"!==e.element.content.style.display&&e.element.show()},e.hide=function(t){var e=window.$hsAccordionCollection.find((function(e){return e.element.el===("string"==typeof t?document.querySelector(t):t)}));e&&"block"===e.element.content.style.display&&e.element.hide()},e.on=function(t,e,n){var o=window.$hsAccordionCollection.find((function(t){return t.element.el===("string"==typeof e?document.querySelector(e):e)}));o&&(o.element.events[t]=n)},e}(n(737).default);window.addEventListener("load",(function(){window.$hsAccordionCollection||(window.$hsAccordionCollection=[]),document.querySelectorAll(".hs-accordion:not(.--prevent-on-load-init)").forEach((function(t){return new r(t)}))})),t.exports.HSAccordion=r,e.default=r},737:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t,e,n){this.el=t,this.options=e,this.events=n,this.el=t,this.options=e,this.events={}}return t.prototype.isIOS=function(){return!!/iPad|iPhone|iPod/.test(navigator.platform)||navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform)},t.prototype.isIpadOS=function(){return navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform)},t.prototype.createCollection=function(t,e){var n;t.push({id:(null===(n=null==e?void 0:e.el)||void 0===n?void 0:n.id)||t.length+1,element:e})},t.prototype.fireEvent=function(t,e){if(void 0===e&&(e=null),this.events.hasOwnProperty(t))return this.events[t](e)},t.prototype.dispatch=function(t,e,n){void 0===n&&(n=null);var o=new CustomEvent(t,{detail:{payload:n},bubbles:!0,cancelable:!0,composed:!1});e.dispatchEvent(o)},t.prototype.on=function(t,e){this.events[t]=e},t.prototype.afterTransition=function(t,e){var n=function(){e(),t.removeEventListener("transitionend",n,!0)};"all 0s ease 0s"!==window.getComputedStyle(t,null).getPropertyValue("transition")?t.addEventListener("transitionend",n,!0):e()},t.prototype.onTransitionEnd=function(t,e){t.addEventListener("transitionend",(function n(o){o.target===t&&(t.removeEventListener("transitionend",n),e())}))},t.prototype.getClassProperty=function(t,e,n){return void 0===n&&(n=""),(window.getComputedStyle(t).getPropertyValue(e)||n).replace(" ","")},t.prototype.getClassPropertyAlt=function(t,e,n){void 0===n&&(n="");var o="";return t.classList.forEach((function(t){t.includes(e)&&(o=t)})),o.match(/:(.*)]/)?o.match(/:(.*)]/)[1]:n},t.prototype.htmlToElement=function(t){var e=document.createElement("template");return t=t.trim(),e.innerHTML=t,e.content.firstChild},t.prototype.classToClassList=function(t,e,n){void 0===n&&(n=" "),t.split(n).forEach((function(t){return e.classList.add(t)}))},t.prototype.debounce=function(t,e){var n,o=this;return void 0===e&&(e=200),function(){for(var i=[],r=0;r<arguments.length;r++)i[r]=arguments[r];clearTimeout(n),n=setTimeout((function(){t.apply(o,i)}),e)}},t.prototype.checkIfFormElement=function(t){return t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement},t.isEnoughSpace=function(t,e,n,o,i){void 0===n&&(n="auto"),void 0===o&&(o=10),void 0===i&&(i=null);var r=e.getBoundingClientRect(),c=i?i.getBoundingClientRect():null,s=window.innerHeight,l=c?r.top-c.top:r.top,a=(i?c.bottom:s)-r.bottom,u=t.clientHeight+o;return"bottom"===n?a>=u:"top"===n?l>=u:l>=u||a>=u},t.isParentOrElementHidden=function(t){return!!t&&("none"===window.getComputedStyle(t).display||this.isParentOrElementHidden(t.parentElement))},t}();e.default=n,window.HSStaticMethods={afterTransition:function(t,e){var n=function(){e(),t.removeEventListener("transitionend",n,!0)};"all 0s ease 0s"!==window.getComputedStyle(t,null).getPropertyValue("transition")?t.addEventListener("transitionend",n,!0):e()},getClassPropertyAlt:function(t,e,n){void 0===n&&(n="");var o="";return t.classList.forEach((function(t){t.includes(e)&&(o=t)})),o.match(/:(.*)]/)?o.match(/:(.*)]/)[1]:n},getClassProperty:function(t,e,n){return void 0===n&&(n=""),(window.getComputedStyle(t).getPropertyValue(e)||n).replace(" ","")}}}},e={};return function n(o){var i=e[o];if(void 0!==i)return i.exports;var r=e[o]={exports:{}};return t[o].call(r.exports,r,r.exports,n),r.exports}(460)})()));
package/package.json CHANGED
@@ -1,9 +1,11 @@
1
1
  {
2
2
  "name": "@preline/accordion",
3
- "version": "1.2.0",
3
+ "version": "2.0.0",
4
4
  "description": "Preline UI is an open-source set of prebuilt UI components based on the utility-first Tailwind CSS framework.",
5
5
  "main": "index.js",
6
+ "types": "index.d.ts",
6
7
  "repository": "https://github.com/htmlstreamofficial/preline.git",
8
+ "homepage": "https://preline.co/plugins.html",
7
9
  "keywords": [
8
10
  "preline",
9
11
  "html",
@@ -14,6 +16,7 @@
14
16
  "react",
15
17
  "angular",
16
18
  "javascript",
19
+ "typescript",
17
20
  "tailwind",
18
21
  "tailwind components",
19
22
  "tailwind elements",
@@ -26,7 +29,8 @@
26
29
  "tailwind css angular",
27
30
  "tailwind css laravel",
28
31
  "tailwindcss plugin",
29
- "tailwindcss plugins"
32
+ "tailwindcss plugins",
33
+ "accordion"
30
34
  ],
31
35
  "author": "Htmlstream",
32
36
  "license": "MIT",
package/LICENSE.txt DELETED
@@ -1,15 +0,0 @@
1
- /*
2
- * Component
3
- * @version: 1.0.0
4
- * @author: HtmlStream
5
- * @license: Licensed under MIT (https://preline.co/docs/license.html)
6
- * Copyright 2022 Htmlstream
7
- */
8
-
9
- /*
10
- * HSAccordion
11
- * @version: 1.0.0
12
- * @author: HtmlStream
13
- * @license: Licensed under MIT (https://preline.co/docs/license.html)
14
- * Copyright 2022 Htmlstream
15
- */