@bevelo/vue 0.0.0-stage → 0.1.0
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 +21 -0
- package/dist/accordion.cjs +89 -0
- package/dist/accordion.d.cts +145 -0
- package/dist/accordion.d.ts +145 -0
- package/dist/accordion.js +88 -0
- package/dist/agent.cjs +74 -0
- package/dist/agent.d.cts +2 -0
- package/dist/agent.d.ts +2 -0
- package/dist/agent.js +1 -0
- package/dist/alert-dialog.cjs +48 -0
- package/dist/alert-dialog.d.cts +142 -0
- package/dist/alert-dialog.d.ts +142 -0
- package/dist/alert-dialog.js +47 -0
- package/dist/alert.cjs +77 -0
- package/dist/alert.d.cts +64 -0
- package/dist/alert.d.ts +64 -0
- package/dist/alert.js +76 -0
- package/dist/aspect-ratio.cjs +21 -0
- package/dist/aspect-ratio.d.cts +13 -0
- package/dist/aspect-ratio.d.ts +13 -0
- package/dist/aspect-ratio.js +21 -0
- package/dist/async-options.cjs +76 -0
- package/dist/async-options.d.cts +49 -0
- package/dist/async-options.d.ts +49 -0
- package/dist/async-options.js +75 -0
- package/dist/autocomplete.cjs +274 -0
- package/dist/autocomplete.d.cts +309 -0
- package/dist/autocomplete.d.ts +309 -0
- package/dist/autocomplete.js +273 -0
- package/dist/avatar.cjs +51 -0
- package/dist/avatar.d.cts +69 -0
- package/dist/avatar.d.ts +69 -0
- package/dist/avatar.js +50 -0
- package/dist/badge.cjs +41 -0
- package/dist/badge.d.cts +39 -0
- package/dist/badge.d.ts +39 -0
- package/dist/badge.js +40 -0
- package/dist/breadcrumb.cjs +59 -0
- package/dist/breadcrumb.d.cts +40 -0
- package/dist/breadcrumb.d.ts +40 -0
- package/dist/breadcrumb.js +58 -0
- package/dist/button.cjs +56 -0
- package/dist/button.d.cts +79 -0
- package/dist/button.d.ts +79 -0
- package/dist/button.js +55 -0
- package/dist/calendar-Bcc6HKc9.js +643 -0
- package/dist/calendar-vHGhj3RI.cjs +720 -0
- package/dist/calendar.cjs +4 -0
- package/dist/calendar.d.cts +316 -0
- package/dist/calendar.d.ts +316 -0
- package/dist/calendar.js +1 -0
- package/dist/card-B_ZoLCvt.d.cts +61 -0
- package/dist/card-B_ZoLCvt.d.ts +61 -0
- package/dist/card-CZHRix0r.js +99 -0
- package/dist/card-CvGfpsiU.cjs +140 -0
- package/dist/card.cjs +9 -0
- package/dist/card.d.cts +2 -0
- package/dist/card.d.ts +2 -0
- package/dist/card.js +1 -0
- package/dist/carousel.cjs +225 -0
- package/dist/carousel.d.cts +214 -0
- package/dist/carousel.d.ts +214 -0
- package/dist/carousel.js +224 -0
- package/dist/checkbox-group.cjs +93 -0
- package/dist/checkbox-group.d.cts +108 -0
- package/dist/checkbox-group.d.ts +108 -0
- package/dist/checkbox-group.js +91 -0
- package/dist/checkbox.cjs +117 -0
- package/dist/checkbox.d.cts +153 -0
- package/dist/checkbox.d.ts +153 -0
- package/dist/checkbox.js +116 -0
- package/dist/collapsible.cjs +70 -0
- package/dist/collapsible.d.cts +141 -0
- package/dist/collapsible.d.ts +141 -0
- package/dist/collapsible.js +69 -0
- package/dist/color-picker.cjs +225 -0
- package/dist/color-picker.d.cts +180 -0
- package/dist/color-picker.d.ts +180 -0
- package/dist/color-picker.js +212 -0
- package/dist/combobox-CDHIXr6J.d.ts +735 -0
- package/dist/combobox-D39Waj6L.d.cts +735 -0
- package/dist/combobox-DlCU0vS1.cjs +945 -0
- package/dist/combobox-wLdV6VA_.js +802 -0
- package/dist/combobox.cjs +26 -0
- package/dist/combobox.d.cts +3 -0
- package/dist/combobox.d.ts +3 -0
- package/dist/combobox.js +1 -0
- package/dist/command-CEJACYpR.d.ts +404 -0
- package/dist/command-CqHZVivR.js +693 -0
- package/dist/command-D54bj6RJ.cjs +836 -0
- package/dist/command-rAVp-wbf.d.cts +404 -0
- package/dist/command.cjs +15 -0
- package/dist/command.d.cts +2 -0
- package/dist/command.d.ts +2 -0
- package/dist/command.js +1 -0
- package/dist/context-menu-BPsgeLQm.cjs +170 -0
- package/dist/context-menu-ByhKzWTm.d.ts +129 -0
- package/dist/context-menu-Co3ABcdp.js +153 -0
- package/dist/context-menu-USbhMQuc.d.cts +129 -0
- package/dist/context-menu.cjs +6 -0
- package/dist/context-menu.d.cts +2 -0
- package/dist/context-menu.d.ts +2 -0
- package/dist/context-menu.js +2 -0
- package/dist/date-input.cjs +374 -0
- package/dist/date-input.d.cts +234 -0
- package/dist/date-input.d.ts +234 -0
- package/dist/date-input.js +371 -0
- package/dist/date-picker-D1mygz_Y.js +891 -0
- package/dist/date-picker-D_hqHHAV.cjs +938 -0
- package/dist/date-picker.cjs +4 -0
- package/dist/date-picker.d.cts +447 -0
- package/dist/date-picker.d.ts +447 -0
- package/dist/date-picker.js +1 -0
- package/dist/describe-BlNg9SbK.js +25 -0
- package/dist/describe-D_dLtwde.cjs +42 -0
- package/dist/dialog-view-CKtpbGq_.js +26 -0
- package/dist/dialog-view-swgEQvlZ.cjs +31 -0
- package/dist/dialog.cjs +66 -0
- package/dist/dialog.d.cts +158 -0
- package/dist/dialog.d.ts +158 -0
- package/dist/dialog.js +63 -0
- package/dist/direction.cjs +21 -0
- package/dist/direction.d.cts +13 -0
- package/dist/direction.d.ts +13 -0
- package/dist/direction.js +21 -0
- package/dist/dnd.cjs +103 -0
- package/dist/dnd.d.cts +54 -0
- package/dist/dnd.d.ts +54 -0
- package/dist/dnd.js +98 -0
- package/dist/drawer.cjs +137 -0
- package/dist/drawer.d.cts +190 -0
- package/dist/drawer.d.ts +190 -0
- package/dist/drawer.js +134 -0
- package/dist/empty-state.cjs +75 -0
- package/dist/empty-state.d.cts +46 -0
- package/dist/empty-state.d.ts +46 -0
- package/dist/empty-state.js +74 -0
- package/dist/engine-refs-8O6mHfYd.d.cts +4 -0
- package/dist/engine-refs-8O6mHfYd.d.ts +4 -0
- package/dist/engine-refs-CPWFFTfA.cjs +32 -0
- package/dist/engine-refs-sojZQs1R.js +21 -0
- package/dist/error-state.cjs +86 -0
- package/dist/error-state.d.cts +54 -0
- package/dist/error-state.d.ts +54 -0
- package/dist/error-state.js +85 -0
- package/dist/field.cjs +123 -0
- package/dist/field.d.cts +100 -0
- package/dist/field.d.ts +100 -0
- package/dist/field.js +122 -0
- package/dist/file-input.cjs +117 -0
- package/dist/file-input.d.cts +168 -0
- package/dist/file-input.d.ts +168 -0
- package/dist/file-input.js +116 -0
- package/dist/form-CKus_NQE.cjs +23 -0
- package/dist/form-y7b0fcqL.js +18 -0
- package/dist/gauge-parts-BVmw61GR.js +64 -0
- package/dist/gauge-parts-DjqBK9pL.d.cts +15 -0
- package/dist/gauge-parts-V31Fma77.cjs +75 -0
- package/dist/gauge-parts-mAgseDD4.d.ts +15 -0
- package/dist/headless-B3zQWaJm.js +225 -0
- package/dist/headless-BQe1X1Vf.d.ts +2 -0
- package/dist/headless-CbQgxdK1.d.cts +2 -0
- package/dist/headless-D88yFw8W.cjs +248 -0
- package/dist/hover-card.cjs +139 -0
- package/dist/hover-card.d.cts +200 -0
- package/dist/hover-card.d.ts +200 -0
- package/dist/hover-card.js +137 -0
- package/dist/icon-button.cjs +75 -0
- package/dist/icon-button.d.cts +104 -0
- package/dist/icon-button.d.ts +104 -0
- package/dist/icon-button.js +74 -0
- package/dist/image-cropper.cjs +106 -0
- package/dist/image-cropper.d.cts +7 -0
- package/dist/image-cropper.d.ts +7 -0
- package/dist/image-cropper.js +105 -0
- package/dist/image.cjs +87 -0
- package/dist/image.d.cts +92 -0
- package/dist/image.d.ts +92 -0
- package/dist/image.js +86 -0
- package/dist/index.cjs +1685 -0
- package/dist/index.d.cts +1195 -0
- package/dist/index.d.ts +1195 -0
- package/dist/index.js +1042 -0
- package/dist/input-group.cjs +91 -0
- package/dist/input-group.d.cts +84 -0
- package/dist/input-group.d.ts +84 -0
- package/dist/input-group.js +90 -0
- package/dist/input.cjs +114 -0
- package/dist/input.d.cts +186 -0
- package/dist/input.d.ts +186 -0
- package/dist/input.js +113 -0
- package/dist/item-B-QdNtAl.cjs +264 -0
- package/dist/item-D6GSb0WD.d.ts +144 -0
- package/dist/item-DPJnk7ED.js +199 -0
- package/dist/item-DyrvCrsL.d.cts +144 -0
- package/dist/item.cjs +10 -0
- package/dist/item.d.cts +2 -0
- package/dist/item.d.ts +2 -0
- package/dist/item.js +1 -0
- package/dist/kbd.cjs +55 -0
- package/dist/kbd.d.cts +38 -0
- package/dist/kbd.d.ts +38 -0
- package/dist/kbd.js +54 -0
- package/dist/label.cjs +41 -0
- package/dist/label.d.cts +40 -0
- package/dist/label.d.ts +40 -0
- package/dist/label.js +40 -0
- package/dist/listbox.cjs +85 -0
- package/dist/listbox.d.cts +200 -0
- package/dist/listbox.d.ts +200 -0
- package/dist/listbox.js +84 -0
- package/dist/loader.cjs +66 -0
- package/dist/loader.d.cts +68 -0
- package/dist/loader.d.ts +68 -0
- package/dist/loader.js +65 -0
- package/dist/mention-menu.cjs +126 -0
- package/dist/mention-menu.d.cts +144 -0
- package/dist/mention-menu.d.ts +144 -0
- package/dist/mention-menu.js +125 -0
- package/dist/menu.cjs +182 -0
- package/dist/menu.d.cts +240 -0
- package/dist/menu.d.ts +240 -0
- package/dist/menu.js +181 -0
- package/dist/menubar.cjs +38 -0
- package/dist/menubar.d.cts +43 -0
- package/dist/menubar.d.ts +43 -0
- package/dist/menubar.js +37 -0
- package/dist/meter.cjs +113 -0
- package/dist/meter.d.cts +124 -0
- package/dist/meter.d.ts +124 -0
- package/dist/meter.js +108 -0
- package/dist/native-select-52jYpA3c.d.cts +136 -0
- package/dist/native-select-BdJojSQt.d.ts +136 -0
- package/dist/native-select-BwptULNE.js +129 -0
- package/dist/native-select-DjBGWFoh.cjs +146 -0
- package/dist/native-select.cjs +5 -0
- package/dist/native-select.d.cts +2 -0
- package/dist/native-select.d.ts +2 -0
- package/dist/native-select.js +1 -0
- package/dist/navigation-menu.cjs +108 -0
- package/dist/navigation-menu.d.cts +245 -0
- package/dist/navigation-menu.d.ts +245 -0
- package/dist/navigation-menu.js +107 -0
- package/dist/number-input.cjs +189 -0
- package/dist/number-input.d.cts +232 -0
- package/dist/number-input.d.ts +232 -0
- package/dist/number-input.js +187 -0
- package/dist/option-row-DFCj-NoL.js +64 -0
- package/dist/option-row-Dlc6brXH.d.cts +30 -0
- package/dist/option-row-hLg6Ye86.cjs +105 -0
- package/dist/option-row-yJqjEx0G.d.ts +30 -0
- package/dist/options-BDn36q6n.cjs +111 -0
- package/dist/options-BlkyK-uO.js +106 -0
- package/dist/options-CGl5jBEY.d.ts +19 -0
- package/dist/options-DUGLoksA.d.cts +19 -0
- package/dist/otp-input.cjs +85 -0
- package/dist/otp-input.d.cts +113 -0
- package/dist/otp-input.d.ts +113 -0
- package/dist/otp-input.js +84 -0
- package/dist/overlay-controller-78GSJGbM.js +76 -0
- package/dist/overlay-controller-BDeITPoR.d.cts +16 -0
- package/dist/overlay-controller-DmaZ8FLl.cjs +93 -0
- package/dist/overlay-controller-HrMdTomI.d.ts +16 -0
- package/dist/pagination.cjs +87 -0
- package/dist/pagination.d.cts +112 -0
- package/dist/pagination.d.ts +112 -0
- package/dist/pagination.js +86 -0
- package/dist/parts-9zrUGbuI.js +84 -0
- package/dist/parts-DcYZV8ug.cjs +95 -0
- package/dist/password-input.cjs +144 -0
- package/dist/password-input.d.cts +151 -0
- package/dist/password-input.d.ts +151 -0
- package/dist/password-input.js +143 -0
- package/dist/placement-C_WRqvZk.js +49 -0
- package/dist/placement-ChEh6uxa.cjs +60 -0
- package/dist/popover.cjs +159 -0
- package/dist/popover.d.cts +185 -0
- package/dist/popover.d.ts +185 -0
- package/dist/popover.js +157 -0
- package/dist/preferences.cjs +96 -0
- package/dist/preferences.d.cts +36 -0
- package/dist/preferences.d.ts +36 -0
- package/dist/preferences.js +94 -0
- package/dist/presence.cjs +85 -0
- package/dist/presence.d.cts +25 -0
- package/dist/presence.d.ts +25 -0
- package/dist/presence.js +83 -0
- package/dist/progress.cjs +111 -0
- package/dist/progress.d.cts +109 -0
- package/dist/progress.d.ts +109 -0
- package/dist/progress.js +106 -0
- package/dist/query.cjs +152 -0
- package/dist/query.d.cts +68 -0
- package/dist/query.d.ts +68 -0
- package/dist/query.js +142 -0
- package/dist/radio.cjs +102 -0
- package/dist/radio.d.cts +136 -0
- package/dist/radio.d.ts +136 -0
- package/dist/radio.js +101 -0
- package/dist/rating.cjs +88 -0
- package/dist/rating.d.cts +100 -0
- package/dist/rating.d.ts +100 -0
- package/dist/rating.js +87 -0
- package/dist/resizable.cjs +57 -0
- package/dist/resizable.d.cts +119 -0
- package/dist/resizable.d.ts +119 -0
- package/dist/resizable.js +56 -0
- package/dist/scroll-area.cjs +59 -0
- package/dist/scroll-area.d.cts +72 -0
- package/dist/scroll-area.d.ts +72 -0
- package/dist/scroll-area.js +58 -0
- package/dist/segmented-control.cjs +88 -0
- package/dist/segmented-control.d.cts +121 -0
- package/dist/segmented-control.d.ts +121 -0
- package/dist/segmented-control.js +86 -0
- package/dist/select.cjs +160 -0
- package/dist/select.d.cts +385 -0
- package/dist/select.d.ts +385 -0
- package/dist/select.js +159 -0
- package/dist/separator.cjs +32 -0
- package/dist/separator.d.cts +31 -0
- package/dist/separator.d.ts +31 -0
- package/dist/separator.js +31 -0
- package/dist/sheet.cjs +294 -0
- package/dist/sheet.d.cts +456 -0
- package/dist/sheet.d.ts +456 -0
- package/dist/sheet.js +292 -0
- package/dist/sidebar-C-OdvGzD.d.cts +96 -0
- package/dist/sidebar-CZ1-p0-V.d.ts +96 -0
- package/dist/sidebar-DC-mpzMR.js +87 -0
- package/dist/sidebar-gSAgHdkn.cjs +110 -0
- package/dist/sidebar.cjs +6 -0
- package/dist/sidebar.d.cts +2 -0
- package/dist/sidebar.d.ts +2 -0
- package/dist/sidebar.js +1 -0
- package/dist/skeleton.cjs +46 -0
- package/dist/skeleton.d.cts +47 -0
- package/dist/skeleton.d.ts +47 -0
- package/dist/skeleton.js +45 -0
- package/dist/slider.cjs +118 -0
- package/dist/slider.d.cts +181 -0
- package/dist/slider.d.ts +181 -0
- package/dist/slider.js +117 -0
- package/dist/sortable-board-strict.cjs +149 -0
- package/dist/sortable-board-strict.d.cts +181 -0
- package/dist/sortable-board-strict.d.ts +181 -0
- package/dist/sortable-board-strict.js +148 -0
- package/dist/sortable-engine.cjs +136 -0
- package/dist/sortable-engine.d.cts +237 -0
- package/dist/sortable-engine.d.ts +237 -0
- package/dist/sortable-engine.js +135 -0
- package/dist/sortable.cjs +67 -0
- package/dist/sortable.d.cts +217 -0
- package/dist/sortable.d.ts +217 -0
- package/dist/sortable.js +66 -0
- package/dist/spinner.cjs +32 -0
- package/dist/spinner.d.cts +31 -0
- package/dist/spinner.d.ts +31 -0
- package/dist/spinner.js +31 -0
- package/dist/steps-C9Jmrt8G.cjs +122 -0
- package/dist/steps-Cs8AfxV7.js +81 -0
- package/dist/steps-DW5NkzVj.d.ts +71 -0
- package/dist/steps-ymRMdju5.d.cts +71 -0
- package/dist/steps.cjs +8 -0
- package/dist/steps.d.cts +2 -0
- package/dist/steps.d.ts +2 -0
- package/dist/steps.js +1 -0
- package/dist/switch.cjs +100 -0
- package/dist/switch.d.cts +144 -0
- package/dist/switch.d.ts +144 -0
- package/dist/switch.js +99 -0
- package/dist/table.cjs +124 -0
- package/dist/table.d.cts +124 -0
- package/dist/table.d.ts +124 -0
- package/dist/table.js +123 -0
- package/dist/tabs.cjs +89 -0
- package/dist/tabs.d.cts +160 -0
- package/dist/tabs.d.ts +160 -0
- package/dist/tabs.js +88 -0
- package/dist/textarea.cjs +140 -0
- package/dist/textarea.d.cts +231 -0
- package/dist/textarea.d.ts +231 -0
- package/dist/textarea.js +139 -0
- package/dist/time-input.cjs +117 -0
- package/dist/time-input.d.cts +140 -0
- package/dist/time-input.d.ts +140 -0
- package/dist/time-input.js +116 -0
- package/dist/timeline.cjs +82 -0
- package/dist/timeline.d.cts +62 -0
- package/dist/timeline.d.ts +62 -0
- package/dist/timeline.js +81 -0
- package/dist/toast-CfkRzdNd.js +354 -0
- package/dist/toast-DyezF7lm.cjs +401 -0
- package/dist/toast.cjs +16 -0
- package/dist/toast.d.cts +275 -0
- package/dist/toast.d.ts +275 -0
- package/dist/toast.js +1 -0
- package/dist/toggle-group.cjs +65 -0
- package/dist/toggle-group.d.cts +128 -0
- package/dist/toggle-group.d.ts +128 -0
- package/dist/toggle-group.js +64 -0
- package/dist/toggle.cjs +64 -0
- package/dist/toggle.d.cts +97 -0
- package/dist/toggle.d.ts +97 -0
- package/dist/toggle.js +63 -0
- package/dist/token-input-BIC9VLMG.d.cts +170 -0
- package/dist/token-input-BTReOHIv.cjs +336 -0
- package/dist/token-input-CQnZ6-pO.d.ts +170 -0
- package/dist/token-input-DtcCZrcC.js +295 -0
- package/dist/token-input.cjs +9 -0
- package/dist/token-input.d.cts +2 -0
- package/dist/token-input.d.ts +2 -0
- package/dist/token-input.js +1 -0
- package/dist/toolbar.cjs +62 -0
- package/dist/toolbar.d.cts +58 -0
- package/dist/toolbar.d.ts +58 -0
- package/dist/toolbar.js +61 -0
- package/dist/tooltip.cjs +149 -0
- package/dist/tooltip.d.cts +208 -0
- package/dist/tooltip.d.ts +208 -0
- package/dist/tooltip.js +147 -0
- package/dist/tree-grid.cjs +127 -0
- package/dist/tree-grid.d.cts +130 -0
- package/dist/tree-grid.d.ts +130 -0
- package/dist/tree-grid.js +126 -0
- package/dist/tree.cjs +227 -0
- package/dist/tree.d.cts +223 -0
- package/dist/tree.d.ts +223 -0
- package/dist/tree.js +226 -0
- package/dist/trigger-menu-8FAwypbs.d.cts +347 -0
- package/dist/trigger-menu-B898rWkz.cjs +502 -0
- package/dist/trigger-menu-C2YHe7es.d.ts +347 -0
- package/dist/trigger-menu-CxzocSWO.js +431 -0
- package/dist/trigger-menu.cjs +22 -0
- package/dist/trigger-menu.d.cts +2 -0
- package/dist/trigger-menu.d.ts +2 -0
- package/dist/trigger-menu.js +2 -0
- package/dist/virtual-list-strict.cjs +126 -0
- package/dist/virtual-list-strict.d.cts +69 -0
- package/dist/virtual-list-strict.d.ts +69 -0
- package/dist/virtual-list-strict.js +125 -0
- package/dist/virtual-list.cjs +65 -0
- package/dist/virtual-list.d.cts +82 -0
- package/dist/virtual-list.d.ts +82 -0
- package/dist/virtual-list.js +64 -0
- package/dist/virtual.cjs +27 -0
- package/dist/virtual.d.cts +30 -0
- package/dist/virtual.d.ts +30 -0
- package/dist/virtual.js +26 -0
- package/dist/vue-helpers-Bh_YF48i.cjs +102 -0
- package/dist/vue-helpers-Z3oOAHYB.js +55 -0
- package/dist/waterfall-chart.cjs +114 -0
- package/dist/waterfall-chart.d.cts +117 -0
- package/dist/waterfall-chart.d.ts +117 -0
- package/dist/waterfall-chart.js +113 -0
- package/dist/waterfall.cjs +296 -0
- package/dist/waterfall.d.cts +219 -0
- package/dist/waterfall.d.ts +219 -0
- package/dist/waterfall.js +284 -0
- package/package.json +518 -3
- package/README.md +0 -3
|
@@ -0,0 +1,643 @@
|
|
|
1
|
+
import { n as usePrimitive, t as renderPart } from "./headless-B3zQWaJm.js";
|
|
2
|
+
import { t as vueOptions } from "./options-BlkyK-uO.js";
|
|
3
|
+
import { r as hostAttrs } from "./vue-helpers-Z3oOAHYB.js";
|
|
4
|
+
import { calendarDayMarks, calendarHeadingText, calendarMonthWeeks, calendarPrimitive, calendarSelection, calendarStepBounds, calendarWeekdayLabels, matchesDate, selectCalendarDay, toCivilDate } from "@bevelo/core";
|
|
5
|
+
import { Fragment, computed, defineComponent, h, inject, onBeforeUnmount, provide, ref, shallowRef } from "vue";
|
|
6
|
+
import { addMonths, compare, formatISODate, startOfMonth } from "@bevelo/date";
|
|
7
|
+
// src/calendar-compound.ts
|
|
8
|
+
const calendarScopeKey = Symbol("calendar-scope");
|
|
9
|
+
const gridOffsetKey = Symbol("calendar-grid-offset");
|
|
10
|
+
const dayKey = Symbol("calendar-day");
|
|
11
|
+
function provideCalendarScope(scope) {
|
|
12
|
+
provide(calendarScopeKey, scope);
|
|
13
|
+
}
|
|
14
|
+
function stepLabel(scope, delta) {
|
|
15
|
+
return calendarHeadingText(addMonths(scope.month(), delta), 1, scope.locale());
|
|
16
|
+
}
|
|
17
|
+
function stepButton(direction) {
|
|
18
|
+
return defineComponent({
|
|
19
|
+
name: direction < 0 ? "CalendarPrevious" : "CalendarNext",
|
|
20
|
+
props: { disabled: {
|
|
21
|
+
type: Boolean,
|
|
22
|
+
default: false
|
|
23
|
+
} },
|
|
24
|
+
setup(props, { slots, attrs }) {
|
|
25
|
+
const scope = inject(calendarScopeKey, null);
|
|
26
|
+
return () => {
|
|
27
|
+
if (scope === null) return null;
|
|
28
|
+
const step = (scope.pageBy() === "page" ? scope.count() : 1) * direction;
|
|
29
|
+
const bounds = scope.canStep();
|
|
30
|
+
const off = props.disabled || !(direction < 0 ? bounds.backward : bounds.forward);
|
|
31
|
+
return h("button", {
|
|
32
|
+
type: "button",
|
|
33
|
+
"aria-label": direction < 0 ? "Previous month" : "Next month",
|
|
34
|
+
"data-part": direction < 0 ? "previous" : "next",
|
|
35
|
+
"data-slot": direction < 0 ? "calendar-previous" : "calendar-next",
|
|
36
|
+
...attrs,
|
|
37
|
+
disabled: off ? true : void 0,
|
|
38
|
+
"data-disabled": off ? "" : void 0,
|
|
39
|
+
onClick: (event) => {
|
|
40
|
+
if (event.defaultPrevented || off) return;
|
|
41
|
+
event.preventDefault();
|
|
42
|
+
scope.stepMonth(step);
|
|
43
|
+
}
|
|
44
|
+
}, slots.default?.({ month: stepLabel(scope, step) }) ?? h("span", { "aria-hidden": "true" }, direction < 0 ? "‹" : "›"));
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/** Steps back one month (or one page with `pageBy="page"`); disabled at `min`. */
|
|
50
|
+
const CalendarPrevious = stepButton(-1);
|
|
51
|
+
/** Steps forward one month (or one page); disabled at `max`. */
|
|
52
|
+
const CalendarNext = stepButton(1);
|
|
53
|
+
/** The shown months' heading; the default slot receives `{ label, month, year }`. */
|
|
54
|
+
const CalendarHeading = defineComponent({
|
|
55
|
+
name: "CalendarHeading",
|
|
56
|
+
setup(_props, { slots, attrs }) {
|
|
57
|
+
const scope = inject(calendarScopeKey, null);
|
|
58
|
+
return () => {
|
|
59
|
+
if (scope === null) return null;
|
|
60
|
+
const month = scope.month();
|
|
61
|
+
const label = calendarHeadingText(month, scope.count(), scope.locale(), scope.monthFormat());
|
|
62
|
+
const content = slots.default?.({
|
|
63
|
+
label,
|
|
64
|
+
month: month.month,
|
|
65
|
+
year: month.year
|
|
66
|
+
}) ?? label;
|
|
67
|
+
return renderPart(scope.handle, "heading", {
|
|
68
|
+
...attrs,
|
|
69
|
+
tag: "h2"
|
|
70
|
+
}, content);
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
function selectPart(kind) {
|
|
75
|
+
return defineComponent({
|
|
76
|
+
name: kind === "month" ? "CalendarMonthSelect" : "CalendarYearSelect",
|
|
77
|
+
setup(_props, { slots, attrs }) {
|
|
78
|
+
const scope = inject(calendarScopeKey, null);
|
|
79
|
+
return () => {
|
|
80
|
+
if (scope === null) return null;
|
|
81
|
+
const month = scope.month();
|
|
82
|
+
const options = kind === "month" ? scope.months() : scope.years().map((year) => ({
|
|
83
|
+
value: year,
|
|
84
|
+
label: String(year),
|
|
85
|
+
disabled: false
|
|
86
|
+
}));
|
|
87
|
+
const value = kind === "month" ? month.month : month.year;
|
|
88
|
+
return h("select", {
|
|
89
|
+
"data-part": kind,
|
|
90
|
+
"data-slot": kind === "month" ? "calendar-month-select" : "calendar-year-select",
|
|
91
|
+
"aria-label": kind === "month" ? "Month" : "Year",
|
|
92
|
+
value: String(value),
|
|
93
|
+
...attrs,
|
|
94
|
+
onChange: (event) => {
|
|
95
|
+
const next = Number(event.currentTarget.value);
|
|
96
|
+
if (!Number.isFinite(next)) return;
|
|
97
|
+
if (kind === "month") scope.selectMonth(month.year, next);
|
|
98
|
+
else scope.selectMonth(next, month.month);
|
|
99
|
+
}
|
|
100
|
+
}, slots.default?.({
|
|
101
|
+
options,
|
|
102
|
+
value
|
|
103
|
+
}) ?? options.map((choice) => h("option", {
|
|
104
|
+
key: choice.value,
|
|
105
|
+
value: String(choice.value),
|
|
106
|
+
disabled: choice.disabled || void 0
|
|
107
|
+
}, choice.label)));
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
/** A select over the twelve months; the default slot receives `{ options, value }`. */
|
|
113
|
+
const CalendarMonthSelect = selectPart("month");
|
|
114
|
+
/** A select over the bounded years; the default slot receives `{ options, value }`. */
|
|
115
|
+
const CalendarYearSelect = selectPart("year");
|
|
116
|
+
/** One month's table; `offset` shows a later month beside the first. */
|
|
117
|
+
const CalendarGrid = defineComponent({
|
|
118
|
+
name: "CalendarGrid",
|
|
119
|
+
props: { offset: {
|
|
120
|
+
type: Number,
|
|
121
|
+
default: 0
|
|
122
|
+
} },
|
|
123
|
+
setup(props, { slots, attrs }) {
|
|
124
|
+
const scope = inject(calendarScopeKey, null);
|
|
125
|
+
provide(gridOffsetKey, props.offset);
|
|
126
|
+
return () => {
|
|
127
|
+
if (scope === null) return null;
|
|
128
|
+
const content = slots.default?.();
|
|
129
|
+
if (props.offset === 0) return renderPart(scope.handle, "root", {
|
|
130
|
+
...attrs,
|
|
131
|
+
tag: "table"
|
|
132
|
+
}, content);
|
|
133
|
+
return h("table", {
|
|
134
|
+
role: "grid",
|
|
135
|
+
"aria-label": calendarHeadingText(addMonths(scope.month(), props.offset), 1, scope.locale()),
|
|
136
|
+
"data-part": "grid",
|
|
137
|
+
"data-slot": "calendar-grid",
|
|
138
|
+
...attrs
|
|
139
|
+
}, content);
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
/** The weekday header row; the default slot receives `{ index }` per column. */
|
|
144
|
+
const CalendarWeekdays = defineComponent({
|
|
145
|
+
name: "CalendarWeekdays",
|
|
146
|
+
setup(_props, { slots, attrs }) {
|
|
147
|
+
return () => h("thead", attrs, [h("tr", {
|
|
148
|
+
role: "row",
|
|
149
|
+
"data-part": "weekdays",
|
|
150
|
+
"data-slot": "calendar-weekdays"
|
|
151
|
+
}, Array.from({ length: 7 }, (_, index) => slots.default !== void 0 ? slots.default({ index }) : h(CalendarWeekday, {
|
|
152
|
+
key: index,
|
|
153
|
+
index
|
|
154
|
+
})))]);
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
/** One weekday header; the default slot receives `{ weekday, label, name, weekend }`. */
|
|
158
|
+
const CalendarWeekday = defineComponent({
|
|
159
|
+
name: "CalendarWeekday",
|
|
160
|
+
props: { index: {
|
|
161
|
+
type: Number,
|
|
162
|
+
default: 0
|
|
163
|
+
} },
|
|
164
|
+
setup(props, { slots, attrs }) {
|
|
165
|
+
const scope = inject(calendarScopeKey, null);
|
|
166
|
+
return () => {
|
|
167
|
+
const day = calendarWeekdayLabels(scope?.locale() ?? "en-US", scope?.weekStartsOn() ?? 0, scope?.weekdayFormat())[props.index % 7];
|
|
168
|
+
return h("th", {
|
|
169
|
+
scope: "col",
|
|
170
|
+
role: "columnheader",
|
|
171
|
+
"data-part": "weekday",
|
|
172
|
+
"data-slot": "calendar-weekday",
|
|
173
|
+
...attrs
|
|
174
|
+
}, slots.default?.(day) ?? h("abbr", {
|
|
175
|
+
title: day.name,
|
|
176
|
+
"data-weekend": day.weekend ? "" : void 0
|
|
177
|
+
}, day.label));
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
const DayScope = defineComponent({
|
|
182
|
+
name: "CalendarDayScope",
|
|
183
|
+
props: { value: {
|
|
184
|
+
type: Object,
|
|
185
|
+
required: true
|
|
186
|
+
} },
|
|
187
|
+
setup(props, { slots }) {
|
|
188
|
+
provide(dayKey, props.value);
|
|
189
|
+
return () => slots.default?.();
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
/** The week rows of the grid's month; the default slot renders one cell from `{ date, civilDate, label, outside, disabled }`. */
|
|
193
|
+
const CalendarWeeks = defineComponent({
|
|
194
|
+
name: "CalendarWeeks",
|
|
195
|
+
setup(_props, { slots, attrs }) {
|
|
196
|
+
const scope = inject(calendarScopeKey, null);
|
|
197
|
+
const offset = inject(gridOffsetKey, 0);
|
|
198
|
+
return () => {
|
|
199
|
+
if (scope === null) return null;
|
|
200
|
+
const weeks = calendarMonthWeeks(addMonths(scope.month(), offset), scope.weekStartsOn(), scope.fixedWeeks());
|
|
201
|
+
let index = 0;
|
|
202
|
+
return h("tbody", attrs, weeks.map((week) => h("tr", {
|
|
203
|
+
key: week[0].iso,
|
|
204
|
+
role: "row",
|
|
205
|
+
"data-part": "week",
|
|
206
|
+
"data-slot": "calendar-week"
|
|
207
|
+
}, week.map((cell) => {
|
|
208
|
+
if (!cell.inMonth && !scope.showOutsideDays()) return h("td", { key: cell.iso });
|
|
209
|
+
const at = index++;
|
|
210
|
+
const disabled = scope.isDisabled(cell.date);
|
|
211
|
+
const inner = slots.default !== void 0 ? slots.default({
|
|
212
|
+
date: cell.iso,
|
|
213
|
+
civilDate: cell.date,
|
|
214
|
+
label: String(cell.date.day),
|
|
215
|
+
outside: !cell.inMonth,
|
|
216
|
+
disabled
|
|
217
|
+
}) : h(CalendarDay);
|
|
218
|
+
return h(DayScope, {
|
|
219
|
+
key: cell.iso,
|
|
220
|
+
value: {
|
|
221
|
+
cell,
|
|
222
|
+
index: at,
|
|
223
|
+
offset,
|
|
224
|
+
disabled
|
|
225
|
+
}
|
|
226
|
+
}, () => inner);
|
|
227
|
+
}))));
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
/** One day cell; the default slot receives its state (selected, range marks, unavailable, today). */
|
|
232
|
+
const CalendarDay = defineComponent({
|
|
233
|
+
name: "CalendarDay",
|
|
234
|
+
props: { value: {
|
|
235
|
+
type: [Object, String],
|
|
236
|
+
default: void 0
|
|
237
|
+
} },
|
|
238
|
+
setup(props, { slots, attrs }) {
|
|
239
|
+
const scope = inject(calendarScopeKey, null);
|
|
240
|
+
const day = inject(dayKey, null);
|
|
241
|
+
return () => {
|
|
242
|
+
if (scope === null) return null;
|
|
243
|
+
const date = toCivilDate(props.value) ?? day?.cell.date;
|
|
244
|
+
if (date === void 0) return null;
|
|
245
|
+
const iso = formatISODate(date);
|
|
246
|
+
const offset = day?.offset ?? 0;
|
|
247
|
+
const outside = day ? !day.cell.inMonth : false;
|
|
248
|
+
const disabled = day?.disabled ?? scope.isDisabled(date);
|
|
249
|
+
const unavailable = scope.isUnavailable(date);
|
|
250
|
+
const today = scope.today() !== void 0 && compare(date, scope.today()) === 0;
|
|
251
|
+
const marks = calendarDayMarks(iso, scope.selection(), scope.mode(), scope.hovered());
|
|
252
|
+
const hover = () => {
|
|
253
|
+
if (scope.mode() !== "range") return;
|
|
254
|
+
scope.hoverDay(disabled || !scope.allowUnavailable() && unavailable ? void 0 : iso);
|
|
255
|
+
};
|
|
256
|
+
const content = slots.default?.({
|
|
257
|
+
date: iso,
|
|
258
|
+
label: String(date.day),
|
|
259
|
+
outside,
|
|
260
|
+
disabled,
|
|
261
|
+
selected: marks.selected,
|
|
262
|
+
unavailable,
|
|
263
|
+
today,
|
|
264
|
+
rangeStart: marks.rangeStart,
|
|
265
|
+
rangeMiddle: marks.rangeMiddle,
|
|
266
|
+
rangeEnd: marks.rangeEnd
|
|
267
|
+
}) ?? String(date.day);
|
|
268
|
+
const markAttrs = {
|
|
269
|
+
...attrs,
|
|
270
|
+
"data-selected": marks.selected ? "" : void 0,
|
|
271
|
+
"aria-selected": marks.selected ? "true" : void 0,
|
|
272
|
+
"data-range-start": marks.rangeStart ? "" : void 0,
|
|
273
|
+
"data-range-end": marks.rangeEnd ? "" : void 0,
|
|
274
|
+
"data-in-range": marks.rangeMiddle ? "" : void 0,
|
|
275
|
+
"data-range-middle": marks.rangeMiddle ? "" : void 0,
|
|
276
|
+
"data-unavailable": unavailable ? "" : void 0,
|
|
277
|
+
"data-today": today ? "" : void 0,
|
|
278
|
+
"aria-current": today ? "date" : void 0,
|
|
279
|
+
onMouseenter: hover,
|
|
280
|
+
onFocus: hover
|
|
281
|
+
};
|
|
282
|
+
if (offset === 0 && day !== null) return renderPart(scope.handle, "day", {
|
|
283
|
+
...markAttrs,
|
|
284
|
+
tag: "td"
|
|
285
|
+
}, content, { index: day.index });
|
|
286
|
+
return h("td", {
|
|
287
|
+
role: "gridcell",
|
|
288
|
+
"data-part": "day",
|
|
289
|
+
"data-slot": "calendar-day",
|
|
290
|
+
"data-date": iso,
|
|
291
|
+
"data-outside": outside ? "" : void 0,
|
|
292
|
+
"data-disabled": disabled ? "" : void 0,
|
|
293
|
+
"aria-disabled": disabled ? "true" : void 0,
|
|
294
|
+
tabindex: -1,
|
|
295
|
+
...markAttrs,
|
|
296
|
+
onClick: (event) => {
|
|
297
|
+
if (!event.defaultPrevented) scope.selectDay(date);
|
|
298
|
+
}
|
|
299
|
+
}, content);
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
/** The default composition: previous, heading, next, then one grid per shown month. */
|
|
304
|
+
function defaultCalendarParts(count) {
|
|
305
|
+
return [h("div", {
|
|
306
|
+
key: "nav",
|
|
307
|
+
"data-slot": "row"
|
|
308
|
+
}, [
|
|
309
|
+
h(CalendarPrevious),
|
|
310
|
+
h(CalendarHeading),
|
|
311
|
+
h(CalendarNext)
|
|
312
|
+
]), h("div", {
|
|
313
|
+
key: "grids",
|
|
314
|
+
"data-slot": "row"
|
|
315
|
+
}, Array.from({ length: count }, (_, offset) => h(CalendarGrid, {
|
|
316
|
+
key: offset,
|
|
317
|
+
offset
|
|
318
|
+
}, () => [h(CalendarWeekdays), h(CalendarWeeks)])))];
|
|
319
|
+
}
|
|
320
|
+
// src/calendar.ts
|
|
321
|
+
const schema = vueOptions(calendarPrimitive, {
|
|
322
|
+
modelValue: ["selected", "onSelect"],
|
|
323
|
+
selected: ["selected", "onSelect"],
|
|
324
|
+
month: ["month", "onMonthChange"]
|
|
325
|
+
});
|
|
326
|
+
/** A controller for a `Calendar`: pass it as `controller`, read `api` once mounted. */
|
|
327
|
+
function createCalendarController() {
|
|
328
|
+
return {};
|
|
329
|
+
}
|
|
330
|
+
const Calendar = defineComponent({
|
|
331
|
+
name: "Calendar",
|
|
332
|
+
inheritAttrs: false,
|
|
333
|
+
props: {
|
|
334
|
+
...schema.props,
|
|
335
|
+
month: {
|
|
336
|
+
type: Object,
|
|
337
|
+
required: false
|
|
338
|
+
},
|
|
339
|
+
defaultMonth: {
|
|
340
|
+
type: Object,
|
|
341
|
+
required: false
|
|
342
|
+
},
|
|
343
|
+
today: {
|
|
344
|
+
type: Object,
|
|
345
|
+
required: false
|
|
346
|
+
},
|
|
347
|
+
weekStartsOn: {
|
|
348
|
+
type: Number,
|
|
349
|
+
required: false
|
|
350
|
+
},
|
|
351
|
+
showOutsideDays: {
|
|
352
|
+
type: Boolean,
|
|
353
|
+
default: void 0
|
|
354
|
+
},
|
|
355
|
+
fixedWeeks: {
|
|
356
|
+
type: Boolean,
|
|
357
|
+
default: void 0
|
|
358
|
+
},
|
|
359
|
+
selected: {
|
|
360
|
+
type: Object,
|
|
361
|
+
required: false
|
|
362
|
+
},
|
|
363
|
+
isDateDisabled: {
|
|
364
|
+
type: Function,
|
|
365
|
+
required: false
|
|
366
|
+
},
|
|
367
|
+
disabled: {
|
|
368
|
+
type: Boolean,
|
|
369
|
+
default: false
|
|
370
|
+
},
|
|
371
|
+
readOnly: {
|
|
372
|
+
type: Boolean,
|
|
373
|
+
default: false
|
|
374
|
+
},
|
|
375
|
+
locale: {
|
|
376
|
+
type: String,
|
|
377
|
+
default: "en-US"
|
|
378
|
+
},
|
|
379
|
+
header: {
|
|
380
|
+
type: Boolean,
|
|
381
|
+
default: false
|
|
382
|
+
},
|
|
383
|
+
min: {
|
|
384
|
+
type: Object,
|
|
385
|
+
required: false
|
|
386
|
+
},
|
|
387
|
+
max: {
|
|
388
|
+
type: Object,
|
|
389
|
+
required: false
|
|
390
|
+
},
|
|
391
|
+
label: {
|
|
392
|
+
type: String,
|
|
393
|
+
default: "Calendar"
|
|
394
|
+
},
|
|
395
|
+
id: {
|
|
396
|
+
type: String,
|
|
397
|
+
required: false
|
|
398
|
+
},
|
|
399
|
+
/** How the value holds days: one, a start/end range, or a set. */
|
|
400
|
+
mode: {
|
|
401
|
+
type: String,
|
|
402
|
+
default: void 0
|
|
403
|
+
},
|
|
404
|
+
/** The selection (`v-model:value`): ISO text, an ISO list, or a range pair. */
|
|
405
|
+
value: {
|
|
406
|
+
type: [
|
|
407
|
+
String,
|
|
408
|
+
Array,
|
|
409
|
+
Object
|
|
410
|
+
],
|
|
411
|
+
default: void 0
|
|
412
|
+
},
|
|
413
|
+
defaultValue: {
|
|
414
|
+
type: [
|
|
415
|
+
String,
|
|
416
|
+
Array,
|
|
417
|
+
Object
|
|
418
|
+
],
|
|
419
|
+
default: void 0
|
|
420
|
+
},
|
|
421
|
+
/** Days that cannot be chosen and that a range cannot span. */
|
|
422
|
+
unavailable: {
|
|
423
|
+
type: [
|
|
424
|
+
String,
|
|
425
|
+
Array,
|
|
426
|
+
Object,
|
|
427
|
+
Function
|
|
428
|
+
],
|
|
429
|
+
default: void 0
|
|
430
|
+
},
|
|
431
|
+
allowUnavailable: {
|
|
432
|
+
type: Boolean,
|
|
433
|
+
default: false
|
|
434
|
+
},
|
|
435
|
+
/** Single mode: pressing the selected day clears it. */
|
|
436
|
+
deselectable: {
|
|
437
|
+
type: Boolean,
|
|
438
|
+
default: false
|
|
439
|
+
},
|
|
440
|
+
minDays: {
|
|
441
|
+
type: Number,
|
|
442
|
+
default: void 0
|
|
443
|
+
},
|
|
444
|
+
maxDays: {
|
|
445
|
+
type: Number,
|
|
446
|
+
default: void 0
|
|
447
|
+
},
|
|
448
|
+
/** How many months show side by side. */
|
|
449
|
+
months: {
|
|
450
|
+
type: Number,
|
|
451
|
+
default: void 0
|
|
452
|
+
},
|
|
453
|
+
/** `"page"` steps by all shown months. */
|
|
454
|
+
pageBy: {
|
|
455
|
+
type: String,
|
|
456
|
+
default: "month"
|
|
457
|
+
},
|
|
458
|
+
monthFormat: {
|
|
459
|
+
type: String,
|
|
460
|
+
default: void 0
|
|
461
|
+
},
|
|
462
|
+
weekdayFormat: {
|
|
463
|
+
type: String,
|
|
464
|
+
default: void 0
|
|
465
|
+
},
|
|
466
|
+
controller: {
|
|
467
|
+
type: Object,
|
|
468
|
+
default: void 0
|
|
469
|
+
}
|
|
470
|
+
},
|
|
471
|
+
emits: {
|
|
472
|
+
...schema.emits,
|
|
473
|
+
change: (_value, _details) => true,
|
|
474
|
+
"update:value": (_value) => true
|
|
475
|
+
},
|
|
476
|
+
setup(props, { attrs, slots, emit, expose }) {
|
|
477
|
+
const compound = () => slots.default !== void 0 || props.mode !== void 0 || props.value !== void 0 || props.defaultValue !== void 0 || props.unavailable !== void 0 || props.months !== void 0 || props.monthFormat !== void 0 || props.weekdayFormat !== void 0 || props.deselectable || props.minDays !== void 0 || props.maxDays !== void 0;
|
|
478
|
+
const mode = () => props.mode ?? "single";
|
|
479
|
+
const own = shallowRef(props.defaultValue);
|
|
480
|
+
const hovered = ref(void 0);
|
|
481
|
+
const current = () => props.value !== void 0 ? props.value : own.value;
|
|
482
|
+
const selection = computed(() => calendarSelection(current(), mode()));
|
|
483
|
+
let committed = props.defaultValue;
|
|
484
|
+
const emitValue = (next, reason) => {
|
|
485
|
+
if (props.value === void 0) own.value = next;
|
|
486
|
+
const after = calendarSelection(next, mode());
|
|
487
|
+
if (mode() !== "range" || after.start === void 0 || after.end !== void 0) committed = next;
|
|
488
|
+
emit("change", next, { reason });
|
|
489
|
+
emit("update:value", next);
|
|
490
|
+
};
|
|
491
|
+
const isUnavailable = (date) => matchesDate(date, props.unavailable);
|
|
492
|
+
let kernel;
|
|
493
|
+
const selectDay = (date) => {
|
|
494
|
+
if (props.disabled || props.readOnly) return;
|
|
495
|
+
const outcome = selectCalendarDay(selection.value, date, {
|
|
496
|
+
mode: mode(),
|
|
497
|
+
deselectable: props.deselectable,
|
|
498
|
+
allowUnavailable: props.allowUnavailable,
|
|
499
|
+
minDays: props.minDays,
|
|
500
|
+
maxDays: props.maxDays,
|
|
501
|
+
isUnavailable,
|
|
502
|
+
isDisabled: (day) => kernel?.isDisabled(day) ?? false
|
|
503
|
+
});
|
|
504
|
+
if (outcome === void 0) return;
|
|
505
|
+
emit("select", date);
|
|
506
|
+
hovered.value = void 0;
|
|
507
|
+
emitValue(outcome.value, "day-press");
|
|
508
|
+
};
|
|
509
|
+
const handle = usePrimitive(calendarPrimitive, schema.bind(props, () => {
|
|
510
|
+
if (!compound()) return {};
|
|
511
|
+
const primary = selection.value.primary;
|
|
512
|
+
return {
|
|
513
|
+
selected: mode() === "single" ? primary : void 0,
|
|
514
|
+
defaultMonth: props.defaultMonth ?? primary,
|
|
515
|
+
header: true,
|
|
516
|
+
onSelect: selectDay
|
|
517
|
+
};
|
|
518
|
+
}));
|
|
519
|
+
kernel = handle.api;
|
|
520
|
+
const api = kernel;
|
|
521
|
+
const controllerApi = {
|
|
522
|
+
...api,
|
|
523
|
+
setValue: (next) => emitValue(next, "imperative"),
|
|
524
|
+
focus: (target) => {
|
|
525
|
+
const date = toCivilDate(target);
|
|
526
|
+
if (date === void 0) return;
|
|
527
|
+
api.pickMonth(startOfMonth(date));
|
|
528
|
+
api.moveTo(date);
|
|
529
|
+
},
|
|
530
|
+
setMonth: (target) => {
|
|
531
|
+
const date = toCivilDate(target);
|
|
532
|
+
if (date !== void 0) api.pickMonth(startOfMonth(date));
|
|
533
|
+
}
|
|
534
|
+
};
|
|
535
|
+
if (props.controller !== void 0) props.controller.api = controllerApi;
|
|
536
|
+
onBeforeUnmount(() => {
|
|
537
|
+
if (props.controller?.api === controllerApi) delete props.controller.api;
|
|
538
|
+
});
|
|
539
|
+
expose({ api: controllerApi });
|
|
540
|
+
const count = () => Math.max(1, Math.floor(props.months ?? 1) || 1);
|
|
541
|
+
const shown = () => {
|
|
542
|
+
handle.revision.value;
|
|
543
|
+
return startOfMonth(api.month());
|
|
544
|
+
};
|
|
545
|
+
provideCalendarScope({
|
|
546
|
+
handle,
|
|
547
|
+
months: () => {
|
|
548
|
+
handle.revision.value;
|
|
549
|
+
return api.months();
|
|
550
|
+
},
|
|
551
|
+
years: () => {
|
|
552
|
+
handle.revision.value;
|
|
553
|
+
return api.years();
|
|
554
|
+
},
|
|
555
|
+
month: shown,
|
|
556
|
+
locale: () => props.locale,
|
|
557
|
+
weekStartsOn: () => props.weekStartsOn ?? 0,
|
|
558
|
+
showOutsideDays: () => props.showOutsideDays !== false,
|
|
559
|
+
fixedWeeks: () => props.fixedWeeks === true,
|
|
560
|
+
count,
|
|
561
|
+
pageBy: () => props.pageBy,
|
|
562
|
+
monthFormat: () => props.monthFormat ?? "long",
|
|
563
|
+
weekdayFormat: () => props.weekdayFormat ?? "short",
|
|
564
|
+
mode,
|
|
565
|
+
allowUnavailable: () => props.allowUnavailable,
|
|
566
|
+
selection: () => selection.value,
|
|
567
|
+
hovered: () => hovered.value,
|
|
568
|
+
today: () => props.today,
|
|
569
|
+
canStep: () => calendarStepBounds({
|
|
570
|
+
month: shown(),
|
|
571
|
+
months: count(),
|
|
572
|
+
min: props.min,
|
|
573
|
+
max: props.max,
|
|
574
|
+
disabled: props.disabled
|
|
575
|
+
}),
|
|
576
|
+
isUnavailable,
|
|
577
|
+
isDisabled: (date) => api.isDisabled(date),
|
|
578
|
+
stepMonth: (delta) => api.pickMonth(addMonths(shown(), delta)),
|
|
579
|
+
selectDay: (date) => api.select(date),
|
|
580
|
+
hoverDay: (iso) => {
|
|
581
|
+
if (mode() === "range") hovered.value = iso;
|
|
582
|
+
},
|
|
583
|
+
selectMonth: (year, month) => api.pickMonth({
|
|
584
|
+
year,
|
|
585
|
+
month,
|
|
586
|
+
day: 1
|
|
587
|
+
})
|
|
588
|
+
});
|
|
589
|
+
const renderCompound = () => h("div", {
|
|
590
|
+
"data-slot": "calendar",
|
|
591
|
+
"data-disabled": props.disabled ? "" : void 0,
|
|
592
|
+
id: props.id,
|
|
593
|
+
...attrs,
|
|
594
|
+
onMouseleave: () => {
|
|
595
|
+
if (mode() === "range") hovered.value = void 0;
|
|
596
|
+
},
|
|
597
|
+
onKeydown: (event) => {
|
|
598
|
+
const open = selection.value;
|
|
599
|
+
if (event.key !== "Escape" || mode() !== "range" || open.start === void 0 || open.end !== void 0) return;
|
|
600
|
+
event.preventDefault();
|
|
601
|
+
hovered.value = void 0;
|
|
602
|
+
emitValue(committed, "escape");
|
|
603
|
+
}
|
|
604
|
+
}, slots.default?.() ?? defaultCalendarParts(count()));
|
|
605
|
+
const stateOf = (name, address) => {
|
|
606
|
+
return handle.part(name, address)?.state ?? {};
|
|
607
|
+
};
|
|
608
|
+
return () => {
|
|
609
|
+
handle.revision.value;
|
|
610
|
+
if (compound()) return renderCompound();
|
|
611
|
+
const weekdayCells = Array.from({ length: 7 }, (_, index) => renderPart(handle, "weekday", { key: index }, String(stateOf("weekday", { index })["name"] ?? ""), { index }));
|
|
612
|
+
const weekdays = renderPart(handle, "weekdays", { key: "weekdays" }, weekdayCells);
|
|
613
|
+
const weeks = api.grid().weeks;
|
|
614
|
+
let offset = 0;
|
|
615
|
+
const weekRows = weeks.map((week, index) => {
|
|
616
|
+
const rowOffset = offset;
|
|
617
|
+
const cells = week.map((cell, position) => renderPart(handle, "day", { key: formatISODate(cell.date) }, String(cell.date.day), { index: rowOffset + position }));
|
|
618
|
+
offset += week.length;
|
|
619
|
+
return renderPart(handle, "week", { key: `week:${formatISODate(week[0]?.date ?? props.month)}` }, cells, { index });
|
|
620
|
+
});
|
|
621
|
+
const host = hostAttrs(attrs, { id: props.id });
|
|
622
|
+
const grid = renderPart(handle, "root", host, [h(Fragment, null, [weekdays, ...weekRows])]);
|
|
623
|
+
if (!props.header) return grid;
|
|
624
|
+
const heading = renderPart(handle, "heading", { key: "heading" }, String(stateOf("heading")["text"] ?? ""));
|
|
625
|
+
const monthSelect = renderPart(handle, "month", { key: "month" }, api.months().map((choice) => h("option", {
|
|
626
|
+
key: choice.value,
|
|
627
|
+
value: String(choice.value),
|
|
628
|
+
disabled: choice.disabled === true ? true : void 0
|
|
629
|
+
}, choice.label)));
|
|
630
|
+
const yearSelect = renderPart(handle, "year", { key: "year" }, api.years().map((year) => h("option", {
|
|
631
|
+
key: year,
|
|
632
|
+
value: String(year)
|
|
633
|
+
}, String(year))));
|
|
634
|
+
const headerRow = renderPart(handle, "header", { key: "header" }, [h(Fragment, null, [
|
|
635
|
+
heading,
|
|
636
|
+
monthSelect,
|
|
637
|
+
yearSelect
|
|
638
|
+
])]);
|
|
639
|
+
return renderPart(handle, "frame", {}, [h(Fragment, null, [headerRow, grid])]);
|
|
640
|
+
};
|
|
641
|
+
}
|
|
642
|
+
});
|
|
643
|
+
export { CalendarHeading as a, CalendarPrevious as c, CalendarWeeks as d, CalendarYearSelect as f, CalendarGrid as i, CalendarWeekday as l, createCalendarController as n, CalendarMonthSelect as o, provideCalendarScope as p, CalendarDay as r, CalendarNext as s, Calendar as t, CalendarWeekdays as u };
|