@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,1510 @@
|
|
|
1
|
+
import { LitElement, css, html, nothing } from 'lit';
|
|
2
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
3
|
+
import { repeat } from 'lit/directives/repeat.js';
|
|
4
|
+
import { wordPlaces } from '../../generated/words.js';
|
|
5
|
+
import { exported } from '../../primitives/composed.js';
|
|
6
|
+
import { hiddenHost } from '../../primitives/hidden.js';
|
|
7
|
+
import { AvailabilityController, BUTTON_VARIANTS, GlyphDrawnController, SHEET_FLING_VELOCITY, SHEET_TOUCH_SLOP, SystemWatchController, WordsController, closeRequestReason, compChoice, deepActive, focusOverlay, giveVariant, holdPageScroll, modalLayer, modalSheetKeys, report, returnFocus, syncFocusStyle, watchEscape, watchInput, } from '../../primitives/index.js';
|
|
8
|
+
import { ambientLocale } from '../../primitives/locale-date.js';
|
|
9
|
+
import { fillPlaces, reportPlaces } from '../../primitives/places.js';
|
|
10
|
+
import { TanreiButton } from '../button/button.js';
|
|
11
|
+
import '../skeleton/skeleton.js';
|
|
12
|
+
import { styles } from './image-preview.styles.js';
|
|
13
|
+
const ITEM_TAG = 'tanrei-image-preview-item';
|
|
14
|
+
const PREFIX = '--tanrei-comp-image-preview';
|
|
15
|
+
/** The five controls, in the order Tab visits them (IMP-3); each is a part of that name (IMP-8, IMP-10). */
|
|
16
|
+
const CONTROLS = ['zoom-out', 'zoom-in', 'close', 'previous', 'next'];
|
|
17
|
+
/** Each Button's documented parts under the control's name: `close-container`, `close-label`, `close-icon`. */
|
|
18
|
+
const BUTTON_PARTS = Object.fromEntries(CONTROLS.map((control) => [control, exported(TanreiButton, Object.fromEntries(TanreiButton.parts.map((part) => [part, { as: `${control}-${part}` }])))]));
|
|
19
|
+
/** IMP-14: two presses are a double tap within this long, in ms, and within the touch slop: the web names no interval of its own. */
|
|
20
|
+
const DOUBLE_TAP = 300;
|
|
21
|
+
/** IMP-14: how far apart the two presses of a double tap may land, in px: a second finger does not land within the slop of a drag. */
|
|
22
|
+
const DOUBLE_TAP_REACH = 24;
|
|
23
|
+
/** IMP-15: how much one pixel of a wheel turned with Ctrl or Command — or of a trackpad pinch, which arrives as one — changes the zoom. */
|
|
24
|
+
const WHEEL_ZOOM = 0.01;
|
|
25
|
+
/** IMP-15, IMP-21: a wheel names no end of its gesture; one that has been still this long, in ms, has ended. */
|
|
26
|
+
const WHEEL_END = 160;
|
|
27
|
+
/** IMP-16: a wheel that counts lines or pages, as pixels. */
|
|
28
|
+
const WHEEL_LINE = 16;
|
|
29
|
+
/** IMP-16: how a fling slows — the time, in ms, over which its speed falls to 1/e — and the speed below which it has stopped, in px per ms. */
|
|
30
|
+
const FLING_TIME = 325;
|
|
31
|
+
const FLING_REST = 0.02;
|
|
32
|
+
/** IMP-18: how much of a drag past the first or the last image the image follows (the web names no overscroll of its own). */
|
|
33
|
+
const OVERSCROLL = 0.3;
|
|
34
|
+
const EPSILON = 0.001;
|
|
35
|
+
/** One event of the preview's, with its detail, from the element. */
|
|
36
|
+
function fire(host, name, detail) {
|
|
37
|
+
host.dispatchEvent(new CustomEvent(name, { detail, bubbles: true, composed: true }));
|
|
38
|
+
}
|
|
39
|
+
const positive = (value) => typeof value === 'number' && Number.isFinite(value) && value > 0;
|
|
40
|
+
/** IMP-31: nothing is drawn for it, and what was asked for did not load. */
|
|
41
|
+
const failed = (picture) => !!picture && !picture.drawn && !!picture.asked && picture.refused === picture.asked;
|
|
42
|
+
const numberOrNull = {
|
|
43
|
+
fromAttribute: (value) => (value === null || value.trim() === '' ? null : Number(value)),
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* One picture of an image preview's set: where it is, what it shows in words, and optionally what the product says
|
|
47
|
+
* about it. `<tanrei-image-preview-item src="room-large.jpg" alt="A bedroom with a window onto a garden">`.
|
|
48
|
+
*
|
|
49
|
+
* The element is data for the preview that holds it: it draws nothing, takes no focus and fires no event, and it is
|
|
50
|
+
* not an `<img>`, so the browser asks for no picture the preview has not asked for (IMP-32). The preview reads its
|
|
51
|
+
* children in order and reads them again when an attribute changes. Every property reflects to its attribute, which
|
|
52
|
+
* is what the preview reads.
|
|
53
|
+
*
|
|
54
|
+
* @tag tanrei-image-preview-item
|
|
55
|
+
*/
|
|
56
|
+
export class TanreiImagePreviewItem extends LitElement {
|
|
57
|
+
constructor() {
|
|
58
|
+
super(...arguments);
|
|
59
|
+
/** The address of the picture as the preview shows it — usually a larger file than the thumbnail on the page. Required; while it is empty the preview asks for nothing and the image waits. Changed while the image is shown, the new picture replaces the old one in place once it has loaded (IMP-30). */
|
|
60
|
+
this.src = '';
|
|
61
|
+
/** What the picture shows, in the product's language: the name assistive technology reads for it. Required for every image (IMP-27). Never drawn. */
|
|
62
|
+
this.alt = '';
|
|
63
|
+
/** What the product says about the picture, drawn below it and read as its description: a credit, a date, a sentence. Plain text of any length; a long one scrolls in its own region (IMP-26). Empty draws no caption. */
|
|
64
|
+
this.caption = '';
|
|
65
|
+
/** The address of a smaller picture of the same image that the page has usually loaded already (`thumbnail-src`). Drawn enlarged in the image's place until `src` has loaded, in place of the Skeleton (IMP-29). */
|
|
66
|
+
this.thumbnailSrc = '';
|
|
67
|
+
/** The picture's own width in pixels, where the product knows it. With `height` it lets the preview hold the image's place before the picture has loaded. Null: learned when it loads. */
|
|
68
|
+
this.width = null;
|
|
69
|
+
/** The picture's own height in pixels; see `width`. */
|
|
70
|
+
this.height = null;
|
|
71
|
+
}
|
|
72
|
+
static { this.styles = css `
|
|
73
|
+
:host {
|
|
74
|
+
display: none !important;
|
|
75
|
+
}
|
|
76
|
+
`; }
|
|
77
|
+
static { this.properties = {
|
|
78
|
+
src: { type: String, reflect: true },
|
|
79
|
+
alt: { type: String, reflect: true },
|
|
80
|
+
caption: { type: String, reflect: true },
|
|
81
|
+
thumbnailSrc: { type: String, attribute: 'thumbnail-src', reflect: true },
|
|
82
|
+
width: { converter: numberOrNull, reflect: true },
|
|
83
|
+
height: { converter: numberOrNull, reflect: true },
|
|
84
|
+
}; }
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Shows one picture of a set over the whole window when the person presses its thumbnail, to be looked at closely —
|
|
88
|
+
* enlarged and back by a double tap, a pinch, a control or a key, moved about while enlarged — and moved on to the
|
|
89
|
+
* next picture or back, until it is closed.
|
|
90
|
+
*
|
|
91
|
+
* Contract: specs/image-preview.spec.json. A feature: its stage — the picture, its zoom and its place —
|
|
92
|
+
* and its pager are its own; its five controls are real `<tanrei-button>` elements and its placeholder a real
|
|
93
|
+
* `<tanrei-skeleton>`, each reading its own tokens. The images are `<tanrei-image-preview-item>` children.
|
|
94
|
+
*
|
|
95
|
+
* The product opens it from its own thumbnail — a `<button type="button" aria-haspopup="dialog">` around its own
|
|
96
|
+
* picture, named for what it does — by setting `index` and `open`, and closes it in answer to `close` by setting
|
|
97
|
+
* `open` to false: the preview never closes itself. It is a native `<dialog>` in the shadow root opened with
|
|
98
|
+
* `showModal()`: in the top layer over the whole window, everything else inert, the page held from scrolling, focus on
|
|
99
|
+
* the stage and kept inside, and returned where it was when the preview closes. It writes no history entry.
|
|
100
|
+
*
|
|
101
|
+
* Every gesture has a control and a key: the zoom controls and `+` `−` `0` for a double tap and a pinch; the previous
|
|
102
|
+
* and next controls, the arrow keys, Page Up, Page Down, Home and End for a sideways drag; the arrow keys for a drag
|
|
103
|
+
* over an enlarged picture; the close control and Escape for the downward drag by touch. `index`, `zoom` and
|
|
104
|
+
* `controlsHidden` are plain values the element writes itself on a person's change, before the event.
|
|
105
|
+
*
|
|
106
|
+
* Only the image shown and the one before and after it are asked for. An item without a `src` is asked for nothing
|
|
107
|
+
* and waits. Every visual value comes from `--tanrei-comp-image-preview-*` tokens.
|
|
108
|
+
*
|
|
109
|
+
* @tag tanrei-image-preview
|
|
110
|
+
* @slot - The images: `<tanrei-image-preview-item>` elements, in the order they are shown. They are read, never drawn in place.
|
|
111
|
+
* @csspart container - The surface that fills the window: the native `<dialog>`.
|
|
112
|
+
* @csspart bar - The row across the top: the count and the zoom-out, zoom-in and close controls.
|
|
113
|
+
* @csspart count - The sentence that says which image of how many is shown.
|
|
114
|
+
* @csspart stage - The whole of the container as the place the image is shown: the focus stop that takes the gestures and the keys, exposed as the image shown.
|
|
115
|
+
* @csspart image - The picture shown, and its neighbour beside it while one replaces the other.
|
|
116
|
+
* @csspart placeholder - What stands in the image's place while it is on its way: its thumbnail enlarged, or the box of the Skeleton.
|
|
117
|
+
* @csspart error - The mark and the sentence in place of an image that did not arrive.
|
|
118
|
+
* @csspart caption - The region that holds the text about the image shown, and scrolls where it is long.
|
|
119
|
+
* @csspart zoom-out - The zoom-out control: a `<tanrei-button>`.
|
|
120
|
+
* @csspart zoom-in - The zoom-in control: a `<tanrei-button>`.
|
|
121
|
+
* @csspart close - The close control: a `<tanrei-button>`.
|
|
122
|
+
* @csspart previous - The previous control: a `<tanrei-button>`.
|
|
123
|
+
* @csspart next - The next control: a `<tanrei-button>`.
|
|
124
|
+
* @exportparts tanrei-button container: zoom-out-container, label: zoom-out-label, icon: zoom-out-icon
|
|
125
|
+
* @exportparts tanrei-button container: zoom-in-container, label: zoom-in-label, icon: zoom-in-icon
|
|
126
|
+
* @exportparts tanrei-button container: close-container, label: close-label, icon: close-icon
|
|
127
|
+
* @exportparts tanrei-button container: previous-container, label: previous-label, icon: previous-icon
|
|
128
|
+
* @exportparts tanrei-button container: next-container, label: next-label, icon: next-icon
|
|
129
|
+
* @fires {CustomEvent<TanreiImagePreviewCloseDetail>} close - The person asked to close the preview: `detail.reason` is `button`, `escape`, `back` or `swipe`. Set `open` to false.
|
|
130
|
+
* @fires {CustomEvent<TanreiImagePreviewIndexChangeDetail>} indexchange - The person moved to another image: `detail.index`, which `index` already is. Not fired when you set `index`.
|
|
131
|
+
* @fires {CustomEvent<TanreiImagePreviewZoomChangeDetail>} zoomchange - The zoom changed by the person's gesture, control or key, or returned to 1 because the image changed: `detail.zoom`, once the change has ended. Not fired when you set `zoom`.
|
|
132
|
+
* @fires {CustomEvent<TanreiImagePreviewControlsHiddenChangeDetail>} controlshiddenchange - The person hid or showed the controls: `detail.hidden`. Not fired when you set `controlsHidden`.
|
|
133
|
+
* @fires {CustomEvent<TanreiImagePreviewLoadErrorDetail>} loaderror - The source of an image the preview asked for did not load: `detail.index`. Once for each source that fails.
|
|
134
|
+
*/
|
|
135
|
+
export class TanreiImagePreview extends LitElement {
|
|
136
|
+
constructor() {
|
|
137
|
+
super(...arguments);
|
|
138
|
+
this.availability = new AvailabilityController(this, 'image-preview');
|
|
139
|
+
/** The product's words, read where the instance gives none (src/primitives/words.ts). */
|
|
140
|
+
this.words = new WordsController(this);
|
|
141
|
+
/** IMP-8, IMP-10: the variants its tokens name are read again when the document's root switches the design system. */
|
|
142
|
+
this.system = new SystemWatchController(this);
|
|
143
|
+
/** IMP-31: the mark carries `data-drawn` while the icon set can draw its ligature; until then it draws nothing. */
|
|
144
|
+
this.glyphs = new GlyphDrawnController(this, () => this.renderRoot?.querySelectorAll('.glyph') ?? []);
|
|
145
|
+
/** Whether the preview is presented. Open it from your own thumbnail, with `index` set to that image, and close it in answer to `close`. Reflected. */
|
|
146
|
+
this.open = false;
|
|
147
|
+
/** Which image is shown, counted from 0 in the order the images are given. The person changes it by a drag, the previous and next controls and the keys, and the preview then fires `indexchange`; setting it fires nothing. A number outside the images is taken as the nearest that exists (IMP-20). */
|
|
148
|
+
this.index = 0;
|
|
149
|
+
/** How far the image shown is enlarged: 1 is its fit in the window, 2 twice that. The person changes it by a double tap, a pinch, the zoom controls and the keys, and the preview then fires `zoomchange`; it returns to 1 whenever the image shown changes. Kept between 1 and the greatest zoom (IMP-12). */
|
|
150
|
+
this.zoom = 1;
|
|
151
|
+
/** The greatest zoom (`max-zoom`). Null takes the greater of 4 and twice the zoom at which the image fills the window's free area, so that a very wide or very tall image can still be read (IMP-12). */
|
|
152
|
+
this.maxZoom = null;
|
|
153
|
+
/** Whether the bar, the count, the previous and next controls and the caption are not drawn (`controls-hidden`). The person changes it by one tap on the picture, and the preview then fires `controlshiddenchange`; any key, focus on a control or a moving mouse shows them again (IMP-25). Hidden controls stay in the focus order and exposed to assistive technology. Reflected. */
|
|
154
|
+
this.controlsHidden = false;
|
|
155
|
+
/** The accessible name of the preview, in the product's language ("Photos of the room"). Never drawn. Required. */
|
|
156
|
+
this.label = '';
|
|
157
|
+
/** The close control's accessible name ("Close"). Required. Left empty, it reads the product's words (`closeLabel`). */
|
|
158
|
+
this.closeLabel = '';
|
|
159
|
+
/** The previous control's accessible name ("Previous image"). Required while there are two or more images. Left empty, it reads the product's words (`previousImageLabel`). */
|
|
160
|
+
this.previousLabel = '';
|
|
161
|
+
/** The next control's accessible name ("Next image"). Required while there are two or more images. Left empty, it reads the product's words (`nextImageLabel`). */
|
|
162
|
+
this.nextLabel = '';
|
|
163
|
+
/** The zoom-in control's accessible name ("Zoom in"). Required. Left empty, it reads the product's words (`zoomInLabel`). */
|
|
164
|
+
this.zoomInLabel = '';
|
|
165
|
+
/** The zoom-out control's accessible name ("Zoom out"). Required. Left empty, it reads the product's words (`zoomOutLabel`). */
|
|
166
|
+
this.zoomOutLabel = '';
|
|
167
|
+
/**
|
|
168
|
+
* The sentence that says which image of how many is shown, drawn in the bar and told to assistive technology. Write
|
|
169
|
+
* the whole sentence in your own language and mark two places in it, which the preview fills: `{position}` with the
|
|
170
|
+
* place of the image shown, counted from 1, and `{count}` with the number of images ("{position} of {count}"). Left
|
|
171
|
+
* empty, it reads the product's words (`imageCountText`). Required while there are two or more images.
|
|
172
|
+
*/
|
|
173
|
+
this.countText = '';
|
|
174
|
+
/** What assistive technology is told while the image shown is on its way ("Loading image"): the name of the Skeleton that stands in its place. Left empty, the Skeleton reads the product's words (`loadingLabel`). */
|
|
175
|
+
this.loadingLabel = '';
|
|
176
|
+
/** The sentence drawn, and told to assistive technology, in place of an image that did not arrive ("This image could not be loaded"). Left empty, it reads the product's words (`imageErrorText`). Required. */
|
|
177
|
+
this.errorText = '';
|
|
178
|
+
/** The images, as its children hold them now. */
|
|
179
|
+
this.images = [];
|
|
180
|
+
/** The place of the image shown: `index`, kept within the images (IMP-20). */
|
|
181
|
+
this.shown = 0;
|
|
182
|
+
/** Counts what is drawn anew for a reason that is no property (a source that loaded, a zoom that ended). */
|
|
183
|
+
this.drawn = 0;
|
|
184
|
+
/** IMP-26: whether the caption's text needs more than its region. */
|
|
185
|
+
this.captionScrolls = false;
|
|
186
|
+
/** IMP-32: the three images asked for, by their elements. */
|
|
187
|
+
this.pictures = new Map();
|
|
188
|
+
/** IMP-31: the sources that failed, by element: `loaderror` is fired once for each. */
|
|
189
|
+
this.failed = new WeakMap();
|
|
190
|
+
/** A picture's own size, kept while its element is not one of the three, so that it is drawn where it was. */
|
|
191
|
+
this.sizes = new WeakMap();
|
|
192
|
+
/** IMP-12 to IMP-17: where the image shown is. */
|
|
193
|
+
this.view = { z: 1, x: 0, y: 0 };
|
|
194
|
+
/** IMP-11: the stage and the fit area in it, as last measured (px, from the stage's top left corner). */
|
|
195
|
+
this.stage = { w: 0, h: 0 };
|
|
196
|
+
this.fit = { x: 0, y: 0, w: 0, h: 0 };
|
|
197
|
+
/** IMP-4: where focus was when it opened. */
|
|
198
|
+
this.opener = null;
|
|
199
|
+
/** Presented: in the top layer. */
|
|
200
|
+
this.presented = false;
|
|
201
|
+
/** IMP-43: an opening with nothing to show was reported, until there is something. */
|
|
202
|
+
this.reportedEmpty = false;
|
|
203
|
+
this.touches = new Map();
|
|
204
|
+
this.gesture = null;
|
|
205
|
+
/** IMP-14: the last single press, which a second one within the interval makes a double tap. */
|
|
206
|
+
this.lastTap = null;
|
|
207
|
+
/** IMP-25: where the pointer was when the controls were hidden by a press: a mouse shows them again once it has moved from there. */
|
|
208
|
+
this.hiddenAt = null;
|
|
209
|
+
this.wheelTimer = null;
|
|
210
|
+
this.flingFrame = 0;
|
|
211
|
+
/** IMP-15: the view when a trackpad pinch that arrives as a gesture event began. */
|
|
212
|
+
this.gestureView = null;
|
|
213
|
+
/** IMP-28: the control that had focus when it became disabled: focus goes to the stage once it is drawn so. */
|
|
214
|
+
this.focusLeaves = false;
|
|
215
|
+
this.children$ = new MutationObserver(() => this.readImages());
|
|
216
|
+
this.resize$ = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(() => this.onResize());
|
|
217
|
+
this.onLoad = (event) => {
|
|
218
|
+
const element = event.currentTarget;
|
|
219
|
+
const at = Number(element.dataset.at);
|
|
220
|
+
const picture = this.pictureAt(at);
|
|
221
|
+
const src = element.dataset.src ?? '';
|
|
222
|
+
if (!picture || src !== picture.asked)
|
|
223
|
+
return;
|
|
224
|
+
const natural = positive(element.naturalWidth) && positive(element.naturalHeight) ? { w: element.naturalWidth, h: element.naturalHeight } : null;
|
|
225
|
+
const image = this.images[at];
|
|
226
|
+
const declared = positive(image.width) && positive(image.height);
|
|
227
|
+
// IMP-30: a picture of the same proportions as the one drawn takes its place, at its size; another is its own.
|
|
228
|
+
if (!declared && natural) {
|
|
229
|
+
const same = picture.own && Math.abs(picture.own.w / picture.own.h - natural.w / natural.h) < 0.01;
|
|
230
|
+
if (!same || !picture.drawn)
|
|
231
|
+
picture.own = natural;
|
|
232
|
+
}
|
|
233
|
+
if (picture.own)
|
|
234
|
+
this.sizes.set(image.element, picture.own);
|
|
235
|
+
picture.drawn = src;
|
|
236
|
+
this.drawn++;
|
|
237
|
+
};
|
|
238
|
+
this.onError = (event) => {
|
|
239
|
+
const element = event.currentTarget;
|
|
240
|
+
const at = Number(element.dataset.at);
|
|
241
|
+
const picture = this.pictureAt(at);
|
|
242
|
+
const src = element.dataset.src ?? '';
|
|
243
|
+
const image = this.images[at];
|
|
244
|
+
if (!picture || !image || src !== picture.asked)
|
|
245
|
+
return;
|
|
246
|
+
// IMP-31: once for each source that fails.
|
|
247
|
+
const told = this.failed.get(image.element) ?? new Set();
|
|
248
|
+
const first = !told.has(src);
|
|
249
|
+
told.add(src);
|
|
250
|
+
this.failed.set(image.element, told);
|
|
251
|
+
// A source that was to replace a picture that is drawn (IMP-30) leaves that picture drawn.
|
|
252
|
+
picture.refused = src;
|
|
253
|
+
this.drawn++;
|
|
254
|
+
if (first)
|
|
255
|
+
this.emit('loaderror', { index: at });
|
|
256
|
+
if (at === this.shown && failed(picture)) {
|
|
257
|
+
const sentence = this.words.get('imageErrorText', this.errorText);
|
|
258
|
+
if (sentence)
|
|
259
|
+
this.say([sentence]);
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
this.onThumbnailLoad = (event) => {
|
|
263
|
+
const element = event.currentTarget;
|
|
264
|
+
const picture = this.pictureAt(Number(element.dataset.at));
|
|
265
|
+
if (!picture || element.dataset.src !== picture.thumbnail)
|
|
266
|
+
return;
|
|
267
|
+
if (positive(element.naturalWidth) && positive(element.naturalHeight))
|
|
268
|
+
picture.thumbnailSize = { w: element.naturalWidth, h: element.naturalHeight };
|
|
269
|
+
this.drawn++;
|
|
270
|
+
};
|
|
271
|
+
this.onThumbnailError = (event) => {
|
|
272
|
+
const element = event.currentTarget;
|
|
273
|
+
const picture = this.pictureAt(Number(element.dataset.at));
|
|
274
|
+
if (!picture || element.dataset.src !== picture.thumbnail)
|
|
275
|
+
return;
|
|
276
|
+
picture.thumbnailFailed = true;
|
|
277
|
+
this.drawn++;
|
|
278
|
+
};
|
|
279
|
+
this.onImageSettled = (event) => {
|
|
280
|
+
event.currentTarget.classList.remove('stepping');
|
|
281
|
+
};
|
|
282
|
+
this.announce = false;
|
|
283
|
+
/** IMP-32, IMP-33: once it has faded out, what it drew is let go. */
|
|
284
|
+
this.onFaded = (event) => {
|
|
285
|
+
if (event.target !== this.dialog || event.propertyName !== 'opacity' || this.presented || this.open || !this.pictures.size)
|
|
286
|
+
return;
|
|
287
|
+
this.pictures.clear();
|
|
288
|
+
this.drawn++;
|
|
289
|
+
};
|
|
290
|
+
this.onPagesSettled = (event) => {
|
|
291
|
+
if (event.propertyName !== 'translate')
|
|
292
|
+
return;
|
|
293
|
+
this.pagesElement?.classList.remove('settling');
|
|
294
|
+
};
|
|
295
|
+
/** The Buttons' clicks do not leave the preview: it answers them. */
|
|
296
|
+
this.onControl = (control) => (event) => {
|
|
297
|
+
event.stopPropagation();
|
|
298
|
+
if (control === 'close')
|
|
299
|
+
this.requestClose('button');
|
|
300
|
+
else if (control === 'zoom-in')
|
|
301
|
+
this.stepZoom(1);
|
|
302
|
+
else if (control === 'zoom-out')
|
|
303
|
+
this.stepZoom(-1);
|
|
304
|
+
else if (control === 'previous')
|
|
305
|
+
this.go(this.shown - 1);
|
|
306
|
+
else
|
|
307
|
+
this.go(this.shown + 1);
|
|
308
|
+
};
|
|
309
|
+
// ---- The keys (IMP-3, IMP-5, IMP-23, IMP-25) ----
|
|
310
|
+
/** IMP-25: any key shows the controls, before the control answers (heard on the way down). */
|
|
311
|
+
this.onKeyDownFirst = () => this.hideControls(false);
|
|
312
|
+
this.onKeyDown = (event) => {
|
|
313
|
+
const dialog = this.dialog;
|
|
314
|
+
if (!dialog)
|
|
315
|
+
return;
|
|
316
|
+
// IMP-3, IMP-5: Tab stays inside; Escape asks to close, whatever the zoom.
|
|
317
|
+
if (event.key === 'Escape' || event.key === 'Tab') {
|
|
318
|
+
modalSheetKeys(event, dialog, () => this.requestClose('escape'));
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
if (event.defaultPrevented || event.ctrlKey || event.metaKey || event.altKey)
|
|
322
|
+
return;
|
|
323
|
+
// IMP-23: a part that uses the key itself keeps it: the caption that scrolls.
|
|
324
|
+
const inCaption = event.composedPath().some((node) => node instanceof HTMLElement && node.classList.contains('caption') && node.tabIndex >= 0);
|
|
325
|
+
const zoomed = this.view.z > 1 + EPSILON;
|
|
326
|
+
const last = this.images.length - 1;
|
|
327
|
+
const sideways = (toward) => {
|
|
328
|
+
// IMP-23, IMP-35: at fit, the image that lies on that side; enlarged, the view moves toward it (never mirrored).
|
|
329
|
+
if (!zoomed)
|
|
330
|
+
this.go(this.shown + (this.rtl ? -toward : toward));
|
|
331
|
+
else
|
|
332
|
+
this.stepTo(this.held({ ...this.view, x: this.view.x - (toward * this.fit.w) / 4 }));
|
|
333
|
+
};
|
|
334
|
+
const upDown = (toward) => {
|
|
335
|
+
if (zoomed)
|
|
336
|
+
this.stepTo(this.held({ ...this.view, y: this.view.y - (toward * this.fit.h) / 4 }));
|
|
337
|
+
};
|
|
338
|
+
const keys = {
|
|
339
|
+
ArrowLeft: inCaption ? undefined : () => sideways(-1),
|
|
340
|
+
ArrowRight: inCaption ? undefined : () => sideways(1),
|
|
341
|
+
ArrowUp: inCaption ? undefined : () => upDown(-1),
|
|
342
|
+
ArrowDown: inCaption ? undefined : () => upDown(1),
|
|
343
|
+
PageUp: inCaption ? undefined : () => this.go(this.shown - 1),
|
|
344
|
+
PageDown: inCaption ? undefined : () => this.go(this.shown + 1),
|
|
345
|
+
Home: inCaption ? undefined : () => this.go(0),
|
|
346
|
+
End: inCaption ? undefined : () => this.go(last),
|
|
347
|
+
'+': () => this.stepZoom(1),
|
|
348
|
+
'=': () => this.stepZoom(1),
|
|
349
|
+
'-': () => this.stepZoom(-1),
|
|
350
|
+
'−': () => this.stepZoom(-1),
|
|
351
|
+
'0': () => this.stepZoom(0),
|
|
352
|
+
};
|
|
353
|
+
const answer = Object.hasOwn(keys, event.key) ? keys[event.key] : undefined;
|
|
354
|
+
if (!answer)
|
|
355
|
+
return;
|
|
356
|
+
// A key that has nothing to do does nothing, and does not leave the preview.
|
|
357
|
+
event.preventDefault();
|
|
358
|
+
answer();
|
|
359
|
+
};
|
|
360
|
+
/** IMP-5: a close request without a key the preview saw (Android's back) arrives as the native cancel. */
|
|
361
|
+
this.onNativeCancel = (event) => {
|
|
362
|
+
event.preventDefault();
|
|
363
|
+
this.requestClose(closeRequestReason(event));
|
|
364
|
+
};
|
|
365
|
+
/** The browser closed the dialog itself (a close request it would not let the preview cancel): ask, and stay unless closed. */
|
|
366
|
+
this.onNativeClose = () => {
|
|
367
|
+
const dialog = this.dialog;
|
|
368
|
+
if (!this.presented || !dialog || dialog.open)
|
|
369
|
+
return;
|
|
370
|
+
this.requestClose('back');
|
|
371
|
+
if (this.open && this.presented)
|
|
372
|
+
dialog.showModal();
|
|
373
|
+
};
|
|
374
|
+
/** IMP-25: focus that reaches a control shows the controls. IMP-26, IMP-27: the focus style of the stage and of the caption, where style queries are missing. */
|
|
375
|
+
this.onFocusIn = (event) => {
|
|
376
|
+
const target = event.target;
|
|
377
|
+
if (target === this.stageElement) {
|
|
378
|
+
syncFocusStyle(this, target);
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
// IMP-26: the scrolling caption draws its own indicator, and is one of what a hidden preview does not draw.
|
|
382
|
+
if (target.classList.contains('caption'))
|
|
383
|
+
syncFocusStyle(this, target);
|
|
384
|
+
this.hideControls(false);
|
|
385
|
+
};
|
|
386
|
+
this.onStageBlur = () => this.stageElement?.removeAttribute('data-focus-quiet');
|
|
387
|
+
/**
|
|
388
|
+
* IMP-3, IMP-23: focus stays inside. An engine that gives a button no focus for a press takes focus from where it was
|
|
389
|
+
* and puts it on nothing: the keys would then reach no part of the preview. Focus that has left for nothing, in a
|
|
390
|
+
* window that still has it, is on the stage again.
|
|
391
|
+
*/
|
|
392
|
+
this.onFocusOut = (event) => {
|
|
393
|
+
if (!this.presented || event.relatedTarget)
|
|
394
|
+
return;
|
|
395
|
+
setTimeout(() => {
|
|
396
|
+
const active = deepActive();
|
|
397
|
+
const nowhere = !active || active === document.body || active === document.documentElement;
|
|
398
|
+
const stage = this.stageElement;
|
|
399
|
+
if (this.presented && nowhere && document.hasFocus() && stage)
|
|
400
|
+
focusOverlay(this, stage);
|
|
401
|
+
}, 0);
|
|
402
|
+
};
|
|
403
|
+
this.onPointerDown = (event) => {
|
|
404
|
+
if (event.pointerType === 'mouse' && event.button !== 0)
|
|
405
|
+
return;
|
|
406
|
+
const stage = this.stageElement;
|
|
407
|
+
if (!stage)
|
|
408
|
+
return;
|
|
409
|
+
const at = this.point(event);
|
|
410
|
+
this.touches.set(event.pointerId, { ...at, type: event.pointerType });
|
|
411
|
+
try {
|
|
412
|
+
stage.setPointerCapture(event.pointerId);
|
|
413
|
+
}
|
|
414
|
+
catch {
|
|
415
|
+
// A pointer the browser no longer counts as active cannot be captured; its moves still arrive while it is over the stage.
|
|
416
|
+
}
|
|
417
|
+
this.still();
|
|
418
|
+
if (this.touches.size === 2) {
|
|
419
|
+
this.beginPinch();
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
if (this.touches.size > 2)
|
|
423
|
+
return;
|
|
424
|
+
this.gesture = { kind: 'wait', id: event.pointerId, x: at.x, y: at.y, time: event.timeStamp };
|
|
425
|
+
};
|
|
426
|
+
this.onPointerMove = (event) => {
|
|
427
|
+
const touch = this.touches.get(event.pointerId);
|
|
428
|
+
if (!touch) {
|
|
429
|
+
// IMP-25: a pointer that can hover moves over the preview.
|
|
430
|
+
if (event.pointerType === 'mouse' && this.controlsHidden)
|
|
431
|
+
this.onHover(event);
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
const at = this.point(event);
|
|
435
|
+
touch.x = at.x;
|
|
436
|
+
touch.y = at.y;
|
|
437
|
+
const gesture = this.gesture;
|
|
438
|
+
if (!gesture)
|
|
439
|
+
return;
|
|
440
|
+
if (gesture.kind === 'pinch') {
|
|
441
|
+
if (this.touches.size < 2 || !this.ready)
|
|
442
|
+
return;
|
|
443
|
+
const [a, b] = [...this.touches.values()];
|
|
444
|
+
const distance = Math.max(1, Math.hypot(a.x - b.x, a.y - b.y));
|
|
445
|
+
const mid = { x: (a.x + b.x) / 2, y: (a.y + b.y) / 2 };
|
|
446
|
+
const centre = { x: this.fit.x + this.fit.w / 2, y: this.fit.y + this.fit.h / 2 };
|
|
447
|
+
// The point that was midway between the fingers is midway between them still.
|
|
448
|
+
const zoomed = this.zoomedAbout(gesture.view, gesture.view.z * (distance / gesture.distance), gesture.midX - centre.x, gesture.midY - centre.y);
|
|
449
|
+
this.view = this.held({ z: zoomed.z, x: zoomed.x + (mid.x - gesture.midX), y: zoomed.y + (mid.y - gesture.midY) });
|
|
450
|
+
this.place();
|
|
451
|
+
return;
|
|
452
|
+
}
|
|
453
|
+
if (gesture.id !== event.pointerId)
|
|
454
|
+
return;
|
|
455
|
+
if (gesture.kind === 'wait') {
|
|
456
|
+
const dx = at.x - gesture.x;
|
|
457
|
+
const dy = at.y - gesture.y;
|
|
458
|
+
if (Math.hypot(dx, dy) <= SHEET_TOUCH_SLOP)
|
|
459
|
+
return;
|
|
460
|
+
this.cancelTap();
|
|
461
|
+
this.gesture = this.begin(event, gesture, dx, dy);
|
|
462
|
+
if (this.gesture.kind === 'none')
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
this.follow(event, at);
|
|
466
|
+
};
|
|
467
|
+
this.onPointerUp = (event) => {
|
|
468
|
+
const touch = this.touches.get(event.pointerId);
|
|
469
|
+
if (!touch)
|
|
470
|
+
return;
|
|
471
|
+
this.touches.delete(event.pointerId);
|
|
472
|
+
const gesture = this.gesture;
|
|
473
|
+
const cancelled = event.type === 'pointercancel';
|
|
474
|
+
if (!gesture)
|
|
475
|
+
return;
|
|
476
|
+
if (gesture.kind === 'pinch') {
|
|
477
|
+
if (this.touches.size >= 2)
|
|
478
|
+
return;
|
|
479
|
+
// IMP-15: the zoom stays where it is. IMP-21: the gesture has ended.
|
|
480
|
+
this.gesture = null;
|
|
481
|
+
this.commitZoom();
|
|
482
|
+
// The finger that stays goes on as a drag of its own.
|
|
483
|
+
const [left] = [...this.touches.entries()];
|
|
484
|
+
if (left)
|
|
485
|
+
this.gesture = { kind: 'pan', id: left[0], lastX: left[1].x, lastY: left[1].y, samples: [] };
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
488
|
+
if (gesture.id !== event.pointerId)
|
|
489
|
+
return;
|
|
490
|
+
this.gesture = null;
|
|
491
|
+
const at = this.point(event);
|
|
492
|
+
if (gesture.kind === 'wait') {
|
|
493
|
+
if (!cancelled)
|
|
494
|
+
this.tap(at.x, at.y, event.timeStamp, touch.type);
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
if (gesture.kind === 'pan') {
|
|
498
|
+
if (cancelled || this.reduced)
|
|
499
|
+
return;
|
|
500
|
+
const now = event.timeStamp;
|
|
501
|
+
const recent = gesture.samples.filter((sample) => now - sample.time <= 80);
|
|
502
|
+
if (recent.length < 2)
|
|
503
|
+
return;
|
|
504
|
+
const time = recent[recent.length - 1].time - recent[0].time;
|
|
505
|
+
if (time <= 0)
|
|
506
|
+
return;
|
|
507
|
+
// IMP-16: a fling goes on and slows.
|
|
508
|
+
this.fling((recent[recent.length - 1].x - recent[0].x) / time, (recent[recent.length - 1].y - recent[0].y) / time);
|
|
509
|
+
return;
|
|
510
|
+
}
|
|
511
|
+
if (gesture.kind === 'page') {
|
|
512
|
+
const moved = at.x - gesture.x + gesture.from;
|
|
513
|
+
const velocity = cancelled ? 0 : this.speed(gesture.samples, event.timeStamp);
|
|
514
|
+
// IMP-18, IMP-19: past half the stage's width — or, by a finger or a pen, flung toward that side. A mouse's drag
|
|
515
|
+
// turns the page by its distance alone, at fit and from the limit of an enlarged image alike: a mouse moves at a
|
|
516
|
+
// fling's speed in ordinary use and is dragged in repeated strokes. The kind is the `pointerType` of the
|
|
517
|
+
// pointer's `pointerdown`; an empty or unknown one is taken as a finger's.
|
|
518
|
+
const far = Math.abs(moved) > this.stage.w / 2;
|
|
519
|
+
const flung = touch.type !== 'mouse' && Math.abs(velocity) > SHEET_FLING_VELOCITY && Math.sign(velocity) === Math.sign(moved);
|
|
520
|
+
const toward = this.rtl ? Math.sign(moved) : -Math.sign(moved);
|
|
521
|
+
if (!cancelled && (far || flung) && this.go(this.shown + toward))
|
|
522
|
+
return;
|
|
523
|
+
this.settle();
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
if (gesture.kind === 'close') {
|
|
527
|
+
const moved = Math.max(0, at.y - gesture.y);
|
|
528
|
+
const velocity = cancelled ? 0 : this.speed(gesture.samples, event.timeStamp);
|
|
529
|
+
if (!cancelled && (moved > this.stage.h / 4 || velocity > SHEET_FLING_VELOCITY)) {
|
|
530
|
+
// IMP-22: ask, hold the image where it was left for one frame, then close from there (the product closed it:
|
|
531
|
+
// the exit motion starts from there) or bring everything back (it declined).
|
|
532
|
+
this.requestClose('swipe');
|
|
533
|
+
requestAnimationFrame(() => {
|
|
534
|
+
if (this.open && this.presented)
|
|
535
|
+
this.comeBack();
|
|
536
|
+
});
|
|
537
|
+
return;
|
|
538
|
+
}
|
|
539
|
+
this.comeBack();
|
|
540
|
+
}
|
|
541
|
+
};
|
|
542
|
+
/** IMP-15, IMP-16: a wheel with Ctrl or Command — and a trackpad pinch, which arrives as one — zooms about the pointer; without, it moves an enlarged image; at fit it does nothing. */
|
|
543
|
+
this.onWheel = (event) => {
|
|
544
|
+
if (!this.presented)
|
|
545
|
+
return;
|
|
546
|
+
const unit = event.deltaMode === 1 ? WHEEL_LINE : event.deltaMode === 2 ? this.fit.h : 1;
|
|
547
|
+
if (event.ctrlKey || event.metaKey) {
|
|
548
|
+
// The browser's own zoom of the page does not take it.
|
|
549
|
+
event.preventDefault();
|
|
550
|
+
if (!this.ready)
|
|
551
|
+
return;
|
|
552
|
+
this.still();
|
|
553
|
+
const at = this.point(event);
|
|
554
|
+
this.view = this.zoomedAbout(this.view, this.view.z * Math.exp(-event.deltaY * unit * WHEEL_ZOOM), at.x - (this.fit.x + this.fit.w / 2), at.y - (this.fit.y + this.fit.h / 2));
|
|
555
|
+
this.place();
|
|
556
|
+
this.wheelEnds();
|
|
557
|
+
return;
|
|
558
|
+
}
|
|
559
|
+
if (this.view.z <= 1 + EPSILON)
|
|
560
|
+
return;
|
|
561
|
+
event.preventDefault();
|
|
562
|
+
this.still();
|
|
563
|
+
// Up and down, and sideways with a sideways wheel or Shift.
|
|
564
|
+
const dx = (event.shiftKey && !event.deltaX ? event.deltaY : event.deltaX) * unit;
|
|
565
|
+
const dy = (event.shiftKey && !event.deltaX ? 0 : event.deltaY) * unit;
|
|
566
|
+
this.view = this.held({ z: this.view.z, x: this.view.x - dx, y: this.view.y - dy });
|
|
567
|
+
this.place();
|
|
568
|
+
};
|
|
569
|
+
/** IMP-15: a trackpad pinch where the browser tells it as a gesture of its own (its `scale` from 1), not as a wheel. */
|
|
570
|
+
this.onGesture = (event) => {
|
|
571
|
+
const told = event;
|
|
572
|
+
// Two fingers on a touch screen are followed as pointers.
|
|
573
|
+
if (this.touches.size > 0 || !this.presented)
|
|
574
|
+
return;
|
|
575
|
+
event.preventDefault();
|
|
576
|
+
if (event.type === 'gesturestart') {
|
|
577
|
+
this.still();
|
|
578
|
+
this.gestureView = { ...this.view };
|
|
579
|
+
return;
|
|
580
|
+
}
|
|
581
|
+
const from = this.gestureView;
|
|
582
|
+
if (!from)
|
|
583
|
+
return;
|
|
584
|
+
if (event.type === 'gesturechange' && this.ready && positive(told.scale ?? null)) {
|
|
585
|
+
const at = this.point({ clientX: told.clientX ?? 0, clientY: told.clientY ?? 0 });
|
|
586
|
+
this.view = this.zoomedAbout(from, from.z * told.scale, at.x - (this.fit.x + this.fit.w / 2), at.y - (this.fit.y + this.fit.h / 2));
|
|
587
|
+
this.place();
|
|
588
|
+
}
|
|
589
|
+
if (event.type === 'gestureend') {
|
|
590
|
+
this.gestureView = null;
|
|
591
|
+
this.commitZoom();
|
|
592
|
+
}
|
|
593
|
+
};
|
|
594
|
+
/** IMP-12: the product set `zoom`, and the image shown has not taken it yet (it has not loaded, or is not presented). */
|
|
595
|
+
this.zoomGiven = false;
|
|
596
|
+
}
|
|
597
|
+
static { this.styles = [styles, hiddenHost]; }
|
|
598
|
+
/** @internal */
|
|
599
|
+
static { this.parts = ['container', 'bar', 'count', 'stage', 'image', 'placeholder', 'error', 'caption', ...CONTROLS, ...CONTROLS.flatMap((control) => BUTTON_PARTS[control].names)]; }
|
|
600
|
+
static { this.properties = {
|
|
601
|
+
open: { type: Boolean, reflect: true },
|
|
602
|
+
index: { type: Number },
|
|
603
|
+
zoom: { type: Number },
|
|
604
|
+
maxZoom: { converter: numberOrNull, attribute: 'max-zoom' },
|
|
605
|
+
controlsHidden: { type: Boolean, attribute: 'controls-hidden', reflect: true },
|
|
606
|
+
label: { type: String },
|
|
607
|
+
closeLabel: { type: String, attribute: 'close-label' },
|
|
608
|
+
previousLabel: { type: String, attribute: 'previous-label' },
|
|
609
|
+
nextLabel: { type: String, attribute: 'next-label' },
|
|
610
|
+
zoomInLabel: { type: String, attribute: 'zoom-in-label' },
|
|
611
|
+
zoomOutLabel: { type: String, attribute: 'zoom-out-label' },
|
|
612
|
+
countText: { type: String, attribute: 'count-text' },
|
|
613
|
+
loadingLabel: { type: String, attribute: 'loading-label' },
|
|
614
|
+
errorText: { type: String, attribute: 'error-text' },
|
|
615
|
+
images: { state: true },
|
|
616
|
+
shown: { state: true },
|
|
617
|
+
drawn: { state: true },
|
|
618
|
+
captionScrolls: { state: true },
|
|
619
|
+
}; }
|
|
620
|
+
get dialog() {
|
|
621
|
+
return this.renderRoot?.querySelector('dialog') ?? null;
|
|
622
|
+
}
|
|
623
|
+
get stageElement() {
|
|
624
|
+
return this.renderRoot?.querySelector('.stage') ?? null;
|
|
625
|
+
}
|
|
626
|
+
get pagesElement() {
|
|
627
|
+
return this.renderRoot?.querySelector('.pages') ?? null;
|
|
628
|
+
}
|
|
629
|
+
get reduced() {
|
|
630
|
+
return typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
631
|
+
}
|
|
632
|
+
get rtl() {
|
|
633
|
+
return this.matches(':dir(rtl)');
|
|
634
|
+
}
|
|
635
|
+
connectedCallback() {
|
|
636
|
+
super.connectedCallback();
|
|
637
|
+
this.children$.observe(this, { childList: true, subtree: true, attributes: true, attributeFilter: ['src', 'alt', 'caption', 'thumbnail-src', 'width', 'height'] });
|
|
638
|
+
this.readImages();
|
|
639
|
+
if (this.hasUpdated && this.open)
|
|
640
|
+
this.present();
|
|
641
|
+
}
|
|
642
|
+
disconnectedCallback() {
|
|
643
|
+
super.disconnectedCallback();
|
|
644
|
+
this.children$.disconnect();
|
|
645
|
+
this.resize$?.disconnect();
|
|
646
|
+
if (this.presented)
|
|
647
|
+
this.withdraw(false);
|
|
648
|
+
}
|
|
649
|
+
// ---- The images (IMP-20, IMP-32, IMP-43) ----
|
|
650
|
+
/** The images, read from its children in order. */
|
|
651
|
+
readImages() {
|
|
652
|
+
const read = [...this.children]
|
|
653
|
+
.filter((child) => child.localName === ITEM_TAG)
|
|
654
|
+
.map((element) => {
|
|
655
|
+
const number = (name) => {
|
|
656
|
+
const written = element.getAttribute(name);
|
|
657
|
+
const value = written === null || written.trim() === '' ? null : Number(written);
|
|
658
|
+
return positive(value) ? value : null;
|
|
659
|
+
};
|
|
660
|
+
return {
|
|
661
|
+
element,
|
|
662
|
+
src: element.getAttribute('src') ?? '',
|
|
663
|
+
alt: element.getAttribute('alt') ?? '',
|
|
664
|
+
caption: element.getAttribute('caption') ?? '',
|
|
665
|
+
thumbnailSrc: element.getAttribute('thumbnail-src') ?? '',
|
|
666
|
+
width: number('width'),
|
|
667
|
+
height: number('height'),
|
|
668
|
+
};
|
|
669
|
+
});
|
|
670
|
+
const same = read.length === this.images.length &&
|
|
671
|
+
read.every((image, at) => {
|
|
672
|
+
const was = this.images[at];
|
|
673
|
+
return image.element === was.element && image.src === was.src && image.alt === was.alt && image.caption === was.caption && image.thumbnailSrc === was.thumbnailSrc && image.width === was.width && image.height === was.height;
|
|
674
|
+
});
|
|
675
|
+
if (!same)
|
|
676
|
+
this.images = read;
|
|
677
|
+
}
|
|
678
|
+
/** IMP-20: `index` within the images: the nearest that exists. */
|
|
679
|
+
within(index) {
|
|
680
|
+
const last = this.images.length - 1;
|
|
681
|
+
if (last < 0)
|
|
682
|
+
return 0;
|
|
683
|
+
const whole = Number.isFinite(index) ? Math.round(index) : 0;
|
|
684
|
+
return Math.min(last, Math.max(0, whole));
|
|
685
|
+
}
|
|
686
|
+
/** IMP-32: the picture of each of the three images, asked for as its `src` says now; every other is let go. */
|
|
687
|
+
syncPictures() {
|
|
688
|
+
// Closed, it asks for nothing: what it drew stays as it was while it fades (IMP-33), and is let go after.
|
|
689
|
+
if (!this.open)
|
|
690
|
+
return;
|
|
691
|
+
const three = [this.shown - 1, this.shown, this.shown + 1].filter((at) => at >= 0 && at < this.images.length);
|
|
692
|
+
const kept = new Set();
|
|
693
|
+
for (const at of three) {
|
|
694
|
+
const image = this.images[at];
|
|
695
|
+
kept.add(image.element);
|
|
696
|
+
const declared = positive(image.width) && positive(image.height) ? { w: image.width, h: image.height } : null;
|
|
697
|
+
let picture = this.pictures.get(image.element);
|
|
698
|
+
if (!picture) {
|
|
699
|
+
picture = { asked: '', drawn: '', refused: '', own: declared ?? this.sizes.get(image.element) ?? null, thumbnail: '', thumbnailSize: null, thumbnailFailed: false };
|
|
700
|
+
this.pictures.set(image.element, picture);
|
|
701
|
+
}
|
|
702
|
+
if (declared)
|
|
703
|
+
picture.own = declared;
|
|
704
|
+
// IMP-30, IMP-31: another source is asked for; the earlier picture stays drawn until it has loaded.
|
|
705
|
+
picture.asked = image.src;
|
|
706
|
+
if (picture.thumbnail !== image.thumbnailSrc) {
|
|
707
|
+
picture.thumbnail = image.thumbnailSrc;
|
|
708
|
+
picture.thumbnailSize = null;
|
|
709
|
+
picture.thumbnailFailed = false;
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
for (const element of [...this.pictures.keys()])
|
|
713
|
+
if (!kept.has(element))
|
|
714
|
+
this.pictures.delete(element);
|
|
715
|
+
}
|
|
716
|
+
pictureAt(at) {
|
|
717
|
+
const image = this.images[at];
|
|
718
|
+
return image ? (this.pictures.get(image.element) ?? null) : null;
|
|
719
|
+
}
|
|
720
|
+
/** IMP-13, IMP-29, IMP-31: whether the image shown can be enlarged: it has loaded. */
|
|
721
|
+
get ready() {
|
|
722
|
+
const picture = this.pictureAt(this.shown);
|
|
723
|
+
return !!picture && !!picture.drawn;
|
|
724
|
+
}
|
|
725
|
+
// ---- The geometry (IMP-11, IMP-12, IMP-17, IMP-40) ----
|
|
726
|
+
/** IMP-11: the size an image has at fit: the largest at which the whole of it lies in the fit area, never above its own. */
|
|
727
|
+
fitSize(size, own) {
|
|
728
|
+
if (!size)
|
|
729
|
+
return { w: this.fit.w, h: this.fit.h };
|
|
730
|
+
const scale = Math.min(this.fit.w / size.w, this.fit.h / size.h, own ? 1 : Number.POSITIVE_INFINITY);
|
|
731
|
+
return { w: Math.max(0, size.w * scale), h: Math.max(0, size.h * scale) };
|
|
732
|
+
}
|
|
733
|
+
/** The size the image at `at` has at fit: from its own size, else its thumbnail's proportions, else the fit area (IMP-29). */
|
|
734
|
+
baseAt(at) {
|
|
735
|
+
const picture = this.pictureAt(at);
|
|
736
|
+
if (picture?.own)
|
|
737
|
+
return this.fitSize(picture.own, true);
|
|
738
|
+
if (picture?.thumbnailSize)
|
|
739
|
+
return this.fitSize(picture.thumbnailSize, false);
|
|
740
|
+
return this.fitSize(null, false);
|
|
741
|
+
}
|
|
742
|
+
/** IMP-12: the greatest zoom of the image shown and its steps. */
|
|
743
|
+
limits() {
|
|
744
|
+
const base = this.baseAt(this.shown);
|
|
745
|
+
if (!this.ready || base.w <= 0 || base.h <= 0)
|
|
746
|
+
return { max: 1, steps: [1] };
|
|
747
|
+
const fill = Math.max(this.fit.w / base.w, this.fit.h / base.h, 1);
|
|
748
|
+
const given = positive(this.maxZoom) && this.maxZoom >= 1 ? this.maxZoom : null;
|
|
749
|
+
const max = given ?? Math.max(4, 2 * fill);
|
|
750
|
+
const steps = [1];
|
|
751
|
+
for (let step = Math.max(2, fill); step < max - EPSILON; step *= 2)
|
|
752
|
+
steps.push(step);
|
|
753
|
+
if (max > 1 + EPSILON)
|
|
754
|
+
steps.push(max);
|
|
755
|
+
return { max, steps };
|
|
756
|
+
}
|
|
757
|
+
/** IMP-17: `view` within its limits: each edge of the image can reach the matching edge of the fit area and no farther; centred along an axis it does not fill. */
|
|
758
|
+
held(view) {
|
|
759
|
+
const base = this.baseAt(this.shown);
|
|
760
|
+
const { max } = this.limits();
|
|
761
|
+
const z = Math.min(max, Math.max(1, view.z));
|
|
762
|
+
const reachX = Math.max(0, (base.w * z - this.fit.w) / 2);
|
|
763
|
+
const reachY = Math.max(0, (base.h * z - this.fit.h) / 2);
|
|
764
|
+
return { z, x: Math.min(reachX, Math.max(-reachX, view.x)), y: Math.min(reachY, Math.max(-reachY, view.y)) };
|
|
765
|
+
}
|
|
766
|
+
/** How far the image shown can be moved from the centre, each way, at its zoom. */
|
|
767
|
+
reach() {
|
|
768
|
+
const base = this.baseAt(this.shown);
|
|
769
|
+
return { x: Math.max(0, (base.w * this.view.z - this.fit.w) / 2), y: Math.max(0, (base.h * this.view.z - this.fit.h) / 2) };
|
|
770
|
+
}
|
|
771
|
+
/** `view` at the zoom `z`, with the point of the image at (`ax`, `ay`) from the centre of the fit area kept there (IMP-13 to IMP-15), within the limits (IMP-17). */
|
|
772
|
+
zoomedAbout(view, z, ax, ay) {
|
|
773
|
+
const { max } = this.limits();
|
|
774
|
+
const to = Math.min(max, Math.max(1, z));
|
|
775
|
+
const ratio = to / view.z;
|
|
776
|
+
return this.held({ z: to, x: ax - (ax - view.x) * ratio, y: ay - (ay - view.y) * ratio });
|
|
777
|
+
}
|
|
778
|
+
/** IMP-11, IMP-40: the stage and the fit area, measured; true when either changed. */
|
|
779
|
+
measure() {
|
|
780
|
+
const dialog = this.dialog;
|
|
781
|
+
const area = this.renderRoot?.querySelector('.fit');
|
|
782
|
+
if (!dialog || !area)
|
|
783
|
+
return false;
|
|
784
|
+
const outer = dialog.getBoundingClientRect();
|
|
785
|
+
const inner = area.getBoundingClientRect();
|
|
786
|
+
const stage = { w: outer.width, h: outer.height };
|
|
787
|
+
const fit = { x: inner.left - outer.left, y: inner.top - outer.top, w: inner.width, h: inner.height };
|
|
788
|
+
const changed = stage.w !== this.stage.w || stage.h !== this.stage.h || fit.x !== this.fit.x || fit.y !== this.fit.y || fit.w !== this.fit.w || fit.h !== this.fit.h;
|
|
789
|
+
// IMP-40: the point of the image at the middle of the fit area stays there: its distance from the image's centre
|
|
790
|
+
// grows as the image does.
|
|
791
|
+
if (changed && this.view.z > 1 && this.fit.w > 0) {
|
|
792
|
+
const before = this.baseAt(this.shown);
|
|
793
|
+
this.stage = stage;
|
|
794
|
+
this.fit = fit;
|
|
795
|
+
const after = this.baseAt(this.shown);
|
|
796
|
+
const ratio = before.w > 0 ? after.w / before.w : 1;
|
|
797
|
+
this.view = this.held({ z: this.view.z, x: this.view.x * ratio, y: this.view.y * ratio });
|
|
798
|
+
}
|
|
799
|
+
else {
|
|
800
|
+
this.stage = stage;
|
|
801
|
+
this.fit = fit;
|
|
802
|
+
this.view = this.held(this.view);
|
|
803
|
+
}
|
|
804
|
+
if (changed) {
|
|
805
|
+
// IMP-33: the image grows about the centre of the fit area.
|
|
806
|
+
dialog.style.setProperty('--_fit-x', `${fit.x + fit.w / 2}px`);
|
|
807
|
+
dialog.style.setProperty('--_fit-y', `${fit.y + fit.h / 2}px`);
|
|
808
|
+
}
|
|
809
|
+
const caption = this.renderRoot.querySelector('.caption');
|
|
810
|
+
const scrolls = !!caption && caption.scrollHeight > caption.clientHeight + 0.5;
|
|
811
|
+
if (scrolls !== this.captionScrolls)
|
|
812
|
+
this.captionScrolls = scrolls;
|
|
813
|
+
return changed;
|
|
814
|
+
}
|
|
815
|
+
onResize() {
|
|
816
|
+
if (!this.presented)
|
|
817
|
+
return;
|
|
818
|
+
// IMP-40: without a motion.
|
|
819
|
+
this.still();
|
|
820
|
+
this.measure();
|
|
821
|
+
this.place();
|
|
822
|
+
}
|
|
823
|
+
/** Where everything on the pages is drawn: each image at its fit, the one shown at its zoom and place. */
|
|
824
|
+
place() {
|
|
825
|
+
const root = this.renderRoot;
|
|
826
|
+
if (!root)
|
|
827
|
+
return;
|
|
828
|
+
const centre = { x: this.fit.x + this.fit.w / 2, y: this.fit.y + this.fit.h / 2 };
|
|
829
|
+
for (const page of root.querySelectorAll('.page')) {
|
|
830
|
+
const at = Number(page.dataset.at);
|
|
831
|
+
const base = this.baseAt(at);
|
|
832
|
+
const view = at === this.shown ? this.view : { z: 1, x: 0, y: 0 };
|
|
833
|
+
const left = centre.x - base.w / 2;
|
|
834
|
+
const top = centre.y - base.h / 2;
|
|
835
|
+
for (const element of page.querySelectorAll('.image, .thumbnail')) {
|
|
836
|
+
element.style.width = `${base.w}px`;
|
|
837
|
+
element.style.height = `${base.h}px`;
|
|
838
|
+
element.style.transform = `translate(${centre.x + view.x - (base.w * view.z) / 2}px, ${centre.y + view.y - (base.h * view.z) / 2}px) scale(${view.z})`;
|
|
839
|
+
}
|
|
840
|
+
const waiting = page.querySelector('.waiting');
|
|
841
|
+
if (waiting) {
|
|
842
|
+
waiting.style.width = `${base.w}px`;
|
|
843
|
+
waiting.style.height = `${base.h}px`;
|
|
844
|
+
waiting.style.transform = `translate(${left}px, ${top}px)`;
|
|
845
|
+
}
|
|
846
|
+
const error = page.querySelector('.error');
|
|
847
|
+
if (error) {
|
|
848
|
+
error.style.width = `${this.fit.w}px`;
|
|
849
|
+
error.style.height = `${this.fit.h}px`;
|
|
850
|
+
error.style.transform = `translate(${this.fit.x}px, ${this.fit.y}px)`;
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
get shownImage() {
|
|
855
|
+
return this.renderRoot?.querySelector(`.page[data-at="${this.shown}"] .image`) ?? null;
|
|
856
|
+
}
|
|
857
|
+
/**
|
|
858
|
+
* Ends a motion of the image shown where it is drawn now (a step of the zoom that a pinch or a drag interrupts): the
|
|
859
|
+
* view becomes what is drawn, so the person's gesture goes on from what they see.
|
|
860
|
+
*/
|
|
861
|
+
still() {
|
|
862
|
+
cancelAnimationFrame(this.flingFrame);
|
|
863
|
+
this.flingFrame = 0;
|
|
864
|
+
const image = this.shownImage;
|
|
865
|
+
if (!image?.classList.contains('stepping'))
|
|
866
|
+
return;
|
|
867
|
+
const drawn = new DOMMatrixReadOnly(getComputedStyle(image).transform);
|
|
868
|
+
image.classList.remove('stepping');
|
|
869
|
+
const base = this.baseAt(this.shown);
|
|
870
|
+
const z = drawn.a || 1;
|
|
871
|
+
const centre = { x: this.fit.x + this.fit.w / 2, y: this.fit.y + this.fit.h / 2 };
|
|
872
|
+
this.view = { z, x: drawn.e + (base.w * z) / 2 - centre.x, y: drawn.f + (base.h * z) / 2 - centre.y };
|
|
873
|
+
this.place();
|
|
874
|
+
}
|
|
875
|
+
/** IMP-13, IMP-14: the image shown moves to `view` over the zoom motion — at once where motion is reduced (IMP-34). */
|
|
876
|
+
stepTo(view) {
|
|
877
|
+
this.still();
|
|
878
|
+
const image = this.shownImage;
|
|
879
|
+
const moves = !this.reduced && !!image && (view.z !== this.view.z || view.x !== this.view.x || view.y !== this.view.y);
|
|
880
|
+
this.view = view;
|
|
881
|
+
if (image && moves)
|
|
882
|
+
image.classList.add('stepping');
|
|
883
|
+
this.place();
|
|
884
|
+
}
|
|
885
|
+
// ---- The zoom (IMP-12 to IMP-15, IMP-21) ----
|
|
886
|
+
/** IMP-21: the zoom the person's change ended at becomes `zoom`, and `zoomchange` is fired once for it. */
|
|
887
|
+
commitZoom() {
|
|
888
|
+
const zoom = this.view.z;
|
|
889
|
+
if (Math.abs(zoom - this.zoom) < EPSILON) {
|
|
890
|
+
this.drawn++;
|
|
891
|
+
return;
|
|
892
|
+
}
|
|
893
|
+
this.zoom = zoom;
|
|
894
|
+
this.emit('zoomchange', { zoom });
|
|
895
|
+
}
|
|
896
|
+
/** IMP-13: one step up or down, or to fit, about the centre of the fit area. */
|
|
897
|
+
stepZoom(direction) {
|
|
898
|
+
if (!this.ready)
|
|
899
|
+
return;
|
|
900
|
+
const { steps } = this.limits();
|
|
901
|
+
const z = this.view.z;
|
|
902
|
+
const to = direction === 0 ? 1 : direction > 0 ? (steps.find((step) => step > z + EPSILON) ?? z) : ([...steps].reverse().find((step) => step < z - EPSILON) ?? z);
|
|
903
|
+
if (Math.abs(to - z) < EPSILON)
|
|
904
|
+
return;
|
|
905
|
+
this.stepTo(this.zoomedAbout(this.view, to, 0, 0));
|
|
906
|
+
this.commitZoom();
|
|
907
|
+
}
|
|
908
|
+
/** IMP-14: fit to the first step with the point under the tap kept there, and any other zoom to fit. */
|
|
909
|
+
doubleTap(x, y) {
|
|
910
|
+
if (!this.ready)
|
|
911
|
+
return;
|
|
912
|
+
const { steps } = this.limits();
|
|
913
|
+
if (steps.length < 2)
|
|
914
|
+
return;
|
|
915
|
+
const to = this.view.z > 1 + EPSILON ? 1 : steps[1];
|
|
916
|
+
this.stepTo(this.zoomedAbout(this.view, to, x - (this.fit.x + this.fit.w / 2), y - (this.fit.y + this.fit.h / 2)));
|
|
917
|
+
this.commitZoom();
|
|
918
|
+
}
|
|
919
|
+
// ---- Moving between images (IMP-18 to IMP-20) ----
|
|
920
|
+
/** IMP-20: the person moved to the image at `to`: it slides in as the one shown slides out; `index`, then `indexchange`. */
|
|
921
|
+
go(to) {
|
|
922
|
+
const index = this.within(to);
|
|
923
|
+
if (index === this.shown || !this.images.length)
|
|
924
|
+
return false;
|
|
925
|
+
this.settle();
|
|
926
|
+
this.index = index;
|
|
927
|
+
const zoomed = this.show(index);
|
|
928
|
+
this.emit('indexchange', { index });
|
|
929
|
+
if (zoomed)
|
|
930
|
+
this.emit('zoomchange', { zoom: 1 });
|
|
931
|
+
return true;
|
|
932
|
+
}
|
|
933
|
+
/**
|
|
934
|
+
* IMP-20: the image shown is the one at `index`: the zoom returns to 1 and the image left to its fit, and the new one
|
|
935
|
+
* is said (IMP-28). True where the zoom was not 1: the caller fires `zoomchange`, after `zoom` is written.
|
|
936
|
+
*/
|
|
937
|
+
show(index) {
|
|
938
|
+
const left = this.shownImage;
|
|
939
|
+
const zoomed = this.view.z > 1 + EPSILON || this.zoom !== 1;
|
|
940
|
+
this.still();
|
|
941
|
+
// The image left returns to its fit as it leaves, over the zoom motion.
|
|
942
|
+
if (left && zoomed && !this.reduced && this.pagesElement?.classList.contains('settling'))
|
|
943
|
+
left.classList.add('stepping');
|
|
944
|
+
this.shown = index;
|
|
945
|
+
this.view = { z: 1, x: 0, y: 0 };
|
|
946
|
+
if (zoomed)
|
|
947
|
+
this.zoom = 1;
|
|
948
|
+
this.zoomGiven = false;
|
|
949
|
+
this.announce = true;
|
|
950
|
+
return zoomed;
|
|
951
|
+
}
|
|
952
|
+
/** The pages move to where they rest over the page motion (IMP-18, IMP-20) — at once where motion is reduced. */
|
|
953
|
+
settle() {
|
|
954
|
+
const pages = this.pagesElement;
|
|
955
|
+
if (!pages)
|
|
956
|
+
return;
|
|
957
|
+
pages.classList.toggle('settling', !this.reduced);
|
|
958
|
+
pages.style.removeProperty('--_drag-x');
|
|
959
|
+
pages.style.removeProperty('--_drag-y');
|
|
960
|
+
}
|
|
961
|
+
// ---- The controls (IMP-21, IMP-24, IMP-25) ----
|
|
962
|
+
/** IMP-21: the person hid or showed the controls. */
|
|
963
|
+
hideControls(hidden) {
|
|
964
|
+
if (this.controlsHidden === hidden)
|
|
965
|
+
return;
|
|
966
|
+
this.controlsHidden = hidden;
|
|
967
|
+
this.emit('controlshiddenchange', { hidden });
|
|
968
|
+
}
|
|
969
|
+
/** Its events bubble and leave the shadow root (the names are the class's `@fires` lines). */
|
|
970
|
+
emit(name, detail) {
|
|
971
|
+
fire(this, name, detail);
|
|
972
|
+
}
|
|
973
|
+
/** IMP-5: `close` with the reason, once for each asking, while it is presented. */
|
|
974
|
+
requestClose(reason) {
|
|
975
|
+
if (!this.open || !this.presented)
|
|
976
|
+
return;
|
|
977
|
+
this.emit('close', { reason });
|
|
978
|
+
}
|
|
979
|
+
// ---- The gestures (IMP-14 to IMP-19, IMP-22, IMP-24) ----
|
|
980
|
+
/** A point of the window, from the stage's top left corner. */
|
|
981
|
+
point(event) {
|
|
982
|
+
const box = this.dialog?.getBoundingClientRect();
|
|
983
|
+
return { x: event.clientX - (box?.left ?? 0), y: event.clientY - (box?.top ?? 0) };
|
|
984
|
+
}
|
|
985
|
+
/** IMP-15: two fingers: the zoom follows their distance about the point midway between them, and the image their move. */
|
|
986
|
+
beginPinch() {
|
|
987
|
+
const [a, b] = [...this.touches.values()];
|
|
988
|
+
this.cancelTap();
|
|
989
|
+
// A drag that a second finger joins ends where it is.
|
|
990
|
+
this.endDrag();
|
|
991
|
+
this.gesture = { kind: 'pinch', distance: Math.max(1, Math.hypot(a.x - b.x, a.y - b.y)), midX: (a.x + b.x) / 2, midY: (a.y + b.y) / 2, view: { ...this.view } };
|
|
992
|
+
}
|
|
993
|
+
/** IMP-16, IMP-18, IMP-19, IMP-22: whose a drag that has passed the slop is. */
|
|
994
|
+
begin(event, from, dx, dy) {
|
|
995
|
+
const sideways = Math.abs(dx) > Math.abs(dy);
|
|
996
|
+
const zoomed = this.view.z > 1 + EPSILON;
|
|
997
|
+
const several = this.images.length > 1;
|
|
998
|
+
const time = event.timeStamp;
|
|
999
|
+
const page = () => {
|
|
1000
|
+
const pages = this.pagesElement;
|
|
1001
|
+
// From where the pages are drawn (a settle under way included); nothing transitions while they follow.
|
|
1002
|
+
const drawn = this.drawnDrag();
|
|
1003
|
+
pages?.classList.remove('settling');
|
|
1004
|
+
return { kind: 'page', id: from.id, x: from.x, from: drawn, samples: [{ at: from.x, time }] };
|
|
1005
|
+
};
|
|
1006
|
+
if (zoomed) {
|
|
1007
|
+
// IMP-19: the image already stands at its limit on the side the drag would uncover: the drag is the pager's.
|
|
1008
|
+
const reach = this.reach();
|
|
1009
|
+
const atLimit = dx > 0 ? this.view.x >= reach.x - 0.5 : this.view.x <= -reach.x + 0.5;
|
|
1010
|
+
if (sideways && several && atLimit)
|
|
1011
|
+
return page();
|
|
1012
|
+
return { kind: 'pan', id: from.id, lastX: from.x, lastY: from.y, samples: [{ x: from.x, y: from.y, time }] };
|
|
1013
|
+
}
|
|
1014
|
+
if (sideways)
|
|
1015
|
+
return several ? page() : { kind: 'none', id: from.id };
|
|
1016
|
+
// IMP-22: downward, by touch, at fit. An upward drag, and a mouse's, close nothing.
|
|
1017
|
+
if (dy > 0 && event.pointerType === 'touch') {
|
|
1018
|
+
const dialog = this.dialog;
|
|
1019
|
+
dialog?.classList.remove('returning');
|
|
1020
|
+
dialog?.classList.add('clearing');
|
|
1021
|
+
this.pagesElement?.classList.remove('settling');
|
|
1022
|
+
return { kind: 'close', id: from.id, y: from.y, samples: [{ at: from.y, time }] };
|
|
1023
|
+
}
|
|
1024
|
+
return { kind: 'none', id: from.id };
|
|
1025
|
+
}
|
|
1026
|
+
/** How far the pages are drawn from where they rest, sideways (px). */
|
|
1027
|
+
drawnDrag() {
|
|
1028
|
+
const page = this.renderRoot?.querySelector(`.page[data-at="${this.shown}"]`);
|
|
1029
|
+
if (!page)
|
|
1030
|
+
return 0;
|
|
1031
|
+
return Number.parseFloat(getComputedStyle(page).translate) || 0;
|
|
1032
|
+
}
|
|
1033
|
+
follow(event, at) {
|
|
1034
|
+
const gesture = this.gesture;
|
|
1035
|
+
if (!gesture)
|
|
1036
|
+
return;
|
|
1037
|
+
const recent = (samples, sample) => {
|
|
1038
|
+
samples.push(sample);
|
|
1039
|
+
while (samples.length > 2 && sample.time - samples[0].time > 80)
|
|
1040
|
+
samples.shift();
|
|
1041
|
+
};
|
|
1042
|
+
if (gesture.kind === 'pan') {
|
|
1043
|
+
// IMP-16, IMP-19: the image moves with the pointer, and stops at its limit.
|
|
1044
|
+
this.view = this.held({ z: this.view.z, x: this.view.x + (at.x - gesture.lastX), y: this.view.y + (at.y - gesture.lastY) });
|
|
1045
|
+
gesture.lastX = at.x;
|
|
1046
|
+
gesture.lastY = at.y;
|
|
1047
|
+
recent(gesture.samples, { x: at.x, y: at.y, time: event.timeStamp });
|
|
1048
|
+
this.place();
|
|
1049
|
+
}
|
|
1050
|
+
else if (gesture.kind === 'page') {
|
|
1051
|
+
recent(gesture.samples, { at: at.x, time: event.timeStamp });
|
|
1052
|
+
let moved = gesture.from + (at.x - gesture.x);
|
|
1053
|
+
// IMP-18: where there is no neighbour on that side, it follows by a part only.
|
|
1054
|
+
const toward = this.rtl ? Math.sign(moved) : -Math.sign(moved);
|
|
1055
|
+
const neighbour = this.shown + toward;
|
|
1056
|
+
if (neighbour < 0 || neighbour >= this.images.length)
|
|
1057
|
+
moved *= OVERSCROLL;
|
|
1058
|
+
this.pagesElement?.style.setProperty('--_drag-x', `${moved}px`);
|
|
1059
|
+
}
|
|
1060
|
+
else if (gesture.kind === 'close') {
|
|
1061
|
+
recent(gesture.samples, { at: at.y, time: event.timeStamp });
|
|
1062
|
+
const moved = Math.max(0, at.y - gesture.y);
|
|
1063
|
+
this.pagesElement?.style.setProperty('--_drag-y', `${moved}px`);
|
|
1064
|
+
this.dialog?.style.setProperty('--_presence', `${Math.max(0, 1 - moved / Math.max(1, this.stage.h))}`);
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
/** The speed of a release along what `samples` hold, px per ms; 0 when the pointer had stopped. */
|
|
1068
|
+
speed(samples, now) {
|
|
1069
|
+
const recent = samples.filter((sample) => now - sample.time <= 80);
|
|
1070
|
+
if (recent.length < 2)
|
|
1071
|
+
return 0;
|
|
1072
|
+
const time = recent[recent.length - 1].time - recent[0].time;
|
|
1073
|
+
return time > 0 ? (recent[recent.length - 1].at - recent[0].at) / time : 0;
|
|
1074
|
+
}
|
|
1075
|
+
/** A drag that is taken over (a second finger) ends where it rests. */
|
|
1076
|
+
endDrag() {
|
|
1077
|
+
const gesture = this.gesture;
|
|
1078
|
+
if (gesture?.kind === 'page')
|
|
1079
|
+
this.settle();
|
|
1080
|
+
if (gesture?.kind === 'close')
|
|
1081
|
+
this.comeBack();
|
|
1082
|
+
}
|
|
1083
|
+
/** IMP-22: everything back to where it rests, over the page motion. */
|
|
1084
|
+
comeBack() {
|
|
1085
|
+
const dialog = this.dialog;
|
|
1086
|
+
if (!dialog)
|
|
1087
|
+
return;
|
|
1088
|
+
dialog.classList.remove('clearing');
|
|
1089
|
+
dialog.classList.toggle('returning', !this.reduced);
|
|
1090
|
+
dialog.style.removeProperty('--_presence');
|
|
1091
|
+
this.settle();
|
|
1092
|
+
}
|
|
1093
|
+
/** IMP-16: the image goes on as it was flung (`vx`, `vy`, px per ms) and slows, to its limit at most. */
|
|
1094
|
+
fling(vx, vy) {
|
|
1095
|
+
let last = performance.now();
|
|
1096
|
+
const step = (now) => {
|
|
1097
|
+
// (A frame's time may be the time the fling began, or a little before it.)
|
|
1098
|
+
const elapsed = Math.min(64, Math.max(0, now - last));
|
|
1099
|
+
last = now;
|
|
1100
|
+
const wanted = { z: this.view.z, x: this.view.x + vx * elapsed, y: this.view.y + vy * elapsed };
|
|
1101
|
+
const next = this.held(wanted);
|
|
1102
|
+
// Stopped at a limit along an axis, it does not go on along it.
|
|
1103
|
+
if (next.x !== wanted.x)
|
|
1104
|
+
vx = 0;
|
|
1105
|
+
if (next.y !== wanted.y)
|
|
1106
|
+
vy = 0;
|
|
1107
|
+
this.view = next;
|
|
1108
|
+
this.place();
|
|
1109
|
+
const slow = Math.exp(-elapsed / FLING_TIME);
|
|
1110
|
+
vx *= slow;
|
|
1111
|
+
vy *= slow;
|
|
1112
|
+
this.flingFrame = Math.hypot(vx, vy) > FLING_REST ? requestAnimationFrame(step) : 0;
|
|
1113
|
+
};
|
|
1114
|
+
if (Math.hypot(vx, vy) > FLING_REST)
|
|
1115
|
+
this.flingFrame = requestAnimationFrame(step);
|
|
1116
|
+
}
|
|
1117
|
+
cancelTap() {
|
|
1118
|
+
if (this.lastTap)
|
|
1119
|
+
clearTimeout(this.lastTap.timer);
|
|
1120
|
+
this.lastTap = null;
|
|
1121
|
+
}
|
|
1122
|
+
/** IMP-14, IMP-24: a press without a drag: the second of two within the interval is a double tap, and one alone hides or shows the controls. */
|
|
1123
|
+
tap(x, y, time, type) {
|
|
1124
|
+
const last = this.lastTap;
|
|
1125
|
+
if (last && time - last.time <= DOUBLE_TAP && Math.hypot(x - last.x, y - last.y) <= DOUBLE_TAP_REACH) {
|
|
1126
|
+
this.cancelTap();
|
|
1127
|
+
this.doubleTap(x, y);
|
|
1128
|
+
return;
|
|
1129
|
+
}
|
|
1130
|
+
this.cancelTap();
|
|
1131
|
+
const timer = setTimeout(() => {
|
|
1132
|
+
this.lastTap = null;
|
|
1133
|
+
if (!this.presented)
|
|
1134
|
+
return;
|
|
1135
|
+
const hidden = !this.controlsHidden;
|
|
1136
|
+
// IMP-25: a mouse shows them again when it moves from here, not while it rests where it pressed.
|
|
1137
|
+
this.hiddenAt = hidden && type === 'mouse' ? { x, y } : null;
|
|
1138
|
+
this.hideControls(hidden);
|
|
1139
|
+
}, DOUBLE_TAP);
|
|
1140
|
+
this.lastTap = { x, y, time, timer };
|
|
1141
|
+
}
|
|
1142
|
+
onHover(event) {
|
|
1143
|
+
const at = this.point(event);
|
|
1144
|
+
if (this.hiddenAt && Math.hypot(at.x - this.hiddenAt.x, at.y - this.hiddenAt.y) <= SHEET_TOUCH_SLOP)
|
|
1145
|
+
return;
|
|
1146
|
+
this.hiddenAt = null;
|
|
1147
|
+
this.hideControls(false);
|
|
1148
|
+
}
|
|
1149
|
+
wheelEnds() {
|
|
1150
|
+
if (this.wheelTimer)
|
|
1151
|
+
clearTimeout(this.wheelTimer);
|
|
1152
|
+
this.wheelTimer = setTimeout(() => {
|
|
1153
|
+
this.wheelTimer = null;
|
|
1154
|
+
if (this.presented)
|
|
1155
|
+
this.commitZoom();
|
|
1156
|
+
}, WHEEL_END);
|
|
1157
|
+
}
|
|
1158
|
+
// ---- Presenting and focus (IMP-1, IMP-2, IMP-4, IMP-6, IMP-43) ----
|
|
1159
|
+
/** IMP-8, IMP-10: each control is told the variant its token names, through the channel a Button reads from the component that places it (BTN-10). */
|
|
1160
|
+
giveVariants() {
|
|
1161
|
+
const bar = compChoice(this, `${PREFIX}-bar-button-variant`, BUTTON_VARIANTS);
|
|
1162
|
+
const navigation = compChoice(this, `${PREFIX}-navigation-button-variant`, BUTTON_VARIANTS);
|
|
1163
|
+
for (const control of CONTROLS)
|
|
1164
|
+
giveVariant(this.renderRoot?.querySelector(`tanrei-button.${control}`), control === 'previous' || control === 'next' ? navigation : bar);
|
|
1165
|
+
}
|
|
1166
|
+
/** IMP-1, IMP-2: in the top layer over the whole window, the page held, focus on the stage. */
|
|
1167
|
+
present() {
|
|
1168
|
+
const dialog = this.dialog;
|
|
1169
|
+
if (!dialog || this.presented || !this.isConnected)
|
|
1170
|
+
return;
|
|
1171
|
+
if (!this.images.length) {
|
|
1172
|
+
// IMP-43: nothing to show: nothing is presented. A document that is still being read has not given its images yet.
|
|
1173
|
+
const say = () => {
|
|
1174
|
+
if (this.open && !this.presented && !this.images.length && !this.reportedEmpty) {
|
|
1175
|
+
this.reportedEmpty = true;
|
|
1176
|
+
report(this, 'IMP-43', 'it was opened with no image, so nothing is presented; give it <tanrei-image-preview-item> children before it opens', { once: false, level: 'error' });
|
|
1177
|
+
}
|
|
1178
|
+
};
|
|
1179
|
+
if (document.readyState === 'loading')
|
|
1180
|
+
document.addEventListener('DOMContentLoaded', say, { once: true });
|
|
1181
|
+
else
|
|
1182
|
+
say();
|
|
1183
|
+
return;
|
|
1184
|
+
}
|
|
1185
|
+
this.reportedEmpty = false;
|
|
1186
|
+
watchEscape();
|
|
1187
|
+
watchInput();
|
|
1188
|
+
this.opener = deepActive();
|
|
1189
|
+
// What a drag that closed it left (IMP-22) is gone when it opens again.
|
|
1190
|
+
dialog.classList.remove('clearing', 'returning');
|
|
1191
|
+
dialog.style.removeProperty('--_presence');
|
|
1192
|
+
this.pagesElement?.classList.remove('settling');
|
|
1193
|
+
this.pagesElement?.style.removeProperty('--_drag-x');
|
|
1194
|
+
this.pagesElement?.style.removeProperty('--_drag-y');
|
|
1195
|
+
if (!dialog.open)
|
|
1196
|
+
dialog.showModal();
|
|
1197
|
+
this.presented = true;
|
|
1198
|
+
modalLayer.add(this);
|
|
1199
|
+
holdPageScroll(this, true);
|
|
1200
|
+
this.giveVariants();
|
|
1201
|
+
this.measure();
|
|
1202
|
+
this.place();
|
|
1203
|
+
this.resize$?.observe(dialog);
|
|
1204
|
+
const area = this.renderRoot.querySelector('.fit');
|
|
1205
|
+
if (area)
|
|
1206
|
+
this.resize$?.observe(area);
|
|
1207
|
+
// IMP-2: focus moves when it opens, not when its motion ends.
|
|
1208
|
+
const stage = this.stageElement;
|
|
1209
|
+
if (stage)
|
|
1210
|
+
focusOverlay(this, stage);
|
|
1211
|
+
}
|
|
1212
|
+
/** IMP-4: out of the top layer (fading), the page given back, focus back where it was. */
|
|
1213
|
+
withdraw(restore) {
|
|
1214
|
+
if (!this.presented)
|
|
1215
|
+
return;
|
|
1216
|
+
this.presented = false;
|
|
1217
|
+
this.cancelTap();
|
|
1218
|
+
if (this.wheelTimer)
|
|
1219
|
+
clearTimeout(this.wheelTimer);
|
|
1220
|
+
this.wheelTimer = null;
|
|
1221
|
+
cancelAnimationFrame(this.flingFrame);
|
|
1222
|
+
this.flingFrame = 0;
|
|
1223
|
+
this.touches.clear();
|
|
1224
|
+
this.gesture = null;
|
|
1225
|
+
this.gestureView = null;
|
|
1226
|
+
this.resize$?.disconnect();
|
|
1227
|
+
modalLayer.delete(this);
|
|
1228
|
+
holdPageScroll(this, false);
|
|
1229
|
+
const dialog = this.dialog;
|
|
1230
|
+
if (dialog?.open)
|
|
1231
|
+
dialog.close();
|
|
1232
|
+
const opener = this.opener;
|
|
1233
|
+
this.opener = null;
|
|
1234
|
+
if (restore)
|
|
1235
|
+
returnFocus(opener, this);
|
|
1236
|
+
}
|
|
1237
|
+
/** IMP-28: what assistive technology is told, politely: each sentence a block of its own, in place of what was said. */
|
|
1238
|
+
say(sentences) {
|
|
1239
|
+
const region = this.renderRoot?.querySelector('.said');
|
|
1240
|
+
if (!region)
|
|
1241
|
+
return;
|
|
1242
|
+
region.replaceChildren(...sentences.filter(Boolean).map((sentence) => {
|
|
1243
|
+
const block = document.createElement('div');
|
|
1244
|
+
block.textContent = sentence;
|
|
1245
|
+
return block;
|
|
1246
|
+
}));
|
|
1247
|
+
}
|
|
1248
|
+
/**
|
|
1249
|
+
* IMP-9: the count's sentence with its two places filled, each number written as the preview's language writes a
|
|
1250
|
+
* whole number; empty where it is not drawn.
|
|
1251
|
+
*/
|
|
1252
|
+
countSentence(report_ = false) {
|
|
1253
|
+
if (this.images.length < 2)
|
|
1254
|
+
return '';
|
|
1255
|
+
const sentence = this.words.get('imageCountText', this.countText);
|
|
1256
|
+
if (!sentence)
|
|
1257
|
+
return '';
|
|
1258
|
+
const number = new Intl.NumberFormat(ambientLocale(this), { maximumFractionDigits: 0 });
|
|
1259
|
+
// (A word with places is read in one place: src/primitives/places.ts.) Another text between braces and a brace that
|
|
1260
|
+
// opens or closes nothing are drawn as they are written, and reported.
|
|
1261
|
+
const { runs } = fillPlaces(sentence, { position: number.format(this.shown + 1), count: number.format(this.images.length) });
|
|
1262
|
+
if (report_)
|
|
1263
|
+
reportPlaces(this, 'IMP-9', 'countText', sentence, wordPlaces.imageCountText ?? [], 'it is drawn as it is written');
|
|
1264
|
+
return runs.map((run) => run.text).join('');
|
|
1265
|
+
}
|
|
1266
|
+
// ---- The update ----
|
|
1267
|
+
willUpdate(changed) {
|
|
1268
|
+
const images = changed.has('images');
|
|
1269
|
+
// IMP-20, IMP-43: the image shown is `index`, within the images. The product set it: at once, and no `indexchange`.
|
|
1270
|
+
const was = images ? (changed.get('images')?.[this.shown]?.element ?? null) : null;
|
|
1271
|
+
const target = this.within(this.index);
|
|
1272
|
+
if (changed.has('index') && this.images.length && target !== this.index) {
|
|
1273
|
+
report(this, 'IMP-20', `index is ${this.index}, which is not one of its ${this.images.length} images; the nearest, ${target}, is shown`, { once: false });
|
|
1274
|
+
}
|
|
1275
|
+
if (target !== this.shown) {
|
|
1276
|
+
this.pagesElement?.classList.remove('settling');
|
|
1277
|
+
this.pagesElement?.style.removeProperty('--_drag-x');
|
|
1278
|
+
if (!this.presented)
|
|
1279
|
+
this.shown = target;
|
|
1280
|
+
else if (this.show(target))
|
|
1281
|
+
this.emit('zoomchange', { zoom: 1 });
|
|
1282
|
+
}
|
|
1283
|
+
else if (images && this.presented && was && this.images[this.shown]?.element !== was) {
|
|
1284
|
+
// IMP-43: the image shown is no longer the same one.
|
|
1285
|
+
if (this.show(this.shown))
|
|
1286
|
+
this.emit('zoomchange', { zoom: 1 });
|
|
1287
|
+
}
|
|
1288
|
+
if (!this.presented && (changed.has('open') || changed.has('index') || images))
|
|
1289
|
+
this.view = { z: 1, x: 0, y: 0 };
|
|
1290
|
+
this.syncPictures();
|
|
1291
|
+
// IMP-12, IMP-21: the product set the zoom (the element's own writes are what the view already is): taken at once.
|
|
1292
|
+
if ((changed.has('zoom') && Math.abs(this.zoom - this.view.z) > EPSILON) || changed.has('maxZoom')) {
|
|
1293
|
+
this.zoomGiven = true;
|
|
1294
|
+
if (positive(this.maxZoom) ? this.maxZoom < 1 : this.maxZoom !== null)
|
|
1295
|
+
report(this, 'IMP-12', `max-zoom is ${this.maxZoom}, which is less than 1; it is taken as not given`, { once: false });
|
|
1296
|
+
}
|
|
1297
|
+
this.takeZoom();
|
|
1298
|
+
// IMP-28: a control that is about to be disabled while it has focus.
|
|
1299
|
+
if (this.presented) {
|
|
1300
|
+
const active = this.shadowRoot?.activeElement;
|
|
1301
|
+
const control = CONTROLS.find((name) => active?.classList.contains(name));
|
|
1302
|
+
this.focusLeaves = !!control && this.disabledNow(control);
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
/** IMP-12: `zoom` as the product set it, once the image can take it: within 1 and the greatest value, about the centre of the fit area, at once. */
|
|
1306
|
+
takeZoom() {
|
|
1307
|
+
if (!this.zoomGiven || !this.presented || !this.ready || this.fit.w <= 0)
|
|
1308
|
+
return;
|
|
1309
|
+
this.zoomGiven = false;
|
|
1310
|
+
const { max } = this.limits();
|
|
1311
|
+
const asked = Number.isFinite(this.zoom) ? this.zoom : 1;
|
|
1312
|
+
const zoom = Math.min(max, Math.max(1, asked));
|
|
1313
|
+
if (Math.abs(zoom - asked) > EPSILON)
|
|
1314
|
+
report(this, 'IMP-12', `zoom is ${this.zoom}, which is outside 1 to ${max}; ${zoom} is used`, { once: false });
|
|
1315
|
+
if (Math.abs(zoom - this.view.z) < EPSILON)
|
|
1316
|
+
return;
|
|
1317
|
+
this.still();
|
|
1318
|
+
this.view = this.zoomedAbout(this.view, zoom, 0, 0);
|
|
1319
|
+
}
|
|
1320
|
+
/** IMP-10, IMP-13: whether a control is disabled as things are now. */
|
|
1321
|
+
disabledNow(control) {
|
|
1322
|
+
if (control === 'previous')
|
|
1323
|
+
return this.shown <= 0;
|
|
1324
|
+
if (control === 'next')
|
|
1325
|
+
return this.shown >= this.images.length - 1;
|
|
1326
|
+
if (control === 'zoom-out')
|
|
1327
|
+
return this.view.z <= 1 + EPSILON;
|
|
1328
|
+
if (control === 'zoom-in')
|
|
1329
|
+
return !this.ready || this.view.z >= this.limits().max - EPSILON;
|
|
1330
|
+
return false;
|
|
1331
|
+
}
|
|
1332
|
+
firstUpdated() {
|
|
1333
|
+
const stage = this.stageElement;
|
|
1334
|
+
// Not passive: a wheel with Ctrl or Command, and one over an enlarged image, is the preview's (IMP-15, IMP-16).
|
|
1335
|
+
// The stage has a box only while the preview is presented, so a closed preview takes no wheel of the page's.
|
|
1336
|
+
stage?.addEventListener('wheel', this.onWheel, { passive: false });
|
|
1337
|
+
for (const type of ['gesturestart', 'gesturechange', 'gestureend'])
|
|
1338
|
+
stage?.addEventListener(type, this.onGesture);
|
|
1339
|
+
this.dialog?.addEventListener('keydown', this.onKeyDownFirst, { capture: true });
|
|
1340
|
+
}
|
|
1341
|
+
updated(changed) {
|
|
1342
|
+
if (changed.has('open') || (this.open && !this.presented && changed.has('images'))) {
|
|
1343
|
+
if (this.open)
|
|
1344
|
+
this.present();
|
|
1345
|
+
else if (this.presented)
|
|
1346
|
+
this.withdraw(true);
|
|
1347
|
+
}
|
|
1348
|
+
// IMP-43: the images are gone while it is presented: there is nothing to show.
|
|
1349
|
+
if (this.presented && !this.images.length)
|
|
1350
|
+
this.withdraw(true);
|
|
1351
|
+
if (!this.presented)
|
|
1352
|
+
return;
|
|
1353
|
+
this.giveVariants();
|
|
1354
|
+
this.measure();
|
|
1355
|
+
this.takeZoom();
|
|
1356
|
+
this.place();
|
|
1357
|
+
// IMP-7, IMP-8, IMP-9, IMP-10, IMP-27, IMP-31: what a debug build reports.
|
|
1358
|
+
this.reports();
|
|
1359
|
+
// IMP-28: the new image is said — the count's sentence, then its alt — and focus stays where it is, unless the
|
|
1360
|
+
// control it is on has become disabled: then it is on the stage.
|
|
1361
|
+
if (this.announce) {
|
|
1362
|
+
this.announce = false;
|
|
1363
|
+
this.say([this.countSentence(), this.images[this.shown]?.alt ?? '']);
|
|
1364
|
+
}
|
|
1365
|
+
if (this.focusLeaves) {
|
|
1366
|
+
this.focusLeaves = false;
|
|
1367
|
+
this.stageElement?.focus({ preventScroll: true });
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
reports() {
|
|
1371
|
+
if (!this.label.trim())
|
|
1372
|
+
report(this, 'IMP-7', 'label is empty, so the modal dialog has no accessible name; give it a label');
|
|
1373
|
+
const named = (key, prop, own, id, what) => {
|
|
1374
|
+
if (!this.words.get(key, own))
|
|
1375
|
+
this.words.missing(key, { prop, id, effect: `the ${what} control is drawn and has no accessible name` });
|
|
1376
|
+
};
|
|
1377
|
+
named('closeLabel', 'closeLabel', this.closeLabel, 'IMP-8', 'close');
|
|
1378
|
+
named('zoomInLabel', 'zoomInLabel', this.zoomInLabel, 'IMP-8', 'zoom-in');
|
|
1379
|
+
named('zoomOutLabel', 'zoomOutLabel', this.zoomOutLabel, 'IMP-8', 'zoom-out');
|
|
1380
|
+
if (this.images.length > 1) {
|
|
1381
|
+
named('previousImageLabel', 'previousLabel', this.previousLabel, 'IMP-10', 'previous');
|
|
1382
|
+
named('nextImageLabel', 'nextLabel', this.nextLabel, 'IMP-10', 'next');
|
|
1383
|
+
if (!this.words.get('imageCountText', this.countText))
|
|
1384
|
+
this.words.missing('imageCountText', { prop: 'countText', id: 'IMP-9', effect: 'no count is drawn' });
|
|
1385
|
+
else
|
|
1386
|
+
this.countSentence(true);
|
|
1387
|
+
}
|
|
1388
|
+
const image = this.images[this.shown];
|
|
1389
|
+
if (image && !image.alt.trim())
|
|
1390
|
+
report(this, 'IMP-27', `the image at ${this.shown} has no alt, so the image shown has no accessible name; give every image an alt`);
|
|
1391
|
+
if (failed(this.pictureAt(this.shown)) && !this.words.get('imageErrorText', this.errorText)) {
|
|
1392
|
+
this.words.missing('imageErrorText', { prop: 'errorText', id: 'IMP-31', effect: 'the mark is drawn alone and the failure is told to no one' });
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
page(at) {
|
|
1396
|
+
const image = this.images[at];
|
|
1397
|
+
const picture = this.pictureAt(at);
|
|
1398
|
+
if (!image || !picture)
|
|
1399
|
+
return nothing;
|
|
1400
|
+
const shown = at === this.shown;
|
|
1401
|
+
const broken = failed(picture);
|
|
1402
|
+
const sources = [...new Set([picture.drawn, picture.asked === picture.refused ? '' : picture.asked].filter(Boolean))];
|
|
1403
|
+
// IMP-29: until the source has loaded, the thumbnail enlarged, or — for the image shown — a Skeleton's one block.
|
|
1404
|
+
const waiting = !picture.drawn && !broken;
|
|
1405
|
+
const thumbnail = waiting && !!picture.thumbnail && !picture.thumbnailFailed;
|
|
1406
|
+
const errorText = this.words.get('imageErrorText', this.errorText);
|
|
1407
|
+
return html `<div class="page" data-at=${at} style="--_at: ${at - this.shown}">
|
|
1408
|
+
${thumbnail
|
|
1409
|
+
? html `<img part="placeholder" class="thumbnail" alt="" draggable="false" data-at=${at} data-src=${picture.thumbnail} src=${picture.thumbnail} @load=${this.onThumbnailLoad} @error=${this.onThumbnailError} />`
|
|
1410
|
+
: nothing}
|
|
1411
|
+
${repeat(sources, (src) => src, (src) => html `<img
|
|
1412
|
+
part=${src === picture.drawn ? 'image' : nothing}
|
|
1413
|
+
class=${src === picture.drawn ? 'image' : 'asked'}
|
|
1414
|
+
alt=""
|
|
1415
|
+
draggable="false"
|
|
1416
|
+
data-at=${at}
|
|
1417
|
+
data-src=${src}
|
|
1418
|
+
src=${src}
|
|
1419
|
+
@load=${this.onLoad}
|
|
1420
|
+
@error=${this.onError}
|
|
1421
|
+
@transitionend=${this.onImageSettled}
|
|
1422
|
+
@transitioncancel=${this.onImageSettled}
|
|
1423
|
+
/>`)}
|
|
1424
|
+
${waiting && !thumbnail && shown
|
|
1425
|
+
? html `<div part="placeholder" class="waiting"><tanrei-skeleton label=${this.loadingLabel}><div class="tanrei-skeleton-placeholder" data-shape="block"></div></tanrei-skeleton></div>`
|
|
1426
|
+
: nothing}
|
|
1427
|
+
${broken
|
|
1428
|
+
? html `<div part="error" class="error">
|
|
1429
|
+
<span class="glyph" aria-hidden="true"><span class="ink">broken_image</span></span>
|
|
1430
|
+
${errorText ? html `<p class="error-text" id=${shown ? 'error' : nothing}>${errorText}</p>` : nothing}
|
|
1431
|
+
</div>`
|
|
1432
|
+
: nothing}
|
|
1433
|
+
</div>`;
|
|
1434
|
+
}
|
|
1435
|
+
control(control, glyph, label) {
|
|
1436
|
+
return html `<tanrei-button
|
|
1437
|
+
part=${control}
|
|
1438
|
+
exportparts=${BUTTON_PARTS[control].attribute}
|
|
1439
|
+
class=${control}
|
|
1440
|
+
size="medium"
|
|
1441
|
+
label=${label}
|
|
1442
|
+
?disabled=${this.disabledNow(control)}
|
|
1443
|
+
@click=${this.onControl(control)}
|
|
1444
|
+
><span slot="icon">${glyph}</span></tanrei-button
|
|
1445
|
+
>`;
|
|
1446
|
+
}
|
|
1447
|
+
render() {
|
|
1448
|
+
const several = this.images.length > 1;
|
|
1449
|
+
const image = this.images[this.shown];
|
|
1450
|
+
const count = this.countSentence();
|
|
1451
|
+
const caption = image?.caption ?? '';
|
|
1452
|
+
const broken = failed(this.pictureAt(this.shown)) && !!this.words.get('imageErrorText', this.errorText);
|
|
1453
|
+
// IMP-27: named by the alt of the image shown; described by the count's sentence first, then its caption, then
|
|
1454
|
+
// what failed (IMP-31).
|
|
1455
|
+
const described = [count ? 'count' : '', caption ? 'caption' : '', broken ? 'error' : ''].filter(Boolean).join(' ');
|
|
1456
|
+
const three = [this.shown - 1, this.shown, this.shown + 1].filter((at) => !!this.pictureAt(at));
|
|
1457
|
+
return html `<dialog
|
|
1458
|
+
part="container"
|
|
1459
|
+
class=${classMap({ container: true, 'controls-hidden': this.controlsHidden, captioned: !!caption })}
|
|
1460
|
+
aria-label=${this.label.trim() ? this.label : nothing}
|
|
1461
|
+
tabindex="-1"
|
|
1462
|
+
@keydown=${this.onKeyDown}
|
|
1463
|
+
@cancel=${this.onNativeCancel}
|
|
1464
|
+
@close=${this.onNativeClose}
|
|
1465
|
+
@focusin=${this.onFocusIn}
|
|
1466
|
+
@focusout=${this.onFocusOut}
|
|
1467
|
+
@transitionend=${this.onFaded}
|
|
1468
|
+
@pointermove=${this.onPointerMove}
|
|
1469
|
+
>
|
|
1470
|
+
<div class="surface"></div>
|
|
1471
|
+
<div class="pages" @transitionend=${this.onPagesSettled} @transitioncancel=${this.onPagesSettled}>
|
|
1472
|
+
${repeat(three, (at) => this.images[at].element, (at) => this.page(at))}
|
|
1473
|
+
</div>
|
|
1474
|
+
<div part="bar" class="bar">
|
|
1475
|
+
<p part="count" class="count" id="count">${count}</p>
|
|
1476
|
+
<div class="controls">
|
|
1477
|
+
${this.control('zoom-out', 'zoom_out', this.words.get('zoomOutLabel', this.zoomOutLabel))} ${this.control('zoom-in', 'zoom_in', this.words.get('zoomInLabel', this.zoomInLabel))}
|
|
1478
|
+
${this.control('close', 'close', this.words.get('closeLabel', this.closeLabel))}
|
|
1479
|
+
</div>
|
|
1480
|
+
</div>
|
|
1481
|
+
${several ? this.control('previous', 'chevron_left', this.words.get('previousImageLabel', this.previousLabel)) : nothing}
|
|
1482
|
+
<div
|
|
1483
|
+
part="stage"
|
|
1484
|
+
class="stage"
|
|
1485
|
+
role="img"
|
|
1486
|
+
tabindex="0"
|
|
1487
|
+
aria-label=${image?.alt.trim() ? image.alt : nothing}
|
|
1488
|
+
aria-describedby=${described || nothing}
|
|
1489
|
+
@pointerdown=${this.onPointerDown}
|
|
1490
|
+
@pointerup=${this.onPointerUp}
|
|
1491
|
+
@pointercancel=${this.onPointerUp}
|
|
1492
|
+
@blur=${this.onStageBlur}
|
|
1493
|
+
></div>
|
|
1494
|
+
${several ? this.control('next', 'chevron_right', this.words.get('nextImageLabel', this.nextLabel)) : nothing}
|
|
1495
|
+
${caption
|
|
1496
|
+
? html `<div part="caption" class="caption" role=${this.captionScrolls ? 'group' : nothing} tabindex=${this.captionScrolls ? '0' : nothing} data-tanrei-shape>
|
|
1497
|
+
<p class="caption-text" id="caption">${caption}</p>
|
|
1498
|
+
</div>
|
|
1499
|
+
<div class="caption-focus" aria-hidden="true" data-tanrei-shape></div>`
|
|
1500
|
+
: nothing}
|
|
1501
|
+
<div class="fit" aria-hidden="true" data-tanrei-shape></div>
|
|
1502
|
+
<div class="said" aria-live="polite"></div>
|
|
1503
|
+
</dialog>`;
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1506
|
+
if (!customElements.get(ITEM_TAG))
|
|
1507
|
+
customElements.define(ITEM_TAG, TanreiImagePreviewItem);
|
|
1508
|
+
if (!customElements.get('tanrei-image-preview'))
|
|
1509
|
+
customElements.define('tanrei-image-preview', TanreiImagePreview);
|
|
1510
|
+
//# sourceMappingURL=image-preview.js.map
|