wj-elements 0.1.241 → 0.1.243
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/packages/wje-element/element.d.ts +1 -0
- package/dist/wje-button.js +11 -4
- package/dist/wje-button.js.map +1 -1
- package/dist/wje-element.js +51 -25
- package/dist/wje-element.js.map +1 -1
- package/dist/wje-img.js +25 -6
- package/dist/wje-img.js.map +1 -1
- package/package.json +1 -1
|
@@ -18,6 +18,7 @@ export default class WJElement extends HTMLElement {
|
|
|
18
18
|
* @param [options] Additional options for defining the element.
|
|
19
19
|
*/
|
|
20
20
|
static define(name: any, elementConstructor?: typeof WJElement, options?: {}): void;
|
|
21
|
+
__templateInserted: boolean;
|
|
21
22
|
service: UniversalService;
|
|
22
23
|
_dependencies: {};
|
|
23
24
|
/**
|
package/dist/wje-button.js
CHANGED
|
@@ -356,16 +356,23 @@ class Button extends WJElement {
|
|
|
356
356
|
* After draw method for the Button element.
|
|
357
357
|
*/
|
|
358
358
|
afterDraw() {
|
|
359
|
+
var _a, _b, _c, _d;
|
|
359
360
|
if (this.hasAttribute("route")) {
|
|
360
361
|
this.unbindRouterLinks = bindRouterLinks(this.parentElement, { selector: false });
|
|
361
362
|
}
|
|
362
363
|
if (this.hasToggle) {
|
|
363
364
|
if (this.toggle === "off") {
|
|
364
|
-
this.slotToggle.assignedNodes()[1]
|
|
365
|
-
|
|
365
|
+
const node = (_b = (_a = this.slotToggle) == null ? void 0 : _a.assignedNodes()) == null ? void 0 : _b[1];
|
|
366
|
+
if (node) {
|
|
367
|
+
node.classList.add("show");
|
|
368
|
+
this.setAttribute("value", "off");
|
|
369
|
+
}
|
|
366
370
|
} else {
|
|
367
|
-
this.slotToggle.assignedNodes()[0]
|
|
368
|
-
|
|
371
|
+
const node = (_d = (_c = this.slotToggle) == null ? void 0 : _c.assignedNodes()) == null ? void 0 : _d[0];
|
|
372
|
+
if (node) {
|
|
373
|
+
node.classList.add("show");
|
|
374
|
+
this.setAttribute("value", "on");
|
|
375
|
+
}
|
|
369
376
|
}
|
|
370
377
|
}
|
|
371
378
|
if (this.hasAttribute("custom-event")) {
|
package/dist/wje-button.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wje-button.js","sources":["../packages/wje-button/button.element.js","../packages/wje-button/button.js"],"sourcesContent":["import { bindRouterLinks } from 'slick-router/middlewares/router-links.js';\n\nimport { bool } from '../utils/utils.js';\nimport { default as WJElement, event, WjElementUtils } from '../wje-element/element.js';\nimport Icon from '../wje-icon/icon.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary This class represents Button element, extending the WJElement class.\n * @documentation https://elements.webjet.sk/components/button\n * @status stable\n * @augments WJElement\n * @dependency wje-icon\n * @slot - The button main content.\n * @slot icon - The button icon.\n * @slot caret - The button caret.\n * @slot start - The button start slot.\n * @slot end - The button end slot.\n * @slot toggle - The button toggle slot.\n * @csspart native - The component's native wrapper.\n * @cssproperty [--wje-button-background-color=transparent] - Background color of the component;\n * @cssproperty [--wje-button-border-color=--wje-color-contrast-4] - Border color of the component;\n * @cssproperty [--wje-button-color=--wje-color-contrast-11] - Color of the component;\n * @cssproperty [--wje-button-border-radius=--wje-border-radius-medium] - Border radius of the component;\n * @cssproperty [--wje-button-border-width=1px] - Border width of the component;\n * @cssproperty [--wje-button-border-style=solid] - Border style of the component;\n * @cssproperty [--wje-button-border-color=--wje-color-contrast-1] - Border color of the component;\n * @cssproperty [--wje-button-margin-inline=0] - Margin inline of the component;\n */\n\nexport default class Button extends WJElement {\n /**\n * Button constructor method.\n * @class\n */\n constructor() {\n super();\n\n this.internals_ = this.attachInternals();\n }\n\n /**\n * Dependencies of the Button element.\n * @type {object}\n */\n dependencies = {\n 'wje-icon': Icon,\n };\n\n /**\n * Properties of the element Button.\n * @param value\n */\n set color(value) {\n this.setAttribute('color', value || 'default');\n }\n\n /**\n * Get color of the Button element.\n * @returns {string|string}\n */\n get color() {\n return this.getAttribute('color') || 'default';\n }\n\n /**\n * Set variant of the Button element.\n * @param value\n */\n set caret(value) {\n this.setAttribute('caret', value);\n }\n\n /**\n * Get variant of the Button element.\n * @returns {boolean}\n */\n get caret() {\n return this.hasAttribute('caret');\n }\n\n /**\n * Sets the 'round' attribute on the element. If the value is true, the attribute is added;\n * otherwise, it is removed from the element.\n * @param {boolean} value A boolean indicating whether to set or remove the 'round' attribute.\n */\n set round(value) {\n if (value) {\n this.setAttribute('round', '');\n } else {\n this.removeAttribute('round');\n }\n }\n\n /**\n * Retrieves the value of the 'round' attribute as a boolean.\n * Checks if the 'round' attribute is present on the element.\n * @returns {boolean} True if the 'round' attribute exists, otherwise false.\n */\n get round() {\n return this.hasAttribute('round');\n }\n\n /**\n * Set variant of the Button element.\n * @param value\n */\n set tooltip(value) {\n this.setAttribute('tooltip', value);\n }\n\n /**\n * Get variant of the Button element.\n * @returns {boolean}\n */\n get tooltip() {\n return this.hasAttribute('tooltip');\n }\n\n /**\n * Set variant of the Button element.\n * @param value\n */\n set dialog(value) {\n this.setAttribute('dialog', value);\n }\n\n /**\n * Get variant of the Button element.\n * @returns {string|object}\n */\n get dialog() {\n return this.getAttribute('dialog');\n }\n\n /**\n * Set active state of the Button element.\n * @param {boolean} value The value to set\n */\n set active(value) {\n this.setAttribute('active', '');\n }\n\n /**\n * Get active state of the Button element.\n * @returns {boolean} active - The active state\n */\n get active() {\n return this.hasAttribute('active');\n }\n\n /**\n * Set disabled state of the Button element.\n * @param {boolean} value The value to set\n */\n set disabled(value) {\n this.removeAttribute('disabled');\n\n if (value) {\n this.setAttribute('disabled', '');\n }\n }\n\n /**\n * Get disabled state of the Button element.\n * @returns {boolean} disabled - The disabled state\n */\n get disabled() {\n return this.hasAttribute('disabled');\n }\n\n /**\n * Set fill of the Button element.\n * @param {string} value The value to set\n */\n set fill(value) {\n this.setAttribute('fill', value);\n }\n\n /**\n * Get fill of the Button element.\n * @returns {string} fill - The fill value\n */\n get fill() {\n return this.getAttribute('fill') || 'solid';\n }\n\n /**\n * Set outline state of the Button element.\n * @param {boolean} value The value to set\n */\n set outline(value) {\n this.setAttribute('outline', '');\n }\n\n /**\n * Get outline state of the Button element.\n * @returns {boolean} outline - The outline state\n */\n get outline() {\n return this.hasAttribute('outline');\n }\n\n /**\n * Set stop propagation state of the Button element.\n * @param {boolean} value The value to set\n */\n set stopPropagation(value) {\n this.setAttribute('stop-propagation', bool(value));\n }\n\n /**\n * Get stop propagation state of the Button element.\n * @returns {boolean} stopPropagation - The stop propagation state\n */\n get stopPropagation() {\n return bool(this.getAttribute('stop-propagation'));\n }\n\n /**\n * Sets the value of the custom event attribute.\n * @param {string} value The value to be assigned to the custom event attribute.\n */\n set customEvent(value) {\n this.setAttribute('custom-event', value);\n }\n\n /**\n * Retrieves the value of the 'custom-event' attribute from the element.\n * @returns {string | null} The value of the 'custom-event' attribute, or null if the attribute is not set.\n */\n get customEvent() {\n return this.getAttribute('custom-event');\n }\n\n /**\n * Retrieves a mapped object containing custom event parameters extracted from the element's attributes.\n * Attributes considered are those that begin with 'custom-event-'.\n * The mapped object's keys are derived by removing the 'custom-event-' prefix from the attribute names,\n * and the values are the corresponding attribute values.\n * @returns {object} An object containing key-value pairs of custom event parameters.\n */\n get customEventParameters() {\n const attributes = Array.from(this.attributes).filter((attr) => attr.name.startsWith('custom-event-'));\n\n return attributes.reduce((acc, attr) => {\n const key = attr.name.replace('custom-event-', '');\n acc[key] = attr.value;\n\n return acc;\n }, {});\n }\n\n /**\n * Class name for the Button element\n * @type {string}\n */\n className = 'Button';\n\n /**\n * Get CSS stylesheet for the Button element.\n * @static\n * @returns {CSSStyleSheet} styles - The CSS stylesheet for the Button element.\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Get observed attributes for the Button element.\n * @static\n * @returns {Array<string>} observedAttributes - The observed attributes array for the Button element.\n */\n static get observedAttributes() {\n return ['disabled', 'color'];\n }\n\n /**\n * @summary A static property that indicates whether the custom element is form-associated or not.\n * Form-associated custom elements are elements that can participate in form submission.\n * @type {boolean}\n */\n static formAssociated = true;\n\n /**\n * @summary Callback function that is called when the custom element is associated with a form.\n * This function sets the internal `_form` property to the associated form.\n * @param {HTMLFormElement} form The form the custom element is associated with.\n */\n formAssociatedCallback(form) {\n this._form = form;\n }\n\n /**\n * @summary Callback function that is called when the form-associated state of the custom element changes.\n * This function updates the 'disabled' attribute of the element based on the new state.\n * @param {boolean} disabled The new form-associated state.\n */\n formDisabledCallback(disabled) {\n if (disabled) {\n this.setAttribute('disabled', '');\n } else {\n this.removeAttribute('disabled');\n }\n }\n\n /**\n * Setup attributes for the Button element.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Draw method for the Button element.\n * @returns {object} fragment - The document fragment containing the drawn element.\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement(this.hasAttribute('href') ? 'a' : 'button');\n if (this.hasAttribute('href')) {\n native.setAttribute('href', this.getAttribute('href'));\n } else {\n if (this.type === 'submit') {\n native.setAttribute('type', 'submit');\n }\n }\n\n native.classList.add('native-button');\n native.setAttribute('part', 'native');\n\n this.classList.remove('wje-button-disabled');\n\n if (this.disabled) native.classList.add('wje-button-disabled');\n\n if (this.variant) native.classList.add('wje-button-' + this.variant);\n\n if (this.hasAttribute('round')) native.classList.add('wje-button-round');\n\n if (this.hasAttribute('circle')) native.classList.add('wje-button-circle');\n\n if (this.outline) native.classList.add('wje-outline');\n\n if (this.fill) native.classList.add('wje-button-' + this.fill);\n\n if (this.size) native.classList.add('wje-button-' + this.size);\n\n if (\n (this.querySelectorAll('[slot=caret]').length < 1 && this.hasAttribute('caret')) ||\n this.hasAttribute('only-caret')\n ) {\n let i = document.createElement('wje-icon');\n i.style.setProperty('--wje-icon-size', '14px');\n i.setAttribute('slot', 'caret');\n i.setAttribute('name', 'chevron-down');\n i.setAttribute('part', 'caret');\n\n this.appendChild(i);\n }\n\n if (this.active) {\n this.classList.add('wje-active');\n let i = document.createElement('wje-icon');\n i.setAttribute('name', 'check');\n\n this.appendChild(i);\n }\n\n native.classList.add('wje-color-' + this.color, 'wje-color');\n\n let span = document.createElement('span');\n span.setAttribute('part', 'inner');\n span.classList.add('button-inner');\n\n let slot = document.createElement('slot');\n slot.setAttribute('name', 'icon-only');\n span.appendChild(slot);\n\n slot = document.createElement('slot');\n slot.setAttribute('name', 'start');\n span.appendChild(slot);\n\n slot = document.createElement('slot');\n span.appendChild(slot);\n\n slot = document.createElement('slot');\n slot.setAttribute('name', 'end');\n span.appendChild(slot);\n\n slot = document.createElement('slot');\n slot.setAttribute('name', 'caret');\n span.appendChild(slot);\n\n this.hasToggle = WjElementUtils.hasSlot(this, 'toggle');\n\n if (this.hasToggle) {\n this.slotToggle = document.createElement('slot');\n this.slotToggle.setAttribute('name', 'toggle');\n\n span.appendChild(this.slotToggle);\n }\n\n native.appendChild(span);\n\n if (this.tooltip) {\n let tooltip = document.createElement('wje-tooltip');\n tooltip.setAttribute('content', this.getAttribute('tooltip'));\n tooltip.setAttribute('placement', this.getAttribute('tooltip-placement') || 'top');\n tooltip.appendChild(native);\n\n fragment.appendChild(tooltip);\n } else {\n fragment.appendChild(native);\n }\n\n return fragment;\n }\n\n /**\n * After draw method for the Button element.\n */\n afterDraw() {\n if (this.hasAttribute('route')) {\n this.unbindRouterLinks = bindRouterLinks(this.parentElement, { selector: false });\n }\n\n // nastavenie toggle podla atributu, ak nie je nastaveny, tak sa zobrazi vzdy prvy element\n if (this.hasToggle) {\n if (this.toggle === 'off') {\n this.slotToggle.assignedNodes()[1].classList.add('show');\n this.setAttribute('value', 'off');\n } else {\n this.slotToggle.assignedNodes()[0].classList.add('show');\n this.setAttribute('value', 'on');\n }\n }\n\n if (this.hasAttribute('custom-event')) {\n event.addListener(this, 'click', null, this.#populateCustomEvent);\n }\n\n if (this.hasAttribute('dialog')) {\n event.addListener(this, 'click', null, this.eventDialogOpen);\n } else {\n event.addListener(this, 'click', 'wje-button:click', null); // { stopPropagation: this.stopPropagation } - zrusene kvoli dropdown kde som nevedel odchytit event click\n }\n\n if (this.hasToggle)\n event.addListener(this, 'click', 'wje-button:toggle', this.toggleStates, {\n stopPropagation: this.stopPropagation,\n });\n\n if (this.type === 'submit') {\n event.addListener(this, 'click', 'wje-button:submit', () => {\n event.dispatchCustomEvent(this.internals_.form, 'submit', {});\n });\n }\n\n if (this.type === 'reset') {\n event.addListener(this, 'click', 'wje-button:reset', () => {\n this.internals_.form.reset();\n });\n }\n }\n\n /**\n * Before disconnect method for the Button element.\n */\n beforeDisconnect() {\n // remove all events from the button\n event.removeListener(this, 'click', null, this.eventDialogOpen);\n event.removeListener(this, 'click', 'wje-button:click', null);\n event.removeListener(this, 'click', 'wje-button:toggle', this.toggleStates);\n event.removeListener(this, 'click', null, this.#populateCustomEvent);\n event.removeListener(this, 'click', 'wje-button:submit', null);\n event.removeListener(this, 'click', 'wje-button:reset', null);\n\n this.removeEventListener('click', this.eventDialogOpen);\n this.unbindRouterLinks?.();\n }\n\n /**\n * Event dialog open method for the Button element.\n * @param {Event} e The event object\n */\n eventDialogOpen = (e) => {\n event.dispatchCustomEvent(this, this.dialog);\n };\n\n /**\n * Toggle states method for the Button element.\n */\n toggleStates = () => {\n const nodes = this.slotToggle.assignedNodes().filter((node) => node.nodeType === Node.ELEMENT_NODE);\n\n nodes.forEach((node, index) => {\n if (node.classList.contains('show')) {\n node.classList.remove('show');\n } else {\n node.classList.add('show');\n this.setAttribute('value', index === 0 ? 'on' : 'off');\n }\n });\n }\n\n /**\n * Dispatches a custom event with specified parameters.\n * This method uses the `customEvent` and `customEventParameters` properties\n * to create and dispatch a `CustomEvent`. The event is configured to be\n * composed and bubbles up through the DOM.\n * @returns {void} This method does not return a value.\n */\n #populateCustomEvent() {\n this.dispatchEvent(\n new CustomEvent(this.customEvent, { detail: this.customEventParameters, composed: true, bubbles: true })\n );\n }\n}\n","import Button from './button.element.js';\n\nexport default Button;\n\nButton.define('wje-button', Button);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AA8Be,MAA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AoB,IAAI;AAC5D,UAAM,eAAe,MAAM,SAAS,qBAAqB,KAAK,YAAY;AAC1E,UAAM,eAAe,MAAM,SAAS,MAAM,sBAAK,0CAAoB;AACnE,UAAM,eAAe,MAAM,SAAS,qBAAqB,IAAI;AAC7D,UAAM,eAAe,MAAM,SAAS,oBAAoB,IAAI;AAE5D,SAAK,oBAAoB,SAAS,KAAK,eAAe;AACtD,eAAK,sBAAL;AAAA,EACR;AAsCA;AAxee;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmeX,yBAAoB,WAAG;AACnB,OAAK;AAAA,IACH,IAAI,YAAY,KAAK,aAAa,EAAE,QAAQ,KAAK,uBAAuB,UAAU,MAAM,SAAS,KAAM,CAAA;AAAA,EACxG;AACT;AAAA;AAAA;AAAA;AAAA;AAAA;AA3OI,cA5PiB,QA4PV,kBAAiB;ACtR5B,OAAO,OAAO,cAAc,MAAM;"}
|
|
1
|
+
{"version":3,"file":"wje-button.js","sources":["../packages/wje-button/button.element.js","../packages/wje-button/button.js"],"sourcesContent":["import { bindRouterLinks } from 'slick-router/middlewares/router-links.js';\n\nimport { bool } from '../utils/utils.js';\nimport { default as WJElement, event, WjElementUtils } from '../wje-element/element.js';\nimport Icon from '../wje-icon/icon.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary This class represents Button element, extending the WJElement class.\n * @documentation https://elements.webjet.sk/components/button\n * @status stable\n * @augments WJElement\n * @dependency wje-icon\n * @slot - The button main content.\n * @slot icon - The button icon.\n * @slot caret - The button caret.\n * @slot start - The button start slot.\n * @slot end - The button end slot.\n * @slot toggle - The button toggle slot.\n * @csspart native - The component's native wrapper.\n * @cssproperty [--wje-button-background-color=transparent] - Background color of the component;\n * @cssproperty [--wje-button-border-color=--wje-color-contrast-4] - Border color of the component;\n * @cssproperty [--wje-button-color=--wje-color-contrast-11] - Color of the component;\n * @cssproperty [--wje-button-border-radius=--wje-border-radius-medium] - Border radius of the component;\n * @cssproperty [--wje-button-border-width=1px] - Border width of the component;\n * @cssproperty [--wje-button-border-style=solid] - Border style of the component;\n * @cssproperty [--wje-button-border-color=--wje-color-contrast-1] - Border color of the component;\n * @cssproperty [--wje-button-margin-inline=0] - Margin inline of the component;\n */\n\nexport default class Button extends WJElement {\n /**\n * Button constructor method.\n * @class\n */\n constructor() {\n super();\n\n this.internals_ = this.attachInternals();\n }\n\n /**\n * Dependencies of the Button element.\n * @type {object}\n */\n dependencies = {\n 'wje-icon': Icon,\n };\n\n /**\n * Properties of the element Button.\n * @param value\n */\n set color(value) {\n this.setAttribute('color', value || 'default');\n }\n\n /**\n * Get color of the Button element.\n * @returns {string|string}\n */\n get color() {\n return this.getAttribute('color') || 'default';\n }\n\n /**\n * Set variant of the Button element.\n * @param value\n */\n set caret(value) {\n this.setAttribute('caret', value);\n }\n\n /**\n * Get variant of the Button element.\n * @returns {boolean}\n */\n get caret() {\n return this.hasAttribute('caret');\n }\n\n /**\n * Sets the 'round' attribute on the element. If the value is true, the attribute is added;\n * otherwise, it is removed from the element.\n * @param {boolean} value A boolean indicating whether to set or remove the 'round' attribute.\n */\n set round(value) {\n if (value) {\n this.setAttribute('round', '');\n } else {\n this.removeAttribute('round');\n }\n }\n\n /**\n * Retrieves the value of the 'round' attribute as a boolean.\n * Checks if the 'round' attribute is present on the element.\n * @returns {boolean} True if the 'round' attribute exists, otherwise false.\n */\n get round() {\n return this.hasAttribute('round');\n }\n\n /**\n * Set variant of the Button element.\n * @param value\n */\n set tooltip(value) {\n this.setAttribute('tooltip', value);\n }\n\n /**\n * Get variant of the Button element.\n * @returns {boolean}\n */\n get tooltip() {\n return this.hasAttribute('tooltip');\n }\n\n /**\n * Set variant of the Button element.\n * @param value\n */\n set dialog(value) {\n this.setAttribute('dialog', value);\n }\n\n /**\n * Get variant of the Button element.\n * @returns {string|object}\n */\n get dialog() {\n return this.getAttribute('dialog');\n }\n\n /**\n * Set active state of the Button element.\n * @param {boolean} value The value to set\n */\n set active(value) {\n this.setAttribute('active', '');\n }\n\n /**\n * Get active state of the Button element.\n * @returns {boolean} active - The active state\n */\n get active() {\n return this.hasAttribute('active');\n }\n\n /**\n * Set disabled state of the Button element.\n * @param {boolean} value The value to set\n */\n set disabled(value) {\n this.removeAttribute('disabled');\n\n if (value) {\n this.setAttribute('disabled', '');\n }\n }\n\n /**\n * Get disabled state of the Button element.\n * @returns {boolean} disabled - The disabled state\n */\n get disabled() {\n return this.hasAttribute('disabled');\n }\n\n /**\n * Set fill of the Button element.\n * @param {string} value The value to set\n */\n set fill(value) {\n this.setAttribute('fill', value);\n }\n\n /**\n * Get fill of the Button element.\n * @returns {string} fill - The fill value\n */\n get fill() {\n return this.getAttribute('fill') || 'solid';\n }\n\n /**\n * Set outline state of the Button element.\n * @param {boolean} value The value to set\n */\n set outline(value) {\n this.setAttribute('outline', '');\n }\n\n /**\n * Get outline state of the Button element.\n * @returns {boolean} outline - The outline state\n */\n get outline() {\n return this.hasAttribute('outline');\n }\n\n /**\n * Set stop propagation state of the Button element.\n * @param {boolean} value The value to set\n */\n set stopPropagation(value) {\n this.setAttribute('stop-propagation', bool(value));\n }\n\n /**\n * Get stop propagation state of the Button element.\n * @returns {boolean} stopPropagation - The stop propagation state\n */\n get stopPropagation() {\n return bool(this.getAttribute('stop-propagation'));\n }\n\n /**\n * Sets the value of the custom event attribute.\n * @param {string} value The value to be assigned to the custom event attribute.\n */\n set customEvent(value) {\n this.setAttribute('custom-event', value);\n }\n\n /**\n * Retrieves the value of the 'custom-event' attribute from the element.\n * @returns {string | null} The value of the 'custom-event' attribute, or null if the attribute is not set.\n */\n get customEvent() {\n return this.getAttribute('custom-event');\n }\n\n /**\n * Retrieves a mapped object containing custom event parameters extracted from the element's attributes.\n * Attributes considered are those that begin with 'custom-event-'.\n * The mapped object's keys are derived by removing the 'custom-event-' prefix from the attribute names,\n * and the values are the corresponding attribute values.\n * @returns {object} An object containing key-value pairs of custom event parameters.\n */\n get customEventParameters() {\n const attributes = Array.from(this.attributes).filter((attr) => attr.name.startsWith('custom-event-'));\n\n return attributes.reduce((acc, attr) => {\n const key = attr.name.replace('custom-event-', '');\n acc[key] = attr.value;\n\n return acc;\n }, {});\n }\n\n /**\n * Class name for the Button element\n * @type {string}\n */\n className = 'Button';\n\n /**\n * Get CSS stylesheet for the Button element.\n * @static\n * @returns {CSSStyleSheet} styles - The CSS stylesheet for the Button element.\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Get observed attributes for the Button element.\n * @static\n * @returns {Array<string>} observedAttributes - The observed attributes array for the Button element.\n */\n static get observedAttributes() {\n return ['disabled', 'color'];\n }\n\n /**\n * @summary A static property that indicates whether the custom element is form-associated or not.\n * Form-associated custom elements are elements that can participate in form submission.\n * @type {boolean}\n */\n static formAssociated = true;\n\n /**\n * @summary Callback function that is called when the custom element is associated with a form.\n * This function sets the internal `_form` property to the associated form.\n * @param {HTMLFormElement} form The form the custom element is associated with.\n */\n formAssociatedCallback(form) {\n this._form = form;\n }\n\n /**\n * @summary Callback function that is called when the form-associated state of the custom element changes.\n * This function updates the 'disabled' attribute of the element based on the new state.\n * @param {boolean} disabled The new form-associated state.\n */\n formDisabledCallback(disabled) {\n if (disabled) {\n this.setAttribute('disabled', '');\n } else {\n this.removeAttribute('disabled');\n }\n }\n\n /**\n * Setup attributes for the Button element.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Draw method for the Button element.\n * @returns {object} fragment - The document fragment containing the drawn element.\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement(this.hasAttribute('href') ? 'a' : 'button');\n if (this.hasAttribute('href')) {\n native.setAttribute('href', this.getAttribute('href'));\n } else {\n if (this.type === 'submit') {\n native.setAttribute('type', 'submit');\n }\n }\n\n native.classList.add('native-button');\n native.setAttribute('part', 'native');\n\n this.classList.remove('wje-button-disabled');\n\n if (this.disabled) native.classList.add('wje-button-disabled');\n\n if (this.variant) native.classList.add('wje-button-' + this.variant);\n\n if (this.hasAttribute('round')) native.classList.add('wje-button-round');\n\n if (this.hasAttribute('circle')) native.classList.add('wje-button-circle');\n\n if (this.outline) native.classList.add('wje-outline');\n\n if (this.fill) native.classList.add('wje-button-' + this.fill);\n\n if (this.size) native.classList.add('wje-button-' + this.size);\n\n if (\n (this.querySelectorAll('[slot=caret]').length < 1 && this.hasAttribute('caret')) ||\n this.hasAttribute('only-caret')\n ) {\n let i = document.createElement('wje-icon');\n i.style.setProperty('--wje-icon-size', '14px');\n i.setAttribute('slot', 'caret');\n i.setAttribute('name', 'chevron-down');\n i.setAttribute('part', 'caret');\n\n this.appendChild(i);\n }\n\n if (this.active) {\n this.classList.add('wje-active');\n let i = document.createElement('wje-icon');\n i.setAttribute('name', 'check');\n\n this.appendChild(i);\n }\n\n native.classList.add('wje-color-' + this.color, 'wje-color');\n\n let span = document.createElement('span');\n span.setAttribute('part', 'inner');\n span.classList.add('button-inner');\n\n let slot = document.createElement('slot');\n slot.setAttribute('name', 'icon-only');\n span.appendChild(slot);\n\n slot = document.createElement('slot');\n slot.setAttribute('name', 'start');\n span.appendChild(slot);\n\n slot = document.createElement('slot');\n span.appendChild(slot);\n\n slot = document.createElement('slot');\n slot.setAttribute('name', 'end');\n span.appendChild(slot);\n\n slot = document.createElement('slot');\n slot.setAttribute('name', 'caret');\n span.appendChild(slot);\n\n this.hasToggle = WjElementUtils.hasSlot(this, 'toggle');\n\n if (this.hasToggle) {\n this.slotToggle = document.createElement('slot');\n this.slotToggle.setAttribute('name', 'toggle');\n\n span.appendChild(this.slotToggle);\n }\n\n native.appendChild(span);\n\n if (this.tooltip) {\n let tooltip = document.createElement('wje-tooltip');\n tooltip.setAttribute('content', this.getAttribute('tooltip'));\n tooltip.setAttribute('placement', this.getAttribute('tooltip-placement') || 'top');\n tooltip.appendChild(native);\n\n fragment.appendChild(tooltip);\n } else {\n fragment.appendChild(native);\n }\n\n return fragment;\n }\n\n /**\n * After draw method for the Button element.\n */\n afterDraw() {\n if (this.hasAttribute('route')) {\n this.unbindRouterLinks = bindRouterLinks(this.parentElement, { selector: false });\n }\n\n // nastavenie toggle podla atributu, ak nie je nastaveny, tak sa zobrazi vzdy prvy element\n if (this.hasToggle) {\n if (this.toggle === 'off') {\n const node = this.slotToggle?.assignedNodes()?.[1];\n if (node) {\n node.classList.add(\"show\");\n this.setAttribute('value', 'off');\n }\n // this.slotToggle.assignedNodes()[1].classList.add('show');\n\n } else {\n const node = this.slotToggle?.assignedNodes()?.[0];\n if (node) {\n node.classList.add(\"show\");\n this.setAttribute('value', 'on');\n }\n // this.slotToggle.assignedNodes()[0].classList.add('show');\n\n }\n }\n\n if (this.hasAttribute('custom-event')) {\n event.addListener(this, 'click', null, this.#populateCustomEvent);\n }\n\n if (this.hasAttribute('dialog')) {\n event.addListener(this, 'click', null, this.eventDialogOpen);\n } else {\n event.addListener(this, 'click', 'wje-button:click', null); // { stopPropagation: this.stopPropagation } - zrusene kvoli dropdown kde som nevedel odchytit event click\n }\n\n if (this.hasToggle)\n event.addListener(this, 'click', 'wje-button:toggle', this.toggleStates, {\n stopPropagation: this.stopPropagation,\n });\n\n if (this.type === 'submit') {\n event.addListener(this, 'click', 'wje-button:submit', () => {\n event.dispatchCustomEvent(this.internals_.form, 'submit', {});\n });\n }\n\n if (this.type === 'reset') {\n event.addListener(this, 'click', 'wje-button:reset', () => {\n this.internals_.form.reset();\n });\n }\n }\n\n /**\n * Before disconnect method for the Button element.\n */\n beforeDisconnect() {\n // remove all events from the button\n event.removeListener(this, 'click', null, this.eventDialogOpen);\n event.removeListener(this, 'click', 'wje-button:click', null);\n event.removeListener(this, 'click', 'wje-button:toggle', this.toggleStates);\n event.removeListener(this, 'click', null, this.#populateCustomEvent);\n event.removeListener(this, 'click', 'wje-button:submit', null);\n event.removeListener(this, 'click', 'wje-button:reset', null);\n\n this.removeEventListener('click', this.eventDialogOpen);\n this.unbindRouterLinks?.();\n }\n\n /**\n * Event dialog open method for the Button element.\n * @param {Event} e The event object\n */\n eventDialogOpen = (e) => {\n event.dispatchCustomEvent(this, this.dialog);\n };\n\n /**\n * Toggle states method for the Button element.\n */\n toggleStates = () => {\n const nodes = this.slotToggle.assignedNodes().filter((node) => node.nodeType === Node.ELEMENT_NODE);\n\n nodes.forEach((node, index) => {\n if (node.classList.contains('show')) {\n node.classList.remove('show');\n } else {\n node.classList.add('show');\n this.setAttribute('value', index === 0 ? 'on' : 'off');\n }\n });\n }\n\n /**\n * Dispatches a custom event with specified parameters.\n * This method uses the `customEvent` and `customEventParameters` properties\n * to create and dispatch a `CustomEvent`. The event is configured to be\n * composed and bubbles up through the DOM.\n * @returns {void} This method does not return a value.\n */\n #populateCustomEvent() {\n this.dispatchEvent(\n new CustomEvent(this.customEvent, { detail: this.customEventParameters, composed: true, bubbles: true })\n );\n }\n}\n","import Button from './button.element.js';\n\nexport default Button;\n\nButton.define('wje-button', Button);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AA8Be,MAAM,eAAe,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA,EAK1C,cAAc;AACV,UAAO;AANA;AAeX;AAAA;AAAA;AAAA;AAAA,wCAAe;AAAA,MACX,YAAY;AAAA,IACf;AAkND;AAAA;AAAA;AAAA;AAAA,qCAAY;AA+OZ;AAAA;AAAA;AAAA;AAAA,2CAAkB,CAAC,MAAM;AACrB,YAAM,oBAAoB,MAAM,KAAK,MAAM;AAAA,IAC9C;AAKD;AAAA;AAAA;AAAA,wCAAe,MAAM;AACjB,YAAM,QAAQ,KAAK,WAAW,cAAa,EAAG,OAAO,CAAC,SAAS,KAAK,aAAa,KAAK,YAAY;AAElG,YAAM,QAAQ,CAAC,MAAM,UAAU;AAC3B,YAAI,KAAK,UAAU,SAAS,MAAM,GAAG;AACjC,eAAK,UAAU,OAAO,MAAM;AAAA,QAC5C,OAAmB;AACH,eAAK,UAAU,IAAI,MAAM;AACzB,eAAK,aAAa,SAAS,UAAU,IAAI,OAAO,KAAK;AAAA,QACrE;AAAA,MACA,CAAS;AAAA,IACT;AA5dQ,SAAK,aAAa,KAAK,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M;"}
|
package/dist/wje-element.js
CHANGED
|
@@ -51,6 +51,7 @@ const _WJElement = class _WJElement extends HTMLElement {
|
|
|
51
51
|
resolve();
|
|
52
52
|
});
|
|
53
53
|
});
|
|
54
|
+
this.__templateInserted = false;
|
|
54
55
|
__privateSet(this, _isAttached, false);
|
|
55
56
|
this.service = new UniversalService({
|
|
56
57
|
store
|
|
@@ -268,6 +269,7 @@ const _WJElement = class _WJElement extends HTMLElement {
|
|
|
268
269
|
*/
|
|
269
270
|
connectedCallback() {
|
|
270
271
|
var _a;
|
|
272
|
+
if (__privateGet(this, _isAttached)) return;
|
|
271
273
|
if (!__privateGet(this, _isRendering)) {
|
|
272
274
|
__privateSet(this, _originalVisibility, __privateGet(this, _originalVisibility) ?? this.style.visibility);
|
|
273
275
|
this.style.visibility = "hidden";
|
|
@@ -349,8 +351,12 @@ const _WJElement = class _WJElement extends HTMLElement {
|
|
|
349
351
|
this.finisPromise = resolve;
|
|
350
352
|
this.rejectPromise = reject;
|
|
351
353
|
});
|
|
352
|
-
|
|
353
|
-
|
|
354
|
+
if (__privateGet(this, _isAttached)) {
|
|
355
|
+
if (!__privateGet(this, _isRendering)) {
|
|
356
|
+
__privateSet(this, _pristine, false);
|
|
357
|
+
__privateMethod(this, _WJElement_instances, enqueueUpdate_fn).call(this);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
354
360
|
}
|
|
355
361
|
stopRenderLoop() {
|
|
356
362
|
if (this.rafId) {
|
|
@@ -386,10 +392,15 @@ const _WJElement = class _WJElement extends HTMLElement {
|
|
|
386
392
|
*/
|
|
387
393
|
display(force = false) {
|
|
388
394
|
this.template = this.constructor.customTemplate || document.createElement("template");
|
|
389
|
-
if (
|
|
390
|
-
|
|
395
|
+
if (!this.__templateInserted && this.context.childElementCount === 0) {
|
|
396
|
+
this.context.append(this.template.content.cloneNode(true));
|
|
397
|
+
this.__templateInserted = true;
|
|
398
|
+
}
|
|
399
|
+
if (this.context && this.constructor.cssStyleSheet) {
|
|
400
|
+
const sheet = new CSSStyleSheet();
|
|
401
|
+
sheet.replaceSync(this.constructor.cssStyleSheet);
|
|
402
|
+
this.context.adoptedStyleSheets = [sheet];
|
|
391
403
|
}
|
|
392
|
-
this.context.append(this.template.content.cloneNode(true));
|
|
393
404
|
if (this.noShow || this.isPermissionCheck && !Permissions.isPermissionFulfilled(this.permission)) {
|
|
394
405
|
this.remove();
|
|
395
406
|
return Promise.resolve();
|
|
@@ -400,22 +411,25 @@ const _WJElement = class _WJElement extends HTMLElement {
|
|
|
400
411
|
* Renders the component's content.
|
|
401
412
|
*/
|
|
402
413
|
async render() {
|
|
414
|
+
var _a;
|
|
403
415
|
__privateSet(this, _drawingStatus, this.drawingStatuses.DRAWING);
|
|
404
|
-
let
|
|
405
|
-
if (
|
|
406
|
-
|
|
416
|
+
let result = this.draw(this.context, this.store, WjElementUtils.getAttributes(this));
|
|
417
|
+
if (result instanceof Promise || ((_a = result == null ? void 0 : result.constructor) == null ? void 0 : _a.name) === "Promise") {
|
|
418
|
+
result = await result;
|
|
419
|
+
}
|
|
420
|
+
if (result === null || result === void 0) {
|
|
421
|
+
return;
|
|
407
422
|
}
|
|
408
|
-
|
|
423
|
+
this.context.innerHTML = "";
|
|
409
424
|
let element;
|
|
410
|
-
if (
|
|
411
|
-
element =
|
|
425
|
+
if (result instanceof HTMLElement || result instanceof DocumentFragment) {
|
|
426
|
+
element = result;
|
|
412
427
|
} else {
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
element =
|
|
428
|
+
const tpl = document.createElement("template");
|
|
429
|
+
tpl.innerHTML = String(result);
|
|
430
|
+
element = tpl.content.cloneNode(true);
|
|
416
431
|
}
|
|
417
|
-
|
|
418
|
-
this.context.appendChild(rendered);
|
|
432
|
+
this.context.appendChild(element);
|
|
419
433
|
}
|
|
420
434
|
/**
|
|
421
435
|
* Sanitizes a given name by converting it from kebab-case to camelCase.
|
|
@@ -492,7 +506,7 @@ enqueueUpdate_fn = function() {
|
|
|
492
506
|
}
|
|
493
507
|
};
|
|
494
508
|
refresh_fn = async function() {
|
|
495
|
-
var _a, _b, _c;
|
|
509
|
+
var _a, _b, _c, _d;
|
|
496
510
|
if (__privateGet(this, _isRendering)) {
|
|
497
511
|
this.rafId = requestAnimationFrame(() => __privateMethod(this, _WJElement_instances, refresh_fn).call(this));
|
|
498
512
|
return;
|
|
@@ -500,15 +514,26 @@ refresh_fn = async function() {
|
|
|
500
514
|
if (!__privateGet(this, _pristine)) {
|
|
501
515
|
__privateSet(this, _pristine, true);
|
|
502
516
|
__privateSet(this, _isRendering, true);
|
|
503
|
-
if (__privateGet(this, _isAttached)) {
|
|
504
|
-
(_a = this.beforeRedraw) == null ? void 0 : _a.call(this);
|
|
505
|
-
(_b = this.beforeDisconnect) == null ? void 0 : _b.call(this);
|
|
506
|
-
(_c = this.afterDisconnect) == null ? void 0 : _c.call(this);
|
|
507
|
-
} else {
|
|
508
|
-
this.stopRenderLoop();
|
|
509
|
-
}
|
|
510
517
|
try {
|
|
511
|
-
|
|
518
|
+
(_a = this.beforeRedraw) == null ? void 0 : _a.call(this);
|
|
519
|
+
if (this.hasShadowRoot && !this.shadowRoot) {
|
|
520
|
+
this.attachShadow({ mode: this.shadowType || "open", delegatesFocus: true });
|
|
521
|
+
}
|
|
522
|
+
if (!__privateGet(this, _isAttached)) {
|
|
523
|
+
await this.display(false);
|
|
524
|
+
} else {
|
|
525
|
+
const params = WjElementUtils.getAttributes(this);
|
|
526
|
+
const bd = this.beforeDraw(this.context, this.store, params);
|
|
527
|
+
if (bd instanceof Promise || ((_b = bd == null ? void 0 : bd.constructor) == null ? void 0 : _b.name) === "Promise") {
|
|
528
|
+
await bd;
|
|
529
|
+
}
|
|
530
|
+
await this.render();
|
|
531
|
+
const ad = (_c = this.afterDraw) == null ? void 0 : _c.call(this, this.context, this.store, params);
|
|
532
|
+
if (ad instanceof Promise || ((_d = ad == null ? void 0 : ad.constructor) == null ? void 0 : _d.name) === "Promise") {
|
|
533
|
+
await ad;
|
|
534
|
+
}
|
|
535
|
+
__privateSet(this, _drawingStatus, this.drawingStatuses.DONE);
|
|
536
|
+
}
|
|
512
537
|
} catch (error) {
|
|
513
538
|
console.error("Render error:", error);
|
|
514
539
|
} finally {
|
|
@@ -537,6 +562,7 @@ resolveRender_fn = function() {
|
|
|
537
562
|
await __beforeDraw;
|
|
538
563
|
}
|
|
539
564
|
await this.render();
|
|
565
|
+
await new Promise((r) => queueMicrotask(r));
|
|
540
566
|
const __afterDraw = (_a = this.afterDraw) == null ? void 0 : _a.call(this, this.context, this.store, WjElementUtils.getAttributes(this));
|
|
541
567
|
if (__afterDraw instanceof Promise || (__afterDraw == null ? void 0 : __afterDraw.constructor.name) === "Promise") {
|
|
542
568
|
await __afterDraw;
|
package/dist/wje-element.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wje-element.js","sources":["../packages/wje-element/element.js"],"sourcesContent":["import { UniversalService } from '../utils/universal-service.js';\nimport { Permissions } from '../utils/permissions.js';\nimport { WjElementUtils } from '../utils/element-utils.js';\nimport { event } from '../utils/event.js';\nimport { defaultStoreActions, store } from '../wje-store/store.js';\n\nconst template = document.createElement('template');\ntemplate.innerHTML = ``;\nexport default class WJElement extends HTMLElement {\n\t#drawingStatus;\n\t#isAttached;\n\t#isRendering;\n\t#originalVisibility;\n\t#pristine;\n\n\t/**\n\t * Initializes a new instance of the WJElement class.\n\t */\n\n\tconstructor() {\n\t\tsuper();\n\n\t\tthis.#isAttached = false;\n\t\tthis.service = new UniversalService({\n\t\t\tstore: store,\n\t\t});\n\n\t\t// definujeme vsetky zavislosti.\n\t\t// Do zavislosti patria len komponenty, ktore su zavisle od ktoreho je zavisly tento komponent\n\t\tthis.defineDependencies();\n\n\t\tthis.#isRendering = false;\n\t\tthis._dependencies = {};\n\n\t\t/**\n\t\t * @typedef {object} DrawingStatuses\n\t\t * @property {number} CREATED - The component has been created.\n\t\t * @property {number} ATTACHED - The component has been attached to the DOM.\n\t\t * @property {number} BEGINING - The component is beginning to draw.\n\t\t * @property {number} START - The component has started drawing.\n\t\t * @property {number} DRAWING - The component is drawing.\n\t\t * @property {number} DONE - The component has finished drawing.\n\t\t * @property {number} DISCONNECTED - The component has been disconnected from the DOM.\n\t\t */\n\n\t\t/**\n\t\t * WJElement is a base class for custom web components with managed lifecycle, attribute/property sync,\n\t\t * permission-based visibility, and extensibility hooks.\n\t\t * @property {boolean} isAttached - True if the component is currently attached to the DOM.\n\t\t * @property {DrawingStatuses} drawingStatuses - Enum of possible drawing states.\n\t\t * @property {number} drawingStatus - Current drawing status (see drawingStatuses).\n\t\t * @property {boolean} _pristine - True if the component has not been updated since last render.\n\t\t * @property {boolean} isRendering - True if a render is currently in progress.\n\t\t * @property {number|null} rafId - ID of the scheduled animation frame for rendering, or null.\n\t\t * @property {string|null} originalVisibility - Stores the original CSS visibility before rendering.\n\t\t * @property {object} params - Stores the current attributes/properties for rendering.\n\t\t * @property {Promise<void>} updateComplete - Promise resolved when the current update/render is complete.\n\t\t * @property {string[]} permission - List of required permissions (from 'permission' attribute).\n\t\t * @property {boolean} isPermissionCheck - Whether permission checking is enabled (from 'permission-check' attribute).\n\t\t * @property {boolean} noShow - Whether the element should be hidden (from 'no-show' attribute).\n\t\t * @property {string|undefined} isShadowRoot - Value of the 'shadow' attribute, if present.\n\t\t * @property {boolean} hasShadowRoot - True if the 'shadow' attribute is present.\n\t\t * @property {string} shadowType - Type of shadow root ('open' by default).\n\t\t * @property {object} store - Reference to the global store instance.\n\t\t * @property {object} defaultStoreActions - Default store actions for arrays and objects.\n\t\t * @property {string[]|undefined} removeClassAfterConnect - Classes to remove after connect (from 'remove-class-after-connect' attribute).\n\t\t * @property {object} dependencies - Registered component dependencies.\n\t\t * @property {HTMLElement|ShadowRoot} context - The rendering context (shadow root or element itself).\n\t\t */\n\t\tthis.drawingStatuses = {\n\t\t\tCREATED: 0,\n\t\t\tATTACHED: 1,\n\t\t\tBEGINING: 2,\n\t\t\tSTART: 3,\n\t\t\tDRAWING: 4,\n\t\t\tDONE: 5,\n\t\t\tDISCONNECTED: 6,\n\t\t};\n\n\t\tthis.#drawingStatus = this.drawingStatuses.CREATED;\n\n\t\tthis.#pristine = true;\n\t\tthis.#isRendering = false;\n\t\tthis.rafId = null;\n\t\tthis.#originalVisibility = null;\n\t\tthis.params = {};\n\n\t\tthis.updateComplete = new Promise((resolve, reject) => {\n\t\t\tthis.finisPromise = resolve;\n\t\t\tthis.rejectPromise = reject;\n\t\t});\n\t}\n\n\tget drawingStatus() {\n\t\treturn this.#drawingStatus;\n\t}\n\n\t/**\n\t * Sets the value of the 'permission' attribute.\n\t * @param {string[]} value The value to set for the 'permission' attribute.\n\t */\n\tset permission(value) {\n\t\tthis.setAttribute('permission', value.join(','));\n\t}\n\n\t/**\n\t * Gets the value of the 'permission-check' attribute.\n\t * @returns {string[]} The value of the 'permission' attribute.\n\t */\n\tget permission() {\n\t\treturn this.getAttribute('permission')?.split(',') || [];\n\t}\n\n\t/**\n\t * Sets the 'permission-check' attribute.\n\t * @param {boolean} value The value to set for the 'permission-check' attribute.\n\t */\n\tset isPermissionCheck(value) {\n\t\tif (value) this.setAttribute('permission-check', '');\n\t\telse this.removeAttribute('permission-check');\n\t}\n\n\t/**\n\t * Checks if the 'permission-check' attribute is present.\n\t * @returns {boolean} True if the 'permission-check' attribute is present.\n\t */\n\tget isPermissionCheck() {\n\t\treturn this.hasAttribute('permission-check');\n\t}\n\n\tset noShow(value) {\n\t\tif (value) this.setAttribute('no-show', '');\n\t\telse this.removeAttribute('no-show');\n\t}\n\n\t/**\n\t * Checks if the 'show' attribute is present.\n\t * @returns {boolean} True if the 'show' attribute is present.\n\t */\n\tget noShow() {\n\t\treturn this.hasAttribute('no-show');\n\t}\n\n\t/**\n\t * Sets the 'shadow' attribute.\n\t * @param {string} value The value to set for the 'shadow' attribute.\n\t */\n\tset isShadowRoot(value) {\n\t\treturn this.setAttribute('shadow', value);\n\t}\n\n\tget isShadowRoot() {\n\t\treturn this.getAttribute('shadow');\n\t}\n\n\t/**\n\t * Checks if the 'shadow' attribute is present.\n\t * @returns {boolean} True if the 'shadow' attribute is present.\n\t */\n\tget hasShadowRoot() {\n\t\treturn this.hasAttribute('shadow');\n\t}\n\n\t/**\n\t * Gets the value of the 'shadow' attribute or 'open' if not set.\n\t * @returns {string} The value of the 'shadow' attribute or 'open'.\n\t */\n\tget shadowType() {\n\t\treturn this.getAttribute('shadow') || 'open';\n\t}\n\n\t/**\n\t * Gets the rendering context, either the shadow root or the component itself.\n\t * @returns The rendering context.\n\t */\n\tget context() {\n\t\tif (this.hasShadowRoot) {\n\t\t\treturn this.shadowRoot;\n\t\t} else {\n\t\t\treturn this;\n\t\t}\n\t}\n\n\t/**\n\t * Gets the store instance.\n\t * @returns {object} The store instance.\n\t */\n\tget store() {\n\t\treturn store;\n\t}\n\n\t/**\n\t * @typedef {object} ArrayActions\n\t * @property {Function} addAction - Adds an item to the array.\n\t * @property {Function} deleteAction - Deletes an item from the array.\n\t * @property {Function} loadAction - Loads an array.\n\t * @property {Function} updateAction - Updates an item in the array.\n\t * @property {Function} addManyAction - Adds many items to the array.\n\t */\n\n\t/**\n\t * @typedef {object} ObjectActions\n\t * @property {Function} addAction - Replace old object with new object\n\t * @property {Function} deleteAction - Delete item based on key\n\t * @property {Function} updateAction - Update item based on key\n\t */\n\n\t/**\n\t * Gets the default store actions.\n\t * @returns The default store actions for arrays and objects.\n\t */\n\tget defaultStoreActions() {\n\t\treturn defaultStoreActions;\n\t}\n\n\t/**\n\t * Gets the classes to be removed after the component is connected.\n\t * @returns An array of class names to remove.\n\t */\n\tget removeClassAfterConnect() {\n\t\treturn this.getAttribute('remove-class-after-connect')?.split(' ');\n\t}\n\n\t/**\n\t * Sets the component dependencies.\n\t * @param value The dependencies to set.\n\t */\n\tset dependencies(value) {\n\t\tthis._dependencies = value;\n\t}\n\n\t/**\n\t * Gets the component dependencies.\n\t * @returns The component dependencies.\n\t */\n\tget dependencies() {\n\t\treturn this._dependencies;\n\t}\n\n\t/**\n\t * Processes and combines two templates into one.\n\t * @param pTemplate The primary template.\n\t * @param inputTemplate The secondary template.\n\t * @returns The combined template.\n\t */\n\tstatic processTemplates = (pTemplate, inputTemplate) => {\n\t\tconst newTemplate = document.createElement('template');\n\t\tnewTemplate.innerHTML = [inputTemplate.innerHTML, pTemplate?.innerHTML || ''].join('');\n\t\treturn newTemplate;\n\t};\n\n\t/**\n\t * Defines a custom element if not already defined.\n\t * @param name The name of the custom element.\n\t * @param [elementConstructor] The constructor for the custom element.\n\t * @param [options] Additional options for defining the element.\n\t */\n\tstatic define(name, elementConstructor = this, options = {}) {\n\t\tconst definedElement = customElements.get(name);\n\n\t\tif (!definedElement) {\n\t\t\tcustomElements.define(name, elementConstructor, options);\n\t\t}\n\t}\n\n\t/**\n\t * Defines component dependencies by registering custom elements.\n\t */\n\tdefineDependencies() {\n\t\tif (this.dependencies)\n\t\t\tObject.entries(this.dependencies).forEach((name, component) => WJElement.define(name, component));\n\t}\n\n\t/**\n\t * Hook for extending behavior before drawing the component.\n\t * @param context The rendering context, usually the element's shadow root or main DOM element.\n\t * @param appStoreObj The global application store for managing state.\n\t * @param params Additional parameters or attributes for rendering the component.\n\t */\n\tbeforeDraw(context, appStoreObj, params) {\n\t\t// Hook for extending behavior before drawing\n\t}\n\n\t/**\n\t * Renders the component within the provided context.\n\t * @param context The rendering context, usually the element's shadow root or main DOM element.\n\t * @param appStoreObj\n\t * @param params Additional parameters or attributes for rendering the component.\n\t * @returns This implementation does not render anything and returns `null`.\n\t * @description\n\t * The `draw` method is responsible for rendering the component's content.\n\t * Override this method in subclasses to define custom rendering logic.\n\t * @example\n\t * class MyComponent extends WJElement {\n\t * draw(context, appStoreObj, params) {\n\t * const div = document.createElement('div');\n\t * div.textContent = 'Hello, world!';\n\t * context.appendChild(div);\n\t * }\n\t * }\n\t */\n\tdraw(context, appStoreObj, params) {\n\t\treturn null;\n\t}\n\n\t/**\n\t * Hook for extending behavior after drawing the component.\n\t * @param context The rendering context, usually the element's shadow root or main DOM element.\n\t * @param appStoreObj The global application store for managing state.\n\t * @param params Additional parameters or attributes for rendering the component.\n\t */\n\tafterDraw(context, appStoreObj, params) {\n\t\t// Hook for extending behavior after drawing\n\t}\n\n\t/**\n\t * Lifecycle method invoked when the component is connected to the DOM.\n\t */\n\tconnectedCallback() {\n\t\tif (!this.#isRendering) {\n\t\t\tthis.#originalVisibility = this.#originalVisibility ?? this.style.visibility;\n\t\t\tthis.style.visibility = 'hidden';\n\n\t\t\tthis.setupAttributes?.();\n\t\t\tthis.setUpAccessors();\n\n\t\t\tthis.#drawingStatus = this.drawingStatuses.ATTACHED;\n\t\t\tthis.#pristine = false;\n\t\t\tthis.#enqueueUpdate();\n\t\t}\n\t}\n\n\t/**\n\t * Initializes the component, setting up attributes and rendering.\n\t * @param [force] Whether to force initialization.\n\t * @returns A promise that resolves when initialization is complete.\n\t */\n\tinitWjElement = (force = false) => {\n\t\treturn new Promise(async (resolve, reject) => {\n\t\t\tthis.#drawingStatus = this.drawingStatuses.BEGINING;\n\n\t\t\tthis.setupAttributes?.();\n\t\t\tif (this.hasShadowRoot) {\n\t\t\t\tif (!this.shadowRoot) this.attachShadow({ mode: this.shadowType || 'open', delegatesFocus: true });\n\t\t\t}\n\t\t\tthis.setUpAccessors();\n\n\t\t\tthis.#drawingStatus = this.drawingStatuses.START;\n\t\t\tawait this.display(force);\n\n\t\t\tconst sheet = new CSSStyleSheet();\n\t\t\tsheet.replaceSync(this.constructor.cssStyleSheet);\n\n\t\t\tthis.context.adoptedStyleSheets = [sheet];\n\n\t\t\tresolve();\n\t\t});\n\t};\n\n\t/**\n\t * Sets up attributes and event listeners for the component.\n\t * This method retrieves all custom events defined for the component\n\t * and adds event listeners for each of them. When an event is triggered,\n\t * it calls the corresponding method on the host element.\n\t */\n\tsetupAttributes() {\n\t\t// Keď neaký element si zadefinuje funkciu \"setupAttributes\" tak sa obsah tejto funkcie nezavolá\n\n\t\tlet allEvents = WjElementUtils.getEvents(this);\n\t\tallEvents.forEach((customEvent, domEvent) => {\n\t\t\tthis.addEventListener(domEvent, (e) => {\n\t\t\t\tthis.getRootNode().host[customEvent]?.();\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * Hook for extending behavior before disconnecting the component.\n\t */\n\tbeforeDisconnect() {\n\t\t// Hook for extending behavior before disconnecting\n\t}\n\n\t/**\n\t * Hook for extending behavior after disconnecting the component.\n\t */\n\tafterDisconnect() {\n\t\t// Hook for extending behavior after disconnecting\n\t}\n\n\t/**\n\t * Hook for extending behavior before redrawing the component.\n\t */\n\tbeforeRedraw() {\n\t\t// Hook for extending behavior before redrawing\n\t}\n\n\t/**\n\t * Cleans up resources and event listeners for the component.\n\t */\n\tcomponentCleanup() {\n\t\t// Hook for cleaning up the component\n\t}\n\n\t/**\n\t * Lifecycle method invoked when the component is disconnected from the DOM.\n\t */\n\tdisconnectedCallback() {\n\t\tif (this.#isAttached) {\n\t\t\tthis.beforeDisconnect?.();\n\t\t\tthis.context.innerHTML = '';\n\t\t\tthis.afterDisconnect?.();\n\t\t\tthis.#isAttached = false;\n\t\t\tthis.style.visibility = this.#originalVisibility;\n\t\t\tthis.#originalVisibility = null;\n\t\t}\n\n\t\tif (this.#isRendering) {\n\t\t\tthis.stopRenderLoop();\n\t\t}\n\n\t\tthis.#drawingStatus = this.drawingStatuses.DISCONNECTED;\n\n\t\tthis.componentCleanup();\n\t}\n\n\t/**\n\t * Enqueues an update for the component.\n\t * This method processes the current render promise and then refreshes the component.\n\t */\n\t#enqueueUpdate() {\n\t\tif (!this.#isRendering) {\n\t\t\tthis.rafId = requestAnimationFrame(() => this.#refresh());\n\t\t}\n\t}\n\n\t/**\n\t * Lifecycle method invoked when an observed attribute changes.\n\t * @param name The name of the attribute that changed.\n\t * @param old The old value of the attribute.\n\t * @param newName The new value of the attribute.\n\t */\n\tattributeChangedCallback(name, old, newName) {\n\t\tif (old !== newName) {\n\t\t\tthis.#pristine = false;\n\t\t\tthis.#enqueueUpdate();\n\t\t}\n\t}\n\n\trefresh() {\n\t\tthis.updateComplete = new Promise((resolve, reject) => {\n\t\t\tthis.finisPromise = resolve;\n\t\t\tthis.rejectPromise = reject;\n\t\t});\n\n\t\tthis.#pristine = false;\n\t\tthis.#enqueueUpdate();\n\t}\n\n\t/**\n\t * Refreshes the component by reinitializing it if it is in a drawing state.\n\t * This method checks if the component's drawing status is at least in the START state.\n\t * If so, it performs the following steps:\n\t * 1. Calls the `beforeRedraw` hook if defined.\n\t * 2. Calls the `beforeDisconnect` hook if defined.\n\t * 3. Refreshes the update promise to manage the rendering lifecycle.\n\t * 4. Calls the `afterDisconnect` hook if defined.\n\t * 5. Reinitializes the component by calling `initWjElement` with `true` to force initialization.\n\t * If the component is not in a drawing state, it simply returns a resolved promise.\n\t */\n\tasync #refresh() {\n\t\tif (this.#isRendering) {\n\t\t\tthis.rafId = requestAnimationFrame(() => this.#refresh());\n\t\t\treturn; // Skip if async render is still processing\n\t\t}\n\n\t\tif (!this.#pristine) {\n\t\t\tthis.#pristine = true;\n\t\t\tthis.#isRendering = true;\n\n\t\t\tif (this.#isAttached) {\n\t\t\t\tthis.beforeRedraw?.();\n\t\t\t\tthis.beforeDisconnect?.();\n\t\t\t\tthis.afterDisconnect?.();\n\t\t\t} else {\n\t\t\t\tthis.stopRenderLoop();\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tawait this.initWjElement(true);\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error('Render error:', error);\n\t\t\t} finally {\n\t\t\t\tthis.#isRendering = false;\n\n\t\t\t\tif (!this.#pristine) {\n\t\t\t\t\tthis.#pristine = false;\n\t\t\t\t\tthis.#enqueueUpdate();\n\t\t\t\t} else {\n\t\t\t\t\tthis.finisPromise();\n\t\t\t\t\tthis.style.visibility = this.#originalVisibility;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tstopRenderLoop() {\n\t\tif (this.rafId) {\n\t\t\tcancelAnimationFrame(this.rafId);\n\t\t\tthis.rafId = null;\n\t\t}\n\t}\n\n\t/**\n\t * Renders the component within the provided context.\n\t * @param context The rendering context, usually the element's shadow root or main DOM element.\n\t * @param appStore The global application store for managing state.\n\t * @param params Additional parameters or attributes for rendering the component.\n\t * @returns This implementation does not render anything and returns `null`.\n\t * @description\n\t * The `draw` method is responsible for rendering the component's content.\n\t * Override this method in subclasses to define custom rendering logic.\n\t * @example\n\t * class MyComponent extends WJElement {\n\t * draw(context, appStore, params) {\n\t * const div = document.createElement('div');\n\t * div.textContent = 'Hello, world!';\n\t * context.appendChild(div);\n\t * }\n\t * }\n\t */\n\tdraw(context, appStore, params) {\n\t\treturn null;\n\t}\n\n\t/**\n\t * Displays the component's content, optionally forcing a re-render.\n\t * @param [force] Whether to force a re-render.\n\t * @returns A promise that resolves when the display is complete.\n\t */\n\tdisplay(force = false) {\n\t\tthis.template = this.constructor.customTemplate || document.createElement('template');\n\n\t\tif (force) {\n\t\t\t[...this.context.childNodes].forEach(this.context.removeChild.bind(this.context));\n\t\t}\n\n\t\tthis.context.append(this.template.content.cloneNode(true));\n\n\t\tif (this.noShow || (this.isPermissionCheck && !Permissions.isPermissionFulfilled(this.permission))) {\n\t\t\tthis.remove();\n\t\t\treturn Promise.resolve();\n\t\t}\n\n\t\treturn this.#resolveRender();\n\t}\n\n\t/**\n\t * Renders the component's content.\n\t */\n\tasync render() {\n\t\tthis.#drawingStatus = this.drawingStatuses.DRAWING;\n\n\t\tlet _draw = this.draw(this.context, this.store, WjElementUtils.getAttributes(this));\n\n\t\tif (_draw instanceof Promise || _draw?.constructor.name === 'Promise') {\n\t\t\t_draw = await _draw;\n\t\t}\n\n\t\tlet rend = _draw;\n\t\tlet element;\n\n\t\tif (rend instanceof HTMLElement || rend instanceof DocumentFragment) {\n\t\t\telement = rend;\n\t\t} else {\n\t\t\tlet inputTemplate = document.createElement('template');\n\t\t\tinputTemplate.innerHTML = rend;\n\t\t\telement = inputTemplate.content.cloneNode(true);\n\t\t}\n\n\t\tlet rendered = element;\n\n\t\tthis.context.appendChild(rendered);\n\t}\n\n\t/**\n\t * Sanitizes a given name by converting it from kebab-case to camelCase.\n\t * @param {string} name The name in kebab-case format (e.g., \"example-name\").\n\t * @returns {string} The sanitized name in camelCase format (e.g., \"exampleName\").\n\t * @example\n\t * sanitizeName('example-name');\n\t * @example\n\t * sanitizeName('my-custom-component');\n\t */\n\tsanitizeName(name) {\n\t\tlet parts = name.split('-');\n\t\treturn [parts.shift(), ...parts.map((n) => n[0].toUpperCase() + n.slice(1))].join('');\n\t}\n\n\t/**\n\t * Checks if a property on an object has a getter or setter method defined.\n\t * @param {object} obj The object on which the property is defined.\n\t * @param {string} property The name of the property to check.\n\t * @returns {object} An object indicating the presence of getter and setter methods.\n\t * @property {Function|null} hasGetter The getter function if it exists, otherwise `null`.\n\t * @property {Function|null} hasSetter The setter function if it exists, otherwise `null`.\n\t * @example\n\t * const obj = {\n\t * get name() { return 'value'; },\n\t * set name(val) { console.log(val); }\n\t * };\n\t * checkGetterSetter(obj, 'name');\n\t * @example\n\t * const obj = { prop: 42 };\n\t * checkGetterSetter(obj, 'prop');\n\t */\n\tcheckGetterSetter(obj, property) {\n\t\tlet descriptor = Object.getOwnPropertyDescriptor(obj, property);\n\n\t\t// Check if the descriptor is found on the object itself\n\t\tif (descriptor) {\n\t\t\treturn {\n\t\t\t\thasGetter: typeof descriptor.get === 'function' ? descriptor.get : null,\n\t\t\t\thasSetter: typeof descriptor.set === 'function' ? descriptor.set : null,\n\t\t\t};\n\t\t}\n\n\t\t// Otherwise, check the prototype chain\n\t\tlet proto = Object.getPrototypeOf(obj);\n\t\tif (proto) {\n\t\t\treturn this.checkGetterSetter(proto, property);\n\t\t}\n\n\t\t// If the property doesn't exist at all\n\t\treturn { hasGetter: null, hasSetter: null };\n\t}\n\n\t/**\n\t * Sets up property accessors for the component's attributes.\n\t */\n\tsetUpAccessors() {\n\t\tlet attrs = this.getAttributeNames();\n\t\tattrs.forEach((name) => {\n\t\t\tconst sanitizedName = this.sanitizeName(name);\n\n\t\t\tconst { hasGetter, hasSetter } = this.checkGetterSetter(this, sanitizedName);\n\n\t\t\tObject.defineProperty(this, sanitizedName, {\n\t\t\t\tset: hasSetter ?? ((value) => this.setAttribute(name, value)),\n\t\t\t\tget: hasGetter ?? (() => this.getAttribute(name)),\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * Resolves the rendering process of the component.\n\t * @returns A promise that resolves when rendering is complete.\n\t * @private\n\t */\n\t#resolveRender() {\n\t\tthis.params = WjElementUtils.getAttributes(this);\n\n\t\treturn new Promise(async (resolve, reject) => {\n\t\t\tconst __beforeDraw = this.beforeDraw(this.context, this.store, WjElementUtils.getAttributes(this));\n\n\t\t\tif (__beforeDraw instanceof Promise || __beforeDraw?.constructor.name === 'Promise') {\n\t\t\t\tawait __beforeDraw;\n\t\t\t}\n\n\t\t\tawait this.render();\n\n\t\t\tconst __afterDraw = this.afterDraw?.(this.context, this.store, WjElementUtils.getAttributes(this));\n\n\t\t\tif (__afterDraw instanceof Promise || __afterDraw?.constructor.name === 'Promise') {\n\t\t\t\tawait __afterDraw;\n\t\t\t}\n\n\t\t\t// RHR toto je bicykel pre slickRouter pretože routovanie nieje vykonané pokiaľ sa nezavolá updateComplete promise,\n\t\t\t// toto bude treba rozšíriť aby sme lepšie vedeli kontrolovať vykreslovanie elementov, a flow hookov.\n\t\t\tthis.#isRendering = false;\n\t\t\tthis.#isAttached = true;\n\n\t\t\tif (this.removeClassAfterConnect) {\n\t\t\t\tthis.classList.remove(...this.removeClassAfterConnect);\n\t\t\t}\n\n\t\t\tthis.#drawingStatus = this.drawingStatuses.DONE;\n\n\t\t\tresolve();\n\t\t}).catch((e) => {\n\t\t\tconsole.error(e);\n\t\t});\n\t}\n}\n\nlet __esModule = 'true';\nexport { __esModule, Permissions, WjElementUtils, event };\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAMA,MAAM,WAAW,SAAS,cAAc,UAAU;AAClD,SAAS,YAAY;AACN,MAAM,aAAN,MA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YAAW,6CAAc,YAAY,UAAS,WAAW;AACpF,YAAM;AAAA,IACV;AAEG,UAAM,KAAK,OAAQ;AAEnB,UAAM,eAAc,UAAK,cAAL,8BAAiB,KAAK,SAAS,KAAK,OAAO,eAAe,cAAc,IAAI;AAEhG,QAAI,uBAAuB,YAAW,2CAAa,YAAY,UAAS,WAAW;AAClF,YAAM;AAAA,IACV;AAIG,uBAAK,cAAe;AACpB,uBAAK,aAAc;AAEnB,QAAI,KAAK,yBAAyB;AACjC,WAAK,UAAU,OAAO,GAAG,KAAK,uBAAuB;AAAA,IACzD;AAEG,uBAAK,gBAAiB,KAAK,gBAAgB;AAE3C,YAAS;AAAA,EACZ,CAAG,EAAE,MAAM,CAAC,MAAM;AACf,YAAQ,MAAM,CAAC;AAAA,EAClB,CAAG;AACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA/bC,cA7OoB,YA6Ob,oBAAmB,CAAC,WAAW,kBAAkB;AACvD,QAAM,cAAc,SAAS,cAAc,UAAU;AACrD,cAAY,YAAY,CAAC,cAAc,YAAW,uCAAW,cAAa,EAAE,EAAE,KAAK,EAAE;AACrF,SAAO;AACP;AAjPa,IAAM,YAAN;AA+qBZ,IAAC,aAAa;"}
|
|
1
|
+
{"version":3,"file":"wje-element.js","sources":["../packages/wje-element/element.js"],"sourcesContent":["import { UniversalService } from '../utils/universal-service.js';\nimport { Permissions } from '../utils/permissions.js';\nimport { WjElementUtils } from '../utils/element-utils.js';\nimport { event } from '../utils/event.js';\nimport { defaultStoreActions, store } from '../wje-store/store.js';\n\nconst template = document.createElement('template');\ntemplate.innerHTML = ``;\nexport default class WJElement extends HTMLElement {\n\t#drawingStatus;\n\t#isAttached;\n\t#isRendering;\n\t#originalVisibility;\n\t#pristine;\n\n\t/**\n\t * Initializes a new instance of the WJElement class.\n\t */\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.__templateInserted = false;\n\n\t\tthis.#isAttached = false;\n\t\tthis.service = new UniversalService({\n\t\t\tstore: store,\n\t\t});\n\n\t\t// definujeme vsetky zavislosti.\n\t\t// Do zavislosti patria len komponenty, ktore su zavisle od ktoreho je zavisly tento komponent\n\t\tthis.defineDependencies();\n\n\t\tthis.#isRendering = false;\n\t\tthis._dependencies = {};\n\n\t\t/**\n\t\t * @typedef {object} DrawingStatuses\n\t\t * @property {number} CREATED - The component has been created.\n\t\t * @property {number} ATTACHED - The component has been attached to the DOM.\n\t\t * @property {number} BEGINING - The component is beginning to draw.\n\t\t * @property {number} START - The component has started drawing.\n\t\t * @property {number} DRAWING - The component is drawing.\n\t\t * @property {number} DONE - The component has finished drawing.\n\t\t * @property {number} DISCONNECTED - The component has been disconnected from the DOM.\n\t\t */\n\n\t\t/**\n\t\t * WJElement is a base class for custom web components with managed lifecycle, attribute/property sync,\n\t\t * permission-based visibility, and extensibility hooks.\n\t\t * @property {boolean} isAttached - True if the component is currently attached to the DOM.\n\t\t * @property {DrawingStatuses} drawingStatuses - Enum of possible drawing states.\n\t\t * @property {number} drawingStatus - Current drawing status (see drawingStatuses).\n\t\t * @property {boolean} _pristine - True if the component has not been updated since last render.\n\t\t * @property {boolean} isRendering - True if a render is currently in progress.\n\t\t * @property {number|null} rafId - ID of the scheduled animation frame for rendering, or null.\n\t\t * @property {string|null} originalVisibility - Stores the original CSS visibility before rendering.\n\t\t * @property {object} params - Stores the current attributes/properties for rendering.\n\t\t * @property {Promise<void>} updateComplete - Promise resolved when the current update/render is complete.\n\t\t * @property {string[]} permission - List of required permissions (from 'permission' attribute).\n\t\t * @property {boolean} isPermissionCheck - Whether permission checking is enabled (from 'permission-check' attribute).\n\t\t * @property {boolean} noShow - Whether the element should be hidden (from 'no-show' attribute).\n\t\t * @property {string|undefined} isShadowRoot - Value of the 'shadow' attribute, if present.\n\t\t * @property {boolean} hasShadowRoot - True if the 'shadow' attribute is present.\n\t\t * @property {string} shadowType - Type of shadow root ('open' by default).\n\t\t * @property {object} store - Reference to the global store instance.\n\t\t * @property {object} defaultStoreActions - Default store actions for arrays and objects.\n\t\t * @property {string[]|undefined} removeClassAfterConnect - Classes to remove after connect (from 'remove-class-after-connect' attribute).\n\t\t * @property {object} dependencies - Registered component dependencies.\n\t\t * @property {HTMLElement|ShadowRoot} context - The rendering context (shadow root or element itself).\n\t\t */\n\t\tthis.drawingStatuses = {\n\t\t\tCREATED: 0,\n\t\t\tATTACHED: 1,\n\t\t\tBEGINING: 2,\n\t\t\tSTART: 3,\n\t\t\tDRAWING: 4,\n\t\t\tDONE: 5,\n\t\t\tDISCONNECTED: 6,\n\t\t};\n\n\t\tthis.#drawingStatus = this.drawingStatuses.CREATED;\n\n\t\tthis.#pristine = true;\n\t\tthis.#isRendering = false;\n\t\tthis.rafId = null;\n\t\tthis.#originalVisibility = null;\n\t\tthis.params = {};\n\n\t\tthis.updateComplete = new Promise((resolve, reject) => {\n\t\t\tthis.finisPromise = resolve;\n\t\t\tthis.rejectPromise = reject;\n\t\t});\n\t}\n\n\tget drawingStatus() {\n\t\treturn this.#drawingStatus;\n\t}\n\n\t/**\n\t * Sets the value of the 'permission' attribute.\n\t * @param {string[]} value The value to set for the 'permission' attribute.\n\t */\n\tset permission(value) {\n\t\tthis.setAttribute('permission', value.join(','));\n\t}\n\n\t/**\n\t * Gets the value of the 'permission-check' attribute.\n\t * @returns {string[]} The value of the 'permission' attribute.\n\t */\n\tget permission() {\n\t\treturn this.getAttribute('permission')?.split(',') || [];\n\t}\n\n\t/**\n\t * Sets the 'permission-check' attribute.\n\t * @param {boolean} value The value to set for the 'permission-check' attribute.\n\t */\n\tset isPermissionCheck(value) {\n\t\tif (value) this.setAttribute('permission-check', '');\n\t\telse this.removeAttribute('permission-check');\n\t}\n\n\t/**\n\t * Checks if the 'permission-check' attribute is present.\n\t * @returns {boolean} True if the 'permission-check' attribute is present.\n\t */\n\tget isPermissionCheck() {\n\t\treturn this.hasAttribute('permission-check');\n\t}\n\n\tset noShow(value) {\n\t\tif (value) this.setAttribute('no-show', '');\n\t\telse this.removeAttribute('no-show');\n\t}\n\n\t/**\n\t * Checks if the 'show' attribute is present.\n\t * @returns {boolean} True if the 'show' attribute is present.\n\t */\n\tget noShow() {\n\t\treturn this.hasAttribute('no-show');\n\t}\n\n\t/**\n\t * Sets the 'shadow' attribute.\n\t * @param {string} value The value to set for the 'shadow' attribute.\n\t */\n\tset isShadowRoot(value) {\n\t\treturn this.setAttribute('shadow', value);\n\t}\n\n\tget isShadowRoot() {\n\t\treturn this.getAttribute('shadow');\n\t}\n\n\t/**\n\t * Checks if the 'shadow' attribute is present.\n\t * @returns {boolean} True if the 'shadow' attribute is present.\n\t */\n\tget hasShadowRoot() {\n\t\treturn this.hasAttribute('shadow');\n\t}\n\n\t/**\n\t * Gets the value of the 'shadow' attribute or 'open' if not set.\n\t * @returns {string} The value of the 'shadow' attribute or 'open'.\n\t */\n\tget shadowType() {\n\t\treturn this.getAttribute('shadow') || 'open';\n\t}\n\n\t/**\n\t * Gets the rendering context, either the shadow root or the component itself.\n\t * @returns The rendering context.\n\t */\n\tget context() {\n\t\tif (this.hasShadowRoot) {\n\t\t\treturn this.shadowRoot;\n\t\t} else {\n\t\t\treturn this;\n\t\t}\n\t}\n\n\t/**\n\t * Gets the store instance.\n\t * @returns {object} The store instance.\n\t */\n\tget store() {\n\t\treturn store;\n\t}\n\n\t/**\n\t * @typedef {object} ArrayActions\n\t * @property {Function} addAction - Adds an item to the array.\n\t * @property {Function} deleteAction - Deletes an item from the array.\n\t * @property {Function} loadAction - Loads an array.\n\t * @property {Function} updateAction - Updates an item in the array.\n\t * @property {Function} addManyAction - Adds many items to the array.\n\t */\n\n\t/**\n\t * @typedef {object} ObjectActions\n\t * @property {Function} addAction - Replace old object with new object\n\t * @property {Function} deleteAction - Delete item based on key\n\t * @property {Function} updateAction - Update item based on key\n\t */\n\n\t/**\n\t * Gets the default store actions.\n\t * @returns The default store actions for arrays and objects.\n\t */\n\tget defaultStoreActions() {\n\t\treturn defaultStoreActions;\n\t}\n\n\t/**\n\t * Gets the classes to be removed after the component is connected.\n\t * @returns An array of class names to remove.\n\t */\n\tget removeClassAfterConnect() {\n\t\treturn this.getAttribute('remove-class-after-connect')?.split(' ');\n\t}\n\n\t/**\n\t * Sets the component dependencies.\n\t * @param value The dependencies to set.\n\t */\n\tset dependencies(value) {\n\t\tthis._dependencies = value;\n\t}\n\n\t/**\n\t * Gets the component dependencies.\n\t * @returns The component dependencies.\n\t */\n\tget dependencies() {\n\t\treturn this._dependencies;\n\t}\n\n\t/**\n\t * Processes and combines two templates into one.\n\t * @param pTemplate The primary template.\n\t * @param inputTemplate The secondary template.\n\t * @returns The combined template.\n\t */\n\tstatic processTemplates = (pTemplate, inputTemplate) => {\n\t\tconst newTemplate = document.createElement('template');\n\t\tnewTemplate.innerHTML = [inputTemplate.innerHTML, pTemplate?.innerHTML || ''].join('');\n\t\treturn newTemplate;\n\t};\n\n\t/**\n\t * Defines a custom element if not already defined.\n\t * @param name The name of the custom element.\n\t * @param [elementConstructor] The constructor for the custom element.\n\t * @param [options] Additional options for defining the element.\n\t */\n\tstatic define(name, elementConstructor = this, options = {}) {\n\t\tconst definedElement = customElements.get(name);\n\n\t\tif (!definedElement) {\n\t\t\tcustomElements.define(name, elementConstructor, options);\n\t\t}\n\t}\n\n\t/**\n\t * Defines component dependencies by registering custom elements.\n\t */\n\tdefineDependencies() {\n\t\tif (this.dependencies)\n\t\t\tObject.entries(this.dependencies).forEach((name, component) => WJElement.define(name, component));\n\t}\n\n\t/**\n\t * Hook for extending behavior before drawing the component.\n\t * @param context The rendering context, usually the element's shadow root or main DOM element.\n\t * @param appStoreObj The global application store for managing state.\n\t * @param params Additional parameters or attributes for rendering the component.\n\t */\n\tbeforeDraw(context, appStoreObj, params) {\n\t\t// Hook for extending behavior before drawing\n\t}\n\n\t/**\n\t * Renders the component within the provided context.\n\t * @param context The rendering context, usually the element's shadow root or main DOM element.\n\t * @param appStoreObj\n\t * @param params Additional parameters or attributes for rendering the component.\n\t * @returns This implementation does not render anything and returns `null`.\n\t * @description\n\t * The `draw` method is responsible for rendering the component's content.\n\t * Override this method in subclasses to define custom rendering logic.\n\t * @example\n\t * class MyComponent extends WJElement {\n\t * draw(context, appStoreObj, params) {\n\t * const div = document.createElement('div');\n\t * div.textContent = 'Hello, world!';\n\t * context.appendChild(div);\n\t * }\n\t * }\n\t */\n\tdraw(context, appStoreObj, params) {\n\t\treturn null;\n\t}\n\n\t/**\n\t * Hook for extending behavior after drawing the component.\n\t * @param context The rendering context, usually the element's shadow root or main DOM element.\n\t * @param appStoreObj The global application store for managing state.\n\t * @param params Additional parameters or attributes for rendering the component.\n\t */\n\tafterDraw(context, appStoreObj, params) {\n\t\t// Hook for extending behavior after drawing\n\t}\n\n\t/**\n\t * Lifecycle method invoked when the component is connected to the DOM.\n\t */\n\tconnectedCallback() {\n\t\tif (this.#isAttached) return;\n\n\t\tif (!this.#isRendering) {\n\t\t\tthis.#originalVisibility = this.#originalVisibility ?? this.style.visibility;\n\t\t\tthis.style.visibility = 'hidden';\n\n\t\t\tthis.setupAttributes?.();\n\t\t\tthis.setUpAccessors();\n\n\t\t\tthis.#drawingStatus = this.drawingStatuses.ATTACHED;\n\t\t\tthis.#pristine = false;\n\t\t\tthis.#enqueueUpdate();\n\t\t}\n\t}\n\n\t/**\n\t * Initializes the component, setting up attributes and rendering.\n\t * @param [force] Whether to force initialization.\n\t * @returns A promise that resolves when initialization is complete.\n\t */\n\tinitWjElement = (force = false) => {\n\t\treturn new Promise(async (resolve, reject) => {\n\t\t\tthis.#drawingStatus = this.drawingStatuses.BEGINING;\n\n\t\t\tthis.setupAttributes?.();\n\t\t\tif (this.hasShadowRoot) {\n\t\t\t\tif (!this.shadowRoot) this.attachShadow({ mode: this.shadowType || 'open', delegatesFocus: true });\n\t\t\t}\n\t\t\tthis.setUpAccessors();\n\n\t\t\tthis.#drawingStatus = this.drawingStatuses.START;\n\t\t\tawait this.display(force);\n\n\t\t\tconst sheet = new CSSStyleSheet();\n\t\t\tsheet.replaceSync(this.constructor.cssStyleSheet);\n\n\t\t\tthis.context.adoptedStyleSheets = [sheet];\n\n\t\t\tresolve();\n\t\t});\n\t};\n\n\t/**\n\t * Sets up attributes and event listeners for the component.\n\t * This method retrieves all custom events defined for the component\n\t * and adds event listeners for each of them. When an event is triggered,\n\t * it calls the corresponding method on the host element.\n\t */\n\tsetupAttributes() {\n\t\t// Keď neaký element si zadefinuje funkciu \"setupAttributes\" tak sa obsah tejto funkcie nezavolá\n\n\t\tlet allEvents = WjElementUtils.getEvents(this);\n\t\tallEvents.forEach((customEvent, domEvent) => {\n\t\t\tthis.addEventListener(domEvent, (e) => {\n\t\t\t\tthis.getRootNode().host[customEvent]?.();\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * Hook for extending behavior before disconnecting the component.\n\t */\n\tbeforeDisconnect() {\n\t\t// Hook for extending behavior before disconnecting\n\t}\n\n\t/**\n\t * Hook for extending behavior after disconnecting the component.\n\t */\n\tafterDisconnect() {\n\t\t// Hook for extending behavior after disconnecting\n\t}\n\n\t/**\n\t * Hook for extending behavior before redrawing the component.\n\t */\n\tbeforeRedraw() {\n\t\t// Hook for extending behavior before redrawing\n\t}\n\n\t/**\n\t * Cleans up resources and event listeners for the component.\n\t */\n\tcomponentCleanup() {\n\t\t// Hook for cleaning up the component\n\t}\n\n\t/**\n\t * Lifecycle method invoked when the component is disconnected from the DOM.\n\t */\n\tdisconnectedCallback() {\n\t\tif (this.#isAttached) {\n\t\t\tthis.beforeDisconnect?.();\n\t\t\tthis.context.innerHTML = '';\n\t\t\tthis.afterDisconnect?.();\n\t\t\tthis.#isAttached = false;\n\t\t\tthis.style.visibility = this.#originalVisibility;\n\t\t\tthis.#originalVisibility = null;\n\t\t}\n\n\t\tif (this.#isRendering) {\n\t\t\tthis.stopRenderLoop();\n\t\t}\n\n\t\tthis.#drawingStatus = this.drawingStatuses.DISCONNECTED;\n\n\t\tthis.componentCleanup();\n\t}\n\n\t/**\n\t * Enqueues an update for the component.\n\t * This method processes the current render promise and then refreshes the component.\n\t */\n\t#enqueueUpdate() {\n\t\tif (!this.#isRendering) {\n\t\t\tthis.rafId = requestAnimationFrame(() => this.#refresh());\n\t\t}\n\t}\n\n\t/**\n\t * Lifecycle method invoked when an observed attribute changes.\n\t * @param name The name of the attribute that changed.\n\t * @param old The old value of the attribute.\n\t * @param newName The new value of the attribute.\n\t */\n\tattributeChangedCallback(name, old, newName) {\n\t\tif (old !== newName) {\n\t\t\tthis.#pristine = false;\n\t\t\tthis.#enqueueUpdate();\n\t\t}\n\t}\n\n\trefresh() {\n\t\tthis.updateComplete = new Promise((resolve, reject) => {\n\t\t\tthis.finisPromise = resolve;\n\t\t\tthis.rejectPromise = reject;\n\t\t});\n\n\t\tif (this.#isAttached) {\n\t\t\t// 🔥 NEVOLAJ redraw, keď sa práve renderuje\n\t\t\tif (!this.#isRendering) {\n\t\t\t\tthis.#pristine = false;\n\t\t\t\tthis.#enqueueUpdate();\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Refreshes the component by reinitializing it if it is in a drawing state.\n\t * This method checks if the component's drawing status is at least in the START state.\n\t * If so, it performs the following steps:\n\t * 1. Calls the `beforeRedraw` hook if defined.\n\t * 2. Calls the `beforeDisconnect` hook if defined.\n\t * 3. Refreshes the update promise to manage the rendering lifecycle.\n\t * 4. Calls the `afterDisconnect` hook if defined.\n\t * 5. Reinitializes the component by calling `initWjElement` with `true` to force initialization.\n\t * If the component is not in a drawing state, it simply returns a resolved promise.\n\t */\n\tasync #refresh() {\n\t\tif (this.#isRendering) {\n\t\t\tthis.rafId = requestAnimationFrame(() => this.#refresh());\n\t\t\treturn; // Skip if async render is still processing\n\t\t}\n\n\t\tif (!this.#pristine) {\n\t\t\tthis.#pristine = true;\n\t\t\tthis.#isRendering = true;\n\n\t\t\ttry {\n\t\t\t\tthis.beforeRedraw?.();\n\n\t\t\t\tif (this.hasShadowRoot && !this.shadowRoot) {\n\t\t\t\t\tthis.attachShadow({ mode: this.shadowType || 'open', delegatesFocus: true });\n\t\t\t\t}\n\n\t\t\t\tif (!this.#isAttached) {\n\t\t\t\t\t// 🔹 Prvé vykreslenie: vloží template + beforeDraw + render + afterDraw cez #resolveRender\n\t\t\t\t\tawait this.display(false);\n\t\t\t\t} else {\n\t\t\t\t\t// 🔹 Redraw: už nevoláme display(), len znova prebehnú hooky.\n\t\t\t\t\tconst params = WjElementUtils.getAttributes(this);\n\n\t\t\t\t\tconst bd = this.beforeDraw(this.context, this.store, params);\n\t\t\t\t\tif (bd instanceof Promise || bd?.constructor?.name === 'Promise') {\n\t\t\t\t\t\tawait bd;\n\t\t\t\t\t}\n\n\t\t\t\t\tawait this.render();\n\n\t\t\t\t\tconst ad = this.afterDraw?.(this.context, this.store, params);\n\t\t\t\t\tif (ad instanceof Promise || ad?.constructor?.name === 'Promise') {\n\t\t\t\t\t\tawait ad;\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.#drawingStatus = this.drawingStatuses.DONE;\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error('Render error:', error);\n\t\t\t} finally {\n\t\t\t\tthis.#isRendering = false;\n\n\t\t\t\tif (!this.#pristine) {\n\t\t\t\t\tthis.#pristine = false;\n\t\t\t\t\tthis.#enqueueUpdate();\n\t\t\t\t} else {\n\t\t\t\t\tthis.finisPromise();\n\t\t\t\t\tthis.style.visibility = this.#originalVisibility;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tstopRenderLoop() {\n\t\tif (this.rafId) {\n\t\t\tcancelAnimationFrame(this.rafId);\n\t\t\tthis.rafId = null;\n\t\t}\n\t}\n\n\t/**\n\t * Renders the component within the provided context.\n\t * @param context The rendering context, usually the element's shadow root or main DOM element.\n\t * @param appStore The global application store for managing state.\n\t * @param params Additional parameters or attributes for rendering the component.\n\t * @returns This implementation does not render anything and returns `null`.\n\t * @description\n\t * The `draw` method is responsible for rendering the component's content.\n\t * Override this method in subclasses to define custom rendering logic.\n\t * @example\n\t * class MyComponent extends WJElement {\n\t * draw(context, appStore, params) {\n\t * const div = document.createElement('div');\n\t * div.textContent = 'Hello, world!';\n\t * context.appendChild(div);\n\t * }\n\t * }\n\t */\n\tdraw(context, appStore, params) {\n\t\treturn null;\n\t}\n\n\t/**\n\t * Displays the component's content, optionally forcing a re-render.\n\t * @param [force] Whether to force a re-render.\n\t * @returns A promise that resolves when the display is complete.\n\t */\n\tdisplay(force = false) {\n\t\tthis.template = this.constructor.customTemplate || document.createElement('template');\n\n\t\t// Insert template ONLY once per component instance\n\t\tif (!this.__templateInserted && this.context.childElementCount === 0) {\n\t\t\tthis.context.append(this.template.content.cloneNode(true));\n\t\t\tthis.__templateInserted = true;\n\t\t}\n\n\t\t// Base stylesheet – aplikuj raz, keď context existuje.\n\t\tif (this.context && this.constructor.cssStyleSheet) {\n\t\t\tconst sheet = new CSSStyleSheet();\n\t\t\tsheet.replaceSync(this.constructor.cssStyleSheet);\n\t\t\tthis.context.adoptedStyleSheets = [sheet];\n\t\t}\n\n\t\tif (this.noShow || (this.isPermissionCheck && !Permissions.isPermissionFulfilled(this.permission))) {\n\t\t\tthis.remove();\n\t\t\treturn Promise.resolve();\n\t\t}\n\n\t\treturn this.#resolveRender();\n\t}\n\n\t/**\n\t * Renders the component's content.\n\t */\n\tasync render() {\n\t\tthis.#drawingStatus = this.drawingStatuses.DRAWING;\n\n\t\tlet result = this.draw(this.context, this.store, WjElementUtils.getAttributes(this));\n\n\t\tif (result instanceof Promise || result?.constructor?.name === 'Promise') {\n\t\t\tresult = await result;\n\t\t}\n\n\t\t// If draw() returns null or undefined → DO NOT clear DOM (template-only components)\n\t\tif (result === null || result === undefined) {\n\t\t\treturn;\n\t\t}\n\n\t\t// FULL RERENDER: clear existing DOM before inserting new content\n\t\tthis.context.innerHTML = '';\n\n\t\tlet element;\n\n\t\tif (result instanceof HTMLElement || result instanceof DocumentFragment) {\n\t\t\telement = result;\n\t\t} else {\n\t\t\tconst tpl = document.createElement('template');\n\t\t\ttpl.innerHTML = String(result);\n\t\t\telement = tpl.content.cloneNode(true);\n\t\t}\n\n\t\tthis.context.appendChild(element);\n\t}\n\n\t/**\n\t * Sanitizes a given name by converting it from kebab-case to camelCase.\n\t * @param {string} name The name in kebab-case format (e.g., \"example-name\").\n\t * @returns {string} The sanitized name in camelCase format (e.g., \"exampleName\").\n\t * @example\n\t * sanitizeName('example-name');\n\t * @example\n\t * sanitizeName('my-custom-component');\n\t */\n\tsanitizeName(name) {\n\t\tlet parts = name.split('-');\n\t\treturn [parts.shift(), ...parts.map((n) => n[0].toUpperCase() + n.slice(1))].join('');\n\t}\n\n\t/**\n\t * Checks if a property on an object has a getter or setter method defined.\n\t * @param {object} obj The object on which the property is defined.\n\t * @param {string} property The name of the property to check.\n\t * @returns {object} An object indicating the presence of getter and setter methods.\n\t * @property {Function|null} hasGetter The getter function if it exists, otherwise `null`.\n\t * @property {Function|null} hasSetter The setter function if it exists, otherwise `null`.\n\t * @example\n\t * const obj = {\n\t * get name() { return 'value'; },\n\t * set name(val) { console.log(val); }\n\t * };\n\t * checkGetterSetter(obj, 'name');\n\t * @example\n\t * const obj = { prop: 42 };\n\t * checkGetterSetter(obj, 'prop');\n\t */\n\tcheckGetterSetter(obj, property) {\n\t\tlet descriptor = Object.getOwnPropertyDescriptor(obj, property);\n\n\t\t// Check if the descriptor is found on the object itself\n\t\tif (descriptor) {\n\t\t\treturn {\n\t\t\t\thasGetter: typeof descriptor.get === 'function' ? descriptor.get : null,\n\t\t\t\thasSetter: typeof descriptor.set === 'function' ? descriptor.set : null,\n\t\t\t};\n\t\t}\n\n\t\t// Otherwise, check the prototype chain\n\t\tlet proto = Object.getPrototypeOf(obj);\n\t\tif (proto) {\n\t\t\treturn this.checkGetterSetter(proto, property);\n\t\t}\n\n\t\t// If the property doesn't exist at all\n\t\treturn { hasGetter: null, hasSetter: null };\n\t}\n\n\t/**\n\t * Sets up property accessors for the component's attributes.\n\t */\n\tsetUpAccessors() {\n\t\tlet attrs = this.getAttributeNames();\n\t\tattrs.forEach((name) => {\n\t\t\tconst sanitizedName = this.sanitizeName(name);\n\n\t\t\tconst { hasGetter, hasSetter } = this.checkGetterSetter(this, sanitizedName);\n\n\t\t\tObject.defineProperty(this, sanitizedName, {\n\t\t\t\tset: hasSetter ?? ((value) => this.setAttribute(name, value)),\n\t\t\t\tget: hasGetter ?? (() => this.getAttribute(name)),\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * Resolves the rendering process of the component.\n\t * @returns A promise that resolves when rendering is complete.\n\t * @private\n\t */\n\t#resolveRender() {\n\t\tthis.params = WjElementUtils.getAttributes(this);\n\n\t\treturn new Promise(async (resolve, reject) => {\n\t\t\tconst __beforeDraw = this.beforeDraw(this.context, this.store, WjElementUtils.getAttributes(this));\n\n\t\t\tif (__beforeDraw instanceof Promise || __beforeDraw?.constructor.name === 'Promise') {\n\t\t\t\tawait __beforeDraw;\n\t\t\t}\n\n\t\t\tawait this.render();\n\n\t\t\t// Počkaj na flush DOMu (mikrotask), aby v afterDraw už boli elementy pripravené\n\t\t\tawait new Promise(r => queueMicrotask(r));\n\n\t\t\tconst __afterDraw = this.afterDraw?.(this.context, this.store, WjElementUtils.getAttributes(this));\n\n\t\t\tif (__afterDraw instanceof Promise || __afterDraw?.constructor.name === 'Promise') {\n\t\t\t\tawait __afterDraw;\n\t\t\t}\n\n\t\t\t// RHR toto je bicykel pre slickRouter pretože routovanie nieje vykonané pokiaľ sa nezavolá updateComplete promise,\n\t\t\t// toto bude treba rozšíriť aby sme lepšie vedeli kontrolovať vykreslovanie elementov, a flow hookov.\n\t\t\tthis.#isRendering = false;\n\t\t\tthis.#isAttached = true;\n\n\t\t\tif (this.removeClassAfterConnect) {\n\t\t\t\tthis.classList.remove(...this.removeClassAfterConnect);\n\t\t\t}\n\n\t\t\tthis.#drawingStatus = this.drawingStatuses.DONE;\n\n\t\t\tresolve();\n\t\t}).catch((e) => {\n\t\t\tconsole.error(e);\n\t\t});\n\t}\n}\n\nlet __esModule = 'true';\nexport { __esModule, Permissions, WjElementUtils, event };\n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QAAI,KAAK,yBAAyB;AACjC,WAAK,UAAU,OAAO,GAAG,KAAK,uBAAuB;AAAA,IACzD;AAEG,uBAAK,gBAAiB,KAAK,gBAAgB;AAE3C,YAAS;AAAA,EACZ,CAAG,EAAE,MAAM,CAAC,MAAM;AACf,YAAQ,MAAM,CAAC;AAAA,EAClB,CAAG;AACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAveC,cA9OoB,YA8Ob,oBAAmB,CAAC,WAAW,kBAAkB;AACvD,QAAM,cAAc,SAAS,cAAc,UAAU;AACrD,cAAY,YAAY,CAAC,cAAc,YAAW,uCAAW,cAAa,EAAE,EAAE,KAAK,EAAE;AACrF,SAAO;AACP;AAlPa,IAAM,YAAN;AAwtBZ,IAAC,aAAa;"}
|
package/dist/wje-img.js
CHANGED
|
@@ -163,17 +163,36 @@ class Img extends WJElement {
|
|
|
163
163
|
* It also invokes the `onerrorFunc` method at the beginning to handle potential error scenarios.
|
|
164
164
|
* @returns {void} Does not return a value.
|
|
165
165
|
*/
|
|
166
|
+
// afterDraw() {
|
|
167
|
+
// let lazyImageObserver = new IntersectionObserver((entries, observer) => {
|
|
168
|
+
// entries.forEach((entry) => {
|
|
169
|
+
// if (entry.isIntersecting) {
|
|
170
|
+
// entry.target.src = this.src;
|
|
171
|
+
// this.classList.remove('lazy');
|
|
172
|
+
//
|
|
173
|
+
// lazyImageObserver.unobserve(entry.target);
|
|
174
|
+
// }
|
|
175
|
+
// });
|
|
176
|
+
// });
|
|
177
|
+
//
|
|
178
|
+
// lazyImageObserver.observe(this.native);
|
|
179
|
+
// }
|
|
166
180
|
afterDraw() {
|
|
167
|
-
|
|
181
|
+
const img = this.native;
|
|
182
|
+
let observer = new IntersectionObserver((entries, obs) => {
|
|
168
183
|
entries.forEach((entry) => {
|
|
169
|
-
if (entry.isIntersecting)
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
184
|
+
if (!entry.isIntersecting) return;
|
|
185
|
+
const realSrc = this.getAttribute("src");
|
|
186
|
+
if (typeof realSrc === "string" && realSrc.length > 0) {
|
|
187
|
+
img.src = realSrc;
|
|
173
188
|
}
|
|
189
|
+
this.classList.remove("lazy");
|
|
190
|
+
obs.unobserve(entry.target);
|
|
174
191
|
});
|
|
175
192
|
});
|
|
176
|
-
|
|
193
|
+
if (img) {
|
|
194
|
+
observer.observe(img);
|
|
195
|
+
}
|
|
177
196
|
}
|
|
178
197
|
/**
|
|
179
198
|
* Adds a new action to the internal actions object.
|
package/dist/wje-img.js.map
CHANGED
|
@@ -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 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') || './assets/img/image-loader.gif';\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);\n native.setAttribute('alt', this.alt || '');\n native.classList.add('lazy-loaded-image', 'lazy');\n native.addEventListener('error', (e) => {\n const absoluteLoaderUrl = new URL(this.loader, window.location.origin).href;\n if (e.target.src === absoluteLoaderUrl) return;\n\n this.setAvatarInitials(true);\n });\n\n this.onerrorFunc(native);\n\n fragment.appendChild(native);\n\n this.native = 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 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\n lazyImageObserver.unobserve(entry.target);\n }\n });\n });\n\n lazyImageObserver.observe(this.native);\n }\n\n setAvatarInitials = (value = false) => {\n let parent = this.parentElement;\n if (parent?.tagName === 'WJE-AVATAR') parent.initials = value;\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 * 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 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;AAAA;AAAA;AAAA;AAAA,EAKvC,cAAc;AACV,UAAO;AAqFX;AAAA;AAAA;AAAA;AAAA,qCAAY;AA6EZ,6CAAoB,CAAC,QAAQ,UAAU;AACnC,UAAI,SAAS,KAAK;AAClB,WAAI,iCAAQ,aAAY,aAAc,QAAO,WAAW;AAAA,IAC3D;AAMD;AAAA;AAAA;AAAA;AAAA;AAAA,uCAAc,MAAM;AAChB,WAAK,OAAQ;AAAA,IAChB;AAsCD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uCAAc,CAAC,QAAQ;AACnB,UAAI,CAAC,KAAK,QAAS;AACnB,UAAI,KAAK,QAAQ,KAAK,OAAO,GAAG;AAC5B,YAAI,UAAU,KAAK,QAAQ,KAAK,OAAO;AAAA,MACnD,OAAe;AACH,gBAAQ,MAAM,sBAAsB,KAAK,OAAO;AAAA,MAC5D;AAAA,IACK;AAxNG,SAAK,WAAW;AAEhB,SAAK,UAAU;AAAA,MACX,QAAQ,MAAM,KAAK,YAAa;AAAA,MAChC,KAAK,MAAM,QAAQ,MAAM,0BAA0B,KAAK,GAAG;AAAA,IAC9D;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,IAAI,OAAO;AACX,SAAK,aAAa,OAAO,KAAK;AAAA,EACtC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,MAAM;AACN,WAAO,KAAK,aAAa,KAAK;AAAA,EACtC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,IAAI,OAAO;AACX,SAAK,aAAa,OAAO,KAAK;AAAA,EACtC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,M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AK,kBAAkB,IAAI;AAAA,IACvC,CAAS;AAED,SAAK,YAAY,MAAM;AAEvB,aAAS,YAAY,MAAM;AAE3B,SAAK,SAAS;AAEd,WAAO;AAAA,EACf;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASI,YAAY;AACR,QAAI,oBAAoB,IAAI,qBAAqB,CAAC,SAAS,aAAa;AACpE,cAAQ,QAAQ,CAAC,UAAU;AACvB,YAAI,MAAM,gBAAgB;AACtB,gBAAM,OAAO,MAAM,KAAK;AACxB,eAAK,UAAU,OAAO,MAAM;AAE5B,4BAAkB,UAAU,MAAM,MAAM;AAAA,QAC5D;AAAA,MACA,CAAa;AAAA,IACb,CAAS;AAED,sBAAkB,QAAQ,KAAK,MAAM;AAAA,EAC7C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAqBI,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;AAmBA;AC7OA,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') || './assets/img/image-loader.gif';\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);\n native.setAttribute('alt', this.alt || '');\n native.classList.add('lazy-loaded-image', 'lazy');\n native.addEventListener('error', (e) => {\n const absoluteLoaderUrl = new URL(this.loader, window.location.origin).href;\n if (e.target.src === absoluteLoaderUrl) return;\n\n this.setAvatarInitials(true);\n });\n\n this.onerrorFunc(native);\n\n fragment.appendChild(native);\n\n this.native = 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 // 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 //\n // lazyImageObserver.unobserve(entry.target);\n // }\n // });\n // });\n //\n // lazyImageObserver.observe(this.native);\n // }\n\n afterDraw() {\n const img = this.native;\n\n let observer = new IntersectionObserver((entries, obs) => {\n entries.forEach((entry) => {\n if (!entry.isIntersecting) return;\n\n const realSrc = this.getAttribute('src');\n\n if (typeof realSrc === 'string' && realSrc.length > 0) {\n img.src = realSrc;\n }\n\n this.classList.remove('lazy');\n\n obs.unobserve(entry.target);\n });\n });\n\n if (img) {\n observer.observe(img);\n }\n }\n\n setAvatarInitials = (value = false) => {\n let parent = this.parentElement;\n if (parent?.tagName === 'WJE-AVATAR') parent.initials = value;\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 * 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 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;AAAA;AAAA;AAAA;AAAA,EAKvC,cAAc;AACV,UAAO;AAqFX;AAAA;AAAA;AAAA;AAAA,qCAAY;AAqGZ,6CAAoB,CAAC,QAAQ,UAAU;AACnC,UAAI,SAAS,KAAK;AAClB,WAAI,iCAAQ,aAAY,aAAc,QAAO,WAAW;AAAA,IA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YAAI,CAAC,MAAM,eAAgB;AAE3B,cAAM,UAAU,KAAK,aAAa,KAAK;AAEvC,YAAI,OAAO,YAAY,YAAY,QAAQ,SAAS,GAAG;AACnD,cAAI,MAAM;AAAA,QAC9B;AAEgB,aAAK,UAAU,OAAO,MAAM;AAE5B,YAAI,UAAU,MAAM,MAAM;AAAA,MAC1C,CAAa;AAAA,IACb,CAAS;AAED,QAAI,KAAK;AACL,eAAS,QAAQ,GAAG;AAAA,IAChC;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAqBI,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;AAmBA;ACrQA,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.
|
|
4
|
+
"version": "0.1.243",
|
|
5
5
|
"homepage": "https://github.com/lencys/wj-elements",
|
|
6
6
|
"author": "Lukáš Ondrejček <lukas.ondrejcek@gmail.com>",
|
|
7
7
|
"license": "MIT",
|