@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,194 @@
|
|
|
1
|
+
# Drawer
|
|
2
|
+
|
|
3
|
+
`drawer` is a panel that slides in from an edge of the viewport and lies over the page: for a navigation, a filter, the details of a row. While it is open the page behind it cannot be used.
|
|
4
|
+
|
|
5
|
+
It is `el-dialog` at another place, a modal built on the native `<dialog>` element. The platform keeps the focus inside, makes the page behind it `inert`, renders it in the top layer (no `z-index` to manage) and gives the focus back when it closes. The component adds the edge it comes from, the slide, a close that a listener can refuse, and the lock on the scrolling of the page.
|
|
6
|
+
|
|
7
|
+
Without a theme the drawer paints nothing: no background, no border, no shadow, no backdrop. Import a theme, or set the `--el-*` tokens yourself.
|
|
8
|
+
|
|
9
|
+
## How to use
|
|
10
|
+
|
|
11
|
+
#### Install
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
npm i --save @webtides/element-library
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
#### Use
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
import '@webtides/element-library/drawer/define';
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
```html
|
|
24
|
+
<button type="button" onclick="document.querySelector('el-drawer').show()">Filters</button>
|
|
25
|
+
|
|
26
|
+
<el-drawer label="Filters">
|
|
27
|
+
<p>The content of the drawer.</p>
|
|
28
|
+
<button slot="footer" type="button" onclick="this.closest('el-drawer').hide()">Cancel</button>
|
|
29
|
+
<button slot="footer" type="button" onclick="this.closest('el-drawer').hide()">Apply</button>
|
|
30
|
+
</el-drawer>
|
|
31
|
+
|
|
32
|
+
<!-- A navigation at the start -->
|
|
33
|
+
<el-drawer label="Menu" placement="start">
|
|
34
|
+
<nav aria-label="Main">…</nav>
|
|
35
|
+
</el-drawer>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Open and close it with `show()` and `hide()`, which both return a promise that resolves once the drawer has come to rest, or with the `open` attribute or property.
|
|
39
|
+
|
|
40
|
+
> Boolean attributes are passed as strings (`no-header="true"`), matching the rest of the library.
|
|
41
|
+
|
|
42
|
+
## API
|
|
43
|
+
|
|
44
|
+
#### Properties/Attributes
|
|
45
|
+
|
|
46
|
+
| Name | Type | Default | Description |
|
|
47
|
+
| --- | --- | --- | --- |
|
|
48
|
+
| `open` | `boolean` | `false` | Whether the drawer is open. Reflected to the `open` attribute. |
|
|
49
|
+
| `label` | `string` | `''` | The title of the drawer (used when the `label` slot is empty), and its accessible name with `no-header`. |
|
|
50
|
+
| `placement` | `string` | `'end'` | The edge the drawer comes from: `start`, `end`, `top` or `bottom`. Reflected to the `placement` attribute. |
|
|
51
|
+
| `no-header` | `boolean` | `false` | Removes the header (title and close button). Reflected to the `no-header` attribute. |
|
|
52
|
+
| `close-label` | `string` | `'Close'` | Accessible label of the close button. |
|
|
53
|
+
|
|
54
|
+
The properties of the last two are `noHeader` and `closeLabel`.
|
|
55
|
+
|
|
56
|
+
#### Methods
|
|
57
|
+
|
|
58
|
+
| Name | Returns | Description |
|
|
59
|
+
| ---------------------- | --------------- | ------------------------------------------------------------------- |
|
|
60
|
+
| `show()` | `Promise<void>` | Opens the drawer. Resolves once it has come to rest. |
|
|
61
|
+
| `hide()` | `Promise<void>` | Closes the drawer. Resolves once it has come to rest. |
|
|
62
|
+
| `requestClose(source)` | `void` | Asks for a close with `drawer-request-close`, which can be refused. |
|
|
63
|
+
|
|
64
|
+
#### Events
|
|
65
|
+
|
|
66
|
+
| Name | Cancelable | Detail | Description |
|
|
67
|
+
| --- | --- | --- | --- |
|
|
68
|
+
| `drawer-show` | no | | The drawer starts to open. |
|
|
69
|
+
| `drawer-after-show` | no | | The drawer has slid in. |
|
|
70
|
+
| `drawer-hide` | no | | The drawer starts to close. |
|
|
71
|
+
| `drawer-after-hide` | no | | The drawer has slid out. |
|
|
72
|
+
| `drawer-initial-focus` | no | | The focus has moved into the drawer. Move it in a listener to have it elsewhere. |
|
|
73
|
+
| `drawer-request-close` | yes | `{ source: 'close-button' \| 'keyboard' \| 'overlay' }` | A close was asked for. `preventDefault()` keeps the drawer open. |
|
|
74
|
+
|
|
75
|
+
All of them bubble and cross shadow boundaries.
|
|
76
|
+
|
|
77
|
+
#### Slots
|
|
78
|
+
|
|
79
|
+
| Name | Description |
|
|
80
|
+
| ---------------- | ------------------------------------------------------------- |
|
|
81
|
+
| _(default)_ | The content of the drawer (body). |
|
|
82
|
+
| `label` | The title. Takes precedence over the `label` attribute. |
|
|
83
|
+
| `header-actions` | Controls in the header, before the close button. |
|
|
84
|
+
| `footer` | The footer, for buttons as a rule. Left out when it is empty. |
|
|
85
|
+
|
|
86
|
+
#### CSS Parts
|
|
87
|
+
|
|
88
|
+
| Name | Description |
|
|
89
|
+
| ---------------- | ----------------------------------------------------------------------------------- |
|
|
90
|
+
| `base` | The native `<dialog>`: the surface of the drawer. The backdrop is its `::backdrop`. |
|
|
91
|
+
| `header` | The header row (title, header actions, close button). |
|
|
92
|
+
| `title` | The title heading. |
|
|
93
|
+
| `header-actions` | The container of the `header-actions` slot. |
|
|
94
|
+
| `close-button` | The close button. |
|
|
95
|
+
| `body` | The body with the default slot. It scrolls when the content is longer. |
|
|
96
|
+
| `footer` | The footer with the `footer` slot. |
|
|
97
|
+
|
|
98
|
+
#### CSS States
|
|
99
|
+
|
|
100
|
+
| Name | Description |
|
|
101
|
+
| ------ | ------------------------------------------------------------------------------------ |
|
|
102
|
+
| `open` | Present on the element while the drawer is open. Style with `el-drawer:state(open)`. |
|
|
103
|
+
|
|
104
|
+
#### CSS Custom Properties
|
|
105
|
+
|
|
106
|
+
The surface reads `--el-color-bg`, `--el-color-fg` and `--el-shadow-lg`, and for the border on the edge that faces the page `--el-border-width` and `--el-color-border`. The parts read `--el-space-2` and `--el-space-4`, `--el-font-size-lg`, `--el-font-weight-semibold` and `--el-radius-md` (the close button). The slide takes `--el-duration-md` with `--el-ease`.
|
|
107
|
+
|
|
108
|
+
| Name | Default | Description |
|
|
109
|
+
| --- | --- | --- |
|
|
110
|
+
| `--el-drawer-size` | `25rem` at the start and the end, the height of the content at the top and the bottom | The width of a drawer at the start or the end, the height of one at the top or the bottom. |
|
|
111
|
+
| `--el-dialog-overlay-background` | `transparent` | The background of the backdrop. The drawer shares it with `el-dialog`, so a theme sets one. |
|
|
112
|
+
|
|
113
|
+
The drawer has square corners and no border on the edges it lies against. To change the surface, style the part:
|
|
114
|
+
|
|
115
|
+
```css
|
|
116
|
+
el-drawer {
|
|
117
|
+
--el-drawer-size: 20rem;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
el-drawer::part(base) {
|
|
121
|
+
border-radius: 1rem 0 0 1rem;
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
On a touch screen (`@media (any-pointer: coarse)`) the close button is at least `--el-touch-target` wide and high. Its icon keeps its size, and the header grows with the button. Without that token, and on a fine pointer, the sizes stay as they are.
|
|
126
|
+
|
|
127
|
+
## Placement
|
|
128
|
+
|
|
129
|
+
`placement` names the edge of the viewport the drawer lies along and slides in from.
|
|
130
|
+
|
|
131
|
+
- `start` and `end` are the two ends of a line of text: left and right, and the other way round in a right-to-left page (`dir="rtl"` on the page, on an element around the drawer or on the drawer). The drawer goes from the top of the viewport to the bottom and is `--el-drawer-size` wide.
|
|
132
|
+
- `top` and `bottom` go across the viewport. The drawer is as high as its content, or `--el-drawer-size` high when that is set.
|
|
133
|
+
- A placement that is none of the four is `end`.
|
|
134
|
+
|
|
135
|
+
The drawer is never wider or higher than the viewport. On a narrow screen a drawer at the start or the end covers the page, and the close button is the way back.
|
|
136
|
+
|
|
137
|
+
A page that reaches under the notch and the home indicator of a phone (`viewport-fit=cover`) keeps the content of the drawer clear of them itself:
|
|
138
|
+
|
|
139
|
+
```css
|
|
140
|
+
el-drawer::part(base) {
|
|
141
|
+
padding-block-end: env(safe-area-inset-bottom);
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## Opening and closing
|
|
146
|
+
|
|
147
|
+
- `show()`, or `open` set, opens the drawer. `hide()`, or `open` taken back, closes it, whatever a listener says.
|
|
148
|
+
- **The close button**, **`Escape`** and **a click on the backdrop** ask for a close: they fire `drawer-request-close` with what asked in `detail.source`. A listener that calls `preventDefault()` keeps the drawer open, to protect unsaved input for example. The drawer then grows a little for a moment, to show that the request arrived. `requestClose(source)` asks the same from a script.
|
|
149
|
+
- The drawer slides in `--el-duration-md`. Without that token, and for a user who prefers reduced motion, it is in its place at once.
|
|
150
|
+
- `open` can change while the drawer slides, by a button that is clicked twice for example. The last value wins: a drawer that is closed on its way in turns back, one that is opened on its way out turns round. `drawer-after-show` and `drawer-after-hide` fire when the drawer has got there, so a way that is cut short has none: after `drawer-show` comes `drawer-after-show` or `drawer-hide`, after `drawer-hide` comes `drawer-after-hide` or `drawer-show`. The promises of `show()` and `hide()` resolve when the drawer is at rest, at whichever end, and never reject.
|
|
151
|
+
- A form with `method="dialog"` inside the drawer closes it when it is submitted: by its submit button, by `Enter` in one of its fields, or by a button that belongs to it through the `form` attribute, in the footer for example. A button with `formmethod="dialog"` does the same in a form with another method. Nothing is sent, and the drawer closes without `drawer-request-close`: a listener that calls `preventDefault()` on the `submit` keeps it open, and so does a form that is not valid.
|
|
152
|
+
|
|
153
|
+
## Focus
|
|
154
|
+
|
|
155
|
+
When the drawer opens, the platform moves the focus into it: to the element in it that has the `autofocus` attribute, or else to the first one that takes the focus, which is the close button. To have the focus somewhere else, move it in a listener of `drawer-initial-focus`.
|
|
156
|
+
|
|
157
|
+
The focus of the keyboard stays inside the drawer while it is open, and goes back to the element that had it when the drawer closes.
|
|
158
|
+
|
|
159
|
+
## Scroll locking
|
|
160
|
+
|
|
161
|
+
While a drawer is open the page does not scroll. The lock counts its holders, so a drawer and a dialog that are open at the same time work together. Hiding the scrollbar would make the page wider and move its content, so the lock pads the document by the width of the scrollbar it took away. Elements that are fixed to the right edge still move by that width; reserve the room for the scrollbar up front to avoid it:
|
|
162
|
+
|
|
163
|
+
```css
|
|
164
|
+
:root {
|
|
165
|
+
scrollbar-gutter: stable;
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
A drawer that is taken out of the page while it is open gives its lock back, and opens again when it is put back while `open`.
|
|
170
|
+
|
|
171
|
+
## Accessibility
|
|
172
|
+
|
|
173
|
+
- The drawer is a dialog for a screen reader, with its title as its name. With `no-header` set `label`, which names it then.
|
|
174
|
+
- It opens with `showModal()`: the focus stays inside, the rest of the page is `inert`, and the focus goes back where it was when the drawer closes.
|
|
175
|
+
- `Escape` closes it, through `drawer-request-close`.
|
|
176
|
+
- The close button has the name `Close`. Set `close-label` for another language.
|
|
177
|
+
- Give a drawer without a header a way to close it that a pointer can use.
|
|
178
|
+
- A navigation in a drawer stays a `<nav>` of the page, with a name of its own (`aria-label`).
|
|
179
|
+
|
|
180
|
+
## Server-side rendering
|
|
181
|
+
|
|
182
|
+
The closed drawer is part of the server-rendered markup (Declarative Shadow DOM). A `<dialog>` that is not open is not shown, so nothing flashes before the JavaScript has loaded. Opening needs the JavaScript: a drawer with `open` in the markup opens when its element is defined.
|
|
183
|
+
|
|
184
|
+
Without server-side rendering the content of a drawer is in the page until its element is defined. Hide it until then:
|
|
185
|
+
|
|
186
|
+
```css
|
|
187
|
+
el-drawer:not(:defined) {
|
|
188
|
+
display: none;
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## Browser support
|
|
193
|
+
|
|
194
|
+
The drawer needs the native `<dialog>` element and custom states (`:state()`): Chrome 125, Firefox 126, Safari 17.4.
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import modalStyle from '../../styles/modal.style.js';
|
|
2
|
+
|
|
3
|
+
const css = String.raw;
|
|
4
|
+
|
|
5
|
+
const border = 'var(--el-border-width, 0)';
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
* What is the drawer's own: a box along one edge of the viewport, which slides in from that edge.
|
|
9
|
+
* The paint of the surface, the backdrop and the parts are in the modal module.
|
|
10
|
+
*
|
|
11
|
+
* The first rule is the drawer at the end of the line, which is also what a placement that is none
|
|
12
|
+
* of the four gets. The other placements change what differs.
|
|
13
|
+
*/
|
|
14
|
+
const style = css`
|
|
15
|
+
dialog {
|
|
16
|
+
/* The direction the end of a line is in: 1 for the right, -1 for the left. */
|
|
17
|
+
--_el-drawer-end: 1;
|
|
18
|
+
/* How far the drawer is out of the viewport before it is shown. */
|
|
19
|
+
--_el-drawer-x: calc(100% * var(--_el-drawer-end));
|
|
20
|
+
--_el-drawer-y: 0;
|
|
21
|
+
|
|
22
|
+
box-sizing: border-box;
|
|
23
|
+
/* The browser centres a modal dialog and keeps it smaller than the viewport. Here it lies
|
|
24
|
+
against three edges, and the fourth is free. */
|
|
25
|
+
inset: 0;
|
|
26
|
+
inset-inline-start: auto;
|
|
27
|
+
/* Not in the middle either, when a page makes it shorter than the viewport. */
|
|
28
|
+
margin: 0;
|
|
29
|
+
max-inline-size: 100%;
|
|
30
|
+
max-block-size: 100%;
|
|
31
|
+
inline-size: var(--el-drawer-size, 25rem);
|
|
32
|
+
/* From edge to edge: the browser gives a dialog the height of its content. */
|
|
33
|
+
block-size: auto;
|
|
34
|
+
|
|
35
|
+
/* A border on the edge that faces the page only. */
|
|
36
|
+
border: 0 solid var(--el-color-border, transparent);
|
|
37
|
+
border-inline-start-width: ${border};
|
|
38
|
+
|
|
39
|
+
transform: translate(var(--_el-drawer-x), var(--_el-drawer-y));
|
|
40
|
+
/* A close that is refused makes the dialog a little larger for a moment. The drawer grows
|
|
41
|
+
away from its edge. */
|
|
42
|
+
transform-origin: calc(50% + 50% * var(--_el-drawer-end)) 50%;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/* Asked of the host. With \`dir\` on an element around the drawer, Chromium does not match
|
|
46
|
+
\`:dir(rtl)\` for an element inside the shadow root. */
|
|
47
|
+
:host(:dir(rtl)) dialog {
|
|
48
|
+
--_el-drawer-end: -1;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
:host([placement='start']) dialog {
|
|
52
|
+
--_el-drawer-x: calc(-100% * var(--_el-drawer-end));
|
|
53
|
+
inset-inline: 0 auto;
|
|
54
|
+
border-inline-width: 0 ${border};
|
|
55
|
+
transform-origin: calc(50% - 50% * var(--_el-drawer-end)) 50%;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/* Across the viewport, and as high as the content unless a size is given. */
|
|
59
|
+
:host([placement='top']) dialog,
|
|
60
|
+
:host([placement='bottom']) dialog {
|
|
61
|
+
--_el-drawer-x: 0;
|
|
62
|
+
inset-inline: 0;
|
|
63
|
+
inline-size: auto;
|
|
64
|
+
block-size: var(--el-drawer-size, auto);
|
|
65
|
+
border-inline-width: 0;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
:host([placement='top']) dialog {
|
|
69
|
+
--_el-drawer-y: -100%;
|
|
70
|
+
inset-block-end: auto;
|
|
71
|
+
border-block-end-width: ${border};
|
|
72
|
+
transform-origin: 50% 0;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
:host([placement='bottom']) dialog {
|
|
76
|
+
--_el-drawer-y: 100%;
|
|
77
|
+
inset-block-start: auto;
|
|
78
|
+
border-block-start-width: ${border};
|
|
79
|
+
transform-origin: 50% 100%;
|
|
80
|
+
}
|
|
81
|
+
`;
|
|
82
|
+
|
|
83
|
+
export default [modalStyle(), style].join('\n');
|
|
@@ -82,13 +82,15 @@ export default class Dropdown extends TemplateElement {
|
|
|
82
82
|
template() {
|
|
83
83
|
return html`
|
|
84
84
|
<slot part="trigger" name="trigger" show-dropdown></slot>
|
|
85
|
-
${
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
<
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
85
|
+
${
|
|
86
|
+
this.open
|
|
87
|
+
? html`
|
|
88
|
+
<div part="panel">
|
|
89
|
+
<slot part="content" name="content"></slot>
|
|
90
|
+
</div>
|
|
91
|
+
`
|
|
92
|
+
: null
|
|
93
|
+
}
|
|
92
94
|
`;
|
|
93
95
|
}
|
|
94
96
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
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-empty-state`: what stands in the place of a list or a collection while there is nothing in it. Pure presentation, without a role and without behaviour. ([#83](https://github.com/webtides/element-library/issues/83))
|
|
20
|
+
- Four regions, each of them a slot: `icon`, `heading`, the message (the default slot) and `action`. A region that nothing is slotted into takes no space, on the server as in the browser, and comes and goes with its element.
|
|
21
|
+
- The content is a column in the middle, at most `30rem` wide. The message, the icon and the action have the muted text colour (`--el-color-fg-muted`), the heading has `--el-color-fg` and is semibold; the gaps and the padding come from the spacing tokens. No surface is painted.
|
|
22
|
+
- The action is an element of the page, a button with a listener of its own: the component has no properties and fires no event.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { TemplateElement, defineElement, html } from '@webtides/element-js';
|
|
2
|
+
import { hasSlotted } from '../../utils/slots.js';
|
|
3
|
+
import style from './empty-state.style.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* An empty state: what stands in the place of a list or a collection while there is nothing in
|
|
7
|
+
* it. A message in the middle, with a heading above it, an icon above that and an action below, as
|
|
8
|
+
* far as they are given. Pure presentation, without a role and without behaviour.
|
|
9
|
+
*
|
|
10
|
+
* @element el-empty-state
|
|
11
|
+
*
|
|
12
|
+
* @slot - The message: what is missing, and what to do about it.
|
|
13
|
+
* @slot icon - An icon or an illustration above the heading.
|
|
14
|
+
* @slot heading - A short heading above the message.
|
|
15
|
+
* @slot action - What the user can do now: a button, a link, or two.
|
|
16
|
+
*
|
|
17
|
+
* @csspart base - The column in the middle that holds the regions.
|
|
18
|
+
* @csspart icon - The region of the `icon` slot.
|
|
19
|
+
* @csspart heading - The region of the `heading` slot.
|
|
20
|
+
* @csspart message - The region of the default slot.
|
|
21
|
+
* @csspart action - The region of the `action` slot.
|
|
22
|
+
*/
|
|
23
|
+
export default class EmptyState extends TemplateElement {
|
|
24
|
+
constructor() {
|
|
25
|
+
super({
|
|
26
|
+
styles: [style],
|
|
27
|
+
shadowRender: true,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
events() {
|
|
32
|
+
return {
|
|
33
|
+
// A template element does not render again when a child comes, goes or changes its
|
|
34
|
+
// `slot` attribute. The slot tells of all three, and the event bubbles to the base.
|
|
35
|
+
"[part~='base']": {
|
|
36
|
+
slotchange: () => this.requestUpdate(),
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
template() {
|
|
42
|
+
return html`
|
|
43
|
+
<div part="base" class="empty-state">
|
|
44
|
+
<div part="icon" ?hidden="${!hasSlotted(this, 'icon')}"><slot name="icon"></slot></div>
|
|
45
|
+
<div part="heading" ?hidden="${!hasSlotted(this, 'heading')}"><slot name="heading"></slot></div>
|
|
46
|
+
<div part="message"><slot></slot></div>
|
|
47
|
+
<div part="action" ?hidden="${!hasSlotted(this, 'action')}"><slot name="action"></slot></div>
|
|
48
|
+
</div>
|
|
49
|
+
`;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function define() {
|
|
54
|
+
defineElement('el-empty-state', EmptyState);
|
|
55
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# Empty State
|
|
2
|
+
|
|
3
|
+
`empty-state` stands in the place of a list or a collection while there is nothing in it: a message in the middle, with a heading above it, an icon above that and an action below, as far as they are given. It is pure presentation, without a role and without behaviour.
|
|
4
|
+
|
|
5
|
+
It paints no surface. Its colours are the text colours of the theme, and the text colour of the page without one.
|
|
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/empty-state/define';
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
```html
|
|
22
|
+
<el-empty-state>Nothing here yet.</el-empty-state>
|
|
23
|
+
|
|
24
|
+
<!-- With a heading and an action -->
|
|
25
|
+
<el-empty-state>
|
|
26
|
+
<h3 slot="heading">No projects yet</h3>
|
|
27
|
+
A project holds everything that belongs to one piece of work.
|
|
28
|
+
<el-button slot="action" variant="brand">Create a project</el-button>
|
|
29
|
+
</el-empty-state>
|
|
30
|
+
|
|
31
|
+
<!-- With an icon above -->
|
|
32
|
+
<el-empty-state>
|
|
33
|
+
<svg slot="icon" width="48" height="48" aria-hidden="true">…</svg>
|
|
34
|
+
<h3 slot="heading">No results</h3>
|
|
35
|
+
No project matches your search.
|
|
36
|
+
<el-button slot="action">Reset the search</el-button>
|
|
37
|
+
</el-empty-state>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
The action is an element of your own, with a listener of your own: the empty state fires no event.
|
|
41
|
+
|
|
42
|
+
## API
|
|
43
|
+
|
|
44
|
+
#### Properties/Attributes
|
|
45
|
+
|
|
46
|
+
_None._
|
|
47
|
+
|
|
48
|
+
#### Methods
|
|
49
|
+
|
|
50
|
+
_None._
|
|
51
|
+
|
|
52
|
+
#### Events
|
|
53
|
+
|
|
54
|
+
_None._
|
|
55
|
+
|
|
56
|
+
#### Slots
|
|
57
|
+
|
|
58
|
+
| Name | Description |
|
|
59
|
+
| ----------- | ------------------------------------------------------ |
|
|
60
|
+
| _(default)_ | The message: what is missing, and what to do about it. |
|
|
61
|
+
| `icon` | An icon or an illustration above the heading. |
|
|
62
|
+
| `heading` | A short heading above the message. |
|
|
63
|
+
| `action` | What the user can do now: a button, a link, or two. |
|
|
64
|
+
|
|
65
|
+
#### CSS Parts
|
|
66
|
+
|
|
67
|
+
| Name | Description |
|
|
68
|
+
| --------- | ------------------------------------------------ |
|
|
69
|
+
| `base` | The column in the middle that holds the regions. |
|
|
70
|
+
| `icon` | The region of the `icon` slot. |
|
|
71
|
+
| `heading` | The region of the `heading` slot. |
|
|
72
|
+
| `message` | The region of the default slot. |
|
|
73
|
+
| `action` | The region of the `action` slot. |
|
|
74
|
+
|
|
75
|
+
#### CSS Custom Properties
|
|
76
|
+
|
|
77
|
+
Reads the standard library design tokens: `--el-color-fg-muted` for the message, the icon and the action, `--el-color-fg` for the heading, and `--el-space-2`, `--el-space-4` and `--el-space-5` for the gaps and the padding.
|
|
78
|
+
|
|
79
|
+
## Regions
|
|
80
|
+
|
|
81
|
+
The regions are below each other in a fixed order, whatever the order of the children: `icon`, `heading`, the message, `action`. Each of `icon`, `heading` and `action` is there when an element with its `slot` is a child of the empty state, and comes and goes with that element. A message that is not there leaves no gap.
|
|
82
|
+
|
|
83
|
+
- **`icon`** places what is slotted into it in the middle. The icon has the size you give it and the muted text colour (`currentColor`).
|
|
84
|
+
- **`heading`** has the text colour of the page and is semibold. The level of the heading is yours: `<h3 slot="heading">`.
|
|
85
|
+
- **The message** is text like any other: a link in it stays in its line.
|
|
86
|
+
- **`action`** lines what is slotted into it up in the middle, with a gap, and wraps.
|
|
87
|
+
|
|
88
|
+
The regions take the margins of the browser off a heading or a paragraph that is slotted into them, and space them themselves.
|
|
89
|
+
|
|
90
|
+
## Size and place
|
|
91
|
+
|
|
92
|
+
The empty state is as wide as its container, and its content is a column in the middle of it, at most `30rem` wide, so that a message stays readable in a wide place. For another width, set it on the part:
|
|
93
|
+
|
|
94
|
+
```css
|
|
95
|
+
el-empty-state::part(base) {
|
|
96
|
+
max-width: 20rem;
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Its height is the one of its content, with a padding of `--el-space-5` above and below. For an empty state that fills a place of a fixed height, centre it in that place with the layout of the page.
|
|
101
|
+
|
|
102
|
+
The `hidden` attribute hides the empty state.
|
|
103
|
+
|
|
104
|
+
## Accessibility
|
|
105
|
+
|
|
106
|
+
- An empty state is text for assistive technology, read where it stands in the page. It has no role.
|
|
107
|
+
- It is not announced when it appears. If a list empties while the user is on the page, after a search or a deletion, say so in a live region of the page.
|
|
108
|
+
- Write into the message what is missing and what to do about it. An icon alone does not say it.
|
|
109
|
+
- An icon that only decorates is hidden from assistive technology: `aria-hidden="true"` on an `svg`, an empty `alt` on an `img`.
|
|
110
|
+
- Whether the message can be read depends on the colours of the theme: `--el-color-fg-muted` needs a contrast of 4.5 : 1 to the background it stands on. The three shipped themes have that on `--el-color-bg` and on the muted fill, in a `filled` card for example, in both schemes.
|
|
111
|
+
|
|
112
|
+
## Server-side rendering
|
|
113
|
+
|
|
114
|
+
The empty state is fully part of the server-rendered markup (Declarative Shadow DOM) and looks the same before and after its JavaScript has loaded. Which regions are left out is read from the children of the element, on the server as in the browser, so nothing moves when the element takes over.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import hostStyle from '../../styles/host.style.js';
|
|
2
|
+
|
|
3
|
+
const css = String.raw;
|
|
4
|
+
|
|
5
|
+
const style = css`
|
|
6
|
+
:host {
|
|
7
|
+
display: block;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/*
|
|
11
|
+
* A column in the middle of the host, no wider than a text can be read. It paints nothing:
|
|
12
|
+
* the colours are the text colours of the theme, and the ones of the page without a theme.
|
|
13
|
+
*/
|
|
14
|
+
.empty-state {
|
|
15
|
+
max-width: 30rem;
|
|
16
|
+
margin-inline: auto;
|
|
17
|
+
padding: var(--el-space-5, 1.5rem) var(--el-space-4, 1rem);
|
|
18
|
+
color: var(--el-color-fg-muted, inherit);
|
|
19
|
+
text-align: center;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/* A gap above every region that has one before it. Margins, and not the gap of a grid: the
|
|
23
|
+
message is always there, and while it is empty it collapses into nothing, its margin
|
|
24
|
+
included. */
|
|
25
|
+
[part]:not([hidden]) ~ [part] {
|
|
26
|
+
margin-top: var(--el-space-2, 0.5rem);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* The action stands a little apart from the text. */
|
|
30
|
+
[part]:not([hidden]) ~ [part~='action'] {
|
|
31
|
+
margin-top: var(--el-space-4, 1rem);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/* A flex row, so that an icon is in the middle also where a reset of the page makes an image
|
|
35
|
+
or an svg a block. */
|
|
36
|
+
[part~='icon'] {
|
|
37
|
+
display: flex;
|
|
38
|
+
justify-content: center;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
[part~='heading'] {
|
|
42
|
+
color: var(--el-color-fg, inherit);
|
|
43
|
+
font-weight: var(--el-font-weight-semibold, 600);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
[part~='action'] {
|
|
47
|
+
display: flex;
|
|
48
|
+
flex-wrap: wrap;
|
|
49
|
+
justify-content: center;
|
|
50
|
+
gap: var(--el-space-2, 0.5rem);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/* The regions space what is slotted into them. The margins the browser gives a heading or a
|
|
54
|
+
paragraph would come on top of that. */
|
|
55
|
+
::slotted(*) {
|
|
56
|
+
margin: 0;
|
|
57
|
+
}
|
|
58
|
+
`;
|
|
59
|
+
|
|
60
|
+
export default [hostStyle(), 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-file-field`: one or several files for a form. A native `<input type="file">` with the label, the help message, the error message and the layout of every field; the dialog, a drop onto the control and the form submission are the ones of the browser. ([#140](https://github.com/webtides/element-library/issues/140))
|
|
20
|
+
- `accept`, `multiple` and `capture` reach the control. `files` gives the chosen files, `value` is the list of their names, and `input-change` reports it on every choice, also one of files with the names of the files before.
|
|
21
|
+
- The files come from the user: a value from a script that names other files is put back to the names of the control. An empty value takes the choice away, and so does `form.reset()`.
|
|
22
|
+
- `required` keeps the form from being submitted without a file. An error the page renders the field with (`valid="false"`), a file that was too large for the server, shows from the start.
|
|
23
|
+
- The field is touched once the user has left the control for another place of the page. The dialog of the system takes the focus from the page as well, which does not touch the field: the error message of a required field does not show behind the dialog.
|
|
24
|
+
- The control keeps the look of the browser. With `styles/native.css` it has the border, the colours, the focus ring and the three sizes of the input of `el-input-field`, and its button the tokens of the theme. On a touch screen it is at least `--el-touch-target` high.
|