@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,929 @@
|
|
|
1
|
+
import { LitElement, html, nothing } from 'lit';
|
|
2
|
+
import { AvailabilityController, FieldControlController, GlyphDrawnController, KeptLengths, NativeTextController, OpenAxesController, ambientLocale, report, supportedLocale, syncFocusStyle, WordsController, } from '../../primitives/index.js';
|
|
3
|
+
import { missingValueMessage } from '../../primitives/missing-value.js';
|
|
4
|
+
import { FloatingLabelController, floatingAsterisk, floatingLabel, triggerEdges } from '../../primitives/field-trigger.js';
|
|
5
|
+
import '../button/button.js';
|
|
6
|
+
import { formOf, pressDefaultButton } from '../../primitives/default-button.js';
|
|
7
|
+
import { takeFormDisabled } from '../../primitives/form-disabled.js';
|
|
8
|
+
import { FormSays } from '../../primitives/form-says.js';
|
|
9
|
+
import { AXES, INSET, styles } from './number-input.styles.js';
|
|
10
|
+
import { runDirection } from '../../styles/product-text.js';
|
|
11
|
+
import { ZERO, canonical, clamp, compare, decimalFromString, decimalOf, format, numberForm, numberOf, read, round, stepped, times } from './number-text.js';
|
|
12
|
+
import { disabledWaitsWhileFocused } from '../../primitives/disabled-while-focused.js';
|
|
13
|
+
import { focusedAtFirst } from '../../primitives/autofocus.js';
|
|
14
|
+
const ALIGNS = ['start', 'end'];
|
|
15
|
+
/** NMI-23: Page Up and Page Down step by ten times the step. */
|
|
16
|
+
const PAGE = 10;
|
|
17
|
+
/** NMI-27: after its tenth repeated step a hold steps at the fast interval. */
|
|
18
|
+
const FAST_AFTER = 10;
|
|
19
|
+
/** The most digits after the separator a number is written with (what `Intl` itself allows). */
|
|
20
|
+
const MOST_DIGITS = 20;
|
|
21
|
+
/** A finite number, or null: what `value`, `min` and `max` are whatever they were given (a string of an attribute, undefined, NaN). */
|
|
22
|
+
export function numberOrNull(value) {
|
|
23
|
+
if (value === null || value === undefined || value === '')
|
|
24
|
+
return null;
|
|
25
|
+
const number = typeof value === 'number' ? value : typeof value === 'string' ? (decimalFromString(value) ? Number(value) : Number.NaN) : Number.NaN;
|
|
26
|
+
return Number.isFinite(number) ? number : null;
|
|
27
|
+
}
|
|
28
|
+
/** An attribute that holds a plain decimal number ("12.5"), or nothing: a property that is a number or null. */
|
|
29
|
+
export const NUMBER_OR_NULL = { converter: { fromAttribute: (value) => numberOrNull(value) } };
|
|
30
|
+
/** NMI-16: a platform whose decimal keypad has no minus sign (iOS and iPadOS, which may report itself as a Mac). */
|
|
31
|
+
function keypadWithoutMinus() {
|
|
32
|
+
if (typeof navigator === 'undefined')
|
|
33
|
+
return false;
|
|
34
|
+
return /iP(hone|ad|od)/.test(navigator.userAgent) || (/Mac/.test(navigator.platform ?? '') && navigator.maxTouchPoints > 1);
|
|
35
|
+
}
|
|
36
|
+
/** Runs `task` once the document has been read: an element upgraded while its children are still being parsed has none yet. */
|
|
37
|
+
function whenParsed(task) {
|
|
38
|
+
if (document.readyState === 'loading')
|
|
39
|
+
document.addEventListener('DOMContentLoaded', task, { once: true });
|
|
40
|
+
else
|
|
41
|
+
task();
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The box of a number: lets people enter a number as a number — typed in their locale's form or stepped by a key or a
|
|
45
|
+
* button, kept within limits, with its unit beside it — and draws no row around it. A `<tanrei-field>` frames it with
|
|
46
|
+
* a label, a requirement mark, help and an error, or the product names it with `label` where its visible label is
|
|
47
|
+
* elsewhere: the head of a table's column, a toolbar, the title of a row that also holds a slider.
|
|
48
|
+
* `<tanrei-number-field>` is the two as one element.
|
|
49
|
+
*
|
|
50
|
+
* Contract: specs/number-input.spec.json. Every visual value is a token: the box is drawn from
|
|
51
|
+
* `--tanrei-comp-input-box-*`, the one set every input box is drawn from (NMI-47), and where the steppers stand and how
|
|
52
|
+
* a hold repeats from `--tanrei-comp-number-input-*`; the steppers are `<tanrei-button>`s, drawn from
|
|
53
|
+
* Button's own tokens.
|
|
54
|
+
*
|
|
55
|
+
* ```html
|
|
56
|
+
* <tanrei-number-input label="Scale" value="1.5" min="0.25" max="4" step="0.05" suffix-text="×" value-text="1.5 times" align="end" no-steppers></tanrei-number-input>
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* `value` is a number, or null while the input holds none. It changes on a **commit** — focus leaves, Enter, a step —
|
|
60
|
+
* and never while the person types: the text is theirs until then, and nothing typed is refused, reformatted, clamped
|
|
61
|
+
* or rounded. `input` carries what the text reads as meanwhile (what a slider beside the input follows). A commit
|
|
62
|
+
* raises the number to `min`, lowers it to `max`, rounds it to `maxFractionDigits` and writes it back in the locale's
|
|
63
|
+
* form — its digits and its decimal separator, no grouping separators. A text that is not a number is kept, marked as
|
|
64
|
+
* an error, reported with `entryerror` and told to the Field that frames it, which shows `invalidText`.
|
|
65
|
+
*
|
|
66
|
+
* `step` is how far Up Arrow, Down Arrow and a stepper move the number (Page Up and Page Down ten times as far), to
|
|
67
|
+
* the next number on the step's grid counted from `min`; it does not limit what may be typed. Home and End stay the
|
|
68
|
+
* caret's, and the wheel never changes the number.
|
|
69
|
+
*
|
|
70
|
+
* It is a block as wide as its place, with no width of its own: give it a narrower place for a narrower box. In a
|
|
71
|
+
* Field it takes the Field's name, description and required, invalid and disabled states, floats the Field's label
|
|
72
|
+
* in the filled and the outlined look, and tells the Field where its number's line starts and ends. It is a
|
|
73
|
+
* form-associated element: it takes `name`, submits its value as a plain decimal number ("12.5") whatever the locale
|
|
74
|
+
* shows, resets to the `value` attribute, is restored on navigation, follows `<fieldset disabled>` and reports
|
|
75
|
+
* `valueMissing` while its Field says it is required and it holds no value, and `badInput` while it holds a text that
|
|
76
|
+
* is not a number.
|
|
77
|
+
*
|
|
78
|
+
* To assistive technology it is a spin button: its value the committed number, its limits `min` and `max`, its value
|
|
79
|
+
* text `valueText` or the number as shown with its prefix and suffix. The two steppers are named buttons outside the
|
|
80
|
+
* focus order.
|
|
81
|
+
*
|
|
82
|
+
* @tag tanrei-number-input
|
|
83
|
+
* @csspart container - The input's box.
|
|
84
|
+
* @csspart outline - A stacked number input's inner line, or an outlined one's border.
|
|
85
|
+
* @csspart active-indicator - The line along the bottom of a filled number input.
|
|
86
|
+
* @csspart label - The label floating in a filled or an outlined number input.
|
|
87
|
+
* @csspart requirement-label - The required asterisk after a floating label.
|
|
88
|
+
* @csspart input - The native `<input>`: the spin button.
|
|
89
|
+
* @csspart prefix - The fixed text before the number.
|
|
90
|
+
* @csspart suffix - The fixed text after the number.
|
|
91
|
+
* @csspart stepper - One of the two steppers, a `<tanrei-button>`: first the one that steps down, then the one that steps up.
|
|
92
|
+
* @attr {string} form - The id of the form the number input 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.
|
|
93
|
+
* @fires {CustomEvent<TanreiNumberInputInputDetail>} input - The person changed the text, or a step changed the value. `detail.value` is the number the text reads as — not clamped, not rounded — or null while it reads as no value or as not a number. Composed and bubbling. Never fired when the product sets `value`.
|
|
94
|
+
* @fires change - A commit changed the value: focus left the input, Enter was pressed, a key stepped it, or a pressed stepper was released; `value` is already the new one. Composed and bubbling. Never fired when the product sets `value`.
|
|
95
|
+
* @fires action - The person pressed Enter; after any `change` it caused. Cancelable: unless it is cancelled, the form the number input stands in is then asked to submit.
|
|
96
|
+
* @fires {CustomEvent<TanreiNumberInputEntryErrorDetail>} entryerror - The person committed a text that is not a number. `detail.reason` is `invalid`, `detail.text` the input's `invalidText` (empty where none was given). Composed and bubbling.
|
|
97
|
+
*/
|
|
98
|
+
export class TanreiNumberInput extends LitElement {
|
|
99
|
+
static { this.styles = styles; }
|
|
100
|
+
static { this.formAssociated = true; }
|
|
101
|
+
/**
|
|
102
|
+
* Its documented parts, once: what an element composed around it exports (src/primitives/composed.ts). Held equal to
|
|
103
|
+
* the `@csspart` lines above by src/primitives/composed.test.ts.
|
|
104
|
+
*
|
|
105
|
+
* @internal
|
|
106
|
+
*/
|
|
107
|
+
static { this.parts = ['container', 'outline', 'active-indicator', 'label', 'requirement-label', 'input', 'prefix', 'suffix', 'stepper']; }
|
|
108
|
+
static { this.properties = {
|
|
109
|
+
variant: { type: String, reflect: true },
|
|
110
|
+
size: { type: String, reflect: true },
|
|
111
|
+
value: NUMBER_OR_NULL,
|
|
112
|
+
name: { type: String, reflect: true },
|
|
113
|
+
label: { type: String },
|
|
114
|
+
labelHidden: { type: Boolean, attribute: 'label-hidden', reflect: true },
|
|
115
|
+
placeholder: { type: String },
|
|
116
|
+
error: { type: Boolean, reflect: true },
|
|
117
|
+
disabled: { type: Boolean, reflect: true },
|
|
118
|
+
readOnly: { type: Boolean, attribute: 'readonly', reflect: true },
|
|
119
|
+
min: NUMBER_OR_NULL,
|
|
120
|
+
max: NUMBER_OR_NULL,
|
|
121
|
+
step: { type: Number },
|
|
122
|
+
noSteppers: { type: Boolean, attribute: 'no-steppers', reflect: true },
|
|
123
|
+
incrementLabel: { type: String, attribute: 'increment-label' },
|
|
124
|
+
decrementLabel: { type: String, attribute: 'decrement-label' },
|
|
125
|
+
prefixText: { type: String, attribute: 'prefix-text' },
|
|
126
|
+
suffixText: { type: String, attribute: 'suffix-text' },
|
|
127
|
+
valueText: { type: String, attribute: 'value-text' },
|
|
128
|
+
align: { type: String, reflect: true },
|
|
129
|
+
minFractionDigits: { type: Number, attribute: 'min-fraction-digits' },
|
|
130
|
+
maxFractionDigits: { type: Number, attribute: 'max-fraction-digits' },
|
|
131
|
+
locale: { type: String },
|
|
132
|
+
invalidText: { type: String, attribute: 'invalid-text' },
|
|
133
|
+
text: { state: true },
|
|
134
|
+
entryError: { state: true },
|
|
135
|
+
pressing: { state: true },
|
|
136
|
+
focused: { state: true },
|
|
137
|
+
formDisabled: { state: true },
|
|
138
|
+
}; }
|
|
139
|
+
/** The committed number, or null while the input holds none. It changes when the person commits — focus leaves, Enter, a step — not on every keystroke; `input` carries what is being typed. The `value` attribute is a plain decimal number ("12.5"), and the value a form reset returns to. */
|
|
140
|
+
get value() {
|
|
141
|
+
return this.given;
|
|
142
|
+
}
|
|
143
|
+
// NMI-31: a value the product sets replaces the text and ends an entry error — also where it is the value held
|
|
144
|
+
// already, which is no change of the property and so no update: an entry error leaves the value empty (NMI-21), and
|
|
145
|
+
// the product that clears the field sets it empty. What the input makes the value itself goes through `keep()`.
|
|
146
|
+
set value(value) {
|
|
147
|
+
this.given = value;
|
|
148
|
+
if ((this.edited || this.entryError) && numberOrNull(value) === this.ownValue) {
|
|
149
|
+
this.took(this.ownValue);
|
|
150
|
+
this.requestUpdate();
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
constructor() {
|
|
154
|
+
super();
|
|
155
|
+
this.availability = new AvailabilityController(this, 'number-input');
|
|
156
|
+
/** The look, as the text inputs beside it: `stacked` is a filled box whose label is the row of its Field; `filled` and `outlined` float the label inside the box. Use one style per form. A value the number input does not know by name is laid out as stacked. Reflected. */
|
|
157
|
+
this.variant = 'stacked';
|
|
158
|
+
/** The container's minimum height: `medium` or `large` (48 / 56 in the default system), the text input's two sizes. The hit area always meets the minimum target. Reflected. */
|
|
159
|
+
this.size = 'medium';
|
|
160
|
+
/** The name the value is submitted under in a form. Reflected. */
|
|
161
|
+
this.name = '';
|
|
162
|
+
/** Names the number input where no Field does, or where its visible label is elsewhere: it wins over the Field's label as the accessible name, and is what a filled or an outlined input floats. Never drawn by a stacked input. */
|
|
163
|
+
this.label = '';
|
|
164
|
+
/** Does not draw the floating label of a filled or an outlined input, which stays the accessible name (`label-hidden`). The Field that frames it says the same with its own `labelHidden`. */
|
|
165
|
+
this.labelHidden = false;
|
|
166
|
+
/** A hint shown while the input is empty and the label is not in the input line. Never a replacement for `label`. */
|
|
167
|
+
this.placeholder = '';
|
|
168
|
+
/** Puts the number input in the error condition: every part of its box is drawn from the error parts and it is exposed as invalid. The Field that frames it sets the same through its own `error`. The number input never sets this itself; it enters an error of its own while the text it was left with is not a number. */
|
|
169
|
+
this.error = false;
|
|
170
|
+
/** Prevents focus, editing, stepping and form submission. */
|
|
171
|
+
this.disabled = false;
|
|
172
|
+
/** The number can be focused, selected and copied, and is submitted, but not changed: no key steps it and no stepper is drawn. The attribute is `readonly`. */
|
|
173
|
+
this.readOnly = false;
|
|
174
|
+
/** The lowest number a commit keeps; a lower one is raised to it. Null for no limit. It is also where the steps are counted from. */
|
|
175
|
+
this.min = null;
|
|
176
|
+
/** The highest number a commit keeps; a higher one is lowered to it. Null for no limit. A `max` below `min` is no limit. */
|
|
177
|
+
this.max = null;
|
|
178
|
+
/** How far Up Arrow, Down Arrow and a stepper move the number; Page Up and Page Down move ten times as far. It does not limit what may be typed. 0 or less, or not a number, steps by 1. */
|
|
179
|
+
this.step = 1;
|
|
180
|
+
/** Draws no steppers (`no-steppers`: the spec's `steppers`, inverted, because a boolean attribute cannot default to true): for an input in a row too narrow for them, or beside a slider that does their work. The keys still step. Reflected. */
|
|
181
|
+
this.noSteppers = false;
|
|
182
|
+
/** The accessible name of the stepper that steps up (`increment-label`): this instance's words, else the product's (`setWords({ incrementLabel })`). Tanrei has none: without them the stepper is drawn, works for a pointer and is kept from assistive technology, where the spin button steps by itself. */
|
|
183
|
+
this.incrementLabel = '';
|
|
184
|
+
/** The accessible name of the stepper that steps down (`decrement-label`): this instance's words, else the product's (`setWords({ decrementLabel })`). Tanrei has none: without them the stepper is drawn, works for a pointer and is kept from assistive technology, where the spin button steps by itself. */
|
|
185
|
+
this.decrementLabel = '';
|
|
186
|
+
/** Fixed text before the number, not part of the value (`prefix-text`): a currency sign. Written before the number along the direction of the run the two affixes make — that of their first strong character, the prefix asked first, and left-to-right where they have none — in every layout direction. */
|
|
187
|
+
this.prefixText = '';
|
|
188
|
+
/** Fixed text after the number, not part of the value (`suffix-text`): the unit. Read to assistive technology with the number. Written after the number along the run's direction: at its right for a unit in Latin letters or signs, at its left for one in a right-to-left script or one that begins with a right-to-left mark (U+200F). */
|
|
189
|
+
this.suffixText = '';
|
|
190
|
+
/** The value as words (`value-text`: "12 pixels"), given to assistive technology in place of the number with its prefix and suffix. The same text a slider beside the field takes. */
|
|
191
|
+
this.valueText = '';
|
|
192
|
+
/** Where the number stands in the input: at the `start`, the field's start edge, as the text of every other field; or at the `end` of the number's run — the edge at which the suffix stands or would stand, the right for a number alone or with a unit in Latin letters or signs in every layout direction — for a number against its unit or in a column of numbers. Anything else is `start`. Reflected. */
|
|
193
|
+
this.align = 'start';
|
|
194
|
+
/** The fewest digits shown after the decimal separator; zeros fill them (`min-fraction-digits`: 2 for an amount of money). */
|
|
195
|
+
this.minFractionDigits = 0;
|
|
196
|
+
/** The most digits kept after the decimal separator (`max-fraction-digits`): a commit rounds to it. 0 makes the field hold whole numbers and asks for a keyboard without a separator. */
|
|
197
|
+
this.maxFractionDigits = 3;
|
|
198
|
+
/** A BCP 47 language tag ("de-DE", "ar-EG") for how the number is shown and read: its digits and its decimal separator. Empty reads the nearest `lang` attribute, then the browser's language. The value itself is a number in every locale. */
|
|
199
|
+
this.locale = '';
|
|
200
|
+
/** The words of the refusal of a text that is not a number (`invalid-text`: "Enter a number"): what the Field that frames the input shows in its supporting row while the entry error lasts — its own `errorText` while this is empty — and the input's description where no Field frames it. */
|
|
201
|
+
this.invalidText = '';
|
|
202
|
+
/** The text in the input: the person's while they edit, the committed number in the locale's form otherwise (NMI-16, NMI-17). */
|
|
203
|
+
this.text = '';
|
|
204
|
+
/** NMI-21: the field was committed with a text that is not a number, and holds it still. */
|
|
205
|
+
this.entryError = false;
|
|
206
|
+
/** What `value` holds: what the product set last, or what the input made the value since. */
|
|
207
|
+
this.given = null;
|
|
208
|
+
/** NMI-15: the input has focus, however it was gained. */
|
|
209
|
+
this.focused = false;
|
|
210
|
+
/** Set by an ancestor `<fieldset disabled>` (the element's `formDisabledCallback`). */
|
|
211
|
+
this.formDisabled = false;
|
|
212
|
+
/** The value the number input committed or took from the product last: another `value` is the product's (NMI-31). */
|
|
213
|
+
this.ownValue = null;
|
|
214
|
+
/** NMI-20: the value last committed — when the product set it, or at the last `change`. */
|
|
215
|
+
this.base = null;
|
|
216
|
+
/** NMI-16: the person changed the text since it was last written. */
|
|
217
|
+
this.edited = false;
|
|
218
|
+
/** NMI-31: the product set a value while an input method was composing: its text is written when the composition ends, and is not the person's. */
|
|
219
|
+
this.awaited = false;
|
|
220
|
+
/** NMI-22: a step wrote the text: the caret goes to its end and all of it is kept in view, once it is drawn. */
|
|
221
|
+
this.reveal = false;
|
|
222
|
+
/** NMI-27: the stepper that is held down, and its next step. */
|
|
223
|
+
this.hold = null;
|
|
224
|
+
/** NMI-26: a press of a pointer stepped already; the `click` that ends it is not another step. */
|
|
225
|
+
this.pressed = false;
|
|
226
|
+
/**
|
|
227
|
+
* NMI-26: the stepper whose press has begun and whose `mousedown` is still to come (0: none). The step is taken at
|
|
228
|
+
* `pointerdown`; a step that reaches the limit does not disable that stepper before the `mousedown` of the same
|
|
229
|
+
* press has been heard — at once for a mouse, at the release for a touch — because that event is where the field
|
|
230
|
+
* keeps focus where it is (`onContainerPress`), and a control disabled in between is not sent it: focus left the
|
|
231
|
+
* input, or the control it was on, for the page.
|
|
232
|
+
*/
|
|
233
|
+
this.pressing = 0;
|
|
234
|
+
/** NMI-43: sizes and variants a design system adds, and a value the active system does not have (src/primitives/axes.ts). */
|
|
235
|
+
this.axes = new OpenAxesController(this, { component: 'number-input', behavior: 'NMI-43', axes: AXES });
|
|
236
|
+
/**
|
|
237
|
+
* NMI-45: the input's side of the exchange with the Field that frames it (src/primitives/field.ts). It takes the
|
|
238
|
+
* Field's name, description and states, whether the label is hidden and whether an asterisk follows it; and it says
|
|
239
|
+
* what only it knows — that it draws the label, how far its number's line is inset, its own refusal of an entry. It
|
|
240
|
+
* has an error condition of its own (NMI-10). No Field: it is drawn as a bare input (NMI-46).
|
|
241
|
+
*/
|
|
242
|
+
this.frame = new FieldControlController(this, {
|
|
243
|
+
errorCondition: true,
|
|
244
|
+
named: () => !!this.label.trim(),
|
|
245
|
+
says: () => this.saysToField,
|
|
246
|
+
changed: () => (this.frameChanged = true),
|
|
247
|
+
});
|
|
248
|
+
/** The Field's answer changed since the last update: the floating label may have other lines (NMI-8). */
|
|
249
|
+
this.frameChanged = false;
|
|
250
|
+
/** NMI-16, NMI-31: the text and the native element kept in step without breaking an input method (src/primitives/native-text.ts). */
|
|
251
|
+
this.native = new NativeTextController({
|
|
252
|
+
input: () => this.input,
|
|
253
|
+
value: () => this.text,
|
|
254
|
+
// What an input method is composing is not read (NMI-16): the text follows the element and nothing is said. A
|
|
255
|
+
// value the product set meanwhile is the text that waits for the composition's end (NMI-31).
|
|
256
|
+
setValue: (text) => {
|
|
257
|
+
if (text === this.text || this.awaited)
|
|
258
|
+
return;
|
|
259
|
+
this.text = text;
|
|
260
|
+
this.edited = true;
|
|
261
|
+
},
|
|
262
|
+
});
|
|
263
|
+
/** NMI-8: a floating label that does not fit on one line is given the room its lines take. */
|
|
264
|
+
this.floating = new FloatingLabelController(this);
|
|
265
|
+
/** A glyph the number input draws by name is drawn once the icon set can draw it; until then nothing stands in its place. */
|
|
266
|
+
this.glyphs = new GlyphDrawnController(this, () => this.renderRoot.querySelectorAll('.stepper-glyph'));
|
|
267
|
+
/**
|
|
268
|
+
* NMI-25: the two steppers keep the touch target's length along the row each (src/primitives/kept-length.ts). NMI-8:
|
|
269
|
+
* the length the pair takes is what a floating label must end before (`--_steppers`).
|
|
270
|
+
*/
|
|
271
|
+
this.kept = new KeptLengths(() => this.measureSteppers());
|
|
272
|
+
/** NMI-44: the product's words, read where the instance gives none (src/primitives/words.ts). */
|
|
273
|
+
this.words = new WordsController(this);
|
|
274
|
+
this.repeat = () => {
|
|
275
|
+
const hold = this.hold;
|
|
276
|
+
if (!hold)
|
|
277
|
+
return;
|
|
278
|
+
const moved = this.stepBy(hold.direction, 1, true);
|
|
279
|
+
hold.repeats++;
|
|
280
|
+
if (!moved || this.atLimit(hold.direction))
|
|
281
|
+
this.release();
|
|
282
|
+
else
|
|
283
|
+
hold.timer = setTimeout(this.repeat, hold.repeats >= FAST_AFTER ? hold.fast : hold.interval);
|
|
284
|
+
};
|
|
285
|
+
this.onPointerEnd = () => {
|
|
286
|
+
window.removeEventListener('pointerup', this.onPointerEnd, true);
|
|
287
|
+
window.removeEventListener('pointercancel', this.onPointerEnd, true);
|
|
288
|
+
this.release();
|
|
289
|
+
// The `click` that ends this press follows at once; one that comes later is assistive technology's. A touch's
|
|
290
|
+
// `mousedown` comes with it.
|
|
291
|
+
setTimeout(() => {
|
|
292
|
+
this.pressed = false;
|
|
293
|
+
this.pressing = 0;
|
|
294
|
+
});
|
|
295
|
+
};
|
|
296
|
+
this.internals = this.attachInternals();
|
|
297
|
+
this.says = new FormSays(this, this.internals);
|
|
298
|
+
// A `<label for>` of the page activates the element itself: its input takes focus, and nothing changes.
|
|
299
|
+
this.addEventListener('click', (event) => {
|
|
300
|
+
if (event.composedPath()[0] === this)
|
|
301
|
+
this.focus();
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
get input() {
|
|
305
|
+
return this.renderRoot?.querySelector('.input') ?? null;
|
|
306
|
+
}
|
|
307
|
+
/** NMI-32: disabled by its own `disabled`, a fieldset's, or the Field or the field group that frames it. */
|
|
308
|
+
get inert_() {
|
|
309
|
+
return this.disabled || this.formDisabled || this.frame.disabled;
|
|
310
|
+
}
|
|
311
|
+
/** How the variant is laid out: filled and outlined by name, every other value as stacked (NMI-43). */
|
|
312
|
+
get layout() {
|
|
313
|
+
return this.variant === 'filled' || this.variant === 'outlined' ? this.variant : 'stacked';
|
|
314
|
+
}
|
|
315
|
+
/** NMI-12: the accessible name — its own label, else the label of the Field that frames it. */
|
|
316
|
+
get name_() {
|
|
317
|
+
return this.frame.name(this.label.trim() ? this.label : '');
|
|
318
|
+
}
|
|
319
|
+
/** NMI-8: the label floats in the box — a filled or an outlined input with a name, unless its own `labelHidden` or its Field's says to draw none. */
|
|
320
|
+
get labelled() {
|
|
321
|
+
return this.layout !== 'stacked' && !!this.name_ && !this.labelHidden && !this.frame.labelHidden;
|
|
322
|
+
}
|
|
323
|
+
/** NMI-10, NMI-21: in the error condition — its own `error`, its Field's, or an entry error. */
|
|
324
|
+
get wrong() {
|
|
325
|
+
return this.error || this.frame.invalid || this.entryError;
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* NMI-45: what the input says to the Field that frames it. That it draws the label while its look floats one — the
|
|
329
|
+
* Field draws no label row either way (FLD-25). How far the line of its number stands from its start edge and from
|
|
330
|
+
* its end edge: its inline padding at each, with and without steppers (`INSET`, in the styles; FLD-26). And an
|
|
331
|
+
* entry error, with its words (FLD-28).
|
|
332
|
+
*/
|
|
333
|
+
get saysToField() {
|
|
334
|
+
return {
|
|
335
|
+
drawsLabel: this.layout !== 'stacked',
|
|
336
|
+
inset: INSET(/^[a-z0-9][a-z0-9-]*$/.test(this.size) ? this.size : 'medium'),
|
|
337
|
+
refusal: this.entryError ? { text: this.invalidText } : null,
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* NMI-12, NMI-21: what the input is described by — `invalidText` while an entry error lasts and no Field frames it
|
|
342
|
+
* (a Field shows the words and gives them back as its own description, FLD-28), then the description its Field gives.
|
|
343
|
+
*/
|
|
344
|
+
get described() {
|
|
345
|
+
return [this.entryError && !this.frame.framed ? this.invalidText : '', this.frame.description()].filter(Boolean).join(' ');
|
|
346
|
+
}
|
|
347
|
+
/** NMI-25: the steppers are drawn. */
|
|
348
|
+
get steppers() {
|
|
349
|
+
return !this.noSteppers && !this.readOnly;
|
|
350
|
+
}
|
|
351
|
+
// ── NMI-17, NMI-18, NMI-30, NMI-43: the limits, the digits and the form ───────────────────────────────────────
|
|
352
|
+
/** NMI-30: the limits as decimals; a `max` below `min` is no limit. */
|
|
353
|
+
get limits() {
|
|
354
|
+
const low = numberOrNull(this.min);
|
|
355
|
+
const high = numberOrNull(this.max);
|
|
356
|
+
const min = low === null ? null : decimalOf(low);
|
|
357
|
+
const max = high === null || (low !== null && low > high) ? null : decimalOf(high);
|
|
358
|
+
return { min, max };
|
|
359
|
+
}
|
|
360
|
+
/** NMI-30: the digits after the separator: the most a commit keeps, and the fewest shown — never more than the most. */
|
|
361
|
+
get digits() {
|
|
362
|
+
const whole = (value, fallback) => (typeof value === 'number' && Number.isFinite(value) && value >= 0 ? Math.min(Math.floor(value), MOST_DIGITS) : fallback);
|
|
363
|
+
const max = whole(this.maxFractionDigits, 3);
|
|
364
|
+
return { min: Math.min(whole(this.minFractionDigits, 0), max), max };
|
|
365
|
+
}
|
|
366
|
+
/** NMI-22: the step as a decimal; 0 or less, or not a number, is 1. */
|
|
367
|
+
get stepNow() {
|
|
368
|
+
const step = typeof this.step === 'number' && Number.isFinite(this.step) && this.step > 0 ? decimalOf(this.step) : null;
|
|
369
|
+
return step ?? decimalOf(1);
|
|
370
|
+
}
|
|
371
|
+
/** NMI-17, NMI-43: the locale's form — `locale`, or where it is empty or no tag the browser knows, the nearest `lang` attribute, then the browser's language. */
|
|
372
|
+
get form_() {
|
|
373
|
+
return numberForm((this.locale && supportedLocale(this.locale)) || ambientLocale(this));
|
|
374
|
+
}
|
|
375
|
+
/** NMI-17: a number as the input shows it; an empty value is an empty input. */
|
|
376
|
+
shown(value) {
|
|
377
|
+
const decimal = value === null ? null : decimalOf(value);
|
|
378
|
+
if (!decimal)
|
|
379
|
+
return '';
|
|
380
|
+
const { min, max } = this.digits;
|
|
381
|
+
return format(decimal, this.form_, min, max);
|
|
382
|
+
}
|
|
383
|
+
/** NMI-18: what a text reads as, by the locale's form, without the prefix and the suffix where they were typed with it. */
|
|
384
|
+
reading(text) {
|
|
385
|
+
return read(text, this.form_, { prefix: this.prefixText, suffix: this.suffixText });
|
|
386
|
+
}
|
|
387
|
+
/** The form it belongs to, if any. */
|
|
388
|
+
get form() {
|
|
389
|
+
return this.internals.form;
|
|
390
|
+
}
|
|
391
|
+
/** The native constraint validity: `valueMissing` while its Field says it is required and it holds no value, `badInput` while it holds a text that is not a number. */
|
|
392
|
+
get validity() {
|
|
393
|
+
return this.internals.validity;
|
|
394
|
+
}
|
|
395
|
+
get validationMessage() {
|
|
396
|
+
return this.internals.validationMessage;
|
|
397
|
+
}
|
|
398
|
+
get willValidate() {
|
|
399
|
+
return this.internals.willValidate;
|
|
400
|
+
}
|
|
401
|
+
checkValidity() {
|
|
402
|
+
return this.internals.checkValidity();
|
|
403
|
+
}
|
|
404
|
+
reportValidity() {
|
|
405
|
+
return this.internals.reportValidity();
|
|
406
|
+
}
|
|
407
|
+
/** Moves focus to the input: the number input's one stop in the focus order. */
|
|
408
|
+
focus(options) {
|
|
409
|
+
this.input?.focus(options);
|
|
410
|
+
}
|
|
411
|
+
blur() {
|
|
412
|
+
this.input?.blur();
|
|
413
|
+
}
|
|
414
|
+
/** Selects the text in the input. */
|
|
415
|
+
select() {
|
|
416
|
+
this.input?.select();
|
|
417
|
+
}
|
|
418
|
+
formResetCallback() {
|
|
419
|
+
this.resetTo(numberOrNull(this.getAttribute('value')));
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* NMI-35: a form's reset — the value it was first given is written back. The same value as the one held is still a
|
|
423
|
+
* new one: the text and an entry error go. An element composed around this one, which is then the form's control and
|
|
424
|
+
* holds the `value` attribute, calls it with its own first value.
|
|
425
|
+
*
|
|
426
|
+
* @internal
|
|
427
|
+
*/
|
|
428
|
+
resetTo(value) {
|
|
429
|
+
this.value = value;
|
|
430
|
+
this.took(value);
|
|
431
|
+
this.requestUpdate();
|
|
432
|
+
}
|
|
433
|
+
formStateRestoreCallback(state) {
|
|
434
|
+
this.value = typeof state === 'string' ? numberOrNull(state) : null;
|
|
435
|
+
this.took(numberOrNull(this.value));
|
|
436
|
+
this.requestUpdate();
|
|
437
|
+
}
|
|
438
|
+
formDisabledCallback(disabled) {
|
|
439
|
+
takeFormDisabled(this, disabled, (value) => (this.formDisabled = value));
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* NMI-35: the form's view — the committed value as a plain decimal number, whatever the locale shows, or an empty
|
|
443
|
+
* string; left out while disabled. A missing value while its Field says it is required, and a bad input while an entry
|
|
444
|
+
* error lasts (NMI-12, NMI-21). Said through `FormSays`, where an element composed around it hears it. Said when the number input is drawn, and at once when it commits: a listener of `change`
|
|
445
|
+
* or `action`, and the form Enter submits, already see the new value.
|
|
446
|
+
*/
|
|
447
|
+
syncForm() {
|
|
448
|
+
const decimal = this.ownValue === null ? null : decimalOf(this.ownValue);
|
|
449
|
+
const plain = decimal ? canonical(decimal) : '';
|
|
450
|
+
this.says.value(this.inert_ ? null : plain, plain);
|
|
451
|
+
const missing = this.frame.required && this.ownValue === null;
|
|
452
|
+
if ((this.entryError || missing) && !this.inert_ && !this.readOnly) {
|
|
453
|
+
const missingMessage = missingValueMessage('text', { errorText: '', requiredText: this.frame.state?.requiredText ?? '', label: this.name_ });
|
|
454
|
+
// The words of the refusal: the input's own, else what its Field shows for it (its errorText, or its help).
|
|
455
|
+
const message = this.entryError ? this.invalidText || this.frame.description() || missingMessage : missingMessage;
|
|
456
|
+
this.says.validity({ badInput: this.entryError, valueMissing: missing }, message, this.input ?? undefined);
|
|
457
|
+
}
|
|
458
|
+
else
|
|
459
|
+
this.says.validity();
|
|
460
|
+
}
|
|
461
|
+
// ── NMI-16, NMI-19 … NMI-21, NMI-31: the text and the value ───────────────────────────────────────────────────
|
|
462
|
+
/** NMI-31: the product gave a value: it is written into the input, whatever was typed, an entry error ends, and nothing is said. */
|
|
463
|
+
took(value) {
|
|
464
|
+
this.ownValue = value;
|
|
465
|
+
this.base = value;
|
|
466
|
+
this.edited = false;
|
|
467
|
+
this.entryError = false;
|
|
468
|
+
this.text = this.shown(value);
|
|
469
|
+
this.awaited = this.native.composing;
|
|
470
|
+
}
|
|
471
|
+
/** The number input makes `value` the value itself. */
|
|
472
|
+
keep(value) {
|
|
473
|
+
const before = this.given;
|
|
474
|
+
this.given = value;
|
|
475
|
+
this.ownValue = value;
|
|
476
|
+
this.requestUpdate('value', before);
|
|
477
|
+
}
|
|
478
|
+
/** NMI-20: `change`, once, while the value differs from the one last committed. `value` is already the new one. */
|
|
479
|
+
changed() {
|
|
480
|
+
if (this.ownValue === this.base)
|
|
481
|
+
return;
|
|
482
|
+
this.base = this.ownValue;
|
|
483
|
+
this.dispatchEvent(new Event('change', { bubbles: true, composed: true }));
|
|
484
|
+
}
|
|
485
|
+
said(value) {
|
|
486
|
+
this.dispatchEvent(new CustomEvent('input', { bubbles: true, composed: true, detail: { value } }));
|
|
487
|
+
}
|
|
488
|
+
/**
|
|
489
|
+
* NMI-16, NMI-19, NMI-21: the person changed the text. Nothing is rewritten: the text is theirs. `input` carries the
|
|
490
|
+
* number it reads as, or null; `value` stays the committed number. A text that became a number, or empty, ends an
|
|
491
|
+
* entry error.
|
|
492
|
+
*/
|
|
493
|
+
typed(text) {
|
|
494
|
+
if (this.awaited) {
|
|
495
|
+
// The composition ended on the product's value: it is shown, and nothing is said.
|
|
496
|
+
this.awaited = false;
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
499
|
+
this.text = text;
|
|
500
|
+
this.edited = true;
|
|
501
|
+
const reading = this.reading(text);
|
|
502
|
+
if (reading.kind !== 'invalid')
|
|
503
|
+
this.entryError = false;
|
|
504
|
+
this.said(reading.kind === 'number' ? numberOf(reading.value) : null);
|
|
505
|
+
}
|
|
506
|
+
onInput(event) {
|
|
507
|
+
// The native element's own `input` stops at the shadow root: the number input's carries a number (NMI-19).
|
|
508
|
+
event.stopPropagation();
|
|
509
|
+
// NMI-16: a composition is left to the native element; the text is read when it ends.
|
|
510
|
+
if (this.native.composingInput(event))
|
|
511
|
+
return;
|
|
512
|
+
this.typed(event.target.value);
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* NMI-20, NMI-21: commits the text. A number is raised to `min`, lowered to `max`, rounded to `maxFractionDigits`,
|
|
516
|
+
* made the value and written back in the locale's form; an empty text makes the value empty; a text that is not a
|
|
517
|
+
* number is kept, makes the value empty and enters the entry error (`entryerror`). Then `change`, once, while the
|
|
518
|
+
* value differs from the one last committed. A text the person did not change commits nothing.
|
|
519
|
+
*/
|
|
520
|
+
commit() {
|
|
521
|
+
if (!this.edited || this.inert_ || this.readOnly)
|
|
522
|
+
return;
|
|
523
|
+
this.edited = false;
|
|
524
|
+
const reading = this.reading(this.text);
|
|
525
|
+
if (reading.kind === 'invalid') {
|
|
526
|
+
this.keep(null);
|
|
527
|
+
this.entryError = true;
|
|
528
|
+
this.syncForm();
|
|
529
|
+
this.dispatchEvent(new CustomEvent('entryerror', { bubbles: true, composed: true, detail: { reason: 'invalid', text: this.invalidText } }));
|
|
530
|
+
}
|
|
531
|
+
else {
|
|
532
|
+
this.entryError = false;
|
|
533
|
+
if (reading.kind === 'empty') {
|
|
534
|
+
this.keep(null);
|
|
535
|
+
this.text = '';
|
|
536
|
+
}
|
|
537
|
+
else {
|
|
538
|
+
const { min, max } = this.limits;
|
|
539
|
+
const decimal = round(clamp(reading.value, min, max), this.digits.max);
|
|
540
|
+
this.keep(numberOf(decimal));
|
|
541
|
+
this.text = this.shown(this.ownValue);
|
|
542
|
+
}
|
|
543
|
+
this.syncForm();
|
|
544
|
+
}
|
|
545
|
+
this.changed();
|
|
546
|
+
}
|
|
547
|
+
// ── NMI-22, NMI-23, NMI-26, NMI-27: stepping ──────────────────────────────────────────────────────────────────
|
|
548
|
+
/**
|
|
549
|
+
* NMI-22: steps `direction` by `factor` steps. From the number the text reads as — or from the value where the
|
|
550
|
+
* person did not change the text, or changed it into what is not a number — to the next number that is `min` (or
|
|
551
|
+
* zero) plus a whole multiple of the amount, held within the limits and computed in decimal; a field that holds no
|
|
552
|
+
* value takes the number nearest to zero the limits allow, and nothing more. The result is a commit's: rounded to
|
|
553
|
+
* `maxFractionDigits`, made the value and written into the input. `input`, then `change` — or, while a stepper is
|
|
554
|
+
* held, `change` when the hold ends. A step that would not change the value says nothing. Returns whether it stepped.
|
|
555
|
+
*/
|
|
556
|
+
stepBy(direction, factor, held = false) {
|
|
557
|
+
if (this.inert_ || this.readOnly)
|
|
558
|
+
return false;
|
|
559
|
+
const reading = this.edited ? this.reading(this.text) : null;
|
|
560
|
+
const from = reading?.kind === 'number' ? reading.value : reading?.kind === 'empty' || this.ownValue === null ? null : decimalOf(this.ownValue);
|
|
561
|
+
const { min, max } = this.limits;
|
|
562
|
+
const target = from ? stepped(from, min ?? ZERO, times(this.stepNow, factor), direction) : ZERO;
|
|
563
|
+
const next = numberOf(round(clamp(target, min, max), this.digits.max));
|
|
564
|
+
const moved = next !== this.ownValue;
|
|
565
|
+
// Up at max, down at min: nothing is done. (A text the person had changed is still made the value's.)
|
|
566
|
+
if (!moved && !this.edited && !this.entryError)
|
|
567
|
+
return false;
|
|
568
|
+
this.keep(next);
|
|
569
|
+
this.text = this.shown(next);
|
|
570
|
+
this.edited = false;
|
|
571
|
+
this.entryError = false;
|
|
572
|
+
this.reveal = true;
|
|
573
|
+
this.syncForm();
|
|
574
|
+
if (!moved)
|
|
575
|
+
return false;
|
|
576
|
+
this.said(next);
|
|
577
|
+
if (!held)
|
|
578
|
+
this.changed();
|
|
579
|
+
return true;
|
|
580
|
+
}
|
|
581
|
+
/** NMI-25: the stepper of `direction` has nowhere to go: the value is at or past that limit, or the field is disabled. */
|
|
582
|
+
atLimit(direction) {
|
|
583
|
+
if (this.inert_)
|
|
584
|
+
return true;
|
|
585
|
+
const value = this.ownValue === null ? null : decimalOf(this.ownValue);
|
|
586
|
+
const { min, max } = this.limits;
|
|
587
|
+
if (!value)
|
|
588
|
+
return false;
|
|
589
|
+
return direction > 0 ? !!max && compare(value, max) >= 0 : !!min && compare(value, min) <= 0;
|
|
590
|
+
}
|
|
591
|
+
/** NMI-27: the three waiting times of a hold, in milliseconds: before the first repeat, between repeats, and between them after the tenth. */
|
|
592
|
+
holdTimes() {
|
|
593
|
+
const box = this.renderRoot.querySelector('.steppers');
|
|
594
|
+
const times = box
|
|
595
|
+
? getComputedStyle(box)
|
|
596
|
+
.transitionDelay.split(',')
|
|
597
|
+
.map((time) => {
|
|
598
|
+
const seconds = Number.parseFloat(time);
|
|
599
|
+
return Number.isFinite(seconds) ? (time.trim().endsWith('ms') ? seconds : seconds * 1000) : 0;
|
|
600
|
+
})
|
|
601
|
+
: [];
|
|
602
|
+
return [times[0] ?? 0, times[1] ?? 0, times[2] ?? times[1] ?? 0];
|
|
603
|
+
}
|
|
604
|
+
/**
|
|
605
|
+
* NMI-26, NMI-27: a press on a stepper steps once when it begins, and takes no focus (the container's `mousedown`
|
|
606
|
+
* keeps it where it is). Held, it steps again after `motion.repeat-delay`, then once every `motion.repeat-interval`,
|
|
607
|
+
* and after its tenth repeated step once every `motion.repeat-interval-fast`, until the press ends, the pointer
|
|
608
|
+
* leaves the stepper, or the value reaches the limit. Every step is one step; `change` follows once, when it ends.
|
|
609
|
+
*/
|
|
610
|
+
onStepperDown(event, direction) {
|
|
611
|
+
if (!event.isPrimary || event.button !== 0)
|
|
612
|
+
return;
|
|
613
|
+
this.release();
|
|
614
|
+
this.pressed = true;
|
|
615
|
+
this.pressing = direction;
|
|
616
|
+
window.addEventListener('pointerup', this.onPointerEnd, true);
|
|
617
|
+
window.addEventListener('pointercancel', this.onPointerEnd, true);
|
|
618
|
+
if (this.inert_ || this.readOnly || this.atLimit(direction))
|
|
619
|
+
return;
|
|
620
|
+
// A touch is captured by what it lands on: without the capture, leaving the stepper is heard (NMI-27).
|
|
621
|
+
const target = event.composedPath()[0];
|
|
622
|
+
if (target instanceof Element && target.hasPointerCapture?.(event.pointerId))
|
|
623
|
+
target.releasePointerCapture(event.pointerId);
|
|
624
|
+
this.stepBy(direction, 1, true);
|
|
625
|
+
if (this.atLimit(direction)) {
|
|
626
|
+
this.changed();
|
|
627
|
+
return;
|
|
628
|
+
}
|
|
629
|
+
const [delay, interval, fast] = this.holdTimes();
|
|
630
|
+
this.hold = { direction, timer: undefined, repeats: 0, interval, fast };
|
|
631
|
+
this.hold.timer = setTimeout(this.repeat, delay);
|
|
632
|
+
}
|
|
633
|
+
/** NMI-27: the hold ends: no more steps, and `change` once while the value differs from the one last committed. */
|
|
634
|
+
release() {
|
|
635
|
+
if (!this.hold)
|
|
636
|
+
return;
|
|
637
|
+
clearTimeout(this.hold.timer);
|
|
638
|
+
this.hold = null;
|
|
639
|
+
if (this.isConnected)
|
|
640
|
+
this.changed();
|
|
641
|
+
}
|
|
642
|
+
/** NMI-26: a stepper activated through assistive technology — a `click` no press of a pointer began — steps once. */
|
|
643
|
+
onStepperClick(event, direction) {
|
|
644
|
+
const pointer = this.pressed && event.detail > 0;
|
|
645
|
+
this.pressed = false;
|
|
646
|
+
if (!pointer)
|
|
647
|
+
this.stepBy(direction, 1);
|
|
648
|
+
}
|
|
649
|
+
/**
|
|
650
|
+
* NMI-20, NMI-23: the input's keys. Up Arrow and Down Arrow step by `step`, Page Up and Page Down by ten times it —
|
|
651
|
+
* once for each repeat of a held key; Enter commits, fires `action` after any `change`, and asks the form to submit
|
|
652
|
+
* unless `action` was cancelled. Home, End, Left Arrow and Right Arrow, and every arrow or page key with a modifier,
|
|
653
|
+
* are the text's. While an input method composes, every key is its own.
|
|
654
|
+
*/
|
|
655
|
+
onKeyDown(event) {
|
|
656
|
+
if (event.defaultPrevented || this.inert_)
|
|
657
|
+
return;
|
|
658
|
+
if (event.isComposing || this.native.composing || event.keyCode === 229)
|
|
659
|
+
return;
|
|
660
|
+
const { key } = event;
|
|
661
|
+
if (key === 'Enter') {
|
|
662
|
+
this.commit();
|
|
663
|
+
// Its own form, or the form of the element composed around it (src/primitives/default-button.ts, `formOf`).
|
|
664
|
+
const form = this.dispatchEvent(new Event('action', { bubbles: true, composed: true, cancelable: true })) ? formOf(this, this.form) : null;
|
|
665
|
+
if (form) {
|
|
666
|
+
event.preventDefault();
|
|
667
|
+
pressDefaultButton(form);
|
|
668
|
+
}
|
|
669
|
+
return;
|
|
670
|
+
}
|
|
671
|
+
if (this.readOnly || event.ctrlKey || event.metaKey || event.altKey || event.shiftKey)
|
|
672
|
+
return;
|
|
673
|
+
const step = key === 'ArrowUp' ? [1, 1] : key === 'ArrowDown' ? [-1, 1] : key === 'PageUp' ? [1, PAGE] : key === 'PageDown' ? [-1, PAGE] : null;
|
|
674
|
+
if (!step)
|
|
675
|
+
return;
|
|
676
|
+
event.preventDefault();
|
|
677
|
+
this.stepBy(step[0], step[1]);
|
|
678
|
+
}
|
|
679
|
+
onFocus() {
|
|
680
|
+
this.focused = true;
|
|
681
|
+
// NMI-15: where style queries are missing, the focus style is read when focus arrives.
|
|
682
|
+
syncFocusStyle(this, this.renderRoot.querySelector('.field'));
|
|
683
|
+
}
|
|
684
|
+
/** NMI-20: the input lost focus: the text is committed. */
|
|
685
|
+
onBlur() {
|
|
686
|
+
this.focused = false;
|
|
687
|
+
this.commit();
|
|
688
|
+
}
|
|
689
|
+
/**
|
|
690
|
+
* NMI-14: a press on the container's padding, on a floating label, on the prefix or on the suffix moves focus to the input and does
|
|
691
|
+
* nothing else. A press in the input places the caret. NMI-26: a press on a stepper moves no focus: a field that was
|
|
692
|
+
* not focused stays unfocused, and a focused input keeps its focus and its caret.
|
|
693
|
+
*/
|
|
694
|
+
onContainerPress(event) {
|
|
695
|
+
if (event.button !== 0)
|
|
696
|
+
return;
|
|
697
|
+
const target = event.target;
|
|
698
|
+
if (target.closest('.input'))
|
|
699
|
+
return;
|
|
700
|
+
event.preventDefault();
|
|
701
|
+
// NMI-26: the press's `mousedown` has been heard: a stepper that reached the limit is disabled from here on.
|
|
702
|
+
if (target.closest('.steppers'))
|
|
703
|
+
this.pressing = 0;
|
|
704
|
+
else if (!this.inert_)
|
|
705
|
+
this.focus();
|
|
706
|
+
}
|
|
707
|
+
/**
|
|
708
|
+
* NMI-8: the length the steppers take, for a floating label to end before. Read now; what is returned writes it
|
|
709
|
+
* (nothing where it is what the field has): the fields of a page are all read before any of them is written
|
|
710
|
+
* (src/primitives/kept-length.ts).
|
|
711
|
+
*/
|
|
712
|
+
measureSteppers() {
|
|
713
|
+
const field = this.renderRoot.querySelector('.field');
|
|
714
|
+
const box = this.renderRoot.querySelector('.steppers');
|
|
715
|
+
if (!field)
|
|
716
|
+
return undefined;
|
|
717
|
+
const length = box ? `${Math.round(box.getBoundingClientRect().width * 100) / 100}px` : '';
|
|
718
|
+
if (field.style.getPropertyValue('--_steppers') === length)
|
|
719
|
+
return undefined;
|
|
720
|
+
return () => {
|
|
721
|
+
if (length)
|
|
722
|
+
field.style.setProperty('--_steppers', length);
|
|
723
|
+
else
|
|
724
|
+
field.style.removeProperty('--_steppers');
|
|
725
|
+
};
|
|
726
|
+
}
|
|
727
|
+
disconnectedCallback() {
|
|
728
|
+
super.disconnectedCallback();
|
|
729
|
+
window.removeEventListener('pointerup', this.onPointerEnd, true);
|
|
730
|
+
window.removeEventListener('pointercancel', this.onPointerEnd, true);
|
|
731
|
+
this.release();
|
|
732
|
+
this.pressing = 0;
|
|
733
|
+
this.kept.clear();
|
|
734
|
+
this.focused = false;
|
|
735
|
+
}
|
|
736
|
+
willUpdate(changed) {
|
|
737
|
+
if (this.inert_)
|
|
738
|
+
this.focused = false;
|
|
739
|
+
// NMI-31: a value the product set is written into the input whatever the person had typed, ends an entry error and
|
|
740
|
+
// says nothing. NMI-30: it is shown as it is, never corrected by the limits.
|
|
741
|
+
const value = numberOrNull(this.value);
|
|
742
|
+
if (changed.has('value') && value !== this.ownValue)
|
|
743
|
+
this.took(value);
|
|
744
|
+
// NMI-17, NMI-31: the limits, the step, the digits or the locale changed: the value is shown again in the new form,
|
|
745
|
+
// and is not changed. A text the person is editing, or was left with, is never touched.
|
|
746
|
+
else if (!this.edited && !this.entryError && (!this.hasUpdated || ['minFractionDigits', 'maxFractionDigits', 'locale'].some((name) => changed.has(name))))
|
|
747
|
+
this.text = this.shown(this.ownValue);
|
|
748
|
+
}
|
|
749
|
+
updated(changed) {
|
|
750
|
+
// NMI-16, NMI-31: the text is shown in the element — never into a composition.
|
|
751
|
+
this.native.show();
|
|
752
|
+
const input = this.input;
|
|
753
|
+
if (this.reveal && input && !this.native.composing) {
|
|
754
|
+
this.reveal = false;
|
|
755
|
+
// NMI-22: the caret at the end of the stepped number, and all of it kept in view.
|
|
756
|
+
if (this.focused) {
|
|
757
|
+
input.setSelectionRange(input.value.length, input.value.length);
|
|
758
|
+
input.scrollLeft = input.scrollWidth;
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
// NMI-8: the label's lines follow its text — the Field's, where it gives the name —, the asterisk and the size.
|
|
762
|
+
if (this.frameChanged || changed.has('label') || changed.has('labelHidden') || changed.has('variant') || changed.has('size'))
|
|
763
|
+
this.floating.measure();
|
|
764
|
+
this.frameChanged = false;
|
|
765
|
+
// NMI-25: the steppers that are drawn keep their targets apart.
|
|
766
|
+
this.kept.set([...this.renderRoot.querySelectorAll('.stepper')]);
|
|
767
|
+
if (!this.steppers)
|
|
768
|
+
this.measureSteppers()?.();
|
|
769
|
+
// NMI-25, NMI-26: a stepper that held focus itself — given by a script or by assistive technology, never by Tab or
|
|
770
|
+
// a press — and is disabled now: focus goes to the input, the one stop, before it would go to nothing.
|
|
771
|
+
const holder = this.shadowRoot?.activeElement;
|
|
772
|
+
if (!this.inert_ && holder?.classList.contains('stepper') && holder.disabled)
|
|
773
|
+
this.focus();
|
|
774
|
+
this.syncForm();
|
|
775
|
+
whenParsed(() => this.reports(changed));
|
|
776
|
+
}
|
|
777
|
+
/** What a debug build tells the developer; the number input still renders. */
|
|
778
|
+
reports(changed) {
|
|
779
|
+
if (!this.isConnected)
|
|
780
|
+
return;
|
|
781
|
+
// NMI-12: an input no Field names, with no label of its own, still renders. (A Field with an empty label says so itself: FLD-10.)
|
|
782
|
+
if (!this.label.trim() && !this.frame.state)
|
|
783
|
+
report(this, 'NMI-12', 'label is empty and no field frames it, so the number input has no accessible name; put it in a field with a label, or give it a label');
|
|
784
|
+
// NMI-44: a stepper nobody named is kept from assistive technology, and said to the developer.
|
|
785
|
+
if (this.steppers && !this.words.get('incrementLabel', this.incrementLabel)) {
|
|
786
|
+
this.words.missing('incrementLabel', { id: 'NMI-44', effect: 'the stepper that steps up has no name and is kept from assistive technology; the spin button still steps' });
|
|
787
|
+
}
|
|
788
|
+
if (this.steppers && !this.words.get('decrementLabel', this.decrementLabel)) {
|
|
789
|
+
this.words.missing('decrementLabel', { id: 'NMI-44', effect: 'the stepper that steps down has no name and is kept from assistive technology; the spin button still steps' });
|
|
790
|
+
}
|
|
791
|
+
if (changed.has('step') && !(typeof this.step === 'number' && Number.isFinite(this.step) && this.step > 0))
|
|
792
|
+
report(this, 'NMI-22', `step "${String(this.step)}" is not a number above 0; the number input steps by 1`);
|
|
793
|
+
const low = numberOrNull(this.min);
|
|
794
|
+
const high = numberOrNull(this.max);
|
|
795
|
+
if ((changed.has('min') || changed.has('max')) && low !== null && high !== null && low > high)
|
|
796
|
+
report(this, 'NMI-30', `min (${low}) is above max (${high}); max is treated as empty`);
|
|
797
|
+
if ((changed.has('minFractionDigits') || changed.has('maxFractionDigits')) && this.minFractionDigits > this.maxFractionDigits) {
|
|
798
|
+
report(this, 'NMI-30', `minFractionDigits (${this.minFractionDigits}) is above maxFractionDigits (${this.maxFractionDigits}); maxFractionDigits is used for both`);
|
|
799
|
+
}
|
|
800
|
+
if (changed.has('align') && !ALIGNS.includes(this.align))
|
|
801
|
+
report(this, 'NMI-43', `align "${this.align}" is not start or end; it behaves as "start"`);
|
|
802
|
+
if (changed.has('locale') && this.locale && !supportedLocale(this.locale))
|
|
803
|
+
report(this, 'NMI-43', `locale "${this.locale}" is not a language tag the browser knows; the number is shown and read in the form of the page's language`);
|
|
804
|
+
}
|
|
805
|
+
render() {
|
|
806
|
+
const layout = this.layout;
|
|
807
|
+
const stacked = layout === 'stacked';
|
|
808
|
+
const labelled = this.labelled;
|
|
809
|
+
const inert = this.inert_;
|
|
810
|
+
const name = this.name_;
|
|
811
|
+
const described = this.described;
|
|
812
|
+
const wrong = this.wrong;
|
|
813
|
+
const steppers = this.steppers;
|
|
814
|
+
// NMI-44: the steppers' names — the instance's, else the product's words; a stepper without one is kept from assistive technology.
|
|
815
|
+
const incrementLabel = this.words.get('incrementLabel', this.incrementLabel);
|
|
816
|
+
const decrementLabel = this.words.get('decrementLabel', this.decrementLabel);
|
|
817
|
+
// NMI-7: the asterisk follows a floating label while the Field says so (FLD-25); never outside a Field.
|
|
818
|
+
const asterisk = labelled && this.frame.requiredMark === 'asterisk' ? floatingAsterisk('asterisk') : nothing;
|
|
819
|
+
// NMI-34: the spin button's value is the committed number, its limits `min` and `max` while each is given, and
|
|
820
|
+
// its value text `valueText`, or the number as shown with the prefix before it and the suffix after it, each parted
|
|
821
|
+
// from it by a space. A field that holds no value exposes neither.
|
|
822
|
+
const value = this.ownValue === null ? null : decimalOf(this.ownValue);
|
|
823
|
+
const { min, max } = this.limits;
|
|
824
|
+
const valueText = value ? this.valueText || [this.prefixText.trim(), this.shown(this.ownValue), this.suffixText.trim()].filter(Boolean).join(' ') : '';
|
|
825
|
+
// NMI-39: the prefix, the number and the suffix are one run of writing, in the direction of the affixes' first strong
|
|
826
|
+
// character and left-to-right where they have none — the `dir` of the box that holds the three, in every layout
|
|
827
|
+
// direction. Read from the two props alone, so nothing changes sides while the person types. The container, the
|
|
828
|
+
// steppers and the floating label keep the layout's direction. NMI-29: `align` end is the end of that run.
|
|
829
|
+
const run = runDirection(this.prefixText, this.suffixText);
|
|
830
|
+
// NMI-16: a numeric keyboard — with a decimal separator while a fraction may be typed, and one that has a minus
|
|
831
|
+
// sign while a negative number may be.
|
|
832
|
+
const negative = !min || min.int < 0n;
|
|
833
|
+
const inputmode = negative && keypadWithoutMinus() ? 'text' : this.digits.max > 0 ? 'decimal' : 'numeric';
|
|
834
|
+
// NMI-12: the input is named by its own label, else by its Field's — drawn or not, and never by the placeholder —
|
|
835
|
+
// and described by what its Field gives (and by invalidText while an entry error lasts and no Field frames it).
|
|
836
|
+
// It names itself (`aria-label`): an id cannot cross a shadow root, and a name taken from a text that is not
|
|
837
|
+
// drawn is no name to a checker. The floating label, the glyphs, the prefix and the suffix are kept from
|
|
838
|
+
// assistive technology: the name and the value text say them.
|
|
839
|
+
return html `
|
|
840
|
+
<div
|
|
841
|
+
class="field"
|
|
842
|
+
data-layout=${layout}
|
|
843
|
+
data-align=${this.align === 'end' ? 'end' : 'start'}
|
|
844
|
+
data-run=${run}
|
|
845
|
+
?data-error=${wrong}
|
|
846
|
+
?data-disabled=${inert}
|
|
847
|
+
?data-focused=${this.focused && !inert}
|
|
848
|
+
?data-labelled=${labelled}
|
|
849
|
+
?data-has-value=${this.text !== ''}
|
|
850
|
+
?data-steppers=${steppers}
|
|
851
|
+
>
|
|
852
|
+
<div part="container" class="container" data-tanrei-shape aria-disabled=${inert ? 'true' : nothing} @mousedown=${this.onContainerPress}>
|
|
853
|
+
<div class="body" dir=${run}>
|
|
854
|
+
<span part="prefix" class="prefix" aria-hidden="true">${this.prefixText}</span>
|
|
855
|
+
<input
|
|
856
|
+
id="input"
|
|
857
|
+
part="input"
|
|
858
|
+
class="input"
|
|
859
|
+
type="text"
|
|
860
|
+
role="spinbutton"
|
|
861
|
+
inputmode=${inputmode}
|
|
862
|
+
autocomplete="off"
|
|
863
|
+
autocapitalize="none"
|
|
864
|
+
autocorrect="off"
|
|
865
|
+
spellcheck="false"
|
|
866
|
+
.placeholder=${this.placeholder}
|
|
867
|
+
?disabled=${inert}
|
|
868
|
+
?readonly=${this.readOnly}
|
|
869
|
+
aria-label=${name || nothing}
|
|
870
|
+
aria-describedby=${described ? 'description' : nothing}
|
|
871
|
+
aria-invalid=${wrong ? 'true' : nothing}
|
|
872
|
+
aria-required=${this.frame.required ? 'true' : nothing}
|
|
873
|
+
aria-readonly=${this.readOnly ? 'true' : nothing}
|
|
874
|
+
aria-valuenow=${value ? canonical(value) : nothing}
|
|
875
|
+
aria-valuemin=${min ? canonical(min) : nothing}
|
|
876
|
+
aria-valuemax=${max ? canonical(max) : nothing}
|
|
877
|
+
aria-valuetext=${valueText || nothing}
|
|
878
|
+
@input=${this.onInput}
|
|
879
|
+
@keydown=${this.onKeyDown}
|
|
880
|
+
@focus=${this.onFocus}
|
|
881
|
+
@blur=${this.onBlur}
|
|
882
|
+
@compositionstart=${this.native.onCompositionStart}
|
|
883
|
+
@compositionend=${this.native.onCompositionEnd}
|
|
884
|
+
/>
|
|
885
|
+
<span part="suffix" class="suffix" aria-hidden="true">${this.suffixText}</span>
|
|
886
|
+
</div>
|
|
887
|
+
${steppers
|
|
888
|
+
? html `<span class="steppers"
|
|
889
|
+
><tanrei-button
|
|
890
|
+
part="stepper"
|
|
891
|
+
class="stepper down"
|
|
892
|
+
variant="text"
|
|
893
|
+
label=${decrementLabel}
|
|
894
|
+
aria-hidden=${decrementLabel ? nothing : 'true'}
|
|
895
|
+
.outsideFocusOrder=${true}
|
|
896
|
+
?disabled=${this.atLimit(-1) && this.pressing !== -1}
|
|
897
|
+
@pointerdown=${(event) => this.onStepperDown(event, -1)}
|
|
898
|
+
@pointerleave=${this.release}
|
|
899
|
+
@click=${(event) => this.onStepperClick(event, -1)}
|
|
900
|
+
><span slot="icon" class="stepper-glyph"><span class="ink">remove</span></span></tanrei-button
|
|
901
|
+
><tanrei-button
|
|
902
|
+
part="stepper"
|
|
903
|
+
class="stepper up"
|
|
904
|
+
variant="text"
|
|
905
|
+
label=${incrementLabel}
|
|
906
|
+
aria-hidden=${incrementLabel ? nothing : 'true'}
|
|
907
|
+
.outsideFocusOrder=${true}
|
|
908
|
+
?disabled=${this.atLimit(1) && this.pressing !== 1}
|
|
909
|
+
@pointerdown=${(event) => this.onStepperDown(event, 1)}
|
|
910
|
+
@pointerleave=${this.release}
|
|
911
|
+
@click=${(event) => this.onStepperClick(event, 1)}
|
|
912
|
+
><span slot="icon" class="stepper-glyph"><span class="ink">add</span></span></tanrei-button
|
|
913
|
+
></span
|
|
914
|
+
>`
|
|
915
|
+
: nothing}
|
|
916
|
+
${floatingLabel({ floating: labelled, label: name, asterisk })} ${triggerEdges({ stacked, floating: labelled, label: name, asterisk })}
|
|
917
|
+
</div>
|
|
918
|
+
${described ? html `<span id="description" hidden>${described}</span>` : nothing}
|
|
919
|
+
</div>
|
|
920
|
+
`;
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
// Its `disabled` attribute, written while it holds focus, waits until focus has left: a frame at most.
|
|
924
|
+
disabledWaitsWhileFocused(TanreiNumberInput);
|
|
925
|
+
// `autofocus` on it gives it focus when the page first loads too (src/primitives/autofocus.ts).
|
|
926
|
+
focusedAtFirst(TanreiNumberInput);
|
|
927
|
+
if (!customElements.get('tanrei-number-input'))
|
|
928
|
+
customElements.define('tanrei-number-input', TanreiNumberInput);
|
|
929
|
+
//# sourceMappingURL=number-input.js.map
|