@voltro/ui 0.85.0 → 0.87.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.
@@ -0,0 +1,43 @@
1
+ import { defaultUiStrings as e, useUiStrings as t } from "./strings.js";
2
+ import { jsx as n, jsxs as r } from "react/jsx-runtime";
3
+ //#region src/presence.tsx
4
+ var i = (e, t) => {
5
+ let n = e.meta?.[t];
6
+ return typeof n == "string" ? n : void 0;
7
+ }, a = (e) => i(e, "name") ?? i(e, "displayName") ?? e.key, o = (e) => {
8
+ let t = e.trim().split(/\s+/).filter(Boolean);
9
+ return t.length === 0 ? "?" : t.length === 1 ? t[0].slice(0, 2).toUpperCase() : (t[0][0] + t[t.length - 1][0]).toUpperCase();
10
+ };
11
+ function s(e) {
12
+ let { members: i, max: s = 5, nameOf: c = a, renderAvatar: l } = e, u = t().presence, d = i.slice(0, s), f = i.length - d.length;
13
+ return /* @__PURE__ */ r("div", {
14
+ "data-voltro-presence-avatars": !0,
15
+ role: "group",
16
+ "aria-label": u.onlineCount(i.length),
17
+ children: [d.map((e) => {
18
+ let t = c(e);
19
+ return l ? /* @__PURE__ */ n("span", { children: l(e, t) }, e.key) : /* @__PURE__ */ n("span", {
20
+ "data-avatar": !0,
21
+ title: t,
22
+ "aria-label": t,
23
+ children: o(t)
24
+ }, e.key);
25
+ }), f > 0 ? /* @__PURE__ */ r("span", {
26
+ "data-avatar-overflow": !0,
27
+ "aria-label": u.moreOverflow(f),
28
+ children: ["+", f]
29
+ }) : null]
30
+ });
31
+ }
32
+ var c = (t, n, r = e.presence) => t.length === 0 ? "" : t.length === 1 ? r.editingOne(t[0], n) : t.length === 2 ? r.editingTwo(t[0], t[1], n) : r.editingMany(t[0], t.length - 1, n);
33
+ function l(e) {
34
+ let { members: r, selfKey: o, field: s, verb: l = "editing", nameOf: u = a } = e, d = t().presence, f = r.filter((e) => !(o !== void 0 && e.key === o || s !== void 0 && i(e, "field") !== s));
35
+ return f.length === 0 ? null : /* @__PURE__ */ n("span", {
36
+ "data-voltro-editing-indicator": !0,
37
+ "data-field": s,
38
+ role: "status",
39
+ children: c(f.map(u), l, d)
40
+ });
41
+ }
42
+ //#endregion
43
+ export { l as EditingIndicator, s as PresenceAvatars, o as initials, c as summarizeEditors };
@@ -0,0 +1,41 @@
1
+ //#region src/questStrings.ts
2
+ var e = {
3
+ en: {
4
+ title: "Quests",
5
+ loading: "Loading quests…",
6
+ empty: "No current quests.",
7
+ unavailable: "Quests could not be loaded. Reconnect to try again.",
8
+ active: "In progress",
9
+ completed: "Completed",
10
+ expired: "Expired",
11
+ reroll: "Reroll quest",
12
+ rerollPending: "Rerolling…",
13
+ recover: "Check previous reroll",
14
+ recoverPending: "Checking previous reroll…",
15
+ rerollError: "The reroll outcome is unconfirmed. Retry to check the same request.",
16
+ invalid: "Quest data is invalid. Reconnect to request it again.",
17
+ objective: (e, t, n) => `${e}: ${t} of ${n}`,
18
+ expires: (e) => `Ends ${e}`,
19
+ remaining: (e) => `${e} rerolls remaining`
20
+ },
21
+ de: {
22
+ title: "Quests",
23
+ loading: "Quests werden geladen…",
24
+ empty: "Keine aktuellen Quests.",
25
+ unavailable: "Quests konnten nicht geladen werden. Erneut verbinden und wieder versuchen.",
26
+ active: "In Arbeit",
27
+ completed: "Abgeschlossen",
28
+ expired: "Abgelaufen",
29
+ reroll: "Quest neu auslosen",
30
+ rerollPending: "Quest wird ausgelost…",
31
+ recover: "Vorherige Auslosung prüfen",
32
+ recoverPending: "Vorherige Auslosung wird geprüft…",
33
+ rerollError: "Das Ergebnis ist unbestätigt. Erneut versuchen prüft dieselbe Anfrage.",
34
+ invalid: "Die Quest-Daten sind ungültig. Erneut verbinden fordert sie neu an.",
35
+ objective: (e, t, n) => `${e}: ${t} von ${n}`,
36
+ expires: (e) => `Endet ${e}`,
37
+ remaining: (e) => `${e} Auslosungen verbleiben`
38
+ }
39
+ };
40
+ //#endregion
41
+ export { e as questUiStrings };
@@ -0,0 +1,52 @@
1
+ import { useUiStrings as e } from "./strings.js";
2
+ import { useRecord as t } from "@voltro/client";
3
+ import { jsx as n, jsxs as r } from "react/jsx-runtime";
4
+ //#region src/recordView.tsx
5
+ var i = (e) => e.replace(/[_-]+/g, " ").replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/\s+/g, " ").trim().replace(/^./, (e) => e.toUpperCase()), a = (e) => Array.isArray(e) && e.every((e) => typeof e == "object" && !!e), o = (e) => e == null ? "—" : typeof e == "boolean" ? e ? "✓" : "✗" : String(e);
6
+ function s({ name: t, items: a }) {
7
+ let s = e().recordView;
8
+ if (a.length === 0) return /* @__PURE__ */ n("p", {
9
+ "data-relation": t,
10
+ "data-empty": !0,
11
+ children: s.emptyRelation(i(t).toLowerCase())
12
+ });
13
+ let c = Object.keys(a[0]);
14
+ return /* @__PURE__ */ r("table", {
15
+ "data-relation": t,
16
+ children: [/* @__PURE__ */ n("thead", { children: /* @__PURE__ */ n("tr", { children: c.map((e) => /* @__PURE__ */ n("th", {
17
+ scope: "col",
18
+ children: i(e)
19
+ }, e)) }) }), /* @__PURE__ */ n("tbody", { children: a.map((e, t) => /* @__PURE__ */ n("tr", { children: c.map((t) => /* @__PURE__ */ n("td", { children: o(e[t]) }, t)) }, String(e.id ?? t))) })]
20
+ });
21
+ }
22
+ function c(e) {
23
+ let { api: c, query: l, input: u, fields: d, renderField: f, renderRelation: p, loadingText: m, emptyText: h } = e, { record: g, loading: _ } = t(c, l, u ?? {});
24
+ if (_) return /* @__PURE__ */ n("p", {
25
+ "data-voltro-record-loading": !0,
26
+ "aria-busy": "true",
27
+ children: m ?? "Loading…"
28
+ });
29
+ if (g == null) return /* @__PURE__ */ n("p", {
30
+ "data-voltro-record-empty": !0,
31
+ children: h ?? "Not found."
32
+ });
33
+ let v = Object.entries(g), y = v.filter(([e, t]) => !a(t) && (d === void 0 || d.includes(e))), b = v.filter(([, e]) => a(e)), x = d === void 0 ? y : d.map((e) => [e, g[e]]).filter(([, e]) => !a(e));
34
+ return /* @__PURE__ */ r("div", {
35
+ "data-voltro-record-view": l,
36
+ children: [/* @__PURE__ */ n("dl", {
37
+ "data-record-fields": !0,
38
+ children: x.map(([e, t]) => /* @__PURE__ */ r("div", {
39
+ "data-field": e,
40
+ children: [/* @__PURE__ */ n("dt", { children: i(e) }), /* @__PURE__ */ n("dd", { children: f ? f(e, t, g) : o(t) })]
41
+ }, e))
42
+ }), b.map(([e, t]) => /* @__PURE__ */ r("section", {
43
+ "data-record-relation": e,
44
+ children: [/* @__PURE__ */ n("h3", { children: i(e) }), p ? p(e, t, g) : /* @__PURE__ */ n(s, {
45
+ name: e,
46
+ items: t
47
+ })]
48
+ }, e))]
49
+ });
50
+ }
51
+ //#endregion
52
+ export { c as RecordView };
@@ -0,0 +1,81 @@
1
+ import { Fragment as e, useEffect as t, useId as n, useRef as r, useState as i } from "react";
2
+ import { isRichTextDocument as a, isSafeHref as o, parseRichText as s, serializeRichText as c } from "@voltro/client";
3
+ import { Fragment as l, jsx as u, jsxs as d } from "react/jsx-runtime";
4
+ //#region src/richText.tsx
5
+ var f = (t, n) => {
6
+ let r = t.marks ?? [], i = t.text;
7
+ return r.includes("code") && (i = /* @__PURE__ */ u("code", { children: i }, n)), r.includes("italic") && (i = /* @__PURE__ */ u("em", { children: i }, n)), r.includes("strike") && (i = /* @__PURE__ */ u("s", { children: i }, n)), r.includes("bold") && (i = /* @__PURE__ */ u("strong", { children: i }, n)), /* @__PURE__ */ u(e, { children: i }, n);
8
+ }, p = (t) => t.map((t, n) => {
9
+ if (t.type === "link") {
10
+ let r = t.content.map((e) => e.text).join("");
11
+ return o(t.href) ? /* @__PURE__ */ u("a", {
12
+ href: t.href,
13
+ rel: "noopener noreferrer nofollow",
14
+ children: r
15
+ }, n) : /* @__PURE__ */ u(e, { children: r }, n);
16
+ }
17
+ return f(t, n);
18
+ }), m = (e, t) => {
19
+ switch (e.type) {
20
+ case "heading": {
21
+ let n = [
22
+ "h1",
23
+ "h2",
24
+ "h3"
25
+ ][e.level - 1] ?? "h3";
26
+ return /* @__PURE__ */ u(n, { children: p(e.content) }, t);
27
+ }
28
+ case "blockquote": return /* @__PURE__ */ u("blockquote", { children: p(e.content) }, t);
29
+ case "bulletList": return /* @__PURE__ */ u("ul", { children: e.content.map((e, t) => /* @__PURE__ */ u("li", { children: p(e.content) }, t)) }, t);
30
+ case "orderedList": return /* @__PURE__ */ u("ol", { children: e.content.map((e, t) => /* @__PURE__ */ u("li", { children: p(e.content) }, t)) }, t);
31
+ case "codeBlock": return /* @__PURE__ */ u("pre", { children: /* @__PURE__ */ u("code", { children: e.text }) }, t);
32
+ default: return /* @__PURE__ */ u("p", { children: p(e.content) }, t);
33
+ }
34
+ }, h = (e) => a(e.doc) ? /* @__PURE__ */ u(l, { children: e.doc.content.map((e, t) => m(e, t)) }) : null, g = (e) => {
35
+ let a = n(), [o, l] = i(() => c(e.value)), f = r(e.value);
36
+ t(() => {
37
+ e.value !== f.current && JSON.stringify(e.value) !== JSON.stringify(f.current) && (f.current = e.value, l(c(e.value)));
38
+ }, [e.value]);
39
+ let p = [e.description === void 0 ? "" : `${a}-desc`, e.error === void 0 ? "" : `${a}-error`].filter(Boolean).join(" ");
40
+ return /* @__PURE__ */ d("div", {
41
+ "data-voltro-field": !0,
42
+ "data-voltro-rich-text": !0,
43
+ children: [
44
+ /* @__PURE__ */ d("label", {
45
+ htmlFor: a,
46
+ children: [e.label, e.required ? /* @__PURE__ */ u("span", {
47
+ "aria-hidden": "true",
48
+ children: " *"
49
+ }) : null]
50
+ }),
51
+ e.description === void 0 ? null : /* @__PURE__ */ u("p", {
52
+ id: `${a}-desc`,
53
+ "data-voltro-field-hint": !0,
54
+ children: e.description
55
+ }),
56
+ /* @__PURE__ */ u("textarea", {
57
+ id: a,
58
+ name: e.name,
59
+ value: o,
60
+ onChange: (t) => {
61
+ l(t.target.value);
62
+ let n = s(t.target.value);
63
+ f.current = n, e.onChange(n);
64
+ },
65
+ onBlur: e.onBlur,
66
+ disabled: e.disabled,
67
+ required: e.required,
68
+ "aria-required": e.required ? !0 : void 0,
69
+ "aria-invalid": e.error !== void 0,
70
+ "aria-describedby": p === "" ? void 0 : p
71
+ }),
72
+ e.error === void 0 ? null : /* @__PURE__ */ u("p", {
73
+ id: `${a}-error`,
74
+ role: "alert",
75
+ children: e.error
76
+ })
77
+ ]
78
+ });
79
+ };
80
+ //#endregion
81
+ export { h as RichTextView, g as RichTextWidget };
@@ -0,0 +1,52 @@
1
+ import { formSections as e, useFormSkeleton as t, useTableSkeleton as n } from "@voltro/client";
2
+ import { jsx as r, jsxs as i } from "react/jsx-runtime";
3
+ //#region src/skeleton.tsx
4
+ var a = ({ w: e }) => /* @__PURE__ */ r("span", {
5
+ "data-skeleton-bar": !0,
6
+ style: {
7
+ display: "inline-block",
8
+ width: e ?? "100%",
9
+ height: "1em",
10
+ borderRadius: 4
11
+ },
12
+ "aria-hidden": "true"
13
+ });
14
+ function o(n) {
15
+ let o = t(n.api, n.mutation), s = o.length > 0 ? o.length : n.fallbackFields ?? 3, c = o.length > 0 ? e(o) : [{
16
+ name: void 0,
17
+ label: void 0,
18
+ fields: Array.from({ length: s }, (e, t) => ({ name: `f${t}` }))
19
+ }];
20
+ return /* @__PURE__ */ r("div", {
21
+ "data-voltro-form-skeleton": n.mutation,
22
+ "aria-busy": "true",
23
+ "aria-hidden": "true",
24
+ children: c.map((e, t) => /* @__PURE__ */ i("div", {
25
+ ...e.name === void 0 ? {} : { "data-skeleton-section": e.name },
26
+ children: [e.name !== void 0 && /* @__PURE__ */ r("div", {
27
+ "data-skeleton-section-title": !0,
28
+ children: /* @__PURE__ */ r(a, { w: "40%" })
29
+ }), e.fields.map((e) => /* @__PURE__ */ i("div", {
30
+ "data-skeleton-field": !0,
31
+ children: [/* @__PURE__ */ r(a, { w: "30%" }), /* @__PURE__ */ r(a, {})]
32
+ }, e.name))]
33
+ }, e.name ?? `_${t}`))
34
+ });
35
+ }
36
+ function s(e) {
37
+ let t = n(e.api, e.query), o = t.length > 0 ? t.length : e.fallbackColumns ?? 4, s = t.length > 0 ? t.map((e) => e.name) : Array.from({ length: o }, (e, t) => `c${t}`), c = e.rows ?? 5;
38
+ return /* @__PURE__ */ i("table", {
39
+ "data-voltro-table-skeleton": e.query,
40
+ "aria-busy": "true",
41
+ "aria-hidden": "true",
42
+ children: [/* @__PURE__ */ r("thead", { children: /* @__PURE__ */ r("tr", { children: s.map((e) => /* @__PURE__ */ r("th", {
43
+ scope: "col",
44
+ children: /* @__PURE__ */ r(a, { w: "60%" })
45
+ }, e)) }) }), /* @__PURE__ */ r("tbody", { children: Array.from({ length: c }, (e, t) => /* @__PURE__ */ r("tr", {
46
+ "data-skeleton-row": !0,
47
+ children: s.map((e) => /* @__PURE__ */ r("td", { children: /* @__PURE__ */ r(a, {}) }, e))
48
+ }, t)) })]
49
+ });
50
+ }
51
+ //#endregion
52
+ export { o as FormSkeleton, s as TableSkeleton };
@@ -0,0 +1,148 @@
1
+ import { achievementUiStrings as e } from "./achievementStrings.js";
2
+ import { questUiStrings as t } from "./questStrings.js";
3
+ import { createContext as n, useContext as r, useMemo as i } from "react";
4
+ import { jsx as a } from "react/jsx-runtime";
5
+ //#region src/strings.tsx
6
+ var o = {
7
+ achievements: e.en,
8
+ quests: t.en,
9
+ filters: {
10
+ clear: "Clear",
11
+ filtersLabel: "Filters",
12
+ anyOption: (e) => `Any ${e}`,
13
+ resultCount: (e) => `${e} results`
14
+ },
15
+ asyncSelect: {
16
+ searchPlaceholder: "Search…",
17
+ searchLabel: (e) => `Search ${e}`,
18
+ loading: "Loading…",
19
+ empty: "—"
20
+ },
21
+ dataTable: { actions: "Actions" },
22
+ workflow: {
23
+ status: {
24
+ running: "Running",
25
+ succeeded: "Succeeded",
26
+ failed: "Failed",
27
+ cancelled: "Cancelled",
28
+ suspended: "Waiting"
29
+ },
30
+ attempt: (e) => `attempt ${e}`,
31
+ loading: "Loading…",
32
+ empty: "No steps yet."
33
+ },
34
+ agentChat: {
35
+ reasoning: "Reasoning",
36
+ messagePlaceholder: "Message…",
37
+ messageLabel: "Message",
38
+ send: "Send"
39
+ },
40
+ comments: {
41
+ comment: "Comment",
42
+ reply: "Reply",
43
+ replyPlaceholder: "Reply… (@name to mention)",
44
+ replyLabel: "Reply",
45
+ newPlaceholder: "Start a discussion… (@name to mention)",
46
+ newLabel: "New comment",
47
+ resolve: "Resolve",
48
+ reopen: "Reopen",
49
+ markRead: "Mark read",
50
+ edit: "Edit",
51
+ edited: "edited",
52
+ editLabel: "Edit comment",
53
+ save: "Save",
54
+ remove: "Delete",
55
+ react: "React"
56
+ },
57
+ appAgent: {
58
+ toolsSummary: (e) => `${e} tools · acts as you`,
59
+ needsConfirm: "needs confirm"
60
+ },
61
+ presence: {
62
+ moreOverflow: (e) => `${e} more`,
63
+ onlineCount: (e) => `${e} online`,
64
+ editingOne: (e, t) => `${e} is ${t}`,
65
+ editingTwo: (e, t, n) => `${e} and ${t} are ${n}`,
66
+ editingMany: (e, t, n) => `${e} and ${t} others are ${n}`
67
+ },
68
+ recordView: { emptyRelation: (e) => `No ${e}.` },
69
+ connectAccount: {
70
+ connect: (e) => `Connect ${e}`,
71
+ disconnect: "Disconnect",
72
+ reconnect: "Reconnect",
73
+ connectedAs: (e) => `Connected as ${e}`,
74
+ connected: "Connected",
75
+ notConnected: "Not connected",
76
+ expired: "Expired — reconnect to continue",
77
+ revoked: "Access was revoked — reconnect to continue",
78
+ errored: "Could not refresh — retrying",
79
+ tokenLabel: (e) => `${e} personal access token`,
80
+ tokenPlaceholder: "Paste your token…",
81
+ save: "Save",
82
+ howToGetToken: "How do I get a token?",
83
+ loading: "Loading…"
84
+ }
85
+ }, s = n(o), c = (e, t) => ({
86
+ achievements: {
87
+ ...e.achievements,
88
+ ...t.achievements
89
+ },
90
+ quests: {
91
+ ...e.quests,
92
+ ...t.quests
93
+ },
94
+ filters: {
95
+ ...e.filters,
96
+ ...t.filters
97
+ },
98
+ asyncSelect: {
99
+ ...e.asyncSelect,
100
+ ...t.asyncSelect
101
+ },
102
+ dataTable: {
103
+ ...e.dataTable,
104
+ ...t.dataTable
105
+ },
106
+ workflow: {
107
+ ...e.workflow,
108
+ ...t.workflow,
109
+ status: {
110
+ ...e.workflow.status,
111
+ ...t.workflow?.status
112
+ }
113
+ },
114
+ agentChat: {
115
+ ...e.agentChat,
116
+ ...t.agentChat
117
+ },
118
+ comments: {
119
+ ...e.comments,
120
+ ...t.comments
121
+ },
122
+ appAgent: {
123
+ ...e.appAgent,
124
+ ...t.appAgent
125
+ },
126
+ presence: {
127
+ ...e.presence,
128
+ ...t.presence
129
+ },
130
+ recordView: {
131
+ ...e.recordView,
132
+ ...t.recordView
133
+ },
134
+ connectAccount: {
135
+ ...e.connectAccount,
136
+ ...t.connectAccount
137
+ }
138
+ });
139
+ function l(e) {
140
+ let t = r(s), n = i(() => c(t, e.strings), [t, e.strings]);
141
+ return /* @__PURE__ */ a(s.Provider, {
142
+ value: n,
143
+ children: e.children
144
+ });
145
+ }
146
+ var u = () => r(s);
147
+ //#endregion
148
+ export { l as UiStringsProvider, o as defaultUiStrings, u as useUiStrings };
@@ -0,0 +1,247 @@
1
+ import { RichTextWidget as e } from "./richText.js";
2
+ import { createContext as t, useContext as n, useId as r, useMemo as i } from "react";
3
+ import { jsx as a, jsxs as o } from "react/jsx-runtime";
4
+ //#region src/widgets.tsx
5
+ var s = (e) => e == null ? "" : String(e), c = ({ required: e }) => e ? /* @__PURE__ */ a("span", {
6
+ "aria-hidden": "true",
7
+ children: " *"
8
+ }) : null, l = (e) => /* @__PURE__ */ o("div", {
9
+ "data-voltro-field": !0,
10
+ children: [
11
+ /* @__PURE__ */ o("label", {
12
+ htmlFor: e.id,
13
+ children: [e.label, /* @__PURE__ */ a(c, { required: e.required })]
14
+ }),
15
+ e.description === void 0 ? null : /* @__PURE__ */ a("p", {
16
+ id: `${e.id}-desc`,
17
+ "data-voltro-field-hint": !0,
18
+ children: e.description
19
+ }),
20
+ e.children,
21
+ e.error === void 0 ? null : /* @__PURE__ */ a("p", {
22
+ id: `${e.id}-error`,
23
+ role: "alert",
24
+ children: e.error
25
+ })
26
+ ]
27
+ }), u = (e, t, n) => {
28
+ let r = [t === void 0 ? "" : `${e}-desc`, n === void 0 ? "" : `${e}-error`].filter(Boolean);
29
+ return r.length > 0 ? r.join(" ") : void 0;
30
+ }, d = (e) => e ? !0 : void 0, f = (e, t) => (n) => {
31
+ let i = r();
32
+ return /* @__PURE__ */ a(l, {
33
+ id: i,
34
+ label: n.label,
35
+ required: n.required,
36
+ description: n.description,
37
+ error: n.error,
38
+ children: /* @__PURE__ */ a("input", {
39
+ id: i,
40
+ type: e,
41
+ name: n.name,
42
+ value: s(n.value),
43
+ onChange: (e) => n.onChange(t(e.target.value)),
44
+ onBlur: n.onBlur,
45
+ disabled: n.disabled,
46
+ required: n.required,
47
+ "aria-required": d(n.required),
48
+ "aria-invalid": n.error !== void 0,
49
+ "aria-describedby": u(i, n.description, n.error)
50
+ })
51
+ });
52
+ }, p = (e) => {
53
+ let t = r();
54
+ return /* @__PURE__ */ a(l, {
55
+ id: t,
56
+ label: e.label,
57
+ required: e.required,
58
+ description: e.description,
59
+ error: e.error,
60
+ children: /* @__PURE__ */ a("textarea", {
61
+ id: t,
62
+ name: e.name,
63
+ value: s(e.value),
64
+ onChange: (t) => e.onChange(t.target.value),
65
+ disabled: e.disabled,
66
+ onBlur: e.onBlur,
67
+ required: e.required,
68
+ "aria-required": d(e.required),
69
+ "aria-invalid": e.error !== void 0,
70
+ "aria-describedby": u(t, e.description, e.error)
71
+ })
72
+ });
73
+ }, m = (e) => {
74
+ let t = r();
75
+ return /* @__PURE__ */ a(l, {
76
+ id: t,
77
+ label: e.label,
78
+ required: e.required,
79
+ description: e.description,
80
+ error: e.error,
81
+ children: /* @__PURE__ */ a("input", {
82
+ id: t,
83
+ type: "checkbox",
84
+ name: e.name,
85
+ checked: e.value === !0,
86
+ onChange: (t) => e.onChange(t.target.checked),
87
+ disabled: e.disabled,
88
+ onBlur: e.onBlur,
89
+ "aria-required": d(e.required),
90
+ "aria-invalid": e.error !== void 0,
91
+ "aria-describedby": u(t, e.description, e.error)
92
+ })
93
+ });
94
+ }, h = (e) => {
95
+ let t = r();
96
+ return /* @__PURE__ */ a(l, {
97
+ id: t,
98
+ label: e.label,
99
+ required: e.required,
100
+ description: e.description,
101
+ error: e.error,
102
+ children: /* @__PURE__ */ o("select", {
103
+ id: t,
104
+ name: e.name,
105
+ value: s(e.value),
106
+ onChange: (t) => e.onChange(t.target.value),
107
+ disabled: e.disabled,
108
+ onBlur: e.onBlur,
109
+ required: e.required,
110
+ "aria-required": d(e.required),
111
+ "aria-invalid": e.error !== void 0,
112
+ "aria-describedby": u(t, e.description, e.error),
113
+ children: [/* @__PURE__ */ a("option", {
114
+ value: "",
115
+ children: "—"
116
+ }), (e.options ?? []).map((e) => /* @__PURE__ */ a("option", {
117
+ value: e.value,
118
+ children: e.label
119
+ }, e.value))]
120
+ })
121
+ });
122
+ }, g = (e) => {
123
+ let t = r();
124
+ return /* @__PURE__ */ o("fieldset", {
125
+ "data-voltro-field": !0,
126
+ "aria-invalid": e.error !== void 0,
127
+ "aria-required": d(e.required),
128
+ "aria-describedby": u(t, e.description, e.error),
129
+ children: [
130
+ /* @__PURE__ */ o("legend", { children: [e.label, /* @__PURE__ */ a(c, { required: e.required })] }),
131
+ e.description === void 0 ? null : /* @__PURE__ */ a("p", {
132
+ id: `${t}-desc`,
133
+ "data-voltro-field-hint": !0,
134
+ children: e.description
135
+ }),
136
+ (e.options ?? []).map((n) => {
137
+ let r = `${t}-${n.value}`;
138
+ return /* @__PURE__ */ o("span", { children: [/* @__PURE__ */ a("input", {
139
+ id: r,
140
+ type: "radio",
141
+ name: e.name,
142
+ value: n.value,
143
+ checked: s(e.value) === n.value,
144
+ onChange: () => e.onChange(n.value),
145
+ disabled: e.disabled,
146
+ onBlur: e.onBlur
147
+ }), /* @__PURE__ */ a("label", {
148
+ htmlFor: r,
149
+ children: n.label
150
+ })] }, n.value);
151
+ }),
152
+ e.error === void 0 ? null : /* @__PURE__ */ a("p", {
153
+ id: `${t}-error`,
154
+ role: "alert",
155
+ children: e.error
156
+ })
157
+ ]
158
+ });
159
+ }, _ = (e) => {
160
+ let t = r(), n = Array.isArray(e.value) ? e.value.map(String) : [];
161
+ return /* @__PURE__ */ a(l, {
162
+ id: t,
163
+ label: e.label,
164
+ required: e.required,
165
+ description: e.description,
166
+ error: e.error,
167
+ children: /* @__PURE__ */ a("select", {
168
+ id: t,
169
+ name: e.name,
170
+ multiple: !0,
171
+ value: n,
172
+ onChange: (t) => e.onChange(Array.from(t.target.selectedOptions, (e) => e.value)),
173
+ disabled: e.disabled,
174
+ onBlur: e.onBlur,
175
+ "aria-required": d(e.required),
176
+ "aria-invalid": e.error !== void 0,
177
+ "aria-describedby": u(t, e.description, e.error),
178
+ children: (e.options ?? []).map((e) => /* @__PURE__ */ a("option", {
179
+ value: e.value,
180
+ children: e.label
181
+ }, e.value))
182
+ })
183
+ });
184
+ }, v = (e) => /* @__PURE__ */ a("input", {
185
+ type: "hidden",
186
+ name: e.name,
187
+ value: s(e.value),
188
+ readOnly: !0
189
+ }), y = (e) => {
190
+ let t = r();
191
+ return /* @__PURE__ */ a(l, {
192
+ id: t,
193
+ label: e.label,
194
+ required: e.required,
195
+ description: e.description,
196
+ error: e.error,
197
+ children: /* @__PURE__ */ a("input", {
198
+ id: t,
199
+ type: "file",
200
+ name: e.name,
201
+ onChange: (t) => e.onChange(t.target.files?.[0] ?? null),
202
+ disabled: e.disabled,
203
+ onBlur: e.onBlur,
204
+ required: e.required,
205
+ "aria-required": d(e.required),
206
+ "aria-invalid": e.error !== void 0,
207
+ "aria-describedby": u(t, e.description, e.error)
208
+ })
209
+ });
210
+ }, b = (e) => /* @__PURE__ */ o("div", {
211
+ "data-voltro-field": !0,
212
+ "data-voltro-custom": !0,
213
+ children: [/* @__PURE__ */ o("label", { children: [e.label, /* @__PURE__ */ a(c, { required: e.required })] }), /* @__PURE__ */ a("p", {
214
+ role: "note",
215
+ children: `No default widget for "${e.name}" — provide a render-prop via <Field>.`
216
+ })]
217
+ }), x = {
218
+ text: f("text", (e) => e),
219
+ number: f("number", (e) => e === "" ? void 0 : Number(e)),
220
+ date: f("date", (e) => e),
221
+ datetime: f("datetime-local", (e) => e),
222
+ daterange: f("text", (e) => e),
223
+ file: y,
224
+ "async-select": f("text", (e) => e),
225
+ textarea: p,
226
+ "rich-text": e,
227
+ checkbox: m,
228
+ switch: m,
229
+ select: h,
230
+ radio: g,
231
+ "multi-select": _,
232
+ hidden: v,
233
+ array: b,
234
+ reference: b,
235
+ custom: b
236
+ }, S = t({}), C = (e) => {
237
+ let t = n(S), r = i(() => ({
238
+ ...t,
239
+ ...e.widgets
240
+ }), [t, e.widgets]);
241
+ return /* @__PURE__ */ a(S.Provider, {
242
+ value: r,
243
+ children: e.children
244
+ });
245
+ }, w = (e) => n(S)[e] ?? x[e] ?? x.custom;
246
+ //#endregion
247
+ export { C as WidgetRegistryProvider, x as defaultWidgets, w as useWidget };