@tanrei/web 0.0.0-stage → 0.1.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/NOTICE +58 -0
- package/README.md +9743 -2
- package/custom-elements.json +86072 -0
- package/dist/THIRD_PARTY_LICENSES.md +136 -0
- package/dist/accordion.css +812 -0
- package/dist/app-shell.css +493 -0
- package/dist/avatar.css +80 -0
- package/dist/breadcrumbs.css +511 -0
- package/dist/callout.css +65 -0
- package/dist/code.css +595 -0
- package/dist/components/accordion/accordion.d.ts +197 -0
- package/dist/components/accordion/accordion.js +763 -0
- package/dist/components/accordion/accordion.js.map +1 -0
- package/dist/components/app-bar/app-bar.d.ts +107 -0
- package/dist/components/app-bar/app-bar.js +295 -0
- package/dist/components/app-bar/app-bar.js.map +1 -0
- package/dist/components/app-bar/app-bar.styles.d.ts +12 -0
- package/dist/components/app-bar/app-bar.styles.js +223 -0
- package/dist/components/app-bar/app-bar.styles.js.map +1 -0
- package/dist/components/app-shell/app-shell.d.ts +220 -0
- package/dist/components/app-shell/app-shell.js +677 -0
- package/dist/components/app-shell/app-shell.js.map +1 -0
- package/dist/components/avatar/avatar.d.ts +162 -0
- package/dist/components/avatar/avatar.js +390 -0
- package/dist/components/avatar/avatar.js.map +1 -0
- package/dist/components/avatar/avatar.styles.d.ts +9 -0
- package/dist/components/avatar/avatar.styles.js +258 -0
- package/dist/components/avatar/avatar.styles.js.map +1 -0
- package/dist/components/badge/badge.d.ts +59 -0
- package/dist/components/badge/badge.js +176 -0
- package/dist/components/badge/badge.js.map +1 -0
- package/dist/components/badge/badge.styles.d.ts +1 -0
- package/dist/components/badge/badge.styles.js +106 -0
- package/dist/components/badge/badge.styles.js.map +1 -0
- package/dist/components/bottom-sheet/bottom-sheet.d.ts +207 -0
- package/dist/components/bottom-sheet/bottom-sheet.js +724 -0
- package/dist/components/bottom-sheet/bottom-sheet.js.map +1 -0
- package/dist/components/bottom-sheet/bottom-sheet.styles.d.ts +1 -0
- package/dist/components/bottom-sheet/bottom-sheet.styles.js +393 -0
- package/dist/components/bottom-sheet/bottom-sheet.styles.js.map +1 -0
- package/dist/components/breadcrumbs/breadcrumbs.d.ts +176 -0
- package/dist/components/breadcrumbs/breadcrumbs.js +638 -0
- package/dist/components/breadcrumbs/breadcrumbs.js.map +1 -0
- package/dist/components/breadcrumbs/breadcrumbs.styles.d.ts +1 -0
- package/dist/components/breadcrumbs/breadcrumbs.styles.js +225 -0
- package/dist/components/breadcrumbs/breadcrumbs.styles.js.map +1 -0
- package/dist/components/button/button.d.ts +280 -0
- package/dist/components/button/button.js +530 -0
- package/dist/components/button/button.js.map +1 -0
- package/dist/components/button/button.styles.d.ts +20 -0
- package/dist/components/button/button.styles.js +328 -0
- package/dist/components/button/button.styles.js.map +1 -0
- package/dist/components/button-group/button-group.d.ts +124 -0
- package/dist/components/button-group/button-group.js +287 -0
- package/dist/components/button-group/button-group.js.map +1 -0
- package/dist/components/button-group/button-group.styles.d.ts +1 -0
- package/dist/components/button-group/button-group.styles.js +220 -0
- package/dist/components/button-group/button-group.styles.js.map +1 -0
- package/dist/components/button-with-menu/button-with-menu.d.ts +224 -0
- package/dist/components/button-with-menu/button-with-menu.js +635 -0
- package/dist/components/button-with-menu/button-with-menu.js.map +1 -0
- package/dist/components/button-with-menu/button-with-menu.styles.d.ts +15 -0
- package/dist/components/button-with-menu/button-with-menu.styles.js +418 -0
- package/dist/components/button-with-menu/button-with-menu.styles.js.map +1 -0
- package/dist/components/calendar/calendar.d.ts +380 -0
- package/dist/components/calendar/calendar.js +1619 -0
- package/dist/components/calendar/calendar.js.map +1 -0
- package/dist/components/calendar/calendar.styles.d.ts +11 -0
- package/dist/components/calendar/calendar.styles.js +412 -0
- package/dist/components/calendar/calendar.styles.js.map +1 -0
- package/dist/components/callout/callout.d.ts +157 -0
- package/dist/components/callout/callout.js +436 -0
- package/dist/components/callout/callout.js.map +1 -0
- package/dist/components/callout/callout.styles.d.ts +13 -0
- package/dist/components/callout/callout.styles.js +383 -0
- package/dist/components/callout/callout.styles.js.map +1 -0
- package/dist/components/card/card.d.ts +108 -0
- package/dist/components/card/card.js +235 -0
- package/dist/components/card/card.js.map +1 -0
- package/dist/components/card/card.styles.d.ts +9 -0
- package/dist/components/card/card.styles.js +170 -0
- package/dist/components/card/card.styles.js.map +1 -0
- package/dist/components/carousel/carousel-geometry.d.ts +178 -0
- package/dist/components/carousel/carousel-geometry.js +356 -0
- package/dist/components/carousel/carousel-geometry.js.map +1 -0
- package/dist/components/carousel/carousel.d.ts +401 -0
- package/dist/components/carousel/carousel.js +1352 -0
- package/dist/components/carousel/carousel.js.map +1 -0
- package/dist/components/carousel/carousel.styles.d.ts +4 -0
- package/dist/components/carousel/carousel.styles.js +475 -0
- package/dist/components/carousel/carousel.styles.js.map +1 -0
- package/dist/components/chat-composer/chat-composer.d.ts +482 -0
- package/dist/components/chat-composer/chat-composer.js +1374 -0
- package/dist/components/chat-composer/chat-composer.js.map +1 -0
- package/dist/components/chat-composer/chat-composer.styles.d.ts +9 -0
- package/dist/components/chat-composer/chat-composer.styles.js +308 -0
- package/dist/components/chat-composer/chat-composer.styles.js.map +1 -0
- package/dist/components/checkbox/checkbox.d.ts +135 -0
- package/dist/components/checkbox/checkbox.js +296 -0
- package/dist/components/checkbox/checkbox.js.map +1 -0
- package/dist/components/checkbox/checkbox.styles.d.ts +13 -0
- package/dist/components/checkbox/checkbox.styles.js +226 -0
- package/dist/components/checkbox/checkbox.styles.js.map +1 -0
- package/dist/components/checkbox-group/checkbox-group.d.ts +199 -0
- package/dist/components/checkbox-group/checkbox-group.js +500 -0
- package/dist/components/checkbox-group/checkbox-group.js.map +1 -0
- package/dist/components/chip/chip.d.ts +176 -0
- package/dist/components/chip/chip.js +376 -0
- package/dist/components/chip/chip.js.map +1 -0
- package/dist/components/chip/chip.styles.d.ts +10 -0
- package/dist/components/chip/chip.styles.js +465 -0
- package/dist/components/chip/chip.styles.js.map +1 -0
- package/dist/components/chip-field/chip-field.d.ts +315 -0
- package/dist/components/chip-field/chip-field.js +887 -0
- package/dist/components/chip-field/chip-field.js.map +1 -0
- package/dist/components/code-block/code-block.before.d.ts +2 -0
- package/dist/components/code-block/code-block.before.js +193 -0
- package/dist/components/code-block/code-block.before.js.map +1 -0
- package/dist/components/code-block/code-block.d.ts +268 -0
- package/dist/components/code-block/code-block.js +1009 -0
- package/dist/components/code-block/code-block.js.map +1 -0
- package/dist/components/code-block/code-block.light.d.ts +50 -0
- package/dist/components/code-block/code-block.light.js +287 -0
- package/dist/components/code-block/code-block.light.js.map +1 -0
- package/dist/components/code-block/code-block.lines.d.ts +49 -0
- package/dist/components/code-block/code-block.lines.js +75 -0
- package/dist/components/code-block/code-block.lines.js.map +1 -0
- package/dist/components/code-block/code-block.styles.d.ts +8 -0
- package/dist/components/code-block/code-block.styles.js +212 -0
- package/dist/components/code-block/code-block.styles.js.map +1 -0
- package/dist/components/color-field/color-field.d.ts +120 -0
- package/dist/components/color-field/color-field.js +182 -0
- package/dist/components/color-field/color-field.js.map +1 -0
- package/dist/components/color-input/color-input.d.ts +302 -0
- package/dist/components/color-input/color-input.js +748 -0
- package/dist/components/color-input/color-input.js.map +1 -0
- package/dist/components/color-input/color-input.styles.d.ts +22 -0
- package/dist/components/color-input/color-input.styles.js +373 -0
- package/dist/components/color-input/color-input.styles.js.map +1 -0
- package/dist/components/color-input/color-text.d.ts +48 -0
- package/dist/components/color-input/color-text.js +77 -0
- package/dist/components/color-input/color-text.js.map +1 -0
- package/dist/components/combobox/combobox.d.ts +387 -0
- package/dist/components/combobox/combobox.js +1108 -0
- package/dist/components/combobox/combobox.js.map +1 -0
- package/dist/components/combobox/combobox.styles.d.ts +26 -0
- package/dist/components/combobox/combobox.styles.js +497 -0
- package/dist/components/combobox/combobox.styles.js.map +1 -0
- package/dist/components/combobox-field/combobox-field.d.ts +159 -0
- package/dist/components/combobox-field/combobox-field.js +280 -0
- package/dist/components/combobox-field/combobox-field.js.map +1 -0
- package/dist/components/copy-button/copy-button.d.ts +112 -0
- package/dist/components/copy-button/copy-button.js +237 -0
- package/dist/components/copy-button/copy-button.js.map +1 -0
- package/dist/components/copy-button/copy-button.styles.d.ts +1 -0
- package/dist/components/copy-button/copy-button.styles.js +62 -0
- package/dist/components/copy-button/copy-button.styles.js.map +1 -0
- package/dist/components/date-time-picker/date-time-picker.d.ts +603 -0
- package/dist/components/date-time-picker/date-time-picker.js +2537 -0
- package/dist/components/date-time-picker/date-time-picker.js.map +1 -0
- package/dist/components/date-time-picker/date-time-picker.styles.d.ts +1 -0
- package/dist/components/date-time-picker/date-time-picker.styles.js +842 -0
- package/dist/components/date-time-picker/date-time-picker.styles.js.map +1 -0
- package/dist/components/description-list/description-list.d.ts +133 -0
- package/dist/components/description-list/description-list.js +395 -0
- package/dist/components/description-list/description-list.js.map +1 -0
- package/dist/components/dialog/dialog.d.ts +140 -0
- package/dist/components/dialog/dialog.js +440 -0
- package/dist/components/dialog/dialog.js.map +1 -0
- package/dist/components/dialog/dialog.styles.d.ts +1 -0
- package/dist/components/dialog/dialog.styles.js +306 -0
- package/dist/components/dialog/dialog.styles.js.map +1 -0
- package/dist/components/divider/divider.d.ts +112 -0
- package/dist/components/divider/divider.js +331 -0
- package/dist/components/divider/divider.js.map +1 -0
- package/dist/components/divider/divider.styles.d.ts +6 -0
- package/dist/components/divider/divider.styles.js +183 -0
- package/dist/components/divider/divider.styles.js.map +1 -0
- package/dist/components/embedded-text-input/embedded-text-input.d.ts +246 -0
- package/dist/components/embedded-text-input/embedded-text-input.js +673 -0
- package/dist/components/embedded-text-input/embedded-text-input.js.map +1 -0
- package/dist/components/embedded-text-input/embedded-text-input.styles.d.ts +1 -0
- package/dist/components/embedded-text-input/embedded-text-input.styles.js +204 -0
- package/dist/components/embedded-text-input/embedded-text-input.styles.js.map +1 -0
- package/dist/components/empty-state/empty-state.d.ts +132 -0
- package/dist/components/empty-state/empty-state.js +333 -0
- package/dist/components/empty-state/empty-state.js.map +1 -0
- package/dist/components/empty-state/empty-state.styles.d.ts +11 -0
- package/dist/components/empty-state/empty-state.styles.js +218 -0
- package/dist/components/empty-state/empty-state.styles.js.map +1 -0
- package/dist/components/fab-menu/fab-menu.d.ts +240 -0
- package/dist/components/fab-menu/fab-menu.js +605 -0
- package/dist/components/fab-menu/fab-menu.js.map +1 -0
- package/dist/components/fab-menu/fab-menu.styles.d.ts +21 -0
- package/dist/components/fab-menu/fab-menu.styles.js +427 -0
- package/dist/components/fab-menu/fab-menu.styles.js.map +1 -0
- package/dist/components/field/field.d.ts +165 -0
- package/dist/components/field/field.js +399 -0
- package/dist/components/field/field.js.map +1 -0
- package/dist/components/field/field.styles.d.ts +2 -0
- package/dist/components/field/field.styles.js +177 -0
- package/dist/components/field/field.styles.js.map +1 -0
- package/dist/components/field-group/field-group.d.ts +122 -0
- package/dist/components/field-group/field-group.js +246 -0
- package/dist/components/field-group/field-group.js.map +1 -0
- package/dist/components/field-group/field-group.styles.d.ts +7 -0
- package/dist/components/field-group/field-group.styles.js +28 -0
- package/dist/components/field-group/field-group.styles.js.map +1 -0
- package/dist/components/figure/figure.d.ts +152 -0
- package/dist/components/figure/figure.js +435 -0
- package/dist/components/figure/figure.js.map +1 -0
- package/dist/components/file-item/file-item.d.ts +232 -0
- package/dist/components/file-item/file-item.js +665 -0
- package/dist/components/file-item/file-item.js.map +1 -0
- package/dist/components/file-item/file-item.styles.d.ts +2 -0
- package/dist/components/file-item/file-item.styles.js +582 -0
- package/dist/components/file-item/file-item.styles.js.map +1 -0
- package/dist/components/file-picker/file-picker.d.ts +221 -0
- package/dist/components/file-picker/file-picker.js +588 -0
- package/dist/components/file-picker/file-picker.js.map +1 -0
- package/dist/components/file-picker/file-picker.styles.d.ts +2 -0
- package/dist/components/file-picker/file-picker.styles.js +303 -0
- package/dist/components/file-picker/file-picker.styles.js.map +1 -0
- package/dist/components/file-upload/file-upload.d.ts +353 -0
- package/dist/components/file-upload/file-upload.js +939 -0
- package/dist/components/file-upload/file-upload.js.map +1 -0
- package/dist/components/file-upload/file-upload.styles.d.ts +1 -0
- package/dist/components/file-upload/file-upload.styles.js +91 -0
- package/dist/components/file-upload/file-upload.styles.js.map +1 -0
- package/dist/components/image-preview/image-preview.d.ts +336 -0
- package/dist/components/image-preview/image-preview.js +1510 -0
- package/dist/components/image-preview/image-preview.js.map +1 -0
- package/dist/components/image-preview/image-preview.styles.d.ts +1 -0
- package/dist/components/image-preview/image-preview.styles.js +418 -0
- package/dist/components/image-preview/image-preview.styles.js.map +1 -0
- package/dist/components/keyboard-shortcut/keyboard-shortcut.d.ts +94 -0
- package/dist/components/keyboard-shortcut/keyboard-shortcut.js +285 -0
- package/dist/components/keyboard-shortcut/keyboard-shortcut.js.map +1 -0
- package/dist/components/keyboard-shortcut/keyboard-shortcut.styles.d.ts +11 -0
- package/dist/components/keyboard-shortcut/keyboard-shortcut.styles.js +155 -0
- package/dist/components/keyboard-shortcut/keyboard-shortcut.styles.js.map +1 -0
- package/dist/components/link-card/link-card.d.ts +156 -0
- package/dist/components/link-card/link-card.js +713 -0
- package/dist/components/link-card/link-card.js.map +1 -0
- package/dist/components/list/list.d.ts +430 -0
- package/dist/components/list/list.js +1230 -0
- package/dist/components/list/list.js.map +1 -0
- package/dist/components/list/list.styles.d.ts +3 -0
- package/dist/components/list/list.styles.js +334 -0
- package/dist/components/list/list.styles.js.map +1 -0
- package/dist/components/loading-indicator/loading-indicator.d.ts +83 -0
- package/dist/components/loading-indicator/loading-indicator.js +195 -0
- package/dist/components/loading-indicator/loading-indicator.js.map +1 -0
- package/dist/components/loading-indicator/loading-indicator.styles.d.ts +6 -0
- package/dist/components/loading-indicator/loading-indicator.styles.js +124 -0
- package/dist/components/loading-indicator/loading-indicator.styles.js.map +1 -0
- package/dist/components/main-action-button/main-action-button.d.ts +95 -0
- package/dist/components/main-action-button/main-action-button.js +202 -0
- package/dist/components/main-action-button/main-action-button.js.map +1 -0
- package/dist/components/main-action-button/main-action-button.styles.d.ts +10 -0
- package/dist/components/main-action-button/main-action-button.styles.js +285 -0
- package/dist/components/main-action-button/main-action-button.styles.js.map +1 -0
- package/dist/components/menu/menu.d.ts +813 -0
- package/dist/components/menu/menu.js +2061 -0
- package/dist/components/menu/menu.js.map +1 -0
- package/dist/components/menu/menu.styles.d.ts +18 -0
- package/dist/components/menu/menu.styles.js +587 -0
- package/dist/components/menu/menu.styles.js.map +1 -0
- package/dist/components/menubar/menubar.d.ts +477 -0
- package/dist/components/menubar/menubar.js +1677 -0
- package/dist/components/menubar/menubar.js.map +1 -0
- package/dist/components/menubar/menubar.styles.d.ts +43 -0
- package/dist/components/menubar/menubar.styles.js +379 -0
- package/dist/components/menubar/menubar.styles.js.map +1 -0
- package/dist/components/navigation-bar/navigation-bar.d.ts +239 -0
- package/dist/components/navigation-bar/navigation-bar.js +544 -0
- package/dist/components/navigation-bar/navigation-bar.js.map +1 -0
- package/dist/components/navigation-bar/navigation-bar.styles.d.ts +21 -0
- package/dist/components/navigation-bar/navigation-bar.styles.js +320 -0
- package/dist/components/navigation-bar/navigation-bar.styles.js.map +1 -0
- package/dist/components/navigation-drawer/navigation-drawer.d.ts +627 -0
- package/dist/components/navigation-drawer/navigation-drawer.js +1917 -0
- package/dist/components/navigation-drawer/navigation-drawer.js.map +1 -0
- package/dist/components/navigation-drawer/navigation-drawer.styles.d.ts +40 -0
- package/dist/components/navigation-drawer/navigation-drawer.styles.js +934 -0
- package/dist/components/navigation-drawer/navigation-drawer.styles.js.map +1 -0
- package/dist/components/number-field/number-field.d.ts +147 -0
- package/dist/components/number-field/number-field.js +252 -0
- package/dist/components/number-field/number-field.js.map +1 -0
- package/dist/components/number-input/number-input.d.ts +347 -0
- package/dist/components/number-input/number-input.js +929 -0
- package/dist/components/number-input/number-input.js.map +1 -0
- package/dist/components/number-input/number-input.styles.d.ts +22 -0
- package/dist/components/number-input/number-input.styles.js +395 -0
- package/dist/components/number-input/number-input.styles.js.map +1 -0
- package/dist/components/number-input/number-text.d.ts +74 -0
- package/dist/components/number-input/number-text.js +230 -0
- package/dist/components/number-input/number-text.js.map +1 -0
- package/dist/components/one-time-code-field/one-time-code-field.d.ts +94 -0
- package/dist/components/one-time-code-field/one-time-code-field.js +135 -0
- package/dist/components/one-time-code-field/one-time-code-field.js.map +1 -0
- package/dist/components/one-time-code-input/code-text.d.ts +51 -0
- package/dist/components/one-time-code-input/code-text.js +145 -0
- package/dist/components/one-time-code-input/code-text.js.map +1 -0
- package/dist/components/one-time-code-input/one-time-code-input.d.ts +219 -0
- package/dist/components/one-time-code-input/one-time-code-input.js +710 -0
- package/dist/components/one-time-code-input/one-time-code-input.js.map +1 -0
- package/dist/components/one-time-code-input/one-time-code-input.styles.d.ts +8 -0
- package/dist/components/one-time-code-input/one-time-code-input.styles.js +323 -0
- package/dist/components/one-time-code-input/one-time-code-input.styles.js.map +1 -0
- package/dist/components/option/option.d.ts +51 -0
- package/dist/components/option/option.js +75 -0
- package/dist/components/option/option.js.map +1 -0
- package/dist/components/page-header/page-header.d.ts +97 -0
- package/dist/components/page-header/page-header.js +258 -0
- package/dist/components/page-header/page-header.js.map +1 -0
- package/dist/components/popover/popover.d.ts +217 -0
- package/dist/components/popover/popover.js +616 -0
- package/dist/components/popover/popover.js.map +1 -0
- package/dist/components/popover/popover.styles.d.ts +8 -0
- package/dist/components/popover/popover.styles.js +299 -0
- package/dist/components/popover/popover.styles.js.map +1 -0
- package/dist/components/progress-indicator/progress-indicator.d.ts +76 -0
- package/dist/components/progress-indicator/progress-indicator.js +165 -0
- package/dist/components/progress-indicator/progress-indicator.js.map +1 -0
- package/dist/components/progress-indicator/progress-indicator.styles.d.ts +7 -0
- package/dist/components/progress-indicator/progress-indicator.styles.js +271 -0
- package/dist/components/progress-indicator/progress-indicator.styles.js.map +1 -0
- package/dist/components/radio-button/radio-button.d.ts +149 -0
- package/dist/components/radio-button/radio-button.js +370 -0
- package/dist/components/radio-button/radio-button.js.map +1 -0
- package/dist/components/radio-button/radio-button.styles.d.ts +8 -0
- package/dist/components/radio-button/radio-button.styles.js +190 -0
- package/dist/components/radio-button/radio-button.styles.js.map +1 -0
- package/dist/components/radio-group/radio-group.d.ts +188 -0
- package/dist/components/radio-group/radio-group.js +380 -0
- package/dist/components/radio-group/radio-group.js.map +1 -0
- package/dist/components/search/search.d.ts +569 -0
- package/dist/components/search/search.js +1801 -0
- package/dist/components/search/search.js.map +1 -0
- package/dist/components/search/search.styles.d.ts +15 -0
- package/dist/components/search/search.styles.js +967 -0
- package/dist/components/search/search.styles.js.map +1 -0
- package/dist/components/segmented-button/segmented-button.d.ts +183 -0
- package/dist/components/segmented-button/segmented-button.js +483 -0
- package/dist/components/segmented-button/segmented-button.js.map +1 -0
- package/dist/components/segmented-button/segmented-button.styles.d.ts +19 -0
- package/dist/components/segmented-button/segmented-button.styles.js +400 -0
- package/dist/components/segmented-button/segmented-button.styles.js.map +1 -0
- package/dist/components/select/select.d.ts +259 -0
- package/dist/components/select/select.js +702 -0
- package/dist/components/select/select.js.map +1 -0
- package/dist/components/select/select.styles.d.ts +27 -0
- package/dist/components/select/select.styles.js +359 -0
- package/dist/components/select/select.styles.js.map +1 -0
- package/dist/components/select-field/select-field.d.ts +141 -0
- package/dist/components/select-field/select-field.js +234 -0
- package/dist/components/select-field/select-field.js.map +1 -0
- package/dist/components/side-sheet/side-sheet.d.ts +190 -0
- package/dist/components/side-sheet/side-sheet.js +592 -0
- package/dist/components/side-sheet/side-sheet.js.map +1 -0
- package/dist/components/side-sheet/side-sheet.styles.d.ts +9 -0
- package/dist/components/side-sheet/side-sheet.styles.js +352 -0
- package/dist/components/side-sheet/side-sheet.styles.js.map +1 -0
- package/dist/components/skeleton/skeleton.d.ts +157 -0
- package/dist/components/skeleton/skeleton.js +550 -0
- package/dist/components/skeleton/skeleton.js.map +1 -0
- package/dist/components/slider/slider.d.ts +235 -0
- package/dist/components/slider/slider.js +792 -0
- package/dist/components/slider/slider.js.map +1 -0
- package/dist/components/slider/slider.styles.d.ts +6 -0
- package/dist/components/slider/slider.styles.js +492 -0
- package/dist/components/slider/slider.styles.js.map +1 -0
- package/dist/components/slider-field/slider-field.d.ts +150 -0
- package/dist/components/slider-field/slider-field.js +269 -0
- package/dist/components/slider-field/slider-field.js.map +1 -0
- package/dist/components/snackbar/snackbar.d.ts +237 -0
- package/dist/components/snackbar/snackbar.js +607 -0
- package/dist/components/snackbar/snackbar.js.map +1 -0
- package/dist/components/snackbar/snackbar.styles.d.ts +10 -0
- package/dist/components/snackbar/snackbar.styles.js +510 -0
- package/dist/components/snackbar/snackbar.styles.js.map +1 -0
- package/dist/components/switch/switch.d.ts +161 -0
- package/dist/components/switch/switch.js +470 -0
- package/dist/components/switch/switch.js.map +1 -0
- package/dist/components/switch/switch.styles.d.ts +3 -0
- package/dist/components/switch/switch.styles.js +440 -0
- package/dist/components/switch/switch.styles.js.map +1 -0
- package/dist/components/tab-view/tab-view.d.ts +303 -0
- package/dist/components/tab-view/tab-view.js +917 -0
- package/dist/components/tab-view/tab-view.js.map +1 -0
- package/dist/components/tab-view/tab-view.styles.d.ts +19 -0
- package/dist/components/tab-view/tab-view.styles.js +85 -0
- package/dist/components/tab-view/tab-view.styles.js.map +1 -0
- package/dist/components/table/table.d.ts +386 -0
- package/dist/components/table/table.js +1320 -0
- package/dist/components/table/table.js.map +1 -0
- package/dist/components/table-of-contents/table-of-contents.d.ts +227 -0
- package/dist/components/table-of-contents/table-of-contents.js +963 -0
- package/dist/components/table-of-contents/table-of-contents.js.map +1 -0
- package/dist/components/table-of-contents/table-of-contents.styles.d.ts +1 -0
- package/dist/components/table-of-contents/table-of-contents.styles.js +243 -0
- package/dist/components/table-of-contents/table-of-contents.styles.js.map +1 -0
- package/dist/components/tabs/tabs.d.ts +800 -0
- package/dist/components/tabs/tabs.js +2183 -0
- package/dist/components/tabs/tabs.js.map +1 -0
- package/dist/components/tabs/tabs.styles.d.ts +47 -0
- package/dist/components/tabs/tabs.styles.js +595 -0
- package/dist/components/tabs/tabs.styles.js.map +1 -0
- package/dist/components/tag/tag.d.ts +77 -0
- package/dist/components/tag/tag.js +143 -0
- package/dist/components/tag/tag.js.map +1 -0
- package/dist/components/tag/tag.styles.d.ts +13 -0
- package/dist/components/tag/tag.styles.js +215 -0
- package/dist/components/tag/tag.styles.js.map +1 -0
- package/dist/components/tag-group/tag-group.d.ts +110 -0
- package/dist/components/tag-group/tag-group.js +298 -0
- package/dist/components/tag-group/tag-group.js.map +1 -0
- package/dist/components/tag-group/tag-group.styles.d.ts +8 -0
- package/dist/components/tag-group/tag-group.styles.js +66 -0
- package/dist/components/tag-group/tag-group.styles.js.map +1 -0
- package/dist/components/text-field/text-field.d.ts +159 -0
- package/dist/components/text-field/text-field.js +272 -0
- package/dist/components/text-field/text-field.js.map +1 -0
- package/dist/components/text-input/text-input-segments.d.ts +93 -0
- package/dist/components/text-input/text-input-segments.js +233 -0
- package/dist/components/text-input/text-input-segments.js.map +1 -0
- package/dist/components/text-input/text-input.d.ts +683 -0
- package/dist/components/text-input/text-input.js +2120 -0
- package/dist/components/text-input/text-input.js.map +1 -0
- package/dist/components/text-input/text-input.styles.d.ts +27 -0
- package/dist/components/text-input/text-input.styles.js +1071 -0
- package/dist/components/text-input/text-input.styles.js.map +1 -0
- package/dist/components/toolbar/toolbar.d.ts +123 -0
- package/dist/components/toolbar/toolbar.js +336 -0
- package/dist/components/toolbar/toolbar.js.map +1 -0
- package/dist/components/toolbar/toolbar.styles.d.ts +10 -0
- package/dist/components/toolbar/toolbar.styles.js +156 -0
- package/dist/components/toolbar/toolbar.styles.js.map +1 -0
- package/dist/components/tooltip/tooltip-placement.d.ts +22 -0
- package/dist/components/tooltip/tooltip-placement.js +15 -0
- package/dist/components/tooltip/tooltip-placement.js.map +1 -0
- package/dist/components/tooltip/tooltip.d.ts +267 -0
- package/dist/components/tooltip/tooltip.js +902 -0
- package/dist/components/tooltip/tooltip.js.map +1 -0
- package/dist/components/tooltip/tooltip.styles.d.ts +7 -0
- package/dist/components/tooltip/tooltip.styles.js +240 -0
- package/dist/components/tooltip/tooltip.styles.js.map +1 -0
- package/dist/components/tree-view/tree-view.d.ts +264 -0
- package/dist/components/tree-view/tree-view.js +1228 -0
- package/dist/components/tree-view/tree-view.js.map +1 -0
- package/dist/description-list.css +337 -0
- package/dist/empty-state.css +70 -0
- package/dist/figure.css +381 -0
- package/dist/generated/icon-sets.d.ts +9 -0
- package/dist/generated/icon-sets.js +18 -0
- package/dist/generated/icon-sets.js.map +1 -0
- package/dist/generated/words.d.ts +161 -0
- package/dist/generated/words.js +91 -0
- package/dist/generated/words.js.map +1 -0
- package/dist/highlight/grammars/css.d.ts +3 -0
- package/dist/highlight/grammars/css.js +56 -0
- package/dist/highlight/grammars/css.js.map +1 -0
- package/dist/highlight/grammars/dart.d.ts +3 -0
- package/dist/highlight/grammars/dart.js +53 -0
- package/dist/highlight/grammars/dart.js.map +1 -0
- package/dist/highlight/grammars/javascript.d.ts +4 -0
- package/dist/highlight/grammars/javascript.js +119 -0
- package/dist/highlight/grammars/javascript.js.map +1 -0
- package/dist/highlight/grammars/json.d.ts +3 -0
- package/dist/highlight/grammars/json.js +19 -0
- package/dist/highlight/grammars/json.js.map +1 -0
- package/dist/highlight/grammars/kotlin.d.ts +3 -0
- package/dist/highlight/grammars/kotlin.js +46 -0
- package/dist/highlight/grammars/kotlin.js.map +1 -0
- package/dist/highlight/grammars/markup.d.ts +3 -0
- package/dist/highlight/grammars/markup.js +45 -0
- package/dist/highlight/grammars/markup.js.map +1 -0
- package/dist/highlight/grammars/shared.d.ts +25 -0
- package/dist/highlight/grammars/shared.js +37 -0
- package/dist/highlight/grammars/shared.js.map +1 -0
- package/dist/highlight/grammars/shell.d.ts +3 -0
- package/dist/highlight/grammars/shell.js +48 -0
- package/dist/highlight/grammars/shell.js.map +1 -0
- package/dist/highlight/grammars/swift.d.ts +3 -0
- package/dist/highlight/grammars/swift.js +46 -0
- package/dist/highlight/grammars/swift.js.map +1 -0
- package/dist/highlight/grammars/typescript.d.ts +2 -0
- package/dist/highlight/grammars/typescript.js +5 -0
- package/dist/highlight/grammars/typescript.js.map +1 -0
- package/dist/highlight/index.d.ts +104 -0
- package/dist/highlight/index.js +331 -0
- package/dist/highlight/index.js.map +1 -0
- package/dist/icons.css +107 -0
- package/dist/icons.d.ts +2 -0
- package/dist/icons.js +10 -0
- package/dist/icons.js.map +1 -0
- package/dist/index.d.ts +85 -0
- package/dist/index.js +100 -0
- package/dist/index.js.map +1 -0
- package/dist/link-card.css +678 -0
- package/dist/link.css +728 -0
- package/dist/link.d.ts +21 -0
- package/dist/link.js +594 -0
- package/dist/link.js.map +1 -0
- package/dist/links/index.d.ts +136 -0
- package/dist/links/index.js +404 -0
- package/dist/links/index.js.map +1 -0
- package/dist/links/node/address.js +154 -0
- package/dist/links/node/cli.js +102 -0
- package/dist/links/node/fetcher.js +267 -0
- package/dist/links/node/head.js +278 -0
- package/dist/links/node/index.d.ts +164 -0
- package/dist/links/node/index.js +26 -0
- package/dist/links/node/links.js +275 -0
- package/dist/links/node/lock.js +86 -0
- package/dist/links/node/mark.js +71 -0
- package/dist/links/node/options.js +120 -0
- package/dist/links/node/pictures.js +265 -0
- package/dist/links/node/refresh.js +28 -0
- package/dist/menu.css +97 -0
- package/dist/menubar.css +69 -0
- package/dist/page-header.css +324 -0
- package/dist/pagination.css +410 -0
- package/dist/pagination.d.ts +6 -0
- package/dist/pagination.js +256 -0
- package/dist/pagination.js.map +1 -0
- package/dist/primitives/actions.d.ts +75 -0
- package/dist/primitives/actions.js +142 -0
- package/dist/primitives/actions.js.map +1 -0
- package/dist/primitives/after-click.d.ts +8 -0
- package/dist/primitives/after-click.js +21 -0
- package/dist/primitives/after-click.js.map +1 -0
- package/dist/primitives/anchored.d.ts +134 -0
- package/dist/primitives/anchored.js +425 -0
- package/dist/primitives/anchored.js.map +1 -0
- package/dist/primitives/arc.d.ts +13 -0
- package/dist/primitives/arc.js +49 -0
- package/dist/primitives/arc.js.map +1 -0
- package/dist/primitives/arrow.d.ts +47 -0
- package/dist/primitives/arrow.js +159 -0
- package/dist/primitives/arrow.js.map +1 -0
- package/dist/primitives/auto-height.d.ts +56 -0
- package/dist/primitives/auto-height.js +150 -0
- package/dist/primitives/auto-height.js.map +1 -0
- package/dist/primitives/autofocus.d.ts +11 -0
- package/dist/primitives/autofocus.js +26 -0
- package/dist/primitives/autofocus.js.map +1 -0
- package/dist/primitives/availability.d.ts +32 -0
- package/dist/primitives/availability.js +122 -0
- package/dist/primitives/availability.js.map +1 -0
- package/dist/primitives/axes.d.ts +45 -0
- package/dist/primitives/axes.js +72 -0
- package/dist/primitives/axes.js.map +1 -0
- package/dist/primitives/behavior.d.ts +14 -0
- package/dist/primitives/behavior.js +19 -0
- package/dist/primitives/behavior.js.map +1 -0
- package/dist/primitives/calendar-date.d.ts +79 -0
- package/dist/primitives/calendar-date.js +135 -0
- package/dist/primitives/calendar-date.js.map +1 -0
- package/dist/primitives/composed.d.ts +144 -0
- package/dist/primitives/composed.js +303 -0
- package/dist/primitives/composed.js.map +1 -0
- package/dist/primitives/default-button.d.ts +49 -0
- package/dist/primitives/default-button.js +270 -0
- package/dist/primitives/default-button.js.map +1 -0
- package/dist/primitives/description.d.ts +18 -0
- package/dist/primitives/description.js +18 -0
- package/dist/primitives/description.js.map +1 -0
- package/dist/primitives/destination.d.ts +259 -0
- package/dist/primitives/destination.js +651 -0
- package/dist/primitives/destination.js.map +1 -0
- package/dist/primitives/direction.d.ts +23 -0
- package/dist/primitives/direction.js +90 -0
- package/dist/primitives/direction.js.map +1 -0
- package/dist/primitives/disabled-while-focused.d.ts +46 -0
- package/dist/primitives/disabled-while-focused.js +126 -0
- package/dist/primitives/disabled-while-focused.js.map +1 -0
- package/dist/primitives/disclosure.d.ts +9 -0
- package/dist/primitives/disclosure.js +15 -0
- package/dist/primitives/disclosure.js.map +1 -0
- package/dist/primitives/dismiss.d.ts +88 -0
- package/dist/primitives/dismiss.js +232 -0
- package/dist/primitives/dismiss.js.map +1 -0
- package/dist/primitives/field-frame.d.ts +166 -0
- package/dist/primitives/field-frame.js +358 -0
- package/dist/primitives/field-frame.js.map +1 -0
- package/dist/primitives/field-group-frame.d.ts +59 -0
- package/dist/primitives/field-group-frame.js +174 -0
- package/dist/primitives/field-group-frame.js.map +1 -0
- package/dist/primitives/field-trigger.d.ts +117 -0
- package/dist/primitives/field-trigger.js +387 -0
- package/dist/primitives/field-trigger.js.map +1 -0
- package/dist/primitives/field.d.ts +186 -0
- package/dist/primitives/field.js +349 -0
- package/dist/primitives/field.js.map +1 -0
- package/dist/primitives/file-format.d.ts +23 -0
- package/dist/primitives/file-format.js +185 -0
- package/dist/primitives/file-format.js.map +1 -0
- package/dist/primitives/file-item-holder.d.ts +45 -0
- package/dist/primitives/file-item-holder.js +39 -0
- package/dist/primitives/file-item-holder.js.map +1 -0
- package/dist/primitives/focus-order.d.ts +11 -0
- package/dist/primitives/focus-order.js +11 -0
- package/dist/primitives/focus-order.js.map +1 -0
- package/dist/primitives/focus-ring.d.ts +76 -0
- package/dist/primitives/focus-ring.js +230 -0
- package/dist/primitives/focus-ring.js.map +1 -0
- package/dist/primitives/follow.d.ts +65 -0
- package/dist/primitives/follow.js +283 -0
- package/dist/primitives/follow.js.map +1 -0
- package/dist/primitives/form-disabled.d.ts +20 -0
- package/dist/primitives/form-disabled.js +46 -0
- package/dist/primitives/form-disabled.js.map +1 -0
- package/dist/primitives/form-says.d.ts +33 -0
- package/dist/primitives/form-says.js +45 -0
- package/dist/primitives/form-says.js.map +1 -0
- package/dist/primitives/forward.d.ts +13 -0
- package/dist/primitives/forward.js +28 -0
- package/dist/primitives/forward.js.map +1 -0
- package/dist/primitives/glyph-mirror.d.ts +77 -0
- package/dist/primitives/glyph-mirror.js +211 -0
- package/dist/primitives/glyph-mirror.js.map +1 -0
- package/dist/primitives/glyph-pending.d.ts +17 -0
- package/dist/primitives/glyph-pending.js +91 -0
- package/dist/primitives/glyph-pending.js.map +1 -0
- package/dist/primitives/glyph.d.ts +53 -0
- package/dist/primitives/glyph.js +161 -0
- package/dist/primitives/glyph.js.map +1 -0
- package/dist/primitives/group-item.d.ts +128 -0
- package/dist/primitives/group-item.js +334 -0
- package/dist/primitives/group-item.js.map +1 -0
- package/dist/primitives/hidden.d.ts +2 -0
- package/dist/primitives/hidden.js +23 -0
- package/dist/primitives/hidden.js.map +1 -0
- package/dist/primitives/host-aria.d.ts +8 -0
- package/dist/primitives/host-aria.js +18 -0
- package/dist/primitives/host-aria.js.map +1 -0
- package/dist/primitives/index.d.ts +59 -0
- package/dist/primitives/index.js +189 -0
- package/dist/primitives/index.js.map +1 -0
- package/dist/primitives/indicator-drag.d.ts +90 -0
- package/dist/primitives/indicator-drag.js +207 -0
- package/dist/primitives/indicator-drag.js.map +1 -0
- package/dist/primitives/interactive.d.ts +13 -0
- package/dist/primitives/interactive.js +67 -0
- package/dist/primitives/interactive.js.map +1 -0
- package/dist/primitives/item-row.d.ts +34 -0
- package/dist/primitives/item-row.js +76 -0
- package/dist/primitives/item-row.js.map +1 -0
- package/dist/primitives/item-update.d.ts +2 -0
- package/dist/primitives/item-update.js +12 -0
- package/dist/primitives/item-update.js.map +1 -0
- package/dist/primitives/kept-length.d.ts +34 -0
- package/dist/primitives/kept-length.js +154 -0
- package/dist/primitives/kept-length.js.map +1 -0
- package/dist/primitives/keyboard-convention.d.ts +30 -0
- package/dist/primitives/keyboard-convention.js +88 -0
- package/dist/primitives/keyboard-convention.js.map +1 -0
- package/dist/primitives/label-lines.d.ts +12 -0
- package/dist/primitives/label-lines.js +34 -0
- package/dist/primitives/label-lines.js.map +1 -0
- package/dist/primitives/layout-scale.d.ts +18 -0
- package/dist/primitives/layout-scale.js +35 -0
- package/dist/primitives/layout-scale.js.map +1 -0
- package/dist/primitives/link.d.ts +147 -0
- package/dist/primitives/link.js +204 -0
- package/dist/primitives/link.js.map +1 -0
- package/dist/primitives/locale-date.d.ts +132 -0
- package/dist/primitives/locale-date.js +508 -0
- package/dist/primitives/locale-date.js.map +1 -0
- package/dist/primitives/missing-value.d.ts +16 -0
- package/dist/primitives/missing-value.js +31 -0
- package/dist/primitives/missing-value.js.map +1 -0
- package/dist/primitives/modal.d.ts +38 -0
- package/dist/primitives/modal.js +175 -0
- package/dist/primitives/modal.js.map +1 -0
- package/dist/primitives/native-text.d.ts +51 -0
- package/dist/primitives/native-text.js +77 -0
- package/dist/primitives/native-text.js.map +1 -0
- package/dist/primitives/natural-height.d.ts +21 -0
- package/dist/primitives/natural-height.js +36 -0
- package/dist/primitives/natural-height.js.map +1 -0
- package/dist/primitives/option-list.d.ts +314 -0
- package/dist/primitives/option-list.js +1098 -0
- package/dist/primitives/option-list.js.map +1 -0
- package/dist/primitives/overlay-focus.d.ts +48 -0
- package/dist/primitives/overlay-focus.js +152 -0
- package/dist/primitives/overlay-focus.js.map +1 -0
- package/dist/primitives/placement.d.ts +131 -0
- package/dist/primitives/placement.js +144 -0
- package/dist/primitives/placement.js.map +1 -0
- package/dist/primitives/places.d.ts +44 -0
- package/dist/primitives/places.js +98 -0
- package/dist/primitives/places.js.map +1 -0
- package/dist/primitives/press.d.ts +90 -0
- package/dist/primitives/press.js +153 -0
- package/dist/primitives/press.js.map +1 -0
- package/dist/primitives/report.d.ts +17 -0
- package/dist/primitives/report.js +34 -0
- package/dist/primitives/report.js.map +1 -0
- package/dist/primitives/ripple.d.ts +40 -0
- package/dist/primitives/ripple.js +70 -0
- package/dist/primitives/ripple.js.map +1 -0
- package/dist/primitives/roving.d.ts +41 -0
- package/dist/primitives/roving.js +71 -0
- package/dist/primitives/roving.js.map +1 -0
- package/dist/primitives/selection.d.ts +134 -0
- package/dist/primitives/selection.js +287 -0
- package/dist/primitives/selection.js.map +1 -0
- package/dist/primitives/separation.d.ts +28 -0
- package/dist/primitives/separation.js +96 -0
- package/dist/primitives/separation.js.map +1 -0
- package/dist/primitives/shared-choice.d.ts +33 -0
- package/dist/primitives/shared-choice.js +110 -0
- package/dist/primitives/shared-choice.js.map +1 -0
- package/dist/primitives/sheet.d.ts +63 -0
- package/dist/primitives/sheet.js +139 -0
- package/dist/primitives/sheet.js.map +1 -0
- package/dist/primitives/sheets.d.ts +8 -0
- package/dist/primitives/sheets.js +96 -0
- package/dist/primitives/sheets.js.map +1 -0
- package/dist/primitives/states.d.ts +33 -0
- package/dist/primitives/states.js +30 -0
- package/dist/primitives/states.js.map +1 -0
- package/dist/primitives/system-watch.d.ts +9 -0
- package/dist/primitives/system-watch.js +29 -0
- package/dist/primitives/system-watch.js.map +1 -0
- package/dist/primitives/target.d.ts +21 -0
- package/dist/primitives/target.js +79 -0
- package/dist/primitives/target.js.map +1 -0
- package/dist/primitives/values.d.ts +6 -0
- package/dist/primitives/values.js +22 -0
- package/dist/primitives/values.js.map +1 -0
- package/dist/primitives/visibility.d.ts +12 -0
- package/dist/primitives/visibility.js +50 -0
- package/dist/primitives/visibility.js.map +1 -0
- package/dist/primitives/words.d.ts +81 -0
- package/dist/primitives/words.js +236 -0
- package/dist/primitives/words.js.map +1 -0
- package/dist/prose.css +1917 -0
- package/dist/registry.d.ts +182 -0
- package/dist/registry.js +2 -0
- package/dist/registry.js.map +1 -0
- package/dist/shape.css +21 -0
- package/dist/skeleton.css +428 -0
- package/dist/steps.css +231 -0
- package/dist/steps.d.ts +6 -0
- package/dist/steps.js +156 -0
- package/dist/steps.js.map +1 -0
- package/dist/styles/icons.d.ts +62 -0
- package/dist/styles/icons.js +237 -0
- package/dist/styles/icons.js.map +1 -0
- package/dist/styles/product-text.d.ts +66 -0
- package/dist/styles/product-text.js +114 -0
- package/dist/styles/product-text.js.map +1 -0
- package/dist/styles/registered-properties.d.ts +6 -0
- package/dist/styles/registered-properties.js +68 -0
- package/dist/styles/registered-properties.js.map +1 -0
- package/dist/styles/shape.d.ts +59 -0
- package/dist/styles/shape.js +95 -0
- package/dist/styles/shape.js.map +1 -0
- package/dist/systems/cupertino.css +8793 -0
- package/dist/systems/m3-expressive-like.css +8786 -0
- package/dist/systems/m3-like.css +8748 -0
- package/dist/table-of-contents.css +482 -0
- package/dist/table.css +902 -0
- package/dist/tanrei.bundle.js +26644 -0
- package/dist/tanrei.bundle.js.map +7 -0
- package/dist/text.css +104 -0
- package/dist/timeline.css +410 -0
- package/dist/timeline.d.ts +6 -0
- package/dist/timeline.js +176 -0
- package/dist/timeline.js.map +1 -0
- package/dist/tokens.css +8801 -0
- package/dist/tree-view.css +797 -0
- package/dist/words.d.ts +2 -0
- package/dist/words.js +6 -0
- package/dist/words.js.map +1 -0
- package/package.json +132 -3
|
@@ -0,0 +1,1619 @@
|
|
|
1
|
+
import { LitElement, html, nothing } from 'lit';
|
|
2
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
3
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
4
|
+
import { repeat } from 'lit/directives/repeat.js';
|
|
5
|
+
import { styleMap } from 'lit/directives/style-map.js';
|
|
6
|
+
import { AvailabilityController, FALLBACK_LOCALE, PressController, SHEET_FLING_VELOCITY, SheetDrag, SystemWatchController, WEEKDAY_NAMES, addDays, addMonths, addMonthsTo, ambientLocale, clampDate, clampMonth, compChoice, compareDates, compareMonths, daysInMonth, deviceToday, fullDateText, inMonth, isoOf, localeFirstDay, longWeekdays, monthGrid, monthOf, monthYearText, narrowWeekdays, numberText, parseIsoDate, parseValues, report, sameDate, supportedLocale, syncFocusStyle, todayName, untilMidnight, weekdayColumns, weekdayOf, WordsController, } from '../../primitives/index.js';
|
|
7
|
+
import '../button/button.js';
|
|
8
|
+
import { PROGRESS, styles } from './calendar.styles.js';
|
|
9
|
+
const MODES = ['single', 'range'];
|
|
10
|
+
const FIRST_DAYS = ['locale', ...WEEKDAY_NAMES];
|
|
11
|
+
const START_VIEWS = ['day', 'year'];
|
|
12
|
+
/** The axis the months move along (comp.calendar.navigation.axis, a choice of kind: its value is the name). */
|
|
13
|
+
const AXIS = '--tanrei-comp-calendar-navigation-axis';
|
|
14
|
+
const AXES = ['vertical', 'horizontal'];
|
|
15
|
+
/** The glyphs the calendar draws (CAL-5, CAL-6), by the icon set's names. */
|
|
16
|
+
const GLYPHS = { up: 'arrow_upward', down: 'arrow_downward', back: 'arrow_back', forward: 'arrow_forward', expand: 'expand_more' };
|
|
17
|
+
/** The years listed while min or max is empty (CAL-7). */
|
|
18
|
+
const FIRST_LISTED_YEAR = 1900;
|
|
19
|
+
const LAST_LISTED_YEAR = 2100;
|
|
20
|
+
/** CAL-34: a followed scroll has ended when no wheel event has arrived for this long (ms) … */
|
|
21
|
+
const SCROLL_QUIET = 150;
|
|
22
|
+
/** … or when it has slowed below this speed (px per ms), measured over its events of the last `SCROLL_WINDOW` ms. */
|
|
23
|
+
const SCROLL_SLOW = 0.1;
|
|
24
|
+
const SCROLL_WINDOW = 100;
|
|
25
|
+
/**
|
|
26
|
+
* How much faster than `SCROLL_SLOW` an event must be to move the days again once a scroll has ended by slowing: a
|
|
27
|
+
* momentum tail's speed, read from whole pixels a frame apart, wavers about the threshold as it falls through it, and
|
|
28
|
+
* without a margin it would end, begin and end again. A new push of the fingers passes it within an event or two.
|
|
29
|
+
*/
|
|
30
|
+
const SCROLL_RESUME = 1.5;
|
|
31
|
+
/** CAL-31, CAL-34: the share of the way to a neighbouring month's view from which a release or the end of a scroll chooses it. */
|
|
32
|
+
const SETTLE_SHARE = 0.25;
|
|
33
|
+
/** What a sum of travelled shares may be off by. */
|
|
34
|
+
const EPSILON = 1e-6;
|
|
35
|
+
/** The rows of a month's view (CAL-1), and the rows two views that are not neighbours lie apart (CAL-29). */
|
|
36
|
+
const VIEW_ROWS = 6;
|
|
37
|
+
/** The first day of the week row a month's view begins with: the row of its first day (CAL-29). */
|
|
38
|
+
const firstRowOf = (month, firstDay) => {
|
|
39
|
+
const first = { ...month, day: 1 };
|
|
40
|
+
return addDays(first, -((weekdayOf(first) - firstDay + 7) % 7));
|
|
41
|
+
};
|
|
42
|
+
const sameMonth = (a, b) => compareMonths(a, b) === 0;
|
|
43
|
+
const clamp = (value, low, high) => Math.min(high, Math.max(low, value));
|
|
44
|
+
/**
|
|
45
|
+
* CAL-29: a value drawn at the progress — `values[i]` at view `i`, straight between two views — as a CSS number: null
|
|
46
|
+
* where every view draws the same, else the first plus each step's change by that step's share of the progress.
|
|
47
|
+
*/
|
|
48
|
+
function between(values) {
|
|
49
|
+
const terms = values.slice(1).flatMap((value, i) => (value === values[i] ? [] : [`${value - values[i]} * clamp(0, var(${PROGRESS}) - ${i}, 1)`]));
|
|
50
|
+
return terms.length ? `calc(${values[0]} + ${terms.join(' + ')})` : null;
|
|
51
|
+
}
|
|
52
|
+
/** How far the days have travelled at progress `p`, in rows (or pages), where step `i` is `steps[i]` long. */
|
|
53
|
+
const travelAt = (steps, p) => steps.reduce((sum, step, i) => sum + step * clamp(p - i, 0, 1), 0);
|
|
54
|
+
/** The progress at which the days have travelled `travel` rows (or pages). */
|
|
55
|
+
function progressAt(steps, travel) {
|
|
56
|
+
let p = 0;
|
|
57
|
+
for (const step of steps) {
|
|
58
|
+
const share = clamp(travel / step, 0, 1);
|
|
59
|
+
p += share;
|
|
60
|
+
travel -= step * share;
|
|
61
|
+
if (share < 1)
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
return p;
|
|
65
|
+
}
|
|
66
|
+
const detailOf = (choice, mode) => mode === 'single'
|
|
67
|
+
? { value: choice.value ? isoOf(choice.value) : '', start: '', end: '' }
|
|
68
|
+
: { value: '', start: choice.start ? isoOf(choice.start) : '', end: choice.end ? isoOf(choice.end) : '' };
|
|
69
|
+
/**
|
|
70
|
+
* The browser's frames, for a month's travel (CAL-14): the functions the page had when this module was evaluated. A
|
|
71
|
+
* travel is drawn frame by frame as a transition is, by the browser's own clock — so a page that later replaces its
|
|
72
|
+
* timers with a clock of its own (a test that stops time to count a scroll's 150 ms of silence) stops the timers it
|
|
73
|
+
* replaced, and not the drawing of a motion that is under way.
|
|
74
|
+
*/
|
|
75
|
+
const nextFrame = typeof requestAnimationFrame === 'function' ? requestAnimationFrame.bind(globalThis) : () => 0;
|
|
76
|
+
const dropFrame = typeof cancelAnimationFrame === 'function' ? cancelAnimationFrame.bind(globalThis) : () => undefined;
|
|
77
|
+
/**
|
|
78
|
+
* Shows one month as a grid of days, in the page or inside a picker, and lets a person choose one date or one range of
|
|
79
|
+
* dates from it.
|
|
80
|
+
*
|
|
81
|
+
* Contract: specs/calendar.spec.json. The calendar draws no surface and no padding of its own: it is seven cells wide
|
|
82
|
+
* (never wider than its container) and the page, or the picker that holds it, gives it its background. It commits each
|
|
83
|
+
* choice itself — it sets `value` (or `start` and `end`) and then fires `change` — and is not form-associated: the
|
|
84
|
+
* product's field is. Months move by the previous and next buttons, Page Up / Page Down, and along the axis the design
|
|
85
|
+
* system names (`comp.calendar.navigation.axis`, vertical by default) by a wheel or trackpad scroll and by a drag of a
|
|
86
|
+
* finger, a pen or the primary mouse button: the days follow either point for point — a scroll through month after
|
|
87
|
+
* month, a drag to the neighbouring month — and settle on the neighbour from a quarter of the way on. A wheel that
|
|
88
|
+
* reports lines or pages moves one month a step.
|
|
89
|
+
*
|
|
90
|
+
* Dates are ISO 8601 calendar dates ("2026-09-17") without a time or a time zone. Month and weekday names, digits and
|
|
91
|
+
* the first day of the week come from `Intl` for `locale` — without it, the nearest `lang` attribute, then the browser's
|
|
92
|
+
* language. Every visual value comes from `--tanrei-comp-calendar-*` tokens; the navigation buttons are
|
|
93
|
+
* `<tanrei-button variant="text">` elements that keep their own. `focus()` moves focus to the active day (or the
|
|
94
|
+
* displayed year in the year view).
|
|
95
|
+
*
|
|
96
|
+
* @tag tanrei-calendar
|
|
97
|
+
* @csspart navigation - The top row: the view toggle and the previous and next buttons.
|
|
98
|
+
* @csspart view-toggle - The month-and-year button that switches between the day view and the year view.
|
|
99
|
+
* @csspart grid - The day grid (role grid): the weekday row and six rows of days.
|
|
100
|
+
* @csspart day - A day (a gridcell); `data-date` holds its ISO date, `data-adjacent` marks a day of the neighbouring month.
|
|
101
|
+
* @csspart years - The year list of the year view.
|
|
102
|
+
* @csspart year - A year of the year view (a button, `data-year` holds it).
|
|
103
|
+
* @fires {CustomEvent<TanreiCalendarChangeDetail>} change - The person chose a day that changes the choice. `value`, `start` and `end` are already the new ones (end empty after a start alone); `detail` holds them too.
|
|
104
|
+
*/
|
|
105
|
+
export class TanreiCalendar extends LitElement {
|
|
106
|
+
constructor() {
|
|
107
|
+
super(...arguments);
|
|
108
|
+
this.availability = new AvailabilityController(this, 'calendar');
|
|
109
|
+
this.system = new SystemWatchController(this);
|
|
110
|
+
/** CAL-35: the product's words, read where the instance gives none (src/primitives/words.ts). */
|
|
111
|
+
this.words = new WordsController(this);
|
|
112
|
+
/** `single`: one date, in `value`. `range`: one contiguous span, from `start` to `end` inclusive. Reflected. */
|
|
113
|
+
this.mode = 'single';
|
|
114
|
+
/** The chosen date in single mode, as an ISO 8601 calendar date ("2026-09-17"); empty when none is chosen. */
|
|
115
|
+
this.value = '';
|
|
116
|
+
/** The first date of the chosen range in range mode; empty when none is chosen. */
|
|
117
|
+
this.start = '';
|
|
118
|
+
/** The last date of the chosen range in range mode, never before `start`; empty while only `start` is chosen. */
|
|
119
|
+
this.end = '';
|
|
120
|
+
/** The earliest date that can be chosen; empty for no limit. */
|
|
121
|
+
this.min = '';
|
|
122
|
+
/** The latest date that can be chosen; empty for no limit. */
|
|
123
|
+
this.max = '';
|
|
124
|
+
/** Dates inside min and max that cannot be chosen (booked, closed). The `disabled-dates` attribute is a space-separated list or a JSON array. */
|
|
125
|
+
this.disabledDates = [];
|
|
126
|
+
/** A rule no list can hold (every weekend): true for an ISO date that cannot be chosen. Read with `disabledDates`. Property only. */
|
|
127
|
+
this.isDateDisabled = null;
|
|
128
|
+
/** The date drawn as today; empty reads the device's current date in its own time zone (and again at midnight). */
|
|
129
|
+
this.today = '';
|
|
130
|
+
/** The weekday in the first column (`first-day-of-week`); `locale` takes it from the locale. */
|
|
131
|
+
this.firstDayOfWeek = 'locale';
|
|
132
|
+
/** A BCP 47 tag ("en-US", "ja-JP") for names, digits and the first day of the week; empty: the nearest `lang`, then the browser's. */
|
|
133
|
+
this.locale = '';
|
|
134
|
+
/** Whether the calendar first shows the days of a month or the list of years (`start-view`). */
|
|
135
|
+
this.startView = 'day';
|
|
136
|
+
/** Fills the spare cells with the neighbouring months' days, drawn quieter; they can be chosen (`show-adjacent-days`). */
|
|
137
|
+
this.showAdjacentDays = false;
|
|
138
|
+
/** The accessible name of the whole calendar ("Check-in date"); a picker that holds it names it itself. */
|
|
139
|
+
this.label = '';
|
|
140
|
+
/** Range mode: the description of the start day (`start-label`): this instance's words, else the product's (`setWords({ startLabel })`). Tanrei has none: without them the day has no description. */
|
|
141
|
+
this.startLabel = '';
|
|
142
|
+
/** Range mode: the description of the end day (`end-label`): this instance's words, else the product's (`setWords({ endLabel })`). Tanrei has none: without them the day has no description. */
|
|
143
|
+
this.endLabel = '';
|
|
144
|
+
/** The previous-month button's accessible name (`previous-month-label`): this instance's words, else the product's (`setWords({ previousMonthLabel })`). Tanrei has none: without them the button is drawn and works, and has no name. */
|
|
145
|
+
this.previousMonthLabel = '';
|
|
146
|
+
/** The next-month button's accessible name (`next-month-label`): this instance's words, else the product's (`setWords({ nextMonthLabel })`). Tanrei has none: without them the button is drawn and works, and has no name. */
|
|
147
|
+
this.nextMonthLabel = '';
|
|
148
|
+
/** The view toggle's description; its name is the month and year it shows (`year-view-label`): this instance's words, else the product's (`setWords({ yearViewLabel })`). Tanrei has none: without them the toggle has no description. */
|
|
149
|
+
this.yearViewLabel = '';
|
|
150
|
+
/** Read after the current year. Today's date is `aria-current="date"` on the web, so it is not added to a day (`today-label`): this instance's words, else the product's (`setWords({ todayLabel })`), else the locale's own word for the present day, from the browser. */
|
|
151
|
+
this.todayLabel = '';
|
|
152
|
+
/** The displayed month. */
|
|
153
|
+
this.month = monthOf(deviceToday());
|
|
154
|
+
this.view = 'day';
|
|
155
|
+
/** The day grid's one tab stop (CAL-10). */
|
|
156
|
+
this.active = deviceToday();
|
|
157
|
+
/** The year list's one tab stop (CAL-12). */
|
|
158
|
+
this.activeYear = deviceToday().year;
|
|
159
|
+
/** The polite announcement of a new month (CAL-13). */
|
|
160
|
+
this.announcement = '';
|
|
161
|
+
/** The device's date while `today` is empty, read again at midnight (CAL-24). */
|
|
162
|
+
this.deviceDate = deviceToday();
|
|
163
|
+
this.shown = false;
|
|
164
|
+
this.axis = 'vertical';
|
|
165
|
+
/**
|
|
166
|
+
* CAL-29: the views the grid holds, earliest first — the displayed month alone at rest; while a change plays or a drag
|
|
167
|
+
* lasts, also the months the days move between. The progress counts them: 0 at the first, 1 at the next.
|
|
168
|
+
*/
|
|
169
|
+
this.views = [];
|
|
170
|
+
/** The progress to write once the views are rendered: `jump` at once (where the days are now), then `to` over the page motion. */
|
|
171
|
+
this.step = null;
|
|
172
|
+
/**
|
|
173
|
+
* CAL-14, CAL-29: the progress on its way from one place to another over the page motion. The progress is a custom
|
|
174
|
+
* property that no one registers — a registered one makes every transition of the page dear —
|
|
175
|
+
* so it has no transition of its own: `clock` is an
|
|
176
|
+
* animation with no effect on the grid, running for the page motion's duration on its curve, and each frame writes
|
|
177
|
+
* the progress where the clock's eased time says it is. A moment of it and a drag held at that place are one look.
|
|
178
|
+
*/
|
|
179
|
+
this.travel = null;
|
|
180
|
+
/** CAL-30: the press that may become a drag, or the drag. */
|
|
181
|
+
this.drag = null;
|
|
182
|
+
/** Where focus goes after the next update, and whether it shows its ring (true after a key, false after a press). */
|
|
183
|
+
this.focusAfter = null;
|
|
184
|
+
this.scrollYearsAfter = false;
|
|
185
|
+
/**
|
|
186
|
+
* The year list holds its years: while the year view is shown, and until it has faded out after it (CAL-6's
|
|
187
|
+
* cross-fade). A calendar in its day view holds none of them — two hundred and one buttons, most of what a calendar
|
|
188
|
+
* would otherwise be made of, and a picker's date view is a calendar.
|
|
189
|
+
*/
|
|
190
|
+
this.yearsHeld = false;
|
|
191
|
+
/** The calendar set its own choice (CAL-17 is about a date the product sets). */
|
|
192
|
+
this.ownChoice = false;
|
|
193
|
+
this.midnight = 0;
|
|
194
|
+
/** CAL-33, CAL-34: the scroll in progress, if any. */
|
|
195
|
+
this.wheel = null;
|
|
196
|
+
/** CAL-30, CAL-31: the click a taken drag's release still produces chooses no day. */
|
|
197
|
+
this.swallowClick = false;
|
|
198
|
+
/** CAL-20, CAL-21: the press of a day, a year or the view toggle — whichever container `pressedBox` is. */
|
|
199
|
+
this.pressedBox = null;
|
|
200
|
+
this.press = new PressController(this, {
|
|
201
|
+
container: () => this.pressedBox,
|
|
202
|
+
holdCarrier: () => this.renderRoot?.querySelector('.hold') ?? null,
|
|
203
|
+
disabled: () => !!this.pressedBox?.closest('[aria-disabled="true"]'),
|
|
204
|
+
});
|
|
205
|
+
/** CAL-6: the view toggle switches between the day view and the year view. */
|
|
206
|
+
this.onToggleView = () => {
|
|
207
|
+
if (this.view === 'day') {
|
|
208
|
+
// CAL-32: the year view shown while a drag lasts or a scroll is followed cancels it.
|
|
209
|
+
this.cancelDrag();
|
|
210
|
+
this.cancelScroll();
|
|
211
|
+
this.view = 'year';
|
|
212
|
+
this.yearsHeld = true;
|
|
213
|
+
this.activeYear = this.month.year;
|
|
214
|
+
this.scrollYearsAfter = true;
|
|
215
|
+
}
|
|
216
|
+
else
|
|
217
|
+
this.view = 'day';
|
|
218
|
+
};
|
|
219
|
+
// ── Following a scroll (CAL-33, CAL-34) ───────────────────────────────────────────────────────────────────────────
|
|
220
|
+
/**
|
|
221
|
+
* CAL-33: a wheel or trackpad scroll along the axis is the calendar's — also where the days can move no further — and
|
|
222
|
+
* one across it, or one that zooms, is left to the scrolling ancestor. A scroll reported as a distance is followed; one
|
|
223
|
+
* reported in lines or pages is a detented wheel's step, and moves one month as a button does.
|
|
224
|
+
*/
|
|
225
|
+
this.onWheel = (event) => {
|
|
226
|
+
if (this.view !== 'day' || event.ctrlKey)
|
|
227
|
+
return;
|
|
228
|
+
const vertical = this.readAxis() === 'vertical';
|
|
229
|
+
const along = vertical ? event.deltaY : event.deltaX * (this.rtl ? -1 : 1);
|
|
230
|
+
const across = vertical ? event.deltaX : event.deltaY;
|
|
231
|
+
if (along === 0 || Math.abs(across) > Math.abs(along))
|
|
232
|
+
return;
|
|
233
|
+
event.preventDefault();
|
|
234
|
+
// The pointer holds the days while a drag lasts.
|
|
235
|
+
if (this.drag?.taken)
|
|
236
|
+
return;
|
|
237
|
+
if (event.deltaMode !== 0)
|
|
238
|
+
this.pageBy(along > 0 ? 1 : -1);
|
|
239
|
+
else
|
|
240
|
+
this.followScroll(along, event.timeStamp);
|
|
241
|
+
};
|
|
242
|
+
/** CAL-34: no event for `SCROLL_QUIET` ms — the scroll is over; days it still holds settle. */
|
|
243
|
+
this.onScrollQuiet = () => {
|
|
244
|
+
if (this.wheel?.following)
|
|
245
|
+
this.settleScroll();
|
|
246
|
+
this.wheel = null;
|
|
247
|
+
};
|
|
248
|
+
// ── Following a drag (CAL-30 … CAL-32) ────────────────────────────────────────────────────────────────────────────
|
|
249
|
+
/** CAL-30: a press of touch, a pen or the primary button of a mouse on the day grid may become a drag; another mouse button takes none. */
|
|
250
|
+
this.onDragDown = (event) => {
|
|
251
|
+
if ((event.pointerType === 'mouse' && event.button !== 0) || this.view !== 'day' || this.drag)
|
|
252
|
+
return;
|
|
253
|
+
const gesture = new SheetDrag(event, this.readAxis() === 'vertical' ? 'y' : 'x');
|
|
254
|
+
this.drag = { gesture, taken: false, from: 0, unit: 1, home: 0, low: 0, high: 0, at: 0 };
|
|
255
|
+
};
|
|
256
|
+
this.onDragMove = (event) => {
|
|
257
|
+
const drag = this.drag;
|
|
258
|
+
if (!drag || event.pointerId !== drag.gesture.id)
|
|
259
|
+
return;
|
|
260
|
+
const moved = drag.gesture.move(event);
|
|
261
|
+
if (moved === 'start')
|
|
262
|
+
this.takeDrag(event);
|
|
263
|
+
if (drag.taken)
|
|
264
|
+
this.followDrag(event);
|
|
265
|
+
};
|
|
266
|
+
/**
|
|
267
|
+
* CAL-31: the release chooses the displayed month or the neighbour the days have moved toward — the neighbour from a
|
|
268
|
+
* quarter of the way on (as the end of a scroll does, CAL-34), or the one a fling is toward — shows it as any month change (CAL-13) and lets the
|
|
269
|
+
* days travel there from where they are; a release on the displayed month returns them and announces nothing.
|
|
270
|
+
*/
|
|
271
|
+
this.onDragUp = (event) => {
|
|
272
|
+
const drag = this.drag;
|
|
273
|
+
if (!drag || event.pointerId !== drag.gesture.id)
|
|
274
|
+
return;
|
|
275
|
+
if (!drag.taken) {
|
|
276
|
+
this.drag = null;
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
this.followDrag(event);
|
|
280
|
+
const toward = this.axis === 'vertical' || !this.rtl ? -1 : 1;
|
|
281
|
+
const velocity = toward * drag.gesture.velocity(event);
|
|
282
|
+
const side = Math.sign(drag.at - drag.home);
|
|
283
|
+
const fling = Math.abs(velocity) >= SHEET_FLING_VELOCITY;
|
|
284
|
+
const chosen = side !== 0 && (fling ? Math.sign(velocity) === side : Math.abs(drag.at - drag.home) >= SETTLE_SHARE - EPSILON) ? drag.home + side : drag.home;
|
|
285
|
+
this.endDrag(clamp(chosen, 0, this.views.length - 1));
|
|
286
|
+
};
|
|
287
|
+
/** CAL-32: the platform cancels the pointer (a system gesture, a lost capture): the days return. */
|
|
288
|
+
this.onDragCancel = (event) => {
|
|
289
|
+
if (this.drag && event.pointerId === this.drag.gesture.id)
|
|
290
|
+
this.cancelDrag();
|
|
291
|
+
};
|
|
292
|
+
/** CAL-32: Escape while a drag lasts cancels it, and is spent on it: nothing behind the calendar hears it. */
|
|
293
|
+
this.onDragKeyDown = (event) => {
|
|
294
|
+
if (event.key !== 'Escape' || !this.drag?.taken)
|
|
295
|
+
return;
|
|
296
|
+
event.preventDefault();
|
|
297
|
+
event.stopPropagation();
|
|
298
|
+
this.cancelDrag();
|
|
299
|
+
};
|
|
300
|
+
this.onGridKeyDown = (event) => {
|
|
301
|
+
const cell = this.dayOf(event);
|
|
302
|
+
if (!cell || event.altKey || event.ctrlKey || event.metaKey)
|
|
303
|
+
return;
|
|
304
|
+
const day = parseIsoDate(cell.dataset.date);
|
|
305
|
+
const forward = this.rtl ? -1 : 1;
|
|
306
|
+
const column = (weekdayOf(day) - this.cfg.firstDay + 7) % 7;
|
|
307
|
+
let to = null;
|
|
308
|
+
switch (event.key) {
|
|
309
|
+
case 'ArrowRight':
|
|
310
|
+
to = addDays(day, forward);
|
|
311
|
+
break;
|
|
312
|
+
case 'ArrowLeft':
|
|
313
|
+
to = addDays(day, -forward);
|
|
314
|
+
break;
|
|
315
|
+
case 'ArrowDown':
|
|
316
|
+
to = addDays(day, 7);
|
|
317
|
+
break;
|
|
318
|
+
case 'ArrowUp':
|
|
319
|
+
to = addDays(day, -7);
|
|
320
|
+
break;
|
|
321
|
+
case 'Home':
|
|
322
|
+
to = addDays(day, -column);
|
|
323
|
+
break;
|
|
324
|
+
case 'End':
|
|
325
|
+
to = addDays(day, 6 - column);
|
|
326
|
+
break;
|
|
327
|
+
case 'PageDown':
|
|
328
|
+
to = addMonths(day, event.shiftKey ? 12 : 1);
|
|
329
|
+
break;
|
|
330
|
+
case 'PageUp':
|
|
331
|
+
to = addMonths(day, event.shiftKey ? -12 : -1);
|
|
332
|
+
break;
|
|
333
|
+
case 'Enter':
|
|
334
|
+
case ' ':
|
|
335
|
+
event.preventDefault();
|
|
336
|
+
if (event.repeat)
|
|
337
|
+
return;
|
|
338
|
+
this.pressedBox = this.containerOf(cell);
|
|
339
|
+
this.press.press(null);
|
|
340
|
+
this.choose(day);
|
|
341
|
+
return;
|
|
342
|
+
default:
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
event.preventDefault();
|
|
346
|
+
this.moveActive(to);
|
|
347
|
+
};
|
|
348
|
+
this.onGridKeyUp = (event) => {
|
|
349
|
+
if (event.key === 'Enter' || event.key === ' ')
|
|
350
|
+
this.press.release();
|
|
351
|
+
};
|
|
352
|
+
this.onGridPointerDown = (event) => {
|
|
353
|
+
this.swallowClick = false;
|
|
354
|
+
this.onDragDown(event);
|
|
355
|
+
const cell = this.dayOf(event);
|
|
356
|
+
if (!cell)
|
|
357
|
+
return;
|
|
358
|
+
this.pressedBox = this.containerOf(cell);
|
|
359
|
+
this.press.onPointerDown(event);
|
|
360
|
+
};
|
|
361
|
+
this.onGridPointerUp = (event) => {
|
|
362
|
+
this.onDragUp(event);
|
|
363
|
+
this.press.release();
|
|
364
|
+
};
|
|
365
|
+
/** CAL-15: a press on a neighbouring month's day moves no focus by itself: the day takes it once its month is shown, if focus was in the grid. */
|
|
366
|
+
this.onGridMouseDown = (event) => {
|
|
367
|
+
if (this.dayOf(event)?.dataset.adjacent !== undefined)
|
|
368
|
+
event.preventDefault();
|
|
369
|
+
};
|
|
370
|
+
this.onGridClick = (event) => {
|
|
371
|
+
if (this.swallowClick) {
|
|
372
|
+
this.swallowClick = false;
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
const cell = this.dayOf(event);
|
|
376
|
+
if (!cell)
|
|
377
|
+
return;
|
|
378
|
+
const day = parseIsoDate(cell.dataset.date);
|
|
379
|
+
if (inMonth(day, this.month)) {
|
|
380
|
+
this.active = day;
|
|
381
|
+
this.choose(day);
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
// CAL-15: an available day of a neighbouring month is chosen as any day — change first — and then its month is
|
|
385
|
+
// shown (CAL-13, with the motion of CAL-14), where it is the active day and takes focus if focus was in the grid.
|
|
386
|
+
if (this.cfg.unavailable(day))
|
|
387
|
+
return;
|
|
388
|
+
const focused = this.renderRoot.activeElement;
|
|
389
|
+
this.choose(day);
|
|
390
|
+
this.showMonth(monthOf(day));
|
|
391
|
+
this.active = day;
|
|
392
|
+
if (focused instanceof HTMLElement && focused.classList.contains('day')) {
|
|
393
|
+
this.focusAfter = 'day';
|
|
394
|
+
this.ringAfter = false;
|
|
395
|
+
}
|
|
396
|
+
this.announce();
|
|
397
|
+
};
|
|
398
|
+
this.onCellFocus = (event) => {
|
|
399
|
+
const cell = event.target;
|
|
400
|
+
if (cell.classList?.contains('cell'))
|
|
401
|
+
syncFocusStyle(this, cell);
|
|
402
|
+
};
|
|
403
|
+
this.onYearsKeyDown = (event) => {
|
|
404
|
+
const button = this.yearOf(event);
|
|
405
|
+
if (!button || event.altKey || event.ctrlKey || event.metaKey)
|
|
406
|
+
return;
|
|
407
|
+
const year = Number(button.dataset.year);
|
|
408
|
+
const [first, last] = this.years;
|
|
409
|
+
const forward = this.rtl ? -1 : 1;
|
|
410
|
+
const moves = { ArrowRight: year + forward, ArrowLeft: year - forward, ArrowDown: year + 3, ArrowUp: year - 3, Home: first, End: last };
|
|
411
|
+
if (event.key in moves) {
|
|
412
|
+
event.preventDefault();
|
|
413
|
+
this.activeYear = Math.min(last, Math.max(first, moves[event.key]));
|
|
414
|
+
this.focusAfter = 'year';
|
|
415
|
+
this.ringAfter = true;
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
418
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
419
|
+
this.pressedBox = button.querySelector('.box');
|
|
420
|
+
this.press.onKeyDown(event);
|
|
421
|
+
}
|
|
422
|
+
};
|
|
423
|
+
this.onYearsPointerDown = (event) => {
|
|
424
|
+
const button = this.yearOf(event);
|
|
425
|
+
if (!button)
|
|
426
|
+
return;
|
|
427
|
+
this.pressedBox = button.querySelector('.box');
|
|
428
|
+
this.press.onPointerDown(event);
|
|
429
|
+
};
|
|
430
|
+
this.onYearsClick = (event) => {
|
|
431
|
+
const button = this.yearOf(event);
|
|
432
|
+
if (button)
|
|
433
|
+
this.chooseYear(Number(button.dataset.year), event.detail === 0);
|
|
434
|
+
};
|
|
435
|
+
/** The year list has faded out (its `visibility` is the last to change): the day view holds no year. */
|
|
436
|
+
this.onYearsFaded = (event) => {
|
|
437
|
+
if (event.target !== event.currentTarget || event.propertyName !== 'visibility')
|
|
438
|
+
return;
|
|
439
|
+
this.releaseYears();
|
|
440
|
+
};
|
|
441
|
+
// ── The view toggle's press (CAL-6, CAL-20) ───────────────────────────────────────────────────────────────────────
|
|
442
|
+
this.onTogglePointerDown = (event) => {
|
|
443
|
+
this.pressedBox = event.currentTarget.querySelector('.box');
|
|
444
|
+
this.press.onPointerDown(event);
|
|
445
|
+
};
|
|
446
|
+
this.onToggleKeyDown = (event) => {
|
|
447
|
+
this.pressedBox = event.currentTarget.querySelector('.box');
|
|
448
|
+
this.press.onKeyDown(event);
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
static { this.styles = styles; }
|
|
452
|
+
static { this.properties = {
|
|
453
|
+
mode: { type: String, reflect: true },
|
|
454
|
+
value: { type: String },
|
|
455
|
+
start: { type: String },
|
|
456
|
+
end: { type: String },
|
|
457
|
+
min: { type: String },
|
|
458
|
+
max: { type: String },
|
|
459
|
+
disabledDates: { attribute: 'disabled-dates', converter: { fromAttribute: parseValues, toAttribute: (value) => value.join(' ') } },
|
|
460
|
+
isDateDisabled: { attribute: false },
|
|
461
|
+
today: { type: String },
|
|
462
|
+
firstDayOfWeek: { type: String, attribute: 'first-day-of-week' },
|
|
463
|
+
locale: { type: String },
|
|
464
|
+
startView: { type: String, attribute: 'start-view' },
|
|
465
|
+
showAdjacentDays: { type: Boolean, attribute: 'show-adjacent-days' },
|
|
466
|
+
label: { type: String },
|
|
467
|
+
startLabel: { type: String, attribute: 'start-label' },
|
|
468
|
+
endLabel: { type: String, attribute: 'end-label' },
|
|
469
|
+
previousMonthLabel: { type: String, attribute: 'previous-month-label' },
|
|
470
|
+
nextMonthLabel: { type: String, attribute: 'next-month-label' },
|
|
471
|
+
yearViewLabel: { type: String, attribute: 'year-view-label' },
|
|
472
|
+
todayLabel: { type: String, attribute: 'today-label' },
|
|
473
|
+
month: { state: true },
|
|
474
|
+
view: { state: true },
|
|
475
|
+
active: { state: true },
|
|
476
|
+
activeYear: { state: true },
|
|
477
|
+
announcement: { state: true },
|
|
478
|
+
deviceDate: { state: true },
|
|
479
|
+
}; }
|
|
480
|
+
connectedCallback() {
|
|
481
|
+
super.connectedCallback();
|
|
482
|
+
this.scheduleMidnight();
|
|
483
|
+
}
|
|
484
|
+
disconnectedCallback() {
|
|
485
|
+
super.disconnectedCallback();
|
|
486
|
+
clearTimeout(this.midnight);
|
|
487
|
+
// A scroll, a drag or a change in progress has nothing left to move: the days are at the displayed month's view.
|
|
488
|
+
this.forgetScroll();
|
|
489
|
+
this.dropDrag();
|
|
490
|
+
this.endTravel();
|
|
491
|
+
if (this.views.length > 1)
|
|
492
|
+
this.rest();
|
|
493
|
+
else
|
|
494
|
+
this.pages?.removeAttribute('data-held');
|
|
495
|
+
}
|
|
496
|
+
/** CAL-24: while `today` is empty, the device's date is read again when it changes (at the next local midnight). */
|
|
497
|
+
scheduleMidnight() {
|
|
498
|
+
clearTimeout(this.midnight);
|
|
499
|
+
this.midnight = window.setTimeout(() => {
|
|
500
|
+
this.deviceDate = deviceToday();
|
|
501
|
+
this.scheduleMidnight();
|
|
502
|
+
}, untilMidnight());
|
|
503
|
+
}
|
|
504
|
+
/** Moves focus to the active day, or to the displayed year in the year view (CAL-10, CAL-12). */
|
|
505
|
+
focus(options) {
|
|
506
|
+
const target = this.view === 'year'
|
|
507
|
+
? this.renderRoot?.querySelector(`.year[data-year="${this.activeYear}"]`)
|
|
508
|
+
: this.renderRoot?.querySelector(`.page.current .day[data-date="${isoOf(this.active)}"]`);
|
|
509
|
+
if (!target)
|
|
510
|
+
return super.focus(options);
|
|
511
|
+
// Focused already (a dialog's focusing steps): focused again, so that whether its ring shows is the options' call.
|
|
512
|
+
if (options && 'focusVisible' in options && this.renderRoot.activeElement === target)
|
|
513
|
+
target.blur();
|
|
514
|
+
target.focus(options);
|
|
515
|
+
}
|
|
516
|
+
// ── Reading the props (CAL-24, CAL-27) ────────────────────────────────────────────────────────────────────────────
|
|
517
|
+
closed(values, value, fallback, name) {
|
|
518
|
+
if (values.includes(value))
|
|
519
|
+
return value;
|
|
520
|
+
report(this, 'CAL-27', `${name} "${value}" is not a value the calendar defines; it behaves as "${fallback}"`);
|
|
521
|
+
return fallback;
|
|
522
|
+
}
|
|
523
|
+
/** CAL-24: `locale`, else the nearest `lang` (through shadow roots), else the browser's language; English when `Intl` does not know it. */
|
|
524
|
+
resolveLocale() {
|
|
525
|
+
const tag = this.locale.trim();
|
|
526
|
+
if (!tag)
|
|
527
|
+
return ambientLocale(this);
|
|
528
|
+
const known = supportedLocale(tag);
|
|
529
|
+
if (!known)
|
|
530
|
+
report(this, 'CAL-24', `locale "${tag}" is not a BCP 47 tag this browser knows; it uses "${FALLBACK_LOCALE}"`);
|
|
531
|
+
return known ?? FALLBACK_LOCALE;
|
|
532
|
+
}
|
|
533
|
+
readConfig() {
|
|
534
|
+
const mode = this.closed(MODES, this.mode, 'single', 'mode');
|
|
535
|
+
const startView = this.closed(START_VIEWS, this.startView, 'day', 'startView');
|
|
536
|
+
const firstDayOfWeek = this.closed(FIRST_DAYS, this.firstDayOfWeek, 'locale', 'firstDayOfWeek');
|
|
537
|
+
const locale = this.resolveLocale();
|
|
538
|
+
const firstDay = firstDayOfWeek === 'locale' ? localeFirstDay(locale) : WEEKDAY_NAMES.indexOf(firstDayOfWeek);
|
|
539
|
+
const date = (name, text) => {
|
|
540
|
+
if (!text)
|
|
541
|
+
return null;
|
|
542
|
+
const parsed = parseIsoDate(text);
|
|
543
|
+
if (!parsed)
|
|
544
|
+
report(this, 'CAL-27', `${name} "${text}" is not an ISO 8601 calendar date (YYYY-MM-DD); it is ignored`);
|
|
545
|
+
return parsed;
|
|
546
|
+
};
|
|
547
|
+
let min = date('min', this.min);
|
|
548
|
+
let max = date('max', this.max);
|
|
549
|
+
if (min && max && compareDates(min, max) > 0) {
|
|
550
|
+
report(this, 'CAL-27', `min "${this.min}" is after max "${this.max}"; both are ignored`);
|
|
551
|
+
min = null;
|
|
552
|
+
max = null;
|
|
553
|
+
}
|
|
554
|
+
let value = date('value', this.value);
|
|
555
|
+
let start = date('start', this.start);
|
|
556
|
+
let end = date('end', this.end);
|
|
557
|
+
if (mode === 'range' && value) {
|
|
558
|
+
report(this, 'CAL-27', `value "${this.value}" is set in range mode, where the choice is start and end; it is ignored`);
|
|
559
|
+
value = null;
|
|
560
|
+
}
|
|
561
|
+
if (mode === 'single' && (start || end)) {
|
|
562
|
+
report(this, 'CAL-27', 'start or end is set in single mode, where the choice is value; they are ignored');
|
|
563
|
+
start = null;
|
|
564
|
+
end = null;
|
|
565
|
+
}
|
|
566
|
+
if (start && end && compareDates(end, start) < 0) {
|
|
567
|
+
report(this, 'CAL-27', `end "${this.end}" is before start "${this.start}"; the end is ignored`);
|
|
568
|
+
end = null;
|
|
569
|
+
}
|
|
570
|
+
if (end && !start) {
|
|
571
|
+
report(this, 'CAL-27', `end "${this.end}" is set without a start; it is ignored`);
|
|
572
|
+
end = null;
|
|
573
|
+
}
|
|
574
|
+
const disabled = new Set();
|
|
575
|
+
for (const entry of this.disabledDates ?? []) {
|
|
576
|
+
const parsed = date('an entry of disabledDates', entry);
|
|
577
|
+
if (parsed)
|
|
578
|
+
disabled.add(isoOf(parsed));
|
|
579
|
+
}
|
|
580
|
+
const predicate = this.isDateDisabled;
|
|
581
|
+
const unavailable = (day) => (min !== null && compareDates(day, min) < 0) || (max !== null && compareDates(day, max) > 0) || disabled.has(isoOf(day)) || (typeof predicate === 'function' && !!predicate(isoOf(day)));
|
|
582
|
+
const today = date('today', this.today) ?? this.deviceDate;
|
|
583
|
+
return { mode, startView, firstDay, locale, min, max, today, choice: { value, start, end }, unavailable };
|
|
584
|
+
}
|
|
585
|
+
/** CAL-17: the month of value or start, otherwise of today, between min's and max's months. */
|
|
586
|
+
homeMonth() {
|
|
587
|
+
const { today, min, max, choice } = this.cfg;
|
|
588
|
+
return clampMonth(monthOf(choice.value ?? choice.start ?? today), min, max);
|
|
589
|
+
}
|
|
590
|
+
/** CAL-10: the chosen date (start) in the month, otherwise today there, otherwise its first available day, otherwise its first. */
|
|
591
|
+
activeDayOf(month) {
|
|
592
|
+
const { choice, today, unavailable } = this.cfg;
|
|
593
|
+
const chosen = choice.value ?? choice.start;
|
|
594
|
+
if (inMonth(chosen, month))
|
|
595
|
+
return chosen;
|
|
596
|
+
if (inMonth(today, month))
|
|
597
|
+
return today;
|
|
598
|
+
const days = Array.from({ length: daysInMonth(month.year, month.month) }, (_, i) => ({ ...month, day: i + 1 }));
|
|
599
|
+
return days.find((day) => !unavailable(day)) ?? days[0];
|
|
600
|
+
}
|
|
601
|
+
/** CAL-2: the condition a day is drawn from, by precedence. */
|
|
602
|
+
dayCondition(day) {
|
|
603
|
+
const { value, start, end } = this.cfg.choice;
|
|
604
|
+
if (sameDate(day.date, value) || sameDate(day.date, start) || sameDate(day.date, end))
|
|
605
|
+
return 'selected';
|
|
606
|
+
if (start && end && compareDates(day.date, start) > 0 && compareDates(day.date, end) < 0)
|
|
607
|
+
return 'in-range';
|
|
608
|
+
if (sameDate(day.date, this.cfg.today))
|
|
609
|
+
return 'today';
|
|
610
|
+
if (day.adjacent)
|
|
611
|
+
return 'adjacent';
|
|
612
|
+
return 'unselected';
|
|
613
|
+
}
|
|
614
|
+
get rtl() {
|
|
615
|
+
return this.matches(':dir(rtl)');
|
|
616
|
+
}
|
|
617
|
+
get reducedMotion() {
|
|
618
|
+
return typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
619
|
+
}
|
|
620
|
+
/** The axis the months move along, read from the cascade now (never cached). */
|
|
621
|
+
readAxis() {
|
|
622
|
+
this.axis = compChoice(this, AXIS, AXES);
|
|
623
|
+
return this.axis;
|
|
624
|
+
}
|
|
625
|
+
// ── Choosing (CAL-8, CAL-9, CAL-15, CAL-16) ───────────────────────────────────────────────────────────────────────
|
|
626
|
+
choose(day) {
|
|
627
|
+
const { mode, unavailable, choice } = this.cfg;
|
|
628
|
+
if (unavailable(day))
|
|
629
|
+
return;
|
|
630
|
+
let next;
|
|
631
|
+
if (mode === 'single') {
|
|
632
|
+
if (sameDate(day, choice.value))
|
|
633
|
+
return;
|
|
634
|
+
next = { value: day, start: null, end: null };
|
|
635
|
+
}
|
|
636
|
+
else {
|
|
637
|
+
const { start, end } = choice;
|
|
638
|
+
next = !start || end || compareDates(day, start) < 0 ? { value: null, start: day, end: null } : { value: null, start, end: day };
|
|
639
|
+
}
|
|
640
|
+
const detail = detailOf(next, mode);
|
|
641
|
+
this.ownChoice = true;
|
|
642
|
+
if (mode === 'single')
|
|
643
|
+
this.value = detail.value;
|
|
644
|
+
else {
|
|
645
|
+
this.start = detail.start;
|
|
646
|
+
this.end = detail.end;
|
|
647
|
+
}
|
|
648
|
+
this.cfg = { ...this.cfg, choice: next };
|
|
649
|
+
this.dispatchEvent(new CustomEvent('change', { bubbles: true, detail }));
|
|
650
|
+
}
|
|
651
|
+
// ── The month and the views (CAL-5 … CAL-7, CAL-13, CAL-14, CAL-17) ──────────────────────────────────────────────
|
|
652
|
+
get pages() {
|
|
653
|
+
return this.renderRoot?.querySelector('.pages') ?? null;
|
|
654
|
+
}
|
|
655
|
+
/** CAL-29: how far apart two consecutive views are — the rows between their first rows (four or five) for neighbouring months, six otherwise; one page on the horizontal axis. */
|
|
656
|
+
stepsOf(views, axis = this.axis) {
|
|
657
|
+
const { firstDay } = this.cfg;
|
|
658
|
+
return views.slice(1).map((view, i) => {
|
|
659
|
+
if (axis === 'horizontal')
|
|
660
|
+
return 1;
|
|
661
|
+
if (!sameMonth(addMonthsTo(views[i], 1), view))
|
|
662
|
+
return VIEW_ROWS;
|
|
663
|
+
const next = firstRowOf(view, firstDay);
|
|
664
|
+
let rows = 0;
|
|
665
|
+
for (let row = firstRowOf(views[i], firstDay); compareDates(row, next) < 0; row = addDays(row, 7))
|
|
666
|
+
rows += 1;
|
|
667
|
+
return rows;
|
|
668
|
+
});
|
|
669
|
+
}
|
|
670
|
+
/** CAL-29: the column of week rows the views hold, in order: a row two views share is there once. */
|
|
671
|
+
weekRows(views) {
|
|
672
|
+
const { firstDay } = this.cfg;
|
|
673
|
+
const rows = [];
|
|
674
|
+
const byStart = new Map();
|
|
675
|
+
views.forEach((view, index) => {
|
|
676
|
+
const first = firstRowOf(view, firstDay);
|
|
677
|
+
for (let n = 0; n < VIEW_ROWS; n += 1) {
|
|
678
|
+
const start = addDays(first, 7 * n);
|
|
679
|
+
let row = byStart.get(isoOf(start));
|
|
680
|
+
if (!row) {
|
|
681
|
+
row = { start, held: views.map(() => false) };
|
|
682
|
+
byStart.set(isoOf(start), row);
|
|
683
|
+
rows.push(row);
|
|
684
|
+
}
|
|
685
|
+
row.held[index] = true;
|
|
686
|
+
}
|
|
687
|
+
});
|
|
688
|
+
return rows;
|
|
689
|
+
}
|
|
690
|
+
/** Where the days are now, as the progress drawn (a moment of a travel included). */
|
|
691
|
+
progressNow() {
|
|
692
|
+
if (this.travel)
|
|
693
|
+
return this.travelAt(this.travel);
|
|
694
|
+
const pages = this.pages;
|
|
695
|
+
return pages ? Number(getComputedStyle(pages).getPropertyValue(PROGRESS)) || 0 : 0;
|
|
696
|
+
}
|
|
697
|
+
/** The page motion, as the day view carries it — it cross-fades over it (CAL-14): its duration in ms and its curve. */
|
|
698
|
+
get pageMotion() {
|
|
699
|
+
const carrier = this.renderRoot?.querySelector('.day-view');
|
|
700
|
+
if (!carrier)
|
|
701
|
+
return { duration: 0, easing: 'linear' };
|
|
702
|
+
const style = getComputedStyle(carrier);
|
|
703
|
+
// The first of the list (`opacity`); a curve holds commas of its own.
|
|
704
|
+
const easing = /^(?:[^,(]|\((?:[^()]|\([^()]*\))*\))+/.exec(style.transitionTimingFunction)?.[0].trim() || 'linear';
|
|
705
|
+
return { duration: (Number.parseFloat(style.transitionDuration) || 0) * 1000, easing };
|
|
706
|
+
}
|
|
707
|
+
/** Whether a month change can play: not where motion is reduced, the page motion is none, or the browser has no animation to keep its time. */
|
|
708
|
+
get canTravel() {
|
|
709
|
+
const pages = this.pages;
|
|
710
|
+
if (!pages || this.reducedMotion || typeof pages.animate !== 'function')
|
|
711
|
+
return false;
|
|
712
|
+
return this.pageMotion.duration > 0;
|
|
713
|
+
}
|
|
714
|
+
/** Whether the progress is on its way somewhere. */
|
|
715
|
+
get travelling() {
|
|
716
|
+
return !!this.travel;
|
|
717
|
+
}
|
|
718
|
+
/** Where a travel's clock says the progress is: its eased time, between where it began and where it goes. */
|
|
719
|
+
travelAt(travel) {
|
|
720
|
+
const eased = travel.clock.playState === 'finished' ? 1 : (travel.clock.effect?.getComputedTiming().progress ?? 1);
|
|
721
|
+
return travel.from + (travel.to - travel.from) * eased;
|
|
722
|
+
}
|
|
723
|
+
/** CAL-14, CAL-29: sends the progress from `from` to `to` over the page motion, written in each frame; at once where no change can play. */
|
|
724
|
+
beginTravel(from, to) {
|
|
725
|
+
const pages = this.pages;
|
|
726
|
+
this.endTravel();
|
|
727
|
+
if (!pages)
|
|
728
|
+
return;
|
|
729
|
+
if (from === to || !this.canTravel) {
|
|
730
|
+
pages.style.setProperty(PROGRESS, String(to));
|
|
731
|
+
return;
|
|
732
|
+
}
|
|
733
|
+
const clock = pages.animate(null, this.pageMotion);
|
|
734
|
+
// The name tells the clock from any other animation of the grid.
|
|
735
|
+
clock.id = PROGRESS;
|
|
736
|
+
const travel = { clock, from, to, frame: 0 };
|
|
737
|
+
const frame = () => {
|
|
738
|
+
if (this.travel !== travel)
|
|
739
|
+
return;
|
|
740
|
+
if (clock.playState === 'finished') {
|
|
741
|
+
pages.style.setProperty(PROGRESS, String(to));
|
|
742
|
+
this.endTravel();
|
|
743
|
+
this.onTravelEnd();
|
|
744
|
+
return;
|
|
745
|
+
}
|
|
746
|
+
pages.style.setProperty(PROGRESS, String(this.travelAt(travel)));
|
|
747
|
+
travel.frame = nextFrame(frame);
|
|
748
|
+
};
|
|
749
|
+
this.travel = travel;
|
|
750
|
+
pages.style.setProperty(PROGRESS, String(from));
|
|
751
|
+
travel.frame = nextFrame(frame);
|
|
752
|
+
}
|
|
753
|
+
/** Stops a travel where it is: whoever stops it writes the progress next. */
|
|
754
|
+
endTravel() {
|
|
755
|
+
const travel = this.travel;
|
|
756
|
+
if (!travel)
|
|
757
|
+
return;
|
|
758
|
+
this.travel = null;
|
|
759
|
+
dropFrame(travel.frame);
|
|
760
|
+
travel.clock.cancel();
|
|
761
|
+
}
|
|
762
|
+
/** CAL-29: the grid keeps its six rows' height while it holds more (the rows of a month's view are equally tall). */
|
|
763
|
+
pin() {
|
|
764
|
+
const pages = this.pages;
|
|
765
|
+
if (pages && !pages.style.blockSize)
|
|
766
|
+
pages.style.blockSize = `${pages.getBoundingClientRect().height}px`;
|
|
767
|
+
}
|
|
768
|
+
/** The days are at the displayed month's view, and the grid holds that view alone. */
|
|
769
|
+
rest() {
|
|
770
|
+
this.views = [this.month];
|
|
771
|
+
this.step = { jump: 0, to: 0 };
|
|
772
|
+
this.requestUpdate();
|
|
773
|
+
}
|
|
774
|
+
/**
|
|
775
|
+
* CAL-14, CAL-29: shows `month`. With the motion, the days travel there from where they are now — the views on screen
|
|
776
|
+
* stay, the new month's joins them, and the progress goes to it over the page motion — so a change that begins while
|
|
777
|
+
* another plays carries on without a jump. Without it (CAL-7, CAL-17, reduced motion) the month is shown at once.
|
|
778
|
+
*/
|
|
779
|
+
showMonth(month, { motion = true } = {}) {
|
|
780
|
+
// CAL-14: a scroll being followed ends here, and the change carries on from where it left the days.
|
|
781
|
+
this.dropScroll();
|
|
782
|
+
const moving = this.views.length > 1;
|
|
783
|
+
if (sameMonth(month, this.month) && !moving)
|
|
784
|
+
return;
|
|
785
|
+
if (!motion || this.view !== 'day' || !this.shown || !this.canTravel) {
|
|
786
|
+
this.month = month;
|
|
787
|
+
this.rest();
|
|
788
|
+
return;
|
|
789
|
+
}
|
|
790
|
+
this.readAxis();
|
|
791
|
+
// Where the days are, among the views they are between.
|
|
792
|
+
let at = moving ? this.progressNow() : 0;
|
|
793
|
+
let views = moving ? this.views : [this.month];
|
|
794
|
+
const low = clamp(Math.floor(at), 0, views.length - 1);
|
|
795
|
+
const high = clamp(Math.ceil(at), low, views.length - 1);
|
|
796
|
+
views = views.slice(low, high + 1);
|
|
797
|
+
at -= low;
|
|
798
|
+
let to = views.findIndex((view) => sameMonth(view, month));
|
|
799
|
+
if (to < 0) {
|
|
800
|
+
if (compareMonths(month, views[0]) < 0) {
|
|
801
|
+
views = [month, ...views];
|
|
802
|
+
at += 1;
|
|
803
|
+
to = 0;
|
|
804
|
+
}
|
|
805
|
+
else if (compareMonths(month, views[views.length - 1]) > 0) {
|
|
806
|
+
views = [...views, month];
|
|
807
|
+
to = views.length - 1;
|
|
808
|
+
}
|
|
809
|
+
else {
|
|
810
|
+
// Between two views that are not neighbours (a month step during a year's): the later one gives way.
|
|
811
|
+
views = [views[0], month];
|
|
812
|
+
to = 1;
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
this.pin();
|
|
816
|
+
this.views = views;
|
|
817
|
+
this.month = month;
|
|
818
|
+
this.step = { jump: at, to };
|
|
819
|
+
this.requestUpdate();
|
|
820
|
+
}
|
|
821
|
+
/** Writes the progress the last render asked for (see `step`), and rests when it has nowhere to travel. */
|
|
822
|
+
applyStep() {
|
|
823
|
+
const step = this.step;
|
|
824
|
+
const pages = this.pages;
|
|
825
|
+
this.step = null;
|
|
826
|
+
if (!step || !pages)
|
|
827
|
+
return;
|
|
828
|
+
// From where the step says the days are — or from where they are — to where it sends them.
|
|
829
|
+
const from = step.jump ?? this.progressNow();
|
|
830
|
+
pages.removeAttribute('data-held');
|
|
831
|
+
this.beginTravel(from, step.to);
|
|
832
|
+
if (this.views.length === 1)
|
|
833
|
+
pages.style.removeProperty('block-size');
|
|
834
|
+
else if (!this.travelling)
|
|
835
|
+
queueMicrotask(() => this.views.length > 1 && !this.drag?.taken && !this.wheel?.following && !this.travelling && this.rest());
|
|
836
|
+
}
|
|
837
|
+
/** CAL-14, CAL-31: the travel has ended — the grid holds the displayed month's view alone again. */
|
|
838
|
+
onTravelEnd() {
|
|
839
|
+
if (this.drag?.taken || this.wheel?.following)
|
|
840
|
+
return;
|
|
841
|
+
if (this.views.length > 1 && !this.travelling)
|
|
842
|
+
this.rest();
|
|
843
|
+
}
|
|
844
|
+
/**
|
|
845
|
+
* CAL-13: `month` is shown — the active day keeps its number (the last day of a shorter month), the month is announced
|
|
846
|
+
* once, and focus stays where it was: a focused day that leaves the view hands it to the new active day.
|
|
847
|
+
*/
|
|
848
|
+
turnTo(month) {
|
|
849
|
+
const focused = this.renderRoot.activeElement;
|
|
850
|
+
this.showMonth(month);
|
|
851
|
+
this.carryActive(month, focused);
|
|
852
|
+
this.announce();
|
|
853
|
+
}
|
|
854
|
+
/** CAL-13: the active day keeps its number in `month`, and a day that had the focus hands it to the new active day. */
|
|
855
|
+
carryActive(month, focused) {
|
|
856
|
+
const { min, max } = this.cfg;
|
|
857
|
+
this.active = clampDate({ ...month, day: Math.min(this.active.day, daysInMonth(month.year, month.month)) }, min, max);
|
|
858
|
+
if (focused instanceof HTMLElement && focused.classList.contains('day')) {
|
|
859
|
+
this.focusAfter = 'day';
|
|
860
|
+
this.ringAfter = focused.matches(':focus-visible');
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
/**
|
|
864
|
+
* CAL-13: a month button that has just shown the first or the last month is disabled under the focus it holds, and a
|
|
865
|
+
* disabled button holds none: focus stays in the calendar, on the other month button — the one that leads back — or,
|
|
866
|
+
* where that one is disabled too (the product moved min or max under it), on the active day. It is moved within the
|
|
867
|
+
* turn that disables the button — once the other button, which this update may have just enabled, has drawn itself
|
|
868
|
+
* so — before the platform takes focus, so focus is never on nothing and nothing hears it leave.
|
|
869
|
+
*/
|
|
870
|
+
keepPagingFocus() {
|
|
871
|
+
const root = this.renderRoot;
|
|
872
|
+
const focused = root.activeElement;
|
|
873
|
+
if (!focused?.disabled || !focused.matches('.previous, .next'))
|
|
874
|
+
return;
|
|
875
|
+
const other = this.renderRoot.querySelector(focused.matches('.next') ? '.previous' : '.next');
|
|
876
|
+
void Promise.resolve(other?.updateComplete).then(() => {
|
|
877
|
+
if (root.activeElement !== focused || !focused.disabled)
|
|
878
|
+
return;
|
|
879
|
+
if (other && !other.disabled)
|
|
880
|
+
other.focus();
|
|
881
|
+
else
|
|
882
|
+
this.focus();
|
|
883
|
+
});
|
|
884
|
+
}
|
|
885
|
+
/** CAL-13: the previous or next month, never past min's or max's. */
|
|
886
|
+
pageBy(months) {
|
|
887
|
+
const target = addMonthsTo(this.month, months);
|
|
888
|
+
if (!this.allowed(target))
|
|
889
|
+
return false;
|
|
890
|
+
this.turnTo(target);
|
|
891
|
+
return true;
|
|
892
|
+
}
|
|
893
|
+
allowed(month) {
|
|
894
|
+
const { min, max } = this.cfg;
|
|
895
|
+
return !(min && compareMonths(month, min) < 0) && !(max && compareMonths(month, max) > 0);
|
|
896
|
+
}
|
|
897
|
+
announce() {
|
|
898
|
+
const text = monthYearText(this.cfg.locale, this.month);
|
|
899
|
+
// The same words twice in a row are still a change the live region reads: a zero-width space tells them apart.
|
|
900
|
+
this.announcement = this.announcement === text ? `${text}` : text;
|
|
901
|
+
}
|
|
902
|
+
/** CAL-7: a year is chosen — the day view of the displayed month in that year, focus to its active day; the choice is unchanged. */
|
|
903
|
+
chooseYear(year, byKey) {
|
|
904
|
+
const { min, max } = this.cfg;
|
|
905
|
+
this.showMonth(clampMonth({ year, month: this.month.month }, min, max), { motion: false });
|
|
906
|
+
this.view = 'day';
|
|
907
|
+
this.active = this.activeDayOf(this.month);
|
|
908
|
+
this.focusAfter = 'day';
|
|
909
|
+
this.ringAfter = byKey;
|
|
910
|
+
this.announce();
|
|
911
|
+
}
|
|
912
|
+
/**
|
|
913
|
+
* CAL-33, CAL-34: one event of a scroll, `distance` px toward the next month, at `time`. The days move by it, unless
|
|
914
|
+
* the scroll has ended: it ends when it has slowed below `SCROLL_SLOW` — having been that fast: a scroll that never
|
|
915
|
+
* was has not slowed, and is followed until it is quiet — and what follows is ignored for as long as it is no faster
|
|
916
|
+
* (the tail of a momentum scroll). A faster event (by `SCROLL_RESUME`) is a new push, and moves the days again from
|
|
917
|
+
* where they are.
|
|
918
|
+
*/
|
|
919
|
+
followScroll(distance, time) {
|
|
920
|
+
const scroll = (this.wheel ??= { following: false, spent: false, fast: false, origin: this.month, samples: [], unit: 1, at: 0, quiet: 0 });
|
|
921
|
+
clearTimeout(scroll.quiet);
|
|
922
|
+
scroll.quiet = window.setTimeout(this.onScrollQuiet, SCROLL_QUIET);
|
|
923
|
+
scroll.samples.push({ time, distance: Math.abs(distance) });
|
|
924
|
+
while (time - scroll.samples[0].time > SCROLL_WINDOW)
|
|
925
|
+
scroll.samples.shift();
|
|
926
|
+
if (scroll.spent)
|
|
927
|
+
return;
|
|
928
|
+
const speed = scroll.samples.reduce((sum, sample) => sum + sample.distance, 0) / SCROLL_WINDOW;
|
|
929
|
+
const slow = speed < SCROLL_SLOW;
|
|
930
|
+
const ended = scroll.fast && slow;
|
|
931
|
+
if (!scroll.following) {
|
|
932
|
+
// Ended by slowing (or handed to a button, a key or a drag): only a new push moves the days again.
|
|
933
|
+
if (scroll.fast && speed < SCROLL_SLOW * SCROLL_RESUME)
|
|
934
|
+
return;
|
|
935
|
+
if (!this.beginScroll(scroll))
|
|
936
|
+
return;
|
|
937
|
+
}
|
|
938
|
+
if (!slow)
|
|
939
|
+
scroll.fast = true;
|
|
940
|
+
this.moveScroll(scroll, distance / scroll.unit);
|
|
941
|
+
if (ended)
|
|
942
|
+
this.settleScroll();
|
|
943
|
+
}
|
|
944
|
+
/**
|
|
945
|
+
* CAL-33: the days begin to follow a scroll, as a drag takes them without a pointer: the progress is held where the
|
|
946
|
+
* days are now (a change that is playing carries on from there, CAL-14), and the grid holds the displayed month's view
|
|
947
|
+
* and its neighbours'.
|
|
948
|
+
*/
|
|
949
|
+
beginScroll(scroll) {
|
|
950
|
+
const pages = this.pages;
|
|
951
|
+
if (!pages)
|
|
952
|
+
return false;
|
|
953
|
+
const moving = this.views.length > 1;
|
|
954
|
+
let at = moving ? this.progressNow() : 0;
|
|
955
|
+
let views = moving ? this.views : [this.month];
|
|
956
|
+
const box = pages.getBoundingClientRect();
|
|
957
|
+
scroll.unit = Math.max(1, this.axis === 'vertical' ? box.height / VIEW_ROWS : box.width);
|
|
958
|
+
this.pin();
|
|
959
|
+
const [before, after] = [addMonthsTo(this.month, -1), addMonthsTo(this.month, 1)];
|
|
960
|
+
if (sameMonth(views[0], this.month) && this.allowed(before)) {
|
|
961
|
+
views = [before, ...views];
|
|
962
|
+
at += 1;
|
|
963
|
+
}
|
|
964
|
+
if (sameMonth(views[views.length - 1], this.month) && this.allowed(after))
|
|
965
|
+
views = [...views, after];
|
|
966
|
+
scroll.following = true;
|
|
967
|
+
scroll.origin = this.month;
|
|
968
|
+
scroll.at = at;
|
|
969
|
+
this.views = views;
|
|
970
|
+
this.step = null;
|
|
971
|
+
// A change that was playing stops where the scroll took the days from.
|
|
972
|
+
this.endTravel();
|
|
973
|
+
pages.setAttribute('data-held', '');
|
|
974
|
+
pages.style.setProperty(PROGRESS, String(at));
|
|
975
|
+
this.requestUpdate();
|
|
976
|
+
return true;
|
|
977
|
+
}
|
|
978
|
+
/**
|
|
979
|
+
* CAL-33: the days move `travel` rows (or pages) toward the next month — toward the previous one when negative — one
|
|
980
|
+
* point for each point, in the frame the event arrives. When they reach a neighbouring month's view that month is the
|
|
981
|
+
* displayed one (CAL-34: shown, not announced), the grid holds its neighbours', and the scroll carries on with what is
|
|
982
|
+
* left; where there is no further view (min's or max's month) they stop.
|
|
983
|
+
*/
|
|
984
|
+
moveScroll(scroll, travel) {
|
|
985
|
+
const pages = this.pages;
|
|
986
|
+
if (!pages)
|
|
987
|
+
return;
|
|
988
|
+
let left = travel;
|
|
989
|
+
if (Math.abs(scroll.at - Math.round(scroll.at)) < EPSILON)
|
|
990
|
+
scroll.at = Math.round(scroll.at);
|
|
991
|
+
while (Math.abs(left) > 0) {
|
|
992
|
+
const views = this.views;
|
|
993
|
+
const toward = Math.sign(left);
|
|
994
|
+
const next = toward > 0 ? Math.floor(scroll.at + EPSILON) + 1 : Math.ceil(scroll.at - EPSILON) - 1;
|
|
995
|
+
if (next < 0 || next >= views.length)
|
|
996
|
+
break;
|
|
997
|
+
const step = this.stepsOf(views)[toward > 0 ? next - 1 : next];
|
|
998
|
+
const room = Math.abs(next - scroll.at) * step;
|
|
999
|
+
// (A hair short of a view is at it: the days never rest within a rounding error of a view they have not reached.)
|
|
1000
|
+
if (Math.abs(left) < room - EPSILON) {
|
|
1001
|
+
scroll.at += left / step;
|
|
1002
|
+
break;
|
|
1003
|
+
}
|
|
1004
|
+
left = Math.abs(left) > room ? left - toward * room : 0;
|
|
1005
|
+
scroll.at = next;
|
|
1006
|
+
// A view passed on the way back to the displayed month's (a change was playing) is only passed.
|
|
1007
|
+
const home = views.findIndex((view) => sameMonth(view, this.month));
|
|
1008
|
+
if ((next - home) * toward >= 0)
|
|
1009
|
+
this.reachView(scroll, views[next]);
|
|
1010
|
+
}
|
|
1011
|
+
pages.style.setProperty(PROGRESS, String(scroll.at));
|
|
1012
|
+
}
|
|
1013
|
+
/** CAL-34: the days have reached `month`'s view — it is the displayed month (CAL-13, without the announcement), between its neighbours'. */
|
|
1014
|
+
reachView(scroll, month) {
|
|
1015
|
+
if (!sameMonth(month, this.month)) {
|
|
1016
|
+
const focused = this.renderRoot.activeElement;
|
|
1017
|
+
this.month = month;
|
|
1018
|
+
this.carryActive(month, focused);
|
|
1019
|
+
}
|
|
1020
|
+
const views = [addMonthsTo(month, -1), month, addMonthsTo(month, 1)].filter((view) => this.allowed(view));
|
|
1021
|
+
this.views = views;
|
|
1022
|
+
scroll.at = views.findIndex((view) => sameMonth(view, month));
|
|
1023
|
+
this.requestUpdate();
|
|
1024
|
+
}
|
|
1025
|
+
/**
|
|
1026
|
+
* CAL-34: the scroll has ended. Between two views the days go to the neighbour's from a quarter of the way on, and
|
|
1027
|
+
* otherwise return, over the page motion (at once where motion is reduced, CAL-32); the month is announced once, if it
|
|
1028
|
+
* is not the one displayed when the scroll began.
|
|
1029
|
+
*/
|
|
1030
|
+
settleScroll() {
|
|
1031
|
+
const scroll = this.wheel;
|
|
1032
|
+
if (!scroll?.following)
|
|
1033
|
+
return;
|
|
1034
|
+
scroll.following = false;
|
|
1035
|
+
const home = this.views.findIndex((view) => sameMonth(view, this.month));
|
|
1036
|
+
const from = scroll.at;
|
|
1037
|
+
const side = Math.sign(from - home);
|
|
1038
|
+
const share = Math.abs(from - home);
|
|
1039
|
+
let to = home;
|
|
1040
|
+
if (side !== 0 && share >= SETTLE_SHARE - EPSILON && share <= 1 + EPSILON && this.views[home + side]) {
|
|
1041
|
+
to = home + side;
|
|
1042
|
+
const focused = this.renderRoot.activeElement;
|
|
1043
|
+
this.month = this.views[to];
|
|
1044
|
+
this.carryActive(this.month, focused);
|
|
1045
|
+
}
|
|
1046
|
+
if (!sameMonth(this.month, scroll.origin))
|
|
1047
|
+
this.announce();
|
|
1048
|
+
scroll.origin = this.month;
|
|
1049
|
+
if (!this.canTravel) {
|
|
1050
|
+
this.rest();
|
|
1051
|
+
return;
|
|
1052
|
+
}
|
|
1053
|
+
this.step = { jump: from, to };
|
|
1054
|
+
this.requestUpdate();
|
|
1055
|
+
}
|
|
1056
|
+
/**
|
|
1057
|
+
* CAL-14: something else moves the month (a button, a key, a drag): the scroll no longer holds the days, which stay
|
|
1058
|
+
* where it left them for that to carry on from. A month the scroll had reached is announced, as its end would have.
|
|
1059
|
+
*/
|
|
1060
|
+
dropScroll() {
|
|
1061
|
+
const scroll = this.wheel;
|
|
1062
|
+
if (!scroll?.following)
|
|
1063
|
+
return;
|
|
1064
|
+
scroll.following = false;
|
|
1065
|
+
if (!sameMonth(this.month, scroll.origin))
|
|
1066
|
+
this.announce();
|
|
1067
|
+
}
|
|
1068
|
+
/** CAL-32: the scroll is cancelled — the days return to the displayed month's view, nothing is announced, and what is left of it is ignored. */
|
|
1069
|
+
cancelScroll() {
|
|
1070
|
+
const scroll = this.wheel;
|
|
1071
|
+
if (!scroll)
|
|
1072
|
+
return;
|
|
1073
|
+
scroll.spent = true;
|
|
1074
|
+
if (!scroll.following)
|
|
1075
|
+
return;
|
|
1076
|
+
scroll.following = false;
|
|
1077
|
+
if (!this.canTravel) {
|
|
1078
|
+
this.rest();
|
|
1079
|
+
return;
|
|
1080
|
+
}
|
|
1081
|
+
this.step = { jump: scroll.at, to: this.views.findIndex((view) => sameMonth(view, this.month)) };
|
|
1082
|
+
this.requestUpdate();
|
|
1083
|
+
}
|
|
1084
|
+
/** The scroll has nothing left to move (the grid is drawn anew, or gone). */
|
|
1085
|
+
forgetScroll() {
|
|
1086
|
+
clearTimeout(this.wheel?.quiet);
|
|
1087
|
+
this.wheel = null;
|
|
1088
|
+
}
|
|
1089
|
+
/**
|
|
1090
|
+
* CAL-30: past the slop, further along the axis than across it — the drag is the calendar's. The press chooses no day
|
|
1091
|
+
* and the day under it leaves its pressed state; the grid holds the displayed month's view and its neighbours' (never
|
|
1092
|
+
* one past min or max), and from now on the progress is the pointer's — wherever it goes, since the grid captures it.
|
|
1093
|
+
* While it lasts nothing in the calendar is hovered and a fine pointer shows the grabbing cursor (`data-dragging`).
|
|
1094
|
+
*/
|
|
1095
|
+
takeDrag(event) {
|
|
1096
|
+
const drag = this.drag;
|
|
1097
|
+
const pages = this.pages;
|
|
1098
|
+
const grid = this.renderRoot.querySelector('.day-view');
|
|
1099
|
+
if (!drag || !pages || !grid)
|
|
1100
|
+
return;
|
|
1101
|
+
try {
|
|
1102
|
+
grid.setPointerCapture(event.pointerId);
|
|
1103
|
+
}
|
|
1104
|
+
catch {
|
|
1105
|
+
// No active pointer by that id (a dispatched event): the moves still reach the grid they are dispatched on.
|
|
1106
|
+
}
|
|
1107
|
+
this.press.release();
|
|
1108
|
+
// CAL-14: a scroll being followed ends here; the drag carries on from where it left the days.
|
|
1109
|
+
this.dropScroll();
|
|
1110
|
+
grid.closest('.calendar')?.setAttribute('data-dragging', '');
|
|
1111
|
+
const moving = this.views.length > 1;
|
|
1112
|
+
let at = moving ? this.progressNow() : 0;
|
|
1113
|
+
let views = moving ? this.views : [this.month];
|
|
1114
|
+
const box = pages.getBoundingClientRect();
|
|
1115
|
+
drag.unit = Math.max(1, this.axis === 'vertical' ? box.height / VIEW_ROWS : box.width);
|
|
1116
|
+
this.pin();
|
|
1117
|
+
const [before, after] = [addMonthsTo(this.month, -1), addMonthsTo(this.month, 1)];
|
|
1118
|
+
if (sameMonth(views[0], this.month) && this.allowed(before)) {
|
|
1119
|
+
views = [before, ...views];
|
|
1120
|
+
at += 1;
|
|
1121
|
+
}
|
|
1122
|
+
if (sameMonth(views[views.length - 1], this.month) && this.allowed(after))
|
|
1123
|
+
views = [...views, after];
|
|
1124
|
+
drag.home = views.findIndex((view) => sameMonth(view, this.month));
|
|
1125
|
+
const has = (index) => index >= 0 && index < views.length && this.allowed(views[index]) && sameMonth(views[index], addMonthsTo(this.month, index - drag.home));
|
|
1126
|
+
drag.low = Math.min(at, has(drag.home - 1) ? drag.home - 1 : drag.home);
|
|
1127
|
+
drag.high = Math.max(at, has(drag.home + 1) ? drag.home + 1 : drag.home);
|
|
1128
|
+
drag.from = travelAt(this.stepsOf(views), at);
|
|
1129
|
+
drag.at = at;
|
|
1130
|
+
drag.taken = true;
|
|
1131
|
+
this.views = views;
|
|
1132
|
+
this.step = null;
|
|
1133
|
+
// A change that was playing stops where the drag took the days from.
|
|
1134
|
+
this.endTravel();
|
|
1135
|
+
pages.setAttribute('data-held', '');
|
|
1136
|
+
pages.style.setProperty(PROGRESS, String(at));
|
|
1137
|
+
window.addEventListener('keydown', this.onDragKeyDown, true);
|
|
1138
|
+
this.requestUpdate();
|
|
1139
|
+
}
|
|
1140
|
+
/**
|
|
1141
|
+
* CAL-30: the days move by the distance the pointer has travelled along the axis since the press, in the frame it
|
|
1142
|
+
* moves — toward the next month for a drag toward the top (or the start), wherever the pointer goes in either layout
|
|
1143
|
+
* direction (CAL-26) — and stop at the neighbouring month's view.
|
|
1144
|
+
*/
|
|
1145
|
+
followDrag(event) {
|
|
1146
|
+
const drag = this.drag;
|
|
1147
|
+
const pages = this.pages;
|
|
1148
|
+
if (!drag?.taken || !pages)
|
|
1149
|
+
return;
|
|
1150
|
+
const toward = this.axis === 'vertical' || !this.rtl ? -1 : 1;
|
|
1151
|
+
const steps = this.stepsOf(this.views);
|
|
1152
|
+
const travel = drag.from + (toward * drag.gesture.distance(event)) / drag.unit;
|
|
1153
|
+
drag.at = clamp(travel < 0 ? 0 : progressAt(steps, travel), drag.low, drag.high);
|
|
1154
|
+
pages.style.setProperty(PROGRESS, String(drag.at));
|
|
1155
|
+
}
|
|
1156
|
+
/** CAL-32: the drag is over without a choice — the days return to the displayed month's view; nothing is announced. */
|
|
1157
|
+
cancelDrag() {
|
|
1158
|
+
const drag = this.drag;
|
|
1159
|
+
if (!drag)
|
|
1160
|
+
return;
|
|
1161
|
+
if (drag.taken)
|
|
1162
|
+
this.endDrag(drag.home);
|
|
1163
|
+
else
|
|
1164
|
+
this.drag = null;
|
|
1165
|
+
}
|
|
1166
|
+
/**
|
|
1167
|
+
* Lets go of the pointer, without moving anything. The progress stays held where the drag left it until the next
|
|
1168
|
+
* step is written (`applyStep`), so that no style read in between starts a travel from somewhere else.
|
|
1169
|
+
*/
|
|
1170
|
+
dropDrag() {
|
|
1171
|
+
const drag = this.drag;
|
|
1172
|
+
this.drag = null;
|
|
1173
|
+
window.removeEventListener('keydown', this.onDragKeyDown, true);
|
|
1174
|
+
if (!drag?.taken)
|
|
1175
|
+
return;
|
|
1176
|
+
const grid = this.renderRoot?.querySelector('.day-view');
|
|
1177
|
+
grid?.closest('.calendar')?.removeAttribute('data-dragging');
|
|
1178
|
+
if (grid?.hasPointerCapture?.(drag.gesture.id))
|
|
1179
|
+
grid.releasePointerCapture(drag.gesture.id);
|
|
1180
|
+
}
|
|
1181
|
+
/**
|
|
1182
|
+
* CAL-31, CAL-32: the drag ends on the view at `index`. Another month than the displayed one is shown as CAL-13 says;
|
|
1183
|
+
* the days go there from where the pointer left them over the page motion — at once where motion is reduced.
|
|
1184
|
+
*/
|
|
1185
|
+
endDrag(index) {
|
|
1186
|
+
const drag = this.drag;
|
|
1187
|
+
if (!drag?.taken)
|
|
1188
|
+
return;
|
|
1189
|
+
const month = this.views[index];
|
|
1190
|
+
// The click this release may still produce chooses no day (CAL-31); the mark is taken away by it, or by the next press.
|
|
1191
|
+
this.swallowClick = true;
|
|
1192
|
+
const from = drag.at;
|
|
1193
|
+
const travel = this.canTravel;
|
|
1194
|
+
this.dropDrag();
|
|
1195
|
+
if (!sameMonth(month, this.month)) {
|
|
1196
|
+
const focused = this.renderRoot.activeElement;
|
|
1197
|
+
this.month = month;
|
|
1198
|
+
this.carryActive(month, focused);
|
|
1199
|
+
this.announce();
|
|
1200
|
+
}
|
|
1201
|
+
if (!travel) {
|
|
1202
|
+
this.rest();
|
|
1203
|
+
return;
|
|
1204
|
+
}
|
|
1205
|
+
// From where the pointer left the days — said again, so that it is where the travel starts even when no frame was drawn there.
|
|
1206
|
+
this.step = { jump: from, to: index };
|
|
1207
|
+
this.requestUpdate();
|
|
1208
|
+
}
|
|
1209
|
+
// ── The day grid's keys and presses (CAL-10, CAL-11, CAL-20) ──────────────────────────────────────────────────────
|
|
1210
|
+
dayOf(event) {
|
|
1211
|
+
for (const node of event.composedPath()) {
|
|
1212
|
+
if (node instanceof HTMLElement && node.classList.contains('day') && node.dataset.date)
|
|
1213
|
+
return node;
|
|
1214
|
+
if (node === this)
|
|
1215
|
+
break;
|
|
1216
|
+
}
|
|
1217
|
+
return null;
|
|
1218
|
+
}
|
|
1219
|
+
containerOf(cell) {
|
|
1220
|
+
return cell.querySelector(cell.classList.contains('in-range') ? '.band' : '.box');
|
|
1221
|
+
}
|
|
1222
|
+
/** CAL-11: moves the active day (showing its month) and focus to it, never before min or after max. */
|
|
1223
|
+
moveActive(to) {
|
|
1224
|
+
const target = clampDate(to, this.cfg.min, this.cfg.max);
|
|
1225
|
+
if (!inMonth(target, this.month)) {
|
|
1226
|
+
this.showMonth(monthOf(target));
|
|
1227
|
+
this.active = target;
|
|
1228
|
+
this.announce();
|
|
1229
|
+
}
|
|
1230
|
+
else
|
|
1231
|
+
this.active = target;
|
|
1232
|
+
this.focusAfter = 'day';
|
|
1233
|
+
this.ringAfter = true;
|
|
1234
|
+
}
|
|
1235
|
+
// ── The year list (CAL-7, CAL-12) ─────────────────────────────────────────────────────────────────────────────────
|
|
1236
|
+
get years() {
|
|
1237
|
+
const { min, max } = this.cfg;
|
|
1238
|
+
return [min?.year ?? FIRST_LISTED_YEAR, max?.year ?? LAST_LISTED_YEAR];
|
|
1239
|
+
}
|
|
1240
|
+
yearOf(event) {
|
|
1241
|
+
for (const node of event.composedPath()) {
|
|
1242
|
+
if (node instanceof HTMLElement && node.classList.contains('year'))
|
|
1243
|
+
return node;
|
|
1244
|
+
if (node === this)
|
|
1245
|
+
break;
|
|
1246
|
+
}
|
|
1247
|
+
return null;
|
|
1248
|
+
}
|
|
1249
|
+
/** CAL-7: the displayed year's row is the third in view, or as near to it as the list's ends allow. */
|
|
1250
|
+
scrollYears() {
|
|
1251
|
+
const list = this.renderRoot.querySelector('.years');
|
|
1252
|
+
const first = list?.querySelector('.year');
|
|
1253
|
+
if (!list || !first)
|
|
1254
|
+
return;
|
|
1255
|
+
const row = Math.floor((this.month.year - this.years[0]) / 3);
|
|
1256
|
+
list.scrollTop = Math.max(0, (row - 2) * first.offsetHeight);
|
|
1257
|
+
}
|
|
1258
|
+
/** Lets go of the years once the day view is shown and the list is out of sight (at once where nothing fades). */
|
|
1259
|
+
releaseYears() {
|
|
1260
|
+
if (!this.yearsHeld || this.view === 'year')
|
|
1261
|
+
return;
|
|
1262
|
+
const list = this.renderRoot?.querySelector('.years');
|
|
1263
|
+
if (list && getComputedStyle(list).visibility !== 'hidden')
|
|
1264
|
+
return;
|
|
1265
|
+
this.yearsHeld = false;
|
|
1266
|
+
this.requestUpdate();
|
|
1267
|
+
}
|
|
1268
|
+
/** CAL-12: the focused year scrolled into view inside the list. */
|
|
1269
|
+
revealYear(button) {
|
|
1270
|
+
const list = button.closest('.years');
|
|
1271
|
+
if (!list)
|
|
1272
|
+
return;
|
|
1273
|
+
const [box, room] = [button.getBoundingClientRect(), list.getBoundingClientRect()];
|
|
1274
|
+
if (box.top < room.top)
|
|
1275
|
+
list.scrollTop -= room.top - box.top;
|
|
1276
|
+
else if (box.bottom > room.bottom)
|
|
1277
|
+
list.scrollTop += box.bottom - room.bottom;
|
|
1278
|
+
}
|
|
1279
|
+
// ── Updates ───────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
1280
|
+
willUpdate(changed) {
|
|
1281
|
+
this.cfg = this.readConfig();
|
|
1282
|
+
const axis = this.axis;
|
|
1283
|
+
if (this.readAxis() !== axis && this.hasUpdated) {
|
|
1284
|
+
// Another system's axis draws the days anew (a column, or pages): nothing is left to move, and a focused day keeps the focus.
|
|
1285
|
+
const focused = this.renderRoot.activeElement;
|
|
1286
|
+
if (focused instanceof HTMLElement && focused.classList.contains('day')) {
|
|
1287
|
+
this.focusAfter = 'day';
|
|
1288
|
+
this.ringAfter = focused.matches(':focus-visible');
|
|
1289
|
+
}
|
|
1290
|
+
this.forgetScroll();
|
|
1291
|
+
this.dropDrag();
|
|
1292
|
+
this.views = [this.month];
|
|
1293
|
+
this.step = { jump: 0, to: 0 };
|
|
1294
|
+
}
|
|
1295
|
+
const { min, max, choice, startView } = this.cfg;
|
|
1296
|
+
if (!this.hasUpdated) {
|
|
1297
|
+
// CAL-17: the month of the choice or of today, or the year view.
|
|
1298
|
+
this.view = startView;
|
|
1299
|
+
this.yearsHeld = startView === 'year';
|
|
1300
|
+
this.month = this.homeMonth();
|
|
1301
|
+
this.active = this.activeDayOf(this.month);
|
|
1302
|
+
this.activeYear = this.month.year;
|
|
1303
|
+
this.scrollYearsAfter = this.view === 'year';
|
|
1304
|
+
this.views = [this.month];
|
|
1305
|
+
return;
|
|
1306
|
+
}
|
|
1307
|
+
const own = this.ownChoice;
|
|
1308
|
+
this.ownChoice = false;
|
|
1309
|
+
if (!own) {
|
|
1310
|
+
// CAL-17: a date the product sets outside the displayed month shows that month, without the slide.
|
|
1311
|
+
const set = ['value', 'start', 'end'].find((name) => changed.has(name) && choice[name] && !inMonth(choice[name], this.month));
|
|
1312
|
+
// CAL-32: a date the product sets while a drag lasts cancels it — the days return, to that date's month where it names one.
|
|
1313
|
+
// A scroll being followed is cancelled the same way, and what is left of it is ignored.
|
|
1314
|
+
const named = ['value', 'start', 'end'].some((name) => changed.has(name));
|
|
1315
|
+
const dragged = (!!this.drag?.taken || !!this.wheel?.following) && named;
|
|
1316
|
+
if (dragged) {
|
|
1317
|
+
this.cancelDrag();
|
|
1318
|
+
this.cancelScroll();
|
|
1319
|
+
}
|
|
1320
|
+
if (set) {
|
|
1321
|
+
this.showMonth(clampMonth(monthOf(choice[set]), min, max), { motion: dragged });
|
|
1322
|
+
this.active = this.activeDayOf(this.month);
|
|
1323
|
+
this.activeYear = this.month.year;
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
// The bounds may have moved: the displayed month and the active day stay inside them.
|
|
1327
|
+
const clamped = clampMonth(this.month, min, max);
|
|
1328
|
+
if (compareMonths(clamped, this.month) !== 0) {
|
|
1329
|
+
this.month = clamped;
|
|
1330
|
+
this.active = this.activeDayOf(clamped);
|
|
1331
|
+
}
|
|
1332
|
+
else if (!inMonth(this.active, this.month))
|
|
1333
|
+
this.active = this.activeDayOf(this.month);
|
|
1334
|
+
else
|
|
1335
|
+
this.active = clampDate(this.active, min, max);
|
|
1336
|
+
// The grid holds the displayed month's view: alone at rest, among the views the days move between otherwise.
|
|
1337
|
+
if (!this.views.some((view) => sameMonth(view, this.month)) || this.views.some((view) => !this.allowed(view))) {
|
|
1338
|
+
this.forgetScroll();
|
|
1339
|
+
this.dropDrag();
|
|
1340
|
+
this.views = [this.month];
|
|
1341
|
+
this.step = { jump: 0, to: 0 };
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
/**
|
|
1345
|
+
* CAL-35: a part that needs a word nobody gave — not the instance, not the product's words — is still drawn and
|
|
1346
|
+
* works; it is recorded (`missingWords()`) and, in a debug build, reported once, naming the prop. The view toggle's
|
|
1347
|
+
* description is not one of them: its name and its expanded state already say what it shows.
|
|
1348
|
+
*/
|
|
1349
|
+
reportWords() {
|
|
1350
|
+
const { choice } = this.cfg;
|
|
1351
|
+
if (this.view !== 'year') {
|
|
1352
|
+
if (!this.words.get('previousMonthLabel', this.previousMonthLabel))
|
|
1353
|
+
this.words.missing('previousMonthLabel', { id: 'CAL-35', effect: 'the previous-month button is drawn and works, and has no accessible name' });
|
|
1354
|
+
if (!this.words.get('nextMonthLabel', this.nextMonthLabel))
|
|
1355
|
+
this.words.missing('nextMonthLabel', { id: 'CAL-35', effect: 'the next-month button is drawn and works, and has no accessible name' });
|
|
1356
|
+
}
|
|
1357
|
+
if (choice.start && !this.words.get('startLabel', this.startLabel))
|
|
1358
|
+
this.words.missing('startLabel', { id: 'CAL-35', effect: 'the start of the range has no description' });
|
|
1359
|
+
if (choice.end && !this.words.get('endLabel', this.endLabel))
|
|
1360
|
+
this.words.missing('endLabel', { id: 'CAL-35', effect: 'the end of the range has no description' });
|
|
1361
|
+
}
|
|
1362
|
+
updated() {
|
|
1363
|
+
this.shown = true;
|
|
1364
|
+
this.reportWords();
|
|
1365
|
+
this.applyStep();
|
|
1366
|
+
if (this.scrollYearsAfter) {
|
|
1367
|
+
this.scrollYearsAfter = false;
|
|
1368
|
+
this.scrollYears();
|
|
1369
|
+
}
|
|
1370
|
+
// Where the list does not fade (reduced motion, a calendar that is not drawn) no transition ends: it is let go here.
|
|
1371
|
+
this.releaseYears();
|
|
1372
|
+
this.keepPagingFocus();
|
|
1373
|
+
if (this.focusAfter) {
|
|
1374
|
+
const what = this.focusAfter;
|
|
1375
|
+
const ring = this.ringAfter;
|
|
1376
|
+
this.focusAfter = null;
|
|
1377
|
+
this.ringAfter = undefined;
|
|
1378
|
+
const options = ring === undefined ? {} : { focusVisible: ring };
|
|
1379
|
+
if (what === 'day')
|
|
1380
|
+
this.focus(options);
|
|
1381
|
+
else {
|
|
1382
|
+
const button = this.renderRoot.querySelector(`.year[data-year="${this.activeYear}"]`);
|
|
1383
|
+
if (button) {
|
|
1384
|
+
button.focus({ ...options, preventScroll: true });
|
|
1385
|
+
this.revealYear(button);
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
// ── Rendering ─────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
1391
|
+
/** The day grid's item: one day, a gridcell with its condition and state (CAL-2, CAL-3, CAL-15, CAL-16, CAL-23). */
|
|
1392
|
+
renderDay(day, look = {}) {
|
|
1393
|
+
if (!day)
|
|
1394
|
+
return html `<div class="cell empty" aria-hidden="true"></div>`;
|
|
1395
|
+
const { locale, today, unavailable, choice } = this.cfg;
|
|
1396
|
+
const { date, adjacent } = day;
|
|
1397
|
+
const { start, end } = choice;
|
|
1398
|
+
const condition = this.dayCondition(day);
|
|
1399
|
+
const disabled = unavailable(date);
|
|
1400
|
+
const band = !!start && !!end && compareDates(start, end) !== 0;
|
|
1401
|
+
const isStart = band && sameDate(date, start);
|
|
1402
|
+
const isEnd = band && sameDate(date, end);
|
|
1403
|
+
// CAL-35: the words of a range's ends are the instance's, else the product's; without them the day has no description.
|
|
1404
|
+
const described = [sameDate(date, start) ? this.words.get('startLabel', this.startLabel) : '', sameDate(date, end) ? this.words.get('endLabel', this.endLabel) : ''].filter(Boolean).join(', ');
|
|
1405
|
+
return html `<div
|
|
1406
|
+
role="gridcell"
|
|
1407
|
+
part="day"
|
|
1408
|
+
class=${classMap({ cell: true, day: true, [condition]: condition !== 'unselected', 'range-start': isStart, 'range-end': isEnd, between: !!look.mix })}
|
|
1409
|
+
style=${styleMap(look.mix ? { '--_mix': look.mix } : {})}
|
|
1410
|
+
data-date=${isoOf(date)}
|
|
1411
|
+
?data-adjacent=${adjacent}
|
|
1412
|
+
?inert=${!!look.coming}
|
|
1413
|
+
aria-hidden=${ifDefined(look.coming ? 'true' : undefined)}
|
|
1414
|
+
tabindex=${!adjacent && !look.coming && sameDate(date, this.active) ? '0' : '-1'}
|
|
1415
|
+
aria-selected=${condition === 'selected' || condition === 'in-range' ? 'true' : 'false'}
|
|
1416
|
+
aria-disabled=${ifDefined(disabled ? 'true' : undefined)}
|
|
1417
|
+
aria-current=${ifDefined(sameDate(date, today) ? 'date' : undefined)}
|
|
1418
|
+
aria-label=${fullDateText(locale, date)}
|
|
1419
|
+
aria-description=${ifDefined(described || undefined)}
|
|
1420
|
+
>
|
|
1421
|
+
<span class="lane" style=${styleMap(look.opacity ? { opacity: look.opacity } : {})}
|
|
1422
|
+
><span class="band"></span><span class="box" data-tanrei-shape>${numberText(locale, date.day)}</span></span
|
|
1423
|
+
>
|
|
1424
|
+
</div>`;
|
|
1425
|
+
}
|
|
1426
|
+
/**
|
|
1427
|
+
* CAL-29: the day grid on the vertical axis — ONE column of week rows, keyed by their first day, holding the rows of
|
|
1428
|
+
* every view the grid holds: the displayed month's six at rest, and those of the months the days move between while a
|
|
1429
|
+
* change plays or a drag lasts. Each day is drawn between what the views draw for it, by the progress: faded where a
|
|
1430
|
+
* view does not draw it (a row outside its six; an empty cell without showAdjacentDays), mixed between the adjacent
|
|
1431
|
+
* and the unselected condition where it is a neighbouring month's in one view and the month's own in another. What the
|
|
1432
|
+
* displayed month's view does not hold is inert and hidden until that month is the displayed one (CAL-32).
|
|
1433
|
+
*/
|
|
1434
|
+
renderColumn() {
|
|
1435
|
+
const views = this.views;
|
|
1436
|
+
const home = views.findIndex((view) => sameMonth(view, this.month));
|
|
1437
|
+
const rows = this.weekRows(views);
|
|
1438
|
+
const steps = this.stepsOf(views, 'vertical');
|
|
1439
|
+
const travel = steps.map((step, i) => `${step} * clamp(0, var(${PROGRESS}) - ${i}, 1)`).join(' + ');
|
|
1440
|
+
const cell = (row, date) => {
|
|
1441
|
+
const own = views.map((view) => inMonth(date, view));
|
|
1442
|
+
const drawn = views.map((_, i) => row.held[i] && (own[i] || this.showAdjacentDays));
|
|
1443
|
+
if (!drawn.some(Boolean))
|
|
1444
|
+
return this.renderDay(null);
|
|
1445
|
+
// Where a view does not draw the day its condition there is the nearest drawing view's, so that nothing mixes unseen:
|
|
1446
|
+
// a day only October's view draws is one of the month's own for as long as it fades in.
|
|
1447
|
+
const first = drawn.indexOf(true);
|
|
1448
|
+
let last = own[first];
|
|
1449
|
+
const conditions = own.map((value, i) => (last = drawn[i] ? value : last));
|
|
1450
|
+
const day = { date, adjacent: !conditions[home] };
|
|
1451
|
+
const condition = this.dayCondition(day);
|
|
1452
|
+
const mix = condition === 'adjacent' || condition === 'unselected' ? between(conditions.map(Number)) : null;
|
|
1453
|
+
const opacity = between(drawn.map(Number));
|
|
1454
|
+
return this.renderDay(day, { ...(mix ? { mix } : {}), ...(opacity ? { opacity } : {}), coming: !drawn[home] });
|
|
1455
|
+
};
|
|
1456
|
+
return html `<div role="rowgroup" class="page current" style=${styleMap(views.length > 1 ? { '--_travel': `calc(${travel})`, '--_rows': String(rows.length) } : {})}>
|
|
1457
|
+
${repeat(rows, (row) => isoOf(row.start), (row) => {
|
|
1458
|
+
const days = Array.from({ length: 7 }, (_, column) => addDays(row.start, column));
|
|
1459
|
+
const cells = days.map((date) => cell(row, date));
|
|
1460
|
+
const coming = !row.held[home];
|
|
1461
|
+
const empty = !coming && days.every((date) => !inMonth(date, this.month) && !this.showAdjacentDays);
|
|
1462
|
+
return html `<div role="row" class="row" ?inert=${coming} aria-hidden=${ifDefined(coming || empty ? 'true' : undefined)}>${cells}</div>`;
|
|
1463
|
+
})}
|
|
1464
|
+
</div>`;
|
|
1465
|
+
}
|
|
1466
|
+
/**
|
|
1467
|
+
* CAL-14, CAL-30: the day grid on the horizontal axis — a page a view, side by side in order, travelling together by
|
|
1468
|
+
* the progress. The displayed month's page is the grid's; the others are inert and hidden until theirs is (CAL-32).
|
|
1469
|
+
*/
|
|
1470
|
+
renderPages() {
|
|
1471
|
+
const { firstDay } = this.cfg;
|
|
1472
|
+
const moving = this.views.length > 1;
|
|
1473
|
+
return html `${repeat(this.views, (view) => `${view.year}-${view.month}`, (view, place) => {
|
|
1474
|
+
const current = sameMonth(view, this.month);
|
|
1475
|
+
const cells = monthGrid(view, firstDay, this.showAdjacentDays);
|
|
1476
|
+
const rows = Array.from({ length: VIEW_ROWS }, (_, row) => cells.slice(row * 7, row * 7 + 7));
|
|
1477
|
+
return html `<div role="rowgroup" class=${classMap({ page: true, current })} style=${styleMap(moving ? { '--_place': String(place) } : {})} ?inert=${!current} aria-hidden=${ifDefined(current ? undefined : 'true')}>
|
|
1478
|
+
${rows.map((row) => html `<div role="row" class="row" aria-hidden=${ifDefined(row.every((day) => !day) ? 'true' : undefined)}>${row.map((day) => this.renderDay(day))}</div>`)}
|
|
1479
|
+
</div>`;
|
|
1480
|
+
})}`;
|
|
1481
|
+
}
|
|
1482
|
+
/** The year list's item: one year, a button with its condition (CAL-2, CAL-7, CAL-23). */
|
|
1483
|
+
renderYear(year) {
|
|
1484
|
+
const { locale, today } = this.cfg;
|
|
1485
|
+
const displayed = year === this.month.year;
|
|
1486
|
+
const condition = displayed ? 'selected' : year === today.year ? 'today' : 'unselected';
|
|
1487
|
+
return html `<button
|
|
1488
|
+
type="button"
|
|
1489
|
+
part="year"
|
|
1490
|
+
class=${classMap({ cell: true, year: true, [condition]: condition !== 'unselected' })}
|
|
1491
|
+
data-year=${year}
|
|
1492
|
+
tabindex=${year === this.activeYear ? '0' : '-1'}
|
|
1493
|
+
aria-current=${ifDefined(displayed ? 'true' : undefined)}
|
|
1494
|
+
aria-description=${ifDefined((year === today.year && (this.words.get('todayLabel', this.todayLabel) || todayName(locale))) || undefined)}
|
|
1495
|
+
>
|
|
1496
|
+
<span class="lane"><span class="box" data-tanrei-shape>${numberText(locale, year)}</span></span>
|
|
1497
|
+
</button>`;
|
|
1498
|
+
}
|
|
1499
|
+
/**
|
|
1500
|
+
* CAL-5: the arrows follow the axis — up and down, or back and forward. The names never change with the direction:
|
|
1501
|
+
* arrow_back and arrow_forward are flagged by the icon set, so each Button's icon helper mirrors its glyph in
|
|
1502
|
+
* right-to-left (BTN-19), and previous still points to the start edge.
|
|
1503
|
+
*/
|
|
1504
|
+
glyphs() {
|
|
1505
|
+
return this.axis === 'vertical' ? { previous: GLYPHS.up, next: GLYPHS.down } : { previous: GLYPHS.back, next: GLYPHS.forward };
|
|
1506
|
+
}
|
|
1507
|
+
render() {
|
|
1508
|
+
const { locale, firstDay, min, max } = this.cfg;
|
|
1509
|
+
const year = this.view === 'year';
|
|
1510
|
+
const monthYear = monthYearText(locale, this.month);
|
|
1511
|
+
const narrow = narrowWeekdays(locale);
|
|
1512
|
+
const long = longWeekdays(locale);
|
|
1513
|
+
const [first, last] = this.years;
|
|
1514
|
+
const moving = this.views.length > 1;
|
|
1515
|
+
const glyphs = this.glyphs();
|
|
1516
|
+
const label = this.label.trim();
|
|
1517
|
+
return html `<div class="calendar" role=${ifDefined(label ? 'group' : undefined)} aria-label=${ifDefined(label || undefined)} data-axis=${this.axis}>
|
|
1518
|
+
<div part="navigation" class="nav">
|
|
1519
|
+
<button
|
|
1520
|
+
type="button"
|
|
1521
|
+
part="view-toggle"
|
|
1522
|
+
class="cell toggle"
|
|
1523
|
+
aria-expanded=${year ? 'true' : 'false'}
|
|
1524
|
+
aria-description=${ifDefined(this.words.get('yearViewLabel', this.yearViewLabel) || undefined)}
|
|
1525
|
+
@click=${this.onToggleView}
|
|
1526
|
+
@pointerdown=${this.onTogglePointerDown}
|
|
1527
|
+
@pointerup=${this.press.release}
|
|
1528
|
+
@pointercancel=${this.press.release}
|
|
1529
|
+
@pointerleave=${this.press.release}
|
|
1530
|
+
@keydown=${this.onToggleKeyDown}
|
|
1531
|
+
@keyup=${this.press.onKeyUp}
|
|
1532
|
+
@blur=${this.press.onBlur}
|
|
1533
|
+
@focus=${this.onCellFocus}
|
|
1534
|
+
>
|
|
1535
|
+
<span class="lane"
|
|
1536
|
+
><span class="box" data-tanrei-shape><span class="toggle-label">${monthYear}</span><span class="chevron" aria-hidden="true">${GLYPHS.expand}</span></span></span
|
|
1537
|
+
>
|
|
1538
|
+
</button>
|
|
1539
|
+
<span class="arrows" ?data-off=${year}>
|
|
1540
|
+
<tanrei-button
|
|
1541
|
+
class="previous"
|
|
1542
|
+
variant="text"
|
|
1543
|
+
size="medium"
|
|
1544
|
+
label=${this.words.get('previousMonthLabel', this.previousMonthLabel)}
|
|
1545
|
+
?disabled=${!!min && compareMonths(this.month, min) <= 0}
|
|
1546
|
+
@click=${() => this.pageBy(-1)}
|
|
1547
|
+
><span slot="icon">${glyphs.previous}</span></tanrei-button
|
|
1548
|
+
>
|
|
1549
|
+
<tanrei-button
|
|
1550
|
+
class="next"
|
|
1551
|
+
variant="text"
|
|
1552
|
+
size="medium"
|
|
1553
|
+
label=${this.words.get('nextMonthLabel', this.nextMonthLabel)}
|
|
1554
|
+
?disabled=${!!max && compareMonths(this.month, max) >= 0}
|
|
1555
|
+
@click=${() => this.pageBy(1)}
|
|
1556
|
+
><span slot="icon">${glyphs.next}</span></tanrei-button
|
|
1557
|
+
>
|
|
1558
|
+
</span>
|
|
1559
|
+
</div>
|
|
1560
|
+
<div class="views">
|
|
1561
|
+
<div
|
|
1562
|
+
part="grid"
|
|
1563
|
+
class="day-view"
|
|
1564
|
+
role="grid"
|
|
1565
|
+
aria-label=${monthYear}
|
|
1566
|
+
?data-off=${year}
|
|
1567
|
+
?inert=${year}
|
|
1568
|
+
@keydown=${this.onGridKeyDown}
|
|
1569
|
+
@keyup=${this.onGridKeyUp}
|
|
1570
|
+
@pointerdown=${this.onGridPointerDown}
|
|
1571
|
+
@pointermove=${this.onDragMove}
|
|
1572
|
+
@pointerup=${this.onGridPointerUp}
|
|
1573
|
+
@pointercancel=${(event) => (this.onDragCancel(event), this.press.release())}
|
|
1574
|
+
@lostpointercapture=${this.onDragCancel}
|
|
1575
|
+
@pointerleave=${this.press.release}
|
|
1576
|
+
@mousedown=${this.onGridMouseDown}
|
|
1577
|
+
@click=${this.onGridClick}
|
|
1578
|
+
@dragstart=${(event) => event.preventDefault()}
|
|
1579
|
+
@wheel=${this.onWheel}
|
|
1580
|
+
@focusin=${this.onCellFocus}
|
|
1581
|
+
@focusout=${this.press.onBlur}
|
|
1582
|
+
>
|
|
1583
|
+
<div role="rowgroup">
|
|
1584
|
+
<div role="row" class="row weekdays">
|
|
1585
|
+
${weekdayColumns(firstDay).map((weekday) => html `<div role="columnheader" class="weekday" aria-label=${long[weekday]}>${narrow[weekday]}</div>`)}
|
|
1586
|
+
</div>
|
|
1587
|
+
</div>
|
|
1588
|
+
<div class="pages" data-moving=${ifDefined(moving ? this.axis : undefined)}>
|
|
1589
|
+
${this.axis === 'vertical' ? this.renderColumn() : this.renderPages()}
|
|
1590
|
+
</div>
|
|
1591
|
+
</div>
|
|
1592
|
+
<div
|
|
1593
|
+
part="years"
|
|
1594
|
+
class="years"
|
|
1595
|
+
?data-off=${!year}
|
|
1596
|
+
?inert=${!year}
|
|
1597
|
+
@keydown=${this.onYearsKeyDown}
|
|
1598
|
+
@keyup=${this.press.onKeyUp}
|
|
1599
|
+
@pointerdown=${this.onYearsPointerDown}
|
|
1600
|
+
@pointerup=${this.press.release}
|
|
1601
|
+
@pointercancel=${this.press.release}
|
|
1602
|
+
@pointerleave=${this.press.release}
|
|
1603
|
+
@click=${this.onYearsClick}
|
|
1604
|
+
@focusin=${this.onCellFocus}
|
|
1605
|
+
@focusout=${this.press.onBlur}
|
|
1606
|
+
@transitionend=${this.onYearsFaded}
|
|
1607
|
+
@transitioncancel=${this.onYearsFaded}
|
|
1608
|
+
>
|
|
1609
|
+
${year || this.yearsHeld ? Array.from({ length: last - first + 1 }, (_, i) => this.renderYear(first + i)) : nothing}
|
|
1610
|
+
</div>
|
|
1611
|
+
</div>
|
|
1612
|
+
<span class="hold" aria-hidden="true"></span>
|
|
1613
|
+
<div class="announce" aria-live="polite">${this.announcement}</div>
|
|
1614
|
+
</div>`;
|
|
1615
|
+
}
|
|
1616
|
+
}
|
|
1617
|
+
if (!customElements.get('tanrei-calendar'))
|
|
1618
|
+
customElements.define('tanrei-calendar', TanreiCalendar);
|
|
1619
|
+
//# sourceMappingURL=calendar.js.map
|