wj-elements 0.2.0-alpha.9 → 0.3.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dark.css +15 -1
- package/dist/{form-associated-element-o0UjvdUp.js → form-associated-element-DEQ4y-jn.js} +1 -2
- package/dist/form-associated-element-DEQ4y-jn.js.map +1 -0
- package/dist/{icon-DY5AZ6xM.js → icon-DVyMc4Wv.js} +36 -2
- package/dist/{icon-DY5AZ6xM.js.map → icon-DVyMc4Wv.js.map} +1 -1
- package/dist/light.css +7 -2
- package/dist/localize.js +8 -5
- package/dist/localize.js.map +1 -1
- package/dist/packages/internals/form-associated-element.d.ts +0 -1
- package/dist/packages/utils/utils.d.ts +16 -0
- package/dist/packages/wje-accordion-item/accordion-item.element.d.ts +3 -0
- package/dist/packages/wje-avatar/avatar.element.d.ts +5 -0
- package/dist/packages/wje-breadcrumb/breadcrumb.element.d.ts +1 -0
- package/dist/packages/wje-button/button.element.d.ts +5 -1
- package/dist/packages/wje-button-group/button-group.element.d.ts +4 -0
- package/dist/packages/wje-card/card.element.d.ts +15 -6
- package/dist/packages/wje-carousel/carousel.element.d.ts +4 -0
- package/dist/packages/wje-checkbox/checkbox.element.d.ts +14 -0
- package/dist/packages/wje-chip/chip.element.d.ts +6 -0
- package/dist/packages/wje-color-picker/color-picker.element.d.ts +43 -1
- package/dist/packages/wje-copy-button/copy-button.element.d.ts +4 -0
- package/dist/packages/wje-dialog/dialog.element.d.ts +2 -0
- package/dist/packages/wje-dropdown/dropdown.element.d.ts +7 -0
- package/dist/packages/wje-element/element.d.ts +55 -24
- package/dist/packages/wje-file-upload/file-upload.element.d.ts +17 -6
- package/dist/packages/wje-file-upload/service/service.d.ts +0 -23
- package/dist/packages/wje-file-upload-item/file-upload-item.element.d.ts +5 -0
- package/dist/packages/wje-format-digital/format-digital.element.d.ts +2 -0
- package/dist/packages/wje-icon/icon.element.d.ts +11 -0
- package/dist/packages/wje-icon-picker/icon-picker.element.d.ts +4 -0
- package/dist/packages/wje-img/img.element.d.ts +1 -0
- package/dist/packages/wje-infinite-scroll/infinite-scroll.element.d.ts +4 -0
- package/dist/packages/wje-input/input.element.d.ts +9 -1
- package/dist/packages/wje-item/item.element.d.ts +8 -0
- package/dist/packages/wje-kanban/kanban.element.d.ts +4 -0
- package/dist/packages/wje-level-indicator/level-indicator.element.d.ts +17 -0
- package/dist/packages/wje-list/list.element.d.ts +4 -0
- package/dist/packages/wje-menu-item/menu-item.element.d.ts +4 -0
- package/dist/packages/wje-option/option.element.d.ts +4 -0
- package/dist/packages/wje-options/options.element.d.ts +4 -0
- package/dist/packages/wje-orgchart/orgchart.element.d.ts +4 -0
- package/dist/packages/wje-progress-bar/progress-bar.element.d.ts +11 -0
- package/dist/packages/wje-qr-code/qr-code.element.d.ts +63 -0
- package/dist/packages/wje-radio/radio.element.d.ts +5 -0
- package/dist/packages/wje-radio-group/radio-group.element.d.ts +16 -1
- package/dist/packages/wje-rate/rate.element.d.ts +4 -0
- package/dist/packages/wje-relative-time/relative-time.element.d.ts +2 -0
- package/dist/packages/wje-reorder/reorder.element.d.ts +4 -0
- package/dist/packages/wje-reorder-handle/reorder-handle.element.d.ts +4 -0
- package/dist/packages/wje-select/select.element.d.ts +7 -0
- package/dist/packages/wje-slider/slider.element.d.ts +5 -0
- package/dist/packages/wje-sliding-container/sliding-container.element.d.ts +4 -0
- package/dist/packages/wje-split-view/split-view.element.d.ts +1 -0
- package/dist/packages/wje-stepper/stepper.element.d.ts +1 -0
- package/dist/packages/wje-tab/tab.element.d.ts +10 -0
- package/dist/packages/wje-tab-group/tab-group.element.d.ts +11 -0
- package/dist/packages/wje-textarea/textarea.element.d.ts +20 -1
- package/dist/packages/wje-thumbnail/thumbnail.element.d.ts +4 -0
- package/dist/packages/wje-timeline/timeline.element.d.ts +4 -0
- package/dist/packages/wje-toggle/toggle.element.d.ts +4 -0
- package/dist/packages/wje-toolbar/toolbar.element.d.ts +4 -0
- package/dist/packages/wje-tooltip/tooltip.element.d.ts +3 -0
- package/dist/packages/wje-tree/tree.element.d.ts +4 -0
- package/dist/packages/wje-tree-item/tree-item.element.d.ts +5 -0
- package/dist/{popup.element-DeajFyOQ.js → popup.element-Cl6QeG8M.js} +2 -2
- package/dist/{popup.element-DeajFyOQ.js.map → popup.element-Cl6QeG8M.js.map} +1 -1
- package/dist/skeleton.css +197 -0
- package/dist/utils.js +18 -1
- package/dist/utils.js.map +1 -1
- package/dist/wje-accordion-item.js +26 -4
- package/dist/wje-accordion-item.js.map +1 -1
- package/dist/wje-accordion.js +1 -0
- package/dist/wje-accordion.js.map +1 -1
- package/dist/wje-animation.js +1 -0
- package/dist/wje-animation.js.map +1 -1
- package/dist/wje-avatar.js +18 -0
- package/dist/wje-avatar.js.map +1 -1
- package/dist/wje-badge.js +1 -0
- package/dist/wje-badge.js.map +1 -1
- package/dist/wje-breadcrumb.js +13 -1
- package/dist/wje-breadcrumb.js.map +1 -1
- package/dist/wje-breadcrumbs.js +1 -0
- package/dist/wje-breadcrumbs.js.map +1 -1
- package/dist/wje-button-group.js +10 -0
- package/dist/wje-button-group.js.map +1 -1
- package/dist/wje-button.js +29 -5
- package/dist/wje-button.js.map +1 -1
- package/dist/wje-card.js +37 -0
- package/dist/wje-card.js.map +1 -1
- package/dist/wje-carousel.js +38 -4
- package/dist/wje-carousel.js.map +1 -1
- package/dist/wje-checkbox.js +48 -3
- package/dist/wje-checkbox.js.map +1 -1
- package/dist/wje-chip.js +22 -0
- package/dist/wje-chip.js.map +1 -1
- package/dist/wje-color-picker.js +143 -29
- package/dist/wje-color-picker.js.map +1 -1
- package/dist/wje-copy-button.js +21 -0
- package/dist/wje-copy-button.js.map +1 -1
- package/dist/wje-dialog.js +35 -2
- package/dist/wje-dialog.js.map +1 -1
- package/dist/wje-dropdown.js +27 -3
- package/dist/wje-dropdown.js.map +1 -1
- package/dist/wje-element.js +87 -242
- package/dist/wje-element.js.map +1 -1
- package/dist/wje-file-upload-item.js +23 -1
- package/dist/wje-file-upload-item.js.map +1 -1
- package/dist/wje-file-upload.js +100 -77
- package/dist/wje-file-upload.js.map +1 -1
- package/dist/wje-format-digital.js +9 -0
- package/dist/wje-format-digital.js.map +1 -1
- package/dist/wje-icon-picker.js +15 -0
- package/dist/wje-icon-picker.js.map +1 -1
- package/dist/wje-icon.js +1 -1
- package/dist/wje-img-comparer.js +5 -1
- package/dist/wje-img-comparer.js.map +1 -1
- package/dist/wje-img.js +16 -1
- package/dist/wje-img.js.map +1 -1
- package/dist/wje-infinite-scroll.js +10 -0
- package/dist/wje-infinite-scroll.js.map +1 -1
- package/dist/wje-input-file.js +2 -0
- package/dist/wje-input-file.js.map +1 -1
- package/dist/wje-input.js +59 -4
- package/dist/wje-input.js.map +1 -1
- package/dist/wje-item.js +14 -0
- package/dist/wje-item.js.map +1 -1
- package/dist/wje-kanban.js +14 -0
- package/dist/wje-kanban.js.map +1 -1
- package/dist/wje-level-indicator.js +36 -0
- package/dist/wje-level-indicator.js.map +1 -1
- package/dist/wje-list.js +10 -0
- package/dist/wje-list.js.map +1 -1
- package/dist/wje-master.js +11 -2
- package/dist/wje-master.js.map +1 -1
- package/dist/wje-menu-button.js +1 -0
- package/dist/wje-menu-button.js.map +1 -1
- package/dist/wje-menu-item.js +24 -0
- package/dist/wje-menu-item.js.map +1 -1
- package/dist/wje-menu.js +4 -1
- package/dist/wje-menu.js.map +1 -1
- package/dist/wje-option.js +14 -1
- package/dist/wje-option.js.map +1 -1
- package/dist/wje-options.js +13 -0
- package/dist/wje-options.js.map +1 -1
- package/dist/wje-orgchart.js +9 -0
- package/dist/wje-orgchart.js.map +1 -1
- package/dist/wje-pagination.js +18 -9
- package/dist/wje-pagination.js.map +1 -1
- package/dist/wje-popup.js +1 -1
- package/dist/wje-progress-bar.js +26 -0
- package/dist/wje-progress-bar.js.map +1 -1
- package/dist/wje-qr-code.js +159 -17
- package/dist/wje-qr-code.js.map +1 -1
- package/dist/wje-radio-group.js +49 -2
- package/dist/wje-radio-group.js.map +1 -1
- package/dist/wje-radio.js +27 -1
- package/dist/wje-radio.js.map +1 -1
- package/dist/wje-rate.js +23 -1
- package/dist/wje-rate.js.map +1 -1
- package/dist/wje-relative-time.js +14 -1
- package/dist/wje-relative-time.js.map +1 -1
- package/dist/wje-reorder-handle.js +21 -0
- package/dist/wje-reorder-handle.js.map +1 -1
- package/dist/wje-reorder.js +10 -0
- package/dist/wje-reorder.js.map +1 -1
- package/dist/wje-select.js +35 -5
- package/dist/wje-select.js.map +1 -1
- package/dist/wje-slider.js +51 -1
- package/dist/wje-slider.js.map +1 -1
- package/dist/wje-sliding-container.js +18 -0
- package/dist/wje-sliding-container.js.map +1 -1
- package/dist/wje-split-view.js +9 -0
- package/dist/wje-split-view.js.map +1 -1
- package/dist/wje-status.js +1 -0
- package/dist/wje-status.js.map +1 -1
- package/dist/wje-stepper.js +24 -1
- package/dist/wje-stepper.js.map +1 -1
- package/dist/wje-tab-group.js +59 -2
- package/dist/wje-tab-group.js.map +1 -1
- package/dist/wje-tab.js +30 -0
- package/dist/wje-tab.js.map +1 -1
- package/dist/wje-textarea.js +96 -14
- package/dist/wje-textarea.js.map +1 -1
- package/dist/wje-thumbnail.js +19 -0
- package/dist/wje-thumbnail.js.map +1 -1
- package/dist/wje-toast.js +4 -0
- package/dist/wje-toast.js.map +1 -1
- package/dist/wje-toggle.js +17 -1
- package/dist/wje-toggle.js.map +1 -1
- package/dist/wje-toolbar.js +14 -0
- package/dist/wje-toolbar.js.map +1 -1
- package/dist/wje-tooltip.js +31 -7
- package/dist/wje-tooltip.js.map +1 -1
- package/dist/wje-tree-item.js +41 -5
- package/dist/wje-tree-item.js.map +1 -1
- package/dist/wje-tree.js +12 -1
- package/dist/wje-tree.js.map +1 -1
- package/package.json +21 -2
- package/dist/form-associated-element-o0UjvdUp.js.map +0 -1
- package/dist/packages/wje-accordion/accordion.test.d.ts +0 -0
- package/dist/packages/wje-animation/animation.test.d.ts +0 -1
- package/dist/packages/wje-avatar/avatar.test.d.ts +0 -1
- package/dist/packages/wje-badge/badge.test.d.ts +0 -1
- package/dist/packages/wje-breadcrumbs/breadcrumbs.test.d.ts +0 -1
- package/dist/packages/wje-button/button.test.d.ts +0 -1
- package/dist/packages/wje-chip/chip.test.d.ts +0 -1
- package/dist/packages/wje-color-picker/color-picker.test.d.ts +0 -1
- package/dist/packages/wje-file-upload/file-upload.test.d.ts +0 -1
- package/dist/packages/wje-format-digital/format-digital.test.d.ts +0 -1
- package/dist/packages/wje-pagination/pagination.test.d.ts +0 -1
- package/dist/packages/wje-relative-time/relative-time.test.d.ts +0 -1
- package/dist/packages/wje-select/select.test.d.ts +0 -1
- package/dist/packages/wje-tab-group/tab-group.test.d.ts +0 -1
- package/dist/packages/wje-toast/toast.test.d.ts +0 -1
- package/dist/packages/wje-toggle/toggle.test.d.ts +0 -1
- package/dist/packages/wje-tree/tree.test.d.ts +0 -1
- package/dist/packages/wje-tree-item/tree-item.test.d.ts +0 -1
package/dist/wje-options.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wje-options.js","sources":["../packages/wje-options/options.element.js","../packages/wje-options/options.js"],"sourcesContent":["import { default as WJElement, event } from '../wje-element/element.js';\nimport InfiniteScroll from '../wje-infinite-scroll/infinite-scroll.js';\nimport List from '../wje-list/list.js';\nimport Option from '../wje-option/option.js';\n\nimport styles from './styles/styles.css?inline';\n\n/**\n * `Options` is a custom web component that represents a set of options. It extends from `WJElement`.\n * @summary This element represents a set of options.\n * @documentation https://elements.webjet.sk/components/options\n * @status stable\n * @tag wje-options\n */\n\nexport default class Options extends WJElement {\n\n\t#loadedOptions = [];\n\n\t#drawPreloadedElements = [];\n\n\tconstructor() {\n\t\tsuper();\n\t}\n\n\tdependencies = {\n\t\t'wje-option': Option,\n\t\t'wje-infinite-scroll': InfiniteScroll,\n\t\t'wje-list': List,\n\t}\n\n\t/**\n\t * Sets the option array path attribute.\n\t * @param {string} value The value to set for the option array path.\n\t */\n\tset optionArrayPath(value) {\n\t\tthis.setAttribute('option-array-path', value);\n\t}\n\n\t/**\n\t * Gets the option array path attribute.\n\t * @returns {string} The value of the option array path attribute or \"data\" if not set.\n\t */\n\tget optionArrayPath() {\n\t\treturn this.getAttribute('option-array-path');\n\t}\n\n\t/**\n\t * Checks if the option array path attribute is present.\n\t * @returns {boolean} True if the option array path attribute is present, false otherwise.\n\t */\n\tget hasOptionArrayPath() {\n\t\treturn this.hasAttribute('option-array-path');\n\t}\n\n\t/**\n\t * Gets the dropdown height attribute.\n\t * @returns {string} The value of the dropdown height attribute or \"100%\" if not set.\n\t */\n\tget dropdownHeight() {\n\t\treturn this.getAttribute('dropdown-height') || '100%';\n\t}\n\n\t/**\n\t * Sets the dropdown height attribute.\n\t * @param {string} value The value to set for the dropdown height.\n\t */\n\tset dropdownHeight(value) {\n\t\tthis.setAttribute('dropdown-height', value);\n\t}\n\n\t/**\n\t * Sets the item value attribute.\n\t * @param {string} value The value to set for the item value.\n\t */\n\tset itemValue(value) {\n\t\tthis.setAttribute('item-value', value);\n\t}\n\n\t/**\n\t * Gets the item value attribute.\n\t * @returns {string} The value of the item value attribute or \"value\" if not set.\n\t */\n\tget itemValue() {\n\t\treturn this.getAttribute('item-value') || 'value';\n\t}\n\n\t/**\n\t * Sets the item text attribute.\n\t * @param {string} value The value to set for the item text.\n\t */\n\tset itemText(value) {\n\t\tthis.setAttribute('item-text', value);\n\t}\n\n\t/**\n\t * Gets the item text attribute.\n\t * @returns {string} The value of the item text attribute or \"text\" if not set.\n\t */\n\tget itemText() {\n\t\treturn this.getAttribute('item-text') || 'text';\n\t}\n\n\t/**\n\t * Gets the lazy load size attribute.\n\t * @returns {number} The value of the lazy load size attribute or 10 if not set.\n\t */\n\tget lazyLoadSize() {\n\t\treturn this.getAttribute('lazy-load-size') || 10;\n\t}\n\n\t/**\n\t * Sets the lazy load size attribute.\n\t * @param {number} value The value to set for the lazy load size.\n\t */\n\tset lazyLoadSize(value) {\n\t\tthis.setAttribute('lazy-load-size', value);\n\t}\n\n\t/**\n\t * Sets the search attribute.\n\t * @param {string} value The value to set for the search.\n\t */\n\tset search(value) {\n\t\tthis.setAttribute('search', value);\n\t}\n\n\t/**\n\t * Gets the search attribute.\n\t * @returns {string} The value of the search attribute.\n\t */\n\tget search() {\n\t\treturn this.getAttribute('search');\n\t}\n\n\t/**\n\t * Checks if the search attribute is present.\n\t * @returns {boolean} True if the search attribute is present, false otherwise.\n\t */\n\tget hasSearch() {\n\t\treturn this.hasAttribute('search');\n\t}\n\n\t/**\n\t * Retrieves the value of the 'search-to-query-params' attribute from the current instance.\n\t * @returns {string | null} The value of the 'search-to-query-params' attribute, or null if the attribute is not set.\n\t */\n\tget searchToQueryParams() {\n\t\treturn this.getAttribute('search-to-query-params');\n\t}\n\n\t/**\n\t * Sets the value to define search-to-query params behavior.\n\t * @param {string} value The value to be set for the search-to-query-params attribute.\n\t */\n\tset searchToQueryParams(value) {\n\t\tthis.setAttribute('search-to-query-params', value);\n\t}\n\n\t/**\n\t * Determines whether the 'search-to-query-params' attribute is present on the element.\n\t * @returns {boolean} True if the 'search-to-query-params' attribute exists, otherwise false.\n\t */\n\tget hasSearchToQueryParams() {\n\t\treturn this.hasAttribute('search-to-query-params');\n\t}\n\n\t/**\n\t * Sets the value of the search parameter name attribute.\n\t * @param {string} value The string value to set as the search parameter name.\n\t */\n\tset searchParamName(value) {\n\t\tthis.setAttribute('search-param-name', value);\n\t}\n\n\t/**\n\t * Gets the search parameter name used in queries.\n\t * Retrieves the value of the 'search-param-name' attribute.\n\t * If the attribute is not set, it defaults to 'search'.\n\t * @returns {string} The search parameter name used for queries.\n\t */\n\tget searchParamName() {\n\t\treturn this.getAttribute('search-param-name') || 'search';\n\t}\n\n\t/**\n\t * Sets the queryParams attribute on the element.\n\t * @param {string} value The query parameters to set, represented as a string.\n\t */\n\tset queryParams(value) {\n\t\tthis.setAttribute('query-params', value);\n\t}\n\n\t/**\n\t * Retrieves the value of the 'query-params' attribute.\n\t * @returns {string | null} The value of the 'query-params' attribute, or null if the attribute is not set.\n\t */\n\tget queryParams() {\n\t\treturn this.getAttribute('query-params');\n\t}\n\n\t/**\n\t * Sets the lazy attribute.\n\t * @param {boolean} value The value to set for the lazy attribute.\n\t */\n\tset lazy(value) {\n\t\tthis.setAttribute('lazy', value);\n\t}\n\n\t/**\n\t * Checks if the lazy attribute is present.\n\t * @returns {boolean} True if the lazy attribute is present, false otherwise.\n\t */\n\tget lazy() {\n\t\treturn this.hasAttribute('lazy');\n\t}\n\n\t/**\n\t * Gets the loaded options.\n\t * @returns {Array} The loaded options.\n\t */\n\tget options() {\n\t\treturn this.loadedOptions?.flat();\n\t}\n\n\t/**\n\t * Gets the loaded options.\n\t * @type {Array}\n\t */\n\tget loadedOptions() {\n\t\treturn this.#loadedOptions;\n\t}\n\n\t/**\n\t * Sets the loaded options.\n\t * @type {Array}\n\t */\n\tset loadedOptions(loadedOptions) {\n\t\tthis.#loadedOptions = loadedOptions;\n\t}\n\n\t/**\n\t * Array of preloaded elements.\n\t * @type {Array}\n\t * @private\n\t */\n\tget drawPreloadedElements() {\n\t\treturn this.#drawPreloadedElements;\n\t}\n\n\t/**\n\t * Sets the elements that are preloaded and ready to be drawn.\n\t * @param {Array|object} elements The elements to be set for preloading. This can be an array or a specific object containing drawable elements.\n\t */\n\tset drawPreloadedElements(elements) {\n\t\tthis.#drawPreloadedElements = elements;\n\t}\n\n\tclassName = 'Options';\n\n\t/**\n\t * Returns the CSS styles for the component.\n\t * @static\n\t * @returns {CSSStyleSheet} The CSS styles for the component.\n\t */\n\tstatic get cssStyleSheet() {\n\t\treturn styles;\n\t}\n\n\t/**\n\t * Retrieves an array of attributes that should be observed for changes.\n\t * The method returns a list of attribute names that the browser will monitor for changes.\n\t * @returns {Array<string>} An array of attribute names to observe.\n\t */\n\tstatic get observedAttributes() {\n\t\treturn ['search', 'attached'];\n\t}\n\n\t/**\n\t * Sets up the attributes for the component.\n\t */\n\tsetupAttributes() {\n\t\tthis.isShadowRoot = 'open';\n\t}\n\n\t/**\n\t * Draws the component.\n\t * @returns {DocumentFragment}\n\t */\n\tasync draw() {\n\t\tlet fragment = document.createDocumentFragment();\n\n\t\tconst slot = document.createElement('slot');\n\t\tfragment.appendChild(slot);\n\n\t\tif (this.lazy) {\n\t\t\tif (this.contains(this.infiniteScroll)) {\n\t\t\t\tthis.drawPreloadedElements.forEach((el) => { el.remove() });\n\t\t\t\tthis.loadedOptions = [];\n\t\t\t\tthis.infiniteScroll.placementObj.innerHTML = '';\n\t\t\t\tthis.infiniteScroll.totalPages = 0;\n\t\t\t\tthis.infiniteScroll.refresh();\n\t\t\t}\n\n\t\t\tlet loader = document.createElement('div');\n\t\t\tloader.setAttribute('slot', 'loader');\n\t\t\tloader.append('Loading...');\n\t\t\tloader.classList.add('loader');\n\n\t\t\tconst infiniteScroll = document.createElement('wje-infinite-scroll');\n\t\t\tinfiniteScroll.setAttribute('placement', 'wje-list');\n\t\t\tinfiniteScroll.setAttribute('height', this.dropdownHeight);\n\t\t\tinfiniteScroll.setAttribute('object-name', this.optionArrayPath);\n\t\t\tinfiniteScroll.dataToHtml = this.htmlItem;\n\t\t\tinfiniteScroll.setCustomData = async (page, signal) => {\n\t\t\t\tlet processedUrl = `${this.url}${this.search ? `/${this.search}` : ''}?page=${page}&size=${this.lazyLoadSize}${this.queryParams ? `&${this.queryParams}` : ''}`;\n\n\t\t\t\tif (this.hasSearchToQueryParams) {\n\t\t\t\t\tprocessedUrl = `${this.url}?page=${page}&size=${this.lazyLoadSize}${this.queryParams ? `&${this.queryParams}` : ''}${this.search ? `&${this.searchParamName}=${this.search}` : ''}`;\n\t\t\t\t}\n\n\t\t\t\tlet res = await this.service.get(processedUrl, null, false, signal);\n\t\t\t\tconst filteredOptions = this.filterOutDrawnOptions(res);\n\t\t\t\tthis.loadedOptions.push(...this.processData(filteredOptions));\n\n\t\t\t\treturn filteredOptions;\n\t\t\t};\n\n\t\t\tconst list = document.createElement('wje-list');\n\n\t\t\tinfiniteScroll.append(list);\n\t\t\tinfiniteScroll.append(loader);\n\n\t\t\tif (this.hasAttribute('attached') && !this.hasSearch) {\n\t\t\t\tthis.appendChild(infiniteScroll);\n\t\t\t\tthis.drawPreloadedElements.forEach((el) => {\n\t\t\t\t\tlist.appendChild(el);\n\t\t\t\t});\n\t\t\t\tthis.infiniteScroll = infiniteScroll;\n\t\t\t}\n\t\t} else {\n\t\t\tthis.response = await this.getPages();\n\n\t\t\tlet optionsData = this.filterOutDrawnOptions(this.response);\n\t\t\toptionsData = this.processData(optionsData);\n\n\t\t\tthis.loadedOptions.push(...optionsData);\n\n\t\t\tthis.append(...optionsData.map(this.htmlItem));\n\n\t\t\tevent.dispatchCustomEvent(this, 'wje-options:load', {});\n\t\t}\n\n\t\treturn fragment;\n\t}\n\n\tafterDraw() {\n\t\tevent.addListener(this.infiniteScroll, 'wje-infinite-scroll:load', null, this.dispatchOptionsLoadEvent);\n\t}\n\n\tdispatchOptionsLoadEvent = (e) => {\n\t\t// Wait for next paint cycle to ensure options are in DOM\n\t\trequestAnimationFrame(() => {\n\t\t\trequestAnimationFrame(() => {\n\t\t\t\tevent.dispatchCustomEvent(this, 'wje-options:load', {});\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * Processes the provided data based on the optional array path set in the instance.\n\t * @param {object} data The input data to be processed.\n\t * @returns {Array} The resolved options array from the data or an empty array if no match is found.\n\t */\n\tprocessData(data) {\n\t\tconst splittedOptionArrayPath = this.optionArrayPath ? this.optionArrayPath?.split('.') : null;\n\t\tlet options = data;\n\n\t\tsplittedOptionArrayPath?.forEach((path) => {\n\t\t\toptions = options[path];\n\t\t});\n\n\t\treturn options ?? [];\n\t}\n\n\t/**\n\t * Filters out options from the response object that have already been drawn, based on the specified option array path.\n\t * @param {object} response The response object containing data to process.\n\t * @returns {object} The filtered response object with drawn options removed.\n\t */\n\tfilterOutDrawnOptions(response) {\n\t\tconst splittedOptionArrayPath = this.optionArrayPath ? this.optionArrayPath?.split('.') : [];\n\t\tlet filteredResponse = structuredClone(response);\n\n\t\tfilteredResponse = this.recursiveUpdate(filteredResponse, splittedOptionArrayPath);\n\t\treturn filteredResponse;\n\t}\n\n\t/**\n\t * Recursively updates the object based on the provided path to the property.\n\t * @param {object | Array | null} object\n\t * @param {Array<string> | null} pathToProperty\n\t * @returns {object | Array | null}\n\t */\n\trecursiveUpdate = (object, pathToProperty) => {\n\t\tif (pathToProperty.length === 0) {\n\t\t\tif (Array.isArray(object)) {\n\t\t\t\treturn object.filter(\n\t\t\t\t\t(option) =>\n\t\t\t\t\t\t!this.loadedOptions.some(\n\t\t\t\t\t\t\t(loadedOption) => loadedOption[this.itemValue] === option[this.itemValue]\n\t\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tconsole.error('Expected an array but got:', object, pathToProperty);\n\t\t\t\treturn [];\n\t\t\t}\n\t\t}\n\n\t\tconst [currentPath, ...remainingPath] = pathToProperty;\n\t\tif (remainingPath.length > 0) {\n\t\t\tobject[currentPath] = this.recursiveUpdate(object[currentPath], remainingPath);\n\t\t} else {\n\t\t\tobject[currentPath] =\n\t\t\t\tobject[currentPath]?.filter(\n\t\t\t\t\t(option) =>\n\t\t\t\t\t\t!this.loadedOptions.some(\n\t\t\t\t\t\t\t(loadedOption) => loadedOption[this.itemValue] === option[this.itemValue]\n\t\t\t\t\t\t)\n\t\t\t\t) ?? [];\n\t\t}\n\t\treturn object;\n\t};\n\n\t/**\n\t * Generates an HTML option element based on the provided item.\n\t * @param {object} item The item to generate the option element for.\n\t * @returns {HTMLElement} The generated option element.\n\t */\n\thtmlItem = (item) => {\n\t\tlet option = document.createElement('wje-option');\n\n\t\tif (item[this.itemValue] === null || item[this.itemValue] === undefined) {\n\t\t\tconsole.warn(`The item ${JSON.stringify(item)} does not have the property ${this.itemValue}`);\n\t\t}\n\n\t\tif (item[this.itemText] === null || item[this.itemText] === undefined) {\n\t\t\tconsole.warn(`The item ${JSON.stringify(item)} does not have the property ${this.itemText}`);\n\t\t}\n\n\t\toption.setAttribute('value', item[this.itemValue] ?? '');\n\t\toption.innerText = item[this.itemText] ?? '';\n\n\t\treturn option;\n\t};\n\n\t/**\n\t * Fetches the pages from the provided URL.\n\t * @param {number} page The page number to fetch.\n\t * @returns {Promise<object>} The fetched data.\n\t * @throws Will throw an error if the response is not ok.\n\t */\n\tasync getPages(page) {\n\t\tconst response = await fetch(this.url);\n\t\tif (!response.ok) {\n\t\t\tthrow new Error(`An error occurred: ${response.status}`);\n\t\t}\n\t\treturn await response.json();\n\t}\n\n\t/**\n\t * Finds the selected option data based on the given selected option values.\n\t * @param {Array} selectedOptionValues The array of selected option values.\n\t * @returns {Array} - The array of option data that matches the selected option values.\n\t */\n\tfindSelectedOptionData(selectedOptionValues = []) {\n\t\treturn this.options.filter((option) => selectedOptionValues.includes(option[this.itemValue]));\n\t}\n\n\t/**\n\t * Adds an option to the element.\n\t * @param {object} optionData The data of the option to be added.\n\t */\n\taddOption(optionData) {\n\t\tif (this.loadedOptions.some((option) => option[this.itemValue] === optionData[this.itemValue])) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst item = this.htmlItem(optionData);\n\t\tthis.#drawPreloadedElements.push(item);\n\t\tthis.prepend(item);\n\t\tthis.loadedOptions.push(optionData);\n\t}\n\n\t/**\n\t * Adds options to the element.\n\t * @param {Array} optionsData The array of option data to be added.\n\t * @param {boolean} [silent] Whether to suppress events triggered by adding options.\n\t */\n\taddOptions(optionsData = [], silent = false) {\n\t\tif (Array.isArray(optionsData)) optionsData?.forEach((od) => this.addOption(od, silent));\n\t\telse this.addOption(optionsData, silent);\n\t}\n\n\tbeforeDisconnect() {\n\t\tevent.removeListener(this.infiniteScroll, 'wje-infinite-scroll:load', null, this.dispatchOptionsLoadEvent);\n\t}\n}\n","import Options from './options.element.js';\n\nexport default Options;\n\nOptions.define('wje-options', Options);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAee,MAAM,gBAAgB,UAAU;AAAA,EAM9C,cAAc;AACb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,CAAC,WAAW,qBAAqB,SAAS,OAAO,KAAK,SAAS,CAAC,CAAC;AAAA,EAC9F;AAAA;AAAA;AAAA;AAAA;AAAA,EAMC,UAAU,YAAY;AACrB,QAAI,KAAK,cAAc,KAAK,CAAC,WAAW,OAAO,KAAK,SAAS,MAAM,WAAW,KAAK,SAAS,CAAC,GAAG;AAC/F;AAAA,IACH;AAEE,UAAM,OAAO,KAAK,SAAS,UAAU;AACrC,uBAAK,wBAAuB,KAAK,IAAI;AACrC,SAAK,QAAQ,IAAI;AACjB,SAAK,cAAc,KAAK,UAAU;AAAA,EACpC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOC,WAAW,cAAc,IAAI,SAAS,OAAO;AAC5C,QAAI,MAAM,QAAQ,WAAW,EAAG,4CAAa,QAAQ,CAAC,OAAO,KAAK,UAAU,IAAI,MAAM;AAAA,QACjF,MAAK,UAAU,aAAa,MAAM;AAAA,EACzC;AAAA,EAEC,mBAAmB;AAClB,UAAM,eAAe,KAAK,gBAAgB,4BAA4B,MAAM,KAAK,wBAAwB;AAAA,EAC3G;AACA;AA1eC;AAEA;ACfD,QAAQ,OAAO,eAAe,OAAO;"}
|
|
1
|
+
{"version":3,"file":"wje-options.js","sources":["../packages/wje-options/options.element.js","../packages/wje-options/options.js"],"sourcesContent":["import { default as WJElement, event } from '../wje-element/element.js';\nimport InfiniteScroll from '../wje-infinite-scroll/infinite-scroll.js';\nimport List from '../wje-list/list.js';\nimport Option from '../wje-option/option.js';\n\nimport styles from './styles/styles.css?inline';\n\n/**\n * `Options` is a custom web component that represents a set of options. It extends from `WJElement`.\n * @summary This element represents a set of options.\n * @documentation https://elements.webjet.sk/components/options\n * @status stable\n * @tag wje-options\n */\n\nexport default class Options extends WJElement {\n\n\t#loadedOptions = [];\n\n\t#drawPreloadedElements = [];\n\n\tconstructor() {\n\t\tsuper();\n\t}\n\n\tdependencies = {\n\t\t'wje-option': Option,\n\t\t'wje-infinite-scroll': InfiniteScroll,\n\t\t'wje-list': List,\n\t}\n\n\t/**\n\t * Sets the option array path attribute.\n\t * @param {string} value The value to set for the option array path.\n\t */\n\tset optionArrayPath(value) {\n\t\tthis.setAttribute('option-array-path', value);\n\t}\n\n\t/**\n\t * Gets the option array path attribute.\n\t * @returns {string} The value of the option array path attribute or \"data\" if not set.\n\t */\n\tget optionArrayPath() {\n\t\treturn this.getAttribute('option-array-path');\n\t}\n\n\t/**\n\t * Checks if the option array path attribute is present.\n\t * @returns {boolean} True if the option array path attribute is present, false otherwise.\n\t */\n\tget hasOptionArrayPath() {\n\t\treturn this.hasAttribute('option-array-path');\n\t}\n\n\t/**\n\t * Gets the dropdown height attribute.\n\t * @returns {string} The value of the dropdown height attribute or \"100%\" if not set.\n\t */\n\tget dropdownHeight() {\n\t\treturn this.getAttribute('dropdown-height') || '100%';\n\t}\n\n\t/**\n\t * Sets the dropdown height attribute.\n\t * @param {string} value The value to set for the dropdown height.\n\t */\n\tset dropdownHeight(value) {\n\t\tthis.setAttribute('dropdown-height', value);\n\t}\n\n\t/**\n\t * Sets the item value attribute.\n\t * @param {string} value The value to set for the item value.\n\t */\n\tset itemValue(value) {\n\t\tthis.setAttribute('item-value', value);\n\t}\n\n\t/**\n\t * Gets the item value attribute.\n\t * @returns {string} The value of the item value attribute or \"value\" if not set.\n\t */\n\tget itemValue() {\n\t\treturn this.getAttribute('item-value') || 'value';\n\t}\n\n\t/**\n\t * Sets the item text attribute.\n\t * @param {string} value The value to set for the item text.\n\t */\n\tset itemText(value) {\n\t\tthis.setAttribute('item-text', value);\n\t}\n\n\t/**\n\t * Gets the item text attribute.\n\t * @returns {string} The value of the item text attribute or \"text\" if not set.\n\t */\n\tget itemText() {\n\t\treturn this.getAttribute('item-text') || 'text';\n\t}\n\n\t/**\n\t * Gets the lazy load size attribute.\n\t * @returns {number} The value of the lazy load size attribute or 10 if not set.\n\t */\n\tget lazyLoadSize() {\n\t\treturn this.getAttribute('lazy-load-size') || 10;\n\t}\n\n\t/**\n\t * Sets the lazy load size attribute.\n\t * @param {number} value The value to set for the lazy load size.\n\t */\n\tset lazyLoadSize(value) {\n\t\tthis.setAttribute('lazy-load-size', value);\n\t}\n\n\t/**\n\t * Sets the search attribute.\n\t * @param {string} value The value to set for the search.\n\t */\n\tset search(value) {\n\t\tthis.setAttribute('search', value);\n\t}\n\n\t/**\n\t * Gets the search attribute.\n\t * @returns {string} The value of the search attribute.\n\t */\n\tget search() {\n\t\treturn this.getAttribute('search');\n\t}\n\n\t/**\n\t * Checks if the search attribute is present.\n\t * @returns {boolean} True if the search attribute is present, false otherwise.\n\t */\n\tget hasSearch() {\n\t\treturn this.hasAttribute('search');\n\t}\n\n\t/**\n\t * Retrieves the value of the 'search-to-query-params' attribute from the current instance.\n\t * @returns {string | null} The value of the 'search-to-query-params' attribute, or null if the attribute is not set.\n\t */\n\tget searchToQueryParams() {\n\t\treturn this.getAttribute('search-to-query-params');\n\t}\n\n\t/**\n\t * Sets the value to define search-to-query params behavior.\n\t * @param {string} value The value to be set for the search-to-query-params attribute.\n\t */\n\tset searchToQueryParams(value) {\n\t\tthis.setAttribute('search-to-query-params', value);\n\t}\n\n\t/**\n\t * Determines whether the 'search-to-query-params' attribute is present on the element.\n\t * @returns {boolean} True if the 'search-to-query-params' attribute exists, otherwise false.\n\t */\n\tget hasSearchToQueryParams() {\n\t\treturn this.hasAttribute('search-to-query-params');\n\t}\n\n\t/**\n\t * Sets the value of the search parameter name attribute.\n\t * @param {string} value The string value to set as the search parameter name.\n\t */\n\tset searchParamName(value) {\n\t\tthis.setAttribute('search-param-name', value);\n\t}\n\n\t/**\n\t * Gets the search parameter name used in queries.\n\t * Retrieves the value of the 'search-param-name' attribute.\n\t * If the attribute is not set, it defaults to 'search'.\n\t * @returns {string} The search parameter name used for queries.\n\t */\n\tget searchParamName() {\n\t\treturn this.getAttribute('search-param-name') || 'search';\n\t}\n\n\t/**\n\t * Sets the queryParams attribute on the element.\n\t * @param {string} value The query parameters to set, represented as a string.\n\t */\n\tset queryParams(value) {\n\t\tthis.setAttribute('query-params', value);\n\t}\n\n\t/**\n\t * Retrieves the value of the 'query-params' attribute.\n\t * @returns {string | null} The value of the 'query-params' attribute, or null if the attribute is not set.\n\t */\n\tget queryParams() {\n\t\treturn this.getAttribute('query-params');\n\t}\n\n\t/**\n\t * Sets the lazy attribute.\n\t * @param {boolean} value The value to set for the lazy attribute.\n\t */\n\tset lazy(value) {\n\t\tthis.setAttribute('lazy', value);\n\t}\n\n\t/**\n\t * Checks if the lazy attribute is present.\n\t * @returns {boolean} True if the lazy attribute is present, false otherwise.\n\t */\n\tget lazy() {\n\t\treturn this.hasAttribute('lazy');\n\t}\n\n\t/**\n\t * Gets the loaded options.\n\t * @returns {Array} The loaded options.\n\t */\n\tget options() {\n\t\treturn this.loadedOptions?.flat();\n\t}\n\n\t/**\n\t * Gets the loaded options.\n\t * @type {Array}\n\t */\n\tget loadedOptions() {\n\t\treturn this.#loadedOptions;\n\t}\n\n\t/**\n\t * Sets the loaded options.\n\t * @type {Array}\n\t */\n\tset loadedOptions(loadedOptions) {\n\t\tthis.#loadedOptions = loadedOptions;\n\t}\n\n\t/**\n\t * Array of preloaded elements.\n\t * @type {Array}\n\t * @private\n\t */\n\tget drawPreloadedElements() {\n\t\treturn this.#drawPreloadedElements;\n\t}\n\n\t/**\n\t * Sets the elements that are preloaded and ready to be drawn.\n\t * @param {Array|object} elements The elements to be set for preloading. This can be an array or a specific object containing drawable elements.\n\t */\n\tset drawPreloadedElements(elements) {\n\t\tthis.#drawPreloadedElements = elements;\n\t}\n\n\tclassName = 'Options';\n\n\t/**\n\t * Returns the CSS styles for the component.\n\t * @static\n\t * @returns {CSSStyleSheet} The CSS styles for the component.\n\t */\n\tstatic get cssStyleSheet() {\n\t\treturn styles;\n\t}\n\n\t/**\n\t * Retrieves an array of attributes that should be observed for changes.\n\t * The method returns a list of attribute names that the browser will monitor for changes.\n\t * @returns {Array<string>} An array of attribute names to observe.\n\t */\n\tstatic get observedAttributes() {\n\t\treturn ['search', 'attached'];\n\t}\n\n\t/**\n\t * Sets up the attributes for the component.\n\t */\n\tsetupAttributes() {\n\t\tthis.isShadowRoot = 'open';\n\t\tthis.syncAria();\n\t}\n\n\t/**\n\t * Draws the component.\n\t * @returns {DocumentFragment}\n\t */\n\tasync draw() {\n\t\tlet fragment = document.createDocumentFragment();\n\n\t\tconst slot = document.createElement('slot');\n\t\tfragment.appendChild(slot);\n\t\tthis.syncAria();\n\n\t\tif (this.lazy) {\n\t\t\tif (this.contains(this.infiniteScroll)) {\n\t\t\t\tthis.drawPreloadedElements.forEach((el) => { el.remove() });\n\t\t\t\tthis.loadedOptions = [];\n\t\t\t\tthis.infiniteScroll.placementObj.innerHTML = '';\n\t\t\t\tthis.infiniteScroll.totalPages = 0;\n\t\t\t\tthis.infiniteScroll.refresh();\n\t\t\t}\n\n\t\t\tlet loader = document.createElement('div');\n\t\t\tloader.setAttribute('slot', 'loader');\n\t\t\tloader.append('Loading...');\n\t\t\tloader.classList.add('loader');\n\n\t\t\tconst infiniteScroll = document.createElement('wje-infinite-scroll');\n\t\t\tinfiniteScroll.setAttribute('placement', 'wje-list');\n\t\t\tinfiniteScroll.setAttribute('height', this.dropdownHeight);\n\t\t\tinfiniteScroll.setAttribute('object-name', this.optionArrayPath);\n\t\t\tinfiniteScroll.dataToHtml = this.htmlItem;\n\t\t\tinfiniteScroll.setCustomData = async (page, signal) => {\n\t\t\t\tlet processedUrl = `${this.url}${this.search ? `/${this.search}` : ''}?page=${page}&size=${this.lazyLoadSize}${this.queryParams ? `&${this.queryParams}` : ''}`;\n\n\t\t\t\tif (this.hasSearchToQueryParams) {\n\t\t\t\t\tprocessedUrl = `${this.url}?page=${page}&size=${this.lazyLoadSize}${this.queryParams ? `&${this.queryParams}` : ''}${this.search ? `&${this.searchParamName}=${this.search}` : ''}`;\n\t\t\t\t}\n\n\t\t\t\tlet res = await this.service.get(processedUrl, null, false, signal);\n\t\t\t\tconst filteredOptions = this.filterOutDrawnOptions(res);\n\t\t\t\tthis.loadedOptions.push(...this.processData(filteredOptions));\n\n\t\t\t\treturn filteredOptions;\n\t\t\t};\n\n\t\t\tconst list = document.createElement('wje-list');\n\n\t\t\tinfiniteScroll.append(list);\n\t\t\tinfiniteScroll.append(loader);\n\n\t\t\tif (this.hasAttribute('attached') && !this.hasSearch) {\n\t\t\t\tthis.appendChild(infiniteScroll);\n\t\t\t\tthis.drawPreloadedElements.forEach((el) => {\n\t\t\t\t\tlist.appendChild(el);\n\t\t\t\t});\n\t\t\t\tthis.infiniteScroll = infiniteScroll;\n\t\t\t}\n\t\t} else {\n\t\t\tthis.response = await this.getPages();\n\n\t\t\tlet optionsData = this.filterOutDrawnOptions(this.response);\n\t\t\toptionsData = this.processData(optionsData);\n\n\t\t\tthis.loadedOptions.push(...optionsData);\n\n\t\t\tthis.append(...optionsData.map(this.htmlItem));\n\n\t\t\tevent.dispatchCustomEvent(this, 'wje-options:load', {});\n\t\t}\n\n\t\treturn fragment;\n\t}\n\n\t/**\n\t * Syncs ARIA attributes on the host element.\n\t */\n\tsyncAria() {\n\t\tconst isMultiple = this.closest('wje-select')?.hasAttribute('multiple');\n\t\tthis.setAriaState({\n\t\t\trole: 'listbox',\n\t\t\tmultiselectable: isMultiple ? 'true' : undefined,\n\t\t});\n\t}\n\n\tafterDraw() {\n\t\tevent.addListener(this.infiniteScroll, 'wje-infinite-scroll:load', null, this.dispatchOptionsLoadEvent);\n\t}\n\n\tdispatchOptionsLoadEvent = (e) => {\n\t\t// Wait for next paint cycle to ensure options are in DOM\n\t\trequestAnimationFrame(() => {\n\t\t\trequestAnimationFrame(() => {\n\t\t\t\tevent.dispatchCustomEvent(this, 'wje-options:load', {});\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * Processes the provided data based on the optional array path set in the instance.\n\t * @param {object} data The input data to be processed.\n\t * @returns {Array} The resolved options array from the data or an empty array if no match is found.\n\t */\n\tprocessData(data) {\n\t\tconst splittedOptionArrayPath = this.optionArrayPath ? this.optionArrayPath?.split('.') : null;\n\t\tlet options = data;\n\n\t\tsplittedOptionArrayPath?.forEach((path) => {\n\t\t\toptions = options[path];\n\t\t});\n\n\t\treturn options ?? [];\n\t}\n\n\t/**\n\t * Filters out options from the response object that have already been drawn, based on the specified option array path.\n\t * @param {object} response The response object containing data to process.\n\t * @returns {object} The filtered response object with drawn options removed.\n\t */\n\tfilterOutDrawnOptions(response) {\n\t\tconst splittedOptionArrayPath = this.optionArrayPath ? this.optionArrayPath?.split('.') : [];\n\t\tlet filteredResponse = structuredClone(response);\n\n\t\tfilteredResponse = this.recursiveUpdate(filteredResponse, splittedOptionArrayPath);\n\t\treturn filteredResponse;\n\t}\n\n\t/**\n\t * Recursively updates the object based on the provided path to the property.\n\t * @param {object | Array | null} object\n\t * @param {Array<string> | null} pathToProperty\n\t * @returns {object | Array | null}\n\t */\n\trecursiveUpdate = (object, pathToProperty) => {\n\t\tif (pathToProperty.length === 0) {\n\t\t\tif (Array.isArray(object)) {\n\t\t\t\treturn object.filter(\n\t\t\t\t\t(option) =>\n\t\t\t\t\t\t!this.loadedOptions.some(\n\t\t\t\t\t\t\t(loadedOption) => loadedOption[this.itemValue] === option[this.itemValue]\n\t\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tconsole.error('Expected an array but got:', object, pathToProperty);\n\t\t\t\treturn [];\n\t\t\t}\n\t\t}\n\n\t\tconst [currentPath, ...remainingPath] = pathToProperty;\n\t\tif (remainingPath.length > 0) {\n\t\t\tobject[currentPath] = this.recursiveUpdate(object[currentPath], remainingPath);\n\t\t} else {\n\t\t\tobject[currentPath] =\n\t\t\t\tobject[currentPath]?.filter(\n\t\t\t\t\t(option) =>\n\t\t\t\t\t\t!this.loadedOptions.some(\n\t\t\t\t\t\t\t(loadedOption) => loadedOption[this.itemValue] === option[this.itemValue]\n\t\t\t\t\t\t)\n\t\t\t\t) ?? [];\n\t\t}\n\t\treturn object;\n\t};\n\n\t/**\n\t * Generates an HTML option element based on the provided item.\n\t * @param {object} item The item to generate the option element for.\n\t * @returns {HTMLElement} The generated option element.\n\t */\n\thtmlItem = (item) => {\n\t\tlet option = document.createElement('wje-option');\n\n\t\tif (item[this.itemValue] === null || item[this.itemValue] === undefined) {\n\t\t\tconsole.warn(`The item ${JSON.stringify(item)} does not have the property ${this.itemValue}`);\n\t\t}\n\n\t\tif (item[this.itemText] === null || item[this.itemText] === undefined) {\n\t\t\tconsole.warn(`The item ${JSON.stringify(item)} does not have the property ${this.itemText}`);\n\t\t}\n\n\t\toption.setAttribute('value', item[this.itemValue] ?? '');\n\t\toption.innerText = item[this.itemText] ?? '';\n\n\t\treturn option;\n\t};\n\n\t/**\n\t * Fetches the pages from the provided URL.\n\t * @param {number} page The page number to fetch.\n\t * @returns {Promise<object>} The fetched data.\n\t * @throws Will throw an error if the response is not ok.\n\t */\n\tasync getPages(page) {\n\t\tconst response = await fetch(this.url);\n\t\tif (!response.ok) {\n\t\t\tthrow new Error(`An error occurred: ${response.status}`);\n\t\t}\n\t\treturn await response.json();\n\t}\n\n\t/**\n\t * Finds the selected option data based on the given selected option values.\n\t * @param {Array} selectedOptionValues The array of selected option values.\n\t * @returns {Array} - The array of option data that matches the selected option values.\n\t */\n\tfindSelectedOptionData(selectedOptionValues = []) {\n\t\treturn this.options.filter((option) => selectedOptionValues.includes(option[this.itemValue]));\n\t}\n\n\t/**\n\t * Adds an option to the element.\n\t * @param {object} optionData The data of the option to be added.\n\t */\n\taddOption(optionData) {\n\t\tif (this.loadedOptions.some((option) => option[this.itemValue] === optionData[this.itemValue])) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst item = this.htmlItem(optionData);\n\t\tthis.#drawPreloadedElements.push(item);\n\t\tthis.prepend(item);\n\t\tthis.loadedOptions.push(optionData);\n\t}\n\n\t/**\n\t * Adds options to the element.\n\t * @param {Array} optionsData The array of option data to be added.\n\t * @param {boolean} [silent] Whether to suppress events triggered by adding options.\n\t */\n\taddOptions(optionsData = [], silent = false) {\n\t\tif (Array.isArray(optionsData)) optionsData?.forEach((od) => this.addOption(od, silent));\n\t\telse this.addOption(optionsData, silent);\n\t}\n\n\tbeforeDisconnect() {\n\t\tevent.removeListener(this.infiniteScroll, 'wje-infinite-scroll:load', null, this.dispatchOptionsLoadEvent);\n\t}\n}\n","import Options from './options.element.js';\n\nexport default Options;\n\nOptions.define('wje-options', Options);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAee,MAAM,gBAAgB,UAAU;AAAA,EAM9C,cAAc;AACb,UAAO;AALR,uCAAiB,CAAE;AAEnB,+CAAyB,CAAE;AAM3B,wCAAe;AAAA,MACd,cAAc;AAAA,MACd,uBAAuB;AAAA,MACvB,YAAY;AAAA,IACd;AAqOC,qCAAY;AAmHZ,oDAA2B,CAAC,MAAM;AAEjC,4BAAsB,MAAM;AAC3B,8BAAsB,MAAM;AAC3B,gBAAM,oBAAoB,MAAM,oBAAoB,CAAA,CAAE;AAAA,QAC1D,CAAI;AAAA,MACJ,CAAG;AAAA,IACH;AAqCC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2CAAkB,CAAC,QAAQ,mBAAmB;;AAC7C,UAAI,eAAe,WAAW,GAAG;AAChC,YAAI,MAAM,QAAQ,MAAM,GAAG;AAC1B,iBAAO,OAAO;AAAA,YACb,CAAC,WACA,CAAC,KAAK,cAAc;AAAA,cACnB,CAAC,iBAAiB,aAAa,KAAK,SAAS,MAAM,OAAO,KAAK,SAAS;AAAA,YAC/E;AAAA,UACK;AAAA,QACL,OAAU;AACN,kBAAQ,MAAM,8BAA8B,QAAQ,cAAc;AAClE,iBAAO,CAAE;AAAA,QACb;AAAA,MACA;AAEE,YAAM,CAAC,aAAa,GAAG,aAAa,IAAI;AACxC,UAAI,cAAc,SAAS,GAAG;AAC7B,eAAO,WAAW,IAAI,KAAK,gBAAgB,OAAO,WAAW,GAAG,aAAa;AAAA,MAChF,OAAS;AACN,eAAO,WAAW,MACjB,YAAO,WAAW,MAAlB,mBAAqB;AAAA,UACpB,CAAC,W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AQ,OAAO,eAAe,OAAO;"}
|
package/dist/wje-orgchart.js
CHANGED
|
@@ -25,6 +25,7 @@ class Orgchart extends WJElement {
|
|
|
25
25
|
*/
|
|
26
26
|
setupAttributes() {
|
|
27
27
|
this.isShadowRoot = "open";
|
|
28
|
+
this.syncAria();
|
|
28
29
|
}
|
|
29
30
|
/**
|
|
30
31
|
* Draws the component for the org chart.
|
|
@@ -41,6 +42,14 @@ class Orgchart extends WJElement {
|
|
|
41
42
|
this.native = native;
|
|
42
43
|
return fragment;
|
|
43
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Sync ARIA attributes on host.
|
|
47
|
+
*/
|
|
48
|
+
syncAria() {
|
|
49
|
+
if (!this.hasAttribute("role")) {
|
|
50
|
+
this.setAriaState({ role: "tree" });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
44
53
|
}
|
|
45
54
|
Orgchart.define("wje-orgchart", Orgchart);
|
|
46
55
|
export {
|
package/dist/wje-orgchart.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wje-orgchart.js","sources":["../packages/wje-orgchart/orgchart.element.js","../packages/wje-orgchart/orgchart.js"],"sourcesContent":["import { default as WJElement } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary Orgchart is a custom web component that extends WJElement.\n * @documentation https://elements.webjet.sk/components/Orgchart\n * @status stable\n * @augments WJElement\n * @csspart - Styles the element.\n * @tag wje-orgchart\n * @example\n */\nexport default class Orgchart extends WJElement {\n /**\n * Creates an instance of Orgchart.\n * @class\n */\n constructor() {\n super();\n }\n\n className = 'Orgchart';\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 * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Draws the component for the org chart.\n * @returns {DocumentFragment}\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('div');\n native.setAttribute('part', 'native');\n native.classList.add('native-orgchart');\n\n let slot = document.createElement('slot');\n\n native.appendChild(slot);\n\n fragment.appendChild(native);\n\n this.native = native;\n\n return fragment;\n }\n}\n","import Orgchart from './orgchart.element.js';\n\nexport default Orgchart;\n\nOrgchart.define('wje-orgchart', Orgchart);\n"],"names":[],"mappings":";;;;;AAYe,MAAM,iBAAiB,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA,EAK5C,cAAc;AACV,UAAO;AAGX,qCAAY;AAAA,EAFhB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASI,WAAW,gBAAgB;AACvB,WAAO;AAAA,EACf;AAAA;AAAA;AAAA;AAAA,EAKI,kBAAkB;AACd,SAAK,eAAe;AAAA,
|
|
1
|
+
{"version":3,"file":"wje-orgchart.js","sources":["../packages/wje-orgchart/orgchart.element.js","../packages/wje-orgchart/orgchart.js"],"sourcesContent":["import { default as WJElement } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary Orgchart is a custom web component that extends WJElement.\n * @documentation https://elements.webjet.sk/components/Orgchart\n * @status stable\n * @augments WJElement\n * @csspart - Styles the element.\n * @tag wje-orgchart\n * @example\n */\nexport default class Orgchart extends WJElement {\n /**\n * Creates an instance of Orgchart.\n * @class\n */\n constructor() {\n super();\n }\n\n className = 'Orgchart';\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 * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n this.syncAria();\n }\n\n /**\n * Draws the component for the org chart.\n * @returns {DocumentFragment}\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('div');\n native.setAttribute('part', 'native');\n native.classList.add('native-orgchart');\n\n let slot = document.createElement('slot');\n\n native.appendChild(slot);\n\n fragment.appendChild(native);\n\n this.native = native;\n\n return fragment;\n }\n\n /**\n * Sync ARIA attributes on host.\n */\n syncAria() {\n if (!this.hasAttribute('role')) {\n this.setAriaState({ role: 'tree' });\n }\n }\n}\n","import Orgchart from './orgchart.element.js';\n\nexport default Orgchart;\n\nOrgchart.define('wje-orgchart', Orgchart);\n"],"names":[],"mappings":";;;;;AAYe,MAAM,iBAAiB,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA,EAK5C,cAAc;AACV,UAAO;AAGX,qCAAY;AAAA,EAFhB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASI,WAAW,gBAAgB;AACvB,WAAO;AAAA,EACf;AAAA;AAAA;AAAA;AAAA,EAKI,kBAAkB;AACd,SAAK,eAAe;AACpB,SAAK,SAAU;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,OAAO;AACH,QAAI,WAAW,SAAS,uBAAwB;AAEhD,QAAI,SAAS,SAAS,cAAc,KAAK;AACzC,WAAO,aAAa,QAAQ,QAAQ;AACpC,WAAO,UAAU,IAAI,iBAAiB;AAEtC,QAAI,OAAO,SAAS,cAAc,MAAM;AAExC,WAAO,YAAY,IAAI;AAEvB,aAAS,YAAY,MAAM;AAE3B,SAAK,SAAS;AAEd,WAAO;AAAA,EACf;AAAA;AAAA;AAAA;AAAA,EAKI,WAAW;AACP,QAAI,CAAC,KAAK,aAAa,MAAM,GAAG;AAC5B,WAAK,aAAa,EAAE,MAAM,OAAM,CAAE;AAAA,IAC9C;AAAA,EACA;AACA;AClEA,SAAS,OAAO,gBAAgB,QAAQ;"}
|
package/dist/wje-pagination.js
CHANGED
|
@@ -3,7 +3,7 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { en
|
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
4
|
import { Localizer } from "./localize.js";
|
|
5
5
|
import WJElement from "./wje-element.js";
|
|
6
|
-
import { I as Icon } from "./icon-
|
|
6
|
+
import { I as Icon } from "./icon-DVyMc4Wv.js";
|
|
7
7
|
import Button from "./wje-button.js";
|
|
8
8
|
import { event } from "./event.js";
|
|
9
9
|
function paginate(totalItems, currentPage = 1, pageSize = 10, maxPages = 5) {
|
|
@@ -279,6 +279,9 @@ class Pagination extends WJElement {
|
|
|
279
279
|
*/
|
|
280
280
|
setupAttributes() {
|
|
281
281
|
this.isShadowRoot = "open";
|
|
282
|
+
this.setAriaState({
|
|
283
|
+
role: "navigation"
|
|
284
|
+
});
|
|
282
285
|
}
|
|
283
286
|
async beforeDraw() {
|
|
284
287
|
this.classList.remove("empty");
|
|
@@ -289,7 +292,7 @@ class Pagination extends WJElement {
|
|
|
289
292
|
this.setAttribute("hidden", "");
|
|
290
293
|
return;
|
|
291
294
|
}
|
|
292
|
-
this.paginateObj = await paginate(this.totalItems, this.page, this.pageSize, this.maxPages) || {};
|
|
295
|
+
this.paginateObj = await paginate(this.totalItems, this.page + 1, this.pageSize, this.maxPages) || {};
|
|
293
296
|
}
|
|
294
297
|
/**
|
|
295
298
|
* Creates a document fragment, appends a new slot element to it, and returns the fragment.
|
|
@@ -339,24 +342,28 @@ class Pagination extends WJElement {
|
|
|
339
342
|
if (this.round) button.setAttribute("round", "");
|
|
340
343
|
let firstButton = button.cloneNode(true);
|
|
341
344
|
firstButton.title = this.localizer.translate("wj.pagination.first");
|
|
345
|
+
firstButton.setAttribute("aria-label", firstButton.title);
|
|
342
346
|
firstButton.innerHTML = `<wje-icon name="chevron-left-pipe" slot="icon-only"></wje-icon>`;
|
|
343
|
-
firstButton.addEventListener("
|
|
347
|
+
firstButton.addEventListener("click", (e) => this.pageClickAction(e, 0));
|
|
344
348
|
const prevButton = button.cloneNode(true);
|
|
345
349
|
prevButton.title = this.localizer.translate("wj.pagination.prev");
|
|
350
|
+
prevButton.setAttribute("aria-label", prevButton.title);
|
|
346
351
|
prevButton.innerHTML = `<wje-icon name="chevron-left" slot="icon-only"></wje-icon>`;
|
|
347
352
|
if (this.page === 0) prevButton.disabled = true;
|
|
348
|
-
prevButton.addEventListener("
|
|
353
|
+
prevButton.addEventListener("click", (e) => this.pageClickAction(e, this.page - 1));
|
|
349
354
|
const nextButton = button.cloneNode(true);
|
|
350
355
|
nextButton.title = this.localizer.translate("wj.pagination.next");
|
|
356
|
+
nextButton.setAttribute("aria-label", nextButton.title);
|
|
351
357
|
nextButton.innerHTML = `<wje-icon name="chevron-right" slot="icon-only"></wje-icon>`;
|
|
352
358
|
if (this.page + 1 >= ((_c = this.paginateObj) == null ? void 0 : _c.totalPages)) nextButton.disabled = true;
|
|
353
|
-
nextButton.addEventListener("
|
|
359
|
+
nextButton.addEventListener("click", (e) => this.pageClickAction(e, this.page + 1));
|
|
354
360
|
let lastButton = button.cloneNode(true);
|
|
355
361
|
lastButton.title = this.localizer.translate("wj.pagination.last");
|
|
362
|
+
lastButton.setAttribute("aria-label", lastButton.title);
|
|
356
363
|
lastButton.innerHTML = `<wje-icon name="chevron-right-pipe" slot="icon-only"></wje-icon>`;
|
|
357
364
|
lastButton.disabled = ((_d = this.paginateObj) == null ? void 0 : _d.endIndex) + 1 >= this.totalItems;
|
|
358
365
|
lastButton.addEventListener(
|
|
359
|
-
"
|
|
366
|
+
"click",
|
|
360
367
|
(e) => {
|
|
361
368
|
var _a2;
|
|
362
369
|
return this.pageClickAction(e, ((_a2 = this.paginateObj) == null ? void 0 : _a2.totalPages) - 1);
|
|
@@ -389,12 +396,13 @@ class Pagination extends WJElement {
|
|
|
389
396
|
if (this.round) button.setAttribute("round", "");
|
|
390
397
|
let dots = document.createElement("span");
|
|
391
398
|
dots.classList.add("dots");
|
|
399
|
+
dots.setAttribute("aria-hidden", "true");
|
|
392
400
|
const first = button.cloneNode(true);
|
|
393
401
|
first.textContent = "1";
|
|
394
|
-
first.addEventListener("
|
|
402
|
+
first.addEventListener("click", (e) => this.pageClickAction(e, 0));
|
|
395
403
|
const last = button.cloneNode(true);
|
|
396
404
|
last.textContent = paginateObj == null ? void 0 : paginateObj.totalPages;
|
|
397
|
-
last.addEventListener("
|
|
405
|
+
last.addEventListener("click", (e) => this.pageClickAction(e, (paginateObj == null ? void 0 : paginateObj.totalPages) - 1));
|
|
398
406
|
if ((paginateObj == null ? void 0 : paginateObj.currentPage) >= this.maxPages + 1 && (paginateObj == null ? void 0 : paginateObj.boundary) < (paginateObj == null ? void 0 : paginateObj.totalPages)) {
|
|
399
407
|
fragment.appendChild(first);
|
|
400
408
|
fragment.appendChild(dots);
|
|
@@ -404,8 +412,9 @@ class Pagination extends WJElement {
|
|
|
404
412
|
newButton.textContent = page;
|
|
405
413
|
if (page - 1 === this.page) {
|
|
406
414
|
newButton.removeAttribute("fill");
|
|
415
|
+
newButton.setAttribute("aria-current", "page");
|
|
407
416
|
} else {
|
|
408
|
-
newButton.addEventListener("
|
|
417
|
+
newButton.addEventListener("click", (e) => this.pageClickAction(e, page - 1));
|
|
409
418
|
}
|
|
410
419
|
fragment.appendChild(newButton);
|
|
411
420
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wje-pagination.js","sources":["../packages/wje-pagination/service/service.js","../packages/wje-pagination/pagination.element.js","../packages/wje-pagination/pagination.js"],"sourcesContent":["/**\n * Paginates items based on the total number of items, current page, page size, and maximum number of pages to display.\n * @param {number} totalItems The total number of items to paginate.\n * @param {number} [currentPage] The current page number (default is 1).\n * @param {number} [pageSize] The number of items per page (default is 10).\n * @param {number} [maxPages] The maximum number of pages to display in the pagination control (default is 5).\n * @returns {object} An object containing pagination details including total items, current page, page size, total pages, start/end page, start/end index, and the pages array.\n */\nexport function paginate(totalItems, currentPage = 1, pageSize = 10, maxPages = 5) {\n // Calculate total pages\n const totalPages = Math.ceil(totalItems / pageSize);\n\n // Ensure current page is within valid range\n if (currentPage < 1) {\n currentPage = 1;\n } else if (currentPage > totalPages) {\n currentPage = totalPages;\n }\n\n let startPage;\n let endPage;\n\n const pagesNearEnd = maxPages + 1; // Define how close to the end we switch back to 5 pages 4\n\n const boundary = pagesNearEnd + 3;\n\n if (totalPages > boundary) {\n if (currentPage < pagesNearEnd) {\n // If in the first 4 pages, show up to 5 pages\n startPage = 1;\n endPage = Math.min(pagesNearEnd + 1, totalPages); //5\n } else if (currentPage >= totalPages - pagesNearEnd) {\n // If within 4 pages from the end, show last 5 pages\n startPage = Math.max(totalPages - pagesNearEnd, 1); //4\n endPage = totalPages;\n } else {\n const halfPages = Math.floor(maxPages / 2);\n // Otherwise, only show 3 pages (current, previous, next)\n startPage = currentPage - halfPages + 1;\n endPage = maxPages % 2 === 1 ? currentPage + halfPages + 1 : currentPage + halfPages - 1;\n }\n } else {\n startPage = 1;\n endPage = totalPages;\n }\n\n // Calculate start and end item indexes\n const startIndex = (currentPage - 1) * pageSize;\n const endIndex = Math.min(startIndex + pageSize - 1, totalItems - 1);\n\n // Create an array of pages to display\n const pages = Array.from({ length: endPage - startPage + 1 }, (_, i) => startPage + i);\n\n // Return object with all pager properties (preserving original format)\n return {\n boundary: boundary,\n currentPage: currentPage,\n endIndex: endIndex,\n endPage: endPage,\n totalPages: totalPages,\n pages: pages,\n pageSize: pageSize,\n startIndex: startIndex,\n startPage: startPage,\n totalItems: totalItems,\n };\n}\n","import { Localizer } from '../utils/localize.js';\nimport { default as WJElement, event } from '../wje-element/element.js';\nimport { paginate } from './service/service.js';\nimport Icon from '../wje-icon/icon.js';\nimport Button from '../wje-button/button.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary This class represents the Pagination component for navigating through paginated content and dynamically updating navigation elements based on attributes like the number of items, page size, etc. Extends the WJElement class.\n * @documentation https://elements.webjet.sk/components/pagination\n * @status stable\n * @augments WJElement\n * @dependency wje-icon, wje-button\n * @csspart native - The wrapper element for the pagination component.\n */\nexport default class Pagination extends WJElement {\n /**\n * Creates an instance of Pagination.\n */\n constructor() {\n super();\n this.localizer = new Localizer(this);\n\n this._paginateObj = null;\n }\n\n /**\n * Sets the value of the 'page' attribute for the object.\n * @param {string} value The value to set for the 'page' attribute.\n */\n set page(value) {\n this.setAttribute('page', value);\n }\n\n /**\n * Retrieves the current page number as a numeric value.\n * @returns {number} The current page number. Returns 0 if the attribute 'page' is not set or is not a numeric value.\n */\n get page() {\n return +this.getAttribute('page') || 0;\n }\n\n /**\n * Sets the maximum number of pages.\n * Updates the 'max-pages' attribute with the provided value.\n * @param {number|string} value The maximum number of pages to set. Can be a number or a parsable string representing a number.\n */\n set maxPages(value) {\n this.setAttribute('max-pages', value);\n }\n\n /**\n * Gets the maximum number of pages.\n * This getter retrieves the value of the \"max-pages\" attribute from the element.\n * If the attribute is not set or is invalid, it defaults to 3.\n * @returns {number} The maximum number of pages as a numeric value.\n */\n get maxPages() {\n return +this.getAttribute('max-pages') || 10;\n }\n\n /**\n * Sets the `pageSize` attribute to the specified value.\n * @param {number|string} value The desired page size value. This can be a number or a string representation of the size.\n */\n set pageSize(value) {\n this.setAttribute('page-size', value);\n }\n\n /**\n * Retrieves the value of the 'page-size' attribute and converts it to a number.\n * If the attribute is not set or is invalid, returns the default value of 3.\n * @returns {number} The numeric value of the 'page-size' attribute or the default value of 3.\n */\n get pageSize() {\n return +this.getAttribute('page-size') || 3;\n }\n\n /**\n * Sets the total number of items.\n * @param {number} value The new total number of items to set.\n */\n set totalItems(value) {\n this.setAttribute('total-items', value);\n }\n\n /**\n * Retrieves the total number of items represented by the 'total-items' attribute.\n * @returns {number} The total number of items. Defaults to 0 if the attribute is not set or is invalid.\n */\n get totalItems() {\n return +this.getAttribute('total-items') || 0;\n }\n\n /**\n * Sets the visibility of the first button based on the provided value.\n * Adds the 'show-first-button' attribute when the value is truthy, and removes it otherwise.\n * @param {boolean} value Determines whether to show the first button. If true, the 'show-first-button' attribute is added; if false, it is removed.\n */\n set showFirstButton(value) {\n this.removeAttribute('show-first-button');\n\n if (value) {\n this.setAttribute('show-first-button', '');\n }\n }\n\n /**\n * Determines whether the 'show-first-button' attribute is present on the element.\n * @returns {boolean} True if the 'show-first-button' attribute is set; otherwise, false.\n */\n get showFirstButton() {\n return this.hasAttribute('show-first-button');\n }\n\n /**\n * Sets the visibility of the \"last\" button. This method controls the presence\n * or absence of the \"show-last-button\" attribute based on the provided value.\n * @param {boolean} value A boolean value indicating whether to show the \"last\" button.\n * If true, the \"show-last-button\" attribute is added;\n * if false, the attribute is removed.\n */\n set showLastButton(value) {\n this.removeAttribute('show-last-button');\n\n if (value) {\n this.setAttribute('show-last-button', '');\n }\n }\n\n /**\n * Determines if the 'show-last-button' attribute is present on the element.\n * @returns {boolean} True if the 'show-last-button' attribute is present, otherwise false.\n */\n get showLastButton() {\n return this.hasAttribute('show-last-button');\n }\n\n /**\n * Sets the pagination object by calculating the pagination details\n * based on the total items, current page, page size, and maximum pages.\n * @param {object} value The value to set the pagination object. The pagination details are computed internally.\n */\n set paginateObj(value) {\n this._paginateObj = value;\n }\n\n /**\n * Retrieves the pagination object used for managing paginated data.\n * @returns {object} The pagination object containing details and functionality for paginating data.\n */\n get paginateObj() {\n return this._paginateObj;\n }\n\n /**\n * Sets the 'round' attribute on the element. If the provided value is truthy,\n * the 'round' attribute is added. If the value is falsy, the attribute is removed.\n * @param {boolean} value A boolean value determining whether to add or remove the 'round' attribute.\n */\n set round(value) {\n this.removeAttribute('round');\n\n if (value) {\n this.setAttribute('round', '');\n }\n }\n\n /**\n * Retrieves the value of the 'round' attribute for the current element.\n * @returns {boolean} A boolean indicating whether the 'round' attribute is present on the element.\n */\n get round() {\n return this.hasAttribute('round');\n }\n\n /**\n * Sets the `show-info` attribute on the element based on the provided value.\n * @param {boolean} value A boolean indicating whether to add or remove the `show-info` attribute.\n */\n set showInfo(value) {\n this.removeAttribute('show-info');\n\n if (value) {\n this.setAttribute('show-info', '');\n }\n }\n\n /**\n * Retrieves the value of the 'show-info' attribute.\n * Checks if the 'show-info' attribute is present on the element.\n * @returns {boolean} True if the 'show-info' attribute is present, otherwise false.\n */\n get showInfo() {\n return this.hasAttribute('show-info');\n }\n\n set showPageSizeOptions(value) {\n if (!value) return;\n this.setAttribute('show-page-size-options', value);\n }\n\n get showPageSizeOptions() {\n return this.hasAttribute('show-page-size-options');\n }\n\n set pageSizeOptions(value) {\n if (!value) return;\n this.setAttribute('page-size-options', value);\n }\n\n /**\n * Retrieves the list of available page size options.\n * This method is used to fetch the values representing the different page size options\n * that can be provided or configured in a paginated component or system.\n * @returns {Array<number>} An array of numbers representing the selectable page size options.\n */\n get pageSizeOptions() {\n let options = this.getAttribute('page-size-options');\n if (!options) return [6, 10, 50, 100, 500];\n return options.split(',').map((o) => +o).filter((o) => !isNaN(o));\n }\n\n set hideEmpty(value) {\n if (!value) return;\n this.setAttribute('hide-empty', value);\n }\n\n get hideEmpty() {\n return this.hasAttribute('hide-empty');\n }\n\n /**\n * Dependencies of the Button element.\n * @type {object}\n */\n dependencies = {\n 'wje-icon': Icon,\n 'wje-button': Button,\n };\n\n className = 'Pagination';\n\n /**\n * Returns the CSS styles for the component.\n * @static\n * @returns {CSSStyleSheet}\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Getter for the observedAttributes attribute of the input element.\n * @returns {Array} The attributes to observe for changes.\n */\n static get observedAttributes() {\n return ['page', 'total-items', 'page-size'];\n }\n\n /**\n * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n async beforeDraw() {\n this.classList.remove('empty');\n this.removeAttribute(\"hidden\");\n\n if (!this.totalItems || this.totalItems === 0) {\n this.classList.add('empty');\n if (this.hideEmpty)\n this.setAttribute(\"hidden\", \"\");\n\n return;\n }\n\n this.paginateObj = await paginate(this.totalItems, this.page, this.pageSize, this.maxPages) || {};\n }\n\n /**\n * Creates a document fragment, appends a new slot element to it, and returns the fragment.\n * @returns {DocumentFragment} A document fragment containing a slot element.\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('div');\n native.setAttribute('part', 'native');\n native.classList.add('native-pagination');\n\n native.append(this.htmlPagination());\n\n fragment.append(native);\n\n return fragment;\n }\n\n /**\n * Creates a pagination control for navigating between pages of content.\n * This method generates and returns a document fragment containing pagination controls, including buttons for navigating to the first, previous, next, and last pages, as well as optional informational text about the current set of displayed items and total number of items.\n * @returns {DocumentFragment} A document fragment containing the pagination controls.\n */\n htmlPagination() {\n let fragment = document.createDocumentFragment();\n\n let select = document.createElement('wje-select');\n select.setAttribute('size', 'small');\n select.setAttribute('variant', 'standard');\n select.setAttribute('value', this.pageSize);\n select.addEventListener('wje-select:change', (e) => {\n\n if(+e.detail.context.value[0] !== this.pageSize) {\n this.pageSize = +e.detail.context.value[0];\n this.page = 0; // Reset to first page when page size changes\n event.dispatchCustomEvent(this, 'wje-pagination:page-change', { page: this.page, pageSize: this.pageSize });\n }\n });\n\n let options = this.pageSizeOptions.map((o) => {\n let option = document.createElement('wje-option');\n option.value = o;\n option.textContent = o;\n return option;\n });\n\n let info = document.createElement('div');\n info.classList.add('info');\n info.innerHTML = `${this.paginateObj?.startIndex + 1} - ${this.paginateObj?.endIndex + 1} ${this.localizer.translate('wj.pagination.of')} ${this.totalItems}`;\n\n let pagination = document.createElement('div');\n pagination.classList.add('pages');\n\n const button = document.createElement('wje-button');\n button.setAttribute('fill', 'link');\n if (this.round) button.setAttribute('round', '');\n\n // First button\n let firstButton = button.cloneNode(true);\n firstButton.title = this.localizer.translate('wj.pagination.first');\n firstButton.innerHTML = `<wje-icon name=\"chevron-left-pipe\" slot=\"icon-only\"></wje-icon>`;\n firstButton.addEventListener('wje-button:click', (e) => this.pageClickAction(e, 0));\n\n // Previous button\n const prevButton = button.cloneNode(true);\n prevButton.title = this.localizer.translate('wj.pagination.prev');\n prevButton.innerHTML = `<wje-icon name=\"chevron-left\" slot=\"icon-only\"></wje-icon>`;\n if (this.page === 0) prevButton.disabled = true;\n prevButton.addEventListener('wje-button:click', (e) => this.pageClickAction(e, this.page - 1));\n\n // Next button\n const nextButton = button.cloneNode(true);\n nextButton.title = this.localizer.translate('wj.pagination.next');\n nextButton.innerHTML = `<wje-icon name=\"chevron-right\" slot=\"icon-only\"></wje-icon>`;\n if (this.page + 1 >= this.paginateObj?.totalPages) nextButton.disabled = true;\n nextButton.addEventListener('wje-button:click', (e) => this.pageClickAction(e, this.page + 1));\n\n // Last button\n let lastButton = button.cloneNode(true);\n lastButton.title = this.localizer.translate('wj.pagination.last');\n lastButton.innerHTML = `<wje-icon name=\"chevron-right-pipe\" slot=\"icon-only\"></wje-icon>`;\n lastButton.disabled = this.paginateObj?.endIndex + 1 >= this.totalItems;\n lastButton.addEventListener('wje-button:click', (e) =>\n this.pageClickAction(e, this.paginateObj?.totalPages - 1)\n );\n\n select.append(...options);\n\n if (this.showFirstButton) pagination.appendChild(firstButton);\n pagination.appendChild(prevButton);\n pagination.appendChild(this.htmlStackButtons(this.paginateObj));\n pagination.appendChild(nextButton);\n if (this.showLastButton) pagination.appendChild(lastButton);\n\n if (this.showPageSizeOptions) fragment.append(select);\n if (this.showInfo) fragment.appendChild(info);\n fragment.appendChild(pagination);\n\n return fragment;\n }\n\n /**\n * Creates and returns a DocumentFragment containing a series of buttons for pagination purposes,\n * based on the provided pagination object.\n * @param {object} paginateObj An object containing pagination details.\n * @param {number} paginateObj.currentPage The current active page index (1-based).\n * @param {Array<number>} paginateObj.pages An array of page numbers to display in the pagination.\n * @param {number} paginateObj.totalPages Total number of pages available for pagination.\n * @returns {DocumentFragment} A DocumentFragment containing the buttons and additional pagination elements.\n */\n htmlStackButtons(paginateObj) {\n let fragment = document.createDocumentFragment();\n\n const button = document.createElement('wje-button');\n button.setAttribute('fill', 'link');\n if (this.round) button.setAttribute('round', '');\n\n let dots = document.createElement('span');\n dots.classList.add('dots');\n\n const first = button.cloneNode(true);\n first.textContent = '1';\n first.addEventListener('wje-button:click', (e) => this.pageClickAction(e, 0));\n\n const last = button.cloneNode(true);\n last.textContent = paginateObj?.totalPages;\n last.addEventListener('wje-button:click', (e) => this.pageClickAction(e, paginateObj?.totalPages - 1));\n\n if (paginateObj?.currentPage >= this.maxPages + 1 && paginateObj?.boundary < paginateObj?.totalPages) {\n fragment.appendChild(first);\n fragment.appendChild(dots);\n }\n\n paginateObj?.pages.forEach((page) => {\n let newButton = button.cloneNode(true);\n newButton.textContent = page;\n\n if (page - 1 === this.page) {\n newButton.removeAttribute('fill');\n } else {\n newButton.addEventListener('wje-button:click', (e) => this.pageClickAction(e, page - 1));\n }\n\n fragment.appendChild(newButton);\n });\n\n if (\n (paginateObj?.pages.length === this.maxPages || paginateObj?.currentPage < this.maxPages + 1) &&\n paginateObj.boundary < paginateObj?.totalPages\n ) {\n fragment.appendChild(dots.cloneNode(true));\n fragment.appendChild(last);\n }\n\n return fragment;\n }\n\n /**\n * Handles the click action for pagination and updates the current page.\n * If the clicked page number is the same as the current page, no action is performed.\n * Otherwise, the current page is updated to the new page number, and a custom event\n * 'wje-pagination:page-change' is dispatched with the pagination object.\n * @param {Event} e The event triggered by the page click.\n * @param {number} page The page number that was clicked.\n */\n pageClickAction = (e, page) => {\n if (+page === this.page || this.page > this.paginateObj.totalPages) return;\n this.page = page;\n event.dispatchCustomEvent(this, 'wje-pagination:page-change', { page: this.page, pageSize: this.pageSize });\n };\n}\n\nPagination.define('wje-pagination', Pagination);\n","import Pagination from './pagination.element.js';\n\nexport default Pagination;\n\nPagination.define('wje-pagination', Pagination);\n"],"names":["_a"],"mappings":";;;;;;;;AAQO,SAAS,SAAS,YAAY,cAAc,GAAG,WAAW,IAAI,WAAW,GAAG;AAE/E,QAAM,aAAa,KAAK,KAAK,aAAa,QAAQ;AAGlD,MAAI,cAAc,GAAG;AACjB,kBAAc;AAAA,EACtB,WAAe,cAAc,YAAY;AACjC,kBAAc;AAAA,EACtB;AAEI,MAAI;AACJ,MAAI;AAEJ,QAAM,eAAe,WAAW;AAEhC,QAAM,WAAW,eAAe;AAEhC,MAAI,aAAa,UAAU;AACvB,QAAI,cAAc,cAAc;AAE5B,kBAAY;AACZ,gBAAU,KAAK,IAAI,eAAe,GAAG,UAAU;AAAA,IAC3D,WAAmB,eAAe,aAAa,cAAc;AAEjD,kBAAY,KAAK,IAAI,aAAa,cAAc,CAAC;AACjD,gBAAU;A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AACpB,UAAM,iBAAiB,oBAAoB,CAAC,MAAM,KAAK,gBAAgB,GAAG,CAAC,CAAC;AAE5E,UAAM,OAAO,OAAO,UAAU,IAAI;AAClC,SAAK,cAAc,2CAAa;AAChC,SAAK,iBAAiB,oBAAoB,CAAC,MAAM,KAAK,gBAAgB,IAAG,2CAAa,cAAa,CAAC,CAAC;AAErG,SAAI,2CAAa,gBAAe,KAAK,WAAW,MAAK,2CAAa,aAAW,2CAAa,aAAY;AAClG,eAAS,YAAY,KAAK;AAC1B,eAAS,YAAY,IAAI;AAAA,IACrC;AAEQ,+CAAa,MAAM,QAAQ,CAAC,SAAS;AACjC,UAAI,YAAY,OAAO,UAAU,IAAI;AACrC,gBAAU,cAAc;AAExB,UAAI,OAAO,MAAM,KAAK,MAAM;AACxB,kBAAU,gBAAgB,MAAM;AAAA,MAChD,OAAmB;AACH,kBAAU,iBAAiB,oBAAoB,CAAC,MAAM,KAAK,gBAAgB,GAAG,OAAO,CAAC,CAAC;AAAA,MACvG;AAEY,eAAS,YAAY,SAAS;AAAA,IAC1C;AAEQ,UACK,2CAAa,MAAM,YAAW,KAAK,aAAY,2CAAa,eAAc,KAAK,WAAW,MAC3F,YAAY,YAAW,2CAAa,aACtC;AACE,eAAS,YAAY,KAAK,UAAU,IAAI,CAAC;AACzC,eAAS,YAAY,IAAI;AAAA,IACrC;AAEQ,WAAO;AAAA,EACf;AAeA;AAEA,WAAW,OAAO,kBAAkB,UAAU;AClc9C,WAAW,OAAO,kBAAkB,UAAU;"}
|
|
1
|
+
{"version":3,"file":"wje-pagination.js","sources":["../packages/wje-pagination/service/service.js","../packages/wje-pagination/pagination.element.js","../packages/wje-pagination/pagination.js"],"sourcesContent":["/**\n * Paginates items based on the total number of items, current page, page size, and maximum number of pages to display.\n * @param {number} totalItems The total number of items to paginate.\n * @param {number} [currentPage] The current page number (default is 1).\n * @param {number} [pageSize] The number of items per page (default is 10).\n * @param {number} [maxPages] The maximum number of pages to display in the pagination control (default is 5).\n * @returns {object} An object containing pagination details including total items, current page, page size, total pages, start/end page, start/end index, and the pages array.\n */\nexport function paginate(totalItems, currentPage = 1, pageSize = 10, maxPages = 5) {\n // Calculate total pages\n const totalPages = Math.ceil(totalItems / pageSize);\n\n // Ensure current page is within valid range\n if (currentPage < 1) {\n currentPage = 1;\n } else if (currentPage > totalPages) {\n currentPage = totalPages;\n }\n\n let startPage;\n let endPage;\n\n const pagesNearEnd = maxPages + 1; // Define how close to the end we switch back to 5 pages 4\n\n const boundary = pagesNearEnd + 3;\n\n if (totalPages > boundary) {\n if (currentPage < pagesNearEnd) {\n // If in the first 4 pages, show up to 5 pages\n startPage = 1;\n endPage = Math.min(pagesNearEnd + 1, totalPages); //5\n } else if (currentPage >= totalPages - pagesNearEnd) {\n // If within 4 pages from the end, show last 5 pages\n startPage = Math.max(totalPages - pagesNearEnd, 1); //4\n endPage = totalPages;\n } else {\n const halfPages = Math.floor(maxPages / 2);\n // Otherwise, only show 3 pages (current, previous, next)\n startPage = currentPage - halfPages + 1;\n endPage = maxPages % 2 === 1 ? currentPage + halfPages + 1 : currentPage + halfPages - 1;\n }\n } else {\n startPage = 1;\n endPage = totalPages;\n }\n\n // Calculate start and end item indexes\n const startIndex = (currentPage - 1) * pageSize;\n const endIndex = Math.min(startIndex + pageSize - 1, totalItems - 1);\n\n // Create an array of pages to display\n const pages = Array.from({ length: endPage - startPage + 1 }, (_, i) => startPage + i);\n\n // Return object with all pager properties (preserving original format)\n return {\n boundary: boundary,\n currentPage: currentPage,\n endIndex: endIndex,\n endPage: endPage,\n totalPages: totalPages,\n pages: pages,\n pageSize: pageSize,\n startIndex: startIndex,\n startPage: startPage,\n totalItems: totalItems,\n };\n}\n","import { Localizer } from '../utils/localize.js';\nimport { default as WJElement, event } from '../wje-element/element.js';\nimport { paginate } from './service/service.js';\nimport Icon from '../wje-icon/icon.js';\nimport Button from '../wje-button/button.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary This class represents the Pagination component for navigating through paginated content and dynamically updating navigation elements based on attributes like the number of items, page size, etc. Extends the WJElement class.\n * @documentation https://elements.webjet.sk/components/pagination\n * @status stable\n * @augments WJElement\n * @dependency wje-icon, wje-button\n * @csspart native - The wrapper element for the pagination component.\n */\nexport default class Pagination extends WJElement {\n /**\n * Creates an instance of Pagination.\n */\n constructor() {\n super();\n this.localizer = new Localizer(this);\n\n this._paginateObj = null;\n }\n\n /**\n * Sets the value of the 'page' attribute for the object.\n * @param {string} value The value to set for the 'page' attribute.\n */\n set page(value) {\n this.setAttribute('page', value);\n }\n\n /**\n * Retrieves the current page number as a numeric value.\n * @returns {number} The current page number. Returns 0 if the attribute 'page' is not set or is not a numeric value.\n */\n get page() {\n return +this.getAttribute('page') || 0;\n }\n\n /**\n * Sets the maximum number of pages.\n * Updates the 'max-pages' attribute with the provided value.\n * @param {number|string} value The maximum number of pages to set. Can be a number or a parsable string representing a number.\n */\n set maxPages(value) {\n this.setAttribute('max-pages', value);\n }\n\n /**\n * Gets the maximum number of pages.\n * This getter retrieves the value of the \"max-pages\" attribute from the element.\n * If the attribute is not set or is invalid, it defaults to 3.\n * @returns {number} The maximum number of pages as a numeric value.\n */\n get maxPages() {\n return +this.getAttribute('max-pages') || 10;\n }\n\n /**\n * Sets the `pageSize` attribute to the specified value.\n * @param {number|string} value The desired page size value. This can be a number or a string representation of the size.\n */\n set pageSize(value) {\n this.setAttribute('page-size', value);\n }\n\n /**\n * Retrieves the value of the 'page-size' attribute and converts it to a number.\n * If the attribute is not set or is invalid, returns the default value of 3.\n * @returns {number} The numeric value of the 'page-size' attribute or the default value of 3.\n */\n get pageSize() {\n return +this.getAttribute('page-size') || 3;\n }\n\n /**\n * Sets the total number of items.\n * @param {number} value The new total number of items to set.\n */\n set totalItems(value) {\n this.setAttribute('total-items', value);\n }\n\n /**\n * Retrieves the total number of items represented by the 'total-items' attribute.\n * @returns {number} The total number of items. Defaults to 0 if the attribute is not set or is invalid.\n */\n get totalItems() {\n return +this.getAttribute('total-items') || 0;\n }\n\n /**\n * Sets the visibility of the first button based on the provided value.\n * Adds the 'show-first-button' attribute when the value is truthy, and removes it otherwise.\n * @param {boolean} value Determines whether to show the first button. If true, the 'show-first-button' attribute is added; if false, it is removed.\n */\n set showFirstButton(value) {\n this.removeAttribute('show-first-button');\n\n if (value) {\n this.setAttribute('show-first-button', '');\n }\n }\n\n /**\n * Determines whether the 'show-first-button' attribute is present on the element.\n * @returns {boolean} True if the 'show-first-button' attribute is set; otherwise, false.\n */\n get showFirstButton() {\n return this.hasAttribute('show-first-button');\n }\n\n /**\n * Sets the visibility of the \"last\" button. This method controls the presence\n * or absence of the \"show-last-button\" attribute based on the provided value.\n * @param {boolean} value A boolean value indicating whether to show the \"last\" button.\n * If true, the \"show-last-button\" attribute is added;\n * if false, the attribute is removed.\n */\n set showLastButton(value) {\n this.removeAttribute('show-last-button');\n\n if (value) {\n this.setAttribute('show-last-button', '');\n }\n }\n\n /**\n * Determines if the 'show-last-button' attribute is present on the element.\n * @returns {boolean} True if the 'show-last-button' attribute is present, otherwise false.\n */\n get showLastButton() {\n return this.hasAttribute('show-last-button');\n }\n\n /**\n * Sets the pagination object by calculating the pagination details\n * based on the total items, current page, page size, and maximum pages.\n * @param {object} value The value to set the pagination object. The pagination details are computed internally.\n */\n set paginateObj(value) {\n this._paginateObj = value;\n }\n\n /**\n * Retrieves the pagination object used for managing paginated data.\n * @returns {object} The pagination object containing details and functionality for paginating data.\n */\n get paginateObj() {\n return this._paginateObj;\n }\n\n /**\n * Sets the 'round' attribute on the element. If the provided value is truthy,\n * the 'round' attribute is added. If the value is falsy, the attribute is removed.\n * @param {boolean} value A boolean value determining whether to add or remove the 'round' attribute.\n */\n set round(value) {\n this.removeAttribute('round');\n\n if (value) {\n this.setAttribute('round', '');\n }\n }\n\n /**\n * Retrieves the value of the 'round' attribute for the current element.\n * @returns {boolean} A boolean indicating whether the 'round' attribute is present on the element.\n */\n get round() {\n return this.hasAttribute('round');\n }\n\n /**\n * Sets the `show-info` attribute on the element based on the provided value.\n * @param {boolean} value A boolean indicating whether to add or remove the `show-info` attribute.\n */\n set showInfo(value) {\n this.removeAttribute('show-info');\n\n if (value) {\n this.setAttribute('show-info', '');\n }\n }\n\n /**\n * Retrieves the value of the 'show-info' attribute.\n * Checks if the 'show-info' attribute is present on the element.\n * @returns {boolean} True if the 'show-info' attribute is present, otherwise false.\n */\n get showInfo() {\n return this.hasAttribute('show-info');\n }\n\n set showPageSizeOptions(value) {\n if (!value) return;\n this.setAttribute('show-page-size-options', value);\n }\n\n get showPageSizeOptions() {\n return this.hasAttribute('show-page-size-options');\n }\n\n set pageSizeOptions(value) {\n if (!value) return;\n this.setAttribute('page-size-options', value);\n }\n\n /**\n * Retrieves the list of available page size options.\n * This method is used to fetch the values representing the different page size options\n * that can be provided or configured in a paginated component or system.\n * @returns {Array<number>} An array of numbers representing the selectable page size options.\n */\n get pageSizeOptions() {\n let options = this.getAttribute('page-size-options');\n if (!options) return [6, 10, 50, 100, 500];\n return options.split(',').map((o) => +o).filter((o) => !isNaN(o));\n }\n\n set hideEmpty(value) {\n if (!value) return;\n this.setAttribute('hide-empty', value);\n }\n\n get hideEmpty() {\n return this.hasAttribute('hide-empty');\n }\n\n /**\n * Dependencies of the Button element.\n * @type {object}\n */\n dependencies = {\n 'wje-icon': Icon,\n 'wje-button': Button,\n };\n\n className = 'Pagination';\n\n /**\n * Returns the CSS styles for the component.\n * @static\n * @returns {CSSStyleSheet}\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Getter for the observedAttributes attribute of the input element.\n * @returns {Array} The attributes to observe for changes.\n */\n static get observedAttributes() {\n return ['page', 'total-items', 'page-size'];\n }\n\n /**\n * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n this.setAriaState({\n role: 'navigation',\n });\n }\n\n async beforeDraw() {\n this.classList.remove('empty');\n this.removeAttribute(\"hidden\");\n\n if (!this.totalItems || this.totalItems === 0) {\n this.classList.add('empty');\n if (this.hideEmpty)\n this.setAttribute(\"hidden\", \"\");\n\n return;\n }\n\n this.paginateObj = await paginate(this.totalItems, this.page + 1, this.pageSize, this.maxPages) || {};\n }\n\n /**\n * Creates a document fragment, appends a new slot element to it, and returns the fragment.\n * @returns {DocumentFragment} A document fragment containing a slot element.\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('div');\n native.setAttribute('part', 'native');\n native.classList.add('native-pagination');\n\n native.append(this.htmlPagination());\n\n fragment.append(native);\n\n return fragment;\n }\n\n /**\n * Creates a pagination control for navigating between pages of content.\n * This method generates and returns a document fragment containing pagination controls, including buttons for navigating to the first, previous, next, and last pages, as well as optional informational text about the current set of displayed items and total number of items.\n * @returns {DocumentFragment} A document fragment containing the pagination controls.\n */\n htmlPagination() {\n let fragment = document.createDocumentFragment();\n\n let select = document.createElement('wje-select');\n select.setAttribute('size', 'small');\n select.setAttribute('variant', 'standard');\n select.setAttribute('value', this.pageSize);\n select.addEventListener('wje-select:change', (e) => {\n\n if(+e.detail.context.value[0] !== this.pageSize) {\n this.pageSize = +e.detail.context.value[0];\n this.page = 0; // Reset to first page when page size changes\n event.dispatchCustomEvent(this, 'wje-pagination:page-change', { page: this.page, pageSize: this.pageSize });\n }\n });\n\n let options = this.pageSizeOptions.map((o) => {\n let option = document.createElement('wje-option');\n option.value = o;\n option.textContent = o;\n return option;\n });\n\n let info = document.createElement('div');\n info.classList.add('info');\n info.innerHTML = `${this.paginateObj?.startIndex + 1} - ${this.paginateObj?.endIndex + 1} ${this.localizer.translate('wj.pagination.of')} ${this.totalItems}`;\n\n let pagination = document.createElement('div');\n pagination.classList.add('pages');\n\n const button = document.createElement('wje-button');\n button.setAttribute('fill', 'link');\n if (this.round) button.setAttribute('round', '');\n\n // First button\n let firstButton = button.cloneNode(true);\n firstButton.title = this.localizer.translate('wj.pagination.first');\n firstButton.setAttribute('aria-label', firstButton.title);\n firstButton.innerHTML = `<wje-icon name=\"chevron-left-pipe\" slot=\"icon-only\"></wje-icon>`;\n firstButton.addEventListener('click', (e) => this.pageClickAction(e, 0));\n\n // Previous button\n const prevButton = button.cloneNode(true);\n prevButton.title = this.localizer.translate('wj.pagination.prev');\n prevButton.setAttribute('aria-label', prevButton.title);\n prevButton.innerHTML = `<wje-icon name=\"chevron-left\" slot=\"icon-only\"></wje-icon>`;\n if (this.page === 0) prevButton.disabled = true;\n prevButton.addEventListener('click', (e) => this.pageClickAction(e, this.page - 1));\n\n // Next button\n const nextButton = button.cloneNode(true);\n nextButton.title = this.localizer.translate('wj.pagination.next');\n nextButton.setAttribute('aria-label', nextButton.title);\n nextButton.innerHTML = `<wje-icon name=\"chevron-right\" slot=\"icon-only\"></wje-icon>`;\n if (this.page + 1 >= this.paginateObj?.totalPages) nextButton.disabled = true;\n nextButton.addEventListener('click', (e) => this.pageClickAction(e, this.page + 1));\n\n // Last button\n let lastButton = button.cloneNode(true);\n lastButton.title = this.localizer.translate('wj.pagination.last');\n lastButton.setAttribute('aria-label', lastButton.title);\n lastButton.innerHTML = `<wje-icon name=\"chevron-right-pipe\" slot=\"icon-only\"></wje-icon>`;\n lastButton.disabled = this.paginateObj?.endIndex + 1 >= this.totalItems;\n lastButton.addEventListener('click', (e) =>\n this.pageClickAction(e, this.paginateObj?.totalPages - 1)\n );\n\n select.append(...options);\n\n if (this.showFirstButton) pagination.appendChild(firstButton);\n pagination.appendChild(prevButton);\n pagination.appendChild(this.htmlStackButtons(this.paginateObj));\n pagination.appendChild(nextButton);\n if (this.showLastButton) pagination.appendChild(lastButton);\n\n if (this.showPageSizeOptions) fragment.append(select);\n if (this.showInfo) fragment.appendChild(info);\n fragment.appendChild(pagination);\n\n return fragment;\n }\n\n /**\n * Creates and returns a DocumentFragment containing a series of buttons for pagination purposes,\n * based on the provided pagination object.\n * @param {object} paginateObj An object containing pagination details.\n * @param {number} paginateObj.currentPage The current active page index (1-based).\n * @param {Array<number>} paginateObj.pages An array of page numbers to display in the pagination.\n * @param {number} paginateObj.totalPages Total number of pages available for pagination.\n * @returns {DocumentFragment} A DocumentFragment containing the buttons and additional pagination elements.\n */\n htmlStackButtons(paginateObj) {\n let fragment = document.createDocumentFragment();\n\n const button = document.createElement('wje-button');\n button.setAttribute('fill', 'link');\n if (this.round) button.setAttribute('round', '');\n\n let dots = document.createElement('span');\n dots.classList.add('dots');\n dots.setAttribute('aria-hidden', 'true');\n\n const first = button.cloneNode(true);\n first.textContent = '1';\n first.addEventListener('click', (e) => this.pageClickAction(e, 0));\n\n const last = button.cloneNode(true);\n last.textContent = paginateObj?.totalPages;\n last.addEventListener('click', (e) => this.pageClickAction(e, paginateObj?.totalPages - 1));\n\n if (paginateObj?.currentPage >= this.maxPages + 1 && paginateObj?.boundary < paginateObj?.totalPages) {\n fragment.appendChild(first);\n fragment.appendChild(dots);\n }\n\n paginateObj?.pages.forEach((page) => {\n let newButton = button.cloneNode(true);\n newButton.textContent = page;\n\n if (page - 1 === this.page) {\n newButton.removeAttribute('fill');\n newButton.setAttribute('aria-current', 'page');\n } else {\n newButton.addEventListener('click', (e) => this.pageClickAction(e, page - 1));\n }\n\n fragment.appendChild(newButton);\n });\n\n if (\n (paginateObj?.pages.length === this.maxPages || paginateObj?.currentPage < this.maxPages + 1) &&\n paginateObj.boundary < paginateObj?.totalPages\n ) {\n fragment.appendChild(dots.cloneNode(true));\n fragment.appendChild(last);\n }\n\n return fragment;\n }\n\n /**\n * Handles the click action for pagination and updates the current page.\n * If the clicked page number is the same as the current page, no action is performed.\n * Otherwise, the current page is updated to the new page number, and a custom event\n * 'wje-pagination:page-change' is dispatched with the pagination object.\n * @param {Event} e The event triggered by the page click.\n * @param {number} page The page number that was clicked.\n */\n pageClickAction = (e, page) => {\n if (+page === this.page || this.page > this.paginateObj.totalPages) return;\n this.page = page;\n event.dispatchCustomEvent(this, 'wje-pagination:page-change', { page: this.page, pageSize: this.pageSize });\n };\n}\n\nPagination.define('wje-pagination', Pagination);\n","import Pagination from './pagination.element.js';\n\nexport default Pagination;\n\nPagination.define('wje-pagination', Pagination);\n"],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AAM;AAChC,kBAAU,aAAa,gBAAgB,MAAM;AAAA,MAC7D,OAAmB;AACH,kBAAU,iBAAiB,SAAS,CAAC,MAAM,KAAK,gBAAgB,GAAG,OAAO,CAAC,CAAC;AAAA,MAC5F;AAEY,eAAS,YAAY,SAAS;AAAA,IAC1C;AAEQ,UACK,2CAAa,MAAM,YAAW,KAAK,aAAY,2CAAa,eAAc,KAAK,WAAW,MAC3F,YAAY,YAAW,2CAAa,aACtC;AACE,eAAS,YAAY,KAAK,UAAU,IAAI,CAAC;AACzC,eAAS,YAAY,IAAI;AAAA,IACrC;AAEQ,WAAO;AAAA,EACf;AAeA;AAEA,WAAW,OAAO,kBAAkB,UAAU;AC3c9C,WAAW,OAAO,kBAAkB,UAAU;"}
|
package/dist/wje-popup.js
CHANGED
package/dist/wje-progress-bar.js
CHANGED
|
@@ -82,6 +82,7 @@ class ProgressBar extends WJElement {
|
|
|
82
82
|
*/
|
|
83
83
|
setupAttributes() {
|
|
84
84
|
this.isShadowRoot = "open";
|
|
85
|
+
this.syncAria();
|
|
85
86
|
}
|
|
86
87
|
/**
|
|
87
88
|
* Draws the component.
|
|
@@ -168,6 +169,31 @@ class ProgressBar extends WJElement {
|
|
|
168
169
|
this.bar = bar;
|
|
169
170
|
return fragment;
|
|
170
171
|
}
|
|
172
|
+
/**
|
|
173
|
+
* Handles attribute changes for ARIA sync.
|
|
174
|
+
* @param {string} name
|
|
175
|
+
* @param {string|null} oldValue
|
|
176
|
+
* @param {string|null} newValue
|
|
177
|
+
*/
|
|
178
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
179
|
+
if (super.attributeChangedCallback) {
|
|
180
|
+
super.attributeChangedCallback(name, oldValue, newValue);
|
|
181
|
+
}
|
|
182
|
+
if (name === "progress" && oldValue !== newValue) {
|
|
183
|
+
this.syncAria();
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Sync ARIA attributes on host.
|
|
188
|
+
*/
|
|
189
|
+
syncAria() {
|
|
190
|
+
this.setAriaState({
|
|
191
|
+
role: "progressbar",
|
|
192
|
+
valuemin: 0,
|
|
193
|
+
valuemax: 100,
|
|
194
|
+
valuenow: this.progress || 0
|
|
195
|
+
});
|
|
196
|
+
}
|
|
171
197
|
/**
|
|
172
198
|
* Adds event listeners after the component is drawn.
|
|
173
199
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wje-progress-bar.js","sources":["../packages/wje-progress-bar/progress-bar.element.js","../packages/wje-progress-bar/progress-bar.js"],"sourcesContent":["import { default as WJElement } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * `ProgressBar` is a custom web component that represents a progress bar.\n * @summary This element represents a progress bar.\n * @documentation https://elements.webjet.sk/components/progress-bar\n * @status stable\n * @augments {WJElement}\n * @slot - The default slot for the progress bar.\n * @slot start - The start slot of the progress bar.\n * @slot end - The end slot of the progress bar.\n * @cssproperty [--wje-progress-bar-color=var(--wje-color-contrast-6)] - Sets the color of the progress bar. This property controls the fill color of the progress indicator. Accepts any valid CSS color value, such as named colors (`red`), hex values (`#ff0000`), or CSS variables.\n * @cssproperty [--wje-progress-bar-text-size=.75rem] - Defines the font size of the text displayed within the progress bar. Accepts any valid CSS length unit (e.g., `rem`, `px`, `em`) to control text size relative to the bar's design.\n * @cssproperty [--wje-progress-bar-text-color=var(--wje-color)] - Specifies the color of the text displayed within the progress bar. Accepts any valid CSS color value to ensure contrast and readability against the progress bar's background.\n * @tag wje-progress-bar\n */\nexport default class ProgressBar extends WJElement {\n /**\n * Creates an instance of ProgressBar.\n * @class\n */\n constructor() {\n super();\n }\n\n /**\n * Sets the radius of the progress bar.\n * @param {number} value The value to set.\n */\n set radius(value) {\n this.setAttribute('radius', value);\n }\n\n /**\n * Gets the radius of the progress bar.\n * @returns {number} The value of the radius.\n */\n get radius() {\n return +this.getAttribute('radius') || 70;\n }\n\n /**\n * Gets the diameter of the progress bar.\n * @returns {number} The value of the diameter.\n */\n get diameter() {\n return this.radius * 2;\n }\n\n /**\n * Gets the diameter of the progress bar.\n * @returns {number} The value of the diameter.\n */\n get containerSize() {\n return this.diameter + 2 * this.stroke;\n }\n\n /**\n * Sets the stroke of the progress bar.\n * @param {number} value The value to set.\n */\n set stroke(value) {\n this.setAttribute('stroke', value);\n }\n\n /**\n * Gets the stroke of the progress bar.\n * @returns {number} The value of the stroke.\n */\n get stroke() {\n return +this.getAttribute('stroke') || 6;\n }\n\n /**\n * Gets the linecap of the progress bar.\n * @returns {string} The value of the linecap.\n */\n get linecap() {\n return this.getAttribute('linecap') || 'square';\n }\n\n className = 'ProgressBar';\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 ['progress'];\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 xy = this.radius + this.stroke / 2;\n\n let fragment = document.createDocumentFragment();\n\n if (params.color) this.classList.add('wje-color');\n\n let element = document.createElement('div');\n element.classList.add('progress');\n\n let slot = document.createElement('slot');\n\n let slotWrapper = document.createElement('div');\n slotWrapper.classList.add('slot-wrapper');\n\n let slotStart = document.createElement('slot');\n slotStart.setAttribute('name', 'start');\n\n let slotEnd = document.createElement('slot');\n slotEnd.setAttribute('name', 'end');\n\n const svgNamespace = 'http://www.w3.org/2000/svg';\n\n let svg = document.createElementNS(svgNamespace, 'svg');\n\n let background;\n let bar;\n\n if (this?.type === 'circle') {\n svg.setAttribute('width', this.containerSize);\n svg.setAttribute('height', this.containerSize);\n svg.setAttribute('viewBox', `0 0 ${this.containerSize} ${this.containerSize}`);\n svg.setAttribute('style', 'transform: rotate(-90deg)');\n\n background = document.createElementNS(svgNamespace, 'circle');\n background.setAttribute('stroke', 'var(--wje-progress-bar-background-color)');\n background.setAttribute('stroke-width', this.stroke);\n background.setAttribute('fill', 'transparent');\n background.setAttribute('r', this.radius);\n background.setAttribute('cx', this.containerSize / 2);\n background.setAttribute('cy', this.containerSize / 2);\n\n bar = document.createElementNS(svgNamespace, 'circle');\n bar.setAttribute('stroke', 'var(--wje-progress-bar-color)');\n bar.setAttribute('stroke-width', this.stroke);\n bar.setAttribute('fill', 'transparent');\n bar.setAttribute('r', this.radius);\n bar.setAttribute('cx', this.containerSize / 2);\n bar.setAttribute('cy', this.containerSize / 2);\n bar.setAttribute('stroke-linecap', this.linecap);\n\n let text = document.createElementNS(svgNamespace, 'text');\n text.setAttribute('x', '50%');\n text.setAttribute('y', '50%');\n text.innerHTML = this.progress + '%';\n\n svg.appendChild(text);\n } else {\n svg.setAttribute('width', '100%');\n svg.setAttribute('height', this.stroke);\n svg.setAttribute('preserveAspectRatio', 'none');\n\n background = document.createElementNS(svgNamespace, 'rect');\n background.setAttribute('x', 0);\n background.setAttribute('y', 0);\n background.setAttribute('width', '100%');\n background.setAttribute('height', this.stroke);\n if (this.linecap === 'round') {\n background.setAttribute('rx', this.stroke / 2);\n background.setAttribute('ry', this.stroke / 2);\n }\n\n bar = document.createElementNS(svgNamespace, 'rect');\n bar.setAttribute('x', 0);\n bar.setAttribute('y', 0);\n bar.setAttribute('width', this.progress + '%');\n bar.setAttribute('height', this.stroke);\n bar.setAttribute('id', 'bar');\n\n if (this.linecap === 'round') {\n bar.setAttribute('rx', this.stroke / 2);\n bar.setAttribute('ry', this.stroke / 2);\n }\n }\n\n svg.appendChild(background);\n svg.appendChild(bar);\n\n slotWrapper.appendChild(slot);\n\n element.appendChild(slotStart);\n element.appendChild(slotWrapper);\n element.appendChild(svg);\n element.appendChild(slotEnd);\n\n fragment.appendChild(element);\n\n this.background = background;\n this.bar = bar;\n\n return fragment;\n }\n\n /**\n * Adds event listeners after the component is drawn.\n */\n afterDraw() {\n if (this.type === 'circle') {\n this.setCircleProgress(this.progress);\n }\n }\n\n /**\n * Returns the dasharray for a circle with the given radius.\n * @param {number} radius The radius of the circle in pixels.\n * @returns {number} The dasharray value.\n */\n getCircleDasharray(radius = 70) {\n return 2 * Math.PI * radius;\n }\n\n /**\n * Returns the dashoffset for a circle with the given progress and radius.\n * @param {number} progress The progress of the circle in percentage.\n * @param {number} radius The radius of the circle in pixels.\n * @returns {number} The dashoffset value.\n */\n getCircleDashoffset(progress = 0, radius = 70) {\n return this.getCircleDasharray(radius) * ((100 - progress) / 100);\n }\n\n /**\n * Sets the progress of the circle.\n * @param percent\n */\n setCircleProgress(percent) {\n const progress = this.bar;\n const radius = progress.r.baseVal.value;\n const circumference = 2 * Math.PI * radius;\n\n progress.style.strokeDasharray = `${circumference}`;\n const offset = circumference - (percent / 100) * circumference;\n progress.style.strokeDashoffset = offset;\n }\n}\n","import ProgressBar from './progress-bar.element.js';\n\nexport default ProgressBar;\n\nProgressBar.define('wje-progress-bar', ProgressBar);\n"],"names":[],"mappings":";;;;;AAiBe,MAAM,oBAAoB,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA,EAK/C,cAAc;AACV,UAAO;AA2DX,qCAAY;AAAA,EA1DhB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,OAAO,OAAO;AACd,SAAK,aAAa,UAAU,KAAK;AAAA,EACzC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,SAAS;AACT,WAAO,CAAC,KAAK,aAAa,QAAQ,KAAK;AAAA,EAC/C;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,WAAW;AACX,WAAO,KAAK,SAAS;AAAA,EAC7B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,gBAAgB;AAChB,WAAO,KAAK,WAAW,IAAI,KAAK;AAAA,EACxC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,OAAO,OAAO;AACd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AmB;AAAA,EAC1C;AACA;AChQA,YAAY,OAAO,oBAAoB,WAAW;"}
|
|
1
|
+
{"version":3,"file":"wje-progress-bar.js","sources":["../packages/wje-progress-bar/progress-bar.element.js","../packages/wje-progress-bar/progress-bar.js"],"sourcesContent":["import { default as WJElement } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * `ProgressBar` is a custom web component that represents a progress bar.\n * @summary This element represents a progress bar.\n * @documentation https://elements.webjet.sk/components/progress-bar\n * @status stable\n * @augments {WJElement}\n * @slot - The default slot for the progress bar.\n * @slot start - The start slot of the progress bar.\n * @slot end - The end slot of the progress bar.\n * @cssproperty [--wje-progress-bar-color=var(--wje-color-contrast-6)] - Sets the color of the progress bar. This property controls the fill color of the progress indicator. Accepts any valid CSS color value, such as named colors (`red`), hex values (`#ff0000`), or CSS variables.\n * @cssproperty [--wje-progress-bar-text-size=.75rem] - Defines the font size of the text displayed within the progress bar. Accepts any valid CSS length unit (e.g., `rem`, `px`, `em`) to control text size relative to the bar's design.\n * @cssproperty [--wje-progress-bar-text-color=var(--wje-color)] - Specifies the color of the text displayed within the progress bar. Accepts any valid CSS color value to ensure contrast and readability against the progress bar's background.\n * @tag wje-progress-bar\n */\nexport default class ProgressBar extends WJElement {\n /**\n * Creates an instance of ProgressBar.\n * @class\n */\n constructor() {\n super();\n }\n\n /**\n * Sets the radius of the progress bar.\n * @param {number} value The value to set.\n */\n set radius(value) {\n this.setAttribute('radius', value);\n }\n\n /**\n * Gets the radius of the progress bar.\n * @returns {number} The value of the radius.\n */\n get radius() {\n return +this.getAttribute('radius') || 70;\n }\n\n /**\n * Gets the diameter of the progress bar.\n * @returns {number} The value of the diameter.\n */\n get diameter() {\n return this.radius * 2;\n }\n\n /**\n * Gets the diameter of the progress bar.\n * @returns {number} The value of the diameter.\n */\n get containerSize() {\n return this.diameter + 2 * this.stroke;\n }\n\n /**\n * Sets the stroke of the progress bar.\n * @param {number} value The value to set.\n */\n set stroke(value) {\n this.setAttribute('stroke', value);\n }\n\n /**\n * Gets the stroke of the progress bar.\n * @returns {number} The value of the stroke.\n */\n get stroke() {\n return +this.getAttribute('stroke') || 6;\n }\n\n /**\n * Gets the linecap of the progress bar.\n * @returns {string} The value of the linecap.\n */\n get linecap() {\n return this.getAttribute('linecap') || 'square';\n }\n\n className = 'ProgressBar';\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 ['progress'];\n }\n\n /**\n * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n this.syncAria();\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 xy = this.radius + this.stroke / 2;\n\n let fragment = document.createDocumentFragment();\n\n if (params.color) this.classList.add('wje-color');\n\n let element = document.createElement('div');\n element.classList.add('progress');\n\n let slot = document.createElement('slot');\n\n let slotWrapper = document.createElement('div');\n slotWrapper.classList.add('slot-wrapper');\n\n let slotStart = document.createElement('slot');\n slotStart.setAttribute('name', 'start');\n\n let slotEnd = document.createElement('slot');\n slotEnd.setAttribute('name', 'end');\n\n const svgNamespace = 'http://www.w3.org/2000/svg';\n\n let svg = document.createElementNS(svgNamespace, 'svg');\n\n let background;\n let bar;\n\n if (this?.type === 'circle') {\n svg.setAttribute('width', this.containerSize);\n svg.setAttribute('height', this.containerSize);\n svg.setAttribute('viewBox', `0 0 ${this.containerSize} ${this.containerSize}`);\n svg.setAttribute('style', 'transform: rotate(-90deg)');\n\n background = document.createElementNS(svgNamespace, 'circle');\n background.setAttribute('stroke', 'var(--wje-progress-bar-background-color)');\n background.setAttribute('stroke-width', this.stroke);\n background.setAttribute('fill', 'transparent');\n background.setAttribute('r', this.radius);\n background.setAttribute('cx', this.containerSize / 2);\n background.setAttribute('cy', this.containerSize / 2);\n\n bar = document.createElementNS(svgNamespace, 'circle');\n bar.setAttribute('stroke', 'var(--wje-progress-bar-color)');\n bar.setAttribute('stroke-width', this.stroke);\n bar.setAttribute('fill', 'transparent');\n bar.setAttribute('r', this.radius);\n bar.setAttribute('cx', this.containerSize / 2);\n bar.setAttribute('cy', this.containerSize / 2);\n bar.setAttribute('stroke-linecap', this.linecap);\n\n let text = document.createElementNS(svgNamespace, 'text');\n text.setAttribute('x', '50%');\n text.setAttribute('y', '50%');\n text.innerHTML = this.progress + '%';\n\n svg.appendChild(text);\n } else {\n svg.setAttribute('width', '100%');\n svg.setAttribute('height', this.stroke);\n svg.setAttribute('preserveAspectRatio', 'none');\n\n background = document.createElementNS(svgNamespace, 'rect');\n background.setAttribute('x', 0);\n background.setAttribute('y', 0);\n background.setAttribute('width', '100%');\n background.setAttribute('height', this.stroke);\n if (this.linecap === 'round') {\n background.setAttribute('rx', this.stroke / 2);\n background.setAttribute('ry', this.stroke / 2);\n }\n\n bar = document.createElementNS(svgNamespace, 'rect');\n bar.setAttribute('x', 0);\n bar.setAttribute('y', 0);\n bar.setAttribute('width', this.progress + '%');\n bar.setAttribute('height', this.stroke);\n bar.setAttribute('id', 'bar');\n\n if (this.linecap === 'round') {\n bar.setAttribute('rx', this.stroke / 2);\n bar.setAttribute('ry', this.stroke / 2);\n }\n }\n\n svg.appendChild(background);\n svg.appendChild(bar);\n\n slotWrapper.appendChild(slot);\n\n element.appendChild(slotStart);\n element.appendChild(slotWrapper);\n element.appendChild(svg);\n element.appendChild(slotEnd);\n\n fragment.appendChild(element);\n\n this.background = background;\n this.bar = bar;\n\n return fragment;\n }\n\n /**\n * Handles attribute changes for ARIA sync.\n * @param {string} name\n * @param {string|null} oldValue\n * @param {string|null} newValue\n */\n attributeChangedCallback(name, oldValue, newValue) {\n if (super.attributeChangedCallback) {\n super.attributeChangedCallback(name, oldValue, newValue);\n }\n\n if (name === 'progress' && oldValue !== newValue) {\n this.syncAria();\n }\n }\n\n /**\n * Sync ARIA attributes on host.\n */\n syncAria() {\n this.setAriaState({\n role: 'progressbar',\n valuemin: 0,\n valuemax: 100,\n valuenow: this.progress || 0,\n });\n }\n\n /**\n * Adds event listeners after the component is drawn.\n */\n afterDraw() {\n if (this.type === 'circle') {\n this.setCircleProgress(this.progress);\n }\n }\n\n /**\n * Returns the dasharray for a circle with the given radius.\n * @param {number} radius The radius of the circle in pixels.\n * @returns {number} The dasharray value.\n */\n getCircleDasharray(radius = 70) {\n return 2 * Math.PI * radius;\n }\n\n /**\n * Returns the dashoffset for a circle with the given progress and radius.\n * @param {number} progress The progress of the circle in percentage.\n * @param {number} radius The radius of the circle in pixels.\n * @returns {number} The dashoffset value.\n */\n getCircleDashoffset(progress = 0, radius = 70) {\n return this.getCircleDasharray(radius) * ((100 - progress) / 100);\n }\n\n /**\n * Sets the progress of the circle.\n * @param percent\n */\n setCircleProgress(percent) {\n const progress = this.bar;\n const radius = progress.r.baseVal.value;\n const circumference = 2 * Math.PI * radius;\n\n progress.style.strokeDasharray = `${circumference}`;\n const offset = circumference - (percent / 100) * circumference;\n progress.style.strokeDashoffset = offset;\n }\n}\n","import ProgressBar from './progress-bar.element.js';\n\nexport default ProgressBar;\n\nProgressBar.define('wje-progress-bar', ProgressBar);\n"],"names":[],"mappings":";;;;;AAiBe,MAAM,oBAAoB,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA,EAK/C,cAAc;AACV,UAAO;AA2DX,qCAAY;AAAA,EA1DhB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,OAAO,OAAO;AACd,SAAK,aAAa,UAAU,KAAK;AAAA,EACzC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,SAAS;AACT,WAAO,CAAC,KAAK,aAAa,QAAQ,KAAK;AAAA,EAC/C;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,WAAW;AACX,WAAO,KAAK,SAAS;AAAA,EAC7B;AAA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