wj-elements 0.7.7 → 0.8.0
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/animations.js +28 -51
- package/dist/animations.js.map +1 -1
- package/dist/base-path.js +19 -31
- package/dist/base-path.js.map +1 -1
- package/dist/custom-elements.json +11504 -11499
- package/dist/dark.css +1 -302
- package/dist/date.js +16 -36
- package/dist/date.js.map +1 -1
- package/dist/element-utils.js +20 -81
- package/dist/element-utils.js.map +1 -1
- package/dist/event.js +49 -165
- package/dist/event.js.map +1 -1
- package/dist/form-associated-element-BjeJn7j8.js +101 -0
- package/dist/{form-associated-element-DEQ4y-jn.js.map → form-associated-element-BjeJn7j8.js.map} +1 -1
- package/dist/icon-DmsqtDpL.js +102 -0
- package/dist/{icon-CReYMzAK.js.map → icon-DmsqtDpL.js.map} +1 -1
- package/dist/light.css +1 -731
- package/dist/localize.js +36 -111
- package/dist/localize.js.map +1 -1
- package/dist/packages/wje-accordion-item/accordion-item.element.d.ts +3 -2
- package/dist/permissions.js +14 -41
- package/dist/permissions.js.map +1 -1
- package/dist/popup.element-CbkhthPP.js +806 -0
- package/dist/{popup.element-CwXvVFK7.js.map → popup.element-CbkhthPP.js.map} +1 -1
- package/dist/router-links-CNsJ-elb.js +105 -0
- package/dist/{router-links-wjqCnncc.js.map → router-links-CNsJ-elb.js.map} +1 -1
- package/dist/skeleton.css +1 -197
- package/dist/styles.css +1 -866
- package/dist/universal-service.js +48 -109
- package/dist/universal-service.js.map +1 -1
- package/dist/utils.js +11 -18
- package/dist/utils.js.map +1 -1
- package/dist/web-types.json +760 -760
- package/dist/wje-accordion-item.js +33 -106
- package/dist/wje-accordion-item.js.map +1 -1
- package/dist/wje-accordion.js +19 -84
- package/dist/wje-accordion.js.map +1 -1
- package/dist/wje-animation.js +37 -4258
- package/dist/wje-animation.js.map +1 -1
- package/dist/wje-aside.js +9 -34
- package/dist/wje-aside.js.map +1 -1
- package/dist/wje-avatar.js +36 -126
- package/dist/wje-avatar.js.map +1 -1
- package/dist/wje-badge.js +10 -52
- package/dist/wje-badge.js.map +1 -1
- package/dist/wje-breadcrumb.js +205 -672
- package/dist/wje-breadcrumb.js.map +1 -1
- package/dist/wje-breadcrumbs.js +177 -633
- package/dist/wje-breadcrumbs.js.map +1 -1
- package/dist/wje-button-group.js +48 -153
- package/dist/wje-button-group.js.map +1 -1
- package/dist/wje-button.js +92 -413
- package/dist/wje-button.js.map +1 -1
- package/dist/wje-card-content.js +7 -30
- package/dist/wje-card-content.js.map +1 -1
- package/dist/wje-card-controls.js +7 -30
- package/dist/wje-card-controls.js.map +1 -1
- package/dist/wje-card-header.js +7 -30
- package/dist/wje-card-header.js.map +1 -1
- package/dist/wje-card-subtitle.js +7 -34
- package/dist/wje-card-subtitle.js.map +1 -1
- package/dist/wje-card-title.js +7 -34
- package/dist/wje-card-title.js.map +1 -1
- package/dist/wje-card.js +15 -71
- package/dist/wje-card.js.map +1 -1
- package/dist/wje-carousel-item.js +12 -56
- package/dist/wje-carousel-item.js.map +1 -1
- package/dist/wje-carousel.js +154 -509
- package/dist/wje-carousel.js.map +1 -1
- package/dist/wje-checkbox.js +50 -227
- package/dist/wje-checkbox.js.map +1 -1
- package/dist/wje-chip.js +43 -160
- package/dist/wje-chip.js.map +1 -1
- package/dist/wje-col.js +7 -20
- package/dist/wje-col.js.map +1 -1
- package/dist/wje-color-picker.js +445 -1464
- package/dist/wje-color-picker.js.map +1 -1
- package/dist/wje-container.js +9 -35
- package/dist/wje-container.js.map +1 -1
- package/dist/wje-copy-button.js +64 -204
- package/dist/wje-copy-button.js.map +1 -1
- package/dist/wje-dialog.js +85 -553
- package/dist/wje-dialog.js.map +1 -1
- package/dist/wje-divider.js +7 -34
- package/dist/wje-divider.js.map +1 -1
- package/dist/wje-dropdown.js +78 -305
- package/dist/wje-dropdown.js.map +1 -1
- package/dist/wje-element.js +191 -700
- package/dist/wje-element.js.map +1 -1
- package/dist/wje-file-upload-item.js +51 -156
- package/dist/wje-file-upload-item.js.map +1 -1
- package/dist/wje-file-upload.js +181 -619
- package/dist/wje-file-upload.js.map +1 -1
- package/dist/wje-footer.js +7 -31
- package/dist/wje-footer.js.map +1 -1
- package/dist/wje-form.js +7 -32
- package/dist/wje-form.js.map +1 -1
- package/dist/wje-format-digital.js +26 -118
- package/dist/wje-format-digital.js.map +1 -1
- package/dist/wje-grid.js +7 -33
- package/dist/wje-grid.js.map +1 -1
- package/dist/wje-header.js +9 -35
- package/dist/wje-header.js.map +1 -1
- package/dist/wje-icon-library.js +12 -18
- package/dist/wje-icon-library.js.map +1 -1
- package/dist/wje-icon-picker.js +65 -320
- package/dist/wje-icon-picker.js.map +1 -1
- package/dist/wje-icon.js +1 -1
- package/dist/wje-img-comparer.js +37 -114
- package/dist/wje-img-comparer.js.map +1 -1
- package/dist/wje-img.js +50 -198
- package/dist/wje-img.js.map +1 -1
- package/dist/wje-infinite-scroll.js +94 -346
- package/dist/wje-infinite-scroll.js.map +1 -1
- package/dist/wje-input-file.js +23 -84
- package/dist/wje-input-file.js.map +1 -1
- package/dist/wje-input.js +78 -392
- package/dist/wje-input.js.map +1 -1
- package/dist/wje-item.js +11 -64
- package/dist/wje-item.js.map +1 -1
- package/dist/wje-kanban.js +124 -401
- package/dist/wje-kanban.js.map +1 -1
- package/dist/wje-label.js +9 -32
- package/dist/wje-label.js.map +1 -1
- package/dist/wje-level-indicator.js +38 -157
- package/dist/wje-level-indicator.js.map +1 -1
- package/dist/wje-list.js +10 -40
- package/dist/wje-list.js.map +1 -1
- package/dist/wje-main.js +7 -31
- package/dist/wje-main.js.map +1 -1
- package/dist/wje-masonry.js +66 -211
- package/dist/wje-masonry.js.map +1 -1
- package/dist/wje-master.js +45 -161
- package/dist/wje-master.js.map +1 -1
- package/dist/wje-menu-button.js +10 -38
- package/dist/wje-menu-button.js.map +1 -1
- package/dist/wje-menu-item.js +127 -577
- package/dist/wje-menu-item.js.map +1 -1
- package/dist/wje-menu-label.js +9 -35
- package/dist/wje-menu-label.js.map +1 -1
- package/dist/wje-menu.js +14 -49
- package/dist/wje-menu.js.map +1 -1
- package/dist/wje-option.js +48 -279
- package/dist/wje-option.js.map +1 -1
- package/dist/wje-options.js +130 -384
- package/dist/wje-options.js.map +1 -1
- package/dist/wje-orgchart-group.js +16 -52
- package/dist/wje-orgchart-group.js.map +1 -1
- package/dist/wje-orgchart-item.js +24 -93
- package/dist/wje-orgchart-item.js.map +1 -1
- package/dist/wje-orgchart.js +18 -68
- package/dist/wje-orgchart.js.map +1 -1
- package/dist/wje-pagination.js +113 -397
- package/dist/wje-pagination.js.map +1 -1
- package/dist/wje-popup.js +3 -3
- package/dist/wje-popup.js.map +1 -1
- package/dist/wje-progress-bar.js +53 -205
- package/dist/wje-progress-bar.js.map +1 -1
- package/dist/wje-qr-code.js +398 -2980
- package/dist/wje-qr-code.js.map +1 -1
- package/dist/wje-radio-group.js +52 -190
- package/dist/wje-radio-group.js.map +1 -1
- package/dist/wje-radio.js +24 -118
- package/dist/wje-radio.js.map +1 -1
- package/dist/wje-rate.js +62 -266
- package/dist/wje-rate.js.map +1 -1
- package/dist/wje-relative-time.js +24 -99
- package/dist/wje-relative-time.js.map +1 -1
- package/dist/wje-reorder-dropzone.js +9 -31
- package/dist/wje-reorder-dropzone.js.map +1 -1
- package/dist/wje-reorder-handle.js +67 -204
- package/dist/wje-reorder-handle.js.map +1 -1
- package/dist/wje-reorder-item.js +14 -44
- package/dist/wje-reorder-item.js.map +1 -1
- package/dist/wje-reorder.js +61 -246
- package/dist/wje-reorder.js.map +1 -1
- package/dist/wje-route.js +6 -24
- package/dist/wje-route.js.map +1 -1
- package/dist/wje-router-link.js +11 -39
- package/dist/wje-router-link.js.map +1 -1
- package/dist/wje-router-outlet.js +76 -172
- package/dist/wje-router-outlet.js.map +1 -1
- package/dist/wje-routerx.js +537 -1331
- package/dist/wje-routerx.js.map +1 -1
- package/dist/wje-row.js +9 -31
- package/dist/wje-row.js.map +1 -1
- package/dist/wje-select.js +326 -1152
- package/dist/wje-select.js.map +1 -1
- package/dist/wje-slider.js +44 -225
- package/dist/wje-slider.js.map +1 -1
- package/dist/wje-sliding-container.js +295 -1319
- package/dist/wje-sliding-container.js.map +1 -1
- package/dist/wje-split-view.js +35 -121
- package/dist/wje-split-view.js.map +1 -1
- package/dist/wje-status.js +14 -45
- package/dist/wje-status.js.map +1 -1
- package/dist/wje-step.js +9 -32
- package/dist/wje-step.js.map +1 -1
- package/dist/wje-stepper.js +109 -357
- package/dist/wje-stepper.js.map +1 -1
- package/dist/wje-store.js +67 -360
- package/dist/wje-store.js.map +1 -1
- package/dist/wje-tab-group.js +85 -314
- package/dist/wje-tab-group.js.map +1 -1
- package/dist/wje-tab-panel.js +7 -28
- package/dist/wje-tab-panel.js.map +1 -1
- package/dist/wje-tab.js +21 -198
- package/dist/wje-tab.js.map +1 -1
- package/dist/wje-textarea.js +64 -264
- package/dist/wje-textarea.js.map +1 -1
- package/dist/wje-thumbnail.js +10 -51
- package/dist/wje-thumbnail.js.map +1 -1
- package/dist/wje-toast.js +127 -632
- package/dist/wje-toast.js.map +1 -1
- package/dist/wje-toggle.js +52 -177
- package/dist/wje-toggle.js.map +1 -1
- package/dist/wje-toolbar-action.js +128 -456
- package/dist/wje-toolbar-action.js.map +1 -1
- package/dist/wje-toolbar.js +75 -270
- package/dist/wje-toolbar.js.map +1 -1
- package/dist/wje-tooltip.js +50 -161
- package/dist/wje-tooltip.js.map +1 -1
- package/dist/wje-tree-item.js +70 -301
- package/dist/wje-tree-item.js.map +1 -1
- package/dist/wje-tree.js +145 -489
- package/dist/wje-tree.js.map +1 -1
- package/dist/wje-visually-hidden.js +7 -34
- package/dist/wje-visually-hidden.js.map +1 -1
- package/package.json +3 -2
- package/dist/form-associated-element-DEQ4y-jn.js +0 -245
- package/dist/icon-CReYMzAK.js +0 -245
- package/dist/popup.element-CwXvVFK7.js +0 -2133
- package/dist/router-links-wjqCnncc.js +0 -156
package/dist/wje-kanban.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wje-kanban.js","sources":["../packages/wje-kanban/kanban.element.js","../packages/wje-kanban/kanban.js"],"sourcesContent":["import Checkbox from '../wje-checkbox/checkbox.js';\nimport { default as WJElement } from '../wje-element/element.js';\nimport MenuItem from '../wje-menu-item/menu-item.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * `Kanban` is a custom web component that represents a Kanban board with draggable columns and cards.\n * @summary This element represents a Kanban board.\n * @documentation https://elements.webjet.sk/components/kanban\n * @status stable\n * @augments {WJElement}\n * @slot - The default slot for the Kanban board.\n * @csspart native-infinite-scroll - Styles the native part of the Kanban board.\n * @tag wje-kanban\n */\nexport default class Kanban extends WJElement {\n /**\n * Creates an instance of Kanban.\n * @class\n */\n constructor() {\n super();\n this.totalPages = 0; // Total number of pages\n this.isLoading = []; // Array to hold loading status of each page\n this._response = {}; // Response from the API\n this.isDragging = false; // Flag to indicate if an element is being dragged\n this.selectedCards = []; // Array to hold selected cards\n }\n\n /**\n * Dependencies of the Option component.\n */\n dependencies = {\n 'wje-checkbox': Checkbox,\n 'wje-menu-item': MenuItem,\n };\n\n /**\n * Sets the URL for fetching data.\n * @param value {string}\n */\n set response(value) {\n this._response = value;\n }\n\n /**\n * Gets the URL for fetching data.\n * @returns {*|{}|{}}\n */\n get response() {\n return this._response;\n }\n\n /**\n * Sets the URL for fetching data.\n * @param value {array}\n */\n set selectedItems(value) {\n this._selectedItems = value;\n }\n\n /**\n * Gets the URL for fetching data.\n * @returns {Array}\n */\n get selectedItems() {\n return this._selectedItems;\n }\n\n /**\n * Sets the URL for fetching data.\n * @type {string}\n */\n className = 'Kanban';\n\n /**\n * Returns the CSS styles for the component.\n * @static\n * @returns {CSSStyleSheet}\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Returns the list of attributes to observe for changes.\n * @static\n * @returns {Array<string>}\n */\n static get observedAttributes() {\n return [];\n }\n\n /**\n * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n this.syncAria();\n }\n\n /**\n * Prepares the component before drawing.\n * @param {object} context The context for drawing.\n * @param {object} store The store for drawing.\n * @param {object} params The parameters for drawing.\n */\n async beforeDraw(context, store, params) {\n this.response = await this.getPages();\n }\n\n /**\n * Draws the component after it has been prepared.\n * @returns {DocumentFragment}\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('div');\n native.classList.add('native');\n native.setAttribute('part', 'native-infinite-scroll');\n\n let pools = this.getPool(this.response, this.poolName);\n\n // Add pools to the native element\n for (const statusName in pools) {\n if (pools.hasOwnProperty(statusName)) {\n let pool = this.htmlPool(statusName, pools[statusName].length);\n\n native.appendChild(pool);\n const items = pools[statusName];\n\n this.customForeach(pool, items);\n }\n }\n\n fragment.appendChild(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: 'region' });\n }\n\n const ariaLabel = this.getAttribute('aria-label');\n const label = this.getAttribute('label');\n if (!ariaLabel && label) {\n this.setAriaState({ label });\n }\n }\n\n /**\n * Called after the component has been drawn.\n */\n afterDraw() {\n this.ui = {\n elBoard: this.shadowRoot.getElementById('board'),\n elTotalCardCount: this.shadowRoot.getElementById('totalCards'),\n elCardPlaceholder: null,\n };\n\n this.setupDragAndDropEvents();\n this.setupSelectAllCardsEvent();\n this.setupMenuItemClickEvents();\n }\n\n /**\n * Iterates over a list of items, generates an HTML card for each, and appends it to the specified pool's content area.\n * @param {HTMLElement} pool The container element where the cards will be appended. It should contain an element with the class `.pool-content`.\n * @param {Array} items An array of items used to generate HTML cards.\n */\n customForeach = (pool, items) => {\n for (const item of items) {\n let card = this.htmlCard(item);\n pool.querySelector('.pool-content').appendChild(card);\n }\n };\n\n /**\n * Sets up the drag and drop events for the component.\n */\n setupDragAndDropEvents() {\n this.live('dragstart', '.pool .card', (e) => {\n this.isDragging = true;\n e.dataTransfer.clearData();\n e.dataTransfer.setData('text/plain', e.target.dataset.id);\n e.dataTransfer.dropEffect = 'move';\n e.target.style.opacity = '0.5';\n\n const rect = e.target.getBoundingClientRect();\n\n this.draggedElementWidth = rect.width;\n this.draggedElementHeight = rect.height;\n });\n\n this.live('dragend', '.pool .card', (e) => {\n e.target.style.opacity = '';\n if (this.ui.elCardPlaceholder) {\n this.ui.elCardPlaceholder.remove();\n }\n this.ui.elCardPlaceholder = null;\n this.isDragging = false;\n });\n\n this.live('dragover', '.pool, .pool .card, .pool .card-placeholder', (e) => {\n e.preventDefault();\n e.dataTransfer.dropEffect = 'move';\n\n if (e.target.classList.contains('pool')) {\n e.target.appendChild(this.getCardPlaceholder());\n } else if (e.target.classList.contains('card')) {\n e.target.parentNode.insertBefore(this.getCardPlaceholder(), e.target);\n }\n });\n\n this.live('drop', '.pool, .pool .card-placeholder', (e) => {\n e.preventDefault();\n if (!this.isDragging) return;\n\n const todo_id = +e.dataTransfer.getData('text');\n const card = this.shadowRoot.querySelector('.card[data-id=\"' + todo_id + '\"]');\n\n if (e.target.classList.contains('pool')) {\n e.target.querySelector('.pool-content').appendChild(card);\n } else if (e.target.classList.contains('card-placeholder')) {\n e.target.parentNode.replaceChild(card, e.target);\n }\n\n window.setTimeout(this.updateColumnItemCount, 100);\n });\n }\n\n /**\n * Sets up the select all cards event for the component.\n */\n setupSelectAllCardsEvent() {\n // Event listener for selecting all cards in a pool\n this.live('wje-toggle:change', '.select-all-cards', (e) => {\n const pool = e.target.closest('.pool');\n this.updateSelectedCards(pool, e.target.checked);\n });\n\n // Event listener for selecting individual cards\n this.live('wje-toggle:change', '.select-card', (e) => {\n const card = e.target.closest('.card');\n this.setSelectedCards(e.target.checked, card);\n\n if (this.selectedCards.length === 0) {\n e.target.closest('.pool').querySelector('.select-all-cards').checked = false;\n }\n\n this.setSelectedItems();\n });\n }\n\n /**\n * Sets up the menu item click events for the component.\n */\n setupMenuItemClickEvents() {\n this.context.querySelectorAll('wje-menu-item').forEach((menuItem) => {\n menuItem.removeEventListener('wje-menu-item:click', this.menuItemClickHandler);\n });\n\n this.context.querySelectorAll('wje-menu-item').forEach((menuItem) => {\n menuItem.addEventListener('wje-menu-item:click', this.menuItemClickHandler);\n });\n }\n\n /**\n * Handles the menu item click event.\n * @param e\n */\n menuItemClickHandler = (e) => {\n const action = e.target.dataset.action;\n const pool = e.target.closest('.pool');\n\n this.handlePoolAction(action, pool);\n };\n\n /**\n * Updates the selected cards in the pool.\n * @param pool {HTMLElement}\n * @param isChecked {boolean}\n */\n updateSelectedCards(pool, isChecked) {\n const cards = pool.querySelectorAll('.pool-content .card');\n\n cards.forEach((card) => {\n const checkbox = card.querySelector('wje-checkbox');\n if (checkbox) {\n checkbox.checked = isChecked;\n }\n\n this.setSelectedCards(isChecked, card);\n });\n\n this.setSelectedItems();\n }\n\n /**\n * Updates the column item count.\n */\n updateColumnItemCount = () => {\n const pools = this.shadowRoot.querySelectorAll('.pool');\n\n pools.forEach((pool) => {\n const itemCount = pool.querySelectorAll('.pool-content .card').length;\n let itemCountDisplay = pool.querySelector('.item-count');\n\n itemCountDisplay.innerHTML = itemCount;\n });\n };\n\n /**\n * Handles the pool action.\n * @param action {string}\n * @param pool {HTMLElement}\n */\n handlePoolAction(action, pool) {\n switch (action) {\n case 'move-left':\n this.movePool(pool, 'left');\n break;\n case 'move-right':\n this.movePool(pool, 'right');\n break;\n case 'rename-pool':\n this.renamePool(pool);\n break;\n default:\n console.error(`Neznáma akcia: ${action}`);\n }\n }\n\n /**\n * Moves the pool in the specified direction.\n * @param pool {HTMLElement}\n * @param direction {string}\n */\n movePool(pool, direction) {\n const parent = pool.parentElement;\n\n // Najprv odstránime všetky event listenery z aktuálnych stĺpcov (pools)\n // Array.from(parent.children).forEach(removeEventListeners);\n\n if (direction === 'left' && pool.previousElementSibling) {\n // Presunieme pool doľava\n parent.insertBefore(pool, pool.previousElementSibling);\n } else if (direction === 'right' && pool.nextElementSibling) {\n // Presunieme pool doprava\n parent.insertBefore(pool.nextElementSibling, pool);\n }\n\n // Po presune stĺpcov (pools) musíme znova pripojiť event listenery\n this.setupMenuItemClickEvents();\n }\n\n /**\n * Renames the pool.\n * @param pool {HTMLElement}\n */\n renamePool(pool) {\n const newName = prompt('Zadajte nový názov pre stĺpec:');\n if (newName) {\n const header = pool.querySelector('.pool-header h4');\n header.innerHTML = `${newName} (<span class=\"item-count\">0</span> položiek)`;\n this.updateColumnItemCount(); // Aktualizovať počet položiek po premenovaní\n }\n }\n\n /**\n * Gets the card placeholder.\n * @returns {null|*}\n */\n getCardPlaceholder() {\n if (!this.ui.elCardPlaceholder) {\n this.ui.elCardPlaceholder = document.createElement('div');\n this.ui.elCardPlaceholder.className = 'card-placeholder';\n\n this.ui.elCardPlaceholder.style.width = this.draggedElementWidth + 'px';\n this.ui.elCardPlaceholder.style.height = this.draggedElementHeight + 'px';\n } else {\n this.ui.elCardPlaceholder.style.width = this.draggedElementWidth + 'px';\n this.ui.elCardPlaceholder.style.height = this.draggedElementHeight + 'px';\n }\n return this.ui.elCardPlaceholder;\n }\n\n /**\n * Adds a live event listener to the component.\n * @param eventType {string}\n * @param selector {string}\n * @param callback {function}\n */\n live(eventType, selector, callback) {\n const attachListener = (root) => {\n root.addEventListener(\n eventType,\n (e) => {\n if (e.target.matches(selector)) {\n callback.call(e.target, e);\n }\n },\n false\n );\n };\n\n const traverseAndAttach = (root) => {\n attachListener(root);\n\n root.querySelectorAll('*').forEach((node) => {\n if (node.shadowRoot) {\n traverseAndAttach(node.shadowRoot);\n }\n });\n };\n\n traverseAndAttach(this.shadowRoot || this); // Start from the Shadow DOM if it exists\n }\n\n /**\n * Sets the selected cards.\n * @param isChecked {boolean}\n * @param card {HTMLElement}\n */\n setSelectedCards(isChecked, card) {\n if (isChecked) {\n if (!this.selectedCards.includes(card)) {\n this.selectedCards.push(card);\n }\n } else {\n this.selectedCards = this.selectedCards.filter((selectedCard) => selectedCard !== card);\n }\n }\n\n /**\n * Sets the selected items.\n */\n setSelectedItems() {\n const selectedIds = this.selectedCards.map((card) => card.getAttribute('data-id'));\n this.selectedItems = this.response.filter((item) => selectedIds.includes(item.id));\n }\n\n /**\n * Fetches the pages.\n * @param page\n * @returns {Promise<any>}\n */\n async getPages(page = 0) {\n let hasParams = this.url.includes('?');\n const response = await fetch(\n `${this.url}${hasParams ? '&' : '?'}page=${page}&size=${this.size}${this?.queryParams}`\n );\n if (!response.ok) {\n throw new Error(`An error occurred: ${response.status}`);\n }\n return await response.json();\n }\n\n /**\n * Gets the pool.\n * @param data {Array}\n * @param poolName {string}\n * @returns {*}\n */\n getPool = (data, poolName) => {\n return data.reduce((acc, item) => {\n const statusName = item.status.name;\n if (!acc[statusName]) {\n acc[statusName] = [];\n }\n acc[statusName].push(item);\n return acc;\n }, {});\n };\n\n /**\n * Returns the HTML for the pool.\n * @param title {string}\n * @param countItems {number}\n * @returns {Element}\n */\n htmlPool = (title, countItems) => {\n let poolHtml = document.createElement('div');\n poolHtml.classList.add('pool');\n\n let header = document.createElement('div');\n header.classList.add('pool-header');\n\n let checkbox = document.createElement('wje-checkbox');\n checkbox.setAttribute('type', 'checkbox');\n checkbox.classList.add('select-all-cards');\n checkbox.title = 'Select all cards';\n\n let h4 = document.createElement('h4');\n h4.textContent = title;\n\n let badge = document.createElement('wje-badge');\n badge.setAttribute('color', 'danger');\n badge.classList.add('item-count');\n badge.textContent = countItems;\n\n let dropdown = document.createElement('wje-dropdown');\n dropdown.setAttribute('placement', 'bottom-start');\n dropdown.setAttribute('offset', '5');\n dropdown.setAttribute('collapsible', '');\n dropdown.innerHTML = `\n <wje-button fill=\"link\" slot=\"trigger\" size=\"small\" round>\n <wje-icon name=\"dots-vertical\"></wje-icon>\n </wje-button>\n <wje-menu active>\n <wje-menu-item data-action=\"rename-pool\">\n <wj-label>Zmeniť názov</wj-label>\n </wje-menu-item>\n <wje-menu-item data-action=\"move-left\">\n <wj-label>Posunúť doľava</wj-label>\n </wje-menu-item>\n <wje-menu-item data-action=\"move-right\">\n <wj-label>Posunúť doprava</wj-label>\n </wje-menu-item>\n </wje-menu>\n `;\n\n header.appendChild(checkbox);\n header.appendChild(h4);\n header.appendChild(badge);\n header.appendChild(dropdown);\n\n let content = document.createElement('div');\n content.classList.add('pool-content');\n\n poolHtml.appendChild(header);\n poolHtml.appendChild(content);\n\n return poolHtml;\n };\n\n /**\n * Returns the HTML for the card.\n * @param item {Object}\n * @returns {Element}\n */\n htmlCard = (item) => {\n let card = document.createElement('div');\n card.classList.add('card');\n card.draggable = true;\n card.setAttribute('data-id', item.id);\n card.innerHTML = `\n <wje-checkbox type=\"checkbox\" class=\"select-card\" title=\"Select card\"></wje-checkbox>\n <div>${item.body}</div>\n `;\n\n return card;\n };\n\n dispatchEvent(event) {\n return false;\n }\n}\n","import Kanban from './kanban.element.js';\n\nexport default Kanban;\n\nKanban.define('wje-kanban', Kanban);\n"],"names":[],"mappings":";;;;;;;AAee,MAAM,eAAe,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA,EAK1C,cAAc;AACV,UAAK;AAWT;AAAA;AAAA;AAAA,wCAAe;AAAA,MACX,gBAAgB;AAAA,MAChB,iBAAiB;AAAA,IACzB;AAsCI;AAAA;AAAA;AAAA;AAAA,qCAAY;AAuGZ;AAAA;AAAA;AAAA;AAAA;AAAA,yCAAgB,CAAC,MAAM,UAAU;AAC7B,iBAAW,QAAQ,OAAO;AACtB,YAAI,OAAO,KAAK,SAAS,IAAI;AAC7B,aAAK,cAAc,eAAe,EAAE,YAAY,IAAI;AAAA,MACxD;AAAA,IACJ;AAgGA;AAAA;AAAA;AAAA;AAAA,gDAAuB,CAAC,MAAM;AAC1B,YAAM,SAAS,EAAE,OAAO,QAAQ;AAChC,YAAM,OAAO,EAAE,OAAO,QAAQ,OAAO;AAErC,WAAK,iBAAiB,QAAQ,IAAI;AAAA,IACtC;AAyBA;AAAA;AAAA;AAAA,iDAAwB,MAAM;AAC1B,YAAM,QAAQ,KAAK,WAAW,iBAAiB,OAAO;AAEtD,YAAM,QAAQ,CAAC,SAAS;A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3D;AACA,WAAO,MAAM,SAAS,KAAI;AAAA,EAC9B;AAAA,EAkGA,cAAc,OAAO;AACjB,WAAO;AAAA,EACX;AACJ;AC/iBA,OAAO,OAAO,cAAc,MAAM;"}
|
|
1
|
+
{"version":3,"file":"wje-kanban.js","sources":["../packages/wje-kanban/kanban.element.js","../packages/wje-kanban/kanban.js"],"sourcesContent":["import Checkbox from '../wje-checkbox/checkbox.js';\nimport { default as WJElement } from '../wje-element/element.js';\nimport MenuItem from '../wje-menu-item/menu-item.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * `Kanban` is a custom web component that represents a Kanban board with draggable columns and cards.\n * @summary This element represents a Kanban board.\n * @documentation https://elements.webjet.sk/components/kanban\n * @status stable\n * @augments {WJElement}\n * @slot - The default slot for the Kanban board.\n * @csspart native-infinite-scroll - Styles the native part of the Kanban board.\n * @tag wje-kanban\n */\nexport default class Kanban extends WJElement {\n /**\n * Creates an instance of Kanban.\n * @class\n */\n constructor() {\n super();\n this.totalPages = 0; // Total number of pages\n this.isLoading = []; // Array to hold loading status of each page\n this._response = {}; // Response from the API\n this.isDragging = false; // Flag to indicate if an element is being dragged\n this.selectedCards = []; // Array to hold selected cards\n }\n\n /**\n * Dependencies of the Option component.\n */\n dependencies = {\n 'wje-checkbox': Checkbox,\n 'wje-menu-item': MenuItem,\n };\n\n /**\n * Sets the URL for fetching data.\n * @param value {string}\n */\n set response(value) {\n this._response = value;\n }\n\n /**\n * Gets the URL for fetching data.\n * @returns {*|{}|{}}\n */\n get response() {\n return this._response;\n }\n\n /**\n * Sets the URL for fetching data.\n * @param value {array}\n */\n set selectedItems(value) {\n this._selectedItems = value;\n }\n\n /**\n * Gets the URL for fetching data.\n * @returns {Array}\n */\n get selectedItems() {\n return this._selectedItems;\n }\n\n /**\n * Sets the URL for fetching data.\n * @type {string}\n */\n className = 'Kanban';\n\n /**\n * Returns the CSS styles for the component.\n * @static\n * @returns {CSSStyleSheet}\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Returns the list of attributes to observe for changes.\n * @static\n * @returns {Array<string>}\n */\n static get observedAttributes() {\n return [];\n }\n\n /**\n * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n this.syncAria();\n }\n\n /**\n * Prepares the component before drawing.\n * @param {object} context The context for drawing.\n * @param {object} store The store for drawing.\n * @param {object} params The parameters for drawing.\n */\n async beforeDraw(context, store, params) {\n this.response = await this.getPages();\n }\n\n /**\n * Draws the component after it has been prepared.\n * @returns {DocumentFragment}\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('div');\n native.classList.add('native');\n native.setAttribute('part', 'native-infinite-scroll');\n\n let pools = this.getPool(this.response, this.poolName);\n\n // Add pools to the native element\n for (const statusName in pools) {\n if (pools.hasOwnProperty(statusName)) {\n let pool = this.htmlPool(statusName, pools[statusName].length);\n\n native.appendChild(pool);\n const items = pools[statusName];\n\n this.customForeach(pool, items);\n }\n }\n\n fragment.appendChild(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: 'region' });\n }\n\n const ariaLabel = this.getAttribute('aria-label');\n const label = this.getAttribute('label');\n if (!ariaLabel && label) {\n this.setAriaState({ label });\n }\n }\n\n /**\n * Called after the component has been drawn.\n */\n afterDraw() {\n this.ui = {\n elBoard: this.shadowRoot.getElementById('board'),\n elTotalCardCount: this.shadowRoot.getElementById('totalCards'),\n elCardPlaceholder: null,\n };\n\n this.setupDragAndDropEvents();\n this.setupSelectAllCardsEvent();\n this.setupMenuItemClickEvents();\n }\n\n /**\n * Iterates over a list of items, generates an HTML card for each, and appends it to the specified pool's content area.\n * @param {HTMLElement} pool The container element where the cards will be appended. It should contain an element with the class `.pool-content`.\n * @param {Array} items An array of items used to generate HTML cards.\n */\n customForeach = (pool, items) => {\n for (const item of items) {\n let card = this.htmlCard(item);\n pool.querySelector('.pool-content').appendChild(card);\n }\n };\n\n /**\n * Sets up the drag and drop events for the component.\n */\n setupDragAndDropEvents() {\n this.live('dragstart', '.pool .card', (e) => {\n this.isDragging = true;\n e.dataTransfer.clearData();\n e.dataTransfer.setData('text/plain', e.target.dataset.id);\n e.dataTransfer.dropEffect = 'move';\n e.target.style.opacity = '0.5';\n\n const rect = e.target.getBoundingClientRect();\n\n this.draggedElementWidth = rect.width;\n this.draggedElementHeight = rect.height;\n });\n\n this.live('dragend', '.pool .card', (e) => {\n e.target.style.opacity = '';\n if (this.ui.elCardPlaceholder) {\n this.ui.elCardPlaceholder.remove();\n }\n this.ui.elCardPlaceholder = null;\n this.isDragging = false;\n });\n\n this.live('dragover', '.pool, .pool .card, .pool .card-placeholder', (e) => {\n e.preventDefault();\n e.dataTransfer.dropEffect = 'move';\n\n if (e.target.classList.contains('pool')) {\n e.target.appendChild(this.getCardPlaceholder());\n } else if (e.target.classList.contains('card')) {\n e.target.parentNode.insertBefore(this.getCardPlaceholder(), e.target);\n }\n });\n\n this.live('drop', '.pool, .pool .card-placeholder', (e) => {\n e.preventDefault();\n if (!this.isDragging) return;\n\n const todo_id = +e.dataTransfer.getData('text');\n const card = this.shadowRoot.querySelector('.card[data-id=\"' + todo_id + '\"]');\n\n if (e.target.classList.contains('pool')) {\n e.target.querySelector('.pool-content').appendChild(card);\n } else if (e.target.classList.contains('card-placeholder')) {\n e.target.parentNode.replaceChild(card, e.target);\n }\n\n window.setTimeout(this.updateColumnItemCount, 100);\n });\n }\n\n /**\n * Sets up the select all cards event for the component.\n */\n setupSelectAllCardsEvent() {\n // Event listener for selecting all cards in a pool\n this.live('wje-toggle:change', '.select-all-cards', (e) => {\n const pool = e.target.closest('.pool');\n this.updateSelectedCards(pool, e.target.checked);\n });\n\n // Event listener for selecting individual cards\n this.live('wje-toggle:change', '.select-card', (e) => {\n const card = e.target.closest('.card');\n this.setSelectedCards(e.target.checked, card);\n\n if (this.selectedCards.length === 0) {\n e.target.closest('.pool').querySelector('.select-all-cards').checked = false;\n }\n\n this.setSelectedItems();\n });\n }\n\n /**\n * Sets up the menu item click events for the component.\n */\n setupMenuItemClickEvents() {\n this.context.querySelectorAll('wje-menu-item').forEach((menuItem) => {\n menuItem.removeEventListener('wje-menu-item:click', this.menuItemClickHandler);\n });\n\n this.context.querySelectorAll('wje-menu-item').forEach((menuItem) => {\n menuItem.addEventListener('wje-menu-item:click', this.menuItemClickHandler);\n });\n }\n\n /**\n * Handles the menu item click event.\n * @param e\n */\n menuItemClickHandler = (e) => {\n const action = e.target.dataset.action;\n const pool = e.target.closest('.pool');\n\n this.handlePoolAction(action, pool);\n };\n\n /**\n * Updates the selected cards in the pool.\n * @param pool {HTMLElement}\n * @param isChecked {boolean}\n */\n updateSelectedCards(pool, isChecked) {\n const cards = pool.querySelectorAll('.pool-content .card');\n\n cards.forEach((card) => {\n const checkbox = card.querySelector('wje-checkbox');\n if (checkbox) {\n checkbox.checked = isChecked;\n }\n\n this.setSelectedCards(isChecked, card);\n });\n\n this.setSelectedItems();\n }\n\n /**\n * Updates the column item count.\n */\n updateColumnItemCount = () => {\n const pools = this.shadowRoot.querySelectorAll('.pool');\n\n pools.forEach((pool) => {\n const itemCount = pool.querySelectorAll('.pool-content .card').length;\n let itemCountDisplay = pool.querySelector('.item-count');\n\n itemCountDisplay.innerHTML = itemCount;\n });\n };\n\n /**\n * Handles the pool action.\n * @param action {string}\n * @param pool {HTMLElement}\n */\n handlePoolAction(action, pool) {\n switch (action) {\n case 'move-left':\n this.movePool(pool, 'left');\n break;\n case 'move-right':\n this.movePool(pool, 'right');\n break;\n case 'rename-pool':\n this.renamePool(pool);\n break;\n default:\n console.error(`Neznáma akcia: ${action}`);\n }\n }\n\n /**\n * Moves the pool in the specified direction.\n * @param pool {HTMLElement}\n * @param direction {string}\n */\n movePool(pool, direction) {\n const parent = pool.parentElement;\n\n // Najprv odstránime všetky event listenery z aktuálnych stĺpcov (pools)\n // Array.from(parent.children).forEach(removeEventListeners);\n\n if (direction === 'left' && pool.previousElementSibling) {\n // Presunieme pool doľava\n parent.insertBefore(pool, pool.previousElementSibling);\n } else if (direction === 'right' && pool.nextElementSibling) {\n // Presunieme pool doprava\n parent.insertBefore(pool.nextElementSibling, pool);\n }\n\n // Po presune stĺpcov (pools) musíme znova pripojiť event listenery\n this.setupMenuItemClickEvents();\n }\n\n /**\n * Renames the pool.\n * @param pool {HTMLElement}\n */\n renamePool(pool) {\n const newName = prompt('Zadajte nový názov pre stĺpec:');\n if (newName) {\n const header = pool.querySelector('.pool-header h4');\n header.innerHTML = `${newName} (<span class=\"item-count\">0</span> položiek)`;\n this.updateColumnItemCount(); // Aktualizovať počet položiek po premenovaní\n }\n }\n\n /**\n * Gets the card placeholder.\n * @returns {null|*}\n */\n getCardPlaceholder() {\n if (!this.ui.elCardPlaceholder) {\n this.ui.elCardPlaceholder = document.createElement('div');\n this.ui.elCardPlaceholder.className = 'card-placeholder';\n\n this.ui.elCardPlaceholder.style.width = this.draggedElementWidth + 'px';\n this.ui.elCardPlaceholder.style.height = this.draggedElementHeight + 'px';\n } else {\n this.ui.elCardPlaceholder.style.width = this.draggedElementWidth + 'px';\n this.ui.elCardPlaceholder.style.height = this.draggedElementHeight + 'px';\n }\n return this.ui.elCardPlaceholder;\n }\n\n /**\n * Adds a live event listener to the component.\n * @param eventType {string}\n * @param selector {string}\n * @param callback {function}\n */\n live(eventType, selector, callback) {\n const attachListener = (root) => {\n root.addEventListener(\n eventType,\n (e) => {\n if (e.target.matches(selector)) {\n callback.call(e.target, e);\n }\n },\n false\n );\n };\n\n const traverseAndAttach = (root) => {\n attachListener(root);\n\n root.querySelectorAll('*').forEach((node) => {\n if (node.shadowRoot) {\n traverseAndAttach(node.shadowRoot);\n }\n });\n };\n\n traverseAndAttach(this.shadowRoot || this); // Start from the Shadow DOM if it exists\n }\n\n /**\n * Sets the selected cards.\n * @param isChecked {boolean}\n * @param card {HTMLElement}\n */\n setSelectedCards(isChecked, card) {\n if (isChecked) {\n if (!this.selectedCards.includes(card)) {\n this.selectedCards.push(card);\n }\n } else {\n this.selectedCards = this.selectedCards.filter((selectedCard) => selectedCard !== card);\n }\n }\n\n /**\n * Sets the selected items.\n */\n setSelectedItems() {\n const selectedIds = this.selectedCards.map((card) => card.getAttribute('data-id'));\n this.selectedItems = this.response.filter((item) => selectedIds.includes(item.id));\n }\n\n /**\n * Fetches the pages.\n * @param page\n * @returns {Promise<any>}\n */\n async getPages(page = 0) {\n let hasParams = this.url.includes('?');\n const response = await fetch(\n `${this.url}${hasParams ? '&' : '?'}page=${page}&size=${this.size}${this?.queryParams}`\n );\n if (!response.ok) {\n throw new Error(`An error occurred: ${response.status}`);\n }\n return await response.json();\n }\n\n /**\n * Gets the pool.\n * @param data {Array}\n * @param poolName {string}\n * @returns {*}\n */\n getPool = (data, poolName) => {\n return data.reduce((acc, item) => {\n const statusName = item.status.name;\n if (!acc[statusName]) {\n acc[statusName] = [];\n }\n acc[statusName].push(item);\n return acc;\n }, {});\n };\n\n /**\n * Returns the HTML for the pool.\n * @param title {string}\n * @param countItems {number}\n * @returns {Element}\n */\n htmlPool = (title, countItems) => {\n let poolHtml = document.createElement('div');\n poolHtml.classList.add('pool');\n\n let header = document.createElement('div');\n header.classList.add('pool-header');\n\n let checkbox = document.createElement('wje-checkbox');\n checkbox.setAttribute('type', 'checkbox');\n checkbox.classList.add('select-all-cards');\n checkbox.title = 'Select all cards';\n\n let h4 = document.createElement('h4');\n h4.textContent = title;\n\n let badge = document.createElement('wje-badge');\n badge.setAttribute('color', 'danger');\n badge.classList.add('item-count');\n badge.textContent = countItems;\n\n let dropdown = document.createElement('wje-dropdown');\n dropdown.setAttribute('placement', 'bottom-start');\n dropdown.setAttribute('offset', '5');\n dropdown.setAttribute('collapsible', '');\n dropdown.innerHTML = `\n <wje-button fill=\"link\" slot=\"trigger\" size=\"small\" round>\n <wje-icon name=\"dots-vertical\"></wje-icon>\n </wje-button>\n <wje-menu active>\n <wje-menu-item data-action=\"rename-pool\">\n <wj-label>Zmeniť názov</wj-label>\n </wje-menu-item>\n <wje-menu-item data-action=\"move-left\">\n <wj-label>Posunúť doľava</wj-label>\n </wje-menu-item>\n <wje-menu-item data-action=\"move-right\">\n <wj-label>Posunúť doprava</wj-label>\n </wje-menu-item>\n </wje-menu>\n `;\n\n header.appendChild(checkbox);\n header.appendChild(h4);\n header.appendChild(badge);\n header.appendChild(dropdown);\n\n let content = document.createElement('div');\n content.classList.add('pool-content');\n\n poolHtml.appendChild(header);\n poolHtml.appendChild(content);\n\n return poolHtml;\n };\n\n /**\n * Returns the HTML for the card.\n * @param item {Object}\n * @returns {Element}\n */\n htmlCard = (item) => {\n let card = document.createElement('div');\n card.classList.add('card');\n card.draggable = true;\n card.setAttribute('data-id', item.id);\n card.innerHTML = `\n <wje-checkbox type=\"checkbox\" class=\"select-card\" title=\"Select card\"></wje-checkbox>\n <div>${item.body}</div>\n `;\n\n return card;\n };\n\n dispatchEvent(event) {\n return false;\n }\n}\n","import Kanban from './kanban.element.js';\n\nexport default Kanban;\n\nKanban.define('wje-kanban', Kanban);\n"],"names":["Kanban","WJElement","constructor","super","dependencies","Checkbox","MenuItem","className","customForeach","pool","items","item","card","this","htmlCard","querySelector","appendChild","menuItemClickHandler","e","action","target","dataset","closest","handlePoolAction","updateColumnItemCount","shadowRoot","querySelectorAll","forEach","itemCount","length","innerHTML","getPool","data","poolName","reduce","acc","statusName","status","name","push","htmlPool","title","countItems","poolHtml","document","createElement","classList","add","header","checkbox","setAttribute","h4","textContent","badge","dropdown","content","draggable","id","body","totalPages","isLoading","_response","isDragging","selectedCards","value","_selectedItems","selectedItems","cssStyleSheet","observedAttributes","setupAttributes","isShadowRoot","syncAria","context","store","params","response","getPages","draw","fragment","createDocumentFragment","native","pools","hasOwnProperty","hasAttribute","setAriaState","role","ariaLabel","getAttribute","label","afterDraw","ui","elBoard","getElementById","elTotalCardCount","elCardPlaceholder","setupDragAndDropEvents","setupSelectAllCardsEvent","setupMenuItemClickEvents","live","dataTransfer","clearData","setData","dropEffect","style","opacity","rect","getBoundingClientRect","draggedElementWidth","width","draggedElementHeight","height","remove","preventDefault","contains","getCardPlaceholder","parentNode","insertBefore","todo_id","getData","replaceChild","window","setTimeout","updateSelectedCards","checked","setSelectedCards","setSelectedItems","menuItem","removeEventListener","addEventListener","isChecked","movePool","renamePool","console","error","direction","parent","parentElement","previousElementSibling","nextElementSibling","newName","prompt","eventType","selector","callback","traverseAndAttach","root","matches","call","node","includes","filter","selectedCard","selectedIds","map","page","hasParams","url","fetch","size","queryParams","ok","Error","json","event","define"],"mappings":";;;;;;AAee,MAAMA,UAAeC,EAAAA;AAAAA,EAKhC,cAAAC;AACIC,UAAAA;AAWJC,wCAAe,EACX,gBAAgBC,GAChB,iBAAiBC,EAAAA;AAuCrBC,qCAAY;AAuGZC,yCAAgB,CAACC,IAAMC;AACnB,iBAAWC,MAAQD,IAAO;AACtB,YAAIE,KAAOC,KAAKC,SAASH,EAAAA;AACzBF,QAAAA,GAAKM,cAAc,eAAA,EAAiBC,YAAYJ;MACpD;AAAA,IAAA;AAiGJK,gDAAwBC,CAAAA,OAAAA;AACpB,YAAMC,KAASD,GAAEE,OAAOC,QAAQF,QAC1BV,KAAOS,GAAEE,OAAOE,QAAQ,OAAA;AAE9BT,WAAKU,iBAAiBJ,IAAQV,EAAAA;AAAAA,IAAAA;AA0BlCe,iDAAwB,MAAA;AACNX,WAAKY,WAAWC,iBAAiB,OAAA,EAEzCC,QAASlB,CAAAA,OAAAA;AACX,cAAMmB,KAAYnB,GAAKiB,iBAAiB,qBAAA,EAAuBG;AACxCpB,QAAAA,GAAKM,cAAc,aAAA,EAEzBe,YAAYF;AAAAA,MAAAA,CAAAA;AAAAA,IAAAA;AA4JrCG,mCAAU,CAACC,IAAMC,OACND,GAAKE,OAAO,CAACC,IAAKxB,OAAAA;AACrB,YAAMyB,KAAazB,GAAK0B,OAAOC;AAK/B,aAJKH,GAAIC,EAAAA,MACLD,GAAIC,EAAAA,IAAc,CAAA,IAEtBD,GAAIC,EAAAA,EAAYG,KAA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KkD,cAAcsF,SAASzI,EAAAA,KAC7BC,KAAKkD,cAAcxB,KAAK3B,EAAAA,IAG5BC,KAAKkD,gBAAgBlD,KAAKkD,cAAcuF,OAAQC,CAAAA,OAAiBA,OAAiB3I,EAAAA;AAAAA,EAE1F;AAAA,EAKA,mBAAAiH;AACI,UAAM2B,KAAc3I,KAAKkD,cAAc0F,IAAK7I,CAAAA,OAASA,GAAK2E,aAAa,SAAA,CAAA;AACvE1E,SAAKqD,gBAAgBrD,KAAK8D,SAAS2E,OAAQ3I,CAAAA,OAAS6I,GAAYH,SAAS1I,GAAK8C,EAAAA,CAAAA;AAAAA,EAClF;AAAA,EAOA,MAAA,SAAeiG,KAAO,GAAA;AAClB,QAAIC,KAAY9I,KAAK+I,IAAIP,SAAS,GAAA;AAClC,UAAM1E,KAAAA,MAAiBkF,MACnB,GAAGhJ,KAAK+I,GAAAA,GAAMD,KAAY,MAAM,GAAA,QAAWD,WAAa7I,KAAKiJ,IAAAA,GAAOjJ,6BAAMkJ,WAAAA,EAAAA;AAE9E,QAAA,CAAKpF,GAASqF,GACV,OAAM,IAAIC,MAAM,sBAAsBtF,GAAStC,MAAAA,EAAAA;AAEnD,WAAA,MAAasC,GAASuF,KAAAA;AAAAA,EAC1B;AAAA,EAkGA,cAAcC,IAAAA;AACV,WAAA;AAAA,EACJ;AAAA;AC9iBJnK,EAAOoK,OAAO,cAAcpK,CAAAA;"}
|
package/dist/wje-label.js
CHANGED
|
@@ -1,53 +1,30 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
class Label extends WJElement {
|
|
7
|
-
/**
|
|
8
|
-
* Creates an instance of Label.
|
|
9
|
-
* @class
|
|
10
|
-
*/
|
|
4
|
+
import o from "./wje-element.js";
|
|
5
|
+
class t extends o {
|
|
11
6
|
constructor() {
|
|
12
7
|
super();
|
|
13
8
|
__publicField(this, "className", "Label");
|
|
14
9
|
}
|
|
15
|
-
/**
|
|
16
|
-
* Returns the CSS styles for the component.
|
|
17
|
-
* @static
|
|
18
|
-
* @returns {CSSStyleSheet}
|
|
19
|
-
*/
|
|
20
10
|
static get cssStyleSheet() {
|
|
21
|
-
return
|
|
11
|
+
return ":host(.wje-color-primary){--wje-color: var(--wje-color-primary) !important}:host(.wje-color-complete){--wje-color: var(--wje-color-complete) !important}:host(.wje-color-success){--wje-color-base: var(--wje-color-success) !important;--wje-color-contrast: var(--wje-color-contrast-0) !important}:host(.wje-color-warning){--wje-color-base: var(--wje-color-warning) !important;--wje-color-contrast: var(--wje-color-contrast-11) !important}:host(.wje-color-danger){--wje-color-base: var(--wje-color-danger) !important;--wje-color-contrast: var(--wje-color-contrast-0) !important}:host(.wje-color-info){--wje-color-base: var(--wje-color-info) !important;--wje-color-contrast: var(--wje-color-contrast-0) !important}:host(.wje-color-menu){--wje-color-base: var(--wje-color-menu) !important;--wje-color-contrast: var(--wje-color-contrast-0) !important}:host{--wje-color: initial;display:block;font-size:inherit;text-overflow:ellipsis;white-space:nowrap;overflow:hidden;box-sizing:border-box}:host(.wje-color){color:current-color(base)}:host(.wje-text-wrap),:host([text-wrap]){white-space:normal!important}:host(.label-fixed){flex:0 0 100px;width:100px;min-width:100px;max-width:200px}:host(.label-stacked),:host(.label-floating){margin-bottom:0;align-self:stretch;width:auto;max-width:100%}:host(.label-no-animate.label-floating){transition:none}::slotted(*) h1,::slotted(*) h2,::slotted(*) h3,::slotted(*) h4,::slotted(*) h5,::slotted(*) h6{text-overflow:inherit;overflow:inherit}:host(.wje-color){color:var(--wje-color)}::slotted(*:first-child){margin-top:0!important}::slotted(*:last-child){margin-bottom:0!important}";
|
|
22
12
|
}
|
|
23
|
-
/**
|
|
24
|
-
* Returns the list of attributes to observe for changes.
|
|
25
|
-
* @static
|
|
26
|
-
* @returns {Array<string>}
|
|
27
|
-
*/
|
|
28
13
|
static get observedAttributes() {
|
|
29
14
|
return [];
|
|
30
15
|
}
|
|
31
|
-
/**
|
|
32
|
-
* Sets up the attributes for the component.
|
|
33
|
-
*/
|
|
34
16
|
setupAttributes() {
|
|
35
17
|
this.isShadowRoot = "open";
|
|
36
18
|
}
|
|
37
|
-
/**
|
|
38
|
-
* Draws the component.
|
|
39
|
-
* @returns {DocumentFragment}
|
|
40
|
-
*/
|
|
41
19
|
draw() {
|
|
42
|
-
let
|
|
43
|
-
|
|
44
|
-
let
|
|
45
|
-
|
|
46
|
-
return fragment;
|
|
20
|
+
let o2 = document.createDocumentFragment();
|
|
21
|
+
this.color && this.classList.add("wje-color-" + params.color, "wje-color");
|
|
22
|
+
let t2 = document.createElement("slot");
|
|
23
|
+
return o2.appendChild(t2), o2;
|
|
47
24
|
}
|
|
48
25
|
}
|
|
49
|
-
|
|
26
|
+
t.define("wje-label", t);
|
|
50
27
|
export {
|
|
51
|
-
|
|
28
|
+
t as default
|
|
52
29
|
};
|
|
53
30
|
//# sourceMappingURL=wje-label.js.map
|
package/dist/wje-label.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wje-label.js","sources":["../packages/wje-label/label.element.js","../packages/wje-label/label.js"],"sourcesContent":["import { default as WJElement } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * `Label` is a custom web component that represents a label.\n * It extends from `WJElement`.\n * @summary This element represents a label.\n * @documentation https://elements.webjet.sk/components/label\n * @status stable\n * @augments {WJElement}\n * @csspart label - The label part of the component.\n * @slot - The default slot for the label.\n * @cssproperty [--wje-label-color=black] - Defines the text color of the label. This property determines the color of the label's text. Accepts any valid CSS color value (e.g., named colors like `black`, `red`, or values like `#000000`, `rgb(0, 0, 0)`).\n * @cssproperty [--wje-label-font-size=16px] - Specifies the font size of the label. This property sets the size of the label's text. Accepts any valid CSS length unit (e.g., `px`, `em`, `rem`). The default value is `16px`, which provides optimal readability in most designs.\n * // @fires wje-label:change - Event fired when the label is changed.\n * @tag wje-label\n */\nexport default class Label extends WJElement {\n /**\n * Creates an instance of Label.\n * @class\n */\n constructor() {\n super();\n }\n\n className = 'Label';\n\n /**\n * Returns the CSS styles for the component.\n * @static\n * @returns {CSSStyleSheet}\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Returns the list of attributes to observe for changes.\n * @static\n * @returns {Array<string>}\n */\n static get observedAttributes() {\n return [];\n }\n\n /**\n * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Draws the component.\n * @returns {DocumentFragment}\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n if (this.color) this.classList.add('wje-color-' + params.color, 'wje-color');\n\n let element = document.createElement('slot');\n\n fragment.appendChild(element);\n\n return fragment;\n }\n}\n","import Label from './label.element.js';\n\nexport default Label;\n\nLabel.define('wje-label', Label);\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wje-label.js","sources":["../packages/wje-label/label.element.js","../packages/wje-label/label.js"],"sourcesContent":["import { default as WJElement } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * `Label` is a custom web component that represents a label.\n * It extends from `WJElement`.\n * @summary This element represents a label.\n * @documentation https://elements.webjet.sk/components/label\n * @status stable\n * @augments {WJElement}\n * @csspart label - The label part of the component.\n * @slot - The default slot for the label.\n * @cssproperty [--wje-label-color=black] - Defines the text color of the label. This property determines the color of the label's text. Accepts any valid CSS color value (e.g., named colors like `black`, `red`, or values like `#000000`, `rgb(0, 0, 0)`).\n * @cssproperty [--wje-label-font-size=16px] - Specifies the font size of the label. This property sets the size of the label's text. Accepts any valid CSS length unit (e.g., `px`, `em`, `rem`). The default value is `16px`, which provides optimal readability in most designs.\n * // @fires wje-label:change - Event fired when the label is changed.\n * @tag wje-label\n */\nexport default class Label extends WJElement {\n /**\n * Creates an instance of Label.\n * @class\n */\n constructor() {\n super();\n }\n\n className = 'Label';\n\n /**\n * Returns the CSS styles for the component.\n * @static\n * @returns {CSSStyleSheet}\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Returns the list of attributes to observe for changes.\n * @static\n * @returns {Array<string>}\n */\n static get observedAttributes() {\n return [];\n }\n\n /**\n * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Draws the component.\n * @returns {DocumentFragment}\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n if (this.color) this.classList.add('wje-color-' + params.color, 'wje-color');\n\n let element = document.createElement('slot');\n\n fragment.appendChild(element);\n\n return fragment;\n }\n}\n","import Label from './label.element.js';\n\nexport default Label;\n\nLabel.define('wje-label', Label);\n"],"names":["Label","WJElement","super","className","cssStyleSheet","observedAttributes","setupAttributes","this","isShadowRoot","fragment","document","createDocumentFragment","color","classList","add","params","element","createElement","appendChild","define"],"mappings":";;;;AAiBe,MAAMA,UAAcC,EAAAA;AAAAA,EAK/B;AACIC,UAAAA;AAGJC,qCAAY;AAAA,EAFZ;AAAA,EASA,WAAA,gBAAWC;AACP;EACJ;AAAA,EAOA,WAAA,qBAAWC;AACP,WAAO,CAAA;AAAA,EACX;AAAA,EAKA,kBAAAC;AACIC,SAAKC,eAAe;AAAA,EACxB;AAAA,EAMA;AACI,QAAIC,KAAWC,SAASC,uBAAAA;AAEpBJ,SAAKK,SAAOL,KAAKM,UAAUC,IAAI,eAAeC,OAAOH,OAAO,WAAA;AAEhE,QAAII,KAAUN,SAASO,cAAc,MAAA;AAIrC,WAFAR,GAASS,YAAYF,EAAAA,GAEdP;AAAAA,EACX;AAAA;AC/DJT,EAAMmB,OAAO,aAAanB,CAAAA;"}
|
|
@@ -1,196 +1,77 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
class LevelIndicator extends WJElement {
|
|
7
|
-
/**
|
|
8
|
-
* Creates an instance of LevelIndicator.
|
|
9
|
-
* @class
|
|
10
|
-
*/
|
|
4
|
+
import e from "./wje-element.js";
|
|
5
|
+
class t extends e {
|
|
11
6
|
constructor() {
|
|
12
7
|
super();
|
|
13
8
|
__publicField(this, "className", "LevelIndicator");
|
|
14
9
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
*/
|
|
19
|
-
set level(value) {
|
|
20
|
-
this.setAttribute("level", value);
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Retrieves the level attribute of an element, with validation to ensure
|
|
24
|
-
* it is within the range of 0 to 3. If the level attribute is not present,
|
|
25
|
-
* the default value is 1. The result is parsed as an integer and constrained
|
|
26
|
-
* to the valid range.
|
|
27
|
-
* @returns {number} The normalized level value, which is an integer between 0 and 3.
|
|
28
|
-
*/
|
|
10
|
+
set level(e2) {
|
|
11
|
+
this.setAttribute("level", e2);
|
|
12
|
+
}
|
|
29
13
|
get level() {
|
|
30
14
|
return Math.min(this.bars, Math.max(0, parseInt(this.getAttribute("level") || "1", 10)));
|
|
31
15
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
*/
|
|
36
|
-
set bars(value) {
|
|
37
|
-
this.setAttribute("bars", value);
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Retrieves the value of the "bars" attribute, parses it as an integer,
|
|
41
|
-
* and ensures it is at least 1. If the attribute is not set, defaults to 3.
|
|
42
|
-
* @returns {number} The parsed integer value of the "bars" attribute or the default value of 3, constrained to a minimum of 1.
|
|
43
|
-
*/
|
|
16
|
+
set bars(e2) {
|
|
17
|
+
this.setAttribute("bars", e2);
|
|
18
|
+
}
|
|
44
19
|
get bars() {
|
|
45
20
|
return Math.max(1, parseInt(this.getAttribute("bars") || "3", 10));
|
|
46
21
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
* @param {boolean} value A boolean determining whether to set or remove the 'colorize' attribute.
|
|
51
|
-
*/
|
|
52
|
-
set colorize(value) {
|
|
53
|
-
this.removeAttribute("colorize");
|
|
54
|
-
if (value) this.setAttribute("colorize", "");
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Determines whether the element has the "colorize" attribute set.
|
|
58
|
-
* @returns {boolean} Returns true if the "colorize" attribute is present, otherwise false.
|
|
59
|
-
*/
|
|
22
|
+
set colorize(e2) {
|
|
23
|
+
this.removeAttribute("colorize"), e2 && this.setAttribute("colorize", "");
|
|
24
|
+
}
|
|
60
25
|
get colorize() {
|
|
61
26
|
return this.hasAttribute("colorize");
|
|
62
27
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
* @param {boolean} value The value determining whether to set or remove the 'reverse' attribute.
|
|
67
|
-
*/
|
|
68
|
-
set reverse(value) {
|
|
69
|
-
this.removeAttribute("reverse");
|
|
70
|
-
if (value) this.setAttribute("reverse", "");
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Getter method to check if the "reverse" attribute is present on the element.
|
|
74
|
-
* @returns {boolean} Returns true if the "reverse" attribute is set; otherwise, returns false.
|
|
75
|
-
*/
|
|
28
|
+
set reverse(e2) {
|
|
29
|
+
this.removeAttribute("reverse"), e2 && this.setAttribute("reverse", "");
|
|
30
|
+
}
|
|
76
31
|
get reverse() {
|
|
77
32
|
return this.hasAttribute("reverse");
|
|
78
33
|
}
|
|
79
|
-
/**
|
|
80
|
-
* Returns the CSS styles for the component.
|
|
81
|
-
* @static
|
|
82
|
-
* @returns {CSSStyleSheet}
|
|
83
|
-
*/
|
|
84
34
|
static get cssStyleSheet() {
|
|
85
|
-
return
|
|
35
|
+
return ":host{display:block}:host .native-level-indicator{display:flex;flex-direction:column-reverse;gap:var(--wje-level-indicator-height);align-items:center;width:var(--wje-level-indicator-width)}:host .reverse{flex-direction:column}:host .bar{width:100%;height:var(--wje-level-indicator-height);background:var(--wje-level-indicator-color);border-radius:var(--wje-level-indicator-border-radius);opacity:var(--wje-level-indicator-opacity);transition:opacity .3s}:host .bar.active{opacity:1;background:var(--wje-level-indicator-color-active)}";
|
|
86
36
|
}
|
|
87
|
-
/**
|
|
88
|
-
* Returns the list of attributes to observe for changes.
|
|
89
|
-
* @static
|
|
90
|
-
* @returns {Array<string>}
|
|
91
|
-
*/
|
|
92
37
|
static get observedAttributes() {
|
|
93
38
|
return ["level", "bars"];
|
|
94
39
|
}
|
|
95
|
-
/**
|
|
96
|
-
* Sets up the attributes for the component.
|
|
97
|
-
*/
|
|
98
40
|
setupAttributes() {
|
|
99
|
-
this.isShadowRoot = "open";
|
|
100
|
-
this.syncAria();
|
|
41
|
+
this.isShadowRoot = "open", this.syncAria();
|
|
101
42
|
}
|
|
102
|
-
/**
|
|
103
|
-
* Creates a document fragment, appends a new slot element to it, and returns the fragment.
|
|
104
|
-
* @returns {DocumentFragment} A document fragment containing a slot element.
|
|
105
|
-
*/
|
|
106
43
|
draw() {
|
|
107
|
-
let
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
let
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
const width = (i + 1) / this.bars * 100;
|
|
116
|
-
let bar = defaultBar.cloneNode(true);
|
|
117
|
-
bar.style.setProperty("width", width + "%");
|
|
118
|
-
native.appendChild(bar);
|
|
119
|
-
this.barsArray.push(bar);
|
|
44
|
+
let e2 = document.createDocumentFragment(), t2 = document.createElement("div");
|
|
45
|
+
t2.classList.add("native-level-indicator"), this.reverse && t2.classList.add("reverse");
|
|
46
|
+
let r = document.createElement("div");
|
|
47
|
+
r.classList.add("bar"), this.barsArray = [];
|
|
48
|
+
for (let e3 = 0; e3 < this.bars; e3++) {
|
|
49
|
+
const i = (e3 + 1) / this.bars * 100;
|
|
50
|
+
let a = r.cloneNode(true);
|
|
51
|
+
a.style.setProperty("width", i + "%"), t2.appendChild(a), this.barsArray.push(a);
|
|
120
52
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
return fragment;
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Executes any additional operations or updates required after the drawing process is completed.
|
|
127
|
-
* @returns {void} This method does not return any value.
|
|
128
|
-
*/
|
|
53
|
+
return e2.appendChild(t2), this.native = t2, e2;
|
|
54
|
+
}
|
|
129
55
|
afterDraw() {
|
|
130
|
-
this.syncAria();
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
"--wje-level-indicator-color-active",
|
|
135
|
-
`var(${this.getColor(this.level, this.barsArray.length)})`
|
|
136
|
-
);
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Handles attribute changes for ARIA sync.
|
|
140
|
-
* @param {string} name
|
|
141
|
-
* @param {string|null} oldValue
|
|
142
|
-
* @param {string|null} newValue
|
|
143
|
-
*/
|
|
144
|
-
attributeChangedCallback(name, oldValue, newValue) {
|
|
145
|
-
if (super.attributeChangedCallback) {
|
|
146
|
-
super.attributeChangedCallback(name, oldValue, newValue);
|
|
147
|
-
}
|
|
148
|
-
if (oldValue !== newValue) {
|
|
149
|
-
this.syncAria();
|
|
150
|
-
}
|
|
56
|
+
this.syncAria(), this.updateBars(this.level, this.barsArray), this.colorize && this.native.style.setProperty("--wje-level-indicator-color-active", `var(${this.getColor(this.level, this.barsArray.length)})`);
|
|
57
|
+
}
|
|
58
|
+
attributeChangedCallback(e2, t2, r) {
|
|
59
|
+
super.attributeChangedCallback && super.attributeChangedCallback(e2, t2, r), t2 !== r && this.syncAria();
|
|
151
60
|
}
|
|
152
|
-
/**
|
|
153
|
-
* Sync ARIA attributes on host.
|
|
154
|
-
*/
|
|
155
61
|
syncAria() {
|
|
156
|
-
this.setAriaState({
|
|
157
|
-
role: "meter",
|
|
158
|
-
valuemin: 0,
|
|
159
|
-
valuemax: this.bars,
|
|
160
|
-
valuenow: this.level,
|
|
161
|
-
valuetext: `${this.level} of ${this.bars}`
|
|
162
|
-
});
|
|
62
|
+
this.setAriaState({ role: "meter", valuemin: 0, valuemax: this.bars, valuenow: this.level, valuetext: `${this.level} of ${this.bars}` });
|
|
163
63
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
* @param {Array} bars An array of bar elements to be updated.
|
|
168
|
-
* @returns {void} This method does not return a value.
|
|
169
|
-
*/
|
|
170
|
-
updateBars(level, bars) {
|
|
171
|
-
bars.forEach((bar, index) => {
|
|
172
|
-
bar.classList.toggle("active", index < level);
|
|
64
|
+
updateBars(e2, t2) {
|
|
65
|
+
t2.forEach((t3, r) => {
|
|
66
|
+
t3.classList.toggle("active", r < e2);
|
|
173
67
|
});
|
|
174
68
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
* @param {number} level The current value level used to calculate the ratio.
|
|
178
|
-
* @param {number} bars The maximum value that level can reach.
|
|
179
|
-
* @returns {string | undefined} A string representing the color code based on the ratio, or undefined if colorize is disabled.
|
|
180
|
-
*/
|
|
181
|
-
getColor(level, bars) {
|
|
182
|
-
const thresholds = [
|
|
183
|
-
"--wje-level-indicator-color-low",
|
|
184
|
-
"--wje-level-indicator-color-medium",
|
|
185
|
-
"--wje-level-indicator-color-high"
|
|
186
|
-
// 67% - 100% (tretia tretina)
|
|
187
|
-
];
|
|
188
|
-
const index = Math.min(2, Math.floor((level - 1) / (bars / 3)));
|
|
189
|
-
return thresholds[index];
|
|
69
|
+
getColor(e2, t2) {
|
|
70
|
+
return ["--wje-level-indicator-color-low", "--wje-level-indicator-color-medium", "--wje-level-indicator-color-high"][Math.min(2, Math.floor((e2 - 1) / (t2 / 3)))];
|
|
190
71
|
}
|
|
191
72
|
}
|
|
192
|
-
|
|
73
|
+
t.define("wje-level-indicator", t);
|
|
193
74
|
export {
|
|
194
|
-
|
|
75
|
+
t as default
|
|
195
76
|
};
|
|
196
77
|
//# sourceMappingURL=wje-level-indicator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wje-level-indicator.js","sources":["../packages/wje-level-indicator/level-indicator.element.js","../packages/wje-level-indicator/level-indicator.js"],"sourcesContent":["import { default as WJElement, event } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary LevelIndicator is a custom web component that extends WJElement.\n * @documentation https://elements.webjet.sk/components/LevelIndicator\n * @status stable\n * @augments WJElement\n * @csspart - Styles the element.\n * @tag wje-level-indicator\n * @example\n * <wje-level-indicator></wje-level-indicator>\n */\nexport default class LevelIndicator extends WJElement {\n /**\n * Creates an instance of LevelIndicator.\n * @class\n */\n constructor() {\n super();\n }\n\n /**\n * Sets the level attribute for an instance.\n * @param {string} value The value to set for the 'level' attribute.\n */\n set level(value) {\n this.setAttribute('level', value);\n }\n\n /**\n * Retrieves the level attribute of an element, with validation to ensure\n * it is within the range of 0 to 3. If the level attribute is not present,\n * the default value is 1. The result is parsed as an integer and constrained\n * to the valid range.\n * @returns {number} The normalized level value, which is an integer between 0 and 3.\n */\n get level() {\n return Math.min(this.bars, Math.max(0, parseInt(this.getAttribute('level') || '1', 10)));\n }\n\n /**\n * Sets the value of the \"bars\" attribute.\n * @param {string} value The value to set for the \"bars\" attribute.\n */\n set bars(value) {\n this.setAttribute('bars', value);\n }\n\n /**\n * Retrieves the value of the \"bars\" attribute, parses it as an integer,\n * and ensures it is at least 1. If the attribute is not set, defaults to 3.\n * @returns {number} The parsed integer value of the \"bars\" attribute or the default value of 3, constrained to a minimum of 1.\n */\n get bars() {\n return Math.max(1, parseInt(this.getAttribute('bars') || '3', 10));\n }\n\n /**\n * Sets the 'colorize' attribute on the element. If the provided value is truthy,\n * the attribute will be set. If the value is falsy, the attribute will be removed.\n * @param {boolean} value A boolean determining whether to set or remove the 'colorize' attribute.\n */\n set colorize(value) {\n this.removeAttribute('colorize');\n\n if (value) this.setAttribute('colorize', '');\n }\n\n /**\n * Determines whether the element has the \"colorize\" attribute set.\n * @returns {boolean} Returns true if the \"colorize\" attribute is present, otherwise false.\n */\n get colorize() {\n return this.hasAttribute('colorize');\n }\n\n /**\n * Sets the 'reverse' attribute on the element. If the provided value is truthy, the attribute is added;\n * otherwise, the attribute is removed.\n * @param {boolean} value The value determining whether to set or remove the 'reverse' attribute.\n */\n set reverse(value) {\n this.removeAttribute('reverse');\n\n if (value) this.setAttribute('reverse', '');\n }\n\n /**\n * Getter method to check if the \"reverse\" attribute is present on the element.\n * @returns {boolean} Returns true if the \"reverse\" attribute is set; otherwise, returns false.\n */\n get reverse() {\n return this.hasAttribute('reverse');\n }\n\n className = 'LevelIndicator';\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 ['level', 'bars'];\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 * 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.classList.add('native-level-indicator');\n if (this.reverse) native.classList.add('reverse');\n\n let defaultBar = document.createElement('div');\n defaultBar.classList.add('bar');\n\n this.barsArray = [];\n\n for (let i = 0; i < this.bars; i++) {\n const width = ((i + 1) / this.bars) * 100;\n\n let bar = defaultBar.cloneNode(true);\n bar.style.setProperty('width', width + '%');\n\n native.appendChild(bar);\n this.barsArray.push(bar);\n }\n\n fragment.appendChild(native);\n\n this.native = native;\n\n return fragment;\n }\n\n /**\n * Executes any additional operations or updates required after the drawing process is completed.\n * @returns {void} This method does not return any value.\n */\n afterDraw() {\n this.syncAria();\n this.updateBars(this.level, this.barsArray);\n\n if (this.colorize)\n this.native.style.setProperty(\n '--wje-level-indicator-color-active',\n `var(${this.getColor(this.level, this.barsArray.length)})`\n );\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 (oldValue !== newValue) {\n this.syncAria();\n }\n }\n\n /**\n * Sync ARIA attributes on host.\n */\n syncAria() {\n this.setAriaState({\n role: 'meter',\n valuemin: 0,\n valuemax: this.bars,\n valuenow: this.level,\n valuetext: `${this.level} of ${this.bars}`,\n });\n }\n\n /**\n * Updates the class of each bar element based on the specified level.\n * @param {number} level The threshold level determining how many bars should be active.\n * @param {Array} bars An array of bar elements to be updated.\n * @returns {void} This method does not return a value.\n */\n updateBars(level, bars) {\n bars.forEach((bar, index) => {\n bar.classList.toggle('active', index < level);\n });\n }\n\n /**\n * Determines the color indicator based on the given level and bars.\n * @param {number} level The current value level used to calculate the ratio.\n * @param {number} bars The maximum value that level can reach.\n * @returns {string | undefined} A string representing the color code based on the ratio, or undefined if colorize is disabled.\n */\n\n getColor(level, bars) {\n const thresholds = [\n '--wje-level-indicator-color-low',\n '--wje-level-indicator-color-medium',\n '--wje-level-indicator-color-high', // 67% - 100% (tretia tretina)\n ];\n\n const index = Math.min(2, Math.floor((level - 1) / (bars / 3)));\n return thresholds[index];\n }\n}\n","import LevelIndicator from './level-indicator.element.js';\n\nexport default LevelIndicator;\n\nLevelIndicator.define('wje-level-indicator', LevelIndicator);\n"],"names":[],"mappings":";;;;;AAae,MAAM,uBAAuB,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA,EAKlD,cAAc;AACV,UAAK;AA6ET,qCAAY;AAAA,EA5EZ;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAI,MAAM,OAAO;AACb,SAAK,aAAa,SAAS,KAAK;AAAA,EACpC;AAAA;AAAA;A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,WAAW,OAAO,MAAM;AACpB,SAAK,QAAQ,CAAC,KAAK,UAAU;AACzB,UAAI,UAAU,OAAO,UAAU,QAAQ,KAAK;AAAA,IAChD,CAAC;AAAA,EACL;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,SAAS,OAAO,MAAM;AAClB,UAAM,aAAa;AAAA,MACf;AAAA,MACA;AAAA,MACA;AAAA;AAAA,IACZ;AAEQ,UAAM,QAAQ,KAAK,IAAI,GAAG,KAAK,OAAO,QAAQ,MAAM,OAAO,EAAE,CAAC;AAC9D,WAAO,WAAW,KAAK;AAAA,EAC3B;AACJ;AClOA,eAAe,OAAO,uBAAuB,cAAc;"}
|
|
1
|
+
{"version":3,"file":"wje-level-indicator.js","sources":["../packages/wje-level-indicator/level-indicator.element.js","../packages/wje-level-indicator/level-indicator.js"],"sourcesContent":["import { default as WJElement, event } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary LevelIndicator is a custom web component that extends WJElement.\n * @documentation https://elements.webjet.sk/components/LevelIndicator\n * @status stable\n * @augments WJElement\n * @csspart - Styles the element.\n * @tag wje-level-indicator\n * @example\n * <wje-level-indicator></wje-level-indicator>\n */\nexport default class LevelIndicator extends WJElement {\n /**\n * Creates an instance of LevelIndicator.\n * @class\n */\n constructor() {\n super();\n }\n\n /**\n * Sets the level attribute for an instance.\n * @param {string} value The value to set for the 'level' attribute.\n */\n set level(value) {\n this.setAttribute('level', value);\n }\n\n /**\n * Retrieves the level attribute of an element, with validation to ensure\n * it is within the range of 0 to 3. If the level attribute is not present,\n * the default value is 1. The result is parsed as an integer and constrained\n * to the valid range.\n * @returns {number} The normalized level value, which is an integer between 0 and 3.\n */\n get level() {\n return Math.min(this.bars, Math.max(0, parseInt(this.getAttribute('level') || '1', 10)));\n }\n\n /**\n * Sets the value of the \"bars\" attribute.\n * @param {string} value The value to set for the \"bars\" attribute.\n */\n set bars(value) {\n this.setAttribute('bars', value);\n }\n\n /**\n * Retrieves the value of the \"bars\" attribute, parses it as an integer,\n * and ensures it is at least 1. If the attribute is not set, defaults to 3.\n * @returns {number} The parsed integer value of the \"bars\" attribute or the default value of 3, constrained to a minimum of 1.\n */\n get bars() {\n return Math.max(1, parseInt(this.getAttribute('bars') || '3', 10));\n }\n\n /**\n * Sets the 'colorize' attribute on the element. If the provided value is truthy,\n * the attribute will be set. If the value is falsy, the attribute will be removed.\n * @param {boolean} value A boolean determining whether to set or remove the 'colorize' attribute.\n */\n set colorize(value) {\n this.removeAttribute('colorize');\n\n if (value) this.setAttribute('colorize', '');\n }\n\n /**\n * Determines whether the element has the \"colorize\" attribute set.\n * @returns {boolean} Returns true if the \"colorize\" attribute is present, otherwise false.\n */\n get colorize() {\n return this.hasAttribute('colorize');\n }\n\n /**\n * Sets the 'reverse' attribute on the element. If the provided value is truthy, the attribute is added;\n * otherwise, the attribute is removed.\n * @param {boolean} value The value determining whether to set or remove the 'reverse' attribute.\n */\n set reverse(value) {\n this.removeAttribute('reverse');\n\n if (value) this.setAttribute('reverse', '');\n }\n\n /**\n * Getter method to check if the \"reverse\" attribute is present on the element.\n * @returns {boolean} Returns true if the \"reverse\" attribute is set; otherwise, returns false.\n */\n get reverse() {\n return this.hasAttribute('reverse');\n }\n\n className = 'LevelIndicator';\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 ['level', 'bars'];\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 * 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.classList.add('native-level-indicator');\n if (this.reverse) native.classList.add('reverse');\n\n let defaultBar = document.createElement('div');\n defaultBar.classList.add('bar');\n\n this.barsArray = [];\n\n for (let i = 0; i < this.bars; i++) {\n const width = ((i + 1) / this.bars) * 100;\n\n let bar = defaultBar.cloneNode(true);\n bar.style.setProperty('width', width + '%');\n\n native.appendChild(bar);\n this.barsArray.push(bar);\n }\n\n fragment.appendChild(native);\n\n this.native = native;\n\n return fragment;\n }\n\n /**\n * Executes any additional operations or updates required after the drawing process is completed.\n * @returns {void} This method does not return any value.\n */\n afterDraw() {\n this.syncAria();\n this.updateBars(this.level, this.barsArray);\n\n if (this.colorize)\n this.native.style.setProperty(\n '--wje-level-indicator-color-active',\n `var(${this.getColor(this.level, this.barsArray.length)})`\n );\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 (oldValue !== newValue) {\n this.syncAria();\n }\n }\n\n /**\n * Sync ARIA attributes on host.\n */\n syncAria() {\n this.setAriaState({\n role: 'meter',\n valuemin: 0,\n valuemax: this.bars,\n valuenow: this.level,\n valuetext: `${this.level} of ${this.bars}`,\n });\n }\n\n /**\n * Updates the class of each bar element based on the specified level.\n * @param {number} level The threshold level determining how many bars should be active.\n * @param {Array} bars An array of bar elements to be updated.\n * @returns {void} This method does not return a value.\n */\n updateBars(level, bars) {\n bars.forEach((bar, index) => {\n bar.classList.toggle('active', index < level);\n });\n }\n\n /**\n * Determines the color indicator based on the given level and bars.\n * @param {number} level The current value level used to calculate the ratio.\n * @param {number} bars The maximum value that level can reach.\n * @returns {string | undefined} A string representing the color code based on the ratio, or undefined if colorize is disabled.\n */\n\n getColor(level, bars) {\n const thresholds = [\n '--wje-level-indicator-color-low',\n '--wje-level-indicator-color-medium',\n '--wje-level-indicator-color-high', // 67% - 100% (tretia tretina)\n ];\n\n const index = Math.min(2, Math.floor((level - 1) / (bars / 3)));\n return thresholds[index];\n }\n}\n","import LevelIndicator from './level-indicator.element.js';\n\nexport default LevelIndicator;\n\nLevelIndicator.define('wje-level-indicator', LevelIndicator);\n"],"names":["LevelIndicator","WJElement","constructor","super","className","value","this","setAttribute","level","Math","min","bars","max","parseInt","getAttribute","removeAttribute","colorize","hasAttribute","reverse","cssStyleSheet","observedAttributes","setupAttributes","isShadowRoot","syncAria","fragment","document","createDocumentFragment","native","createElement","classList","add","defaultBar","barsArray","i","width","bar","cloneNode","style","setProperty","appendChild","push","afterDraw","updateBars","getColor","length","name","oldValue","newValue","attributeChangedCallback","setAriaState","role","valuemin","valuemax","valuenow","valuetext","forEach","index","toggle","floor","define"],"mappings":";;;;AAae,MAAMA,UAAuBC,EAAAA;AAAAA,EAKxC,cAAAC;AACIC,UAAAA;AA6EJC,qCAAY;AAAA,EA5EZ;AAAA,EAMA,IAAA,MAAUC,IAAAA;AACNC,SAAKC,aAAa,SAASF,EAAAA;AAAAA,EAC/B;AAAA,EASA,IAAA,QAAIG;AACA,WAAOC,KAAKC,IAAIJ,KAAKK,MAAMF,KAAKG,IAAI,GAAGC,SAASP,KAAKQ,aAAa,OAAA,KAAY,KAAK,EAAA,CAAA,CAAA;AAAA,EACvF;AAAA,EAMA,IAAA,KAAST,IAAAA;AACLC,SAAKC,aAAa,QAAQF,EAAAA;AAAAA,EAC9B;AAAA,EAOA,WAAIM;AACA,WAAOF,KAAKG,IAAI,GAAGC,SAASP,KAAKQ,aAAa,WAAW,KAAK,EAAA,CAAA;AAAA,EAClE;AAAA,EAOA,IAAA,SAAaT,IAAAA;AACTC,SAAKS,gBAAgB,aAEjBV,MAAOC,KAAKC,aAAa,YAAY;EAC7C;AAAA,EAMA,IAAA,WAAIS;AACA,WAAOV,KAAKW,aAAa,UAAA;AAAA,EAC7B;AAAA,EAOA,IAAA,QAAYZ,IAAAA;AACRC,SAAKS,gBAAgB,YAEjBV,MAAOC,KAAKC,aAAa,WAAW,EAAA;AAAA,EAC5C;AAAA,EAMA,IAAA,U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AA;AAAAA,EAEb;AAAA,EAKA,WAAAA;AACIjB,SAAK2C,aAAa,EACdC,MAAM,SACNC,UAAU,GACVC,UAAU9C,KAAKK,MACf0C,UAAU/C,KAAKE,OACf8C,WAAW,GAAGhD,KAAKE,KAAAA,OAAYF,KAAKK,IAAAA,GAAAA,CAAAA;AAAAA,EAE5C;AAAA,EAQA,WAAWH,IAAOG,IAAAA;AACdA,IAAAA,GAAK4C,QAAQ,CAACpB,IAAKqB;AACfrB,MAAAA,GAAIN,UAAU4B,OAAO,UAAUD,IAAQhD,EAAAA;AAAAA,IAAAA,CAAAA;AAAAA,EAE/C;AAAA,EASA,SAASA,IAAOG,IAAAA;AAQZ,WAPmB,CACf,mCACA,sCACA,kCAAA,EAGUF,KAAKC,IAAI,GAAGD,KAAKiD,OAAOlD,KAAQ,MAAMG,KAAO,EAAA,CAAA,CAAA;AAAA,EAE/D;AAAA;ACjOJX,EAAe2D,OAAO,uBAAuB3D,CAAAA;"}
|
package/dist/wje-list.js
CHANGED
|
@@ -1,61 +1,31 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
class List extends WJElement {
|
|
7
|
-
/**
|
|
8
|
-
* Creates an instance of List.
|
|
9
|
-
* @class
|
|
10
|
-
*/
|
|
4
|
+
import t from "./wje-element.js";
|
|
5
|
+
class e extends t {
|
|
11
6
|
constructor() {
|
|
12
7
|
super();
|
|
13
8
|
__publicField(this, "className", "List");
|
|
14
9
|
}
|
|
15
|
-
/**
|
|
16
|
-
* Returns the CSS styles for the component.
|
|
17
|
-
* @static
|
|
18
|
-
* @returns {CSSStyleSheet}
|
|
19
|
-
*/
|
|
20
10
|
static get cssStyleSheet() {
|
|
21
|
-
return
|
|
11
|
+
return ":host{margin:0;padding:0;display:block;list-style-type:none}:host(.wje-inset){background:var(--wje-list-background);transform:translateZ(0);overflow:hidden;padding:var(--wje-list-inset-padding);border-radius:var(--wje-list-border-radius)}:host(.wje-lines-none) ::slotted(wje-item){--wje-border-width: 0 !important;--wje-item-border-width: 0!important}";
|
|
22
12
|
}
|
|
23
|
-
/**
|
|
24
|
-
* Sets up the attributes for the component.
|
|
25
|
-
*/
|
|
26
13
|
setupAttributes() {
|
|
27
|
-
this.isShadowRoot = "open";
|
|
28
|
-
this.syncAria();
|
|
14
|
+
this.isShadowRoot = "open", this.syncAria();
|
|
29
15
|
}
|
|
30
|
-
/**
|
|
31
|
-
* Returns the list of attributes to observe for changes.
|
|
32
|
-
* @returns {DocumentFragment}
|
|
33
|
-
*/
|
|
34
16
|
draw() {
|
|
35
|
-
let
|
|
36
|
-
|
|
37
|
-
fragment.appendChild(element);
|
|
38
|
-
return fragment;
|
|
17
|
+
let t2 = document.createDocumentFragment(), e2 = document.createElement("slot");
|
|
18
|
+
return t2.appendChild(e2), t2;
|
|
39
19
|
}
|
|
40
|
-
/**
|
|
41
|
-
* Called after the component has been drawn.
|
|
42
|
-
*/
|
|
43
20
|
afterDraw() {
|
|
44
|
-
this.syncAria();
|
|
45
|
-
this.classList.toggle("wje-lines-" + this.lines, this.hasAttribute("lines"));
|
|
46
|
-
this.classList.toggle("wje-inset", this.hasAttribute("inset"));
|
|
21
|
+
this.syncAria(), this.classList.toggle("wje-lines-" + this.lines, this.hasAttribute("lines")), this.classList.toggle("wje-inset", this.hasAttribute("inset"));
|
|
47
22
|
}
|
|
48
|
-
/**
|
|
49
|
-
* Sync ARIA attributes on host.
|
|
50
|
-
*/
|
|
51
23
|
syncAria() {
|
|
52
|
-
|
|
53
|
-
this.setAriaState({ role: "list" });
|
|
54
|
-
}
|
|
24
|
+
this.hasAttribute("role") || this.setAriaState({ role: "list" });
|
|
55
25
|
}
|
|
56
26
|
}
|
|
57
|
-
|
|
27
|
+
e.define("wje-list", e);
|
|
58
28
|
export {
|
|
59
|
-
|
|
29
|
+
e as default
|
|
60
30
|
};
|
|
61
31
|
//# sourceMappingURL=wje-list.js.map
|
package/dist/wje-list.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wje-list.js","sources":["../packages/wje-list/list.element.js","../packages/wje-list/list.js"],"sourcesContent":["import { default as WJElement } from '../wje-element/element.js';\n\nimport styles from './styles/styles.css?inline';\n\n/**\n * `List` is a custom web component that represents a list.\n * It extends from `WJElement`.\n * @summary This element represents a list.\n * @documentation https://elements.webjet.sk/components/list\n * @status stable\n * @augments {WJElement}\n * @slot - The default slot for the list.\n * @cssproperty [--wje-list-inset-padding=1rem] - The padding of the list when it is inset.\n * @cssproperty [--wje-list-border-radius=8px] - The border radius of the list. Accepts any valid CSS length.\n * @cssproperty [--wje-list-background=var(--wje-background)] - The background of the list. Accepts any valid CSS color value.\n * @tag wje-list\n */\nexport default class List extends WJElement {\n /**\n * Creates an instance of List.\n * @class\n */\n constructor() {\n super();\n }\n\n className = 'List';\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 * Returns the list of attributes to observe for changes.\n * @returns {DocumentFragment}\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let element = document.createElement('slot');\n fragment.appendChild(element);\n\n return fragment;\n }\n\n /**\n * Called after the component has been drawn.\n */\n afterDraw() {\n this.syncAria();\n this.classList.toggle('wje-lines-' + this.lines, this.hasAttribute('lines'));\n this.classList.toggle('wje-inset', this.hasAttribute('inset'));\n }\n\n /**\n * Sync ARIA attributes on host.\n */\n syncAria() {\n if (!this.hasAttribute('role')) {\n this.setAriaState({ role: 'list' });\n }\n }\n}\n","import List from './list.element.js';\n\nexport default List;\n\nList.define('wje-list', List);\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wje-list.js","sources":["../packages/wje-list/list.element.js","../packages/wje-list/list.js"],"sourcesContent":["import { default as WJElement } from '../wje-element/element.js';\n\nimport styles from './styles/styles.css?inline';\n\n/**\n * `List` is a custom web component that represents a list.\n * It extends from `WJElement`.\n * @summary This element represents a list.\n * @documentation https://elements.webjet.sk/components/list\n * @status stable\n * @augments {WJElement}\n * @slot - The default slot for the list.\n * @cssproperty [--wje-list-inset-padding=1rem] - The padding of the list when it is inset.\n * @cssproperty [--wje-list-border-radius=8px] - The border radius of the list. Accepts any valid CSS length.\n * @cssproperty [--wje-list-background=var(--wje-background)] - The background of the list. Accepts any valid CSS color value.\n * @tag wje-list\n */\nexport default class List extends WJElement {\n /**\n * Creates an instance of List.\n * @class\n */\n constructor() {\n super();\n }\n\n className = 'List';\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 * Returns the list of attributes to observe for changes.\n * @returns {DocumentFragment}\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let element = document.createElement('slot');\n fragment.appendChild(element);\n\n return fragment;\n }\n\n /**\n * Called after the component has been drawn.\n */\n afterDraw() {\n this.syncAria();\n this.classList.toggle('wje-lines-' + this.lines, this.hasAttribute('lines'));\n this.classList.toggle('wje-inset', this.hasAttribute('inset'));\n }\n\n /**\n * Sync ARIA attributes on host.\n */\n syncAria() {\n if (!this.hasAttribute('role')) {\n this.setAriaState({ role: 'list' });\n }\n }\n}\n","import List from './list.element.js';\n\nexport default List;\n\nList.define('wje-list', List);\n"],"names":["List","WJElement","constructor","super","className","cssStyleSheet","setupAttributes","this","isShadowRoot","syncAria","fragment","document","createDocumentFragment","element","createElement","appendChild","afterDraw","classList","toggle","lines","hasAttribute","setAriaState","role","define"],"mappings":";;;;AAiBe,MAAMA,UAAaC,EAAAA;AAAAA,EAK9B,cAAAC;AACIC,UAAAA;AAGJC,qCAAY;AAAA,EAFZ;AAAA,EASA,WAAA,gBAAWC;AACP;EACJ;AAAA,EAKA,kBAAAC;AACIC,SAAKC,eAAe,QACpBD,KAAKE,SAAAA;AAAAA,EACT;AAAA,EAMA;AACI,QAAIC,KAAWC,SAASC,uBAAAA,GAEpBC,KAAUF,SAASG,cAAc,MAAA;AAGrC,WAFAJ,GAASK,YAAYF,EAAAA,GAEdH;AAAAA,EACX;AAAA,EAKA,YAAAM;AACIT,SAAKE,SAAAA,GACLF,KAAKU,UAAUC,OAAO,eAAeX,KAAKY,OAAOZ,KAAKa,aAAa,OAAA,CAAA,GACnEb,KAAKU,UAAUC,OAAO,aAAaX,KAAKa,aAAa;EACzD;AAAA,EAKA,WAAAX;AACSF,SAAKa,aAAa,MAAA,KACnBb,KAAKc,aAAa,EAAEC,MAAM,OAAA,CAAA;AAAA,EAElC;AAAA;ACtEJtB,EAAKuB,OAAO,YAAYvB,CAAAA;"}
|