@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,1352 @@
|
|
|
1
|
+
import { LitElement, html, nothing } from 'lit';
|
|
2
|
+
import { hiddenHost } from '../../primitives/hidden.js';
|
|
3
|
+
import { AvailabilityController, DIRECTION_PROBE, DirectionController, PressController, RovingKeys, hostAria, report, slottedInteractive, syncFocusStyle, WordsController } from '../../primitives/index.js';
|
|
4
|
+
import { CarouselGeometry } from './carousel-geometry.js';
|
|
5
|
+
import { carouselStyles, itemStyles } from './carousel.styles.js';
|
|
6
|
+
const HERO_ALIGNMENTS = ['start', 'center'];
|
|
7
|
+
const CONTENT_ALIGNMENTS = ['center', 'toward-hero'];
|
|
8
|
+
/**
|
|
9
|
+
* A release at least this fast is a fling (CRL-14), in px per ms: the web names no minimum fling velocity of its own,
|
|
10
|
+
* so the spec's 0.5 points per millisecond. A behaviour of the spec, not a design value.
|
|
11
|
+
*/
|
|
12
|
+
const FLING_VELOCITY = 0.5;
|
|
13
|
+
/** How far back the velocity of a release looks, in ms: a finger that stopped longer ago than this releases at rest. */
|
|
14
|
+
const VELOCITY_WINDOW = 80;
|
|
15
|
+
/**
|
|
16
|
+
* Where no `scrollend` comes, a scroll counts as over once no scroll event has come for this long, in ms. A behaviour
|
|
17
|
+
* constant of the fallback, not a design value.
|
|
18
|
+
*/
|
|
19
|
+
const SCROLL_IDLE = 100;
|
|
20
|
+
/** The glyphs of the playback control (CRL-35): ligatures of the system's icon set. */
|
|
21
|
+
const GLYPH_PAUSE = 'pause';
|
|
22
|
+
const GLYPH_PLAY = 'play_arrow';
|
|
23
|
+
/**
|
|
24
|
+
* One item of a carousel — the spec's item kind `item`: the product's content in a rounded box, one action
|
|
25
|
+
* named by its label. A child of `<tanrei-carousel>`, which places it, sizes it and says which item is the Tab stop.
|
|
26
|
+
*
|
|
27
|
+
* The host is a `listitem` with its position among the items; inside it one element has the button role, named by
|
|
28
|
+
* `label` — the content is not read (CRL-19). The content is the default slot: an image, a poster, anything that is not
|
|
29
|
+
* interactive (CRL-20). The item lays it out at the hero's width and the carousel's height, aligned as the carousel
|
|
30
|
+
* says, clips it to its corners and hands it `comp.carousel.item.content.color` as the inherited `color` (CRL-15,
|
|
31
|
+
* CRL-16). Give an image `inline-size: 100%; block-size: 100%; object-fit: cover`.
|
|
32
|
+
*
|
|
33
|
+
* @tag tanrei-carousel-item
|
|
34
|
+
* @slot - The content: an image or other visual, never anything interactive.
|
|
35
|
+
* @csspart container - The item's rounded box: its resting fill, its corners, every state and the button semantics.
|
|
36
|
+
* @csspart content - The box the content is laid out in: the hero's width, the item's height.
|
|
37
|
+
* @csspart state-layer - The layer over the content that shows hover, focus and press (CRL-16).
|
|
38
|
+
* @fires click - The item was activated by pointer, touch, keyboard or assistive technology.
|
|
39
|
+
*/
|
|
40
|
+
export class TanreiCarouselItem extends LitElement {
|
|
41
|
+
constructor() {
|
|
42
|
+
super(...arguments);
|
|
43
|
+
/** The item's accessible name: what its content shows ("Coast path, 12 photos"). Required; the content is not read. */
|
|
44
|
+
this.label = '';
|
|
45
|
+
/** What the carousel says about this item. */
|
|
46
|
+
this.context = { tabStop: false, position: 0, size: 0 };
|
|
47
|
+
/** CRL-5 / CRL-6: the pressed state, press-hold and the answer the system chooses (src/primitives/press.ts). */
|
|
48
|
+
this.press = new PressController(this, {
|
|
49
|
+
container: () => this.container,
|
|
50
|
+
holdCarrier: () => this.renderRoot?.querySelector('.clip') ?? null,
|
|
51
|
+
disabled: () => false,
|
|
52
|
+
});
|
|
53
|
+
/** Space activates on key-up, as a native button does, and only when the key went down on the item. */
|
|
54
|
+
this.spaceDown = false;
|
|
55
|
+
}
|
|
56
|
+
static { this.styles = [itemStyles, hiddenHost]; }
|
|
57
|
+
// `element.focus()` focuses the item's button; the carousel moves focus between items this way.
|
|
58
|
+
static { this.shadowRootOptions = { ...LitElement.shadowRootOptions, delegatesFocus: true }; }
|
|
59
|
+
static { this.properties = {
|
|
60
|
+
label: { type: String },
|
|
61
|
+
context: { state: true },
|
|
62
|
+
}; }
|
|
63
|
+
get container() {
|
|
64
|
+
return this.renderRoot?.querySelector('.container') ?? null;
|
|
65
|
+
}
|
|
66
|
+
/** @internal The carousel's side: which item is the Tab stop, and the item's position and the number of items. */
|
|
67
|
+
setCarouselContext(context) {
|
|
68
|
+
const now = this.context;
|
|
69
|
+
if (context.tabStop === now.tabStop && context.position === now.position && context.size === now.size)
|
|
70
|
+
return;
|
|
71
|
+
this.context = context;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* @internal CRL-8, CRL-12, CRL-15, CRL-26, CRL-40: where the carousel draws the item — the drawn container's start
|
|
75
|
+
* along the row and its width — the width its content is laid out at, where the content sits and the scale of its
|
|
76
|
+
* height and content. Written as custom properties on the host, so a scroll re-renders nothing.
|
|
77
|
+
*/
|
|
78
|
+
place({ start, width, content, contentLeft, scale, narrow }) {
|
|
79
|
+
this.style.setProperty('--_x', `${start}px`);
|
|
80
|
+
this.style.setProperty('--_w', `${width}px`);
|
|
81
|
+
this.style.setProperty('--_content', `${content}px`);
|
|
82
|
+
this.style.setProperty('--_content-left', `${contentLeft}px`);
|
|
83
|
+
if (scale === null)
|
|
84
|
+
this.style.removeProperty('--_scale');
|
|
85
|
+
else
|
|
86
|
+
this.style.setProperty('--_scale', String(scale));
|
|
87
|
+
// CRL-4: an item narrower than any slot gets no hit area beyond its container and half the gap on each side.
|
|
88
|
+
if (narrow)
|
|
89
|
+
this.style.setProperty('--_hit-floor', '0px');
|
|
90
|
+
else
|
|
91
|
+
this.style.removeProperty('--_hit-floor');
|
|
92
|
+
}
|
|
93
|
+
/** @internal Moves keyboard focus to the item's button. */
|
|
94
|
+
focusButton(options) {
|
|
95
|
+
this.container?.focus(options);
|
|
96
|
+
}
|
|
97
|
+
/** CRL-7: where style queries are missing, the focus style is read when focus arrives. */
|
|
98
|
+
onFocus() {
|
|
99
|
+
syncFocusStyle(this, this.container);
|
|
100
|
+
}
|
|
101
|
+
/** CRL-1: Enter activates on key-down and Space on key-up, as a native button does. */
|
|
102
|
+
onKeyDown(event) {
|
|
103
|
+
if (event.target !== this.container)
|
|
104
|
+
return;
|
|
105
|
+
this.press.onKeyDown(event);
|
|
106
|
+
if (event.key === 'Enter') {
|
|
107
|
+
if (!event.repeat)
|
|
108
|
+
this.container?.click();
|
|
109
|
+
}
|
|
110
|
+
else if (event.key === ' ') {
|
|
111
|
+
// Space would scroll the row or the page.
|
|
112
|
+
event.preventDefault();
|
|
113
|
+
this.spaceDown = true;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
onKeyUp(event) {
|
|
117
|
+
this.press.onKeyUp(event);
|
|
118
|
+
if (event.key !== ' ' || !this.spaceDown)
|
|
119
|
+
return;
|
|
120
|
+
this.spaceDown = false;
|
|
121
|
+
this.container?.click();
|
|
122
|
+
}
|
|
123
|
+
onBlur() {
|
|
124
|
+
// A Space whose key-up arrives somewhere else does not activate, as on a native button.
|
|
125
|
+
this.spaceDown = false;
|
|
126
|
+
this.press.onBlur();
|
|
127
|
+
}
|
|
128
|
+
/** CRL-20: an item's content holds nothing interactive; a debug build names what it found, on every slot change. */
|
|
129
|
+
async inspectContent() {
|
|
130
|
+
const found = await slottedInteractive(this.renderRoot.querySelector('slot'));
|
|
131
|
+
if (found) {
|
|
132
|
+
report(this, 'CRL-20', `a carousel item holds an interactive element (<${found.localName}>), which assistive technology cannot reach and whose press would also activate the item; an item is one action — put other actions outside the carousel`);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
updated(changed) {
|
|
136
|
+
const { position, size } = this.context;
|
|
137
|
+
// CRL-19: a list item with its position among the items and their number.
|
|
138
|
+
hostAria(this, {
|
|
139
|
+
role: 'listitem',
|
|
140
|
+
'aria-posinset': position ? String(position) : null,
|
|
141
|
+
'aria-setsize': size ? String(size) : null,
|
|
142
|
+
});
|
|
143
|
+
// CRL-20: an item without a label still renders; a debug build says it has no name.
|
|
144
|
+
if (changed.has('label') && !this.label.trim())
|
|
145
|
+
report(this, 'CRL-20', 'label is empty, so the carousel item has no accessible name; give it a label that says what its content shows');
|
|
146
|
+
}
|
|
147
|
+
render() {
|
|
148
|
+
return html `
|
|
149
|
+
<div
|
|
150
|
+
part="container"
|
|
151
|
+
class="container"
|
|
152
|
+
data-tanrei-shape
|
|
153
|
+
role="button"
|
|
154
|
+
tabindex=${this.context.tabStop ? '0' : '-1'}
|
|
155
|
+
aria-label=${this.label}
|
|
156
|
+
@pointerdown=${this.press.onPointerDown}
|
|
157
|
+
@pointerup=${this.press.release}
|
|
158
|
+
@pointercancel=${this.press.release}
|
|
159
|
+
@pointerleave=${this.press.release}
|
|
160
|
+
@keydown=${this.onKeyDown}
|
|
161
|
+
@keyup=${this.onKeyUp}
|
|
162
|
+
@blur=${this.onBlur}
|
|
163
|
+
@focus=${this.onFocus}
|
|
164
|
+
>
|
|
165
|
+
<div class="clip" aria-hidden="true">
|
|
166
|
+
<div part="content" class="content"><slot @slotchange=${this.inspectContent}></slot></div>
|
|
167
|
+
</div>
|
|
168
|
+
<span part="state-layer" class="state-layer" aria-hidden="true"></span>
|
|
169
|
+
</div>
|
|
170
|
+
`;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
/** A number from an attribute (`item-width` in CSS px, `autoplay-interval` in ms); no attribute is null. */
|
|
174
|
+
const numberConverter = {
|
|
175
|
+
fromAttribute: (value) => (value === null || value.trim() === '' ? null : Number(value)),
|
|
176
|
+
toAttribute: (value) => (value === null || value === undefined ? null : String(value)),
|
|
177
|
+
};
|
|
178
|
+
/** A boolean property that defaults to true, whose attribute is its inverse (an HTML boolean attribute cannot default to true). */
|
|
179
|
+
const inverse = { fromAttribute: (value) => value === null, toAttribute: (value) => (value ? null : '') };
|
|
180
|
+
/** A number that is positive, else null (CRL-24). */
|
|
181
|
+
const positive = (value) => (typeof value === 'number' && Number.isFinite(value) && value > 0 ? value : null);
|
|
182
|
+
/**
|
|
183
|
+
* Lets people browse a row of visual items that scrolls sideways around one item in focus — the hero, in the centre (the
|
|
184
|
+
* default) or at the start, the others narrower (fluid widths) or smaller (scaleOthers) as they move away, every two
|
|
185
|
+
* neighbours one gap apart at every scroll position (CRL-40) — each item opening what it shows. A featured row may loop, show its position in dots and advance by itself, with a control to stop it.
|
|
186
|
+
*
|
|
187
|
+
* Contract: specs/carousel.spec.json. The items are `<tanrei-carousel-item>` children, in order. The carousel is a native
|
|
188
|
+
* horizontal scroller — wheel, trackpad, touch and pen scroll it as the platform does — whose track is as long as the
|
|
189
|
+
* scroll range; it places every item from the scroll offset (CRL-12), and settles at a resting position when a scroll
|
|
190
|
+
* ends while `snap` is true (CRL-14). The items are one Tab stop; the arrow keys, Home and End move between items and
|
|
191
|
+
* bring the focused one into place (CRL-17, CRL-18). Below the items, a controls row holds the page indicator (one
|
|
192
|
+
* slider, CRL-29 – CRL-31) and the playback control (CRL-35). Every visual value comes from `--tanrei-comp-carousel-*`
|
|
193
|
+
* tokens.
|
|
194
|
+
*
|
|
195
|
+
* @tag tanrei-carousel
|
|
196
|
+
* @slot - `<tanrei-carousel-item>` children: the items, in order.
|
|
197
|
+
* @csspart row - The scroller: as wide as the carousel, scrolled sideways by the person.
|
|
198
|
+
* @csspart list - The element with the list role around the items, named by `label`.
|
|
199
|
+
* @csspart controls - The row below the items that holds the indicator and the playback control.
|
|
200
|
+
* @csspart indicator - The dots: one slider, named by `label`.
|
|
201
|
+
* @csspart dot - One dot of the indicator.
|
|
202
|
+
* @csspart playback - The playback control: a native button that pauses and plays autoplay.
|
|
203
|
+
* @fires {CustomEvent<TanreiCarouselPausedChangeDetail>} pausedchange - The person paused or played autoplay with the playback control; `detail.paused` is the new value. Not fired when `paused` is set, nor for a hold.
|
|
204
|
+
*/
|
|
205
|
+
export class TanreiCarousel extends LitElement {
|
|
206
|
+
static { this.styles = [carouselStyles, hiddenHost]; }
|
|
207
|
+
static { this.properties = {
|
|
208
|
+
heroAlignment: { type: String, attribute: 'hero-alignment', reflect: true },
|
|
209
|
+
itemWidth: { attribute: 'item-width', converter: numberConverter },
|
|
210
|
+
// An HTML boolean attribute cannot default to true: the attributes are the inverses, `fixed-width`, `free-scroll` and
|
|
211
|
+
// `no-playback-control`.
|
|
212
|
+
fluidWidth: { attribute: 'fixed-width', reflect: true, converter: inverse },
|
|
213
|
+
contentAlignment: { type: String, attribute: 'content-alignment', reflect: true },
|
|
214
|
+
scaleOthers: { type: Boolean, attribute: 'scale-others', reflect: true },
|
|
215
|
+
snap: { attribute: 'free-scroll', reflect: true, converter: inverse },
|
|
216
|
+
loop: { type: Boolean, reflect: true },
|
|
217
|
+
indicator: { type: Boolean, reflect: true },
|
|
218
|
+
autoplay: { type: Boolean, reflect: true },
|
|
219
|
+
autoplayInterval: { attribute: 'autoplay-interval', converter: numberConverter },
|
|
220
|
+
paused: { type: Boolean, reflect: true },
|
|
221
|
+
playbackControl: { attribute: 'no-playback-control', reflect: true, converter: inverse },
|
|
222
|
+
autoplayProgress: { type: Boolean, attribute: 'autoplay-progress', reflect: true },
|
|
223
|
+
playLabel: { type: String, attribute: 'play-label' },
|
|
224
|
+
pauseLabel: { type: String, attribute: 'pause-label' },
|
|
225
|
+
label: { type: String },
|
|
226
|
+
restingCount: { state: true },
|
|
227
|
+
indicatorFits: { state: true },
|
|
228
|
+
current: { state: true },
|
|
229
|
+
reducedMotion: { state: true },
|
|
230
|
+
glyphReady: { state: true },
|
|
231
|
+
}; }
|
|
232
|
+
constructor() {
|
|
233
|
+
super();
|
|
234
|
+
this.availability = new AvailabilityController(this, 'carousel');
|
|
235
|
+
/** The product's words, read where the instance gives none (src/primitives/words.ts). */
|
|
236
|
+
this.words = new WordsController(this);
|
|
237
|
+
/** Where the item in focus sits: `center` (the middle of the row, items on both sides) or `start` (the inner start edge). An unknown value is drawn as `center` and reported (CRL-24). Reflected. */
|
|
238
|
+
this.heroAlignment = 'center';
|
|
239
|
+
/**
|
|
240
|
+
* The width the hero is laid out at, in CSS px (the `item-width` attribute); null takes
|
|
241
|
+
* `comp.carousel.container.large-width`. With fixed widths every item is this wide (at most the inner width); with
|
|
242
|
+
* fluid widths the hero is kept between a floor and a cap (CRL-9). Not a positive number: treated as null and
|
|
243
|
+
* reported (CRL-24).
|
|
244
|
+
*/
|
|
245
|
+
this.itemWidth = null;
|
|
246
|
+
/** Whether item widths change fluidly (CRL-10). False (the `fixed-width` attribute) makes every item the hero's width. */
|
|
247
|
+
this.fluidWidth = true;
|
|
248
|
+
/** With fluid widths, where a narrowed item's content is anchored: `center` or `toward-hero` (CRL-15). An unknown value is `center`, reported (CRL-24). Reflected. */
|
|
249
|
+
this.contentAlignment = 'center';
|
|
250
|
+
/** Draws the items other than the hero smaller, down to `comp.carousel.container.min-scale`, following the scroll (CRL-26). */
|
|
251
|
+
this.scaleOthers = false;
|
|
252
|
+
/** Whether the row settles at a resting position when a scroll ends (CRL-14). False (the `free-scroll` attribute) lets it rest wherever it ends. */
|
|
253
|
+
this.snap = true;
|
|
254
|
+
/** Whether the row is endless (CRL-27). Takes effect only with two or more items. */
|
|
255
|
+
this.loop = false;
|
|
256
|
+
/** Draws the dots below the items: one per resting position, the current one stretched (CRL-29). */
|
|
257
|
+
this.indicator = false;
|
|
258
|
+
/** Advances the row by itself, one resting position every `autoplayInterval` (CRL-32); it holds while hovered, focused within, pressed or hidden, and never runs where motion is reduced. */
|
|
259
|
+
this.autoplay = false;
|
|
260
|
+
/** How long the row rests before autoplay moves on, in ms (the `autoplay-interval` attribute); null takes `comp.carousel.autoplay.interval`. Not a positive number: null, reported (CRL-24). */
|
|
261
|
+
this.autoplayInterval = null;
|
|
262
|
+
/** Whether autoplay is paused, by the person (the playback control, which fires `pausedchange`) or by the product (which fires nothing). Reflected. */
|
|
263
|
+
this.paused = false;
|
|
264
|
+
/** Draws the playback control while autoplay is on (CRL-35). False (the `no-playback-control` attribute) hides it: keep it wherever you can (WCAG 2.2.2). */
|
|
265
|
+
this.playbackControl = true;
|
|
266
|
+
/** Fills the current dot to show the time until autoplay moves on (CRL-36). Needs `indicator`. */
|
|
267
|
+
this.autoplayProgress = false;
|
|
268
|
+
/** The playback control's accessible name while autoplay is paused ("Play the slideshow"). Required while it can be drawn. */
|
|
269
|
+
this.playLabel = '';
|
|
270
|
+
/** The playback control's accessible name while autoplay is playing ("Pause the slideshow"). Required while it can be drawn. */
|
|
271
|
+
this.pauseLabel = '';
|
|
272
|
+
/** Names the carousel's list and its indicator for assistive technology ("Recently played"). Required. */
|
|
273
|
+
this.label = '';
|
|
274
|
+
/** D, the number of resting positions of the last arrangement. */
|
|
275
|
+
this.restingCount = 0;
|
|
276
|
+
/** CRL-29: whether the indicator's container fits beside the playback control's target. */
|
|
277
|
+
this.indicatorFits = true;
|
|
278
|
+
/** CRL-31: the resting position nearest the indicator's position, from 0. */
|
|
279
|
+
this.current = 0;
|
|
280
|
+
/** CRL-34: `prefers-reduced-motion: reduce`, followed as it changes. */
|
|
281
|
+
this.reducedMotion = false;
|
|
282
|
+
/** CRL-38: whether the icon set can draw the playback glyphs. */
|
|
283
|
+
this.glyphReady = false;
|
|
284
|
+
this.itemKeys = new RovingKeys({ wrap: false });
|
|
285
|
+
this.loopKeys = new RovingKeys({ wrap: true });
|
|
286
|
+
/**
|
|
287
|
+
* Watches the row — the box the arrangement measures (CRL-8) — not the host: the host is also as tall as its controls
|
|
288
|
+
* row, which an arrangement may add or take away (CRL-29), and an observer told of a change its own callback made
|
|
289
|
+
* does not come to rest within the frame.
|
|
290
|
+
*/
|
|
291
|
+
this.resize$ = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(() => this.arrange());
|
|
292
|
+
this.motionQuery = typeof matchMedia === 'undefined' ? null : matchMedia('(prefers-reduced-motion: reduce)');
|
|
293
|
+
/**
|
|
294
|
+
* CRL-23: the row follows the direction it inherits, and a change of it while the page runs: the scroll offset and
|
|
295
|
+
* where each item's content sits were written physically for the old direction, so the row is arranged again — the
|
|
296
|
+
* resting item kept where it was, without motion.
|
|
297
|
+
*/
|
|
298
|
+
this.direction = new DirectionController(this, () => this.arrange());
|
|
299
|
+
/** The arrangement of the last layout, the items it placed and the scroll offset they were placed at. */
|
|
300
|
+
this.geometry = null;
|
|
301
|
+
/** The zoom of the row's ancestors, read when the row is arranged: a device pixel is the window's ratio times it (CRL-40). */
|
|
302
|
+
this.zoom = 1;
|
|
303
|
+
this.laidOut = [];
|
|
304
|
+
this.offset = 0;
|
|
305
|
+
/** The offset the carousel last wrote itself: a scroll event that reports it is the carousel's own. */
|
|
306
|
+
this.written = Number.NaN;
|
|
307
|
+
/** CRL-17: the item that last had keyboard focus in the carousel, or the one a dot's move brought (CRL-30). */
|
|
308
|
+
this.remembered = null;
|
|
309
|
+
/** CRL-32: the Tab stop an advance keeps, until the person moves the row. */
|
|
310
|
+
this.pinned = null;
|
|
311
|
+
/** The scroll the carousel is animating, where it goes, and whether it is an advance. */
|
|
312
|
+
this.scrolling = null;
|
|
313
|
+
this.scrollFrame = 0;
|
|
314
|
+
this.target = null;
|
|
315
|
+
/** Whether the row is moving: a scroll, a settle, a scroll into place, a dot's move or an advance, not yet at rest. */
|
|
316
|
+
this.moving = false;
|
|
317
|
+
/**
|
|
318
|
+
* CRL-14: a finger is on the row; where it was and when (its events' own time stamps, not the time a frame handled
|
|
319
|
+
* them), for the velocity of its release.
|
|
320
|
+
*/
|
|
321
|
+
this.touching = false;
|
|
322
|
+
this.scrolledSinceTouch = false;
|
|
323
|
+
this.samples = [];
|
|
324
|
+
/** The direction of the last release's fling (1 toward the end, −1 toward the start), or 0. */
|
|
325
|
+
this.fling = 0;
|
|
326
|
+
/** CRL-30: the indicator is being pressed by this pointer, and the dot it last moved the row to. */
|
|
327
|
+
this.indicatorPointer = null;
|
|
328
|
+
this.indicatorDot = -1;
|
|
329
|
+
// ── Autoplay (CRL-32 – CRL-36) ──
|
|
330
|
+
/** The time of the interval that has passed, in ms, up to the moment the clock last stopped. */
|
|
331
|
+
this.elapsed = 0;
|
|
332
|
+
/** When the clock last started (`performance.now()`), or null while it is stopped. */
|
|
333
|
+
this.runningSince = null;
|
|
334
|
+
/** The interval the advance's timer was last set for, in ms: a new interval sets it again. */
|
|
335
|
+
this.timedInterval = 0;
|
|
336
|
+
/** CRL-36: the animation that draws the current dot's fill across the interval — the browser runs it, no frame is asked for. */
|
|
337
|
+
this.progressAnimation = null;
|
|
338
|
+
/** CRL-36: the resting position the row last came to rest at. */
|
|
339
|
+
this.progressDot = 0;
|
|
340
|
+
/** CRL-33: the holds, and the hover and focus holds that playing lifted until the pointer or focus leaves. */
|
|
341
|
+
this.hovering = false;
|
|
342
|
+
this.hoverLifted = false;
|
|
343
|
+
this.focusWithin = false;
|
|
344
|
+
this.focusLifted = false;
|
|
345
|
+
this.pressing = false;
|
|
346
|
+
this.documentHidden = false;
|
|
347
|
+
/** The last reported values, so a debug build reports each once per change. */
|
|
348
|
+
this.reported = new Map();
|
|
349
|
+
// ── Scrolling ───────────────────────────────────────────────────────────────────────────────────
|
|
350
|
+
/** CRL-14: the row scrolled: the items follow; a scroll that is not the carousel's own is the person's move. */
|
|
351
|
+
this.onScroll = () => {
|
|
352
|
+
const offset = this.readOffset();
|
|
353
|
+
const own = Math.abs(offset - this.written) < 1;
|
|
354
|
+
// The write has been reported: the next scroll event is someone else's, wherever it leads (back here, too).
|
|
355
|
+
if (own)
|
|
356
|
+
this.written = Number.NaN;
|
|
357
|
+
if (this.touching)
|
|
358
|
+
this.scrolledSinceTouch = true;
|
|
359
|
+
this.place(offset);
|
|
360
|
+
if (own && this.target === null)
|
|
361
|
+
return;
|
|
362
|
+
if (!own) {
|
|
363
|
+
// CRL-33: the person (or the browser) moves the row; the clock waits for it to come to rest.
|
|
364
|
+
this.moving = true;
|
|
365
|
+
this.pinned = null;
|
|
366
|
+
this.syncClock();
|
|
367
|
+
}
|
|
368
|
+
this.syncTabStop();
|
|
369
|
+
// Not every engine ends every scroll with `scrollend` (Firefox after a wheel, older engines not at all): a pause ends
|
|
370
|
+
// the person's scroll too. The carousel's own scrolls end by themselves.
|
|
371
|
+
clearTimeout(this.idleTimer);
|
|
372
|
+
if (this.target === null)
|
|
373
|
+
this.idleTimer = setTimeout(() => this.onScrollEnd(), SCROLL_IDLE);
|
|
374
|
+
};
|
|
375
|
+
/** CRL-14: a scroll ended (a drag released, a wheel or trackpad gesture over): the row settles while snap is true. */
|
|
376
|
+
this.onScrollEnd = () => {
|
|
377
|
+
clearTimeout(this.idleTimer);
|
|
378
|
+
if (this.target !== null || this.touching)
|
|
379
|
+
return;
|
|
380
|
+
this.settle();
|
|
381
|
+
};
|
|
382
|
+
this.onTouchStart = (event) => {
|
|
383
|
+
if (event.touches.length > 1)
|
|
384
|
+
return;
|
|
385
|
+
this.stopScrolling();
|
|
386
|
+
this.touching = true;
|
|
387
|
+
this.scrolledSinceTouch = false;
|
|
388
|
+
this.fling = 0;
|
|
389
|
+
this.samples = [];
|
|
390
|
+
this.sample(event);
|
|
391
|
+
this.syncClock();
|
|
392
|
+
};
|
|
393
|
+
/** CRL-14: the finger moved. */
|
|
394
|
+
this.onTouchMove = (event) => {
|
|
395
|
+
if (this.touching && event.touches.length === 1)
|
|
396
|
+
this.sample(event);
|
|
397
|
+
};
|
|
398
|
+
/**
|
|
399
|
+
* CRL-14: the finger left the row: a release faster than FLING_VELOCITY is a fling, in its direction. The velocity is
|
|
400
|
+
* the finger's over its moves in the last VELOCITY_WINDOW before the release, timed by the events' own time stamps, so
|
|
401
|
+
* a busy main thread (or a frame that came late) does not slow a fling down.
|
|
402
|
+
*/
|
|
403
|
+
this.onTouchEnd = (event) => {
|
|
404
|
+
if (event.touches.length || !this.touching)
|
|
405
|
+
return;
|
|
406
|
+
this.touching = false;
|
|
407
|
+
this.sample(event);
|
|
408
|
+
const release = event.timeStamp;
|
|
409
|
+
const recent = this.samples.filter((sample) => release - sample.time <= VELOCITY_WINDOW);
|
|
410
|
+
const [first, last] = [recent[0], recent[recent.length - 1]];
|
|
411
|
+
// The finger moving toward the row's start scrolls it toward its end: toward the left, or the right in right-to-left.
|
|
412
|
+
const toward = this.rtl ? 1 : -1;
|
|
413
|
+
const velocity = first && last && last.time > first.time ? (toward * (last.x - first.x)) / (last.time - first.time) : 0;
|
|
414
|
+
// A touch that did not scroll the row (a tap, or the page's vertical scroll) is no fling of the row.
|
|
415
|
+
this.fling = this.scrolledSinceTouch && Math.abs(velocity) >= FLING_VELOCITY ? (velocity > 0 ? 1 : -1) : 0;
|
|
416
|
+
this.samples = [];
|
|
417
|
+
this.syncClock();
|
|
418
|
+
// A touch that never scrolled (or stopped a settle) settles now; one that scrolled settles when its scroll ends —
|
|
419
|
+
// by `scrollend`, or, where none comes and the finger had come to rest before it lifted (so no scroll event follows
|
|
420
|
+
// either), once no scroll has come for a moment.
|
|
421
|
+
if (!this.scrolledSinceTouch)
|
|
422
|
+
this.settle();
|
|
423
|
+
else if (!this.fling || this.snap === false) {
|
|
424
|
+
clearTimeout(this.idleTimer);
|
|
425
|
+
this.idleTimer = setTimeout(() => this.onScrollEnd(), SCROLL_IDLE);
|
|
426
|
+
}
|
|
427
|
+
else {
|
|
428
|
+
// A fling goes on to the next resting position from where the finger let go, not from wherever the browser's own
|
|
429
|
+
// momentum would carry the row (to its end, after a quick one): the row is held still while it settles.
|
|
430
|
+
this.settle();
|
|
431
|
+
this.hold(this.target !== null);
|
|
432
|
+
}
|
|
433
|
+
};
|
|
434
|
+
/** A wheel or a trackpad takes over from a running settle; Shift with a vertical wheel scrolls the row (CRL-14). */
|
|
435
|
+
this.onWheel = (event) => {
|
|
436
|
+
this.takeOver();
|
|
437
|
+
if (event.shiftKey && event.deltaX === 0 && event.deltaY !== 0 && event.deltaMode === WheelEvent.DOM_DELTA_PIXEL) {
|
|
438
|
+
event.preventDefault();
|
|
439
|
+
this.scroller?.scrollBy({ left: event.deltaY });
|
|
440
|
+
}
|
|
441
|
+
};
|
|
442
|
+
/** A mouse or a pen takes over from a running motion (a touch does in onTouchStart). CRL-33: a press holds autoplay. */
|
|
443
|
+
this.onPointerDown = (event) => {
|
|
444
|
+
if (event.pointerType !== 'touch')
|
|
445
|
+
this.takeOver();
|
|
446
|
+
this.pressing = true;
|
|
447
|
+
this.syncClock();
|
|
448
|
+
};
|
|
449
|
+
this.onPointerUp = () => {
|
|
450
|
+
if (!this.pressing)
|
|
451
|
+
return;
|
|
452
|
+
this.pressing = false;
|
|
453
|
+
this.syncClock();
|
|
454
|
+
};
|
|
455
|
+
/** CRL-33: the hover hold; leaving ends a hold that playing lifted. */
|
|
456
|
+
this.onPointerEnter = () => {
|
|
457
|
+
this.hovering = true;
|
|
458
|
+
this.syncClock();
|
|
459
|
+
};
|
|
460
|
+
this.onPointerLeave = () => {
|
|
461
|
+
this.hovering = false;
|
|
462
|
+
this.hoverLifted = false;
|
|
463
|
+
this.syncClock();
|
|
464
|
+
};
|
|
465
|
+
/**
|
|
466
|
+
* CRL-17: the focused item becomes the Tab stop. CRL-18: keyboard or assistive-technology focus — focus the browser
|
|
467
|
+
* shows, `:focus-visible`, which a pointer's never is — brings it into place over the scroll motion. CRL-33: focus
|
|
468
|
+
* within holds autoplay, however it came there.
|
|
469
|
+
*/
|
|
470
|
+
this.onFocusIn = (event) => {
|
|
471
|
+
this.focusWithin = true;
|
|
472
|
+
this.syncClock();
|
|
473
|
+
const item = this.itemOf(event);
|
|
474
|
+
if (!item)
|
|
475
|
+
return;
|
|
476
|
+
this.remembered = item;
|
|
477
|
+
this.syncTabStop();
|
|
478
|
+
if (item.shadowRoot?.activeElement?.matches(':focus-visible'))
|
|
479
|
+
this.reveal(item);
|
|
480
|
+
};
|
|
481
|
+
this.onFocusOut = (event) => {
|
|
482
|
+
const next = event.relatedTarget;
|
|
483
|
+
if (next && (this.contains(next) || this.renderRoot.contains(next)))
|
|
484
|
+
return;
|
|
485
|
+
this.focusWithin = false;
|
|
486
|
+
this.focusLifted = false;
|
|
487
|
+
this.syncClock();
|
|
488
|
+
};
|
|
489
|
+
/** CRL-17: Right / Left Arrow (mirrored in right-to-left) to the next and previous item, wrapping while loop is in effect; Home and End. */
|
|
490
|
+
this.onKeyDown = (event) => {
|
|
491
|
+
if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey)
|
|
492
|
+
return;
|
|
493
|
+
const item = this.itemOf(event);
|
|
494
|
+
if (!item)
|
|
495
|
+
return;
|
|
496
|
+
const rtl = this.rtl;
|
|
497
|
+
const keys = { ArrowRight: rtl ? 'ArrowUp' : 'ArrowDown', ArrowLeft: rtl ? 'ArrowDown' : 'ArrowUp', Home: 'Home', End: 'End' };
|
|
498
|
+
const key = keys[event.key];
|
|
499
|
+
if (!key)
|
|
500
|
+
return;
|
|
501
|
+
const items = this.laidOut;
|
|
502
|
+
const roving = this.geometry?.loop ? this.loopKeys : this.itemKeys;
|
|
503
|
+
const target = roving.target(key, items.indexOf(item), items.map((each) => ({ focusable: true, label: each.label })));
|
|
504
|
+
// The arrow keys never scroll the row themselves.
|
|
505
|
+
event.preventDefault();
|
|
506
|
+
if (target === null || items[target] === item)
|
|
507
|
+
return;
|
|
508
|
+
items[target].focusButton({ preventScroll: true });
|
|
509
|
+
};
|
|
510
|
+
// ── The indicator (CRL-29 – CRL-31) ─────────────────────────────────────────────────────────────
|
|
511
|
+
/** CRL-5 / CRL-6: the indicator's pressed state, by pointer or touch only, lasting as long as the press. */
|
|
512
|
+
this.indicatorPress = new PressController(this, {
|
|
513
|
+
container: () => this.renderRoot?.querySelector('.indicator') ?? null,
|
|
514
|
+
holdCarrier: () => this.renderRoot?.querySelector('.indicator .hold') ?? null,
|
|
515
|
+
disabled: () => false,
|
|
516
|
+
keys: [],
|
|
517
|
+
});
|
|
518
|
+
/** CRL-5 / CRL-6: the playback control's pressed state. */
|
|
519
|
+
this.playbackPress = new PressController(this, {
|
|
520
|
+
container: () => this.renderRoot?.querySelector('.playback') ?? null,
|
|
521
|
+
holdCarrier: () => this.renderRoot?.querySelector('.playback .hold') ?? null,
|
|
522
|
+
disabled: () => false,
|
|
523
|
+
});
|
|
524
|
+
this.onIndicatorPointerDown = (event) => {
|
|
525
|
+
if (event.button !== 0 && event.pointerType === 'mouse')
|
|
526
|
+
return;
|
|
527
|
+
const indicator = event.currentTarget;
|
|
528
|
+
indicator.setPointerCapture?.(event.pointerId);
|
|
529
|
+
this.indicatorPointer = event.pointerId;
|
|
530
|
+
this.indicatorDot = -1;
|
|
531
|
+
this.indicatorPress.onPointerDown(event);
|
|
532
|
+
syncFocusStyle(this, indicator);
|
|
533
|
+
this.toDot(this.dotAt(event.clientX));
|
|
534
|
+
};
|
|
535
|
+
this.onIndicatorPointerMove = (event) => {
|
|
536
|
+
if (event.pointerId !== this.indicatorPointer)
|
|
537
|
+
return;
|
|
538
|
+
this.toDot(this.dotAt(event.clientX));
|
|
539
|
+
};
|
|
540
|
+
this.onIndicatorPointerUp = (event) => {
|
|
541
|
+
if (event.pointerId !== this.indicatorPointer)
|
|
542
|
+
return;
|
|
543
|
+
this.indicatorPointer = null;
|
|
544
|
+
this.indicatorDot = -1;
|
|
545
|
+
this.indicatorPress.release();
|
|
546
|
+
};
|
|
547
|
+
/** CRL-30: Right / Left Arrow to the next and previous resting position (wrapping while loop is in effect), Home and End; mirrored in right-to-left. */
|
|
548
|
+
this.onIndicatorKeyDown = (event) => {
|
|
549
|
+
const geometry = this.geometry;
|
|
550
|
+
if (!geometry || event.altKey || event.ctrlKey || event.metaKey || event.shiftKey)
|
|
551
|
+
return;
|
|
552
|
+
const rtl = this.rtl;
|
|
553
|
+
const from = geometry.position(this.target ?? this.offset);
|
|
554
|
+
let to = null;
|
|
555
|
+
if (event.key === 'ArrowRight' || event.key === 'ArrowLeft') {
|
|
556
|
+
const forward = (event.key === 'ArrowRight') !== rtl;
|
|
557
|
+
to = geometry.stepResting(from, forward ? 1 : -1, geometry.loop);
|
|
558
|
+
}
|
|
559
|
+
else if (event.key === 'ArrowUp' || event.key === 'ArrowDown') {
|
|
560
|
+
// A slider's vertical arrows move it too (as the platform's own range input does, and as a screen reader's increment and decrement arrive).
|
|
561
|
+
to = geometry.stepResting(from, event.key === 'ArrowUp' ? 1 : -1, geometry.loop);
|
|
562
|
+
}
|
|
563
|
+
else if (event.key === 'Home') {
|
|
564
|
+
to = geometry.restingPosition(0, from);
|
|
565
|
+
}
|
|
566
|
+
else if (event.key === 'End') {
|
|
567
|
+
to = geometry.restingPosition(geometry.restingCount - 1, from);
|
|
568
|
+
}
|
|
569
|
+
if (to === null)
|
|
570
|
+
return;
|
|
571
|
+
event.preventDefault();
|
|
572
|
+
if (Math.abs(to - from) > 1e-3)
|
|
573
|
+
this.moveTo(to);
|
|
574
|
+
};
|
|
575
|
+
this.onIndicatorFocus = (event) => {
|
|
576
|
+
syncFocusStyle(this, event.currentTarget);
|
|
577
|
+
};
|
|
578
|
+
/** CRL-32: the interval has passed with the row at rest: on to the next resting position, or from the last back to the first. */
|
|
579
|
+
this.onTimeUp = () => {
|
|
580
|
+
const geometry = this.geometry;
|
|
581
|
+
if (!geometry || !this.clockRuns)
|
|
582
|
+
return;
|
|
583
|
+
// A timer may fire a little early: the clock decides, not the timer.
|
|
584
|
+
const remaining = this.interval() - this.passed();
|
|
585
|
+
if (remaining > 1) {
|
|
586
|
+
this.advanceTimer = setTimeout(this.onTimeUp, remaining);
|
|
587
|
+
return;
|
|
588
|
+
}
|
|
589
|
+
this.elapsed = this.interval();
|
|
590
|
+
this.stopClock();
|
|
591
|
+
this.drawProgress();
|
|
592
|
+
// An advance moves neither focus nor the items' Tab stop.
|
|
593
|
+
const items = this.laidOut;
|
|
594
|
+
this.pinned = this.remembered ?? this.pinned ?? items[geometry.restingIndex(geometry.position(this.offset))] ?? null;
|
|
595
|
+
const to = geometry.stepResting(geometry.position(this.offset), 1, true);
|
|
596
|
+
this.scrollRowTo(geometry.offset(to), { kind: 'autoplay' });
|
|
597
|
+
};
|
|
598
|
+
/** CRL-35: the person pauses or plays; on play the time starts from zero and the hover and focus holds in effect are lifted (CRL-33). */
|
|
599
|
+
this.onPlaybackClick = () => {
|
|
600
|
+
const paused = !this.paused;
|
|
601
|
+
this.paused = paused;
|
|
602
|
+
if (!paused) {
|
|
603
|
+
this.elapsed = 0;
|
|
604
|
+
this.runningSince = null;
|
|
605
|
+
this.stopClock();
|
|
606
|
+
this.hoverLifted = this.hovering;
|
|
607
|
+
this.focusLifted = this.focusWithin;
|
|
608
|
+
}
|
|
609
|
+
this.syncClock();
|
|
610
|
+
this.dispatchEvent(new CustomEvent('pausedchange', { detail: { paused }, bubbles: true, composed: true }));
|
|
611
|
+
};
|
|
612
|
+
this.onPlaybackFocus = (event) => {
|
|
613
|
+
syncFocusStyle(this, event.currentTarget);
|
|
614
|
+
};
|
|
615
|
+
/** CRL-34: reduced motion stops autoplay; when it stops being reduced, autoplay starts again with the time from zero. */
|
|
616
|
+
this.onMotionChange = (event) => {
|
|
617
|
+
this.reducedMotion = event.matches;
|
|
618
|
+
if (!event.matches) {
|
|
619
|
+
this.elapsed = 0;
|
|
620
|
+
this.runningSince = null;
|
|
621
|
+
this.stopClock();
|
|
622
|
+
}
|
|
623
|
+
this.syncClock();
|
|
624
|
+
};
|
|
625
|
+
/** CRL-33: a hidden document holds autoplay. */
|
|
626
|
+
this.onVisibilityChange = () => {
|
|
627
|
+
this.documentHidden = document.visibilityState === 'hidden';
|
|
628
|
+
this.syncClock();
|
|
629
|
+
};
|
|
630
|
+
this.addEventListener('keydown', this.onKeyDown);
|
|
631
|
+
this.addEventListener('focusin', this.onFocusIn);
|
|
632
|
+
this.addEventListener('focusout', this.onFocusOut);
|
|
633
|
+
this.addEventListener('pointerdown', this.onPointerDown, { capture: true });
|
|
634
|
+
this.addEventListener('pointerenter', this.onPointerEnter);
|
|
635
|
+
this.addEventListener('pointerleave', this.onPointerLeave);
|
|
636
|
+
}
|
|
637
|
+
connectedCallback() {
|
|
638
|
+
super.connectedCallback();
|
|
639
|
+
this.reducedMotion = this.motionQuery?.matches ?? false;
|
|
640
|
+
this.motionQuery?.addEventListener('change', this.onMotionChange);
|
|
641
|
+
this.documentHidden = typeof document !== 'undefined' && document.visibilityState === 'hidden';
|
|
642
|
+
document.addEventListener('visibilitychange', this.onVisibilityChange);
|
|
643
|
+
window.addEventListener('pointerup', this.onPointerUp, true);
|
|
644
|
+
window.addEventListener('pointercancel', this.onPointerUp, true);
|
|
645
|
+
if (this.hasUpdated) {
|
|
646
|
+
this.observeRow();
|
|
647
|
+
this.arrange();
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
disconnectedCallback() {
|
|
651
|
+
super.disconnectedCallback();
|
|
652
|
+
this.resize$?.disconnect();
|
|
653
|
+
this.motionQuery?.removeEventListener('change', this.onMotionChange);
|
|
654
|
+
document.removeEventListener('visibilitychange', this.onVisibilityChange);
|
|
655
|
+
window.removeEventListener('pointerup', this.onPointerUp, true);
|
|
656
|
+
window.removeEventListener('pointercancel', this.onPointerUp, true);
|
|
657
|
+
this.stopScrolling();
|
|
658
|
+
this.stopClock();
|
|
659
|
+
this.endProgress();
|
|
660
|
+
clearTimeout(this.idleTimer);
|
|
661
|
+
}
|
|
662
|
+
/** The carousel's items, in order. */
|
|
663
|
+
get items() {
|
|
664
|
+
return [...this.children].filter((child) => child instanceof TanreiCarouselItem);
|
|
665
|
+
}
|
|
666
|
+
/** CRL-24: the hero alignment drawn — `heroAlignment`, or the default while it names a value the carousel does not define. */
|
|
667
|
+
get drawnHero() {
|
|
668
|
+
return HERO_ALIGNMENTS.includes(this.heroAlignment) ? this.heroAlignment : 'center';
|
|
669
|
+
}
|
|
670
|
+
/** CRL-24: the content alignment drawn. */
|
|
671
|
+
get drawnContent() {
|
|
672
|
+
return CONTENT_ALIGNMENTS.includes(this.contentAlignment) ? this.contentAlignment : 'center';
|
|
673
|
+
}
|
|
674
|
+
/** CRL-29: whether the indicator is drawn. */
|
|
675
|
+
get indicatorDrawn() {
|
|
676
|
+
return this.indicator && this.restingCount >= 2 && this.indicatorFits;
|
|
677
|
+
}
|
|
678
|
+
/** CRL-35: whether the playback control is drawn. */
|
|
679
|
+
get playbackDrawn() {
|
|
680
|
+
return this.autoplay && this.playbackControl && this.restingCount >= 2 && !this.reducedMotion;
|
|
681
|
+
}
|
|
682
|
+
/** CRL-36: whether the current dot shows the time until autoplay moves on. */
|
|
683
|
+
get progressDrawn() {
|
|
684
|
+
return this.autoplayProgress && this.indicatorDrawn && this.autoplay && !this.paused && !this.reducedMotion;
|
|
685
|
+
}
|
|
686
|
+
get scroller() {
|
|
687
|
+
return this.renderRoot?.querySelector('.scroller') ?? null;
|
|
688
|
+
}
|
|
689
|
+
get rtl() {
|
|
690
|
+
return this.direction.rtl;
|
|
691
|
+
}
|
|
692
|
+
/** The scroll offset along the reading direction (a right-to-left row scrolls to negative `scrollLeft`). */
|
|
693
|
+
readOffset() {
|
|
694
|
+
const scroller = this.scroller;
|
|
695
|
+
return scroller ? Math.abs(scroller.scrollLeft) : 0;
|
|
696
|
+
}
|
|
697
|
+
/**
|
|
698
|
+
* What a `zoom` in CSS on an ancestor makes of one of the row's own pixels (CRL-40): the browser says it where it
|
|
699
|
+
* can, and where it cannot the row's box, measured in the window's pixels and in its own, tells it. 1 with no zoom.
|
|
700
|
+
*/
|
|
701
|
+
readZoom() {
|
|
702
|
+
const scroller = this.scroller;
|
|
703
|
+
if (!scroller)
|
|
704
|
+
return 1;
|
|
705
|
+
if (typeof scroller.currentCSSZoom === 'number')
|
|
706
|
+
return scroller.currentCSSZoom > 0 ? scroller.currentCSSZoom : 1;
|
|
707
|
+
const own = Number.parseFloat(getComputedStyle(scroller).width);
|
|
708
|
+
const seen = scroller.getBoundingClientRect().width;
|
|
709
|
+
return own > 0 && seen > 0 ? seen / own : 1;
|
|
710
|
+
}
|
|
711
|
+
/** The tokens the arrangement reads, in px (and the least scale, a number), through the probes' real properties. */
|
|
712
|
+
metrics() {
|
|
713
|
+
const read = (selector) => {
|
|
714
|
+
const probe = this.renderRoot.querySelector(selector);
|
|
715
|
+
return probe ? getComputedStyle(probe) : null;
|
|
716
|
+
};
|
|
717
|
+
const [slots, controls] = [read('.probe'), read('.probe-controls')];
|
|
718
|
+
const px = (value) => Number.parseFloat(value ?? '') || 0;
|
|
719
|
+
const minScale = Number.parseFloat(controls?.flexGrow ?? '');
|
|
720
|
+
return {
|
|
721
|
+
// The row's width in its own pixels, as its tokens are: a client rect is in the window's, which a `zoom` on an
|
|
722
|
+
// ancestor makes larger than the row's (the row's box is a border box, so its used width is the whole of it).
|
|
723
|
+
width: this.scroller ? px(getComputedStyle(this.scroller).width) : 0,
|
|
724
|
+
zoom: this.readZoom(),
|
|
725
|
+
padding: px(slots?.paddingLeft),
|
|
726
|
+
gap: px(slots?.paddingRight),
|
|
727
|
+
largeWidth: positive(this.itemWidth) ?? px(slots?.paddingTop),
|
|
728
|
+
smallMin: px(slots?.paddingBottom),
|
|
729
|
+
smallMax: px(slots?.marginLeft),
|
|
730
|
+
dotSize: px(controls?.paddingLeft),
|
|
731
|
+
dotActive: px(controls?.paddingRight),
|
|
732
|
+
dotGap: px(controls?.paddingTop),
|
|
733
|
+
indicatorPadding: px(controls?.paddingBottom),
|
|
734
|
+
touch: px(controls?.marginLeft),
|
|
735
|
+
minScale: Number.isFinite(minScale) ? minScale : 1,
|
|
736
|
+
};
|
|
737
|
+
}
|
|
738
|
+
/**
|
|
739
|
+
* CRL-8 – CRL-13, CRL-21, CRL-27: arranges the slots for the carousel's width, its axes and its items, and keeps the
|
|
740
|
+
* resting item where it was, as far as the new range allows, without motion.
|
|
741
|
+
*/
|
|
742
|
+
arrange() {
|
|
743
|
+
const scroller = this.scroller;
|
|
744
|
+
const track = this.renderRoot?.querySelector('.track');
|
|
745
|
+
const stage = this.renderRoot?.querySelector('.stage');
|
|
746
|
+
if (!scroller || !track || !stage || !this.isConnected)
|
|
747
|
+
return;
|
|
748
|
+
const items = this.items;
|
|
749
|
+
const { zoom, ...metrics } = this.metrics();
|
|
750
|
+
this.zoom = zoom;
|
|
751
|
+
const before = this.geometry;
|
|
752
|
+
const next = new CarouselGeometry({
|
|
753
|
+
...metrics,
|
|
754
|
+
heroAlignment: this.drawnHero,
|
|
755
|
+
fluid: this.fluidWidth !== false,
|
|
756
|
+
scaleOthers: this.scaleOthers === true,
|
|
757
|
+
snap: this.snap !== false,
|
|
758
|
+
loop: this.loop,
|
|
759
|
+
count: items.length,
|
|
760
|
+
});
|
|
761
|
+
// Where the resting item was, in the last arrangement: its index, and how far the row was from it.
|
|
762
|
+
const wasAnimating = this.target !== null;
|
|
763
|
+
const offset = this.target ?? this.offset;
|
|
764
|
+
this.stopScrolling();
|
|
765
|
+
let position;
|
|
766
|
+
if (before && this.laidOut.length && before.step > 0) {
|
|
767
|
+
const p = before.position(offset);
|
|
768
|
+
const index = before.restingIndex(p);
|
|
769
|
+
const anchor = this.laidOut[index];
|
|
770
|
+
const moved = anchor ? items.indexOf(anchor) : -1;
|
|
771
|
+
const at = moved >= 0 ? moved : Math.min(index, Math.max(0, items.length - 1));
|
|
772
|
+
if (next.toSlot) {
|
|
773
|
+
// As far from slot 0 as it was, in positions (0 at rest).
|
|
774
|
+
position = at + (before.toSlot ? p - Math.round(p) : 0);
|
|
775
|
+
}
|
|
776
|
+
else {
|
|
777
|
+
// Its start where it was, in px.
|
|
778
|
+
position = before.toSlot || next.step <= 0 ? at : at - before.item(index, p).start / next.step;
|
|
779
|
+
}
|
|
780
|
+
if (next.loop)
|
|
781
|
+
position = next.middle + position;
|
|
782
|
+
}
|
|
783
|
+
else {
|
|
784
|
+
position = next.loop ? next.middle : next.position(this.readOffset());
|
|
785
|
+
}
|
|
786
|
+
this.geometry = next;
|
|
787
|
+
this.laidOut = items;
|
|
788
|
+
if (this.remembered && !items.includes(this.remembered))
|
|
789
|
+
this.remembered = null;
|
|
790
|
+
if (this.pinned && !items.includes(this.pinned))
|
|
791
|
+
this.pinned = null;
|
|
792
|
+
const view = metrics.width;
|
|
793
|
+
track.style.setProperty('--_track', `${view + next.range}px`);
|
|
794
|
+
stage.style.setProperty('--_view', `${view}px`);
|
|
795
|
+
this.setOffset(next.offset(next.recentre(position)));
|
|
796
|
+
// CRL-29: the dots fit while their container leaves the playback control's target and a gap on each side.
|
|
797
|
+
const d = next.restingCount;
|
|
798
|
+
const container = d * metrics.dotSize + Math.max(0, d - 1) * metrics.dotGap + (metrics.dotActive - metrics.dotSize) + 2 * metrics.indicatorPadding;
|
|
799
|
+
this.indicatorFits = container <= next.inner - 2 * (metrics.touch + metrics.gap);
|
|
800
|
+
this.restingCount = d;
|
|
801
|
+
if (this.indicator && d >= 2 && !this.indicatorFits && this.reported.get('fit') !== `${d}@${next.inner}`) {
|
|
802
|
+
this.reported.set('fit', `${d}@${next.inner}`);
|
|
803
|
+
report(this, 'CRL-20', `indicator is set but its ${d} dots do not fit beside the playback control at this width, so they are not drawn; a row of dots is for a short featured row`, { once: false });
|
|
804
|
+
}
|
|
805
|
+
if (wasAnimating || this.moving)
|
|
806
|
+
this.atRest();
|
|
807
|
+
this.syncTabStop();
|
|
808
|
+
this.syncClock();
|
|
809
|
+
}
|
|
810
|
+
/** Scrolls to `offset` at once and places the items there. */
|
|
811
|
+
setOffset(offset) {
|
|
812
|
+
const scroller = this.scroller;
|
|
813
|
+
if (!scroller)
|
|
814
|
+
return;
|
|
815
|
+
const before = this.readOffset();
|
|
816
|
+
scroller.scrollLeft = this.rtl ? -offset : offset;
|
|
817
|
+
const now = this.readOffset();
|
|
818
|
+
// A write that moves the row is reported by one scroll event, which is then the carousel's own; one that moves
|
|
819
|
+
// nothing is reported by none, and must not make a later scroll to this same offset look like the carousel's.
|
|
820
|
+
this.written = now !== before ? now : Number.NaN;
|
|
821
|
+
this.place(now);
|
|
822
|
+
}
|
|
823
|
+
/**
|
|
824
|
+
* CRL-12, CRL-13, CRL-15, CRL-26, CRL-29, CRL-40: every item and every dot for `offset` — all from the one scroll
|
|
825
|
+
* position, in one pass.
|
|
826
|
+
*
|
|
827
|
+
* CRL-40: a browser paints a box's edges on whole device pixels, so two gaps of the same length in CSS px can be
|
|
828
|
+
* painted a device pixel apart (10 and 9 for a gap of 8 at a pixel ratio of 1.25, measured). So each drawn item's
|
|
829
|
+
* start is rounded to a device pixel, and its end is the next item's rounded start less the gap, itself rounded: the
|
|
830
|
+
* rounding falls on a width, never on a gap.
|
|
831
|
+
*/
|
|
832
|
+
place(offset) {
|
|
833
|
+
const geometry = this.geometry;
|
|
834
|
+
if (!geometry)
|
|
835
|
+
return;
|
|
836
|
+
this.offset = offset;
|
|
837
|
+
const p = geometry.position(offset);
|
|
838
|
+
const { padding, hero, gap } = geometry;
|
|
839
|
+
const rtl = this.rtl;
|
|
840
|
+
const towardHero = geometry.fluid && this.drawnContent === 'toward-hero';
|
|
841
|
+
// A device pixel of the row: the window's ratio and the zoom of an ancestor, which the ratio does not hold.
|
|
842
|
+
const ratio = ((typeof devicePixelRatio === 'number' && devicePixelRatio > 0 ? devicePixelRatio : 1) || 1) * this.zoom;
|
|
843
|
+
const snap = (length) => Math.round(length * ratio) / ratio;
|
|
844
|
+
const view = geometry.inner + 2 * padding;
|
|
845
|
+
const items = this.laidOut;
|
|
846
|
+
const placed = items.map((_, index) => geometry.item(index, p));
|
|
847
|
+
// The drawn items in the order they stand in: neighbours are one slot position apart.
|
|
848
|
+
const order = placed.map((_, index) => index).filter((index) => placed[index].drawn).sort((a, b) => placed[a].s - placed[b].s);
|
|
849
|
+
const starts = new Map(order.map((index) => [index, snap(padding + placed[index].start)]));
|
|
850
|
+
const width = new Map();
|
|
851
|
+
order.forEach((index, at) => {
|
|
852
|
+
const start = starts.get(index);
|
|
853
|
+
const next = order[at + 1];
|
|
854
|
+
const neighbour = next !== undefined && Math.abs(placed[next].s - placed[index].s - 1) < 1e-6;
|
|
855
|
+
const end = neighbour ? starts.get(next) - snap(gap) : snap(padding + placed[index].start + placed[index].width);
|
|
856
|
+
width.set(index, Math.max(0, end - start));
|
|
857
|
+
});
|
|
858
|
+
items.forEach((item, index) => {
|
|
859
|
+
const { s, drawn, transit, scale: k } = placed[index];
|
|
860
|
+
const scale = geometry.scaled ? k : null;
|
|
861
|
+
if (!drawn) {
|
|
862
|
+
// CRL-12: at or beyond an edge slot the item is not drawn: no width, beyond the stage's edge on its side, where
|
|
863
|
+
// nothing of it (a focus ring) can show and no press reaches it. It stays in the list for assistive technology.
|
|
864
|
+
item.place({ start: s > 0 ? view + gap : -gap, width: 0, content: hero, contentLeft: 0, scale, narrow: true });
|
|
865
|
+
return;
|
|
866
|
+
}
|
|
867
|
+
const w = width.get(index);
|
|
868
|
+
// What the drawn container leaves beside its content, which is H wide before the scale (CRL-15, CRL-26).
|
|
869
|
+
const free = w - k * hero;
|
|
870
|
+
// CRL-15: centred, or the side nearest the hero — an item after it aligns its start, one before it its end.
|
|
871
|
+
const contentLeft = towardHero && s !== 0 ? ((s > 0) !== rtl ? 0 : free) : free / 2;
|
|
872
|
+
item.place({ start: starts.get(index), width: w, content: hero, contentLeft, scale, narrow: transit });
|
|
873
|
+
});
|
|
874
|
+
this.paintDots(p);
|
|
875
|
+
}
|
|
876
|
+
/** CRL-29, CRL-36: each dot's stretch and fill for the position `p`; the value of the slider. */
|
|
877
|
+
paintDots(p) {
|
|
878
|
+
const geometry = this.geometry;
|
|
879
|
+
if (!geometry)
|
|
880
|
+
return;
|
|
881
|
+
const q = geometry.indicatorPosition(p);
|
|
882
|
+
const current = geometry.nearestResting(p);
|
|
883
|
+
if (current !== this.current)
|
|
884
|
+
this.current = current;
|
|
885
|
+
const progress = this.progressDrawn;
|
|
886
|
+
this.renderRoot.querySelectorAll('.dot').forEach((dot, j) => {
|
|
887
|
+
const w = Math.max(0, 1 - geometry.dotDistance(q, j));
|
|
888
|
+
dot.style.setProperty('--_w', String(w));
|
|
889
|
+
dot.classList.toggle('timed', progress && j === this.progressDot);
|
|
890
|
+
});
|
|
891
|
+
this.renderRoot.querySelector('.indicator')?.classList.toggle('progress', progress);
|
|
892
|
+
// CRL-36: the dots may have been drawn again, or the progress may have stopped being drawn: the fill's animation follows.
|
|
893
|
+
const timed = progress ? this.renderRoot.querySelectorAll('.dot')[this.progressDot]?.querySelector('.fill') : null;
|
|
894
|
+
if ((this.progressAnimation?.effect?.target ?? null) !== (timed ?? null))
|
|
895
|
+
this.drawProgress();
|
|
896
|
+
}
|
|
897
|
+
/** CRL-17, CRL-32: one Tab stop — the item that last had keyboard focus, the one an advance kept, or else the resting item. */
|
|
898
|
+
syncTabStop() {
|
|
899
|
+
const items = this.laidOut;
|
|
900
|
+
const geometry = this.geometry;
|
|
901
|
+
if (!geometry || !items.length)
|
|
902
|
+
return;
|
|
903
|
+
const stop = this.remembered ?? this.pinned ?? items[geometry.restingIndex(geometry.position(this.offset))];
|
|
904
|
+
items.forEach((item, index) => item.setCarouselContext({ tabStop: item === stop, position: index + 1, size: items.length }));
|
|
905
|
+
}
|
|
906
|
+
/** Where the finger of `event` is along the row, at the event's own time. */
|
|
907
|
+
sample(event) {
|
|
908
|
+
const touch = event.changedTouches[0] ?? event.touches[0];
|
|
909
|
+
if (touch)
|
|
910
|
+
this.samples.push({ x: touch.clientX, time: event.timeStamp });
|
|
911
|
+
}
|
|
912
|
+
/** Holds the row still — no momentum, no pan — while a fling's settle runs (CRL-14); the scroll offset stays settable. */
|
|
913
|
+
hold(on) {
|
|
914
|
+
this.scroller?.classList.toggle('held', on);
|
|
915
|
+
}
|
|
916
|
+
/**
|
|
917
|
+
* The person takes over from a motion the carousel runs (a wheel, a mouse press): it stops where it is, and, unless a
|
|
918
|
+
* scroll follows, the row comes to rest — settling first while snap is true — once no scroll has come for a moment.
|
|
919
|
+
*/
|
|
920
|
+
takeOver() {
|
|
921
|
+
if (this.target === null)
|
|
922
|
+
return;
|
|
923
|
+
this.stopScrolling();
|
|
924
|
+
this.moving = true;
|
|
925
|
+
this.pinned = null;
|
|
926
|
+
clearTimeout(this.idleTimer);
|
|
927
|
+
this.idleTimer = setTimeout(() => this.onScrollEnd(), SCROLL_IDLE);
|
|
928
|
+
}
|
|
929
|
+
/** CRL-14: while snap is true, the row comes to rest at a resting position — the next one in the direction of a fling, or the nearest. */
|
|
930
|
+
settle() {
|
|
931
|
+
const geometry = this.geometry;
|
|
932
|
+
const direction = this.fling;
|
|
933
|
+
this.fling = 0;
|
|
934
|
+
if (!geometry || this.snap === false) {
|
|
935
|
+
this.atRest();
|
|
936
|
+
return;
|
|
937
|
+
}
|
|
938
|
+
const offset = this.readOffset();
|
|
939
|
+
const target = geometry.offset(geometry.settlePosition(geometry.position(offset), direction));
|
|
940
|
+
// A fling's settle claims the row from the release (whatever the pan or the momentum moved before its first frame);
|
|
941
|
+
// a settle after a scroll ended yields to a scroll that comes before its first frame.
|
|
942
|
+
if (Math.abs(target - offset) >= 0.5)
|
|
943
|
+
this.scrollRowTo(target, { from: offset, claim: direction !== 0 });
|
|
944
|
+
else
|
|
945
|
+
this.atRest();
|
|
946
|
+
}
|
|
947
|
+
/**
|
|
948
|
+
* The row came to rest. CRL-27: a looping row moves by whole turns back to the middle of its track (which draws nothing
|
|
949
|
+
* new). CRL-33: the clock starts again from zero after the row moved — and only then: an engine reports the end of the
|
|
950
|
+
* carousel's own scroll (`scrollend`) when it next updates its rendering, which may be long after the row came to rest,
|
|
951
|
+
* and a row that has been at rest since keeps the time it has counted (CRL-32).
|
|
952
|
+
*/
|
|
953
|
+
atRest() {
|
|
954
|
+
const geometry = this.geometry;
|
|
955
|
+
const moved = this.moving;
|
|
956
|
+
this.moving = false;
|
|
957
|
+
if (geometry) {
|
|
958
|
+
const p = geometry.position(this.readOffset());
|
|
959
|
+
const centred = geometry.recentre(p);
|
|
960
|
+
if (centred !== p)
|
|
961
|
+
this.setOffset(geometry.offset(centred));
|
|
962
|
+
this.progressDot = geometry.nearestResting(centred);
|
|
963
|
+
}
|
|
964
|
+
if (moved) {
|
|
965
|
+
this.elapsed = 0;
|
|
966
|
+
this.runningSince = null;
|
|
967
|
+
this.stopClock();
|
|
968
|
+
}
|
|
969
|
+
this.syncTabStop();
|
|
970
|
+
this.place(this.readOffset());
|
|
971
|
+
this.syncClock();
|
|
972
|
+
}
|
|
973
|
+
/**
|
|
974
|
+
* The motion of a settle, a scroll into place and a dot's move (CRL-14, CRL-18, CRL-30), or of an advance (CRL-32):
|
|
975
|
+
* the tokens through real properties, 0 where reduced.
|
|
976
|
+
*/
|
|
977
|
+
motion(kind) {
|
|
978
|
+
const carrier = kind === 'autoplay' ? this.renderRoot.querySelector('.timing') : this.scroller;
|
|
979
|
+
const style = getComputedStyle(carrier ?? this);
|
|
980
|
+
return { duration: (Number.parseFloat(style.animationDuration) || 0) * 1000, easing: style.animationTimingFunction || 'ease' };
|
|
981
|
+
}
|
|
982
|
+
stopScrolling() {
|
|
983
|
+
cancelAnimationFrame(this.scrollFrame);
|
|
984
|
+
this.scrolling?.cancel();
|
|
985
|
+
this.scrolling = null;
|
|
986
|
+
this.target = null;
|
|
987
|
+
this.hold(false);
|
|
988
|
+
}
|
|
989
|
+
/**
|
|
990
|
+
* Scrolls from `from` to `to` over the motion's duration and easing, or at once where motion is reduced. It starts in
|
|
991
|
+
* the next frame. With `claim`, that first frame replaces whatever scrolled the row since the call (the browser's own
|
|
992
|
+
* jump to a focused element, the momentum after a fling); without it, a scroll that came before the first frame wins,
|
|
993
|
+
* as one that comes during the motion does. The easing's progress is read from an effect without a target, so the
|
|
994
|
+
* scroll follows the token's curve.
|
|
995
|
+
*/
|
|
996
|
+
scrollRowTo(to, { from = this.offset, claim = true, kind = 'scroll' } = {}) {
|
|
997
|
+
this.stopScrolling();
|
|
998
|
+
const { duration, easing } = this.motion(kind);
|
|
999
|
+
this.target = to;
|
|
1000
|
+
this.moving = true;
|
|
1001
|
+
this.syncClock();
|
|
1002
|
+
// Where the row was when the carousel last set it: a scroll away from there is someone else's (the product's, the
|
|
1003
|
+
// browser's), which wins and settles in its turn.
|
|
1004
|
+
let last = claim ? null : this.readOffset();
|
|
1005
|
+
const overtaken = () => {
|
|
1006
|
+
if (last === null || Math.abs(this.readOffset() - last) <= 1)
|
|
1007
|
+
return false;
|
|
1008
|
+
this.stopScrolling();
|
|
1009
|
+
this.onScroll();
|
|
1010
|
+
return true;
|
|
1011
|
+
};
|
|
1012
|
+
const finish = () => {
|
|
1013
|
+
this.scrolling = null;
|
|
1014
|
+
this.target = null;
|
|
1015
|
+
this.hold(false);
|
|
1016
|
+
this.atRest();
|
|
1017
|
+
};
|
|
1018
|
+
if (Math.abs(to - from) < 0.5 || duration <= 0 || typeof KeyframeEffect === 'undefined') {
|
|
1019
|
+
this.scrollFrame = requestAnimationFrame(() => {
|
|
1020
|
+
if (overtaken())
|
|
1021
|
+
return;
|
|
1022
|
+
this.setOffset(to);
|
|
1023
|
+
finish();
|
|
1024
|
+
});
|
|
1025
|
+
return;
|
|
1026
|
+
}
|
|
1027
|
+
const timing = new Animation(new KeyframeEffect(null, [], { duration, easing, fill: 'forwards' }));
|
|
1028
|
+
this.scrolling = timing;
|
|
1029
|
+
timing.play();
|
|
1030
|
+
const step = () => {
|
|
1031
|
+
if (this.scrolling !== timing || overtaken())
|
|
1032
|
+
return;
|
|
1033
|
+
const progress = timing.effect?.getComputedTiming().progress ?? 1;
|
|
1034
|
+
this.setOffset(from + (to - from) * (progress ?? 1));
|
|
1035
|
+
last = this.readOffset();
|
|
1036
|
+
if (timing.playState === 'finished') {
|
|
1037
|
+
finish();
|
|
1038
|
+
return;
|
|
1039
|
+
}
|
|
1040
|
+
this.scrollFrame = requestAnimationFrame(step);
|
|
1041
|
+
};
|
|
1042
|
+
this.scrollFrame = requestAnimationFrame(step);
|
|
1043
|
+
}
|
|
1044
|
+
/** Moves the row to `position` over the scroll motion, as the person asked (a key, a dot): the Tab stop follows (CRL-30). */
|
|
1045
|
+
moveTo(position) {
|
|
1046
|
+
const geometry = this.geometry;
|
|
1047
|
+
if (!geometry)
|
|
1048
|
+
return;
|
|
1049
|
+
this.pinned = null;
|
|
1050
|
+
this.remembered = this.laidOut[geometry.restingIndex(position)] ?? null;
|
|
1051
|
+
this.scrollRowTo(geometry.offset(position));
|
|
1052
|
+
this.syncTabStop();
|
|
1053
|
+
}
|
|
1054
|
+
// ── Focus and keys ──────────────────────────────────────────────────────────────────────────────
|
|
1055
|
+
/** The item an event came from. */
|
|
1056
|
+
itemOf(event) {
|
|
1057
|
+
for (const node of event.composedPath()) {
|
|
1058
|
+
if (node === this)
|
|
1059
|
+
return null;
|
|
1060
|
+
if (node instanceof TanreiCarouselItem && node.parentElement === this)
|
|
1061
|
+
return node;
|
|
1062
|
+
}
|
|
1063
|
+
return null;
|
|
1064
|
+
}
|
|
1065
|
+
/** CRL-18: slot 0 (or as near as the range allows, the shorter way round), or wholly in view with the least scroll. */
|
|
1066
|
+
reveal(item) {
|
|
1067
|
+
const geometry = this.geometry;
|
|
1068
|
+
const index = this.laidOut.indexOf(item);
|
|
1069
|
+
if (!geometry || index < 0)
|
|
1070
|
+
return;
|
|
1071
|
+
this.pinned = null;
|
|
1072
|
+
this.scrollRowTo(geometry.offset(geometry.revealPosition(index, geometry.position(this.offset))), { from: this.offset });
|
|
1073
|
+
}
|
|
1074
|
+
/** CRL-30: the dot nearest a point along the indicator. */
|
|
1075
|
+
dotAt(x) {
|
|
1076
|
+
let nearest = -1;
|
|
1077
|
+
let distance = Number.POSITIVE_INFINITY;
|
|
1078
|
+
this.renderRoot.querySelectorAll('.dot').forEach((dot, j) => {
|
|
1079
|
+
const box = dot.getBoundingClientRect();
|
|
1080
|
+
const d = Math.abs(x - (box.left + box.width / 2));
|
|
1081
|
+
if (d < distance) {
|
|
1082
|
+
distance = d;
|
|
1083
|
+
nearest = j;
|
|
1084
|
+
}
|
|
1085
|
+
});
|
|
1086
|
+
return nearest;
|
|
1087
|
+
}
|
|
1088
|
+
/** CRL-30: moves the row to dot `j`'s resting position, unless it is already going there. */
|
|
1089
|
+
toDot(j) {
|
|
1090
|
+
const geometry = this.geometry;
|
|
1091
|
+
if (!geometry || j < 0 || j === this.indicatorDot)
|
|
1092
|
+
return;
|
|
1093
|
+
this.indicatorDot = j;
|
|
1094
|
+
this.moveTo(geometry.restingPosition(j, geometry.position(this.target ?? this.offset)));
|
|
1095
|
+
}
|
|
1096
|
+
// ── Autoplay (CRL-32 – CRL-36) ──────────────────────────────────────────────────────────────────
|
|
1097
|
+
/** How long the row rests before it advances, in ms: `autoplayInterval`, or comp.carousel.autoplay.interval through a real property. */
|
|
1098
|
+
interval() {
|
|
1099
|
+
const own = positive(this.autoplayInterval);
|
|
1100
|
+
if (own !== null)
|
|
1101
|
+
return own;
|
|
1102
|
+
const timing = this.renderRoot?.querySelector('.timing');
|
|
1103
|
+
const seconds = timing ? Number.parseFloat(getComputedStyle(timing).transitionDelay) : Number.NaN;
|
|
1104
|
+
return Number.isFinite(seconds) && seconds > 0 ? seconds * 1000 : 0;
|
|
1105
|
+
}
|
|
1106
|
+
/** CRL-33: whether a hold is in effect. */
|
|
1107
|
+
get held() {
|
|
1108
|
+
return (this.hovering && !this.hoverLifted) || (this.focusWithin && !this.focusLifted) || this.pressing || this.touching || this.documentHidden;
|
|
1109
|
+
}
|
|
1110
|
+
/** CRL-32, CRL-34: whether the clock runs now. */
|
|
1111
|
+
get clockRuns() {
|
|
1112
|
+
return this.isConnected && this.autoplay && !this.paused && this.restingCount >= 2 && !this.reducedMotion && !this.held && !this.moving && this.interval() > 0;
|
|
1113
|
+
}
|
|
1114
|
+
/** The time of the interval that has passed, in ms. */
|
|
1115
|
+
passed(now = performance.now()) {
|
|
1116
|
+
return this.elapsed + (this.runningSince === null ? 0 : now - this.runningSince);
|
|
1117
|
+
}
|
|
1118
|
+
/** Starts or stops the clock as the conditions of CRL-32 – CRL-34 say; a stop keeps the time that has passed. */
|
|
1119
|
+
syncClock() {
|
|
1120
|
+
const runs = this.clockRuns;
|
|
1121
|
+
const interval = runs ? this.interval() : 0;
|
|
1122
|
+
if (runs && (this.runningSince === null || this.timedInterval !== interval)) {
|
|
1123
|
+
// The clock starts — or runs on under a new interval (CRL-32): the advance is timed for what is left of the
|
|
1124
|
+
// interval as it is now, so that the row moves when the fill of CRL-36, which is drawn against it, is full.
|
|
1125
|
+
this.runningSince ??= performance.now();
|
|
1126
|
+
this.timedInterval = interval;
|
|
1127
|
+
clearTimeout(this.advanceTimer);
|
|
1128
|
+
this.advanceTimer = setTimeout(this.onTimeUp, Math.max(0, interval - this.passed()));
|
|
1129
|
+
}
|
|
1130
|
+
else if (!runs && this.runningSince !== null) {
|
|
1131
|
+
this.elapsed = this.passed();
|
|
1132
|
+
this.stopClock();
|
|
1133
|
+
}
|
|
1134
|
+
this.drawProgress();
|
|
1135
|
+
}
|
|
1136
|
+
stopClock() {
|
|
1137
|
+
this.runningSince = null;
|
|
1138
|
+
clearTimeout(this.advanceTimer);
|
|
1139
|
+
// CRL-36: the fill stops with the clock, where it is; drawProgress() puts it where the clock says.
|
|
1140
|
+
if (this.progressAnimation?.playState === 'running')
|
|
1141
|
+
this.progressAnimation.pause();
|
|
1142
|
+
}
|
|
1143
|
+
/**
|
|
1144
|
+
* CRL-36: the current dot's fill, as the part of the interval that has passed. One animation of the interval's length
|
|
1145
|
+
* draws it — the fill's scale along the row, from nothing at its start edge to the whole dot, at an even pace — and the
|
|
1146
|
+
* browser runs it: script writes only when the clock starts or stops (a hold, a pause, the row moving, a new
|
|
1147
|
+
* interval), putting the animation at the time the clock has counted and letting it run or holding it there.
|
|
1148
|
+
*/
|
|
1149
|
+
drawProgress() {
|
|
1150
|
+
const dot = this.renderRoot?.querySelectorAll('.dot')[this.progressDot];
|
|
1151
|
+
this.renderRoot?.querySelectorAll('.dot.timed').forEach((each) => each !== dot && each.classList.remove('timed'));
|
|
1152
|
+
const fill = dot?.querySelector('.fill');
|
|
1153
|
+
const interval = this.interval();
|
|
1154
|
+
if (!this.progressDrawn || !dot || !fill || !(interval > 0) || typeof fill.animate !== 'function') {
|
|
1155
|
+
this.endProgress();
|
|
1156
|
+
return;
|
|
1157
|
+
}
|
|
1158
|
+
dot.classList.add('timed');
|
|
1159
|
+
let animation = this.progressAnimation;
|
|
1160
|
+
const effect = animation?.effect;
|
|
1161
|
+
if (!animation || effect?.target !== fill || effect.getTiming().duration !== interval) {
|
|
1162
|
+
this.endProgress();
|
|
1163
|
+
animation = this.progressAnimation = fill.animate({ transform: ['scaleX(0)', 'scaleX(1)'] }, { duration: interval, easing: 'linear', fill: 'both' });
|
|
1164
|
+
animation.pause();
|
|
1165
|
+
}
|
|
1166
|
+
animation.currentTime = Math.min(interval, this.passed());
|
|
1167
|
+
if (this.runningSince !== null)
|
|
1168
|
+
animation.play();
|
|
1169
|
+
else if (animation.playState !== 'paused')
|
|
1170
|
+
animation.pause();
|
|
1171
|
+
}
|
|
1172
|
+
endProgress() {
|
|
1173
|
+
this.progressAnimation?.cancel();
|
|
1174
|
+
this.progressAnimation = null;
|
|
1175
|
+
}
|
|
1176
|
+
/**
|
|
1177
|
+
* CRL-38: the playback glyphs are drawn only once the icon set can draw them — before that the glyph's box stays and
|
|
1178
|
+
* shows nothing, never the glyph's name as text. A face that never loads leaves the box empty.
|
|
1179
|
+
*/
|
|
1180
|
+
async checkGlyphs() {
|
|
1181
|
+
if (this.glyphReady)
|
|
1182
|
+
return;
|
|
1183
|
+
const icon = this.renderRoot.querySelector('.playback .icon');
|
|
1184
|
+
const fonts = typeof document === 'undefined' ? undefined : document.fonts;
|
|
1185
|
+
if (!icon)
|
|
1186
|
+
return;
|
|
1187
|
+
if (!fonts) {
|
|
1188
|
+
this.glyphReady = true;
|
|
1189
|
+
return;
|
|
1190
|
+
}
|
|
1191
|
+
const style = getComputedStyle(icon);
|
|
1192
|
+
const font = `${style.fontSize} ${style.fontFamily}`;
|
|
1193
|
+
const text = `${GLYPH_PAUSE}${GLYPH_PLAY}`;
|
|
1194
|
+
try {
|
|
1195
|
+
if (fonts.check(font, text)) {
|
|
1196
|
+
this.glyphReady = true;
|
|
1197
|
+
return;
|
|
1198
|
+
}
|
|
1199
|
+
const faces = await fonts.load(font, text);
|
|
1200
|
+
if (faces.length || fonts.check(font, text))
|
|
1201
|
+
this.glyphReady = true;
|
|
1202
|
+
}
|
|
1203
|
+
catch {
|
|
1204
|
+
// A font string the engine cannot parse: nothing to wait for.
|
|
1205
|
+
this.glyphReady = true;
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
// ── Lifecycle ───────────────────────────────────────────────────────────────────────────────────
|
|
1209
|
+
firstUpdated() {
|
|
1210
|
+
this.observeRow();
|
|
1211
|
+
this.arrange();
|
|
1212
|
+
}
|
|
1213
|
+
observeRow() {
|
|
1214
|
+
const row = this.scroller;
|
|
1215
|
+
if (row)
|
|
1216
|
+
this.resize$?.observe(row);
|
|
1217
|
+
}
|
|
1218
|
+
/** CRL-20, CRL-24: what a debug build reports, each once per value. */
|
|
1219
|
+
reportOnce(key, value, id, message) {
|
|
1220
|
+
if (Object.is(this.reported.get(key), value))
|
|
1221
|
+
return;
|
|
1222
|
+
this.reported.set(key, value);
|
|
1223
|
+
report(this, id, message, { once: false });
|
|
1224
|
+
}
|
|
1225
|
+
updated(changed) {
|
|
1226
|
+
// CRL-20: a list and an indicator without a name; a playback control without its names.
|
|
1227
|
+
if (changed.has('label') && !this.label.trim())
|
|
1228
|
+
report(this, 'CRL-20', 'label is empty, so the carousel’s list and its indicator have no accessible name; give it a label ("Recently played")');
|
|
1229
|
+
if ((changed.has('autoplay') || changed.has('playbackControl') || changed.has('playLabel') || changed.has('pauseLabel')) && this.autoplay && this.playbackControl) {
|
|
1230
|
+
const missing = [this.words.lacks('playLabel', this.playLabel) && 'play-label', this.words.lacks('pauseLabel', this.pauseLabel) && 'pause-label'].filter(Boolean).join(' and ');
|
|
1231
|
+
if (missing)
|
|
1232
|
+
this.reportOnce('labels', missing, 'CRL-20', `autoplay is on and the playback control is drawn, but ${missing} is empty, so the control has no accessible name in that state; give it both labels ("Pause the slideshow", "Play the slideshow")`);
|
|
1233
|
+
else
|
|
1234
|
+
this.reported.delete('labels');
|
|
1235
|
+
}
|
|
1236
|
+
// CRL-24: an unknown alignment is drawn as the default; an itemWidth or autoplayInterval that is not a positive number is null.
|
|
1237
|
+
if (changed.has('heroAlignment') && !HERO_ALIGNMENTS.includes(this.heroAlignment)) {
|
|
1238
|
+
this.reportOnce('heroAlignment', this.heroAlignment, 'CRL-24', `heroAlignment "${this.heroAlignment}" is not a hero alignment of the carousel; it is drawn as "center"`);
|
|
1239
|
+
}
|
|
1240
|
+
if (changed.has('contentAlignment') && !CONTENT_ALIGNMENTS.includes(this.contentAlignment)) {
|
|
1241
|
+
this.reportOnce('contentAlignment', this.contentAlignment, 'CRL-24', `contentAlignment "${this.contentAlignment}" is not a content alignment of the carousel; it is drawn as "center"`);
|
|
1242
|
+
}
|
|
1243
|
+
if (changed.has('itemWidth') && this.itemWidth !== null && this.itemWidth !== undefined && positive(this.itemWidth) === null) {
|
|
1244
|
+
this.reportOnce('itemWidth', this.itemWidth, 'CRL-24', `itemWidth ${String(this.itemWidth)} is not a positive number of CSS pixels; comp.carousel.container.large-width is used instead`);
|
|
1245
|
+
}
|
|
1246
|
+
if (changed.has('autoplayInterval') && this.autoplayInterval !== null && this.autoplayInterval !== undefined && positive(this.autoplayInterval) === null) {
|
|
1247
|
+
this.reportOnce('autoplayInterval', this.autoplayInterval, 'CRL-24', `autoplayInterval ${String(this.autoplayInterval)} is not a positive number of milliseconds; comp.carousel.autoplay.interval is used instead`);
|
|
1248
|
+
}
|
|
1249
|
+
const geometryChanged = ['heroAlignment', 'itemWidth', 'fluidWidth', 'scaleOthers', 'snap', 'loop', 'indicator'].some((name) => changed.has(name));
|
|
1250
|
+
if (this.hasUpdated && geometryChanged)
|
|
1251
|
+
this.arrange();
|
|
1252
|
+
else if (['contentAlignment', 'restingCount', 'indicatorFits', 'autoplayProgress', 'paused', 'reducedMotion'].some((name) => changed.has(name))) {
|
|
1253
|
+
this.place(this.offset);
|
|
1254
|
+
}
|
|
1255
|
+
if (['autoplay', 'paused', 'autoplayInterval', 'restingCount', 'reducedMotion', 'autoplayProgress'].some((name) => changed.has(name))) {
|
|
1256
|
+
this.syncClock();
|
|
1257
|
+
}
|
|
1258
|
+
if (this.playbackDrawn && !this.glyphReady)
|
|
1259
|
+
void this.checkGlyphs();
|
|
1260
|
+
}
|
|
1261
|
+
render() {
|
|
1262
|
+
const d = this.restingCount;
|
|
1263
|
+
const indicator = this.indicatorDrawn;
|
|
1264
|
+
const playback = this.playbackDrawn;
|
|
1265
|
+
const current = Math.min(this.current, Math.max(0, d - 1));
|
|
1266
|
+
const geometry = this.geometry;
|
|
1267
|
+
// CRL-8, CRL-9: the hero's width where the product names one — the row's own width in a box as wide as its content.
|
|
1268
|
+
const hero = positive(this.itemWidth);
|
|
1269
|
+
const valueText = geometry ? (this.laidOut[geometry.restingIndex(geometry.restingPosition(current, geometry.middle + current))]?.label ?? '') : '';
|
|
1270
|
+
// The playback control comes first in the tree, so that it is the first Tab stop (CRL-17); it is drawn in the
|
|
1271
|
+
// controls row, at its inline end (CRL-28).
|
|
1272
|
+
// The row is no Tab stop of its own (CRL-17: at most three): Firefox makes every scroller one, so it is taken out
|
|
1273
|
+
// of the order (`tabindex="-1"`). The keys reach the items, which bring themselves into place (CRL-18).
|
|
1274
|
+
return html `
|
|
1275
|
+
${playback
|
|
1276
|
+
? html `<button
|
|
1277
|
+
part="playback"
|
|
1278
|
+
class="control playback"
|
|
1279
|
+
type="button"
|
|
1280
|
+
data-tanrei-shape
|
|
1281
|
+
aria-label=${(this.paused ? this.words.get('playLabel', this.playLabel) : this.words.get('pauseLabel', this.pauseLabel)) || nothing}
|
|
1282
|
+
@click=${this.onPlaybackClick}
|
|
1283
|
+
@focus=${this.onPlaybackFocus}
|
|
1284
|
+
@pointerdown=${this.playbackPress.onPointerDown}
|
|
1285
|
+
@pointerup=${this.playbackPress.release}
|
|
1286
|
+
@pointercancel=${this.playbackPress.release}
|
|
1287
|
+
@pointerleave=${this.playbackPress.release}
|
|
1288
|
+
@keydown=${this.playbackPress.onKeyDown}
|
|
1289
|
+
@keyup=${this.playbackPress.onKeyUp}
|
|
1290
|
+
@blur=${this.playbackPress.onBlur}
|
|
1291
|
+
>
|
|
1292
|
+
<span class="icon hold${this.glyphReady ? '' : ' loading'}" aria-hidden="true">${this.paused ? GLYPH_PLAY : GLYPH_PAUSE}</span>
|
|
1293
|
+
</button>`
|
|
1294
|
+
: nothing}
|
|
1295
|
+
<div
|
|
1296
|
+
part="row"
|
|
1297
|
+
class="scroller"
|
|
1298
|
+
style=${hero === null ? nothing : `--_hero: ${hero}px`}
|
|
1299
|
+
tabindex="-1"
|
|
1300
|
+
@scroll=${this.onScroll}
|
|
1301
|
+
@scrollend=${this.onScrollEnd}
|
|
1302
|
+
@touchstart=${{ handleEvent: this.onTouchStart, passive: true }}
|
|
1303
|
+
@touchmove=${{ handleEvent: this.onTouchMove, passive: true }}
|
|
1304
|
+
@touchend=${{ handleEvent: this.onTouchEnd, passive: true }}
|
|
1305
|
+
@touchcancel=${{ handleEvent: this.onTouchEnd, passive: true }}
|
|
1306
|
+
@wheel=${{ handleEvent: this.onWheel, passive: false }}
|
|
1307
|
+
>
|
|
1308
|
+
<div class="track">
|
|
1309
|
+
<div part="list" class="stage" role="list" aria-label=${this.label || nothing}><slot @slotchange=${() => this.arrange()}></slot></div>
|
|
1310
|
+
</div>
|
|
1311
|
+
</div>
|
|
1312
|
+
${indicator || playback
|
|
1313
|
+
? html `<div part="controls" class="controls">
|
|
1314
|
+
${indicator
|
|
1315
|
+
? html `<div
|
|
1316
|
+
part="indicator"
|
|
1317
|
+
class="control indicator"
|
|
1318
|
+
data-tanrei-shape
|
|
1319
|
+
role="slider"
|
|
1320
|
+
tabindex="0"
|
|
1321
|
+
aria-label=${this.label || nothing}
|
|
1322
|
+
aria-orientation="horizontal"
|
|
1323
|
+
aria-valuemin="1"
|
|
1324
|
+
aria-valuemax=${String(d)}
|
|
1325
|
+
aria-valuenow=${String(current + 1)}
|
|
1326
|
+
aria-valuetext=${valueText || nothing}
|
|
1327
|
+
@pointerdown=${this.onIndicatorPointerDown}
|
|
1328
|
+
@pointermove=${this.onIndicatorPointerMove}
|
|
1329
|
+
@pointerup=${this.onIndicatorPointerUp}
|
|
1330
|
+
@pointercancel=${this.onIndicatorPointerUp}
|
|
1331
|
+
@lostpointercapture=${this.onIndicatorPointerUp}
|
|
1332
|
+
@keydown=${this.onIndicatorKeyDown}
|
|
1333
|
+
@focus=${this.onIndicatorFocus}
|
|
1334
|
+
>
|
|
1335
|
+
<span class="hold" hidden></span>
|
|
1336
|
+
${Array.from({ length: d }, () => html `<span part="dot" class="dot" aria-hidden="true"><span class="fill"></span></span>`)}
|
|
1337
|
+
</div>`
|
|
1338
|
+
: nothing}
|
|
1339
|
+
</div>`
|
|
1340
|
+
: nothing}
|
|
1341
|
+
<span class="probe" aria-hidden="true"></span>
|
|
1342
|
+
<span class="probe probe-controls" aria-hidden="true"></span>
|
|
1343
|
+
${DIRECTION_PROBE}
|
|
1344
|
+
<span class="timing" aria-hidden="true"></span>
|
|
1345
|
+
`;
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1348
|
+
if (!customElements.get('tanrei-carousel-item'))
|
|
1349
|
+
customElements.define('tanrei-carousel-item', TanreiCarouselItem);
|
|
1350
|
+
if (!customElements.get('tanrei-carousel'))
|
|
1351
|
+
customElements.define('tanrei-carousel', TanreiCarousel);
|
|
1352
|
+
//# sourceMappingURL=carousel.js.map
|