@adecore/agents-react 0.22.0 → 0.22.1
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/chat/ui/intelligent-ui/UiBlockFrame.js +3 -3
- package/dist/chat/ui/intelligent-ui/UiFallbackPart.js +1 -1
- package/dist/chat/ui/intelligent-ui/chart-data.d.ts +22 -2
- package/dist/chat/ui/intelligent-ui/chart-data.js +83 -19
- package/dist/chat/ui/intelligent-ui/renderers/chart.d.ts +1 -1
- package/dist/chat/ui/intelligent-ui/renderers/chart.js +99 -35
- package/dist/chat/ui/intelligent-ui/renderers/choices.d.ts +1 -1
- package/dist/chat/ui/intelligent-ui/renderers/choices.js +8 -2
- package/dist/chat/ui/intelligent-ui/renderers/content.js +5 -3
- package/dist/chat/ui/intelligent-ui/renderers/inputs.js +9 -4
- package/dist/chat/ui/intelligent-ui/renderers/links.js +1 -1
- package/dist/chat/ui/intelligent-ui/renderers/text.js +5 -2
- package/dist/chat/ui/intelligent-ui/table-data.js +4 -4
- package/dist/chat/ui/intelligent-ui/use-truncated.d.ts +1 -0
- package/dist/chat/ui/intelligent-ui/use-truncated.js +28 -0
- package/dist/locales/en/agent-chat.json +9 -3
- package/dist/locales/nl/agent-chat.json +9 -3
- package/package.json +9 -4
- package/src/chat/ui/intelligent-ui/UiBlockFrame.tsx +5 -5
- package/src/chat/ui/intelligent-ui/UiFallbackPart.tsx +6 -1
- package/src/chat/ui/intelligent-ui/chart-data.ts +106 -20
- package/src/chat/ui/intelligent-ui/renderers/chart.tsx +237 -72
- package/src/chat/ui/intelligent-ui/renderers/choices.tsx +9 -4
- package/src/chat/ui/intelligent-ui/renderers/content.tsx +31 -15
- package/src/chat/ui/intelligent-ui/renderers/inputs.tsx +16 -5
- package/src/chat/ui/intelligent-ui/renderers/links.tsx +3 -3
- package/src/chat/ui/intelligent-ui/renderers/text.tsx +18 -8
- package/src/chat/ui/intelligent-ui/table-data.ts +4 -4
- package/src/chat/ui/intelligent-ui/use-truncated.ts +33 -0
- package/src/locales/en/agent-chat.json +9 -3
- package/src/locales/nl/agent-chat.json +9 -3
|
@@ -115,11 +115,11 @@ function LinkRow({ target, context, described, children }: { target: UiLinkTarge
|
|
|
115
115
|
return <UiLinkChip target={target} context={context} />;
|
|
116
116
|
}
|
|
117
117
|
return (
|
|
118
|
-
<div className="flex min-w-0 items-baseline gap-2 px-2 text-sm">
|
|
119
|
-
<span className="
|
|
118
|
+
<div className="flex min-w-0 flex-wrap items-baseline gap-x-2 px-2 text-sm">
|
|
119
|
+
<span className="max-w-full min-w-0">
|
|
120
120
|
<UiLinkChip target={target} context={context} />
|
|
121
121
|
</span>
|
|
122
|
-
<span className="min-w-0 text-text-muted">{children}</span>
|
|
122
|
+
<span className="min-w-0 wrap-break-word text-text-muted">{children}</span>
|
|
123
123
|
</div>
|
|
124
124
|
);
|
|
125
125
|
}
|
|
@@ -31,20 +31,27 @@ function isLive(context: UiRenderContext): boolean {
|
|
|
31
31
|
return context.phase === 'streaming' || (context.live !== undefined && context.live !== null && context.live.state !== 'refused');
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
/* A badge longer than this is a sentence, which a tag cannot wrap; it stands under the title as text instead. */
|
|
35
|
+
const BADGE_AS_TAG = 32;
|
|
36
|
+
|
|
34
37
|
/* The head of the block when it is the first node, a subheading without an icon further down. */
|
|
35
38
|
export function SummaryRenderer({ node, children }: UiRendererProps<UiProps<'Summary'>>) {
|
|
36
39
|
const headId = useContext(UiHeadContext);
|
|
37
40
|
const head = headId === undefined || headId === node.id;
|
|
38
41
|
const { tone, badge } = node.props;
|
|
42
|
+
const tag = badge !== undefined && badge !== '' && badge.length <= BADGE_AS_TAG;
|
|
39
43
|
return (
|
|
40
44
|
<div className="flex items-start gap-2 px-2">
|
|
41
45
|
{head && tone !== undefined && <Icon icon={UI_TONE_ICONS[tone]} size={16} className={clsx('mt-0.75 shrink-0', UI_TONE_TEXT[tone])} />}
|
|
42
|
-
<div className="min-w-0 grow
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
{
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
<div className="flex min-w-0 grow flex-wrap items-start gap-x-2 gap-y-1">
|
|
47
|
+
<div className="max-w-full min-w-0 grow basis-48 text-sm font-semibold text-balance wrap-break-word text-text">{children}</div>
|
|
48
|
+
{tag && (
|
|
49
|
+
<Pill shape="tag" tone={tone === undefined ? 'muted' : UI_TONE_PILL[tone]}>
|
|
50
|
+
{badge}
|
|
51
|
+
</Pill>
|
|
52
|
+
)}
|
|
53
|
+
{!tag && badge !== undefined && badge !== '' && <p className="w-full text-xs wrap-anywhere text-text-muted">{badge}</p>}
|
|
54
|
+
</div>
|
|
48
55
|
</div>
|
|
49
56
|
);
|
|
50
57
|
}
|
|
@@ -117,8 +124,11 @@ export function StepRenderer({ node, children, context }: UiRendererProps<UiProp
|
|
|
117
124
|
)}
|
|
118
125
|
</span>
|
|
119
126
|
<span className="sr-only">{t(`blocks.step.${state}`)}</span>
|
|
120
|
-
|
|
121
|
-
|
|
127
|
+
{/* A short detail stays beside the title; one that does not fit beside it takes the line under it. */}
|
|
128
|
+
<span className="flex min-w-0 grow flex-wrap items-baseline justify-between gap-x-2">
|
|
129
|
+
<span className={clsx('max-w-full min-w-0 grow basis-48 wrap-break-word', quiet ? 'text-text-faint' : 'text-text')}>{children}</span>
|
|
130
|
+
{detail !== undefined && detail !== '' && <span className="max-w-full text-xs wrap-anywhere text-text-faint tabular-nums">{detail}</span>}
|
|
131
|
+
</span>
|
|
122
132
|
</li>
|
|
123
133
|
);
|
|
124
134
|
}
|
|
@@ -21,8 +21,8 @@ export type UiTableCell =
|
|
|
21
21
|
|
|
22
22
|
/* Rows shown before a person asks for all of them. */
|
|
23
23
|
export const UI_TABLE_ROWS = 50;
|
|
24
|
-
/*
|
|
25
|
-
const
|
|
24
|
+
/* The furthest a JavaScript Date reaches from the epoch either way, in milliseconds. */
|
|
25
|
+
const DATE_RANGE = 8.64e15;
|
|
26
26
|
const NUMERIC_KINDS: ReadonlySet<UiColumnKind> = new Set(['number', 'bytes', 'duration']);
|
|
27
27
|
|
|
28
28
|
export function isNumericColumn(column: UiTableColumn): boolean {
|
|
@@ -51,7 +51,7 @@ export function uiTableColumns(node: UiViewNode<UiProps<'Table'>>): UiTableColum
|
|
|
51
51
|
const keys: string[] = [];
|
|
52
52
|
for (const row of rows) {
|
|
53
53
|
for (const key of Object.keys(row)) {
|
|
54
|
-
if (!keys.includes(key)
|
|
54
|
+
if (!keys.includes(key)) {
|
|
55
55
|
keys.push(key);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
@@ -92,7 +92,7 @@ export function uiTableCell(value: unknown, column: UiTableColumn): UiTableCell
|
|
|
92
92
|
}
|
|
93
93
|
case 'date': {
|
|
94
94
|
const at = typeof value === 'number' ? value : typeof value === 'string' ? Date.parse(value) : Number.NaN;
|
|
95
|
-
return Number.isFinite(at) ? { kind: 'date', at } : { kind: 'text', text: textOf(value) };
|
|
95
|
+
return Number.isFinite(at) && Math.abs(at) <= DATE_RANGE ? { kind: 'date', at } : { kind: 'text', text: textOf(value) };
|
|
96
96
|
}
|
|
97
97
|
case 'file':
|
|
98
98
|
return typeof value === 'string' ? { kind: 'file', path: value } : { kind: 'text', text: textOf(value) };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useCallback, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
function cut(element: HTMLElement): boolean {
|
|
4
|
+
return element.scrollWidth > element.clientWidth + 1;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
* Whether an element's text is cut short where it stands, for a tooltip or a list of values that shows
|
|
9
|
+
* it whole exactly then. `within` asks the same of every `.truncate` element inside it instead. Measured
|
|
10
|
+
* again when the box resizes or the text changes, since neither moves the other.
|
|
11
|
+
*/
|
|
12
|
+
export function useTruncated<T extends HTMLElement>(within = false): [(element: T | null) => (() => void) | undefined, boolean] {
|
|
13
|
+
const [truncated, setTruncated] = useState(false);
|
|
14
|
+
const measure = useCallback(
|
|
15
|
+
(element: T | null) => {
|
|
16
|
+
if (element === null || typeof ResizeObserver === 'undefined') {
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
const check = () => setTruncated(within ? [...element.querySelectorAll<HTMLElement>('.truncate')].some(cut) : cut(element));
|
|
20
|
+
check();
|
|
21
|
+
const resize = new ResizeObserver(check);
|
|
22
|
+
resize.observe(element);
|
|
23
|
+
const text = new MutationObserver(check);
|
|
24
|
+
text.observe(element, { characterData: true, childList: true, subtree: true });
|
|
25
|
+
return () => {
|
|
26
|
+
resize.disconnect();
|
|
27
|
+
text.disconnect();
|
|
28
|
+
};
|
|
29
|
+
},
|
|
30
|
+
[within]
|
|
31
|
+
);
|
|
32
|
+
return [measure, truncated];
|
|
33
|
+
}
|
|
@@ -527,7 +527,13 @@
|
|
|
527
527
|
"chart": {
|
|
528
528
|
"values": "Values",
|
|
529
529
|
"summary": "{{count}} values, highest {{label}} at {{value}}",
|
|
530
|
-
"summarySeries": "{{count}} categories, highest {{series}} for {{label}} at {{value}}"
|
|
530
|
+
"summarySeries": "{{count}} categories, highest {{series}} for {{label}} at {{value}}",
|
|
531
|
+
"rowsLeftOut": "The first {{shown}} of {{total}} rows are drawn.",
|
|
532
|
+
"seriesLeftOut_one": "{{series}} is not drawn.",
|
|
533
|
+
"seriesLeftOut_other": "{{series}} are not drawn.",
|
|
534
|
+
"sideBySide": "Negative values cannot be stacked, so the series stand side by side.",
|
|
535
|
+
"showValues": "Show all values",
|
|
536
|
+
"hideValues": "Hide values"
|
|
531
537
|
},
|
|
532
538
|
"image": {
|
|
533
539
|
"label": "Image",
|
|
@@ -551,8 +557,8 @@
|
|
|
551
557
|
"answered": "Answered with “{{label}}”",
|
|
552
558
|
"chose": "Chose “{{label}}”",
|
|
553
559
|
"choseOlder": "Chose “{{label}}” on the reply of {{time}}",
|
|
554
|
-
"
|
|
555
|
-
"
|
|
560
|
+
"notes_one": "{{count}} note",
|
|
561
|
+
"notes_other": "{{count}} notes",
|
|
556
562
|
"shownAsText": "Shown as text",
|
|
557
563
|
"unknownComponent": "This version cannot draw {{component}}",
|
|
558
564
|
"renderFailed": "Could not draw this part",
|
|
@@ -527,7 +527,13 @@
|
|
|
527
527
|
"chart": {
|
|
528
528
|
"values": "Waarden",
|
|
529
529
|
"summary": "{{count}} waarden, hoogste {{label}} met {{value}}",
|
|
530
|
-
"summarySeries": "{{count}} categorieën, hoogste {{series}} bij {{label}} met {{value}}"
|
|
530
|
+
"summarySeries": "{{count}} categorieën, hoogste {{series}} bij {{label}} met {{value}}",
|
|
531
|
+
"rowsLeftOut": "De eerste {{shown}} van {{total}} rijen zijn getekend.",
|
|
532
|
+
"seriesLeftOut_one": "{{series}} is niet getekend.",
|
|
533
|
+
"seriesLeftOut_other": "{{series}} zijn niet getekend.",
|
|
534
|
+
"sideBySide": "Negatieve waarden kunnen niet gestapeld worden, dus de reeksen staan naast elkaar.",
|
|
535
|
+
"showValues": "Alle waarden tonen",
|
|
536
|
+
"hideValues": "Waarden verbergen"
|
|
531
537
|
},
|
|
532
538
|
"image": {
|
|
533
539
|
"label": "Afbeelding",
|
|
@@ -551,8 +557,8 @@
|
|
|
551
557
|
"answered": "Beantwoord met “{{label}}”",
|
|
552
558
|
"chose": "Gekozen: “{{label}}”",
|
|
553
559
|
"choseOlder": "Gekozen: “{{label}}”, bij het antwoord van {{time}}",
|
|
554
|
-
"
|
|
555
|
-
"
|
|
560
|
+
"notes_one": "{{count}} opmerking",
|
|
561
|
+
"notes_other": "{{count}} opmerkingen",
|
|
556
562
|
"shownAsText": "Als tekst getoond",
|
|
557
563
|
"unknownComponent": "Deze versie kan {{component}} niet tekenen",
|
|
558
564
|
"renderFailed": "Dit deel kon niet getekend worden",
|