@webtides/element-library 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +384 -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 +16604 -3420
- 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 +34 -1
- package/src/components/button/button.js +285 -29
- package/src/components/button/button.readme.md +130 -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 +19 -0
- package/src/components/checkbox-field/checkbox-field.js +25 -10
- 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 +16 -0
- package/src/components/switch-field/switch-field.js +17 -9
- 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 +129 -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,110 @@
|
|
|
1
|
+
# DateField
|
|
2
|
+
|
|
3
|
+
`date-field` takes a date, a time or both: a birthday, the day of a delivery, the start of a booking. It extends `input-field`, inheriting the label, help text, error message, `required`, the sizes and the touched-state handling.
|
|
4
|
+
|
|
5
|
+
It renders the control of the browser for the `type` (`<input type="date">` and its relatives), so the picker fits the platform, the user sees the date in the order of their language, and the keyboard and a screen reader work as the browser has them. The field has no calendar of its own.
|
|
6
|
+
|
|
7
|
+
It adds what a date needs and a text does not: the earliest and the latest value (`min`, `max`) and the step between two values (`step`).
|
|
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 picker 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/date-field/define';
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
```html
|
|
26
|
+
<el-date-field name="birthday" label="Birthday" max="2026-11-15"></el-date-field>
|
|
27
|
+
|
|
28
|
+
<el-date-field name="pickup" label="Pick-up" type="time" min="09:00" max="17:00" step="900"></el-date-field>
|
|
29
|
+
|
|
30
|
+
<el-date-field name="start" label="Start" type="datetime-local" value="2026-11-15T14:30"></el-date-field>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
#### The value
|
|
34
|
+
|
|
35
|
+
The value is text in the one format of the control, whatever the language of the user and whatever the control shows:
|
|
36
|
+
|
|
37
|
+
| `type` | Format | Example |
|
|
38
|
+
| ---------------- | ------------------ | ------------------ |
|
|
39
|
+
| `date` | `YYYY-MM-DD` | `2026-11-15` |
|
|
40
|
+
| `time` | `hh:mm`, 24 hours | `14:30` |
|
|
41
|
+
| `datetime-local` | `YYYY-MM-DDThh:mm` | `2026-11-15T14:30` |
|
|
42
|
+
| `month` | `YYYY-MM` | `2026-11` |
|
|
43
|
+
| `week` | `YYYY-Www` | `2026-W46` |
|
|
44
|
+
|
|
45
|
+
`min` and `max` are in the same format. A time has its seconds (`14:30:15`) when the `step` asks for them.
|
|
46
|
+
|
|
47
|
+
The control takes a value in its format only. For every other it is empty: `15.11.2026`, a day that does not exist (`2026-02-30`), a date in a field for a time. The field takes that over: `value` is empty then, as is what the form submits, and `input-change` reports it.
|
|
48
|
+
|
|
49
|
+
While the user is still entering a date, the control has no value yet, and neither has the field.
|
|
50
|
+
|
|
51
|
+
#### The limits
|
|
52
|
+
|
|
53
|
+
A value before `min`, after `max` or beside a `step` is not valid. The field says so like every field: with its error message once it is touched, or when the browser refuses to submit the form. The picker of a browser usually does not offer such a value; the keyboard can still enter it.
|
|
54
|
+
|
|
55
|
+
```html
|
|
56
|
+
<el-date-field
|
|
57
|
+
name="delivery"
|
|
58
|
+
label="Delivery"
|
|
59
|
+
min="2026-11-16"
|
|
60
|
+
max="2026-12-23"
|
|
61
|
+
required="true"
|
|
62
|
+
error-message="Pick a day between 16 November and 23 December."
|
|
63
|
+
></el-date-field>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
The step is in days for a date, in weeks for a week, in months for a month and in seconds for a time: `step="900"` is every quarter of an hour.
|
|
67
|
+
|
|
68
|
+
A month and a week have no control of their own in every browser. Where one is missing, the browser renders a text input, and the user has to write the format above: say it in the help message, or ask for a date.
|
|
69
|
+
|
|
70
|
+
## API
|
|
71
|
+
|
|
72
|
+
#### Properties/Attributes
|
|
73
|
+
|
|
74
|
+
Inherits all of `input-field`'s properties and of `form-field` (`name`, `value`, `required`, `disabled`, `label`, `labelScreenReaderOnly`, `errorMessage`, `helpMessage`, `valid`, `touched`) and adds:
|
|
75
|
+
|
|
76
|
+
| Name | Type | Default | Description |
|
|
77
|
+
| --- | --- | --- | --- |
|
|
78
|
+
| `type` | `'date' \| 'time' \| 'datetime-local' \| 'month' \| 'week'` | `'date'` | What the field takes. |
|
|
79
|
+
| `value` | `string` | `null` | The value, in the format of the control. |
|
|
80
|
+
| `min` | `string` | `null` | The earliest value, in the format of the control. `null` is no limit. |
|
|
81
|
+
| `max` | `string` | `null` | The latest value, in the format of the control. `null` is no limit. |
|
|
82
|
+
| `step` | `number \| 'any'` | `null` | The distance between two values. `null` is the step of the browser. |
|
|
83
|
+
|
|
84
|
+
`size` works as on `el-input-field`. `placeholder` and `pattern` have no effect on these controls: the browser shows the parts of a date in their place, and a date has no pattern to match.
|
|
85
|
+
|
|
86
|
+
#### Events
|
|
87
|
+
|
|
88
|
+
| Name | Detail | Description |
|
|
89
|
+
| --- | --- | --- |
|
|
90
|
+
| `input-change` | `string` (the value) | Fired when the value changes: entered, picked in the picker, set by a script. |
|
|
91
|
+
|
|
92
|
+
#### CSS States
|
|
93
|
+
|
|
94
|
+
Inherited from `form-field`: `touched`, `valid`, `invalid`.
|
|
95
|
+
|
|
96
|
+
#### CSS Custom Properties
|
|
97
|
+
|
|
98
|
+
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 has the border, the radius, the padding, the colours, the focus ring and the three sizes of the input of `el-input-field`.
|
|
99
|
+
|
|
100
|
+
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`.
|
|
101
|
+
|
|
102
|
+
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.
|
|
103
|
+
|
|
104
|
+
## Accessibility
|
|
105
|
+
|
|
106
|
+
- The control is the native one for a date or a time, named by the label (`<label for>`). Its parts (day, month, year) are entered with the keyboard and changed with the arrow keys, and the picker of the browser brings its own keyboard handling.
|
|
107
|
+
- The user sees and hears the date in the order of their language. The format of `value` is for the page, not for the user: do not put it into the label.
|
|
108
|
+
- It names the help message in `aria-describedby`, and the error message while that is shown, and says whether it is valid (`aria-invalid`).
|
|
109
|
+
- Say the limits in the help message or the error message: "between 16 November and 23 December". The browser has a text of its own for them only in its bubble, when it refuses a submit.
|
|
110
|
+
- 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,53 @@
|
|
|
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-date-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 [hostStyle('el-date-field'), formControlStyle('el-date-field'), sizeStyle('el-date-field'), style].join(
|
|
52
|
+
'\n',
|
|
53
|
+
);
|
|
@@ -12,6 +12,21 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).
|
|
|
12
12
|
|
|
13
13
|
## Unreleased
|
|
14
14
|
|
|
15
|
+
## [0.3.0] - 2026-11-17
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- On a touch screen (`@media (any-pointer: coarse)`) the close button is at least `--el-touch-target` wide and high (20 × 20 px before). Its icon keeps its size, and the header grows with the button. Unchanged on a fine pointer and without the token.
|
|
20
|
+
- `dialog-after-show` and `dialog-after-hide` fire only when the dialog has got there. A way that is cut short has none, so after `dialog-show` comes `dialog-after-show` or `dialog-hide`, and after `dialog-hide` comes `dialog-after-hide` or `dialog-show`; before, `dialog-after-show` could fire after the dialog had closed again. The promises of `show()` and `hide()` resolve when the dialog is at rest, at whichever end, and never reject; a `show()` while the dialog is still coming in waits for that way, where it resolved at once. Two changes of `open` before the next frame that cancel each other do nothing and fire nothing. Nothing changes for a dialog that opens and closes undisturbed. ([#110](https://github.com/webtides/element-library/issues/110))
|
|
21
|
+
|
|
22
|
+
### Fixed
|
|
23
|
+
|
|
24
|
+
- A dialog that is taken out of the page while it is open gives the page its scrolling back. Before, the page stayed locked (`overflow: hidden` on the document) with no dialog left to close, and a dialog opened later did not unlock it either, because the lock counts its holders. Put back into the page while `open`, the dialog opens as a modal again; before, it was shown in the flow of the page, without a backdrop and without taking the focus.
|
|
25
|
+
- An empty footer takes no room. The footer was meant to be left out without content, but the rule for it never matched, so a dialog without a footer had the padding of the footer (`--el-space-4`, 16 px with the shipped themes) as extra room under its body. A footer that gets content later appears with it, and the footer of a server-rendered dialog is shown.
|
|
26
|
+
- Opening and closing in quick succession no longer leaves the dialog out of step with `open`. A dialog that was closed and opened again while its way out was still running stayed closed with `open` still `true`: nothing was shown, the promise of `show()` never resolved, and the next `show()` did nothing. A button that toggles the dialog and is clicked twice got there. A dialog that was opened and closed again at once kept the class of its shown state, and came in without its transition the next time. Now the last value of `open` wins: a dialog that is closed on its way in turns back, one that is opened on its way out turns round and is shown again. ([#110](https://github.com/webtides/element-library/issues/110))
|
|
27
|
+
- A `<form method="dialog">` inside the dialog closes it, as the readme has said since 0.1.0. It never did: the form is a child of the element and the `<dialog>` is in the shadow root, so the platform found no dialog above the form to close. The dialog now closes for the `submit` of such a form itself: by its submit button, by `Enter` in one of its fields, by a button that belongs to it through the `form` attribute, and by a button with `formmethod="dialog"` in a form with another method. It closes without `dialog-request-close`; a listener that calls `preventDefault()` on the `submit` keeps it open, and so does a form that is not valid. There is no `returnValue`: the button that was used is `event.submitter` in the listener. ([#111](https://github.com/webtides/element-library/issues/111))
|
|
28
|
+
- `show()` and `hide()` wait for the dialog also when `open` got its value just before the call, in the same frame: set by hand, or by `requestClose()`. Such a call resolved at once, while the dialog was still shown (or still closed), because the dialog begins to move with the next frame. ([#112](https://github.com/webtides/element-library/issues/112))
|
|
29
|
+
|
|
15
30
|
## [0.1.2] - 2026-06-04
|
|
16
31
|
|
|
17
32
|
### Fixed
|
|
@@ -22,7 +37,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).
|
|
|
22
37
|
|
|
23
38
|
### Added
|
|
24
39
|
|
|
25
|
-
- Initial release of `el-dialog` — a modal dialog built on the native `<dialog>` element. The platform provides focus trapping, background `inert`, top-layer rendering, focus restoration and `<form method="dialog">` auto-close; the component adds an animated, cancelable open/close lifecycle and ref-counted body-scroll locking that compensates for the removed scrollbar width (no layout shift on open).
|
|
40
|
+
- Initial release of `el-dialog` — a modal dialog built on the native `<dialog>` element. The platform provides focus trapping, background `inert`, top-layer rendering, focus restoration and `<form method="dialog">` auto-close; the component adds an animated, cancelable open/close lifecycle and ref-counted body-scroll locking that compensates for the removed scrollbar width (no layout shift on open).
|
|
26
41
|
- Properties `open` (reflected), `label`, `no-header` (reflected) and `close-label`.
|
|
27
42
|
- Methods `show()` / `hide()` (both resolve after their transition) and `requestClose(source)`.
|
|
28
43
|
- Events `dialog-show`, `dialog-after-show`, `dialog-hide`, `dialog-after-hide`, the cancelable `dialog-initial-focus`, and the cancelable `dialog-request-close` (with `detail.source` of `'close-button' | 'keyboard' | 'overlay'`).
|
|
@@ -4,11 +4,23 @@ import Events from './dialog.events.js';
|
|
|
4
4
|
import { lockBodyScroll, unlockBodyScroll } from '../../utils/body-scroll.js';
|
|
5
5
|
import { afterTransition, nextFrame } from '../../utils/transitions.js';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* A promise together with the function that resolves it.
|
|
9
|
+
* @returns {{ promise: Promise<void>, resolve: () => void }}
|
|
10
|
+
*/
|
|
11
|
+
function pending() {
|
|
12
|
+
let resolve;
|
|
13
|
+
const promise = new Promise((done) => {
|
|
14
|
+
resolve = done;
|
|
15
|
+
});
|
|
16
|
+
return { promise, resolve };
|
|
17
|
+
}
|
|
18
|
+
|
|
7
19
|
/**
|
|
8
20
|
* A modal dialog built on the native `<dialog>` element, so the platform owns focus trapping,
|
|
9
|
-
* background `inert`, top-layer rendering
|
|
10
|
-
*
|
|
11
|
-
*
|
|
21
|
+
* background `inert`, top-layer rendering and focus restoration. The component adds an animated,
|
|
22
|
+
* cancelable open/close lifecycle and ref-counted body-scroll locking on top, and closes for a
|
|
23
|
+
* `<form method="dialog">` in one of its slots.
|
|
12
24
|
*
|
|
13
25
|
* @element el-dialog
|
|
14
26
|
*
|
|
@@ -47,12 +59,54 @@ import { afterTransition, nextFrame } from '../../utils/transitions.js';
|
|
|
47
59
|
* @property {string} closeLabel - Accessible label for the built-in close button. Default `'Close'`.
|
|
48
60
|
*/
|
|
49
61
|
export default class Dialog extends TemplateElement {
|
|
50
|
-
|
|
62
|
+
/**
|
|
63
|
+
* @param {object} [options] - For a component that extends the dialog: its own `styles`, and
|
|
64
|
+
* `propertyOptions` for the properties it adds.
|
|
65
|
+
*/
|
|
66
|
+
constructor(options = {}) {
|
|
51
67
|
super({
|
|
52
68
|
shadowRender: true,
|
|
53
69
|
styles: [style],
|
|
54
|
-
|
|
70
|
+
...options,
|
|
71
|
+
propertyOptions: { open: { reflect: true }, noHeader: { reflect: true }, ...options.propertyOptions },
|
|
55
72
|
});
|
|
73
|
+
|
|
74
|
+
// element-js keeps the stylesheets of an element on its class, and looks them up there
|
|
75
|
+
// without asking whose they are. A component that extends the dialog found the stylesheets
|
|
76
|
+
// of the dialog there, when a dialog was connected first, and never built its own: an
|
|
77
|
+
// el-drawer after an el-dialog was a dialog in the middle of the page. A property of its own
|
|
78
|
+
// on every class makes the lookup stop there. The fields have the same in FormField.
|
|
79
|
+
if (!Object.hasOwn(this.constructor, 'elementStyleSheets')) {
|
|
80
|
+
this.constructor.elementStyleSheets = undefined;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Counts the ways the dialog has set out on. See `_sync()`.
|
|
85
|
+
* @private
|
|
86
|
+
*/
|
|
87
|
+
this._run = 0;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Where the dialog is, or is on its way to: shown (`true`) or closed.
|
|
91
|
+
* @private
|
|
92
|
+
*/
|
|
93
|
+
this._heading = false;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Whether it is on its way, with a transition still to wait for.
|
|
97
|
+
* @private
|
|
98
|
+
*/
|
|
99
|
+
this._moving = false;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* The names of the events. A component that extends the dialog fires them under names of its
|
|
104
|
+
* own.
|
|
105
|
+
* @protected
|
|
106
|
+
* @returns {typeof Events}
|
|
107
|
+
*/
|
|
108
|
+
get _eventNames() {
|
|
109
|
+
return Events;
|
|
56
110
|
}
|
|
57
111
|
|
|
58
112
|
properties() {
|
|
@@ -65,30 +119,45 @@ export default class Dialog extends TemplateElement {
|
|
|
65
119
|
}
|
|
66
120
|
|
|
67
121
|
connected() {
|
|
122
|
+
// What is in the footer slot right now. A `slotchange` tells of every later change, but the
|
|
123
|
+
// first one can be over before the listener is there: in server-rendered markup the browser
|
|
124
|
+
// fills the slots while it parses.
|
|
125
|
+
const footerSlot = this.$refs.footer?.querySelector('slot');
|
|
126
|
+
if (footerSlot) this._syncFooter(footerSlot);
|
|
127
|
+
|
|
68
128
|
// The watcher does not run during initial hydration, so honour a declaratively-open dialog here.
|
|
69
129
|
if (this.open) {
|
|
70
130
|
this._internals.states.add('open');
|
|
71
|
-
this.
|
|
131
|
+
this._sync();
|
|
72
132
|
}
|
|
73
133
|
}
|
|
74
134
|
|
|
75
135
|
disconnected() {
|
|
76
|
-
//
|
|
77
|
-
|
|
78
|
-
|
|
136
|
+
// A dialog that leaves the page while it is open: the platform takes it out of the top
|
|
137
|
+
// layer, but the `<dialog>` stays open and the page stays locked. Both are undone here, so
|
|
138
|
+
// that the page scrolls again and the dialog can open as a modal when it comes back.
|
|
139
|
+
// element-js has emptied `$refs` by now; the element is the one `_sync()` kept.
|
|
140
|
+
// Whatever way was under way ends here.
|
|
141
|
+
this._run++;
|
|
142
|
+
this._heading = false;
|
|
143
|
+
const dialog = this._shown;
|
|
144
|
+
if (dialog) {
|
|
145
|
+
dialog.classList.remove('showing');
|
|
146
|
+
this._close(dialog);
|
|
147
|
+
// It was on its way out, and it is out now.
|
|
148
|
+
if (!this.open) this.dispatch(this._eventNames.AFTER_HIDE);
|
|
79
149
|
}
|
|
150
|
+
this._settle();
|
|
80
151
|
}
|
|
81
152
|
|
|
82
153
|
watch() {
|
|
83
154
|
return {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
this._applyClose();
|
|
91
|
-
}
|
|
155
|
+
// element-js calls a watcher after the next render, a frame after the change, and once
|
|
156
|
+
// for every change. So what counts is the value `open` has now, not the one of the call.
|
|
157
|
+
open: () => {
|
|
158
|
+
if (this.open) this._internals.states.add('open');
|
|
159
|
+
else this._internals.states.delete('open');
|
|
160
|
+
this._sync();
|
|
92
161
|
},
|
|
93
162
|
};
|
|
94
163
|
}
|
|
@@ -108,42 +177,41 @@ export default class Dialog extends TemplateElement {
|
|
|
108
177
|
this.requestClose('keyboard');
|
|
109
178
|
},
|
|
110
179
|
click: (event) => this._handleOverlayClick(event),
|
|
180
|
+
submit: (event) => this._handleSubmit(event),
|
|
111
181
|
},
|
|
112
182
|
};
|
|
113
183
|
}
|
|
114
184
|
|
|
115
185
|
/**
|
|
116
186
|
* Opens the dialog.
|
|
117
|
-
* @returns {Promise<void>} Resolves
|
|
187
|
+
* @returns {Promise<void>} Resolves once the dialog has come to rest. That is after the open
|
|
188
|
+
* transition as a rule; when a `hide()` overtakes it, it is once the dialog is closed again.
|
|
189
|
+
* It never rejects.
|
|
118
190
|
*/
|
|
119
191
|
show() {
|
|
120
|
-
|
|
121
|
-
const done = this._once(Events.AFTER_SHOW);
|
|
122
|
-
this.open = true;
|
|
123
|
-
return done;
|
|
192
|
+
return this._setOpen(true);
|
|
124
193
|
}
|
|
125
194
|
|
|
126
195
|
/**
|
|
127
196
|
* Closes the dialog.
|
|
128
|
-
* @returns {Promise<void>} Resolves
|
|
197
|
+
* @returns {Promise<void>} Resolves once the dialog has come to rest. That is after the close
|
|
198
|
+
* transition as a rule; when a `show()` overtakes it, it is once the dialog is shown again.
|
|
199
|
+
* It never rejects.
|
|
129
200
|
*/
|
|
130
201
|
hide() {
|
|
131
|
-
|
|
132
|
-
const done = this._once(Events.AFTER_HIDE);
|
|
133
|
-
this.open = false;
|
|
134
|
-
return done;
|
|
202
|
+
return this._setOpen(false);
|
|
135
203
|
}
|
|
136
204
|
|
|
137
205
|
/**
|
|
138
|
-
* Requests that the dialog close, emitting
|
|
139
|
-
*
|
|
206
|
+
* Requests that the dialog close, emitting its cancelable request-close event. When a listener
|
|
207
|
+
* calls `preventDefault()` the dialog stays open and plays a short deny animation.
|
|
140
208
|
* @param {'close-button' | 'keyboard' | 'overlay'} source - What triggered the request.
|
|
141
209
|
* @returns {void}
|
|
142
210
|
*/
|
|
143
211
|
requestClose(source) {
|
|
144
212
|
// element-js's dispatch() swallows the dispatchEvent() return value, so build the cancelable
|
|
145
213
|
// event by hand to read defaultPrevented.
|
|
146
|
-
const event = new CustomEvent(
|
|
214
|
+
const event = new CustomEvent(this._eventNames.REQUEST_CLOSE, {
|
|
147
215
|
bubbles: true,
|
|
148
216
|
composed: true,
|
|
149
217
|
cancelable: true,
|
|
@@ -158,34 +226,138 @@ export default class Dialog extends TemplateElement {
|
|
|
158
226
|
this.open = false;
|
|
159
227
|
}
|
|
160
228
|
|
|
161
|
-
/**
|
|
162
|
-
|
|
229
|
+
/**
|
|
230
|
+
* Sets `open` and hands out the promise for the moment the dialog is at rest again.
|
|
231
|
+
* @private
|
|
232
|
+
* @param {boolean} open
|
|
233
|
+
* @returns {Promise<void>}
|
|
234
|
+
*/
|
|
235
|
+
_setOpen(open) {
|
|
236
|
+
// Outside of the page nothing moves, so there is nothing to wait for.
|
|
237
|
+
if (!this.isConnected) {
|
|
238
|
+
this.open = open;
|
|
239
|
+
return Promise.resolve();
|
|
240
|
+
}
|
|
241
|
+
// The watcher runs a frame later. The promise has to be there before that, whenever the
|
|
242
|
+
// dialog is not where the call wants it. That is not read from `open`: it can have got its
|
|
243
|
+
// value just before, by hand or by a request to close, and the dialog has not moved yet.
|
|
244
|
+
if (this._heading !== open) this._rest ??= pending();
|
|
245
|
+
this.open = open;
|
|
246
|
+
return this._rest?.promise ?? Promise.resolve();
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Brings the `<dialog>` to what `open` says, with the transition on the way.
|
|
251
|
+
*
|
|
252
|
+
* Every time the dialog has to turn, it sets out on a new way with a number of its own. A way
|
|
253
|
+
* waits, for two frames and for the transition, and when it goes on it first looks whether a
|
|
254
|
+
* later way has begun. If so it stops: the last value of `open` wins, and no way finishes
|
|
255
|
+
* work that is out of date.
|
|
256
|
+
*
|
|
257
|
+
* `…-after-show` and `…-after-hide` are fired by the way that gets there. A way that is cut
|
|
258
|
+
* short has none: after `…-show` comes `…-after-show` or `…-hide`, after `…-hide` comes
|
|
259
|
+
* `…-after-hide` or `…-show`.
|
|
260
|
+
* @private
|
|
261
|
+
*/
|
|
262
|
+
async _sync() {
|
|
263
|
+
const wanted = !!this.open;
|
|
163
264
|
const dialog = this.$refs.dialog;
|
|
164
|
-
if (!dialog
|
|
265
|
+
if (!dialog) {
|
|
266
|
+
// Not rendered yet, or not in the page. A dialog that is `open` is shown when it
|
|
267
|
+
// connects; until then only a closed one is at rest.
|
|
268
|
+
if (!wanted || !this.isConnected) this._settle();
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
165
271
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
this.
|
|
272
|
+
// It is there already, or on its way there. `open` can change twice between two frames.
|
|
273
|
+
if (wanted === this._heading) {
|
|
274
|
+
if (!this._moving) this._settle();
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
const run = ++this._run;
|
|
279
|
+
const overtaken = () => run !== this._run;
|
|
280
|
+
this._heading = wanted;
|
|
281
|
+
this._moving = true;
|
|
282
|
+
// What `show()` and `hide()` hand out: one promise for all the ways until it is at rest.
|
|
283
|
+
this._rest ??= pending();
|
|
284
|
+
|
|
285
|
+
const names = this._eventNames;
|
|
286
|
+
if (wanted) {
|
|
287
|
+
this.dispatch(names.SHOW);
|
|
288
|
+
if (!dialog.open) {
|
|
289
|
+
this._shown = dialog;
|
|
290
|
+
this._lockScroll();
|
|
291
|
+
dialog.showModal();
|
|
292
|
+
// The platform has now moved focus inside the dialog; let consumers redirect it.
|
|
293
|
+
this.dispatch(names.INITIAL_FOCUS);
|
|
294
|
+
|
|
295
|
+
// The look before it is shown has to be painted, or the transition has no start.
|
|
296
|
+
await nextFrame();
|
|
297
|
+
if (overtaken()) return;
|
|
298
|
+
}
|
|
299
|
+
// Also the way back from a close that was under way: the `<dialog>` is still open then,
|
|
300
|
+
// and the transition turns round where it is.
|
|
301
|
+
dialog.classList.add('showing');
|
|
302
|
+
await afterTransition(dialog);
|
|
303
|
+
if (overtaken()) return;
|
|
304
|
+
this.dispatch(names.AFTER_SHOW);
|
|
305
|
+
} else {
|
|
306
|
+
this.dispatch(names.HIDE);
|
|
307
|
+
// A dialog that has not begun to come in has no way out to wait for.
|
|
308
|
+
const shown = dialog.classList.contains('showing');
|
|
309
|
+
dialog.classList.remove('showing');
|
|
310
|
+
if (shown) {
|
|
311
|
+
await afterTransition(dialog);
|
|
312
|
+
if (overtaken()) return;
|
|
313
|
+
}
|
|
314
|
+
this._close(dialog);
|
|
315
|
+
this.dispatch(names.AFTER_HIDE);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
this._settle();
|
|
176
319
|
}
|
|
177
320
|
|
|
178
|
-
/**
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
321
|
+
/**
|
|
322
|
+
* Closes the `<dialog>` for the platform and gives the page back.
|
|
323
|
+
* @private
|
|
324
|
+
* @param {HTMLDialogElement} dialog
|
|
325
|
+
*/
|
|
326
|
+
_close(dialog) {
|
|
327
|
+
if (dialog.open) dialog.close();
|
|
328
|
+
this._shown = undefined;
|
|
329
|
+
this._unlockScroll();
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* The dialog is at rest, shown or closed: whoever waits for that can go on.
|
|
334
|
+
* @private
|
|
335
|
+
*/
|
|
336
|
+
_settle() {
|
|
337
|
+
this._moving = false;
|
|
338
|
+
this._rest?.resolve();
|
|
339
|
+
this._rest = undefined;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Takes the lock on the scrolling of the page, once for this dialog.
|
|
344
|
+
* @private
|
|
345
|
+
*/
|
|
346
|
+
_lockScroll() {
|
|
347
|
+
if (this._scrollLocked) return;
|
|
348
|
+
this._scrollLocked = true;
|
|
349
|
+
lockBodyScroll();
|
|
350
|
+
}
|
|
182
351
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
352
|
+
/**
|
|
353
|
+
* Gives the lock back, if this dialog holds it. The lock counts its holders, so a dialog must
|
|
354
|
+
* not give back more than it took.
|
|
355
|
+
* @private
|
|
356
|
+
*/
|
|
357
|
+
_unlockScroll() {
|
|
358
|
+
if (!this._scrollLocked) return;
|
|
359
|
+
this._scrollLocked = false;
|
|
187
360
|
unlockBodyScroll();
|
|
188
|
-
this.dispatch(Events.AFTER_HIDE);
|
|
189
361
|
}
|
|
190
362
|
|
|
191
363
|
/** @private */
|
|
@@ -203,6 +375,34 @@ export default class Dialog extends TemplateElement {
|
|
|
203
375
|
if (!inside) this.requestClose('overlay');
|
|
204
376
|
}
|
|
205
377
|
|
|
378
|
+
/**
|
|
379
|
+
* Closes the dialog for a form with `method="dialog"` in one of its slots, as the platform does
|
|
380
|
+
* for a form inside a `<dialog>`. The platform looks for the `<dialog>` above the form in the
|
|
381
|
+
* tree of the form, and a form in a slot is a child of the element, in the page. Its `submit`
|
|
382
|
+
* passes the `<dialog>` all the same, on its way up through the slot.
|
|
383
|
+
* @private
|
|
384
|
+
* @param {SubmitEvent} event
|
|
385
|
+
*/
|
|
386
|
+
_handleSubmit(event) {
|
|
387
|
+
const path = event.composedPath();
|
|
388
|
+
const form = path[0];
|
|
389
|
+
if (!(form instanceof HTMLFormElement)) return;
|
|
390
|
+
// The nearest `<dialog>` above the form is the one that closes. One that is inside this
|
|
391
|
+
// one, of the platform or of a component, comes before it on the path.
|
|
392
|
+
if (path.find((node) => node.localName === 'dialog') !== event.currentTarget) return;
|
|
393
|
+
|
|
394
|
+
// The button decides before the form. Read from the attributes: a control with the name
|
|
395
|
+
// `method` takes the place of the property of the form.
|
|
396
|
+
const method = event.submitter?.getAttribute('formmethod') ?? form.getAttribute('method');
|
|
397
|
+
if (method?.toLowerCase() !== 'dialog') return;
|
|
398
|
+
|
|
399
|
+
// The platform acts once every listener has had the event, those further up included: on
|
|
400
|
+
// the element, on the document. So whether one of them has prevented it is known after that.
|
|
401
|
+
setTimeout(() => {
|
|
402
|
+
if (!event.defaultPrevented) this.open = false;
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
|
|
206
406
|
/** @private */
|
|
207
407
|
_denyClose() {
|
|
208
408
|
const dialog = this.$refs.dialog;
|
|
@@ -222,11 +422,6 @@ export default class Dialog extends TemplateElement {
|
|
|
222
422
|
this.$refs.footer?.classList.toggle('is-empty', !hasContent);
|
|
223
423
|
}
|
|
224
424
|
|
|
225
|
-
/** @private */
|
|
226
|
-
_once(name) {
|
|
227
|
-
return new Promise((resolve) => this.addEventListener(name, () => resolve(), { once: true }));
|
|
228
|
-
}
|
|
229
|
-
|
|
230
425
|
/** @private */
|
|
231
426
|
headerTemplate() {
|
|
232
427
|
return html`
|