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-checkbox.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wje-checkbox.js","sources":["../packages/wje-checkbox/checkbox.element.js","../packages/wje-checkbox/checkbox.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 * @summary This method dispatches a custom event named \"wje-toggle:change\".\n * It is triggered when the input event is fired, which happens when the state of the checkbox changes.\n * The event is dispatched on the current instance of the Checkbox class.\n * @documentation https://elements.webjet.sk/components/checkbox\n * @status stable\n * @augments {FormAssociatedElement}\n * @slot - The checkbox main content.\n * @csspart native - The component's native wrapper.\n * @cssproperty [--wje-checkbox-border-radius=--wje-border-radius-medium] - Border radius of the component;\n * @cssproperty [--wje-checkbox-border-width=1px] - Border width of the component;\n * @cssproperty [--wje-checkbox-border-style=solid] - Border style of the component;\n * @cssproperty [--wje-checkbox-border-color=--wje-color-contrast-1] - Border color of the component;\n * @cssproperty [--wje-checkbox-margin-inline=0] - Margin inline of the component;\n */\nexport default class Checkbox extends FormAssociatedElement {\n\t#internalValue;\n\t/**\n\t * Checkbox constructor method.\n\t */\n\tconstructor() {\n\t\tsuper();\n\n\t\tthis.invalid = false;\n\t\tthis.pristine = true;\n\t\tthis._valueOff = 'off';\n\t}\n\n\t/**\n\t * Setter for the value attribute.\n\t * @param {string} value The value to set.\n\t */\n\tset value(value) {\n\t\tthis.#internalValue = value;\n\t\tif (this.input) {\n\t\t\tthis.input.value = value;\n\t\t}\n\t}\n\n\t/**\n\t * Getter for the value attribute.\n\t * @returns {string} The value of the attribute.\n\t */\n\tget value() {\n\t\treturn this.#internalValue ?? this.getAttribute('value') ?? 'on';\n\t}\n\n\t/**\n\t * Getter for the customErrorDisplay attribute.\n\t * @returns {boolean} Whether the attribute is present.\n\t */\n\tget customErrorDisplay() {\n\t\treturn this.hasAttribute('custom-error-display');\n\t}\n\n\t/**\n\t * Getter for the validateOnChange attribute.\n\t * @returns {boolean} Whether the attribute is present.\n\t */\n\tget validateOnChange() {\n\t\treturn this.hasAttribute('validate-on-change');\n\t}\n\n\t/**\n\t * Setter for the defaultValue attribute.\n\t * This method sets the 'value' attribute of the custom input element to the provided value.\n\t * The 'value' attribute represents the default value of the input element.\n\t * @param {string} value The value to set as the default value.\n\t */\n\tset defaultValue(value) {\n\t\tthis.setAttribute('value', value);\n\t}\n\n\t/**\n\t * Getter for the defaultValue attribute.\n\t * This method retrieves the 'value' attribute of the custom input element.\n\t * The 'value' attribute represents the default value of the input element.\n\t * If the 'value' attribute is not set, it returns an empty string.\n\t * @returns {string} The default value of the input element.\n\t */\n\tget defaultValue() {\n\t\treturn this.getAttribute('value') ?? '';\n\t}\n\n\t/**\n\t * Sets or removes the 'indeterminate' attribute for the object.\n\t * This property typically reflects the visual or functional state where\n\t * the component is neither fully active nor inactive.\n\t * @param {boolean} value A boolean where `true` indicates the 'indeterminate'\n\t * state should be set, and `false` removes it.\n\t */\n\tset indeterminate(value) {\n\t\tif (value) {\n\t\t\tthis.setAttribute('indeterminate', '');\n\t\t} else {\n\t\t\tthis.removeAttribute('indeterminate');\n\t\t}\n\t}\n\n\t/**\n\t * Retrieves the current state of the 'indeterminate' attribute.\n\t *\n\t * The 'indeterminate' attribute is typically used to signify a state\n\t * where a checkbox is neither checked nor unchecked, such as a partially\n\t * selected state.\n\t * @returns {boolean} Returns true if the 'indeterminate' attribute is present; otherwise, false.\n\t */\n\tget indeterminate() {\n\t\treturn this.hasAttribute('indeterminate');\n\t}\n\n\t/**\n\t * Set checked attribute.\n\t * @param {boolean} value true if the toggle is checked, false otherwise\n\t */\n\tset checked(value) {\n\t\tif (value) {\n\t\t\tthis.setAttribute('checked', '');\n\t\t\tthis.internals.setFormValue(this.value); // len ak je checked\n\t\t} else {\n\t\t\tthis.removeAttribute('checked');\n\t\t\tthis.internals.setFormValue(this._valueOff); // ak nie je checked, nič sa neposiela\n\t\t}\n\t\tif (this.input) {\n\t\t\tthis.input.checked = value;\n\t\t}\n\t}\n\n\t/**\n\t * Get checked attribute.\n\t * @returns {boolean} true if the toggle is checked, false otherwise\n\t */\n\tget checked() {\n\t\treturn this.hasAttribute('checked');\n\t}\n\n\t/**\n\t * The class name for the Checkbox.\n\t */\n\tclassName = 'Checkbox';\n\n\t/**\n\t * Getter for the CSS stylesheet.\n\t * @returns {string} The CSS stylesheet.\n\t */\n\tstatic get cssStyleSheet() {\n\t\treturn styles;\n\t}\n\n\tstatic get observedAttributes() {\n\t\treturn ['checked', 'disabled', 'value', 'indeterminate'];\n\t}\n\n\tattributeChangedCallback(name, oldValue, newValue) {\n\t\tif (!this.input) return;\n\t\tif (name === 'checked') {\n\t\t\tconst isChecked = this.hasAttribute('checked');\n\t\t\tthis.input.checked = isChecked;\n\t\t\t// Reflect into form value\n\t\t\tif (isChecked) {\n\t\t\t\tthis.internals.setFormValue(this.value);\n\t\t\t} else {\n\t\t\t\tthis.internals.setFormValue(this._valueOff);\n\t\t\t}\n\t\t} else if (name === 'disabled') {\n\t\t\tthis.input.disabled = this.hasAttribute('disabled');\n\t\t} else if (name === 'indeterminate') {\n\t\t\tthis.input.indeterminate = this.hasAttribute('indeterminate');\n\t\t} else if (name === 'value') {\n\t\t\t// keep payload in sync; do not toggle checked here\n\t\t\tthis.#internalValue = newValue ?? undefined;\n\t\t\tthis.input.value = this.value;\n\t\t\t// If currently checked, update the submitted payload\n\t\t\tif (this.input.checked) {\n\t\t\t\tthis.internals.setFormValue(this.value);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Sets up the attributes for the checkbox.\n\t */\n\tsetupAttributes() {\n\t\tthis.isShadowRoot = 'open';\n\t\t// if some value was set via value setter then dont use default value\n\t\tif (this.pristine) {\n\t\t\tthis.value = this.#internalValue;\n\t\t\tthis.pristine = false;\n\t\t}\n\t}\n\n\t/**\n\t * Draws the checkbox element.\n\t * @returns {DocumentFragment} The created fragment.\n\t */\n\tdraw() {\n\t\tlet fragment = document.createDocumentFragment();\n\n\t\tlet native = document.createElement('div');\n\t\tnative.setAttribute('part', 'native');\n\t\tnative.classList.add('native-checkbox');\n\n\t\tlet input = document.createElement('input');\n\t\tinput.type = 'checkbox';\n\t\tinput.id = 'checkbox';\n\t\tinput.name = this.name || 'checkbox';\n\t\tinput.checked = this.checked;\n\t\tinput.disabled = this.disabled;\n\t\tinput.indeterminate = this.indeterminate;\n\t\tinput.required = this.required;\n\t\tinput.value = this.value;\n\n\t\tlet label = document.createElement('label');\n\t\tlabel.htmlFor = 'checkbox';\n\t\tlabel.innerHTML = '<slot></slot>';\n\n\t\t// Error\n\t\tlet errorSlot = document.createElement('slot');\n\t\terrorSlot.setAttribute('name', 'error');\n\n\t\tlet error = document.createElement('div');\n\t\terror.setAttribute('slot', 'error');\n\n\t\t// APPEND\n\t\tnative.append(input);\n\t\tnative.append(label);\n\t\tnative.append(errorSlot);\n\n\t\tthis.append(error);\n\n\t\tthis.input = input;\n\n\t\tfragment.appendChild(native);\n\n\t\treturn fragment;\n\t}\n\n\t/**\n\t * Adds an event listener after drawing the checkbox.\n\t */\n\tafterDraw() {\n\t\tthis.internals.setFormValue(this.checked ? this.value : this._valueOff); // Set initial form value based on checked state\n\n\t\tif (!this.disabled) {\n\t\t\tthis.input.addEventListener('input', (e) => {\n\t\t\t\tthis.validate();\n\n\t\t\t\tthis.pristine = false;\n\t\t\t\tthis.propagateValidation();\n\n\t\t\t\t// User interaction decides the checked state; value stays as payload\n\t\t\t\tthis.indeterminate = false;\n\t\t\t\tthis.checked = e.target.checked;\n\n\t\t\t\tevent.dispatchCustomEvent(this, 'wje-toggle:input');\n\t\t\t});\n\n\t\t\tthis.input.addEventListener('change', (e) => {\n\t\t\t\tevent.dispatchCustomEvent(this, 'wje-toggle:change');\n\t\t\t});\n\n\t\t\tthis.addEventListener('invalid', (e) => {\n\t\t\t\tthis.invalid = true;\n\t\t\t\tthis.pristine = false;\n\n\t\t\t\tthis.showInvalidMessage();\n\t\t\t});\n\n\t\t\tthis.validate();\n\n\t\t\tif (this.invalid) {\n\t\t\t\tthis.showInvalidMessage();\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Removes the event listener when the checkbox is disconnected.\n\t */\n\tbeforeDisconnect() {\n\t\tevent.removeElement(this.input);\n\t}\n}\n","import { default as WJElement } from '../wje-element/element.js';\nimport Checkbox from './checkbox.element.js';\n\n// export * from \"./checkbox.element.js\";\nexport default Checkbox;\n\nWJElement.define('wje-checkbox', Checkbox);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAmBe,MAAM,iBAAiB,sBAAsB;AAAA;AAAA;AAAA;AAAA,EAK3D,cAAc;AACb,UAAO;AALR;AA2HA;AAAA;AAAA;AAAA,qCAAY;AApHX,SAAK,UAAU;AACf,SAAK,WAAW;AAChB,SAAK,YAAY;AAAA,EACnB;AAAA;AAAA;AAAA;AAAA;A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AAA;AAAA;AAAA;AAAA,EAKC,mBAAmB;AAClB,UAAM,cAAc,KAAK,KAAK;AAAA,EAChC;AACA;AA1QC;ACdD,UAAU,OAAO,gBAAgB,QAAQ;"}
|
|
1
|
+
{"version":3,"file":"wje-checkbox.js","sources":["../packages/wje-checkbox/checkbox.element.js","../packages/wje-checkbox/checkbox.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 * @summary This method dispatches a custom event named \"wje-toggle:change\".\n * It is triggered when the input event is fired, which happens when the state of the checkbox changes.\n * The event is dispatched on the current instance of the Checkbox class.\n * @documentation https://elements.webjet.sk/components/checkbox\n * @status stable\n * @augments {FormAssociatedElement}\n * @slot - The checkbox main content.\n * @csspart native - The component's native wrapper.\n * @cssproperty [--wje-checkbox-border-radius=--wje-border-radius-medium] - Border radius of the component;\n * @cssproperty [--wje-checkbox-border-width=1px] - Border width of the component;\n * @cssproperty [--wje-checkbox-border-style=solid] - Border style of the component;\n * @cssproperty [--wje-checkbox-border-color=--wje-color-contrast-1] - Border color of the component;\n * @cssproperty [--wje-checkbox-margin-inline=0] - Margin inline of the component;\n */\nexport default class Checkbox extends FormAssociatedElement {\n\t#internalValue;\n\t/**\n\t * Checkbox constructor method.\n\t */\n\tconstructor() {\n\t\tsuper();\n\n\t\tthis.invalid = false;\n\t\tthis.pristine = true;\n\t\tthis._valueOff = 'off';\n\t}\n\n\t/**\n\t * Setter for the value attribute.\n\t * @param {string} value The value to set.\n\t */\n\tset value(value) {\n\t\tthis.#internalValue = value;\n\t\tif (this.input) {\n\t\t\tthis.input.value = value;\n\t\t}\n\t}\n\n\t/**\n\t * Getter for the value attribute.\n\t * @returns {string} The value of the attribute.\n\t */\n\tget value() {\n\t\treturn this.#internalValue ?? this.getAttribute('value') ?? 'on';\n\t}\n\n\t/**\n\t * Getter for the customErrorDisplay attribute.\n\t * @returns {boolean} Whether the attribute is present.\n\t */\n\tget customErrorDisplay() {\n\t\treturn this.hasAttribute('custom-error-display');\n\t}\n\n\t/**\n\t * Getter for the validateOnChange attribute.\n\t * @returns {boolean} Whether the attribute is present.\n\t */\n\tget validateOnChange() {\n\t\treturn this.hasAttribute('validate-on-change');\n\t}\n\n\t/**\n\t * Setter for the label attribute.\n\t * @param {string} value The label to set.\n\t */\n\tset label(value) {\n\t\tif (value === null || value === undefined) {\n\t\t\tthis.removeAttribute('label');\n\t\t} else {\n\t\t\tthis.setAttribute('label', value);\n\t\t}\n\t}\n\n\t/**\n\t * Getter for the label attribute.\n\t * @returns {string|null}\n\t */\n\tget label() {\n\t\treturn this.getAttribute('label');\n\t}\n\n\t/**\n\t * Setter for the defaultValue attribute.\n\t * This method sets the 'value' attribute of the custom input element to the provided value.\n\t * The 'value' attribute represents the default value of the input element.\n\t * @param {string} value The value to set as the default value.\n\t */\n\tset defaultValue(value) {\n\t\tthis.setAttribute('value', value);\n\t}\n\n\t/**\n\t * Getter for the defaultValue attribute.\n\t * This method retrieves the 'value' attribute of the custom input element.\n\t * The 'value' attribute represents the default value of the input element.\n\t * If the 'value' attribute is not set, it returns an empty string.\n\t * @returns {string} The default value of the input element.\n\t */\n\tget defaultValue() {\n\t\treturn this.getAttribute('value') ?? '';\n\t}\n\n\t/**\n\t * Sets or removes the 'indeterminate' attribute for the object.\n\t * This property typically reflects the visual or functional state where\n\t * the component is neither fully active nor inactive.\n\t * @param {boolean} value A boolean where `true` indicates the 'indeterminate'\n\t * state should be set, and `false` removes it.\n\t */\n\tset indeterminate(value) {\n\t\tif (value) {\n\t\t\tthis.setAttribute('indeterminate', '');\n\t\t} else {\n\t\t\tthis.removeAttribute('indeterminate');\n\t\t}\n\t}\n\n\t/**\n\t * Retrieves the current state of the 'indeterminate' attribute.\n\t *\n\t * The 'indeterminate' attribute is typically used to signify a state\n\t * where a checkbox is neither checked nor unchecked, such as a partially\n\t * selected state.\n\t * @returns {boolean} Returns true if the 'indeterminate' attribute is present; otherwise, false.\n\t */\n\tget indeterminate() {\n\t\treturn this.hasAttribute('indeterminate');\n\t}\n\n\t/**\n\t * Set checked attribute.\n\t * @param {boolean} value true if the toggle is checked, false otherwise\n\t */\n\tset checked(value) {\n\t\tif (value) {\n\t\t\tthis.setAttribute('checked', '');\n\t\t\tthis.internals.setFormValue(this.value); // len ak je checked\n\t\t} else {\n\t\t\tthis.removeAttribute('checked');\n\t\t\tthis.internals.setFormValue(this._valueOff); // ak nie je checked, nič sa neposiela\n\t\t}\n\t\tif (this.input) {\n\t\t\tthis.input.checked = value;\n\t\t}\n\t}\n\n\t/**\n\t * Get checked attribute.\n\t * @returns {boolean} true if the toggle is checked, false otherwise\n\t */\n\tget checked() {\n\t\treturn this.hasAttribute('checked');\n\t}\n\n\t/**\n\t * The class name for the Checkbox.\n\t */\n\tclassName = 'Checkbox';\n\n\t/**\n\t * Getter for the CSS stylesheet.\n\t * @returns {string} The CSS stylesheet.\n\t */\n\tstatic get cssStyleSheet() {\n\t\treturn styles;\n\t}\n\n\tstatic get observedAttributes() {\n\t\treturn ['checked', 'disabled', 'value', 'indeterminate', 'required', 'invalid', 'label'];\n\t}\n\n\tattributeChangedCallback(name, oldValue, newValue) {\n\t\tsuper.attributeChangedCallback?.(name, oldValue, newValue);\n\t\tif (!this.input) {\n\t\t\tthis.syncAria();\n\t\t\treturn;\n\t\t}\n\t\tif (name === 'checked') {\n\t\t\tconst isChecked = this.hasAttribute('checked');\n\t\t\tthis.input.checked = isChecked;\n\t\t\t// Reflect into form value\n\t\t\tif (isChecked) {\n\t\t\t\tthis.internals.setFormValue(this.value);\n\t\t\t} else {\n\t\t\t\tthis.internals.setFormValue(this._valueOff);\n\t\t\t}\n\t\t} else if (name === 'disabled') {\n\t\t\tthis.input.disabled = this.hasAttribute('disabled');\n\t\t} else if (name === 'indeterminate') {\n\t\t\tthis.input.indeterminate = this.hasAttribute('indeterminate');\n\t\t} else if (name === 'value') {\n\t\t\t// keep payload in sync; do not toggle checked here\n\t\t\tthis.#internalValue = newValue ?? undefined;\n\t\t\tthis.input.value = this.value;\n\t\t\t// If currently checked, update the submitted payload\n\t\t\tif (this.input.checked) {\n\t\t\t\tthis.internals.setFormValue(this.value);\n\t\t\t}\n\t\t}\n\t\tthis.syncAria();\n\t}\n\n\t/**\n\t * Sets up the attributes for the checkbox.\n\t */\n\tsetupAttributes() {\n\t\tthis.isShadowRoot = 'open';\n\t\t// if some value was set via value setter then dont use default value\n\t\tif (this.pristine) {\n\t\t\tthis.value = this.#internalValue;\n\t\t\tthis.pristine = false;\n\t\t}\n\t\tthis.syncAria();\n\t}\n\n\t/**\n\t * Draws the checkbox element.\n\t * @returns {DocumentFragment} The created fragment.\n\t */\n\tdraw() {\n\t\tlet fragment = document.createDocumentFragment();\n\n\t\tlet native = document.createElement('div');\n\t\tnative.setAttribute('part', 'native');\n\t\tnative.classList.add('native-checkbox');\n\n\t\tlet input = document.createElement('input');\n\t\tinput.type = 'checkbox';\n\t\tinput.id = 'checkbox';\n\t\tinput.name = this.name || 'checkbox';\n\t\tinput.checked = this.checked;\n\t\tinput.disabled = this.disabled;\n\t\tinput.indeterminate = this.indeterminate;\n\t\tinput.required = this.required;\n\t\tinput.value = this.value;\n\n\t\tlet label = document.createElement('label');\n\t\tlabel.htmlFor = 'checkbox';\n\t\tlabel.innerHTML = '<slot></slot>';\n\n\t\t// Error\n\t\tlet errorSlot = document.createElement('slot');\n\t\terrorSlot.setAttribute('name', 'error');\n\n\t\tlet error = document.createElement('div');\n\t\terror.setAttribute('slot', 'error');\n\n\t\t// APPEND\n\t\tnative.append(input);\n\t\tnative.append(label);\n\t\tnative.append(errorSlot);\n\n\t\tthis.append(error);\n\n\t\tthis.input = input;\n\n\t\tfragment.appendChild(native);\n\n\t\treturn fragment;\n\t}\n\n\t/**\n\t * Adds an event listener after drawing the checkbox.\n\t */\n\tafterDraw() {\n\t\tthis.internals.setFormValue(this.checked ? this.value : this._valueOff); // Set initial form value based on checked state\n\t\tthis.syncAria();\n\n\t\tif (!this.disabled) {\n\t\t\tthis.input.addEventListener('input', (e) => {\n\t\t\t\tthis.validate();\n\n\t\t\t\tthis.pristine = false;\n\t\t\t\tthis.propagateValidation();\n\n\t\t\t\t// User interaction decides the checked state; value stays as payload\n\t\t\t\tthis.indeterminate = false;\n\t\t\t\tthis.checked = e.target.checked;\n\t\t\t\tthis.syncAria();\n\n\t\t\t\tevent.dispatchCustomEvent(this, 'wje-toggle:input');\n\t\t\t});\n\n\t\t\tthis.input.addEventListener('change', (e) => {\n\t\t\t\tevent.dispatchCustomEvent(this, 'wje-toggle:change');\n\t\t\t});\n\n\t\t\tthis.addEventListener('invalid', (e) => {\n\t\t\t\tthis.invalid = true;\n\t\t\t\tthis.pristine = false;\n\n\t\t\t\tthis.showInvalidMessage();\n\t\t\t});\n\n\t\t\tthis.validate();\n\n\t\t\tif (this.invalid) {\n\t\t\t\tthis.showInvalidMessage();\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Syncs ARIA attributes on the host element.\n\t */\n\tsyncAria() {\n\t\tconst checked = this.indeterminate ? 'mixed' : (this.checked ? 'true' : 'false');\n\t\tconst requiredInvalid = this.required && !this.checked;\n\t\tconst invalid = this.invalid || requiredInvalid;\n\t\tconst label = this.label?.trim();\n\t\tthis.setAriaState({\n\t\t\trole: 'checkbox',\n\t\t\tchecked,\n\t\t\tdisabled: this.disabled,\n\t\t\trequired: this.required,\n\t\t\tinvalid,\n\t\t\t...(label ? { label } : {}),\n\t\t});\n\t}\n\n\t/**\n\t * Removes the event listener when the checkbox is disconnected.\n\t */\n\tbeforeDisconnect() {\n\t\tevent.removeElement(this.input);\n\t}\n}\n","import { default as WJElement } from '../wje-element/element.js';\nimport Checkbox from './checkbox.element.js';\n\n// export * from \"./checkbox.element.js\";\nexport default Checkbox;\n\nWJElement.define('wje-checkbox', Checkbox);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAmBe,MAAM,iBAAiB,sBAAsB;AAAA;AAAA;AAAA;AAAA,EAK3D,cAA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,SAAS;AACtE,SAAK,SAAU;AAEf,QAAI,CAAC,KAAK,UAAU;AACnB,WAAK,MAAM,iBAAiB,SAAS,CAAC,MAAM;AAC3C,aAAK,SAAU;AAEf,aAAK,WAAW;AAChB,aAAK,oBAAqB;AAG1B,aAAK,gBAAgB;AACrB,aAAK,UAAU,EAAE,OAAO;AACxB,aAAK,SAAU;AAEf,cAAM,oBAAoB,MAAM,kBAAkB;AAAA,MACtD,CAAI;AAED,WAAK,MAAM,iBAAiB,UAAU,CAAC,MAAM;AAC5C,cAAM,oBAAoB,MAAM,mBAAmB;AAAA,MACvD,CAAI;AAED,WAAK,iBAAiB,WAAW,CAAC,MAAM;AACvC,aAAK,UAAU;AACf,aAAK,WAAW;AAEhB,aAAK,mBAAoB;AAAA,MAC7B,CAAI;AAED,WAAK,SAAU;AAEf,UAAI,KAAK,SAAS;AACjB,aAAK,mBAAoB;AAAA,MAC7B;AAAA,IACA;AAAA,EACA;AAAA;AAAA;AAAA;AAAA,EAKC,WAAW;;AACV,UAAM,UAAU,KAAK,gBAAgB,UAAW,KAAK,UAAU,SAAS;AACxE,UAAM,kBAAkB,KAAK,YAAY,CAAC,KAAK;AAC/C,UAAM,UAAU,KAAK,WAAW;AAChC,UAAM,SAAQ,UAAK,UAAL,mBAAY;AAC1B,SAAK,aAAa;AAAA,MACjB,MAAM;AAAA,MACN;AAAA,MACA,UAAU,KAAK;AAAA,MACf,UAAU,KAAK;AAAA,MACf;AAAA,MACA,GAAI,QAAQ,EAAE,MAAO,IAAG;IAC3B,CAAG;AAAA,EACH;AAAA;AAAA;AAAA;AAAA,EAKC,mBAAmB;AAClB,UAAM,cAAc,KAAK,KAAK;AAAA,EAChC;AACA;AAxTC;ACdD,UAAU,OAAO,gBAAgB,QAAQ;"}
|
|
@@ -16,6 +16,7 @@ export default class Chip extends WJElement {
|
|
|
16
16
|
* @returns {*}
|
|
17
17
|
*/
|
|
18
18
|
static get cssStyleSheet(): any;
|
|
19
|
+
static get observedAttributes(): string[];
|
|
19
20
|
/**
|
|
20
21
|
* Sets or removes the "round" attribute on the element based on the provided value.
|
|
21
22
|
* @param {boolean} value Determines whether the "round" attribute should be set or removed.
|
|
@@ -62,6 +63,7 @@ export default class Chip extends WJElement {
|
|
|
62
63
|
* @returns {boolean} True if the element has the 'disabled' attribute, otherwise false.
|
|
63
64
|
*/
|
|
64
65
|
get disabled(): boolean;
|
|
66
|
+
attributeChangedCallback(name: any, oldValue: any, newValue: any): void;
|
|
65
67
|
/**
|
|
66
68
|
* Draws the Chip element.
|
|
67
69
|
* @returns {DocumentFragment}
|
|
@@ -69,6 +71,10 @@ export default class Chip extends WJElement {
|
|
|
69
71
|
draw(): DocumentFragment;
|
|
70
72
|
removeElement: HTMLElement;
|
|
71
73
|
slotEnd: HTMLSlotElement;
|
|
74
|
+
/**
|
|
75
|
+
* Syncs ARIA attributes on the host element.
|
|
76
|
+
*/
|
|
77
|
+
syncAria(): void;
|
|
72
78
|
/**
|
|
73
79
|
* Getter for the observed attributes.
|
|
74
80
|
*/
|
package/dist/wje-chip.js
CHANGED
|
@@ -103,6 +103,17 @@ class Chip extends WJElement {
|
|
|
103
103
|
*/
|
|
104
104
|
setupAttributes() {
|
|
105
105
|
this.isShadowRoot = "open";
|
|
106
|
+
this.syncAria();
|
|
107
|
+
}
|
|
108
|
+
static get observedAttributes() {
|
|
109
|
+
return ["removable", "disabled", "label"];
|
|
110
|
+
}
|
|
111
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
112
|
+
var _a;
|
|
113
|
+
(_a = super.attributeChangedCallback) == null ? void 0 : _a.call(this, name, oldValue, newValue);
|
|
114
|
+
if (name === "removable" || name === "disabled" || name === "label") {
|
|
115
|
+
this.syncAria();
|
|
116
|
+
}
|
|
106
117
|
}
|
|
107
118
|
/**
|
|
108
119
|
* Draws the Chip element.
|
|
@@ -120,6 +131,7 @@ class Chip extends WJElement {
|
|
|
120
131
|
remove.setAttribute("part", "remove");
|
|
121
132
|
remove.setAttribute("fill", "link");
|
|
122
133
|
remove.setAttribute("color", this.color || "default");
|
|
134
|
+
remove.setAttribute("aria-label", "Remove");
|
|
123
135
|
remove.round = !this.round;
|
|
124
136
|
if (this.hasAttribute("size")) {
|
|
125
137
|
if (this.size === "small") {
|
|
@@ -146,6 +158,16 @@ class Chip extends WJElement {
|
|
|
146
158
|
this.slotEnd = slotEnd;
|
|
147
159
|
return fragment;
|
|
148
160
|
}
|
|
161
|
+
/**
|
|
162
|
+
* Syncs ARIA attributes on the host element.
|
|
163
|
+
*/
|
|
164
|
+
syncAria() {
|
|
165
|
+
var _a;
|
|
166
|
+
const label = (_a = this.getAttribute("label")) == null ? void 0 : _a.trim();
|
|
167
|
+
if (label) this.setAriaState({ label });
|
|
168
|
+
if (this.removable) this.setAriaState({ role: "button", disabled: this.disabled });
|
|
169
|
+
else this.setAriaState({ role: "status" });
|
|
170
|
+
}
|
|
149
171
|
/**
|
|
150
172
|
* Getter for the observed attributes.
|
|
151
173
|
*/
|
package/dist/wje-chip.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wje-chip.js","sources":["../packages/wje-chip/chip.element.js","../packages/wje-chip/chip.js"],"sourcesContent":["import { default as WJElement, event, WjElementUtils } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary This method dispatches a custom event named \"wje-chip:remove\".\n * It is triggered when the remove button is clicked, which happens when the chip is removed.\n * The event is dispatched on the current instance of the Chip class.\n * @documentation https://elements.webjet.sk/components/chip\n * @status stable\n * @augments WJElement\n * @slot - The chip main content.\n * @csspart native - The component's native wrapper.\n * //@fires wje-chip:remove - Dispatched when the chip is removed;\n */\nexport default class Chip extends WJElement {\n /**\n * Chip constructor method.\n */\n constructor() {\n super();\n }\n\n /**\n * Sets or removes the \"round\" attribute on the element based on the provided value.\n * @param {boolean} value Determines whether the \"round\" attribute should be set or removed.\n * If true, the \"round\" attribute is added. If false, the \"round\"\n * attribute is removed.\n */\n set round(value) {\n if (value) {\n this.setAttribute('round', '');\n } else {\n this.removeAttribute('round');\n }\n }\n\n /**\n * Checks if the 'round' attribute is present on the element.\n * @returns {boolean} Returns true if the 'round' attribute exists, otherwise false.\n */\n get round() {\n return this.hasAttribute('round');\n }\n\n /**\n * Sets the size attribute of the element.\n * @param {string} value The value to set for the size attribute.\n */\n set size(value) {\n this.setAttribute('size', value);\n }\n\n /**\n * Retrieves the 'size' attribute of the current element.\n * @returns {string | null} The value of the 'size' attribute, or null if the attribute is not set.\n */\n get size() {\n return this.getAttribute('size');\n }\n\n /**\n * Sets or removes the \"removable\" attribute on the element.\n * @param {boolean} value A boolean indicating whether the element should have the \"removable\" attribute.\n * If true, the \"removable\" attribute is added;\n * if false, the \"removable\" attribute is removed.\n */\n set removable(value) {\n if (value) {\n this.setAttribute('removable', '');\n } else {\n this.removeAttribute('removable');\n }\n }\n\n /**\n * Determines if the element has the 'removable' attribute.\n * @returns {boolean} True if the element has the 'removable' attribute, otherwise false.\n */\n get removable() {\n return this.hasAttribute('removable');\n }\n\n /**\n * Sets the disabled state of the element.\n * If true, the 'disabled' attribute is added to the element.\n * If false, the 'disabled' attribute is removed from the element.\n * @param {boolean} value Specifies whether the element should be disabled.\n */\n set disabled(value) {\n if (value) {\n this.setAttribute('disabled', '');\n } else {\n this.removeAttribute('disabled');\n }\n }\n\n /**\n * Determines if the element has the 'disabled' attribute.\n * @returns {boolean} True if the element has the 'disabled' attribute, otherwise false.\n */\n get disabled() {\n return this.hasAttribute('disabled');\n }\n\n /**\n * Class name for the Chip element.\n * @type {string}\n */\n className = 'Chip';\n\n /**\n * Getter for the CSS stylesheet.\n * @returns {*}\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Getter for the observed attributes.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Draws the Chip element.\n * @returns {DocumentFragment}\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('div');\n native.setAttribute('part', 'native');\n native.classList.add('native-chip');\n\n let slot = document.createElement('slot');\n\n let slotEnd = document.createElement('slot');\n slotEnd.setAttribute('name', 'end');\n\n let remove = document.createElement('wje-button');\n remove.setAttribute('part', 'remove');\n remove.setAttribute('fill', 'link');\n remove.setAttribute('color', this.color || 'default');\n remove.round = !this.round;\n\n if(this.hasAttribute('size')) {\n if(this.size === 'small') {\n remove.innerHTML = `<wje-icon name=\"x\" size=\"small\"></wje-icon>`;\n } else if (this.size === 'large') {\n remove.innerHTML = `<wje-icon name=\"x\"></wje-icon>`;\n }\n } else {\n remove.innerHTML = `<wje-icon name=\"x\"></wje-icon>`;\n }\n\n let active = document.createElement('wje-icon');\n active.setAttribute('name', 'check');\n active.classList.add('check');\n\n // Add color\n if (this.hasAttribute('color')) native.classList.add('wje-color-' + this.color, 'wje-color');\n else native.classList.add('wje-color-default', 'wje-color');\n\n if (this.disabled) this.classList.add('wje-disabled');\n\n if (this.outline) this.classList.add('wje-outline');\n\n native.appendChild(slot);\n native.appendChild(slotEnd);\n native.appendChild(active);\n\n if (this.removable) native.appendChild(remove);\n\n fragment.appendChild(native);\n\n this.removeElement = remove;\n this.slotEnd = slotEnd;\n\n return fragment;\n }\n\n /**\n * Getter for the observed attributes.\n */\n afterDraw() {\n if (WjElementUtils.hasSlotContent(this.context, 'end')) this.slotEnd.classList.add('has-content');\n\n event.addListener(this.removeElement, 'click', 'wje:chip-remove', null, { stopPropagation: true });\n }\n\n /**\n * Before disconnect event for the Chip element.\n */\n beforeDisconnect() {\n event.removeListener(this.removeElement, 'click', 'wje:chip-remove');\n }\n}\n","import { default as WJElement } from '../wje-element/element.js';\nimport Chip from './chip.element.js';\n\n// export * from \"./chip.element.js\";\nexport default Chip;\n\nWJElement.define('wje-chip', Chip);\n"],"names":[],"mappings":";;;;;;;AAce,MAAM,aAAa,UAAU;AAAA;AAAA;AAAA;AAAA,EAIxC,cAAc;AACV,UAAO;AAyFX;AAAA;AAAA;AAAA;AAAA,qCAAY;AAAA,EAxFhB;AAAA;AAAA;AA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mB,MAAM,EAAE,iBAAiB,MAAM;AAAA,EACzG;AAAA;AAAA;AAAA;AAAA,EAKI,mBAAmB;AACf,UAAM,eAAe,KAAK,eAAe,SAAS,iBAAiB;AAAA,EAC3E;AACA;AChMA,UAAU,OAAO,YAAY,IAAI;"}
|
|
1
|
+
{"version":3,"file":"wje-chip.js","sources":["../packages/wje-chip/chip.element.js","../packages/wje-chip/chip.js"],"sourcesContent":["import { default as WJElement, event, WjElementUtils } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary This method dispatches a custom event named \"wje-chip:remove\".\n * It is triggered when the remove button is clicked, which happens when the chip is removed.\n * The event is dispatched on the current instance of the Chip class.\n * @documentation https://elements.webjet.sk/components/chip\n * @status stable\n * @augments WJElement\n * @slot - The chip main content.\n * @csspart native - The component's native wrapper.\n * //@fires wje-chip:remove - Dispatched when the chip is removed;\n */\nexport default class Chip extends WJElement {\n /**\n * Chip constructor method.\n */\n constructor() {\n super();\n }\n\n /**\n * Sets or removes the \"round\" attribute on the element based on the provided value.\n * @param {boolean} value Determines whether the \"round\" attribute should be set or removed.\n * If true, the \"round\" attribute is added. If false, the \"round\"\n * attribute is removed.\n */\n set round(value) {\n if (value) {\n this.setAttribute('round', '');\n } else {\n this.removeAttribute('round');\n }\n }\n\n /**\n * Checks if the 'round' attribute is present on the element.\n * @returns {boolean} Returns true if the 'round' attribute exists, otherwise false.\n */\n get round() {\n return this.hasAttribute('round');\n }\n\n /**\n * Sets the size attribute of the element.\n * @param {string} value The value to set for the size attribute.\n */\n set size(value) {\n this.setAttribute('size', value);\n }\n\n /**\n * Retrieves the 'size' attribute of the current element.\n * @returns {string | null} The value of the 'size' attribute, or null if the attribute is not set.\n */\n get size() {\n return this.getAttribute('size');\n }\n\n /**\n * Sets or removes the \"removable\" attribute on the element.\n * @param {boolean} value A boolean indicating whether the element should have the \"removable\" attribute.\n * If true, the \"removable\" attribute is added;\n * if false, the \"removable\" attribute is removed.\n */\n set removable(value) {\n if (value) {\n this.setAttribute('removable', '');\n } else {\n this.removeAttribute('removable');\n }\n }\n\n /**\n * Determines if the element has the 'removable' attribute.\n * @returns {boolean} True if the element has the 'removable' attribute, otherwise false.\n */\n get removable() {\n return this.hasAttribute('removable');\n }\n\n /**\n * Sets the disabled state of the element.\n * If true, the 'disabled' attribute is added to the element.\n * If false, the 'disabled' attribute is removed from the element.\n * @param {boolean} value Specifies whether the element should be disabled.\n */\n set disabled(value) {\n if (value) {\n this.setAttribute('disabled', '');\n } else {\n this.removeAttribute('disabled');\n }\n }\n\n /**\n * Determines if the element has the 'disabled' attribute.\n * @returns {boolean} True if the element has the 'disabled' attribute, otherwise false.\n */\n get disabled() {\n return this.hasAttribute('disabled');\n }\n\n /**\n * Class name for the Chip element.\n * @type {string}\n */\n className = 'Chip';\n\n /**\n * Getter for the CSS stylesheet.\n * @returns {*}\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Getter for the observed attributes.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n this.syncAria();\n }\n\n static get observedAttributes() {\n return ['removable', 'disabled', 'label'];\n }\n\n attributeChangedCallback(name, oldValue, newValue) {\n super.attributeChangedCallback?.(name, oldValue, newValue);\n if (name === 'removable' || name === 'disabled' || name === 'label') {\n this.syncAria();\n }\n }\n\n /**\n * Draws the Chip element.\n * @returns {DocumentFragment}\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('div');\n native.setAttribute('part', 'native');\n native.classList.add('native-chip');\n\n let slot = document.createElement('slot');\n\n let slotEnd = document.createElement('slot');\n slotEnd.setAttribute('name', 'end');\n\n let remove = document.createElement('wje-button');\n remove.setAttribute('part', 'remove');\n remove.setAttribute('fill', 'link');\n remove.setAttribute('color', this.color || 'default');\n remove.setAttribute('aria-label', 'Remove');\n remove.round = !this.round;\n\n if(this.hasAttribute('size')) {\n if(this.size === 'small') {\n remove.innerHTML = `<wje-icon name=\"x\" size=\"small\"></wje-icon>`;\n } else if (this.size === 'large') {\n remove.innerHTML = `<wje-icon name=\"x\"></wje-icon>`;\n }\n } else {\n remove.innerHTML = `<wje-icon name=\"x\"></wje-icon>`;\n }\n\n let active = document.createElement('wje-icon');\n active.setAttribute('name', 'check');\n active.classList.add('check');\n\n // Add color\n if (this.hasAttribute('color')) native.classList.add('wje-color-' + this.color, 'wje-color');\n else native.classList.add('wje-color-default', 'wje-color');\n\n if (this.disabled) this.classList.add('wje-disabled');\n\n if (this.outline) this.classList.add('wje-outline');\n\n native.appendChild(slot);\n native.appendChild(slotEnd);\n native.appendChild(active);\n\n if (this.removable) native.appendChild(remove);\n\n fragment.appendChild(native);\n\n this.removeElement = remove;\n this.slotEnd = slotEnd;\n\n return fragment;\n }\n\n /**\n * Syncs ARIA attributes on the host element.\n */\n syncAria() {\n const label = this.getAttribute('label')?.trim();\n if (label) this.setAriaState({ label });\n if (this.removable) this.setAriaState({ role: 'button', disabled: this.disabled });\n else this.setAriaState({ role: 'status' });\n }\n\n /**\n * Getter for the observed attributes.\n */\n afterDraw() {\n if (WjElementUtils.hasSlotContent(this.context, 'end')) this.slotEnd.classList.add('has-content');\n\n event.addListener(this.removeElement, 'click', 'wje:chip-remove', null, { stopPropagation: true });\n }\n\n /**\n * Before disconnect event for the Chip element.\n */\n beforeDisconnect() {\n event.removeListener(this.removeElement, 'click', 'wje:chip-remove');\n }\n}\n","import { default as WJElement } from '../wje-element/element.js';\nimport Chip from './chip.element.js';\n\n// export * from \"./chip.element.js\";\nexport default Chip;\n\nWJElement.define('wje-chip', Chip);\n"],"names":[],"mappings":";;;;;;;AAce,MAAM,aAAa,UAAU;AAAA;AAAA;AAAA;AAAA,EAIxC,cAAc;AACV,UAAO;AAyFX;AAAA;AAAA;AAAA;AAAA,qCAAY;AAAA,EAxFhB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQI,IAAI,MAAM,OAAO;AACb,QAAI,OAAO;AACP,WAAK,aAAa,SAAS,EAAE;AAAA,IACzC,OAAe;AACH,WAA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WAAO;AAAA,EACf;AAAA;AAAA;AAAA;AAAA,EAKI,WAAW;;AACP,UAAM,SAAQ,UAAK,aAAa,OAAO,MAAzB,mBAA4B;AAC1C,QAAI,MAAO,MAAK,aAAa,EAAE,MAAK,CAAE;AACtC,QAAI,KAAK,UAAW,MAAK,aAAa,EAAE,MAAM,UAAU,UAAU,KAAK,UAAU;AAAA,QAC5E,MAAK,aAAa,EAAE,MAAM,SAAQ,CAAE;AAAA,EACjD;AAAA;AAAA;AAAA;AAAA,EAKI,YAAY;AACR,QAAI,eAAe,eAAe,KAAK,SAAS,KAAK,EAAG,MAAK,QAAQ,UAAU,IAAI,aAAa;AAEhG,UAAM,YAAY,KAAK,eAAe,SAAS,mBAAmB,MAAM,EAAE,iBAAiB,MAAM;AAAA,EACzG;AAAA;AAAA;AAAA;AAAA,EAKI,mBAAmB;AACf,UAAM,eAAe,KAAK,eAAe,SAAS,iBAAiB;AAAA,EAC3E;AACA;ACvNA,UAAU,OAAO,YAAY,IAAI;"}
|
|
@@ -15,6 +15,7 @@ import { default as WJElement } from '../wje-element/element.js';
|
|
|
15
15
|
* @csspart alpha - The alpha slider part of the color picker.
|
|
16
16
|
* @csspart color-preview - The color preview part of the color picker.
|
|
17
17
|
* @csspart input - The input part of the color picker.
|
|
18
|
+
* @attribute {boolean} input-editable - Enables manual color typing into the input field.
|
|
18
19
|
* @cssproperty [--wje-color-picker-area] - The color of the color area background.
|
|
19
20
|
* @cssproperty [--wje-color-picker-value] - The value of the color picker input.
|
|
20
21
|
* @cssproperty [--wje-color-picker-swatch] - The color of the color swatch button.
|
|
@@ -46,6 +47,13 @@ export default class ColorPicker extends WJElement {
|
|
|
46
47
|
* @private
|
|
47
48
|
*/
|
|
48
49
|
private _swatches;
|
|
50
|
+
/**
|
|
51
|
+
* Stores last raw value typed by user in editable input.
|
|
52
|
+
* Used to avoid aggressive normalization while typing.
|
|
53
|
+
* @type {string|null}
|
|
54
|
+
* @private
|
|
55
|
+
*/
|
|
56
|
+
private _manualInputValue;
|
|
49
57
|
/**
|
|
50
58
|
* Sets the color attribute of the element.
|
|
51
59
|
* @param {string} value The color value to be set. It should be a valid color string such as a named color, HEX, RGB, or HSL format.
|
|
@@ -76,6 +84,13 @@ export default class ColorPicker extends WJElement {
|
|
|
76
84
|
* @returns {Array} The current color swatches.
|
|
77
85
|
*/
|
|
78
86
|
get swatches(): any[];
|
|
87
|
+
/**
|
|
88
|
+
* Normalizes swatch colors from a string to an array.
|
|
89
|
+
* Supports comma and semicolon separators.
|
|
90
|
+
* @param {string} value
|
|
91
|
+
* @returns {string[]}
|
|
92
|
+
*/
|
|
93
|
+
parseSwatches(value?: string): string[];
|
|
79
94
|
/**
|
|
80
95
|
* Sets or removes the 'no-color-area' attribute based on the provided value.
|
|
81
96
|
* @param {boolean} value A boolean value indicating whether to set or remove the 'no-color-area' attribute. If true, the attribute is added; if false, the attribute is removed.
|
|
@@ -108,6 +123,16 @@ export default class ColorPicker extends WJElement {
|
|
|
108
123
|
* @returns {boolean} Returns true if the 'no-swatches' attribute is present; otherwise, false.
|
|
109
124
|
*/
|
|
110
125
|
get noSwatches(): boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Enables/disables manual typing in the input.
|
|
128
|
+
* @param {boolean} value
|
|
129
|
+
*/
|
|
130
|
+
set inputEditable(value: boolean);
|
|
131
|
+
/**
|
|
132
|
+
* Returns true when manual input typing is enabled.
|
|
133
|
+
* @returns {boolean}
|
|
134
|
+
*/
|
|
135
|
+
get inputEditable(): boolean;
|
|
111
136
|
/**
|
|
112
137
|
* Creates and returns a document fragment containing the structure and components of a custom color picker.
|
|
113
138
|
* The method initializes DOM elements such as divs, sliders, and inputs, with specific classes and attributes,
|
|
@@ -174,6 +199,16 @@ export default class ColorPicker extends WJElement {
|
|
|
174
199
|
* @param y
|
|
175
200
|
*/
|
|
176
201
|
setMarkerPosition(x: any, y: any): void;
|
|
202
|
+
/**
|
|
203
|
+
* Clamps marker coordinates to the color area boundaries.
|
|
204
|
+
* @param {number} x
|
|
205
|
+
* @param {number} y
|
|
206
|
+
* @returns {{x: number, y: number}}
|
|
207
|
+
*/
|
|
208
|
+
clampMarkerPosition(x: number, y: number): {
|
|
209
|
+
x: number;
|
|
210
|
+
y: number;
|
|
211
|
+
};
|
|
177
212
|
/**
|
|
178
213
|
* Sets the color at the given position.
|
|
179
214
|
* @param x
|
|
@@ -194,7 +229,7 @@ export default class ColorPicker extends WJElement {
|
|
|
194
229
|
/**
|
|
195
230
|
* Updates the color picker's current color and its associated UI elements.
|
|
196
231
|
* @param {tinycolor.Instance|null} [color] The color value to set. If null, the current value from the input field is used.
|
|
197
|
-
* @param {string} [type] The type of action determining which UI element to update. Possible values: "marker", "hue", "alpha", "swatch".
|
|
232
|
+
* @param {string} [type] The type of action determining which UI element to update. Possible values: "marker", "hue", "alpha", "swatch", "input".
|
|
198
233
|
*/
|
|
199
234
|
setColor: (color?: tinycolor.Instance | null, type?: string) => void;
|
|
200
235
|
value: {
|
|
@@ -226,5 +261,12 @@ export default class ColorPicker extends WJElement {
|
|
|
226
261
|
* @returns {string} - The HSVA color string in the format `hsva(h, 100%, 100%, a)`.
|
|
227
262
|
*/
|
|
228
263
|
getHSVA: (hue: number, alpha: number) => string;
|
|
264
|
+
/**
|
|
265
|
+
* Returns fully saturated and bright color for the current hue.
|
|
266
|
+
* Used as base color for the SV area so neutral grays do not black out the palette.
|
|
267
|
+
* @param {string} color
|
|
268
|
+
* @returns {string}
|
|
269
|
+
*/
|
|
270
|
+
getHueAreaColor(color?: string): string;
|
|
229
271
|
#private;
|
|
230
272
|
}
|
package/dist/wje-color-picker.js
CHANGED
|
@@ -992,12 +992,15 @@ class ColorPicker extends WJElement {
|
|
|
992
992
|
* @param {Event} e The event triggering the marker movement, typically a mouse or touch event.
|
|
993
993
|
*/
|
|
994
994
|
__publicField(this, "moveMarker", (e) => {
|
|
995
|
+
var _a;
|
|
995
996
|
this.colorAreaDimension = this.dimension();
|
|
996
997
|
const pointer = this.getPointerPosition(e);
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
this.
|
|
1000
|
-
this.
|
|
998
|
+
const x = pointer.x - this.colorAreaDimension.x;
|
|
999
|
+
const y = pointer.y - this.colorAreaDimension.y;
|
|
1000
|
+
const markerPosition = this.clampMarkerPosition(x, y);
|
|
1001
|
+
const alpha = Number(((_a = this.alphaSlider) == null ? void 0 : _a.value) || 100);
|
|
1002
|
+
this.setColor(this.setColorAtPosition(markerPosition.x, markerPosition.y, alpha), "marker");
|
|
1003
|
+
this.setMarkerPosition(markerPosition.x, markerPosition.y);
|
|
1001
1004
|
});
|
|
1002
1005
|
/**
|
|
1003
1006
|
* Sets the marker position by color.
|
|
@@ -1005,16 +1008,21 @@ class ColorPicker extends WJElement {
|
|
|
1005
1008
|
* @returns {{x: number, y: number}}
|
|
1006
1009
|
*/
|
|
1007
1010
|
__publicField(this, "setMarkerPositionByColor", (color = "red") => {
|
|
1011
|
+
var _a, _b;
|
|
1008
1012
|
let hsva = tinycolor(color).toHsv();
|
|
1013
|
+
const width = ((_a = this.colorAreaDimension) == null ? void 0 : _a.width) || 0;
|
|
1014
|
+
const height = ((_b = this.colorAreaDimension) == null ? void 0 : _b.height) || 0;
|
|
1015
|
+
const safeS = Number.isFinite(hsva.s) ? hsva.s : 0;
|
|
1016
|
+
const safeV = Number.isFinite(hsva.v) ? hsva.v : 0;
|
|
1009
1017
|
return {
|
|
1010
|
-
x:
|
|
1011
|
-
y:
|
|
1018
|
+
x: width * safeS,
|
|
1019
|
+
y: height - height * safeV
|
|
1012
1020
|
};
|
|
1013
1021
|
});
|
|
1014
1022
|
/**
|
|
1015
1023
|
* Updates the color picker's current color and its associated UI elements.
|
|
1016
1024
|
* @param {tinycolor.Instance|null} [color] The color value to set. If null, the current value from the input field is used.
|
|
1017
|
-
* @param {string} [type] The type of action determining which UI element to update. Possible values: "marker", "hue", "alpha", "swatch".
|
|
1025
|
+
* @param {string} [type] The type of action determining which UI element to update. Possible values: "marker", "hue", "alpha", "swatch", "input".
|
|
1018
1026
|
*/
|
|
1019
1027
|
__publicField(this, "setColor", (color = null, type = "") => {
|
|
1020
1028
|
let currentColor = color;
|
|
@@ -1023,7 +1031,6 @@ class ColorPicker extends WJElement {
|
|
|
1023
1031
|
this.colorArea.style.setProperty("--wje-color-picker-area", currentColor.toHexString());
|
|
1024
1032
|
}
|
|
1025
1033
|
if (type === "marker") {
|
|
1026
|
-
this.alphaSlider.value = 100;
|
|
1027
1034
|
this.alphaSlider.style.setProperty("--wje-color-picker-value", currentColor.toHexString());
|
|
1028
1035
|
this.colorPreview.style.setProperty("--wje-color-picker-value", currentColor.toHex8String());
|
|
1029
1036
|
this.picker.style.setProperty("--wje-color-picker-value", currentColor.toHexString());
|
|
@@ -1035,12 +1042,13 @@ class ColorPicker extends WJElement {
|
|
|
1035
1042
|
this.markerPosition.y,
|
|
1036
1043
|
this.alphaSlider.value
|
|
1037
1044
|
);
|
|
1038
|
-
|
|
1045
|
+
const hueColor = this.getHueAreaColor(this.getHSVA(this.hueSlider.value, 100));
|
|
1039
1046
|
this.colorPreview.style.setProperty("--wje-color-picker-value", markerColorByPosition.toHex8String());
|
|
1040
1047
|
this.marker.style.setProperty("--wje-color-picker-value", markerColorByPosition.toHexString());
|
|
1041
|
-
this.alphaSlider.style.setProperty("--wje-color-picker-value",
|
|
1042
|
-
this.colorArea.style.setProperty("--wje-color-picker-area",
|
|
1048
|
+
this.alphaSlider.style.setProperty("--wje-color-picker-value", markerColorByPosition.toHexString());
|
|
1049
|
+
this.colorArea.style.setProperty("--wje-color-picker-area", hueColor);
|
|
1043
1050
|
this.input.value = markerColorByPosition.toHex8String();
|
|
1051
|
+
currentColor = markerColorByPosition;
|
|
1044
1052
|
}
|
|
1045
1053
|
if (type === "alpha") {
|
|
1046
1054
|
currentColor = tinycolor(this.input.value);
|
|
@@ -1049,16 +1057,21 @@ class ColorPicker extends WJElement {
|
|
|
1049
1057
|
currentColor = tinycolor(hsv);
|
|
1050
1058
|
this.colorPreview.style.setProperty("--wje-color-picker-value", currentColor.toHex8String());
|
|
1051
1059
|
}
|
|
1052
|
-
if (type === "swatch" || type === "init") {
|
|
1060
|
+
if (type === "swatch" || type === "init" || type === "input") {
|
|
1053
1061
|
this.colorPreview.style.setProperty("--wje-color-picker-value", currentColor.toHex8String());
|
|
1054
1062
|
this.marker.style.setProperty("--wje-color-picker-value", currentColor.toHexString());
|
|
1055
1063
|
this.alphaSlider.style.setProperty("--wje-color-picker-value", currentColor.toHexString());
|
|
1056
|
-
this.colorArea.style.setProperty("--wje-color-picker-area", currentColor.toHex8String());
|
|
1064
|
+
this.colorArea.style.setProperty("--wje-color-picker-area", this.getHueAreaColor(currentColor.toHex8String()));
|
|
1057
1065
|
this.markerPosition = this.setMarkerPositionByColor(currentColor.toHex8String());
|
|
1058
1066
|
this.setMarkerPosition(this.markerPosition.x, this.markerPosition.y);
|
|
1059
1067
|
}
|
|
1068
|
+
if (!(currentColor == null ? void 0 : currentColor.isValid())) return;
|
|
1060
1069
|
if (!this.noColorArea || !this.noControls || !this.noSwatches) {
|
|
1061
|
-
this.
|
|
1070
|
+
if (type === "input" && this.inputEditable && typeof this._manualInputValue === "string") {
|
|
1071
|
+
this.input.value = this._manualInputValue;
|
|
1072
|
+
} else {
|
|
1073
|
+
this.input.value = currentColor.toHex8String();
|
|
1074
|
+
}
|
|
1062
1075
|
}
|
|
1063
1076
|
this.anchor.style.setProperty("--wje-color-picker-value", currentColor.toHexString());
|
|
1064
1077
|
this.value = {
|
|
@@ -1120,6 +1133,7 @@ class ColorPicker extends WJElement {
|
|
|
1120
1133
|
"#00b4d880",
|
|
1121
1134
|
"rgba(0,119,182,0.8)"
|
|
1122
1135
|
];
|
|
1136
|
+
this._manualInputValue = null;
|
|
1123
1137
|
}
|
|
1124
1138
|
/**
|
|
1125
1139
|
* Sets the color attribute of the element.
|
|
@@ -1154,16 +1168,30 @@ class ColorPicker extends WJElement {
|
|
|
1154
1168
|
* @param {string} value The new color swatches.
|
|
1155
1169
|
*/
|
|
1156
1170
|
set swatches(value) {
|
|
1157
|
-
|
|
1171
|
+
if (Array.isArray(value)) {
|
|
1172
|
+
this.setAttribute("swatches", value.join(","));
|
|
1173
|
+
return;
|
|
1174
|
+
}
|
|
1175
|
+
this.setAttribute("swatches", this.parseSwatches(value).join(","));
|
|
1158
1176
|
}
|
|
1159
1177
|
/**
|
|
1160
1178
|
* Getter for the color swatches.
|
|
1161
1179
|
* @returns {Array} The current color swatches.
|
|
1162
1180
|
*/
|
|
1163
1181
|
get swatches() {
|
|
1164
|
-
this._swatches = this.getAttribute("swatches") ? this.getAttribute("swatches")
|
|
1182
|
+
this._swatches = this.getAttribute("swatches") ? this.parseSwatches(this.getAttribute("swatches")) : this._swatches;
|
|
1165
1183
|
return this._swatches;
|
|
1166
1184
|
}
|
|
1185
|
+
/**
|
|
1186
|
+
* Normalizes swatch colors from a string to an array.
|
|
1187
|
+
* Supports comma and semicolon separators.
|
|
1188
|
+
* @param {string} value
|
|
1189
|
+
* @returns {string[]}
|
|
1190
|
+
*/
|
|
1191
|
+
parseSwatches(value = "") {
|
|
1192
|
+
if (typeof value !== "string") return [];
|
|
1193
|
+
return value.split(/[;,]/).map((item) => item.trim()).filter(Boolean);
|
|
1194
|
+
}
|
|
1167
1195
|
/**
|
|
1168
1196
|
* Sets or removes the 'no-color-area' attribute based on the provided value.
|
|
1169
1197
|
* @param {boolean} value A boolean value indicating whether to set or remove the 'no-color-area' attribute. If true, the attribute is added; if false, the attribute is removed.
|
|
@@ -1220,6 +1248,24 @@ class ColorPicker extends WJElement {
|
|
|
1220
1248
|
get noSwatches() {
|
|
1221
1249
|
return this.hasAttribute("no-swatches");
|
|
1222
1250
|
}
|
|
1251
|
+
/**
|
|
1252
|
+
* Enables/disables manual typing in the input.
|
|
1253
|
+
* @param {boolean} value
|
|
1254
|
+
*/
|
|
1255
|
+
set inputEditable(value) {
|
|
1256
|
+
if (value) {
|
|
1257
|
+
this.setAttribute("input-editable", "");
|
|
1258
|
+
} else {
|
|
1259
|
+
this.removeAttribute("input-editable");
|
|
1260
|
+
}
|
|
1261
|
+
}
|
|
1262
|
+
/**
|
|
1263
|
+
* Returns true when manual input typing is enabled.
|
|
1264
|
+
* @returns {boolean}
|
|
1265
|
+
*/
|
|
1266
|
+
get inputEditable() {
|
|
1267
|
+
return this.hasAttribute("input-editable");
|
|
1268
|
+
}
|
|
1223
1269
|
/**
|
|
1224
1270
|
* Getter for the CSS stylesheet.
|
|
1225
1271
|
* @returns {object} The styles object.
|
|
@@ -1294,11 +1340,30 @@ class ColorPicker extends WJElement {
|
|
|
1294
1340
|
colorPreview.classList.add("color-preview");
|
|
1295
1341
|
let input = document.createElement("wje-input");
|
|
1296
1342
|
input.setAttribute("variant", "standard");
|
|
1297
|
-
|
|
1343
|
+
input.setAttribute("maxlength", "9");
|
|
1344
|
+
if ((!this.noColorArea || !this.noControls || !this.noSwatches) && !this.inputEditable)
|
|
1298
1345
|
input.setAttribute("readonly", "");
|
|
1299
1346
|
input.classList.add("input");
|
|
1300
|
-
input.addEventListener("wje-input:input", (
|
|
1301
|
-
|
|
1347
|
+
input.addEventListener("wje-input:input", () => {
|
|
1348
|
+
let rawValue = (input.value || "").trim();
|
|
1349
|
+
const hasHashPrefix = rawValue.startsWith("#");
|
|
1350
|
+
const maxLength = hasHashPrefix ? 9 : 8;
|
|
1351
|
+
if (rawValue.length > maxLength) {
|
|
1352
|
+
rawValue = rawValue.slice(0, maxLength);
|
|
1353
|
+
input.value = rawValue;
|
|
1354
|
+
}
|
|
1355
|
+
const hexCandidate = hasHashPrefix ? rawValue.slice(1) : rawValue;
|
|
1356
|
+
const isHex = /^[0-9a-fA-F]+$/.test(hexCandidate);
|
|
1357
|
+
if (isHex) {
|
|
1358
|
+
if (hexCandidate.length < 6) return;
|
|
1359
|
+
if (![6, 8].includes(hexCandidate.length)) return;
|
|
1360
|
+
}
|
|
1361
|
+
const parsedColor = tinycolor(isHex ? `#${hexCandidate}` : rawValue);
|
|
1362
|
+
if (!parsedColor.isValid()) return;
|
|
1363
|
+
this._manualInputValue = rawValue;
|
|
1364
|
+
this.setSliders(parsedColor.toHex8String());
|
|
1365
|
+
this.setColor(parsedColor, "input");
|
|
1366
|
+
this._manualInputValue = null;
|
|
1302
1367
|
});
|
|
1303
1368
|
colorArea.append(marker);
|
|
1304
1369
|
alphaWrapper.append(alphaSlider);
|
|
@@ -1352,10 +1417,12 @@ class ColorPicker extends WJElement {
|
|
|
1352
1417
|
let swatches = document.createElement("div");
|
|
1353
1418
|
swatches.classList.add("swatches");
|
|
1354
1419
|
this.swatches.forEach((swatch) => {
|
|
1420
|
+
if (!tinycolor(swatch).isValid()) return;
|
|
1355
1421
|
let button = document.createElement("button");
|
|
1422
|
+
button.setAttribute("type", "button");
|
|
1356
1423
|
button.classList.add("swatch");
|
|
1357
1424
|
button.style.setProperty("--wje-color-picker-swatch", swatch);
|
|
1358
|
-
button.addEventListener("click", (
|
|
1425
|
+
button.addEventListener("click", () => {
|
|
1359
1426
|
this.setSliders(swatch);
|
|
1360
1427
|
this.setColor(tinycolor(swatch), "swatch");
|
|
1361
1428
|
});
|
|
@@ -1416,14 +1483,30 @@ class ColorPicker extends WJElement {
|
|
|
1416
1483
|
* @param y
|
|
1417
1484
|
*/
|
|
1418
1485
|
setMarkerPosition(x, y) {
|
|
1419
|
-
|
|
1420
|
-
y = y < 0 ? 0 : y > this.colorAreaDimension.height ? this.colorAreaDimension.height : y;
|
|
1486
|
+
const markerPosition = this.clampMarkerPosition(x, y);
|
|
1421
1487
|
this.markerPosition = {
|
|
1422
|
-
x,
|
|
1423
|
-
y
|
|
1488
|
+
x: markerPosition.x,
|
|
1489
|
+
y: markerPosition.y
|
|
1490
|
+
};
|
|
1491
|
+
this.marker.style.left = `${markerPosition.x}px`;
|
|
1492
|
+
this.marker.style.top = `${markerPosition.y}px`;
|
|
1493
|
+
}
|
|
1494
|
+
/**
|
|
1495
|
+
* Clamps marker coordinates to the color area boundaries.
|
|
1496
|
+
* @param {number} x
|
|
1497
|
+
* @param {number} y
|
|
1498
|
+
* @returns {{x: number, y: number}}
|
|
1499
|
+
*/
|
|
1500
|
+
clampMarkerPosition(x, y) {
|
|
1501
|
+
var _a, _b;
|
|
1502
|
+
const width = ((_a = this.colorAreaDimension) == null ? void 0 : _a.width) || 0;
|
|
1503
|
+
const height = ((_b = this.colorAreaDimension) == null ? void 0 : _b.height) || 0;
|
|
1504
|
+
const safeX = Number.isFinite(x) ? x : 0;
|
|
1505
|
+
const safeY = Number.isFinite(y) ? y : 0;
|
|
1506
|
+
return {
|
|
1507
|
+
x: Math.min(Math.max(safeX, 0), width),
|
|
1508
|
+
y: Math.min(Math.max(safeY, 0), height)
|
|
1424
1509
|
};
|
|
1425
|
-
this.marker.style.left = `${x}px`;
|
|
1426
|
-
this.marker.style.top = `${y}px`;
|
|
1427
1510
|
}
|
|
1428
1511
|
/**
|
|
1429
1512
|
* Sets the color at the given position.
|
|
@@ -1433,14 +1516,45 @@ class ColorPicker extends WJElement {
|
|
|
1433
1516
|
* @returns {*|tinycolor}
|
|
1434
1517
|
*/
|
|
1435
1518
|
setColorAtPosition(x, y, alpha = 100) {
|
|
1519
|
+
var _a, _b, _c;
|
|
1520
|
+
const markerPosition = this.clampMarkerPosition(x, y);
|
|
1521
|
+
const width = ((_a = this.colorAreaDimension) == null ? void 0 : _a.width) || 0;
|
|
1522
|
+
const height = ((_b = this.colorAreaDimension) == null ? void 0 : _b.height) || 0;
|
|
1523
|
+
const safeAlpha = Number.isFinite(Number(alpha)) ? Number(alpha) : 100;
|
|
1524
|
+
if (width <= 0 || height <= 0) {
|
|
1525
|
+
const fallbackHsv = tinycolor(((_c = this.input) == null ? void 0 : _c.value) || this.color).toHsv();
|
|
1526
|
+
return tinycolor({
|
|
1527
|
+
h: this.hueSlider.value * 1,
|
|
1528
|
+
s: fallbackHsv.s,
|
|
1529
|
+
v: fallbackHsv.v,
|
|
1530
|
+
a: Math.max(0, Math.min(100, safeAlpha)) / 100
|
|
1531
|
+
});
|
|
1532
|
+
}
|
|
1436
1533
|
const hsva = {
|
|
1437
1534
|
h: this.hueSlider.value * 1,
|
|
1438
|
-
s: x /
|
|
1439
|
-
v: 100 - y /
|
|
1440
|
-
a:
|
|
1535
|
+
s: markerPosition.x / width * 100,
|
|
1536
|
+
v: 100 - markerPosition.y / height * 100,
|
|
1537
|
+
a: Math.max(0, Math.min(100, safeAlpha)) / 100
|
|
1441
1538
|
};
|
|
1442
1539
|
return tinycolor(hsva);
|
|
1443
1540
|
}
|
|
1541
|
+
/**
|
|
1542
|
+
* Returns fully saturated and bright color for the current hue.
|
|
1543
|
+
* Used as base color for the SV area so neutral grays do not black out the palette.
|
|
1544
|
+
* @param {string} color
|
|
1545
|
+
* @returns {string}
|
|
1546
|
+
*/
|
|
1547
|
+
getHueAreaColor(color = "#ff0000") {
|
|
1548
|
+
var _a;
|
|
1549
|
+
const hsv = tinycolor(color).toHsv();
|
|
1550
|
+
const hue = Number.isFinite(hsv.h) ? hsv.h : Number(((_a = this.hueSlider) == null ? void 0 : _a.value) || 0);
|
|
1551
|
+
return tinycolor({
|
|
1552
|
+
h: hue,
|
|
1553
|
+
s: 100,
|
|
1554
|
+
v: 100,
|
|
1555
|
+
a: 1
|
|
1556
|
+
}).toHexString();
|
|
1557
|
+
}
|
|
1444
1558
|
}
|
|
1445
1559
|
_init = new WeakMap();
|
|
1446
1560
|
WJElement.define("wje-color-picker", ColorPicker);
|