@voltro/ui 0.85.0 → 0.86.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/index.js CHANGED
@@ -1,1408 +1,17 @@
1
- import { Fragment as e, createContext as t, useContext as n, useEffect as r, useId as i, useMemo as a, useRef as o, useState as s } from "react";
2
- import { FORM_KEY_FIELD as c, FORM_REDIRECT_FIELD as l, FormBindingProvider as u, formActionPath as d, formSections as f, isRichTextDocument as p, isSafeHref as m, parseRichText as ee, serializeRichText as h, useAgentChat as g, useConnection as te, useDataCopilot as _, useDataTable as ne, useFormBinding as re, useFormFlash as ie, useFormSkeleton as ae, useQueryField as oe, useQueryFilters as se, useRecord as ce, useTableSkeleton as le, useWorkflowRunState as v } from "@voltro/client";
3
- import { Fragment as y, jsx as b, jsxs as x } from "react/jsx-runtime";
4
- import { useComments as ue } from "@voltro/plugin-comments/web";
5
- //#region src/richText.tsx
6
- var de = (t, n) => {
7
- let r = t.marks ?? [], i = t.text;
8
- return r.includes("code") && (i = /* @__PURE__ */ b("code", { children: i }, n)), r.includes("italic") && (i = /* @__PURE__ */ b("em", { children: i }, n)), r.includes("strike") && (i = /* @__PURE__ */ b("s", { children: i }, n)), r.includes("bold") && (i = /* @__PURE__ */ b("strong", { children: i }, n)), /* @__PURE__ */ b(e, { children: i }, n);
9
- }, S = (t) => t.map((t, n) => {
10
- if (t.type === "link") {
11
- let r = t.content.map((e) => e.text).join("");
12
- return m(t.href) ? /* @__PURE__ */ b("a", {
13
- href: t.href,
14
- rel: "noopener noreferrer nofollow",
15
- children: r
16
- }, n) : /* @__PURE__ */ b(e, { children: r }, n);
17
- }
18
- return de(t, n);
19
- }), fe = (e, t) => {
20
- switch (e.type) {
21
- case "heading": {
22
- let n = [
23
- "h1",
24
- "h2",
25
- "h3"
26
- ][e.level - 1] ?? "h3";
27
- return /* @__PURE__ */ b(n, { children: S(e.content) }, t);
28
- }
29
- case "blockquote": return /* @__PURE__ */ b("blockquote", { children: S(e.content) }, t);
30
- case "bulletList": return /* @__PURE__ */ b("ul", { children: e.content.map((e, t) => /* @__PURE__ */ b("li", { children: S(e.content) }, t)) }, t);
31
- case "orderedList": return /* @__PURE__ */ b("ol", { children: e.content.map((e, t) => /* @__PURE__ */ b("li", { children: S(e.content) }, t)) }, t);
32
- case "codeBlock": return /* @__PURE__ */ b("pre", { children: /* @__PURE__ */ b("code", { children: e.text }) }, t);
33
- default: return /* @__PURE__ */ b("p", { children: S(e.content) }, t);
34
- }
35
- }, pe = (e) => p(e.doc) ? /* @__PURE__ */ b(y, { children: e.doc.content.map((e, t) => fe(e, t)) }) : null, C = (e) => {
36
- let t = i(), [n, a] = s(() => h(e.value)), c = o(e.value);
37
- r(() => {
38
- e.value !== c.current && JSON.stringify(e.value) !== JSON.stringify(c.current) && (c.current = e.value, a(h(e.value)));
39
- }, [e.value]);
40
- let l = [e.description === void 0 ? "" : `${t}-desc`, e.error === void 0 ? "" : `${t}-error`].filter(Boolean).join(" ");
41
- return /* @__PURE__ */ x("div", {
42
- "data-voltro-field": !0,
43
- "data-voltro-rich-text": !0,
44
- children: [
45
- /* @__PURE__ */ x("label", {
46
- htmlFor: t,
47
- children: [e.label, e.required ? /* @__PURE__ */ b("span", {
48
- "aria-hidden": "true",
49
- children: " *"
50
- }) : null]
51
- }),
52
- e.description === void 0 ? null : /* @__PURE__ */ b("p", {
53
- id: `${t}-desc`,
54
- "data-voltro-field-hint": !0,
55
- children: e.description
56
- }),
57
- /* @__PURE__ */ b("textarea", {
58
- id: t,
59
- name: e.name,
60
- value: n,
61
- onChange: (t) => {
62
- a(t.target.value);
63
- let n = ee(t.target.value);
64
- c.current = n, e.onChange(n);
65
- },
66
- onBlur: e.onBlur,
67
- disabled: e.disabled,
68
- required: e.required,
69
- "aria-required": e.required ? !0 : void 0,
70
- "aria-invalid": e.error !== void 0,
71
- "aria-describedby": l === "" ? void 0 : l
72
- }),
73
- e.error === void 0 ? null : /* @__PURE__ */ b("p", {
74
- id: `${t}-error`,
75
- role: "alert",
76
- children: e.error
77
- })
78
- ]
79
- });
80
- }, w = (e) => e == null ? "" : String(e), T = ({ required: e }) => e ? /* @__PURE__ */ b("span", {
81
- "aria-hidden": "true",
82
- children: " *"
83
- }) : null, E = (e) => /* @__PURE__ */ x("div", {
84
- "data-voltro-field": !0,
85
- children: [
86
- /* @__PURE__ */ x("label", {
87
- htmlFor: e.id,
88
- children: [e.label, /* @__PURE__ */ b(T, { required: e.required })]
89
- }),
90
- e.description === void 0 ? null : /* @__PURE__ */ b("p", {
91
- id: `${e.id}-desc`,
92
- "data-voltro-field-hint": !0,
93
- children: e.description
94
- }),
95
- e.children,
96
- e.error === void 0 ? null : /* @__PURE__ */ b("p", {
97
- id: `${e.id}-error`,
98
- role: "alert",
99
- children: e.error
100
- })
101
- ]
102
- }), D = (e, t, n) => {
103
- let r = [t === void 0 ? "" : `${e}-desc`, n === void 0 ? "" : `${e}-error`].filter(Boolean);
104
- return r.length > 0 ? r.join(" ") : void 0;
105
- }, O = (e) => e ? !0 : void 0, k = (e, t) => (n) => {
106
- let r = i();
107
- return /* @__PURE__ */ b(E, {
108
- id: r,
109
- label: n.label,
110
- required: n.required,
111
- description: n.description,
112
- error: n.error,
113
- children: /* @__PURE__ */ b("input", {
114
- id: r,
115
- type: e,
116
- name: n.name,
117
- value: w(n.value),
118
- onChange: (e) => n.onChange(t(e.target.value)),
119
- onBlur: n.onBlur,
120
- disabled: n.disabled,
121
- required: n.required,
122
- "aria-required": O(n.required),
123
- "aria-invalid": n.error !== void 0,
124
- "aria-describedby": D(r, n.description, n.error)
125
- })
126
- });
127
- }, me = (e) => {
128
- let t = i();
129
- return /* @__PURE__ */ b(E, {
130
- id: t,
131
- label: e.label,
132
- required: e.required,
133
- description: e.description,
134
- error: e.error,
135
- children: /* @__PURE__ */ b("textarea", {
136
- id: t,
137
- name: e.name,
138
- value: w(e.value),
139
- onChange: (t) => e.onChange(t.target.value),
140
- disabled: e.disabled,
141
- onBlur: e.onBlur,
142
- required: e.required,
143
- "aria-required": O(e.required),
144
- "aria-invalid": e.error !== void 0,
145
- "aria-describedby": D(t, e.description, e.error)
146
- })
147
- });
148
- }, A = (e) => {
149
- let t = i();
150
- return /* @__PURE__ */ b(E, {
151
- id: t,
152
- label: e.label,
153
- required: e.required,
154
- description: e.description,
155
- error: e.error,
156
- children: /* @__PURE__ */ b("input", {
157
- id: t,
158
- type: "checkbox",
159
- name: e.name,
160
- checked: e.value === !0,
161
- onChange: (t) => e.onChange(t.target.checked),
162
- disabled: e.disabled,
163
- onBlur: e.onBlur,
164
- "aria-required": O(e.required),
165
- "aria-invalid": e.error !== void 0,
166
- "aria-describedby": D(t, e.description, e.error)
167
- })
168
- });
169
- }, he = (e) => {
170
- let t = i();
171
- return /* @__PURE__ */ b(E, {
172
- id: t,
173
- label: e.label,
174
- required: e.required,
175
- description: e.description,
176
- error: e.error,
177
- children: /* @__PURE__ */ x("select", {
178
- id: t,
179
- name: e.name,
180
- value: w(e.value),
181
- onChange: (t) => e.onChange(t.target.value),
182
- disabled: e.disabled,
183
- onBlur: e.onBlur,
184
- required: e.required,
185
- "aria-required": O(e.required),
186
- "aria-invalid": e.error !== void 0,
187
- "aria-describedby": D(t, e.description, e.error),
188
- children: [/* @__PURE__ */ b("option", {
189
- value: "",
190
- children: "—"
191
- }), (e.options ?? []).map((e) => /* @__PURE__ */ b("option", {
192
- value: e.value,
193
- children: e.label
194
- }, e.value))]
195
- })
196
- });
197
- }, ge = (e) => {
198
- let t = i();
199
- return /* @__PURE__ */ x("fieldset", {
200
- "data-voltro-field": !0,
201
- "aria-invalid": e.error !== void 0,
202
- "aria-required": O(e.required),
203
- "aria-describedby": D(t, e.description, e.error),
204
- children: [
205
- /* @__PURE__ */ x("legend", { children: [e.label, /* @__PURE__ */ b(T, { required: e.required })] }),
206
- e.description === void 0 ? null : /* @__PURE__ */ b("p", {
207
- id: `${t}-desc`,
208
- "data-voltro-field-hint": !0,
209
- children: e.description
210
- }),
211
- (e.options ?? []).map((n) => {
212
- let r = `${t}-${n.value}`;
213
- return /* @__PURE__ */ x("span", { children: [/* @__PURE__ */ b("input", {
214
- id: r,
215
- type: "radio",
216
- name: e.name,
217
- value: n.value,
218
- checked: w(e.value) === n.value,
219
- onChange: () => e.onChange(n.value),
220
- disabled: e.disabled,
221
- onBlur: e.onBlur
222
- }), /* @__PURE__ */ b("label", {
223
- htmlFor: r,
224
- children: n.label
225
- })] }, n.value);
226
- }),
227
- e.error === void 0 ? null : /* @__PURE__ */ b("p", {
228
- id: `${t}-error`,
229
- role: "alert",
230
- children: e.error
231
- })
232
- ]
233
- });
234
- }, _e = (e) => {
235
- let t = i(), n = Array.isArray(e.value) ? e.value.map(String) : [];
236
- return /* @__PURE__ */ b(E, {
237
- id: t,
238
- label: e.label,
239
- required: e.required,
240
- description: e.description,
241
- error: e.error,
242
- children: /* @__PURE__ */ b("select", {
243
- id: t,
244
- name: e.name,
245
- multiple: !0,
246
- value: n,
247
- onChange: (t) => e.onChange(Array.from(t.target.selectedOptions, (e) => e.value)),
248
- disabled: e.disabled,
249
- onBlur: e.onBlur,
250
- "aria-required": O(e.required),
251
- "aria-invalid": e.error !== void 0,
252
- "aria-describedby": D(t, e.description, e.error),
253
- children: (e.options ?? []).map((e) => /* @__PURE__ */ b("option", {
254
- value: e.value,
255
- children: e.label
256
- }, e.value))
257
- })
258
- });
259
- }, ve = (e) => /* @__PURE__ */ b("input", {
260
- type: "hidden",
261
- name: e.name,
262
- value: w(e.value),
263
- readOnly: !0
264
- }), ye = (e) => {
265
- let t = i();
266
- return /* @__PURE__ */ b(E, {
267
- id: t,
268
- label: e.label,
269
- required: e.required,
270
- description: e.description,
271
- error: e.error,
272
- children: /* @__PURE__ */ b("input", {
273
- id: t,
274
- type: "file",
275
- name: e.name,
276
- onChange: (t) => e.onChange(t.target.files?.[0] ?? null),
277
- disabled: e.disabled,
278
- onBlur: e.onBlur,
279
- required: e.required,
280
- "aria-required": O(e.required),
281
- "aria-invalid": e.error !== void 0,
282
- "aria-describedby": D(t, e.description, e.error)
283
- })
284
- });
285
- }, j = (e) => /* @__PURE__ */ x("div", {
286
- "data-voltro-field": !0,
287
- "data-voltro-custom": !0,
288
- children: [/* @__PURE__ */ x("label", { children: [e.label, /* @__PURE__ */ b(T, { required: e.required })] }), /* @__PURE__ */ b("p", {
289
- role: "note",
290
- children: `No default widget for "${e.name}" — provide a render-prop via <Field>.`
291
- })]
292
- }), M = {
293
- text: k("text", (e) => e),
294
- number: k("number", (e) => e === "" ? void 0 : Number(e)),
295
- date: k("date", (e) => e),
296
- datetime: k("datetime-local", (e) => e),
297
- daterange: k("text", (e) => e),
298
- file: ye,
299
- "async-select": k("text", (e) => e),
300
- textarea: me,
301
- "rich-text": C,
302
- checkbox: A,
303
- switch: A,
304
- select: he,
305
- radio: ge,
306
- "multi-select": _e,
307
- hidden: ve,
308
- array: j,
309
- reference: j,
310
- custom: j
311
- }, N = t({}), be = (e) => {
312
- let t = n(N), r = a(() => ({
313
- ...t,
314
- ...e.widgets
315
- }), [t, e.widgets]);
316
- return /* @__PURE__ */ b(N.Provider, {
317
- value: r,
318
- children: e.children
319
- });
320
- }, P = (e) => n(N)[e] ?? M[e] ?? M.custom, F = t(null), xe = () => {
321
- let e = n(F);
322
- if (e === null) throw Error("<Field> must be rendered inside <AutoForm>");
323
- return e;
324
- }, Se = (e, t) => {
325
- let n = e.field(t.name);
326
- return {
327
- name: t.name,
328
- label: t.label,
329
- value: n.value,
330
- onChange: n.setValue,
331
- onBlur: n.onBlur,
332
- required: t.required,
333
- disabled: e.pending,
334
- ...n.error === void 0 ? {} : { error: n.error },
335
- ...t.options ? { options: t.options } : {},
336
- ...n.description === void 0 ? {} : { description: n.description },
337
- ...t.reference === void 0 ? {} : { reference: t.reference }
338
- };
339
- }, I = ({ name: e, children: t }) => {
340
- let n = xe(), r = n.fields.find((t) => t.name === e), i = P(r?.widget ?? "custom");
341
- if (r === void 0) return null;
342
- let a = Se(n, r);
343
- return t ? t(a) : /* @__PURE__ */ b(i, { ...a });
344
- };
345
- function Ce(e) {
346
- let t = e.formKey ?? e.mutation, n = ie(t), r = re(e.api, e.mutation, {
347
- ...e.schema ? { schema: e.schema } : {},
348
- ...e.defaults ? { defaults: e.defaults } : {},
349
- ...n === void 0 ? {} : { flash: n }
350
- }), i = (t) => {
351
- t.preventDefault(), r.submit().then((t) => {
352
- t !== void 0 && e.onSuccess && e.onSuccess(t);
353
- });
354
- };
355
- return /* @__PURE__ */ b(u, {
356
- binding: r,
357
- children: /* @__PURE__ */ b(F.Provider, {
358
- value: r,
359
- children: /* @__PURE__ */ x("form", {
360
- ...e.action === !1 ? {} : {
361
- action: d(e.mutation),
362
- method: "post"
363
- },
364
- onSubmit: i,
365
- noValidate: !0,
366
- "data-voltro-autoform": e.mutation,
367
- children: [
368
- e.action === !1 ? null : /* @__PURE__ */ b("input", {
369
- type: "hidden",
370
- name: c,
371
- value: t
372
- }),
373
- e.action === !1 || e.redirectTo === void 0 ? null : /* @__PURE__ */ b("input", {
374
- type: "hidden",
375
- name: l,
376
- value: e.redirectTo
377
- }),
378
- e.children ? e.children(r) : f(r.fields).map((e, t) => e.name === void 0 ? e.fields.map((e) => /* @__PURE__ */ b(I, { name: e.name }, e.name)) : /* @__PURE__ */ x("fieldset", {
379
- "data-voltro-section": e.name,
380
- children: [/* @__PURE__ */ b("legend", { children: e.label ?? e.name }), e.fields.map((e) => /* @__PURE__ */ b(I, { name: e.name }, e.name))]
381
- }, e.name)),
382
- r.formError === void 0 ? null : /* @__PURE__ */ b("p", {
383
- role: "alert",
384
- "data-voltro-form-error": "",
385
- children: r.formError
386
- }),
387
- /* @__PURE__ */ b("button", {
388
- type: "submit",
389
- disabled: r.pending,
390
- children: e.submitLabel ?? "Submit"
391
- })
392
- ]
393
- })
394
- })
395
- });
396
- }
397
- //#endregion
398
- //#region src/strings.tsx
399
- var L = {
400
- filters: {
401
- clear: "Clear",
402
- filtersLabel: "Filters",
403
- anyOption: (e) => `Any ${e}`,
404
- resultCount: (e) => `${e} results`
405
- },
406
- asyncSelect: {
407
- searchPlaceholder: "Search…",
408
- searchLabel: (e) => `Search ${e}`,
409
- loading: "Loading…",
410
- empty: "—"
411
- },
412
- dataTable: { actions: "Actions" },
413
- workflow: {
414
- status: {
415
- running: "Running",
416
- succeeded: "Succeeded",
417
- failed: "Failed",
418
- cancelled: "Cancelled",
419
- suspended: "Waiting"
420
- },
421
- attempt: (e) => `attempt ${e}`,
422
- loading: "Loading…",
423
- empty: "No steps yet."
424
- },
425
- agentChat: {
426
- reasoning: "Reasoning",
427
- messagePlaceholder: "Message…",
428
- messageLabel: "Message",
429
- send: "Send"
430
- },
431
- comments: {
432
- comment: "Comment",
433
- reply: "Reply",
434
- replyPlaceholder: "Reply… (@name to mention)",
435
- replyLabel: "Reply",
436
- newPlaceholder: "Start a discussion… (@name to mention)",
437
- newLabel: "New comment",
438
- resolve: "Resolve",
439
- reopen: "Reopen",
440
- markRead: "Mark read",
441
- edit: "Edit",
442
- edited: "edited",
443
- editLabel: "Edit comment",
444
- save: "Save",
445
- remove: "Delete",
446
- react: "React"
447
- },
448
- appAgent: {
449
- toolsSummary: (e) => `${e} tools · acts as you`,
450
- needsConfirm: "needs confirm"
451
- },
452
- presence: {
453
- moreOverflow: (e) => `${e} more`,
454
- onlineCount: (e) => `${e} online`,
455
- editingOne: (e, t) => `${e} is ${t}`,
456
- editingTwo: (e, t, n) => `${e} and ${t} are ${n}`,
457
- editingMany: (e, t, n) => `${e} and ${t} others are ${n}`
458
- },
459
- recordView: { emptyRelation: (e) => `No ${e}.` },
460
- connectAccount: {
461
- connect: (e) => `Connect ${e}`,
462
- disconnect: "Disconnect",
463
- reconnect: "Reconnect",
464
- connectedAs: (e) => `Connected as ${e}`,
465
- connected: "Connected",
466
- notConnected: "Not connected",
467
- expired: "Expired — reconnect to continue",
468
- revoked: "Access was revoked — reconnect to continue",
469
- errored: "Could not refresh — retrying",
470
- tokenLabel: (e) => `${e} personal access token`,
471
- tokenPlaceholder: "Paste your token…",
472
- save: "Save",
473
- howToGetToken: "How do I get a token?",
474
- loading: "Loading…"
475
- }
476
- }, R = t(L), we = (e, t) => ({
477
- filters: {
478
- ...e.filters,
479
- ...t.filters
480
- },
481
- asyncSelect: {
482
- ...e.asyncSelect,
483
- ...t.asyncSelect
484
- },
485
- dataTable: {
486
- ...e.dataTable,
487
- ...t.dataTable
488
- },
489
- workflow: {
490
- ...e.workflow,
491
- ...t.workflow,
492
- status: {
493
- ...e.workflow.status,
494
- ...t.workflow?.status
495
- }
496
- },
497
- agentChat: {
498
- ...e.agentChat,
499
- ...t.agentChat
500
- },
501
- comments: {
502
- ...e.comments,
503
- ...t.comments
504
- },
505
- appAgent: {
506
- ...e.appAgent,
507
- ...t.appAgent
508
- },
509
- presence: {
510
- ...e.presence,
511
- ...t.presence
512
- },
513
- recordView: {
514
- ...e.recordView,
515
- ...t.recordView
516
- },
517
- connectAccount: {
518
- ...e.connectAccount,
519
- ...t.connectAccount
520
- }
521
- });
522
- function Te(e) {
523
- let t = n(R), r = a(() => we(t, e.strings), [t, e.strings]);
524
- return /* @__PURE__ */ b(R.Provider, {
525
- value: r,
526
- children: e.children
527
- });
528
- }
529
- var z = () => n(R), Ee = (e) => {
530
- let t = oe(e.api, e.source, {
531
- skipUntilTerm: !0,
532
- ...e.labelField === void 0 ? {} : { labelField: e.labelField },
533
- ...e.valueField === void 0 ? {} : { valueField: e.valueField },
534
- ...e.input === void 0 ? {} : { input: e.input },
535
- ...e.debounceMs === void 0 ? {} : { debounceMs: e.debounceMs }
536
- }), n = z().asyncSelect, r = i(), a = e.value === void 0 || e.value === null ? "" : String(e.value), o = a !== "" && t.options.some((e) => e.value === a), s = `${r}-error`;
537
- return /* @__PURE__ */ x("div", {
538
- "data-voltro-field": !0,
539
- "data-voltro-async-select": !0,
540
- children: [
541
- /* @__PURE__ */ x("label", {
542
- htmlFor: r,
543
- children: [e.label, e.required ? " *" : ""]
544
- }),
545
- /* @__PURE__ */ b("input", {
546
- type: "search",
547
- "aria-label": n.searchLabel(e.label),
548
- placeholder: n.searchPlaceholder,
549
- onChange: (e) => t.search(e.target.value),
550
- disabled: e.disabled
551
- }),
552
- /* @__PURE__ */ x("select", {
553
- id: r,
554
- name: e.name,
555
- value: a,
556
- onChange: (t) => e.onChange(t.target.value),
557
- disabled: e.disabled,
558
- required: e.required,
559
- "aria-invalid": e.error !== void 0,
560
- "aria-describedby": e.error === void 0 ? void 0 : s,
561
- "aria-busy": t.loading,
562
- children: [
563
- /* @__PURE__ */ b("option", {
564
- value: "",
565
- children: t.loading ? n.loading : n.empty
566
- }),
567
- a !== "" && !o ? /* @__PURE__ */ b("option", {
568
- value: a,
569
- children: a
570
- }) : null,
571
- t.options.map((e) => /* @__PURE__ */ b("option", {
572
- value: e.value,
573
- children: e.label
574
- }, e.value))
575
- ]
576
- }),
577
- e.error === void 0 ? null : /* @__PURE__ */ b("p", {
578
- id: s,
579
- role: "alert",
580
- children: e.error
581
- })
582
- ]
583
- });
584
- }, De = (e) => e == null ? "" : typeof e == "boolean" ? e ? "✓" : "✗" : String(e), Oe = (e, t) => e ? t === "asc" ? "ascending" : "descending" : "none";
585
- function ke(e) {
586
- let { api: t, query: n, emptyText: r, loadingText: i, loadMoreText: a, renderCell: o, rowActions: s, rowKey: c, ...l } = e, u = z().dataTable, d = ne(t, n, l);
587
- return d.loading ? /* @__PURE__ */ b("p", {
588
- "data-voltro-datatable-loading": !0,
589
- "aria-busy": "true",
590
- children: i ?? "Loading…"
591
- }) : d.rows.length === 0 ? /* @__PURE__ */ b("p", {
592
- "data-voltro-datatable-empty": !0,
593
- children: r ?? "No rows."
594
- }) : /* @__PURE__ */ x(y, { children: [/* @__PURE__ */ x("table", {
595
- "data-voltro-datatable": n,
596
- children: [/* @__PURE__ */ b("thead", { children: /* @__PURE__ */ x("tr", { children: [d.columns.map((e) => {
597
- let t = d.sort?.column === e.name, n = d.sort?.direction ?? "asc";
598
- return /* @__PURE__ */ b("th", {
599
- "aria-sort": Oe(t, n),
600
- scope: "col",
601
- children: /* @__PURE__ */ x("button", {
602
- type: "button",
603
- onClick: () => d.toggleSort(e.name),
604
- children: [e.label, t ? n === "asc" ? " ▲" : " ▼" : ""]
605
- })
606
- }, e.name);
607
- }), s ? /* @__PURE__ */ b("th", {
608
- scope: "col",
609
- children: u.actions
610
- }) : null] }) }), /* @__PURE__ */ b("tbody", { children: d.rows.map((e, t) => /* @__PURE__ */ x("tr", { children: [d.columns.map((t) => /* @__PURE__ */ b("td", {
611
- "data-column": t.name,
612
- children: o ? o(e, t) : De(e[t.name])
613
- }, t.name)), s ? /* @__PURE__ */ b("td", { children: s(e) }) : null] }, c ? c(e) : String(e.id ?? t))) })]
614
- }), d.hasMore ? /* @__PURE__ */ b("button", {
615
- type: "button",
616
- "data-voltro-datatable-more": !0,
617
- onClick: () => d.loadMore(),
618
- children: a ?? "Load more"
619
- }) : null] });
620
- }
621
- //#endregion
622
- //#region src/workflow.tsx
623
- var Ae = (e) => e === "succeeded" ? "✓" : e === "failed" ? "✗" : "…";
624
- function je(e) {
625
- let { api: t, runId: n, loadingText: r, emptyText: i } = e, a = z().workflow, o = v(t, n);
626
- return o.loading ? /* @__PURE__ */ b("p", {
627
- "data-voltro-workflow-loading": !0,
628
- "aria-busy": "true",
629
- children: r ?? a.loading
630
- }) : o.steps.length === 0 ? /* @__PURE__ */ b("p", {
631
- "data-voltro-workflow-empty": !0,
632
- children: i ?? a.empty
633
- }) : /* @__PURE__ */ b("ol", {
634
- "data-voltro-workflow-progress": n,
635
- "aria-busy": o.status === "running" ? "true" : void 0,
636
- children: o.steps.map((e) => {
637
- let t = o.currentStep?.id === e.id;
638
- return /* @__PURE__ */ x("li", {
639
- "data-step": e.stepName,
640
- "data-status": e.status,
641
- "aria-current": t ? "step" : void 0,
642
- children: [
643
- /* @__PURE__ */ b("span", {
644
- "aria-hidden": "true",
645
- children: Ae(e.status)
646
- }),
647
- " ",
648
- e.stepName,
649
- e.attempt > 1 ? /* @__PURE__ */ x("span", {
650
- "data-attempts": !0,
651
- children: [" · ", a.attempt(e.attempt)]
652
- }) : null,
653
- e.durationMs === null ? null : /* @__PURE__ */ x("span", {
654
- "data-duration": !0,
655
- children: [
656
- " · ",
657
- e.durationMs,
658
- "ms"
659
- ]
660
- }),
661
- e.status === "failed" && e.errorMessage ? /* @__PURE__ */ x("span", {
662
- "data-step-error": !0,
663
- children: [" · ", e.errorMessage]
664
- }) : null
665
- ]
666
- }, e.id);
667
- })
668
- });
669
- }
670
- function Me(e) {
671
- let { api: t, runId: n } = e, r = z().workflow, i = v(t, n);
672
- if (i.loading || i.status === void 0) return /* @__PURE__ */ b("span", {
673
- "data-voltro-workflow-badge": !0,
674
- "data-status": "loading",
675
- children: "…"
676
- });
677
- let a = i.status === "suspended" && i.waitingFor ? `${r.status.suspended} · ${i.waitingFor.name}` : r.status[i.status];
678
- return /* @__PURE__ */ x("span", {
679
- "data-voltro-workflow-badge": !0,
680
- "data-status": i.status,
681
- role: "status",
682
- children: [a, i.error ? /* @__PURE__ */ x("span", {
683
- "data-error-detail": !0,
684
- children: [i.error.step ? ` · ${i.error.step}` : "", i.traceId ? ` · voltro logs --trace ${i.traceId}` : ""]
685
- }) : null]
686
- });
687
- }
688
- function Ne(e) {
689
- let { when: t, onApprove: n, onReject: r, approveLabel: i, rejectLabel: a, pending: o } = e;
690
- return t ? /* @__PURE__ */ x("div", {
691
- "data-voltro-approval-controls": !0,
692
- role: "group",
693
- "aria-label": "Approval",
694
- children: [/* @__PURE__ */ b("button", {
695
- type: "button",
696
- "data-approve": !0,
697
- onClick: n,
698
- disabled: o,
699
- children: i ?? "Approve"
700
- }), /* @__PURE__ */ b("button", {
701
- type: "button",
702
- "data-reject": !0,
703
- onClick: r,
704
- disabled: o,
705
- children: a ?? "Reject"
706
- })]
707
- }) : null;
708
- }
709
- //#endregion
710
- //#region src/presence.tsx
711
- var B = (e, t) => {
712
- let n = e.meta?.[t];
713
- return typeof n == "string" ? n : void 0;
714
- }, V = (e) => B(e, "name") ?? B(e, "displayName") ?? e.key, H = (e) => {
715
- let t = e.trim().split(/\s+/).filter(Boolean);
716
- return t.length === 0 ? "?" : t.length === 1 ? t[0].slice(0, 2).toUpperCase() : (t[0][0] + t[t.length - 1][0]).toUpperCase();
717
- };
718
- function Pe(e) {
719
- let { members: t, max: n = 5, nameOf: r = V, renderAvatar: i } = e, a = z().presence, o = t.slice(0, n), s = t.length - o.length;
720
- return /* @__PURE__ */ x("div", {
721
- "data-voltro-presence-avatars": !0,
722
- role: "group",
723
- "aria-label": a.onlineCount(t.length),
724
- children: [o.map((e) => {
725
- let t = r(e);
726
- return i ? /* @__PURE__ */ b("span", { children: i(e, t) }, e.key) : /* @__PURE__ */ b("span", {
727
- "data-avatar": !0,
728
- title: t,
729
- "aria-label": t,
730
- children: H(t)
731
- }, e.key);
732
- }), s > 0 ? /* @__PURE__ */ x("span", {
733
- "data-avatar-overflow": !0,
734
- "aria-label": a.moreOverflow(s),
735
- children: ["+", s]
736
- }) : null]
737
- });
738
- }
739
- var U = (e, t, n = L.presence) => e.length === 0 ? "" : e.length === 1 ? n.editingOne(e[0], t) : e.length === 2 ? n.editingTwo(e[0], e[1], t) : n.editingMany(e[0], e.length - 1, t);
740
- function Fe(e) {
741
- let { members: t, selfKey: n, field: r, verb: i = "editing", nameOf: a = V } = e, o = z().presence, s = t.filter((e) => !(n !== void 0 && e.key === n || r !== void 0 && B(e, "field") !== r));
742
- return s.length === 0 ? null : /* @__PURE__ */ b("span", {
743
- "data-voltro-editing-indicator": !0,
744
- "data-field": r,
745
- role: "status",
746
- children: U(s.map(a), i, o)
747
- });
748
- }
749
- //#endregion
750
- //#region src/agentChat.tsx
751
- var W = (e) => typeof e.text == "string" ? e.text : "";
752
- function Ie({ text: e }) {
753
- let t = z().agentChat;
754
- return /* @__PURE__ */ x("details", {
755
- "data-part": "reasoning",
756
- children: [/* @__PURE__ */ b("summary", { children: t.reasoning }), /* @__PURE__ */ b("span", { children: e })]
757
- });
758
- }
759
- function G({ part: e }) {
760
- switch (e.type) {
761
- case "text": return /* @__PURE__ */ b("span", {
762
- "data-part": "text",
763
- children: W(e)
764
- });
765
- case "reasoning": return /* @__PURE__ */ b(Ie, { text: W(e) });
766
- case "tool": {
767
- let t = e;
768
- return /* @__PURE__ */ x("span", {
769
- "data-part": "tool",
770
- "data-tool": t.toolName,
771
- "data-state": t.state,
772
- children: ["🔧 ", t.toolName]
773
- });
774
- }
775
- case "source": {
776
- let t = e;
777
- return t.url ? /* @__PURE__ */ b("a", {
778
- "data-part": "source",
779
- href: t.url,
780
- rel: "noreferrer",
781
- children: t.title ?? t.url
782
- }) : /* @__PURE__ */ b("span", {
783
- "data-part": "source",
784
- children: t.title ?? t.id ?? "source"
785
- });
786
- }
787
- case "file": {
788
- let t = e;
789
- return t.mediaType.startsWith("image/") ? /* @__PURE__ */ b("img", {
790
- "data-part": "file",
791
- alt: "",
792
- src: `data:${t.mediaType};base64,${t.data}`
793
- }) : /* @__PURE__ */ x("span", {
794
- "data-part": "file",
795
- "data-media": t.mediaType,
796
- children: ["📎 ", t.mediaType]
797
- });
798
- }
799
- default: return /* @__PURE__ */ b("span", {
800
- "data-part": e.type,
801
- children: JSON.stringify(e)
802
- });
803
- }
804
- }
805
- function K({ message: e }) {
806
- let t = e.parts ?? [];
807
- return /* @__PURE__ */ x("div", {
808
- "data-voltro-agent-message": !0,
809
- "data-role": e.role,
810
- "data-streaming": e.streaming ? "true" : void 0,
811
- "aria-busy": e.streaming ? "true" : void 0,
812
- children: [t.length > 0 ? t.map((e, t) => /* @__PURE__ */ b(G, { part: e }, t)) : /* @__PURE__ */ b("span", {
813
- "data-part": "text",
814
- children: e.content
815
- }), e.streaming ? /* @__PURE__ */ b("span", {
816
- "data-cursor": !0,
817
- "aria-hidden": "true",
818
- children: "▍"
819
- }) : null]
820
- });
821
- }
822
- function q(e) {
823
- let { api: t, agent: n, threadId: r, placeholder: i, sendLabel: a, emptyText: o } = e, c = z().agentChat, l = g(t, n, { threadId: r }), [u, d] = s(""), f = () => {
824
- let e = u.trim();
825
- e.length === 0 || l.sending || (d(""), l.send(e));
826
- };
827
- return /* @__PURE__ */ x("div", {
828
- "data-voltro-agent-chat": n,
829
- children: [/* @__PURE__ */ b("div", {
830
- "data-messages": !0,
831
- role: "log",
832
- "aria-live": "polite",
833
- "aria-busy": l.streaming ? "true" : void 0,
834
- children: l.messages.length === 0 && !l.loading ? /* @__PURE__ */ b("p", {
835
- "data-empty": !0,
836
- children: o ?? "No messages yet."
837
- }) : l.messages.map((e) => /* @__PURE__ */ b(K, { message: e }, e.id))
838
- }), /* @__PURE__ */ x("form", {
839
- "data-composer": !0,
840
- onSubmit: (e) => {
841
- e.preventDefault(), f();
842
- },
843
- children: [/* @__PURE__ */ b("input", {
844
- value: u,
845
- onChange: (e) => d(e.target.value),
846
- placeholder: i ?? c.messagePlaceholder,
847
- "aria-label": c.messageLabel,
848
- disabled: l.sending
849
- }), /* @__PURE__ */ b("button", {
850
- type: "submit",
851
- disabled: l.sending || u.trim().length === 0,
852
- children: a ?? c.send
853
- })]
854
- })]
855
- });
856
- }
857
- function Le(e) {
858
- let t = g(e.api, e.agent, { threadId: e.threadId });
859
- return e.children(t);
860
- }
861
- //#endregion
862
- //#region src/appAgent.tsx
863
- function Re(e) {
864
- let { tools: t, showTools: n, ...r } = e, i = z().appAgent, a = (n ?? (t !== void 0 && t.length > 0)) && t && t.length > 0;
865
- return /* @__PURE__ */ x("div", {
866
- "data-voltro-app-agent": r.agent,
867
- children: [a ? /* @__PURE__ */ x("details", {
868
- "data-agent-tools": !0,
869
- children: [/* @__PURE__ */ b("summary", { children: i.toolsSummary(t.length) }), /* @__PURE__ */ b("ul", { children: t.map((e) => /* @__PURE__ */ x("li", {
870
- "data-tool": e.name,
871
- "data-write": e.write ? "true" : void 0,
872
- children: [
873
- /* @__PURE__ */ b("code", { children: e.name }),
874
- e.confirm ? /* @__PURE__ */ x("span", {
875
- "data-confirm": !0,
876
- children: [" · ", i.needsConfirm]
877
- }) : null,
878
- e.description ? /* @__PURE__ */ x("span", {
879
- "data-desc": !0,
880
- children: [" — ", e.description]
881
- }) : null
882
- ]
883
- }, e.name)) })]
884
- }) : null, /* @__PURE__ */ b(q, { ...r })]
885
- });
886
- }
887
- //#endregion
888
- //#region src/dataCopilot.tsx
889
- var ze = (e) => e == null ? "" : typeof e == "boolean" ? e ? "✓" : "✗" : typeof e == "object" ? JSON.stringify(e) : String(e), Be = (e) => {
890
- let t = /* @__PURE__ */ new Set(), n = [];
891
- for (let r of e) for (let e of Object.keys(r)) t.has(e) || (t.add(e), n.push(e));
892
- return n;
893
- };
894
- function J(e) {
895
- let { answer: t, emptyText: n } = e;
896
- if (t === void 0) return null;
897
- if (!t.ok) return /* @__PURE__ */ b("p", {
898
- "data-voltro-data-copilot-refused": !0,
899
- role: "status",
900
- children: t.reason
901
- });
902
- if (t.rows.length === 0) return /* @__PURE__ */ b("p", {
903
- "data-voltro-data-copilot-empty": !0,
904
- children: n ?? "No rows."
905
- });
906
- let r = Be(t.rows);
907
- return /* @__PURE__ */ x("table", {
908
- "data-voltro-data-copilot-results": !0,
909
- children: [/* @__PURE__ */ b("thead", { children: /* @__PURE__ */ b("tr", { children: r.map((e) => /* @__PURE__ */ b("th", {
910
- scope: "col",
911
- children: e
912
- }, e)) }) }), /* @__PURE__ */ b("tbody", { children: t.rows.map((e, t) => /* @__PURE__ */ b("tr", { children: r.map((t) => /* @__PURE__ */ b("td", {
913
- "data-column": t,
914
- children: ze(e[t])
915
- }, t)) }, String(e.id ?? t))) })]
916
- });
917
- }
918
- function Ve(e) {
919
- let { api: t, action: n, placeholder: r, askLabel: i, emptyText: a } = e, o = _(t, n), [c, l] = s(""), u = () => {
920
- let e = c.trim();
921
- e.length === 0 || o.pending || o.ask(e);
922
- };
923
- return /* @__PURE__ */ x("div", {
924
- "data-voltro-data-copilot": n,
925
- children: [/* @__PURE__ */ x("form", {
926
- "data-composer": !0,
927
- onSubmit: (e) => {
928
- e.preventDefault(), u();
929
- },
930
- children: [/* @__PURE__ */ b("input", {
931
- value: c,
932
- onChange: (e) => l(e.target.value),
933
- placeholder: r ?? "Ask about your data…",
934
- "aria-label": "Ask about your data",
935
- disabled: o.pending
936
- }), /* @__PURE__ */ b("button", {
937
- type: "submit",
938
- disabled: o.pending || c.trim().length === 0,
939
- children: i ?? "Ask"
940
- })]
941
- }), /* @__PURE__ */ b("div", {
942
- "data-answer": !0,
943
- "aria-live": "polite",
944
- "aria-busy": o.pending ? "true" : void 0,
945
- children: o.error === void 0 ? /* @__PURE__ */ b(J, {
946
- answer: o.answer,
947
- ...a === void 0 ? {} : { emptyText: a }
948
- }) : /* @__PURE__ */ b("p", {
949
- "data-voltro-data-copilot-error": !0,
950
- role: "alert",
951
- children: o.error instanceof Error ? o.error.message : String(o.error)
952
- })
953
- })]
954
- });
955
- }
956
- function He(e) {
957
- let t = _(e.api, e.action);
958
- return e.children(t);
959
- }
960
- //#endregion
961
- //#region src/skeleton.tsx
962
- var Y = ({ w: e }) => /* @__PURE__ */ b("span", {
963
- "data-skeleton-bar": !0,
964
- style: {
965
- display: "inline-block",
966
- width: e ?? "100%",
967
- height: "1em",
968
- borderRadius: 4
969
- },
970
- "aria-hidden": "true"
971
- });
972
- function Ue(e) {
973
- let t = ae(e.api, e.mutation), n = t.length > 0 ? t.length : e.fallbackFields ?? 3, r = t.length > 0 ? f(t) : [{
974
- name: void 0,
975
- label: void 0,
976
- fields: Array.from({ length: n }, (e, t) => ({ name: `f${t}` }))
977
- }];
978
- return /* @__PURE__ */ b("div", {
979
- "data-voltro-form-skeleton": e.mutation,
980
- "aria-busy": "true",
981
- "aria-hidden": "true",
982
- children: r.map((e, t) => /* @__PURE__ */ x("div", {
983
- ...e.name === void 0 ? {} : { "data-skeleton-section": e.name },
984
- children: [e.name !== void 0 && /* @__PURE__ */ b("div", {
985
- "data-skeleton-section-title": !0,
986
- children: /* @__PURE__ */ b(Y, { w: "40%" })
987
- }), e.fields.map((e) => /* @__PURE__ */ x("div", {
988
- "data-skeleton-field": !0,
989
- children: [/* @__PURE__ */ b(Y, { w: "30%" }), /* @__PURE__ */ b(Y, {})]
990
- }, e.name))]
991
- }, e.name ?? `_${t}`))
992
- });
993
- }
994
- function We(e) {
995
- let t = le(e.api, e.query), n = t.length > 0 ? t.length : e.fallbackColumns ?? 4, r = t.length > 0 ? t.map((e) => e.name) : Array.from({ length: n }, (e, t) => `c${t}`), i = e.rows ?? 5;
996
- return /* @__PURE__ */ x("table", {
997
- "data-voltro-table-skeleton": e.query,
998
- "aria-busy": "true",
999
- "aria-hidden": "true",
1000
- children: [/* @__PURE__ */ b("thead", { children: /* @__PURE__ */ b("tr", { children: r.map((e) => /* @__PURE__ */ b("th", {
1001
- scope: "col",
1002
- children: /* @__PURE__ */ b(Y, { w: "60%" })
1003
- }, e)) }) }), /* @__PURE__ */ b("tbody", { children: Array.from({ length: i }, (e, t) => /* @__PURE__ */ b("tr", {
1004
- "data-skeleton-row": !0,
1005
- children: r.map((e) => /* @__PURE__ */ b("td", { children: /* @__PURE__ */ b(Y, {}) }, e))
1006
- }, t)) })]
1007
- });
1008
- }
1009
- //#endregion
1010
- //#region src/filters.tsx
1011
- var X = (e) => e == null ? "" : String(e);
1012
- function Ge(e) {
1013
- let { filter: t, value: n, onChange: r } = e, i = z().filters, a = {
1014
- "data-filter": t.name,
1015
- "aria-label": t.label
1016
- };
1017
- switch (t.kind) {
1018
- case "select": return /* @__PURE__ */ x("select", {
1019
- ...a,
1020
- value: X(n),
1021
- onChange: (e) => r(e.target.value || void 0),
1022
- children: [/* @__PURE__ */ b("option", {
1023
- value: "",
1024
- children: i.anyOption(t.label)
1025
- }), (t.options ?? []).map((e) => /* @__PURE__ */ b("option", {
1026
- value: e.value,
1027
- children: e.label
1028
- }, e.value))]
1029
- });
1030
- case "multi-select": return /* @__PURE__ */ b("select", {
1031
- ...a,
1032
- multiple: !0,
1033
- value: Array.isArray(n) ? n : [],
1034
- onChange: (e) => r(Array.from(e.target.selectedOptions, (e) => e.value)),
1035
- children: (t.options ?? []).map((e) => /* @__PURE__ */ b("option", {
1036
- value: e.value,
1037
- children: e.label
1038
- }, e.value))
1039
- });
1040
- case "boolean": return /* @__PURE__ */ b("input", {
1041
- ...a,
1042
- type: "checkbox",
1043
- checked: n === !0,
1044
- onChange: (e) => r(e.target.checked ? !0 : void 0)
1045
- });
1046
- case "number-range":
1047
- case "date-range": {
1048
- let e = t.kind === "number-range" ? "number" : "date", i = n ?? {};
1049
- return /* @__PURE__ */ x("span", {
1050
- "data-filter": t.name,
1051
- "data-range": t.kind,
1052
- children: [/* @__PURE__ */ b("input", {
1053
- "aria-label": `${t.label} from`,
1054
- type: e,
1055
- value: X(i.gte),
1056
- onChange: (e) => r({
1057
- ...i,
1058
- gte: e.target.value || void 0
1059
- })
1060
- }), /* @__PURE__ */ b("input", {
1061
- "aria-label": `${t.label} to`,
1062
- type: e,
1063
- value: X(i.lte),
1064
- onChange: (e) => r({
1065
- ...i,
1066
- lte: e.target.value || void 0
1067
- })
1068
- })]
1069
- });
1070
- }
1071
- default: return /* @__PURE__ */ b("input", {
1072
- ...a,
1073
- type: "text",
1074
- value: X(n),
1075
- onChange: (e) => r(e.target.value || void 0)
1076
- });
1077
- }
1078
- }
1079
- function Ke(e) {
1080
- let t = se(e.api, e.query, e.initial ? { initial: e.initial } : {}), n = z().filters;
1081
- return /* @__PURE__ */ x("div", {
1082
- "data-voltro-query-filters": e.query,
1083
- children: [/* @__PURE__ */ x("div", {
1084
- "data-filter-controls": !0,
1085
- role: "group",
1086
- "aria-label": n.filtersLabel,
1087
- children: [
1088
- t.filters.map((e) => /* @__PURE__ */ x("label", {
1089
- "data-filter-label": !0,
1090
- children: [/* @__PURE__ */ b("span", { children: e.label }), /* @__PURE__ */ b(Ge, {
1091
- filter: e,
1092
- value: t.values[e.name],
1093
- onChange: (n) => t.setFilter(e.name, n)
1094
- })]
1095
- }, e.name)),
1096
- /* @__PURE__ */ b("button", {
1097
- type: "button",
1098
- "data-filter-clear": !0,
1099
- onClick: () => t.clear(),
1100
- children: n.clear
1101
- }),
1102
- e.showCount ?? !0 ? /* @__PURE__ */ b("span", {
1103
- "data-filter-count": !0,
1104
- children: n.resultCount(t.count ?? "…")
1105
- }) : null
1106
- ]
1107
- }), e.children ? e.children(t) : null]
1108
- });
1109
- }
1110
- //#endregion
1111
- //#region src/recordView.tsx
1112
- var Z = (e) => e.replace(/[_-]+/g, " ").replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/\s+/g, " ").trim().replace(/^./, (e) => e.toUpperCase()), Q = (e) => Array.isArray(e) && e.every((e) => typeof e == "object" && !!e), qe = (e) => e == null ? "—" : typeof e == "boolean" ? e ? "✓" : "✗" : String(e);
1113
- function Je({ name: e, items: t }) {
1114
- let n = z().recordView;
1115
- if (t.length === 0) return /* @__PURE__ */ b("p", {
1116
- "data-relation": e,
1117
- "data-empty": !0,
1118
- children: n.emptyRelation(Z(e).toLowerCase())
1119
- });
1120
- let r = Object.keys(t[0]);
1121
- return /* @__PURE__ */ x("table", {
1122
- "data-relation": e,
1123
- children: [/* @__PURE__ */ b("thead", { children: /* @__PURE__ */ b("tr", { children: r.map((e) => /* @__PURE__ */ b("th", {
1124
- scope: "col",
1125
- children: Z(e)
1126
- }, e)) }) }), /* @__PURE__ */ b("tbody", { children: t.map((e, t) => /* @__PURE__ */ b("tr", { children: r.map((t) => /* @__PURE__ */ b("td", { children: qe(e[t]) }, t)) }, String(e.id ?? t))) })]
1127
- });
1128
- }
1129
- function Ye(e) {
1130
- let { api: t, query: n, input: r, fields: i, renderField: a, renderRelation: o, loadingText: s, emptyText: c } = e, { record: l, loading: u } = ce(t, n, r ?? {});
1131
- if (u) return /* @__PURE__ */ b("p", {
1132
- "data-voltro-record-loading": !0,
1133
- "aria-busy": "true",
1134
- children: s ?? "Loading…"
1135
- });
1136
- if (l == null) return /* @__PURE__ */ b("p", {
1137
- "data-voltro-record-empty": !0,
1138
- children: c ?? "Not found."
1139
- });
1140
- let d = Object.entries(l), f = d.filter(([e, t]) => !Q(t) && (i === void 0 || i.includes(e))), p = d.filter(([, e]) => Q(e)), m = i === void 0 ? f : i.map((e) => [e, l[e]]).filter(([, e]) => !Q(e));
1141
- return /* @__PURE__ */ x("div", {
1142
- "data-voltro-record-view": n,
1143
- children: [/* @__PURE__ */ b("dl", {
1144
- "data-record-fields": !0,
1145
- children: m.map(([e, t]) => /* @__PURE__ */ x("div", {
1146
- "data-field": e,
1147
- children: [/* @__PURE__ */ b("dt", { children: Z(e) }), /* @__PURE__ */ b("dd", { children: a ? a(e, t, l) : qe(t) })]
1148
- }, e))
1149
- }), p.map(([e, t]) => /* @__PURE__ */ x("section", {
1150
- "data-record-relation": e,
1151
- children: [/* @__PURE__ */ b("h3", { children: Z(e) }), o ? o(e, t, l) : /* @__PURE__ */ b(Je, {
1152
- name: e,
1153
- items: t
1154
- })]
1155
- }, e))]
1156
- });
1157
- }
1158
- //#endregion
1159
- //#region src/connectAccount.tsx
1160
- var Xe = (e, t) => {
1161
- switch (e.status) {
1162
- case "connected": return e.accountLabel === null ? t.connected : t.connectedAs(e.accountLabel);
1163
- case "expired": return t.expired;
1164
- case "revoked": return t.revoked;
1165
- case "error": return t.errored;
1166
- default: return t.notConnected;
1167
- }
1168
- }, Ze = ({ api: e, connectionId: t, ...n }) => {
1169
- let r = te(e, t);
1170
- return /* @__PURE__ */ b(Qe, {
1171
- connection: r,
1172
- loading: r.loading,
1173
- ...n
1174
- });
1175
- }, Qe = ({ connection: e, instructionsUrl: t, loading: n = !1, children: r, className: i }) => {
1176
- let a = z().connectAccount, [o, c] = s("");
1177
- if (r !== void 0) return r(e);
1178
- if (n) return /* @__PURE__ */ b("div", {
1179
- className: i,
1180
- "data-voltro-connect": e.connectionId,
1181
- children: a.loading
1182
- });
1183
- let l = async (t) => {
1184
- t.preventDefault(), o.trim() !== "" && (await e.submitToken(o), c(""));
1185
- };
1186
- return /* @__PURE__ */ x("div", {
1187
- className: i,
1188
- "data-voltro-connect": e.connectionId,
1189
- "data-status": e.status,
1190
- children: [/* @__PURE__ */ x("div", { children: [
1191
- /* @__PURE__ */ b("strong", { children: e.label }),
1192
- " — ",
1193
- /* @__PURE__ */ b("span", {
1194
- role: e.needsAttention ? "alert" : void 0,
1195
- children: Xe(e, a)
1196
- })
1197
- ] }), e.connected || e.needsAttention ? /* @__PURE__ */ x(y, { children: [e.needsAttention && e.kind === "oauth2" && /* @__PURE__ */ b("button", {
1198
- type: "button",
1199
- disabled: e.pending,
1200
- onClick: () => {
1201
- e.connect();
1202
- },
1203
- children: a.reconnect
1204
- }), /* @__PURE__ */ b("button", {
1205
- type: "button",
1206
- disabled: e.pending,
1207
- onClick: () => {
1208
- e.disconnect();
1209
- },
1210
- children: a.disconnect
1211
- })] }) : e.kind === "oauth2" ? /* @__PURE__ */ b("button", {
1212
- type: "button",
1213
- disabled: e.pending,
1214
- onClick: () => {
1215
- e.connect();
1216
- },
1217
- children: a.connect(e.label)
1218
- }) : /* @__PURE__ */ x("form", {
1219
- onSubmit: (e) => {
1220
- l(e);
1221
- },
1222
- children: [
1223
- /* @__PURE__ */ b("label", {
1224
- htmlFor: `voltro-connect-${e.connectionId}`,
1225
- children: a.tokenLabel(e.label)
1226
- }),
1227
- /* @__PURE__ */ b("input", {
1228
- id: `voltro-connect-${e.connectionId}`,
1229
- type: "password",
1230
- autoComplete: "off",
1231
- value: o,
1232
- placeholder: a.tokenPlaceholder,
1233
- onChange: (e) => {
1234
- c(e.target.value);
1235
- }
1236
- }),
1237
- /* @__PURE__ */ b("button", {
1238
- type: "submit",
1239
- disabled: e.pending || o.trim() === "",
1240
- children: a.save
1241
- }),
1242
- t !== void 0 && /* @__PURE__ */ b("a", {
1243
- href: t,
1244
- target: "_blank",
1245
- rel: "noreferrer noopener",
1246
- children: a.howToGetToken
1247
- })
1248
- ]
1249
- })]
1250
- });
1251
- }, $ = (e) => [...e.matchAll(/@([\w.-]+)/g)].map((e) => e[1]);
1252
- function $e({ comment: e, onReact: t, onRemove: n, onEdit: r }) {
1253
- let i = z().comments, [a, o] = s(!1), [c, l] = s(e.body);
1254
- return /* @__PURE__ */ x("li", {
1255
- "data-comment": e.id,
1256
- "data-author": e.authorSubjectId,
1257
- children: [
1258
- /* @__PURE__ */ b("span", {
1259
- "data-comment-author": !0,
1260
- children: e.authorSubjectId
1261
- }),
1262
- a ? /* @__PURE__ */ x("form", {
1263
- "data-comment-edit": !0,
1264
- onSubmit: (e) => {
1265
- e.preventDefault(), r(c), o(!1);
1266
- },
1267
- children: [/* @__PURE__ */ b("input", {
1268
- value: c,
1269
- onChange: (e) => l(e.target.value),
1270
- "aria-label": i.editLabel
1271
- }), /* @__PURE__ */ b("button", {
1272
- type: "submit",
1273
- children: i.save
1274
- })]
1275
- }) : /* @__PURE__ */ x("p", {
1276
- "data-comment-body": !0,
1277
- children: [e.body, e.editedAt ? /* @__PURE__ */ x("em", {
1278
- "data-comment-edited": !0,
1279
- children: [
1280
- " (",
1281
- i.edited,
1282
- ")"
1283
- ]
1284
- }) : null]
1285
- }),
1286
- /* @__PURE__ */ x("span", {
1287
- "data-comment-reactions": !0,
1288
- children: [e.reactions.map((e) => /* @__PURE__ */ x("button", {
1289
- type: "button",
1290
- "data-reaction": e.emoji,
1291
- "data-mine": e.mine || void 0,
1292
- onClick: () => t(e.emoji),
1293
- children: [
1294
- e.emoji,
1295
- " ",
1296
- e.count
1297
- ]
1298
- }, e.emoji)), /* @__PURE__ */ b("button", {
1299
- type: "button",
1300
- "data-reaction-add": !0,
1301
- onClick: () => t("👍"),
1302
- "aria-label": i.react,
1303
- children: "+👍"
1304
- })]
1305
- }),
1306
- /* @__PURE__ */ x("span", {
1307
- "data-comment-actions": !0,
1308
- children: [/* @__PURE__ */ b("button", {
1309
- type: "button",
1310
- onClick: () => o((e) => !e),
1311
- children: i.edit
1312
- }), /* @__PURE__ */ b("button", {
1313
- type: "button",
1314
- onClick: n,
1315
- children: i.remove
1316
- })]
1317
- })
1318
- ]
1319
- });
1320
- }
1321
- function et({ thread: e, api: t }) {
1322
- let n = z().comments, [r, i] = s("");
1323
- return /* @__PURE__ */ x("section", {
1324
- "data-thread": e.id,
1325
- "data-status": e.status,
1326
- children: [
1327
- /* @__PURE__ */ x("header", {
1328
- "data-thread-header": !0,
1329
- children: [
1330
- e.unreadCount > 0 ? /* @__PURE__ */ b("span", {
1331
- "data-thread-unread": !0,
1332
- children: e.unreadCount
1333
- }) : null,
1334
- /* @__PURE__ */ b("button", {
1335
- type: "button",
1336
- "data-thread-resolve": !0,
1337
- onClick: () => void t.resolve(e.id, e.status !== "resolved"),
1338
- children: e.status === "resolved" ? n.reopen : n.resolve
1339
- }),
1340
- /* @__PURE__ */ b("button", {
1341
- type: "button",
1342
- "data-thread-markread": !0,
1343
- onClick: () => void t.markRead(e.id),
1344
- children: n.markRead
1345
- })
1346
- ]
1347
- }),
1348
- e.quote === null ? null : /* @__PURE__ */ b("blockquote", {
1349
- "data-thread-quote": !0,
1350
- children: e.quote.exact
1351
- }),
1352
- /* @__PURE__ */ b("ul", {
1353
- "data-thread-comments": !0,
1354
- children: e.comments.map((e) => /* @__PURE__ */ b($e, {
1355
- comment: e,
1356
- onReact: (n) => void t.react(e.id, n),
1357
- onRemove: () => void t.remove(e.id),
1358
- onEdit: (n) => void t.edit(e.id, n)
1359
- }, e.id))
1360
- }),
1361
- /* @__PURE__ */ x("form", {
1362
- "data-thread-reply": !0,
1363
- onSubmit: (n) => {
1364
- n.preventDefault(), r.trim() !== "" && (t.create(r, {
1365
- threadId: e.id,
1366
- mentions: $(r)
1367
- }), i(""));
1368
- },
1369
- children: [/* @__PURE__ */ b("input", {
1370
- value: r,
1371
- onChange: (e) => i(e.target.value),
1372
- placeholder: n.replyPlaceholder,
1373
- "aria-label": n.replyLabel
1374
- }), /* @__PURE__ */ b("button", {
1375
- type: "submit",
1376
- children: n.reply
1377
- })]
1378
- })
1379
- ]
1380
- });
1381
- }
1382
- function tt({ anchor: e, api: t = "app" }) {
1383
- let n = z().comments, r = ue(e, t), [i, a] = s("");
1384
- return /* @__PURE__ */ x("div", {
1385
- "data-comments": !0,
1386
- "data-anchor": e,
1387
- children: [r.threads.map((e) => /* @__PURE__ */ b(et, {
1388
- thread: e,
1389
- api: r
1390
- }, e.id)), /* @__PURE__ */ x("form", {
1391
- "data-comments-new": !0,
1392
- onSubmit: (e) => {
1393
- e.preventDefault(), i.trim() !== "" && (r.create(i, { mentions: $(i) }), a(""));
1394
- },
1395
- children: [/* @__PURE__ */ b("input", {
1396
- value: i,
1397
- onChange: (e) => a(e.target.value),
1398
- placeholder: n.newPlaceholder,
1399
- "aria-label": n.newLabel
1400
- }), /* @__PURE__ */ b("button", {
1401
- type: "submit",
1402
- children: n.comment
1403
- })]
1404
- })]
1405
- });
1406
- }
1407
- //#endregion
1408
- export { q as AgentChat, K as AgentMessageView, G as AgentPartView, Le as AgentStream, Re as AppAgent, Ne as ApprovalControls, Ee as AsyncSelect, Ce as AutoForm, tt as CommentsThread, Qe as ConnectAccount, Ze as ConnectAccountFor, Ve as DataCopilot, J as DataCopilotAnswer, He as DataCopilotStream, ke as DataTable, Fe as EditingIndicator, I as Field, Ue as FormSkeleton, Pe as PresenceAvatars, Ke as QueryFilters, Ye as RecordView, pe as RichTextView, C as RichTextWidget, We as TableSkeleton, Te as UiStringsProvider, be as WidgetRegistryProvider, je as WorkflowProgress, Me as WorkflowStatusBadge, L as defaultUiStrings, M as defaultWidgets, H as initials, U as summarizeEditors, z as useUiStrings, P as useWidget };
1
+ import { RichTextView as e, RichTextWidget as t } from "./richText.js";
2
+ import { WidgetRegistryProvider as n, defaultWidgets as r, useWidget as i } from "./widgets.js";
3
+ import { AutoForm as a, Field as o } from "./autoForm.js";
4
+ import { UiStringsProvider as s, defaultUiStrings as c, useUiStrings as l } from "./strings.js";
5
+ import { AsyncSelect as u } from "./asyncSelect.js";
6
+ import { DataTable as d } from "./dataTable.js";
7
+ import { ApprovalControls as f, WorkflowProgress as p, WorkflowStatusBadge as m } from "./workflow.js";
8
+ import { EditingIndicator as h, PresenceAvatars as g, initials as _, summarizeEditors as v } from "./presence.js";
9
+ import { AgentChat as y, AgentMessageView as b, AgentPartView as x, AgentStream as S } from "./agentChat.js";
10
+ import { AppAgent as C } from "./appAgent.js";
11
+ import { DataCopilot as w, DataCopilotAnswer as T, DataCopilotStream as E } from "./dataCopilot.js";
12
+ import { FormSkeleton as D, TableSkeleton as O } from "./skeleton.js";
13
+ import { QueryFilters as k } from "./filters.js";
14
+ import { RecordView as A } from "./recordView.js";
15
+ import { ConnectAccount as j, ConnectAccountFor as M } from "./connectAccount.js";
16
+ import { CommentsThread as N } from "./commentsThread.js";
17
+ export { y as AgentChat, b as AgentMessageView, x as AgentPartView, S as AgentStream, C as AppAgent, f as ApprovalControls, u as AsyncSelect, a as AutoForm, N as CommentsThread, j as ConnectAccount, M as ConnectAccountFor, w as DataCopilot, T as DataCopilotAnswer, E as DataCopilotStream, d as DataTable, h as EditingIndicator, o as Field, D as FormSkeleton, g as PresenceAvatars, k as QueryFilters, A as RecordView, e as RichTextView, t as RichTextWidget, O as TableSkeleton, s as UiStringsProvider, n as WidgetRegistryProvider, p as WorkflowProgress, m as WorkflowStatusBadge, c as defaultUiStrings, r as defaultWidgets, _ as initials, v as summarizeEditors, l as useUiStrings, i as useWidget };