wj-elements 0.2.0-alpha.8 → 0.3.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/dark.css +15 -1
- package/dist/{form-associated-element-o0UjvdUp.js → form-associated-element-DEQ4y-jn.js} +1 -2
- package/dist/form-associated-element-DEQ4y-jn.js.map +1 -0
- package/dist/{icon-DY5AZ6xM.js → icon-DVyMc4Wv.js} +36 -2
- package/dist/{icon-DY5AZ6xM.js.map → icon-DVyMc4Wv.js.map} +1 -1
- package/dist/{packages/internals → internals}/form-associated-element.d.ts +0 -1
- package/dist/light.css +7 -2
- package/dist/localize.js +8 -5
- package/dist/localize.js.map +1 -1
- package/dist/{popup.element-DeajFyOQ.js → popup.element-Cl6QeG8M.js} +2 -2
- package/dist/{popup.element-DeajFyOQ.js.map → popup.element-Cl6QeG8M.js.map} +1 -1
- package/dist/skeleton.css +197 -0
- package/dist/utils/utils.d.ts +17 -0
- package/dist/utils.js +18 -1
- package/dist/utils.js.map +1 -1
- package/dist/{packages/wje-accordion-item → wje-accordion-item}/accordion-item.element.d.ts +3 -0
- package/dist/wje-accordion-item.js +26 -4
- package/dist/wje-accordion-item.js.map +1 -1
- package/dist/wje-accordion.js +1 -0
- package/dist/wje-accordion.js.map +1 -1
- package/dist/wje-animation.js +1 -0
- package/dist/wje-animation.js.map +1 -1
- package/dist/{packages/wje-avatar → wje-avatar}/avatar.element.d.ts +5 -0
- package/dist/wje-avatar.js +18 -0
- package/dist/wje-avatar.js.map +1 -1
- package/dist/wje-badge.js +1 -0
- package/dist/wje-badge.js.map +1 -1
- package/dist/{packages/wje-breadcrumb → wje-breadcrumb}/breadcrumb.element.d.ts +1 -0
- package/dist/wje-breadcrumb.js +13 -1
- package/dist/wje-breadcrumb.js.map +1 -1
- package/dist/wje-breadcrumbs.js +1 -0
- package/dist/wje-breadcrumbs.js.map +1 -1
- package/dist/{packages/wje-button → wje-button}/button.element.d.ts +5 -1
- package/dist/{packages/wje-button-group → wje-button-group}/button-group.element.d.ts +4 -0
- package/dist/wje-button-group.js +10 -0
- package/dist/wje-button-group.js.map +1 -1
- package/dist/wje-button.js +29 -5
- package/dist/wje-button.js.map +1 -1
- package/dist/{packages/wje-card → wje-card}/card.element.d.ts +15 -6
- package/dist/wje-card.js +37 -0
- package/dist/wje-card.js.map +1 -1
- package/dist/{packages/wje-carousel → wje-carousel}/carousel.element.d.ts +4 -0
- package/dist/wje-carousel.js +38 -4
- package/dist/wje-carousel.js.map +1 -1
- package/dist/{packages/wje-checkbox → wje-checkbox}/checkbox.element.d.ts +14 -0
- package/dist/wje-checkbox.js +48 -3
- package/dist/wje-checkbox.js.map +1 -1
- package/dist/{packages/wje-chip → wje-chip}/chip.element.d.ts +6 -0
- package/dist/wje-chip.js +22 -0
- package/dist/wje-chip.js.map +1 -1
- package/dist/{packages/wje-color-picker → wje-color-picker}/color-picker.element.d.ts +43 -1
- package/dist/wje-color-picker.js +143 -29
- package/dist/wje-color-picker.js.map +1 -1
- package/dist/{packages/wje-copy-button → wje-copy-button}/copy-button.element.d.ts +4 -0
- package/dist/wje-copy-button.js +21 -0
- package/dist/wje-copy-button.js.map +1 -1
- package/dist/{packages/wje-dialog → wje-dialog}/dialog.element.d.ts +2 -0
- package/dist/wje-dialog.js +35 -2
- package/dist/wje-dialog.js.map +1 -1
- package/dist/{packages/wje-dropdown → wje-dropdown}/dropdown.element.d.ts +7 -0
- package/dist/wje-dropdown.js +27 -3
- package/dist/wje-dropdown.js.map +1 -1
- package/dist/{packages/wje-element → wje-element}/element.d.ts +55 -24
- package/dist/wje-element.js +87 -242
- package/dist/wje-element.js.map +1 -1
- package/dist/{packages/wje-file-upload → wje-file-upload}/file-upload.element.d.ts +17 -6
- package/dist/{packages/wje-file-upload → wje-file-upload}/service/service.d.ts +0 -23
- package/dist/{packages/wje-file-upload-item → wje-file-upload-item}/file-upload-item.element.d.ts +6 -0
- package/dist/wje-file-upload-item.js +24 -2
- package/dist/wje-file-upload-item.js.map +1 -1
- package/dist/wje-file-upload.js +100 -77
- package/dist/wje-file-upload.js.map +1 -1
- package/dist/{packages/wje-format-digital → wje-format-digital}/format-digital.element.d.ts +2 -0
- package/dist/wje-format-digital.js +9 -0
- package/dist/wje-format-digital.js.map +1 -1
- package/dist/{packages/wje-icon → wje-icon}/icon.element.d.ts +11 -0
- package/dist/{packages/wje-icon-picker → wje-icon-picker}/icon-picker.element.d.ts +4 -0
- package/dist/wje-icon-picker.js +15 -0
- package/dist/wje-icon-picker.js.map +1 -1
- package/dist/wje-icon.js +1 -1
- package/dist/{packages/wje-img → wje-img}/img.element.d.ts +1 -0
- package/dist/wje-img-comparer.js +5 -1
- package/dist/wje-img-comparer.js.map +1 -1
- package/dist/wje-img.js +16 -1
- package/dist/wje-img.js.map +1 -1
- package/dist/{packages/wje-infinite-scroll → wje-infinite-scroll}/infinite-scroll.element.d.ts +4 -0
- package/dist/wje-infinite-scroll.js +10 -0
- package/dist/wje-infinite-scroll.js.map +1 -1
- package/dist/{packages/wje-input → wje-input}/input.element.d.ts +9 -1
- package/dist/wje-input-file.js +2 -0
- package/dist/wje-input-file.js.map +1 -1
- package/dist/wje-input.js +59 -4
- package/dist/wje-input.js.map +1 -1
- package/dist/{packages/wje-item → wje-item}/item.element.d.ts +8 -0
- package/dist/wje-item.js +14 -0
- package/dist/wje-item.js.map +1 -1
- package/dist/{packages/wje-kanban → wje-kanban}/kanban.element.d.ts +4 -0
- package/dist/wje-kanban.js +14 -0
- package/dist/wje-kanban.js.map +1 -1
- package/dist/{packages/wje-level-indicator → wje-level-indicator}/level-indicator.element.d.ts +17 -0
- package/dist/wje-level-indicator.js +36 -0
- package/dist/wje-level-indicator.js.map +1 -1
- package/dist/{packages/wje-list → wje-list}/list.element.d.ts +4 -0
- package/dist/wje-list.js +10 -0
- package/dist/wje-list.js.map +1 -1
- package/dist/wje-master.js +11 -2
- package/dist/wje-master.js.map +1 -1
- package/dist/wje-menu-button.js +1 -0
- package/dist/wje-menu-button.js.map +1 -1
- package/dist/{packages/wje-menu-item → wje-menu-item}/menu-item.element.d.ts +4 -0
- package/dist/wje-menu-item.js +24 -0
- package/dist/wje-menu-item.js.map +1 -1
- package/dist/wje-menu.js +4 -1
- package/dist/wje-menu.js.map +1 -1
- package/dist/{packages/wje-option → wje-option}/option.element.d.ts +4 -0
- package/dist/wje-option.js +14 -1
- package/dist/wje-option.js.map +1 -1
- package/dist/{packages/wje-options → wje-options}/options.element.d.ts +4 -0
- package/dist/wje-options.js +13 -0
- package/dist/wje-options.js.map +1 -1
- package/dist/{packages/wje-orgchart → wje-orgchart}/orgchart.element.d.ts +4 -0
- package/dist/wje-orgchart.js +9 -0
- package/dist/wje-orgchart.js.map +1 -1
- package/dist/wje-pagination.js +18 -9
- package/dist/wje-pagination.js.map +1 -1
- package/dist/wje-popup.js +1 -1
- package/dist/{packages/wje-progress-bar → wje-progress-bar}/progress-bar.element.d.ts +11 -0
- package/dist/wje-progress-bar.js +26 -0
- package/dist/wje-progress-bar.js.map +1 -1
- package/dist/wje-qr-code/qr-code.element.d.ts +96 -0
- package/dist/wje-qr-code.js +159 -17
- package/dist/wje-qr-code.js.map +1 -1
- package/dist/{packages/wje-radio → wje-radio}/radio.element.d.ts +5 -0
- package/dist/{packages/wje-radio-group → wje-radio-group}/radio-group.element.d.ts +16 -1
- package/dist/wje-radio-group.js +49 -2
- package/dist/wje-radio-group.js.map +1 -1
- package/dist/wje-radio.js +27 -1
- package/dist/wje-radio.js.map +1 -1
- package/dist/{packages/wje-rate → wje-rate}/rate.element.d.ts +4 -0
- package/dist/wje-rate.js +23 -1
- package/dist/wje-rate.js.map +1 -1
- package/dist/{packages/wje-relative-time → wje-relative-time}/relative-time.element.d.ts +2 -0
- package/dist/wje-relative-time.js +14 -1
- package/dist/wje-relative-time.js.map +1 -1
- package/dist/{packages/wje-reorder → wje-reorder}/reorder.element.d.ts +4 -0
- package/dist/{packages/wje-reorder-handle → wje-reorder-handle}/reorder-handle.element.d.ts +4 -0
- package/dist/wje-reorder-handle.js +21 -0
- package/dist/wje-reorder-handle.js.map +1 -1
- package/dist/wje-reorder.js +10 -0
- package/dist/wje-reorder.js.map +1 -1
- package/dist/{packages/wje-select → wje-select}/select.element.d.ts +7 -0
- package/dist/wje-select.js +35 -5
- package/dist/wje-select.js.map +1 -1
- package/dist/{packages/wje-slider → wje-slider}/slider.element.d.ts +5 -0
- package/dist/wje-slider.js +51 -1
- package/dist/wje-slider.js.map +1 -1
- package/dist/{packages/wje-sliding-container → wje-sliding-container}/sliding-container.element.d.ts +4 -0
- package/dist/wje-sliding-container.js +18 -0
- package/dist/wje-sliding-container.js.map +1 -1
- package/dist/{packages/wje-split-view → wje-split-view}/split-view.element.d.ts +1 -0
- package/dist/wje-split-view.js +9 -0
- package/dist/wje-split-view.js.map +1 -1
- package/dist/wje-status.js +1 -0
- package/dist/wje-status.js.map +1 -1
- package/dist/{packages/wje-stepper → wje-stepper}/stepper.element.d.ts +1 -0
- package/dist/wje-stepper.js +24 -1
- package/dist/wje-stepper.js.map +1 -1
- package/dist/{packages/wje-tab → wje-tab}/tab.element.d.ts +10 -0
- package/dist/{packages/wje-tab-group → wje-tab-group}/tab-group.element.d.ts +11 -0
- package/dist/wje-tab-group.js +59 -2
- package/dist/wje-tab-group.js.map +1 -1
- package/dist/wje-tab.js +30 -0
- package/dist/wje-tab.js.map +1 -1
- package/dist/{packages/wje-textarea → wje-textarea}/textarea.element.d.ts +20 -1
- package/dist/wje-textarea.js +96 -14
- package/dist/wje-textarea.js.map +1 -1
- package/dist/{packages/wje-thumbnail → wje-thumbnail}/thumbnail.element.d.ts +4 -0
- package/dist/wje-thumbnail.js +19 -0
- package/dist/wje-thumbnail.js.map +1 -1
- package/dist/{packages/wje-timeline → wje-timeline}/timeline.element.d.ts +4 -0
- package/dist/wje-toast.js +4 -0
- package/dist/wje-toast.js.map +1 -1
- package/dist/{packages/wje-toggle → wje-toggle}/toggle.element.d.ts +4 -0
- package/dist/wje-toggle.js +17 -1
- package/dist/wje-toggle.js.map +1 -1
- package/dist/{packages/wje-toolbar → wje-toolbar}/toolbar.element.d.ts +4 -0
- package/dist/wje-toolbar.js +14 -0
- package/dist/wje-toolbar.js.map +1 -1
- package/dist/{packages/wje-tooltip → wje-tooltip}/tooltip.element.d.ts +3 -0
- package/dist/wje-tooltip.js +31 -7
- package/dist/wje-tooltip.js.map +1 -1
- package/dist/{packages/wje-tree → wje-tree}/tree.element.d.ts +4 -0
- package/dist/{packages/wje-tree-item → wje-tree-item}/tree-item.element.d.ts +5 -0
- package/dist/wje-tree-item.js +41 -5
- package/dist/wje-tree-item.js.map +1 -1
- package/dist/wje-tree.js +12 -1
- package/dist/wje-tree.js.map +1 -1
- package/package.json +21 -2
- package/dist/form-associated-element-o0UjvdUp.js.map +0 -1
- package/dist/packages/utils/utils.d.ts +0 -1
- package/dist/packages/wje-accordion/accordion.test.d.ts +0 -0
- package/dist/packages/wje-animation/animation.test.d.ts +0 -1
- package/dist/packages/wje-avatar/avatar.test.d.ts +0 -1
- package/dist/packages/wje-badge/badge.test.d.ts +0 -1
- package/dist/packages/wje-breadcrumbs/breadcrumbs.test.d.ts +0 -1
- package/dist/packages/wje-button/button.test.d.ts +0 -1
- package/dist/packages/wje-chip/chip.test.d.ts +0 -1
- package/dist/packages/wje-color-picker/color-picker.test.d.ts +0 -1
- package/dist/packages/wje-file-upload/file-upload.test.d.ts +0 -1
- package/dist/packages/wje-format-digital/format-digital.test.d.ts +0 -1
- package/dist/packages/wje-pagination/pagination.test.d.ts +0 -1
- package/dist/packages/wje-qr-code/qr-code.element.d.ts +0 -33
- package/dist/packages/wje-relative-time/relative-time.test.d.ts +0 -1
- package/dist/packages/wje-select/select.test.d.ts +0 -1
- package/dist/packages/wje-tab-group/tab-group.test.d.ts +0 -1
- package/dist/packages/wje-toast/toast.test.d.ts +0 -1
- package/dist/packages/wje-toggle/toggle.test.d.ts +0 -1
- package/dist/packages/wje-tree/tree.test.d.ts +0 -1
- package/dist/packages/wje-tree-item/tree-item.test.d.ts +0 -1
- /package/dist/{packages/index.d.ts → index.d.ts} +0 -0
- /package/dist/{packages/localize → localize}/localize.d.ts +0 -0
- /package/dist/{packages/translations → translations}/en-gb.d.ts +0 -0
- /package/dist/{packages/translations → translations}/sk-sk.d.ts +0 -0
- /package/dist/{packages/utils → utils}/animations.d.ts +0 -0
- /package/dist/{packages/utils → utils}/base-path.d.ts +0 -0
- /package/dist/{packages/utils → utils}/date.d.ts +0 -0
- /package/dist/{packages/utils → utils}/element-utils.d.ts +0 -0
- /package/dist/{packages/utils → utils}/event.d.ts +0 -0
- /package/dist/{packages/utils → utils}/icon-library.d.ts +0 -0
- /package/dist/{packages/utils → utils}/localize.d.ts +0 -0
- /package/dist/{packages/utils → utils}/permissions.d.ts +0 -0
- /package/dist/{packages/utils → utils}/universal-service.d.ts +0 -0
- /package/dist/{packages/wje-accordion → wje-accordion}/accordion.d.ts +0 -0
- /package/dist/{packages/wje-accordion → wje-accordion}/accordion.element.d.ts +0 -0
- /package/dist/{packages/wje-accordion-item → wje-accordion-item}/accordion-item.d.ts +0 -0
- /package/dist/{packages/wje-animation → wje-animation}/animation.d.ts +0 -0
- /package/dist/{packages/wje-animation → wje-animation}/animation.element.d.ts +0 -0
- /package/dist/{packages/wje-aside → wje-aside}/aside.d.ts +0 -0
- /package/dist/{packages/wje-aside → wje-aside}/aside.element.d.ts +0 -0
- /package/dist/{packages/wje-avatar → wje-avatar}/avatar.d.ts +0 -0
- /package/dist/{packages/wje-avatar → wje-avatar}/service/service.d.ts +0 -0
- /package/dist/{packages/wje-badge → wje-badge}/badge.d.ts +0 -0
- /package/dist/{packages/wje-badge → wje-badge}/badge.element.d.ts +0 -0
- /package/dist/{packages/wje-breadcrumb → wje-breadcrumb}/breadcrumb.d.ts +0 -0
- /package/dist/{packages/wje-breadcrumbs → wje-breadcrumbs}/breadcrumbs.d.ts +0 -0
- /package/dist/{packages/wje-breadcrumbs → wje-breadcrumbs}/breadcrumbs.element.d.ts +0 -0
- /package/dist/{packages/wje-button → wje-button}/button.d.ts +0 -0
- /package/dist/{packages/wje-button-group → wje-button-group}/button-group.d.ts +0 -0
- /package/dist/{packages/wje-card → wje-card}/card.d.ts +0 -0
- /package/dist/{packages/wje-card-content → wje-card-content}/card-content.d.ts +0 -0
- /package/dist/{packages/wje-card-content → wje-card-content}/card-content.element.d.ts +0 -0
- /package/dist/{packages/wje-card-controls → wje-card-controls}/card-controls.d.ts +0 -0
- /package/dist/{packages/wje-card-controls → wje-card-controls}/card-controls.element.d.ts +0 -0
- /package/dist/{packages/wje-card-header → wje-card-header}/card-header.d.ts +0 -0
- /package/dist/{packages/wje-card-header → wje-card-header}/card-header.element.d.ts +0 -0
- /package/dist/{packages/wje-card-subtitle → wje-card-subtitle}/card-subtitle.d.ts +0 -0
- /package/dist/{packages/wje-card-subtitle → wje-card-subtitle}/card-subtitle.element.d.ts +0 -0
- /package/dist/{packages/wje-card-title → wje-card-title}/card-title.d.ts +0 -0
- /package/dist/{packages/wje-card-title → wje-card-title}/card-title.element.d.ts +0 -0
- /package/dist/{packages/wje-carousel → wje-carousel}/carousel.d.ts +0 -0
- /package/dist/{packages/wje-carousel-item → wje-carousel-item}/carousel-item.d.ts +0 -0
- /package/dist/{packages/wje-carousel-item → wje-carousel-item}/carousel-item.element.d.ts +0 -0
- /package/dist/{packages/wje-checkbox → wje-checkbox}/checkbox.d.ts +0 -0
- /package/dist/{packages/wje-chip → wje-chip}/chip.d.ts +0 -0
- /package/dist/{packages/wje-col → wje-col}/col.d.ts +0 -0
- /package/dist/{packages/wje-col → wje-col}/col.element.d.ts +0 -0
- /package/dist/{packages/wje-color-picker → wje-color-picker}/color-picker.d.ts +0 -0
- /package/dist/{packages/wje-container → wje-container}/container.d.ts +0 -0
- /package/dist/{packages/wje-container → wje-container}/container.element.d.ts +0 -0
- /package/dist/{packages/wje-copy-button → wje-copy-button}/copy-button.d.ts +0 -0
- /package/dist/{packages/wje-copy-button → wje-copy-button}/service/service.d.ts +0 -0
- /package/dist/{packages/wje-dialog → wje-dialog}/dialog.d.ts +0 -0
- /package/dist/{packages/wje-divider → wje-divider}/divider.d.ts +0 -0
- /package/dist/{packages/wje-divider → wje-divider}/divider.element.d.ts +0 -0
- /package/dist/{packages/wje-dropdown → wje-dropdown}/dropdown.d.ts +0 -0
- /package/dist/{packages/wje-file-upload → wje-file-upload}/file-upload.d.ts +0 -0
- /package/dist/{packages/wje-file-upload-item → wje-file-upload-item}/file-upload-item.d.ts +0 -0
- /package/dist/{packages/wje-footer → wje-footer}/footer.d.ts +0 -0
- /package/dist/{packages/wje-footer → wje-footer}/footer.element.d.ts +0 -0
- /package/dist/{packages/wje-form → wje-form}/form.d.ts +0 -0
- /package/dist/{packages/wje-form → wje-form}/form.element.d.ts +0 -0
- /package/dist/{packages/wje-format-digital → wje-format-digital}/format-digital.d.ts +0 -0
- /package/dist/{packages/wje-grid → wje-grid}/grid.d.ts +0 -0
- /package/dist/{packages/wje-grid → wje-grid}/grid.element.d.ts +0 -0
- /package/dist/{packages/wje-header → wje-header}/header.d.ts +0 -0
- /package/dist/{packages/wje-header → wje-header}/header.element.d.ts +0 -0
- /package/dist/{packages/wje-icon → wje-icon}/icon.d.ts +0 -0
- /package/dist/{packages/wje-icon → wje-icon}/service/library.d.ts +0 -0
- /package/dist/{packages/wje-icon → wje-icon}/service/service.d.ts +0 -0
- /package/dist/{packages/wje-icon-picker → wje-icon-picker}/icon-picker.d.ts +0 -0
- /package/dist/{packages/wje-img → wje-img}/img.d.ts +0 -0
- /package/dist/{packages/wje-img-comparer → wje-img-comparer}/img-comparer.d.ts +0 -0
- /package/dist/{packages/wje-img-comparer → wje-img-comparer}/img-comparer.element.d.ts +0 -0
- /package/dist/{packages/wje-img-comparer → wje-img-comparer}/service/service.d.ts +0 -0
- /package/dist/{packages/wje-infinite-scroll → wje-infinite-scroll}/infinite-scroll.d.ts +0 -0
- /package/dist/{packages/wje-input → wje-input}/input.d.ts +0 -0
- /package/dist/{packages/wje-input-file → wje-input-file}/input-file.d.ts +0 -0
- /package/dist/{packages/wje-input-file → wje-input-file}/input-file.element.d.ts +0 -0
- /package/dist/{packages/wje-item → wje-item}/item.d.ts +0 -0
- /package/dist/{packages/wje-kanban → wje-kanban}/kanban.d.ts +0 -0
- /package/dist/{packages/wje-label → wje-label}/label.d.ts +0 -0
- /package/dist/{packages/wje-label → wje-label}/label.element.d.ts +0 -0
- /package/dist/{packages/wje-level-indicator → wje-level-indicator}/level-indicator.d.ts +0 -0
- /package/dist/{packages/wje-list → wje-list}/list.d.ts +0 -0
- /package/dist/{packages/wje-main → wje-main}/main.d.ts +0 -0
- /package/dist/{packages/wje-main → wje-main}/main.element.d.ts +0 -0
- /package/dist/{packages/wje-masonry → wje-masonry}/masonry.d.ts +0 -0
- /package/dist/{packages/wje-masonry → wje-masonry}/masonry.element.d.ts +0 -0
- /package/dist/{packages/wje-masonry → wje-masonry}/service/service.d.ts +0 -0
- /package/dist/{packages/wje-menu → wje-menu}/menu.d.ts +0 -0
- /package/dist/{packages/wje-menu → wje-menu}/menu.element.d.ts +0 -0
- /package/dist/{packages/wje-menu-button → wje-menu-button}/menu-button.d.ts +0 -0
- /package/dist/{packages/wje-menu-button → wje-menu-button}/menu-button.element.d.ts +0 -0
- /package/dist/{packages/wje-menu-item → wje-menu-item}/menu-item.d.ts +0 -0
- /package/dist/{packages/wje-menu-label → wje-menu-label}/menu-label.d.ts +0 -0
- /package/dist/{packages/wje-menu-label → wje-menu-label}/menu-label.element.d.ts +0 -0
- /package/dist/{packages/wje-option → wje-option}/option.d.ts +0 -0
- /package/dist/{packages/wje-options → wje-options}/options.d.ts +0 -0
- /package/dist/{packages/wje-orgchart → wje-orgchart}/orgchart.d.ts +0 -0
- /package/dist/{packages/wje-orgchart-group → wje-orgchart-group}/orgchart-group.d.ts +0 -0
- /package/dist/{packages/wje-orgchart-group → wje-orgchart-group}/orgchart-group.element.d.ts +0 -0
- /package/dist/{packages/wje-orgchart-item → wje-orgchart-item}/orgchart-item.d.ts +0 -0
- /package/dist/{packages/wje-orgchart-item → wje-orgchart-item}/orgchart-item.element.d.ts +0 -0
- /package/dist/{packages/wje-pagination → wje-pagination}/pagination.d.ts +0 -0
- /package/dist/{packages/wje-pagination → wje-pagination}/pagination.element.d.ts +0 -0
- /package/dist/{packages/wje-pagination → wje-pagination}/service/service.d.ts +0 -0
- /package/dist/{packages/wje-panel → wje-panel}/panel.d.ts +0 -0
- /package/dist/{packages/wje-panel → wje-panel}/panel.element.d.ts +0 -0
- /package/dist/{packages/wje-popup → wje-popup}/popup.d.ts +0 -0
- /package/dist/{packages/wje-popup → wje-popup}/popup.element.d.ts +0 -0
- /package/dist/{packages/wje-progress-bar → wje-progress-bar}/progress-bar.d.ts +0 -0
- /package/dist/{packages/wje-qr-code → wje-qr-code}/qr-code.d.ts +0 -0
- /package/dist/{packages/wje-radio → wje-radio}/radio.d.ts +0 -0
- /package/dist/{packages/wje-radio-group → wje-radio-group}/radio-group.d.ts +0 -0
- /package/dist/{packages/wje-rate → wje-rate}/rate.d.ts +0 -0
- /package/dist/{packages/wje-relative-time → wje-relative-time}/relative-time.d.ts +0 -0
- /package/dist/{packages/wje-reorder → wje-reorder}/reorder.d.ts +0 -0
- /package/dist/{packages/wje-reorder-dropzone → wje-reorder-dropzone}/reorder-dropzone.d.ts +0 -0
- /package/dist/{packages/wje-reorder-dropzone → wje-reorder-dropzone}/reorder-dropzone.element.d.ts +0 -0
- /package/dist/{packages/wje-reorder-handle → wje-reorder-handle}/reorder-handle.d.ts +0 -0
- /package/dist/{packages/wje-reorder-item → wje-reorder-item}/reorder-item.d.ts +0 -0
- /package/dist/{packages/wje-reorder-item → wje-reorder-item}/reorder-item.element.d.ts +0 -0
- /package/dist/{packages/wje-route → wje-route}/route.d.ts +0 -0
- /package/dist/{packages/wje-route → wje-route}/route.element.d.ts +0 -0
- /package/dist/{packages/wje-router → wje-router}/router.d.ts +0 -0
- /package/dist/{packages/wje-router → wje-router}/router.element.d.ts +0 -0
- /package/dist/{packages/wje-router-link → wje-router-link}/router-link.d.ts +0 -0
- /package/dist/{packages/wje-router-link → wje-router-link}/router-link.element.d.ts +0 -0
- /package/dist/{packages/wje-router-outlet → wje-router-outlet}/router-outlet.d.ts +0 -0
- /package/dist/{packages/wje-router-outlet → wje-router-outlet}/router-outlet.element.d.ts +0 -0
- /package/dist/{packages/wje-row → wje-row}/row.d.ts +0 -0
- /package/dist/{packages/wje-row → wje-row}/row.element.d.ts +0 -0
- /package/dist/{packages/wje-select → wje-select}/select.d.ts +0 -0
- /package/dist/{packages/wje-slider → wje-slider}/slider.d.ts +0 -0
- /package/dist/{packages/wje-sliding-container → wje-sliding-container}/sliding-container.d.ts +0 -0
- /package/dist/{packages/wje-split-view → wje-split-view}/service/service.d.ts +0 -0
- /package/dist/{packages/wje-split-view → wje-split-view}/split-view.d.ts +0 -0
- /package/dist/{packages/wje-status → wje-status}/status.d.ts +0 -0
- /package/dist/{packages/wje-status → wje-status}/status.element.d.ts +0 -0
- /package/dist/{packages/wje-step → wje-step}/step.d.ts +0 -0
- /package/dist/{packages/wje-step → wje-step}/step.element.d.ts +0 -0
- /package/dist/{packages/wje-stepper → wje-stepper}/stepper.d.ts +0 -0
- /package/dist/{packages/wje-store → wje-store}/default-store-actions.d.ts +0 -0
- /package/dist/{packages/wje-store → wje-store}/pubsub.d.ts +0 -0
- /package/dist/{packages/wje-store → wje-store}/store.d.ts +0 -0
- /package/dist/{packages/wje-tab → wje-tab}/tab.d.ts +0 -0
- /package/dist/{packages/wje-tab-group → wje-tab-group}/tab-group.d.ts +0 -0
- /package/dist/{packages/wje-tab-panel → wje-tab-panel}/tab-panel.d.ts +0 -0
- /package/dist/{packages/wje-tab-panel → wje-tab-panel}/tab-panel.element.d.ts +0 -0
- /package/dist/{packages/wje-textarea → wje-textarea}/textarea.d.ts +0 -0
- /package/dist/{packages/wje-thumbnail → wje-thumbnail}/thumbnail.d.ts +0 -0
- /package/dist/{packages/wje-timeline → wje-timeline}/timeline.d.ts +0 -0
- /package/dist/{packages/wje-timeline-item → wje-timeline-item}/timeline-item.d.ts +0 -0
- /package/dist/{packages/wje-timeline-item → wje-timeline-item}/timeline-item.element.d.ts +0 -0
- /package/dist/{packages/wje-toast → wje-toast}/toast.d.ts +0 -0
- /package/dist/{packages/wje-toast → wje-toast}/toast.element.d.ts +0 -0
- /package/dist/{packages/wje-toggle → wje-toggle}/toggle.d.ts +0 -0
- /package/dist/{packages/wje-toolbar → wje-toolbar}/toolbar.d.ts +0 -0
- /package/dist/{packages/wje-toolbar-action → wje-toolbar-action}/toolbar-action.d.ts +0 -0
- /package/dist/{packages/wje-toolbar-action → wje-toolbar-action}/toolbar-action.element.d.ts +0 -0
- /package/dist/{packages/wje-tooltip → wje-tooltip}/tooltip.d.ts +0 -0
- /package/dist/{packages/wje-tree → wje-tree}/tree.d.ts +0 -0
- /package/dist/{packages/wje-tree-item → wje-tree-item}/tree-item.d.ts +0 -0
- /package/dist/{packages/wje-visually-hidden → wje-visually-hidden}/visually-hidden.d.ts +0 -0
- /package/dist/{packages/wje-visually-hidden → wje-visually-hidden}/visually-hidden.element.d.ts +0 -0
package/dist/wje-textarea.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wje-textarea.js","sources":["../packages/wje-textarea/textarea.element.js","../packages/wje-textarea/textarea.js"],"sourcesContent":["import { FormAssociatedElement } from '../internals/form-associated-element.js';\nimport { event } from '../utils/event.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * `Textarea` is a custom web component that represents a textarea input.\n * @summary This element represents a textarea input.\n * @documentation https://elements.webjet.sk/components/textarea\n * @status stable\n * @augments {FormAssociatedElement}\n * @csspart native - The native textarea wrapper.\n * @csspart input - The textarea input.\n * @csspart wrapper - The textarea wrapper.\n * @cssproperty [--wje-textarea-font-family=var(--wje-font-family)] - Specifies the font family used for the textarea. Accepts any valid CSS font-family value.\n * @cssproperty [--wje-textarea-background-color=var(--wje-background)] - Sets the background color of the textarea. Accepts any valid CSS color value.\n * @cssproperty [--wje-textarea-color=var(--wje-color)] - Defines the text color within the textarea. Accepts any valid CSS color value.\n * @cssproperty [--wje-textarea-color-invalid=var(--wje-color-danger)] - Changes the text color of the textarea when it is invalid. Useful for highlighting validation errors.\n * @cssproperty [--wje-textarea-border-width=1px] - Specifies the width of the textarea's border. Accepts any valid CSS length unit.\n * @cssproperty [--wje-textarea-border-style=solid] - Sets the style of the textarea's border. Accepts standard CSS border styles such as `solid`, `dashed`, or `dotted`.\n * @cssproperty [--wje-textarea-border-color=var(--wje-border-color)] - Defines the border color of the textarea. Accepts any valid CSS color value.\n * @cssproperty [--wje-textarea-border-color-focus=var(--wje-color-primary)] - Specifies the border color of the textarea when it is focused. Enhances the user experience by providing visual feedback.\n * @cssproperty [--wje-textarea-border-radius=4px] - Determines the border radius of the textarea, defining how rounded its corners are. Accepts any valid CSS length unit.\n * @cssproperty [--wje-textarea-margin-bottom=.5rem] - Sets the bottom margin of the textarea. Ensures spacing between the textarea and other elements.\n * @cssproperty [--wje-textarea-line-height=20px] - Specifies the line height of the text within the textarea. Helps control the vertical spacing of the text.\n * @cssproperty [--wje-textarea-padding=0.5rem] - Defines the padding inside the textarea. Controls the spacing between the content and the border.\n * @tag wje-textarea\n */\n\nexport default class Textarea extends FormAssociatedElement {\n /**\n * Creates an instance of Textarea.\n * @class\n */\n constructor() {\n super();\n\n this.invalid = false;\n this.pristine = true;\n }\n\n /**\n * Setter for the value attribute.\n * @param {string} value The value to set.\n */\n set value(value) {\n this.internals.setFormValue(value);\n\n if (this.input) this.input.value = value;\n\n this.pristine = false;\n this._value = value;\n }\n\n /**\n * Getter for the value attribute.\n * @returns {string} The value of the attribute.\n */\n get value() {\n return this.input?.value ?? this._value ?? '';\n }\n\n /**\n * Sets the `validateOnChange` property. If set to a truthy value, it adds the\n * `validate-on-change` attribute to the element. If set to a falsy value, it\n * removes the `validate-on-change` attribute from the element.\n * @param {boolean} value Determines whether to add or remove the\n * `validate-on-change` attribute. A truthy value adds the attribute, whereas a\n * falsy value removes it.\n */\n set validateOnChange(value) {\n if (value) {\n this.setAttribute('validate-on-change', '');\n } else {\n this.removeAttribute('validate-on-change');\n }\n }\n\n /**\n * Getter for the validateOnChange attribute.\n * @returns {boolean} Whether the attribute is present.\n */\n get validateOnChange() {\n return this.hasAttribute('validate-on-change');\n }\n\n set placeholder(value) {\n this.setAttribute('placeholder', value);\n }\n\n get placeholder() {\n return this.getAttribute('placeholder');\n }\n\n className = 'Textarea';\n\n /**\n * Returns the CSS styles for the component.\n * @static\n * @returns {CSSStyleSheet} The CSS stylesheet\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 // if some value was set via value setter then don't use default value\n if (this.pristine) {\n this.value = this.innerHTML;\n this.pristine = false;\n }\n }\n\n /**\n * Draws the component for the textarea.\n * @returns {DocumentFragment}\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('div');\n native.classList.add('native-textarea', this.variant || 'default');\n native.setAttribute('part', 'native');\n\n if (this.hasAttribute('invalid')) native.classList.add('has-error');\n\n let wrapper = document.createElement('div');\n wrapper.setAttribute('part', 'wrapper');\n wrapper.classList.add('wrapper');\n\n let inputWrapper = document.createElement('div');\n inputWrapper.classList.add('input-wrapper');\n\n let label = document.createElement('label');\n label.setAttribute('part', 'label');\n label.htmlFor = 'textarea';\n label.innerHTML = this.label || '';\n\n let input = document.createElement('textarea');\n input.id = 'textarea';\n input.name = this.name;\n input.disabled = this.hasAttribute('disabled');\n input.innerText = this.value;\n input.placeholder = this.placeholder || '';\n input.classList.add('form-control');\n input.setAttribute('part', 'input');\n input.setAttribute('rows', this.rows || 3);\n input.setAttribute('spellcheck', false);\n\n const attributes = Array.from(this.attributes).map((attr) => attr.name);\n\n attributes.forEach((attr) => {\n if (this.hasAttribute(attr)) {\n input.setAttribute(attr, this[attr] || '');\n }\n });\n\n let error = document.createElement('div');\n error.setAttribute('slot', 'error');\n\n let errorSlot = document.createElement('slot');\n errorSlot.setAttribute('name', 'error');\n\n if (this.resize === 'auto') input.addEventListener('input', this.setTextareaHeight);\n\n if (this.variant === 'standard') {\n if (this.label) native.appendChild(label);\n } else {\n inputWrapper.appendChild(label);\n }\n\n inputWrapper.appendChild(input);\n\n wrapper.appendChild(inputWrapper);\n\n native.appendChild(wrapper);\n native.append(errorSlot);\n\n this.append(error);\n\n fragment.appendChild(native);\n\n if (this.hasAttribute('counter')) {\n input.maxLength = this.maxLength || 1000;\n input.addEventListener('input', this.counterFn);\n\n let counter = document.createElement('div');\n counter.classList.add('counter');\n counter.innerText = `${input.value.length}/${input.maxLength}`;\n\n this.counterElement = counter;\n fragment.appendChild(counter);\n }\n\n this.native = native;\n this.labelElement = label;\n this.input = input;\n\n return fragment;\n }\n\n /**\n * Sets up the event listeners after the component is drawn.\n */\n afterDraw() {\n this.resizeObserver = new ResizeObserver(() => this.setTextareaHeight);\n\n if (!this.hasAttribute('disabled')) {\n event.addListener(this, 'click', 'wje-textarea:change');\n event.addListener(this, 'click', 'wje-textarea:input');\n }\n\n this.input.addEventListener('focus', (e) => {\n this.labelElement.classList.add('fade');\n this.native.classList.add('focused');\n });\n\n this.input.addEventListener('blur', (e) => {\n this.native.classList.remove('focused');\n if (!e.target.value) this.labelElement.classList.remove('fade');\n });\n\n this.input.addEventListener('input', (e) => {\n this.validate();\n\n if (this.validateOnChange) {\n this.pristine = false;\n this.propagateValidation();\n }\n\n if (this.invalid) {\n this.invalid = false;\n this.internals.setValidity({}, '');\n }\n\n this.input.classList.remove('pristine');\n this.labelElement.classList.add('fade');\n\n const clone = new e.constructor(e.type, e);\n this.dispatchEvent(clone);\n\n event.dispatchCustomEvent(this, 'wje-textarea:input', {\n value: this.input.value,\n });\n\n this.value = this.input.value;\n });\n\n this.addEventListener('invalid', (e) => {\n this.invalid = true;\n this.pristine = false;\n\n this.showInvalidMessage();\n\n if (this.customErrorDisplay) {\n e.preventDefault();\n }\n });\n\n this.validate();\n }\n\n componentCleanup() {\n this.resizeObserver?.unobserve(this.input);\n }\n\n /**\n * Disconnects the component.\n */\n beforeDisconnect() {\n this.resizeObserver?.unobserve(this.input);\n }\n\n /**\n * Sets the height of the textarea.\n */\n setTextareaHeight = () => {\n if (this.getAttribute('resize') === 'auto') {\n this.input.style.height = 'auto';\n this.input.style.height = this.input.scrollHeight + 'px';\n }\n };\n\n /**\n * Updates the counter for the textarea.\n * @param {Event} e The event object.\n */\n counterFn = (e) => {\n this.counterElement.innerText = e.target.value.length + '/' + this.input.maxLength;\n }\n}\n","import Textarea from './textarea.element.js';\n\nexport default Textarea;\n\nTextarea.define('wje-textarea', Textarea);\n"],"names":[],"mappings":";;;;;;AA4Be,MAAM,iBAAiB,sBAAsB;AAAA;AAAA;AAAA;AAAA;AAAA,EAKxD,cAAc;AACV,UAAO;AA2DX,qCAAY;AAoMZ;AAAA;AAAA;AAAA,6CAAoB,MAAM;AACtB,UAAI,KAAK,aAAa,QAAQ,MAAM,QAAQ;AACxC,aAAK,MAAM,MAAM,SAAS;AAC1B,aAAK,MAAM,MAAM,SAAS,KAAK,MAAM,eAAe;AAAA,MAChE;AAAA,IACK;AAMD;AAAA;AAAA;AAAA;AAAA,qCAAY,CAAC,MAAM;AACf,WAAK,eAAe,YAAY,EAAE,OAAO,MAAM,SAAS,MAAM,KAAK,MAAM;AAAA,IACjF;AA1QQ,SAAK,UAAU;AACf,SAAK,WAAW;AAAA,EACxB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,MAAM,OAAO;AACb,SAAK,UAAU,aAAa,KAAK;AAEjC,QAAI,KAAK,MAAO,MAAK,MAAM,QAAQ;AAEnC,SAAK,WAAW;AAChB,SAAK,SAAS;AAAA,EACtB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,QAAQ;;AACR,aAAO,UAAK,UA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AM;AAAA,MAClC,CAAa;AAED,WAAK,QAAQ,KAAK,MAAM;AAAA,IACpC,CAAS;AAED,SAAK,iBAAiB,WAAW,CAAC,MAAM;AACpC,WAAK,UAAU;AACf,WAAK,WAAW;AAEhB,WAAK,mBAAoB;AAEzB,UAAI,KAAK,oBAAoB;AACzB,UAAE,eAAgB;AAAA,MAClC;AAAA,IACA,CAAS;AAED,SAAK,SAAU;AAAA,EACvB;AAAA,EAEI,mBAAmB;;AACf,eAAK,mBAAL,mBAAqB,UAAU,KAAK;AAAA,EAC5C;AAAA;AAAA;AAAA;AAAA,EAKI,mBAAmB;;AACf,eAAK,mBAAL,mBAAqB,UAAU,KAAK;AAAA,EAC5C;AAmBA;AC3SA,SAAS,OAAO,gBAAgB,QAAQ;"}
|
|
1
|
+
{"version":3,"file":"wje-textarea.js","sources":["../packages/wje-textarea/textarea.element.js","../packages/wje-textarea/textarea.js"],"sourcesContent":["import { FormAssociatedElement } from '../internals/form-associated-element.js';\nimport { event } from '../utils/event.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * `Textarea` is a custom web component that represents a textarea input.\n * @summary This element represents a textarea input.\n * @documentation https://elements.webjet.sk/components/textarea\n * @status stable\n * @augments {FormAssociatedElement}\n * @csspart native - The native textarea wrapper.\n * @csspart input - The textarea input.\n * @csspart wrapper - The textarea wrapper.\n * @cssproperty [--wje-textarea-font-family=var(--wje-font-family)] - Specifies the font family used for the textarea. Accepts any valid CSS font-family value.\n * @cssproperty [--wje-textarea-background-color=var(--wje-background)] - Sets the background color of the textarea. Accepts any valid CSS color value.\n * @cssproperty [--wje-textarea-color=var(--wje-color)] - Defines the text color within the textarea. Accepts any valid CSS color value.\n * @cssproperty [--wje-textarea-color-invalid=var(--wje-color-danger)] - Changes the text color of the textarea when it is invalid. Useful for highlighting validation errors.\n * @cssproperty [--wje-textarea-border-width=1px] - Specifies the width of the textarea's border. Accepts any valid CSS length unit.\n * @cssproperty [--wje-textarea-border-style=solid] - Sets the style of the textarea's border. Accepts standard CSS border styles such as `solid`, `dashed`, or `dotted`.\n * @cssproperty [--wje-textarea-border-color=var(--wje-border-color)] - Defines the border color of the textarea. Accepts any valid CSS color value.\n * @cssproperty [--wje-textarea-border-color-focus=var(--wje-color-primary)] - Specifies the border color of the textarea when it is focused. Enhances the user experience by providing visual feedback.\n * @cssproperty [--wje-textarea-border-radius=4px] - Determines the border radius of the textarea, defining how rounded its corners are. Accepts any valid CSS length unit.\n * @cssproperty [--wje-textarea-margin-bottom=.5rem] - Sets the bottom margin of the textarea. Ensures spacing between the textarea and other elements.\n * @cssproperty [--wje-textarea-line-height=20px] - Specifies the line height of the text within the textarea. Helps control the vertical spacing of the text.\n * @cssproperty [--wje-textarea-padding=0.5rem] - Defines the padding inside the textarea. Controls the spacing between the content and the border.\n * @tag wje-textarea\n */\n\nexport default class Textarea extends FormAssociatedElement {\n static _instanceId = 0;\n /**\n * Creates an instance of Textarea.\n * @class\n */\n constructor() {\n super();\n\n this.invalid = false;\n this.pristine = true;\n this._instanceId = ++Textarea._instanceId;\n }\n\n /**\n * Setter for the value attribute.\n * @param {string} value The value to set.\n */\n set value(value) {\n this.internals.setFormValue(value);\n\n if (this.input) this.input.value = value;\n\n this.pristine = false;\n this._value = value;\n this.syncAria();\n }\n\n /**\n * Getter for the value attribute.\n * @returns {string} The value of the attribute.\n */\n get value() {\n return this.input?.value ?? this._value ?? '';\n }\n\n /**\n * Sets the label attribute of the element.\n * @param {string} value The value to set as the label attribute.\n */\n set label(value) {\n if (value === null || value === undefined) {\n this.removeAttribute('label');\n } else {\n this.setAttribute('label', value);\n }\n }\n\n /**\n * Retrieves the value of the 'label' attribute if it exists.\n * If the 'label' attribute is not set, it returns false.\n * @returns {string|boolean} The value of the 'label' attribute as a string, or false if the attribute is not set.\n */\n get label() {\n return this.getAttribute('label') || false;\n }\n\n /**\n * Sets the `validateOnChange` property. If set to a truthy value, it adds the\n * `validate-on-change` attribute to the element. If set to a falsy value, it\n * removes the `validate-on-change` attribute from the element.\n * @param {boolean} value Determines whether to add or remove the\n * `validate-on-change` attribute. A truthy value adds the attribute, whereas a\n * falsy value removes it.\n */\n set validateOnChange(value) {\n if (value) {\n this.setAttribute('validate-on-change', '');\n } else {\n this.removeAttribute('validate-on-change');\n }\n }\n\n /**\n * Getter for the validateOnChange attribute.\n * @returns {boolean} Whether the attribute is present.\n */\n get validateOnChange() {\n return this.hasAttribute('validate-on-change');\n }\n\n set placeholder(value) {\n this.setAttribute('placeholder', value);\n }\n\n get placeholder() {\n return this.getAttribute('placeholder');\n }\n\n className = 'Textarea';\n\n /**\n * Returns the CSS styles for the component.\n * @static\n * @returns {CSSStyleSheet} The CSS stylesheet\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 ['value', 'name', 'disabled', 'placeholder', 'label', 'required', 'readonly', 'invalid', 'rows'];\n }\n\n /**\n * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n\n // if some value was set via value setter then don't use default value\n if (this.pristine) {\n const attrValue = this.getAttribute('value');\n this.value = attrValue !== null ? attrValue : this.innerHTML;\n this.pristine = false;\n }\n this.syncAria();\n }\n\n attributeChangedCallback(name, oldValue, newValue) {\n if (oldValue === newValue) return;\n\n if (name === 'label') {\n this.refresh();\n return;\n }\n\n if (!this.input) {\n this.syncAria();\n return;\n }\n\n if (name === 'value') {\n this._value = newValue ?? '';\n this.input.value = this.value;\n this.internals.setFormValue(this.value);\n } else if (name === 'name') {\n this.input.name = this.name;\n } else if (name === 'disabled') {\n this.input.disabled = this.hasAttribute('disabled');\n } else if (name === 'required') {\n this.input.required = this.required;\n } else if (name === 'readonly') {\n this.input.readOnly = this.hasAttribute('readonly');\n } else if (name === 'placeholder') {\n this.input.placeholder = this.placeholder || '';\n } else if (name === 'rows') {\n this.input.rows = Number(newValue || 3);\n }\n\n this.syncAria();\n }\n\n /**\n * Draws the component for the textarea.\n * @returns {DocumentFragment}\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('div');\n native.classList.add('native-textarea', this.variant || 'default');\n native.setAttribute('part', 'native');\n\n if (this.hasAttribute('invalid')) native.classList.add('has-error');\n\n let wrapper = document.createElement('div');\n wrapper.setAttribute('part', 'wrapper');\n wrapper.classList.add('wrapper');\n\n let inputWrapper = document.createElement('div');\n inputWrapper.classList.add('input-wrapper');\n\n let label = document.createElement('label');\n label.setAttribute('part', 'label');\n label.htmlFor = 'textarea';\n label.innerHTML = this.label || '';\n\n let input = document.createElement('textarea');\n input.id = 'textarea';\n input.name = this.name;\n input.disabled = this.hasAttribute('disabled');\n input.innerText = this.value;\n input.placeholder = this.placeholder || '';\n input.classList.add('form-control');\n input.setAttribute('part', 'input');\n input.rows = Number(this.getAttribute('rows') || 3);\n input.setAttribute('spellcheck', false);\n\n const attributes = Array.from(this.attributes).map((attr) => attr.name);\n\n attributes.forEach((attr) => {\n if (this.hasAttribute(attr)) {\n input.setAttribute(attr, this[attr] || '');\n }\n });\n\n let error = document.createElement('div');\n error.setAttribute('slot', 'error');\n\n let errorSlot = document.createElement('slot');\n errorSlot.setAttribute('name', 'error');\n this._ariaErrorId = this.id ? `${this.id}-error` : `wje-textarea-${this._instanceId}-error`;\n errorSlot.id = this._ariaErrorId;\n\n if (this.getAttribute('resize') === 'auto') input.addEventListener('input', this.setTextareaHeight);\n\n if (this.label) {\n if (this.variant === 'standard') {\n native.appendChild(label);\n } else {\n inputWrapper.appendChild(label);\n }\n }\n\n inputWrapper.appendChild(input);\n\n wrapper.appendChild(inputWrapper);\n\n native.appendChild(wrapper);\n native.append(errorSlot);\n\n this.append(error);\n\n fragment.appendChild(native);\n\n if (this.hasAttribute('counter')) {\n input.maxLength = this.maxLength || 1000;\n input.addEventListener('input', this.counterFn);\n\n let counter = document.createElement('div');\n counter.classList.add('counter');\n counter.innerText = `${input.value.length}/${input.maxLength}`;\n\n this.counterElement = counter;\n fragment.appendChild(counter);\n }\n\n this.native = native;\n this.labelElement = label;\n this.input = input;\n\n this.syncAria();\n return fragment;\n }\n\n /**\n * Sets up the event listeners after the component is drawn.\n */\n afterDraw() {\n if (this.getAttribute('resize') === 'auto' && typeof ResizeObserver === 'function') {\n this.resizeObserver = new ResizeObserver(() => this.setTextareaHeight());\n this.resizeObserver.observe(this.input);\n }\n\n if (!this.hasAttribute('disabled')) {\n event.addListener(this, 'click', 'wje-textarea:change');\n event.addListener(this, 'click', 'wje-textarea:input');\n }\n\n this.input.addEventListener('focus', (e) => {\n this.labelElement.classList.add('fade');\n this.native.classList.add('focused');\n });\n\n this.input.addEventListener('blur', (e) => {\n this.native.classList.remove('focused');\n if (!e.target.value) this.labelElement.classList.remove('fade');\n });\n\n this.input.addEventListener('input', (e) => {\n this.validate();\n\n if (this.validateOnChange) {\n this.pristine = false;\n this.propagateValidation();\n }\n\n if (this.invalid) {\n this.invalid = false;\n this.internals.setValidity({}, '');\n }\n\n this.input.classList.remove('pristine');\n this.labelElement.classList.add('fade');\n\n const clone = new e.constructor(e.type, e);\n this.dispatchEvent(clone);\n\n event.dispatchCustomEvent(this, 'wje-textarea:input', {\n value: this.input.value,\n });\n\n this.value = this.input.value;\n });\n\n this.addEventListener('invalid', (e) => {\n this.invalid = true;\n this.pristine = false;\n\n this.showInvalidMessage();\n\n if (this.customErrorDisplay) {\n e.preventDefault();\n }\n });\n\n this.validate();\n\n this.syncAria();\n }\n\n /**\n * Syncs ARIA attributes on the host element.\n */\n syncAria() {\n const requiredInvalid = this.required && !this.value;\n const invalid = this.invalid || requiredInvalid;\n const label = this.label && this.label !== false ? this.label.trim() : '';\n this.setAriaState({\n role: 'textbox',\n disabled: this.disabled,\n required: this.required,\n readonly: this.hasAttribute('readonly'),\n invalid,\n describedBy: this._ariaErrorId,\n ...(label ? { label } : {}),\n });\n }\n\n componentCleanup() {\n this.resizeObserver?.unobserve(this.input);\n this.resizeObserver?.disconnect();\n }\n\n /**\n * Disconnects the component.\n */\n beforeDisconnect() {\n this.resizeObserver?.unobserve(this.input);\n this.resizeObserver?.disconnect();\n }\n\n /**\n * Sets the height of the textarea.\n */\n setTextareaHeight = () => {\n if (this.getAttribute('resize') === 'auto') {\n this.input.style.height = 'auto';\n this.input.style.height = this.input.scrollHeight + 'px';\n }\n };\n\n /**\n * Updates the counter for the textarea.\n * @param {Event} e The event object.\n */\n counterFn = (e) => {\n this.counterElement.innerText = e.target.value.length + '/' + this.input.maxLength;\n }\n}\n","import Textarea from './textarea.element.js';\n\nexport default Textarea;\n\nTextarea.define('wje-textarea', Textarea);\n"],"names":[],"mappings":";;;;;;AA4Be,MAAM,YAAN,MAAM,kBAAiB,sBAAsB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMxD,cAAc;AACV,UAAO;AAkFX,qCAAY;AAsQZ;AAAA;AAAA;AAAA,6CAAoB,MAAM;AACtB,UAAI,KAAK,aAAa,QAAQ,MAAM,QAAQ;AACxC,aAAK,MAAM,MAAM,SAAS;AAC1B,aAAK,MAAM,MAAM,SAAS,KAAK,MAAM,eAAe;AAAA,MAChE;AAAA,IACK;AAMD;AAAA;AAAA;AAAA;AAAA,qCAAY,CAAC,MAAM;AACf,WAAK,eAAe,YAAY,EAAE,OAAO,MAAM,SAAS,MAAM,KAAK,MAAM;AAAA,IACjF;AAnWQ,SAAK,UAAU;AACf,SAAK,WAAW;AAChB,SAAK,cAAc,EAAE,UAAS;AAAA,EACtC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,MAAM,OAAO;AACb,SAAK,UAAU,aAAa,KAAK;AAEjC,QAAI,KAAK,MAAO,MAAK,MAAM,QAAQ;AAEnC,SAAK,WAAW;AAChB,SAAK,SAAS;AACd,SAAK,SAAU;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,QAAQ;;AACR,aAAO,UAAK,UAAL,mBAAY,UAAS,KAAK,UAAU;AAAA,EACnD;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,MAA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|
|
36
36
|
setupAttributes() {
|
|
37
37
|
this.isShadowRoot = "open";
|
|
38
|
+
this.syncAria();
|
|
38
39
|
}
|
|
39
40
|
/**
|
|
40
41
|
* Draws the component for the thumbnail.
|
|
@@ -46,6 +47,24 @@ class Thumbnail extends WJElement {
|
|
|
46
47
|
fragment.appendChild(element);
|
|
47
48
|
return fragment;
|
|
48
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Sync ARIA attributes on host.
|
|
52
|
+
*/
|
|
53
|
+
syncAria() {
|
|
54
|
+
const ariaLabel = this.getAttribute("aria-label");
|
|
55
|
+
const label = this.getAttribute("label");
|
|
56
|
+
if (ariaLabel || label) {
|
|
57
|
+
if (!this.hasAttribute("role")) {
|
|
58
|
+
this.setAttribute("role", "img");
|
|
59
|
+
}
|
|
60
|
+
if (!ariaLabel && label) {
|
|
61
|
+
this.setAriaState({ label });
|
|
62
|
+
}
|
|
63
|
+
this.removeAttribute("aria-hidden");
|
|
64
|
+
} else {
|
|
65
|
+
this.setAttribute("aria-hidden", "true");
|
|
66
|
+
}
|
|
67
|
+
}
|
|
49
68
|
}
|
|
50
69
|
Thumbnail.define("wje-thumbnail", Thumbnail);
|
|
51
70
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wje-thumbnail.js","sources":["../packages/wje-thumbnail/thumbnail.element.js","../packages/wje-thumbnail/thumbnail.js"],"sourcesContent":["import { default as WJElement } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary Thumbnail class\n * @documentation https://elements.webjet.sk/components/thumbnail\n * @status stable\n * @augments WJElement\n * @slot thumbnail-slot - The slot for the thumbnail content.\n * @cssproperty [--wje-thumbnail-width=48px] - Defines the width of the thumbnail. Accepts any valid CSS length unit such as `px`, `rem`, or `%`.\n * @cssproperty [--wje-thumbnail-height=48px] - Specifies the height of the thumbnail. Accepts any valid CSS length unit.\n * @cssproperty [--wje-thumbnail-border-radius=var(--wje-border-radius-medium)] - Sets the border radius of the thumbnail, determining how rounded its corners appear. Accepts any valid CSS length unit or CSS variable.\n * @tag thumbnail-element\n */\n\nexport default class Thumbnail extends WJElement {\n /**\n * Creates an instance of Thumbnail.\n */\n constructor() {\n super();\n }\n\n /**\n * The class name for the component\n */\n className = 'Thumbnail';\n\n /**\n * Returns the CSS stylesheet for the component.\n * @static\n * @returns {CSSStyleSheet} The CSS stylesheet\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Returns the list of observed attributes.\n * @static\n * @returns {Array} An empty array\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 for the thumbnail.\n * @returns {object} Document fragment\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let element = document.createElement('slot');\n\n fragment.appendChild(element);\n\n return fragment;\n }\n}\n","import Thumbnail from './thumbnail.element.js';\n\nexport default Thumbnail;\n\nThumbnail.define('wje-thumbnail', Thumbnail);\n"],"names":[],"mappings":";;;;;AAee,MAAM,kBAAkB,UAAU;AAAA;AAAA;AAAA;AAAA,EAI7C,cAAc;AACV,UAAO;AAMX;AAAA;AAAA;AAAA,qCAAY;AAAA,EALhB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYI,WAAW,gBAAgB;AACvB,WAAO;AAAA,EACf;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOI,WAAW,qBAAqB;AAC5B,WAAO,CAAE;AAAA,EACjB;AAAA;AAAA;AAAA;AAAA,EAKI,kBAAkB;AACd,SAAK,eAAe;AAAA,
|
|
1
|
+
{"version":3,"file":"wje-thumbnail.js","sources":["../packages/wje-thumbnail/thumbnail.element.js","../packages/wje-thumbnail/thumbnail.js"],"sourcesContent":["import { default as WJElement } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary Thumbnail class\n * @documentation https://elements.webjet.sk/components/thumbnail\n * @status stable\n * @augments WJElement\n * @slot thumbnail-slot - The slot for the thumbnail content.\n * @cssproperty [--wje-thumbnail-width=48px] - Defines the width of the thumbnail. Accepts any valid CSS length unit such as `px`, `rem`, or `%`.\n * @cssproperty [--wje-thumbnail-height=48px] - Specifies the height of the thumbnail. Accepts any valid CSS length unit.\n * @cssproperty [--wje-thumbnail-border-radius=var(--wje-border-radius-medium)] - Sets the border radius of the thumbnail, determining how rounded its corners appear. Accepts any valid CSS length unit or CSS variable.\n * @tag thumbnail-element\n */\n\nexport default class Thumbnail extends WJElement {\n /**\n * Creates an instance of Thumbnail.\n */\n constructor() {\n super();\n }\n\n /**\n * The class name for the component\n */\n className = 'Thumbnail';\n\n /**\n * Returns the CSS stylesheet for the component.\n * @static\n * @returns {CSSStyleSheet} The CSS stylesheet\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Returns the list of observed attributes.\n * @static\n * @returns {Array} An empty array\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 * Draws the component for the thumbnail.\n * @returns {object} Document fragment\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let element = document.createElement('slot');\n\n fragment.appendChild(element);\n\n return fragment;\n }\n\n /**\n * Sync ARIA attributes on host.\n */\n syncAria() {\n const ariaLabel = this.getAttribute('aria-label');\n const label = this.getAttribute('label');\n\n if (ariaLabel || label) {\n if (!this.hasAttribute('role')) {\n this.setAttribute('role', 'img');\n }\n if (!ariaLabel && label) {\n this.setAriaState({ label });\n }\n this.removeAttribute('aria-hidden');\n } else {\n this.setAttribute('aria-hidden', 'true');\n }\n }\n}\n","import Thumbnail from './thumbnail.element.js';\n\nexport default Thumbnail;\n\nThumbnail.define('wje-thumbnail', Thumbnail);\n"],"names":[],"mappings":";;;;;AAee,MAAM,kBAAkB,UAAU;AAAA;AAAA;AAAA;AAAA,EAI7C,cAAc;AACV,UAAO;AAMX;AAAA;AAAA;AAAA,qCAAY;AAAA,EALhB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYI,WAAW,gBAAgB;AACvB,WAAO;AAAA,EACf;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOI,WAAW,qBAAqB;AAC5B,WAAO,CAAE;AAAA,EACjB;AAAA;AAAA;AAAA;AAAA,EAKI,kBAAkB;AACd,SAAK,eAAe;AACpB,SAAK,SAAU;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,OAAO;AACH,QAAI,WAAW,SAAS,uBAAwB;AAEhD,QAAI,UAAU,SAAS,cAAc,MAAM;AAE3C,aAAS,YAAY,OAAO;AAE5B,WAAO;AAAA,EACf;AAAA;AAAA;AAAA;AAAA,EAKI,WAAW;AACP,UAAM,YAAY,KAAK,aAAa,YAAY;AAChD,UAAM,QAAQ,KAAK,aAAa,OAAO;AAEvC,QAAI,aAAa,OAAO;AACpB,UAAI,CAAC,KAAK,aAAa,MAAM,GAAG;AAC5B,aAAK,aAAa,QAAQ,KAAK;AAAA,MAC/C;AACY,UAAI,CAAC,aAAa,OAAO;AACrB,aAAK,aAAa,EAAE,OAAO;AAAA,MAC3C;AACY,WAAK,gBAAgB,aAAa;AAAA,IAC9C,OAAe;AACH,WAAK,aAAa,eAAe,MAAM;AAAA,IACnD;AAAA,EACA;AACA;ACnFA,UAAU,OAAO,iBAAiB,SAAS;"}
|
package/dist/wje-toast.js
CHANGED
|
@@ -193,6 +193,9 @@ class Toast extends WJElement {
|
|
|
193
193
|
*/
|
|
194
194
|
setupAttributes() {
|
|
195
195
|
this.isShadowRoot = "open";
|
|
196
|
+
this.setAriaState({
|
|
197
|
+
role: "status"
|
|
198
|
+
});
|
|
196
199
|
}
|
|
197
200
|
/**
|
|
198
201
|
* Draw method for the toast notification.
|
|
@@ -223,6 +226,7 @@ class Toast extends WJElement {
|
|
|
223
226
|
closeBtn.setAttribute("color", this.color);
|
|
224
227
|
closeBtn.setAttribute("size", "small");
|
|
225
228
|
closeBtn.classList.add("close");
|
|
229
|
+
closeBtn.setAttribute("aria-label", "Close");
|
|
226
230
|
let countdownEl = document.createElement("div");
|
|
227
231
|
countdownEl.classList.add("countdown");
|
|
228
232
|
let countdownBar = document.createElement("div");
|
package/dist/wje-toast.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wje-toast.js","sources":["../packages/wje-toast/toast.element.js","../packages/wje-toast/toast.js"],"sourcesContent":["import { default as WJElement, WjElementUtils, event } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * `Toast` is a custom web component that represents a toast notification.\n * @summary This element represents a toast notification.\n * @documentation https://elements.webjet.sk/components/toast\n * @status stable\n * @augments {WJElement}\n * @csspart native - The native part\n * @cssproperty {string} headline - Specifies the headline text of the toast. Represents the main title or heading displayed in the toast.\n * @cssproperty {boolean} open - Indicates whether the toast is currently open (visible). A value of `true` shows the toast, while `false` hides it.\n * @cssproperty {number} duration - Determines the duration (in milliseconds) for which the toast is displayed. After this time, the toast will automatically close unless it is manually closed.\n * @cssproperty {boolean} closable - Specifies whether the toast can be manually closed by the user. If `true`, the toast will include a close button or mechanism.\n * @cssproperty {string} color - Defines the color of the toast. Accepts any valid CSS color value such as `hex`, `RGB`, or named colors.\n * @cssproperty {boolean} countdown - Indicates whether a countdown is displayed in the toast. When `true`, a visual countdown timer is shown to indicate the remaining time before the toast closes.\n * @slot - The content of the toast.\n * @slot media - The media of the toast.\n * // @fires wje-toast:after-show - Fired after the toast is shown.\n * // @fires wje-toast:after-hide - Fired after the toast is hidden.\n */\n\nexport default class Toast extends WJElement {\n /**\n * Creates an instance of Toast.\n */\n constructor() {\n super();\n\n this.toastStack = Object.assign(document.createElement('div'), { className: 'wje-toast-stack' });\n }\n\n /**\n * Set headline value of the toast.\n * @param value\n */\n set headline(value) {\n this.setAttribute('headline', value);\n }\n\n /**\n * Get headline value of the toast.\n * @returns {string}\n */\n get headline() {\n return this.getAttribute('headline');\n }\n\n /**\n * Set open value of the toast.\n * @param value\n */\n set open(value) {\n this.removeAttribute('open');\n\n if (WjElementUtils.stringToBoolean(value)) this.setAttribute('open', value);\n }\n\n /**\n * Get open value of the toast.\n * @returns {boolean}\n */\n get open() {\n return this.hasAttribute('open');\n }\n\n /**\n * Set duration value of the toast.\n * @param value\n */\n set duration(value) {\n this.setAttribute('duration', value);\n }\n\n /**\n * Get duration value of the toast.\n * @returns {number}\n */\n get duration() {\n return +this.getAttribute('duration');\n }\n\n /**\n * Set closable value of the toast.\n * @param value\n */\n set closable(value) {\n this.setAttribute('closable', value || '');\n }\n\n /**\n * Get closable value of the toast.\n * @returns {boolean}\n */\n get closable() {\n return this.hasAttribute('closable');\n }\n\n /**\n * Set color value of the toast.\n * @param value\n */\n set color(value) {\n this.setAttribute('color', value);\n }\n\n /**\n * Get color value of the toast.\n * @returns {string}\n */\n get color() {\n return this.getAttribute('color');\n }\n\n /**\n * Set countdown value of the toast.\n * @param value\n */\n set countdown(value) {\n if (value) this.setAttribute('countdown', value);\n }\n\n /**\n * Get countdown value of the toast.\n * @returns {boolean}\n */\n get countdown() {\n return this.hasAttribute('countdown');\n }\n\n /**\n * Set icon value of the toast.\n * @param value\n */\n set icon(value) {\n this.setAttribute('icon', value);\n }\n\n /**\n * Get icon value of the toast.\n * @returns {string}\n */\n get icon() {\n return this.getAttribute('icon');\n }\n\n /**\n * The class name for the component.\n * @type {string}\n */\n className = 'Toast';\n\n /**\n * Returns the CSS stylesheet for the component.\n * @static\n * @returns {CSSStyleSheet} The CSS stylesheet\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Setup attributes for the Button element.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Draw method for the toast notification.\n * @returns {object} Document fragment\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('div');\n native.setAttribute('part', 'native');\n native.classList.add('native-toast');\n\n let mediaSlot = document.createElement('slot');\n mediaSlot.setAttribute('name', 'media');\n mediaSlot.classList.add('media');\n mediaSlot.addEventListener('slotchange', () => {\n if (WjElementUtils.hasSlotContent(this.context, 'media')) {\n mediaSlot.parentElement.classList.add('has-media');\n } else {\n mediaSlot.parentElement.classList.remove('has-media');\n }\n });\n\n let content = document.createElement('div');\n content.classList.add('content');\n content.innerHTML = `<div class=\"headline\">${this.headline}</div><div class=\"message\"><slot></slot></div>`;\n\n let iconX = document.createElement('wje-icon');\n iconX.setAttribute('name', 'x');\n\n let closeBtn = document.createElement('wje-button');\n closeBtn.setAttribute('fill', 'link');\n closeBtn.setAttribute('color', this.color);\n closeBtn.setAttribute('size', 'small');\n closeBtn.classList.add('close');\n\n let countdownEl = document.createElement('div');\n countdownEl.classList.add('countdown');\n\n let countdownBar = document.createElement('div');\n countdownBar.classList.add('countdown-bar');\n\n closeBtn.appendChild(iconX);\n countdownEl.appendChild(countdownBar);\n\n if (this.hasAttribute('icon') && this.icon) {\n let icon = document.createElement('wje-icon');\n icon.setAttribute('name', this.icon);\n icon.setAttribute('color', this.color);\n icon.setAttribute('slot', 'media');\n icon.setAttribute('part', 'icon');\n\n this.appendChild(icon);\n }\n\n native.appendChild(mediaSlot);\n native.appendChild(content);\n\n if (this.closable) native.appendChild(closeBtn);\n\n if (this.hasAttribute('countdown')) native.appendChild(countdownEl);\n\n fragment.appendChild(native);\n\n this.closeBtn = closeBtn;\n this.countdownBar = countdownBar;\n\n return fragment;\n }\n\n /**\n * After draw method for the toast notification.\n */\n afterDraw() {\n this.closeBtn.addEventListener('wje-button:click', this.hide);\n this.addEventListener('mouseenter', this.pause);\n this.addEventListener('mouseleave', this.resume);\n\n if (this.hasAttribute('countdown')) {\n const startWidth = '100%';\n const endWidth = '0';\n\n this.countdownAnimation = this.countdownBar.animate([{ width: startWidth }, { width: endWidth }], {\n duration: this.duration,\n easing: 'linear',\n });\n }\n\n if (this.duration > 0) {\n this.remainingTime = this.duration;\n this.startTimer();\n }\n }\n\n /**\n * Before disconnect method\n * This method is called before the element is disconnected from the document.\n */\n beforeDisconnect() {\n this.closeBtn?.removeEventListener('wje-button:click', this.hide);\n this.removeEventListener('wje-toast:after-hide', this.removeChildAndStack);\n this.removeEventListener('mouseenter', this.pause);\n this.removeEventListener('mouseleave', this.resume);\n\n clearTimeout(this.timeoutID);\n }\n\n /**\n * Starts the timer.\n * This method sets the `startTime` property to the current time and sets\n * the `timeoutID` property to the ID of the timeout. The method also\n * dispatches the `wje-toast:after-hide` custom event when the timeout\n * expires.\n */\n startTimer() {\n this.startTime = Date.now();\n if (this.timeoutID) {\n clearTimeout(this.timeoutID);\n }\n this.timeoutID = window.setTimeout(() => {\n this.hide();\n }, this.remainingTime);\n }\n\n /**\n * Stops the timer.\n * This method clears the timeout and calculates the remaining time.\n * The method is called when the toast notification is paused.\n */\n stopTimer() {\n if (this.timeoutID) {\n window.clearTimeout(this.timeoutID);\n }\n const elapsedTime = Date.now() - this.startTime;\n this.remainingTime -= elapsedTime;\n }\n\n /**\n * Resumes the timer.\n * This method resumes the timer if the remaining time is greater\n * than zero. The method is called when the toast notification is resumed.\n */\n resumeTimer() {\n if (this.remainingTime > 0) {\n this.startTimer();\n }\n }\n\n /**\n * Asynchronously shows the toast notification.\n * This method sets the `open` property to `true` and dispatches the\n * `wje-toast:after-show` custom event. If the toast is already open,\n * the method returns `undefined`.\n */\n show = () => {\n if (this.open) {\n return;\n }\n\n this.open = true;\n event.dispatchCustomEvent(this, 'wje-toast:after-show');\n };\n\n /**\n * Asynchronously hides the toast notification.\n * This method sets the `open` property to `false` and dispatches the\n * `wje-toast:after-hide` custom event. If the toast is already hidden,\n * the method returns `undefined`.\n */\n hide = () => {\n if (!this.open) {\n return;\n }\n\n this.open = false;\n event.dispatchCustomEvent(this, 'wje-toast:after-hide');\n };\n\n /**\n * Pauses the countdown animation and stops the timer.\n */\n pause = () => {\n this.countdownAnimation?.pause();\n this.stopTimer();\n };\n\n /**\n * Resumes the countdown animation and resumes the timer.\n */\n resume = () => {\n this.countdownAnimation?.play();\n this.resumeTimer();\n };\n\n /**\n * Removes the toast notification and the toast stack.\n *\n * This method removes the toast notification from the toast stack and\n * removes the toast stack from the document body if the toast stack is\n * empty.\n */\n removeChildAndStack() {\n this.toastStack.removeChild(this);\n\n if (this.toastStack.querySelector('wje-toast') === null) {\n this.toastStack.remove();\n }\n }\n\n /**\n * Asynchronously starts the toast notification.\n * This method appends the toast notification to the document body and\n * shows the toast notification. The method returns a promise that\n * resolves when the toast notification is shown.\n * @returns {Promise<unknown>}\n */\n start = () => {\n return new Promise((resolve) => {\n let stack = document.body.querySelector('.wje-toast-stack');\n if (stack) {\n this.toastStack = stack;\n }\n\n if (this.toastStack.parentElement === null) {\n document.body.append(this.toastStack);\n }\n\n this.toastStack.append(this);\n\n this.show();\n\n this.addEventListener('wje-toast:after-hide', this.removeChildAndStack);\n });\n };\n}\n","import Toast from './toast.element.js';\n\nexport default Toast;\n\nToast.define('wje-toast', Toast);\n"],"names":[],"mappings":";;;;;;;AAsBe,MAAM,cAAc,UAAU;AAAA;AAAA;AAAA;AAAA,EAIzC,cAAc;AACV,UAAO;AA2HX;AAAA;AAAA;AAAA;AAAA,qCAAY;AA2KZ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gCAAO,MAAM;AACT,UAAI,KAAK,MAAM;AACX;AAAA,MACZ;AAEQ,WAAK,OAAO;AACZ,YAAM,oBAAoB,MAAM,sBAAsB;AAAA,IACzD;AAQD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gCAAO,MAAM;AACT,UAAI,CAAC,KAAK,MAAM;AACZ;AAAA,MACZ;AAEQ,WAAK,OAAO;AACZ,YAAM,oBAAoB,MAAM,sBAAsB;AAAA,IACzD;AAKD;AAAA;AAAA;AAAA,iCAAQ,MAAM;;AACV,iBAAK,uBAAL,mBAAyB;AACzB,WAAK,UAAW;AAAA,IACnB;AAKD;AAAA;AAAA;AAAA,kCAAS,MAAM;;AACX,iBAAK,uBAAL,mBAAyB;AACzB,WAAK,YAAa;AAAA,IACrB;AAwBD;AAA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WAAW,YAAY,IAAI;AAEhC,QAAI,KAAK,WAAW,cAAc,WAAW,MAAM,MAAM;AACrD,WAAK,WAAW,OAAQ;AAAA,IACpC;AAAA,EACA;AA2BA;AC7YA,MAAM,OAAO,aAAa,KAAK;"}
|
|
1
|
+
{"version":3,"file":"wje-toast.js","sources":["../packages/wje-toast/toast.element.js","../packages/wje-toast/toast.js"],"sourcesContent":["import { default as WJElement, WjElementUtils, event } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * `Toast` is a custom web component that represents a toast notification.\n * @summary This element represents a toast notification.\n * @documentation https://elements.webjet.sk/components/toast\n * @status stable\n * @augments {WJElement}\n * @csspart native - The native part\n * @cssproperty {string} headline - Specifies the headline text of the toast. Represents the main title or heading displayed in the toast.\n * @cssproperty {boolean} open - Indicates whether the toast is currently open (visible). A value of `true` shows the toast, while `false` hides it.\n * @cssproperty {number} duration - Determines the duration (in milliseconds) for which the toast is displayed. After this time, the toast will automatically close unless it is manually closed.\n * @cssproperty {boolean} closable - Specifies whether the toast can be manually closed by the user. If `true`, the toast will include a close button or mechanism.\n * @cssproperty {string} color - Defines the color of the toast. Accepts any valid CSS color value such as `hex`, `RGB`, or named colors.\n * @cssproperty {boolean} countdown - Indicates whether a countdown is displayed in the toast. When `true`, a visual countdown timer is shown to indicate the remaining time before the toast closes.\n * @slot - The content of the toast.\n * @slot media - The media of the toast.\n * // @fires wje-toast:after-show - Fired after the toast is shown.\n * // @fires wje-toast:after-hide - Fired after the toast is hidden.\n */\n\nexport default class Toast extends WJElement {\n /**\n * Creates an instance of Toast.\n */\n constructor() {\n super();\n\n this.toastStack = Object.assign(document.createElement('div'), { className: 'wje-toast-stack' });\n }\n\n /**\n * Set headline value of the toast.\n * @param value\n */\n set headline(value) {\n this.setAttribute('headline', value);\n }\n\n /**\n * Get headline value of the toast.\n * @returns {string}\n */\n get headline() {\n return this.getAttribute('headline');\n }\n\n /**\n * Set open value of the toast.\n * @param value\n */\n set open(value) {\n this.removeAttribute('open');\n\n if (WjElementUtils.stringToBoolean(value)) this.setAttribute('open', value);\n }\n\n /**\n * Get open value of the toast.\n * @returns {boolean}\n */\n get open() {\n return this.hasAttribute('open');\n }\n\n /**\n * Set duration value of the toast.\n * @param value\n */\n set duration(value) {\n this.setAttribute('duration', value);\n }\n\n /**\n * Get duration value of the toast.\n * @returns {number}\n */\n get duration() {\n return +this.getAttribute('duration');\n }\n\n /**\n * Set closable value of the toast.\n * @param value\n */\n set closable(value) {\n this.setAttribute('closable', value || '');\n }\n\n /**\n * Get closable value of the toast.\n * @returns {boolean}\n */\n get closable() {\n return this.hasAttribute('closable');\n }\n\n /**\n * Set color value of the toast.\n * @param value\n */\n set color(value) {\n this.setAttribute('color', value);\n }\n\n /**\n * Get color value of the toast.\n * @returns {string}\n */\n get color() {\n return this.getAttribute('color');\n }\n\n /**\n * Set countdown value of the toast.\n * @param value\n */\n set countdown(value) {\n if (value) this.setAttribute('countdown', value);\n }\n\n /**\n * Get countdown value of the toast.\n * @returns {boolean}\n */\n get countdown() {\n return this.hasAttribute('countdown');\n }\n\n /**\n * Set icon value of the toast.\n * @param value\n */\n set icon(value) {\n this.setAttribute('icon', value);\n }\n\n /**\n * Get icon value of the toast.\n * @returns {string}\n */\n get icon() {\n return this.getAttribute('icon');\n }\n\n /**\n * The class name for the component.\n * @type {string}\n */\n className = 'Toast';\n\n /**\n * Returns the CSS stylesheet for the component.\n * @static\n * @returns {CSSStyleSheet} The CSS stylesheet\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Setup attributes for the Button element.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n this.setAriaState({\n role: 'status',\n });\n }\n\n /**\n * Draw method for the toast notification.\n * @returns {object} Document fragment\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('div');\n native.setAttribute('part', 'native');\n native.classList.add('native-toast');\n\n let mediaSlot = document.createElement('slot');\n mediaSlot.setAttribute('name', 'media');\n mediaSlot.classList.add('media');\n mediaSlot.addEventListener('slotchange', () => {\n if (WjElementUtils.hasSlotContent(this.context, 'media')) {\n mediaSlot.parentElement.classList.add('has-media');\n } else {\n mediaSlot.parentElement.classList.remove('has-media');\n }\n });\n\n let content = document.createElement('div');\n content.classList.add('content');\n content.innerHTML = `<div class=\"headline\">${this.headline}</div><div class=\"message\"><slot></slot></div>`;\n\n let iconX = document.createElement('wje-icon');\n iconX.setAttribute('name', 'x');\n\n let closeBtn = document.createElement('wje-button');\n closeBtn.setAttribute('fill', 'link');\n closeBtn.setAttribute('color', this.color);\n closeBtn.setAttribute('size', 'small');\n closeBtn.classList.add('close');\n closeBtn.setAttribute('aria-label', 'Close');\n\n let countdownEl = document.createElement('div');\n countdownEl.classList.add('countdown');\n\n let countdownBar = document.createElement('div');\n countdownBar.classList.add('countdown-bar');\n\n closeBtn.appendChild(iconX);\n countdownEl.appendChild(countdownBar);\n\n if (this.hasAttribute('icon') && this.icon) {\n let icon = document.createElement('wje-icon');\n icon.setAttribute('name', this.icon);\n icon.setAttribute('color', this.color);\n icon.setAttribute('slot', 'media');\n icon.setAttribute('part', 'icon');\n\n this.appendChild(icon);\n }\n\n native.appendChild(mediaSlot);\n native.appendChild(content);\n\n if (this.closable) native.appendChild(closeBtn);\n\n if (this.hasAttribute('countdown')) native.appendChild(countdownEl);\n\n fragment.appendChild(native);\n\n this.closeBtn = closeBtn;\n this.countdownBar = countdownBar;\n\n return fragment;\n }\n\n /**\n * After draw method for the toast notification.\n */\n afterDraw() {\n this.closeBtn.addEventListener('wje-button:click', this.hide);\n this.addEventListener('mouseenter', this.pause);\n this.addEventListener('mouseleave', this.resume);\n\n if (this.hasAttribute('countdown')) {\n const startWidth = '100%';\n const endWidth = '0';\n\n this.countdownAnimation = this.countdownBar.animate([{ width: startWidth }, { width: endWidth }], {\n duration: this.duration,\n easing: 'linear',\n });\n }\n\n if (this.duration > 0) {\n this.remainingTime = this.duration;\n this.startTimer();\n }\n }\n\n /**\n * Before disconnect method\n * This method is called before the element is disconnected from the document.\n */\n beforeDisconnect() {\n this.closeBtn?.removeEventListener('wje-button:click', this.hide);\n this.removeEventListener('wje-toast:after-hide', this.removeChildAndStack);\n this.removeEventListener('mouseenter', this.pause);\n this.removeEventListener('mouseleave', this.resume);\n\n clearTimeout(this.timeoutID);\n }\n\n /**\n * Starts the timer.\n * This method sets the `startTime` property to the current time and sets\n * the `timeoutID` property to the ID of the timeout. The method also\n * dispatches the `wje-toast:after-hide` custom event when the timeout\n * expires.\n */\n startTimer() {\n this.startTime = Date.now();\n if (this.timeoutID) {\n clearTimeout(this.timeoutID);\n }\n this.timeoutID = window.setTimeout(() => {\n this.hide();\n }, this.remainingTime);\n }\n\n /**\n * Stops the timer.\n * This method clears the timeout and calculates the remaining time.\n * The method is called when the toast notification is paused.\n */\n stopTimer() {\n if (this.timeoutID) {\n window.clearTimeout(this.timeoutID);\n }\n const elapsedTime = Date.now() - this.startTime;\n this.remainingTime -= elapsedTime;\n }\n\n /**\n * Resumes the timer.\n * This method resumes the timer if the remaining time is greater\n * than zero. The method is called when the toast notification is resumed.\n */\n resumeTimer() {\n if (this.remainingTime > 0) {\n this.startTimer();\n }\n }\n\n /**\n * Asynchronously shows the toast notification.\n * This method sets the `open` property to `true` and dispatches the\n * `wje-toast:after-show` custom event. If the toast is already open,\n * the method returns `undefined`.\n */\n show = () => {\n if (this.open) {\n return;\n }\n\n this.open = true;\n event.dispatchCustomEvent(this, 'wje-toast:after-show');\n };\n\n /**\n * Asynchronously hides the toast notification.\n * This method sets the `open` property to `false` and dispatches the\n * `wje-toast:after-hide` custom event. If the toast is already hidden,\n * the method returns `undefined`.\n */\n hide = () => {\n if (!this.open) {\n return;\n }\n\n this.open = false;\n event.dispatchCustomEvent(this, 'wje-toast:after-hide');\n };\n\n /**\n * Pauses the countdown animation and stops the timer.\n */\n pause = () => {\n this.countdownAnimation?.pause();\n this.stopTimer();\n };\n\n /**\n * Resumes the countdown animation and resumes the timer.\n */\n resume = () => {\n this.countdownAnimation?.play();\n this.resumeTimer();\n };\n\n /**\n * Removes the toast notification and the toast stack.\n *\n * This method removes the toast notification from the toast stack and\n * removes the toast stack from the document body if the toast stack is\n * empty.\n */\n removeChildAndStack() {\n this.toastStack.removeChild(this);\n\n if (this.toastStack.querySelector('wje-toast') === null) {\n this.toastStack.remove();\n }\n }\n\n /**\n * Asynchronously starts the toast notification.\n * This method appends the toast notification to the document body and\n * shows the toast notification. The method returns a promise that\n * resolves when the toast notification is shown.\n * @returns {Promise<unknown>}\n */\n start = () => {\n return new Promise((resolve) => {\n let stack = document.body.querySelector('.wje-toast-stack');\n if (stack) {\n this.toastStack = stack;\n }\n\n if (this.toastStack.parentElement === null) {\n document.body.append(this.toastStack);\n }\n\n this.toastStack.append(this);\n\n this.show();\n\n this.addEventListener('wje-toast:after-hide', this.removeChildAndStack);\n });\n };\n}\n","import Toast from './toast.element.js';\n\nexport default Toast;\n\nToast.define('wje-toast', Toast);\n"],"names":[],"mappings":";;;;;;;AAsBe,MAAM,cAAc,UAAU;AAAA;AAAA;AAAA;AAAA,EAIzC,cAAc;AACV,UAAO;AA2HX;AAAA;AAAA;AAAA;AAAA,qCAAY;AA+KZ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gCAAO,MAAM;AACT,UAAI,KAAK,MAAM;AACX;AAAA,MACZ;AAEQ,WAAK,OAAO;AACZ,YAAM,oBAAoB,MAAM,sBAAsB;AAAA,IACzD;AAQD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gCAAO,MAAM;AACT,UAAI,CAAC,KAAK,MAAM;AACZ;AAAA,MACZ;AAEQ,WAAK,OAAO;AACZ,YAAM,oBAAoB,MAAM,sBAAsB;AAAA,IACzD;AAKD;AAAA;AAAA;AAAA,iCAAQ,MAAM;;AACV,iBAAK,uBAAL,mBAAyB;AACzB,WAAK,UAAW;AAAA,IACnB;AAKD;AAAA;AAAA;AAAA,kCAAS,MAAM;;AACX,iBAAK,uBAAL,mBAAyB;AACzB,WAAK,YAAa;AAA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;AAAA,IAC7B;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAuDI,sBAAsB;AAClB,SAAK,WAAW,YAAY,IAAI;AAEhC,QAAI,KAAK,WAAW,cAAc,WAAW,MAAM,MAAM;AACrD,WAAK,WAAW,OAAQ;AAAA,IACpC;AAAA,EACA;AA2BA;ACjZA,MAAM,OAAO,aAAa,KAAK;"}
|
package/dist/wje-toggle.js
CHANGED
|
@@ -6,7 +6,7 @@ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read fr
|
|
|
6
6
|
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
7
7
|
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
8
8
|
var _internalValue;
|
|
9
|
-
import { F as FormAssociatedElement } from "./form-associated-element-
|
|
9
|
+
import { F as FormAssociatedElement } from "./form-associated-element-DEQ4y-jn.js";
|
|
10
10
|
import { event } from "./event.js";
|
|
11
11
|
const styles = "/*\n[ WJ Toggle ]\n*/\n\n:host {\n --wje-toggle-color-base: var(--wje-color-contrast-3);\n --wje-toggle-width: 30px;\n --wje-toggle-height: 18px;\n --wje-toggle-border-radius: 50px;\n --wje-toggle-handle-width: 13px;\n --wje-toggle-handle-height: 13px;\n --wje-toggle-handle-border-radius: 9px;\n --wje-toggle-handle-color: #fff;\n --wje-toggle-handle-shadow: 1px 0 1px 0.5px rgba(0, 0, 0, 0.12), 2px 4px 6px rgba(0, 0, 0, 0.2);\n --wje-toggle-handle-shadow-checked: 1px 1px 0 rgba(0, 0, 0, 0.08), -3px 3px 6px rgba(0, 0, 0, 0.3);\n --wje-toggle-duration: 250ms;\n --wje-toggle-curve: cubic-bezier(0.4, 0, 0.2, 1);\n}\n\n:host([color='primary']) input:checked + label > .label-wrapper {\n --wje-toggle-color-base: var(--wje-color-primary-9) !important;\n}\n\n:host([color='complete']) input:checked + label > .label-wrapper {\n --wje-toggle-color-base: var(--wje-color-complete-9);\n}\n\n:host([color='success']) input:checked + label > .label-wrapper {\n --wje-toggle-color-base: var(--wje-color-success-9) !important;\n}\n\n:host([color='warning']) input:checked + label > .label-wrapper {\n --wje-toggle-color-base: var(--wje-color-warning-9);\n}\n\n:host([color='danger']) input:checked + label > .label-wrapper {\n --wje-toggle-color-base: var(--wje-color-danger-9);\n}\n\n:host([color='info']) input:checked + label > .label-wrapper {\n --wje-toggle-color-base: var(--wje-color-info-9);\n}\n\n.native-toggle {\n\n label {\n display: flex;\n cursor: pointer;\n align-items: center;\n user-select: none;\n\n .label-wrapper {\n width: var(--wje-toggle-width) !important;\n min-width: var(--wje-toggle-width);\n height: var(--wje-toggle-height);\n position: relative;\n display: flex;\n align-items: center;\n\n &:before {\n content: '';\n position: absolute;\n cursor: pointer;\n width: 100%;\n height: 100%;\n top: auto;\n left: 0;\n background: var(--wje-toggle-color-base);\n background-size: 300%;\n background-position: right;\n border-radius: var(--wje-toggle-border-radius);\n border: none;\n box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);\n transition: background calc(var(--wje-toggle-duration) + (var(--wje-toggle-duration) * 0.24)),\n box-shadow var(--wje-toggle-duration);\n transition-timing-function: var(--wje-toggle-curve);\n }\n\n &:after {\n content: '';\n position: absolute;\n transform: translateX(0%);\n background: var(--wje-toggle-handle-color);\n width: var(--wje-toggle-handle-width);\n height: var(--wje-toggle-handle-height);\n border-radius: var(--wje-toggle-handle-border-radius);\n top: auto;\n left: 2px;\n box-shadow: var(--wje-toggle-handle-shadow);\n transition: transform, box-shadow;\n transition-duration: var(--wje-toggle-duration);\n transition-timing-function: var(--wje-toggle-curve);\n }\n }\n }\n\n input[type='checkbox'][disabled] {\n & + label {\n cursor: not-allowed !important;\n color: var(--wje-color-contrast-9);\n opacity: 0.58;\n\n &:before {\n cursor: not-allowed !important;\n }\n }\n }\n\n input[type='checkbox'] {\n position: absolute;\n z-index: -1;\n opacity: 0;\n\n &:checked {\n & + label {\n .label-wrapper:before {\n background-position: left;\n box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);\n }\n\n .label-wrapper:after {\n transform: translateX(calc(var(--wje-toggle-width) - var(--wje-toggle-handle-width) - 4px));\n box-shadow: var(--wje-toggle-handle-shadow-checked);\n }\n }\n }\n\n &:focus {\n & + label {\n .label-wrapper:before {\n outline: none !important;\n box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12),\n 0 0 0 0 #78c8fe;\n }\n }\n }\n\n &[disabled]:active {\n & + label {\n .label-wrapper:after {\n transform: scaleX(1.1);\n transform-origin: center left;\n transition: transform step-start;\n }\n }\n }\n\n &:checked {\n &[disabled]:active {\n & + label {\n .label-wrapper:after {\n transform: translateX(calc(100% - 6px)) scaleX(1.1);\n transform-origin: center right;\n }\n }\n }\n }\n\n &:hover {\n &:active {\n & + label {\n .label-wrapper:before {\n background-color: transparent;\n }\n }\n }\n }\n }\n}\n\n:host .text {\n margin-inline: 0.5rem 0;\n}\n\n/*Placememt*/\n:host([placement='end']) {\n label {\n width: 100%;\n }\n .text {\n margin-inline: 0 0.5rem;\n width: 100%;\n }\n}\n\n:host([invalid]) {\n label{\n color: var(--wje-input-color-invalid);\n }\n}\n\nslot[name='error'] {\n display: none;\n}\n\n:host([invalid]) slot[name='error'] {\n display: block;\n}\n\nslot[name='error'] {\n display: none;\n max-width: 100%;\n min-width: auto;\n border-radius: 50px;\n top: 0;\n width: max-content;\n line-height: normal;\n position: static;\n background: transparent;\n padding: 0.25rem 0;\n left: auto;\n transform: none;\n color: var(--wje-input-color-invalid);\n font-size: 12px;\n}\n";
|
|
12
12
|
class Toggle extends FormAssociatedElement {
|
|
@@ -101,6 +101,7 @@ class Toggle extends FormAssociatedElement {
|
|
|
101
101
|
this.value = __privateGet(this, _internalValue);
|
|
102
102
|
this.pristine = false;
|
|
103
103
|
}
|
|
104
|
+
this.syncAria();
|
|
104
105
|
}
|
|
105
106
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
106
107
|
if (!this.input) return;
|
|
@@ -123,6 +124,7 @@ class Toggle extends FormAssociatedElement {
|
|
|
123
124
|
this.internals.setFormValue(this.value);
|
|
124
125
|
}
|
|
125
126
|
}
|
|
127
|
+
this.syncAria();
|
|
126
128
|
}
|
|
127
129
|
draw() {
|
|
128
130
|
const fragment = document.createDocumentFragment();
|
|
@@ -167,6 +169,7 @@ class Toggle extends FormAssociatedElement {
|
|
|
167
169
|
}
|
|
168
170
|
afterDraw() {
|
|
169
171
|
this.internals.setFormValue(this.checked ? this.value : null);
|
|
172
|
+
this.syncAria();
|
|
170
173
|
if (!this.disabled) {
|
|
171
174
|
this.input.addEventListener("input", (e) => {
|
|
172
175
|
this.validate();
|
|
@@ -174,6 +177,7 @@ class Toggle extends FormAssociatedElement {
|
|
|
174
177
|
this.propagateValidation();
|
|
175
178
|
this.indeterminate = false;
|
|
176
179
|
this.checked = e.target.checked;
|
|
180
|
+
this.syncAria();
|
|
177
181
|
event.dispatchCustomEvent(this, "wje-toggle:input");
|
|
178
182
|
});
|
|
179
183
|
this.input.addEventListener("change", (e) => {
|
|
@@ -190,6 +194,18 @@ class Toggle extends FormAssociatedElement {
|
|
|
190
194
|
}
|
|
191
195
|
}
|
|
192
196
|
}
|
|
197
|
+
/**
|
|
198
|
+
* Syncs ARIA attributes on the host element.
|
|
199
|
+
*/
|
|
200
|
+
syncAria() {
|
|
201
|
+
this.setAriaState({
|
|
202
|
+
role: "switch",
|
|
203
|
+
checked: this.checked,
|
|
204
|
+
disabled: this.disabled,
|
|
205
|
+
required: this.required,
|
|
206
|
+
invalid: this.invalid
|
|
207
|
+
});
|
|
208
|
+
}
|
|
193
209
|
/**
|
|
194
210
|
* Removes the event listener when the checkbox is disconnected.
|
|
195
211
|
*/
|
package/dist/wje-toggle.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wje-toggle.js","sources":["../packages/wje-toggle/toggle.element.js","../packages/wje-toggle/toggle.js"],"sourcesContent":["import { FormAssociatedElement } from '../internals/form-associated-element.js';\nimport { event } from '../utils/event.js';\n\nimport styles from './styles/styles.css?inline';\n\n/**\n * `Toggle` is a custom web component that represents a toggle input.\n * @summary This element represents a toggle input.\n * @documentation https://elements.webjet.sk/components/toggle\n * @status stable\n * @augments {FormAssociatedElement}\n * @csspart native - The native toggle wrapper.\n * @csspart input - The toggle input.\n * @csspart toggle - The toggle part.\n * @slot - The default slot for the toggle.\n * @cssproperty [--wje-toggle-color-base=var(--wje-color-contrast-3)] - The base background color of the toggle. Defines the default background color when the toggle is in an unselected state.\n * @cssproperty [--wje-toggle-width=30px] - The overall width of the toggle switch. Determines how wide the toggle component appears.\n * @cssproperty [--wje-toggle-height=18px] - The overall height of the toggle switch. Specifies how tall the toggle component appears.\n * @cssproperty [--wje-toggle-border-radius=50px] - The border radius of the toggle. Controls how rounded the corners of the toggle are.\n * @cssproperty [--wje-toggle-handle-width=14px] - The width of the toggle handle (knob). Determines the size of the handle for user interaction.\n * @cssproperty [--wje-toggle-handle-height=14px] - The height of the toggle handle (knob). Specifies the vertical size of the handle.\n * @cssproperty [--wje-toggle-handle-border-radius=9px] - The border radius of the toggle handle. Controls how rounded the handle is.\n * @cssproperty [--wje-toggle-handle-color=#fff] - The color of the toggle handle. Accepts any valid CSS color, such as `hex`, `rgb`, or `css variable`.\n * @cssproperty [--wje-toggle-handle-shadow=1px 0 1px 0.5px rgba(0,0,0,0.12), 2px 4px 6px rgba(0,0,0,0.2)] - The shadow applied to the toggle handle. Adds a subtle shadow effect for better visual clarity.\n * @cssproperty [--wje-toggle-handle-shadow-checked=1px 1px 0 rgba(0,0,0,0.08), -3px 3px 6px rgba(0,0,0,0.3)] - The shadow applied to the toggle handle when it is in the checked (on) state. Provides visual feedback to indicate the toggle state.\n * @cssproperty [--wje-toggle-duration=250ms] - The duration of the toggle animation in milliseconds. Controls how long the toggle animation lasts during state changes.\n * @cssproperty [--wje-toggle-curve=cubic-bezier(.4,0,.2,1)] - The easing curve used for the toggle animation. Defines the speed curve for the animation, enhancing the user experience with smooth transitions.\n * @tag wje-toggle\n */\n\nexport default class Toggle extends FormAssociatedElement {\n #internalValue;\n\n constructor() {\n super();\n\n this.invalid = false;\n this.pristine = true;\n }\n\n /**\n * Setter for the value attribute.\n * @param {string} value The value to set.\n */\n set value(value) {\n this.#internalValue = value;\n if (this.input) {\n this.input.value = value;\n }\n }\n\n /**\n * Getter for the value attribute.\n * @returns {string} The value of the attribute.\n */\n get value() {\n return this.#internalValue ?? this.getAttribute('value') ?? 'on';\n }\n\n /**\n * Getter for the customErrorDisplay attribute.\n * @returns {boolean} Whether the attribute is present.\n */\n get customErrorDisplay() {\n return this.hasAttribute('custom-error-display');\n }\n\n /**\n * Getter for the validateOnChange attribute.\n * @returns {boolean} Whether the attribute is present.\n */\n get validateOnChange() {\n return this.hasAttribute('validate-on-change');\n }\n\n /**\n * Setter for the defaultValue attribute.\n * This method sets the 'value' attribute of the custom input element to the provided value.\n * The 'value' attribute represents the default value of the input element.\n * @param {string} value The value to set as the default value.\n */\n set defaultValue(value) {\n this.setAttribute('value', value);\n }\n\n /**\n * Getter for the defaultValue attribute.\n * This method retrieves the 'value' attribute of the custom input element.\n * The 'value' attribute represents the default value of the input element.\n * If the 'value' attribute is not set, it returns an empty string.\n * @returns {string} The default value of the input element.\n */\n get defaultValue() {\n return this.getAttribute('value') ?? '';\n }\n\n /**\n * Set checked attribute.\n * @param {boolean} value true if the toggle is checked, false otherwise\n */\n set checked(value) {\n if (value) {\n this.setAttribute('checked', '');\n this.internals.setFormValue(this.value); // len ak je checked\n } else {\n this.removeAttribute('checked');\n this.internals.setFormValue(null); // ak nie je checked, nič sa neposiela\n }\n if (this.input) {\n this.input.checked = value;\n }\n }\n\n /**\n * Get checked attribute.\n * @returns {boolean} true if the toggle is checked, false otherwise\n */\n get checked() {\n return this.hasAttribute('checked');\n }\n\n static get cssStyleSheet() {\n return styles;\n }\n\n static get observedAttributes() {\n return ['checked', 'disabled', 'required'];\n }\n\n setupAttributes() {\n this.isShadowRoot = 'open';\n // if some value was set via value setter then dont use default value\n if (this.pristine) {\n this.value = this.#internalValue;\n this.pristine = false;\n }\n }\n\n attributeChangedCallback(name, oldValue, newValue) {\n if (!this.input) return;\n if (name === 'checked') {\n const isChecked = this.hasAttribute('checked');\n this.input.checked = isChecked;\n // Reflect into form value\n if (isChecked) {\n this.internals.setFormValue(this.value);\n } else {\n this.internals.setFormValue(null);\n }\n } else if (name === 'disabled') {\n this.input.disabled = this.hasAttribute('disabled');\n } else if (name === 'indeterminate') {\n this.input.indeterminate = this.hasAttribute('indeterminate');\n } else if (name === 'value') {\n // keep payload in sync; do not toggle checked here\n this.#internalValue = newValue ?? undefined;\n this.input.value = this.value;\n // If currently checked, update the submitted payload\n if (this.input.checked) {\n this.internals.setFormValue(this.value);\n }\n }\n }\n\n draw() {\n const fragment = document.createDocumentFragment();\n\n const native = document.createElement('div');\n native.setAttribute('part', 'native');\n native.classList.add('native-toggle');\n\n const input = document.createElement('input');\n input.setAttribute('part', 'input');\n input.type = 'checkbox';\n input.name = this.name;\n input.id = 'input';\n input.checked = this.hasAttribute('checked');\n input.disabled = this.hasAttribute('disabled');\n if (this.hasAttribute('required')) input.required = true;\n\n const label = document.createElement('label');\n label.setAttribute('for', 'input');\n\n const toggle = document.createElement('div');\n toggle.setAttribute('part', 'toggle');\n toggle.classList.add('label-wrapper');\n\n const text = document.createElement('div');\n text.classList.add('text');\n text.innerHTML = '<slot></slot>';\n\n // Error\n let errorSlot = document.createElement('slot');\n errorSlot.setAttribute('name', 'error');\n\n let error = document.createElement('div');\n error.setAttribute('slot', 'error');\n\n // APPEND\n if (this.placement === 'end') {\n native.classList.add('end');\n label.appendChild(text);\n label.appendChild(toggle);\n } else {\n label.appendChild(toggle);\n label.appendChild(text);\n }\n\n native.appendChild(input);\n native.appendChild(label);\n native.append(errorSlot);\n\n this.append(error);\n\n fragment.appendChild(native);\n\n this.input = input;\n\n return fragment;\n }\n\n afterDraw() {\n this.internals.setFormValue(this.checked ? this.value : null); // Set initial form value based on checked state\n\n if (!this.disabled) {\n this.input.addEventListener('input', (e) => {\n this.validate();\n\n this.pristine = false;\n this.propagateValidation();\n\n this.indeterminate = false;\n this.checked = e.target.checked;\n\n event.dispatchCustomEvent(this, 'wje-toggle:input');\n });\n\n this.input.addEventListener('change', (e) => {\n event.dispatchCustomEvent(this, 'wje-toggle:change');\n });\n\n this.addEventListener('invalid', (e) => {\n this.invalid = true;\n this.pristine = false;\n\n this.showInvalidMessage();\n });\n\n this.validate();\n\n if (this.invalid) {\n this.showInvalidMessage();\n }\n }\n }\n\n /**\n * Removes the event listener when the checkbox is disconnected.\n */\n beforeDisconnect() {\n event.removeElement(this.input);\n }\n}\n","import Toggle from './toggle.element.js';\n\nexport default Toggle;\n\nToggle.define('wje-toggle', Toggle);\n"],"names":[],"mappings":";;;;;;;;;;;AA8Be,MAAM,eAAe,sBAAsB;AAAA,EAGtD,cAAc;AACV,UAAO;AAHX;AAKI,SAAK,UAAU;AACf,SAAK,WAAW;AAAA,EACxB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,MAAM,OAAO;AACb,uBAAK,gBAAiB;AACtB,QAAI,KAAK,OAAO;AACZ,WAAK,MAAM,QAAQ;AAAA,IAC/B;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,QAAQ;AACR,WAAO,mBAAK,mBAAkB,KAAK,aAAa,OAAO,KAAK;AAAA,EACpE;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,qBAAqB;AACrB,WAAO,KAAK,aAAa,sBAAsB;AAAA,EACvD;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,mBAAmB;AACnB,WAAO,KAAK,aAAa,oBAAoB;AAAA,EACrD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQI,IAAI,aAAa,OAAO;AACpB,SAAK,aAA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K,OAAO,KAAK;AAEjB,aAAS,YAAY,MAAM;AAE3B,SAAK,QAAQ;AAEb,WAAO;AAAA,EACf;AAAA,EAEI,YAAY;AACR,SAAK,UAAU,aAAa,KAAK,UAAU,KAAK,QAAQ,IAAI;AAE5D,QAAI,CAAC,KAAK,UAAU;AAChB,WAAK,MAAM,iBAAiB,SAAS,CAAC,MAAM;AACxC,aAAK,SAAU;AAEf,aAAK,WAAW;AAChB,aAAK,oBAAqB;AAE1B,aAAK,gBAAgB;AACrB,aAAK,UAAU,EAAE,OAAO;AAExB,cAAM,oBAAoB,MAAM,kBAAkB;AAAA,MAClE,CAAa;AAED,WAAK,MAAM,iBAAiB,UAAU,CAAC,MAAM;AACzC,cAAM,oBAAoB,MAAM,mBAAmB;AAAA,MACnE,CAAa;AAED,WAAK,iBAAiB,WAAW,CAAC,MAAM;AACpC,aAAK,UAAU;AACf,aAAK,WAAW;AAEhB,aAAK,mBAAoB;AAAA,MACzC,CAAa;AAED,WAAK,SAAU;AAEf,UAAI,KAAK,SAAS;AACd,aAAK,mBAAoB;AAAA,MACzC;AAAA,IACA;AAAA,EACA;AAAA;AAAA;AAAA;AAAA,EAKI,mBAAmB;AACf,UAAM,cAAc,KAAK,KAAK;AAAA,EACtC;AACA;AAvOI;AC3BJ,OAAO,OAAO,cAAc,MAAM;"}
|
|
1
|
+
{"version":3,"file":"wje-toggle.js","sources":["../packages/wje-toggle/toggle.element.js","../packages/wje-toggle/toggle.js"],"sourcesContent":["import { FormAssociatedElement } from '../internals/form-associated-element.js';\nimport { event } from '../utils/event.js';\n\nimport styles from './styles/styles.css?inline';\n\n/**\n * `Toggle` is a custom web component that represents a toggle input.\n * @summary This element represents a toggle input.\n * @documentation https://elements.webjet.sk/components/toggle\n * @status stable\n * @augments {FormAssociatedElement}\n * @csspart native - The native toggle wrapper.\n * @csspart input - The toggle input.\n * @csspart toggle - The toggle part.\n * @slot - The default slot for the toggle.\n * @cssproperty [--wje-toggle-color-base=var(--wje-color-contrast-3)] - The base background color of the toggle. Defines the default background color when the toggle is in an unselected state.\n * @cssproperty [--wje-toggle-width=30px] - The overall width of the toggle switch. Determines how wide the toggle component appears.\n * @cssproperty [--wje-toggle-height=18px] - The overall height of the toggle switch. Specifies how tall the toggle component appears.\n * @cssproperty [--wje-toggle-border-radius=50px] - The border radius of the toggle. Controls how rounded the corners of the toggle are.\n * @cssproperty [--wje-toggle-handle-width=14px] - The width of the toggle handle (knob). Determines the size of the handle for user interaction.\n * @cssproperty [--wje-toggle-handle-height=14px] - The height of the toggle handle (knob). Specifies the vertical size of the handle.\n * @cssproperty [--wje-toggle-handle-border-radius=9px] - The border radius of the toggle handle. Controls how rounded the handle is.\n * @cssproperty [--wje-toggle-handle-color=#fff] - The color of the toggle handle. Accepts any valid CSS color, such as `hex`, `rgb`, or `css variable`.\n * @cssproperty [--wje-toggle-handle-shadow=1px 0 1px 0.5px rgba(0,0,0,0.12), 2px 4px 6px rgba(0,0,0,0.2)] - The shadow applied to the toggle handle. Adds a subtle shadow effect for better visual clarity.\n * @cssproperty [--wje-toggle-handle-shadow-checked=1px 1px 0 rgba(0,0,0,0.08), -3px 3px 6px rgba(0,0,0,0.3)] - The shadow applied to the toggle handle when it is in the checked (on) state. Provides visual feedback to indicate the toggle state.\n * @cssproperty [--wje-toggle-duration=250ms] - The duration of the toggle animation in milliseconds. Controls how long the toggle animation lasts during state changes.\n * @cssproperty [--wje-toggle-curve=cubic-bezier(.4,0,.2,1)] - The easing curve used for the toggle animation. Defines the speed curve for the animation, enhancing the user experience with smooth transitions.\n * @tag wje-toggle\n */\n\nexport default class Toggle extends FormAssociatedElement {\n #internalValue;\n\n constructor() {\n super();\n\n this.invalid = false;\n this.pristine = true;\n }\n\n /**\n * Setter for the value attribute.\n * @param {string} value The value to set.\n */\n set value(value) {\n this.#internalValue = value;\n if (this.input) {\n this.input.value = value;\n }\n }\n\n /**\n * Getter for the value attribute.\n * @returns {string} The value of the attribute.\n */\n get value() {\n return this.#internalValue ?? this.getAttribute('value') ?? 'on';\n }\n\n /**\n * Getter for the customErrorDisplay attribute.\n * @returns {boolean} Whether the attribute is present.\n */\n get customErrorDisplay() {\n return this.hasAttribute('custom-error-display');\n }\n\n /**\n * Getter for the validateOnChange attribute.\n * @returns {boolean} Whether the attribute is present.\n */\n get validateOnChange() {\n return this.hasAttribute('validate-on-change');\n }\n\n /**\n * Setter for the defaultValue attribute.\n * This method sets the 'value' attribute of the custom input element to the provided value.\n * The 'value' attribute represents the default value of the input element.\n * @param {string} value The value to set as the default value.\n */\n set defaultValue(value) {\n this.setAttribute('value', value);\n }\n\n /**\n * Getter for the defaultValue attribute.\n * This method retrieves the 'value' attribute of the custom input element.\n * The 'value' attribute represents the default value of the input element.\n * If the 'value' attribute is not set, it returns an empty string.\n * @returns {string} The default value of the input element.\n */\n get defaultValue() {\n return this.getAttribute('value') ?? '';\n }\n\n /**\n * Set checked attribute.\n * @param {boolean} value true if the toggle is checked, false otherwise\n */\n set checked(value) {\n if (value) {\n this.setAttribute('checked', '');\n this.internals.setFormValue(this.value); // len ak je checked\n } else {\n this.removeAttribute('checked');\n this.internals.setFormValue(null); // ak nie je checked, nič sa neposiela\n }\n if (this.input) {\n this.input.checked = value;\n }\n }\n\n /**\n * Get checked attribute.\n * @returns {boolean} true if the toggle is checked, false otherwise\n */\n get checked() {\n return this.hasAttribute('checked');\n }\n\n static get cssStyleSheet() {\n return styles;\n }\n\n static get observedAttributes() {\n return ['checked', 'disabled', 'required'];\n }\n\n setupAttributes() {\n this.isShadowRoot = 'open';\n // if some value was set via value setter then dont use default value\n if (this.pristine) {\n this.value = this.#internalValue;\n this.pristine = false;\n }\n this.syncAria();\n }\n\n attributeChangedCallback(name, oldValue, newValue) {\n if (!this.input) return;\n if (name === 'checked') {\n const isChecked = this.hasAttribute('checked');\n this.input.checked = isChecked;\n // Reflect into form value\n if (isChecked) {\n this.internals.setFormValue(this.value);\n } else {\n this.internals.setFormValue(null);\n }\n } else if (name === 'disabled') {\n this.input.disabled = this.hasAttribute('disabled');\n } else if (name === 'indeterminate') {\n this.input.indeterminate = this.hasAttribute('indeterminate');\n } else if (name === 'value') {\n // keep payload in sync; do not toggle checked here\n this.#internalValue = newValue ?? undefined;\n this.input.value = this.value;\n // If currently checked, update the submitted payload\n if (this.input.checked) {\n this.internals.setFormValue(this.value);\n }\n }\n this.syncAria();\n }\n\n draw() {\n const fragment = document.createDocumentFragment();\n\n const native = document.createElement('div');\n native.setAttribute('part', 'native');\n native.classList.add('native-toggle');\n\n const input = document.createElement('input');\n input.setAttribute('part', 'input');\n input.type = 'checkbox';\n input.name = this.name;\n input.id = 'input';\n input.checked = this.hasAttribute('checked');\n input.disabled = this.hasAttribute('disabled');\n if (this.hasAttribute('required')) input.required = true;\n\n const label = document.createElement('label');\n label.setAttribute('for', 'input');\n\n const toggle = document.createElement('div');\n toggle.setAttribute('part', 'toggle');\n toggle.classList.add('label-wrapper');\n\n const text = document.createElement('div');\n text.classList.add('text');\n text.innerHTML = '<slot></slot>';\n\n // Error\n let errorSlot = document.createElement('slot');\n errorSlot.setAttribute('name', 'error');\n\n let error = document.createElement('div');\n error.setAttribute('slot', 'error');\n\n // APPEND\n if (this.placement === 'end') {\n native.classList.add('end');\n label.appendChild(text);\n label.appendChild(toggle);\n } else {\n label.appendChild(toggle);\n label.appendChild(text);\n }\n\n native.appendChild(input);\n native.appendChild(label);\n native.append(errorSlot);\n\n this.append(error);\n\n fragment.appendChild(native);\n\n this.input = input;\n\n return fragment;\n }\n\n afterDraw() {\n this.internals.setFormValue(this.checked ? this.value : null); // Set initial form value based on checked state\n this.syncAria();\n\n if (!this.disabled) {\n this.input.addEventListener('input', (e) => {\n this.validate();\n\n this.pristine = false;\n this.propagateValidation();\n\n this.indeterminate = false;\n this.checked = e.target.checked;\n this.syncAria();\n\n event.dispatchCustomEvent(this, 'wje-toggle:input');\n });\n\n this.input.addEventListener('change', (e) => {\n event.dispatchCustomEvent(this, 'wje-toggle:change');\n });\n\n this.addEventListener('invalid', (e) => {\n this.invalid = true;\n this.pristine = false;\n\n this.showInvalidMessage();\n });\n\n this.validate();\n\n if (this.invalid) {\n this.showInvalidMessage();\n }\n }\n }\n\n /**\n * Syncs ARIA attributes on the host element.\n */\n syncAria() {\n this.setAriaState({\n role: 'switch',\n checked: this.checked,\n disabled: this.disabled,\n required: this.required,\n invalid: this.invalid,\n });\n }\n\n /**\n * Removes the event listener when the checkbox is disconnected.\n */\n beforeDisconnect() {\n event.removeElement(this.input);\n }\n}\n","import Toggle from './toggle.element.js';\n\nexport default Toggle;\n\nToggle.define('wje-toggle', Toggle);\n"],"names":[],"mappings":";;;;;;;;;;;AA8Be,MAAM,eAAe,sBAAsB;AAAA,EAGtD,cAAc;AACV,UAAO;AAHX;AAKI,SAAK,UAAU;AACf,SAAK,WAAW;AAAA,EACxB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,MAAM,OAAO;AACb,uBAAK,gBAAiB;AACtB,QAAI,KAAK,OAAO;AACZ,WAAK,MAAM,QAAQ;AAAA,IAC/B;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,QAAQ;AACR,WAAO,mBAAK,mBAAkB,KAAK,aAAa,OAAO,KAAK;AAAA,EACpE;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,qBAAqB;AACrB,WAAO,KAAK,aAAa,sBAAsB;AAAA,EACvD;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,mBAAmB;AACnB,WAAO,KAAK,aAAa,oBAAoB;AAAA,EACrD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQI,IAAI,aAAa,OAAO;AACpB,SAAK,aAAa,SAAS,KAAK;AAAA,EACxC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASI,IAAI,eAAe;AACf,WAAO,KAAK,aAAa,OAAO,KAAK;AAAA,EAC7C;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,QAAQ,OAAO;AACf,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,SAAK,SAAU;AAEf,QAAI,CAAC,KAAK,UAAU;AAChB,WAAK,MAAM,iBAAiB,SAAS,CAAC,MAAM;AACxC,aAAK,SAAU;AAEf,aAAK,WAAW;AAChB,aAAK,oBAAqB;AAE1B,aAAK,gBAAgB;AACrB,aAAK,UAAU,EAAE,OAAO;AACxB,aAAK,SAAU;AAEf,cAAM,oBAAoB,MAAM,kBAAkB;AAAA,MAClE,CAAa;AAED,WAAK,MAAM,iBAAiB,UAAU,CAAC,MAAM;AACzC,cAAM,oBAAoB,MAAM,mBAAmB;AAAA,MACnE,CAAa;AAED,WAAK,iBAAiB,WAAW,CAAC,MAAM;AACpC,aAAK,UAAU;AACf,aAAK,WAAW;AAEhB,aAAK,mBAAoB;AAAA,MACzC,CAAa;AAED,WAAK,SAAU;AAEf,UAAI,KAAK,SAAS;AACd,aAAK,mBAAoB;AAAA,MACzC;AAAA,IACA;AAAA,EACA;AAAA;AAAA;AAAA;AAAA,EAKI,WAAW;AACP,SAAK,aAAa;AAAA,MACd,MAAM;AAAA,MACN,SAAS,KAAK;AAAA,MACd,UAAU,KAAK;AAAA,MACf,UAAU,KAAK;AAAA,MACf,SAAS,KAAK;AAAA,IAC1B,CAAS;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKI,mBAAmB;AACf,UAAM,cAAc,KAAK,KAAK;AAAA,EACtC;AACA;AAxPI;AC3BJ,OAAO,OAAO,cAAc,MAAM;"}
|
package/dist/wje-toolbar.js
CHANGED
|
@@ -36,6 +36,7 @@ class Toolbar extends WJElement {
|
|
|
36
36
|
*/
|
|
37
37
|
setupAttributes() {
|
|
38
38
|
this.isShadowRoot = "open";
|
|
39
|
+
this.syncAria();
|
|
39
40
|
}
|
|
40
41
|
/**
|
|
41
42
|
* Draws the component for the toolbar.
|
|
@@ -55,6 +56,19 @@ class Toolbar extends WJElement {
|
|
|
55
56
|
fragment.appendChild(native);
|
|
56
57
|
return fragment;
|
|
57
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Sync ARIA attributes on host.
|
|
61
|
+
*/
|
|
62
|
+
syncAria() {
|
|
63
|
+
if (!this.hasAttribute("role")) {
|
|
64
|
+
this.setAriaState({ role: "toolbar" });
|
|
65
|
+
}
|
|
66
|
+
const ariaLabel = this.getAttribute("aria-label");
|
|
67
|
+
const label = this.getAttribute("label");
|
|
68
|
+
if (!ariaLabel && label) {
|
|
69
|
+
this.setAriaState({ label });
|
|
70
|
+
}
|
|
71
|
+
}
|
|
58
72
|
}
|
|
59
73
|
Toolbar.define("wje-toolbar", Toolbar);
|
|
60
74
|
export {
|
package/dist/wje-toolbar.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wje-toolbar.js","sources":["../packages/wje-toolbar/toolbar.element.js","../packages/wje-toolbar/toolbar.js"],"sourcesContent":["import { default as WJElement } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * `Toolbar` is a custom web component that represents a toolbar.\n * @summary This element represents a toolbar.\n * @documentation https://elements.webjet.sk/components/toolbar\n * @status stable\n * @augments {WJElement}\n * @csspart native - The native toolbar wrapper.\n * @slot start - The start slot for the toolbar.\n * @slot end - The end slot for the toolbar.\n * @cssproperty [--wje-toolbar-background=var(--wje-background)] - Specifies the background color of the toolbar. Accepts any valid CSS color value, such as `hex`, `rgb`, or `CSS variable`.\n * @cssproperty [--wje-toolbar-height=auto] - Defines the height of the toolbar. If set to `auto`, the height adjusts based on the content.\n * @cssproperty [--wje-toolbar-min-height=70px] - Sets the minimum height of the toolbar. Ensures the toolbar maintains a consistent minimum size.\n * @cssproperty [--wje-toolbar-padding-top=1rem] - Specifies the padding at the top of the toolbar. Accepts any valid CSS length unit.\n * @cssproperty [--wje-toolbar-padding-bottom=1rem] - Specifies the padding at the bottom of the toolbar. Helps create spacing between the content and the bottom edge.\n * @cssproperty [--wje-toolbar-padding-inline=1.5rem] - Defines the horizontal padding (left and right) of the toolbar. Creates consistent spacing on both sides.\n * @cssproperty [--wje-toolbar-border-color=var(--wje-border-color)] - Sets the color of the toolbar's border. Accepts any valid CSS color value.\n * @cssproperty [--wje-toolbar-top=0] - Specifies the vertical position of the toolbar relative to its container. Useful for fixed or sticky toolbars.\n * @tag wje-toolbar\n */\n\nexport default class Toolbar extends WJElement {\n /**\n * Creates an instance of Toolbar.\n */\n constructor() {\n super();\n }\n\n /**\n * The class name for the component.\n * @type {string}\n */\n className = 'Toolbar';\n\n /**\n * Returns the CSS stylesheet for the component.\n * @static\n * @returns {CSSStyleSheet} The CSS stylesheet\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Returns the list of observed attributes.\n * @static\n * @returns {Array} An empty array\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 for the toolbar.\n * @returns {object} Document fragment\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('div');\n native.setAttribute('part', 'native');\n native.classList.add('native-toolbar');\n\n let start = document.createElement('slot');\n start.setAttribute('name', 'start');\n\n let end = document.createElement('slot');\n end.setAttribute('name', 'end');\n\n native.appendChild(start);\n native.appendChild(end);\n fragment.appendChild(native);\n\n return fragment;\n }\n}\n","import Toolbar from './toolbar.element.js';\n\nexport default Toolbar;\n\nToolbar.define('wje-toolbar', Toolbar);\n"],"names":[],"mappings":";;;;;AAuBe,MAAM,gBAAgB,UAAU;AAAA;AAAA;AAAA;AAAA,EAI3C,cAAc;AACV,UAAO;AAOX;AAAA;AAAA;AAAA;AAAA,qCAAY;AAAA,EANhB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaI,WAAW,gBAAgB;AACvB,WAAO;AAAA,EACf;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOI,WAAW,qBAAqB;AAC5B,WAAO,CAAE;AAAA,EACjB;AAAA;AAAA;AAAA;AAAA,EAKI,kBAAkB;AACd,SAAK,eAAe;AAAA,
|
|
1
|
+
{"version":3,"file":"wje-toolbar.js","sources":["../packages/wje-toolbar/toolbar.element.js","../packages/wje-toolbar/toolbar.js"],"sourcesContent":["import { default as WJElement } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * `Toolbar` is a custom web component that represents a toolbar.\n * @summary This element represents a toolbar.\n * @documentation https://elements.webjet.sk/components/toolbar\n * @status stable\n * @augments {WJElement}\n * @csspart native - The native toolbar wrapper.\n * @slot start - The start slot for the toolbar.\n * @slot end - The end slot for the toolbar.\n * @cssproperty [--wje-toolbar-background=var(--wje-background)] - Specifies the background color of the toolbar. Accepts any valid CSS color value, such as `hex`, `rgb`, or `CSS variable`.\n * @cssproperty [--wje-toolbar-height=auto] - Defines the height of the toolbar. If set to `auto`, the height adjusts based on the content.\n * @cssproperty [--wje-toolbar-min-height=70px] - Sets the minimum height of the toolbar. Ensures the toolbar maintains a consistent minimum size.\n * @cssproperty [--wje-toolbar-padding-top=1rem] - Specifies the padding at the top of the toolbar. Accepts any valid CSS length unit.\n * @cssproperty [--wje-toolbar-padding-bottom=1rem] - Specifies the padding at the bottom of the toolbar. Helps create spacing between the content and the bottom edge.\n * @cssproperty [--wje-toolbar-padding-inline=1.5rem] - Defines the horizontal padding (left and right) of the toolbar. Creates consistent spacing on both sides.\n * @cssproperty [--wje-toolbar-border-color=var(--wje-border-color)] - Sets the color of the toolbar's border. Accepts any valid CSS color value.\n * @cssproperty [--wje-toolbar-top=0] - Specifies the vertical position of the toolbar relative to its container. Useful for fixed or sticky toolbars.\n * @tag wje-toolbar\n */\n\nexport default class Toolbar extends WJElement {\n /**\n * Creates an instance of Toolbar.\n */\n constructor() {\n super();\n }\n\n /**\n * The class name for the component.\n * @type {string}\n */\n className = 'Toolbar';\n\n /**\n * Returns the CSS stylesheet for the component.\n * @static\n * @returns {CSSStyleSheet} The CSS stylesheet\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Returns the list of observed attributes.\n * @static\n * @returns {Array} An empty array\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 * Draws the component for the toolbar.\n * @returns {object} Document fragment\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('div');\n native.setAttribute('part', 'native');\n native.classList.add('native-toolbar');\n\n let start = document.createElement('slot');\n start.setAttribute('name', 'start');\n\n let end = document.createElement('slot');\n end.setAttribute('name', 'end');\n\n native.appendChild(start);\n native.appendChild(end);\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: 'toolbar' });\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","import Toolbar from './toolbar.element.js';\n\nexport default Toolbar;\n\nToolbar.define('wje-toolbar', Toolbar);\n"],"names":[],"mappings":";;;;;AAuBe,MAAM,gBAAgB,UAAU;AAAA;AAAA;AAAA;AAAA,EAI3C,cAAc;AACV,UAAO;AAOX;AAAA;AAAA;AAAA;AAAA,qCAAY;AAAA,EANhB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaI,WAAW,gBAAgB;AACvB,WAAO;AAAA,EACf;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOI,WAAW,qBAAqB;AAC5B,WAAO,CAAE;AAAA,EACjB;AAAA;AAAA;AAAA;AAAA,EAKI,kBAAkB;AACd,SAAK,eAAe;AACpB,SAAK,SAAU;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,OAAO;AACH,QAAI,WAAW,SAAS,uBAAwB;AAEhD,QAAI,SAAS,SAAS,cAAc,KAAK;AACzC,WAAO,aAAa,QAAQ,QAAQ;AACpC,WAAO,UAAU,IAAI,gBAAgB;AAErC,QAAI,QAAQ,SAAS,cAAc,MAAM;AACzC,UAAM,aAAa,QAAQ,OAAO;AAElC,QAAI,MAAM,SAAS,cAAc,MAAM;AACvC,QAAI,aAAa,QAAQ,KAAK;AAE9B,WAAO,YAAY,KAAK;AACxB,WAAO,YAAY,GAAG;AACtB,aAAS,YAAY,MAAM;AAE3B,WAAO;AAAA,EACf;AAAA;AAAA;AAAA;AAAA,EAKI,WAAW;AACP,QAAI,CAAC,KAAK,aAAa,MAAM,GAAG;AAC5B,WAAK,aAAa,EAAE,MAAM,UAAS,CAAE;AAAA,IACjD;AAEQ,UAAM,YAAY,KAAK,aAAa,YAAY;AAChD,UAAM,QAAQ,KAAK,aAAa,OAAO;AACvC,QAAI,CAAC,aAAa,OAAO;AACrB,WAAK,aAAa,EAAE,OAAO;AAAA,IACvC;AAAA,EACA;AACA;ACjGA,QAAQ,OAAO,eAAe,OAAO;"}
|
|
@@ -13,6 +13,7 @@ import { default as WJElement } from '../wje-element/element.js';
|
|
|
13
13
|
* @tag wje-tooltip
|
|
14
14
|
*/
|
|
15
15
|
export default class Tooltip extends WJElement {
|
|
16
|
+
static _instanceId: number;
|
|
16
17
|
/**
|
|
17
18
|
* Returns the CSS stylesheet for the component.
|
|
18
19
|
* @static
|
|
@@ -25,6 +26,7 @@ export default class Tooltip extends WJElement {
|
|
|
25
26
|
* @returns {Array} An array of observed attributes
|
|
26
27
|
*/
|
|
27
28
|
static get observedAttributes(): any[];
|
|
29
|
+
_instanceId: number;
|
|
28
30
|
/**
|
|
29
31
|
* Dependencies of the Button element.
|
|
30
32
|
* @type {object}
|
|
@@ -52,6 +54,7 @@ export default class Tooltip extends WJElement {
|
|
|
52
54
|
* Draws the component for the tooltip.
|
|
53
55
|
*/
|
|
54
56
|
afterDraw(): void;
|
|
57
|
+
onSlotChange: () => void;
|
|
55
58
|
dispatch(customEvent: any): Promise<any>;
|
|
56
59
|
beforeShow(): string;
|
|
57
60
|
afterShow(): boolean;
|
package/dist/wje-tooltip.js
CHANGED
|
@@ -3,10 +3,10 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { en
|
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
4
|
import WJElement from "./wje-element.js";
|
|
5
5
|
import "./wje-popup.js";
|
|
6
|
-
import { P as Popup } from "./popup.element-
|
|
6
|
+
import { P as Popup } from "./popup.element-Cl6QeG8M.js";
|
|
7
7
|
import { event } from "./event.js";
|
|
8
8
|
const styles = "/*\n[ WJ Tooltip ]\n*/\n\n.native-tooltip {\n display: flex;\n align-items: center;\n padding: var(--wje-tooltip-spacing);\n color: var(--wje-tooltip-color);\n background-color: var(--wje-tooltip-background);\n font-weight: var(--wje-tooltip-font-weight);\n font-size: var(--wje-tooltip-font-size);\n border-radius: var(--wje-tooltip-border-radius);\n line-height: var(--wje-tooltip-line-height);\n box-sizing: border-box;\n box-shadow: var(--wje-tooltip-shadow);\n}\n\n::slotted([slot='start']) {\n margin: 0 0.3rem 0 0;\n}\n\n::slotted([slot='end']) {\n margin: 0 0 0 0.3rem;\n}\n\n.arrow {\n position: absolute;\n width: 10px;\n height: 10px;\n background: var(--wje-tooltip-arrow-color);\n transform: rotate(45deg);\n}\n";
|
|
9
|
-
class
|
|
9
|
+
const _Tooltip = class _Tooltip extends WJElement {
|
|
10
10
|
/**
|
|
11
11
|
* Creates an instance of Tooltip.
|
|
12
12
|
*/
|
|
@@ -60,6 +60,7 @@ class Tooltip extends WJElement {
|
|
|
60
60
|
this.classList.remove("active");
|
|
61
61
|
this.popup.hide();
|
|
62
62
|
});
|
|
63
|
+
this._instanceId = ++_Tooltip._instanceId;
|
|
63
64
|
}
|
|
64
65
|
/**
|
|
65
66
|
* Set active attribute for the tooltip element.
|
|
@@ -97,6 +98,7 @@ class Tooltip extends WJElement {
|
|
|
97
98
|
*/
|
|
98
99
|
setupAttributes() {
|
|
99
100
|
this.isShadowRoot = "open";
|
|
101
|
+
this.setAriaState({ role: "tooltip" });
|
|
100
102
|
}
|
|
101
103
|
/**
|
|
102
104
|
* Draws the component for the tooltip.
|
|
@@ -108,6 +110,7 @@ class Tooltip extends WJElement {
|
|
|
108
110
|
popup.setAttribute("placement", this.placement || "top");
|
|
109
111
|
popup.setAttribute("offset", this.offset || "0");
|
|
110
112
|
let slot = document.createElement("slot");
|
|
113
|
+
slot.setAttribute("name", "anchor");
|
|
111
114
|
slot.setAttribute("slot", "anchor");
|
|
112
115
|
let arrow = document.createElement("div");
|
|
113
116
|
arrow.classList.add("arrow");
|
|
@@ -137,10 +140,27 @@ class Tooltip extends WJElement {
|
|
|
137
140
|
* Draws the component for the tooltip.
|
|
138
141
|
*/
|
|
139
142
|
afterDraw() {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
143
|
+
const resolveAnchor = () => {
|
|
144
|
+
let anchorEl2 = this.mySlot.assignedElements()[0];
|
|
145
|
+
if (!anchorEl2) {
|
|
146
|
+
anchorEl2 = this.querySelector(":scope > *:not([slot])");
|
|
147
|
+
if (anchorEl2) anchorEl2.setAttribute("slot", "anchor");
|
|
148
|
+
}
|
|
149
|
+
if (this.selector) {
|
|
150
|
+
anchorEl2 = this.checkSelector(anchorEl2);
|
|
151
|
+
}
|
|
152
|
+
if (!anchorEl2) return null;
|
|
153
|
+
const tooltipId = this.id || `wje-tooltip-${this._instanceId}`;
|
|
154
|
+
if (!this.id) this.id = tooltipId;
|
|
155
|
+
anchorEl2.setAttribute("aria-describedby", tooltipId);
|
|
156
|
+
return anchorEl2;
|
|
157
|
+
};
|
|
158
|
+
this.onSlotChange = () => {
|
|
159
|
+
resolveAnchor();
|
|
160
|
+
};
|
|
161
|
+
this.mySlot.addEventListener("slotchange", this.onSlotChange);
|
|
162
|
+
this.onSlotChange();
|
|
163
|
+
let anchorEl = resolveAnchor();
|
|
144
164
|
if (!anchorEl) return;
|
|
145
165
|
event.addListener(anchorEl, "mouseenter", null, this.onShow);
|
|
146
166
|
event.addListener(anchorEl, "mouseleave", null, this.onHide);
|
|
@@ -148,10 +168,12 @@ class Tooltip extends WJElement {
|
|
|
148
168
|
event.addListener(this, "wje-dropdown:close", null, this.onShow);
|
|
149
169
|
}
|
|
150
170
|
afterDisconnect() {
|
|
171
|
+
var _a;
|
|
151
172
|
event.removeListener(this, "wje-dropdown:open", null, this.onHide);
|
|
152
173
|
event.removeListener(this, "wje-dropdown:close", null, this.onShow);
|
|
153
174
|
event.removeListener(this, "mouseenter", null, this.onShow);
|
|
154
175
|
event.removeListener(this, "mouseleave", null, this.onHide);
|
|
176
|
+
(_a = this.mySlot) == null ? void 0 : _a.removeEventListener("slotchange", this.onSlotChange);
|
|
155
177
|
}
|
|
156
178
|
dispatch(customEvent) {
|
|
157
179
|
return new Promise((resolve) => {
|
|
@@ -179,7 +201,9 @@ class Tooltip extends WJElement {
|
|
|
179
201
|
}
|
|
180
202
|
return newAnchorEl;
|
|
181
203
|
}
|
|
182
|
-
}
|
|
204
|
+
};
|
|
205
|
+
__publicField(_Tooltip, "_instanceId", 0);
|
|
206
|
+
let Tooltip = _Tooltip;
|
|
183
207
|
Tooltip.define("wje-tooltip", Tooltip);
|
|
184
208
|
export {
|
|
185
209
|
Tooltip as default
|