wj-elements 0.1.145 → 0.1.147

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.
@@ -24,6 +24,12 @@ export default class Avatar extends WJElement {
24
24
  * @returns {string} styles
25
25
  */
26
26
  static get cssStyleSheet(): string;
27
+ /**
28
+ * Returns the list of attributes to observe for changes.
29
+ * @static
30
+ * @returns {Array<string>}
31
+ */
32
+ static get observedAttributes(): string[];
27
33
  /**
28
34
  * Sets the value of the 'label' attribute for the element.
29
35
  * @param {string} value The new value to be set for the 'label' attribute.
@@ -189,8 +189,8 @@ export default class WJElement extends HTMLElement {
189
189
  */
190
190
  refreshUpdatePromise(): void;
191
191
  updateComplete: Promise<any>;
192
- finisPromise: ((value: any) => void) | ((resolve: any) => void);
193
- rejectPromise: ((reason?: any) => void) | ((reject: any) => void);
192
+ finisPromise: (value: any) => void;
193
+ rejectPromise: (reason?: any) => void;
194
194
  /**
195
195
  * Lifecycle method invoked when the component is connected to the DOM.
196
196
  */
@@ -229,6 +229,7 @@ export default class WJElement extends HTMLElement {
229
229
  * Lifecycle method invoked when the component is disconnected from the DOM.
230
230
  */
231
231
  disconnectedCallback(): void;
232
+ processCurrentRenderPromise(): Promise<void>;
232
233
  /**
233
234
  * Enqueues an update to the component.
234
235
  * @returns A promise that resolves when the update is complete.
@@ -241,6 +242,7 @@ export default class WJElement extends HTMLElement {
241
242
  * @param newName The new value of the attribute.
242
243
  */
243
244
  attributeChangedCallback(name: any, old: any, newName: any): void;
245
+ refresh(): void;
244
246
  /**
245
247
  * Refreshes the component by reinitializing it if it is in a drawing state.
246
248
  * This method checks if the component's drawing status is at least in the START state.
@@ -253,7 +255,7 @@ export default class WJElement extends HTMLElement {
253
255
  * If the component is not in a drawing state, it simply returns a resolved promise.
254
256
  * @returns {Promise<void>} A promise that resolves when the refresh is complete.
255
257
  */
256
- refresh(): Promise<void>;
258
+ _refresh(): Promise<void>;
257
259
  /**
258
260
  * Displays the component's content, optionally forcing a re-render.
259
261
  * @param [force] Whether to force a re-render.
@@ -30,6 +30,26 @@ export default class Img extends WJElement {
30
30
  delete: () => void;
31
31
  log: () => void;
32
32
  };
33
+ /**
34
+ * Sets the value of the `src` attribute for the element.
35
+ * @param {string} value The value to set for the `src` attribute.
36
+ */
37
+ set src(value: string);
38
+ /**
39
+ * Retrieves the value of the 'src' attribute from the element.
40
+ * @returns {string} The value of the 'src' attribute.
41
+ */
42
+ get src(): string;
43
+ /**
44
+ * Sets the value of the 'alt' attribute for the element.
45
+ * @param {string} value The new value to set for the 'alt' attribute.
46
+ */
47
+ set alt(value: string);
48
+ /**
49
+ * Retrieves the value of the 'alt' attribute for the current element.
50
+ * @returns {string|null} The value of the 'alt' attribute, or null if the attribute is not set.
51
+ */
52
+ get alt(): string;
33
53
  /**
34
54
  * Sets the fallout property. Updates the `fallout` attribute if the value is a string;
35
55
  * otherwise, assigns the value to the `_fallout` property.
@@ -93,5 +113,5 @@ export default class Img extends WJElement {
93
113
  * @function onerrorFunc
94
114
  * @memberof Img
95
115
  */
96
- onerrorFunc: () => void;
116
+ onerrorFunc: (img: any) => void;
97
117
  }
@@ -83,6 +83,14 @@ class Avatar extends WJElement {
83
83
  static get cssStyleSheet() {
84
84
  return styles;
85
85
  }
86
+ /**
87
+ * Returns the list of attributes to observe for changes.
88
+ * @static
89
+ * @returns {Array<string>}
90
+ */
91
+ static get observedAttributes() {
92
+ return ["initials"];
93
+ }
86
94
  /**
87
95
  * Method to setup attributes.
88
96
  */
@@ -1 +1 @@
1
- {"version":3,"file":"wje-avatar.js","sources":["../packages/wje-avatar/service/service.js","../packages/wje-avatar/avatar.element.js","../packages/wje-avatar/avatar.js"],"sourcesContent":["/**\n * Generates an HSL color value based on the input text.\n * @param {string} text The input text to generate the HSL color.\n * @param {number} [s] The saturation value (in percentage) for the HSL color.\n * @param {number} [l] The lightness value (in percentage) for the HSL color.\n * @returns {string} - The HSL color string in the format `hsl(h, s%, l%)`.\n * @description\n * This function computes a hash from the input text and uses it to generate\n * a hue value. The hue is combined with the provided saturation and lightness\n * values to create an HSL color. This can be useful for consistently assigning\n * colors based on text input, such as for avatars or tags.\n * @example\n * // Returns 'hsl(180, 40%, 65%)'\n * getHsl('example');\n * @example\n * // Returns 'hsl(300, 50%, 70%)'\n * getHsl('test', 50, 70);\n */\nexport function getHsl(text, s = 40, l = 65) {\n let str = text;\n let hash = 0;\n\n for (let i = 0; i < str?.length; i++) {\n hash = str.charCodeAt(i) + hash * 31;\n }\n\n let h = hash % 360;\n\n return `hsl(${h}, ${s}%, ${l}%)`;\n}\n\n/**\n * Generates initials from a given string.\n * @param {string} string The input string, typically a full name.\n * @param {number} [length] The desired number of initials (default is 2).\n * @returns {string} - The generated initials in uppercase.\n * @description\n * This function takes a string, splits it by spaces, and generates initials.\n * It always includes the first character of the first word. If the input string\n * contains more than one word and the `length` parameter is greater than 1, it\n * also includes the first character of the last word.\n * @example\n * // Returns 'JD'\n * getInitials('John Doe');\n * @example\n * // Returns 'J'\n * getInitials('John');\n * @example\n * // Returns 'JM'\n * getInitials('John Michael Doe', 2);\n */\nexport function getInitials(string, length = 2) {\n let names = string.split(' ');\n let initials = names[0].substring(0, 1).toUpperCase();\n\n if (names.length > 1 && length > 1) {\n initials += names[names.length - 1].substring(0, 1).toUpperCase();\n }\n return initials;\n}\n","import { default as WJElement } from '../wje-element/element.js';\nimport { getHsl, getInitials } from './service/service.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary This class represents an Avatar element, extending the WJElement class.\n * @documentation https://elements.webjet.sk/components/avatar\n * @status stable\n * @augments WJElement\n * @slot - The avatar main content.\n * @csspart native - The component's native wrapper.\n * @cssproperty --wje-avatar-width;\n * @cssproperty --wje-avatar-height;\n * @cssproperty --wje-avatar-font-size;\n * @cssproperty --wje-avatar-font-weight;\n * @cssproperty --wje-avatar-color;\n * @cssproperty --wje-avatar-background-color;\n * @cssproperty --wje-avatar-border-radius;\n * @cssproperty --wje-avatar-border-color;\n * @cssproperty --wje-avatar-border-width;\n * @cssproperty --wje-avatar-border-style;\n * @tag wje-avatar\n */\nexport default class Avatar extends WJElement {\n /**\n * Avatar class constructor.\n */\n constructor() {\n super();\n }\n\n /**\n * Sets the value of the 'label' attribute for the element.\n * @param {string} value The new value to be set for the 'label' attribute.\n */\n set label(value) {\n this.setAttribute('label', value);\n }\n\n /**\n * Retrieves the value of the 'label' attribute for the element.\n * If the attribute is not set, it defaults to an empty string.\n * @returns {string} The value of the 'label' attribute or an empty string if not defined.\n */\n get label() {\n return this.getAttribute('label') || '';\n }\n\n /**\n * Sets the value of initials for the element by updating\n * the 'initials' attribute with the provided value.\n * @param {string} value The value to be set as the initials.\n */\n set initials(value) {\n this.setAttribute('initials', '');\n }\n\n /**\n * Retrieves the value of the 'initials' attribute if it exists.\n * @returns {boolean} Returns true if the 'initials' attribute is present, otherwise false.\n */\n get initials() {\n return this.hasAttribute('initials') || false;\n }\n\n /**\n * Sets the size attribute for the element.\n * @param {string | number} value The value to set for the size attribute.\n */\n set size(value) {\n this.setAttribute('size', value);\n }\n\n /**\n * Retrieves the size attribute of the element. If the size attribute\n * is not defined, it returns the default value 'medium'.\n * @returns {string} The size value of the element or 'medium' if not specified.\n */\n get size() {\n return this.getAttribute('size') || 'medium';\n }\n\n /**\n * Class name for the Avatar element.\n */\n className = 'Avatar';\n\n /**\n * Getter for cssStyleSheet.\n * @returns {string} styles\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Method to setup attributes.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Method to draw the avatar element and return a document fragment.\n * @returns {object} fragment - The document fragment\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let element = document.createElement('div');\n element.setAttribute('part', 'native');\n element.classList.add('native-avatar');\n\n let slot = document.createElement('slot');\n\n element.appendChild(slot);\n\n if (this.initials) {\n let initials = getInitials(this.label);\n\n this.setAttribute('style', `--wje-avatar-background-color: ${getHsl(initials)}`);\n element.innerText = initials;\n } else {\n let slotIcon = document.createElement('slot');\n slotIcon.setAttribute('name', 'icon');\n\n element.appendChild(slotIcon);\n }\n\n let status = document.createElement('slot');\n status.setAttribute('name', 'status');\n status.setAttribute('part', 'status');\n\n let secondary = document.createElement('slot');\n secondary.setAttribute('name', 'secondary');\n secondary.setAttribute('part', 'secondary');\n\n element.appendChild(status);\n element.appendChild(secondary);\n\n fragment.appendChild(element);\n\n return fragment;\n }\n\n /**\n * Method to check if the avatar is an image.\n * @returns {boolean} - True if the avatar is an image, false otherwise\n */\n isImage() {\n return this.getElementsByTagName('wje-img').length > 0;\n }\n}\n","import Avatar from './avatar.element.js';\n\nexport default Avatar;\n\nAvatar.define('wje-avatar', Avatar);\n"],"names":[],"mappings":";;;;AAkBO,SAAS,OAAO,MAAM,IAAI,IAAI,IAAI,IAAI;AACzC,MAAI,MAAM;AACV,MAAI,OAAO;AAEX,WAAS,IAAI,GAAG,KAAI,2BAAK,SAAQ,KAAK;AAClC,WAAO,IAAI,WAAW,CAAC,IAAI,OAAO;AAAA,EAC1C;AAEI,MAAI,IAAI,OAAO;AAEf,SAAO,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC;AAChC;AAsBO,SAAS,YAAY,QAAQ,SAAS,GAAG;AAC5C,MAAI,QAAQ,OAAO,MAAM,GAAG;AAC5B,MAAI,WAAW,MAAM,CAAC,EAAE,UAAU,GAAG,CAAC,EAAE,YAAa;AAErD,MAAI,MAAM,SAAS,KAAK,SAAS,GAAG;AAChC,gBAAY,MAAM,MAAM,SAAS,CAAC,EAAE,UAAU,GAAG,CAAC,EAAE,YAAa;AAAA,EACzE;AACI,SAAO;AACX;;ACpCe,MAAM,eAAe,UAAU;AAAA;AAAA;AAAA;AAAA,EAI1C,cAAc;AACV,UAAO;AAyDX;AAAA;AAAA;AAAA,qCAAY;AAAA,EAxDhB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,MAAM,OAAO;AACb,SAAK,aAAa,SAAS,KAAK;AAAA,EACxC;A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AAQ,QAAQ;AAEpC,QAAI,YAAY,SAAS,cAAc,MAAM;AAC7C,cAAU,aAAa,QAAQ,WAAW;AAC1C,cAAU,aAAa,QAAQ,WAAW;AAE1C,YAAQ,YAAY,MAAM;AAC1B,YAAQ,YAAY,SAAS;AAE7B,aAAS,YAAY,OAAO;AAE5B,WAAO;AAAA,EACf;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,UAAU;AACN,WAAO,KAAK,qBAAqB,SAAS,EAAE,SAAS;AAAA,EAC7D;AACA;ACpJA,OAAO,OAAO,cAAc,MAAM;"}
1
+ {"version":3,"file":"wje-avatar.js","sources":["../packages/wje-avatar/service/service.js","../packages/wje-avatar/avatar.element.js","../packages/wje-avatar/avatar.js"],"sourcesContent":["/**\n * Generates an HSL color value based on the input text.\n * @param {string} text The input text to generate the HSL color.\n * @param {number} [s] The saturation value (in percentage) for the HSL color.\n * @param {number} [l] The lightness value (in percentage) for the HSL color.\n * @returns {string} - The HSL color string in the format `hsl(h, s%, l%)`.\n * @description\n * This function computes a hash from the input text and uses it to generate\n * a hue value. The hue is combined with the provided saturation and lightness\n * values to create an HSL color. This can be useful for consistently assigning\n * colors based on text input, such as for avatars or tags.\n * @example\n * // Returns 'hsl(180, 40%, 65%)'\n * getHsl('example');\n * @example\n * // Returns 'hsl(300, 50%, 70%)'\n * getHsl('test', 50, 70);\n */\nexport function getHsl(text, s = 40, l = 65) {\n let str = text;\n let hash = 0;\n\n for (let i = 0; i < str?.length; i++) {\n hash = str.charCodeAt(i) + hash * 31;\n }\n\n let h = hash % 360;\n\n return `hsl(${h}, ${s}%, ${l}%)`;\n}\n\n/**\n * Generates initials from a given string.\n * @param {string} string The input string, typically a full name.\n * @param {number} [length] The desired number of initials (default is 2).\n * @returns {string} - The generated initials in uppercase.\n * @description\n * This function takes a string, splits it by spaces, and generates initials.\n * It always includes the first character of the first word. If the input string\n * contains more than one word and the `length` parameter is greater than 1, it\n * also includes the first character of the last word.\n * @example\n * // Returns 'JD'\n * getInitials('John Doe');\n * @example\n * // Returns 'J'\n * getInitials('John');\n * @example\n * // Returns 'JM'\n * getInitials('John Michael Doe', 2);\n */\nexport function getInitials(string, length = 2) {\n let names = string.split(' ');\n let initials = names[0].substring(0, 1).toUpperCase();\n\n if (names.length > 1 && length > 1) {\n initials += names[names.length - 1].substring(0, 1).toUpperCase();\n }\n return initials;\n}\n","import { default as WJElement } from '../wje-element/element.js';\nimport { getHsl, getInitials } from './service/service.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary This class represents an Avatar element, extending the WJElement class.\n * @documentation https://elements.webjet.sk/components/avatar\n * @status stable\n * @augments WJElement\n * @slot - The avatar main content.\n * @csspart native - The component's native wrapper.\n * @cssproperty --wje-avatar-width;\n * @cssproperty --wje-avatar-height;\n * @cssproperty --wje-avatar-font-size;\n * @cssproperty --wje-avatar-font-weight;\n * @cssproperty --wje-avatar-color;\n * @cssproperty --wje-avatar-background-color;\n * @cssproperty --wje-avatar-border-radius;\n * @cssproperty --wje-avatar-border-color;\n * @cssproperty --wje-avatar-border-width;\n * @cssproperty --wje-avatar-border-style;\n * @tag wje-avatar\n */\nexport default class Avatar extends WJElement {\n /**\n * Avatar class constructor.\n */\n constructor() {\n super();\n }\n\n /**\n * Sets the value of the 'label' attribute for the element.\n * @param {string} value The new value to be set for the 'label' attribute.\n */\n set label(value) {\n this.setAttribute('label', value);\n }\n\n /**\n * Retrieves the value of the 'label' attribute for the element.\n * If the attribute is not set, it defaults to an empty string.\n * @returns {string} The value of the 'label' attribute or an empty string if not defined.\n */\n get label() {\n return this.getAttribute('label') || '';\n }\n\n /**\n * Sets the value of initials for the element by updating\n * the 'initials' attribute with the provided value.\n * @param {string} value The value to be set as the initials.\n */\n set initials(value) {\n this.setAttribute('initials', '');\n }\n\n /**\n * Retrieves the value of the 'initials' attribute if it exists.\n * @returns {boolean} Returns true if the 'initials' attribute is present, otherwise false.\n */\n get initials() {\n return this.hasAttribute('initials') || false;\n }\n\n /**\n * Sets the size attribute for the element.\n * @param {string | number} value The value to set for the size attribute.\n */\n set size(value) {\n this.setAttribute('size', value);\n }\n\n /**\n * Retrieves the size attribute of the element. If the size attribute\n * is not defined, it returns the default value 'medium'.\n * @returns {string} The size value of the element or 'medium' if not specified.\n */\n get size() {\n return this.getAttribute('size') || 'medium';\n }\n\n /**\n * Class name for the Avatar element.\n */\n className = 'Avatar';\n\n /**\n * Getter for cssStyleSheet.\n * @returns {string} styles\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 ['initials'];\n }\n\n /**\n * Method to setup attributes.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Method to draw the avatar element and return a document fragment.\n * @returns {object} fragment - The document fragment\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let element = document.createElement('div');\n element.setAttribute('part', 'native');\n element.classList.add('native-avatar');\n\n let slot = document.createElement('slot');\n\n element.appendChild(slot);\n\n if (this.initials) {\n let initials = getInitials(this.label);\n\n this.setAttribute('style', `--wje-avatar-background-color: ${getHsl(initials)}`);\n element.innerText = initials;\n } else {\n let slotIcon = document.createElement('slot');\n slotIcon.setAttribute('name', 'icon');\n\n element.appendChild(slotIcon);\n }\n\n let status = document.createElement('slot');\n status.setAttribute('name', 'status');\n status.setAttribute('part', 'status');\n\n let secondary = document.createElement('slot');\n secondary.setAttribute('name', 'secondary');\n secondary.setAttribute('part', 'secondary');\n\n element.appendChild(status);\n element.appendChild(secondary);\n\n fragment.appendChild(element);\n\n return fragment;\n }\n\n /**\n * Method to check if the avatar is an image.\n * @returns {boolean} - True if the avatar is an image, false otherwise\n */\n isImage() {\n return this.getElementsByTagName('wje-img').length > 0;\n }\n}\n","import Avatar from './avatar.element.js';\n\nexport default Avatar;\n\nAvatar.define('wje-avatar', Avatar);\n"],"names":[],"mappings":";;;;AAkBO,SAAS,OAAO,MAAM,IAAI,IAAI,IAAI,IAAI;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UpAccessors();
463
463
  this.drawingStatus = this.drawingStatuses.START;
464
464
  await this.display(force);
465
- const sheet = new CSSStyleSheet();
466
- sheet.replaceSync(this.constructor.cssStyleSheet);
467
- this.context.adoptedStyleSheets = [sheet];
468
465
  resolve();
469
466
  });
470
467
  });
@@ -672,9 +669,13 @@ const _WJElement = class _WJElement extends HTMLElement {
672
669
  * Refreshes the update promise for rendering lifecycle management.
673
670
  */
674
671
  refreshUpdatePromise() {
672
+ if (this.updateComplete) {
673
+ this.rejectPromise("Update cancelled");
674
+ }
675
675
  this.updateComplete = new Promise((resolve, reject) => {
676
676
  this.finisPromise = resolve;
677
677
  this.rejectPromise = reject;
678
+ }).catch((e) => {
678
679
  });
679
680
  }
680
681
  /**
@@ -682,12 +683,6 @@ const _WJElement = class _WJElement extends HTMLElement {
682
683
  */
683
684
  connectedCallback() {
684
685
  this.drawingStatus = this.drawingStatuses.ATTACHED;
685
- this.finisPromise = (resolve) => {
686
- resolve();
687
- };
688
- this.rejectPromise = (reject) => {
689
- reject();
690
- };
691
686
  this.refreshUpdatePromise();
692
687
  this.renderPromise = this.initWjElement(true);
693
688
  }
@@ -738,20 +733,24 @@ const _WJElement = class _WJElement extends HTMLElement {
738
733
  this.drawingStatus = this.drawingStatuses.DISCONNECTED;
739
734
  this.componentCleanup();
740
735
  }
741
- /**
742
- * Enqueues an update to the component.
743
- * @returns A promise that resolves when the update is complete.
744
- */
745
- async enqueueUpdate() {
736
+ async processCurrentRenderPromise() {
737
+ var _a;
746
738
  try {
747
- if (this.renderPromise && this.renderPromise instanceof Promise) {
739
+ if (this.renderPromise && (this.renderPromise instanceof Promise || ((_a = this.renderPromise) == null ? void 0 : _a.constructor.name) === "Promise")) {
748
740
  await this.renderPromise;
749
741
  }
750
742
  } catch (e) {
751
743
  console.error("An error occurred:", e);
752
744
  Promise.reject(e);
753
745
  }
754
- const result = this.refresh();
746
+ }
747
+ /**
748
+ * Enqueues an update to the component.
749
+ * @returns A promise that resolves when the update is complete.
750
+ */
751
+ async enqueueUpdate() {
752
+ await this.processCurrentRenderPromise();
753
+ const result = this._refresh();
755
754
  if (result !== null) {
756
755
  await result;
757
756
  }
@@ -768,6 +767,9 @@ const _WJElement = class _WJElement extends HTMLElement {
768
767
  this.renderPromise = this.enqueueUpdate();
769
768
  }
770
769
  }
770
+ refresh() {
771
+ this.renderPromise = this.enqueueUpdate();
772
+ }
771
773
  /**
772
774
  * Refreshes the component by reinitializing it if it is in a drawing state.
773
775
  * This method checks if the component's drawing status is at least in the START state.
@@ -780,7 +782,7 @@ const _WJElement = class _WJElement extends HTMLElement {
780
782
  * If the component is not in a drawing state, it simply returns a resolved promise.
781
783
  * @returns {Promise<void>} A promise that resolves when the refresh is complete.
782
784
  */
783
- refresh() {
785
+ _refresh() {
784
786
  var _a, _b, _c;
785
787
  if (this.drawingStatus && this.drawingStatus >= this.drawingStatuses.START) {
786
788
  (_a = this.beforeRedraw) == null ? void 0 : _a.call(this);
@@ -836,7 +838,7 @@ const _WJElement = class _WJElement extends HTMLElement {
836
838
  async render() {
837
839
  this.drawingStatus = this.drawingStatuses.DRAWING;
838
840
  let _draw = this.draw(this.context, this.store, WjElementUtils.getAttributes(this));
839
- if (_draw instanceof Promise) {
841
+ if (_draw instanceof Promise || (_draw == null ? void 0 : _draw.constructor.name) === "Promise") {
840
842
  _draw = await _draw;
841
843
  }
842
844
  let rend = _draw;
@@ -923,12 +925,15 @@ const _WJElement = class _WJElement extends HTMLElement {
923
925
  return new Promise(async (resolve, reject) => {
924
926
  var _a;
925
927
  const __beforeDraw = this.beforeDraw(this.context, this.store, WjElementUtils.getAttributes(this));
926
- if (__beforeDraw instanceof Promise) {
928
+ if (__beforeDraw instanceof Promise || (__beforeDraw == null ? void 0 : __beforeDraw.constructor.name) === "Promise") {
927
929
  await __beforeDraw;
928
930
  }
931
+ const sheet = new CSSStyleSheet();
932
+ sheet.replaceSync(this.constructor.cssStyleSheet);
933
+ this.context.adoptedStyleSheets = [sheet];
929
934
  await this.render();
930
935
  const __afterDraw = (_a = this.afterDraw) == null ? void 0 : _a.call(this, this.context, this.store, WjElementUtils.getAttributes(this));
931
- if (__afterDraw instanceof Promise) {
936
+ if (__afterDraw instanceof Promise || (__afterDraw == null ? void 0 : __afterDraw.constructor.name) === "Promise") {
932
937
  await __afterDraw;
933
938
  }
934
939
  this.finisPromise();
@@ -1 +1 @@
1
- {"version":3,"file":"wje-element.js","sources":["../packages/wje-element/service/universal-service.js","../packages/utils/permissions-api.js","../packages/utils/element-utils.js","../packages/utils/event.js","../packages/wje-element/element.js"],"sourcesContent":["export class UniversalService {\n constructor(props = {}) {\n this._store = props.store;\n }\n\n findByKey = (attrName, key, keyValue) => {\n if (this._store.getState()[attrName] instanceof Array) {\n return this._store.getState()[attrName].find((item) => item[key] === keyValue);\n } else {\n console.warn(` Attribute ${attrName} is not array`);\n return null;\n }\n };\n\n findById = (attrName, id) => {\n if (this._store.getState()[attrName] instanceof Array) {\n return this._store.getState()[attrName].find((item) => item.id === id);\n } else {\n console.warn(` Attribute ${attrName} is not array`);\n return null;\n }\n };\n\n findAttributeValue = (attrName) => {\n return this._store.getState()[attrName];\n };\n\n update = (data, action) => {\n this._store.dispatch(action(data));\n };\n\n add = (data, action) => {\n this._store.dispatch(action(data));\n };\n\n _save(url, data, action, dispatchMethod, method) {\n let promise = fetch(url, {\n method: method,\n body: JSON.stringify(data),\n headers: {\n 'Content-Type': 'application/json',\n },\n }).then((response) => {\n if (response.ok) {\n return response.json();\n } else {\n return response.json();\n }\n });\n\n return this.dispatch(promise, dispatchMethod, action);\n }\n\n _get(url, action, dispatchMethod, signal) {\n let promise = fetch(url, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n },\n ...(signal ? { signal } : {}),\n }).then(async (response) => {\n let responseText;\n try {\n responseText = await response.text();\n return JSON.parse(responseText);\n } catch (err) {\n console.error(err);\n return responseText;\n }\n });\n\n return this.dispatch(promise, dispatchMethod, action);\n }\n\n put(url, data, action, dispatchMethod = true) {\n return this._save(url, data, action, dispatchMethod, 'PUT');\n }\n\n post(url, data, action, dispatchMethod = true) {\n return this._save(url, data, action, dispatchMethod, 'POST');\n }\n\n delete(url, data, action, dispatchMethod = true) {\n return this._save(url, data, action, dispatchMethod, 'DELETE');\n }\n\n get(url, action, dispatchMethod = true) {\n return this._get(url, action, dispatchMethod);\n }\n\n dispatch(promise, dispatchMethod, action) {\n if (dispatchMethod) {\n return promise\n .then((data) => {\n this._store.dispatch(action(data.data));\n return data;\n })\n .catch((error) => {\n console.error(error);\n });\n }\n return promise;\n }\n\n loadPromise = (\n url,\n action,\n method = 'GET',\n data = '',\n permissionCallBack = () => {\n //\n // No empty function\n }\n ) => {\n return fetch(url, {\n method: method,\n body: data,\n headers: {\n 'Content-Type': 'application/json',\n },\n async: true,\n })\n .then((response, e) => {\n let permissions = response.headers.get('permissions')?.split(',');\n permissionCallBack(permissions);\n\n if (response.ok) {\n return response.json();\n } else {\n throw response.json();\n }\n })\n .then((responseData) => {\n this._store.dispatch(action(responseData));\n return responseData;\n });\n };\n\n loadOnePromise = (url, action) => {\n return fetch(url, {\n headers: {\n 'Content-Type': 'application/json',\n },\n }).then((response) => {\n const responseData = response.json();\n if (action) {\n this._store.dispatch(action(responseData));\n }\n return responseData;\n });\n };\n}\n","export class WjePermissionsApi {\n static _permissionKey = 'permissions';\n\n /**\n * Sets the permission key.\n * @param value\n */\n static set permissionKey(value) {\n WjePermissionsApi._permissionKey = value || 'permissions';\n }\n\n /**\n * Returns the permission key.\n * @returns {*|string}\n */\n static get permissionKey() {\n return WjePermissionsApi._permissionKey;\n }\n\n /**\n * Sets the permissions.\n * @param value\n */\n static set permissions(value) {\n window.localStorage.setItem(WjePermissionsApi.permissionKey, JSON.stringify(value));\n }\n\n /**\n * Returns the permissions.\n * @returns {string[]}\n */\n static get permissions() {\n return JSON.parse(window.localStorage.getItem(WjePermissionsApi.permissionKey)) || [];\n }\n\n /**\n * Checks if the permission is included.\n * @param key\n * @returns {boolean}\n */\n static includesKey(key) {\n return WjePermissionsApi.permissions.includes(key);\n }\n\n /**\n * Checks if the permission is fulfilled.\n * @returns {boolean}\n */\n static isPermissionFulfilled(permissions) {\n return permissions.some((perm) => WjePermissionsApi.permissions.includes(perm));\n }\n}\n","export class WjElementUtils {\n /**\n * This function creates an element.\n * @param element : HTMLElement - The element value.\n * @param object : Object - The object value.\n */\n static setAttributesToElement(element, object) {\n Object.entries(object).forEach(([key, value]) => {\n element.setAttribute(key, value);\n });\n }\n\n /**\n * This function gets the attributes from an element.\n * @param {string|HTMLElement} el The element or selector to retrieve attributes from.\n * @returns {object} - An object containing the element's attributes as key-value pairs.\n */\n static getAttributes(el) {\n if (typeof el === 'string') el = document.querySelector(el);\n\n return Array.from(el.attributes)\n .filter((a) => !a.name.startsWith('@'))\n .map((a) => [\n a.name\n .split('-')\n .map((s, i) => {\n if (i !== 0) {\n return s.charAt(0).toUpperCase() + s.slice(1);\n } else {\n return s;\n }\n })\n .join(''),\n a.value,\n ])\n .reduce((acc, attr) => {\n acc[attr[0]] = attr[1];\n return acc;\n }, {});\n }\n\n /**\n * This function gets the events from an element.\n * @param {string|HTMLElement} el The element or selector to retrieve events from.\n * @returns {Map<any, any>} - The map value.\n */\n static getEvents(el) {\n if (typeof el === 'string') el = document.querySelector(el);\n\n return Array.from(el.attributes)\n .filter((a) => a.name.startsWith('@wje'))\n .map((a) => [a.name.substring(3).split('-').join(''), a.value])\n .reduce((acc, attr) => {\n acc.set(attr[0], attr[1]);\n return acc;\n }, new Map());\n }\n\n /**\n * This function converts an object to a string.\n * @param {object} object The object to convert.\n * @returns {string} - The string value.\n */\n static attributesToString(object) {\n return Object.entries(object)\n .map(([key, value]) => {\n return `${key}=\"${value}\"`;\n })\n .join(' ');\n }\n\n /**\n * This function checks if the slot exists.\n * @param {string|HTMLElement} el The element or selector to check for slots.\n * @param slotName The slot name to check for.\n * @returns {boolean} - The boolean value.\n */\n static hasSlot(el, slotName = null) {\n let selector = slotName ? `[slot=\"${slotName}\"]` : '[slot]';\n\n return el.querySelectorAll(selector).length > 0 ? true : false;\n }\n\n /**\n * This function checks if the slot has content.\n * @param {string|HTMLElement} el The element or selector to check for slot content\n * @param slotName The slot name to check for.\n * @returns {boolean} - The boolean value.\n */\n static hasSlotContent(el, slotName = null) {\n let slotElement = el.querySelector(`slot`);\n if (slotName) {\n slotElement = el.querySelector(`slot[name=\"${slotName}\"]`);\n }\n\n if (slotElement) {\n const assignedElements = slotElement.assignedElements();\n return assignedElements.length > 0;\n }\n\n return false;\n }\n\n /**\n * This function converts a string to a boolean.\n * @param {string | object} value The value to convert to a boolean. If the value is a boolean, it will be returned as is.\n * @returns {boolean} - The boolean value.\n */\n static stringToBoolean(value) {\n if (typeof value === 'boolean') return value;\n\n return !['false', '0', 0].includes(value);\n }\n}\n","var self; // eslint-disable-line no-var\n\nclass Event {\n constructor() {\n this.customEventStorage = [];\n self = this;\n }\n\n /**\n * Dispatch event to the element and trigger the listener.\n * @param e\n */\n #dispatch(e) {\n let element = this;\n let record = self.findRecordByElement(element);\n let listeners = record.listeners[e.type];\n\n listeners.forEach((listener) => {\n self.dispatchCustomEvent(element, listener.event, {\n originalEvent: e?.type || null,\n context: element,\n event: self,\n });\n\n if (listener.options && listener.options.stopPropagation === true) e.stopPropagation();\n });\n }\n\n /**\n * Dispatch custom event to the element with the specified event name and detail.\n * @param element\n * @param event\n * @param detail\n */\n dispatchCustomEvent(element, event, detail) {\n element.dispatchEvent(\n new CustomEvent(event, {\n detail: detail || {\n context: element,\n event: self,\n },\n bubbles: true,\n composed: true,\n cancelable: true,\n })\n );\n }\n\n /**\n * Find record by element in the storage.\n * @param element\n * @returns {*}\n */\n\n findRecordByElement(element) {\n for (let index = 0, length = this.customEventStorage.length; index < length; index++) {\n let record = this.customEventStorage[index];\n\n if (element === record.element) {\n return record;\n }\n }\n\n return false;\n }\n\n /**\n * Add listener to the element. If the element is an array, the listener will be added to all elements in the array.\n * @param element\n * @param originalEvent\n * @param event\n * @param listener\n * @param options\n */\n addListener(element, originalEvent, event, listener, options) {\n if (!element) return;\n\n if (!Array.isArray(element)) element = [element];\n\n element.forEach((el) => {\n this.writeRecord(el, originalEvent, event, listener, options);\n });\n }\n\n /**\n * Write record to the storage.\n * @param element\n * @param originalEvent\n * @param event\n * @param listener\n * @param options\n */\n writeRecord(element, originalEvent, event, listener, options) {\n let record = this.findRecordByElement(element);\n\n if (record) {\n record.listeners[originalEvent] = record.listeners[originalEvent] || [];\n } else {\n record = {\n element: element,\n listeners: {},\n };\n\n // vytvorime object listeners pre kazdy original event zvlast\n record.listeners[originalEvent] = [];\n\n this.customEventStorage.push(record);\n }\n\n listener = listener || this.#dispatch;\n let obj = {\n listener: listener,\n options: options,\n event: event,\n };\n\n // skontrolujeme ci uz tento listener neexistuje\n if (!this.listenerExists(element, originalEvent, obj)) {\n record.listeners[originalEvent].push(obj);\n\n element.addEventListener(originalEvent, listener, options);\n } else {\n // in case we want to add the same listener multiple times trigger a warning for a better debugging\n // console.warn(\"Listener already exists\", element, originalEvent, listener);\n }\n }\n\n /**\n * Performs a deep equality check between two objects.\n * @param x The first object to compare.\n * @param y The second object to compare.\n * @returns - Returns `true` if the objects are deeply equal, `false` otherwise.\n */\n deepEqual(x, y) {\n return x && y && typeof x === 'object' && typeof x === typeof y\n ? Object.keys(x).length === Object.keys(y).length &&\n Object.keys(x).every((key) => this.deepEqual(x[key], y[key]))\n : x === y;\n }\n\n /**\n * Check if the listener already exists on the element.\n * @param element\n * @param event\n * @param listener\n * @returns\n */\n listenerExists(element, event, listener) {\n let record = this.findRecordByElement(element);\n return record.listeners[event].some((e) => this.deepEqual(e, listener));\n }\n\n /**\n * Remove listener from the element and delete the listener from the custom event storage.\n * @param element\n * @param originalEvent\n * @param event\n * @param listener\n * @param options\n */\n removeListener(element, originalEvent, event, listener, options) {\n let record = this.findRecordByElement(element);\n\n if (record && originalEvent in record.listeners) {\n let index = record.listeners[originalEvent].indexOf(listener);\n\n if (index !== -1) {\n record.listeners[originalEvent].splice(index, 1);\n }\n\n if (!record.listeners[originalEvent].length) {\n delete record.listeners[originalEvent];\n }\n }\n\n listener = listener || this.#dispatch;\n\n element.removeEventListener(originalEvent, listener, options);\n }\n\n /**\n * Remove all event listeners from the specified element and delete the element from the custom event storage.\n * @param {HTMLElement} element The element from which all listeners will be removed.\n */\n removeElement(element) {\n this.customEventStorage = this.customEventStorage.filter((e) => {\n return e.element !== element;\n });\n }\n\n // TODO\n createPromiseFromEvent(element, event) {\n return new Promise((resolve) => {\n let success = () => {\n element.removeEventListener(event, success);\n resolve();\n };\n\n element.addEventListener(event, success);\n });\n }\n}\n\nlet event = new Event();\nexport { event };\n","import { UniversalService } from './service/universal-service.js';\nimport { defaultStoreActions, store } from '../wje-store/store.js';\nimport { WjePermissionsApi } from '../utils/permissions-api.js';\nimport { WjElementUtils } from '../utils/element-utils.js';\nimport { event } from '../utils/event.js';\n\nconst template = document.createElement('template');\ntemplate.innerHTML = ``;\n\nexport default class WJElement extends HTMLElement {\n /**\n * Initializes a new instance of the WJElement class.\n */\n\n constructor() {\n super();\n\n this.isAttached = false;\n this.service = new UniversalService({\n store: store,\n });\n\n // definujeme vsetky zavislosti.\n // Do zavislosti patria len komponenty, ktore su zavisle od ktoreho je zavisly tento komponent\n this.defineDependencies();\n\n this.rendering = false;\n this._dependencies = {};\n\n /**\n * @typedef {CREATED | ATTACHED | BEGINING | START | DRAWING | DONE | DISCONNECTED} DrawingStatus\n * @property {number} CREATED - The component has been created.\n * @property {number} ATTACHED - The component has been attached to the DOM.\n * @property {number} BEGINING - The component is beginning to draw.\n * @property {number} START - The component has started drawing.\n * @property {number} DRAWING - The component is drawing.\n * @property {number} DONE - The component has finished drawing.\n * @property {number} DISCONNECTED - The component has been disconnected from the DOM.\n */\n this.drawingStatuses = {\n CREATED: 0,\n ATTACHED: 1,\n BEGINING: 2,\n START: 3,\n DRAWING: 4,\n DONE: 5,\n DISCONNECTED: 6,\n };\n\n this.drawingStatus = this.drawingStatuses.CREATED;\n }\n\n /**\n * Sets the value of the 'permission' attribute.\n * @param {string[]} value The value to set for the 'permission' attribute.\n */\n set permission(value) {\n this.setAttribute('permission', value.join(','));\n }\n\n /**\n * Gets the value of the 'permission-check' attribute.\n * @returns {string[]} The value of the 'permission' attribute.\n */\n get permission() {\n return this.getAttribute('permission')?.split(',') || [];\n }\n\n /**\n * Sets the 'permission-check' attribute.\n * @param {boolean} value The value to set for the 'permission-check' attribute.\n */\n set isPermissionCheck(value) {\n if (value) this.setAttribute('permission-check', '');\n else this.removeAttribute('permission-check');\n }\n\n /**\n * Checks if the 'permission-check' attribute is present.\n * @returns {boolean} True if the 'permission-check' attribute is present.\n */\n get isPermissionCheck() {\n return this.hasAttribute('permission-check');\n }\n\n set noShow(value) {\n if (value) this.setAttribute('no-show', '');\n else this.removeAttribute('no-show');\n }\n\n /**\n * Checks if the 'show' attribute is present.\n * @returns {boolean} True if the 'show' attribute is present.\n */\n get noShow() {\n return this.hasAttribute('no-show');\n }\n\n /**\n * Sets the 'shadow' attribute.\n * @param {string} value The value to set for the 'shadow' attribute.\n */\n set isShadowRoot(value) {\n return this.setAttribute('shadow', value);\n }\n\n get isShadowRoot() {\n return this.getAttribute('shadow');\n }\n\n /**\n * Checks if the 'shadow' attribute is present.\n * @returns {boolean} True if the 'shadow' attribute is present.\n */\n get hasShadowRoot() {\n return this.hasAttribute('shadow');\n }\n\n /**\n * Gets the value of the 'shadow' attribute or 'open' if not set.\n * @returns {string} The value of the 'shadow' attribute or 'open'.\n */\n get shadowType() {\n return this.getAttribute('shadow') || 'open';\n }\n\n /**\n * Gets the rendering context, either the shadow root or the component itself.\n * @returns The rendering context.\n */\n get context() {\n if (this.hasShadowRoot) {\n return this.shadowRoot;\n } else {\n return this;\n }\n }\n\n /**\n * Gets the store instance.\n * @returns {object} The store instance.\n */\n get store() {\n return store;\n }\n\n /**\n * @typedef {object} ArrayActions\n * @property {Function} addAction - Adds an item to the array.\n * @property {Function} deleteAction - Deletes an item from the array.\n * @property {Function} loadAction - Loads an array.\n * @property {Function} updateAction - Updates an item in the array.\n * @property {Function} addManyAction - Adds many items to the array.\n */\n\n /**\n * @typedef {object} ObjectActions\n * @property {Function} addAction - Replace old object with new object\n * @property {Function} deleteAction - Delete item based on key\n * @property {Function} updateAction - Update item based on key\n */\n\n /**\n * Gets the default store actions.\n * @returns The default store actions for arrays and objects.\n */\n get defaultStoreActions() {\n return defaultStoreActions;\n }\n\n /**\n * Gets the classes to be removed after the component is connected.\n * @returns An array of class names to remove.\n */\n get removeClassAfterConnect() {\n return this.getAttribute('remove-class-after-connect')?.split(' ');\n }\n\n /**\n * Sets the component dependencies.\n * @param value The dependencies to set.\n */\n set dependencies(value) {\n this._dependencies = value;\n }\n\n /**\n * Gets the component dependencies.\n * @returns The component dependencies.\n */\n get dependencies() {\n return this._dependencies;\n }\n\n /**\n * Processes and combines two templates into one.\n * @param pTemplate The primary template.\n * @param inputTemplate The secondary template.\n * @returns The combined template.\n */\n static processTemplates = (pTemplate, inputTemplate) => {\n const newTemplate = document.createElement('template');\n newTemplate.innerHTML = [inputTemplate.innerHTML, pTemplate?.innerHTML || ''].join('');\n return newTemplate;\n };\n\n /**\n * Defines a custom element if not already defined.\n * @param name The name of the custom element.\n * @param [elementConstructor] The constructor for the custom element.\n * @param [options] Additional options for defining the element.\n */\n static define(name, elementConstructor = this, options = {}) {\n const definedElement = customElements.get(name);\n\n if (!definedElement) {\n customElements.define(name, elementConstructor, options);\n }\n }\n\n /**\n * Defines component dependencies by registering custom elements.\n */\n defineDependencies() {\n if (this.dependencies)\n Object.entries(this.dependencies).forEach((name, component) => WJElement.define(name, component));\n }\n\n /**\n * Hook for extending behavior before drawing the component.\n * @param context The rendering context, usually the element's shadow root or main DOM element.\n * @param appStoreObj The global application store for managing state.\n * @param params Additional parameters or attributes for rendering the component.\n */\n beforeDraw(context, appStoreObj, params) {\n // Hook for extending behavior before drawing\n }\n\n /**\n * Renders the component within the provided context.\n * @param context The rendering context, usually the element's shadow root or main DOM element.\n * @param appStoreObj\n * @param params Additional parameters or attributes for rendering the component.\n * @returns This implementation does not render anything and returns `null`.\n * @description\n * The `draw` method is responsible for rendering the component's content.\n * Override this method in subclasses to define custom rendering logic.\n * @example\n * class MyComponent extends WJElement {\n * draw(context, appStoreObj, params) {\n * const div = document.createElement('div');\n * div.textContent = 'Hello, world!';\n * context.appendChild(div);\n * }\n * }\n */\n draw(context, appStoreObj, params) {\n return null;\n }\n\n /**\n * Hook for extending behavior after drawing the component.\n * @param context The rendering context, usually the element's shadow root or main DOM element.\n * @param appStoreObj The global application store for managing state.\n * @param params Additional parameters or attributes for rendering the component.\n */\n afterDraw(context, appStoreObj, params) {\n // Hook for extending behavior after drawing\n }\n\n /**\n * Refreshes the update promise for rendering lifecycle management.\n */\n refreshUpdatePromise() {\n this.updateComplete = new Promise((resolve, reject) => {\n this.finisPromise = resolve;\n this.rejectPromise = reject;\n });\n }\n\n /**\n * Lifecycle method invoked when the component is connected to the DOM.\n */\n connectedCallback() {\n this.drawingStatus = this.drawingStatuses.ATTACHED;\n\n // RHR toto sa tiež týka slick routeru pretože on začal routovanie ešte pred vykreslením wjelementu\n this.finisPromise = (resolve) => {\n resolve();\n };\n this.rejectPromise = (reject) => {\n reject();\n };\n this.refreshUpdatePromise();\n\n this.renderPromise = this.initWjElement(true);\n }\n\n /**\n * Initializes the component, setting up attributes and rendering.\n * @param [force] Whether to force initialization.\n * @returns A promise that resolves when initialization is complete.\n */\n initWjElement = (force = false) => {\n return new Promise(async (resolve, reject) => {\n this.drawingStatus = this.drawingStatuses.BEGINING;\n\n this.setupAttributes?.();\n if (this.hasShadowRoot) {\n if (!this.shadowRoot) this.attachShadow({ mode: this.shadowType || 'open' });\n }\n\n this.setUpAccessors();\n\n this.drawingStatus = this.drawingStatuses.START;\n await this.display(force);\n\n const sheet = new CSSStyleSheet();\n sheet.replaceSync(this.constructor.cssStyleSheet);\n\n this.context.adoptedStyleSheets = [sheet];\n\n resolve();\n });\n };\n\n /**\n * Sets up attributes and event listeners for the component.\n * This method retrieves all custom events defined for the component\n * and adds event listeners for each of them. When an event is triggered,\n * it calls the corresponding method on the host element.\n */\n setupAttributes() {\n // Keď neaký element si zadefinuje funkciu \"setupAttributes\" tak sa obsah tejto funkcie nezavolá\n\n let allEvents = WjElementUtils.getEvents(this);\n allEvents.forEach((customEvent, domEvent) => {\n this.addEventListener(domEvent, (e) => {\n this.getRootNode().host[customEvent]?.();\n });\n });\n }\n\n /**\n * Hook for extending behavior before disconnecting the component.\n */\n beforeDisconnect() {\n // Hook for extending behavior before disconnecting\n }\n\n /**\n * Hook for extending behavior after disconnecting the component.\n */\n afterDisconnect() {\n // Hook for extending behavior after disconnecting\n }\n\n /**\n * Hook for extending behavior before redrawing the component.\n */\n beforeRedraw() {\n // Hook for extending behavior before redrawing\n }\n\n /**\n * Cleans up resources and event listeners for the component.\n */\n componentCleanup() {\n // Hook for cleaning up the component\n }\n\n /**\n * Lifecycle method invoked when the component is disconnected from the DOM.\n */\n disconnectedCallback() {\n this.beforeDisconnect?.();\n\n if (this.isAttached) this.context.innerHTML = '';\n this.isAttached = false;\n\n this.afterDisconnect?.();\n\n this.drawingStatus = this.drawingStatuses.DISCONNECTED;\n\n this.componentCleanup();\n }\n\n /**\n * Enqueues an update to the component.\n * @returns A promise that resolves when the update is complete.\n */\n async enqueueUpdate() {\n try {\n if (this.renderPromise && this.renderPromise instanceof Promise) {\n await this.renderPromise;\n }\n } catch (e) {\n console.error('An error occurred:', e);\n Promise.reject(e);\n }\n const result = this.refresh();\n\n if (result !== null) {\n await result;\n }\n\n this.renderPromise = null;\n }\n\n /**\n * Lifecycle method invoked when an observed attribute changes.\n * @param name The name of the attribute that changed.\n * @param old The old value of the attribute.\n * @param newName The new value of the attribute.\n */\n attributeChangedCallback(name, old, newName) {\n if (old !== newName) {\n this.renderPromise = this.enqueueUpdate();\n }\n }\n\n /**\n * Refreshes the component by reinitializing it if it is in a drawing state.\n * This method checks if the component's drawing status is at least in the START state.\n * If so, it performs the following steps:\n * 1. Calls the `beforeRedraw` hook if defined.\n * 2. Calls the `beforeDisconnect` hook if defined.\n * 3. Refreshes the update promise to manage the rendering lifecycle.\n * 4. Calls the `afterDisconnect` hook if defined.\n * 5. Reinitializes the component by calling `initWjElement` with `true` to force initialization.\n * If the component is not in a drawing state, it simply returns a resolved promise.\n * @returns {Promise<void>} A promise that resolves when the refresh is complete.\n */\n refresh() {\n if (this.drawingStatus && this.drawingStatus >= this.drawingStatuses.START) {\n this.beforeRedraw?.();\n this.beforeDisconnect?.();\n this.refreshUpdatePromise();\n this.afterDisconnect?.();\n\n return this.initWjElement(true);\n }\n\n return Promise.resolve();\n }\n\n /**\n * Renders the component within the provided context.\n * @param context The rendering context, usually the element's shadow root or main DOM element.\n * @param appStore The global application store for managing state.\n * @param params Additional parameters or attributes for rendering the component.\n * @returns This implementation does not render anything and returns `null`.\n * @description\n * The `draw` method is responsible for rendering the component's content.\n * Override this method in subclasses to define custom rendering logic.\n * @example\n * class MyComponent extends WJElement {\n * draw(context, appStore, params) {\n * const div = document.createElement('div');\n * div.textContent = 'Hello, world!';\n * context.appendChild(div);\n * }\n * }\n */\n draw(context, appStore, params) {\n return null;\n }\n\n /**\n * Displays the component's content, optionally forcing a re-render.\n * @param [force] Whether to force a re-render.\n * @returns A promise that resolves when the display is complete.\n */\n display(force = false) {\n this.template = this.constructor.customTemplate || document.createElement('template');\n\n if (force) {\n [...this.context.childNodes].forEach(this.context.removeChild.bind(this.context));\n this.isAttached = false;\n }\n\n this.context.append(this.template.content.cloneNode(true));\n\n if (this.noShow || (this.isPermissionCheck && !WjePermissionsApi.isPermissionFulfilled(this.permission))) {\n this.remove();\n return Promise.resolve();\n }\n\n return this._resolveRender();\n }\n\n /**\n * Renders the component's content.\n */\n async render() {\n this.drawingStatus = this.drawingStatuses.DRAWING;\n\n let _draw = this.draw(this.context, this.store, WjElementUtils.getAttributes(this));\n\n if (_draw instanceof Promise) {\n _draw = await _draw;\n }\n\n let rend = _draw;\n let element;\n\n if (rend instanceof HTMLElement || rend instanceof DocumentFragment) {\n element = rend;\n } else {\n let inputTemplate = document.createElement('template');\n inputTemplate.innerHTML = rend;\n element = inputTemplate.content.cloneNode(true);\n }\n\n let rendered = element;\n\n this.context.appendChild(rendered);\n }\n\n /**\n * Sanitizes a given name by converting it from kebab-case to camelCase.\n * @param {string} name The name in kebab-case format (e.g., \"example-name\").\n * @returns {string} The sanitized name in camelCase format (e.g., \"exampleName\").\n * @example\n * // Returns 'exampleName'\n * sanitizeName('example-name');\n * @example\n * // Returns 'myCustomComponent'\n * sanitizeName('my-custom-component');\n */\n sanitizeName(name) {\n let parts = name.split('-');\n return [parts.shift(), ...parts.map((n) => n[0].toUpperCase() + n.slice(1))].join('');\n }\n\n /**\n * Checks if a property on an object has a getter or setter method defined.\n * @param {object} obj The object on which the property is defined.\n * @param {string} property The name of the property to check.\n * @returns {object} An object indicating the presence of getter and setter methods.\n * @property {Function|null} hasGetter The getter function if it exists, otherwise `null`.\n * @property {Function|null} hasSetter The setter function if it exists, otherwise `null`.\n * @example\n * const obj = {\n * get name() { return 'value'; },\n * set name(val) { console.log(val); }\n * };\n * // Returns { hasGetter: [Function: get name], hasSetter: [Function: set name] }\n * checkGetterSetter(obj, 'name');\n * @example\n * const obj = { prop: 42 };\n * // Returns { hasGetter: null, hasSetter: null }\n * checkGetterSetter(obj, 'prop');\n */\n checkGetterSetter(obj, property) {\n let descriptor = Object.getOwnPropertyDescriptor(obj, property);\n\n // Check if the descriptor is found on the object itself\n if (descriptor) {\n return {\n hasGetter: typeof descriptor.get === 'function' ? descriptor.get : null,\n hasSetter: typeof descriptor.set === 'function' ? descriptor.set : null,\n };\n }\n\n // Otherwise, check the prototype chain\n let proto = Object.getPrototypeOf(obj);\n if (proto) {\n return this.checkGetterSetter(proto, property);\n }\n\n // If the property doesn't exist at all\n return { hasGetter: null, hasSetter: null };\n }\n\n /**\n * Sets up property accessors for the component's attributes.\n */\n setUpAccessors() {\n let attrs = this.getAttributeNames();\n attrs.forEach((name) => {\n const sanitizedName = this.sanitizeName(name);\n\n const { hasGetter, hasSetter } = this.checkGetterSetter(this, sanitizedName);\n\n Object.defineProperty(this, sanitizedName, {\n set: hasSetter ?? ((value) => this.setAttribute(name, value)),\n get: hasGetter ?? (() => this.getAttribute(name)),\n });\n });\n }\n\n /**\n * Resolves the rendering process of the component.\n * @returns A promise that resolves when rendering is complete.\n * @private\n */\n _resolveRender() {\n this.params = WjElementUtils.getAttributes(this);\n\n return new Promise(async (resolve, reject) => {\n const __beforeDraw = this.beforeDraw(this.context, this.store, WjElementUtils.getAttributes(this));\n\n if (__beforeDraw instanceof Promise) {\n await __beforeDraw;\n }\n\n await this.render();\n\n const __afterDraw = this.afterDraw?.(this.context, this.store, WjElementUtils.getAttributes(this));\n\n if (__afterDraw instanceof Promise) {\n await __afterDraw;\n }\n\n // RHR toto je bicykel pre slickRouter pretože routovanie nieje vykonané pokiaľ sa nezavolá updateComplete promise,\n // toto bude treba rozšíriť aby sme lepšie vedeli kontrolovať vykreslovanie elementov, a flow hookov.\n this.finisPromise();\n\n this.rendering = false;\n this.isAttached = true;\n\n if (this.removeClassAfterConnect) {\n this.classList.remove(...this.removeClassAfterConnect);\n }\n\n this.drawingStatus = this.drawingStatuses.DONE;\n\n resolve();\n }).catch((e) => {\n console.log(e);\n });\n }\n}\n\nlet __esModule = 'true';\nexport { __esModule, WjePermissionsApi, WjElementUtils, event };\n"],"names":["event"],"mappings":";;;;;;;;;;;AAAO,MAAM,iBAAiB;AAAA,EAC1B,YAAY,QAAQ,IAAI;AAIxB,qCAAY,CAAC,UAAU,KAAK,aAAa;AACrC,UAAI,KAAK,OAAO,SAAU,EAAC,QAAQ,aAAa,OAAO;AACnD,eAAO,KAAK,OAAO,SAAQ,EAAG,QAAQ,EAAE,KAAK,CAAC,SAAS,KAAK,GAAG,MAAM,QAAQ;AAAA,MACzF,OAAe;AACH,gBAAQ,KAAK,cAAc,QAAQ,eAAe;AAClD,eAAO;AAAA,MACnB;AAAA,IACK;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AAI,QAAQ,OAAO,SAAS,WAAW;;AAC1C,YAAM,eAAe,KAAK,WAAW,KAAK,SAAS,KAAK,OAAO,eAAe,cAAc,IAAI,CAAC;AAEjG,UAAI,wBAAwB,SAAS;AACjC,cAAM;AAAA,MACtB;AAEY,YAAM,KAAK,OAAQ;AAEnB,YAAM,eAAc,UAAK,cAAL,8BAAiB,KAAK,SAAS,KAAK,OAAO,eAAe,cAAc,IAAI;AAEhG,UAAI,uBAAuB,SAAS;AAChC,cAAM;AAAA,MACtB;AAIY,WAAK,aAAc;AAEnB,WAAK,YAAY;AACjB,WAAK,aAAa;AAElB,UAAI,KAAK,yBAAyB;AAC9B,aAAK,UAAU,OAAO,GAAG,KAAK,uBAAuB;AAAA,MACrE;AAEY,WAAK,gBAAgB,KAAK,gBAAgB;AAE1C,cAAS;AAAA,IACrB,CAAS,EAAE,MAAM,CAAC,MAAM;AACZ,cAAQ,IAAI,CAAC;AAAA,IACzB,CAAS;AAAA,EACT;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAjbI,cA/LiB,YA+LV,oBAAmB,CAAC,WAAW,kBAAkB;AACpD,QAAM,cAAc,SAAS,cAAc,UAAU;AACrD,cAAY,YAAY,CAAC,cAAc,YAAW,uCAAW,cAAa,EAAE,EAAE,KAAK,EAAE;AACrF,SAAO;AACV;AAnMU,IAAM,YAAN;AAknBZ,IAAC,aAAa;"}
1
+ {"version":3,"file":"wje-element.js","sources":["../packages/wje-element/service/universal-service.js","../packages/utils/permissions-api.js","../packages/utils/element-utils.js","../packages/utils/event.js","../packages/wje-element/element.js"],"sourcesContent":["export class UniversalService {\n constructor(props = {}) {\n this._store = props.store;\n }\n\n findByKey = (attrName, key, keyValue) => {\n if (this._store.getState()[attrName] instanceof Array) {\n return this._store.getState()[attrName].find((item) => item[key] === keyValue);\n } else {\n console.warn(` Attribute ${attrName} is not array`);\n return null;\n }\n };\n\n findById = (attrName, id) => {\n if (this._store.getState()[attrName] instanceof Array) {\n return this._store.getState()[attrName].find((item) => item.id === id);\n } else {\n console.warn(` Attribute ${attrName} is not array`);\n return null;\n }\n };\n\n findAttributeValue = (attrName) => {\n return this._store.getState()[attrName];\n };\n\n update = (data, action) => {\n this._store.dispatch(action(data));\n };\n\n add = (data, action) => {\n this._store.dispatch(action(data));\n };\n\n _save(url, data, action, dispatchMethod, method) {\n let promise = fetch(url, {\n method: method,\n body: JSON.stringify(data),\n headers: {\n 'Content-Type': 'application/json',\n },\n }).then((response) => {\n if (response.ok) {\n return response.json();\n } else {\n return response.json();\n }\n });\n\n return this.dispatch(promise, dispatchMethod, action);\n }\n\n _get(url, action, dispatchMethod, signal) {\n let promise = fetch(url, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n },\n ...(signal ? { signal } : {}),\n }).then(async (response) => {\n let responseText;\n try {\n responseText = await response.text();\n return JSON.parse(responseText);\n } catch (err) {\n console.error(err);\n return responseText;\n }\n });\n\n return this.dispatch(promise, dispatchMethod, action);\n }\n\n put(url, data, action, dispatchMethod = true) {\n return this._save(url, data, action, dispatchMethod, 'PUT');\n }\n\n post(url, data, action, dispatchMethod = true) {\n return this._save(url, data, action, dispatchMethod, 'POST');\n }\n\n delete(url, data, action, dispatchMethod = true) {\n return this._save(url, data, action, dispatchMethod, 'DELETE');\n }\n\n get(url, action, dispatchMethod = true) {\n return this._get(url, action, dispatchMethod);\n }\n\n dispatch(promise, dispatchMethod, action) {\n if (dispatchMethod) {\n return promise\n .then((data) => {\n this._store.dispatch(action(data.data));\n return data;\n })\n .catch((error) => {\n console.error(error);\n });\n }\n return promise;\n }\n\n loadPromise = (\n url,\n action,\n method = 'GET',\n data = '',\n permissionCallBack = () => {\n //\n // No empty function\n }\n ) => {\n return fetch(url, {\n method: method,\n body: data,\n headers: {\n 'Content-Type': 'application/json',\n },\n async: true,\n })\n .then((response, e) => {\n let permissions = response.headers.get('permissions')?.split(',');\n permissionCallBack(permissions);\n\n if (response.ok) {\n return response.json();\n } else {\n throw response.json();\n }\n })\n .then((responseData) => {\n this._store.dispatch(action(responseData));\n return responseData;\n });\n };\n\n loadOnePromise = (url, action) => {\n return fetch(url, {\n headers: {\n 'Content-Type': 'application/json',\n },\n }).then((response) => {\n const responseData = response.json();\n if (action) {\n this._store.dispatch(action(responseData));\n }\n return responseData;\n });\n };\n}\n","export class WjePermissionsApi {\n static _permissionKey = 'permissions';\n\n /**\n * Sets the permission key.\n * @param value\n */\n static set permissionKey(value) {\n WjePermissionsApi._permissionKey = value || 'permissions';\n }\n\n /**\n * Returns the permission key.\n * @returns {*|string}\n */\n static get permissionKey() {\n return WjePermissionsApi._permissionKey;\n }\n\n /**\n * Sets the permissions.\n * @param value\n */\n static set permissions(value) {\n window.localStorage.setItem(WjePermissionsApi.permissionKey, JSON.stringify(value));\n }\n\n /**\n * Returns the permissions.\n * @returns {string[]}\n */\n static get permissions() {\n return JSON.parse(window.localStorage.getItem(WjePermissionsApi.permissionKey)) || [];\n }\n\n /**\n * Checks if the permission is included.\n * @param key\n * @returns {boolean}\n */\n static includesKey(key) {\n return WjePermissionsApi.permissions.includes(key);\n }\n\n /**\n * Checks if the permission is fulfilled.\n * @returns {boolean}\n */\n static isPermissionFulfilled(permissions) {\n return permissions.some((perm) => WjePermissionsApi.permissions.includes(perm));\n }\n}\n","export class WjElementUtils {\n /**\n * This function creates an element.\n * @param element : HTMLElement - The element value.\n * @param object : Object - The object value.\n */\n static setAttributesToElement(element, object) {\n Object.entries(object).forEach(([key, value]) => {\n element.setAttribute(key, value);\n });\n }\n\n /**\n * This function gets the attributes from an element.\n * @param {string|HTMLElement} el The element or selector to retrieve attributes from.\n * @returns {object} - An object containing the element's attributes as key-value pairs.\n */\n static getAttributes(el) {\n if (typeof el === 'string') el = document.querySelector(el);\n\n return Array.from(el.attributes)\n .filter((a) => !a.name.startsWith('@'))\n .map((a) => [\n a.name\n .split('-')\n .map((s, i) => {\n if (i !== 0) {\n return s.charAt(0).toUpperCase() + s.slice(1);\n } else {\n return s;\n }\n })\n .join(''),\n a.value,\n ])\n .reduce((acc, attr) => {\n acc[attr[0]] = attr[1];\n return acc;\n }, {});\n }\n\n /**\n * This function gets the events from an element.\n * @param {string|HTMLElement} el The element or selector to retrieve events from.\n * @returns {Map<any, any>} - The map value.\n */\n static getEvents(el) {\n if (typeof el === 'string') el = document.querySelector(el);\n\n return Array.from(el.attributes)\n .filter((a) => a.name.startsWith('@wje'))\n .map((a) => [a.name.substring(3).split('-').join(''), a.value])\n .reduce((acc, attr) => {\n acc.set(attr[0], attr[1]);\n return acc;\n }, new Map());\n }\n\n /**\n * This function converts an object to a string.\n * @param {object} object The object to convert.\n * @returns {string} - The string value.\n */\n static attributesToString(object) {\n return Object.entries(object)\n .map(([key, value]) => {\n return `${key}=\"${value}\"`;\n })\n .join(' ');\n }\n\n /**\n * This function checks if the slot exists.\n * @param {string|HTMLElement} el The element or selector to check for slots.\n * @param slotName The slot name to check for.\n * @returns {boolean} - The boolean value.\n */\n static hasSlot(el, slotName = null) {\n let selector = slotName ? `[slot=\"${slotName}\"]` : '[slot]';\n\n return el.querySelectorAll(selector).length > 0 ? true : false;\n }\n\n /**\n * This function checks if the slot has content.\n * @param {string|HTMLElement} el The element or selector to check for slot content\n * @param slotName The slot name to check for.\n * @returns {boolean} - The boolean value.\n */\n static hasSlotContent(el, slotName = null) {\n let slotElement = el.querySelector(`slot`);\n if (slotName) {\n slotElement = el.querySelector(`slot[name=\"${slotName}\"]`);\n }\n\n if (slotElement) {\n const assignedElements = slotElement.assignedElements();\n return assignedElements.length > 0;\n }\n\n return false;\n }\n\n /**\n * This function converts a string to a boolean.\n * @param {string | object} value The value to convert to a boolean. If the value is a boolean, it will be returned as is.\n * @returns {boolean} - The boolean value.\n */\n static stringToBoolean(value) {\n if (typeof value === 'boolean') return value;\n\n return !['false', '0', 0].includes(value);\n }\n}\n","var self; // eslint-disable-line no-var\n\nclass Event {\n constructor() {\n this.customEventStorage = [];\n self = this;\n }\n\n /**\n * Dispatch event to the element and trigger the listener.\n * @param e\n */\n #dispatch(e) {\n let element = this;\n let record = self.findRecordByElement(element);\n let listeners = record.listeners[e.type];\n\n listeners.forEach((listener) => {\n self.dispatchCustomEvent(element, listener.event, {\n originalEvent: e?.type || null,\n context: element,\n event: self,\n });\n\n if (listener.options && listener.options.stopPropagation === true) e.stopPropagation();\n });\n }\n\n /**\n * Dispatch custom event to the element with the specified event name and detail.\n * @param element\n * @param event\n * @param detail\n */\n dispatchCustomEvent(element, event, detail) {\n element.dispatchEvent(\n new CustomEvent(event, {\n detail: detail || {\n context: element,\n event: self,\n },\n bubbles: true,\n composed: true,\n cancelable: true,\n })\n );\n }\n\n /**\n * Find record by element in the storage.\n * @param element\n * @returns {*}\n */\n\n findRecordByElement(element) {\n for (let index = 0, length = this.customEventStorage.length; index < length; index++) {\n let record = this.customEventStorage[index];\n\n if (element === record.element) {\n return record;\n }\n }\n\n return false;\n }\n\n /**\n * Add listener to the element. If the element is an array, the listener will be added to all elements in the array.\n * @param element\n * @param originalEvent\n * @param event\n * @param listener\n * @param options\n */\n addListener(element, originalEvent, event, listener, options) {\n if (!element) return;\n\n if (!Array.isArray(element)) element = [element];\n\n element.forEach((el) => {\n this.writeRecord(el, originalEvent, event, listener, options);\n });\n }\n\n /**\n * Write record to the storage.\n * @param element\n * @param originalEvent\n * @param event\n * @param listener\n * @param options\n */\n writeRecord(element, originalEvent, event, listener, options) {\n let record = this.findRecordByElement(element);\n\n if (record) {\n record.listeners[originalEvent] = record.listeners[originalEvent] || [];\n } else {\n record = {\n element: element,\n listeners: {},\n };\n\n // vytvorime object listeners pre kazdy original event zvlast\n record.listeners[originalEvent] = [];\n\n this.customEventStorage.push(record);\n }\n\n listener = listener || this.#dispatch;\n let obj = {\n listener: listener,\n options: options,\n event: event,\n };\n\n // skontrolujeme ci uz tento listener neexistuje\n if (!this.listenerExists(element, originalEvent, obj)) {\n record.listeners[originalEvent].push(obj);\n\n element.addEventListener(originalEvent, listener, options);\n } else {\n // in case we want to add the same listener multiple times trigger a warning for a better debugging\n // console.warn(\"Listener already exists\", element, originalEvent, listener);\n }\n }\n\n /**\n * Performs a deep equality check between two objects.\n * @param x The first object to compare.\n * @param y The second object to compare.\n * @returns - Returns `true` if the objects are deeply equal, `false` otherwise.\n */\n deepEqual(x, y) {\n return x && y && typeof x === 'object' && typeof x === typeof y\n ? Object.keys(x).length === Object.keys(y).length &&\n Object.keys(x).every((key) => this.deepEqual(x[key], y[key]))\n : x === y;\n }\n\n /**\n * Check if the listener already exists on the element.\n * @param element\n * @param event\n * @param listener\n * @returns\n */\n listenerExists(element, event, listener) {\n let record = this.findRecordByElement(element);\n return record.listeners[event].some((e) => this.deepEqual(e, listener));\n }\n\n /**\n * Remove listener from the element and delete the listener from the custom event storage.\n * @param element\n * @param originalEvent\n * @param event\n * @param listener\n * @param options\n */\n removeListener(element, originalEvent, event, listener, options) {\n let record = this.findRecordByElement(element);\n\n if (record && originalEvent in record.listeners) {\n let index = record.listeners[originalEvent].indexOf(listener);\n\n if (index !== -1) {\n record.listeners[originalEvent].splice(index, 1);\n }\n\n if (!record.listeners[originalEvent].length) {\n delete record.listeners[originalEvent];\n }\n }\n\n listener = listener || this.#dispatch;\n\n element.removeEventListener(originalEvent, listener, options);\n }\n\n /**\n * Remove all event listeners from the specified element and delete the element from the custom event storage.\n * @param {HTMLElement} element The element from which all listeners will be removed.\n */\n removeElement(element) {\n this.customEventStorage = this.customEventStorage.filter((e) => {\n return e.element !== element;\n });\n }\n\n // TODO\n createPromiseFromEvent(element, event) {\n return new Promise((resolve) => {\n let success = () => {\n element.removeEventListener(event, success);\n resolve();\n };\n\n element.addEventListener(event, success);\n });\n }\n}\n\nlet event = new Event();\nexport { event };\n","import { UniversalService } from './service/universal-service.js';\nimport { defaultStoreActions, store } from '../wje-store/store.js';\nimport { WjePermissionsApi } from '../utils/permissions-api.js';\nimport { WjElementUtils } from '../utils/element-utils.js';\nimport { event } from '../utils/event.js';\n\nconst template = document.createElement('template');\ntemplate.innerHTML = ``;\n\nexport default class WJElement extends HTMLElement {\n /**\n * Initializes a new instance of the WJElement class.\n */\n\n constructor() {\n super();\n\n this.isAttached = false;\n this.service = new UniversalService({\n store: store,\n });\n\n // definujeme vsetky zavislosti.\n // Do zavislosti patria len komponenty, ktore su zavisle od ktoreho je zavisly tento komponent\n this.defineDependencies();\n\n this.rendering = false;\n this._dependencies = {};\n\n /**\n * @typedef {CREATED | ATTACHED | BEGINING | START | DRAWING | DONE | DISCONNECTED} DrawingStatus\n * @property {number} CREATED - The component has been created.\n * @property {number} ATTACHED - The component has been attached to the DOM.\n * @property {number} BEGINING - The component is beginning to draw.\n * @property {number} START - The component has started drawing.\n * @property {number} DRAWING - The component is drawing.\n * @property {number} DONE - The component has finished drawing.\n * @property {number} DISCONNECTED - The component has been disconnected from the DOM.\n */\n this.drawingStatuses = {\n CREATED: 0,\n ATTACHED: 1,\n BEGINING: 2,\n START: 3,\n DRAWING: 4,\n DONE: 5,\n DISCONNECTED: 6,\n };\n\n this.drawingStatus = this.drawingStatuses.CREATED;\n }\n\n /**\n * Sets the value of the 'permission' attribute.\n * @param {string[]} value The value to set for the 'permission' attribute.\n */\n set permission(value) {\n this.setAttribute('permission', value.join(','));\n }\n\n /**\n * Gets the value of the 'permission-check' attribute.\n * @returns {string[]} The value of the 'permission' attribute.\n */\n get permission() {\n return this.getAttribute('permission')?.split(',') || [];\n }\n\n /**\n * Sets the 'permission-check' attribute.\n * @param {boolean} value The value to set for the 'permission-check' attribute.\n */\n set isPermissionCheck(value) {\n if (value) this.setAttribute('permission-check', '');\n else this.removeAttribute('permission-check');\n }\n\n /**\n * Checks if the 'permission-check' attribute is present.\n * @returns {boolean} True if the 'permission-check' attribute is present.\n */\n get isPermissionCheck() {\n return this.hasAttribute('permission-check');\n }\n\n set noShow(value) {\n if (value) this.setAttribute('no-show', '');\n else this.removeAttribute('no-show');\n }\n\n /**\n * Checks if the 'show' attribute is present.\n * @returns {boolean} True if the 'show' attribute is present.\n */\n get noShow() {\n return this.hasAttribute('no-show');\n }\n\n /**\n * Sets the 'shadow' attribute.\n * @param {string} value The value to set for the 'shadow' attribute.\n */\n set isShadowRoot(value) {\n return this.setAttribute('shadow', value);\n }\n\n get isShadowRoot() {\n return this.getAttribute('shadow');\n }\n\n /**\n * Checks if the 'shadow' attribute is present.\n * @returns {boolean} True if the 'shadow' attribute is present.\n */\n get hasShadowRoot() {\n return this.hasAttribute('shadow');\n }\n\n /**\n * Gets the value of the 'shadow' attribute or 'open' if not set.\n * @returns {string} The value of the 'shadow' attribute or 'open'.\n */\n get shadowType() {\n return this.getAttribute('shadow') || 'open';\n }\n\n /**\n * Gets the rendering context, either the shadow root or the component itself.\n * @returns The rendering context.\n */\n get context() {\n if (this.hasShadowRoot) {\n return this.shadowRoot;\n } else {\n return this;\n }\n }\n\n /**\n * Gets the store instance.\n * @returns {object} The store instance.\n */\n get store() {\n return store;\n }\n\n /**\n * @typedef {object} ArrayActions\n * @property {Function} addAction - Adds an item to the array.\n * @property {Function} deleteAction - Deletes an item from the array.\n * @property {Function} loadAction - Loads an array.\n * @property {Function} updateAction - Updates an item in the array.\n * @property {Function} addManyAction - Adds many items to the array.\n */\n\n /**\n * @typedef {object} ObjectActions\n * @property {Function} addAction - Replace old object with new object\n * @property {Function} deleteAction - Delete item based on key\n * @property {Function} updateAction - Update item based on key\n */\n\n /**\n * Gets the default store actions.\n * @returns The default store actions for arrays and objects.\n */\n get defaultStoreActions() {\n return defaultStoreActions;\n }\n\n /**\n * Gets the classes to be removed after the component is connected.\n * @returns An array of class names to remove.\n */\n get removeClassAfterConnect() {\n return this.getAttribute('remove-class-after-connect')?.split(' ');\n }\n\n /**\n * Sets the component dependencies.\n * @param value The dependencies to set.\n */\n set dependencies(value) {\n this._dependencies = value;\n }\n\n /**\n * Gets the component dependencies.\n * @returns The component dependencies.\n */\n get dependencies() {\n return this._dependencies;\n }\n\n /**\n * Processes and combines two templates into one.\n * @param pTemplate The primary template.\n * @param inputTemplate The secondary template.\n * @returns The combined template.\n */\n static processTemplates = (pTemplate, inputTemplate) => {\n const newTemplate = document.createElement('template');\n newTemplate.innerHTML = [inputTemplate.innerHTML, pTemplate?.innerHTML || ''].join('');\n return newTemplate;\n };\n\n /**\n * Defines a custom element if not already defined.\n * @param name The name of the custom element.\n * @param [elementConstructor] The constructor for the custom element.\n * @param [options] Additional options for defining the element.\n */\n static define(name, elementConstructor = this, options = {}) {\n const definedElement = customElements.get(name);\n\n if (!definedElement) {\n customElements.define(name, elementConstructor, options);\n }\n }\n\n /**\n * Defines component dependencies by registering custom elements.\n */\n defineDependencies() {\n if (this.dependencies)\n Object.entries(this.dependencies).forEach((name, component) => WJElement.define(name, component));\n }\n\n /**\n * Hook for extending behavior before drawing the component.\n * @param context The rendering context, usually the element's shadow root or main DOM element.\n * @param appStoreObj The global application store for managing state.\n * @param params Additional parameters or attributes for rendering the component.\n */\n beforeDraw(context, appStoreObj, params) {\n // Hook for extending behavior before drawing\n }\n\n /**\n * Renders the component within the provided context.\n * @param context The rendering context, usually the element's shadow root or main DOM element.\n * @param appStoreObj\n * @param params Additional parameters or attributes for rendering the component.\n * @returns This implementation does not render anything and returns `null`.\n * @description\n * The `draw` method is responsible for rendering the component's content.\n * Override this method in subclasses to define custom rendering logic.\n * @example\n * class MyComponent extends WJElement {\n * draw(context, appStoreObj, params) {\n * const div = document.createElement('div');\n * div.textContent = 'Hello, world!';\n * context.appendChild(div);\n * }\n * }\n */\n draw(context, appStoreObj, params) {\n return null;\n }\n\n /**\n * Hook for extending behavior after drawing the component.\n * @param context The rendering context, usually the element's shadow root or main DOM element.\n * @param appStoreObj The global application store for managing state.\n * @param params Additional parameters or attributes for rendering the component.\n */\n afterDraw(context, appStoreObj, params) {\n // Hook for extending behavior after drawing\n }\n\n /**\n * Refreshes the update promise for rendering lifecycle management.\n */\n refreshUpdatePromise() {\n if (this.updateComplete) {\n this.rejectPromise('Update cancelled');\n }\n\n this.updateComplete = new Promise((resolve, reject) => {\n this.finisPromise = resolve;\n this.rejectPromise = reject;\n }).catch((e) => {\n // console.log(e);\n })\n }\n\n /**\n * Lifecycle method invoked when the component is connected to the DOM.\n */\n connectedCallback() {\n this.drawingStatus = this.drawingStatuses.ATTACHED;\n\n // RHR toto sa tiež týka slick routeru pretože on začal routovanie ešte pred vykreslením wjelementu\n this.refreshUpdatePromise();\n\n this.renderPromise = this.initWjElement(true);\n }\n\n /**\n * Initializes the component, setting up attributes and rendering.\n * @param [force] Whether to force initialization.\n * @returns A promise that resolves when initialization is complete.\n */\n initWjElement = (force = false) => {\n return new Promise(async (resolve, reject) => {\n this.drawingStatus = this.drawingStatuses.BEGINING;\n\n this.setupAttributes?.();\n if (this.hasShadowRoot) {\n if (!this.shadowRoot) this.attachShadow({ mode: this.shadowType || 'open' });\n }\n\n this.setUpAccessors();\n\n this.drawingStatus = this.drawingStatuses.START;\n await this.display(force);\n\n resolve();\n });\n };\n\n /**\n * Sets up attributes and event listeners for the component.\n * This method retrieves all custom events defined for the component\n * and adds event listeners for each of them. When an event is triggered,\n * it calls the corresponding method on the host element.\n */\n setupAttributes() {\n // Keď neaký element si zadefinuje funkciu \"setupAttributes\" tak sa obsah tejto funkcie nezavolá\n\n let allEvents = WjElementUtils.getEvents(this);\n allEvents.forEach((customEvent, domEvent) => {\n this.addEventListener(domEvent, (e) => {\n this.getRootNode().host[customEvent]?.();\n });\n });\n }\n\n /**\n * Hook for extending behavior before disconnecting the component.\n */\n beforeDisconnect() {\n // Hook for extending behavior before disconnecting\n }\n\n /**\n * Hook for extending behavior after disconnecting the component.\n */\n afterDisconnect() {\n // Hook for extending behavior after disconnecting\n }\n\n /**\n * Hook for extending behavior before redrawing the component.\n */\n beforeRedraw() {\n // Hook for extending behavior before redrawing\n }\n\n /**\n * Cleans up resources and event listeners for the component.\n */\n componentCleanup() {\n // Hook for cleaning up the component\n }\n\n /**\n * Lifecycle method invoked when the component is disconnected from the DOM.\n */\n disconnectedCallback() {\n this.beforeDisconnect?.();\n\n if (this.isAttached) this.context.innerHTML = '';\n this.isAttached = false;\n\n this.afterDisconnect?.();\n\n this.drawingStatus = this.drawingStatuses.DISCONNECTED;\n\n this.componentCleanup();\n }\n\n\n async processCurrentRenderPromise() {\n try {\n if (this.renderPromise && (this.renderPromise instanceof Promise || this.renderPromise?.constructor.name === \"Promise\")) {\n await this.renderPromise;\n }\n } catch (e) {\n console.error('An error occurred:', e);\n Promise.reject(e);\n }\n }\n\n /**\n * Enqueues an update to the component.\n * @returns A promise that resolves when the update is complete.\n */\n async enqueueUpdate() {\n await this.processCurrentRenderPromise();\n\n const result = this._refresh();\n\n if (result !== null) {\n await result;\n }\n\n this.renderPromise = null;\n }\n\n /**\n * Lifecycle method invoked when an observed attribute changes.\n * @param name The name of the attribute that changed.\n * @param old The old value of the attribute.\n * @param newName The new value of the attribute.\n */\n attributeChangedCallback(name, old, newName) {\n if (old !== newName) {\n this.renderPromise = this.enqueueUpdate();\n }\n }\n\n refresh() {\n this.renderPromise = this.enqueueUpdate();\n }\n\n /**\n * Refreshes the component by reinitializing it if it is in a drawing state.\n * This method checks if the component's drawing status is at least in the START state.\n * If so, it performs the following steps:\n * 1. Calls the `beforeRedraw` hook if defined.\n * 2. Calls the `beforeDisconnect` hook if defined.\n * 3. Refreshes the update promise to manage the rendering lifecycle.\n * 4. Calls the `afterDisconnect` hook if defined.\n * 5. Reinitializes the component by calling `initWjElement` with `true` to force initialization.\n * If the component is not in a drawing state, it simply returns a resolved promise.\n * @returns {Promise<void>} A promise that resolves when the refresh is complete.\n */\n _refresh() {\n if (this.drawingStatus && this.drawingStatus >= this.drawingStatuses.START) {\n this.beforeRedraw?.();\n this.beforeDisconnect?.();\n this.refreshUpdatePromise();\n this.afterDisconnect?.();\n\n return this.initWjElement(true);\n }\n\n return Promise.resolve();\n }\n\n /**\n * Renders the component within the provided context.\n * @param context The rendering context, usually the element's shadow root or main DOM element.\n * @param appStore The global application store for managing state.\n * @param params Additional parameters or attributes for rendering the component.\n * @returns This implementation does not render anything and returns `null`.\n * @description\n * The `draw` method is responsible for rendering the component's content.\n * Override this method in subclasses to define custom rendering logic.\n * @example\n * class MyComponent extends WJElement {\n * draw(context, appStore, params) {\n * const div = document.createElement('div');\n * div.textContent = 'Hello, world!';\n * context.appendChild(div);\n * }\n * }\n */\n draw(context, appStore, params) {\n return null;\n }\n\n /**\n * Displays the component's content, optionally forcing a re-render.\n * @param [force] Whether to force a re-render.\n * @returns A promise that resolves when the display is complete.\n */\n display(force = false) {\n this.template = this.constructor.customTemplate || document.createElement('template');\n\n if (force) {\n [...this.context.childNodes].forEach(this.context.removeChild.bind(this.context));\n this.isAttached = false;\n }\n\n this.context.append(this.template.content.cloneNode(true));\n\n if (this.noShow || (this.isPermissionCheck && !WjePermissionsApi.isPermissionFulfilled(this.permission))) {\n this.remove();\n return Promise.resolve();\n }\n\n return this._resolveRender();\n }\n\n /**\n * Renders the component's content.\n */\n async render() {\n this.drawingStatus = this.drawingStatuses.DRAWING;\n\n let _draw = this.draw(this.context, this.store, WjElementUtils.getAttributes(this));\n\n if (_draw instanceof Promise || _draw?.constructor.name === \"Promise\") {\n _draw = await _draw;\n }\n\n let rend = _draw;\n let element;\n\n if (rend instanceof HTMLElement || rend instanceof DocumentFragment) {\n element = rend;\n } else {\n let inputTemplate = document.createElement('template');\n inputTemplate.innerHTML = rend;\n element = inputTemplate.content.cloneNode(true);\n }\n\n let rendered = element;\n\n this.context.appendChild(rendered);\n }\n\n /**\n * Sanitizes a given name by converting it from kebab-case to camelCase.\n * @param {string} name The name in kebab-case format (e.g., \"example-name\").\n * @returns {string} The sanitized name in camelCase format (e.g., \"exampleName\").\n * @example\n * // Returns 'exampleName'\n * sanitizeName('example-name');\n * @example\n * // Returns 'myCustomComponent'\n * sanitizeName('my-custom-component');\n */\n sanitizeName(name) {\n let parts = name.split('-');\n return [parts.shift(), ...parts.map((n) => n[0].toUpperCase() + n.slice(1))].join('');\n }\n\n /**\n * Checks if a property on an object has a getter or setter method defined.\n * @param {object} obj The object on which the property is defined.\n * @param {string} property The name of the property to check.\n * @returns {object} An object indicating the presence of getter and setter methods.\n * @property {Function|null} hasGetter The getter function if it exists, otherwise `null`.\n * @property {Function|null} hasSetter The setter function if it exists, otherwise `null`.\n * @example\n * const obj = {\n * get name() { return 'value'; },\n * set name(val) { console.log(val); }\n * };\n * // Returns { hasGetter: [Function: get name], hasSetter: [Function: set name] }\n * checkGetterSetter(obj, 'name');\n * @example\n * const obj = { prop: 42 };\n * // Returns { hasGetter: null, hasSetter: null }\n * checkGetterSetter(obj, 'prop');\n */\n checkGetterSetter(obj, property) {\n let descriptor = Object.getOwnPropertyDescriptor(obj, property);\n\n // Check if the descriptor is found on the object itself\n if (descriptor) {\n return {\n hasGetter: typeof descriptor.get === 'function' ? descriptor.get : null,\n hasSetter: typeof descriptor.set === 'function' ? descriptor.set : null,\n };\n }\n\n // Otherwise, check the prototype chain\n let proto = Object.getPrototypeOf(obj);\n if (proto) {\n return this.checkGetterSetter(proto, property);\n }\n\n // If the property doesn't exist at all\n return { hasGetter: null, hasSetter: null };\n }\n\n /**\n * Sets up property accessors for the component's attributes.\n */\n setUpAccessors() {\n let attrs = this.getAttributeNames();\n attrs.forEach((name) => {\n const sanitizedName = this.sanitizeName(name);\n\n const { hasGetter, hasSetter } = this.checkGetterSetter(this, sanitizedName);\n\n Object.defineProperty(this, sanitizedName, {\n set: hasSetter ?? ((value) => this.setAttribute(name, value)),\n get: hasGetter ?? (() => this.getAttribute(name)),\n });\n });\n }\n\n /**\n * Resolves the rendering process of the component.\n * @returns A promise that resolves when rendering is complete.\n * @private\n */\n _resolveRender() {\n this.params = WjElementUtils.getAttributes(this);\n\n return new Promise(async (resolve, reject) => {\n const __beforeDraw = this.beforeDraw(this.context, this.store, WjElementUtils.getAttributes(this));\n\n if (__beforeDraw instanceof Promise || __beforeDraw?.constructor.name === \"Promise\") {\n await __beforeDraw;\n }\n\n // APPEND CSS HERE\n const sheet = new CSSStyleSheet();\n sheet.replaceSync(this.constructor.cssStyleSheet);\n\n this.context.adoptedStyleSheets = [sheet];\n\n await this.render();\n\n const __afterDraw = this.afterDraw?.(this.context, this.store, WjElementUtils.getAttributes(this));\n\n if (__afterDraw instanceof Promise || __afterDraw?.constructor.name === \"Promise\") {\n await __afterDraw;\n }\n\n // RHR toto je bicykel pre slickRouter pretože routovanie nieje vykonané pokiaľ sa nezavolá updateComplete promise,\n // toto bude treba rozšíriť aby sme lepšie vedeli kontrolovať vykreslovanie elementov, a flow hookov.\n this.finisPromise();\n\n this.rendering = false;\n this.isAttached = true;\n\n if (this.removeClassAfterConnect) {\n this.classList.remove(...this.removeClassAfterConnect);\n }\n\n this.drawingStatus = this.drawingStatuses.DONE;\n\n resolve();\n }).catch((e) => {\n console.log(e);\n });\n }\n}\n\nlet __esModule = 'true';\nexport { __esModule, WjePermissionsApi, WjElementUtils, event };\n"],"names":["event"],"mappings":";;;;;;;;;;;AAAO,MAAM,iBAAiB;AAAA,EAC1B,YAAY,QAAQ,IAAI;AAIxB,qCAAY,CAAC,UAAU,KAAK,aAAa;AACrC,UAAI,KAAK,OAAO,SAAU,EAAC,QAAQ,aAAa,OAAO;AACnD,eAAO,KAAK,OAAO,SAAQ,EAAG,QAAQ,EAAE,KAAK,CAAC,SAAS,KAAK,GAAG,MAAM,QAAQ;AAAA,MACzF,OAAe;AACH,gBAAQ,KAAK,cAAc,QAAQ,eAAe;AAClD,eAAO;AAAA,MACnB;AAAA,IACK;AAED,oCAAW,CAAC,UAAU,OAAO;AACzB,UAAI,KAAK,OAAO,SAAU,EAAC,QAAQ,aAAa,OAAO;AACnD,eAAO,KAAK,OAAO,SAAQ,EAAG,QAAQ,EAAE,KAAK,CAAC,SAAS,KAAK,OAAO,EAAE;AAAA,MACjF,OAAe;AACH,gBAAQ,KAAK,cAAc,QAAQ,eAAe;AAClD,eAAO;AAAA,MACnB;AAAA,IACK;AAED,8CAAqB,CAAC,aAAa;AAC/B,aAAO,KAAK,OAAO,SAAQ,EAAG,QAAQ;AAAA,IACzC;AAED,kCAAS,CAAC,MAAM,WAAW;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ExC,YAAM,KAAK,OAAQ;AAEnB,YAAM,eAAc,UAAK,cAAL,8BAAiB,KAAK,SAAS,KAAK,OAAO,eAAe,cAAc,IAAI;AAEhG,UAAI,uBAAuB,YAAW,2CAAa,YAAY,UAAS,WAAW;AAC/E,cAAM;AAAA,MACtB;AAIY,WAAK,aAAc;AAEnB,WAAK,YAAY;AACjB,WAAK,aAAa;AAElB,UAAI,KAAK,yBAAyB;AAC9B,aAAK,UAAU,OAAO,GAAG,KAAK,uBAAuB;AAAA,MACrE;AAEY,WAAK,gBAAgB,KAAK,gBAAgB;AAE1C,cAAS;AAAA,IACrB,CAAS,EAAE,MAAM,CAAC,MAAM;AACZ,cAAQ,IAAI,CAAC;AAAA,IACzB,CAAS;AAAA,EACT;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA5bI,cA/LiB,YA+LV,oBAAmB,CAAC,WAAW,kBAAkB;AACpD,QAAM,cAAc,SAAS,cAAc,UAAU;AACrD,cAAY,YAAY,CAAC,cAAc,YAAW,uCAAW,cAAa,EAAE,EAAE,KAAK,EAAE;AACrF,SAAO;AACV;AAnMU,IAAM,YAAN;AA6nBZ,IAAC,aAAa;"}
package/dist/wje-img.js CHANGED
@@ -32,10 +32,10 @@ class Img extends WJElement {
32
32
  * @function onerrorFunc
33
33
  * @memberof Img
34
34
  */
35
- __publicField(this, "onerrorFunc", () => {
35
+ __publicField(this, "onerrorFunc", (img) => {
36
36
  if (!this.fallout) return;
37
37
  if (this.actions[this.fallout]) {
38
- this.native.onerror = this.actions[this.fallout];
38
+ img.onerror = this.actions[this.fallout];
39
39
  } else {
40
40
  console.error("Unsupported value:", this.fallout);
41
41
  }
@@ -46,6 +46,34 @@ class Img extends WJElement {
46
46
  log: () => console.error("Error log pre obrázok:", this.src)
47
47
  };
48
48
  }
49
+ /**
50
+ * Sets the value of the `src` attribute for the element.
51
+ * @param {string} value The value to set for the `src` attribute.
52
+ */
53
+ set src(value) {
54
+ this.setAttribute("src", value);
55
+ }
56
+ /**
57
+ * Retrieves the value of the 'src' attribute from the element.
58
+ * @returns {string} The value of the 'src' attribute.
59
+ */
60
+ get src() {
61
+ return this.getAttribute("src");
62
+ }
63
+ /**
64
+ * Sets the value of the 'alt' attribute for the element.
65
+ * @param {string} value The new value to set for the 'alt' attribute.
66
+ */
67
+ set alt(value) {
68
+ this.setAttribute("alt", value);
69
+ }
70
+ /**
71
+ * Retrieves the value of the 'alt' attribute for the current element.
72
+ * @returns {string|null} The value of the 'alt' attribute, or null if the attribute is not set.
73
+ */
74
+ get alt() {
75
+ return this.getAttribute("alt");
76
+ }
49
77
  /**
50
78
  * Sets the fallout property. Updates the `fallout` attribute if the value is a string;
51
79
  * otherwise, assigns the value to the `_fallout` property.
@@ -95,7 +123,7 @@ class Img extends WJElement {
95
123
  * @returns {Array<string>}
96
124
  */
97
125
  static get observedAttributes() {
98
- return ["src"];
126
+ return [];
99
127
  }
100
128
  /**
101
129
  * Sets up the attributes for the component.
@@ -114,6 +142,7 @@ class Img extends WJElement {
114
142
  native.setAttribute("src", this.loader || "./assets/img/image-loader.gif");
115
143
  native.setAttribute("alt", this.alt || "");
116
144
  native.classList.add("lazy-loaded-image", "lazy");
145
+ this.onerrorFunc(native);
117
146
  this.native = native;
118
147
  fragment.appendChild(native);
119
148
  return fragment;
@@ -126,7 +155,6 @@ class Img extends WJElement {
126
155
  * @returns {void} Does not return a value.
127
156
  */
128
157
  afterDraw() {
129
- this.onerrorFunc();
130
158
  let lazyImageObserver = new IntersectionObserver((entries, observer) => {
131
159
  entries.forEach((entry) => {
132
160
  if (entry.isIntersecting) {
@@ -1 +1 @@
1
- {"version":3,"file":"wje-img.js","sources":["../packages/wje-img/img.element.js","../packages/wje-img/img.js"],"sourcesContent":["import { default as WJElement } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary This element represents an image. `Img` is a custom web component that represents an image. It extends from `WJElement`.\n * @documentation https://elements.webjet.sk/components/img\n * @status stable\n * @augments {WJElement}\n * @cssproperty --img-width - The width of the image\n * @cssproperty --img-height - The height of the image\n * @property {string} src - The source URL of the image.\n * @property {string} alt - The alternative text for the image.\n * @property {string} fallout - The action to perform when an error occurs while loading the image. The value can be a function or a predefined action like 'delete'.\n * @property {string} loader - The URL of the image loader to display while the image is loading.\n * @tag wje-img\n */\nexport default class Img extends WJElement {\n /**\n * Creates an instance of Img.\n * @class\n */\n constructor() {\n super();\n\n this._fallout = false;\n\n this.actions = {\n delete: () => this.deleteImage(),\n log: () => console.error('Error log pre obrázok:', this.src),\n }\n }\n\n /**\n * Sets the fallout property. Updates the `fallout` attribute if the value is a string;\n * otherwise, assigns the value to the `_fallout` property.\n * @param {string|*} value The value to set for the fallout property. If a string, it will update the `fallout` attribute; for other types, it will assign it to the `_fallout` property.\n */\n set fallout(value) {\n if (typeof value === 'string') {\n this.setAttribute('fallout', value);\n } else {\n this._fallout = value;\n }\n }\n\n /**\n * Retrieves the value of the 'fallout' attribute if it exists, otherwise returns the internal `_fallout` property.\n * @returns {string|null} The value of the 'fallout' attribute or the `_fallout` property if the attribute is not present. Returns null if no value is found.\n */\n get fallout() {\n return this.hasAttribute('fallout') ? this.getAttribute('fallout') : this._fallout;\n }\n\n /**\n * Sets the value of the loader attribute.\n * @param {string} value The value to set for the loader attribute.\n */\n set loader(value) {\n if (value) {\n this.setAttribute('loader', value);\n }\n }\n\n /**\n * Retrieves the value of the 'loader' attribute from the element.\n * @returns {string|null} The value of the 'loader' attribute if set, otherwise null.\n */\n get loader() {\n return this.getAttribute('loader');\n }\n\n /**\n * The class name for the component.\n * @type {string}\n */\n className = 'Img';\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 ['src'];\n }\n\n /**\n * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Creates and assembles a lazy-loaded image element within a document fragment.\n * @returns {DocumentFragment} A document fragment containing the image element.\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('img');\n native.setAttribute('part', 'native');\n native.setAttribute('src', this.loader || './assets/img/image-loader.gif');\n native.setAttribute('alt', this.alt || '');\n native.classList.add('lazy-loaded-image', 'lazy');\n\n this.native = native;\n fragment.appendChild(native);\n\n return fragment;\n }\n\n /**\n * Handles post-draw operations, such as setting up a lazy image loader using an IntersectionObserver.\n * Observes when the target element becomes visible in the viewport and updates its source with the provided image source.\n * Removes the `lazy` class once the image source is updated and unobserves the element.\n * It also invokes the `onerrorFunc` method at the beginning to handle potential error scenarios.\n * @returns {void} Does not return a value.\n */\n afterDraw() {\n this.onerrorFunc();\n\n let lazyImageObserver = new IntersectionObserver((entries, observer) => {\n entries.forEach((entry) => {\n if (entry.isIntersecting) {\n entry.target.src = this.src;\n this.classList.remove('lazy');\n lazyImageObserver.unobserve(entry.target);\n }\n });\n });\n\n lazyImageObserver.observe(this.native);\n }\n\n /**\n * Deletes the current image by calling the remove method.\n * This function is typically used to trigger the removal of an image element\n * or perform cleanup operations related to the image.\n */\n deleteImage = () => {\n this.remove();\n }\n\n /**\n * Adds a new action to the internal actions object.\n * @param {string} name The name of the action to be added.\n * @param {Function} func The function representing the action logic.\n * @returns {void} This method does not return a value.\n */\n addAction(name, func) {\n if (typeof func === 'function') {\n this.actions[name] = func;\n } else {\n console.error('The action must be a function.');\n }\n }\n\n /**\n * Removes an action from the actions list if it exists.\n * @param {string} name The name of the action to remove.\n * @returns {void} Does not return a value.\n */\n removeAction(name) {\n if (this.actions[name]) {\n delete this.actions[name];\n } else {\n console.error(`Action \"${name}\" does not exist.`);\n }\n }\n\n\n /**\n * Handles error scenarios by checking the `fallout` property and performing\n * corresponding actions. If `fallout` is not defined, the function terminates\n * early. Logs the active actions and attempts to assign an error handler\n * based on the `fallout` value. If the `fallout` value does not correspond to\n * a recognized action, it logs an error message.\n * @function onerrorFunc\n * @memberof Img\n */\n onerrorFunc = () => {\n if (!this.fallout) return;\n if (this.actions[this.fallout]) {\n this.native.onerror = this.actions[this.fallout];\n } else {\n console.error('Unsupported value:', this.fallout);\n }\n }\n}\n","import Img from './img.element.js';\n\nexport default Img;\n\nImg.define('wje-img', Img);\n"],"names":[],"mappings":";;;;;AAgBe,MAAM,YAAY,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA,EAKvC,cAAc;AACV,UAAO;AAqDX;AAAA;AAAA;AAAA;AAAA,qCAAY;AA0EZ;AAAA;AAAA;AAAA;AAAA;AAAA,uCAAc,MAAM;AAChB,WAAK,OAAQ;AAAA,IACrB;AAuCI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uCAAc,MAAM;AAChB,UAAI,CAAC,KAAK,QAAS;AACnB,UAAI,KAAK,QAAQ,KAAK,OAAO,GAAG;AAC5B,aAAK,OAAO,UAAU,KAAK,QAAQ,KAAK,OAAO;AAAA,MAC3D,OAAe;AACH,gBAAQ,MAAM,sBAAsB,KAAK,OAAO;AAAA,MAC5D;AAAA,IACA;AA7KQ,SAAK,WAAW;AAEhB,SAAK,UAAU;AAAA,MACX,QAAQ,MAAM,KAAK,YAAa;AAAA,MAChC,KAAK,MAAM,QAAQ,MAAM,0BAA0B,KAAK,GAAG;AAAA,IACvE;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOI,IAAI,QAAQ,OAAO;AACf,QAAI,OAAO,UAAU,UAAU;AAC3B,WAAK,aAAa,WAAW,KAAK;AAAA,IAC9C,OAAe;AACH,WAAK,WAAW;AAAA,IAC5B;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,UAAU;AACV,WAAO,KAAK,aAAa,SAAS,IAAI,KAAK,aAAa,SAAS,IAAI,KAAK;AAAA,EAClF;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,OAAO,OAAO;AACd,QAAI,OAAO;AAC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C,OAAe;AACH,cAAQ,MAAM,gCAAgC;AAAA,IAC1D;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOI,aAAa,MAAM;AACf,QAAI,KAAK,QAAQ,IAAI,GAAG;AACpB,aAAO,KAAK,QAAQ,IAAI;AAAA,IACpC,OAAe;AACH,cAAQ,MAAM,WAAW,IAAI,mBAAmB;AAAA,IAC5D;AAAA,EACA;AAoBA;AClMA,IAAI,OAAO,WAAW,GAAG;"}
1
+ {"version":3,"file":"wje-img.js","sources":["../packages/wje-img/img.element.js","../packages/wje-img/img.js"],"sourcesContent":["import { default as WJElement } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary This element represents an image. `Img` is a custom web component that represents an image. It extends from `WJElement`.\n * @documentation https://elements.webjet.sk/components/img\n * @status stable\n * @augments {WJElement}\n * @cssproperty --img-width - The width of the image\n * @cssproperty --img-height - The height of the image\n * @property {string} src - The source URL of the image.\n * @property {string} alt - The alternative text for the image.\n * @property {string} fallout - The action to perform when an error occurs while loading the image. The value can be a function or a predefined action like 'delete'.\n * @property {string} loader - The URL of the image loader to display while the image is loading.\n * @tag wje-img\n */\nexport default class Img extends WJElement {\n /**\n * Creates an instance of Img.\n * @class\n */\n constructor() {\n super();\n\n this._fallout = false;\n\n this.actions = {\n delete: () => this.deleteImage(),\n log: () => console.error('Error log pre obrázok:', this.src),\n }\n }\n\n /**\n * Sets the value of the `src` attribute for the element.\n * @param {string} value The value to set for the `src` attribute.\n */\n set src(value) {\n this.setAttribute('src', value);\n }\n\n /**\n * Retrieves the value of the 'src' attribute from the element.\n * @returns {string} The value of the 'src' attribute.\n */\n get src() {\n return this.getAttribute('src');\n }\n\n /**\n * Sets the value of the 'alt' attribute for the element.\n * @param {string} value The new value to set for the 'alt' attribute.\n */\n set alt(value) {\n this.setAttribute('alt', value);\n }\n\n /**\n * Retrieves the value of the 'alt' attribute for the current element.\n * @returns {string|null} The value of the 'alt' attribute, or null if the attribute is not set.\n */\n get alt() {\n return this.getAttribute('alt');\n }\n\n /**\n * Sets the fallout property. Updates the `fallout` attribute if the value is a string;\n * otherwise, assigns the value to the `_fallout` property.\n * @param {string|*} value The value to set for the fallout property. If a string, it will update the `fallout` attribute; for other types, it will assign it to the `_fallout` property.\n */\n set fallout(value) {\n if (typeof value === 'string') {\n this.setAttribute('fallout', value);\n } else {\n this._fallout = value;\n }\n }\n\n /**\n * Retrieves the value of the 'fallout' attribute if it exists, otherwise returns the internal `_fallout` property.\n * @returns {string|null} The value of the 'fallout' attribute or the `_fallout` property if the attribute is not present. Returns null if no value is found.\n */\n get fallout() {\n return this.hasAttribute('fallout') ? this.getAttribute('fallout') : this._fallout;\n }\n\n /**\n * Sets the value of the loader attribute.\n * @param {string} value The value to set for the loader attribute.\n */\n set loader(value) {\n if (value) {\n this.setAttribute('loader', value);\n }\n }\n\n /**\n * Retrieves the value of the 'loader' attribute from the element.\n * @returns {string|null} The value of the 'loader' attribute if set, otherwise null.\n */\n get loader() {\n return this.getAttribute('loader');\n }\n\n /**\n * The class name for the component.\n * @type {string}\n */\n className = 'Img';\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 * Creates and assembles a lazy-loaded image element within a document fragment.\n * @returns {DocumentFragment} A document fragment containing the image element.\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('img');\n native.setAttribute('part', 'native');\n native.setAttribute('src', this.loader || './assets/img/image-loader.gif');\n native.setAttribute('alt', this.alt || '');\n native.classList.add('lazy-loaded-image', 'lazy');\n\n this.onerrorFunc(native);\n\n this.native = native;\n\n fragment.appendChild(native);\n\n return fragment;\n }\n\n /**\n * Handles post-draw operations, such as setting up a lazy image loader using an IntersectionObserver.\n * Observes when the target element becomes visible in the viewport and updates its source with the provided image source.\n * Removes the `lazy` class once the image source is updated and unobserves the element.\n * It also invokes the `onerrorFunc` method at the beginning to handle potential error scenarios.\n * @returns {void} Does not return a value.\n */\n afterDraw() {\n\n\n let lazyImageObserver = new IntersectionObserver((entries, observer) => {\n entries.forEach((entry) => {\n if (entry.isIntersecting) {\n // console.log(\"SRC INTERSECTING\", this.src, entry.target);\n entry.target.src = this.src;\n this.classList.remove('lazy');\n lazyImageObserver.unobserve(entry.target);\n }\n });\n });\n\n lazyImageObserver.observe(this.native);\n }\n\n /**\n * Deletes the current image by calling the remove method.\n * This function is typically used to trigger the removal of an image element\n * or perform cleanup operations related to the image.\n */\n deleteImage = () => {\n this.remove();\n }\n\n /**\n * Adds a new action to the internal actions object.\n * @param {string} name The name of the action to be added.\n * @param {Function} func The function representing the action logic.\n * @returns {void} This method does not return a value.\n */\n addAction(name, func) {\n if (typeof func === 'function') {\n this.actions[name] = func;\n } else {\n console.error('The action must be a function.');\n }\n }\n\n /**\n * Removes an action from the actions list if it exists.\n * @param {string} name The name of the action to remove.\n * @returns {void} Does not return a value.\n */\n removeAction(name) {\n if (this.actions[name]) {\n delete this.actions[name];\n } else {\n console.error(`Action \"${name}\" does not exist.`);\n }\n }\n\n\n /**\n * Handles error scenarios by checking the `fallout` property and performing\n * corresponding actions. If `fallout` is not defined, the function terminates\n * early. Logs the active actions and attempts to assign an error handler\n * based on the `fallout` value. If the `fallout` value does not correspond to\n * a recognized action, it logs an error message.\n * @function onerrorFunc\n * @memberof Img\n */\n onerrorFunc = (img) => {\n // console.log(img, this.fallout);\n if (!this.fallout) return;\n if (this.actions[this.fallout]) {\n img.onerror = this.actions[this.fallout];\n } else {\n console.error('Unsupported value:', this.fallout);\n }\n }\n}\n","import Img from './img.element.js';\n\nexport default Img;\n\nImg.define('wje-img', Img);\n"],"names":[],"mappings":";;;;;AAgBe,MAAM,YAAY,UAAU;AAAA;A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;AAAA;AAAA;AAAA;AAAA;AAAA,EAiBI,UAAU,MAAM,MAAM;AAClB,QAAI,OAAO,SAAS,YAAY;AAC5B,WAAK,QAAQ,IAAI,IAAI;AAAA,IACjC,OAAe;AACH,cAAQ,MAAM,gCAAgC;AAAA,IAC1D;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOI,aAAa,MAAM;AACf,QAAI,KAAK,QAAQ,IAAI,GAAG;AACpB,aAAO,KAAK,QAAQ,IAAI;AAAA,IACpC,OAAe;AACH,cAAQ,MAAM,WAAW,IAAI,mBAAmB;AAAA,IAC5D;AAAA,EACA;AAqBA;ACvOA,IAAI,OAAO,WAAW,GAAG;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "wj-elements",
3
3
  "description": "WebJET Elements is a modern set of user interface tools harnessing the power of web components designed to simplify web application development.",
4
- "version": "0.1.145",
4
+ "version": "0.1.147",
5
5
  "homepage": "https://github.com/lencys/wj-elements",
6
6
  "author": "Lukáš Ondrejček <lukas.ondrejcek@gmail.com>",
7
7
  "license": "MIT",