@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,1098 @@
|
|
|
1
|
+
import { html, nothing, unsafeCSS } from 'lit';
|
|
2
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
3
|
+
import { styleMap } from 'lit/directives/style-map.js';
|
|
4
|
+
import { iconGlyph } from '../styles/icons.js';
|
|
5
|
+
import { productText } from '../styles/product-text.js';
|
|
6
|
+
import { cornerRadius } from '../styles/shape.js';
|
|
7
|
+
import { AnchoredSurfaceController, anchoredSurfaceStyles } from './anchored.js';
|
|
8
|
+
import { focusRing, syncFocusStyle } from './focus-ring.js';
|
|
9
|
+
import { itemRowStyles, rowTarget } from './item-row.js';
|
|
10
|
+
import { PressController, pressHold } from './press.js';
|
|
11
|
+
import { RovingKeys } from './roving.js';
|
|
12
|
+
import { SELECTION_STATES } from './selection.js';
|
|
13
|
+
import { separationHost, syncSeparation, whenGap } from './separation.js';
|
|
14
|
+
// A list of options that opens from a field (a select, SEL-24 … SEL-45; a combobox, which shares the field, the list
|
|
15
|
+
// and the options and adds a text input). Three things are shared, and each is here once:
|
|
16
|
+
//
|
|
17
|
+
// the options `<tanrei-option>` and `<tanrei-option-group>` children of the field (src/components/option/): data
|
|
18
|
+
// the field reads (`readOptions()`), and reads again when they change (`OptionsController`). They draw
|
|
19
|
+
// nothing themselves.
|
|
20
|
+
// the list the rows the field renders in its own shadow root from that data — so that the field's combobox, its
|
|
21
|
+
// `aria-controls` list box and its `aria-activedescendant` option are in one tree — on the raised sheet
|
|
22
|
+
// a menu and a popover are drawn on, placed against the field as a popover is against its anchor
|
|
23
|
+
// (`optionListStyles()`, `anchoredOptionList()`, `OptionListController.render()`).
|
|
24
|
+
// the active the one option the keys act on and assistive technology is told of, moved by the arrow keys, Home,
|
|
25
|
+
// option End, the page keys, typing and the pointer, pressed and chosen (`OptionListController`). Focus is
|
|
26
|
+
// never moved into the list: it stays on the field.
|
|
27
|
+
//
|
|
28
|
+
// The rows are drawn while the list is shown and at no other time: a field that is closed holds the placed box, the
|
|
29
|
+
// sheet and an empty list box (what `aria-controls` names), and no row — so what a closed field costs to draw, and to
|
|
30
|
+
// draw again, does not grow with the number of its options. The rows are made by the render that opens the list and
|
|
31
|
+
// taken away once it has closed and faded out (`OptionListController.drawn`). Everything a closed field needs of its
|
|
32
|
+
// options — the chosen one's label and glyph, the form's value, what a typed character finds — is read from the data.
|
|
33
|
+
//
|
|
34
|
+
// A long list (more than `OPTION_WINDOW_FROM` options shown) draws only the rows near the box that scrolls, and the
|
|
35
|
+
// active option with its neighbours; a row that is not drawn is room of its height (`.skipped`), so the box scrolls
|
|
36
|
+
// over the whole list and every option is reached by scrolling and by the keys. What assistive technology is told
|
|
37
|
+
// does not change: each drawn option says its position and the number of options, the active option is always drawn,
|
|
38
|
+
// and a group that draws any of its options draws its title. A list of fewer options draws them all.
|
|
39
|
+
//
|
|
40
|
+
// Nothing here knows which field it is drawn for. The component gives its token prefix (`--tanrei-comp-select`), whose
|
|
41
|
+
// tokens the list reads by the names every such field has (`list.*`, `option.*`, `group.*`, `divider.*`, `motion.*`,
|
|
42
|
+
// and per variant `<variant>.[<state>.]option.*` and `<variant>.[<state>.]selected-option.*`), and what its own rules
|
|
43
|
+
// decide: which options are drawn (a combobox draws the ones its filter leaves), which is the chosen one, what an
|
|
44
|
+
// option's label is drawn as (a combobox marks the match), and what choosing does.
|
|
45
|
+
/** The option's element: one choice. Data for its field. */
|
|
46
|
+
export const OPTION_TAG = 'tanrei-option';
|
|
47
|
+
/** The group's element: a run of options under an optional title. */
|
|
48
|
+
export const OPTION_GROUP_TAG = 'tanrei-option-group';
|
|
49
|
+
/** The attributes of the two elements that their field reads (the properties reflect to them). */
|
|
50
|
+
export const OPTION_ATTRIBUTES = ['label', 'value', 'supporting-text', 'leading-icon', 'disabled'];
|
|
51
|
+
/**
|
|
52
|
+
* The two attributes of every element that say what an option's — or a group's — own words are: the language they are
|
|
53
|
+
* in, and their direction where their first letter does not tell it. The field reads them with the words and gives
|
|
54
|
+
* them to what it draws from those words (the row, the value it shows): the option itself is never drawn, so nothing
|
|
55
|
+
* would inherit them from it.
|
|
56
|
+
*/
|
|
57
|
+
export const OPTION_TEXT_ATTRIBUTES = ['lang', 'dir'];
|
|
58
|
+
const text = (element) => (element.textContent ?? '').replace(/\s+/g, ' ').trim();
|
|
59
|
+
/**
|
|
60
|
+
* What `element` or the nearest group around it says of its own words, below its owner: a `lang` or a `dir`. The owner
|
|
61
|
+
* is the element whose child the option — or its outermost group — is in the page: the field itself, or, for an option
|
|
62
|
+
* that reaches the field through a slot, the element it was written in. The
|
|
63
|
+
* owner's own, and the page's, are inherited by everything the field draws.
|
|
64
|
+
*/
|
|
65
|
+
function said(element, name, owner) {
|
|
66
|
+
for (let at = element; at && at !== owner; at = at.parentElement) {
|
|
67
|
+
const value = at.getAttribute(name)?.trim();
|
|
68
|
+
if (value)
|
|
69
|
+
return value;
|
|
70
|
+
}
|
|
71
|
+
return '';
|
|
72
|
+
}
|
|
73
|
+
function readOption(element, index, owner) {
|
|
74
|
+
return {
|
|
75
|
+
element,
|
|
76
|
+
index,
|
|
77
|
+
label: element.getAttribute('label') || text(element),
|
|
78
|
+
value: element.getAttribute('value') ?? '',
|
|
79
|
+
supportingText: element.getAttribute('supporting-text') ?? '',
|
|
80
|
+
leadingIcon: (element.getAttribute('leading-icon') ?? '').trim(),
|
|
81
|
+
disabled: element.hasAttribute('disabled') && element.getAttribute('disabled') !== 'false',
|
|
82
|
+
lang: said(element, 'lang', owner),
|
|
83
|
+
dir: said(element, 'dir', owner),
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Reads a field's options: its `<tanrei-option>` and `<tanrei-option-group>` children, in order. A group inside a group
|
|
88
|
+
* gives its options to the outer group and is listed in `nested`; anything else among the children (a slotted glyph)
|
|
89
|
+
* is not an option.
|
|
90
|
+
*
|
|
91
|
+
* A child that is a `<slot>` with no `slot` attribute stands for the elements assigned to it, flattened, in its place
|
|
92
|
+
* — each read as though it were the field's child there: how an element composed
|
|
93
|
+
* around the field, or a product's own, gives it the options written as that element's children, which are never
|
|
94
|
+
* moved or copied. A `<slot>` that names a slot of the field's own (a glyph passed on) is not read for options, and a
|
|
95
|
+
* `<slot>` inside a group is not followed. `through`, where given, is told what the reading went through.
|
|
96
|
+
*/
|
|
97
|
+
export function readOptions(host, through) {
|
|
98
|
+
const entries = [];
|
|
99
|
+
const options = [];
|
|
100
|
+
const nested = [];
|
|
101
|
+
let groups = 0;
|
|
102
|
+
const take = (element, owner) => {
|
|
103
|
+
const option = readOption(element, options.length, owner);
|
|
104
|
+
options.push(option);
|
|
105
|
+
return option;
|
|
106
|
+
};
|
|
107
|
+
const inside = (group, into, owner) => {
|
|
108
|
+
for (const child of group.children) {
|
|
109
|
+
if (child.localName === OPTION_TAG)
|
|
110
|
+
into.push(take(child, owner));
|
|
111
|
+
else if (child.localName === OPTION_GROUP_TAG) {
|
|
112
|
+
nested.push(child);
|
|
113
|
+
inside(child, into, owner);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
// O5: an option's own words are looked for up to its owner — the element it is a child of in the page.
|
|
118
|
+
const top = (child) => {
|
|
119
|
+
const owner = child.parentElement;
|
|
120
|
+
if (child.localName === OPTION_TAG)
|
|
121
|
+
entries.push({ kind: 'option', option: take(child, owner) });
|
|
122
|
+
else if (child.localName === OPTION_GROUP_TAG) {
|
|
123
|
+
const group = { element: child, index: groups++, title: child.getAttribute('label') ?? '', lang: said(child, 'lang', owner), dir: said(child, 'dir', owner), options: [] };
|
|
124
|
+
inside(child, group.options, owner);
|
|
125
|
+
entries.push({ kind: 'group', group });
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
for (const child of host.children) {
|
|
129
|
+
if (child.localName === 'slot' && !child.hasAttribute('slot')) {
|
|
130
|
+
if (through)
|
|
131
|
+
through.slots = true;
|
|
132
|
+
for (const assigned of child.assignedElements({ flatten: true })) {
|
|
133
|
+
through?.assigned.push(assigned);
|
|
134
|
+
top(assigned);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
else
|
|
138
|
+
top(child);
|
|
139
|
+
}
|
|
140
|
+
return { entries, options, hasIcons: options.some((option) => !!option.leadingIcon), nested };
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* The model with only the options `keep` keeps, each with the index it had: a group the filter leaves empty is not
|
|
144
|
+
* drawn, and neither is its title (what a combobox draws while the person types).
|
|
145
|
+
*/
|
|
146
|
+
export function filterOptions(model, keep) {
|
|
147
|
+
const entries = [];
|
|
148
|
+
for (const entry of model.entries) {
|
|
149
|
+
if (entry.kind === 'option') {
|
|
150
|
+
if (keep(entry.option))
|
|
151
|
+
entries.push(entry);
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
const options = entry.group.options.filter(keep);
|
|
155
|
+
if (options.length)
|
|
156
|
+
entries.push({ kind: 'group', group: { ...entry.group, options } });
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
const options = entries.flatMap((entry) => (entry.kind === 'option' ? [entry.option] : entry.group.options));
|
|
160
|
+
return { entries, options, hasIcons: model.hasIcons, nested: model.nested };
|
|
161
|
+
}
|
|
162
|
+
/** What the field's own children, and each element that reaches it through a slot, are observed for. */
|
|
163
|
+
const OBSERVED = { childList: true, subtree: true, characterData: true, attributes: true, attributeFilter: [...OPTION_ATTRIBUTES, ...OPTION_TEXT_ATTRIBUTES] };
|
|
164
|
+
/**
|
|
165
|
+
* Keeps a field's options read: when the host is connected, and whenever a `<tanrei-option>` or a
|
|
166
|
+
* `<tanrei-option-group>` is added, removed, moved or changed (an attribute the field reads, or the text that is its
|
|
167
|
+
* label). The host is rendered again; `changed` is told first.
|
|
168
|
+
*
|
|
169
|
+
* Options that reach the field through a slot (`readOptions()`, O4) are not its descendants, so the
|
|
170
|
+
* one observer does not see them: the controller also hears `slotchange` on the host — the event of a slot among its
|
|
171
|
+
* children bubbles to it, and so does that of a slot assigned to that slot, at any depth — and observes each element
|
|
172
|
+
* assigned through a slot as it observes the host's own children, the set rebuilt when a reading finds it changed.
|
|
173
|
+
* A field with no slot among its children hears and observes nothing more than before.
|
|
174
|
+
*/
|
|
175
|
+
export class OptionsController {
|
|
176
|
+
constructor(host, changed) {
|
|
177
|
+
this.host = host;
|
|
178
|
+
this.changed = changed;
|
|
179
|
+
this.model = { entries: [], options: [], hasIcons: false, nested: [] };
|
|
180
|
+
this.observer = typeof MutationObserver === 'undefined' ? null : new MutationObserver(() => this.read());
|
|
181
|
+
/** O4: the elements observed because they reach the host through a slot. */
|
|
182
|
+
this.assigned = [];
|
|
183
|
+
this.onSlotChange = (event) => {
|
|
184
|
+
// The host's own shadow tree is not heard here (a `slotchange` is not composed); a slot that names one of the
|
|
185
|
+
// host's own slots passes a glyph, not options.
|
|
186
|
+
const slot = event.target;
|
|
187
|
+
if (slot?.localName === 'slot' && !(slot.parentElement === this.host && slot.hasAttribute('slot')))
|
|
188
|
+
this.read();
|
|
189
|
+
};
|
|
190
|
+
host.addController(this);
|
|
191
|
+
}
|
|
192
|
+
hostConnected() {
|
|
193
|
+
this.observer?.observe(this.host, OBSERVED);
|
|
194
|
+
this.host.addEventListener('slotchange', this.onSlotChange);
|
|
195
|
+
this.read();
|
|
196
|
+
}
|
|
197
|
+
hostDisconnected() {
|
|
198
|
+
this.observer?.disconnect();
|
|
199
|
+
this.assigned = [];
|
|
200
|
+
this.host.removeEventListener('slotchange', this.onSlotChange);
|
|
201
|
+
}
|
|
202
|
+
/** Reads the options now. Called for you; call it after changing an option in a way no mutation tells. */
|
|
203
|
+
read() {
|
|
204
|
+
const through = { slots: false, assigned: [] };
|
|
205
|
+
this.model = readOptions(this.host, through);
|
|
206
|
+
this.observe(through.assigned);
|
|
207
|
+
this.changed?.(this.model);
|
|
208
|
+
this.host.requestUpdate();
|
|
209
|
+
}
|
|
210
|
+
/** O4: each element that came through a slot is observed as a child is; one that no longer comes is let go. */
|
|
211
|
+
observe(assigned) {
|
|
212
|
+
const was = this.assigned;
|
|
213
|
+
if (!this.observer || (assigned.length === was.length && assigned.every((element, index) => element === was[index])))
|
|
214
|
+
return;
|
|
215
|
+
const now = new Set(assigned);
|
|
216
|
+
if (was.some((element) => !now.has(element))) {
|
|
217
|
+
// An observer lets go of everything or nothing: what it has not delivered yet is this reading's already.
|
|
218
|
+
this.observer.disconnect();
|
|
219
|
+
this.observer.observe(this.host, OBSERVED);
|
|
220
|
+
for (const element of assigned)
|
|
221
|
+
this.observer.observe(element, OBSERVED);
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
const had = new Set(was);
|
|
225
|
+
for (const element of assigned)
|
|
226
|
+
if (!had.has(element))
|
|
227
|
+
this.observer.observe(element, OBSERVED);
|
|
228
|
+
}
|
|
229
|
+
this.assigned = assigned;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
// ── The list's styles ──────────────────────────────────────────────────────────────────────────────────────
|
|
233
|
+
/** The parts an option's condition colors in every state: private key → token part. `c` is the row's fill. */
|
|
234
|
+
const PARTS = { c: 'container-color', l: 'label-color', s: 'supporting-text-color', li: 'leading-icon-color', m: 'mark-color' };
|
|
235
|
+
/** An option's two conditions (its state variants): every option, and the chosen one. */
|
|
236
|
+
const CONDITIONS = ['option', 'selected-option'];
|
|
237
|
+
/** Only the chosen option draws a mark. */
|
|
238
|
+
const HAS = (condition, part) => part !== 'mark-color' || condition === 'selected-option';
|
|
239
|
+
/**
|
|
240
|
+
* The row primitive (item-row.ts) reads `<prefix>-<condition>-[<state>-]<part>`; a field's option tokens are its
|
|
241
|
+
* variant's (`<prefix>-<variant>-[<state>-]<condition>-<part>`: the list holds the same values under every variant, a
|
|
242
|
+
* token test says so). The variant's are given the names the primitive reads, under this private prefix.
|
|
243
|
+
*/
|
|
244
|
+
const ROW = '--_option';
|
|
245
|
+
const STATE_NAMES = Object.keys(SELECTION_STATES).filter(Boolean);
|
|
246
|
+
/** The rows' colors from one variant's tokens, under `selector`; `fallback` is the variant read where the system has none of `variant`. */
|
|
247
|
+
export function optionVariantRules(prefix, variant, selector, fallback = null) {
|
|
248
|
+
const token = (look, state, condition, part) => `${prefix}-${look}-${state ? `${state}-` : ''}${condition}-${part}`;
|
|
249
|
+
const value = (state, condition, part) => fallback ? `var(${token(variant, state, condition, part)}, var(${token(fallback, state, condition, part)}))` : `var(${token(variant, state, condition, part)})`;
|
|
250
|
+
const lines = CONDITIONS.flatMap((condition) => ['', ...STATE_NAMES].flatMap((state) => Object.values(PARTS)
|
|
251
|
+
.filter((part) => HAS(condition, part))
|
|
252
|
+
.map((part) => ` ${ROW}-${condition}-${state ? `${state}-` : ''}${part}: ${value(state, condition, part)};`)));
|
|
253
|
+
return `${selector} {\n${lines.join('\n')}\n }`;
|
|
254
|
+
}
|
|
255
|
+
/** The most the list may be now: what the placement allows (the window less its margins, or the room its side leaves). */
|
|
256
|
+
const MAX_INLINE = 'var(--_anchored-max-inline, 100vw)';
|
|
257
|
+
const MAX_BLOCK = 'var(--_anchored-max-block, 100vh)';
|
|
258
|
+
/** Where each state of a row is read. Every selector has the same specificity, so the order is the precedence. */
|
|
259
|
+
const on = (state) => {
|
|
260
|
+
// SEL-32: the active option by the keyboard is the focused one; focus itself stays on the field.
|
|
261
|
+
if (state === ':focus-visible')
|
|
262
|
+
return '.row.p.kf';
|
|
263
|
+
if (state === ':disabled')
|
|
264
|
+
return '.row.p.d';
|
|
265
|
+
if (state === ':hover')
|
|
266
|
+
return '.row.p:hover';
|
|
267
|
+
return `.row.p${state}`;
|
|
268
|
+
};
|
|
269
|
+
/**
|
|
270
|
+
* The list's styles (SEL-24, SEL-25, SEL-30, SEL-37 … SEL-45, SEL-53, SEL-55, SEL-59): the placed box and its motion,
|
|
271
|
+
* the raised sheet, the box that scrolls, the rows with their columns, conditions, states, press answers and focus
|
|
272
|
+
* indicator, the group titles and what separates the groups. Every value is a token of `prefix`.
|
|
273
|
+
*/
|
|
274
|
+
export function optionListStyles({ prefix, variants, minWidth }) {
|
|
275
|
+
const T = (name) => `var(${prefix}-${name})`;
|
|
276
|
+
const [first, ...others] = variants;
|
|
277
|
+
const motion = `${T('motion-state-duration')} ${T('motion-state-easing')}`;
|
|
278
|
+
return unsafeCSS(`
|
|
279
|
+
/* The rows' colors, from the variant's option tokens: the default's for every value the field does not know. */
|
|
280
|
+
${optionVariantRules(prefix, first, ':host')}
|
|
281
|
+
${others.map((variant) => optionVariantRules(prefix, variant, `:host([variant='${variant}'])`)).join('\n ')}
|
|
282
|
+
:host {
|
|
283
|
+
${ROW}-motion-state-duration: ${T('motion-state-duration')};
|
|
284
|
+
${ROW}-motion-state-easing: ${T('motion-state-easing')};
|
|
285
|
+
${ROW}-motion-feedback-duration: ${T('motion-feedback-duration')};
|
|
286
|
+
${ROW}-container-shape: ${T('option-shape')};
|
|
287
|
+
${ROW}-container-shape-pill: var(${prefix}-option-shape-pill, 0);
|
|
288
|
+
${STATE_NAMES.map((state) => ` ${ROW}-${state}-container-shape: ${T('option-shape')};\n ${ROW}-${state}-container-shape-pill: var(${prefix}-option-shape-pill, 0);\n ${ROW}-${state}-opacity: ${T(`${state}-opacity`)};`).join('\n')}
|
|
289
|
+
}
|
|
290
|
+
/* What separates the groups: the field's attribute, else its separation token. */
|
|
291
|
+
${separationHost(`${prefix}-separation`)}
|
|
292
|
+
|
|
293
|
+
/* The placed box and its motion: in the top layer, or in place for a fixture (src/primitives/anchored.ts). */
|
|
294
|
+
${anchoredSurfaceStyles({
|
|
295
|
+
surface: '.surface',
|
|
296
|
+
motion: '.motion',
|
|
297
|
+
offset: T('list-offset'),
|
|
298
|
+
margin: T('list-viewport-margin'),
|
|
299
|
+
open: { duration: T('motion-open-duration'), easing: T('motion-open-easing') },
|
|
300
|
+
close: { duration: T('motion-close-duration'), easing: T('motion-close-easing') },
|
|
301
|
+
})}
|
|
302
|
+
|
|
303
|
+
/* The sheet: its color, elevation and corners (eased by the smoothing), its options clipped to that shape; as wide
|
|
304
|
+
as the field${minWidth ? ', at least its least width' : ''}, never wider than the window allows; as tall as its options and paddings up to its
|
|
305
|
+
greatest height and the room its side leaves. */
|
|
306
|
+
.list {
|
|
307
|
+
box-sizing: border-box;
|
|
308
|
+
display: flex;
|
|
309
|
+
flex-direction: column;
|
|
310
|
+
inline-size: var(--_anchored-anchor-inline, auto);
|
|
311
|
+
min-inline-size: ${minWidth ? `min(${minWidth}, ${MAX_INLINE})` : '0'};
|
|
312
|
+
max-inline-size: ${MAX_INLINE};
|
|
313
|
+
max-block-size: min(${T('list-max-height')}, ${MAX_BLOCK});
|
|
314
|
+
overflow: hidden;
|
|
315
|
+
background: ${T('list-color')};
|
|
316
|
+
box-shadow: ${T('list-elevation')};
|
|
317
|
+
text-align: start;
|
|
318
|
+
cursor: default;
|
|
319
|
+
${cornerRadius(`${prefix}-list-shape`)}
|
|
320
|
+
}
|
|
321
|
+
/* The options scroll inside the sheet, vertically only, the paddings with them. It also carries press-hold for the
|
|
322
|
+
rows' press (it has no transition of its own). */
|
|
323
|
+
.scroll {
|
|
324
|
+
position: relative;
|
|
325
|
+
display: flex;
|
|
326
|
+
flex: 1 1 auto;
|
|
327
|
+
flex-direction: column;
|
|
328
|
+
min-block-size: 0;
|
|
329
|
+
overflow-x: hidden;
|
|
330
|
+
overflow-y: auto;
|
|
331
|
+
overscroll-behavior: contain;
|
|
332
|
+
padding-block: ${T('list-padding-block')};
|
|
333
|
+
padding-inline: ${T('list-padding-inline')};
|
|
334
|
+
outline: none;
|
|
335
|
+
}
|
|
336
|
+
${pressHold('.scroll')}
|
|
337
|
+
/* What a field draws after the options (a combobox's status row) stands under the box that scrolls, in the sheet: the
|
|
338
|
+
options scroll above it and it stays in view. The end padding is then below it, and a list that draws no option is
|
|
339
|
+
that row alone. */
|
|
340
|
+
.list.tail > .scroll {
|
|
341
|
+
padding-block-end: 0;
|
|
342
|
+
}
|
|
343
|
+
.list.bare > .scroll {
|
|
344
|
+
display: none;
|
|
345
|
+
}
|
|
346
|
+
.group {
|
|
347
|
+
display: flex;
|
|
348
|
+
flex: none;
|
|
349
|
+
flex-direction: column;
|
|
350
|
+
}
|
|
351
|
+
/* A long list: the room of the rows that are not drawn now, as tall as they would be (the script writes the height). */
|
|
352
|
+
.skipped {
|
|
353
|
+
flex: none;
|
|
354
|
+
}
|
|
355
|
+
/* A group's title: above its options, inset from the rows' edges, wrapping; never a choice. */
|
|
356
|
+
.group-title {
|
|
357
|
+
display: block;
|
|
358
|
+
padding-block: ${T('option-padding-block')};
|
|
359
|
+
padding-inline: ${T('group-title-padding-inline')};
|
|
360
|
+
font: ${T('group-title-typescale-font')};
|
|
361
|
+
letter-spacing: ${T('group-title-typescale-letter-spacing')};
|
|
362
|
+
color: ${T('group-title-color')};
|
|
363
|
+
overflow-wrap: break-word;
|
|
364
|
+
}
|
|
365
|
+
/* Divider: a line across the list's inner width with space above and below. Gap: empty space in its place, and no
|
|
366
|
+
line. The cascade answers which (the attribute over the token), so a change of either is followed at once. */
|
|
367
|
+
.divider {
|
|
368
|
+
flex: none;
|
|
369
|
+
block-size: ${T('divider-thickness')};
|
|
370
|
+
margin-block: ${T('divider-space')};
|
|
371
|
+
background: ${T('divider-color')};
|
|
372
|
+
}
|
|
373
|
+
.gap {
|
|
374
|
+
display: none;
|
|
375
|
+
flex: none;
|
|
376
|
+
block-size: ${T('group-gap')};
|
|
377
|
+
}
|
|
378
|
+
${whenGap('.scroll', (scroll) => `
|
|
379
|
+
${scroll} > .divider {
|
|
380
|
+
display: none;
|
|
381
|
+
}
|
|
382
|
+
${scroll} > .gap {
|
|
383
|
+
display: block;
|
|
384
|
+
}`)}
|
|
385
|
+
|
|
386
|
+
/* The glyphs: an option's own, in the family and fill of its condition, and the check, always the selected ones. */
|
|
387
|
+
${iconGlyph('.option-icon', { size: `${prefix}-option-leading-icon-size`, selected: '.row.selected', duration: `${prefix}-motion-state-duration`, easing: `${prefix}-motion-state-easing` })}
|
|
388
|
+
${iconGlyph('.check', { size: `${prefix}-option-mark-size`, selected: '.mark', duration: `${prefix}-motion-state-duration`, easing: `${prefix}-motion-state-easing` })}
|
|
389
|
+
|
|
390
|
+
/* The conditions, the states and their precedence, the paints, the ripple and the state motion (item-row.ts). */
|
|
391
|
+
${itemRowStyles({
|
|
392
|
+
prefix: ROW,
|
|
393
|
+
parts: PARTS,
|
|
394
|
+
conditions: { option: '.row', 'selected-option': '.row.selected' },
|
|
395
|
+
on,
|
|
396
|
+
paints: { '.option-label': 'l', '.option-supporting': 's', '.option-icon': 'li' },
|
|
397
|
+
})}
|
|
398
|
+
.row.p {
|
|
399
|
+
-webkit-user-select: none;
|
|
400
|
+
}
|
|
401
|
+
.row.p.d {
|
|
402
|
+
cursor: default;
|
|
403
|
+
}
|
|
404
|
+
/* One row: the padding at each end (logical, so right-to-left mirrors), at least the option's height and the minimum
|
|
405
|
+
target tall, growing with its content and never cutting it. */
|
|
406
|
+
.row {
|
|
407
|
+
display: flex;
|
|
408
|
+
flex: none;
|
|
409
|
+
align-items: center;
|
|
410
|
+
padding-block: ${T('option-padding-block')};
|
|
411
|
+
padding-inline: ${T('option-padding-inline')};
|
|
412
|
+
}
|
|
413
|
+
${rowTarget('.row', T('option-height'))}
|
|
414
|
+
/* The columns — the leading icon, the texts, the check's box — a gap apart, each centred on the label's first line. */
|
|
415
|
+
.row-content {
|
|
416
|
+
--_first: max(1lh, ${T('option-mark-size')}, ${T('option-leading-icon-size')});
|
|
417
|
+
display: flex;
|
|
418
|
+
flex: 1 1 auto;
|
|
419
|
+
align-items: flex-start;
|
|
420
|
+
gap: ${T('option-gap')};
|
|
421
|
+
min-inline-size: 0;
|
|
422
|
+
font: ${T('option-label-typescale-font')};
|
|
423
|
+
letter-spacing: ${T('option-label-typescale-letter-spacing')};
|
|
424
|
+
}
|
|
425
|
+
.row-column {
|
|
426
|
+
display: flex;
|
|
427
|
+
flex: none;
|
|
428
|
+
align-items: center;
|
|
429
|
+
justify-content: center;
|
|
430
|
+
}
|
|
431
|
+
.row-column.leading {
|
|
432
|
+
margin-block-start: calc((var(--_first) - ${T('option-leading-icon-size')}) / 2);
|
|
433
|
+
}
|
|
434
|
+
.row-column.mark {
|
|
435
|
+
inline-size: ${T('option-mark-size')};
|
|
436
|
+
block-size: ${T('option-mark-size')};
|
|
437
|
+
margin-block-start: calc((var(--_first) - ${T('option-mark-size')}) / 2);
|
|
438
|
+
}
|
|
439
|
+
.row-text {
|
|
440
|
+
display: flex;
|
|
441
|
+
flex: 1 1 auto;
|
|
442
|
+
flex-direction: column;
|
|
443
|
+
min-inline-size: 0;
|
|
444
|
+
padding-block-start: calc((var(--_first) - 1lh) / 2);
|
|
445
|
+
}
|
|
446
|
+
.option-label,
|
|
447
|
+
.option-supporting {
|
|
448
|
+
overflow-wrap: break-word;
|
|
449
|
+
}
|
|
450
|
+
.option-supporting {
|
|
451
|
+
font: ${T('option-supporting-text-typescale-font')};
|
|
452
|
+
letter-spacing: ${T('option-supporting-text-typescale-letter-spacing')};
|
|
453
|
+
}
|
|
454
|
+
/* Each text is its own run, in the direction of its first strong character, aligned to the layout's start. */
|
|
455
|
+
${productText(':is(.option-label, .option-supporting, .group-title)', { align: 'start' })}
|
|
456
|
+
|
|
457
|
+
/* An option's glyph, and the check, are drawn once the icon set can draw them (GlyphDrawnController sets
|
|
458
|
+
data-drawn): until then nothing stands in the box, never the glyph's name. An option without a glyph keeps the
|
|
459
|
+
column. */
|
|
460
|
+
.option-icon:not([data-drawn]) {
|
|
461
|
+
visibility: hidden;
|
|
462
|
+
}
|
|
463
|
+
.ink {
|
|
464
|
+
display: inline-block;
|
|
465
|
+
vertical-align: top;
|
|
466
|
+
}
|
|
467
|
+
/* The check: in the mark color of the chosen option's state, faded in and out over the state motion and never moved
|
|
468
|
+
or scaled; nothing in its box for any other option. */
|
|
469
|
+
.check {
|
|
470
|
+
color: var(--_m);
|
|
471
|
+
opacity: 0;
|
|
472
|
+
visibility: hidden;
|
|
473
|
+
transition:
|
|
474
|
+
opacity ${motion},
|
|
475
|
+
visibility ${motion},
|
|
476
|
+
color ${motion},
|
|
477
|
+
font-variation-settings ${motion};
|
|
478
|
+
}
|
|
479
|
+
.row.selected .check {
|
|
480
|
+
opacity: 1;
|
|
481
|
+
}
|
|
482
|
+
.row.selected .check[data-drawn] {
|
|
483
|
+
visibility: visible;
|
|
484
|
+
}
|
|
485
|
+
.check:not([data-drawn]) {
|
|
486
|
+
transition: none;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
/* The focus indicator of the option that is active by the keyboard: inside the row, which the list would otherwise
|
|
490
|
+
clip, never animated. Focus itself is on the field, so the row carries the mark (kf) and the focus style's name. */
|
|
491
|
+
${focusRing((focus) => (focus === ':focus-visible' ? '.row.kf' : ".row.kf[data-focus-style='glow']"), { inside: true })}
|
|
492
|
+
|
|
493
|
+
@media (prefers-reduced-motion: reduce) {
|
|
494
|
+
.check {
|
|
495
|
+
transition: none;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
/* Forced colors: an edge round the list, the active option in the highlight colors, a disabled option in the
|
|
499
|
+
disabled text color; the chosen option is then shown by its check alone. */
|
|
500
|
+
@media (forced-colors: active) {
|
|
501
|
+
.list {
|
|
502
|
+
border: var(--tanrei-sys-border-hairline) solid CanvasText;
|
|
503
|
+
}
|
|
504
|
+
.divider {
|
|
505
|
+
background: CanvasText;
|
|
506
|
+
}
|
|
507
|
+
.row.p.d,
|
|
508
|
+
.row.p.d :is(.option-label, .option-supporting, .option-icon, .check) {
|
|
509
|
+
color: GrayText;
|
|
510
|
+
}
|
|
511
|
+
.row.p.active {
|
|
512
|
+
forced-color-adjust: none;
|
|
513
|
+
background: Highlight;
|
|
514
|
+
}
|
|
515
|
+
.row.p.active :is(.option-label, .option-supporting, .option-icon, .check) {
|
|
516
|
+
color: HighlightText;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
`);
|
|
520
|
+
}
|
|
521
|
+
/**
|
|
522
|
+
* The list as an anchored surface (src/primitives/anchored.ts), placed as a popover whose placement is bottom-start
|
|
523
|
+
* and whose width is its anchor's: below the field with the start edges together, above it where below has no room,
|
|
524
|
+
* limited to the room where neither has, following the field, without an arrow.
|
|
525
|
+
*/
|
|
526
|
+
export function anchoredOptionList(host, { anchor, inline, gone }) {
|
|
527
|
+
const find = (selector) => host.renderRoot?.querySelector(selector) ?? null;
|
|
528
|
+
return new AnchoredSurfaceController(host, {
|
|
529
|
+
surface: () => find('.surface'),
|
|
530
|
+
motion: () => find('.motion'),
|
|
531
|
+
box: () => find('.list'),
|
|
532
|
+
anchor,
|
|
533
|
+
placement: () => 'bottom-start',
|
|
534
|
+
fallback: 'bottom-start',
|
|
535
|
+
auto: ['bottom', 'top'],
|
|
536
|
+
autoAlign: 'start',
|
|
537
|
+
offset: () => null,
|
|
538
|
+
crossOffset: () => 0,
|
|
539
|
+
arrow: () => false,
|
|
540
|
+
matchWidth: () => true,
|
|
541
|
+
inline,
|
|
542
|
+
// Limited to the room its side leaves down to one option and the paddings; with less, it covers the field.
|
|
543
|
+
least: () => {
|
|
544
|
+
const scroll = find('.scroll');
|
|
545
|
+
const row = find('.row');
|
|
546
|
+
if (!scroll || !row)
|
|
547
|
+
return { width: 0, height: 0 };
|
|
548
|
+
const style = getComputedStyle(scroll);
|
|
549
|
+
return { width: 0, height: row.offsetHeight + (Number.parseFloat(style.paddingTop) || 0) + (Number.parseFloat(style.paddingBottom) || 0) };
|
|
550
|
+
},
|
|
551
|
+
scroller: () => find('.scroll'),
|
|
552
|
+
gone,
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
// ── The active option ──────────────────────────────────────────────────────────────────────────────────────
|
|
556
|
+
/** How far Page Down and Page Up move the active option. */
|
|
557
|
+
export const OPTION_PAGE = 10;
|
|
558
|
+
/** A list that shows more options than this draws only the rows near the box that scrolls. */
|
|
559
|
+
export const OPTION_WINDOW_FROM = 100;
|
|
560
|
+
/** The rows a long list draws from its start before any row has been measured. */
|
|
561
|
+
const UNMEASURED_ROWS = 40;
|
|
562
|
+
/** How often in a row a measurement may ask for another render: heights that never settle are left as they are. */
|
|
563
|
+
const SETTLE_PASSES = 4;
|
|
564
|
+
/** An element's own block size as laid out, fractions kept (a row and a title are border boxes; neither has a margin). */
|
|
565
|
+
const blockSize = (element) => Number.parseFloat(getComputedStyle(element).blockSize) || 0;
|
|
566
|
+
/** The boxes of the glyphs the list draws by name, for GlyphDrawnController. */
|
|
567
|
+
export const OPTION_GLYPHS = '.check, .option-icon';
|
|
568
|
+
/** The boxes of the glyphs the icon set may mirror in right-to-left (the check is never mirrored), for GlyphMirrorController. */
|
|
569
|
+
export const OPTION_MIRRORED = '.option-icon';
|
|
570
|
+
/** The id of an option's row in the field's shadow root: what `aria-activedescendant` names. */
|
|
571
|
+
export const optionId = (option) => `option-${option.index}`;
|
|
572
|
+
/**
|
|
573
|
+
* The list's active option and what acts on it. The field keeps focus; one option at a time is the active one, which
|
|
574
|
+
* the keys act on and `aria-activedescendant` names. The component calls `start()` when its list opens and `stop()`
|
|
575
|
+
* when it closes, `key()` for a key pressed on the field while the list is open, `activate()` for Enter or Space, and
|
|
576
|
+
* renders the list with `render()`.
|
|
577
|
+
*/
|
|
578
|
+
export class OptionListController {
|
|
579
|
+
constructor(host, options) {
|
|
580
|
+
this.host = host;
|
|
581
|
+
this.options = options;
|
|
582
|
+
/** The active option, or null while the list is closed or holds no option. */
|
|
583
|
+
this.active = null;
|
|
584
|
+
/** Whether the active option was made active by the keyboard: it is then drawn focused, with the focus indicator. */
|
|
585
|
+
this.keyboard = false;
|
|
586
|
+
this.running = false;
|
|
587
|
+
/**
|
|
588
|
+
* Whether the rows are drawn: from the render that opens the list until the list has closed and its sheet has left
|
|
589
|
+
* the top layer (a closing sheet fades with its rows in it). A closed field draws none.
|
|
590
|
+
*/
|
|
591
|
+
this.drawn = false;
|
|
592
|
+
// ── A long list's rows (see the head of this file) ──
|
|
593
|
+
/** The rows are windowed in what is drawn now. */
|
|
594
|
+
this.windowed = false;
|
|
595
|
+
/** What the last render drew of a long list. */
|
|
596
|
+
this.windowKey = '';
|
|
597
|
+
/** The options, and the titled groups, the last render of a long list drew, in order: its `.row` and `.group-title` elements. */
|
|
598
|
+
this.drawnRows = [];
|
|
599
|
+
this.drawnTitles = [];
|
|
600
|
+
/** A drawn row's height — the least seen since the list opened: what a row that was never drawn is taken to be. */
|
|
601
|
+
this.rowHeight = 0;
|
|
602
|
+
/** A drawn title's height, and the room between two groups, likewise. */
|
|
603
|
+
this.titleHeight = 0;
|
|
604
|
+
this.separatorHeight = 0;
|
|
605
|
+
/** The height of each row and title that was drawn and is not of that height, by its `<tanrei-option>` or group. */
|
|
606
|
+
this.heights = new WeakMap();
|
|
607
|
+
this.settling = 0;
|
|
608
|
+
this.activeElement = null;
|
|
609
|
+
this.activeValue = null;
|
|
610
|
+
this.keys = new RovingKeys({ wrap: false, repeat: true });
|
|
611
|
+
this.pressedRow = null;
|
|
612
|
+
this.pressedOption = null;
|
|
613
|
+
this.revealing = false;
|
|
614
|
+
/** The placed box left the top layer (a popover's `toggle`): the closed list's rows are taken away. */
|
|
615
|
+
this.onSurfaceToggle = (event) => {
|
|
616
|
+
if (this.running || !this.drawn || event.currentTarget.matches(':popover-open'))
|
|
617
|
+
return;
|
|
618
|
+
this.drawn = false;
|
|
619
|
+
this.host.requestUpdate();
|
|
620
|
+
};
|
|
621
|
+
this.onScroll = () => this.rewindow();
|
|
622
|
+
/** A press on the list never takes focus from the field; on an option it shows the pressed state without delay. */
|
|
623
|
+
this.onPointerDown = (event) => {
|
|
624
|
+
if (event.button !== 0 && event.pointerType === 'mouse')
|
|
625
|
+
return;
|
|
626
|
+
const hit = this.optionAt(event);
|
|
627
|
+
if (!hit)
|
|
628
|
+
return;
|
|
629
|
+
this.makeActive(hit.option, false);
|
|
630
|
+
this.pressOn(hit.option, { x: event.clientX, y: event.clientY });
|
|
631
|
+
};
|
|
632
|
+
/** Focus stays on the field: the press that would move it is cancelled (the pointer events still come). */
|
|
633
|
+
this.onMouseDown = (event) => event.preventDefault();
|
|
634
|
+
this.onPointerUp = () => this.press.release();
|
|
635
|
+
/** A pointer that moves onto an option makes it the active one, without the focus indicator. */
|
|
636
|
+
this.onPointerMove = (event) => {
|
|
637
|
+
if (event.pointerType === 'touch')
|
|
638
|
+
return;
|
|
639
|
+
const hit = this.optionAt(event);
|
|
640
|
+
if (hit && (hit.option.element !== this.activeElement || this.keyboard))
|
|
641
|
+
this.makeActive(hit.option, false);
|
|
642
|
+
};
|
|
643
|
+
/** A press that ended on an option chooses it; on a disabled one, on a title or on the sheet, nothing. */
|
|
644
|
+
this.onClick = (event) => {
|
|
645
|
+
const hit = this.optionAt(event);
|
|
646
|
+
if (!hit || hit.option.disabled)
|
|
647
|
+
return;
|
|
648
|
+
this.options.choose(hit.option, event);
|
|
649
|
+
};
|
|
650
|
+
host.addController(this);
|
|
651
|
+
this.press = new PressController(host, {
|
|
652
|
+
container: () => this.pressedRow,
|
|
653
|
+
holdCarrier: () => this.find('.scroll'),
|
|
654
|
+
disabled: () => !!this.pressedOption?.disabled,
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
find(selector) {
|
|
658
|
+
return this.host.renderRoot?.querySelector(selector) ?? null;
|
|
659
|
+
}
|
|
660
|
+
rowOf(option) {
|
|
661
|
+
return option ? this.find(`#${optionId(option)}`) : null;
|
|
662
|
+
}
|
|
663
|
+
/** The id of the active option's row, for `aria-activedescendant`; undefined while there is none. */
|
|
664
|
+
get activeId() {
|
|
665
|
+
return this.running && this.active ? optionId(this.active) : undefined;
|
|
666
|
+
}
|
|
667
|
+
/** The option SEL-31 names for an opening list: the chosen one, or the first that is not disabled where none is chosen. */
|
|
668
|
+
initial() {
|
|
669
|
+
const { options } = this.options.model();
|
|
670
|
+
const chosen = this.options.chosen();
|
|
671
|
+
return (chosen && options.find((option) => option.element === chosen.element)) || options.find((option) => !option.disabled) || null;
|
|
672
|
+
}
|
|
673
|
+
/** Whether the list is running: between `start()` and `stop()`. */
|
|
674
|
+
get started() {
|
|
675
|
+
return this.running;
|
|
676
|
+
}
|
|
677
|
+
/**
|
|
678
|
+
* Makes `option` the active one, or none (`null`: a combobox while Enter keeps the text, CMB-26). `keyboard` says
|
|
679
|
+
* whether it is drawn focused. The whole of it is brought into view.
|
|
680
|
+
*/
|
|
681
|
+
setActive(option, keyboard) {
|
|
682
|
+
this.makeActive(option, keyboard);
|
|
683
|
+
if (option)
|
|
684
|
+
this.revealing = true;
|
|
685
|
+
this.host.requestUpdate();
|
|
686
|
+
}
|
|
687
|
+
makeActive(option, keyboard) {
|
|
688
|
+
const changed = option?.element !== this.activeElement || keyboard !== this.keyboard;
|
|
689
|
+
this.active = option;
|
|
690
|
+
this.activeElement = option?.element ?? null;
|
|
691
|
+
this.activeValue = option?.value ?? null;
|
|
692
|
+
this.keyboard = keyboard;
|
|
693
|
+
if (changed)
|
|
694
|
+
this.host.requestUpdate();
|
|
695
|
+
}
|
|
696
|
+
/** The list opened: the chosen option is the active one, or the first enabled one. `keyboard` says what opened it. */
|
|
697
|
+
start(keyboard, active) {
|
|
698
|
+
this.running = true;
|
|
699
|
+
this.drawn = true;
|
|
700
|
+
// Measured again each time the list opens: the text may have another size by now.
|
|
701
|
+
this.rowHeight = this.titleHeight = this.separatorHeight = 0;
|
|
702
|
+
this.settling = 0;
|
|
703
|
+
this.makeActive(active === undefined ? this.initial() : active, keyboard);
|
|
704
|
+
this.revealing = true;
|
|
705
|
+
this.host.requestUpdate();
|
|
706
|
+
}
|
|
707
|
+
/** The list closed. A press that is still held ends by itself. */
|
|
708
|
+
stop() {
|
|
709
|
+
if (!this.running)
|
|
710
|
+
return;
|
|
711
|
+
this.running = false;
|
|
712
|
+
this.makeActive(null, false);
|
|
713
|
+
// A sheet that is fading out keeps its rows until it has gone (`onSurfaceToggle`); one that is not in the top layer
|
|
714
|
+
// — drawn in place, never shown, or taken out of the page — has nothing to fade.
|
|
715
|
+
if (!this.find('.surface')?.matches(':popover-open'))
|
|
716
|
+
this.drawn = false;
|
|
717
|
+
}
|
|
718
|
+
/**
|
|
719
|
+
* The options changed, or the chosen one did: the active option stays where an option of the same element or value
|
|
720
|
+
* still exists, and is otherwise the one an opening list has (SEL-36). Called before every render.
|
|
721
|
+
*/
|
|
722
|
+
hostUpdate() {
|
|
723
|
+
if (!this.running)
|
|
724
|
+
return;
|
|
725
|
+
const { options } = this.options.model();
|
|
726
|
+
const kept = options.find((option) => option.element === this.activeElement) ?? (this.activeValue === null ? undefined : options.find((option) => option.value === this.activeValue));
|
|
727
|
+
if (kept) {
|
|
728
|
+
this.active = kept;
|
|
729
|
+
this.activeElement = kept.element;
|
|
730
|
+
this.activeValue = kept.value;
|
|
731
|
+
}
|
|
732
|
+
else {
|
|
733
|
+
const next = this.options.replacement ? this.options.replacement(options) : this.initial();
|
|
734
|
+
this.active = next;
|
|
735
|
+
this.activeElement = next?.element ?? null;
|
|
736
|
+
this.activeValue = next?.value ?? null;
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
hostUpdated() {
|
|
740
|
+
if (!this.running)
|
|
741
|
+
return;
|
|
742
|
+
const row = this.rowOf(this.active);
|
|
743
|
+
// The focus style's name, for a browser without style queries: read when the option becomes the focused one.
|
|
744
|
+
if (row && this.keyboard)
|
|
745
|
+
syncFocusStyle(this.host, row);
|
|
746
|
+
syncSeparation(this.host, this.find('.scroll'));
|
|
747
|
+
if (this.revealing)
|
|
748
|
+
this.reveal();
|
|
749
|
+
else
|
|
750
|
+
this.measure();
|
|
751
|
+
}
|
|
752
|
+
// ── A long list's rows ───────────────────────────────────────────────────────────────────────────────────
|
|
753
|
+
rowExtent(option) {
|
|
754
|
+
return this.heights.get(option.element) ?? this.rowHeight;
|
|
755
|
+
}
|
|
756
|
+
titleExtent(group) {
|
|
757
|
+
return group.title ? (this.heights.get(group.element) ?? this.titleHeight) : 0;
|
|
758
|
+
}
|
|
759
|
+
/** Where each option of `model` begins in the box that scrolls, from its first row's edge: measured, or for what was never drawn taken from what was. */
|
|
760
|
+
tops(model) {
|
|
761
|
+
const tops = [];
|
|
762
|
+
let at = 0;
|
|
763
|
+
model.entries.forEach((entry, index) => {
|
|
764
|
+
const before = model.entries[index - 1];
|
|
765
|
+
if (before && (entry.kind === 'group' || before.kind === 'group'))
|
|
766
|
+
at += this.separatorHeight;
|
|
767
|
+
const options = entry.kind === 'option' ? [entry.option] : entry.group.options;
|
|
768
|
+
if (entry.kind === 'group')
|
|
769
|
+
at += this.titleExtent(entry.group);
|
|
770
|
+
for (const option of options) {
|
|
771
|
+
tops.push(at);
|
|
772
|
+
at += this.rowExtent(option);
|
|
773
|
+
}
|
|
774
|
+
});
|
|
775
|
+
return tops;
|
|
776
|
+
}
|
|
777
|
+
/**
|
|
778
|
+
* The rows a list of `model` draws now, or null for a list short enough to draw them all: the rows in the box that
|
|
779
|
+
* scrolls and as much again before and after it, and the active option with a page of rows on each side — so the row
|
|
780
|
+
* a key moves to is there before the box has scrolled to it. Before anything was measured, the list's first rows.
|
|
781
|
+
*/
|
|
782
|
+
windowOf(model) {
|
|
783
|
+
const { options } = model;
|
|
784
|
+
const count = options.length;
|
|
785
|
+
if (count <= OPTION_WINDOW_FROM)
|
|
786
|
+
return null;
|
|
787
|
+
const scroll = this.find('.scroll');
|
|
788
|
+
const view = scroll?.clientHeight ?? 0;
|
|
789
|
+
let from = 0;
|
|
790
|
+
let to = Math.min(count, UNMEASURED_ROWS);
|
|
791
|
+
if (scroll && view > 0 && this.rowHeight > 0) {
|
|
792
|
+
const tops = this.tops(model);
|
|
793
|
+
const start = scroll.scrollTop - view;
|
|
794
|
+
const end = scroll.scrollTop + 2 * view;
|
|
795
|
+
from = count;
|
|
796
|
+
to = 0;
|
|
797
|
+
for (let index = 0; index < count; index++) {
|
|
798
|
+
if (tops[index] >= end)
|
|
799
|
+
break;
|
|
800
|
+
if (tops[index] + this.rowExtent(options[index]) <= start)
|
|
801
|
+
continue;
|
|
802
|
+
from = Math.min(from, index);
|
|
803
|
+
to = index + 1;
|
|
804
|
+
}
|
|
805
|
+
// Scrolled past what the list now holds (the options changed): its last rows, until the box has followed.
|
|
806
|
+
if (from >= to) {
|
|
807
|
+
from = Math.max(0, count - UNMEASURED_ROWS);
|
|
808
|
+
to = count;
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
const active = this.activeElement ? options.findIndex((option) => option.element === this.activeElement) : -1;
|
|
812
|
+
const near = active < 0 ? 0 : Math.max(0, active - OPTION_PAGE);
|
|
813
|
+
const far = active < 0 ? 0 : Math.min(count, active + OPTION_PAGE + 1);
|
|
814
|
+
return { key: `${from}:${to}:${near}:${far}`, has: (index) => (index >= from && index < to) || (index >= near && index < far) };
|
|
815
|
+
}
|
|
816
|
+
/** The box scrolled, or was scrolled: a long list draws the rows that are near it now. */
|
|
817
|
+
rewindow() {
|
|
818
|
+
if (!this.windowed || !this.running)
|
|
819
|
+
return;
|
|
820
|
+
const next = this.windowOf(this.options.model());
|
|
821
|
+
if (next && next.key !== this.windowKey)
|
|
822
|
+
this.host.requestUpdate();
|
|
823
|
+
}
|
|
824
|
+
/**
|
|
825
|
+
* A long list's drawn rows, titles and separation are measured, so that what is not drawn takes the room it would.
|
|
826
|
+
* A height that is not the one assumed draws the list again (the rooms change), a few times at most. Returns whether
|
|
827
|
+
* it does.
|
|
828
|
+
*/
|
|
829
|
+
measure() {
|
|
830
|
+
if (!this.windowed)
|
|
831
|
+
return false;
|
|
832
|
+
const scroll = this.find('.scroll');
|
|
833
|
+
if (!scroll || scroll.clientHeight === 0)
|
|
834
|
+
return false;
|
|
835
|
+
let changed = false;
|
|
836
|
+
const take = (elements, keys, assumed) => {
|
|
837
|
+
if (elements.length === 0 || elements.length !== keys.length)
|
|
838
|
+
return assumed;
|
|
839
|
+
// Whole pixels tell which elements differ; the fractions are read only for those, and once for the common height.
|
|
840
|
+
const sizes = elements.map((element) => element.offsetHeight);
|
|
841
|
+
const least = Math.min(...sizes);
|
|
842
|
+
let common = assumed;
|
|
843
|
+
if (common === 0 || least < Math.round(common)) {
|
|
844
|
+
common = blockSize(elements[sizes.indexOf(least)]);
|
|
845
|
+
changed = true;
|
|
846
|
+
}
|
|
847
|
+
elements.forEach((element, index) => {
|
|
848
|
+
const own = Math.abs(sizes[index] - common) < 1 ? undefined : blockSize(element);
|
|
849
|
+
if (own === this.heights.get(keys[index]))
|
|
850
|
+
return;
|
|
851
|
+
if (own === undefined)
|
|
852
|
+
this.heights.delete(keys[index]);
|
|
853
|
+
else
|
|
854
|
+
this.heights.set(keys[index], own);
|
|
855
|
+
changed = true;
|
|
856
|
+
});
|
|
857
|
+
return common;
|
|
858
|
+
};
|
|
859
|
+
this.rowHeight = take([...scroll.querySelectorAll('.row')], this.drawnRows.map((option) => option.element), this.rowHeight);
|
|
860
|
+
this.titleHeight = take([...scroll.querySelectorAll('.group-title')], this.drawnTitles, this.titleHeight);
|
|
861
|
+
// What separates two groups: the line with the space above and below it, or the gap — whichever is drawn.
|
|
862
|
+
const divider = scroll.querySelector('.divider');
|
|
863
|
+
if (divider) {
|
|
864
|
+
const outer = (element) => {
|
|
865
|
+
if (!element)
|
|
866
|
+
return 0;
|
|
867
|
+
const style = getComputedStyle(element);
|
|
868
|
+
return style.display === 'none' ? 0 : (Number.parseFloat(style.blockSize) || 0) + (Number.parseFloat(style.marginBlockStart) || 0) + (Number.parseFloat(style.marginBlockEnd) || 0);
|
|
869
|
+
};
|
|
870
|
+
const separator = outer(divider) + outer(divider.nextElementSibling);
|
|
871
|
+
if (separator !== this.separatorHeight) {
|
|
872
|
+
this.separatorHeight = separator;
|
|
873
|
+
changed = true;
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
if (!changed) {
|
|
877
|
+
this.settling = 0;
|
|
878
|
+
return false;
|
|
879
|
+
}
|
|
880
|
+
if (this.settling >= SETTLE_PASSES)
|
|
881
|
+
return false;
|
|
882
|
+
this.settling += 1;
|
|
883
|
+
this.host.requestUpdate();
|
|
884
|
+
return true;
|
|
885
|
+
}
|
|
886
|
+
/** Whether characters typed now continue a search: a Space then belongs to it, and does not choose. */
|
|
887
|
+
searching() {
|
|
888
|
+
return this.keys.searching();
|
|
889
|
+
}
|
|
890
|
+
/**
|
|
891
|
+
* A key pressed on the field while its list is open: the arrow keys (stopping at the ends), Home, End, the page keys
|
|
892
|
+
* (by `OPTION_PAGE`) and printable characters (the next option whose label begins with what was typed within a
|
|
893
|
+
* second, wrapping). A disabled option is reached like any other. Returns whether the key was the list's.
|
|
894
|
+
*/
|
|
895
|
+
key(key) {
|
|
896
|
+
const { options } = this.options.model();
|
|
897
|
+
if (options.length === 0)
|
|
898
|
+
return false;
|
|
899
|
+
const current = this.active ? options.findIndex((option) => option.element === this.active?.element) : -1;
|
|
900
|
+
let target;
|
|
901
|
+
if (key === 'PageDown')
|
|
902
|
+
target = Math.min((current < 0 ? -1 : current) + OPTION_PAGE, options.length - 1);
|
|
903
|
+
else if (key === 'PageUp')
|
|
904
|
+
target = Math.max((current < 0 ? options.length : current) - OPTION_PAGE, 0);
|
|
905
|
+
else
|
|
906
|
+
target = this.keys.target(key, current, options.map((option) => ({ focusable: true, label: option.label })));
|
|
907
|
+
if (target === null)
|
|
908
|
+
return false;
|
|
909
|
+
this.makeActive(options[target], true);
|
|
910
|
+
this.revealing = true;
|
|
911
|
+
this.host.requestUpdate();
|
|
912
|
+
return true;
|
|
913
|
+
}
|
|
914
|
+
/**
|
|
915
|
+
* Enter or Space on the active option: it shows the pressed state from its centre, held for press-hold, and is
|
|
916
|
+
* chosen — unless it is disabled, which does nothing. Returns whether there was an active option.
|
|
917
|
+
*/
|
|
918
|
+
activate(event) {
|
|
919
|
+
const option = this.active;
|
|
920
|
+
if (!option)
|
|
921
|
+
return false;
|
|
922
|
+
if (option.disabled)
|
|
923
|
+
return true;
|
|
924
|
+
this.pressOn(option, null);
|
|
925
|
+
this.press.release();
|
|
926
|
+
this.options.choose(option, event);
|
|
927
|
+
return true;
|
|
928
|
+
}
|
|
929
|
+
/** The whole of the active option in view, in the list's own scroll box and nowhere else (the page does not move). */
|
|
930
|
+
reveal() {
|
|
931
|
+
// A long list whose rooms are about to change is revealed again by the render that changes them.
|
|
932
|
+
this.revealing = this.measure();
|
|
933
|
+
const scroll = this.find('.scroll');
|
|
934
|
+
const row = this.rowOf(this.active);
|
|
935
|
+
if (!scroll || !row)
|
|
936
|
+
return;
|
|
937
|
+
// Layout offsets, not drawn boxes: the list may be growing in.
|
|
938
|
+
const top = row.offsetTop;
|
|
939
|
+
const bottom = top + row.offsetHeight;
|
|
940
|
+
if (top < scroll.scrollTop)
|
|
941
|
+
scroll.scrollTop = top;
|
|
942
|
+
else if (bottom > scroll.scrollTop + scroll.clientHeight)
|
|
943
|
+
scroll.scrollTop = bottom - scroll.clientHeight;
|
|
944
|
+
// …and a long list draws the rows around it now, not when the box says it has scrolled.
|
|
945
|
+
this.rewindow();
|
|
946
|
+
}
|
|
947
|
+
optionAt(event) {
|
|
948
|
+
const row = event.composedPath().find((node) => node instanceof HTMLElement && node.classList.contains('row')) ?? null;
|
|
949
|
+
if (!row)
|
|
950
|
+
return null;
|
|
951
|
+
const index = Number(row.dataset.index);
|
|
952
|
+
const option = this.options.model().options.find((each) => each.index === index);
|
|
953
|
+
return option ? { option, row } : null;
|
|
954
|
+
}
|
|
955
|
+
pressOn(option, at) {
|
|
956
|
+
const row = this.rowOf(option);
|
|
957
|
+
if (this.pressedRow && this.pressedRow !== row)
|
|
958
|
+
delete this.pressedRow.dataset.pressed;
|
|
959
|
+
this.pressedRow = row;
|
|
960
|
+
this.pressedOption = option;
|
|
961
|
+
this.press.press(at);
|
|
962
|
+
}
|
|
963
|
+
/**
|
|
964
|
+
* The list (SEL-24, SEL-25, SEL-37 … SEL-45, SEL-48): the placed box, the sheet, and in the box that scrolls a list
|
|
965
|
+
* box named by the field's label whose options are named by their label and described by their supporting text, each
|
|
966
|
+
* with its selected state, its disabled state, its position and the number of options; groups named by their title.
|
|
967
|
+
* The glyphs, the check and what separates the groups are kept from assistive technology.
|
|
968
|
+
*/
|
|
969
|
+
render({ labelledBy, text: drawn, inline, after, tail, busy }) {
|
|
970
|
+
const model = this.options.model();
|
|
971
|
+
const chosen = this.options.chosen();
|
|
972
|
+
const size = model.options.length;
|
|
973
|
+
// A long list draws the rows near the box that scrolls; what it skips is room of the rows' heights.
|
|
974
|
+
const windowed = this.drawn ? this.windowOf(model) : null;
|
|
975
|
+
this.windowed = !!windowed;
|
|
976
|
+
this.windowKey = windowed?.key ?? '';
|
|
977
|
+
this.drawnRows = [];
|
|
978
|
+
this.drawnTitles = [];
|
|
979
|
+
let position = 0;
|
|
980
|
+
let skipped = 0;
|
|
981
|
+
/** The room of what was skipped since the last element drawn, as one element; nothing where nothing was. */
|
|
982
|
+
const room = () => {
|
|
983
|
+
const block = skipped;
|
|
984
|
+
skipped = 0;
|
|
985
|
+
return block > 0 ? html `<div class="skipped" aria-hidden="true" style=${styleMap({ blockSize: `${block}px` })}></div>` : nothing;
|
|
986
|
+
};
|
|
987
|
+
/**
|
|
988
|
+
* Words in the direction their option or group says (`dir`): a run of their own inside the text's box, which stays
|
|
989
|
+
* placed and aligned by the layout (the row is never turned: its check stays at the layout's end). Words that say
|
|
990
|
+
* none are the box's own text, by their first strong character.
|
|
991
|
+
*/
|
|
992
|
+
const words = (dir, content) => (dir ? html `<span class="said" dir=${dir}>${content}</span>` : content);
|
|
993
|
+
const row = (option) => {
|
|
994
|
+
const id = optionId(option);
|
|
995
|
+
const selected = !!chosen && chosen.element === option.element;
|
|
996
|
+
const active = this.running && this.active?.element === option.element;
|
|
997
|
+
position += 1;
|
|
998
|
+
return html `<div
|
|
999
|
+
part="option"
|
|
1000
|
+
class=${classMap({ row: true, p: true, d: option.disabled, selected, active, kf: active && this.keyboard })}
|
|
1001
|
+
role="option"
|
|
1002
|
+
id=${id}
|
|
1003
|
+
data-index=${option.index}
|
|
1004
|
+
data-tanrei-shape
|
|
1005
|
+
lang=${option.lang || nothing}
|
|
1006
|
+
aria-selected=${selected ? 'true' : 'false'}
|
|
1007
|
+
aria-disabled=${option.disabled ? 'true' : nothing}
|
|
1008
|
+
aria-labelledby=${`${id}-label`}
|
|
1009
|
+
aria-describedby=${option.supportingText ? `${id}-supporting` : nothing}
|
|
1010
|
+
aria-posinset=${position}
|
|
1011
|
+
aria-setsize=${size}
|
|
1012
|
+
>
|
|
1013
|
+
<span class="row-content">
|
|
1014
|
+
${model.hasIcons
|
|
1015
|
+
? html `<span class="row-column leading" aria-hidden="true"><span part="option-leading-icon" class="option-icon"><span class="ink">${option.leadingIcon}</span></span></span>`
|
|
1016
|
+
: nothing}
|
|
1017
|
+
<span class="row-text"
|
|
1018
|
+
><span part="option-label" class="option-label" id=${`${id}-label`}>${words(option.dir, drawn ? drawn(option) : option.label)}</span>${option.supportingText
|
|
1019
|
+
? html `<span part="option-supporting-text" class="option-supporting" id=${`${id}-supporting`}>${words(option.dir, option.supportingText)}</span>`
|
|
1020
|
+
: nothing}</span
|
|
1021
|
+
>
|
|
1022
|
+
<span class="row-column mark" aria-hidden="true"><span part="mark" class="check"><span class="ink">check</span></span></span>
|
|
1023
|
+
</span>
|
|
1024
|
+
</div>`;
|
|
1025
|
+
};
|
|
1026
|
+
/** An option's row — or, in a long list, its room where it is not drawn (it still has its position). */
|
|
1027
|
+
const each = (option) => {
|
|
1028
|
+
if (!windowed)
|
|
1029
|
+
return row(option);
|
|
1030
|
+
if (!windowed.has(position)) {
|
|
1031
|
+
position += 1;
|
|
1032
|
+
skipped += this.rowExtent(option);
|
|
1033
|
+
return nothing;
|
|
1034
|
+
}
|
|
1035
|
+
this.drawnRows.push(option);
|
|
1036
|
+
return html `${room()}${row(option)}`;
|
|
1037
|
+
};
|
|
1038
|
+
// Closed, the list box is empty: the rows are drawn by the render that opens the list.
|
|
1039
|
+
const shown = this.drawn ? model.entries : [];
|
|
1040
|
+
const entries = shown.map((entry, index) => {
|
|
1041
|
+
const before = shown[index - 1];
|
|
1042
|
+
// A group is told from an adjacent group, and from an adjacent option outside any group; never before the first
|
|
1043
|
+
// element or after the last.
|
|
1044
|
+
const parted = !!before && (entry.kind === 'group' || before.kind === 'group');
|
|
1045
|
+
const separator = parted ? html `<div part="divider" class="divider" aria-hidden="true"></div><div class="gap" aria-hidden="true"></div>` : nothing;
|
|
1046
|
+
if (entry.kind === 'option') {
|
|
1047
|
+
if (!windowed)
|
|
1048
|
+
return html `${separator}${row(entry.option)}`;
|
|
1049
|
+
if (windowed.has(position))
|
|
1050
|
+
return html `${room()}${separator}${each(entry.option)}`;
|
|
1051
|
+
if (parted)
|
|
1052
|
+
skipped += this.separatorHeight;
|
|
1053
|
+
return each(entry.option);
|
|
1054
|
+
}
|
|
1055
|
+
const { group } = entry;
|
|
1056
|
+
const titled = !!group.title;
|
|
1057
|
+
// A long list's group that draws none of its options is room: its title and what separates it with them.
|
|
1058
|
+
if (windowed && !group.options.some((_, at) => windowed.has(position + at))) {
|
|
1059
|
+
skipped += (parted ? this.separatorHeight : 0) + this.titleExtent(group);
|
|
1060
|
+
for (const option of group.options)
|
|
1061
|
+
each(option);
|
|
1062
|
+
return nothing;
|
|
1063
|
+
}
|
|
1064
|
+
const lead = room();
|
|
1065
|
+
if (windowed && titled)
|
|
1066
|
+
this.drawnTitles.push(group.element);
|
|
1067
|
+
const rows = group.options.map(each);
|
|
1068
|
+
return html `${lead}${separator}
|
|
1069
|
+
<div part="group" class="group" role="group" lang=${group.lang || nothing} aria-labelledby=${titled ? `group-${group.index}` : nothing}>
|
|
1070
|
+
${titled ? html `<div part="group-title" class="group-title" id=${`group-${group.index}`} role="presentation">${words(group.dir, group.title)}</div>` : nothing}${rows}${room()}
|
|
1071
|
+
</div>`;
|
|
1072
|
+
});
|
|
1073
|
+
const rest = room();
|
|
1074
|
+
// The press that would take focus from the field is cancelled on the whole placed box, not on the sheet alone: while
|
|
1075
|
+
// the sheet grows in, the box already has its full size and the sheet inside it does not, and a press on the part
|
|
1076
|
+
// the sheet has not reached yet lands on the box (SEL-26).
|
|
1077
|
+
// The placed box is only a box: without `role="none"` a popover element with no role is exposed as an unnamed group
|
|
1078
|
+
// around the list box.
|
|
1079
|
+
return html `<div class="surface" popover=${inline ? nothing : 'manual'} role="none" @mousedown=${this.onMouseDown} @toggle=${this.onSurfaceToggle}>
|
|
1080
|
+
<div class="motion">
|
|
1081
|
+
<div
|
|
1082
|
+
part="list"
|
|
1083
|
+
class=${classMap({ list: true, tail: !!tail, bare: !!tail && size === 0 })}
|
|
1084
|
+
data-tanrei-shape
|
|
1085
|
+
@pointerdown=${this.onPointerDown}
|
|
1086
|
+
@pointerup=${this.onPointerUp}
|
|
1087
|
+
@pointercancel=${this.onPointerUp}
|
|
1088
|
+
@pointermove=${this.onPointerMove}
|
|
1089
|
+
@click=${this.onClick}
|
|
1090
|
+
>
|
|
1091
|
+
<div class="scroll" role="listbox" id="list" aria-labelledby=${labelledBy} aria-busy=${busy ? 'true' : nothing} @scroll=${this.onScroll}>${entries}${rest}</div>
|
|
1092
|
+
${after ?? nothing}
|
|
1093
|
+
</div>
|
|
1094
|
+
</div>
|
|
1095
|
+
</div>`;
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
//# sourceMappingURL=option-list.js.map
|