@inkeep/agents-ui 0.0.0-dev-20260508213807 → 0.0.0-dev-20260508233535

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.
Files changed (38) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.js +156 -153
  3. package/dist/primitives/components/embedded-chat/use-inkeep-chat.cjs +2 -2
  4. package/dist/primitives/components/embedded-chat/use-inkeep-chat.d.ts +0 -13
  5. package/dist/primitives/components/embedded-chat/use-inkeep-chat.js +224 -238
  6. package/dist/primitives/components/embedded-chat.d.ts +1 -1
  7. package/dist/primitives/index.cjs +1 -1
  8. package/dist/primitives/index.js +144 -141
  9. package/dist/primitives/providers/chat-auth-provider.cjs +1 -0
  10. package/dist/primitives/providers/chat-auth-provider.d.ts +15 -0
  11. package/dist/primitives/providers/chat-auth-provider.js +44 -0
  12. package/dist/primitives/providers/index.cjs +1 -1
  13. package/dist/primitives/providers/index.d.ts +1 -0
  14. package/dist/primitives/providers/index.js +51 -48
  15. package/dist/react/embedded-chat.cjs +1 -1
  16. package/dist/react/embedded-chat.js +75 -74
  17. package/dist/react/index.cjs +1 -1
  18. package/dist/react/index.js +156 -153
  19. package/dist/styled/components/message.cjs +1 -1
  20. package/dist/styled/components/message.js +210 -272
  21. package/dist/styled/index.cjs +1 -1
  22. package/dist/styled/index.js +148 -145
  23. package/dist/styled/inkeep.css.cjs +0 -78
  24. package/dist/styled/inkeep.css.js +0 -78
  25. package/package.json +1 -2
  26. package/dist/node_modules/.pnpm/@hookform_resolvers@5.2.2_react-hook-form@7.70.0_react@19.3.0-canary-87ae75b3-20260128_/node_modules/@hookform/resolvers/zod/dist/zod.cjs +0 -1
  27. package/dist/node_modules/.pnpm/@hookform_resolvers@5.2.2_react-hook-form@7.70.0_react@19.3.0-canary-87ae75b3-20260128_/node_modules/@hookform/resolvers/zod/dist/zod.js +0 -93
  28. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/core.cjs +0 -1
  29. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/core.js +0 -49
  30. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/errors.cjs +0 -1
  31. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/errors.js +0 -19
  32. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/parse.cjs +0 -1
  33. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/parse.js +0 -28
  34. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/util.cjs +0 -1
  35. package/dist/node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/util.js +0 -23
  36. package/dist/styled/components/ask-user-form.cjs +0 -1
  37. package/dist/styled/components/ask-user-form.d.ts +0 -96
  38. package/dist/styled/components/ask-user-form.js +0 -672
@@ -1,672 +0,0 @@
1
- "use client";
2
- import { jsx as a, jsxs as n, Fragment as W } from "react/jsx-runtime";
3
- import { zodResolver as Q } from "../../node_modules/.pnpm/@hookform_resolvers@5.2.2_react-hook-form@7.70.0_react@19.3.0-canary-87ae75b3-20260128_/node_modules/@hookform/resolvers/zod/dist/zod.js";
4
- import { useMemo as I, useState as X, useCallback as S, useRef as ee, useEffect as O } from "react";
5
- import { useForm as re, FormProvider as te, useFormContext as z, useWatch as ae, useFormState as V, useFieldArray as ie, Controller as Y } from "react-hook-form";
6
- import { z as p } from "zod";
7
- import { cn as b } from "../utils.js";
8
- import { button as D } from "./ui/recipes/button.js";
9
- const C = "border border-gray-200 dark:border-white-alpha-200 rounded-lg mb-3 p-4 bg-white dark:bg-gray-dark-900", F = "text-xs font-medium text-gray-700 dark:text-white-alpha-700 select-none", L = "text-xs px-2 py-1.5 rounded-md border bg-white dark:bg-gray-dark-900 text-gray-800 dark:text-white-alpha-800 border-gray-200 dark:border-white-alpha-200 focus:outline-none focus:ring-1 focus:ring-inkeep-expanded-primary-500 disabled:opacity-60 disabled:cursor-not-allowed", q = "text-2xs text-gray-500 dark:text-white-alpha-500 mt-0.5", R = "text-2xs text-red-600 dark:text-red-400 mt-0.5", P = (e) => {
10
- switch (e) {
11
- case "short":
12
- return "w-20";
13
- case "medium":
14
- return "w-48";
15
- default:
16
- return "w-full";
17
- }
18
- };
19
- function le(e) {
20
- return !(e.length > 200 || /[+*?}]\)?[+*?{]/.test(e) || /\([^)]*\|[^)]*\)[+*?{]/.test(e));
21
- }
22
- function se(e) {
23
- const t = e.required !== !1;
24
- switch (e.type) {
25
- case "boolean":
26
- return p.boolean().default(!1);
27
- case "number": {
28
- let r = p.number();
29
- e.validation?.min !== void 0 && (r = r.min(e.validation.min)), e.validation?.max !== void 0 && (r = r.max(e.validation.max));
30
- const i = t ? r : r.optional();
31
- return p.preprocess((l) => {
32
- if (!(l === "" || l === null || l === void 0)) {
33
- if (typeof l == "string") {
34
- const s = Number(l);
35
- return Number.isNaN(s) ? l : s;
36
- }
37
- return l;
38
- }
39
- }, i);
40
- }
41
- case "email": {
42
- let r = p.string().email("Enter a valid email");
43
- return e.validation?.minLength !== void 0 && (r = r.min(e.validation.minLength)), e.validation?.maxLength !== void 0 && (r = r.max(e.validation.maxLength)), t ? r.min(1, "Required") : r.or(p.literal(""));
44
- }
45
- case "date": {
46
- const r = p.string();
47
- return t ? r.min(1, "Required") : r.optional();
48
- }
49
- default: {
50
- let r = p.string();
51
- if (e.validation?.minLength !== void 0 && (r = r.min(e.validation.minLength)), e.validation?.maxLength !== void 0 && (r = r.max(e.validation.maxLength)), e.validation?.pattern && le(e.validation.pattern))
52
- try {
53
- r = r.regex(new RegExp(e.validation.pattern), "Invalid format");
54
- } catch {
55
- }
56
- if (e.options && e.options.length > 0) {
57
- const i = e.options.map((s) => s.value), l = p.enum(i);
58
- return t ? l : l.or(p.literal(""));
59
- }
60
- return t ? r.min(1, "Required") : r;
61
- }
62
- }
63
- }
64
- function ne(e) {
65
- let t;
66
- switch (e.itemType) {
67
- case "number":
68
- t = p.preprocess(
69
- (i) => i === "" || i === null || i === void 0 ? void 0 : Number(i),
70
- p.number()
71
- );
72
- break;
73
- case "email":
74
- t = p.string().email();
75
- break;
76
- case "boolean":
77
- t = p.boolean();
78
- break;
79
- default:
80
- t = p.string().min(1);
81
- }
82
- let r = p.array(t);
83
- return e.min !== void 0 && (r = r.min(e.min, `At least ${e.min}`)), e.max !== void 0 && (r = r.max(e.max, `At most ${e.max}`)), r;
84
- }
85
- function oe(e) {
86
- return e.kind === "leaf" ? se(e) : e.kind === "list" ? ne(e) : e.kind === "groupList" ? ce(e) : Z(e.children);
87
- }
88
- function Z(e) {
89
- const t = {};
90
- for (const r of e)
91
- t[r.id] = oe(r);
92
- return p.object(t);
93
- }
94
- function ce(e) {
95
- const t = Z(e.item.children);
96
- let r = p.array(t);
97
- return e.min !== void 0 && (r = r.min(e.min, `At least ${e.min}`)), e.max !== void 0 && (r = r.max(e.max, `At most ${e.max}`)), r;
98
- }
99
- function de(e) {
100
- return Z(e);
101
- }
102
- function me(e) {
103
- if (e.default !== void 0) return e.default;
104
- if (e.options && e.options.length > 0) return e.options[0]?.value ?? "";
105
- switch (e.type) {
106
- case "boolean":
107
- return !1;
108
- case "number":
109
- return "";
110
- default:
111
- return "";
112
- }
113
- }
114
- function E(e) {
115
- const t = {};
116
- for (const r of e)
117
- if (r.kind === "leaf")
118
- t[r.id] = me(r);
119
- else if (r.kind === "list")
120
- t[r.id] = [];
121
- else if (r.kind === "groupList") {
122
- const i = r.min ?? 0, l = [];
123
- for (let s = 0; s < i; s++)
124
- l.push(E(r.item.children));
125
- t[r.id] = l;
126
- } else
127
- t[r.id] = E(r.children);
128
- return t;
129
- }
130
- function _(e, t = []) {
131
- for (const r of e) {
132
- if (r.kind === "leaf") return [...t, r.id];
133
- if (r.kind === "group") {
134
- const i = _(r.children, [...t, r.id]);
135
- if (i) return i;
136
- }
137
- }
138
- }
139
- function H(e, t = []) {
140
- for (const r of e)
141
- if (r.kind === "leaf") {
142
- if (!(r.default !== void 0 && r.default !== "")) return [...t, r.id];
143
- } else if (r.kind === "group") {
144
- const i = H(r.children, [...t, r.id]);
145
- if (i) return i;
146
- }
147
- }
148
- function ue(e) {
149
- return H(e) ?? _(e);
150
- }
151
- const Se = ({
152
- input: e,
153
- output: t,
154
- status: r,
155
- errorText: i,
156
- onSubmit: l,
157
- onDecline: s
158
- }) => r === "pending" ? /* @__PURE__ */ a("div", { className: C, children: /* @__PURE__ */ n("div", { className: "space-y-3 animate-pulse", children: [
159
- /* @__PURE__ */ a("div", { className: "h-3 w-32 bg-gray-100 dark:bg-white-alpha-100 rounded" }),
160
- /* @__PURE__ */ a("div", { className: "h-7 w-full bg-gray-100 dark:bg-white-alpha-100 rounded" }),
161
- /* @__PURE__ */ a("div", { className: "h-7 w-full bg-gray-100 dark:bg-white-alpha-100 rounded" })
162
- ] }) }) : r === "declined" ? /* @__PURE__ */ a("div", { className: C, children: /* @__PURE__ */ a("div", { className: "text-xs font-medium text-gray-700 dark:text-white-alpha-700", children: i || "User declined to provide input." }) }) : r === "submitted" && t ? /* @__PURE__ */ a(he, { output: t }) : !e || !Array.isArray(e.form) ? /* @__PURE__ */ a("div", { className: C, children: /* @__PURE__ */ a("div", { className: "text-xs text-gray-500 dark:text-white-alpha-500 italic", children: "Preparing form…" }) }) : /* @__PURE__ */ a(
163
- pe,
164
- {
165
- input: e,
166
- onSubmit: l ?? (() => {
167
- }),
168
- onDecline: s ?? (() => {
169
- })
170
- }
171
- ), he = ({ output: e }) => /* @__PURE__ */ n("div", { className: C, children: [
172
- e.message && /* @__PURE__ */ a("div", { className: "text-sm font-medium text-gray-800 dark:text-white-alpha-800 mb-3", children: e.message }),
173
- /* @__PURE__ */ a("div", { className: "space-y-3", children: e.form.map((t) => /* @__PURE__ */ a(M, { node: t, value: e.answers[t.id] }, t.id)) })
174
- ] }), M = ({ node: e, value: t }) => {
175
- if (e.kind === "group") {
176
- const r = t && typeof t == "object" && !Array.isArray(t) ? t : {};
177
- return /* @__PURE__ */ n("fieldset", { className: "border-l-2 border-gray-100 dark:border-white-alpha-100 pl-3", children: [
178
- e.label && /* @__PURE__ */ a("legend", { className: "text-xs font-semibold text-gray-700 dark:text-white-alpha-700 mb-2", children: e.label }),
179
- /* @__PURE__ */ a("div", { className: "space-y-3", children: e.children.map((i) => /* @__PURE__ */ a(M, { node: i, value: r[i.id] }, i.id)) })
180
- ] });
181
- }
182
- if (e.kind === "list") {
183
- const r = Array.isArray(t) ? t : [];
184
- return /* @__PURE__ */ n("div", { className: "flex flex-col gap-1", children: [
185
- /* @__PURE__ */ a("span", { className: F, children: e.label }),
186
- /* @__PURE__ */ a("div", { className: "flex flex-wrap gap-1", children: r.length === 0 ? /* @__PURE__ */ a("span", { className: "text-2xs text-gray-500 dark:text-white-alpha-500 italic", children: "(none)" }) : r.map((i, l) => {
187
- const s = J(i);
188
- return /* @__PURE__ */ a(
189
- "span",
190
- {
191
- className: "inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-gray-100 dark:bg-white-alpha-100 text-2xs text-gray-700 dark:text-white-alpha-700",
192
- children: s
193
- },
194
- `${s}-${l}`
195
- );
196
- }) })
197
- ] });
198
- }
199
- if (e.kind === "groupList") {
200
- const r = Array.isArray(t) ? t : [];
201
- return /* @__PURE__ */ n("fieldset", { className: "border-l-2 border-gray-100 dark:border-white-alpha-100 pl-3", children: [
202
- /* @__PURE__ */ a("legend", { className: "text-xs font-semibold text-gray-700 dark:text-white-alpha-700 mb-2", children: e.label }),
203
- /* @__PURE__ */ a("div", { className: "space-y-2", children: r.length === 0 ? /* @__PURE__ */ a("span", { className: "text-2xs text-gray-500 dark:text-white-alpha-500 italic", children: "(none)" }) : r.map((i, l) => {
204
- const s = i && typeof i == "object" && !Array.isArray(i) ? i : {};
205
- return /* @__PURE__ */ n(
206
- "div",
207
- {
208
- className: "pl-2 py-1 rounded-md bg-gray-50/50 dark:bg-white-alpha-50/50",
209
- children: [
210
- /* @__PURE__ */ n("span", { className: "text-2xs font-medium text-gray-500 dark:text-white-alpha-500 uppercase tracking-wider", children: [
211
- "#",
212
- l + 1
213
- ] }),
214
- /* @__PURE__ */ a("div", { className: "mt-1 space-y-2", children: e.item.children.map((o) => /* @__PURE__ */ a(M, { node: o, value: s[o.id] }, o.id)) })
215
- ]
216
- },
217
- `row-${l}-${e.id}`
218
- );
219
- }) })
220
- ] });
221
- }
222
- return /* @__PURE__ */ n("div", { className: "flex flex-col gap-1", children: [
223
- /* @__PURE__ */ a("span", { className: F, children: e.label }),
224
- /* @__PURE__ */ a(
225
- "span",
226
- {
227
- className: b(L, P(e.width), "inline-block opacity-70"),
228
- "aria-disabled": "true",
229
- children: t === void 0 || t === "" ? /* @__PURE__ */ a("span", { className: "italic text-gray-500 dark:text-white-alpha-500", children: "(empty)" }) : e.type === "boolean" ? t ? "Yes" : "No" : String(t)
230
- }
231
- )
232
- ] });
233
- }, pe = ({ input: e, onSubmit: t, onDecline: r }) => {
234
- const i = e.form ?? [], l = I(() => de(i), [i]), s = I(() => E(i), [i]), o = I(() => ue(i), [i]), f = Q(l), u = re({
235
- resolver: f,
236
- defaultValues: s,
237
- mode: "onBlur",
238
- reValidateMode: "onChange",
239
- shouldFocusError: !0
240
- }), A = u.handleSubmit((c) => {
241
- t(c);
242
- });
243
- return /* @__PURE__ */ a(te, { ...u, children: /* @__PURE__ */ n(
244
- "form",
245
- {
246
- onSubmit: A,
247
- className: C,
248
- noValidate: !0,
249
- "aria-label": e.message || "User input form",
250
- children: [
251
- e.message && /* @__PURE__ */ a("div", { className: "text-sm font-medium text-gray-800 dark:text-white-alpha-800 mb-3", children: e.message }),
252
- /* @__PURE__ */ a("div", { className: "space-y-3", children: i.map((c) => /* @__PURE__ */ a(U, { node: c, pathPrefix: "", autoFocusPath: o }, c.id)) }),
253
- /* @__PURE__ */ n("div", { className: "flex items-center justify-end gap-2 mt-4", children: [
254
- /* @__PURE__ */ a(
255
- "button",
256
- {
257
- type: "button",
258
- className: D({ size: "xs", variant: "ghost" }),
259
- onClick: r,
260
- disabled: u.formState.isSubmitting,
261
- children: "Cancel"
262
- }
263
- ),
264
- /* @__PURE__ */ a(
265
- "button",
266
- {
267
- type: "submit",
268
- className: D({ size: "xs", variant: "primaryFilled" }),
269
- disabled: u.formState.isSubmitting,
270
- children: u.formState.isSubmitting ? "Submitting…" : "Submit"
271
- }
272
- )
273
- ] })
274
- ]
275
- }
276
- ) });
277
- }, U = ({ node: e, pathPrefix: t, autoFocusPath: r }) => {
278
- const i = t ? `${t}.${e.id}` : e.id;
279
- return e.kind === "group" ? /* @__PURE__ */ a(fe, { node: e, path: i, autoFocusPath: r }) : e.kind === "list" ? /* @__PURE__ */ a(ge, { node: e, path: i }) : e.kind === "groupList" ? /* @__PURE__ */ a(ye, { node: e, path: i, autoFocusPath: r }) : /* @__PURE__ */ a(xe, { node: e, path: i, autoFocusPath: r });
280
- }, fe = ({ node: e, path: t, autoFocusPath: r }) => /* @__PURE__ */ n(
281
- "fieldset",
282
- {
283
- className: "border-l-2 border-gray-100 dark:border-white-alpha-100 pl-3",
284
- "aria-labelledby": e.label ? `group-${t}` : void 0,
285
- children: [
286
- e.label && /* @__PURE__ */ a(
287
- "legend",
288
- {
289
- id: `group-${t}`,
290
- className: "text-xs font-semibold text-gray-700 dark:text-white-alpha-700 mb-2 px-1",
291
- children: e.label
292
- }
293
- ),
294
- e.helpText && /* @__PURE__ */ a("div", { className: q, children: e.helpText }),
295
- /* @__PURE__ */ a("div", { className: "space-y-3", children: e.children.map((i) => /* @__PURE__ */ a(U, { node: i, pathPrefix: t, autoFocusPath: r }, i.id)) })
296
- ]
297
- }
298
- ), xe = ({
299
- node: e,
300
- path: t,
301
- autoFocusPath: r
302
- }) => {
303
- const { register: i, control: l } = z(), s = e.required !== !1, o = `askuser-${t.replace(/\./g, "-")}`, f = `${o}-error`, u = `${o}-help`, { errors: A } = V({ control: l, name: t }), c = G(A, t), v = I(
304
- () => r !== void 0 && r.join(".") === t,
305
- [r, t]
306
- ), k = /* @__PURE__ */ n("label", { htmlFor: o, className: F, children: [
307
- e.label,
308
- s && /* @__PURE__ */ a("span", { "aria-label": "required", className: "text-red-500 ml-0.5", children: "*" })
309
- ] }), x = /* @__PURE__ */ n(W, { children: [
310
- e.helpText && /* @__PURE__ */ a("div", { id: u, className: q, children: e.helpText }),
311
- c && /* @__PURE__ */ a("div", { id: f, role: "alert", className: R, children: c })
312
- ] });
313
- if (e.type === "boolean")
314
- return /* @__PURE__ */ a(
315
- Y,
316
- {
317
- name: t,
318
- control: l,
319
- render: ({ field: m }) => /* @__PURE__ */ n("div", { className: "flex items-start gap-3", children: [
320
- /* @__PURE__ */ a(
321
- "button",
322
- {
323
- type: "button",
324
- role: "switch",
325
- id: o,
326
- "aria-checked": !!m.value,
327
- "aria-required": s,
328
- "aria-invalid": !!c,
329
- "aria-describedby": b(e.helpText && u, c && f) || void 0,
330
- onClick: () => m.onChange(!m.value),
331
- onBlur: m.onBlur,
332
- ref: v ? B : void 0,
333
- className: b(
334
- "inline-flex h-5 w-9 items-center rounded-full border transition-colors mt-0.5",
335
- "border-gray-200 dark:border-white-alpha-200",
336
- "focus:outline-none focus:ring-1 focus:ring-inkeep-expanded-primary-500",
337
- m.value ? "bg-inkeep-expanded-primary-500" : "bg-gray-100 dark:bg-white-alpha-100"
338
- ),
339
- children: /* @__PURE__ */ a(
340
- "span",
341
- {
342
- className: b(
343
- "inline-block h-3.5 w-3.5 rounded-full bg-white shadow transform transition-transform",
344
- m.value ? "translate-x-4" : "translate-x-0.5"
345
- )
346
- }
347
- )
348
- }
349
- ),
350
- /* @__PURE__ */ n("div", { className: "flex flex-col flex-1", children: [
351
- k,
352
- x
353
- ] })
354
- ] })
355
- }
356
- );
357
- if (e.type === "multiline")
358
- return /* @__PURE__ */ n("div", { className: "flex flex-col gap-1", children: [
359
- k,
360
- /* @__PURE__ */ a(
361
- Y,
362
- {
363
- name: t,
364
- control: l,
365
- render: ({ field: m }) => /* @__PURE__ */ a(
366
- be,
367
- {
368
- id: o,
369
- value: m.value ?? "",
370
- onChange: (h) => m.onChange(h.target.value),
371
- onBlur: m.onBlur,
372
- placeholder: e.placeholder,
373
- autoComplete: e.autocomplete ?? "off",
374
- "aria-required": s,
375
- "aria-invalid": !!c,
376
- "aria-describedby": b(e.helpText && u, c && f) || void 0,
377
- focusOnMount: v,
378
- className: b(L, "w-full resize-none min-h-[60px]")
379
- }
380
- )
381
- }
382
- ),
383
- x
384
- ] });
385
- if (e.options && e.options.length > 0) {
386
- const m = i(t);
387
- return /* @__PURE__ */ n("div", { className: "flex flex-col gap-1", children: [
388
- k,
389
- /* @__PURE__ */ n(
390
- "select",
391
- {
392
- id: o,
393
- ...m,
394
- ref: (h) => {
395
- m.ref(h), v && B(h);
396
- },
397
- "aria-required": s,
398
- "aria-invalid": !!c,
399
- "aria-describedby": b(e.helpText && u, c && f) || void 0,
400
- className: b(L, P(e.width)),
401
- children: [
402
- !s && /* @__PURE__ */ a("option", { value: "", children: "—" }),
403
- e.options.map((h) => /* @__PURE__ */ a("option", { value: h.value, children: h.label ?? h.value }, h.value))
404
- ]
405
- }
406
- ),
407
- x
408
- ] });
409
- }
410
- const w = e.type === "date" ? "date" : e.type === "email" ? "email" : "text", T = e.type === "number" ? "numeric" : void 0, N = i(t);
411
- return /* @__PURE__ */ n("div", { className: "flex flex-col gap-1", children: [
412
- k,
413
- /* @__PURE__ */ a(
414
- "input",
415
- {
416
- id: o,
417
- type: w,
418
- inputMode: T,
419
- placeholder: e.placeholder,
420
- autoComplete: e.autocomplete ?? "off",
421
- "aria-required": s,
422
- "aria-invalid": !!c,
423
- "aria-describedby": b(e.helpText && u, c && f) || void 0,
424
- ...N,
425
- ref: (m) => {
426
- N.ref(m), v && B(m);
427
- },
428
- className: b(L, P(e.width))
429
- }
430
- ),
431
- x
432
- ] });
433
- };
434
- function B(e) {
435
- e && requestAnimationFrame(() => {
436
- typeof e.focus == "function" && e.focus();
437
- });
438
- }
439
- const be = ({ value: e, className: t, focusOnMount: r, ...i }) => {
440
- const l = ee(null);
441
- return O(() => {
442
- const s = l.current;
443
- if (!s) return;
444
- s.style.height = "0";
445
- const o = Math.min(s.scrollHeight, 200);
446
- s.style.height = `${o}px`;
447
- }, [e]), O(() => {
448
- r && requestAnimationFrame(() => l.current?.focus());
449
- }, []), /* @__PURE__ */ a("textarea", { ref: l, value: e, className: t, rows: 3, ...i });
450
- }, ge = ({ node: e, path: t }) => {
451
- const { control: r, setValue: i, trigger: l } = z(), s = ae({ control: r, name: t }), o = Array.isArray(s) ? s : [], f = `askuser-${t.replace(/\./g, "-")}`, u = `${f}-error`, { errors: A } = V({ control: r, name: t }), c = G(A, t), v = (e.min ?? 0) > 0, k = e.max ?? Number.POSITIVE_INFINITY, x = o.length >= k, [w, T] = X(""), N = S(
452
- (d) => {
453
- i(t, d, { shouldValidate: !0, shouldDirty: !0, shouldTouch: !0 });
454
- },
455
- [i, t]
456
- ), m = S(
457
- (d) => {
458
- N([...o, d]);
459
- },
460
- [o, N]
461
- ), h = S(
462
- (d) => {
463
- N(o.filter((y, g) => g !== d));
464
- },
465
- [o, N]
466
- ), $ = S(() => {
467
- const d = w.trim();
468
- if (!d || x) return;
469
- let y;
470
- if (e.itemType === "number") {
471
- const g = Number(d);
472
- if (Number.isNaN(g)) return;
473
- y = g;
474
- } else e.itemType === "boolean" ? y = d === "true" : y = d;
475
- m(y), T("");
476
- }, [w, x, e.itemType, m]), K = (d) => {
477
- d.key === "Enter" || d.key === "," ? (d.preventDefault(), $()) : d.key === "Backspace" && w === "" && o.length > 0 && h(o.length - 1);
478
- };
479
- return e.options && e.options.length > 0 ? /* @__PURE__ */ n("div", { className: "flex flex-col gap-1", children: [
480
- /* @__PURE__ */ n("label", { htmlFor: f, className: F, children: [
481
- e.label,
482
- v && /* @__PURE__ */ a("span", { "aria-label": "required", className: "text-red-500 ml-0.5", children: "*" })
483
- ] }),
484
- /* @__PURE__ */ a("fieldset", { className: "flex flex-wrap gap-1.5", id: f, children: e.options.map((d) => {
485
- const y = o.findIndex((j) => j === d.value), g = y >= 0;
486
- return /* @__PURE__ */ a(
487
- "button",
488
- {
489
- type: "button",
490
- "aria-pressed": g,
491
- onClick: () => {
492
- g ? h(y) : x || m(d.value), l(t);
493
- },
494
- className: b(
495
- "inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-2xs border transition-colors",
496
- g ? "bg-inkeep-expanded-primary-500 text-white border-inkeep-expanded-primary-500" : "bg-white dark:bg-gray-dark-900 text-gray-700 dark:text-white-alpha-700 border-gray-200 dark:border-white-alpha-200 hover:bg-gray-50 dark:hover:bg-white-alpha-50"
497
- ),
498
- children: d.label ?? d.value
499
- },
500
- d.value
501
- );
502
- }) }),
503
- e.helpText && /* @__PURE__ */ a("div", { className: q, children: e.helpText }),
504
- c && /* @__PURE__ */ a("div", { id: u, role: "alert", className: R, children: c })
505
- ] }) : /* @__PURE__ */ n("div", { className: "flex flex-col gap-1", children: [
506
- /* @__PURE__ */ n("label", { htmlFor: f, className: F, children: [
507
- e.label,
508
- v && /* @__PURE__ */ a("span", { "aria-label": "required", className: "text-red-500 ml-0.5", children: "*" })
509
- ] }),
510
- /* @__PURE__ */ n(
511
- "div",
512
- {
513
- className: b(
514
- L,
515
- "w-full flex flex-wrap gap-1 items-center cursor-text min-h-[32px] py-1"
516
- ),
517
- onClick: () => document.getElementById(f)?.focus(),
518
- children: [
519
- o.map((d, y) => {
520
- const g = J(d);
521
- return /* @__PURE__ */ n(
522
- "span",
523
- {
524
- className: "inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-gray-100 dark:bg-white-alpha-100 text-2xs text-gray-700 dark:text-white-alpha-700",
525
- children: [
526
- g,
527
- /* @__PURE__ */ a(
528
- "button",
529
- {
530
- type: "button",
531
- onClick: (j) => {
532
- j.stopPropagation(), h(y);
533
- },
534
- "aria-label": `Remove ${g}`,
535
- className: "text-gray-500 hover:text-gray-700 dark:text-white-alpha-500 dark:hover:text-white-alpha-700",
536
- children: "×"
537
- }
538
- )
539
- ]
540
- },
541
- `${g}-${y}`
542
- );
543
- }),
544
- /* @__PURE__ */ a(
545
- "input",
546
- {
547
- id: f,
548
- type: e.itemType === "number" ? "text" : e.itemType === "email" ? "email" : "text",
549
- inputMode: e.itemType === "number" ? "numeric" : void 0,
550
- value: w,
551
- placeholder: o.length === 0 ? e.placeholder ?? "Type and press Enter…" : "",
552
- onChange: (d) => T(d.target.value),
553
- onKeyDown: K,
554
- onBlur: $,
555
- "aria-required": v,
556
- "aria-invalid": !!c,
557
- "aria-describedby": c ? u : void 0,
558
- disabled: x,
559
- className: "flex-1 min-w-[80px] outline-none bg-transparent text-xs"
560
- }
561
- )
562
- ]
563
- }
564
- ),
565
- e.helpText && /* @__PURE__ */ a("div", { className: q, children: e.helpText }),
566
- c && /* @__PURE__ */ a("div", { id: u, role: "alert", className: R, children: c })
567
- ] });
568
- };
569
- function J(e) {
570
- if (e == null) return "";
571
- if (typeof e == "string" || typeof e == "number" || typeof e == "boolean")
572
- return String(e);
573
- try {
574
- return JSON.stringify(e);
575
- } catch {
576
- return "";
577
- }
578
- }
579
- const ye = ({ node: e, path: t, autoFocusPath: r }) => {
580
- const { control: i } = z(), { errors: l } = V({ control: i, name: t }), { fields: s, append: o, remove: f } = ie({ control: i, name: t }), u = `askuser-${t.replace(/\./g, "-")}`, A = `${u}-error`, c = G(l, t), v = (e.min ?? 0) > 0, k = e.max ?? Number.POSITIVE_INFINITY, x = s.length >= k, w = e.min ?? 0, T = s.length > w, N = S(() => {
581
- x || o(E(e.item.children));
582
- }, [o, x, e.item.children]);
583
- return /* @__PURE__ */ n(
584
- "fieldset",
585
- {
586
- className: "border-l-2 border-gray-100 dark:border-white-alpha-100 pl-3",
587
- "aria-labelledby": `grouplist-${u}`,
588
- children: [
589
- /* @__PURE__ */ n(
590
- "legend",
591
- {
592
- id: `grouplist-${u}`,
593
- className: "text-xs font-semibold text-gray-700 dark:text-white-alpha-700 mb-2 px-1",
594
- children: [
595
- e.label,
596
- v && /* @__PURE__ */ a("span", { "aria-label": "required", className: "text-red-500 ml-0.5", children: "*" })
597
- ]
598
- }
599
- ),
600
- e.helpText && /* @__PURE__ */ a("div", { className: q, children: e.helpText }),
601
- /* @__PURE__ */ a("div", { className: "space-y-3", children: s.length === 0 ? /* @__PURE__ */ n("div", { className: "text-2xs text-gray-500 dark:text-white-alpha-500 italic", children: [
602
- "No rows yet — click “",
603
- e.addLabel ?? "Add row",
604
- "” below."
605
- ] }) : s.map((m, h) => /* @__PURE__ */ n(
606
- "div",
607
- {
608
- className: "relative pl-2 py-2 rounded-md bg-gray-50/50 dark:bg-white-alpha-50/50",
609
- children: [
610
- /* @__PURE__ */ n("div", { className: "flex items-start justify-between mb-1", children: [
611
- /* @__PURE__ */ n("span", { className: "text-2xs font-medium text-gray-500 dark:text-white-alpha-500 uppercase tracking-wider", children: [
612
- "#",
613
- h + 1
614
- ] }),
615
- T && /* @__PURE__ */ a(
616
- "button",
617
- {
618
- type: "button",
619
- onClick: () => f(h),
620
- "aria-label": `Remove row ${h + 1}`,
621
- className: "text-2xs text-gray-500 hover:text-red-500 dark:text-white-alpha-500",
622
- children: "Remove"
623
- }
624
- )
625
- ] }),
626
- /* @__PURE__ */ a("div", { className: "space-y-3", children: e.item.children.map(($) => /* @__PURE__ */ a(
627
- U,
628
- {
629
- node: $,
630
- pathPrefix: `${t}.${h}`,
631
- autoFocusPath: r
632
- },
633
- $.id
634
- )) })
635
- ]
636
- },
637
- m.id
638
- )) }),
639
- /* @__PURE__ */ a("div", { className: "mt-2", children: /* @__PURE__ */ n(
640
- "button",
641
- {
642
- type: "button",
643
- onClick: N,
644
- disabled: x,
645
- className: b(D({ size: "xs", variant: "outline" })),
646
- children: [
647
- "+ ",
648
- e.addLabel ?? "Add row"
649
- ]
650
- }
651
- ) }),
652
- c && /* @__PURE__ */ a("div", { id: A, role: "alert", className: R, children: c })
653
- ]
654
- }
655
- );
656
- };
657
- function G(e, t) {
658
- const r = t.split(".");
659
- let i = e;
660
- for (const l of r)
661
- if (i && typeof i == "object" && l in i)
662
- i = i[l];
663
- else
664
- return;
665
- if (i && typeof i == "object" && "message" in i) {
666
- const l = i.message;
667
- return typeof l == "string" ? l : void 0;
668
- }
669
- }
670
- export {
671
- Se as AskUserForm
672
- };