@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/toast.js
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
// src/toast.ts
|
|
2
|
+
import {
|
|
3
|
+
createToaster as createCoreToaster,
|
|
4
|
+
toast as coreToast,
|
|
5
|
+
toastRegion
|
|
6
|
+
} from "@ui-sdk/core/toast";
|
|
7
|
+
import { actionOf } from "./action.js";
|
|
8
|
+
import { createParts, wrappedButton } from "./define-element.js";
|
|
9
|
+
var rendered = /* @__PURE__ */ new WeakMap();
|
|
10
|
+
var filled = /* @__PURE__ */ new WeakMap();
|
|
11
|
+
var dataCloses = /* @__PURE__ */ new WeakSet();
|
|
12
|
+
var latest = /* @__PURE__ */ new WeakMap();
|
|
13
|
+
var authorLabels = /* @__PURE__ */ new WeakMap();
|
|
14
|
+
var part = (tag) => document.createElement(tag);
|
|
15
|
+
function button(tag) {
|
|
16
|
+
const wrapper = part(tag);
|
|
17
|
+
const el = part("button");
|
|
18
|
+
el.setAttribute("type", "button");
|
|
19
|
+
wrapper.append(el);
|
|
20
|
+
return wrapper;
|
|
21
|
+
}
|
|
22
|
+
function fromData() {
|
|
23
|
+
const root = part("ui-toast");
|
|
24
|
+
const content = part("div");
|
|
25
|
+
content.append(part("ui-toast-title"), part("ui-toast-description"));
|
|
26
|
+
root.append(content);
|
|
27
|
+
const close = button("ui-toast-close");
|
|
28
|
+
dataCloses.add(close);
|
|
29
|
+
root.append(button("ui-toast-action"), close);
|
|
30
|
+
return root;
|
|
31
|
+
}
|
|
32
|
+
function fromTemplate(template) {
|
|
33
|
+
const root = template.content.cloneNode(true).querySelector("ui-toast");
|
|
34
|
+
for (const close of root.querySelectorAll("ui-toast-close")) {
|
|
35
|
+
if (!(wrappedButton(close) ?? close).childNodes.length) {
|
|
36
|
+
dataCloses.add(close);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return root;
|
|
40
|
+
}
|
|
41
|
+
var cancelOf = (el) => (event, details) => {
|
|
42
|
+
const root = el.closest("ui-toast");
|
|
43
|
+
return root ? latest.get(root)?.cancel?.onCancel?.(event, details) : void 0;
|
|
44
|
+
};
|
|
45
|
+
function fill(root, toast2) {
|
|
46
|
+
latest.set(root, toast2);
|
|
47
|
+
const contents = [
|
|
48
|
+
["ui-toast-title", toast2.title],
|
|
49
|
+
["ui-toast-description", toast2.description],
|
|
50
|
+
["ui-toast-action", toast2.action?.label],
|
|
51
|
+
["ui-toast-close", toast2.cancel?.label]
|
|
52
|
+
];
|
|
53
|
+
for (const [tag, content] of contents) {
|
|
54
|
+
for (const el of root.querySelectorAll(tag)) {
|
|
55
|
+
if (tag === "ui-toast-close" && !dataCloses.has(el)) {
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
const target = tag === "ui-toast-action" || tag === "ui-toast-close" ? wrappedButton(el) ?? el : el;
|
|
59
|
+
if (filled.has(target) ? filled.get(target) === content : target.childNodes.length) {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
el.hidden = content == null;
|
|
63
|
+
target.replaceChildren(...content == null ? [] : [content]);
|
|
64
|
+
filled.set(target, content);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function sync(region, instance, refresh = false) {
|
|
69
|
+
const state = rendered.get(region);
|
|
70
|
+
if (!state) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const template = region.querySelector(":scope > template");
|
|
74
|
+
const items = instance.get().items;
|
|
75
|
+
const ids = new Set(items.map((item) => item.toast.id));
|
|
76
|
+
for (const [id, el] of state.toasts) {
|
|
77
|
+
if (!ids.has(id)) {
|
|
78
|
+
state.toasts.delete(id);
|
|
79
|
+
el.remove();
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
let previous = null;
|
|
83
|
+
for (const { toast: toast2 } of items) {
|
|
84
|
+
let el = state.toasts.get(toast2.id);
|
|
85
|
+
if (!el) {
|
|
86
|
+
el = template ? fromTemplate(template) : fromData();
|
|
87
|
+
el.setAttribute("toast", toast2.id);
|
|
88
|
+
state.toasts.set(toast2.id, el);
|
|
89
|
+
}
|
|
90
|
+
if (refresh || latest.get(el) !== toast2) {
|
|
91
|
+
fill(el, toast2);
|
|
92
|
+
region.renderToast?.(toast2, el);
|
|
93
|
+
}
|
|
94
|
+
instance.api.internal.label(toast2.id);
|
|
95
|
+
const next = previous ? previous.nextElementSibling : state.list.firstElementChild;
|
|
96
|
+
if (next !== el) {
|
|
97
|
+
state.list.insertBefore(el, next);
|
|
98
|
+
}
|
|
99
|
+
previous = el;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function render(region, instance) {
|
|
103
|
+
if (!rendered.has(region)) {
|
|
104
|
+
const list = document.createElement("ol");
|
|
105
|
+
list.setAttribute("data-slot", "toast-list");
|
|
106
|
+
region.append(list);
|
|
107
|
+
rendered.set(region, { list, toasts: /* @__PURE__ */ new Map() });
|
|
108
|
+
}
|
|
109
|
+
sync(region, instance, true);
|
|
110
|
+
return instance.subscribe(() => sync(region, instance));
|
|
111
|
+
}
|
|
112
|
+
function defineToastElements() {
|
|
113
|
+
createParts(toastRegion, {
|
|
114
|
+
root: {
|
|
115
|
+
tag: "ui-toast-region",
|
|
116
|
+
self: "region",
|
|
117
|
+
display: "block",
|
|
118
|
+
// The region sets these itself: whether a host placed it, and its author's name.
|
|
119
|
+
kinds: { placed: null, label: null },
|
|
120
|
+
// Described on `UiToastRegionElement`.
|
|
121
|
+
properties: ["renderToast"],
|
|
122
|
+
options: (el) => {
|
|
123
|
+
if (!authorLabels.has(el)) {
|
|
124
|
+
authorLabels.set(el, el.getAttribute("aria-label") ?? void 0);
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
placed: !el.hosted,
|
|
128
|
+
label: authorLabels.get(el)
|
|
129
|
+
};
|
|
130
|
+
},
|
|
131
|
+
api: ["focus", "pause", "resume"],
|
|
132
|
+
render: (el, instance) => render(el, instance)
|
|
133
|
+
},
|
|
134
|
+
toast: {
|
|
135
|
+
tag: "ui-toast",
|
|
136
|
+
// Each toast fills the root slot, since the region fills `region`.
|
|
137
|
+
slot: "root",
|
|
138
|
+
display: "block",
|
|
139
|
+
context: (el) => ({
|
|
140
|
+
id: el.getAttribute("toast") ?? void 0
|
|
141
|
+
}),
|
|
142
|
+
// In the region's list, each toast is an item of it.
|
|
143
|
+
render: (el) => el.setAttribute("role", "listitem")
|
|
144
|
+
},
|
|
145
|
+
title: { tag: "ui-toast-title", display: "block" },
|
|
146
|
+
description: { tag: "ui-toast-description", display: "block" },
|
|
147
|
+
// Runs the toast's action. Without one, an `action` attribute fires a
|
|
148
|
+
// cancelable `action` event; pass a Promise to `event.detail.waitUntil()` to
|
|
149
|
+
// keep the toast open, and the button pending, until it settles.
|
|
150
|
+
action: {
|
|
151
|
+
tag: "ui-toast-action",
|
|
152
|
+
defaults: { dismiss: true },
|
|
153
|
+
display: "contents",
|
|
154
|
+
target: wrappedButton,
|
|
155
|
+
// Always present, so the toast's own action runs when there's no attribute.
|
|
156
|
+
context: (el) => ({
|
|
157
|
+
onAction: el.hasAttribute("action") ? actionOf(el) : void 0
|
|
158
|
+
})
|
|
159
|
+
},
|
|
160
|
+
// Closes the toast. With an `action` attribute, fires `action` first, like the action part.
|
|
161
|
+
close: {
|
|
162
|
+
tag: "ui-toast-close",
|
|
163
|
+
display: "contents",
|
|
164
|
+
target: wrappedButton,
|
|
165
|
+
context: (el) => ({
|
|
166
|
+
action: dataCloses.has(el) ? cancelOf(el) : el.hasAttribute("action") ? actionOf(el) : void 0
|
|
167
|
+
})
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
var toast = coreToast;
|
|
172
|
+
var createToaster = createCoreToaster;
|
|
173
|
+
export {
|
|
174
|
+
createToaster,
|
|
175
|
+
defineToastElements,
|
|
176
|
+
toast
|
|
177
|
+
};
|
package/dist/toggle.d.ts
ADDED
package/dist/toggle.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// src/toggle.ts
|
|
2
|
+
import {
|
|
3
|
+
toggle,
|
|
4
|
+
toggleGroup
|
|
5
|
+
} from "@ui-sdk/core/toggle";
|
|
6
|
+
import { createParts, instanceOf, wrappedButton } from "./define-element.js";
|
|
7
|
+
var toolbarOf = (el) => () => instanceOf(
|
|
8
|
+
el.parentElement?.closest("ui-toolbar")
|
|
9
|
+
)?.api.internal.scopeIn(
|
|
10
|
+
!!el.parentElement?.closest(
|
|
11
|
+
'ui-toolbar-group[disabled]:not([disabled="false"])'
|
|
12
|
+
)
|
|
13
|
+
);
|
|
14
|
+
function defineToggleElements() {
|
|
15
|
+
createParts(toggle, {
|
|
16
|
+
root: {
|
|
17
|
+
tag: "ui-toggle",
|
|
18
|
+
target: wrappedButton,
|
|
19
|
+
display: "contents",
|
|
20
|
+
// Its group and toolbar are the ones around it, never properties.
|
|
21
|
+
kinds: { group: null, toolbar: null },
|
|
22
|
+
options: (el) => ({
|
|
23
|
+
// Read when needed, since the group may upgrade after the toggle.
|
|
24
|
+
group: () => instanceOf(
|
|
25
|
+
el.parentElement?.closest("ui-toggle-group")
|
|
26
|
+
)?.api,
|
|
27
|
+
toolbar: toolbarOf(el)
|
|
28
|
+
}),
|
|
29
|
+
state: {
|
|
30
|
+
pressed: {
|
|
31
|
+
get: (api) => api.isPressed(),
|
|
32
|
+
set: (api, pressed) => api.setPressed(!!pressed)
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
api: ["isPressed", "setPressed", "toggle", "focus"]
|
|
36
|
+
},
|
|
37
|
+
// An icon inside the toggle's button. Screen readers skip it.
|
|
38
|
+
icon: "ui-toggle-icon"
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function defineToggleGroupElements() {
|
|
42
|
+
createParts(toggleGroup, {
|
|
43
|
+
root: {
|
|
44
|
+
tag: "ui-toggle-group",
|
|
45
|
+
self: "group",
|
|
46
|
+
display: "block",
|
|
47
|
+
defaults: { deselectable: true, loop: true },
|
|
48
|
+
kinds: { toolbar: null },
|
|
49
|
+
options: (el) => ({ toolbar: toolbarOf(el) }),
|
|
50
|
+
state: {
|
|
51
|
+
value: {
|
|
52
|
+
get: (api) => api.getValue(),
|
|
53
|
+
set: (api, value) => api.setValue(value ?? [])
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
api: ["getValue", "setValue", "isPressed", "toggle", "focus"]
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
defineToggleElements();
|
|
60
|
+
}
|
|
61
|
+
export {
|
|
62
|
+
defineToggleElements,
|
|
63
|
+
defineToggleGroupElements
|
|
64
|
+
};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// src/token-input.ts
|
|
2
|
+
import {
|
|
3
|
+
tokenInput
|
|
4
|
+
} from "@ui-sdk/core/token-input";
|
|
5
|
+
import { createParts, reconfigureInside } from "./define-element.js";
|
|
6
|
+
var owner = "ui-token-input";
|
|
7
|
+
function tokenOf(el) {
|
|
8
|
+
const id = el.closest("[data-token-id]")?.getAttribute("data-token-id") ?? "";
|
|
9
|
+
return { id, token: id };
|
|
10
|
+
}
|
|
11
|
+
function defineTokenInputElements() {
|
|
12
|
+
createParts(tokenInput, {
|
|
13
|
+
root: {
|
|
14
|
+
tag: owner,
|
|
15
|
+
formAssociated: true,
|
|
16
|
+
properties: ["renderToken"],
|
|
17
|
+
// The submit shortcut submits the form the element is in, so a form's own
|
|
18
|
+
// submit event hears it. A bubbling "submit" event would reach the form too.
|
|
19
|
+
silent: ["onSubmit"],
|
|
20
|
+
// A disabled <ui-field> around it disables it, as a disabled Field does
|
|
21
|
+
// in the other frameworks.
|
|
22
|
+
options: (el) => ({
|
|
23
|
+
...el.closest("ui-field")?.hasAttribute("disabled") && {
|
|
24
|
+
disabled: true
|
|
25
|
+
}
|
|
26
|
+
}),
|
|
27
|
+
display: "block",
|
|
28
|
+
state: {
|
|
29
|
+
value: {
|
|
30
|
+
get: (api) => api.getValue(),
|
|
31
|
+
set: (api, value) => api.setValue(
|
|
32
|
+
typeof value === "string" ? api.internal.codec().parse(value) : value
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
api: [
|
|
37
|
+
"getValue",
|
|
38
|
+
"setValue",
|
|
39
|
+
"getText",
|
|
40
|
+
"getLabel",
|
|
41
|
+
"insert",
|
|
42
|
+
"updateToken",
|
|
43
|
+
"removeToken",
|
|
44
|
+
"undo",
|
|
45
|
+
"redo",
|
|
46
|
+
"canUndo",
|
|
47
|
+
"canRedo",
|
|
48
|
+
"clear",
|
|
49
|
+
"focus"
|
|
50
|
+
],
|
|
51
|
+
render(el, { api, subscribe }) {
|
|
52
|
+
const target = el;
|
|
53
|
+
const mode = contentMode(target);
|
|
54
|
+
api.internal.setCustom(mode !== "label");
|
|
55
|
+
reconfigureInside(el);
|
|
56
|
+
const rendered = /* @__PURE__ */ new WeakMap();
|
|
57
|
+
const showTokens = () => renderTokens(target, api, rendered);
|
|
58
|
+
showTokens();
|
|
59
|
+
const unsubscribe = subscribe(showTokens);
|
|
60
|
+
return () => {
|
|
61
|
+
unsubscribe();
|
|
62
|
+
if (el.isConnected && contentMode(target) === mode) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
for (const { host } of api.internal.hosts()) {
|
|
66
|
+
if (rendered.has(host)) {
|
|
67
|
+
host.replaceChildren();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
editor: { tag: "ui-token-input-editor", display: "block" },
|
|
74
|
+
token: { tag: "ui-token-input-token", context: tokenOf },
|
|
75
|
+
"token-remove": { tag: "ui-token-input-token-remove", context: tokenOf }
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
var contentMode = (el) => el.renderToken ? "renderToken" : el.querySelector(":scope > template") ? "template" : "label";
|
|
79
|
+
function renderTokens(el, api, rendered) {
|
|
80
|
+
const template = el.querySelector(":scope > template");
|
|
81
|
+
for (const { token, host } of api.internal.hosts()) {
|
|
82
|
+
if (rendered.get(host) === token) {
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
rendered.set(host, token);
|
|
86
|
+
if (el.renderToken) {
|
|
87
|
+
el.renderToken(token, host);
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
if (!template) {
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
if (!host.firstChild) {
|
|
94
|
+
host.append(template.content.cloneNode(true));
|
|
95
|
+
}
|
|
96
|
+
for (const label of host.querySelectorAll("[data-token-label]")) {
|
|
97
|
+
label.textContent = token.label;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
export {
|
|
102
|
+
defineTokenInputElements
|
|
103
|
+
};
|
package/dist/toolbar.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// src/toolbar.ts
|
|
2
|
+
import { toolbar } from "@ui-sdk/core/toolbar";
|
|
3
|
+
import { createParts } from "./define-element.js";
|
|
4
|
+
var wrappedControl = (el) => el.querySelector("button, a[href], input, textarea") ?? el.firstElementChild;
|
|
5
|
+
function defineToolbarElements() {
|
|
6
|
+
createParts(toolbar, {
|
|
7
|
+
root: {
|
|
8
|
+
tag: "ui-toolbar",
|
|
9
|
+
display: "block",
|
|
10
|
+
defaults: { loop: true },
|
|
11
|
+
api: ["focus"]
|
|
12
|
+
},
|
|
13
|
+
button: {
|
|
14
|
+
tag: "ui-toolbar-button",
|
|
15
|
+
display: "contents",
|
|
16
|
+
target: wrappedControl,
|
|
17
|
+
defaults: { focusableWhenDisabled: true }
|
|
18
|
+
},
|
|
19
|
+
input: {
|
|
20
|
+
tag: "ui-toolbar-input",
|
|
21
|
+
display: "contents",
|
|
22
|
+
target: wrappedControl,
|
|
23
|
+
defaults: { focusableWhenDisabled: true }
|
|
24
|
+
},
|
|
25
|
+
link: {
|
|
26
|
+
tag: "ui-toolbar-link",
|
|
27
|
+
display: "contents",
|
|
28
|
+
target: wrappedControl
|
|
29
|
+
},
|
|
30
|
+
group: { tag: "ui-toolbar-group", display: "block" },
|
|
31
|
+
separator: { tag: "ui-toolbar-separator", display: "block" }
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
defineToolbarElements
|
|
36
|
+
};
|
package/dist/tooltip.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// src/tooltip.ts
|
|
2
|
+
import { tooltip } from "@ui-sdk/core/tooltip";
|
|
3
|
+
import { createParts } from "./define-element.js";
|
|
4
|
+
import { popupApi, popupKinds, popupPortal, popupState } from "./popup.js";
|
|
5
|
+
var owner = "ui-tooltip";
|
|
6
|
+
function defineTooltipElements() {
|
|
7
|
+
createParts(tooltip, {
|
|
8
|
+
root: {
|
|
9
|
+
tag: owner,
|
|
10
|
+
defaults: { closeOnPress: true },
|
|
11
|
+
kinds: popupKinds,
|
|
12
|
+
// `portal` handles the `container` attribute, so core never gets it.
|
|
13
|
+
options: () => ({ container: void 0 }),
|
|
14
|
+
state: popupState,
|
|
15
|
+
api: popupApi,
|
|
16
|
+
// container="#id" renders the popup there.
|
|
17
|
+
portal: popupPortal
|
|
18
|
+
},
|
|
19
|
+
// The trigger wraps the user's own button or link, so it stays one. Inside
|
|
20
|
+
// another component's trigger, like <ui-menu-trigger>, it's the button deepest in.
|
|
21
|
+
// With `for="tooltip-id"`, it shows that tooltip from anywhere on the page.
|
|
22
|
+
trigger: {
|
|
23
|
+
tag: "ui-tooltip-trigger",
|
|
24
|
+
display: "contents",
|
|
25
|
+
target: (el) => el.querySelector("button, a[href]") ?? el.firstElementChild
|
|
26
|
+
},
|
|
27
|
+
content: { tag: "ui-tooltip-content", kinds: popupKinds },
|
|
28
|
+
arrow: { tag: "ui-tooltip-arrow", display: "block" },
|
|
29
|
+
// Shows the tooltip's shortcut, or its own `shortcut`, when it has no text of its own.
|
|
30
|
+
shortcut: "ui-tooltip-shortcut"
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
defineTooltipElements
|
|
35
|
+
};
|
package/dist/tree.d.ts
ADDED
package/dist/tree.js
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
// src/tree.ts
|
|
2
|
+
import { tree } from "@ui-sdk/core/tree";
|
|
3
|
+
import { createParts } from "./define-element.js";
|
|
4
|
+
import { copy, element, listAttribute, templateOf } from "./list.js";
|
|
5
|
+
var owner = "ui-tree";
|
|
6
|
+
var generated = /* @__PURE__ */ new WeakMap();
|
|
7
|
+
function renderItems(items, checkable, template) {
|
|
8
|
+
return items.map((item) => {
|
|
9
|
+
const el = copy(template, "ui-tree-item", false);
|
|
10
|
+
el.setAttribute("value", item.value);
|
|
11
|
+
if (item.children !== void 0) {
|
|
12
|
+
el.setAttribute("branch", "");
|
|
13
|
+
}
|
|
14
|
+
if (item.disabled) {
|
|
15
|
+
el.setAttribute("disabled", "");
|
|
16
|
+
}
|
|
17
|
+
if (item.children) {
|
|
18
|
+
el.append(copy(template, "ui-tree-item-indicator"));
|
|
19
|
+
}
|
|
20
|
+
if (checkable) {
|
|
21
|
+
el.append(copy(template, "ui-tree-item-checkbox"));
|
|
22
|
+
}
|
|
23
|
+
const label = copy(template, "ui-tree-item-label");
|
|
24
|
+
if (item.href) {
|
|
25
|
+
const link = element(
|
|
26
|
+
"a",
|
|
27
|
+
{ href: item.href, class: label.getAttribute("class") ?? void 0 },
|
|
28
|
+
item.label
|
|
29
|
+
);
|
|
30
|
+
label.removeAttribute("class");
|
|
31
|
+
label.setAttribute("as-child", "");
|
|
32
|
+
label.replaceChildren(link);
|
|
33
|
+
} else {
|
|
34
|
+
label.textContent = item.label;
|
|
35
|
+
}
|
|
36
|
+
el.append(label);
|
|
37
|
+
if (item.children) {
|
|
38
|
+
const group = copy(template, "ui-tree-group", false);
|
|
39
|
+
group.append(...renderItems(item.children, checkable, template));
|
|
40
|
+
el.append(group);
|
|
41
|
+
}
|
|
42
|
+
return el;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
function defineTreeElements() {
|
|
46
|
+
createParts(tree, {
|
|
47
|
+
root: {
|
|
48
|
+
tag: owner,
|
|
49
|
+
defaults: { expandOnPress: true, focusableWhenDisabled: true },
|
|
50
|
+
display: "block",
|
|
51
|
+
// `action` listeners call `event.detail.waitUntil(promise)` to mark the item pending.
|
|
52
|
+
options: (el) => {
|
|
53
|
+
const data = el;
|
|
54
|
+
const multiple = el.getAttribute("mode") === "multiple";
|
|
55
|
+
const start = el.getAttribute("default-value") ?? el.getAttribute("value");
|
|
56
|
+
return {
|
|
57
|
+
items: data.items,
|
|
58
|
+
paths: data.paths,
|
|
59
|
+
...start !== null && {
|
|
60
|
+
defaultValue: multiple ? listAttribute(start) : start
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
},
|
|
64
|
+
state: {
|
|
65
|
+
value: {
|
|
66
|
+
get: (api) => api.getValue(),
|
|
67
|
+
// A string lists values separated by commas with multiple selection.
|
|
68
|
+
set: (api, value) => {
|
|
69
|
+
const multiple = api.internal.mode() === "multiple";
|
|
70
|
+
if (typeof value === "string") {
|
|
71
|
+
return api.setValue(
|
|
72
|
+
multiple ? listAttribute(value) : value || null
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
api.setValue(value ?? (multiple ? [] : null));
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
expanded: {
|
|
79
|
+
get: (api) => api.getExpanded(),
|
|
80
|
+
set: (api, value) => api.setExpanded(
|
|
81
|
+
typeof value === "string" ? listAttribute(value) : value ?? []
|
|
82
|
+
)
|
|
83
|
+
},
|
|
84
|
+
checked: {
|
|
85
|
+
get: (api) => api.getChecked(),
|
|
86
|
+
set: (api, value) => api.setChecked(
|
|
87
|
+
typeof value === "string" ? listAttribute(value) : value ?? []
|
|
88
|
+
)
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
api: [
|
|
92
|
+
"getExpanded",
|
|
93
|
+
"setExpanded",
|
|
94
|
+
"isExpanded",
|
|
95
|
+
"expand",
|
|
96
|
+
"collapse",
|
|
97
|
+
"toggle",
|
|
98
|
+
"expandAll",
|
|
99
|
+
"collapseAll",
|
|
100
|
+
"getValue",
|
|
101
|
+
"setValue",
|
|
102
|
+
"getChecked",
|
|
103
|
+
"setChecked",
|
|
104
|
+
"checkedState",
|
|
105
|
+
"reveal",
|
|
106
|
+
"focus"
|
|
107
|
+
],
|
|
108
|
+
// Runs again whenever `items` or `paths` is set.
|
|
109
|
+
render(el, { api }) {
|
|
110
|
+
const focused = el.ownerDocument.activeElement?.closest("ui-tree-item");
|
|
111
|
+
const keep = focused && el.contains(focused) ? focused.getAttribute("value") : null;
|
|
112
|
+
generated.get(el)?.forEach((child) => child.remove());
|
|
113
|
+
generated.delete(el);
|
|
114
|
+
if (el.querySelector(":scope > ui-tree-item")) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
const items = api.internal.items();
|
|
118
|
+
if (!items) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
const fresh = renderItems(
|
|
122
|
+
items,
|
|
123
|
+
el.hasAttribute("checkable"),
|
|
124
|
+
templateOf(el)
|
|
125
|
+
);
|
|
126
|
+
generated.set(el, fresh);
|
|
127
|
+
el.append(...fresh);
|
|
128
|
+
if (keep !== null) {
|
|
129
|
+
api.focus(keep);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
// An item's parent is the item around it, and a group inside it makes it a branch.
|
|
134
|
+
item: {
|
|
135
|
+
tag: "ui-tree-item",
|
|
136
|
+
display: "block",
|
|
137
|
+
context: (el) => el.querySelector(":scope > ui-tree-group") ? { branch: true } : {}
|
|
138
|
+
},
|
|
139
|
+
label: "ui-tree-item-label",
|
|
140
|
+
indicator: "ui-tree-item-indicator",
|
|
141
|
+
checkbox: "ui-tree-item-checkbox",
|
|
142
|
+
group: { tag: "ui-tree-group", display: "block" }
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
export {
|
|
146
|
+
defineTreeElements
|
|
147
|
+
};
|