@ember-joinery/primitives 0.0.0-stage → 1.0.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/CHANGELOG.md +472 -0
- package/LICENSE.md +9 -0
- package/NOTICE +532 -0
- package/README.md +11 -2
- package/addon-main.cjs +4 -0
- package/declarations/-private/combobox-list.d.ts +59 -0
- package/declarations/-private/combobox-list.d.ts.map +1 -0
- package/declarations/-private/command-score.d.ts +33 -0
- package/declarations/-private/command-score.d.ts.map +1 -0
- package/declarations/-private/delay-group.d.ts +47 -0
- package/declarations/-private/delay-group.d.ts.map +1 -0
- package/declarations/-private/dialog.d.ts +180 -0
- package/declarations/-private/dialog.d.ts.map +1 -0
- package/declarations/-private/form-control.d.ts +70 -0
- package/declarations/-private/form-control.d.ts.map +1 -0
- package/declarations/-private/form-data.d.ts +14 -0
- package/declarations/-private/form-data.d.ts.map +1 -0
- package/declarations/-private/hover-intent.d.ts +48 -0
- package/declarations/-private/hover-intent.d.ts.map +1 -0
- package/declarations/-private/image-loading.d.ts +77 -0
- package/declarations/-private/image-loading.d.ts.map +1 -0
- package/declarations/-private/indicator.d.ts +27 -0
- package/declarations/-private/indicator.d.ts.map +1 -0
- package/declarations/-private/instances.d.ts +11 -0
- package/declarations/-private/instances.d.ts.map +1 -0
- package/declarations/-private/layout-styles.d.ts +34 -0
- package/declarations/-private/layout-styles.d.ts.map +1 -0
- package/declarations/-private/menu.d.ts +616 -0
- package/declarations/-private/menu.d.ts.map +1 -0
- package/declarations/-private/observers.d.ts +35 -0
- package/declarations/-private/observers.d.ts.map +1 -0
- package/declarations/-private/popper.d.ts +149 -0
- package/declarations/-private/popper.d.ts.map +1 -0
- package/declarations/-private/presence-chart.d.ts +39 -0
- package/declarations/-private/presence-chart.d.ts.map +1 -0
- package/declarations/-private/promise-state.d.ts +41 -0
- package/declarations/-private/promise-state.d.ts.map +1 -0
- package/declarations/-private/scroll-end.d.ts +16 -0
- package/declarations/-private/scroll-end.d.ts.map +1 -0
- package/declarations/-private/scroll-visibility.d.ts +68 -0
- package/declarations/-private/scroll-visibility.d.ts.map +1 -0
- package/declarations/-private/toast.d.ts +119 -0
- package/declarations/-private/toast.d.ts.map +1 -0
- package/declarations/-private/typeahead-search.d.ts +29 -0
- package/declarations/-private/typeahead-search.d.ts.map +1 -0
- package/declarations/accordion.d.ts +284 -0
- package/declarations/accordion.d.ts.map +1 -0
- package/declarations/alert-dialog.d.ts +80 -0
- package/declarations/alert-dialog.d.ts.map +1 -0
- package/declarations/anchor/component.d.ts +63 -0
- package/declarations/anchor/component.d.ts.map +1 -0
- package/declarations/anchor/index.d.ts +7 -0
- package/declarations/anchor/index.d.ts.map +1 -0
- package/declarations/anchor/middleware.d.ts +46 -0
- package/declarations/anchor/middleware.d.ts.map +1 -0
- package/declarations/anchor/modifier.d.ts +34 -0
- package/declarations/anchor/modifier.d.ts.map +1 -0
- package/declarations/anchor/options.d.ts +112 -0
- package/declarations/anchor/options.d.ts.map +1 -0
- package/declarations/anchor/position.d.ts +36 -0
- package/declarations/anchor/position.d.ts.map +1 -0
- package/declarations/anchor.d.ts +2 -0
- package/declarations/as.d.ts +33 -0
- package/declarations/as.d.ts.map +1 -0
- package/declarations/aspect-ratio.d.ts +34 -0
- package/declarations/aspect-ratio.d.ts.map +1 -0
- package/declarations/avatar.d.ts +178 -0
- package/declarations/avatar.d.ts.map +1 -0
- package/declarations/body-class.d.ts +30 -0
- package/declarations/body-class.d.ts.map +1 -0
- package/declarations/breadcrumb.d.ts +64 -0
- package/declarations/breadcrumb.d.ts.map +1 -0
- package/declarations/calendar/dates.d.ts +142 -0
- package/declarations/calendar/dates.d.ts.map +1 -0
- package/declarations/calendar/index.d.ts +59 -0
- package/declarations/calendar/index.d.ts.map +1 -0
- package/declarations/calendar/state.d.ts +415 -0
- package/declarations/calendar/state.d.ts.map +1 -0
- package/declarations/calendar.d.ts +3 -0
- package/declarations/checkbox.d.ts +71 -0
- package/declarations/checkbox.d.ts.map +1 -0
- package/declarations/collapsible.d.ts +216 -0
- package/declarations/collapsible.d.ts.map +1 -0
- package/declarations/color-scheme.d.ts +115 -0
- package/declarations/color-scheme.d.ts.map +1 -0
- package/declarations/combobox.d.ts +569 -0
- package/declarations/combobox.d.ts.map +1 -0
- package/declarations/command.d.ts +410 -0
- package/declarations/command.d.ts.map +1 -0
- package/declarations/context-menu.d.ts +155 -0
- package/declarations/context-menu.d.ts.map +1 -0
- package/declarations/controllable-state.d.ts +85 -0
- package/declarations/controllable-state.d.ts.map +1 -0
- package/declarations/dialog.d.ts +80 -0
- package/declarations/dialog.d.ts.map +1 -0
- package/declarations/direction.d.ts +55 -0
- package/declarations/direction.d.ts.map +1 -0
- package/declarations/dismiss.d.ts +111 -0
- package/declarations/dismiss.d.ts.map +1 -0
- package/declarations/dom-context.d.ts +74 -0
- package/declarations/dom-context.d.ts.map +1 -0
- package/declarations/drawer/controller.d.ts +174 -0
- package/declarations/drawer/controller.d.ts.map +1 -0
- package/declarations/drawer/index.d.ts +105 -0
- package/declarations/drawer/index.d.ts.map +1 -0
- package/declarations/drawer/machine.d.ts +139 -0
- package/declarations/drawer/machine.d.ts.map +1 -0
- package/declarations/drawer/parts.d.ts +85 -0
- package/declarations/drawer/parts.d.ts.map +1 -0
- package/declarations/drawer.d.ts +2 -0
- package/declarations/dropdown-menu.d.ts +169 -0
- package/declarations/dropdown-menu.d.ts.map +1 -0
- package/declarations/external-link.d.ts +26 -0
- package/declarations/external-link.d.ts.map +1 -0
- package/declarations/file-drop.d.ts +119 -0
- package/declarations/file-drop.d.ts.map +1 -0
- package/declarations/focus-scope.d.ts +105 -0
- package/declarations/focus-scope.d.ts.map +1 -0
- package/declarations/focus.d.ts +114 -0
- package/declarations/focus.d.ts.map +1 -0
- package/declarations/head.d.ts +20 -0
- package/declarations/head.d.ts.map +1 -0
- package/declarations/heading.d.ts +59 -0
- package/declarations/heading.d.ts.map +1 -0
- package/declarations/hero.d.ts +32 -0
- package/declarations/hero.d.ts.map +1 -0
- package/declarations/hide-others.d.ts +35 -0
- package/declarations/hide-others.d.ts.map +1 -0
- package/declarations/hover-card.d.ts +148 -0
- package/declarations/hover-card.d.ts.map +1 -0
- package/declarations/i18n.d.ts +47 -0
- package/declarations/i18n.d.ts.map +1 -0
- package/declarations/id.d.ts +15 -0
- package/declarations/id.d.ts.map +1 -0
- package/declarations/iframe.d.ts +12 -0
- package/declarations/iframe.d.ts.map +1 -0
- package/declarations/incremental-each.d.ts +81 -0
- package/declarations/incremental-each.d.ts.map +1 -0
- package/declarations/index.d.ts +108 -0
- package/declarations/index.d.ts.map +1 -0
- package/declarations/input-otp.d.ts +201 -0
- package/declarations/input-otp.d.ts.map +1 -0
- package/declarations/keys.d.ts +50 -0
- package/declarations/keys.d.ts.map +1 -0
- package/declarations/label.d.ts +36 -0
- package/declarations/label.d.ts.map +1 -0
- package/declarations/layer.d.ts +56 -0
- package/declarations/layer.d.ts.map +1 -0
- package/declarations/link-helper.d.ts +73 -0
- package/declarations/link-helper.d.ts.map +1 -0
- package/declarations/link.d.ts +60 -0
- package/declarations/link.d.ts.map +1 -0
- package/declarations/load.d.ts +47 -0
- package/declarations/load.d.ts.map +1 -0
- package/declarations/menubar.d.ts +231 -0
- package/declarations/menubar.d.ts.map +1 -0
- package/declarations/message-scroller/components.d.ts +229 -0
- package/declarations/message-scroller/components.d.ts.map +1 -0
- package/declarations/message-scroller/geometry.d.ts +95 -0
- package/declarations/message-scroller/geometry.d.ts.map +1 -0
- package/declarations/message-scroller/index.d.ts +4 -0
- package/declarations/message-scroller/index.d.ts.map +1 -0
- package/declarations/message-scroller/state.d.ts +124 -0
- package/declarations/message-scroller/state.d.ts.map +1 -0
- package/declarations/message-scroller.d.ts +2 -0
- package/declarations/messages.d.ts +166 -0
- package/declarations/messages.d.ts.map +1 -0
- package/declarations/narrowing.d.ts +24 -0
- package/declarations/narrowing.d.ts.map +1 -0
- package/declarations/native-form.d.ts +56 -0
- package/declarations/native-form.d.ts.map +1 -0
- package/declarations/native-value.d.ts +47 -0
- package/declarations/native-value.d.ts.map +1 -0
- package/declarations/navigation-menu.d.ts +406 -0
- package/declarations/navigation-menu.d.ts.map +1 -0
- package/declarations/on-resize.d.ts +32 -0
- package/declarations/on-resize.d.ts.map +1 -0
- package/declarations/part.d.ts +99 -0
- package/declarations/part.d.ts.map +1 -0
- package/declarations/popover.d.ts +236 -0
- package/declarations/popover.d.ts.map +1 -0
- package/declarations/portal/index.d.ts +3 -0
- package/declarations/portal/index.d.ts.map +1 -0
- package/declarations/portal/portal.d.ts +46 -0
- package/declarations/portal/portal.d.ts.map +1 -0
- package/declarations/portal/targets.d.ts +40 -0
- package/declarations/portal/targets.d.ts.map +1 -0
- package/declarations/portal.d.ts +2 -0
- package/declarations/presence.d.ts +80 -0
- package/declarations/presence.d.ts.map +1 -0
- package/declarations/progress.d.ts +98 -0
- package/declarations/progress.d.ts.map +1 -0
- package/declarations/proper-links.d.ts +69 -0
- package/declarations/proper-links.d.ts.map +1 -0
- package/declarations/qp.d.ts +55 -0
- package/declarations/qp.d.ts.map +1 -0
- package/declarations/questionnaire/components.d.ts +348 -0
- package/declarations/questionnaire/components.d.ts.map +1 -0
- package/declarations/questionnaire/index.d.ts +4 -0
- package/declarations/questionnaire/index.d.ts.map +1 -0
- package/declarations/questionnaire/state.d.ts +400 -0
- package/declarations/questionnaire/state.d.ts.map +1 -0
- package/declarations/questionnaire/utils.d.ts +65 -0
- package/declarations/questionnaire/utils.d.ts.map +1 -0
- package/declarations/questionnaire.d.ts +2 -0
- package/declarations/radio-group.d.ts +115 -0
- package/declarations/radio-group.d.ts.map +1 -0
- package/declarations/rating.d.ts +214 -0
- package/declarations/rating.d.ts.map +1 -0
- package/declarations/resizable/components.d.ts +107 -0
- package/declarations/resizable/components.d.ts.map +1 -0
- package/declarations/resizable/index.d.ts +4 -0
- package/declarations/resizable/index.d.ts.map +1 -0
- package/declarations/resizable/layout.d.ts +93 -0
- package/declarations/resizable/layout.d.ts.map +1 -0
- package/declarations/resizable/state.d.ts +211 -0
- package/declarations/resizable/state.d.ts.map +1 -0
- package/declarations/resizable.d.ts +2 -0
- package/declarations/resize-observer.d.ts +40 -0
- package/declarations/resize-observer.d.ts.map +1 -0
- package/declarations/roving-focus.d.ts +204 -0
- package/declarations/roving-focus.d.ts.map +1 -0
- package/declarations/scroll-area/components.d.ts +125 -0
- package/declarations/scroll-area/components.d.ts.map +1 -0
- package/declarations/scroll-area/index.d.ts +3 -0
- package/declarations/scroll-area/index.d.ts.map +1 -0
- package/declarations/scroll-area/state.d.ts +147 -0
- package/declarations/scroll-area/state.d.ts.map +1 -0
- package/declarations/scroll-area.d.ts +2 -0
- package/declarations/scroll-lock.d.ts +69 -0
- package/declarations/scroll-lock.d.ts.map +1 -0
- package/declarations/scroller.d.ts +71 -0
- package/declarations/scroller.d.ts.map +1 -0
- package/declarations/select.d.ts +459 -0
- package/declarations/select.d.ts.map +1 -0
- package/declarations/separator.d.ts +71 -0
- package/declarations/separator.d.ts.map +1 -0
- package/declarations/service.d.ts +83 -0
- package/declarations/service.d.ts.map +1 -0
- package/declarations/shadowed.d.ts +63 -0
- package/declarations/shadowed.d.ts.map +1 -0
- package/declarations/slider.d.ts +283 -0
- package/declarations/slider.d.ts.map +1 -0
- package/declarations/sticky-footer.d.ts +43 -0
- package/declarations/sticky-footer.d.ts.map +1 -0
- package/declarations/store.d.ts +47 -0
- package/declarations/store.d.ts.map +1 -0
- package/declarations/switch.d.ts +76 -0
- package/declarations/switch.d.ts.map +1 -0
- package/declarations/tabs.d.ts +250 -0
- package/declarations/tabs.d.ts.map +1 -0
- package/declarations/toast/icons.d.ts +29 -0
- package/declarations/toast/icons.d.ts.map +1 -0
- package/declarations/toast/index.d.ts +4 -0
- package/declarations/toast/index.d.ts.map +1 -0
- package/declarations/toast/item.d.ts +162 -0
- package/declarations/toast/item.d.ts.map +1 -0
- package/declarations/toast/state.d.ts +276 -0
- package/declarations/toast/state.d.ts.map +1 -0
- package/declarations/toast/styles.d.ts +20 -0
- package/declarations/toast/styles.d.ts.map +1 -0
- package/declarations/toast/toaster.d.ts +173 -0
- package/declarations/toast/toaster.d.ts.map +1 -0
- package/declarations/toast.d.ts +2 -0
- package/declarations/toggle-group.d.ts +161 -0
- package/declarations/toggle-group.d.ts.map +1 -0
- package/declarations/toggle.d.ts +70 -0
- package/declarations/toggle.d.ts.map +1 -0
- package/declarations/tooltip.d.ts +227 -0
- package/declarations/tooltip.d.ts.map +1 -0
- package/declarations/typeahead.d.ts +97 -0
- package/declarations/typeahead.d.ts.map +1 -0
- package/declarations/viewport.d.ts +109 -0
- package/declarations/viewport.d.ts.map +1 -0
- package/declarations/visually-hidden.d.ts +42 -0
- package/declarations/visually-hidden.d.ts.map +1 -0
- package/declarations/zoetrope.d.ts +120 -0
- package/declarations/zoetrope.d.ts.map +1 -0
- package/dist/accordion.js +367 -0
- package/dist/accordion.js.map +1 -0
- package/dist/alert-dialog.js +122 -0
- package/dist/alert-dialog.js.map +1 -0
- package/dist/anchor.js +2 -0
- package/dist/anchor.js.map +1 -0
- package/dist/as.js +60 -0
- package/dist/as.js.map +1 -0
- package/dist/aspect-ratio.js +59 -0
- package/dist/aspect-ratio.js.map +1 -0
- package/dist/avatar.js +464 -0
- package/dist/avatar.js.map +1 -0
- package/dist/body-class.js +57 -0
- package/dist/body-class.js.map +1 -0
- package/dist/breadcrumb.js +59 -0
- package/dist/breadcrumb.js.map +1 -0
- package/dist/calendar.js +1494 -0
- package/dist/calendar.js.map +1 -0
- package/dist/checkbox.js +81 -0
- package/dist/checkbox.js.map +1 -0
- package/dist/collapsible.js +255 -0
- package/dist/collapsible.js.map +1 -0
- package/dist/color-scheme.js +306 -0
- package/dist/color-scheme.js.map +1 -0
- package/dist/combobox.js +1413 -0
- package/dist/combobox.js.map +1 -0
- package/dist/command.js +1054 -0
- package/dist/command.js.map +1 -0
- package/dist/component-DqLt83fo.js +886 -0
- package/dist/component-DqLt83fo.js.map +1 -0
- package/dist/components-CWfg0cFs.js +1745 -0
- package/dist/components-CWfg0cFs.js.map +1 -0
- package/dist/components-DBWszEI3.js +1285 -0
- package/dist/components-DBWszEI3.js.map +1 -0
- package/dist/components-DI8Azu05.js +1542 -0
- package/dist/components-DI8Azu05.js.map +1 -0
- package/dist/components-F0Ini448.js +875 -0
- package/dist/components-F0Ini448.js.map +1 -0
- package/dist/context-menu.js +207 -0
- package/dist/context-menu.js.map +1 -0
- package/dist/controllable-state.js +134 -0
- package/dist/controllable-state.js.map +1 -0
- package/dist/delay-group-B1K03gBL.js +75 -0
- package/dist/delay-group-B1K03gBL.js.map +1 -0
- package/dist/dialog-3gfz_8NA.js +349 -0
- package/dist/dialog-3gfz_8NA.js.map +1 -0
- package/dist/dialog.js +57 -0
- package/dist/dialog.js.map +1 -0
- package/dist/direction.js +75 -0
- package/dist/direction.js.map +1 -0
- package/dist/dismiss.js +329 -0
- package/dist/dismiss.js.map +1 -0
- package/dist/dom-context.js +104 -0
- package/dist/dom-context.js.map +1 -0
- package/dist/drawer.js +1456 -0
- package/dist/drawer.js.map +1 -0
- package/dist/dropdown-menu.js +201 -0
- package/dist/dropdown-menu.js.map +1 -0
- package/dist/external-link.js +21 -0
- package/dist/external-link.js.map +1 -0
- package/dist/file-drop.js +183 -0
- package/dist/file-drop.js.map +1 -0
- package/dist/focus-scope.js +292 -0
- package/dist/focus-scope.js.map +1 -0
- package/dist/focus.js +307 -0
- package/dist/focus.js.map +1 -0
- package/dist/form-control-Ca_KHSKK.js +177 -0
- package/dist/form-control-Ca_KHSKK.js.map +1 -0
- package/dist/head.js +25 -0
- package/dist/head.js.map +1 -0
- package/dist/heading.js +152 -0
- package/dist/heading.js.map +1 -0
- package/dist/hero.js +36 -0
- package/dist/hero.js.map +1 -0
- package/dist/hide-others.js +108 -0
- package/dist/hide-others.js.map +1 -0
- package/dist/hover-card.js +246 -0
- package/dist/hover-card.js.map +1 -0
- package/dist/hover-intent-Bxb83fgX.js +92 -0
- package/dist/hover-intent-Bxb83fgX.js.map +1 -0
- package/dist/i18n.js +72 -0
- package/dist/i18n.js.map +1 -0
- package/dist/id.js +24 -0
- package/dist/id.js.map +1 -0
- package/dist/iframe.js +19 -0
- package/dist/iframe.js.map +1 -0
- package/dist/incremental-each.js +181 -0
- package/dist/incremental-each.js.map +1 -0
- package/dist/index.js +87 -0
- package/dist/index.js.map +1 -0
- package/dist/indicator-sYuRuFJA.js +26 -0
- package/dist/indicator-sYuRuFJA.js.map +1 -0
- package/dist/input-otp.js +611 -0
- package/dist/input-otp.js.map +1 -0
- package/dist/keys.js +65 -0
- package/dist/keys.js.map +1 -0
- package/dist/label.js +41 -0
- package/dist/label.js.map +1 -0
- package/dist/layer.js +157 -0
- package/dist/layer.js.map +1 -0
- package/dist/layout-styles-DY86so8a.js +81 -0
- package/dist/layout-styles-DY86so8a.js.map +1 -0
- package/dist/link-helper.js +122 -0
- package/dist/link-helper.js.map +1 -0
- package/dist/link.js +39 -0
- package/dist/link.js.map +1 -0
- package/dist/load.js +54 -0
- package/dist/load.js.map +1 -0
- package/dist/menu-Da1LFCet.js +1109 -0
- package/dist/menu-Da1LFCet.js.map +1 -0
- package/dist/menubar.js +357 -0
- package/dist/menubar.js.map +1 -0
- package/dist/message-scroller.js +2 -0
- package/dist/message-scroller.js.map +1 -0
- package/dist/messages.js +168 -0
- package/dist/messages.js.map +1 -0
- package/dist/narrowing.js +29 -0
- package/dist/narrowing.js.map +1 -0
- package/dist/native-form.js +134 -0
- package/dist/native-form.js.map +1 -0
- package/dist/native-value.js +125 -0
- package/dist/native-value.js.map +1 -0
- package/dist/navigation-menu.js +872 -0
- package/dist/navigation-menu.js.map +1 -0
- package/dist/observers-aItWe029.js +113 -0
- package/dist/observers-aItWe029.js.map +1 -0
- package/dist/on-resize.js +47 -0
- package/dist/on-resize.js.map +1 -0
- package/dist/part.js +291 -0
- package/dist/part.js.map +1 -0
- package/dist/popover.js +419 -0
- package/dist/popover.js.map +1 -0
- package/dist/popper-BbTzV8dP.js +323 -0
- package/dist/popper-BbTzV8dP.js.map +1 -0
- package/dist/portal-U554WDI9.js +214 -0
- package/dist/portal-U554WDI9.js.map +1 -0
- package/dist/portal.js +2 -0
- package/dist/portal.js.map +1 -0
- package/dist/presence.js +243 -0
- package/dist/presence.js.map +1 -0
- package/dist/progress.js +106 -0
- package/dist/progress.js.map +1 -0
- package/dist/promise-state-BMi2zVoT.js +91 -0
- package/dist/promise-state-BMi2zVoT.js.map +1 -0
- package/dist/proper-links.js +136 -0
- package/dist/proper-links.js.map +1 -0
- package/dist/qp.js +77 -0
- package/dist/qp.js.map +1 -0
- package/dist/questionnaire.js +2 -0
- package/dist/questionnaire.js.map +1 -0
- package/dist/radio-group.js +149 -0
- package/dist/radio-group.js.map +1 -0
- package/dist/rating.js +261 -0
- package/dist/rating.js.map +1 -0
- package/dist/resizable.js +2 -0
- package/dist/resizable.js.map +1 -0
- package/dist/resize-observer.js +85 -0
- package/dist/resize-observer.js.map +1 -0
- package/dist/roving-focus.js +355 -0
- package/dist/roving-focus.js.map +1 -0
- package/dist/scroll-area.js +2 -0
- package/dist/scroll-area.js.map +1 -0
- package/dist/scroll-end-Cer8JSIB.js +87 -0
- package/dist/scroll-end-Cer8JSIB.js.map +1 -0
- package/dist/scroll-lock.js +267 -0
- package/dist/scroll-lock.js.map +1 -0
- package/dist/scroller.js +117 -0
- package/dist/scroller.js.map +1 -0
- package/dist/select.js +1223 -0
- package/dist/select.js.map +1 -0
- package/dist/separator.js +80 -0
- package/dist/separator.js.map +1 -0
- package/dist/service.js +160 -0
- package/dist/service.js.map +1 -0
- package/dist/shadowed.js +70 -0
- package/dist/shadowed.js.map +1 -0
- package/dist/slider.js +586 -0
- package/dist/slider.js.map +1 -0
- package/dist/sticky-footer.js +40 -0
- package/dist/sticky-footer.js.map +1 -0
- package/dist/store-BjiAd-KP.js +93 -0
- package/dist/store-BjiAd-KP.js.map +1 -0
- package/dist/store.js +4 -0
- package/dist/store.js.map +1 -0
- package/dist/switch.js +58 -0
- package/dist/switch.js.map +1 -0
- package/dist/tabs.js +458 -0
- package/dist/tabs.js.map +1 -0
- package/dist/toast.js +2 -0
- package/dist/toast.js.map +1 -0
- package/dist/toaster-DwprFZ1J.js +1518 -0
- package/dist/toaster-DwprFZ1J.js.map +1 -0
- package/dist/toggle-group.js +221 -0
- package/dist/toggle-group.js.map +1 -0
- package/dist/toggle.js +78 -0
- package/dist/toggle.js.map +1 -0
- package/dist/tooltip.js +422 -0
- package/dist/tooltip.js.map +1 -0
- package/dist/typeahead.js +233 -0
- package/dist/typeahead.js.map +1 -0
- package/dist/viewport.js +138 -0
- package/dist/viewport.js.map +1 -0
- package/dist/visually-hidden.js +49 -0
- package/dist/visually-hidden.js.map +1 -0
- package/dist/zoetrope.js +336 -0
- package/dist/zoetrope.js.map +1 -0
- package/package.json +101 -3
package/dist/calendar.js
ADDED
|
@@ -0,0 +1,1494 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { fn } from '@ember/helper';
|
|
3
|
+
import { on } from '@ember/modifier';
|
|
4
|
+
import { visuallyHidden } from './visually-hidden.js';
|
|
5
|
+
import { tracked, cached } from '@glimmer/tracking';
|
|
6
|
+
import { modifier } from 'ember-modifier';
|
|
7
|
+
import { ControllableState } from './controllable-state.js';
|
|
8
|
+
import { getDirection } from './direction.js';
|
|
9
|
+
import { isBoolean, isFunction, isObject as isObject$1 } from '@sindresorhus/is';
|
|
10
|
+
import { translator, translate } from './i18n.js';
|
|
11
|
+
import { messages } from './messages.js';
|
|
12
|
+
import { g, i, n } from 'decorator-transforms/runtime';
|
|
13
|
+
import { precompileTemplate } from '@ember/template-compilation';
|
|
14
|
+
import { setComponentTemplate } from '@ember/component';
|
|
15
|
+
import templateOnly from '@ember/component/template-only';
|
|
16
|
+
|
|
17
|
+
// Joinery's calendar works on plain `Date`s, with no date library: each day is a `Date` at local
|
|
18
|
+
// midnight, as react-day-picker's are (Joinery's Calendar replaces it). Day arithmetic is native.
|
|
19
|
+
// Month and year arithmetic goes through a calendar system: the Gregorian one is native too, and
|
|
20
|
+
// any other calendar `Intl` knows (Persian, Islamic, Hebrew…) is worked out from `Intl`'s own
|
|
21
|
+
// reading of each day, so a Persian calendar needs no Jalali library, as upstream's does.
|
|
22
|
+
|
|
23
|
+
/** The days of the week, 0 for Sunday to 6 for Saturday, as `Date#getDay()` numbers them. */
|
|
24
|
+
|
|
25
|
+
/** A date at local midnight, from its year, month (0 for January) and day. Any year works. */
|
|
26
|
+
function makeDate(year, month, day) {
|
|
27
|
+
const date = new Date(2000, 0, 1);
|
|
28
|
+
date.setFullYear(year, month, day);
|
|
29
|
+
return date;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** The day `date` falls on, at local midnight. */
|
|
33
|
+
function startOfDay(date) {
|
|
34
|
+
return makeDate(date.getFullYear(), date.getMonth(), date.getDate());
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* `date` moved by `amount` days (back, when negative), at local midnight: the calendar day, so
|
|
39
|
+
* a daylight-saving change never moves it by an hour.
|
|
40
|
+
*/
|
|
41
|
+
function addDays(date, amount) {
|
|
42
|
+
return makeDate(date.getFullYear(), date.getMonth(), date.getDate() + amount);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Whether two dates fall on the same day. */
|
|
46
|
+
function isSameDay(a, b) {
|
|
47
|
+
return a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Compares the days two dates fall on: negative when `a` is earlier, 0 on the same day. */
|
|
51
|
+
function compareDays(a, b) {
|
|
52
|
+
return a.getFullYear() - b.getFullYear() || a.getMonth() - b.getMonth() || a.getDate() - b.getDate();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** How many days from `b` to `a`, counting calendar days (negative when `a` is earlier). */
|
|
56
|
+
function differenceInDays(a, b) {
|
|
57
|
+
const utc = date => Date.UTC(date.getFullYear(), date.getMonth(), date.getDate());
|
|
58
|
+
return Math.round((utc(a) - utc(b)) / 86_400_000);
|
|
59
|
+
}
|
|
60
|
+
function pad(value, length = 2) {
|
|
61
|
+
const digits = String(Math.abs(value)).padStart(length, '0');
|
|
62
|
+
return value < 0 ? `-${digits}` : digits;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** The day as `yyyy-MM-dd`, in local time: the key Joinery's parts carry in `data-day`. */
|
|
66
|
+
function isoDate(date) {
|
|
67
|
+
return `${pad(date.getFullYear(), 4)}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** The month as `yyyy-MM`, in local time (Gregorian), as upstream's `data-month`. */
|
|
71
|
+
function isoMonth(date) {
|
|
72
|
+
return `${pad(date.getFullYear(), 4)}-${pad(date.getMonth() + 1)}`;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** A `yyyy-MM-dd` string as a date at local midnight (`new Date('2026-01-12')` would be UTC's). */
|
|
76
|
+
function parseIsoDate(value) {
|
|
77
|
+
const match = /^(-?\d{4,6})-(\d{2})-(\d{2})$/.exec(value);
|
|
78
|
+
if (!match) throw new Error(`Joinery: "${value}" is not a yyyy-MM-dd date`);
|
|
79
|
+
return makeDate(Number(match[1]), Number(match[2]) - 1, Number(match[3]));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** The first day of the week `date` is in, for weeks starting on `weekStartsOn`. */
|
|
83
|
+
function startOfWeek(date, weekStartsOn) {
|
|
84
|
+
return addDays(date, -((date.getDay() - weekStartsOn + 7) % 7));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** The last day of the week `date` is in. */
|
|
88
|
+
function endOfWeek(date, weekStartsOn) {
|
|
89
|
+
return addDays(startOfWeek(date, weekStartsOn), 6);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// ---------------------------------------------------------------------------------------------
|
|
93
|
+
// Calendar systems
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* A calendar's months and years. Each date is still a `Date`; the system says which year, month
|
|
97
|
+
* and day it is in that calendar, and how to move by months and years.
|
|
98
|
+
*/
|
|
99
|
+
|
|
100
|
+
const gregorian = {
|
|
101
|
+
id: 'gregory',
|
|
102
|
+
year: date => date.getFullYear(),
|
|
103
|
+
month: date => date.getMonth(),
|
|
104
|
+
day: date => date.getDate(),
|
|
105
|
+
startOfMonth: date => makeDate(date.getFullYear(), date.getMonth(), 1),
|
|
106
|
+
endOfMonth: date => makeDate(date.getFullYear(), date.getMonth() + 1, 0),
|
|
107
|
+
daysInMonth: date => makeDate(date.getFullYear(), date.getMonth() + 1, 0).getDate(),
|
|
108
|
+
monthsInYear: () => 12,
|
|
109
|
+
monthStart: (year, month) => makeDate(year, Math.max(0, Math.min(11, month)), 1),
|
|
110
|
+
addMonths(date, amount) {
|
|
111
|
+
const target = makeDate(date.getFullYear(), date.getMonth() + amount, 1);
|
|
112
|
+
const last = makeDate(target.getFullYear(), target.getMonth() + 1, 0).getDate();
|
|
113
|
+
return makeDate(target.getFullYear(), target.getMonth(), Math.min(date.getDate(), last));
|
|
114
|
+
},
|
|
115
|
+
addYears(date, amount) {
|
|
116
|
+
return gregorian.addMonths(date, amount * 12);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
/** Calendars whose months and days are the Gregorian ones, with years counted otherwise. */
|
|
121
|
+
const GREGORIAN_MONTHS = new Set(['gregory', 'iso8601', 'buddhist', 'japanese', 'roc']);
|
|
122
|
+
/**
|
|
123
|
+
* A calendar `Intl` knows, read from `Intl.DateTimeFormat`'s parts for each day: a month starts
|
|
124
|
+
* on the day numbered 1, and a year when its number changes. Lookups are cached, so the steps
|
|
125
|
+
* it takes stay cheap.
|
|
126
|
+
*/
|
|
127
|
+
class IntlCalendarSystem {
|
|
128
|
+
id;
|
|
129
|
+
#format;
|
|
130
|
+
#parts = new Map();
|
|
131
|
+
#nextMonth = new Map();
|
|
132
|
+
#monthIndex = new Map();
|
|
133
|
+
#yearLength;
|
|
134
|
+
constructor(id) {
|
|
135
|
+
this.id = id;
|
|
136
|
+
this.#format = new Intl.DateTimeFormat(`en-u-ca-${id}-nu-latn`, {
|
|
137
|
+
year: 'numeric',
|
|
138
|
+
month: 'numeric',
|
|
139
|
+
day: 'numeric',
|
|
140
|
+
timeZone: 'UTC'
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
#read(date) {
|
|
144
|
+
const key = isoDate(date);
|
|
145
|
+
let parts = this.#parts.get(key);
|
|
146
|
+
if (parts) return parts;
|
|
147
|
+
// The local day, at noon UTC, read in UTC: the same day wherever the browser is.
|
|
148
|
+
const utc = new Date(0);
|
|
149
|
+
utc.setUTCFullYear(date.getFullYear(), date.getMonth(), date.getDate());
|
|
150
|
+
utc.setUTCHours(12);
|
|
151
|
+
let year = 0;
|
|
152
|
+
let month = '';
|
|
153
|
+
let day = 0;
|
|
154
|
+
for (const part of this.#format.formatToParts(utc)) {
|
|
155
|
+
// `relatedYear` is the Gregorian year of a calendar whose own years cycle (Chinese).
|
|
156
|
+
const type = part.type;
|
|
157
|
+
if (type === 'year' || type === 'relatedYear') year = Number(part.value);else if (part.type === 'month') month = part.value;else if (part.type === 'day') day = Number(part.value);
|
|
158
|
+
}
|
|
159
|
+
parts = {
|
|
160
|
+
year,
|
|
161
|
+
month,
|
|
162
|
+
day
|
|
163
|
+
};
|
|
164
|
+
this.#parts.set(key, parts);
|
|
165
|
+
return parts;
|
|
166
|
+
}
|
|
167
|
+
year(date) {
|
|
168
|
+
return this.#read(date).year;
|
|
169
|
+
}
|
|
170
|
+
day(date) {
|
|
171
|
+
return this.#read(date).day;
|
|
172
|
+
}
|
|
173
|
+
startOfMonth(date) {
|
|
174
|
+
return addDays(startOfDay(date), 1 - this.#read(date).day);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** The first day of the month after the one starting on `start`. */
|
|
178
|
+
#next(start) {
|
|
179
|
+
const key = isoDate(start);
|
|
180
|
+
let next = this.#nextMonth.get(key);
|
|
181
|
+
if (next) return next;
|
|
182
|
+
next = addDays(start, 1);
|
|
183
|
+
for (let step = 1; step < 40 && this.#read(next).day !== 1; step += 1) next = addDays(next, 1);
|
|
184
|
+
this.#nextMonth.set(key, next);
|
|
185
|
+
return next;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/** The first day of the month before the one starting on `start`. */
|
|
189
|
+
#previous(start) {
|
|
190
|
+
return this.startOfMonth(addDays(start, -1));
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/** The first day of the year `date` is in. */
|
|
194
|
+
#startOfYear(date) {
|
|
195
|
+
let start = this.startOfMonth(date);
|
|
196
|
+
const year = this.#read(start).year;
|
|
197
|
+
for (let step = 0; step < 14; step += 1) {
|
|
198
|
+
const previous = this.#previous(start);
|
|
199
|
+
if (this.#read(previous).year !== year) break;
|
|
200
|
+
start = previous;
|
|
201
|
+
}
|
|
202
|
+
return start;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/** The first day of the year after the one starting on `start`. */
|
|
206
|
+
#nextYear(start) {
|
|
207
|
+
const year = this.#read(start).year;
|
|
208
|
+
let next = this.#next(start);
|
|
209
|
+
for (let step = 0; step < 14 && this.#read(next).year === year; step += 1) next = this.#next(next);
|
|
210
|
+
return next;
|
|
211
|
+
}
|
|
212
|
+
month(date) {
|
|
213
|
+
const start = this.startOfMonth(date);
|
|
214
|
+
const key = isoDate(start);
|
|
215
|
+
let index = this.#monthIndex.get(key);
|
|
216
|
+
if (index !== undefined) return index;
|
|
217
|
+
index = differenceInMonthsWithin(this, this.#startOfYear(start), start);
|
|
218
|
+
this.#monthIndex.set(key, index);
|
|
219
|
+
return index;
|
|
220
|
+
}
|
|
221
|
+
endOfMonth(date) {
|
|
222
|
+
return addDays(this.#next(this.startOfMonth(date)), -1);
|
|
223
|
+
}
|
|
224
|
+
daysInMonth(date) {
|
|
225
|
+
const start = this.startOfMonth(date);
|
|
226
|
+
return differenceInDays(this.#next(start), start);
|
|
227
|
+
}
|
|
228
|
+
monthsInYear(year) {
|
|
229
|
+
const start = this.#yearStart(year);
|
|
230
|
+
return differenceInMonthsWithin(this, start, addDays(this.#nextYear(start), -1)) + 1;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/** The year's average length in days, measured once around 2000. */
|
|
234
|
+
get #averageYear() {
|
|
235
|
+
if (this.#yearLength === undefined) {
|
|
236
|
+
const start = this.#startOfYear(makeDate(2000, 0, 1));
|
|
237
|
+
let next = start;
|
|
238
|
+
for (let year = 0; year < 4; year += 1) next = this.#nextYear(next);
|
|
239
|
+
this.#yearLength = differenceInDays(next, start) / 4;
|
|
240
|
+
}
|
|
241
|
+
return this.#yearLength;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/** The first day of `year`: a jump by its average length, then a step or two to correct it. */
|
|
245
|
+
#yearStart(year) {
|
|
246
|
+
const anchor = makeDate(2000, 6, 1);
|
|
247
|
+
const estimate = addDays(anchor, Math.round((year - this.#read(anchor).year) * this.#averageYear));
|
|
248
|
+
let start = this.#startOfYear(estimate);
|
|
249
|
+
for (let step = 0; step < 50; step += 1) {
|
|
250
|
+
const found = this.#read(start).year;
|
|
251
|
+
if (found === year) break;
|
|
252
|
+
start = found < year ? this.#nextYear(start) : this.#startOfYear(addDays(start, -1));
|
|
253
|
+
}
|
|
254
|
+
return start;
|
|
255
|
+
}
|
|
256
|
+
monthStart(year, month) {
|
|
257
|
+
let start = this.#yearStart(year);
|
|
258
|
+
for (let index = 0; index < month; index += 1) {
|
|
259
|
+
const next = this.#next(start);
|
|
260
|
+
if (this.#read(next).year !== year) break;
|
|
261
|
+
start = next;
|
|
262
|
+
}
|
|
263
|
+
return start;
|
|
264
|
+
}
|
|
265
|
+
addMonths(date, amount) {
|
|
266
|
+
let start = this.startOfMonth(date);
|
|
267
|
+
const steps = Math.min(Math.abs(Math.trunc(amount)), 2400);
|
|
268
|
+
for (let step = 0; step < steps; step += 1) {
|
|
269
|
+
start = amount > 0 ? this.#next(start) : this.#previous(start);
|
|
270
|
+
}
|
|
271
|
+
return withDay(this, start, this.#read(date).day);
|
|
272
|
+
}
|
|
273
|
+
addYears(date, amount) {
|
|
274
|
+
const year = this.year(date) + Math.trunc(amount);
|
|
275
|
+
const month = Math.min(this.month(date), this.monthsInYear(year) - 1);
|
|
276
|
+
return withDay(this, this.monthStart(year, month), this.#read(date).day);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/** The day `day` of the month starting on `start`, or its last day. */
|
|
281
|
+
function withDay(system, start, day) {
|
|
282
|
+
return addDays(start, Math.min(day, system.daysInMonth(start)) - 1);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/** How many months from the month starting `from` to the one `to` is in (same year or close). */
|
|
286
|
+
function differenceInMonthsWithin(system, from, to) {
|
|
287
|
+
let count = 0;
|
|
288
|
+
let start = system.startOfMonth(from);
|
|
289
|
+
const end = system.startOfMonth(to);
|
|
290
|
+
while (compareDays(start, end) < 0 && count < 2400) {
|
|
291
|
+
start = system.addMonths(start, 1);
|
|
292
|
+
count += 1;
|
|
293
|
+
}
|
|
294
|
+
return count;
|
|
295
|
+
}
|
|
296
|
+
const systems = new Map([['gregory', gregorian]]);
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* The calendar system `Intl` calls `id`: `gregory` (and those with Gregorian months, such as
|
|
300
|
+
* `buddhist` and `japanese`) natively, anything else Intl knows through Intl. An `id` Intl
|
|
301
|
+
* doesn't know is Gregorian.
|
|
302
|
+
*/
|
|
303
|
+
function calendarSystem(id) {
|
|
304
|
+
const name = id ?? 'gregory';
|
|
305
|
+
let system = systems.get(name);
|
|
306
|
+
if (system) return system;
|
|
307
|
+
let known;
|
|
308
|
+
try {
|
|
309
|
+
known = new Intl.DateTimeFormat(`en-u-ca-${name}`).resolvedOptions().calendar === name;
|
|
310
|
+
} catch {
|
|
311
|
+
known = false;
|
|
312
|
+
}
|
|
313
|
+
system = !known || GREGORIAN_MONTHS.has(name) ? gregorian : new IntlCalendarSystem(name);
|
|
314
|
+
systems.set(name, system);
|
|
315
|
+
return system;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// ---------------------------------------------------------------------------------------------
|
|
319
|
+
// Weeks
|
|
320
|
+
|
|
321
|
+
/** Where a locale's weeks start, and how many days of a new year its first week needs. */
|
|
322
|
+
|
|
323
|
+
// CLDR's week data, for a browser whose Intl.Locale has no getWeekInfo() (Firefox): the regions
|
|
324
|
+
// whose weeks start on a Sunday, Saturday or Friday (the rest start on a Monday), and those whose
|
|
325
|
+
// first week needs four days of the year (the rest need one).
|
|
326
|
+
const SUNDAY = 'AG AS BD BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP PA PE PH PK PR PT PY SA SG SV TH TT TW UM US VE VI WS YE ZA ZW';
|
|
327
|
+
const SATURDAY = 'AE AF BH DJ DZ EG IQ IR JO KW LY OM QA SD SY';
|
|
328
|
+
const FRIDAY = 'MV';
|
|
329
|
+
const FOUR_DAYS = 'AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL RE RU SE SJ SK SM VA';
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* The week a locale uses: its first day from `Intl.Locale#getWeekInfo()`, and the days a first
|
|
333
|
+
* week needs from CLDR's data (Intl no longer gives them), as is the first day without Intl's.
|
|
334
|
+
*/
|
|
335
|
+
function weekInfo(locale) {
|
|
336
|
+
try {
|
|
337
|
+
const intl = new Intl.Locale(locale);
|
|
338
|
+
const region = intl.maximize().region ?? '';
|
|
339
|
+
const has = list => list.split(' ').includes(region);
|
|
340
|
+
const info = intl.getWeekInfo?.() ?? intl.weekInfo;
|
|
341
|
+
const firstDay = info ? info.firstDay % 7 : has(SUNDAY) ? 0 : has(SATURDAY) ? 6 : has(FRIDAY) ? 5 : 1;
|
|
342
|
+
// Intl dropped `minimalDays` from the week info (browsers that had it still give it).
|
|
343
|
+
return {
|
|
344
|
+
firstDay,
|
|
345
|
+
minimalDays: info?.minimalDays ?? (has(FOUR_DAYS) ? 4 : 1)
|
|
346
|
+
};
|
|
347
|
+
} catch {
|
|
348
|
+
return {
|
|
349
|
+
firstDay: 0,
|
|
350
|
+
minimalDays: 1
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* The week number of `date`, as date-fns' `getWeek` counts it (react-day-picker's): week 1 is the
|
|
357
|
+
* week holding day `firstWeekContainsDate` of the year, in `system`'s years.
|
|
358
|
+
*/
|
|
359
|
+
function weekNumber(date, system, weekStartsOn, firstWeekContainsDate) {
|
|
360
|
+
const firstWeek = year => startOfWeek(addDays(system.monthStart(year, 0), firstWeekContainsDate - 1), weekStartsOn);
|
|
361
|
+
const year = system.year(date);
|
|
362
|
+
const next = firstWeek(year + 1);
|
|
363
|
+
let start;
|
|
364
|
+
if (compareDays(date, next) >= 0) start = next;else {
|
|
365
|
+
const current = firstWeek(year);
|
|
366
|
+
start = compareDays(date, current) >= 0 ? current : firstWeek(year - 1);
|
|
367
|
+
}
|
|
368
|
+
return Math.round(differenceInDays(startOfWeek(date, weekStartsOn), start) / 7) + 1;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
// ---------------------------------------------------------------------------------------------
|
|
372
|
+
// Matchers and ranges, as react-day-picker's
|
|
373
|
+
|
|
374
|
+
/** A range of days. While it's being picked, `to` is unset. */
|
|
375
|
+
|
|
376
|
+
/** The days before `before`. */
|
|
377
|
+
|
|
378
|
+
/** The days after `after`. */
|
|
379
|
+
|
|
380
|
+
/** The days between `after` and `before` (both left out), or outside them when `after` is later. */
|
|
381
|
+
|
|
382
|
+
/** The days falling on these days of the week (0 for Sunday). */
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Which days something applies to, as react-day-picker's matchers: `true` (every day), a date,
|
|
386
|
+
* several dates, a range (`{ from, to }`), `{ before }`, `{ after }`, both, `{ dayOfWeek }`, or a
|
|
387
|
+
* function of the date. `@disabled`, `@hidden` and `@modifiers` take one, or an array of them.
|
|
388
|
+
*/
|
|
389
|
+
|
|
390
|
+
function isObject(value) {
|
|
391
|
+
return isObject$1(value) && !isFunction(value);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/** Whether `range` holds `date`; with `excludeEnds`, its first and last days don't count. */
|
|
395
|
+
function rangeIncludesDate(range, date, excludeEnds = false) {
|
|
396
|
+
let {
|
|
397
|
+
from,
|
|
398
|
+
to
|
|
399
|
+
} = range;
|
|
400
|
+
if (from && to) {
|
|
401
|
+
if (differenceInDays(to, from) < 0) [from, to] = [to, from];
|
|
402
|
+
const edge = excludeEnds ? 1 : 0;
|
|
403
|
+
return differenceInDays(date, from) >= edge && differenceInDays(to, date) >= edge;
|
|
404
|
+
}
|
|
405
|
+
if (!excludeEnds && to) return isSameDay(to, date);
|
|
406
|
+
if (!excludeEnds && from) return isSameDay(from, date);
|
|
407
|
+
return false;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/** Whether `date` matches any of `matchers` (see `Matcher`). */
|
|
411
|
+
function isMatch(date, matchers) {
|
|
412
|
+
if (matchers === undefined) return false;
|
|
413
|
+
const list = Array.isArray(matchers) ? matchers : [matchers];
|
|
414
|
+
return list.some(matcher => {
|
|
415
|
+
if (isBoolean(matcher)) return matcher;
|
|
416
|
+
if (isFunction(matcher)) return matcher(date);
|
|
417
|
+
if (matcher instanceof Date) return isSameDay(date, matcher);
|
|
418
|
+
if (Array.isArray(matcher)) return matcher.some(day => isSameDay(date, day));
|
|
419
|
+
if (!isObject(matcher)) return false;
|
|
420
|
+
if ('from' in matcher) return rangeIncludesDate(matcher, date);
|
|
421
|
+
if ('dayOfWeek' in matcher) {
|
|
422
|
+
const days = matcher.dayOfWeek;
|
|
423
|
+
return Array.isArray(days) ? days.includes(date.getDay()) : days === date.getDay();
|
|
424
|
+
}
|
|
425
|
+
if ('before' in matcher && 'after' in matcher) {
|
|
426
|
+
const {
|
|
427
|
+
before,
|
|
428
|
+
after
|
|
429
|
+
} = matcher;
|
|
430
|
+
const isBefore = differenceInDays(before, date) > 0;
|
|
431
|
+
const isAfter = differenceInDays(after, date) < 0;
|
|
432
|
+
return differenceInDays(before, after) > 0 ? isAfter && isBefore : isBefore || isAfter;
|
|
433
|
+
}
|
|
434
|
+
if ('after' in matcher) return differenceInDays(date, matcher.after) > 0;
|
|
435
|
+
if ('before' in matcher) return differenceInDays(matcher.before, date) > 0;
|
|
436
|
+
return false;
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/** Whether any day of a range matches `matchers`. */
|
|
441
|
+
function rangeContainsMatch(range, matchers) {
|
|
442
|
+
let from = range.from;
|
|
443
|
+
let to = range.to;
|
|
444
|
+
if (compareDays(to, from) < 0) [from, to] = [to, from];
|
|
445
|
+
for (let day = startOfDay(from); compareDays(day, to) <= 0; day = addDays(day, 1)) {
|
|
446
|
+
if (isMatch(day, matchers)) return true;
|
|
447
|
+
}
|
|
448
|
+
return false;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* The range a click on `date` makes of `range`, as react-day-picker's `addToRange`: the first
|
|
453
|
+
* click starts a range, the next ends it (or starts it earlier), and a click on an end moves it.
|
|
454
|
+
* `min` and `max` bound the range's length in days, and `required` keeps a range from emptying.
|
|
455
|
+
*/
|
|
456
|
+
function addToRange(date, range, min = 0, max = 0, required = false) {
|
|
457
|
+
const {
|
|
458
|
+
from,
|
|
459
|
+
to
|
|
460
|
+
} = range ?? {
|
|
461
|
+
from: undefined,
|
|
462
|
+
to: undefined
|
|
463
|
+
};
|
|
464
|
+
let next;
|
|
465
|
+
if (!from && !to) {
|
|
466
|
+
next = {
|
|
467
|
+
from: date,
|
|
468
|
+
to: min > 0 ? undefined : date
|
|
469
|
+
};
|
|
470
|
+
} else if (from && !to) {
|
|
471
|
+
if (isSameDay(from, date)) next = required ? {
|
|
472
|
+
from,
|
|
473
|
+
to: undefined
|
|
474
|
+
} : undefined;else if (compareDays(date, from) < 0) next = {
|
|
475
|
+
from: date,
|
|
476
|
+
to: from
|
|
477
|
+
};else next = {
|
|
478
|
+
from,
|
|
479
|
+
to: date
|
|
480
|
+
};
|
|
481
|
+
} else if (from && to) {
|
|
482
|
+
if (isSameDay(from, date) && isSameDay(to, date)) next = required ? {
|
|
483
|
+
from,
|
|
484
|
+
to
|
|
485
|
+
} : undefined;else if (isSameDay(from, date)) next = {
|
|
486
|
+
from,
|
|
487
|
+
to: min > 0 ? undefined : date
|
|
488
|
+
};else if (isSameDay(to, date)) next = {
|
|
489
|
+
from: date,
|
|
490
|
+
to: min > 0 ? undefined : date
|
|
491
|
+
};else if (compareDays(date, from) < 0) next = {
|
|
492
|
+
from: date,
|
|
493
|
+
to
|
|
494
|
+
};else next = {
|
|
495
|
+
from,
|
|
496
|
+
to: date
|
|
497
|
+
};
|
|
498
|
+
} else if (to) {
|
|
499
|
+
next = compareDays(date, to) < 0 ? {
|
|
500
|
+
from: date,
|
|
501
|
+
to
|
|
502
|
+
} : {
|
|
503
|
+
from: to,
|
|
504
|
+
to: date
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
if (next?.from && next.to) {
|
|
508
|
+
const days = differenceInDays(next.to, next.from);
|
|
509
|
+
if (max > 0 && days > max || min > 1 && days < min) next = {
|
|
510
|
+
from: date,
|
|
511
|
+
to: undefined
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
return next;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
// ---------------------------------------------------------------------------------------------
|
|
518
|
+
// Locales
|
|
519
|
+
|
|
520
|
+
/** A locale, calendar and numbering system, and the Intl formatting they give. */
|
|
521
|
+
|
|
522
|
+
const formats = new Map();
|
|
523
|
+
const numberFormats = new Map();
|
|
524
|
+
const locales = new Map();
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* A `CalendarLocale` for `locale` (default `en-US`, as react-day-picker's). The calendar is
|
|
528
|
+
* `calendar`, else the one the tag names (`-u-ca-persian`), else Gregorian; the numbering system
|
|
529
|
+
* is `numerals`, else the tag's (`-u-nu-arab`), else Latin digits. Those defaults are
|
|
530
|
+
* react-day-picker's: Arabic month names in a Gregorian calendar for `ar-SA`, unless asked.
|
|
531
|
+
*/
|
|
532
|
+
function calendarLocale(locale, calendar, numerals) {
|
|
533
|
+
const key = `${locale ?? ''}|${calendar ?? ''}|${numerals ?? ''}`;
|
|
534
|
+
const cached = locales.get(key);
|
|
535
|
+
if (cached) return cached;
|
|
536
|
+
let base;
|
|
537
|
+
try {
|
|
538
|
+
base = new Intl.Locale(locale ?? 'en-US');
|
|
539
|
+
} catch {
|
|
540
|
+
base = new Intl.Locale('en-US');
|
|
541
|
+
}
|
|
542
|
+
let tag;
|
|
543
|
+
try {
|
|
544
|
+
tag = new Intl.Locale(base.toString(), {
|
|
545
|
+
calendar: calendar ?? base.calendar ?? 'gregory',
|
|
546
|
+
numberingSystem: numerals ?? base.numberingSystem ?? 'latn'
|
|
547
|
+
}).toString();
|
|
548
|
+
} catch {
|
|
549
|
+
tag = base.toString();
|
|
550
|
+
}
|
|
551
|
+
const resolved = new Intl.DateTimeFormat(tag).resolvedOptions();
|
|
552
|
+
const value = {
|
|
553
|
+
tag,
|
|
554
|
+
language: base.language,
|
|
555
|
+
calendar: resolved.calendar,
|
|
556
|
+
numerals: resolved.numberingSystem,
|
|
557
|
+
format(date, options) {
|
|
558
|
+
const formatKey = `${tag}|${JSON.stringify(options)}`;
|
|
559
|
+
let format = formats.get(formatKey);
|
|
560
|
+
if (!format) formats.set(formatKey, format = new Intl.DateTimeFormat(tag, options));
|
|
561
|
+
return format.format(date);
|
|
562
|
+
},
|
|
563
|
+
formatNumber(number, options = {}) {
|
|
564
|
+
const formatKey = `${tag}|${JSON.stringify(options)}`;
|
|
565
|
+
let format = numberFormats.get(formatKey);
|
|
566
|
+
if (!format) {
|
|
567
|
+
numberFormats.set(formatKey, format = new Intl.NumberFormat(tag, {
|
|
568
|
+
useGrouping: false,
|
|
569
|
+
...options
|
|
570
|
+
}));
|
|
571
|
+
}
|
|
572
|
+
return format.format(number);
|
|
573
|
+
}
|
|
574
|
+
};
|
|
575
|
+
locales.set(key, value);
|
|
576
|
+
return value;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
const narrow = new WeakMap();
|
|
580
|
+
|
|
581
|
+
/** Whether a locale's abbreviated weekday names are too long for a calendar's columns. */
|
|
582
|
+
function narrowWeekdays(locale) {
|
|
583
|
+
let value = narrow.get(locale);
|
|
584
|
+
if (value === undefined) {
|
|
585
|
+
// 4 to 10 January 2026 run Sunday to Saturday.
|
|
586
|
+
value = Array.from({
|
|
587
|
+
length: 7
|
|
588
|
+
}, (_, index) => new Date(2026, 0, 4 + index)).some(day => [...locale.format(day, {
|
|
589
|
+
weekday: 'short'
|
|
590
|
+
})].length > 4);
|
|
591
|
+
narrow.set(locale, value);
|
|
592
|
+
}
|
|
593
|
+
return value;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
/** Intl's formatting, as react-day-picker formats with date-fns. */
|
|
597
|
+
const defaultCalendarFormatters = {
|
|
598
|
+
formatCaption: (month, locale) => locale.format(month, {
|
|
599
|
+
month: 'long',
|
|
600
|
+
year: 'numeric'
|
|
601
|
+
}),
|
|
602
|
+
formatDay: (date, locale) => locale.format(date, {
|
|
603
|
+
day: 'numeric'
|
|
604
|
+
}),
|
|
605
|
+
formatMonthDropdown: (month, locale) => locale.format(month, {
|
|
606
|
+
month: 'long'
|
|
607
|
+
}),
|
|
608
|
+
formatYearDropdown: (year, locale) => locale.format(year, {
|
|
609
|
+
year: 'numeric'
|
|
610
|
+
}),
|
|
611
|
+
formatWeekdayName(weekday, locale) {
|
|
612
|
+
// react-day-picker shows date-fns' short day names (CLDR's "short" width: Su, Mo, Tu),
|
|
613
|
+
// which Intl doesn't offer. In English they are the abbreviation's first two letters; in
|
|
614
|
+
// a language whose abbreviations are whole words (Persian, Arabic), the narrow names fit
|
|
615
|
+
// the columns.
|
|
616
|
+
const name = locale.format(weekday, {
|
|
617
|
+
weekday: 'short'
|
|
618
|
+
});
|
|
619
|
+
if (locale.language === 'en') return name.slice(0, 2);
|
|
620
|
+
return narrowWeekdays(locale) ? locale.format(weekday, {
|
|
621
|
+
weekday: 'narrow'
|
|
622
|
+
}) : name;
|
|
623
|
+
},
|
|
624
|
+
formatWeekNumber: (weekNumber, locale) => locale.formatNumber(weekNumber, {
|
|
625
|
+
minimumIntegerDigits: 2
|
|
626
|
+
}),
|
|
627
|
+
formatWeekNumberHeader: () => ''
|
|
628
|
+
};
|
|
629
|
+
|
|
630
|
+
/** react-day-picker's labels, with Intl's full date for each day, in `context`'s translator's words. */
|
|
631
|
+
function calendarLabels(context) {
|
|
632
|
+
return {
|
|
633
|
+
labelDayButton(date, modifiers, locale) {
|
|
634
|
+
const values = {
|
|
635
|
+
date: locale.format(date, {
|
|
636
|
+
dateStyle: 'full'
|
|
637
|
+
})
|
|
638
|
+
};
|
|
639
|
+
if (modifiers.today && modifiers.selected) {
|
|
640
|
+
return translate(context, messages.calendarTodaySelected, values);
|
|
641
|
+
}
|
|
642
|
+
if (modifiers.today) return translate(context, messages.calendarToday, values);
|
|
643
|
+
if (modifiers.selected) return translate(context, messages.calendarSelected, values);
|
|
644
|
+
return values.date;
|
|
645
|
+
},
|
|
646
|
+
labelGridcell(date, modifiers, locale) {
|
|
647
|
+
const label = locale.format(date, {
|
|
648
|
+
dateStyle: 'full'
|
|
649
|
+
});
|
|
650
|
+
return modifiers.today ? translate(context, messages.calendarToday, {
|
|
651
|
+
date: label
|
|
652
|
+
}) : label;
|
|
653
|
+
},
|
|
654
|
+
labelGrid: (month, locale) => locale.format(month, {
|
|
655
|
+
month: 'long',
|
|
656
|
+
year: 'numeric'
|
|
657
|
+
}),
|
|
658
|
+
labelMonthDropdown: () => translate(context, messages.calendarMonthDropdown),
|
|
659
|
+
labelYearDropdown: () => translate(context, messages.calendarYearDropdown),
|
|
660
|
+
labelNav: () => '',
|
|
661
|
+
labelNext: () => translate(context, messages.calendarNextMonth),
|
|
662
|
+
labelPrevious: () => translate(context, messages.calendarPreviousMonth),
|
|
663
|
+
labelWeekday: (weekday, locale) => locale.format(weekday, {
|
|
664
|
+
weekday: 'long'
|
|
665
|
+
}),
|
|
666
|
+
labelWeekNumber: week => translate(context, messages.calendarWeekNumber, {
|
|
667
|
+
week
|
|
668
|
+
}),
|
|
669
|
+
labelWeekNumberHeader: () => translate(context, messages.calendarWeekNumberHeader)
|
|
670
|
+
};
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
/** react-day-picker's English labels, with Intl's full date for each day. */
|
|
674
|
+
const defaultCalendarLabels = calendarLabels(undefined);
|
|
675
|
+
|
|
676
|
+
/** The parts and states react-day-picker gives a class each (`classNames`). */
|
|
677
|
+
|
|
678
|
+
/** react-day-picker's default classes, `rdp-<part>`: what the styled Calendar renders too. */
|
|
679
|
+
const defaultCalendarClassNames = Object.fromEntries(['root', 'months', 'month', 'nav', 'button_previous', 'button_next', 'chevron', 'month_caption', 'caption_label', 'dropdowns', 'dropdown_root', 'dropdown', 'months_dropdown', 'years_dropdown', 'month_grid', 'weekdays', 'weekday', 'weeks', 'week', 'week_number_header', 'week_number', 'day', 'day_button', 'footer', 'today', 'outside', 'disabled', 'hidden', 'focused', 'selected', 'range_start', 'range_middle', 'range_end'].map(part => [part, `rdp-${part}`]));
|
|
680
|
+
|
|
681
|
+
/** What a calendar takes: the styled `<Calendar>` and the headless one alike. */
|
|
682
|
+
|
|
683
|
+
/** A day the calendar shows: the date, the month it's shown in, and what applies to it. */
|
|
684
|
+
|
|
685
|
+
/** A week row: its number, and its seven days. */
|
|
686
|
+
|
|
687
|
+
/** An option of a month or year dropdown. */
|
|
688
|
+
|
|
689
|
+
/** A month the calendar shows. */
|
|
690
|
+
|
|
691
|
+
/** A column's weekday. */
|
|
692
|
+
|
|
693
|
+
/** A day the focus is on: which date, shown in which month. */
|
|
694
|
+
|
|
695
|
+
function sameRef(a, b) {
|
|
696
|
+
return Boolean(a && isSameDay(a.date, b.date) && isSameDay(a.displayMonth, b.displayMonth));
|
|
697
|
+
}
|
|
698
|
+
function isRange(value) {
|
|
699
|
+
return isObject$1(value) && !isFunction(value) && !Array.isArray(value) && 'from' in value;
|
|
700
|
+
}
|
|
701
|
+
const KEYS = {
|
|
702
|
+
ArrowLeft: (shift, rtl) => [shift ? 'month' : 'day', rtl ? 'after' : 'before'],
|
|
703
|
+
ArrowRight: (shift, rtl) => [shift ? 'month' : 'day', rtl ? 'before' : 'after'],
|
|
704
|
+
ArrowDown: shift => [shift ? 'year' : 'week', 'after'],
|
|
705
|
+
ArrowUp: shift => [shift ? 'year' : 'week', 'before'],
|
|
706
|
+
PageUp: shift => [shift ? 'year' : 'month', 'before'],
|
|
707
|
+
PageDown: shift => [shift ? 'year' : 'month', 'after'],
|
|
708
|
+
Home: () => ['startOfWeek', 'before'],
|
|
709
|
+
End: () => ['endOfWeek', 'after']
|
|
710
|
+
};
|
|
711
|
+
|
|
712
|
+
/**
|
|
713
|
+
* A calendar's state and behaviour, as react-day-picker's `DayPicker` has them: the months it
|
|
714
|
+
* shows and how to move between them, its selection, its days' modifiers and labels, and the one
|
|
715
|
+
* day in the tab order with the arrow keys moving focus. The styled `<Calendar>` and the headless
|
|
716
|
+
* one both render from it.
|
|
717
|
+
*
|
|
718
|
+
* calendar = new CalendarState(() => this.args)
|
|
719
|
+
* {{#each this.calendar.months as |month|}} … {{/each}}
|
|
720
|
+
*/
|
|
721
|
+
class CalendarState {
|
|
722
|
+
#args;
|
|
723
|
+
#classNames;
|
|
724
|
+
#context;
|
|
725
|
+
/** The first month shown: `@month`, `@defaultMonth` and `@onMonthChange`. */
|
|
726
|
+
month;
|
|
727
|
+
/** The selection the calendar holds itself, uncontrolled. */
|
|
728
|
+
static {
|
|
729
|
+
g(this.prototype, "ownValue", [tracked]);
|
|
730
|
+
}
|
|
731
|
+
#ownValue = (i(this, "ownValue"), void 0);
|
|
732
|
+
static {
|
|
733
|
+
g(this.prototype, "focused", [tracked]);
|
|
734
|
+
}
|
|
735
|
+
#focused = (i(this, "focused"), void 0);
|
|
736
|
+
/** The day with focus, while a day has it. */
|
|
737
|
+
static {
|
|
738
|
+
g(this.prototype, "lastFocused", [tracked]);
|
|
739
|
+
}
|
|
740
|
+
#lastFocused = (i(this, "lastFocused"), void 0);
|
|
741
|
+
/** The last day that had focus, where focus goes back to. */
|
|
742
|
+
#root;
|
|
743
|
+
|
|
744
|
+
/**
|
|
745
|
+
* @param args the calendar's arguments, read live
|
|
746
|
+
* @param classNames the headless component's `@classNames`; the styled one keeps the defaults
|
|
747
|
+
* @param context the component, whose app's translator words the labels and sets the locale
|
|
748
|
+
*/
|
|
749
|
+
constructor(args, classNames = () => undefined, context) {
|
|
750
|
+
this.#args = args;
|
|
751
|
+
this.#classNames = classNames;
|
|
752
|
+
this.#context = context;
|
|
753
|
+
this.month = new ControllableState({
|
|
754
|
+
name: 'month',
|
|
755
|
+
value: () => args().month,
|
|
756
|
+
defaultValue: () => args().defaultMonth,
|
|
757
|
+
onChange: () => args().onMonthChange,
|
|
758
|
+
fallback: startOfDay(args().today ?? new Date())
|
|
759
|
+
});
|
|
760
|
+
if (args().autoFocus) {
|
|
761
|
+
// Nothing has had focus yet. The target is worked out without reading `focused`, which is
|
|
762
|
+
// set next: the calendar is made while it renders, and Ember 6.12 asserts on a tracked
|
|
763
|
+
// value written after it was read in the same render.
|
|
764
|
+
const target = this.#focusTargetOf(this.grid, undefined, undefined);
|
|
765
|
+
if (target) this.focused = {
|
|
766
|
+
date: target.date,
|
|
767
|
+
displayMonth: target.displayMonth
|
|
768
|
+
};
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
get args() {
|
|
772
|
+
return this.#args();
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
/** The class of each part and state: react-day-picker's `rdp-*`, or the `@classNames` given. */
|
|
776
|
+
get classNames() {
|
|
777
|
+
return {
|
|
778
|
+
...defaultCalendarClassNames,
|
|
779
|
+
...this.#classNames()
|
|
780
|
+
};
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
/** The locale, calendar and numbering system everything is formatted in. */
|
|
784
|
+
get locale() {
|
|
785
|
+
const {
|
|
786
|
+
locale,
|
|
787
|
+
calendar,
|
|
788
|
+
numerals
|
|
789
|
+
} = this.#args();
|
|
790
|
+
return calendarLocale(locale ?? translator(this.#context)?.locale, calendar, numerals);
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
/** The calendar's months and years. */
|
|
794
|
+
get system() {
|
|
795
|
+
return calendarSystem(this.locale.calendar);
|
|
796
|
+
}
|
|
797
|
+
get weekStartsOn() {
|
|
798
|
+
return this.#args().weekStartsOn ?? weekInfo(this.locale.tag).firstDay;
|
|
799
|
+
}
|
|
800
|
+
get firstWeekContainsDate() {
|
|
801
|
+
return this.#args().firstWeekContainsDate ?? weekInfo(this.locale.tag).minimalDays;
|
|
802
|
+
}
|
|
803
|
+
get formatters() {
|
|
804
|
+
return {
|
|
805
|
+
...defaultCalendarFormatters,
|
|
806
|
+
...this.#args().formatters
|
|
807
|
+
};
|
|
808
|
+
}
|
|
809
|
+
get labels() {
|
|
810
|
+
return {
|
|
811
|
+
...calendarLabels(this.#context),
|
|
812
|
+
...this.#args().labels
|
|
813
|
+
};
|
|
814
|
+
}
|
|
815
|
+
get today() {
|
|
816
|
+
return startOfDay(this.#args().today ?? new Date());
|
|
817
|
+
}
|
|
818
|
+
get numberOfMonths() {
|
|
819
|
+
return Math.max(1, this.#args().numberOfMonths ?? 1);
|
|
820
|
+
}
|
|
821
|
+
get captionLayout() {
|
|
822
|
+
return this.#args().captionLayout ?? 'label';
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
/** Whether the caption is dropdowns (a month dropdown, a year dropdown, or both). */
|
|
826
|
+
get hasDropdowns() {
|
|
827
|
+
return this.captionLayout.startsWith('dropdown');
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
/** Whether the days are buttons: the calendar selects, or listens for presses. */
|
|
831
|
+
get isInteractive() {
|
|
832
|
+
const {
|
|
833
|
+
mode,
|
|
834
|
+
onDayClick
|
|
835
|
+
} = this.#args();
|
|
836
|
+
return mode !== undefined || onDayClick !== undefined;
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
/** `aria-multiselectable`: `true` for `multiple` and `range`. */
|
|
840
|
+
get isMultiselectable() {
|
|
841
|
+
const mode = this.#args().mode;
|
|
842
|
+
return mode === 'multiple' || mode === 'range';
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
/**
|
|
846
|
+
* The first and last day you can go to: `@startMonth`'s first and `@endMonth`'s last, or with a
|
|
847
|
+
* year dropdown, 100 years back to the end of this year, as react-day-picker's.
|
|
848
|
+
*/
|
|
849
|
+
get navBounds() {
|
|
850
|
+
const {
|
|
851
|
+
startMonth,
|
|
852
|
+
endMonth
|
|
853
|
+
} = this.#args();
|
|
854
|
+
const system = this.system;
|
|
855
|
+
const hasYears = this.captionLayout === 'dropdown' || this.captionLayout === 'dropdown-years';
|
|
856
|
+
const thisYear = system.year(this.today);
|
|
857
|
+
let start;
|
|
858
|
+
let end;
|
|
859
|
+
if (startMonth) start = system.startOfMonth(startOfDay(startMonth));else if (hasYears) start = system.monthStart(thisYear - 100, 0);
|
|
860
|
+
if (endMonth) end = system.endOfMonth(startOfDay(endMonth));else if (hasYears) {
|
|
861
|
+
end = system.endOfMonth(system.monthStart(thisYear, system.monthsInYear(thisYear) - 1));
|
|
862
|
+
}
|
|
863
|
+
return [start, end];
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
/** `month`, kept where `@numberOfMonths` months from it fit between the bounds. */
|
|
867
|
+
static {
|
|
868
|
+
n(this.prototype, "navBounds", [cached]);
|
|
869
|
+
}
|
|
870
|
+
#clampFirstMonth(month) {
|
|
871
|
+
const system = this.system;
|
|
872
|
+
const [start, end] = this.navBounds;
|
|
873
|
+
let first = system.startOfMonth(startOfDay(month));
|
|
874
|
+
const offset = this.numberOfMonths - 1;
|
|
875
|
+
if (end && compareDays(system.addMonths(first, offset), system.startOfMonth(end)) > 0) {
|
|
876
|
+
first = system.addMonths(system.startOfMonth(end), -offset);
|
|
877
|
+
}
|
|
878
|
+
if (start && compareDays(first, start) < 0) first = start;
|
|
879
|
+
return system.startOfMonth(first);
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
/** The first day of the first month shown. */
|
|
883
|
+
get firstMonth() {
|
|
884
|
+
return this.#clampFirstMonth(this.month.value);
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
/** The first day of each month shown. */
|
|
888
|
+
get displayMonths() {
|
|
889
|
+
const system = this.system;
|
|
890
|
+
const end = this.navBounds[1];
|
|
891
|
+
const months = [];
|
|
892
|
+
for (let index = 0; index < this.numberOfMonths; index += 1) {
|
|
893
|
+
const month = system.addMonths(this.firstMonth, index);
|
|
894
|
+
if (end && compareDays(month, end) > 0) break;
|
|
895
|
+
months.push(month);
|
|
896
|
+
}
|
|
897
|
+
return months;
|
|
898
|
+
}
|
|
899
|
+
static {
|
|
900
|
+
n(this.prototype, "displayMonths", [cached]);
|
|
901
|
+
}
|
|
902
|
+
get #offset() {
|
|
903
|
+
return this.#args().pagedNavigation ? this.numberOfMonths : 1;
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
/** The month the previous button goes to, or `undefined` when there's none. */
|
|
907
|
+
get previousMonth() {
|
|
908
|
+
if (this.#args().disableNavigation) return undefined;
|
|
909
|
+
const start = this.navBounds[0];
|
|
910
|
+
const first = this.firstMonth;
|
|
911
|
+
if (start && compareDays(first, start) <= 0) return undefined;
|
|
912
|
+
return this.system.addMonths(first, -this.#offset);
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
/** The month the next button goes to, or `undefined` when there's none. */
|
|
916
|
+
get nextMonth() {
|
|
917
|
+
if (this.#args().disableNavigation) return undefined;
|
|
918
|
+
const end = this.navBounds[1];
|
|
919
|
+
const system = this.system;
|
|
920
|
+
const first = this.firstMonth;
|
|
921
|
+
if (end && compareDays(system.addMonths(first, this.numberOfMonths), system.startOfMonth(end)) > 0) {
|
|
922
|
+
return undefined;
|
|
923
|
+
}
|
|
924
|
+
return system.addMonths(first, this.#offset);
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
/** Shows `month` (any day of it) first, kept between the bounds, and tells `@onMonthChange`. */
|
|
928
|
+
goToMonth = month => {
|
|
929
|
+
if (this.#args().disableNavigation) return;
|
|
930
|
+
const system = this.system;
|
|
931
|
+
const [start, end] = this.navBounds;
|
|
932
|
+
let next = system.startOfMonth(startOfDay(month));
|
|
933
|
+
if (start && compareDays(next, start) < 0) next = start;
|
|
934
|
+
if (end && compareDays(next, system.startOfMonth(end)) > 0) next = system.startOfMonth(end);
|
|
935
|
+
this.month.set(next);
|
|
936
|
+
};
|
|
937
|
+
goToPrevious = () => {
|
|
938
|
+
const month = this.previousMonth;
|
|
939
|
+
if (month) this.goToMonth(month);
|
|
940
|
+
};
|
|
941
|
+
goToNext = () => {
|
|
942
|
+
const month = this.nextMonth;
|
|
943
|
+
if (month) this.goToMonth(month);
|
|
944
|
+
};
|
|
945
|
+
|
|
946
|
+
/** A month dropdown's change: shows that month of the year it was in. */
|
|
947
|
+
changeMonth = (month, event) => {
|
|
948
|
+
const index = Number(event.target.value);
|
|
949
|
+
this.goToMonth(this.system.monthStart(this.system.year(month.date), index));
|
|
950
|
+
};
|
|
951
|
+
|
|
952
|
+
/** A year dropdown's change: shows the same month of that year. */
|
|
953
|
+
changeYear = (month, event) => {
|
|
954
|
+
const year = Number(event.target.value);
|
|
955
|
+
const system = this.system;
|
|
956
|
+
const index = Math.min(system.month(month.date), system.monthsInYear(year) - 1);
|
|
957
|
+
this.goToMonth(system.monthStart(year, index));
|
|
958
|
+
};
|
|
959
|
+
|
|
960
|
+
// ---------------------------------------------------------------------------------------------
|
|
961
|
+
// Selection
|
|
962
|
+
|
|
963
|
+
/**
|
|
964
|
+
* Whether the caller owns the selection: they pass `@value`, or `@onValueChange` without a
|
|
965
|
+
* `@defaultValue` (react-day-picker's rule: `onSelect` controls `selected`, even unset).
|
|
966
|
+
*/
|
|
967
|
+
get isValueControlled() {
|
|
968
|
+
const {
|
|
969
|
+
value,
|
|
970
|
+
defaultValue,
|
|
971
|
+
onValueChange
|
|
972
|
+
} = this.#args();
|
|
973
|
+
return value !== undefined || onValueChange !== undefined && defaultValue === undefined;
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
/** The selection now. */
|
|
977
|
+
get selected() {
|
|
978
|
+
if (this.isValueControlled) return this.#args().value;
|
|
979
|
+
return this.ownValue ? this.ownValue.value : this.#args().defaultValue;
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
/** Whether `date` is selected. */
|
|
983
|
+
isSelected = date => {
|
|
984
|
+
const selected = this.selected;
|
|
985
|
+
if (!selected) return false;
|
|
986
|
+
if (selected instanceof Date) return isSameDay(selected, date);
|
|
987
|
+
if (Array.isArray(selected)) return selected.some(day => isSameDay(day, date));
|
|
988
|
+
return rangeIncludesDate(selected, date);
|
|
989
|
+
};
|
|
990
|
+
#setValue(value, details) {
|
|
991
|
+
if (!this.isValueControlled) this.ownValue = {
|
|
992
|
+
value
|
|
993
|
+
};
|
|
994
|
+
this.#args().onValueChange?.(value, details);
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
/** Selects `date` (or lets it go) by the calendar's mode, as a press on it does. */
|
|
998
|
+
select(date, modifiers, event) {
|
|
999
|
+
const {
|
|
1000
|
+
mode,
|
|
1001
|
+
required,
|
|
1002
|
+
min,
|
|
1003
|
+
max,
|
|
1004
|
+
excludeDisabled,
|
|
1005
|
+
disabled
|
|
1006
|
+
} = this.#args();
|
|
1007
|
+
const details = {
|
|
1008
|
+
date,
|
|
1009
|
+
modifiers,
|
|
1010
|
+
event
|
|
1011
|
+
};
|
|
1012
|
+
if (mode === 'single') {
|
|
1013
|
+
const selected = this.selected instanceof Date ? this.selected : undefined;
|
|
1014
|
+
const next = !required && selected && isSameDay(selected, date) ? undefined : date;
|
|
1015
|
+
this.#setValue(next, details);
|
|
1016
|
+
} else if (mode === 'multiple') {
|
|
1017
|
+
const selected = Array.isArray(this.selected) ? this.selected : undefined;
|
|
1018
|
+
let next;
|
|
1019
|
+
if (this.isSelected(date)) {
|
|
1020
|
+
if (selected?.length === min) return;
|
|
1021
|
+
if (required && selected?.length === 1) return;
|
|
1022
|
+
next = selected?.filter(day => !isSameDay(day, date));
|
|
1023
|
+
} else {
|
|
1024
|
+
next = selected?.length === max ? [date] : [...(selected ?? []), date];
|
|
1025
|
+
}
|
|
1026
|
+
this.#setValue(next, details);
|
|
1027
|
+
} else if (mode === 'range') {
|
|
1028
|
+
const selected = isRange(this.selected) ? this.selected : undefined;
|
|
1029
|
+
const next = addToRange(date, selected, min, max, required);
|
|
1030
|
+
if (excludeDisabled && disabled && next?.from && next.to) {
|
|
1031
|
+
if (rangeContainsMatch({
|
|
1032
|
+
from: next.from,
|
|
1033
|
+
to: next.to
|
|
1034
|
+
}, disabled)) {
|
|
1035
|
+
next.from = date;
|
|
1036
|
+
next.to = undefined;
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
this.#setValue(next, details);
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
// ---------------------------------------------------------------------------------------------
|
|
1044
|
+
// Days
|
|
1045
|
+
|
|
1046
|
+
/** The day's flags and your modifiers, before selection and focus. */
|
|
1047
|
+
#baseModifiers(date, displayMonth) {
|
|
1048
|
+
const args = this.#args();
|
|
1049
|
+
const [start, end] = this.navBounds;
|
|
1050
|
+
const outside = !isSameDay(this.system.startOfMonth(date), displayMonth);
|
|
1051
|
+
const hidden = isMatch(date, args.hidden) || Boolean(start && compareDays(date, start) < 0) || Boolean(end && compareDays(date, end) > 0) || !args.showOutsideDays && outside;
|
|
1052
|
+
const modifiers = {
|
|
1053
|
+
focused: false,
|
|
1054
|
+
disabled: isMatch(date, args.disabled),
|
|
1055
|
+
hidden,
|
|
1056
|
+
outside,
|
|
1057
|
+
today: isSameDay(date, this.today),
|
|
1058
|
+
selected: false,
|
|
1059
|
+
range_start: false,
|
|
1060
|
+
range_end: false,
|
|
1061
|
+
range_middle: false
|
|
1062
|
+
};
|
|
1063
|
+
for (const [name, matcher] of Object.entries(args.modifiers ?? {})) {
|
|
1064
|
+
modifiers[name] = isMatch(date, matcher);
|
|
1065
|
+
}
|
|
1066
|
+
return modifiers;
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
/** The days of one month's grid: whole weeks, or six of them with `@fixedWeeks`. */
|
|
1070
|
+
#daysOf(month) {
|
|
1071
|
+
const weekStartsOn = this.weekStartsOn;
|
|
1072
|
+
const days = [];
|
|
1073
|
+
const last = endOfWeek(this.system.endOfMonth(month), weekStartsOn);
|
|
1074
|
+
for (let day = startOfWeek(month, weekStartsOn); compareDays(day, last) <= 0;) {
|
|
1075
|
+
days.push(day);
|
|
1076
|
+
day = addDays(day, 1);
|
|
1077
|
+
}
|
|
1078
|
+
if (this.#args().fixedWeeks) {
|
|
1079
|
+
while (days.length < 42) days.push(addDays(days[days.length - 1], 1));
|
|
1080
|
+
}
|
|
1081
|
+
return days;
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
/**
|
|
1085
|
+
* The day focus goes to with Tab, as react-day-picker picks it: the focused day, else the one
|
|
1086
|
+
* focused last, else the first selected, else today, else the first that can take focus.
|
|
1087
|
+
*/
|
|
1088
|
+
get focusTarget() {
|
|
1089
|
+
return this.#focusTargetOf(this.grid, this.focused, this.lastFocused);
|
|
1090
|
+
}
|
|
1091
|
+
#focusTargetOf(grid, focused, lastFocused) {
|
|
1092
|
+
const focusable = modifiers => !modifiers.disabled && !modifiers.hidden && !modifiers.outside;
|
|
1093
|
+
let found;
|
|
1094
|
+
let priority = -1;
|
|
1095
|
+
for (const days of grid) {
|
|
1096
|
+
for (const day of days) {
|
|
1097
|
+
if (!focusable(day.modifiers)) continue;
|
|
1098
|
+
if (priority < 4 && sameRef(focused, day)) [found, priority] = [day, 4];else if (priority < 3 && sameRef(lastFocused, day)) [found, priority] = [day, 3];else if (priority < 2 && this.isSelected(day.date)) [found, priority] = [day, 2];else if (priority < 1 && day.modifiers.today) [found, priority] = [day, 1];else if (priority < 0) [found, priority] = [day, 0];
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
return found;
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
/** Each month's days, with their base modifiers. */
|
|
1105
|
+
get grid() {
|
|
1106
|
+
return this.displayMonths.map(month => this.#daysOf(month).map(date => ({
|
|
1107
|
+
date,
|
|
1108
|
+
displayMonth: month,
|
|
1109
|
+
modifiers: this.#baseModifiers(date, month)
|
|
1110
|
+
})));
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
/** The column headings, from the first day of the week. */
|
|
1114
|
+
static {
|
|
1115
|
+
n(this.prototype, "grid", [cached]);
|
|
1116
|
+
}
|
|
1117
|
+
get weekdays() {
|
|
1118
|
+
const locale = this.locale;
|
|
1119
|
+
const {
|
|
1120
|
+
formatWeekdayName
|
|
1121
|
+
} = this.formatters;
|
|
1122
|
+
const {
|
|
1123
|
+
labelWeekday
|
|
1124
|
+
} = this.labels;
|
|
1125
|
+
const start = startOfWeek(this.today, this.weekStartsOn);
|
|
1126
|
+
return Array.from({
|
|
1127
|
+
length: 7
|
|
1128
|
+
}, (_, index) => {
|
|
1129
|
+
const day = addDays(start, index);
|
|
1130
|
+
return {
|
|
1131
|
+
key: String(day.getDay()),
|
|
1132
|
+
name: formatWeekdayName(day, locale),
|
|
1133
|
+
label: labelWeekday(day, locale)
|
|
1134
|
+
};
|
|
1135
|
+
});
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
/** The months shown, each with its caption, dropdowns, weeks and days. */
|
|
1139
|
+
static {
|
|
1140
|
+
n(this.prototype, "weekdays", [cached]);
|
|
1141
|
+
}
|
|
1142
|
+
get months() {
|
|
1143
|
+
const args = this.#args();
|
|
1144
|
+
const system = this.system;
|
|
1145
|
+
const locale = this.locale;
|
|
1146
|
+
const formatters = this.formatters;
|
|
1147
|
+
const labels = this.labels;
|
|
1148
|
+
const classNames = this.classNames;
|
|
1149
|
+
const custom = args.modifiersClassNames ?? {};
|
|
1150
|
+
const grid = this.grid;
|
|
1151
|
+
const target = this.#focusTargetOf(grid, this.focused, this.lastFocused);
|
|
1152
|
+
const interactive = this.isInteractive;
|
|
1153
|
+
const selected = this.selected;
|
|
1154
|
+
const range = isRange(selected) ? selected : undefined;
|
|
1155
|
+
const weekStartsOn = this.weekStartsOn;
|
|
1156
|
+
const firstWeekContainsDate = this.firstWeekContainsDate;
|
|
1157
|
+
const [start, end] = this.navBounds;
|
|
1158
|
+
const years = this.#yearOptions();
|
|
1159
|
+
return this.displayMonths.map((month, index) => {
|
|
1160
|
+
const days = grid[index].map(({
|
|
1161
|
+
date,
|
|
1162
|
+
displayMonth,
|
|
1163
|
+
modifiers: base
|
|
1164
|
+
}) => {
|
|
1165
|
+
const modifiers = {
|
|
1166
|
+
...base
|
|
1167
|
+
};
|
|
1168
|
+
modifiers.focused = !modifiers.hidden && sameRef(this.focused, {
|
|
1169
|
+
date,
|
|
1170
|
+
displayMonth
|
|
1171
|
+
});
|
|
1172
|
+
modifiers.selected = this.isSelected(date) || Boolean(base.selected);
|
|
1173
|
+
if (range) {
|
|
1174
|
+
modifiers.range_start = Boolean(range.from && range.to && isSameDay(date, range.from));
|
|
1175
|
+
modifiers.range_end = Boolean(range.from && range.to && isSameDay(date, range.to));
|
|
1176
|
+
modifiers.range_middle = rangeIncludesDate(range, date, true);
|
|
1177
|
+
}
|
|
1178
|
+
const classes = [classNames.day];
|
|
1179
|
+
for (const [name, active] of Object.entries(modifiers)) {
|
|
1180
|
+
if (!active) continue;
|
|
1181
|
+
const className = custom[name] ?? classNames[name];
|
|
1182
|
+
if (className) classes.push(className);
|
|
1183
|
+
}
|
|
1184
|
+
const iso = isoDate(date);
|
|
1185
|
+
const outside = modifiers.outside;
|
|
1186
|
+
return {
|
|
1187
|
+
key: `${iso}_${isoDate(displayMonth)}`,
|
|
1188
|
+
iso,
|
|
1189
|
+
date,
|
|
1190
|
+
displayMonth,
|
|
1191
|
+
outside,
|
|
1192
|
+
modifiers,
|
|
1193
|
+
label: formatters.formatDay(date, locale),
|
|
1194
|
+
buttonLabel: labels.labelDayButton(date, modifiers, locale),
|
|
1195
|
+
cellLabel: !interactive && !modifiers.hidden ? labels.labelGridcell(date, modifiers, locale) : undefined,
|
|
1196
|
+
isButton: interactive && !modifiers.hidden,
|
|
1197
|
+
isShown: !modifiers.hidden,
|
|
1198
|
+
tabIndex: target && sameRef(target, {
|
|
1199
|
+
date,
|
|
1200
|
+
displayMonth
|
|
1201
|
+
}) ? 0 : -1,
|
|
1202
|
+
localeDate: date.toLocaleDateString(locale.tag),
|
|
1203
|
+
outsideMonth: outside ? isoMonth(date) : undefined,
|
|
1204
|
+
className: classes.join(' '),
|
|
1205
|
+
selectedSingle: modifiers.selected && !modifiers.range_start && !modifiers.range_end && !modifiers.range_middle
|
|
1206
|
+
};
|
|
1207
|
+
});
|
|
1208
|
+
const weeks = [];
|
|
1209
|
+
for (let at = 0; at < days.length; at += 7) {
|
|
1210
|
+
const week = days.slice(at, at + 7);
|
|
1211
|
+
const number = weekNumber(week[0].date, system, weekStartsOn, firstWeekContainsDate);
|
|
1212
|
+
weeks.push({
|
|
1213
|
+
key: week[0].key,
|
|
1214
|
+
number,
|
|
1215
|
+
numberText: formatters.formatWeekNumber(number, locale),
|
|
1216
|
+
numberLabel: labels.labelWeekNumber(number, locale),
|
|
1217
|
+
days: week
|
|
1218
|
+
});
|
|
1219
|
+
}
|
|
1220
|
+
const year = system.year(month);
|
|
1221
|
+
const monthIndex = system.month(month);
|
|
1222
|
+
const withMonths = this.captionLayout === 'dropdown' || this.captionLayout === 'dropdown-months';
|
|
1223
|
+
const withYears = this.captionLayout === 'dropdown' || this.captionLayout === 'dropdown-years';
|
|
1224
|
+
const monthOptions = withMonths ? Array.from({
|
|
1225
|
+
length: system.monthsInYear(year)
|
|
1226
|
+
}, (_, value) => {
|
|
1227
|
+
const option = system.monthStart(year, value);
|
|
1228
|
+
return {
|
|
1229
|
+
value,
|
|
1230
|
+
label: formatters.formatMonthDropdown(option, locale),
|
|
1231
|
+
disabled: Boolean(start && compareDays(option, system.startOfMonth(start)) < 0) || Boolean(end && compareDays(option, system.startOfMonth(end)) > 0),
|
|
1232
|
+
selected: value === monthIndex
|
|
1233
|
+
};
|
|
1234
|
+
}) : undefined;
|
|
1235
|
+
const yearOptions = withYears && years ? years.map(option => ({
|
|
1236
|
+
...option,
|
|
1237
|
+
selected: option.value === year
|
|
1238
|
+
})) : undefined;
|
|
1239
|
+
return {
|
|
1240
|
+
key: isoDate(month),
|
|
1241
|
+
index,
|
|
1242
|
+
date: month,
|
|
1243
|
+
caption: formatters.formatCaption(month, locale),
|
|
1244
|
+
gridLabel: labels.labelGrid(month, locale),
|
|
1245
|
+
weeks,
|
|
1246
|
+
monthOptions,
|
|
1247
|
+
yearOptions,
|
|
1248
|
+
monthText: monthOptions?.find(option => option.selected)?.label ?? formatters.formatMonthDropdown(month, locale),
|
|
1249
|
+
yearText: yearOptions?.find(option => option.selected)?.label ?? formatters.formatYearDropdown(month, locale)
|
|
1250
|
+
};
|
|
1251
|
+
});
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1254
|
+
/** The year dropdown's options: every year between the bounds, when there are both. */
|
|
1255
|
+
static {
|
|
1256
|
+
n(this.prototype, "months", [cached]);
|
|
1257
|
+
}
|
|
1258
|
+
#yearOptions() {
|
|
1259
|
+
const [start, end] = this.navBounds;
|
|
1260
|
+
if (!start || !end) return undefined;
|
|
1261
|
+
const system = this.system;
|
|
1262
|
+
const locale = this.locale;
|
|
1263
|
+
const {
|
|
1264
|
+
formatYearDropdown
|
|
1265
|
+
} = this.formatters;
|
|
1266
|
+
const options = [];
|
|
1267
|
+
for (let year = system.year(start); year <= system.year(end); year += 1) {
|
|
1268
|
+
options.push({
|
|
1269
|
+
value: year,
|
|
1270
|
+
label: formatYearDropdown(system.monthStart(year, 0), locale),
|
|
1271
|
+
disabled: false
|
|
1272
|
+
});
|
|
1273
|
+
}
|
|
1274
|
+
return options;
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
/** The day after a move, skipping disabled and hidden days, as react-day-picker's. */
|
|
1278
|
+
#nextFocus(by, direction, from, attempt = 0) {
|
|
1279
|
+
if (attempt > 365) return undefined;
|
|
1280
|
+
const system = this.system;
|
|
1281
|
+
const step = direction === 'after' ? 1 : -1;
|
|
1282
|
+
const weekStartsOn = this.weekStartsOn;
|
|
1283
|
+
let next;
|
|
1284
|
+
switch (by) {
|
|
1285
|
+
case 'day':
|
|
1286
|
+
next = addDays(from, step);
|
|
1287
|
+
break;
|
|
1288
|
+
case 'week':
|
|
1289
|
+
next = addDays(from, step * 7);
|
|
1290
|
+
break;
|
|
1291
|
+
case 'month':
|
|
1292
|
+
next = system.addMonths(from, step);
|
|
1293
|
+
break;
|
|
1294
|
+
case 'year':
|
|
1295
|
+
next = system.addYears(from, step);
|
|
1296
|
+
break;
|
|
1297
|
+
case 'startOfWeek':
|
|
1298
|
+
next = startOfWeek(from, weekStartsOn);
|
|
1299
|
+
break;
|
|
1300
|
+
case 'endOfWeek':
|
|
1301
|
+
next = endOfWeek(from, weekStartsOn);
|
|
1302
|
+
break;
|
|
1303
|
+
}
|
|
1304
|
+
const [start, end] = this.navBounds;
|
|
1305
|
+
if (direction === 'before' && start && compareDays(next, start) < 0) next = start;
|
|
1306
|
+
if (direction === 'after' && end && compareDays(next, end) > 0) next = end;
|
|
1307
|
+
const {
|
|
1308
|
+
disabled,
|
|
1309
|
+
hidden
|
|
1310
|
+
} = this.#args();
|
|
1311
|
+
if (!isMatch(next, disabled) && !isMatch(next, hidden)) return next;
|
|
1312
|
+
return this.#nextFocus(by, direction, next, attempt + 1);
|
|
1313
|
+
}
|
|
1314
|
+
|
|
1315
|
+
/** Moves focus from the focused day, showing the month it lands in if it isn't shown. */
|
|
1316
|
+
moveFocus(by, direction) {
|
|
1317
|
+
const focused = this.focused;
|
|
1318
|
+
if (!focused) return;
|
|
1319
|
+
const next = this.#nextFocus(by, direction, focused.date);
|
|
1320
|
+
if (!next) return;
|
|
1321
|
+
const displayMonth = this.system.startOfMonth(next);
|
|
1322
|
+
if (!this.displayMonths.some(month => isSameDay(month, displayMonth))) {
|
|
1323
|
+
// With @disableNavigation the month can't change, so focus stays where it is.
|
|
1324
|
+
if (this.#args().disableNavigation) return;
|
|
1325
|
+
this.goToMonth(next);
|
|
1326
|
+
}
|
|
1327
|
+
this.focused = {
|
|
1328
|
+
date: next,
|
|
1329
|
+
displayMonth
|
|
1330
|
+
};
|
|
1331
|
+
}
|
|
1332
|
+
|
|
1333
|
+
// ---------------------------------------------------------------------------------------------
|
|
1334
|
+
// Events on a day's button
|
|
1335
|
+
|
|
1336
|
+
clickDay = (day, event) => {
|
|
1337
|
+
event.preventDefault();
|
|
1338
|
+
event.stopPropagation();
|
|
1339
|
+
if (!sameRef(this.focused, day)) this.focused = {
|
|
1340
|
+
date: day.date,
|
|
1341
|
+
displayMonth: day.displayMonth
|
|
1342
|
+
};
|
|
1343
|
+
if (this.#args().mode) this.select(day.date, day.modifiers, event);
|
|
1344
|
+
this.#args().onDayClick?.(day.date, day.modifiers, event);
|
|
1345
|
+
};
|
|
1346
|
+
focusDay = day => {
|
|
1347
|
+
if (!sameRef(this.focused, day)) this.focused = {
|
|
1348
|
+
date: day.date,
|
|
1349
|
+
displayMonth: day.displayMonth
|
|
1350
|
+
};
|
|
1351
|
+
};
|
|
1352
|
+
|
|
1353
|
+
/**
|
|
1354
|
+
* Forgets the focused day once focus has left the calendar's days (not when it moves from one
|
|
1355
|
+
* day to another, which the arrow keys do). It waits a microtask, so a button that is removed
|
|
1356
|
+
* while it has focus doesn't change state mid-render.
|
|
1357
|
+
*/
|
|
1358
|
+
blurDay = (day, event) => {
|
|
1359
|
+
const next = event.relatedTarget;
|
|
1360
|
+
if (next instanceof Element && this.#root?.contains(next) && next.matches('button[data-day]')) {
|
|
1361
|
+
return;
|
|
1362
|
+
}
|
|
1363
|
+
queueMicrotask(() => {
|
|
1364
|
+
const active = this.#root?.ownerDocument.activeElement;
|
|
1365
|
+
if (active && this.#root?.contains(active) && active.matches('button[data-day]')) return;
|
|
1366
|
+
if (!sameRef(this.focused, day)) return;
|
|
1367
|
+
this.lastFocused = this.focused;
|
|
1368
|
+
this.focused = undefined;
|
|
1369
|
+
});
|
|
1370
|
+
};
|
|
1371
|
+
keyDay = (_day, event) => {
|
|
1372
|
+
const map = KEYS[event.key];
|
|
1373
|
+
if (!map) return;
|
|
1374
|
+
event.preventDefault();
|
|
1375
|
+
event.stopPropagation();
|
|
1376
|
+
const rtl = getDirection(event.currentTarget, this.#args().dir) === 'rtl';
|
|
1377
|
+
const [by, direction] = map(event.shiftKey, rtl);
|
|
1378
|
+
this.moveFocus(by, direction);
|
|
1379
|
+
};
|
|
1380
|
+
|
|
1381
|
+
/** Put it on the root: the calendar keeps its element, for focus. */
|
|
1382
|
+
root = modifier(element => {
|
|
1383
|
+
this.#root = element;
|
|
1384
|
+
return () => {
|
|
1385
|
+
if (this.#root === element) this.#root = undefined;
|
|
1386
|
+
};
|
|
1387
|
+
});
|
|
1388
|
+
|
|
1389
|
+
/**
|
|
1390
|
+
* Put it on each day's button with its `focused` modifier: it takes focus when that's set, once
|
|
1391
|
+
* the render is over. Focusing fires the days' blur and focus handlers, which read their day;
|
|
1392
|
+
* run inside the modifier, those reads would count as the modifier's, and on Ember 6.12 the next
|
|
1393
|
+
* render, which updates those days, would then assert that they were read before they changed
|
|
1394
|
+
* (when focus moves to an earlier week, whose modifiers render first).
|
|
1395
|
+
*/
|
|
1396
|
+
focusWhen = modifier((element, [focused]) => {
|
|
1397
|
+
if (!focused) return;
|
|
1398
|
+
queueMicrotask(() => {
|
|
1399
|
+
if (element.isConnected && element.ownerDocument.activeElement !== element) element.focus();
|
|
1400
|
+
});
|
|
1401
|
+
});
|
|
1402
|
+
}
|
|
1403
|
+
|
|
1404
|
+
/** Which way a chevron points: back, forward, or down (a dropdown's). */
|
|
1405
|
+
|
|
1406
|
+
const isLeft = orientation => orientation === 'left';
|
|
1407
|
+
const isRight = orientation => orientation === 'right';
|
|
1408
|
+
const flag = value => value ? 'true' : undefined;
|
|
1409
|
+
const bool = value => value ? 'true' : 'false';
|
|
1410
|
+
const join = (...classes) => classes.filter(Boolean).join(' ');
|
|
1411
|
+
/**
|
|
1412
|
+
* A calendar's chevron, react-day-picker's own: the default where no `<:chevron>` block is given.
|
|
1413
|
+
*/
|
|
1414
|
+
const Chevron = setComponentTemplate(precompileTemplate("<svg class={{@class}} width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n {{#if (isLeft @orientation)}}\n <polygon points=\"16 18.112 9.81111111 12 16 5.87733333 14.0888889 4 6 12 14.0888889 20\" />\n {{else if (isRight @orientation)}}\n <polygon points=\"8 18.112 14.18888889 12 8 5.87733333 9.91111111 4 18 12 9.91111111 20\" />\n {{else}}\n <polygon points=\"6.77 8 12.5 13.57 18.24 8 20 9.72 12.5 17 5 9.72\" />\n {{/if}}\n</svg>", {
|
|
1415
|
+
strictMode: true,
|
|
1416
|
+
scope: () => ({
|
|
1417
|
+
isLeft,
|
|
1418
|
+
isRight
|
|
1419
|
+
})
|
|
1420
|
+
}), templateOnly());
|
|
1421
|
+
/**
|
|
1422
|
+
* A calendar, headless: react-day-picker's `DayPicker`, which Joinery's `<Calendar>` replaces.
|
|
1423
|
+
* It renders react-day-picker's markup (a grid for each month, with its caption and weekday
|
|
1424
|
+
* names, and a button for each day) with react-day-picker's `rdp-*` classes, or yours
|
|
1425
|
+
* (`@classNames`), and no styles; the styled `<Calendar>` in `@ember-joinery/ember` renders the
|
|
1426
|
+
* same from the same `CalendarState`, in shadcn's style.
|
|
1427
|
+
*
|
|
1428
|
+
* <Calendar @mode="single" @value={{this.date}} @onValueChange={{this.setDate}} />
|
|
1429
|
+
* <Calendar @mode="range" @numberOfMonths={{2}} @disabled={{this.isPast}} />
|
|
1430
|
+
*
|
|
1431
|
+
* Dates go in and out as `Date`s, a range as `{ from, to }`, and every name and number comes
|
|
1432
|
+
* from Intl in `@locale`, so there is no date library. The days are a grid: one is in the tab
|
|
1433
|
+
* order, and the arrow keys, Page Up and Down, Home and End move between them.
|
|
1434
|
+
*/
|
|
1435
|
+
class Calendar extends Component {
|
|
1436
|
+
state = new CalendarState(() => this.args, () => this.args.classNames, this);
|
|
1437
|
+
get cls() {
|
|
1438
|
+
return this.state.classNames;
|
|
1439
|
+
}
|
|
1440
|
+
get rootClass() {
|
|
1441
|
+
return this.cls.root;
|
|
1442
|
+
}
|
|
1443
|
+
get requiredAttribute() {
|
|
1444
|
+
const required = this.args.required;
|
|
1445
|
+
return required === undefined ? undefined : bool(required);
|
|
1446
|
+
}
|
|
1447
|
+
get navLabel() {
|
|
1448
|
+
return this.state.labels.labelNav(this.state.locale) || undefined;
|
|
1449
|
+
}
|
|
1450
|
+
get previousLabel() {
|
|
1451
|
+
return this.state.labels.labelPrevious(this.state.previousMonth, this.state.locale);
|
|
1452
|
+
}
|
|
1453
|
+
get nextLabel() {
|
|
1454
|
+
return this.state.labels.labelNext(this.state.nextMonth, this.state.locale);
|
|
1455
|
+
}
|
|
1456
|
+
get monthDropdownLabel() {
|
|
1457
|
+
return this.state.labels.labelMonthDropdown(this.state.locale);
|
|
1458
|
+
}
|
|
1459
|
+
get yearDropdownLabel() {
|
|
1460
|
+
return this.state.labels.labelYearDropdown(this.state.locale);
|
|
1461
|
+
}
|
|
1462
|
+
get weekNumberHeaderLabel() {
|
|
1463
|
+
return this.state.labels.labelWeekNumberHeader(this.state.locale);
|
|
1464
|
+
}
|
|
1465
|
+
get weekNumberHeader() {
|
|
1466
|
+
return this.state.formatters.formatWeekNumberHeader(this.state.locale);
|
|
1467
|
+
}
|
|
1468
|
+
get multipleMonths() {
|
|
1469
|
+
return flag(this.state.numberOfMonths > 1);
|
|
1470
|
+
}
|
|
1471
|
+
get previousDisabled() {
|
|
1472
|
+
return !this.state.previousMonth;
|
|
1473
|
+
}
|
|
1474
|
+
get nextDisabled() {
|
|
1475
|
+
return !this.state.nextMonth;
|
|
1476
|
+
}
|
|
1477
|
+
dropdownClass = part => join(this.cls.dropdown, this.cls[part]);
|
|
1478
|
+
static {
|
|
1479
|
+
setComponentTemplate(precompileTemplate("<div class={{this.rootClass}} dir={{@dir}} data-mode={{@mode}} data-required={{this.requiredAttribute}} data-multiple-months={{this.multipleMonths}} data-week-numbers={{flag @showWeekNumber}} data-test-jn=\"calendar\" data-test-jn-name={{@name}} {{this.state.root}} ...attributes>\n <div class={{this.cls.months}}>\n {{#unless @hideNavigation}}\n <nav class={{this.cls.nav}} aria-label={{this.navLabel}} data-test-jn-part=\"nav\">\n <button type=\"button\" class={{this.cls.button_previous}} tabindex={{if this.previousDisabled \"-1\"}} aria-disabled={{flag this.previousDisabled}} aria-label={{this.previousLabel}} data-test-jn-part=\"previous\" {{on \"click\" this.state.goToPrevious}}>\n {{#if (has-block \"chevron\")}}\n {{yield \"left\" this.cls.chevron to=\"chevron\"}}\n {{else}}\n <Chevron @orientation=\"left\" @class={{this.cls.chevron}} />\n {{/if}}\n </button>\n <button type=\"button\" class={{this.cls.button_next}} tabindex={{if this.nextDisabled \"-1\"}} aria-disabled={{flag this.nextDisabled}} aria-label={{this.nextLabel}} data-test-jn-part=\"next\" {{on \"click\" this.state.goToNext}}>\n {{#if (has-block \"chevron\")}}\n {{yield \"right\" this.cls.chevron to=\"chevron\"}}\n {{else}}\n <Chevron @orientation=\"right\" @class={{this.cls.chevron}} />\n {{/if}}\n </button>\n </nav>\n {{/unless}}\n {{#each this.state.months key=\"key\" as |month|}}\n <div class={{this.cls.month}} data-test-jn-part=\"month\" data-test-jn-value={{month.key}}>\n <div class={{this.cls.month_caption}}>\n {{#if this.state.hasDropdowns}}\n <div class={{this.cls.dropdowns}}>\n {{#if month.monthOptions}}\n <span data-disabled={{flag @disableNavigation}} class={{this.cls.dropdown_root}}>\n <select class={{this.dropdownClass \"months_dropdown\"}} aria-label={{this.monthDropdownLabel}} disabled={{@disableNavigation}} data-test-jn-part=\"month-dropdown\" {{on \"change\" (fn this.state.changeMonth month)}}>\n {{#each month.monthOptions as |choice|}}\n <option value={{choice.value}} disabled={{choice.disabled}} selected={{choice.selected}}>{{choice.label}}</option>\n {{/each}}\n </select>\n <span class={{this.cls.caption_label}} aria-hidden=\"true\">\n {{month.monthText}}\n {{#if (has-block \"chevron\")}}\n {{yield \"down\" this.cls.chevron to=\"chevron\"}}\n {{else}}\n <Chevron @orientation=\"down\" @class={{this.cls.chevron}} />\n {{/if}}\n </span>\n </span>\n {{else}}\n <span>{{month.monthText}}</span>\n {{/if}}\n {{#if month.yearOptions}}\n <span data-disabled={{flag @disableNavigation}} class={{this.cls.dropdown_root}}>\n <select class={{this.dropdownClass \"years_dropdown\"}} aria-label={{this.yearDropdownLabel}} disabled={{@disableNavigation}} data-test-jn-part=\"year-dropdown\" {{on \"change\" (fn this.state.changeYear month)}}>\n {{#each month.yearOptions as |choice|}}\n <option value={{choice.value}} disabled={{choice.disabled}} selected={{choice.selected}}>{{choice.label}}</option>\n {{/each}}\n </select>\n <span class={{this.cls.caption_label}} aria-hidden=\"true\">\n {{month.yearText}}\n {{#if (has-block \"chevron\")}}\n {{yield \"down\" this.cls.chevron to=\"chevron\"}}\n {{else}}\n <Chevron @orientation=\"down\" @class={{this.cls.chevron}} />\n {{/if}}\n </span>\n </span>\n {{else}}\n <span>{{month.yearText}}</span>\n {{/if}}\n <span role=\"status\" aria-live=\"polite\" data-test-jn-part=\"caption\" {{visuallyHidden}}>\n {{month.caption}}\n </span>\n </div>\n {{else}}\n <span class={{this.cls.caption_label}} role=\"status\" aria-live=\"polite\" data-test-jn-part=\"caption\">{{month.caption}}</span>\n {{/if}}\n </div>\n <table role=\"grid\" aria-multiselectable={{bool this.state.isMultiselectable}} aria-label={{month.gridLabel}} class={{this.cls.month_grid}} data-test-jn-part=\"grid\">\n {{#unless @hideWeekdays}}\n <thead aria-hidden=\"true\">\n <tr class={{this.cls.weekdays}}>\n {{#if @showWeekNumber}}\n <th aria-label={{this.weekNumberHeaderLabel}} class={{this.cls.week_number_header}} scope=\"col\">{{this.weekNumberHeader}}</th>\n {{/if}}\n {{#each this.state.weekdays key=\"key\" as |weekday|}}\n <th aria-label={{weekday.label}} class={{this.cls.weekday}} scope=\"col\" data-test-jn-part=\"weekday\">{{weekday.name}}</th>\n {{/each}}\n </tr>\n </thead>\n {{/unless}}\n <tbody class={{this.cls.weeks}}>\n {{#each month.weeks key=\"key\" as |week|}}\n <tr class={{this.cls.week}} data-test-jn-part=\"week\">\n {{#if @showWeekNumber}}\n <th aria-label={{week.numberLabel}} class={{this.cls.week_number}} scope=\"row\" role=\"rowheader\" data-test-jn-part=\"week-number\">{{week.numberText}}</th>\n {{/if}}\n {{#each week.days key=\"key\" as |day|}}\n <td class={{day.className}} role=\"gridcell\" aria-selected={{flag day.modifiers.selected}} aria-label={{day.cellLabel}} data-day={{day.iso}} data-month={{day.outsideMonth}} data-selected={{flag day.modifiers.selected}} data-disabled={{flag day.modifiers.disabled}} data-hidden={{flag day.modifiers.hidden}} data-outside={{flag day.outside}} data-focused={{flag day.modifiers.focused}} data-today={{flag day.modifiers.today}} data-test-jn-part=\"day\" data-test-jn-value={{day.iso}}>\n {{#if day.isButton}}\n <button type=\"button\" class={{this.cls.day_button}} disabled={{day.modifiers.disabled}} tabindex={{day.tabIndex}} aria-label={{day.buttonLabel}} data-day={{day.localeDate}} data-selected-single={{bool day.selectedSingle}} data-range-start={{bool day.modifiers.range_start}} data-range-end={{bool day.modifiers.range_end}} data-range-middle={{bool day.modifiers.range_middle}} data-test-jn-part=\"day-button\" data-test-jn-value={{day.iso}} {{on \"click\" (fn this.state.clickDay day)}} {{on \"focus\" (fn this.state.focusDay day)}} {{on \"blur\" (fn this.state.blurDay day)}} {{on \"keydown\" (fn this.state.keyDay day)}} {{this.state.focusWhen day.modifiers.focused}}>\n {{#if (has-block \"day\")}}\n {{yield day to=\"day\"}}\n {{else}}\n {{day.label}}\n {{/if}}\n </button>\n {{else if day.isShown}}\n {{day.label}}\n {{/if}}\n </td>\n {{/each}}\n </tr>\n {{/each}}\n </tbody>\n </table>\n </div>\n {{/each}}\n </div>\n</div>", {
|
|
1480
|
+
strictMode: true,
|
|
1481
|
+
scope: () => ({
|
|
1482
|
+
flag,
|
|
1483
|
+
on,
|
|
1484
|
+
Chevron,
|
|
1485
|
+
fn,
|
|
1486
|
+
visuallyHidden,
|
|
1487
|
+
bool
|
|
1488
|
+
})
|
|
1489
|
+
}), this);
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1493
|
+
export { Calendar, CalendarState, addDays, addToRange, calendarLocale, calendarSystem, Calendar as default, defaultCalendarClassNames, defaultCalendarFormatters, defaultCalendarLabels, isMatch, isSameDay, isoDate, parseIsoDate, rangeIncludesDate, startOfDay, weekInfo };
|
|
1494
|
+
//# sourceMappingURL=calendar.js.map
|