@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,2537 @@
|
|
|
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 { hiddenHost } from '../../primitives/hidden.js';
|
|
7
|
+
import { ActionPlacement, AvailabilityController, BUTTON_VARIANTS, FALLBACK_LOCALE, FollowController, MINUTE_STEPS, PressController, SHEET_TOUCH_SLOP, SystemWatchController, WEEKDAY_NAMES, ambientLocale, asciiDigits, clockText, closeRequestReason, compChoice, compareDates, deepActive, deviceTime, headerDateText, holdPageScroll, hostAria, hourOf12, hourText, isoOf, keyboardCover, clockFor, localeHourCycle, minuteText, modalLayer, layoutSize, naturalHeight, numberText, parseClockTime, parseIsoDate, parseValues, periodNames, periodOf, periodPlace, report, roundDown, shownHour12, stepMinutes, supportedLocale, syncFocusStyle, tabbables, timeSeparator, timeText, trapFocus, unitName, watchEscape, WordsController, } from '../../primitives/index.js';
|
|
8
|
+
import '../button/button.js';
|
|
9
|
+
import '../calendar/calendar.js';
|
|
10
|
+
import { placeMenu } from '../menu/menu.js';
|
|
11
|
+
import '../tabs/tabs.js';
|
|
12
|
+
import { styles } from './date-time-picker.styles.js';
|
|
13
|
+
const PRESENTATIONS = ['modal', 'docked'];
|
|
14
|
+
const MODES = ['date', 'time', 'date-time'];
|
|
15
|
+
const HOUR_CYCLES = ['locale', 'h12', 'h23'];
|
|
16
|
+
const ENTRY_MODES = ['wheels', 'dial'];
|
|
17
|
+
const UNITS = ['hour', 'minute'];
|
|
18
|
+
const LAYOUTS = ['auto', 'vertical', 'horizontal'];
|
|
19
|
+
const FIRST_DAYS = ['locale', ...WEEKDAY_NAMES];
|
|
20
|
+
const START_VIEWS = ['day', 'year'];
|
|
21
|
+
const PREFIX = '--tanrei-comp-date-time-picker';
|
|
22
|
+
/** The choices of kind the picker reads from the cascade: their values are the names. */
|
|
23
|
+
const OFFERED = ['both', 'wheels', 'dial'];
|
|
24
|
+
const ARRANGEMENTS = ['fill', 'end'];
|
|
25
|
+
/** DTM-18: a selection container for each wheel, or one band behind both. */
|
|
26
|
+
const SPANS = ['each', 'joined'];
|
|
27
|
+
/** The glyphs of the entry-mode tabs (DTM-13), by the icon set's names: the keyboard for the wheels, the clock face for the dial. */
|
|
28
|
+
const ENTRY_GLYPHS = { wheels: 'keyboard', dial: 'schedule' };
|
|
29
|
+
/** DTM-48: the glyphs that say Cancel and OK without a word, by the icon set's names, where neither the instance nor the product's words gave one. */
|
|
30
|
+
const ACTION_GLYPHS = { cancel: 'close', confirm: 'check' };
|
|
31
|
+
/** DTM-48: what stands where words that nobody gave would be drawn — a zero-width space, so that the place keeps the height of its line. */
|
|
32
|
+
const HOLDS_A_LINE = '\u200b';
|
|
33
|
+
/** DTM-44: what, typed on the hour, ends its entry and moves on to the minute, besides the locale's own separator. */
|
|
34
|
+
const SEPARATORS = [':', '.', ' '];
|
|
35
|
+
/** A wheel's quiet time that ends a scroll of it (DTM-19). */
|
|
36
|
+
const WHEEL_QUIET = 150;
|
|
37
|
+
/** How far back a release's velocity looks, in ms. */
|
|
38
|
+
const VELOCITY_WINDOW = 80;
|
|
39
|
+
const EMPTY = { date: null, time: null };
|
|
40
|
+
const NO_CHOICE = { value: EMPTY, start: EMPTY, end: EMPTY };
|
|
41
|
+
/** A direction on the dial for `degrees` clockwise from the top: x right, y down, unit length. */
|
|
42
|
+
const direction = (degrees) => {
|
|
43
|
+
const radians = (degrees * Math.PI) / 180;
|
|
44
|
+
return { x: Math.round(Math.sin(radians) * 1e6) / 1e6, y: Math.round(-Math.cos(radians) * 1e6) / 1e6 };
|
|
45
|
+
};
|
|
46
|
+
/** `n` modulo `m`, never negative. */
|
|
47
|
+
const mod = (n, m) => ((n % m) + m) % m;
|
|
48
|
+
/** The shortest signed move from index `from` to index `to` on a wheel of `n` values. */
|
|
49
|
+
const shortest = (from, to, n) => {
|
|
50
|
+
const d = mod(to - from, n);
|
|
51
|
+
return d > n / 2 ? d - n : d;
|
|
52
|
+
};
|
|
53
|
+
let ids = 0;
|
|
54
|
+
/**
|
|
55
|
+
* Lets a person choose a date, a time, or a date and time — or a span of any of them — from a Calendar and time wheels
|
|
56
|
+
* or a clock dial, in a dialog or in a surface that drops down from a field.
|
|
57
|
+
*
|
|
58
|
+
* Contract: specs/date-time-picker.spec.json. `modal` (the default) is a native `<dialog>` in the shadow root opened with
|
|
59
|
+
* `showModal()` — `::backdrop` is the scrim, everything else is inert, focus is trapped — with a start-aligned title row,
|
|
60
|
+
* the pending value (in a mode with a date) and Cancel and OK; the choice is pending until OK. `docked` is a manual
|
|
61
|
+
* popover in the top layer, placed below the element whose id is `anchor` with the menu's placement (flipped above when
|
|
62
|
+
* there is more room there, shifted to stay in the viewport, following the anchor); it is not modal: Tab and focus
|
|
63
|
+
* leaving close it, and a docked picker that sets a date only commits by choosing it. Both move focus in when they open
|
|
64
|
+
* and give it back when they close.
|
|
65
|
+
*
|
|
66
|
+
* The picker never closes itself: it fires `close` with a reason and you set `open` to false. When one activation
|
|
67
|
+
* commits a choice, the element takes the new `value` (or `start` and `end`) and fires `change` before `close`.
|
|
68
|
+
*
|
|
69
|
+
* Values are the strings of `<input type=date>`, `type=time` and `type=datetime-local`: "2026-09-17", "19:30",
|
|
70
|
+
* "2026-09-17T19:30" — no seconds, no time zone. The date is a `<tanrei-calendar>`; the time is set on two wheels (spin
|
|
71
|
+
* buttons that also take a typed number: press a wheel's chosen value, or type a digit) or on a clock dial with an hour
|
|
72
|
+
* and a minute selector, chosen by two icon-only `<tanrei-tabs variant="secondary">` at the end of the title row while
|
|
73
|
+
* the design system offers both (`comp.date-time-picker.time.entry-modes`) — the keyboard glyph for the wheels, the
|
|
74
|
+
* clock face for the dial, `wheelsLabel` and `dialLabel` their accessible names. They are the picker's only tabs. The
|
|
75
|
+
* period of a 12-hour time (AM, PM) is a part of the time, after the minute or — where the locale writes it first —
|
|
76
|
+
* before the hour: a third wheel of two rows in the wheels mode, and in the dial mode a narrow selector that shows the
|
|
77
|
+
* pending period and changes to the other when pressed; either is a spin button of two values named `periodLabel`, and
|
|
78
|
+
* neither is ever drawn as selected. The two ends of a range that has a time are two range fields joined by an en dash
|
|
79
|
+
* ("9:00 AM – 5:30 PM") across the whole time section, with no word for start or end; the one the wheels or the dial set
|
|
80
|
+
* is drawn as selected, and pressing the other sets it. Names, digits, forms, the separator and the preferred clock come from `Intl` for `locale`
|
|
81
|
+
* (without it, the nearest `lang`, then the browser's language). Every visual value comes from
|
|
82
|
+
* `--tanrei-comp-date-time-picker-*` tokens; the calendar, the tabs and the Buttons keep their own. The `inline`
|
|
83
|
+
* attribute, for tests and documentation, draws the open surface in place without the overlay's behaviour.
|
|
84
|
+
*
|
|
85
|
+
* @tag tanrei-date-time-picker
|
|
86
|
+
* @csspart container - The surface: the native `<dialog>` (modal) or the popover (docked).
|
|
87
|
+
* @csspart header - The title row (and, in a modal picker with a date, the pending value).
|
|
88
|
+
* @csspart calendar - The `<tanrei-calendar>`.
|
|
89
|
+
* @csspart time - The time section: the range display across its width, the time display and the wheels or the dial.
|
|
90
|
+
* @csspart range-display - The two ends of a range that has a time: a group of two range fields and the dash between them.
|
|
91
|
+
* @csspart range-field - One end of the range (a button, `data-end` is `start` or `end`); `aria-pressed` on the one being set.
|
|
92
|
+
* @csspart range-separator - The en dash between the two range fields.
|
|
93
|
+
* @csspart wheel - The hour or the minute wheel; its middle row is the spin button, an input that takes typed digits.
|
|
94
|
+
* @csspart selector - The hour or the minute selector of the dial mode (a spin button).
|
|
95
|
+
* @csspart period - The period of a 12-hour time (a spin button of two values): the period wheel in the wheels mode, the period selector in the dial mode.
|
|
96
|
+
* @csspart separator - The separator between the hour and the minute.
|
|
97
|
+
* @csspart dial - The clock dial.
|
|
98
|
+
* @csspart handle - The handle over the chosen value.
|
|
99
|
+
* @csspart error - The line that says a range's end is before its start.
|
|
100
|
+
* @csspart actions - Cancel and OK.
|
|
101
|
+
* @fires {CustomEvent<TanreiDateTimePickerChangeDetail>} change - The person committed a choice that differs from the one before (OK, or choosing a date in a docked picker that sets a date only). `value`, `start` and `end` are already the new ones; `detail` holds them too. Fired before the `close` it causes.
|
|
102
|
+
* @fires {CustomEvent<TanreiDateTimePickerCloseDetail>} close - The picker asks to be closed: `detail.reason` is `escape`, `back`, `outside`, `tab`, `focus-out`, `cancel`, `confirm` or `select`. Set `open` to false.
|
|
103
|
+
*/
|
|
104
|
+
export class TanreiDateTimePicker extends LitElement {
|
|
105
|
+
/**
|
|
106
|
+
* DTM-48: the picker's own words, each the instance's prop, else the product's — and, for the hour's, the minute's and
|
|
107
|
+
* the period's names, else the locale's own name for that field, which is the platform's and not a word of Tanrei's.
|
|
108
|
+
* (The calendar reads its six itself, from the props the picker hands it.)
|
|
109
|
+
*/
|
|
110
|
+
get say() {
|
|
111
|
+
const { locale } = this.cfg;
|
|
112
|
+
const get = (key, own) => this.words.get(key, own);
|
|
113
|
+
return {
|
|
114
|
+
dateLabel: get('dateLabel', this.dateLabel),
|
|
115
|
+
startLabel: get('startLabel', this.startLabel),
|
|
116
|
+
endLabel: get('endLabel', this.endLabel),
|
|
117
|
+
confirmLabel: get('confirmLabel', this.confirmLabel),
|
|
118
|
+
cancelLabel: get('cancelLabel', this.cancelLabel),
|
|
119
|
+
hourLabel: get('hourLabel', this.hourLabel) || unitName(locale, 'hour'),
|
|
120
|
+
minuteLabel: get('minuteLabel', this.minuteLabel) || unitName(locale, 'minute'),
|
|
121
|
+
periodLabel: get('periodLabel', this.periodLabel) || unitName(locale, 'period'),
|
|
122
|
+
wheelsLabel: get('wheelsLabel', this.wheelsLabel),
|
|
123
|
+
dialLabel: get('dialLabel', this.dialLabel),
|
|
124
|
+
entryModeLabel: get('entryModeLabel', this.entryModeLabel),
|
|
125
|
+
rangeLabel: get('rangeLabel', this.rangeLabel),
|
|
126
|
+
// "+1" is a mark, in the locale's digits: what "next day" says, without a word.
|
|
127
|
+
nextDayLabel: get('nextDayLabel', this.nextDayLabel) || `+${numberText(locale, 1)}`,
|
|
128
|
+
rangeErrorText: get('rangeErrorText', this.rangeErrorText),
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* DTM-48: a word that is drawn or exposed now and that nobody gave — not the instance, not the product's words, not
|
|
133
|
+
* the platform — is recorded (`missingWords()`) and, in a debug build, reported once, naming the prop. The part is
|
|
134
|
+
* still drawn and still works. `label` is the instance's alone, and reported for this picker.
|
|
135
|
+
*/
|
|
136
|
+
reportWords() {
|
|
137
|
+
if (!this.session)
|
|
138
|
+
return;
|
|
139
|
+
const say = this.say;
|
|
140
|
+
const { range, mode } = this.cfg;
|
|
141
|
+
const lacks = (key, effect) => this.words.missing(key, { id: 'DTM-48', effect });
|
|
142
|
+
if (!this.label.trim())
|
|
143
|
+
report(this, 'DTM-48', 'label is empty, so the title row draws no words and the surface has no accessible name; say what is being chosen ("Check-in"): the product\'s words hold no title');
|
|
144
|
+
if (this.pendingUntilOk) {
|
|
145
|
+
if (!say.cancelLabel)
|
|
146
|
+
lacks('cancelLabel', 'an icon-only Button with the close glyph is drawn in its place, without a name');
|
|
147
|
+
if (!say.confirmLabel)
|
|
148
|
+
lacks('confirmLabel', 'an icon-only Button with the check glyph is drawn in its place, without a name');
|
|
149
|
+
}
|
|
150
|
+
if (this.modal && this.hasDate && !say.dateLabel && (range ? !this.pending.start.date || !this.pending.end.date : !this.pending.value.date))
|
|
151
|
+
lacks('dateLabel', 'a date not chosen yet draws nothing in the header, which keeps its height');
|
|
152
|
+
if (this.hasTime) {
|
|
153
|
+
if (!say.hourLabel)
|
|
154
|
+
lacks('hourLabel', 'the hour has no accessible name');
|
|
155
|
+
if (!say.minuteLabel)
|
|
156
|
+
lacks('minuteLabel', 'the minute has no accessible name');
|
|
157
|
+
if (this.cfg.cycle === 'h12' && !say.periodLabel)
|
|
158
|
+
lacks('periodLabel', 'the period has no accessible name');
|
|
159
|
+
if (this.offered === 'both') {
|
|
160
|
+
if (!say.entryModeLabel)
|
|
161
|
+
lacks('entryModeLabel', 'the row of entry-mode tabs has no accessible name');
|
|
162
|
+
if (!say.wheelsLabel)
|
|
163
|
+
lacks('wheelsLabel', 'the tab that shows the wheels has no accessible name');
|
|
164
|
+
if (!say.dialLabel)
|
|
165
|
+
lacks('dialLabel', 'the tab that shows the dial has no accessible name');
|
|
166
|
+
}
|
|
167
|
+
if (range) {
|
|
168
|
+
if (!say.rangeLabel)
|
|
169
|
+
lacks('rangeLabel', 'the group of the two range fields has no accessible name');
|
|
170
|
+
if (!say.startLabel)
|
|
171
|
+
lacks('startLabel', 'the start\'s range field is named by its time alone');
|
|
172
|
+
if (!say.endLabel)
|
|
173
|
+
lacks('endLabel', 'the end\'s range field is named by its time alone');
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
if (this.nextDay && !this.words.get('nextDayLabel', this.nextDayLabel))
|
|
177
|
+
lacks('nextDayLabel', '"+1" is drawn after the end\'s time in its place');
|
|
178
|
+
if (mode === 'date-time' && this.rangeError && !say.rangeErrorText)
|
|
179
|
+
lacks('rangeErrorText', 'the error line draws no words and keeps its height');
|
|
180
|
+
}
|
|
181
|
+
static { this.styles = [styles, hiddenHost]; }
|
|
182
|
+
static { this.properties = {
|
|
183
|
+
open: { type: Boolean, reflect: true },
|
|
184
|
+
presentation: { type: String, reflect: true },
|
|
185
|
+
mode: { type: String, reflect: true },
|
|
186
|
+
range: { type: Boolean, reflect: true },
|
|
187
|
+
value: { type: String },
|
|
188
|
+
start: { type: String },
|
|
189
|
+
end: { type: String },
|
|
190
|
+
min: { type: String },
|
|
191
|
+
max: { type: String },
|
|
192
|
+
disabledDates: { attribute: 'disabled-dates', converter: { fromAttribute: parseValues, toAttribute: (value) => value.join(' ') } },
|
|
193
|
+
isDateDisabled: { attribute: false },
|
|
194
|
+
today: { type: String },
|
|
195
|
+
firstDayOfWeek: { type: String, attribute: 'first-day-of-week' },
|
|
196
|
+
locale: { type: String },
|
|
197
|
+
startView: { type: String, attribute: 'start-view' },
|
|
198
|
+
showAdjacentDays: { type: Boolean, attribute: 'show-adjacent-days' },
|
|
199
|
+
hourCycle: { type: String, attribute: 'hour-cycle' },
|
|
200
|
+
minuteStep: { type: Number, attribute: 'minute-step' },
|
|
201
|
+
entryMode: { type: String, attribute: 'entry-mode' },
|
|
202
|
+
unit: { type: String },
|
|
203
|
+
layout: { type: String, reflect: true },
|
|
204
|
+
label: { type: String },
|
|
205
|
+
dateLabel: { type: String, attribute: 'date-label' },
|
|
206
|
+
startLabel: { type: String, attribute: 'start-label' },
|
|
207
|
+
endLabel: { type: String, attribute: 'end-label' },
|
|
208
|
+
confirmLabel: { type: String, attribute: 'confirm-label' },
|
|
209
|
+
cancelLabel: { type: String, attribute: 'cancel-label' },
|
|
210
|
+
previousMonthLabel: { type: String, attribute: 'previous-month-label' },
|
|
211
|
+
nextMonthLabel: { type: String, attribute: 'next-month-label' },
|
|
212
|
+
yearViewLabel: { type: String, attribute: 'year-view-label' },
|
|
213
|
+
todayLabel: { type: String, attribute: 'today-label' },
|
|
214
|
+
hourLabel: { type: String, attribute: 'hour-label' },
|
|
215
|
+
minuteLabel: { type: String, attribute: 'minute-label' },
|
|
216
|
+
wheelsLabel: { type: String, attribute: 'wheels-label' },
|
|
217
|
+
dialLabel: { type: String, attribute: 'dial-label' },
|
|
218
|
+
entryModeLabel: { type: String, attribute: 'entry-mode-label' },
|
|
219
|
+
periodLabel: { type: String, attribute: 'period-label' },
|
|
220
|
+
rangeLabel: { type: String, attribute: 'range-label' },
|
|
221
|
+
nextDayLabel: { type: String, attribute: 'next-day-label' },
|
|
222
|
+
rangeErrorText: { type: String, attribute: 'range-error-text' },
|
|
223
|
+
anchor: { type: String, reflect: true },
|
|
224
|
+
opener: { type: String, reflect: true },
|
|
225
|
+
inline: { type: Boolean, reflect: true },
|
|
226
|
+
pending: { state: true },
|
|
227
|
+
editing: { state: true },
|
|
228
|
+
entry: { state: true },
|
|
229
|
+
typed: { state: true },
|
|
230
|
+
armed: { state: true },
|
|
231
|
+
ringed: { state: true },
|
|
232
|
+
ringedEnd: { state: true },
|
|
233
|
+
shownUnit: { state: true },
|
|
234
|
+
angle: { state: true },
|
|
235
|
+
instant: { state: true },
|
|
236
|
+
stacked: { state: true },
|
|
237
|
+
wheelFrame: { state: true },
|
|
238
|
+
}; }
|
|
239
|
+
constructor() {
|
|
240
|
+
super();
|
|
241
|
+
this.availability = new AvailabilityController(this, 'date-time-picker');
|
|
242
|
+
this.system = new SystemWatchController(this);
|
|
243
|
+
/** DTM-48: the product's words, read where the instance gives none (src/primitives/words.ts). */
|
|
244
|
+
this.words = new WordsController(this);
|
|
245
|
+
/** Whether the picker is shown. Open it from your field or button; set it to false when the picker fires `close`. */
|
|
246
|
+
this.open = false;
|
|
247
|
+
/** `modal`: a dialog over a scrim, committed by OK. `docked`: a surface below `anchor`. */
|
|
248
|
+
this.presentation = 'modal';
|
|
249
|
+
/** `date`, `time` or `date-time`: what is chosen. */
|
|
250
|
+
this.mode = 'date';
|
|
251
|
+
/** Chooses a span (`start` … `end`) instead of one `value`: of dates, of times (the end may fall on the next day) or of both. */
|
|
252
|
+
this.range = false;
|
|
253
|
+
/** The chosen value without a range: "2026-09-17" (date), "19:30" (time, 24-hour), "2026-09-17T19:30" (date-time); empty when none. */
|
|
254
|
+
this.value = '';
|
|
255
|
+
/** The first value of the chosen span when `range` is true, in the mode's form; empty when none. */
|
|
256
|
+
this.start = '';
|
|
257
|
+
/** The last value of the chosen span when `range` is true, in the mode's form; empty while only `start` is chosen. */
|
|
258
|
+
this.end = '';
|
|
259
|
+
/** The earliest date that can be chosen (it bounds the calendar only); empty for no limit. */
|
|
260
|
+
this.min = '';
|
|
261
|
+
/** The latest date that can be chosen; empty for no limit. */
|
|
262
|
+
this.max = '';
|
|
263
|
+
/** Dates that cannot be chosen, passed to the calendar. The `disabled-dates` attribute is a space-separated list or a JSON array. */
|
|
264
|
+
this.disabledDates = [];
|
|
265
|
+
/** A rule no list can hold (every weekend): true for an ISO date that cannot be chosen. Passed to the calendar. Property only. */
|
|
266
|
+
this.isDateDisabled = null;
|
|
267
|
+
/** The date the calendar draws as today; empty uses the device's current date. */
|
|
268
|
+
this.today = '';
|
|
269
|
+
/** The weekday in the calendar's first column (`first-day-of-week`). */
|
|
270
|
+
this.firstDayOfWeek = 'locale';
|
|
271
|
+
/** A BCP 47 tag ("en-US", "ja-JP") for names, digits, forms, the separator and the clock; empty: the nearest `lang`, then the browser's. */
|
|
272
|
+
this.locale = '';
|
|
273
|
+
/** Whether the calendar opens on the days of a month or on the list of years (`start-view`). */
|
|
274
|
+
this.startView = 'day';
|
|
275
|
+
/** Whether the calendar shows the neighbouring months' days in its spare cells (`show-adjacent-days`). */
|
|
276
|
+
this.showAdjacentDays = false;
|
|
277
|
+
/** `h12` (1–12 with a period), `h23` (00–23) or `locale` (the locale's clock). Values are 24-hour in every cycle (`hour-cycle`). */
|
|
278
|
+
this.hourCycle = 'locale';
|
|
279
|
+
/** The minutes a person can choose: every minute (1), or every 5, 10, 15 or 30 (`minute-step`). */
|
|
280
|
+
this.minuteStep = 1;
|
|
281
|
+
/** How the time is set when the picker opens (`entry-mode`): `wheels` or `dial`. Not HTML's `inputmode`. */
|
|
282
|
+
this.entryMode = 'wheels';
|
|
283
|
+
/** Dial mode: the unit the dial shows, and the selector that takes focus, when the picker opens. */
|
|
284
|
+
this.unit = 'hour';
|
|
285
|
+
/** `vertical`, `horizontal`, or `auto`: horizontal only when the window is too short for vertical and wide enough. */
|
|
286
|
+
this.layout = 'auto';
|
|
287
|
+
/** Names the picker: its surface's accessible name and the start of its title row — what is being chosen ("Check-in", "Meeting time"). Required, and this instance's alone: the product's words hold none. Empty, the title row draws no words and keeps its height, and the surface has no name. */
|
|
288
|
+
this.label = '';
|
|
289
|
+
/** What the header shows for a date not chosen yet: a single value's, and either end's of a range (`date-label`). This instance's words, else the product's (`setWords({ dateLabel })`); Tanrei has none: without them nothing is drawn there, and the place keeps its height. */
|
|
290
|
+
this.dateLabel = '';
|
|
291
|
+
/** Range: the accessible name of the start's range field and the calendar's start day's description; never drawn (`start-label`). This instance's words, else the product's (`setWords({ startLabel })`); Tanrei has none: without them the field and the day say nothing of it. */
|
|
292
|
+
this.startLabel = '';
|
|
293
|
+
/** Range: the accessible name of the end's range field and the calendar's end day's description; never drawn (`end-label`). This instance's words, else the product's (`setWords({ endLabel })`); Tanrei has none: without them the field and the day say nothing of it. */
|
|
294
|
+
this.endLabel = '';
|
|
295
|
+
/** OK's label (`confirm-label`). This instance's words, else the product's (`setWords({ confirmLabel })`); Tanrei has none: without them an icon-only Button with the check glyph, unnamed. */
|
|
296
|
+
this.confirmLabel = '';
|
|
297
|
+
/** Cancel's label (`cancel-label`). This instance's words, else the product's (`setWords({ cancelLabel })`); Tanrei has none: without them an icon-only Button with the close glyph, unnamed. */
|
|
298
|
+
this.cancelLabel = '';
|
|
299
|
+
/** Passed to the calendar (`previous-month-label`). This instance's words, else the product's (`setWords({ previousMonthLabel })`); Tanrei has none: without them the button is drawn and works, unnamed. */
|
|
300
|
+
this.previousMonthLabel = '';
|
|
301
|
+
/** Passed to the calendar (`next-month-label`). This instance's words, else the product's (`setWords({ nextMonthLabel })`); Tanrei has none: without them the button is drawn and works, unnamed. */
|
|
302
|
+
this.nextMonthLabel = '';
|
|
303
|
+
/** Passed to the calendar (`year-view-label`). This instance's words, else the product's (`setWords({ yearViewLabel })`); Tanrei has none: without them the view toggle has no description. */
|
|
304
|
+
this.yearViewLabel = '';
|
|
305
|
+
/** Passed to the calendar (`today-label`). This instance's words, else the product's (`setWords({ todayLabel })`); Tanrei has none: without them the locale's own word for the present day, from the browser. */
|
|
306
|
+
this.todayLabel = '';
|
|
307
|
+
/** The accessible name of the hour wheel and the hour selector (`hour-label`). This instance's words, else the product's (`setWords({ hourLabel })`); Tanrei has none: without them the locale's own name for the hour, from the browser. */
|
|
308
|
+
this.hourLabel = '';
|
|
309
|
+
/** The accessible name of the minute wheel and the minute selector (`minute-label`). This instance's words, else the product's (`setWords({ minuteLabel })`); Tanrei has none: without them the locale's own name for the minute, from the browser. */
|
|
310
|
+
this.minuteLabel = '';
|
|
311
|
+
/** The accessible name of the entry-mode tab that shows the wheels, which draws the keyboard glyph alone (`wheels-label`). This instance's words, else the product's (`setWords({ wheelsLabel })`); Tanrei has none: without them the tab is drawn and works, unnamed. */
|
|
312
|
+
this.wheelsLabel = '';
|
|
313
|
+
/** The accessible name of the entry-mode tab that shows the dial, which draws the schedule glyph alone (`dial-label`). This instance's words, else the product's (`setWords({ dialLabel })`); Tanrei has none: without them the tab is drawn and works, unnamed. */
|
|
314
|
+
this.dialLabel = '';
|
|
315
|
+
/** The accessible name of the row of entry-mode tabs (`entry-mode-label`). This instance's words, else the product's (`setWords({ entryModeLabel })`); Tanrei has none: without them the row of tabs has no name. */
|
|
316
|
+
this.entryModeLabel = '';
|
|
317
|
+
/** The accessible name of the period — the period wheel or the period selector, a spin button (`period-label`). This instance's words, else the product's (`setWords({ periodLabel })`); Tanrei has none: without them the locale's own name for the day period, from the browser. */
|
|
318
|
+
this.periodLabel = '';
|
|
319
|
+
/** The accessible name of the range display, the group of the two range fields (`range-label`). This instance's words, else the product's (`setWords({ rangeLabel })`); Tanrei has none: without them the group has no name. */
|
|
320
|
+
this.rangeLabel = '';
|
|
321
|
+
/** Mode time with a range: added after the end's time, in its range field and its accessible name, while it falls on the next day (`next-day-label`). This instance's words, else the product's (`setWords({ nextDayLabel })`); Tanrei has none: without them "+1" in the locale's digits. */
|
|
322
|
+
this.nextDayLabel = '';
|
|
323
|
+
/** Mode date-time with a range: the error line while the end is before the start (`range-error-text`). This instance's words, else the product's (`setWords({ rangeErrorText })`); Tanrei has none: without them the line draws no words and keeps its height; OK is still disabled. */
|
|
324
|
+
this.rangeErrorText = '';
|
|
325
|
+
/** Docked: the id of the element the surface is placed against (as the menu's `anchor`), in the picker's own document or shadow root. */
|
|
326
|
+
this.anchor = '';
|
|
327
|
+
/** Docked: the id of the element that opens the picker, when it is not the anchor (a text field's picker button). It gets `aria-haspopup`, `aria-controls` and `aria-expanded`. */
|
|
328
|
+
this.opener = '';
|
|
329
|
+
/** For tests and documentation: draws the open surface in place (DTM-1's verify), without the overlay's behaviour. */
|
|
330
|
+
this.inline = false;
|
|
331
|
+
/** The choice shown, from opening to OK (DTM-6). */
|
|
332
|
+
this.pending = NO_CHOICE;
|
|
333
|
+
/** Which end the time section sets (DTM-15): `value` without a range. */
|
|
334
|
+
this.editing = 'value';
|
|
335
|
+
/** The entry mode shown (DTM-13). */
|
|
336
|
+
this.entry = 'wheels';
|
|
337
|
+
/** The unit the dial shows (DTM-21). */
|
|
338
|
+
this.shownUnit = 'hour';
|
|
339
|
+
/** DTM-26: the handle's angle, kept continuous so that a change turns it along the shorter arc. */
|
|
340
|
+
this.angle = 0;
|
|
341
|
+
/** DTM-25: the handle moves without animation (a drag, or the picker just opened). */
|
|
342
|
+
this.instant = true;
|
|
343
|
+
/** DTM-34: the actions are a column. */
|
|
344
|
+
this.stacked = false;
|
|
345
|
+
/** DTM-19: a count that renders the wheels again while they follow a pointer. */
|
|
346
|
+
this.wheelFrame = 0;
|
|
347
|
+
/** DTM-43, DTM-44: the typed entry in progress — the wheel or the selector it is on, and the digits read so far. */
|
|
348
|
+
this.typed = null;
|
|
349
|
+
/**
|
|
350
|
+
* DTM-44: the wheel that an hour's finished entry moved on to. Its input takes text — so that an on-screen keyboard
|
|
351
|
+
* stays up — though no entry has begun on it: the next digit begins one.
|
|
352
|
+
*/
|
|
353
|
+
this.armed = null;
|
|
354
|
+
/**
|
|
355
|
+
* DTM-20, DTM-47: the wheel — or the period, wheel or selector — whose focus is keyboard focus, and so shows its ring.
|
|
356
|
+
* An input's own `:focus-visible` cannot tell, and whether a key pressed after a pointer press makes a focused element
|
|
357
|
+
* match it is each browser's own guess: the picker keeps the answer itself, so every engine draws the same.
|
|
358
|
+
*/
|
|
359
|
+
this.ringed = null;
|
|
360
|
+
/**
|
|
361
|
+
* DTM-28: the range field whose focus is keyboard focus, kept by the picker for the same reason: after a press and
|
|
362
|
+
* then Space or Enter one engine draws no ring on a button it still reads as focused by the pointer.
|
|
363
|
+
*/
|
|
364
|
+
this.ringedEnd = null;
|
|
365
|
+
this.session = false;
|
|
366
|
+
this.shown = false;
|
|
367
|
+
this.presenting = false;
|
|
368
|
+
this.closeRequested = false;
|
|
369
|
+
/** The choice the picker opened with, in the mode's form (DTM-6). */
|
|
370
|
+
this.openedWith = { value: '', start: '', end: '' };
|
|
371
|
+
/** DTM-4: where focus was when it opened. */
|
|
372
|
+
this.returnTo = null;
|
|
373
|
+
this.lastLayout = '';
|
|
374
|
+
this.listening = false;
|
|
375
|
+
this.pressedScrim = false;
|
|
376
|
+
this.dragging = null;
|
|
377
|
+
/** DTM-33: the error line was shown at the last update (it is announced when it appears). */
|
|
378
|
+
this.errorShown = false;
|
|
379
|
+
/** DTM-20: a press on a wheel is about to focus its input (no ring), or the next focus was asked to show one or not. */
|
|
380
|
+
this.wheelPress = false;
|
|
381
|
+
this.nextRing = null;
|
|
382
|
+
/** DTM-45: the Escape that ended a typed entry closes nothing: when the key was pressed. */
|
|
383
|
+
this.escapeSpent = Number.NEGATIVE_INFINITY;
|
|
384
|
+
/** DTM-45: how much of the window the on-screen keyboard covered at the last look. */
|
|
385
|
+
this.keyboard = 0;
|
|
386
|
+
this.wheels = {
|
|
387
|
+
hour: { at: 0, shift: 0, pointer: null, startY: 0, moved: false, samples: [], settling: 0, scrolling: 0 },
|
|
388
|
+
minute: { at: 0, shift: 0, pointer: null, startY: 0, moved: false, samples: [], settling: 0, scrolling: 0 },
|
|
389
|
+
};
|
|
390
|
+
/** DTM-46: the period wheel — its rows' position is 0 before noon and 1 after, and never past either. */
|
|
391
|
+
this.periodWheel = { at: 0, shift: 0, pointer: null, startY: 0, moved: false, samples: [], settling: 0, scrolling: 0 };
|
|
392
|
+
this.placement = new ActionPlacement(this);
|
|
393
|
+
this.resize$ = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(() => this.arrange());
|
|
394
|
+
/** DTM-29, DTM-30: each selector is pressed on its own (data-pressed, press-hold, the ripple). */
|
|
395
|
+
this.presses = (() => {
|
|
396
|
+
const part = (name) => () => this.renderRoot?.querySelector(`.selector[data-unit='${name}']`) ?? null;
|
|
397
|
+
const press = (name) => new PressController(this, { container: part(name), holdCarrier: () => part(name)()?.querySelector('.value') ?? null, disabled: () => false });
|
|
398
|
+
return { hour: press('hour'), minute: press('minute') };
|
|
399
|
+
})();
|
|
400
|
+
/** DTM-14: and the period selector, which answers a press as an unselected selector does. */
|
|
401
|
+
this.periodPress = (() => {
|
|
402
|
+
const part = () => this.renderRoot?.querySelector('.selector.period') ?? null;
|
|
403
|
+
return new PressController(this, { container: part, holdCarrier: () => part()?.querySelector('.value') ?? null, disabled: () => false });
|
|
404
|
+
})();
|
|
405
|
+
/** DTM-29, DTM-30: and each range field. */
|
|
406
|
+
this.rangePresses = (() => {
|
|
407
|
+
const part = (name) => () => this.renderRoot?.querySelector(`.range-field[data-end='${name}']`) ?? null;
|
|
408
|
+
const press = (name) => new PressController(this, { container: part(name), holdCarrier: () => part(name)()?.querySelector('.value') ?? null, disabled: () => false });
|
|
409
|
+
return { start: press('start'), end: press('end') };
|
|
410
|
+
})();
|
|
411
|
+
this.onConfirm = () => {
|
|
412
|
+
if (this.confirmable)
|
|
413
|
+
this.commit('confirm');
|
|
414
|
+
};
|
|
415
|
+
this.onCancel = () => this.requestClose('cancel');
|
|
416
|
+
// ── The calendar (DTM-11) ─────────────────────────────────────────────────────────────────────────────────────────
|
|
417
|
+
this.onCalendarChange = (event) => {
|
|
418
|
+
event.stopPropagation();
|
|
419
|
+
const detail = event.detail;
|
|
420
|
+
const { range } = this.cfg;
|
|
421
|
+
const date = (text) => parseIsoDate(text);
|
|
422
|
+
if (!range)
|
|
423
|
+
this.pending = { ...this.pending, value: { ...this.pending.value, date: date(detail.value) } };
|
|
424
|
+
else {
|
|
425
|
+
this.pending = { ...this.pending, start: { ...this.pending.start, date: date(detail.start) }, end: { ...this.pending.end, date: date(detail.end) } };
|
|
426
|
+
// DTM-11: a chosen start selects the start's range field, a chosen end the end's.
|
|
427
|
+
if (this.hasTime)
|
|
428
|
+
this.selectEnd(detail.end ? 'end' : 'start');
|
|
429
|
+
}
|
|
430
|
+
// DTM-7: a docked picker for a date only commits a completed choice (any day; a range's end).
|
|
431
|
+
if (!this.pendingUntilOk && (!range || detail.end))
|
|
432
|
+
this.commit('select');
|
|
433
|
+
};
|
|
434
|
+
// ── The entry-mode tabs and the range fields (DTM-13, DTM-15, DTM-42) ─────────────────────────────────────────────
|
|
435
|
+
this.onEntryTabs = (event) => {
|
|
436
|
+
event.stopPropagation();
|
|
437
|
+
const next = event.detail.value === 'dial' ? 'dial' : 'wheels';
|
|
438
|
+
if (next === this.entry)
|
|
439
|
+
return;
|
|
440
|
+
// DTM-13: a typed entry ends first, keeping what it read.
|
|
441
|
+
this.endEntry(true);
|
|
442
|
+
this.armed = null;
|
|
443
|
+
this.entry = next;
|
|
444
|
+
this.instant = true;
|
|
445
|
+
this.syncWheels(true);
|
|
446
|
+
};
|
|
447
|
+
/** DTM-42: a press, Enter or Space on a range field selects it (a native button's click); focus alone does not. */
|
|
448
|
+
this.rangeHandlers = (end) => {
|
|
449
|
+
const press = this.rangePresses[end];
|
|
450
|
+
return {
|
|
451
|
+
onClick: () => this.selectEnd(end),
|
|
452
|
+
onPointerDown: (event) => press.onPointerDown(event),
|
|
453
|
+
/** DTM-28: a key that works the field makes its focus keyboard focus, however focus first reached it. */
|
|
454
|
+
onKeyDown: (event) => {
|
|
455
|
+
if (event.key === 'Enter' || event.key === ' ')
|
|
456
|
+
this.ringedEnd = end;
|
|
457
|
+
press.onKeyDown(event);
|
|
458
|
+
},
|
|
459
|
+
/** DTM-28: the field shows its ring for keyboard focus only — what the browser says of how focus arrived. */
|
|
460
|
+
onFocus: (event) => {
|
|
461
|
+
const control = event.currentTarget;
|
|
462
|
+
syncFocusStyle(this, control);
|
|
463
|
+
this.ringedEnd = control.matches(':focus-visible') ? end : this.ringedEnd === end ? null : this.ringedEnd;
|
|
464
|
+
},
|
|
465
|
+
onBlur: () => {
|
|
466
|
+
if (this.ringedEnd === end)
|
|
467
|
+
this.ringedEnd = null;
|
|
468
|
+
press.onBlur();
|
|
469
|
+
},
|
|
470
|
+
};
|
|
471
|
+
};
|
|
472
|
+
this.startHandlers = this.rangeHandlers('start');
|
|
473
|
+
this.endHandlers = this.rangeHandlers('end');
|
|
474
|
+
this.onWheelPointerDown = (event) => {
|
|
475
|
+
const found = this.wheelOf(event);
|
|
476
|
+
if (!found || (event.pointerType === 'mouse' && event.button !== 0))
|
|
477
|
+
return;
|
|
478
|
+
const wheel = this.wheels[found.unit];
|
|
479
|
+
if (wheel.pointer !== null)
|
|
480
|
+
return;
|
|
481
|
+
// DTM-45: a press on another wheel is a press elsewhere, and ends a typed entry.
|
|
482
|
+
if (this.typed && this.typed.unit !== found.unit)
|
|
483
|
+
this.endEntry(true);
|
|
484
|
+
// DTM-20: the wheel takes focus on its input, whichever row is pressed, and a pressed wheel shows no ring.
|
|
485
|
+
this.wheelPress = true;
|
|
486
|
+
const input = this.spin(found.unit);
|
|
487
|
+
if (input && deepActive() !== input) {
|
|
488
|
+
this.nextRing = false;
|
|
489
|
+
input.focus({ preventScroll: true });
|
|
490
|
+
}
|
|
491
|
+
// A press on a wheel starts a drag (DTM-20): it draws no press state.
|
|
492
|
+
clearTimeout(wheel.settling);
|
|
493
|
+
if (wheel.settling) {
|
|
494
|
+
wheel.settling = 0;
|
|
495
|
+
this.setTime(this.withIndex(found.unit, wheel.at));
|
|
496
|
+
}
|
|
497
|
+
wheel.pointer = event.pointerId;
|
|
498
|
+
wheel.startY = event.clientY;
|
|
499
|
+
wheel.moved = false;
|
|
500
|
+
wheel.shift = 0;
|
|
501
|
+
wheel.samples = [{ y: event.clientY, t: event.timeStamp }];
|
|
502
|
+
found.element.setPointerCapture?.(event.pointerId);
|
|
503
|
+
};
|
|
504
|
+
this.onWheelPointerMove = (event) => {
|
|
505
|
+
const found = this.wheelOf(event);
|
|
506
|
+
if (!found)
|
|
507
|
+
return;
|
|
508
|
+
const wheel = this.wheels[found.unit];
|
|
509
|
+
if (wheel.pointer !== event.pointerId)
|
|
510
|
+
return;
|
|
511
|
+
const dy = event.clientY - wheel.startY;
|
|
512
|
+
if (!wheel.moved && Math.abs(dy) <= SHEET_TOUCH_SLOP)
|
|
513
|
+
return;
|
|
514
|
+
// DTM-45: a wheel that is dragged ends its typed entry, keeping what it read.
|
|
515
|
+
if (!wheel.moved && this.typed?.unit === found.unit) {
|
|
516
|
+
this.endEntry(true);
|
|
517
|
+
this.alignWheel(found.unit);
|
|
518
|
+
}
|
|
519
|
+
wheel.moved = true;
|
|
520
|
+
const { row } = this.rowMetrics(found.element);
|
|
521
|
+
// DTM-19: the rows move with the pointer; a drag upward brings the next values to the band.
|
|
522
|
+
wheel.shift = -dy / row;
|
|
523
|
+
wheel.samples = [...wheel.samples.filter((s) => event.timeStamp - s.t <= VELOCITY_WINDOW), { y: event.clientY, t: event.timeStamp }];
|
|
524
|
+
this.wheelFrame++;
|
|
525
|
+
};
|
|
526
|
+
this.onWheelPointerUp = (event) => {
|
|
527
|
+
const found = this.wheelOf(event);
|
|
528
|
+
if (!found)
|
|
529
|
+
return;
|
|
530
|
+
const wheel = this.wheels[found.unit];
|
|
531
|
+
if (wheel.pointer !== event.pointerId)
|
|
532
|
+
return;
|
|
533
|
+
const { row, duration } = this.rowMetrics(found.element);
|
|
534
|
+
this.wheelPress = false;
|
|
535
|
+
if (!wheel.moved) {
|
|
536
|
+
// DTM-19: a press on a row above or below the selection container settles that row on it; one on the middle row
|
|
537
|
+
// that ends without a drag begins a typed entry (DTM-43).
|
|
538
|
+
const box = found.element.getBoundingClientRect();
|
|
539
|
+
const rows = Math.round((event.clientY - (box.top + box.height / 2)) / row);
|
|
540
|
+
wheel.pointer = null;
|
|
541
|
+
if (rows !== 0) {
|
|
542
|
+
this.endEntry(true);
|
|
543
|
+
this.settle(found.unit, found.element, rows);
|
|
544
|
+
}
|
|
545
|
+
else
|
|
546
|
+
this.beginEntry(found.unit, { raise: true });
|
|
547
|
+
return;
|
|
548
|
+
}
|
|
549
|
+
// DTM-19: a fling carries on and slows down (none where motion is reduced), then the nearest row settles.
|
|
550
|
+
const first = wheel.samples[0];
|
|
551
|
+
const velocity = first && event.timeStamp > first.t ? (event.clientY - first.y) / (event.timeStamp - first.t) : 0;
|
|
552
|
+
const carry = duration > 0 ? (-velocity * duration) / 2 / row : 0;
|
|
553
|
+
this.settle(found.unit, found.element, Math.round(wheel.shift + carry));
|
|
554
|
+
};
|
|
555
|
+
this.onWheelPointerCancel = (event) => {
|
|
556
|
+
const found = this.wheelOf(event);
|
|
557
|
+
if (!found)
|
|
558
|
+
return;
|
|
559
|
+
const wheel = this.wheels[found.unit];
|
|
560
|
+
if (wheel.pointer !== event.pointerId)
|
|
561
|
+
return;
|
|
562
|
+
this.wheelPress = false;
|
|
563
|
+
this.settle(found.unit, found.element, Math.round(wheel.shift));
|
|
564
|
+
};
|
|
565
|
+
/** A press on a row of a wheel keeps the focus on the wheel's input: the rows take none, and the page gets none. */
|
|
566
|
+
this.onWheelMouseDown = (event) => {
|
|
567
|
+
if (!(event.target instanceof HTMLInputElement))
|
|
568
|
+
event.preventDefault();
|
|
569
|
+
};
|
|
570
|
+
/** DTM-19: a scroll moves the rows; when it stops, the nearest row settles. */
|
|
571
|
+
this.onWheelScroll = (event) => {
|
|
572
|
+
const found = this.wheelOf(event);
|
|
573
|
+
if (!found || event.ctrlKey || event.deltaY === 0)
|
|
574
|
+
return;
|
|
575
|
+
event.preventDefault();
|
|
576
|
+
// DTM-45: a wheel that is scrolled ends its typed entry, keeping what it read.
|
|
577
|
+
if (this.typed?.unit === found.unit) {
|
|
578
|
+
this.endEntry(true);
|
|
579
|
+
this.alignWheel(found.unit);
|
|
580
|
+
}
|
|
581
|
+
const wheel = this.wheels[found.unit];
|
|
582
|
+
const { row } = this.rowMetrics(found.element);
|
|
583
|
+
const pixels = event.deltaMode === 1 ? event.deltaY * row : event.deltaMode === 2 ? event.deltaY * row * 5 : event.deltaY;
|
|
584
|
+
clearTimeout(wheel.settling);
|
|
585
|
+
wheel.settling = 0;
|
|
586
|
+
wheel.shift += pixels / row;
|
|
587
|
+
clearTimeout(wheel.scrolling);
|
|
588
|
+
wheel.scrolling = window.setTimeout(() => {
|
|
589
|
+
wheel.scrolling = 0;
|
|
590
|
+
this.settle(found.unit, found.element, Math.round(wheel.shift));
|
|
591
|
+
}, WHEEL_QUIET);
|
|
592
|
+
this.wheelFrame++;
|
|
593
|
+
};
|
|
594
|
+
/**
|
|
595
|
+
* DTM-20: the keys of a wheel; the rows move over the wheel motion. DTM-43 … DTM-45: a digit begins or goes on with
|
|
596
|
+
* a typed entry, and while one lasts the keys that move the wheel end it first, keeping what it read.
|
|
597
|
+
*/
|
|
598
|
+
this.onWheelKeyDown = (event) => {
|
|
599
|
+
const found = this.wheelOf(event);
|
|
600
|
+
if (!found || event.altKey || event.ctrlKey || event.metaKey)
|
|
601
|
+
return;
|
|
602
|
+
if (this.entryKey(found.unit, event))
|
|
603
|
+
return this.ringKeyed();
|
|
604
|
+
if (event.key === 'Enter' && this.armed === found.unit) {
|
|
605
|
+
// The keyboard's action key on a wheel that only waits for a digit: it stops waiting.
|
|
606
|
+
event.preventDefault();
|
|
607
|
+
this.armed = null;
|
|
608
|
+
return this.ringKeyed();
|
|
609
|
+
}
|
|
610
|
+
if (!this.keyTime(found.unit, event.key))
|
|
611
|
+
return;
|
|
612
|
+
this.ringKeyed();
|
|
613
|
+
event.preventDefault();
|
|
614
|
+
this.endEntry(true);
|
|
615
|
+
const next = this.keyTime(found.unit, event.key);
|
|
616
|
+
const wheel = this.wheels[found.unit];
|
|
617
|
+
clearTimeout(wheel.settling);
|
|
618
|
+
wheel.settling = 0;
|
|
619
|
+
this.setTime(next);
|
|
620
|
+
};
|
|
621
|
+
/**
|
|
622
|
+
* DTM-20: a wheel shows its ring for focus from the keyboard only. Its control is a text input, which matches
|
|
623
|
+
* `:focus-visible` however it was focused, so the wheel says itself: no ring after a press on it, the ring it was
|
|
624
|
+
* asked for when the picker moved the focus, and the ring otherwise (Tab).
|
|
625
|
+
*/
|
|
626
|
+
this.onSpinFocus = (event) => {
|
|
627
|
+
const input = event.currentTarget;
|
|
628
|
+
syncFocusStyle(this, input);
|
|
629
|
+
const unit = input.dataset.unit;
|
|
630
|
+
const ring = this.nextRing ?? !this.wheelPress;
|
|
631
|
+
this.nextRing = null;
|
|
632
|
+
this.ringed = ring ? unit : this.ringed === unit ? null : this.ringed;
|
|
633
|
+
};
|
|
634
|
+
/** DTM-45: focus leaving a wheel ends its typed entry, keeping what it read. */
|
|
635
|
+
this.onSpinBlur = (event) => {
|
|
636
|
+
const unit = event.currentTarget.dataset.unit;
|
|
637
|
+
if (this.typed?.unit === unit)
|
|
638
|
+
this.endEntry(true);
|
|
639
|
+
if (this.armed === unit)
|
|
640
|
+
this.armed = null;
|
|
641
|
+
if (this.ringed === unit)
|
|
642
|
+
this.ringed = null;
|
|
643
|
+
};
|
|
644
|
+
/**
|
|
645
|
+
* DTM-44: text that reaches a wheel's input without a key the picker read — an on-screen keyboard's digits, a paste —
|
|
646
|
+
* is read as its characters typed in order. The input itself shows only what the entry holds.
|
|
647
|
+
*/
|
|
648
|
+
this.onSpinInput = (event) => {
|
|
649
|
+
const input = event.currentTarget;
|
|
650
|
+
const unit = input.dataset.unit;
|
|
651
|
+
const digits = this.typed?.unit === unit ? this.typed.digits : '';
|
|
652
|
+
const held = [...this.typedText(digits)];
|
|
653
|
+
const text = [...input.value];
|
|
654
|
+
input.value = held.join('');
|
|
655
|
+
if (event.inputType === 'insertLineBreak') {
|
|
656
|
+
this.endEntry(true);
|
|
657
|
+
this.armed = null;
|
|
658
|
+
}
|
|
659
|
+
else if (text.length < held.length)
|
|
660
|
+
this.typed = this.typed && { ...this.typed, digits: digits.slice(0, text.length) };
|
|
661
|
+
else
|
|
662
|
+
this.readTyped(unit, (held.every((char, i) => text[i] === char) ? text.slice(held.length) : text).join(''));
|
|
663
|
+
this.ringKeyed();
|
|
664
|
+
};
|
|
665
|
+
/** DTM-14: the period selector — a press, Enter or Space changes it to the other period; it shows no unit and is never selected. */
|
|
666
|
+
this.periodHandlers = {
|
|
667
|
+
onPointerDown: (event) => {
|
|
668
|
+
// DTM-45: a press ends a typed entry, keeping what it read.
|
|
669
|
+
this.endEntry(true);
|
|
670
|
+
this.periodPress.onPointerDown(event);
|
|
671
|
+
},
|
|
672
|
+
onClick: () => this.setPeriod(periodOf(this.time.hour) ? 0 : 1),
|
|
673
|
+
onKeyDown: (event) => {
|
|
674
|
+
const period = this.periodKey(event, true);
|
|
675
|
+
if (period === null)
|
|
676
|
+
return;
|
|
677
|
+
event.preventDefault();
|
|
678
|
+
this.ringPeriod();
|
|
679
|
+
if (event.repeat && (event.key === 'Enter' || event.key === ' '))
|
|
680
|
+
return;
|
|
681
|
+
this.periodPress.onKeyDown(event);
|
|
682
|
+
this.setPeriod(period);
|
|
683
|
+
},
|
|
684
|
+
/**
|
|
685
|
+
* DTM-47: the period shows its ring for keyboard focus only — what the picker asked for when it moved the focus
|
|
686
|
+
* (none after a press on the period wheel), otherwise what the browser says of how focus arrived (Tab, or a press).
|
|
687
|
+
*/
|
|
688
|
+
onFocus: (event) => {
|
|
689
|
+
const control = event.currentTarget;
|
|
690
|
+
syncFocusStyle(this, control);
|
|
691
|
+
const ring = this.nextRing ?? control.matches(':focus-visible');
|
|
692
|
+
this.nextRing = null;
|
|
693
|
+
this.ringed = ring ? 'period' : this.ringed === 'period' ? null : this.ringed;
|
|
694
|
+
},
|
|
695
|
+
onBlur: () => {
|
|
696
|
+
if (this.ringed === 'period')
|
|
697
|
+
this.ringed = null;
|
|
698
|
+
},
|
|
699
|
+
};
|
|
700
|
+
this.onPeriodPointerDown = (event) => {
|
|
701
|
+
const element = event.currentTarget;
|
|
702
|
+
const wheel = this.periodWheel;
|
|
703
|
+
if ((event.pointerType === 'mouse' && event.button !== 0) || wheel.pointer !== null)
|
|
704
|
+
return;
|
|
705
|
+
// DTM-45: a press on another wheel is a press elsewhere, and ends a typed entry.
|
|
706
|
+
this.endEntry(true);
|
|
707
|
+
// DTM-47: the wheel takes focus on its control, whichever row is pressed; a pressed wheel shows no ring.
|
|
708
|
+
const control = this.periodControl;
|
|
709
|
+
if (control && deepActive() !== control) {
|
|
710
|
+
this.nextRing = false;
|
|
711
|
+
control.focus({ preventScroll: true, focusVisible: false });
|
|
712
|
+
this.nextRing = null;
|
|
713
|
+
}
|
|
714
|
+
clearTimeout(wheel.settling);
|
|
715
|
+
if (wheel.settling) {
|
|
716
|
+
wheel.settling = 0;
|
|
717
|
+
this.setPeriod(wheel.at ? 1 : 0);
|
|
718
|
+
}
|
|
719
|
+
wheel.pointer = event.pointerId;
|
|
720
|
+
wheel.startY = event.clientY;
|
|
721
|
+
wheel.moved = false;
|
|
722
|
+
wheel.shift = 0;
|
|
723
|
+
wheel.samples = [{ y: event.clientY, t: event.timeStamp }];
|
|
724
|
+
element.setPointerCapture?.(event.pointerId);
|
|
725
|
+
};
|
|
726
|
+
this.onPeriodPointerMove = (event) => {
|
|
727
|
+
const wheel = this.periodWheel;
|
|
728
|
+
if (wheel.pointer !== event.pointerId)
|
|
729
|
+
return;
|
|
730
|
+
const dy = event.clientY - wheel.startY;
|
|
731
|
+
if (!wheel.moved && Math.abs(dy) <= SHEET_TOUCH_SLOP)
|
|
732
|
+
return;
|
|
733
|
+
wheel.moved = true;
|
|
734
|
+
const { row } = this.rowMetrics(event.currentTarget);
|
|
735
|
+
// DTM-46: the rows move with the pointer and stop at the first and the last name.
|
|
736
|
+
wheel.shift = this.periodShift(-dy / row);
|
|
737
|
+
wheel.samples = [...wheel.samples.filter((sample) => event.timeStamp - sample.t <= VELOCITY_WINDOW), { y: event.clientY, t: event.timeStamp }];
|
|
738
|
+
this.wheelFrame++;
|
|
739
|
+
};
|
|
740
|
+
this.onPeriodPointerUp = (event) => {
|
|
741
|
+
const element = event.currentTarget;
|
|
742
|
+
const wheel = this.periodWheel;
|
|
743
|
+
if (wheel.pointer !== event.pointerId)
|
|
744
|
+
return;
|
|
745
|
+
const { row, duration } = this.rowMetrics(element);
|
|
746
|
+
if (!wheel.moved) {
|
|
747
|
+
// DTM-46: a press on the other name's row settles it; a press on the middle row settles the other name too — a
|
|
748
|
+
// period is not typed, so the press begins no entry.
|
|
749
|
+
const box = element.getBoundingClientRect();
|
|
750
|
+
const rows = Math.round((event.clientY - (box.top + box.height / 2)) / row);
|
|
751
|
+
this.settlePeriod(element, rows === 0 ? 1 - wheel.at : wheel.at + rows);
|
|
752
|
+
return;
|
|
753
|
+
}
|
|
754
|
+
const first = wheel.samples[0];
|
|
755
|
+
const velocity = first && event.timeStamp > first.t ? (event.clientY - first.y) / (event.timeStamp - first.t) : 0;
|
|
756
|
+
const carry = duration > 0 ? (-velocity * duration) / 2 / row : 0;
|
|
757
|
+
this.settlePeriod(element, wheel.at + wheel.shift + carry);
|
|
758
|
+
};
|
|
759
|
+
this.onPeriodPointerCancel = (event) => {
|
|
760
|
+
const wheel = this.periodWheel;
|
|
761
|
+
if (wheel.pointer !== event.pointerId)
|
|
762
|
+
return;
|
|
763
|
+
this.settlePeriod(event.currentTarget, wheel.at + wheel.shift);
|
|
764
|
+
};
|
|
765
|
+
/** DTM-46: a scroll moves the rows, to the first and the last name at most; when it stops, the nearer name settles. */
|
|
766
|
+
this.onPeriodScroll = (event) => {
|
|
767
|
+
if (event.ctrlKey || event.deltaY === 0)
|
|
768
|
+
return;
|
|
769
|
+
event.preventDefault();
|
|
770
|
+
this.endEntry(true);
|
|
771
|
+
const element = event.currentTarget;
|
|
772
|
+
const wheel = this.periodWheel;
|
|
773
|
+
const { row } = this.rowMetrics(element);
|
|
774
|
+
const pixels = event.deltaMode === 0 ? event.deltaY : event.deltaY * row;
|
|
775
|
+
clearTimeout(wheel.settling);
|
|
776
|
+
wheel.settling = 0;
|
|
777
|
+
wheel.shift = this.periodShift(wheel.shift + pixels / row);
|
|
778
|
+
clearTimeout(wheel.scrolling);
|
|
779
|
+
wheel.scrolling = window.setTimeout(() => {
|
|
780
|
+
wheel.scrolling = 0;
|
|
781
|
+
this.settlePeriod(element, wheel.at + wheel.shift);
|
|
782
|
+
}, WHEEL_QUIET);
|
|
783
|
+
this.wheelFrame++;
|
|
784
|
+
};
|
|
785
|
+
this.onPeriodKeyDown = (event) => {
|
|
786
|
+
const period = this.periodKey(event, false);
|
|
787
|
+
if (period === null)
|
|
788
|
+
return;
|
|
789
|
+
event.preventDefault();
|
|
790
|
+
this.ringPeriod();
|
|
791
|
+
if (event.repeat && (event.key === 'Enter' || event.key === ' '))
|
|
792
|
+
return;
|
|
793
|
+
const wheel = this.periodWheel;
|
|
794
|
+
clearTimeout(wheel.settling);
|
|
795
|
+
wheel.settling = 0;
|
|
796
|
+
this.setPeriod(period);
|
|
797
|
+
};
|
|
798
|
+
this.selectorHandlers = (unit) => {
|
|
799
|
+
const press = this.presses[unit];
|
|
800
|
+
return {
|
|
801
|
+
onPointerDown: (event) => {
|
|
802
|
+
// DTM-45: a press ends a typed entry, keeping what it read.
|
|
803
|
+
this.endEntry(true);
|
|
804
|
+
press.onPointerDown(event);
|
|
805
|
+
this.showUnit(unit);
|
|
806
|
+
},
|
|
807
|
+
onKeyDown: (event) => {
|
|
808
|
+
if (event.altKey || event.ctrlKey || event.metaKey)
|
|
809
|
+
return;
|
|
810
|
+
// DTM-22: digits typed on a selector are read as a wheel's typed entry is; the dial mode raises no keyboard.
|
|
811
|
+
if (this.entryKey(unit, event))
|
|
812
|
+
return;
|
|
813
|
+
press.onKeyDown(event);
|
|
814
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
815
|
+
event.preventDefault();
|
|
816
|
+
this.showUnit(unit);
|
|
817
|
+
return;
|
|
818
|
+
}
|
|
819
|
+
// DTM-22: Right and Left as Up and Down (a time is written left to right in every direction).
|
|
820
|
+
const key = event.key === 'ArrowRight' ? 'ArrowUp' : event.key === 'ArrowLeft' ? 'ArrowDown' : event.key;
|
|
821
|
+
if (!this.keyTime(unit, key))
|
|
822
|
+
return;
|
|
823
|
+
event.preventDefault();
|
|
824
|
+
// DTM-45: the keys that move the value end a typed entry first, keeping what it read.
|
|
825
|
+
this.endEntry(true);
|
|
826
|
+
this.showUnit(unit);
|
|
827
|
+
this.instant = false;
|
|
828
|
+
this.setTime(this.keyTime(unit, key));
|
|
829
|
+
},
|
|
830
|
+
onFocus: (event) => {
|
|
831
|
+
syncFocusStyle(this, event.currentTarget);
|
|
832
|
+
if (!this.presenting)
|
|
833
|
+
this.showUnit(unit);
|
|
834
|
+
},
|
|
835
|
+
onBlur: () => {
|
|
836
|
+
press.onBlur();
|
|
837
|
+
// DTM-45: focus leaving ends a typed entry, keeping what it read.
|
|
838
|
+
if (this.typed?.unit === unit)
|
|
839
|
+
this.endEntry(true);
|
|
840
|
+
},
|
|
841
|
+
};
|
|
842
|
+
};
|
|
843
|
+
this.hourHandlers = this.selectorHandlers('hour');
|
|
844
|
+
this.minuteHandlers = this.selectorHandlers('minute');
|
|
845
|
+
this.onDialDown = (event) => {
|
|
846
|
+
if (this.dragging !== null || (event.pointerType === 'mouse' && event.button !== 0))
|
|
847
|
+
return;
|
|
848
|
+
// DTM-45: a press elsewhere in the picker ends a typed entry, keeping what it read.
|
|
849
|
+
this.endEntry(true);
|
|
850
|
+
// No focus change and no text selection: focus stays where it is (on a selector, DTM-25).
|
|
851
|
+
event.preventDefault();
|
|
852
|
+
this.dragging = event.pointerId;
|
|
853
|
+
event.currentTarget.setPointerCapture?.(event.pointerId);
|
|
854
|
+
this.instant = true;
|
|
855
|
+
this.setFromPoint(event);
|
|
856
|
+
};
|
|
857
|
+
this.onDialMove = (event) => {
|
|
858
|
+
if (event.pointerId !== this.dragging)
|
|
859
|
+
return;
|
|
860
|
+
this.setFromPoint(event);
|
|
861
|
+
};
|
|
862
|
+
/** DTM-25: a press or drag on the hour dial ends — the minute dial, its selector selected, and focus moved there from the hour's. */
|
|
863
|
+
this.onDialUp = (event) => {
|
|
864
|
+
if (event.pointerId !== this.dragging)
|
|
865
|
+
return;
|
|
866
|
+
this.dragging = null;
|
|
867
|
+
this.instant = false;
|
|
868
|
+
if (this.shownUnit !== 'hour')
|
|
869
|
+
return;
|
|
870
|
+
const hour = this.renderRoot.querySelector(".selector[data-unit='hour']");
|
|
871
|
+
const hourHadFocus = !!hour && deepActive() === hour;
|
|
872
|
+
this.shownUnit = 'minute';
|
|
873
|
+
if (hourHadFocus) {
|
|
874
|
+
const ring = hour.matches(':focus-visible');
|
|
875
|
+
void this.updateComplete.then(() => this.renderRoot.querySelector(".selector[data-unit='minute']")?.focus({ focusVisible: ring }));
|
|
876
|
+
}
|
|
877
|
+
};
|
|
878
|
+
this.onDialCancel = (event) => {
|
|
879
|
+
if (event.pointerId !== this.dragging)
|
|
880
|
+
return;
|
|
881
|
+
this.dragging = null;
|
|
882
|
+
this.instant = false;
|
|
883
|
+
};
|
|
884
|
+
/** DTM-5: Escape; Tab (the modal keeps focus in, the docked one lets it leave and closes). */
|
|
885
|
+
this.onSurfaceKeyDown = (event) => {
|
|
886
|
+
if (event.key === 'Escape') {
|
|
887
|
+
// DTM-45: the Escape that ended a typed entry closes nothing.
|
|
888
|
+
if (event.defaultPrevented || event.timeStamp === this.escapeSpent)
|
|
889
|
+
return;
|
|
890
|
+
event.preventDefault();
|
|
891
|
+
event.stopPropagation();
|
|
892
|
+
this.requestClose('escape');
|
|
893
|
+
return;
|
|
894
|
+
}
|
|
895
|
+
if (event.key !== 'Tab' || this.inline)
|
|
896
|
+
return;
|
|
897
|
+
const surface = this.surface;
|
|
898
|
+
if (!surface)
|
|
899
|
+
return;
|
|
900
|
+
if (this.modal) {
|
|
901
|
+
trapFocus(event, surface);
|
|
902
|
+
return;
|
|
903
|
+
}
|
|
904
|
+
const order = tabbables(surface);
|
|
905
|
+
const active = deepActive();
|
|
906
|
+
const at = (element) => !!element && (active === element || (!!active && !!element.shadowRoot?.contains(active)));
|
|
907
|
+
const leaving = order.length === 0 || (event.shiftKey ? at(order[0]) : at(order[order.length - 1]));
|
|
908
|
+
if (!leaving)
|
|
909
|
+
return;
|
|
910
|
+
// Focus goes back first, so that the Tab's own move goes on from there, as it would have from the anchor; the surface,
|
|
911
|
+
// still drawn while it closes, is inert, so that the move cannot land back in it.
|
|
912
|
+
this.requestClose('tab');
|
|
913
|
+
surface.inert = true;
|
|
914
|
+
requestAnimationFrame(() => {
|
|
915
|
+
if (this.open && this.shown)
|
|
916
|
+
surface.inert = false;
|
|
917
|
+
});
|
|
918
|
+
this.returnFocus();
|
|
919
|
+
};
|
|
920
|
+
/** DTM-5: the native dialog's cancel is `escape` when an Escape key caused it, and the platform's `back` otherwise. */
|
|
921
|
+
this.onNativeCancel = (event) => {
|
|
922
|
+
event.preventDefault();
|
|
923
|
+
// DTM-45: a close request the Escape of a typed entry still caused closes nothing — one press never both discards
|
|
924
|
+
// a number and dismisses the surface.
|
|
925
|
+
if (event.timeStamp - this.escapeSpent < 500)
|
|
926
|
+
return;
|
|
927
|
+
this.requestClose(closeRequestReason(event));
|
|
928
|
+
};
|
|
929
|
+
/** DTM-45: a press elsewhere in the picker — anywhere but the wheel or the selector the entry is on — ends a typed entry, keeping what it read. */
|
|
930
|
+
this.onSurfacePointerDown = (event) => {
|
|
931
|
+
const typed = this.typed;
|
|
932
|
+
if (!typed)
|
|
933
|
+
return;
|
|
934
|
+
const own = event.composedPath().some((node) => node instanceof HTMLElement && node.matches('.wheel, .selector') && node.dataset.unit === typed.unit);
|
|
935
|
+
if (!own)
|
|
936
|
+
this.endEntry(true);
|
|
937
|
+
};
|
|
938
|
+
/** DTM-5: a press that starts and ends on a modal picker's scrim. */
|
|
939
|
+
this.onDialogPointerDown = (event) => {
|
|
940
|
+
this.onSurfacePointerDown(event);
|
|
941
|
+
this.pressedScrim = this.onScrim(event);
|
|
942
|
+
};
|
|
943
|
+
this.onDialogClick = (event) => {
|
|
944
|
+
const scrim = this.pressedScrim && this.onScrim(event);
|
|
945
|
+
this.pressedScrim = false;
|
|
946
|
+
if (scrim)
|
|
947
|
+
this.requestClose('outside');
|
|
948
|
+
};
|
|
949
|
+
/** A press on something in the docked surface that takes no focus keeps focus where it is. */
|
|
950
|
+
this.onSurfaceMouseDown = (event) => {
|
|
951
|
+
if (this.modal)
|
|
952
|
+
return;
|
|
953
|
+
const focusable = event
|
|
954
|
+
.composedPath()
|
|
955
|
+
.some((node) => node instanceof HTMLElement && node.matches('input, button, [tabindex], tanrei-button, tanrei-tab, tanrei-calendar, .wheel, .selector'));
|
|
956
|
+
if (!focusable)
|
|
957
|
+
event.preventDefault();
|
|
958
|
+
};
|
|
959
|
+
/** DTM-5: focus moving out of a docked picker — anywhere but its anchor and opener — asks to close. */
|
|
960
|
+
this.onFocusOut = (event) => {
|
|
961
|
+
if (!this.open || this.inline || !this.cfg || this.modal)
|
|
962
|
+
return;
|
|
963
|
+
const to = event.relatedTarget;
|
|
964
|
+
if (!to || to === this || this.contains(to) || this.renderRoot.contains(to) || this.atAnchor(to))
|
|
965
|
+
return;
|
|
966
|
+
if (to instanceof Element && to.getRootNode().host && this.renderRoot.contains(to.getRootNode().host))
|
|
967
|
+
return;
|
|
968
|
+
this.requestClose('focus-out');
|
|
969
|
+
};
|
|
970
|
+
/** DTM-5: a press outside a docked picker and its anchor asks to close; the press also reaches what is under it. */
|
|
971
|
+
this.onOutsidePress = (event) => {
|
|
972
|
+
const path = event.composedPath();
|
|
973
|
+
if (path.includes(this) || path.some((node) => node instanceof Node && this.atAnchor(node)))
|
|
974
|
+
return;
|
|
975
|
+
this.requestClose('outside');
|
|
976
|
+
};
|
|
977
|
+
/**
|
|
978
|
+
* DTM-2: the docked container follows its anchor while it moves (scrolling, layout, the viewport) — asked by
|
|
979
|
+
* FollowController when something can have moved, frame by frame only while something does.
|
|
980
|
+
*/
|
|
981
|
+
this.follow = () => {
|
|
982
|
+
const box = this.anchorElement?.getBoundingClientRect();
|
|
983
|
+
const body = this.renderRoot.querySelector('.body');
|
|
984
|
+
// DTM-41: the layout direction too — the start edges are aligned (DTM-2), so a change of it places the container again.
|
|
985
|
+
const layout = `${box?.x},${box?.y},${box?.width},${box?.height},${document.documentElement.clientWidth},${document.documentElement.clientHeight},${body?.scrollHeight},${getComputedStyle(this).direction}`;
|
|
986
|
+
if (layout === this.lastLayout)
|
|
987
|
+
return false;
|
|
988
|
+
this.lastLayout = layout;
|
|
989
|
+
this.place();
|
|
990
|
+
return true;
|
|
991
|
+
};
|
|
992
|
+
this.following = new FollowController(this, {
|
|
993
|
+
followed: () => [this.anchorElement],
|
|
994
|
+
sized: () => [this.surface, this.renderRoot?.querySelector('.body')],
|
|
995
|
+
check: this.follow,
|
|
996
|
+
});
|
|
997
|
+
/** DTM-1: above the on-screen keyboard; DTM-9: the layout is decided again when the window changes. */
|
|
998
|
+
this.onWindow = () => {
|
|
999
|
+
const cover = keyboardCover();
|
|
1000
|
+
this.surface?.style.setProperty('--_keyboard', `${cover}px`);
|
|
1001
|
+
// DTM-45: the on-screen keyboard dismissed ends a typed entry, keeping what it read.
|
|
1002
|
+
if (this.keyboard > 0 && cover === 0) {
|
|
1003
|
+
this.endEntry(true);
|
|
1004
|
+
this.armed = null;
|
|
1005
|
+
}
|
|
1006
|
+
this.keyboard = cover;
|
|
1007
|
+
this.arrange();
|
|
1008
|
+
};
|
|
1009
|
+
this.addEventListener('focusout', this.onFocusOut);
|
|
1010
|
+
}
|
|
1011
|
+
connectedCallback() {
|
|
1012
|
+
super.connectedCallback();
|
|
1013
|
+
if (this.hasUpdated && this.open) {
|
|
1014
|
+
this.requestUpdate();
|
|
1015
|
+
void this.updateComplete.then(() => this.present());
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
disconnectedCallback() {
|
|
1019
|
+
super.disconnectedCallback();
|
|
1020
|
+
this.resize$?.disconnect();
|
|
1021
|
+
this.stopFollowing();
|
|
1022
|
+
this.listen(false);
|
|
1023
|
+
window.removeEventListener('resize', this.onWindow);
|
|
1024
|
+
if (this.shown)
|
|
1025
|
+
this.withdraw(false);
|
|
1026
|
+
}
|
|
1027
|
+
// ── Reading the props (DTM-16, DTM-17, DTM-38, DTM-40) ───────────────────────────────────────────────────────────
|
|
1028
|
+
closed(values, value, fallback, name) {
|
|
1029
|
+
if (values.includes(value))
|
|
1030
|
+
return value;
|
|
1031
|
+
report(this, 'DTM-40', `${name} "${value}" is not a value the date-time picker defines; it behaves as "${fallback}"`);
|
|
1032
|
+
return fallback;
|
|
1033
|
+
}
|
|
1034
|
+
/** DTM-38: `locale`, else the nearest `lang` (through shadow roots), else the browser's language; English when `Intl` does not know it. */
|
|
1035
|
+
resolveLocale() {
|
|
1036
|
+
const tag = this.locale.trim();
|
|
1037
|
+
if (!tag)
|
|
1038
|
+
return ambientLocale(this);
|
|
1039
|
+
const known = supportedLocale(tag);
|
|
1040
|
+
if (!known)
|
|
1041
|
+
report(this, 'DTM-38', `locale "${tag}" is not a BCP 47 tag this browser knows; it uses "${FALLBACK_LOCALE}"`);
|
|
1042
|
+
return known ?? FALLBACK_LOCALE;
|
|
1043
|
+
}
|
|
1044
|
+
/** DTM-8, DTM-40: a value in the mode's form as a moment, or null (reported) when it is not one. */
|
|
1045
|
+
parseMoment(name, text, mode) {
|
|
1046
|
+
if (!text)
|
|
1047
|
+
return null;
|
|
1048
|
+
let moment = null;
|
|
1049
|
+
if (mode === 'date') {
|
|
1050
|
+
const date = parseIsoDate(text);
|
|
1051
|
+
moment = date ? { date, time: null } : null;
|
|
1052
|
+
}
|
|
1053
|
+
else if (mode === 'time') {
|
|
1054
|
+
const time = parseClockTime(text);
|
|
1055
|
+
moment = time ? { date: null, time } : null;
|
|
1056
|
+
}
|
|
1057
|
+
else {
|
|
1058
|
+
const [date, time, ...rest] = text.split('T');
|
|
1059
|
+
const d = parseIsoDate(date);
|
|
1060
|
+
const t = parseClockTime(time);
|
|
1061
|
+
moment = d && t && !rest.length ? { date: d, time: t } : null;
|
|
1062
|
+
}
|
|
1063
|
+
if (!moment) {
|
|
1064
|
+
const form = mode === 'date' ? 'YYYY-MM-DD' : mode === 'time' ? 'HH:MM' : 'YYYY-MM-DDTHH:MM';
|
|
1065
|
+
report(this, 'DTM-40', `${name} "${text}" is not in the ${mode} mode's form (${form}); it is ignored`);
|
|
1066
|
+
}
|
|
1067
|
+
return moment;
|
|
1068
|
+
}
|
|
1069
|
+
readConfig() {
|
|
1070
|
+
const presentation = this.closed(PRESENTATIONS, this.presentation, 'modal', 'presentation');
|
|
1071
|
+
const mode = this.closed(MODES, this.mode, 'date', 'mode');
|
|
1072
|
+
const hourCycle = this.closed(HOUR_CYCLES, this.hourCycle, 'locale', 'hourCycle');
|
|
1073
|
+
const entryMode = this.closed(ENTRY_MODES, this.entryMode, 'wheels', 'entryMode');
|
|
1074
|
+
const unit = this.closed(UNITS, this.unit, 'hour', 'unit');
|
|
1075
|
+
const layout = this.closed(LAYOUTS, this.layout, 'auto', 'layout');
|
|
1076
|
+
const firstDayOfWeek = this.closed(FIRST_DAYS, this.firstDayOfWeek, 'locale', 'firstDayOfWeek');
|
|
1077
|
+
const startView = this.closed(START_VIEWS, this.startView, 'day', 'startView');
|
|
1078
|
+
const range = !!this.range;
|
|
1079
|
+
const locale = this.resolveLocale();
|
|
1080
|
+
// A 12-hour clock needs the locale's own period names: Tanrei has no "AM" and "PM" of its own to stand in.
|
|
1081
|
+
const cycle = hourCycle === 'locale' ? localeHourCycle(locale) : clockFor(locale, hourCycle);
|
|
1082
|
+
const step = Number(this.minuteStep);
|
|
1083
|
+
const known = MINUTE_STEPS.includes(step);
|
|
1084
|
+
if (!known)
|
|
1085
|
+
report(this, 'DTM-17', `minuteStep "${this.minuteStep}" is not 1, 5, 10, 15 or 30; it behaves as 1`);
|
|
1086
|
+
const isoDate = (name, text) => {
|
|
1087
|
+
if (!text)
|
|
1088
|
+
return '';
|
|
1089
|
+
if (parseIsoDate(text))
|
|
1090
|
+
return text;
|
|
1091
|
+
report(this, 'DTM-40', `${name} "${text}" is not an ISO 8601 calendar date (YYYY-MM-DD); it is ignored`);
|
|
1092
|
+
return '';
|
|
1093
|
+
};
|
|
1094
|
+
let min = isoDate('min', this.min);
|
|
1095
|
+
let max = isoDate('max', this.max);
|
|
1096
|
+
if (min && max && min > max) {
|
|
1097
|
+
report(this, 'DTM-40', `min "${this.min}" is after max "${this.max}"; both are ignored`);
|
|
1098
|
+
min = '';
|
|
1099
|
+
max = '';
|
|
1100
|
+
}
|
|
1101
|
+
const today = isoDate('today', this.today);
|
|
1102
|
+
const disabledDates = (this.disabledDates ?? []).filter((entry) => isoDate('an entry of disabledDates', entry) !== '');
|
|
1103
|
+
let value = this.parseMoment('value', this.value, mode);
|
|
1104
|
+
let start = this.parseMoment('start', this.start, mode);
|
|
1105
|
+
let end = this.parseMoment('end', this.end, mode);
|
|
1106
|
+
if (range && value) {
|
|
1107
|
+
report(this, 'DTM-40', `value "${this.value}" is set while range is true, where the choice is start and end; it is ignored`);
|
|
1108
|
+
value = null;
|
|
1109
|
+
}
|
|
1110
|
+
if (!range && (start || end)) {
|
|
1111
|
+
report(this, 'DTM-40', 'start or end is set while range is false, where the choice is value; they are ignored');
|
|
1112
|
+
start = null;
|
|
1113
|
+
end = null;
|
|
1114
|
+
}
|
|
1115
|
+
if (start && end && mode !== 'time' && this.momentText(end, mode) < this.momentText(start, mode)) {
|
|
1116
|
+
report(this, 'DTM-40', `end "${this.end}" is before start "${this.start}"; the end is ignored`);
|
|
1117
|
+
end = null;
|
|
1118
|
+
}
|
|
1119
|
+
const committed = { value: value ?? EMPTY, start: start ?? EMPTY, end: end ?? EMPTY };
|
|
1120
|
+
return { presentation, mode, range, cycle, step: known ? step : 1, entryMode, unit, layout, locale, min, max, today, disabledDates, firstDayOfWeek, startView, committed };
|
|
1121
|
+
}
|
|
1122
|
+
/** DTM-8: a moment in the mode's form; `""` while a part the mode needs is missing. */
|
|
1123
|
+
momentText(moment, mode = this.cfg.mode) {
|
|
1124
|
+
if (mode === 'date')
|
|
1125
|
+
return moment.date ? isoOf(moment.date) : '';
|
|
1126
|
+
if (mode === 'time')
|
|
1127
|
+
return moment.time ? clockText(moment.time) : '';
|
|
1128
|
+
return moment.date && moment.time ? `${isoOf(moment.date)}T${clockText(moment.time)}` : '';
|
|
1129
|
+
}
|
|
1130
|
+
detailOf(choice) {
|
|
1131
|
+
return this.cfg.range
|
|
1132
|
+
? { value: '', start: this.momentText(choice.start), end: this.momentText(choice.end) }
|
|
1133
|
+
: { value: this.momentText(choice.value), start: '', end: '' };
|
|
1134
|
+
}
|
|
1135
|
+
// ── The session: what a picker holds from opening to closing (DTM-6, DTM-8) ─────────────────────────────────────
|
|
1136
|
+
get hasDate() {
|
|
1137
|
+
return this.cfg.mode !== 'time';
|
|
1138
|
+
}
|
|
1139
|
+
get hasTime() {
|
|
1140
|
+
return this.cfg.mode !== 'date';
|
|
1141
|
+
}
|
|
1142
|
+
get modal() {
|
|
1143
|
+
return this.cfg.presentation === 'modal';
|
|
1144
|
+
}
|
|
1145
|
+
/** DTM-6, DTM-7: whether the choice is pending until OK (every picker but a docked one for a date only). */
|
|
1146
|
+
get pendingUntilOk() {
|
|
1147
|
+
return this.modal || this.hasTime;
|
|
1148
|
+
}
|
|
1149
|
+
/** DTM-13: the entry modes the design system offers, read from the cascade now. */
|
|
1150
|
+
get offered() {
|
|
1151
|
+
return compChoice(this, `${PREFIX}-time-entry-modes`, OFFERED);
|
|
1152
|
+
}
|
|
1153
|
+
/** The entry mode shown: the one chosen, or the only one offered (DTM-13). */
|
|
1154
|
+
get shownEntry() {
|
|
1155
|
+
const offered = this.offered;
|
|
1156
|
+
return offered === 'both' ? this.entry : offered;
|
|
1157
|
+
}
|
|
1158
|
+
initSession() {
|
|
1159
|
+
this.session = true;
|
|
1160
|
+
this.cfg = this.readConfig();
|
|
1161
|
+
const { committed, step, entryMode, unit, range } = this.cfg;
|
|
1162
|
+
this.openedWith = { value: this.momentText(committed.value), start: this.momentText(committed.start), end: this.momentText(committed.end) };
|
|
1163
|
+
// DTM-8: an empty time starts at the device's time; a minute off the step is rounded down to it.
|
|
1164
|
+
const now = roundDown(deviceTime(), step);
|
|
1165
|
+
const fill = (moment) => (this.hasTime ? { ...moment, time: moment.time ? roundDown(moment.time, step) : now } : moment);
|
|
1166
|
+
this.pending = { value: fill(committed.value), start: fill(committed.start), end: fill(committed.end) };
|
|
1167
|
+
this.editing = range ? 'start' : 'value';
|
|
1168
|
+
this.entry = entryMode;
|
|
1169
|
+
this.shownUnit = unit;
|
|
1170
|
+
this.instant = true;
|
|
1171
|
+
this.angle = this.targetAngle();
|
|
1172
|
+
this.errorShown = false;
|
|
1173
|
+
this.typed = null;
|
|
1174
|
+
this.armed = null;
|
|
1175
|
+
this.ringed = null;
|
|
1176
|
+
for (const wheel of [...Object.values(this.wheels), this.periodWheel]) {
|
|
1177
|
+
clearTimeout(wheel.settling);
|
|
1178
|
+
clearTimeout(wheel.scrolling);
|
|
1179
|
+
Object.assign(wheel, { shift: 0, pointer: null, moved: false, samples: [], settling: 0, scrolling: 0 });
|
|
1180
|
+
}
|
|
1181
|
+
this.syncWheels(true);
|
|
1182
|
+
}
|
|
1183
|
+
/** The pending time of the end the time section sets. */
|
|
1184
|
+
get time() {
|
|
1185
|
+
return this.pending[this.editing].time ?? { hour: 0, minute: 0 };
|
|
1186
|
+
}
|
|
1187
|
+
setTime(time) {
|
|
1188
|
+
this.pending = { ...this.pending, [this.editing]: { ...this.pending[this.editing], time } };
|
|
1189
|
+
}
|
|
1190
|
+
/** DTM-6: OK is enabled while the pending choice is complete and a date-time range's end is not before its start. */
|
|
1191
|
+
get confirmable() {
|
|
1192
|
+
const { range, mode } = this.cfg;
|
|
1193
|
+
if (!range)
|
|
1194
|
+
return this.momentText(this.pending.value) !== '';
|
|
1195
|
+
if (!this.momentText(this.pending.start) || !this.momentText(this.pending.end))
|
|
1196
|
+
return false;
|
|
1197
|
+
return !(mode === 'date-time' && this.rangeError);
|
|
1198
|
+
}
|
|
1199
|
+
/** DTM-33: a date-time range whose pending end is before its start. */
|
|
1200
|
+
get rangeError() {
|
|
1201
|
+
const { range, mode } = this.cfg;
|
|
1202
|
+
if (!range || mode !== 'date-time')
|
|
1203
|
+
return false;
|
|
1204
|
+
const [start, end] = [this.momentText(this.pending.start), this.momentText(this.pending.end)];
|
|
1205
|
+
return !!start && !!end && end < start;
|
|
1206
|
+
}
|
|
1207
|
+
/** DTM-33: a time range's end at or before its start falls on the next day. */
|
|
1208
|
+
get nextDay() {
|
|
1209
|
+
const { range, mode } = this.cfg;
|
|
1210
|
+
const { start, end } = this.pending;
|
|
1211
|
+
if (!range || mode !== 'time' || !start.time || !end.time)
|
|
1212
|
+
return false;
|
|
1213
|
+
return end.time.hour * 60 + end.time.minute <= start.time.hour * 60 + start.time.minute;
|
|
1214
|
+
}
|
|
1215
|
+
// ── Committing and closing (DTM-5 … DTM-7) ────────────────────────────────────────────────────────────────────────
|
|
1216
|
+
/** DTM-6, DTM-7: the pending choice becomes the element's — `change` if it differs — then `close` with the reason. */
|
|
1217
|
+
commit(reason) {
|
|
1218
|
+
if (!this.open || this.closeRequested)
|
|
1219
|
+
return;
|
|
1220
|
+
const next = this.detailOf(this.pending);
|
|
1221
|
+
const before = this.pendingUntilOk ? this.openedWith : { value: this.value, start: this.start, end: this.end };
|
|
1222
|
+
const changed = this.cfg.range ? next.start !== before.start || next.end !== before.end : next.value !== before.value;
|
|
1223
|
+
if (changed) {
|
|
1224
|
+
if (this.cfg.range) {
|
|
1225
|
+
this.start = next.start;
|
|
1226
|
+
this.end = next.end;
|
|
1227
|
+
}
|
|
1228
|
+
else
|
|
1229
|
+
this.value = next.value;
|
|
1230
|
+
this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: next }));
|
|
1231
|
+
}
|
|
1232
|
+
this.requestClose(reason);
|
|
1233
|
+
}
|
|
1234
|
+
/** DTM-5: asks the product to close the picker, once, with the reason. */
|
|
1235
|
+
requestClose(reason) {
|
|
1236
|
+
if (!this.open || this.closeRequested)
|
|
1237
|
+
return;
|
|
1238
|
+
this.closeRequested = true;
|
|
1239
|
+
this.dispatchEvent(new CustomEvent('close', { detail: { reason } }));
|
|
1240
|
+
}
|
|
1241
|
+
/**
|
|
1242
|
+
* DTM-42: the range field of `end` becomes the selected one — the wheels, the time display, the period and the
|
|
1243
|
+
* dial show and set that end's pending time (moving to it, DTM-26). A typed entry ends first; no pending time changes
|
|
1244
|
+
* and nothing is emitted. Selecting the selected one changes nothing.
|
|
1245
|
+
*/
|
|
1246
|
+
selectEnd(end) {
|
|
1247
|
+
if (this.editing === end)
|
|
1248
|
+
return;
|
|
1249
|
+
this.endEntry(true);
|
|
1250
|
+
this.instant = false;
|
|
1251
|
+
this.editing = end;
|
|
1252
|
+
}
|
|
1253
|
+
// ── Values of the clock (DTM-16, DTM-17) ──────────────────────────────────────────────────────────────────────────
|
|
1254
|
+
/** The hours of the clock in use, as drawn: 1–12, or 0–23. */
|
|
1255
|
+
get hourValues() {
|
|
1256
|
+
return this.cfg.cycle === 'h12' ? Array.from({ length: 12 }, (_, i) => i + 1) : Array.from({ length: 24 }, (_, i) => i);
|
|
1257
|
+
}
|
|
1258
|
+
get minuteValues() {
|
|
1259
|
+
return stepMinutes(this.cfg.step);
|
|
1260
|
+
}
|
|
1261
|
+
values(unit) {
|
|
1262
|
+
return unit === 'hour' ? this.hourValues : this.minuteValues;
|
|
1263
|
+
}
|
|
1264
|
+
/** The index in its list of the pending value of `unit`. */
|
|
1265
|
+
indexOf(unit, time = this.time) {
|
|
1266
|
+
if (unit === 'minute')
|
|
1267
|
+
return Math.max(0, this.minuteValues.indexOf(time.minute - (time.minute % this.cfg.step)));
|
|
1268
|
+
return this.cfg.cycle === 'h12' ? shownHour12(time.hour) - 1 : time.hour;
|
|
1269
|
+
}
|
|
1270
|
+
/** The time with `unit` set to the list's entry at `index` (the period kept: DTM-19, DTM-20). */
|
|
1271
|
+
withIndex(unit, index, time = this.time) {
|
|
1272
|
+
const values = this.values(unit);
|
|
1273
|
+
const value = values[mod(index, values.length)];
|
|
1274
|
+
if (unit === 'minute')
|
|
1275
|
+
return { ...time, minute: value };
|
|
1276
|
+
return { ...time, hour: this.cfg.cycle === 'h12' ? hourOf12(value, periodOf(time.hour)) : value };
|
|
1277
|
+
}
|
|
1278
|
+
/** DTM-20, DTM-22: the keys of a wheel or a selector. Returns the new time, or null for a key that is not theirs. */
|
|
1279
|
+
keyTime(unit, key) {
|
|
1280
|
+
const index = this.indexOf(unit);
|
|
1281
|
+
const last = this.values(unit).length - 1;
|
|
1282
|
+
const pageable = unit === 'minute' && this.cfg.step === 1;
|
|
1283
|
+
switch (key) {
|
|
1284
|
+
case 'ArrowUp':
|
|
1285
|
+
return this.withIndex(unit, index + 1);
|
|
1286
|
+
case 'ArrowDown':
|
|
1287
|
+
return this.withIndex(unit, index - 1);
|
|
1288
|
+
case 'PageUp':
|
|
1289
|
+
return pageable ? this.withIndex(unit, index + 5) : null;
|
|
1290
|
+
case 'PageDown':
|
|
1291
|
+
return pageable ? this.withIndex(unit, index - 5) : null;
|
|
1292
|
+
case 'Home':
|
|
1293
|
+
return this.withIndex(unit, 0);
|
|
1294
|
+
case 'End':
|
|
1295
|
+
return this.withIndex(unit, last);
|
|
1296
|
+
default:
|
|
1297
|
+
return null;
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
/** DTM-20, DTM-22: a spin button's value as drawn, the hour with the period's name in the 12-hour clock ("7 AM"). */
|
|
1301
|
+
valueText(unit) {
|
|
1302
|
+
const { locale, cycle } = this.cfg;
|
|
1303
|
+
const time = this.time;
|
|
1304
|
+
if (unit === 'minute')
|
|
1305
|
+
return minuteText(locale, time.minute);
|
|
1306
|
+
const hour = hourText(locale, cycle, time.hour);
|
|
1307
|
+
if (cycle !== 'h12')
|
|
1308
|
+
return hour;
|
|
1309
|
+
const period = periodNames(locale)[periodOf(time.hour)];
|
|
1310
|
+
return periodPlace(locale) === 'before' ? `${period} ${hour}` : `${hour} ${period}`;
|
|
1311
|
+
}
|
|
1312
|
+
spinAria(unit) {
|
|
1313
|
+
const values = this.values(unit);
|
|
1314
|
+
const time = this.time;
|
|
1315
|
+
const now = unit === 'minute' ? time.minute : this.cfg.cycle === 'h12' ? shownHour12(time.hour) : time.hour;
|
|
1316
|
+
return { now, min: values[0], max: values[values.length - 1], text: this.valueText(unit) };
|
|
1317
|
+
}
|
|
1318
|
+
// ── The wheels (DTM-18 … DTM-20) ──────────────────────────────────────────────────────────────────────────────────
|
|
1319
|
+
/** Brings each wheel's rows to its pending value, along the shorter way, unless a pointer or a settle is moving it. */
|
|
1320
|
+
syncWheels(jump = false) {
|
|
1321
|
+
for (const unit of ['hour', 'minute']) {
|
|
1322
|
+
const wheel = this.wheels[unit];
|
|
1323
|
+
if (wheel.pointer !== null || wheel.settling || wheel.scrolling)
|
|
1324
|
+
continue;
|
|
1325
|
+
const n = this.values(unit).length;
|
|
1326
|
+
const target = this.indexOf(unit);
|
|
1327
|
+
wheel.at = jump ? target : wheel.at + shortest(mod(wheel.at, n), target, n);
|
|
1328
|
+
}
|
|
1329
|
+
// DTM-46: the period wheel does not run on: its rows are at the pending period's.
|
|
1330
|
+
const period = this.periodWheel;
|
|
1331
|
+
if (period.pointer === null && !period.settling && !period.scrolling)
|
|
1332
|
+
period.at = periodOf(this.time.hour);
|
|
1333
|
+
}
|
|
1334
|
+
/** The wheel an event of its own, or of its input, is about. */
|
|
1335
|
+
/** A wheel's rows at its pending value now, along the shorter way — also while a pointer holds it: what a drag or a scroll that ended a typed entry goes on from (DTM-45). */
|
|
1336
|
+
alignWheel(unit) {
|
|
1337
|
+
const wheel = this.wheels[unit];
|
|
1338
|
+
const n = this.values(unit).length;
|
|
1339
|
+
wheel.at += shortest(mod(wheel.at, n), this.indexOf(unit), n);
|
|
1340
|
+
}
|
|
1341
|
+
wheelOf(event) {
|
|
1342
|
+
const element = event.currentTarget?.closest('.wheel') ?? null;
|
|
1343
|
+
const unit = element?.dataset.unit;
|
|
1344
|
+
return element && unit ? { unit, element } : null;
|
|
1345
|
+
}
|
|
1346
|
+
/** A wheel's control: the input on its middle row (DTM-20, DTM-43). */
|
|
1347
|
+
spin(unit) {
|
|
1348
|
+
return this.renderRoot?.querySelector(`.wheel[data-unit='${unit}'] .entry`) ?? null;
|
|
1349
|
+
}
|
|
1350
|
+
/** The height of a row in px (row.height, at least the target: DTM-32), and the settle's duration in ms (DTM-19). */
|
|
1351
|
+
rowMetrics(element) {
|
|
1352
|
+
const probe = element.querySelector('.row') ?? element;
|
|
1353
|
+
const style = getComputedStyle(probe);
|
|
1354
|
+
const row = probe.getBoundingClientRect().height || Number.parseFloat(style.blockSize) || 1;
|
|
1355
|
+
const reduced = typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
1356
|
+
return { row, duration: reduced ? 0 : (Number.parseFloat(style.transitionDuration) || 0) * 1000 };
|
|
1357
|
+
}
|
|
1358
|
+
/** DTM-19: the rows settle `rows` rows on (a drag's end, a fling, a press on a row) and the value is taken once they have. */
|
|
1359
|
+
settle(unit, element, rows) {
|
|
1360
|
+
const wheel = this.wheels[unit];
|
|
1361
|
+
const { duration } = this.rowMetrics(element);
|
|
1362
|
+
wheel.at += rows;
|
|
1363
|
+
wheel.shift = 0;
|
|
1364
|
+
wheel.pointer = null;
|
|
1365
|
+
clearTimeout(wheel.settling);
|
|
1366
|
+
const take = () => {
|
|
1367
|
+
wheel.settling = 0;
|
|
1368
|
+
const time = this.withIndex(unit, wheel.at);
|
|
1369
|
+
if (clockText(time) !== clockText(this.time))
|
|
1370
|
+
this.setTime(time);
|
|
1371
|
+
this.wheelFrame++;
|
|
1372
|
+
};
|
|
1373
|
+
if (duration <= 0)
|
|
1374
|
+
take();
|
|
1375
|
+
else
|
|
1376
|
+
wheel.settling = window.setTimeout(take, duration);
|
|
1377
|
+
this.wheelFrame++;
|
|
1378
|
+
}
|
|
1379
|
+
/**
|
|
1380
|
+
* DTM-20: a wheel that has just been worked by the keyboard — a digit, a key that moves it, a key that ends its entry,
|
|
1381
|
+
* text from an on-screen keyboard — holds keyboard focus from then on, however focus first reached it: the wheel that
|
|
1382
|
+
* has focus now shows its ring. So the minute wheel shows where focus is once the hour's entry has moved on to it
|
|
1383
|
+
* (DTM-44), and a wheel whose entry has ended still does, where a press on it had shown none.
|
|
1384
|
+
*/
|
|
1385
|
+
ringKeyed() {
|
|
1386
|
+
const active = deepActive();
|
|
1387
|
+
if (!(active instanceof HTMLInputElement) || !active.classList.contains('entry') || active.getRootNode() !== this.renderRoot)
|
|
1388
|
+
return;
|
|
1389
|
+
const unit = active.dataset.unit;
|
|
1390
|
+
if (unit === 'hour' || unit === 'minute')
|
|
1391
|
+
this.ringed = unit;
|
|
1392
|
+
}
|
|
1393
|
+
// ── Typing a number into a wheel or a selector (DTM-22, DTM-43 … DTM-45) ─────────────────────────────────────────
|
|
1394
|
+
/** The digits read so far as they are shown: in the locale's digits, as the values around them are (DTM-44). */
|
|
1395
|
+
typedText(digits) {
|
|
1396
|
+
return [...digits].map((digit) => numberText(this.cfg.locale, Number(digit))).join('');
|
|
1397
|
+
}
|
|
1398
|
+
/** The digit a typed character is, ASCII or the locale's (DTM-44); null for any other character. */
|
|
1399
|
+
digitOf(char) {
|
|
1400
|
+
const ascii = asciiDigits(this.cfg.locale, char);
|
|
1401
|
+
return /^[0-9]$/.test(ascii) ? Number(ascii) : null;
|
|
1402
|
+
}
|
|
1403
|
+
/** Whether `value` is a value of `unit`: an hour of the clock in use, or a minute (DTM-44). */
|
|
1404
|
+
isValue(unit, value) {
|
|
1405
|
+
if (unit === 'minute')
|
|
1406
|
+
return value >= 0 && value <= 59;
|
|
1407
|
+
return this.cfg.cycle === 'h12' ? value >= 1 && value <= 12 : value >= 0 && value <= 23;
|
|
1408
|
+
}
|
|
1409
|
+
/** Whether a second digit could join `first` (DTM-44): not after 2–9 for the 12-hour hour, 3–9 for the 24-hour one, 6–9 for the minute. */
|
|
1410
|
+
canJoin(unit, first) {
|
|
1411
|
+
if (unit === 'minute')
|
|
1412
|
+
return first <= 5;
|
|
1413
|
+
return first <= (this.cfg.cycle === 'h12' ? 1 : 2);
|
|
1414
|
+
}
|
|
1415
|
+
/**
|
|
1416
|
+
* DTM-43: a typed entry begins on `unit`. In the wheels mode the wheel takes focus and its input takes text, so that
|
|
1417
|
+
* an on-screen keyboard comes up for it (`raise`: within the press that began it, where a platform asks for that).
|
|
1418
|
+
*/
|
|
1419
|
+
beginEntry(unit, { raise = false } = {}) {
|
|
1420
|
+
if (this.typed?.unit === unit)
|
|
1421
|
+
return;
|
|
1422
|
+
this.endEntry(true);
|
|
1423
|
+
this.typed = { unit, digits: '' };
|
|
1424
|
+
if (this.shownEntry !== 'wheels')
|
|
1425
|
+
return;
|
|
1426
|
+
const input = this.spin(unit);
|
|
1427
|
+
if (!input)
|
|
1428
|
+
return;
|
|
1429
|
+
input.readOnly = false;
|
|
1430
|
+
if (raise && deepActive() === input) {
|
|
1431
|
+
// Focused again, within the press: a keyboard that stayed down for a read-only input comes up for this one.
|
|
1432
|
+
this.nextRing = this.ringed === unit;
|
|
1433
|
+
input.blur();
|
|
1434
|
+
this.typed = { unit, digits: '' };
|
|
1435
|
+
}
|
|
1436
|
+
if (deepActive() !== input) {
|
|
1437
|
+
this.nextRing ??= false;
|
|
1438
|
+
input.focus({ preventScroll: true });
|
|
1439
|
+
}
|
|
1440
|
+
}
|
|
1441
|
+
/**
|
|
1442
|
+
* DTM-45: the typed entry ends. Kept, what it read becomes the pending value where it is a value of the unit — a
|
|
1443
|
+
* minute rounded down to minuteStep (DTM-8), an hour of the 12-hour clock in the pending period — and the wheel's rows
|
|
1444
|
+
* or the dial's handle move to it; nothing typed, or no value (0 alone for the 12-hour hour), keeps the value it had.
|
|
1445
|
+
*/
|
|
1446
|
+
endEntry(keep) {
|
|
1447
|
+
const typed = this.typed;
|
|
1448
|
+
if (!typed)
|
|
1449
|
+
return;
|
|
1450
|
+
this.typed = null;
|
|
1451
|
+
if (!keep || typed.digits === '')
|
|
1452
|
+
return;
|
|
1453
|
+
const value = Number(typed.digits);
|
|
1454
|
+
if (!this.isValue(typed.unit, value))
|
|
1455
|
+
return;
|
|
1456
|
+
const time = this.time;
|
|
1457
|
+
const { cycle, step } = this.cfg;
|
|
1458
|
+
const next = typed.unit === 'minute' ? { ...time, minute: value - (value % step) } : { ...time, hour: cycle === 'h12' ? hourOf12(value, periodOf(time.hour)) : value };
|
|
1459
|
+
if (clockText(next) === clockText(time))
|
|
1460
|
+
return;
|
|
1461
|
+
const wheel = this.wheels[typed.unit];
|
|
1462
|
+
clearTimeout(wheel.settling);
|
|
1463
|
+
wheel.settling = 0;
|
|
1464
|
+
this.instant = false;
|
|
1465
|
+
this.setTime(next);
|
|
1466
|
+
}
|
|
1467
|
+
/**
|
|
1468
|
+
* DTM-44: the hour's entry has ended by its digits or by a separator: focus moves to the minute — the minute wheel,
|
|
1469
|
+
* whose input takes text from now on (the next digit begins its entry), or the minute selector.
|
|
1470
|
+
*/
|
|
1471
|
+
moveOn() {
|
|
1472
|
+
if (this.shownEntry === 'wheels') {
|
|
1473
|
+
const input = this.spin('minute');
|
|
1474
|
+
if (!input)
|
|
1475
|
+
return;
|
|
1476
|
+
this.armed = 'minute';
|
|
1477
|
+
input.readOnly = false;
|
|
1478
|
+
// DTM-20: typing moved the focus, so it is keyboard focus — the minute wheel shows its ring, whether or not the
|
|
1479
|
+
// hour wheel, pressed, had shown one. Without it nothing would say where the next digit goes.
|
|
1480
|
+
this.nextRing = true;
|
|
1481
|
+
input.focus({ preventScroll: true });
|
|
1482
|
+
return;
|
|
1483
|
+
}
|
|
1484
|
+
const from = deepActive();
|
|
1485
|
+
const ring = from instanceof HTMLElement && from.matches(':focus-visible');
|
|
1486
|
+
this.renderRoot.querySelector(".selector[data-unit='minute']")?.focus({ focusVisible: ring });
|
|
1487
|
+
}
|
|
1488
|
+
/** DTM-44: reads `text` as typed on `unit`, character by character, each on the unit the one before left the entry at. */
|
|
1489
|
+
readTyped(unit, text) {
|
|
1490
|
+
let at = unit;
|
|
1491
|
+
for (const char of text)
|
|
1492
|
+
at = this.readChar(at, char);
|
|
1493
|
+
}
|
|
1494
|
+
/** DTM-44: one typed character on `unit`. Returns the unit the next character is read on. */
|
|
1495
|
+
readChar(unit, char) {
|
|
1496
|
+
const digit = this.digitOf(char);
|
|
1497
|
+
if (digit === null) {
|
|
1498
|
+
// The separator between hours and minutes ends the hour's entry and moves on; every other character is ignored.
|
|
1499
|
+
if (unit !== 'hour' || this.typed?.unit !== 'hour' || ![timeSeparator(this.cfg.locale), ...SEPARATORS].includes(char))
|
|
1500
|
+
return unit;
|
|
1501
|
+
this.endEntry(true);
|
|
1502
|
+
this.moveOn();
|
|
1503
|
+
return 'minute';
|
|
1504
|
+
}
|
|
1505
|
+
this.beginEntry(unit);
|
|
1506
|
+
const digits = `${this.typed.digits}${digit}`;
|
|
1507
|
+
if (digits.length === 2 && !this.isValue(unit, Number(digits))) {
|
|
1508
|
+
// Only an hour can meet it (1 3 on the 12-hour clock): the hour ends with its first digit, and this one begins the minute.
|
|
1509
|
+
this.endEntry(true);
|
|
1510
|
+
this.moveOn();
|
|
1511
|
+
return this.readChar('minute', char);
|
|
1512
|
+
}
|
|
1513
|
+
this.typed = { unit, digits };
|
|
1514
|
+
if (digits.length < 2 && this.canJoin(unit, digit))
|
|
1515
|
+
return unit;
|
|
1516
|
+
// Full, or a digit no second one could join: the entry ends, and an hour's moves on to the minute. The minute wheel
|
|
1517
|
+
// goes on taking text — the next digit begins its entry again — so that an on-screen keyboard stays up.
|
|
1518
|
+
this.endEntry(true);
|
|
1519
|
+
if (unit === 'hour')
|
|
1520
|
+
this.moveOn();
|
|
1521
|
+
else if (this.shownEntry === 'wheels')
|
|
1522
|
+
this.armed = 'minute';
|
|
1523
|
+
return 'minute';
|
|
1524
|
+
}
|
|
1525
|
+
/**
|
|
1526
|
+
* DTM-43 … DTM-45: a key on a wheel or a selector, as a typed entry reads it. A digit begins an entry or goes on with
|
|
1527
|
+
* it. While one lasts: Backspace removes the last digit; Enter ends it, keeping what it read, and presses nothing;
|
|
1528
|
+
* Escape ends it with the value it had and closes nothing; the separator moves an hour on to the minute; any other
|
|
1529
|
+
* character is ignored. Returns whether the key was the entry's.
|
|
1530
|
+
*/
|
|
1531
|
+
entryKey(unit, event) {
|
|
1532
|
+
const typing = this.typed?.unit === unit;
|
|
1533
|
+
if (event.key.length === 1 && this.digitOf(event.key) !== null) {
|
|
1534
|
+
event.preventDefault();
|
|
1535
|
+
this.readChar(unit, event.key);
|
|
1536
|
+
return true;
|
|
1537
|
+
}
|
|
1538
|
+
if (!typing)
|
|
1539
|
+
return false;
|
|
1540
|
+
if (event.key === 'Backspace') {
|
|
1541
|
+
event.preventDefault();
|
|
1542
|
+
this.typed = { unit, digits: this.typed.digits.slice(0, -1) };
|
|
1543
|
+
return true;
|
|
1544
|
+
}
|
|
1545
|
+
if (event.key === 'Enter') {
|
|
1546
|
+
event.preventDefault();
|
|
1547
|
+
event.stopPropagation();
|
|
1548
|
+
this.endEntry(true);
|
|
1549
|
+
this.armed = null;
|
|
1550
|
+
return true;
|
|
1551
|
+
}
|
|
1552
|
+
if (event.key === 'Escape') {
|
|
1553
|
+
event.preventDefault();
|
|
1554
|
+
event.stopPropagation();
|
|
1555
|
+
this.escapeSpent = event.timeStamp;
|
|
1556
|
+
this.endEntry(false);
|
|
1557
|
+
this.armed = null;
|
|
1558
|
+
return true;
|
|
1559
|
+
}
|
|
1560
|
+
if (event.key.length !== 1)
|
|
1561
|
+
return false;
|
|
1562
|
+
event.preventDefault();
|
|
1563
|
+
this.readChar(unit, event.key);
|
|
1564
|
+
return true;
|
|
1565
|
+
}
|
|
1566
|
+
// ── The period (DTM-14, DTM-46, DTM-47) ───────────────────────────────────────────────────────────────────────────
|
|
1567
|
+
/**
|
|
1568
|
+
* DTM-14, DTM-47: `period` (0 before noon, 1 after) becomes the pending period. The hour's number and the minute stay,
|
|
1569
|
+
* the dial's handle stays where it is (the same angle), and neither the unit the dial shows nor the selected selector
|
|
1570
|
+
* changes. A typed entry ends first, keeping what it read.
|
|
1571
|
+
*/
|
|
1572
|
+
setPeriod(period) {
|
|
1573
|
+
this.endEntry(true);
|
|
1574
|
+
const time = this.time;
|
|
1575
|
+
if (periodOf(time.hour) === period)
|
|
1576
|
+
return;
|
|
1577
|
+
this.setTime({ ...time, hour: hourOf12(shownHour12(time.hour), period) });
|
|
1578
|
+
}
|
|
1579
|
+
/**
|
|
1580
|
+
* DTM-47: the keys of the period — Up and Down change it (it has two values), and on the period selector Right and
|
|
1581
|
+
* Left too, in every layout direction; Home is before noon, End after; Enter and Space do what Up does. Returns the
|
|
1582
|
+
* period the key asks for, or null for a key that is not the period's (a digit or a letter is ignored).
|
|
1583
|
+
*/
|
|
1584
|
+
periodKey(event, sideways) {
|
|
1585
|
+
if (event.altKey || event.ctrlKey || event.metaKey)
|
|
1586
|
+
return null;
|
|
1587
|
+
const now = periodOf(this.time.hour);
|
|
1588
|
+
const other = now ? 0 : 1;
|
|
1589
|
+
switch (event.key) {
|
|
1590
|
+
case 'ArrowUp':
|
|
1591
|
+
case 'ArrowDown':
|
|
1592
|
+
case 'Enter':
|
|
1593
|
+
case ' ':
|
|
1594
|
+
return other;
|
|
1595
|
+
case 'ArrowRight':
|
|
1596
|
+
case 'ArrowLeft':
|
|
1597
|
+
return sideways ? other : null;
|
|
1598
|
+
case 'Home':
|
|
1599
|
+
return 0;
|
|
1600
|
+
case 'End':
|
|
1601
|
+
return 1;
|
|
1602
|
+
default:
|
|
1603
|
+
return null;
|
|
1604
|
+
}
|
|
1605
|
+
}
|
|
1606
|
+
/**
|
|
1607
|
+
* DTM-47, as DTM-20 for the other wheels: a key that works the period makes its focus keyboard focus, however focus
|
|
1608
|
+
* first reached it — after a press and then an arrow, the ring says where focus is.
|
|
1609
|
+
*/
|
|
1610
|
+
ringPeriod() {
|
|
1611
|
+
this.ringed = 'period';
|
|
1612
|
+
}
|
|
1613
|
+
get periodControl() {
|
|
1614
|
+
return this.renderRoot?.querySelector('.wheel.period .entry') ?? null;
|
|
1615
|
+
}
|
|
1616
|
+
/** DTM-46: the period wheel's rows settle on `period` over the wheel motion, and the period is taken once they have. */
|
|
1617
|
+
settlePeriod(element, period) {
|
|
1618
|
+
const wheel = this.periodWheel;
|
|
1619
|
+
const { duration } = this.rowMetrics(element);
|
|
1620
|
+
wheel.at = Math.min(1, Math.max(0, Math.round(period)));
|
|
1621
|
+
wheel.shift = 0;
|
|
1622
|
+
wheel.pointer = null;
|
|
1623
|
+
clearTimeout(wheel.settling);
|
|
1624
|
+
const take = () => {
|
|
1625
|
+
wheel.settling = 0;
|
|
1626
|
+
this.setPeriod(wheel.at ? 1 : 0);
|
|
1627
|
+
this.wheelFrame++;
|
|
1628
|
+
};
|
|
1629
|
+
if (duration <= 0)
|
|
1630
|
+
take();
|
|
1631
|
+
else
|
|
1632
|
+
wheel.settling = window.setTimeout(take, duration);
|
|
1633
|
+
this.wheelFrame++;
|
|
1634
|
+
}
|
|
1635
|
+
/** DTM-46: how far the rows may be moved off their place, in rows: to the first name and to the last, and no further. */
|
|
1636
|
+
periodShift(shift) {
|
|
1637
|
+
const wheel = this.periodWheel;
|
|
1638
|
+
return Math.min(1 - wheel.at, Math.max(-wheel.at, shift));
|
|
1639
|
+
}
|
|
1640
|
+
// ── The dial mode: selectors and dial (DTM-21 … DTM-26) ───────────────────────────────────────────────────────────
|
|
1641
|
+
/** DTM-22: a selector focused or pressed shows its unit on the dial and is drawn as selected. */
|
|
1642
|
+
showUnit(unit) {
|
|
1643
|
+
if (this.shownUnit === unit)
|
|
1644
|
+
return;
|
|
1645
|
+
this.instant = false;
|
|
1646
|
+
this.shownUnit = unit;
|
|
1647
|
+
}
|
|
1648
|
+
/** The angle of the pending value of the unit shown, clockwise from the top (0–359). */
|
|
1649
|
+
targetAngle() {
|
|
1650
|
+
const { hour, minute } = this.time;
|
|
1651
|
+
return this.shownUnit === 'minute' ? minute * 6 : (hour % 12) * 30;
|
|
1652
|
+
}
|
|
1653
|
+
/** On the 24-hour hour dial, 12 to 23 are on the inner ring. */
|
|
1654
|
+
get innerRing() {
|
|
1655
|
+
return this.shownUnit === 'hour' && this.cfg.cycle === 'h23' && this.time.hour >= 12;
|
|
1656
|
+
}
|
|
1657
|
+
/** DTM-25: the value under a point — the nearest angle's, on the nearer ring for the 24-hour hour dial, a minute of the step. */
|
|
1658
|
+
setFromPoint(event) {
|
|
1659
|
+
const dial = this.renderRoot.querySelector('.dial');
|
|
1660
|
+
if (!dial)
|
|
1661
|
+
return;
|
|
1662
|
+
const box = dial.getBoundingClientRect();
|
|
1663
|
+
const dx = event.clientX - (box.left + box.width / 2);
|
|
1664
|
+
const dy = event.clientY - (box.top + box.height / 2);
|
|
1665
|
+
const degrees = ((Math.atan2(dx, -dy) * 180) / Math.PI + 360) % 360;
|
|
1666
|
+
const time = this.time;
|
|
1667
|
+
if (this.shownUnit === 'minute') {
|
|
1668
|
+
const step = this.cfg.step;
|
|
1669
|
+
this.setTime({ ...time, minute: (Math.round(degrees / (6 * step)) * step) % 60 });
|
|
1670
|
+
return;
|
|
1671
|
+
}
|
|
1672
|
+
const index = Math.round(degrees / 30) % 12;
|
|
1673
|
+
if (this.cfg.cycle === 'h12') {
|
|
1674
|
+
this.setTime({ ...time, hour: hourOf12(index === 0 ? 12 : index, periodOf(time.hour)) });
|
|
1675
|
+
return;
|
|
1676
|
+
}
|
|
1677
|
+
const radius = (selector) => {
|
|
1678
|
+
const number = dial.querySelector(selector)?.getBoundingClientRect();
|
|
1679
|
+
return number ? Math.hypot(number.left + number.width / 2 - (box.left + box.width / 2), number.top + number.height / 2 - (box.top + box.height / 2)) : 0;
|
|
1680
|
+
};
|
|
1681
|
+
const distance = Math.hypot(dx, dy);
|
|
1682
|
+
const inner = Math.abs(distance - radius('.face .hours .inner')) < Math.abs(distance - radius('.face .hours .outer'));
|
|
1683
|
+
this.setTime({ ...time, hour: index + (inner ? 12 : 0) });
|
|
1684
|
+
}
|
|
1685
|
+
// ── Closing requests (DTM-5) ──────────────────────────────────────────────────────────────────────────────────────
|
|
1686
|
+
element(id) {
|
|
1687
|
+
if (!id)
|
|
1688
|
+
return null;
|
|
1689
|
+
return this.getRootNode().getElementById?.(id) ?? null;
|
|
1690
|
+
}
|
|
1691
|
+
get anchorElement() {
|
|
1692
|
+
return this.element(this.anchor);
|
|
1693
|
+
}
|
|
1694
|
+
get openerElement() {
|
|
1695
|
+
return this.element(this.opener || this.anchor);
|
|
1696
|
+
}
|
|
1697
|
+
/** Whether `node` is the anchor or the opener, or inside one. */
|
|
1698
|
+
atAnchor(node) {
|
|
1699
|
+
return [this.anchorElement, this.openerElement].some((element) => !!element && !!node && (element === node || element.contains(node) || !!element.shadowRoot?.contains(node)));
|
|
1700
|
+
}
|
|
1701
|
+
get surface() {
|
|
1702
|
+
return this.renderRoot?.querySelector('.surface') ?? null;
|
|
1703
|
+
}
|
|
1704
|
+
onScrim(event) {
|
|
1705
|
+
const surface = this.surface;
|
|
1706
|
+
if (!surface || this.inline || event.composedPath()[0] !== surface)
|
|
1707
|
+
return false;
|
|
1708
|
+
const box = surface.getBoundingClientRect();
|
|
1709
|
+
return event.clientX < box.left || event.clientX > box.right || event.clientY < box.top || event.clientY > box.bottom;
|
|
1710
|
+
}
|
|
1711
|
+
listen(on) {
|
|
1712
|
+
if (on === this.listening)
|
|
1713
|
+
return;
|
|
1714
|
+
this.listening = on;
|
|
1715
|
+
if (on)
|
|
1716
|
+
document.addEventListener('pointerdown', this.onOutsidePress, true);
|
|
1717
|
+
else
|
|
1718
|
+
document.removeEventListener('pointerdown', this.onOutsidePress, true);
|
|
1719
|
+
}
|
|
1720
|
+
// ── Presenting (DTM-1 … DTM-4, DTM-9, DTM-35 … DTM-37) ────────────────────────────────────────────────────────────
|
|
1721
|
+
/** DTM-2, DTM-36: a docked picker below its anchor (flipped, shifted, its height limited to the room), following it. */
|
|
1722
|
+
place() {
|
|
1723
|
+
const surface = this.surface;
|
|
1724
|
+
if (!surface || this.inline || !this.shown || this.modal)
|
|
1725
|
+
return;
|
|
1726
|
+
const style = getComputedStyle(surface);
|
|
1727
|
+
const offset = Number.parseFloat(style.scrollMarginBlockStart) || 0;
|
|
1728
|
+
const margin = Number.parseFloat(style.scrollMarginBlockEnd) || 0;
|
|
1729
|
+
// Measured as it stands, never by lifting the cap (which would lay the body out without overflow and send a scrolled
|
|
1730
|
+
// calendar back to its top on every placement): the body is the part that scrolls under the cap (DTM-36), or the
|
|
1731
|
+
// surface itself where everything scrolls together.
|
|
1732
|
+
const scroller = surface.classList.contains('whole') ? surface : surface.querySelector('.body');
|
|
1733
|
+
const size = { width: layoutSize(surface).width, height: naturalHeight(surface, scroller) };
|
|
1734
|
+
const box = this.anchorElement?.getBoundingClientRect() ?? { x: margin, y: margin, width: 0, height: 0 };
|
|
1735
|
+
const viewport = { width: document.documentElement.clientWidth, height: document.documentElement.clientHeight };
|
|
1736
|
+
const at = placeMenu({ anchor: box, surface: size, viewport, placement: 'bottom-start', offset, margin, rtl: getComputedStyle(this).direction === 'rtl' });
|
|
1737
|
+
const left = size.width > viewport.width - 2 * margin ? Math.max(0, (viewport.width - size.width) / 2) : at.left;
|
|
1738
|
+
surface.style.top = `${at.top}px`;
|
|
1739
|
+
surface.style.left = `${left}px`;
|
|
1740
|
+
surface.style.maxBlockSize = `${at.maxHeight}px`;
|
|
1741
|
+
surface.classList.toggle('side-top', at.side === 'top');
|
|
1742
|
+
}
|
|
1743
|
+
stopFollowing() {
|
|
1744
|
+
this.following.stop();
|
|
1745
|
+
this.lastLayout = '';
|
|
1746
|
+
}
|
|
1747
|
+
/**
|
|
1748
|
+
* DTM-9, DTM-34, DTM-36: the layout — vertical or horizontal as `layout` says; for auto, horizontal only when the
|
|
1749
|
+
* vertical one does not fit the window's height and the horizontal one fits its width — the actions in a row or a
|
|
1750
|
+
* column, and the whole surface scrolling as one when the header and the actions leave no room between them.
|
|
1751
|
+
*/
|
|
1752
|
+
arrange() {
|
|
1753
|
+
const surface = this.surface;
|
|
1754
|
+
const body = this.renderRoot?.querySelector('.body');
|
|
1755
|
+
if (!surface || !body || !this.session)
|
|
1756
|
+
return;
|
|
1757
|
+
surface.dataset.arrangement = compChoice(this, `${PREFIX}-actions-arrangement`, ARRANGEMENTS);
|
|
1758
|
+
const { layout } = this.cfg;
|
|
1759
|
+
const overflows = () => body.scrollHeight > body.clientHeight + 0.5;
|
|
1760
|
+
surface.classList.remove('whole');
|
|
1761
|
+
if (layout !== 'auto' || this.inline)
|
|
1762
|
+
surface.dataset.layout = layout === 'horizontal' ? 'horizontal' : 'vertical';
|
|
1763
|
+
else {
|
|
1764
|
+
surface.dataset.layout = 'vertical';
|
|
1765
|
+
if (overflows()) {
|
|
1766
|
+
surface.dataset.layout = 'horizontal';
|
|
1767
|
+
const fits = surface.scrollWidth <= surface.clientWidth + 0.5;
|
|
1768
|
+
if (!fits)
|
|
1769
|
+
surface.dataset.layout = 'vertical';
|
|
1770
|
+
}
|
|
1771
|
+
}
|
|
1772
|
+
const box = this.renderRoot.querySelector('.actions');
|
|
1773
|
+
if (box) {
|
|
1774
|
+
this.placement.read([...box.children]);
|
|
1775
|
+
const { changed } = this.placement.measure(box, surface.dataset.arrangement === 'end' ? 'packed' : 'fill');
|
|
1776
|
+
if (changed)
|
|
1777
|
+
this.stacked = this.placement.stacked;
|
|
1778
|
+
}
|
|
1779
|
+
const line = Number.parseFloat(getComputedStyle(body).getPropertyValue('--_line')) || 0;
|
|
1780
|
+
surface.classList.toggle('whole', overflows() && body.clientHeight < line);
|
|
1781
|
+
}
|
|
1782
|
+
/** DTM-1, DTM-2, DTM-3: the overlay is presented and focus moves in — when it opens, not when its motion ends. */
|
|
1783
|
+
present() {
|
|
1784
|
+
const surface = this.surface;
|
|
1785
|
+
if (!surface || this.shown || !this.isConnected)
|
|
1786
|
+
return;
|
|
1787
|
+
if (this.inline) {
|
|
1788
|
+
// Drawn in place where the page wrote it, it is no overlay somebody opened, and takes no focus (DTM-3 speaks of a
|
|
1789
|
+
// picker that opens): the dialog is marked open, not shown — `show()` runs the dialog's focusing steps, which
|
|
1790
|
+
// moved focus into a picker nobody had touched and had the browser scroll the page to it.
|
|
1791
|
+
if (surface instanceof HTMLDialogElement && !surface.open)
|
|
1792
|
+
surface.open = true;
|
|
1793
|
+
this.arrange();
|
|
1794
|
+
return;
|
|
1795
|
+
}
|
|
1796
|
+
this.returnTo = deepActive();
|
|
1797
|
+
this.shown = true;
|
|
1798
|
+
surface.inert = false;
|
|
1799
|
+
this.presenting = true;
|
|
1800
|
+
try {
|
|
1801
|
+
if (surface instanceof HTMLDialogElement) {
|
|
1802
|
+
watchEscape();
|
|
1803
|
+
if (!surface.open)
|
|
1804
|
+
surface.showModal();
|
|
1805
|
+
modalLayer.add(this);
|
|
1806
|
+
holdPageScroll(this, true);
|
|
1807
|
+
window.visualViewport?.addEventListener('resize', this.onWindow);
|
|
1808
|
+
}
|
|
1809
|
+
else {
|
|
1810
|
+
surface.classList.remove('leaving');
|
|
1811
|
+
if (!surface.matches(':popover-open'))
|
|
1812
|
+
surface.showPopover();
|
|
1813
|
+
this.place();
|
|
1814
|
+
this.following.start();
|
|
1815
|
+
this.listen(true);
|
|
1816
|
+
surface.classList.remove('entering');
|
|
1817
|
+
void surface.offsetWidth; // restart the animation
|
|
1818
|
+
surface.classList.add('entering');
|
|
1819
|
+
}
|
|
1820
|
+
}
|
|
1821
|
+
finally {
|
|
1822
|
+
this.presenting = false;
|
|
1823
|
+
}
|
|
1824
|
+
window.addEventListener('resize', this.onWindow);
|
|
1825
|
+
this.onWindow();
|
|
1826
|
+
void this.focusInitial();
|
|
1827
|
+
// The handle is placed at once when the picker opens, and moves over the dial motion from the next frame on (DTM-26).
|
|
1828
|
+
requestAnimationFrame(() => requestAnimationFrame(() => (this.instant = this.dragging !== null)));
|
|
1829
|
+
}
|
|
1830
|
+
/**
|
|
1831
|
+
* DTM-3: focus to the calendar's active day (or displayed year), the hour wheel, or the selector of `unit`. The ring
|
|
1832
|
+
* shows when the picker was opened from the keyboard — from an element that showed its own keyboard focus — and not
|
|
1833
|
+
* when it was opened by a press or with the page.
|
|
1834
|
+
*/
|
|
1835
|
+
async focusInitial() {
|
|
1836
|
+
const from = this.returnTo;
|
|
1837
|
+
const options = { focusVisible: !!from && from !== document.body && from.matches(':focus-visible') };
|
|
1838
|
+
this.presenting = true;
|
|
1839
|
+
try {
|
|
1840
|
+
if (this.hasDate) {
|
|
1841
|
+
const calendar = this.renderRoot.querySelector('tanrei-calendar');
|
|
1842
|
+
if (calendar) {
|
|
1843
|
+
await calendar.updateComplete;
|
|
1844
|
+
calendar.focus(options);
|
|
1845
|
+
}
|
|
1846
|
+
}
|
|
1847
|
+
else if (this.shownEntry === 'wheels') {
|
|
1848
|
+
// DTM-3, DTM-43: the hour wheel takes focus; no entry begins and no keyboard comes up.
|
|
1849
|
+
this.nextRing = !!options.focusVisible;
|
|
1850
|
+
focusAgain(this.spin('hour'), options);
|
|
1851
|
+
}
|
|
1852
|
+
else
|
|
1853
|
+
focusAgain(this.renderRoot.querySelector(`.selector[data-unit='${this.shownUnit}']`), options);
|
|
1854
|
+
}
|
|
1855
|
+
finally {
|
|
1856
|
+
this.presenting = false;
|
|
1857
|
+
}
|
|
1858
|
+
}
|
|
1859
|
+
/** DTM-4: focus back where it was when the picker opened (the opener, then the anchor, when that is gone). */
|
|
1860
|
+
returnFocus() {
|
|
1861
|
+
const candidates = [this.returnTo, this.openerElement, this.anchorElement];
|
|
1862
|
+
for (const element of candidates) {
|
|
1863
|
+
if (element instanceof HTMLElement && element.isConnected && !element.closest('[inert]') && element !== document.body) {
|
|
1864
|
+
element.focus();
|
|
1865
|
+
const now = deepActive();
|
|
1866
|
+
if (now === element || (!!now && (element.shadowRoot?.contains(now) || element.contains(now))))
|
|
1867
|
+
return;
|
|
1868
|
+
}
|
|
1869
|
+
}
|
|
1870
|
+
// Nowhere to go back to: focus does not stay in a closed picker.
|
|
1871
|
+
const active = deepActive();
|
|
1872
|
+
if (active && this.inside(active))
|
|
1873
|
+
active.blur();
|
|
1874
|
+
}
|
|
1875
|
+
/** Whether `node` is in the picker, its shadow root, or the shadow root of an element it draws. */
|
|
1876
|
+
inside(node) {
|
|
1877
|
+
for (let at = node; at;) {
|
|
1878
|
+
if (at === this || this.renderRoot.contains(at))
|
|
1879
|
+
return true;
|
|
1880
|
+
const root = at.getRootNode();
|
|
1881
|
+
at = root instanceof ShadowRoot ? root.host : null;
|
|
1882
|
+
}
|
|
1883
|
+
return false;
|
|
1884
|
+
}
|
|
1885
|
+
/** DTM-4, DTM-35: out of the top layer (fading), the page given back, focus back where it was if it was inside. */
|
|
1886
|
+
withdraw(restoreFocus = true) {
|
|
1887
|
+
const surface = this.surface;
|
|
1888
|
+
if (!this.shown)
|
|
1889
|
+
return;
|
|
1890
|
+
this.shown = false;
|
|
1891
|
+
const active = deepActive();
|
|
1892
|
+
const inside = !!active && this.inside(active);
|
|
1893
|
+
this.stopFollowing();
|
|
1894
|
+
this.listen(false);
|
|
1895
|
+
window.removeEventListener('resize', this.onWindow);
|
|
1896
|
+
if (surface instanceof HTMLDialogElement) {
|
|
1897
|
+
modalLayer.delete(this);
|
|
1898
|
+
holdPageScroll(this, false);
|
|
1899
|
+
window.visualViewport?.removeEventListener('resize', this.onWindow);
|
|
1900
|
+
if (surface.open)
|
|
1901
|
+
surface.close();
|
|
1902
|
+
}
|
|
1903
|
+
else if (surface) {
|
|
1904
|
+
surface.classList.remove('entering');
|
|
1905
|
+
surface.classList.add('leaving');
|
|
1906
|
+
const finish = () => {
|
|
1907
|
+
if (this.open || !surface.classList.contains('leaving'))
|
|
1908
|
+
return;
|
|
1909
|
+
surface.classList.remove('leaving');
|
|
1910
|
+
if (surface.matches(':popover-open'))
|
|
1911
|
+
surface.hidePopover();
|
|
1912
|
+
};
|
|
1913
|
+
const running = surface.getAnimations();
|
|
1914
|
+
if (running.length === 0)
|
|
1915
|
+
finish();
|
|
1916
|
+
else
|
|
1917
|
+
void Promise.allSettled(running.map((animation) => animation.finished)).then(finish);
|
|
1918
|
+
}
|
|
1919
|
+
if (restoreFocus && inside)
|
|
1920
|
+
this.returnFocus();
|
|
1921
|
+
this.returnTo = null;
|
|
1922
|
+
}
|
|
1923
|
+
/** DTM-37: the element that opens a docked picker says it opens a dialog, whether it is open, and which. */
|
|
1924
|
+
syncOpener() {
|
|
1925
|
+
const element = this.openerElement;
|
|
1926
|
+
if (!element)
|
|
1927
|
+
return;
|
|
1928
|
+
const target = findOpenerTarget(element);
|
|
1929
|
+
const docked = this.cfg.presentation === 'docked' && !this.inline;
|
|
1930
|
+
if (docked && !this.id)
|
|
1931
|
+
this.id = `tanrei-date-time-picker-${++ids}`;
|
|
1932
|
+
// A modal picker's opener keeps whatever it says itself (a text field's picker button says it opens a dialog, TXF-32).
|
|
1933
|
+
if (docked)
|
|
1934
|
+
hostAria(target, { 'aria-haspopup': 'dialog' });
|
|
1935
|
+
hostAria(target, {
|
|
1936
|
+
'aria-expanded': docked ? String(this.open) : null,
|
|
1937
|
+
'aria-controls': docked && target.getRootNode() === this.getRootNode() ? this.id : null,
|
|
1938
|
+
});
|
|
1939
|
+
}
|
|
1940
|
+
/** DTM-13: the entry-mode tabs control their panel (the row sets none of its own: it has no panels). */
|
|
1941
|
+
linkPanels() {
|
|
1942
|
+
const link = (tabs, panel) => {
|
|
1943
|
+
const row = this.renderRoot.querySelector(tabs);
|
|
1944
|
+
if (!row)
|
|
1945
|
+
return;
|
|
1946
|
+
void row.updateComplete.then(() => requestAnimationFrame(() => {
|
|
1947
|
+
for (const tab of row.querySelectorAll('tanrei-tab'))
|
|
1948
|
+
hostAria(tab, { 'aria-controls': panel });
|
|
1949
|
+
}));
|
|
1950
|
+
};
|
|
1951
|
+
link('.entry-tabs', 'time-panel');
|
|
1952
|
+
}
|
|
1953
|
+
// ── Updates ───────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
1954
|
+
willUpdate(changed) {
|
|
1955
|
+
const reopened = changed.has('open') || changed.has('presentation') || changed.has('inline') || changed.has('mode') || changed.has('range');
|
|
1956
|
+
if (this.open && (reopened || !this.session))
|
|
1957
|
+
this.initSession();
|
|
1958
|
+
else {
|
|
1959
|
+
this.cfg = this.readConfig();
|
|
1960
|
+
// DTM-7: a docked picker for a date only shows what the product sets while it is open; any other keeps its pending choice (DTM-6).
|
|
1961
|
+
if (this.open && !this.pendingUntilOk && (changed.has('value') || changed.has('start') || changed.has('end')))
|
|
1962
|
+
this.pending = this.cfg.committed;
|
|
1963
|
+
if (!this.session)
|
|
1964
|
+
this.pending = this.cfg.committed;
|
|
1965
|
+
}
|
|
1966
|
+
if (this.session)
|
|
1967
|
+
this.syncWheels();
|
|
1968
|
+
// DTM-26: the handle turns along the shorter arc to the value it shows.
|
|
1969
|
+
const target = this.targetAngle();
|
|
1970
|
+
const current = ((this.angle % 360) + 360) % 360;
|
|
1971
|
+
const delta = ((target - current + 540) % 360) - 180;
|
|
1972
|
+
if (delta !== 0)
|
|
1973
|
+
this.angle += delta;
|
|
1974
|
+
}
|
|
1975
|
+
updated(changed) {
|
|
1976
|
+
if (changed.has('open') || changed.has('presentation') || changed.has('inline')) {
|
|
1977
|
+
this.closeRequested = false;
|
|
1978
|
+
if (changed.has('presentation') && this.shown)
|
|
1979
|
+
this.withdraw(false);
|
|
1980
|
+
if (this.open)
|
|
1981
|
+
this.present();
|
|
1982
|
+
else
|
|
1983
|
+
this.withdraw();
|
|
1984
|
+
}
|
|
1985
|
+
this.syncOpener();
|
|
1986
|
+
this.linkPanels();
|
|
1987
|
+
const surface = this.surface;
|
|
1988
|
+
if (surface)
|
|
1989
|
+
this.resize$?.observe(surface);
|
|
1990
|
+
const body = this.renderRoot.querySelector('.body');
|
|
1991
|
+
if (body)
|
|
1992
|
+
this.resize$?.observe(body);
|
|
1993
|
+
if (this.shown || this.inline)
|
|
1994
|
+
this.arrange();
|
|
1995
|
+
// DTM-33: the error line is announced once, politely, when it appears.
|
|
1996
|
+
const error = this.session && this.rangeError;
|
|
1997
|
+
if (error && !this.errorShown) {
|
|
1998
|
+
const live = this.renderRoot.querySelector('.announce');
|
|
1999
|
+
const words = this.say.rangeErrorText;
|
|
2000
|
+
if (live)
|
|
2001
|
+
live.textContent = live.textContent === words ? `${words}` : words;
|
|
2002
|
+
}
|
|
2003
|
+
this.errorShown = error;
|
|
2004
|
+
this.reportWords();
|
|
2005
|
+
}
|
|
2006
|
+
// ── Rendering ─────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
2007
|
+
/** DTM-10, DTM-48: the title's words and the surface's name — `label`, the instance's alone; nothing while it is empty. */
|
|
2008
|
+
get heading() {
|
|
2009
|
+
return this.label.trim();
|
|
2010
|
+
}
|
|
2011
|
+
/**
|
|
2012
|
+
* DTM-10: the pending choice in the header — a date with its weekday, a range joined by an en dash, a date not chosen
|
|
2013
|
+
* yet as `dateLabel`, for a single value and for either end of a range: no word for start or end is drawn. Each part of
|
|
2014
|
+
* a range is an isolated run (`<bdi>`: a date as its locale writes it, or the product's word), and the two stand in
|
|
2015
|
+
* reading order around the dash: in a right-to-left layout the start is at its right.
|
|
2016
|
+
*/
|
|
2017
|
+
renderValue() {
|
|
2018
|
+
const { locale, range, cycle, mode } = this.cfg;
|
|
2019
|
+
const year = (parseIsoDate(this.cfg.today) ?? { year: new Date().getFullYear() }).year;
|
|
2020
|
+
const time = mode === 'date-time';
|
|
2021
|
+
const part = (moment, placeholder, weekday) => moment.date ? html `<bdi>${headerDateText(locale, moment.date, year, { weekday, time: time ? moment.time : null, cycle })}</bdi>` : html `<bdi class="placeholder">${placeholder || HOLDS_A_LINE}</bdi>`;
|
|
2022
|
+
const { value, start, end } = this.pending;
|
|
2023
|
+
const { dateLabel } = this.say;
|
|
2024
|
+
return html `<div class="value">${range ? html `${part(start, dateLabel, false)} – ${part(end, dateLabel, false)}` : part(value, dateLabel, true)}</div>`;
|
|
2025
|
+
}
|
|
2026
|
+
/**
|
|
2027
|
+
* DTM-13: the entry-mode tabs — two icon-only tabs that hug, the keyboard glyph for the wheels at the start and the
|
|
2028
|
+
* schedule glyph for the dial at the end. No word is drawn: `wheelsLabel` and `dialLabel` are their accessible names.
|
|
2029
|
+
*/
|
|
2030
|
+
renderEntryTabs() {
|
|
2031
|
+
if (!this.hasTime || this.offered !== 'both')
|
|
2032
|
+
return nothing;
|
|
2033
|
+
const say = this.say;
|
|
2034
|
+
return html `<tanrei-tabs class="entry-tabs" variant="secondary" label=${say.entryModeLabel} .value=${this.entry} @change=${this.onEntryTabs}>
|
|
2035
|
+
<tanrei-tab id="entry-wheels" value="wheels" label=${say.wheelsLabel} icon=${ENTRY_GLYPHS.wheels} label-hidden></tanrei-tab>
|
|
2036
|
+
<tanrei-tab id="entry-dial" value="dial" label=${say.dialLabel} icon=${ENTRY_GLYPHS.dial} label-hidden></tanrei-tab>
|
|
2037
|
+
</tanrei-tabs>`;
|
|
2038
|
+
}
|
|
2039
|
+
/** DTM-10: the title row (and in a modal picker with a date, the value and the divider below it). */
|
|
2040
|
+
renderHeader() {
|
|
2041
|
+
const tabs = this.renderEntryTabs();
|
|
2042
|
+
const valueLine = this.modal && this.hasDate;
|
|
2043
|
+
if (!this.modal && tabs === nothing)
|
|
2044
|
+
return nothing;
|
|
2045
|
+
return html `<div part="header" class="header">
|
|
2046
|
+
<div class="title-row"><span class="title">${this.heading || HOLDS_A_LINE}</span>${tabs}</div>
|
|
2047
|
+
${valueLine ? this.renderValue() : nothing}
|
|
2048
|
+
</div>
|
|
2049
|
+
${valueLine ? html `<div class="divider" aria-hidden="true"></div>` : nothing}`;
|
|
2050
|
+
}
|
|
2051
|
+
/** DTM-11: the calendar, in single or range mode, given the pending dates and the picker's words; no label of its own. */
|
|
2052
|
+
renderCalendar() {
|
|
2053
|
+
const { range, min, max, today, disabledDates, firstDayOfWeek, startView, locale } = this.cfg;
|
|
2054
|
+
const date = (moment) => (moment.date ? isoOf(moment.date) : '');
|
|
2055
|
+
return html `<tanrei-calendar
|
|
2056
|
+
part="calendar"
|
|
2057
|
+
class="calendar"
|
|
2058
|
+
mode=${range ? 'range' : 'single'}
|
|
2059
|
+
.value=${range ? '' : date(this.pending.value)}
|
|
2060
|
+
.start=${range ? date(this.pending.start) : ''}
|
|
2061
|
+
.end=${range ? date(this.pending.end) : ''}
|
|
2062
|
+
.min=${min}
|
|
2063
|
+
.max=${max}
|
|
2064
|
+
.today=${today}
|
|
2065
|
+
.disabledDates=${disabledDates}
|
|
2066
|
+
.isDateDisabled=${this.isDateDisabled}
|
|
2067
|
+
.firstDayOfWeek=${firstDayOfWeek}
|
|
2068
|
+
.locale=${locale}
|
|
2069
|
+
.startView=${startView}
|
|
2070
|
+
.showAdjacentDays=${this.showAdjacentDays}
|
|
2071
|
+
.startLabel=${this.startLabel}
|
|
2072
|
+
.endLabel=${this.endLabel}
|
|
2073
|
+
.previousMonthLabel=${this.previousMonthLabel}
|
|
2074
|
+
.nextMonthLabel=${this.nextMonthLabel}
|
|
2075
|
+
.yearViewLabel=${this.yearViewLabel}
|
|
2076
|
+
.todayLabel=${this.todayLabel}
|
|
2077
|
+
@change=${this.onCalendarChange}
|
|
2078
|
+
></tanrei-calendar>`;
|
|
2079
|
+
}
|
|
2080
|
+
/**
|
|
2081
|
+
* DTM-15, DTM-42: the range display — the start's range field, an en dash and the end's, in reading order. Each field
|
|
2082
|
+
* is a button that holds its end's pending time as the locale writes it (an isolated run), "next day" after an
|
|
2083
|
+
* overnight end; no word says start or end. The one the time section sets is drawn from the selected selector's
|
|
2084
|
+
* tokens and is the pressed one; assistive technology hears "Start, 9:00 AM" in a group named rangeLabel. The error
|
|
2085
|
+
* line, while it is shown, describes the end's field (DTM-33).
|
|
2086
|
+
*/
|
|
2087
|
+
renderRangeDisplay() {
|
|
2088
|
+
if (!this.cfg.range)
|
|
2089
|
+
return nothing;
|
|
2090
|
+
const { locale, cycle } = this.cfg;
|
|
2091
|
+
const say = this.say;
|
|
2092
|
+
const field = (end) => {
|
|
2093
|
+
const moment = this.pending[end];
|
|
2094
|
+
const time = moment.time ? timeText(locale, cycle, moment.time) : '';
|
|
2095
|
+
const after = end === 'end' && this.nextDay ? ` ${say.nextDayLabel}` : '';
|
|
2096
|
+
const selected = this.editing === end;
|
|
2097
|
+
const handlers = end === 'start' ? this.startHandlers : this.endHandlers;
|
|
2098
|
+
const press = this.rangePresses[end];
|
|
2099
|
+
return html `<button
|
|
2100
|
+
type="button"
|
|
2101
|
+
part="range-field"
|
|
2102
|
+
class=${classMap({ 'range-field': true, selected })}
|
|
2103
|
+
data-end=${end}
|
|
2104
|
+
?data-ring=${this.ringedEnd === end}
|
|
2105
|
+
data-tanrei-shape
|
|
2106
|
+
aria-pressed=${selected ? 'true' : 'false'}
|
|
2107
|
+
aria-label=${[end === 'start' ? say.startLabel : say.endLabel, `${time}${after}`].filter(Boolean).join(', ')}
|
|
2108
|
+
aria-describedby=${ifDefined(end === 'end' && this.rangeError ? 'range-error' : undefined)}
|
|
2109
|
+
@click=${handlers.onClick}
|
|
2110
|
+
@pointerdown=${handlers.onPointerDown}
|
|
2111
|
+
@pointerup=${press.release}
|
|
2112
|
+
@pointercancel=${press.release}
|
|
2113
|
+
@pointerleave=${press.release}
|
|
2114
|
+
@keydown=${handlers.onKeyDown}
|
|
2115
|
+
@keyup=${press.onKeyUp}
|
|
2116
|
+
@blur=${handlers.onBlur}
|
|
2117
|
+
@focus=${handlers.onFocus}
|
|
2118
|
+
>
|
|
2119
|
+
<span class="value"><bdi>${time}</bdi>${after}</span>
|
|
2120
|
+
</button>`;
|
|
2121
|
+
};
|
|
2122
|
+
return html `<div part="range-display" class="range-display" role="group" aria-label=${ifDefined(say.rangeLabel || undefined)}>
|
|
2123
|
+
${field('start')}<span part="range-separator" class="range-separator" aria-hidden="true">–</span>${field('end')}
|
|
2124
|
+
</div>`;
|
|
2125
|
+
}
|
|
2126
|
+
/** DTM-14: whether the locale writes the period before the hour ("午前7:30"); otherwise it stands after the minute. */
|
|
2127
|
+
get periodFirst() {
|
|
2128
|
+
return periodPlace(this.cfg.locale) === 'before';
|
|
2129
|
+
}
|
|
2130
|
+
/** The two names of the period, each in the same place: the part is as wide as the wider needs, whichever is shown. */
|
|
2131
|
+
periodNames(shown) {
|
|
2132
|
+
return html `${periodNames(this.cfg.locale).map((name, index) => html `<span class="name" ?data-off=${index !== shown}>${name}</span>`)}`;
|
|
2133
|
+
}
|
|
2134
|
+
/**
|
|
2135
|
+
* DTM-46, DTM-47: the period wheel — two rows, the name before noon above the one after, that do not run on; the
|
|
2136
|
+
* pending period on its selection container (its own, or its part of the joined band). Its control is its middle row,
|
|
2137
|
+
* a spin button of two values that takes no text: a period is not typed.
|
|
2138
|
+
*/
|
|
2139
|
+
renderPeriodWheel() {
|
|
2140
|
+
const names = periodNames(this.cfg.locale);
|
|
2141
|
+
const wheel = this.periodWheel;
|
|
2142
|
+
const position = wheel.at + wheel.shift;
|
|
2143
|
+
const following = wheel.pointer !== null || wheel.scrolling !== 0;
|
|
2144
|
+
const pending = periodOf(this.time.hour);
|
|
2145
|
+
return html `<div
|
|
2146
|
+
part="period"
|
|
2147
|
+
class=${classMap({ wheel: true, period: true, following })}
|
|
2148
|
+
data-unit="period"
|
|
2149
|
+
?data-ring=${this.ringed === 'period'}
|
|
2150
|
+
@pointerdown=${this.onPeriodPointerDown}
|
|
2151
|
+
@pointermove=${this.onPeriodPointerMove}
|
|
2152
|
+
@pointerup=${this.onPeriodPointerUp}
|
|
2153
|
+
@pointercancel=${this.onPeriodPointerCancel}
|
|
2154
|
+
@lostpointercapture=${this.onPeriodPointerCancel}
|
|
2155
|
+
@mousedown=${this.onWheelMouseDown}
|
|
2156
|
+
@wheel=${this.onPeriodScroll}
|
|
2157
|
+
>
|
|
2158
|
+
<span class="ground" data-tanrei-shape aria-hidden="true"></span>
|
|
2159
|
+
<span class="ring" data-tanrei-shape aria-hidden="true"></span>
|
|
2160
|
+
<span class="measure" aria-hidden="true">${this.periodNames(null)}</span>
|
|
2161
|
+
<div class="rows" aria-hidden="true">
|
|
2162
|
+
${names.map((name, at) => html `<span class=${classMap({ row: true, on: Math.abs(at - position) < 0.5 })} style=${styleMap({ '--_at': String(at - position) })}>${name}</span>`)}
|
|
2163
|
+
</div>
|
|
2164
|
+
<div
|
|
2165
|
+
class="entry"
|
|
2166
|
+
data-unit="period"
|
|
2167
|
+
role="spinbutton"
|
|
2168
|
+
tabindex="0"
|
|
2169
|
+
aria-label=${ifDefined(this.say.periodLabel || undefined)}
|
|
2170
|
+
aria-valuenow=${pending}
|
|
2171
|
+
aria-valuemin="0"
|
|
2172
|
+
aria-valuemax="1"
|
|
2173
|
+
aria-valuetext=${names[pending]}
|
|
2174
|
+
@keydown=${this.onPeriodKeyDown}
|
|
2175
|
+
@focus=${this.periodHandlers.onFocus}
|
|
2176
|
+
@blur=${this.periodHandlers.onBlur}
|
|
2177
|
+
></div>
|
|
2178
|
+
</div>`;
|
|
2179
|
+
}
|
|
2180
|
+
/**
|
|
2181
|
+
* DTM-14, DTM-47: the period selector — a spin button of two values that shows the pending period's name and changes
|
|
2182
|
+
* to the other on a press. It is drawn from the unselected selector's tokens in every state: it never takes the
|
|
2183
|
+
* selected class, which marks the unit the dial sets.
|
|
2184
|
+
*/
|
|
2185
|
+
renderPeriodSelector() {
|
|
2186
|
+
const names = periodNames(this.cfg.locale);
|
|
2187
|
+
const pending = periodOf(this.time.hour);
|
|
2188
|
+
const press = this.periodPress;
|
|
2189
|
+
return html `<div
|
|
2190
|
+
part="period"
|
|
2191
|
+
class="selector period"
|
|
2192
|
+
data-unit="period"
|
|
2193
|
+
role="spinbutton"
|
|
2194
|
+
tabindex="0"
|
|
2195
|
+
aria-label=${ifDefined(this.say.periodLabel || undefined)}
|
|
2196
|
+
aria-valuenow=${pending}
|
|
2197
|
+
aria-valuemin="0"
|
|
2198
|
+
aria-valuemax="1"
|
|
2199
|
+
aria-valuetext=${names[pending]}
|
|
2200
|
+
data-tanrei-shape
|
|
2201
|
+
?data-ring=${this.ringed === 'period'}
|
|
2202
|
+
@pointerdown=${this.periodHandlers.onPointerDown}
|
|
2203
|
+
@pointerup=${press.release}
|
|
2204
|
+
@pointercancel=${press.release}
|
|
2205
|
+
@pointerleave=${press.release}
|
|
2206
|
+
@click=${this.periodHandlers.onClick}
|
|
2207
|
+
@keydown=${this.periodHandlers.onKeyDown}
|
|
2208
|
+
@keyup=${press.onKeyUp}
|
|
2209
|
+
@blur=${() => {
|
|
2210
|
+
press.onBlur();
|
|
2211
|
+
this.periodHandlers.onBlur();
|
|
2212
|
+
}}
|
|
2213
|
+
@focus=${this.periodHandlers.onFocus}
|
|
2214
|
+
>
|
|
2215
|
+
<span class="value">${this.periodNames(pending)}</span>
|
|
2216
|
+
</div>`;
|
|
2217
|
+
}
|
|
2218
|
+
separator() {
|
|
2219
|
+
return html `<span part="separator" class="separator" aria-hidden="true">${timeSeparator(this.cfg.locale)}</span>`;
|
|
2220
|
+
}
|
|
2221
|
+
/**
|
|
2222
|
+
* DTM-18, DTM-20, DTM-43: one wheel — its rows running on past its ends, the pending value on its selection container
|
|
2223
|
+
* — whose control is its middle row: a native input that is a spin button, read-only until a number is typed into it,
|
|
2224
|
+
* showing the digits typed in place of the value.
|
|
2225
|
+
*/
|
|
2226
|
+
renderWheel(unit) {
|
|
2227
|
+
const { locale, cycle } = this.cfg;
|
|
2228
|
+
const wheel = this.wheels[unit];
|
|
2229
|
+
const values = this.values(unit);
|
|
2230
|
+
const n = values.length;
|
|
2231
|
+
const position = wheel.at + wheel.shift;
|
|
2232
|
+
const around = 4;
|
|
2233
|
+
const rows = [];
|
|
2234
|
+
for (let at = Math.floor(position) - around; at <= Math.ceil(position) + around; at++)
|
|
2235
|
+
rows.push(at);
|
|
2236
|
+
const text = (index) => {
|
|
2237
|
+
const value = values[mod(index, n)];
|
|
2238
|
+
return unit === 'minute' ? minuteText(locale, value) : hourText(locale, cycle, cycle === 'h12' ? hourOf12(value, 0) : value);
|
|
2239
|
+
};
|
|
2240
|
+
const aria = this.spinAria(unit);
|
|
2241
|
+
const following = wheel.pointer !== null || wheel.scrolling !== 0;
|
|
2242
|
+
const typing = this.typed?.unit === unit;
|
|
2243
|
+
const digits = typing ? this.typed.digits : '';
|
|
2244
|
+
return html `<div
|
|
2245
|
+
part="wheel"
|
|
2246
|
+
class=${classMap({ wheel: true, following, typing, typed: digits !== '' })}
|
|
2247
|
+
data-unit=${unit}
|
|
2248
|
+
?data-ring=${this.ringed === unit}
|
|
2249
|
+
@pointerdown=${this.onWheelPointerDown}
|
|
2250
|
+
@pointermove=${this.onWheelPointerMove}
|
|
2251
|
+
@pointerup=${this.onWheelPointerUp}
|
|
2252
|
+
@pointercancel=${this.onWheelPointerCancel}
|
|
2253
|
+
@lostpointercapture=${this.onWheelPointerCancel}
|
|
2254
|
+
@mousedown=${this.onWheelMouseDown}
|
|
2255
|
+
@wheel=${this.onWheelScroll}
|
|
2256
|
+
>
|
|
2257
|
+
<span class="ground" data-tanrei-shape aria-hidden="true"></span>
|
|
2258
|
+
<span class="ring" data-tanrei-shape aria-hidden="true"></span>
|
|
2259
|
+
<div class="rows" aria-hidden="true">
|
|
2260
|
+
${repeat(rows, (at) => at, (at) => html `<span class=${classMap({ row: true, on: Math.abs(at - position) < 0.5 })} style=${styleMap({ '--_at': String(at - position) })}>${text(at)}</span>`)}
|
|
2261
|
+
</div>
|
|
2262
|
+
<input
|
|
2263
|
+
class="entry"
|
|
2264
|
+
data-unit=${unit}
|
|
2265
|
+
type="text"
|
|
2266
|
+
inputmode="numeric"
|
|
2267
|
+
enterkeyhint="done"
|
|
2268
|
+
autocomplete="off"
|
|
2269
|
+
autocorrect="off"
|
|
2270
|
+
spellcheck="false"
|
|
2271
|
+
role="spinbutton"
|
|
2272
|
+
.value=${this.typedText(digits)}
|
|
2273
|
+
?readonly=${!typing && this.armed !== unit}
|
|
2274
|
+
aria-label=${ifDefined((unit === 'hour' ? this.say.hourLabel : this.say.minuteLabel) || undefined)}
|
|
2275
|
+
aria-valuenow=${aria.now}
|
|
2276
|
+
aria-valuemin=${aria.min}
|
|
2277
|
+
aria-valuemax=${aria.max}
|
|
2278
|
+
aria-valuetext=${aria.text}
|
|
2279
|
+
@keydown=${this.onWheelKeyDown}
|
|
2280
|
+
@input=${this.onSpinInput}
|
|
2281
|
+
@focus=${this.onSpinFocus}
|
|
2282
|
+
@blur=${this.onSpinBlur}
|
|
2283
|
+
/>
|
|
2284
|
+
</div>`;
|
|
2285
|
+
}
|
|
2286
|
+
/**
|
|
2287
|
+
* DTM-18: the hour wheel, the separator and the minute wheel, left to right — each wheel on a selection container of
|
|
2288
|
+
* its own, or, where the system joins them (wheel.selection.span, read from the cascade now), on one band. DTM-46: with
|
|
2289
|
+
* the 12-hour clock the period wheel beside them, after the minute or before the hour as the locale writes a time —
|
|
2290
|
+
* its side follows the layout direction, the digits do not (DTM-39) — on the same band where the span is joined.
|
|
2291
|
+
*/
|
|
2292
|
+
renderWheels() {
|
|
2293
|
+
const period = this.cfg.cycle === 'h12';
|
|
2294
|
+
const first = period && this.periodFirst;
|
|
2295
|
+
return html `<div class="wheels" data-frame=${this.wheelFrame} data-span=${compChoice(this, `${PREFIX}-wheel-selection-span`, SPANS)}>
|
|
2296
|
+
<span class="band" data-tanrei-shape aria-hidden="true"></span>
|
|
2297
|
+
${first ? this.renderPeriodWheel() : nothing}
|
|
2298
|
+
<div class="digits" dir="ltr">${this.renderWheel('hour')}${this.separator()}${this.renderWheel('minute')}</div>
|
|
2299
|
+
${period && !first ? this.renderPeriodWheel() : nothing}
|
|
2300
|
+
</div>`;
|
|
2301
|
+
}
|
|
2302
|
+
/**
|
|
2303
|
+
* DTM-12: what the other entry mode needs of the section's width, measured and never drawn — the time display beside
|
|
2304
|
+
* or above the dial for the wheels mode, the wheels for the dial mode — so that the section is as wide in the one mode
|
|
2305
|
+
* as in the other and switching does not change the picker's width. Only where the system offers both.
|
|
2306
|
+
*/
|
|
2307
|
+
renderMeasure(dial) {
|
|
2308
|
+
if (this.offered !== 'both')
|
|
2309
|
+
return nothing;
|
|
2310
|
+
const period = this.cfg.cycle === 'h12';
|
|
2311
|
+
const first = period && this.periodFirst;
|
|
2312
|
+
const separator = html `<span class="separator">${timeSeparator(this.cfg.locale)}</span>`;
|
|
2313
|
+
if (dial) {
|
|
2314
|
+
const wheel = html `<span class="wheel"></span>`;
|
|
2315
|
+
const name = html `<span class="wheel period"><span class="measure">${this.periodNames(null)}</span></span>`;
|
|
2316
|
+
return html `<div class="other-mode" aria-hidden="true">
|
|
2317
|
+
<div class="wheels">${first ? name : nothing}<div class="digits" dir="ltr">${wheel}${separator}${wheel}</div>${period && !first ? name : nothing}</div>
|
|
2318
|
+
</div>`;
|
|
2319
|
+
}
|
|
2320
|
+
const selector = html `<span class="selector"></span>`;
|
|
2321
|
+
const name = html `<span class="selector period"><span class="value">${this.periodNames(null)}</span></span>`;
|
|
2322
|
+
return html `<div class="other-mode" aria-hidden="true">
|
|
2323
|
+
<div class="display">${first ? name : nothing}<div class="digits" dir="ltr">${selector}${separator}${selector}</div>${period && !first ? name : nothing}</div>
|
|
2324
|
+
<span class="dial-room"></span>
|
|
2325
|
+
</div>`;
|
|
2326
|
+
}
|
|
2327
|
+
/** DTM-21, DTM-22: a selector — a spin button drawn from its condition. */
|
|
2328
|
+
renderSelector(unit) {
|
|
2329
|
+
const handlers = unit === 'hour' ? this.hourHandlers : this.minuteHandlers;
|
|
2330
|
+
const press = this.presses[unit];
|
|
2331
|
+
const aria = this.spinAria(unit);
|
|
2332
|
+
const { locale, cycle } = this.cfg;
|
|
2333
|
+
// DTM-22: what has been typed is the selector's text for as long as the entry lasts.
|
|
2334
|
+
const digits = this.typed?.unit === unit ? this.typed.digits : '';
|
|
2335
|
+
const text = digits ? this.typedText(digits) : unit === 'hour' ? hourText(locale, cycle, this.time.hour) : minuteText(locale, this.time.minute);
|
|
2336
|
+
return html `<div
|
|
2337
|
+
part="selector"
|
|
2338
|
+
class=${classMap({ selector: true, selected: this.shownUnit === unit })}
|
|
2339
|
+
data-unit=${unit}
|
|
2340
|
+
role="spinbutton"
|
|
2341
|
+
tabindex="0"
|
|
2342
|
+
aria-label=${ifDefined((unit === 'hour' ? this.say.hourLabel : this.say.minuteLabel) || undefined)}
|
|
2343
|
+
aria-valuenow=${aria.now}
|
|
2344
|
+
aria-valuemin=${aria.min}
|
|
2345
|
+
aria-valuemax=${aria.max}
|
|
2346
|
+
aria-valuetext=${aria.text}
|
|
2347
|
+
data-tanrei-shape
|
|
2348
|
+
@pointerdown=${handlers.onPointerDown}
|
|
2349
|
+
@pointerup=${press.release}
|
|
2350
|
+
@pointercancel=${press.release}
|
|
2351
|
+
@pointerleave=${press.release}
|
|
2352
|
+
@keydown=${handlers.onKeyDown}
|
|
2353
|
+
@keyup=${press.onKeyUp}
|
|
2354
|
+
@blur=${handlers.onBlur}
|
|
2355
|
+
@focus=${handlers.onFocus}
|
|
2356
|
+
>
|
|
2357
|
+
<span class="value">${text}</span>
|
|
2358
|
+
</div>`;
|
|
2359
|
+
}
|
|
2360
|
+
/** DTM-23: the numbers of a unit around the dial, clockwise from the top (two rings for the 24-hour hours). */
|
|
2361
|
+
dialNumbers(unit) {
|
|
2362
|
+
const { locale, cycle, step } = this.cfg;
|
|
2363
|
+
if (unit === 'minute') {
|
|
2364
|
+
const every = step <= 5 ? 5 : step;
|
|
2365
|
+
return stepMinutes(every).map((minute) => ({ text: numberText(locale, minute, 2), inner: false, ...direction(minute * 6) }));
|
|
2366
|
+
}
|
|
2367
|
+
const ring = (inner, value, digits) => Array.from({ length: 12 }, (_, index) => ({ text: numberText(locale, value(index), digits), inner, ...direction(index * 30) }));
|
|
2368
|
+
if (cycle === 'h12')
|
|
2369
|
+
return ring(false, (index) => (index === 0 ? 12 : index), 1);
|
|
2370
|
+
return [...ring(false, (index) => index, 2), ...ring(true, (index) => index + 12, 2)];
|
|
2371
|
+
}
|
|
2372
|
+
numbers() {
|
|
2373
|
+
const layer = (unit) => html `<div class=${classMap({ numbers: true, [`${unit}s`]: true, faded: this.shownUnit !== unit })}>
|
|
2374
|
+
${this.dialNumbers(unit).map((number) => html `<span class=${classMap({ number: true, inner: number.inner, outer: !number.inner })} style=${styleMap({ '--_x': String(number.x), '--_y': String(number.y) })}
|
|
2375
|
+
>${number.text}</span
|
|
2376
|
+
>`)}
|
|
2377
|
+
</div>`;
|
|
2378
|
+
return html `${layer('hour')}${layer('minute')}`;
|
|
2379
|
+
}
|
|
2380
|
+
/** DTM-23 … DTM-25: the dial, its numbers, the handle over the pending value and the track to it; hidden from assistive technology. */
|
|
2381
|
+
renderDial() {
|
|
2382
|
+
const between = this.shownUnit === 'minute' && this.time.minute % 5 !== 0;
|
|
2383
|
+
return html `<div
|
|
2384
|
+
part="dial"
|
|
2385
|
+
class="dial"
|
|
2386
|
+
aria-hidden="true"
|
|
2387
|
+
data-ring=${this.innerRing ? 'inner' : 'outer'}
|
|
2388
|
+
?data-instant=${this.instant}
|
|
2389
|
+
style=${styleMap({ '--_angle': `${this.angle}deg` })}
|
|
2390
|
+
@pointerdown=${this.onDialDown}
|
|
2391
|
+
@pointermove=${this.onDialMove}
|
|
2392
|
+
@pointerup=${this.onDialUp}
|
|
2393
|
+
@pointercancel=${this.onDialCancel}
|
|
2394
|
+
@lostpointercapture=${this.onDialCancel}
|
|
2395
|
+
>
|
|
2396
|
+
<div class="face">${this.numbers()}</div>
|
|
2397
|
+
<div class="center"></div>
|
|
2398
|
+
<div class="arm">
|
|
2399
|
+
<div class="track"></div>
|
|
2400
|
+
<div part="handle" class="handle">
|
|
2401
|
+
<div class="copy">${this.numbers()}</div>
|
|
2402
|
+
${between ? html `<div class="between"></div>` : nothing}
|
|
2403
|
+
</div>
|
|
2404
|
+
</div>
|
|
2405
|
+
</div>`;
|
|
2406
|
+
}
|
|
2407
|
+
/**
|
|
2408
|
+
* DTM-12: the time section, top to bottom — the range display across its whole width, the time display (dial) and the
|
|
2409
|
+
* wheels or the dial; the time display is the row next to the dial. DTM-14: the period of a 12-hour time is a part of
|
|
2410
|
+
* the time display (the period selector) and of the wheels (the period wheel) — after the minute, or before the hour
|
|
2411
|
+
* where the locale writes it first; its side follows the layout direction while the hour, the separator and the minute
|
|
2412
|
+
* stay left to right (DTM-39). There is no row of tabs in the section.
|
|
2413
|
+
*/
|
|
2414
|
+
renderTime() {
|
|
2415
|
+
const dial = this.shownEntry === 'dial';
|
|
2416
|
+
const entryTabs = this.offered === 'both';
|
|
2417
|
+
const period = this.cfg.cycle === 'h12';
|
|
2418
|
+
const first = period && this.periodFirst;
|
|
2419
|
+
const clock = dial ? this.renderDial() : this.renderWheels();
|
|
2420
|
+
const display = dial
|
|
2421
|
+
? html `<div class="display">
|
|
2422
|
+
${first ? this.renderPeriodSelector() : nothing}
|
|
2423
|
+
<div class="digits" dir="ltr">${this.renderSelector('hour')}${this.separator()}${this.renderSelector('minute')}</div>
|
|
2424
|
+
${period && !first ? this.renderPeriodSelector() : nothing}
|
|
2425
|
+
</div>`
|
|
2426
|
+
: nothing;
|
|
2427
|
+
return html `<div part="time" class=${classMap({ time: true, 'by-dial': dial, 'by-wheels': !dial })} id="time-panel" role=${ifDefined(entryTabs ? 'tabpanel' : undefined)} aria-labelledby=${ifDefined(entryTabs ? `entry-${this.shownEntry}` : undefined)}>
|
|
2428
|
+
${this.renderRangeDisplay()}${display}${clock}${this.renderMeasure(dial)}
|
|
2429
|
+
</div>`;
|
|
2430
|
+
}
|
|
2431
|
+
/** DTM-34: Cancel and OK, placed as a full-width Button group places a dismissive and a confirming item. */
|
|
2432
|
+
renderActions() {
|
|
2433
|
+
if (!this.pendingUntilOk)
|
|
2434
|
+
return nothing;
|
|
2435
|
+
const variant = compChoice(this, `${PREFIX}-actions-variant`, BUTTON_VARIANTS);
|
|
2436
|
+
const { cancelLabel, confirmLabel } = this.say;
|
|
2437
|
+
// DTM-48: without its word a Button draws the glyph that says the same — close, check — alone: the same variant,
|
|
2438
|
+
// size and place, and no name.
|
|
2439
|
+
const words = (label, glyph) => (label ? label : html `<span slot="icon">${glyph}</span>`);
|
|
2440
|
+
const actions = [
|
|
2441
|
+
{ key: 'cancel', template: html `<tanrei-button class="cancel" dismissive variant=${variant} size="medium" @click=${this.onCancel}>${words(cancelLabel, ACTION_GLYPHS.cancel)}</tanrei-button>` },
|
|
2442
|
+
{
|
|
2443
|
+
key: 'confirm',
|
|
2444
|
+
template: html `<tanrei-button class="confirm" confirming variant=${variant} size="medium" ?disabled=${!this.confirmable} @click=${this.onConfirm}>${words(confirmLabel, ACTION_GLYPHS.confirm)}</tanrei-button>`,
|
|
2445
|
+
},
|
|
2446
|
+
];
|
|
2447
|
+
const ordered = this.stacked ? [actions[1], actions[0]] : actions;
|
|
2448
|
+
return html `<div part="actions" class=${classMap({ actions: true, stacked: this.stacked })}>
|
|
2449
|
+
${repeat(ordered, (action) => action.key, (action) => action.template)}
|
|
2450
|
+
</div>`;
|
|
2451
|
+
}
|
|
2452
|
+
render() {
|
|
2453
|
+
if (!this.cfg)
|
|
2454
|
+
this.cfg = this.readConfig();
|
|
2455
|
+
const modal = this.cfg.presentation === 'modal';
|
|
2456
|
+
const error = this.session && this.rangeError;
|
|
2457
|
+
const content = this.session
|
|
2458
|
+
? html `${this.renderHeader()}
|
|
2459
|
+
<div class="body">${this.hasDate ? this.renderCalendar() : nothing}${this.hasTime ? this.renderTime() : nothing}</div>
|
|
2460
|
+
${error ? html `<div part="error" class="error" id="range-error">${this.say.rangeErrorText || HOLDS_A_LINE}</div>` : nothing} ${this.renderActions()}`
|
|
2461
|
+
: nothing;
|
|
2462
|
+
const extras = html `<span class="hold" aria-hidden="true"></span><div class="announce" aria-live="polite"></div>`;
|
|
2463
|
+
const classes = classMap({
|
|
2464
|
+
surface: true,
|
|
2465
|
+
modal,
|
|
2466
|
+
docked: !modal,
|
|
2467
|
+
inline: this.inline,
|
|
2468
|
+
[`mode-${this.cfg.mode}`]: true,
|
|
2469
|
+
});
|
|
2470
|
+
const label = this.heading;
|
|
2471
|
+
if (modal) {
|
|
2472
|
+
return html `<dialog
|
|
2473
|
+
part="container"
|
|
2474
|
+
class=${classes}
|
|
2475
|
+
aria-label=${ifDefined(label || undefined)}
|
|
2476
|
+
tabindex="-1"
|
|
2477
|
+
data-tanrei-shape
|
|
2478
|
+
@keydown=${this.onSurfaceKeyDown}
|
|
2479
|
+
@cancel=${this.onNativeCancel}
|
|
2480
|
+
@pointerdown=${this.onDialogPointerDown}
|
|
2481
|
+
@click=${this.onDialogClick}
|
|
2482
|
+
>
|
|
2483
|
+
${content}${extras}
|
|
2484
|
+
</dialog>`;
|
|
2485
|
+
}
|
|
2486
|
+
return html `<div
|
|
2487
|
+
part="container"
|
|
2488
|
+
class=${classes}
|
|
2489
|
+
role="dialog"
|
|
2490
|
+
aria-label=${ifDefined(label || undefined)}
|
|
2491
|
+
data-tanrei-shape
|
|
2492
|
+
popover=${ifDefined(this.inline ? undefined : 'manual')}
|
|
2493
|
+
@keydown=${this.onSurfaceKeyDown}
|
|
2494
|
+
@pointerdown=${this.onSurfacePointerDown}
|
|
2495
|
+
@mousedown=${this.onSurfaceMouseDown}
|
|
2496
|
+
>
|
|
2497
|
+
${content}${extras}
|
|
2498
|
+
</div>`;
|
|
2499
|
+
}
|
|
2500
|
+
}
|
|
2501
|
+
/**
|
|
2502
|
+
* Focus to `element` with `options`. `showModal()` may have focused it already (the dialog's focusing steps): it is
|
|
2503
|
+
* focused again, so that whether its ring shows is the options' call, not the first focus's.
|
|
2504
|
+
*/
|
|
2505
|
+
function focusAgain(element, options) {
|
|
2506
|
+
if (!element)
|
|
2507
|
+
return;
|
|
2508
|
+
if (deepActive() === element)
|
|
2509
|
+
element.blur();
|
|
2510
|
+
element.focus(options);
|
|
2511
|
+
}
|
|
2512
|
+
/**
|
|
2513
|
+
* DTM-37: the element a docked picker's opener exposes its state on — the opener itself, or, for a component that holds
|
|
2514
|
+
* its button in a shadow root (a text field's picker button, a Tanrei Button), the native control inside it that says
|
|
2515
|
+
* it opens a dialog, else its first button.
|
|
2516
|
+
*/
|
|
2517
|
+
function findOpenerTarget(element) {
|
|
2518
|
+
const search = (root, depth) => {
|
|
2519
|
+
if (!root || depth > 3)
|
|
2520
|
+
return null;
|
|
2521
|
+
const popup = root.querySelector('[aria-haspopup="dialog"]');
|
|
2522
|
+
if (popup)
|
|
2523
|
+
return popup;
|
|
2524
|
+
for (const inner of root.querySelectorAll('*')) {
|
|
2525
|
+
const found = inner.shadowRoot ? search(inner.shadowRoot, depth + 1) : null;
|
|
2526
|
+
if (found)
|
|
2527
|
+
return found;
|
|
2528
|
+
}
|
|
2529
|
+
return null;
|
|
2530
|
+
};
|
|
2531
|
+
if (!element.shadowRoot)
|
|
2532
|
+
return element;
|
|
2533
|
+
return search(element.shadowRoot, 0) ?? element.shadowRoot.querySelector('button, [role="button"]') ?? element;
|
|
2534
|
+
}
|
|
2535
|
+
if (!customElements.get('tanrei-date-time-picker'))
|
|
2536
|
+
customElements.define('tanrei-date-time-picker', TanreiDateTimePicker);
|
|
2537
|
+
//# sourceMappingURL=date-time-picker.js.map
|