jaguar-form 1.0.4 → 1.0.6

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 (64) hide show
  1. package/README.md +38 -2
  2. package/dist/Cascader-ZIkXvvC3.js +226 -0
  3. package/dist/Select-BIBk_TT6.js +415 -0
  4. package/dist/TreeSelect-BQCyCCqa.js +350 -0
  5. package/dist/{compound-D4_6P0d_.js → compound-BX_PoTK5.js} +100 -88
  6. package/dist/compound.js +1 -1
  7. package/dist/core.js +1 -1
  8. package/dist/date-time.js +1 -1
  9. package/dist/demo-plant.svg +1 -0
  10. package/dist/form-CSfUExUT.js +599 -0
  11. package/dist/form.js +3 -3
  12. package/dist/{icons-BI3fdIey.js → icons-BwE05e0C.js} +1 -1
  13. package/dist/{image-upload-VtUlQgzJ.js → image-upload-D9oPG0Eh.js} +252 -179
  14. package/dist/image-upload.js +1 -1
  15. package/dist/index.js +15 -14
  16. package/dist/input.js +1 -1
  17. package/dist/inputs-Dx3xOy9q.js +718 -0
  18. package/dist/{useSelection-C0OEFZUE.js → lazy-tree-NCX3ntYm.js} +96 -4
  19. package/dist/locale/load.js +7 -3
  20. package/dist/pickers-Bci1y8cc.js +634 -0
  21. package/dist/select.js +3 -1
  22. package/dist/selection-DCIzhR5q.js +197 -0
  23. package/dist/{slider-CNwkLMmo.js → slider-AM0Egz9P.js} +1 -1
  24. package/dist/slider.js +1 -1
  25. package/dist/store-CFSQW-Fv.js +622 -0
  26. package/dist/style.css +1 -1
  27. package/dist/tree-select.js +1 -1
  28. package/dist/types/components/compound/ControlGroup.d.ts +5 -2
  29. package/dist/types/components/compound/index.d.ts +10 -1
  30. package/dist/types/components/extended-inputs.d.ts +34 -0
  31. package/dist/types/components/image-upload/ManagedImageUpload.d.ts +11 -4
  32. package/dist/types/components/image-upload/index.d.ts +3 -2
  33. package/dist/types/components/image-upload/upload.d.ts +1 -1
  34. package/dist/types/components/image-upload/usePreparation.d.ts +7 -0
  35. package/dist/types/components/image-upload/validation.d.ts +16 -0
  36. package/dist/types/components/inputs.d.ts +42 -4
  37. package/dist/types/components/select/Cascader.d.ts +13 -0
  38. package/dist/types/components/select/types.d.ts +10 -1
  39. package/dist/types/components/select/useRemoteOptions.d.ts +18 -0
  40. package/dist/types/components/select.d.ts +3 -0
  41. package/dist/types/config/index.d.ts +3 -0
  42. package/dist/types/entries/input.d.ts +5 -2
  43. package/dist/types/entries/select.d.ts +3 -0
  44. package/dist/types/form/adapter.d.ts +1 -0
  45. package/dist/types/form/index.d.ts +85 -10
  46. package/dist/types/form/store.d.ts +21 -1
  47. package/dist/types/locale/load.d.ts +2 -1
  48. package/dist/types/primitives/Control.d.ts +3 -1
  49. package/dist/types/primitives/Popup.d.ts +1 -0
  50. package/dist/types/types.d.ts +1 -0
  51. package/dist/types/utils/cascader.d.ts +12 -0
  52. package/dist/types/utils/decimal.d.ts +22 -0
  53. package/dist/types/utils/remote-options.d.ts +24 -0
  54. package/dist/useControllable-QDX_UWRh.js +102 -0
  55. package/package.json +1 -1
  56. package/dist/Control-B36bu6zQ.js +0 -47
  57. package/dist/Select-BG2H-YnK.js +0 -252
  58. package/dist/TreeSelect-CkPtMg-g.js +0 -440
  59. package/dist/form-DTI0Sqsy.js +0 -413
  60. package/dist/inputs-BOP8Ryne.js +0 -403
  61. package/dist/pickers-C9QTR2XN.js +0 -631
  62. package/dist/selection-CIEa1uce.js +0 -146
  63. package/dist/store-DOn9K-EA.js +0 -491
  64. package/dist/useControllable-Zax42z2F.js +0 -87
@@ -0,0 +1,599 @@
1
+ import { d as e, l as t, s as n, t as r, u as i } from "./compound-BX_PoTK5.js";
2
+ import { a, i as o } from "./useControllable-QDX_UWRh.js";
3
+ import { r as s } from "./locale-yHkdw2xz.js";
4
+ import { n as c, t as l } from "./slider-AM0Egz9P.js";
5
+ import { i as u, t as d } from "./image-upload-D9oPG0Eh.js";
6
+ import { cloneElement as f, createContext as p, isValidElement as m, useCallback as h, useContext as g, useEffect as _, useId as v, useMemo as y, useRef as b, useState as x, useSyncExternalStore as S } from "react";
7
+ import { d as C, n as w, t as T } from "./store-CFSQW-Fv.js";
8
+ import { c as E, d as D, f as O, g as k, h as A, l as j, m as M, n as N, o as P, p as F, r as I, s as L, t as R, u as z } from "./inputs-Dx3xOy9q.js";
9
+ import { n as B, t as V } from "./Select-BIBk_TT6.js";
10
+ import { t as H } from "./TreeSelect-BQCyCCqa.js";
11
+ import { n as U } from "./validation-D6vk5NAv.js";
12
+ import { t as ee } from "./Cascader-ZIkXvvC3.js";
13
+ import { a as W, c as G, i as K, l as te, n as ne, o as re, r as ie, s as ae, t as oe, u as se } from "./pickers-Bci1y8cc.js";
14
+ import { jsx as q, jsxs as J } from "react/jsx-runtime";
15
+ // src/form/index.tsx
16
+ var ce = p(null);
17
+ function le(e = {}) {
18
+ let t = b(e.onSubmit);
19
+ t.current = e.onSubmit;
20
+ let [n] = x(() => {
21
+ let n = e.fields ?? [], r = {
22
+ ...Object.fromEntries(n.map((e) => [e.name, be(e)])),
23
+ ...typeof e.defaultValues == "function" ? {} : e.defaultValues
24
+ }, i = Object.fromEntries(n.filter((e) => e.transform).map((e) => [e.name, e.transform]));
25
+ return T(r, {
26
+ onSubmit: (e) => t.current?.(e),
27
+ nested: e.nested,
28
+ initialValues: e.initialValues,
29
+ adapter: {
30
+ ...e.adapter,
31
+ fields: {
32
+ ...i,
33
+ ...e.adapter?.fields
34
+ }
35
+ }
36
+ });
37
+ }), r = typeof e.defaultValues == "function" ? e.defaultValues : void 0, i = b(r);
38
+ return i.current = r, _(() => {
39
+ let e = i.current;
40
+ if (!e) return;
41
+ let t = new AbortController();
42
+ n.setLoading(!0);
43
+ let r = n.getDataVersion();
44
+ return Promise.resolve().then(() => e({ signal: t.signal })).then((e) => {
45
+ !t.signal.aborted && r === n.getDataVersion() && !n.getFormSummary().isDirty && n.loadDefaults(e);
46
+ }).catch((e) => {
47
+ t.signal.aborted || n.setLoadError(e);
48
+ }).finally(() => {
49
+ t.signal.aborted || n.setLoading(!1);
50
+ }), () => {
51
+ t.abort(), n.setLoading(!1);
52
+ };
53
+ }, [
54
+ n,
55
+ !!r,
56
+ e.defaultValuesKey
57
+ ]), n;
58
+ }
59
+ function ue({ form: e, children: t }) {
60
+ return /* @__PURE__ */ q(ce.Provider, {
61
+ value: e,
62
+ children: t
63
+ });
64
+ }
65
+ function Y() {
66
+ let e = g(ce);
67
+ if (!e) throw Error("FormProvider is required");
68
+ return e;
69
+ }
70
+ function X(e) {
71
+ let t = Y(), n = h((n) => t.subscribe(e, n), [t, e]), r = h(() => t.getFieldState(e), [t, e]), i = S(n, r, r);
72
+ return {
73
+ ...i,
74
+ value: i.value,
75
+ setValue: (n) => t.setValue(e, n),
76
+ onBlur: () => t.blur(e)
77
+ };
78
+ }
79
+ function de(e) {
80
+ let t = Y(), n = h((n) => t.subscribe(e, n), [t, e]), r = h(() => t.getValue(e), [t, e]);
81
+ return S(n, r, r);
82
+ }
83
+ function fe(e) {
84
+ let t = Y(), n = de(e), r = v(), i = b(0), a = b([]), o = (e) => ({
85
+ key: `${r}-${++i.current}`,
86
+ value: e
87
+ }), s = (e) => {
88
+ let t = [...a.current];
89
+ return e.map((e) => {
90
+ let n = t.findIndex((t) => w(t.value, e));
91
+ return n < 0 ? o(e) : {
92
+ ...t.splice(n, 1)[0],
93
+ value: e
94
+ };
95
+ });
96
+ }, c = y(() => s(Array.isArray(n) ? n : []), [n]);
97
+ _(() => {
98
+ a.current = c;
99
+ }, [c]);
100
+ let l = (n) => {
101
+ let r = t.getValue(e), i = s(Array.isArray(r) ? r : []), c = n.type === "insert" ? {
102
+ ...n,
103
+ value: o(n.value)
104
+ } : n.type === "update" ? {
105
+ ...n,
106
+ value: {
107
+ key: i[n.index]?.key ?? "",
108
+ value: n.value
109
+ }
110
+ } : n, l = C(i, c);
111
+ return a.current = l, t.editFieldArray(e, n);
112
+ };
113
+ return {
114
+ fields: c,
115
+ append: (n) => {
116
+ let r = t.getValue(e);
117
+ return l({
118
+ type: "insert",
119
+ index: Array.isArray(r) ? r.length : 0,
120
+ value: n
121
+ });
122
+ },
123
+ prepend: (e) => l({
124
+ type: "insert",
125
+ index: 0,
126
+ value: e
127
+ }),
128
+ insert: (e, t) => l({
129
+ type: "insert",
130
+ index: e,
131
+ value: t
132
+ }),
133
+ remove: (e) => l({
134
+ type: "remove",
135
+ index: e
136
+ }),
137
+ move: (e, t) => l({
138
+ type: "move",
139
+ from: e,
140
+ to: t
141
+ }),
142
+ update: (e, t) => l({
143
+ type: "update",
144
+ index: e,
145
+ value: t
146
+ }),
147
+ replace: (n) => t.setValue(e, n)
148
+ };
149
+ }
150
+ function pe(e = (e) => e) {
151
+ let t = Y(), n = b(null), r = h(() => {
152
+ let r = e(t.getFormSummary());
153
+ return n.current && w(n.current.value, r) ? n.current.value : (n.current = { value: r }, r);
154
+ }, [t, e]);
155
+ return S(t.subscribeAll, r, r);
156
+ }
157
+ function me(e) {
158
+ return S(e.subscribeAll, e.getFormSummary, e.getFormSummary);
159
+ }
160
+ function he() {
161
+ let e = Y();
162
+ return S(e.subscribeAll, e.getVersion, e.getVersion), {
163
+ values: e.getValues(),
164
+ changedValues: e.getChangedValues()
165
+ };
166
+ }
167
+ var Z = (e, t = 1) => Number.isFinite(e) ? Math.max(1, Math.min(24, Math.floor(e))) : t;
168
+ function ge(e, t, n = !1) {
169
+ let r = typeof t == "number" ? n ? 1 : Z(t) : Z(t.xs), i = typeof t == "number" ? Z(t) : Z(t.sm, r), a = typeof t == "number" ? i : Z(t.md, i), o = typeof t == "number" ? a : Z(t.lg, a);
170
+ return {
171
+ [`--rfe-${e}-xs`]: r,
172
+ [`--rfe-${e}-sm`]: i,
173
+ [`--rfe-${e}-md`]: a,
174
+ [`--rfe-${e}-lg`]: o
175
+ };
176
+ }
177
+ var _e = (e) => e, ve = {
178
+ compound: r,
179
+ imageUpload: d,
180
+ input: P,
181
+ number: L,
182
+ decimal: A,
183
+ tags: k,
184
+ autocomplete: M,
185
+ password: E,
186
+ textarea: F,
187
+ switch: O,
188
+ checkbox: N,
189
+ radio: j,
190
+ checkboxGroup: I,
191
+ select: B,
192
+ multiSelect: V,
193
+ treeSelect: H,
194
+ cascader: ee,
195
+ date: oe,
196
+ dateRange: ne,
197
+ time: ae,
198
+ timeRange: G,
199
+ dateTime: ie,
200
+ dateTimeRange: K,
201
+ month: W,
202
+ year: te,
203
+ monthRange: re,
204
+ yearRange: se,
205
+ search: z,
206
+ segmented: D,
207
+ slider: c,
208
+ rangeSlider: l
209
+ };
210
+ function Q({ label: e, description: t, error: n, required: r, id: i, children: a, span: o = 1, placement: s, name: c }) {
211
+ return /* @__PURE__ */ J("div", {
212
+ className: "rfe-field",
213
+ "data-field-name": c,
214
+ "data-label-placement": s,
215
+ style: {
216
+ gridColumn: `span ${Z(typeof o == "number" ? o : o.xs)}`,
217
+ ...ge("span", o)
218
+ },
219
+ children: [e && /* @__PURE__ */ J("label", {
220
+ htmlFor: i,
221
+ className: "rfe-field-label",
222
+ children: [r && /* @__PURE__ */ q("span", {
223
+ className: "rfe-required",
224
+ "aria-hidden": "true",
225
+ children: "* "
226
+ }), e]
227
+ }), /* @__PURE__ */ J("div", {
228
+ className: "rfe-field-content",
229
+ children: [a, n ? /* @__PURE__ */ q("div", {
230
+ id: i ? `${i}-help` : void 0,
231
+ role: "alert",
232
+ className: "rfe-error",
233
+ children: n
234
+ }) : t && /* @__PURE__ */ q("div", {
235
+ id: i ? `${i}-help` : void 0,
236
+ className: "rfe-description",
237
+ children: t
238
+ })]
239
+ })]
240
+ });
241
+ }
242
+ var ye = (e, t) => typeof e.visible == "function" ? e.visible(t) : e.visible !== !1, $ = (e) => e.type === "compound" && Array.isArray(e.componentProps?.fields) ? e.componentProps.fields : void 0, be = (e) => e.defaultValue === void 0 ? $(e) ? n($(e)) : void 0 : e.defaultValue;
243
+ function xe(e) {
244
+ return [
245
+ ...e.required && !e.rules?.some((e) => e.required) ? [{ required: !0 }] : [],
246
+ ...e.rules ?? [],
247
+ ...e.type === "imageUpload" && e.componentProps?.mode === "upload" ? [u] : []
248
+ ];
249
+ }
250
+ function Se(n, r, a, o) {
251
+ let s = JSON.stringify(a?.map((e) => e.name) ?? []), c = b(a);
252
+ c.current = a;
253
+ let l = y(() => c.current?.map((a) => ({
254
+ key: a.name,
255
+ config: {
256
+ validateOn: o,
257
+ defaultValue: a.defaultValue,
258
+ dependsOn: c.current.map((e) => `${r}.${e.name}`),
259
+ visible: () => {
260
+ let o = c.current ?? [], s = o.find((e) => e.name === a.name), l = t(o, n.getValue(r));
261
+ return !!s && e(s, l) && !i(s, l);
262
+ },
263
+ rules: [{ validate: async (e, i, { signal: o }) => {
264
+ let s = c.current ?? [], l = s.find((e) => e.name === a.name);
265
+ if (l) return U(e, t(s, n.getValue(r)), [...l.required ? [{ required: !0 }] : [], ...l.rules ?? []], o);
266
+ } }]
267
+ }
268
+ })) ?? [], [
269
+ n,
270
+ r,
271
+ s,
272
+ o
273
+ ]);
274
+ if (_(() => {
275
+ let e = l.map(({ key: e, config: t }) => n.registerCompoundPart(r, e, t));
276
+ return () => e.forEach((e) => e());
277
+ }, [
278
+ n,
279
+ r,
280
+ s
281
+ ]), _(() => {
282
+ for (let { key: e, config: t } of l) n.updateField(`${r}.${e}`, t);
283
+ }, [
284
+ n,
285
+ r,
286
+ l
287
+ ]), !a) return;
288
+ let u = Object.fromEntries(a.map((e) => [e.name, n.getFieldState(`${r}.${e.name}`)]));
289
+ return {
290
+ states: u,
291
+ error: Object.values(u).find((e) => e.error),
292
+ onPartChange: (e, t) => {
293
+ n.setValue(`${r}.${e}`, t);
294
+ },
295
+ onPartBlur: (e) => {
296
+ n.blur(`${r}.${e}`);
297
+ }
298
+ };
299
+ }
300
+ function Ce({ field: e, components: t, fields: n, validateOn: r }) {
301
+ let i = Y(), o = X(e.name), c = a(), l = v(), u = e.dependsOn, d = g(Ee), f = e.labelPlacement ?? d, p = g(Oe), m = y(() => ({
302
+ rules: xe(e),
303
+ debounce: e.debounce,
304
+ dependsOn: u,
305
+ validateOn: e.validateOn ?? r,
306
+ defaultValue: be(e),
307
+ visible: (t) => ye(e, t)
308
+ }), [
309
+ e,
310
+ u,
311
+ r
312
+ ]);
313
+ _(() => i.registerField(e.name, { ...m }), [i, e.name]), _(() => i.updateField(e.name, m), [
314
+ i,
315
+ e.name,
316
+ m
317
+ ]);
318
+ let b = Se(i, e.name, $(e), e.validateOn ?? r), x = o.error ? o : b?.error ?? o, C = h((t) => {
319
+ if (!u) return typeof e.visible == "function" || typeof e.disabled == "function" ? i.subscribeAll(t) : () => {};
320
+ let n = u.map((e) => i.subscribe(e, t));
321
+ return () => n.forEach((e) => e());
322
+ }, [
323
+ i,
324
+ u,
325
+ e.visible,
326
+ e.disabled
327
+ ]);
328
+ S(C, i.getVersion, i.getVersion);
329
+ let w = typeof e.visible == "function" || typeof e.disabled == "function" ? i.getValues() : Ae;
330
+ if (!ye(e, w)) return null;
331
+ let T = t[e.type] ?? ve[e.type], E = f === "floating" && typeof e.label == "string" && we.has(e.type) && !e.render && !t[e.type], D = {
332
+ ...e.componentProps,
333
+ ...b ? {
334
+ partStates: b.states,
335
+ onPartChange: b.onPartChange,
336
+ onPartBlur: b.onPartBlur
337
+ } : {},
338
+ ...E ? { floatingLabel: e.label } : {},
339
+ ...typeof e.label == "string" ? { "aria-label": e.label } : {},
340
+ id: l,
341
+ name: e.name,
342
+ value: o.value ?? ([
343
+ "input",
344
+ "password",
345
+ "textarea",
346
+ "search",
347
+ "autocomplete"
348
+ ].includes(e.type) ? "" : e.type === "switch" || e.type === "checkbox" ? !1 : e.type === "imageUpload" || e.type === "tags" || e.type === "cascader" || e.type === "multiSelect" || e.type === "checkboxGroup" || e.type === "treeSelect" && e.componentProps?.multiple ? [] : e.type === "slider" ? 0 : e.type === "rangeSlider" ? [0, 100] : null),
349
+ onChange: (t) => {
350
+ i.setValue(e.name, t);
351
+ },
352
+ onBlur: () => {
353
+ i.blur(e.name);
354
+ },
355
+ status: x.error ? "error" : "default",
356
+ "aria-invalid": !!x.error,
357
+ disabled: p.disabled || p.loading || (typeof e.disabled == "function" ? e.disabled(w) : e.disabled ?? e.componentProps?.disabled),
358
+ readOnly: p.readOnly || e.componentProps?.readOnly,
359
+ "aria-describedby": x.error || e.description ? `${l}-help` : void 0
360
+ };
361
+ return /* @__PURE__ */ J(Q, {
362
+ name: e.name,
363
+ placement: f,
364
+ label: E || f === "none" ? void 0 : e.label,
365
+ required: e.required,
366
+ description: e.description,
367
+ error: s(x.issue, x.error, c),
368
+ id: l,
369
+ span: e.span,
370
+ children: [e.render ? e.render(D) : T ? /* @__PURE__ */ q(T, { ...D }) : /* @__PURE__ */ q("div", {
371
+ className: "rfe-error",
372
+ children: c.t("unknownField", { type: e.type })
373
+ }), o.validating && /* @__PURE__ */ q("small", {
374
+ role: "status",
375
+ className: "rfe-description",
376
+ children: c.t("validating")
377
+ })]
378
+ });
379
+ }
380
+ var we = /* @__PURE__ */ new Set([
381
+ "input",
382
+ "password",
383
+ "search",
384
+ "number",
385
+ "decimal",
386
+ "select",
387
+ "multiSelect",
388
+ "treeSelect",
389
+ "date",
390
+ "dateRange",
391
+ "time",
392
+ "timeRange",
393
+ "dateTime",
394
+ "dateTimeRange",
395
+ "month",
396
+ "year",
397
+ "monthRange",
398
+ "yearRange",
399
+ "compound",
400
+ "cascader"
401
+ ]), Te = new Set([...we].map((e) => ve[e])), Ee = p(void 0), De = p("blur"), Oe = p({
402
+ disabled: !1,
403
+ readOnly: !1,
404
+ loading: !1
405
+ }), ke = [], Ae = {}, je = {};
406
+ function Me({ nested: e, initialValues: t, adapter: n, submitHiddenFields: r = !1, validateOn: i = "blur", form: s, fields: c = ke, defaultValues: l = Ae, defaultValuesKey: u, components: d = je, children: f, columns: p = 1, responsive: m = !1, gap: h, labelPlacement: g, disabled: v = !1, readOnly: S = !1, loading: C = !1, layout: w = "vertical", onSubmit: T, onError: E, submitText: D, resetText: O, showActions: k = !0 }) {
407
+ let A = a(), j = o(), M = le(s ? {} : {
408
+ fields: c,
409
+ defaultValues: l,
410
+ defaultValuesKey: u,
411
+ initialValues: t,
412
+ adapter: n,
413
+ nested: e
414
+ }), N = s ?? M, P = me(N), F = P.isSubmitting;
415
+ C ||= P.isLoading;
416
+ let [I, L] = x(""), z = b(null);
417
+ _(() => N.bindFieldLocator((e, t) => {
418
+ let n = [...z.current?.querySelectorAll("[data-field-name]") ?? []].find((t) => t.dataset.fieldName === e), r = [...z.current?.querySelectorAll("[data-compound-field]") ?? []].find((t) => t.dataset.compoundField === e) ?? n;
419
+ if (!r) return !1;
420
+ let i = r.querySelector("input:not(:disabled):not([type=hidden]),textarea:not(:disabled),button:not(:disabled),[tabindex=\"0\"]");
421
+ return t && i?.focus({ preventScroll: !0 }), r.scrollIntoView({ block: "nearest" }), !t || !!i;
422
+ }), [N]);
423
+ let B = () => requestAnimationFrame(() => {
424
+ let e = z.current?.querySelector("input[aria-invalid=\"true\"],button[aria-invalid=\"true\"],textarea[aria-invalid=\"true\"],[tabindex][aria-invalid=\"true\"]");
425
+ e?.focus({ preventScroll: !0 }), e?.scrollIntoView({ block: "nearest" });
426
+ });
427
+ _(() => N.bindSubmission({
428
+ handler: T,
429
+ includeHidden: r,
430
+ invalid: B,
431
+ blocked: v || S || C
432
+ }), [
433
+ N,
434
+ T,
435
+ r,
436
+ v,
437
+ S,
438
+ C
439
+ ]);
440
+ let V = y(() => ({
441
+ disabled: v,
442
+ readOnly: S,
443
+ loading: C
444
+ }), [
445
+ v,
446
+ S,
447
+ C
448
+ ]), H = m || typeof p != "number", U = ge("grid", p, m);
449
+ return /* @__PURE__ */ q(ue, {
450
+ form: N,
451
+ children: /* @__PURE__ */ q(Ee.Provider, {
452
+ value: g ?? j.form?.labelPlacement,
453
+ children: /* @__PURE__ */ q(De.Provider, {
454
+ value: i,
455
+ children: /* @__PURE__ */ q(Oe.Provider, {
456
+ value: V,
457
+ children: /* @__PURE__ */ J("form", {
458
+ ref: z,
459
+ className: "rfe-form",
460
+ "data-responsive": m || void 0,
461
+ "data-responsive-grid": H || void 0,
462
+ style: {
463
+ ...U,
464
+ ...h === void 0 ? {} : { "--rfe-form-gap": typeof h == "number" ? `${h}px` : h }
465
+ },
466
+ "data-layout": w,
467
+ "aria-busy": C || F || void 0,
468
+ noValidate: !0,
469
+ onSubmit: async (e) => {
470
+ if (e.preventDefault(), !(v || S || C || N.getFormSummary().isSubmitting)) {
471
+ L("");
472
+ try {
473
+ await N.submit(T, r);
474
+ } catch (e) {
475
+ L(e instanceof Error ? e.message : A.t("submitFailed")), E?.(e);
476
+ }
477
+ }
478
+ },
479
+ children: [
480
+ /* @__PURE__ */ J("div", {
481
+ className: "rfe-form-grid",
482
+ style: H ? void 0 : { gridTemplateColumns: `repeat(${Z(typeof p == "number" ? p : 1)},minmax(0,1fr))` },
483
+ children: [c.map((e) => /* @__PURE__ */ q(Ce, {
484
+ field: e,
485
+ components: d,
486
+ fields: c,
487
+ validateOn: i
488
+ }, e.name)), f]
489
+ }),
490
+ I && /* @__PURE__ */ q("div", {
491
+ role: "alert",
492
+ className: "rfe-error",
493
+ children: I
494
+ }),
495
+ k && /* @__PURE__ */ J("div", {
496
+ className: "rfe-form-actions",
497
+ children: [/* @__PURE__ */ q(R, {
498
+ variant: "secondary",
499
+ disabled: F || v || S || C,
500
+ onClick: () => {
501
+ N.reset(), L("");
502
+ },
503
+ children: O ?? A.t("reset")
504
+ }), /* @__PURE__ */ q(R, {
505
+ type: "submit",
506
+ loading: F,
507
+ disabled: v || S || C,
508
+ children: D ?? A.t("save")
509
+ })]
510
+ })
511
+ ]
512
+ })
513
+ })
514
+ })
515
+ })
516
+ });
517
+ }
518
+ function Ne({ children: e, name: t, label: i, description: o, required: c, rules: l, defaultValue: p, dependsOn: b, debounce: x, validateOn: C, span: w, labelPlacement: T, disabled: E, visible: D, componentProps: O }) {
519
+ let k = Y(), A = g(De), j = g(Ee), M = T ?? j, N = g(Oe), P = C ?? A, F = X(t), I = a(), L = v(), R = m(e) && e.type === r ? e.props.fields : void 0, z = JSON.stringify(R?.map((e) => e.name) ?? []), B = m(e) && e.type === d && e.props.mode === "upload", V = y(() => ({
520
+ rules: [
521
+ ...c && !l?.some((e) => e.required) ? [{ required: !0 }] : [],
522
+ ...l ?? [],
523
+ ...B ? [u] : []
524
+ ],
525
+ defaultValue: p ?? (R ? n(R) : void 0),
526
+ dependsOn: b,
527
+ debounce: x,
528
+ validateOn: P,
529
+ visible: (e) => typeof D == "function" ? D(e) : D !== !1
530
+ }), [
531
+ c,
532
+ l,
533
+ p,
534
+ b,
535
+ x,
536
+ P,
537
+ D,
538
+ B,
539
+ z
540
+ ]);
541
+ _(() => k.registerField(t, { ...V }), [k, t]), _(() => k.updateField(t, V), [
542
+ k,
543
+ t,
544
+ V
545
+ ]);
546
+ let H = Se(k, t, R, P), U = F.error ? F : H?.error ?? F, ee = h((e) => typeof D == "function" || typeof E == "function" ? k.subscribeAll(e) : () => {}, [
547
+ k,
548
+ D,
549
+ E
550
+ ]);
551
+ S(ee, k.getVersion, k.getVersion);
552
+ let W = typeof D == "function" || typeof E == "function" ? k.getValues() : Ae;
553
+ if (!V.visible(W)) return null;
554
+ let G = M === "floating" && typeof i == "string" && m(e) && Te.has(e.type), K = {
555
+ ...O,
556
+ ...H ? {
557
+ partStates: H.states,
558
+ onPartChange: H.onPartChange,
559
+ onPartBlur: H.onPartBlur
560
+ } : {},
561
+ ...G ? { floatingLabel: i } : {},
562
+ ...typeof i == "string" ? { "aria-label": i } : {},
563
+ id: L,
564
+ name: t,
565
+ value: F.value,
566
+ onChange: (e) => {
567
+ k.setValue(t, e);
568
+ },
569
+ onBlur: () => {
570
+ k.blur(t);
571
+ },
572
+ disabled: N.disabled || N.loading || (typeof E == "function" ? E(W) : E) || O?.disabled === !0,
573
+ readOnly: N.readOnly || O?.readOnly === !0,
574
+ status: U.error ? "error" : "default",
575
+ "aria-invalid": !!U.error,
576
+ "aria-describedby": U.error || o ? `${L}-help` : void 0
577
+ };
578
+ return /* @__PURE__ */ J(Q, {
579
+ name: t,
580
+ placement: M,
581
+ id: L,
582
+ label: G || M === "none" ? void 0 : i,
583
+ required: c,
584
+ description: o,
585
+ error: s(U.issue, U.error, I),
586
+ span: w,
587
+ children: [typeof e == "function" ? e(K) : m(e) ? f(e, {
588
+ ...K,
589
+ disabled: K.disabled || e.props.disabled,
590
+ readOnly: K.readOnly || e.props.readOnly
591
+ }) : e, F.validating && /* @__PURE__ */ q("small", {
592
+ role: "status",
593
+ className: "rfe-description",
594
+ children: I.t("validating")
595
+ })]
596
+ });
597
+ }
598
+ var Pe = Object.assign(Me, { Field: Ne }), Fe = (e) => e;
599
+ export { _e as a, le as c, me as d, pe as f, Fe as i, Y as l, Q as n, X as o, de as p, ue as r, fe as s, Pe as t, he as u };
package/dist/form.js CHANGED
@@ -1,4 +1,4 @@
1
1
  import { n as e, r as t, t as n } from "./validation-D6vk5NAv.js";
2
- import { _ as r, a as i, c as a, d as o, f as s, g as c, h as l, i as u, l as d, m as f, n as p, o as m, p as h, r as g, s as _, t as v, u as y, v as b, y as x } from "./store-DOn9K-EA.js";
3
- import { a as S, c as C, d as w, f as T, i as E, l as D, n as O, o as k, r as A, s as j, t as M, u as N } from "./form-DTI0Sqsy.js";
4
- export { M as Form, O as FormItem, A as FormProvider, m as changedOutputValues, _ as cloneValues, v as createFormStore, g as createPathAdapter, E as defineComponents, S as defineForm, a as defineValueAdapter, o as editArray, p as equalValue, u as expandPaths, s as fieldSegments, i as getPathValue, h as hasPath, d as inputValues, f as isArrayIndex, n as isEmpty, l as isPlainRecord, c as normalizePaths, r as omitPaths, y as outputValues, b as readPath, k as useField, j as useFieldArray, C as useForm, D as useFormContext, N as useFormState, w as useFormSummary, T as useWatch, e as validateRuleIssue, t as validateRules, x as writePath };
2
+ import { _ as r, a as i, c as a, d as o, f as s, g as c, h as l, i as u, l as d, m as f, n as p, o as m, p as h, r as g, s as _, t as v, u as y, v as b, y as x } from "./store-CFSQW-Fv.js";
3
+ import { a as S, c as C, d as w, f as T, i as E, l as D, n as O, o as k, p as A, r as j, s as M, t as N, u as P } from "./form-CSfUExUT.js";
4
+ export { N as Form, O as FormItem, j as FormProvider, m as changedOutputValues, _ as cloneValues, v as createFormStore, g as createPathAdapter, E as defineComponents, S as defineForm, a as defineValueAdapter, o as editArray, p as equalValue, u as expandPaths, s as fieldSegments, i as getPathValue, h as hasPath, d as inputValues, f as isArrayIndex, n as isEmpty, l as isPlainRecord, c as normalizePaths, r as omitPaths, y as outputValues, b as readPath, k as useField, M as useFieldArray, C as useForm, D as useFormContext, P as useFormState, w as useFormStatus, T as useFormSummary, A as useWatch, e as validateRuleIssue, t as validateRules, x as writePath };
@@ -1,5 +1,5 @@
1
1
  import { isValidElement as e } from "react";
2
- import { i as t } from "./useControllable-Zax42z2F.js";
2
+ import { i as t } from "./useControllable-QDX_UWRh.js";
3
3
  import { jsx as n } from "react/jsx-runtime";
4
4
  // src/icons/index.tsx
5
5
  var r = {