@redvars/peacock 4.1.0 → 4.2.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/dist/{BaseField-BMumJpkW.js → BaseField-_unSNU5x.js} +40 -4
- package/dist/BaseField-_unSNU5x.js.map +1 -0
- package/dist/{BaseInput-mWdyYv27.js → BaseInput-DtZH0fPJ.js} +3 -3
- package/dist/BaseInput-DtZH0fPJ.js.map +1 -0
- package/dist/ai-badge.js +32 -6
- package/dist/ai-badge.js.map +1 -1
- package/dist/ai-summary.js +2 -2
- package/dist/alert.js +2 -2
- package/dist/anchor-nav.js +2 -2
- package/dist/app-shell.js +2 -2
- package/dist/assistant-panel.js +2 -2
- package/dist/assistant-step.js +2 -2
- package/dist/assistant-steps.js +2 -2
- package/dist/avatar-group.js +2 -2
- package/dist/banner.js +2 -2
- package/dist/{base-progress-CvLVSjuy.js → base-progress-D7Nmfh1s.js} +2 -2
- package/dist/{base-progress-CvLVSjuy.js.map → base-progress-D7Nmfh1s.js.map} +1 -1
- package/dist/bottom-sheet.js +2 -2
- package/dist/breadcrumb.js +2 -2
- package/dist/button.js +11 -5
- package/dist/button.js.map +1 -1
- package/dist/calendar.js +2 -2
- package/dist/{canvas-base-BTQMEVn_.js → canvas-base-CWQ4rQ2s.js} +2 -2
- package/dist/{canvas-base-BTQMEVn_.js.map → canvas-base-CWQ4rQ2s.js.map} +1 -1
- package/dist/{cartesian-chart-DM1FC_XT.js → cartesian-chart-CS5yRLfE.js} +2 -2
- package/dist/{cartesian-chart-DM1FC_XT.js.map → cartesian-chart-CS5yRLfE.js.map} +1 -1
- package/dist/{cb-group-base-B6fa4Lll.js → cb-group-base-CO30uFQZ.js} +2 -2
- package/dist/{cb-group-base-B6fa4Lll.js.map → cb-group-base-CO30uFQZ.js.map} +1 -1
- package/dist/cb-group.js +3 -3
- package/dist/cb-rule.js +3 -3
- package/dist/chart-area.js +4 -4
- package/dist/chart-bar.js +4 -4
- package/dist/{chart-base-Dhxuw_Mw.js → chart-base-C_XKVyhf.js} +2 -2
- package/dist/{chart-base-Dhxuw_Mw.js.map → chart-base-C_XKVyhf.js.map} +1 -1
- package/dist/chart-doughnut.js +3 -3
- package/dist/chart-line.js +4 -4
- package/dist/chart-pie.js +3 -3
- package/dist/chat-event.js +152 -0
- package/dist/chat-event.js.map +1 -0
- package/dist/chat-message.js +195 -19
- package/dist/chat-message.js.map +1 -1
- package/dist/chat-thread.js +26 -9
- package/dist/chat-thread.js.map +1 -1
- package/dist/checkbox-group.js +4 -4
- package/dist/checkbox.js +4 -4
- package/dist/chip-set.js +3 -3
- package/dist/chip.js +2 -2
- package/dist/circular-progress.js +3 -3
- package/dist/citation.js +2 -2
- package/dist/code-editor.js +4 -4
- package/dist/code-highlighter.js +2 -2
- package/dist/color-field.js +5 -5
- package/dist/color-picker.js +2 -2
- package/dist/command-palette.js +2 -2
- package/dist/comment-composer.js +5 -5
- package/dist/condition-builder.js +3 -3
- package/dist/confirm-dialog.js +2 -2
- package/dist/copy-button.js +2 -2
- package/dist/currency-field.js +5 -5
- package/dist/custom-elements-jsdocs.json +174 -20
- package/dist/custom-elements.json +1122 -68
- package/dist/date-field.js +6 -6
- package/dist/date-picker.js +2 -2
- package/dist/date-range-field.js +6 -6
- package/dist/datetime-field.js +6 -6
- package/dist/dependency-map.js +3 -3
- package/dist/description-item.js +2 -2
- package/dist/description-list.js +2 -2
- package/dist/{diagram-2r11KySs.js → diagram-Va096vj9.js} +2 -2
- package/dist/{diagram-2r11KySs.js.map → diagram-Va096vj9.js.map} +1 -1
- package/dist/diagram-controls.js +2 -2
- package/dist/diagram-minimap.js +2 -2
- package/dist/diagram.js +4 -4
- package/dist/diff-viewer.js +2 -2
- package/dist/discussion-activity.js +4 -4
- package/dist/discussion-comment.js +4 -4
- package/dist/{discussion-time-BegaYfhf.js → discussion-time-DqykqvNy.js} +2 -2
- package/dist/{discussion-time-BegaYfhf.js.map → discussion-time-DqykqvNy.js.map} +1 -1
- package/dist/discussion.js +7 -7
- package/dist/{document-editor-BnEugM3E.js → document-editor-Dc8JeFVB.js} +2 -2
- package/dist/{document-editor-BnEugM3E.js.map → document-editor-Dc8JeFVB.js.map} +1 -1
- package/dist/document-editor.js +3 -3
- package/dist/draft-card.js +14 -4
- package/dist/draft-card.js.map +1 -1
- package/dist/dropdown-button.js +3 -2
- package/dist/dropdown-button.js.map +1 -1
- package/dist/erd.js +3 -3
- package/dist/file-upload.js +4 -4
- package/dist/filter-bar.js +2 -2
- package/dist/flow.js +4 -4
- package/dist/form.js +3 -3
- package/dist/{generative-view-BgOcLRXr.js → generative-view-BKlcuujw.js} +2 -2
- package/dist/{generative-view-BgOcLRXr.js.map → generative-view-BKlcuujw.js.map} +1 -1
- package/dist/generative-view.js +3 -3
- package/dist/html-editor.js +5 -5
- package/dist/{i18n-controller-Cp43HjJl.js → i18n-controller-DJHsE1YH.js} +2 -2
- package/dist/{i18n-controller-Cp43HjJl.js.map → i18n-controller-DJHsE1YH.js.map} +1 -1
- package/dist/icon-button.js +7 -5
- package/dist/icon-button.js.map +1 -1
- package/dist/image.js +2 -2
- package/dist/index.js +21 -20
- package/dist/index.js.map +1 -1
- package/dist/inline-edit.js +2 -2
- package/dist/input.js +4 -4
- package/dist/json-viewer.js +2 -2
- package/dist/kanban.js +2 -2
- package/dist/kbd.js +2 -2
- package/dist/linear-progress.js +3 -3
- package/dist/link-button.js +7 -5
- package/dist/link-button.js.map +1 -1
- package/dist/listbox.js +3 -3
- package/dist/loader-full.js +13 -12
- package/dist/loader-full.js.map +1 -1
- package/dist/loader.js +16 -12
- package/dist/loader.js.map +1 -1
- package/dist/markdown-editor.js +5 -5
- package/dist/mention-input.js +5 -5
- package/dist/{menu-trigger-controller-DyLpTxM7.js → menu-trigger-controller-CEJq1ugC.js} +11 -14
- package/dist/menu-trigger-controller-CEJq1ugC.js.map +1 -0
- package/dist/modal.js +2 -2
- package/dist/navigation-bar.js +2 -2
- package/dist/navigation-drawer.js +2 -2
- package/dist/navigation-rail.js +2 -2
- package/dist/notification-center.js +3 -3
- package/dist/number-field.js +5 -5
- package/dist/page-header.js +2 -2
- package/dist/pagination.js +2 -2
- package/dist/password-field.js +5 -5
- package/dist/password-rules.js +2 -2
- package/dist/phone-field.js +5 -5
- package/dist/{picker-field-dTlIMAQn.js → picker-field-CUI05sWc.js} +3 -3
- package/dist/{picker-field-dTlIMAQn.js.map → picker-field-CUI05sWc.js.map} +1 -1
- package/dist/pin-input.js +5 -5
- package/dist/presence-indicator.js +2 -2
- package/dist/prompt-input.js +5 -5
- package/dist/radio-group.js +1 -1
- package/dist/radio.js +4 -4
- package/dist/rating.js +4 -4
- package/dist/redvars-loader.js +2 -2
- package/dist/{relative-time-BVQXLuHm.js → relative-time-BNxqvEbg.js} +13 -2
- package/dist/relative-time-BNxqvEbg.js.map +1 -0
- package/dist/relative-time.js +3 -3
- package/dist/resizable-panels.js +2 -2
- package/dist/{rich-text-input-DM_BOzgk.js → rich-text-input-N_hqnXej.js} +3 -3
- package/dist/{rich-text-input-DM_BOzgk.js.map → rich-text-input-N_hqnXej.js.map} +1 -1
- package/dist/{schema-B8g30A_n.js → schema-Dy0z-80u.js} +2 -2
- package/dist/{schema-B8g30A_n.js.map → schema-Dy0z-80u.js.map} +1 -1
- package/dist/search.js +4 -4
- package/dist/select.js +5 -5
- package/dist/side-sheet.js +2 -2
- package/dist/signature-pad.js +4 -4
- package/dist/slider.js +4 -4
- package/dist/snackbar.js +2 -2
- package/dist/sparkline.js +2 -2
- package/dist/split-button.js +109 -21
- package/dist/split-button.js.map +1 -1
- package/dist/src/__internal/ai/suggestion-controller.d.ts +2 -0
- package/dist/src/__internal/i18n/strings.d.ts +6 -0
- package/dist/src/__internal/menu-trigger-controller.d.ts +11 -8
- package/dist/src/__internal/utils/relative-time.d.ts +5 -0
- package/dist/src/ai-badge/ai-badge.d.ts +8 -0
- package/dist/src/button/button/button.d.ts +4 -0
- package/dist/src/chat-message/chat-message.d.ts +51 -10
- package/dist/src/chat-message/index.d.ts +1 -1
- package/dist/src/chat-thread/chat-event.d.ts +37 -0
- package/dist/src/chat-thread/chat-thread.d.ts +7 -4
- package/dist/src/chat-thread/index.d.ts +1 -0
- package/dist/src/index.d.ts +2 -2
- package/dist/src/input/BaseField.d.ts +12 -1
- package/dist/src/input/BaseInput.d.ts +1 -0
- package/dist/src/split-button/split-button.d.ts +7 -2
- package/dist/src/textarea/textarea.d.ts +2 -0
- package/dist/stat.js +2 -2
- package/dist/status-indicator.js +2 -2
- package/dist/step.js +2 -2
- package/dist/stepper.js +2 -2
- package/dist/{strings-BJPuhKJk.js → strings-DnYjGbbc.js} +7 -1
- package/dist/{strings-BJPuhKJk.js.map → strings-DnYjGbbc.js.map} +1 -1
- package/dist/{suggestion-controller-CW17adxd.js → suggestion-controller-7YRQqkaI.js} +3 -1
- package/dist/{suggestion-controller-CW17adxd.js.map → suggestion-controller-7YRQqkaI.js.map} +1 -1
- package/dist/svg.js +2 -2
- package/dist/switch.js +4 -4
- package/dist/table.js +50 -11
- package/dist/table.js.map +1 -1
- package/dist/textarea.js +10 -5
- package/dist/textarea.js.map +1 -1
- package/dist/time-field.js +6 -6
- package/dist/time-picker.js +2 -2
- package/dist/timeline-item.js +2 -2
- package/dist/timeline.js +2 -2
- package/dist/{toggle-base-BlaHalfS.js → toggle-base-CXmFSp3b.js} +2 -2
- package/dist/{toggle-base-BlaHalfS.js.map → toggle-base-CXmFSp3b.js.map} +1 -1
- package/dist/tour.js +2 -2
- package/dist/transfer-list.js +4 -4
- package/dist/tree-chart.js +3 -3
- package/dist/tree-item.js +2 -2
- package/dist/tree.js +2 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/typing-indicator.js +2 -2
- package/dist/url-field.js +5 -5
- package/dist/user-menu.js +3 -3
- package/dist/virtual-list.js +2 -2
- package/dist/workflow-timeline.js +2 -2
- package/dist/workflow.js +3 -3
- package/dist/workspace-switcher.js +3 -3
- package/package.json +1 -1
- package/src/__internal/ai/suggestion-controller.ts +3 -1
- package/src/__internal/i18n/strings.ts +6 -0
- package/src/__internal/menu-trigger-controller.ts +11 -15
- package/src/__internal/utils/relative-time.ts +20 -0
- package/src/ai-badge/ai-badge.scss +8 -0
- package/src/ai-badge/ai-badge.ts +21 -4
- package/src/button/button/button-base.scss +9 -2
- package/src/button/button/button-layers.scss +3 -1
- package/src/button/button/button.ts +4 -0
- package/src/chat-message/chat-message.scss +72 -0
- package/src/chat-message/chat-message.ts +137 -18
- package/src/chat-message/index.ts +1 -0
- package/src/chat-thread/chat-event.scss +36 -0
- package/src/chat-thread/chat-event.ts +79 -0
- package/src/chat-thread/chat-thread.scss +4 -1
- package/src/chat-thread/chat-thread.ts +22 -6
- package/src/chat-thread/index.ts +1 -0
- package/src/draft-card/draft-card.scss +16 -2
- package/src/dropdown-button/dropdown-button.ts +2 -1
- package/src/index.ts +2 -1
- package/src/input/BaseField.ts +42 -2
- package/src/input/BaseInput.ts +1 -1
- package/src/loader.ts +4 -0
- package/src/split-button/split-button-colors.scss +9 -0
- package/src/split-button/split-button-sizes.scss +32 -5
- package/src/split-button/split-button.scss +61 -8
- package/src/split-button/split-button.ts +15 -8
- package/src/table/table.scss +57 -9
- package/src/table/table.ts +3 -1
- package/src/textarea/textarea.ts +7 -0
- package/dist/BaseField-BMumJpkW.js.map +0 -1
- package/dist/BaseInput-mWdyYv27.js.map +0 -1
- package/dist/menu-trigger-controller-DyLpTxM7.js.map +0 -1
- package/dist/relative-time-BVQXLuHm.js.map +0 -1
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
import { html, LitElement, nothing } from 'lit';
|
|
2
|
-
import { property } from 'lit/decorators.js';
|
|
2
|
+
import { property, state } from 'lit/decorators.js';
|
|
3
3
|
import { classMap } from 'lit/directives/class-map.js';
|
|
4
4
|
|
|
5
5
|
import type { AiCitation } from '@/__internal/ai/types.js';
|
|
6
6
|
import { I18nController } from '@/__internal/i18n/i18n-controller.js';
|
|
7
7
|
import type { PeacockStrings } from '@/__internal/i18n/strings.js';
|
|
8
|
+
import {
|
|
9
|
+
formatAbsoluteTime,
|
|
10
|
+
formatClockTime,
|
|
11
|
+
parseDatetime,
|
|
12
|
+
} from '@/__internal/utils/relative-time.js';
|
|
8
13
|
import IndividualComponent from '@/IndividualComponent.js';
|
|
9
14
|
import styles from './chat-message.scss';
|
|
10
15
|
|
|
11
|
-
/**
|
|
12
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Who wrote a message: the person using the page (`user`), the assistant, or another person in
|
|
18
|
+
* the conversation (`participant`), such as a caller or a teammate.
|
|
19
|
+
*/
|
|
20
|
+
export type ChatMessageFrom = 'user' | 'assistant' | 'participant';
|
|
13
21
|
|
|
14
22
|
/** What the person thought of an answer; `''` for nothing. */
|
|
15
23
|
export type ChatMessageFeedback = 'up' | 'down' | '';
|
|
@@ -19,17 +27,28 @@ export interface ChatMessageFeedbackDetail {
|
|
|
19
27
|
value: ChatMessageFeedback;
|
|
20
28
|
}
|
|
21
29
|
|
|
30
|
+
/** `detail` of `suggestion-select`. */
|
|
31
|
+
export interface ChatMessageSuggestionDetail {
|
|
32
|
+
value: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
22
35
|
/**
|
|
23
36
|
* @label Chat Message
|
|
24
37
|
* @tag wc-chat-message
|
|
25
38
|
* @rawTag chat-message
|
|
26
|
-
* @summary One turn of a conversation: what the person asked, or the assistant's answer with its steps, drafts and sources.
|
|
39
|
+
* @summary One turn of a conversation: what the person asked, another person's message, or the assistant's answer with its steps, drafts and sources.
|
|
27
40
|
* @overview
|
|
28
41
|
* <p>Put messages in <code>wc-chat-thread</code>. <code>from="user"</code> shows the person's text in
|
|
29
42
|
* a bubble at the end of the line; <code>from="assistant"</code> (default) shows the answer as
|
|
30
|
-
* formatted text
|
|
31
|
-
*
|
|
32
|
-
* <code>
|
|
43
|
+
* formatted text; <code>from="participant"</code> shows another person's text, such as a caller's
|
|
44
|
+
* or a teammate's, in a quiet bubble at the start of the line, with their name above it. All take
|
|
45
|
+
* Markdown in <code>value</code>, rendered by <code>wc-markdown</code>, so mentions and
|
|
46
|
+
* <code>[1](cite:id)</code> citations work; give the sources in <code>citations</code>.</p>
|
|
47
|
+
* <p><strong>Who and when.</strong> A line above the message names <code>author</code> and adds
|
|
48
|
+
* <code>channel</code> ("via Teams") and the time of <code>datetime</code>. It shows for a
|
|
49
|
+
* participant, whenever <code>datetime</code> or <code>channel</code> is set, and when the
|
|
50
|
+
* <code>meta</code> slot has content, such as a "Work note" tag. In a one-to-one conversation with
|
|
51
|
+
* the assistant, leave them out and the messages stay bare.</p>
|
|
33
52
|
* <p>While an answer arrives, set <code>streaming</code> and keep replacing <code>value</code>. Before
|
|
34
53
|
* the first words, a typing indicator shows <code>status</code>, such as "Looking up your laptop…".
|
|
35
54
|
* Put <code>wc-assistant-steps</code> in the <code>steps</code> slot, above the text, and
|
|
@@ -37,28 +56,42 @@ export interface ChatMessageFeedbackDetail {
|
|
|
37
56
|
* <p>A finished answer has actions: copy, <strong>Try again</strong> (<code>regenerate</code>) and
|
|
38
57
|
* good or bad (<code>feedback</code>, which toggles <code>feedback</code>). <code>hide-actions</code>
|
|
39
58
|
* removes them. With <code>error</code> the message says the answer failed, with Try again.</p>
|
|
59
|
+
* <p><strong>Quick replies.</strong> <code>suggestions</code> shows the likely next moves as chips
|
|
60
|
+
* under the message ("Promote to major incident", "Why P2?"). Picking one fires
|
|
61
|
+
* <code>suggestion-select</code>; the app sends it and usually clears the list.</p>
|
|
40
62
|
* @tags display, ai
|
|
41
63
|
*
|
|
42
64
|
* @slot - Below the text, such as `wc-draft-card`s.
|
|
43
65
|
* @slot steps - Above the text, such as `wc-assistant-steps`.
|
|
44
66
|
* @slot avatar - Beside the message, such as a `wc-avatar`.
|
|
45
|
-
* @slot
|
|
67
|
+
* @slot meta - At the end of the line above the message, such as a "Work note" `wc-tag`.
|
|
68
|
+
* @slot footer - Below everything.
|
|
46
69
|
*
|
|
47
|
-
* @csspart
|
|
70
|
+
* @csspart header - The line above the message with the author, channel and time.
|
|
71
|
+
* @csspart bubble - The text bubble of the person or a participant.
|
|
48
72
|
* @csspart content - The answer's text.
|
|
49
73
|
* @csspart actions - The answer's actions.
|
|
74
|
+
* @csspart suggestions - The quick replies.
|
|
50
75
|
*
|
|
51
76
|
* @cssprop --chat-message-bubble-background - Background of the person's bubble.
|
|
52
77
|
* @cssprop --chat-message-bubble-color - Text color of the person's bubble.
|
|
78
|
+
* @cssprop --chat-message-participant-background - Background of a participant's bubble.
|
|
79
|
+
* @cssprop --chat-message-participant-color - Text color of a participant's bubble.
|
|
53
80
|
*
|
|
54
81
|
* @fires {CustomEvent<void>} regenerate - The person asked for the answer again.
|
|
55
82
|
* @fires {CustomEvent<ChatMessageFeedbackDetail>} feedback - The person rated the answer, or took the rating back (`value: ''`).
|
|
83
|
+
* @fires {CustomEvent<ChatMessageSuggestionDetail>} suggestion-select - The person picked a quick reply.
|
|
56
84
|
*
|
|
57
85
|
* @example
|
|
58
86
|
* ```html
|
|
59
87
|
* <wc-chat-message from="user" value="Will I get a loaner before Friday?"></wc-chat-message>
|
|
60
88
|
* <wc-chat-message value="Desk support has **2 loaners** free."></wc-chat-message>
|
|
61
89
|
* ```
|
|
90
|
+
* @example
|
|
91
|
+
* ```html
|
|
92
|
+
* <wc-chat-message from="participant" author="Priya Shah" channel="Teams"
|
|
93
|
+
* datetime="2026-11-08T09:41:00" value="VPN keeps dropping every ten minutes."></wc-chat-message>
|
|
94
|
+
* ```
|
|
62
95
|
*/
|
|
63
96
|
@IndividualComponent
|
|
64
97
|
export class ChatMessage extends LitElement {
|
|
@@ -68,13 +101,19 @@ export class ChatMessage extends LitElement {
|
|
|
68
101
|
|
|
69
102
|
// ── Properties ───────────────────────────────────────────────────────────
|
|
70
103
|
|
|
71
|
-
/** Who wrote it: the person (`user`)
|
|
104
|
+
/** Who wrote it: the person (`user`), the assistant (`assistant`, default) or another person (`participant`). */
|
|
72
105
|
@property({ type: String, reflect: true }) from: ChatMessageFrom =
|
|
73
106
|
'assistant';
|
|
74
107
|
|
|
75
|
-
/** Name read before
|
|
108
|
+
/** Name shown above a participant's message and read before every message; defaults to "You", "Assistant" or "Participant". */
|
|
76
109
|
@property({ type: String }) author = '';
|
|
77
110
|
|
|
111
|
+
/** When it was written, as an ISO 8601 date-time; shown as a time above the message. */
|
|
112
|
+
@property({ type: String }) datetime = '';
|
|
113
|
+
|
|
114
|
+
/** Where it came from, such as "Teams"; shown as "via Teams" above the message. */
|
|
115
|
+
@property({ type: String }) channel = '';
|
|
116
|
+
|
|
78
117
|
/** The text, as Markdown. */
|
|
79
118
|
@property({ type: String }) value = '';
|
|
80
119
|
|
|
@@ -102,9 +141,20 @@ export class ChatMessage extends LitElement {
|
|
|
102
141
|
/** Removes copy, Try again and the rating from an answer. */
|
|
103
142
|
@property({ type: Boolean, attribute: 'hide-actions' }) hideActions = false;
|
|
104
143
|
|
|
144
|
+
/** Quick replies shown as chips under the message once it is complete. */
|
|
145
|
+
@property({ attribute: false }) suggestions: string[] = [];
|
|
146
|
+
|
|
147
|
+
/** Locale for the time; defaults to the nearest `lang`, else the browser's. */
|
|
148
|
+
@property({ type: String }) locale?: string;
|
|
149
|
+
|
|
105
150
|
/** Per-instance string overrides. */
|
|
106
151
|
@property({ attribute: false }) strings?: Partial<PeacockStrings>;
|
|
107
152
|
|
|
153
|
+
// ── State ────────────────────────────────────────────────────────────────
|
|
154
|
+
|
|
155
|
+
/** The `meta` slot has content. */
|
|
156
|
+
@state() private _hasMeta = false;
|
|
157
|
+
|
|
108
158
|
// ── Private fields ───────────────────────────────────────────────────────
|
|
109
159
|
|
|
110
160
|
private readonly i18n = new I18nController(this);
|
|
@@ -114,13 +164,29 @@ export class ChatMessage extends LitElement {
|
|
|
114
164
|
/** The name read before the message. */
|
|
115
165
|
get authorName(): string {
|
|
116
166
|
if (this.author) return this.author;
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
167
|
+
if (this.from === 'user') return this.i18n.t('chatYou');
|
|
168
|
+
if (this.from === 'participant') return this.i18n.t('chatParticipant');
|
|
169
|
+
return this.i18n.t('chatAssistant');
|
|
120
170
|
}
|
|
121
171
|
|
|
122
172
|
// ── Private methods ──────────────────────────────────────────────────────
|
|
123
173
|
|
|
174
|
+
private _onMetaChange(event: Event) {
|
|
175
|
+
this._hasMeta =
|
|
176
|
+
(event.target as HTMLSlotElement).assignedNodes({ flatten: true })
|
|
177
|
+
.length > 0;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
private _pick(value: string) {
|
|
181
|
+
this.dispatchEvent(
|
|
182
|
+
new CustomEvent<ChatMessageSuggestionDetail>('suggestion-select', {
|
|
183
|
+
detail: { value },
|
|
184
|
+
bubbles: true,
|
|
185
|
+
composed: true,
|
|
186
|
+
}),
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
|
|
124
190
|
private regenerate = () => {
|
|
125
191
|
this.dispatchEvent(
|
|
126
192
|
new CustomEvent('regenerate', { bubbles: true, composed: true }),
|
|
@@ -138,7 +204,7 @@ export class ChatMessage extends LitElement {
|
|
|
138
204
|
);
|
|
139
205
|
}
|
|
140
206
|
|
|
141
|
-
// ── Render
|
|
207
|
+
// ── Render helpers ───────────────────────────────────────────────────────
|
|
142
208
|
|
|
143
209
|
private renderText() {
|
|
144
210
|
if (!this.value && this.streaming) {
|
|
@@ -220,23 +286,76 @@ export class ChatMessage extends LitElement {
|
|
|
220
286
|
</div>`;
|
|
221
287
|
}
|
|
222
288
|
|
|
289
|
+
private renderHeader() {
|
|
290
|
+
const date = parseDatetime(this.datetime);
|
|
291
|
+
const shown =
|
|
292
|
+
this.from === 'participant' || !!date || !!this.channel || this._hasMeta;
|
|
293
|
+
const { locale } = this.i18n;
|
|
294
|
+
return html`<div class="header" part="header" ?hidden=${!shown}>
|
|
295
|
+
<span class="author">${this.authorName}</span>
|
|
296
|
+
${this.channel
|
|
297
|
+
? html`<span class="channel"
|
|
298
|
+
>${this.i18n.t('chatVia')(this.channel)}</span
|
|
299
|
+
>`
|
|
300
|
+
: nothing}
|
|
301
|
+
${date
|
|
302
|
+
? html`<time
|
|
303
|
+
class="time"
|
|
304
|
+
datetime=${this.datetime}
|
|
305
|
+
title=${formatAbsoluteTime(date, locale)}
|
|
306
|
+
>${formatClockTime(date, locale)}</time
|
|
307
|
+
>`
|
|
308
|
+
: nothing}
|
|
309
|
+
<slot name="meta" @slotchange=${this._onMetaChange}></slot>
|
|
310
|
+
</div>`;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
private renderSuggestions() {
|
|
314
|
+
if (!this.suggestions.length || this.streaming || this.error) {
|
|
315
|
+
return nothing;
|
|
316
|
+
}
|
|
317
|
+
return html`<div
|
|
318
|
+
class="suggestions"
|
|
319
|
+
part="suggestions"
|
|
320
|
+
role="group"
|
|
321
|
+
aria-label=${this.i18n.t('chatQuickReplies')}
|
|
322
|
+
>
|
|
323
|
+
${this.suggestions.map(
|
|
324
|
+
suggestion =>
|
|
325
|
+
html`<wc-chip @click=${() => this._pick(suggestion)}
|
|
326
|
+
>${suggestion}</wc-chip
|
|
327
|
+
>`,
|
|
328
|
+
)}
|
|
329
|
+
</div>`;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// ── Render ───────────────────────────────────────────────────────────────
|
|
333
|
+
|
|
223
334
|
render() {
|
|
224
|
-
const
|
|
335
|
+
const { from } = this;
|
|
336
|
+
const bubble = from !== 'assistant';
|
|
225
337
|
return html`<article
|
|
226
|
-
class=${classMap({
|
|
338
|
+
class=${classMap({
|
|
339
|
+
message: true,
|
|
340
|
+
user: from === 'user',
|
|
341
|
+
participant: from === 'participant',
|
|
342
|
+
assistant: from === 'assistant',
|
|
343
|
+
})}
|
|
227
344
|
aria-label=${this.authorName}
|
|
228
345
|
aria-busy=${this.streaming ? 'true' : nothing}
|
|
229
346
|
>
|
|
230
347
|
<slot name="avatar"></slot>
|
|
231
348
|
<div class="body">
|
|
349
|
+
${this.renderHeader()}
|
|
232
350
|
<slot name="steps"></slot>
|
|
233
|
-
${
|
|
351
|
+
${bubble
|
|
234
352
|
? html`<div class="bubble" part="bubble">${this.renderText()}</div>`
|
|
235
353
|
: html`<div class="content" part="content">
|
|
236
354
|
${this.renderText()}
|
|
237
355
|
</div>`}
|
|
238
356
|
<slot></slot>
|
|
239
357
|
${this.renderError()} ${this.renderActions()}
|
|
358
|
+
${this.renderSuggestions()}
|
|
240
359
|
<slot name="footer"></slot>
|
|
241
360
|
</div>
|
|
242
361
|
</article>`;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
@use '../../scss/mixin';
|
|
2
|
+
|
|
3
|
+
@include mixin.base-styles;
|
|
4
|
+
|
|
5
|
+
:host {
|
|
6
|
+
display: block;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.event {
|
|
10
|
+
display: flex;
|
|
11
|
+
flex-wrap: wrap;
|
|
12
|
+
align-items: center;
|
|
13
|
+
justify-content: center;
|
|
14
|
+
gap: var(--spacing-050, 0.25rem) var(--spacing-100, 0.5rem);
|
|
15
|
+
margin: 0;
|
|
16
|
+
color: var(--color-on-surface-variant);
|
|
17
|
+
text-align: center;
|
|
18
|
+
@include mixin.get-typography-not-important(body-small);
|
|
19
|
+
|
|
20
|
+
wc-icon {
|
|
21
|
+
flex: none;
|
|
22
|
+
--icon-size: 1rem;
|
|
23
|
+
--icon-color: currentColor;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
::slotted(strong),
|
|
28
|
+
::slotted(b) {
|
|
29
|
+
color: var(--color-on-surface);
|
|
30
|
+
font-weight: 600;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.time::before {
|
|
34
|
+
margin-inline-end: var(--spacing-100, 0.5rem);
|
|
35
|
+
content: '·';
|
|
36
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { html, LitElement, nothing } from 'lit';
|
|
2
|
+
import { property } from 'lit/decorators.js';
|
|
3
|
+
|
|
4
|
+
import { I18nController } from '@/__internal/i18n/i18n-controller.js';
|
|
5
|
+
import {
|
|
6
|
+
formatAbsoluteTime,
|
|
7
|
+
formatClockTime,
|
|
8
|
+
parseDatetime,
|
|
9
|
+
} from '@/__internal/utils/relative-time.js';
|
|
10
|
+
import IndividualComponent from '@/IndividualComponent.js';
|
|
11
|
+
import styles from './chat-event.scss';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @label Chat Event
|
|
15
|
+
* @tag wc-chat-event
|
|
16
|
+
* @rawTag chat-event
|
|
17
|
+
* @summary A line in a conversation for something that happened rather than something said, such as "Alan Kay confirmed the rollback".
|
|
18
|
+
* @overview
|
|
19
|
+
* <p>Goes in <code>wc-chat-thread</code> between <code>wc-chat-message</code>s. It records what
|
|
20
|
+
* happened to the conversation's subject: a person confirmed a draft, a record changed state,
|
|
21
|
+
* someone joined. The content is the sentence; <code>icon</code> sets the glyph before it, and
|
|
22
|
+
* <code>datetime</code> adds the time after it.</p>
|
|
23
|
+
* <p>Use a message for anything someone wrote, and an event for anything the platform recorded.
|
|
24
|
+
* Events are not announced as they arrive; the record they describe is what changed.</p>
|
|
25
|
+
* @tags display, ai
|
|
26
|
+
*
|
|
27
|
+
* @slot - What happened. Bold the name of who did it with `<strong>`.
|
|
28
|
+
*
|
|
29
|
+
* @csspart event - The line.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```html
|
|
33
|
+
* <wc-chat-event icon="verified" datetime="2026-11-08T10:07:00">
|
|
34
|
+
* <strong>Alan Kay</strong> confirmed the rollback · policy NET-04
|
|
35
|
+
* </wc-chat-event>
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
@IndividualComponent
|
|
39
|
+
export class ChatEvent extends LitElement {
|
|
40
|
+
// ── Static ───────────────────────────────────────────────────────────────
|
|
41
|
+
|
|
42
|
+
static styles = [styles];
|
|
43
|
+
|
|
44
|
+
// ── Properties ───────────────────────────────────────────────────────────
|
|
45
|
+
|
|
46
|
+
/** Material Symbols name of the glyph before the text, such as `verified`. */
|
|
47
|
+
@property({ type: String }) icon = '';
|
|
48
|
+
|
|
49
|
+
/** When it happened, as an ISO 8601 date-time; shown as a time after the text. */
|
|
50
|
+
@property({ type: String }) datetime = '';
|
|
51
|
+
|
|
52
|
+
/** Locale for the time; defaults to the nearest `lang`, else the browser's. */
|
|
53
|
+
@property({ type: String }) locale?: string;
|
|
54
|
+
|
|
55
|
+
// ── Private fields ───────────────────────────────────────────────────────
|
|
56
|
+
|
|
57
|
+
private readonly i18n = new I18nController(this);
|
|
58
|
+
|
|
59
|
+
// ── Render ───────────────────────────────────────────────────────────────
|
|
60
|
+
|
|
61
|
+
render() {
|
|
62
|
+
const date = parseDatetime(this.datetime);
|
|
63
|
+
const { locale } = this.i18n;
|
|
64
|
+
return html`<p class="event" part="event">
|
|
65
|
+
${this.icon
|
|
66
|
+
? html`<wc-icon name=${this.icon} aria-hidden="true"></wc-icon>`
|
|
67
|
+
: nothing}
|
|
68
|
+
<span class="text"><slot></slot></span>
|
|
69
|
+
${date
|
|
70
|
+
? html`<time
|
|
71
|
+
class="time"
|
|
72
|
+
datetime=${this.datetime}
|
|
73
|
+
title=${formatAbsoluteTime(date, locale)}
|
|
74
|
+
>${formatClockTime(date, locale)}</time
|
|
75
|
+
>`
|
|
76
|
+
: nothing}
|
|
77
|
+
</p>`;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -24,6 +24,8 @@
|
|
|
24
24
|
min-block-size: 0;
|
|
25
25
|
overflow-y: auto;
|
|
26
26
|
overscroll-behavior: contain;
|
|
27
|
+
// The thread keeps the end in view itself; the browser's scroll anchoring would fight it.
|
|
28
|
+
overflow-anchor: none;
|
|
27
29
|
outline: none;
|
|
28
30
|
|
|
29
31
|
&:focus-visible {
|
|
@@ -39,7 +41,8 @@
|
|
|
39
41
|
padding: var(--chat-thread-padding);
|
|
40
42
|
}
|
|
41
43
|
|
|
42
|
-
::slotted(wc-chat-message)
|
|
44
|
+
::slotted(wc-chat-message),
|
|
45
|
+
::slotted(wc-chat-event) {
|
|
43
46
|
display: block;
|
|
44
47
|
}
|
|
45
48
|
|
|
@@ -31,17 +31,18 @@ function plainText(markdown: string): string {
|
|
|
31
31
|
* @rawTag chat-thread
|
|
32
32
|
* @summary The scrolling log of a conversation: keeps the latest message in view and announces finished answers.
|
|
33
33
|
* @overview
|
|
34
|
-
* <p>Holds <code>wc-chat-message</code>s, oldest first
|
|
34
|
+
* <p>Holds <code>wc-chat-message</code>s, oldest first, with <code>wc-chat-event</code> lines between
|
|
35
|
+
* them for what happened along the way. It fills its container and scrolls; while
|
|
35
36
|
* the person reads the end, new messages and growing answers stay in view. Scrolling up stops that,
|
|
36
37
|
* and a <strong>Jump to latest</strong> button appears.</p>
|
|
37
38
|
* <p>It is a log (<code>role="log"</code>), but not a live region of its own: streaming text would be
|
|
38
|
-
* read word by word. Instead, an assistant answer
|
|
39
|
-
* <code>streaming</code> turns off), as "Assistant: …".</p>
|
|
39
|
+
* read word by word. Instead, an assistant answer or a participant's message is announced once,
|
|
40
|
+
* when it is complete (its <code>streaming</code> turns off), as "Assistant: …".</p>
|
|
40
41
|
* <p>Before the first message it shows the <code>empty</code> slot and <code>suggestions</code>: prompt
|
|
41
42
|
* starters as chips that fire <code>suggestion-select</code>.</p>
|
|
42
43
|
* @tags display, ai
|
|
43
44
|
*
|
|
44
|
-
* @slot - The `wc-chat-message`s.
|
|
45
|
+
* @slot - The `wc-chat-message`s and `wc-chat-event`s.
|
|
45
46
|
* @slot empty - Shown while there are no messages, above the suggestions.
|
|
46
47
|
*
|
|
47
48
|
* @csspart scroller - The scrolling area.
|
|
@@ -102,6 +103,9 @@ export class ChatThread extends LitElement {
|
|
|
102
103
|
/** Set while Jump to latest scrolls smoothly to the end. */
|
|
103
104
|
private _seeking = false;
|
|
104
105
|
|
|
106
|
+
/** The scroll position at the last scroll event, to tell the reader scrolling up from growth. */
|
|
107
|
+
private _lastScrollTop = 0;
|
|
108
|
+
|
|
105
109
|
/** Messages already announced or present from the start, which are not announced. */
|
|
106
110
|
private readonly _settled = new WeakSet<Element>();
|
|
107
111
|
|
|
@@ -164,6 +168,8 @@ export class ChatThread extends LitElement {
|
|
|
164
168
|
const scroller = this._scroller;
|
|
165
169
|
if (!scroller) return;
|
|
166
170
|
scroller.scrollTo({ top: scroller.scrollHeight, behavior });
|
|
171
|
+
// Where the thread put it, so the next scroll event can tell the reader moving up from it.
|
|
172
|
+
if (behavior === 'instant') this._lastScrollTop = scroller.scrollTop;
|
|
167
173
|
}
|
|
168
174
|
|
|
169
175
|
private _onScroll() {
|
|
@@ -172,19 +178,29 @@ export class ChatThread extends LitElement {
|
|
|
172
178
|
const distance =
|
|
173
179
|
scroller.scrollHeight - scroller.scrollTop - scroller.clientHeight;
|
|
174
180
|
const atEnd = distance <= PINNED_SLACK;
|
|
181
|
+
const movedUp = scroller.scrollTop < this._lastScrollTop - 1;
|
|
182
|
+
this._lastScrollTop = scroller.scrollTop;
|
|
175
183
|
// While Jump to latest scrolls smoothly, its own steps are not the reader scrolling up.
|
|
176
184
|
if (this._seeking) {
|
|
177
185
|
if (atEnd) this._seeking = false;
|
|
178
186
|
return;
|
|
179
187
|
}
|
|
180
|
-
|
|
188
|
+
// Only the reader scrolling up lets go of the end. Content growing below the view (a draft
|
|
189
|
+
// card, an answer arriving) leaves the end out of reach for a moment without anyone scrolling,
|
|
190
|
+
// and the resize observer catches up.
|
|
191
|
+
if (atEnd) this._pinned = true;
|
|
192
|
+
else if (movedUp) this._pinned = false;
|
|
181
193
|
}
|
|
182
194
|
|
|
183
195
|
private _onSlotChange(event: Event) {
|
|
184
196
|
const slot = event.target as HTMLSlotElement;
|
|
185
197
|
this._empty = !slot
|
|
186
198
|
.assignedElements({ flatten: true })
|
|
187
|
-
.some(
|
|
199
|
+
.some(
|
|
200
|
+
element =>
|
|
201
|
+
element.localName === 'wc-chat-message' ||
|
|
202
|
+
element.localName === 'wc-chat-event',
|
|
203
|
+
);
|
|
188
204
|
if (this._pinned) this.updateComplete.then(() => this._toBottom('instant'));
|
|
189
205
|
}
|
|
190
206
|
|
package/src/chat-thread/index.ts
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
.card {
|
|
10
|
+
container: draft-card / inline-size;
|
|
10
11
|
overflow: hidden;
|
|
11
12
|
background: var(--color-surface);
|
|
12
13
|
border: 1px solid var(--color-outline-variant);
|
|
@@ -62,6 +63,14 @@
|
|
|
62
63
|
padding: var(--spacing-075, 0.375rem) var(--spacing-200, 1rem);
|
|
63
64
|
}
|
|
64
65
|
|
|
66
|
+
// In a narrow card, such as a thread on a phone, each label sits above its value.
|
|
67
|
+
@container draft-card (inline-size < 26rem) {
|
|
68
|
+
.field {
|
|
69
|
+
grid-template-columns: minmax(0, 1fr);
|
|
70
|
+
gap: 0;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
65
74
|
dt {
|
|
66
75
|
color: var(--color-on-surface-variant);
|
|
67
76
|
}
|
|
@@ -112,10 +121,15 @@ dd {
|
|
|
112
121
|
}
|
|
113
122
|
}
|
|
114
123
|
|
|
124
|
+
// Done is a quiet record of what happened, not an alert: the check carries the color.
|
|
115
125
|
.done {
|
|
116
|
-
color: var(--color-on-
|
|
117
|
-
background: var(--color-
|
|
126
|
+
color: var(--color-on-surface);
|
|
127
|
+
background: var(--color-surface-container-low);
|
|
118
128
|
font-weight: 500;
|
|
129
|
+
|
|
130
|
+
wc-icon {
|
|
131
|
+
--icon-color: var(--color-success);
|
|
132
|
+
}
|
|
119
133
|
}
|
|
120
134
|
|
|
121
135
|
.done-text {
|
|
@@ -128,7 +128,8 @@ export class DropdownButton extends LitElement {
|
|
|
128
128
|
color=${this.color}
|
|
129
129
|
trailing-icon
|
|
130
130
|
?disabled=${this.disabled}
|
|
131
|
-
|
|
131
|
+
aria-haspopup="menu"
|
|
132
|
+
aria-expanded=${String(this._trigger.open)}
|
|
132
133
|
@click=${this._trigger.handleTriggerClick}
|
|
133
134
|
@keydown=${this._trigger.handleTriggerKeyDown}
|
|
134
135
|
>
|
package/src/index.ts
CHANGED
|
@@ -341,8 +341,9 @@ export type {
|
|
|
341
341
|
ChatMessageFrom,
|
|
342
342
|
ChatMessageFeedback,
|
|
343
343
|
ChatMessageFeedbackDetail,
|
|
344
|
+
ChatMessageSuggestionDetail,
|
|
344
345
|
} from './chat-message/index.js';
|
|
345
|
-
export { ChatThread } from './chat-thread/index.js';
|
|
346
|
+
export { ChatThread, ChatEvent } from './chat-thread/index.js';
|
|
346
347
|
export type { ChatThreadSuggestionDetail } from './chat-thread/index.js';
|
|
347
348
|
export { AssistantSteps, AssistantStep } from './assistant-steps/index.js';
|
|
348
349
|
export type { AssistantStepStatus } from './assistant-steps/index.js';
|
package/src/input/BaseField.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import { html, nothing, type TemplateResult } from 'lit';
|
|
1
|
+
import { html, nothing, type PropertyValues, type TemplateResult } from 'lit';
|
|
2
2
|
import { property, state } from 'lit/decorators.js';
|
|
3
3
|
|
|
4
4
|
import { peacockString } from '@/__internal/i18n/strings.js';
|
|
5
5
|
import type { Size } from '@/__internal/utils/size.js';
|
|
6
6
|
import BaseInput from './BaseInput.js';
|
|
7
7
|
|
|
8
|
+
/** Below this width, in pixels, a field's Suggested badge shows just the sparkle. */
|
|
9
|
+
const NARROW_FIELD_WIDTH = 320;
|
|
10
|
+
|
|
8
11
|
/** What a field component passes to `renderField()`. */
|
|
9
12
|
export interface FieldRenderOptions {
|
|
10
13
|
/** Whether the field has a value; outlined fields float their label when it does. */
|
|
@@ -78,6 +81,9 @@ export default abstract class BaseField extends BaseInput {
|
|
|
78
81
|
|
|
79
82
|
@state() protected focused = false;
|
|
80
83
|
|
|
84
|
+
/** The field is too narrow for the Suggested badge's label; it shows just the sparkle. */
|
|
85
|
+
@state() private __narrow = false;
|
|
86
|
+
|
|
81
87
|
// ── Private fields ───────────────────────────────────────────────────────
|
|
82
88
|
|
|
83
89
|
/** Id of the hidden description the inner control points at. */
|
|
@@ -86,6 +92,9 @@ export default abstract class BaseField extends BaseInput {
|
|
|
86
92
|
/** A `tabindex` set on the host, moved to the inner control. */
|
|
87
93
|
protected controlTabIndex?: string;
|
|
88
94
|
|
|
95
|
+
/** Watches the field's width while it holds a suggestion, so the badge can shrink. */
|
|
96
|
+
private __widthObserver?: ResizeObserver;
|
|
97
|
+
|
|
89
98
|
// ── Lifecycle ────────────────────────────────────────────────────────────
|
|
90
99
|
|
|
91
100
|
override connectedCallback() {
|
|
@@ -103,8 +112,36 @@ export default abstract class BaseField extends BaseInput {
|
|
|
103
112
|
}
|
|
104
113
|
}
|
|
105
114
|
|
|
115
|
+
override disconnectedCallback() {
|
|
116
|
+
super.disconnectedCallback();
|
|
117
|
+
this.__widthObserver?.disconnect();
|
|
118
|
+
this.__widthObserver = undefined;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
protected override updated(changed: PropertyValues) {
|
|
122
|
+
super.updated(changed);
|
|
123
|
+
// Only a field showing a suggestion pays for an observer.
|
|
124
|
+
if (this.suggestionVisible && !this.__widthObserver) {
|
|
125
|
+
this.__widthObserver = new ResizeObserver(([entry]) => {
|
|
126
|
+
this.__narrow = entry.contentRect.width < NARROW_FIELD_WIDTH;
|
|
127
|
+
});
|
|
128
|
+
this.__widthObserver.observe(this);
|
|
129
|
+
} else if (!this.suggestionVisible && this.__widthObserver) {
|
|
130
|
+
this.__widthObserver.disconnect();
|
|
131
|
+
this.__widthObserver = undefined;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
106
135
|
// ── Protected ────────────────────────────────────────────────────────────
|
|
107
136
|
|
|
137
|
+
/**
|
|
138
|
+
* Whether the Suggested badge always shows just the sparkle, whatever the width. A textarea
|
|
139
|
+
* sets it: a label beside it would narrow every line of the text.
|
|
140
|
+
*/
|
|
141
|
+
protected get suggestionBadgeIconOnly(): boolean {
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
|
|
108
145
|
/**
|
|
109
146
|
* The error text the field shows: the consumer's `error-text` while `error` is set, else an
|
|
110
147
|
* error the control found itself, else the validation message once it should show.
|
|
@@ -163,7 +200,10 @@ export default abstract class BaseField extends BaseInput {
|
|
|
163
200
|
<slot name="start" slot="field-start"></slot>
|
|
164
201
|
${options.start ?? nothing} ${control}
|
|
165
202
|
<slot name="end" slot="field-end"></slot>
|
|
166
|
-
${this.suggestionBadge({
|
|
203
|
+
${this.suggestionBadge({
|
|
204
|
+
slot: 'field-end',
|
|
205
|
+
iconOnly: this.__narrow || this.suggestionBadgeIconOnly,
|
|
206
|
+
})}
|
|
167
207
|
${this.renderClearButton(options.populated)} ${options.end ?? nothing}
|
|
168
208
|
</wc-field>
|
|
169
209
|
${description
|
package/src/input/BaseInput.ts
CHANGED
|
@@ -224,7 +224,7 @@ export default abstract class BaseInput extends mixinFormAssociated(
|
|
|
224
224
|
* without helper text pass `withReason` so the badge's tooltip carries the reason.
|
|
225
225
|
*/
|
|
226
226
|
protected suggestionBadge(
|
|
227
|
-
options: { slot?: string; withReason?: boolean } = {},
|
|
227
|
+
options: { slot?: string; withReason?: boolean; iconOnly?: boolean } = {},
|
|
228
228
|
) {
|
|
229
229
|
return this.__suggestions.badge(options);
|
|
230
230
|
}
|
package/src/loader.ts
CHANGED
|
@@ -124,6 +124,7 @@ import { TypingIndicator } from '@/typing-indicator/typing-indicator.js';
|
|
|
124
124
|
import { Citation } from '@/citation/citation.js';
|
|
125
125
|
import { ChatMessage } from '@/chat-message/chat-message.js';
|
|
126
126
|
import { ChatThread } from '@/chat-thread/chat-thread.js';
|
|
127
|
+
import { ChatEvent } from '@/chat-thread/chat-event.js';
|
|
127
128
|
import { AssistantSteps } from '@/assistant-steps/assistant-steps.js';
|
|
128
129
|
import { AssistantStep } from '@/assistant-steps/assistant-step.js';
|
|
129
130
|
import { DraftCard } from '@/draft-card/draft-card.js';
|
|
@@ -589,6 +590,9 @@ const loaderConfig: LoaderConfig = {
|
|
|
589
590
|
'wc-chat-thread': {
|
|
590
591
|
CustomElementClass: ChatThread,
|
|
591
592
|
},
|
|
593
|
+
'wc-chat-event': {
|
|
594
|
+
CustomElementClass: ChatEvent,
|
|
595
|
+
},
|
|
592
596
|
'wc-assistant-steps': {
|
|
593
597
|
CustomElementClass: AssistantSteps,
|
|
594
598
|
},
|