@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,1374 @@
|
|
|
1
|
+
import { html, nothing } from 'lit';
|
|
2
|
+
import { repeat } from 'lit/directives/repeat.js';
|
|
3
|
+
import { BUTTON_VARIANTS, FieldControlController, FieldProviderController, GROUP_PLACE, SystemWatchController, WordsController, compChoice, giveAttributes, giveVariant, report, syncFocusStyle, takeBack, } from '../../primitives/index.js';
|
|
4
|
+
import { ComposedElement, composedHost, exported } from '../../primitives/composed.js';
|
|
5
|
+
import { acceptConverter, fileKind } from '../../primitives/file-format.js';
|
|
6
|
+
import { FILE_ITEM_TAKE_FOCUS, FILE_ITEM_UPDATE, giveFileItem } from '../../primitives/file-item-holder.js';
|
|
7
|
+
import { takeFormDisabled } from '../../primitives/form-disabled.js';
|
|
8
|
+
import { hiddenHost } from '../../primitives/hidden.js';
|
|
9
|
+
import { TanreiButton } from '../button/button.js';
|
|
10
|
+
import { TanreiEmbeddedTextInput } from '../embedded-text-input/embedded-text-input.js';
|
|
11
|
+
import { TanreiFileItem } from '../file-item/file-item.js';
|
|
12
|
+
import { TanreiFilePicker } from '../file-picker/file-picker.js';
|
|
13
|
+
import { measured, styles } from './chat-composer.styles.js';
|
|
14
|
+
import { disabledWaitsWhileFocused } from '../../primitives/disabled-while-focused.js';
|
|
15
|
+
const ITEM = 'tanrei-file-item';
|
|
16
|
+
const BUTTON = 'tanrei-button';
|
|
17
|
+
const PREFIX = '--tanrei-comp-chat-composer';
|
|
18
|
+
const LAYOUTS = ['inline', 'stacked'];
|
|
19
|
+
const SEND_KEYS = ['enter', 'modifier'];
|
|
20
|
+
const ATTACHMENTS = ['none', 'own', 'given'];
|
|
21
|
+
const FORMS = ['auto', 'tile', 'row'];
|
|
22
|
+
const STATUSES = ['pending', 'uploading', 'done', 'error'];
|
|
23
|
+
/** CCM-6, CCM-7, CCM-17: the glyphs of the Buttons it brings, by their names in the system's icon set. */
|
|
24
|
+
const GLYPHS = { send: 'send', stop: 'stop', attach: 'attach_file' };
|
|
25
|
+
/** The named slots that hold the product's own Buttons. */
|
|
26
|
+
const SLOTS = ['leading', 'trailing', 'attach', 'send', 'stop'];
|
|
27
|
+
/**
|
|
28
|
+
* W4: each member's documented parts, from the member's own list, each under the member's name: `container`, `label`
|
|
29
|
+
* and `icon` are parts of two or three of them, and `container` is the chat composer's own.
|
|
30
|
+
*/
|
|
31
|
+
const prefixed = (member, prefix) => exported(member, Object.fromEntries(member.parts.map((part) => [part, { as: `${prefix}-${part}` }])));
|
|
32
|
+
const INPUT_PARTS = prefixed(TanreiEmbeddedTextInput, 'input');
|
|
33
|
+
const PICKER_PARTS = prefixed(TanreiFilePicker, 'picker');
|
|
34
|
+
const ITEM_PARTS = prefixed(TanreiFileItem, 'item');
|
|
35
|
+
const ATTACH_PARTS = prefixed(TanreiButton, 'attach');
|
|
36
|
+
const SEND_PARTS = prefixed(TanreiButton, 'send');
|
|
37
|
+
/** CCM-22: a limit of the files it keeps is a number above zero; anything else sets none. */
|
|
38
|
+
const limit = (value) => (typeof value === 'number' && Number.isFinite(value) && value > 0 ? value : null);
|
|
39
|
+
/** CCM-18: the user-perceived characters of a text: grapheme clusters, where the browser segments them, and code points where it does not. */
|
|
40
|
+
function graphemes(text) {
|
|
41
|
+
if (!text)
|
|
42
|
+
return 0;
|
|
43
|
+
const Segmenter = Intl.Segmenter;
|
|
44
|
+
if (!Segmenter)
|
|
45
|
+
return [...text].length;
|
|
46
|
+
let count = 0;
|
|
47
|
+
for (const _ of new Segmenter(undefined, { granularity: 'grapheme' }).segment(text))
|
|
48
|
+
count++;
|
|
49
|
+
return count;
|
|
50
|
+
}
|
|
51
|
+
/** Whether focus is on `element` or inside it, its shadow root included. */
|
|
52
|
+
function holdsFocus(element) {
|
|
53
|
+
const active = element.getRootNode().activeElement;
|
|
54
|
+
return !!active && element.contains(active);
|
|
55
|
+
}
|
|
56
|
+
/** A File item's prop, from the element or — before it is defined — from its attribute. */
|
|
57
|
+
const itemText = (item, prop, attribute) => String(item[prop] ?? item.getAttribute(attribute) ?? '');
|
|
58
|
+
const itemStatus = (item) => {
|
|
59
|
+
const status = itemText(item, 'status', 'status');
|
|
60
|
+
return STATUSES.includes(status) ? status : 'pending';
|
|
61
|
+
};
|
|
62
|
+
const itemRetryable = (item) => (typeof item.retryable === 'boolean' ? item.retryable : item.hasAttribute('retryable'));
|
|
63
|
+
/** CCM-25: focus into a File item that stays — its remove action. */
|
|
64
|
+
const takeFocus = (item) => {
|
|
65
|
+
if (item[FILE_ITEM_TAKE_FOCUS])
|
|
66
|
+
return item[FILE_ITEM_TAKE_FOCUS]();
|
|
67
|
+
item.focus();
|
|
68
|
+
return holdsFocus(item);
|
|
69
|
+
};
|
|
70
|
+
/** CCM-22: the same file — the same name, size and time of last change, as the browser reports them. */
|
|
71
|
+
const sameFile = (a, b) => a === b || (a.name === b.name && a.size === b.size && a.lastModified === b.lastModified);
|
|
72
|
+
/** CCM-22, CCM-31: each reason's key of the product's words. */
|
|
73
|
+
const REASON_WORDS = { type: 'fileTypeErrorText', size: 'fileSizeErrorText', count: 'fileCountErrorText' };
|
|
74
|
+
/** `multiple` is true unless it is said to be false: an attribute that is there says true, and `multiple="false"` false. */
|
|
75
|
+
const DEFAULT_TRUE = { fromAttribute: (value) => value !== 'false' };
|
|
76
|
+
/**
|
|
77
|
+
* Lets a person write a message and send it, in one capsule that holds everything. Built from an Embedded text input
|
|
78
|
+
* (`<tanrei-embedded-text-input>`) — the typing, which grows with what is written — a File picker
|
|
79
|
+
* (`<tanrei-file-picker>`) and File items (`<tanrei-file-item>`) — the attachments, as a strip at the top of the
|
|
80
|
+
* capsule — and Buttons (`<tanrei-button>`): the send button, the stop button in its place, the attach button, and the
|
|
81
|
+
* product's own in its slots. It adds what ties them: the capsule, which is its own part and shows the typing area's
|
|
82
|
+
* focus on its edge; whether what it holds can be sent, and why not; the files it keeps; the counter; one live
|
|
83
|
+
* region; and the form's value. **It never sends**: `send` hands the text and the attachments to the product.
|
|
84
|
+
*
|
|
85
|
+
* Contract: specs/chat-composer.spec.json.
|
|
86
|
+
*
|
|
87
|
+
* ```html
|
|
88
|
+
* <tanrei-chat-composer label="Message" placeholder="Write a message" send-label="Send"
|
|
89
|
+
* attachments="own" attach-label="Attach files" remove-label="Remove">
|
|
90
|
+
* <tanrei-button slot="leading" variant="text" label="Mention someone"><span slot="icon">alternate_email</span></tanrei-button>
|
|
91
|
+
* </tanrei-chat-composer>
|
|
92
|
+
* ```
|
|
93
|
+
*
|
|
94
|
+
* `layout="inline"` (the default) puts every action on the line being written; `layout="stacked"` keeps the send
|
|
95
|
+
* button on that line and puts everything else in a row beneath it, inside the capsule. A capsule narrower than
|
|
96
|
+
* `comp.chat-composer.layout.inline-min-width` is laid out stacked whatever `layout` says; a stacked composer with
|
|
97
|
+
* nothing for the row beneath is drawn as an inline one. Tab moves through it in the order it is drawn.
|
|
98
|
+
*
|
|
99
|
+
* Enter sends and Shift+Enter begins a new line; with `send-key="modifier"` Enter begins a new line. Ctrl+Enter and
|
|
100
|
+
* Command+Enter send under both. An input method's Enter never sends, and neither does the return key of an on-screen
|
|
101
|
+
* keyboard: both are the embedded text input's to tell. A request by the keyboard while the message cannot be sent
|
|
102
|
+
* emits `sendblocked` with the reasons, unless there is simply nothing to send.
|
|
103
|
+
*
|
|
104
|
+
* `attachments="own"`: the composer keeps the files a person attaches — chosen, dropped on the capsule or pasted — and
|
|
105
|
+
* draws a File item for each (`attachment-form`: a tile with its picture for an image, a row for anything else); a
|
|
106
|
+
* refused file is a failed row with the product's sentence for its reason. `files` reads the kept files,
|
|
107
|
+
* `addFiles(files)` hands files over and answers with the refused, `clear()` empties the text and the files.
|
|
108
|
+
* `attachments="given"`: the File items are `<tanrei-file-item>` children the product adds on `select` and removes on
|
|
109
|
+
* an item's `remove`, each with its status and progress; nothing can be sent while one is uploading, or has failed and
|
|
110
|
+
* can be tried again.
|
|
111
|
+
*
|
|
112
|
+
* Form-associated: it submits the text under `name` and, while `attachments` is `own`, each kept file under
|
|
113
|
+
* `files-name`; after `send` — unless that was cancelled — it asks its form to submit, and then does not empty itself.
|
|
114
|
+
* Inside a `<tanrei-field>` it takes the field's label, help, error and `disabled`.
|
|
115
|
+
*
|
|
116
|
+
* Without script, and until the element is defined, a `<textarea>` and a submit `<button>` the product wrote as its
|
|
117
|
+
* children are the form; when it is defined it takes the text area's text and hides and disables both.
|
|
118
|
+
*
|
|
119
|
+
* @tag tanrei-chat-composer
|
|
120
|
+
* @slot leading - The product's own Buttons after the attach button: before the typing area in the inline layout, at the start of the row beneath it in the stacked one. Laid out and never restyled.
|
|
121
|
+
* @slot trailing - The product's own Buttons before the send button in the inline layout, and at the end of the row beneath the typing area in the stacked one. Laid out and never restyled.
|
|
122
|
+
* @slot attach - The product's own Button in place of the attach button the chat composer brings. Exactly one; it opens the browser's picker. Not drawn while `attachments` is `none`.
|
|
123
|
+
* @slot send - The product's own Button in place of the send button the chat composer brings. Exactly one; it sends, and is disabled while nothing can be sent.
|
|
124
|
+
* @slot stop - The product's own Button in place of the stop button the chat composer brings, shown in the send button's place while `sending` and `stoppable` are set. Exactly one.
|
|
125
|
+
* @slot - While `attachments` is `given`: the attachments, `<tanrei-file-item>` children, in order. Anything else is not drawn, and while `attachments` is `own` or `none` nothing here is.
|
|
126
|
+
* @csspart container - The capsule: the one container the chat composer draws, behind everything it holds.
|
|
127
|
+
* @csspart strip - The strip of attachments at the top of the capsule.
|
|
128
|
+
* @csspart counter - The number of characters, and the limit.
|
|
129
|
+
* @csspart embedded-text-input - The typing area: the `<tanrei-embedded-text-input>` it is built from.
|
|
130
|
+
* @csspart file-picker - The `<tanrei-file-picker>` it is built from, around the attach button.
|
|
131
|
+
* @csspart file-item - A File item the chat composer drew itself, while `attachments` is `own`: a `<tanrei-file-item>` it is built from.
|
|
132
|
+
* @csspart button - Each `<tanrei-button>` the chat composer brings: the attach button, and the send or the stop button.
|
|
133
|
+
* @csspart attach-button - The attach button the chat composer brings.
|
|
134
|
+
* @csspart send-button - The send button the chat composer brings.
|
|
135
|
+
* @csspart stop-button - The stop button the chat composer brings, in the send button's place.
|
|
136
|
+
* @exportparts tanrei-embedded-text-input input: input-input
|
|
137
|
+
* @exportparts tanrei-file-picker container: picker-container, icon: picker-icon, label: picker-label, supporting-text: picker-supporting-text, selection-text: picker-selection-text
|
|
138
|
+
* @exportparts tanrei-file-item container: item-container, media: item-media, icon: item-icon, preview: item-preview, headline: item-headline, supporting-text: item-supporting-text, status-icon: item-status-icon, progress: item-progress, action: item-action
|
|
139
|
+
* @exportparts tanrei-button container: attach-container, label: attach-label, icon: attach-icon
|
|
140
|
+
* @exportparts tanrei-button container: send-container, label: send-label, icon: send-icon
|
|
141
|
+
* @attr {string} form - The id of the form the chat composer belongs to, where it stands outside it: the platform's own attribute. The `form` property is read-only and returns the form element.
|
|
142
|
+
* @attr {string} files-name - Web only: the name each kept file is submitted under, while `attachments` is `own` and the chat composer stands in a form. Without it no file is submitted.
|
|
143
|
+
* @fires input - The person changed the text: the typing area's own `input` event, which leaves the element as it is. Read the new text from `event.target.value`. Never when `value` is set, and not when the chat composer empties itself after `send`.
|
|
144
|
+
* @fires {CustomEvent<TanreiChatComposerSendDetail>} send - The person sent what the chat composer holds, by the send button or the keyboard, while it could be sent. `detail.value` is the text exactly as written; `detail.attachments` the kept `File`s (`own`) or the values of the File items that have not failed (`given`), in the order of the strip. Bubbles; cancelable — a cancelled one keeps the content and asks no form to submit.
|
|
145
|
+
* @fires {CustomEvent} stop - The person activated the stop button while `sending` and `stoppable` were set. The product stops what is under way and sets `sending`. Bubbles.
|
|
146
|
+
* @fires {CustomEvent<TanreiChatComposerSendableDetail>} sendablechange - Whether what the chat composer holds can be sent changed, or the reasons it cannot did: `detail.sendable`, and `detail.reasons` by name — `disabled`, `sending`, `blocked`, `empty`, `length`, `uploading`, `failed`. Bubbles. Never when it is first drawn.
|
|
147
|
+
* @fires {CustomEvent<TanreiChatComposerSendableDetail>} sendblocked - The person asked to send by the keyboard while it could not be sent for a reason other than being empty or disabled; `detail.reasons` says why. Bubbles.
|
|
148
|
+
* @fires {CustomEvent<TanreiChatComposerSelectDetail>} select - Files were chosen in the picker, dropped on the capsule or pasted, and passed. Once per arrival; `detail.files` is a `File[]` — while `attachments` is `own`, the files newly kept. Bubbles.
|
|
149
|
+
* @fires {CustomEvent<TanreiChatComposerRejectDetail>} reject - Files of one arrival were refused. Once, after `select` where both happen; `detail.files` is `{ file, reason }[]`, the reason `type`, `size` or `count`. Bubbles.
|
|
150
|
+
* @fires {CustomEvent<TanreiChatComposerAttachmentsChangeDetail>} attachmentschange - While `attachments` is `own`: the kept files changed by what a person did — an arrival that kept a file, or a kept file removed by its File item. `detail.files` is the `File[]` now kept. Bubbles. Never for `addFiles()`, `clear()`, the emptying after `send` or a reset.
|
|
151
|
+
*/
|
|
152
|
+
export class TanreiChatComposer extends ComposedElement {
|
|
153
|
+
static { this.styles = [composedHost, styles, hiddenHost]; }
|
|
154
|
+
/** CCM-36: the one control the form meets. Its members stand in its shadow root, or are the product's own children, and take no part in a form. */
|
|
155
|
+
static { this.formAssociated = true; }
|
|
156
|
+
/**
|
|
157
|
+
* Its parts, once: its own three, each member's host, and what each member exports.
|
|
158
|
+
*
|
|
159
|
+
* @internal
|
|
160
|
+
*/
|
|
161
|
+
static { this.parts = [
|
|
162
|
+
'container',
|
|
163
|
+
'strip',
|
|
164
|
+
'counter',
|
|
165
|
+
'embedded-text-input',
|
|
166
|
+
'file-picker',
|
|
167
|
+
'file-item',
|
|
168
|
+
'button',
|
|
169
|
+
'attach-button',
|
|
170
|
+
'send-button',
|
|
171
|
+
'stop-button',
|
|
172
|
+
...INPUT_PARTS.names,
|
|
173
|
+
...PICKER_PARTS.names,
|
|
174
|
+
...ITEM_PARTS.names,
|
|
175
|
+
...ATTACH_PARTS.names,
|
|
176
|
+
...SEND_PARTS.names,
|
|
177
|
+
]; }
|
|
178
|
+
static get observedAttributes() {
|
|
179
|
+
return [...super.observedAttributes, 'files-name'];
|
|
180
|
+
}
|
|
181
|
+
static { this.properties = {
|
|
182
|
+
value: { type: String },
|
|
183
|
+
label: { type: String },
|
|
184
|
+
placeholder: { type: String },
|
|
185
|
+
layout: { type: String, reflect: true },
|
|
186
|
+
minRows: { type: Number, attribute: 'min-rows' },
|
|
187
|
+
maxRows: { type: Number, attribute: 'max-rows' },
|
|
188
|
+
maxLength: { type: Number, attribute: 'max-length' },
|
|
189
|
+
counter: { type: Boolean },
|
|
190
|
+
sendKey: { type: String, attribute: 'send-key' },
|
|
191
|
+
attachments: { type: String, reflect: true },
|
|
192
|
+
attachmentForm: { type: String, attribute: 'attachment-form' },
|
|
193
|
+
multiple: { attribute: 'multiple', converter: DEFAULT_TRUE },
|
|
194
|
+
accept: { converter: acceptConverter },
|
|
195
|
+
maxSize: { type: Number, attribute: 'max-size' },
|
|
196
|
+
maxFiles: { type: Number, attribute: 'max-files' },
|
|
197
|
+
sending: { type: Boolean, reflect: true },
|
|
198
|
+
stoppable: { type: Boolean },
|
|
199
|
+
blocked: { type: Boolean },
|
|
200
|
+
keepAfterSend: { type: Boolean, attribute: 'keep-after-send' },
|
|
201
|
+
disabled: { type: Boolean, reflect: true },
|
|
202
|
+
error: { type: Boolean, reflect: true },
|
|
203
|
+
sendLabel: { type: String, attribute: 'send-label' },
|
|
204
|
+
stopLabel: { type: String, attribute: 'stop-label' },
|
|
205
|
+
attachLabel: { type: String, attribute: 'attach-label' },
|
|
206
|
+
removeLabel: { type: String, attribute: 'remove-label' },
|
|
207
|
+
retryLabel: { type: String, attribute: 'retry-label' },
|
|
208
|
+
typeErrorText: { type: String, attribute: 'type-error-text' },
|
|
209
|
+
sizeErrorText: { type: String, attribute: 'size-error-text' },
|
|
210
|
+
countErrorText: { type: String, attribute: 'count-error-text' },
|
|
211
|
+
announcement: { type: String },
|
|
212
|
+
name: { type: String, reflect: true },
|
|
213
|
+
typing: { state: true },
|
|
214
|
+
receiving: { state: true },
|
|
215
|
+
narrow: { state: true },
|
|
216
|
+
count: { state: true },
|
|
217
|
+
formDisabled: { state: true },
|
|
218
|
+
}; }
|
|
219
|
+
/** @from tanrei-embedded-text-input.value */
|
|
220
|
+
// W5: the value is the typing area's at every moment — what was last set here until the typing area has taken it,
|
|
221
|
+
// and from then on what it holds, so that `event.target.value` is the new text in every listener of `input`.
|
|
222
|
+
get value() {
|
|
223
|
+
if (this.pending)
|
|
224
|
+
return this.given;
|
|
225
|
+
return this.input?.value ?? this.given;
|
|
226
|
+
}
|
|
227
|
+
set value(value) {
|
|
228
|
+
const text = value === null || value === undefined ? '' : String(value);
|
|
229
|
+
const input = this.input;
|
|
230
|
+
if (!this.pending && input && input.value === text)
|
|
231
|
+
return;
|
|
232
|
+
this.given = text;
|
|
233
|
+
this.pending = true;
|
|
234
|
+
}
|
|
235
|
+
constructor() {
|
|
236
|
+
super();
|
|
237
|
+
/** @from tanrei-embedded-text-input.label */
|
|
238
|
+
this.label = '';
|
|
239
|
+
/** @from tanrei-embedded-text-input.placeholder */
|
|
240
|
+
this.placeholder = '';
|
|
241
|
+
/** Where the actions stand in the capsule. `inline` (the default, and every value it does not know): on the line being written — the attach button and the leading actions before the typing area, the counter, the trailing actions and the send button after it. `stacked`: the typing area and the send button on one line, and everything else in a row beneath them, inside the capsule. A capsule too narrow for inline is laid out stacked whatever this says; the number of lines never changes the layout. */
|
|
242
|
+
this.layout = 'inline';
|
|
243
|
+
/** @from tanrei-embedded-text-input.minRows */
|
|
244
|
+
this.minRows = 1;
|
|
245
|
+
/** The most lines the typing area grows to before it scrolls inside itself (`max-rows`). Given to the embedded text input as its `maxRows`, with a default of the chat composer's own: six lines. 0 sets no limit. */
|
|
246
|
+
this.maxRows = 6;
|
|
247
|
+
/** The most user-perceived characters a message may hold (`max-length`); 0 is no limit. It refuses no edit and shortens no paste: text beyond it stays, is marked, and stops sending until the person has cut it. */
|
|
248
|
+
this.maxLength = 0;
|
|
249
|
+
/** Draws the number of characters, and `maxLength` where one is set, before the trailing actions. */
|
|
250
|
+
this.counter = false;
|
|
251
|
+
/** What Enter does on a hardware keyboard (`send-key`). `enter` (the default, and every value it does not know): Enter sends and Shift+Enter begins a new line. `modifier`: Enter begins a new line and Ctrl+Enter or Command+Enter sends. Ctrl+Enter and Command+Enter send under both. */
|
|
252
|
+
this.sendKey = 'enter';
|
|
253
|
+
/** Whether files can be attached, and who holds them. `none` (the default, and every value it does not know): text alone. `own`: the chat composer keeps the files a person attached and draws a File item for each, and `send` carries them. `given`: the product gives the File items as children and the chat composer lays them out and keeps no file. */
|
|
254
|
+
this.attachments = 'none';
|
|
255
|
+
/** The form of the File items the chat composer draws itself, while `attachments` is `own` (`attachment-form`). `auto` (the default, and every value it does not know): a tile with its picture for an image, a row for every other file. `tile`: every file a tile. `row`: every file a row, and no picture. A refused file is a row under every value. */
|
|
256
|
+
this.attachmentForm = 'auto';
|
|
257
|
+
/** Whether more than one file can be attached. Given to the file picker as its `multiple`; the default is true (`multiple="false"` says false). */
|
|
258
|
+
this.multiple = true;
|
|
259
|
+
/** @from tanrei-file-picker.accept */
|
|
260
|
+
this.accept = [];
|
|
261
|
+
/** @from tanrei-file-picker.maxSize */
|
|
262
|
+
this.maxSize = null;
|
|
263
|
+
/** @from tanrei-file-picker.maxFiles */
|
|
264
|
+
this.maxFiles = null;
|
|
265
|
+
/** What was sent is on its way, or its answer is still arriving: the product's to set and to clear. While it is set nothing more can be sent; the typing area stays open. */
|
|
266
|
+
this.sending = false;
|
|
267
|
+
/** While `sending` is set, puts a stop button in the send button's place, which asks the product to stop what is under way (`stop`). Ignored while `sending` is not set. */
|
|
268
|
+
this.stoppable = false;
|
|
269
|
+
/** The product's own reason that nothing can be sent now. The send button is disabled and the send key sends nothing; the product says why in its own words. */
|
|
270
|
+
this.blocked = false;
|
|
271
|
+
/** Keeps the text and the attachments after `send` (`keep-after-send`), for a product that clears them itself (`clear()`) once it knows the message arrived. */
|
|
272
|
+
this.keepAfterSend = false;
|
|
273
|
+
/** Nothing can be written, attached, removed or sent: every member and every Button in a slot is disabled. Inside a Field, disable the Field. */
|
|
274
|
+
this.disabled = false;
|
|
275
|
+
/** Draws the capsule in its error condition and exposes the typing area as invalid. A Field sets it with its own error. It does not stop sending by itself: `blocked` does. */
|
|
276
|
+
this.error = false;
|
|
277
|
+
/** The accessible name of the send button the chat composer brings (`send-label`): this instance's words, else the product's (`setWords({ sendLabel })`). Tanrei has none: without them the button is drawn and works, and has no name. */
|
|
278
|
+
this.sendLabel = '';
|
|
279
|
+
/** The accessible name of the stop button the chat composer brings (`stop-label`): this instance's words, else the product's (`setWords({ stopLabel })`). */
|
|
280
|
+
this.stopLabel = '';
|
|
281
|
+
/** The accessible name of the attach button the chat composer brings (`attach-label`): this instance's words, else the product's (`setWords({ attachLabel })`). */
|
|
282
|
+
this.attachLabel = '';
|
|
283
|
+
/** @from tanrei-file-item.removeLabel */
|
|
284
|
+
this.removeLabel = '';
|
|
285
|
+
/** @from tanrei-file-item.retryLabel */
|
|
286
|
+
this.retryLabel = '';
|
|
287
|
+
/** While `attachments` is `own`: the sentence on the File item of a file refused for its kind (`type-error-text`): this instance's words, else the product's (`setWords({ fileTypeErrorText })`). */
|
|
288
|
+
this.typeErrorText = '';
|
|
289
|
+
/** While `attachments` is `own`: the sentence on the File item of a file refused for its size (`size-error-text`): this instance's words, else the product's (`setWords({ fileSizeErrorText })`). */
|
|
290
|
+
this.sizeErrorText = '';
|
|
291
|
+
/** While `attachments` is `own`: the sentence on the File item of a file refused because no more can be added (`count-error-text`): this instance's words, else the product's (`setWords({ fileCountErrorText })`). */
|
|
292
|
+
this.countErrorText = '';
|
|
293
|
+
/** A message assistive technology hears through the one live region when the product sets or changes it. Not drawn. */
|
|
294
|
+
this.announcement = '';
|
|
295
|
+
/** Web only: the name the text is submitted under. */
|
|
296
|
+
this.name = '';
|
|
297
|
+
/** CCM-42: the typing area has focus. */
|
|
298
|
+
this.typing = false;
|
|
299
|
+
/** CCM-23: files are dragged over the capsule. */
|
|
300
|
+
this.receiving = false;
|
|
301
|
+
/** CCM-4: the capsule is narrower than `layout.inline-min-width`. */
|
|
302
|
+
this.narrow = false;
|
|
303
|
+
/** CCM-43: how many File items the product gave. */
|
|
304
|
+
this.count = 0;
|
|
305
|
+
/** Set by an ancestor `<fieldset disabled>`, or by the element's own attribute (`formDisabledCallback`). */
|
|
306
|
+
this.formDisabled = false;
|
|
307
|
+
this.hostNameSentence = 'CCM-29';
|
|
308
|
+
this.internals = this.attachInternals();
|
|
309
|
+
/** CCM-31: the product's words, read where the instance gives none (src/primitives/words.ts). */
|
|
310
|
+
this.words = new WordsController(this);
|
|
311
|
+
/** CCM-6: the variant of the send button it brings is a choice the active design system makes; a system switch draws it again. */
|
|
312
|
+
this.system = new SystemWatchController(this);
|
|
313
|
+
/** CCM-28: what a field around the chat composer gives it (src/primitives/field.ts): the name while it has no `label` of its own, the description, the invalid and the disabled state. The chat composer is the field's one control. */
|
|
314
|
+
this.field = new FieldControlController(this, { errorCondition: true, named: () => !!this.label.trim() });
|
|
315
|
+
/**
|
|
316
|
+
* CCM-28: the file picker inside asks as every control does, and the chat composer answers it in a field's place —
|
|
317
|
+
* `disabled` alone — so that its question does not reach a field around the chat composer as a second control.
|
|
318
|
+
*/
|
|
319
|
+
this.provider = new FieldProviderController(this, {
|
|
320
|
+
controls: () => (this.picker ? [this.picker] : []),
|
|
321
|
+
state: () => ({ label: '', description: '', invalid: false, required: false, requiredText: '', disabled: this.isDisabled }),
|
|
322
|
+
plain: () => null,
|
|
323
|
+
});
|
|
324
|
+
/** W5: the value last set on the element, while the typing area has not taken it. */
|
|
325
|
+
this.given = '';
|
|
326
|
+
this.pending = false;
|
|
327
|
+
/** CCM-22: the files it keeps while `attachments` is `own`, in order — handles, never read (CCM-40). */
|
|
328
|
+
this.kept = [];
|
|
329
|
+
/** CCM-22: the files the last arrival refused, in the order they were refused. Not kept. */
|
|
330
|
+
this.refused = [];
|
|
331
|
+
/** What the file picker's two events of one arrival said, until the arrival is over. */
|
|
332
|
+
this.arriving = { accepted: [], refused: [] };
|
|
333
|
+
/** CCM-30: what each File item last said; one not in it is new. */
|
|
334
|
+
this.known = new Map();
|
|
335
|
+
/** CCM-30: the chat composer has been presented: a File item that comes now was added. */
|
|
336
|
+
this.presented = false;
|
|
337
|
+
/** CCM-30: the product's own sentence, set or changed in this turn; what the arrivals of this turn say. */
|
|
338
|
+
this.own = null;
|
|
339
|
+
this.arrived = [];
|
|
340
|
+
/** CCM-38: the next message says no File item: the ones that are there came by a change of `attachments`. */
|
|
341
|
+
this.hush = false;
|
|
342
|
+
/** CCM-25: the File item focus is on, as the last `focusin` said, and the items as they stood. */
|
|
343
|
+
this.held = null;
|
|
344
|
+
this.stood = [];
|
|
345
|
+
/** CCM-23: the drags that entered and have not left. */
|
|
346
|
+
this.drags = 0;
|
|
347
|
+
/** CCM-17: focus was on the button in the send button's place when the update began. */
|
|
348
|
+
this.sendHeld = false;
|
|
349
|
+
/** CCM-4: focus was on a Button the layout is about to draw again. */
|
|
350
|
+
this.startHeld = false;
|
|
351
|
+
/** CCM-41: one line of the typing area's text, as its native element computes it, and the rule that is written from it. */
|
|
352
|
+
this.line = '';
|
|
353
|
+
this.sheet = typeof CSSStyleSheet === 'undefined' ? null : new CSSStyleSheet();
|
|
354
|
+
this.watched = [];
|
|
355
|
+
/** What the product's own Buttons in the slots were given, to take back (CCM-10, CCM-26). */
|
|
356
|
+
this.lent = new Set();
|
|
357
|
+
/** CCM-43, CCM-25, CCM-3: a child that comes or goes — a File item, a Button in a slot — is drawn at once. */
|
|
358
|
+
this.children$ = typeof MutationObserver === 'undefined' ? null : new MutationObserver((records) => this.childrenChanged(records));
|
|
359
|
+
this.onSend = (event) => {
|
|
360
|
+
// A click of the product's own Button in the slot, or of the one it brings.
|
|
361
|
+
if (this.isDisabled || event.target?.disabled === true)
|
|
362
|
+
return;
|
|
363
|
+
this.requestSend(false);
|
|
364
|
+
};
|
|
365
|
+
/** CCM-17: the stop button asks the product to stop, and changes nothing itself. */
|
|
366
|
+
this.onStop = () => {
|
|
367
|
+
if (this.isDisabled || !(this.sending && this.stoppable))
|
|
368
|
+
return;
|
|
369
|
+
this.dispatchEvent(new CustomEvent('stop', { bubbles: true, composed: true }));
|
|
370
|
+
};
|
|
371
|
+
// ─── The typing area (CCM-5, CCM-12, CCM-42) ──────────────────────────────────────────────────────────────────
|
|
372
|
+
/** The person changed the text: the event leaves as it is (W5); the counter, the limit and what can be sent follow. */
|
|
373
|
+
this.onInput = () => {
|
|
374
|
+
this.requestUpdate();
|
|
375
|
+
};
|
|
376
|
+
/** CCM-12: the embedded text input's action is a request to send. The event itself does not leave the element. */
|
|
377
|
+
this.onAction = (event) => {
|
|
378
|
+
event.stopPropagation();
|
|
379
|
+
this.requestSend(true);
|
|
380
|
+
};
|
|
381
|
+
/** W5: the embedded text input's `change` and `rowschange` are not events of the chat composer. */
|
|
382
|
+
this.stop = (event) => event.stopPropagation();
|
|
383
|
+
/** CCM-42: the capsule's edge is the focus indication of the typing area, however its focus was given. */
|
|
384
|
+
this.onTypingFocus = () => {
|
|
385
|
+
syncFocusStyle(this, this.capsule);
|
|
386
|
+
this.typing = true;
|
|
387
|
+
};
|
|
388
|
+
this.onTypingBlur = () => {
|
|
389
|
+
this.typing = false;
|
|
390
|
+
};
|
|
391
|
+
/**
|
|
392
|
+
* CCM-24: a paste into the typing area that holds files and no plain text is an arrival, and inserts nothing; one
|
|
393
|
+
* that holds text is the typing area's.
|
|
394
|
+
*/
|
|
395
|
+
this.onPaste = (event) => {
|
|
396
|
+
const data = event.clipboardData;
|
|
397
|
+
if (this.attaches === 'none' || this.isDisabled || !data)
|
|
398
|
+
return;
|
|
399
|
+
const files = [...(data.files ?? [])];
|
|
400
|
+
if (!files.length || data.getData('text/plain'))
|
|
401
|
+
return;
|
|
402
|
+
event.preventDefault();
|
|
403
|
+
this.take(files);
|
|
404
|
+
};
|
|
405
|
+
/**
|
|
406
|
+
* CCM-5: a press on the capsule's own ground — its padding, the room beside a short text, the gaps of the strip — is
|
|
407
|
+
* passed on to the typing area, which takes focus with the caret at the nearest point of its text (ETI-12). A press
|
|
408
|
+
* on a Button, a File item or the counter is not. The press's default is prevented, so that focus is not taken away
|
|
409
|
+
* again; the capsule shows no pressed state.
|
|
410
|
+
*/
|
|
411
|
+
this.onGround = (event) => {
|
|
412
|
+
if (this.isDisabled || event.button !== 0)
|
|
413
|
+
return;
|
|
414
|
+
const target = event.composedPath()[0];
|
|
415
|
+
if (!(target instanceof Element) || target.getRootNode() !== this.renderRoot)
|
|
416
|
+
return;
|
|
417
|
+
// An element of its own tree that is a member, or the counter, is not ground.
|
|
418
|
+
if (target.localName.includes('-') || target.closest('.counter, .announce'))
|
|
419
|
+
return;
|
|
420
|
+
event.preventDefault();
|
|
421
|
+
this.input?.focusAt(event.clientX, event.clientY);
|
|
422
|
+
};
|
|
423
|
+
// ─── Files that arrive (CCM-21 to CCM-24) ─────────────────────────────────────────────────────────────────────
|
|
424
|
+
/** The file picker's `select` and `reject` are answered here and do not leave the element as they are. */
|
|
425
|
+
this.onPickerSelect = (event) => {
|
|
426
|
+
event.stopPropagation();
|
|
427
|
+
this.arriving.accepted = [...event.detail.files];
|
|
428
|
+
};
|
|
429
|
+
this.onPickerReject = (event) => {
|
|
430
|
+
event.stopPropagation();
|
|
431
|
+
this.arriving.refused = [...event.detail.files];
|
|
432
|
+
};
|
|
433
|
+
/** The browser's picker closed with a choice: one arrival, told once. CCM-25: with a file kept or handed over, focus goes to the typing area. */
|
|
434
|
+
this.onArrival = (event) => {
|
|
435
|
+
event.stopPropagation();
|
|
436
|
+
const { accepted, refused } = this.arriving;
|
|
437
|
+
this.arriving = { accepted: [], refused: [] };
|
|
438
|
+
if (this.isDisabled || (!accepted.length && !refused.length))
|
|
439
|
+
return;
|
|
440
|
+
if (this.arrive(accepted, refused, true))
|
|
441
|
+
this.input?.focus();
|
|
442
|
+
};
|
|
443
|
+
this.onDragEnter = (event) => {
|
|
444
|
+
if (!this.drops(event))
|
|
445
|
+
return;
|
|
446
|
+
event.preventDefault();
|
|
447
|
+
this.drags += 1;
|
|
448
|
+
this.receiving = true;
|
|
449
|
+
};
|
|
450
|
+
this.onDragOver = (event) => {
|
|
451
|
+
if (!this.drops(event))
|
|
452
|
+
return;
|
|
453
|
+
// Taken, so that the browser neither opens the file nor navigates to it.
|
|
454
|
+
event.preventDefault();
|
|
455
|
+
if (event.dataTransfer)
|
|
456
|
+
event.dataTransfer.dropEffect = 'copy';
|
|
457
|
+
this.receiving = true;
|
|
458
|
+
};
|
|
459
|
+
this.onDragLeave = (event) => {
|
|
460
|
+
if (!this.receiving)
|
|
461
|
+
return;
|
|
462
|
+
this.drags = Math.max(0, this.drags - 1);
|
|
463
|
+
// The last of them left — or the drag left the element altogether.
|
|
464
|
+
const to = event.relatedTarget;
|
|
465
|
+
if (this.drags === 0 || (to instanceof Node && !this.contains(to) && !this.renderRoot.contains(to)))
|
|
466
|
+
this.endDrag();
|
|
467
|
+
};
|
|
468
|
+
this.onDrop = (event) => {
|
|
469
|
+
if (!this.drops(event)) {
|
|
470
|
+
this.endDrag();
|
|
471
|
+
return;
|
|
472
|
+
}
|
|
473
|
+
event.preventDefault();
|
|
474
|
+
this.endDrag();
|
|
475
|
+
const files = [...(event.dataTransfer?.files ?? [])];
|
|
476
|
+
if (files.length)
|
|
477
|
+
this.take(files);
|
|
478
|
+
};
|
|
479
|
+
this.onItemUpdate = (event) => {
|
|
480
|
+
if (event.target === this)
|
|
481
|
+
return;
|
|
482
|
+
event.stopPropagation();
|
|
483
|
+
if (this.attaches !== 'given')
|
|
484
|
+
return;
|
|
485
|
+
this.readItems();
|
|
486
|
+
};
|
|
487
|
+
this.onFocusIn = (event) => {
|
|
488
|
+
this.held = this.itemOf(event.target);
|
|
489
|
+
};
|
|
490
|
+
this.onFocusOut = (event) => {
|
|
491
|
+
const item = this.itemOf(event.target);
|
|
492
|
+
if (!item)
|
|
493
|
+
return;
|
|
494
|
+
queueMicrotask(() => {
|
|
495
|
+
if (this.held === item && item.parentNode === this && !holdsFocus(item))
|
|
496
|
+
this.held = null;
|
|
497
|
+
});
|
|
498
|
+
};
|
|
499
|
+
this.addEventListener(FILE_ITEM_UPDATE, this.onItemUpdate);
|
|
500
|
+
this.addEventListener('focusin', this.onFocusIn);
|
|
501
|
+
this.addEventListener('focusout', this.onFocusOut);
|
|
502
|
+
this.addEventListener('dragenter', this.onDragEnter);
|
|
503
|
+
this.addEventListener('dragover', this.onDragOver);
|
|
504
|
+
this.addEventListener('dragleave', this.onDragLeave);
|
|
505
|
+
this.addEventListener('drop', this.onDrop);
|
|
506
|
+
}
|
|
507
|
+
// ─── What it reads ────────────────────────────────────────────────────────────────────────────────────────────
|
|
508
|
+
/** CCM-5: its one embedded text input, once rendered. */
|
|
509
|
+
get input() {
|
|
510
|
+
return this.renderRoot?.querySelector('tanrei-embedded-text-input') ?? null;
|
|
511
|
+
}
|
|
512
|
+
/** CCM-7: its one file picker, while `attachments` is not none. */
|
|
513
|
+
get picker() {
|
|
514
|
+
return this.renderRoot?.querySelector('tanrei-file-picker') ?? null;
|
|
515
|
+
}
|
|
516
|
+
get capsule() {
|
|
517
|
+
return this.renderRoot?.querySelector('.capsule') ?? null;
|
|
518
|
+
}
|
|
519
|
+
/** W7: focus is the typing area's (CCM-5). */
|
|
520
|
+
get control() {
|
|
521
|
+
return this.input;
|
|
522
|
+
}
|
|
523
|
+
/** Disabled by its own `disabled`, by a field around it, or by its form (CCM-26, CCM-28, CCM-36). */
|
|
524
|
+
get isDisabled() {
|
|
525
|
+
// The platform's word arrives a turn after the element's own `disabled` was unset (src/primitives/form-disabled.ts):
|
|
526
|
+
// until then it is the platform's present answer that is read, so that nothing is said twice (CCM-9).
|
|
527
|
+
return this.disabled || this.field.disabled || (this.formDisabled && this.matches(':disabled'));
|
|
528
|
+
}
|
|
529
|
+
/** CCM-18, CCM-27, CCM-28: the capsule is in its error condition, and the typing area is invalid — by `error`, by a field's, or over the limit. */
|
|
530
|
+
get isError() {
|
|
531
|
+
return this.error || this.field.invalid || this.over;
|
|
532
|
+
}
|
|
533
|
+
/** CCM-38: who holds the files; a value it does not know is none. */
|
|
534
|
+
get attaches() {
|
|
535
|
+
return this.attachments === 'own' || this.attachments === 'given' ? this.attachments : 'none';
|
|
536
|
+
}
|
|
537
|
+
/** CCM-29: the group's name, and the typing area's — its own label, else the field's. */
|
|
538
|
+
get groupName() {
|
|
539
|
+
return this.field.name(this.label).trim();
|
|
540
|
+
}
|
|
541
|
+
/** CCM-18: the limit, where one is set. */
|
|
542
|
+
get lengthLimit() {
|
|
543
|
+
return typeof this.maxLength === 'number' && Number.isFinite(this.maxLength) && this.maxLength > 0 ? this.maxLength : 0;
|
|
544
|
+
}
|
|
545
|
+
/** CCM-18: the count is over the limit. */
|
|
546
|
+
get over() {
|
|
547
|
+
const most = this.lengthLimit;
|
|
548
|
+
return most > 0 && graphemes(this.value) > most;
|
|
549
|
+
}
|
|
550
|
+
/** CCM-19: the counter is drawn. */
|
|
551
|
+
get counts() {
|
|
552
|
+
return this.counter && !this.isDisabled;
|
|
553
|
+
}
|
|
554
|
+
/** CCM-19: what the counter shows — the count, then a slash and the limit where one is set. */
|
|
555
|
+
get counterText() {
|
|
556
|
+
const most = this.lengthLimit;
|
|
557
|
+
return `${graphemes(this.value)}${most ? `/${most}` : ''}`;
|
|
558
|
+
}
|
|
559
|
+
/** The elements the product placed in a named slot. */
|
|
560
|
+
slotted(name) {
|
|
561
|
+
return [...this.children].filter((child) => child.slot === name);
|
|
562
|
+
}
|
|
563
|
+
/** CCM-21, CCM-43: the File items the product gave, in the order it gave them — and none unless `attachments` is `given`. */
|
|
564
|
+
get givenItems() {
|
|
565
|
+
return this.attaches === 'given' ? this.itemChildren : [];
|
|
566
|
+
}
|
|
567
|
+
/** The `tanrei-file-item` children the product wrote, whatever `attachments` says. */
|
|
568
|
+
get itemChildren() {
|
|
569
|
+
return [...this.children].filter((child) => child.localName === ITEM && !child.slot);
|
|
570
|
+
}
|
|
571
|
+
/** The File items it drew itself, in the order they are drawn. */
|
|
572
|
+
get ownItems() {
|
|
573
|
+
return [...(this.renderRoot?.querySelectorAll(`.strip > ${ITEM}`) ?? [])];
|
|
574
|
+
}
|
|
575
|
+
/** CCM-7: the attach button is drawn. */
|
|
576
|
+
get attachShown() {
|
|
577
|
+
return this.attaches !== 'none';
|
|
578
|
+
}
|
|
579
|
+
/** CCM-3: the row beneath would hold something — the attach button, a Button in either slot, or the counter. */
|
|
580
|
+
get rowHolds() {
|
|
581
|
+
return this.attachShown || this.slotted('leading').length > 0 || this.slotted('trailing').length > 0 || this.counts;
|
|
582
|
+
}
|
|
583
|
+
/** CCM-3, CCM-4: it is laid out stacked — by `layout`, or because the capsule is too narrow for inline — and has something for the row beneath. */
|
|
584
|
+
get stacked() {
|
|
585
|
+
return (this.layout === 'stacked' || this.narrow) && this.rowHolds;
|
|
586
|
+
}
|
|
587
|
+
/** CCM-12: what the embedded text input's Enter does; a value of `sendKey` it does not know is enter. */
|
|
588
|
+
get enterKey() {
|
|
589
|
+
return this.sendKey === 'modifier' ? 'line-break' : 'action';
|
|
590
|
+
}
|
|
591
|
+
/** CCM-5: the most lines of the typing area — 0, or a number of at least its fewest. */
|
|
592
|
+
get mostRows() {
|
|
593
|
+
const least = typeof this.minRows === 'number' && Number.isFinite(this.minRows) && this.minRows >= 1 ? this.minRows : 1;
|
|
594
|
+
if (this.maxRows === 0)
|
|
595
|
+
return 0;
|
|
596
|
+
return typeof this.maxRows === 'number' && Number.isFinite(this.maxRows) && this.maxRows >= least ? this.maxRows : least;
|
|
597
|
+
}
|
|
598
|
+
/** CCM-19, CCM-28: the typing area's description — what the counter shows first, and the field's shown text last. */
|
|
599
|
+
get description() {
|
|
600
|
+
return [this.counts ? this.counterText : '', this.field.description()].filter(Boolean).join(' ');
|
|
601
|
+
}
|
|
602
|
+
/** CCM-22: the room `maxFiles` leaves, which is what the file picker is given while the chat composer keeps the files. */
|
|
603
|
+
get room() {
|
|
604
|
+
if (this.attaches !== 'own' || !this.multiple)
|
|
605
|
+
return this.maxFiles;
|
|
606
|
+
const most = limit(this.maxFiles);
|
|
607
|
+
return most === null ? this.maxFiles : Math.max(0, Math.floor(most) - this.kept.length);
|
|
608
|
+
}
|
|
609
|
+
// ─── Whether it can be sent (CCM-9) ───────────────────────────────────────────────────────────────────────────
|
|
610
|
+
/** CCM-9: each reason what it holds cannot be sent, by name; none while it can. */
|
|
611
|
+
reasons() {
|
|
612
|
+
const reasons = [];
|
|
613
|
+
if (this.isDisabled)
|
|
614
|
+
reasons.push('disabled');
|
|
615
|
+
if (this.sending)
|
|
616
|
+
reasons.push('sending');
|
|
617
|
+
if (this.blocked)
|
|
618
|
+
reasons.push('blocked');
|
|
619
|
+
const items = this.givenItems;
|
|
620
|
+
const carried = this.attaches === 'own' ? this.kept.length : items.filter((item) => itemStatus(item) !== 'error').length;
|
|
621
|
+
if (!/\S/.test(this.value) && carried === 0)
|
|
622
|
+
reasons.push('empty');
|
|
623
|
+
if (this.over)
|
|
624
|
+
reasons.push('length');
|
|
625
|
+
if (items.some((item) => itemStatus(item) === 'uploading'))
|
|
626
|
+
reasons.push('uploading');
|
|
627
|
+
if (items.some((item) => itemStatus(item) === 'error' && itemRetryable(item)))
|
|
628
|
+
reasons.push('failed');
|
|
629
|
+
return reasons;
|
|
630
|
+
}
|
|
631
|
+
/** Whether what it holds can be sent now, read-only: what the last `sendablechange` said. */
|
|
632
|
+
get sendable() {
|
|
633
|
+
return this.reasons().length === 0;
|
|
634
|
+
}
|
|
635
|
+
/** CCM-9: the answer or the reasons changed — said once, and never when it is first drawn. */
|
|
636
|
+
tellSendable() {
|
|
637
|
+
const reasons = this.reasons();
|
|
638
|
+
const key = reasons.join(',');
|
|
639
|
+
const first = this.said === undefined;
|
|
640
|
+
if (key === this.said)
|
|
641
|
+
return;
|
|
642
|
+
this.said = key;
|
|
643
|
+
if (first)
|
|
644
|
+
return;
|
|
645
|
+
this.dispatchEvent(new CustomEvent('sendablechange', { bubbles: true, composed: true, detail: { sendable: reasons.length === 0, reasons } }));
|
|
646
|
+
}
|
|
647
|
+
// ─── Sending (CCM-11 to CCM-17) ───────────────────────────────────────────────────────────────────────────────
|
|
648
|
+
/**
|
|
649
|
+
* CCM-11: a request to send — by the send button (`key` false) or by the keyboard. While it can be sent: `send`,
|
|
650
|
+
* once, with the text exactly as it stands and the attachments in the order of the strip; then, in a form, the
|
|
651
|
+
* form's submission (CCM-36), and outside one the emptying (CCM-15); then focus in the typing area (CCM-16). While
|
|
652
|
+
* it cannot: nothing — but `sendblocked` for a request by the keyboard that a reason other than empty holds back (CCM-14).
|
|
653
|
+
*/
|
|
654
|
+
requestSend(key) {
|
|
655
|
+
const reasons = this.reasons();
|
|
656
|
+
if (reasons.length) {
|
|
657
|
+
if (key && !reasons.includes('disabled') && reasons.some((reason) => reason !== 'empty')) {
|
|
658
|
+
this.dispatchEvent(new CustomEvent('sendblocked', { bubbles: true, composed: true, detail: { sendable: false, reasons } }));
|
|
659
|
+
}
|
|
660
|
+
return;
|
|
661
|
+
}
|
|
662
|
+
const attachments = this.attaches === 'own' ? this.files : this.givenItems.filter((item) => itemStatus(item) !== 'error').map((item) => itemText(item, 'value', 'value'));
|
|
663
|
+
const proceed = this.dispatchEvent(new CustomEvent('send', { bubbles: true, composed: true, cancelable: true, detail: { value: this.value, attachments } }));
|
|
664
|
+
const form = this.internals.form;
|
|
665
|
+
if (proceed && form) {
|
|
666
|
+
// CCM-36: as a submit button of the platform's own does — the form's validation, then its submit event. In a
|
|
667
|
+
// form it does not empty itself, whatever keepAfterSend says.
|
|
668
|
+
this.syncForm();
|
|
669
|
+
form.requestSubmit();
|
|
670
|
+
}
|
|
671
|
+
else if (proceed && !this.keepAfterSend)
|
|
672
|
+
this.empty();
|
|
673
|
+
// CCM-16: the next message can be written at once.
|
|
674
|
+
if (!this.isDisabled)
|
|
675
|
+
this.input?.focus();
|
|
676
|
+
}
|
|
677
|
+
/** CCM-15: empties itself — the text, every file it keeps and every File item it drew. Emits nothing. */
|
|
678
|
+
empty() {
|
|
679
|
+
this.value = '';
|
|
680
|
+
if (this.kept.length || this.refused.length) {
|
|
681
|
+
this.kept = [];
|
|
682
|
+
this.refused = [];
|
|
683
|
+
}
|
|
684
|
+
this.arrived = [];
|
|
685
|
+
this.requestUpdate();
|
|
686
|
+
}
|
|
687
|
+
/**
|
|
688
|
+
* CCM-15: empties the chat composer as it empties itself after `send` — the text, every file it keeps and every File
|
|
689
|
+
* item it drew — for a product that set `keep-after-send` and now knows the message arrived. Emits nothing and
|
|
690
|
+
* announces nothing. The product's own File items (`attachments="given"`) are the product's to remove.
|
|
691
|
+
*/
|
|
692
|
+
clear() {
|
|
693
|
+
this.empty();
|
|
694
|
+
}
|
|
695
|
+
/** CCM-23, CCM-24: files that came another way — dropped, pasted — are judged by the file picker as a choice is (FPK-31). */
|
|
696
|
+
take(files) {
|
|
697
|
+
const picker = this.judge();
|
|
698
|
+
const { accepted, refused } = picker.judge(files);
|
|
699
|
+
this.arrive(accepted, refused, true);
|
|
700
|
+
}
|
|
701
|
+
/** The file picker that judges by what the chat composer says now — its own, or, before it was first drawn, one that is nowhere and judges by the same props. */
|
|
702
|
+
judge() {
|
|
703
|
+
const picker = this.picker ?? document.createElement('tanrei-file-picker');
|
|
704
|
+
picker.multiple = this.multiple;
|
|
705
|
+
picker.accept = this.accept;
|
|
706
|
+
picker.maxSize = this.maxSize;
|
|
707
|
+
picker.maxFiles = this.room;
|
|
708
|
+
return picker;
|
|
709
|
+
}
|
|
710
|
+
/**
|
|
711
|
+
* One arrival, judged. CCM-21: while `attachments` is `given` nothing is kept — `select`, then `reject`, and the
|
|
712
|
+
* product gives back a File item for each file it keeps. CCM-22: while it is `own` the File items of what an earlier
|
|
713
|
+
* arrival refused leave; a file that passed and that it already keeps is passed over; with `multiple` the rest is
|
|
714
|
+
* kept after the others, each one beyond the room `maxFiles` leaves refused for the count, and without it a file
|
|
715
|
+
* that passed takes the place of the one kept. Then, for what a person did (`person`): `select`, `reject`,
|
|
716
|
+
* `attachmentschange`, each once and only where it applies. Answers whether a file was kept or handed over.
|
|
717
|
+
*/
|
|
718
|
+
arrive(accepted, refusedByPicker, person) {
|
|
719
|
+
if (this.attaches === 'given') {
|
|
720
|
+
if (accepted.length)
|
|
721
|
+
this.dispatchEvent(new CustomEvent('select', { bubbles: true, composed: true, detail: { files: [...accepted] } }));
|
|
722
|
+
if (refusedByPicker.length)
|
|
723
|
+
this.dispatchEvent(new CustomEvent('reject', { bubbles: true, composed: true, detail: { files: [...refusedByPicker] } }));
|
|
724
|
+
return accepted.length > 0;
|
|
725
|
+
}
|
|
726
|
+
if (this.attaches !== 'own')
|
|
727
|
+
return false;
|
|
728
|
+
const before = this.kept;
|
|
729
|
+
const fresh = [];
|
|
730
|
+
for (const file of accepted) {
|
|
731
|
+
if (before.some((own) => sameFile(own.file, file)) || fresh.some((other) => sameFile(other, file)))
|
|
732
|
+
continue;
|
|
733
|
+
fresh.push(file);
|
|
734
|
+
}
|
|
735
|
+
const most = this.multiple ? limit(this.maxFiles) : null;
|
|
736
|
+
const left = most === null ? fresh.length : Math.max(0, Math.floor(most) - before.length);
|
|
737
|
+
const passed = fresh.slice(0, left);
|
|
738
|
+
const refused = [...refusedByPicker, ...fresh.slice(left).map((file) => ({ file, reason: 'count' }))];
|
|
739
|
+
const added = passed.map((file) => ({ file, reason: null }));
|
|
740
|
+
const kept = !added.length ? before : this.multiple ? [...before, ...added] : added;
|
|
741
|
+
this.redraw(() => {
|
|
742
|
+
this.kept = kept;
|
|
743
|
+
this.refused = refused.map(({ file, reason }) => ({ file, reason }));
|
|
744
|
+
});
|
|
745
|
+
// CCM-30: one message for the arrival — the names are the files' own and the sentences the product's.
|
|
746
|
+
this.arrived.push(...passed.map((file) => file.name), ...refused.map(({ file, reason }) => [file.name, this.sentence(reason)].map((text) => text.trim()).filter(Boolean).join(', ')));
|
|
747
|
+
if (this.arrived.length)
|
|
748
|
+
this.changed();
|
|
749
|
+
if (person && !this.isDisabled) {
|
|
750
|
+
if (passed.length)
|
|
751
|
+
this.dispatchEvent(new CustomEvent('select', { bubbles: true, composed: true, detail: { files: passed } }));
|
|
752
|
+
if (refused.length)
|
|
753
|
+
this.dispatchEvent(new CustomEvent('reject', { bubbles: true, composed: true, detail: { files: refused } }));
|
|
754
|
+
if (kept !== before)
|
|
755
|
+
this.emitAttachments();
|
|
756
|
+
}
|
|
757
|
+
return passed.length > 0;
|
|
758
|
+
}
|
|
759
|
+
/** CCM-22: the files it keeps changed by what a person did. */
|
|
760
|
+
emitAttachments() {
|
|
761
|
+
if (this.isDisabled)
|
|
762
|
+
return;
|
|
763
|
+
this.dispatchEvent(new CustomEvent('attachmentschange', { bubbles: true, composed: true, detail: { files: this.files } }));
|
|
764
|
+
}
|
|
765
|
+
/** CCM-22, CCM-31: the product's sentence for a reason — the instance's prop, else the product's words, else nothing. */
|
|
766
|
+
sentence(reason) {
|
|
767
|
+
return reason === 'type' ? this.words.get('fileTypeErrorText', this.typeErrorText) : reason === 'size' ? this.words.get('fileSizeErrorText', this.sizeErrorText) : this.words.get('fileCountErrorText', this.countErrorText);
|
|
768
|
+
}
|
|
769
|
+
/**
|
|
770
|
+
* CCM-22: the files it keeps while `attachments` is `own`, in order, as the browser's own `File` handles: a new array
|
|
771
|
+
* on each read. Never a refused file. Empty while `attachments` is `given` or `none`.
|
|
772
|
+
*/
|
|
773
|
+
get files() {
|
|
774
|
+
return this.attaches === 'own' ? this.kept.map((own) => own.file) : [];
|
|
775
|
+
}
|
|
776
|
+
/**
|
|
777
|
+
* CCM-22: hands files over, as a product does whose own action in a slot makes a file — a photograph, a recording.
|
|
778
|
+
* They are judged by its file picker (FPK-31) and are then an arrival: kept or refused, drawn and announced as a
|
|
779
|
+
* choice is, with no event. Answers with the refused files and their reasons. While `attachments` is not `own` it
|
|
780
|
+
* does nothing and is reported.
|
|
781
|
+
*/
|
|
782
|
+
addFiles(files) {
|
|
783
|
+
if (this.attaches !== 'own') {
|
|
784
|
+
report(this, 'CCM-22', `addFiles() was called while attachments is "${String(this.attachments)}": the chat composer keeps files only while it is "own", and nothing was added`);
|
|
785
|
+
return [];
|
|
786
|
+
}
|
|
787
|
+
const given = typeof File === 'undefined' ? [] : [...(files ?? [])].filter((file) => file instanceof File);
|
|
788
|
+
if (!given.length)
|
|
789
|
+
return [];
|
|
790
|
+
const { accepted, refused } = this.judge().judge(given);
|
|
791
|
+
this.arrive(accepted, refused, false);
|
|
792
|
+
return this.refused.map(({ file, reason }) => ({ file, reason: reason }));
|
|
793
|
+
}
|
|
794
|
+
// ─── A drag over the capsule (CCM-23) ─────────────────────────────────────────────────────────────────────────
|
|
795
|
+
/** A drag that holds a file, while files can be attached. */
|
|
796
|
+
drops(event) {
|
|
797
|
+
return this.attaches !== 'none' && !this.isDisabled && [...(event.dataTransfer?.types ?? [])].includes('Files');
|
|
798
|
+
}
|
|
799
|
+
endDrag() {
|
|
800
|
+
this.drags = 0;
|
|
801
|
+
this.receiving = false;
|
|
802
|
+
}
|
|
803
|
+
// ─── The File items (CCM-20, CCM-25, CCM-30, CCM-43) ──────────────────────────────────────────────────────────
|
|
804
|
+
/** CCM-20, CCM-26, CCM-29: what every File item it holds is given, through the internal channel: the names of its two actions, whether it is disabled, and that it is an item of the strip's list. */
|
|
805
|
+
gift(made) {
|
|
806
|
+
return {
|
|
807
|
+
...(this.removeLabel ? { removeLabel: this.removeLabel } : {}),
|
|
808
|
+
...(this.retryLabel ? { retryLabel: this.retryLabel } : {}),
|
|
809
|
+
disabled: this.isDisabled,
|
|
810
|
+
listItem: true,
|
|
811
|
+
...(made ? { made: true } : {}),
|
|
812
|
+
};
|
|
813
|
+
}
|
|
814
|
+
tellItems() {
|
|
815
|
+
const own = this.attaches === 'own';
|
|
816
|
+
for (const item of this.ownItems)
|
|
817
|
+
giveFileItem(item, this.gift(true));
|
|
818
|
+
// A child it does not draw is given nothing.
|
|
819
|
+
for (const item of this.itemChildren)
|
|
820
|
+
giveFileItem(item, own || this.attaches === 'none' ? null : this.gift(false));
|
|
821
|
+
}
|
|
822
|
+
/**
|
|
823
|
+
* Changes the files it keeps and draws their File items at once, so that what is emitted afterwards is emitted with
|
|
824
|
+
* the strip as it will be. CCM-25: where an item that leaves held focus, focus goes to the remove action of the item
|
|
825
|
+
* that followed it, or of the one before where none follows, or to the typing area where none is left.
|
|
826
|
+
*/
|
|
827
|
+
redraw(change) {
|
|
828
|
+
const order = [...this.kept, ...this.refused];
|
|
829
|
+
const active = this.shadowRoot?.activeElement ?? null;
|
|
830
|
+
const at = active ? this.ownItems.indexOf(active) : -1;
|
|
831
|
+
const held = at >= 0 ? order[at] : undefined;
|
|
832
|
+
change();
|
|
833
|
+
this.requestUpdate();
|
|
834
|
+
if (!this.hasUpdated || !this.isConnected)
|
|
835
|
+
return;
|
|
836
|
+
this.performUpdate();
|
|
837
|
+
const now = [...this.kept, ...this.refused];
|
|
838
|
+
if (!held || now.includes(held))
|
|
839
|
+
return;
|
|
840
|
+
const next = [...order.slice(at + 1), ...order.slice(0, at).reverse()].find((own) => now.includes(own));
|
|
841
|
+
const target = next ? this.ownItems[now.indexOf(next)] : undefined;
|
|
842
|
+
if (!target || !takeFocus(target))
|
|
843
|
+
this.input?.focus();
|
|
844
|
+
}
|
|
845
|
+
/** CCM-22: the remove action of a File item it drew removes the item, at once; a kept file is let go and `attachmentschange` is emitted. The item's own `remove` does not leave the element: it is an event of the product's items. */
|
|
846
|
+
removeOwn(event, own) {
|
|
847
|
+
event.stopPropagation();
|
|
848
|
+
if (this.isDisabled)
|
|
849
|
+
return;
|
|
850
|
+
const kept = this.kept.includes(own);
|
|
851
|
+
this.redraw(() => {
|
|
852
|
+
this.kept = this.kept.filter((each) => each !== own);
|
|
853
|
+
this.refused = this.refused.filter((each) => each !== own);
|
|
854
|
+
});
|
|
855
|
+
if (kept)
|
|
856
|
+
this.emitAttachments();
|
|
857
|
+
}
|
|
858
|
+
/** The product's File items were added to, removed from, or changed: drawn at once, said once. */
|
|
859
|
+
readItems() {
|
|
860
|
+
const items = this.givenItems;
|
|
861
|
+
this.count = items.length;
|
|
862
|
+
this.tellItems();
|
|
863
|
+
this.requestUpdate();
|
|
864
|
+
this.changed();
|
|
865
|
+
}
|
|
866
|
+
childrenChanged(records) {
|
|
867
|
+
this.adopt();
|
|
868
|
+
for (const record of records)
|
|
869
|
+
for (const node of record.removedNodes)
|
|
870
|
+
if (node instanceof Element && node.localName === ITEM)
|
|
871
|
+
giveFileItem(node, null);
|
|
872
|
+
const before = this.stood;
|
|
873
|
+
this.readItems();
|
|
874
|
+
this.stood = this.givenItems;
|
|
875
|
+
this.afterLeave(before, records);
|
|
876
|
+
}
|
|
877
|
+
itemOf(target) {
|
|
878
|
+
return target instanceof Element && target.parentNode === this && target.localName === ITEM ? target : null;
|
|
879
|
+
}
|
|
880
|
+
/**
|
|
881
|
+
* CCM-25: a File item the product gave left while focus was on one of its actions, and focus is now nowhere: it goes
|
|
882
|
+
* to the remove action of the item that followed, or of the one before where none follows, or to the typing area
|
|
883
|
+
* where no item is left. Where the product has already put focus somewhere, nothing is done.
|
|
884
|
+
*/
|
|
885
|
+
afterLeave(before, records) {
|
|
886
|
+
const held = this.held;
|
|
887
|
+
if (!held || !records.some((record) => [...record.removedNodes].includes(held)))
|
|
888
|
+
return;
|
|
889
|
+
const active = this.ownerDocument.activeElement;
|
|
890
|
+
const nowhere = !active || active === this.ownerDocument.body || active === this.ownerDocument.documentElement;
|
|
891
|
+
if (!nowhere || held.parentNode === this) {
|
|
892
|
+
if (!holdsFocus(held))
|
|
893
|
+
this.held = null;
|
|
894
|
+
return;
|
|
895
|
+
}
|
|
896
|
+
this.held = null;
|
|
897
|
+
const here = (node) => node.parentNode === this;
|
|
898
|
+
const at = before.indexOf(held);
|
|
899
|
+
const now = this.givenItems;
|
|
900
|
+
const order = before.some(here) ? [...before.slice(at + 1), ...before.slice(0, Math.max(0, at)).reverse()] : [...now.slice(Math.max(0, at)), ...now.slice(0, Math.max(0, at)).reverse()];
|
|
901
|
+
const candidates = order.filter(here);
|
|
902
|
+
const take = () => {
|
|
903
|
+
for (const candidate of candidates.filter(here)) {
|
|
904
|
+
if (takeFocus(candidate)) {
|
|
905
|
+
this.held = candidate;
|
|
906
|
+
return true;
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
return false;
|
|
910
|
+
};
|
|
911
|
+
if (take())
|
|
912
|
+
return;
|
|
913
|
+
// An item that was written a moment ago has no action to focus until it has rendered.
|
|
914
|
+
const pending = candidates.map((candidate) => candidate.updateComplete).filter((promise) => !!promise);
|
|
915
|
+
void Promise.all(pending).then(() => {
|
|
916
|
+
const current = this.ownerDocument.activeElement;
|
|
917
|
+
if (!this.isConnected || (current && current !== this.ownerDocument.body && current !== this.ownerDocument.documentElement))
|
|
918
|
+
return;
|
|
919
|
+
if (!take())
|
|
920
|
+
this.input?.focus();
|
|
921
|
+
});
|
|
922
|
+
}
|
|
923
|
+
/** CCM-30: something that may be said changed in this turn; everything of one turn is one message. */
|
|
924
|
+
changed() {
|
|
925
|
+
if (this.turn !== undefined)
|
|
926
|
+
return;
|
|
927
|
+
this.turn = setTimeout(() => {
|
|
928
|
+
this.turn = undefined;
|
|
929
|
+
this.say();
|
|
930
|
+
}, 0);
|
|
931
|
+
}
|
|
932
|
+
/**
|
|
933
|
+
* CCM-30: the one message of a turn, in the product's words alone — its own sentence where it set one; while
|
|
934
|
+
* `attachments` is `own`, what arrived; while it is `given`, each File item that was added after the chat composer
|
|
935
|
+
* was first presented, finished or failed: its name, then its status text or its error text. Nothing of progress, and
|
|
936
|
+
* nothing of the chat composer's own making.
|
|
937
|
+
*/
|
|
938
|
+
say() {
|
|
939
|
+
const hush = this.hush;
|
|
940
|
+
this.hush = false;
|
|
941
|
+
const messages = this.attaches === 'own' && this.presented ? this.arrived : [];
|
|
942
|
+
this.arrived = [];
|
|
943
|
+
const items = this.givenItems;
|
|
944
|
+
for (const item of items) {
|
|
945
|
+
const now = { status: itemStatus(item), errorText: itemText(item, 'errorText', 'error-text') };
|
|
946
|
+
const was = this.known.get(item);
|
|
947
|
+
const failed = now.status === 'error';
|
|
948
|
+
const said = !was ? this.presented && !hush : (now.status === 'done' && was.status !== 'done') || (failed && (was.status !== 'error' || was.errorText !== now.errorText));
|
|
949
|
+
if (said)
|
|
950
|
+
messages.push([itemText(item, 'name', 'name'), failed ? now.errorText : itemText(item, 'statusText', 'status-text')].map((text) => text.trim()).filter(Boolean).join(', '));
|
|
951
|
+
this.known.set(item, now);
|
|
952
|
+
}
|
|
953
|
+
for (const item of [...this.known.keys()])
|
|
954
|
+
if (!items.includes(item))
|
|
955
|
+
this.known.delete(item);
|
|
956
|
+
const first = !this.presented;
|
|
957
|
+
this.presented = true;
|
|
958
|
+
const own = this.own;
|
|
959
|
+
this.own = null;
|
|
960
|
+
if (first)
|
|
961
|
+
this.check();
|
|
962
|
+
const region = this.renderRoot?.querySelector('.announce');
|
|
963
|
+
const lines = [...(own ? [own] : []), ...messages.filter(Boolean)];
|
|
964
|
+
if (!region || !this.isConnected || lines.length === 0)
|
|
965
|
+
return;
|
|
966
|
+
// Written as new lines in place of the last ones, so that a text equal to the last one is said again.
|
|
967
|
+
region.replaceChildren(...lines.map((text) => {
|
|
968
|
+
const line = document.createElement('div');
|
|
969
|
+
line.textContent = text;
|
|
970
|
+
return line;
|
|
971
|
+
}));
|
|
972
|
+
}
|
|
973
|
+
/** @internal FPK-22: where a child is placed, for the Button that asks its parent when it connects: the file picker says it of its trigger. */
|
|
974
|
+
[GROUP_PLACE](child) {
|
|
975
|
+
return this.picker?.[GROUP_PLACE]?.(child) ?? null;
|
|
976
|
+
}
|
|
977
|
+
// ─── Form (CCM-36, CCM-40) ────────────────────────────────────────────────────────────────────────────────────
|
|
978
|
+
/** The form it belongs to, if any. */
|
|
979
|
+
get form() {
|
|
980
|
+
return this.internals.form;
|
|
981
|
+
}
|
|
982
|
+
/** CCM-36: a reset empties it, and emits nothing. */
|
|
983
|
+
formResetCallback() {
|
|
984
|
+
this.empty();
|
|
985
|
+
}
|
|
986
|
+
/** CCM-40: the text is restored with the page; it begins with no file. */
|
|
987
|
+
formStateRestoreCallback(state) {
|
|
988
|
+
this.value = typeof state === 'string' ? state : '';
|
|
989
|
+
}
|
|
990
|
+
formDisabledCallback(disabled) {
|
|
991
|
+
takeFormDisabled(this, disabled, (value) => (this.formDisabled = value));
|
|
992
|
+
}
|
|
993
|
+
attributeChangedCallback(name, old, value) {
|
|
994
|
+
super.attributeChangedCallback(name, old, value);
|
|
995
|
+
if (name === 'files-name' && old !== value)
|
|
996
|
+
this.requestUpdate();
|
|
997
|
+
}
|
|
998
|
+
/** CCM-36: the text under its name and, while it keeps its own files, each of them under the name given for its files — nothing while disabled. The text is what a restored page gives back. */
|
|
999
|
+
syncForm() {
|
|
1000
|
+
const value = this.value;
|
|
1001
|
+
if (this.isDisabled) {
|
|
1002
|
+
this.internals.setFormValue(null, value);
|
|
1003
|
+
return;
|
|
1004
|
+
}
|
|
1005
|
+
const data = new FormData();
|
|
1006
|
+
if (this.name)
|
|
1007
|
+
data.append(this.name, value);
|
|
1008
|
+
const filesName = this.getAttribute('files-name');
|
|
1009
|
+
if (filesName && this.attaches === 'own')
|
|
1010
|
+
for (const { file } of this.kept)
|
|
1011
|
+
data.append(filesName, file, file.name);
|
|
1012
|
+
this.internals.setFormValue(data, value);
|
|
1013
|
+
}
|
|
1014
|
+
// ─── Without script (CCM-37) ──────────────────────────────────────────────────────────────────────────────────
|
|
1015
|
+
/**
|
|
1016
|
+
* CCM-37: the platform's own text area and submit button that the product wrote as children are the form until the
|
|
1017
|
+
* element is defined. Now the text area's text is the value while its own is empty, and each is taken out of what
|
|
1018
|
+
* is drawn, focused, read and submitted.
|
|
1019
|
+
*/
|
|
1020
|
+
adopt() {
|
|
1021
|
+
for (const child of this.children) {
|
|
1022
|
+
if (child.slot || child.hasAttribute('data-tanrei-adopted'))
|
|
1023
|
+
continue;
|
|
1024
|
+
if (!(child instanceof HTMLTextAreaElement || child instanceof HTMLButtonElement || child instanceof HTMLInputElement))
|
|
1025
|
+
continue;
|
|
1026
|
+
child.setAttribute('data-tanrei-adopted', '');
|
|
1027
|
+
if (child instanceof HTMLTextAreaElement && !this.value && child.value)
|
|
1028
|
+
this.value = child.value;
|
|
1029
|
+
child.hidden = true;
|
|
1030
|
+
child.disabled = true;
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
// ─── What it measures (CCM-4, CCM-41) ─────────────────────────────────────────────────────────────────────────
|
|
1034
|
+
/**
|
|
1035
|
+
* CCM-41: one line of the typing area's text — the member's computed line height, never its token — from which the
|
|
1036
|
+
* capsule's corners and the least height of its groups are written, as a rule of the element's own. CCM-4: whether
|
|
1037
|
+
* the capsule is narrower than `layout.inline-min-width`, by its own width.
|
|
1038
|
+
*/
|
|
1039
|
+
measure() {
|
|
1040
|
+
const capsule = this.capsule;
|
|
1041
|
+
if (!capsule || !this.isConnected)
|
|
1042
|
+
return;
|
|
1043
|
+
const typed = this.input?.shadowRoot?.querySelector('[part~="input"]');
|
|
1044
|
+
const line = typed ? getComputedStyle(typed).lineHeight : '';
|
|
1045
|
+
if (/^[\d.]+px$/.test(line) && line !== this.line) {
|
|
1046
|
+
this.line = line;
|
|
1047
|
+
this.sheet?.replaceSync(measured(line));
|
|
1048
|
+
}
|
|
1049
|
+
const probe = capsule.querySelector('.probe');
|
|
1050
|
+
const [width, least] = [capsule.getBoundingClientRect().width, probe?.getBoundingClientRect().width ?? 0];
|
|
1051
|
+
const narrow = width > 0 && least > 0 && width < least - 0.01;
|
|
1052
|
+
if (narrow !== this.narrow)
|
|
1053
|
+
this.narrow = narrow;
|
|
1054
|
+
}
|
|
1055
|
+
watch() {
|
|
1056
|
+
const next = [this.capsule, this.input].filter((element) => !!element);
|
|
1057
|
+
if (next.length === this.watched.length && next.every((element, index) => element === this.watched[index]))
|
|
1058
|
+
return;
|
|
1059
|
+
this.sizes?.disconnect();
|
|
1060
|
+
this.watched = next;
|
|
1061
|
+
if (typeof ResizeObserver === 'undefined')
|
|
1062
|
+
return;
|
|
1063
|
+
this.sizes ??= new ResizeObserver(() => this.measure());
|
|
1064
|
+
for (const element of next)
|
|
1065
|
+
this.sizes.observe(element);
|
|
1066
|
+
}
|
|
1067
|
+
// ─── Lifecycle ────────────────────────────────────────────────────────────────────────────────────────────────
|
|
1068
|
+
createRenderRoot() {
|
|
1069
|
+
const root = super.createRenderRoot();
|
|
1070
|
+
// The rule it writes from what it measures stands after its stylesheet, and in no cascade layer.
|
|
1071
|
+
if (this.sheet && root instanceof ShadowRoot && 'adoptedStyleSheets' in root)
|
|
1072
|
+
root.adoptedStyleSheets = [...root.adoptedStyleSheets, this.sheet];
|
|
1073
|
+
return root;
|
|
1074
|
+
}
|
|
1075
|
+
connectedCallback() {
|
|
1076
|
+
super.connectedCallback();
|
|
1077
|
+
this.adopt();
|
|
1078
|
+
this.children$?.observe(this, { childList: true, attributes: true, attributeFilter: ['slot'], subtree: false });
|
|
1079
|
+
this.stood = this.givenItems;
|
|
1080
|
+
this.count = this.stood.length;
|
|
1081
|
+
this.tellItems();
|
|
1082
|
+
// CCM-36: a control of its form from the moment it stands in it, before it first draws.
|
|
1083
|
+
this.syncForm();
|
|
1084
|
+
if (this.hasUpdated)
|
|
1085
|
+
this.watch();
|
|
1086
|
+
}
|
|
1087
|
+
disconnectedCallback() {
|
|
1088
|
+
super.disconnectedCallback();
|
|
1089
|
+
this.children$?.disconnect();
|
|
1090
|
+
this.sizes?.disconnect();
|
|
1091
|
+
this.watched = [];
|
|
1092
|
+
clearTimeout(this.turn);
|
|
1093
|
+
this.turn = undefined;
|
|
1094
|
+
this.held = null;
|
|
1095
|
+
this.arriving = { accepted: [], refused: [] };
|
|
1096
|
+
this.endDrag();
|
|
1097
|
+
for (const element of this.lent)
|
|
1098
|
+
takeBack(element);
|
|
1099
|
+
this.lent.clear();
|
|
1100
|
+
}
|
|
1101
|
+
willUpdate(changed) {
|
|
1102
|
+
// CCM-38: `attachments` changed while it is shown: every file it keeps is let go and every File item it drew
|
|
1103
|
+
// leaves, or the product's items are no longer drawn and it begins with no kept file. Nothing is emitted or said.
|
|
1104
|
+
if (changed.has('attachments') && this.hasUpdated) {
|
|
1105
|
+
this.kept = [];
|
|
1106
|
+
this.refused = [];
|
|
1107
|
+
this.arrived = [];
|
|
1108
|
+
this.held = null;
|
|
1109
|
+
this.stood = this.givenItems;
|
|
1110
|
+
this.count = this.stood.length;
|
|
1111
|
+
this.hush = true;
|
|
1112
|
+
this.endDrag();
|
|
1113
|
+
this.changed();
|
|
1114
|
+
}
|
|
1115
|
+
if (this.isDisabled && this.receiving)
|
|
1116
|
+
this.endDrag();
|
|
1117
|
+
// CCM-30: the product's sentence, when it is set to a text or changed — never the one it was first presented with.
|
|
1118
|
+
if (changed.has('announcement') && this.hasUpdated && this.announcement.trim()) {
|
|
1119
|
+
this.own = this.announcement;
|
|
1120
|
+
this.changed();
|
|
1121
|
+
}
|
|
1122
|
+
if (this.hasUpdated) {
|
|
1123
|
+
// CCM-17: the button in the send button's place may change with this update; CCM-4: so may where the attach button stands.
|
|
1124
|
+
const active = this.shadowRoot?.activeElement ?? null;
|
|
1125
|
+
this.sendHeld = (!!active && active.matches('.send > *')) || [...this.slotted('send'), ...this.slotted('stop')].some(holdsFocus);
|
|
1126
|
+
this.startHeld = !!active && active.matches(`tanrei-file-picker > ${BUTTON}`);
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
firstUpdated() {
|
|
1130
|
+
// CCM-30: the File items that are here now are the ones it was presented with.
|
|
1131
|
+
this.changed();
|
|
1132
|
+
}
|
|
1133
|
+
updated(changed) {
|
|
1134
|
+
// W5: the render that has just ended gave the typing area what was set; from here the value is its own.
|
|
1135
|
+
this.pending = false;
|
|
1136
|
+
super.updated(changed);
|
|
1137
|
+
this.provider.sync();
|
|
1138
|
+
this.tellItems();
|
|
1139
|
+
this.lend();
|
|
1140
|
+
// CCM-6, CCM-17: the Button it brings in the send button's place takes the variant the system names.
|
|
1141
|
+
const variant = compChoice(this, `${PREFIX}-send-button-variant`, BUTTON_VARIANTS);
|
|
1142
|
+
giveVariant(this.renderRoot.querySelector(`.send > ${BUTTON}`), variant);
|
|
1143
|
+
this.keepFocus();
|
|
1144
|
+
this.syncForm();
|
|
1145
|
+
this.tellSendable();
|
|
1146
|
+
this.watch();
|
|
1147
|
+
if (!this.line)
|
|
1148
|
+
void this.input?.updateComplete.then(() => this.measure());
|
|
1149
|
+
if (this.presented)
|
|
1150
|
+
this.reports(changed);
|
|
1151
|
+
}
|
|
1152
|
+
/**
|
|
1153
|
+
* CCM-10, CCM-26: the product's own Buttons in the slots are disabled as their own `disabled` does — every one while
|
|
1154
|
+
* the chat composer is disabled, and the one in the send slot while nothing can be sent — and each gets back what it
|
|
1155
|
+
* had; one the product disabled itself is never enabled.
|
|
1156
|
+
*/
|
|
1157
|
+
lend() {
|
|
1158
|
+
const disabled = this.isDisabled;
|
|
1159
|
+
const now = new Map();
|
|
1160
|
+
for (const element of [...this.slotted('leading'), ...this.slotted('trailing'), ...this.slotted('stop')])
|
|
1161
|
+
now.set(element, disabled);
|
|
1162
|
+
for (const element of this.slotted('send'))
|
|
1163
|
+
now.set(element, disabled || !this.sendable);
|
|
1164
|
+
for (const [element, off] of now) {
|
|
1165
|
+
giveAttributes(element, { disabled: off });
|
|
1166
|
+
this.lent.add(element);
|
|
1167
|
+
}
|
|
1168
|
+
for (const element of [...this.lent]) {
|
|
1169
|
+
if (now.has(element))
|
|
1170
|
+
continue;
|
|
1171
|
+
takeBack(element);
|
|
1172
|
+
this.lent.delete(element);
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
/**
|
|
1176
|
+
* CCM-17: the button in the send button's place changed while it had focus — focus stays on the button now there, or
|
|
1177
|
+
* goes to the typing area where that one is disabled. CCM-4: an attach button the layout drew again keeps its focus.
|
|
1178
|
+
*/
|
|
1179
|
+
keepFocus() {
|
|
1180
|
+
if (this.sendHeld) {
|
|
1181
|
+
this.sendHeld = false;
|
|
1182
|
+
const place = this.renderRoot.querySelector(`.send > ${BUTTON}`) ?? this.slotted(this.sending && this.stoppable ? 'stop' : 'send')[0] ?? null;
|
|
1183
|
+
// A Button that is disabled now gives its focus up a moment later: it is not waited for.
|
|
1184
|
+
const off = !place || place.disabled === true;
|
|
1185
|
+
if (off) {
|
|
1186
|
+
if (!this.isDisabled)
|
|
1187
|
+
this.input?.focus();
|
|
1188
|
+
}
|
|
1189
|
+
else if (!holdsFocus(place))
|
|
1190
|
+
place.focus();
|
|
1191
|
+
}
|
|
1192
|
+
if (this.startHeld) {
|
|
1193
|
+
this.startHeld = false;
|
|
1194
|
+
const attach = this.renderRoot.querySelector(`tanrei-file-picker > ${BUTTON}`);
|
|
1195
|
+
if (attach && !holdsFocus(attach) && !this.shadowRoot?.activeElement)
|
|
1196
|
+
attach.focus();
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
/** What a debug build is told about the content, once it has all been written: the chat composer still renders. */
|
|
1200
|
+
check() {
|
|
1201
|
+
this.reports(new Map(), true);
|
|
1202
|
+
}
|
|
1203
|
+
reports(changed, all = false) {
|
|
1204
|
+
const has = (name) => all || changed.has(name);
|
|
1205
|
+
if (has('layout') && !LAYOUTS.includes(this.layout))
|
|
1206
|
+
report(this, 'CCM-4', `layout "${String(this.layout)}" is not a layout of the chat composer; it is laid out as "inline"`);
|
|
1207
|
+
if (has('sendKey') && !SEND_KEYS.includes(this.sendKey))
|
|
1208
|
+
report(this, 'CCM-12', `send-key "${String(this.sendKey)}" is not a value of sendKey; Enter sends, as with "enter"`);
|
|
1209
|
+
if (has('attachments') && !ATTACHMENTS.includes(this.attachments))
|
|
1210
|
+
report(this, 'CCM-38', `attachments "${String(this.attachments)}" is not a way of holding attachments; none can be attached, as with "none"`);
|
|
1211
|
+
if (has('attachmentForm') && !FORMS.includes(this.attachmentForm))
|
|
1212
|
+
report(this, 'CCM-44', `attachment-form "${String(this.attachmentForm)}" is not a form of the attachments; each file's form is chosen, as with "auto"`);
|
|
1213
|
+
// CCM-7: an element in the attach slot while nothing can be attached is not drawn.
|
|
1214
|
+
if (this.attaches === 'none' && this.slotted('attach').length)
|
|
1215
|
+
report(this, 'CCM-7', 'the attach slot holds an element while attachments is "none"; it is not drawn — say attachments="own" or "given"');
|
|
1216
|
+
// CCM-8: what a slot holds is laid out as it is; one that is not a Button is said.
|
|
1217
|
+
for (const name of ['leading', 'trailing']) {
|
|
1218
|
+
const other = this.slotted(name).find((element) => element.localName !== BUTTON);
|
|
1219
|
+
if (other)
|
|
1220
|
+
report(this, 'CCM-8', `<${other.localName}> in the ${name} slot is not a tanrei-button; it is laid out in its place as it is`);
|
|
1221
|
+
}
|
|
1222
|
+
// CCM-31: a control that assistive technology cannot name is a functional failure.
|
|
1223
|
+
if (!this.groupName)
|
|
1224
|
+
report(this, 'CCM-31', 'label is empty and no field names the chat composer, so the group and its typing area have no accessible name; give it a label, or put it in a tanrei-field', { level: 'error' });
|
|
1225
|
+
const stop = this.sending && this.stoppable;
|
|
1226
|
+
if (!stop && !this.slotted('send').length && !this.words.get('sendLabel', this.sendLabel))
|
|
1227
|
+
this.words.missing('sendLabel', { id: 'CCM-31', effect: 'the send button is drawn and works, and has no accessible name' });
|
|
1228
|
+
if (stop && !this.slotted('stop').length && !this.words.get('stopLabel', this.stopLabel))
|
|
1229
|
+
this.words.missing('stopLabel', { id: 'CCM-31', effect: 'the stop button is drawn and works, and has no accessible name' });
|
|
1230
|
+
if (this.attachShown && !this.slotted('attach').length && !this.words.get('attachLabel', this.attachLabel))
|
|
1231
|
+
this.words.missing('attachLabel', { id: 'CCM-31', effect: 'the attach button is drawn and works, and has no accessible name' });
|
|
1232
|
+
// CCM-22, CCM-31: a refused file's File item without the product's sentence for its reason is drawn with its mark and its name.
|
|
1233
|
+
for (const reason of ['type', 'size', 'count']) {
|
|
1234
|
+
if (this.refused.some((own) => own.reason === reason) && !this.sentence(reason))
|
|
1235
|
+
this.words.missing(REASON_WORDS[reason], { id: 'CCM-22', effect: `a file refused for its ${reason} is drawn as a failed row without a sentence that says why` });
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
// ─── What it draws ────────────────────────────────────────────────────────────────────────────────────────────
|
|
1239
|
+
/**
|
|
1240
|
+
* CCM-22, CCM-44: a File item it draws itself. A kept file is a pending File item given the file's handle — a tile
|
|
1241
|
+
* with its picture and no drawn name for an image (auto, tile), a tile for any file (tile), a row otherwise; a
|
|
1242
|
+
* refused one a failed row with the product's sentence, given no handle and never retryable. Neither is pressable.
|
|
1243
|
+
*/
|
|
1244
|
+
ownItem(own) {
|
|
1245
|
+
const image = fileKind(own.file.type, own.file.name) === 'image';
|
|
1246
|
+
const tile = !own.reason && (this.attachmentForm === 'tile' || (this.attachmentForm !== 'row' && image));
|
|
1247
|
+
const pictured = tile && image;
|
|
1248
|
+
return html `<tanrei-file-item
|
|
1249
|
+
part="file-item"
|
|
1250
|
+
exportparts=${ITEM_PARTS.attribute}
|
|
1251
|
+
.file=${own.reason ? null : own.file}
|
|
1252
|
+
.name=${own.file.name}
|
|
1253
|
+
.mediaType=${own.file.type}
|
|
1254
|
+
.status=${own.reason ? 'error' : 'pending'}
|
|
1255
|
+
.errorText=${own.reason ? this.sentence(own.reason) : ''}
|
|
1256
|
+
.form=${tile ? 'tile' : 'row'}
|
|
1257
|
+
.preview=${pictured}
|
|
1258
|
+
.nameHidden=${pictured}
|
|
1259
|
+
@remove=${(event) => this.removeOwn(event, own)}
|
|
1260
|
+
@retry=${this.stop}
|
|
1261
|
+
@click=${this.stop}
|
|
1262
|
+
></tanrei-file-item>`;
|
|
1263
|
+
}
|
|
1264
|
+
/** CCM-7: its file picker around its trigger — the product's own Button in the attach slot, or the one it brings. */
|
|
1265
|
+
attachPart(disabled) {
|
|
1266
|
+
const own = this.slotted('attach').length > 0;
|
|
1267
|
+
return html `<tanrei-file-picker
|
|
1268
|
+
part="file-picker"
|
|
1269
|
+
exportparts=${PICKER_PARTS.attribute}
|
|
1270
|
+
.multiple=${this.multiple}
|
|
1271
|
+
.accept=${this.accept}
|
|
1272
|
+
.maxSize=${this.maxSize}
|
|
1273
|
+
.maxFiles=${this.room}
|
|
1274
|
+
.disabled=${disabled}
|
|
1275
|
+
@select=${this.onPickerSelect}
|
|
1276
|
+
@reject=${this.onPickerReject}
|
|
1277
|
+
@tanrei-file-picker-arrival=${this.onArrival}
|
|
1278
|
+
>${own
|
|
1279
|
+
? html `<slot name="attach" slot="trigger"></slot>`
|
|
1280
|
+
: html `<tanrei-button slot="trigger" part="button attach-button" exportparts=${ATTACH_PARTS.attribute} variant="text" .label=${this.words.get('attachLabel', this.attachLabel)}
|
|
1281
|
+
><span slot="icon">${GLYPHS.attach}</span></tanrei-button
|
|
1282
|
+
>`}</tanrei-file-picker
|
|
1283
|
+
>`;
|
|
1284
|
+
}
|
|
1285
|
+
/** CCM-6, CCM-17: the send button — or, while a stoppable sending is under way, the stop button in its place: the product's own in its slot, or the one it brings. */
|
|
1286
|
+
sendPart(disabled, sendable) {
|
|
1287
|
+
const stop = this.sending && this.stoppable;
|
|
1288
|
+
const name = stop ? 'stop' : 'send';
|
|
1289
|
+
if (this.slotted(name).length)
|
|
1290
|
+
return html `<slot name=${name} @click=${stop ? this.onStop : this.onSend}></slot>`;
|
|
1291
|
+
return html `<tanrei-button
|
|
1292
|
+
part=${stop ? 'button stop-button' : 'button send-button'}
|
|
1293
|
+
exportparts=${SEND_PARTS.attribute}
|
|
1294
|
+
.label=${stop ? this.words.get('stopLabel', this.stopLabel) : this.words.get('sendLabel', this.sendLabel)}
|
|
1295
|
+
.disabled=${stop ? disabled : !sendable}
|
|
1296
|
+
@click=${stop ? this.onStop : this.onSend}
|
|
1297
|
+
><span slot="icon">${stop ? GLYPHS.stop : GLYPHS.send}</span></tanrei-button
|
|
1298
|
+
>`;
|
|
1299
|
+
}
|
|
1300
|
+
render() {
|
|
1301
|
+
const attaches = this.attaches;
|
|
1302
|
+
const disabled = this.isDisabled;
|
|
1303
|
+
const sendable = this.sendable;
|
|
1304
|
+
const stacked = this.stacked;
|
|
1305
|
+
const name = this.groupName;
|
|
1306
|
+
const own = attaches === 'own';
|
|
1307
|
+
const items = own ? [...this.kept, ...this.refused] : [];
|
|
1308
|
+
const drawn = own ? items.length : attaches === 'given' ? this.count : 0;
|
|
1309
|
+
const hasStart = this.attachShown || this.slotted('leading').length > 0;
|
|
1310
|
+
const hasEnd = this.counts || this.slotted('trailing').length > 0;
|
|
1311
|
+
// CCM-2, CCM-3: what stands before the typing area, or at the start of the row beneath — and what stands after it, or at that row's end.
|
|
1312
|
+
const start = hasStart ? html `${this.attachShown ? this.attachPart(disabled) : nothing}<slot name="leading"></slot>` : nothing;
|
|
1313
|
+
const end = hasEnd
|
|
1314
|
+
? html `<div class="group end">${this.counts ? html `<span part="counter" class="counter" ?data-over=${this.over}>${this.counterText}</span>` : nothing}<slot name="trailing"></slot></div>`
|
|
1315
|
+
: nothing;
|
|
1316
|
+
return html `
|
|
1317
|
+
<div
|
|
1318
|
+
part="container"
|
|
1319
|
+
class="capsule"
|
|
1320
|
+
role="group"
|
|
1321
|
+
aria-label=${name || nothing}
|
|
1322
|
+
aria-busy=${this.sending ? 'true' : nothing}
|
|
1323
|
+
aria-disabled=${disabled ? 'true' : nothing}
|
|
1324
|
+
data-layout=${stacked ? 'stacked' : 'inline'}
|
|
1325
|
+
?data-error=${this.isError}
|
|
1326
|
+
?data-focused=${this.typing && !disabled}
|
|
1327
|
+
?data-receiving=${this.receiving && !disabled}
|
|
1328
|
+
?data-disabled=${disabled}
|
|
1329
|
+
@mousedown=${this.onGround}
|
|
1330
|
+
>
|
|
1331
|
+
<span class="outline"></span>
|
|
1332
|
+
<div part="strip" class="strip" role=${drawn ? 'list' : nothing} aria-label=${drawn && name ? name : nothing} ?hidden=${!drawn}>
|
|
1333
|
+
${own ? repeat(items, (each) => each, (each) => this.ownItem(each)) : attaches === 'given' ? html `<slot></slot>` : nothing}
|
|
1334
|
+
</div>
|
|
1335
|
+
<div class="line" ?data-start=${!stacked && hasStart}>
|
|
1336
|
+
${!stacked && hasStart ? html `<div class="group start">${start}</div>` : nothing}
|
|
1337
|
+
<div class="typing">
|
|
1338
|
+
<tanrei-embedded-text-input
|
|
1339
|
+
part="embedded-text-input"
|
|
1340
|
+
exportparts=${INPUT_PARTS.attribute}
|
|
1341
|
+
multiline
|
|
1342
|
+
.value=${this.value}
|
|
1343
|
+
.label=${name}
|
|
1344
|
+
.placeholder=${this.placeholder}
|
|
1345
|
+
.minRows=${this.minRows}
|
|
1346
|
+
.maxRows=${this.mostRows}
|
|
1347
|
+
.enterKey=${this.enterKey}
|
|
1348
|
+
.description=${this.description}
|
|
1349
|
+
.error=${this.isError}
|
|
1350
|
+
.disabled=${disabled}
|
|
1351
|
+
@input=${this.onInput}
|
|
1352
|
+
@action=${this.onAction}
|
|
1353
|
+
@change=${this.stop}
|
|
1354
|
+
@rowschange=${this.stop}
|
|
1355
|
+
@focusin=${this.onTypingFocus}
|
|
1356
|
+
@focusout=${this.onTypingBlur}
|
|
1357
|
+
@paste=${this.onPaste}
|
|
1358
|
+
></tanrei-embedded-text-input>
|
|
1359
|
+
</div>
|
|
1360
|
+
${!stacked ? end : nothing}
|
|
1361
|
+
<div class="group send">${this.sendPart(disabled, sendable)}</div>
|
|
1362
|
+
</div>
|
|
1363
|
+
${stacked ? html `<div class="row">${start}${end}</div>` : nothing}
|
|
1364
|
+
<div class="measures" aria-hidden="true"><span class="probe"></span></div>
|
|
1365
|
+
<div class="announce" aria-live="polite" aria-atomic="true"></div>
|
|
1366
|
+
</div>
|
|
1367
|
+
`;
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
// Its `disabled` attribute, written while it holds focus, waits until focus has left: a frame at most.
|
|
1371
|
+
disabledWaitsWhileFocused(TanreiChatComposer);
|
|
1372
|
+
if (!customElements.get('tanrei-chat-composer'))
|
|
1373
|
+
customElements.define('tanrei-chat-composer', TanreiChatComposer);
|
|
1374
|
+
//# sourceMappingURL=chat-composer.js.map
|