wj-elements 0.1.168 → 0.1.170

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/light.css CHANGED
@@ -328,6 +328,10 @@
328
328
  --wje-dialog-padding-inline: var(--wje-spacing-medium);
329
329
  --wje-dialog-padding-top: var(--wje-spacing-medium);
330
330
  --wje-dialog-padding-bottom: var(--wje-spacing-medium);
331
+ --wje-dialog-headline-font-size: 0.656rem;
332
+ --wje-dialog-headline-letter-spacing: 0.06em;
333
+ --wje-dialog-headline-font-weight: 500;
334
+ --wje-dialog-headline-text-transform: uppercase;
331
335
 
332
336
  /* Divider */
333
337
  --wje-divider-border-width: var(--wje-border-width, 1px);
@@ -168,4 +168,5 @@ export default class Checkbox extends WJElement {
168
168
  * @function
169
169
  */
170
170
  formDisabledCallback(disabled: boolean): void;
171
+ #private;
171
172
  }
@@ -31,6 +31,8 @@ export default class FileUploadItem extends WJElement {
31
31
  */
32
32
  static get observedAttributes(): Array<string>;
33
33
  localizer: Localizer;
34
+ set isUploaded(value: boolean);
35
+ get isUploaded(): boolean;
34
36
  set size(value: string);
35
37
  get size(): string;
36
38
  /**
@@ -42,6 +42,7 @@ export default class Option extends WJElement {
42
42
  * @param {string} value The value to set.
43
43
  */
44
44
  set value(value: string);
45
+ get value(): string;
45
46
  /**
46
47
  * Sets the text content of the option.
47
48
  * @param {string} value The text to set.
@@ -1,6 +1,14 @@
1
1
  var __defProp = Object.defineProperty;
2
+ var __typeError = (msg) => {
3
+ throw TypeError(msg);
4
+ };
2
5
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
6
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
7
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
8
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
9
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
10
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
11
+ var _internalValue;
4
12
  import WJElement, { event } from "./wje-element.js";
5
13
  const styles = `/*
6
14
  [ Checkbox ]
@@ -269,6 +277,7 @@ class Checkbox extends WJElement {
269
277
  */
270
278
  constructor() {
271
279
  super();
280
+ __privateAdd(this, _internalValue, false);
272
281
  /**
273
282
  * The class name for the Checkbox.
274
283
  */
@@ -281,15 +290,18 @@ class Checkbox extends WJElement {
281
290
  */
282
291
  set value(value) {
283
292
  this.internals.setFormValue(value);
284
- if (this.input) this.input.value = value;
293
+ __privateSet(this, _internalValue, value);
294
+ if (this.input) {
295
+ this.input.value = value;
296
+ this.input.checked = value;
297
+ }
285
298
  }
286
299
  /**
287
300
  * Getter for the value attribute.
288
301
  * @returns {string} The value of the attribute.
289
302
  */
290
303
  get value() {
291
- var _a;
292
- return ((_a = this.input) == null ? void 0 : _a.value) || "";
304
+ return __privateGet(this, _internalValue);
293
305
  }
294
306
  /**
295
307
  * Getter for the customErrorDisplay attribute.
@@ -401,8 +413,13 @@ class Checkbox extends WJElement {
401
413
  * @param {boolean} value true if the toggle is checked, false otherwise
402
414
  */
403
415
  set checked(value) {
404
- if (value) this.setAttribute("checked", "");
405
- else this.removeAttribute("checked");
416
+ if (value) {
417
+ this.setAttribute("checked", "");
418
+ this.value = true;
419
+ } else {
420
+ this.removeAttribute("checked");
421
+ this.value = false;
422
+ }
406
423
  }
407
424
  /**
408
425
  * Get checked attribute.
@@ -529,6 +546,7 @@ class Checkbox extends WJElement {
529
546
  console.warn("formDisabledCallback not implemented yet");
530
547
  }
531
548
  }
549
+ _internalValue = new WeakMap();
532
550
  /**
533
551
  * Whether the input is associated with a form.
534
552
  * @type {boolean}
@@ -1 +1 @@
1
- {"version":3,"file":"wje-checkbox.js","sources":["../packages/wje-checkbox/checkbox.element.js","../packages/wje-checkbox/checkbox.js"],"sourcesContent":["import { default as WJElement, event } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary This method dispatches a custom event named \"wje-checkbox:change\".\n * It is triggered when the input event is fired, which happens when the state of the checkbox changes.\n * The event is dispatched on the current instance of the Checkbox class.\n * @documentation https://elements.webjet.sk/components/checkbox\n * @status stable\n * @augments WJElement\n * @slot - The checkbox main content.\n * @csspart native - The component's native wrapper.\n * @cssproperty [--wje-checkbox-border-radius=--wje-border-radius-medium] - Border radius of the component;\n * @cssproperty [--wje-checkbox-border-width=1px] - Border width of the component;\n * @cssproperty [--wje-checkbox-border-style=solid] - Border style of the component;\n * @cssproperty [--wje-checkbox-border-color=--wje-color-contrast-1] - Border color of the component;\n * @cssproperty [--wje-checkbox-margin-inline=0] - Margin inline of the component;\n * //@fires wje-checkbox:change - Dispatched when the checkbox state changes;\n */\nexport default class Checkbox extends WJElement {\n /**\n * Checkbox constructor method.\n */\n constructor() {\n super();\n this.internals = this.attachInternals();\n }\n\n /**\n * Setter for the value attribute.\n * @param {string} value The value to set.\n */\n set value(value) {\n this.internals.setFormValue(value);\n\n if (this.input) this.input.value = value;\n }\n\n /**\n * Getter for the value attribute.\n * @returns {string} The value of the attribute.\n */\n get value() {\n return this.input?.value || '';\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 * 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 invalid attribute.\n * @returns {boolean} Whether the attribute is present.\n */\n get invalid() {\n return this.hasAttribute('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 * 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 * 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 * Set checked attribute.\n * @param {boolean} value true if the toggle is checked, false otherwise\n */\n set disabled(value) {\n if (value) this.setAttribute('disabled', '');\n else this.removeAttribute('disabled');\n }\n\n /**\n * Get disabled attribute value.\n * @returns {boolean} true if the toggle is disabled, false otherwise\n */\n get disabled() {\n return this.hasAttribute('disabled');\n }\n\n /**\n * Set checked attribute.\n * @param {boolean} value true if the toggle is checked, false otherwise\n */\n set checked(value) {\n if (value) this.setAttribute('checked', '');\n else this.removeAttribute('checked');\n }\n\n /**\n * Get checked attribute.\n * @returns {boolean} true if the toggle is checked, false otherwise\n */\n get checked() {\n return this.hasAttribute('checked');\n }\n\n /**\n * The class name for the Checkbox.\n */\n className = 'Checkbox';\n\n /**\n * Getter for the CSS stylesheet.\n * @returns {string} The CSS stylesheet.\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n static get observedAttributes() {\n return ['checked', 'disabled', 'value', 'indeterminate'];\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 checkbox.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Draws the checkbox element.\n * @returns {DocumentFragment} The created fragment.\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-checkbox');\n\n let input = document.createElement('input');\n input.type = 'checkbox';\n input.id = 'checkbox';\n input.name = this.name || 'checkbox';\n input.checked = this.hasAttribute('checked');\n input.disabled = this.hasAttribute('disabled');\n input.indeterminate = this.hasAttribute('indeterminate');\n\n let label = document.createElement('label');\n label.htmlFor = 'checkbox';\n label.innerHTML = '<slot></slot>';\n\n native.appendChild(input);\n native.appendChild(label);\n\n this.input = input;\n\n fragment.appendChild(native);\n\n return fragment;\n }\n\n /**\n * Adds an event listener after drawing the checkbox.\n */\n afterDraw() {\n if (!this.disabled) {\n this.input.addEventListener('input', (e) => {\n this.value = e.target.checked;\n this.checked = e.target.checked;\n event.dispatchCustomEvent(this, 'wje-toggle:input');\n });\n\n this.input.addEventListener('change', (e) => {\n this.value = e.target.checked;\n this.checked = e.target.checked;\n event.dispatchCustomEvent(this, 'wje-toggle:change');\n });\n }\n }\n\n /**\n * Removes the event listener when the checkbox is disconnected.\n */\n beforeDisconnect() {\n event.removeElement(this.input);\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 }\n}\n","import { default as WJElement } from '../wje-element/element.js';\nimport Checkbox from './checkbox.element.js';\n\n// export * from \"./checkbox.element.js\";\nexport default Checkbox;\n\nWJElement.define('wje-checkbox', Checkbox);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAA;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;AAAA,EAC/D;AACA;AAAA;AAAA;AAAA;AAAA;AAnII,cAxLiB,UAwLV,kBAAiB;ACrM5B,UAAU,OAAO,gBAAgB,QAAQ;"}
1
+ {"version":3,"file":"wje-checkbox.js","sources":["../packages/wje-checkbox/checkbox.element.js","../packages/wje-checkbox/checkbox.js"],"sourcesContent":["import { default as WJElement, event } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary This method dispatches a custom event named \"wje-checkbox:change\".\n * It is triggered when the input event is fired, which happens when the state of the checkbox changes.\n * The event is dispatched on the current instance of the Checkbox class.\n * @documentation https://elements.webjet.sk/components/checkbox\n * @status stable\n * @augments WJElement\n * @slot - The checkbox main content.\n * @csspart native - The component's native wrapper.\n * @cssproperty [--wje-checkbox-border-radius=--wje-border-radius-medium] - Border radius of the component;\n * @cssproperty [--wje-checkbox-border-width=1px] - Border width of the component;\n * @cssproperty [--wje-checkbox-border-style=solid] - Border style of the component;\n * @cssproperty [--wje-checkbox-border-color=--wje-color-contrast-1] - Border color of the component;\n * @cssproperty [--wje-checkbox-margin-inline=0] - Margin inline of the component;\n * //@fires wje-checkbox:change - Dispatched when the checkbox state changes;\n */\nexport default class Checkbox extends WJElement {\n\t#internalValue = false;\n\t/**\n\t * Checkbox constructor method.\n\t */\n\tconstructor() {\n\t\tsuper();\n\t\tthis.internals = this.attachInternals();\n\t}\n\n\t/**\n\t * Setter for the value attribute.\n\t * @param {string} value The value to set.\n\t */\n\tset value(value) {\n\t\tthis.internals.setFormValue(value);\n\t\tthis.#internalValue = value;\n\n\t\tif (this.input) {\n\t\t\tthis.input.value = value;\n\t\t\tthis.input.checked = value;\n\t\t}\n\t}\n\n\t/**\n\t * Getter for the value attribute.\n\t * @returns {string} The value of the attribute.\n\t */\n\tget value() {\n\t\treturn this.#internalValue;\n\t}\n\n\t/**\n\t * Getter for the customErrorDisplay attribute.\n\t * @returns {boolean} Whether the attribute is present.\n\t */\n\tget customErrorDisplay() {\n\t\treturn this.hasAttribute('custom-error-display');\n\t}\n\n\t/**\n\t * Getter for the validateOnChange attribute.\n\t * @returns {boolean} Whether the attribute is present.\n\t */\n\tget validateOnChange() {\n\t\treturn this.hasAttribute('validate-on-change');\n\t}\n\n\t/**\n\t * Setter for the invalid attribute.\n\t * @param {boolean} isInvalid Whether the input is invalid.\n\t */\n\tset invalid(isInvalid) {\n\t\tif (isInvalid) this.setAttribute('invalid', '');\n\t\telse this.removeAttribute('invalid');\n\t}\n\n\t/**\n\t * Getter for the invalid attribute.\n\t * @returns {boolean} Whether the attribute is present.\n\t */\n\tget invalid() {\n\t\treturn this.hasAttribute('invalid');\n\t}\n\n\t/**\n\t * Getter for the form attribute.\n\t * @returns {HTMLFormElement} The form the input is associated with.\n\t */\n\tget form() {\n\t\treturn this.internals.form;\n\t}\n\n\t/**\n\t * Getter for the name attribute.\n\t * @returns {string} The name of the input.\n\t */\n\tget name() {\n\t\treturn this.getAttribute('name');\n\t}\n\n\t/**\n\t * Getter for the type attribute.\n\t * @returns {string} The type of the input.\n\t */\n\tget type() {\n\t\treturn this.localName;\n\t}\n\n\t/**\n\t * Getter for the validity attribute.\n\t * @returns {ValidityState} The validity state of the input.\n\t */\n\tget validity() {\n\t\treturn this.internals.validity;\n\t}\n\n\t/**\n\t * Getter for the validationMessage attribute.\n\t * @returns {string} The validation message of the input.\n\t */\n\tget validationMessage() {\n\t\treturn this.internals.validationMessage;\n\t}\n\n\t/**\n\t * Getter for the willValidate attribute.\n\t * @returns {boolean} Whether the input will be validated.\n\t */\n\tget willValidate() {\n\t\treturn this.internals.willValidate;\n\t}\n\n\t/**\n\t * Getter for the defaultValue attribute.\n\t * This method retrieves the 'value' attribute of the custom input element.\n\t * The 'value' attribute represents the default value of the input element.\n\t * If the 'value' attribute is not set, it returns an empty string.\n\t * @returns {string} The default value of the input element.\n\t */\n\tget defaultValue() {\n\t\treturn this.getAttribute('value') ?? '';\n\t}\n\n\t/**\n\t * Setter for the defaultValue attribute.\n\t * This method sets the 'value' attribute of the custom input element to the provided value.\n\t * The 'value' attribute represents the default value of the input element.\n\t * @param {string} value The value to set as the default value.\n\t */\n\tset defaultValue(value) {\n\t\tthis.setAttribute('value', value);\n\t}\n\n\t/**\n\t * Set checked attribute.\n\t * @param {boolean} value true if the toggle is checked, false otherwise\n\t */\n\tset disabled(value) {\n\t\tif (value) this.setAttribute('disabled', '');\n\t\telse this.removeAttribute('disabled');\n\t}\n\n\t/**\n\t * Get disabled attribute value.\n\t * @returns {boolean} true if the toggle is disabled, false otherwise\n\t */\n\tget disabled() {\n\t\treturn this.hasAttribute('disabled');\n\t}\n\n\t/**\n\t * Set checked attribute.\n\t * @param {boolean} value true if the toggle is checked, false otherwise\n\t */\n\tset checked(value) {\n\t\tif (value) {\n\t\t\tthis.setAttribute('checked', '');\n\t\t\tthis.value = true;\n\t\t}\n\t\telse {\n\t\t\tthis.removeAttribute('checked');\n\t\t\tthis.value = false;\n\t\t}\n\t}\n\n\t/**\n\t * Get checked attribute.\n\t * @returns {boolean} true if the toggle is checked, false otherwise\n\t */\n\tget checked() {\n\t\treturn this.hasAttribute('checked');\n\t}\n\n\t/**\n\t * The class name for the Checkbox.\n\t */\n\tclassName = 'Checkbox';\n\n\t/**\n\t * Getter for the CSS stylesheet.\n\t * @returns {string} The CSS stylesheet.\n\t */\n\tstatic get cssStyleSheet() {\n\t\treturn styles;\n\t}\n\n\tstatic get observedAttributes() {\n\t\treturn ['checked', 'disabled', 'value', 'indeterminate'];\n\t}\n\n\t/**\n\t * Whether the input is associated with a form.\n\t * @type {boolean}\n\t */\n\tstatic formAssociated = true;\n\n\t/**\n\t * Sets up the attributes for the checkbox.\n\t */\n\tsetupAttributes() {\n\t\tthis.isShadowRoot = 'open';\n\t}\n\n\t/**\n\t * Draws the checkbox element.\n\t * @returns {DocumentFragment} The created fragment.\n\t */\n\tdraw() {\n\t\tlet fragment = document.createDocumentFragment();\n\n\t\tlet native = document.createElement('div');\n\t\tnative.setAttribute('part', 'native');\n\t\tnative.classList.add('native-checkbox');\n\n\t\tlet input = document.createElement('input');\n\t\tinput.type = 'checkbox';\n\t\tinput.id = 'checkbox';\n\t\tinput.name = this.name || 'checkbox';\n\t\tinput.checked = this.hasAttribute('checked');\n\t\tinput.disabled = this.hasAttribute('disabled');\n\t\tinput.indeterminate = this.hasAttribute('indeterminate');\n\n\t\tlet label = document.createElement('label');\n\t\tlabel.htmlFor = 'checkbox';\n\t\tlabel.innerHTML = '<slot></slot>';\n\n\t\tnative.appendChild(input);\n\t\tnative.appendChild(label);\n\n\t\tthis.input = input;\n\n\t\tfragment.appendChild(native);\n\n\t\treturn fragment;\n\t}\n\n\t/**\n\t * Adds an event listener after drawing the checkbox.\n\t */\n\tafterDraw() {\n\t\tif (!this.disabled) {\n\t\t\tthis.input.addEventListener('input', (e) => {\n\t\t\t\tthis.value = e.target.checked;\n\t\t\t\tthis.checked = e.target.checked;\n\t\t\t\tevent.dispatchCustomEvent(this, 'wje-toggle:input');\n\t\t\t});\n\n\t\t\tthis.input.addEventListener('change', (e) => {\n\t\t\t\tthis.value = e.target.checked;\n\t\t\t\tthis.checked = e.target.checked;\n\t\t\t\tevent.dispatchCustomEvent(this, 'wje-toggle:change');\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Removes the event listener when the checkbox is disconnected.\n\t */\n\tbeforeDisconnect() {\n\t\tevent.removeElement(this.input);\n\t}\n\n\t/**\n\t * @summary Callback function that is called when the custom element is associated with a form.\n\t * This function adds an event listener to the form's submit event, which validates the input and propagates the validation.\n\t * @param {HTMLFormElement} form The form the custom element is associated with.\n\t */\n\tformAssociatedCallback(form) {\n\t\tif (form) {\n\t\t\tthis.internals.setFormValue(this.value);\n\t\t}\n\t}\n\n\t/**\n\t * The formResetCallback method is a built-in lifecycle callback that gets called when a form gets reset.\n\t * This method is responsible for resetting the value of the custom input element to its default value.\n\t * It also resets the form value and validity state in the form internals.\n\t * @function\n\t */\n\tformResetCallback() {\n\t\t// Set the value of the custom input element to its default value\n\t\tthis.value = this.defaultValue;\n\t\t// Reset the form value in the form internals to the default value\n\t\tthis.internals.setFormValue(this.defaultValue);\n\t\t// Reset the validity state in the form internals\n\t\tthis.internals.setValidity({});\n\t}\n\n\t/**\n\t * The formStateRestoreCallback method is a built-in lifecycle callback that gets called when the state of a form-associated custom element is restored.\n\t * This method is responsible for restoring the value of the custom input element to its saved state.\n\t * It also restores the form value and validity state in the form internals to their saved states.\n\t * @param {object} state The saved state of the custom input element.\n\t * @function\n\t */\n\tformStateRestoreCallback(state) {\n\t\t// Set the value of the custom input element to its saved value\n\t\tthis.value = state.value;\n\t\t// Restore the form value in the form internals to the saved value\n\t\tthis.internals.setFormValue(state.value);\n\t\t// Restore the validity state in the form internals to the saved state\n\t\tthis.internals.setValidity({});\n\t}\n\n\t/**\n\t * The formStateSaveCallback method is a built-in lifecycle callback that gets called when the state of a form-associated custom element is saved.\n\t * This method is responsible for saving the value of the custom input element.\n\t * @returns {object} The saved state of the custom input element.\n\t * @function\n\t */\n\tformStateSaveCallback() {\n\t\treturn {\n\t\t\tvalue: this.value,\n\t\t};\n\t}\n\n\t/**\n\t * The formDisabledCallback method is a built-in lifecycle callback that gets called when the disabled state of a form-associated custom element changes.\n\t * This method is not implemented yet.\n\t * @param {boolean} disabled The new disabled state of the custom input element.\n\t * @function\n\t */\n\tformDisabledCallback(disabled) {\n\t\tconsole.warn('formDisabledCallback not implemented yet');\n\t}\n}\n","import { default as WJElement } from '../wje-element/element.js';\nimport Checkbox from './checkbox.element.js';\n\n// export * from \"./checkbox.element.js\";\nexport default Checkbox;\n\nWJElement.define('wje-checkbox', Checkbox);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBe,MAAM,iBAAiB,UAAU;AAAA;AAAA;AAAA;AAAA,EAK/C,cAAc;AACb,UAAO;AALR,uCAAiB;AAgLjB;AAAA;AAAA;AAAA,qCAAY;AA1KX,SAAK,YAAY,KAAK,gBAAiB;AAAA,EACzC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMC,IAAI,MAAM,OAAO;AAChB,SAAK,UAAU,aAAa,KAAK;AACjC,uBAAK,gBAAiB;AAEtB,QAAI,KAAK,OAAO;AACf,WAAK,MAAM,QAAQ;AACnB,WAAK,MAAM,UAAU;AAAA,IACxB;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMC,IAAI,QAAQ;AACX,WAAO,mBAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA,EAMC,IAAI,qBAAqB;AACxB,WAAO,KAAK,aAAa,sBAAsB;AAAA,EACjD;AAAA;AAAA;AAAA;AAAA;AAAA,EAMC,IAAI,mBAAmB;AACtB,WAAO,KAAK,aAAa,oBAAoB;AAAA,EAC/C;AAAA;AAAA;AAAA;AAAA;AAAA,EAMC,IAAI,QAAQ,WAAW;AACtB,QAAI,UAAW,MAAK,aAAa,WAAW,EAAE;AAAA,QACzC,MAAK,gBAAg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E,OAAO;AACtB,aAAK,UAAU,EAAE,OAAO;AACxB,cAAM,oBAAoB,MAAM,mBAAmB;AAAA,MACvD,CAAI;AAAA,IACJ;AAAA,EACA;AAAA;AAAA;AAAA;AAAA,EAKC,mBAAmB;AAClB,UAAM,cAAc,KAAK,KAAK;AAAA,EAChC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOC,uBAAuB,MAAM;AAC5B,QAAI,MAAM;AACT,WAAK,UAAU,aAAa,KAAK,KAAK;AAAA,IACzC;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQC,oBAAoB;AAEnB,SAAK,QAAQ,KAAK;AAElB,SAAK,UAAU,aAAa,KAAK,YAAY;AAE7C,SAAK,UAAU,YAAY,EAAE;AAAA,EAC/B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASC,yBAAyB,OAAO;AAE/B,SAAK,QAAQ,MAAM;AAEnB,SAAK,UAAU,aAAa,MAAM,KAAK;AAEvC,SAAK,UAAU,YAAY,EAAE;AAAA,EAC/B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQC,wBAAwB;AACvB,WAAO;AAAA,MACN,OAAO,KAAK;AAAA,IACZ;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQC,qBAAqB,UAAU;AAC9B,YAAQ,KAAK,0CAA0C;AAAA,EACzD;AACA;AArUC;AAAA;AAAA;AAAA;AAAA;AAkMA,cAnMoB,UAmMb,kBAAiB;AChNzB,UAAU,OAAO,gBAAgB,QAAQ;"}
@@ -2,7 +2,7 @@ var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
4
  import WJElement, { event } from "./wje-element.js";
5
- const styles = "/*\n[ WJ Dialog ]\n*/\n\n:host {\n --wje-dialog-header-actions-gap: 0.5rem;\n\n .close {\n margin-left: auto;\n }\n\n .header-actions {\n margin-left: auto;\n display: flex;\n align-items: center;\n gap: var(--wje-dialog-header-actions-gap);\n }\n\n .modal-content {\n border-radius: 3px;\n box-shadow: none;\n }\n\n .dialog-header {\n position: relative;\n border-bottom: 0;\n padding-inline: var(--wje-dialog-padding);\n padding-top: var(--wje-dialog-padding);\n padding-bottom: var(--wje-dialog-padding);\n display: flex;\n align-items: center;\n span {\n font-family: var(--wje-font-family-secondary);\n font-size: 10.5px;\n text-transform: uppercase;\n display: inline-block;\n letter-spacing: 0.06em;\n font-weight: 500;\n margin: 0;\n padding: 0;\n line-height: normal;\n overflow: hidden;\n text-overflow: ellipsis;\n filter: alpha(opacity=40);\n }\n }\n\n .dialog-content {\n box-shadow: none;\n padding-inline: var(--wje-dialog-padding);\n white-space: normal;\n z-index: 1;\n }\n\n .dialog-footer {\n display: flex;\n justify-content: end;\n border-top: none;\n box-shadow: none;\n margin-top: 0;\n padding-inline: var(--wje-dialog-padding-inline);\n padding-top: var(--wje-dialog-padding-top);\n padding-bottom: var(--wje-dialog-padding-bottom);\n }\n}\n\n/*Blocking element styles*/\n.blocking-element {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background-color: var(--wje-color-contrast-0);\n opacity: 0.75;\n z-index: 1;\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100%;\n\n wje-icon {\n animation: loader 1s linear infinite;\n }\n}\n\n@keyframes loader {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n}\n\ndialog::backdrop {\n opacity: var(--wje-backdrop-opacity);\n background-color: var(--wje-backdrop);\n}\n\ndialog:focus-visible {\n outline: none;\n}\n\n:host(.separator) .dialog-header:after {\n content: '';\n height: 1px;\n background: rgba(0, 0, 0, 0.08);\n left: var(--wje-dialog-padding);\n right: var(--wje-dialog-padding);\n position: absolute;\n bottom: 0;\n}\n\n:host {\n dialog {\n box-sizing: border-box;\n transition: all 0.2s !important;\n width: var(--wje-dialog-width);\n height: var(--wje-dialog-height);\n box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);\n\n border-radius: var(--wje-dialog-border-radius);\n border-width: var(--wje-dialog-border-width);\n border-style: var(--wje-dialog-border-style);\n border-color: var(--wje-dialog-border-color);\n\n margin-top: var(--wje-dialog-margin-top);\n\n margin-bottom: var(--wje-dialog-margin-bottom);\n margin-inline: var(--wje-dialog-margin-start) var(--wje-dialog-margin-end);\n\n padding: 0;\n }\n}\n\n/*Top*/\n:host(.stick-up) {\n --wje-dialog-width: 300px !important;\n --wje-dialog-height: fit-content;\n --wje-dialog-border-radius: 0 0 8px 8px;\n --wje-dialog-border-width: 0 1px 1px 1px;\n --wje-dialog-margin-top: 0;\n --wje-dialog-translate-from: translateY(-110%);\n --wje-dialog-template-to: translateX(0);\n}\n\n/*Cenetered*/\n:host(.slide-up) {\n --wje-dialog-width: 300px !important;\n --wje-dialog-height: fit-content;\n --wje-dialog-border-radius: 8px;\n --wje-dialog-border-width: 1px;\n --wje-dialog-opacity-from: 0;\n --wje-dialog-translate-from: scale(0.9);\n --wje-dialog-translate-to: scale(1);\n}\n\n/*Fullscreen*/\n:host(.fill-in) {\n --wje-dialog-width: 100%;\n --wje-dialog-height: 100%;\n --wje-dialog-border-radius: 0 0 0 0 !important;\n --wje-dialog-border-width: 0;\n --wje-dialog-margin-top: 0;\n --wje-dialog-margin-start: 0;\n --wje-dialog-margin-end: 0;\n --wje-dialog-margin-bottom: 0;\n --wje-dialog-translate-from: scale(0.95);\n --wje-dialog-translate-to: scale(1);\n dialog {\n min-width: var(--wje-dialog-width);\n min-height: var(--wje-dialog-height);\n }\n}\n\n/*Slide Left*/\n:host(.slide-left) {\n --wje-dialog-width: 300px !important;\n --wje-dialog-height: 100% !important;\n --wje-dialog-border-radius: 0;\n --wje-dialog-border-width: 0 1px 0 0;\n --wje-dialog-margin-top: 0;\n --wje-dialog-margin-start: 0;\n --wje-dialog-margin-end: auto;\n --wje-dialog-margin-bottom: 0;\n dialog {\n min-height: var(--wje-dialog-height);\n --wje-dialog-translate-from: translateX(-110%);\n --wje-dialog-template-to: translateX(0);\n }\n}\n\n/*Slide Right*/\n:host(.slide-right) {\n --wje-dialog-width: 300px !important;\n --wje-dialog-height: 100% !important;\n --wje-dialog-border-radius: 0;\n --wje-dialog-border-width: 0 0 0 1px;\n --wje-dialog-margin-top: 0;\n --wje-dialog-margin-start: auto;\n --wje-dialog-margin-end: 0;\n --wje-dialog-margin-bottom: 0;\n dialog {\n min-height: var(--wje-dialog-height);\n --wje-dialog-translate-from: translateX(110%);\n --wje-dialog-template-to: translateX(0);\n }\n}\n\n:host(.small) {\n --wje-dialog-width: 300px !important;\n}\n\n:host(.medium) {\n --wje-dialog-width: 500px !important;\n}\n\n:host(.large) {\n --wje-dialog-width: 600px !important;\n}\n\n:host(.ex-large) {\n --wje-dialog-width: 900px !important;\n}\n\ndialog[open] {\n animation: show 0.5s ease normal;\n}\n\n@keyframes show {\n from {\n opacity: var(--wje-dialog-opacity-from, 1);\n transform: var(--wje-dialog-translate-from);\n }\n to {\n opacity: 1;\n transform: var(--wje-dialog-translate-to);\n }\n}\n";
5
+ const styles = "/*\n[ WJ Dialog ]\n*/\n\n:host {\n --wje-dialog-header-actions-gap: 0.5rem;\n\n .close {\n margin-left: auto;\n }\n\n .header-actions {\n margin-left: auto;\n display: flex;\n align-items: center;\n gap: var(--wje-dialog-header-actions-gap);\n }\n\n .modal-content {\n border-radius: 3px;\n box-shadow: none;\n }\n\n .dialog-header {\n position: relative;\n border-bottom: 0;\n padding-inline: var(--wje-dialog-padding);\n padding-top: var(--wje-dialog-padding);\n padding-bottom: var(--wje-dialog-padding);\n display: flex;\n align-items: center;\n span {\n font-family: var(--wje-font-family-secondary);\n font-size: var(--wje-dialog-headline-font-size);\n text-transform: var(--wje-dialog-headline-text-transform);\n display: inline-block;\n letter-spacing: var(--wje-dialog-headline-letter-spacing);\n font-weight: var(--wje-dialog-headline-font-weight);\n margin: 0;\n padding: 0;\n line-height: normal;\n overflow: hidden;\n text-overflow: ellipsis;\n filter: alpha(opacity=40);\n }\n }\n\n .dialog-content {\n box-shadow: none;\n padding-inline: var(--wje-dialog-padding);\n white-space: normal;\n z-index: 1;\n }\n\n .dialog-footer {\n display: flex;\n justify-content: end;\n border-top: none;\n box-shadow: none;\n margin-top: 0;\n padding-inline: var(--wje-dialog-padding-inline);\n padding-top: var(--wje-dialog-padding-top);\n padding-bottom: var(--wje-dialog-padding-bottom);\n }\n}\n\n/*Blocking element styles*/\n.blocking-element {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background-color: var(--wje-color-contrast-0);\n opacity: 0.75;\n z-index: 1;\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100%;\n\n wje-icon {\n animation: loader 1s linear infinite;\n }\n}\n\n@keyframes loader {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n}\n\ndialog::backdrop {\n opacity: var(--wje-backdrop-opacity);\n background-color: var(--wje-backdrop);\n}\n\ndialog:focus-visible {\n outline: none;\n}\n\n:host(.separator) .dialog-header:after {\n content: '';\n height: 1px;\n background: rgba(0, 0, 0, 0.08);\n left: var(--wje-dialog-padding);\n right: var(--wje-dialog-padding);\n position: absolute;\n bottom: 0;\n}\n\n:host {\n dialog {\n box-sizing: border-box;\n transition: all 0.2s !important;\n width: var(--wje-dialog-width);\n height: var(--wje-dialog-height);\n box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);\n\n border-radius: var(--wje-dialog-border-radius);\n border-width: var(--wje-dialog-border-width);\n border-style: var(--wje-dialog-border-style);\n border-color: var(--wje-dialog-border-color);\n\n margin-top: var(--wje-dialog-margin-top);\n\n margin-bottom: var(--wje-dialog-margin-bottom);\n margin-inline: var(--wje-dialog-margin-start) var(--wje-dialog-margin-end);\n\n padding: 0;\n }\n}\n\n/*Top*/\n:host(.stick-up) {\n --wje-dialog-width: 300px !important;\n --wje-dialog-height: fit-content;\n --wje-dialog-border-radius: 0 0 8px 8px;\n --wje-dialog-border-width: 0 1px 1px 1px;\n --wje-dialog-margin-top: 0;\n --wje-dialog-translate-from: translateY(-110%);\n --wje-dialog-template-to: translateX(0);\n}\n\n/*Cenetered*/\n:host(.slide-up) {\n --wje-dialog-width: 300px !important;\n --wje-dialog-height: fit-content;\n --wje-dialog-border-radius: 8px;\n --wje-dialog-border-width: 1px;\n --wje-dialog-opacity-from: 0;\n --wje-dialog-translate-from: scale(0.9);\n --wje-dialog-translate-to: scale(1);\n}\n\n/*Fullscreen*/\n:host(.fill-in) {\n --wje-dialog-width: 100%;\n --wje-dialog-height: 100%;\n --wje-dialog-border-radius: 0 0 0 0 !important;\n --wje-dialog-border-width: 0;\n --wje-dialog-margin-top: 0;\n --wje-dialog-margin-start: 0;\n --wje-dialog-margin-end: 0;\n --wje-dialog-margin-bottom: 0;\n --wje-dialog-translate-from: scale(0.95);\n --wje-dialog-translate-to: scale(1);\n dialog {\n min-width: var(--wje-dialog-width);\n min-height: var(--wje-dialog-height);\n }\n}\n\n/*Slide Left*/\n:host(.slide-left) {\n --wje-dialog-width: 300px !important;\n --wje-dialog-height: 100% !important;\n --wje-dialog-border-radius: 0;\n --wje-dialog-border-width: 0 1px 0 0;\n --wje-dialog-margin-top: 0;\n --wje-dialog-margin-start: 0;\n --wje-dialog-margin-end: auto;\n --wje-dialog-margin-bottom: 0;\n dialog {\n min-height: var(--wje-dialog-height);\n --wje-dialog-translate-from: translateX(-110%);\n --wje-dialog-template-to: translateX(0);\n }\n}\n\n/*Slide Right*/\n:host(.slide-right) {\n --wje-dialog-width: 300px !important;\n --wje-dialog-height: 100% !important;\n --wje-dialog-border-radius: 0;\n --wje-dialog-border-width: 0 0 0 1px;\n --wje-dialog-margin-top: 0;\n --wje-dialog-margin-start: auto;\n --wje-dialog-margin-end: 0;\n --wje-dialog-margin-bottom: 0;\n dialog {\n min-height: var(--wje-dialog-height);\n --wje-dialog-translate-from: translateX(110%);\n --wje-dialog-template-to: translateX(0);\n }\n}\n\n:host(.small) {\n --wje-dialog-width: 300px !important;\n}\n\n:host(.medium) {\n --wje-dialog-width: 500px !important;\n}\n\n:host(.large) {\n --wje-dialog-width: 600px !important;\n}\n\n:host(.ex-large) {\n --wje-dialog-width: 900px !important;\n}\n\ndialog[open] {\n animation: show 0.5s ease normal;\n}\n\n@keyframes show {\n from {\n opacity: var(--wje-dialog-opacity-from, 1);\n transform: var(--wje-dialog-translate-from);\n }\n to {\n opacity: 1;\n transform: var(--wje-dialog-translate-to);\n }\n}\n";
6
6
  class Dialog extends WJElement {
7
7
  /**
8
8
  * @class
@@ -154,6 +154,7 @@ class Dropdown extends WJElement {
154
154
  let popup = document.createElement("wje-popup");
155
155
  popup.setAttribute("placement", this.placement);
156
156
  popup.setAttribute("offset", this.offset);
157
+ popup.setAttribute("part", "popup");
157
158
  popup.appendChild(anchorSlot);
158
159
  popup.appendChild(slot);
159
160
  popup.setAttribute("manual", "");
@@ -1 +1 @@
1
- {"version":3,"file":"wje-dropdown.js","sources":["../packages/wje-dropdown/dropdown.element.js","../packages/wje-dropdown/dropdown.js"],"sourcesContent":["import { default as WJElement, event } from '../wje-element/element.js';\nimport Popup from '../wje-popup/popup.element.js';\n\n/**\n * `Dropdown` is a custom element that displays a dropdown menu.\n * @summary This element represents a dropdown menu.\n * @documentation https://elements.webjet.sk/components/dropdown\n * @status stable\n * @augments {WJElement}\n * @csspart native - The native part of the dropdown.\n * @slot trigger - The slot for the trigger of the dropdown.\n * @slot - The default slot for the dropdown.\n * // @fires wje-dropdown:open - Event fired when the dropdown is opened.\n * // @fires wje-dropdown:close - Event fired when the dropdown is closed.\n * @tag wje-dropdown\n */\nexport default class Dropdown extends WJElement {\n /**\n * Creates an instance of Dropdown.\n * @class\n */\n constructor() {\n super();\n }\n\n /**\n * The placement of the dropdown.\n * @type {{\"wje-popup\": Popup}}\n */\n dependencies = {\n 'wje-popup': Popup,\n };\n\n /**\n * Sets the placement of the dropdown.\n * @param value\n */\n set trigger(value) {\n this.setAttribute('trigger', value);\n }\n\n /**\n * Gets the placement of the dropdown.\n * @returns {string|string}\n */\n get trigger() {\n return this.getAttribute('trigger') || 'click';\n }\n\n /**\n * Sets the placement of the dropdown.\n * @type {string}\n */\n className = 'Dropdown';\n\n /**\n * Getter for the CSS stylesheet.\n * @returns {string[]}\n */\n static get observedAttributes() {\n return ['active'];\n }\n\n /**\n * Callback function to handle other dropdowns being opened. Close the dropdown if it is not the target and collapse is enabled.\n * @param {Event} e The event object.\n */\n otherDropdownOpennedCallback = (e) => {\n if (e.detail.detail.target !== this) {\n this.classList.remove('active');\n this.popup.hide();\n }\n };\n\n /**\n * Sets up the attributes for the dropdown.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Removes the popup element.\n */\n beforeDraw() {\n this.popup?.remove();\n this.popup = null;\n }\n\n /**\n * Draws the dropdown element and returns the created document fragment.\n * @returns {DocumentFragment}\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n this.classList.add('wje-placement', 'wje-' + this.placement || 'wje-start');\n\n let native = document.createElement('div');\n native.setAttribute('part', 'native');\n native.classList.add('native-dropdown');\n\n let tooltip = document.createElement('wje-tooltip');\n tooltip.setAttribute('content', this.tooltip);\n\n let anchorSlot = document.createElement('slot');\n anchorSlot.setAttribute('name', 'trigger');\n anchorSlot.setAttribute('slot', 'anchor');\n\n let slot = document.createElement('slot');\n\n let popup = document.createElement('wje-popup');\n popup.setAttribute('placement', this.placement);\n popup.setAttribute('offset', this.offset);\n\n popup.appendChild(anchorSlot);\n popup.appendChild(slot);\n\n // if(this.trigger === \"click\")\n popup.setAttribute('manual', '');\n\n native.appendChild(popup);\n\n fragment.appendChild(native);\n\n this.popup = popup;\n this.anchorSlot = anchorSlot;\n\n return fragment;\n }\n\n /**\n * Adds event listeners for the mouseenter and mouseleave events.\n */\n afterDisconnect() {\n event.removeListener(this, 'mouseenter', null, this.onOpen);\n event.removeListener(this, 'mouseleave', null, this.onClose);\n event.removeListener(this.anchorSlot, 'click', null, this.toggleCallback, { capture: true });\n event.removeListener(this, 'wje-popup:hide', null, this.popupHideCallback);\n }\n\n popupHideCallback = () => {\n if (this.classList.contains('active')) {\n this.classList.remove('active');\n\n event.dispatchCustomEvent(this, 'wje-dropdown:close', {\n bubbles: true,\n detail: { target: this },\n });\n }\n };\n\n /**\n * Adds event listeners for the mouseenter and mouseleave events.\n */\n afterDraw() {\n event.addListener(this, 'wje-popup:hide', null, this.popupHideCallback);\n\n if (this.trigger !== 'click') {\n event.addListener(this, 'mouseenter', null, this.onOpen);\n event.addListener(this, 'mouseleave', null, this.onClose);\n } else {\n event.addListener(this.anchorSlot, 'click', null, this.toggleCallback, { capture: true });\n }\n\n if (this.hasAttribute('collapsible')) {\n event.addListener(\n Array.from(this.querySelectorAll('wje-menu-item')),\n 'click',\n 'wje-menu-item:click',\n this.onClose\n );\n }\n }\n\n /**\n * @summary Returns the content to be displayed before showing the dropdown.\n * @returns {any} The content to be displayed.\n */\n beforeShow() {\n return this.content;\n }\n\n /**\n * This method is called after the dropdown is shown.\n */\n afterShow() {\n // Do nothing\n }\n\n /**\n * @summary Toggles the dropdown element between active and inactive states.\n * Calls the `onOpen` method if the element is currently inactive,\n * and calls the `onClose` method if the element is currently active.\n * @param {Event} e The event object.\n */\n toggleCallback = (e) => {\n e.stopPropagation();\n\n if (this.classList.contains('active')) {\n this.onClose(e);\n } else {\n this.onOpen(e);\n }\n };\n\n /**\n * Open the popup element.\n * @param {object} e\n */\n onOpen = (e) => {\n e.stopPropagation();\n\n this.classList.add('active');\n Promise.resolve(this.beforeShow(this))\n .then((res) => {\n if (!this.classList.contains('active')) {\n throw new Error('beforeShow method returned false or not string');\n }\n\n this.popup.show(true); // Show tooltip\n\n event.dispatchCustomEvent(this, 'wje-dropdown:open', {\n bubbles: true,\n detail: { target: this },\n });\n\n Promise.resolve(this.afterShow(this));\n })\n .catch((error) => {\n // ak je nejaka chyba tak to len zatvorime\n this.classList.remove('active');\n this.popup.hide(true);\n });\n };\n\n beforeClose = () => {\n // Do nothing\n };\n\n afterClose = () => {\n // Do nothing\n };\n\n onClose = (e) => {\n e.stopPropagation();\n\n this.classList.remove('active');\n Promise.resolve(this.beforeClose(this))\n .then((res) => {\n if (this.classList.contains('active')) {\n throw new Error('beforeShow method returned false or not string');\n }\n\n this.popup.hide(true); // Show tooltip\n\n event.dispatchCustomEvent(this, 'wje-dropdown:close', {\n bubbles: true,\n detail: { target: this },\n });\n\n Promise.resolve(this.afterClose(this));\n })\n .catch((error) => {\n this.classList.add('active');\n this.popup.show(true);\n });\n };\n}\n","import Dropdown from './dropdown.element.js';\n\nexport default Dropdown;\n\nDropdown.define('wje-dropdown', Dropdown);\n"],"names":[],"mappings":";;;;;AAgBe,MAAM,iBAAiB,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA,EAK5C,cAAc;AACV,UAAO;AAOX;AAAA;AAAA;AAAA;AAAA,wCAAe;AAAA,MACX,aAAa;AAAA,IAChB;AAsBD;AAAA;AAAA;AAAA;AAAA,qCAAY;AAcZ;AAAA;AAAA;AAAA;AAAA,wDAA+B,CAAC,MAAM;AAClC,UAAI,EAAE,OAAO,OAAO,WAAW,MAAM;AACjC,aAAK,UAAU,OAAO,QAAQ;AAC9B,aAAK,MAAM,KAAM;AAAA,MAC7B;AAAA,IACK;AAqED,6CAAoB,MAAM;AACtB,UAAI,KAAK,UAAU,SAAS,QAAQ,GAAG;AACnC,aAAK,UAAU,OAAO,QAAQ;AAE9B,cAAM,oBAAoB,MAAM,sBAAsB;AAAA,UAClD,SAAS;AAAA,UACT,QAAQ,EAAE,QAAQ,KAAM;AAAA,QACxC,CAAa;AAAA,MACb;AAAA,IACK;AA8CD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0CAAiB,CAAC,MAAM;AACpB,QAAE,gBAAiB;AAEnB,UAAI,KAAK,UAAU,SAAS,QAAQ,GAAG;A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AK,aAAa;AAElB,WAAO;AAAA,EACf;AAAA;AAAA;AAAA;AAAA,EAKI,kBAAkB;AACd,UAAM,eAAe,MAAM,cAAc,MAAM,KAAK,MAAM;AAC1D,UAAM,eAAe,MAAM,cAAc,MAAM,KAAK,OAAO;AAC3D,UAAM,eAAe,KAAK,YAAY,SAAS,MAAM,KAAK,gBAAgB,EAAE,SAAS,KAAI,CAAE;AAC3F,UAAM,eAAe,MAAM,kBAAkB,MAAM,KAAK,iBAAiB;AAAA,EACjF;AAAA;AAAA;AAAA;AAAA,EAgBI,YAAY;AACR,UAAM,YAAY,MAAM,kBAAkB,MAAM,KAAK,iBAAiB;AAEtE,QAAI,KAAK,YAAY,SAAS;AAC1B,YAAM,YAAY,MAAM,cAAc,MAAM,KAAK,MAAM;AACvD,YAAM,YAAY,MAAM,cAAc,MAAM,KAAK,OAAO;AAAA,IACpE,OAAe;AACH,YAAM,YAAY,KAAK,YAAY,SAAS,MAAM,KAAK,gBAAgB,EAAE,SAAS,KAAI,CAAE;AAAA,IACpG;AAEQ,QAAI,KAAK,aAAa,aAAa,GAAG;AAClC,YAAM;AAAA,QACF,MAAM,KAAK,KAAK,iBAAiB,eAAe,CAAC;AAAA,QACjD;AAAA,QACA;AAAA,QACA,KAAK;AAAA,MACR;AAAA,IACb;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,aAAa;AACT,WAAO,KAAK;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA,EAKI,YAAY;AAAA,EAEhB;AAgFA;ACxQA,SAAS,OAAO,gBAAgB,QAAQ;"}
1
+ {"version":3,"file":"wje-dropdown.js","sources":["../packages/wje-dropdown/dropdown.element.js","../packages/wje-dropdown/dropdown.js"],"sourcesContent":["import { default as WJElement, event } from '../wje-element/element.js';\nimport Popup from '../wje-popup/popup.element.js';\n\n/**\n * `Dropdown` is a custom element that displays a dropdown menu.\n * @summary This element represents a dropdown menu.\n * @documentation https://elements.webjet.sk/components/dropdown\n * @status stable\n * @augments {WJElement}\n * @csspart native - The native part of the dropdown.\n * @slot trigger - The slot for the trigger of the dropdown.\n * @slot - The default slot for the dropdown.\n * // @fires wje-dropdown:open - Event fired when the dropdown is opened.\n * // @fires wje-dropdown:close - Event fired when the dropdown is closed.\n * @tag wje-dropdown\n */\nexport default class Dropdown extends WJElement {\n /**\n * Creates an instance of Dropdown.\n * @class\n */\n constructor() {\n super();\n }\n\n /**\n * The placement of the dropdown.\n * @type {{\"wje-popup\": Popup}}\n */\n dependencies = {\n 'wje-popup': Popup,\n };\n\n /**\n * Sets the placement of the dropdown.\n * @param value\n */\n set trigger(value) {\n this.setAttribute('trigger', value);\n }\n\n /**\n * Gets the placement of the dropdown.\n * @returns {string|string}\n */\n get trigger() {\n return this.getAttribute('trigger') || 'click';\n }\n\n /**\n * Sets the placement of the dropdown.\n * @type {string}\n */\n className = 'Dropdown';\n\n /**\n * Getter for the CSS stylesheet.\n * @returns {string[]}\n */\n static get observedAttributes() {\n return ['active'];\n }\n\n /**\n * Callback function to handle other dropdowns being opened. Close the dropdown if it is not the target and collapse is enabled.\n * @param {Event} e The event object.\n */\n otherDropdownOpennedCallback = (e) => {\n if (e.detail.detail.target !== this) {\n this.classList.remove('active');\n this.popup.hide();\n }\n };\n\n /**\n * Sets up the attributes for the dropdown.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Removes the popup element.\n */\n beforeDraw() {\n this.popup?.remove();\n this.popup = null;\n }\n\n /**\n * Draws the dropdown element and returns the created document fragment.\n * @returns {DocumentFragment}\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n this.classList.add('wje-placement', 'wje-' + this.placement || 'wje-start');\n\n let native = document.createElement('div');\n native.setAttribute('part', 'native');\n native.classList.add('native-dropdown');\n\n let tooltip = document.createElement('wje-tooltip');\n tooltip.setAttribute('content', this.tooltip);\n\n let anchorSlot = document.createElement('slot');\n anchorSlot.setAttribute('name', 'trigger');\n anchorSlot.setAttribute('slot', 'anchor');\n\n let slot = document.createElement('slot');\n\n let popup = document.createElement('wje-popup');\n popup.setAttribute('placement', this.placement);\n popup.setAttribute('offset', this.offset);\n popup.setAttribute('part', 'popup');\n\n popup.appendChild(anchorSlot);\n popup.appendChild(slot);\n\n // if(this.trigger === \"click\")\n popup.setAttribute('manual', '');\n\n native.appendChild(popup);\n\n fragment.appendChild(native);\n\n this.popup = popup;\n this.anchorSlot = anchorSlot;\n\n return fragment;\n }\n\n /**\n * Adds event listeners for the mouseenter and mouseleave events.\n */\n afterDisconnect() {\n event.removeListener(this, 'mouseenter', null, this.onOpen);\n event.removeListener(this, 'mouseleave', null, this.onClose);\n event.removeListener(this.anchorSlot, 'click', null, this.toggleCallback, { capture: true });\n event.removeListener(this, 'wje-popup:hide', null, this.popupHideCallback);\n }\n\n popupHideCallback = () => {\n if (this.classList.contains('active')) {\n this.classList.remove('active');\n\n event.dispatchCustomEvent(this, 'wje-dropdown:close', {\n bubbles: true,\n detail: { target: this },\n });\n }\n };\n\n /**\n * Adds event listeners for the mouseenter and mouseleave events.\n */\n afterDraw() {\n event.addListener(this, 'wje-popup:hide', null, this.popupHideCallback);\n\n if (this.trigger !== 'click') {\n event.addListener(this, 'mouseenter', null, this.onOpen);\n event.addListener(this, 'mouseleave', null, this.onClose);\n } else {\n event.addListener(this.anchorSlot, 'click', null, this.toggleCallback, { capture: true });\n }\n\n if (this.hasAttribute('collapsible')) {\n event.addListener(\n Array.from(this.querySelectorAll('wje-menu-item')),\n 'click',\n 'wje-menu-item:click',\n this.onClose\n );\n }\n }\n\n /**\n * @summary Returns the content to be displayed before showing the dropdown.\n * @returns {any} The content to be displayed.\n */\n beforeShow() {\n return this.content;\n }\n\n /**\n * This method is called after the dropdown is shown.\n */\n afterShow() {\n // Do nothing\n }\n\n /**\n * @summary Toggles the dropdown element between active and inactive states.\n * Calls the `onOpen` method if the element is currently inactive,\n * and calls the `onClose` method if the element is currently active.\n * @param {Event} e The event object.\n */\n toggleCallback = (e) => {\n e.stopPropagation();\n\n if (this.classList.contains('active')) {\n this.onClose(e);\n } else {\n this.onOpen(e);\n }\n };\n\n /**\n * Open the popup element.\n * @param {object} e\n */\n onOpen = (e) => {\n e.stopPropagation();\n\n this.classList.add('active');\n Promise.resolve(this.beforeShow(this))\n .then((res) => {\n if (!this.classList.contains('active')) {\n throw new Error('beforeShow method returned false or not string');\n }\n\n this.popup.show(true); // Show tooltip\n\n event.dispatchCustomEvent(this, 'wje-dropdown:open', {\n bubbles: true,\n detail: { target: this },\n });\n\n Promise.resolve(this.afterShow(this));\n })\n .catch((error) => {\n // ak je nejaka chyba tak to len zatvorime\n this.classList.remove('active');\n this.popup.hide(true);\n });\n };\n\n beforeClose = () => {\n // Do nothing\n };\n\n afterClose = () => {\n // Do nothing\n };\n\n onClose = (e) => {\n e.stopPropagation();\n\n this.classList.remove('active');\n Promise.resolve(this.beforeClose(this))\n .then((res) => {\n if (this.classList.contains('active')) {\n throw new Error('beforeShow method returned false or not string');\n }\n\n this.popup.hide(true); // Show tooltip\n\n event.dispatchCustomEvent(this, 'wje-dropdown:close', {\n bubbles: true,\n detail: { target: this },\n });\n\n Promise.resolve(this.afterClose(this));\n })\n .catch((error) => {\n this.classList.add('active');\n this.popup.show(true);\n });\n };\n}\n","import Dropdown from './dropdown.element.js';\n\nexport default Dropdown;\n\nDropdown.define('wje-dropdown', Dropdown);\n"],"names":[],"mappings":";;;;;AAgBe,MAAM,iBAAiB,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA,EAK5C,cAAc;AACV,UAAO;AAOX;AAAA;AAAA;AAAA;AAAA,wCAAe;AAAA,MACX,aAAa;AAAA,IAChB;AAsBD;AAAA;AAAA;AAAA;AAAA,qCAAY;AAcZ;AAAA;AAAA;AAAA;AAAA,wDAA+B,CAAC,MAAM;AAClC,UAAI,EAAE,OAAO,OAAO,WAAW,MAAM;AACjC,aAAK,UAAU,OAAO,QAAQ;AAC9B,aAAK,MAAM,KAAM;AAAA,MAC7B;AAAA,IACK;AAsED,6CAAoB,MAA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AO,KAAK;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA,EAKI,YAAY;AAAA,EAEhB;AAgFA;ACzQA,SAAS,OAAO,gBAAgB,QAAQ;"}
@@ -34,6 +34,12 @@ class FileUploadItem extends WJElement {
34
34
  });
35
35
  this.localizer = new Localizer(this);
36
36
  }
37
+ set isUploaded(value) {
38
+ this.setAttribute("is-uploaded", "");
39
+ }
40
+ get isUploaded() {
41
+ return this.hasAttribute("is-uploaded");
42
+ }
37
43
  set size(value) {
38
44
  this.setAttribute("size", value);
39
45
  }
@@ -108,6 +114,8 @@ class FileUploadItem extends WJElement {
108
114
  let size = document.createElement("wje-format-digital");
109
115
  size.setAttribute("value", this.size || 0);
110
116
  size.innerHTML = `<span slot="start">&nbsp;${this.localizer.translate("wj.file.upload.from")} </span>`;
117
+ let size2 = document.createElement("wje-format-digital");
118
+ size2.setAttribute("value", this.size || 0);
111
119
  let slider = document.createElement("wje-progress-bar");
112
120
  slider.classList.add("file-progress");
113
121
  slider.setAttribute("id", "id-" + this.lastModified);
@@ -119,9 +127,13 @@ class FileUploadItem extends WJElement {
119
127
  sizeWrapper.appendChild(size);
120
128
  native.appendChild(image);
121
129
  native.appendChild(name);
122
- native.appendChild(sizeWrapper);
130
+ if (!this.isUploaded)
131
+ native.appendChild(sizeWrapper);
132
+ else
133
+ native.appendChild(size2);
123
134
  native.appendChild(actions);
124
- native.appendChild(slider);
135
+ if (!this.isUploaded)
136
+ native.appendChild(slider);
125
137
  fragment.appendChild(native);
126
138
  this.button = button;
127
139
  this.uploadedEl = uploaded;
@@ -1 +1 @@
1
- {"version":3,"file":"wje-file-upload-item.js","sources":["../packages/wje-file-upload-item/file-upload-item.element.js","../packages/wje-file-upload-item/file-upload-item.js"],"sourcesContent":["import { Localizer } from '../utils/localize.js';\nimport Button from '../wje-button/button.js';\nimport { default as WJElement } from '../wje-element/element.js';\nimport FormatDigital from '../wje-format-digital/format-digital.js';\nimport Icon from '../wje-icon/icon.js';\nimport Slider from '../wje-slider/slider.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary This element allows users to upload files.\n * `FileUploadItem` is a custom web component that represents a file upload item.\n * It extends from `WJElement` and uses the `Localizer` utility for localization.\n * @documentation https://elements.webjet.sk/components/file-upload\n * @status stable\n * @augments WJElement\n * @csspart button - The delete button part\n * @csspart image - The image part\n * @csspart name - The name part\n * @csspart size - The size part\n * @slot img - Slot for the image\n * @slot action - Slot for the action buttons\n * @cssproperty --primary-color - The primary color of the file upload item.\n * //@fires wje-button:click - Dispatches when the delete button is clicked\n * @tag wje-file-upload\n */\nexport default class FileUploadItem extends WJElement {\n /**\n * Creates an instance of FileUploadItem.\n * @class\n */\n constructor() {\n super();\n this.localizer = new Localizer(this);\n }\n\n set size(value) {\n this.setAttribute('size', value);\n }\n\n get size() {\n return this.getAttribute('size');\n }\n\n /**\n * Dependencies for the component.\n * @type {object}\n */\n dependencies = {\n 'wje-format-digital': FormatDigital,\n 'wje-button': Button,\n 'wje-slider': Slider,\n 'wje-icon': Icon,\n };\n\n className = 'FileUploadItem';\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 ['uploaded'];\n }\n\n /**\n * Handles updates to the attributes of a custom element whenever one of the observed attributes is changed.\n * Updates the related elements based on the changed attribute and its new value.\n * @param {string} name The name of the attribute being changed.\n * @param {string | null} oldValue The previous value of the attribute before the change, or null if the attribute was not previously set.\n * @param {string | null} newValue The new value of the attribute after the change, or null if the attribute is being removed.\n * @returns {void} Does not return a value.\n */\n attributeChangedCallback(name, oldValue, newValue) {\n if (name === 'uploaded' && oldValue !== newValue && this.uploadedEl) {\n this.uploadedEl.setAttribute('value', newValue);\n\n let progress = (+newValue / +this.size) * 100 || 0;\n\n this.sliderEl.setAttribute('progress', Math.round(progress, 0));\n }\n }\n\n /**\n * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Method to draw the component on the screen.\n * @returns {DocumentFragment} The fragment containing the component.\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('div');\n native.classList.add('native-file-upload-item');\n\n let slot = document.createElement('slot');\n slot.setAttribute('name', 'img');\n\n let image = document.createElement('div');\n image.setAttribute('part', 'image');\n image.classList.add('image');\n\n let name = document.createElement('span');\n name.classList.add('name');\n name.innerText = this.name;\n\n let actions = document.createElement('slot');\n actions.classList.add('actions');\n actions.setAttribute('name', 'action');\n\n let button = document.createElement('wje-button');\n button.setAttribute('fill', 'link');\n button.setAttribute('size', 'small');\n button.innerHTML = `<wje-icon name=\"x\" size=\"small\"></wje-icon>`;\n\n let sizeWrapper = document.createElement('span');\n sizeWrapper.classList.add('size');\n\n let uploaded = document.createElement('wje-format-digital');\n uploaded.setAttribute('value', this.uploaded || 0);\n uploaded.innerHTML = `<span slot=\"start\">${this.localizer.translate('wj.file.upload.uploaded')}</span>`;\n\n let size = document.createElement('wje-format-digital');\n size.setAttribute('value', this.size || 0);\n size.innerHTML = `<span slot=\"start\">&nbsp;${this.localizer.translate('wj.file.upload.from')} </span>`;\n\n let slider = document.createElement('wje-progress-bar');\n slider.classList.add('file-progress');\n slider.setAttribute('id', 'id-' + this.lastModified);\n slider.setAttribute('progress', this.progress);\n slider.setAttribute('color', 'success');\n\n image.appendChild(slot);\n actions.appendChild(button);\n\n sizeWrapper.appendChild(uploaded);\n sizeWrapper.appendChild(size);\n\n native.appendChild(image);\n native.appendChild(name);\n native.appendChild(sizeWrapper);\n native.appendChild(actions);\n native.appendChild(slider);\n\n fragment.appendChild(native);\n\n this.button = button;\n this.uploadedEl = uploaded;\n this.sliderEl = slider;\n\n return fragment;\n }\n\n /**\n * Called after the component has been drawn.\n */\n afterDraw() {\n this.button.addEventListener('wje-button:click', this.onDelete);\n }\n\n /**\n * Handles the delete action.\n */\n onDelete = () => {\n this.remove();\n };\n}\n","import FileUploadItem from './file-upload-item.element.js';\n\nexport default FileUploadItem;\n\nFileUploadItem.define('wje-file-upload-item', FileUploadItem);\n"],"names":[],"mappings":";;;;;;;;;;AAyBe,MAAM,uBAAuB,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA,EAKlD,cAAc;AACV,UAAO;AAgBX;AAAA;AAAA;AAAA;AAAA,wCAAe;AAAA,MACX,sBAAsB;AAAA,MACtB,cAAc;AAAA,MACd,cAAc;AAAA,MACd,YAAY;AAAA,IACf;AAED,qCAAY;AA2HZ;AAAA;AAAA;AAAA,oCAAW,MAAM;AACb,WAAK,OAAQ;AAAA,IAChB;AAnJG,SAAK,YAAY,IAAI,UAAU,IAAI;AAAA,EAC3C;AAAA,EAEI,IAAI,KAAK,OAAO;AACZ,SAAK,aAAa,QAAQ,KAAK;AAAA,EACvC;AAAA,EAEI,IAAI,OAAO;AACP,WAAO,KAAK,aAAa,MAAM;AAAA,EACvC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAoBI,WAAW,gBAAgB;AACvB,WAAO;AAAA,EACf;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOI,WAAW,qBAAqB;AAC5B,WAAO,CAAC,UAAU;AAAA,EAC1B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUI,yBAAyB,MAAM,UAAU,UAAU;AAC/C,QAAI,SAAS,cAAc,aAAa,YAAY,KAAK,YAAY;AACjE,WAAK,WAAW,aAAa,SAAS,QAAQ;AAE9C,UAAI,WAAY,CAAC,WAAW,CAAC,KAAK,OAAQ,OAAO;AAEjD,WAAK,SAAS,aAAa,YAAY,KAAK,MAAM,UAAU,CAAC,CAAC;AAAA,IAC1E;AAAA,EACA;AAAA;AAAA;AAAA;AAAA,EAKI,kBAAkB;AACd,SAAK,eAAe;AAAA,EAC5B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,OAAO;AACH,QAAI,WAAW,SAAS,uBAAwB;AAE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AI;AACvB,WAAO,YAAY,WAAW;AAC9B,WAAO,YAAY,OAAO;AAC1B,WAAO,YAAY,MAAM;AAEzB,aAAS,YAAY,MAAM;AAE3B,SAAK,SAAS;AACd,SAAK,aAAa;AAClB,SAAK,WAAW;AAEhB,WAAO;AAAA,EACf;AAAA;AAAA;AAAA;AAAA,EAKI,YAAY;AACR,SAAK,OAAO,iBAAiB,oBAAoB,KAAK,QAAQ;AAAA,EACtE;AAQA;AChLA,eAAe,OAAO,wBAAwB,cAAc;"}
1
+ {"version":3,"file":"wje-file-upload-item.js","sources":["../packages/wje-file-upload-item/file-upload-item.element.js","../packages/wje-file-upload-item/file-upload-item.js"],"sourcesContent":["import { Localizer } from '../utils/localize.js';\nimport Button from '../wje-button/button.js';\nimport { default as WJElement } from '../wje-element/element.js';\nimport FormatDigital from '../wje-format-digital/format-digital.js';\nimport Icon from '../wje-icon/icon.js';\nimport Slider from '../wje-slider/slider.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary This element allows users to upload files.\n * `FileUploadItem` is a custom web component that represents a file upload item.\n * It extends from `WJElement` and uses the `Localizer` utility for localization.\n * @documentation https://elements.webjet.sk/components/file-upload\n * @status stable\n * @augments WJElement\n * @csspart button - The delete button part\n * @csspart image - The image part\n * @csspart name - The name part\n * @csspart size - The size part\n * @slot img - Slot for the image\n * @slot action - Slot for the action buttons\n * @cssproperty --primary-color - The primary color of the file upload item.\n * //@fires wje-button:click - Dispatches when the delete button is clicked\n * @tag wje-file-upload\n */\nexport default class FileUploadItem extends WJElement {\n /**\n * Creates an instance of FileUploadItem.\n * @class\n */\n constructor() {\n super();\n this.localizer = new Localizer(this);\n }\n\n set isUploaded(value) {\n this.setAttribute('is-uploaded', '');\n }\n\n get isUploaded() {\n return this.hasAttribute('is-uploaded');\n }\n\n set size(value) {\n this.setAttribute('size', value);\n }\n\n get size() {\n return this.getAttribute('size');\n }\n\n /**\n * Dependencies for the component.\n * @type {object}\n */\n dependencies = {\n 'wje-format-digital': FormatDigital,\n 'wje-button': Button,\n 'wje-slider': Slider,\n 'wje-icon': Icon,\n };\n\n className = 'FileUploadItem';\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 ['uploaded'];\n }\n\n /**\n * Handles updates to the attributes of a custom element whenever one of the observed attributes is changed.\n * Updates the related elements based on the changed attribute and its new value.\n * @param {string} name The name of the attribute being changed.\n * @param {string | null} oldValue The previous value of the attribute before the change, or null if the attribute was not previously set.\n * @param {string | null} newValue The new value of the attribute after the change, or null if the attribute is being removed.\n * @returns {void} Does not return a value.\n */\n attributeChangedCallback(name, oldValue, newValue) {\n if (name === 'uploaded' && oldValue !== newValue && this.uploadedEl) {\n this.uploadedEl.setAttribute('value', newValue);\n\n let progress = (+newValue / +this.size) * 100 || 0;\n\n this.sliderEl.setAttribute('progress', Math.round(progress, 0));\n }\n }\n\n /**\n * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Method to draw the component on the screen.\n * @returns {DocumentFragment} The fragment containing the component.\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('div');\n native.classList.add('native-file-upload-item');\n\n let slot = document.createElement('slot');\n slot.setAttribute('name', 'img');\n\n let image = document.createElement('div');\n image.setAttribute('part', 'image');\n image.classList.add('image');\n\n let name = document.createElement('span');\n name.classList.add('name');\n name.innerText = this.name;\n\n let actions = document.createElement('slot');\n actions.classList.add('actions');\n actions.setAttribute('name', 'action');\n\n let button = document.createElement('wje-button');\n button.setAttribute('fill', 'link');\n button.setAttribute('size', 'small');\n button.innerHTML = `<wje-icon name=\"x\" size=\"small\"></wje-icon>`;\n\n let sizeWrapper = document.createElement('span');\n sizeWrapper.classList.add('size');\n\n let uploaded = document.createElement('wje-format-digital');\n uploaded.setAttribute('value', this.uploaded || 0);\n uploaded.innerHTML = `<span slot=\"start\">${this.localizer.translate('wj.file.upload.uploaded')}</span>`;\n\n let size = document.createElement('wje-format-digital');\n size.setAttribute('value', this.size || 0);\n size.innerHTML = `<span slot=\"start\">&nbsp;${this.localizer.translate('wj.file.upload.from')} </span>`;\n\n let size2 = document.createElement('wje-format-digital');\n size2.setAttribute('value', this.size || 0);\n\n let slider = document.createElement('wje-progress-bar');\n slider.classList.add('file-progress');\n slider.setAttribute('id', 'id-' + this.lastModified);\n slider.setAttribute('progress', this.progress);\n slider.setAttribute('color', 'success');\n\n image.appendChild(slot);\n actions.appendChild(button);\n\n sizeWrapper.appendChild(uploaded);\n sizeWrapper.appendChild(size);\n\n native.appendChild(image);\n native.appendChild(name);\n\n if (!this.isUploaded)\n native.appendChild(sizeWrapper);\n else\n native.appendChild(size2);\n\n native.appendChild(actions);\n\n if (!this.isUploaded)\n native.appendChild(slider);\n\n fragment.appendChild(native);\n\n this.button = button;\n this.uploadedEl = uploaded;\n this.sliderEl = slider;\n\n return fragment;\n }\n\n /**\n * Called after the component has been drawn.\n */\n afterDraw() {\n this.button.addEventListener('wje-button:click', this.onDelete);\n }\n\n /**\n * Handles the delete action.\n */\n onDelete = () => {\n this.remove();\n };\n}\n","import FileUploadItem from './file-upload-item.element.js';\n\nexport default FileUploadItem;\n\nFileUploadItem.define('wje-file-upload-item', FileUploadItem);\n"],"names":[],"mappings":";;;;;;;;;;AAyBe,MAAM,uBAAuB,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA,EAKlD,cAAc;AACV,UAAO;AAwBX;AAAA;AAAA;AAAA;AAAA,wCAAe;AAAA,MACX,sBAAsB;AAAA,MACtB,cAAc;AAAA,MACd,cAAc;AAAA,MACd,YAAY;AAAA,IACf;AAED,qCAAY;AAqIZ;AAAA;AAAA;AAAA,oCAAW,MAAM;AACb,WAAK,OAAQ;AAAA,IAChB;AArKG,SAAK,YAAY,IAAI,UAAU,IAAI;AAAA,EAC3C;AAAA,EAEI,IA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;AAAA,EACf;AAAA;AAAA;AAAA;AAAA,EAKI,YAAY;AACR,SAAK,OAAO,iBAAiB,oBAAoB,KAAK,QAAQ;AAAA,EACtE;AAQA;AClMA,eAAe,OAAO,wBAAwB,cAAc;"}
@@ -147,7 +147,7 @@ class IconPicker extends WJElement {
147
147
  * @returns {string} The URL of the tags path.
148
148
  */
149
149
  __publicField(this, "getTagsUrl", (path) => {
150
- return new URL(process.env.VITE_ICON_ASSETS_URL + path).href;
150
+ return new URL("http://localhost:5174/dist/assets/img/icons/" + path).href;
151
151
  });
152
152
  }
153
153
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"wje-icon-picker.js","sources":["../packages/wje-icon-picker/icon-picker.element.js","../packages/wje-icon-picker/icon-picker.js"],"sourcesContent":["import { default as WJElement, event } from '../wje-element/element.js';\nimport InfiniteScroll from '../wje-infinite-scroll/infinite-scroll.js';\nimport Input from '../wje-input/input.js';\nimport Popup from '../wje-popup/popup.js';\nimport Tooltip from '../wje-tooltip/tooltip.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary This element allows users to pick an icon from a set of available options.\n * `IconPicker` is a custom web component that represents an interactive icon picker. It features\n * search functionality, infinite scrolling, and popup-based selection. The component is highly customizable\n * and integrates seamlessly with other `WJElement` components.\n * @documentation https://elements.webjet.sk/components/icon-picker\n * @status stable\n * @augments {WJElement}\n * @attribute {string} icon - The selected icon's name.\n * @attribute {number} size - The number of icons displayed per page in infinite scroll. Default is 60.\n * @csspart native - The native part of the component.\n * @csspart anchor - The part representing the anchor button displaying the selected icon.\n * @csspart picker - The picker part containing the search and icon selection interface.\n * @csspart input - The input part for searching icons.\n * @cssproperty [--wje-color-picker-value=#ff0000] - The default color value.\n * @cssproperty [--wje-color-picker-area=transparent] - The background color of the color picker area.\n * @cssproperty [--wje-color-picker-swatch=transparent] - The background color of the swatch picker.\n * @cssproperty [--wje-color-picker-size=1rem] - The size of the icons in the picker.\n * @cssproperty [--wje-color-picker-radius=4px] - The border radius of the picker.\n * @tag wje-icon-picker\n */\n\nexport default class IconPicker extends WJElement {\n /**\n * Creates an instance of IconPicker.\n * @class\n */\n constructor() {\n super();\n }\n\n /**\n * Dependencies of the IconPicker component.\n * @property {object} dependencies\n */\n dependencies = {\n 'wje-input': Input,\n 'wje-infinite-scroll': InfiniteScroll,\n 'wje-tooltip': Tooltip,\n 'wje-popup': Popup,\n };\n\n /**\n * Setter for the markerPosition property.\n * @param {any} value The value to set.\n */\n set size(value) {\n this.setAttribute('size', value);\n }\n\n /**\n * Getter for the markerPosition property.\n * @returns {any} size The value of the markerPosition property.\n */\n get size() {\n return this.getAttribute('size') || 60;\n }\n\n /**\n * Setter for the value property.\n * @param value\n */\n set icon(value) {\n this.setAttribute('icon', value);\n }\n\n /**\n * Getter for the value property.\n * @returns {string}\n */\n get icon() {\n return this.getAttribute('icon');\n }\n\n className = 'IconPicker';\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 [];\n }\n\n /**\n * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Prepares the component before drawing.\n */\n async beforeDraw() {\n this.tags = Object.values(await this.getTags());\n\n this.transformedObjects = this.convertObject(this.tags);\n\n this.index = this.transformedObjects.map((item) => ({\n ...item,\n searchText: `${item.name.toLowerCase()} ${item.tags.join(' ').toLowerCase()}`,\n }));\n }\n\n /**\n * Draws the component.\n * @returns {DocumentFragment}\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('div');\n native.classList.add('native-color-picker');\n\n // ANCHOR\n let anchor = document.createElement('div');\n anchor.setAttribute('slot', 'anchor');\n anchor.classList.add('anchor');\n\n if (this.hasAttribute('icon') && this.icon) {\n let icon = document.createElement('wje-icon');\n icon.setAttribute('name', this.icon);\n\n anchor.appendChild(icon);\n }\n\n // PICKER\n let picker = document.createElement('div');\n picker.classList.add('picker');\n\n let input = document.createElement('wje-input');\n input.classList.add('input');\n input.setAttribute('variant', 'standard');\n input.setAttribute('placeholder', 'type to filter...');\n input.setAttribute('clearable', '');\n input.addEventListener('wje-input:input', this.searchIcon);\n\n let infiniteScroll = new InfiniteScroll();\n\n infiniteScroll.setAttribute('url', this.getTagsUrl('../../tags.json'));\n infiniteScroll.setAttribute('placement', '.icon-items');\n infiniteScroll.setAttribute('size', this.size);\n infiniteScroll.setAttribute('height', '223px');\n infiniteScroll.innerHTML = '<div class=\"icon-items\"></div>';\n\n // APPEND\n picker.appendChild(input);\n\n picker.appendChild(infiniteScroll);\n\n // POPUP\n let popup = document.createElement('wje-popup');\n popup.setAttribute('placement', this.placement || 'bottom-start');\n popup.setAttribute('offset', this.offset);\n popup.setAttribute('manual', '');\n\n popup.appendChild(anchor);\n popup.appendChild(picker);\n\n native.appendChild(popup);\n\n fragment.appendChild(native);\n\n this.popup = popup;\n this.input = input;\n this.anchor = anchor;\n this.picker = picker;\n this.infiniteScroll = infiniteScroll;\n\n this.infiniteScroll.dataToHtml = this.dataToHtml;\n this.infiniteScroll.compareFunction = (i, item) => i.name === item.name;\n this.infiniteScroll.setCustomData = (page = 0) => {\n return {\n data: this.transformedObjects.slice(page * this.size, page * this.size + this.size),\n page: page,\n size: this.size,\n totalPages: Math.round(this.transformedObjects.length / this.size),\n };\n };\n\n return fragment;\n }\n\n /**\n * Called after the component has been drawn.\n */\n afterDraw() {\n this.addEventListener('wje-popup:show', () => {\n this.initial();\n });\n\n // udalost po vymazani inputu\n this.addEventListener('wje-input:clear', () => {\n this.clearIconsContainer(); // clear icons container\n this.infiniteScroll.scrollEvent(); // bind scroll event\n this.infiniteScroll.loadPages(0); // load first page\n });\n\n this.addEventListener('wje-infinite-scroll:click-item', (e) => {\n let icon = e.detail.context.querySelector('wje-icon');\n let name = icon.getAttribute('name');\n let stylesType = icon.hasAttribute('filled') ? 'filled' : 'outline';\n let uniqueObject = this.transformedObjects.find(\n (i) => i.name === name && Object.keys(i.styles)[0] === stylesType\n );\n\n const iconElement = document.createElement('wje-icon');\n iconElement.setAttribute('name', name);\n if (uniqueObject.styles.hasOwnProperty('filled')) iconElement.setAttribute('filled', '');\n\n uniqueObject.icon = iconElement;\n\n this.value = uniqueObject;\n this.icon = uniqueObject.name;\n\n this.anchor.innerHTML = '';\n this.anchor.appendChild(iconElement);\n\n event.dispatchCustomEvent(this, 'wje-icon-picker:select', uniqueObject); // odpalenie custom eventu\n });\n\n this.init = false;\n }\n\n /**\n * Initializes the component.\n */\n initial() {\n this.infiniteScroll.scrollEvent();\n }\n\n /**\n * Converts an object of tags into a transformed array of objects, separating `filled` and `outline` styles.\n * The function processes an input object containing tags, extracts its values,\n * and for each tag that has both `filled` and `outline` styles, splits them into\n * two separate objects. Tags without `filled` styles remain unchanged.\n * @param {object} tags The input object containing tags as properties. Each property is an object with a `styles` key.\n * @param {object} tags[].styles The styles object containing `filled` and/or `outline` styles.\n * @param {object} [tags[].styles.outline] The outline style object, if present.\n * @param {object} [tags[].styles.filled] The filled style object, if present.\n * @returns {Array<object>} An array of transformed objects. Objects with both `filled` and `outline` styles are split into separate objects, each containing only one style.\n * @example\n * const tags = {\n * hourglass: {\n * styles: {\n * outline: { ... },\n * filled: { ... },\n * }\n * },\n * clock: {\n * styles: {\n * outline: { ... },\n * }\n * }\n * };\n * const result = convertObject(tags);\n * console.log(result);\n * // [\n * // { styles: { outline: { ... } } },\n * // { styles: { filled: { ... } } },\n * // { styles: { outline: { ... } } }\n * // ]\n */\n convertObject = (tags = {}) => {\n let originalObjects = Object.values(tags);\n let transformedObjects = [];\n for (let i = 0; i < originalObjects.length; i++) {\n const obj = originalObjects[i];\n if (obj.styles.filled) {\n transformedObjects.push(\n { ...obj, styles: { outline: obj.styles.outline } },\n { ...obj, styles: { filled: obj.styles.filled } }\n );\n } else {\n transformedObjects.push(obj);\n }\n }\n\n return transformedObjects;\n };\n\n /**\n * Converts an icon data object into an HTML element structure.\n * This function creates a styled HTML element that represents an icon with a tooltip.\n * The tooltip displays the name of the icon, and the icon itself is styled based on\n * whether it uses the `filled` style.\n * @param {object} data The icon data object.\n * @returns {HTMLElement} A `div` element containing the icon wrapped in a `wje-tooltip`. The tooltip displays the icon name, and the `wje-icon` element represents the icon with attributes set according to the data.\n * @example\n * const iconData = {\n * name: \"hourglass\",\n * styles: {\n * filled: { ... }\n * }\n * };\n * const htmlElement = dataToHtml(iconData);\n * document.body.appendChild(htmlElement);\n *\n * // The resulting structure:\n * // <div class=\"icon-item\">\n * // <wje-tooltip content=\"hourglass\">\n * // <wje-icon name=\"hourglass\" size=\"large\" filled></wje-icon>\n * // </wje-tooltip>\n * // </div>\n */\n dataToHtml = (data) => {\n let iconItem = document.createElement('div');\n iconItem.classList.add('icon-item');\n\n let tooltip = document.createElement('wje-tooltip');\n tooltip.setAttribute('content', data.name);\n\n let icon = document.createElement('wje-icon');\n icon.setAttribute('name', data.name);\n icon.setAttribute('size', 'large');\n if (data.styles.hasOwnProperty('filled')) icon.setAttribute('filled', '');\n\n tooltip.appendChild(icon);\n iconItem.appendChild(tooltip);\n\n return iconItem;\n };\n\n /**\n * Gets the category of the tags.\n * @param {Array} tags The tags to get the category of.\n * @returns {Array} The category of the tags.\n */\n getCategory(tags) {\n return [...new Set(tags.map((obj) => obj.category))];\n }\n\n /**\n * Gets the tags.\n * @returns {Promise<Array>} The tags of the component.\n */\n async getTags() {\n const response = await fetch(this.getTagsUrl('../../tags.json'));\n return response.json();\n }\n\n /**\n * Called when the component is disconnected.\n */\n beforeDisconnect() {\n this.init = false;\n }\n\n /**\n * Searches icons based on user input.\n * This method handles the input event and filters the available icons based on the provided search string.\n * The filtering is performed on an index that combines icon names and their tags.\n * The results are then adjusted for infinite scrolling.\n * @param {Event} e The input event (e.g., `wje-input:input`) containing the search query details.\n */\n searchIcon = (e) => {\n const query = e.detail.value.toLowerCase();\n\n const results = this.index.filter((item) => item.searchText.includes(query));\n\n this.infiniteScroll.unScrollEvent();\n this.infiniteScroll.setCustomData = (page = 0) => {\n const data = results.slice(page * this.size, page * this.size + this.size);\n return {\n data: data,\n page: page,\n size: this.size,\n totalPages: Math.ceil(results.length / this.size),\n };\n };\n\n this.clearIconsContainer();\n this.infiniteScroll.loadPages(0);\n };\n\n /**\n * Clears the icons container.\n */\n clearIconsContainer() {\n this.context.querySelector('.icon-items').innerHTML = '';\n }\n\n /**\n * Closes the component.\n */\n onClose = () => {\n this.popup.handleHide();\n };\n\n /**\n * Gets the URL of the tags.\n * @param {string} path The path to get the URL of.\n * @returns {string} The URL of the tags path.\n */\n getTagsUrl = (path) => {\n return new URL(process.env.VITE_ICON_ASSETS_URL + path).href;\n };\n}\n","import IconPicker from './icon-picker.element.js';\n\nexport default IconPicker;\n\nIconPicker.define('wje-icon-picker', IconPicker);\n"],"names":[],"mappings":";;;;;;;;;;;AA6Be,MAAM,mBAAmB,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA,EAK9C,cAAc;AACV,UAAO;AAOX;AAAA;AAAA;AAAA;AAAA,wCAAe;AAAA,MACX,aAAa;AAAA,MACb,uBAAuB;AAAA,MACvB,eAAe;AAAA,MACf,aAAa;AAAA,IAChB;AAkCD,qCAAY;AAwMZ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yCAAgB,CAAC,OAAO,OAAO;AAC3B,UAAI,kBAAkB,OAAO,OAAO,IAAI;AACxC,UAAI,qBAAqB,CAAE;AAC3B,eAAS,IAAI,GAAG,IAAI,gBAAgB,QAAQ,KAAK;AAC7C,cAAM,MAAM,gBAAgB,CAAC;AAC7B,YAAI,IAAI,OAAO,QAAQ;AACnB,6BAAmB;AAAA,YACf,EAAE,GAAG,KAAK,QA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,YAAM,oBAAoB,MAAM,0BAA0B,YAAY;AAAA,IAClF,CAAS;AAED,SAAK,OAAO;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA,EAKI,UAAU;AACN,SAAK,eAAe,YAAa;AAAA,EACzC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAmGI,YAAY,MAAM;AACd,WAAO,CAAC,GAAG,IAAI,IAAI,KAAK,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,CAAC;AAAA,EAC3D;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,MAAM,UAAU;AACZ,UAAM,WAAW,MAAM,MAAM,KAAK,WAAW,iBAAiB,CAAC;AAC/D,WAAO,SAAS,KAAM;AAAA,EAC9B;AAAA;AAAA;AAAA;AAAA,EAKI,mBAAmB;AACf,SAAK,OAAO;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA,EAgCI,sBAAsB;AAClB,SAAK,QAAQ,cAAc,aAAa,EAAE,YAAY;AAAA,EAC9D;AAiBA;AC3ZA,WAAW,OAAO,mBAAmB,UAAU;"}
1
+ {"version":3,"file":"wje-icon-picker.js","sources":["../packages/wje-icon-picker/icon-picker.element.js","../packages/wje-icon-picker/icon-picker.js"],"sourcesContent":["import { default as WJElement, event } from '../wje-element/element.js';\nimport InfiniteScroll from '../wje-infinite-scroll/infinite-scroll.js';\nimport Input from '../wje-input/input.js';\nimport Popup from '../wje-popup/popup.js';\nimport Tooltip from '../wje-tooltip/tooltip.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary This element allows users to pick an icon from a set of available options.\n * `IconPicker` is a custom web component that represents an interactive icon picker. It features\n * search functionality, infinite scrolling, and popup-based selection. The component is highly customizable\n * and integrates seamlessly with other `WJElement` components.\n * @documentation https://elements.webjet.sk/components/icon-picker\n * @status stable\n * @augments {WJElement}\n * @attribute {string} icon - The selected icon's name.\n * @attribute {number} size - The number of icons displayed per page in infinite scroll. Default is 60.\n * @csspart native - The native part of the component.\n * @csspart anchor - The part representing the anchor button displaying the selected icon.\n * @csspart picker - The picker part containing the search and icon selection interface.\n * @csspart input - The input part for searching icons.\n * @cssproperty [--wje-color-picker-value=#ff0000] - The default color value.\n * @cssproperty [--wje-color-picker-area=transparent] - The background color of the color picker area.\n * @cssproperty [--wje-color-picker-swatch=transparent] - The background color of the swatch picker.\n * @cssproperty [--wje-color-picker-size=1rem] - The size of the icons in the picker.\n * @cssproperty [--wje-color-picker-radius=4px] - The border radius of the picker.\n * @tag wje-icon-picker\n */\n\nexport default class IconPicker extends WJElement {\n /**\n * Creates an instance of IconPicker.\n * @class\n */\n constructor() {\n super();\n }\n\n /**\n * Dependencies of the IconPicker component.\n * @property {object} dependencies\n */\n dependencies = {\n 'wje-input': Input,\n 'wje-infinite-scroll': InfiniteScroll,\n 'wje-tooltip': Tooltip,\n 'wje-popup': Popup,\n };\n\n /**\n * Setter for the markerPosition property.\n * @param {any} value The value to set.\n */\n set size(value) {\n this.setAttribute('size', value);\n }\n\n /**\n * Getter for the markerPosition property.\n * @returns {any} size The value of the markerPosition property.\n */\n get size() {\n return this.getAttribute('size') || 60;\n }\n\n /**\n * Setter for the value property.\n * @param value\n */\n set icon(value) {\n this.setAttribute('icon', value);\n }\n\n /**\n * Getter for the value property.\n * @returns {string}\n */\n get icon() {\n return this.getAttribute('icon');\n }\n\n className = 'IconPicker';\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 [];\n }\n\n /**\n * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Prepares the component before drawing.\n */\n async beforeDraw() {\n this.tags = Object.values(await this.getTags());\n\n this.transformedObjects = this.convertObject(this.tags);\n\n this.index = this.transformedObjects.map((item) => ({\n ...item,\n searchText: `${item.name.toLowerCase()} ${item.tags.join(' ').toLowerCase()}`,\n }));\n }\n\n /**\n * Draws the component.\n * @returns {DocumentFragment}\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('div');\n native.classList.add('native-color-picker');\n\n // ANCHOR\n let anchor = document.createElement('div');\n anchor.setAttribute('slot', 'anchor');\n anchor.classList.add('anchor');\n\n if (this.hasAttribute('icon') && this.icon) {\n let icon = document.createElement('wje-icon');\n icon.setAttribute('name', this.icon);\n\n anchor.appendChild(icon);\n }\n\n // PICKER\n let picker = document.createElement('div');\n picker.classList.add('picker');\n\n let input = document.createElement('wje-input');\n input.classList.add('input');\n input.setAttribute('variant', 'standard');\n input.setAttribute('placeholder', 'type to filter...');\n input.setAttribute('clearable', '');\n input.addEventListener('wje-input:input', this.searchIcon);\n\n let infiniteScroll = new InfiniteScroll();\n\n infiniteScroll.setAttribute('url', this.getTagsUrl('../../tags.json'));\n infiniteScroll.setAttribute('placement', '.icon-items');\n infiniteScroll.setAttribute('size', this.size);\n infiniteScroll.setAttribute('height', '223px');\n infiniteScroll.innerHTML = '<div class=\"icon-items\"></div>';\n\n // APPEND\n picker.appendChild(input);\n\n picker.appendChild(infiniteScroll);\n\n // POPUP\n let popup = document.createElement('wje-popup');\n popup.setAttribute('placement', this.placement || 'bottom-start');\n popup.setAttribute('offset', this.offset);\n popup.setAttribute('manual', '');\n\n popup.appendChild(anchor);\n popup.appendChild(picker);\n\n native.appendChild(popup);\n\n fragment.appendChild(native);\n\n this.popup = popup;\n this.input = input;\n this.anchor = anchor;\n this.picker = picker;\n this.infiniteScroll = infiniteScroll;\n\n this.infiniteScroll.dataToHtml = this.dataToHtml;\n this.infiniteScroll.compareFunction = (i, item) => i.name === item.name;\n this.infiniteScroll.setCustomData = (page = 0) => {\n return {\n data: this.transformedObjects.slice(page * this.size, page * this.size + this.size),\n page: page,\n size: this.size,\n totalPages: Math.round(this.transformedObjects.length / this.size),\n };\n };\n\n return fragment;\n }\n\n /**\n * Called after the component has been drawn.\n */\n afterDraw() {\n this.addEventListener('wje-popup:show', () => {\n this.initial();\n });\n\n // udalost po vymazani inputu\n this.addEventListener('wje-input:clear', () => {\n this.clearIconsContainer(); // clear icons container\n this.infiniteScroll.scrollEvent(); // bind scroll event\n this.infiniteScroll.loadPages(0); // load first page\n });\n\n this.addEventListener('wje-infinite-scroll:click-item', (e) => {\n let icon = e.detail.context.querySelector('wje-icon');\n let name = icon.getAttribute('name');\n let stylesType = icon.hasAttribute('filled') ? 'filled' : 'outline';\n let uniqueObject = this.transformedObjects.find(\n (i) => i.name === name && Object.keys(i.styles)[0] === stylesType\n );\n\n const iconElement = document.createElement('wje-icon');\n iconElement.setAttribute('name', name);\n if (uniqueObject.styles.hasOwnProperty('filled')) iconElement.setAttribute('filled', '');\n\n uniqueObject.icon = iconElement;\n\n this.value = uniqueObject;\n this.icon = uniqueObject.name;\n\n this.anchor.innerHTML = '';\n this.anchor.appendChild(iconElement);\n\n event.dispatchCustomEvent(this, 'wje-icon-picker:select', uniqueObject); // odpalenie custom eventu\n });\n\n this.init = false;\n }\n\n /**\n * Initializes the component.\n */\n initial() {\n this.infiniteScroll.scrollEvent();\n }\n\n /**\n * Converts an object of tags into a transformed array of objects, separating `filled` and `outline` styles.\n * The function processes an input object containing tags, extracts its values,\n * and for each tag that has both `filled` and `outline` styles, splits them into\n * two separate objects. Tags without `filled` styles remain unchanged.\n * @param {object} tags The input object containing tags as properties. Each property is an object with a `styles` key.\n * @param {object} tags[].styles The styles object containing `filled` and/or `outline` styles.\n * @param {object} [tags[].styles.outline] The outline style object, if present.\n * @param {object} [tags[].styles.filled] The filled style object, if present.\n * @returns {Array<object>} An array of transformed objects. Objects with both `filled` and `outline` styles are split into separate objects, each containing only one style.\n * @example\n * const tags = {\n * hourglass: {\n * styles: {\n * outline: { ... },\n * filled: { ... },\n * }\n * },\n * clock: {\n * styles: {\n * outline: { ... },\n * }\n * }\n * };\n * const result = convertObject(tags);\n * console.log(result);\n * // [\n * // { styles: { outline: { ... } } },\n * // { styles: { filled: { ... } } },\n * // { styles: { outline: { ... } } }\n * // ]\n */\n convertObject = (tags = {}) => {\n let originalObjects = Object.values(tags);\n let transformedObjects = [];\n for (let i = 0; i < originalObjects.length; i++) {\n const obj = originalObjects[i];\n if (obj.styles.filled) {\n transformedObjects.push(\n { ...obj, styles: { outline: obj.styles.outline } },\n { ...obj, styles: { filled: obj.styles.filled } }\n );\n } else {\n transformedObjects.push(obj);\n }\n }\n\n return transformedObjects;\n };\n\n /**\n * Converts an icon data object into an HTML element structure.\n * This function creates a styled HTML element that represents an icon with a tooltip.\n * The tooltip displays the name of the icon, and the icon itself is styled based on\n * whether it uses the `filled` style.\n * @param {object} data The icon data object.\n * @returns {HTMLElement} A `div` element containing the icon wrapped in a `wje-tooltip`. The tooltip displays the icon name, and the `wje-icon` element represents the icon with attributes set according to the data.\n * @example\n * const iconData = {\n * name: \"hourglass\",\n * styles: {\n * filled: { ... }\n * }\n * };\n * const htmlElement = dataToHtml(iconData);\n * document.body.appendChild(htmlElement);\n *\n * // The resulting structure:\n * // <div class=\"icon-item\">\n * // <wje-tooltip content=\"hourglass\">\n * // <wje-icon name=\"hourglass\" size=\"large\" filled></wje-icon>\n * // </wje-tooltip>\n * // </div>\n */\n dataToHtml = (data) => {\n let iconItem = document.createElement('div');\n iconItem.classList.add('icon-item');\n\n let tooltip = document.createElement('wje-tooltip');\n tooltip.setAttribute('content', data.name);\n\n let icon = document.createElement('wje-icon');\n icon.setAttribute('name', data.name);\n icon.setAttribute('size', 'large');\n if (data.styles.hasOwnProperty('filled')) icon.setAttribute('filled', '');\n\n tooltip.appendChild(icon);\n iconItem.appendChild(tooltip);\n\n return iconItem;\n };\n\n /**\n * Gets the category of the tags.\n * @param {Array} tags The tags to get the category of.\n * @returns {Array} The category of the tags.\n */\n getCategory(tags) {\n return [...new Set(tags.map((obj) => obj.category))];\n }\n\n /**\n * Gets the tags.\n * @returns {Promise<Array>} The tags of the component.\n */\n async getTags() {\n const response = await fetch(this.getTagsUrl('../../tags.json'));\n return response.json();\n }\n\n /**\n * Called when the component is disconnected.\n */\n beforeDisconnect() {\n this.init = false;\n }\n\n /**\n * Searches icons based on user input.\n * This method handles the input event and filters the available icons based on the provided search string.\n * The filtering is performed on an index that combines icon names and their tags.\n * The results are then adjusted for infinite scrolling.\n * @param {Event} e The input event (e.g., `wje-input:input`) containing the search query details.\n */\n searchIcon = (e) => {\n const query = e.detail.value.toLowerCase();\n\n const results = this.index.filter((item) => item.searchText.includes(query));\n\n this.infiniteScroll.unScrollEvent();\n this.infiniteScroll.setCustomData = (page = 0) => {\n const data = results.slice(page * this.size, page * this.size + this.size);\n return {\n data: data,\n page: page,\n size: this.size,\n totalPages: Math.ceil(results.length / this.size),\n };\n };\n\n this.clearIconsContainer();\n this.infiniteScroll.loadPages(0);\n };\n\n /**\n * Clears the icons container.\n */\n clearIconsContainer() {\n this.context.querySelector('.icon-items').innerHTML = '';\n }\n\n /**\n * Closes the component.\n */\n onClose = () => {\n this.popup.handleHide();\n };\n\n /**\n * Gets the URL of the tags.\n * @param {string} path The path to get the URL of.\n * @returns {string} The URL of the tags path.\n */\n getTagsUrl = (path) => {\n return new URL(process.env.VITE_ICON_ASSETS_URL + path).href;\n };\n}\n","import IconPicker from './icon-picker.element.js';\n\nexport default IconPicker;\n\nIconPicker.define('wje-icon-picker', IconPicker);\n"],"names":[],"mappings":";;;;;;;;;;;AA6BA,MAAqB,mBAAmB,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA,EAK9C,cAAc;AACJ,UAAA;AAOV;AAAA;AAAA;AAAA;AAAA,wCAAe;AAAA,MACX,aAAa;AAAA,MACb,uBAAuB;AAAA,MACvB,eAAe;AAAA,MACf,aAAa;AAAA,IACjB;AAkCA,qCAAY;AAwMZ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A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AC3D;AAEM,YAAA,cAAc,SAAS,cAAc,UAAU;AACzC,kBAAA,aAAa,QAAQ,IAAI;AACjC,UAAA,aAAa,OAAO,eAAe,QAAQ,EAAe,aAAA,aAAa,UAAU,EAAE;AAEvF,mBAAa,OAAO;AAEpB,WAAK,QAAQ;AACb,WAAK,OAAO,aAAa;AAEzB,WAAK,OAAO,YAAY;AACnB,WAAA,OAAO,YAAY,WAAW;AAE7B,YAAA,oBAAoB,MAAM,0BAA0B,YAAY;AAAA,IAAA,CACzE;AAED,SAAK,OAAO;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA,EAMhB,UAAU;AACN,SAAK,eAAe,YAAY;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAoGpC,YAAY,MAAM;AACP,WAAA,CAAC,GAAG,IAAI,IAAI,KAAK,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,CAAC;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOvD,MAAM,UAAU;AACZ,UAAM,WAAW,MAAM,MAAM,KAAK,WAAW,iBAAiB,CAAC;AAC/D,WAAO,SAAS,KAAK;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA,EAMzB,mBAAmB;AACf,SAAK,OAAO;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA,EAiChB,sBAAsB;AAClB,SAAK,QAAQ,cAAc,aAAa,EAAE,YAAY;AAAA,EAAA;AAkB9D;AC3ZA,WAAW,OAAO,mBAAmB,UAAU;"}
package/dist/wje-icon.js CHANGED
@@ -107,7 +107,7 @@ const getName = (iconName) => {
107
107
  };
108
108
  const getNamedUrl = (iconName, filled = false) => {
109
109
  const path = `${filled ? "filled" : "outline"}/${iconName}.svg`;
110
- let url = new URL(process.env.VITE_ICON_ASSETS_URL + path);
110
+ let url = new URL("http://localhost:5174/dist/assets/img/icons/" + path);
111
111
  return url.href;
112
112
  };
113
113
  const styles = "/*\n[ WJ Icon ]\n*/\n\n:host {\n width: var(--wje-icon-size);\n height: var(--wje-icon-size);\n display: block;\n}\n\n.native-icon {\n display: flex;\n align-items: center;\n}\n\nsvg {\n width: 100%;\n height: 100%;\n stroke-width: var(--wje-icon-stroke);\n color: var(--wje-icon-color);\n}\n\n/*STROKE*/\n:host([stroke='1']) {\n --wje-icon-stroke: 1;\n}\n\n:host([stroke='1.25']) {\n --wje-icon-stroke: 1.25;\n}\n\n:host([stroke='1.5']) {\n --wje-icon-stroke: 1.5;\n}\n\n:host([stroke='1.75']) {\n --wje-icon-stroke: 1.75;\n}\n\n:host([stroke='2']) {\n --wje-icon-stroke: 2;\n}\n\n/*SIZE*/\n:host([size='2x-small']) {\n --wje-icon-size: var(--wje-size-2x-small);\n}\n\n:host([size='x-small']) {\n --wje-icon-size: var(--wje-size-x-small);\n}\n\n:host([size='small']) {\n --wje-icon-size: var(--wje-size-small);\n}\n\n:host([size='medium']) {\n --wje-icon-size: var(--wje-size-medium);\n}\n\n:host([size='large']) {\n --wje-icon-size: var(--wje-size-large);\n}\n\n:host([size='x-large']) {\n --wje-icon-size: var(--wje-size-x-large);\n}\n\n:host([size='2x-large']) {\n --wje-icon-size: var(--wje-size-2x-large);\n}\n\n:host([size='3x-large']) {\n --wje-icon-size: var(--wje-size-3x-large);\n}\n\n:host([size='4x-large']) {\n --wje-icon-size: var(--wje-size-4x-large);\n}\n\n/*COLOR*/\n:host([color='primary']) .native-icon {\n color: var(--wje-color-primary-9);\n}\n\n:host([color='complete']) .native-icon {\n color: var(--wje-color-complete-9);\n}\n\n:host([color='success']) .native-icon {\n color: var(--wje-color-success-9);\n}\n\n:host([color='warning']) .native-icon {\n color: var(--wje-color-warning-9);\n}\n\n:host([color='danger']) .native-icon {\n color: var(--wje-color-danger-9);\n}\n\n:host([color='info']) .native-icon {\n color: var(--wje-color-info-9);\n}\n\n:host([color='menu']) .native-icon {\n color: var(--wje-color-contrast-9);\n}\n";
@@ -1 +1 @@
1
- {"version":3,"file":"wje-icon.js","sources":["../packages/wje-icon/service/service.js","../packages/wje-icon/icon.element.js","../packages/wje-icon/icon.js"],"sourcesContent":["export const iconContent = new Map();\nconst requests = new Map();\n\nlet parser;\n\n/**\n * Validates and returns a trimmed source string if it meets the required criteria.\n * @param {string} src The source string to validate and trim.\n * @returns {string|null} The validated and trimmed source string, or `null` if invalid.\n * @example\n * getSrc(' https://example.com/image.jpg '); // Returns 'https://example.com/image.jpg'\n * getSrc('invalid-src'); // Returns null\n */\nexport const getSrc = (src) => {\n if (isStr(src)) {\n src = src.trim();\n if (isSrc(src)) {\n return src;\n }\n }\n return null;\n};\n\n/**\n * Checks if a given string is a valid source based on specific criteria.\n * @param {string} str The string to validate as a source.\n * @returns {boolean} `true` if the string is considered a valid source, `false` otherwise.\n * @example\n * isSrc('https://example.com/image.jpg'); // Returns true\n * isSrc('image.jpg'); // Returns true\n * isSrc('invalid-src'); // Returns false\n */\nexport const isSrc = (str) => str.length > 0 && /(\\/|\\.)/.test(str);\n\n/**\n * Checks if the provided URL is an SVG data URL.\n * @param {string} url The URL to check.\n * @returns {boolean} - Returns `true` if the URL starts with 'data:image/svg+xml', otherwise `false`.\n * @example\n * isSvgDataUrl('data:image/svg+xml;base64,...'); // Returns true\n * isSvgDataUrl('https://example.com/image.svg'); // Returns false\n */\nexport const isSvgDataUrl = (url) => url.startsWith('data:image/svg+xml');\n\n/**\n * Checks if the provided URL is an encoded data URL.\n * @param {string} url The URL to check.\n * @returns {boolean} - Returns `true` if the URL contains ';utf8,', otherwise `false`.\n * @example\n * isEncodedDataUrl('data:text/plain;charset=utf8,...'); // Returns true\n * isEncodedDataUrl('https://example.com/file.txt'); // Returns false\n */\nexport const isEncodedDataUrl = (url) => url.indexOf(';utf8,') !== -1;\n\n/**\n * Checks if the provided value is of string type.\n * @param {*} val The value to check.\n * @returns {boolean} - Returns `true` if the value is a string, otherwise `false`.\n * @example\n * isStr('Hello, World!'); // Returns true\n * isStr(12345); // Returns false\n */\nexport const isStr = (val) => typeof val === 'string';\n\n/**\n * Validates the provided SVG content and ensures it contains a valid SVG element.\n * @param {string} svgContent The SVG content to validate.\n * @returns {string} Returns the validated SVG content as a string if valid, otherwise an empty string.\n * @example\n * const validSvg = '&lt;svg class=\"icon\" xmlns=\"http://www.w3.org/2000/svg\">&lt;/svg>';\n * validateContent(validSvg); // Returns '&lt;svg class=\"icon\" xmlns=\"http://www.w3.org/2000/svg\">&lt;/svg>'\n * const invalidSvg = '&lt;div>&lt;/div>';\n * validateContent(invalidSvg); // Returns ''\n */\nexport const validateContent = (svgContent) => {\n const div = document.createElement('div');\n div.innerHTML = svgContent;\n\n const svgElm = div.firstElementChild;\n if (svgElm && svgElm.nodeName.toLowerCase() === 'svg') {\n const svgClass = svgElm.getAttribute('class') || '';\n\n if (isValid(svgElm)) {\n return div.innerHTML;\n }\n }\n return '';\n};\n\n/**\n * Validates an element to ensure it does not contain potentially unsafe content.\n * @param {Element|Node} elm The element or node to validate.\n * @returns {boolean} - Returns `true` if the element is valid, otherwise `false`.\n * @description\n * This function checks the following:\n * 1. The element is an element node (nodeType 1).\n * 2. The element is not a `&lt;script>` tag.\n * 3. The element does not contain any `on*` event handler attributes (e.g., `onclick`).\n * 4. All child nodes recursively pass the same validation.\n * @example\n * const validElement = document.createElement('div');\n * isValid(validElement); // Returns true\n *\n * const scriptElement = document.createElement('script');\n * isValid(scriptElement); // Returns false\n *\n * const divWithOnClick = document.createElement('div');\n * divWithOnClick.setAttribute('onclick', 'alert(\"hi\")');\n * isValid(divWithOnClick); // Returns false\n */\nexport const isValid = (elm) => {\n // Only element nodes\n if (elm.nodeType === 1) {\n // Check for script elements\n if (elm.nodeName.toLowerCase() === 'script') {\n return false;\n }\n\n // Check for on* attributes\n for (let i = 0; i < elm.attributes.length; i++) {\n const name = elm.attributes[i].name;\n if (isStr(name) && name.toLowerCase().indexOf('on') === 0) {\n return false;\n }\n }\n\n // Check for child nodes\n for (let i = 0; i < elm.childNodes.length; i++) {\n if (!isValid(elm.childNodes[i])) {\n return false;\n }\n }\n }\n return true;\n};\n\n/**\n * Fetches and optionally sanitizes SVG content from a given URL.\n * @param {string} url The URL of the SVG resource or data URL.\n * @param {boolean} [sanitize] Whether to sanitize the SVG content. Defaults to `true`.\n * @returns {Promise<void>} A promise that resolves when the SVG content is fetched and stored.\n * @description\n * This function performs the following:\n * - If the URL is an SVG data URL and encoded, it parses the content to extract the SVG.\n * - If the URL is a standard HTTP/HTTPS URL, it fetches the content.\n * - Optionally sanitizes the fetched SVG content.\n * - Caches the content for future use.\n * @example\n * getSvgContent('https://example.com/icon.svg').then(() => {\n * console.log('SVG content fetched and stored.');\n * });\n * @example\n * getSvgContent('data:image/svg+xml;base64,...', false).then(() => {\n * console.log('SVG data URL processed without sanitization.');\n * });\n */\nexport const getSvgContent = (url, sanitize) => {\n let req = requests.get(url);\n if (!req) {\n if (typeof fetch !== 'undefined' && typeof document !== 'undefined') {\n if (isSvgDataUrl(url) && isEncodedDataUrl(url)) {\n if (!parser) {\n parser = new DOMParser();\n }\n const doc = parser.parseFromString(url, 'text/html');\n const svg = doc.querySelector('svg');\n if (svg) {\n iconContent.set(url, svg.outerHTML);\n }\n return Promise.resolve();\n } else {\n req = fetch(url).then((rsp) => {\n if (rsp.ok) {\n return rsp.text().then((svgContent) => {\n if (svgContent && sanitize !== false) {\n svgContent = validateContent(svgContent);\n }\n iconContent.set(url, svgContent || '');\n });\n }\n return iconContent.set(url, '');\n });\n requests.set(url, req);\n }\n } else {\n iconContent.set(url, '');\n return Promise.resolve();\n }\n }\n return req;\n};\n\n/**\n * Retrieves the URL for an icon based on its `src` or `name` attributes.\n * @param {HTMLElement} i The icon element from which to extract the URL.\n * @returns {string|null} The URL of the icon if found, or `null` if no valid URL can be determined.\n * @description\n * This function performs the following:\n * 1. Attempts to retrieve the URL from the `src` attribute using `getSrc`.\n * 2. If no `src` is provided, it falls back to the `name` attribute using `getName`.\n * 3. If a name is found, it uses `getNamedUrl` to construct the URL, considering the `filled` attribute.\n * @example\n * const iconElement = document.querySelector('wje-icon');\n * const url = getUrl(iconElement);\n * console.log(url); // Outputs the resolved URL or `null`.\n */\nexport const getUrl = (i) => {\n let url = getSrc(i.src);\n if (url) {\n return url;\n }\n\n url = getName(i.name);\n\n if (url) {\n return getNamedUrl(url, i.hasAttribute('filled'));\n }\n\n return null;\n};\n\n/**\n * Validates and returns a sanitized icon name.\n * @param {string} iconName The icon name to validate.\n * @returns {string|null} The sanitized icon name, or `null` if the input is invalid.\n * @description\n * This function checks if the provided `iconName` is a valid string:\n * - It must not be empty or contain invalid characters.\n * - Only alphanumeric characters, hyphens, and digits are allowed.\n * @example\n * const validName = getName('user-icon');\n * console.log(validName); // 'user-icon'\n * const invalidName = getName('user@icon!');\n * console.log(invalidName); // null\n */\nexport const getName = (iconName) => {\n if (!isStr(iconName) || iconName.trim() === '') {\n return null;\n }\n\n const invalidChars = iconName.replace(/[a-z]|-|\\d/gi, '');\n if (invalidChars !== '') {\n return null;\n }\n\n return iconName;\n};\n\n/**\n * Constructs the URL for a named SVG icon.\n * @param {string} iconName The name of the icon to retrieve.\n * @param {boolean} [filled] Whether to use the \"filled\" variant of the icon. Defaults to \"outline\" if `false`.\n * @returns {string} - The complete URL to the SVG icon.\n * @description\n * This function generates a URL for an icon based on its name and style (filled or outline).\n * It uses the base URL from the environment variable `VITE_ICON_ASSETS_URL`.\n * @example\n * const url = getNamedUrl('user-icon', true);\n * console.log(url); // 'https://example.com/filled/user-icon.svg'\n *\n * const outlineUrl = getNamedUrl('settings');\n * console.log(outlineUrl); // 'https://example.com/outline/settings.svg'\n */\nconst getNamedUrl = (iconName, filled = false) => {\n const path = `${filled ? 'filled' : 'outline'}/${iconName}.svg`;\n\n let url = new URL(process.env.VITE_ICON_ASSETS_URL + path);\n\n return url.href;\n};\n","import { default as WJElement } from '../wje-element/element.js';\nimport { getSvgContent, getUrl, iconContent } from './service/service.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary This element represents an icon. `IconElement` is a custom web component that represents an icon.\n * @documentation https://elements.webjet.sk/components/icon\n * @status stable\n * @augments WJElement\n * @csspart svg - The SVG part of the icon\n * @cssproperty [--wje-icon-size=1rem] - The size of the icon element\n * @cssproperty [--wje-icon-width=var(--wje-icon-size, 100%)] - The width of the icon element\n * @cssproperty [--wje-icon-height=var(--wje-icon-size, 100%)] - The height of the icon element\n * @tag wje-icon\n */\nexport default class Icon extends WJElement {\n /**\n * Creates an instance of IconElement.\n * @class\n */\n constructor() {\n super();\n }\n\n /**\n * Sets the name of the icon.\n * @type {string}\n */\n className = 'Icon';\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 ['name', 'filled'];\n }\n\n /**\n * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\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 this.classList.add('lazy-loaded-image', 'lazy');\n\n let native = document.createElement('div');\n native.setAttribute('part', 'native');\n native.classList.add('native-icon');\n\n this.url = getUrl(this);\n\n fragment.appendChild(native);\n\n this.native = native;\n\n return fragment;\n }\n\n /**\n * Called after the component has been drawn.\n */\n afterDraw() {\n let lazyImageObserver = new IntersectionObserver((entries, observer) => {\n entries.forEach((entry) => {\n if (entry.isIntersecting) {\n getSvgContent(this.url).then((svgContent) => {\n this.native.innerHTML = iconContent?.get(this.url);\n this.native.querySelector('svg')?.setAttribute('part', 'svg');\n });\n\n this.classList.remove('lazy');\n lazyImageObserver.unobserve(entry.target);\n }\n });\n });\n\n lazyImageObserver.observe(this.native);\n }\n}\n","import Icon from './icon.element.js';\n\nexport default Icon;\n\nIcon.define('wje-icon', Icon);\n"],"names":[],"mappings":";;;;AAAO,MAAM,cAAc,oBAAI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ACtB,wBAAc,KAAK,GAAG,EAAE,KAAK,CAAC,eAAe;;AACzC,iBAAK,OAAO,YAAY,2CAAa,IAAI,KAAK;AAC9C,uBAAK,OAAO,cAAc,KAAK,MAA/B,mBAAkC,aAAa,QAAQ;AAAA,UAC/E,CAAqB;AAED,eAAK,UAAU,OAAO,MAAM;AAC5B,4BAAkB,UAAU,MAAM,MAAM;AAAA,QAC5D;AAAA,MACA,CAAa;AAAA,IACb,CAAS;AAED,sBAAkB,QAAQ,KAAK,MAAM;AAAA,EAC7C;AACA;AChGA,KAAK,OAAO,YAAY,IAAI;"}
1
+ {"version":3,"file":"wje-icon.js","sources":["../packages/wje-icon/service/service.js","../packages/wje-icon/icon.element.js","../packages/wje-icon/icon.js"],"sourcesContent":["export const iconContent = new Map();\nconst requests = new Map();\n\nlet parser;\n\n/**\n * Validates and returns a trimmed source string if it meets the required criteria.\n * @param {string} src The source string to validate and trim.\n * @returns {string|null} The validated and trimmed source string, or `null` if invalid.\n * @example\n * getSrc(' https://example.com/image.jpg '); // Returns 'https://example.com/image.jpg'\n * getSrc('invalid-src'); // Returns null\n */\nexport const getSrc = (src) => {\n if (isStr(src)) {\n src = src.trim();\n if (isSrc(src)) {\n return src;\n }\n }\n return null;\n};\n\n/**\n * Checks if a given string is a valid source based on specific criteria.\n * @param {string} str The string to validate as a source.\n * @returns {boolean} `true` if the string is considered a valid source, `false` otherwise.\n * @example\n * isSrc('https://example.com/image.jpg'); // Returns true\n * isSrc('image.jpg'); // Returns true\n * isSrc('invalid-src'); // Returns false\n */\nexport const isSrc = (str) => str.length > 0 && /(\\/|\\.)/.test(str);\n\n/**\n * Checks if the provided URL is an SVG data URL.\n * @param {string} url The URL to check.\n * @returns {boolean} - Returns `true` if the URL starts with 'data:image/svg+xml', otherwise `false`.\n * @example\n * isSvgDataUrl('data:image/svg+xml;base64,...'); // Returns true\n * isSvgDataUrl('https://example.com/image.svg'); // Returns false\n */\nexport const isSvgDataUrl = (url) => url.startsWith('data:image/svg+xml');\n\n/**\n * Checks if the provided URL is an encoded data URL.\n * @param {string} url The URL to check.\n * @returns {boolean} - Returns `true` if the URL contains ';utf8,', otherwise `false`.\n * @example\n * isEncodedDataUrl('data:text/plain;charset=utf8,...'); // Returns true\n * isEncodedDataUrl('https://example.com/file.txt'); // Returns false\n */\nexport const isEncodedDataUrl = (url) => url.indexOf(';utf8,') !== -1;\n\n/**\n * Checks if the provided value is of string type.\n * @param {*} val The value to check.\n * @returns {boolean} - Returns `true` if the value is a string, otherwise `false`.\n * @example\n * isStr('Hello, World!'); // Returns true\n * isStr(12345); // Returns false\n */\nexport const isStr = (val) => typeof val === 'string';\n\n/**\n * Validates the provided SVG content and ensures it contains a valid SVG element.\n * @param {string} svgContent The SVG content to validate.\n * @returns {string} Returns the validated SVG content as a string if valid, otherwise an empty string.\n * @example\n * const validSvg = '&lt;svg class=\"icon\" xmlns=\"http://www.w3.org/2000/svg\">&lt;/svg>';\n * validateContent(validSvg); // Returns '&lt;svg class=\"icon\" xmlns=\"http://www.w3.org/2000/svg\">&lt;/svg>'\n * const invalidSvg = '&lt;div>&lt;/div>';\n * validateContent(invalidSvg); // Returns ''\n */\nexport const validateContent = (svgContent) => {\n const div = document.createElement('div');\n div.innerHTML = svgContent;\n\n const svgElm = div.firstElementChild;\n if (svgElm && svgElm.nodeName.toLowerCase() === 'svg') {\n const svgClass = svgElm.getAttribute('class') || '';\n\n if (isValid(svgElm)) {\n return div.innerHTML;\n }\n }\n return '';\n};\n\n/**\n * Validates an element to ensure it does not contain potentially unsafe content.\n * @param {Element|Node} elm The element or node to validate.\n * @returns {boolean} - Returns `true` if the element is valid, otherwise `false`.\n * @description\n * This function checks the following:\n * 1. The element is an element node (nodeType 1).\n * 2. The element is not a `&lt;script>` tag.\n * 3. The element does not contain any `on*` event handler attributes (e.g., `onclick`).\n * 4. All child nodes recursively pass the same validation.\n * @example\n * const validElement = document.createElement('div');\n * isValid(validElement); // Returns true\n *\n * const scriptElement = document.createElement('script');\n * isValid(scriptElement); // Returns false\n *\n * const divWithOnClick = document.createElement('div');\n * divWithOnClick.setAttribute('onclick', 'alert(\"hi\")');\n * isValid(divWithOnClick); // Returns false\n */\nexport const isValid = (elm) => {\n // Only element nodes\n if (elm.nodeType === 1) {\n // Check for script elements\n if (elm.nodeName.toLowerCase() === 'script') {\n return false;\n }\n\n // Check for on* attributes\n for (let i = 0; i < elm.attributes.length; i++) {\n const name = elm.attributes[i].name;\n if (isStr(name) && name.toLowerCase().indexOf('on') === 0) {\n return false;\n }\n }\n\n // Check for child nodes\n for (let i = 0; i < elm.childNodes.length; i++) {\n if (!isValid(elm.childNodes[i])) {\n return false;\n }\n }\n }\n return true;\n};\n\n/**\n * Fetches and optionally sanitizes SVG content from a given URL.\n * @param {string} url The URL of the SVG resource or data URL.\n * @param {boolean} [sanitize] Whether to sanitize the SVG content. Defaults to `true`.\n * @returns {Promise<void>} A promise that resolves when the SVG content is fetched and stored.\n * @description\n * This function performs the following:\n * - If the URL is an SVG data URL and encoded, it parses the content to extract the SVG.\n * - If the URL is a standard HTTP/HTTPS URL, it fetches the content.\n * - Optionally sanitizes the fetched SVG content.\n * - Caches the content for future use.\n * @example\n * getSvgContent('https://example.com/icon.svg').then(() => {\n * console.log('SVG content fetched and stored.');\n * });\n * @example\n * getSvgContent('data:image/svg+xml;base64,...', false).then(() => {\n * console.log('SVG data URL processed without sanitization.');\n * });\n */\nexport const getSvgContent = (url, sanitize) => {\n let req = requests.get(url);\n if (!req) {\n if (typeof fetch !== 'undefined' && typeof document !== 'undefined') {\n if (isSvgDataUrl(url) && isEncodedDataUrl(url)) {\n if (!parser) {\n parser = new DOMParser();\n }\n const doc = parser.parseFromString(url, 'text/html');\n const svg = doc.querySelector('svg');\n if (svg) {\n iconContent.set(url, svg.outerHTML);\n }\n return Promise.resolve();\n } else {\n req = fetch(url).then((rsp) => {\n if (rsp.ok) {\n return rsp.text().then((svgContent) => {\n if (svgContent && sanitize !== false) {\n svgContent = validateContent(svgContent);\n }\n iconContent.set(url, svgContent || '');\n });\n }\n return iconContent.set(url, '');\n });\n requests.set(url, req);\n }\n } else {\n iconContent.set(url, '');\n return Promise.resolve();\n }\n }\n return req;\n};\n\n/**\n * Retrieves the URL for an icon based on its `src` or `name` attributes.\n * @param {HTMLElement} i The icon element from which to extract the URL.\n * @returns {string|null} The URL of the icon if found, or `null` if no valid URL can be determined.\n * @description\n * This function performs the following:\n * 1. Attempts to retrieve the URL from the `src` attribute using `getSrc`.\n * 2. If no `src` is provided, it falls back to the `name` attribute using `getName`.\n * 3. If a name is found, it uses `getNamedUrl` to construct the URL, considering the `filled` attribute.\n * @example\n * const iconElement = document.querySelector('wje-icon');\n * const url = getUrl(iconElement);\n * console.log(url); // Outputs the resolved URL or `null`.\n */\nexport const getUrl = (i) => {\n let url = getSrc(i.src);\n if (url) {\n return url;\n }\n\n url = getName(i.name);\n\n if (url) {\n return getNamedUrl(url, i.hasAttribute('filled'));\n }\n\n return null;\n};\n\n/**\n * Validates and returns a sanitized icon name.\n * @param {string} iconName The icon name to validate.\n * @returns {string|null} The sanitized icon name, or `null` if the input is invalid.\n * @description\n * This function checks if the provided `iconName` is a valid string:\n * - It must not be empty or contain invalid characters.\n * - Only alphanumeric characters, hyphens, and digits are allowed.\n * @example\n * const validName = getName('user-icon');\n * console.log(validName); // 'user-icon'\n * const invalidName = getName('user@icon!');\n * console.log(invalidName); // null\n */\nexport const getName = (iconName) => {\n if (!isStr(iconName) || iconName.trim() === '') {\n return null;\n }\n\n const invalidChars = iconName.replace(/[a-z]|-|\\d/gi, '');\n if (invalidChars !== '') {\n return null;\n }\n\n return iconName;\n};\n\n/**\n * Constructs the URL for a named SVG icon.\n * @param {string} iconName The name of the icon to retrieve.\n * @param {boolean} [filled] Whether to use the \"filled\" variant of the icon. Defaults to \"outline\" if `false`.\n * @returns {string} - The complete URL to the SVG icon.\n * @description\n * This function generates a URL for an icon based on its name and style (filled or outline).\n * It uses the base URL from the environment variable `VITE_ICON_ASSETS_URL`.\n * @example\n * const url = getNamedUrl('user-icon', true);\n * console.log(url); // 'https://example.com/filled/user-icon.svg'\n *\n * const outlineUrl = getNamedUrl('settings');\n * console.log(outlineUrl); // 'https://example.com/outline/settings.svg'\n */\nconst getNamedUrl = (iconName, filled = false) => {\n const path = `${filled ? 'filled' : 'outline'}/${iconName}.svg`;\n\n let url = new URL(process.env.VITE_ICON_ASSETS_URL + path);\n\n return url.href;\n};\n","import { default as WJElement } from '../wje-element/element.js';\nimport { getSvgContent, getUrl, iconContent } from './service/service.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary This element represents an icon. `IconElement` is a custom web component that represents an icon.\n * @documentation https://elements.webjet.sk/components/icon\n * @status stable\n * @augments WJElement\n * @csspart svg - The SVG part of the icon\n * @cssproperty [--wje-icon-size=1rem] - The size of the icon element\n * @cssproperty [--wje-icon-width=var(--wje-icon-size, 100%)] - The width of the icon element\n * @cssproperty [--wje-icon-height=var(--wje-icon-size, 100%)] - The height of the icon element\n * @tag wje-icon\n */\nexport default class Icon extends WJElement {\n /**\n * Creates an instance of IconElement.\n * @class\n */\n constructor() {\n super();\n }\n\n /**\n * Sets the name of the icon.\n * @type {string}\n */\n className = 'Icon';\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 ['name', 'filled'];\n }\n\n /**\n * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\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 this.classList.add('lazy-loaded-image', 'lazy');\n\n let native = document.createElement('div');\n native.setAttribute('part', 'native');\n native.classList.add('native-icon');\n\n this.url = getUrl(this);\n\n fragment.appendChild(native);\n\n this.native = native;\n\n return fragment;\n }\n\n /**\n * Called after the component has been drawn.\n */\n afterDraw() {\n let lazyImageObserver = new IntersectionObserver((entries, observer) => {\n entries.forEach((entry) => {\n if (entry.isIntersecting) {\n getSvgContent(this.url).then((svgContent) => {\n this.native.innerHTML = iconContent?.get(this.url);\n this.native.querySelector('svg')?.setAttribute('part', 'svg');\n });\n\n this.classList.remove('lazy');\n lazyImageObserver.unobserve(entry.target);\n }\n });\n });\n\n lazyImageObserver.observe(this.native);\n }\n}\n","import Icon from './icon.element.js';\n\nexport default Icon;\n\nIcon.define('wje-icon', Icon);\n"],"names":[],"mappings":";;;;AAAa,MAAA,kCAAkB,IAAI;AACnC,MAAM,+BAAe,IAAI;AAEzB,IAAI;AAUS,MAAA,SAAS,CAAC,QAAQ;AACvB,MAAA,MAAM,GAAG,GAAG;AACZ,UAAM,IAAI,KAAK;AACX,QAAA,MAAM,GAAG,GAAG;AACL,aAAA;AAAA,IAAA;AAAA,EACX;AAEG,SAAA;AACX;AAWa,MAAA,QAAQ,CAAC,QAAQ,IAAI,SAAS,KAAK,UAAU,KAAK,GAAG;AAU3D,MAAM,eAAe,CAAC,QAAQ,IAAI,WAAW,oBAAoB;AAUjE,MAAM,mBAAmB,CAAC,QAAQ,IAAI,QAAQ,QAAQ,MAAM;AAU5D,MAAM,QAAQ,CAAC,QAAQ,OAAO,QAAQ;AAYhC,MAAA,kBAAkB,CAAC,eAAe;AACrC,QAAA,MAAM,SAAS,cAAc,KAAK;AACxC,MAAI,YAAY;AAEhB,QAAM,SAAS,IAAI;AACnB,MAAI,UAAU,OAAO,SAAS,YAAA,MAAkB,OAAO;AAClC,WAAO,aAAa,OAAO,KAAK;AAE7C,QAAA,QAAQ,MAAM,GAAG;AACjB,aAAO,IAAI;AAAA,IAAA;AAAA,EACf;AAEG,SAAA;AACX;AAuBa,MAAA,UAAU,CAAC,QAAQ;AAExB,MAAA,IAAI,aAAa,GAAG;AAEpB,QAAI,IAAI,SAAS,YAAY,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