wj-elements 0.1.164 → 0.1.166

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.
Files changed (38) hide show
  1. package/dist/packages/utils/event.d.ts +4 -4
  2. package/dist/packages/wje-accordion/accordion.test.d.ts +0 -0
  3. package/dist/packages/wje-color-picker/color-picker.test.d.ts +1 -0
  4. package/dist/packages/wje-dialog/dialog.element.d.ts +4 -4
  5. package/dist/packages/wje-element/element.d.ts +1 -1
  6. package/dist/packages/wje-icon-picker/icon-picker.element.d.ts +0 -4
  7. package/dist/packages/wje-input/input.element.d.ts +0 -5
  8. package/dist/packages/wje-option/option.element.d.ts +1 -0
  9. package/dist/packages/wje-options/options.element.d.ts +8 -6
  10. package/dist/packages/wje-radio-group/radio-group.element.d.ts +6 -0
  11. package/dist/packages/wje-select/select.element.d.ts +3 -1
  12. package/dist/packages/wje-tab/tab.element.d.ts +2 -0
  13. package/dist/packages/wje-tab-group/tab-group.element.d.ts +44 -9
  14. package/dist/wje-checkbox.js +3 -2
  15. package/dist/wje-checkbox.js.map +1 -1
  16. package/dist/wje-dialog.js +4 -4
  17. package/dist/wje-dialog.js.map +1 -1
  18. package/dist/wje-element.js +17 -16
  19. package/dist/wje-element.js.map +1 -1
  20. package/dist/wje-icon-picker.js +10 -16
  21. package/dist/wje-icon-picker.js.map +1 -1
  22. package/dist/wje-input.js +7 -11
  23. package/dist/wje-input.js.map +1 -1
  24. package/dist/wje-option.js +17 -13
  25. package/dist/wje-option.js.map +1 -1
  26. package/dist/wje-options.js +44 -7
  27. package/dist/wje-options.js.map +1 -1
  28. package/dist/wje-radio-group.js +22 -12
  29. package/dist/wje-radio-group.js.map +1 -1
  30. package/dist/wje-radio.js +6 -7
  31. package/dist/wje-radio.js.map +1 -1
  32. package/dist/wje-select.js +65 -28
  33. package/dist/wje-select.js.map +1 -1
  34. package/dist/wje-tab-group.js +52 -12
  35. package/dist/wje-tab-group.js.map +1 -1
  36. package/dist/wje-tab.js +2 -1
  37. package/dist/wje-tab.js.map +1 -1
  38. package/package.json +1 -1
@@ -41,26 +41,47 @@ class Select extends WJElement {
41
41
  * @param {Event} e The event.
42
42
  */
43
43
  __publicField(this, "optionChange", (e) => {
44
+ e.stopPropagation();
45
+ e.stopImmediatePropagation();
44
46
  let allOptions = this.getAllOptions();
45
47
  if (!this.hasAttribute("multiple")) {
46
48
  allOptions.forEach((option) => {
47
- option.selected = false;
48
- option.removeAttribute("selected");
49
+ if (option.value === e.target.value) {
50
+ this.processClickedOption(option);
51
+ } else {
52
+ option.selected = false;
53
+ option.removeAttribute("selected");
54
+ }
49
55
  });
50
- this.popup.removeAttribute("active");
56
+ this.popup.hide();
57
+ } else {
58
+ this.processClickedOption(e.target, true);
51
59
  }
52
- e.target.selected = !e.target.hasAttribute("selected");
53
60
  this.selections();
54
61
  });
62
+ __publicField(this, "processClickedOption", (option, multiple = false) => {
63
+ const isSelected = option.hasAttribute("selected");
64
+ option.selected = !isSelected;
65
+ if (isSelected) {
66
+ option.removeAttribute("selected");
67
+ this.filterOutOption(option);
68
+ } else {
69
+ option.setAttribute("selected", "");
70
+ this.selectedOptions = multiple ? [...this.selectedOptions, option] : [option];
71
+ }
72
+ });
73
+ __publicField(this, "filterOutOption", (option) => {
74
+ this.selectedOptions = this.selectedOptions.filter((sOption) => {
75
+ return sOption.value !== option.value;
76
+ });
77
+ });
55
78
  /**
56
79
  * Handles the chip remove event.
57
80
  * @param {Event} e The event.
58
81
  */
59
82
  __publicField(this, "removeChip", (e) => {
60
- let option = e.target.option;
61
- option.selected = false;
62
- option.removeAttribute("selected");
63
83
  e.target.parentNode.removeChild(e.target);
84
+ this.processClickedOption(e.target.option, true);
64
85
  this.selections();
65
86
  });
66
87
  this._selected = [];
@@ -77,14 +98,17 @@ class Select extends WJElement {
77
98
  this.chips = null;
78
99
  this.clear = null;
79
100
  this.list = null;
101
+ this.selectedOptions = [];
80
102
  }
81
103
  /**
82
104
  * Setter for the value attribute.
83
105
  * @param {string} value The value to set.
84
106
  */
85
107
  set value(value) {
86
- if (Array.isArray(value)) {
87
- this.internals.setFormValue(JSON.stringify(value));
108
+ if (this.hasAttribute("multiple")) {
109
+ const formData = new FormData();
110
+ value.forEach((v) => formData.append(this.name, v));
111
+ this.internals.setFormValue(formData);
88
112
  } else {
89
113
  this.internals.setFormValue(value);
90
114
  }
@@ -228,7 +252,7 @@ class Select extends WJElement {
228
252
  * @returns {Array<string>}
229
253
  */
230
254
  static get observedAttributes() {
231
- return ["active", "value"];
255
+ return ["active", "value", "disabled", "multiple", "label", "placeholder", "max-height", "max-options", "variant", "placement"];
232
256
  }
233
257
  /**
234
258
  * Sets up the attributes for the component.
@@ -280,6 +304,7 @@ class Select extends WJElement {
280
304
  let clear = document.createElement("wje-button");
281
305
  clear.setAttribute("fill", "link");
282
306
  clear.setAttribute("part", "clear");
307
+ clear.setAttribute("stop-propagation", "");
283
308
  let clearIcon = document.createElement("wje-icon");
284
309
  clearIcon.setAttribute("name", "x");
285
310
  clear.appendChild(clearIcon);
@@ -313,6 +338,7 @@ class Select extends WJElement {
313
338
  if (this._wasOppened) return;
314
339
  this._wasOppened = true;
315
340
  const optionsElement = this.querySelector("wje-options");
341
+ optionsElement.setAttribute("lazy", "");
316
342
  optionsElement.setAttribute("attached", "");
317
343
  });
318
344
  } else {
@@ -342,16 +368,22 @@ class Select extends WJElement {
342
368
  * Sets up the event listeners after the component is drawn.
343
369
  */
344
370
  afterDraw() {
371
+ var _a;
345
372
  this.input.addEventListener("focus", (e) => {
346
- this.labelElement.classList.add("fade");
373
+ var _a2;
374
+ (_a2 = this.labelElement) == null ? void 0 : _a2.classList.add("fade");
347
375
  this.native.classList.add("focused");
348
376
  });
349
377
  this.input.addEventListener("blur", (e) => {
378
+ var _a2;
350
379
  this.native.classList.remove("focused");
351
- if (!e.target.value) this.labelElement.classList.remove("fade");
380
+ if (!e.target.value) (_a2 = this.labelElement) == null ? void 0 : _a2.classList.remove("fade");
352
381
  });
353
382
  this.addEventListener("wje-option:change", this.optionChange);
354
- this.clear.addEventListener("wje-button:click", (e) => {
383
+ (_a = this.clear) == null ? void 0 : _a.addEventListener("wje-button:click", (e) => {
384
+ e.preventDefault();
385
+ e.stopPropagation();
386
+ this.selectedOptions = [];
355
387
  this.getAllOptions().forEach((option) => {
356
388
  option.selected = false;
357
389
  option.removeAttribute("selected");
@@ -359,8 +391,17 @@ class Select extends WJElement {
359
391
  this.selections();
360
392
  e.stopPropagation();
361
393
  });
394
+ this.selectedOptions = this.getSelectedOptions();
362
395
  this.selections(true);
363
396
  this.list.addEventListener("wje-options:load", (e) => {
397
+ this.selectedOptions.forEach((option) => {
398
+ this.getAllOptions().forEach((el) => {
399
+ if (el.value === option.value) {
400
+ el.selected = true;
401
+ el.setAttribute("selected", "");
402
+ }
403
+ });
404
+ });
364
405
  this.list.scrollTo(0, 0);
365
406
  });
366
407
  if (this.hasAttribute("find") && this.findEl instanceof HTMLElement) {
@@ -390,22 +431,19 @@ class Select extends WJElement {
390
431
  * @returns {NodeList} The selected options as HTML.
391
432
  */
392
433
  getSelectedOptions() {
393
- return this.querySelectorAll("wje-option[selected]");
434
+ return Array.from(this.querySelectorAll("wje-option[selected]"));
394
435
  }
395
436
  /**
396
437
  * Returns the selected options.
397
438
  * @returns {Array} The selected options.
398
439
  */
399
440
  getSelected() {
400
- let selectedOptions = this.getSelectedOptions();
401
- selectedOptions = Array.isArray(selectedOptions) ? selectedOptions : Array.from(selectedOptions);
402
- selectedOptions = selectedOptions.map((option) => {
441
+ return this.selectedOptions.map((option) => {
403
442
  return {
404
443
  value: option.value,
405
444
  text: option.textContent.trim()
406
445
  };
407
446
  });
408
- return selectedOptions;
409
447
  }
410
448
  /**
411
449
  * Handles the selection change.
@@ -420,10 +458,9 @@ class Select extends WJElement {
420
458
  this.chips.innerHTML = this.placeholder;
421
459
  this.input.value = "";
422
460
  } else {
461
+ if (option !== null) this.chips.appendChild(this.getChip(option));
423
462
  if (this.counterEl instanceof HTMLElement || length > +this.maxOptions) {
424
463
  this.counter();
425
- } else {
426
- if (option !== null) this.chips.appendChild(this.getChip(option));
427
464
  }
428
465
  }
429
466
  } else {
@@ -460,8 +497,6 @@ class Select extends WJElement {
460
497
  * selections(true);
461
498
  */
462
499
  selections(silence = false) {
463
- let options = this.getSelectedOptions();
464
- this.selectedOptions = Array.isArray(options) ? options : Array.from(options);
465
500
  if (this.selectedOptions.length >= +this.maxOptions) {
466
501
  this.counterEl = null;
467
502
  }
@@ -469,9 +504,7 @@ class Select extends WJElement {
469
504
  this.chips.innerHTML = "";
470
505
  }
471
506
  if (this.selectedOptions.length > 0) {
472
- this.selectedOptions.forEach((option, index) => {
473
- this.selectionChanged(option, ++index);
474
- });
507
+ this.selectionChanged(this.selectedOptions.at(0), this.selectedOptions.length);
475
508
  } else {
476
509
  this.selectionChanged();
477
510
  }
@@ -576,7 +609,7 @@ class Select extends WJElement {
576
609
  if (!value) return;
577
610
  let option = this.querySelector(`wje-option[value="${value}"]`);
578
611
  if (option) {
579
- option.selected = true;
612
+ this.processClickedOption(option, this.hasAttribute("multiple"));
580
613
  }
581
614
  if (this.drawingStatus > this.drawingStatuses.START) this.selections(silent);
582
615
  }
@@ -600,8 +633,9 @@ class Select extends WJElement {
600
633
  * @param {HTMLFormElement} form The form the custom element is associated with.
601
634
  */
602
635
  formAssociatedCallback(form) {
603
- form == null ? void 0 : form.addEventListener("submit", () => {
604
- });
636
+ if (form) {
637
+ this.internals.setFormValue(this.value);
638
+ }
605
639
  }
606
640
  /**
607
641
  * The formResetCallback method is a built-in lifecycle callback that gets called when a form gets reset.
@@ -644,7 +678,10 @@ class Select extends WJElement {
644
678
  * @function
645
679
  */
646
680
  formDisabledCallback(disabled) {
681
+ var _a;
647
682
  console.warn("formDisabledCallback not implemented yet");
683
+ (_a = this.native) == null ? void 0 : _a.classList.toggle("disabled", disabled);
684
+ this.toggleAttribute("disabled", disabled);
648
685
  }
649
686
  }
650
687
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"wje-select.js","sources":["../packages/wje-select/select.element.js","../packages/wje-select/select.js"],"sourcesContent":["import { default as WJElement, event } from '../wje-element/element.js';\nimport Button from '../wje-button/button.js';\nimport Popup from '../wje-popup/popup.js';\nimport Icon from '../wje-icon/icon.js';\nimport Label from '../wje-label/label.js';\nimport Chip from '../wje-chip/chip.js';\nimport Input from '../wje-input/input.js';\nimport Option from '../wje-option/option.js';\nimport Options from '../wje-options/options.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * `Select` is a custom web component that represents a select input.\n * @summary This element represents a select input.\n * @documentation https://elements.webjet.sk/components/select\n * @status stable\n * @augments {WJElement}\n * @slot - The default slot for the select.\n * @slot anchor - The slot for the anchor.\n * @slot arrow - The slot for the arrow.\n * @csspart native - The native select wrapper.\n * @csspart input - The input field.\n * @csspart clear - The clear button.\n * @property {Array} _selected - An array to store selected items.\n * @property {HTMLElement|null} counterEl - A reference to the counter element, initially null.\n * @property {ElementInternals} internals - The internal element API for managing state and attributes.\n * @property {boolean} _wasOppened - Tracks whether the select element was previously opened, initially false.\n * @cssproperty [--wje-select-border-width=1px] - Specifies the width of the border around the select component. Accepts any valid CSS length unit (e.g., `px`, `rem`, `em`).\n * @cssproperty [--wje-select-border-style=solid] - Defines the style of the border for the select component. Accepts standard CSS border styles, such as `solid`, `dashed`, or `dotted`.\n * @cssproperty [--wje-select-border-color=var(--wje-border-color)] - Sets the color of the border for the select component. Accepts any valid CSS color value, including color variables, named colors, and hex values.\n * @cssproperty [--wje-select-options-border-width=1px] - Specifies the width of the border for the select options dropdown. Accepts any valid CSS length unit.\n * @cssproperty [--wje-select-options-border-style=var(--wje-border-style)] - Defines the border style for the select options dropdown. Inherits from a defined CSS variable for consistency.\n * @cssproperty [--wje-select-options-border-color=var(--wje-border-color)] - Sets the border color for the select options dropdown. Accepts any valid CSS color value.\n * @cssproperty [--wje-select-background=var(--wje-background)] - Specifies the background color of the select component. Accepts any valid CSS color value.\n * @cssproperty [--wje-select-line-height=20px] - Defines the line height for the text within the select component. Accepts any valid CSS length value, ensuring consistent vertical alignment.\n * @cssproperty [--wje-select-color=var(--wje-color)] - Sets the text color for the select component. Accepts any valid CSS color value.\n * @cssproperty [--wje-select-border-radius=var(--wje-border-radius-medium)] - Specifies the border radius for the select component.Determines the roundness of the corners and accepts any valid CSS length unit or variable.\n * @tag wje-select\n */\n\nexport default class Select extends WJElement {\n /**\n * Constructor for the Select class.\n * @class\n * @description Initializes the Select component.\n * This constructor sets up the initial state of the component, including selected items, counter element, and internal element API.\n * It also tracks whether the select element was previously opened.\n * @class\n * @augments {WJElement}\n * @memberof Select\n */\n constructor() {\n super();\n\n /**\n * @type {Array}\n * @description An array to store selected items.\n */\n this._selected = [];\n\n /**\n * @type {HTMLElement|null}\n * @description A reference to the counter element, initially null.\n * @private\n */\n this.counterEl = null;\n\n /**\n * @type {ElementInternals}\n * @description The internal element API for managing state and attributes.\n * @private\n * @readonly\n * @constant\n * @default {ElementInternals} this.attachInternals()\n * @description Attaches the internals to the element.\n */\n this.internals = this.attachInternals();\n\n /**\n * @type {boolean}\n * @description Tracks whether the select element was previously opened, initially false.\n * @private\n * @default {boolean} false\n */\n this._wasOppened = false;\n\n /**\n * @type {HTMLElement|null}\n * @description A reference to the native select element, initially null.\n */\n this.native = null;\n\n /**\n * @type {HTMLElement|null}\n * @description A reference to the popup element, initially null.\n */\n this.popup = null;\n\n /**\n * @type {HTMLElement|null}\n * @description A reference to the label element, initially null.\n */\n this.labelElement = null;\n\n /**\n * @type {HTMLElement|null}\n * @description A reference to the slot start element, initially null.\n */\n this.slotStart = null;\n\n /**\n * @type {HTMLElement|null}\n * @description A reference to the slot end element, initially null.\n */\n this.slotEnd = null;\n\n /**\n * @type {HTMLElement|null}\n * @description A reference to the input element, initially null.\n */\n this.input = null;\n\n /**\n * @type {HTMLElement|null}\n * @description A reference to the options wrapper element, initially null.\n */\n this.optionsWrapper = null;\n\n /**\n * @type {HTMLElement|null}\n * @description A reference to the chips element, initially null.\n */\n this.chips = null;\n\n /**\n * @type {HTMLElement|null}\n * @description A reference to the clear button element, initially null.\n */\n this.clear = null;\n\n /**\n * @type {HTMLElement|null}\n * @description A reference to the list element, initially null.\n */\n this.list = null;\n }\n\n dependencies = {\n 'wje-button': Button,\n 'wje-popup': Popup,\n 'wje-icon': Icon,\n 'wje-label': Label,\n 'wje-chip': Chip,\n 'wje-input': Input,\n 'wje-option': Option,\n 'wje-options': Options,\n };\n\n /**\n * Setter for the value attribute.\n * @param {string} value The value to set.\n */\n set value(value) {\n if (Array.isArray(value)) {\n this.internals.setFormValue(JSON.stringify(value));\n } else {\n this.internals.setFormValue(value);\n }\n }\n\n /**\n * Getter for the value attribute.\n * @returns {string} The value of the attribute.\n */\n get value() {\n return this.selected;\n }\n\n /**\n * Getter for the customErrorDisplay attribute.\n * @returns {boolean} Whether the attribute is present.\n */\n get customErrorDisplay() {\n return this.hasAttribute('custom-error-display');\n }\n\n /**\n * Getter for the validateOnChange attribute.\n * @returns {boolean} Whether the attribute is present.\n */\n get validateOnChange() {\n return this.hasAttribute('validate-on-change');\n }\n\n /**\n * Getter for the invalid attribute.\n * @returns {boolean} Whether the attribute is present.\n */\n get invalid() {\n return this.hasAttribute('invalid');\n }\n\n /**\n * Setter for the invalid attribute.\n * @param {boolean} isInvalid Whether the input is invalid.\n */\n set invalid(isInvalid) {\n if (isInvalid) this.setAttribute('invalid', '');\n else this.removeAttribute('invalid');\n }\n\n /**\n * Getter for the form attribute.\n * @returns {HTMLFormElement} The form the input is associated with.\n */\n get form() {\n return this.internals.form;\n }\n\n /**\n * Getter for the name attribute.\n * @returns {string} The name of the input.\n */\n get name() {\n return this.getAttribute('name');\n }\n\n /**\n * Getter for the type attribute.\n * @returns {string} The type of the input.\n */\n get type() {\n return this.localName;\n }\n\n /**\n * Getter for the validity attribute.\n * @returns {ValidityState} The validity state of the input.\n */\n get validity() {\n return this.internals.validity;\n }\n\n /**\n * Getter for the validationMessage attribute.\n * @returns {string} The validation message of the input.\n */\n get validationMessage() {\n return this.internals.validationMessage;\n }\n\n /**\n * Getter for the willValidate attribute.\n * @returns {boolean} Whether the input will be validated.\n */\n get willValidate() {\n return this.internals.willValidate;\n }\n\n /**\n * @summary Getter for the defaultValue attribute.\n * This method retrieves the 'value' attribute of the custom input element.\n * The 'value' attribute represents the default value of the input element.\n * If the 'value' attribute is not set, it returns an empty string.\n * @returns {string} The default value of the input element.\n */\n get defaultValue() {\n return this.getAttribute('value') ?? '';\n }\n\n /**\n * @summary Setter for the defaultValue attribute.\n * This method sets the 'value' attribute of the custom input element to the provided value.\n * The 'value' attribute represents the default value of the input element.\n * @param {string} value The value to set as the default value.\n */\n set defaultValue(value) {\n this.setAttribute('value', value);\n }\n\n /**\n * Sets the label value.\n * @param {Array} value The selected value to set.\n */\n set selected(value) {\n this._selected = value;\n }\n\n /**\n * Returns the selected value.\n * @returns {Array} The selected value.\n */\n get selected() {\n return this.getSelected();\n }\n\n /**\n * Sets the trigger value.\n * @param {string} value The trigger value to set.\n */\n set trigger(value) {\n this.setAttribute('trigger', value);\n }\n\n /**\n * Returns the trigger value.\n * @returns {string} The trigger value.\n */\n get trigger() {\n return this.getAttribute('trigger') || 'click';\n }\n\n className = 'Select';\n\n /**\n * Returns the CSS styles for the component.\n * @static\n * @returns {CSSStyleSheet}\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Returns the list of attributes to observe for changes.\n * @static\n * @returns {Array<string>}\n */\n static get observedAttributes() {\n return ['active', 'value'];\n }\n\n /**\n * Whether the input is associated with a form.\n * @type {boolean}\n */\n static formAssociated = true;\n\n /**\n * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Draws the component for the select.\n * @returns {DocumentFragment}\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n this.classList.add('wje-placement', this.placement ? 'wje-' + this.placement : 'wje-start');\n\n // zakladny obalovac\n let native = document.createElement('div');\n native.setAttribute('part', 'native');\n native.classList.add('native-select', this.variant || 'default');\n\n // wrapper pre label a inputWrapper\n let wrapper = document.createElement('div');\n wrapper.classList.add('wrapper');\n wrapper.setAttribute('slot', 'anchor');\n\n // label\n let label = document.createElement('wje-label');\n label.innerText = this.label || '';\n\n // obalovac pre input\n let inputWrapper = document.createElement('div');\n inputWrapper.setAttribute('part', 'input-wrapper');\n inputWrapper.classList.add('input-wrapper');\n\n let slotStart = document.createElement('div');\n slotStart.classList.add('slot-start');\n\n let input = document.createElement('input');\n input.setAttribute('type', 'text');\n input.setAttribute('part', 'input');\n input.setAttribute('autocomplete', 'off');\n input.setAttribute('readonly', '');\n input.setAttribute('placeholder', this.placeholder || '');\n\n let slotEnd = document.createElement('div');\n slotEnd.classList.add('slot-end');\n\n let arrow = document.createElement('wje-icon');\n arrow.setAttribute('name', 'chevron-down');\n arrow.setAttribute('slot', 'arrow');\n\n let chips = document.createElement('div');\n chips.classList.add('chips');\n chips.innerText = this.placeholder || '';\n\n // obalovac pre option a find\n let optionsWrapper = document.createElement('div');\n optionsWrapper.setAttribute('part', 'options-wrapper');\n optionsWrapper.classList.add('options-wrapper');\n optionsWrapper.style.setProperty('height', this.maxHeight || 'auto');\n\n let list = document.createElement('div');\n list.classList.add('list');\n\n let slot = document.createElement('slot');\n\n let clear = document.createElement('wje-button');\n clear.setAttribute('fill', 'link');\n clear.setAttribute('part', 'clear');\n\n let clearIcon = document.createElement('wje-icon');\n clearIcon.setAttribute('name', 'x');\n\n clear.appendChild(clearIcon);\n\n // vytvorime popup\n let popup = document.createElement('wje-popup');\n popup.setAttribute('placement', 'bottom-start');\n popup.setAttribute('manual', '');\n popup.setAttribute('size', '');\n\n if (this.hasAttribute('disabled')) popup.setAttribute('disabled', '');\n\n if (this.variant === 'standard') {\n if (this.hasAttribute('label')) native.appendChild(label);\n } else {\n wrapper.appendChild(label);\n }\n\n inputWrapper.appendChild(slotStart);\n inputWrapper.appendChild(input);\n if (this.hasAttribute('multiple')) inputWrapper.appendChild(chips);\n\n if (this.hasAttribute('clearable')) inputWrapper.appendChild(clear);\n\n inputWrapper.appendChild(slotEnd);\n inputWrapper.appendChild(arrow);\n\n list.appendChild(slot);\n\n if (this.hasAttribute('find')) {\n let find = document.createElement('wje-input');\n find.setAttribute('variant', 'standard');\n find.setAttribute('placeholder', 'Hľadať');\n find.classList.add('find');\n\n optionsWrapper.appendChild(find);\n\n this.findEl = find;\n }\n\n if (this.hasAttribute('lazy')) {\n event.addListener(popup, 'wje-popup:show', null, (e) => {\n if (this._wasOppened) return;\n this._wasOppened = true;\n\n const optionsElement = this.querySelector('wje-options');\n optionsElement.setAttribute('attached', '');\n });\n } else {\n const optionsElement = this.querySelector('wje-options');\n optionsElement?.setAttribute('attached', '');\n }\n\n optionsWrapper.appendChild(list);\n\n wrapper.appendChild(inputWrapper);\n popup.appendChild(optionsWrapper);\n popup.appendChild(wrapper);\n\n if (this.trigger === 'click') popup.setAttribute('manual', '');\n\n native.appendChild(popup);\n\n this.native = native;\n this.popup = popup;\n this.labelElement = label;\n this.slotStart = slotStart;\n this.slotEnd = slotEnd;\n this.input = input;\n this.optionsWrapper = optionsWrapper;\n this.chips = chips;\n this.clear = clear;\n this.list = list;\n\n fragment.appendChild(native);\n\n return fragment;\n }\n\n /**\n * Sets up the event listeners after the component is drawn.\n */\n afterDraw() {\n this.input.addEventListener('focus', (e) => {\n this.labelElement.classList.add('fade');\n this.native.classList.add('focused');\n });\n\n this.input.addEventListener('blur', (e) => {\n this.native.classList.remove('focused');\n if (!e.target.value) this.labelElement.classList.remove('fade');\n });\n\n this.addEventListener('wje-option:change', this.optionChange);\n\n this.clear.addEventListener('wje-button:click', (e) => {\n this.getAllOptions().forEach((option) => {\n option.selected = false;\n option.removeAttribute('selected');\n });\n this.selections();\n\n e.stopPropagation();\n });\n\n this.selections(true);\n\n this.list.addEventListener('wje-options:load', (e) => {\n this.list.scrollTo(0, 0);\n });\n\n // skontrolujeme ci ma select atribut find\n if (this.hasAttribute('find') && this.findEl instanceof HTMLElement) {\n event.addListener(this.findEl, 'keyup', '', (e) => {\n // contains wj-options element with options\n const optionsElement = this.querySelector('wje-options');\n if (optionsElement && optionsElement.hasAttribute('lazy')) {\n // pass search value to wj-options element and infinite scroll will handle the rest\n optionsElement.setAttribute('search', e.target.value);\n } else {\n let value = e.target.value.trim().toLowerCase();\n\n this.getAllOptions().forEach((option) => {\n if (option.textContent.trim().toLowerCase().includes(value)) option.style.display = 'block';\n else option.style.display = 'none';\n });\n }\n });\n }\n }\n\n /**\n * Handles the option change event.\n * @param {Event} e The event.\n */\n optionChange = (e) => {\n let allOptions = this.getAllOptions();\n\n if (!this.hasAttribute('multiple')) {\n allOptions.forEach((option) => {\n option.selected = false;\n option.removeAttribute('selected');\n });\n this.popup.removeAttribute('active');\n }\n\n e.target.selected = !e.target.hasAttribute('selected');\n\n this.selections();\n };\n\n /**\n * Returns all the options as HTML.\n * @returns {NodeList} The options as HTML.\n */\n getAllOptions() {\n return this.querySelectorAll('wje-option');\n }\n\n /**\n * Returns the selected options as HTML.\n * @returns {NodeList} The selected options as HTML.\n */\n getSelectedOptions() {\n return this.querySelectorAll('wje-option[selected]');\n }\n\n /**\n * Returns the selected options.\n * @returns {Array} The selected options.\n */\n getSelected() {\n let selectedOptions = this.getSelectedOptions();\n\n selectedOptions = Array.isArray(selectedOptions) ? selectedOptions : Array.from(selectedOptions);\n\n selectedOptions = selectedOptions.map((option) => {\n return {\n value: option.value,\n text: option.textContent.trim(),\n };\n });\n\n return selectedOptions;\n }\n\n /**\n * Handles the selection change.\n * @param {Element} option The option that changed.\n * @param {number} length The length of the selected options.\n */\n selectionChanged(option = null, length = 0) {\n if (this.hasAttribute('multiple')) {\n this.value = this.selectedOptions.map((el) => el.value).reverse();\n\n if (this.placeholder && length === 0) {\n this.chips.innerHTML = this.placeholder;\n this.input.value = '';\n } else {\n if (this.counterEl instanceof HTMLElement || length > +this.maxOptions) {\n this.counter();\n } else {\n if (option !== null) this.chips.appendChild(this.getChip(option));\n }\n }\n } else {\n let value = option?.textContent.trim() || '';\n this.value = this.selectedOptions?.map((el) => el.value)?.at(0);\n this.input.value = value;\n\n if (option && option instanceof HTMLElement) {\n this.slotStart.innerHTML = '';\n\n if (option?.querySelector('[slot=start]')) {\n this.slotStart.appendChild(option?.querySelector('[slot=start]').cloneNode(true));\n }\n\n this.slotEnd.innerHTML = '';\n\n if (option?.querySelector('[slot=end]')) {\n this.slotEnd.appendChild(option?.querySelector('[slot=end]').cloneNode(true));\n }\n }\n }\n }\n\n /**\n * Updates the selected options and their corresponding chips.\n * @param {boolean} [silence] Determines whether to suppress the \"wje-select:change\" event.\n * @returns {void}\n * @description\n * This method fetches the currently selected options and updates the `selectedOptions` array.\n * It clears and rebuilds the chips representing the selected items in the UI.\n * If the number of selected options reaches the maximum allowed (`maxOptions`), it stops updating the counter.\n * Optionally, it dispatches a custom event when the selection changes unless `silence` is set to `true`.\n * //@fires wje-select:change - Dispatched when the selection changes, unless `silence` is `true`.\n * @example\n * // Call the method and allow event dispatch\n * selections();\n * @example\n * // Call the method without dispatching the event\n * selections(true);\n */\n selections(silence = false) {\n let options = this.getSelectedOptions();\n\n this.selectedOptions = Array.isArray(options) ? options : Array.from(options);\n\n if (this.selectedOptions.length >= +this.maxOptions) {\n this.counterEl = null;\n }\n\n if (this.chips) {\n this.chips.innerHTML = '';\n }\n\n if (this.selectedOptions.length > 0) {\n this.selectedOptions.forEach((option, index) => {\n this.selectionChanged(option, ++index);\n });\n } else {\n this.selectionChanged();\n }\n\n if (silence) return;\n event.dispatchCustomEvent(this, 'wje-select:change');\n }\n\n /**\n * Manages the display of a counter element to indicate the number of items exceeding the maximum allowed options.\n * - If the number of selected items equals the maximum allowed, the counter element is removed.\n * - If the counter element doesn't exist and the number of items exceeds the maximum, it is created and updated.\n */\n counter() {\n // zmazanie counter (span)\n if (this.counterEl && this.value.length === +this.maxOptions) {\n this.counterEl.remove();\n this.counterEl = null;\n return;\n }\n\n // ak counter nie je, tak ho vytvorime\n if (!this.counterEl) {\n this.counterEl = document.createElement('span');\n this.counterEl.classList.add('counter');\n\n this.chips.appendChild(this.counterEl);\n }\n\n // nastavime hodnotu counter\n this.counterEl.innerText = `+${this.value.length - +this.maxOptions}`;\n }\n\n /**\n * Returns a chip element.\n * @param {Element} option The option to get the chip for.\n * @returns {Element} The chip element.\n */\n getChip(option) {\n let chip = document.createElement('wje-chip');\n chip.setAttribute('removable', '');\n chip.addEventListener('wje:chip-remove', this.removeChip);\n chip.option = option;\n\n let label = document.createElement('wje-label');\n label.innerText = option.textContent.trim();\n\n chip.appendChild(label);\n\n return chip;\n }\n\n /**\n * Handles the chip remove event.\n * @param {Event} e The event.\n */\n removeChip = (e) => {\n let option = e.target.option;\n option.selected = false;\n option.removeAttribute('selected');\n e.target.parentNode.removeChild(e.target);\n\n this.selections();\n };\n\n /**\n * Generates an HTML option element based on the provided item and mapping.\n * @param {object} item The item to generate the option for.\n * @param {object} [map] The mapping object that specifies the properties of the item to use for the option's value and text.\n * @param {string} [map.value] The property of the item to use for the option's value.\n * @param {string} [map.text] The property of the item to use for the option's text.\n * @returns {HTMLElement} The generated HTML option element.\n */\n htmlOption(item, map = { value: 'value', text: 'text' }) {\n let option = document.createElement('wje-option');\n\n if (item[map.value] === null) {\n console.warn(`The item ${JSON.stringify(item)} does not have the property ${map.value}`);\n }\n\n if (item[map.text] === null) {\n console.warn(`The item ${JSON.stringify(item)} does not have the property ${map.text}`);\n }\n\n option.setAttribute('value', item[map.value] ?? '');\n option.innerText = item[map.text] ?? '';\n return option;\n }\n\n /**\n * Adds an option to the select element.\n * @param {any} optionData The data for the option to be added.\n * @param {boolean} [silent] Whether to suppress any events triggered by the addition of the option.\n * @param {object} [map] The mapping object specifying the properties of the option data to be used for the value and text of the option.\n */\n addOption(optionData, silent = false, map = { value: 'value', text: 'text' }) {\n if (!optionData) return;\n\n const optionsElement = this.querySelector('wje-options');\n if (optionsElement) {\n optionsElement.addOption(optionData, silent, map);\n return;\n }\n\n let option = this.htmlOption(optionData, map);\n this.appendChild(option);\n }\n\n /**\n * Adds options to the select element.\n * @param {Array | object} optionsData The options data to be added. Can be an array of objects or a single object.\n * @param {boolean} [silent] Indicates whether to trigger events when adding options. Default is false.\n * @param {object} [map] The mapping object that specifies the properties of the options data object. Default is { value: \"value\", text: \"text\" }.\n */\n addOptions(optionsData, silent = false, map = { value: 'value', text: 'text' }) {\n if (!Array.isArray(optionsData)) {\n this.addOption(optionsData, silent, map);\n } else {\n const optionsElement = this.querySelector('wje-options');\n if (optionsElement) {\n optionsElement.addOptions(optionsData, silent, map);\n return;\n }\n\n optionsData.forEach((item) => {\n this.addOption(item, silent, map);\n });\n }\n }\n\n /**\n * Selects an option with the specified value.\n * @param {string} value The value of the option to be selected.\n * @param {boolean} [silent] Whether to suppress firing events.\n */\n selectOption(value, silent = false) {\n if (!value) return;\n\n let option = this.querySelector(`wje-option[value=\"${value}\"]`);\n\n if (option) {\n option.selected = true;\n }\n\n if (this.drawingStatus > this.drawingStatuses.START) this.selections(silent);\n }\n\n /**\n * Selects one or multiple options in the select element.\n * @param {Array|any} values The value(s) of the option(s) to be selected.\n * @param {boolean} [silent] Whether to trigger the change event or not.\n */\n selectOptions(values, silent = false) {\n if (!Array.isArray(values)) {\n this.selectOption(values, silent);\n } else {\n values.forEach((value) => {\n this.selectOption(value, silent);\n });\n }\n }\n\n /**\n * @summary Callback function that is called when the custom element is associated with a form.\n * This function adds an event listener to the form's submit event, which validates the input and propagates the validation.\n * @param {HTMLFormElement} form The form the custom element is associated with.\n */\n formAssociatedCallback(form) {\n form?.addEventListener('submit', () => {\n // this.validateInput();\n // this.propagateValidation();\n });\n }\n\n /**\n * The formResetCallback method is a built-in lifecycle callback that gets called when a form gets reset.\n * This method is responsible for resetting the value of the custom input element to its default value.\n * It also resets the form value and validity state in the form internals.\n * @function\n */\n formResetCallback() {\n // Set the value of the custom input element to its default value\n this.value = this.defaultValue;\n // Reset the form value in the form internals to the default value\n this.internals.setFormValue(this.defaultValue);\n // Reset the validity state in the form internals\n this.internals.setValidity({});\n }\n\n /**\n * The formStateRestoreCallback method is a built-in lifecycle callback that gets called when the state of a form-associated custom element is restored.\n * This method is responsible for restoring the value of the custom input element to its saved state.\n * It also restores the form value and validity state in the form internals to their saved states.\n * @param {object} state The saved state of the custom input element.\n * @function\n */\n formStateRestoreCallback(state) {\n // Set the value of the custom input element to its saved value\n this.value = state.value;\n // Restore the form value in the form internals to the saved value\n this.internals.setFormValue(state.value);\n // Restore the validity state in the form internals to the saved state\n this.internals.setValidity({});\n }\n\n /**\n * The formStateSaveCallback method is a built-in lifecycle callback that gets called when the state of a form-associated custom element is saved.\n * This method is responsible for saving the value of the custom input element.\n * @returns {object} The saved state of the custom input element.\n * @function\n */\n formStateSaveCallback() {\n return {\n value: this.value,\n };\n }\n\n /**\n * The formDisabledCallback method is a built-in lifecycle callback that gets called when the disabled state of a form-associated custom element changes.\n * This method is not implemented yet.\n * @param {boolean} disabled The new disabled state of the custom input element.\n * @function\n */\n formDisabledCallback(disabled) {\n console.warn('formDisabledCallback not implemented yet');\n }\n}\n","import Select from './select.element.js';\n\nexport default Select;\n\nSelect.define('wje-select', Select);\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAwCe,MAAM,eAAe,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAW1C,cAAc;AACV,UAAO;AA+FX,wCAAe;AAAA,MACX,cAAc;AAAA,MACd,aAAa;AAAA,MACb,YAAY;AAAA,MACZ,aAAa;AAAA,MACb,YAAY;AAAA,MACZ,aAAa;AAAA,MACb,cAAc;AAAA,MACd,eAAe;AAAA,IAClB;AA4JD,qCAAY;AAyOZ;AAAA;AAAA;AAAA;AAAA,wCAAe,CAAC,MAAM;AAClB,UAAI,aAAa,KAAK,cAAe;AAErC,UAAI,CAAC,KAAK,aAAa,UAAU,GAAG;AAChC,mBAAW,QAAQ,CAAC,WAAW;AAC3B,iBAAO,WAAW;AAClB,iBAAO,gBAAgB,UAAU;AAAA,QACjD,CAAa;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EAC/D;AACA;AAAA;AAAA;AAAA;AAAA;AAhjBI,cAxSiB,QAwSV,kBAAiB;AC5U5B,OAAO,OAAO,cAAc,MAAM;"}
1
+ {"version":3,"file":"wje-select.js","sources":["../packages/wje-select/select.element.js","../packages/wje-select/select.js"],"sourcesContent":["import { default as WJElement, event } from '../wje-element/element.js';\nimport Button from '../wje-button/button.js';\nimport Popup from '../wje-popup/popup.js';\nimport Icon from '../wje-icon/icon.js';\nimport Label from '../wje-label/label.js';\nimport Chip from '../wje-chip/chip.js';\nimport Input from '../wje-input/input.js';\nimport Option from '../wje-option/option.js';\nimport Options from '../wje-options/options.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * `Select` is a custom web component that represents a select input.\n * @summary This element represents a select input.\n * @documentation https://elements.webjet.sk/components/select\n * @status stable\n * @augments {WJElement}\n * @slot - The default slot for the select.\n * @slot anchor - The slot for the anchor.\n * @slot arrow - The slot for the arrow.\n * @csspart native - The native select wrapper.\n * @csspart input - The input field.\n * @csspart clear - The clear button.\n * @property {Array} _selected - An array to store selected items.\n * @property {HTMLElement|null} counterEl - A reference to the counter element, initially null.\n * @property {ElementInternals} internals - The internal element API for managing state and attributes.\n * @property {boolean} _wasOppened - Tracks whether the select element was previously opened, initially false.\n * @cssproperty [--wje-select-border-width=1px] - Specifies the width of the border around the select component. Accepts any valid CSS length unit (e.g., `px`, `rem`, `em`).\n * @cssproperty [--wje-select-border-style=solid] - Defines the style of the border for the select component. Accepts standard CSS border styles, such as `solid`, `dashed`, or `dotted`.\n * @cssproperty [--wje-select-border-color=var(--wje-border-color)] - Sets the color of the border for the select component. Accepts any valid CSS color value, including color variables, named colors, and hex values.\n * @cssproperty [--wje-select-options-border-width=1px] - Specifies the width of the border for the select options dropdown. Accepts any valid CSS length unit.\n * @cssproperty [--wje-select-options-border-style=var(--wje-border-style)] - Defines the border style for the select options dropdown. Inherits from a defined CSS variable for consistency.\n * @cssproperty [--wje-select-options-border-color=var(--wje-border-color)] - Sets the border color for the select options dropdown. Accepts any valid CSS color value.\n * @cssproperty [--wje-select-background=var(--wje-background)] - Specifies the background color of the select component. Accepts any valid CSS color value.\n * @cssproperty [--wje-select-line-height=20px] - Defines the line height for the text within the select component. Accepts any valid CSS length value, ensuring consistent vertical alignment.\n * @cssproperty [--wje-select-color=var(--wje-color)] - Sets the text color for the select component. Accepts any valid CSS color value.\n * @cssproperty [--wje-select-border-radius=var(--wje-border-radius-medium)] - Specifies the border radius for the select component.Determines the roundness of the corners and accepts any valid CSS length unit or variable.\n * @tag wje-select\n */\n\nexport default class Select extends WJElement {\n /**\n * Constructor for the Select class.\n * @class\n * @description Initializes the Select component.\n * This constructor sets up the initial state of the component, including selected items, counter element, and internal element API.\n * It also tracks whether the select element was previously opened.\n * @class\n * @augments {WJElement}\n * @memberof Select\n */\n constructor() {\n super();\n\n /**\n * @type {Array}\n * @description An array to store selected items.\n */\n this._selected = [];\n\n /**\n * @type {HTMLElement|null}\n * @description A reference to the counter element, initially null.\n * @private\n */\n this.counterEl = null;\n\n /**\n * @type {ElementInternals}\n * @description The internal element API for managing state and attributes.\n * @private\n * @readonly\n * @constant\n * @default {ElementInternals} this.attachInternals()\n * @description Attaches the internals to the element.\n */\n this.internals = this.attachInternals();\n\n /**\n * @type {boolean}\n * @description Tracks whether the select element was previously opened, initially false.\n * @private\n * @default {boolean} false\n */\n this._wasOppened = false;\n\n /**\n * @type {HTMLElement|null}\n * @description A reference to the native select element, initially null.\n */\n this.native = null;\n\n /**\n * @type {HTMLElement|null}\n * @description A reference to the popup element, initially null.\n */\n this.popup = null;\n\n /**\n * @type {HTMLElement|null}\n * @description A reference to the label element, initially null.\n */\n this.labelElement = null;\n\n /**\n * @type {HTMLElement|null}\n * @description A reference to the slot start element, initially null.\n */\n this.slotStart = null;\n\n /**\n * @type {HTMLElement|null}\n * @description A reference to the slot end element, initially null.\n */\n this.slotEnd = null;\n\n /**\n * @type {HTMLElement|null}\n * @description A reference to the input element, initially null.\n */\n this.input = null;\n\n /**\n * @type {HTMLElement|null}\n * @description A reference to the options wrapper element, initially null.\n */\n this.optionsWrapper = null;\n\n /**\n * @type {HTMLElement|null}\n * @description A reference to the chips element, initially null.\n */\n this.chips = null;\n\n /**\n * @type {HTMLElement|null}\n * @description A reference to the clear button element, initially null.\n */\n this.clear = null;\n\n /**\n * @type {HTMLElement|null}\n * @description A reference to the list element, initially null.\n */\n this.list = null;\n\n this.selectedOptions = []\n }\n\n dependencies = {\n 'wje-button': Button,\n 'wje-popup': Popup,\n 'wje-icon': Icon,\n 'wje-label': Label,\n 'wje-chip': Chip,\n 'wje-input': Input,\n 'wje-option': Option,\n 'wje-options': Options,\n };\n\n /**\n * Setter for the value attribute.\n * @param {string} value The value to set.\n */\n set value(value) {\n if (this.hasAttribute('multiple')) {\n const formData = new FormData();\n value.forEach(v => formData.append(this.name, v));\n this.internals.setFormValue(formData);\n } else {\n this.internals.setFormValue(value);\n }\n }\n\n /**\n * Getter for the value attribute.\n * @returns {string} The value of the attribute.\n */\n get value() {\n return this.selected;\n }\n\n /**\n * Getter for the customErrorDisplay attribute.\n * @returns {boolean} Whether the attribute is present.\n */\n get customErrorDisplay() {\n return this.hasAttribute('custom-error-display');\n }\n\n /**\n * Getter for the validateOnChange attribute.\n * @returns {boolean} Whether the attribute is present.\n */\n get validateOnChange() {\n return this.hasAttribute('validate-on-change');\n }\n\n /**\n * Getter for the invalid attribute.\n * @returns {boolean} Whether the attribute is present.\n */\n get invalid() {\n return this.hasAttribute('invalid');\n }\n\n /**\n * Setter for the invalid attribute.\n * @param {boolean} isInvalid Whether the input is invalid.\n */\n set invalid(isInvalid) {\n if (isInvalid) this.setAttribute('invalid', '');\n else this.removeAttribute('invalid');\n }\n\n /**\n * Getter for the form attribute.\n * @returns {HTMLFormElement} The form the input is associated with.\n */\n get form() {\n return this.internals.form;\n }\n\n /**\n * Getter for the name attribute.\n * @returns {string} The name of the input.\n */\n get name() {\n return this.getAttribute('name');\n }\n\n /**\n * Getter for the type attribute.\n * @returns {string} The type of the input.\n */\n get type() {\n return this.localName;\n }\n\n /**\n * Getter for the validity attribute.\n * @returns {ValidityState} The validity state of the input.\n */\n get validity() {\n return this.internals.validity;\n }\n\n /**\n * Getter for the validationMessage attribute.\n * @returns {string} The validation message of the input.\n */\n get validationMessage() {\n return this.internals.validationMessage;\n }\n\n /**\n * Getter for the willValidate attribute.\n * @returns {boolean} Whether the input will be validated.\n */\n get willValidate() {\n return this.internals.willValidate;\n }\n\n /**\n * @summary Getter for the defaultValue attribute.\n * This method retrieves the 'value' attribute of the custom input element.\n * The 'value' attribute represents the default value of the input element.\n * If the 'value' attribute is not set, it returns an empty string.\n * @returns {string} The default value of the input element.\n */\n get defaultValue() {\n return this.getAttribute('value') ?? '';\n }\n\n /**\n * @summary Setter for the defaultValue attribute.\n * This method sets the 'value' attribute of the custom input element to the provided value.\n * The 'value' attribute represents the default value of the input element.\n * @param {string} value The value to set as the default value.\n */\n set defaultValue(value) {\n this.setAttribute('value', value);\n }\n\n /**\n * Sets the label value.\n * @param {Array} value The selected value to set.\n */\n set selected(value) {\n this._selected = value;\n }\n\n /**\n * Returns the selected value.\n * @returns {Array} The selected value.\n */\n get selected() {\n return this.getSelected();\n }\n\n /**\n * Sets the trigger value.\n * @param {string} value The trigger value to set.\n */\n set trigger(value) {\n this.setAttribute('trigger', value);\n }\n\n /**\n * Returns the trigger value.\n * @returns {string} The trigger value.\n */\n get trigger() {\n return this.getAttribute('trigger') || 'click';\n }\n\n className = 'Select';\n\n /**\n * Returns the CSS styles for the component.\n * @static\n * @returns {CSSStyleSheet}\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Returns the list of attributes to observe for changes.\n * @static\n * @returns {Array<string>}\n */\n static get observedAttributes() {\n return ['active', 'value', 'disabled', 'multiple', 'label', 'placeholder', 'max-height', 'max-options', 'variant', 'placement'];\n }\n\n /**\n * Whether the input is associated with a form.\n * @type {boolean}\n */\n static formAssociated = true;\n\n /**\n * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Draws the component for the select.\n * @returns {DocumentFragment}\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n this.classList.add('wje-placement', this.placement ? 'wje-' + this.placement : 'wje-start');\n\n // zakladny obalovac\n let native = document.createElement('div');\n native.setAttribute('part', 'native');\n native.classList.add('native-select', this.variant || 'default');\n\n // wrapper pre label a inputWrapper\n let wrapper = document.createElement('div');\n wrapper.classList.add('wrapper');\n wrapper.setAttribute('slot', 'anchor');\n\n // label\n let label = document.createElement('wje-label');\n label.innerText = this.label || '';\n\n // obalovac pre input\n let inputWrapper = document.createElement('div');\n inputWrapper.setAttribute('part', 'input-wrapper');\n inputWrapper.classList.add('input-wrapper');\n\n let slotStart = document.createElement('div');\n slotStart.classList.add('slot-start');\n\n let input = document.createElement('input');\n input.setAttribute('type', 'text');\n input.setAttribute('part', 'input');\n input.setAttribute('autocomplete', 'off');\n input.setAttribute('readonly', '');\n input.setAttribute('placeholder', this.placeholder || '');\n\n let slotEnd = document.createElement('div');\n slotEnd.classList.add('slot-end');\n\n let arrow = document.createElement('wje-icon');\n arrow.setAttribute('name', 'chevron-down');\n arrow.setAttribute('slot', 'arrow');\n\n let chips = document.createElement('div');\n chips.classList.add('chips');\n chips.innerText = this.placeholder || '';\n\n // obalovac pre option a find\n let optionsWrapper = document.createElement('div');\n optionsWrapper.setAttribute('part', 'options-wrapper');\n optionsWrapper.classList.add('options-wrapper');\n optionsWrapper.style.setProperty('height', this.maxHeight || 'auto');\n\n let list = document.createElement('div');\n list.classList.add('list');\n\n let slot = document.createElement('slot');\n\n let clear = document.createElement('wje-button');\n clear.setAttribute('fill', 'link');\n clear.setAttribute('part', 'clear');\n clear.setAttribute('stop-propagation', '');\n\n let clearIcon = document.createElement('wje-icon');\n clearIcon.setAttribute('name', 'x');\n\n clear.appendChild(clearIcon);\n\n // vytvorime popup\n let popup = document.createElement('wje-popup');\n popup.setAttribute('placement', 'bottom-start');\n popup.setAttribute('manual', '');\n popup.setAttribute('size', '');\n\n if (this.hasAttribute('disabled')) popup.setAttribute('disabled', '');\n\n if (this.variant === 'standard') {\n if (this.hasAttribute('label')) native.appendChild(label);\n } else {\n wrapper.appendChild(label);\n }\n\n inputWrapper.appendChild(slotStart);\n inputWrapper.appendChild(input);\n if (this.hasAttribute('multiple')) inputWrapper.appendChild(chips);\n\n if (this.hasAttribute('clearable')) inputWrapper.appendChild(clear);\n\n inputWrapper.appendChild(slotEnd);\n inputWrapper.appendChild(arrow);\n\n list.appendChild(slot);\n\n if (this.hasAttribute('find')) {\n let find = document.createElement('wje-input');\n find.setAttribute('variant', 'standard');\n find.setAttribute('placeholder', 'Hľadať');\n find.classList.add('find');\n\n optionsWrapper.appendChild(find);\n\n this.findEl = find;\n }\n\n if (this.hasAttribute('lazy')) {\n event.addListener(popup, 'wje-popup:show', null, (e) => {\n if (this._wasOppened) return;\n this._wasOppened = true;\n\n const optionsElement = this.querySelector('wje-options');\n optionsElement.setAttribute('lazy', '');\n optionsElement.setAttribute('attached', '');\n });\n } else {\n const optionsElement = this.querySelector('wje-options');\n optionsElement?.setAttribute('attached', '');\n }\n\n optionsWrapper.appendChild(list);\n\n wrapper.appendChild(inputWrapper);\n popup.appendChild(optionsWrapper);\n popup.appendChild(wrapper);\n\n if (this.trigger === 'click') popup.setAttribute('manual', '');\n\n native.appendChild(popup);\n\n this.native = native;\n this.popup = popup;\n this.labelElement = label;\n this.slotStart = slotStart;\n this.slotEnd = slotEnd;\n this.input = input;\n this.optionsWrapper = optionsWrapper;\n this.chips = chips;\n this.clear = clear;\n this.list = list;\n\n fragment.appendChild(native);\n\n return fragment;\n }\n\n /**\n * Sets up the event listeners after the component is drawn.\n */\n afterDraw() {\n this.input.addEventListener('focus', (e) => {\n this.labelElement?.classList.add('fade');\n this.native.classList.add('focused');\n });\n\n this.input.addEventListener('blur', (e) => {\n this.native.classList.remove('focused');\n if (!e.target.value) this.labelElement?.classList.remove('fade');\n });\n\n this.addEventListener('wje-option:change', this.optionChange);\n\n this.clear?.addEventListener('wje-button:click', (e) => {\n e.preventDefault();\n e.stopPropagation();\n this.selectedOptions = [];\n\n this.getAllOptions().forEach((option) => {\n option.selected = false;\n option.removeAttribute('selected');\n });\n this.selections();\n\n e.stopPropagation();\n });\n\n this.selectedOptions = this.getSelectedOptions();\n this.selections(true);\n\n this.list.addEventListener('wje-options:load', (e) => {\n // todo select options from this.selectedOptions\n this.selectedOptions.forEach((option) => {\n this.getAllOptions().forEach((el) => {\n if (el.value === option.value) {\n el.selected = true;\n el.setAttribute('selected', '');\n }\n });\n })\n\n this.list.scrollTo(0, 0);\n });\n\n // skontrolujeme ci ma select atribut find\n if (this.hasAttribute('find') && this.findEl instanceof HTMLElement) {\n event.addListener(this.findEl, 'keyup', '', (e) => {\n // contains wj-options element with options\n const optionsElement = this.querySelector('wje-options');\n if (optionsElement && optionsElement.hasAttribute('lazy')) {\n // pass search value to wj-options element and infinite scroll will handle the rest\n optionsElement.setAttribute('search', e.target.value);\n } else {\n let value = e.target.value.trim().toLowerCase();\n\n this.getAllOptions().forEach((option) => {\n if (option.textContent.trim().toLowerCase().includes(value)) option.style.display = 'block';\n else option.style.display = 'none';\n });\n }\n });\n }\n }\n\n /**\n * Handles the option change event.\n * @param {Event} e The event.\n */\n optionChange = (e) => {\n e.stopPropagation()\n e.stopImmediatePropagation()\n\n let allOptions = this.getAllOptions();\n\n if (!this.hasAttribute('multiple')) {\n allOptions.forEach((option) => {\n if (option.value === e.target.value) {\n this.processClickedOption(option);\n\n } else {\n option.selected = false;\n option.removeAttribute('selected');\n }\n });\n this.popup.hide();\n } else {\n this.processClickedOption(e.target, true);\n }\n\n this.selections();\n };\n\n processClickedOption = (option, multiple = false) => {\n const isSelected = option.hasAttribute(\"selected\")\n option.selected = !isSelected;\n\n if (isSelected) {\n option.removeAttribute('selected');\n this.filterOutOption(option);\n } else {\n option.setAttribute('selected', '');\n this.selectedOptions = multiple ? [...this.selectedOptions, option] : [option];\n }\n }\n\n filterOutOption = (option) => {\n this.selectedOptions = this.selectedOptions.filter((sOption) => {\n return sOption.value !== option.value;\n });\n }\n\n /**\n * Returns all the options as HTML.\n * @returns {NodeList} The options as HTML.\n */\n getAllOptions() {\n return this.querySelectorAll('wje-option');\n }\n\n /**\n * Returns the selected options as HTML.\n * @returns {NodeList} The selected options as HTML.\n */\n getSelectedOptions() {\n return Array.from(this.querySelectorAll('wje-option[selected]'));\n }\n\n /**\n * Returns the selected options.\n * @returns {Array} The selected options.\n */\n getSelected() {\n return this.selectedOptions.map((option) => {\n return {\n value: option.value,\n text: option.textContent.trim(),\n };\n });\n }\n\n /**\n * Handles the selection change.\n * @param {Element} option The option that changed.\n * @param {number} length The length of the selected options.\n */\n selectionChanged(option = null, length = 0) {\n if (this.hasAttribute('multiple')) {\n this.value = this.selectedOptions.map((el) => el.value).reverse();\n\n if (this.placeholder && length === 0) {\n this.chips.innerHTML = this.placeholder;\n this.input.value = '';\n } else {\n if (option !== null) this.chips.appendChild(this.getChip(option));\n if (this.counterEl instanceof HTMLElement || length > +this.maxOptions) {\n this.counter();\n }\n }\n } else {\n let value = option?.textContent.trim() || '';\n this.value = this.selectedOptions?.map((el) => el.value)?.at(0);\n this.input.value = value;\n\n if (option && option instanceof HTMLElement) {\n this.slotStart.innerHTML = '';\n\n if (option?.querySelector('[slot=start]')) {\n this.slotStart.appendChild(option?.querySelector('[slot=start]').cloneNode(true));\n }\n\n this.slotEnd.innerHTML = '';\n\n if (option?.querySelector('[slot=end]')) {\n this.slotEnd.appendChild(option?.querySelector('[slot=end]').cloneNode(true));\n }\n }\n }\n }\n\n /**\n * Updates the selected options and their corresponding chips.\n * @param {boolean} [silence] Determines whether to suppress the \"wje-select:change\" event.\n * @returns {void}\n * @description\n * This method fetches the currently selected options and updates the `selectedOptions` array.\n * It clears and rebuilds the chips representing the selected items in the UI.\n * If the number of selected options reaches the maximum allowed (`maxOptions`), it stops updating the counter.\n * Optionally, it dispatches a custom event when the selection changes unless `silence` is set to `true`.\n * //@fires wje-select:change - Dispatched when the selection changes, unless `silence` is `true`.\n * @example\n * // Call the method and allow event dispatch\n * selections();\n * @example\n * // Call the method without dispatching the event\n * selections(true);\n */\n selections(silence = false) {\n if (this.selectedOptions.length >= +this.maxOptions) {\n this.counterEl = null;\n }\n\n if (this.chips) {\n this.chips.innerHTML = '';\n }\n\n if (this.selectedOptions.length > 0) {\n this.selectionChanged(this.selectedOptions.at(0), this.selectedOptions.length);\n\n } else {\n this.selectionChanged();\n }\n\n if (silence) return;\n event.dispatchCustomEvent(this, 'wje-select:change');\n }\n\n /**\n * Manages the display of a counter element to indicate the number of items exceeding the maximum allowed options.\n * - If the number of selected items equals the maximum allowed, the counter element is removed.\n * - If the counter element doesn't exist and the number of items exceeds the maximum, it is created and updated.\n */\n counter() {\n // zmazanie counter (span)\n if (this.counterEl && this.value.length === +this.maxOptions) {\n this.counterEl.remove();\n this.counterEl = null;\n return;\n }\n\n // ak counter nie je, tak ho vytvorime\n if (!this.counterEl) {\n this.counterEl = document.createElement('span');\n this.counterEl.classList.add('counter');\n\n this.chips.appendChild(this.counterEl);\n }\n\n // nastavime hodnotu counter\n this.counterEl.innerText = `+${this.value.length - +this.maxOptions}`;\n }\n\n /**\n * Returns a chip element.\n * @param {Element} option The option to get the chip for.\n * @returns {Element} The chip element.\n */\n getChip(option) {\n let chip = document.createElement('wje-chip');\n chip.setAttribute('removable', '');\n chip.addEventListener('wje:chip-remove', this.removeChip);\n chip.option = option;\n\n let label = document.createElement('wje-label');\n label.innerText = option.textContent.trim();\n\n chip.appendChild(label);\n\n return chip;\n }\n\n /**\n * Handles the chip remove event.\n * @param {Event} e The event.\n */\n removeChip = (e) => {\n e.target.parentNode.removeChild(e.target);\n this.processClickedOption(e.target.option, true);\n this.selections();\n };\n\n /**\n * Generates an HTML option element based on the provided item and mapping.\n * @param {object} item The item to generate the option for.\n * @param {object} [map] The mapping object that specifies the properties of the item to use for the option's value and text.\n * @param {string} [map.value] The property of the item to use for the option's value.\n * @param {string} [map.text] The property of the item to use for the option's text.\n * @returns {HTMLElement} The generated HTML option element.\n */\n htmlOption(item, map = { value: 'value', text: 'text' }) {\n let option = document.createElement('wje-option');\n\n if (item[map.value] === null) {\n console.warn(`The item ${JSON.stringify(item)} does not have the property ${map.value}`);\n }\n\n if (item[map.text] === null) {\n console.warn(`The item ${JSON.stringify(item)} does not have the property ${map.text}`);\n }\n\n option.setAttribute('value', item[map.value] ?? '');\n option.innerText = item[map.text] ?? '';\n return option;\n }\n\n /**\n * Adds an option to the select element.\n * @param {any} optionData The data for the option to be added.\n * @param {boolean} [silent] Whether to suppress any events triggered by the addition of the option.\n * @param {object} [map] The mapping object specifying the properties of the option data to be used for the value and text of the option.\n */\n addOption(optionData, silent = false, map = { value: 'value', text: 'text' }) {\n if (!optionData) return;\n\n const optionsElement = this.querySelector('wje-options');\n if (optionsElement) {\n optionsElement.addOption(optionData, silent, map);\n return;\n }\n\n let option = this.htmlOption(optionData, map);\n this.appendChild(option);\n }\n\n /**\n * Adds options to the select element.\n * @param {Array | object} optionsData The options data to be added. Can be an array of objects or a single object.\n * @param {boolean} [silent] Indicates whether to trigger events when adding options. Default is false.\n * @param {object} [map] The mapping object that specifies the properties of the options data object. Default is { value: \"value\", text: \"text\" }.\n */\n addOptions(optionsData, silent = false, map = { value: 'value', text: 'text' }) {\n if (!Array.isArray(optionsData)) {\n this.addOption(optionsData, silent, map);\n } else {\n const optionsElement = this.querySelector('wje-options');\n if (optionsElement) {\n optionsElement.addOptions(optionsData, silent, map);\n return;\n }\n\n optionsData.forEach((item) => {\n this.addOption(item, silent, map);\n });\n }\n }\n\n /**\n * Selects an option with the specified value.\n * @param {string} value The value of the option to be selected.\n * @param {boolean} [silent] Whether to suppress firing events.\n */\n selectOption(value, silent = false) {\n if (!value) return;\n\n let option = this.querySelector(`wje-option[value=\"${value}\"]`);\n\n if (option) {\n this.processClickedOption(option, this.hasAttribute('multiple'));\n }\n\n if (this.drawingStatus > this.drawingStatuses.START) this.selections(silent);\n }\n\n /**\n * Selects one or multiple options in the select element.\n * @param {Array|any} values The value(s) of the option(s) to be selected.\n * @param {boolean} [silent] Whether to trigger the change event or not.\n */\n selectOptions(values, silent = false) {\n if (!Array.isArray(values)) {\n this.selectOption(values, silent);\n } else {\n values.forEach((value) => {\n this.selectOption(value, silent);\n });\n }\n }\n\n /**\n * @summary Callback function that is called when the custom element is associated with a form.\n * This function adds an event listener to the form's submit event, which validates the input and propagates the validation.\n * @param {HTMLFormElement} form The form the custom element is associated with.\n */\n formAssociatedCallback(form) {\n if (form) {\n this.internals.setFormValue(this.value);\n }\n }\n\n /**\n * The formResetCallback method is a built-in lifecycle callback that gets called when a form gets reset.\n * This method is responsible for resetting the value of the custom input element to its default value.\n * It also resets the form value and validity state in the form internals.\n * @function\n */\n formResetCallback() {\n // Set the value of the custom input element to its default value\n this.value = this.defaultValue;\n // Reset the form value in the form internals to the default value\n this.internals.setFormValue(this.defaultValue);\n // Reset the validity state in the form internals\n this.internals.setValidity({});\n }\n\n /**\n * The formStateRestoreCallback method is a built-in lifecycle callback that gets called when the state of a form-associated custom element is restored.\n * This method is responsible for restoring the value of the custom input element to its saved state.\n * It also restores the form value and validity state in the form internals to their saved states.\n * @param {object} state The saved state of the custom input element.\n * @function\n */\n formStateRestoreCallback(state) {\n // Set the value of the custom input element to its saved value\n this.value = state.value;\n // Restore the form value in the form internals to the saved value\n this.internals.setFormValue(state.value);\n // Restore the validity state in the form internals to the saved state\n this.internals.setValidity({});\n }\n\n /**\n * The formStateSaveCallback method is a built-in lifecycle callback that gets called when the state of a form-associated custom element is saved.\n * This method is responsible for saving the value of the custom input element.\n * @returns {object} The saved state of the custom input element.\n * @function\n */\n formStateSaveCallback() {\n return {\n value: this.value,\n };\n }\n\n /**\n * The formDisabledCallback method is a built-in lifecycle callback that gets called when the disabled state of a form-associated custom element changes.\n * This method is not implemented yet.\n * @param {boolean} disabled The new disabled state of the custom input element.\n * @function\n */\n formDisabledCallback(disabled) {\n console.warn('formDisabledCallback not implemented yet');\n this.native?.classList.toggle('disabled', disabled);\n this.toggleAttribute('disabled', disabled);\n }\n}\n","import Select from './select.element.js';\n\nexport default Select;\n\nSelect.define('wje-select', Select);\n"],"names":["_a"],"mappings":";;;;;;;;;;;;;;AAwCe,MAAM,eAAe,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAW1C,cAAc;AACV,UAAO;AAiGX,wCAAe;AAAA,MACX,cAAc;AAAA,MACd,aAAa;AAAA,MACb,YAAY;AAAA,MACZ,aAAa;AAAA,MACb,YAAY;AAAA,MACZ,aAAa;AAAA,MACb,cAAc;AAAA,MACd,eAAe;AAAA,IAClB;AA8JD,qCAAY;AA0PZ;AAAA;AAAA;AAAA;AAAA,wCAAe,CAAC,MAAM;AAClB,QAAE,gBAAe;AACjB,QAAE,yBAAwB;AAE1B,UAAI,aAAa,KAAK,cAAe;AAErC,UAAI,CAAC,KAAK,aAAa,UAAU,GAAG;AAChC,mBAAW,QAAQ,CAAC,WAAW;AAC3B,cAAI,OAAO,UAAU,EAAE,OAAO,OAAO;AACjC,iBAAK,qBAAqB,MAAM;AAAA,UAEpD,OAAuB;AACH,mBAAO,WAAW;AAClB,mBAAO,gBAAgB,UAAU;AAAA,UACrD;AAAA,QACA,CAAa;AACD,aAAK,MAAM,KAAM;AAAA,MAC7B,OAAe;AACH,aAAK,qBAAqB,EAAE,QAAQ,IAAI;AAAA,MACpD;AAEQ,WAAK,WAAY;AAAA,IACpB;AAED,gDAAuB,CAAC,QAAQ,WAAW,UAAU;AACjD,YAAM,aAAa,OAAO,aAAa,UAAU;AACjD,aAAO,WAAW,CAAC;AAEnB,UAAI,YAAY;AACZ,eAAO,gBAAgB,UAAU;AACjC,aAAK,gBAAgB,MAAM;AAAA,MACvC,OAAe;AACH,eAAO,aAAa,YAAY,EAAE;AAClC,aAAK,kBAAkB,WAAW,CAAC,GAAG,KAAK,iBAAiB,MAAM,IAAI,CAAC,MAAM;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;AAAA,EACrC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASI,yBAAyB,OAAO;AAE5B,SAAK,QAAQ,MAAM;AAEnB,SAAK,UAAU,aAAa,MAAM,KAAK;AAEvC,SAAK,UAAU,YAAY,EAAE;AAAA,EACrC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQI,wBAAwB;AACpB,WAAO;AAAA,MACH,OAAO,KAAK;AAAA,IACf;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQI,qBAAqB,UAAU;;AAC3B,YAAQ,KAAK,0CAA0C;AACvD,eAAK,WAAL,mBAAa,UAAU,OAAO,YAAY;AAC1C,SAAK,gBAAgB,YAAY,QAAQ;AAAA,EACjD;AACA;AAAA;AAAA;AAAA;AAAA;AA9kBI,cA5SiB,QA4SV,kBAAiB;AChV5B,OAAO,OAAO,cAAc,MAAM;"}
@@ -12,6 +12,21 @@ class TabGroup extends WJElement {
12
12
  super();
13
13
  __publicField(this, "className", "TabGroup");
14
14
  }
15
+ /**
16
+ * Sets the 'type' attribute of the element to the specified value.
17
+ * @param {string} value The value to set for the 'type' attribute.
18
+ */
19
+ set type(value) {
20
+ this.setAttribute("type", value);
21
+ }
22
+ /**
23
+ * Retrieves the `type` attribute of the element.
24
+ * If the `type` attribute is not set, it defaults to `'panel'`.
25
+ * @returns {string} The value of the `type` attribute or the default value `'panel'`.
26
+ */
27
+ get type() {
28
+ return this.getAttribute("type") || "panel";
29
+ }
15
30
  /**
16
31
  * Returns the CSS styles for the component.
17
32
  * @static
@@ -40,13 +55,18 @@ class TabGroup extends WJElement {
40
55
  }
41
56
  }
42
57
  /**
43
- * Draws the component.
44
- * @param {object} context The context for drawing.
45
- * @param {object} store The store for drawing.
46
- * @param {object} params The parameters for drawing.
47
- * @returns {DocumentFragment}
58
+ * Creates and returns a document fragment containing a structured layout for a tab group.
59
+ * The tab group layout includes a `header` section with navigational elements,
60
+ * a `section` element for tab panels, and slots for customization such as additional navigation items,
61
+ * dropdowns, and more.
62
+ * The structure comprises:
63
+ * - A `div` container with relevant styling and part attributes.
64
+ * - A `header` for tabs, including a slot for navigation (`nav`) and additional tabs in a dropdown (`moreDropdown`).
65
+ * - A `section` for tab panels with a customizable `slot`.
66
+ * This function also initializes the `nav` and `moreDropdown` properties for external use.
67
+ * @returns {DocumentFragment} The completed document fragment containing the tab group layout.
48
68
  */
49
- draw(context, store, params) {
69
+ draw() {
50
70
  let fragment = document.createDocumentFragment();
51
71
  let native = document.createElement("div");
52
72
  native.setAttribute("part", "native");
@@ -89,11 +109,13 @@ class TabGroup extends WJElement {
89
109
  return fragment;
90
110
  }
91
111
  /**
92
- * Sets up the event listeners after the component is drawn.
112
+ * Executes necessary initializations and attaches event listeners after a drawing operation.
113
+ * Handles active tab selection, 'wje-tab:change' event binding, and window resize event for overflow checking.
114
+ * @returns {void} Does not return a value.
93
115
  */
94
116
  afterDraw() {
95
117
  let activeTab = this.getActiveTab();
96
- let activeTabName = activeTab ? activeTab[0].panel : this.getTabAll()[0].panel;
118
+ let activeTabName = activeTab ? activeTab[0][this.type] : this.getTabAll()[0][this.type];
97
119
  this.setActiveTab(activeTabName);
98
120
  this.addEventListener("wje-tab:change", (e) => {
99
121
  if (e.detail.context.hasAttribute("disabled")) return;
@@ -104,7 +126,8 @@ class TabGroup extends WJElement {
104
126
  requestAnimationFrame(() => this.checkOverflow());
105
127
  }
106
128
  /**
107
- * Removes the active attribute from all tabs and panels.
129
+ * Removes the 'active' class from all panel and tab elements.
130
+ * @returns {void} This method does not return a value.
108
131
  */
109
132
  removeActiveTab() {
110
133
  this.getPanelAll().forEach((el) => {
@@ -121,10 +144,12 @@ class TabGroup extends WJElement {
121
144
  setActiveTab(tab) {
122
145
  var _a;
123
146
  this.removeActiveTab();
124
- const el = this.querySelector(`[panel="${tab}"]`);
147
+ const el = this.querySelector(`[${this.type}="${tab}"]`);
125
148
  el == null ? void 0 : el.classList.add("active");
126
- (_a = this.querySelector(`[name="${tab}"]`)) == null ? void 0 : _a.classList.add("active");
127
- this.dropdownActive(el);
149
+ if (this.type === "panel")
150
+ (_a = this.querySelector(`[name="${tab}"]`)) == null ? void 0 : _a.classList.add("active");
151
+ if (el)
152
+ this.dropdownActive(el);
128
153
  }
129
154
  /**
130
155
  * Returns the currently active tab.
@@ -155,10 +180,19 @@ class TabGroup extends WJElement {
155
180
  getPanelAllName() {
156
181
  return this.getPanelAll().map((el) => el.getAttribute("name"));
157
182
  }
183
+ /**
184
+ * Toggles the visibility of the "more" dropdown based on the presence of tabs in the "more" slot.
185
+ * @returns {void} Does not return a value.
186
+ */
158
187
  toggleMoreVisibility() {
159
188
  const hasTabsInMore = this.querySelector('wje-tab[slot="more"]');
160
189
  this.moreDropdown.hidden = !hasTabsInMore;
161
190
  }
191
+ /**
192
+ * Checks if the tabs within a navigation bar overflow the available space.
193
+ * Moves overflowing tabs into a dropdown menu and updates their state accordingly.
194
+ * @returns {void} This method does not return a value.
195
+ */
162
196
  checkOverflow() {
163
197
  const nav = this.nav;
164
198
  const moreBtn = this.moreDropdown;
@@ -180,6 +214,12 @@ class TabGroup extends WJElement {
180
214
  this.toggleMoreVisibility();
181
215
  });
182
216
  }
217
+ /**
218
+ * Toggles the "dropdown-active" class on the element based on its "active" status
219
+ * and the value of its "slot" attribute.
220
+ * @param {HTMLElement} el The HTML element to evaluate and apply the toggle logic.
221
+ * @returns {void} This method does not return any value.
222
+ */
183
223
  dropdownActive(el) {
184
224
  if (el.classList.contains("active")) {
185
225
  if (el.getAttribute("slot") === "more")
@@ -1 +1 @@
1
- {"version":3,"file":"wje-tab-group.js","sources":["../packages/wje-tab-group/tab-group.element.js","../packages/wje-tab-group/tab-group.js"],"sourcesContent":["import { default as WJElement } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * `TabGroup` is a custom web component that represents a group of tabs.\n * @summary This element represents a group of tabs.\n * @documentation https://elements.webjet.sk/components/tab-group\n * @status stable\n * @augments WJElement\n * @slot - The default slot for the tab group.\n * @slot nav - Slot for the navigation of the tab group.\n * @cssproperty [--wje-tab-group-padding=1rem] - Specifies the padding inside the tab group. This property defines the space between the content of the tab group and its outer boundary. Accepts any valid CSS length unit (e.g., `px`, `rem`, `em`, `%`).\n * @tag wje-tab-group\n */\n\nexport default class TabGroup extends WJElement {\n /**\n * Creates an instance of TabGroup.\n * @class\n */\n constructor() {\n super();\n }\n\n className = 'TabGroup';\n\n /**\n * Returns the CSS styles for the component.\n * @static\n * @returns {CSSStyleSheet}\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Sets up the event listeners before the component is drawn.\n * This method is called before the component is drawn.\n * It is used to set up event listeners.\n */\n beforeDraw() {\n let activeTabName = location.hash.replace('#', '');\n\n // skontrolujeme ci sa nachadza v paneloch\n if (this.getPanelAllName().includes(activeTabName)) {\n window.addEventListener('load', (e) => {\n this.setActiveTab(activeTabName);\n });\n }\n }\n\n /**\n * Draws the component.\n * @param {object} context The context for drawing.\n * @param {object} store The store for drawing.\n * @param {object} params The parameters for drawing.\n * @returns {DocumentFragment}\n */\n draw(context, store, params) {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('div');\n native.setAttribute('part', 'native');\n native.classList.add('native-tab-group');\n\n let header = document.createElement('header');\n header.setAttribute('part', 'tabs');\n header.classList.add('scroll-snap-x');\n\n let nav = document.createElement('nav');\n\n let section = document.createElement('section');\n section.setAttribute('part', 'panels');\n\n let slot = document.createElement('slot');\n\n let slotNav = document.createElement('slot');\n slotNav.setAttribute('name', 'nav');\n\n let icon = document.createElement('wje-icon');\n icon.setAttribute('name', 'dots');\n\n let button = document.createElement('wje-button');\n button.setAttribute('slot', 'trigger');\n button.setAttribute('fill', 'link');\n\n let menu = document.createElement('wje-menu');\n menu.setAttribute('variant', 'context');\n\n let slotMore = document.createElement('slot');\n slotMore.setAttribute('name', 'more');\n\n let moreDropdown = document.createElement('wje-dropdown');\n moreDropdown.setAttribute('placement', 'bottom-end');\n moreDropdown.setAttribute('collapsible', '');\n moreDropdown.classList.add('more-tabs');\n\n button.append(icon);\n\n menu.append(slotMore);\n\n moreDropdown.append(button);\n moreDropdown.append(menu);\n\n header.append(nav);\n\n nav.append(slotNav);\n nav.append(moreDropdown);\n\n section.append(slot);\n\n native.append(header);\n native.append(section);\n\n fragment.append(native);\n\n this.nav = nav;\n this.moreDropdown = moreDropdown;\n\n return fragment;\n }\n\n /**\n * Sets up the event listeners after the component is drawn.\n */\n afterDraw() {\n let activeTab = this.getActiveTab();\n let activeTabName = activeTab ? activeTab[0].panel : this.getTabAll()[0].panel;\n\n this.setActiveTab(activeTabName);\n\n this.addEventListener('wje-tab:change', (e) => {\n if (e.detail.context.hasAttribute('disabled')) return;\n this.setActiveTab(e.detail.context.panel);\n });\n\n this.checkOverflow = this.checkOverflow.bind(this);\n\n window.addEventListener('resize', this.checkOverflow);\n\n requestAnimationFrame(() => this.checkOverflow());\n }\n\n /**\n * Removes the active attribute from all tabs and panels.\n */\n removeActiveTab() {\n this.getPanelAll().forEach((el) => {\n el.classList.remove('active');\n });\n\n this.getTabAll().forEach((el) => {\n el.classList.remove('active');\n });\n }\n\n /**\n * Sets the active tab and panel.\n * @param {string} tab The name of the tab to set as active.\n */\n setActiveTab(tab) {\n this.removeActiveTab();\n const el = this.querySelector(`[panel=\"${tab}\"]`)\n el?.classList.add('active');\n this.querySelector(`[name=\"${tab}\"]`)?.classList.add('active');\n\n this.dropdownActive(el);\n }\n\n /**\n * Returns the currently active tab.\n * @returns {Element|null} The active tab, or null if no tab is active.\n */\n getActiveTab() {\n let activeTabs = Array.from(this.querySelectorAll('wje-tab.active'));\n return activeTabs.length > 0 ? activeTabs : null;\n }\n\n /**\n * Returns all tabs.\n * @returns {Array<Element>} An array of all tabs.\n */\n getTabAll() {\n return this.context.querySelector('[name=\"nav\"]').assignedElements();\n }\n\n /**\n * Returns all panels.\n * @returns {Array<Element>} An array of all panels.\n */\n getPanelAll() {\n return Array.from(this.querySelectorAll('wje-tab-panel'));\n }\n\n /**\n * Returns the names of all tabs.\n * @returns {Array<string>} An array of all tab names.\n */\n getPanelAllName() {\n return this.getPanelAll().map((el) => el.getAttribute('name'));\n }\n\n toggleMoreVisibility() {\n const hasTabsInMore = this.querySelector('wje-tab[slot=\"more\"]');\n this.moreDropdown.hidden = !hasTabsInMore;\n }\n\n checkOverflow() {\n const nav = this.nav;\n const moreBtn = this.moreDropdown;\n const moreWidth = moreBtn.offsetWidth || 48; // fallback ak ešte nie je vykreslený\n\n const tabs = Array.from(this.querySelectorAll('wje-tab'));\n\n // Reset: presunieme všetky taby naspäť do nav slotu\n tabs.forEach(tab => tab.setAttribute('slot', 'nav'));\n\n // Vykreslíme nanovo, aby sa more button správne umiestnil\n requestAnimationFrame(() => {\n const navRight = nav.getBoundingClientRect().right;\n let overflowStarted = false;\n\n for (const tab of tabs) {\n const tabRect = tab.getBoundingClientRect();\n\n // Ak by pretekal vrátane rezervy na more, presunieme ho\n const fits = tabRect.right + moreWidth <= navRight;\n\n if (!fits || overflowStarted) {\n tab.setAttribute('slot', 'more');\n this.dropdownActive(tab);\n overflowStarted = true;\n }\n }\n\n this.toggleMoreVisibility();\n });\n }\n\n dropdownActive(el) {\n if(el.classList.contains('active')) {\n if(el.getAttribute('slot') === 'more')\n this.moreDropdown.classList.add('dropdown-active');\n else\n this.moreDropdown.classList.remove('dropdown-active');\n }\n }\n}\n","import TabGroup from './tab-group.element.js';\n\nexport default TabGroup;\n\nTabGroup.define('wje-tab-group', TabGroup);\n"],"names":[],"mappings":";;;;;AAee,MAAM,iBAAiB,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA,EAK5C,cAAc;AACV,UAAO;AAGX,qCAAY;AAAA,EAFhB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASI,WAAW,gBAAgB;AACvB,WAAO;AAAA,EACf;AAAA;AAAA;AAAA;AAAA,EA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;AAAA,EAEI,eAAe,IAAI;AACf,QAAG,GAAG,UAAU,SAAS,QAAQ,GAAG;AAChC,UAAG,GAAG,aAAa,MAAM,MAAM;AAC3B,aAAK,aAAa,UAAU,IAAI,iBAAiB;AAAA;AAEjD,aAAK,aAAa,UAAU,OAAO,iBAAiB;AAAA,IACpE;AAAA,EACA;AACA;AC1PA,SAAS,OAAO,iBAAiB,QAAQ;"}
1
+ {"version":3,"file":"wje-tab-group.js","sources":["../packages/wje-tab-group/tab-group.element.js","../packages/wje-tab-group/tab-group.js"],"sourcesContent":["import { default as WJElement } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * `TabGroup` is a custom web component that represents a group of tabs.\n * @summary This element represents a group of tabs.\n * @documentation https://elements.webjet.sk/components/tab-group\n * @status stable\n * @augments WJElement\n * @param {string} type The type of the tab group. Can be either 'panel' or 'route'.\n * @slot - The default slot for the tab group.\n * @slot nav - Slot for the navigation of the tab group.\n * @cssproperty [--wje-tab-group-padding=1rem] - Specifies the padding inside the tab group. This property defines the space between the content of the tab group and its outer boundary. Accepts any valid CSS length unit (e.g., `px`, `rem`, `em`, `%`).\n * @tag wje-tab-group\n */\n\nexport default class TabGroup extends WJElement {\n /**\n * Creates an instance of TabGroup.\n * @class\n */\n constructor() {\n super();\n }\n\n /**\n * Sets the 'type' attribute of the element to the specified value.\n * @param {string} value The value to set for the 'type' attribute.\n */\n set type(value) {\n this.setAttribute('type', value);\n }\n\n /**\n * Retrieves the `type` attribute of the element.\n * If the `type` attribute is not set, it defaults to `'panel'`.\n * @returns {string} The value of the `type` attribute or the default value `'panel'`.\n */\n get type() {\n return this.getAttribute('type') || 'panel';\n }\n\n className = 'TabGroup';\n\n /**\n * Returns the CSS styles for the component.\n * @static\n * @returns {CSSStyleSheet}\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Sets up the event listeners before the component is drawn.\n * This method is called before the component is drawn.\n * It is used to set up event listeners.\n */\n beforeDraw() {\n let activeTabName = location.hash.replace('#', '');\n\n // skontrolujeme ci sa nachadza v paneloch\n if (this.getPanelAllName().includes(activeTabName)) {\n window.addEventListener('load', (e) => {\n this.setActiveTab(activeTabName);\n });\n }\n }\n\n /**\n * Creates and returns a document fragment containing a structured layout for a tab group.\n * The tab group layout includes a `header` section with navigational elements,\n * a `section` element for tab panels, and slots for customization such as additional navigation items,\n * dropdowns, and more.\n * The structure comprises:\n * - A `div` container with relevant styling and part attributes.\n * - A `header` for tabs, including a slot for navigation (`nav`) and additional tabs in a dropdown (`moreDropdown`).\n * - A `section` for tab panels with a customizable `slot`.\n * This function also initializes the `nav` and `moreDropdown` properties for external use.\n * @returns {DocumentFragment} The completed document fragment containing the tab group layout.\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('div');\n native.setAttribute('part', 'native');\n native.classList.add('native-tab-group');\n\n let header = document.createElement('header');\n header.setAttribute('part', 'tabs');\n header.classList.add('scroll-snap-x');\n\n let nav = document.createElement('nav');\n\n let section = document.createElement('section');\n section.setAttribute('part', 'panels');\n\n let slot = document.createElement('slot');\n\n let slotNav = document.createElement('slot');\n slotNav.setAttribute('name', 'nav');\n\n let icon = document.createElement('wje-icon');\n icon.setAttribute('name', 'dots');\n\n let button = document.createElement('wje-button');\n button.setAttribute('slot', 'trigger');\n button.setAttribute('fill', 'link');\n\n let menu = document.createElement('wje-menu');\n menu.setAttribute('variant', 'context');\n\n let slotMore = document.createElement('slot');\n slotMore.setAttribute('name', 'more');\n\n let moreDropdown = document.createElement('wje-dropdown');\n moreDropdown.setAttribute('placement', 'bottom-end');\n moreDropdown.setAttribute('collapsible', '');\n moreDropdown.classList.add('more-tabs');\n\n button.append(icon);\n\n menu.append(slotMore);\n\n moreDropdown.append(button);\n moreDropdown.append(menu);\n\n header.append(nav);\n\n nav.append(slotNav);\n nav.append(moreDropdown);\n\n section.append(slot);\n\n native.append(header);\n native.append(section);\n\n fragment.append(native);\n\n this.nav = nav;\n this.moreDropdown = moreDropdown;\n\n return fragment;\n }\n\n /**\n * Executes necessary initializations and attaches event listeners after a drawing operation.\n * Handles active tab selection, 'wje-tab:change' event binding, and window resize event for overflow checking.\n * @returns {void} Does not return a value.\n */\n afterDraw() {\n let activeTab = this.getActiveTab();\n let activeTabName = activeTab ? activeTab[0][this.type] : this.getTabAll()[0][this.type];\n\n this.setActiveTab(activeTabName);\n\n this.addEventListener('wje-tab:change', (e) => {\n if (e.detail.context.hasAttribute('disabled')) return;\n this.setActiveTab(e.detail.context.panel);\n });\n\n this.checkOverflow = this.checkOverflow.bind(this);\n\n window.addEventListener('resize', this.checkOverflow);\n\n requestAnimationFrame(() => this.checkOverflow());\n }\n\n /**\n * Removes the 'active' class from all panel and tab elements.\n * @returns {void} This method does not return a value.\n */\n removeActiveTab() {\n this.getPanelAll().forEach((el) => {\n el.classList.remove('active');\n });\n\n this.getTabAll().forEach((el) => {\n el.classList.remove('active');\n });\n }\n\n /**\n * Sets the active tab and panel.\n * @param {string} tab The name of the tab to set as active.\n */\n setActiveTab(tab) {\n this.removeActiveTab();\n\n const el = this.querySelector(`[${this.type}=\"${tab}\"]`)\n el?.classList.add('active');\n\n if(this.type === 'panel')\n this.querySelector(`[name=\"${tab}\"]`)?.classList.add('active');\n\n if(el)\n this.dropdownActive(el);\n }\n\n /**\n * Returns the currently active tab.\n * @returns {Element|null} The active tab, or null if no tab is active.\n */\n getActiveTab() {\n let activeTabs = Array.from(this.querySelectorAll('wje-tab.active'));\n return activeTabs.length > 0 ? activeTabs : null;\n }\n\n /**\n * Returns all tabs.\n * @returns {Array<Element>} An array of all tabs.\n */\n getTabAll() {\n return this.context.querySelector('[name=\"nav\"]').assignedElements();\n }\n\n /**\n * Returns all panels.\n * @returns {Array<Element>} An array of all panels.\n */\n getPanelAll() {\n return Array.from(this.querySelectorAll('wje-tab-panel'));\n }\n\n /**\n * Returns the names of all tabs.\n * @returns {Array<string>} An array of all tab names.\n */\n getPanelAllName() {\n return this.getPanelAll().map((el) => el.getAttribute('name'));\n }\n\n /**\n * Toggles the visibility of the \"more\" dropdown based on the presence of tabs in the \"more\" slot.\n * @returns {void} Does not return a value.\n */\n toggleMoreVisibility() {\n const hasTabsInMore = this.querySelector('wje-tab[slot=\"more\"]');\n this.moreDropdown.hidden = !hasTabsInMore;\n }\n\n /**\n * Checks if the tabs within a navigation bar overflow the available space.\n * Moves overflowing tabs into a dropdown menu and updates their state accordingly.\n * @returns {void} This method does not return a value.\n */\n checkOverflow() {\n const nav = this.nav;\n const moreBtn = this.moreDropdown;\n const moreWidth = moreBtn.offsetWidth || 48; // fallback ak ešte nie je vykreslený\n\n const tabs = Array.from(this.querySelectorAll('wje-tab'));\n\n // Reset: presunieme všetky taby naspäť do nav slotu\n tabs.forEach(tab => tab.setAttribute('slot', 'nav'));\n\n // Vykreslíme nanovo, aby sa more button správne umiestnil\n requestAnimationFrame(() => {\n const navRight = nav.getBoundingClientRect().right;\n let overflowStarted = false;\n\n for (const tab of tabs) {\n const tabRect = tab.getBoundingClientRect();\n\n // Ak by pretekal vrátane rezervy na more, presunieme ho\n const fits = tabRect.right + moreWidth <= navRight;\n\n if (!fits || overflowStarted) {\n tab.setAttribute('slot', 'more');\n this.dropdownActive(tab);\n overflowStarted = true;\n }\n }\n\n this.toggleMoreVisibility();\n });\n }\n\n /**\n * Toggles the \"dropdown-active\" class on the element based on its \"active\" status\n * and the value of its \"slot\" attribute.\n * @param {HTMLElement} el The HTML element to evaluate and apply the toggle logic.\n * @returns {void} This method does not return any value.\n */\n dropdownActive(el) {\n if(el.classList.contains('active')) {\n if(el.getAttribute('slot') === 'more')\n this.moreDropdown.classList.add('dropdown-active');\n else\n this.moreDropdown.classList.remove('dropdown-active');\n }\n }\n}\n","import TabGroup from './tab-group.element.js';\n\nexport default TabGroup;\n\nTabGroup.define('wje-tab-group', TabGroup);\n"],"names":[],"mappings":";;;;;AAgBe,MAAM,iBAAiB,UAAU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