@zeyos/zx 5.6.0 → 5.7.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/CHANGELOG.md +188 -0
- package/README.md +73 -7
- package/bin/zx-css.js +328 -0
- package/dist/types/components/account-menu/account-menu.d.ts +4 -2
- package/dist/types/components/activity-list/activity-list.d.ts +14 -8
- package/dist/types/components/agent-thread/ag-ui.d.ts +340 -0
- package/dist/types/components/agent-thread/agent-thread.d.ts +142 -14
- package/dist/types/components/agent-thread/ui-message-stream.d.ts +401 -0
- package/dist/types/components/app-sidebar/app-sidebar.d.ts +14 -8
- package/dist/types/components/breadcrumb/breadcrumb.d.ts +3 -3
- package/dist/types/components/calendar/calendar-model.d.ts +9 -2
- package/dist/types/components/calendar/calendar.d.ts +12 -4
- package/dist/types/components/chart/chart.d.ts +25 -13
- package/dist/types/components/checklist/checklist.d.ts +29 -0
- package/dist/types/components/code-editor/code-editor.d.ts +7 -2
- package/dist/types/components/composer/composer.d.ts +206 -4
- package/dist/types/components/composer/queue.d.ts +76 -0
- package/dist/types/components/copy/copy-button.d.ts +6 -4
- package/dist/types/components/copy/copy-input.d.ts +10 -6
- package/dist/types/components/datebox/date-range-box.d.ts +33 -0
- package/dist/types/components/datebox/placeholder.d.ts +7 -0
- package/dist/types/components/dialog/dialog.d.ts +2 -2
- package/dist/types/components/dock/dock.d.ts +12 -3
- package/dist/types/components/entity-ref/entity-ref.d.ts +5 -3
- package/dist/types/components/field-upload/field-upload.d.ts +3 -2
- package/dist/types/components/file-item/file-item.d.ts +3 -2
- package/dist/types/components/file-list/file-list.d.ts +14 -8
- package/dist/types/components/filter/filter-model.d.ts +31 -1
- package/dist/types/components/filter/filter.d.ts +20 -2
- package/dist/types/components/finder/finder.d.ts +14 -6
- package/dist/types/components/flag/flag.d.ts +99 -0
- package/dist/types/components/grid/grid.d.ts +1 -1
- package/dist/types/components/kanban-view/kanban-view.d.ts +8 -66
- package/dist/types/components/launcher/launcher.d.ts +2 -0
- package/dist/types/components/modal/modal.d.ts +34 -8
- package/dist/types/components/multi-value-editor/multi-value-editor.d.ts +3 -2
- package/dist/types/components/number-field/number-field.d.ts +41 -7
- package/dist/types/components/prompt-starters/prompt-starters.d.ts +107 -0
- package/dist/types/components/prose/prose.d.ts +9 -6
- package/dist/types/components/questionnaire/conditions.d.ts +270 -0
- package/dist/types/components/questionnaire/items.d.ts +52 -30
- package/dist/types/components/questionnaire/questionnaire.d.ts +44 -4
- package/dist/types/components/rating/rating.d.ts +5 -3
- package/dist/types/components/select/country.d.ts +106 -0
- package/dist/types/components/select/field-adapter.d.ts +2 -1
- package/dist/types/components/select/locale.d.ts +102 -0
- package/dist/types/components/select/select.d.ts +41 -2
- package/dist/types/components/sheet/sheet.d.ts +2 -2
- package/dist/types/components/slider/slider.d.ts +1 -0
- package/dist/types/components/sort-control/sort-control.d.ts +7 -3
- package/dist/types/components/source-list/source-list.d.ts +7 -5
- package/dist/types/components/split-view/split-view.d.ts +5 -3
- package/dist/types/components/surface/catalog.d.ts +260 -0
- package/dist/types/components/surface/elicit.d.ts +81 -0
- package/dist/types/components/surface/mcp.d.ts +165 -0
- package/dist/types/components/surface/schema.d.ts +314 -0
- package/dist/types/components/surface/stream.d.ts +118 -0
- package/dist/types/components/surface/surface.d.ts +718 -0
- package/dist/types/components/surface/text.d.ts +277 -0
- package/dist/types/components/surface/validate.d.ts +339 -0
- package/dist/types/components/table/table.d.ts +55 -3
- package/dist/types/components/table/window.d.ts +203 -0
- package/dist/types/components/toolbar/toolbar.d.ts +10 -6
- package/dist/types/components/tooltip/tooltip.d.ts +2 -2
- package/dist/types/components/tree/tree.d.ts +20 -13
- package/dist/types/core/component.d.ts +10 -0
- package/dist/types/core/date.d.ts +8 -1
- package/dist/types/core/dom.d.ts +15 -0
- package/dist/types/core/http.d.ts +10 -0
- package/dist/types/core/i18n.d.ts +38 -0
- package/dist/types/core/messages.d.ts +344 -1
- package/dist/types/core/storage.d.ts +7 -2
- package/dist/types/elements/define.d.ts +21 -46
- package/dist/types/elements/definitions.d.ts +147 -0
- package/dist/types/elements/kit.d.ts +7 -0
- package/dist/types/elements/reflect.d.ts +6 -3
- package/dist/types/index.d.ts +10 -1
- package/dist/types/internal/date-locale.d.ts +7 -0
- package/dist/types/internal/json-patch.d.ts +146 -0
- package/dist/types/locales/de.d.ts +13 -0
- package/dist/types/locales/en.d.ts +2 -0
- package/dist/types/locales/index.d.ts +823 -0
- package/dist/types/zeyos/view.d.ts +8 -1
- package/dist/zx-zeyos.esm.js +16852 -15131
- package/dist/zx-zeyos.esm.min.js +5 -5
- package/dist/zx.core.css +1276 -0
- package/dist/zx.core.min.css +1 -0
- package/dist/zx.css +520 -143
- package/dist/zx.esm.js +40940 -29684
- package/dist/zx.esm.min.js +36 -23
- package/dist/zx.global.js +40940 -29684
- package/dist/zx.global.min.js +36 -23
- package/dist/zx.layered.css +17315 -0
- package/dist/zx.layered.min.css +1 -0
- package/dist/zx.min.css +1 -1
- package/docs/agent-catalog.json +12501 -0
- package/docs/agent-surfaces.md +340 -0
- package/docs/api.json +909 -137
- package/docs/llms.md +1046 -80
- package/docs/llms.txt +30 -9
- package/package.json +29 -6
- package/src/components/account-menu/account-menu.js +6 -3
- package/src/components/activity-item/activity-item.js +2 -1
- package/src/components/activity-list/activity-list.js +16 -10
- package/src/components/agent-thread/ag-ui.js +1439 -0
- package/src/components/agent-thread/agent-thread.js +359 -54
- package/src/components/agent-thread/ui-message-stream.js +1281 -0
- package/src/components/app-sidebar/app-sidebar.js +18 -8
- package/src/components/approval-card/approval-card.js +3 -2
- package/src/components/block-view/block-view.js +7 -6
- package/src/components/breadcrumb/breadcrumb.js +8 -5
- package/src/components/button/button.css +24 -11
- package/src/components/calendar/calendar-model.js +8 -2
- package/src/components/calendar/calendar.js +53 -18
- package/src/components/chart/chart.js +54 -23
- package/src/components/checklist/checklist.css +9 -1
- package/src/components/checklist/checklist.js +59 -3
- package/src/components/checklist/field-adapter.js +2 -11
- package/src/components/code-editor/code-editor.js +45 -8
- package/src/components/code-editor/field-adapter.js +1 -1
- package/src/components/composer/composer.css +80 -1
- package/src/components/composer/composer.js +390 -16
- package/src/components/composer/queue.js +78 -0
- package/src/components/context-menu/context-menu.js +12 -1
- package/src/components/copy/copy-button.js +9 -7
- package/src/components/copy/copy-input.js +10 -6
- package/src/components/date-picker/date-picker.js +2 -1
- package/src/components/date-picker/date-range-picker.js +8 -7
- package/src/components/datebox/date-range-box.js +3 -9
- package/src/components/datebox/datebox.js +18 -21
- package/src/components/datebox/placeholder.js +18 -0
- package/src/components/dialog/dialog.js +4 -5
- package/src/components/dock/dock.js +34 -13
- package/src/components/entity-ref/entity-ref.js +16 -5
- package/src/components/field-upload/field-upload.js +81 -38
- package/src/components/file-item/file-item.js +70 -40
- package/src/components/file-list/file-list.js +15 -9
- package/src/components/filter/filter-model.js +46 -8
- package/src/components/filter/filter.css +3 -3
- package/src/components/filter/filter.js +29 -10
- package/src/components/filter-panel/filter-panel.js +13 -5
- package/src/components/finder/finder.js +50 -26
- package/src/components/flag/flag.css +40 -0
- package/src/components/flag/flag.js +177 -0
- package/src/components/form/form.js +1 -1
- package/src/components/grid/grid.js +22 -8
- package/src/components/kanban-view/kanban-view.js +51 -81
- package/src/components/launcher/launcher.js +17 -2
- package/src/components/list-toolbar/list-toolbar.js +2 -1
- package/src/components/master-panel/master-panel.js +1 -1
- package/src/components/menu-button/menu-button.js +4 -0
- package/src/components/message/message.js +3 -0
- package/src/components/modal/modal.js +62 -8
- package/src/components/multi-value-editor/multi-value-editor.js +10 -9
- package/src/components/navigation-bar/navigation-bar.js +3 -3
- package/src/components/number-field/number-field.js +98 -29
- package/src/components/prompt-starters/prompt-starters.css +91 -0
- package/src/components/prompt-starters/prompt-starters.js +206 -0
- package/src/components/prose/prose.js +14 -10
- package/src/components/questionnaire/conditions.js +666 -0
- package/src/components/questionnaire/items.js +150 -41
- package/src/components/questionnaire/questionnaire.js +126 -32
- package/src/components/rating/rating.js +5 -4
- package/src/components/run-status/run-status.js +2 -2
- package/src/components/select/country.js +136 -0
- package/src/components/select/field-adapter.js +7 -2
- package/src/components/select/locale.js +219 -0
- package/src/components/select/select.css +20 -22
- package/src/components/select/select.js +94 -12
- package/src/components/sheet/sheet-stack.js +10 -1
- package/src/components/sheet/sheet.js +12 -5
- package/src/components/slider/slider.js +7 -2
- package/src/components/sort-control/sort-control.js +15 -5
- package/src/components/source-list/source-list.js +7 -4
- package/src/components/split-view/split-view.js +5 -3
- package/src/components/surface/catalog.js +1334 -0
- package/src/components/surface/elicit.js +107 -0
- package/src/components/surface/mcp.js +243 -0
- package/src/components/surface/schema.js +644 -0
- package/src/components/surface/stream.js +245 -0
- package/src/components/surface/surface.css +308 -0
- package/src/components/surface/surface.js +2291 -0
- package/src/components/surface/text.js +513 -0
- package/src/components/surface/validate.js +2218 -0
- package/src/components/tabbox/tabbox.js +9 -0
- package/src/components/table/table.css +63 -3
- package/src/components/table/table.js +167 -28
- package/src/components/table/window.js +317 -0
- package/src/components/toolbar/toolbar.js +12 -7
- package/src/components/tooltip/tooltip.css +2 -3
- package/src/components/tooltip/tooltip.js +32 -5
- package/src/components/tree/tree.js +53 -23
- package/src/core/component.js +25 -1
- package/src/core/date.js +62 -16
- package/src/core/dom.js +67 -4
- package/src/core/format.js +15 -13
- package/src/core/http.js +29 -20
- package/src/core/i18n.js +83 -10
- package/src/core/icons.js +13 -2
- package/src/core/keyboard.js +79 -8
- package/src/core/messages.js +376 -2
- package/src/core/overlay-host.js +1 -0
- package/src/core/position.js +3 -2
- package/src/core/storage.js +59 -6
- package/src/elements/define.js +178 -130
- package/src/elements/definitions.js +229 -0
- package/src/elements/kit.js +444 -0
- package/src/elements/reflect.js +8 -3
- package/src/index.js +10 -1
- package/src/internal/date-locale.js +11 -0
- package/src/internal/json-patch.js +405 -0
- package/src/locales/de.js +911 -0
- package/src/locales/en.js +2 -0
- package/src/locales/index.js +7 -0
- package/src/zeyos/calendar.js +2 -1
- package/src/zeyos/form.js +2 -1
- package/src/zeyos/launcher.js +7 -6
- package/src/zeyos/module-bar.js +2 -1
- package/src/zeyos/schema.js +37 -23
- package/src/zeyos/select.js +4 -3
- package/src/zeyos/table.js +2 -13
- package/src/zeyos/view.js +57 -17
- package/styles/core.css +11 -0
- package/styles/tokens/semantic.css +1 -0
- package/styles/zeyos.css +2 -0
- package/styles/zx.css +4 -8
- package/styles/zx.layered.css +1 -0
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { INVALID_ATTRIBUTE, serializeAttribute } from './reflect.js';
|
|
2
|
+
|
|
3
|
+
/** @typedef {import('./reflect.js').AttributeType} AttributeType */
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {Object} ElementAttribute
|
|
6
|
+
* @property {AttributeType} [type='string'] Attribute representation.
|
|
7
|
+
* @property {string|null} [option] Component option name; null keeps the value on the host only.
|
|
8
|
+
* @property {string} [property] Host property name; defaults to camel-cased attribute name.
|
|
9
|
+
* @property {unknown} [default] Property value used while the attribute is absent.
|
|
10
|
+
* @property {boolean} [always=false] Pass the default to the component during initial creation.
|
|
11
|
+
* @property {boolean} [rebuild=false] Recreate the component when this value changes.
|
|
12
|
+
* @property {boolean} [reflect=true] Write a value set on the property back to the attribute.
|
|
13
|
+
* @property {boolean} [observed=true] Read the attribute at all; false makes this a property alone.
|
|
14
|
+
* @property {(value: unknown, host: HTMLElement) => unknown} [normalize] Value adapter.
|
|
15
|
+
* @property {(value: unknown, host: HTMLElement) => string|null|typeof INVALID_ATTRIBUTE} [serialize]
|
|
16
|
+
* Property serializer override.
|
|
17
|
+
* @property {(component: InstanceType<typeof import('../core/component.js').Component>, value: any, host: HTMLElement) => void} [set]
|
|
18
|
+
* Live component setter.
|
|
19
|
+
* @property {(component: any, host: HTMLElement) => unknown} [get]
|
|
20
|
+
* Live component getter.
|
|
21
|
+
*/
|
|
22
|
+
/** @typedef {Record<string, AttributeType|ElementAttribute>} ElementAttributeMap */
|
|
23
|
+
/**
|
|
24
|
+
* What a forwarded method does to the host's properties, worked out from its arguments, for a
|
|
25
|
+
* method that changes an option the component has no getter for. Null forwards it and nothing else.
|
|
26
|
+
* @typedef {((args: unknown[]) => Record<string, unknown>|null|undefined)|null} MethodTracker
|
|
27
|
+
*/
|
|
28
|
+
/** @typedef {Record<string, MethodTracker>} ElementMethodMap */
|
|
29
|
+
|
|
30
|
+
/** @param {string} value @returns {string} */
|
|
31
|
+
function camelCase(value) {
|
|
32
|
+
return value.replace(/-([a-z])/g, (_match, letter) => letter.toUpperCase());
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Fills in every field of an attribute map. Normalizing an already normalized map changes nothing.
|
|
37
|
+
* @param {ElementAttributeMap} attrs Attribute name to definition.
|
|
38
|
+
* @returns {Readonly<Record<string, ElementAttribute>>}
|
|
39
|
+
*/
|
|
40
|
+
export function normalizeAttributes(attrs) {
|
|
41
|
+
const normalized = {};
|
|
42
|
+
for (const [attribute, definition] of Object.entries(attrs)) {
|
|
43
|
+
const details = typeof definition === 'string' ? { type: definition } : { ...definition };
|
|
44
|
+
const property = details.property ?? camelCase(attribute);
|
|
45
|
+
normalized[attribute] = Object.freeze({
|
|
46
|
+
type: details.type ?? 'string',
|
|
47
|
+
option: Object.prototype.hasOwnProperty.call(details, 'option') ? details.option : property,
|
|
48
|
+
property,
|
|
49
|
+
default: details.default,
|
|
50
|
+
always: Boolean(details.always),
|
|
51
|
+
rebuild: Boolean(details.rebuild),
|
|
52
|
+
reflect: details.reflect !== false,
|
|
53
|
+
observed: details.observed !== false,
|
|
54
|
+
normalize: details.normalize,
|
|
55
|
+
serialize: details.serialize,
|
|
56
|
+
set: details.set,
|
|
57
|
+
get: details.get,
|
|
58
|
+
attribute
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return Object.freeze(normalized);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** @param {Record<string, ElementAttribute>} value @returns {Readonly<Record<string, ElementAttribute>>} */
|
|
65
|
+
export function attributes(value) {
|
|
66
|
+
return normalizeAttributes(value);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** @param {Partial<ElementAttribute>} [options={}] @returns {ElementAttribute} */
|
|
70
|
+
export function text(options = {}) {
|
|
71
|
+
return { type: 'string', ...options };
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** @param {Partial<ElementAttribute>} [options={}] @returns {ElementAttribute} */
|
|
75
|
+
export function number(options = {}) {
|
|
76
|
+
return { type: 'number', ...options };
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** @param {Partial<ElementAttribute>} [options={}] @returns {ElementAttribute} */
|
|
80
|
+
export function bool(options = {}) {
|
|
81
|
+
return { type: 'boolean', default: false, always: true, ...options };
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** @param {Partial<ElementAttribute>} [options={}] @returns {ElementAttribute} */
|
|
85
|
+
export function json(options = {}) {
|
|
86
|
+
return { type: 'json', ...options };
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* An option that is on by default, or that stays undecided (`default: null`) until it is set.
|
|
91
|
+
* @param {Partial<ElementAttribute>} [options={}]
|
|
92
|
+
* @returns {ElementAttribute}
|
|
93
|
+
*/
|
|
94
|
+
export function flag(options = {}) {
|
|
95
|
+
return { type: 'flag', default: true, ...options };
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Rich data: a JSON attribute is read for static markup, and a value set on the property stays
|
|
100
|
+
* there, never serialized back into the attribute.
|
|
101
|
+
* @param {Partial<ElementAttribute>} [options={}]
|
|
102
|
+
* @returns {ElementAttribute}
|
|
103
|
+
*/
|
|
104
|
+
export function data(options = {}) {
|
|
105
|
+
return { type: 'json', reflect: false, ...options };
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* A value markup cannot express: a function, a node, an adapter. It has no attribute at all.
|
|
110
|
+
* @param {Partial<ElementAttribute>} [options={}]
|
|
111
|
+
* @returns {ElementAttribute}
|
|
112
|
+
*/
|
|
113
|
+
export function prop(options = {}) {
|
|
114
|
+
return { type: 'json', reflect: false, observed: false, ...options };
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Reflects the plain values of an option that also takes a function, an object or a node. Those
|
|
119
|
+
* stay on the property, because their text would mean nothing in an attribute.
|
|
120
|
+
* @param {AttributeType} type Attribute representation.
|
|
121
|
+
* @returns {(value: unknown) => string|null|typeof INVALID_ATTRIBUTE}
|
|
122
|
+
*/
|
|
123
|
+
export function reflectPlain(type) {
|
|
124
|
+
return (value) => (value === null || value === undefined
|
|
125
|
+
|| ['string', 'number', 'boolean'].includes(typeof value)
|
|
126
|
+
? serializeAttribute(value, type)
|
|
127
|
+
: INVALID_ATTRIBUTE);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** @param {unknown} value @returns {unknown} */
|
|
131
|
+
export function normalizeSelectable(value) {
|
|
132
|
+
if (value === '' || value === 'true') return 'single';
|
|
133
|
+
if (value === 'false') return false;
|
|
134
|
+
return value;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** @param {unknown} value @returns {unknown} */
|
|
138
|
+
export function normalizeNumberOrString(value) {
|
|
139
|
+
if (typeof value !== 'string' || value.trim() === '') return value;
|
|
140
|
+
const numeric = Number(value);
|
|
141
|
+
return Number.isFinite(numeric) ? numeric : value;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Declares forwarded methods that need no property bookkeeping.
|
|
146
|
+
* @param {...string} names Method names.
|
|
147
|
+
* @returns {ElementMethodMap}
|
|
148
|
+
*/
|
|
149
|
+
export function forward(...names) {
|
|
150
|
+
return Object.fromEntries(names.map((name) => [name, null]));
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* A tracker for a method whose first argument is the new value of one property.
|
|
155
|
+
* @param {string} property Host property name.
|
|
156
|
+
* @returns {MethodTracker}
|
|
157
|
+
*/
|
|
158
|
+
export function records(property) {
|
|
159
|
+
return ([value]) => ({ [property]: value });
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* A tracker for a method whose first argument is a partial set of options, keyed as the
|
|
164
|
+
* properties are.
|
|
165
|
+
* @param {unknown[]} args Call arguments.
|
|
166
|
+
* @returns {Record<string, unknown>|null}
|
|
167
|
+
*/
|
|
168
|
+
export function recordsPatch([partial]) {
|
|
169
|
+
return partial && typeof partial === 'object' ? /** @type {Record<string, unknown>} */ (partial) : null;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* The calls made on an element before its component exists, oldest first.
|
|
174
|
+
* @returns {{size: number, push: (name: string, args: unknown[]) => void, drain: (run: (name: string, args: unknown[]) => void, ready?: () => boolean) => void}}
|
|
175
|
+
*/
|
|
176
|
+
export function createCallQueue() {
|
|
177
|
+
/** @type {{name: string, args: unknown[]}[]} */
|
|
178
|
+
const calls = [];
|
|
179
|
+
return {
|
|
180
|
+
get size() {
|
|
181
|
+
return calls.length;
|
|
182
|
+
},
|
|
183
|
+
push(name, args) {
|
|
184
|
+
calls.push({ name, args });
|
|
185
|
+
},
|
|
186
|
+
/**
|
|
187
|
+
* Runs the calls in order while `ready` holds. A call that throws stops the run where a
|
|
188
|
+
* sequence of direct calls would have stopped; what follows it stays queued.
|
|
189
|
+
*/
|
|
190
|
+
drain(run, ready = () => true) {
|
|
191
|
+
while (calls.length > 0 && ready()) {
|
|
192
|
+
const { name, args } = /** @type {{name: string, args: unknown[]}} */ (calls.shift());
|
|
193
|
+
run(name, args);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* What a forwarded call returns: the component's answer, with the component itself swapped for
|
|
201
|
+
* the element, so a chain stays on the element.
|
|
202
|
+
* @param {unknown} value Component method result.
|
|
203
|
+
* @param {object} component Backing component.
|
|
204
|
+
* @param {HTMLElement} host Custom element.
|
|
205
|
+
* @returns {unknown}
|
|
206
|
+
*/
|
|
207
|
+
export function forwardedResult(value, component, host) {
|
|
208
|
+
if (value === component) return host;
|
|
209
|
+
if (value && typeof (/** @type {PromiseLike<unknown>} */ (value)).then === 'function') {
|
|
210
|
+
return /** @type {PromiseLike<unknown>} */ (value).then((resolved) => (resolved === component ? host : resolved));
|
|
211
|
+
}
|
|
212
|
+
return value;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Whether a call to a method the DOM also defines is the DOM's. `element.remove()` removes the
|
|
217
|
+
* element and `element.remove(id)` an item; `element.append(node)` adds a child and
|
|
218
|
+
* `element.append(block)` a block.
|
|
219
|
+
* @param {string} name Method name.
|
|
220
|
+
* @param {unknown[]} args Call arguments.
|
|
221
|
+
* @returns {boolean}
|
|
222
|
+
*/
|
|
223
|
+
export function isDomCall(name, args) {
|
|
224
|
+
if (name === 'remove') return args.length === 0;
|
|
225
|
+
if (name !== 'append') return false;
|
|
226
|
+
const [first] = args;
|
|
227
|
+
return args.length !== 1 || first === null || typeof first !== 'object'
|
|
228
|
+
|| typeof (/** @type {{nodeType?: unknown}} */ (first)).nodeType === 'number';
|
|
229
|
+
}
|
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
import { AgentThread } from '../components/agent-thread/agent-thread.js';
|
|
2
|
+
import { ApprovalCard } from '../components/approval-card/approval-card.js';
|
|
3
|
+
import { BlockView } from '../components/block-view/block-view.js';
|
|
4
|
+
import { CardView } from '../components/card-view/card-view.js';
|
|
5
|
+
import { Chart } from '../components/chart/chart.js';
|
|
6
|
+
import { Composer } from '../components/composer/composer.js';
|
|
7
|
+
import { KanbanView } from '../components/kanban-view/kanban-view.js';
|
|
8
|
+
import { RunStatus } from '../components/run-status/run-status.js';
|
|
9
|
+
import { RunTrace } from '../components/run-trace/run-trace.js';
|
|
10
|
+
import { SourceList } from '../components/source-list/source-list.js';
|
|
11
|
+
import { TreeView } from '../components/tree/tree.js';
|
|
12
|
+
import {
|
|
13
|
+
attributes, bool, data, flag, forward, normalizeNumberOrString, normalizeSelectable, number, prop,
|
|
14
|
+
records, recordsPatch, reflectPlain, text
|
|
15
|
+
} from './definitions.js';
|
|
16
|
+
|
|
17
|
+
/** @typedef {import('./definitions.js').ElementAttribute} ElementAttribute */
|
|
18
|
+
|
|
19
|
+
/* Options rebuilt on change: the component has no way to take them in place. */
|
|
20
|
+
|
|
21
|
+
/** @param {Partial<ElementAttribute>} [options={}] @returns {ElementAttribute} */
|
|
22
|
+
const rebuiltText = (options = {}) => text({ rebuild: true, ...options });
|
|
23
|
+
/** @param {number|null} value @returns {ElementAttribute} */
|
|
24
|
+
const rebuiltNumber = (value) => number({ default: value, rebuild: true });
|
|
25
|
+
/** @param {unknown} value @returns {ElementAttribute} */
|
|
26
|
+
const rebuiltData = (value) => data({ default: value, rebuild: true });
|
|
27
|
+
/** @returns {ElementAttribute} */
|
|
28
|
+
const rebuiltBool = () => bool({ rebuild: true });
|
|
29
|
+
/** @returns {ElementAttribute} */
|
|
30
|
+
const rebuiltProp = () => prop({ default: null, rebuild: true });
|
|
31
|
+
/** @returns {ElementAttribute} The `msg` table every message-bearing component takes. */
|
|
32
|
+
const messages = () => rebuiltData(null);
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* A text in markup, or something markup cannot write (a function, a node, a date) on the property.
|
|
36
|
+
* @param {Partial<ElementAttribute>} [options={}]
|
|
37
|
+
* @returns {ElementAttribute}
|
|
38
|
+
*/
|
|
39
|
+
const textOrValue = (options = {}) => text({ serialize: reflectPlain('string'), ...options });
|
|
40
|
+
|
|
41
|
+
/** @param {string} key @returns {(component: any, value: unknown) => void} A setter through `update()`. */
|
|
42
|
+
const updates = (key) => (component, value) => component.update({ [key]: value });
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* A setter through a record view's saved state, which replaces all of it, so the rest is read back.
|
|
46
|
+
* @param {string} key State key.
|
|
47
|
+
* @returns {(component: any, value: unknown) => void}
|
|
48
|
+
*/
|
|
49
|
+
const viewState = (key) => (component, value) => {
|
|
50
|
+
component.setViewState({ ...component.getViewState(), [key]: value }, { silent: true });
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/** @param {any} component @param {Array<{id: string}>|null} chips @returns {void} */
|
|
54
|
+
function setContext(component, chips) {
|
|
55
|
+
for (const chip of component.getContext()) component.removeContext(chip.id);
|
|
56
|
+
for (const chip of chips ?? []) component.addContext(chip);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** @param {any} component @returns {boolean} Whether the card lists an edit. */
|
|
60
|
+
function isEdited(component) {
|
|
61
|
+
const keys = component.getEditedKeys();
|
|
62
|
+
return keys === null || keys.length > 0;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** @param {unknown} value @returns {unknown} `'icon'`, or a boolean from the attribute's text. */
|
|
66
|
+
function normalizeCompact(value) {
|
|
67
|
+
if (value === '' || value === 'true') return true;
|
|
68
|
+
if (value === 'false') return false;
|
|
69
|
+
return value;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const AGENT_THREAD_ATTRS = attributes({
|
|
73
|
+
items: data({ default: [], set: (component, value) => component.setItems(value), get: (component) => component.getItems() }),
|
|
74
|
+
authors: rebuiltData({}),
|
|
75
|
+
me: rebuiltText({ default: 'me' }),
|
|
76
|
+
label: rebuiltText({ default: null }),
|
|
77
|
+
'heading-level': rebuiltNumber(3),
|
|
78
|
+
'empty-state': rebuiltData(null),
|
|
79
|
+
'follow-output': flag({ rebuild: true }),
|
|
80
|
+
scroller: rebuiltProp(),
|
|
81
|
+
'answer-actions': rebuiltData(['copy', 'regenerate', 'branch']),
|
|
82
|
+
icons: rebuiltData({}),
|
|
83
|
+
'user-actions': rebuiltData([]),
|
|
84
|
+
'trace-icons': rebuiltData({}),
|
|
85
|
+
'source-icons': rebuiltData({}),
|
|
86
|
+
'surface-options': rebuiltData({}),
|
|
87
|
+
now: rebuiltProp(),
|
|
88
|
+
'format-time': rebuiltProp(),
|
|
89
|
+
locale: rebuiltText(),
|
|
90
|
+
msg: messages()
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
const COMPOSER_ATTRS = attributes({
|
|
94
|
+
label: text({ default: null, set: updates('label') }),
|
|
95
|
+
placeholder: text({ default: '', set: updates('placeholder') }),
|
|
96
|
+
value: text({ default: '', reflect: false, set: (component, value) => component.setValue(value), get: (component) => component.getValue() }),
|
|
97
|
+
'submit-key': text({ default: 'enter', set: updates('submitKey') }),
|
|
98
|
+
busy: bool({ set: (component, value) => component.setBusy(value), get: (component) => component.isBusy() }),
|
|
99
|
+
disabled: bool({ set: (component, value) => component.setDisabled(value) }),
|
|
100
|
+
attachments: rebuiltBool(),
|
|
101
|
+
accept: rebuiltText({ default: '' }),
|
|
102
|
+
'max-files': rebuiltNumber(10),
|
|
103
|
+
mentions: rebuiltData(null),
|
|
104
|
+
commands: rebuiltData(null),
|
|
105
|
+
context: data({ default: [], set: setContext, get: (component) => component.getContext() }),
|
|
106
|
+
hint: text({ default: '', set: (component, value) => component.setHint(value) }),
|
|
107
|
+
note: text({ default: '', set: (component, value) => component.setNote(value) }),
|
|
108
|
+
'draft-key': rebuiltText({ default: null }),
|
|
109
|
+
'min-rows': rebuiltNumber(1),
|
|
110
|
+
'max-rows': rebuiltNumber(10),
|
|
111
|
+
icons: rebuiltData({}),
|
|
112
|
+
tools: data({ default: [], set: (component, value) => component.setTools(value) }),
|
|
113
|
+
'send-label': text({ default: null, set: updates('sendLabel') }),
|
|
114
|
+
queue: rebuiltBool(),
|
|
115
|
+
'queue-limit': rebuiltNumber(10),
|
|
116
|
+
msg: messages()
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
const BLOCK_VIEW_ATTRS = attributes({
|
|
120
|
+
blocks: data({ default: [], set: (component, value) => component.setBlocks(value), get: (component) => component.getBlocks() }),
|
|
121
|
+
'heading-level': rebuiltNumber(3),
|
|
122
|
+
size: rebuiltText({ default: 'sm' }),
|
|
123
|
+
streaming: bool({
|
|
124
|
+
set: (component, value) => (value ? component.setBlocks(component.getBlocks(), { streaming: true }) : component.end()),
|
|
125
|
+
get: (component) => component.isStreaming()
|
|
126
|
+
}),
|
|
127
|
+
sources: data({ default: null, set: (component, value) => component.setSources(value) }),
|
|
128
|
+
msg: messages()
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
const RUN_TRACE_ATTRS = attributes({
|
|
132
|
+
steps: data({ default: [], set: (component, value) => component.setSteps(value), get: (component) => component.getSteps() }),
|
|
133
|
+
open: bool({ set: (component, value) => (value ? component.expand() : component.collapse()), get: (component) => component.isOpen() }),
|
|
134
|
+
label: text({ default: null, set: (component, value) => component.setLabel(value) }),
|
|
135
|
+
authors: rebuiltData({}),
|
|
136
|
+
'show-arguments': flag({ rebuild: true }),
|
|
137
|
+
'max-result': rebuiltNumber(4000),
|
|
138
|
+
summary: flag({ rebuild: true }),
|
|
139
|
+
'kind-icons': flag({ default: null, rebuild: true }),
|
|
140
|
+
selectable: rebuiltBool(),
|
|
141
|
+
ticking: rebuiltBool(),
|
|
142
|
+
now: rebuiltProp(),
|
|
143
|
+
'format-time': rebuiltProp(),
|
|
144
|
+
icons: rebuiltData({}),
|
|
145
|
+
msg: messages()
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
const APPROVAL_CARD_ATTRS = attributes({
|
|
149
|
+
// Off the attribute, where the browser would show it as a tooltip over the whole card.
|
|
150
|
+
title: text({ default: '', reflect: false, set: updates('title') }),
|
|
151
|
+
description: text({ default: '', set: updates('description') }),
|
|
152
|
+
icon: text({ default: null, set: updates('icon') }),
|
|
153
|
+
tone: text({ default: 'blue', set: updates('tone') }),
|
|
154
|
+
'heading-level': rebuiltNumber(3),
|
|
155
|
+
status: text({ default: 'pending', set: (component, value) => component.setStatus(value), get: (component) => component.getStatus() }),
|
|
156
|
+
details: data({ default: null, set: updates('details') }),
|
|
157
|
+
preview: data({ default: null, set: updates('preview') }),
|
|
158
|
+
fields: data({ default: null, set: updates('fields') }),
|
|
159
|
+
values: data({ default: {}, set: updates('values'), get: (component) => component.getValues() }),
|
|
160
|
+
'confirm-text': text({ default: null, set: updates('confirmText') }),
|
|
161
|
+
reason: text({ default: 'optional', set: updates('reason') }),
|
|
162
|
+
edited: bool({ set: updates('edited'), get: isEdited }),
|
|
163
|
+
'edited-keys': data({ default: null, set: updates('editedKeys'), get: (component) => component.getEditedKeys() }),
|
|
164
|
+
'reject-reason': text({ default: null, set: (component, value) => component.setStatus(component.getStatus(), { reason: value }) }),
|
|
165
|
+
'answered-by': text({ default: null, set: (component, value) => component.setStatus(component.getStatus(), { by: value }) }),
|
|
166
|
+
'answered-at': textOrValue({ default: null, set: (component, value) => component.setStatus(component.getStatus(), { at: value }) }),
|
|
167
|
+
now: rebuiltProp(),
|
|
168
|
+
keys: flag({ rebuild: true }),
|
|
169
|
+
msg: messages()
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
const SOURCE_LIST_ATTRS = attributes({
|
|
173
|
+
sources: data({ default: [], set: (component, value) => component.setSources(value), get: (component) => component.getSources() }),
|
|
174
|
+
label: rebuiltText(),
|
|
175
|
+
layout: rebuiltText({ default: 'chips' }),
|
|
176
|
+
numbered: flag({ rebuild: true }),
|
|
177
|
+
icons: rebuiltData({}),
|
|
178
|
+
msg: messages()
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
const RUN_STATUS_ATTRS = attributes({
|
|
182
|
+
state: text({ default: 'queued', set: updates('state') }),
|
|
183
|
+
summary: text({ default: '', set: updates('summary') }),
|
|
184
|
+
steps: data({ default: null, set: updates('steps') }),
|
|
185
|
+
started: textOrValue({ default: null, set: updates('started') }),
|
|
186
|
+
finished: textOrValue({ default: null, set: updates('finished') }),
|
|
187
|
+
'work-ms': number({ default: null, set: updates('workMs'), get: (component) => component.getState().workMs }),
|
|
188
|
+
'waiting-since': textOrValue({ default: null, set: updates('waitingSince') }),
|
|
189
|
+
tokens: data({ default: null, set: updates('tokens') }),
|
|
190
|
+
'token-budget': number({ default: null, set: updates('tokenBudget') }),
|
|
191
|
+
cost: data({ default: null, set: updates('cost') }),
|
|
192
|
+
model: text({ default: null, set: updates('model') }),
|
|
193
|
+
actions: data({ default: [], set: updates('actions') }),
|
|
194
|
+
ticking: flag({ set: updates('ticking') }),
|
|
195
|
+
compact: text({ default: false, normalize: normalizeCompact, set: updates('compact') }),
|
|
196
|
+
now: rebuiltProp(),
|
|
197
|
+
locale: rebuiltText(),
|
|
198
|
+
msg: messages()
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
const RECORD_VIEW_ATTRS = Object.freeze({
|
|
202
|
+
fields: data({ default: [], set: (component, value) => component.setFields(value), get: (component) => component.getFields() }),
|
|
203
|
+
data: data({ default: [], set: (component, value) => component.setData(value), get: (component) => component.getData() }),
|
|
204
|
+
'record-id': textOrValue({ default: 'ID', rebuild: true }),
|
|
205
|
+
sort: data({ default: null, set: (component, value) => component.setSort(value?.id ?? null, value?.dir, { silent: true }), get: (component) => component.getSort() }),
|
|
206
|
+
'sort-mode': rebuiltText({ default: 'local' }),
|
|
207
|
+
selectable: rebuiltText({ default: false, normalize: normalizeSelectable }),
|
|
208
|
+
'selection-trigger': rebuiltText({ default: 'checkbox' }),
|
|
209
|
+
selection: data({ default: [], set: (component, value) => component.setSelection(value, { silent: true }), get: (component) => component.getSelectionIds() }),
|
|
210
|
+
'field-order': data({ default: [], set: (component, value) => component.setFieldOrder(value, { silent: true }), get: (component) => component.getFieldOrder() }),
|
|
211
|
+
'hidden-fields': data({ default: [], set: viewState('hiddenFields'), get: (component) => component.getHiddenFields() }),
|
|
212
|
+
'field-controls': flag({ rebuild: true, serialize: reflectPlain('flag') }),
|
|
213
|
+
'empty-text': textOrValue({ default: null, rebuild: true })
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
const CARD_VIEW_ATTRS = attributes({
|
|
217
|
+
...RECORD_VIEW_ATTRS,
|
|
218
|
+
'title-field': textOrValue({ default: null, rebuild: true }),
|
|
219
|
+
'subtitle-field': textOrValue({ default: null, rebuild: true }),
|
|
220
|
+
preview: textOrValue({ rebuild: true }),
|
|
221
|
+
'preview-alt': textOrValue({ default: null, rebuild: true }),
|
|
222
|
+
link: rebuiltData(undefined),
|
|
223
|
+
actions: rebuiltData([]),
|
|
224
|
+
'group-by': textOrValue({ default: null, rebuild: true }),
|
|
225
|
+
'group-order': data({ default: [], set: viewState('groupOrder') }),
|
|
226
|
+
'min-card-width': text({ default: '15rem', normalize: normalizeNumberOrString, set: viewState('minCardWidth') }),
|
|
227
|
+
'max-columns': number({ default: null, set: viewState('maxColumns') }),
|
|
228
|
+
variant: text({ default: 'outlined', set: viewState('variant') }),
|
|
229
|
+
'loading-count': rebuiltNumber(6),
|
|
230
|
+
'heading-level': rebuiltNumber(3),
|
|
231
|
+
label: rebuiltText({ default: null }),
|
|
232
|
+
keyboard: rebuiltText({ default: 'tabs' }),
|
|
233
|
+
'collapsible-groups': rebuiltBool(),
|
|
234
|
+
'collapsed-groups': data({ default: [], set: viewState('collapsedGroups'), get: (component) => component.getCollapsedGroups() }),
|
|
235
|
+
'render-group-heading': rebuiltProp()
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
const KANBAN_VIEW_ATTRS = attributes({
|
|
239
|
+
...RECORD_VIEW_ATTRS,
|
|
240
|
+
'column-by': textOrValue({ default: 'status', rebuild: true }),
|
|
241
|
+
columns: data({ default: null, set: (component, value) => component.setColumns(value) }),
|
|
242
|
+
'swimlane-by': textOrValue({ default: null, rebuild: true }),
|
|
243
|
+
swimlanes: data({ default: null, set: (component, value) => component.setSwimlanes(value) }),
|
|
244
|
+
'title-field': textOrValue({ default: null, rebuild: true }),
|
|
245
|
+
'subtitle-field': textOrValue({ default: null, rebuild: true }),
|
|
246
|
+
preview: textOrValue({ default: null, rebuild: true }),
|
|
247
|
+
'preview-alt': textOrValue({ default: null, rebuild: true }),
|
|
248
|
+
link: rebuiltData(null),
|
|
249
|
+
actions: rebuiltData([]),
|
|
250
|
+
'move-mode': rebuiltText({ default: 'local' }),
|
|
251
|
+
'drag-from': rebuiltText({ default: 'card' }),
|
|
252
|
+
'move-handle': rebuiltText({ default: 'keyboard' }),
|
|
253
|
+
'entity-icon': textOrValue({ default: null, rebuild: true }),
|
|
254
|
+
identifier: textOrValue({ default: null, rebuild: true }),
|
|
255
|
+
status: textOrValue({ default: null, rebuild: true }),
|
|
256
|
+
'status-tones': rebuiltData({}),
|
|
257
|
+
priority: textOrValue({ default: null, rebuild: true }),
|
|
258
|
+
'priority-tones': rebuiltData({}),
|
|
259
|
+
progress: textOrValue({ default: null, rebuild: true }),
|
|
260
|
+
'progress-max': rebuiltNumber(100),
|
|
261
|
+
assignees: textOrValue({ default: null, rebuild: true }),
|
|
262
|
+
'max-avatars': rebuiltNumber(3),
|
|
263
|
+
'multi-move': flag({ rebuild: true }),
|
|
264
|
+
'auto-scroll': flag({ rebuild: true }),
|
|
265
|
+
'wip-policy': rebuiltText({ default: 'warn' }),
|
|
266
|
+
rules: rebuiltData([]),
|
|
267
|
+
search: text({ default: '', set: (component, value) => component.setSearch(value, { silent: true }), get: (component) => component.getSearch() }),
|
|
268
|
+
'search-fields': rebuiltData(null),
|
|
269
|
+
filter: prop({ default: null, set: (component, value) => component.setFilter(value) }),
|
|
270
|
+
'search-control': rebuiltBool(),
|
|
271
|
+
history: flag({ rebuild: true }),
|
|
272
|
+
'history-limit': rebuiltNumber(50),
|
|
273
|
+
'history-controls': rebuiltBool(),
|
|
274
|
+
'column-height': rebuiltText({ default: null }),
|
|
275
|
+
'allow-add': bool({ rebuild: true, serialize: reflectPlain('boolean') }),
|
|
276
|
+
'context-menu': bool({ rebuild: true, serialize: reflectPlain('boolean') }),
|
|
277
|
+
'render-card': rebuiltProp(),
|
|
278
|
+
'render-column-header': rebuiltProp(),
|
|
279
|
+
'render-swimlane-header': rebuiltProp(),
|
|
280
|
+
'render-column-empty': rebuiltProp(),
|
|
281
|
+
'render-drag-preview': rebuiltProp(),
|
|
282
|
+
labels: rebuiltData({}),
|
|
283
|
+
'column-order': data({ default: [], set: (component, value) => component.setColumnOrder(value, { silent: true }), get: (component) => component.getColumnOrder() }),
|
|
284
|
+
'swimlane-order': data({ default: [], set: (component, value) => component.setSwimlaneOrder(value, { silent: true }), get: (component) => component.getSwimlaneOrder() }),
|
|
285
|
+
'collapsed-columns': data({ default: [], set: viewState('collapsedColumns'), get: (component) => component.getCollapsedColumns() }),
|
|
286
|
+
'collapsed-swimlanes': data({ default: [], set: viewState('collapsedSwimlanes'), get: (component) => component.getCollapsedSwimlanes() }),
|
|
287
|
+
'show-counts': flag({ rebuild: true }),
|
|
288
|
+
'show-empty-columns': flag({ rebuild: true }),
|
|
289
|
+
variant: rebuiltText({ default: 'outlined' }),
|
|
290
|
+
label: rebuiltText()
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
const TREE_ATTRS = attributes({
|
|
294
|
+
items: data({ default: [], set: (component, value) => component.setItems(value), get: (component) => component.getItems() }),
|
|
295
|
+
'value-key': textOrValue({ default: 'ID', rebuild: true }),
|
|
296
|
+
'label-key': textOrValue({ default: 'name', rebuild: true }),
|
|
297
|
+
'children-key': rebuiltText({ default: 'children' }),
|
|
298
|
+
expanded: rebuiltData([]),
|
|
299
|
+
selection: rebuiltText({ default: 'single', normalize: normalizeSelectable }),
|
|
300
|
+
selected: data({ default: [], set: (component, value) => component.setSelection(value), get: (component) => component.getSelection() }),
|
|
301
|
+
checkboxes: rebuiltBool(),
|
|
302
|
+
checked: data({ default: [], set: (component, value) => component.setChecked(value), get: (component) => component.getChecked() }),
|
|
303
|
+
icons: flag({ rebuild: true }),
|
|
304
|
+
'render-label': rebuiltProp(),
|
|
305
|
+
'row-actions': rebuiltProp(),
|
|
306
|
+
'more-label': rebuiltText({ default: null }),
|
|
307
|
+
load: rebuiltProp(),
|
|
308
|
+
filter: text({ default: '', set: (component, value) => component.setFilter(value) }),
|
|
309
|
+
label: rebuiltText({ default: null }),
|
|
310
|
+
'empty-text': rebuiltText(),
|
|
311
|
+
height: rebuiltText({ default: null, normalize: normalizeNumberOrString }),
|
|
312
|
+
msg: messages()
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
const CHART_ATTRS = attributes({
|
|
316
|
+
adapter: prop({ default: null, set: (component, value) => component.setAdapter(value) }),
|
|
317
|
+
type: text({ default: 'bar', set: (component, value) => component.setType(value) }),
|
|
318
|
+
data: data({ default: { labels: [], datasets: [] }, set: (component, value) => component.setData(value) }),
|
|
319
|
+
'chart-options': data({ default: {}, set: (component, value) => component.update(value) }),
|
|
320
|
+
label: rebuiltText({ default: null }),
|
|
321
|
+
description: rebuiltText({ default: '' }),
|
|
322
|
+
summary: rebuiltText({ default: 'hidden' }),
|
|
323
|
+
// New data ends a load on its own, so the property reads the chart rather than what it was told.
|
|
324
|
+
loading: bool({ set: (component, value) => component.setLoading(value), get: (component) => component.el.dataset.state === 'loading' }),
|
|
325
|
+
'empty-text': rebuiltText(),
|
|
326
|
+
'loading-text': rebuiltText(),
|
|
327
|
+
'error-text': rebuiltText(),
|
|
328
|
+
'aspect-ratio': rebuiltText({ default: '16 / 9' })
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
const RECORD_VIEW_METHODS = Object.freeze({
|
|
332
|
+
...forward(
|
|
333
|
+
'setData', 'addData', 'updateRecord', 'removeRecord', 'setFields', 'mountFieldControls', 'setFieldVisible',
|
|
334
|
+
'toggleField', 'moveField', 'setFieldOrder', 'setSort', 'setSelection', 'clearSelection', 'toggleSelection',
|
|
335
|
+
'setLoading'
|
|
336
|
+
),
|
|
337
|
+
setViewState: recordsPatch
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
const RECORD_VIEW_EVENTS = Object.freeze([
|
|
341
|
+
'recordclick', 'recorddblclick', 'datachange', 'selectionchange', 'sortchange', 'fieldvisibilitychange',
|
|
342
|
+
'fieldorderchange', 'statechange', 'recordaction'
|
|
343
|
+
]);
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* The agent kit and the data views, as `[suffix, Component, wrapper options]`. None of them is a
|
|
347
|
+
* form control, so none is form-associated.
|
|
348
|
+
* @type {ReadonlyArray<[string, typeof import('../core/component.js').Component, import('./define.js').ElementWrapperOptions]>}
|
|
349
|
+
*/
|
|
350
|
+
export const KIT_ELEMENTS = Object.freeze([
|
|
351
|
+
['agent-thread', AgentThread, {
|
|
352
|
+
attrs: AGENT_THREAD_ATTRS,
|
|
353
|
+
methods: forward(
|
|
354
|
+
'setItems', 'upsert', 'patch', 'appendText', 'appendBlock', 'announce', 'remove', 'get', 'getItems',
|
|
355
|
+
'getComponent', 'surface', 'reveal', 'setArtifactState', 'scrollToEnd'
|
|
356
|
+
),
|
|
357
|
+
events: ['action', 'approve', 'edit', 'reject', 'cite', 'artifact', 'reveal', 'open', 'reply']
|
|
358
|
+
}],
|
|
359
|
+
['composer', Composer, {
|
|
360
|
+
attrs: COMPOSER_ATTRS,
|
|
361
|
+
methods: {
|
|
362
|
+
...forward('focus', 'setValue', 'insertText', 'clear', 'setToolPressed', 'addFiles', 'addContext', 'removeContext',
|
|
363
|
+
'getQueue', 'clearQueue', 'removeQueued'),
|
|
364
|
+
setBusy: records('busy'),
|
|
365
|
+
setHint: records('hint'),
|
|
366
|
+
setNote: records('note'),
|
|
367
|
+
setDisabled: records('disabled'),
|
|
368
|
+
setTools: records('tools'),
|
|
369
|
+
update: recordsPatch
|
|
370
|
+
},
|
|
371
|
+
events: ['send', 'stop', 'input', 'attach', 'remove', 'mention', 'command', 'tool', 'historyprevious', 'queue', 'dequeue']
|
|
372
|
+
}],
|
|
373
|
+
['block-view', BlockView, {
|
|
374
|
+
attrs: BLOCK_VIEW_ATTRS,
|
|
375
|
+
methods: {
|
|
376
|
+
...forward('setBlocks', 'append', 'appendText', 'end', 'stop', 'setArtifactState'),
|
|
377
|
+
setSources: records('sources')
|
|
378
|
+
},
|
|
379
|
+
events: ['cite', 'artifact', 'end']
|
|
380
|
+
}],
|
|
381
|
+
['run-trace', RunTrace, {
|
|
382
|
+
attrs: RUN_TRACE_ATTRS,
|
|
383
|
+
methods: { ...forward('setSteps', 'upsert', 'expand', 'collapse', 'reveal'), setLabel: records('label') },
|
|
384
|
+
events: ['toggle', 'reveal', 'select', 'open']
|
|
385
|
+
}],
|
|
386
|
+
['approval-card', ApprovalCard, {
|
|
387
|
+
attrs: APPROVAL_CARD_ATTRS,
|
|
388
|
+
methods: { ...forward('focus', 'handleKey'), update: recordsPatch, setStatus: records('status') },
|
|
389
|
+
events: ['approve', 'edit', 'reject']
|
|
390
|
+
}],
|
|
391
|
+
['source-list', SourceList, {
|
|
392
|
+
attrs: SOURCE_LIST_ATTRS,
|
|
393
|
+
methods: forward('setSources', 'highlight'),
|
|
394
|
+
events: ['select']
|
|
395
|
+
}],
|
|
396
|
+
['run-status', RunStatus, {
|
|
397
|
+
attrs: RUN_STATUS_ATTRS,
|
|
398
|
+
methods: { update: recordsPatch },
|
|
399
|
+
events: ['action']
|
|
400
|
+
}],
|
|
401
|
+
['card-view', CardView, {
|
|
402
|
+
attrs: CARD_VIEW_ATTRS,
|
|
403
|
+
methods: { ...RECORD_VIEW_METHODS, ...forward('setGroupCollapsed') },
|
|
404
|
+
events: [...RECORD_VIEW_EVENTS, 'groupcollapse']
|
|
405
|
+
}],
|
|
406
|
+
['kanban-view', KanbanView, {
|
|
407
|
+
attrs: KANBAN_VIEW_ATTRS,
|
|
408
|
+
methods: {
|
|
409
|
+
...RECORD_VIEW_METHODS,
|
|
410
|
+
...forward(
|
|
411
|
+
'setColumnOrder', 'moveColumn', 'setSwimlaneOrder', 'moveSwimlane', 'setColumnCollapsed', 'toggleColumn',
|
|
412
|
+
'setSwimlaneCollapsed', 'toggleSwimlane', 'moveRecord', 'moveRecords', 'undo', 'redo', 'clearHistory'
|
|
413
|
+
),
|
|
414
|
+
setColumns: records('columns'),
|
|
415
|
+
setSwimlanes: records('swimlanes'),
|
|
416
|
+
setSearch: records('search'),
|
|
417
|
+
setFilter: records('filter')
|
|
418
|
+
},
|
|
419
|
+
events: [...RECORD_VIEW_EVENTS, 'recordmove', 'movereject', 'recordadd', 'searchchange', 'historychange']
|
|
420
|
+
}],
|
|
421
|
+
['tree', TreeView, {
|
|
422
|
+
attrs: TREE_ATTRS,
|
|
423
|
+
methods: {
|
|
424
|
+
...forward(
|
|
425
|
+
'setItems', 'expand', 'collapse', 'toggle', 'expandAll', 'collapseAll', 'reveal', 'select', 'setSelection',
|
|
426
|
+
'clearSelection', 'setChecked', 'check', 'focusNode'
|
|
427
|
+
),
|
|
428
|
+
setFilter: records('filter')
|
|
429
|
+
},
|
|
430
|
+
events: ['select', 'expand', 'collapse', 'activate', 'check', 'error']
|
|
431
|
+
}],
|
|
432
|
+
['chart', Chart, {
|
|
433
|
+
attrs: CHART_ATTRS,
|
|
434
|
+
methods: {
|
|
435
|
+
...forward('setError', 'clearError', 'resize', 'refreshTheme'),
|
|
436
|
+
setData: records('data'),
|
|
437
|
+
setType: records('type'),
|
|
438
|
+
update: records('chartOptions'),
|
|
439
|
+
setAdapter: records('adapter'),
|
|
440
|
+
setLoading: ([loading = true]) => ({ loading })
|
|
441
|
+
},
|
|
442
|
+
events: ['ready', 'update', 'select', 'error']
|
|
443
|
+
}]
|
|
444
|
+
]);
|