@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,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How long typed characters add up to one typeahead search (LST-15, MNU-7: "within one second of each other"). A
|
|
3
|
+
* behaviour of the spec, not a design value: no system re-values it.
|
|
4
|
+
*/
|
|
5
|
+
export const TYPEAHEAD_WINDOW = 1000;
|
|
6
|
+
/**
|
|
7
|
+
* The keyboard model of a column of items (a list with interactive items or options, LST-15; an open menu, MNU-7):
|
|
8
|
+
* Down and Up Arrow move to the next and previous item that takes focus — wrapping at the ends or stopping there —
|
|
9
|
+
* Home and End to the first and last, and printable characters typed within `TYPEAHEAD_WINDOW` of each other to the
|
|
10
|
+
* next item whose text begins with them (case-insensitive; a new search starts after the current item, a longer one
|
|
11
|
+
* keeps matching from it). Moving focus never activates or selects: the component moves focus to the index returned.
|
|
12
|
+
*
|
|
13
|
+
* One instance per column: it remembers what was typed.
|
|
14
|
+
*/
|
|
15
|
+
export class RovingKeys {
|
|
16
|
+
/**
|
|
17
|
+
* `repeat`: one character typed again within the window moves on to the next item that begins with it (SEL-33),
|
|
18
|
+
* where otherwise the characters add up to a search for a text that begins with both.
|
|
19
|
+
*/
|
|
20
|
+
constructor(options) {
|
|
21
|
+
this.options = options;
|
|
22
|
+
this.typed = '';
|
|
23
|
+
this.at = Number.NEGATIVE_INFINITY;
|
|
24
|
+
}
|
|
25
|
+
/** Whether characters typed now continue a search: a Space then belongs to it, not to the activation (see `target`). */
|
|
26
|
+
searching(now = performance.now()) {
|
|
27
|
+
return now - this.at <= TYPEAHEAD_WINDOW;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The index `key` moves focus to from `current` (-1: no item has focus yet), or `null` when the key is not one of the
|
|
31
|
+
* column's. A Space that does not continue a search is not the column's: it activates the focused item.
|
|
32
|
+
*/
|
|
33
|
+
target(key, current, items, now = performance.now()) {
|
|
34
|
+
const order = items.flatMap((item, index) => (item.focusable ? [index] : []));
|
|
35
|
+
if (order.length === 0)
|
|
36
|
+
return null;
|
|
37
|
+
const at = order.indexOf(current);
|
|
38
|
+
const { wrap } = this.options;
|
|
39
|
+
switch (key) {
|
|
40
|
+
case 'ArrowDown':
|
|
41
|
+
return at < 0 ? order[0] : wrap ? order[(at + 1) % order.length] : order[Math.min(at + 1, order.length - 1)];
|
|
42
|
+
case 'ArrowUp':
|
|
43
|
+
return at < 0 ? order[order.length - 1] : wrap ? order[(at - 1 + order.length) % order.length] : order[Math.max(at - 1, 0)];
|
|
44
|
+
case 'Home':
|
|
45
|
+
return order[0];
|
|
46
|
+
case 'End':
|
|
47
|
+
return order[order.length - 1];
|
|
48
|
+
}
|
|
49
|
+
// A printable character is one code point (`key` of a letter, a digit, punctuation, a Space).
|
|
50
|
+
if ([...key].length !== 1)
|
|
51
|
+
return null;
|
|
52
|
+
const continues = this.searching(now);
|
|
53
|
+
if (key === ' ' && !continues)
|
|
54
|
+
return null;
|
|
55
|
+
const typed = continues ? this.typed + key.toLowerCase() : key.toLowerCase();
|
|
56
|
+
this.typed = typed;
|
|
57
|
+
this.at = now;
|
|
58
|
+
// One character typed again is that character once more, looked for after the current item.
|
|
59
|
+
const again = !!this.options.repeat && [...typed].length > 1 && [...typed].every((character) => character === [...typed][0]);
|
|
60
|
+
const text = again ? [...typed][0] : typed;
|
|
61
|
+
const from = at < 0 ? 0 : [...text].length === 1 ? at + 1 : at;
|
|
62
|
+
for (let step = 0; step < order.length; step += 1) {
|
|
63
|
+
const index = order[(from + step) % order.length];
|
|
64
|
+
if (items[index].label.trim().toLowerCase().startsWith(text))
|
|
65
|
+
return index;
|
|
66
|
+
}
|
|
67
|
+
// Nothing matches: the key was the column's all the same (it is not typed into anything), focus stays.
|
|
68
|
+
return current >= 0 ? current : null;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=roving.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"roving.js","sourceRoot":"","sources":["../../src/primitives/roving.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAUrC;;;;;;;;GAQG;AACH,MAAM,OAAO,UAAU;IAIrB;;;OAGG;IACH,YAA6B,OAA4C;QAA5C,YAAO,GAAP,OAAO,CAAqC;QAPjE,UAAK,GAAG,EAAE,CAAC;QACX,OAAE,GAAG,MAAM,CAAC,iBAAiB,CAAC;IAMsC,CAAC;IAE7E,wHAAwH;IACxH,SAAS,CAAC,GAAG,GAAG,WAAW,CAAC,GAAG,EAAE;QAC/B,OAAO,GAAG,GAAG,IAAI,CAAC,EAAE,IAAI,gBAAgB,CAAC;IAC3C,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,GAAW,EAAE,OAAe,EAAE,KAA4B,EAAE,GAAG,GAAG,WAAW,CAAC,GAAG,EAAE;QACxF,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAC9E,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QACpC,MAAM,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAClC,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;QAC9B,QAAQ,GAAG,EAAE,CAAC;YACZ,KAAK,WAAW;gBACd,OAAO,EAAE,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type FieldControlOptions } from './field.js';
|
|
3
|
+
import type { Point } from './ripple.js';
|
|
4
|
+
import { type StateSelector } from './states.js';
|
|
5
|
+
/**
|
|
6
|
+
* Selection controls (checkbox, radio button, switch): a form-associated element whose semantics
|
|
7
|
+
* are a native `<input>` in its shadow root (axe cannot see ElementInternals roles),
|
|
8
|
+
* wrapped in a `<label>` so that a click on the visible label — or on the minimum target around the control — activates
|
|
9
|
+
* the input as a native label does. The anatomy every one of them shares, and that the pieces below assume:
|
|
10
|
+
*
|
|
11
|
+
* <label class="root"> hover, opacity; carries the current state's value of every part (--_<key>)
|
|
12
|
+
* <span class="control"> the control's layout box; the minimum target (::before); press-hold carrier
|
|
13
|
+
* <input class="native"> role, state, focus, keyboard, disabled — invisible, clicks reach it through the label
|
|
14
|
+
* <span class="container"> the round state layer: data-pressed, the ripple
|
|
15
|
+
* …the component's own parts
|
|
16
|
+
* <span class="label"> the visible label, when there is one
|
|
17
|
+
*
|
|
18
|
+
* `SelectionController` is the element's side (form value, fieldset-disabled, a click on the host, Enter); the CSS
|
|
19
|
+
* helpers are its styles' side (the condition blocks, the state rules on `.root`, the label).
|
|
20
|
+
*/
|
|
21
|
+
/** The interaction states as the token names say them (`<condition>-<state>-<part>`), and their private suffix. */
|
|
22
|
+
export declare const SELECTION_STATES: {
|
|
23
|
+
readonly '': '-r';
|
|
24
|
+
readonly hovered: '-h';
|
|
25
|
+
readonly focused: '-f';
|
|
26
|
+
readonly pressed: '-p';
|
|
27
|
+
readonly disabled: '-d';
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* One condition's parts in every state, as private custom properties under `selector`: `--_<key><suffix>`
|
|
31
|
+
* reads `<prefix>-<condition>-[<state>-]<part>` — `--_c-h` is the container of this condition, hovered.
|
|
32
|
+
*/
|
|
33
|
+
export declare function conditionBlock(prefix: string, condition: string, parts: Record<string, string>, selector: string): string;
|
|
34
|
+
/**
|
|
35
|
+
* Where each state is read (for `stateRules()`): hover is the whole `.root` — the label is part of the hit area — focus
|
|
36
|
+
* and disabled are the native input's, and pressed is `data-pressed` on the container (`PressController`). `:where()`
|
|
37
|
+
* keeps every state rule at the resting rule's specificity, so the order `stateRules()` writes them in is the precedence.
|
|
38
|
+
*/
|
|
39
|
+
export declare const selectionState: (state: string) => string;
|
|
40
|
+
/**
|
|
41
|
+
* The state rules of a component whose conditions are its state variants: each state sets, on `root`, the
|
|
42
|
+
* current value of every part (`--_<key>`, from the condition block's `--_<key><suffix>`) from that state's tokens of
|
|
43
|
+
* the current condition, the component's opacity and its container shape (`--_shape`, `--_shape-pill`, which the
|
|
44
|
+
* container names with `selectionContainerShape`). Under ripple and dim everything but the container color (`container`
|
|
45
|
+
* names its key) comes from the pressed tokens; under none nothing changes. `on` names where each state is read (see
|
|
46
|
+
* `stateRules()`); every selector it returns must have the same specificity, so that the order is the precedence.
|
|
47
|
+
*/
|
|
48
|
+
export declare function conditionStates(prefix: string, parts: Record<string, string>, { container, root, on }: {
|
|
49
|
+
container: string;
|
|
50
|
+
root: string;
|
|
51
|
+
on: StateSelector;
|
|
52
|
+
}): string;
|
|
53
|
+
/**
|
|
54
|
+
* The state rules of a selection control (CHK-5/8/9/10, RAD-7/10/11/12, SWT-3/6/7/8): `conditionStates()` on `.root`,
|
|
55
|
+
* each state read where `selectionState` says. The container takes the pressed color without a transition in.
|
|
56
|
+
*/
|
|
57
|
+
export declare function selectionStates(prefix: string, parts: Record<string, string>, container: string): CSSResult;
|
|
58
|
+
/** The container names the current state's shape token, the way `cornerRadius()` names one. */
|
|
59
|
+
export declare const selectionContainerShape: string;
|
|
60
|
+
/**
|
|
61
|
+
* The root and its label (CHK-15, RAD-17, SWT-15): the control, then the label at its inline end `gap` away — RTL
|
|
62
|
+
* mirrors the order — in the label's text role, wrapping rather than truncating. The label's first line is centered on
|
|
63
|
+
* the control (`block` is the control's block size), and every line after it continues below.
|
|
64
|
+
*/
|
|
65
|
+
export declare function selectionLabel(prefix: string, block: string): CSSResult;
|
|
66
|
+
/**
|
|
67
|
+
* The ripple's origin for `PressController` (CHK-10, RAD-12, SWT-8): the point of contact when it is on the round
|
|
68
|
+
* container, its center when the press is outside it — on the label, or on a switch's track away from the handle.
|
|
69
|
+
*/
|
|
70
|
+
export declare const selectionRippleOrigin: (container: () => Element | null) => (at: Point) => Point | null;
|
|
71
|
+
/**
|
|
72
|
+
* CHK-5 / CHK-13 (RAD-7 / RAD-15, SWT-3 / SWT-13): a part that both the interaction states and the condition recolor
|
|
73
|
+
* changes over the state motion, except when the condition changes, which takes the selection motion. CSS cannot tell
|
|
74
|
+
* the two apart, so the element marks a change of condition: `data-condition-change` on `.root` from the change until
|
|
75
|
+
* two frames later — long enough for the transitions to start with the selection's timing (a running transition keeps
|
|
76
|
+
* the timing it started with), and not so long that a hover right after it would take it. Call it before the update
|
|
77
|
+
* that draws the new condition is styled (in `willUpdate`, or in the event that changed it).
|
|
78
|
+
*/
|
|
79
|
+
export declare function markConditionChange(root: Element | null | undefined): void;
|
|
80
|
+
/**
|
|
81
|
+
* The timing of the parts that the states and the condition both recolor (see `markConditionChange`): on `.root`,
|
|
82
|
+
* `--_recolor-duration` and `--_recolor-easing` are the state motion, and the selection motion while the condition changes.
|
|
83
|
+
*/
|
|
84
|
+
export declare function recolorTiming(prefix: string): CSSResult;
|
|
85
|
+
/** What the controller needs from the element. */
|
|
86
|
+
export interface SelectionHost extends ReactiveControllerHost, HTMLElement {
|
|
87
|
+
disabled: boolean;
|
|
88
|
+
readonly isUpdatePending: boolean;
|
|
89
|
+
readonly renderRoot: HTMLElement | DocumentFragment;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* The element's side of a selection control, as a Lit controller: its `ElementInternals` (form value, validity), the
|
|
93
|
+
* disabled state an ancestor `<fieldset disabled>` gives it, a click on the host itself (a `<label for>` in the light
|
|
94
|
+
* DOM, a dispatched click) activating the native input once, and Enter, which on the web submits the form instead of
|
|
95
|
+
* activating the control (CHK-1, RAD-1, SWT-1). The element keeps `static formAssociated = true` and forwards its form
|
|
96
|
+
* callbacks.
|
|
97
|
+
*/
|
|
98
|
+
export declare class SelectionController implements ReactiveController {
|
|
99
|
+
private readonly host;
|
|
100
|
+
private readonly input;
|
|
101
|
+
readonly internals: ElementInternals;
|
|
102
|
+
/** Set by an ancestor `<fieldset disabled>` (the element's `formDisabledCallback`). */
|
|
103
|
+
formDisabled: boolean;
|
|
104
|
+
/**
|
|
105
|
+
* What a field or a field group around the control gives it (src/primitives/field.ts): the name while it has none of
|
|
106
|
+
* its own, the description, the invalid and required states, and `disabled` (FLD-8, FLD-10, FLD-11, FLD-14, FGR-8,
|
|
107
|
+
* FGR-14). The element reads it where it renders the native input.
|
|
108
|
+
*/
|
|
109
|
+
readonly field: FieldControlController;
|
|
110
|
+
constructor(host: SelectionHost, input: () => HTMLInputElement | null, field?: FieldControlOptions);
|
|
111
|
+
hostConnected(): void;
|
|
112
|
+
/** Disabled by its own `disabled`, by a disabled fieldset around it, or by the field or field group that frames it. */
|
|
113
|
+
get disabled(): boolean;
|
|
114
|
+
/** The form this element belongs to, if any. */
|
|
115
|
+
get form(): HTMLFormElement | null;
|
|
116
|
+
/** `element.click()`: activates the native input as a person would, and does nothing while disabled. */
|
|
117
|
+
click(): void;
|
|
118
|
+
/** The value submitted with the form (`null`: nothing), and what a restored form state is. */
|
|
119
|
+
setFormValue(value: string | null, state: string): void;
|
|
120
|
+
/** The native input's validity is the element's (`required`, as the native control has it). */
|
|
121
|
+
syncValidity(): void;
|
|
122
|
+
formDisabledCallback(disabled: boolean): void;
|
|
123
|
+
/**
|
|
124
|
+
* Enter does not activate a selection control on the web: in a form it submits it (the native checkbox's convention)
|
|
125
|
+
* — through the form's default button, which a disabled one stops (BTN-30).
|
|
126
|
+
*/
|
|
127
|
+
readonly onKeyDown: (event: KeyboardEvent) => void;
|
|
128
|
+
/**
|
|
129
|
+
* A click aimed at the host itself — a light-DOM `<label for>` naming it, or a click dispatched on it — activates the
|
|
130
|
+
* native input, once; that click then arrives from the input. A click from inside the shadow root already is the
|
|
131
|
+
* input's (or the label's, which the browser turns into the input's).
|
|
132
|
+
*/
|
|
133
|
+
private readonly onHostClick;
|
|
134
|
+
}
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import { unsafeCSS } from 'lit';
|
|
2
|
+
import { cornerRadius } from '../styles/shape.js';
|
|
3
|
+
import { formOf, pressDefaultButton } from './default-button.js';
|
|
4
|
+
import { FieldControlController } from './field.js';
|
|
5
|
+
import { takeFormDisabled } from './form-disabled.js';
|
|
6
|
+
import { stateRules } from './states.js';
|
|
7
|
+
/**
|
|
8
|
+
* Selection controls (checkbox, radio button, switch): a form-associated element whose semantics
|
|
9
|
+
* are a native `<input>` in its shadow root (axe cannot see ElementInternals roles),
|
|
10
|
+
* wrapped in a `<label>` so that a click on the visible label — or on the minimum target around the control — activates
|
|
11
|
+
* the input as a native label does. The anatomy every one of them shares, and that the pieces below assume:
|
|
12
|
+
*
|
|
13
|
+
* <label class="root"> hover, opacity; carries the current state's value of every part (--_<key>)
|
|
14
|
+
* <span class="control"> the control's layout box; the minimum target (::before); press-hold carrier
|
|
15
|
+
* <input class="native"> role, state, focus, keyboard, disabled — invisible, clicks reach it through the label
|
|
16
|
+
* <span class="container"> the round state layer: data-pressed, the ripple
|
|
17
|
+
* …the component's own parts
|
|
18
|
+
* <span class="label"> the visible label, when there is one
|
|
19
|
+
*
|
|
20
|
+
* `SelectionController` is the element's side (form value, fieldset-disabled, a click on the host, Enter); the CSS
|
|
21
|
+
* helpers are its styles' side (the condition blocks, the state rules on `.root`, the label).
|
|
22
|
+
*/
|
|
23
|
+
/** The interaction states as the token names say them (`<condition>-<state>-<part>`), and their private suffix. */
|
|
24
|
+
export const SELECTION_STATES = { '': '-r', hovered: '-h', focused: '-f', pressed: '-p', disabled: '-d' };
|
|
25
|
+
/**
|
|
26
|
+
* One condition's parts in every state, as private custom properties under `selector`: `--_<key><suffix>`
|
|
27
|
+
* reads `<prefix>-<condition>-[<state>-]<part>` — `--_c-h` is the container of this condition, hovered.
|
|
28
|
+
*/
|
|
29
|
+
export function conditionBlock(prefix, condition, parts, selector) {
|
|
30
|
+
return `${selector} {\n${Object.entries(SELECTION_STATES)
|
|
31
|
+
.flatMap(([state, suffix]) => Object.entries(parts).map(([key, part]) => ` --_${key}${suffix}: var(${prefix}-${condition}-${state ? `${state}-` : ''}${part});`))
|
|
32
|
+
.join('\n')}\n}`;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Where each state is read (for `stateRules()`): hover is the whole `.root` — the label is part of the hit area — focus
|
|
36
|
+
* and disabled are the native input's, and pressed is `data-pressed` on the container (`PressController`). `:where()`
|
|
37
|
+
* keeps every state rule at the resting rule's specificity, so the order `stateRules()` writes them in is the precedence.
|
|
38
|
+
*/
|
|
39
|
+
export const selectionState = (state) => state === ':hover' ? '.root:where(:hover)' : `.root:where(:has(${state.startsWith('[') ? '.container' : 'input'}${state}))`;
|
|
40
|
+
/**
|
|
41
|
+
* The state rules of a component whose conditions are its state variants: each state sets, on `root`, the
|
|
42
|
+
* current value of every part (`--_<key>`, from the condition block's `--_<key><suffix>`) from that state's tokens of
|
|
43
|
+
* the current condition, the component's opacity and its container shape (`--_shape`, `--_shape-pill`, which the
|
|
44
|
+
* container names with `selectionContainerShape`). Under ripple and dim everything but the container color (`container`
|
|
45
|
+
* names its key) comes from the pressed tokens; under none nothing changes. `on` names where each state is read (see
|
|
46
|
+
* `stateRules()`); every selector it returns must have the same specificity, so that the order is the precedence.
|
|
47
|
+
*/
|
|
48
|
+
export function conditionStates(prefix, parts, { container, root, on }) {
|
|
49
|
+
const set = (suffix, skip) => Object.keys(parts)
|
|
50
|
+
.filter((key) => key !== skip)
|
|
51
|
+
.map((key) => `\n --_${key}: var(--_${key}${suffix});`)
|
|
52
|
+
.join('');
|
|
53
|
+
const shape = (state) => `
|
|
54
|
+
--_shape: var(${prefix}-${state}-container-shape);
|
|
55
|
+
--_shape-pill: var(${prefix}-${state}-container-shape-pill, 0);
|
|
56
|
+
opacity: var(${prefix}-${state}-opacity);`;
|
|
57
|
+
return `
|
|
58
|
+
${root} {${set('-r')}
|
|
59
|
+
--_shape: var(${prefix}-container-shape);
|
|
60
|
+
--_shape-pill: var(${prefix}-container-shape-pill, 0);
|
|
61
|
+
}
|
|
62
|
+
${stateRules(on, {
|
|
63
|
+
hovered: `${set('-h')}${shape('hovered')}`,
|
|
64
|
+
focused: `${set('-f')}${shape('focused')}`,
|
|
65
|
+
pressed: `${set('-p')}${shape('pressed')}`,
|
|
66
|
+
pressedContent: `${set('-p', container)}${shape('pressed')}`,
|
|
67
|
+
disabled: `
|
|
68
|
+
cursor: default;${set('-d')}${shape('disabled')}`,
|
|
69
|
+
})}`;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The state rules of a selection control (CHK-5/8/9/10, RAD-7/10/11/12, SWT-3/6/7/8): `conditionStates()` on `.root`,
|
|
73
|
+
* each state read where `selectionState` says. The container takes the pressed color without a transition in.
|
|
74
|
+
*/
|
|
75
|
+
export function selectionStates(prefix, parts, container) {
|
|
76
|
+
return unsafeCSS(`${conditionStates(prefix, parts, { container, root: '.root', on: selectionState })}
|
|
77
|
+
.container[data-pressed]:not([data-pressed='none']) {
|
|
78
|
+
transition-duration: 0s;
|
|
79
|
+
}
|
|
80
|
+
`);
|
|
81
|
+
}
|
|
82
|
+
/** The container names the current state's shape token, the way `cornerRadius()` names one. */
|
|
83
|
+
export const selectionContainerShape = cornerRadius('--_shape');
|
|
84
|
+
/**
|
|
85
|
+
* The root and its label (CHK-15, RAD-17, SWT-15): the control, then the label at its inline end `gap` away — RTL
|
|
86
|
+
* mirrors the order — in the label's text role, wrapping rather than truncating. The label's first line is centered on
|
|
87
|
+
* the control (`block` is the control's block size), and every line after it continues below.
|
|
88
|
+
*/
|
|
89
|
+
export function selectionLabel(prefix, block) {
|
|
90
|
+
return unsafeCSS(`
|
|
91
|
+
:host {
|
|
92
|
+
display: inline-flex;
|
|
93
|
+
vertical-align: middle;
|
|
94
|
+
max-inline-size: 100%;
|
|
95
|
+
}
|
|
96
|
+
.root {
|
|
97
|
+
display: flex;
|
|
98
|
+
flex: 1 1 auto;
|
|
99
|
+
min-inline-size: 0;
|
|
100
|
+
align-items: flex-start;
|
|
101
|
+
gap: var(${prefix}-label-gap);
|
|
102
|
+
cursor: pointer;
|
|
103
|
+
-webkit-user-select: none;
|
|
104
|
+
user-select: none;
|
|
105
|
+
-webkit-tap-highlight-color: transparent;
|
|
106
|
+
transition: opacity var(${prefix}-motion-state-duration) var(${prefix}-motion-state-easing);
|
|
107
|
+
}
|
|
108
|
+
.control {
|
|
109
|
+
position: relative;
|
|
110
|
+
flex: none;
|
|
111
|
+
}
|
|
112
|
+
${recolorTiming(prefix)}
|
|
113
|
+
.native {
|
|
114
|
+
all: unset;
|
|
115
|
+
position: absolute;
|
|
116
|
+
inset: 0;
|
|
117
|
+
margin: 0;
|
|
118
|
+
opacity: 0;
|
|
119
|
+
/* A click anywhere on the control reaches the input through the label, like a click on the label's text. */
|
|
120
|
+
pointer-events: none;
|
|
121
|
+
appearance: none;
|
|
122
|
+
}
|
|
123
|
+
/* The control is centered on the label's first line: the root carries the label's text style, so 1lh is the label's
|
|
124
|
+
line height on the control too. A line shorter than the control is padded down to its middle; a taller one moves
|
|
125
|
+
the control down to the line's middle. */
|
|
126
|
+
.root {
|
|
127
|
+
font: var(${prefix}-label-typescale-font);
|
|
128
|
+
letter-spacing: var(${prefix}-label-typescale-letter-spacing);
|
|
129
|
+
}
|
|
130
|
+
.root:has(.label) .control {
|
|
131
|
+
margin-block-start: max(0px, calc((1lh - ${block}) / 2));
|
|
132
|
+
}
|
|
133
|
+
.label {
|
|
134
|
+
flex: 0 1 auto;
|
|
135
|
+
min-inline-size: 0;
|
|
136
|
+
padding-block: max(0px, calc((${block} - 1lh) / 2));
|
|
137
|
+
color: var(--_l);
|
|
138
|
+
overflow-wrap: break-word;
|
|
139
|
+
transition: color var(--_recolor-duration) var(--_recolor-easing);
|
|
140
|
+
}
|
|
141
|
+
@media (prefers-reduced-motion: reduce) {
|
|
142
|
+
.root,
|
|
143
|
+
.label {
|
|
144
|
+
transition: none;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
@media (forced-colors: active) {
|
|
148
|
+
.label {
|
|
149
|
+
color: CanvasText;
|
|
150
|
+
}
|
|
151
|
+
.root:has(input:disabled) .label {
|
|
152
|
+
color: GrayText;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
`);
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* The ripple's origin for `PressController` (CHK-10, RAD-12, SWT-8): the point of contact when it is on the round
|
|
159
|
+
* container, its center when the press is outside it — on the label, or on a switch's track away from the handle.
|
|
160
|
+
*/
|
|
161
|
+
export const selectionRippleOrigin = (container) => (at) => {
|
|
162
|
+
const box = container()?.getBoundingClientRect();
|
|
163
|
+
if (!box)
|
|
164
|
+
return null;
|
|
165
|
+
const [cx, cy] = [box.left + box.width / 2, box.top + box.height / 2];
|
|
166
|
+
return Math.hypot(at.x - cx, at.y - cy) <= Math.min(box.width, box.height) / 2 ? at : null;
|
|
167
|
+
};
|
|
168
|
+
/** The latest change of condition on each root, so that only the last one's frames remove the mark. */
|
|
169
|
+
const changes = new WeakMap();
|
|
170
|
+
/**
|
|
171
|
+
* CHK-5 / CHK-13 (RAD-7 / RAD-15, SWT-3 / SWT-13): a part that both the interaction states and the condition recolor
|
|
172
|
+
* changes over the state motion, except when the condition changes, which takes the selection motion. CSS cannot tell
|
|
173
|
+
* the two apart, so the element marks a change of condition: `data-condition-change` on `.root` from the change until
|
|
174
|
+
* two frames later — long enough for the transitions to start with the selection's timing (a running transition keeps
|
|
175
|
+
* the timing it started with), and not so long that a hover right after it would take it. Call it before the update
|
|
176
|
+
* that draws the new condition is styled (in `willUpdate`, or in the event that changed it).
|
|
177
|
+
*/
|
|
178
|
+
export function markConditionChange(root) {
|
|
179
|
+
if (!root)
|
|
180
|
+
return;
|
|
181
|
+
root.setAttribute('data-condition-change', '');
|
|
182
|
+
const token = (changes.get(root) ?? 0) + 1;
|
|
183
|
+
changes.set(root, token);
|
|
184
|
+
requestAnimationFrame(() => requestAnimationFrame(() => {
|
|
185
|
+
if (changes.get(root) === token)
|
|
186
|
+
root.removeAttribute('data-condition-change');
|
|
187
|
+
}));
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* The timing of the parts that the states and the condition both recolor (see `markConditionChange`): on `.root`,
|
|
191
|
+
* `--_recolor-duration` and `--_recolor-easing` are the state motion, and the selection motion while the condition changes.
|
|
192
|
+
*/
|
|
193
|
+
export function recolorTiming(prefix) {
|
|
194
|
+
return unsafeCSS(`
|
|
195
|
+
.root {
|
|
196
|
+
--_recolor-duration: var(${prefix}-motion-state-duration);
|
|
197
|
+
--_recolor-easing: var(${prefix}-motion-state-easing);
|
|
198
|
+
}
|
|
199
|
+
.root[data-condition-change] {
|
|
200
|
+
--_recolor-duration: var(${prefix}-motion-selection-duration);
|
|
201
|
+
--_recolor-easing: var(${prefix}-motion-selection-easing);
|
|
202
|
+
}
|
|
203
|
+
`);
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* The element's side of a selection control, as a Lit controller: its `ElementInternals` (form value, validity), the
|
|
207
|
+
* disabled state an ancestor `<fieldset disabled>` gives it, a click on the host itself (a `<label for>` in the light
|
|
208
|
+
* DOM, a dispatched click) activating the native input once, and Enter, which on the web submits the form instead of
|
|
209
|
+
* activating the control (CHK-1, RAD-1, SWT-1). The element keeps `static formAssociated = true` and forwards its form
|
|
210
|
+
* callbacks.
|
|
211
|
+
*/
|
|
212
|
+
export class SelectionController {
|
|
213
|
+
constructor(host, input, field = {}) {
|
|
214
|
+
this.host = host;
|
|
215
|
+
this.input = input;
|
|
216
|
+
/** Set by an ancestor `<fieldset disabled>` (the element's `formDisabledCallback`). */
|
|
217
|
+
this.formDisabled = false;
|
|
218
|
+
/**
|
|
219
|
+
* Enter does not activate a selection control on the web: in a form it submits it (the native checkbox's convention)
|
|
220
|
+
* — through the form's default button, which a disabled one stops (BTN-30).
|
|
221
|
+
*/
|
|
222
|
+
this.onKeyDown = (event) => {
|
|
223
|
+
if (event.key !== 'Enter' || event.repeat)
|
|
224
|
+
return;
|
|
225
|
+
event.preventDefault();
|
|
226
|
+
// In the shadow root of a form-associated element — a checkbox group's select-all checkbox — the form is that
|
|
227
|
+
// element's (src/primitives/default-button.ts, `formOf`).
|
|
228
|
+
const form = formOf(this.host, this.form);
|
|
229
|
+
if (form)
|
|
230
|
+
pressDefaultButton(form);
|
|
231
|
+
};
|
|
232
|
+
/**
|
|
233
|
+
* A click aimed at the host itself — a light-DOM `<label for>` naming it, or a click dispatched on it — activates the
|
|
234
|
+
* native input, once; that click then arrives from the input. A click from inside the shadow root already is the
|
|
235
|
+
* input's (or the label's, which the browser turns into the input's).
|
|
236
|
+
*/
|
|
237
|
+
this.onHostClick = (event) => {
|
|
238
|
+
if (event.composedPath()[0] !== this.host)
|
|
239
|
+
return;
|
|
240
|
+
event.stopImmediatePropagation();
|
|
241
|
+
this.click();
|
|
242
|
+
};
|
|
243
|
+
this.field = new FieldControlController(host, field);
|
|
244
|
+
this.internals = host.attachInternals();
|
|
245
|
+
host.addController(this);
|
|
246
|
+
host.addEventListener('click', this.onHostClick);
|
|
247
|
+
}
|
|
248
|
+
hostConnected() {
|
|
249
|
+
// Nothing to do on connection: the element forwards its form callbacks, and a click on the host is heard from the start.
|
|
250
|
+
}
|
|
251
|
+
/** Disabled by its own `disabled`, by a disabled fieldset around it, or by the field or field group that frames it. */
|
|
252
|
+
get disabled() {
|
|
253
|
+
return this.host.disabled || this.formDisabled || this.field.disabled;
|
|
254
|
+
}
|
|
255
|
+
/** The form this element belongs to, if any. */
|
|
256
|
+
get form() {
|
|
257
|
+
return this.internals.form;
|
|
258
|
+
}
|
|
259
|
+
/** `element.click()`: activates the native input as a person would, and does nothing while disabled. */
|
|
260
|
+
click() {
|
|
261
|
+
if (!this.disabled)
|
|
262
|
+
this.input()?.click();
|
|
263
|
+
}
|
|
264
|
+
/** The value submitted with the form (`null`: nothing), and what a restored form state is. */
|
|
265
|
+
setFormValue(value, state) {
|
|
266
|
+
// Disabled, it submits nothing — said here too: the platform leaves a disabled element out by its attribute, which
|
|
267
|
+
// waits a frame where the element holds focus (disabled-while-focused.ts).
|
|
268
|
+
this.internals.setFormValue(this.host.disabled ? null : value, state);
|
|
269
|
+
}
|
|
270
|
+
/** The native input's validity is the element's (`required`, as the native control has it). */
|
|
271
|
+
syncValidity() {
|
|
272
|
+
const input = this.input();
|
|
273
|
+
if (!input)
|
|
274
|
+
return;
|
|
275
|
+
if (input.validity.valid)
|
|
276
|
+
this.internals.setValidity({});
|
|
277
|
+
else
|
|
278
|
+
this.internals.setValidity(input.validity, input.validationMessage, input);
|
|
279
|
+
}
|
|
280
|
+
formDisabledCallback(disabled) {
|
|
281
|
+
takeFormDisabled(this.host, disabled, (value) => {
|
|
282
|
+
this.formDisabled = value;
|
|
283
|
+
this.host.requestUpdate();
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
//# sourceMappingURL=selection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selection.js","sourceRoot":"","sources":["../../src/primitives/selection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwE,SAAS,EAAE,MAAM,KAAK,CAAC;AACtG,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,sBAAsB,EAA4B,MAAM,YAAY,CAAC;AAC9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAsB,UAAU,EAAE,MAAM,aAAa,CAAC;AAE7D;;;;;;;;;;;;;;;GAeG;AAEH,mHAAmH;AACnH,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,EAAE,EAAE,IAAI,EA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C,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,iBAAiB,EAAE,KAAK,CAAC,CAAC;IAClF,CAAC;IAED,oBAAoB,CAAC,QAAiB;QACpC,gBAAgB,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;YAC9C,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;YAC1B,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;QAC5B,CAAC,CAAC,CAAC;IACL,CAAC;CAyBF"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type CSSResult } from 'lit';
|
|
2
|
+
/** `sys.behavior.separation`. The first value is the default, and what an unknown name falls back to. */
|
|
3
|
+
export declare const SEPARATIONS: readonly ['divider', 'gap'];
|
|
4
|
+
export type Separation = (typeof SEPARATIONS)[number];
|
|
5
|
+
/** The `separation` prop of a component that reads the choice: `auto` takes the component token. */
|
|
6
|
+
export declare const SEPARATION_VALUES: readonly ["auto", "divider", "gap"];
|
|
7
|
+
export type SeparationProp = (typeof SEPARATION_VALUES)[number];
|
|
8
|
+
/** The host's rules: `--_separation` is the attribute's name, or — `auto`, unset or unknown — the component token's. */
|
|
9
|
+
export declare function separationHost(token: `--${string}`): CSSResult;
|
|
10
|
+
/**
|
|
11
|
+
* The rules of the gap form. `rules` gets the selector of `element` — an element of the shadow root that is an ancestor
|
|
12
|
+
* of (or is) everything the rules style; the divider form is the component's plain rules, written before these.
|
|
13
|
+
*/
|
|
14
|
+
export declare function whenGap(element: string, rules: (element: string) => string): CSSResult;
|
|
15
|
+
/** The separation `host` draws now, by name: its attribute's, or the component token's as the cascade gives it. */
|
|
16
|
+
export declare function separationOf(host: Element): Separation;
|
|
17
|
+
/**
|
|
18
|
+
* Whether this browser answers style container queries: asked once, with a probe that is gone when it returns. The
|
|
19
|
+
* probe's rule stands in a shadow root of the probe's own, never in the document's sheets: a sheet added to the
|
|
20
|
+
* document and taken away again has the browser build the document's rules twice for one answer.
|
|
21
|
+
*/
|
|
22
|
+
export declare function styleQueries(): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* The fallback for a browser without style container queries: the name `host` draws now, written as `data-separation`
|
|
25
|
+
* on `element` (the one `whenGap()` was given). Call it when the component has rendered. Where the queries work it
|
|
26
|
+
* removes the attribute instead.
|
|
27
|
+
*/
|
|
28
|
+
export declare function syncSeparation(host: Element, element: HTMLElement | SVGElement | null | undefined): void;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { unsafeCSS } from 'lit';
|
|
2
|
+
import { compChoice } from './actions.js';
|
|
3
|
+
// Separation: how parts that sit side by side inside one component are told apart — by a
|
|
4
|
+
// line where they touch (`divider`) or by empty space (`gap`). One choice of kind for the whole system
|
|
5
|
+
// (`sys.behavior.separation`), a component token that follows it (`comp.<name>.….separation`, an alias), and a
|
|
6
|
+
// `separation` attribute on the instance (`auto | divider | gap`).
|
|
7
|
+
//
|
|
8
|
+
// The three levels meet in one private custom property on the host, `--_separation`:
|
|
9
|
+
//
|
|
10
|
+
// :host → the component token's value (the choice's NAME, whatever the cascade says now)
|
|
11
|
+
// :host([separation='divider']) → divider
|
|
12
|
+
// :host([separation='gap']) → gap (any other attribute value is `auto`: no rule matches it)
|
|
13
|
+
//
|
|
14
|
+
// A component writes its divider form as its plain rules — divider is the first value, so it is also what an unknown
|
|
15
|
+
// name draws — and its gap form inside `whenGap()`: a style container query on the host's
|
|
16
|
+
// `--_separation`, answered by the cascade with no script, so a system switched on any ancestor, a layer that sets the
|
|
17
|
+
// component token apart and the attribute are all followed at once (BGR-21, SPB-30, PRG-17).
|
|
18
|
+
//
|
|
19
|
+
// A browser without style container queries cannot answer the query. There the component's script reads the same
|
|
20
|
+
// property when it renders and writes `data-separation` on the element `whenGap()` was given (`syncSeparation()`); the
|
|
21
|
+
// same rules match the attribute. Where the queries work nothing is written: an attribute could only go stale.
|
|
22
|
+
/** `sys.behavior.separation`. The first value is the default, and what an unknown name falls back to. */
|
|
23
|
+
export const SEPARATIONS = ['divider', 'gap'];
|
|
24
|
+
/** The `separation` prop of a component that reads the choice: `auto` takes the component token. */
|
|
25
|
+
export const SEPARATION_VALUES = ['auto', ...SEPARATIONS];
|
|
26
|
+
const PRIVATE = '--_separation';
|
|
27
|
+
/** The host's rules: `--_separation` is the attribute's name, or — `auto`, unset or unknown — the component token's. */
|
|
28
|
+
export function separationHost(token) {
|
|
29
|
+
return unsafeCSS(`
|
|
30
|
+
:host {
|
|
31
|
+
${PRIVATE}: var(${token});
|
|
32
|
+
}
|
|
33
|
+
${SEPARATIONS.map((name) => ` :host([separation='${name}']) {\n ${PRIVATE}: ${name};\n }`).join('\n')}
|
|
34
|
+
`);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The rules of the gap form. `rules` gets the selector of `element` — an element of the shadow root that is an ancestor
|
|
38
|
+
* of (or is) everything the rules style; the divider form is the component's plain rules, written before these.
|
|
39
|
+
*/
|
|
40
|
+
export function whenGap(element, rules) {
|
|
41
|
+
return unsafeCSS(`
|
|
42
|
+
@container style(${PRIVATE}: gap) {
|
|
43
|
+
${rules(element)}
|
|
44
|
+
}
|
|
45
|
+
${rules(`${element}[data-separation='gap']`)}
|
|
46
|
+
`);
|
|
47
|
+
}
|
|
48
|
+
/** The separation `host` draws now, by name: its attribute's, or the component token's as the cascade gives it. */
|
|
49
|
+
export function separationOf(host) {
|
|
50
|
+
return compChoice(host, PRIVATE, SEPARATIONS);
|
|
51
|
+
}
|
|
52
|
+
let queries;
|
|
53
|
+
/**
|
|
54
|
+
* Whether this browser answers style container queries: asked once, with a probe that is gone when it returns. The
|
|
55
|
+
* probe's rule stands in a shadow root of the probe's own, never in the document's sheets: a sheet added to the
|
|
56
|
+
* document and taken away again has the browser build the document's rules twice for one answer.
|
|
57
|
+
*/
|
|
58
|
+
export function styleQueries() {
|
|
59
|
+
if (queries !== undefined)
|
|
60
|
+
return queries;
|
|
61
|
+
if (typeof document === 'undefined' || typeof CSSStyleSheet === 'undefined')
|
|
62
|
+
return (queries = false);
|
|
63
|
+
try {
|
|
64
|
+
const sheet = new CSSStyleSheet();
|
|
65
|
+
sheet.replaceSync('@container style(--tanrei-style-query-probe: on) { [data-tanrei-style-query-probe] { --tanrei-style-query-answer: yes; } }');
|
|
66
|
+
const outer = document.createElement('div');
|
|
67
|
+
const inner = document.createElement('div');
|
|
68
|
+
outer.style.setProperty('--tanrei-style-query-probe', 'on');
|
|
69
|
+
outer.style.display = 'none';
|
|
70
|
+
inner.setAttribute('data-tanrei-style-query-probe', '');
|
|
71
|
+
const root = outer.attachShadow({ mode: 'open' });
|
|
72
|
+
root.adoptedStyleSheets = [sheet];
|
|
73
|
+
root.append(inner);
|
|
74
|
+
document.documentElement.append(outer);
|
|
75
|
+
queries = getComputedStyle(inner).getPropertyValue('--tanrei-style-query-answer').trim() === 'yes';
|
|
76
|
+
outer.remove();
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
queries = false;
|
|
80
|
+
}
|
|
81
|
+
return queries;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* The fallback for a browser without style container queries: the name `host` draws now, written as `data-separation`
|
|
85
|
+
* on `element` (the one `whenGap()` was given). Call it when the component has rendered. Where the queries work it
|
|
86
|
+
* removes the attribute instead.
|
|
87
|
+
*/
|
|
88
|
+
export function syncSeparation(host, element) {
|
|
89
|
+
if (!element)
|
|
90
|
+
return;
|
|
91
|
+
if (styleQueries())
|
|
92
|
+
delete element.dataset.separation;
|
|
93
|
+
else
|
|
94
|
+
element.dataset.separation = separationOf(host);
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=separation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"separation.js","sourceRoot":"","sources":["../../src/primitives/separation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,SAAS,EAAE,MAAM,KAAK,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,yFAAyF;AACzF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