@webtides/element-library 0.2.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +399 -3
- package/README.md +61 -41
- package/all.js +28 -0
- package/catalog.d.ts +14 -0
- package/catalog.js +55 -27
- package/custom-elements.json +16676 -3457
- package/package.json +35 -28
- package/src/components/accordion/accordion.changelog.md +10 -0
- package/src/components/accordion/accordion.js +10 -7
- package/src/components/accordion/accordion.readme.md +2 -0
- package/src/components/accordion/accordion.style.js +8 -0
- package/src/components/amount-field/amount-field.changelog.md +23 -3
- package/src/components/amount-field/amount-field.js +53 -26
- package/src/components/amount-field/amount-field.readme.md +82 -20
- package/src/components/amount-field/amount-field.style.js +111 -47
- package/src/components/avatar/avatar.changelog.md +23 -0
- package/src/components/avatar/avatar.define.js +3 -0
- package/src/components/avatar/avatar.js +115 -0
- package/src/components/avatar/avatar.readme.md +132 -0
- package/src/components/avatar/avatar.style.js +67 -0
- package/src/components/badge/badge.changelog.md +23 -0
- package/src/components/badge/badge.define.js +3 -0
- package/src/components/badge/badge.js +59 -0
- package/src/components/badge/badge.readme.md +109 -0
- package/src/components/badge/badge.style.js +63 -0
- package/src/components/breadcrumb/breadcrumb.changelog.md +22 -0
- package/src/components/breadcrumb/breadcrumb.define.js +3 -0
- package/src/components/breadcrumb/breadcrumb.js +47 -0
- package/src/components/breadcrumb/breadcrumb.readme.md +108 -0
- package/src/components/breadcrumb/breadcrumb.style.js +20 -0
- package/src/components/breadcrumb-item/breadcrumb-item.changelog.md +23 -0
- package/src/components/breadcrumb-item/breadcrumb-item.define.js +3 -0
- package/src/components/breadcrumb-item/breadcrumb-item.js +82 -0
- package/src/components/breadcrumb-item/breadcrumb-item.readme.md +106 -0
- package/src/components/breadcrumb-item/breadcrumb-item.style.js +92 -0
- package/src/components/button/button.changelog.md +44 -1
- package/src/components/button/button.js +338 -29
- package/src/components/button/button.readme.md +138 -10
- package/src/components/button/button.style.js +99 -120
- package/src/components/button-group/button-group.changelog.md +24 -0
- package/src/components/button-group/button-group.define.js +3 -0
- package/src/components/button-group/button-group.js +53 -0
- package/src/components/button-group/button-group.readme.md +114 -0
- package/src/components/button-group/button-group.style.js +41 -0
- package/src/components/card/card.changelog.md +23 -0
- package/src/components/card/card.define.js +3 -0
- package/src/components/card/card.js +73 -0
- package/src/components/card/card.readme.md +136 -0
- package/src/components/card/card.style.js +99 -0
- package/src/components/carousel/carousel.changelog.md +20 -0
- package/src/components/carousel/carousel.js +89 -40
- package/src/components/carousel/carousel.readme.md +39 -6
- package/src/components/carousel/carousel.style.js +21 -77
- package/src/components/carousel/glide/components/ShadowAnchors.js +3 -1
- package/src/components/carousel/glide/components/ShadowClones.js +21 -24
- package/src/components/carousel/glide/components/ShadowGaps.js +2 -2
- package/src/components/carousel/glide/components/ShadowHtml.js +22 -3
- package/src/components/checkbox-field/checkbox-field.changelog.md +25 -0
- package/src/components/checkbox-field/checkbox-field.js +32 -11
- package/src/components/checkbox-field/checkbox-field.readme.md +17 -4
- package/src/components/checkbox-field/checkbox-field.style.js +15 -3
- package/src/components/checkbox-group-field/checkbox-group-field.changelog.md +25 -0
- package/src/components/checkbox-group-field/checkbox-group-field.define.js +3 -0
- package/src/components/checkbox-group-field/checkbox-group-field.js +217 -0
- package/src/components/checkbox-group-field/checkbox-group-field.readme.md +95 -0
- package/src/components/checkbox-group-field/checkbox-group-field.style.js +62 -0
- package/src/components/color-field/color-field.changelog.md +24 -0
- package/src/components/color-field/color-field.define.js +3 -0
- package/src/components/color-field/color-field.js +184 -0
- package/src/components/color-field/color-field.readme.md +95 -0
- package/src/components/color-field/color-field.style.js +39 -0
- package/src/components/combobox-field/combobox-field.changelog.md +23 -0
- package/src/components/combobox-field/combobox-field.define.js +3 -0
- package/src/components/combobox-field/combobox-field.js +97 -0
- package/src/components/combobox-field/combobox-field.readme.md +93 -0
- package/src/components/combobox-field/combobox-field.style.js +56 -0
- package/src/components/copy-button/copy-button.changelog.md +24 -0
- package/src/components/copy-button/copy-button.define.js +3 -0
- package/src/components/copy-button/copy-button.events.js +4 -0
- package/src/components/copy-button/copy-button.js +237 -0
- package/src/components/copy-button/copy-button.readme.md +134 -0
- package/src/components/copy-button/copy-button.style.js +109 -0
- package/src/components/date-field/date-field.changelog.md +24 -0
- package/src/components/date-field/date-field.define.js +3 -0
- package/src/components/date-field/date-field.js +119 -0
- package/src/components/date-field/date-field.readme.md +110 -0
- package/src/components/date-field/date-field.style.js +53 -0
- package/src/components/dialog/dialog.changelog.md +16 -1
- package/src/components/dialog/dialog.js +252 -57
- package/src/components/dialog/dialog.readme.md +36 -4
- package/src/components/dialog/dialog.style.js +9 -109
- package/src/components/divider/divider.changelog.md +23 -0
- package/src/components/divider/divider.define.js +3 -0
- package/src/components/divider/divider.js +48 -0
- package/src/components/divider/divider.readme.md +101 -0
- package/src/components/divider/divider.style.js +50 -0
- package/src/components/drawer/drawer.changelog.md +25 -0
- package/src/components/drawer/drawer.define.js +3 -0
- package/src/components/drawer/drawer.events.js +8 -0
- package/src/components/drawer/drawer.js +80 -0
- package/src/components/drawer/drawer.readme.md +194 -0
- package/src/components/drawer/drawer.style.js +83 -0
- package/src/components/dropdown/dropdown.js +9 -7
- package/src/components/empty-state/empty-state.changelog.md +22 -0
- package/src/components/empty-state/empty-state.define.js +3 -0
- package/src/components/empty-state/empty-state.js +55 -0
- package/src/components/empty-state/empty-state.readme.md +114 -0
- package/src/components/empty-state/empty-state.style.js +60 -0
- package/src/components/file-field/file-field.changelog.md +24 -0
- package/src/components/file-field/file-field.define.js +3 -0
- package/src/components/file-field/file-field.js +205 -0
- package/src/components/file-field/file-field.readme.md +103 -0
- package/src/components/file-field/file-field.style.js +28 -0
- package/src/components/form-field/form-field.changelog.md +25 -0
- package/src/components/form-field/form-field.js +212 -15
- package/src/components/form-field/form-field.readme.md +82 -18
- package/src/components/form-field/form-field.style.js +6 -24
- package/src/components/input-field/input-field.changelog.md +24 -0
- package/src/components/input-field/input-field.js +82 -6
- package/src/components/input-field/input-field.readme.md +34 -5
- package/src/components/input-field/input-field.style.js +32 -13
- package/src/components/notification/notification.changelog.md +21 -1
- package/src/components/notification/notification.js +80 -74
- package/src/components/notification/notification.readme.md +54 -13
- package/src/components/notification/notification.style.js +37 -22
- package/src/components/otp-field/otp-field.changelog.md +23 -0
- package/src/components/otp-field/otp-field.define.js +3 -0
- package/src/components/otp-field/otp-field.events.js +3 -0
- package/src/components/otp-field/otp-field.js +172 -0
- package/src/components/otp-field/otp-field.readme.md +111 -0
- package/src/components/otp-field/otp-field.style.js +53 -0
- package/src/components/pagination/pagination.changelog.md +30 -0
- package/src/components/pagination/pagination.define.js +3 -0
- package/src/components/pagination/pagination.events.js +3 -0
- package/src/components/pagination/pagination.js +282 -0
- package/src/components/pagination/pagination.readme.md +167 -0
- package/src/components/pagination/pagination.style.js +162 -0
- package/src/components/password-field/password-field.changelog.md +24 -0
- package/src/components/password-field/password-field.js +7 -1
- package/src/components/password-field/password-field.readme.md +15 -6
- package/src/components/password-field/password-field.style.js +36 -13
- package/src/components/popover/popover.changelog.md +24 -0
- package/src/components/popover/popover.define.js +3 -0
- package/src/components/popover/popover.events.js +4 -0
- package/src/components/popover/popover.js +255 -0
- package/src/components/popover/popover.readme.md +132 -0
- package/src/components/popover/popover.style.js +41 -0
- package/src/components/progress-bar/progress-bar.changelog.md +23 -0
- package/src/components/progress-bar/progress-bar.define.js +3 -0
- package/src/components/progress-bar/progress-bar.js +80 -0
- package/src/components/progress-bar/progress-bar.readme.md +110 -0
- package/src/components/progress-bar/progress-bar.style.js +93 -0
- package/src/components/progress-ring/progress-ring.changelog.md +23 -0
- package/src/components/progress-ring/progress-ring.define.js +3 -0
- package/src/components/progress-ring/progress-ring.js +83 -0
- package/src/components/progress-ring/progress-ring.readme.md +115 -0
- package/src/components/progress-ring/progress-ring.style.js +85 -0
- package/src/components/radio-field/radio-field.changelog.md +16 -0
- package/src/components/radio-field/radio-field.js +34 -11
- package/src/components/radio-field/radio-field.readme.md +13 -8
- package/src/components/radio-field/radio-field.style.js +17 -65
- package/src/components/range-field/range-field.changelog.md +24 -0
- package/src/components/range-field/range-field.define.js +3 -0
- package/src/components/range-field/range-field.js +167 -0
- package/src/components/range-field/range-field.readme.md +87 -0
- package/src/components/range-field/range-field.style.js +41 -0
- package/src/components/rating-field/rating-field.changelog.md +24 -0
- package/src/components/rating-field/rating-field.define.js +3 -0
- package/src/components/rating-field/rating-field.js +195 -0
- package/src/components/rating-field/rating-field.readme.md +82 -0
- package/src/components/rating-field/rating-field.style.js +79 -0
- package/src/components/select-field/select-field.changelog.md +17 -0
- package/src/components/select-field/select-field.js +100 -8
- package/src/components/select-field/select-field.readme.md +32 -6
- package/src/components/select-field/select-field.style.js +19 -9
- package/src/components/skeleton/skeleton.changelog.md +22 -0
- package/src/components/skeleton/skeleton.define.js +3 -0
- package/src/components/skeleton/skeleton.js +49 -0
- package/src/components/skeleton/skeleton.readme.md +115 -0
- package/src/components/skeleton/skeleton.style.js +79 -0
- package/src/components/slider/slider.changelog.md +15 -0
- package/src/components/slider/slider.js +37 -5
- package/src/components/slider/slider.readme.md +28 -6
- package/src/components/slider/slider.style.js +7 -71
- package/src/components/spinner/spinner.changelog.md +22 -0
- package/src/components/spinner/spinner.define.js +3 -0
- package/src/components/spinner/spinner.js +48 -0
- package/src/components/spinner/spinner.readme.md +98 -0
- package/src/components/spinner/spinner.style.js +44 -0
- package/src/components/switch-field/switch-field.changelog.md +22 -0
- package/src/components/switch-field/switch-field.js +24 -10
- package/src/components/switch-field/switch-field.readme.md +11 -4
- package/src/components/switch-field/switch-field.style.js +13 -13
- package/src/components/tab-group/tab-group.changelog.md +19 -0
- package/src/components/tab-group/tab-group.js +122 -10
- package/src/components/tab-group/tab-group.readme.md +25 -4
- package/src/components/tab-link/tab-link.changelog.md +16 -0
- package/src/components/tab-link/tab-link.js +51 -8
- package/src/components/tab-link/tab-link.readme.md +14 -8
- package/src/components/tab-link/tab-link.style.js +13 -0
- package/src/components/tab-panel/tab-panel.changelog.md +8 -2
- package/src/components/tab-panel/tab-panel.js +7 -3
- package/src/components/tab-panel/tab-panel.readme.md +7 -5
- package/src/components/tag/tag.changelog.md +24 -0
- package/src/components/tag/tag.define.js +3 -0
- package/src/components/tag/tag.events.js +3 -0
- package/src/components/tag/tag.js +116 -0
- package/src/components/tag/tag.readme.md +119 -0
- package/src/components/tag/tag.style.js +101 -0
- package/src/components/tag-field/tag-field.changelog.md +25 -0
- package/src/components/tag-field/tag-field.define.js +3 -0
- package/src/components/tag-field/tag-field.js +359 -0
- package/src/components/tag-field/tag-field.readme.md +113 -0
- package/src/components/tag-field/tag-field.style.js +62 -0
- package/src/components/textarea-field/textarea-field.changelog.md +28 -4
- package/src/components/textarea-field/textarea-field.js +68 -14
- package/src/components/textarea-field/textarea-field.readme.md +45 -9
- package/src/components/textarea-field/textarea-field.style.js +45 -2
- package/src/components/toast/toast.changelog.md +24 -0
- package/src/components/toast/toast.define.js +3 -0
- package/src/components/toast/toast.js +193 -0
- package/src/components/toast/toast.readme.md +189 -0
- package/src/components/toast/toast.style.js +74 -0
- package/src/components/tooltip/tooltip.changelog.md +24 -0
- package/src/components/tooltip/tooltip.define.js +3 -0
- package/src/components/tooltip/tooltip.events.js +4 -0
- package/src/components/tooltip/tooltip.js +377 -0
- package/src/components/tooltip/tooltip.readme.md +172 -0
- package/src/components/tooltip/tooltip.style.js +107 -0
- package/src/components/transition-classes/transition-classes.js +6 -6
- package/src/styles/appearance.style.js +42 -0
- package/src/styles/arrow.style.js +65 -0
- package/src/styles/choice-group.style.js +94 -0
- package/src/styles/form-control.style.js +79 -0
- package/src/styles/host.style.js +55 -0
- package/src/styles/layers.css +31 -0
- package/src/styles/modal.style.js +146 -0
- package/src/styles/native.css +275 -0
- package/src/styles/size.style.js +48 -0
- package/src/styles/slide-controls.style.js +225 -0
- package/src/styles/utilities.css +30 -0
- package/src/styles/variants.style.js +78 -0
- package/src/themes/default.css +86 -142
- package/src/themes/high-contrast.css +72 -129
- package/src/themes/sketchy.css +95 -175
- package/src/utils/floating.js +71 -0
- package/src/utils/focus.js +18 -0
- package/src/utils/progress.js +25 -0
- package/src/utils/slots.js +21 -0
- package/src/utils/text-entry-attributes.js +51 -0
- package/types/all.d.ts +54 -1
- package/types/index.d.ts +1 -0
- package/types/src/components/accordion/accordion.d.ts +6 -4
- package/types/src/components/accordion/accordion.events.d.ts +3 -3
- package/types/src/components/accordion-group/accordion-group.d.ts +4 -3
- package/types/src/components/amount-field/amount-field.d.ts +30 -16
- package/types/src/components/avatar/avatar.d.ts +57 -0
- package/types/src/components/avatar/avatar.define.d.ts +1 -0
- package/types/src/components/avatar/avatar.style.d.ts +2 -0
- package/types/src/components/badge/badge.d.ts +32 -0
- package/types/src/components/badge/badge.define.d.ts +1 -0
- package/types/src/components/badge/badge.style.d.ts +2 -0
- package/types/src/components/breadcrumb/breadcrumb.d.ts +27 -0
- package/types/src/components/breadcrumb/breadcrumb.define.d.ts +1 -0
- package/types/src/components/breadcrumb/breadcrumb.style.d.ts +2 -0
- package/types/src/components/breadcrumb-item/breadcrumb-item.d.ts +38 -0
- package/types/src/components/breadcrumb-item/breadcrumb-item.define.d.ts +1 -0
- package/types/src/components/breadcrumb-item/breadcrumb-item.style.d.ts +2 -0
- package/types/src/components/button/button.d.ts +158 -14
- package/types/src/components/button-group/button-group.d.ts +28 -0
- package/types/src/components/button-group/button-group.define.d.ts +1 -0
- package/types/src/components/button-group/button-group.style.d.ts +2 -0
- package/types/src/components/card/card.d.ts +40 -0
- package/types/src/components/card/card.define.d.ts +1 -0
- package/types/src/components/card/card.style.d.ts +2 -0
- package/types/src/components/carousel/carousel.d.ts +22 -8
- package/types/src/components/carousel/carousel.events.d.ts +3 -3
- package/types/src/components/carousel/glide/components/ShadowAnchors.d.ts +1 -1
- package/types/src/components/carousel/glide/components/ShadowClones.d.ts +8 -1
- package/types/src/components/carousel/glide/components/ShadowGaps.d.ts +1 -1
- package/types/src/components/carousel/glide/components/ShadowHtml.d.ts +1 -1
- package/types/src/components/carousel/glide/components/glide-html.d.ts +1 -1
- package/types/src/components/checkbox-field/checkbox-field.d.ts +22 -15
- package/types/src/components/checkbox-group-field/checkbox-group-field.d.ts +100 -0
- package/types/src/components/checkbox-group-field/checkbox-group-field.define.d.ts +1 -0
- package/types/src/components/checkbox-group-field/checkbox-group-field.style.d.ts +2 -0
- package/types/src/components/color-field/color-field.d.ts +102 -0
- package/types/src/components/color-field/color-field.define.d.ts +1 -0
- package/types/src/components/color-field/color-field.style.d.ts +2 -0
- package/types/src/components/combobox-field/combobox-field.d.ts +84 -0
- package/types/src/components/combobox-field/combobox-field.define.d.ts +1 -0
- package/types/src/components/combobox-field/combobox-field.style.d.ts +2 -0
- package/types/src/components/copy-button/copy-button.d.ts +93 -0
- package/types/src/components/copy-button/copy-button.define.d.ts +1 -0
- package/types/src/components/copy-button/copy-button.events.d.ts +5 -0
- package/types/src/components/copy-button/copy-button.style.d.ts +2 -0
- package/types/src/components/date-field/date-field.d.ts +102 -0
- package/types/src/components/date-field/date-field.define.d.ts +1 -0
- package/types/src/components/date-field/date-field.style.d.ts +2 -0
- package/types/src/components/dialog/dialog.d.ts +101 -19
- package/types/src/components/dialog/dialog.events.d.ts +8 -8
- package/types/src/components/divider/divider.d.ts +27 -0
- package/types/src/components/divider/divider.define.d.ts +1 -0
- package/types/src/components/divider/divider.style.d.ts +2 -0
- package/types/src/components/drawer/drawer.d.ts +70 -0
- package/types/src/components/drawer/drawer.define.d.ts +1 -0
- package/types/src/components/drawer/drawer.events.d.ts +9 -0
- package/types/src/components/drawer/drawer.style.d.ts +2 -0
- package/types/src/components/dropdown/dropdown.d.ts +5 -3
- package/types/src/components/empty-state/empty-state.d.ts +29 -0
- package/types/src/components/empty-state/empty-state.define.d.ts +1 -0
- package/types/src/components/empty-state/empty-state.style.d.ts +2 -0
- package/types/src/components/file-field/file-field.d.ts +115 -0
- package/types/src/components/file-field/file-field.define.d.ts +1 -0
- package/types/src/components/file-field/file-field.style.d.ts +2 -0
- package/types/src/components/form-field/form-field.d.ts +129 -14
- package/types/src/components/form-field/form-field.events.d.ts +4 -4
- package/types/src/components/input-field/input-field.d.ts +52 -5
- package/types/src/components/lazy-src/lazy-src.d.ts +7 -5
- package/types/src/components/lazy-src/lazy-src.events.d.ts +5 -5
- package/types/src/components/notification/notification.d.ts +18 -18
- package/types/src/components/notification/notification.events.d.ts +6 -6
- package/types/src/components/otp-field/otp-field.d.ts +130 -0
- package/types/src/components/otp-field/otp-field.define.d.ts +1 -0
- package/types/src/components/otp-field/otp-field.events.d.ts +4 -0
- package/types/src/components/otp-field/otp-field.style.d.ts +2 -0
- package/types/src/components/pagination/pagination.d.ts +117 -0
- package/types/src/components/pagination/pagination.define.d.ts +1 -0
- package/types/src/components/pagination/pagination.events.d.ts +4 -0
- package/types/src/components/pagination/pagination.style.d.ts +2 -0
- package/types/src/components/password-field/password-field.d.ts +29 -12
- package/types/src/components/popover/popover.d.ts +123 -0
- package/types/src/components/popover/popover.define.d.ts +1 -0
- package/types/src/components/popover/popover.events.d.ts +5 -0
- package/types/src/components/popover/popover.style.d.ts +2 -0
- package/types/src/components/progress-bar/progress-bar.d.ts +35 -0
- package/types/src/components/progress-bar/progress-bar.define.d.ts +1 -0
- package/types/src/components/progress-bar/progress-bar.style.d.ts +2 -0
- package/types/src/components/progress-ring/progress-ring.d.ts +40 -0
- package/types/src/components/progress-ring/progress-ring.define.d.ts +1 -0
- package/types/src/components/progress-ring/progress-ring.style.d.ts +2 -0
- package/types/src/components/radio-field/radio-field.d.ts +21 -9
- package/types/src/components/range-field/range-field.d.ts +94 -0
- package/types/src/components/range-field/range-field.define.d.ts +1 -0
- package/types/src/components/range-field/range-field.style.d.ts +2 -0
- package/types/src/components/rating-field/rating-field.d.ts +96 -0
- package/types/src/components/rating-field/rating-field.define.d.ts +1 -0
- package/types/src/components/rating-field/rating-field.style.d.ts +2 -0
- package/types/src/components/scroll-to/scroll-to.d.ts +3 -2
- package/types/src/components/scroll-to-top/scroll-to-top.d.ts +4 -2
- package/types/src/components/select-field/select-field.d.ts +55 -5
- package/types/src/components/skeleton/skeleton.d.ts +29 -0
- package/types/src/components/skeleton/skeleton.define.d.ts +1 -0
- package/types/src/components/skeleton/skeleton.style.d.ts +2 -0
- package/types/src/components/slider/slider.d.ts +14 -8
- package/types/src/components/slider/slider.events.d.ts +4 -4
- package/types/src/components/spinner/spinner.d.ts +28 -0
- package/types/src/components/spinner/spinner.define.d.ts +1 -0
- package/types/src/components/spinner/spinner.style.d.ts +2 -0
- package/types/src/components/sticky/sticky.d.ts +4 -2
- package/types/src/components/svg-use/svg-use.d.ts +4 -2
- package/types/src/components/switch-field/switch-field.d.ts +17 -15
- package/types/src/components/tab-group/tab-group.d.ts +44 -3
- package/types/src/components/tab-link/tab-link.d.ts +33 -10
- package/types/src/components/tab-panel/tab-panel.d.ts +8 -5
- package/types/src/components/tag/tag.d.ts +53 -0
- package/types/src/components/tag/tag.define.d.ts +1 -0
- package/types/src/components/tag/tag.events.d.ts +4 -0
- package/types/src/components/tag/tag.style.d.ts +2 -0
- package/types/src/components/tag-field/tag-field.d.ts +178 -0
- package/types/src/components/tag-field/tag-field.define.d.ts +1 -0
- package/types/src/components/tag-field/tag-field.style.d.ts +2 -0
- package/types/src/components/textarea-field/textarea-field.d.ts +44 -4
- package/types/src/components/toast/toast.d.ts +110 -0
- package/types/src/components/toast/toast.define.d.ts +1 -0
- package/types/src/components/toast/toast.style.d.ts +2 -0
- package/types/src/components/tooltip/tooltip.d.ts +161 -0
- package/types/src/components/tooltip/tooltip.define.d.ts +1 -0
- package/types/src/components/tooltip/tooltip.events.d.ts +5 -0
- package/types/src/components/tooltip/tooltip.style.d.ts +2 -0
- package/types/src/components/transition-classes/transition-classes.d.ts +9 -8
- package/types/src/styles/appearance.style.d.ts +18 -0
- package/types/src/styles/arrow.style.d.ts +15 -0
- package/types/src/styles/choice-group.style.d.ts +23 -0
- package/types/src/styles/form-control.style.d.ts +26 -0
- package/types/src/styles/host.style.d.ts +24 -0
- package/types/src/styles/modal.style.d.ts +20 -0
- package/types/src/styles/size.style.d.ts +20 -0
- package/types/src/styles/slide-controls.style.d.ts +20 -0
- package/types/src/styles/variants.style.d.ts +32 -0
- package/types/src/utils/body-scroll.d.ts +12 -2
- package/types/src/utils/floating.d.ts +36 -0
- package/types/src/utils/focus.d.ts +16 -0
- package/types/src/utils/progress.d.ts +19 -0
- package/types/src/utils/slots.d.ts +19 -0
- package/types/src/utils/text-entry-attributes.d.ts +18 -0
- package/types/src/utils/transitions.d.ts +2 -2
- package/web-types.json +6590 -1584
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { html, defineElement } from '@webtides/element-js';
|
|
2
|
+
import FormField, { FormFieldEvents } from '../form-field/form-field.js';
|
|
3
|
+
import style from './color-field.style.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A colour, picked in the picker of the browser. Renders a native `<input type="color">`, so the
|
|
7
|
+
* picker, the keyboard and the form submission are the ones of the browser. Extends `FormField`
|
|
8
|
+
* and inherits its label / help / error surface.
|
|
9
|
+
*
|
|
10
|
+
* The control always has a value: without one it is black. The field takes that value over, so
|
|
11
|
+
* that `value` says what the form submits.
|
|
12
|
+
*
|
|
13
|
+
* @element el-color-field
|
|
14
|
+
*
|
|
15
|
+
* @fires {CustomEvent<string>} input-change - Fired when the value changes, also while the user
|
|
16
|
+
* goes through the picker. `detail` is the new value. Bubbles.
|
|
17
|
+
*
|
|
18
|
+
* @cssstate touched - Set on the host once the user has focused and left the control. Inherits
|
|
19
|
+
* `valid` and `invalid` from `FormField`.
|
|
20
|
+
*
|
|
21
|
+
* @property {string | null} value - The colour, as the text the form submits: `#rrggbb`. A field
|
|
22
|
+
* without one takes over the value of the control, `#000000`.
|
|
23
|
+
* @property {'small'|'medium'|'large'} size - Size of the control. Default `'medium'`. Reflected to
|
|
24
|
+
* the `size` attribute. It shows once the control is decorated (`styles/native.css`); a control
|
|
25
|
+
* with the look of the browser keeps its size.
|
|
26
|
+
* @property {boolean} showValue - Shows the value beside the control. Default `false`.
|
|
27
|
+
* @property {Array<string | { value: string, label?: string }>} options - Colours the picker of the
|
|
28
|
+
* browser offers: plain strings (`['#2563eb', '#16a34a']`) or option objects. Without options the
|
|
29
|
+
* control has no list.
|
|
30
|
+
*/
|
|
31
|
+
export default class ColorField extends FormField {
|
|
32
|
+
/**
|
|
33
|
+
* The value that `input-change` last reported, or that the field started with. See `watch()`.
|
|
34
|
+
* @private
|
|
35
|
+
*/
|
|
36
|
+
_reportedValue = undefined;
|
|
37
|
+
|
|
38
|
+
constructor(options) {
|
|
39
|
+
super({
|
|
40
|
+
shadowRender: false,
|
|
41
|
+
styles: [style],
|
|
42
|
+
...options,
|
|
43
|
+
// The size module selects the host by the `size` attribute.
|
|
44
|
+
propertyOptions: { size: { reflect: true }, ...options?.propertyOptions },
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
properties() {
|
|
49
|
+
return {
|
|
50
|
+
...super.properties(),
|
|
51
|
+
size: 'medium',
|
|
52
|
+
showValue: false,
|
|
53
|
+
options: [],
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* A form field takes a control with a value as touched: someone has filled it in. The control
|
|
59
|
+
* of this field always has a value, so that says nothing here.
|
|
60
|
+
*/
|
|
61
|
+
connected() {
|
|
62
|
+
if (this.valid === false) this.touched = true;
|
|
63
|
+
this.syncValidationStates();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
afterUpdate() {
|
|
67
|
+
// Before the form field keeps the state for a reset: what the field takes over from the
|
|
68
|
+
// control is part of it.
|
|
69
|
+
this._matchControl();
|
|
70
|
+
if (this._reportedValue === undefined) this._reportedValue = this.value;
|
|
71
|
+
super.afterUpdate();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
watch() {
|
|
75
|
+
return {
|
|
76
|
+
...super.watch(),
|
|
77
|
+
// The watcher runs a frame after the change, once for every change, and the field can
|
|
78
|
+
// have taken another value over from the control by then. So it is the value of now
|
|
79
|
+
// that is reported, and each one once.
|
|
80
|
+
value: () => {
|
|
81
|
+
this._matchControl();
|
|
82
|
+
if (this.value === this._reportedValue) return;
|
|
83
|
+
this._reportedValue = this.value;
|
|
84
|
+
this.dispatch(FormFieldEvents.INPUT_CHANGE, this.value);
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
events() {
|
|
90
|
+
return {
|
|
91
|
+
'[ref=input]': {
|
|
92
|
+
// The value follows the picker while the user goes through it. `change`, when the
|
|
93
|
+
// picker is closed, has nothing new to say.
|
|
94
|
+
input: () => this.onChange(),
|
|
95
|
+
focus: () => this.onFocus(),
|
|
96
|
+
blur: () => this.onBlur(),
|
|
97
|
+
invalid: (event) => this._onInvalid(event.target),
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Makes the control and `value` say the same, after every render and every change of `value`.
|
|
104
|
+
*
|
|
105
|
+
* The `value` attribute of the control is only its default: once the user has picked a colour,
|
|
106
|
+
* a value from outside has to be written to the control. The control in turn keeps a colour in
|
|
107
|
+
* its own format: it writes `#F00` as `#ff0000`, and is black for a text that is no colour and
|
|
108
|
+
* when it is given none. The field takes over what the control made of the value: that is what
|
|
109
|
+
* the form submits.
|
|
110
|
+
* @private
|
|
111
|
+
*/
|
|
112
|
+
_matchControl() {
|
|
113
|
+
const control = this.$refs.input;
|
|
114
|
+
if (!control) return;
|
|
115
|
+
|
|
116
|
+
const wanted = String(this.value ?? '');
|
|
117
|
+
if (control.value !== wanted) control.value = wanted;
|
|
118
|
+
if (control.value !== wanted) this.value = control.value;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* The colours of `options`, as the options of the list.
|
|
123
|
+
* @private
|
|
124
|
+
* @returns {Array<{ value: string, label: string | null }>}
|
|
125
|
+
*/
|
|
126
|
+
_colors() {
|
|
127
|
+
if (!Array.isArray(this.options)) return [];
|
|
128
|
+
return this.options.map((option) => ({
|
|
129
|
+
value: String(option?.value ?? option),
|
|
130
|
+
label: option?.label ?? null,
|
|
131
|
+
}));
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** @private */
|
|
135
|
+
fieldTemplate() {
|
|
136
|
+
const colors = this._colors();
|
|
137
|
+
|
|
138
|
+
return html`
|
|
139
|
+
<input
|
|
140
|
+
ref="input"
|
|
141
|
+
type="color"
|
|
142
|
+
id="${this._idOf('input')}"
|
|
143
|
+
name="${this.name}"
|
|
144
|
+
value="${this.value}"
|
|
145
|
+
?disabled="${this.disabled}"
|
|
146
|
+
list="${colors.length > 0 ? this._idOf('list') : null}"
|
|
147
|
+
aria-describedby="${this._describedBy()}"
|
|
148
|
+
aria-invalid="${this.valid ? 'false' : 'true'}"
|
|
149
|
+
aria-errormessage="${this._idOf('error-message')}"
|
|
150
|
+
/>
|
|
151
|
+
${this.listTemplate(colors)} ${this.valueTemplate()}
|
|
152
|
+
`;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* The colours the picker of the browser offers. A control without them has no list: an empty
|
|
157
|
+
* one would be an offer of nothing.
|
|
158
|
+
* @private
|
|
159
|
+
* @param {Array<{ value: string, label: string | null }>} colors
|
|
160
|
+
*/
|
|
161
|
+
listTemplate(colors) {
|
|
162
|
+
if (colors.length === 0) return null;
|
|
163
|
+
|
|
164
|
+
return html`
|
|
165
|
+
<datalist id="${this._idOf('list')}">
|
|
166
|
+
${colors.map((color) => html`<option value="${color.value}" label="${color.label}"></option>`)}
|
|
167
|
+
</datalist>
|
|
168
|
+
`;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* The value beside the control. It is hidden from assistive technology: the control says its
|
|
173
|
+
* value itself, and would be heard twice.
|
|
174
|
+
* @private
|
|
175
|
+
*/
|
|
176
|
+
valueTemplate() {
|
|
177
|
+
if (!this.showValue) return null;
|
|
178
|
+
return html`<span class="value" aria-hidden="true">${this.value}</span>`;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export function define() {
|
|
183
|
+
defineElement('el-color-field', ColorField);
|
|
184
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# ColorField
|
|
2
|
+
|
|
3
|
+
`color-field` takes a colour: the colour of a label, of a calendar, the accent of a workspace. It renders a native `<input type="color">`, so the picker, the keyboard and the form submission are the ones of the browser. It extends `form-field`, inheriting the label, help text, error message and touched-state handling.
|
|
4
|
+
|
|
5
|
+
It is headless by default: the control keeps the look of the browser. `styles/native.css` gives it the border, the radius and the height of the other controls.
|
|
6
|
+
|
|
7
|
+
## How to use
|
|
8
|
+
|
|
9
|
+
#### Install
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm i --save @webtides/element-library
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
#### Use
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
import '@webtides/element-library/color-field/define';
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
```html
|
|
22
|
+
<el-color-field name="accent" label="Accent colour" value="#2563eb"></el-color-field>
|
|
23
|
+
|
|
24
|
+
<el-color-field
|
|
25
|
+
name="label"
|
|
26
|
+
label="Label colour"
|
|
27
|
+
value="#16a34a"
|
|
28
|
+
show-value="true"
|
|
29
|
+
options='["#2563eb", "#16a34a", "#f59e0b", "#dc2626"]'
|
|
30
|
+
></el-color-field>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
#### The value
|
|
34
|
+
|
|
35
|
+
The value is the colour as the control has it: `#rrggbb`, in lower case. That is what the form submits.
|
|
36
|
+
|
|
37
|
+
A colour input always has a value. Without a `value` the control is black, and the field takes that over: `value` is `#000000`. That is no change, so no `input-change` reports it.
|
|
38
|
+
|
|
39
|
+
The control also brings a value from outside into its format, and the field takes over what the control made of it: `#F00` becomes `#ff0000`. A text that is no colour becomes black. Which other notations a browser reads (`red`, `rgb(255 0 0)`) is up to the browser, so give the field `#rrggbb`.
|
|
40
|
+
|
|
41
|
+
The field cannot be empty. A page that needs "no colour" puts a checkbox or a button beside it.
|
|
42
|
+
|
|
43
|
+
#### Colours to pick from
|
|
44
|
+
|
|
45
|
+
`options` is a list of colours the picker of the browser offers, the colours of a brand for example. The field renders them as the native list of the control (`<datalist>`). How a browser shows them is up to the browser, and one that does not know the list shows its picker without them. The user can still pick any other colour.
|
|
46
|
+
|
|
47
|
+
```js
|
|
48
|
+
field.options = ['#2563eb', '#16a34a', '#f59e0b', '#dc2626'];
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## API
|
|
52
|
+
|
|
53
|
+
#### Properties/Attributes
|
|
54
|
+
|
|
55
|
+
Inherits all of `form-field`'s properties (`name`, `value`, `disabled`, `label`, `labelScreenReaderOnly`, `errorMessage`, `helpMessage`, `valid`, `touched`) and adds:
|
|
56
|
+
|
|
57
|
+
| Name | Type | Default | Description |
|
|
58
|
+
| --- | --- | --- | --- |
|
|
59
|
+
| `value` | `string` | `null` | The colour, `#rrggbb`. Without one: the value of the control, see above. |
|
|
60
|
+
| `size` | `'small' \| 'medium' \| 'large'` | `'medium'` | Size of the control. Reflected to the `size` attribute. It shows once the control is decorated. |
|
|
61
|
+
| `showValue` | `boolean` | `false` | Shows the value beside the control (`show-value`). |
|
|
62
|
+
| `options` | `Array<string \| { value, label? }>` | `[]` | Colours the picker offers. A `label` is passed on to the option of the list. |
|
|
63
|
+
|
|
64
|
+
`required` has no effect: the control always has a value. The browser never finds a colour invalid, so the error message shows when the page sets `valid="false"` after a check of its own.
|
|
65
|
+
|
|
66
|
+
#### Events
|
|
67
|
+
|
|
68
|
+
| Name | Detail | Description |
|
|
69
|
+
| --- | --- | --- |
|
|
70
|
+
| `input-change` | `string` (the value) | Fired when the value changes, also while the user goes through the picker. Each value once. |
|
|
71
|
+
|
|
72
|
+
#### CSS States
|
|
73
|
+
|
|
74
|
+
| Name | Description |
|
|
75
|
+
| --------- | ----------------------------------------------------------------------------------------- |
|
|
76
|
+
| `touched` | Set once the control has been focused and left. A value alone does not set it. |
|
|
77
|
+
| `valid` | Set while the field passes validation. |
|
|
78
|
+
| `invalid` | Set while the field fails validation, which for this field is when the page says it does. |
|
|
79
|
+
|
|
80
|
+
#### CSS Custom Properties
|
|
81
|
+
|
|
82
|
+
Headless by default. The texts read the tokens every field reads (`--el-color-fg`, `--el-color-fg-muted`, `--el-color-danger`, `--el-font-size-sm`, `--el-space-1`, `--el-space-2`). With `styles/native.css` the control is a well with the border of the other controls (`--el-border-width`, `--el-color-border`, `--el-radius-md`) on `--el-color-bg`. It is as high as an input of its size (`--el-control-height`) and half again as wide, and the colour fills it up to a rim of `--el-space-1`. Keyboard focus shows the ring of the theme (`--el-focus-ring-width`, `--el-focus-ring-offset`, `--el-color-focus-ring`).
|
|
83
|
+
|
|
84
|
+
The label, the help message, the control and the error message stack in a column, and the texts have one look in every field: see [Layout](../form-field/form-field.readme.md#layout) in the readme of `form-field`. The shown value stands after the control, in its row.
|
|
85
|
+
|
|
86
|
+
On a touch screen (`@media (any-pointer: coarse)`) the control is at least `--el-touch-target` high. Without that token, and on a fine pointer, the size stays as it is.
|
|
87
|
+
|
|
88
|
+
## Accessibility
|
|
89
|
+
|
|
90
|
+
- The native control is named by the label, and it says its value itself. Enter and Space open the picker of the browser, which brings its own keyboard handling.
|
|
91
|
+
- The shown value is hidden from assistive technology (`aria-hidden`): the control already says it, and it would be heard twice.
|
|
92
|
+
- A colour alone says little to a user who cannot tell colours apart. `show-value` gives the value as text; where a colour has a meaning, name it in the page.
|
|
93
|
+
- The control names the help message in `aria-describedby`, and the error message while that is shown.
|
|
94
|
+
- The control says whether the field is valid (`aria-invalid`).
|
|
95
|
+
- The error message is an alert (`role="alert"`): a screen reader announces it when it appears.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import hostStyle from '../../styles/host.style.js';
|
|
2
|
+
import formControlStyle from '../../styles/form-control.style.js';
|
|
3
|
+
import sizeStyle from '../../styles/size.style.js';
|
|
4
|
+
|
|
5
|
+
const css = String.raw;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The control keeps the look of the browser, as the control of every field does: `styles/native.css`
|
|
9
|
+
* gives it the border and the height of the other controls.
|
|
10
|
+
*/
|
|
11
|
+
const style = css`
|
|
12
|
+
el-color-field {
|
|
13
|
+
/* The value beside the control. Every colour has as many characters, and digits of one
|
|
14
|
+
width keep the text from moving while the user goes through the picker. */
|
|
15
|
+
.value {
|
|
16
|
+
flex: none;
|
|
17
|
+
color: var(--el-color-fg, inherit);
|
|
18
|
+
font-variant-numeric: tabular-nums;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/* Touch screens: the control is at least --el-touch-target high, whatever the size of the
|
|
22
|
+
field. Without the token the size stays as it is. */
|
|
23
|
+
@media (any-pointer: coarse) {
|
|
24
|
+
input {
|
|
25
|
+
min-height: max(
|
|
26
|
+
calc(var(--el-control-height, 0px) * var(--_el-size-scale, 1)),
|
|
27
|
+
var(--el-touch-target, 0px)
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
`;
|
|
33
|
+
|
|
34
|
+
export default [
|
|
35
|
+
hostStyle('el-color-field'),
|
|
36
|
+
formControlStyle('el-color-field'),
|
|
37
|
+
sizeStyle('el-color-field'),
|
|
38
|
+
style,
|
|
39
|
+
].join('\n');
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this component live here. Versions refer to the parent `@webtides/element-library` release (see root [`CHANGELOG.md`](../../../CHANGELOG.md)); components no longer version independently.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/).
|
|
6
|
+
|
|
7
|
+
<!--
|
|
8
|
+
When your PR touches this component, add an entry under Unreleased and
|
|
9
|
+
mirror it (prefixed with the component name) in root CHANGELOG.md.
|
|
10
|
+
Uncomment headings as needed.
|
|
11
|
+
-->
|
|
12
|
+
|
|
13
|
+
## Unreleased
|
|
14
|
+
|
|
15
|
+
## [0.3.0] - 2026-11-17
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- Initial `el-combobox-field`: a text the user writes, with suggestions the browser offers while they type. An `el-input-field` with a native `<datalist>`, so it has the label, the messages, `required`, `pattern`, the sizes and the place in a form of an input field. ([#145](https://github.com/webtides/element-library/issues/145))
|
|
20
|
+
- `options` are the suggestions: plain strings, or `{ value, label }`. The field renders them as a list with an id of its own and names it on the control. Options that change reach the list, for suggestions a page loads while the user types.
|
|
21
|
+
- Without options there is no list, and the control is a plain text input, also for a screen reader.
|
|
22
|
+
- The value is free text: a suggestion is an offer, not a limit. `value` follows what is typed and what is picked, and `input-change` reports it.
|
|
23
|
+
- With `styles/native.css` the input has the look and the three sizes of the input of `el-input-field`. The list of the suggestions is drawn by the browser.
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { html, defineElement } from '@webtides/element-js';
|
|
2
|
+
import InputField from '../input-field/input-field.js';
|
|
3
|
+
import style from './combobox-field.style.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A text the user writes, with suggestions the browser offers while they type: a city, a job
|
|
7
|
+
* title, the name of a product. Extends `InputField` (and therefore `FormField`), inheriting the
|
|
8
|
+
* label / help / error / validation surface and the look from `styles/native.css`.
|
|
9
|
+
*
|
|
10
|
+
* The suggestions are a native `<datalist>`: the browser filters and shows them, and the keyboard
|
|
11
|
+
* and a screen reader work as the browser has them. A suggestion is an offer, not a limit: the
|
|
12
|
+
* value is free text. For a choice from a fixed list there is `el-select-field`.
|
|
13
|
+
*
|
|
14
|
+
* @element el-combobox-field
|
|
15
|
+
*
|
|
16
|
+
* @fires {CustomEvent<string>} input-change - Fired when the value changes: typed, or picked from
|
|
17
|
+
* the suggestions. `detail` is the new value. Bubbles.
|
|
18
|
+
*
|
|
19
|
+
* @property {Array<string | { value: string, label?: string }>} options - The suggestions: plain
|
|
20
|
+
* strings (`['Berlin', 'Bern']`) or option objects. The `value` is what a pick writes into the
|
|
21
|
+
* control; a `label` is a text the browser may show with it. Without options the control has no
|
|
22
|
+
* list and is a plain text input.
|
|
23
|
+
*/
|
|
24
|
+
export default class ComboboxField extends InputField {
|
|
25
|
+
constructor(options) {
|
|
26
|
+
super({ shadowRender: false, styles: [style], ...options });
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
properties() {
|
|
30
|
+
return {
|
|
31
|
+
...super.properties(),
|
|
32
|
+
options: [],
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
events() {
|
|
37
|
+
const events = super.events();
|
|
38
|
+
return {
|
|
39
|
+
...events,
|
|
40
|
+
'[ref=input]': {
|
|
41
|
+
...events['[ref=input]'],
|
|
42
|
+
// A pick from the suggestions presses no key that the field would hear, and not
|
|
43
|
+
// every browser fires `change` before the control is left.
|
|
44
|
+
input: () => this.onChange(),
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The suggestions of `options`, as the options of the list.
|
|
51
|
+
* @private
|
|
52
|
+
* @returns {Array<{ value: string, label: string | null }>}
|
|
53
|
+
*/
|
|
54
|
+
_suggestions() {
|
|
55
|
+
if (!Array.isArray(this.options)) return [];
|
|
56
|
+
return this.options.map((option) => ({
|
|
57
|
+
value: String(option?.value ?? option),
|
|
58
|
+
label: option?.label ?? null,
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* The control names its list. Without suggestions it has none: a list that is empty would
|
|
64
|
+
* still make the control a combobox for a screen reader, one that offers nothing.
|
|
65
|
+
* @private
|
|
66
|
+
*/
|
|
67
|
+
_controlAttributes() {
|
|
68
|
+
return { list: this._suggestions().length > 0 ? this._idOf('list') : null };
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** @private */
|
|
72
|
+
fieldTemplate() {
|
|
73
|
+
return html`${super.fieldTemplate()} ${this.listTemplate()}`;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* The suggestions, in the list the control names. The id is the one of this field alone, so
|
|
78
|
+
* two fields of a page do not offer the suggestions of each other.
|
|
79
|
+
* @private
|
|
80
|
+
*/
|
|
81
|
+
listTemplate() {
|
|
82
|
+
const suggestions = this._suggestions();
|
|
83
|
+
if (suggestions.length === 0) return null;
|
|
84
|
+
|
|
85
|
+
return html`
|
|
86
|
+
<datalist id="${this._idOf('list')}">
|
|
87
|
+
${suggestions.map(
|
|
88
|
+
(suggestion) => html`<option value="${suggestion.value}" label="${suggestion.label}"></option>`,
|
|
89
|
+
)}
|
|
90
|
+
</datalist>
|
|
91
|
+
`;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function define() {
|
|
96
|
+
defineElement('el-combobox-field', ComboboxField);
|
|
97
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# ComboboxField
|
|
2
|
+
|
|
3
|
+
`combobox-field` takes a text the user writes, with suggestions the browser offers while they type: a city, a job title, the name of a product. It extends `input-field`, inheriting the label, help text, error message, `required`, `pattern`, the sizes and the touched-state handling.
|
|
4
|
+
|
|
5
|
+
The suggestions are a native `<datalist>`. The browser filters and shows them, and the keyboard and a screen reader work as the browser has them; the field has no list of its own.
|
|
6
|
+
|
|
7
|
+
A suggestion is an offer, not a limit: the value is free text, and the user may write something the list does not have. For a choice from a fixed list use `el-select-field`, for several texts `el-tag-field`.
|
|
8
|
+
|
|
9
|
+
It is headless by default: the control keeps the look of the browser. `styles/native.css` gives it the look of the input of `el-input-field`. The list of the suggestions is drawn by the browser and stays as it is.
|
|
10
|
+
|
|
11
|
+
## How to use
|
|
12
|
+
|
|
13
|
+
#### Install
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
npm i --save @webtides/element-library
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
#### Use
|
|
20
|
+
|
|
21
|
+
```js
|
|
22
|
+
import '@webtides/element-library/combobox-field/define';
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
```html
|
|
26
|
+
<el-combobox-field name="city" label="City" options='["Berlin", "Bern", "Bremen", "Brussels"]'></el-combobox-field>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
#### The suggestions
|
|
30
|
+
|
|
31
|
+
`options` takes plain strings, or option objects in the shape the other fields have:
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
field.options = ['Berlin', 'Bern'];
|
|
35
|
+
field.options = [
|
|
36
|
+
{ value: 'Berlin', label: 'Germany' },
|
|
37
|
+
{ value: 'Bern', label: 'Switzerland' }
|
|
38
|
+
];
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
The `value` of a suggestion is what a pick writes into the control, and so what the form submits. A `label` is a second text for it. What a browser shows of the two, and which of them it filters by, differs between browsers: do not put a value there that the user is not meant to see.
|
|
42
|
+
|
|
43
|
+
Without options the control has no list: it is a plain text input, also for a screen reader.
|
|
44
|
+
|
|
45
|
+
#### Suggestions from a server
|
|
46
|
+
|
|
47
|
+
`options` can change while the user types. Listen for `input-change`, load, and set the new list:
|
|
48
|
+
|
|
49
|
+
```js
|
|
50
|
+
field.addEventListener('input-change', async (event) => {
|
|
51
|
+
field.options = await search(event.detail);
|
|
52
|
+
});
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
The browser filters the list by what is in the control, so a list the server has filtered already is filtered twice. That only shows when the server finds by something else than the start or a part of the value.
|
|
56
|
+
|
|
57
|
+
## API
|
|
58
|
+
|
|
59
|
+
#### Properties/Attributes
|
|
60
|
+
|
|
61
|
+
Inherits all of `input-field`'s properties (`type`, `size`, `placeholder`, `pattern`, `autocomplete`, `inputmode`, `enterkeyhint`, `autocapitalize`, `autocorrect`, `spellcheck`) and of `form-field` (`name`, `value`, `required`, `disabled`, `label`, `labelScreenReaderOnly`, `errorMessage`, `helpMessage`, `valid`, `touched`) and adds:
|
|
62
|
+
|
|
63
|
+
| Name | Type | Default | Description |
|
|
64
|
+
| --------- | ------------------------------------ | ------- | -------------------------------------------- |
|
|
65
|
+
| `options` | `Array<string \| { value, label? }>` | `[]` | The suggestions. As an attribute it is JSON. |
|
|
66
|
+
|
|
67
|
+
A list works with the types that take text: `text` (the default), `search`, `email`, `url`, `tel`. Set `autocomplete="off"` where the suggestions of the browser's own history would stand beside the ones of the page.
|
|
68
|
+
|
|
69
|
+
#### Events
|
|
70
|
+
|
|
71
|
+
| Name | Detail | Description |
|
|
72
|
+
| -------------- | -------------------- | -------------------------------------------------------------------- |
|
|
73
|
+
| `input-change` | `string` (the value) | Fired when the value changes: typed, or picked from the suggestions. |
|
|
74
|
+
|
|
75
|
+
#### CSS States
|
|
76
|
+
|
|
77
|
+
Inherited from `form-field`: `touched`, `valid`, `invalid`.
|
|
78
|
+
|
|
79
|
+
#### CSS Custom Properties
|
|
80
|
+
|
|
81
|
+
Headless by default. The texts read the tokens every field reads (`--el-color-fg`, `--el-color-fg-muted`, `--el-color-danger`, `--el-font-size-sm`, `--el-space-1`, `--el-space-2`). With `styles/native.css` the input has the border, the radius, the padding, the colours, the focus ring and the three sizes of the input of `el-input-field`.
|
|
82
|
+
|
|
83
|
+
The label, the help message, the control and the error message stack in a column, and the texts have one look in every field: see [Layout](../form-field/form-field.readme.md#layout) in the readme of `form-field`.
|
|
84
|
+
|
|
85
|
+
On a touch screen (`@media (any-pointer: coarse)`) the control is at least `--el-touch-target` high. Without that token, and on a fine pointer, the sizes stay as they are.
|
|
86
|
+
|
|
87
|
+
## Accessibility
|
|
88
|
+
|
|
89
|
+
- The control is a native text input with a list: the browser makes it a combobox for a screen reader, named by the label (`<label for>`), and announces the suggestions as it shows them.
|
|
90
|
+
- The keyboard is the one of the browser: the arrow keys go through the suggestions, Enter takes one, Escape closes the list.
|
|
91
|
+
- Without options the control is a plain text input, with no list to announce.
|
|
92
|
+
- It names the help message in `aria-describedby`, and the error message while that is shown, and says whether it is valid (`aria-invalid`).
|
|
93
|
+
- Validation messages surface only once the field is `touched`. The error message is an alert (`role="alert"`): a screen reader announces it when it appears.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import hostStyle from '../../styles/host.style.js';
|
|
2
|
+
import formControlStyle from '../../styles/form-control.style.js';
|
|
3
|
+
import sizeStyle from '../../styles/size.style.js';
|
|
4
|
+
|
|
5
|
+
const css = String.raw;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The field has the style of `el-input-field`, under its own tag: a field does not get the
|
|
9
|
+
* stylesheet of the class it extends.
|
|
10
|
+
*/
|
|
11
|
+
const style = css`
|
|
12
|
+
el-combobox-field {
|
|
13
|
+
.field {
|
|
14
|
+
.validity {
|
|
15
|
+
.valid {
|
|
16
|
+
color: var(--el-color-success, green);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.invalid {
|
|
20
|
+
color: var(--el-color-danger, red);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/* Touch screens: the control and the clear cross are at least --el-touch-target, whatever
|
|
26
|
+
the size of the field. The mark beside the input keeps that width in both states, so the
|
|
27
|
+
input does not jump when the validity changes. Without the token the sizes stay as they
|
|
28
|
+
are. */
|
|
29
|
+
@media (any-pointer: coarse) {
|
|
30
|
+
input {
|
|
31
|
+
min-height: max(
|
|
32
|
+
calc(var(--el-control-height, 0px) * var(--_el-size-scale, 1)),
|
|
33
|
+
var(--el-touch-target, 0px)
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.validity,
|
|
38
|
+
[data-clear-input] {
|
|
39
|
+
display: grid;
|
|
40
|
+
place-items: center;
|
|
41
|
+
min-width: var(--el-touch-target, auto);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
[data-clear-input] {
|
|
45
|
+
min-height: var(--el-touch-target, auto);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
`;
|
|
50
|
+
|
|
51
|
+
export default [
|
|
52
|
+
hostStyle('el-combobox-field'),
|
|
53
|
+
formControlStyle('el-combobox-field'),
|
|
54
|
+
sizeStyle('el-combobox-field'),
|
|
55
|
+
style,
|
|
56
|
+
].join('\n');
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this component live here. Versions refer to the parent `@webtides/element-library` release (see root [`CHANGELOG.md`](../../../CHANGELOG.md)); components no longer version independently.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/).
|
|
6
|
+
|
|
7
|
+
<!--
|
|
8
|
+
When your PR touches this component, add an entry under Unreleased and
|
|
9
|
+
mirror it (prefixed with the component name) in root CHANGELOG.md.
|
|
10
|
+
Uncomment headings as needed.
|
|
11
|
+
-->
|
|
12
|
+
|
|
13
|
+
## Unreleased
|
|
14
|
+
|
|
15
|
+
## [0.3.0] - 2026-11-17
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- Initial `el-copy-button`: a button that copies a text to the clipboard and says whether that worked. A native `<button>` that shows an icon and is named by `label`, "Copy" by default. ([#125](https://github.com/webtides/element-library/issues/125))
|
|
20
|
+
- The text is `value`, or with `from` the content of the element with that id: its `value` if it has one, its text without the white space around it otherwise. The element is read at the moment of the press.
|
|
21
|
+
- After a press the icon shows the outcome for `feedback-duration` milliseconds (`1500` by default), a check mark in the success colour or a cross in the danger colour, and a live region tells a screen reader (`success-label`, `error-label`). `status` is `success`, `error` or `idle`, reflected.
|
|
22
|
+
- `copy-button-copy` is fired with the text when it was copied, `copy-button-error` with the reason when it could not be: there was nothing to copy, the page has no clipboard, or the browser refused. `copy()` does the same from a script.
|
|
23
|
+
- `size` is `small`, `medium` or `large`, reflected: a square of the control height of the size, and at least `--el-touch-target` on a touch screen. `disabled` disables it.
|
|
24
|
+
- The slots `copy-icon`, `success-icon` and `error-icon` take other icons.
|