@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,519 @@
|
|
|
1
|
+
# Field
|
|
2
|
+
|
|
3
|
+
Connect a form control to its label, description, and validation errors.
|
|
4
|
+
|
|
5
|
+
A field connects a form control to its label, its description and the errors it shows, and wires up `id`, `for` and `aria-describedby` for you.
|
|
6
|
+
|
|
7
|
+
```ts title="input.ts"
|
|
8
|
+
import "@ui-sdk/web/field"
|
|
9
|
+
import "@ui-sdk/web/input"
|
|
10
|
+
|
|
11
|
+
function mount(root: HTMLElement) {
|
|
12
|
+
root.innerHTML = `
|
|
13
|
+
<div data-slot="stack">
|
|
14
|
+
<ui-field>
|
|
15
|
+
<ui-field-label>Username</ui-field-label>
|
|
16
|
+
<ui-input>
|
|
17
|
+
<input name="username" placeholder="hollis" autocomplete="username" />
|
|
18
|
+
</ui-input>
|
|
19
|
+
<ui-field-description>Choose a unique username for your account.</ui-field-description>
|
|
20
|
+
</ui-field>
|
|
21
|
+
</div>
|
|
22
|
+
`
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { mount }
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Press Username to focus the input, then type a name.
|
|
29
|
+
|
|
30
|
+
## Installation
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npm install @ui-sdk/web @ui-sdk/core
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Importing the component defines every field part, [field sets](#field-sets) included. Import the controls you put inside too. On the server the import does nothing.
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
import "@ui-sdk/web/field"
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Composition
|
|
43
|
+
|
|
44
|
+
Use the following composition to build a `ui-field`:
|
|
45
|
+
|
|
46
|
+
```text
|
|
47
|
+
ui-field
|
|
48
|
+
├── ui-field-label
|
|
49
|
+
├── ui-input
|
|
50
|
+
├── ui-field-description
|
|
51
|
+
└── ui-field-error
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Usage
|
|
55
|
+
|
|
56
|
+
```html
|
|
57
|
+
<script type="module">
|
|
58
|
+
import "@ui-sdk/web/field"
|
|
59
|
+
import "@ui-sdk/web/input"
|
|
60
|
+
</script>
|
|
61
|
+
|
|
62
|
+
<ui-field name="username">
|
|
63
|
+
<ui-field-label>Username</ui-field-label>
|
|
64
|
+
<ui-input>
|
|
65
|
+
<input autocomplete="username" required />
|
|
66
|
+
</ui-input>
|
|
67
|
+
<ui-field-description>This is your public name.</ui-field-description>
|
|
68
|
+
<ui-field-error></ui-field-error>
|
|
69
|
+
</ui-field>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
The control is one of ours, like `<ui-input>`, `<ui-textarea>` or `<ui-checkbox>`. The field finds the first one inside it and writes its `id`, `aria-labelledby`, `aria-describedby` and `aria-invalid`.
|
|
73
|
+
|
|
74
|
+
The label names the control, and the description and any error that shows describe it.
|
|
75
|
+
|
|
76
|
+
Group related fields in a [field set](#field-sets):
|
|
77
|
+
|
|
78
|
+
```html
|
|
79
|
+
<ui-field-set>
|
|
80
|
+
<fieldset>
|
|
81
|
+
<legend></legend>
|
|
82
|
+
<ui-field-description></ui-field-description>
|
|
83
|
+
<ui-field-group>
|
|
84
|
+
<ui-field></ui-field>
|
|
85
|
+
<ui-field></ui-field>
|
|
86
|
+
</ui-field-group>
|
|
87
|
+
</fieldset>
|
|
88
|
+
</ui-field-set>
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Controls
|
|
92
|
+
|
|
93
|
+
Use `<ui-input>` for a line of text and `<ui-textarea>` for more, each around its native element:
|
|
94
|
+
|
|
95
|
+
```html
|
|
96
|
+
<ui-field>
|
|
97
|
+
<ui-field-label>Feedback</ui-field-label>
|
|
98
|
+
<ui-textarea>
|
|
99
|
+
<textarea name="feedback"></textarea>
|
|
100
|
+
</ui-textarea>
|
|
101
|
+
</ui-field>
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
For a control we don't ship, like a native `<select>`, put the element straight in the field, and it connects the same way. An [agent](../agents.md) sees only our components, so it can't fill a bare element: use ours where there is one.
|
|
105
|
+
|
|
106
|
+
```html
|
|
107
|
+
<ui-field>
|
|
108
|
+
<ui-field-label>Department</ui-field-label>
|
|
109
|
+
<select name="department">
|
|
110
|
+
<option value="design">Design</option>
|
|
111
|
+
<option value="engineering">Engineering</option>
|
|
112
|
+
</select>
|
|
113
|
+
</ui-field>
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
A [Checkbox](./checkbox.md), [Switch](./switch.md) or [Radio Group](./radio.md) inside a field uses the field's label and description. Pressing the label toggles a checkbox or switch. A radio group takes the field's label as its name, and each radio keeps a label of its own:
|
|
117
|
+
|
|
118
|
+
```html
|
|
119
|
+
<ui-field>
|
|
120
|
+
<ui-switch name="mfa"></ui-switch>
|
|
121
|
+
<ui-field-label>Two-factor authentication</ui-field-label>
|
|
122
|
+
<ui-field-description>Ask for a code when you sign in.</ui-field-description>
|
|
123
|
+
</ui-field>
|
|
124
|
+
|
|
125
|
+
<ui-field>
|
|
126
|
+
<ui-field-label>Plan</ui-field-label>
|
|
127
|
+
<ui-radio-group name="plan" default-value="monthly">
|
|
128
|
+
<label>
|
|
129
|
+
<ui-radio value="monthly"></ui-radio>
|
|
130
|
+
Monthly
|
|
131
|
+
</label>
|
|
132
|
+
<label>
|
|
133
|
+
<ui-radio value="yearly"></ui-radio>
|
|
134
|
+
Yearly
|
|
135
|
+
</label>
|
|
136
|
+
</ui-radio-group>
|
|
137
|
+
</ui-field>
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Validation
|
|
141
|
+
|
|
142
|
+
Use native constraints such as `required`, `type="email"`, and `pattern`. Errors appear after a submit attempt and update as the value changes. The first invalid control takes focus.
|
|
143
|
+
|
|
144
|
+
Leave an error empty to show the browser's message, or use `match="valueMissing"` and `match="typeMismatch"` for your own messages. Adding an error part replaces the browser's validation bubble with that message in the page.
|
|
145
|
+
|
|
146
|
+
```ts title="validation.ts"
|
|
147
|
+
import "@ui-sdk/web/field"
|
|
148
|
+
import "@ui-sdk/web/input"
|
|
149
|
+
import { log } from "./log"
|
|
150
|
+
|
|
151
|
+
function mount(root: HTMLElement) {
|
|
152
|
+
root.innerHTML = `
|
|
153
|
+
<form data-slot="stack">
|
|
154
|
+
<ui-field name="email">
|
|
155
|
+
<ui-field-label>Email</ui-field-label>
|
|
156
|
+
<ui-input>
|
|
157
|
+
<input type="email" required placeholder="hollis@example.com" />
|
|
158
|
+
</ui-input>
|
|
159
|
+
<ui-field-description>
|
|
160
|
+
<span data-hide="valid">We'll send you a confirmation link.</span>
|
|
161
|
+
<span data-show="valid">Looks good.</span>
|
|
162
|
+
</ui-field-description>
|
|
163
|
+
<ui-field-error match="valueMissing">Enter your email address.</ui-field-error>
|
|
164
|
+
<ui-field-error match="typeMismatch">Enter an email address like hollis@example.com.</ui-field-error>
|
|
165
|
+
</ui-field>
|
|
166
|
+
<ui-field name="website">
|
|
167
|
+
<ui-field-label>Website</ui-field-label>
|
|
168
|
+
<ui-input>
|
|
169
|
+
<input type="url" required placeholder="https://example.com" />
|
|
170
|
+
</ui-input>
|
|
171
|
+
<ui-field-error></ui-field-error>
|
|
172
|
+
</ui-field>
|
|
173
|
+
<button type="submit" data-variant="solid">Subscribe</button>
|
|
174
|
+
</form>
|
|
175
|
+
`
|
|
176
|
+
const form = root.querySelector("form")!
|
|
177
|
+
form.addEventListener("submit", (event) => {
|
|
178
|
+
event.preventDefault()
|
|
179
|
+
log(root, `Subscribed ${new FormData(form).get("email")}`)
|
|
180
|
+
})
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export { mount }
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
Press Subscribe with an empty or invalid email, then correct it to clear the error.
|
|
187
|
+
|
|
188
|
+
## Errors from Your Code
|
|
189
|
+
|
|
190
|
+
Pass `invalid` when your server or form library supplies an error. `true` shows it immediately. Clear the value to return to the browser's validation.
|
|
191
|
+
|
|
192
|
+
Give this error its own text and set `match` to `true`. Named matches such as `valueMissing` still refer to native validation. `invalid="false"` hides the field's invalid state, but does not make an invalid native control pass validation.
|
|
193
|
+
|
|
194
|
+
```html
|
|
195
|
+
<ui-field name="email">
|
|
196
|
+
<ui-field-label>Email</ui-field-label>
|
|
197
|
+
<ui-input>
|
|
198
|
+
<input type="email" required />
|
|
199
|
+
</ui-input>
|
|
200
|
+
<ui-field-error match="valueMissing"
|
|
201
|
+
>Enter your email address.</ui-field-error
|
|
202
|
+
>
|
|
203
|
+
</ui-field>
|
|
204
|
+
|
|
205
|
+
<script type="module">
|
|
206
|
+
const field = document.querySelector("ui-field")
|
|
207
|
+
const serverError = document.createElement("ui-field-error")
|
|
208
|
+
serverError.setAttribute("match", "true")
|
|
209
|
+
|
|
210
|
+
function showServerError(message) {
|
|
211
|
+
serverError.textContent = message
|
|
212
|
+
field.append(serverError)
|
|
213
|
+
field.invalid = true
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
field.querySelector("input").addEventListener("input", () => {
|
|
217
|
+
serverError.remove()
|
|
218
|
+
field.invalid = undefined
|
|
219
|
+
})
|
|
220
|
+
</script>
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
## Required and Disabled
|
|
224
|
+
|
|
225
|
+
A required control marks every part with `data-required`, and the parts' state has `required`, so a label can show a mark with CSS alone.
|
|
226
|
+
|
|
227
|
+
A disabled field disables its control and marks every part with `data-disabled`, the way a [disabled field set](#disabled-field-sets) does for every field inside it.
|
|
228
|
+
|
|
229
|
+
## Character Count
|
|
230
|
+
|
|
231
|
+
Listen for `input` on the control and show its length in the description. Set `maxlength` on the control to enforce the limit.
|
|
232
|
+
|
|
233
|
+
```html
|
|
234
|
+
<ui-field>
|
|
235
|
+
<ui-field-label>Bio</ui-field-label>
|
|
236
|
+
<ui-textarea>
|
|
237
|
+
<textarea maxlength="280"></textarea>
|
|
238
|
+
</ui-textarea>
|
|
239
|
+
<ui-field-description>0 / 280</ui-field-description>
|
|
240
|
+
</ui-field>
|
|
241
|
+
|
|
242
|
+
<script type="module">
|
|
243
|
+
const bio = document.querySelector("textarea")
|
|
244
|
+
const count = document.querySelector("ui-field-description")
|
|
245
|
+
bio.addEventListener("input", () => {
|
|
246
|
+
count.textContent = `${bio.value.length} / 280`
|
|
247
|
+
})
|
|
248
|
+
</script>
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
## Forms
|
|
252
|
+
|
|
253
|
+
The control submits its value under its own `name`, or the field's name if it has none. Reset restores the control's default and hides validation errors. Disabled controls are left out of the submitted values. See [Forms](../forms.md) for the shared form behavior.
|
|
254
|
+
|
|
255
|
+
## Field Sets
|
|
256
|
+
|
|
257
|
+
A field set groups related fields under a legend, and disables them together.
|
|
258
|
+
|
|
259
|
+
```ts title="field-set.ts"
|
|
260
|
+
import "@ui-sdk/web/field"
|
|
261
|
+
import "@ui-sdk/web/input"
|
|
262
|
+
|
|
263
|
+
function mount(root: HTMLElement) {
|
|
264
|
+
root.innerHTML = `
|
|
265
|
+
<ui-field-set>
|
|
266
|
+
<fieldset>
|
|
267
|
+
<legend>Address</legend>
|
|
268
|
+
<ui-field-description>We need your address to deliver your order.</ui-field-description>
|
|
269
|
+
<ui-field-group>
|
|
270
|
+
<ui-field name="street">
|
|
271
|
+
<ui-field-label>Street address</ui-field-label>
|
|
272
|
+
<ui-input><input autocomplete="street-address" /></ui-input>
|
|
273
|
+
</ui-field>
|
|
274
|
+
<div data-slot="grid">
|
|
275
|
+
<ui-field name="city">
|
|
276
|
+
<ui-field-label>City</ui-field-label>
|
|
277
|
+
<ui-input><input autocomplete="address-level2" /></ui-input>
|
|
278
|
+
</ui-field>
|
|
279
|
+
<ui-field name="postal-code">
|
|
280
|
+
<ui-field-label>Postal code</ui-field-label>
|
|
281
|
+
<ui-input><input autocomplete="postal-code" /></ui-input>
|
|
282
|
+
</ui-field>
|
|
283
|
+
</div>
|
|
284
|
+
</ui-field-group>
|
|
285
|
+
</fieldset>
|
|
286
|
+
</ui-field-set>
|
|
287
|
+
`
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
export { mount }
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
Move through the address fields. Their legend and description name the group.
|
|
294
|
+
|
|
295
|
+
`<ui-field-set>` wraps a native `<fieldset>` and its `<legend>`, and displays as contents, so the set is named, and disabled, before scripts run. Keep the legend the first child. For a legend that isn't a native `<legend>`, use `<ui-field-legend>`: it still names the set through `aria-labelledby`.
|
|
296
|
+
|
|
297
|
+
A `<ui-field-description>` right inside the set, outside any `<ui-field>`, describes the set, so screen readers read it as focus enters. `<ui-field-group>` stacks the fields, with no role and no state: the field set is what names and disables a group.
|
|
298
|
+
|
|
299
|
+
## Disabled Field Sets
|
|
300
|
+
|
|
301
|
+
Disabling the set disables its controls and nested field sets. The form leaves their values out of submissions.
|
|
302
|
+
|
|
303
|
+
```html
|
|
304
|
+
<ui-field-set disabled>
|
|
305
|
+
<fieldset>
|
|
306
|
+
<legend>Billing address</legend>
|
|
307
|
+
<ui-field name="billing-street">
|
|
308
|
+
<ui-field-label>Street address</ui-field-label>
|
|
309
|
+
<ui-input>
|
|
310
|
+
<input autocomplete="billing street-address" />
|
|
311
|
+
</ui-input>
|
|
312
|
+
</ui-field>
|
|
313
|
+
</fieldset>
|
|
314
|
+
</ui-field-set>
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
## Groups in a Field Set
|
|
318
|
+
|
|
319
|
+
The legend names a [checkbox group](./checkbox.md#group) or a [radio group](./radio.md) inside the set, so the group needs no label of its own.
|
|
320
|
+
|
|
321
|
+
```html
|
|
322
|
+
<ui-field-set>
|
|
323
|
+
<fieldset>
|
|
324
|
+
<legend>Notifications</legend>
|
|
325
|
+
<ui-checkbox-group name="notify" default-value="mentions">
|
|
326
|
+
<label>
|
|
327
|
+
<ui-checkbox value="mentions"></ui-checkbox>
|
|
328
|
+
Mentions
|
|
329
|
+
</label>
|
|
330
|
+
<label>
|
|
331
|
+
<ui-checkbox value="follows"></ui-checkbox>
|
|
332
|
+
New followers
|
|
333
|
+
</label>
|
|
334
|
+
</ui-checkbox-group>
|
|
335
|
+
</fieldset>
|
|
336
|
+
</ui-field-set>
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
## Custom Rendering
|
|
340
|
+
|
|
341
|
+
The control is your own element, so render whatever you like. Parts have no render functions: show and hide content from the parts' data attributes, like `in-data-invalid:inline` in Tailwind. An empty `<ui-field-error>` fills itself with the message for the current problem.
|
|
342
|
+
|
|
343
|
+
## Custom Controls
|
|
344
|
+
|
|
345
|
+
Web components have no hook: the field finds its control itself. It takes the first native `<input>`, `<select>` or `<textarea>` inside it, or the first element with a control role, like `role="checkbox"`, `"switch"`, `"radiogroup"`, `"combobox"`, `"slider"`, `"spinbutton"`, `"textbox"` or `"listbox"`. It writes that element's `id`, `aria-labelledby`, `aria-describedby`, `aria-invalid`, `disabled` and data attributes, and the field's `name` when it has none.
|
|
346
|
+
|
|
347
|
+
So a custom element of your own joins a field when it has one of those roles. The field reads validity only from native inputs, selects and textareas and from our own elements, so yours submits and validates through a native input inside it, with its own `name`.
|
|
348
|
+
|
|
349
|
+
To build a control from scratch on the primitives ours use, see [Primitives](../core.md#define-a-primitive).
|
|
350
|
+
|
|
351
|
+
## Styling
|
|
352
|
+
|
|
353
|
+
Use `data-invalid` and `data-valid` for validation, and `data-focused`, `data-required` and `data-disabled` for the rest. Every part of a field gets the same attributes, so a label can turn red with its control.
|
|
354
|
+
|
|
355
|
+
Each part has a `data-slot`, such as `field-label`, and its state attributes are listed under [Data Attributes](#data-attributes).
|
|
356
|
+
|
|
357
|
+
## Data Attributes
|
|
358
|
+
|
|
359
|
+
### `<ui-field>`
|
|
360
|
+
`[data-slot="field"]`
|
|
361
|
+
|
|
362
|
+
- `data-disabled`: Present when the field is disabled.
|
|
363
|
+
- `data-invalid`: Present while the field shows as invalid: with `invalid`, or once a submit finds the control invalid.
|
|
364
|
+
|
|
365
|
+
### `<ui-field-label>`
|
|
366
|
+
`[data-slot="field-label"]`
|
|
367
|
+
|
|
368
|
+
- `data-disabled`: Present when the field is disabled.
|
|
369
|
+
- `data-invalid`: Present while the field shows as invalid: with `invalid`, or once a submit finds the control invalid.
|
|
370
|
+
|
|
371
|
+
### `<input>`
|
|
372
|
+
`[data-slot="field-control"]`
|
|
373
|
+
|
|
374
|
+
- `data-disabled`: Present when the field is disabled.
|
|
375
|
+
- `data-invalid`: Present while the field shows as invalid: with `invalid`, or once a submit finds the control invalid.
|
|
376
|
+
|
|
377
|
+
### `<ui-field-description>`
|
|
378
|
+
`[data-slot="field-description"]`
|
|
379
|
+
|
|
380
|
+
- `data-disabled`: Present when the field is disabled.
|
|
381
|
+
- `data-invalid`: Present while the field shows as invalid: with `invalid`, or once a submit finds the control invalid.
|
|
382
|
+
|
|
383
|
+
### `<ui-field-error>`
|
|
384
|
+
`[data-slot="field-error"]`
|
|
385
|
+
|
|
386
|
+
- `data-disabled`: Present when the field is disabled.
|
|
387
|
+
- `data-invalid`: Present while the field shows as invalid: with `invalid`, or once a submit finds the control invalid.
|
|
388
|
+
|
|
389
|
+
### `<fieldset>`
|
|
390
|
+
`<ui-field-group>` has `data-slot="field-group"` and no state attributes.
|
|
391
|
+
|
|
392
|
+
`[data-slot="field-set"]`
|
|
393
|
+
|
|
394
|
+
- `data-disabled`: Present when the field set is disabled, by its own prop or a `<fieldset>` around it.
|
|
395
|
+
|
|
396
|
+
### `<legend>`
|
|
397
|
+
`[data-slot="field-legend"]`
|
|
398
|
+
|
|
399
|
+
- `data-disabled`: Present when the field set is disabled, by its own prop or a `<fieldset>` around it.
|
|
400
|
+
|
|
401
|
+
### `<ui-field-description>` in a `<ui-field-set>`
|
|
402
|
+
`[data-slot="field-description"]`
|
|
403
|
+
|
|
404
|
+
- `data-disabled`: Present when the field set is disabled, by its own prop or a `<fieldset>` around it.
|
|
405
|
+
|
|
406
|
+
## API Reference
|
|
407
|
+
|
|
408
|
+
Props are attributes in kebab case. `invalid` without a value is `true`, and `invalid="false"` is `false`. `invalid` is also a property, where `undefined` leaves it to the attribute, or to the browser without one.
|
|
409
|
+
|
|
410
|
+
A field has no change events. Read its state from the parts' data attributes. Add the `debug` attribute to log every state change and its reason.
|
|
411
|
+
|
|
412
|
+
### Field
|
|
413
|
+
|
|
414
|
+
- `name?` (`string`): The name the control submits under, when the control doesn't set its own.
|
|
415
|
+
- `disabled?` (`boolean`): Disables the control, and marks every part.
|
|
416
|
+
- `invalid?` (`boolean`): Whether the field shows as invalid, when your code decides, like a form library or an error from the server. `true` shows its errors now, `false` shows none whatever the browser thinks. Leave it out to show the browser's own validation once a submit finds the field invalid.
|
|
417
|
+
- `debug?` (`boolean`): Logs every state change with its reason to the console, in development builds.
|
|
418
|
+
|
|
419
|
+
### FieldError
|
|
420
|
+
|
|
421
|
+
- `match?` (`boolean | ValidityKey`): When this error shows. `true` shows it always and `false` never. A validity flag, like `"valueMissing"`, shows it only for that problem of the browser's own validation. Without it, any problem shows it.
|
|
422
|
+
|
|
423
|
+
### FieldSet
|
|
424
|
+
|
|
425
|
+
- `disabled?` (`boolean`): Disables every control inside it, except those in its legend, and leaves them out of the form.
|
|
426
|
+
- `debug?` (`boolean`): Logs every state change with its reason to the console, in development builds.
|
|
427
|
+
|
|
428
|
+
### State
|
|
429
|
+
|
|
430
|
+
- `disabled` (`boolean`): Whether the field is disabled, by itself or by a `<fieldset>`.
|
|
431
|
+
- `required` (`boolean`): Whether the control is required, read from its `required` or `aria-required`.
|
|
432
|
+
- `focused` (`boolean`): Whether focus is inside the control.
|
|
433
|
+
- `invalid` (`boolean`): Whether the field shows as invalid: `invalid` when you pass it, else the browser's validation once shown.
|
|
434
|
+
- `valid` (`boolean`): Whether the browser's validation passes, once shown. Always false while you pass `invalid`.
|
|
435
|
+
|
|
436
|
+
- `disabled` (`boolean`): Whether the field is disabled, by itself or by a `<fieldset>`.
|
|
437
|
+
- `required` (`boolean`): Whether the control is required, read from its `required` or `aria-required`.
|
|
438
|
+
- `focused` (`boolean`): Whether focus is inside the control.
|
|
439
|
+
- `invalid` (`boolean`): Whether the field shows as invalid: `invalid` when you pass it, else the browser's validation once shown.
|
|
440
|
+
- `valid` (`boolean`): Whether the browser's validation passes, once shown. Always false while you pass `invalid`.
|
|
441
|
+
- `message` (`string`): The browser's message for the current problem. Children you pass show instead.
|
|
442
|
+
|
|
443
|
+
A `<ui-field-description>` receives the field's state, or only `disabled` when it describes a field set.
|
|
444
|
+
|
|
445
|
+
- `disabled` (`boolean`): Whether the field set is disabled, by itself or by a field set around it. Whether the field is disabled, by itself or by a `<fieldset>`.
|
|
446
|
+
- `required` (`boolean | undefined`): Whether the control is required, read from its `required` or `aria-required`.
|
|
447
|
+
- `focused` (`boolean | undefined`): Whether focus is inside the control.
|
|
448
|
+
- `invalid` (`boolean | undefined`): Whether the field shows as invalid: `invalid` when you pass it, else the browser's validation once shown.
|
|
449
|
+
- `valid` (`boolean | undefined`): Whether the browser's validation passes, once shown. Always false while you pass `invalid`.
|
|
450
|
+
|
|
451
|
+
Every part of a field set receives the same state.
|
|
452
|
+
|
|
453
|
+
- `disabled` (`boolean`): Whether the field set is disabled, by itself or by a field set around it.
|
|
454
|
+
|
|
455
|
+
## Accessibility
|
|
456
|
+
|
|
457
|
+
The label names the control with `aria-labelledby`, beside a native `<label for>` where the control can take one. The description and any error that shows describe it with `aria-describedby`, and an invalid control has `aria-invalid`. The tests below cover these connections and keyboard behavior.
|
|
458
|
+
|
|
459
|
+
**Labelling**
|
|
460
|
+
|
|
461
|
+
- The label names the control.
|
|
462
|
+
- The description describes the control.
|
|
463
|
+
- Clicking the label of a text field focuses it.
|
|
464
|
+
|
|
465
|
+
**A label wrapping a field**
|
|
466
|
+
|
|
467
|
+
- Names the control inside it.
|
|
468
|
+
- Checks its control when clicked anywhere.
|
|
469
|
+
- Keeps the field's description on its control.
|
|
470
|
+
- Names a control that renders after it.
|
|
471
|
+
- Keeps the part's data-slot.
|
|
472
|
+
- Warns in development only when a label outside a field labels nothing.
|
|
473
|
+
- A description and an error outside a field keep their data-slot. Web components only.
|
|
474
|
+
- A hidden error outside a field stays hidden whatever display its class gives. Web components only.
|
|
475
|
+
- An error outside a field follows its match. Web components only.
|
|
476
|
+
- An error outside a field shows a child that arrives after it. Web components only.
|
|
477
|
+
|
|
478
|
+
**Errors**
|
|
479
|
+
|
|
480
|
+
- Stay hidden until the form tries to submit.
|
|
481
|
+
- Show the browser's message when they have no text of their own.
|
|
482
|
+
- Count another library's form-associated element inside the field.
|
|
483
|
+
- Describe the control while they show.
|
|
484
|
+
- Update as the value changes once shown.
|
|
485
|
+
- Update as state set from script changes the value once shown. Web components only.
|
|
486
|
+
- A field marked invalid shows its error right away.
|
|
487
|
+
- A field marked valid never shows the browser's errors.
|
|
488
|
+
- A form reset hides them again.
|
|
489
|
+
- Errors in the page replace the browser's message, and the first invalid control takes focus.
|
|
490
|
+
|
|
491
|
+
Runs in React, Vue and web components.
|
|
492
|
+
|
|
493
|
+
In a field set:
|
|
494
|
+
|
|
495
|
+
- The legend names the group.
|
|
496
|
+
- A disabled field set disables the controls inside and leaves them out of the form.
|
|
497
|
+
- Enabling it again restores the controls.
|
|
498
|
+
- A field set disabled from the start disables its required fields.
|
|
499
|
+
- Fields in a disabled field set mark their parts disabled.
|
|
500
|
+
|
|
501
|
+
**Enhancements**
|
|
502
|
+
|
|
503
|
+
- The description describes the group.
|
|
504
|
+
|
|
505
|
+
Runs in React, Vue and web components.
|
|
506
|
+
|
|
507
|
+
In a form:
|
|
508
|
+
|
|
509
|
+
- The form submits every checked control's name and value.
|
|
510
|
+
- Unchecked controls submit nothing.
|
|
511
|
+
- A checkbox outside the form joins it with the form attribute.
|
|
512
|
+
- Required controls block submission.
|
|
513
|
+
- A form reset returns every control to its default.
|
|
514
|
+
- A reset returns to the default value, not to nothing.
|
|
515
|
+
- A disabled fieldset disables the controls inside it.
|
|
516
|
+
- A read-only control still submits.
|
|
517
|
+
- A user's change fires native input and change events on the form.
|
|
518
|
+
|
|
519
|
+
Runs in React, Vue and web components.
|