@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,174 @@
|
|
|
1
|
+
// src/date-picker.ts
|
|
2
|
+
import { datePicker } from "@ui-sdk/core/date-picker";
|
|
3
|
+
import { partState } from "@ui-sdk/core/renderer";
|
|
4
|
+
import {
|
|
5
|
+
defineCalendarParts,
|
|
6
|
+
renderCalendarParts,
|
|
7
|
+
renderDefaultCalendar
|
|
8
|
+
} from "./calendar.js";
|
|
9
|
+
import {
|
|
10
|
+
createParts,
|
|
11
|
+
findOwner,
|
|
12
|
+
ownButton,
|
|
13
|
+
parseAttribute
|
|
14
|
+
} from "./define-element.js";
|
|
15
|
+
import { showDefaultText } from "./default-text.js";
|
|
16
|
+
import { element } from "./list.js";
|
|
17
|
+
import { popupKinds, popupState, sheetPortal } from "./popup.js";
|
|
18
|
+
var owner = "ui-date-picker";
|
|
19
|
+
function defineDatePickerElements() {
|
|
20
|
+
createParts(datePicker, {
|
|
21
|
+
root: {
|
|
22
|
+
tag: owner,
|
|
23
|
+
defaults: {
|
|
24
|
+
showOutsideDays: true,
|
|
25
|
+
closeOnSelect: true,
|
|
26
|
+
dismissible: true
|
|
27
|
+
},
|
|
28
|
+
display: "block",
|
|
29
|
+
formAssociated: true,
|
|
30
|
+
kinds: popupKinds,
|
|
31
|
+
// `unavailable` as a property takes any matcher, like `{ weekday: [0, 6] }`.
|
|
32
|
+
properties: ["unavailable"],
|
|
33
|
+
// container="#id" is found in the page by the portal, never passed on as a
|
|
34
|
+
// selector. A disabled <ui-field> around it disables all of it, as a
|
|
35
|
+
// disabled Field does in the other frameworks.
|
|
36
|
+
options: (el) => ({
|
|
37
|
+
container: void 0,
|
|
38
|
+
...el.closest("ui-field")?.hasAttribute("disabled") && {
|
|
39
|
+
disabled: true
|
|
40
|
+
}
|
|
41
|
+
}),
|
|
42
|
+
// The live `value` and `month` properties, as on a calendar.
|
|
43
|
+
state: {
|
|
44
|
+
value: {
|
|
45
|
+
get: (api) => api.getValue(),
|
|
46
|
+
set: (api, value) => api.setValue(value)
|
|
47
|
+
},
|
|
48
|
+
month: {
|
|
49
|
+
get: (api) => api.getMonth(),
|
|
50
|
+
set: (api, month) => api.setMonth(month)
|
|
51
|
+
},
|
|
52
|
+
...popupState
|
|
53
|
+
},
|
|
54
|
+
api: [
|
|
55
|
+
"getValue",
|
|
56
|
+
"setValue",
|
|
57
|
+
"clear",
|
|
58
|
+
"getMonth",
|
|
59
|
+
"setMonth",
|
|
60
|
+
"previous",
|
|
61
|
+
"next",
|
|
62
|
+
"focus",
|
|
63
|
+
"isOpen",
|
|
64
|
+
"setOpen",
|
|
65
|
+
"open",
|
|
66
|
+
"close",
|
|
67
|
+
"toggle"
|
|
68
|
+
],
|
|
69
|
+
// container="#id" renders the popup there, and a sheet's viewport with it.
|
|
70
|
+
portal: sheetPortal("ui-date-picker-viewport"),
|
|
71
|
+
render(picker, instance) {
|
|
72
|
+
if (!checkedForContent.has(picker)) {
|
|
73
|
+
checkedForContent.add(picker);
|
|
74
|
+
if (!picker.firstElementChild) {
|
|
75
|
+
renderDefaultContent(picker);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const cleanups = [
|
|
79
|
+
renderCalendarParts(picker, instance),
|
|
80
|
+
showDefaultText(
|
|
81
|
+
picker,
|
|
82
|
+
instance,
|
|
83
|
+
"ui-date-picker-hint",
|
|
84
|
+
() => partState(instance.part("hint", {})).placeholder
|
|
85
|
+
)
|
|
86
|
+
];
|
|
87
|
+
if (hasDefaultContent.has(picker)) {
|
|
88
|
+
const update = () => matchInputs(picker, instance);
|
|
89
|
+
update();
|
|
90
|
+
cleanups.push(instance.subscribe(update));
|
|
91
|
+
}
|
|
92
|
+
return () => cleanups.forEach((cleanup) => cleanup?.());
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
input: {
|
|
96
|
+
tag: "ui-date-picker-input",
|
|
97
|
+
display: "contents",
|
|
98
|
+
target: textInput,
|
|
99
|
+
context: (el) => ({
|
|
100
|
+
id: parseAttribute("boolean", el.getAttribute("end")) ? "end" : "start"
|
|
101
|
+
}),
|
|
102
|
+
// The input's binding reads which end it holds once.
|
|
103
|
+
rebind: ["end"]
|
|
104
|
+
},
|
|
105
|
+
trigger: {
|
|
106
|
+
tag: "ui-date-picker-trigger",
|
|
107
|
+
display: "contents",
|
|
108
|
+
target: ownButton((button) => button.innerHTML = calendarIcon)
|
|
109
|
+
},
|
|
110
|
+
content: {
|
|
111
|
+
tag: "ui-date-picker-content",
|
|
112
|
+
display: "block",
|
|
113
|
+
kinds: popupKinds,
|
|
114
|
+
render(el) {
|
|
115
|
+
const picker = findOwner(el, owner);
|
|
116
|
+
if (picker && !el.firstElementChild) {
|
|
117
|
+
renderDefaultCalendar(el, picker);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
hint: "ui-date-picker-hint",
|
|
122
|
+
clear: {
|
|
123
|
+
tag: "ui-date-picker-clear",
|
|
124
|
+
display: "contents",
|
|
125
|
+
target: ownButton()
|
|
126
|
+
},
|
|
127
|
+
// `value` is a date, or a range's two dates separated by a comma.
|
|
128
|
+
preset: {
|
|
129
|
+
tag: "ui-date-picker-preset",
|
|
130
|
+
display: "contents",
|
|
131
|
+
target: ownButton(),
|
|
132
|
+
context: (el) => ({ id: el.getAttribute("value") ?? "" })
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
defineCalendarParts(datePicker, "ui-calendar");
|
|
136
|
+
}
|
|
137
|
+
var calendarIcon = '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" aria-hidden="true"><rect x="2" y="3" width="12" height="11" rx="1.5" /><path d="M2 6.5h12M5.5 1.5v3M10.5 1.5v3" /></svg>';
|
|
138
|
+
var checkedForContent = /* @__PURE__ */ new WeakSet();
|
|
139
|
+
var hasDefaultContent = /* @__PURE__ */ new WeakSet();
|
|
140
|
+
var renderedModes = /* @__PURE__ */ new WeakMap();
|
|
141
|
+
function renderDefaultContent(picker) {
|
|
142
|
+
hasDefaultContent.add(picker);
|
|
143
|
+
picker.append(
|
|
144
|
+
element("ui-date-picker-input"),
|
|
145
|
+
element("ui-date-picker-trigger"),
|
|
146
|
+
element("ui-date-picker-content")
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
function matchInputs(picker, instance) {
|
|
150
|
+
const { mode } = instance.get();
|
|
151
|
+
if (renderedModes.get(picker) === mode) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
renderedModes.set(picker, mode);
|
|
155
|
+
const end = picker.querySelector(":scope > ui-date-picker-input[end]");
|
|
156
|
+
if (mode !== "range") {
|
|
157
|
+
return end?.remove();
|
|
158
|
+
}
|
|
159
|
+
if (!end) {
|
|
160
|
+
picker.querySelector(":scope > ui-date-picker-input")?.after(element("ui-date-picker-input", { end: true }));
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
function textInput(el) {
|
|
164
|
+
const written = el.querySelector("input");
|
|
165
|
+
if (written) {
|
|
166
|
+
return written;
|
|
167
|
+
}
|
|
168
|
+
const input = element("input");
|
|
169
|
+
el.append(input);
|
|
170
|
+
return input;
|
|
171
|
+
}
|
|
172
|
+
export {
|
|
173
|
+
defineDatePickerElements
|
|
174
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { PrimitiveInstance } from "@ui-sdk/core";
|
|
2
|
+
declare function showDefaultText(owner: HTMLElement, instance: PrimitiveInstance, selector: string, text: (el: HTMLElement, instance: PrimitiveInstance, index: number) => string): () => void;
|
|
3
|
+
export { showDefaultText };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// src/default-text.ts
|
|
2
|
+
function showDefaultText(owner, instance, selector, text) {
|
|
3
|
+
const update = () => {
|
|
4
|
+
const parts = Array.from(
|
|
5
|
+
owner.querySelectorAll(selector)
|
|
6
|
+
).filter((el) => el.closest(owner.localName) === owner);
|
|
7
|
+
parts.forEach((el, index) => {
|
|
8
|
+
if (!("text" in el.dataset) && el.childNodes.length) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
el.dataset.text = "";
|
|
12
|
+
const next = text(el, instance, index);
|
|
13
|
+
if (el.textContent !== next) {
|
|
14
|
+
el.textContent = next;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
const unsubscribe = instance.subscribe(update);
|
|
19
|
+
queueMicrotask(update);
|
|
20
|
+
return unsubscribe;
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
showDefaultText
|
|
24
|
+
};
|
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
import type { OptionsOf, Part as InstancePart, Primitive, PrimitiveInstance, PropSpec, SlotName, TypesOf } from "@ui-sdk/core";
|
|
2
|
+
import { type Feature } from "@ui-sdk/core/renderer";
|
|
3
|
+
/**
|
|
4
|
+
* Whether to define a tag now. Never on the server, where importing a component
|
|
5
|
+
* does nothing, and once per tag. A tag that another library or another copy
|
|
6
|
+
* of ui-sdk defined first keeps that definition, with a warning.
|
|
7
|
+
*/
|
|
8
|
+
declare function claimTag(tagName: string): boolean;
|
|
9
|
+
/** A stable id for any element, for parts that need a key and have none. */
|
|
10
|
+
declare function autoId(el: Element): string;
|
|
11
|
+
/**
|
|
12
|
+
* The button or link a wrapper part holds, like the <button> in <ui-tabs-tab>,
|
|
13
|
+
* so the part binds to it and native button behavior stays.
|
|
14
|
+
* @stable
|
|
15
|
+
*/
|
|
16
|
+
declare function wrappedButton(el: HTMLElement): HTMLElement | null;
|
|
17
|
+
/**
|
|
18
|
+
* A `target` for a wrapper part: its child matching `selector`, like the
|
|
19
|
+
* <input> in <ui-combobox-input>, else its first child.
|
|
20
|
+
* @stable
|
|
21
|
+
*/
|
|
22
|
+
declare const wrappedChild: (selector: string) => (el: HTMLElement) => HTMLElement | null;
|
|
23
|
+
/**
|
|
24
|
+
* A `target` for a wrapper part that binds a button: the one written inside
|
|
25
|
+
* it, else a new one holding what the part held. `fill` fills a button that
|
|
26
|
+
* would be empty, like with an arrow or an icon.
|
|
27
|
+
*/
|
|
28
|
+
declare function ownButton(fill?: (button: HTMLButtonElement) => void): (el: HTMLElement) => HTMLElement;
|
|
29
|
+
/**
|
|
30
|
+
* How an attribute becomes an option or prop. `"boolean"`: present, empty or
|
|
31
|
+
* `"true"` is true and `"false"` is false, except `disabled` and `required`,
|
|
32
|
+
* which are true whenever present, as on native controls. `"number"`: a number. `"list"`:
|
|
33
|
+
* comma-separated values. `"string"`: the value as written. A function parses
|
|
34
|
+
* anything else, like `modal`, which is a boolean or a string.
|
|
35
|
+
* @stable
|
|
36
|
+
*/
|
|
37
|
+
type AttributeType = "boolean" | "number" | "string" | "list" | ((value: string | null) => unknown);
|
|
38
|
+
/**
|
|
39
|
+
* An attribute's value as an option. Missing attributes are undefined, so the
|
|
40
|
+
* component's default applies.
|
|
41
|
+
*/
|
|
42
|
+
declare function parseAttribute(type: AttributeType, value: string | null): unknown;
|
|
43
|
+
type BooleanDefaults = Record<string, boolean | ((el: HTMLElement) => boolean)>;
|
|
44
|
+
declare function upgradeProperties(el: HTMLElement, names: Iterable<string>): void;
|
|
45
|
+
declare function instanceOf<Api = unknown>(el: Element | null | undefined): (PrimitiveInstance & {
|
|
46
|
+
api: Api;
|
|
47
|
+
}) | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* A part's default CSS display. `contents` keeps it out of layout, for
|
|
50
|
+
* wrappers, and the table values lay out parts that stand in for a table's
|
|
51
|
+
* elements, like a calendar's weeks and days.
|
|
52
|
+
*/
|
|
53
|
+
type PartDisplay = "block" | "contents" | "table" | "table-header-group" | "table-row-group" | "table-row" | "table-cell";
|
|
54
|
+
/**
|
|
55
|
+
* Gives elements matching `selector` a default display, like a part's tag,
|
|
56
|
+
* or the elements a part generates inside it.
|
|
57
|
+
*/
|
|
58
|
+
declare function setDisplay(selector: string, value?: PartDisplay, align?: boolean): void;
|
|
59
|
+
type Part = {
|
|
60
|
+
slot: string;
|
|
61
|
+
feature?: Feature;
|
|
62
|
+
el: HTMLElement;
|
|
63
|
+
props: Record<string, unknown>;
|
|
64
|
+
unbind?: () => void;
|
|
65
|
+
placeholder?: Comment;
|
|
66
|
+
disconnect?: () => void;
|
|
67
|
+
unwatch?: () => void;
|
|
68
|
+
record?: InstancePart;
|
|
69
|
+
selected?: string;
|
|
70
|
+
version?: number;
|
|
71
|
+
shown?: boolean;
|
|
72
|
+
dataSlot?: string;
|
|
73
|
+
sync?: () => void;
|
|
74
|
+
reread?: () => Record<string, unknown>;
|
|
75
|
+
keyed?: boolean;
|
|
76
|
+
observer?: MutationObserver;
|
|
77
|
+
};
|
|
78
|
+
declare function reconfigureInside(el: HTMLElement): void;
|
|
79
|
+
type OwnerElement = HTMLElement & {
|
|
80
|
+
register: (part: Part) => void;
|
|
81
|
+
unregister: (part: Part) => void;
|
|
82
|
+
update: (part: Part, rebind: boolean) => void;
|
|
83
|
+
rebind: () => void;
|
|
84
|
+
};
|
|
85
|
+
/** Popups inside `container` inherit `to` instead, or render in place for null. */
|
|
86
|
+
declare function passPortalOn(container: Element, to: Element | DocumentFragment | null): void;
|
|
87
|
+
/**
|
|
88
|
+
* The container the nearest portaled part above `el` renders into. A popup
|
|
89
|
+
* inside a portaled popup renders there too, unless it names its own.
|
|
90
|
+
*/
|
|
91
|
+
declare function inheritedPortal(el: Element): Element | DocumentFragment | null;
|
|
92
|
+
/**
|
|
93
|
+
* The nearest owner above `el`, or the owner of the nearest part above it.
|
|
94
|
+
* Popups may have moved to a portal, so the DOM alone can't answer. A part with
|
|
95
|
+
* `for="id"` names its owner anywhere on the page, like a trigger in a table row.
|
|
96
|
+
* Parts of other components in between are skipped, like a popover trigger
|
|
97
|
+
* inside a tooltip trigger.
|
|
98
|
+
*/
|
|
99
|
+
declare function findOwner(el: Element, selector: string): OwnerElement | undefined;
|
|
100
|
+
/**
|
|
101
|
+
* The element `selector` matches, like a popup's `container="#id"`. Looked up
|
|
102
|
+
* in the element's own tree first, like `for`, then in each tree around it up
|
|
103
|
+
* to the document, so a popup in a shadow root can name a container outside it.
|
|
104
|
+
*/
|
|
105
|
+
declare function findContainer(el: Element, selector: string): Element | null;
|
|
106
|
+
declare function whenGone(el: HTMLElement, run: () => void): void;
|
|
107
|
+
type OwnerConfig<P extends Primitive> = {
|
|
108
|
+
/**
|
|
109
|
+
* Attributes, by option name in camelCase. Each is read from its kebab-case
|
|
110
|
+
* attribute, observed, and parsed by its type. `debug` is always there.
|
|
111
|
+
*/
|
|
112
|
+
attributes?: Record<string, AttributeType>;
|
|
113
|
+
/** Options that don't come from attributes, like a group found in the page. */
|
|
114
|
+
options?: (el: HTMLElement) => Partial<OptionsOf<P>>;
|
|
115
|
+
/**
|
|
116
|
+
* Live properties for the state a user controls, like `open` or `value`.
|
|
117
|
+
* Setting one changes the state as a controller would, and fires the
|
|
118
|
+
* change event. An attribute of the same name sets the starting state, and
|
|
119
|
+
* changing it later changes the state the same way.
|
|
120
|
+
*/
|
|
121
|
+
state?: Record<string, {
|
|
122
|
+
get: (api: any) => unknown;
|
|
123
|
+
set: (api: any, value: any) => void;
|
|
124
|
+
}>;
|
|
125
|
+
/** The controller's methods, which the element's `api` property exposes. */
|
|
126
|
+
api?: string[];
|
|
127
|
+
/** Callbacks that fire no event, because part elements already report them. */
|
|
128
|
+
silent?: string[];
|
|
129
|
+
/** Callbacks whose event hands listeners `waitUntil()`, from the schema's `"action"` kind. */
|
|
130
|
+
actions?: string[];
|
|
131
|
+
/**
|
|
132
|
+
* Event names for callbacks whose own name a native event that bubbles in
|
|
133
|
+
* already takes, like `{ onSelect: "itemselect" }` beside a text field's `select`.
|
|
134
|
+
*/
|
|
135
|
+
events?: Record<string, string>;
|
|
136
|
+
/**
|
|
137
|
+
* Runs once the instance exists, and again when a property is set, with
|
|
138
|
+
* the element and its instance, which only this hook sees. Data elements
|
|
139
|
+
* render their parts here. A returned cleanup runs before the next render
|
|
140
|
+
* and once the element is gone, like a store subscription's.
|
|
141
|
+
*/
|
|
142
|
+
render?: (el: HTMLElement, instance: ReturnType<P>) => void | (() => void);
|
|
143
|
+
/**
|
|
144
|
+
* Attributes for the element itself, like role="none" on wrappers that
|
|
145
|
+
* must not split a list for assistive technology.
|
|
146
|
+
*/
|
|
147
|
+
host?: Record<string, string>;
|
|
148
|
+
/** The element's CSS display. `contents` keeps it out of layout, for wrappers. Inline by default. */
|
|
149
|
+
display?: PartDisplay;
|
|
150
|
+
/** The slot the element itself fills, like the root of a tabs widget. */
|
|
151
|
+
self?: string;
|
|
152
|
+
/**
|
|
153
|
+
* Native elements inside it that fill slots, like the <fieldset> inside
|
|
154
|
+
* <ui-field-set>. They keep their native behavior, which a custom element can't
|
|
155
|
+
* have, like a fieldset disabling the controls inside it. A missing one
|
|
156
|
+
* warns, unless its slot is in `optionalChildren`, like a fieldset's legend.
|
|
157
|
+
*/
|
|
158
|
+
children?: Record<string, (el: HTMLElement) => HTMLElement | null>;
|
|
159
|
+
/**
|
|
160
|
+
* The element the `self` slot binds to, when it isn't the element itself,
|
|
161
|
+
* like the <button> inside <ui-button>, so native button behavior stays.
|
|
162
|
+
*/
|
|
163
|
+
target?: (el: HTMLElement) => HTMLElement | null;
|
|
164
|
+
/** Slots in `children` that may be missing without a warning, like a fieldset's legend. */
|
|
165
|
+
optionalChildren?: string[];
|
|
166
|
+
/**
|
|
167
|
+
* The native children's attributes that props or options follow, like an
|
|
168
|
+
* <input>'s `disabled`, `readonly` and `required`, or its `autocomplete`.
|
|
169
|
+
* A change reads `read` and the options again.
|
|
170
|
+
*/
|
|
171
|
+
childProps?: {
|
|
172
|
+
attributes: string[];
|
|
173
|
+
read?: (el: HTMLElement) => Record<string, unknown>;
|
|
174
|
+
};
|
|
175
|
+
/**
|
|
176
|
+
* Slots that move into a container while present, like popups. Without
|
|
177
|
+
* top layer support they move to the body. The container is asked on
|
|
178
|
+
* every sync, with the part, so a part can move while bound, like a
|
|
179
|
+
* navigation menu's content into its viewport as it opens.
|
|
180
|
+
*/
|
|
181
|
+
portal?: {
|
|
182
|
+
slots: string[];
|
|
183
|
+
container: (el: HTMLElement, part: {
|
|
184
|
+
slot: string;
|
|
185
|
+
el: HTMLElement;
|
|
186
|
+
props: Record<string, unknown>;
|
|
187
|
+
}) => Element | DocumentFragment | null;
|
|
188
|
+
};
|
|
189
|
+
/**
|
|
190
|
+
* Properties, like a data menu's items or a `controller`. Each one set goes
|
|
191
|
+
* into the options, and setting one updates them and renders again.
|
|
192
|
+
*/
|
|
193
|
+
properties?: string[];
|
|
194
|
+
/** Takes part in forms like a native control, like <ui-checkbox name="terms">. */
|
|
195
|
+
formAssociated?: boolean;
|
|
196
|
+
/**
|
|
197
|
+
* Boolean options that start on, like `{ loop: true }`, so their
|
|
198
|
+
* properties read true without the attribute and `false` writes "false".
|
|
199
|
+
* A function decides from the element, like `closeOnOutsidePress` from `modal`.
|
|
200
|
+
*/
|
|
201
|
+
defaults?: Partial<Record<keyof OptionsOf<P> & string, BooleanDefaults[string]>>;
|
|
202
|
+
};
|
|
203
|
+
type SlotConfig = {
|
|
204
|
+
/** The owner primitive's slot this element fills. */
|
|
205
|
+
slot: string;
|
|
206
|
+
/** Owner elements this part can belong to. */
|
|
207
|
+
owner: string;
|
|
208
|
+
/** Attributes read as props, by name in camelCase, each with its type. */
|
|
209
|
+
props?: Record<string, AttributeType>;
|
|
210
|
+
/** Props that come from the surroundings, like the group a radio item is in. */
|
|
211
|
+
context?: (el: HTMLElement) => Record<string, unknown>;
|
|
212
|
+
/**
|
|
213
|
+
* Props that, left out, come from a prop of the nearest part around it of
|
|
214
|
+
* the slot named, like a handle's `value` from its item's.
|
|
215
|
+
*/
|
|
216
|
+
from?: Record<string, {
|
|
217
|
+
slot: string;
|
|
218
|
+
prop: string;
|
|
219
|
+
}>;
|
|
220
|
+
/** Props made unique for each element, like an icon's `id`. */
|
|
221
|
+
ids?: string[];
|
|
222
|
+
/**
|
|
223
|
+
* The element the slot binds to, when it isn't the part itself. Without it,
|
|
224
|
+
* an as-child attribute binds the part's first child instead, like a link.
|
|
225
|
+
*/
|
|
226
|
+
target?: (el: HTMLElement) => HTMLElement | null;
|
|
227
|
+
/** Runs once before the first registration, to add generated children. */
|
|
228
|
+
render?: (el: HTMLElement) => void;
|
|
229
|
+
/** Runs when one of its `props` attributes changes, for generated children that follow it. */
|
|
230
|
+
changed?: (el: HTMLElement) => void;
|
|
231
|
+
/** The element's CSS display. `contents` keeps it out of layout, for wrappers. Inline by default. */
|
|
232
|
+
display?: PartDisplay;
|
|
233
|
+
/** Form-associated, so labels and fieldsets treat it like a native control. */
|
|
234
|
+
formAssociated?: boolean;
|
|
235
|
+
/** Properties read as props, like a trigger's `payload`. Setting one re-syncs the part. */
|
|
236
|
+
properties?: string[];
|
|
237
|
+
/** Boolean props that start on, like `{ closeOnSelect: true }`, as the owner's `defaults`. */
|
|
238
|
+
defaults?: BooleanDefaults;
|
|
239
|
+
/** Props the part's core binding reads once, so a change binds it again. */
|
|
240
|
+
rebind?: string[];
|
|
241
|
+
/** @internal The feature that ships the slot, like a select's select-all option. */
|
|
242
|
+
feature?: Feature;
|
|
243
|
+
/**
|
|
244
|
+
* @internal Runs on the element the part binds when no owner is around it,
|
|
245
|
+
* in place of the warning that it needs one, for a part that works alone,
|
|
246
|
+
* like a field label wrapping a whole field. It gets the bound element and
|
|
247
|
+
* the part element, which holds the attributes, and runs again when they change.
|
|
248
|
+
*/
|
|
249
|
+
alone?: (el: HTMLElement, host: HTMLElement) => void;
|
|
250
|
+
/** Callbacks whose event hands listeners `waitUntil()`, from the schema's `"action"` kind. */
|
|
251
|
+
actions?: string[];
|
|
252
|
+
/** Whether its `value` keys it, like a list item's, from the schema's `"key"` kind. */
|
|
253
|
+
keyed?: boolean;
|
|
254
|
+
};
|
|
255
|
+
/**
|
|
256
|
+
* Web-only kinds that replace the schema's, by prop name, like
|
|
257
|
+
* `{ container: "string" }` for a container named by a selector. `null`
|
|
258
|
+
* leaves a prop out, for one the element sets itself, like a group it finds
|
|
259
|
+
* around it.
|
|
260
|
+
* @stable
|
|
261
|
+
*/
|
|
262
|
+
type Kinds = Record<string, PropSpec | null>;
|
|
263
|
+
/**
|
|
264
|
+
* How `createParts` and `definePart` define a part's element, beyond its tag.
|
|
265
|
+
* @stable
|
|
266
|
+
*/
|
|
267
|
+
type PartOptions<P extends Primitive = Primitive> = {
|
|
268
|
+
/** The element's tag, like `"ui-tabs-tab"`. */
|
|
269
|
+
tag: string;
|
|
270
|
+
/**
|
|
271
|
+
* The slot it fills, when it isn't its key, like a radio filling the root
|
|
272
|
+
* slot of a radio group whose own element is the group.
|
|
273
|
+
*/
|
|
274
|
+
slot?: SlotName<P>;
|
|
275
|
+
/** Owners of another primitive it belongs to as well, like a calendar day's <ui-date-picker>. */
|
|
276
|
+
owners?: string[];
|
|
277
|
+
kinds?: Kinds;
|
|
278
|
+
/** Properties beyond the schema's, read as props. */
|
|
279
|
+
properties?: string[];
|
|
280
|
+
} & Omit<SlotConfig, "slot" | "owner" | "props" | "properties" | "from" | "ids" | "actions" | "keyed">;
|
|
281
|
+
/**
|
|
282
|
+
* How `createParts` and `definePart` define the root's element, the one that owns an instance, beyond its tag.
|
|
283
|
+
* @stable
|
|
284
|
+
*/
|
|
285
|
+
type RootOptions<P extends Primitive> = {
|
|
286
|
+
/** The element's tag, like `"ui-tabs"`. */
|
|
287
|
+
tag: string;
|
|
288
|
+
/**
|
|
289
|
+
* The slot the element itself fills, when it isn't `root`, like a radio
|
|
290
|
+
* group's `group`. Without one, it fills `root` when the primitive has it
|
|
291
|
+
* and no native child fills it.
|
|
292
|
+
*/
|
|
293
|
+
self?: SlotName<P>;
|
|
294
|
+
kinds?: Kinds;
|
|
295
|
+
/**
|
|
296
|
+
* Properties beyond the schema's, which go into the options, like a
|
|
297
|
+
* `filter` function beside its attribute.
|
|
298
|
+
*/
|
|
299
|
+
properties?: string[];
|
|
300
|
+
/**
|
|
301
|
+
* Live properties for the state a user controls, like `open` or `value`.
|
|
302
|
+
* Setting one changes the state as a controller would, and fires the
|
|
303
|
+
* change event. An attribute of the same name sets the starting state, and
|
|
304
|
+
* changing it later changes the state the same way.
|
|
305
|
+
*/
|
|
306
|
+
state?: Record<string, {
|
|
307
|
+
get: (api: TypesOf<P>["api"]) => unknown;
|
|
308
|
+
set: (api: TypesOf<P>["api"], value: any) => void;
|
|
309
|
+
}>;
|
|
310
|
+
/** The controller's methods, which the element's `api` property exposes. */
|
|
311
|
+
api?: (keyof TypesOf<P>["api"] & string)[];
|
|
312
|
+
} & Omit<OwnerConfig<P>, "attributes" | "properties" | "self" | "state" | "api" | "actions">;
|
|
313
|
+
/**
|
|
314
|
+
* What `definePart` defines for a slot: for `root`, the element that owns an
|
|
315
|
+
* instance, with the primitive's options as attributes and properties; for
|
|
316
|
+
* any other slot, an element that finds that owner, with the slot's props.
|
|
317
|
+
* The kinds come from the primitive's schema. A root's tag is remembered, so
|
|
318
|
+
* the parts defined after it find their owner. The docs' elements manifest
|
|
319
|
+
* reads it too.
|
|
320
|
+
*/
|
|
321
|
+
declare function partElement<P extends Primitive>(primitive: P, key: string, tagOrOptions: string | RootOptions<P> | PartOptions<P>, root?: string): {
|
|
322
|
+
kind: "owner";
|
|
323
|
+
key: string;
|
|
324
|
+
tagName: string;
|
|
325
|
+
config: OwnerConfig<P>;
|
|
326
|
+
} | {
|
|
327
|
+
kind: "part";
|
|
328
|
+
key: string;
|
|
329
|
+
tagName: string;
|
|
330
|
+
config: SlotConfig;
|
|
331
|
+
};
|
|
332
|
+
/**
|
|
333
|
+
* The tags `createParts` takes: `root` for the element that owns an
|
|
334
|
+
* instance, and each slot it renders by name. A part under another key
|
|
335
|
+
* names its slot, like `{ radio: { tag: "ui-radio", slot: "root" } }`.
|
|
336
|
+
*/
|
|
337
|
+
type PartTags<P extends Primitive> = {
|
|
338
|
+
root: string | RootOptions<P>;
|
|
339
|
+
} & {
|
|
340
|
+
[S in Exclude<SlotName<P>, "root">]?: string | PartOptions<P>;
|
|
341
|
+
};
|
|
342
|
+
/**
|
|
343
|
+
* Every element `createParts` defines, as `partElement` describes each, the
|
|
344
|
+
* root first, so its parts know their owner's tag.
|
|
345
|
+
*/
|
|
346
|
+
declare function partElements<P extends Primitive>(primitive: P, tags: PartTags<P>): ({
|
|
347
|
+
kind: "owner";
|
|
348
|
+
key: string;
|
|
349
|
+
tagName: string;
|
|
350
|
+
config: OwnerConfig<P>;
|
|
351
|
+
} | {
|
|
352
|
+
kind: "part";
|
|
353
|
+
key: string;
|
|
354
|
+
tagName: string;
|
|
355
|
+
config: SlotConfig;
|
|
356
|
+
})[];
|
|
357
|
+
type Pascal<Name extends string> = Name extends `${infer Head}-${infer Tail}` ? `${Capitalize<Head>}${Pascal<Tail>}` : Capitalize<Name>;
|
|
358
|
+
/**
|
|
359
|
+
* The element classes `createParts` returns: `Root`, and one per tagged
|
|
360
|
+
* part, named in Pascal case. Each is `undefined` on the server.
|
|
361
|
+
* @stable
|
|
362
|
+
*/
|
|
363
|
+
type Parts<Tags> = {
|
|
364
|
+
[K in keyof Tags & string as Pascal<K>]: CustomElementConstructor | undefined;
|
|
365
|
+
};
|
|
366
|
+
/**
|
|
367
|
+
* Defines a custom element for each part of a primitive, typed from it.
|
|
368
|
+
* `root` is the element that owns an instance: the primitive's options are
|
|
369
|
+
* its attributes (strings, numbers, booleans and comma-separated lists),
|
|
370
|
+
* each reflected by a property, and properties (any other value), and its
|
|
371
|
+
* callbacks are events, like
|
|
372
|
+
* `onValueChange` firing `valuechange`. Every other slot named becomes an
|
|
373
|
+
* element that finds the root above it, with the slot's props read the same
|
|
374
|
+
* way. A part that needs more than a tag takes an object, like
|
|
375
|
+
* `{ tag, display, target, render }`, and the root's takes `state`, `api` and
|
|
376
|
+
* `display` too. Defines each tag once, and returns the element classes,
|
|
377
|
+
* `Root` and one per part named in Pascal case, like `TabIcon` for
|
|
378
|
+
* `tab-icon`. On the server it defines nothing and the classes are
|
|
379
|
+
* `undefined`.
|
|
380
|
+
*
|
|
381
|
+
* @example
|
|
382
|
+
* createParts(tabs, {
|
|
383
|
+
* root: { tag: "ui-tabs", display: "block", api: ["select"] },
|
|
384
|
+
* list: "ui-tabs-list",
|
|
385
|
+
* // Binds the <button> inside, so it stays a real button.
|
|
386
|
+
* tab: { tag: "ui-tabs-tab", display: "contents", target: wrappedButton },
|
|
387
|
+
* panel: "ui-tabs-panel",
|
|
388
|
+
* })
|
|
389
|
+
* @stable
|
|
390
|
+
*/
|
|
391
|
+
declare function createParts<P extends Primitive, Tags extends PartTags<P>>(primitive: P, tags: Tags): Parts<Tags>;
|
|
392
|
+
/**
|
|
393
|
+
* Defines the custom element for one part of a primitive, written by hand:
|
|
394
|
+
* the root, which owns an instance, or a part that finds the root above it.
|
|
395
|
+
* Its attributes, properties and events come from the primitive's schema, as
|
|
396
|
+
* in `createParts`. Define the root first. A second root of the same
|
|
397
|
+
* primitive, like a submenu's, owns the parts defined after it too.
|
|
398
|
+
*
|
|
399
|
+
* @example
|
|
400
|
+
* definePart(rating, "root", "my-rating")
|
|
401
|
+
* definePart(rating, "star", { tag: "my-rating-star", target: wrappedButton })
|
|
402
|
+
*/
|
|
403
|
+
declare function definePart<P extends Primitive, S extends SlotName<P> | "root">(primitive: P, slot: S, tagOrOptions: S extends "root" ? string | RootOptions<P> : string | PartOptions<P>): void;
|
|
404
|
+
export { type AttributeType, autoId, claimTag, createParts, definePart, findContainer, findOwner, inheritedPortal, instanceOf, type Kinds, ownButton, parseAttribute, type PartDisplay, partElement, partElements, type PartOptions, type Parts, type PartTags, passPortalOn, type RootOptions, reconfigureInside, setDisplay, upgradeProperties, whenGone, wrappedButton, wrappedChild, };
|