jaguar-form 1.0.7 → 1.0.8

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 (37) hide show
  1. package/README.md +4 -0
  2. package/dist/{Cascader-iWlk7VJR.js → Cascader-COGUcdDS.js} +4 -4
  3. package/dist/{Select-CoEW4UIq.js → Select-BxwT7MHH.js} +81 -77
  4. package/dist/{TreeSelect-BWksr9iW.js → TreeSelect-W5sgU5nW.js} +4 -4
  5. package/dist/{compound-BW6G7E_-.js → compound-nXxRSVJu.js} +27 -27
  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/{form-B-BSf2n1.js → form-D6O5PqrZ.js} +62 -49
  10. package/dist/form.js +3 -3
  11. package/dist/{icons-BwE05e0C.js → icons-B1dOXz-r.js} +1 -1
  12. package/dist/{image-upload-D9oPG0Eh.js → image-upload-BFVs81x3.js} +46 -42
  13. package/dist/image-upload.js +1 -1
  14. package/dist/index.js +15 -15
  15. package/dist/input.js +1 -1
  16. package/dist/inputs-w_es2t_C.js +862 -0
  17. package/dist/{lazy-tree-C9l9lzQw.js → lazy-tree-DNvNf_Yv.js} +20 -17
  18. package/dist/{pickers-Bci1y8cc.js → pickers-5zLmSrsp.js} +3 -3
  19. package/dist/select.js +2 -2
  20. package/dist/selection-CA_66JX9.js +223 -0
  21. package/dist/{slider-AM0Egz9P.js → slider-Bhd1Z4LP.js} +35 -35
  22. package/dist/slider.js +1 -1
  23. package/dist/{store-CFSQW-Fv.js → store-C9eBd8Y7.js} +205 -194
  24. package/dist/style.css +1 -1
  25. package/dist/tree-select.js +1 -1
  26. package/dist/types/components/extended-inputs.d.ts +4 -1
  27. package/dist/types/components/image-upload/index.d.ts +1 -1
  28. package/dist/types/components/inputs.d.ts +28 -8
  29. package/dist/types/config/index.d.ts +32 -1
  30. package/dist/types/entries/input.d.ts +2 -2
  31. package/dist/types/form/index.d.ts +3 -0
  32. package/dist/types/form/store.d.ts +1 -0
  33. package/dist/types/primitives/Control.d.ts +7 -2
  34. package/dist/{useControllable-QDX_UWRh.js → useControllable-Dt38Jg9E.js} +54 -21
  35. package/package.json +1 -1
  36. package/dist/inputs-DpZdLaoP.js +0 -718
  37. package/dist/selection-DCIzhR5q.js +0 -197
@@ -1,16 +1,16 @@
1
- import { d as e, l as t, s as n, t as r, u as i } from "./compound-BW6G7E_-.js";
2
- import { a, i as o } from "./useControllable-QDX_UWRh.js";
1
+ import { d as e, l as t, s as n, t as r, u as i } from "./compound-nXxRSVJu.js";
2
+ import { c as a, s as o } from "./useControllable-Dt38Jg9E.js";
3
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";
4
+ import { n as c, t as l } from "./slider-Bhd1Z4LP.js";
5
+ import { i as u, t as d } from "./image-upload-BFVs81x3.js";
6
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-DpZdLaoP.js";
9
- import { n as B, t as V } from "./Select-CoEW4UIq.js";
10
- import { t as H } from "./TreeSelect-BWksr9iW.js";
7
+ import { d as C, n as w, t as T } from "./store-C9eBd8Y7.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-w_es2t_C.js";
9
+ import { n as B, t as V } from "./Select-BxwT7MHH.js";
10
+ import { t as H } from "./TreeSelect-W5sgU5nW.js";
11
11
  import { n as U } from "./validation-D6vk5NAv.js";
12
- import { t as ee } from "./Cascader-iWlk7VJR.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";
12
+ import { t as ee } from "./Cascader-COGUcdDS.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-5zLmSrsp.js";
14
14
  import { jsx as q, jsxs as J } from "react/jsx-runtime";
15
15
  // src/form/index.tsx
16
16
  var ce = p(null);
@@ -19,7 +19,7 @@ function le(e = {}) {
19
19
  t.current = e.onSubmit;
20
20
  let [n] = x(() => {
21
21
  let n = e.fields ?? [], r = {
22
- ...Object.fromEntries(n.map((e) => [e.name, be(e)])),
22
+ ...Object.fromEntries(n.map((e) => [e.name, xe(e)])),
23
23
  ...typeof e.defaultValues == "function" ? {} : e.defaultValues
24
24
  }, i = Object.fromEntries(n.filter((e) => e.transform).map((e) => [e.name, e.transform]));
25
25
  return T(r, {
@@ -147,12 +147,22 @@ function fe(e) {
147
147
  replace: (n) => t.setValue(e, n)
148
148
  };
149
149
  }
150
+ function Z(e, t, n = w) {
151
+ let r = b(null), i = h(() => {
152
+ let i = t(e.getFormSummary());
153
+ return r.current?.store === e && n(r.current.value, i) ? r.current.value : (r.current = {
154
+ store: e,
155
+ value: i
156
+ }, i);
157
+ }, [
158
+ e,
159
+ t,
160
+ n
161
+ ]);
162
+ return S(e.subscribeAll, i, i);
163
+ }
150
164
  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);
165
+ return Z(Y(), e);
156
166
  }
157
167
  function me(e) {
158
168
  return S(e.subscribeAll, e.getFormSummary, e.getFormSummary);
@@ -164,9 +174,9 @@ function he() {
164
174
  changedValues: e.getChangedValues()
165
175
  };
166
176
  }
167
- var Z = (e, t = 1) => Number.isFinite(e) ? Math.max(1, Math.min(24, Math.floor(e))) : t;
177
+ var Q = (e, t = 1) => Number.isFinite(e) ? Math.max(1, Math.min(24, Math.floor(e))) : t;
168
178
  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);
179
+ let r = typeof t == "number" ? n ? 1 : Q(t) : Q(t.xs), i = typeof t == "number" ? Q(t) : Q(t.sm, r), a = typeof t == "number" ? i : Q(t.md, i), o = typeof t == "number" ? a : Q(t.lg, a);
170
180
  return {
171
181
  [`--rfe-${e}-xs`]: r,
172
182
  [`--rfe-${e}-sm`]: i,
@@ -207,13 +217,13 @@ var _e = (e) => e, ve = {
207
217
  slider: c,
208
218
  rangeSlider: l
209
219
  };
210
- function Q({ label: e, description: t, error: n, required: r, id: i, children: a, span: o = 1, placement: s, name: c }) {
220
+ function $({ label: e, description: t, error: n, required: r, id: i, children: a, span: o = 1, placement: s, name: c }) {
211
221
  return /* @__PURE__ */ J("div", {
212
222
  className: "rfe-field",
213
223
  "data-field-name": c,
214
224
  "data-label-placement": s,
215
225
  style: {
216
- gridColumn: `span ${Z(typeof o == "number" ? o : o.xs)}`,
226
+ gridColumn: `span ${Q(typeof o == "number" ? o : o.xs)}`,
217
227
  ...ge("span", o)
218
228
  },
219
229
  children: [e && /* @__PURE__ */ J("label", {
@@ -239,15 +249,15 @@ function Q({ label: e, description: t, error: n, required: r, id: i, children: a
239
249
  })]
240
250
  });
241
251
  }
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) {
252
+ var ye = (e, t) => typeof e.visible == "function" ? e.visible(t) : e.visible !== !1, be = (e) => e.type === "compound" && Array.isArray(e.componentProps?.fields) ? e.componentProps.fields : void 0, xe = (e) => e.defaultValue === void 0 ? be(e) ? n(be(e)) : void 0 : e.defaultValue;
253
+ function Se(e) {
244
254
  return [
245
255
  ...e.required && !e.rules?.some((e) => e.required) ? [{ required: !0 }] : [],
246
256
  ...e.rules ?? [],
247
257
  ...e.type === "imageUpload" && e.componentProps?.mode === "upload" ? [u] : []
248
258
  ];
249
259
  }
250
- function Se(n, r, a, o) {
260
+ function Ce(n, r, a, o) {
251
261
  let s = JSON.stringify(a?.map((e) => e.name) ?? []), c = b(a);
252
262
  c.current = a;
253
263
  let l = y(() => c.current?.map((a) => ({
@@ -297,13 +307,13 @@ function Se(n, r, a, o) {
297
307
  }
298
308
  };
299
309
  }
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),
310
+ function we({ field: e, components: t, fields: n, validateOn: r }) {
311
+ let i = Y(), o = X(e.name), c = a(), l = v(), u = e.dependsOn, d = g(De), f = e.labelPlacement ?? d, p = g(ke), m = y(() => ({
312
+ rules: Se(e),
303
313
  debounce: e.debounce,
304
314
  dependsOn: u,
305
315
  validateOn: e.validateOn ?? r,
306
- defaultValue: be(e),
316
+ defaultValue: xe(e),
307
317
  visible: (t) => ye(e, t)
308
318
  }), [
309
319
  e,
@@ -315,7 +325,7 @@ function Ce({ field: e, components: t, fields: n, validateOn: r }) {
315
325
  e.name,
316
326
  m
317
327
  ]);
318
- let b = Se(i, e.name, $(e), e.validateOn ?? r), x = o.error ? o : b?.error ?? o, C = h((t) => {
328
+ let b = Ce(i, e.name, be(e), e.validateOn ?? r), x = o.error ? o : b?.error ?? o, C = h((t) => {
319
329
  if (!u) return typeof e.visible == "function" || typeof e.disabled == "function" ? i.subscribeAll(t) : () => {};
320
330
  let n = u.map((e) => i.subscribe(e, t));
321
331
  return () => n.forEach((e) => e());
@@ -326,9 +336,9 @@ function Ce({ field: e, components: t, fields: n, validateOn: r }) {
326
336
  e.disabled
327
337
  ]);
328
338
  S(C, i.getVersion, i.getVersion);
329
- let w = typeof e.visible == "function" || typeof e.disabled == "function" ? i.getValues() : Ae;
339
+ let w = typeof e.visible == "function" || typeof e.disabled == "function" ? i.getValues() : je;
330
340
  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 = {
341
+ let T = t[e.type] ?? ve[e.type], E = f === "floating" && typeof e.label == "string" && Te.has(e.type) && !e.render && !t[e.type], D = {
332
342
  ...e.componentProps,
333
343
  ...b ? {
334
344
  partStates: b.states,
@@ -358,7 +368,7 @@ function Ce({ field: e, components: t, fields: n, validateOn: r }) {
358
368
  readOnly: p.readOnly || e.componentProps?.readOnly,
359
369
  "aria-describedby": x.error || e.description ? `${l}-help` : void 0
360
370
  };
361
- return /* @__PURE__ */ J(Q, {
371
+ return /* @__PURE__ */ J($, {
362
372
  name: e.name,
363
373
  placement: f,
364
374
  label: E || f === "none" ? void 0 : e.label,
@@ -377,7 +387,7 @@ function Ce({ field: e, components: t, fields: n, validateOn: r }) {
377
387
  })]
378
388
  });
379
389
  }
380
- var we = /* @__PURE__ */ new Set([
390
+ var Te = /* @__PURE__ */ new Set([
381
391
  "input",
382
392
  "password",
383
393
  "search",
@@ -398,12 +408,12 @@ var we = /* @__PURE__ */ new Set([
398
408
  "yearRange",
399
409
  "compound",
400
410
  "cascader"
401
- ]), Te = new Set([...we].map((e) => ve[e])), Ee = p(void 0), De = p("blur"), Oe = p({
411
+ ]), Ee = new Set([...Te].map((e) => ve[e])), De = p(void 0), Oe = p("blur"), ke = p({
402
412
  disabled: !1,
403
413
  readOnly: !1,
404
414
  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 }) {
415
+ }), Ae = [], je = {}, Me = {};
416
+ function Ne({ nested: e, initialValues: t, adapter: n, submitHiddenFields: r = !1, validateOn: i = "blur", form: s, fields: c = Ae, defaultValues: l = je, defaultValuesKey: u, components: d = Me, 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
417
  let A = a(), j = o(), M = le(s ? {} : {
408
418
  fields: c,
409
419
  defaultValues: l,
@@ -411,7 +421,10 @@ function Me({ nested: e, initialValues: t, adapter: n, submitHiddenFields: r = !
411
421
  initialValues: t,
412
422
  adapter: n,
413
423
  nested: e
414
- }), N = s ?? M, P = me(N), F = P.isSubmitting;
424
+ }), N = s ?? M, P = Z(N, (e) => ({
425
+ isSubmitting: e.isSubmitting,
426
+ isLoading: e.isLoading
427
+ })), F = P.isSubmitting;
415
428
  C ||= P.isLoading;
416
429
  let [I, L] = x(""), z = b(null);
417
430
  _(() => N.bindFieldLocator((e, t) => {
@@ -448,11 +461,11 @@ function Me({ nested: e, initialValues: t, adapter: n, submitHiddenFields: r = !
448
461
  ]), H = m || typeof p != "number", U = ge("grid", p, m);
449
462
  return /* @__PURE__ */ q(ue, {
450
463
  form: N,
451
- children: /* @__PURE__ */ q(Ee.Provider, {
464
+ children: /* @__PURE__ */ q(De.Provider, {
452
465
  value: g ?? j.form?.labelPlacement,
453
- children: /* @__PURE__ */ q(De.Provider, {
466
+ children: /* @__PURE__ */ q(Oe.Provider, {
454
467
  value: i,
455
- children: /* @__PURE__ */ q(Oe.Provider, {
468
+ children: /* @__PURE__ */ q(ke.Provider, {
456
469
  value: V,
457
470
  children: /* @__PURE__ */ J("form", {
458
471
  ref: z,
@@ -479,8 +492,8 @@ function Me({ nested: e, initialValues: t, adapter: n, submitHiddenFields: r = !
479
492
  children: [
480
493
  /* @__PURE__ */ J("div", {
481
494
  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, {
495
+ style: H ? void 0 : { gridTemplateColumns: `repeat(${Q(typeof p == "number" ? p : 1)},minmax(0,1fr))` },
496
+ children: [c.map((e) => /* @__PURE__ */ q(we, {
484
497
  field: e,
485
498
  components: d,
486
499
  fields: c,
@@ -515,8 +528,8 @@ function Me({ nested: e, initialValues: t, adapter: n, submitHiddenFields: r = !
515
528
  })
516
529
  });
517
530
  }
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(() => ({
531
+ function Pe({ 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 }) {
532
+ let k = Y(), A = g(Oe), j = g(De), M = T ?? j, N = g(ke), 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
533
  rules: [
521
534
  ...c && !l?.some((e) => e.required) ? [{ required: !0 }] : [],
522
535
  ...l ?? [],
@@ -543,15 +556,15 @@ function Ne({ children: e, name: t, label: i, description: o, required: c, rules
543
556
  t,
544
557
  V
545
558
  ]);
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) : () => {}, [
559
+ let H = Ce(k, t, R, P), U = F.error ? F : H?.error ?? F, ee = h((e) => typeof D == "function" || typeof E == "function" ? k.subscribeAll(e) : () => {}, [
547
560
  k,
548
561
  D,
549
562
  E
550
563
  ]);
551
564
  S(ee, k.getVersion, k.getVersion);
552
- let W = typeof D == "function" || typeof E == "function" ? k.getValues() : Ae;
565
+ let W = typeof D == "function" || typeof E == "function" ? k.getValues() : je;
553
566
  if (!V.visible(W)) return null;
554
- let G = M === "floating" && typeof i == "string" && m(e) && Te.has(e.type), K = {
567
+ let G = M === "floating" && typeof i == "string" && m(e) && Ee.has(e.type), K = {
555
568
  ...O,
556
569
  ...H ? {
557
570
  partStates: H.states,
@@ -575,7 +588,7 @@ function Ne({ children: e, name: t, label: i, description: o, required: c, rules
575
588
  "aria-invalid": !!U.error,
576
589
  "aria-describedby": U.error || o ? `${L}-help` : void 0
577
590
  };
578
- return /* @__PURE__ */ J(Q, {
591
+ return /* @__PURE__ */ J($, {
579
592
  name: t,
580
593
  placement: M,
581
594
  id: L,
@@ -595,5 +608,5 @@ function Ne({ children: e, name: t, label: i, description: o, required: c, rules
595
608
  })]
596
609
  });
597
610
  }
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 };
611
+ var Fe = Object.assign(Ne, { Field: Pe }), Ie = (e) => e;
612
+ export { _e as a, le as c, he as d, me as f, Ie as i, Y as l, de as m, $ as n, X as o, pe as p, ue as r, fe as s, Fe as t, Z 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-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-B-BSf2n1.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 };
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-C9eBd8Y7.js";
3
+ import { a as S, c as C, d as w, f as T, i as E, l as D, m as O, n as k, o as A, p as j, r as M, s as N, t as P, u as F } from "./form-D6O5PqrZ.js";
4
+ export { P as Form, k as FormItem, M 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, A as useField, N as useFieldArray, C as useForm, D as useFormContext, F as useFormSelector, w as useFormState, T as useFormStatus, j as useFormSummary, O 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-QDX_UWRh.js";
2
+ import { s as t } from "./useControllable-Dt38Jg9E.js";
3
3
  import { jsx as n } from "react/jsx-runtime";
4
4
  // src/icons/index.tsx
5
5
  var r = {
@@ -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-QDX_UWRh.js";
3
- import { t as l } from "./icons-BwE05e0C.js";
2
+ import { c as a, s as o, t as s, u as c } from "./useControllable-Dt38Jg9E.js";
3
+ import { t as l } from "./icons-B1dOXz-r.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";
@@ -218,13 +218,13 @@ var T = [], E = 0;
218
218
  function ee({ item: t, blocked: n, preview: o, onRemove: s, onRetry: c, onCancel: f, icons: p, sortActions: m, sortProps: h }) {
219
219
  let { t: g } = a(), [_, v] = i(""), [y, b] = i(!1), x = r(null);
220
220
  e(() => {
221
- if (!t.file) {
221
+ if (!t.file || S(t.url)) {
222
222
  v("");
223
223
  return;
224
224
  }
225
225
  let e = URL.createObjectURL(t.file);
226
226
  return v(e), () => URL.revokeObjectURL(e);
227
- }, [t.file]);
227
+ }, [t.file, t.url]);
228
228
  let C = S(t.url) ? t.url : _;
229
229
  return e(() => b(!1), [C]), /* @__PURE__ */ d("div", {
230
230
  className: "rfe-image-tile",
@@ -328,8 +328,8 @@ function ee({ item: t, blocked: n, preview: o, onRemove: s, onRetry: c, onCancel
328
328
  ]
329
329
  });
330
330
  }
331
- function D(c) {
332
- let { t: f } = a(), p = o(), h = t(), v = c.id ?? h, [S, C] = i(c.defaultValue ?? T), D = c.value ?? S, O = r(D), k = r(() => {}), [A] = i(() => w((e, t) => {
331
+ function D(s) {
332
+ let { t: f } = a(), p = o(), h = t(), v = s.id ?? h, [S, C] = i(s.defaultValue ?? T), D = s.value ?? S, O = r(D), k = r(() => {}), [A] = i(() => w((e, t) => {
333
333
  O.current.some((t) => t.uid === e) && k.current(O.current.map((n) => n.uid === e ? {
334
334
  ...n,
335
335
  ...t
@@ -337,51 +337,51 @@ function D(c) {
337
337
  })), [j, te] = i([]), [ne, M] = i(!1), N = r(null);
338
338
  n(() => {
339
339
  O.current = D, k.current = (e) => {
340
- O.current = e, c.value === void 0 && C(e), c.onChange?.(e);
340
+ O.current = e, s.value === void 0 && C(e), s.onChange?.(e);
341
341
  }, A.retain(new Set(D.filter((e) => e.status === "uploading").map((e) => e.uid)));
342
342
  }, [
343
343
  D,
344
- c.value,
345
- c.onChange,
344
+ s.value,
345
+ s.onChange,
346
346
  A
347
347
  ]), e(() => () => A.dispose(), [A]);
348
- let P = c.multiple !== !1, F = _(P, c.maxCount), I = F <= 1, L = c.maxSize ?? 5, re = c.accept ?? "image/jpeg,image/png,image/webp", R = !!(c.disabled || c.readOnly || c.loading), z = x(c, R), B = JSON.stringify(D.map((e) => e.uid)), ie = r(B);
348
+ let P = s.multiple !== !1, F = _(P, s.maxCount), I = F <= 1, L = s.maxSize ?? 5, re = s.accept ?? "image/jpeg,image/png,image/webp", R = !!(s.disabled || s.readOnly || s.loading), z = x(s, R), B = JSON.stringify(D.map((e) => e.uid)), ie = r(B);
349
349
  n(() => {
350
350
  ie.current !== B && z.cancel(), ie.current = B;
351
351
  }, [B]);
352
- let V = R || z.busy, { full: H } = g(D.length, F, P, c.replaceable), U = y(D, (e) => k.current(e), !!c.sortable && !V && P && D.length > 1), W = (e) => {
352
+ let V = R || z.busy, { full: H } = g(D.length, F, P, s.replaceable), U = y(D, (e) => k.current(e), !!s.sortable && !V && P && D.length > 1), W = (e) => {
353
353
  V || H || !e.length || z.prepare(e, (e) => {
354
354
  let t = I ? [] : O.current, n = m([], e, {
355
355
  maxCount: Math.max(0, F - t.length),
356
356
  maxSize: L,
357
357
  accept: re
358
358
  });
359
- if (te(n.rejected), n.rejected.length && c.onReject?.(n.rejected), !n.accepted.length) return;
359
+ if (te(n.rejected), n.rejected.length && s.onReject?.(n.rejected), !n.accepted.length) return;
360
360
  if (I) {
361
361
  A.dispose();
362
- for (let e of O.current) c.onRemove?.(e);
362
+ for (let e of O.current) s.onRemove?.(e);
363
363
  }
364
364
  let r = n.accepted.map((e) => ({
365
365
  uid: `${v}-${++E}`,
366
366
  name: e.name,
367
367
  file: e,
368
- status: c.mode === "mixed" ? "local" : "uploading",
368
+ status: s.mode === "mixed" ? "local" : "uploading",
369
369
  progress: 0
370
370
  }));
371
- if (k.current([...t, ...r]), c.mode === "upload") for (let e of r) A.start(e, c.upload);
371
+ if (k.current([...t, ...r]), s.mode === "upload") for (let e of r) A.start(e, s.upload);
372
372
  });
373
373
  }, ae = (e) => {
374
374
  if (V) return;
375
375
  let t = O.current.find((t) => t.uid === e);
376
- t && c.onRemove?.(t), A.abort(e), k.current(O.current.filter((t) => t.uid !== e)), te([]);
376
+ t && s.onRemove?.(t), A.abort(e), k.current(O.current.filter((t) => t.uid !== e)), te([]);
377
377
  }, G = (e) => {
378
378
  V || (A.abort(e), k.current(O.current.map((t) => t.uid === e ? {
379
379
  ...t,
380
380
  status: "ready",
381
381
  progress: 0
382
382
  } : t)));
383
- }, K = I && D.length ? f("replaceImage") : f("addImage"), q = c.status === "error" || c["aria-invalid"], J = [
384
- c["aria-describedby"],
383
+ }, K = I && D.length ? f("replaceImage") : f("addImage"), q = s.status === "error" || s["aria-invalid"], J = [
384
+ s["aria-describedby"],
385
385
  `${v}-hint`,
386
386
  j.length ? `${v}-rejected` : void 0
387
387
  ].filter(Boolean).join(" "), oe = {
@@ -391,29 +391,29 @@ function D(c) {
391
391
  };
392
392
  return /* @__PURE__ */ d("div", {
393
393
  role: "group",
394
- id: H || c.readOnly ? v : void 0,
395
- tabIndex: H && !c.disabled ? 0 : void 0,
396
- className: s("rfe-image-upload", c.className),
397
- style: c.style,
398
- "data-size": c.size ?? p.size,
399
- "data-status": q ? "error" : c.status ?? "default",
400
- "data-disabled": c.disabled || void 0,
394
+ id: H || s.readOnly ? v : void 0,
395
+ tabIndex: H && !s.disabled ? 0 : void 0,
396
+ className: c("rfe-image-upload", s.className),
397
+ style: s.style,
398
+ "data-size": s.size ?? p.size,
399
+ "data-status": q ? "error" : s.status ?? "default",
400
+ "data-disabled": s.disabled || void 0,
401
401
  "data-dragging": ne || void 0,
402
- "aria-label": c["aria-label"] ?? K,
402
+ "aria-label": s["aria-label"] ?? K,
403
403
  "aria-describedby": J,
404
404
  "aria-invalid": q || void 0,
405
405
  "aria-busy": z.busy || D.some((e) => e.status === "uploading") || void 0,
406
406
  onBlur: (e) => {
407
- e.currentTarget.contains(e.relatedTarget) || c.onBlur?.();
407
+ e.currentTarget.contains(e.relatedTarget) || s.onBlur?.();
408
408
  },
409
409
  onDragOver: (e) => {
410
- c.dragDrop !== !1 && e.dataTransfer.types.includes("Files") && (e.preventDefault(), e.dataTransfer.dropEffect = V || H ? "none" : "copy", !V && !H && M(!0));
410
+ s.dragDrop !== !1 && e.dataTransfer.types.includes("Files") && (e.preventDefault(), e.dataTransfer.dropEffect = V || H ? "none" : "copy", !V && !H && M(!0));
411
411
  },
412
412
  onDragLeave: (e) => {
413
413
  e.relatedTarget instanceof Node && e.currentTarget.contains(e.relatedTarget) || M(!1);
414
414
  },
415
415
  onDrop: (e) => {
416
- c.dragDrop !== !1 && e.dataTransfer.types.includes("Files") && (e.preventDefault(), M(!1), W(Array.from(e.dataTransfer.files)));
416
+ s.dragDrop !== !1 && e.dataTransfer.types.includes("Files") && (e.preventDefault(), M(!1), W(Array.from(e.dataTransfer.files)));
417
417
  },
418
418
  children: [
419
419
  /* @__PURE__ */ d("div", {
@@ -431,20 +431,20 @@ function D(c) {
431
431
  onDragEnd: U.reset
432
432
  }) : void 0,
433
433
  blocked: V,
434
- preview: (c.previewable ?? c.preview ?? !0) && !c.disabled,
435
- icons: c.icons,
434
+ preview: (s.previewable ?? s.preview ?? !0) && !s.disabled,
435
+ icons: s.icons,
436
436
  onRemove: () => ae(e.uid),
437
437
  onCancel: () => G(e.uid),
438
438
  onRetry: () => {
439
- c.mode === "upload" && !V && !A.has(e.uid) && A.start(e, c.upload);
439
+ s.mode === "upload" && !V && !A.has(e.uid) && A.start(e, s.upload);
440
440
  }
441
441
  }, e.uid)),
442
- !H && !c.readOnly && /* @__PURE__ */ d("button", {
442
+ !H && !s.readOnly && /* @__PURE__ */ d("button", {
443
443
  type: "button",
444
444
  id: v,
445
445
  className: "rfe-image-add",
446
446
  disabled: V,
447
- "aria-label": c["aria-label"] ?? K,
447
+ "aria-label": s["aria-label"] ?? K,
448
448
  "aria-describedby": J,
449
449
  "aria-invalid": q || void 0,
450
450
  onClick: () => N.current?.click(),
@@ -452,18 +452,18 @@ function D(c) {
452
452
  /* @__PURE__ */ u("span", {
453
453
  className: "rfe-image-add-icon",
454
454
  children: /* @__PURE__ */ u(l, {
455
- name: c.loading ? "loading" : "imageAdd",
456
- source: c.icons?.add
455
+ name: s.loading ? "loading" : "imageAdd",
456
+ source: s.icons?.add
457
457
  })
458
458
  }),
459
459
  /* @__PURE__ */ u("span", { children: K }),
460
- c.dragDrop !== !1 && /* @__PURE__ */ u("small", { children: f("dropImage") })
460
+ s.dragDrop !== !1 && /* @__PURE__ */ u("small", { children: f("dropImage") })
461
461
  ]
462
462
  }),
463
463
  /* @__PURE__ */ u("input", {
464
464
  ref: N,
465
465
  type: "file",
466
- name: c.name,
466
+ name: s.name,
467
467
  accept: re,
468
468
  multiple: !I && P,
469
469
  disabled: V || H,
@@ -477,7 +477,7 @@ function D(c) {
477
477
  /* @__PURE__ */ d("div", {
478
478
  className: "rfe-image-meta",
479
479
  id: `${v}-hint`,
480
- children: [/* @__PURE__ */ u("span", { children: f("imageHint", { max: L }) }), (c.showCount ?? F > 1) && /* @__PURE__ */ d("span", { children: [
480
+ children: [/* @__PURE__ */ u("span", { children: f("imageHint", { max: L }) }), (s.showCount ?? F > 1) && /* @__PURE__ */ d("span", { children: [
481
481
  D.length,
482
482
  " / ",
483
483
  F
@@ -573,7 +573,7 @@ function te({ file: t, onRemove: n, preview: o, removeIcon: s, previewIcon: c, s
573
573
  });
574
574
  }
575
575
  function ne({ id: e, name: p, value: h, defaultValue: v, onChange: S, onBlur: C, disabled: w, readOnly: T, loading: E, status: ee, size: D, variant: k, className: A, style: ne, multiple: M = !0, dragDrop: N = !0, preview: P = !0, sortable: F = !1, maxCount: I = 3, maxSize: L = 5, accept: re = f, icons: R, onReject: z, showCount: B, replaceable: ie = !1, previewable: V, beforeUpload: H, onPrepareError: U, ...W }) {
576
- let ae = o(), { t: G } = a(), K = t(), q = e ?? K, [J, oe] = c(h, v ?? O, S), Y = Array.isArray(J) ? J : O, [se, ce] = i([]), [le, ue] = i(!1), de = r(null), X = _(M, I), fe = X <= 1, pe = !!(w || T || E), me = x({
576
+ let ae = o(), { t: G } = a(), K = t(), q = e ?? K, [J, oe] = s(h, v ?? O, S), Y = Array.isArray(J) ? J : O, [se, ce] = i([]), [le, ue] = i(!1), de = r(null), X = _(M, I), fe = X <= 1, pe = !!(w || T || E), me = x({
577
577
  beforeUpload: H,
578
578
  onPrepareError: U
579
579
  }, pe), he = r(Y);
@@ -605,7 +605,7 @@ function ne({ id: e, name: p, value: h, defaultValue: v, onChange: S, onBlur: C,
605
605
  "aria-label": W["aria-label"] ?? ve,
606
606
  "aria-describedby": be,
607
607
  "aria-invalid": ye || void 0,
608
- className: s("rfe-image-upload", A),
608
+ className: c("rfe-image-upload", A),
609
609
  style: ne,
610
610
  "data-size": D ?? ae.size,
611
611
  "data-variant": k ?? ae.variant,
@@ -706,6 +706,10 @@ function ne({ id: e, name: p, value: h, defaultValue: v, onChange: S, onBlur: C,
706
706
  });
707
707
  }
708
708
  function M(e) {
709
- return e.mode === "upload" || e.mode === "mixed" ? /* @__PURE__ */ u(D, { ...e }) : /* @__PURE__ */ u(ne, { ...e });
709
+ let t = {
710
+ ...o().components?.ImageUpload,
711
+ ...e
712
+ };
713
+ return t.mode === "upload" || t.mode === "mixed" ? /* @__PURE__ */ u(D, { ...t }) : /* @__PURE__ */ u(ne, { ...t });
710
714
  }
711
715
  export { C as i, w as n, S as r, M as t };
@@ -1 +1 @@
1
- export { t as ImageUpload, n as createImageUploadTasks, r as isImageUrl, i as uploadedImagesRule } from "./image-upload-D9oPG0Eh.js";
1
+ export { t as ImageUpload, n as createImageUploadTasks, r as isImageUrl, i as uploadedImagesRule } from "./image-upload-BFVs81x3.js";
package/dist/index.js CHANGED
@@ -1,15 +1,15 @@
1
- import { a as e, i as t, n, o as r, r as i, s as a } from "./useControllable-QDX_UWRh.js";
2
- import { n as o, t as s } from "./icons-BwE05e0C.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-DpZdLaoP.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-Bci1y8cc.js";
5
- import { n as P, t as F } from "./slider-AM0Egz9P.js";
6
- import { n as I, t as L } from "./Select-CoEW4UIq.js";
7
- import { t as R } from "./TreeSelect-BWksr9iW.js";
8
- import { t as z } from "./Cascader-iWlk7VJR.js";
9
- import { a as B, c as V, d as H, f as U, i as W, l as G, n as K, o as q, p as J, r as Y, s as X, t as Z, u as Q } from "./form-B-BSf2n1.js";
10
- import { i as $, n as ee, r as te, t as ne } from "./image-upload-D9oPG0Eh.js";
11
- import { n as re, r as ie, t as ae } from "./validation-D6vk5NAv.js";
12
- import { a as oe, i as se, n as ce, o as le, r as ue, s as de, t as fe } from "./locale-yHkdw2xz.js";
13
- import { _ as pe, a as me, c as he, d as ge, f as _e, g as ve, h as ye, i as be, l as xe, m as Se, n as Ce, o as we, p as Te, r as Ee, s as De, t as Oe, u as ke, v as Ae, y as je } from "./store-CFSQW-Fv.js";
14
- import { a as Me, c as Ne, d as Pe, f as Fe, i as Ie, l as Le, n as Re, o as ze, r as Be, s as Ve, t as He, u as Ue } from "./compound-BW6G7E_-.js";
15
- export { g as Autocomplete, S as Button, z as Cascader, _ as Checkbox, b as CheckboxGroup, He as CompoundField, n as ConfigProvider, Fe as ControlGroup, M as DatePicker, O as DateRangePicker, A as DateTimePicker, E as DateTimeRangePicker, p as DecimalInput, m as FloatingInput, Z as Form, K as FormItem, Y as FormProvider, s as Icon, c as IconButton, ne as ImageUpload, v as Input, Re as InputRange, Be as InputSelect, w as MonthPicker, k as MonthRangePicker, L as MultiSelect, x as NumberInput, Ie as NumberSelect, Me as NumberUnit, l as Password, h as RadioGroup, F as RangeSlider, ze 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, we as changedOutputValues, De as cloneValues, Ve as compoundDefaults, Ne as compoundRule, Le as compoundValues, Oe as createFormStore, ee as createImageUploadTasks, Ee as createPathAdapter, a as cx, W as defineComponents, B as defineForm, fe as defineLocale, he as defineValueAdapter, ge as editArray, ce as enUS, Ce as equalValue, be as expandPaths, _e as fieldSegments, ue as formatIssue, se as formatPickerValue, me as getPathValue, Te as hasPath, xe as inputValues, Se as isArrayIndex, ae as isEmpty, te as isImageUrl, ye as isPlainRecord, ve as normalizePaths, pe as omitPaths, ke as outputValues, Ue as partDisabled, Pe as partVisible, Ae as readPath, oe as resolveLocale, i as tokenStyle, le as translate, $ as uploadedImagesRule, t as useConfig, q as useField, X as useFieldArray, V as useForm, G as useFormContext, Q as useFormState, H as useFormStatus, U as useFormSummary, e as useLocale, r as useText, J as useWatch, re as validateRuleIssue, ie as validateRules, je as writePath, de as zhCN };
1
+ import { a as e, c as t, i as n, l as r, n as i, o as a, r as o, s, u as c } from "./useControllable-Dt38Jg9E.js";
2
+ import { n as l, t as u } from "./icons-B1dOXz-r.js";
3
+ import { a as d, c as f, d as p, f as m, g as h, h as g, i as _, l as v, m as y, n as b, o as x, p as S, r as C, s as w, t as T, u as E } from "./inputs-w_es2t_C.js";
4
+ import { a as D, c as O, i as k, l as A, n as j, o as M, r as N, s as P, t as F, u as I } from "./pickers-5zLmSrsp.js";
5
+ import { n as L, t as R } from "./slider-Bhd1Z4LP.js";
6
+ import { n as z, t as B } from "./Select-BxwT7MHH.js";
7
+ import { t as V } from "./TreeSelect-W5sgU5nW.js";
8
+ import { t as H } from "./Cascader-COGUcdDS.js";
9
+ import { a as U, c as W, d as G, f as K, i as q, l as J, m as Y, n as X, o as Z, p as Q, r as $, s as ee, t as te, u as ne } from "./form-D6O5PqrZ.js";
10
+ import { i as re, n as ie, r as ae, t as oe } from "./image-upload-BFVs81x3.js";
11
+ import { n as se, r as ce, t as le } from "./validation-D6vk5NAv.js";
12
+ import { a as ue, i as de, n as fe, o as pe, r as me, s as he, t as ge } from "./locale-yHkdw2xz.js";
13
+ import { _ as _e, a as ve, c as ye, d as be, f as xe, g as Se, h as Ce, i as we, l as Te, m as Ee, n as De, o as Oe, p as ke, r as Ae, s as je, t as Me, u as Ne, v as Pe, y as Fe } from "./store-C9eBd8Y7.js";
14
+ import { a as Ie, c as Le, d as Re, f as ze, i as Be, l as Ve, n as He, o as Ue, r as We, s as Ge, t as Ke, u as qe } from "./compound-nXxRSVJu.js";
15
+ export { y as Autocomplete, T as Button, H as Cascader, b as Checkbox, C as CheckboxGroup, Ke as CompoundField, i as ConfigProvider, ze as ControlGroup, F as DatePicker, j as DateRangePicker, N as DateTimePicker, k as DateTimeRangePicker, g as DecimalInput, _ as FloatingInput, te as Form, X as FormItem, $ as FormProvider, u as Icon, d as IconButton, oe as ImageUpload, x as Input, He as InputRange, We as InputSelect, D as MonthPicker, M as MonthRangePicker, B as MultiSelect, w as NumberInput, Be as NumberSelect, Ie as NumberUnit, f as Password, v as RadioGroup, R as RangeSlider, Ue as SearchGroup, E as SearchInput, p as Segmented, z as Select, L as Slider, l as SvgIcon, m as Switch, h as TagsInput, S as Textarea, P as TimePicker, O as TimeRangePicker, V as TreeSelect, A as YearPicker, I as YearRangePicker, Oe as changedOutputValues, je as cloneValues, Ge as compoundDefaults, Le as compoundRule, Ve as compoundValues, Me as createFormStore, ie as createImageUploadTasks, Ae as createPathAdapter, c as cx, q as defineComponents, U as defineForm, ge as defineLocale, ye as defineValueAdapter, be as editArray, fe as enUS, De as equalValue, we as expandPaths, xe as fieldSegments, me as formatIssue, de as formatPickerValue, ve as getPathValue, ke as hasPath, Te as inputValues, Ee as isArrayIndex, le as isEmpty, ae as isImageUrl, Ce as isPlainRecord, o as motionDuration, n as motionEnabled, Se as normalizePaths, _e as omitPaths, Ne as outputValues, qe as partDisabled, Re as partVisible, Pe as readPath, ue as resolveLocale, e as scopeTokenStyle, a as tokenStyle, pe as translate, re as uploadedImagesRule, s as useConfig, Z as useField, ee as useFieldArray, W as useForm, J as useFormContext, ne as useFormSelector, G as useFormState, K as useFormStatus, Q as useFormSummary, t as useLocale, r as useText, Y as useWatch, se as validateRuleIssue, ce as validateRules, Fe as writePath, he as zhCN };
package/dist/input.js CHANGED
@@ -1 +1 @@
1
- export { m as Autocomplete, h as DecimalInput, i as FloatingInput, o as Input, s as NumberInput, c as Password, u as SearchInput, d as Segmented, g as TagsInput, p as Textarea } from "./inputs-DpZdLaoP.js";
1
+ export { m as Autocomplete, h as DecimalInput, i as FloatingInput, o as Input, s as NumberInput, c as Password, u as SearchInput, d as Segmented, f as Switch, g as TagsInput, p as Textarea } from "./inputs-w_es2t_C.js";