wj-elements 0.1.206 → 0.1.208
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/light.css
CHANGED
|
@@ -457,6 +457,7 @@
|
|
|
457
457
|
--wje-menu-shadow: var(--wje-shadow-medium);
|
|
458
458
|
|
|
459
459
|
/* Menu - Item */
|
|
460
|
+
--wje-menu-item-font-size: var(--wje-font-size);
|
|
460
461
|
--wje-menu-item-color: var(--wje-color);
|
|
461
462
|
--wje-menu-item-background: transparent;
|
|
462
463
|
--wje-menu-item-color-hover: var(--wje-color-contrast-8);
|
|
@@ -589,6 +590,7 @@
|
|
|
589
590
|
--wje-tooltip-border-radius: var(--wje-border-radius-medium);
|
|
590
591
|
|
|
591
592
|
/* Tree - Item */
|
|
593
|
+
--wje-tree-item-font-size: var(--wje-font-size-medium);
|
|
592
594
|
--wje-tree-item-padding-inline: var(--wje-spacing-3x-small);
|
|
593
595
|
--wje-tree-item-padding-block: var(--wje-spacing-3x-small);
|
|
594
596
|
--wje-tree-item-indent: var(--wje-spacing-large);
|
package/dist/wje-menu-item.js
CHANGED
|
@@ -26,6 +26,7 @@ const styles = `/*
|
|
|
26
26
|
|
|
27
27
|
display: block;
|
|
28
28
|
.native-menu-item {
|
|
29
|
+
font-size: var(--wje-menu-item-font-size);
|
|
29
30
|
background: var(--wje-menu-item-background);
|
|
30
31
|
position: relative;
|
|
31
32
|
display: flex;
|
|
@@ -272,9 +273,18 @@ class MenuItem extends WJElement {
|
|
|
272
273
|
this.style.setProperty("--wje-menu-item-safe-triangle-submenu-end-y", `${top + height}px`);
|
|
273
274
|
});
|
|
274
275
|
__publicField(this, "handleActiveClick", (e) => {
|
|
276
|
+
var _a, _b;
|
|
275
277
|
const target = e.target.closest("wje-menu-item");
|
|
276
278
|
if (!target) return;
|
|
277
|
-
|
|
279
|
+
let rootMenu = target.closest("wje-menu");
|
|
280
|
+
let currentMenu = rootMenu;
|
|
281
|
+
while (currentMenu == null ? void 0 : currentMenu.parentElement) {
|
|
282
|
+
const parent = (_b = (_a = currentMenu.parentElement).closest) == null ? void 0 : _b.call(_a, "wje-menu");
|
|
283
|
+
if (!parent) break;
|
|
284
|
+
rootMenu = parent;
|
|
285
|
+
currentMenu = parent;
|
|
286
|
+
}
|
|
287
|
+
rootMenu.querySelectorAll("wje-menu-item").forEach((item) => {
|
|
278
288
|
const activeClass = item.getAttribute("active-class");
|
|
279
289
|
if (activeClass) item.classList.remove(activeClass);
|
|
280
290
|
});
|
|
@@ -381,7 +391,6 @@ class MenuItem extends WJElement {
|
|
|
381
391
|
setupAttributes() {
|
|
382
392
|
super.setupAttributes();
|
|
383
393
|
this.isShadowRoot = "open";
|
|
384
|
-
this.setAttribute("active-class", "open");
|
|
385
394
|
}
|
|
386
395
|
/**
|
|
387
396
|
* Removes the active attribute from the menu before drawing the MenuItem.
|
|
@@ -482,7 +491,9 @@ class MenuItem extends WJElement {
|
|
|
482
491
|
if (this.hasAttribute("custom-event")) {
|
|
483
492
|
event.addListener(this, "click", null, __privateMethod(this, _MenuItem_instances, populateCustomEvent_fn));
|
|
484
493
|
}
|
|
485
|
-
this.
|
|
494
|
+
if (this.hasAttribute("active-class")) {
|
|
495
|
+
this.addEventListener("click", this.handleActiveClick);
|
|
496
|
+
}
|
|
486
497
|
}
|
|
487
498
|
/**
|
|
488
499
|
* Creates a tooltip for the MenuItem when it is collapsed.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wje-menu-item.js","sources":["../packages/wje-menu-item/menu-item.element.js","../packages/wje-menu-item/menu-item.js"],"sourcesContent":["import { bindRouterLinks } from 'slick-router/middlewares/router-links.js';\n\nimport { default as WJElement, event, WjElementUtils } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * `MenuItem` is a custom web component that represents a menu item.\n * @summary This element represents a menu item.\n * @documentation https://elements.webjet.sk/components/menu-item\n * @status stable\n * @augments {WJElement}\n * @csspart native - The native part of the menu item.\n * @csspart submenu - The submenu part of the menu item.\n * @slot - The default slot for the menu item.\n * @slot start - The slot for the start of the menu item.\n * @slot end - The slot for the end of the menu item.\n * @slot submenu - The slot for the submenu of the menu item.\n * @cssproperty [--wje-menu-item-color=var(--wje-color)] - Sets the text color of a menu item. Accepts any valid CSS color value.\n * @cssproperty [--wje-menu-item-background=transparent] - Defines the background color of a menu item. Default is `transparent`. Accepts any valid CSS color value.\n * @cssproperty [--wje-menu-item-color-hover=var(--wje-color-contrast-8)] - Specifies the text color of a menu item when hovered. Accepts any valid CSS color value.\n * @cssproperty [--wje-menu-item-background-hover=var(--wje-border-color)] - Sets the background color of a menu item when hovered. Accepts any valid CSS color value.\n * @cssproperty [--wje-menu-item-color-focus=var(--wje-color-contrast-8)] - Defines the text color of a menu item when focused. Accepts any valid CSS color value.\n * @cssproperty [--wje-menu-item-background-focus=var(--wje-border-color)] - Specifies the background color of a menu item when focused. Accepts any valid CSS color value.\n * @cssproperty [--wje-menu-item-color-active=var(--wje-color-contrast-8)] - Sets the text color of a menu item when active. Accepts any valid CSS color value.\n * @cssproperty [--wje-menu-item-background-active=var(--wje-border-color)] - Specifies the background color of a menu item when active. Accepts any valid CSS color value.\n * @cssproperty [--wje-menu-item-padding-top=.5rem] - Specifies the top padding inside a menu item. Accepts any valid CSS length value (e.g., `px`, `rem`).\n * @cssproperty [--wje-menu-item-padding-bottom=.5rem] - Specifies the bottom padding inside a menu item. Accepts any valid CSS length value (e.g., `px`, `rem`).\n * @cssproperty [--wje-menu-item-line-height=1.8rem] - Sets the line height for the text within a menu item. Accepts any valid CSS length value.\n * @cssproperty [--wje-menu-submenu-offset=0] - Determines the horizontal offset of a submenu relative to its parent. Accepts any valid CSS length value.\n * @cssproperty [--wje-menu-item-icon-visibility=hidden] - Controls the visibility of the icon in a menu item. Accepts `visible`, `hidden`, or `collapse`.\n * @cssproperty [--wje-menu-item-safe-triangle-cursor-x] - Specifies the x-coordinate of the cursor for the safe triangle area. Used for managing hover or focus transitions between menu items and submenus.\n * @cssproperty [--wje-menu-item-safe-triangle-cursor-y] - Specifies the y-coordinate of the cursor for the safe triangle area.\n * @cssproperty [--wje-menu-item-safe-triangle-submenu-start-x] - Defines the x-coordinate where the submenu's safe triangle starts. Helps prevent accidental submenu closing when navigating.\n * @cssproperty [--wje-menu-item-safe-triangle-submenu-start-y] - Defines the y-coordinate where the submenu's safe triangle starts.\n * @cssproperty [--wje-menu-item-safe-triangle-submenu-end-x] - Specifies the x-coordinate where the submenu's safe triangle ends.\n * @cssproperty [--wje-menu-item-safe-triangle-submenu-end-y] - Specifies the y-coordinate where the submenu's safe triangle ends.\n * @tag wje-menu-item\n */\nexport default class MenuItem extends WJElement {\n /**\n * Constructor for MenuItem class.\n * @class\n */\n constructor() {\n super();\n\n this._collapsible = false;\n }\n\n /**\n * Getter for placement attribute.\n * @returns {string} The placement attribute of the menu or \"right-start\" if it doesn't exist.\n */\n get placement() {\n let menu = this.querySelector('wje-menu');\n\n if (menu?.hasAttribute('placement')) {\n return menu.getAttribute('placement');\n }\n return 'right-start';\n }\n\n /**\n * Getter for offset attribute.\n * @returns {string} The offset attribute of the menu or \"0\" if it doesn't exist.\n */\n get offset() {\n let menu = this.querySelector('wje-menu');\n\n if (menu?.hasAttribute('offset')) {\n return menu.getAttribute('offset');\n }\n return '0';\n }\n\n /**\n * Getter for variant attribute.\n * @returns {string} The variant attribute of the menu or \"CONTEXT\" if it doesn't exist.\n */\n get variant() {\n let menu = this.querySelector('wje-menu');\n\n if (menu?.hasAttribute('variant') && !this.collapse) {\n return menu.getAttribute('variant').toUpperCase();\n }\n\n return 'CONTEXT';\n }\n\n /**\n * Getter for collapse attribute.\n * @returns {boolean} True if the closest parent has the collapse attribute, false otherwise.\n */\n get collapse() {\n if (this.closest('[collapse]')) return true;\n\n return false;\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 className = 'MenuItem';\n\n /**\n * Getter for cssStyleSheet.\n * @returns {string} The styles imported from styles.css.\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Getter for observedAttributes.\n * @returns {Array} An empty array as no attributes are being observed.\n */\n static get observedAttributes() {\n return [];\n }\n\n /**\n * Sets up the attributes for the MenuItem element.\n */\n setupAttributes() {\n super.setupAttributes();\n this.isShadowRoot = 'open';\n this.setAttribute('active-class', 'open');\n }\n\n /**\n * Removes the active attribute from the menu before drawing the MenuItem.\n */\n beforeDraw() {\n this.querySelector('wje-menu')?.removeAttribute('active');\n }\n\n /**\n * Draws the MenuItem element and sets the variant and collapse attributes.\n * @returns {DocumentFragment} The fragment to be appended to the MenuItem.\n */\n draw() {\n this.hasSubmenu = WjElementUtils.hasSlot(this, 'submenu');\n\n let fragment = document.createDocumentFragment();\n\n this.setAttribute('tabindex', '0');\n\n this.classList.forEach((className) => {\n // Ak trieda začína na \"wje-menu-variant-\", odstráňte ju\n if (className.startsWith('wje-menu-variant-')) {\n this.classList.remove(className);\n }\n });\n\n this.classList.remove('collapse');\n this.classList.add('wje-menu-variant-' + this.variant.toLowerCase());\n\n if (!this.collapse) {\n this.querySelector('wje-menu')?.setAttribute('variant', this.variant.toLowerCase());\n } else if (this.parentElement?.hasAttribute('collapse')) {\n this.classList.add('collapse');\n }\n\n let native = document.createElement('div');\n native.setAttribute('part', 'native');\n native.setAttribute('id', 'anchor');\n native.classList.add('native-menu-item');\n\n // CHECKED - Icon\n let checkedIcon = document.createElement('span');\n checkedIcon.setAttribute('part', 'check');\n checkedIcon.classList.add('check-icon');\n checkedIcon.innerHTML = `<wje-icon name=\"check\"></wje-icon>`;\n\n if (this.hasAttribute('checked')) checkedIcon.classList.add('checked');\n else checkedIcon.classList.remove('checked');\n\n // SLOT - Start\n let start = document.createElement('slot');\n start.name = 'start';\n\n // SLOT\n let slot = document.createElement('slot');\n slot.classList.add('label');\n\n // SLOT - End\n let end = document.createElement('slot');\n end.setAttribute('part', 'end');\n end.name = 'end';\n\n // SLOT - Submenu\n let submenu = document.createElement('slot');\n submenu.setAttribute('part', 'submenu');\n submenu.name = 'submenu';\n\n // SUBMENU - Icon\n let submenuIconClass = this.collapse ? 'collapse' : 'expand';\n let submenuIcon = document.createElement('span');\n submenuIcon.setAttribute('part', 'submenu-icon');\n submenuIcon.classList.add('submenu-icon', submenuIconClass);\n submenuIcon.innerHTML = this.collapse\n ? `<wje-icon name=\"chevron-down\"></wje-icon>`\n : `<wje-icon name=\"chevron-right\"></wje-icon>`;\n\n if (this.hasSubmenu) native.classList.add('has-submenu');\n else native.classList.remove('has-submenu');\n\n native.appendChild(checkedIcon);\n native.appendChild(start);\n native.appendChild(slot);\n native.appendChild(end);\n native.appendChild(submenuIcon);\n\n let isAppend = false;\n // ak je variant typu CONTEXT zobrazime submenu ako popup\n if (this.variant === 'CONTEXT' && this.hasSubmenu) {\n native.setAttribute('slot', 'anchor'); // pridame slot anchor pre popup\n\n let popup = document.createElement('wje-popup');\n popup.setAttribute('anchor', 'anchor');\n popup.setAttribute('placement', this.placement);\n popup.setAttribute('offset', this.offset);\n\n popup.appendChild(native);\n popup.appendChild(submenu);\n\n this.popup = popup;\n fragment.appendChild(popup);\n isAppend = true;\n }\n\n if (this.parentElement?.hasAttribute('collapse') && !this.hasSubmenu) {\n fragment.appendChild(this.collapseItem(native));\n } else if (!isAppend) {\n fragment.appendChild(native);\n }\n\n if ((!this.collapse && this.variant === 'NAV') || (this.variant === 'MEGAMENU' && this.hasSubmenu)) {\n fragment.appendChild(submenu);\n }\n\n this.native = native;\n this.submenu = submenu;\n\n return fragment;\n }\n\n /**\n * Adds event listeners after drawing the MenuItem.\n */\n afterDraw() {\n this.unbindRouterLinks = bindRouterLinks(this.parentElement, { selector: false });\n\n this.addEventListener('mousemove', this.dispatchMove);\n this.addEventListener('wje-popup:reposition', this.dispatchReposition);\n\n // Event na zobrazenie submenu\n event.addListener(this, 'mouseenter', null, this.mouseenterHandler);\n // Event na zrusenie zobrazenia submenu ked sa klikne mimo\n event.addListener(this, 'mouseleave', null, this.shouldHideSubmenu);\n // Event na zrusenie zobrazenia submenu ked sa klikne mimo\n event.addListener(this, 'focusout', null, this.shouldHideSubmenu);\n event.addListener(this, 'click', null, this.clickHandler);\n\n if (this.hasAttribute('custom-event')) {\n event.addListener(this, 'click', null, this.#populateCustomEvent);\n }\n\n this.addEventListener('click', this.handleActiveClick);\n }\n\n mouseenterHandler = (e) => {\n if (this.collapse || (this.variant === 'CONTEXT' && this.hasSubmenu)) {\n if (this.hasAttribute('manual') || (this.variant === 'NAV' && this.collapse)) return;\n\n this.activateSubmenu(e);\n\n e.stopPropagation();\n\n this.showSubmenu();\n // this.focus();\n }\n };\n\n /**\n * Handles the click event on the MenuItem.\n * @param {object} e\n */\n clickHandler = (e) => {\n switch (this.variant) {\n case 'NAV':\n if (!this.collapse && this.hasSubmenu) {\n this.submenuToggle(e);\n this.hideSubmenu();\n e.stopPropagation();\n } else {\n event.dispatchCustomEvent(this, 'wje-menu-item:click');\n event.dispatchCustomEvent(this, this.dialog);\n }\n break;\n case 'CONTEXT':\n if (!this.collapse && this.hasSubmenu) {\n let submenuElements = this.submenu.assignedElements({ flatten: true })[0];\n if (submenuElements?.hasAttribute('active')) {\n this.shouldHideSubmenu(e);\n } else {\n this.activateSubmenu(e);\n this.showSubmenu(e);\n }\n } else {\n event.dispatchCustomEvent(this, 'wje-menu-item:click');\n event.dispatchCustomEvent(this, this.dialog);\n }\n\n break;\n }\n }\n\n /**\n * Checks if the submenu should be hidden based on the event.\n * @param {Event} e The event object.\n */\n shouldHideSubmenu = (e) => {\n if (this.collapse || (this.variant === 'CONTEXT' && this.hasSubmenu)) {\n if ((e.relatedTarget && this.contains(e.relatedTarget)) || (this.variant === 'NAV' && !this.collapse)) {\n return;\n }\n\n this.deactivateSubmenu();\n this.hideSubmenu();\n }\n };\n\n /**\n * Creates a tooltip for the MenuItem when it is collapsed.\n * @param {HTMLElement} native The native MenuItem element.\n * @returns {HTMLElement} The tooltip element.\n */\n collapseItem(native) {\n let tooltipStart = document.createElement('slot');\n tooltipStart.setAttribute('slot', 'start');\n tooltipStart.setAttribute('name', 'tooltip-start');\n\n let tooltipEnd = document.createElement('slot');\n tooltipEnd.setAttribute('slot', 'end');\n tooltipEnd.setAttribute('name', 'tooltip-end');\n\n let tooltip = document.createElement('wje-tooltip');\n tooltip.setAttribute('content', this.getTextFromElement(this));\n tooltip.setAttribute('placement', 'right');\n tooltip.setAttribute('offset', this.offset || '0');\n\n tooltip.appendChild(tooltipStart);\n tooltip.appendChild(tooltipEnd);\n tooltip.appendChild(native);\n\n return tooltip;\n }\n\n /**\n * Dispatches a mousemove event.\n */\n dispatchMove = (e) => {\n this.style.setProperty('--wje-menu-item-safe-triangle-cursor-x', `${e.clientX}px`);\n this.style.setProperty('--wje-menu-item-safe-triangle-cursor-y', `${e.clientY}px`);\n };\n\n /**\n * Dispatches a reposition event.\n */\n dispatchReposition = (e) => {\n // ak nemame submenu tak to ukoncime\n if (this.submenu.assignedNodes().length === 0) return;\n\n let submenu = this.submenu.assignedNodes()[0];\n const { left, top, width, height } = submenu.getBoundingClientRect();\n\n this.style.setProperty('--wje-menu-item-safe-triangle-submenu-start-x', `${left}px`);\n this.style.setProperty('--wje-menu-item-safe-triangle-submenu-start-y', `${top}px`);\n this.style.setProperty('--wje-menu-item-safe-triangle-submenu-end-x', `${left}px`);\n this.style.setProperty('--wje-menu-item-safe-triangle-submenu-end-y', `${top + height}px`);\n };\n\n /**\n * Shows the submenu of the MenuItem.\n */\n showSubmenu() {\n this.tabIndex = -1;\n if (this.hasSubmenu) {\n this.popup?.show();\n this.classList.add('expanded-submenu');\n this.native.classList.add('expanded-submenu');\n }\n }\n\n /**\n * Hides the submenu of the MenuItem.\n */\n hideSubmenu() {\n this.tabIndex = 0;\n if (this.hasSubmenu) {\n this.popup?.hide();\n this.classList.remove('expanded-submenu');\n this.native.classList.remove('expanded-submenu');\n }\n }\n\n /**\n * Toggles the active state of the submenu element.\n * If the submenu is not active, it sets the \"active\" attribute.\n * If the submenu is already active, it removes the \"active\" attribute.\n * @param {Event} e The event object.\n */\n submenuToggle(e) {\n if (this.hasSubmenu) {\n let submenuElements = this.submenu.assignedElements({ flatten: true })[0];\n if (!submenuElements.hasAttribute('active')) {\n submenuElements.setAttribute('active', '');\n } else {\n if (this === e.target) submenuElements.removeAttribute('active');\n }\n }\n }\n\n /**\n * Deactivates the submenu by removing the \"active\" attribute.\n */\n deactivateSubmenu() {\n if (this.hasSubmenu) {\n let submenuElements = this.submenu.assignedElements({ flatten: true })[0];\n if (submenuElements.hasAttribute('active')) {\n submenuElements.removeAttribute('active');\n }\n }\n }\n\n /**\n * Activates the submenu of the menu item.\n */\n activateSubmenu() {\n if (this.hasSubmenu) {\n let submenuElements = this.submenu.assignedElements({ flatten: true })[0];\n if (!submenuElements.hasAttribute('active')) {\n submenuElements.setAttribute('active', '');\n }\n }\n }\n\n /**\n * Gets the text from the element and returns it.\n */\n beforeDisconnect() {\n this.removeEventListener('mousemove', this.dispatchMove);\n this.removeEventListener('wje-popup:reposition', this.dispatchReposition);\n\n event.removeListener(this, 'mouseenter', null, this.mouseenterHandler);\n event.removeListener(this, 'mouseleave', null, this.shouldHideSubmenu);\n event.removeListener(this, 'focusout', null, this.shouldHideSubmenu);\n event.removeListener(this, 'click', null, this.clickHandler);\n\n this.unbindRouterLinks?.();\n }\n\n /**\n * Extracts and returns the concatenated text content from all text nodes within the specified element.\n * @param {HTMLElement} element The HTML element from which to extract text content.\n * @returns {string} The concatenated and trimmed text content from the element's text nodes.\n */\n getTextFromElement(element) {\n let text = '';\n for (let node of element.childNodes) {\n if (node.nodeType === Node.TEXT_NODE) {\n text += node.textContent;\n }\n }\n return text.trim();\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 handleActiveClick = (e) => {\n const target = e.target.closest('wje-menu-item');\n if (!target) return;\n\n // Odstráň všetky existujúce triedy z predchádzajúcich kliknutí\n document.querySelectorAll('wje-menu-item').forEach(item => {\n const activeClass = item.getAttribute('active-class');\n if (activeClass) item.classList.remove(activeClass);\n });\n\n // Pridaj active-class všetkým nadradeným menu-itemom vrátane targetu\n let current = target;\n while (current && current.tagName === 'WJE-MENU-ITEM') {\n const activeClass = current.getAttribute('active-class');\n if (activeClass) current.classList.add(activeClass);\n\n // nájdi najbližší parent wje-menu\n const parentMenu = current.closest('wje-menu');\n if (!parentMenu) break;\n\n // pokračuj na menu-item, ktorý má ako submenu tento parentMenu\n const candidate = parentMenu.closest('wje-menu-item');\n if (!candidate) break;\n\n current = candidate;\n }\n }\n}\n","import MenuItem from './menu-item.element.js';\n\nexport default MenuItem;\n\nMenuItem.define('wje-menu-item', MenuItem);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,QAAQ,iBAAiB,EAAE,SAAS,MAAM,EAAE,CAAC;AACxE,UAAI,CAAC,gBAAgB,aAAa,QAAQ,GAAG;AACzC,wBAAgB,aAAa,UAAU,EAAE;AAAA,MACzD;AAAA,IACA;AAAA,EACA;AAAA;AAAA;AAAA;AAAA,EAKI,mBAAmB;;AACf,SAAK,oBAAoB,aAAa,KAAK,YAAY;AACvD,SAAK,oBAAoB,wBAAwB,KAAK,kBAAkB;AAExE,UAAM,eAAe,MAAM,cAAc,MAAM,KAAK,iBAAiB;AACrE,UAAM,eAAe,MAAM,cAAc,MAAM,KAAK,iBAAiB;AACrE,UAAM,eAAe,MAAM,YAAY,MAAM,KAAK,iBAAiB;AACnE,UAAM,eAAe,MAAM,SAAS,MAAM,KAAK,YAAY;AAE3D,eAAK,sBAAL;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOI,mBAAmB,SAAS;AACxB,QAAI,OAAO;AACX,aAAS,QAAQ,QAAQ,YAAY;AACjC,UAAI,KAAK,aAAa,KAAK,WAAW;AAClC,gBAAQ,KAAK;AAAA,MAC7B;AAAA,IACA;AACQ,WAAO,KAAK,KAAM;AAAA,EAC1B;AA0CA;AA/fe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA8dX,yBAAoB,WAAG;AACnB,OAAK;AAAA,IACH,IAAI,YAAY,KAAK,aAAa,EAAE,QAAQ,KAAK,uBAAuB,UAAU,MAAM,SAAS,KAAM,CAAA;AAAA,EACxG;AACT;ACpgBA,SAAS,OAAO,iBAAiB,QAAQ;"}
|
|
1
|
+
{"version":3,"file":"wje-menu-item.js","sources":["../packages/wje-menu-item/menu-item.element.js","../packages/wje-menu-item/menu-item.js"],"sourcesContent":["import { bindRouterLinks } from 'slick-router/middlewares/router-links.js';\n\nimport { default as WJElement, event, WjElementUtils } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * `MenuItem` is a custom web component that represents a menu item.\n * @summary This element represents a menu item.\n * @documentation https://elements.webjet.sk/components/menu-item\n * @status stable\n * @augments {WJElement}\n * @csspart native - The native part of the menu item.\n * @csspart submenu - The submenu part of the menu item.\n * @slot - The default slot for the menu item.\n * @slot start - The slot for the start of the menu item.\n * @slot end - The slot for the end of the menu item.\n * @slot submenu - The slot for the submenu of the menu item.\n * @cssproperty [--wje-menu-item-color=var(--wje-color)] - Sets the text color of a menu item. Accepts any valid CSS color value.\n * @cssproperty [--wje-menu-item-background=transparent] - Defines the background color of a menu item. Default is `transparent`. Accepts any valid CSS color value.\n * @cssproperty [--wje-menu-item-color-hover=var(--wje-color-contrast-8)] - Specifies the text color of a menu item when hovered. Accepts any valid CSS color value.\n * @cssproperty [--wje-menu-item-background-hover=var(--wje-border-color)] - Sets the background color of a menu item when hovered. Accepts any valid CSS color value.\n * @cssproperty [--wje-menu-item-color-focus=var(--wje-color-contrast-8)] - Defines the text color of a menu item when focused. Accepts any valid CSS color value.\n * @cssproperty [--wje-menu-item-background-focus=var(--wje-border-color)] - Specifies the background color of a menu item when focused. Accepts any valid CSS color value.\n * @cssproperty [--wje-menu-item-color-active=var(--wje-color-contrast-8)] - Sets the text color of a menu item when active. Accepts any valid CSS color value.\n * @cssproperty [--wje-menu-item-background-active=var(--wje-border-color)] - Specifies the background color of a menu item when active. Accepts any valid CSS color value.\n * @cssproperty [--wje-menu-item-padding-top=.5rem] - Specifies the top padding inside a menu item. Accepts any valid CSS length value (e.g., `px`, `rem`).\n * @cssproperty [--wje-menu-item-padding-bottom=.5rem] - Specifies the bottom padding inside a menu item. Accepts any valid CSS length value (e.g., `px`, `rem`).\n * @cssproperty [--wje-menu-item-line-height=1.8rem] - Sets the line height for the text within a menu item. Accepts any valid CSS length value.\n * @cssproperty [--wje-menu-submenu-offset=0] - Determines the horizontal offset of a submenu relative to its parent. Accepts any valid CSS length value.\n * @cssproperty [--wje-menu-item-icon-visibility=hidden] - Controls the visibility of the icon in a menu item. Accepts `visible`, `hidden`, or `collapse`.\n * @cssproperty [--wje-menu-item-safe-triangle-cursor-x] - Specifies the x-coordinate of the cursor for the safe triangle area. Used for managing hover or focus transitions between menu items and submenus.\n * @cssproperty [--wje-menu-item-safe-triangle-cursor-y] - Specifies the y-coordinate of the cursor for the safe triangle area.\n * @cssproperty [--wje-menu-item-safe-triangle-submenu-start-x] - Defines the x-coordinate where the submenu's safe triangle starts. Helps prevent accidental submenu closing when navigating.\n * @cssproperty [--wje-menu-item-safe-triangle-submenu-start-y] - Defines the y-coordinate where the submenu's safe triangle starts.\n * @cssproperty [--wje-menu-item-safe-triangle-submenu-end-x] - Specifies the x-coordinate where the submenu's safe triangle ends.\n * @cssproperty [--wje-menu-item-safe-triangle-submenu-end-y] - Specifies the y-coordinate where the submenu's safe triangle ends.\n * @tag wje-menu-item\n */\nexport default class MenuItem extends WJElement {\n /**\n * Constructor for MenuItem class.\n * @class\n */\n constructor() {\n super();\n\n this._collapsible = false;\n }\n\n /**\n * Getter for placement attribute.\n * @returns {string} The placement attribute of the menu or \"right-start\" if it doesn't exist.\n */\n get placement() {\n let menu = this.querySelector('wje-menu');\n\n if (menu?.hasAttribute('placement')) {\n return menu.getAttribute('placement');\n }\n return 'right-start';\n }\n\n /**\n * Getter for offset attribute.\n * @returns {string} The offset attribute of the menu or \"0\" if it doesn't exist.\n */\n get offset() {\n let menu = this.querySelector('wje-menu');\n\n if (menu?.hasAttribute('offset')) {\n return menu.getAttribute('offset');\n }\n return '0';\n }\n\n /**\n * Getter for variant attribute.\n * @returns {string} The variant attribute of the menu or \"CONTEXT\" if it doesn't exist.\n */\n get variant() {\n let menu = this.querySelector('wje-menu');\n\n if (menu?.hasAttribute('variant') && !this.collapse) {\n return menu.getAttribute('variant').toUpperCase();\n }\n\n return 'CONTEXT';\n }\n\n /**\n * Getter for collapse attribute.\n * @returns {boolean} True if the closest parent has the collapse attribute, false otherwise.\n */\n get collapse() {\n if (this.closest('[collapse]')) return true;\n\n return false;\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 className = 'MenuItem';\n\n /**\n * Getter for cssStyleSheet.\n * @returns {string} The styles imported from styles.css.\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Getter for observedAttributes.\n * @returns {Array} An empty array as no attributes are being observed.\n */\n static get observedAttributes() {\n return [];\n }\n\n /**\n * Sets up the attributes for the MenuItem element.\n */\n setupAttributes() {\n super.setupAttributes();\n this.isShadowRoot = 'open';\n }\n\n /**\n * Removes the active attribute from the menu before drawing the MenuItem.\n */\n beforeDraw() {\n this.querySelector('wje-menu')?.removeAttribute('active');\n }\n\n /**\n * Draws the MenuItem element and sets the variant and collapse attributes.\n * @returns {DocumentFragment} The fragment to be appended to the MenuItem.\n */\n draw() {\n this.hasSubmenu = WjElementUtils.hasSlot(this, 'submenu');\n\n let fragment = document.createDocumentFragment();\n\n this.setAttribute('tabindex', '0');\n\n this.classList.forEach((className) => {\n // Ak trieda začína na \"wje-menu-variant-\", odstráňte ju\n if (className.startsWith('wje-menu-variant-')) {\n this.classList.remove(className);\n }\n });\n\n this.classList.remove('collapse');\n this.classList.add('wje-menu-variant-' + this.variant.toLowerCase());\n\n if (!this.collapse) {\n this.querySelector('wje-menu')?.setAttribute('variant', this.variant.toLowerCase());\n } else if (this.parentElement?.hasAttribute('collapse')) {\n this.classList.add('collapse');\n }\n\n let native = document.createElement('div');\n native.setAttribute('part', 'native');\n native.setAttribute('id', 'anchor');\n native.classList.add('native-menu-item');\n\n // CHECKED - Icon\n let checkedIcon = document.createElement('span');\n checkedIcon.setAttribute('part', 'check');\n checkedIcon.classList.add('check-icon');\n checkedIcon.innerHTML = `<wje-icon name=\"check\"></wje-icon>`;\n\n if (this.hasAttribute('checked')) checkedIcon.classList.add('checked');\n else checkedIcon.classList.remove('checked');\n\n // SLOT - Start\n let start = document.createElement('slot');\n start.name = 'start';\n\n // SLOT\n let slot = document.createElement('slot');\n slot.classList.add('label');\n\n // SLOT - End\n let end = document.createElement('slot');\n end.setAttribute('part', 'end');\n end.name = 'end';\n\n // SLOT - Submenu\n let submenu = document.createElement('slot');\n submenu.setAttribute('part', 'submenu');\n submenu.name = 'submenu';\n\n // SUBMENU - Icon\n let submenuIconClass = this.collapse ? 'collapse' : 'expand';\n let submenuIcon = document.createElement('span');\n submenuIcon.setAttribute('part', 'submenu-icon');\n submenuIcon.classList.add('submenu-icon', submenuIconClass);\n submenuIcon.innerHTML = this.collapse\n ? `<wje-icon name=\"chevron-down\"></wje-icon>`\n : `<wje-icon name=\"chevron-right\"></wje-icon>`;\n\n if (this.hasSubmenu) native.classList.add('has-submenu');\n else native.classList.remove('has-submenu');\n\n native.appendChild(checkedIcon);\n native.appendChild(start);\n native.appendChild(slot);\n native.appendChild(end);\n native.appendChild(submenuIcon);\n\n let isAppend = false;\n // ak je variant typu CONTEXT zobrazime submenu ako popup\n if (this.variant === 'CONTEXT' && this.hasSubmenu) {\n native.setAttribute('slot', 'anchor'); // pridame slot anchor pre popup\n\n let popup = document.createElement('wje-popup');\n popup.setAttribute('anchor', 'anchor');\n popup.setAttribute('placement', this.placement);\n popup.setAttribute('offset', this.offset);\n\n popup.appendChild(native);\n popup.appendChild(submenu);\n\n this.popup = popup;\n fragment.appendChild(popup);\n isAppend = true;\n }\n\n if (this.parentElement?.hasAttribute('collapse') && !this.hasSubmenu) {\n fragment.appendChild(this.collapseItem(native));\n } else if (!isAppend) {\n fragment.appendChild(native);\n }\n\n if ((!this.collapse && this.variant === 'NAV') || (this.variant === 'MEGAMENU' && this.hasSubmenu)) {\n fragment.appendChild(submenu);\n }\n\n this.native = native;\n this.submenu = submenu;\n\n return fragment;\n }\n\n /**\n * Adds event listeners after drawing the MenuItem.\n */\n afterDraw() {\n this.unbindRouterLinks = bindRouterLinks(this.parentElement, { selector: false });\n\n this.addEventListener('mousemove', this.dispatchMove);\n this.addEventListener('wje-popup:reposition', this.dispatchReposition);\n\n // Event na zobrazenie submenu\n event.addListener(this, 'mouseenter', null, this.mouseenterHandler);\n // Event na zrusenie zobrazenia submenu ked sa klikne mimo\n event.addListener(this, 'mouseleave', null, this.shouldHideSubmenu);\n // Event na zrusenie zobrazenia submenu ked sa klikne mimo\n event.addListener(this, 'focusout', null, this.shouldHideSubmenu);\n event.addListener(this, 'click', null, this.clickHandler);\n\n if (this.hasAttribute('custom-event')) {\n event.addListener(this, 'click', null, this.#populateCustomEvent);\n }\n\n if(this.hasAttribute('active-class')) {\n this.addEventListener('click', this.handleActiveClick);\n }\n }\n\n mouseenterHandler = (e) => {\n if (this.collapse || (this.variant === 'CONTEXT' && this.hasSubmenu)) {\n if (this.hasAttribute('manual') || (this.variant === 'NAV' && this.collapse)) return;\n\n this.activateSubmenu(e);\n\n e.stopPropagation();\n\n this.showSubmenu();\n // this.focus();\n }\n };\n\n /**\n * Handles the click event on the MenuItem.\n * @param {object} e\n */\n clickHandler = (e) => {\n switch (this.variant) {\n case 'NAV':\n if (!this.collapse && this.hasSubmenu) {\n this.submenuToggle(e);\n this.hideSubmenu();\n e.stopPropagation();\n } else {\n event.dispatchCustomEvent(this, 'wje-menu-item:click');\n event.dispatchCustomEvent(this, this.dialog);\n }\n break;\n case 'CONTEXT':\n if (!this.collapse && this.hasSubmenu) {\n let submenuElements = this.submenu.assignedElements({ flatten: true })[0];\n if (submenuElements?.hasAttribute('active')) {\n this.shouldHideSubmenu(e);\n } else {\n this.activateSubmenu(e);\n this.showSubmenu(e);\n }\n } else {\n event.dispatchCustomEvent(this, 'wje-menu-item:click');\n event.dispatchCustomEvent(this, this.dialog);\n }\n\n break;\n }\n }\n\n /**\n * Checks if the submenu should be hidden based on the event.\n * @param {Event} e The event object.\n */\n shouldHideSubmenu = (e) => {\n if (this.collapse || (this.variant === 'CONTEXT' && this.hasSubmenu)) {\n if ((e.relatedTarget && this.contains(e.relatedTarget)) || (this.variant === 'NAV' && !this.collapse)) {\n return;\n }\n\n this.deactivateSubmenu();\n this.hideSubmenu();\n }\n };\n\n /**\n * Creates a tooltip for the MenuItem when it is collapsed.\n * @param {HTMLElement} native The native MenuItem element.\n * @returns {HTMLElement} The tooltip element.\n */\n collapseItem(native) {\n let tooltipStart = document.createElement('slot');\n tooltipStart.setAttribute('slot', 'start');\n tooltipStart.setAttribute('name', 'tooltip-start');\n\n let tooltipEnd = document.createElement('slot');\n tooltipEnd.setAttribute('slot', 'end');\n tooltipEnd.setAttribute('name', 'tooltip-end');\n\n let tooltip = document.createElement('wje-tooltip');\n tooltip.setAttribute('content', this.getTextFromElement(this));\n tooltip.setAttribute('placement', 'right');\n tooltip.setAttribute('offset', this.offset || '0');\n\n tooltip.appendChild(tooltipStart);\n tooltip.appendChild(tooltipEnd);\n tooltip.appendChild(native);\n\n return tooltip;\n }\n\n /**\n * Dispatches a mousemove event.\n */\n dispatchMove = (e) => {\n this.style.setProperty('--wje-menu-item-safe-triangle-cursor-x', `${e.clientX}px`);\n this.style.setProperty('--wje-menu-item-safe-triangle-cursor-y', `${e.clientY}px`);\n };\n\n /**\n * Dispatches a reposition event.\n */\n dispatchReposition = (e) => {\n // ak nemame submenu tak to ukoncime\n if (this.submenu.assignedNodes().length === 0) return;\n\n let submenu = this.submenu.assignedNodes()[0];\n const { left, top, width, height } = submenu.getBoundingClientRect();\n\n this.style.setProperty('--wje-menu-item-safe-triangle-submenu-start-x', `${left}px`);\n this.style.setProperty('--wje-menu-item-safe-triangle-submenu-start-y', `${top}px`);\n this.style.setProperty('--wje-menu-item-safe-triangle-submenu-end-x', `${left}px`);\n this.style.setProperty('--wje-menu-item-safe-triangle-submenu-end-y', `${top + height}px`);\n };\n\n /**\n * Shows the submenu of the MenuItem.\n */\n showSubmenu() {\n this.tabIndex = -1;\n if (this.hasSubmenu) {\n this.popup?.show();\n this.classList.add('expanded-submenu');\n this.native.classList.add('expanded-submenu');\n }\n }\n\n /**\n * Hides the submenu of the MenuItem.\n */\n hideSubmenu() {\n this.tabIndex = 0;\n if (this.hasSubmenu) {\n this.popup?.hide();\n this.classList.remove('expanded-submenu');\n this.native.classList.remove('expanded-submenu');\n }\n }\n\n /**\n * Toggles the active state of the submenu element.\n * If the submenu is not active, it sets the \"active\" attribute.\n * If the submenu is already active, it removes the \"active\" attribute.\n * @param {Event} e The event object.\n */\n submenuToggle(e) {\n if (this.hasSubmenu) {\n let submenuElements = this.submenu.assignedElements({ flatten: true })[0];\n if (!submenuElements.hasAttribute('active')) {\n submenuElements.setAttribute('active', '');\n } else {\n if (this === e.target) submenuElements.removeAttribute('active');\n }\n }\n }\n\n /**\n * Deactivates the submenu by removing the \"active\" attribute.\n */\n deactivateSubmenu() {\n if (this.hasSubmenu) {\n let submenuElements = this.submenu.assignedElements({ flatten: true })[0];\n if (submenuElements.hasAttribute('active')) {\n submenuElements.removeAttribute('active');\n }\n }\n }\n\n /**\n * Activates the submenu of the menu item.\n */\n activateSubmenu() {\n if (this.hasSubmenu) {\n let submenuElements = this.submenu.assignedElements({ flatten: true })[0];\n if (!submenuElements.hasAttribute('active')) {\n submenuElements.setAttribute('active', '');\n }\n }\n }\n\n /**\n * Gets the text from the element and returns it.\n */\n beforeDisconnect() {\n this.removeEventListener('mousemove', this.dispatchMove);\n this.removeEventListener('wje-popup:reposition', this.dispatchReposition);\n\n event.removeListener(this, 'mouseenter', null, this.mouseenterHandler);\n event.removeListener(this, 'mouseleave', null, this.shouldHideSubmenu);\n event.removeListener(this, 'focusout', null, this.shouldHideSubmenu);\n event.removeListener(this, 'click', null, this.clickHandler);\n\n this.unbindRouterLinks?.();\n }\n\n /**\n * Extracts and returns the concatenated text content from all text nodes within the specified element.\n * @param {HTMLElement} element The HTML element from which to extract text content.\n * @returns {string} The concatenated and trimmed text content from the element's text nodes.\n */\n getTextFromElement(element) {\n let text = '';\n for (let node of element.childNodes) {\n if (node.nodeType === Node.TEXT_NODE) {\n text += node.textContent;\n }\n }\n return text.trim();\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 handleActiveClick = (e) => {\n const target = e.target.closest('wje-menu-item');\n if (!target) return;\n\n let rootMenu = target.closest('wje-menu');\n let currentMenu = rootMenu;\n\n // Nájdite najvyšší rodičovský wje-menu, ktorý obsahuje tento menu-item\n while (currentMenu?.parentElement) {\n const parent = currentMenu.parentElement.closest?.('wje-menu');\n if (!parent) break;\n rootMenu = parent;\n currentMenu = parent;\n }\n\n // Odstráň všetky existujúce triedy z predchádzajúcich kliknutí\n rootMenu.querySelectorAll('wje-menu-item').forEach(item => {\n const activeClass = item.getAttribute('active-class');\n if (activeClass) item.classList.remove(activeClass);\n });\n\n // Pridaj active-class všetkým nadradeným menu-itemom vrátane targetu\n let current = target;\n while (current && current.tagName === 'WJE-MENU-ITEM') {\n const activeClass = current.getAttribute('active-class');\n if (activeClass) current.classList.add(activeClass);\n\n // nájdi najbližší parent wje-menu\n const parentMenu = current.closest('wje-menu');\n if (!parentMenu) break;\n\n // pokračuj na menu-item, ktorý má ako submenu tento parentMenu\n const candidate = parentMenu.closest('wje-menu-item');\n if (!candidate) break;\n\n current = candidate;\n }\n }\n}\n","import MenuItem from './menu-item.element.js';\n\nexport default MenuItem;\n\nMenuItem.define('wje-menu-item', MenuItem);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCe,MAAM,iBAAiB,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA,EAK5C,cAAc;AACV,UAAO;AANA;AA+FX,qCAAY;AA0KZ,6CAAoB,CAAC,MAAM;AACvB,UAAI,KAAK,YAAa,KAAK,YAAY,aAAa,KAAK,YAAa;AAClE,YAAI,KAAK,aAAa,QAAQ,KAAM,KAAK,YAAY,SAAS,KAAK,SAAW;AAE9E,aAAK,gBAAgB,CAAC;AAEtB,UAAE,gBAAiB;AAEnB,aAAK,YAAa;AAAA,MAE9B;AAAA,IACK;AAMD;AAAA;AAAA;AAAA;AAAA,wCAAe,CAAC,MAAM;AAClB,cAAQ,KAAK,SAAO;AAAA,QAChB,KAAK;AACD,cAAI,CAAC,KAAK,YAAY,KAAK,YAAY;AACnC,iBAAK,cAAc,CAAC;AACpB,iBAAK,YAAa;AAClB,cAAE,gBAAiB;AAAA,UACvC,OAAuB;AACH,kBAAM,oBAAoB,MAAM,qBAAqB;AACrD,kBAAM,oBAAoB,MAAM,KAAK,MAAM;AAAA,UAC/D;AACgB;AAAA,QACJ,KAAK;AACD,cAAI,CAAC,KAAK,YAAY,KAAK,YAAY;AACnC,gBAAI,kBAAkB,KAAK,QAAQ,iBAAiB,EAAE,SAAS,MAAM,EAAE,CAAC;AACxE,gBAAI,mDAAiB,aAAa,WAAW;AACzC,mBAAK,kBAAkB,CAAC;AAAA,YAChD,OAA2B;AACH,mBAAK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3gBe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA+dX,yBAAoB,WAAG;AACnB,OAAK;AAAA,IACH,IAAI,YAAY,KAAK,aAAa,EAAE,QAAQ,KAAK,uBAAuB,UAAU,MAAM,SAAS,KAAM,CAAA;AAAA,EACxG;AACT;ACrgBA,SAAS,OAAO,iBAAiB,QAAQ;"}
|
package/dist/wje-pagination.js
CHANGED
|
@@ -281,6 +281,8 @@ class Pagination extends WJElement {
|
|
|
281
281
|
this.isShadowRoot = "open";
|
|
282
282
|
}
|
|
283
283
|
async beforeDraw() {
|
|
284
|
+
this.classList.remove("empty");
|
|
285
|
+
this.removeAttribute("hidden");
|
|
284
286
|
if (!this.totalItems || this.totalItems === 0) {
|
|
285
287
|
this.classList.add("empty");
|
|
286
288
|
if (this.hideEmpty)
|
|
@@ -314,8 +316,11 @@ class Pagination extends WJElement {
|
|
|
314
316
|
select.setAttribute("variant", "standard");
|
|
315
317
|
select.setAttribute("value", this.pageSize);
|
|
316
318
|
select.addEventListener("wje-select:change", (e) => {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
+
if (+e.detail.context.value[0] !== this.pageSize) {
|
|
320
|
+
this.pageSize = +e.detail.context.value[0];
|
|
321
|
+
this.page = 0;
|
|
322
|
+
event.dispatchCustomEvent(this, "wje-pagination:page-change", { page: this.page, pageSize: this.pageSize });
|
|
323
|
+
}
|
|
319
324
|
});
|
|
320
325
|
let options = this.pageSizeOptions.map((o) => {
|
|
321
326
|
let option = document.createElement("wje-option");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wje-pagination.js","sources":["../packages/wje-pagination/service/service.js","../packages/wje-pagination/pagination.element.js","../packages/wje-pagination/pagination.js"],"sourcesContent":["/**\n * Paginates items based on the total number of items, current page, page size, and maximum number of pages to display.\n * @param {number} totalItems The total number of items to paginate.\n * @param {number} [currentPage] The current page number (default is 1).\n * @param {number} [pageSize] The number of items per page (default is 10).\n * @param {number} [maxPages] The maximum number of pages to display in the pagination control (default is 5).\n * @returns {object} An object containing pagination details including total items, current page, page size, total pages, start/end page, start/end index, and the pages array.\n */\nexport function paginate(totalItems, currentPage = 1, pageSize = 10, maxPages = 5) {\n // Calculate total pages\n const totalPages = Math.ceil(totalItems / pageSize);\n\n // Ensure current page is within valid range\n if (currentPage < 1) {\n currentPage = 1;\n } else if (currentPage > totalPages) {\n currentPage = totalPages;\n }\n\n let startPage;\n let endPage;\n\n const pagesNearEnd = maxPages + 1; // Define how close to the end we switch back to 5 pages 4\n\n const boundary = pagesNearEnd + 3;\n\n if (totalPages > boundary) {\n if (currentPage < pagesNearEnd) {\n // If in the first 4 pages, show up to 5 pages\n startPage = 1;\n endPage = Math.min(pagesNearEnd + 1, totalPages); //5\n } else if (currentPage >= totalPages - pagesNearEnd) {\n // If within 4 pages from the end, show last 5 pages\n startPage = Math.max(totalPages - pagesNearEnd, 1); //4\n endPage = totalPages;\n } else {\n const halfPages = Math.floor(maxPages / 2);\n // Otherwise, only show 3 pages (current, previous, next)\n startPage = currentPage - halfPages + 1;\n endPage = maxPages % 2 === 1 ? currentPage + halfPages + 1 : currentPage + halfPages - 1;\n }\n } else {\n startPage = 1;\n endPage = totalPages;\n }\n\n // Calculate start and end item indexes\n const startIndex = (currentPage - 1) * pageSize;\n const endIndex = Math.min(startIndex + pageSize - 1, totalItems - 1);\n\n // Create an array of pages to display\n const pages = Array.from({ length: endPage - startPage + 1 }, (_, i) => startPage + i);\n\n // Return object with all pager properties (preserving original format)\n return {\n boundary: boundary,\n currentPage: currentPage,\n endIndex: endIndex,\n endPage: endPage,\n totalPages: totalPages,\n pages: pages,\n pageSize: pageSize,\n startIndex: startIndex,\n startPage: startPage,\n totalItems: totalItems,\n };\n}\n","import { Localizer } from '../utils/localize.js';\nimport { default as WJElement, event } from '../wje-element/element.js';\nimport { paginate } from './service/service.js';\nimport Icon from '../wje-icon/icon.js';\nimport Button from '../wje-button/button.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary This class represents the Pagination component for navigating through paginated content and dynamically updating navigation elements based on attributes like the number of items, page size, etc. Extends the WJElement class.\n * @documentation https://elements.webjet.sk/components/pagination\n * @status stable\n * @augments WJElement\n * @dependency wje-icon, wje-button\n * @csspart native - The wrapper element for the pagination component.\n */\nexport default class Pagination extends WJElement {\n /**\n * Creates an instance of Pagination.\n */\n constructor() {\n super();\n this.localizer = new Localizer(this);\n\n this._paginateObj = null;\n }\n\n /**\n * Sets the value of the 'page' attribute for the object.\n * @param {string} value The value to set for the 'page' attribute.\n */\n set page(value) {\n this.setAttribute('page', value);\n }\n\n /**\n * Retrieves the current page number as a numeric value.\n * @returns {number} The current page number. Returns 0 if the attribute 'page' is not set or is not a numeric value.\n */\n get page() {\n return +this.getAttribute('page') || 0;\n }\n\n /**\n * Sets the maximum number of pages.\n * Updates the 'max-pages' attribute with the provided value.\n * @param {number|string} value The maximum number of pages to set. Can be a number or a parsable string representing a number.\n */\n set maxPages(value) {\n this.setAttribute('max-pages', value);\n }\n\n /**\n * Gets the maximum number of pages.\n * This getter retrieves the value of the \"max-pages\" attribute from the element.\n * If the attribute is not set or is invalid, it defaults to 3.\n * @returns {number} The maximum number of pages as a numeric value.\n */\n get maxPages() {\n return +this.getAttribute('max-pages') || 10;\n }\n\n /**\n * Sets the `pageSize` attribute to the specified value.\n * @param {number|string} value The desired page size value. This can be a number or a string representation of the size.\n */\n set pageSize(value) {\n this.setAttribute('page-size', value);\n }\n\n /**\n * Retrieves the value of the 'page-size' attribute and converts it to a number.\n * If the attribute is not set or is invalid, returns the default value of 3.\n * @returns {number} The numeric value of the 'page-size' attribute or the default value of 3.\n */\n get pageSize() {\n return +this.getAttribute('page-size') || 3;\n }\n\n /**\n * Sets the total number of items.\n * @param {number} value The new total number of items to set.\n */\n set totalItems(value) {\n this.setAttribute('total-items', value);\n }\n\n /**\n * Retrieves the total number of items represented by the 'total-items' attribute.\n * @returns {number} The total number of items. Defaults to 0 if the attribute is not set or is invalid.\n */\n get totalItems() {\n return +this.getAttribute('total-items') || 0;\n }\n\n /**\n * Sets the visibility of the first button based on the provided value.\n * Adds the 'show-first-button' attribute when the value is truthy, and removes it otherwise.\n * @param {boolean} value Determines whether to show the first button. If true, the 'show-first-button' attribute is added; if false, it is removed.\n */\n set showFirstButton(value) {\n this.removeAttribute('show-first-button');\n\n if (value) {\n this.setAttribute('show-first-button', '');\n }\n }\n\n /**\n * Determines whether the 'show-first-button' attribute is present on the element.\n * @returns {boolean} True if the 'show-first-button' attribute is set; otherwise, false.\n */\n get showFirstButton() {\n return this.hasAttribute('show-first-button');\n }\n\n /**\n * Sets the visibility of the \"last\" button. This method controls the presence\n * or absence of the \"show-last-button\" attribute based on the provided value.\n * @param {boolean} value A boolean value indicating whether to show the \"last\" button.\n * If true, the \"show-last-button\" attribute is added;\n * if false, the attribute is removed.\n */\n set showLastButton(value) {\n this.removeAttribute('show-last-button');\n\n if (value) {\n this.setAttribute('show-last-button', '');\n }\n }\n\n /**\n * Determines if the 'show-last-button' attribute is present on the element.\n * @returns {boolean} True if the 'show-last-button' attribute is present, otherwise false.\n */\n get showLastButton() {\n return this.hasAttribute('show-last-button');\n }\n\n /**\n * Sets the pagination object by calculating the pagination details\n * based on the total items, current page, page size, and maximum pages.\n * @param {object} value The value to set the pagination object. The pagination details are computed internally.\n */\n set paginateObj(value) {\n this._paginateObj = value;\n }\n\n /**\n * Retrieves the pagination object used for managing paginated data.\n * @returns {object} The pagination object containing details and functionality for paginating data.\n */\n get paginateObj() {\n return this._paginateObj;\n }\n\n /**\n * Sets the 'round' attribute on the element. If the provided value is truthy,\n * the 'round' attribute is added. If the value is falsy, the attribute is removed.\n * @param {boolean} value A boolean value determining whether to add or remove the 'round' attribute.\n */\n set round(value) {\n this.removeAttribute('round');\n\n if (value) {\n this.setAttribute('round', '');\n }\n }\n\n /**\n * Retrieves the value of the 'round' attribute for the current element.\n * @returns {boolean} A boolean indicating whether the 'round' attribute is present on the element.\n */\n get round() {\n return this.hasAttribute('round');\n }\n\n /**\n * Sets the `show-info` attribute on the element based on the provided value.\n * @param {boolean} value A boolean indicating whether to add or remove the `show-info` attribute.\n */\n set showInfo(value) {\n this.removeAttribute('show-info');\n\n if (value) {\n this.setAttribute('show-info', '');\n }\n }\n\n /**\n * Retrieves the value of the 'show-info' attribute.\n * Checks if the 'show-info' attribute is present on the element.\n * @returns {boolean} True if the 'show-info' attribute is present, otherwise false.\n */\n get showInfo() {\n return this.hasAttribute('show-info');\n }\n\n set showPageSizeOptions(value) {\n if (!value) return;\n this.setAttribute('show-page-size-options', value);\n }\n\n get showPageSizeOptions() {\n return this.hasAttribute('show-page-size-options');\n }\n\n set pageSizeOptions(value) {\n if (!value) return;\n this.setAttribute('page-size-options', value);\n }\n\n /**\n * Retrieves the list of available page size options.\n * This method is used to fetch the values representing the different page size options\n * that can be provided or configured in a paginated component or system.\n * @returns {Array<number>} An array of numbers representing the selectable page size options.\n */\n get pageSizeOptions() {\n let options = this.getAttribute('page-size-options');\n if (!options) return [6, 10, 50, 100, 500];\n return options.split(',').map((o) => +o).filter((o) => !isNaN(o));\n }\n\n set hideEmpty(value) {\n if (!value) return;\n this.setAttribute('hide-empty', value);\n }\n\n get hideEmpty() {\n return this.hasAttribute('hide-empty');\n }\n\n /**\n * Dependencies of the Button element.\n * @type {object}\n */\n dependencies = {\n 'wje-icon': Icon,\n 'wje-button': Button,\n };\n\n className = 'Pagination';\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 * Getter for the observedAttributes attribute of the input element.\n * @returns {Array} The attributes to observe for changes.\n */\n static get observedAttributes() {\n return ['page', 'total-items', 'page-size'];\n }\n\n /**\n * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n async beforeDraw() {\n if (!this.totalItems || this.totalItems === 0) {\n this.classList.add('empty');\n if (this.hideEmpty)\n this.setAttribute(\"hidden\", \"\");\n\n return;\n }\n this.paginateObj = await paginate(this.totalItems, this.page, this.pageSize, this.maxPages);\n }\n\n /**\n * Creates a document fragment, appends a new slot element to it, and returns the fragment.\n * @returns {DocumentFragment} A document fragment containing a slot element.\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('div');\n native.setAttribute('part', 'native');\n native.classList.add('native-pagination');\n\n native.append(this.htmlPagination());\n\n fragment.append(native);\n\n return fragment;\n }\n\n /**\n * Creates a pagination control for navigating between pages of content.\n * This method generates and returns a document fragment containing pagination controls, including buttons for navigating to the first, previous, next, and last pages, as well as optional informational text about the current set of displayed items and total number of items.\n * @returns {DocumentFragment} A document fragment containing the pagination controls.\n */\n htmlPagination() {\n let fragment = document.createDocumentFragment();\n\n let select = document.createElement('wje-select');\n select.setAttribute('size', 'small');\n select.setAttribute('variant', 'standard');\n select.setAttribute('value', this.pageSize);\n select.addEventListener('wje-select:change', (e) => {\n this.pageSize = e.detail.context.value[0];\n event.dispatchCustomEvent(this, 'wje-pagination:page-change', { page: this.page, pageSize: this.pageSize });\n });\n\n let options = this.pageSizeOptions.map((o) => {\n let option = document.createElement('wje-option');\n option.value = o;\n option.textContent = o;\n return option;\n });\n\n let info = document.createElement('div');\n info.classList.add('info');\n info.innerHTML = `${this.paginateObj.startIndex + 1} - ${this.paginateObj.endIndex + 1} ${this.localizer.translate('wj.pagination.of')} ${this.totalItems}`;\n\n let pagination = document.createElement('div');\n pagination.classList.add('pages');\n\n const button = document.createElement('wje-button');\n button.setAttribute('fill', 'link');\n if (this.round) button.setAttribute('round', '');\n\n // First button\n let firstButton = button.cloneNode(true);\n firstButton.title = this.localizer.translate('wj.pagination.first');\n firstButton.innerHTML = `<wje-icon name=\"chevron-left-pipe\" slot=\"icon-only\"></wje-icon>`;\n firstButton.addEventListener('wje-button:click', (e) => this.pageClickAction(e, 0));\n\n // Previous button\n const prevButton = button.cloneNode(true);\n prevButton.title = this.localizer.translate('wj.pagination.prev');\n prevButton.innerHTML = `<wje-icon name=\"chevron-left\" slot=\"icon-only\"></wje-icon>`;\n if (this.page === 0) prevButton.disabled = true;\n prevButton.addEventListener('wje-button:click', (e) => this.pageClickAction(e, this.page - 1));\n\n // Next button\n const nextButton = button.cloneNode(true);\n nextButton.title = this.localizer.translate('wj.pagination.next');\n nextButton.innerHTML = `<wje-icon name=\"chevron-right\" slot=\"icon-only\"></wje-icon>`;\n if (this.page + 1 >= this.paginateObj.totalPages) nextButton.disabled = true;\n nextButton.addEventListener('wje-button:click', (e) => this.pageClickAction(e, this.page + 1));\n\n // Last button\n let lastButton = button.cloneNode(true);\n lastButton.title = this.localizer.translate('wj.pagination.last');\n lastButton.innerHTML = `<wje-icon name=\"chevron-right-pipe\" slot=\"icon-only\"></wje-icon>`;\n lastButton.disabled = this.paginateObj.endIndex + 1 >= this.totalItems;\n lastButton.addEventListener('wje-button:click', (e) =>\n this.pageClickAction(e, this.paginateObj.totalPages - 1)\n );\n\n select.append(...options);\n\n if (this.showFirstButton) pagination.appendChild(firstButton);\n pagination.appendChild(prevButton);\n pagination.appendChild(this.htmlStackButtons(this.paginateObj));\n pagination.appendChild(nextButton);\n if (this.showLastButton) pagination.appendChild(lastButton);\n\n if (this.showPageSizeOptions) fragment.append(select);\n if (this.showInfo) fragment.appendChild(info);\n fragment.appendChild(pagination);\n\n return fragment;\n }\n\n /**\n * Creates and returns a DocumentFragment containing a series of buttons for pagination purposes,\n * based on the provided pagination object.\n * @param {object} paginateObj An object containing pagination details.\n * @param {number} paginateObj.currentPage The current active page index (1-based).\n * @param {Array<number>} paginateObj.pages An array of page numbers to display in the pagination.\n * @param {number} paginateObj.totalPages Total number of pages available for pagination.\n * @returns {DocumentFragment} A DocumentFragment containing the buttons and additional pagination elements.\n */\n htmlStackButtons(paginateObj) {\n let fragment = document.createDocumentFragment();\n\n const button = document.createElement('wje-button');\n button.setAttribute('fill', 'link');\n if (this.round) button.setAttribute('round', '');\n\n let dots = document.createElement('span');\n dots.classList.add('dots');\n\n const first = button.cloneNode(true);\n first.textContent = '1';\n first.addEventListener('wje-button:click', (e) => this.pageClickAction(e, 0));\n\n const last = button.cloneNode(true);\n last.textContent = paginateObj.totalPages;\n last.addEventListener('wje-button:click', (e) => this.pageClickAction(e, paginateObj.totalPages - 1));\n\n if (paginateObj.currentPage >= this.maxPages + 1 && paginateObj.boundary < paginateObj.totalPages) {\n fragment.appendChild(first);\n fragment.appendChild(dots);\n }\n\n paginateObj.pages.forEach((page) => {\n let newButton = button.cloneNode(true);\n newButton.textContent = page;\n\n if (page - 1 === this.page) {\n newButton.removeAttribute('fill');\n } else {\n newButton.addEventListener('wje-button:click', (e) => this.pageClickAction(e, page - 1));\n }\n\n fragment.appendChild(newButton);\n });\n\n if (\n (paginateObj.pages.length === this.maxPages || paginateObj.currentPage < this.maxPages + 1) &&\n paginateObj.boundary < paginateObj.totalPages\n ) {\n fragment.appendChild(dots.cloneNode(true));\n fragment.appendChild(last);\n }\n\n return fragment;\n }\n\n /**\n * Handles the click action for pagination and updates the current page.\n * If the clicked page number is the same as the current page, no action is performed.\n * Otherwise, the current page is updated to the new page number, and a custom event\n * 'wje-pagination:page-change' is dispatched with the pagination object.\n * @param {Event} e The event triggered by the page click.\n * @param {number} page The page number that was clicked.\n */\n pageClickAction = (e, page) => {\n if (+page === this.page || this.page > this.paginateObj.totalPages) return;\n this.page = page;\n event.dispatchCustomEvent(this, 'wje-pagination:page-change', { page: this.page, pageSize: this.pageSize });\n };\n}\n\nPagination.define('wje-pagination', Pagination);\n","import Pagination from './pagination.element.js';\n\nexport default Pagination;\n\nPagination.define('wje-pagination', Pagination);\n"],"names":[],"mappings":";;;;;;;;AAQO,SAAS,SAAS,YAAY,cAAc,GAAG,WAAW,IAAI,WAAW,GAAG;AAE/E,QAAM,aAAa,KAAK,KAAK,aAAa,QAAQ;AAGlD,MAAI,cAAc,GAAG;AACjB,kBAAc;AAAA,EACtB,WAAe,cAAc,YAAY;AACjC,kBAAc;AAAA,EACtB;AAEI,MAAI;AACJ,MAAI;AAEJ,QAAM,eAAe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,oBAAoB,CAAC,MAAM,KAAK,gBAAgB,GAAG,CAAC,CAAC;AAE5E,UAAM,OAAO,OAAO,UAAU,IAAI;AAClC,SAAK,cAAc,YAAY;AAC/B,SAAK,iBAAiB,oBAAoB,CAAC,MAAM,KAAK,gBAAgB,GAAG,YAAY,aAAa,CAAC,CAAC;AAEpG,QAAI,YAAY,eAAe,KAAK,WAAW,KAAK,YAAY,WAAW,YAAY,YAAY;AAC/F,eAAS,YAAY,KAAK;AAC1B,eAAS,YAAY,IAAI;AAAA,IACrC;AAEQ,gBAAY,MAAM,QAAQ,CAAC,SAAS;AAChC,UAAI,YAAY,OAAO,UAAU,IAAI;AACrC,gBAAU,cAAc;AAExB,UAAI,OAAO,MAAM,KAAK,MAAM;AACxB,kBAAU,gBAAgB,MAAM;AAAA,MAChD,OAAmB;AACH,kBAAU,iBAAiB,oBAAoB,CAAC,MAAM,KAAK,gBAAgB,GAAG,OAAO,CAAC,CAAC;AAAA,MACvG;AAEY,eAAS,YAAY,SAAS;AAAA,IAC1C,CAAS;AAED,SACK,YAAY,MAAM,WAAW,KAAK,YAAY,YAAY,cAAc,KAAK,WAAW,MACzF,YAAY,WAAW,YAAY,YACrC;AACE,eAAS,YAAY,KAAK,UAAU,IAAI,CAAC;AACzC,eAAS,YAAY,IAAI;AAAA,IACrC;AAEQ,WAAO;AAAA,EACf;AAeA;AAEA,WAAW,OAAO,kBAAkB,UAAU;AC1b9C,WAAW,OAAO,kBAAkB,UAAU;"}
|
|
1
|
+
{"version":3,"file":"wje-pagination.js","sources":["../packages/wje-pagination/service/service.js","../packages/wje-pagination/pagination.element.js","../packages/wje-pagination/pagination.js"],"sourcesContent":["/**\n * Paginates items based on the total number of items, current page, page size, and maximum number of pages to display.\n * @param {number} totalItems The total number of items to paginate.\n * @param {number} [currentPage] The current page number (default is 1).\n * @param {number} [pageSize] The number of items per page (default is 10).\n * @param {number} [maxPages] The maximum number of pages to display in the pagination control (default is 5).\n * @returns {object} An object containing pagination details including total items, current page, page size, total pages, start/end page, start/end index, and the pages array.\n */\nexport function paginate(totalItems, currentPage = 1, pageSize = 10, maxPages = 5) {\n // Calculate total pages\n const totalPages = Math.ceil(totalItems / pageSize);\n\n // Ensure current page is within valid range\n if (currentPage < 1) {\n currentPage = 1;\n } else if (currentPage > totalPages) {\n currentPage = totalPages;\n }\n\n let startPage;\n let endPage;\n\n const pagesNearEnd = maxPages + 1; // Define how close to the end we switch back to 5 pages 4\n\n const boundary = pagesNearEnd + 3;\n\n if (totalPages > boundary) {\n if (currentPage < pagesNearEnd) {\n // If in the first 4 pages, show up to 5 pages\n startPage = 1;\n endPage = Math.min(pagesNearEnd + 1, totalPages); //5\n } else if (currentPage >= totalPages - pagesNearEnd) {\n // If within 4 pages from the end, show last 5 pages\n startPage = Math.max(totalPages - pagesNearEnd, 1); //4\n endPage = totalPages;\n } else {\n const halfPages = Math.floor(maxPages / 2);\n // Otherwise, only show 3 pages (current, previous, next)\n startPage = currentPage - halfPages + 1;\n endPage = maxPages % 2 === 1 ? currentPage + halfPages + 1 : currentPage + halfPages - 1;\n }\n } else {\n startPage = 1;\n endPage = totalPages;\n }\n\n // Calculate start and end item indexes\n const startIndex = (currentPage - 1) * pageSize;\n const endIndex = Math.min(startIndex + pageSize - 1, totalItems - 1);\n\n // Create an array of pages to display\n const pages = Array.from({ length: endPage - startPage + 1 }, (_, i) => startPage + i);\n\n // Return object with all pager properties (preserving original format)\n return {\n boundary: boundary,\n currentPage: currentPage,\n endIndex: endIndex,\n endPage: endPage,\n totalPages: totalPages,\n pages: pages,\n pageSize: pageSize,\n startIndex: startIndex,\n startPage: startPage,\n totalItems: totalItems,\n };\n}\n","import { Localizer } from '../utils/localize.js';\nimport { default as WJElement, event } from '../wje-element/element.js';\nimport { paginate } from './service/service.js';\nimport Icon from '../wje-icon/icon.js';\nimport Button from '../wje-button/button.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary This class represents the Pagination component for navigating through paginated content and dynamically updating navigation elements based on attributes like the number of items, page size, etc. Extends the WJElement class.\n * @documentation https://elements.webjet.sk/components/pagination\n * @status stable\n * @augments WJElement\n * @dependency wje-icon, wje-button\n * @csspart native - The wrapper element for the pagination component.\n */\nexport default class Pagination extends WJElement {\n /**\n * Creates an instance of Pagination.\n */\n constructor() {\n super();\n this.localizer = new Localizer(this);\n\n this._paginateObj = null;\n }\n\n /**\n * Sets the value of the 'page' attribute for the object.\n * @param {string} value The value to set for the 'page' attribute.\n */\n set page(value) {\n this.setAttribute('page', value);\n }\n\n /**\n * Retrieves the current page number as a numeric value.\n * @returns {number} The current page number. Returns 0 if the attribute 'page' is not set or is not a numeric value.\n */\n get page() {\n return +this.getAttribute('page') || 0;\n }\n\n /**\n * Sets the maximum number of pages.\n * Updates the 'max-pages' attribute with the provided value.\n * @param {number|string} value The maximum number of pages to set. Can be a number or a parsable string representing a number.\n */\n set maxPages(value) {\n this.setAttribute('max-pages', value);\n }\n\n /**\n * Gets the maximum number of pages.\n * This getter retrieves the value of the \"max-pages\" attribute from the element.\n * If the attribute is not set or is invalid, it defaults to 3.\n * @returns {number} The maximum number of pages as a numeric value.\n */\n get maxPages() {\n return +this.getAttribute('max-pages') || 10;\n }\n\n /**\n * Sets the `pageSize` attribute to the specified value.\n * @param {number|string} value The desired page size value. This can be a number or a string representation of the size.\n */\n set pageSize(value) {\n this.setAttribute('page-size', value);\n }\n\n /**\n * Retrieves the value of the 'page-size' attribute and converts it to a number.\n * If the attribute is not set or is invalid, returns the default value of 3.\n * @returns {number} The numeric value of the 'page-size' attribute or the default value of 3.\n */\n get pageSize() {\n return +this.getAttribute('page-size') || 3;\n }\n\n /**\n * Sets the total number of items.\n * @param {number} value The new total number of items to set.\n */\n set totalItems(value) {\n this.setAttribute('total-items', value);\n }\n\n /**\n * Retrieves the total number of items represented by the 'total-items' attribute.\n * @returns {number} The total number of items. Defaults to 0 if the attribute is not set or is invalid.\n */\n get totalItems() {\n return +this.getAttribute('total-items') || 0;\n }\n\n /**\n * Sets the visibility of the first button based on the provided value.\n * Adds the 'show-first-button' attribute when the value is truthy, and removes it otherwise.\n * @param {boolean} value Determines whether to show the first button. If true, the 'show-first-button' attribute is added; if false, it is removed.\n */\n set showFirstButton(value) {\n this.removeAttribute('show-first-button');\n\n if (value) {\n this.setAttribute('show-first-button', '');\n }\n }\n\n /**\n * Determines whether the 'show-first-button' attribute is present on the element.\n * @returns {boolean} True if the 'show-first-button' attribute is set; otherwise, false.\n */\n get showFirstButton() {\n return this.hasAttribute('show-first-button');\n }\n\n /**\n * Sets the visibility of the \"last\" button. This method controls the presence\n * or absence of the \"show-last-button\" attribute based on the provided value.\n * @param {boolean} value A boolean value indicating whether to show the \"last\" button.\n * If true, the \"show-last-button\" attribute is added;\n * if false, the attribute is removed.\n */\n set showLastButton(value) {\n this.removeAttribute('show-last-button');\n\n if (value) {\n this.setAttribute('show-last-button', '');\n }\n }\n\n /**\n * Determines if the 'show-last-button' attribute is present on the element.\n * @returns {boolean} True if the 'show-last-button' attribute is present, otherwise false.\n */\n get showLastButton() {\n return this.hasAttribute('show-last-button');\n }\n\n /**\n * Sets the pagination object by calculating the pagination details\n * based on the total items, current page, page size, and maximum pages.\n * @param {object} value The value to set the pagination object. The pagination details are computed internally.\n */\n set paginateObj(value) {\n this._paginateObj = value;\n }\n\n /**\n * Retrieves the pagination object used for managing paginated data.\n * @returns {object} The pagination object containing details and functionality for paginating data.\n */\n get paginateObj() {\n return this._paginateObj;\n }\n\n /**\n * Sets the 'round' attribute on the element. If the provided value is truthy,\n * the 'round' attribute is added. If the value is falsy, the attribute is removed.\n * @param {boolean} value A boolean value determining whether to add or remove the 'round' attribute.\n */\n set round(value) {\n this.removeAttribute('round');\n\n if (value) {\n this.setAttribute('round', '');\n }\n }\n\n /**\n * Retrieves the value of the 'round' attribute for the current element.\n * @returns {boolean} A boolean indicating whether the 'round' attribute is present on the element.\n */\n get round() {\n return this.hasAttribute('round');\n }\n\n /**\n * Sets the `show-info` attribute on the element based on the provided value.\n * @param {boolean} value A boolean indicating whether to add or remove the `show-info` attribute.\n */\n set showInfo(value) {\n this.removeAttribute('show-info');\n\n if (value) {\n this.setAttribute('show-info', '');\n }\n }\n\n /**\n * Retrieves the value of the 'show-info' attribute.\n * Checks if the 'show-info' attribute is present on the element.\n * @returns {boolean} True if the 'show-info' attribute is present, otherwise false.\n */\n get showInfo() {\n return this.hasAttribute('show-info');\n }\n\n set showPageSizeOptions(value) {\n if (!value) return;\n this.setAttribute('show-page-size-options', value);\n }\n\n get showPageSizeOptions() {\n return this.hasAttribute('show-page-size-options');\n }\n\n set pageSizeOptions(value) {\n if (!value) return;\n this.setAttribute('page-size-options', value);\n }\n\n /**\n * Retrieves the list of available page size options.\n * This method is used to fetch the values representing the different page size options\n * that can be provided or configured in a paginated component or system.\n * @returns {Array<number>} An array of numbers representing the selectable page size options.\n */\n get pageSizeOptions() {\n let options = this.getAttribute('page-size-options');\n if (!options) return [6, 10, 50, 100, 500];\n return options.split(',').map((o) => +o).filter((o) => !isNaN(o));\n }\n\n set hideEmpty(value) {\n if (!value) return;\n this.setAttribute('hide-empty', value);\n }\n\n get hideEmpty() {\n return this.hasAttribute('hide-empty');\n }\n\n /**\n * Dependencies of the Button element.\n * @type {object}\n */\n dependencies = {\n 'wje-icon': Icon,\n 'wje-button': Button,\n };\n\n className = 'Pagination';\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 * Getter for the observedAttributes attribute of the input element.\n * @returns {Array} The attributes to observe for changes.\n */\n static get observedAttributes() {\n return ['page', 'total-items', 'page-size'];\n }\n\n /**\n * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n async beforeDraw() {\n this.classList.remove('empty');\n this.removeAttribute(\"hidden\");\n\n if (!this.totalItems || this.totalItems === 0) {\n this.classList.add('empty');\n if (this.hideEmpty)\n this.setAttribute(\"hidden\", \"\");\n\n return;\n }\n\n this.paginateObj = await paginate(this.totalItems, this.page, this.pageSize, this.maxPages);\n }\n\n /**\n * Creates a document fragment, appends a new slot element to it, and returns the fragment.\n * @returns {DocumentFragment} A document fragment containing a slot element.\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('div');\n native.setAttribute('part', 'native');\n native.classList.add('native-pagination');\n\n native.append(this.htmlPagination());\n\n fragment.append(native);\n\n return fragment;\n }\n\n /**\n * Creates a pagination control for navigating between pages of content.\n * This method generates and returns a document fragment containing pagination controls, including buttons for navigating to the first, previous, next, and last pages, as well as optional informational text about the current set of displayed items and total number of items.\n * @returns {DocumentFragment} A document fragment containing the pagination controls.\n */\n htmlPagination() {\n let fragment = document.createDocumentFragment();\n\n let select = document.createElement('wje-select');\n select.setAttribute('size', 'small');\n select.setAttribute('variant', 'standard');\n select.setAttribute('value', this.pageSize);\n select.addEventListener('wje-select:change', (e) => {\n\n if(+e.detail.context.value[0] !== this.pageSize) {\n this.pageSize = +e.detail.context.value[0];\n this.page = 0; // Reset to first page when page size changes\n event.dispatchCustomEvent(this, 'wje-pagination:page-change', { page: this.page, pageSize: this.pageSize });\n }\n });\n\n let options = this.pageSizeOptions.map((o) => {\n let option = document.createElement('wje-option');\n option.value = o;\n option.textContent = o;\n return option;\n });\n\n let info = document.createElement('div');\n info.classList.add('info');\n info.innerHTML = `${this.paginateObj.startIndex + 1} - ${this.paginateObj.endIndex + 1} ${this.localizer.translate('wj.pagination.of')} ${this.totalItems}`;\n\n let pagination = document.createElement('div');\n pagination.classList.add('pages');\n\n const button = document.createElement('wje-button');\n button.setAttribute('fill', 'link');\n if (this.round) button.setAttribute('round', '');\n\n // First button\n let firstButton = button.cloneNode(true);\n firstButton.title = this.localizer.translate('wj.pagination.first');\n firstButton.innerHTML = `<wje-icon name=\"chevron-left-pipe\" slot=\"icon-only\"></wje-icon>`;\n firstButton.addEventListener('wje-button:click', (e) => this.pageClickAction(e, 0));\n\n // Previous button\n const prevButton = button.cloneNode(true);\n prevButton.title = this.localizer.translate('wj.pagination.prev');\n prevButton.innerHTML = `<wje-icon name=\"chevron-left\" slot=\"icon-only\"></wje-icon>`;\n if (this.page === 0) prevButton.disabled = true;\n prevButton.addEventListener('wje-button:click', (e) => this.pageClickAction(e, this.page - 1));\n\n // Next button\n const nextButton = button.cloneNode(true);\n nextButton.title = this.localizer.translate('wj.pagination.next');\n nextButton.innerHTML = `<wje-icon name=\"chevron-right\" slot=\"icon-only\"></wje-icon>`;\n if (this.page + 1 >= this.paginateObj.totalPages) nextButton.disabled = true;\n nextButton.addEventListener('wje-button:click', (e) => this.pageClickAction(e, this.page + 1));\n\n // Last button\n let lastButton = button.cloneNode(true);\n lastButton.title = this.localizer.translate('wj.pagination.last');\n lastButton.innerHTML = `<wje-icon name=\"chevron-right-pipe\" slot=\"icon-only\"></wje-icon>`;\n lastButton.disabled = this.paginateObj.endIndex + 1 >= this.totalItems;\n lastButton.addEventListener('wje-button:click', (e) =>\n this.pageClickAction(e, this.paginateObj.totalPages - 1)\n );\n\n select.append(...options);\n\n if (this.showFirstButton) pagination.appendChild(firstButton);\n pagination.appendChild(prevButton);\n pagination.appendChild(this.htmlStackButtons(this.paginateObj));\n pagination.appendChild(nextButton);\n if (this.showLastButton) pagination.appendChild(lastButton);\n\n if (this.showPageSizeOptions) fragment.append(select);\n if (this.showInfo) fragment.appendChild(info);\n fragment.appendChild(pagination);\n\n return fragment;\n }\n\n /**\n * Creates and returns a DocumentFragment containing a series of buttons for pagination purposes,\n * based on the provided pagination object.\n * @param {object} paginateObj An object containing pagination details.\n * @param {number} paginateObj.currentPage The current active page index (1-based).\n * @param {Array<number>} paginateObj.pages An array of page numbers to display in the pagination.\n * @param {number} paginateObj.totalPages Total number of pages available for pagination.\n * @returns {DocumentFragment} A DocumentFragment containing the buttons and additional pagination elements.\n */\n htmlStackButtons(paginateObj) {\n let fragment = document.createDocumentFragment();\n\n const button = document.createElement('wje-button');\n button.setAttribute('fill', 'link');\n if (this.round) button.setAttribute('round', '');\n\n let dots = document.createElement('span');\n dots.classList.add('dots');\n\n const first = button.cloneNode(true);\n first.textContent = '1';\n first.addEventListener('wje-button:click', (e) => this.pageClickAction(e, 0));\n\n const last = button.cloneNode(true);\n last.textContent = paginateObj.totalPages;\n last.addEventListener('wje-button:click', (e) => this.pageClickAction(e, paginateObj.totalPages - 1));\n\n if (paginateObj.currentPage >= this.maxPages + 1 && paginateObj.boundary < paginateObj.totalPages) {\n fragment.appendChild(first);\n fragment.appendChild(dots);\n }\n\n paginateObj.pages.forEach((page) => {\n let newButton = button.cloneNode(true);\n newButton.textContent = page;\n\n if (page - 1 === this.page) {\n newButton.removeAttribute('fill');\n } else {\n newButton.addEventListener('wje-button:click', (e) => this.pageClickAction(e, page - 1));\n }\n\n fragment.appendChild(newButton);\n });\n\n if (\n (paginateObj.pages.length === this.maxPages || paginateObj.currentPage < this.maxPages + 1) &&\n paginateObj.boundary < paginateObj.totalPages\n ) {\n fragment.appendChild(dots.cloneNode(true));\n fragment.appendChild(last);\n }\n\n return fragment;\n }\n\n /**\n * Handles the click action for pagination and updates the current page.\n * If the clicked page number is the same as the current page, no action is performed.\n * Otherwise, the current page is updated to the new page number, and a custom event\n * 'wje-pagination:page-change' is dispatched with the pagination object.\n * @param {Event} e The event triggered by the page click.\n * @param {number} page The page number that was clicked.\n */\n pageClickAction = (e, page) => {\n if (+page === this.page || this.page > this.paginateObj.totalPages) return;\n this.page = page;\n event.dispatchCustomEvent(this, 'wje-pagination:page-change', { page: this.page, pageSize: this.pageSize });\n };\n}\n\nPagination.define('wje-pagination', Pagination);\n","import Pagination from './pagination.element.js';\n\nexport default Pagination;\n\nPagination.define('wje-pagination', Pagination);\n"],"names":[],"mappings":";;;;;;;;AAQO,SAAS,SAAS,YAAY,cAAc,GAAG,WAAW,IAAI,WAAW,GAAG;AAE/E,QAAM,aAAa,KAAK,KAAK,aAAa,QAAQ;AAGlD,MAAI,cAAc,GAAG;AACjB,kBAAc;AAAA,EACtB,WAAe,cAAc,YAAY;AACjC,kBA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p = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
4
|
import WJElement from "./wje-element.js";
|
|
5
|
-
const styles = "/*\n[ WJ Tree Item ]\n*/\n\n:host {\n .native-tree-item {\n position: relative;\n display: flex;\n align-items: stretch;\n flex-direction: column;\n &.multiple {\n .item {\n border-radius: 0 !important;\n }\n }\n .item {\n display: flex;\n align-items: center;\n padding-inline: var(--wje-tree-item-padding-inline);\n padding-block: var(--wje-tree-item-padding-block);\n border-radius: var(--wje-tree-item-border-radius);\n background-color: var(--wje-tree-item-background);\n color: var(--wje-tree-item-color);\n &:hover {\n background-color: var(--wje-tree-item-background-hover);\n color: var(--wje-tree-item-color-hover);\n }\n .indent {\n display: block;\n width: 1em;\n }\n .toggle {\n font-size: var(--wje-font-size
|
|
5
|
+
const styles = "/*\n[ WJ Tree Item ]\n*/\n\n:host {\n .native-tree-item {\n position: relative;\n display: flex;\n align-items: stretch;\n flex-direction: column;\n &.multiple {\n .item {\n border-radius: 0 !important;\n }\n }\n .item {\n display: flex;\n align-items: center;\n padding-inline: var(--wje-tree-item-padding-inline);\n padding-block: var(--wje-tree-item-padding-block);\n border-radius: var(--wje-tree-item-border-radius);\n background-color: var(--wje-tree-item-background);\n color: var(--wje-tree-item-color);\n &:hover {\n background-color: var(--wje-tree-item-background-hover);\n color: var(--wje-tree-item-color-hover);\n }\n .indent {\n display: block;\n width: 1em;\n }\n .toggle {\n font-size: var(--wje-tree-item-font-size);\n display: flex;\n align-items: center;\n justify-content: center;\n box-sizing: content-box;\n width: var(--wje-tree-item-indent);\n height: var(--wje-tree-item-indent);\n flex-shrink: 0;\n }\n wje-checkbox {\n font-size: var(--wje-tree-item-font-size);\n margin: 0;\n }\n .content {\n font-size: var(--wje-tree-item-font-size);\n }\n slot {\n display: flex;\n align-items: center;\n }\n slot:not([name])::slotted(wje-icon) {\n margin-right: var(--wje-spacing-2x-small);\n }\n slot[name='end'] {\n margin-inline-start: auto;\n }\n }\n .children {\n font-size: calc(1rem + var(--wje-tree-item-indent, var(--wje-spacing-medium)));\n display: none;\n &.open {\n font-size: var(--wje-tree-item-font-size);\n display: block;\n\n ::before {\n content: '';\n position: absolute;\n top: var(--wje-tree-item-indent);\n bottom: 5px;\n left: calc(1em - (var(--wje-spacing-3x-small) * 2) - (var(--wje-tree-item-indent-guid-width) / 2));\n border-inline-end: var(--wje-tree-item-indent-guid-width) solid var(--wje-border-color);\n z-index: 1;\n }\n }\n }\n }\n\n .native-tree-item.expanded .item slot[name='expand'],\n .native-tree-item:not(.expanded) slot[name='collapse'] {\n display: none;\n }\n}\n\n:host([selected]) {\n .item {\n background-color: var(--wje-tree-item-background-selected);\n color: var(--wje-tree-item-color-selected);\n }\n}\n:host([slot-hover-visible]) {\n .item {\n &:hover {\n slot[name='start'], slot[name='end'] {\n visibility: visible;\n }\n }\n slot[name='start'], slot[name='end'] {\n visibility: hidden;\n }\n }\n}\n";
|
|
6
6
|
class TreeItem extends WJElement {
|
|
7
7
|
/**
|
|
8
8
|
* Creates an instance of Toast.
|
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.208",
|
|
5
5
|
"homepage": "https://github.com/lencys/wj-elements",
|
|
6
6
|
"author": "Lukáš Ondrejček <lukas.ondrejcek@gmail.com>",
|
|
7
7
|
"license": "MIT",
|