wj-elements 0.1.160 → 0.1.162

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 (41) 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-accordion/accordion.test.d.ts +0 -0
  5. package/dist/packages/wje-color-picker/color-picker.test.d.ts +1 -0
  6. package/dist/packages/wje-dialog/dialog.element.d.ts +11 -0
  7. package/dist/packages/wje-element/element.d.ts +1 -1
  8. package/dist/packages/wje-element/service/universal-service.d.ts +6 -6
  9. package/dist/packages/wje-options/options.element.d.ts +38 -5
  10. package/dist/packages/wje-select/select.element.d.ts +81 -12
  11. package/dist/packages/wje-stepper/stepper.element.d.ts +1 -0
  12. package/dist/packages/wje-store/pubsub.d.ts +5 -4
  13. package/dist/packages/wje-tab/tab.element.d.ts +23 -0
  14. package/dist/packages/wje-tab-group/tab-group.element.d.ts +5 -0
  15. package/dist/wje-breadcrumb.js +0 -2
  16. package/dist/wje-breadcrumb.js.map +1 -1
  17. package/dist/wje-copy-button.js +0 -1
  18. package/dist/wje-copy-button.js.map +1 -1
  19. package/dist/wje-dialog.js +19 -3
  20. package/dist/wje-dialog.js.map +1 -1
  21. package/dist/wje-element.js +17 -28
  22. package/dist/wje-element.js.map +1 -1
  23. package/dist/wje-icon-picker.js +1 -1
  24. package/dist/wje-infinite-scroll.js +1 -1
  25. package/dist/wje-master.js +1 -1
  26. package/dist/wje-options.js +48 -16
  27. package/dist/wje-options.js.map +1 -1
  28. package/dist/wje-select.js +32 -3
  29. package/dist/wje-select.js.map +1 -1
  30. package/dist/wje-split-view.js +0 -10
  31. package/dist/wje-split-view.js.map +1 -1
  32. package/dist/wje-stepper.js +52 -36
  33. package/dist/wje-stepper.js.map +1 -1
  34. package/dist/wje-store.js +7 -6
  35. package/dist/wje-store.js.map +1 -1
  36. package/dist/wje-tab-group.js +71 -12
  37. package/dist/wje-tab-group.js.map +1 -1
  38. package/dist/wje-tab-panel.js +1 -1
  39. package/dist/wje-tab.js +146 -1
  40. package/dist/wje-tab.js.map +1 -1
  41. package/package.json +1 -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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AE5D,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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AAK,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;"}
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(): this | ShadowRoot;
100
+ get context(): any;
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;
@@ -95,9 +100,33 @@ export default class Options extends WJElement {
95
100
  * @returns {boolean} True if the search attribute is present, false otherwise.
96
101
  */
97
102
  get hasSearch(): boolean;
103
+ /**
104
+ * Sets the value to define search-to-query params behavior.
105
+ * @param {string} value The value to be set for the search-to-query-params attribute.
106
+ */
98
107
  set searchToQueryParams(value: string);
99
- get searchToQueryParams(): string;
108
+ /**
109
+ * Retrieves the value of the 'search-to-query-params' attribute from the current instance.
110
+ * @returns {string | null} The value of the 'search-to-query-params' attribute, or null if the attribute is not set.
111
+ */
112
+ get searchToQueryParams(): string | null;
113
+ /**
114
+ * Determines whether the 'search-to-query-params' attribute is present on the element.
115
+ * @returns {boolean} True if the 'search-to-query-params' attribute exists, otherwise false.
116
+ */
100
117
  get hasSearchToQueryParams(): boolean;
118
+ /**
119
+ * Sets the value of the search parameter name attribute.
120
+ * @param {string} value The string value to set as the search parameter name.
121
+ */
122
+ set searchParamName(value: string);
123
+ /**
124
+ * Gets the search parameter name used in queries.
125
+ * Retrieves the value of the 'search-param-name' attribute.
126
+ * If the attribute is not set, it defaults to 'search'.
127
+ * @returns {string} The search parameter name used for queries.
128
+ */
129
+ get searchParamName(): string;
101
130
  /**
102
131
  * Sets the lazy attribute.
103
132
  * @param {boolean} value The value to set for the lazy attribute.
@@ -113,12 +142,16 @@ export default class Options extends WJElement {
113
142
  * @returns {Array} The loaded options.
114
143
  */
115
144
  get options(): any[];
145
+ /**
146
+ * Sets the loaded options.
147
+ * @type {Array}
148
+ */
116
149
  set loadedOptions(loadedOptions: any[]);
117
- get loadedOptions(): any[];
118
150
  /**
119
- * Lifecycle method, called whenever an observed property changes.
151
+ * Gets the loaded options.
152
+ * @type {Array}
120
153
  */
121
- attributeChangedCallback(name: any, oldValue: any, newValue: any): void;
154
+ get loadedOptions(): any[];
122
155
  /**
123
156
  * Prepares the component before drawing.
124
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
  */
@@ -30,6 +30,7 @@ export default class Stepper extends WJElement {
30
30
  headerSteps: NodeListOf<Element>;
31
31
  prev: HTMLElement;
32
32
  next: HTMLElement;
33
+ processStep(index: any, step: any, header: any, steps: any): void;
33
34
  /**
34
35
  * Sets up the attributes for the component.
35
36
  */
@@ -12,10 +12,11 @@ export default class PubSub {
12
12
  /**
13
13
  * If the passed event has callbacks attached to it, loop through each one and call it.
14
14
  * @param {string} event The name of the event to publish
15
- * @param {object} [newData] The data to pass to the callbacks
16
- * @param {object} [oldData] The data to pass to the callbacks
17
- * @returns {Array} The callbacks for this event, or an empty array if no event exits
15
+ * @param {any} state The current state to pass to the callbacks
16
+ * @param {object} [newData] The new data to pass to the callbacks
17
+ * @param {object} [oldData] The old data to pass to the callbacks
18
+ * @returns {Array} The results of the callbacks for this event, or an empty array if no event exists
18
19
  * @memberof PubSub
19
20
  */
20
- publish(event: string, newData?: object, oldData?: object): any[];
21
+ publish(event: string, state: any, newData?: object, oldData?: object): any[];
21
22
  }
@@ -28,6 +28,28 @@ export default class Tab extends WJElement {
28
28
  * @type {boolean}
29
29
  */
30
30
  last: boolean;
31
+ _hasPanel: boolean;
32
+ /**
33
+ * Sets the panel attribute to the specified value.
34
+ * @param {string} value The value to set for the panel attribute.
35
+ */
36
+ set panel(value: string);
37
+ /**
38
+ * Retrieves the value of the 'panel' attribute of the element.
39
+ * @returns {string|null} Returns the 'panel' attribute value if it exists; otherwise, returns null.
40
+ */
41
+ get panel(): string | null;
42
+ /**
43
+ * Sets the value of the 'route' attribute for the current object.
44
+ * @param {string} value The new value to set for the 'route' attribute.
45
+ */
46
+ set route(value: string);
47
+ /**
48
+ * Retrieves the value of the 'route' attribute.
49
+ * If the 'route' attribute is not set, it returns null.
50
+ * @returns {string|null} The value of the 'route' attribute or null if not set.
51
+ */
52
+ get route(): string | null;
31
53
  /**
32
54
  * Draws the component for the tab.
33
55
  * @returns {DocumentFragment}
@@ -38,4 +60,5 @@ export default class Tab extends WJElement {
38
60
  * // @fires wje-tab:change - Dispatched when the component is clicked, indicating a tab change.
39
61
  */
40
62
  afterDraw(): void;
63
+ unbindRouterLinks: any;
41
64
  }
@@ -31,10 +31,13 @@ export default class TabGroup extends WJElement {
31
31
  * @returns {DocumentFragment}
32
32
  */
33
33
  draw(context: object, store: object, params: object): DocumentFragment;
34
+ nav: HTMLElement;
35
+ moreDropdown: HTMLElement;
34
36
  /**
35
37
  * Sets up the event listeners after the component is drawn.
36
38
  */
37
39
  afterDraw(): void;
40
+ checkOverflow(): void;
38
41
  /**
39
42
  * Removes the active attribute from all tabs and panels.
40
43
  */
@@ -64,4 +67,6 @@ export default class TabGroup extends WJElement {
64
67
  * @returns {Array<string>} An array of all tab names.
65
68
  */
66
69
  getPanelAllName(): Array<string>;
70
+ toggleMoreVisibility(): void;
71
+ dropdownActive(el: any): void;
67
72
  }
@@ -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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AAA,EACf;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,mBAAmB;AACf,QAAI,WAAW,SAAS,cAAc,cAAc;AACpD,aAAS,aAAa,aAAa,QAAQ;AAC3C,aAAS,aAAa,UAAU,IAAI;AAEpC,QAAI,SAAS,SAAS,cAAc,YAAY;AAChD,WAAO,aAAa,QAAQ,SAAS;AACrC,WAAO,aAAa,QAAQ,MAAM;AAClC,WAAO,YAAY;AAEnB,QAAI,OAAO,SAAS,cAAc,UAAU;AAC5C,SAAK,aAAa,WAAW,SAAS;AAEtC,aAAS,YAAY,MAAM;AAC3B,aAAS,YAAY,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;AAA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AAS,cAAc,cAAc;AACpD,aAAS,aAAa,aAAa,QAAQ;AAC3C,aAAS,aAAa,UAAU,IAAI;AAEpC,QAAI,SAAS,SAAS,cAAc,YAAY;AAChD,WAAO,aAAa,QAAQ,SAAS;AACrC,WAAO,aAAa,QAAQ,MAAM;AAClC,WAAO,YAAY;AAEnB,QAAI,OAAO,SAAS,cAAc,UAAU;AAC5C,SAAK,aAAa,WAAW,SAAS;AAEtC,aAAS,YAAY,MAAM;AAC3B,aAAS,YAAY,IAAI;AAEzB,aAAS,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASrB,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 Copy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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;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;A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