wj-elements 0.3.4 → 0.3.5

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.
@@ -1,4 +1,3 @@
1
- export { bindRouterLinks } from './utils/router-links.js';
2
1
  export { Localizer } from './utils/localize.js';
3
2
  export { Permissions } from './utils/permissions.js';
4
3
  export { UniversalService } from './utils/universal-service.js';
@@ -190,8 +190,7 @@ export default class Button extends WJElement {
190
190
  * After draw method for the Button element.
191
191
  */
192
192
  afterDraw(): void;
193
- bindRouterLinks(): void;
194
- unbindRouterLinks: () => void;
193
+ unbindRouterLinks: any;
195
194
  /**
196
195
  * Event dialog open method for the Button element.
197
196
  * @param {Event} e The event object
@@ -201,16 +200,6 @@ export default class Button extends WJElement {
201
200
  * Toggle states method for the Button element.
202
201
  */
203
202
  toggleStates: () => void;
204
- /**
205
- * Returns assigned toggle elements.
206
- * @returns {HTMLElement[]}
207
- */
208
- getToggleNodes(): HTMLElement[];
209
- /**
210
- * Sets toggle state and updates slotted toggle visibility.
211
- * @param {'on'|'off'|string} value
212
- */
213
- setToggleState(value: "on" | "off" | string): void;
214
203
  /**
215
204
  * Syncs ARIA attributes on the host element.
216
205
  */
@@ -99,15 +99,14 @@ export default class MenuItem extends WJElement {
99
99
  * Adds event listeners after drawing the MenuItem.
100
100
  */
101
101
  afterDraw(): void;
102
+ unbindRouterLinks: any;
102
103
  /**
103
104
  * Syncs ARIA attributes based on menu item state.
104
105
  */
105
106
  syncAria(): void;
106
107
  mouseenterHandler: (e: any) => void;
107
108
  rebindRouterLinks: (e: any) => void;
108
- unbindPortalRouterLinks: () => void;
109
- bindRouterLinks(): void;
110
- unbindRouterLinks: () => void;
109
+ unbindPortalRouterLinks: any;
111
110
  /**
112
111
  * Handles the click event on the MenuItem.
113
112
  * @param {object} e
@@ -27,6 +27,5 @@ export default class RouterLink extends WJElement {
27
27
  */
28
28
  draw(): DocumentFragment;
29
29
  afterDraw(context: any, appStore: any, attributes: any): void;
30
- bindRouterLinks(): void;
31
- unbindRouterLinks: () => void;
30
+ unbindRouterLinks: any;
32
31
  }
@@ -246,8 +246,8 @@ export default class SlidingContainer extends WJElement {
246
246
  * @returns {Promise<void>} A promise that resolves when the transition animation is completed.
247
247
  */
248
248
  doAnimateTransition(): Promise<void>;
249
- animation: Animation;
250
- nativeAnimation: Animation;
249
+ animation: any;
250
+ nativeAnimation: any;
251
251
  /**
252
252
  * Opens the sliding container by performing necessary preparatory and transitional operations.
253
253
  * @param {Event} e The event that triggered the open operation.
@@ -63,8 +63,7 @@ export default class Tab extends WJElement {
63
63
  * // @fires wje-tab:change - Dispatched when the component is clicked, indicating a tab change.
64
64
  */
65
65
  afterDraw(): void;
66
- bindRouterLinks(): void;
67
- unbindRouterLinks: () => void;
66
+ unbindRouterLinks: any;
68
67
  /**
69
68
  * Sync aria-label on host based on slotted text when not provided.
70
69
  */
@@ -51,7 +51,6 @@ function mutationHandler(mutations, observer) {
51
51
  }
52
52
  const elementsObserverConfig = { childList: true, subtree: true, attributes: true };
53
53
  function getAttributeValues(el, prefix, result) {
54
- if (!el) return result;
55
54
  const attributes = el.attributes;
56
55
  for (let i = 0; i < attributes.length; i++) {
57
56
  const attr = attributes[i];
@@ -68,7 +67,6 @@ function getDefaults(rootEl, routeName, propName, routeEl, options) {
68
67
  return result || {};
69
68
  }
70
69
  function getRouteProp(rootEl, routeName, routeEl, propName, attrPrefix) {
71
- if (!rootEl || !routeEl || !rootEl[routerLinksData]) return {};
72
70
  const options = rootEl[routerLinksData].options;
73
71
  const defaults = getDefaults(rootEl, routeName, propName, routeEl, options);
74
72
  getAttributeValues(rootEl, attrPrefix, defaults);
@@ -82,7 +80,6 @@ function updateActiveClass(el, routeName, params, query) {
82
80
  }
83
81
  }
84
82
  function updateLink(el, rootEl) {
85
- if (!el || !rootEl) return;
86
83
  const routeName = el.getAttribute("route");
87
84
  if (!routeName) return;
88
85
  const params = getRouteProp(rootEl, routeName, el, "params", "param-");
@@ -99,7 +96,6 @@ function updateLink(el, rootEl) {
99
96
  }
100
97
  }
101
98
  function createLinks(rootEl) {
102
- if (!rootEl) return;
103
99
  const routeEls = rootEl.querySelectorAll("[route]");
104
100
  routeEls.forEach((el) => {
105
101
  updateLink(el, rootEl);
@@ -109,7 +105,6 @@ function linkClickHandler(e) {
109
105
  if (e.type === "click" && (e.button !== 0 || isModifiedEvent(e))) return;
110
106
  e.preventDefault();
111
107
  const el = e.selectorTarget;
112
- if (!el) return;
113
108
  const routeName = el.getAttribute("route");
114
109
  if (!routeName) return;
115
110
  const params = getRouteProp(this, routeName, el, "params", "param-");
@@ -118,18 +113,21 @@ function linkClickHandler(e) {
118
113
  router[method](routeName, params, query);
119
114
  }
120
115
  function bindRouterLinks(rootEl, options = {}) {
121
- if (!rootEl) return () => {
122
- };
123
116
  const observer = new MutationObserver(mutationHandler);
124
117
  observer.rootEl = rootEl;
125
118
  rootEl[routerLinksData] = { options, observer };
126
- const eventHandler = delegate(rootEl, options.event || "click", "[route]", linkClickHandler, rootEl);
119
+ const eventHandler = delegate(
120
+ rootEl,
121
+ options.event || "click",
122
+ "[route]",
123
+ linkClickHandler,
124
+ rootEl
125
+ );
127
126
  createLinks(rootEl);
128
127
  observer.observe(rootEl, elementsObserverConfig);
129
128
  linkContainers.add(rootEl);
130
129
  return function() {
131
130
  linkContainers.delete(rootEl);
132
- observer.disconnect();
133
131
  undelegate(rootEl, eventHandler);
134
132
  };
135
133
  }
@@ -138,10 +136,6 @@ function create(instance) {
138
136
  }
139
137
  function done() {
140
138
  linkContainers.forEach((rootEl) => {
141
- if (!rootEl || typeof rootEl.querySelectorAll !== "function" || !rootEl[routerLinksData]) {
142
- linkContainers.delete(rootEl);
143
- return;
144
- }
145
139
  rootEl.querySelectorAll("[route]").forEach((el) => {
146
140
  const routeName = el.getAttribute("route");
147
141
  if (!routeName) return;
@@ -159,4 +153,4 @@ export {
159
153
  bindRouterLinks as b,
160
154
  routerLinks as r
161
155
  };
162
- //# sourceMappingURL=router-links-DU0wTw84.js.map
156
+ //# sourceMappingURL=router-links-wjqCnncc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router-links-wjqCnncc.js","sources":["../node_modules/slick-router/lib/middlewares/router-links.js"],"sourcesContent":["const routerLinksData = Symbol('routerLinksData')\nconst linkContainers = new Set()\nlet router\n\n/**\n * @callback RoutePropCallback\n * @param {string} routeName\n * @param {HTMLElement} routeEl\n * @return {Record<string, any>}\n *\n * @typedef RouterLinksOptions\n * @property {Record<string, any> | RoutePropCallback} [params]\n * @property {Record<string, any> | RoutePropCallback} [query]\n * @property {string} [event='click']\n */\n\n// Make a event delegation handler for the given `eventName` and `selector`\n// and attach it to `el`.\n// If selector is empty, the listener will be bound to `el`. If not, a\n// new handler that will recursively traverse up the event target's DOM\n// hierarchy looking for a node that matches the selector. If one is found,\n// the event's `delegateTarget` property is set to it and the return the\n// result of calling bound `listener` with the parameters given to the\n// handler.\n\n/**\n * @param {HTMLElement} el\n * @param {string} eventName\n * @param {string} selector\n * @param {Function} listener\n * @param {*} context\n * @return {Function}\n */\nconst delegate = function (el, eventName, selector, listener, context) {\n const handler = function (e) {\n let node = e.target\n for (; node && node !== el; node = node.parentNode) {\n if (node.matches && node.matches(selector)) {\n e.selectorTarget = node\n listener.call(context, e)\n }\n }\n }\n\n handler.eventName = eventName\n el.addEventListener(eventName, handler, false)\n return handler\n}\n\nfunction isModifiedEvent(event) {\n return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey)\n}\n\nconst undelegate = function (el, handler) {\n const eventName = handler.eventName\n el.removeEventListener(eventName, handler, false)\n}\n\nconst camelize = (str) => {\n if (str.indexOf('-') === -1) return str\n const words = str.split('-')\n let result = ''\n for (let i = 0; i < words.length; i++) {\n const word = words[i]\n result += i ? word.charAt(0).toUpperCase() + word.slice(1) : word\n }\n return result\n}\n\nfunction mutationHandler(mutations, observer) {\n mutations.forEach(function (mutation) {\n if (mutation.type === 'attributes') {\n const attr = mutation.attributeName\n if (attr.indexOf('param-') === 0 || attr.indexOf('query-') === 0) {\n updateLink(mutation.target, observer.rootEl)\n }\n } else {\n mutation.addedNodes.forEach((node) => {\n if (node.nodeType === 1) {\n if (node.getAttribute('route')) updateLink(node, observer.rootEl)\n createLinks(observer.rootEl, node)\n }\n })\n }\n })\n}\n\nconst elementsObserverConfig = { childList: true, subtree: true, attributes: true }\n\nfunction getAttributeValues(el, prefix, result) {\n const attributes = el.attributes\n\n for (let i = 0; i < attributes.length; i++) {\n const attr = attributes[i]\n if (attr.name.indexOf(prefix) === 0) {\n const paramName = camelize(attr.name.slice(prefix.length))\n result[paramName] = attr.value\n }\n }\n return result\n}\n\nfunction getDefaults(rootEl, routeName, propName, routeEl, options) {\n let result = options[propName]\n if (typeof result === 'function') result = result.call(rootEl, routeName, routeEl)\n return result || {}\n}\n\nfunction getRouteProp(rootEl, routeName, routeEl, propName, attrPrefix) {\n const options = rootEl[routerLinksData].options\n const defaults = getDefaults(rootEl, routeName, propName, routeEl, options)\n getAttributeValues(rootEl, attrPrefix, defaults)\n return getAttributeValues(routeEl, attrPrefix, defaults)\n}\n\nfunction updateActiveClass(el, routeName, params, query) {\n const activeClass = el.hasAttribute('active-class') ? el.getAttribute('active-class') : 'active'\n if (activeClass) {\n const isActive = router.isActive(routeName, params, query, el.hasAttribute('exact'))\n el.classList.toggle(activeClass, isActive)\n }\n}\n\nfunction updateLink(el, rootEl) {\n const routeName = el.getAttribute('route')\n if (!routeName) return\n const params = getRouteProp(rootEl, routeName, el, 'params', 'param-')\n const query = getRouteProp(rootEl, routeName, el, 'query', 'query-')\n try {\n const href = router.generate(routeName, params, query)\n const anchorEl = el.tagName === 'A' ? el : el.querySelector('a')\n if (anchorEl) anchorEl.setAttribute('href', href)\n if (!router.state.activeTransition) {\n updateActiveClass(el, routeName, params, query)\n }\n } catch (error) {\n console.warn(`Error generating link for \"${routeName}\": ${error}`)\n }\n}\n\n/**\n * @param {HTMLElement} rootEl\n */\nfunction createLinks(rootEl) {\n const routeEls = rootEl.querySelectorAll('[route]')\n\n routeEls.forEach((el) => {\n updateLink(el, rootEl)\n })\n}\n\n/**\n * @param {Event} e\n * @returns\n */\nfunction linkClickHandler(e) {\n if (e.type === 'click' && (e.button !== 0 || isModifiedEvent(e))) return\n e.preventDefault()\n const el = e.selectorTarget\n const routeName = el.getAttribute('route')\n if (!routeName) return\n const params = getRouteProp(this, routeName, el, 'params', 'param-')\n const query = getRouteProp(this, routeName, el, 'query', 'query-')\n const method = el.hasAttribute('replace') ? 'replaceWith' : 'transitionTo'\n router[method](routeName, params, query)\n}\n\n/**\n * @export\n * @param {HTMLElement} rootEl\n * @param {RouterLinksOptions} [options={}]\n * @return {Function}\n */\nexport function bindRouterLinks(rootEl, options = {}) {\n const observer = new MutationObserver(mutationHandler)\n\n observer.rootEl = rootEl\n rootEl[routerLinksData] = { options, observer }\n\n const eventHandler = delegate(\n rootEl,\n options.event || 'click',\n '[route]',\n linkClickHandler,\n rootEl,\n )\n createLinks(rootEl)\n observer.observe(rootEl, elementsObserverConfig)\n\n linkContainers.add(rootEl)\n\n return function () {\n linkContainers.delete(rootEl)\n undelegate(rootEl, eventHandler)\n }\n}\n\nfunction create(instance) {\n router = instance\n}\n\nfunction done() {\n linkContainers.forEach((rootEl) => {\n rootEl.querySelectorAll('[route]').forEach((el) => {\n const routeName = el.getAttribute('route')\n if (!routeName) return\n const params = getRouteProp(rootEl, routeName, el, 'params', 'param-')\n const query = getRouteProp(rootEl, routeName, el, 'query', 'query-')\n updateActiveClass(el, routeName, params, query)\n })\n })\n}\n\nexport const routerLinks = {\n create,\n done,\n}\n"],"names":[],"mappings":"AAAA,MAAM,kBAAkB,OAAO,iBAAiB;AAChD,MAAM,iBAAiB,oBAAI,IAAG;AAC9B,IAAI;AA+BJ,MAAM,WAAW,SAAU,IAAI,WAAW,UAAU,UAAU,SAAS;AACrE,QAAM,UAAU,SAAU,GAAG;AAC3B,QAAI,OAAO,EAAE;AACb,WAAO,QAAQ,SAAS,IAAI,OAAO,KAAK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AI,MAAM;AAEzB,SAAO,WAAY;AACjB,mBAAe,OAAO,MAAM;AAC5B,eAAW,QAAQ,YAAY;AAAA,EACjC;AACF;AAEA,SAAS,OAAO,UAAU;AACxB,WAAS;AACX;AAEA,SAAS,OAAO;AACd,iBAAe,QAAQ,CAAC,WAAW;AACjC,WAAO,iBAAiB,SAAS,EAAE,QAAQ,CAAC,OAAO;AACjD,YAAM,YAAY,GAAG,aAAa,OAAO;AACzC,UAAI,CAAC,UAAW;AAChB,YAAM,SAAS,aAAa,QAAQ,WAAW,IAAI,UAAU,QAAQ;AACrE,YAAM,QAAQ,aAAa,QAAQ,WAAW,IAAI,SAAS,QAAQ;AACnE,wBAAkB,IAAI,WAAW,QAAQ,KAAK;AAAA,IAChD,CAAC;AAAA,EACH,CAAC;AACH;AAEY,MAAC,cAAc;AAAA,EACzB;AAAA,EACA;AACF;","x_google_ignoreList":[0]}
@@ -8,7 +8,7 @@ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot
8
8
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
9
9
  var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
10
10
  var _Button_instances, populateCustomEvent_fn;
11
- import { b as bindRouterLinks } from "./router-links-DU0wTw84.js";
11
+ import { b as bindRouterLinks } from "./router-links-wjqCnncc.js";
12
12
  import { bool } from "./utils.js";
13
13
  import WJElement from "./wje-element.js";
14
14
  import { I as Icon } from "./icon-DVyMc4Wv.js";
@@ -46,8 +46,15 @@ class Button extends WJElement {
46
46
  * Toggle states method for the Button element.
47
47
  */
48
48
  __publicField(this, "toggleStates", () => {
49
- const nextValue = this.getAttribute("value") === "off" ? "on" : "off";
50
- this.setToggleState(nextValue);
49
+ const nodes = this.slotToggle.assignedNodes().filter((node) => node.nodeType === Node.ELEMENT_NODE);
50
+ nodes.forEach((node, index) => {
51
+ if (node.classList.contains("show")) {
52
+ node.classList.remove("show");
53
+ } else {
54
+ node.classList.add("show");
55
+ this.setAttribute("value", index === 0 ? "on" : "off");
56
+ }
57
+ });
51
58
  this.syncAria();
52
59
  });
53
60
  }
@@ -358,14 +365,16 @@ class Button extends WJElement {
358
365
  */
359
366
  afterDraw() {
360
367
  if (this.hasAttribute("route")) {
361
- this.bindRouterLinks();
362
- if (!this.unbindRouterLinks) {
363
- queueMicrotask(() => this.bindRouterLinks());
364
- }
368
+ this.unbindRouterLinks = bindRouterLinks(this.parentElement, { selector: false });
365
369
  }
366
370
  if (this.hasToggle) {
367
- const initialToggleValue = this.getAttribute("value") || (this.toggle === "off" ? "off" : "on");
368
- this.setToggleState(initialToggleValue);
371
+ if (this.toggle === "off") {
372
+ this.slotToggle.assignedNodes()[1].classList.add("show");
373
+ this.setAttribute("value", "off");
374
+ } else {
375
+ this.slotToggle.assignedNodes()[0].classList.add("show");
376
+ this.setAttribute("value", "on");
377
+ }
369
378
  }
370
379
  if (this.hasAttribute("custom-event")) {
371
380
  event.addListener(this, "click", null, __privateMethod(this, _Button_instances, populateCustomEvent_fn));
@@ -393,13 +402,6 @@ class Button extends WJElement {
393
402
  }
394
403
  this.syncAria();
395
404
  }
396
- bindRouterLinks() {
397
- var _a;
398
- const parent = this.parentElement;
399
- if (!parent) return;
400
- (_a = this.unbindRouterLinks) == null ? void 0 : _a.call(this);
401
- this.unbindRouterLinks = bindRouterLinks(parent, { selector: false });
402
- }
403
405
  /**
404
406
  * Before disconnect method for the Button element.
405
407
  */
@@ -414,33 +416,6 @@ class Button extends WJElement {
414
416
  this.removeEventListener("click", this.eventDialogOpen);
415
417
  (_a = this.unbindRouterLinks) == null ? void 0 : _a.call(this);
416
418
  }
417
- /**
418
- * Returns assigned toggle elements.
419
- * @returns {HTMLElement[]}
420
- */
421
- getToggleNodes() {
422
- if (!this.slotToggle) return [];
423
- if (typeof this.slotToggle.assignedElements === "function") {
424
- return this.slotToggle.assignedElements({ flatten: true });
425
- }
426
- return this.slotToggle.assignedNodes().filter((node) => node.nodeType === Node.ELEMENT_NODE);
427
- }
428
- /**
429
- * Sets toggle state and updates slotted toggle visibility.
430
- * @param {'on'|'off'|string} value
431
- */
432
- setToggleState(value) {
433
- const nodes = this.getToggleNodes();
434
- if (!nodes.length) return;
435
- nodes.forEach((node) => node.classList.remove("show"));
436
- const expectedState = value === "off" ? "off" : "on";
437
- const targetNode = expectedState === "off" ? nodes[1] ?? nodes[0] : nodes[0];
438
- targetNode == null ? void 0 : targetNode.classList.add("show");
439
- const normalizedValue = expectedState === "off" && nodes[1] ? "off" : "on";
440
- if (this.getAttribute("value") !== normalizedValue) {
441
- this.setAttribute("value", normalizedValue);
442
- }
443
- }
444
419
  /**
445
420
  * Syncs ARIA attributes on the host element.
446
421
  */
@@ -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 '../utils/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\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', 'value', 'active', 'href'];\n }\n\n attributeChangedCallback(name, oldValue, newValue) {\n super.attributeChangedCallback?.(name, oldValue, newValue);\n if (['disabled', 'value', 'active', 'href'].includes(name)) {\n this.syncAria?.();\n }\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 this.syncAria();\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.bindRouterLinks();\n if (!this.unbindRouterLinks) {\n queueMicrotask(() => this.bindRouterLinks());\n }\n }\n\n // nastavenie toggle podla atributu, ak nie je nastaveny, tak sa zobrazi vzdy prvy element\n if (this.hasToggle) {\n const initialToggleValue = this.getAttribute('value') || (this.toggle === 'off' ? 'off' : 'on');\n this.setToggleState(initialToggleValue);\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 this.syncAria();\n }\n\n bindRouterLinks() {\n const parent = this.parentElement;\n if (!parent) return;\n\n this.unbindRouterLinks?.();\n this.unbindRouterLinks = bindRouterLinks(parent, { selector: false });\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 nextValue = this.getAttribute('value') === 'off' ? 'on' : 'off';\n this.setToggleState(nextValue);\n\n this.syncAria();\n }\n\n /**\n * Returns assigned toggle elements.\n * @returns {HTMLElement[]}\n */\n getToggleNodes() {\n if (!this.slotToggle) return [];\n if (typeof this.slotToggle.assignedElements === 'function') {\n return this.slotToggle.assignedElements({ flatten: true });\n }\n\n return this.slotToggle.assignedNodes().filter((node) => node.nodeType === Node.ELEMENT_NODE);\n }\n\n /**\n * Sets toggle state and updates slotted toggle visibility.\n * @param {'on'|'off'|string} value\n */\n setToggleState(value) {\n const nodes = this.getToggleNodes();\n if (!nodes.length) return;\n\n nodes.forEach((node) => node.classList.remove('show'));\n\n const expectedState = value === 'off' ? 'off' : 'on';\n const targetNode = expectedState === 'off' ? (nodes[1] ?? nodes[0]) : nodes[0];\n targetNode?.classList.add('show');\n\n const normalizedValue = expectedState === 'off' && nodes[1] ? 'off' : 'on';\n if (this.getAttribute('value') !== normalizedValue) {\n this.setAttribute('value', normalizedValue);\n }\n }\n\n /**\n * Syncs ARIA attributes on the host element.\n */\n syncAria() {\n const isLink = this.hasAttribute('href');\n const isToggle = !!this.hasToggle;\n const pressed = isToggle && !isLink ? this.getAttribute('value') === 'on' : undefined;\n\n this.setAriaState({\n role: isLink ? 'link' : 'button',\n disabled: this.disabled,\n pressed,\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;AA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;AAE5E,SAAK,aAAa;AAAA,MACd,MAAM,SAAS,SAAS;AAAA,MACxB,UAAU,KAAK;AAAA,MACf;AAAA,IACZ,CAAS;AAAA,EACL;AAcJ;AAhiBe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA2hBX,yBAAoB,WAAG;AACnB,OAAK;AAAA,IACH,IAAI,YAAY,KAAK,aAAa,EAAE,QAAQ,KAAK,uBAAuB,UAAU,MAAM,SAAS,KAAI,CAAE;AAAA,EACjH;AACI;AAAA;AAAA;AAAA;AAAA;AAAA;AA9RA,cAjQiB,QAiQV,kBAAiB;AC3R5B,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\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', 'value', 'active', 'href'];\n }\n\n attributeChangedCallback(name, oldValue, newValue) {\n super.attributeChangedCallback?.(name, oldValue, newValue);\n if (['disabled', 'value', 'active', 'href'].includes(name)) {\n this.syncAria?.();\n }\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 this.syncAria();\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 this.syncAria();\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 this.syncAria();\n }\n\n /**\n * Syncs ARIA attributes on the host element.\n */\n syncAria() {\n const isLink = this.hasAttribute('href');\n const isToggle = !!this.hasToggle;\n const pressed = isToggle && !isLink ? this.getAttribute('value') === 'on' : undefined;\n\n this.setAriaState({\n role: isLink ? 'link' : 'button',\n disabled: this.disabled,\n pressed,\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,UAAK;AANE;AAaX;AAAA;AAAA;AAAA;AAAA,wCAAe;AAAA,MACX,YAAY;AAAA,IACpB;AAkNI;AAAA;AAAA;AAAA;AAAA,qCAAY;AA+OZ;AAAA;AAAA;AAAA;AAAA,2CAAkB,CAAC,MAAM;AACrB,YAAM,oBAAoB,MAAM,KAAK,MAAM;AAAA,IAC/C;AAKA;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,QAChC,OAAO;AACH,eAAK,UAAU,IAAI,MAAM;AACzB,eAAK,aAAa,SAAS,UAAU,IAAI,OAAO,KAAK;AAAA,QACzD;AA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AAM,UAAU,YAAY,CAAC,SAAS,KAAK,aAAa,OAAO,MAAM,OAAO;AAE5E,SAAK,aAAa;AAAA,MACd,MAAM,SAAS,SAAS;AAAA,MACxB,UAAU,KAAK;AAAA,MACf;AAAA,IACZ,CAAS;AAAA,EACL;AAcJ;AAjgBe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA4fX,yBAAoB,WAAG;AACnB,OAAK;AAAA,IACH,IAAI,YAAY,KAAK,aAAa,EAAE,QAAQ,KAAK,uBAAuB,UAAU,MAAM,SAAS,KAAI,CAAE;AAAA,EACjH;AACI;AAAA;AAAA;AAAA;AAAA;AAAA;AA/PA,cAjQiB,QAiQV,kBAAiB;AC3R5B,OAAO,OAAO,cAAc,MAAM;"}
@@ -1,7 +1,7 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import { b } from "./router-links-DU0wTw84.js";
4
+ import { b } from "./router-links-wjqCnncc.js";
5
5
  import { Localizer } from "./localize.js";
6
6
  import { Permissions } from "./permissions.js";
7
7
  import { UniversalService } from "./universal-service.js";
@@ -8,7 +8,7 @@ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot
8
8
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
9
9
  var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
10
10
  var _MenuItem_instances, populateCustomEvent_fn;
11
- import { b as bindRouterLinks } from "./router-links-DU0wTw84.js";
11
+ import { b as bindRouterLinks } from "./router-links-wjqCnncc.js";
12
12
  import WJElement from "./wje-element.js";
13
13
  import { WjElementUtils } from "./element-utils.js";
14
14
  import { event } from "./event.js";
@@ -209,11 +209,7 @@ class MenuItem extends WJElement {
209
209
  }
210
210
  });
211
211
  __publicField(this, "rebindRouterLinks", (e) => {
212
- var _a, _b;
213
- const container = (_a = e == null ? void 0 : e.detail) == null ? void 0 : _a.container;
214
- if (!container) return;
215
- (_b = this.unbindPortalRouterLinks) == null ? void 0 : _b.call(this);
216
- this.unbindPortalRouterLinks = bindRouterLinks(container, { selector: false });
212
+ this.unbindPortalRouterLinks = bindRouterLinks(e.detail.container, { selector: "[route]" });
217
213
  });
218
214
  /**
219
215
  * Handles the click event on the MenuItem.
@@ -505,10 +501,7 @@ class MenuItem extends WJElement {
505
501
  * Adds event listeners after drawing the MenuItem.
506
502
  */
507
503
  afterDraw() {
508
- this.bindRouterLinks();
509
- if (!this.unbindRouterLinks) {
510
- queueMicrotask(() => this.bindRouterLinks());
511
- }
504
+ this.unbindRouterLinks = bindRouterLinks(this.parentElement, { selector: "[route]" });
512
505
  document.addEventListener("wje-router:rebind", this.rebindRouterLinks);
513
506
  this.addEventListener("mousemove", this.dispatchMove);
514
507
  this.addEventListener("wje-popup:reposition", this.dispatchReposition);
@@ -538,13 +531,6 @@ class MenuItem extends WJElement {
538
531
  expanded: hasSubmenu ? expanded : void 0
539
532
  });
540
533
  }
541
- bindRouterLinks() {
542
- var _a;
543
- const parent = this.parentElement;
544
- if (!parent) return;
545
- (_a = this.unbindRouterLinks) == null ? void 0 : _a.call(this);
546
- this.unbindRouterLinks = bindRouterLinks(parent, { selector: false });
547
- }
548
534
  /**
549
535
  * Creates a tooltip for the MenuItem when it is collapsed.
550
536
  * @param {HTMLElement} native The native MenuItem element.