@preline/accordion 4.1.3 → 5.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/README.md ADDED
@@ -0,0 +1,432 @@
1
+ # Accordion
2
+
3
+ Build vertically collapsing accordions in combination with Accordion JavaScript plugin.
4
+
5
+ [![npm](https://img.shields.io/badge/npm-v4.2.0-blue)](https://www.npmjs.com/package/@preline/accordion) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) [![Demo](https://img.shields.io/badge/demo-online-brightgreen)](https://preline.co/plugins/accordion.html)
6
+
7
+ ## Contents
8
+
9
+ - [Overview](#overview)
10
+ - [Installation](#installation)
11
+ - [Basic usage](#basic-usage)
12
+ - [Configuration Options](#configuration-options)
13
+ - [JavaScript API](#javascript-api)
14
+ - [Events](#events)
15
+ - [Common Patterns](#common-patterns)
16
+ - [License](#license)
17
+
18
+ ## Overview
19
+
20
+ The Accordion component allows you to create collapsible content sections that can be expanded or collapsed by clicking on toggle buttons. It supports multiple accordion items within a group, with options for keeping items open, ensuring at least one item stays open, and treeview mode for hierarchical structures.
21
+
22
+ **Key Features:**
23
+ - Multiple accordion items in a single group
24
+ - Programmatic control via JavaScript API
25
+ - Event system for lifecycle hooks
26
+ - Treeview mode support
27
+ - Accessibility attributes (ARIA) built-in
28
+
29
+ ## Installation
30
+
31
+ To get started, install Accordion plugin via npm, else you can skip this step if you are already using Preline UI as a package.
32
+
33
+ ```bash
34
+ npm i @preline/accordion
35
+ ```
36
+
37
+ ### CSS
38
+
39
+ Use [`@source`](https://tailwindcss.com/docs/functions-and-directives#source-directive) to register the plugin's JavaScript path for Tailwind CSS scanning, then [`@import`](https://tailwindcss.com/docs/functions-and-directives#import-directive) the plugin's CSS files into your Tailwind CSS file.
40
+
41
+ ```css
42
+ @import "tailwindcss";
43
+
44
+ /* @preline/accordion */
45
+ @source "../node_modules/@preline/accordion/*.js";
46
+ @import "./node_modules/@preline/accordion/variants.css";
47
+ @import "./node_modules/@preline/accordion/theme.css";
48
+ ```
49
+
50
+ ### JavaScript
51
+
52
+ Include the JavaScript that powers the interactive elements near the end of your `</body>` tag:
53
+
54
+ ```html
55
+ <script src="./node_modules/@preline/accordion/index.js"></script>
56
+ ```
57
+
58
+ ### Manual Initialization
59
+
60
+ Use the `non-auto` entry if you need manual initialization. In this mode, automatic initialization on page load is not included, so the component should be initialized explicitly.
61
+
62
+ ```html
63
+ <script type="module">
64
+ import HSAccordion from "@preline/accordion/non-auto.mjs";
65
+
66
+ new HSAccordion(document.querySelector("#accordion"));
67
+ </script>
68
+ ```
69
+
70
+ ### Via Bundler
71
+
72
+ When using a bundler (Vite, webpack, etc.), import the plugin directly as an ES module.
73
+
74
+ `@preline/accordion` is the auto-init entry: it scans the DOM and initializes matching elements automatically.
75
+
76
+ ```js
77
+ import "@preline/accordion";
78
+ ```
79
+
80
+ `@preline/accordion/non-auto` is the manual entry: use it when you want explicit control over when initialization happens, either via `autoInit()` or by creating a specific instance yourself.
81
+
82
+ ```js
83
+ import HSAccordion from "@preline/accordion/non-auto";
84
+
85
+ HSAccordion.autoInit();
86
+
87
+ // Or initialize a specific element manually
88
+ const el = document.querySelector("#accordion");
89
+ if (el) new HSAccordion(el);
90
+ ```
91
+
92
+ ### TypeScript
93
+
94
+ This package ships with TypeScript type definitions. No additional `@types/` package is needed.
95
+
96
+ ## Basic usage
97
+
98
+ The following example demonstrates the minimal HTML structure required for an accordion component. This is a base template without custom styling - you can apply your own CSS classes and styles as needed. The example shows three accordion items within a group, with the first item open by default.
99
+
100
+ ```html
101
+ <div class="hs-accordion-group">
102
+ <div class="hs-accordion active" id="hs-unstyled-heading-one">
103
+ <button class="hs-accordion-toggle" aria-expanded="true" aria-controls="hs-unstyled-collapse-one">
104
+ Accordion #1
105
+ </button>
106
+ <div id="hs-unstyled-collapse-one" class="hs-accordion-content overflow-hidden transition-[height] duration-300" role="region" aria-labelledby="hs-unstyled-heading-one">
107
+ Accordion content that expands and collapses when the toggle button is clicked.
108
+ </div>
109
+ </div>
110
+
111
+ <div class="hs-accordion" id="hs-unstyled-heading-two">
112
+ <button class="hs-accordion-toggle" aria-expanded="false" aria-controls="hs-unstyled-collapse-two">
113
+ Accordion #2
114
+ </button>
115
+ <div id="hs-unstyled-collapse-two" class="hs-accordion-content hidden overflow-hidden transition-[height] duration-300" role="region" aria-labelledby="hs-unstyled-heading-two">
116
+ Accordion content that expands and collapses when the toggle button is clicked.
117
+ </div>
118
+ </div>
119
+
120
+ <div class="hs-accordion" id="hs-unstyled-heading-three">
121
+ <button class="hs-accordion-toggle" aria-expanded="false" aria-controls="hs-unstyled-collapse-three">
122
+ Accordion #3
123
+ </button>
124
+ <div id="hs-unstyled-collapse-three" class="hs-accordion-content hidden overflow-hidden transition-[height] duration-300" role="region" aria-labelledby="hs-unstyled-heading-three">
125
+ Accordion content that expands and collapses when the toggle button is clicked.
126
+ </div>
127
+ </div>
128
+ </div>
129
+ ```
130
+
131
+ **Structure Requirements:**
132
+ - `hs-accordion-group`: Required wrapper container for all accordion items
133
+ - `hs-accordion`: Required container for each accordion item
134
+ - `hs-accordion-toggle`: Required button element that triggers expand/collapse
135
+ - `hs-accordion-content`: Required container for collapsible content
136
+ - Unique `id` attributes for each accordion item and its content
137
+ - Proper ARIA attributes (`aria-expanded`, `aria-controls`, `aria-labelledby`, `role="region"`)
138
+
139
+ **Initial State:**
140
+ - To have an accordion item open by default, add the `active` class to the `hs-accordion` element
141
+ - For closed items, add the `hidden` class to the `hs-accordion-content` element
142
+
143
+ ## Configuration Options
144
+
145
+ ### Data Attributes
146
+
147
+ Data attributes are added directly to HTML elements to configure accordion behavior.
148
+
149
+ | Attribute | Target Element | Type | Default | Description |
150
+ | --- | --- | --- | --- | --- |
151
+ | `data-hs-accordion-always-open` | `hs-accordion-group` | boolean attribute | `false` (absent) | When present (boolean attribute), accordion items stay open when another item is opened. By default, opening one item closes others. Presence of attribute = `true`, absence = `false`. |
152
+
153
+ **Example:**
154
+ ```html
155
+ <!-- Boolean attribute: presence = true, absence = false -->
156
+ <div class="hs-accordion-group" data-hs-accordion-always-open>
157
+ <!-- Multiple items can be open simultaneously -->
158
+ </div>
159
+ ```
160
+
161
+ ### CSS Classes (Modifiers)
162
+
163
+ CSS class modifiers use Tailwind-style syntax with `--` prefix to control behavior.
164
+
165
+ | Class Modifier | Target Element | Values | Default | Description |
166
+ | --- | --- | --- | --- | --- |
167
+ | `--stop-propagation:*` | `hs-accordion-toggle` | `"true"` \| `"false"` | `"false"` | When `"true"`, interrupts event propagation when toggle button is clicked. Useful when accordion is nested inside clickable elements. |
168
+ | `--keep-one-open:*` | `hs-accordion-group` | `"true"` \| `"false"` | `"false"` | When `"true"`, ensures at least one accordion item remains open at all times. Prevents closing the last open item. |
169
+
170
+ **Example:**
171
+ ```html
172
+ <div class="hs-accordion-group --keep-one-open:true">
173
+ <!-- At least one item will always be open -->
174
+ </div>
175
+
176
+ <button class="hs-accordion-toggle --stop-propagation:true">
177
+ <!-- Click event won't bubble up -->
178
+ </button>
179
+ ```
180
+
181
+ ### Required CSS Classes
182
+
183
+ These classes define the structure and must be present for the accordion to function.
184
+
185
+ | Class | Required On | Purpose |
186
+ | --- | --- | --- |
187
+ | `hs-accordion-group` | Container wrapper | Groups multiple accordion items together |
188
+ | `hs-accordion` | Each accordion item container | Identifies an individual accordion item |
189
+ | `hs-accordion-toggle` | Button element | The clickable element that expands/collapses content |
190
+ | `hs-accordion-content` | Content container | The collapsible content area |
191
+
192
+ ### Optional CSS Classes
193
+
194
+ | Class | Required On | Purpose |
195
+ | --- | --- | --- |
196
+ | `hs-accordion-treeview-root` | Parent container | When present, activates treeview mode for hierarchical accordion structures |
197
+ | `hs-accordion-selectable` | Elements inside treeview | When treeview mode is active, elements with this class become selectable |
198
+
199
+ **Treeview Mode Example:**
200
+ ```html
201
+ <div class="hs-accordion-treeview-root">
202
+ <div class="hs-accordion-group">
203
+ <div class="hs-accordion">
204
+ <button class="hs-accordion-toggle">Parent</button>
205
+ <div class="hs-accordion-content">
206
+ <div class="hs-accordion-selectable">Selectable item</div>
207
+ </div>
208
+ </div>
209
+ </div>
210
+ </div>
211
+ ```
212
+
213
+ ## JavaScript API
214
+
215
+ The `HSAccordion` object is available in the global `window` object after the plugin is loaded.
216
+
217
+ ### Instance Methods
218
+
219
+ These methods are called on an accordion instance.
220
+
221
+ | Method | Parameters | Return Type | Description |
222
+ | --- | --- | --- | --- |
223
+ | `show()` | None | `boolean` | Opens the collapsed accordion item. Returns `false` if item is already open, `true` otherwise. If other items are open and `always-open` is not set, they will be closed. |
224
+ | `hide()` | None | `boolean` | Collapses the currently open accordion item. Returns `false` if item is already closed or if `keep-one-open` is enabled and this is the last open item, `true` otherwise. |
225
+ | `destroy()` | None | `void` | Destroys the accordion instance, removes all generated markup, classes, and event listeners. Use when removing accordion from DOM. |
226
+
227
+ ### Static Methods
228
+
229
+ These methods are called directly on the `HSAccordion` class.
230
+
231
+ | Method | Parameters | Return Type | Description |
232
+ | --- | --- | --- | --- |
233
+ | `HSAccordion.getInstance(target, isInstance)` | `target`: `HTMLElement \| string` (CSS selector)<br>`isInstance`: `boolean` (optional) | `{ id: string \| number, element: HSAccordion } \| HTMLElement \| null` | Returns the accordion instance or element associated with the target. If `isInstance` is `true`, returns collection item object `{ id, element }` where `element` is the `HSAccordion` instance. If `isInstance` is `false` or omitted, returns the DOM element (`HTMLElement`). Returns `null` if accordion instance is not found. |
234
+ | `HSAccordion.show(target)` | `target`: `HSAccordion \| HTMLElement \| string` (CSS selector) | `void` | Opens the accordion item identified by target. Accepts an accordion instance, DOM element, or CSS selector string. Static alternative to instance `show()` method. Only opens if item is not already open. |
235
+ | `HSAccordion.hide(target)` | `target`: `HSAccordion \| HTMLElement \| string` (CSS selector) | `void` | Closes the accordion item identified by target. Accepts an accordion instance, DOM element, or CSS selector string. Static alternative to instance `hide()` method. Only closes if item is open and `keep-one-open` allows it. |
236
+
237
+ ### Usage Examples
238
+
239
+ **Example 1: Using instance methods (public API)**
240
+ ```javascript
241
+ // Create a new accordion instance
242
+ const accordion = new HSAccordion(document.querySelector('#hs-accordion'));
243
+ const showBtn = document.querySelector('#hs-show-btn');
244
+ const hideBtn = document.querySelector('#hs-hide-btn');
245
+
246
+ // Open accordion programmatically
247
+ showBtn.addEventListener('click', () => {
248
+ accordion.show();
249
+ });
250
+
251
+ // Close accordion programmatically
252
+ hideBtn.addEventListener('click', () => {
253
+ accordion.hide();
254
+ });
255
+ ```
256
+
257
+ **Example 2: Using static methods**
258
+ ```javascript
259
+ const showBtn = document.querySelector('#hs-show-btn');
260
+ const hideBtn = document.querySelector('#hs-hide-btn');
261
+
262
+ // Open accordion using static method (no instance needed)
263
+ showBtn.addEventListener('click', () => {
264
+ HSAccordion.show('#hs-accordion');
265
+ });
266
+
267
+ // Close accordion using static method
268
+ hideBtn.addEventListener('click', () => {
269
+ HSAccordion.hide('#hs-accordion');
270
+ });
271
+ ```
272
+
273
+ **Example 3: Getting instance and using methods (recommended pattern)**
274
+ ```javascript
275
+ // Get the accordion instance
276
+ const instance = HSAccordion.getInstance('#hs-accordion', true);
277
+
278
+ if (instance) {
279
+ const { element } = instance; // element is the HSAccordion instance
280
+ const showBtn = document.querySelector('#hs-show-btn');
281
+
282
+ // Use instance methods
283
+ showBtn.addEventListener('click', () => {
284
+ element.show();
285
+ });
286
+
287
+ // Clean up when removing from DOM
288
+ function removeAccordion() {
289
+ element.destroy();
290
+ }
291
+ }
292
+ ```
293
+
294
+ **Example 4: Destroying accordion instance**
295
+ ```javascript
296
+ const instance = HSAccordion.getInstance('#hs-accordion', true);
297
+
298
+ if (instance) {
299
+ const { element } = instance;
300
+ const removeBtn = document.querySelector('#hs-remove-btn');
301
+
302
+ removeBtn.addEventListener('click', () => {
303
+ // Clean up before removing from DOM
304
+ element.destroy();
305
+ // Now safe to remove the element
306
+ document.querySelector('#hs-accordion').remove();
307
+ });
308
+ }
309
+ ```
310
+
311
+ ## Events
312
+
313
+ Accordion instances emit events that can be listened to for lifecycle hooks and custom behavior.
314
+
315
+ | Event Name | When Fired | Callback Parameter | Description |
316
+ | --- | --- | --- | --- |
317
+ | `on:beforeOpen` | Before accordion item opens | `HTMLElement` (current accordion element) | Fires immediately before the accordion item starts opening. Can be used to cancel or modify behavior. |
318
+ | `on:open` | After accordion item opens | `HTMLElement` (current accordion element) | Fires after the accordion item has fully opened. Use for post-open actions like loading content. |
319
+ | `on:beforeClose` | Before accordion item closes | `HTMLElement` (current accordion element) | Fires immediately before the accordion item starts closing. Can be used to cancel or modify behavior. |
320
+ | `on:close` | After accordion item closes | `HTMLElement` (current accordion element) | Fires after the accordion item has fully closed. Use for cleanup or state updates. |
321
+
322
+ ### Event Usage Example
323
+
324
+ ```javascript
325
+ // Get accordion instance
326
+ const instance = HSAccordion.getInstance('#hs-accordion', true);
327
+
328
+ if (instance) {
329
+ const { element } = instance;
330
+
331
+ // Listen to open event
332
+ element.on('open', (accordionElement) => {
333
+ console.log('Accordion opened:', accordionElement);
334
+ // Perform actions after accordion opens
335
+ // e.g., load content, update UI, track analytics
336
+ });
337
+
338
+ // Listen to close event
339
+ element.on('close', (accordionElement) => {
340
+ console.log('Accordion closed:', accordionElement);
341
+ // Perform cleanup or state updates
342
+ });
343
+
344
+ // Listen to beforeOpen event (can be used to cancel)
345
+ element.on('beforeOpen', (accordionElement) => {
346
+ console.log('About to open:', accordionElement);
347
+ // Can add conditional logic here
348
+ });
349
+
350
+ // Listen to beforeClose event (can be used to cancel)
351
+ element.on('beforeClose', (accordionElement) => {
352
+ console.log('About to close:', accordionElement);
353
+ // Can add conditional logic here
354
+ });
355
+ }
356
+ ```
357
+
358
+ ## Common Patterns
359
+
360
+ ### Pattern 1: Multiple Open Items
361
+
362
+ Allow multiple accordion items to be open simultaneously.
363
+
364
+ ```html
365
+ <div class="hs-accordion-group" data-hs-accordion-always-open>
366
+ <div class="hs-accordion" id="hs-item-first">
367
+ <button class="hs-accordion-toggle">Item 1</button>
368
+ <div class="hs-accordion-content hidden">Content 1</div>
369
+ </div>
370
+
371
+ <div class="hs-accordion" id="hs-item-second">
372
+ <button class="hs-accordion-toggle">Item 2</button>
373
+ <div class="hs-accordion-content hidden">Content 2</div>
374
+ </div>
375
+ </div>
376
+ ```
377
+
378
+ ### Pattern 2: Always Keep One Open
379
+
380
+ Ensure at least one item is always open.
381
+
382
+ ```html
383
+ <div class="hs-accordion-group --keep-one-open:true">
384
+ <div class="hs-accordion active" id="hs-item-first">
385
+ <button class="hs-accordion-toggle">Item 1</button>
386
+ <div class="hs-accordion-content">Content 1</div>
387
+ </div>
388
+
389
+ <div class="hs-accordion" id="hs-item-second">
390
+ <button class="hs-accordion-toggle">Item 2</button>
391
+ <div class="hs-accordion-content hidden">Content 2</div>
392
+ </div>
393
+ </div>
394
+ ```
395
+
396
+ ### Pattern 3: Programmatic Control
397
+
398
+ Control accordion from external buttons.
399
+
400
+ ```html
401
+ <div class="hs-accordion-group">
402
+ <div class="hs-accordion" id="hs-accordion-first">
403
+ <button class="hs-accordion-toggle">Content</button>
404
+ <div class="hs-accordion-content hidden">Content here</div>
405
+ </div>
406
+ </div>
407
+
408
+ <button id="hs-open-all">Open All</button>
409
+ <button id="hs-close-all">Close All</button>
410
+
411
+ <script>
412
+ const instance = HSAccordion.getInstance('#hs-accordion-first', true);
413
+
414
+ if (instance) {
415
+ const { element } = instance;
416
+
417
+ document.querySelector('#hs-open-all').addEventListener('click', () => {
418
+ element.show();
419
+ });
420
+
421
+ document.querySelector('#hs-close-all').addEventListener('click', () => {
422
+ element.hide();
423
+ });
424
+ }
425
+ </script>
426
+ ```
427
+
428
+ ## License
429
+
430
+ Copyright (c) 2024 Htmlstream.
431
+
432
+ Licensed under the [MIT License](https://opensource.org/licenses/MIT).
package/index.js CHANGED
@@ -1,24 +1,24 @@
1
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var o=t();for(var i in o)("object"==typeof exports?exports:e)[i]=o[i]}}(self,(()=>(()=>{"use strict";var e={292:function(e,t){
1
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var o=t();for(var i in o)("object"==typeof exports?exports:e)[i]=o[i]}}(self,()=>(()=>{"use strict";var e={3765(e,t,o){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=i(o(6621));window.addEventListener("load",()=>{n.default.autoInit(),document.querySelectorAll(".hs-accordion-treeview-root").length&&n.default.treeView()}),"undefined"!=typeof window&&(window.HSAccordion=n.default)},6621(e,t,o){
2
2
  /*
3
- * @version: 4.1.3
3
+ * HSAccordion
4
+ * @version: 5.0.0
4
5
  * @author: Preline Labs Ltd.
5
6
  * @license: Licensed under MIT and Preline UI Fair Use License (https://preline.co/docs/license.html)
6
7
  * Copyright 2024 Preline Labs Ltd.
7
8
  */
8
- Object.defineProperty(t,"__esModule",{value:!0}),t.stringToBoolean=t.menuSearchHistory=t.isScrollable=t.isParentOrElementHidden=t.isJson=t.isIpadOS=t.isIOS=t.isFormElement=t.isFocused=t.isEnoughSpace=t.isDirectChild=t.htmlToElement=t.getZIndex=t.getHighestZIndex=t.getClassPropertyAlt=t.getClassProperty=t.dispatch=t.debounce=t.classToClassList=t.afterTransition=void 0;t.stringToBoolean=e=>"true"===e;t.getClassProperty=(e,t,o="")=>(window.getComputedStyle(e).getPropertyValue(t)||o).replace(" ","");t.getClassPropertyAlt=(e,t,o="")=>{let i="";return e.classList.forEach((e=>{e.includes(t)&&(i=e)})),i.match(/:(.*)]/)?i.match(/:(.*)]/)[1]:o};const o=e=>window.getComputedStyle(e).getPropertyValue("z-index");t.getZIndex=o;t.getHighestZIndex=e=>{let t=Number.NEGATIVE_INFINITY;return e.forEach((e=>{let i=o(e);"auto"!==i&&(i=parseInt(i,10),i>t&&(t=i))})),t};t.isDirectChild=(e,t)=>{const o=e.children;for(let e=0;e<o.length;e++)if(o[e]===t)return!0;return!1};t.isEnoughSpace=(e,t,o="auto",i=10,n=null)=>{const s=t.getBoundingClientRect(),l=n?n.getBoundingClientRect():null,r=window.innerHeight,c=l?s.top-l.top:s.top,a=(n?l.bottom:r)-s.bottom,h=e.clientHeight+i;return"bottom"===o?a>=h:"top"===o?c>=h:c>=h||a>=h};t.isFocused=e=>document.activeElement===e;t.isFormElement=e=>e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement;t.isIOS=()=>!!/iPad|iPhone|iPod/.test(navigator.platform)||navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform);t.isIpadOS=()=>navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform);t.isJson=e=>{if("string"!=typeof e)return!1;const t=e.trim()[0],o=e.trim().slice(-1);if("{"===t&&"}"===o||"["===t&&"]"===o)try{return JSON.parse(e),!0}catch(e){return!1}return!1};const i=e=>{if(!e)return!1;return"none"===window.getComputedStyle(e).display||i(e.parentElement)};t.isParentOrElementHidden=i;t.isScrollable=e=>{const t=window.getComputedStyle(e),o=t.overflowY,i=t.overflowX,n=("scroll"===o||"auto"===o)&&e.scrollHeight>e.clientHeight,s=("scroll"===i||"auto"===i)&&e.scrollWidth>e.clientWidth;return n||s};t.debounce=(e,t=200)=>{let o;return(...i)=>{clearTimeout(o),o=setTimeout((()=>{e.apply(this,i)}),t)}};t.dispatch=(e,t,o=null)=>{const i=new CustomEvent(e,{detail:{payload:o},bubbles:!0,cancelable:!0,composed:!1});t.dispatchEvent(i)};t.afterTransition=(e,t)=>{const o=()=>{t(),e.removeEventListener("transitionend",o,!0)},i=window.getComputedStyle(e),n=i.getPropertyValue("transition-duration");"none"!==i.getPropertyValue("transition-property")&&parseFloat(n)>0?e.addEventListener("transitionend",o,!0):t()};t.htmlToElement=e=>{const t=document.createElement("template");return e=e.trim(),t.innerHTML=e,t.content.firstChild};t.classToClassList=(e,t,o=" ",i="add")=>{e.split(o).forEach((e=>{e.trim()&&("add"===i?t.classList.add(e):t.classList.remove(e))}))};const n={historyIndex:-1,addHistory(e){this.historyIndex=e},existsInHistory(e){return e>this.historyIndex},clearHistory(){this.historyIndex=-1}};t.menuSearchHistory=n},2961:(e,t)=>{
9
+ var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=o(292),s=i(o(2961));class l extends s.default{constructor(e,t,o){super(e,t,o),this.toggle=this.el.querySelector(".hs-accordion-toggle")||null,this.content=this.el.querySelector(".hs-accordion-content")||null,this.group=this.el.closest(".hs-accordion-group")||null,this.isAlwaysOpened=!1,this.keepOneOpen=!1,this.isToggleStopPropagated=!1,window.$hsAccordionCollection||(window.$hsAccordionCollection=[]),this.update(),this.isToggleStopPropagated=(0,n.stringToBoolean)((0,n.getClassProperty)(this.toggle,"--stop-propagation","false")||"false"),this.keepOneOpen=!!this.group&&(0,n.stringToBoolean)((0,n.getClassProperty)(this.group,"--keep-one-open","false")||"false"),this.toggle&&this.content&&this.init()}init(){this.createCollection(window.$hsAccordionCollection,this),this.onToggleClickListener=e=>this.toggleClick(e),this.toggle.addEventListener("click",this.onToggleClickListener)}toggleClick(e){if(this.el.classList.contains("active")&&this.keepOneOpen)return!1;this.isToggleStopPropagated&&e.stopPropagation(),this.el.classList.contains("active")?this.hide():this.show()}show(){var e;if(this.group&&!this.isAlwaysOpened&&this.group.querySelector(":scope > .hs-accordion.active")&&this.group.querySelector(":scope > .hs-accordion.active")!==this.el){window.$hsAccordionCollection.find(e=>e.element.el===this.group.querySelector(":scope > .hs-accordion.active")).element.hide()}if(this.el.classList.contains("active"))return!1;this.el.classList.add("active"),(null===(e=null==this?void 0:this.toggle)||void 0===e?void 0:e.ariaExpanded)&&(this.toggle.ariaExpanded="true"),this.fireEvent("beforeOpen",this.el),(0,n.dispatch)("beforeOpen.hs.accordion",this.el,this.el),this.content.style.display="block",this.content.style.height="0",setTimeout(()=>{this.content.style.height=`${this.content.scrollHeight}px`,(0,n.afterTransition)(this.content,()=>{this.content.style.display="block",this.content.style.height="",this.fireEvent("open",this.el),(0,n.dispatch)("open.hs.accordion",this.el,this.el)})})}hide(){var e;if(!this.el.classList.contains("active"))return!1;this.el.classList.remove("active"),(null===(e=null==this?void 0:this.toggle)||void 0===e?void 0:e.ariaExpanded)&&(this.toggle.ariaExpanded="false"),this.fireEvent("beforeClose",this.el),(0,n.dispatch)("beforeClose.hs.accordion",this.el,this.el),this.content.style.height=`${this.content.scrollHeight}px`,setTimeout(()=>{this.content.style.height="0"}),(0,n.afterTransition)(this.content,()=>{this.content.style.display="none",this.content.style.height="",this.fireEvent("close",this.el),(0,n.dispatch)("close.hs.accordion",this.el,this.el)})}update(){return this.group=this.el.closest(".hs-accordion-group")||null,!!this.group&&(this.isAlwaysOpened=this.group.hasAttribute("data-hs-accordion-always-open")||!1,!!window.$hsAccordionCollection&&void window.$hsAccordionCollection.map(e=>(e.id===this.el.id&&(e.element.group=this.group,e.element.isAlwaysOpened=this.isAlwaysOpened),e)))}destroy(){var e;(null===(e=null==l?void 0:l.selectable)||void 0===e?void 0:e.length)&&l.selectable.forEach(e=>{e.listeners.forEach(({el:e,listener:t})=>{e.removeEventListener("click",t)})}),this.onToggleClickListener&&this.toggle.removeEventListener("click",this.onToggleClickListener),this.toggle=null,this.content=null,this.group=null,this.onToggleClickListener=null,window.$hsAccordionCollection=window.$hsAccordionCollection.filter(({element:e})=>e.el!==this.el)}static findInCollection(e){return window.$hsAccordionCollection.find(t=>e instanceof l?t.element.el===e.el:"string"==typeof e?t.element.el===document.querySelector(e):t.element.el===e)||null}static autoInit(){window.$hsAccordionCollection||(window.$hsAccordionCollection=[]),window.$hsAccordionCollection&&(window.$hsAccordionCollection=window.$hsAccordionCollection.filter(({element:e})=>document.contains(e.el))),document.querySelectorAll(".hs-accordion:not(.--prevent-on-load-init)").forEach(e=>{window.$hsAccordionCollection.find(t=>{var o;return(null===(o=null==t?void 0:t.element)||void 0===o?void 0:o.el)===e})||new l(e)})}static getInstance(e,t){const o=window.$hsAccordionCollection.find(t=>t.element.el===("string"==typeof e?document.querySelector(e):e));return o?t?o:o.element.el:null}static show(e){const t=l.findInCollection(e);t&&"block"!==t.element.content.style.display&&t.element.show()}static hide(e){const t=l.findInCollection(e),o=t?window.getComputedStyle(t.element.content):null;t&&"none"!==o.display&&t.element.hide()}static treeView(){if(!document.querySelectorAll(".hs-accordion-treeview-root").length)return!1;this.selectable=[],document.querySelectorAll(".hs-accordion-treeview-root").forEach(e=>{const t=null==e?void 0:e.getAttribute("data-hs-accordion-options"),o=t?JSON.parse(t):{};this.selectable.push({el:e,options:Object.assign({},o),listeners:[]})}),this.selectable.length&&this.selectable.forEach(e=>{const{el:t}=e;t.querySelectorAll(".hs-accordion-selectable").forEach(t=>{const o=o=>this.onSelectableClick(o,e,t);t.addEventListener("click",o),e.listeners.push({el:t,listener:o})})})}static toggleSelected(e,t){t.classList.contains("selected")?t.classList.remove("selected"):(e.el.querySelectorAll(".hs-accordion-selectable").forEach(e=>e.classList.remove("selected")),t.classList.add("selected"))}static on(e,t,o){const i=l.findInCollection(t);i&&(i.element.events[e]=o)}}l.onSelectableClick=(e,t,o)=>{e.stopPropagation(),l.toggleSelected(t,o)},t.default=l},2961(e,t){
9
10
  /*
10
11
  * HSBasePlugin
11
- * @version: 4.1.3
12
+ * @version: 5.0.0
12
13
  * @author: Preline Labs Ltd.
13
14
  * @license: Licensed under MIT and Preline UI Fair Use License (https://preline.co/docs/license.html)
14
15
  * Copyright 2024 Preline Labs Ltd.
15
16
  */
16
- Object.defineProperty(t,"__esModule",{value:!0});t.default=class{constructor(e,t,o){this.el=e,this.options=t,this.events=o,this.el=e,this.options=t,this.events={}}createCollection(e,t){var o,i;let n=e;if(!Array.isArray(n)&&"undefined"!=typeof window){const e=null===(o=this.constructor)||void 0===o?void 0:o.name,t="string"==typeof e&&e.startsWith("HS")?`$hs${e.slice(2)}Collection`:null;t&&(Array.isArray(window[t])||(window[t]=[]),n=window[t])}Array.isArray(n)&&n.push({id:(null===(i=null==t?void 0:t.el)||void 0===i?void 0:i.id)||n.length+1,element:t})}fireEvent(e,t=null){if(this.events.hasOwnProperty(e))return this.events[e](t)}on(e,t){this.events[e]=t}}},6621:function(e,t,o){
17
+ Object.defineProperty(t,"__esModule",{value:!0});t.default=class{constructor(e,t,o){this.el=e,this.options=t,this.events=o,this.el=e,this.options=t,this.events={}}createCollection(e,t){var o,i;let n=e;if(!Array.isArray(n)&&"undefined"!=typeof window){const e=null===(o=this.constructor)||void 0===o?void 0:o.name,t="string"==typeof e&&e.startsWith("HS")?`$hs${e.slice(2)}Collection`:null;t&&(Array.isArray(window[t])||(window[t]=[]),n=window[t])}Array.isArray(n)&&n.push({id:(null===(i=null==t?void 0:t.el)||void 0===i?void 0:i.id)||n.length+1,element:t})}fireEvent(e,t=null){if(this.events.hasOwnProperty(e))return this.events[e](t)}on(e,t){this.events[e]=t}}},292(e,t){
17
18
  /*
18
- * HSAccordion
19
- * @version: 4.1.3
19
+ * @version: 5.0.0
20
20
  * @author: Preline Labs Ltd.
21
21
  * @license: Licensed under MIT and Preline UI Fair Use License (https://preline.co/docs/license.html)
22
22
  * Copyright 2024 Preline Labs Ltd.
23
23
  */
24
- var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=o(292),s=i(o(2961));class l extends s.default{constructor(e,t,o){super(e,t,o),this.toggle=this.el.querySelector(".hs-accordion-toggle")||null,this.content=this.el.querySelector(".hs-accordion-content")||null,this.group=this.el.closest(".hs-accordion-group")||null,this.update(),this.isToggleStopPropagated=(0,n.stringToBoolean)((0,n.getClassProperty)(this.toggle,"--stop-propagation","false")||"false"),this.keepOneOpen=!!this.group&&(0,n.stringToBoolean)((0,n.getClassProperty)(this.group,"--keep-one-open","false")||"false"),this.toggle&&this.content&&this.init()}init(){this.createCollection(window.$hsAccordionCollection,this),this.onToggleClickListener=e=>this.toggleClick(e),this.toggle.addEventListener("click",this.onToggleClickListener)}toggleClick(e){if(this.el.classList.contains("active")&&this.keepOneOpen)return!1;this.isToggleStopPropagated&&e.stopPropagation(),this.el.classList.contains("active")?this.hide():this.show()}show(){var e;if(this.group&&!this.isAlwaysOpened&&this.group.querySelector(":scope > .hs-accordion.active")&&this.group.querySelector(":scope > .hs-accordion.active")!==this.el){window.$hsAccordionCollection.find((e=>e.element.el===this.group.querySelector(":scope > .hs-accordion.active"))).element.hide()}if(this.el.classList.contains("active"))return!1;this.el.classList.add("active"),(null===(e=null==this?void 0:this.toggle)||void 0===e?void 0:e.ariaExpanded)&&(this.toggle.ariaExpanded="true"),this.fireEvent("beforeOpen",this.el),(0,n.dispatch)("beforeOpen.hs.accordion",this.el,this.el),this.content.style.display="block",this.content.style.height="0",setTimeout((()=>{this.content.style.height=`${this.content.scrollHeight}px`,(0,n.afterTransition)(this.content,(()=>{this.content.style.display="block",this.content.style.height="",this.fireEvent("open",this.el),(0,n.dispatch)("open.hs.accordion",this.el,this.el)}))}))}hide(){var e;if(!this.el.classList.contains("active"))return!1;this.el.classList.remove("active"),(null===(e=null==this?void 0:this.toggle)||void 0===e?void 0:e.ariaExpanded)&&(this.toggle.ariaExpanded="false"),this.fireEvent("beforeClose",this.el),(0,n.dispatch)("beforeClose.hs.accordion",this.el,this.el),this.content.style.height=`${this.content.scrollHeight}px`,setTimeout((()=>{this.content.style.height="0"})),(0,n.afterTransition)(this.content,(()=>{this.content.style.display="none",this.content.style.height="",this.fireEvent("close",this.el),(0,n.dispatch)("close.hs.accordion",this.el,this.el)}))}update(){if(this.group=this.el.closest(".hs-accordion-group")||null,!this.group)return!1;this.isAlwaysOpened=this.group.hasAttribute("data-hs-accordion-always-open")||!1,window.$hsAccordionCollection.map((e=>(e.id===this.el.id&&(e.element.group=this.group,e.element.isAlwaysOpened=this.isAlwaysOpened),e)))}destroy(){var e;(null===(e=null==l?void 0:l.selectable)||void 0===e?void 0:e.length)&&l.selectable.forEach((e=>{e.listeners.forEach((({el:e,listener:t})=>{e.removeEventListener("click",t)}))})),this.onToggleClickListener&&this.toggle.removeEventListener("click",this.onToggleClickListener),this.toggle=null,this.content=null,this.group=null,this.onToggleClickListener=null,window.$hsAccordionCollection=window.$hsAccordionCollection.filter((({element:e})=>e.el!==this.el))}static findInCollection(e){return window.$hsAccordionCollection.find((t=>e instanceof l?t.element.el===e.el:"string"==typeof e?t.element.el===document.querySelector(e):t.element.el===e))||null}static autoInit(){window.$hsAccordionCollection||(window.$hsAccordionCollection=[]),window.$hsAccordionCollection&&(window.$hsAccordionCollection=window.$hsAccordionCollection.filter((({element:e})=>document.contains(e.el)))),document.querySelectorAll(".hs-accordion:not(.--prevent-on-load-init)").forEach((e=>{window.$hsAccordionCollection.find((t=>{var o;return(null===(o=null==t?void 0:t.element)||void 0===o?void 0:o.el)===e}))||new l(e)}))}static getInstance(e,t){const o=window.$hsAccordionCollection.find((t=>t.element.el===("string"==typeof e?document.querySelector(e):e)));return o?t?o:o.element.el:null}static show(e){const t=l.findInCollection(e);t&&"block"!==t.element.content.style.display&&t.element.show()}static hide(e){const t=l.findInCollection(e),o=t?window.getComputedStyle(t.element.content):null;t&&"none"!==o.display&&t.element.hide()}static treeView(){if(!document.querySelectorAll(".hs-accordion-treeview-root").length)return!1;this.selectable=[],document.querySelectorAll(".hs-accordion-treeview-root").forEach((e=>{const t=null==e?void 0:e.getAttribute("data-hs-accordion-options"),o=t?JSON.parse(t):{};this.selectable.push({el:e,options:Object.assign({},o),listeners:[]})})),this.selectable.length&&this.selectable.forEach((e=>{const{el:t}=e;t.querySelectorAll(".hs-accordion-selectable").forEach((t=>{const o=o=>this.onSelectableClick(o,e,t);t.addEventListener("click",o),e.listeners.push({el:t,listener:o})}))}))}static toggleSelected(e,t){t.classList.contains("selected")?t.classList.remove("selected"):(e.el.querySelectorAll(".hs-accordion-selectable").forEach((e=>e.classList.remove("selected"))),t.classList.add("selected"))}static on(e,t,o){const i=l.findInCollection(t);i&&(i.element.events[e]=o)}}l.onSelectableClick=(e,t,o)=>{e.stopPropagation(),l.toggleSelected(t,o)},t.default=l}},t={};var o=function o(i){var n=t[i];if(void 0!==n)return n.exports;var s=t[i]={exports:{}};return e[i].call(s.exports,s,s.exports,o),s.exports}(6621);return o})()));
24
+ Object.defineProperty(t,"__esModule",{value:!0}),t.stringToBoolean=t.menuSearchHistory=t.isScrollable=t.isParentOrElementHidden=t.isJson=t.isIpadOS=t.isIOS=t.isFormElement=t.isFocused=t.isEnoughSpace=t.isDirectChild=t.htmlToElement=t.getZIndex=t.getHighestZIndex=t.getClassPropertyAlt=t.getClassProperty=t.dispatch=t.debounce=t.classToClassList=t.afterTransition=void 0;t.stringToBoolean=e=>"true"===e;t.getClassProperty=(e,t,o="")=>(window.getComputedStyle(e).getPropertyValue(t)||o).replace(" ","");t.getClassPropertyAlt=(e,t,o="")=>{let i="";return e.classList.forEach(e=>{e.includes(t)&&(i=e)}),i.match(/:(.*)]/)?i.match(/:(.*)]/)[1]:o};const o=e=>window.getComputedStyle(e).getPropertyValue("z-index");t.getZIndex=o;t.getHighestZIndex=e=>{let t=Number.NEGATIVE_INFINITY;return e.forEach(e=>{let i=o(e);"auto"!==i&&(i=parseInt(i,10),i>t&&(t=i))}),t};t.isDirectChild=(e,t)=>{const o=e.children;for(let e=0;e<o.length;e++)if(o[e]===t)return!0;return!1};t.isEnoughSpace=(e,t,o="auto",i=10,n=null)=>{const s=t.getBoundingClientRect(),l=n?n.getBoundingClientRect():null,r=window.innerHeight,c=l?s.top-l.top:s.top,a=(n?l.bottom:r)-s.bottom,d=e.clientHeight+i;return"bottom"===o?a>=d:"top"===o?c>=d:c>=d||a>=d};t.isFocused=e=>document.activeElement===e;t.isFormElement=e=>e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement;t.isIOS=()=>!!/iPad|iPhone|iPod/.test(navigator.platform)||navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform);t.isIpadOS=()=>navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform);t.isJson=e=>{if("string"!=typeof e)return!1;const t=e.trim()[0],o=e.trim().slice(-1);if("{"===t&&"}"===o||"["===t&&"]"===o)try{return JSON.parse(e),!0}catch(e){return!1}return!1};const i=e=>{if(!e)return!1;return"none"===window.getComputedStyle(e).display||i(e.parentElement)};t.isParentOrElementHidden=i;t.isScrollable=e=>{const t=window.getComputedStyle(e),o=t.overflowY,i=t.overflowX,n=("scroll"===o||"auto"===o)&&e.scrollHeight>e.clientHeight,s=("scroll"===i||"auto"===i)&&e.scrollWidth>e.clientWidth;return n||s};t.debounce=(e,t=200)=>{let o;return(...i)=>{clearTimeout(o),o=setTimeout(()=>{e.apply(this,i)},t)}};t.dispatch=(e,t,o=null)=>{const i=new CustomEvent(e,{detail:{payload:o},bubbles:!0,cancelable:!0,composed:!1});t.dispatchEvent(i)};t.afterTransition=(e,t)=>{const o=()=>{t(),e.removeEventListener("transitionend",o,!0)},i=window.getComputedStyle(e),n=i.getPropertyValue("transition-duration");"none"!==i.getPropertyValue("transition-property")&&parseFloat(n)>0?e.addEventListener("transitionend",o,!0):t()};t.htmlToElement=e=>{const t=document.createElement("template");return e=e.trim(),t.innerHTML=e,t.content.firstChild};t.classToClassList=(e,t,o=" ",i="add")=>{e.split(o).forEach(e=>{e.trim()&&("add"===i?t.classList.add(e):t.classList.remove(e))})};const n={historyIndex:-1,addHistory(e){this.historyIndex=e},existsInHistory(e){return e>this.historyIndex},clearHistory(){this.historyIndex=-1}};t.menuSearchHistory=n}},t={};var o=function o(i){var n=t[i];if(void 0!==n)return n.exports;var s=t[i]={exports:{}};return e[i].call(s.exports,s,s.exports,o),s.exports}(3765);return o})());
package/index.mjs CHANGED
@@ -1,24 +1,24 @@
1
- var e={615:(e,t,o)=>{o.d(t,{A:()=>i});
1
+ var e={2407(e,t,o){o.d(t,{A:()=>l});var i=o(1926),n=o(7615);
2
2
  /*
3
- * HSBasePlugin
4
- * @version: 4.1.3
3
+ * HSAccordion
4
+ * @version: 5.0.0
5
5
  * @author: Preline Labs Ltd.
6
6
  * @license: Licensed under MIT and Preline UI Fair Use License (https://preline.co/docs/license.html)
7
7
  * Copyright 2024 Preline Labs Ltd.
8
8
  */
9
- class i{constructor(e,t,o){this.el=e,this.options=t,this.events=o,this.el=e,this.options=t,this.events={}}createCollection(e,t){var o,i;let n=e;if(!Array.isArray(n)&&"undefined"!=typeof window){const e=null===(o=this.constructor)||void 0===o?void 0:o.name,t="string"==typeof e&&e.startsWith("HS")?`$hs${e.slice(2)}Collection`:null;t&&(Array.isArray(window[t])||(window[t]=[]),n=window[t])}Array.isArray(n)&&n.push({id:(null===(i=null==t?void 0:t.el)||void 0===i?void 0:i.id)||n.length+1,element:t})}fireEvent(e,t=null){if(this.events.hasOwnProperty(e))return this.events[e](t)}on(e,t){this.events[e]=t}}},926:(e,t,o)=>{o.d(t,{JD:()=>s,PK:()=>i,gj:()=>n,yd:()=>l});
9
+ class s extends n.A{constructor(e,t,o){super(e,t,o),this.toggle=this.el.querySelector(".hs-accordion-toggle")||null,this.content=this.el.querySelector(".hs-accordion-content")||null,this.group=this.el.closest(".hs-accordion-group")||null,this.isAlwaysOpened=!1,this.keepOneOpen=!1,this.isToggleStopPropagated=!1,window.$hsAccordionCollection||(window.$hsAccordionCollection=[]),this.update(),this.isToggleStopPropagated=(0,i.PK)((0,i.gj)(this.toggle,"--stop-propagation","false")||"false"),this.keepOneOpen=!!this.group&&(0,i.PK)((0,i.gj)(this.group,"--keep-one-open","false")||"false"),this.toggle&&this.content&&this.init()}init(){this.createCollection(window.$hsAccordionCollection,this),this.onToggleClickListener=e=>this.toggleClick(e),this.toggle.addEventListener("click",this.onToggleClickListener)}toggleClick(e){if(this.el.classList.contains("active")&&this.keepOneOpen)return!1;this.isToggleStopPropagated&&e.stopPropagation(),this.el.classList.contains("active")?this.hide():this.show()}show(){var e;if(this.group&&!this.isAlwaysOpened&&this.group.querySelector(":scope > .hs-accordion.active")&&this.group.querySelector(":scope > .hs-accordion.active")!==this.el){window.$hsAccordionCollection.find(e=>e.element.el===this.group.querySelector(":scope > .hs-accordion.active")).element.hide()}if(this.el.classList.contains("active"))return!1;this.el.classList.add("active"),(null===(e=null==this?void 0:this.toggle)||void 0===e?void 0:e.ariaExpanded)&&(this.toggle.ariaExpanded="true"),this.fireEvent("beforeOpen",this.el),(0,i.JD)("beforeOpen.hs.accordion",this.el,this.el),this.content.style.display="block",this.content.style.height="0",setTimeout(()=>{this.content.style.height=`${this.content.scrollHeight}px`,(0,i.yd)(this.content,()=>{this.content.style.display="block",this.content.style.height="",this.fireEvent("open",this.el),(0,i.JD)("open.hs.accordion",this.el,this.el)})})}hide(){var e;if(!this.el.classList.contains("active"))return!1;this.el.classList.remove("active"),(null===(e=null==this?void 0:this.toggle)||void 0===e?void 0:e.ariaExpanded)&&(this.toggle.ariaExpanded="false"),this.fireEvent("beforeClose",this.el),(0,i.JD)("beforeClose.hs.accordion",this.el,this.el),this.content.style.height=`${this.content.scrollHeight}px`,setTimeout(()=>{this.content.style.height="0"}),(0,i.yd)(this.content,()=>{this.content.style.display="none",this.content.style.height="",this.fireEvent("close",this.el),(0,i.JD)("close.hs.accordion",this.el,this.el)})}update(){return this.group=this.el.closest(".hs-accordion-group")||null,!!this.group&&(this.isAlwaysOpened=this.group.hasAttribute("data-hs-accordion-always-open")||!1,!!window.$hsAccordionCollection&&void window.$hsAccordionCollection.map(e=>(e.id===this.el.id&&(e.element.group=this.group,e.element.isAlwaysOpened=this.isAlwaysOpened),e)))}destroy(){var e;(null===(e=null==s?void 0:s.selectable)||void 0===e?void 0:e.length)&&s.selectable.forEach(e=>{e.listeners.forEach(({el:e,listener:t})=>{e.removeEventListener("click",t)})}),this.onToggleClickListener&&this.toggle.removeEventListener("click",this.onToggleClickListener),this.toggle=null,this.content=null,this.group=null,this.onToggleClickListener=null,window.$hsAccordionCollection=window.$hsAccordionCollection.filter(({element:e})=>e.el!==this.el)}static findInCollection(e){return window.$hsAccordionCollection.find(t=>e instanceof s?t.element.el===e.el:"string"==typeof e?t.element.el===document.querySelector(e):t.element.el===e)||null}static autoInit(){window.$hsAccordionCollection||(window.$hsAccordionCollection=[]),window.$hsAccordionCollection&&(window.$hsAccordionCollection=window.$hsAccordionCollection.filter(({element:e})=>document.contains(e.el))),document.querySelectorAll(".hs-accordion:not(.--prevent-on-load-init)").forEach(e=>{window.$hsAccordionCollection.find(t=>{var o;return(null===(o=null==t?void 0:t.element)||void 0===o?void 0:o.el)===e})||new s(e)})}static getInstance(e,t){const o=window.$hsAccordionCollection.find(t=>t.element.el===("string"==typeof e?document.querySelector(e):e));return o?t?o:o.element.el:null}static show(e){const t=s.findInCollection(e);t&&"block"!==t.element.content.style.display&&t.element.show()}static hide(e){const t=s.findInCollection(e),o=t?window.getComputedStyle(t.element.content):null;t&&"none"!==o.display&&t.element.hide()}static treeView(){if(!document.querySelectorAll(".hs-accordion-treeview-root").length)return!1;this.selectable=[],document.querySelectorAll(".hs-accordion-treeview-root").forEach(e=>{const t=null==e?void 0:e.getAttribute("data-hs-accordion-options"),o=t?JSON.parse(t):{};this.selectable.push({el:e,options:Object.assign({},o),listeners:[]})}),this.selectable.length&&this.selectable.forEach(e=>{const{el:t}=e;t.querySelectorAll(".hs-accordion-selectable").forEach(t=>{const o=o=>this.onSelectableClick(o,e,t);t.addEventListener("click",o),e.listeners.push({el:t,listener:o})})})}static toggleSelected(e,t){t.classList.contains("selected")?t.classList.remove("selected"):(e.el.querySelectorAll(".hs-accordion-selectable").forEach(e=>e.classList.remove("selected")),t.classList.add("selected"))}static on(e,t,o){const i=s.findInCollection(t);i&&(i.element.events[e]=o)}}s.onSelectableClick=(e,t,o)=>{e.stopPropagation(),s.toggleSelected(t,o)};const l=s},7615(e,t,o){o.d(t,{A:()=>i});
10
10
  /*
11
- * @version: 4.1.3
11
+ * HSBasePlugin
12
+ * @version: 5.0.0
12
13
  * @author: Preline Labs Ltd.
13
14
  * @license: Licensed under MIT and Preline UI Fair Use License (https://preline.co/docs/license.html)
14
15
  * Copyright 2024 Preline Labs Ltd.
15
16
  */
16
- const i=e=>"true"===e,n=(e,t,o="")=>(window.getComputedStyle(e).getPropertyValue(t)||o).replace(" ",""),s=(e,t,o=null)=>{const i=new CustomEvent(e,{detail:{payload:o},bubbles:!0,cancelable:!0,composed:!1});t.dispatchEvent(i)},l=(e,t)=>{const o=()=>{t(),e.removeEventListener("transitionend",o,!0)},i=window.getComputedStyle(e),n=i.getPropertyValue("transition-duration");"none"!==i.getPropertyValue("transition-property")&&parseFloat(n)>0?e.addEventListener("transitionend",o,!0):t()}}},t={};function o(i){var n=t[i];if(void 0!==n)return n.exports;var s=t[i]={exports:{}};return e[i](s,s.exports,o),s.exports}o.d=(e,t)=>{for(var i in t)o.o(t,i)&&!o.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var i={};o.d(i,{A:()=>c});var n=o(926),s=o(615);
17
+ class i{constructor(e,t,o){this.el=e,this.options=t,this.events=o,this.el=e,this.options=t,this.events={}}createCollection(e,t){var o,i;let n=e;if(!Array.isArray(n)&&"undefined"!=typeof window){const e=null===(o=this.constructor)||void 0===o?void 0:o.name,t="string"==typeof e&&e.startsWith("HS")?`$hs${e.slice(2)}Collection`:null;t&&(Array.isArray(window[t])||(window[t]=[]),n=window[t])}Array.isArray(n)&&n.push({id:(null===(i=null==t?void 0:t.el)||void 0===i?void 0:i.id)||n.length+1,element:t})}fireEvent(e,t=null){if(this.events.hasOwnProperty(e))return this.events[e](t)}on(e,t){this.events[e]=t}}},1926(e,t,o){o.d(t,{JD:()=>s,PK:()=>i,gj:()=>n,yd:()=>l});
17
18
  /*
18
- * HSAccordion
19
- * @version: 4.1.3
19
+ * @version: 5.0.0
20
20
  * @author: Preline Labs Ltd.
21
21
  * @license: Licensed under MIT and Preline UI Fair Use License (https://preline.co/docs/license.html)
22
22
  * Copyright 2024 Preline Labs Ltd.
23
23
  */
24
- class l extends s.A{constructor(e,t,o){super(e,t,o),this.toggle=this.el.querySelector(".hs-accordion-toggle")||null,this.content=this.el.querySelector(".hs-accordion-content")||null,this.group=this.el.closest(".hs-accordion-group")||null,this.update(),this.isToggleStopPropagated=(0,n.PK)((0,n.gj)(this.toggle,"--stop-propagation","false")||"false"),this.keepOneOpen=!!this.group&&(0,n.PK)((0,n.gj)(this.group,"--keep-one-open","false")||"false"),this.toggle&&this.content&&this.init()}init(){this.createCollection(window.$hsAccordionCollection,this),this.onToggleClickListener=e=>this.toggleClick(e),this.toggle.addEventListener("click",this.onToggleClickListener)}toggleClick(e){if(this.el.classList.contains("active")&&this.keepOneOpen)return!1;this.isToggleStopPropagated&&e.stopPropagation(),this.el.classList.contains("active")?this.hide():this.show()}show(){var e;if(this.group&&!this.isAlwaysOpened&&this.group.querySelector(":scope > .hs-accordion.active")&&this.group.querySelector(":scope > .hs-accordion.active")!==this.el){window.$hsAccordionCollection.find((e=>e.element.el===this.group.querySelector(":scope > .hs-accordion.active"))).element.hide()}if(this.el.classList.contains("active"))return!1;this.el.classList.add("active"),(null===(e=null==this?void 0:this.toggle)||void 0===e?void 0:e.ariaExpanded)&&(this.toggle.ariaExpanded="true"),this.fireEvent("beforeOpen",this.el),(0,n.JD)("beforeOpen.hs.accordion",this.el,this.el),this.content.style.display="block",this.content.style.height="0",setTimeout((()=>{this.content.style.height=`${this.content.scrollHeight}px`,(0,n.yd)(this.content,(()=>{this.content.style.display="block",this.content.style.height="",this.fireEvent("open",this.el),(0,n.JD)("open.hs.accordion",this.el,this.el)}))}))}hide(){var e;if(!this.el.classList.contains("active"))return!1;this.el.classList.remove("active"),(null===(e=null==this?void 0:this.toggle)||void 0===e?void 0:e.ariaExpanded)&&(this.toggle.ariaExpanded="false"),this.fireEvent("beforeClose",this.el),(0,n.JD)("beforeClose.hs.accordion",this.el,this.el),this.content.style.height=`${this.content.scrollHeight}px`,setTimeout((()=>{this.content.style.height="0"})),(0,n.yd)(this.content,(()=>{this.content.style.display="none",this.content.style.height="",this.fireEvent("close",this.el),(0,n.JD)("close.hs.accordion",this.el,this.el)}))}update(){if(this.group=this.el.closest(".hs-accordion-group")||null,!this.group)return!1;this.isAlwaysOpened=this.group.hasAttribute("data-hs-accordion-always-open")||!1,window.$hsAccordionCollection.map((e=>(e.id===this.el.id&&(e.element.group=this.group,e.element.isAlwaysOpened=this.isAlwaysOpened),e)))}destroy(){var e;(null===(e=null==l?void 0:l.selectable)||void 0===e?void 0:e.length)&&l.selectable.forEach((e=>{e.listeners.forEach((({el:e,listener:t})=>{e.removeEventListener("click",t)}))})),this.onToggleClickListener&&this.toggle.removeEventListener("click",this.onToggleClickListener),this.toggle=null,this.content=null,this.group=null,this.onToggleClickListener=null,window.$hsAccordionCollection=window.$hsAccordionCollection.filter((({element:e})=>e.el!==this.el))}static findInCollection(e){return window.$hsAccordionCollection.find((t=>e instanceof l?t.element.el===e.el:"string"==typeof e?t.element.el===document.querySelector(e):t.element.el===e))||null}static autoInit(){window.$hsAccordionCollection||(window.$hsAccordionCollection=[]),window.$hsAccordionCollection&&(window.$hsAccordionCollection=window.$hsAccordionCollection.filter((({element:e})=>document.contains(e.el)))),document.querySelectorAll(".hs-accordion:not(.--prevent-on-load-init)").forEach((e=>{window.$hsAccordionCollection.find((t=>{var o;return(null===(o=null==t?void 0:t.element)||void 0===o?void 0:o.el)===e}))||new l(e)}))}static getInstance(e,t){const o=window.$hsAccordionCollection.find((t=>t.element.el===("string"==typeof e?document.querySelector(e):e)));return o?t?o:o.element.el:null}static show(e){const t=l.findInCollection(e);t&&"block"!==t.element.content.style.display&&t.element.show()}static hide(e){const t=l.findInCollection(e),o=t?window.getComputedStyle(t.element.content):null;t&&"none"!==o.display&&t.element.hide()}static treeView(){if(!document.querySelectorAll(".hs-accordion-treeview-root").length)return!1;this.selectable=[],document.querySelectorAll(".hs-accordion-treeview-root").forEach((e=>{const t=null==e?void 0:e.getAttribute("data-hs-accordion-options"),o=t?JSON.parse(t):{};this.selectable.push({el:e,options:Object.assign({},o),listeners:[]})})),this.selectable.length&&this.selectable.forEach((e=>{const{el:t}=e;t.querySelectorAll(".hs-accordion-selectable").forEach((t=>{const o=o=>this.onSelectableClick(o,e,t);t.addEventListener("click",o),e.listeners.push({el:t,listener:o})}))}))}static toggleSelected(e,t){t.classList.contains("selected")?t.classList.remove("selected"):(e.el.querySelectorAll(".hs-accordion-selectable").forEach((e=>e.classList.remove("selected"))),t.classList.add("selected"))}static on(e,t,o){const i=l.findInCollection(t);i&&(i.element.events[e]=o)}}l.onSelectableClick=(e,t,o)=>{e.stopPropagation(),l.toggleSelected(t,o)};const c=l;var r=i.A;export{r as default};
24
+ const i=e=>"true"===e,n=(e,t,o="")=>(window.getComputedStyle(e).getPropertyValue(t)||o).replace(" ",""),s=(e,t,o=null)=>{const i=new CustomEvent(e,{detail:{payload:o},bubbles:!0,cancelable:!0,composed:!1});t.dispatchEvent(i)},l=(e,t)=>{const o=()=>{t(),e.removeEventListener("transitionend",o,!0)},i=window.getComputedStyle(e),n=i.getPropertyValue("transition-duration");"none"!==i.getPropertyValue("transition-property")&&parseFloat(n)>0?e.addEventListener("transitionend",o,!0):t()}}},t={};function o(i){var n=t[i];if(void 0!==n)return n.exports;var s=t[i]={exports:{}};return e[i](s,s.exports,o),s.exports}o.d=(e,t)=>{for(var i in t)o.o(t,i)&&!o.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var i=o(2407);window.addEventListener("load",()=>{i.A.autoInit(),document.querySelectorAll(".hs-accordion-treeview-root").length&&i.A.treeView()}),"undefined"!=typeof window&&(window.HSAccordion=i.A);