@ui-sdk/web 0.0.0-stage → 0.1.0-beta.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/LICENSE +202 -0
- package/README.md +10 -2
- package/browser/web/accordion.js +1 -0
- package/browser/web/alert-dialog.js +1 -0
- package/browser/web/autocomplete.js +1 -0
- package/browser/web/avatar.js +1 -0
- package/browser/web/button.js +1 -0
- package/browser/web/calendar.js +1 -0
- package/browser/web/carousel.js +1 -0
- package/browser/web/checkbox.js +1 -0
- package/browser/web/chunks/0eRGibL6.js +1 -0
- package/browser/web/chunks/2bIEUO6_.js +1 -0
- package/browser/web/chunks/5A9w2ULz.js +1 -0
- package/browser/web/chunks/5RSyydjV.js +1 -0
- package/browser/web/chunks/9pWTy2wl.js +1 -0
- package/browser/web/chunks/B0f2j6zz.js +1 -0
- package/browser/web/chunks/B1rux6br.js +1 -0
- package/browser/web/chunks/B3-APaNf.js +1 -0
- package/browser/web/chunks/B7EgSgjQ.js +1 -0
- package/browser/web/chunks/B8QcOzJU.js +1 -0
- package/browser/web/chunks/BFueEkwm.js +3 -0
- package/browser/web/chunks/BJj3oS29.js +1 -0
- package/browser/web/chunks/BNSvTCpr.js +1 -0
- package/browser/web/chunks/BPD0kAZB.js +1 -0
- package/browser/web/chunks/BQeduZqT.js +1 -0
- package/browser/web/chunks/B_CVFyiz.js +1 -0
- package/browser/web/chunks/B_ns1YHO.js +1 -0
- package/browser/web/chunks/BcwkVTsR.js +1 -0
- package/browser/web/chunks/BeaQ6TYM.js +1 -0
- package/browser/web/chunks/BgBB013u.js +1 -0
- package/browser/web/chunks/BgsKhHDm.js +1 -0
- package/browser/web/chunks/BjMcbuhi.js +9 -0
- package/browser/web/chunks/Bjiy_F2N.js +1 -0
- package/browser/web/chunks/BqScCLwv.js +1 -0
- package/browser/web/chunks/BqX3Utqx.js +1 -0
- package/browser/web/chunks/BtVkQf3z.js +1 -0
- package/browser/web/chunks/By30h-7B.js +1 -0
- package/browser/web/chunks/C1zqYpy2.js +1 -0
- package/browser/web/chunks/C436juFf.js +1 -0
- package/browser/web/chunks/C4_bULs1.js +1 -0
- package/browser/web/chunks/C4omqJEz.js +1 -0
- package/browser/web/chunks/C7tt0T3n.js +1 -0
- package/browser/web/chunks/C8w7s5dg.js +1 -0
- package/browser/web/chunks/CElY4erO.js +1 -0
- package/browser/web/chunks/CFODo-m2.js +1 -0
- package/browser/web/chunks/CL4wjam9.js +1 -0
- package/browser/web/chunks/CMg-8UVf.js +1 -0
- package/browser/web/chunks/COWKfakj.js +1 -0
- package/browser/web/chunks/CQBU0qZ4.js +1 -0
- package/browser/web/chunks/CV6uABgc.js +1 -0
- package/browser/web/chunks/C_SWFpWQ.js +1 -0
- package/browser/web/chunks/C_Uanbrl.js +1 -0
- package/browser/web/chunks/Ce_CSanC.js +1 -0
- package/browser/web/chunks/Cg-ZmRhS.js +1 -0
- package/browser/web/chunks/Cgf2wPI_.js +1 -0
- package/browser/web/chunks/Cuep_3Vf.js +1 -0
- package/browser/web/chunks/D02PaHn6.js +1 -0
- package/browser/web/chunks/D5LiaI5R.js +1 -0
- package/browser/web/chunks/D9UgVYvF.js +1 -0
- package/browser/web/chunks/DC08tnkE.js +2 -0
- package/browser/web/chunks/DG8YGSvu.js +1 -0
- package/browser/web/chunks/DIQd0FYD.js +1 -0
- package/browser/web/chunks/DMLqacE8.js +1 -0
- package/browser/web/chunks/DSUI3yI-.js +1 -0
- package/browser/web/chunks/DT3Hb76X.js +1 -0
- package/browser/web/chunks/DY75g3-W.js +1 -0
- package/browser/web/chunks/DZpNQKZ9.js +1 -0
- package/browser/web/chunks/Db-W1wrC.js +1 -0
- package/browser/web/chunks/Dc1xK3Ii.js +1 -0
- package/browser/web/chunks/DdF6awFs.js +1 -0
- package/browser/web/chunks/DdaCLml8.js +1 -0
- package/browser/web/chunks/Dh8MLjQO.js +1 -0
- package/browser/web/chunks/DiuslJRy.js +1 -0
- package/browser/web/chunks/DjRcw3Y0.js +1 -0
- package/browser/web/chunks/Djdv-16J.js +1 -0
- package/browser/web/chunks/DnFXe_lF.js +1 -0
- package/browser/web/chunks/DneGv1oC.js +1 -0
- package/browser/web/chunks/DsVxP-p-.js +1 -0
- package/browser/web/chunks/DwDilCo2.js +1 -0
- package/browser/web/chunks/DwV48AXv.js +1 -0
- package/browser/web/chunks/F37aF4-L.js +1 -0
- package/browser/web/chunks/LyB6XIbN.js +1 -0
- package/browser/web/chunks/NKnbYGjC.js +1 -0
- package/browser/web/chunks/Vk-rVi16.js +1 -0
- package/browser/web/chunks/XsM0J1Ex.js +1 -0
- package/browser/web/chunks/asSN9iEp.js +1 -0
- package/browser/web/chunks/c-AjHfdF.js +1 -0
- package/browser/web/chunks/dR-12TPY.js +1 -0
- package/browser/web/chunks/hR4xM0EC.js +1 -0
- package/browser/web/chunks/hqOaBxAg.js +1 -0
- package/browser/web/chunks/kMKqqeG4.js +1 -0
- package/browser/web/chunks/kXboBcfi.js +1 -0
- package/browser/web/chunks/l4aQIg22.js +1 -0
- package/browser/web/chunks/tJC0JSU4.js +1 -0
- package/browser/web/chunks/wHdS_QYM.js +1 -0
- package/browser/web/chunks/yv8dTvNI.js +1 -0
- package/browser/web/chunks/yw9M3nfi.js +1 -0
- package/browser/web/collapsible.js +1 -0
- package/browser/web/color-picker.js +1 -0
- package/browser/web/combobox.js +2 -0
- package/browser/web/command.js +1 -0
- package/browser/web/core.js +5 -0
- package/browser/web/date-input.js +1 -0
- package/browser/web/date-picker.js +1 -0
- package/browser/web/dialog.js +1 -0
- package/browser/web/drawer.js +1 -0
- package/browser/web/field.js +1 -0
- package/browser/web/file-input.js +1 -0
- package/browser/web/hover-card.js +1 -0
- package/browser/web/image-cropper.js +1 -0
- package/browser/web/input.js +1 -0
- package/browser/web/label.js +1 -0
- package/browser/web/listbox.js +1 -0
- package/browser/web/menu.js +1 -0
- package/browser/web/menubar.js +1 -0
- package/browser/web/meter.js +1 -0
- package/browser/web/navigation-menu.js +1 -0
- package/browser/web/number-input.js +1 -0
- package/browser/web/otp-input.js +2 -0
- package/browser/web/overlays.js +1 -0
- package/browser/web/pagination.js +1 -0
- package/browser/web/password-input.js +1 -0
- package/browser/web/popover.js +1 -0
- package/browser/web/preferences.js +1 -0
- package/browser/web/progress.js +1 -0
- package/browser/web/radio.js +1 -0
- package/browser/web/rating.js +1 -0
- package/browser/web/resizable.js +1 -0
- package/browser/web/scroll-area.js +1 -0
- package/browser/web/segmented-control.js +1 -0
- package/browser/web/select.js +1 -0
- package/browser/web/separator.js +1 -0
- package/browser/web/slider.js +1 -0
- package/browser/web/switch.js +1 -0
- package/browser/web/tabs.js +1 -0
- package/browser/web/textarea.js +1 -0
- package/browser/web/time-input.js +1 -0
- package/browser/web/timeline.js +1 -0
- package/browser/web/toast.js +1 -0
- package/browser/web/toggle.js +1 -0
- package/browser/web/token-input.js +8 -0
- package/browser/web/toolbar.js +1 -0
- package/browser/web/tooltip.js +1 -0
- package/browser/web/tree.js +1 -0
- package/browser/web/trigger-menu.js +4 -0
- package/browser/web/waterfall.js +1 -0
- package/browser/web.css +3378 -0
- package/browser/web.js +3 -0
- package/custom-elements.json +32315 -0
- package/dist/accordion.d.ts +2 -0
- package/dist/accordion.js +57 -0
- package/dist/action.d.ts +16 -0
- package/dist/action.js +39 -0
- package/dist/agent.d.ts +2 -0
- package/dist/agent.js +7 -0
- package/dist/autocomplete.d.ts +2 -0
- package/dist/autocomplete.js +120 -0
- package/dist/autoload.d.ts +18 -0
- package/dist/autoload.js +63 -0
- package/dist/avatar.d.ts +2 -0
- package/dist/avatar.js +27 -0
- package/dist/browser-core.d.ts +2 -0
- package/dist/browser-core.js +8 -0
- package/dist/button.d.ts +2 -0
- package/dist/button.js +35 -0
- package/dist/calendar.d.ts +23 -0
- package/dist/calendar.js +429 -0
- package/dist/carousel.d.ts +2 -0
- package/dist/carousel.js +54 -0
- package/dist/checkbox.d.ts +4 -0
- package/dist/checkbox.js +75 -0
- package/dist/collapsible.d.ts +2 -0
- package/dist/collapsible.js +28 -0
- package/dist/color-picker.d.ts +2 -0
- package/dist/color-picker.js +64 -0
- package/dist/combobox.d.ts +2 -0
- package/dist/combobox.js +334 -0
- package/dist/command.d.ts +2 -0
- package/dist/command.js +122 -0
- package/dist/date-input.d.ts +3 -0
- package/dist/date-input.js +87 -0
- package/dist/date-picker.d.ts +2 -0
- package/dist/date-picker.js +174 -0
- package/dist/default-text.d.ts +3 -0
- package/dist/default-text.js +24 -0
- package/dist/define-element.d.ts +404 -0
- package/dist/define-element.js +1489 -0
- package/dist/dialog.d.ts +3 -0
- package/dist/dialog.js +94 -0
- package/dist/drawer.d.ts +2 -0
- package/dist/drawer.js +96 -0
- package/dist/entries/accordion.d.ts +3 -0
- package/dist/entries/accordion.js +7 -0
- package/dist/entries/alert-dialog.d.ts +3 -0
- package/dist/entries/alert-dialog.js +13 -0
- package/dist/entries/autocomplete.d.ts +3 -0
- package/dist/entries/autocomplete.js +7 -0
- package/dist/entries/avatar.d.ts +2 -0
- package/dist/entries/avatar.js +3 -0
- package/dist/entries/button.d.ts +2 -0
- package/dist/entries/button.js +3 -0
- package/dist/entries/calendar.d.ts +3 -0
- package/dist/entries/calendar.js +7 -0
- package/dist/entries/carousel.d.ts +3 -0
- package/dist/entries/carousel.js +7 -0
- package/dist/entries/checkbox.d.ts +3 -0
- package/dist/entries/checkbox.js +15 -0
- package/dist/entries/collapsible.d.ts +3 -0
- package/dist/entries/collapsible.js +7 -0
- package/dist/entries/color-picker.d.ts +3 -0
- package/dist/entries/color-picker.js +7 -0
- package/dist/entries/combobox.d.ts +3 -0
- package/dist/entries/combobox.js +7 -0
- package/dist/entries/command.d.ts +3 -0
- package/dist/entries/command.js +7 -0
- package/dist/entries/date-input.d.ts +3 -0
- package/dist/entries/date-input.js +7 -0
- package/dist/entries/date-picker.d.ts +3 -0
- package/dist/entries/date-picker.js +7 -0
- package/dist/entries/dialog.d.ts +3 -0
- package/dist/entries/dialog.js +7 -0
- package/dist/entries/drawer.d.ts +3 -0
- package/dist/entries/drawer.js +8 -0
- package/dist/entries/field.d.ts +2 -0
- package/dist/entries/field.js +3 -0
- package/dist/entries/file-input.d.ts +3 -0
- package/dist/entries/file-input.js +13 -0
- package/dist/entries/hover-card.d.ts +3 -0
- package/dist/entries/hover-card.js +7 -0
- package/dist/entries/image-cropper.d.ts +3 -0
- package/dist/entries/image-cropper.js +7 -0
- package/dist/entries/input.d.ts +3 -0
- package/dist/entries/input.js +8 -0
- package/dist/entries/label.d.ts +2 -0
- package/dist/entries/label.js +3 -0
- package/dist/entries/listbox.d.ts +3 -0
- package/dist/entries/listbox.js +7 -0
- package/dist/entries/menu.d.ts +3 -0
- package/dist/entries/menu.js +7 -0
- package/dist/entries/menubar.d.ts +3 -0
- package/dist/entries/menubar.js +7 -0
- package/dist/entries/meter.d.ts +2 -0
- package/dist/entries/meter.js +3 -0
- package/dist/entries/navigation-menu.d.ts +3 -0
- package/dist/entries/navigation-menu.js +7 -0
- package/dist/entries/number-input.d.ts +3 -0
- package/dist/entries/number-input.js +7 -0
- package/dist/entries/otp-input.d.ts +3 -0
- package/dist/entries/otp-input.js +7 -0
- package/dist/entries/overlays.d.ts +2 -0
- package/dist/entries/overlays.js +3 -0
- package/dist/entries/pagination.d.ts +3 -0
- package/dist/entries/pagination.js +11 -0
- package/dist/entries/password-input.d.ts +3 -0
- package/dist/entries/password-input.js +7 -0
- package/dist/entries/popover.d.ts +3 -0
- package/dist/entries/popover.js +7 -0
- package/dist/entries/preferences.d.ts +3 -0
- package/dist/entries/preferences.js +13 -0
- package/dist/entries/progress.d.ts +2 -0
- package/dist/entries/progress.js +3 -0
- package/dist/entries/radio.d.ts +3 -0
- package/dist/entries/radio.js +7 -0
- package/dist/entries/rating.d.ts +3 -0
- package/dist/entries/rating.js +8 -0
- package/dist/entries/resizable.d.ts +3 -0
- package/dist/entries/resizable.js +11 -0
- package/dist/entries/scroll-area.d.ts +3 -0
- package/dist/entries/scroll-area.js +7 -0
- package/dist/entries/segmented-control.d.ts +3 -0
- package/dist/entries/segmented-control.js +7 -0
- package/dist/entries/select.d.ts +3 -0
- package/dist/entries/select.js +7 -0
- package/dist/entries/separator.d.ts +2 -0
- package/dist/entries/separator.js +3 -0
- package/dist/entries/slider.d.ts +3 -0
- package/dist/entries/slider.js +7 -0
- package/dist/entries/switch.d.ts +3 -0
- package/dist/entries/switch.js +7 -0
- package/dist/entries/tabs.d.ts +3 -0
- package/dist/entries/tabs.js +7 -0
- package/dist/entries/textarea.d.ts +3 -0
- package/dist/entries/textarea.js +7 -0
- package/dist/entries/time-input.d.ts +3 -0
- package/dist/entries/time-input.js +7 -0
- package/dist/entries/timeline.d.ts +3 -0
- package/dist/entries/timeline.js +7 -0
- package/dist/entries/toast.d.ts +2 -0
- package/dist/entries/toast.js +3 -0
- package/dist/entries/toggle.d.ts +3 -0
- package/dist/entries/toggle.js +12 -0
- package/dist/entries/token-input.d.ts +3 -0
- package/dist/entries/token-input.js +17 -0
- package/dist/entries/toolbar.d.ts +3 -0
- package/dist/entries/toolbar.js +7 -0
- package/dist/entries/tooltip.d.ts +3 -0
- package/dist/entries/tooltip.js +7 -0
- package/dist/entries/tree.d.ts +3 -0
- package/dist/entries/tree.js +17 -0
- package/dist/entries/trigger-menu.d.ts +3 -0
- package/dist/entries/trigger-menu.js +11 -0
- package/dist/entries/waterfall.d.ts +3 -0
- package/dist/entries/waterfall.js +11 -0
- package/dist/events.d.ts +1658 -0
- package/dist/events.js +0 -0
- package/dist/field.d.ts +2 -0
- package/dist/field.js +101 -0
- package/dist/file-input.d.ts +2 -0
- package/dist/file-input.js +140 -0
- package/dist/forward-attributes.d.ts +2 -0
- package/dist/forward-attributes.js +22 -0
- package/dist/history.d.ts +2 -0
- package/dist/history.js +11 -0
- package/dist/hover-card.d.ts +2 -0
- package/dist/hover-card.js +31 -0
- package/dist/image-cropper.d.ts +2 -0
- package/dist/image-cropper.js +66 -0
- package/dist/index.d.ts +66 -0
- package/dist/index.js +269 -0
- package/dist/input.d.ts +3 -0
- package/dist/input.js +69 -0
- package/dist/label.d.ts +2 -0
- package/dist/label.js +11 -0
- package/dist/list.d.ts +40 -0
- package/dist/list.js +192 -0
- package/dist/listbox.d.ts +2 -0
- package/dist/listbox.js +84 -0
- package/dist/menu.d.ts +4 -0
- package/dist/menu.js +295 -0
- package/dist/menubar.d.ts +4 -0
- package/dist/menubar.js +30 -0
- package/dist/meter.d.ts +2 -0
- package/dist/meter.js +22 -0
- package/dist/navigation-menu.d.ts +2 -0
- package/dist/navigation-menu.js +114 -0
- package/dist/number-input.d.ts +2 -0
- package/dist/number-input.js +73 -0
- package/dist/observe.d.ts +2 -0
- package/dist/observe.js +7 -0
- package/dist/otp-input.d.ts +2 -0
- package/dist/otp-input.js +72 -0
- package/dist/overlays.d.ts +13 -0
- package/dist/overlays.js +156 -0
- package/dist/pagination.d.ts +2 -0
- package/dist/pagination.js +127 -0
- package/dist/password-input.d.ts +2 -0
- package/dist/password-input.js +57 -0
- package/dist/popover.d.ts +2 -0
- package/dist/popover.js +64 -0
- package/dist/popup.d.ts +40 -0
- package/dist/popup.js +112 -0
- package/dist/preferences.d.ts +2 -0
- package/dist/preferences.js +56 -0
- package/dist/progress.d.ts +2 -0
- package/dist/progress.js +22 -0
- package/dist/radio.d.ts +2 -0
- package/dist/radio.js +33 -0
- package/dist/rating.d.ts +2 -0
- package/dist/rating.js +64 -0
- package/dist/resizable.d.ts +2 -0
- package/dist/resizable.js +42 -0
- package/dist/scroll-area.d.ts +2 -0
- package/dist/scroll-area.js +45 -0
- package/dist/segmented-control.d.ts +2 -0
- package/dist/segmented-control.js +28 -0
- package/dist/select.d.ts +2 -0
- package/dist/select.js +239 -0
- package/dist/separator.d.ts +2 -0
- package/dist/separator.js +11 -0
- package/dist/slider.d.ts +2 -0
- package/dist/slider.js +77 -0
- package/dist/tabs.d.ts +2 -0
- package/dist/tabs.js +37 -0
- package/dist/timeline.d.ts +2 -0
- package/dist/timeline.js +27 -0
- package/dist/toast.d.ts +20 -0
- package/dist/toast.js +177 -0
- package/dist/toggle.d.ts +3 -0
- package/dist/toggle.js +64 -0
- package/dist/token-input.d.ts +2 -0
- package/dist/token-input.js +103 -0
- package/dist/toolbar.d.ts +2 -0
- package/dist/toolbar.js +36 -0
- package/dist/tooltip.d.ts +2 -0
- package/dist/tooltip.js +35 -0
- package/dist/tree.d.ts +2 -0
- package/dist/tree.js +147 -0
- package/dist/trigger-menu.d.ts +2 -0
- package/dist/trigger-menu.js +133 -0
- package/dist/waterfall.d.ts +2 -0
- package/dist/waterfall.js +140 -0
- package/docs/README.md +89 -0
- package/docs/agents.md +1523 -0
- package/docs/components/accordion.md +1401 -0
- package/docs/components/alert-dialog.md +788 -0
- package/docs/components/autocomplete.md +1692 -0
- package/docs/components/avatar.md +261 -0
- package/docs/components/button.md +441 -0
- package/docs/components/calendar.md +1536 -0
- package/docs/components/carousel.md +1055 -0
- package/docs/components/checkbox.md +1045 -0
- package/docs/components/collapsible.md +535 -0
- package/docs/components/color-picker.md +651 -0
- package/docs/components/combobox.md +3274 -0
- package/docs/components/command.md +1431 -0
- package/docs/components/date-input.md +563 -0
- package/docs/components/date-picker.md +1136 -0
- package/docs/components/dialog.md +1360 -0
- package/docs/components/drawer.md +1201 -0
- package/docs/components/field.md +519 -0
- package/docs/components/file-input.md +617 -0
- package/docs/components/hover-card.md +486 -0
- package/docs/components/image-cropper.md +489 -0
- package/docs/components/input.md +327 -0
- package/docs/components/label.md +208 -0
- package/docs/components/listbox.md +1015 -0
- package/docs/components/menu.md +1212 -0
- package/docs/components/menubar.md +460 -0
- package/docs/components/meter.md +298 -0
- package/docs/components/navigation-menu.md +1573 -0
- package/docs/components/number-input.md +1087 -0
- package/docs/components/otp-input.md +558 -0
- package/docs/components/pagination.md +639 -0
- package/docs/components/password-input.md +649 -0
- package/docs/components/popover.md +1433 -0
- package/docs/components/preferences.md +243 -0
- package/docs/components/progress.md +406 -0
- package/docs/components/radio.md +855 -0
- package/docs/components/rating.md +431 -0
- package/docs/components/resizable.md +866 -0
- package/docs/components/scroll-area.md +898 -0
- package/docs/components/segmented-control.md +421 -0
- package/docs/components/select.md +1957 -0
- package/docs/components/separator.md +238 -0
- package/docs/components/slider.md +1018 -0
- package/docs/components/switch.md +583 -0
- package/docs/components/tabs.md +948 -0
- package/docs/components/textarea.md +331 -0
- package/docs/components/time-input.md +235 -0
- package/docs/components/timeline.md +622 -0
- package/docs/components/toast.md +1223 -0
- package/docs/components/toggle.md +522 -0
- package/docs/components/token-input.md +854 -0
- package/docs/components/toolbar.md +815 -0
- package/docs/components/tooltip.md +860 -0
- package/docs/components/tree.md +1243 -0
- package/docs/components/trigger-menu.md +1110 -0
- package/docs/components/waterfall.md +709 -0
- package/docs/controllers.md +66 -0
- package/docs/core.md +8027 -0
- package/docs/custom-parts.md +91 -0
- package/docs/first-component.md +88 -0
- package/docs/forms.md +125 -0
- package/docs/installation.md +141 -0
- package/docs/introduction.md +32 -0
- package/docs/lists-and-menus.md +166 -0
- package/docs/llms.txt +1566 -0
- package/docs/parts-and-composition.md +57 -0
- package/docs/popups.md +92 -0
- package/docs/rendering.md +71 -0
- package/docs/server-rendering.md +118 -0
- package/docs/state-and-events.md +134 -0
- package/docs/styling-and-animation.md +104 -0
- package/docs/utilities/async-options.md +332 -0
- package/docs/utilities/shortcuts.md +184 -0
- package/html-custom-data.json +14792 -0
- package/package.json +302 -3
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
# Textarea
|
|
2
|
+
|
|
3
|
+
Enter multiple lines of text, grow the field as you type, and connect it to a form.
|
|
4
|
+
|
|
5
|
+
A textarea is a native multi-line text field for messages, notes and descriptions. It works inside a field and a form, can grow with its text, and reports the same change reasons as Input.
|
|
6
|
+
|
|
7
|
+
```ts title="basic.ts"
|
|
8
|
+
import "@ui-sdk/web/field"
|
|
9
|
+
import "@ui-sdk/web/textarea"
|
|
10
|
+
|
|
11
|
+
function mount(root: HTMLElement) {
|
|
12
|
+
root.innerHTML = `
|
|
13
|
+
<ui-field name="message">
|
|
14
|
+
<ui-field-label>Message</ui-field-label>
|
|
15
|
+
<ui-textarea>
|
|
16
|
+
<textarea placeholder="Type your message here…"></textarea>
|
|
17
|
+
</ui-textarea>
|
|
18
|
+
</ui-field>
|
|
19
|
+
`
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { mount }
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Click Message to focus the textarea, then type. Press Enter to start a new line.
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install @ui-sdk/web @ui-sdk/core
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Importing the component defines its element. Import the field too if you use it. On the server the import does nothing.
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import "@ui-sdk/web/textarea"
|
|
37
|
+
import "@ui-sdk/web/field"
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Usage
|
|
41
|
+
|
|
42
|
+
`ui-textarea` wraps your own `<textarea>`. Put `rows`, `placeholder`, `maxlength` and other native attributes on the `<textarea>`.
|
|
43
|
+
|
|
44
|
+
```html
|
|
45
|
+
<script type="module">
|
|
46
|
+
import "@ui-sdk/web/textarea"
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<ui-textarea>
|
|
50
|
+
<textarea
|
|
51
|
+
aria-label="Message"
|
|
52
|
+
placeholder="Type your message here…"
|
|
53
|
+
></textarea>
|
|
54
|
+
</ui-textarea>
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Field
|
|
58
|
+
|
|
59
|
+
Wrap the textarea in a [Field](./field.md) to give it a visible label and a description. The field also supplies its `name` when the textarea has none.
|
|
60
|
+
|
|
61
|
+
```ts title="field.ts"
|
|
62
|
+
import "@ui-sdk/web/field"
|
|
63
|
+
import "@ui-sdk/web/textarea"
|
|
64
|
+
|
|
65
|
+
function mount(root: HTMLElement) {
|
|
66
|
+
root.innerHTML = `
|
|
67
|
+
<ui-field name="feedback">
|
|
68
|
+
<ui-field-label>Feedback</ui-field-label>
|
|
69
|
+
<ui-textarea>
|
|
70
|
+
<textarea placeholder="What could we do better?"></textarea>
|
|
71
|
+
</ui-textarea>
|
|
72
|
+
<ui-field-description>Only the product team can see this.</ui-field-description>
|
|
73
|
+
</ui-field>
|
|
74
|
+
`
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export { mount }
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Click Feedback to focus the textarea. A screen reader reads the description with the field.
|
|
81
|
+
|
|
82
|
+
## Auto Resize
|
|
83
|
+
|
|
84
|
+
Set `auto-resize` to grow and shrink the textarea with its text. CSS `min-height` and `max-height` set its limits; past the maximum, the text scrolls inside it.
|
|
85
|
+
|
|
86
|
+
```ts title="auto-resize.ts"
|
|
87
|
+
import "@ui-sdk/web/field"
|
|
88
|
+
import "@ui-sdk/web/textarea"
|
|
89
|
+
|
|
90
|
+
function mount(root: HTMLElement) {
|
|
91
|
+
root.innerHTML = `
|
|
92
|
+
<ui-field name="notes">
|
|
93
|
+
<ui-field-label>Notes</ui-field-label>
|
|
94
|
+
<ui-textarea auto-resize>
|
|
95
|
+
<textarea placeholder="Add notes for the delivery driver…"></textarea>
|
|
96
|
+
</ui-textarea>
|
|
97
|
+
<ui-field-description>Your driver sees these notes.</ui-field-description>
|
|
98
|
+
</ui-field>
|
|
99
|
+
`
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export { mount }
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Type several lines in Notes. The textarea grows with each line until it reaches its maximum height, then scrolls. Delete the lines and it shrinks back.
|
|
106
|
+
|
|
107
|
+
Browsers that support `field-sizing: content` size it natively. Elsewhere, the component measures it when the value changes, the form resets or its width changes.
|
|
108
|
+
|
|
109
|
+
## Controlled
|
|
110
|
+
|
|
111
|
+
Listen for `valuechange` to read the value, and set the element's `value` property to change it from your app. Here the character count is derived from that value, and the native `maxlength` caps the text.
|
|
112
|
+
|
|
113
|
+
```ts title="controlled.ts"
|
|
114
|
+
import "@ui-sdk/web/field"
|
|
115
|
+
import "@ui-sdk/web/textarea"
|
|
116
|
+
|
|
117
|
+
function mount(root: HTMLElement) {
|
|
118
|
+
root.innerHTML = `
|
|
119
|
+
<ui-field name="bio">
|
|
120
|
+
<ui-field-label>Bio</ui-field-label>
|
|
121
|
+
<ui-textarea>
|
|
122
|
+
<textarea maxlength="160">Product designer in Lisbon. I write about type and interfaces.</textarea>
|
|
123
|
+
</ui-textarea>
|
|
124
|
+
<ui-field-description>62 / 160 characters</ui-field-description>
|
|
125
|
+
</ui-field>
|
|
126
|
+
`
|
|
127
|
+
const count = root.querySelector("ui-field-description")!
|
|
128
|
+
root
|
|
129
|
+
.querySelector("ui-textarea")!
|
|
130
|
+
.addEventListener("valuechange", (event) => {
|
|
131
|
+
count.textContent = `${event.detail.value.length} / 160 characters`
|
|
132
|
+
})
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export { mount }
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Edit Bio and watch the character count under it. The textarea stops accepting text at 160 characters.
|
|
139
|
+
|
|
140
|
+
Textarea shares Input's [change reasons](#reasons) and cancellation behavior. See [State and Events](../state-and-events.md) for the shared conventions.
|
|
141
|
+
|
|
142
|
+
## Form
|
|
143
|
+
|
|
144
|
+
A textarea submits its value through a native form under its field's `name`. Use the element's `api` to change it from outside, here to empty it after sending. The native `required` constraint blocks an empty message.
|
|
145
|
+
|
|
146
|
+
```ts title="button.ts"
|
|
147
|
+
import "@ui-sdk/web/field"
|
|
148
|
+
import "@ui-sdk/web/textarea"
|
|
149
|
+
import { log } from "./log"
|
|
150
|
+
|
|
151
|
+
function mount(root: HTMLElement) {
|
|
152
|
+
root.innerHTML = `
|
|
153
|
+
<form data-slot="stack">
|
|
154
|
+
<ui-field name="message">
|
|
155
|
+
<ui-field-label>Message</ui-field-label>
|
|
156
|
+
<ui-textarea>
|
|
157
|
+
<textarea required placeholder="Write a reply to Hollis Grant…"></textarea>
|
|
158
|
+
</ui-textarea>
|
|
159
|
+
</ui-field>
|
|
160
|
+
<div data-slot="row">
|
|
161
|
+
<button type="submit" data-variant="solid">Send Message</button>
|
|
162
|
+
</div>
|
|
163
|
+
</form>
|
|
164
|
+
`
|
|
165
|
+
const form = root.querySelector("form")!
|
|
166
|
+
const message = root.querySelector("ui-textarea")!
|
|
167
|
+
form.addEventListener("submit", (event) => {
|
|
168
|
+
event.preventDefault()
|
|
169
|
+
log(root, `Sent “${new FormData(form).get("message")}”`)
|
|
170
|
+
message.api.clear()
|
|
171
|
+
})
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export { mount }
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
Type a message and press Send Message. The console logs it and the textarea clears. Pressing Send Message while it's empty is blocked.
|
|
178
|
+
|
|
179
|
+
[Controllers](../controllers.md) covers creating and sharing a controller.
|
|
180
|
+
|
|
181
|
+
## Disabled
|
|
182
|
+
|
|
183
|
+
Set `disabled` on the native textarea or its field to prevent editing and leave it out of the tab order and the submitted values.
|
|
184
|
+
|
|
185
|
+
```ts title="disabled.ts"
|
|
186
|
+
import "@ui-sdk/web/field"
|
|
187
|
+
import "@ui-sdk/web/textarea"
|
|
188
|
+
|
|
189
|
+
function mount(root: HTMLElement) {
|
|
190
|
+
root.innerHTML = `
|
|
191
|
+
<ui-field disabled>
|
|
192
|
+
<ui-field-label>Reply</ui-field-label>
|
|
193
|
+
<ui-textarea>
|
|
194
|
+
<textarea>Replies are closed for this thread.</textarea>
|
|
195
|
+
</ui-textarea>
|
|
196
|
+
</ui-field>
|
|
197
|
+
`
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export { mount }
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Try to edit Reply or reach it with Tab. The disabled textarea keeps its value but can't be changed.
|
|
204
|
+
|
|
205
|
+
## Invalid
|
|
206
|
+
|
|
207
|
+
Set `invalid` on the field for an error your app decides. The field shows its error, associates it with the textarea and sets `aria-invalid`. [Field](./field.md#validation) covers native constraints and error matches.
|
|
208
|
+
|
|
209
|
+
```ts title="invalid.ts"
|
|
210
|
+
import "@ui-sdk/web/field"
|
|
211
|
+
import "@ui-sdk/web/textarea"
|
|
212
|
+
|
|
213
|
+
function mount(root: HTMLElement) {
|
|
214
|
+
root.innerHTML = `
|
|
215
|
+
<ui-field invalid>
|
|
216
|
+
<ui-field-label>Review</ui-field-label>
|
|
217
|
+
<ui-textarea>
|
|
218
|
+
<textarea>Great.</textarea>
|
|
219
|
+
</ui-textarea>
|
|
220
|
+
<ui-field-error match>Write at least 20 characters.</ui-field-error>
|
|
221
|
+
</ui-field>
|
|
222
|
+
`
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export { mount }
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
Focus Review. The textarea is marked invalid, and the error below says how long the review should be.
|
|
229
|
+
|
|
230
|
+
## Submit Shortcut
|
|
231
|
+
|
|
232
|
+
Set `submit-shortcut` to submit the textarea's form from the keyboard. With `"mod+enter"`, Enter still starts a new line and Command or Control+Enter submits. With `"enter"`, Enter submits and Shift+Enter starts a new line. Without it, Enter always starts a new line, and neither submits while an input method is composing.
|
|
233
|
+
|
|
234
|
+
```html
|
|
235
|
+
<script type="module">
|
|
236
|
+
import "@ui-sdk/web/textarea"
|
|
237
|
+
</script>
|
|
238
|
+
|
|
239
|
+
<form action="/messages" method="post">
|
|
240
|
+
<ui-textarea submit-shortcut="mod+enter">
|
|
241
|
+
<textarea name="message" aria-label="Message" required></textarea>
|
|
242
|
+
</ui-textarea>
|
|
243
|
+
<button type="submit">Send</button>
|
|
244
|
+
</form>
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
The shortcut submits the form like the Send button, so `required` and the form's `submit` event still apply.
|
|
248
|
+
|
|
249
|
+
## Styling
|
|
250
|
+
|
|
251
|
+
Style the native textarea directly, with `data-filled`, `data-disabled`, `data-readonly` and `data-required` for its states. Inside a field it also receives the field's validation attributes, such as `data-invalid`. For `auto-resize`, set `min-height` and `max-height` to bound its growth. Use logical spacing so the text follows the surrounding direction.
|
|
252
|
+
|
|
253
|
+
The textarea has a `data-slot` of `textarea`, and its state attributes are listed under [Data Attributes](#data-attributes).
|
|
254
|
+
|
|
255
|
+
## Data Attributes
|
|
256
|
+
|
|
257
|
+
### `<ui-textarea>`
|
|
258
|
+
`[data-slot="textarea"]`
|
|
259
|
+
|
|
260
|
+
- `data-filled`: Present while the field holds any text.
|
|
261
|
+
- `data-disabled`: Present when the field is disabled, by its own prop or its Field.
|
|
262
|
+
- `data-readonly`: Present when the field is read-only.
|
|
263
|
+
- `data-required`: Present when the field is required.
|
|
264
|
+
|
|
265
|
+
## API Reference
|
|
266
|
+
|
|
267
|
+
Props are attributes in kebab case, like `auto-resize` and `default-value`. `disabled`, `readonly`, `required` and other native attributes are read from the `<textarea>`. Callbacks are DOM events: `valuechange` fires on `ui-textarea` with `{ value, reason, event, source }` in `event.detail`.
|
|
268
|
+
|
|
269
|
+
### Textarea
|
|
270
|
+
|
|
271
|
+
- `value?` (`string`): The value, for a controlled field.
|
|
272
|
+
- `defaultValue?` (`string`): The value it starts with. A form reset returns here.
|
|
273
|
+
- `valuechange event`: Called when the user changes the value: typing (`"input-change"`), a Clear part (`"clear-press"`), a form reset (`"reset"`) or a controller (`"imperative"`). `details.cancel()` keeps the value as it was.
|
|
274
|
+
- `controller?` (`object`): Reads and writes the field from anywhere. Create one with `createInputController()`.
|
|
275
|
+
- `debug?` (`boolean`): Logs every state change with its reason to the console, in development builds.
|
|
276
|
+
- `autoResize?` (`boolean`): Grows and shrinks with the text. Bound it with CSS `min-height` and `max-height`; past the maximum, it scrolls.
|
|
277
|
+
- `submit event`: Runs on the submit shortcut, unless an input method is composing. Without it, the shortcut submits the form the textarea is in. With neither, the key is left alone, so Enter adds a line.
|
|
278
|
+
- `submitShortcut?` (`"enter" | "mod+enter"`): Which keys submit: `"enter"`, with Shift+Enter for a new line, or `"mod+enter"`, with Enter for a new line. Without it, Enter always starts a new line.
|
|
279
|
+
|
|
280
|
+
- `disabled?` (`boolean`): Disables the field.
|
|
281
|
+
- `readOnly?` (`boolean`): Makes the field read-only.
|
|
282
|
+
- `required?` (`boolean`): Makes the field required.
|
|
283
|
+
|
|
284
|
+
### State
|
|
285
|
+
|
|
286
|
+
- `filled` (`boolean`): Whether the field holds any text.
|
|
287
|
+
- `disabled` (`boolean`): Whether the field is disabled.
|
|
288
|
+
- `readOnly` (`boolean`): Whether the field is read-only.
|
|
289
|
+
- `required` (`boolean`): Whether the field is required.
|
|
290
|
+
|
|
291
|
+
### Reasons
|
|
292
|
+
|
|
293
|
+
- `input-change` (`Event`): Typing, pasting or dropping changed a text field's value; in a combobox it can also open or close it, or Enter keeps the typed text as the value.
|
|
294
|
+
- `clear-press` (`MouseEvent | KeyboardEvent`): A Clear part was pressed, like on an input, a select or a combobox.
|
|
295
|
+
- `reset` (`none`): A form reset.
|
|
296
|
+
- `imperative` (`none`): A controller or `api` call, or a property set on a web component.
|
|
297
|
+
|
|
298
|
+
### Controller
|
|
299
|
+
|
|
300
|
+
The element's `api` property has these methods, and its `value` property reads and sets the text. Writes fire `valuechange` like typing.
|
|
301
|
+
|
|
302
|
+
- `getValue()` (`() => string`): The current value.
|
|
303
|
+
- `setValue(value, options?)` (`(value: string, options?: ChangeOptions<InputValueChangeReason> | undefined) => boolean`): Sets the value as if the user typed it, so `input` fires. Returns false when the change was canceled or nothing changed.
|
|
304
|
+
- `clear(options?)` (`(options?: ChangeOptions<InputValueChangeReason> | undefined) => boolean`): Empties the field, as if the user deleted the text, so `input` fires. Returns false when the change was canceled or nothing changed.
|
|
305
|
+
- `focus()` (`() => void`): Moves focus to the field.
|
|
306
|
+
|
|
307
|
+
## Accessibility
|
|
308
|
+
|
|
309
|
+
There's no WAI-ARIA pattern for a multi-line text field. The textarea stays a native `<textarea>`, with standard text editing, selection, spell checking and form behavior. Give it a visible field label or an `aria-label`, and keep descriptions and errors in their field parts so they're associated with it.
|
|
310
|
+
|
|
311
|
+
### Tested Behavior
|
|
312
|
+
|
|
313
|
+
Every line below is an automated test.
|
|
314
|
+
|
|
315
|
+
- The label names the textarea and the description describes it.
|
|
316
|
+
|
|
317
|
+
**Auto resize**
|
|
318
|
+
|
|
319
|
+
- Grows with its text and shrinks back.
|
|
320
|
+
- Stops at its max height and scrolls.
|
|
321
|
+
- Shrinks back when a reset empties it.
|
|
322
|
+
- Follows text written from code.
|
|
323
|
+
|
|
324
|
+
**Submit shortcut**
|
|
325
|
+
|
|
326
|
+
- Without a submit shortcut, Enter starts a new line and doesn't submit.
|
|
327
|
+
- With enter, Enter submits the form and Shift+Enter starts a new line.
|
|
328
|
+
- With mod+enter, Enter starts a new line and Cmd or Ctrl+Enter submits.
|
|
329
|
+
- Enter while an input method composes doesn't submit.
|
|
330
|
+
|
|
331
|
+
Runs in React, Vue and web components.
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
# Time Input
|
|
2
|
+
|
|
3
|
+
Type a time one part at a time, on the clock your user's language uses.
|
|
4
|
+
|
|
5
|
+
Use a Time Input for a time of day, like a meeting or an opening hour. It works like [Date Input](./date-input.md), with segments for the hour, the minute and, on a 12-hour clock, AM or PM.
|
|
6
|
+
|
|
7
|
+
```ts title="time.ts"
|
|
8
|
+
import "@ui-sdk/web/field"
|
|
9
|
+
import "@ui-sdk/web/time-input"
|
|
10
|
+
|
|
11
|
+
function mount(root: HTMLElement) {
|
|
12
|
+
root.innerHTML = `
|
|
13
|
+
<ui-field>
|
|
14
|
+
<ui-field-label>Meeting time</ui-field-label>
|
|
15
|
+
<ui-time-input default-value="09:30"></ui-time-input>
|
|
16
|
+
</ui-field>
|
|
17
|
+
`
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { mount }
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Click the hour and type 230, then P. Press ArrowUp or ArrowDown on a part to step it.
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install @ui-sdk/web @ui-sdk/core
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Importing the component defines its elements. Import the field too if you use it. On the server the import does nothing.
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
import "@ui-sdk/web/time-input"
|
|
35
|
+
import "@ui-sdk/web/field"
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Composition
|
|
39
|
+
|
|
40
|
+
Use the following composition to build a `ui-time-input`:
|
|
41
|
+
|
|
42
|
+
```text
|
|
43
|
+
ui-time-input
|
|
44
|
+
├── ui-time-input-segment
|
|
45
|
+
│ └── input
|
|
46
|
+
└── ui-time-input-segment
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
`<ui-time-input>` renders a group with one `<ui-time-input-segment>` for each part of the time, and the text between them.
|
|
50
|
+
|
|
51
|
+
## Usage
|
|
52
|
+
|
|
53
|
+
Put the input in a [Field](./field.md) and give it a label:
|
|
54
|
+
|
|
55
|
+
```html
|
|
56
|
+
<script type="module">
|
|
57
|
+
import "@ui-sdk/web/time-input"
|
|
58
|
+
import "@ui-sdk/web/field"
|
|
59
|
+
</script>
|
|
60
|
+
|
|
61
|
+
<ui-field>
|
|
62
|
+
<ui-field-label>Meeting time</ui-field-label>
|
|
63
|
+
<ui-time-input default-value="09:30"></ui-time-input>
|
|
64
|
+
</ui-field>
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
The value is a 24-hour time like `"14:30"`, the same as a native time input's, whatever clock the input shows. Typing, stepping and pasting work as they do in [Date Input](./date-input.md#usage).
|
|
68
|
+
|
|
69
|
+
## Clock and Seconds
|
|
70
|
+
|
|
71
|
+
The input shows the locale's clock. Set `hour-cycle` to `12` or `24` to choose one, and `granularity` to `"second"` to add seconds, or `"hour"` to show the hour alone.
|
|
72
|
+
|
|
73
|
+
```ts title="hour-cycle.ts"
|
|
74
|
+
import "@ui-sdk/web/field"
|
|
75
|
+
import "@ui-sdk/web/time-input"
|
|
76
|
+
|
|
77
|
+
function mount(root: HTMLElement) {
|
|
78
|
+
root.innerHTML = `
|
|
79
|
+
<div data-slot="stack">
|
|
80
|
+
<ui-field>
|
|
81
|
+
<ui-field-label>12-hour clock</ui-field-label>
|
|
82
|
+
<ui-time-input hour-cycle="12" default-value="18:45"></ui-time-input>
|
|
83
|
+
</ui-field>
|
|
84
|
+
<ui-field>
|
|
85
|
+
<ui-field-label>24-hour clock</ui-field-label>
|
|
86
|
+
<ui-time-input hour-cycle="24" default-value="18:45"></ui-time-input>
|
|
87
|
+
</ui-field>
|
|
88
|
+
<ui-field>
|
|
89
|
+
<ui-field-label>With seconds</ui-field-label>
|
|
90
|
+
<ui-time-input granularity="second" hour-cycle="24" default-value="18:45:30"></ui-time-input>
|
|
91
|
+
</ui-field>
|
|
92
|
+
</div>
|
|
93
|
+
`
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export { mount }
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
The same evening time on a 12-hour clock, a 24-hour clock and with seconds. All three submit 24-hour values.
|
|
100
|
+
|
|
101
|
+
## Min and Max
|
|
102
|
+
|
|
103
|
+
`min` and `max` take times like `"09:00"`. A time outside them is invalid: the input sets `data-invalid`, and its form won't submit.
|
|
104
|
+
|
|
105
|
+
## Form
|
|
106
|
+
|
|
107
|
+
The element is form-associated and submits the time under `name`, with no hidden input. Set `required` to need a time before the form submits, and `form` to the id of a form elsewhere in the page to submit with it. The [Date Input form example](./date-input.md#form) has a time in it.
|
|
108
|
+
|
|
109
|
+
## Controlled and Controller
|
|
110
|
+
|
|
111
|
+
Listen for `valuechange` and set the `value` property, or drive the input with its `api`, as in [Date Input](./date-input.md#controlled).
|
|
112
|
+
|
|
113
|
+
## Styling
|
|
114
|
+
|
|
115
|
+
Style it like [Date Input](./date-input.md#styling). The AM/PM segment sets `data-type="dayPeriod"`.
|
|
116
|
+
|
|
117
|
+
Each part has a `data-slot`, such as `time-input-segment`, and its state attributes are listed under [Data Attributes](#data-attributes).
|
|
118
|
+
|
|
119
|
+
## Data Attributes
|
|
120
|
+
|
|
121
|
+
### `<ui-time-input>`
|
|
122
|
+
`[data-slot="time-input"]`
|
|
123
|
+
|
|
124
|
+
- `data-disabled`: Present when disabled, by its own prop or a `<fieldset>`.
|
|
125
|
+
- `data-readonly`: Present when read-only.
|
|
126
|
+
- `data-required`: Present when required.
|
|
127
|
+
- `data-invalid`: Present while the time is before `min` or after `max`.
|
|
128
|
+
- `data-empty`: Present while every segment is empty.
|
|
129
|
+
|
|
130
|
+
### `<ui-time-input-segment>`
|
|
131
|
+
`[data-slot="time-input-segment"]`
|
|
132
|
+
|
|
133
|
+
- `data-type` (`hour`, `minute`, `second`, `dayPeriod`, `literal`): The segment's unit, or `literal` for the text between segments.
|
|
134
|
+
- `data-disabled`: Present when disabled, by its own prop or a `<fieldset>`.
|
|
135
|
+
- `data-readonly`: Present when read-only.
|
|
136
|
+
- `data-required`: Present when required.
|
|
137
|
+
- `data-invalid`: Present while the time is before `min` or after `max`.
|
|
138
|
+
- `data-empty`: Present while the segment is empty. It shows its placeholder.
|
|
139
|
+
|
|
140
|
+
## API Reference
|
|
141
|
+
|
|
142
|
+
Props are attributes in kebab case, like `default-value`, `hour-cycle` and `read-only`. `value` is also a property, and `controller` is a property. Callbacks are DOM events.
|
|
143
|
+
|
|
144
|
+
### TimeInput
|
|
145
|
+
|
|
146
|
+
- `value?` (`string | null`): The value: a time like `"14:30"`, or `"14:30:15"` with seconds, or `null`. Pass it to control the input.
|
|
147
|
+
- `defaultValue?` (`string | null`): The value it starts with, when uncontrolled, and goes back to when its form resets.
|
|
148
|
+
- `valuechange event`: Runs when the value wants to change: once every segment holds something, and again with `null` when one is emptied. `details.cancel()` keeps the value.
|
|
149
|
+
- `granularity?` (`TimeInputGranularity`): The smallest unit it shows.
|
|
150
|
+
- `hourCycle?` (`HourCycle`): A 12 or 24 hour clock. Defaults to the locale's.
|
|
151
|
+
- `min?` (`string`): The earliest time, like `"09:00"`. A time before it is invalid.
|
|
152
|
+
- `max?` (`string`): The latest time, like `"17:30"`. A time after it is invalid.
|
|
153
|
+
- `locale?` (`string`): The language whose separators and clock it shows. Defaults to the page's.
|
|
154
|
+
- `disabled?` (`boolean`): Whether it can't be used.
|
|
155
|
+
- `readOnly?` (`boolean`): Whether the value can be seen but not changed.
|
|
156
|
+
- `required?` (`boolean`): Whether a time must be entered before its form submits.
|
|
157
|
+
- `name?` (`string`): The name the value submits under.
|
|
158
|
+
- `form?` (`string`): The id of the form it belongs to, when it isn't inside it.
|
|
159
|
+
- `controller?` (`object`): Drives it from anywhere. Create one with `createTimeInputController()`.
|
|
160
|
+
- `debug?` (`boolean`): Logs every state change with its reason to the console, in development builds.
|
|
161
|
+
|
|
162
|
+
### State
|
|
163
|
+
|
|
164
|
+
- `value` (`string | null`): The value, or `null` while empty or partly filled.
|
|
165
|
+
- `segments` (`DateInputSegmentData[]`): The segments in the order the locale shows them, with the text between them. Render one part for each.
|
|
166
|
+
- `disabled` (`boolean`): Whether it can't be used, by itself or by a `<fieldset>`.
|
|
167
|
+
- `readOnly` (`boolean`): Whether the value can be seen but not changed.
|
|
168
|
+
- `invalid` (`boolean`): Whether the value is before `min`, after `max` or an unavailable date.
|
|
169
|
+
|
|
170
|
+
### Reasons
|
|
171
|
+
|
|
172
|
+
- `input-change` (`Event`): Typing, pasting or dropping changed a text field's value; in a combobox it can also open or close it, or Enter keeps the typed text as the value.
|
|
173
|
+
- `step-key` (`KeyboardEvent`): Arrow, Page Up, Page Down, Home or End stepped a slider or a number input.
|
|
174
|
+
- `paste` (`ClipboardEvent`): Files were pasted, like a screenshot, or text and tokens into a token input.
|
|
175
|
+
- `reset` (`none`): A form reset.
|
|
176
|
+
- `restore` (`none`): The browser restored state, like after going back, or a saved value was read back from storage.
|
|
177
|
+
- `imperative` (`none`): A controller or `api` call, or a property set on a web component.
|
|
178
|
+
|
|
179
|
+
### Controller
|
|
180
|
+
|
|
181
|
+
- `getValue()` (`() => string | null`): The value, or `null` while empty or partly filled.
|
|
182
|
+
- `setValue(value, options?)` (`(value: string | null, options?: DateInputChangeOptions | undefined) => boolean`): Sets the value. Returns false when it isn't a value the input can show, or when canceled.
|
|
183
|
+
- `clear(options?)` (`(options?: DateInputChangeOptions | undefined) => boolean`): Empties every segment.
|
|
184
|
+
- `focus(segment?)` (`(segment?: string | undefined) => void`): Focuses a segment, like `"month"`, or the first one.
|
|
185
|
+
|
|
186
|
+
### Events
|
|
187
|
+
|
|
188
|
+
Events fire on their own element and don't bubble, with the value in `event.detail.value` and the `reason` and `event` beside it. Calling `preventDefault()` on `valuechange` cancels the change.
|
|
189
|
+
|
|
190
|
+
| Member | On | Description |
|
|
191
|
+
| ------------------- | ----------------- | ----------------------------------------------------------------------- |
|
|
192
|
+
| `value` property | `<ui-time-input>` | The time, or null while empty or partly typed |
|
|
193
|
+
| `api` property | `<ui-time-input>` | The [controller](#controller) |
|
|
194
|
+
| `valuechange` event | `<ui-time-input>` | `detail: { value, reason, event }`, as a whole value forms or is erased |
|
|
195
|
+
|
|
196
|
+
## Accessibility
|
|
197
|
+
|
|
198
|
+
The root is a group, named by its Field's label or by your `aria-label`. Each segment is a spinbutton named by its unit, like "hour" or "AM/PM", with its value, range and text. The keys are the same as in [Date Input](./date-input.md#keyboard).
|
|
199
|
+
|
|
200
|
+
### Tested Behavior
|
|
201
|
+
|
|
202
|
+
Every line below is an automated test.
|
|
203
|
+
|
|
204
|
+
- Each unit is a spinbutton in the locale's order.
|
|
205
|
+
- Another locale orders the segments its own way.
|
|
206
|
+
- Typing fills each segment, moves on and reports the date once.
|
|
207
|
+
- A press on the box or between segments focuses the nearest segment.
|
|
208
|
+
- A digit that can't start a longer number moves on at once.
|
|
209
|
+
- A separator moves to the next segment.
|
|
210
|
+
- Typing with separators over a filled date or time keeps every segment.
|
|
211
|
+
- ArrowUp and ArrowDown step a segment and wrap around.
|
|
212
|
+
- PageUp and PageDown take bigger steps.
|
|
213
|
+
- Home and End go to a segment's first and last values.
|
|
214
|
+
- ArrowLeft and ArrowRight move between segments.
|
|
215
|
+
- Tab moves through the segments, then out.
|
|
216
|
+
- Backspace empties a segment, then moves back.
|
|
217
|
+
- A day past the end of a new month is moved back to its last day.
|
|
218
|
+
- Pasting a date fills every segment.
|
|
219
|
+
- A time takes hours, minutes and AM or PM.
|
|
220
|
+
- A 24-hour clock has no AM or PM.
|
|
221
|
+
- A date with a time shows its hour and minute too.
|
|
222
|
+
- A controller sets and clears the date.
|
|
223
|
+
- A canceled change keeps the date.
|
|
224
|
+
- The form submits the ISO date and time under their names.
|
|
225
|
+
- Enter submits the form with what was typed.
|
|
226
|
+
- Resetting the form brings back the default date.
|
|
227
|
+
- A partly filled date can't be submitted.
|
|
228
|
+
- A required empty date can't be submitted.
|
|
229
|
+
- A date after max is invalid.
|
|
230
|
+
- An unavailable date is invalid.
|
|
231
|
+
- The field's label focuses the first segment.
|
|
232
|
+
- A read-only date takes focus but doesn't change.
|
|
233
|
+
- A disabled date can't be focused.
|
|
234
|
+
|
|
235
|
+
Runs in React, Vue and web components.
|