@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,161 @@
|
|
|
1
|
+
import { LitElement, type PropertyDeclarations, type PropertyValues } from 'lit';
|
|
2
|
+
/** What `change` carries: the new value of `selected`. */
|
|
3
|
+
export interface TanreiSwitchChangeDetail {
|
|
4
|
+
selected: boolean;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Turns one setting on or off, taking effect at once, with a handle that follows a finger dragged along the track.
|
|
8
|
+
*
|
|
9
|
+
* Contract: specs/switch.spec.json. Every visual value comes from `--tanrei-comp-switch-*` tokens, one set per condition
|
|
10
|
+
* (unselected, selected) and state — the handle's color, size and elevation included: how a state looks is the active
|
|
11
|
+
* design system's decision. The handle travels to the inline end when on (the left in right-to-left layouts).
|
|
12
|
+
*
|
|
13
|
+
* A tap switches it. A drag along the track (touch, pen or mouse; from the track, the handle or the target around them,
|
|
14
|
+
* not from the label) carries the handle with the pointer, and every part that differs between off and on is drawn at
|
|
15
|
+
* the handle's progress between the two, with no threshold. `selected`, the form value and the exposed state change
|
|
16
|
+
* when the pointer is released — to the nearer side, or the side a fling is toward — with one `input` and one `change`;
|
|
17
|
+
* Escape, a cancelled pointer, `disabled` or a `selected` set meanwhile return the handle and fire nothing.
|
|
18
|
+
*
|
|
19
|
+
* Form-associated: while selected it submits `value` (default "on") under `name`, resets to its `selected` attribute and
|
|
20
|
+
* follows a disabled `<fieldset>`, as a native checkbox does. It switches its own `selected` before it fires `input` and
|
|
21
|
+
* `change`. The semantics are a native checkbox with the role switch in the shadow root, named by `label`; a click on
|
|
22
|
+
* the visible label toggles it.
|
|
23
|
+
*
|
|
24
|
+
* @tag tanrei-switch
|
|
25
|
+
* @csspart track - The track: its fill and outline.
|
|
26
|
+
* @csspart handle - The handle (and the icons in it).
|
|
27
|
+
* @csspart container - The round state layer centered on the handle (hover, focus, press).
|
|
28
|
+
* @csspart icon - A glyph in the handle — the unselected one, the selected one, or both, as the props name them: the icon
|
|
29
|
+
* set's glyph, drawn only once the icon set can draw it, at the opacity the handle's progress gives its condition.
|
|
30
|
+
* @csspart label - The visible label.
|
|
31
|
+
* @attr {string} form - The id of the form the switch belongs to, where it stands outside it: the platform's own attribute, which then wins over a form around it. The `form` property is read-only and returns the form element.
|
|
32
|
+
* @fires input - The user switched it; `selected` is already the new value.
|
|
33
|
+
* @fires {CustomEvent<TanreiSwitchChangeDetail>} change - The user switched it; `detail.selected` (and the element's `selected`) is the new value.
|
|
34
|
+
*/
|
|
35
|
+
export declare class TanreiSwitch extends LitElement {
|
|
36
|
+
private readonly availability;
|
|
37
|
+
static styles: import("lit").CSSResult[];
|
|
38
|
+
static formAssociated: boolean;
|
|
39
|
+
static shadowRootOptions: ShadowRootInit;
|
|
40
|
+
static properties: PropertyDeclarations;
|
|
41
|
+
/** Whether the setting is on. The `selected` attribute is the default a form reset returns to. */
|
|
42
|
+
selected: boolean;
|
|
43
|
+
/** Prevents interaction and removes the switch from the focus order. */
|
|
44
|
+
disabled: boolean;
|
|
45
|
+
/** The text that names the setting: drawn next to the track and used as the accessible name. */
|
|
46
|
+
label: string;
|
|
47
|
+
/** Draws no visible label but keeps `label` as the accessible name (the `label-hidden` attribute). */
|
|
48
|
+
labelHidden: boolean;
|
|
49
|
+
/** The glyph (a name in the system's icon set) the handle shows while on; empty shows none (`selected-icon`). A name the icon set flags is drawn mirrored in right-to-left. */
|
|
50
|
+
selectedIcon: string;
|
|
51
|
+
/** The glyph the handle shows while off; empty shows none (`unselected-icon`). A name the icon set flags is drawn mirrored in right-to-left. */
|
|
52
|
+
unselectedIcon: string;
|
|
53
|
+
/** Web only: the name it is submitted under. */
|
|
54
|
+
name: string;
|
|
55
|
+
/** Web only: what it submits while selected. */
|
|
56
|
+
value: string;
|
|
57
|
+
/** Form association, a click on the host, Enter (src/primitives/selection.ts). */
|
|
58
|
+
private readonly selection;
|
|
59
|
+
/** SWT-7 / SWT-8: the pressed state, press-hold and the answer the system chooses (src/primitives/press.ts). */
|
|
60
|
+
private readonly press;
|
|
61
|
+
/**
|
|
62
|
+
* SWT-23: each glyph of the handle is marked when the icon set mirrors its name in right-to-left
|
|
63
|
+
* (src/primitives/glyph-mirror.ts); `iconGlyph()` draws the mark, in the glyph's own box, wherever the handle is.
|
|
64
|
+
*/
|
|
65
|
+
private readonly mirror;
|
|
66
|
+
/** SWT-17: a glyph is drawn only while the icon set can draw it (src/primitives/glyph.ts). */
|
|
67
|
+
private readonly glyphs;
|
|
68
|
+
private get input();
|
|
69
|
+
/** The form it belongs to, if any. */
|
|
70
|
+
get form(): HTMLFormElement | null;
|
|
71
|
+
/** `element.click()` switches it as a person would, and does nothing while disabled. */
|
|
72
|
+
click(): void;
|
|
73
|
+
formResetCallback(): void;
|
|
74
|
+
formStateRestoreCallback(state: string | null): void;
|
|
75
|
+
formDisabledCallback(disabled: boolean): void;
|
|
76
|
+
/** SWT-9: where style queries are missing, the focus style is read when focus arrives. */
|
|
77
|
+
private onFocus;
|
|
78
|
+
private onKeyDown;
|
|
79
|
+
/**
|
|
80
|
+
* A click on the label's text or on the target around the track is the label's; only the input's click is let out.
|
|
81
|
+
* SWT-20: the click that follows a drag the switch took is not an activation — it never reaches the label.
|
|
82
|
+
*/
|
|
83
|
+
private onRootClick;
|
|
84
|
+
/**
|
|
85
|
+
* SWT-13: the handle sets out for the other condition, or for the one it left, and the parts are between the two
|
|
86
|
+
* until it is there: `data-between` on `.root`, under which the two layers of a color are added (switch.styles.ts).
|
|
87
|
+
* Marked before the style pass that starts the travel, with the label's change of condition, and taken away when the
|
|
88
|
+
* thumb's travel ends — or two frames later where none began (motion is reduced, or the handle is where it goes).
|
|
89
|
+
*/
|
|
90
|
+
private markTravel;
|
|
91
|
+
private travelMark;
|
|
92
|
+
/** The thumb's travel ended, was replaced by another, or never began: at rest the parts are between nothing. */
|
|
93
|
+
private readonly endTravel;
|
|
94
|
+
/** SWT-1: the native switch switched; the element takes the new value before anyone hears of it. */
|
|
95
|
+
private onInput;
|
|
96
|
+
private onChange;
|
|
97
|
+
/** The pointer that may become, or is, a drag (SWT-19); null when none is down on the control. */
|
|
98
|
+
private drag;
|
|
99
|
+
/** The handle's progress while a drag holds it: what `PROGRESS` on `.root` was last written to. */
|
|
100
|
+
private progress;
|
|
101
|
+
/** Where the pointer is along the track, as a progress, at its last move. */
|
|
102
|
+
private pointerAt;
|
|
103
|
+
/** How far the handle was from the pointer when the drag was taken; the catch-up closes it. */
|
|
104
|
+
private lag;
|
|
105
|
+
/** The catch-up's clock: an effect-less animation over the state motion, whose progress is the eased time. */
|
|
106
|
+
private catchUp;
|
|
107
|
+
private catchUpFrame;
|
|
108
|
+
/** The click after a drag the switch took is not an activation (SWT-20); cleared by that click or the next press. */
|
|
109
|
+
private swallowClick;
|
|
110
|
+
private get root();
|
|
111
|
+
/**
|
|
112
|
+
* SWT-19: where the handle is drawn now — at rest, or on its way after a tap — as a progress: how far its `translate`
|
|
113
|
+
* has carried it along its travel (the property the progress is drawn by, in the track's own pixels).
|
|
114
|
+
*/
|
|
115
|
+
private drawnProgress;
|
|
116
|
+
/** SWT-19: where a pointer is along the track, as the handle's progress — 0 at its unselected position, 1 at its selected one (mirrored in RTL, SWT-11). */
|
|
117
|
+
private progressAt;
|
|
118
|
+
/** SWT-19: a press on the track, the handle or the target around them may become a drag; the label is not part of the control. */
|
|
119
|
+
private onControlPointerDown;
|
|
120
|
+
private readonly onPointerMove;
|
|
121
|
+
/**
|
|
122
|
+
* SWT-19: the drag is the switch's. The pointer is captured, the switch stays pressed, and the handle goes to the
|
|
123
|
+
* pointer: over the state motion when it was away from it (the catch-up), then in the frame the pointer moves.
|
|
124
|
+
*/
|
|
125
|
+
private takeDrag;
|
|
126
|
+
/** SWT-19: the handle at the pointer's place — less what is left of the catch-up — and every part at that progress. */
|
|
127
|
+
private drawDrag;
|
|
128
|
+
private endCatchUp;
|
|
129
|
+
/**
|
|
130
|
+
* SWT-20: a release chooses the side a fling is toward, else the side the handle is nearer to — the other condition
|
|
131
|
+
* from the middle on. A change switches `selected` with one `input` and one `change`, as an activation does; either
|
|
132
|
+
* way the progress leaves the pointer's place for the condition's over the selection motion.
|
|
133
|
+
*/
|
|
134
|
+
private readonly onPointerUp;
|
|
135
|
+
private readonly onPointerCancel;
|
|
136
|
+
/** SWT-21: Escape cancels a drag in progress, and is spent on it: nothing behind the switch hears it. */
|
|
137
|
+
private readonly onDragKeyDown;
|
|
138
|
+
/** SWT-21: a capture taken away (a system gesture) cancels the drag; after a release there is none left to cancel. */
|
|
139
|
+
private onLostPointerCapture;
|
|
140
|
+
/**
|
|
141
|
+
* SWT-21: the drag is over without a choice. The handle and the look return to the condition `selected` holds, over
|
|
142
|
+
* the selection motion; nothing is emitted, and a click the pointer still produces is not an activation.
|
|
143
|
+
*/
|
|
144
|
+
private cancelDrag;
|
|
145
|
+
/** Lets go of the pointer and of the progress: the stylesheet's value (0 or 1) is its target again. */
|
|
146
|
+
private endDrag;
|
|
147
|
+
/** A new press: whatever click a drag left unanswered is not coming any more. Presses on the control arrive here after `onControlPointerDown`. */
|
|
148
|
+
private onRootPointerDown;
|
|
149
|
+
/** SWT-19: the switch stays pressed for as long as a drag lasts, wherever the captured pointer goes. */
|
|
150
|
+
private onPointerLeave;
|
|
151
|
+
disconnectedCallback(): void;
|
|
152
|
+
/** SWT-21: the product set `selected`, or the switch became disabled, while a drag lasted: the drag is cancelled. */
|
|
153
|
+
protected willUpdate(changed: PropertyValues<this>): void;
|
|
154
|
+
protected updated(changed: PropertyValues<this>): void;
|
|
155
|
+
protected render(): import("lit").TemplateResult<1>;
|
|
156
|
+
}
|
|
157
|
+
declare global {
|
|
158
|
+
interface HTMLElementTagNameMap {
|
|
159
|
+
'tanrei-switch': TanreiSwitch;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
import { LitElement, html, nothing } from 'lit';
|
|
2
|
+
import { live } from 'lit/directives/live.js';
|
|
3
|
+
import { hiddenHost } from '../../primitives/hidden.js';
|
|
4
|
+
import { AvailabilityController, GlyphDrawnController, GlyphMirrorController, PressController, SHEET_FLING_VELOCITY, SelectionController, SheetDrag, markConditionChange, report, selectionRippleOrigin, syncFocusStyle, } from '../../primitives/index.js';
|
|
5
|
+
import { PROGRESS, styles } from './switch.styles.js';
|
|
6
|
+
import { disabledWaitsWhileFocused } from '../../primitives/disabled-while-focused.js';
|
|
7
|
+
import { focusedAtFirst } from '../../primitives/autofocus.js';
|
|
8
|
+
const clamp = (value) => Math.min(1, Math.max(0, value));
|
|
9
|
+
/**
|
|
10
|
+
* Turns one setting on or off, taking effect at once, with a handle that follows a finger dragged along the track.
|
|
11
|
+
*
|
|
12
|
+
* Contract: specs/switch.spec.json. Every visual value comes from `--tanrei-comp-switch-*` tokens, one set per condition
|
|
13
|
+
* (unselected, selected) and state — the handle's color, size and elevation included: how a state looks is the active
|
|
14
|
+
* design system's decision. The handle travels to the inline end when on (the left in right-to-left layouts).
|
|
15
|
+
*
|
|
16
|
+
* A tap switches it. A drag along the track (touch, pen or mouse; from the track, the handle or the target around them,
|
|
17
|
+
* not from the label) carries the handle with the pointer, and every part that differs between off and on is drawn at
|
|
18
|
+
* the handle's progress between the two, with no threshold. `selected`, the form value and the exposed state change
|
|
19
|
+
* when the pointer is released — to the nearer side, or the side a fling is toward — with one `input` and one `change`;
|
|
20
|
+
* Escape, a cancelled pointer, `disabled` or a `selected` set meanwhile return the handle and fire nothing.
|
|
21
|
+
*
|
|
22
|
+
* Form-associated: while selected it submits `value` (default "on") under `name`, resets to its `selected` attribute and
|
|
23
|
+
* follows a disabled `<fieldset>`, as a native checkbox does. It switches its own `selected` before it fires `input` and
|
|
24
|
+
* `change`. The semantics are a native checkbox with the role switch in the shadow root, named by `label`; a click on
|
|
25
|
+
* the visible label toggles it.
|
|
26
|
+
*
|
|
27
|
+
* @tag tanrei-switch
|
|
28
|
+
* @csspart track - The track: its fill and outline.
|
|
29
|
+
* @csspart handle - The handle (and the icons in it).
|
|
30
|
+
* @csspart container - The round state layer centered on the handle (hover, focus, press).
|
|
31
|
+
* @csspart icon - A glyph in the handle — the unselected one, the selected one, or both, as the props name them: the icon
|
|
32
|
+
* set's glyph, drawn only once the icon set can draw it, at the opacity the handle's progress gives its condition.
|
|
33
|
+
* @csspart label - The visible label.
|
|
34
|
+
* @attr {string} form - The id of the form the switch belongs to, where it stands outside it: the platform's own attribute, which then wins over a form around it. The `form` property is read-only and returns the form element.
|
|
35
|
+
* @fires input - The user switched it; `selected` is already the new value.
|
|
36
|
+
* @fires {CustomEvent<TanreiSwitchChangeDetail>} change - The user switched it; `detail.selected` (and the element's `selected`) is the new value.
|
|
37
|
+
*/
|
|
38
|
+
export class TanreiSwitch extends LitElement {
|
|
39
|
+
constructor() {
|
|
40
|
+
super(...arguments);
|
|
41
|
+
this.availability = new AvailabilityController(this, 'switch');
|
|
42
|
+
/** Whether the setting is on. The `selected` attribute is the default a form reset returns to. */
|
|
43
|
+
this.selected = false;
|
|
44
|
+
/** Prevents interaction and removes the switch from the focus order. */
|
|
45
|
+
this.disabled = false;
|
|
46
|
+
/** The text that names the setting: drawn next to the track and used as the accessible name. */
|
|
47
|
+
this.label = '';
|
|
48
|
+
/** Draws no visible label but keeps `label` as the accessible name (the `label-hidden` attribute). */
|
|
49
|
+
this.labelHidden = false;
|
|
50
|
+
/** The glyph (a name in the system's icon set) the handle shows while on; empty shows none (`selected-icon`). A name the icon set flags is drawn mirrored in right-to-left. */
|
|
51
|
+
this.selectedIcon = '';
|
|
52
|
+
/** The glyph the handle shows while off; empty shows none (`unselected-icon`). A name the icon set flags is drawn mirrored in right-to-left. */
|
|
53
|
+
this.unselectedIcon = '';
|
|
54
|
+
/** Web only: the name it is submitted under. */
|
|
55
|
+
this.name = '';
|
|
56
|
+
/** Web only: what it submits while selected. */
|
|
57
|
+
this.value = 'on';
|
|
58
|
+
/** Form association, a click on the host, Enter (src/primitives/selection.ts). */
|
|
59
|
+
this.selection = new SelectionController(this, () => this.input, { named: () => !!this.label });
|
|
60
|
+
/** SWT-7 / SWT-8: the pressed state, press-hold and the answer the system chooses (src/primitives/press.ts). */
|
|
61
|
+
this.press = new PressController(this, {
|
|
62
|
+
container: () => this.renderRoot.querySelector('.container'),
|
|
63
|
+
holdCarrier: () => this.renderRoot.querySelector('.control'),
|
|
64
|
+
disabled: () => this.selection.disabled,
|
|
65
|
+
keys: [' '],
|
|
66
|
+
origin: selectionRippleOrigin(() => this.renderRoot.querySelector('.container')),
|
|
67
|
+
});
|
|
68
|
+
/**
|
|
69
|
+
* SWT-23: each glyph of the handle is marked when the icon set mirrors its name in right-to-left
|
|
70
|
+
* (src/primitives/glyph-mirror.ts); `iconGlyph()` draws the mark, in the glyph's own box, wherever the handle is.
|
|
71
|
+
*/
|
|
72
|
+
this.mirror = new GlyphMirrorController(this, { drawn: '.icon' });
|
|
73
|
+
/** SWT-17: a glyph is drawn only while the icon set can draw it (src/primitives/glyph.ts). */
|
|
74
|
+
this.glyphs = new GlyphDrawnController(this, () => this.renderRoot.querySelectorAll('.icon'));
|
|
75
|
+
this.travelMark = 0;
|
|
76
|
+
/** The thumb's travel ended, was replaced by another, or never began: at rest the parts are between nothing. */
|
|
77
|
+
this.endTravel = (event) => {
|
|
78
|
+
if (event && (event.propertyName !== 'translate' || event.target !== event.currentTarget))
|
|
79
|
+
return;
|
|
80
|
+
const thumb = this.renderRoot.querySelector('.thumb');
|
|
81
|
+
const travelling = thumb?.getAnimations?.().some((animation) => animation.transitionProperty === 'translate' && animation.playState !== 'finished' && animation.playState !== 'idle');
|
|
82
|
+
if (!travelling)
|
|
83
|
+
this.root?.removeAttribute('data-between');
|
|
84
|
+
};
|
|
85
|
+
/** The pointer that may become, or is, a drag (SWT-19); null when none is down on the control. */
|
|
86
|
+
this.drag = null;
|
|
87
|
+
/** The handle's progress while a drag holds it: what `PROGRESS` on `.root` was last written to. */
|
|
88
|
+
this.progress = 0;
|
|
89
|
+
/** Where the pointer is along the track, as a progress, at its last move. */
|
|
90
|
+
this.pointerAt = 0;
|
|
91
|
+
/** How far the handle was from the pointer when the drag was taken; the catch-up closes it. */
|
|
92
|
+
this.lag = 0;
|
|
93
|
+
/** The catch-up's clock: an effect-less animation over the state motion, whose progress is the eased time. */
|
|
94
|
+
this.catchUp = null;
|
|
95
|
+
this.catchUpFrame = 0;
|
|
96
|
+
/** The click after a drag the switch took is not an activation (SWT-20); cleared by that click or the next press. */
|
|
97
|
+
this.swallowClick = false;
|
|
98
|
+
this.onPointerMove = (event) => {
|
|
99
|
+
const drag = this.drag;
|
|
100
|
+
if (!drag || event.pointerId !== drag.id)
|
|
101
|
+
return;
|
|
102
|
+
const step = drag.move(event);
|
|
103
|
+
if (step === 'start')
|
|
104
|
+
this.takeDrag(event);
|
|
105
|
+
else if (step === 'follow') {
|
|
106
|
+
this.pointerAt = this.progressAt(event);
|
|
107
|
+
this.drawDrag();
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* SWT-20: a release chooses the side a fling is toward, else the side the handle is nearer to — the other condition
|
|
112
|
+
* from the middle on. A change switches `selected` with one `input` and one `change`, as an activation does; either
|
|
113
|
+
* way the progress leaves the pointer's place for the condition's over the selection motion.
|
|
114
|
+
*/
|
|
115
|
+
this.onPointerUp = (event) => {
|
|
116
|
+
const drag = this.drag;
|
|
117
|
+
if (!drag || event.pointerId !== drag.id)
|
|
118
|
+
return;
|
|
119
|
+
if (!drag.following) {
|
|
120
|
+
this.endDrag();
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
this.pointerAt = this.progressAt(event);
|
|
124
|
+
this.drawDrag();
|
|
125
|
+
const velocity = drag.velocity(event) * (getComputedStyle(this).direction === 'rtl' ? -1 : 1);
|
|
126
|
+
const chosen = Math.abs(velocity) >= SHEET_FLING_VELOCITY ? velocity > 0 : this.selected ? this.progress > 0.5 : this.progress >= 0.5;
|
|
127
|
+
const switches = chosen !== this.selected;
|
|
128
|
+
// The native switch takes the chosen condition before the progress is let go, so that the progress leaves the
|
|
129
|
+
// pointer's place for that condition's in one step.
|
|
130
|
+
if (switches) {
|
|
131
|
+
const input = this.input;
|
|
132
|
+
if (input)
|
|
133
|
+
input.checked = chosen;
|
|
134
|
+
this.selected = chosen;
|
|
135
|
+
}
|
|
136
|
+
this.swallowClick = true;
|
|
137
|
+
this.endDrag();
|
|
138
|
+
this.press.release();
|
|
139
|
+
if (!switches)
|
|
140
|
+
return;
|
|
141
|
+
this.dispatchEvent(new Event('input', { bubbles: true, composed: true }));
|
|
142
|
+
this.onChange();
|
|
143
|
+
};
|
|
144
|
+
this.onPointerCancel = (event) => {
|
|
145
|
+
if (this.drag && event.pointerId === this.drag.id)
|
|
146
|
+
this.cancelDrag();
|
|
147
|
+
};
|
|
148
|
+
/** SWT-21: Escape cancels a drag in progress, and is spent on it: nothing behind the switch hears it. */
|
|
149
|
+
this.onDragKeyDown = (event) => {
|
|
150
|
+
if (event.key !== 'Escape' || !this.drag?.following)
|
|
151
|
+
return;
|
|
152
|
+
event.preventDefault();
|
|
153
|
+
event.stopPropagation();
|
|
154
|
+
this.cancelDrag();
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
static { this.styles = [styles, hiddenHost]; }
|
|
158
|
+
static { this.formAssociated = true; }
|
|
159
|
+
static { this.shadowRootOptions = { ...LitElement.shadowRootOptions, delegatesFocus: true }; }
|
|
160
|
+
static { this.properties = {
|
|
161
|
+
selected: { type: Boolean },
|
|
162
|
+
disabled: { type: Boolean, reflect: true },
|
|
163
|
+
label: { type: String },
|
|
164
|
+
labelHidden: { type: Boolean, attribute: 'label-hidden', reflect: true },
|
|
165
|
+
selectedIcon: { type: String, attribute: 'selected-icon' },
|
|
166
|
+
unselectedIcon: { type: String, attribute: 'unselected-icon' },
|
|
167
|
+
name: { type: String, reflect: true },
|
|
168
|
+
value: { type: String },
|
|
169
|
+
}; }
|
|
170
|
+
get input() {
|
|
171
|
+
return this.renderRoot.querySelector('input');
|
|
172
|
+
}
|
|
173
|
+
/** The form it belongs to, if any. */
|
|
174
|
+
get form() {
|
|
175
|
+
return this.selection.form;
|
|
176
|
+
}
|
|
177
|
+
/** `element.click()` switches it as a person would, and does nothing while disabled. */
|
|
178
|
+
click() {
|
|
179
|
+
this.selection.click();
|
|
180
|
+
}
|
|
181
|
+
formResetCallback() {
|
|
182
|
+
this.selected = this.hasAttribute('selected');
|
|
183
|
+
}
|
|
184
|
+
formStateRestoreCallback(state) {
|
|
185
|
+
this.selected = state === 'true';
|
|
186
|
+
}
|
|
187
|
+
formDisabledCallback(disabled) {
|
|
188
|
+
this.selection.formDisabledCallback(disabled);
|
|
189
|
+
}
|
|
190
|
+
/** SWT-9: where style queries are missing, the focus style is read when focus arrives. */
|
|
191
|
+
onFocus() {
|
|
192
|
+
syncFocusStyle(this, this.input);
|
|
193
|
+
}
|
|
194
|
+
onKeyDown(event) {
|
|
195
|
+
this.selection.onKeyDown(event);
|
|
196
|
+
this.press.onKeyDown(event);
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* A click on the label's text or on the target around the track is the label's; only the input's click is let out.
|
|
200
|
+
* SWT-20: the click that follows a drag the switch took is not an activation — it never reaches the label.
|
|
201
|
+
*/
|
|
202
|
+
onRootClick(event) {
|
|
203
|
+
if (event.target === this.input)
|
|
204
|
+
return;
|
|
205
|
+
event.stopPropagation();
|
|
206
|
+
if (!this.swallowClick)
|
|
207
|
+
return;
|
|
208
|
+
this.swallowClick = false;
|
|
209
|
+
event.preventDefault();
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* SWT-13: the handle sets out for the other condition, or for the one it left, and the parts are between the two
|
|
213
|
+
* until it is there: `data-between` on `.root`, under which the two layers of a color are added (switch.styles.ts).
|
|
214
|
+
* Marked before the style pass that starts the travel, with the label's change of condition, and taken away when the
|
|
215
|
+
* thumb's travel ends — or two frames later where none began (motion is reduced, or the handle is where it goes).
|
|
216
|
+
*/
|
|
217
|
+
markTravel() {
|
|
218
|
+
const root = this.root;
|
|
219
|
+
if (!root)
|
|
220
|
+
return;
|
|
221
|
+
markConditionChange(root);
|
|
222
|
+
root.setAttribute('data-between', '');
|
|
223
|
+
const mark = ++this.travelMark;
|
|
224
|
+
requestAnimationFrame(() => requestAnimationFrame(() => {
|
|
225
|
+
if (mark === this.travelMark)
|
|
226
|
+
this.endTravel();
|
|
227
|
+
}));
|
|
228
|
+
}
|
|
229
|
+
/** SWT-1: the native switch switched; the element takes the new value before anyone hears of it. */
|
|
230
|
+
onInput(event) {
|
|
231
|
+
event.stopPropagation();
|
|
232
|
+
// SWT-13: the native switch is the new condition already, and the next style pass draws it.
|
|
233
|
+
this.markTravel();
|
|
234
|
+
this.selected = this.input.checked;
|
|
235
|
+
this.dispatchEvent(new Event('input', { bubbles: true, composed: true }));
|
|
236
|
+
}
|
|
237
|
+
onChange() {
|
|
238
|
+
this.dispatchEvent(new CustomEvent('change', { bubbles: true, detail: { selected: this.selected } }));
|
|
239
|
+
}
|
|
240
|
+
get root() {
|
|
241
|
+
return this.renderRoot.querySelector('.root');
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* SWT-19: where the handle is drawn now — at rest, or on its way after a tap — as a progress: how far its `translate`
|
|
245
|
+
* has carried it along its travel (the property the progress is drawn by, in the track's own pixels).
|
|
246
|
+
*/
|
|
247
|
+
drawnProgress() {
|
|
248
|
+
const [thumb, track] = [this.renderRoot.querySelector('.thumb'), this.renderRoot.querySelector('.track')];
|
|
249
|
+
const travel = track ? track.offsetWidth - track.offsetHeight : 0;
|
|
250
|
+
if (!thumb || !track || travel <= 0)
|
|
251
|
+
return this.selected ? 1 : 0;
|
|
252
|
+
const along = Number.parseFloat(getComputedStyle(thumb).translate);
|
|
253
|
+
if (!Number.isFinite(along))
|
|
254
|
+
return 0;
|
|
255
|
+
return clamp((getComputedStyle(track).direction === 'rtl' ? -along : along) / travel);
|
|
256
|
+
}
|
|
257
|
+
/** SWT-19: where a pointer is along the track, as the handle's progress — 0 at its unselected position, 1 at its selected one (mirrored in RTL, SWT-11). */
|
|
258
|
+
progressAt(event) {
|
|
259
|
+
const track = this.renderRoot.querySelector('.track');
|
|
260
|
+
if (!track)
|
|
261
|
+
return this.selected ? 1 : 0;
|
|
262
|
+
const box = track.getBoundingClientRect();
|
|
263
|
+
const travel = box.width - box.height;
|
|
264
|
+
if (travel <= 0)
|
|
265
|
+
return this.selected ? 1 : 0;
|
|
266
|
+
const along = (event.clientX - box.left - box.height / 2) / travel;
|
|
267
|
+
return clamp(getComputedStyle(track).direction === 'rtl' ? 1 - along : along);
|
|
268
|
+
}
|
|
269
|
+
/** SWT-19: a press on the track, the handle or the target around them may become a drag; the label is not part of the control. */
|
|
270
|
+
onControlPointerDown(event) {
|
|
271
|
+
if (this.drag || this.selection.disabled || !event.isPrimary || (event.pointerType === 'mouse' && event.button !== 0))
|
|
272
|
+
return;
|
|
273
|
+
this.drag = new SheetDrag(event, 'x');
|
|
274
|
+
window.addEventListener('pointermove', this.onPointerMove, true);
|
|
275
|
+
window.addEventListener('pointerup', this.onPointerUp, true);
|
|
276
|
+
window.addEventListener('pointercancel', this.onPointerCancel, true);
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* SWT-19: the drag is the switch's. The pointer is captured, the switch stays pressed, and the handle goes to the
|
|
280
|
+
* pointer: over the state motion when it was away from it (the catch-up), then in the frame the pointer moves.
|
|
281
|
+
*/
|
|
282
|
+
takeDrag(event) {
|
|
283
|
+
const [root, control, sizer] = [this.root, this.renderRoot.querySelector('.control'), this.renderRoot.querySelector('.sizer')];
|
|
284
|
+
if (!root || !control || !sizer)
|
|
285
|
+
return;
|
|
286
|
+
try {
|
|
287
|
+
control.setPointerCapture(event.pointerId);
|
|
288
|
+
}
|
|
289
|
+
catch {
|
|
290
|
+
// A pointer that cannot be captured (it is no longer active) is still followed from the window's events.
|
|
291
|
+
}
|
|
292
|
+
// The pointer may have left the switch, which ended the press, before it passed the slop along the track.
|
|
293
|
+
if (this.renderRoot.querySelector('.container')?.dataset.pressed === undefined)
|
|
294
|
+
this.press.press({ x: event.clientX, y: event.clientY });
|
|
295
|
+
// Where the handle is drawn now — at rest, or on its way after a tap — is where the drag takes it from.
|
|
296
|
+
this.progress = this.drawnProgress();
|
|
297
|
+
this.pointerAt = this.progressAt(event);
|
|
298
|
+
this.lag = this.progress - this.pointerAt;
|
|
299
|
+
root.style.setProperty(PROGRESS, String(this.progress));
|
|
300
|
+
root.setAttribute('data-drag', '');
|
|
301
|
+
window.addEventListener('keydown', this.onDragKeyDown, true);
|
|
302
|
+
// The state motion, computed by a real property (`.sizer` carries it as an inert transition); none where motion
|
|
303
|
+
// is reduced (SWT-21), so the handle is at the pointer at once.
|
|
304
|
+
const motion = getComputedStyle(sizer);
|
|
305
|
+
const duration = Number.parseFloat(motion.transitionDuration) * 1000;
|
|
306
|
+
if (this.lag !== 0 && duration > 0 && typeof sizer.animate === 'function') {
|
|
307
|
+
this.catchUp = sizer.animate(null, { duration, easing: motion.transitionTimingFunction });
|
|
308
|
+
const frame = () => {
|
|
309
|
+
if (!this.catchUp)
|
|
310
|
+
return;
|
|
311
|
+
this.drawDrag();
|
|
312
|
+
if (this.catchUp.playState === 'finished')
|
|
313
|
+
this.endCatchUp();
|
|
314
|
+
else
|
|
315
|
+
this.catchUpFrame = requestAnimationFrame(frame);
|
|
316
|
+
};
|
|
317
|
+
this.catchUpFrame = requestAnimationFrame(frame);
|
|
318
|
+
}
|
|
319
|
+
this.drawDrag();
|
|
320
|
+
}
|
|
321
|
+
/** SWT-19: the handle at the pointer's place — less what is left of the catch-up — and every part at that progress. */
|
|
322
|
+
drawDrag() {
|
|
323
|
+
const left = this.catchUp ? 1 - (this.catchUp.playState === 'finished' ? 1 : (this.catchUp.effect?.getComputedTiming().progress ?? 1)) : 0;
|
|
324
|
+
this.progress = clamp(this.pointerAt + this.lag * left);
|
|
325
|
+
this.root?.style.setProperty(PROGRESS, String(this.progress));
|
|
326
|
+
}
|
|
327
|
+
endCatchUp() {
|
|
328
|
+
cancelAnimationFrame(this.catchUpFrame);
|
|
329
|
+
this.catchUp?.cancel();
|
|
330
|
+
this.catchUp = null;
|
|
331
|
+
}
|
|
332
|
+
/** SWT-21: a capture taken away (a system gesture) cancels the drag; after a release there is none left to cancel. */
|
|
333
|
+
onLostPointerCapture(event) {
|
|
334
|
+
if (this.drag?.following && event.pointerId === this.drag.id)
|
|
335
|
+
this.cancelDrag();
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* SWT-21: the drag is over without a choice. The handle and the look return to the condition `selected` holds, over
|
|
339
|
+
* the selection motion; nothing is emitted, and a click the pointer still produces is not an activation.
|
|
340
|
+
*/
|
|
341
|
+
cancelDrag() {
|
|
342
|
+
if (!this.drag)
|
|
343
|
+
return;
|
|
344
|
+
this.swallowClick = this.drag.following;
|
|
345
|
+
this.endDrag();
|
|
346
|
+
this.press.release();
|
|
347
|
+
}
|
|
348
|
+
/** Lets go of the pointer and of the progress: the stylesheet's value (0 or 1) is its target again. */
|
|
349
|
+
endDrag() {
|
|
350
|
+
const drag = this.drag;
|
|
351
|
+
if (!drag)
|
|
352
|
+
return;
|
|
353
|
+
this.drag = null;
|
|
354
|
+
window.removeEventListener('pointermove', this.onPointerMove, true);
|
|
355
|
+
window.removeEventListener('pointerup', this.onPointerUp, true);
|
|
356
|
+
window.removeEventListener('pointercancel', this.onPointerCancel, true);
|
|
357
|
+
window.removeEventListener('keydown', this.onDragKeyDown, true);
|
|
358
|
+
this.endCatchUp();
|
|
359
|
+
if (!drag.following)
|
|
360
|
+
return;
|
|
361
|
+
const [root, control] = [this.root, this.renderRoot.querySelector('.control')];
|
|
362
|
+
// SWT-20, SWT-21: from where the pointer left it the handle travels to its condition's place.
|
|
363
|
+
this.markTravel();
|
|
364
|
+
root?.removeAttribute('data-drag');
|
|
365
|
+
root?.style.removeProperty(PROGRESS);
|
|
366
|
+
try {
|
|
367
|
+
if (control?.hasPointerCapture(drag.id))
|
|
368
|
+
control.releasePointerCapture(drag.id);
|
|
369
|
+
}
|
|
370
|
+
catch {
|
|
371
|
+
// The pointer is gone already.
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
/** A new press: whatever click a drag left unanswered is not coming any more. Presses on the control arrive here after `onControlPointerDown`. */
|
|
375
|
+
onRootPointerDown(event) {
|
|
376
|
+
this.swallowClick = false;
|
|
377
|
+
this.press.onPointerDown(event);
|
|
378
|
+
}
|
|
379
|
+
/** SWT-19: the switch stays pressed for as long as a drag lasts, wherever the captured pointer goes. */
|
|
380
|
+
onPointerLeave() {
|
|
381
|
+
if (!this.drag?.following)
|
|
382
|
+
this.press.release();
|
|
383
|
+
}
|
|
384
|
+
disconnectedCallback() {
|
|
385
|
+
super.disconnectedCallback();
|
|
386
|
+
this.cancelDrag();
|
|
387
|
+
this.swallowClick = false;
|
|
388
|
+
this.travelMark += 1;
|
|
389
|
+
this.root?.removeAttribute('data-between');
|
|
390
|
+
}
|
|
391
|
+
/** SWT-21: the product set `selected`, or the switch became disabled, while a drag lasted: the drag is cancelled. */
|
|
392
|
+
willUpdate(changed) {
|
|
393
|
+
if (this.drag && ((this.hasUpdated && changed.has('selected')) || this.selection.disabled))
|
|
394
|
+
this.cancelDrag();
|
|
395
|
+
// SWT-13: a change of condition the product made is drawn by this update.
|
|
396
|
+
if (this.hasUpdated && changed.has('selected'))
|
|
397
|
+
this.markTravel();
|
|
398
|
+
}
|
|
399
|
+
updated(changed) {
|
|
400
|
+
this.selection.setFormValue(this.selected ? this.value : null, String(this.selected));
|
|
401
|
+
// SWT-16: a switch without a name still renders; a debug build says what is missing.
|
|
402
|
+
if (changed.has('label') && !this.label && !this.selection.field.label)
|
|
403
|
+
report(this, 'SWT-16', 'label is empty, so the switch has no accessible name; give it a label');
|
|
404
|
+
}
|
|
405
|
+
render() {
|
|
406
|
+
const visible = !!this.label && !this.labelHidden;
|
|
407
|
+
// The native checkbox with the role switch supplies on / off (never a checked checkbox, SWT-14), focusability, Space
|
|
408
|
+
// and the disabled state. The name is `label`, visible or not; the drawn text and the glyphs are hidden from
|
|
409
|
+
// assistive technology, so on and off are announced from the state and the name once. Both glyphs are in the
|
|
410
|
+
// handle, the unselected one under the selected one, and the progress crossfades them (SWT-19) — as it does the two
|
|
411
|
+
// layers of the track (.fill), of the container (.tint) and of the handle (.paint); the two rulers and the row they
|
|
412
|
+
// stand in (.sizer) are the handle's size (switch.styles.ts).
|
|
413
|
+
return html `
|
|
414
|
+
<label
|
|
415
|
+
class="root"
|
|
416
|
+
?data-selected-icon=${!!this.selectedIcon}
|
|
417
|
+
?data-unselected-icon=${!!this.unselectedIcon}
|
|
418
|
+
@click=${this.onRootClick}
|
|
419
|
+
@pointerdown=${this.onRootPointerDown}
|
|
420
|
+
@pointerup=${this.press.release}
|
|
421
|
+
@pointercancel=${this.press.release}
|
|
422
|
+
@pointerleave=${this.onPointerLeave}
|
|
423
|
+
>
|
|
424
|
+
<span class="control" @pointerdown=${this.onControlPointerDown} @lostpointercapture=${this.onLostPointerCapture}>
|
|
425
|
+
<input
|
|
426
|
+
class="native"
|
|
427
|
+
type="checkbox"
|
|
428
|
+
role="switch"
|
|
429
|
+
.checked=${live(this.selected)}
|
|
430
|
+
?disabled=${this.selection.disabled}
|
|
431
|
+
aria-label=${this.selection.field.name(this.label) || nothing}
|
|
432
|
+
aria-description=${this.selection.field.description() || nothing}
|
|
433
|
+
aria-invalid=${this.selection.field.invalid ? 'true' : nothing}
|
|
434
|
+
aria-required=${this.selection.field.required ? 'true' : nothing}
|
|
435
|
+
@input=${this.onInput}
|
|
436
|
+
@change=${this.onChange}
|
|
437
|
+
@keydown=${this.onKeyDown}
|
|
438
|
+
@keyup=${this.press.onKeyUp}
|
|
439
|
+
@blur=${this.press.onBlur}
|
|
440
|
+
@focus=${this.onFocus}
|
|
441
|
+
/>
|
|
442
|
+
<span part="track" class="track" data-tanrei-shape aria-hidden="true"><span class="fill off"></span><span class="fill on"></span></span>
|
|
443
|
+
<span class="thumb" aria-hidden="true" @transitionend=${this.endTravel} @transitioncancel=${this.endTravel}>
|
|
444
|
+
<span part="container" class="container" data-tanrei-shape><span class="tint off"></span><span class="tint on"></span></span>
|
|
445
|
+
<span class="sizer">
|
|
446
|
+
<span class="ruler more"><span></span></span>
|
|
447
|
+
<span class="ruler less"><span></span></span>
|
|
448
|
+
<span class="elevation off"></span>
|
|
449
|
+
<span class="elevation on"></span>
|
|
450
|
+
<span part="handle" class="handle">
|
|
451
|
+
<span class="paint off"></span>
|
|
452
|
+
<span class="paint on"></span>
|
|
453
|
+
${this.unselectedIcon ? html `<span class="glyph off"><span part="icon" class="icon off"><span class="ink">${this.unselectedIcon}</span></span></span>` : nothing}
|
|
454
|
+
${this.selectedIcon ? html `<span class="glyph on"><span part="icon" class="icon on"><span class="ink">${this.selectedIcon}</span></span></span>` : nothing}
|
|
455
|
+
</span>
|
|
456
|
+
</span>
|
|
457
|
+
</span>
|
|
458
|
+
</span>
|
|
459
|
+
${visible ? html `<span part="label" class="label" aria-hidden="true">${this.label}</span>` : nothing}
|
|
460
|
+
</label>
|
|
461
|
+
`;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
// Its `disabled` attribute, written while it holds focus, waits until focus has left: a frame at most.
|
|
465
|
+
disabledWaitsWhileFocused(TanreiSwitch);
|
|
466
|
+
// `autofocus` on it gives it focus when the page first loads too (src/primitives/autofocus.ts).
|
|
467
|
+
focusedAtFirst(TanreiSwitch);
|
|
468
|
+
if (!customElements.get('tanrei-switch'))
|
|
469
|
+
customElements.define('tanrei-switch', TanreiSwitch);
|
|
470
|
+
//# sourceMappingURL=switch.js.map
|