@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
package/dist/index.js
ADDED
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import {
|
|
3
|
+
createParts,
|
|
4
|
+
wrappedButton,
|
|
5
|
+
wrappedChild
|
|
6
|
+
} from "./define-element.js";
|
|
7
|
+
import { createDrawerController, sheetPhysics } from "@ui-sdk/core/drawer";
|
|
8
|
+
import {
|
|
9
|
+
createOverlays,
|
|
10
|
+
overlays
|
|
11
|
+
} from "./overlays.js";
|
|
12
|
+
import { createToaster, toast } from "./toast.js";
|
|
13
|
+
import {
|
|
14
|
+
confirm,
|
|
15
|
+
createConfirm,
|
|
16
|
+
createDialogController
|
|
17
|
+
} from "@ui-sdk/core/dialog";
|
|
18
|
+
import { createMenuController } from "@ui-sdk/core/menu";
|
|
19
|
+
import {
|
|
20
|
+
createTriggerMenuController,
|
|
21
|
+
textFieldAdapter
|
|
22
|
+
} from "@ui-sdk/core/trigger-menu";
|
|
23
|
+
import {
|
|
24
|
+
createResizableController,
|
|
25
|
+
resizableStorageKey
|
|
26
|
+
} from "@ui-sdk/core/resizable";
|
|
27
|
+
import {
|
|
28
|
+
createFileInputController,
|
|
29
|
+
formatFileSize,
|
|
30
|
+
relativePath
|
|
31
|
+
} from "@ui-sdk/core/file-input";
|
|
32
|
+
import {
|
|
33
|
+
createPaginationController,
|
|
34
|
+
paginationRange
|
|
35
|
+
} from "@ui-sdk/core/pagination";
|
|
36
|
+
import { createCarouselController } from "@ui-sdk/core/carousel";
|
|
37
|
+
import { createCalendarController } from "@ui-sdk/core/calendar";
|
|
38
|
+
import { createDatePickerController } from "@ui-sdk/core/date-picker";
|
|
39
|
+
import { createDateInputController } from "@ui-sdk/core/date-input";
|
|
40
|
+
import { createTimeInputController } from "@ui-sdk/core/time-input";
|
|
41
|
+
import { createAccordionController } from "@ui-sdk/core/accordion";
|
|
42
|
+
import { createAlertDialogController } from "@ui-sdk/core/alert-dialog";
|
|
43
|
+
import { createAutocompleteController } from "@ui-sdk/core/autocomplete";
|
|
44
|
+
import {
|
|
45
|
+
createCheckboxController,
|
|
46
|
+
createCheckboxGroupController
|
|
47
|
+
} from "@ui-sdk/core/checkbox";
|
|
48
|
+
import { createTimelineController } from "@ui-sdk/core/timeline";
|
|
49
|
+
import { createCollapsibleController } from "@ui-sdk/core/collapsible";
|
|
50
|
+
import { createColorPickerController } from "@ui-sdk/core/color-picker";
|
|
51
|
+
import { createComboboxController } from "@ui-sdk/core/combobox";
|
|
52
|
+
import { createCommandController } from "@ui-sdk/core/command";
|
|
53
|
+
import { createHoverCardController } from "@ui-sdk/core/hover-card";
|
|
54
|
+
import { createImageCropperController } from "@ui-sdk/core/image-cropper";
|
|
55
|
+
import { createInputController } from "@ui-sdk/core/input";
|
|
56
|
+
import { createListboxController } from "@ui-sdk/core/listbox";
|
|
57
|
+
import { createMenubarController } from "@ui-sdk/core/menubar";
|
|
58
|
+
import { createNavigationMenuController } from "@ui-sdk/core/navigation-menu";
|
|
59
|
+
import { createNumberInputController } from "@ui-sdk/core/number-input";
|
|
60
|
+
import { createOTPInputController } from "@ui-sdk/core/otp-input";
|
|
61
|
+
import { createPasswordInputController } from "@ui-sdk/core/password-input";
|
|
62
|
+
import { createPopoverController } from "@ui-sdk/core/popover";
|
|
63
|
+
import { createRadioGroupController } from "@ui-sdk/core/radio";
|
|
64
|
+
import { createRatingController } from "@ui-sdk/core/rating";
|
|
65
|
+
import { createScrollAreaController } from "@ui-sdk/core/scroll-area";
|
|
66
|
+
import { createSegmentedControlController } from "@ui-sdk/core/segmented-control";
|
|
67
|
+
import { createSelectController } from "@ui-sdk/core/select";
|
|
68
|
+
import { createSliderController } from "@ui-sdk/core/slider";
|
|
69
|
+
import { createSwitchController } from "@ui-sdk/core/switch";
|
|
70
|
+
import { createTabsController } from "@ui-sdk/core/tabs";
|
|
71
|
+
import {
|
|
72
|
+
createToggleController,
|
|
73
|
+
createToggleGroupController
|
|
74
|
+
} from "@ui-sdk/core/toggle";
|
|
75
|
+
import { createTokenInputController } from "@ui-sdk/core/token-input";
|
|
76
|
+
import { createToolbarController } from "@ui-sdk/core/toolbar";
|
|
77
|
+
import { createTooltipController } from "@ui-sdk/core/tooltip";
|
|
78
|
+
import { createTreeController } from "@ui-sdk/core/tree";
|
|
79
|
+
import { createWaterfallController } from "@ui-sdk/core/waterfall";
|
|
80
|
+
import { fuzzyScore, matchRanges, matchSegments } from "@ui-sdk/core/text-match";
|
|
81
|
+
import {
|
|
82
|
+
addDays,
|
|
83
|
+
addMonths,
|
|
84
|
+
addYears,
|
|
85
|
+
clampDate,
|
|
86
|
+
dateFormatter,
|
|
87
|
+
dateParts,
|
|
88
|
+
datePattern,
|
|
89
|
+
daysBetween,
|
|
90
|
+
daysInMonth,
|
|
91
|
+
endOfMonth,
|
|
92
|
+
endOfWeek,
|
|
93
|
+
firstDayOfWeek,
|
|
94
|
+
formatDate,
|
|
95
|
+
formatDateRange,
|
|
96
|
+
formatDateToParts,
|
|
97
|
+
isISODate,
|
|
98
|
+
isSameMonth,
|
|
99
|
+
isoDate,
|
|
100
|
+
monthGrid,
|
|
101
|
+
monthNames,
|
|
102
|
+
parseDate,
|
|
103
|
+
startOfMonth,
|
|
104
|
+
startOfWeek,
|
|
105
|
+
toISODate,
|
|
106
|
+
todayDate,
|
|
107
|
+
weekday,
|
|
108
|
+
weekdayNames
|
|
109
|
+
} from "@ui-sdk/core/date";
|
|
110
|
+
import {
|
|
111
|
+
clamp,
|
|
112
|
+
decimalsOf,
|
|
113
|
+
formatNumber,
|
|
114
|
+
formatNumberRange,
|
|
115
|
+
formatNumberToParts,
|
|
116
|
+
fractionOf,
|
|
117
|
+
isPartialNumber,
|
|
118
|
+
maxOnGrid,
|
|
119
|
+
numberFormatter,
|
|
120
|
+
parseNumber,
|
|
121
|
+
roundTo,
|
|
122
|
+
scrubTo,
|
|
123
|
+
stepBy,
|
|
124
|
+
stepFromKey,
|
|
125
|
+
stepValue,
|
|
126
|
+
valueAt,
|
|
127
|
+
wrap
|
|
128
|
+
} from "@ui-sdk/core/number";
|
|
129
|
+
import {
|
|
130
|
+
colorDistance,
|
|
131
|
+
contrastRatio,
|
|
132
|
+
convertColor,
|
|
133
|
+
formatColor,
|
|
134
|
+
isInGamut,
|
|
135
|
+
mixColor,
|
|
136
|
+
parseColor,
|
|
137
|
+
toGamut
|
|
138
|
+
} from "@ui-sdk/core/color";
|
|
139
|
+
import { cropImage } from "@ui-sdk/core/image";
|
|
140
|
+
import {
|
|
141
|
+
ariaKeyshortcuts,
|
|
142
|
+
formatShortcut,
|
|
143
|
+
registerShortcut,
|
|
144
|
+
shortcuts
|
|
145
|
+
} from "@ui-sdk/core/shortcuts";
|
|
146
|
+
export {
|
|
147
|
+
addDays,
|
|
148
|
+
addMonths,
|
|
149
|
+
addYears,
|
|
150
|
+
ariaKeyshortcuts,
|
|
151
|
+
clamp,
|
|
152
|
+
clampDate,
|
|
153
|
+
colorDistance,
|
|
154
|
+
confirm,
|
|
155
|
+
contrastRatio,
|
|
156
|
+
convertColor,
|
|
157
|
+
createAccordionController,
|
|
158
|
+
createAlertDialogController,
|
|
159
|
+
createAutocompleteController,
|
|
160
|
+
createCalendarController,
|
|
161
|
+
createCarouselController,
|
|
162
|
+
createCheckboxController,
|
|
163
|
+
createCheckboxGroupController,
|
|
164
|
+
createCollapsibleController,
|
|
165
|
+
createColorPickerController,
|
|
166
|
+
createComboboxController,
|
|
167
|
+
createCommandController,
|
|
168
|
+
createConfirm,
|
|
169
|
+
createDateInputController,
|
|
170
|
+
createDatePickerController,
|
|
171
|
+
createDialogController,
|
|
172
|
+
createDrawerController,
|
|
173
|
+
createFileInputController,
|
|
174
|
+
createHoverCardController,
|
|
175
|
+
createImageCropperController,
|
|
176
|
+
createInputController,
|
|
177
|
+
createListboxController,
|
|
178
|
+
createMenuController,
|
|
179
|
+
createMenubarController,
|
|
180
|
+
createNavigationMenuController,
|
|
181
|
+
createNumberInputController,
|
|
182
|
+
createOTPInputController,
|
|
183
|
+
createOverlays,
|
|
184
|
+
createPaginationController,
|
|
185
|
+
createParts,
|
|
186
|
+
createPasswordInputController,
|
|
187
|
+
createPopoverController,
|
|
188
|
+
createRadioGroupController,
|
|
189
|
+
createRatingController,
|
|
190
|
+
createResizableController,
|
|
191
|
+
createScrollAreaController,
|
|
192
|
+
createSegmentedControlController,
|
|
193
|
+
createSelectController,
|
|
194
|
+
createSliderController,
|
|
195
|
+
createSwitchController,
|
|
196
|
+
createTabsController,
|
|
197
|
+
createTimeInputController,
|
|
198
|
+
createTimelineController,
|
|
199
|
+
createToaster,
|
|
200
|
+
createToggleController,
|
|
201
|
+
createToggleGroupController,
|
|
202
|
+
createTokenInputController,
|
|
203
|
+
createToolbarController,
|
|
204
|
+
createTooltipController,
|
|
205
|
+
createTreeController,
|
|
206
|
+
createTriggerMenuController,
|
|
207
|
+
createWaterfallController,
|
|
208
|
+
cropImage,
|
|
209
|
+
dateFormatter,
|
|
210
|
+
dateParts,
|
|
211
|
+
datePattern,
|
|
212
|
+
daysBetween,
|
|
213
|
+
daysInMonth,
|
|
214
|
+
decimalsOf,
|
|
215
|
+
endOfMonth,
|
|
216
|
+
endOfWeek,
|
|
217
|
+
firstDayOfWeek,
|
|
218
|
+
formatColor,
|
|
219
|
+
formatDate,
|
|
220
|
+
formatDateRange,
|
|
221
|
+
formatDateToParts,
|
|
222
|
+
formatFileSize,
|
|
223
|
+
formatNumber,
|
|
224
|
+
formatNumberRange,
|
|
225
|
+
formatNumberToParts,
|
|
226
|
+
formatShortcut,
|
|
227
|
+
fractionOf,
|
|
228
|
+
fuzzyScore,
|
|
229
|
+
isISODate,
|
|
230
|
+
isInGamut,
|
|
231
|
+
isPartialNumber,
|
|
232
|
+
isSameMonth,
|
|
233
|
+
isoDate,
|
|
234
|
+
matchRanges,
|
|
235
|
+
matchSegments,
|
|
236
|
+
maxOnGrid,
|
|
237
|
+
mixColor,
|
|
238
|
+
monthGrid,
|
|
239
|
+
monthNames,
|
|
240
|
+
numberFormatter,
|
|
241
|
+
overlays,
|
|
242
|
+
paginationRange,
|
|
243
|
+
parseColor,
|
|
244
|
+
parseDate,
|
|
245
|
+
parseNumber,
|
|
246
|
+
registerShortcut,
|
|
247
|
+
relativePath,
|
|
248
|
+
resizableStorageKey,
|
|
249
|
+
roundTo,
|
|
250
|
+
scrubTo,
|
|
251
|
+
sheetPhysics,
|
|
252
|
+
shortcuts,
|
|
253
|
+
startOfMonth,
|
|
254
|
+
startOfWeek,
|
|
255
|
+
stepBy,
|
|
256
|
+
stepFromKey,
|
|
257
|
+
stepValue,
|
|
258
|
+
textFieldAdapter,
|
|
259
|
+
toGamut,
|
|
260
|
+
toISODate,
|
|
261
|
+
toast,
|
|
262
|
+
todayDate,
|
|
263
|
+
valueAt,
|
|
264
|
+
weekday,
|
|
265
|
+
weekdayNames,
|
|
266
|
+
wrap,
|
|
267
|
+
wrappedButton,
|
|
268
|
+
wrappedChild
|
|
269
|
+
};
|
package/dist/input.d.ts
ADDED
package/dist/input.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// src/input.ts
|
|
2
|
+
import {
|
|
3
|
+
input,
|
|
4
|
+
inputGroup,
|
|
5
|
+
textarea
|
|
6
|
+
} from "@ui-sdk/core/input";
|
|
7
|
+
import { createParts, wrappedChild } from "./define-element.js";
|
|
8
|
+
var textApi = [
|
|
9
|
+
"getValue",
|
|
10
|
+
"setValue",
|
|
11
|
+
"clear",
|
|
12
|
+
"focus"
|
|
13
|
+
];
|
|
14
|
+
var textState = {
|
|
15
|
+
value: {
|
|
16
|
+
get: (api) => api.getValue(),
|
|
17
|
+
set: (api, value) => api.setValue(value ?? "")
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
var controlProps = {
|
|
21
|
+
attributes: ["disabled", "readonly", "required"],
|
|
22
|
+
read: (el) => {
|
|
23
|
+
const field = el;
|
|
24
|
+
return {
|
|
25
|
+
disabled: field.disabled,
|
|
26
|
+
readOnly: field.readOnly,
|
|
27
|
+
required: field.required
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
function defineInputElements() {
|
|
32
|
+
createParts(input, {
|
|
33
|
+
root: {
|
|
34
|
+
tag: "ui-input",
|
|
35
|
+
display: "contents",
|
|
36
|
+
children: { root: (el) => el.querySelector(":scope > input") },
|
|
37
|
+
childProps: controlProps,
|
|
38
|
+
state: textState,
|
|
39
|
+
api: textApi
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
createParts(textarea, {
|
|
43
|
+
root: {
|
|
44
|
+
tag: "ui-textarea",
|
|
45
|
+
display: "contents",
|
|
46
|
+
children: { root: (el) => el.querySelector(":scope > textarea") },
|
|
47
|
+
childProps: controlProps,
|
|
48
|
+
// The submit shortcut submits the form the textarea is in, so a form's own
|
|
49
|
+
// submit event hears it. A bubbling "submit" event would reach the form too.
|
|
50
|
+
silent: ["onSubmit"],
|
|
51
|
+
state: textState,
|
|
52
|
+
api: textApi
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
function defineInputGroupElements() {
|
|
57
|
+
createParts(inputGroup, {
|
|
58
|
+
root: { tag: "ui-input-group", self: "group", display: "block" },
|
|
59
|
+
clear: {
|
|
60
|
+
tag: "ui-input-clear",
|
|
61
|
+
display: "contents",
|
|
62
|
+
target: wrappedChild("button")
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
export {
|
|
67
|
+
defineInputElements,
|
|
68
|
+
defineInputGroupElements
|
|
69
|
+
};
|
package/dist/label.d.ts
ADDED
package/dist/label.js
ADDED
package/dist/list.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ListData } from "@ui-sdk/core/select";
|
|
2
|
+
declare const templateOf: (el: Element | null | undefined) => HTMLTemplateElement | null;
|
|
3
|
+
declare function copy(template: HTMLTemplateElement | null | undefined, tagName: string, deep?: boolean): HTMLElement;
|
|
4
|
+
declare function element(tagName: string, attributes?: Record<string, string | boolean | undefined>, text?: string, template?: HTMLTemplateElement | null): HTMLElement;
|
|
5
|
+
declare function listAttribute(value: string): string[];
|
|
6
|
+
declare const itemText: {
|
|
7
|
+
context: (el: HTMLElement) => {
|
|
8
|
+
text: string;
|
|
9
|
+
write: boolean;
|
|
10
|
+
};
|
|
11
|
+
kinds: {
|
|
12
|
+
text: null;
|
|
13
|
+
write: null;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
declare const stashedEmpty: {
|
|
17
|
+
display: "block";
|
|
18
|
+
context: () => {
|
|
19
|
+
stash: boolean;
|
|
20
|
+
};
|
|
21
|
+
kinds: {
|
|
22
|
+
stash: null;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
declare function renderListItems(prefix: "ui-select" | "ui-combobox" | "ui-trigger-menu" | "ui-autocomplete" | "ui-command" | "ui-listbox", items: ListData<any>, toKey?: (value: unknown) => string, template?: HTMLTemplateElement | null): HTMLElement[];
|
|
26
|
+
declare function valuesOf(keys: string[], items: ListData<unknown> | undefined, itemToValue?: (value: unknown) => string): {}[];
|
|
27
|
+
declare function adoptDefaultValue(el: HTMLElement, items: ListData<unknown> | undefined, api: {
|
|
28
|
+
getValue: () => unknown;
|
|
29
|
+
internal: {
|
|
30
|
+
adoptValue: (value: unknown) => void;
|
|
31
|
+
options: () => {
|
|
32
|
+
itemToValue?: (value: any) => string;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
} | undefined): void;
|
|
36
|
+
/** Whether a part was rendered from data, rather than written in the markup. */
|
|
37
|
+
declare const isGenerated: (el: Element) => boolean;
|
|
38
|
+
declare function renderData(list: Element, prefix: "ui-select" | "ui-autocomplete" | "ui-command", visible: ListData<any>, template: HTMLTemplateElement | null, toKey?: (value: unknown) => string): void;
|
|
39
|
+
declare function placeItems(list: Element, fresh: Element[], owned: (el: Element) => boolean, selectAll: string): void;
|
|
40
|
+
export { adoptDefaultValue, copy, element, isGenerated, itemText, listAttribute, placeItems, renderData, renderListItems, stashedEmpty, templateOf, valuesOf, };
|
package/dist/list.js
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
// src/list.ts
|
|
2
|
+
import { flattenData, itemKey } from "@ui-sdk/core/renderer";
|
|
3
|
+
var templateOf = (el) => el?.querySelector(":scope > template") ?? null;
|
|
4
|
+
function copy(template, tagName, deep = true) {
|
|
5
|
+
const model = template?.content.querySelector(tagName);
|
|
6
|
+
return model ? model.cloneNode(deep) : document.createElement(tagName);
|
|
7
|
+
}
|
|
8
|
+
function element(tagName, attributes = {}, text, template) {
|
|
9
|
+
const el = copy(template, tagName);
|
|
10
|
+
for (const [name, value] of Object.entries(attributes)) {
|
|
11
|
+
if (value === void 0 || value === false) {
|
|
12
|
+
continue;
|
|
13
|
+
}
|
|
14
|
+
el.setAttribute(name, value === true ? "" : value);
|
|
15
|
+
}
|
|
16
|
+
if (text) {
|
|
17
|
+
const slot = el.querySelector(`${tagName}-text`);
|
|
18
|
+
if (slot) {
|
|
19
|
+
slot.textContent = text;
|
|
20
|
+
} else {
|
|
21
|
+
el.prepend(text);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return el;
|
|
25
|
+
}
|
|
26
|
+
function listAttribute(value) {
|
|
27
|
+
return value.split(",").map((item) => item.trim()).filter(Boolean);
|
|
28
|
+
}
|
|
29
|
+
var itemText = {
|
|
30
|
+
context: (el) => ({ text: el.textContent ?? "", write: true }),
|
|
31
|
+
kinds: { text: null, write: null }
|
|
32
|
+
};
|
|
33
|
+
var stashedEmpty = {
|
|
34
|
+
display: "block",
|
|
35
|
+
context: () => ({ stash: true }),
|
|
36
|
+
kinds: { stash: null }
|
|
37
|
+
};
|
|
38
|
+
function renderListItems(prefix, items, toKey = (value) => String(value), template) {
|
|
39
|
+
return items.map((entry) => {
|
|
40
|
+
if (typeof entry === "string") {
|
|
41
|
+
return element(
|
|
42
|
+
`${prefix}-item`,
|
|
43
|
+
{ value: entry, label: entry },
|
|
44
|
+
entry,
|
|
45
|
+
template
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
if ("type" in entry && entry.type === "separator") {
|
|
49
|
+
return element(`${prefix}-separator`, {}, "", template);
|
|
50
|
+
}
|
|
51
|
+
if ("type" in entry && entry.type === "group") {
|
|
52
|
+
const group = copy(template, `${prefix}-group`, false);
|
|
53
|
+
if (entry.label) {
|
|
54
|
+
group.append(
|
|
55
|
+
element(`${prefix}-group-label`, {}, entry.label, template)
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
group.append(...renderListItems(prefix, entry.items, toKey, template));
|
|
59
|
+
return group;
|
|
60
|
+
}
|
|
61
|
+
const data = entry;
|
|
62
|
+
const el = element(
|
|
63
|
+
`${prefix}-item`,
|
|
64
|
+
{ value: toKey(data.value), label: data.label, disabled: data.disabled },
|
|
65
|
+
data.label,
|
|
66
|
+
template
|
|
67
|
+
);
|
|
68
|
+
if (data.keywords) {
|
|
69
|
+
el.setAttribute("keywords", data.keywords.join(","));
|
|
70
|
+
}
|
|
71
|
+
if (data.shortcut) {
|
|
72
|
+
el.setAttribute("shortcut", data.shortcut);
|
|
73
|
+
}
|
|
74
|
+
return el;
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
function valuesOf(keys, items, itemToValue) {
|
|
78
|
+
if (!items) {
|
|
79
|
+
return keys;
|
|
80
|
+
}
|
|
81
|
+
const byKey = new Map(
|
|
82
|
+
flattenData(items, (value) => itemKey(value, itemToValue)).map((entry) => [
|
|
83
|
+
entry.key,
|
|
84
|
+
entry
|
|
85
|
+
])
|
|
86
|
+
);
|
|
87
|
+
return keys.map((key) => byKey.get(key)?.value ?? key);
|
|
88
|
+
}
|
|
89
|
+
function adoptDefaultValue(el, items, api) {
|
|
90
|
+
const start = el.getAttribute("default-value") ?? el.getAttribute("value");
|
|
91
|
+
if (start === null || !items || !api) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const multiple = el.hasAttribute("multiple") && el.getAttribute("multiple") !== "false";
|
|
95
|
+
const keys = multiple ? listAttribute(start) : [start];
|
|
96
|
+
const current = api.getValue();
|
|
97
|
+
const named = multiple ? Array.isArray(current) && current.length === keys.length && current.every((value, index) => value === keys[index]) : current === keys[0];
|
|
98
|
+
if (!named) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const values = valuesOf(keys, items, api.internal.options().itemToValue);
|
|
102
|
+
if (values.every((value, index) => value === keys[index])) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
api.internal.adoptValue(multiple ? values : values[0]);
|
|
106
|
+
}
|
|
107
|
+
var generatedItems = /* @__PURE__ */ new WeakSet();
|
|
108
|
+
var renderedData = /* @__PURE__ */ new WeakMap();
|
|
109
|
+
var isGenerated = (el) => generatedItems.has(el);
|
|
110
|
+
function renderData(list, prefix, visible, template, toKey) {
|
|
111
|
+
const own = Array.from(list.querySelectorAll(`${prefix}-item`)).some(
|
|
112
|
+
(item) => !generatedItems.has(item)
|
|
113
|
+
);
|
|
114
|
+
if (!own && renderedData.get(list) === visible) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
if (own) {
|
|
118
|
+
for (const child of Array.from(list.children)) {
|
|
119
|
+
if (generatedItems.has(child)) {
|
|
120
|
+
child.remove();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
renderedData.delete(list);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
renderedData.set(list, visible);
|
|
127
|
+
const fresh = renderListItems(prefix, visible, toKey, template);
|
|
128
|
+
for (const el of fresh) {
|
|
129
|
+
generatedItems.add(el);
|
|
130
|
+
el.querySelectorAll(`${prefix}-item`).forEach(
|
|
131
|
+
(item) => generatedItems.add(item)
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
placeItems(list, fresh, isGenerated, `${prefix}-select-all`);
|
|
135
|
+
}
|
|
136
|
+
var madeFrom = /* @__PURE__ */ new WeakMap();
|
|
137
|
+
function placeItems(list, fresh, owned, selectAll) {
|
|
138
|
+
const kept = /* @__PURE__ */ new Map();
|
|
139
|
+
for (const child of list.children) {
|
|
140
|
+
const made = madeFrom.get(child);
|
|
141
|
+
if (made !== void 0 && owned(child) && !kept.has(made)) {
|
|
142
|
+
kept.set(made, child);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
const items = fresh.map((el) => {
|
|
146
|
+
const made = el.outerHTML;
|
|
147
|
+
const old = kept.get(made);
|
|
148
|
+
if (old) {
|
|
149
|
+
kept.delete(made);
|
|
150
|
+
return old;
|
|
151
|
+
}
|
|
152
|
+
madeFrom.set(el, made);
|
|
153
|
+
return el;
|
|
154
|
+
});
|
|
155
|
+
const wanted = new Set(items);
|
|
156
|
+
for (const child of Array.from(list.children)) {
|
|
157
|
+
if (owned(child) && !wanted.has(child)) {
|
|
158
|
+
child.remove();
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
const current = Array.from(list.children).filter(owned);
|
|
162
|
+
const end = Array.from(list.children).find(
|
|
163
|
+
(child) => !owned(child) && child.localName !== selectAll
|
|
164
|
+
) ?? null;
|
|
165
|
+
const placed = /* @__PURE__ */ new Set();
|
|
166
|
+
let at = 0;
|
|
167
|
+
for (const el of items) {
|
|
168
|
+
while (current[at] && placed.has(current[at])) {
|
|
169
|
+
at++;
|
|
170
|
+
}
|
|
171
|
+
if (current[at] === el) {
|
|
172
|
+
at++;
|
|
173
|
+
} else {
|
|
174
|
+
list.insertBefore(el, current[at] ?? end);
|
|
175
|
+
}
|
|
176
|
+
placed.add(el);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
export {
|
|
180
|
+
adoptDefaultValue,
|
|
181
|
+
copy,
|
|
182
|
+
element,
|
|
183
|
+
isGenerated,
|
|
184
|
+
itemText,
|
|
185
|
+
listAttribute,
|
|
186
|
+
placeItems,
|
|
187
|
+
renderData,
|
|
188
|
+
renderListItems,
|
|
189
|
+
stashedEmpty,
|
|
190
|
+
templateOf,
|
|
191
|
+
valuesOf
|
|
192
|
+
};
|
package/dist/listbox.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// src/listbox.ts
|
|
2
|
+
import {
|
|
3
|
+
listbox
|
|
4
|
+
} from "@ui-sdk/core/listbox";
|
|
5
|
+
import { createParts } from "./define-element.js";
|
|
6
|
+
import {
|
|
7
|
+
adoptDefaultValue,
|
|
8
|
+
listAttribute,
|
|
9
|
+
renderListItems,
|
|
10
|
+
templateOf,
|
|
11
|
+
valuesOf
|
|
12
|
+
} from "./list.js";
|
|
13
|
+
var owner = "ui-listbox";
|
|
14
|
+
var generated = /* @__PURE__ */ new WeakMap();
|
|
15
|
+
function defineListboxElements() {
|
|
16
|
+
createParts(listbox, {
|
|
17
|
+
root: {
|
|
18
|
+
tag: owner,
|
|
19
|
+
defaults: { loop: true, keepInView: true },
|
|
20
|
+
formAssociated: true,
|
|
21
|
+
display: "block",
|
|
22
|
+
options: (el) => {
|
|
23
|
+
const data = el;
|
|
24
|
+
const multiple = el.hasAttribute("multiple") && el.getAttribute("multiple") !== "false";
|
|
25
|
+
const start = el.getAttribute("default-value") ?? el.getAttribute("value");
|
|
26
|
+
const toValues = (keys) => valuesOf(keys, data.items, data.itemToValue);
|
|
27
|
+
return {
|
|
28
|
+
items: data.items,
|
|
29
|
+
itemToValue: data.itemToValue,
|
|
30
|
+
isItemEqualToValue: data.isItemEqualToValue,
|
|
31
|
+
...start !== null && {
|
|
32
|
+
defaultValue: multiple ? toValues(listAttribute(start)) : toValues([start])[0]
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
},
|
|
36
|
+
state: {
|
|
37
|
+
value: {
|
|
38
|
+
get: (api) => api.getValue(),
|
|
39
|
+
// A string names items by key, comma-separated with multiple.
|
|
40
|
+
set: (api, value) => {
|
|
41
|
+
if (typeof value !== "string") {
|
|
42
|
+
return api.setValue(value);
|
|
43
|
+
}
|
|
44
|
+
const multiple = !!api.internal.options().multiple;
|
|
45
|
+
const keys = multiple ? listAttribute(value) : [value];
|
|
46
|
+
const found = keys.map(
|
|
47
|
+
(key) => api.internal.listbox.valueOf(key) ?? key
|
|
48
|
+
);
|
|
49
|
+
api.setValue(multiple ? found : found[0] ?? null);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
api: ["getValue", "setValue", "clear", "selectAll", "focus"],
|
|
54
|
+
// Runs again whenever `items` is set.
|
|
55
|
+
render(el, { api }) {
|
|
56
|
+
const { items } = el;
|
|
57
|
+
generated.get(el)?.forEach((child) => child.remove());
|
|
58
|
+
generated.delete(el);
|
|
59
|
+
if (!items) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
adoptDefaultValue(el, items, api);
|
|
63
|
+
const fresh = renderListItems(
|
|
64
|
+
"ui-listbox",
|
|
65
|
+
items,
|
|
66
|
+
api.internal.keyOf,
|
|
67
|
+
templateOf(el)
|
|
68
|
+
);
|
|
69
|
+
generated.set(el, fresh);
|
|
70
|
+
el.append(...fresh);
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
item: { tag: "ui-listbox-item", display: "block" },
|
|
74
|
+
"item-indicator": "ui-listbox-item-indicator",
|
|
75
|
+
// An icon inside an item. Screen readers and typeahead skip it.
|
|
76
|
+
"item-icon": "ui-listbox-item-icon",
|
|
77
|
+
group: { tag: "ui-listbox-group", display: "block" },
|
|
78
|
+
"group-label": { tag: "ui-listbox-group-label", display: "block" },
|
|
79
|
+
separator: { tag: "ui-listbox-separator", display: "block" }
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
export {
|
|
83
|
+
defineListboxElements
|
|
84
|
+
};
|
package/dist/menu.d.ts
ADDED