jaguar-form 1.0.3 → 1.0.5
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/README.md +15 -2
- package/dist/Select-DiEHlcyU.js +376 -0
- package/dist/{TreeSelect-CkPtMg-g.js → TreeSelect-1jpd43zZ.js} +7 -8
- package/dist/{compound-D4_6P0d_.js → compound-BhkceJal.js} +11 -10
- package/dist/compound.js +1 -1
- package/dist/core.js +1 -1
- package/dist/date-time.js +1 -1
- package/dist/form-CnRp3fRw.js +457 -0
- package/dist/form.js +3 -3
- package/dist/{icons-BI3fdIey.js → icons-D79FYcGF.js} +1 -1
- package/dist/{image-upload-VtUlQgzJ.js → image-upload-BstB2jRd.js} +13 -9
- package/dist/image-upload.js +1 -1
- package/dist/index.js +14 -14
- package/dist/input.js +1 -1
- package/dist/inputs-Ch4x2nwn.js +615 -0
- package/dist/locale/load.js +7 -3
- package/dist/{pickers-C9QTR2XN.js → pickers-D-ymAf_p.js} +29 -30
- package/dist/select.js +1 -1
- package/dist/selection-9NP9MXSn.js +190 -0
- package/dist/{slider-CNwkLMmo.js → slider-C2T2wII7.js} +1 -1
- package/dist/slider.js +1 -1
- package/dist/{store-DOn9K-EA.js → store-BvcQ7xcl.js} +47 -29
- package/dist/style.css +1 -1
- package/dist/tree-select.js +1 -1
- package/dist/types/components/extended-inputs.d.ts +30 -0
- package/dist/types/components/image-upload/ManagedImageUpload.d.ts +10 -3
- package/dist/types/components/image-upload/upload.d.ts +1 -1
- package/dist/types/components/inputs.d.ts +24 -1
- package/dist/types/components/select/types.d.ts +4 -1
- package/dist/types/components/select/useRemoteOptions.d.ts +11 -0
- package/dist/types/components/select.d.ts +1 -0
- package/dist/types/entries/input.d.ts +5 -2
- package/dist/types/entries/select.d.ts +1 -0
- package/dist/types/form/adapter.d.ts +1 -0
- package/dist/types/form/index.d.ts +32 -1
- package/dist/types/form/store.d.ts +9 -0
- package/dist/types/locale/load.d.ts +2 -1
- package/dist/types/primitives/Popup.d.ts +1 -0
- package/dist/types/utils/decimal.d.ts +4 -0
- package/dist/types/utils/remote-options.d.ts +23 -0
- package/dist/useControllable-Dhp7tTjy.js +97 -0
- package/dist/{useSelection-C0OEFZUE.js → useSelection-BUBndjzo.js} +2 -3
- package/package.json +1 -1
- package/dist/Control-B36bu6zQ.js +0 -47
- package/dist/Select-BG2H-YnK.js +0 -252
- package/dist/form-DTI0Sqsy.js +0 -413
- package/dist/inputs-BOP8Ryne.js +0 -403
- package/dist/selection-CIEa1uce.js +0 -146
- package/dist/useControllable-Zax42z2F.js +0 -87
|
@@ -0,0 +1,457 @@
|
|
|
1
|
+
import { c as e, s as t, t as n } from "./compound-BhkceJal.js";
|
|
2
|
+
import { a as r } from "./useControllable-Dhp7tTjy.js";
|
|
3
|
+
import { r as i } from "./locale-yHkdw2xz.js";
|
|
4
|
+
import { n as a, t as o } from "./slider-C2T2wII7.js";
|
|
5
|
+
import { i as s, t as c } from "./image-upload-BstB2jRd.js";
|
|
6
|
+
import { cloneElement as l, createContext as u, isValidElement as d, useCallback as f, useContext as p, useEffect as m, useId as h, useMemo as g, useRef as _, useState as v, useSyncExternalStore as y } from "react";
|
|
7
|
+
import { d as b, n as x, t as S } from "./store-BvcQ7xcl.js";
|
|
8
|
+
import { c as C, d as w, f as T, g as E, h as D, l as O, m as k, n as A, o as j, p as M, r as N, s as P, t as F, u as I } from "./inputs-Ch4x2nwn.js";
|
|
9
|
+
import { n as L, t as R } from "./Select-DiEHlcyU.js";
|
|
10
|
+
import { t as z } from "./TreeSelect-1jpd43zZ.js";
|
|
11
|
+
import { a as B, c as V, i as ee, l as te, n as ne, o as re, r as ie, s as ae, t as oe, u as se } from "./pickers-D-ymAf_p.js";
|
|
12
|
+
import { jsx as H, jsxs as U } from "react/jsx-runtime";
|
|
13
|
+
// src/form/index.tsx
|
|
14
|
+
var W = u(null);
|
|
15
|
+
function G(e = {}) {
|
|
16
|
+
let t = _(e.onSubmit);
|
|
17
|
+
t.current = e.onSubmit;
|
|
18
|
+
let [n] = v(() => {
|
|
19
|
+
let n = e.fields ?? [], r = {
|
|
20
|
+
...Object.fromEntries(n.map((e) => [e.name, he(e)])),
|
|
21
|
+
...e.defaultValues
|
|
22
|
+
}, i = Object.fromEntries(n.filter((e) => e.transform).map((e) => [e.name, e.transform]));
|
|
23
|
+
return S(r, {
|
|
24
|
+
onSubmit: (e) => t.current?.(e),
|
|
25
|
+
nested: e.nested,
|
|
26
|
+
initialValues: e.initialValues,
|
|
27
|
+
adapter: {
|
|
28
|
+
...e.adapter,
|
|
29
|
+
fields: {
|
|
30
|
+
...i,
|
|
31
|
+
...e.adapter?.fields
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
return n;
|
|
37
|
+
}
|
|
38
|
+
function K({ form: e, children: t }) {
|
|
39
|
+
return /* @__PURE__ */ H(W.Provider, {
|
|
40
|
+
value: e,
|
|
41
|
+
children: t
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function q() {
|
|
45
|
+
let e = p(W);
|
|
46
|
+
if (!e) throw Error("FormProvider is required");
|
|
47
|
+
return e;
|
|
48
|
+
}
|
|
49
|
+
function J(e) {
|
|
50
|
+
let t = q(), n = f((n) => t.subscribe(e, n), [t, e]), r = f(() => t.getFieldState(e), [t, e]), i = y(n, r, r);
|
|
51
|
+
return {
|
|
52
|
+
...i,
|
|
53
|
+
value: i.value,
|
|
54
|
+
setValue: (n) => t.setValue(e, n),
|
|
55
|
+
onBlur: () => t.blur(e)
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function Y(e) {
|
|
59
|
+
let t = q(), n = f((n) => t.subscribe(e, n), [t, e]), r = f(() => t.getValue(e), [t, e]);
|
|
60
|
+
return y(n, r, r);
|
|
61
|
+
}
|
|
62
|
+
function ce(e) {
|
|
63
|
+
let t = q(), n = Y(e), r = h(), i = _(0), a = _([]), o = (e) => ({
|
|
64
|
+
key: `${r}-${++i.current}`,
|
|
65
|
+
value: e
|
|
66
|
+
}), s = (e) => {
|
|
67
|
+
let t = [...a.current];
|
|
68
|
+
return e.map((e) => {
|
|
69
|
+
let n = t.findIndex((t) => x(t.value, e));
|
|
70
|
+
return n < 0 ? o(e) : {
|
|
71
|
+
...t.splice(n, 1)[0],
|
|
72
|
+
value: e
|
|
73
|
+
};
|
|
74
|
+
});
|
|
75
|
+
}, c = g(() => s(Array.isArray(n) ? n : []), [n]);
|
|
76
|
+
m(() => {
|
|
77
|
+
a.current = c;
|
|
78
|
+
}, [c]);
|
|
79
|
+
let l = (n) => {
|
|
80
|
+
let r = t.getValue(e), i = s(Array.isArray(r) ? r : []), c = n.type === "insert" ? {
|
|
81
|
+
...n,
|
|
82
|
+
value: o(n.value)
|
|
83
|
+
} : n.type === "update" ? {
|
|
84
|
+
...n,
|
|
85
|
+
value: {
|
|
86
|
+
key: i[n.index]?.key ?? "",
|
|
87
|
+
value: n.value
|
|
88
|
+
}
|
|
89
|
+
} : n, l = b(i, c);
|
|
90
|
+
return a.current = l, t.editFieldArray(e, n);
|
|
91
|
+
};
|
|
92
|
+
return {
|
|
93
|
+
fields: c,
|
|
94
|
+
append: (n) => {
|
|
95
|
+
let r = t.getValue(e);
|
|
96
|
+
return l({
|
|
97
|
+
type: "insert",
|
|
98
|
+
index: Array.isArray(r) ? r.length : 0,
|
|
99
|
+
value: n
|
|
100
|
+
});
|
|
101
|
+
},
|
|
102
|
+
prepend: (e) => l({
|
|
103
|
+
type: "insert",
|
|
104
|
+
index: 0,
|
|
105
|
+
value: e
|
|
106
|
+
}),
|
|
107
|
+
insert: (e, t) => l({
|
|
108
|
+
type: "insert",
|
|
109
|
+
index: e,
|
|
110
|
+
value: t
|
|
111
|
+
}),
|
|
112
|
+
remove: (e) => l({
|
|
113
|
+
type: "remove",
|
|
114
|
+
index: e
|
|
115
|
+
}),
|
|
116
|
+
move: (e, t) => l({
|
|
117
|
+
type: "move",
|
|
118
|
+
from: e,
|
|
119
|
+
to: t
|
|
120
|
+
}),
|
|
121
|
+
update: (e, t) => l({
|
|
122
|
+
type: "update",
|
|
123
|
+
index: e,
|
|
124
|
+
value: t
|
|
125
|
+
}),
|
|
126
|
+
replace: (n) => t.setValue(e, n)
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
function le(e = (e) => e) {
|
|
130
|
+
let t = q(), n = _(null), r = f(() => {
|
|
131
|
+
let r = e(t.getFormSummary());
|
|
132
|
+
return n.current && x(n.current.value, r) ? n.current.value : (n.current = { value: r }, r);
|
|
133
|
+
}, [t, e]);
|
|
134
|
+
return y(t.subscribeAll, r, r);
|
|
135
|
+
}
|
|
136
|
+
function ue(e) {
|
|
137
|
+
return y(e.subscribeAll, e.getFormSummary, e.getFormSummary);
|
|
138
|
+
}
|
|
139
|
+
function de() {
|
|
140
|
+
let e = q();
|
|
141
|
+
return y(e.subscribeAll, e.getVersion, e.getVersion), {
|
|
142
|
+
values: e.getValues(),
|
|
143
|
+
changedValues: e.getChangedValues()
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
var fe = (e) => e, pe = {
|
|
147
|
+
compound: n,
|
|
148
|
+
imageUpload: c,
|
|
149
|
+
input: j,
|
|
150
|
+
number: P,
|
|
151
|
+
decimal: D,
|
|
152
|
+
tags: E,
|
|
153
|
+
autocomplete: k,
|
|
154
|
+
password: C,
|
|
155
|
+
textarea: M,
|
|
156
|
+
switch: T,
|
|
157
|
+
checkbox: A,
|
|
158
|
+
radio: O,
|
|
159
|
+
checkboxGroup: N,
|
|
160
|
+
select: L,
|
|
161
|
+
multiSelect: R,
|
|
162
|
+
treeSelect: z,
|
|
163
|
+
date: oe,
|
|
164
|
+
dateRange: ne,
|
|
165
|
+
time: ae,
|
|
166
|
+
timeRange: V,
|
|
167
|
+
dateTime: ie,
|
|
168
|
+
dateTimeRange: ee,
|
|
169
|
+
month: B,
|
|
170
|
+
year: te,
|
|
171
|
+
monthRange: re,
|
|
172
|
+
yearRange: se,
|
|
173
|
+
search: I,
|
|
174
|
+
segmented: w,
|
|
175
|
+
slider: a,
|
|
176
|
+
rangeSlider: o
|
|
177
|
+
};
|
|
178
|
+
function X({ label: e, description: t, error: n, required: r, id: i, children: a, span: o = 1 }) {
|
|
179
|
+
return /* @__PURE__ */ U("div", {
|
|
180
|
+
className: "rfe-field",
|
|
181
|
+
style: { gridColumn: `span ${o}` },
|
|
182
|
+
children: [e && /* @__PURE__ */ U("label", {
|
|
183
|
+
htmlFor: i,
|
|
184
|
+
className: "rfe-field-label",
|
|
185
|
+
children: [r && /* @__PURE__ */ H("span", {
|
|
186
|
+
className: "rfe-required",
|
|
187
|
+
"aria-hidden": "true",
|
|
188
|
+
children: "* "
|
|
189
|
+
}), e]
|
|
190
|
+
}), /* @__PURE__ */ U("div", {
|
|
191
|
+
className: "rfe-field-content",
|
|
192
|
+
children: [a, n ? /* @__PURE__ */ H("div", {
|
|
193
|
+
id: i ? `${i}-help` : void 0,
|
|
194
|
+
role: "alert",
|
|
195
|
+
className: "rfe-error",
|
|
196
|
+
children: n
|
|
197
|
+
}) : t && /* @__PURE__ */ H("div", {
|
|
198
|
+
id: i ? `${i}-help` : void 0,
|
|
199
|
+
className: "rfe-description",
|
|
200
|
+
children: t
|
|
201
|
+
})]
|
|
202
|
+
})]
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
var me = (e, t) => typeof e.visible == "function" ? e.visible(t) : e.visible !== !1, Z = (e) => e.type === "compound" && Array.isArray(e.componentProps?.fields) ? e.componentProps.fields : void 0, he = (e) => e.defaultValue === void 0 ? Z(e) ? t(Z(e)) : void 0 : e.defaultValue;
|
|
206
|
+
function ge(t) {
|
|
207
|
+
return [
|
|
208
|
+
...t.required && !t.rules?.some((e) => e.required) ? [{ required: !0 }] : [],
|
|
209
|
+
...t.rules ?? [],
|
|
210
|
+
...Z(t) ? [e(Z(t))] : [],
|
|
211
|
+
...t.type === "imageUpload" && t.componentProps?.mode === "upload" ? [s] : []
|
|
212
|
+
];
|
|
213
|
+
}
|
|
214
|
+
function _e({ field: e, components: t, fields: n, validateOn: a }) {
|
|
215
|
+
let o = q(), s = J(e.name), c = r(), l = h(), u = e.dependsOn, d = p(Q), _ = g(() => ({
|
|
216
|
+
rules: ge(e),
|
|
217
|
+
debounce: e.debounce,
|
|
218
|
+
dependsOn: u,
|
|
219
|
+
validateOn: e.validateOn ?? a,
|
|
220
|
+
defaultValue: he(e),
|
|
221
|
+
visible: (t) => me(e, t)
|
|
222
|
+
}), [
|
|
223
|
+
e,
|
|
224
|
+
u,
|
|
225
|
+
a
|
|
226
|
+
]);
|
|
227
|
+
m(() => o.registerField(e.name, { ..._ }), [o, e.name]), m(() => o.updateField(e.name, _), [
|
|
228
|
+
o,
|
|
229
|
+
e.name,
|
|
230
|
+
_
|
|
231
|
+
]);
|
|
232
|
+
let v = f((t) => {
|
|
233
|
+
if (!u) return typeof e.visible == "function" || typeof e.disabled == "function" ? o.subscribeAll(t) : () => {};
|
|
234
|
+
let n = u.map((e) => o.subscribe(e, t));
|
|
235
|
+
return () => n.forEach((e) => e());
|
|
236
|
+
}, [
|
|
237
|
+
o,
|
|
238
|
+
u,
|
|
239
|
+
e.visible,
|
|
240
|
+
e.disabled
|
|
241
|
+
]);
|
|
242
|
+
y(v, o.getVersion, o.getVersion);
|
|
243
|
+
let b = typeof e.visible == "function" || typeof e.disabled == "function" ? o.getValues() : $;
|
|
244
|
+
if (!me(e, b)) return null;
|
|
245
|
+
let x = t[e.type] ?? pe[e.type], S = {
|
|
246
|
+
...e.componentProps,
|
|
247
|
+
id: l,
|
|
248
|
+
name: e.name,
|
|
249
|
+
value: s.value ?? ([
|
|
250
|
+
"input",
|
|
251
|
+
"password",
|
|
252
|
+
"textarea",
|
|
253
|
+
"search",
|
|
254
|
+
"autocomplete"
|
|
255
|
+
].includes(e.type) ? "" : e.type === "switch" || e.type === "checkbox" ? !1 : e.type === "imageUpload" || e.type === "tags" || e.type === "multiSelect" || e.type === "checkboxGroup" || e.type === "treeSelect" && e.componentProps?.multiple ? [] : e.type === "slider" ? 0 : e.type === "rangeSlider" ? [0, 100] : null),
|
|
256
|
+
onChange: (t) => {
|
|
257
|
+
o.setValue(e.name, t);
|
|
258
|
+
},
|
|
259
|
+
onBlur: () => {
|
|
260
|
+
o.blur(e.name);
|
|
261
|
+
},
|
|
262
|
+
status: s.error ? "error" : "default",
|
|
263
|
+
"aria-invalid": !!s.error,
|
|
264
|
+
disabled: d.disabled || d.loading || (typeof e.disabled == "function" ? e.disabled(b) : e.disabled ?? e.componentProps?.disabled),
|
|
265
|
+
readOnly: d.readOnly || e.componentProps?.readOnly,
|
|
266
|
+
"aria-describedby": s.error || e.description ? `${l}-help` : void 0
|
|
267
|
+
};
|
|
268
|
+
return /* @__PURE__ */ U(X, {
|
|
269
|
+
label: e.label,
|
|
270
|
+
required: e.required,
|
|
271
|
+
description: e.description,
|
|
272
|
+
error: i(s.issue, s.error, c),
|
|
273
|
+
id: l,
|
|
274
|
+
span: e.span,
|
|
275
|
+
children: [e.render ? e.render(S) : x ? /* @__PURE__ */ H(x, { ...S }) : /* @__PURE__ */ H("div", {
|
|
276
|
+
className: "rfe-error",
|
|
277
|
+
children: c.t("unknownField", { type: e.type })
|
|
278
|
+
}), s.validating && /* @__PURE__ */ H("small", {
|
|
279
|
+
role: "status",
|
|
280
|
+
className: "rfe-description",
|
|
281
|
+
children: c.t("validating")
|
|
282
|
+
})]
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
var ve = u("blur"), Q = u({
|
|
286
|
+
disabled: !1,
|
|
287
|
+
readOnly: !1,
|
|
288
|
+
loading: !1
|
|
289
|
+
}), ye = [], $ = {}, be = {};
|
|
290
|
+
function xe({ nested: e, initialValues: t, adapter: n, submitHiddenFields: i = !1, validateOn: a = "blur", form: o, fields: s = ye, defaultValues: c = $, components: l = be, children: u, columns: d = 1, responsive: f = !1, disabled: p = !1, readOnly: h = !1, loading: b = !1, layout: x = "vertical", onSubmit: S, onError: C, submitText: w, resetText: T, showActions: E = !0 }) {
|
|
291
|
+
let D = r(), O = G(o ? {} : {
|
|
292
|
+
fields: s,
|
|
293
|
+
defaultValues: c,
|
|
294
|
+
initialValues: t,
|
|
295
|
+
adapter: n,
|
|
296
|
+
nested: e
|
|
297
|
+
}), k = o ?? O, A = y(k.subscribeAll, () => k.getFormSummary().isSubmitting, () => !1), [j, M] = v(""), N = _(null), P = () => requestAnimationFrame(() => {
|
|
298
|
+
let e = N.current?.querySelector("input[aria-invalid=\"true\"],button[aria-invalid=\"true\"],textarea[aria-invalid=\"true\"],[tabindex][aria-invalid=\"true\"]");
|
|
299
|
+
e?.focus({ preventScroll: !0 }), e?.scrollIntoView({ block: "nearest" });
|
|
300
|
+
});
|
|
301
|
+
m(() => k.bindSubmission({
|
|
302
|
+
handler: S,
|
|
303
|
+
includeHidden: i,
|
|
304
|
+
invalid: P,
|
|
305
|
+
blocked: p || h || b
|
|
306
|
+
}), [
|
|
307
|
+
k,
|
|
308
|
+
S,
|
|
309
|
+
i,
|
|
310
|
+
p,
|
|
311
|
+
h,
|
|
312
|
+
b
|
|
313
|
+
]);
|
|
314
|
+
let I = g(() => ({
|
|
315
|
+
disabled: p,
|
|
316
|
+
readOnly: h,
|
|
317
|
+
loading: b
|
|
318
|
+
}), [
|
|
319
|
+
p,
|
|
320
|
+
h,
|
|
321
|
+
b
|
|
322
|
+
]);
|
|
323
|
+
return /* @__PURE__ */ H(K, {
|
|
324
|
+
form: k,
|
|
325
|
+
children: /* @__PURE__ */ H(ve.Provider, {
|
|
326
|
+
value: a,
|
|
327
|
+
children: /* @__PURE__ */ H(Q.Provider, {
|
|
328
|
+
value: I,
|
|
329
|
+
children: /* @__PURE__ */ U("form", {
|
|
330
|
+
ref: N,
|
|
331
|
+
className: "rfe-form",
|
|
332
|
+
"data-responsive": f || void 0,
|
|
333
|
+
"data-layout": x,
|
|
334
|
+
"aria-busy": b || A || void 0,
|
|
335
|
+
noValidate: !0,
|
|
336
|
+
onSubmit: async (e) => {
|
|
337
|
+
if (e.preventDefault(), !(p || h || b || k.getFormSummary().isSubmitting)) {
|
|
338
|
+
M("");
|
|
339
|
+
try {
|
|
340
|
+
await k.submit(S, i);
|
|
341
|
+
} catch (e) {
|
|
342
|
+
M(e instanceof Error ? e.message : D.t("submitFailed")), C?.(e);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
},
|
|
346
|
+
children: [
|
|
347
|
+
/* @__PURE__ */ U("div", {
|
|
348
|
+
className: "rfe-form-grid",
|
|
349
|
+
style: { gridTemplateColumns: `repeat(${Math.max(1, d)},minmax(0,1fr))` },
|
|
350
|
+
children: [s.map((e) => /* @__PURE__ */ H(_e, {
|
|
351
|
+
field: e,
|
|
352
|
+
components: l,
|
|
353
|
+
fields: s,
|
|
354
|
+
validateOn: a
|
|
355
|
+
}, e.name)), u]
|
|
356
|
+
}),
|
|
357
|
+
j && /* @__PURE__ */ H("div", {
|
|
358
|
+
role: "alert",
|
|
359
|
+
className: "rfe-error",
|
|
360
|
+
children: j
|
|
361
|
+
}),
|
|
362
|
+
E && /* @__PURE__ */ U("div", {
|
|
363
|
+
className: "rfe-form-actions",
|
|
364
|
+
children: [/* @__PURE__ */ H(F, {
|
|
365
|
+
variant: "secondary",
|
|
366
|
+
disabled: A || p || h || b,
|
|
367
|
+
onClick: () => {
|
|
368
|
+
k.reset(), M("");
|
|
369
|
+
},
|
|
370
|
+
children: T ?? D.t("reset")
|
|
371
|
+
}), /* @__PURE__ */ H(F, {
|
|
372
|
+
type: "submit",
|
|
373
|
+
loading: A,
|
|
374
|
+
disabled: p || h || b,
|
|
375
|
+
children: w ?? D.t("save")
|
|
376
|
+
})]
|
|
377
|
+
})
|
|
378
|
+
]
|
|
379
|
+
})
|
|
380
|
+
})
|
|
381
|
+
})
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
function Se({ children: a, name: o, label: u, description: _, required: v, rules: b, defaultValue: x, dependsOn: S, debounce: C, validateOn: w, span: T, disabled: E, visible: D, componentProps: O }) {
|
|
385
|
+
let k = q(), A = p(ve), j = p(Q), M = w ?? A, N = J(o), P = r(), F = h(), I = d(a) && a.type === n ? a.props.fields : void 0, L = d(a) && a.type === c && a.props.mode === "upload", R = g(() => ({
|
|
386
|
+
rules: [
|
|
387
|
+
...v && !b?.some((e) => e.required) ? [{ required: !0 }] : [],
|
|
388
|
+
...b ?? [],
|
|
389
|
+
...L ? [s] : [],
|
|
390
|
+
...I ? [e(I)] : []
|
|
391
|
+
],
|
|
392
|
+
defaultValue: x ?? (I ? t(I) : void 0),
|
|
393
|
+
dependsOn: S,
|
|
394
|
+
debounce: C,
|
|
395
|
+
validateOn: M,
|
|
396
|
+
visible: (e) => typeof D == "function" ? D(e) : D !== !1
|
|
397
|
+
}), [
|
|
398
|
+
v,
|
|
399
|
+
b,
|
|
400
|
+
x,
|
|
401
|
+
S,
|
|
402
|
+
C,
|
|
403
|
+
M,
|
|
404
|
+
D,
|
|
405
|
+
L,
|
|
406
|
+
I
|
|
407
|
+
]);
|
|
408
|
+
m(() => k.registerField(o, { ...R }), [k, o]), m(() => k.updateField(o, R), [
|
|
409
|
+
k,
|
|
410
|
+
o,
|
|
411
|
+
R
|
|
412
|
+
]);
|
|
413
|
+
let z = f((e) => typeof D == "function" || typeof E == "function" ? k.subscribeAll(e) : () => {}, [
|
|
414
|
+
k,
|
|
415
|
+
D,
|
|
416
|
+
E
|
|
417
|
+
]);
|
|
418
|
+
y(z, k.getVersion, k.getVersion);
|
|
419
|
+
let B = typeof D == "function" || typeof E == "function" ? k.getValues() : $;
|
|
420
|
+
if (!R.visible(B)) return null;
|
|
421
|
+
let V = {
|
|
422
|
+
...O,
|
|
423
|
+
id: F,
|
|
424
|
+
name: o,
|
|
425
|
+
value: N.value,
|
|
426
|
+
onChange: (e) => {
|
|
427
|
+
k.setValue(o, e);
|
|
428
|
+
},
|
|
429
|
+
onBlur: () => {
|
|
430
|
+
k.blur(o);
|
|
431
|
+
},
|
|
432
|
+
disabled: j.disabled || j.loading || (typeof E == "function" ? E(B) : E) || O?.disabled === !0,
|
|
433
|
+
readOnly: j.readOnly || O?.readOnly === !0,
|
|
434
|
+
status: N.error ? "error" : "default",
|
|
435
|
+
"aria-invalid": !!N.error,
|
|
436
|
+
"aria-describedby": N.error || _ ? `${F}-help` : void 0
|
|
437
|
+
};
|
|
438
|
+
return /* @__PURE__ */ U(X, {
|
|
439
|
+
id: F,
|
|
440
|
+
label: u,
|
|
441
|
+
required: v,
|
|
442
|
+
description: _,
|
|
443
|
+
error: i(N.issue, N.error, P),
|
|
444
|
+
span: T,
|
|
445
|
+
children: [typeof a == "function" ? a(V) : d(a) ? l(a, {
|
|
446
|
+
...V,
|
|
447
|
+
disabled: V.disabled || a.props.disabled,
|
|
448
|
+
readOnly: V.readOnly || a.props.readOnly
|
|
449
|
+
}) : a, N.validating && /* @__PURE__ */ H("small", {
|
|
450
|
+
role: "status",
|
|
451
|
+
className: "rfe-description",
|
|
452
|
+
children: P.t("validating")
|
|
453
|
+
})]
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
var Ce = Object.assign(xe, { Field: Se }), we = (e) => e;
|
|
457
|
+
export { fe as a, G as c, ue as d, le as f, we as i, q as l, X as n, J as o, Y as p, K as r, ce as s, Ce as t, de 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-
|
|
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,
|
|
4
|
-
export {
|
|
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-BvcQ7xcl.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-CnRp3fRw.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,6 +1,6 @@
|
|
|
1
1
|
import { useEffect as e, useId as t, useLayoutEffect as n, useRef as r, useState as i } from "react";
|
|
2
|
-
import { a, i as o, s, t as c } from "./useControllable-
|
|
3
|
-
import { t as l } from "./icons-
|
|
2
|
+
import { a, i as o, s, t as c } from "./useControllable-Dhp7tTjy.js";
|
|
3
|
+
import { t as l } from "./icons-D79FYcGF.js";
|
|
4
4
|
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
5
5
|
// src/components/image-upload/validation.ts
|
|
6
6
|
var f = "image/jpeg,image/png,image/webp";
|
|
@@ -303,18 +303,22 @@ function w(c) {
|
|
|
303
303
|
accept: I
|
|
304
304
|
});
|
|
305
305
|
if (k(n.rejected), n.rejected.length && c.onReject?.(n.rejected), !n.accepted.length) return;
|
|
306
|
-
|
|
306
|
+
if (!N) {
|
|
307
|
+
D.dispose();
|
|
308
|
+
for (let e of T.current) c.onRemove?.(e);
|
|
309
|
+
}
|
|
307
310
|
let r = n.accepted.map((e) => ({
|
|
308
311
|
uid: `${g}-${++C}`,
|
|
309
312
|
name: e.name,
|
|
310
313
|
file: e,
|
|
311
|
-
status: "uploading",
|
|
314
|
+
status: c.mode === "mixed" ? "local" : "uploading",
|
|
312
315
|
progress: 0
|
|
313
316
|
}));
|
|
314
|
-
E.current([...t, ...r]);
|
|
315
|
-
for (let e of r) D.start(e, c.upload);
|
|
317
|
+
if (E.current([...t, ...r]), c.mode === "upload") for (let e of r) D.start(e, c.upload);
|
|
316
318
|
}, V = (e) => {
|
|
317
|
-
|
|
319
|
+
if (L) return;
|
|
320
|
+
let t = T.current.find((t) => t.uid === e);
|
|
321
|
+
t && c.onRemove?.(t), D.abort(e), E.current(T.current.filter((t) => t.uid !== e)), k([]);
|
|
318
322
|
}, te = (e) => {
|
|
319
323
|
L || (D.abort(e), E.current(T.current.map((t) => t.uid === e ? {
|
|
320
324
|
...t,
|
|
@@ -373,7 +377,7 @@ function w(c) {
|
|
|
373
377
|
onRemove: () => V(e.uid),
|
|
374
378
|
onCancel: () => te(e.uid),
|
|
375
379
|
onRetry: () => {
|
|
376
|
-
!L && !D.has(e.uid) && D.start(e, c.upload);
|
|
380
|
+
c.mode === "upload" && !L && !D.has(e.uid) && D.start(e, c.upload);
|
|
377
381
|
}
|
|
378
382
|
}, e.uid)),
|
|
379
383
|
!R && /* @__PURE__ */ d("button", {
|
|
@@ -633,6 +637,6 @@ function A({ id: e, name: n, value: p, defaultValue: h, onChange: g, onBlur: y,
|
|
|
633
637
|
});
|
|
634
638
|
}
|
|
635
639
|
function j(e) {
|
|
636
|
-
return e.mode === "upload" ? /* @__PURE__ */ u(w, { ...e }) : /* @__PURE__ */ u(A, { ...e });
|
|
640
|
+
return e.mode === "upload" || e.mode === "mixed" ? /* @__PURE__ */ u(w, { ...e }) : /* @__PURE__ */ u(A, { ...e });
|
|
637
641
|
}
|
|
638
642
|
export { b as i, x as n, y as r, j as t };
|
package/dist/image-upload.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as ImageUpload, n as createImageUploadTasks, r as isImageUrl, i as uploadedImagesRule } from "./image-upload-
|
|
1
|
+
export { t as ImageUpload, n as createImageUploadTasks, r as isImageUrl, i as uploadedImagesRule } from "./image-upload-BstB2jRd.js";
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { a as e, i as t, n, o as r, r as i, s as a } from "./useControllable-
|
|
2
|
-
import { n as o, t as s } from "./icons-
|
|
3
|
-
import { a as c, c as l, d as u, f as d,
|
|
4
|
-
import { a as
|
|
5
|
-
import { n as
|
|
6
|
-
import { n as
|
|
7
|
-
import { t as
|
|
8
|
-
import { a as
|
|
9
|
-
import { i as
|
|
10
|
-
import { n as
|
|
11
|
-
import { a as
|
|
12
|
-
import { _ as
|
|
13
|
-
import { a as
|
|
14
|
-
export {
|
|
1
|
+
import { a as e, i as t, n, o as r, r as i, s as a } from "./useControllable-Dhp7tTjy.js";
|
|
2
|
+
import { n as o, t as s } from "./icons-D79FYcGF.js";
|
|
3
|
+
import { a as c, c as l, d as u, f as d, g as f, h as p, i as m, l as h, m as g, n as _, o as v, p as y, r as b, s as x, t as S, u as C } from "./inputs-Ch4x2nwn.js";
|
|
4
|
+
import { a as w, c 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 "./pickers-D-ymAf_p.js";
|
|
5
|
+
import { n as P, t as F } from "./slider-C2T2wII7.js";
|
|
6
|
+
import { n as I, t as L } from "./Select-DiEHlcyU.js";
|
|
7
|
+
import { t as R } from "./TreeSelect-1jpd43zZ.js";
|
|
8
|
+
import { a as z, c as B, d as V, f as H, i as U, l as W, n as G, o as K, p as q, r as J, s as Y, t as X, u as Z } from "./form-CnRp3fRw.js";
|
|
9
|
+
import { i as Q, n as $, r as ee, t as te } from "./image-upload-BstB2jRd.js";
|
|
10
|
+
import { n as ne, r as re, t as ie } from "./validation-D6vk5NAv.js";
|
|
11
|
+
import { a as ae, i as oe, n as se, o as ce, r as le, s as ue, t as de } from "./locale-yHkdw2xz.js";
|
|
12
|
+
import { _ as fe, a as pe, c as me, d as he, f as ge, g as _e, h as ve, i as ye, l as be, m as xe, n as Se, o as Ce, p as we, r as Te, s as Ee, t as De, u as Oe, v as ke, y as Ae } from "./store-BvcQ7xcl.js";
|
|
13
|
+
import { a as je, c as Me, d as Ne, f as Pe, i as Fe, l as Ie, n as Le, o as Re, r as ze, s as Be, t as Ve, u as He } from "./compound-BhkceJal.js";
|
|
14
|
+
export { g as Autocomplete, S as Button, _ as Checkbox, b as CheckboxGroup, Ve as CompoundField, n as ConfigProvider, Pe as ControlGroup, M as DatePicker, O as DateRangePicker, A as DateTimePicker, E as DateTimeRangePicker, p as DecimalInput, m as FloatingInput, X as Form, G as FormItem, J as FormProvider, s as Icon, c as IconButton, te as ImageUpload, v as Input, Le as InputRange, ze as InputSelect, w as MonthPicker, k as MonthRangePicker, L as MultiSelect, x as NumberInput, Fe as NumberSelect, je as NumberUnit, l as Password, h as RadioGroup, F as RangeSlider, Re as SearchGroup, C as SearchInput, u as Segmented, I as Select, P as Slider, o as SvgIcon, d as Switch, f as TagsInput, y as Textarea, j as TimePicker, T as TimeRangePicker, R as TreeSelect, D as YearPicker, N as YearRangePicker, Ce as changedOutputValues, Ee as cloneValues, Be as compoundDefaults, Me as compoundRule, Ie as compoundValues, De as createFormStore, $ as createImageUploadTasks, Te as createPathAdapter, a as cx, U as defineComponents, z as defineForm, de as defineLocale, me as defineValueAdapter, he as editArray, se as enUS, Se as equalValue, ye as expandPaths, ge as fieldSegments, le as formatIssue, oe as formatPickerValue, pe as getPathValue, we as hasPath, be as inputValues, xe as isArrayIndex, ie as isEmpty, ee as isImageUrl, ve as isPlainRecord, _e as normalizePaths, fe as omitPaths, Oe as outputValues, He as partDisabled, Ne as partVisible, ke as readPath, ae as resolveLocale, i as tokenStyle, ce as translate, Q as uploadedImagesRule, t as useConfig, K as useField, Y as useFieldArray, B as useForm, W as useFormContext, Z as useFormState, V as useFormStatus, H as useFormSummary, e as useLocale, r as useText, q as useWatch, ne as validateRuleIssue, re as validateRules, Ae as writePath, ue as zhCN };
|
package/dist/input.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { m as Autocomplete, h as DecimalInput, i as FloatingInput, o as Input, s as NumberInput, c as Password, u as SearchInput, g as TagsInput, p as Textarea } from "./inputs-Ch4x2nwn.js";
|