@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,237 @@
|
|
|
1
|
+
import { TemplateElement, defineElement, html } from '@webtides/element-js';
|
|
2
|
+
import style from './copy-button.style.js';
|
|
3
|
+
import Events from './copy-button.events.js';
|
|
4
|
+
|
|
5
|
+
/** What `feedbackDuration` is without a value that can be used. */
|
|
6
|
+
const FEEDBACK_DURATION = 1500;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A copy button: a button that copies a text to the clipboard and says whether that worked. The
|
|
10
|
+
* text is `value`, or the content of another element of the page named by `from`, a code block or
|
|
11
|
+
* an input. After a press the icon shows the outcome for a moment, and a screen reader hears it.
|
|
12
|
+
*
|
|
13
|
+
* @element el-copy-button
|
|
14
|
+
*
|
|
15
|
+
* @fires {CustomEvent<{ value: string }>} copy-button-copy - Fired when the text was copied.
|
|
16
|
+
* `detail.value` is the text.
|
|
17
|
+
* @fires {CustomEvent<{ error: Error }>} copy-button-error - Fired when the text could not be
|
|
18
|
+
* copied: there was nothing to copy, the browser has no clipboard for the page, or it refused.
|
|
19
|
+
* `detail.error` says which.
|
|
20
|
+
*
|
|
21
|
+
* @slot copy-icon - The icon of the button. Unset, two sheets.
|
|
22
|
+
* @slot success-icon - The icon after the text was copied. Unset, a check mark.
|
|
23
|
+
* @slot error-icon - The icon after the text could not be copied. Unset, a cross.
|
|
24
|
+
*
|
|
25
|
+
* @csspart base - The native `<button>`.
|
|
26
|
+
* @csspart icon - The icon, around the slot that is shown.
|
|
27
|
+
* @csspart feedback - The text of the outcome, a live region that is not shown.
|
|
28
|
+
*
|
|
29
|
+
* @property {string} value - The text to copy.
|
|
30
|
+
* @property {string} from - The id of an element whose content is copied in the place of `value`:
|
|
31
|
+
* its `value` if it has one, its text otherwise.
|
|
32
|
+
* @property {boolean} disabled - Disables the button.
|
|
33
|
+
* @property {'small'|'medium'|'large'} size - The size of the button. Default `'medium'`.
|
|
34
|
+
* Reflected to the `size` attribute.
|
|
35
|
+
* @property {number} feedbackDuration - How long the outcome is shown, in milliseconds. Default
|
|
36
|
+
* `1500`.
|
|
37
|
+
* @property {string} label - The accessible name of the button. Default `'Copy'`.
|
|
38
|
+
* @property {string} successLabel - What a screen reader hears after the text was copied. Default
|
|
39
|
+
* `'Copied'`.
|
|
40
|
+
* @property {string} errorLabel - What a screen reader hears after the text could not be copied.
|
|
41
|
+
* Default `'Could not copy'`.
|
|
42
|
+
* @property {'idle'|'success'|'error'} status - The outcome that is shown right now, set by the
|
|
43
|
+
* button. Reflected to the `status` attribute, so that a stylesheet can select it.
|
|
44
|
+
*/
|
|
45
|
+
export default class CopyButton extends TemplateElement {
|
|
46
|
+
constructor() {
|
|
47
|
+
super({
|
|
48
|
+
styles: [style],
|
|
49
|
+
shadowRender: true,
|
|
50
|
+
propertyOptions: {
|
|
51
|
+
// The shared size module selects the host by this attribute.
|
|
52
|
+
size: { reflect: true },
|
|
53
|
+
status: { reflect: true },
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
properties() {
|
|
59
|
+
return {
|
|
60
|
+
value: '',
|
|
61
|
+
from: '',
|
|
62
|
+
disabled: false,
|
|
63
|
+
size: 'medium',
|
|
64
|
+
feedbackDuration: FEEDBACK_DURATION,
|
|
65
|
+
label: 'Copy',
|
|
66
|
+
successLabel: 'Copied',
|
|
67
|
+
errorLabel: 'Could not copy',
|
|
68
|
+
status: 'idle',
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
disconnected() {
|
|
73
|
+
clearTimeout(this._feedbackTimer);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
events() {
|
|
77
|
+
return {
|
|
78
|
+
'[part~="base"]': {
|
|
79
|
+
click: () => this.copy(),
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Focuses the button. */
|
|
85
|
+
focus(options) {
|
|
86
|
+
this.$refs.button?.focus(options);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** Removes focus from the button. */
|
|
90
|
+
blur() {
|
|
91
|
+
this.$refs.button?.blur();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** Simulates a click on the button. */
|
|
95
|
+
click() {
|
|
96
|
+
this.$refs.button?.click();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Copies the text to the clipboard, shows the outcome and fires `copy-button-copy` or
|
|
101
|
+
* `copy-button-error`. Does nothing while the button is disabled.
|
|
102
|
+
* @returns {Promise<boolean>} Whether the text was copied.
|
|
103
|
+
*/
|
|
104
|
+
async copy() {
|
|
105
|
+
if (this.disabled) return false;
|
|
106
|
+
|
|
107
|
+
const value = this._text();
|
|
108
|
+
try {
|
|
109
|
+
if (!value) throw new Error('There is nothing to copy');
|
|
110
|
+
// Without a secure context a page has no clipboard.
|
|
111
|
+
if (!navigator.clipboard) throw new Error('The page has no access to the clipboard');
|
|
112
|
+
await navigator.clipboard.writeText(value);
|
|
113
|
+
} catch (error) {
|
|
114
|
+
this._show('error');
|
|
115
|
+
this.dispatch(Events.ERROR, { error });
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
this._show('success');
|
|
120
|
+
this.dispatch(Events.COPY, { value });
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* The text to copy: from the element that `from` names, or `value`. An element with a `value`
|
|
126
|
+
* of its own, an input or a field, gives that, any other one its text without the white space
|
|
127
|
+
* around it.
|
|
128
|
+
* @private
|
|
129
|
+
* @returns {string}
|
|
130
|
+
*/
|
|
131
|
+
_text() {
|
|
132
|
+
if (!this.from) return String(this.value ?? '');
|
|
133
|
+
|
|
134
|
+
const source = this.getRootNode().getElementById?.(this.from);
|
|
135
|
+
if (!source) return '';
|
|
136
|
+
if (typeof source.value === 'string' && source.value !== '') return source.value;
|
|
137
|
+
return source.textContent.trim();
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Shows an outcome, and takes it back after `feedbackDuration`. An outcome that is shown
|
|
142
|
+
* already starts its time again.
|
|
143
|
+
* @private
|
|
144
|
+
* @param {'success'|'error'} status
|
|
145
|
+
*/
|
|
146
|
+
_show(status) {
|
|
147
|
+
const duration = Number(this.feedbackDuration);
|
|
148
|
+
this.status = status;
|
|
149
|
+
clearTimeout(this._feedbackTimer);
|
|
150
|
+
this._feedbackTimer = setTimeout(
|
|
151
|
+
() => {
|
|
152
|
+
this.status = 'idle';
|
|
153
|
+
},
|
|
154
|
+
Number.isFinite(duration) && duration >= 0 ? duration : FEEDBACK_DURATION,
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/** @private */
|
|
159
|
+
iconTemplate() {
|
|
160
|
+
if (this.status === 'success') {
|
|
161
|
+
return html`
|
|
162
|
+
<slot name="success-icon">
|
|
163
|
+
<svg
|
|
164
|
+
viewBox="0 0 24 24"
|
|
165
|
+
fill="none"
|
|
166
|
+
stroke="currentColor"
|
|
167
|
+
stroke-width="2"
|
|
168
|
+
stroke-linecap="round"
|
|
169
|
+
stroke-linejoin="round"
|
|
170
|
+
>
|
|
171
|
+
<polyline points="20 6 9 17 4 12"></polyline>
|
|
172
|
+
</svg>
|
|
173
|
+
</slot>
|
|
174
|
+
`;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (this.status === 'error') {
|
|
178
|
+
return html`
|
|
179
|
+
<slot name="error-icon">
|
|
180
|
+
<svg
|
|
181
|
+
viewBox="0 0 24 24"
|
|
182
|
+
fill="none"
|
|
183
|
+
stroke="currentColor"
|
|
184
|
+
stroke-width="2"
|
|
185
|
+
stroke-linecap="round"
|
|
186
|
+
stroke-linejoin="round"
|
|
187
|
+
>
|
|
188
|
+
<line x1="18" y1="6" x2="6" y2="18"></line>
|
|
189
|
+
<line x1="6" y1="6" x2="18" y2="18"></line>
|
|
190
|
+
</svg>
|
|
191
|
+
</slot>
|
|
192
|
+
`;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
return html`
|
|
196
|
+
<slot name="copy-icon">
|
|
197
|
+
<svg
|
|
198
|
+
viewBox="0 0 24 24"
|
|
199
|
+
fill="none"
|
|
200
|
+
stroke="currentColor"
|
|
201
|
+
stroke-width="2"
|
|
202
|
+
stroke-linecap="round"
|
|
203
|
+
stroke-linejoin="round"
|
|
204
|
+
>
|
|
205
|
+
<rect x="9" y="9" width="12" height="12" rx="2"></rect>
|
|
206
|
+
<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path>
|
|
207
|
+
</svg>
|
|
208
|
+
</slot>
|
|
209
|
+
`;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
template() {
|
|
213
|
+
// The live region is there from the start and empty: a screen reader announces what is
|
|
214
|
+
// written into a region it knows, not a region that appears with its text.
|
|
215
|
+
const feedback = this.status === 'success' ? this.successLabel : this.status === 'error' ? this.errorLabel : '';
|
|
216
|
+
|
|
217
|
+
return html`
|
|
218
|
+
<button
|
|
219
|
+
ref="button"
|
|
220
|
+
part="base"
|
|
221
|
+
class="copy-button"
|
|
222
|
+
type="button"
|
|
223
|
+
?disabled="${this.disabled}"
|
|
224
|
+
aria-label="${this.label}"
|
|
225
|
+
>
|
|
226
|
+
<span part="icon" class="icon" aria-hidden="true">${this.iconTemplate()}</span>
|
|
227
|
+
</button>
|
|
228
|
+
<span part="feedback" class="feedback" role="status">${feedback}</span>
|
|
229
|
+
`;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export function define() {
|
|
234
|
+
defineElement('el-copy-button', CopyButton);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export { Events };
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# Copy Button
|
|
2
|
+
|
|
3
|
+
`copy-button` copies a text to the clipboard with one press and says whether that worked: an install command, an API key, a link to share. The text is `value`, or the content of another element of the page named by `from`.
|
|
4
|
+
|
|
5
|
+
After a press the icon of the button shows the outcome for a moment, a check mark or a cross, and a screen reader hears it.
|
|
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/copy-button/define';
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
```html
|
|
22
|
+
<el-copy-button value="npm i --save @webtides/element-library"></el-copy-button>
|
|
23
|
+
|
|
24
|
+
<!-- The text of another element: a code block -->
|
|
25
|
+
<pre id="snippet">npm i --save @webtides/element-library</pre>
|
|
26
|
+
<el-copy-button from="snippet" label="Copy the command"></el-copy-button>
|
|
27
|
+
|
|
28
|
+
<!-- The value of a control -->
|
|
29
|
+
<input id="token" value="4f9a-22c1" readonly />
|
|
30
|
+
<el-copy-button from="token" label="Copy the token"></el-copy-button>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
> Boolean attributes are passed as strings (`disabled="true"`), matching the rest of the library.
|
|
34
|
+
|
|
35
|
+
## API
|
|
36
|
+
|
|
37
|
+
#### Properties/Attributes
|
|
38
|
+
|
|
39
|
+
| Name | Type | Default | Description |
|
|
40
|
+
| --- | --- | --- | --- |
|
|
41
|
+
| `value` | `string` | `''` | The text to copy. |
|
|
42
|
+
| `from` | `string` | `''` | The id of an element whose content is copied in the place of `value`. |
|
|
43
|
+
| `disabled` | `boolean` | `false` | Disables the button. |
|
|
44
|
+
| `size` | `string` | `'medium'` | `small`, `medium` or `large`. Reflected. |
|
|
45
|
+
| `feedback-duration` | `number` | `1500` | How long the outcome is shown, in milliseconds. |
|
|
46
|
+
| `label` | `string` | `'Copy'` | The accessible name of the button. |
|
|
47
|
+
| `success-label` | `string` | `'Copied'` | What a screen reader hears after the text was copied. |
|
|
48
|
+
| `error-label` | `string` | `'Could not copy'` | What a screen reader hears after the text could not be copied. |
|
|
49
|
+
| `status` | `string` | `'idle'` | The outcome that is shown right now: `idle`, `success` or `error`. Set by the button, reflected. |
|
|
50
|
+
|
|
51
|
+
#### Methods
|
|
52
|
+
|
|
53
|
+
| Name | Description |
|
|
54
|
+
| --------- | ------------------------------------------------------------------------------------- |
|
|
55
|
+
| `copy()` | Copies the text and shows the outcome. Resolves with `true` when the text was copied. |
|
|
56
|
+
| `focus()` | Focuses the button. |
|
|
57
|
+
| `blur()` | Removes the focus from the button. |
|
|
58
|
+
| `click()` | Simulates a click on the button. |
|
|
59
|
+
|
|
60
|
+
#### Events
|
|
61
|
+
|
|
62
|
+
| Name | Detail | Description |
|
|
63
|
+
| ------------------- | ------------------- | ------------------------------------------------------ |
|
|
64
|
+
| `copy-button-copy` | `{ value: string }` | The text was copied. `detail.value` is the text. |
|
|
65
|
+
| `copy-button-error` | `{ error: Error }` | The text could not be copied. `detail.error` says why. |
|
|
66
|
+
|
|
67
|
+
#### Slots
|
|
68
|
+
|
|
69
|
+
| Name | Description |
|
|
70
|
+
| -------------- | ------------------------------------------------------------ |
|
|
71
|
+
| `copy-icon` | The icon of the button. Unset, two sheets. |
|
|
72
|
+
| `success-icon` | The icon after the text was copied. Unset, a check mark. |
|
|
73
|
+
| `error-icon` | The icon after the text could not be copied. Unset, a cross. |
|
|
74
|
+
|
|
75
|
+
#### CSS Parts
|
|
76
|
+
|
|
77
|
+
| Name | Description |
|
|
78
|
+
| ---------- | --------------------------------------------------------- |
|
|
79
|
+
| `base` | The native `<button>`. |
|
|
80
|
+
| `icon` | The icon, around the slot that is shown. |
|
|
81
|
+
| `feedback` | The text of the outcome, a live region that is not shown. |
|
|
82
|
+
|
|
83
|
+
#### CSS Custom Properties
|
|
84
|
+
|
|
85
|
+
_None._ The button reads the tokens of the theme: `--el-color-fg`, `--el-color-success`, `--el-color-danger`, `--el-control-height`, `--el-radius-md`.
|
|
86
|
+
|
|
87
|
+
## What is copied
|
|
88
|
+
|
|
89
|
+
Without `from` the button copies `value`.
|
|
90
|
+
|
|
91
|
+
With `from` it copies from the element with that id, which it looks up in the document, or in the shadow root the button is in. An element that has a `value` of its own, an `<input>`, a `<textarea>` or a field of this library, gives that value as it is. Any other element gives its text, without the white space around it, so a `<pre>` can be written on lines of its own. The element is read at the moment of the press: what the user has typed into an input by then is what is copied.
|
|
92
|
+
|
|
93
|
+
`from` comes before `value` when both are set.
|
|
94
|
+
|
|
95
|
+
## The outcome
|
|
96
|
+
|
|
97
|
+
A press ends in one of two ways.
|
|
98
|
+
|
|
99
|
+
- **The text was copied.** The icon is a check mark in the success colour of the theme, a screen reader hears `success-label`, and `copy-button-copy` is fired with the text in `event.detail.value`.
|
|
100
|
+
- **The text could not be copied.** The icon is a cross in the danger colour, a screen reader hears `error-label`, and `copy-button-error` is fired with the reason in `event.detail.error`. There are three reasons: there was nothing to copy (no text, or no element with the id in `from`), the page has no clipboard (a browser gives one to pages served over `https` and to `localhost` only), or the browser refused.
|
|
101
|
+
|
|
102
|
+
After `feedback-duration` milliseconds the button is as before. A second press within that time copies again and starts the time again.
|
|
103
|
+
|
|
104
|
+
`status` is `success` or `error` for as long as the outcome is shown, and `idle` otherwise. It is reflected, so a stylesheet can follow it: `el-copy-button[status='success']`. The button sets it; setting it from outside shows an outcome that did not happen.
|
|
105
|
+
|
|
106
|
+
Both events bubble and cross shadow roots. `copy()` does from a script what a press does, and resolves with whether the text was copied.
|
|
107
|
+
|
|
108
|
+
## Look
|
|
109
|
+
|
|
110
|
+
The button is a square of the control height of its `size`, the height of an `el-button` of that size, so the two line up in a row. It has no surface of its own: the icon has the text colour, and the button shows a tint of it under the pointer and while it is pressed.
|
|
111
|
+
|
|
112
|
+
It shows an icon only. Its name for a screen reader is `label`; to show a sighted user what the button does before it is pressed, give it an `el-tooltip`:
|
|
113
|
+
|
|
114
|
+
```html
|
|
115
|
+
<el-copy-button id="copy-token" from="token"></el-copy-button> <el-tooltip for="copy-token">Copy the token</el-tooltip>
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
The slots `copy-icon`, `success-icon` and `error-icon` take other icons. An `<svg>` slotted there gets the size of the default ones, one and a quarter of the font size of the button.
|
|
119
|
+
|
|
120
|
+
On a touch screen (`any-pointer: coarse`) the button is at least `--el-touch-target` wide and high, in every size.
|
|
121
|
+
|
|
122
|
+
The `hidden` attribute hides the button.
|
|
123
|
+
|
|
124
|
+
## Accessibility
|
|
125
|
+
|
|
126
|
+
- The button is a native `<button>`: it is a tab stop, and `Enter` and `Space` press it.
|
|
127
|
+
- Its name is the `label`, "Copy" by default. Where a page has more than one copy button, say what each one copies: "Copy the command", "Copy the token".
|
|
128
|
+
- The name does not change with the outcome, since what the button does has not changed. The outcome is written into a live region (`role="status"`), which a screen reader announces without moving its user: "Copied", or "Could not copy". Set `success-label` and `error-label` in the language of the page.
|
|
129
|
+
- The outcome does not rest on colour: the icon changes its shape.
|
|
130
|
+
- The focus stays on the button through a press and the outcome.
|
|
131
|
+
|
|
132
|
+
## Server-side rendering
|
|
133
|
+
|
|
134
|
+
The button, its name, its icon and the empty live region are part of the server-rendered markup (Declarative Shadow DOM). Copying needs the JavaScript of the element: until it has loaded, a press does nothing.
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import hostStyle from '../../styles/host.style.js';
|
|
2
|
+
import sizeStyle from '../../styles/size.style.js';
|
|
3
|
+
|
|
4
|
+
const css = String.raw;
|
|
5
|
+
|
|
6
|
+
const style = css`
|
|
7
|
+
:host {
|
|
8
|
+
display: inline-block;
|
|
9
|
+
/* The place the text of the outcome is taken out of the flow from. */
|
|
10
|
+
position: relative;
|
|
11
|
+
vertical-align: middle;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/* ── Button ───────────────────────────────────────────────────────────── */
|
|
15
|
+
|
|
16
|
+
/* A square of the control height of the size, without a surface of its own: a quiet tool next
|
|
17
|
+
to the text it copies. */
|
|
18
|
+
.copy-button {
|
|
19
|
+
display: inline-flex;
|
|
20
|
+
align-items: center;
|
|
21
|
+
justify-content: center;
|
|
22
|
+
width: var(--_el-size-height);
|
|
23
|
+
height: var(--_el-size-height);
|
|
24
|
+
padding: 0;
|
|
25
|
+
border: none;
|
|
26
|
+
border-radius: var(--el-radius-md, 4px);
|
|
27
|
+
background: transparent;
|
|
28
|
+
color: var(--el-color-fg, inherit);
|
|
29
|
+
font-family: var(--el-font-family, inherit);
|
|
30
|
+
font-size: var(--_el-size-font-size);
|
|
31
|
+
line-height: 1;
|
|
32
|
+
cursor: pointer;
|
|
33
|
+
user-select: none;
|
|
34
|
+
transition: background var(--el-duration-md, 0s) var(--el-ease, linear);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.icon {
|
|
38
|
+
display: inline-flex;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/* The icons that are there without an icon of the page, and an svg the page slots in. */
|
|
42
|
+
.icon svg,
|
|
43
|
+
::slotted(svg) {
|
|
44
|
+
width: 1.25em;
|
|
45
|
+
height: 1.25em;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/* ── Outcome ──────────────────────────────────────────────────────────── */
|
|
49
|
+
|
|
50
|
+
:host([status='success']) .icon {
|
|
51
|
+
color: var(--el-color-success, inherit);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
:host([status='error']) .icon {
|
|
55
|
+
color: var(--el-color-danger, inherit);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/* The text of the outcome is for a screen reader. The icon says the same to the eye. */
|
|
59
|
+
.feedback {
|
|
60
|
+
position: absolute;
|
|
61
|
+
width: 1px;
|
|
62
|
+
height: 1px;
|
|
63
|
+
margin: -1px;
|
|
64
|
+
padding: 0;
|
|
65
|
+
border: 0;
|
|
66
|
+
overflow: hidden;
|
|
67
|
+
clip: rect(0 0 0 0);
|
|
68
|
+
clip-path: inset(50%);
|
|
69
|
+
white-space: nowrap;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/* ── States ───────────────────────────────────────────────────────────── */
|
|
73
|
+
|
|
74
|
+
/* A tint of the text colour, which shows on every background. Hover only where the pointer
|
|
75
|
+
can hover: a touch screen leaves :hover on the button that was tapped last. */
|
|
76
|
+
@media (hover: hover) {
|
|
77
|
+
.copy-button:hover {
|
|
78
|
+
background: color-mix(in srgb, currentColor 12%, transparent);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.copy-button:active {
|
|
83
|
+
background: color-mix(in srgb, currentColor 24%, transparent);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.copy-button:focus-visible {
|
|
87
|
+
outline: var(--el-focus-ring-width, 2px) solid var(--el-color-focus-ring, currentColor);
|
|
88
|
+
outline-offset: var(--el-focus-ring-offset, 2px);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.copy-button[disabled] {
|
|
92
|
+
background: transparent;
|
|
93
|
+
opacity: 0.55;
|
|
94
|
+
cursor: not-allowed;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/* ── Touch screens ────────────────────────────────────────────────────── */
|
|
98
|
+
|
|
99
|
+
/* On a coarse pointer the button does not fall below --el-touch-target in either direction.
|
|
100
|
+
Without the token the sizes stay as they are. */
|
|
101
|
+
@media (any-pointer: coarse) {
|
|
102
|
+
.copy-button {
|
|
103
|
+
min-width: var(--el-touch-target, auto);
|
|
104
|
+
min-height: var(--el-touch-target, auto);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
`;
|
|
108
|
+
|
|
109
|
+
export default [hostStyle(), sizeStyle(), style].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-date-field`: a date, a time or both, entered in the control of the browser and picked in its picker. An `el-input-field` with the `type` `date` (the default), `time`, `datetime-local`, `month` or `week`, so it has the label, the messages, `required`, the sizes and the place in a form of an input field. ([#146](https://github.com/webtides/element-library/issues/146))
|
|
20
|
+
- `min`, `max` and `step` reach the control: the earliest and the latest value, and the distance between two values. A value outside of them is not valid, and the field shows its error message once it is touched, or when the browser refuses to submit the form.
|
|
21
|
+
- `value` is text in the format of the control (`2026-11-15`, `14:30`, `2026-11-15T14:30`, `2026-11`, `2026-W46`). A value in another format is empty for the control, and the field takes that over: `value` says what the form submits.
|
|
22
|
+
- `value` follows what the user enters by keyboard and picks in the picker, and `input-change` reports each value once.
|
|
23
|
+
- The field writes to its control only what has changed. The control of a date drops a date that is half entered when its value, its limits or its step are written again, with the same text as well.
|
|
24
|
+
- With `styles/native.css` the control has the look and the three sizes of the input of `el-input-field`. The picker is drawn by the browser.
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { defineElement } from '@webtides/element-js';
|
|
2
|
+
import InputField from '../input-field/input-field.js';
|
|
3
|
+
import style from './date-field.style.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A date, a time or both, entered in the control of the browser and picked in its picker. Extends
|
|
7
|
+
* `InputField` (and therefore `FormField`), inheriting the label / help / error / validation
|
|
8
|
+
* surface and the look from `styles/native.css`.
|
|
9
|
+
*
|
|
10
|
+
* It adds what a date needs and a text does not: the earliest and the latest value, and the step
|
|
11
|
+
* between two values. The value is text in the one format of the control, whatever the language of
|
|
12
|
+
* the user, and the field takes over what the control makes of a value: `value` says what the form
|
|
13
|
+
* submits.
|
|
14
|
+
*
|
|
15
|
+
* @element el-date-field
|
|
16
|
+
*
|
|
17
|
+
* @fires {CustomEvent<string>} input-change - Fired when the value changes: entered, picked, or set
|
|
18
|
+
* by a script. `detail` is the new value. Bubbles.
|
|
19
|
+
*
|
|
20
|
+
* @property {'date'|'time'|'datetime-local'|'month'|'week'} type - What the field takes. Default
|
|
21
|
+
* `'date'`.
|
|
22
|
+
* @property {string | null} value - The value, in the format of the control: `2026-11-15` for a
|
|
23
|
+
* date, `14:30` for a time, `2026-11-15T14:30` for both, `2026-11` for a month, `2026-W46` for a
|
|
24
|
+
* week. A value in another format is empty for the control, and the field takes that over.
|
|
25
|
+
* @property {string | null} min - The earliest value, in the format of the control. `null` (the
|
|
26
|
+
* default) is no limit.
|
|
27
|
+
* @property {string | null} max - The latest value, in the format of the control. `null` (the
|
|
28
|
+
* default) is no limit.
|
|
29
|
+
* @property {number | 'any' | null} step - The distance between two values: days for a date, weeks
|
|
30
|
+
* for a week, months for a month, seconds for a time. `null` (the default) is the step of the
|
|
31
|
+
* browser: a day, a week, a month, a minute.
|
|
32
|
+
*/
|
|
33
|
+
export default class DateField extends InputField {
|
|
34
|
+
constructor(options) {
|
|
35
|
+
super({ shadowRender: false, styles: [style], ...options });
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
properties() {
|
|
39
|
+
return {
|
|
40
|
+
...super.properties(),
|
|
41
|
+
type: 'date',
|
|
42
|
+
min: null,
|
|
43
|
+
max: null,
|
|
44
|
+
step: null,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
afterUpdate() {
|
|
49
|
+
// Before the form field keeps the state for a reset: what the field takes over from the
|
|
50
|
+
// control is part of it.
|
|
51
|
+
this._matchControl();
|
|
52
|
+
super.afterUpdate();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
watch() {
|
|
56
|
+
const watchers = super.watch();
|
|
57
|
+
return {
|
|
58
|
+
...watchers,
|
|
59
|
+
value: (value, oldValue) => {
|
|
60
|
+
this._matchControl();
|
|
61
|
+
// The watcher runs a frame after the change, with the value of then. A value the
|
|
62
|
+
// control did not take is not reported: the field has taken another one over by
|
|
63
|
+
// now, and the watcher runs again for that one.
|
|
64
|
+
if (String(value ?? '') !== String(this.value ?? '')) return;
|
|
65
|
+
watchers.value(value, oldValue);
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
events() {
|
|
71
|
+
const events = super.events();
|
|
72
|
+
return {
|
|
73
|
+
...events,
|
|
74
|
+
'[ref=input]': {
|
|
75
|
+
...events['[ref=input]'],
|
|
76
|
+
// A pick in the picker presses no key that the field would hear.
|
|
77
|
+
input: () => this.onChange(),
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Makes the control and `value` say the same, after every render and every change of `value`.
|
|
84
|
+
*
|
|
85
|
+
* The `value` attribute of the control is only its default: once the user has entered a date,
|
|
86
|
+
* a value from outside has to be written to the control. The control in turn takes a value in
|
|
87
|
+
* its own format only and is empty for every other, `15.11.2026` for example, or a date for a
|
|
88
|
+
* field that has become one for a time. The field takes over what the control made of the
|
|
89
|
+
* value: that is what the form submits.
|
|
90
|
+
*
|
|
91
|
+
* The field hears every change the user makes (`input`), so the control never has a value of
|
|
92
|
+
* the user that this would write over. While the two say the same nothing is written: the
|
|
93
|
+
* control would drop a date that is half entered.
|
|
94
|
+
* @private
|
|
95
|
+
*/
|
|
96
|
+
_matchControl() {
|
|
97
|
+
const control = this.$refs.input;
|
|
98
|
+
if (!control) return;
|
|
99
|
+
|
|
100
|
+
const wanted = String(this.value ?? '');
|
|
101
|
+
if (control.value !== wanted) control.value = wanted;
|
|
102
|
+
// What the control has is what the two agree on, so the input field does not write it again.
|
|
103
|
+
this._controlValue = control.value;
|
|
104
|
+
if (control.value !== wanted) this.value = control.value;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* The limits and the step, for the control. An empty one is none: a page that renders
|
|
109
|
+
* `min=""` for "no limit" means the same as one that leaves the attribute out.
|
|
110
|
+
* @private
|
|
111
|
+
*/
|
|
112
|
+
_controlAttributes() {
|
|
113
|
+
return { min: this.min || null, max: this.max || null, step: this.step || null };
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export function define() {
|
|
118
|
+
defineElement('el-date-field', DateField);
|
|
119
|
+
}
|