@llmnative/react 1.39.1 → 1.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +8 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +273 -263
- package/dist/index.mjs.map +1 -1
- package/dist/types/src/components/ui/fields/Input.d.ts +5 -2
- package/dist/types/src/components/widgets/Form.d.ts +8 -0
- package/llms-full.txt +12 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -8457,56 +8457,64 @@ var Ec = "mb-1 block text-sm font-medium leading-5 text-foreground", Dc = "mt-1
|
|
|
8457
8457
|
value: typeof s == "string" ? s : s == null ? "" : JSON.stringify(s),
|
|
8458
8458
|
readOnly: !0
|
|
8459
8459
|
});
|
|
8460
|
-
}, tl = ({ name: e, onChange: t = void 0, defaultValue: n = void 0, label: r = void 0, title: i = void 0, ariaLabel: a = void 0, required: o = !1, valueChecked: s = "on",
|
|
8461
|
-
let { id:
|
|
8460
|
+
}, tl = ({ name: e, onChange: t = void 0, defaultValue: n = void 0, label: r = void 0, title: i = void 0, ariaLabel: a = void 0, required: o = !1, valueChecked: s = "on", disabled: c = !1, before: l = void 0, after: u = void 0, inheritWrapperClassName: f = !0, wrapperClassName: p = void 0, className: m = void 0 }) => {
|
|
8461
|
+
let { id: h, checked: g, formWrapClass: _, handleCheckboxChange: v } = Bc({
|
|
8462
8462
|
name: e,
|
|
8463
8463
|
onChange: t,
|
|
8464
|
-
wrapperClassName:
|
|
8464
|
+
wrapperClassName: p,
|
|
8465
8465
|
defaultValue: n,
|
|
8466
8466
|
valueChecked: s,
|
|
8467
|
-
inheritWrapperClassName:
|
|
8468
|
-
}),
|
|
8467
|
+
inheritWrapperClassName: f
|
|
8468
|
+
}), y = fp(e, {
|
|
8469
8469
|
required: o,
|
|
8470
8470
|
label: r
|
|
8471
8471
|
});
|
|
8472
|
-
return /* @__PURE__ */ d.createElement(Z, { className:
|
|
8472
|
+
return /* @__PURE__ */ d.createElement(Z, { className: _ }, /* @__PURE__ */ d.createElement("div", {
|
|
8473
|
+
className: "flex items-center gap-2",
|
|
8474
|
+
title: c ? i : void 0
|
|
8475
|
+
}, l, /* @__PURE__ */ d.createElement("input", {
|
|
8473
8476
|
type: "checkbox",
|
|
8474
|
-
id:
|
|
8477
|
+
id: h,
|
|
8475
8478
|
name: e,
|
|
8476
8479
|
title: i,
|
|
8477
8480
|
"aria-label": a,
|
|
8478
|
-
className: X("h-4 w-4 shrink-0 rounded-sm border border-input bg-background text-primary shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
|
|
8479
|
-
checked:
|
|
8480
|
-
|
|
8481
|
+
className: X("h-4 w-4 shrink-0 rounded-sm border border-input bg-background text-primary shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50", m),
|
|
8482
|
+
checked: g,
|
|
8483
|
+
disabled: c,
|
|
8484
|
+
onChange: v
|
|
8481
8485
|
}), r && /* @__PURE__ */ d.createElement("label", {
|
|
8482
|
-
className: "text-sm font-medium leading-none text-foreground",
|
|
8483
|
-
htmlFor:
|
|
8484
|
-
}, r, o && /* @__PURE__ */ d.createElement("span", { className: "text-destructive" }, "\xA0*")),
|
|
8485
|
-
}, nl = ({ name: e, onChange: t = void 0, defaultValue: n = void 0, label: r = void 0, title: i = void 0, ariaLabel: a = void 0, required: o = !1, valueChecked: s = "on",
|
|
8486
|
-
let { id:
|
|
8486
|
+
className: X("text-sm font-medium leading-none text-foreground", c && "cursor-not-allowed opacity-50"),
|
|
8487
|
+
htmlFor: h
|
|
8488
|
+
}, r, o && /* @__PURE__ */ d.createElement("span", { className: "text-destructive" }, "\xA0*")), u), y && /* @__PURE__ */ d.createElement(zc, { message: y }));
|
|
8489
|
+
}, nl = ({ name: e, onChange: t = void 0, defaultValue: n = void 0, label: r = void 0, title: i = void 0, ariaLabel: a = void 0, required: o = !1, valueChecked: s = "on", disabled: c = !1, before: l = void 0, after: u = void 0, inheritWrapperClassName: f = !0, wrapperClassName: p = void 0, className: m = void 0 }) => {
|
|
8490
|
+
let { id: h, checked: g, formWrapClass: _, handleCheckboxChange: v } = Bc({
|
|
8487
8491
|
name: e,
|
|
8488
8492
|
onChange: t,
|
|
8489
|
-
wrapperClassName:
|
|
8493
|
+
wrapperClassName: p,
|
|
8490
8494
|
defaultValue: n,
|
|
8491
8495
|
valueChecked: s,
|
|
8492
|
-
inheritWrapperClassName:
|
|
8493
|
-
}),
|
|
8496
|
+
inheritWrapperClassName: f
|
|
8497
|
+
}), y = fp(e, {
|
|
8494
8498
|
required: o,
|
|
8495
8499
|
label: r
|
|
8496
8500
|
});
|
|
8497
|
-
return /* @__PURE__ */ d.createElement(Z, { className:
|
|
8498
|
-
|
|
8501
|
+
return /* @__PURE__ */ d.createElement(Z, { className: _ }, /* @__PURE__ */ d.createElement("div", { className: "flex items-center gap-2" }, l, /* @__PURE__ */ d.createElement("label", {
|
|
8502
|
+
className: X("inline-flex items-center gap-2 select-none", c ? "cursor-not-allowed opacity-50" : "cursor-pointer"),
|
|
8503
|
+
title: c ? i : void 0
|
|
8504
|
+
}, /* @__PURE__ */ d.createElement("span", { className: "relative inline-flex h-5 w-9 shrink-0 items-center" }, /* @__PURE__ */ d.createElement("input", {
|
|
8505
|
+
id: h,
|
|
8499
8506
|
name: e,
|
|
8500
8507
|
type: "checkbox",
|
|
8501
8508
|
title: i,
|
|
8502
8509
|
"aria-label": a,
|
|
8503
|
-
checked:
|
|
8504
|
-
|
|
8505
|
-
|
|
8510
|
+
checked: g,
|
|
8511
|
+
disabled: c,
|
|
8512
|
+
onChange: v,
|
|
8513
|
+
className: X("peer absolute inset-0 m-0 h-full w-full opacity-0", c ? "cursor-not-allowed" : "cursor-pointer")
|
|
8506
8514
|
}), /* @__PURE__ */ d.createElement("span", {
|
|
8507
8515
|
"aria-hidden": "true",
|
|
8508
|
-
className: X("pointer-events-none absolute inset-0 rounded-full transition-colors duration-200 ease-out peer-focus-visible:ring-2 peer-focus-visible:ring-ring peer-focus-visible:ring-offset-2",
|
|
8509
|
-
}, /* @__PURE__ */ d.createElement("span", { className: X("pointer-events-none absolute top-0.5 left-0.5 h-4 w-4 rounded-full bg-background shadow-sm transition-transform duration-200 ease-out",
|
|
8516
|
+
className: X("pointer-events-none absolute inset-0 rounded-full transition-colors duration-200 ease-out peer-focus-visible:ring-2 peer-focus-visible:ring-ring peer-focus-visible:ring-offset-2", g ? "bg-primary" : "bg-muted-foreground/35", m)
|
|
8517
|
+
}, /* @__PURE__ */ d.createElement("span", { className: X("pointer-events-none absolute top-0.5 left-0.5 h-4 w-4 rounded-full bg-background shadow-sm transition-transform duration-200 ease-out", g && "translate-x-4") }))), r && /* @__PURE__ */ d.createElement("span", { className: "text-sm font-medium leading-none text-foreground" }, r, o && /* @__PURE__ */ d.createElement("span", { className: "text-destructive" }, "\xA0*"))), u), y && /* @__PURE__ */ d.createElement(zc, { message: y }));
|
|
8510
8518
|
}, rl = ({ label: e, required: t = !1, htmlFor: n = void 0, className: r = void 0 }) => /* @__PURE__ */ d.createElement("label", {
|
|
8511
8519
|
htmlFor: n,
|
|
8512
8520
|
className: X(Ec, r)
|
|
@@ -14353,62 +14361,62 @@ function xp(e) {
|
|
|
14353
14361
|
subscribe: (e) => (n.add(e), () => n.delete(e))
|
|
14354
14362
|
};
|
|
14355
14363
|
}
|
|
14356
|
-
var Sp = {}, Cp = ({ children: e, appearance: t = void 0, controller: n = void 0, header: r = void 0, footer: i = void 0, path: a = void 0, defaultValues: o = void 0, keyGenerator: s = void 0, onLoad: c = void 0, onRecordChange: l = void 0, onSave: u = void 0, onDelete: f = void 0, onComplete: p = void 0, log: m = !1, showNotice: h = !0,
|
|
14357
|
-
let
|
|
14358
|
-
|
|
14359
|
-
let
|
|
14360
|
-
if (!
|
|
14361
|
-
let e = yt(
|
|
14364
|
+
var Sp = {}, Cp = ({ children: e, appearance: t = void 0, controller: n = void 0, header: r = void 0, footer: i = void 0, path: a = void 0, defaultValues: o = void 0, keyGenerator: s = void 0, onLoad: c = void 0, onRecordChange: l = void 0, onSave: u = void 0, onDelete: f = void 0, onComplete: p = void 0, log: m = !1, showNotice: h = !0, requireChanges: g = !0, draftBucket: v = void 0, noticeAnchorRef: b = void 0, showBack: x = !1, wrapperClassName: S = void 0, headerClassName: D = void 0, className: O = void 0, footerClassName: k = void 0, formClassName: A = void 0 }) => {
|
|
14365
|
+
let M = j(), N = J("form"), P = Y("form"), F = zi(), I = rp(n), L = ep(I), R = w(void 0);
|
|
14366
|
+
R.current ||= xp(o);
|
|
14367
|
+
let z = R.current, B = E(z.subscribe, z.getRecord), V = z.setRecord, [U, W] = T(!1), [ee, te] = T(!1), ne = !o?.[uo], G = w(Ft(o ?? {})), [K, re] = T(() => yp(o)), [ie, ae] = T(null), oe = w({ isDirty: !1 }), se = C(() => {
|
|
14368
|
+
if (!v) return;
|
|
14369
|
+
let e = yt(v), t = yt(a || `${M.pathname}${M.hash || ""}`);
|
|
14362
14370
|
return e && t ? `llmnative.form-draft.${e}.${t}` : void 0;
|
|
14363
14371
|
}, [
|
|
14364
|
-
|
|
14365
|
-
|
|
14366
|
-
|
|
14372
|
+
v,
|
|
14373
|
+
M.pathname,
|
|
14374
|
+
M.hash,
|
|
14367
14375
|
a
|
|
14368
|
-
]),
|
|
14369
|
-
|
|
14370
|
-
}, [
|
|
14371
|
-
if (
|
|
14372
|
-
}, [
|
|
14373
|
-
|
|
14374
|
-
}, []), [
|
|
14375
|
-
h &&
|
|
14376
|
+
]), ce = !!(u || a || !ne), le = !(!f && ne), ue = C(() => !Kt(B, G.current), [B, G.current]), de = P.noChangesToSave ?? "No changes to save", fe = P.draftRestoreTitle ?? "Unsaved changes found", pe = P.draftRestoreMessage ?? "A local draft is available for this form. Restore it or discard it.", q = P.draftRestoreAction ?? "Restore", me = P.draftDiscardAction ?? "Discard", he = P.draftRestoredTitle ?? "Draft restored", ge = P.draftRestoredMessage ?? "The local draft has been restored. You can still discard it for a few seconds.", _e = _(() => {
|
|
14377
|
+
se && typeof localStorage < "u" && localStorage.removeItem(se);
|
|
14378
|
+
}, [se]), ve = _(() => {
|
|
14379
|
+
if (se && typeof localStorage < "u") return bp(localStorage.getItem(se));
|
|
14380
|
+
}, [se]), ye = _(() => {
|
|
14381
|
+
V(Ft(G.current));
|
|
14382
|
+
}, []), [be, xe] = T(void 0), Se = _(({ message: e, type: t = "danger" }) => {
|
|
14383
|
+
h && xe({
|
|
14376
14384
|
type: t,
|
|
14377
14385
|
message: e
|
|
14378
14386
|
});
|
|
14379
|
-
}, [h]), [
|
|
14380
|
-
|
|
14381
|
-
}, [
|
|
14382
|
-
let e =
|
|
14387
|
+
}, [h]), [Ce, we] = T({}), Te = w({}), Ee = w(null), De = w(B), Oe = w(o), ke = w(u), Ae = w(f), je = w(p), Me = w(a), Ne = w(m), Pe = _(() => {
|
|
14388
|
+
_e(), ye(), ae(null);
|
|
14389
|
+
}, [_e, ye]), Fe = _(() => {
|
|
14390
|
+
let e = ve();
|
|
14383
14391
|
if (!e) {
|
|
14384
|
-
|
|
14392
|
+
ae(null);
|
|
14385
14393
|
return;
|
|
14386
14394
|
}
|
|
14387
|
-
|
|
14388
|
-
}, [
|
|
14389
|
-
|
|
14390
|
-
}, [
|
|
14391
|
-
|
|
14392
|
-
}, []), Le = _((e) => {
|
|
14393
|
-
delete we.current[e];
|
|
14395
|
+
V(Ft(e)), ae("restored");
|
|
14396
|
+
}, [ve]), Ie = _(() => {
|
|
14397
|
+
we({}), xe(void 0), ae(null), ye();
|
|
14398
|
+
}, [ye]), Le = _((e, t) => {
|
|
14399
|
+
Te.current[e] = t;
|
|
14394
14400
|
}, []), Re = _((e) => {
|
|
14395
|
-
|
|
14401
|
+
delete Te.current[e];
|
|
14402
|
+
}, []), ze = _((e) => {
|
|
14403
|
+
we((t) => {
|
|
14396
14404
|
if (!t[e]) return t;
|
|
14397
14405
|
let { [e]: n, ...r } = t;
|
|
14398
14406
|
return r;
|
|
14399
14407
|
});
|
|
14400
|
-
}, []),
|
|
14408
|
+
}, []), Be = _(async () => {
|
|
14401
14409
|
let e = {};
|
|
14402
|
-
for (let [t, n] of Object.entries(
|
|
14410
|
+
for (let [t, n] of Object.entries(Te.current)) {
|
|
14403
14411
|
let { required: r, label: i, validator: a } = n.current, o = t.split(".").reduce((e, t) => {
|
|
14404
14412
|
if (e != null) {
|
|
14405
14413
|
if (Array.isArray(e)) return e[Number(t)];
|
|
14406
14414
|
if (typeof e == "object") return e[t];
|
|
14407
14415
|
}
|
|
14408
|
-
},
|
|
14416
|
+
}, De.current);
|
|
14409
14417
|
if (r && (o == null || typeof o == "string" && o.trim() === "" || Array.isArray(o) && o.length === 0)) {
|
|
14410
14418
|
let n = ul(i);
|
|
14411
|
-
e[t] = n ? Bn(
|
|
14419
|
+
e[t] = n ? Bn(P.requiredField, { field: n }) : P.requiredFieldGeneric;
|
|
14412
14420
|
continue;
|
|
14413
14421
|
}
|
|
14414
14422
|
if (a) {
|
|
@@ -14416,17 +14424,17 @@ var Sp = {}, Cp = ({ children: e, appearance: t = void 0, controller: n = void 0
|
|
|
14416
14424
|
n && (e[t] = n);
|
|
14417
14425
|
}
|
|
14418
14426
|
}
|
|
14419
|
-
if (
|
|
14427
|
+
if (we(e), Object.keys(e).length > 0) {
|
|
14420
14428
|
let t = Object.keys(e)[0];
|
|
14421
14429
|
requestAnimationFrame(() => {
|
|
14422
|
-
|
|
14430
|
+
Ee.current?.querySelector(`[name="${CSS.escape(t)}"]`)?.focus();
|
|
14423
14431
|
});
|
|
14424
14432
|
}
|
|
14425
14433
|
return Object.keys(e).length === 0;
|
|
14426
|
-
}, [
|
|
14434
|
+
}, [P]), Ve = _((e) => {
|
|
14427
14435
|
if (!a) return;
|
|
14428
14436
|
let t = vt(a);
|
|
14429
|
-
if (
|
|
14437
|
+
if (ne) return t.split("/").filter(Boolean).length % 2 == 0 && !s ? `/${t}` : `/${t}/${s?.(e) ?? Date.now().toString()}`;
|
|
14430
14438
|
let n = e[uo];
|
|
14431
14439
|
if (!n) return a;
|
|
14432
14440
|
let r = t.split("/").filter(Boolean);
|
|
@@ -14434,99 +14442,100 @@ var Sp = {}, Cp = ({ children: e, appearance: t = void 0, controller: n = void 0
|
|
|
14434
14442
|
}, [
|
|
14435
14443
|
a,
|
|
14436
14444
|
s,
|
|
14437
|
-
|
|
14438
|
-
]),
|
|
14439
|
-
if (
|
|
14445
|
+
ne
|
|
14446
|
+
]), He = _(async (e) => {
|
|
14447
|
+
if (Ne.current && Me.current && F) {
|
|
14440
14448
|
let t = (/* @__PURE__ */ new Date()).toISOString(), n = di("user");
|
|
14441
|
-
|
|
14449
|
+
F.set(`/log/${Me.current}/${yt(t)}`, {
|
|
14442
14450
|
user: n?.email ?? "unknown",
|
|
14443
14451
|
when: t,
|
|
14444
14452
|
action: e,
|
|
14445
|
-
record:
|
|
14453
|
+
record: De.current
|
|
14446
14454
|
});
|
|
14447
14455
|
}
|
|
14448
|
-
return
|
|
14449
|
-
message: e === "delete" ?
|
|
14456
|
+
return Se({
|
|
14457
|
+
message: e === "delete" ? P.deleteSuccess : P.saveSuccess,
|
|
14450
14458
|
type: "success"
|
|
14451
|
-
}), await
|
|
14452
|
-
record:
|
|
14459
|
+
}), await je.current?.({
|
|
14460
|
+
record: De.current,
|
|
14453
14461
|
action: e
|
|
14454
14462
|
}) ?? !0;
|
|
14455
14463
|
}, [
|
|
14456
|
-
|
|
14457
|
-
|
|
14458
|
-
|
|
14459
|
-
]),
|
|
14460
|
-
if (e?.preventDefault?.(), !
|
|
14461
|
-
message:
|
|
14464
|
+
F,
|
|
14465
|
+
Se,
|
|
14466
|
+
P
|
|
14467
|
+
]), Ue = _(async (e) => {
|
|
14468
|
+
if (e?.preventDefault?.(), g && !ue) return h && xe({
|
|
14469
|
+
message: de,
|
|
14462
14470
|
type: "info"
|
|
14463
14471
|
}), !1;
|
|
14464
14472
|
if (H(() => {
|
|
14465
|
-
|
|
14466
|
-
}), !await
|
|
14467
|
-
message:
|
|
14473
|
+
we({}), h && xe(void 0);
|
|
14474
|
+
}), !await Be()) return h && xe({
|
|
14475
|
+
message: P.noticeRequiredFields,
|
|
14468
14476
|
type: "warning"
|
|
14469
14477
|
}), !1;
|
|
14470
|
-
let t =
|
|
14471
|
-
|
|
14478
|
+
let t = ne ? "create" : "update";
|
|
14479
|
+
W(!0);
|
|
14472
14480
|
try {
|
|
14473
|
-
let e = (
|
|
14474
|
-
record:
|
|
14475
|
-
prevRecord:
|
|
14481
|
+
let e = (ke.current && await ke.current({
|
|
14482
|
+
record: De.current,
|
|
14483
|
+
prevRecord: Oe.current,
|
|
14476
14484
|
action: t,
|
|
14477
|
-
storagePath:
|
|
14478
|
-
})) ??
|
|
14479
|
-
return e && await
|
|
14485
|
+
storagePath: Me.current
|
|
14486
|
+
})) ?? Ve(De.current ?? {});
|
|
14487
|
+
return e && await F.set(e, Wt(De.current)), G.current = Ft(De.current ?? {}), re(yp(De.current)), _e(), ae(null), await He(t);
|
|
14480
14488
|
} finally {
|
|
14481
|
-
|
|
14489
|
+
W(!1);
|
|
14482
14490
|
}
|
|
14483
14491
|
}, [
|
|
14484
|
-
|
|
14485
|
-
Be,
|
|
14486
|
-
P,
|
|
14487
|
-
N.noticeRequiredFields,
|
|
14492
|
+
_e,
|
|
14488
14493
|
Ve,
|
|
14489
|
-
|
|
14490
|
-
|
|
14494
|
+
F,
|
|
14495
|
+
P.noticeRequiredFields,
|
|
14496
|
+
He,
|
|
14491
14497
|
ue,
|
|
14498
|
+
ne,
|
|
14499
|
+
de,
|
|
14500
|
+
g,
|
|
14492
14501
|
h,
|
|
14493
|
-
|
|
14494
|
-
]),
|
|
14495
|
-
e?.preventDefault?.(), h &&
|
|
14502
|
+
Be
|
|
14503
|
+
]), We = _(async (e) => {
|
|
14504
|
+
e?.preventDefault?.(), h && xe(void 0), te(!0);
|
|
14496
14505
|
try {
|
|
14497
|
-
let e = (
|
|
14498
|
-
return e && await
|
|
14506
|
+
let e = (Ae.current && await Ae.current({ record: De.current })) ?? Ve(De.current ?? {});
|
|
14507
|
+
return e && await F.remove(e), _e(), ae(null), await He("delete");
|
|
14499
14508
|
} finally {
|
|
14500
|
-
|
|
14509
|
+
te(!1);
|
|
14501
14510
|
}
|
|
14502
14511
|
}, [
|
|
14503
|
-
|
|
14504
|
-
Be,
|
|
14505
|
-
P,
|
|
14512
|
+
_e,
|
|
14506
14513
|
Ve,
|
|
14514
|
+
F,
|
|
14515
|
+
He,
|
|
14507
14516
|
h
|
|
14508
14517
|
]);
|
|
14509
14518
|
y(() => {
|
|
14510
14519
|
let e = Ft(o ?? {});
|
|
14511
|
-
if (o && (
|
|
14512
|
-
|
|
14520
|
+
if (o && (V(e), c?.(Ft(e))), G.current = e, re(yp(e)), !v) {
|
|
14521
|
+
ae(null);
|
|
14513
14522
|
return;
|
|
14514
14523
|
}
|
|
14515
|
-
let t =
|
|
14524
|
+
let t = ve();
|
|
14516
14525
|
if (t && yp(t) !== yp(e)) {
|
|
14517
|
-
|
|
14526
|
+
ae("restore");
|
|
14518
14527
|
return;
|
|
14519
14528
|
}
|
|
14520
|
-
|
|
14529
|
+
ae(null);
|
|
14521
14530
|
}, [
|
|
14522
14531
|
JSON.stringify(o),
|
|
14523
|
-
|
|
14532
|
+
v,
|
|
14524
14533
|
c,
|
|
14525
|
-
|
|
14534
|
+
ve
|
|
14526
14535
|
]), y(() => {
|
|
14527
|
-
|
|
14528
|
-
}, [
|
|
14529
|
-
|
|
14536
|
+
De.current = B, B !== void 0 && l?.(B);
|
|
14537
|
+
}, [B, l]), y(() => {
|
|
14538
|
+
Oe.current = o, ke.current = u, Ae.current = f, je.current = p, Me.current = a, Ne.current = m;
|
|
14530
14539
|
}, [
|
|
14531
14540
|
o,
|
|
14532
14541
|
m,
|
|
@@ -14535,215 +14544,216 @@ var Sp = {}, Cp = ({ children: e, appearance: t = void 0, controller: n = void 0
|
|
|
14535
14544
|
u,
|
|
14536
14545
|
a
|
|
14537
14546
|
]), y(() => {
|
|
14538
|
-
if (!
|
|
14539
|
-
if (!
|
|
14540
|
-
let e =
|
|
14541
|
-
if (e && yp(e) !==
|
|
14542
|
-
localStorage.removeItem(
|
|
14547
|
+
if (!se || typeof localStorage > "u" || B === void 0) return;
|
|
14548
|
+
if (!ue) {
|
|
14549
|
+
let e = ve();
|
|
14550
|
+
if (e && yp(e) !== K) return;
|
|
14551
|
+
localStorage.removeItem(se);
|
|
14543
14552
|
return;
|
|
14544
14553
|
}
|
|
14545
14554
|
let e = window.setTimeout(() => {
|
|
14546
14555
|
try {
|
|
14547
|
-
localStorage.setItem(
|
|
14556
|
+
localStorage.setItem(se, JSON.stringify(Wt(B)));
|
|
14548
14557
|
} catch {
|
|
14549
|
-
|
|
14558
|
+
Se({
|
|
14550
14559
|
type: "warning",
|
|
14551
|
-
message:
|
|
14560
|
+
message: P.draftSaveError ?? "Could not save a local draft — the change is too large for browser storage (e.g. an unsent image upload). Save the form to keep it."
|
|
14552
14561
|
});
|
|
14553
14562
|
}
|
|
14554
14563
|
}, 150);
|
|
14555
14564
|
return () => window.clearTimeout(e);
|
|
14556
14565
|
}, [
|
|
14557
|
-
|
|
14558
|
-
|
|
14559
|
-
|
|
14560
|
-
|
|
14561
|
-
|
|
14562
|
-
|
|
14566
|
+
K,
|
|
14567
|
+
se,
|
|
14568
|
+
ue,
|
|
14569
|
+
Se,
|
|
14570
|
+
ve,
|
|
14571
|
+
B
|
|
14563
14572
|
]), y(() => {
|
|
14564
|
-
|
|
14565
|
-
storageKey:
|
|
14566
|
-
record:
|
|
14567
|
-
isDirty:
|
|
14573
|
+
oe.current = {
|
|
14574
|
+
storageKey: se,
|
|
14575
|
+
record: B,
|
|
14576
|
+
isDirty: ue
|
|
14568
14577
|
};
|
|
14569
14578
|
}, [
|
|
14570
|
-
|
|
14571
|
-
|
|
14572
|
-
|
|
14579
|
+
se,
|
|
14580
|
+
ue,
|
|
14581
|
+
B
|
|
14573
14582
|
]), y(() => () => {
|
|
14574
|
-
let { storageKey: e, record: t, isDirty: n } =
|
|
14583
|
+
let { storageKey: e, record: t, isDirty: n } = oe.current;
|
|
14575
14584
|
if (e && n && t && typeof localStorage < "u") try {
|
|
14576
14585
|
localStorage.setItem(e, JSON.stringify(Wt(t)));
|
|
14577
14586
|
} catch {}
|
|
14578
14587
|
}, []), y(() => {
|
|
14579
|
-
|
|
14580
|
-
save:
|
|
14581
|
-
delete:
|
|
14582
|
-
reset:
|
|
14583
|
-
restoreDraft:
|
|
14584
|
-
discardDraft:
|
|
14588
|
+
L.bindActions({
|
|
14589
|
+
save: Ue,
|
|
14590
|
+
delete: We,
|
|
14591
|
+
reset: Ie,
|
|
14592
|
+
restoreDraft: Fe,
|
|
14593
|
+
discardDraft: Pe
|
|
14585
14594
|
});
|
|
14586
14595
|
}, [
|
|
14587
|
-
|
|
14588
|
-
|
|
14596
|
+
L,
|
|
14597
|
+
Pe,
|
|
14598
|
+
We,
|
|
14589
14599
|
Ue,
|
|
14590
|
-
|
|
14591
|
-
Fe
|
|
14592
|
-
Pe
|
|
14600
|
+
Ie,
|
|
14601
|
+
Fe
|
|
14593
14602
|
]), y(() => {
|
|
14594
|
-
|
|
14595
|
-
record:
|
|
14596
|
-
isNewRecord:
|
|
14597
|
-
isDirty:
|
|
14598
|
-
canSave:
|
|
14599
|
-
canDelete:
|
|
14600
|
-
isSaving:
|
|
14601
|
-
isDeleting:
|
|
14602
|
-
saveDisabled: !
|
|
14603
|
-
deleteDisabled: !
|
|
14604
|
-
hasDraft:
|
|
14605
|
-
draftStatus:
|
|
14606
|
-
errors:
|
|
14607
|
-
hasErrors: Object.keys(
|
|
14603
|
+
L.setState({
|
|
14604
|
+
record: De.current,
|
|
14605
|
+
isNewRecord: ne,
|
|
14606
|
+
isDirty: ue,
|
|
14607
|
+
canSave: ce,
|
|
14608
|
+
canDelete: le,
|
|
14609
|
+
isSaving: U,
|
|
14610
|
+
isDeleting: ee,
|
|
14611
|
+
saveDisabled: !ce || g && !ue || U,
|
|
14612
|
+
deleteDisabled: !le || ee,
|
|
14613
|
+
hasDraft: ie !== null,
|
|
14614
|
+
draftStatus: ie,
|
|
14615
|
+
errors: Ce,
|
|
14616
|
+
hasErrors: Object.keys(Ce).length > 0
|
|
14608
14617
|
});
|
|
14609
14618
|
}, [
|
|
14610
|
-
ce,
|
|
14611
|
-
se,
|
|
14612
|
-
I,
|
|
14613
|
-
re,
|
|
14614
|
-
Se,
|
|
14615
|
-
W,
|
|
14616
14619
|
le,
|
|
14617
|
-
|
|
14618
|
-
|
|
14619
|
-
|
|
14620
|
-
|
|
14621
|
-
|
|
14622
|
-
|
|
14623
|
-
|
|
14624
|
-
|
|
14625
|
-
|
|
14626
|
-
|
|
14627
|
-
|
|
14620
|
+
ce,
|
|
14621
|
+
L,
|
|
14622
|
+
ie,
|
|
14623
|
+
Ce,
|
|
14624
|
+
ee,
|
|
14625
|
+
ue,
|
|
14626
|
+
ne,
|
|
14627
|
+
U,
|
|
14628
|
+
B,
|
|
14629
|
+
g
|
|
14630
|
+
]), y(() => () => tp(I), [L]);
|
|
14631
|
+
let Ge = _((e) => {
|
|
14632
|
+
e.defaultPrevented || !e.ctrlKey && !e.metaKey || e.key.toLowerCase() !== "s" || I.saveDisabled || (e.preventDefault(), I.save());
|
|
14633
|
+
}, [I]), Ke = C(() => ({
|
|
14634
|
+
registerField: Le,
|
|
14635
|
+
unregisterField: Re,
|
|
14636
|
+
clearFieldError: ze,
|
|
14637
|
+
errors: Ce
|
|
14628
14638
|
}), [
|
|
14629
|
-
Ie,
|
|
14630
14639
|
Le,
|
|
14631
14640
|
Re,
|
|
14632
|
-
|
|
14633
|
-
|
|
14634
|
-
|
|
14641
|
+
ze,
|
|
14642
|
+
Ce
|
|
14643
|
+
]), qe = C(() => ({
|
|
14644
|
+
store: z,
|
|
14635
14645
|
wrapperClassName: "mb-3"
|
|
14636
|
-
}), [
|
|
14646
|
+
}), [z]), Je = C(() => /* @__PURE__ */ d.createElement(np.Provider, { value: I }, /* @__PURE__ */ d.createElement(up.Provider, { value: qe }, /* @__PURE__ */ d.createElement(dp.Provider, { value: Ke }, typeof e == "function" ? e({ record: B }) : e))), [
|
|
14637
14647
|
e,
|
|
14638
|
-
|
|
14639
|
-
|
|
14640
|
-
|
|
14641
|
-
|
|
14642
|
-
]),
|
|
14643
|
-
variant:
|
|
14644
|
-
appearance:
|
|
14645
|
-
placement:
|
|
14646
|
-
anchorRef:
|
|
14647
|
-
timeout:
|
|
14648
|
-
onClose:
|
|
14649
|
-
},
|
|
14650
|
-
if (!
|
|
14651
|
-
let e =
|
|
14648
|
+
I,
|
|
14649
|
+
qe,
|
|
14650
|
+
B,
|
|
14651
|
+
Ke
|
|
14652
|
+
]), Ye = C(() => be ? /* @__PURE__ */ d.createElement(ss, {
|
|
14653
|
+
variant: be.type,
|
|
14654
|
+
appearance: b ? "default" : "text",
|
|
14655
|
+
placement: b ? "sticky" : "inline",
|
|
14656
|
+
anchorRef: b,
|
|
14657
|
+
timeout: be.type === "success" ? 3e3 : void 0,
|
|
14658
|
+
onClose: be.type === "success" ? () => xe(void 0) : void 0
|
|
14659
|
+
}, be.message) : null, [be, b]), Xe = C(() => {
|
|
14660
|
+
if (!ie) return null;
|
|
14661
|
+
let e = ie === "restore" ? fe : he, t = ie === "restore" ? pe : ge;
|
|
14652
14662
|
return /* @__PURE__ */ d.createElement(ss, {
|
|
14653
|
-
variant:
|
|
14654
|
-
timeout:
|
|
14655
|
-
onClose:
|
|
14656
|
-
}, /* @__PURE__ */ d.createElement("div", { className: "flex items-start justify-between gap-3" }, /* @__PURE__ */ d.createElement("div", { className: "min-w-0" }, /* @__PURE__ */ d.createElement("div", { className: "font-medium" }, e), /* @__PURE__ */ d.createElement("div", { className: "text-sm opacity-90" }, t)), /* @__PURE__ */ d.createElement("div", { className: "flex shrink-0 items-center gap-2" },
|
|
14657
|
-
label:
|
|
14663
|
+
variant: ie === "restore" ? "warning" : "info",
|
|
14664
|
+
timeout: ie === "restored" ? 6e3 : void 0,
|
|
14665
|
+
onClose: ie === "restored" ? () => ae(null) : void 0
|
|
14666
|
+
}, /* @__PURE__ */ d.createElement("div", { className: "flex items-start justify-between gap-3" }, /* @__PURE__ */ d.createElement("div", { className: "min-w-0" }, /* @__PURE__ */ d.createElement("div", { className: "font-medium" }, e), /* @__PURE__ */ d.createElement("div", { className: "text-sm opacity-90" }, t)), /* @__PURE__ */ d.createElement("div", { className: "flex shrink-0 items-center gap-2" }, ie === "restore" ? /* @__PURE__ */ d.createElement(d.Fragment, null, /* @__PURE__ */ d.createElement(ni, {
|
|
14667
|
+
label: q,
|
|
14658
14668
|
variant: "warning",
|
|
14659
|
-
onClick: () =>
|
|
14669
|
+
onClick: () => Fe()
|
|
14660
14670
|
}), /* @__PURE__ */ d.createElement(ni, {
|
|
14661
|
-
label:
|
|
14671
|
+
label: me,
|
|
14662
14672
|
variant: "outline-secondary",
|
|
14663
|
-
onClick: () =>
|
|
14673
|
+
onClick: () => Pe()
|
|
14664
14674
|
})) : /* @__PURE__ */ d.createElement(ni, {
|
|
14665
|
-
label:
|
|
14675
|
+
label: me,
|
|
14666
14676
|
variant: "outline-secondary",
|
|
14667
|
-
onClick: () =>
|
|
14677
|
+
onClick: () => Pe()
|
|
14668
14678
|
}))));
|
|
14669
14679
|
}, [
|
|
14670
|
-
|
|
14680
|
+
Pe,
|
|
14681
|
+
me,
|
|
14682
|
+
ie,
|
|
14671
14683
|
q,
|
|
14672
|
-
re,
|
|
14673
14684
|
pe,
|
|
14674
14685
|
fe,
|
|
14675
|
-
|
|
14686
|
+
ge,
|
|
14676
14687
|
he,
|
|
14677
|
-
|
|
14678
|
-
|
|
14679
|
-
]), Xe = C(() => {
|
|
14688
|
+
Fe
|
|
14689
|
+
]), Ze = C(() => {
|
|
14680
14690
|
switch (t) {
|
|
14681
|
-
case "empty": return /* @__PURE__ */ d.createElement(d.Fragment, null,
|
|
14691
|
+
case "empty": return /* @__PURE__ */ d.createElement(d.Fragment, null, Xe, Je, Ye);
|
|
14682
14692
|
default: return /* @__PURE__ */ d.createElement(Gi, {
|
|
14683
14693
|
header: r || /* @__PURE__ */ d.createElement(wa, {
|
|
14684
|
-
rootItem:
|
|
14694
|
+
rootItem: ne ? P.headerAdd : P.headerEdit,
|
|
14685
14695
|
trail: a || void 0
|
|
14686
14696
|
}),
|
|
14687
|
-
footer: (i || !
|
|
14688
|
-
className: X(
|
|
14689
|
-
label:
|
|
14690
|
-
title:
|
|
14691
|
-
disabled:
|
|
14692
|
-
loading:
|
|
14693
|
-
onClick: (e) =>
|
|
14694
|
-
}), (f || !
|
|
14695
|
-
className:
|
|
14696
|
-
label:
|
|
14697
|
-
disabled:
|
|
14698
|
-
loading:
|
|
14699
|
-
onClick: (e) =>
|
|
14700
|
-
}),
|
|
14701
|
-
className:
|
|
14702
|
-
label:
|
|
14697
|
+
footer: (i || !ne || u || f || x || !!a) && /* @__PURE__ */ d.createElement(d.Fragment, null, i, Ye, (u || !!a || !ne) && /* @__PURE__ */ d.createElement(ti, {
|
|
14698
|
+
className: X(N.Form.buttonSaveClass, I.saveDisabled && "cursor-not-allowed opacity-50"),
|
|
14699
|
+
label: P.buttonSave,
|
|
14700
|
+
title: I.saveDisabled && !ue ? de : void 0,
|
|
14701
|
+
disabled: I.saveDisabled,
|
|
14702
|
+
loading: I.isSaving,
|
|
14703
|
+
onClick: (e) => I.save(e)
|
|
14704
|
+
}), (f || !ne) && /* @__PURE__ */ d.createElement(ti, {
|
|
14705
|
+
className: N.Form.buttonDeleteClass,
|
|
14706
|
+
label: P.buttonDelete,
|
|
14707
|
+
disabled: I.deleteDisabled,
|
|
14708
|
+
loading: I.isDeleting,
|
|
14709
|
+
onClick: (e) => I.delete(e)
|
|
14710
|
+
}), x && /* @__PURE__ */ d.createElement(ri, {
|
|
14711
|
+
className: N.Form.buttonBackClass,
|
|
14712
|
+
label: P.buttonBack
|
|
14703
14713
|
})),
|
|
14704
|
-
headerClassName:
|
|
14705
|
-
bodyClassName:
|
|
14706
|
-
footerClassName:
|
|
14707
|
-
}, /* @__PURE__ */ d.createElement(d.Fragment, null,
|
|
14714
|
+
headerClassName: D || N.Form.Card.headerClassName,
|
|
14715
|
+
bodyClassName: O || N.Form.Card.bodyClassName,
|
|
14716
|
+
footerClassName: k || N.Form.Card.footerClassName
|
|
14717
|
+
}, /* @__PURE__ */ d.createElement(d.Fragment, null, Xe, Je));
|
|
14708
14718
|
}
|
|
14709
14719
|
}, [
|
|
14710
14720
|
t,
|
|
14711
|
-
D,
|
|
14712
|
-
qe,
|
|
14713
|
-
N.buttonBack,
|
|
14714
|
-
N.buttonDelete,
|
|
14715
|
-
N.buttonSave,
|
|
14716
|
-
N.headerAdd,
|
|
14717
|
-
N.headerEdit,
|
|
14718
|
-
Ye,
|
|
14719
|
-
i,
|
|
14720
14721
|
O,
|
|
14721
|
-
|
|
14722
|
+
Je,
|
|
14723
|
+
P.buttonBack,
|
|
14724
|
+
P.buttonDelete,
|
|
14725
|
+
P.buttonSave,
|
|
14726
|
+
P.headerAdd,
|
|
14727
|
+
P.headerEdit,
|
|
14728
|
+
Xe,
|
|
14729
|
+
i,
|
|
14730
|
+
k,
|
|
14731
|
+
I,
|
|
14722
14732
|
r,
|
|
14723
|
-
|
|
14724
|
-
le,
|
|
14725
|
-
te,
|
|
14733
|
+
D,
|
|
14726
14734
|
ue,
|
|
14727
|
-
|
|
14735
|
+
ne,
|
|
14736
|
+
de,
|
|
14737
|
+
Ye,
|
|
14728
14738
|
f,
|
|
14729
14739
|
u,
|
|
14730
14740
|
a,
|
|
14731
|
-
|
|
14732
|
-
|
|
14733
|
-
|
|
14734
|
-
|
|
14735
|
-
|
|
14736
|
-
|
|
14737
|
-
|
|
14741
|
+
x,
|
|
14742
|
+
N.Form.buttonDeleteClass,
|
|
14743
|
+
N.Form.buttonSaveClass,
|
|
14744
|
+
N.Form.buttonBackClass,
|
|
14745
|
+
N.Form.Card.bodyClassName,
|
|
14746
|
+
N.Form.Card.footerClassName,
|
|
14747
|
+
N.Form.Card.headerClassName
|
|
14738
14748
|
]);
|
|
14739
|
-
return /* @__PURE__ */ d.createElement(Z, { className:
|
|
14740
|
-
ref:
|
|
14741
|
-
className:
|
|
14749
|
+
return /* @__PURE__ */ d.createElement(Z, { className: S || N.Form.wrapperClassName }, /* @__PURE__ */ d.createElement("form", {
|
|
14750
|
+
ref: Ee,
|
|
14751
|
+
className: A,
|
|
14742
14752
|
noValidate: !0,
|
|
14743
14753
|
onSubmit: (e) => e.preventDefault(),
|
|
14744
|
-
onKeyDownCapture:
|
|
14745
|
-
onKeyDown:
|
|
14746
|
-
},
|
|
14754
|
+
onKeyDownCapture: Ge,
|
|
14755
|
+
onKeyDown: Ge
|
|
14756
|
+
}, Ze));
|
|
14747
14757
|
}, wp = "flex items-center justify-between gap-3 border-b border-border/50 px-3 py-2", Tp = "text-xs font-medium uppercase tracking-[0.14em] text-muted-foreground", Ep = "px-3 py-3", Dp = "h-7 w-7 rounded-md bg-transparent p-0 text-muted-foreground hover:bg-destructive/10 hover:text-destructive", Op = ({ name: e, children: t, onChange: n, onAdd: r, onRemove: i, className: a, layout: o = "horizontal", minItems: s = void 0, maxItems: c = void 0, label: l = void 0, labelPosition: u = "top", hideRemoveButton: f = !1, readOnly: p = !1 }) => {
|
|
14748
14758
|
let { value: m, handleChange: h } = pp({
|
|
14749
14759
|
name: e,
|