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-stepper.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wje-stepper.js","sources":["../packages/wje-stepper/stepper.element.js","../packages/wje-stepper/stepper.js"],"sourcesContent":["import { Localizer } from '../utils/localize.js';\nimport { default as WJElement, event } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\nlet stepperId = 0;\n\n/**\n * `Stepper` is a custom web component that represents a stepper.\n * @summary This element represents a stepper.\n * @documentation https://elements.webjet.sk/components/stepper\n * @status stable\n * @augments WJElement\n * @attribute {string} active - The active color for the stepper.\n * @attribute {string} done - The done color for the stepper.\n * @slot - The default slot for the stepper.\n * @csspart native - The native part of the stepper.\n * @csspart header - The header part of the stepper.\n * @csspart content - The content part of the stepper.\n * @tag wje-stepper\n */\nexport default class Stepper extends WJElement {\n\tconstructor() {\n\t\tsuper();\n\t\tthis.currentStep = 0;\n\n\t\tthis.localizer = new Localizer(this);\n\t\tthis.steps = [];\n\t\tthis.headerSteps = [];\n\t\tthis._stepperId = ++stepperId;\n\n\t}\n\n\t/**\n\t * Sets the start index for an operation or a process. This method assigns\n\t * the provided value to the attribute 'start-index'.\n\t * @param {number|string} value The value to set for the 'start-index' attribute.\n\t */\n\tset startIndex(value) {\n\t\tthis.setAttribute('start-index', value);\n\t}\n\n\t/**\n\t * Retrieves the starting index value stored as an attribute.\n\t * If the attribute 'start-index' exists and is not null, it parses the value as an integer and returns it.\n\t * If the attribute does not exist, it returns the default value of 0.\n\t * @returns {number} The starting index as an integer, or 0 if the attribute is not present.\n\t */\n\tget startIndex() {\n\t\tconst index = this.getAttribute('start-index');\n\t\treturn index !== null ? +index : 0;\n\t}\n\n\tget active() {\n\t\tif (this.hasAttribute('active')) return this.getAttribute('active');\n\n\t\treturn 'primary';\n\t}\n\n\tget done() {\n\t\tif (this.hasAttribute('done')) return this.getAttribute('done');\n\n\t\treturn 'success';\n\t}\n\n\tclassName = 'Stepper';\n\n\tstatic get cssStyleSheet() {\n\t\treturn styles;\n\t}\n\n\tsetupAttributes() {\n\t\tthis.isShadowRoot = 'open';\n\t}\n\n\t/**\n\t * Draws the component for the stepper.\n\t * @returns {DocumentFragment}\n\t */\n\tdraw() {\n\t\tlet fragment = document.createDocumentFragment();\n\n\t\tconst native = document.createElement('div');\n\t\tnative.setAttribute('part', 'native');\n\t\tnative.className = 'native-stepper';\n\n\t\tconst header = document.createElement('div');\n\t\theader.setAttribute('part', 'header');\n\t\theader.className = 'header';\n\t\theader.setAttribute('role', 'tablist');\n\n\t\tconst content = document.createElement('div');\n\t\tcontent.setAttribute('part', 'content');\n\t\tcontent.className = 'content';\n\n\t\tconst steps = Array.from(this.children);\n\n\t\tsteps?.forEach((step, index) => {\n\t\t\tif (step.nodeName === 'WJE-STEP') {\n\t\t\t\tthis.headerSteps.push(this.processStep(index, step, header, steps));\n\t\t\t}\n\t\t});\n\n\t\tlet slot = document.createElement('slot');\n\n\t\tconst navButtons = document.createElement('div');\n\t\tnavButtons.className = 'nav-buttons';\n\n\t\tconst prevButton = document.createElement('wje-button');\n\t\tprevButton.setAttribute('label', this.localizer.translate('wj.stepper.button.previous'));\n\t\tprevButton.innerHTML = this.localizer.translate('wj.stepper.button.previous');\n\n\t\tlet nextButton = document.createElement('wje-button');\n\t\tnextButton.setAttribute('label', this.localizer.translate('wj.stepper.button.next'));\n\t\tnextButton.innerHTML = this.localizer.translate('wj.stepper.button.next');\n\n\t\tlet finishButton = document.createElement('wje-button');\n\t\tfinishButton.setAttribute('label', this.localizer.translate('wj.stepper.button.next'));\n\t\tfinishButton.innerHTML = this.localizer.translate('wj.stepper.button.finish');\n\t\tfinishButton.setAttribute('color', 'primary');\n\n\t\tconst navButtonPrevSlot = document.createElement('slot');\n\t\tnavButtonPrevSlot.setAttribute('name', 'prev');\n\t\tnavButtonPrevSlot.appendChild(prevButton);\n\t\tnavButtonPrevSlot.hidden = this.currentStep === 0;\n\n\t\tconst navButtonNextSlot = document.createElement('slot');\n\t\tnavButtonNextSlot.setAttribute('name', 'next');\n\t\tnavButtonNextSlot.appendChild(nextButton);\n\t\tnavButtonNextSlot.hidden = this.currentStep === this.steps.length - 1;\n\n\t\tconst navButtonFinishSlot = document.createElement('slot');\n\t\tnavButtonFinishSlot.setAttribute('name', 'finish');\n\t\tnavButtonFinishSlot.appendChild(nextButton);\n\t\tnavButtonFinishSlot.hidden = this.currentStep !== this.steps.length - 1;\n\n\t\tconst isNextLocked = this.headerSteps[this.currentStep + 1]?.hasAttribute('locked');\n\t\tnavButtonNextSlot.toggleAttribute('disabled', !!isNextLocked);\n\t\tnavButtonFinishSlot.toggleAttribute('disabled', !!isNextLocked);\n\n\t\tif (steps.length > 1) {\n\t\t\tnavButtonPrevSlot.appendChild(prevButton);\n\t\t\tnavButtonNextSlot.appendChild(nextButton);\n\t\t\tnavButtonFinishSlot.appendChild(finishButton);\n\t\t\tnavButtonFinishSlot.style.display = 'none';\n\n\t\t} else {\n\t\t\tnavButtonPrevSlot.hidden = true;\n\t\t\tnavButtonNextSlot.hidden = true;\n\t\t\tnavButtonPrevSlot.appendChild(prevButton);\n\t\t\tnavButtonNextSlot.appendChild(nextButton);\n\t\t\tnavButtonFinishSlot.appendChild(finishButton);\n\t\t}\n\n\t\tcontent.appendChild(slot);\n\n\t\tnative.appendChild(header);\n\t\tnative.appendChild(content);\n\t\tnative.appendChild(navButtons);\n\n\t\tnavButtons.appendChild(navButtonPrevSlot);\n\t\tnavButtons.appendChild(navButtonNextSlot);\n\t\tnavButtons.appendChild(navButtonFinishSlot);\n\n\t\tfragment.appendChild(native);\n\n\t\tthis.header = header;\n\t\tthis.prev = navButtonPrevSlot;\n\t\tthis.next = navButtonNextSlot;\n\t\tthis.finish = navButtonFinishSlot;\n\n\t\treturn fragment;\n\t}\n\n\tprocessStep(index, step, header, steps) {\n\t\tconst nav = document.createElement('div');\n\t\tnav.className = 'step-header';\n\t\tnav.setAttribute('role', 'tab');\n\t\tnav.addEventListener('click', (e) => {\n\t\t\tthis.goToStep(index)\n\t\t});\n\n\t\tconst badge = document.createElement('wje-badge');\n\t\tbadge.setAttribute('label', (index + 1).toString());\n\t\tbadge.className = 'step-badge';\n\t\tbadge.innerHTML = index + 1;\n\n\t\tconst label = document.createElement('span');\n\t\tlabel.innerText = step.getAttribute('label') || `${this.localizer.translate('wj.stepper.step')} ${index + 1}`; // default label\n\n\t\tconst panelId = step.id || `wje-stepper-${this._stepperId}-panel-${index}`;\n\t\tconst tabId = nav.id || `wje-stepper-${this._stepperId}-tab-${index}`;\n\t\tstep.id = panelId;\n\t\tnav.id = tabId;\n\t\tnav.setAttribute('aria-controls', panelId);\n\t\tstep.setAttribute('role', 'tabpanel');\n\t\tstep.setAttribute('aria-labelledby', tabId);\n\n\t\t// set active step\n\t\tif (index === this.currentStep || step.hasAttribute('active')) {\n\t\t\tthis.setStepActive(nav, badge, index);\n\t\t} else {\n\t\t\tnav.setAttribute('aria-selected', 'false');\n\t\t\tnav.setAttribute('tabindex', '-1');\n\t\t}\n\n\t\tif (step.hasAttribute('disabled')) {\n\t\t\tnav.setAttribute('disabled', '');\n\t\t\tthis.setStepLocked(nav, badge);\n\t\t} else {\n\t\t\tnav.classList.add('pointer');\n\t\t}\n\n\t\tnav.appendChild(badge);\n\t\tnav.appendChild(label);\n\n\t\theader.appendChild(nav);\n\n\t\tif (index < steps.length - 1) {\n\t\t\tconst arrowIcon = document.createElement('wje-icon');\n\t\t\tarrowIcon.setAttribute('name', 'chevron-right');\n\t\t\tarrowIcon.classList.add('arrow-icon');\n\t\t\tarrowIcon.setAttribute('size', 'small');\n\n\t\t\theader.appendChild(arrowIcon);\n\t\t}\n\n\t\tstep.classList.add('step');\n\t\tif (index !== this.currentStep) {\n\t\t\tstep.style.display = 'none';\n\t\t\tstep.setAttribute('aria-hidden', 'true');\n\t\t} else {\n\t\t\tstep.setAttribute('aria-hidden', 'false');\n\t\t}\n\n\t\tthis.steps.push(step);\n\n\t\treturn nav\n\t}\n\n\t/**\n\t * Sets up the attributes for the component.\n\t */\n\tafterDraw() {\n\t\tif (this.steps.length <= 1) {\n\t\t\tthis.prev.hidden = true;\n\t\t}\n\n\t\tevent.addListener(this.prev, 'click', '', () => this.navigate(-1));\n\t\tevent.addListener(this.next, 'click', '', () => this.navigate(1));\n\t\tevent.addListener(this.finish, 'click', '', () => this.navigate(1));\n\n\t\trequestAnimationFrame(() => {\n\t\t\tthis.goToStep(this.startIndex);\n\t\t});\n\t}\n\n\t/**\n\t * Navigates to a different step in a multi-step process based on the provided direction.\n\t * @param {number} direction The navigation direction.\n\t * Use a positive value to move forward or a negative value to move backward.\n\t */\n\tnavigate(direction) {\n\t\tthis.goToStep(this.currentStep + direction);\n\t}\n\n\t/**\n\t * Navigates to a specific step in a workflow or process.\n\t * Executes a set of operations before and after the step transition.\n\t * @param {number} stepIndex The index of the step to navigate to.\n\t * @returns {void} This method does not return a value.\n\t */\n\tgoToStep(stepIndex) {\n\t\tPromise.resolve(this.beforeOpen(stepIndex, this.currentStep)).then((res) => {\n\t\t\tthis._executeGoToStep(stepIndex);\n\n\t\t\tPromise.resolve(this.afterOpen(stepIndex, this.currentStep));\n\t\t})\n\t\t.catch(console.error);\n\t}\n\n\t_executeGoToStep(stepIndex = 0) {\n\t\tif (stepIndex >= 0 && stepIndex < this.steps.length) {\n\t\t\tif (this.headerSteps[stepIndex].hasAttribute('disabled')) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (stepIndex > this.currentStep) {\n\t\t\t\tthis.dispatchEvent(\n\t\t\t\t\tnew CustomEvent('stepper:next', { detail: { stepIndex }, bubbles: true, composed: true })\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthis.dispatchEvent(\n\t\t\t\t\tnew CustomEvent('stepper:prev', { detail: { stepIndex }, bubbles: true, composed: true })\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tthis.headerSteps.forEach((step, index) => {\n\t\t\t\tlet badge = step.querySelector('wje-badge');\n\n\t\t\t\tthis.setStepDefault(step, badge, index);\n\t\t\t\tif (index < stepIndex) this.setStepDone(step, badge);\n\t\t\t\tif (index > stepIndex && step.hasAttribute('disabled')) this.setStepLocked(step, badge, index);\n\t\t\t});\n\n\t\t\tthis.setStepActive(this.headerSteps[stepIndex], null, stepIndex);\n\t\t\tthis.setContentActive(stepIndex);\n\n\t\t\tthis.currentStep = stepIndex;\n\t\t\tthis.prev.hidden = this.currentStep === 0;\n\n\t\t\tconst isNextLocked = this.headerSteps[this.currentStep + 1]?.hasAttribute('locked');\n\t\t\tthis.next.toggleAttribute('disabled', !!isNextLocked);\n\t\t\tthis.finish.toggleAttribute('disabled', !!isNextLocked);\n\n\t\t\tif (this.currentStep === this.steps.length - 1) {\n\t\t\t\tthis.next.hidden = true;\n\t\t\t\tthis.finish.hidden = false;\n\t\t\t\tthis.finish.style.display = 'block';\n\t\t\t} else {\n\t\t\t\tthis.next.hidden = false;\n\t\t\t\tthis.finish.hidden = true;\n\t\t\t\tthis.finish.style.display = 'none';\n\t\t\t}\n\t\t} else if (stepIndex === this.steps.length) {\n\t\t\tthis.dispatchEvent(\n\t\t\t\tnew CustomEvent('stepper:finish', { detail: { stepIndex }, bubbles: true, composed: true })\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Resets a step to its default state by clearing its active and done attributes.\n\t * Updates the step's badge to show its index and removes any color styling.\n\t * @param {HTMLElement} nav The navigation element representing the step.\n\t * @param {HTMLElement|null} [badge] The badge element within the step. If not provided, it will be selected from the `nav` element.\n\t * @param {number} [stepIndex] The index of the step, used to set the badge content.\n\t */\n\tsetStepDefault(nav, badge = null, stepIndex = 0) {\n\t\tnav.removeAttribute('active');\n\t\tnav.removeAttribute('done');\n\t\tnav.setAttribute('aria-selected', 'false');\n\t\tnav.setAttribute('tabindex', '-1');\n\n\t\tif (!badge) {\n\t\t\tbadge = nav.querySelector('wje-badge');\n\t\t}\n\t\tbadge.innerHTML = stepIndex + 1;\n\t\tbadge.removeAttribute('color');\n\t}\n\n\t/**\n\t * Sets a step as active by adding the `active` attribute and updating the step's badge.\n\t * @param {HTMLElement} nav The navigation element representing the step to activate.\n\t * @param {HTMLElement|null} [badge] The badge element within the step. If not provided, it will be selected from the `nav` element.\n\t * @param {number|null} [stepIndex] The index of the step, used to set the badge content. Defaults to `null` if not provided.\n\t */\n\tsetStepActive(nav, badge = null, stepIndex = null) {\n\t\tnav.setAttribute('active', '');\n\t\tnav.setAttribute('aria-selected', 'true');\n\t\tnav.setAttribute('tabindex', '0');\n\n\t\tif (!badge) {\n\t\t\tbadge = nav.querySelector('wje-badge');\n\t\t}\n\t\tbadge.innerHTML = stepIndex + 1;\n\t\tbadge.setAttribute('color', this.active);\n\t}\n\n\t/**\n\t * Activates the content of a specific step by displaying it and hiding all others.\n\t * @param {number} stepIndex The index of the step whose content should be displayed.\n\t */\n\tsetContentActive(stepIndex) {\n\t\tthis.steps?.forEach((step, index) => {\n\t\t\tif (index === stepIndex) {\n\t\t\t\tstep.style.display = 'block';\n\t\t\t\tstep.setAttribute('aria-hidden', 'false');\n\t\t\t} else {\n\t\t\t\tstep.style.display = 'none';\n\t\t\t\tstep.setAttribute('aria-hidden', 'true');\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Returns the DOM element of a step by index.\n\t * @param {number} stepIndex\n\t * @returns {HTMLElement}\n\t */\n\tgetStepElement(stepIndex) {\n\t\treturn this.steps?.[stepIndex];\n\t}\n\n\t/**\n\t * Appends or replaces content inside the step container.\n\t * @param {number} stepIndex\n\t * @param {Node|string|Node[]} content DOM node(s) or HTML string to insert.\n\t * @param {{ replace?: boolean }} [options]\n\t */\n\trenderStepContent(stepIndex, content, options = {}) {\n\t\tconst stepEl = this.getStepElement(stepIndex);\n\t\tif (!stepEl) return;\n\n\t\tconst { replace = false } = options;\n\n\t\tlet frag = document.createDocumentFragment();\n\t\tif (typeof content === 'string') {\n\t\t\tconst tpl = document.createElement('template');\n\t\t\ttpl.innerHTML = content;\n\t\t\tfrag.append(tpl.content);\n\t\t} else if (Array.isArray(content)) {\n\t\t\tcontent.forEach(node => {\n\t\t\t\tif (node instanceof Node) frag.appendChild(node);\n\t\t\t});\n\t\t} else if (content instanceof Node) {\n\t\t\tfrag.append(content);\n\t\t}\n\n\t\tif (replace) {\n\t\t\tstepEl.replaceChildren(frag);\n\t\t} else {\n\t\t\tstepEl.append(frag);\n\t\t}\n\t}\n\n\t/**\n\t * Marks a step as completed by setting the `done` attribute and updating its badge with a check icon.\n\t * @param {HTMLElement} nav The navigation element representing the completed step.\n\t * @param {HTMLElement|null} [badge] The badge element within the step. If not provided, it will be selected from the `nav` element.\n\t */\n\tsetStepDone(nav, badge = null) {\n\t\tnav.setAttribute('done', '');\n\n\t\tconst checkIcon = document.createElement('wje-icon');\n\t\tcheckIcon.setAttribute('name', 'check');\n\t\tcheckIcon.setAttribute('color', this.done);\n\t\tcheckIcon.setAttribute('size', 'medium');\n\n\t\tif (!badge) {\n\t\t\tbadge = nav.querySelector('wje-badge');\n\t\t}\n\n\t\tbadge.setAttribute('color', this.done);\n\t\tbadge.innerHTML = '';\n\t\tbadge.appendChild(checkIcon);\n\t}\n\n\tsetStepLocked(nav, badge = null) {\n\t\tnav.setAttribute('disabled', '');\n\t\tnav.setAttribute('locked', '');\n\n\t\tconst lockIcon = document.createElement('wje-icon');\n\t\tlockIcon.setAttribute('name', 'lock');\n\t\tlockIcon.setAttribute('color', \"danger\");\n\t\tlockIcon.setAttribute('size', 'medium');\n\n\t\tif (!badge) {\n\t\t\tbadge = nav.querySelector('wje-badge');\n\t\t}\n\t\tbadge.innerHTML = '';\n\t\tbadge.removeAttribute('color');\n\t\tbadge.classList.add('disabled');\n\t\tbadge.appendChild(lockIcon);\n\t}\n\n\t/**\n\t * A callback function that is executed before opening a step in a process.\n\t * This allows for custom behavior or logic to be applied before the step is displayed.\n\t * @callback beforeOpen\n\t * @param {number} stepIndex The index of the step that is about to be opened.\n\t * @param {object} currentStep The current step data or configuration object before opening the new step.\n\t */\n\tbeforeOpen = (stepIndex, currentStep) => {\n\t\t// Override to add custom behavior before opening a step.\n\t}\n\n\t/**\n\t * Callback function executed after a step is opened.\n\t * This function can be overridden to implement custom behavior\n\t * that should take place immediately after a step is opened.\n\t * @function afterOpen\n\t * @param {number} stepIndex The index of the step that has been opened.\n\t * @param {object} currentStep The object representing the current step that has been opened.\n\t */\n\tafterOpen = (stepIndex, currentStep) => {\n\t\t// Override to add custom behavior after opening a step.\n\t}\n}\n","import Stepper from './stepper.element.js';\n\nexport default Stepper;\n\nStepper.define('wje-stepper', Stepper);\n"],"names":[],"mappings":";;;;;;;AAIA,IAAI,YAAY;AAgBD,MAAM,gBAAgB,UAAU;AAAA,EAC9C,cAAc;AACb,UAAK;AA0CN,qCAAY;AAwZZ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sCAAa,CAAC,WAAW,gBAAgB;AAAA,IAEzC;AAUA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qCAAY,CAAC,WAAW,gBAAgB;AAAA,IAExC;AA/cC,SAAK,cAAc;AAEnB,SAAK,YAAY,IAAI,UAAU,IAAI;AACnC,SAAK,QAAQ,CAAA;AACb,SAAK,cAAc,CAAA;AACnB,SAAK,aAAa,EAAE;AAAA,EAErB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,IAAI,WAAW,OAAO;AACrB,SAAK,aAAa,eAAe,KAAK;AAAA,EACvC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,IAAI,aAAa;AAChB,UAAM,QAAQ,KAAK,aAAa,aAAa;AAC7C,WAAO,UAAU,OAAO,CAAC,QAAQ;AAAA,EAClC;AAAA,EAEA,IAAI,SAAS;AACZ,QAAI,KAAK,aAAa,QAAQ,EAAG,QAAO,KAAK,aAAa,QAAQ;AAElE,WAAO;AAAA,EACR;AAAA,EAEA,IAAI,OAAO;AACV,QAAI,KAAK,aAAa,MAAM,EAAG,QAAO,KAAK,aAAa,MAAM;AAE9D,WAAO;AAAA,EACR;AAAA,EAIA,WAAW,gBAAgB;AAC1B,WAAO;AAAA,EACR;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OAAO;AAC7B,UAAM,UAAU,IAAI,UAAU;AAC9B,UAAM,YAAY,QAAQ;AAAA,EAC3B;AAwBD;ACneA,QAAQ,OAAO,eAAe,OAAO;"}
|
|
1
|
+
{"version":3,"file":"wje-stepper.js","sources":["../packages/wje-stepper/stepper.element.js","../packages/wje-stepper/stepper.js"],"sourcesContent":["import { Localizer } from '../utils/localize.js';\nimport { default as WJElement, event } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\nlet stepperId = 0;\n\n/**\n * `Stepper` is a custom web component that represents a stepper.\n * @summary This element represents a stepper.\n * @documentation https://elements.webjet.sk/components/stepper\n * @status stable\n * @augments WJElement\n * @attribute {string} active - The active color for the stepper.\n * @attribute {string} done - The done color for the stepper.\n * @slot - The default slot for the stepper.\n * @csspart native - The native part of the stepper.\n * @csspart header - The header part of the stepper.\n * @csspart content - The content part of the stepper.\n * @tag wje-stepper\n */\nexport default class Stepper extends WJElement {\n\tconstructor() {\n\t\tsuper();\n\t\tthis.currentStep = 0;\n\n\t\tthis.localizer = new Localizer(this);\n\t\tthis.steps = [];\n\t\tthis.headerSteps = [];\n\t\tthis._stepperId = ++stepperId;\n\n\t}\n\n\t/**\n\t * Sets the start index for an operation or a process. This method assigns\n\t * the provided value to the attribute 'start-index'.\n\t * @param {number|string} value The value to set for the 'start-index' attribute.\n\t */\n\tset startIndex(value) {\n\t\tthis.setAttribute('start-index', value);\n\t}\n\n\t/**\n\t * Retrieves the starting index value stored as an attribute.\n\t * If the attribute 'start-index' exists and is not null, it parses the value as an integer and returns it.\n\t * If the attribute does not exist, it returns the default value of 0.\n\t * @returns {number} The starting index as an integer, or 0 if the attribute is not present.\n\t */\n\tget startIndex() {\n\t\tconst index = this.getAttribute('start-index');\n\t\treturn index !== null ? +index : 0;\n\t}\n\n\tget active() {\n\t\tif (this.hasAttribute('active')) return this.getAttribute('active');\n\n\t\treturn 'primary';\n\t}\n\n\tget done() {\n\t\tif (this.hasAttribute('done')) return this.getAttribute('done');\n\n\t\treturn 'success';\n\t}\n\n\tclassName = 'Stepper';\n\n\tstatic get cssStyleSheet() {\n\t\treturn styles;\n\t}\n\n\tsetupAttributes() {\n\t\tthis.isShadowRoot = 'open';\n\t}\n\n\t/**\n\t * Draws the component for the stepper.\n\t * @returns {DocumentFragment}\n\t */\n\tdraw() {\n\t\tlet fragment = document.createDocumentFragment();\n\n\t\tconst native = document.createElement('div');\n\t\tnative.setAttribute('part', 'native');\n\t\tnative.className = 'native-stepper';\n\n\t\tconst header = document.createElement('div');\n\t\theader.setAttribute('part', 'header');\n\t\theader.className = 'header';\n\t\theader.setAttribute('role', 'tablist');\n\n\t\tconst content = document.createElement('div');\n\t\tcontent.setAttribute('part', 'content');\n\t\tcontent.className = 'content';\n\n\t\tconst steps = Array.from(this.children);\n\n\t\tsteps?.forEach((step, index) => {\n\t\t\tif (step.nodeName === 'WJE-STEP') {\n\t\t\t\tthis.headerSteps.push(this.processStep(index, step, header, steps));\n\t\t\t}\n\t\t});\n\n\t\tlet slot = document.createElement('slot');\n\n\t\tconst navButtons = document.createElement('div');\n\t\tnavButtons.className = 'nav-buttons';\n\n\t\tconst prevButton = document.createElement('wje-button');\n\t\tprevButton.setAttribute('label', this.localizer.translate('wj.stepper.button.previous'));\n\t\tprevButton.innerHTML = this.localizer.translate('wj.stepper.button.previous');\n\n\t\tlet nextButton = document.createElement('wje-button');\n\t\tnextButton.setAttribute('label', this.localizer.translate('wj.stepper.button.next'));\n\t\tnextButton.innerHTML = this.localizer.translate('wj.stepper.button.next');\n\n\t\tlet finishButton = document.createElement('wje-button');\n\t\tfinishButton.setAttribute('label', this.localizer.translate('wj.stepper.button.next'));\n\t\tfinishButton.innerHTML = this.localizer.translate('wj.stepper.button.finish');\n\t\tfinishButton.setAttribute('color', 'primary');\n\n\t\tconst navButtonPrevSlot = document.createElement('slot');\n\t\tnavButtonPrevSlot.setAttribute('name', 'prev');\n\t\tnavButtonPrevSlot.appendChild(prevButton);\n\t\tnavButtonPrevSlot.hidden = this.currentStep === 0;\n\n\t\tconst navButtonNextSlot = document.createElement('slot');\n\t\tnavButtonNextSlot.setAttribute('name', 'next');\n\t\tnavButtonNextSlot.appendChild(nextButton);\n\t\tnavButtonNextSlot.hidden = this.currentStep === this.steps.length - 1;\n\n\t\tconst navButtonFinishSlot = document.createElement('slot');\n\t\tnavButtonFinishSlot.setAttribute('name', 'finish');\n\t\tnavButtonFinishSlot.appendChild(nextButton);\n\t\tnavButtonFinishSlot.hidden = this.currentStep !== this.steps.length - 1;\n\n\t\tconst isNextLocked = this.headerSteps[this.currentStep + 1]?.hasAttribute('locked');\n\t\tnavButtonNextSlot.toggleAttribute('disabled', !!isNextLocked);\n\t\tnavButtonFinishSlot.toggleAttribute('disabled', !!isNextLocked);\n\n\t\tif (steps.length > 1) {\n\t\t\tnavButtonPrevSlot.appendChild(prevButton);\n\t\t\tnavButtonNextSlot.appendChild(nextButton);\n\t\t\tnavButtonFinishSlot.appendChild(finishButton);\n\t\t\tnavButtonFinishSlot.style.display = 'none';\n\n\t\t} else {\n\t\t\tnavButtonPrevSlot.hidden = true;\n\t\t\tnavButtonNextSlot.hidden = true;\n\t\t\tnavButtonPrevSlot.appendChild(prevButton);\n\t\t\tnavButtonNextSlot.appendChild(nextButton);\n\t\t\tnavButtonFinishSlot.appendChild(finishButton);\n\t\t}\n\n\t\tcontent.appendChild(slot);\n\n\t\tnative.appendChild(header);\n\t\tnative.appendChild(content);\n\t\tnative.appendChild(navButtons);\n\n\t\tnavButtons.appendChild(navButtonPrevSlot);\n\t\tnavButtons.appendChild(navButtonNextSlot);\n\t\tnavButtons.appendChild(navButtonFinishSlot);\n\n\t\tfragment.appendChild(native);\n\n\t\tthis.header = header;\n\t\tthis.prev = navButtonPrevSlot;\n\t\tthis.next = navButtonNextSlot;\n\t\tthis.finish = navButtonFinishSlot;\n\n\t\treturn fragment;\n\t}\n\n\tprocessStep(index, step, header, steps) {\n\t\tconst nav = document.createElement('div');\n\t\tnav.className = 'step-header';\n\t\tnav.setAttribute('role', 'tab');\n\t\tnav.addEventListener('click', (e) => {\n\t\t\tthis.goToStep(index)\n\t\t});\n\n\t\tconst badge = document.createElement('wje-badge');\n\t\tbadge.setAttribute('label', (index + 1).toString());\n\t\tbadge.className = 'step-badge';\n\t\tbadge.innerHTML = index + 1;\n\n\t\tconst label = document.createElement('span');\n\t\tlabel.innerText = step.getAttribute('label') || `${this.localizer.translate('wj.stepper.step')} ${index + 1}`; // default label\n\n\t\tconst panelId = step.id || `wje-stepper-${this._stepperId}-panel-${index}`;\n\t\tconst tabId = nav.id || `wje-stepper-${this._stepperId}-tab-${index}`;\n\t\tstep.id = panelId;\n\t\tnav.id = tabId;\n\t\tnav.setAttribute('aria-controls', panelId);\n\t\tstep.setAttribute('role', 'tabpanel');\n\t\tstep.setAttribute('aria-labelledby', tabId);\n\n\t\t// set active step\n\t\tif (index === this.currentStep || step.hasAttribute('active')) {\n\t\t\tthis.setStepActive(nav, badge, index);\n\t\t} else {\n\t\t\tnav.setAttribute('aria-selected', 'false');\n\t\t\tnav.setAttribute('tabindex', '-1');\n\t\t}\n\n\t\tif (step.hasAttribute('disabled')) {\n\t\t\tnav.setAttribute('disabled', '');\n\t\t\tthis.setStepLocked(nav, badge);\n\t\t} else {\n\t\t\tnav.classList.add('pointer');\n\t\t}\n\n\t\tnav.appendChild(badge);\n\t\tnav.appendChild(label);\n\n\t\theader.appendChild(nav);\n\n\t\tif (index < steps.length - 1) {\n\t\t\tconst arrowIcon = document.createElement('wje-icon');\n\t\t\tarrowIcon.setAttribute('name', 'chevron-right');\n\t\t\tarrowIcon.classList.add('arrow-icon');\n\t\t\tarrowIcon.setAttribute('size', 'small');\n\n\t\t\theader.appendChild(arrowIcon);\n\t\t}\n\n\t\tstep.classList.add('step');\n\t\tif (index !== this.currentStep) {\n\t\t\tstep.style.display = 'none';\n\t\t\tstep.setAttribute('aria-hidden', 'true');\n\t\t} else {\n\t\t\tstep.setAttribute('aria-hidden', 'false');\n\t\t}\n\n\t\tthis.steps.push(step);\n\n\t\treturn nav\n\t}\n\n\t/**\n\t * Sets up the attributes for the component.\n\t */\n\tafterDraw() {\n\t\tif (this.steps.length <= 1) {\n\t\t\tthis.prev.hidden = true;\n\t\t}\n\n\t\tevent.addListener(this.prev, 'click', '', () => this.navigate(-1));\n\t\tevent.addListener(this.next, 'click', '', () => this.navigate(1));\n\t\tevent.addListener(this.finish, 'click', '', () => this.navigate(1));\n\n\t\trequestAnimationFrame(() => {\n\t\t\tthis.goToStep(this.startIndex);\n\t\t});\n\t}\n\n\t/**\n\t * Navigates to a different step in a multi-step process based on the provided direction.\n\t * @param {number} direction The navigation direction.\n\t * Use a positive value to move forward or a negative value to move backward.\n\t */\n\tnavigate(direction) {\n\t\tthis.goToStep(this.currentStep + direction);\n\t}\n\n\t/**\n\t * Navigates to a specific step in a workflow or process.\n\t * Executes a set of operations before and after the step transition.\n\t * @param {number} stepIndex The index of the step to navigate to.\n\t * @returns {void} This method does not return a value.\n\t */\n\tgoToStep(stepIndex) {\n\t\tPromise.resolve(this.beforeOpen(stepIndex, this.currentStep)).then((res) => {\n\t\t\tthis._executeGoToStep(stepIndex);\n\n\t\t\tPromise.resolve(this.afterOpen(stepIndex, this.currentStep));\n\t\t})\n\t\t.catch(console.error);\n\t}\n\n\t_executeGoToStep(stepIndex = 0) {\n\t\tif (stepIndex >= 0 && stepIndex < this.steps.length) {\n\t\t\tif (this.headerSteps[stepIndex].hasAttribute('disabled')) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (stepIndex > this.currentStep) {\n\t\t\t\tthis.dispatchEvent(\n\t\t\t\t\tnew CustomEvent('stepper:next', { detail: { stepIndex }, bubbles: true, composed: true })\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthis.dispatchEvent(\n\t\t\t\t\tnew CustomEvent('stepper:prev', { detail: { stepIndex }, bubbles: true, composed: true })\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tthis.headerSteps.forEach((step, index) => {\n\t\t\t\tlet badge = step.querySelector('wje-badge');\n\n\t\t\t\tthis.setStepDefault(step, badge, index);\n\t\t\t\tif (index < stepIndex) this.setStepDone(step, badge);\n\t\t\t\tif (index > stepIndex && step.hasAttribute('disabled')) this.setStepLocked(step, badge, index);\n\t\t\t});\n\n\t\t\tthis.setStepActive(this.headerSteps[stepIndex], null, stepIndex);\n\t\t\tthis.setContentActive(stepIndex);\n\n\t\t\tthis.currentStep = stepIndex;\n\t\t\tthis.prev.hidden = this.currentStep === 0;\n\n\t\t\tconst isNextLocked = this.headerSteps[this.currentStep + 1]?.hasAttribute('locked');\n\t\t\tthis.next.toggleAttribute('disabled', !!isNextLocked);\n\t\t\tthis.finish.toggleAttribute('disabled', !!isNextLocked);\n\n\t\t\tif (this.currentStep === this.steps.length - 1) {\n\t\t\t\tthis.next.hidden = true;\n\t\t\t\tthis.finish.hidden = false;\n\t\t\t\tthis.finish.style.display = 'block';\n\t\t\t} else {\n\t\t\t\tthis.next.hidden = false;\n\t\t\t\tthis.finish.hidden = true;\n\t\t\t\tthis.finish.style.display = 'none';\n\t\t\t}\n\t\t} else if (stepIndex === this.steps.length) {\n\t\t\tthis.dispatchEvent(\n\t\t\t\tnew CustomEvent('stepper:finish', { detail: { stepIndex }, bubbles: true, composed: true })\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Resets a step to its default state by clearing its active and done attributes.\n\t * Updates the step's badge to show its index and removes any color styling.\n\t * @param {HTMLElement} nav The navigation element representing the step.\n\t * @param {HTMLElement|null} [badge] The badge element within the step. If not provided, it will be selected from the `nav` element.\n\t * @param {number} [stepIndex] The index of the step, used to set the badge content.\n\t */\n\tsetStepDefault(nav, badge = null, stepIndex = 0) {\n\t\tnav.removeAttribute('active');\n\t\tnav.removeAttribute('done');\n\t\tnav.setAttribute('aria-selected', 'false');\n\t\tnav.setAttribute('tabindex', '-1');\n\n\t\tif (!badge) {\n\t\t\tbadge = nav.querySelector('wje-badge');\n\t\t}\n\t\tbadge.innerHTML = stepIndex + 1;\n\t\tbadge.removeAttribute('color');\n\t}\n\n\t/**\n\t * Sets a step as active by adding the `active` attribute and updating the step's badge.\n\t * @param {HTMLElement} nav The navigation element representing the step to activate.\n\t * @param {HTMLElement|null} [badge] The badge element within the step. If not provided, it will be selected from the `nav` element.\n\t * @param {number|null} [stepIndex] The index of the step, used to set the badge content. Defaults to `null` if not provided.\n\t */\n\tsetStepActive(nav, badge = null, stepIndex = null) {\n\t\tnav.setAttribute('active', '');\n\t\tnav.setAttribute('aria-selected', 'true');\n\t\tnav.setAttribute('tabindex', '0');\n\n\t\tif (!badge) {\n\t\t\tbadge = nav.querySelector('wje-badge');\n\t\t}\n\t\tbadge.innerHTML = stepIndex + 1;\n\t\tbadge.setAttribute('color', this.active);\n\t}\n\n\t/**\n\t * Activates the content of a specific step by displaying it and hiding all others.\n\t * @param {number} stepIndex The index of the step whose content should be displayed.\n\t */\n\tsetContentActive(stepIndex) {\n\t\tthis.steps?.forEach((step, index) => {\n\t\t\tif (index === stepIndex) {\n\t\t\t\tstep.style.display = 'block';\n\t\t\t\tstep.setAttribute('aria-hidden', 'false');\n\t\t\t} else {\n\t\t\t\tstep.style.display = 'none';\n\t\t\t\tstep.setAttribute('aria-hidden', 'true');\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Returns the DOM element of a step by index.\n\t * @param {number} stepIndex\n\t * @returns {HTMLElement}\n\t */\n\tgetStepElement(stepIndex) {\n\t\treturn this.steps?.[stepIndex];\n\t}\n\n\t/**\n\t * Appends or replaces content inside the step container.\n\t * @param {number} stepIndex\n\t * @param {Node|string|Node[]} content DOM node(s) or HTML string to insert.\n\t * @param {{ replace?: boolean }} [options]\n\t */\n\trenderStepContent(stepIndex, content, options = {}) {\n\t\tconst stepEl = this.getStepElement(stepIndex);\n\t\tif (!stepEl) return;\n\n\t\tconst { replace = false } = options;\n\n\t\tlet frag = document.createDocumentFragment();\n\t\tif (typeof content === 'string') {\n\t\t\tconst tpl = document.createElement('template');\n\t\t\ttpl.innerHTML = content;\n\t\t\tfrag.append(tpl.content);\n\t\t} else if (Array.isArray(content)) {\n\t\t\tcontent.forEach(node => {\n\t\t\t\tif (node instanceof Node) frag.appendChild(node);\n\t\t\t});\n\t\t} else if (content instanceof Node) {\n\t\t\tfrag.append(content);\n\t\t}\n\n\t\tif (replace) {\n\t\t\tstepEl.replaceChildren(frag);\n\t\t} else {\n\t\t\tstepEl.append(frag);\n\t\t}\n\t}\n\n\t/**\n\t * Marks a step as completed by setting the `done` attribute and updating its badge with a check icon.\n\t * @param {HTMLElement} nav The navigation element representing the completed step.\n\t * @param {HTMLElement|null} [badge] The badge element within the step. If not provided, it will be selected from the `nav` element.\n\t */\n\tsetStepDone(nav, badge = null) {\n\t\tnav.setAttribute('done', '');\n\n\t\tconst checkIcon = document.createElement('wje-icon');\n\t\tcheckIcon.setAttribute('name', 'check');\n\t\tcheckIcon.setAttribute('color', this.done);\n\t\tcheckIcon.setAttribute('size', 'medium');\n\n\t\tif (!badge) {\n\t\t\tbadge = nav.querySelector('wje-badge');\n\t\t}\n\n\t\tbadge.setAttribute('color', this.done);\n\t\tbadge.innerHTML = '';\n\t\tbadge.appendChild(checkIcon);\n\t}\n\n\tsetStepLocked(nav, badge = null) {\n\t\tnav.setAttribute('disabled', '');\n\t\tnav.setAttribute('locked', '');\n\n\t\tconst lockIcon = document.createElement('wje-icon');\n\t\tlockIcon.setAttribute('name', 'lock');\n\t\tlockIcon.setAttribute('color', \"danger\");\n\t\tlockIcon.setAttribute('size', 'medium');\n\n\t\tif (!badge) {\n\t\t\tbadge = nav.querySelector('wje-badge');\n\t\t}\n\t\tbadge.innerHTML = '';\n\t\tbadge.removeAttribute('color');\n\t\tbadge.classList.add('disabled');\n\t\tbadge.appendChild(lockIcon);\n\t}\n\n\t/**\n\t * A callback function that is executed before opening a step in a process.\n\t * This allows for custom behavior or logic to be applied before the step is displayed.\n\t * @callback beforeOpen\n\t * @param {number} stepIndex The index of the step that is about to be opened.\n\t * @param {object} currentStep The current step data or configuration object before opening the new step.\n\t */\n\tbeforeOpen = (stepIndex, currentStep) => {\n\t\t// Override to add custom behavior before opening a step.\n\t}\n\n\t/**\n\t * Callback function executed after a step is opened.\n\t * This function can be overridden to implement custom behavior\n\t * that should take place immediately after a step is opened.\n\t * @function afterOpen\n\t * @param {number} stepIndex The index of the step that has been opened.\n\t * @param {object} currentStep The object representing the current step that has been opened.\n\t */\n\tafterOpen = (stepIndex, currentStep) => {\n\t\t// Override to add custom behavior after opening a step.\n\t}\n}\n","import Stepper from './stepper.element.js';\n\nexport default Stepper;\n\nStepper.define('wje-stepper', Stepper);\n"],"names":["stepperId","Stepper","WJElement","super","className","beforeOpen","stepIndex","currentStep","afterOpen","this","localizer","Localizer","steps","headerSteps","_stepperId","value","setAttribute","startIndex","index","getAttribute","active","hasAttribute","done","cssStyleSheet","setupAttributes","isShadowRoot","draw","fragment","document","createDocumentFragment","native","createElement","header","content","Array","from","children","forEach","step","nodeName","push","processStep","slot","navButtons","prevButton","translate","innerHTML","nextButton","finishButton","navButtonPrevSlot","appendChild","hidden","navButtonNextSlot","length","navButtonFinishSlot","isNextLocked","toggleAttribute","style","display","prev","next","finish","nav","addEventListener","e","goToStep","badge","toString","label","innerText","panelId","id","tabId","setStepActive","setStepLocked","classList","add","arrowIcon","afterDraw","event","addListener","navigate","requestAnimationFrame","direction","Promise","resolve","then","res","_executeGoToStep","catch","console","error","dispatchEvent","CustomEvent","detail","bubbles","composed","querySelector","setStepDefault","setStepDone","setContentActive","removeAttribute","options","stepEl","getStepElement","replace","frag","tpl","append","isArray","node","Node","replaceChildren","checkIcon","lockIcon","define"],"mappings":";;;;;;AAIA,IAAIA,IAAY;AAgBD,MAAMC,UAAgBC,EAAAA;AAAAA,EACpC;AACCC,UAAAA;AA0CDC,qCAAY;AAwZZC,sCAAa,CAACC,IAAWC,OAAAA;AAAAA,IAAAA;AAYzBC,qCAAY,CAACF,IAAWC,OAAAA;AAAAA,IAAAA;AA7cvBE,SAAKF,cAAc,GA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p = 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
|
-
const
|
|
5
|
-
|
|
6
|
-
return {
|
|
7
|
-
type: `${stateValueName}/ADD`,
|
|
8
|
-
payload: structuredClone(payload2),
|
|
9
|
-
actionType: "ADD"
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
const addManyAction = (stateValueName) => {
|
|
14
|
-
return (payload2) => {
|
|
15
|
-
return {
|
|
16
|
-
type: `${stateValueName}/ADD_MANY`,
|
|
17
|
-
payload: structuredClone(payload2),
|
|
18
|
-
actionType: "ADD_MANY"
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
const updateAction = (stateValueName) => {
|
|
23
|
-
return (payload2) => {
|
|
24
|
-
return {
|
|
25
|
-
type: `${stateValueName}/UPDATE`,
|
|
26
|
-
payload: structuredClone(payload2),
|
|
27
|
-
actionType: "UPDATE"
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
const deleteAction = (stateValueName) => {
|
|
32
|
-
return (payload2) => {
|
|
33
|
-
return {
|
|
34
|
-
type: `${stateValueName}/DELETE`,
|
|
35
|
-
payload: structuredClone(payload2),
|
|
36
|
-
actionType: "DELETE"
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
const loadAction = (stateValueName) => {
|
|
41
|
-
return (payload2) => {
|
|
42
|
-
return {
|
|
43
|
-
type: `${stateValueName}/LOAD`,
|
|
44
|
-
payload: structuredClone(payload2),
|
|
45
|
-
actionType: "LOAD"
|
|
46
|
-
};
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
const defaultStoreActions = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
50
|
-
__proto__: null,
|
|
51
|
-
addAction,
|
|
52
|
-
addManyAction,
|
|
53
|
-
deleteAction,
|
|
54
|
-
loadAction,
|
|
55
|
-
updateAction
|
|
56
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
57
|
-
class PubSub {
|
|
4
|
+
const e = (e2) => (t2) => ({ type: `${e2}/UPDATE`, payload: structuredClone(t2), actionType: "UPDATE" }), t = Object.freeze(Object.defineProperty({ __proto__: null, addAction: (e2) => (t2) => ({ type: `${e2}/ADD`, payload: structuredClone(t2), actionType: "ADD" }), addManyAction: (e2) => (t2) => ({ type: `${e2}/ADD_MANY`, payload: structuredClone(t2), actionType: "ADD_MANY" }), deleteAction: (e2) => (t2) => ({ type: `${e2}/DELETE`, payload: structuredClone(t2), actionType: "DELETE" }), loadAction: (e2) => (t2) => ({ type: `${e2}/LOAD`, payload: structuredClone(t2), actionType: "LOAD" }), updateAction: e }, Symbol.toStringTag, { value: "Module" }));
|
|
5
|
+
class r {
|
|
58
6
|
constructor() {
|
|
59
7
|
this.events = {};
|
|
60
8
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
* @returns {number} A count of callbacks for this event
|
|
67
|
-
* @memberof PubSub
|
|
68
|
-
*/
|
|
69
|
-
subscribe(event, callback) {
|
|
70
|
-
let self = this;
|
|
71
|
-
if (!self.events.hasOwnProperty(event)) {
|
|
72
|
-
self.events[event] = [];
|
|
73
|
-
}
|
|
74
|
-
self.events[event].push(callback) - 1;
|
|
75
|
-
return {
|
|
76
|
-
unsubscribe() {
|
|
77
|
-
self.events[event].splice(self.events[event].indexOf(callback), 1);
|
|
78
|
-
}
|
|
79
|
-
};
|
|
9
|
+
subscribe(e2, t2) {
|
|
10
|
+
let r2 = this;
|
|
11
|
+
return r2.events.hasOwnProperty(e2) || (r2.events[e2] = []), r2.events[e2].push(t2), { unsubscribe() {
|
|
12
|
+
r2.events[e2].splice(r2.events[e2].indexOf(t2), 1);
|
|
13
|
+
} };
|
|
80
14
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
* @param {string} event The name of the event to publish
|
|
84
|
-
* @param {any} state The current state to pass to the callbacks
|
|
85
|
-
* @param {object} [newData] The new data to pass to the callbacks
|
|
86
|
-
* @param {object} [oldData] The old data to pass to the callbacks
|
|
87
|
-
* @returns {Array} The results of the callbacks for this event, or an empty array if no event exists
|
|
88
|
-
* @memberof PubSub
|
|
89
|
-
*/
|
|
90
|
-
publish(event, state, newData = {}, oldData = {}) {
|
|
91
|
-
let self = this;
|
|
92
|
-
if (!self.events.hasOwnProperty(event)) {
|
|
93
|
-
return [];
|
|
94
|
-
}
|
|
95
|
-
return self.events[event].map((callback) => callback(state, oldData, newData));
|
|
15
|
+
publish(e2, t2, r2 = {}, s2 = {}) {
|
|
16
|
+
return this.events.hasOwnProperty(e2) ? this.events[e2].map((e3) => e3(t2, s2, r2)) : [];
|
|
96
17
|
}
|
|
97
18
|
}
|
|
98
|
-
class
|
|
99
|
-
|
|
100
|
-
* Initializes the store with optional reducer and state.
|
|
101
|
-
* @param {object} [params] Configuration for the store.
|
|
102
|
-
* @param {Function} [params.reducer] Initial reducer function for handling state updates.
|
|
103
|
-
* @param {object} [params.state] Initial state of the store.
|
|
104
|
-
*/
|
|
105
|
-
constructor(params = {}) {
|
|
19
|
+
let s = new class {
|
|
20
|
+
constructor(e2 = {}) {
|
|
106
21
|
__publicField(this, "_state");
|
|
107
22
|
__publicField(this, "_reducer");
|
|
108
23
|
__publicField(this, "events");
|
|
109
24
|
__publicField(this, "status");
|
|
110
|
-
this._isPause = false;
|
|
111
|
-
this._state = {};
|
|
112
|
-
this._reducer = () => {
|
|
113
|
-
return {};
|
|
114
|
-
};
|
|
115
|
-
this.status = "resting";
|
|
116
|
-
this.events = new PubSub();
|
|
117
|
-
if (params == null ? void 0 : params.hasOwnProperty("reducer")) {
|
|
118
|
-
this._reducer = params.reducer;
|
|
119
|
-
}
|
|
120
|
-
this.refreshProxy(params == null ? void 0 : params.state);
|
|
25
|
+
this._isPause = false, this._state = {}, this._reducer = () => ({}), this.status = "resting", this.events = new r(), (e2 == null ? void 0 : e2.hasOwnProperty("reducer")) && (this._reducer = e2.reducer), this.refreshProxy(e2 == null ? void 0 : e2.state);
|
|
121
26
|
}
|
|
122
|
-
|
|
123
|
-
* Dispatches an action to update the state by invoking the reducer function.
|
|
124
|
-
* @param {object} action The action object containing the type and any associated payload.
|
|
125
|
-
* @param {string} action.type The type of the action being dispatched.
|
|
126
|
-
* @returns {boolean} Returns `true` after the state has been successfully updated.
|
|
127
|
-
* @example
|
|
128
|
-
* const action = { type: 'INCREMENT', payload: { amount: 1 } };
|
|
129
|
-
* store.dispatch(action);
|
|
130
|
-
*/
|
|
131
|
-
dispatch(action) {
|
|
27
|
+
dispatch(e2) {
|
|
132
28
|
this.status = "action";
|
|
133
|
-
let
|
|
134
|
-
this.status = "mutation";
|
|
135
|
-
this._state = Object.assign(this._state, newState);
|
|
136
|
-
return true;
|
|
29
|
+
let t2 = this._reducer(this._state, e2);
|
|
30
|
+
return this.status = "mutation", this._state = Object.assign(this._state, t2), true;
|
|
137
31
|
}
|
|
138
|
-
/**
|
|
139
|
-
* Retrieves a deep copy of the current state to ensure immutability.
|
|
140
|
-
* @returns {object} A deep copy of the current state.
|
|
141
|
-
* @example
|
|
142
|
-
* const currentState = store.getState();
|
|
143
|
-
* console.log(currentState);
|
|
144
|
-
*/
|
|
145
32
|
getState() {
|
|
146
33
|
return JSON.parse(JSON.stringify(this._state));
|
|
147
34
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
* @param {string} eventName The name of the event to subscribe to.
|
|
151
|
-
* @param {Function} callbackFn The function to execute when the event is triggered.
|
|
152
|
-
* @returns {Function} - A function to unsubscribe from the event.
|
|
153
|
-
* @example
|
|
154
|
-
* const unsubscribe = store.subscribe('stateChange', (newState) => {
|
|
155
|
-
* console.log('State changed:', newState);
|
|
156
|
-
* });
|
|
157
|
-
* // Later, to unsubscribe
|
|
158
|
-
* unsubscribe();
|
|
159
|
-
*/
|
|
160
|
-
subscribe(eventName, callbackFn) {
|
|
161
|
-
return this.events.subscribe(eventName, callbackFn);
|
|
35
|
+
subscribe(e2, t2) {
|
|
36
|
+
return this.events.subscribe(e2, t2);
|
|
162
37
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
* @param {string} eventName The name of the event to unsubscribe from.
|
|
166
|
-
* @returns {void}
|
|
167
|
-
* @example
|
|
168
|
-
* store.unsubscribe('stateChange');
|
|
169
|
-
*/
|
|
170
|
-
unsubscribe(eventName) {
|
|
171
|
-
delete this.events[eventName];
|
|
38
|
+
unsubscribe(e2) {
|
|
39
|
+
delete this.events[e2];
|
|
172
40
|
}
|
|
173
|
-
/**
|
|
174
|
-
* Pauses event handling or other operations.
|
|
175
|
-
* @returns {this} Returns the current instance for method chaining.
|
|
176
|
-
* @example
|
|
177
|
-
* store.pause().doSomething();
|
|
178
|
-
*/
|
|
179
41
|
pause() {
|
|
180
|
-
this._isPause = true;
|
|
181
|
-
return this;
|
|
42
|
+
return this._isPause = true, this;
|
|
182
43
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
* @param {*} [val] Optional value to pass while resuming.
|
|
186
|
-
* @returns {this} Returns the current instance for method chaining.
|
|
187
|
-
* @example
|
|
188
|
-
* store.play().doSomething();
|
|
189
|
-
*/
|
|
190
|
-
play(val) {
|
|
191
|
-
this._isPause = false;
|
|
192
|
-
return this;
|
|
44
|
+
play(e2) {
|
|
45
|
+
return this._isPause = false, this;
|
|
193
46
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
* @param {Function} newReducer The reducer function to handle updates for the specified state property.
|
|
198
|
-
* @returns {void}
|
|
199
|
-
* @example
|
|
200
|
-
* const newReducer = (newState, currentState) => ({ ...currentState, ...newState });
|
|
201
|
-
* store.mergeReducers('user', newReducer);
|
|
202
|
-
*/
|
|
203
|
-
mergeReducers(stateValueName, newReducer) {
|
|
204
|
-
let reducerCopy = this._reducer;
|
|
205
|
-
this._reducer = (state, newState) => {
|
|
206
|
-
let preState = reducerCopy(state, newState);
|
|
207
|
-
return {
|
|
208
|
-
...preState,
|
|
209
|
-
[stateValueName]: newReducer(newState, state[stateValueName])
|
|
210
|
-
};
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Synchronizes each entry in an array with the store by defining or updating state entries.
|
|
215
|
-
* @param {string} storeKey The key prefix used for defining or updating store entries.
|
|
216
|
-
* @param {Array<object>} [array] The array of entries to be synchronized with the store.
|
|
217
|
-
* @param {string} [identificator] The property name used as a unique identifier for each entry.
|
|
218
|
-
* @returns {void}
|
|
219
|
-
* @example
|
|
220
|
-
* const data = [{ id: 1, name: 'Item 1' }, { id: 2, name: 'Item 2' }];
|
|
221
|
-
* store.makeEveryArrayEntryAsStoreState('items', data, 'id');
|
|
222
|
-
*/
|
|
223
|
-
makeEveryArrayEntryAsStoreState(storeKey, array = [], identificator = "id") {
|
|
224
|
-
array.forEach((entry) => {
|
|
225
|
-
if (this.getState().hasOwnProperty(`${storeKey}-${entry[identificator]}`)) {
|
|
226
|
-
this.dispatch(updateAction(`${storeKey}-${entry[identificator]}`)(entry));
|
|
227
|
-
} else {
|
|
228
|
-
this.define(
|
|
229
|
-
`${storeKey}-${entry.id || entry.source || entry[identificator]}`,
|
|
230
|
-
entry,
|
|
231
|
-
null,
|
|
232
|
-
identificator
|
|
233
|
-
);
|
|
234
|
-
}
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
/**
|
|
238
|
-
* Defines a new state variable and associates it with a reducer.
|
|
239
|
-
* @param {string} stateValueName The name of the state variable to define.
|
|
240
|
-
* @param {*} defaultValue The initial value of the state variable.
|
|
241
|
-
* @param {Function|null} [reducer] An optional reducer function to manage updates for the state variable.
|
|
242
|
-
* @param {string} [key] The key used to identify individual entries if the state value is an array or object.
|
|
243
|
-
* @returns {void}
|
|
244
|
-
* @example
|
|
245
|
-
* // Define a new state with a custom reducer
|
|
246
|
-
* store.define('user', { id: 1, name: 'John Doe' }, (newState, currentState) => ({ ...currentState, ...newState }));
|
|
247
|
-
* @example
|
|
248
|
-
* // Define a new state with default array reducer
|
|
249
|
-
* store.define('items', [], null, 'itemId');
|
|
250
|
-
*/
|
|
251
|
-
define(stateValueName, defaultValue, reducer, key = "id") {
|
|
252
|
-
if (this._state.hasOwnProperty(stateValueName)) {
|
|
253
|
-
console.warn(`STATE už obsahuje premennú ${stateValueName},ktorú sa pokúšate pridať`);
|
|
254
|
-
return;
|
|
255
|
-
}
|
|
256
|
-
if (reducer instanceof Function) {
|
|
257
|
-
this.mergeReducers(stateValueName, reducer);
|
|
258
|
-
} else {
|
|
259
|
-
if (defaultValue instanceof Array) {
|
|
260
|
-
this.mergeReducers(stateValueName, this.createArrayReducer(stateValueName, key));
|
|
261
|
-
} else {
|
|
262
|
-
this.mergeReducers(stateValueName, this.createObjectReducer(stateValueName, key));
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
this.refreshProxy({
|
|
266
|
-
...this._state,
|
|
267
|
-
[stateValueName]: defaultValue
|
|
268
|
-
});
|
|
47
|
+
mergeReducers(e2, t2) {
|
|
48
|
+
let r2 = this._reducer;
|
|
49
|
+
this._reducer = (s2, a) => ({ ...r2(s2, a), [e2]: t2(a, s2[e2]) });
|
|
269
50
|
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
* @returns {void}
|
|
274
|
-
* @example
|
|
275
|
-
* store.refreshProxy({ user: { id: 1, name: 'John Doe' } });
|
|
276
|
-
*/
|
|
277
|
-
refreshProxy(newState) {
|
|
278
|
-
this._state = new Proxy(newState || {}, {
|
|
279
|
-
set: (state, key, value) => {
|
|
280
|
-
if (JSON.stringify(state[key]) === JSON.stringify(value)) {
|
|
281
|
-
return true;
|
|
282
|
-
}
|
|
283
|
-
let oldState = state[key];
|
|
284
|
-
state[key] = value;
|
|
285
|
-
if (!this._isPause) this.events.publish(key, this._state, state[key], oldState);
|
|
286
|
-
if (this.status !== "mutation") {
|
|
287
|
-
console.warn(`You should use a mutation to set ${key}`);
|
|
288
|
-
}
|
|
289
|
-
this.status = "resting";
|
|
290
|
-
return true;
|
|
291
|
-
}
|
|
51
|
+
makeEveryArrayEntryAsStoreState(t2, r2 = [], s2 = "id") {
|
|
52
|
+
r2.forEach((r3) => {
|
|
53
|
+
this.getState().hasOwnProperty(`${t2}-${r3[s2]}`) ? this.dispatch(e(`${t2}-${r3[s2]}`)(r3)) : this.define(`${t2}-${r3.id || r3.source || r3[s2]}`, r3, null, s2);
|
|
292
54
|
});
|
|
293
55
|
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
switch (action.type) {
|
|
315
|
-
case `${stateValueName}/ADD`:
|
|
316
|
-
return {
|
|
317
|
-
...action.payload
|
|
318
|
-
};
|
|
319
|
-
case `${stateValueName}/UPDATE`:
|
|
320
|
-
return {
|
|
321
|
-
...state,
|
|
322
|
-
...action.payload
|
|
323
|
-
};
|
|
324
|
-
case `${stateValueName}/DELETE`:
|
|
56
|
+
define(e2, t2, r2, s2 = "id") {
|
|
57
|
+
this._state.hasOwnProperty(e2) ? console.warn(`STATE už obsahuje premennú ${e2},ktorú sa pokúšate pridať`) : (r2 instanceof Function ? this.mergeReducers(e2, r2) : t2 instanceof Array ? this.mergeReducers(e2, this.createArrayReducer(e2, s2)) : this.mergeReducers(e2, this.createObjectReducer(e2, s2)), this.refreshProxy({ ...this._state, [e2]: t2 }));
|
|
58
|
+
}
|
|
59
|
+
refreshProxy(e2) {
|
|
60
|
+
this._state = new Proxy(e2 || {}, { set: (e3, t2, r2) => {
|
|
61
|
+
if (JSON.stringify(e3[t2]) === JSON.stringify(r2)) return true;
|
|
62
|
+
let s2 = e3[t2];
|
|
63
|
+
return e3[t2] = r2, this._isPause || this.events.publish(t2, this._state, e3[t2], s2), "mutation" !== this.status && console.warn(`You should use a mutation to set ${t2}`), this.status = "resting", true;
|
|
64
|
+
} });
|
|
65
|
+
}
|
|
66
|
+
createObjectReducer(e2) {
|
|
67
|
+
return (t2, r2 = {}) => {
|
|
68
|
+
!Array.isArray(t2.payload) || t2.type !== `${e2}/ADD` && t2.type !== `${e2}/UPDATE` || console.error(`Nemôžete pridať do objektu ${e2} hodnotu, ktorá je pole.`);
|
|
69
|
+
const s2 = t2.type.split("/")[1];
|
|
70
|
+
switch (t2.type.startsWith(`${e2}/`) && !["ADD", "UPDATE", "DELETE"].includes(s2) && console.error(`Nemôžete použiť akciu ${s2} na objekt. Správne akcie pre objekt sú: ADD, UPDATE, DELETE`), t2.type) {
|
|
71
|
+
case `${e2}/ADD`:
|
|
72
|
+
return { ...t2.payload };
|
|
73
|
+
case `${e2}/UPDATE`:
|
|
74
|
+
return { ...r2, ...t2.payload };
|
|
75
|
+
case `${e2}/DELETE`:
|
|
325
76
|
return {};
|
|
326
77
|
default:
|
|
327
|
-
return
|
|
78
|
+
return r2;
|
|
328
79
|
}
|
|
329
80
|
};
|
|
330
81
|
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
* @param {string} stateValueName The name of the state property this reducer manages.
|
|
334
|
-
* @param {string} key The unique key used to identify items in the array for updates and deletions.
|
|
335
|
-
* @returns {Function} A reducer function that handles `ADD`, `ADD_MANY`, `UPDATE`, `DELETE`, and `LOAD` actions for the specified state property.
|
|
336
|
-
* @throws {Error} If `action.payload` is not an array when required.
|
|
337
|
-
* @example
|
|
338
|
-
* const itemsReducer = store.createArrayReducer('items', 'id');
|
|
339
|
-
* const newState = itemsReducer({ type: 'items/ADD', payload: { id: 1, name: 'Item 1' } });
|
|
340
|
-
*/
|
|
341
|
-
createArrayReducer(stateValueName, key) {
|
|
342
|
-
return (action, state = []) => {
|
|
82
|
+
createArrayReducer(e2, t2) {
|
|
83
|
+
return (r2, s2 = []) => {
|
|
343
84
|
var _a;
|
|
344
|
-
if (
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
return [...
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
}
|
|
357
|
-
case `${stateValueName}/ADD_MANY`:
|
|
358
|
-
return [...state, ...action.payload];
|
|
359
|
-
case `${stateValueName}/UPDATE`:
|
|
360
|
-
if (state.some((obj) => obj[key] === action.payload[key])) {
|
|
361
|
-
return [
|
|
362
|
-
...state.map((obj) => {
|
|
363
|
-
if (obj[key] === action.payload[key]) {
|
|
364
|
-
return action.payload;
|
|
365
|
-
}
|
|
366
|
-
return obj;
|
|
367
|
-
})
|
|
368
|
-
];
|
|
369
|
-
} else {
|
|
370
|
-
return [...state, action.payload];
|
|
371
|
-
}
|
|
372
|
-
case `${stateValueName}/DELETE`:
|
|
373
|
-
if (Array.isArray(action.payload)) {
|
|
374
|
-
return [
|
|
375
|
-
...state.filter(
|
|
376
|
-
(obj) => !action.payload.some(
|
|
377
|
-
(item) => obj.hasOwnProperty(key) && obj[key] !== item[key] || !obj.hasOwnProperty(key) && obj !== item
|
|
378
|
-
)
|
|
379
|
-
)
|
|
380
|
-
];
|
|
381
|
-
}
|
|
382
|
-
return [
|
|
383
|
-
...state.filter(
|
|
384
|
-
(obj) => obj.hasOwnProperty(key) && obj[key] !== action.payload[key] || !obj.hasOwnProperty(key) && obj !== action.payload
|
|
385
|
-
)
|
|
386
|
-
];
|
|
387
|
-
case `${stateValueName}/LOAD`:
|
|
388
|
-
return [...action.payload];
|
|
85
|
+
if ("LOAD" === r2.actionType && ((_a = r2.type) == null ? void 0 : _a.includes(e2)) && !Array.isArray(r2.payload)) return console.error('Snažíte sa použiť "LOAD" akciu na pole, ale payload nie je pole.'), [...s2];
|
|
86
|
+
switch (r2.type) {
|
|
87
|
+
case `${e2}/ADD`:
|
|
88
|
+
return Array.isArray(r2.payload) ? [...s2, ...r2.payload] : [...s2, r2.payload];
|
|
89
|
+
case `${e2}/ADD_MANY`:
|
|
90
|
+
return [...s2, ...r2.payload];
|
|
91
|
+
case `${e2}/UPDATE`:
|
|
92
|
+
return s2.some((e3) => e3[t2] === r2.payload[t2]) ? [...s2.map((e3) => e3[t2] === r2.payload[t2] ? r2.payload : e3)] : [...s2, r2.payload];
|
|
93
|
+
case `${e2}/DELETE`:
|
|
94
|
+
return Array.isArray(r2.payload) ? [...s2.filter((e3) => !r2.payload.some((r3) => e3.hasOwnProperty(t2) && e3[t2] !== r3[t2] || !e3.hasOwnProperty(t2) && e3 !== r3))] : [...s2.filter((e3) => e3.hasOwnProperty(t2) && e3[t2] !== r2.payload[t2] || !e3.hasOwnProperty(t2) && e3 !== r2.payload)];
|
|
95
|
+
case `${e2}/LOAD`:
|
|
96
|
+
return [...r2.payload];
|
|
389
97
|
default:
|
|
390
|
-
return
|
|
98
|
+
return s2;
|
|
391
99
|
}
|
|
392
100
|
};
|
|
393
101
|
}
|
|
394
|
-
}
|
|
395
|
-
let store = new Store();
|
|
102
|
+
}();
|
|
396
103
|
export {
|
|
397
|
-
defaultStoreActions,
|
|
398
|
-
store
|
|
104
|
+
t as defaultStoreActions,
|
|
105
|
+
s as store
|
|
399
106
|
};
|
|
400
107
|
//# sourceMappingURL=wje-store.js.map
|