wj-elements 0.1.161 → 0.1.163

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.
Files changed (32) hide show
  1. package/dist/{infinite-scroll.element-Cj53cbpC.js → infinite-scroll.element-DXzh2umi.js} +4 -2
  2. package/dist/{infinite-scroll.element-Cj53cbpC.js.map → infinite-scroll.element-DXzh2umi.js.map} +1 -1
  3. package/dist/light.css +14 -1
  4. package/dist/packages/wje-dialog/dialog.element.d.ts +11 -0
  5. package/dist/packages/wje-element/element.d.ts +1 -1
  6. package/dist/packages/wje-element/service/universal-service.d.ts +6 -6
  7. package/dist/packages/wje-options/options.element.d.ts +13 -4
  8. package/dist/packages/wje-select/select.element.d.ts +81 -12
  9. package/dist/wje-breadcrumb.js +0 -2
  10. package/dist/wje-breadcrumb.js.map +1 -1
  11. package/dist/wje-copy-button.js +0 -1
  12. package/dist/wje-copy-button.js.map +1 -1
  13. package/dist/wje-dialog.js +16 -2
  14. package/dist/wje-dialog.js.map +1 -1
  15. package/dist/wje-element.js +19 -29
  16. package/dist/wje-element.js.map +1 -1
  17. package/dist/wje-icon-picker.js +1 -1
  18. package/dist/wje-img.js +1 -1
  19. package/dist/wje-img.js.map +1 -1
  20. package/dist/wje-infinite-scroll.js +1 -1
  21. package/dist/wje-master.js +1 -1
  22. package/dist/wje-options.js +19 -15
  23. package/dist/wje-options.js.map +1 -1
  24. package/dist/wje-select.js +32 -3
  25. package/dist/wje-select.js.map +1 -1
  26. package/dist/wje-split-view.js +0 -10
  27. package/dist/wje-split-view.js.map +1 -1
  28. package/dist/wje-tab-group.js +0 -1
  29. package/dist/wje-tab-group.js.map +1 -1
  30. package/package.json +1 -1
  31. package/dist/packages/wje-accordion/accordion.test.d.ts +0 -0
  32. package/dist/packages/wje-color-picker/color-picker.test.d.ts +0 -1
@@ -308,7 +308,9 @@ class InfiniteScroll extends WJElement {
308
308
  event.dispatchCustomEvent(this, "wje-infinite-scroll:load", response);
309
309
  this.response = response;
310
310
  this._loadedItems = this.objectName ? response[this.objectName] : response;
311
- const notDrawnItems = this._loadedItems.filter((item) => !this._drawnItems.some(this.compareFunction.bind(this, item)));
311
+ const notDrawnItems = this._loadedItems.filter(
312
+ (item) => !this._drawnItems.some(this.compareFunction.bind(this, item))
313
+ );
312
314
  this.customForeach(notDrawnItems);
313
315
  this._drawnItems.push(...notDrawnItems);
314
316
  this.isLoading.push(page);
@@ -344,4 +346,4 @@ class InfiniteScroll extends WJElement {
344
346
  export {
345
347
  InfiniteScroll as I
346
348
  };
347
- //# sourceMappingURL=infinite-scroll.element-Cj53cbpC.js.map
349
+ //# sourceMappingURL=infinite-scroll.element-DXzh2umi.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"infinite-scroll.element-Cj53cbpC.js","sources":["../packages/wje-infinite-scroll/infinite-scroll.element.js"],"sourcesContent":["import { default as WJElement, event, WjElementUtils } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * `InfiniteScroll` is a custom web component that represents an infinite scroll.\n * It extends from `WJElement`.\n * @summary This element allows users to scroll through a potentially infinite amount of content.\n * @documentation https://elements.webjet.sk/components/infinite-scroll\n * @status stable\n * @augments {WJElement}\n * @csspart loader - The loader part of the infinite scroll.\n * @slot - The default slot for the infinite scroll.\n * @cssproperty [--wje-infinite-scroll-width=100%] - Sets the width of the infinite scroll container. his property determines how wide the infinite scroll area will be relative to its parent element. Accepts any valid CSS width value, such as percentages (`%`), pixels (`px`), or viewport units (`vw`). The default value is `100%`, which makes it span the full width of its container.\n * @cssproperty [--wje-infinite-scroll-height=300px] - Defines the height of the infinite scroll container. This property specifies how tall the infinite scroll area should be. Accepts any valid CSS height value, such as pixels (`px`), percentages (`%`), or viewport units (`vh`). The default value is `300px`, providing a fixed height suitable for most use cases.\n * //@fires wje-infinite-scroll:click-item - Event fired when an item is clicked.\n * @tag wje-infinite-scroll\n */\n\nexport default class InfiniteScroll extends WJElement {\n /**\n * Creates an instance of InfiniteScroll.\n */\n constructor() {\n super();\n\n this.totalPages = 0;\n this.isLoading = [];\n this._response = {};\n this.iterate = null;\n this._infiniteScrollTemplate = null;\n this._abortController = new AbortController();\n this._signal = this._abortController.signal;\n this._dataToElementWeakMap = new WeakMap();\n this._drawnItems = [];\n this._loadedItems = [];\n this._actualDrawnIndex = 0;\n }\n\n /**\n * Dependencies of the InfiniteScroll component.\n * @param value\n */\n set infiniteScrollTemplate(value) {\n this._infiniteScrollTemplate = value;\n }\n\n /**\n * Getter for the infiniteScrollTemplate property.\n * @returns {null}\n */\n get infiniteScrollTemplate() {\n return this._infiniteScrollTemplate;\n }\n\n /**\n * Dependencies of the InfiniteScroll component.\n * @param value\n */\n set response(value) {\n this._response = value;\n }\n\n /**\n * Getter for the response property.\n * @returns {*|{}}\n */\n get response() {\n return this._response;\n }\n\n /**\n * Dependencies of the InfiniteScroll component.\n * @param value\n */\n set objectName(value) {\n this.setAttribute('object-name', value);\n }\n\n get objectName() {\n return this.getAttribute('object-name') ?? 'data';\n }\n\n className = 'InfiniteScroll';\n\n /**\n * Returns the CSS styles for the component.\n * @static\n * @returns {CSSStyleSheet}\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Returns the list of attributes to observe for changes.\n * @static\n * @returns {Array<string>}\n */\n static get observedAttributes() {\n return [];\n }\n\n /**\n * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Prepares the component for updates before it is drawn.\n * This method handles the removal of templates for iteration, adjusts the height styling of the component,\n * and manages abort signals for loading operations.\n * @returns {void} No return value.\n */\n beforeDraw() {\n this._loadedItems = [];\n this._drawnItems = [];\n this._dataToElementWeakMap = new WeakMap();\n\n this.iterate = this.querySelector('[iterate]');\n\n if (this.iterate) {\n if (this.iterate.nodeName !== 'TEMPLATE') {\n console.error('The iterate attribute must be a template element');\n this.infiniteScrollTemplate = this.iterate?.outerHTML;\n } else {\n this.infiniteScrollTemplate = this.iterate?.innerHTML;\n }\n\n this.iterate?.remove(); // remove template\n }\n\n this.setAttribute('style', 'height: ' + this.height);\n\n // if this._loading is not fulfilled then cancel the promise\n if (this._signal) {\n this._abortController.abort();\n this._abortController = new AbortController();\n this._signal = this._abortController.signal;\n }\n }\n\n /**\n * Creates and returns a document fragment containing the structure for an infinite scroll component.\n * The structure includes native elements, slots for customization, and optional loading content.\n * @returns {DocumentFragment} The document fragment containing the component's DOM structure.\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('div');\n native.classList.add('native');\n native.setAttribute('part', 'native-infinite-scroll');\n\n let slot = document.createElement('slot');\n\n let ending = document.createElement('slot');\n ending.setAttribute('name', 'ending');\n\n if (WjElementUtils.hasSlot(this, 'loader')) {\n let loading = document.createElement('div');\n loading.classList.add('loading');\n\n let loader = document.createElement('slot');\n loader.setAttribute('name', 'loader');\n\n loading.appendChild(loader);\n\n this.loadingEl = loading;\n\n fragment.appendChild(loading);\n }\n\n native.appendChild(slot);\n native.appendChild(ending);\n\n fragment.appendChild(native);\n\n this.endingEl = ending;\n\n return fragment;\n }\n\n /**\n * Called after the component has been drawn.\n */\n async afterDraw() {\n this.queryParams = this.queryParams || '';\n this.size = +this.size || 10;\n this.currentPage = 0;\n\n this.scrollEvent();\n this._loading = this.loadPages(this.currentPage);\n await this._loading;\n }\n\n /**\n * Attaches a scroll event listener to the current object.\n * The `scrollEvent` function binds the `onScroll` method to the 'scroll' event\n * of the current object. This enables handling of scroll events for\n * specific functionality such as updating UI elements, loading content dynamically,\n * or tracking user interaction with scrollable content.\n */\n scrollEvent = () => {\n this.addEventListener('scroll', this.onScroll);\n };\n\n /**\n * A function that removes the scroll event listener from the current context.\n * This function is used to unbind the `onScroll` event listener\n * from the `scroll` event of the current object. It ensures that\n * the scroll event no longer triggers the `onScroll` handler.\n * @function\n */\n unScrollEvent = () => {\n this.removeEventListener('scroll', this.onScroll);\n };\n\n /**\n * A scroll event handler function that checks the scroll position and triggers loading additional content\n * when the user scrolls near the bottom of the page.\n * Properties accessed:\n * - `scrollTop`: The number of pixels that the content of an element is scrolled vertically.\n * - `scrollHeight`: The total height of the element's content.\n * - `clientHeight`: The inner height of the element in pixels, including padding but excluding borders and scrollbars.\n * Conditions:\n * - Determines if the scroll position is within 300 pixels of the bottom of the element.\n * - Verifies that the current page number is less than or equal to the total number of pages.\n * - Checks if the current page is already in the loading state.\n * Actions:\n * - Increments the current page number when the conditions are met.\n * - Initiates loading for the next page by calling the `loadPages` function.\n * @param {Event} e The scroll event object.\n */\n onScroll = (e) => {\n const { scrollTop, scrollHeight, clientHeight } = e.target;\n\n if (\n scrollTop + clientHeight >= scrollHeight - 300 &&\n this.currentPage <= this.totalPages &&\n this.isLoading.includes(this.currentPage)\n ) {\n this.currentPage++;\n this._loading = this.loadPages(this.currentPage);\n }\n };\n\n /**\n * Fetches the pages from the server.\n * @param {number} page The page number.\n * @returns {Promise<object>} The response from the server.\n */\n async getPages(page) {\n let hasParams = this.url.includes('?');\n const response = await fetch(\n `${this.url}${hasParams ? '&' : '?'}page=${page}&size=${this.size}${this?.queryParams}`,\n {\n signal: this._signal,\n }\n );\n\n if (!response.ok) {\n throw new Error(`An error occurred: ${response.status}`);\n }\n return await response.json();\n }\n\n /**\n * Hides the loader.\n */\n hideLoader() {\n this?.loadingEl?.classList.remove('show');\n }\n\n /**\n * Displays the loader element by adding the 'show' class to its class list.\n * This method is useful for indicating a loading or processing state in the UI.\n * @returns {void} No return value.\n */\n showLoader() {\n this?.loadingEl?.classList.add('show');\n }\n\n /**\n * Checks if there are more pages to load.\n * @param {number} page The page number.\n * @returns {boolean} Whether there are more pages to load.\n */\n hasMorePages(page) {\n return this.totalPages === 0 || page < this.totalPages;\n }\n\n /**\n * Loads the pages.\n * @param {number} page The page number.\n */\n async loadPages(page) {\n this.showLoader();\n try {\n if (this.hasMorePages(page)) {\n let response;\n this.parser = new DOMParser();\n\n if (typeof this.setCustomData === 'function') {\n response = await this.setCustomData(page, this._signal);\n } else {\n response = await this.getPages(page);\n }\n\n this.totalPages = response?.totalPages;\n this.currentPage = page;\n\n this.placementObj = this;\n\n // if there is a \"container\" attribute, find the element\n if (this.hasAttribute('placement')) this.placementObj = this.querySelector(this.placement);\n\n event.dispatchCustomEvent(this, 'wje-infinite-scroll:load', response);\n\n this.response = response;\n this._loadedItems = this.objectName ? response[this.objectName] : response;\n const notDrawnItems = this._loadedItems.filter((item) => !this._drawnItems.some(this.compareFunction.bind(this, item)));\n this.customForeach(notDrawnItems);\n this._drawnItems.push(...notDrawnItems);\n\n this.isLoading.push(page);\n } else {\n event.dispatchCustomEvent(this, 'wje-infinite-scroll:complete');\n this.endingEl.classList.add('show');\n }\n } catch (error) {\n console.log(error);\n } finally {\n this.hideLoader();\n }\n }\n\n compareFunction = (i, item) => i.id === item.id\n\n /**\n * Converts a data item into an HTML element based on a template.\n * This function takes a data item, interpolates it into a predefined template,\n * parses the resulting HTML string, and returns the first child element of the parsed HTML content.\n * @param {object} item The data object to interpolate into the HTML template.\n * @returns {Element} The first child element generated from the interpolated HTML string.\n */\n dataToHtml = (item) => {\n let interpolateItem = this.interpolate(this.infiniteScrollTemplate, item);\n let doc = this.parser.parseFromString(interpolateItem, 'text/html');\n let element = doc.activeElement.firstElementChild;\n\n return element;\n };\n\n /**\n * A custom implementation of the forEach method designed to iterate over an array of data,\n * transform each item into an HTML element, and append the element to a specified placement object.\n * Additionally, it adds an event listener to each generated element for handling click events.\n * @param {Array} data An array of items to process. Each item is transformed into an HTML element\n * and appended to the placement object specified in the context of `this`.\n */\n customForeach = (data) => {\n data.forEach((item) => {\n let element = this.dataToHtml(item);\n this._dataToElementWeakMap.set(element, item);\n\n event.addListener(element, 'click', 'wje-infinite-scroll:click-item', null);\n\n this.placementObj.insertAdjacentElement('beforeend', element);\n });\n };\n\n /**\n * Interpolates a string template with values from the provided parameters object.\n * The template contains placeholders in the format `{{key}}` or `{{key.subkey}}`,\n * which are replaced with the corresponding values from the `params` object.\n * Placeholders support dot notation for accessing nested properties within the `params` object.\n * @param {string} template The string template containing placeholders to be replaced.\n * @param {object} params The object containing key-value pairs used for substitution in the template.\n * @returns {string} A string with all placeholders replaced by their respective values from the `params` object.\n */\n interpolate = (template, params) => {\n let keys = template.match(/\\{{.*?\\}}/g);\n\n if (keys) {\n for (let key of keys) {\n let cleanKey = key.replace('{{', '').replace('}}', '');\n let val = '';\n cleanKey.split('.').forEach((k) => {\n val = val === '' ? params[k] : val[k];\n });\n\n template = template.replace(key, val);\n }\n }\n return template;\n };\n\n addItem(item, place = 'beforeend') {\n let element = this.dataToHtml(item);\n this._dataToElementWeakMap.set(element, item);\n this.placementObj.insertAdjacentElement(place, element);\n\n this._drawnItems.push(item);\n\n // if drawnItems are more than page * size then add the page to isLoading\n if (this._drawnItems.length > this.size * this.currentPage) {\n this.totalPages += 1;\n }\n }\n\n removeItem(item) {\n let element = this._dataToElementWeakMap.get(item);\n element.remove();\n this._drawnItems = this._drawnItems.filter((i) => i !== item);\n // if drawnItems are less than page * size then remove the page from isLoading\n if (this._drawnItems.length < this.size * this.currentPage) {\n this.isLoading = this.isLoading.filter((i) => i !== this.currentPage);\n this.currentPage--;\n }\n }\n}\n"],"names":[],"mappings":";;;;;AAkBe,MAAM,uBAAuB,UAAU;AAAA;AAAA;AAAA;AAAA,EAIlD,cAAc;AACV,UAAO;AA2DX,qCAAY;AA0HZ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uCAAc,MAAM;AAChB,WAAK,iBAAiB,UAAU,KAAK,QAAQ;AAAA,IAChD;AASD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yCAAgB,MAAM;AAClB,WAAK,oBAAoB,UAAU,KAAK,QAAQ;AAAA,IACnD;AAkBD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oCAAW,CAAC,MAAM;AACd,YAAM,EAAE,WAAW,cAAc,aAAc,IAAG,EAAE;AAEpD,UACI,YAAY,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AQ;AAEpE,aAAK,WAAW;AAChB,aAAK,eAAe,KAAK,aAAa,SAAS,KAAK,UAAU,IAAI;AAClE,cAAM,gBAAgB,KAAK,aAAa,OAAO,CAAC,SAAS,CAAC,KAAK,YAAY,KAAK,KAAK,gBAAgB,KAAK,MAAM,IAAI,CAAC,CAAC;AACtH,aAAK,cAAc,aAAa;AAChC,aAAK,YAAY,KAAK,GAAG,aAAa;AAEtC,aAAK,UAAU,KAAK,IAAI;AAAA,MACxC,OAAmB;AACH,cAAM,oBAAoB,MAAM,8BAA8B;AAC9D,aAAK,SAAS,UAAU,IAAI,MAAM;AAAA,MAClD;AAAA,IACS,SAAQ,OAAO;AACZ,cAAQ,IAAI,KAAK;AAAA,IAC7B,UAAkB;AACN,WAAK,WAAY;AAAA,IAC7B;AAAA,EACA;AAAA,EA+DI,QAAQ,MAAM,QAAQ,aAAa;AAC/B,QAAI,UAAU,KAAK,WAAW,IAAI;AAClC,SAAK,sBAAsB,IAAI,SAAS,IAAI;AAC5C,SAAK,aAAa,sBAAsB,OAAO,OAAO;AAEtD,SAAK,YAAY,KAAK,IAAI;AAG1B,QAAI,KAAK,YAAY,SAAS,KAAK,OAAO,KAAK,aAAa;AACxD,WAAK,cAAc;AAAA,IAC/B;AAAA,EACA;AAAA,EAEI,WAAW,MAAM;AACb,QAAI,UAAU,KAAK,sBAAsB,IAAI,IAAI;AACjD,YAAQ,OAAQ;AAChB,SAAK,cAAc,KAAK,YAAY,OAAO,CAAC,MAAM,MAAM,IAAI;AAE5D,QAAI,KAAK,YAAY,SAAS,KAAK,OAAO,KAAK,aAAa;AACxD,WAAK,YAAY,KAAK,UAAU,OAAO,CAAC,MAAM,MAAM,KAAK,WAAW;AACpE,WAAK;AAAA,IACjB;AAAA,EACA;AACA;"}
1
+ {"version":3,"file":"infinite-scroll.element-DXzh2umi.js","sources":["../packages/wje-infinite-scroll/infinite-scroll.element.js"],"sourcesContent":["import { default as WJElement, event, WjElementUtils } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * `InfiniteScroll` is a custom web component that represents an infinite scroll.\n * It extends from `WJElement`.\n * @summary This element allows users to scroll through a potentially infinite amount of content.\n * @documentation https://elements.webjet.sk/components/infinite-scroll\n * @status stable\n * @augments {WJElement}\n * @csspart loader - The loader part of the infinite scroll.\n * @slot - The default slot for the infinite scroll.\n * @cssproperty [--wje-infinite-scroll-width=100%] - Sets the width of the infinite scroll container. his property determines how wide the infinite scroll area will be relative to its parent element. Accepts any valid CSS width value, such as percentages (`%`), pixels (`px`), or viewport units (`vw`). The default value is `100%`, which makes it span the full width of its container.\n * @cssproperty [--wje-infinite-scroll-height=300px] - Defines the height of the infinite scroll container. This property specifies how tall the infinite scroll area should be. Accepts any valid CSS height value, such as pixels (`px`), percentages (`%`), or viewport units (`vh`). The default value is `300px`, providing a fixed height suitable for most use cases.\n * //@fires wje-infinite-scroll:click-item - Event fired when an item is clicked.\n * @tag wje-infinite-scroll\n */\n\nexport default class InfiniteScroll extends WJElement {\n /**\n * Creates an instance of InfiniteScroll.\n */\n constructor() {\n super();\n\n this.totalPages = 0;\n this.isLoading = [];\n this._response = {};\n this.iterate = null;\n this._infiniteScrollTemplate = null;\n this._abortController = new AbortController();\n this._signal = this._abortController.signal;\n this._dataToElementWeakMap = new WeakMap();\n this._drawnItems = [];\n this._loadedItems = [];\n this._actualDrawnIndex = 0;\n }\n\n /**\n * Dependencies of the InfiniteScroll component.\n * @param value\n */\n set infiniteScrollTemplate(value) {\n this._infiniteScrollTemplate = value;\n }\n\n /**\n * Getter for the infiniteScrollTemplate property.\n * @returns {null}\n */\n get infiniteScrollTemplate() {\n return this._infiniteScrollTemplate;\n }\n\n /**\n * Dependencies of the InfiniteScroll component.\n * @param value\n */\n set response(value) {\n this._response = value;\n }\n\n /**\n * Getter for the response property.\n * @returns {*|{}}\n */\n get response() {\n return this._response;\n }\n\n /**\n * Dependencies of the InfiniteScroll component.\n * @param value\n */\n set objectName(value) {\n this.setAttribute('object-name', value);\n }\n\n get objectName() {\n return this.getAttribute('object-name') ?? 'data';\n }\n\n className = 'InfiniteScroll';\n\n /**\n * Returns the CSS styles for the component.\n * @static\n * @returns {CSSStyleSheet}\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Returns the list of attributes to observe for changes.\n * @static\n * @returns {Array<string>}\n */\n static get observedAttributes() {\n return [];\n }\n\n /**\n * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Prepares the component for updates before it is drawn.\n * This method handles the removal of templates for iteration, adjusts the height styling of the component,\n * and manages abort signals for loading operations.\n * @returns {void} No return value.\n */\n beforeDraw() {\n this._loadedItems = [];\n this._drawnItems = [];\n this._dataToElementWeakMap = new WeakMap();\n\n this.iterate = this.querySelector('[iterate]');\n\n if (this.iterate) {\n if (this.iterate.nodeName !== 'TEMPLATE') {\n console.error('The iterate attribute must be a template element');\n this.infiniteScrollTemplate = this.iterate?.outerHTML;\n } else {\n this.infiniteScrollTemplate = this.iterate?.innerHTML;\n }\n\n this.iterate?.remove(); // remove template\n }\n\n this.setAttribute('style', 'height: ' + this.height);\n\n // if this._loading is not fulfilled then cancel the promise\n if (this._signal) {\n this._abortController.abort();\n this._abortController = new AbortController();\n this._signal = this._abortController.signal;\n }\n }\n\n /**\n * Creates and returns a document fragment containing the structure for an infinite scroll component.\n * The structure includes native elements, slots for customization, and optional loading content.\n * @returns {DocumentFragment} The document fragment containing the component's DOM structure.\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('div');\n native.classList.add('native');\n native.setAttribute('part', 'native-infinite-scroll');\n\n let slot = document.createElement('slot');\n\n let ending = document.createElement('slot');\n ending.setAttribute('name', 'ending');\n\n if (WjElementUtils.hasSlot(this, 'loader')) {\n let loading = document.createElement('div');\n loading.classList.add('loading');\n\n let loader = document.createElement('slot');\n loader.setAttribute('name', 'loader');\n\n loading.appendChild(loader);\n\n this.loadingEl = loading;\n\n fragment.appendChild(loading);\n }\n\n native.appendChild(slot);\n native.appendChild(ending);\n\n fragment.appendChild(native);\n\n this.endingEl = ending;\n\n return fragment;\n }\n\n /**\n * Called after the component has been drawn.\n */\n async afterDraw() {\n this.queryParams = this.queryParams || '';\n this.size = +this.size || 10;\n this.currentPage = 0;\n\n this.scrollEvent();\n this._loading = this.loadPages(this.currentPage);\n await this._loading;\n }\n\n /**\n * Attaches a scroll event listener to the current object.\n * The `scrollEvent` function binds the `onScroll` method to the 'scroll' event\n * of the current object. This enables handling of scroll events for\n * specific functionality such as updating UI elements, loading content dynamically,\n * or tracking user interaction with scrollable content.\n */\n scrollEvent = () => {\n this.addEventListener('scroll', this.onScroll);\n };\n\n /**\n * A function that removes the scroll event listener from the current context.\n * This function is used to unbind the `onScroll` event listener\n * from the `scroll` event of the current object. It ensures that\n * the scroll event no longer triggers the `onScroll` handler.\n * @function\n */\n unScrollEvent = () => {\n this.removeEventListener('scroll', this.onScroll);\n };\n\n /**\n * A scroll event handler function that checks the scroll position and triggers loading additional content\n * when the user scrolls near the bottom of the page.\n * Properties accessed:\n * - `scrollTop`: The number of pixels that the content of an element is scrolled vertically.\n * - `scrollHeight`: The total height of the element's content.\n * - `clientHeight`: The inner height of the element in pixels, including padding but excluding borders and scrollbars.\n * Conditions:\n * - Determines if the scroll position is within 300 pixels of the bottom of the element.\n * - Verifies that the current page number is less than or equal to the total number of pages.\n * - Checks if the current page is already in the loading state.\n * Actions:\n * - Increments the current page number when the conditions are met.\n * - Initiates loading for the next page by calling the `loadPages` function.\n * @param {Event} e The scroll event object.\n */\n onScroll = (e) => {\n const { scrollTop, scrollHeight, clientHeight } = e.target;\n\n if (\n scrollTop + clientHeight >= scrollHeight - 300 &&\n this.currentPage <= this.totalPages &&\n this.isLoading.includes(this.currentPage)\n ) {\n this.currentPage++;\n this._loading = this.loadPages(this.currentPage);\n }\n };\n\n /**\n * Fetches the pages from the server.\n * @param {number} page The page number.\n * @returns {Promise<object>} The response from the server.\n */\n async getPages(page) {\n let hasParams = this.url.includes('?');\n const response = await fetch(\n `${this.url}${hasParams ? '&' : '?'}page=${page}&size=${this.size}${this?.queryParams}`,\n {\n signal: this._signal,\n }\n );\n\n if (!response.ok) {\n throw new Error(`An error occurred: ${response.status}`);\n }\n return await response.json();\n }\n\n /**\n * Hides the loader.\n */\n hideLoader() {\n this?.loadingEl?.classList.remove('show');\n }\n\n /**\n * Displays the loader element by adding the 'show' class to its class list.\n * This method is useful for indicating a loading or processing state in the UI.\n * @returns {void} No return value.\n */\n showLoader() {\n this?.loadingEl?.classList.add('show');\n }\n\n /**\n * Checks if there are more pages to load.\n * @param {number} page The page number.\n * @returns {boolean} Whether there are more pages to load.\n */\n hasMorePages(page) {\n return this.totalPages === 0 || page < this.totalPages;\n }\n\n /**\n * Loads the pages.\n * @param {number} page The page number.\n */\n async loadPages(page) {\n this.showLoader();\n try {\n if (this.hasMorePages(page)) {\n let response;\n this.parser = new DOMParser();\n\n if (typeof this.setCustomData === 'function') {\n response = await this.setCustomData(page, this._signal);\n } else {\n response = await this.getPages(page);\n }\n\n this.totalPages = response?.totalPages;\n this.currentPage = page;\n\n this.placementObj = this;\n\n // if there is a \"container\" attribute, find the element\n if (this.hasAttribute('placement')) this.placementObj = this.querySelector(this.placement);\n\n event.dispatchCustomEvent(this, 'wje-infinite-scroll:load', response);\n\n this.response = response;\n this._loadedItems = this.objectName ? response[this.objectName] : response;\n const notDrawnItems = this._loadedItems.filter(\n (item) => !this._drawnItems.some(this.compareFunction.bind(this, item))\n );\n this.customForeach(notDrawnItems);\n this._drawnItems.push(...notDrawnItems);\n\n this.isLoading.push(page);\n } else {\n event.dispatchCustomEvent(this, 'wje-infinite-scroll:complete');\n this.endingEl.classList.add('show');\n }\n } catch (error) {\n console.log(error);\n } finally {\n this.hideLoader();\n }\n }\n\n compareFunction = (i, item) => i.id === item.id;\n\n /**\n * Converts a data item into an HTML element based on a template.\n * This function takes a data item, interpolates it into a predefined template,\n * parses the resulting HTML string, and returns the first child element of the parsed HTML content.\n * @param {object} item The data object to interpolate into the HTML template.\n * @returns {Element} The first child element generated from the interpolated HTML string.\n */\n dataToHtml = (item) => {\n let interpolateItem = this.interpolate(this.infiniteScrollTemplate, item);\n let doc = this.parser.parseFromString(interpolateItem, 'text/html');\n let element = doc.activeElement.firstElementChild;\n\n return element;\n };\n\n /**\n * A custom implementation of the forEach method designed to iterate over an array of data,\n * transform each item into an HTML element, and append the element to a specified placement object.\n * Additionally, it adds an event listener to each generated element for handling click events.\n * @param {Array} data An array of items to process. Each item is transformed into an HTML element\n * and appended to the placement object specified in the context of `this`.\n */\n customForeach = (data) => {\n data.forEach((item) => {\n let element = this.dataToHtml(item);\n this._dataToElementWeakMap.set(element, item);\n\n event.addListener(element, 'click', 'wje-infinite-scroll:click-item', null);\n\n this.placementObj.insertAdjacentElement('beforeend', element);\n });\n };\n\n /**\n * Interpolates a string template with values from the provided parameters object.\n * The template contains placeholders in the format `{{key}}` or `{{key.subkey}}`,\n * which are replaced with the corresponding values from the `params` object.\n * Placeholders support dot notation for accessing nested properties within the `params` object.\n * @param {string} template The string template containing placeholders to be replaced.\n * @param {object} params The object containing key-value pairs used for substitution in the template.\n * @returns {string} A string with all placeholders replaced by their respective values from the `params` object.\n */\n interpolate = (template, params) => {\n let keys = template.match(/\\{{.*?\\}}/g);\n\n if (keys) {\n for (let key of keys) {\n let cleanKey = key.replace('{{', '').replace('}}', '');\n let val = '';\n cleanKey.split('.').forEach((k) => {\n val = val === '' ? params[k] : val[k];\n });\n\n template = template.replace(key, val);\n }\n }\n return template;\n };\n\n addItem(item, place = 'beforeend') {\n let element = this.dataToHtml(item);\n this._dataToElementWeakMap.set(element, item);\n this.placementObj.insertAdjacentElement(place, element);\n\n this._drawnItems.push(item);\n\n // if drawnItems are more than page * size then add the page to isLoading\n if (this._drawnItems.length > this.size * this.currentPage) {\n this.totalPages += 1;\n }\n }\n\n removeItem(item) {\n let element = this._dataToElementWeakMap.get(item);\n element.remove();\n this._drawnItems = this._drawnItems.filter((i) => i !== item);\n // if drawnItems are less than page * size then remove the page from isLoading\n if (this._drawnItems.length < this.size * this.currentPage) {\n this.isLoading = this.isLoading.filter((i) => i !== this.currentPage);\n this.currentPage--;\n }\n }\n}\n"],"names":[],"mappings":";;;;;AAkBe,MAAM,uBAAuB,UAAU;AAAA;AAAA;AAAA;AAAA,EAIlD,cAAc;AACV,UAAO;AA2DX,qCAAY;AA0HZ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uCAAc,MAAM;AAChB,WAAK,iBAAiB,UAAU,KAAK,QAAQ;AAAA,IAChD;AASD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yCAAgB,MAAM;AAClB,WAAK,oBAAoB,UAAU,KAAK,QAAQ;AAAA,IACnD;AAkBD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oCAAW,CAAC,MAAM;AACd,YAAM,EAAE,WAAW,cAAc,aAAc,IAAG,EAAE;AAEpD,UACI,YAAY,gBAAgB,eAAe,OAC3C,KAAK,eAAe,KAAK,cACzB,KAAK,UAAU,SAAS,KAAK,WAAW,GAC1C;AACE,aAAK;AACL,aAAK,WAAW,KAAK,UAAU,KAAK,WAAW;AAAA,MAC3D;AAAA,IACK;AA8FD,2CAAkB,CAAC,GAAG,SAAS,EAAE,OAAO,KAAK;AAS7C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sCAAa,CAAC,SAAS;AACnB,UAAI,kBAAkB,KAAK,YAAY,KAAK,wBAAwB,IAAI;AACxE,UAAI,MAAM,KAAK,OAAO,gBAAgB,iBAAiB,WAAW;AAClE,UAAI,UAAU,IAAI,cAAc;AAEhC,aAAO;AAAA,IACV;AASD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yCAAgB,CAAC,SAAS;AACtB,WAAK,QAAQ,CAAC,SAAS;AACnB,YAAI,UAAU,KAAK,WAAW,IAAI;A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AK,WAAW,IAAI;AAClC,SAAK,sBAAsB,IAAI,SAAS,IAAI;AAC5C,SAAK,aAAa,sBAAsB,OAAO,OAAO;AAEtD,SAAK,YAAY,KAAK,IAAI;AAG1B,QAAI,KAAK,YAAY,SAAS,KAAK,OAAO,KAAK,aAAa;AACxD,WAAK,cAAc;AAAA,IAC/B;AAAA,EACA;AAAA,EAEI,WAAW,MAAM;AACb,QAAI,UAAU,KAAK,sBAAsB,IAAI,IAAI;AACjD,YAAQ,OAAQ;AAChB,SAAK,cAAc,KAAK,YAAY,OAAO,CAAC,MAAM,MAAM,IAAI;AAE5D,QAAI,KAAK,YAAY,SAAS,KAAK,OAAO,KAAK,aAAa;AACxD,WAAK,YAAY,KAAK,UAAU,OAAO,CAAC,MAAM,MAAM,KAAK,WAAW;AACpE,WAAK;AAAA,IACjB;AAAA,EACA;AACA;"}
package/dist/light.css CHANGED
@@ -491,10 +491,23 @@
491
491
  --wje-rate-color: var(--wje-color-contrast-11);
492
492
  --wje-rate-selected-color: var(--wje-color-danger-9);
493
493
 
494
+ /* Select */
495
+ --wje-select-border-width: 1px;
496
+ --wje-select-border-style: solid;
497
+ --wje-select-border-color: var(--wje-border-color);
498
+ --wje-select-options-border-width: 1px;
499
+ --wje-select-options-border-style: var(--wje-border-style);
500
+ --wje-select-options-border-color: var(--wje-border-color);
501
+ --wje-select-background: var(--wje-color-contrast-0);
502
+ --wje-select-line-height: 20px;
503
+ --wje-select-color: var(--wje-color);
504
+ --wje-select-border-radius: var(--wje-border-radius-medium);
505
+ --wje-select-margin-bottom: 0.5rem;
506
+
494
507
  /* Status */
495
508
  --wje-status-size: var(--wje-size-small);
496
509
 
497
- /*Stepper*/
510
+ /* Stepper */
498
511
  --wje-stepper-margin: 1.25rem;
499
512
  --wje-stepper-justify: start;
500
513
  --wje-stepper-grow: initial;
@@ -31,6 +31,17 @@ export default class Dialog extends WJElement {
31
31
  * @returns {*[]}
32
32
  */
33
33
  static get observedAttributes(): any[];
34
+ /**
35
+ * Sets the value of the 'headline' attribute.
36
+ * @param {string} value The new value for the 'headline' attribute.
37
+ */
38
+ set headline(value: string);
39
+ /**
40
+ * Retrieves the value of the "headline" attribute from the element.
41
+ * If the "headline" attribute is not present, returns an empty string.
42
+ * @returns {string} The headline attribute value or an empty string if not set.
43
+ */
44
+ get headline(): string;
34
45
  /**
35
46
  * Sets the headline of the dialog.
36
47
  * @param value
@@ -97,7 +97,7 @@ export default class WJElement extends HTMLElement {
97
97
  * Gets the rendering context, either the shadow root or the component itself.
98
98
  * @returns The rendering context.
99
99
  */
100
- get context(): any;
100
+ get context(): this | ShadowRoot;
101
101
  /**
102
102
  * Gets the store instance.
103
103
  * @returns {object} The store instance.
@@ -6,12 +6,12 @@ export class UniversalService {
6
6
  findAttributeValue: (attrName: any) => any;
7
7
  update: (data: any, action: any) => void;
8
8
  add: (data: any, action: any) => void;
9
- _save(url: any, data: any, action: any, dispatchMethod: any, method: any): any;
10
- _get(url: any, action: any, dispatchMethod: any, signal: any): any;
11
- put(url: any, data: any, action: any, dispatchMethod?: boolean): any;
12
- post(url: any, data: any, action: any, dispatchMethod?: boolean): any;
13
- delete(url: any, data: any, action: any, dispatchMethod?: boolean): any;
14
- get(url: any, action: any, dispatchMethod?: boolean): any;
9
+ _request(url: any, data: any, action: any, dispatchMethod: any, method: any, signal: any): any;
10
+ put(url: any, data: any, action: any, dispatchMethod?: boolean, signal?: any): any;
11
+ post(url: any, data: any, action: any, dispatchMethod?: boolean, signal?: any): any;
12
+ delete(url: any, data: any, action: any, dispatchMethod?: boolean, signal?: any): any;
13
+ get(url: any, action: any, dispatchMethod?: boolean, signal?: any): any;
14
+ patch(url: any, data: any, action: any, dispatchMethod?: boolean, signal?: any): any;
15
15
  dispatch(promise: any, dispatchMethod: any, action: any): any;
16
16
  loadPromise: (url: any, action: any, method?: string, data?: string, permissionCallBack?: () => void) => Promise<any>;
17
17
  loadOnePromise: (url: any, action: any) => Promise<any>;
@@ -19,7 +19,12 @@ export default class Options extends WJElement {
19
19
  * @returns {Array<string>}
20
20
  */
21
21
  static get observedAttributes(): Array<string>;
22
- _loadedOptions: any[];
22
+ /**
23
+ * Stores the loaded options.
24
+ * @type {Array}
25
+ * @private
26
+ */
27
+ private _loadedOptions;
23
28
  dependencies: {
24
29
  'wje-option': typeof Option;
25
30
  'wje-infinite-scroll': typeof InfiniteScroll;
@@ -137,12 +142,16 @@ export default class Options extends WJElement {
137
142
  * @returns {Array} The loaded options.
138
143
  */
139
144
  get options(): any[];
145
+ /**
146
+ * Sets the loaded options.
147
+ * @type {Array}
148
+ */
140
149
  set loadedOptions(loadedOptions: any[]);
141
- get loadedOptions(): any[];
142
150
  /**
143
- * Lifecycle method, called whenever an observed property changes.
151
+ * Gets the loaded options.
152
+ * @type {Array}
144
153
  */
145
- attributeChangedCallback(name: any, oldValue: any, newValue: any): void;
154
+ get loadedOptions(): any[];
146
155
  /**
147
156
  * Prepares the component before drawing.
148
157
  * Fetches the pages and creates the options elements.
@@ -19,6 +19,10 @@ import { default as Options } from '../wje-options/options.js';
19
19
  * @csspart native - The native select wrapper.
20
20
  * @csspart input - The input field.
21
21
  * @csspart clear - The clear button.
22
+ * @property {Array} _selected - An array to store selected items.
23
+ * @property {HTMLElement|null} counterEl - A reference to the counter element, initially null.
24
+ * @property {ElementInternals} internals - The internal element API for managing state and attributes.
25
+ * @property {boolean} _wasOppened - Tracks whether the select element was previously opened, initially false.
22
26
  * @cssproperty [--wje-select-border-width=1px] - Specifies the width of the border around the select component. Accepts any valid CSS length unit (e.g., `px`, `rem`, `em`).
23
27
  * @cssproperty [--wje-select-border-style=solid] - Defines the style of the border for the select component. Accepts standard CSS border styles, such as `solid`, `dashed`, or `dotted`.
24
28
  * @cssproperty [--wje-select-border-color=var(--wje-border-color)] - Sets the color of the border for the select component. Accepts any valid CSS color value, including color variables, named colors, and hex values.
@@ -49,9 +53,84 @@ export default class Select extends WJElement {
49
53
  * @type {boolean}
50
54
  */
51
55
  static formAssociated: boolean;
56
+ /**
57
+ * @type {Array}
58
+ * @description An array to store selected items.
59
+ */
52
60
  _selected: any[];
53
- counterEl: HTMLSpanElement;
54
- internals: ElementInternals;
61
+ /**
62
+ * @type {HTMLElement|null}
63
+ * @description A reference to the counter element, initially null.
64
+ * @private
65
+ */
66
+ private counterEl;
67
+ /**
68
+ * @type {ElementInternals}
69
+ * @description The internal element API for managing state and attributes.
70
+ * @private
71
+ * @readonly
72
+ * @constant
73
+ * @default {ElementInternals} this.attachInternals()
74
+ * @description Attaches the internals to the element.
75
+ */
76
+ private readonly internals;
77
+ /**
78
+ * @type {boolean}
79
+ * @description Tracks whether the select element was previously opened, initially false.
80
+ * @private
81
+ * @default {boolean} false
82
+ */
83
+ private _wasOppened;
84
+ /**
85
+ * @type {HTMLElement|null}
86
+ * @description A reference to the native select element, initially null.
87
+ */
88
+ native: HTMLElement | null;
89
+ /**
90
+ * @type {HTMLElement|null}
91
+ * @description A reference to the popup element, initially null.
92
+ */
93
+ popup: HTMLElement | null;
94
+ /**
95
+ * @type {HTMLElement|null}
96
+ * @description A reference to the label element, initially null.
97
+ */
98
+ labelElement: HTMLElement | null;
99
+ /**
100
+ * @type {HTMLElement|null}
101
+ * @description A reference to the slot start element, initially null.
102
+ */
103
+ slotStart: HTMLElement | null;
104
+ /**
105
+ * @type {HTMLElement|null}
106
+ * @description A reference to the slot end element, initially null.
107
+ */
108
+ slotEnd: HTMLElement | null;
109
+ /**
110
+ * @type {HTMLElement|null}
111
+ * @description A reference to the input element, initially null.
112
+ */
113
+ input: HTMLElement | null;
114
+ /**
115
+ * @type {HTMLElement|null}
116
+ * @description A reference to the options wrapper element, initially null.
117
+ */
118
+ optionsWrapper: HTMLElement | null;
119
+ /**
120
+ * @type {HTMLElement|null}
121
+ * @description A reference to the chips element, initially null.
122
+ */
123
+ chips: HTMLElement | null;
124
+ /**
125
+ * @type {HTMLElement|null}
126
+ * @description A reference to the clear button element, initially null.
127
+ */
128
+ clear: HTMLElement | null;
129
+ /**
130
+ * @type {HTMLElement|null}
131
+ * @description A reference to the list element, initially null.
132
+ */
133
+ list: HTMLElement | null;
55
134
  dependencies: {
56
135
  'wje-button': typeof Button;
57
136
  'wje-popup': typeof Popup;
@@ -163,16 +242,6 @@ export default class Select extends WJElement {
163
242
  */
164
243
  draw(): DocumentFragment;
165
244
  findEl: HTMLElement;
166
- native: HTMLDivElement;
167
- popup: HTMLElement;
168
- labelElement: HTMLElement;
169
- slotStart: HTMLDivElement;
170
- slotEnd: HTMLDivElement;
171
- input: HTMLInputElement;
172
- optionsWrapper: HTMLDivElement;
173
- chips: HTMLDivElement;
174
- clear: HTMLElement;
175
- list: HTMLDivElement;
176
245
  /**
177
246
  * Sets up the event listeners after the component is drawn.
178
247
  */
@@ -164,8 +164,6 @@ class Breadcrumb extends WJElement {
164
164
  <wje-menu-item>Test 1</wje-menu-item>
165
165
  <wje-menu-item>Test 2</wje-menu-item>
166
166
  </wje-menu>`;
167
- this.parentElement.querySelectorAll("wje-breadcrumb").forEach((el) => {
168
- });
169
167
  return dropdown;
170
168
  }
171
169
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"wje-breadcrumb.js","sources":["../packages/wje-breadcrumb/breadcrumb.element.js","../packages/wje-breadcrumb/breadcrumb.js"],"sourcesContent":["import { default as WJElement, event, WjElementUtils } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary This class represents a Breadcrumb element, extending the WJElement class. It provides a navigational aid in user interfaces, displaying the current location within a hierarchy.\n * @documentation https://elements.webjet.sk/components/breadcrumb\n * @status stable\n * @augments WJElement\n * @slot - The main content of the breadcrumb.\n * @slot start - Slot for content at the start of the breadcrumb.\n * @slot end - Slot for content at the end of the breadcrumb.\n * @slot separator - Slot for a custom separator between breadcrumb items.\n * @csspart native - The native wrapper of the breadcrumb component.\n * @csspart separator - The separator between breadcrumb items.\n * @cssproperty [--wje-breadcrumb-a=var(--wje-color-contrast-8)] - The color of the breadcrumb text.\n * @cssproperty [--wje-breadcrumb-a-hover=var(--wje-color-contrast-6)] - The color of the breadcrumb separator line.\n * @tag wje-breadcrumb\n */\nexport default class Breadcrumb extends WJElement {\n /**\n * Breadcrumb constructor method.\n */\n constructor() {\n super();\n\n this._showSeparator = true;\n this.showCollapsedIndicator = false;\n }\n\n /**\n * Get show separator flag.\n * @returns {boolean} showSeparator - The show separator flag\n */\n get showSeparator() {\n return this._showSeparator;\n }\n\n /**\n * Set show separator flag.\n * @param {boolean} value The value to set\n */\n set showSeparator(value) {\n this._showSeparator = value;\n }\n\n /**\n * Set collapsed variant.\n * @param {string} value The value to set\n */\n set collapsedVariant(value) {\n this._collapsedVariant = value;\n }\n\n /**\n * Get collapsed variant.\n * @returns {string} The collapsed variant value in uppercase.\n */\n get collapsedVariant() {\n let variant = this.parentElement.variant || this._collapsedVariant;\n return variant.toUpperCase();\n }\n\n /**\n * Class name for the Breadcrumb element.\n * @type {string}\n */\n className = 'Breadcrumb';\n\n /**\n * Get CSS stylesheet for the Breadcrumb element.\n * @static\n * @returns {object} styles - The CSS styles\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Get observed attributes for the Breadcrumb element.\n * @static\n * @returns {Array<string>} - The observed attributes array for the Breadcrumb element.\n */\n static get observedAttributes() {\n return ['show-collapsed-indicator', 'collapsed', 'last'];\n }\n\n /**\n * Attribute changed callback method.\n * @returns {boolean} false - Always returns false\n */\n attributeChangedCallback(name, oldValue, newValue) {\n if (name === 'collapsed') {\n if (WjElementUtils.stringToBoolean(newValue) && !this.hasAttribute('show-collapsed-indicator'))\n this.classList.add('collapsed');\n } else if (name === 'show-collapsed-indicator') {\n if (WjElementUtils.stringToBoolean(newValue)) {\n this.showCollapsedIndicator = true;\n this.refresh();\n }\n } else if (name === 'last') {\n this.active = WjElementUtils.stringToBoolean(newValue);\n this.showSeparator = !WjElementUtils.stringToBoolean(newValue);\n this.refresh();\n }\n\n return false;\n }\n\n /**\n * Setup attributes for the Breadcrumb element.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Draw method for the Breadcrumb element.\n * @returns {object} fragment - The document fragment\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('a');\n native.classList.add('native-breadcrumb');\n native.setAttribute('part', 'native');\n\n if (this.active) native.classList.add('active');\n\n let slot = document.createElement('slot');\n\n let start = document.createElement('slot');\n start.setAttribute('name', 'start');\n\n let end = document.createElement('slot');\n end.setAttribute('name', 'end');\n\n native.appendChild(start);\n native.appendChild(slot);\n native.appendChild(end);\n\n fragment.appendChild(native);\n if (WjElementUtils.stringToBoolean(this.showCollapsedIndicator)) {\n // pridame button za native element\n fragment.appendChild(this.drawCollapsedIndicator());\n\n // skryjeme native element\n native.classList.add('hidden');\n }\n\n if (this.showSeparator) {\n let separator = document.createElement('span');\n separator.classList.add('separator');\n separator.setAttribute('part', 'separator');\n\n if (WjElementUtils.hasSlot(this, 'separator')) {\n let slotSeparator = document.createElement('slot');\n slotSeparator.setAttribute('name', 'separator');\n\n separator.appendChild(slotSeparator);\n } else {\n separator.innerHTML = `<wje-icon name=${this.separator || 'chevron-right'}></wje-icon>`;\n }\n\n fragment.appendChild(separator);\n }\n\n this.native = native;\n\n return fragment;\n }\n\n /**\n * Draw collapsed indicator method.\n * @returns {object} - The collapsed indicator element.\n */\n drawCollapsedIndicator() {\n let collapsedIndicator = null;\n\n if (this.collapsedVariant === 'DROPDOWN') {\n collapsedIndicator = this.collapseDropdown();\n } else {\n collapsedIndicator = this.collapseButton();\n }\n\n return collapsedIndicator;\n }\n\n /**\n * Collapse dropdown button.\n * @returns {object} dropdown - The dropdown button.\n */\n collapseDropdown() {\n let dropdown = document.createElement('wje-dropdown');\n dropdown.setAttribute('placement', 'bottom');\n dropdown.setAttribute('offset', '10');\n\n let button = document.createElement('wje-button');\n button.setAttribute('slot', 'trigger');\n button.setAttribute('fill', 'link');\n button.innerHTML = `<wje-icon name=\"dots\"></wje-icon>`;\n\n let menu = document.createElement('wje-menu');\n menu.setAttribute('variant', 'context');\n\n dropdown.appendChild(button);\n dropdown.appendChild(menu);\n\n dropdown.innerHTML = `<wje-button slot=\"trigger\" fill=\"link\">\n <wje-icon name=\"dots\"></wje-icon>\n </wje-button>\n <wje-menu variant=\"context\">\n <wje-menu-item>Test 0</wje-menu-item>\n <wje-menu-item>Test 1</wje-menu-item>\n <wje-menu-item>Test 2</wje-menu-item>\n </wje-menu>`;\n\n this.parentElement.querySelectorAll('wje-breadcrumb').forEach((el) => {\n // console.log(el);\n });\n\n return dropdown;\n }\n\n /**\n * Collapse button method.\n * @returns {object} - The button element.\n */\n collapseButton() {\n let button = document.createElement('button');\n button.setAttribute('aria-label', 'Show more breadcrumbs');\n button.setAttribute('part', 'collapsed-indicator');\n button.innerHTML = `<wje-icon name=\"dots\"></wje-icon>`;\n\n event.addListener(button, 'click', null, (e) => {\n this.native.classList.remove('hidden');\n button.remove();\n this.parentElement.querySelectorAll('wje-breadcrumb').forEach((el) => {\n el.classList.remove('collapsed');\n });\n e.stopPropagation();\n });\n\n return button;\n }\n}\n","import Breadcrumb from './breadcrumb.element.js';\n\n// export * from \"./breadcrumb.element.js\";\nexport default Breadcrumb;\n\nBreadcrumb.define('wje-breadcrumb', Breadcrumb);\n"],"names":[],"mappings":";;;;;AAkBe,MAAM,mBAAmB,UAAU;AAAA;AAAA;AAAA;AAAA,EAI9C,cAAc;AACV,UAAO;AA2CX;AAAA;AAAA;AAAA;AAAA,qCAAY;AAzCR,SAAK,iBAAiB;AACtB,SAAK,yBAAyB;AAAA,EACtC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,gBAAgB;AAChB,WAAO,KAAK;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,cAAc,OAAO;AACrB,SAAK,iBAAiB;AAAA,EAC9B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,iBAAiB,OAAO;AACxB,SAAK,oBAAoB;AAAA,EACjC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,m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,IAAI;AAEzB,aAAS,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASrB,SAAK,cAAc,iBAAiB,gBAAgB,EAAE,QAAQ,CAAC,OAAO;AAAA,IAE9E,CAAS;AAED,WAAO;AAAA,EACf;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,iBAAiB;AACb,QAAI,SAAS,SAAS,cAAc,QAAQ;AAC5C,WAAO,aAAa,cAAc,uBAAuB;AACzD,WAAO,aAAa,QAAQ,qBAAqB;AACjD,WAAO,YAAY;AAEnB,UAAM,YAAY,QAAQ,SAAS,MAAM,CAAC,MAAM;AAC5C,WAAK,OAAO,UAAU,OAAO,QAAQ;AACrC,aAAO,OAAQ;AACf,WAAK,cAAc,iBAAiB,gBAAgB,EAAE,QAAQ,CAAC,OAAO;AAClE,WAAG,UAAU,OAAO,WAAW;AAAA,MAC/C,CAAa;AACD,QAAE,gBAAiB;AAAA,IAC/B,CAAS;AAED,WAAO;AAAA,EACf;AACA;AC/OA,WAAW,OAAO,kBAAkB,UAAU;"}
1
+ {"version":3,"file":"wje-breadcrumb.js","sources":["../packages/wje-breadcrumb/breadcrumb.element.js","../packages/wje-breadcrumb/breadcrumb.js"],"sourcesContent":["import { default as WJElement, event, WjElementUtils } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary This class represents a Breadcrumb element, extending the WJElement class. It provides a navigational aid in user interfaces, displaying the current location within a hierarchy.\n * @documentation https://elements.webjet.sk/components/breadcrumb\n * @status stable\n * @augments WJElement\n * @slot - The main content of the breadcrumb.\n * @slot start - Slot for content at the start of the breadcrumb.\n * @slot end - Slot for content at the end of the breadcrumb.\n * @slot separator - Slot for a custom separator between breadcrumb items.\n * @csspart native - The native wrapper of the breadcrumb component.\n * @csspart separator - The separator between breadcrumb items.\n * @cssproperty [--wje-breadcrumb-a=var(--wje-color-contrast-8)] - The color of the breadcrumb text.\n * @cssproperty [--wje-breadcrumb-a-hover=var(--wje-color-contrast-6)] - The color of the breadcrumb separator line.\n * @tag wje-breadcrumb\n */\nexport default class Breadcrumb extends WJElement {\n /**\n * Breadcrumb constructor method.\n */\n constructor() {\n super();\n\n this._showSeparator = true;\n this.showCollapsedIndicator = false;\n }\n\n /**\n * Get show separator flag.\n * @returns {boolean} showSeparator - The show separator flag\n */\n get showSeparator() {\n return this._showSeparator;\n }\n\n /**\n * Set show separator flag.\n * @param {boolean} value The value to set\n */\n set showSeparator(value) {\n this._showSeparator = value;\n }\n\n /**\n * Set collapsed variant.\n * @param {string} value The value to set\n */\n set collapsedVariant(value) {\n this._collapsedVariant = value;\n }\n\n /**\n * Get collapsed variant.\n * @returns {string} The collapsed variant value in uppercase.\n */\n get collapsedVariant() {\n let variant = this.parentElement.variant || this._collapsedVariant;\n return variant.toUpperCase();\n }\n\n /**\n * Class name for the Breadcrumb element.\n * @type {string}\n */\n className = 'Breadcrumb';\n\n /**\n * Get CSS stylesheet for the Breadcrumb element.\n * @static\n * @returns {object} styles - The CSS styles\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Get observed attributes for the Breadcrumb element.\n * @static\n * @returns {Array<string>} - The observed attributes array for the Breadcrumb element.\n */\n static get observedAttributes() {\n return ['show-collapsed-indicator', 'collapsed', 'last'];\n }\n\n /**\n * Attribute changed callback method.\n * @returns {boolean} false - Always returns false\n */\n attributeChangedCallback(name, oldValue, newValue) {\n if (name === 'collapsed') {\n if (WjElementUtils.stringToBoolean(newValue) && !this.hasAttribute('show-collapsed-indicator'))\n this.classList.add('collapsed');\n } else if (name === 'show-collapsed-indicator') {\n if (WjElementUtils.stringToBoolean(newValue)) {\n this.showCollapsedIndicator = true;\n this.refresh();\n }\n } else if (name === 'last') {\n this.active = WjElementUtils.stringToBoolean(newValue);\n this.showSeparator = !WjElementUtils.stringToBoolean(newValue);\n this.refresh();\n }\n\n return false;\n }\n\n /**\n * Setup attributes for the Breadcrumb element.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Draw method for the Breadcrumb element.\n * @returns {object} fragment - The document fragment\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('a');\n native.classList.add('native-breadcrumb');\n native.setAttribute('part', 'native');\n\n if (this.active) native.classList.add('active');\n\n let slot = document.createElement('slot');\n\n let start = document.createElement('slot');\n start.setAttribute('name', 'start');\n\n let end = document.createElement('slot');\n end.setAttribute('name', 'end');\n\n native.appendChild(start);\n native.appendChild(slot);\n native.appendChild(end);\n\n fragment.appendChild(native);\n if (WjElementUtils.stringToBoolean(this.showCollapsedIndicator)) {\n // pridame button za native element\n fragment.appendChild(this.drawCollapsedIndicator());\n\n // skryjeme native element\n native.classList.add('hidden');\n }\n\n if (this.showSeparator) {\n let separator = document.createElement('span');\n separator.classList.add('separator');\n separator.setAttribute('part', 'separator');\n\n if (WjElementUtils.hasSlot(this, 'separator')) {\n let slotSeparator = document.createElement('slot');\n slotSeparator.setAttribute('name', 'separator');\n\n separator.appendChild(slotSeparator);\n } else {\n separator.innerHTML = `<wje-icon name=${this.separator || 'chevron-right'}></wje-icon>`;\n }\n\n fragment.appendChild(separator);\n }\n\n this.native = native;\n\n return fragment;\n }\n\n /**\n * Draw collapsed indicator method.\n * @returns {object} - The collapsed indicator element.\n */\n drawCollapsedIndicator() {\n let collapsedIndicator = null;\n\n if (this.collapsedVariant === 'DROPDOWN') {\n collapsedIndicator = this.collapseDropdown();\n } else {\n collapsedIndicator = this.collapseButton();\n }\n\n return collapsedIndicator;\n }\n\n /**\n * Collapse dropdown button.\n * @returns {object} dropdown - The dropdown button.\n */\n collapseDropdown() {\n let dropdown = document.createElement('wje-dropdown');\n dropdown.setAttribute('placement', 'bottom');\n dropdown.setAttribute('offset', '10');\n\n let button = document.createElement('wje-button');\n button.setAttribute('slot', 'trigger');\n button.setAttribute('fill', 'link');\n button.innerHTML = `<wje-icon name=\"dots\"></wje-icon>`;\n\n let menu = document.createElement('wje-menu');\n menu.setAttribute('variant', 'context');\n\n dropdown.appendChild(button);\n dropdown.appendChild(menu);\n\n dropdown.innerHTML = `<wje-button slot=\"trigger\" fill=\"link\">\n <wje-icon name=\"dots\"></wje-icon>\n </wje-button>\n <wje-menu variant=\"context\">\n <wje-menu-item>Test 0</wje-menu-item>\n <wje-menu-item>Test 1</wje-menu-item>\n <wje-menu-item>Test 2</wje-menu-item>\n </wje-menu>`;\n\n return dropdown;\n }\n\n /**\n * Collapse button method.\n * @returns {object} - The button element.\n */\n collapseButton() {\n let button = document.createElement('button');\n button.setAttribute('aria-label', 'Show more breadcrumbs');\n button.setAttribute('part', 'collapsed-indicator');\n button.innerHTML = `<wje-icon name=\"dots\"></wje-icon>`;\n\n event.addListener(button, 'click', null, (e) => {\n this.native.classList.remove('hidden');\n button.remove();\n this.parentElement.querySelectorAll('wje-breadcrumb').forEach((el) => {\n el.classList.remove('collapsed');\n });\n e.stopPropagation();\n });\n\n return button;\n }\n}\n","import Breadcrumb from './breadcrumb.element.js';\n\n// export * from \"./breadcrumb.element.js\";\nexport default Breadcrumb;\n\nBreadcrumb.define('wje-breadcrumb', Breadcrumb);\n"],"names":[],"mappings":";;;;;AAkBe,MAAM,mBAAmB,UAAU;AAAA;AAAA;AAAA;AAAA,EAI9C,cAAc;AACV,UAAO;AA2CX;AAAA;AAAA;AAAA;AAAA,qCAAY;AAzCR,SAAK,iBAAiB;AACtB,SAAK,yBAAyB;AAAA,EACtC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,gBAAgB;AAChB,WAAO,KAAK;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,cAAc,OAAO;AACrB,SAAK,iBAAiB;AAAA,EAC9B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,iBAAiB,OAAO;AACxB,SAAK,oBAAoB;AAAA,EACjC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,mBAAmB;AACnB,QAAI,UAAU,KAAK,cAAc,WAAW,KAAK;AACjD,WAAO,QAAQ,YAA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B,WAAO;AAAA,EACf;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,iBAAiB;AACb,QAAI,SAAS,SAAS,cAAc,QAAQ;AAC5C,WAAO,aAAa,cAAc,uBAAuB;AACzD,WAAO,aAAa,QAAQ,qBAAqB;AACjD,WAAO,YAAY;AAEnB,UAAM,YAAY,QAAQ,SAAS,MAAM,CAAC,MAAM;AAC5C,WAAK,OAAO,UAAU,OAAO,QAAQ;AACrC,aAAO,OAAQ;AACf,WAAK,cAAc,iBAAiB,gBAAgB,EAAE,QAAQ,CAAC,OAAO;AAClE,WAAG,UAAU,OAAO,WAAW;AAAA,MAC/C,CAAa;AACD,QAAE,gBAAiB;AAAA,IAC/B,CAAS;AAED,WAAO;AAAA,EACf;AACA;AC3OA,WAAW,OAAO,kBAAkB,UAAU;"}
@@ -98,7 +98,6 @@ class CopyButton extends WJElement {
98
98
  }
99
99
  this.tooltip.setAttribute("content", this.labelSuccess || "Copied");
100
100
  setTimeout(() => {
101
- console.log("TIMEOUT", this.hasOwnProperty("icon"));
102
101
  if (this.hasOwnProperty("icon")) {
103
102
  this.icon.removeAttribute("color");
104
103
  this.icon.setAttribute("name", "clipboard");
@@ -1 +1 @@
1
- {"version":3,"file":"wje-copy-button.js","sources":["../packages/wje-copy-button/service/service.js","../packages/wje-copy-button/copy-button.element.js","../packages/wje-copy-button/copy-button.js"],"sourcesContent":["/**\n * Create a node with the text content.\n * @param text\n * @returns {Element}\n */\nfunction createNode(text) {\n const node = document.createElement('pre');\n node.style.width = '1px';\n node.style.height = '1px';\n node.style.position = 'fixed';\n node.style.top = '5px';\n node.textContent = text;\n return node;\n}\n\n/**\n * Copy the node to the clipboard.\n * @param node\n * @returns {Promise<never>|Promise<void>}\n */\nexport function copyNode(node) {\n if ('clipboard' in navigator) {\n return navigator.clipboard.writeText(node.textContent || '');\n }\n\n const selection = getSelection(); // Firefox return null\n if (selection === null) {\n return Promise.reject(new Error());\n }\n\n selection.removeAllRanges();\n\n const range = document.createRange();\n range.selectNodeContents(node);\n selection.addRange(range);\n\n // document.execCommand(\"copy\")\n selection.removeAllRanges();\n return Promise.resolve();\n}\n\n/**\n * Copy the text to the clipboard.\n * @param text\n * @returns {Promise<never>|Promise<void>}\n */\nexport function copyText(text) {\n if ('clipboard' in navigator) {\n return navigator.clipboard.writeText(text);\n }\n\n const body = document.body;\n if (!body) {\n return Promise.reject(new Error());\n }\n\n const node = createNode(text);\n body.appendChild(node);\n copyNode(node);\n body.removeChild(node);\n return Promise.resolve();\n}\n","import { default as WJElement, event, WjElementUtils } from '../wje-element/element.js';\nimport Input from '../wje-input/input.js';\nimport { copyNode, copyText } from './service/service.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary CopyButton is a custom web component that extends WJElement.\n * It provides a button that, when clicked, copies a specified text to the clipboard.\n * The text to be copied can be specified through the `value` attribute.\n * The CopyButton also supports keyboard interaction, copying the text when the space or enter key is pressed.\n * @documentation https://elements.webjet.sk/components/copy-button\n * @status stable\n * @augments WJElement\n * @attribute {string} for - The id of the element to copy content from.\n * @attribute {string} value - The text to be copied.\n * @slot - This is a default/unnamed slot.\n * @csspart button - Styles the button element.\n * @cssproperty --text-color - Controls the color of the text.\n * @cssproperty --background-color - Controls the background color of the button.\n * //@fires wje:copy-button - Dispatched when the button is clicked and the text is copied.\n * @tag wje-copy-button\n */\nexport default class CopyButton extends WJElement {\n /**\n * Constructor for the CopyButton class.\n * Initializes the timeout property.\n */\n constructor() {\n super();\n\n this.timeout = 1000;\n }\n\n /**\n * Setter for the value property.\n * @param {string} value The value to be set.\n */\n set value(value) {\n this.setAttribute('value', value);\n }\n\n /**\n * Getter for the value property.\n * @returns {string} The value of the value property.\n */\n get value() {\n return this.getAttribute('value') || '';\n }\n\n className = 'CopyButton';\n\n /**\n * Getter for the cssStyleSheet property.\n * @returns {string} The CSS styles.\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Getter for the observedAttributes property.\n * @returns {Array} An empty array.\n */\n static get observedAttributes() {\n return [];\n }\n\n /**\n * Sets up the attributes for the CopyButton.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Draws the ColorPicker element.\n * @returns {DocumentFragment} The created document fragment.\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let tooltip = document.createElement('wje-tooltip');\n tooltip.setAttribute('offset', '5');\n tooltip.setAttribute('content', this.label || 'Copy');\n\n if (WjElementUtils.hasSlot(this)) {\n let slot = document.createElement('slot');\n tooltip.appendChild(slot);\n } else {\n let icon = document.createElement('wje-icon');\n icon.setAttribute('name', 'clipboard');\n\n tooltip.appendChild(icon);\n this.icon = icon;\n }\n\n fragment.appendChild(tooltip);\n\n this.tooltip = tooltip;\n\n return fragment;\n }\n\n /**\n * Adds event listeners for the click, focus, and blur events.\n */\n afterDraw() {\n event.addListener(this, 'click', null, this.clicked);\n event.addListener(this, 'focus', null, this.focused);\n event.addListener(this, 'blur', null, this.blurred);\n\n event.addListener(this, 'wje-copy-button:click', null, this.copied);\n }\n\n /**\n * Handles the click event.\n * @param {Event} e The event object.\n */\n clicked = (e) => {\n const button = e.currentTarget;\n if (button instanceof HTMLElement) {\n this.copy(button);\n }\n };\n\n /**\n * Handles the keydown event.\n * @param {Event} e The event object.\n */\n keydown = (e) => {\n if (e.key === ' ' || e.key === 'Enter') {\n const button = e.currentTarget;\n if (button instanceof HTMLElement) {\n this.copy(button);\n }\n }\n };\n\n /**\n * Handles the focus event.\n * @param {Event} e The event object.\n */\n focused = (e) => {\n e.currentTarget.addEventListener('keydown', this.keydown);\n };\n\n /**\n * Handles the blur event.\n * @param {Event} e The event object.\n */\n blurred = (e) => {\n e.currentTarget.removeEventListener('keydown', this.keydown);\n };\n\n /**\n * Handles the copied event.\n * You can override this method to customize the behavior when the text is copied.\n * @param {Event} e The event object.\n */\n copied = (e) => {\n if (this.hasOwnProperty('icon')) {\n this.icon.setAttribute('color', 'success');\n this.icon.setAttribute('name', 'check');\n }\n this.tooltip.setAttribute('content', this.labelSuccess || 'Copied');\n\n setTimeout(() => {\n console.log('TIMEOUT', this.hasOwnProperty('icon'));\n if (this.hasOwnProperty('icon')) {\n this.icon.removeAttribute('color');\n this.icon.setAttribute('name', 'clipboard');\n }\n this.tooltip.setAttribute('content', this.label || 'Copy');\n }, this.timeout);\n };\n\n /**\n * Copies the specified text or node.\n * @param {HTMLElement} button The button element.\n */\n async copy(button) {\n const id = this.getAttribute('for');\n const text = this.getAttribute('value');\n\n if (button.getAttribute('aria-disabled') === 'true') {\n return;\n }\n\n if (text) {\n await copyText(text);\n event.dispatchCustomEvent(this, 'wje-copy-button:click');\n } else if (id) {\n const root = 'getRootNode' in Element.prototype ? button.getRootNode() : button.ownerDocument;\n if (!(root instanceof Document || ('ShadowRoot' in window && root instanceof ShadowRoot))) return;\n\n const node = root.getElementById(id);\n if (node) {\n await this.copyTarget(node);\n event.dispatchCustomEvent(this, 'wje-copy-button:click');\n }\n }\n }\n\n /**\n * Copies the target content.\n * @param {HTMLElement} content The content to be copied.\n * @returns {Promise} A promise that resolves when the content is copied.\n */\n copyTarget(content) {\n if (content instanceof HTMLInputElement || content instanceof HTMLTextAreaElement || content instanceof Input) {\n return copyText(content.value);\n } else if (content instanceof HTMLAnchorElement && content.hasAttribute('href')) {\n return copyText(content.href);\n } else {\n return copyNode(content);\n }\n }\n}\n","import CopyButton from './copy-button.element.js';\n\nexport default CopyButton;\n\nCopyButton.define('wje-copy-button', CopyButton);\n"],"names":[],"mappings":";;;;;AAKA,SAAS,WAAW,MAAM;AACtB,QAAM,OAAO,SAAS,cAAc,KAAK;AACzC,OAAK,MAAM,QAAQ;AACnB,OAAK,MAAM,SAAS;AACpB,OAAK,MAAM,WAAW;AACtB,OAAK,MAAM,MAAM;AACjB,OAAK,cAAc;AACnB,SAAO;AACX;AAOO,SAAS,SAAS,MAAM;AAC3B,MAAI,eAAe,WAAW;AAC1B,WAAO,UAAU,UAAU,UAAU,KAAK,eAAe,EAAE;AAAA,EACnE;AAEI,QAAM,YAAY;AA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;AAC7E,aAAO,SAAS,QAAQ,IAAI;AAAA,IACxC,OAAe;AACH,aAAO,SAAS,OAAO;AAAA,IACnC;AAAA,EACA;AACA;ACrNA,WAAW,OAAO,mBAAmB,UAAU;"}
1
+ {"version":3,"file":"wje-copy-button.js","sources":["../packages/wje-copy-button/service/service.js","../packages/wje-copy-button/copy-button.element.js","../packages/wje-copy-button/copy-button.js"],"sourcesContent":["/**\n * Create a node with the text content.\n * @param text\n * @returns {Element}\n */\nfunction createNode(text) {\n const node = document.createElement('pre');\n node.style.width = '1px';\n node.style.height = '1px';\n node.style.position = 'fixed';\n node.style.top = '5px';\n node.textContent = text;\n return node;\n}\n\n/**\n * Copy the node to the clipboard.\n * @param node\n * @returns {Promise<never>|Promise<void>}\n */\nexport function copyNode(node) {\n if ('clipboard' in navigator) {\n return navigator.clipboard.writeText(node.textContent || '');\n }\n\n const selection = getSelection(); // Firefox return null\n if (selection === null) {\n return Promise.reject(new Error());\n }\n\n selection.removeAllRanges();\n\n const range = document.createRange();\n range.selectNodeContents(node);\n selection.addRange(range);\n\n // document.execCommand(\"copy\")\n selection.removeAllRanges();\n return Promise.resolve();\n}\n\n/**\n * Copy the text to the clipboard.\n * @param text\n * @returns {Promise<never>|Promise<void>}\n */\nexport function copyText(text) {\n if ('clipboard' in navigator) {\n return navigator.clipboard.writeText(text);\n }\n\n const body = document.body;\n if (!body) {\n return Promise.reject(new Error());\n }\n\n const node = createNode(text);\n body.appendChild(node);\n copyNode(node);\n body.removeChild(node);\n return Promise.resolve();\n}\n","import { default as WJElement, event, WjElementUtils } from '../wje-element/element.js';\nimport Input from '../wje-input/input.js';\nimport { copyNode, copyText } from './service/service.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary CopyButton is a custom web component that extends WJElement.\n * It provides a button that, when clicked, copies a specified text to the clipboard.\n * The text to be copied can be specified through the `value` attribute.\n * The CopyButton also supports keyboard interaction, copying the text when the space or enter key is pressed.\n * @documentation https://elements.webjet.sk/components/copy-button\n * @status stable\n * @augments WJElement\n * @attribute {string} for - The id of the element to copy content from.\n * @attribute {string} value - The text to be copied.\n * @slot - This is a default/unnamed slot.\n * @csspart button - Styles the button element.\n * @cssproperty --text-color - Controls the color of the text.\n * @cssproperty --background-color - Controls the background color of the button.\n * //@fires wje:copy-button - Dispatched when the button is clicked and the text is copied.\n * @tag wje-copy-button\n */\nexport default class CopyButton extends WJElement {\n /**\n * Constructor for the CopyButton class.\n * Initializes the timeout property.\n */\n constructor() {\n super();\n\n this.timeout = 1000;\n }\n\n /**\n * Setter for the value property.\n * @param {string} value The value to be set.\n */\n set value(value) {\n this.setAttribute('value', value);\n }\n\n /**\n * Getter for the value property.\n * @returns {string} The value of the value property.\n */\n get value() {\n return this.getAttribute('value') || '';\n }\n\n className = 'CopyButton';\n\n /**\n * Getter for the cssStyleSheet property.\n * @returns {string} The CSS styles.\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Getter for the observedAttributes property.\n * @returns {Array} An empty array.\n */\n static get observedAttributes() {\n return [];\n }\n\n /**\n * Sets up the attributes for the CopyButton.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Draws the ColorPicker element.\n * @returns {DocumentFragment} The created document fragment.\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let tooltip = document.createElement('wje-tooltip');\n tooltip.setAttribute('offset', '5');\n tooltip.setAttribute('content', this.label || 'Copy');\n\n if (WjElementUtils.hasSlot(this)) {\n let slot = document.createElement('slot');\n tooltip.appendChild(slot);\n } else {\n let icon = document.createElement('wje-icon');\n icon.setAttribute('name', 'clipboard');\n\n tooltip.appendChild(icon);\n this.icon = icon;\n }\n\n fragment.appendChild(tooltip);\n\n this.tooltip = tooltip;\n\n return fragment;\n }\n\n /**\n * Adds event listeners for the click, focus, and blur events.\n */\n afterDraw() {\n event.addListener(this, 'click', null, this.clicked);\n event.addListener(this, 'focus', null, this.focused);\n event.addListener(this, 'blur', null, this.blurred);\n\n event.addListener(this, 'wje-copy-button:click', null, this.copied);\n }\n\n /**\n * Handles the click event.\n * @param {Event} e The event object.\n */\n clicked = (e) => {\n const button = e.currentTarget;\n if (button instanceof HTMLElement) {\n this.copy(button);\n }\n };\n\n /**\n * Handles the keydown event.\n * @param {Event} e The event object.\n */\n keydown = (e) => {\n if (e.key === ' ' || e.key === 'Enter') {\n const button = e.currentTarget;\n if (button instanceof HTMLElement) {\n this.copy(button);\n }\n }\n };\n\n /**\n * Handles the focus event.\n * @param {Event} e The event object.\n */\n focused = (e) => {\n e.currentTarget.addEventListener('keydown', this.keydown);\n };\n\n /**\n * Handles the blur event.\n * @param {Event} e The event object.\n */\n blurred = (e) => {\n e.currentTarget.removeEventListener('keydown', this.keydown);\n };\n\n /**\n * Handles the copied event.\n * You can override this method to customize the behavior when the text is copied.\n * @param {Event} e The event object.\n */\n copied = (e) => {\n if (this.hasOwnProperty('icon')) {\n this.icon.setAttribute('color', 'success');\n this.icon.setAttribute('name', 'check');\n }\n this.tooltip.setAttribute('content', this.labelSuccess || 'Copied');\n\n setTimeout(() => {\n if (this.hasOwnProperty('icon')) {\n this.icon.removeAttribute('color');\n this.icon.setAttribute('name', 'clipboard');\n }\n this.tooltip.setAttribute('content', this.label || 'Copy');\n }, this.timeout);\n };\n\n /**\n * Copies the specified text or node.\n * @param {HTMLElement} button The button element.\n */\n async copy(button) {\n const id = this.getAttribute('for');\n const text = this.getAttribute('value');\n\n if (button.getAttribute('aria-disabled') === 'true') {\n return;\n }\n\n if (text) {\n await copyText(text);\n event.dispatchCustomEvent(this, 'wje-copy-button:click');\n } else if (id) {\n const root = 'getRootNode' in Element.prototype ? button.getRootNode() : button.ownerDocument;\n if (!(root instanceof Document || ('ShadowRoot' in window && root instanceof ShadowRoot))) return;\n\n const node = root.getElementById(id);\n if (node) {\n await this.copyTarget(node);\n event.dispatchCustomEvent(this, 'wje-copy-button:click');\n }\n }\n }\n\n /**\n * Copies the target content.\n * @param {HTMLElement} content The content to be copied.\n * @returns {Promise} A promise that resolves when the content is copied.\n */\n copyTarget(content) {\n if (content instanceof HTMLInputElement || content instanceof HTMLTextAreaElement || content instanceof Input) {\n return copyText(content.value);\n } else if (content instanceof HTMLAnchorElement && content.hasAttribute('href')) {\n return copyText(content.href);\n } else {\n return copyNode(content);\n }\n }\n}\n","import CopyButton from './copy-button.element.js';\n\nexport default CopyButton;\n\nCopyButton.define('wje-copy-button', CopyButton);\n"],"names":[],"mappings":";;;;;AAKA,SAAS,WAAW,MAAM;AACtB,QAAM,OAAO,SAAS,cAAc,KAAK;AACzC,OAAK,MAAM,QAAQ;AACnB,OAAK,MAAM,SAAS;AACpB,OAAK,MAAM,WAAW;AACtB,OAAK,MAAM,MAAM;AACjB,OAAK,cAAc;AACnB,SAAO;AACX;AAOO,SAAS,SAAS,MAAM;AAC3B,MAAI,eAAe,WAAW;AAC1B,WAAO,UAAU,UAAU,UAAU,KAAK,eAAe,EAAE;AAAA,EACnE;AAEI,QAAM,YAAY;AAClB,MAAI,cAAc,MAAM;AACpB,WAAO,QAAQ,OAAO,IAAI,OAAO;AAAA,EACzC;AAEI,YAAU,gBAAiB;AAE3B,QAAM,QAAQ,SAAS,YAAa;AACpC,QAAM,mBAAmB,IAAI;AAC7B,YAAU,SAAS,KAAK;AAGxB,YAAU,gBAAiB;AAC3B,SAAO,QAAQ,QAAS;AAC5B;AAOO,SAAS,SAAS,MAAM;AAC3B,MAAI,eAAe,WAAW;AAC1B,WAAO,UAAU,UAAU,UAAU,IAAI;AAAA,EACjD;AAEI,QAAM,OAAO,SAAS;AACtB,MAAI,CAAC,MAAM;AACP,WAAO,QAAQ,OAAO,IAAI,OAAO;AAAA,EACzC;AAEI,QAAM,OAAO,WAAW,IAAI;AAC5B,OAAK,YAAY,IAAI;AACrB,WAAS,IAAI;AACb,OAAK,YAAY,IAAI;AACrB,SAAO,QAAQ,QAAS;AAC5B;;ACvCe,MAAM,mBAAmB,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA,EAK9C,cAAc;AACV,UAAO;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ACnB,YAAM,oBAAoB,MAAM,uBAAuB;AAAA,IAC1D,WAAU,IAAI;AACX,YAAM,OAAO,iBAAiB,QAAQ,YAAY,OAAO,YAAW,IAAK,OAAO;AAChF,UAAI,EAAE,gBAAgB,YAAa,gBAAgB,UAAU,gBAAgB,YAAc;AAE3F,YAAM,OAAO,KAAK,eAAe,EAAE;AACnC,UAAI,MAAM;AACN,cAAM,KAAK,WAAW,IAAI;AAC1B,cAAM,oBAAoB,MAAM,uBAAuB;AAAA,MACvE;AAAA,IACA;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOI,WAAW,SAAS;AAChB,QAAI,mBAAmB,oBAAoB,mBAAmB,uBAAuB,mBAAmB,OAAO;AAC3G,aAAO,SAAS,QAAQ,KAAK;AAAA,IACzC,WAAmB,mBAAmB,qBAAqB,QAAQ,aAAa,MAAM,GAAG;AAC7E,aAAO,SAAS,QAAQ,IAAI;AAAA,IACxC,OAAe;AACH,aAAO,SAAS,OAAO;AAAA,IACnC;AAAA,EACA;AACA;ACpNA,WAAW,OAAO,mBAAmB,UAAU;"}
@@ -43,6 +43,21 @@ class Dialog extends WJElement {
43
43
  });
44
44
  });
45
45
  }
46
+ /**
47
+ * Sets the value of the 'headline' attribute.
48
+ * @param {string} value The new value for the 'headline' attribute.
49
+ */
50
+ set headline(value) {
51
+ this.setAttribute("headline", value);
52
+ }
53
+ /**
54
+ * Retrieves the value of the "headline" attribute from the element.
55
+ * If the "headline" attribute is not present, returns an empty string.
56
+ * @returns {string} The headline attribute value or an empty string if not set.
57
+ */
58
+ get headline() {
59
+ return this.getAttribute("headline") || "";
60
+ }
46
61
  /**
47
62
  * Sets the headline of the dialog.
48
63
  * @param value
@@ -141,7 +156,7 @@ class Dialog extends WJElement {
141
156
  header.setAttribute("part", "header");
142
157
  header.classList.add("dialog-header");
143
158
  if (this.hasAttribute("headline"))
144
- header.innerHTML = `<span part="headline">${this.getAttribute("headline")}</span>`;
159
+ header.innerHTML = `<span part="headline">${this.headline}</span>`;
145
160
  let slotHeader = document.createElement("slot");
146
161
  slotHeader.setAttribute("name", "header");
147
162
  const headerActions = document.createElement("div");
@@ -221,7 +236,6 @@ class Dialog extends WJElement {
221
236
  */
222
237
  registerBlockingEvent(button, promise) {
223
238
  button.addEventListener("wje-button:click", async (e) => {
224
- console.log("Button clicked");
225
239
  let blockingElement = document.createElement("div");
226
240
  blockingElement.classList.add("blocking-element");
227
241
  let icon = document.createElement("wje-icon");
@@ -1 +1 @@
1
- {"version":3,"file":"wje-dialog.js","sources":["../packages/wje-dialog/dialog.element.js","../packages/wje-dialog/dialog.js"],"sourcesContent":["import { default as WJElement, event } from '../wje-element/element.js';\nimport '../wje-button/button.element.js';\nimport '../wje-icon/icon.element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * `Dialog` is a custom web component that represents a dialog.\n * @summary This element represents a dialog.\n * @documentation https://elements.webjet.sk/components/dialog\n * @status stable\n * @augments {WJElement}\n * @slot header - Slot for the header content.\n * @slot body - Slot for the body content.\n * @slot footer - Slot for the footer content.\n * @csspart dialog - The dialog wrapper.\n * @csspart header - The header of the dialog.\n * @csspart body - The body of the dialog.\n * @csspart footer - The footer of the dialog.\n * @csspart close - The close button of the dialog.\n * @cssproperty [--wje-dialog-background=var(--wje-background-color)] - Specifies the background color of the dialog.\n * @cssproperty [--wje-dialog-color=var(--wje-text-color)] - Defines the text color within the dialog.\n * @cssproperty [--wje-dialog-padding=1rem] - Controls the padding inside the dialog.\n * @cssproperty [--wje-dialog-border-radius=0.5rem] - Sets the border radius for the dialog's corners.\n * @cssproperty [--wje-dialog-box-shadow=0 2px 10px rgba(0, 0, 0, 0.1)] - Applies a shadow effect to the dialog.\n * @tag wje-dialog\n */\n\nexport default class Dialog extends WJElement {\n /**\n * @class\n */\n constructor() {\n super();\n }\n\n /**\n * Sets the headline of the dialog.\n * @param value\n */\n set placement(value) {\n this.setAttribute('placement', value);\n }\n\n /**\n * Gets the headline of the dialog.\n * @returns {string|string}\n */\n get placement() {\n return this.getAttribute('placement') || 'slide-up';\n }\n\n /**\n * Sets the headline of the dialog.\n * @param value\n */\n set async(value) {\n this.setAttribute('async', '');\n }\n\n /**\n * Gets the headline of the dialog.\n * @returns {boolean}\n */\n get async() {\n return this.hasAttribute('async');\n }\n\n /**\n * Sets the headline of the dialog.\n * @param value\n */\n set closeHidden(value) {\n if (value) this.setAttribute('close-hidden', '');\n }\n\n /**\n * Gets the headline of the dialog.\n * @returns {boolean}\n */\n get closeHidden() {\n return !!this.hasAttribute('close-hidden');\n }\n\n /**\n * Sets the headline of the dialog.\n * @type {string}\n */\n className = 'Dialog';\n\n /**\n * Returns the CSS styles for the component.\n * @returns {*}\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Returns the list of attributes to observe for changes.\n * @returns {*[]}\n */\n static get observedAttributes() {\n return [];\n }\n\n /**\n * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Draws the component.\n * @param {object} context The context for drawing.\n * @param {object} store The store for drawing.\n * @param {object} params The parameters for drawing.\n * @returns {DocumentFragment}\n */\n draw(context, store, params) {\n let fragment = document.createDocumentFragment();\n\n this.classList.add('fade', this.placement, params.size);\n\n let dialog = document.createElement('dialog');\n dialog.classList.add('modal-dialog');\n\n fragment.appendChild(dialog);\n\n this.dialog = dialog;\n return fragment;\n }\n\n /**\n * Creates the dialog body.\n * @param dialog\n */\n htmlDialogBody(dialog) {\n let icon = document.createElement('wje-icon');\n icon.setAttribute('name', 'x');\n icon.setAttribute('slot', 'icon-only');\n\n let close = document.createElement('wje-button');\n close.setAttribute('fill', 'link');\n close.setAttribute('size', 'small');\n close.setAttribute('part', 'close');\n close.addEventListener('click', (e) => {\n this.close(e);\n });\n close.appendChild(icon);\n\n let header = document.createElement('div');\n header.setAttribute('part', 'header');\n header.classList.add('dialog-header');\n if (this.hasAttribute('headline'))\n header.innerHTML = `<span part=\"headline\">${this.getAttribute('headline')}</span>`;\n\n let slotHeader = document.createElement('slot');\n slotHeader.setAttribute('name', 'header');\n\n const headerActions = document.createElement('div');\n headerActions.classList.add('header-actions');\n headerActions.setAttribute('part', 'header-actions');\n headerActions.appendChild(slotHeader);\n\n header.appendChild(headerActions);\n if (!this.closeHidden) header.appendChild(close);\n\n let contentSlot = document.createElement('slot');\n\n let body = document.createElement('div');\n body.setAttribute('part', 'body');\n body.classList.add('dialog-content');\n body.appendChild(contentSlot);\n\n let footer = document.createElement('div');\n footer.setAttribute('part', 'footer');\n footer.classList.add('dialog-footer');\n footer.innerHTML = '';\n\n let slotFooter = document.createElement('slot');\n slotFooter.setAttribute('name', 'footer');\n\n footer.appendChild(slotFooter);\n\n dialog.appendChild(header);\n dialog.appendChild(body);\n dialog.appendChild(footer);\n }\n\n /**\n * Closes the dialog.\n * @param e\n */\n close(e) {\n this.onClose(e);\n }\n\n /**\n * Draws the component after it has been drawn.\n * @param {object} context The context for drawing.\n * @param {object} store The store for drawing.\n * @param {object} params The parameters for drawing.\n */\n afterDraw(context, store, params) {\n if (params.trigger) {\n event.addListener(document, params.trigger, null, this.onOpen);\n }\n\n //this.dialog.addEventListener('close', this.onClose);\n }\n\n /**\n * Before the component is disconnected.\n */\n beforeDisconnect() {\n if (this.params?.trigger) {\n event.removeListener(document, this.params?.trigger, null, this.onOpen);\n }\n\n //this.dialog.removeEventListener('close', this.onClose);\n }\n\n /**\n * Before the dialog opens.\n */\n beforeOpen() {\n // Hook for extending behavior before the dialog opens\n }\n\n /**\n * After the dialog opens.\n */\n afterOpen() {\n // Hook for extending behavior after the dialog opens\n }\n\n /**\n * Before the dialog closes.\n */\n beforeClose() {\n // Hook for extending behavior before the dialog closes\n }\n\n /**\n * After the dialog closes.\n */\n afterClose() {\n // Hook for extending behavior after the dialog closes\n }\n\n /**\n * Opens the dialog.\n * @param e\n */\n onOpen = (e) => {\n if (this.dialog) {\n this.dialog.innerHTML = '';\n }\n\n Promise.resolve(this.beforeOpen(this, e)).then((res) => {\n this.htmlDialogBody(this.dialog);\n\n this.dialog.showModal(); // Now open the dialog\n\n if (this.dialog.open) {\n Promise.resolve(this.afterOpen(this, e));\n }\n });\n }\n\n /**\n * Closes the dialog.\n * @param {object} e\n */\n onClose = (e) => {\n Promise.resolve(this.beforeClose(this, e)).then((res) => {\n this.dialog.close(); // Now close the dialog\n\n if (!this.dialog.open) {\n Promise.resolve(this.afterClose(this, e));\n }\n });\n };\n\n /**\n * Registers an event listener on the provided button that triggers a blocking UI element\n * and executes a given promise when the button is clicked.\n * @param {HTMLElement} button The button element to attach the event listener to.\n * @param {Function} promise A function that returns a promise to be executed when the button is clicked.\n */\n registerBlockingEvent(button, promise) {\n button.addEventListener('wje-button:click', async (e) => {\n console.log('Button clicked');\n\n let blockingElement = document.createElement('div');\n blockingElement.classList.add('blocking-element');\n\n let icon = document.createElement('wje-icon');\n icon.setAttribute('name', 'loader-2');\n icon.setAttribute('size', '2x-large');\n\n blockingElement.appendChild(icon);\n\n let scrollOffset = this.dialog.scrollTop;\n blockingElement.style.top = `${scrollOffset}px`;\n blockingElement.style.bottom = `-${scrollOffset}px`;\n\n this.dialog.appendChild(blockingElement);\n\n await promise()\n .then((res) => {\n this.close();\n blockingElement.remove();\n })\n .catch((err) => {\n console.error(err);\n blockingElement.remove();\n });\n });\n }\n}\n","import Dialog from './dialog.element.js';\n\nexport default Dialog;\n\nDialog.define('wje-dialog', Dialog);\n"],"names":[],"mappings":";;;;;AA2Be,MAAM,eAAe,UAAU;AAAA;AAAA;AAAA;AAAA,EAI1C,cAAc;AACV,UAAO;AAuDX;AAAA;AAAA;AAAA;AAAA,qCAAY;AAwKZ;AAAA;AAAA;AAAA;AAAA,kCAAS,CAAC,MAAM;AACZ,UAAI,KAAK,QAAQ;AACb,aAAK,OAAO,YAAY;AAAA,MACpC;AAEQ,cAAQ,QAAQ,KAAK,WAAW,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,QAAQ;AACpD,aAAK,eAAe,KAAK,MAAM;AAE/B,aAAK,OAA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S,cAAc,UAAU;AAC5C,WAAK,aAAa,QAAQ,UAAU;AACpC,WAAK,aAAa,QAAQ,UAAU;AAEpC,sBAAgB,YAAY,IAAI;AAEhC,UAAI,eAAe,KAAK,OAAO;AAC/B,sBAAgB,MAAM,MAAM,GAAG,YAAY;AAC3C,sBAAgB,MAAM,SAAS,IAAI,YAAY;AAE/C,WAAK,OAAO,YAAY,eAAe;AAEvC,YAAM,QAAO,EACR,KAAK,CAAC,QAAQ;AACX,aAAK,MAAO;AACZ,wBAAgB,OAAQ;AAAA,MAC3B,CAAA,EACA,MAAM,CAAC,QAAQ;AACZ,gBAAQ,MAAM,GAAG;AACjB,wBAAgB,OAAQ;AAAA,MAC5C,CAAiB;AAAA,IACjB,CAAS;AAAA,EACT;AACA;AC7TA,OAAO,OAAO,cAAc,MAAM;"}
1
+ {"version":3,"file":"wje-dialog.js","sources":["../packages/wje-dialog/dialog.element.js","../packages/wje-dialog/dialog.js"],"sourcesContent":["import { default as WJElement, event } from '../wje-element/element.js';\nimport '../wje-button/button.element.js';\nimport '../wje-icon/icon.element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * `Dialog` is a custom web component that represents a dialog.\n * @summary This element represents a dialog.\n * @documentation https://elements.webjet.sk/components/dialog\n * @status stable\n * @augments {WJElement}\n * @slot header - Slot for the header content.\n * @slot body - Slot for the body content.\n * @slot footer - Slot for the footer content.\n * @csspart dialog - The dialog wrapper.\n * @csspart header - The header of the dialog.\n * @csspart body - The body of the dialog.\n * @csspart footer - The footer of the dialog.\n * @csspart close - The close button of the dialog.\n * @cssproperty [--wje-dialog-background=var(--wje-background-color)] - Specifies the background color of the dialog.\n * @cssproperty [--wje-dialog-color=var(--wje-text-color)] - Defines the text color within the dialog.\n * @cssproperty [--wje-dialog-padding=1rem] - Controls the padding inside the dialog.\n * @cssproperty [--wje-dialog-border-radius=0.5rem] - Sets the border radius for the dialog's corners.\n * @cssproperty [--wje-dialog-box-shadow=0 2px 10px rgba(0, 0, 0, 0.1)] - Applies a shadow effect to the dialog.\n * @tag wje-dialog\n */\n\nexport default class Dialog extends WJElement {\n /**\n * @class\n */\n constructor() {\n super();\n }\n\n /**\n * Sets the value of the 'headline' attribute.\n * @param {string} value The new value for the 'headline' attribute.\n */\n set headline(value) {\n this.setAttribute('headline', value);\n }\n\n /**\n * Retrieves the value of the \"headline\" attribute from the element.\n * If the \"headline\" attribute is not present, returns an empty string.\n * @returns {string} The headline attribute value or an empty string if not set.\n */\n get headline() {\n return this.getAttribute('headline') || '';\n }\n\n /**\n * Sets the headline of the dialog.\n * @param value\n */\n set placement(value) {\n this.setAttribute('placement', value);\n }\n\n /**\n * Gets the headline of the dialog.\n * @returns {string|string}\n */\n get placement() {\n return this.getAttribute('placement') || 'slide-up';\n }\n\n /**\n * Sets the headline of the dialog.\n * @param value\n */\n set async(value) {\n this.setAttribute('async', '');\n }\n\n /**\n * Gets the headline of the dialog.\n * @returns {boolean}\n */\n get async() {\n return this.hasAttribute('async');\n }\n\n /**\n * Sets the headline of the dialog.\n * @param value\n */\n set closeHidden(value) {\n if (value) this.setAttribute('close-hidden', '');\n }\n\n /**\n * Gets the headline of the dialog.\n * @returns {boolean}\n */\n get closeHidden() {\n return !!this.hasAttribute('close-hidden');\n }\n\n /**\n * Sets the headline of the dialog.\n * @type {string}\n */\n className = 'Dialog';\n\n /**\n * Returns the CSS styles for the component.\n * @returns {*}\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Returns the list of attributes to observe for changes.\n * @returns {*[]}\n */\n static get observedAttributes() {\n return [];\n }\n\n /**\n * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Draws the component.\n * @param {object} context The context for drawing.\n * @param {object} store The store for drawing.\n * @param {object} params The parameters for drawing.\n * @returns {DocumentFragment}\n */\n draw(context, store, params) {\n let fragment = document.createDocumentFragment();\n\n this.classList.add('fade', this.placement, params.size);\n\n let dialog = document.createElement('dialog');\n dialog.classList.add('modal-dialog');\n\n fragment.appendChild(dialog);\n\n this.dialog = dialog;\n return fragment;\n }\n\n /**\n * Creates the dialog body.\n * @param dialog\n */\n htmlDialogBody(dialog) {\n let icon = document.createElement('wje-icon');\n icon.setAttribute('name', 'x');\n icon.setAttribute('slot', 'icon-only');\n\n let close = document.createElement('wje-button');\n close.setAttribute('fill', 'link');\n close.setAttribute('size', 'small');\n close.setAttribute('part', 'close');\n close.addEventListener('click', (e) => {\n this.close(e);\n });\n close.appendChild(icon);\n\n let header = document.createElement('div');\n header.setAttribute('part', 'header');\n header.classList.add('dialog-header');\n if (this.hasAttribute('headline'))\n header.innerHTML = `<span part=\"headline\">${this.headline}</span>`;\n\n let slotHeader = document.createElement('slot');\n slotHeader.setAttribute('name', 'header');\n\n const headerActions = document.createElement('div');\n headerActions.classList.add('header-actions');\n headerActions.setAttribute('part', 'header-actions');\n headerActions.appendChild(slotHeader);\n\n header.appendChild(headerActions);\n if (!this.closeHidden) header.appendChild(close);\n\n let contentSlot = document.createElement('slot');\n\n let body = document.createElement('div');\n body.setAttribute('part', 'body');\n body.classList.add('dialog-content');\n body.appendChild(contentSlot);\n\n let footer = document.createElement('div');\n footer.setAttribute('part', 'footer');\n footer.classList.add('dialog-footer');\n footer.innerHTML = '';\n\n let slotFooter = document.createElement('slot');\n slotFooter.setAttribute('name', 'footer');\n\n footer.appendChild(slotFooter);\n\n dialog.appendChild(header);\n dialog.appendChild(body);\n dialog.appendChild(footer);\n }\n\n /**\n * Closes the dialog.\n * @param e\n */\n close(e) {\n this.onClose(e);\n }\n\n /**\n * Draws the component after it has been drawn.\n * @param {object} context The context for drawing.\n * @param {object} store The store for drawing.\n * @param {object} params The parameters for drawing.\n */\n afterDraw(context, store, params) {\n if (params.trigger) {\n event.addListener(document, params.trigger, null, this.onOpen);\n }\n\n //this.dialog.addEventListener('close', this.onClose);\n }\n\n /**\n * Before the component is disconnected.\n */\n beforeDisconnect() {\n if (this.params?.trigger) {\n event.removeListener(document, this.params?.trigger, null, this.onOpen);\n }\n\n //this.dialog.removeEventListener('close', this.onClose);\n }\n\n /**\n * Before the dialog opens.\n */\n beforeOpen() {\n // Hook for extending behavior before the dialog opens\n }\n\n /**\n * After the dialog opens.\n */\n afterOpen() {\n // Hook for extending behavior after the dialog opens\n }\n\n /**\n * Before the dialog closes.\n */\n beforeClose() {\n // Hook for extending behavior before the dialog closes\n }\n\n /**\n * After the dialog closes.\n */\n afterClose() {\n // Hook for extending behavior after the dialog closes\n }\n\n /**\n * Opens the dialog.\n * @param e\n */\n onOpen = (e) => {\n if (this.dialog) {\n this.dialog.innerHTML = '';\n }\n\n Promise.resolve(this.beforeOpen(this, e)).then((res) => {\n this.htmlDialogBody(this.dialog);\n\n this.dialog.showModal(); // Now open the dialog\n\n if (this.dialog.open) {\n Promise.resolve(this.afterOpen(this, e));\n }\n });\n }\n\n /**\n * Closes the dialog.\n * @param {object} e\n */\n onClose = (e) => {\n Promise.resolve(this.beforeClose(this, e)).then((res) => {\n this.dialog.close(); // Now close the dialog\n\n if (!this.dialog.open) {\n Promise.resolve(this.afterClose(this, e));\n }\n });\n };\n\n /**\n * Registers an event listener on the provided button that triggers a blocking UI element\n * and executes a given promise when the button is clicked.\n * @param {HTMLElement} button The button element to attach the event listener to.\n * @param {Function} promise A function that returns a promise to be executed when the button is clicked.\n */\n registerBlockingEvent(button, promise) {\n button.addEventListener('wje-button:click', async (e) => {\n let blockingElement = document.createElement('div');\n blockingElement.classList.add('blocking-element');\n\n let icon = document.createElement('wje-icon');\n icon.setAttribute('name', 'loader-2');\n icon.setAttribute('size', '2x-large');\n\n blockingElement.appendChild(icon);\n\n let scrollOffset = this.dialog.scrollTop;\n blockingElement.style.top = `${scrollOffset}px`;\n blockingElement.style.bottom = `-${scrollOffset}px`;\n\n this.dialog.appendChild(blockingElement);\n\n await promise()\n .then((res) => {\n this.close();\n blockingElement.remove();\n })\n .catch((err) => {\n console.error(err);\n blockingElement.remove();\n });\n });\n }\n}\n","import Dialog from './dialog.element.js';\n\nexport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