ding-react-admin 1.0.1 → 1.0.4
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 +107 -2
- package/dist/index.js +712 -723
- package/dist/src/crud/InlineFormSet.d.ts +13 -11
- package/dist/src/crud/InlineFormSet.d.ts.map +1 -1
- package/dist/src/crud/ResourceForm.d.ts +10 -2
- package/dist/src/crud/ResourceForm.d.ts.map +1 -1
- package/dist/src/crud/ResourceFormModal.d.ts.map +1 -1
- package/dist/src/crud/ResourceList.d.ts.map +1 -1
- package/dist/src/crud/context/SubmitFieldsContext.d.ts +18 -0
- package/dist/src/crud/context/SubmitFieldsContext.d.ts.map +1 -0
- package/dist/src/crud/fields/BooleanField.d.ts +3 -1
- package/dist/src/crud/fields/BooleanField.d.ts.map +1 -1
- package/dist/src/crud/fields/DateField.d.ts +3 -1
- package/dist/src/crud/fields/DateField.d.ts.map +1 -1
- package/dist/src/crud/fields/FieldWrapper.d.ts +7 -14
- package/dist/src/crud/fields/FieldWrapper.d.ts.map +1 -1
- package/dist/src/crud/fields/NumberField.d.ts +5 -3
- package/dist/src/crud/fields/NumberField.d.ts.map +1 -1
- package/dist/src/crud/fields/PasswordField.d.ts +5 -3
- package/dist/src/crud/fields/PasswordField.d.ts.map +1 -1
- package/dist/src/crud/fields/ReferenceField.d.ts +6 -5
- package/dist/src/crud/fields/ReferenceField.d.ts.map +1 -1
- package/dist/src/crud/fields/ReferenceManyField.d.ts +3 -1
- package/dist/src/crud/fields/ReferenceManyField.d.ts.map +1 -1
- package/dist/src/crud/fields/SelectField.d.ts +3 -1
- package/dist/src/crud/fields/SelectField.d.ts.map +1 -1
- package/dist/src/crud/fields/TextField.d.ts +5 -3
- package/dist/src/crud/fields/TextField.d.ts.map +1 -1
- package/dist/src/crud/index.d.ts +8 -4
- package/dist/src/crud/index.d.ts.map +1 -1
- package/dist/src/crud/types.d.ts +21 -20
- package/dist/src/crud/types.d.ts.map +1 -1
- package/dist/src/crud/utils/inlineFieldName.d.ts +3 -0
- package/dist/src/crud/utils/inlineFieldName.d.ts.map +1 -0
- package/dist/src/crud/utils/useAbortableEffect.d.ts +7 -0
- package/dist/src/crud/utils/useAbortableEffect.d.ts.map +1 -0
- package/dist/src/crud/utils/useResourceFormData.d.ts +47 -0
- package/dist/src/crud/utils/useResourceFormData.d.ts.map +1 -0
- package/dist/src/data/abortError.d.ts +3 -0
- package/dist/src/data/abortError.d.ts.map +1 -0
- package/dist/src/data/abortError.test.d.ts +2 -0
- package/dist/src/data/abortError.test.d.ts.map +1 -0
- package/dist/src/data/createRestResourceHandlers.d.ts +2 -2
- package/dist/src/data/createRestResourceHandlers.d.ts.map +1 -1
- package/dist/src/data/dataProviderTypes.d.ts +7 -1
- package/dist/src/data/dataProviderTypes.d.ts.map +1 -1
- package/dist/src/data/resourceHandlers.d.ts +2 -2
- package/dist/src/data/resourceHandlers.d.ts.map +1 -1
- package/dist/src/index.d.ts +4 -3
- package/dist/src/index.d.ts.map +1 -1
- package/docs/assets/form-with-inline.png +0 -0
- package/package.json +59 -59
- package/src/crud/InlineFormSet.tsx +77 -89
- package/src/crud/ResourceForm.tsx +87 -202
- package/src/crud/ResourceFormModal.tsx +37 -25
- package/src/crud/ResourceList.tsx +35 -26
- package/src/crud/context/SubmitFieldsContext.tsx +62 -0
- package/src/crud/fields/BooleanField.tsx +22 -16
- package/src/crud/fields/DateField.tsx +32 -26
- package/src/crud/fields/FieldWrapper.tsx +32 -54
- package/src/crud/fields/NumberField.tsx +36 -34
- package/src/crud/fields/PasswordField.tsx +41 -40
- package/src/crud/fields/ReferenceField.tsx +35 -130
- package/src/crud/fields/ReferenceManyField.tsx +31 -25
- package/src/crud/fields/SelectField.tsx +6 -0
- package/src/crud/fields/TextField.tsx +32 -30
- package/src/crud/index.ts +19 -2
- package/src/crud/types.ts +132 -130
- package/src/crud/utils/inlineFieldName.ts +8 -0
- package/src/crud/utils/useAbortableEffect.ts +17 -0
- package/src/crud/utils/useResourceFormData.ts +231 -0
- package/src/data/abortError.test.ts +19 -0
- package/src/data/abortError.ts +10 -0
- package/src/data/createMemoryResourceHandlers.ts +1 -1
- package/src/data/createRestResourceHandlers.ts +4 -4
- package/src/data/dataProviderTypes.ts +8 -0
- package/src/data/resourceHandlers.ts +4 -3
- package/src/index.ts +14 -1
- package/dist/src/crud/context/FormFieldsContext.d.ts +0 -14
- package/dist/src/crud/context/FormFieldsContext.d.ts.map +0 -1
- package/dist/src/crud/context/InlineFormContext.d.ts +0 -16
- package/dist/src/crud/context/InlineFormContext.d.ts.map +0 -1
- package/dist/src/crud/fields/useInlineOrFormField.d.ts +0 -10
- package/dist/src/crud/fields/useInlineOrFormField.d.ts.map +0 -1
- package/src/crud/context/FormFieldsContext.tsx +0 -76
- package/src/crud/context/InlineFormContext.tsx +0 -71
- package/src/crud/fields/useInlineOrFormField.tsx +0 -91
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Children as e, createContext as t, createElement as n, isValidElement as r, useCallback as i, useContext as a, useEffect as o, useMemo as s, useRef as c, useState as l } from "react";
|
|
2
2
|
import { Link as u, Navigate as d, Outlet as f, RouterProvider as p, createBrowserRouter as m, useLocation as h, useNavigate as g, useParams as _, useSearchParams as v } from "react-router-dom";
|
|
3
|
-
import { App as y, Avatar as b, Button as x, Card as S, ConfigProvider as C, DatePicker as w, Drawer as
|
|
3
|
+
import { App as y, Avatar as b, Button as x, Card as S, ConfigProvider as C, DatePicker as w, Drawer as ee, Dropdown as T, Flex as E, Form as D, Grid as O, Input as k, InputNumber as A, Layout as j, Menu as M, Modal as te, Popover as N, Segmented as P, Select as F, Space as I, Spin as L, Steps as ne, Switch as re, Table as ie, Tabs as ae, Typography as R, theme as z } from "antd";
|
|
4
4
|
import { Fragment as B, jsx as V, jsxs as H } from "react/jsx-runtime";
|
|
5
5
|
import { ArrowLeftOutlined as U, CaretDownOutlined as oe, CaretUpOutlined as se, ColumnHeightOutlined as W, DesktopOutlined as ce, LayoutOutlined as le, LogoutOutlined as ue, MenuOutlined as de, MoonOutlined as fe, SettingOutlined as pe, SunOutlined as me, UserOutlined as he } from "@ant-design/icons";
|
|
6
6
|
import { Controller as ge, FormProvider as _e, useFieldArray as ve, useForm as ye, useFormContext as G, useFormState as K, useWatch as be } from "react-hook-form";
|
|
@@ -84,7 +84,7 @@ var Ae = [{
|
|
|
84
84
|
}];
|
|
85
85
|
function je() {
|
|
86
86
|
let { density: e, setDensity: t } = ke();
|
|
87
|
-
return /* @__PURE__ */ V(
|
|
87
|
+
return /* @__PURE__ */ V(P, {
|
|
88
88
|
size: "small",
|
|
89
89
|
value: e,
|
|
90
90
|
options: Ae,
|
|
@@ -112,7 +112,7 @@ var Me = [
|
|
|
112
112
|
];
|
|
113
113
|
function Ne() {
|
|
114
114
|
let { mode: e, setMode: t } = ke();
|
|
115
|
-
return /* @__PURE__ */ V(
|
|
115
|
+
return /* @__PURE__ */ V(P, {
|
|
116
116
|
size: "small",
|
|
117
117
|
value: e,
|
|
118
118
|
options: Me,
|
|
@@ -123,10 +123,10 @@ function Ne() {
|
|
|
123
123
|
//#region src/components/ThemeToolbar.tsx
|
|
124
124
|
function Pe() {
|
|
125
125
|
let { token: e } = z.useToken();
|
|
126
|
-
return /* @__PURE__ */ V(
|
|
126
|
+
return /* @__PURE__ */ V(N, {
|
|
127
127
|
placement: O.useBreakpoint().lg ? "bottomRight" : "bottom",
|
|
128
128
|
trigger: "click",
|
|
129
|
-
content: /* @__PURE__ */ H(
|
|
129
|
+
content: /* @__PURE__ */ H(I, {
|
|
130
130
|
orientation: "vertical",
|
|
131
131
|
size: "middle",
|
|
132
132
|
style: {
|
|
@@ -272,7 +272,7 @@ function Ze(e) {
|
|
|
272
272
|
});
|
|
273
273
|
}
|
|
274
274
|
function Qe({ menuItems: e, selectedKeys: t, inlineCollapsed: n, openKeys: r, onOpenChange: i, onNavigate: a }) {
|
|
275
|
-
return /* @__PURE__ */ V(
|
|
275
|
+
return /* @__PURE__ */ V(M, {
|
|
276
276
|
mode: "inline",
|
|
277
277
|
theme: "dark",
|
|
278
278
|
inlineCollapsed: n,
|
|
@@ -290,9 +290,9 @@ function Qe({ menuItems: e, selectedKeys: t, inlineCollapsed: n, openKeys: r, on
|
|
|
290
290
|
});
|
|
291
291
|
}
|
|
292
292
|
function $e({ navItems: e, brand: t = "Admin", collapsedBrand: n = "A", mobileDrawerTitle: r, headerExtras: a, userMenuItems: c, onUserMenuClick: u, loginPath: d = "/login", siderCollapsedStorageKey: p = Ke }) {
|
|
293
|
-
let m = g(), _ = h(), { resolved: v } = ke(), y = v === "dark", { logout: S } = Le(), C = q(), [w, E] = l(() => qe(p)), [D, O] = l(!1), k = Je(), { token: A } = z.useToken(),
|
|
293
|
+
let m = g(), _ = h(), { resolved: v } = ke(), y = v === "dark", { logout: S } = Le(), C = q(), [w, E] = l(() => qe(p)), [D, O] = l(!1), k = Je(), { token: A } = z.useToken(), M = r ?? t, te = () => {
|
|
294
294
|
S(), m(d, { replace: !0 });
|
|
295
|
-
},
|
|
295
|
+
}, N = i((e) => {
|
|
296
296
|
E(e);
|
|
297
297
|
try {
|
|
298
298
|
localStorage.setItem(p, e ? "1" : "0");
|
|
@@ -303,10 +303,10 @@ function $e({ navItems: e, brand: t = "Admin", collapsedBrand: n = "A", mobileDr
|
|
|
303
303
|
}, [k]), o(() => {
|
|
304
304
|
O(!1);
|
|
305
305
|
}, [_.pathname]);
|
|
306
|
-
let
|
|
306
|
+
let P = s(() => We(e, C), [e, C]), F = s(() => Ye(P), [P]), I = s(() => Ze(P), [P]), L = s(() => Xe(P, _.pathname), [P, _.pathname]), [ne, re] = l(() => Xe(P, _.pathname));
|
|
307
307
|
o(() => {
|
|
308
|
-
re((e) => [...new Set([...e, ...
|
|
309
|
-
}, [
|
|
308
|
+
re((e) => [...new Set([...e, ...L])]);
|
|
309
|
+
}, [L]);
|
|
310
310
|
let ie = i((e) => {
|
|
311
311
|
re(e);
|
|
312
312
|
}, []), ae = s(() => [{
|
|
@@ -319,9 +319,9 @@ function $e({ navItems: e, brand: t = "Admin", collapsedBrand: n = "A", mobileDr
|
|
|
319
319
|
u(e);
|
|
320
320
|
return;
|
|
321
321
|
}
|
|
322
|
-
e.key === "logout" &&
|
|
322
|
+
e.key === "logout" && te();
|
|
323
323
|
}, oe = y ? A.colorBgContainer : Ge, se = [_.pathname], W = (e) => {
|
|
324
|
-
|
|
324
|
+
F.has(e) && (m(e), k && O(!1));
|
|
325
325
|
};
|
|
326
326
|
return /* @__PURE__ */ H(j, {
|
|
327
327
|
style: {
|
|
@@ -333,7 +333,7 @@ function $e({ navItems: e, brand: t = "Admin", collapsedBrand: n = "A", mobileDr
|
|
|
333
333
|
!k && /* @__PURE__ */ H(j.Sider, {
|
|
334
334
|
collapsible: !0,
|
|
335
335
|
collapsed: w,
|
|
336
|
-
onCollapse:
|
|
336
|
+
onCollapse: N,
|
|
337
337
|
collapsedWidth: 64,
|
|
338
338
|
style: {
|
|
339
339
|
background: oe,
|
|
@@ -353,19 +353,19 @@ function $e({ navItems: e, brand: t = "Admin", collapsedBrand: n = "A", mobileDr
|
|
|
353
353
|
children: w ? n : t
|
|
354
354
|
})
|
|
355
355
|
}), /* @__PURE__ */ V(Qe, {
|
|
356
|
-
menuItems:
|
|
356
|
+
menuItems: I,
|
|
357
357
|
selectedKeys: se,
|
|
358
358
|
inlineCollapsed: w,
|
|
359
|
-
openKeys:
|
|
359
|
+
openKeys: ne,
|
|
360
360
|
onOpenChange: ie,
|
|
361
361
|
onNavigate: W
|
|
362
362
|
})]
|
|
363
363
|
}),
|
|
364
|
-
k && /* @__PURE__ */ V(
|
|
364
|
+
k && /* @__PURE__ */ V(ee, {
|
|
365
365
|
title: /* @__PURE__ */ V(R.Text, {
|
|
366
366
|
strong: !0,
|
|
367
367
|
style: { color: A.colorTextLightSolid },
|
|
368
|
-
children:
|
|
368
|
+
children: M
|
|
369
369
|
}),
|
|
370
370
|
placement: "left",
|
|
371
371
|
size: 280,
|
|
@@ -383,10 +383,10 @@ function $e({ navItems: e, brand: t = "Admin", collapsedBrand: n = "A", mobileDr
|
|
|
383
383
|
},
|
|
384
384
|
destroyOnHidden: !0,
|
|
385
385
|
children: /* @__PURE__ */ V(Qe, {
|
|
386
|
-
menuItems:
|
|
386
|
+
menuItems: I,
|
|
387
387
|
selectedKeys: se,
|
|
388
388
|
inlineCollapsed: !1,
|
|
389
|
-
openKeys:
|
|
389
|
+
openKeys: ne,
|
|
390
390
|
onOpenChange: ie,
|
|
391
391
|
onNavigate: W
|
|
392
392
|
})
|
|
@@ -413,7 +413,7 @@ function $e({ navItems: e, brand: t = "Admin", collapsedBrand: n = "A", mobileDr
|
|
|
413
413
|
} }),
|
|
414
414
|
a,
|
|
415
415
|
/* @__PURE__ */ V(Pe, {}),
|
|
416
|
-
/* @__PURE__ */ V(
|
|
416
|
+
/* @__PURE__ */ V(T, {
|
|
417
417
|
menu: {
|
|
418
418
|
items: B,
|
|
419
419
|
onClick: U
|
|
@@ -607,9 +607,9 @@ function _t(e, t) {
|
|
|
607
607
|
let { handlers: i, permissions: o } = a(e);
|
|
608
608
|
return r?.(e, "list"), gt(n, o, "list"), i.getList(t);
|
|
609
609
|
},
|
|
610
|
-
async getOne(e, t) {
|
|
611
|
-
let { handlers:
|
|
612
|
-
return r?.(e, "read"), gt(n,
|
|
610
|
+
async getOne(e, t, i) {
|
|
611
|
+
let { handlers: o, permissions: s } = a(e);
|
|
612
|
+
return r?.(e, "read"), gt(n, s, "read"), o.getOne(t, i);
|
|
613
613
|
},
|
|
614
614
|
async create(e, t) {
|
|
615
615
|
let { handlers: i, permissions: o } = a(e);
|
|
@@ -627,6 +627,13 @@ function _t(e, t) {
|
|
|
627
627
|
};
|
|
628
628
|
}
|
|
629
629
|
//#endregion
|
|
630
|
+
//#region src/data/abortError.ts
|
|
631
|
+
function vt(e) {
|
|
632
|
+
if (typeof e != "object" || !e) return !1;
|
|
633
|
+
let t = e;
|
|
634
|
+
return t.name === "AbortError" || t.name === "CanceledError" || t.code === "ERR_CANCELED";
|
|
635
|
+
}
|
|
636
|
+
//#endregion
|
|
630
637
|
//#region src/data/parseFormErrorHelpers.ts
|
|
631
638
|
function Y(e) {
|
|
632
639
|
if (typeof e == "string") return [e];
|
|
@@ -636,10 +643,10 @@ function Y(e) {
|
|
|
636
643
|
}
|
|
637
644
|
return [];
|
|
638
645
|
}
|
|
639
|
-
function
|
|
646
|
+
function yt(e) {
|
|
640
647
|
return e.length === 1 ? e[0] : e;
|
|
641
648
|
}
|
|
642
|
-
function
|
|
649
|
+
function bt(e) {
|
|
643
650
|
if (!e || typeof e != "object") return null;
|
|
644
651
|
let t = e;
|
|
645
652
|
if (t.body && typeof t.body == "object" && !Array.isArray(t.body)) return t.body;
|
|
@@ -650,58 +657,58 @@ function yt(e) {
|
|
|
650
657
|
}
|
|
651
658
|
return null;
|
|
652
659
|
}
|
|
653
|
-
function
|
|
660
|
+
function xt(e, t) {
|
|
654
661
|
if (t.inlineArrayName == null || t.rowIndex == null) return e;
|
|
655
662
|
let n = `${t.inlineArrayName}.${t.rowIndex}.`, r = {};
|
|
656
663
|
for (let [t, i] of Object.entries(e)) r[n + t] = i;
|
|
657
664
|
return r;
|
|
658
665
|
}
|
|
659
|
-
function
|
|
660
|
-
let r =
|
|
666
|
+
function St(e, t, n) {
|
|
667
|
+
let r = xt(e, n);
|
|
661
668
|
return {
|
|
662
669
|
fields: Object.keys(r).length ? r : void 0,
|
|
663
670
|
global: t.length ? t : void 0
|
|
664
671
|
};
|
|
665
672
|
}
|
|
666
|
-
var
|
|
667
|
-
function
|
|
668
|
-
let n =
|
|
673
|
+
var Ct = new Set(["non_field_errors", "detail"]);
|
|
674
|
+
function wt(e, t) {
|
|
675
|
+
let n = bt(e);
|
|
669
676
|
if (!n) return null;
|
|
670
677
|
let r = {}, i = [];
|
|
671
678
|
for (let [e, t] of Object.entries(n)) {
|
|
672
|
-
if (
|
|
679
|
+
if (Ct.has(e)) {
|
|
673
680
|
i.push(...Y(t));
|
|
674
681
|
continue;
|
|
675
682
|
}
|
|
676
683
|
let n = Y(t);
|
|
677
|
-
n.length && (r[e] =
|
|
684
|
+
n.length && (r[e] = yt(n));
|
|
678
685
|
}
|
|
679
|
-
return !Object.keys(r).length && !i.length ? null :
|
|
686
|
+
return !Object.keys(r).length && !i.length ? null : St(r, i, t);
|
|
680
687
|
}
|
|
681
|
-
function
|
|
682
|
-
let r =
|
|
688
|
+
function Tt(e, t, n) {
|
|
689
|
+
let r = bt(e);
|
|
683
690
|
if (!r) return null;
|
|
684
691
|
let i = n?.camelCase ?? !0, a = n?.fieldMap, o = {}, s = [];
|
|
685
692
|
n?.includeSummary && (s.push(...Y(r.title)), s.push(...Y(r.message)));
|
|
686
693
|
let c = r.errors;
|
|
687
694
|
if (c && typeof c == "object" && !Array.isArray(c)) for (let [e, t] of Object.entries(c)) {
|
|
688
|
-
let n = a?.[e] ?? (i ?
|
|
689
|
-
r.length && (o[n] =
|
|
695
|
+
let n = a?.[e] ?? (i ? Ot(e) : e), r = Y(t);
|
|
696
|
+
r.length && (o[n] = yt(r));
|
|
690
697
|
}
|
|
691
|
-
return !Object.keys(o).length && !s.length ? null :
|
|
698
|
+
return !Object.keys(o).length && !s.length ? null : St(o, s, t);
|
|
692
699
|
}
|
|
693
|
-
function
|
|
694
|
-
let r =
|
|
700
|
+
function Et(e, t, n) {
|
|
701
|
+
let r = bt(e);
|
|
695
702
|
if (!r) return null;
|
|
696
703
|
let i = {}, a = [], o = n?.fieldMap, s = r.errors;
|
|
697
704
|
if (Array.isArray(s)) for (let e of s) {
|
|
698
705
|
if (!e || typeof e != "object") continue;
|
|
699
706
|
let t = e, n = typeof t.path == "string" && t.path || typeof t.param == "string" && t.param || typeof t.field == "string" && t.field, r = Y(t.msg)[0] ?? Y(t.message)[0];
|
|
700
|
-
r && (n ?
|
|
707
|
+
r && (n ? Dt(i, o?.[n] ?? n, r) : a.push(r));
|
|
701
708
|
}
|
|
702
709
|
else if (s && typeof s == "object") for (let [e, t] of Object.entries(s)) {
|
|
703
710
|
let n = o?.[e] ?? e, r = Y(t);
|
|
704
|
-
r.length && (i[n] =
|
|
711
|
+
r.length && (i[n] = yt(r));
|
|
705
712
|
}
|
|
706
713
|
let c = r.details;
|
|
707
714
|
if (Array.isArray(c)) for (let e of c) {
|
|
@@ -712,9 +719,9 @@ function Tt(e, t, n) {
|
|
|
712
719
|
i[e] = r;
|
|
713
720
|
} else a.push(r);
|
|
714
721
|
}
|
|
715
|
-
return a.push(...Y(r.error)), !Object.keys(i).length && !a.length ? null :
|
|
722
|
+
return a.push(...Y(r.error)), !Object.keys(i).length && !a.length ? null : St(i, a, t);
|
|
716
723
|
}
|
|
717
|
-
function
|
|
724
|
+
function Dt(e, t, n) {
|
|
718
725
|
let r = e[t];
|
|
719
726
|
if (!r) {
|
|
720
727
|
e[t] = n;
|
|
@@ -722,20 +729,20 @@ function Et(e, t, n) {
|
|
|
722
729
|
}
|
|
723
730
|
e[t] = Array.isArray(r) ? [...r, n] : [r, n];
|
|
724
731
|
}
|
|
725
|
-
function
|
|
732
|
+
function Ot(e) {
|
|
726
733
|
return e && e.charAt(0).toLowerCase() + e.slice(1);
|
|
727
734
|
}
|
|
728
735
|
//#endregion
|
|
729
736
|
//#region src/data/inMemoryList.ts
|
|
730
|
-
function
|
|
737
|
+
function kt(e, t) {
|
|
731
738
|
return e === t || String(e) === String(t);
|
|
732
739
|
}
|
|
733
|
-
function
|
|
734
|
-
let n = e.find((e) =>
|
|
740
|
+
function At(e, t) {
|
|
741
|
+
let n = e.find((e) => kt(e.id, t));
|
|
735
742
|
if (!n) throw Error("Not found");
|
|
736
743
|
return n;
|
|
737
744
|
}
|
|
738
|
-
function
|
|
745
|
+
function jt(e, t) {
|
|
739
746
|
if (t.length === 0) return e;
|
|
740
747
|
let n = (e) => e === "DESC" ? -1 : 1;
|
|
741
748
|
return [...e].sort((e, r) => {
|
|
@@ -751,33 +758,33 @@ function At(e, t) {
|
|
|
751
758
|
return 0;
|
|
752
759
|
});
|
|
753
760
|
}
|
|
754
|
-
function
|
|
761
|
+
function Mt(e, t) {
|
|
755
762
|
return t == null || t === "" ? !0 : Array.isArray(t) ? t.length === 0 ? !0 : Array.isArray(e) ? t.some((t) => e.includes(t)) : t.includes(e) : Array.isArray(e) ? e.includes(t) : typeof t == "string" && typeof e == "string" ? e.toLowerCase().includes(t.toLowerCase()) : e === t;
|
|
756
763
|
}
|
|
757
|
-
function
|
|
758
|
-
return t ? e.filter((e) => Object.entries(t).every(([t, n]) =>
|
|
764
|
+
function Nt(e, t) {
|
|
765
|
+
return t ? e.filter((e) => Object.entries(t).every(([t, n]) => Mt(e[t], n))) : e;
|
|
759
766
|
}
|
|
760
|
-
function
|
|
767
|
+
function Pt(e, t, n) {
|
|
761
768
|
let r = (t - 1) * n;
|
|
762
769
|
return {
|
|
763
770
|
data: e.slice(r, r + n),
|
|
764
771
|
total: e.length
|
|
765
772
|
};
|
|
766
773
|
}
|
|
767
|
-
function
|
|
768
|
-
let { pagination: n, sort: r, filter: i } = t, a =
|
|
774
|
+
function Ft(e, t) {
|
|
775
|
+
let { pagination: n, sort: r, filter: i } = t, a = Nt(e, i);
|
|
769
776
|
if (r) {
|
|
770
777
|
let e = Array.isArray(r) ? r : [r];
|
|
771
|
-
e.length > 0 && e[0]?.field && (a =
|
|
778
|
+
e.length > 0 && e[0]?.field && (a = jt(a, e));
|
|
772
779
|
}
|
|
773
|
-
return n ?
|
|
780
|
+
return n ? Pt(a, n.page, n.perPage) : {
|
|
774
781
|
data: a,
|
|
775
782
|
total: a.length
|
|
776
783
|
};
|
|
777
784
|
}
|
|
778
785
|
//#endregion
|
|
779
786
|
//#region src/data/createMemoryResourceHandlers.ts
|
|
780
|
-
function
|
|
787
|
+
function It(e) {
|
|
781
788
|
let t = (e) => e, n = e.mapCreate ?? ((e, t) => ({
|
|
782
789
|
...e,
|
|
783
790
|
id: t
|
|
@@ -788,21 +795,21 @@ function Ft(e) {
|
|
|
788
795
|
}));
|
|
789
796
|
return {
|
|
790
797
|
async getList(n) {
|
|
791
|
-
return
|
|
798
|
+
return Ft(t(e.scopeList ? e.scopeList(e.getRows(), n) : e.getRows()), n);
|
|
792
799
|
},
|
|
793
|
-
async getOne(t) {
|
|
794
|
-
return { data:
|
|
800
|
+
async getOne(t, n) {
|
|
801
|
+
return { data: At(e.getRows(), t) };
|
|
795
802
|
},
|
|
796
803
|
async create(t) {
|
|
797
804
|
let r = n(t, e.nextId());
|
|
798
805
|
return e.getRows().push(r), { data: r };
|
|
799
806
|
},
|
|
800
807
|
async update({ id: t, data: n }) {
|
|
801
|
-
let i =
|
|
808
|
+
let i = At(e.getRows(), t), a = r(i, n);
|
|
802
809
|
return Object.assign(i, a), { data: i };
|
|
803
810
|
},
|
|
804
811
|
async delete(t) {
|
|
805
|
-
let n = e.getRows(), r = n.findIndex((e) =>
|
|
812
|
+
let n = e.getRows(), r = n.findIndex((e) => kt(e.id, t));
|
|
806
813
|
if (r < 0) return { data: null };
|
|
807
814
|
let [i] = n.splice(r, 1);
|
|
808
815
|
return e.afterDelete?.(i), { data: i };
|
|
@@ -811,13 +818,13 @@ function Ft(e) {
|
|
|
811
818
|
}
|
|
812
819
|
//#endregion
|
|
813
820
|
//#region src/data/createRestResourceHandlers.ts
|
|
814
|
-
function
|
|
821
|
+
function Lt(e) {
|
|
815
822
|
return {
|
|
816
823
|
async getList(t) {
|
|
817
824
|
return e.list(t);
|
|
818
825
|
},
|
|
819
|
-
async getOne(t) {
|
|
820
|
-
return { data: await e.retrieve(t) };
|
|
826
|
+
async getOne(t, n) {
|
|
827
|
+
return { data: await e.retrieve(t, n) };
|
|
821
828
|
},
|
|
822
829
|
async create(t) {
|
|
823
830
|
let n = e.transformCreate ? e.transformCreate(t) : t;
|
|
@@ -834,24 +841,24 @@ function It(e) {
|
|
|
834
841
|
}
|
|
835
842
|
//#endregion
|
|
836
843
|
//#region src/data/sortHelpers.ts
|
|
837
|
-
function
|
|
844
|
+
function Rt(e) {
|
|
838
845
|
return e ? Array.isArray(e) ? e : [e] : [];
|
|
839
846
|
}
|
|
840
|
-
function
|
|
841
|
-
let t =
|
|
847
|
+
function zt(e) {
|
|
848
|
+
let t = Rt(e);
|
|
842
849
|
if (t.length !== 0) return t.map((e) => e.order === "DESC" ? `-${e.field}` : e.field).join(",");
|
|
843
850
|
}
|
|
844
|
-
function
|
|
845
|
-
let t =
|
|
851
|
+
function Bt(e) {
|
|
852
|
+
let t = Rt(e);
|
|
846
853
|
if (t.length !== 0) return t.map((e) => `${e.field} ${e.order === "DESC" ? "desc" : "asc"}`).join(",");
|
|
847
854
|
}
|
|
848
|
-
function
|
|
849
|
-
let t =
|
|
855
|
+
function Vt(e) {
|
|
856
|
+
let t = Rt(e);
|
|
850
857
|
if (t.length !== 0) return t.map((e) => e.order === "DESC" ? `-${e.field}` : e.field).join(",");
|
|
851
858
|
}
|
|
852
859
|
//#endregion
|
|
853
860
|
//#region src/components/AuthAlternateLink.tsx
|
|
854
|
-
function
|
|
861
|
+
function Ht({ prompt: e, linkText: t, to: n }) {
|
|
855
862
|
return /* @__PURE__ */ H(R.Paragraph, {
|
|
856
863
|
type: "secondary",
|
|
857
864
|
style: {
|
|
@@ -870,7 +877,7 @@ function Vt({ prompt: e, linkText: t, to: n }) {
|
|
|
870
877
|
}
|
|
871
878
|
//#endregion
|
|
872
879
|
//#region src/layouts/AuthPageLayout.tsx
|
|
873
|
-
function
|
|
880
|
+
function Ut({ children: e, brand: t, footer: n, showThemeToolbar: r = !0 }) {
|
|
874
881
|
let { token: i } = z.useToken();
|
|
875
882
|
return /* @__PURE__ */ H(E, {
|
|
876
883
|
vertical: !0,
|
|
@@ -928,11 +935,11 @@ function Ht({ children: e, brand: t, footer: n, showThemeToolbar: r = !0 }) {
|
|
|
928
935
|
}
|
|
929
936
|
//#endregion
|
|
930
937
|
//#region src/pages/LoginPage.tsx
|
|
931
|
-
function
|
|
938
|
+
function Wt({ title: e = "Sign in", description: t = "Use any username and password to continue.", logo: n, brand: r, extraFields: i, showThemeToolbar: a = !0, afterLoginPath: o = "/", alternateAuth: s, footer: c }) {
|
|
932
939
|
let { login: l } = Le(), u = g();
|
|
933
|
-
return /* @__PURE__ */ V(
|
|
940
|
+
return /* @__PURE__ */ V(Ut, {
|
|
934
941
|
brand: r ?? n,
|
|
935
|
-
footer: c ?? (s ? /* @__PURE__ */ V(
|
|
942
|
+
footer: c ?? (s ? /* @__PURE__ */ V(Ht, {
|
|
936
943
|
prompt: s.prompt ?? "Don't have an account?",
|
|
937
944
|
linkText: s.linkText,
|
|
938
945
|
to: s.to
|
|
@@ -993,7 +1000,7 @@ function Ut({ title: e = "Sign in", description: t = "Use any username and passw
|
|
|
993
1000
|
}
|
|
994
1001
|
//#endregion
|
|
995
1002
|
//#region src/pages/PlaceholderPage.tsx
|
|
996
|
-
function
|
|
1003
|
+
function Gt({ title: e }) {
|
|
997
1004
|
return /* @__PURE__ */ V(R.Title, {
|
|
998
1005
|
level: 3,
|
|
999
1006
|
style: { marginTop: 0 },
|
|
@@ -1002,7 +1009,7 @@ function Wt({ title: e }) {
|
|
|
1002
1009
|
}
|
|
1003
1010
|
//#endregion
|
|
1004
1011
|
//#region src/crud/utils/sortQueryParam.ts
|
|
1005
|
-
function
|
|
1012
|
+
function Kt(e) {
|
|
1006
1013
|
if (!e) return [];
|
|
1007
1014
|
let t = [];
|
|
1008
1015
|
for (let n of e.split(",").map((e) => e.trim()).filter(Boolean)) {
|
|
@@ -1026,17 +1033,17 @@ function Gt(e) {
|
|
|
1026
1033
|
}
|
|
1027
1034
|
return t;
|
|
1028
1035
|
}
|
|
1029
|
-
function
|
|
1036
|
+
function qt(e) {
|
|
1030
1037
|
return e.length === 0 ? null : e.map((e) => e.order === "DESC" ? `-${e.field}` : e.field).join(",");
|
|
1031
1038
|
}
|
|
1032
|
-
function
|
|
1039
|
+
function Jt(e) {
|
|
1033
1040
|
return new Map(e.map((e, t) => [e.field, t + 1]));
|
|
1034
1041
|
}
|
|
1035
1042
|
//#endregion
|
|
1036
1043
|
//#region src/crud/context/ListContext.tsx
|
|
1037
|
-
var
|
|
1038
|
-
function
|
|
1039
|
-
let [r, a] = l([]), o = s(() => new Set(n.map((e) => e.field)), [n]), c = s(() => new Map(n.map((e) => [e.field, e.order])), [n]), u = s(() =>
|
|
1044
|
+
var Yt = t(null);
|
|
1045
|
+
function Xt({ children: e, toggleSort: t, sort: n }) {
|
|
1046
|
+
let [r, a] = l([]), o = s(() => new Set(n.map((e) => e.field)), [n]), c = s(() => new Map(n.map((e) => [e.field, e.order])), [n]), u = s(() => Jt(n), [n]), d = i((e) => (a((t) => {
|
|
1040
1047
|
let n = t.findIndex((t) => t.key === e.key);
|
|
1041
1048
|
if (n < 0) return [...t, e];
|
|
1042
1049
|
if (t[n] === e) return t;
|
|
@@ -1059,24 +1066,24 @@ function Yt({ children: e, toggleSort: t, sort: n }) {
|
|
|
1059
1066
|
u,
|
|
1060
1067
|
d
|
|
1061
1068
|
]);
|
|
1062
|
-
return /* @__PURE__ */ V(
|
|
1069
|
+
return /* @__PURE__ */ V(Yt.Provider, {
|
|
1063
1070
|
value: f,
|
|
1064
1071
|
children: e
|
|
1065
1072
|
});
|
|
1066
1073
|
}
|
|
1067
|
-
function
|
|
1068
|
-
let e = a(
|
|
1074
|
+
function Zt() {
|
|
1075
|
+
let e = a(Yt);
|
|
1069
1076
|
if (!e) throw Error("Column components must be used within ResourceList");
|
|
1070
1077
|
return e;
|
|
1071
1078
|
}
|
|
1072
1079
|
function X(e) {
|
|
1073
|
-
let { registerColumn: t } =
|
|
1080
|
+
let { registerColumn: t } = Zt();
|
|
1074
1081
|
o(() => t(e), [t, e]);
|
|
1075
1082
|
}
|
|
1076
1083
|
//#endregion
|
|
1077
1084
|
//#region src/crud/context/FilterContext.tsx
|
|
1078
|
-
var
|
|
1079
|
-
function
|
|
1085
|
+
var Qt = t(null);
|
|
1086
|
+
function $t({ children: e, values: t, setFilterValue: n }) {
|
|
1080
1087
|
let [r, a] = l([]), o = i((e) => (a((t) => {
|
|
1081
1088
|
let n = t.findIndex((t) => t.key === e.key);
|
|
1082
1089
|
if (n < 0) return [...t, e];
|
|
@@ -1096,25 +1103,25 @@ function Qt({ children: e, values: t, setFilterValue: n }) {
|
|
|
1096
1103
|
n,
|
|
1097
1104
|
o
|
|
1098
1105
|
]);
|
|
1099
|
-
return /* @__PURE__ */ V(
|
|
1106
|
+
return /* @__PURE__ */ V(Qt.Provider, {
|
|
1100
1107
|
value: c,
|
|
1101
1108
|
children: e
|
|
1102
1109
|
});
|
|
1103
1110
|
}
|
|
1104
|
-
function
|
|
1105
|
-
return a(
|
|
1111
|
+
function en() {
|
|
1112
|
+
return a(Qt);
|
|
1106
1113
|
}
|
|
1107
1114
|
function Z(e) {
|
|
1108
|
-
let t =
|
|
1115
|
+
let t = en()?.registerFilter;
|
|
1109
1116
|
o(() => {
|
|
1110
1117
|
if (t) return t(e);
|
|
1111
1118
|
}, [t, e]);
|
|
1112
1119
|
}
|
|
1113
1120
|
//#endregion
|
|
1114
1121
|
//#region src/crud/context/FormContext.tsx
|
|
1115
|
-
var
|
|
1116
|
-
function
|
|
1117
|
-
return /* @__PURE__ */ V(
|
|
1122
|
+
var tn = t(null);
|
|
1123
|
+
function nn({ children: e, resource: t, isNew: n, disabled: r }) {
|
|
1124
|
+
return /* @__PURE__ */ V(tn.Provider, {
|
|
1118
1125
|
value: {
|
|
1119
1126
|
resource: t,
|
|
1120
1127
|
isNew: n,
|
|
@@ -1123,56 +1130,60 @@ function tn({ children: e, resource: t, isNew: n, disabled: r }) {
|
|
|
1123
1130
|
children: e
|
|
1124
1131
|
});
|
|
1125
1132
|
}
|
|
1126
|
-
function
|
|
1127
|
-
return a(
|
|
1133
|
+
function rn() {
|
|
1134
|
+
return a(tn);
|
|
1128
1135
|
}
|
|
1129
1136
|
//#endregion
|
|
1130
1137
|
//#region src/crud/context/FormSectionContext.tsx
|
|
1131
|
-
var
|
|
1132
|
-
function
|
|
1133
|
-
return /* @__PURE__ */ V(
|
|
1138
|
+
var an = t(null);
|
|
1139
|
+
function on({ sourcesRef: e, children: t }) {
|
|
1140
|
+
return /* @__PURE__ */ V(an.Provider, {
|
|
1134
1141
|
value: e,
|
|
1135
1142
|
children: t
|
|
1136
1143
|
});
|
|
1137
1144
|
}
|
|
1138
|
-
function
|
|
1139
|
-
return a(
|
|
1140
|
-
}
|
|
1141
|
-
//#endregion
|
|
1142
|
-
//#region src/crud/context/
|
|
1143
|
-
var
|
|
1144
|
-
function
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
}), [r]), o = i(() => Array.from(r.current), [r]), l = s(() => ({
|
|
1148
|
-
registerSource: a,
|
|
1149
|
-
getSources: o
|
|
1150
|
-
}), [a, o]);
|
|
1151
|
-
return /* @__PURE__ */ V(sn.Provider, {
|
|
1152
|
-
value: l,
|
|
1145
|
+
function sn() {
|
|
1146
|
+
return a(an);
|
|
1147
|
+
}
|
|
1148
|
+
//#endregion
|
|
1149
|
+
//#region src/crud/context/SubmitFieldsContext.tsx
|
|
1150
|
+
var cn = t(null);
|
|
1151
|
+
function ln({ children: e, fieldsRef: t }) {
|
|
1152
|
+
return /* @__PURE__ */ V(cn.Provider, {
|
|
1153
|
+
value: t,
|
|
1153
1154
|
children: e
|
|
1154
1155
|
});
|
|
1155
1156
|
}
|
|
1156
|
-
function
|
|
1157
|
-
return a(
|
|
1157
|
+
function un() {
|
|
1158
|
+
return a(cn);
|
|
1158
1159
|
}
|
|
1159
|
-
function
|
|
1160
|
-
let
|
|
1160
|
+
function dn(e, t = !0) {
|
|
1161
|
+
let n = un();
|
|
1161
1162
|
o(() => {
|
|
1162
|
-
if (!t) return
|
|
1163
|
-
|
|
1164
|
-
return n?.current.add(e), () => {
|
|
1165
|
-
r(), n?.current.delete(e);
|
|
1163
|
+
if (!(!t || !n)) return n.current.add(e), () => {
|
|
1164
|
+
n.current.delete(e);
|
|
1166
1165
|
};
|
|
1167
1166
|
}, [
|
|
1168
|
-
t,
|
|
1169
1167
|
n,
|
|
1170
|
-
e
|
|
1168
|
+
e,
|
|
1169
|
+
t
|
|
1170
|
+
]);
|
|
1171
|
+
}
|
|
1172
|
+
function fn(e, t = !0) {
|
|
1173
|
+
let n = sn();
|
|
1174
|
+
o(() => {
|
|
1175
|
+
if (!(!t || !n)) return n.current.add(e), () => {
|
|
1176
|
+
n.current.delete(e);
|
|
1177
|
+
};
|
|
1178
|
+
}, [
|
|
1179
|
+
n,
|
|
1180
|
+
e,
|
|
1181
|
+
t
|
|
1171
1182
|
]);
|
|
1172
1183
|
}
|
|
1173
1184
|
//#endregion
|
|
1174
1185
|
//#region src/crud/utils/getByPath.ts
|
|
1175
|
-
function
|
|
1186
|
+
function pn(e, t) {
|
|
1176
1187
|
let n = t.split("."), r = e;
|
|
1177
1188
|
for (let e of n) {
|
|
1178
1189
|
if (typeof r != "object" || !r) return;
|
|
@@ -1182,7 +1193,7 @@ function dn(e, t) {
|
|
|
1182
1193
|
}
|
|
1183
1194
|
//#endregion
|
|
1184
1195
|
//#region src/crud/utils/setByPath.ts
|
|
1185
|
-
function
|
|
1196
|
+
function mn(e, t, n) {
|
|
1186
1197
|
let r = t.split("."), i = e;
|
|
1187
1198
|
for (let e = 0; e < r.length - 1; e++) {
|
|
1188
1199
|
let t = r[e], n = i[t];
|
|
@@ -1192,22 +1203,22 @@ function fn(e, t, n) {
|
|
|
1192
1203
|
}
|
|
1193
1204
|
//#endregion
|
|
1194
1205
|
//#region src/crud/utils/pickBySources.ts
|
|
1195
|
-
function
|
|
1206
|
+
function hn(e, t) {
|
|
1196
1207
|
if (t.length === 0) return { ...e };
|
|
1197
1208
|
let n = {};
|
|
1198
1209
|
for (let r of t) {
|
|
1199
|
-
let t =
|
|
1200
|
-
t !== void 0 &&
|
|
1210
|
+
let t = pn(e, r);
|
|
1211
|
+
t !== void 0 && mn(n, r, t);
|
|
1201
1212
|
}
|
|
1202
1213
|
return n;
|
|
1203
1214
|
}
|
|
1204
1215
|
//#endregion
|
|
1205
1216
|
//#region src/crud/utils/formErrors.ts
|
|
1206
|
-
function
|
|
1217
|
+
function gn(e) {
|
|
1207
1218
|
return e ? Array.isArray(e) ? e : [e] : [];
|
|
1208
1219
|
}
|
|
1209
|
-
function
|
|
1210
|
-
for (let e of
|
|
1220
|
+
function _n(e, t, n) {
|
|
1221
|
+
for (let e of gn(t.global)) n.error(e);
|
|
1211
1222
|
for (let [n, r] of Object.entries(t.fields ?? {})) {
|
|
1212
1223
|
let t = Array.isArray(r) ? r.join(", ") : r;
|
|
1213
1224
|
e.setError(n, {
|
|
@@ -1216,71 +1227,80 @@ function hn(e, t, n) {
|
|
|
1216
1227
|
});
|
|
1217
1228
|
}
|
|
1218
1229
|
}
|
|
1219
|
-
function
|
|
1230
|
+
function vn(e, t, n, r, i) {
|
|
1220
1231
|
let a = e.parseFormError?.(r, i);
|
|
1221
1232
|
if (!a) return !1;
|
|
1222
|
-
let o = Object.keys(a.fields ?? {}).length > 0, s =
|
|
1223
|
-
return !o && !s ? !1 : (
|
|
1233
|
+
let o = Object.keys(a.fields ?? {}).length > 0, s = gn(a.global).length > 0;
|
|
1234
|
+
return !o && !s ? !1 : (_n(t, a, n), !0);
|
|
1235
|
+
}
|
|
1236
|
+
//#endregion
|
|
1237
|
+
//#region src/crud/utils/useAbortableEffect.ts
|
|
1238
|
+
function yn(e, t) {
|
|
1239
|
+
o(() => {
|
|
1240
|
+
let t = new AbortController();
|
|
1241
|
+
return e(t.signal), () => t.abort();
|
|
1242
|
+
}, t);
|
|
1224
1243
|
}
|
|
1225
1244
|
//#endregion
|
|
1226
1245
|
//#region src/crud/ResourceFormModal.tsx
|
|
1227
|
-
function
|
|
1228
|
-
let
|
|
1229
|
-
if (
|
|
1230
|
-
|
|
1246
|
+
function bn({ resource: e, editId: t, onClose: n, children: r, title: a }) {
|
|
1247
|
+
let o = t === "new" || t == null, s = t != null, u = mt(), { message: d } = y.useApp(), [f, p] = l(!o), m = ye(), h = c(/* @__PURE__ */ new Set()), g = i(async (n) => {
|
|
1248
|
+
if (o || !t) {
|
|
1249
|
+
m.reset({}), p(!1);
|
|
1231
1250
|
return;
|
|
1232
1251
|
}
|
|
1233
|
-
|
|
1252
|
+
p(!0);
|
|
1234
1253
|
try {
|
|
1235
|
-
let
|
|
1236
|
-
|
|
1254
|
+
let r = await u.getOne(e, t, { signal: n });
|
|
1255
|
+
if (n?.aborted) return;
|
|
1256
|
+
m.reset(r.data);
|
|
1237
1257
|
} catch (e) {
|
|
1238
|
-
|
|
1258
|
+
vt(e) || d.error(e instanceof Error ? e.message : "Load failed");
|
|
1239
1259
|
} finally {
|
|
1240
|
-
|
|
1260
|
+
n?.aborted || p(!1);
|
|
1241
1261
|
}
|
|
1242
1262
|
}, [
|
|
1243
|
-
|
|
1263
|
+
u,
|
|
1244
1264
|
e,
|
|
1245
1265
|
t,
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1266
|
+
o,
|
|
1267
|
+
m,
|
|
1268
|
+
d
|
|
1249
1269
|
]);
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
}, [
|
|
1253
|
-
async function
|
|
1270
|
+
yn((e) => {
|
|
1271
|
+
if (s) return g(e);
|
|
1272
|
+
}, [s, g]);
|
|
1273
|
+
async function _(r) {
|
|
1254
1274
|
try {
|
|
1255
|
-
let i =
|
|
1256
|
-
|
|
1275
|
+
let i = hn(r, Array.from(h.current));
|
|
1276
|
+
o ? (await u.create(e, i), d.success("Created")) : t && (await u.update(e, {
|
|
1257
1277
|
id: t,
|
|
1258
1278
|
data: i
|
|
1259
|
-
}),
|
|
1279
|
+
}), d.success("Updated")), n();
|
|
1260
1280
|
} catch (t) {
|
|
1261
|
-
|
|
1281
|
+
vn(u, m, d, t, {
|
|
1262
1282
|
resource: e,
|
|
1263
|
-
mutation:
|
|
1264
|
-
}) ||
|
|
1283
|
+
mutation: o ? "create" : "update"
|
|
1284
|
+
}) || d.error(t instanceof Error ? t.message : "Save failed");
|
|
1265
1285
|
}
|
|
1266
1286
|
}
|
|
1267
|
-
return /* @__PURE__ */ V(
|
|
1268
|
-
open:
|
|
1269
|
-
title: a ?? (
|
|
1287
|
+
return /* @__PURE__ */ V(te, {
|
|
1288
|
+
open: s,
|
|
1289
|
+
title: a ?? (o ? `New ${e}` : `Edit ${e}`),
|
|
1270
1290
|
onCancel: n,
|
|
1271
1291
|
footer: null,
|
|
1272
1292
|
destroyOnHidden: !0,
|
|
1273
1293
|
width: 560,
|
|
1274
|
-
children:
|
|
1294
|
+
children: f ? /* @__PURE__ */ V(L, {}) : /* @__PURE__ */ V(nn, {
|
|
1275
1295
|
resource: e,
|
|
1276
|
-
isNew:
|
|
1277
|
-
children: /* @__PURE__ */ V(
|
|
1278
|
-
|
|
1296
|
+
isNew: o,
|
|
1297
|
+
children: /* @__PURE__ */ V(ln, {
|
|
1298
|
+
fieldsRef: h,
|
|
1279
1299
|
children: /* @__PURE__ */ V(_e, {
|
|
1280
|
-
...
|
|
1300
|
+
...m,
|
|
1281
1301
|
children: /* @__PURE__ */ H(D, {
|
|
1282
1302
|
layout: "vertical",
|
|
1283
|
-
onFinish: () => void
|
|
1303
|
+
onFinish: () => void m.handleSubmit(_)(),
|
|
1284
1304
|
children: [r, /* @__PURE__ */ H(D.Item, {
|
|
1285
1305
|
style: {
|
|
1286
1306
|
marginTop: 16,
|
|
@@ -1304,7 +1324,7 @@ function _n({ resource: e, editId: t, onClose: n, children: r, title: a }) {
|
|
|
1304
1324
|
}
|
|
1305
1325
|
//#endregion
|
|
1306
1326
|
//#region src/crud/ListActionsBar.tsx
|
|
1307
|
-
function
|
|
1327
|
+
function xn({ selectedCount: e, total: t, allPageSelected: n, allMatchingSelected: r, onSelectAllMatching: a, onClearSelection: o, actions: c, onExecute: u, selectedIds: d, running: f = !1 }) {
|
|
1308
1328
|
let [p, m] = l(), h = s(() => c.map((e) => ({
|
|
1309
1329
|
value: e.key,
|
|
1310
1330
|
label: e.label
|
|
@@ -1318,7 +1338,7 @@ function vn({ selectedCount: e, total: t, allPageSelected: n, allMatchingSelecte
|
|
|
1318
1338
|
e,
|
|
1319
1339
|
d
|
|
1320
1340
|
]), _ = n && !r && t > e;
|
|
1321
|
-
return /* @__PURE__ */ H(
|
|
1341
|
+
return /* @__PURE__ */ H(I, {
|
|
1322
1342
|
wrap: !0,
|
|
1323
1343
|
style: {
|
|
1324
1344
|
marginBottom: 16,
|
|
@@ -1367,7 +1387,7 @@ function vn({ selectedCount: e, total: t, allPageSelected: n, allMatchingSelecte
|
|
|
1367
1387
|
" items selected"
|
|
1368
1388
|
]
|
|
1369
1389
|
})] }) : null,
|
|
1370
|
-
/* @__PURE__ */ V(
|
|
1390
|
+
/* @__PURE__ */ V(F, {
|
|
1371
1391
|
placeholder: "Action",
|
|
1372
1392
|
style: { minWidth: 200 },
|
|
1373
1393
|
options: h,
|
|
@@ -1388,14 +1408,14 @@ function vn({ selectedCount: e, total: t, allPageSelected: n, allMatchingSelecte
|
|
|
1388
1408
|
}
|
|
1389
1409
|
//#endregion
|
|
1390
1410
|
//#region src/crud/types.ts
|
|
1391
|
-
var
|
|
1411
|
+
var Sn = new Set([
|
|
1392
1412
|
"page",
|
|
1393
1413
|
"perPage",
|
|
1394
1414
|
"sort",
|
|
1395
1415
|
"create",
|
|
1396
1416
|
"edit"
|
|
1397
|
-
]),
|
|
1398
|
-
function
|
|
1417
|
+
]), Cn = 1, wn = 10;
|
|
1418
|
+
function Tn(e) {
|
|
1399
1419
|
if (e.includes(",")) {
|
|
1400
1420
|
let t = e.split(",").map((e) => e.trim()), n = t.map(Number);
|
|
1401
1421
|
return n.every((e) => Number.isFinite(e)) ? n : t;
|
|
@@ -1403,16 +1423,16 @@ function Sn(e) {
|
|
|
1403
1423
|
let t = Number(e);
|
|
1404
1424
|
return e !== "" && Number.isFinite(t) && String(t) === e ? t : e === "true" ? !0 : e === "false" ? !1 : e;
|
|
1405
1425
|
}
|
|
1406
|
-
function
|
|
1426
|
+
function En(e) {
|
|
1407
1427
|
return e == null || e === "" ? null : Array.isArray(e) ? e.length === 0 ? null : e.map(String).join(",") : String(e);
|
|
1408
1428
|
}
|
|
1409
|
-
function
|
|
1429
|
+
function Dn(e) {
|
|
1410
1430
|
let [t, n] = v(), r = s(() => {
|
|
1411
|
-
let n = t.get("page"), r = t.get("perPage"), i = n ? Math.max(1, Number(n) ||
|
|
1431
|
+
let n = t.get("page"), r = t.get("perPage"), i = n ? Math.max(1, Number(n) || Cn) : Cn, a = r ? Math.max(1, Number(r) || wn) : wn, o = t.getAll("sort"), s = o.length > 0 ? o.flatMap((e) => Kt(e)) : Kt(t.get("sort")), c = { ...e };
|
|
1412
1432
|
return t.forEach((e, n) => {
|
|
1413
|
-
if (
|
|
1433
|
+
if (Sn.has(n)) return;
|
|
1414
1434
|
let r = c[n];
|
|
1415
|
-
r === void 0 ? t.getAll(n).length > 1 ? c[n] = t.getAll(n).map(
|
|
1435
|
+
r === void 0 ? t.getAll(n).length > 1 ? c[n] = t.getAll(n).map(Tn) : c[n] = Tn(e) : c[n] = [...Array.isArray(r) ? r : [r], Tn(e)];
|
|
1416
1436
|
}), {
|
|
1417
1437
|
page: i,
|
|
1418
1438
|
perPage: a,
|
|
@@ -1435,19 +1455,19 @@ function wn(e) {
|
|
|
1435
1455
|
},
|
|
1436
1456
|
setPerPage: (e) => {
|
|
1437
1457
|
a((t) => {
|
|
1438
|
-
e ===
|
|
1458
|
+
e === wn ? t.delete("perPage") : t.set("perPage", String(e)), t.delete("page");
|
|
1439
1459
|
});
|
|
1440
1460
|
},
|
|
1441
1461
|
setSort: (e) => {
|
|
1442
1462
|
a((t) => {
|
|
1443
1463
|
t.delete("sort");
|
|
1444
|
-
let n =
|
|
1464
|
+
let n = qt(e);
|
|
1445
1465
|
n && t.set("sort", n);
|
|
1446
1466
|
});
|
|
1447
1467
|
},
|
|
1448
1468
|
toggleSort: (e) => {
|
|
1449
1469
|
a((t) => {
|
|
1450
|
-
let n = t.getAll("sort").flatMap((e) =>
|
|
1470
|
+
let n = t.getAll("sort").flatMap((e) => Kt(e)), r = n.findIndex((t) => t.field === e), i;
|
|
1451
1471
|
i = r < 0 ? [...n, {
|
|
1452
1472
|
field: e,
|
|
1453
1473
|
order: "ASC"
|
|
@@ -1455,22 +1475,22 @@ function wn(e) {
|
|
|
1455
1475
|
...e,
|
|
1456
1476
|
order: "DESC"
|
|
1457
1477
|
} : e) : n.filter((e, t) => t !== r), t.delete("sort");
|
|
1458
|
-
let a =
|
|
1478
|
+
let a = qt(i);
|
|
1459
1479
|
a && t.set("sort", a);
|
|
1460
1480
|
});
|
|
1461
1481
|
},
|
|
1462
1482
|
setFilter: (e, t) => {
|
|
1463
1483
|
a((n) => {
|
|
1464
1484
|
n.delete(e);
|
|
1465
|
-
let r =
|
|
1485
|
+
let r = En(t);
|
|
1466
1486
|
r != null && n.set(e, r), n.delete("page");
|
|
1467
1487
|
});
|
|
1468
1488
|
},
|
|
1469
1489
|
setFilters: (e) => {
|
|
1470
1490
|
a((t) => {
|
|
1471
|
-
for (let e of [...t.keys()])
|
|
1491
|
+
for (let e of [...t.keys()]) Sn.has(e) || t.delete(e);
|
|
1472
1492
|
for (let [n, r] of Object.entries(e)) {
|
|
1473
|
-
let e =
|
|
1493
|
+
let e = En(r);
|
|
1474
1494
|
e != null && t.set(n, e);
|
|
1475
1495
|
}
|
|
1476
1496
|
t.delete("page");
|
|
@@ -1495,66 +1515,66 @@ function wn(e) {
|
|
|
1495
1515
|
}
|
|
1496
1516
|
//#endregion
|
|
1497
1517
|
//#region src/crud/ResourceList.tsx
|
|
1498
|
-
var
|
|
1499
|
-
function
|
|
1500
|
-
return a(
|
|
1518
|
+
var On = t(null);
|
|
1519
|
+
function kn() {
|
|
1520
|
+
return a(On);
|
|
1501
1521
|
}
|
|
1502
|
-
function
|
|
1503
|
-
let
|
|
1522
|
+
function An({ resource: e, title: t, pathPrefix: n, newPath: r, editMode: a = "page", formChildren: o, actions: c, rowActions: d, headerExtra: f, bulkActions: p, bulkDelete: m = !0, bulkActionsEnabled: h = !0, permissions: g, queryState: _, queryActions: v }) {
|
|
1523
|
+
let b = mt(), C = q(), { message: w, modal: ee } = y.useApp(), { columns: T, sortOrders: E, sortPriorities: D } = Zt(), [O, k] = l(!1), [A, j] = l([]), [M, te] = l(0), [N, P] = l(() => /* @__PURE__ */ new Set()), [F, L] = l(!1), ne = r ?? `${n}/new`, re = J(C, g, "add"), ae = J(C, g, "change"), z = J(C, g, "delete"), U = ae && (a === "page" || a === "both") && c?.edit !== !1, W = ae && (a === "modal" || a === "both") && c?.quickEdit !== !1, ce = z && c?.delete !== !1, le = U || W || ce || d, ue = i(() => {
|
|
1504
1524
|
P(/* @__PURE__ */ new Set());
|
|
1505
|
-
}, []),
|
|
1506
|
-
if (!
|
|
1525
|
+
}, []), de = s(() => {
|
|
1526
|
+
if (!h) return [];
|
|
1507
1527
|
let t = [];
|
|
1508
|
-
return
|
|
1528
|
+
return m && z && t.push({
|
|
1509
1529
|
key: "__delete",
|
|
1510
1530
|
label: "Delete selected",
|
|
1511
1531
|
confirm: (e) => `Delete ${e.length} selected item(s)? This cannot be undone.`,
|
|
1512
1532
|
execute: async (t, { reload: n, clearSelection: r }) => {
|
|
1513
|
-
await Promise.all(t.map((t) =>
|
|
1533
|
+
await Promise.all(t.map((t) => b.delete(e, t))), r(), n(), w.success(`Deleted ${t.length} item(s)`);
|
|
1514
1534
|
}
|
|
1515
|
-
}), [...t, ...
|
|
1535
|
+
}), [...t, ...p ?? []];
|
|
1516
1536
|
}, [
|
|
1517
|
-
g,
|
|
1518
1537
|
h,
|
|
1519
|
-
U,
|
|
1520
1538
|
m,
|
|
1521
|
-
|
|
1539
|
+
z,
|
|
1540
|
+
p,
|
|
1541
|
+
b,
|
|
1522
1542
|
e,
|
|
1523
|
-
|
|
1524
|
-
]),
|
|
1543
|
+
w
|
|
1544
|
+
]), fe = de.length > 0, pe = N.size, me = A.length > 0 && A.every((e) => N.has(e.id)), he = M > 0 && pe >= M, ge = s(() => A.filter((e) => N.has(e.id)).map((e) => e.id), [A, N]), _e = i((e) => {
|
|
1525
1545
|
P((t) => {
|
|
1526
|
-
let n = new Set(t), r =
|
|
1546
|
+
let n = new Set(t), r = A.map((e) => e.id);
|
|
1527
1547
|
for (let t of r) e.includes(t) || n.delete(t);
|
|
1528
1548
|
for (let t of e) n.add(t);
|
|
1529
1549
|
return n;
|
|
1530
1550
|
});
|
|
1531
|
-
}, [
|
|
1551
|
+
}, [A]), ve = i(async () => {
|
|
1532
1552
|
if (!(M <= 0)) {
|
|
1533
1553
|
L(!0);
|
|
1534
1554
|
try {
|
|
1535
|
-
let t =
|
|
1555
|
+
let t = _.sort.length === 0 ? void 0 : _.sort.length === 1 ? _.sort[0] : _.sort, n = await b.getList(e, {
|
|
1536
1556
|
pagination: {
|
|
1537
1557
|
page: 1,
|
|
1538
1558
|
perPage: M
|
|
1539
1559
|
},
|
|
1540
1560
|
sort: t,
|
|
1541
|
-
filter:
|
|
1561
|
+
filter: _.filter
|
|
1542
1562
|
});
|
|
1543
1563
|
P(new Set(n.data.map((e) => e.id)));
|
|
1544
1564
|
} catch (e) {
|
|
1545
|
-
|
|
1565
|
+
w.error(e instanceof Error ? e.message : "Load failed");
|
|
1546
1566
|
} finally {
|
|
1547
1567
|
L(!1);
|
|
1548
1568
|
}
|
|
1549
1569
|
}
|
|
1550
1570
|
}, [
|
|
1551
|
-
|
|
1571
|
+
b,
|
|
1552
1572
|
e,
|
|
1553
1573
|
M,
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
]),
|
|
1574
|
+
_.sort,
|
|
1575
|
+
_.filter,
|
|
1576
|
+
w
|
|
1577
|
+
]), ye = i((e) => {
|
|
1558
1578
|
let t = (e) => {
|
|
1559
1579
|
let t = e?.columnKey ?? e?.field;
|
|
1560
1580
|
return t == null ? null : String(Array.isArray(t) ? t[0] : t);
|
|
@@ -1563,48 +1583,53 @@ function Dn({ resource: e, title: t, pathPrefix: n, newPath: r, editMode: a = "p
|
|
|
1563
1583
|
let n = e.find((e) => e?.order);
|
|
1564
1584
|
if (n) {
|
|
1565
1585
|
let e = t(n);
|
|
1566
|
-
e &&
|
|
1586
|
+
e && v.toggleSort(e);
|
|
1567
1587
|
return;
|
|
1568
1588
|
}
|
|
1569
|
-
|
|
1589
|
+
_.sort.length > 0 && v.setSort([]);
|
|
1570
1590
|
return;
|
|
1571
1591
|
}
|
|
1572
1592
|
let n = t(e);
|
|
1573
1593
|
if (n) {
|
|
1574
|
-
|
|
1594
|
+
v.toggleSort(n);
|
|
1575
1595
|
return;
|
|
1576
1596
|
}
|
|
1577
|
-
!e?.order &&
|
|
1578
|
-
}, [
|
|
1579
|
-
|
|
1597
|
+
!e?.order && _.sort.length > 0 && v.setSort([]);
|
|
1598
|
+
}, [v, _.sort.length]), G = s(() => {
|
|
1599
|
+
let e = _.sort.length === 0 ? void 0 : _.sort.length === 1 ? _.sort[0] : _.sort;
|
|
1600
|
+
return {
|
|
1601
|
+
pagination: {
|
|
1602
|
+
page: _.page,
|
|
1603
|
+
perPage: _.perPage
|
|
1604
|
+
},
|
|
1605
|
+
sort: e,
|
|
1606
|
+
filter: _.filter
|
|
1607
|
+
};
|
|
1608
|
+
}, [_]), K = i(async (t) => {
|
|
1609
|
+
k(!0);
|
|
1580
1610
|
try {
|
|
1581
|
-
let
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
perPage: v.perPage
|
|
1585
|
-
},
|
|
1586
|
-
sort: t,
|
|
1587
|
-
filter: v.filter
|
|
1611
|
+
let n = await b.getList(e, {
|
|
1612
|
+
...G,
|
|
1613
|
+
signal: t
|
|
1588
1614
|
});
|
|
1589
|
-
|
|
1615
|
+
if (t?.aborted) return;
|
|
1616
|
+
j(n.data), te(n.total);
|
|
1590
1617
|
} catch (e) {
|
|
1591
|
-
|
|
1618
|
+
vt(e) || w.error(e instanceof Error ? e.message : "Load failed");
|
|
1592
1619
|
} finally {
|
|
1593
|
-
|
|
1620
|
+
t?.aborted || k(!1);
|
|
1594
1621
|
}
|
|
1595
1622
|
}, [
|
|
1596
|
-
|
|
1623
|
+
b,
|
|
1597
1624
|
e,
|
|
1598
|
-
|
|
1599
|
-
|
|
1625
|
+
G,
|
|
1626
|
+
w
|
|
1600
1627
|
]);
|
|
1601
|
-
|
|
1602
|
-
K();
|
|
1603
|
-
}, [K]);
|
|
1628
|
+
yn((e) => K(e), [K]);
|
|
1604
1629
|
let be = s(() => ({
|
|
1605
1630
|
reload: () => void K(),
|
|
1606
|
-
clearSelection:
|
|
1607
|
-
}), [K,
|
|
1631
|
+
clearSelection: ue
|
|
1632
|
+
}), [K, ue]), xe = i(async (e, t) => {
|
|
1608
1633
|
if (e.confirm) {
|
|
1609
1634
|
let n = typeof e.confirm == "function" ? await e.confirm(t, be) : e.confirm;
|
|
1610
1635
|
if (n === !1 || !await new Promise((t) => {
|
|
@@ -1620,31 +1645,31 @@ function Dn({ resource: e, title: t, pathPrefix: n, newPath: r, editMode: a = "p
|
|
|
1620
1645
|
try {
|
|
1621
1646
|
await e.execute(t, be);
|
|
1622
1647
|
} catch (e) {
|
|
1623
|
-
|
|
1648
|
+
w.error(e instanceof Error ? e.message : "Action failed");
|
|
1624
1649
|
} finally {
|
|
1625
1650
|
L(!1);
|
|
1626
1651
|
}
|
|
1627
1652
|
}, [
|
|
1628
1653
|
be,
|
|
1629
1654
|
ee,
|
|
1630
|
-
|
|
1655
|
+
w
|
|
1631
1656
|
]), Se = i(async (t) => {
|
|
1632
|
-
if (
|
|
1633
|
-
await
|
|
1657
|
+
if (z) try {
|
|
1658
|
+
await b.delete(e, t.id), w.success("Deleted"), K();
|
|
1634
1659
|
} catch (e) {
|
|
1635
|
-
|
|
1660
|
+
w.error(e instanceof Error ? e.message : "Delete failed");
|
|
1636
1661
|
}
|
|
1637
1662
|
}, [
|
|
1638
|
-
|
|
1639
|
-
|
|
1663
|
+
z,
|
|
1664
|
+
b,
|
|
1640
1665
|
e,
|
|
1641
1666
|
K,
|
|
1642
|
-
|
|
1667
|
+
w
|
|
1643
1668
|
]), Ce = s(() => {
|
|
1644
|
-
let e =
|
|
1669
|
+
let e = T.map((e) => {
|
|
1645
1670
|
let t = e.buildColumn();
|
|
1646
1671
|
if (e.sortable) {
|
|
1647
|
-
let n =
|
|
1672
|
+
let n = E.get(e.source), r = D.get(e.source), i = n === "ASC" ? "ascend" : n === "DESC" ? "descend" : void 0, a = i == null ? void 0 : /* @__PURE__ */ H("span", {
|
|
1648
1673
|
style: {
|
|
1649
1674
|
display: "inline-flex",
|
|
1650
1675
|
alignItems: "center",
|
|
@@ -1672,30 +1697,30 @@ function Dn({ resource: e, title: t, pathPrefix: n, newPath: r, editMode: a = "p
|
|
|
1672
1697
|
}
|
|
1673
1698
|
return t;
|
|
1674
1699
|
});
|
|
1675
|
-
if (!
|
|
1700
|
+
if (!le) return e;
|
|
1676
1701
|
let t = {
|
|
1677
1702
|
reload: () => void K(),
|
|
1678
|
-
openEditModal:
|
|
1703
|
+
openEditModal: v.openEditModal
|
|
1679
1704
|
}, r = {
|
|
1680
1705
|
title: "Actions",
|
|
1681
1706
|
key: "__actions",
|
|
1682
1707
|
width: a === "both" ? 200 : 160,
|
|
1683
|
-
render: (e, r) => /* @__PURE__ */ H(
|
|
1708
|
+
render: (e, r) => /* @__PURE__ */ H(I, {
|
|
1684
1709
|
size: "small",
|
|
1685
1710
|
wrap: !0,
|
|
1686
1711
|
children: [
|
|
1687
|
-
|
|
1712
|
+
U ? /* @__PURE__ */ V(u, {
|
|
1688
1713
|
to: `${n}/${String(r.id)}`,
|
|
1689
1714
|
children: "Edit"
|
|
1690
1715
|
}) : null,
|
|
1691
|
-
|
|
1716
|
+
W ? /* @__PURE__ */ V(x, {
|
|
1692
1717
|
type: "link",
|
|
1693
1718
|
size: "small",
|
|
1694
1719
|
style: { padding: 0 },
|
|
1695
|
-
onClick: () =>
|
|
1720
|
+
onClick: () => v.openEditModal(r.id),
|
|
1696
1721
|
children: a === "both" ? "Quick edit" : "Edit"
|
|
1697
1722
|
}) : null,
|
|
1698
|
-
|
|
1723
|
+
ce ? /* @__PURE__ */ V(x, {
|
|
1699
1724
|
type: "link",
|
|
1700
1725
|
danger: !0,
|
|
1701
1726
|
size: "small",
|
|
@@ -1703,91 +1728,91 @@ function Dn({ resource: e, title: t, pathPrefix: n, newPath: r, editMode: a = "p
|
|
|
1703
1728
|
style: { padding: 0 },
|
|
1704
1729
|
children: "Delete"
|
|
1705
1730
|
}) : null,
|
|
1706
|
-
|
|
1731
|
+
d?.(r, t)
|
|
1707
1732
|
]
|
|
1708
1733
|
})
|
|
1709
1734
|
};
|
|
1710
1735
|
return [...e, r];
|
|
1711
1736
|
}, [
|
|
1712
|
-
|
|
1713
|
-
|
|
1737
|
+
T,
|
|
1738
|
+
le,
|
|
1739
|
+
U,
|
|
1714
1740
|
W,
|
|
1715
1741
|
ce,
|
|
1716
|
-
le,
|
|
1717
1742
|
a,
|
|
1718
1743
|
n,
|
|
1719
1744
|
Se,
|
|
1745
|
+
E,
|
|
1720
1746
|
D,
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
f,
|
|
1747
|
+
v,
|
|
1748
|
+
d,
|
|
1724
1749
|
K
|
|
1725
|
-
]), we =
|
|
1750
|
+
]), we = o && (_.createModal || _.editId != null) && (a === "modal" || a === "both");
|
|
1726
1751
|
return /* @__PURE__ */ H(B, { children: [/* @__PURE__ */ H(S, {
|
|
1727
1752
|
title: /* @__PURE__ */ V(R.Title, {
|
|
1728
1753
|
level: 5,
|
|
1729
1754
|
style: { margin: 0 },
|
|
1730
1755
|
children: t
|
|
1731
1756
|
}),
|
|
1732
|
-
extra:
|
|
1733
|
-
to:
|
|
1757
|
+
extra: f || re ? /* @__PURE__ */ H(I, { children: [f, re ? a === "modal" || a === "both" ? /* @__PURE__ */ H(B, { children: [a === "both" ? /* @__PURE__ */ V(u, {
|
|
1758
|
+
to: ne,
|
|
1734
1759
|
children: /* @__PURE__ */ V(x, { children: "New page" })
|
|
1735
1760
|
}) : null, /* @__PURE__ */ V(x, {
|
|
1736
1761
|
type: "primary",
|
|
1737
|
-
onClick: () =>
|
|
1762
|
+
onClick: () => v.openCreateModal(),
|
|
1738
1763
|
children: "New"
|
|
1739
1764
|
})] }) : /* @__PURE__ */ V(u, {
|
|
1740
|
-
to:
|
|
1765
|
+
to: ne,
|
|
1741
1766
|
children: /* @__PURE__ */ V(x, {
|
|
1742
1767
|
type: "primary",
|
|
1743
1768
|
children: "New"
|
|
1744
1769
|
})
|
|
1745
1770
|
}) : null] }) : null,
|
|
1746
|
-
children: [
|
|
1747
|
-
selectedCount:
|
|
1771
|
+
children: [fe ? /* @__PURE__ */ V(xn, {
|
|
1772
|
+
selectedCount: pe,
|
|
1748
1773
|
total: M,
|
|
1749
|
-
allPageSelected:
|
|
1750
|
-
allMatchingSelected:
|
|
1751
|
-
onSelectAllMatching: () => void
|
|
1752
|
-
onClearSelection:
|
|
1753
|
-
actions:
|
|
1774
|
+
allPageSelected: me,
|
|
1775
|
+
allMatchingSelected: he,
|
|
1776
|
+
onSelectAllMatching: () => void ve(),
|
|
1777
|
+
onClearSelection: ue,
|
|
1778
|
+
actions: de,
|
|
1754
1779
|
onExecute: xe,
|
|
1755
1780
|
selectedIds: [...N],
|
|
1756
|
-
running:
|
|
1781
|
+
running: F || O
|
|
1757
1782
|
}) : null, /* @__PURE__ */ V(ie, {
|
|
1758
1783
|
rowKey: "id",
|
|
1759
|
-
loading:
|
|
1784
|
+
loading: O,
|
|
1760
1785
|
columns: Ce,
|
|
1761
|
-
dataSource:
|
|
1762
|
-
rowSelection:
|
|
1763
|
-
selectedRowKeys:
|
|
1764
|
-
onChange:
|
|
1786
|
+
dataSource: A,
|
|
1787
|
+
rowSelection: fe ? {
|
|
1788
|
+
selectedRowKeys: ge,
|
|
1789
|
+
onChange: _e,
|
|
1765
1790
|
preserveSelectedRowKeys: !0
|
|
1766
1791
|
} : void 0,
|
|
1767
1792
|
pagination: {
|
|
1768
|
-
current:
|
|
1769
|
-
pageSize:
|
|
1793
|
+
current: _.page,
|
|
1794
|
+
pageSize: _.perPage,
|
|
1770
1795
|
total: M,
|
|
1771
1796
|
showSizeChanger: !0,
|
|
1772
1797
|
onChange: (e, t) => {
|
|
1773
|
-
|
|
1798
|
+
v.setPage(e), t && v.setPerPage(t);
|
|
1774
1799
|
}
|
|
1775
1800
|
},
|
|
1776
1801
|
onChange: (e, t, n) => {
|
|
1777
|
-
|
|
1802
|
+
ye(n);
|
|
1778
1803
|
}
|
|
1779
1804
|
})]
|
|
1780
|
-
}), we ? /* @__PURE__ */ V(
|
|
1805
|
+
}), we ? /* @__PURE__ */ V(bn, {
|
|
1781
1806
|
resource: e,
|
|
1782
|
-
editId:
|
|
1807
|
+
editId: _.createModal ? "new" : _.editId,
|
|
1783
1808
|
onClose: () => {
|
|
1784
|
-
|
|
1809
|
+
v.closeModal(), K();
|
|
1785
1810
|
},
|
|
1786
|
-
children:
|
|
1811
|
+
children: o
|
|
1787
1812
|
}) : null] });
|
|
1788
1813
|
}
|
|
1789
|
-
function
|
|
1790
|
-
let [v, y] =
|
|
1814
|
+
function jn({ resource: e, title: t, pathPrefix: n, newPath: r, staticFilter: a, editMode: o = "page", syncQueryParams: c = !0, children: l, formChildren: u, actions: d, rowActions: f, headerExtra: p, bulkActions: m, bulkDelete: h, bulkActionsEnabled: g, permissions: _ }) {
|
|
1815
|
+
let [v, y] = Dn(a), b = s(() => {
|
|
1791
1816
|
if (!c) return a ?? {};
|
|
1792
1817
|
let e = {};
|
|
1793
1818
|
for (let [t, n] of Object.entries(v.filter)) a && t in a || (e[t] = n);
|
|
@@ -1802,15 +1827,15 @@ function On({ resource: e, title: t, pathPrefix: n, newPath: r, staticFilter: a,
|
|
|
1802
1827
|
filterValues: b,
|
|
1803
1828
|
setFilterValue: x
|
|
1804
1829
|
}), [b, x]);
|
|
1805
|
-
return /* @__PURE__ */ V(
|
|
1830
|
+
return /* @__PURE__ */ V(On.Provider, {
|
|
1806
1831
|
value: S,
|
|
1807
|
-
children: /* @__PURE__ */ V(
|
|
1832
|
+
children: /* @__PURE__ */ V($t, {
|
|
1808
1833
|
values: b,
|
|
1809
1834
|
setFilterValue: x,
|
|
1810
|
-
children: /* @__PURE__ */ H(
|
|
1835
|
+
children: /* @__PURE__ */ H(Xt, {
|
|
1811
1836
|
toggleSort: y.toggleSort,
|
|
1812
1837
|
sort: v.sort,
|
|
1813
|
-
children: [l, /* @__PURE__ */ V(
|
|
1838
|
+
children: [l, /* @__PURE__ */ V(An, {
|
|
1814
1839
|
resource: e,
|
|
1815
1840
|
title: t,
|
|
1816
1841
|
pathPrefix: n,
|
|
@@ -1833,13 +1858,13 @@ function On({ resource: e, title: t, pathPrefix: n, newPath: r, staticFilter: a,
|
|
|
1833
1858
|
}
|
|
1834
1859
|
//#endregion
|
|
1835
1860
|
//#region src/crud/FilterBar.tsx
|
|
1836
|
-
function
|
|
1837
|
-
let e =
|
|
1838
|
-
return !e || e.filters.length === 0 ? null : /* @__PURE__ */ V(
|
|
1861
|
+
function Mn() {
|
|
1862
|
+
let e = en();
|
|
1863
|
+
return !e || e.filters.length === 0 ? null : /* @__PURE__ */ V(I, {
|
|
1839
1864
|
wrap: !0,
|
|
1840
1865
|
size: "middle",
|
|
1841
1866
|
style: { marginBottom: 16 },
|
|
1842
|
-
children: e.filters.map((t) => /* @__PURE__ */ H(
|
|
1867
|
+
children: e.filters.map((t) => /* @__PURE__ */ H(I, {
|
|
1843
1868
|
orientation: "vertical",
|
|
1844
1869
|
size: 2,
|
|
1845
1870
|
children: [t.label ? /* @__PURE__ */ V(R.Text, {
|
|
@@ -1853,76 +1878,51 @@ function kn() {
|
|
|
1853
1878
|
}, t.key))
|
|
1854
1879
|
});
|
|
1855
1880
|
}
|
|
1856
|
-
function
|
|
1857
|
-
return /* @__PURE__ */ H(B, { children: [e, /* @__PURE__ */ V(
|
|
1858
|
-
}
|
|
1859
|
-
//#endregion
|
|
1860
|
-
//#region src/crud/context/InlineFormContext.tsx
|
|
1861
|
-
var jn = t(null), Mn = t([]);
|
|
1862
|
-
function Nn({ children: e, arrayName: t, layout: n = "tabular" }) {
|
|
1863
|
-
let [r, a] = l([]), o = i((e) => (a((t) => t.some((t) => t.key === e.key) ? t : [...t, e]), () => {
|
|
1864
|
-
a((t) => t.filter((t) => t.key !== e.key));
|
|
1865
|
-
}), []), c = s(() => ({
|
|
1866
|
-
arrayName: t,
|
|
1867
|
-
registerField: o,
|
|
1868
|
-
layout: n
|
|
1869
|
-
}), [
|
|
1870
|
-
t,
|
|
1871
|
-
o,
|
|
1872
|
-
n
|
|
1873
|
-
]);
|
|
1874
|
-
return /* @__PURE__ */ V(jn.Provider, {
|
|
1875
|
-
value: c,
|
|
1876
|
-
children: /* @__PURE__ */ V(Mn.Provider, {
|
|
1877
|
-
value: r,
|
|
1878
|
-
children: e
|
|
1879
|
-
})
|
|
1880
|
-
});
|
|
1881
|
-
}
|
|
1882
|
-
function Pn() {
|
|
1883
|
-
let e = a(jn), t = a(Mn);
|
|
1884
|
-
return e ? {
|
|
1885
|
-
...e,
|
|
1886
|
-
fields: t
|
|
1887
|
-
} : null;
|
|
1881
|
+
function Nn({ children: e }) {
|
|
1882
|
+
return /* @__PURE__ */ H(B, { children: [e, /* @__PURE__ */ V(Mn, {})] });
|
|
1888
1883
|
}
|
|
1889
1884
|
//#endregion
|
|
1890
1885
|
//#region src/crud/utils/inlineArrayName.ts
|
|
1891
|
-
function
|
|
1886
|
+
function Pn(e, t) {
|
|
1892
1887
|
return t ?? `__inline_${e.replace(/[^a-z0-9]/gi, "_")}`;
|
|
1893
1888
|
}
|
|
1894
1889
|
//#endregion
|
|
1890
|
+
//#region src/crud/utils/inlineFieldName.ts
|
|
1891
|
+
function Fn(e, t, n) {
|
|
1892
|
+
return `${e}.${t}.${n}`;
|
|
1893
|
+
}
|
|
1894
|
+
//#endregion
|
|
1895
1895
|
//#region src/crud/InlineFormSet.tsx
|
|
1896
1896
|
function In(e) {
|
|
1897
|
-
let t =
|
|
1897
|
+
let t = {};
|
|
1898
|
+
for (let n of e) t[n] = void 0;
|
|
1899
|
+
return t;
|
|
1900
|
+
}
|
|
1901
|
+
function Ln(e, t) {
|
|
1902
|
+
let { control: n } = G(), { fields: r, append: i, remove: a } = ve({
|
|
1898
1903
|
control: n,
|
|
1899
1904
|
name: e
|
|
1900
1905
|
});
|
|
1901
1906
|
return {
|
|
1902
|
-
ctx: t,
|
|
1903
1907
|
fields: r,
|
|
1904
1908
|
remove: a,
|
|
1905
|
-
appendEmpty: () =>
|
|
1906
|
-
if (!t) return;
|
|
1907
|
-
let e = {};
|
|
1908
|
-
for (let n of t.fields) e[n.source] = void 0;
|
|
1909
|
-
i(e);
|
|
1910
|
-
}
|
|
1909
|
+
appendEmpty: () => i(In(t))
|
|
1911
1910
|
};
|
|
1912
1911
|
}
|
|
1913
|
-
function
|
|
1914
|
-
let
|
|
1915
|
-
title:
|
|
1916
|
-
key:
|
|
1917
|
-
width:
|
|
1918
|
-
onHeaderCell: () =>
|
|
1919
|
-
onCell: () =>
|
|
1920
|
-
render: (n, r
|
|
1921
|
-
name:
|
|
1922
|
-
index:
|
|
1912
|
+
function Rn({ resource: e, label: t, name: n, columns: r }) {
|
|
1913
|
+
let i = Pn(e, n), { fields: a, remove: o, appendEmpty: c } = Ln(i, s(() => r.map((e) => e.source), [r])), l = s(() => r.map((e) => ({
|
|
1914
|
+
title: e.label ?? e.source,
|
|
1915
|
+
key: e.source,
|
|
1916
|
+
width: e.width,
|
|
1917
|
+
onHeaderCell: () => e.minWidth == null ? {} : { style: { minWidth: e.minWidth } },
|
|
1918
|
+
onCell: () => e.minWidth == null ? {} : { style: { minWidth: e.minWidth } },
|
|
1919
|
+
render: (t, n, r) => e.cell({
|
|
1920
|
+
name: Fn(i, r, e.source),
|
|
1921
|
+
index: r,
|
|
1922
|
+
arrayName: i
|
|
1923
1923
|
})
|
|
1924
|
-
}))
|
|
1925
|
-
return
|
|
1924
|
+
})), [r, i]);
|
|
1925
|
+
return /* @__PURE__ */ H("div", {
|
|
1926
1926
|
style: { marginTop: 24 },
|
|
1927
1927
|
children: [
|
|
1928
1928
|
/* @__PURE__ */ V(R.Title, {
|
|
@@ -1933,11 +1933,11 @@ function Ln({ arrayName: e, label: t }) {
|
|
|
1933
1933
|
size: "small",
|
|
1934
1934
|
pagination: !1,
|
|
1935
1935
|
scroll: { x: "max-content" },
|
|
1936
|
-
dataSource:
|
|
1936
|
+
dataSource: a.map((e) => ({
|
|
1937
1937
|
...e,
|
|
1938
1938
|
key: e.id
|
|
1939
1939
|
})),
|
|
1940
|
-
columns: [...
|
|
1940
|
+
columns: [...l, {
|
|
1941
1941
|
title: "",
|
|
1942
1942
|
key: "__remove",
|
|
1943
1943
|
width: 80,
|
|
@@ -1945,7 +1945,7 @@ function Ln({ arrayName: e, label: t }) {
|
|
|
1945
1945
|
type: "link",
|
|
1946
1946
|
danger: !0,
|
|
1947
1947
|
size: "small",
|
|
1948
|
-
onClick: () =>
|
|
1948
|
+
onClick: () => o(n),
|
|
1949
1949
|
children: "Remove"
|
|
1950
1950
|
})
|
|
1951
1951
|
}]
|
|
@@ -1953,59 +1953,49 @@ function Ln({ arrayName: e, label: t }) {
|
|
|
1953
1953
|
/* @__PURE__ */ V(x, {
|
|
1954
1954
|
type: "dashed",
|
|
1955
1955
|
style: { marginTop: 8 },
|
|
1956
|
-
onClick:
|
|
1956
|
+
onClick: c,
|
|
1957
1957
|
children: "Add row"
|
|
1958
1958
|
})
|
|
1959
1959
|
]
|
|
1960
|
-
})
|
|
1960
|
+
});
|
|
1961
1961
|
}
|
|
1962
|
-
function
|
|
1963
|
-
let
|
|
1964
|
-
return
|
|
1962
|
+
function zn({ resource: e, label: t, name: n, sources: r, renderRow: i }) {
|
|
1963
|
+
let a = Pn(e, n), { fields: o, remove: s, appendEmpty: c } = Ln(a, r);
|
|
1964
|
+
return /* @__PURE__ */ H("div", {
|
|
1965
1965
|
style: { marginTop: 24 },
|
|
1966
1966
|
children: [
|
|
1967
1967
|
/* @__PURE__ */ V(R.Title, {
|
|
1968
1968
|
level: 5,
|
|
1969
1969
|
children: t ?? "Related items"
|
|
1970
1970
|
}),
|
|
1971
|
-
/* @__PURE__ */ V(
|
|
1971
|
+
/* @__PURE__ */ V(I, {
|
|
1972
1972
|
orientation: "vertical",
|
|
1973
1973
|
size: "middle",
|
|
1974
1974
|
style: { width: "100%" },
|
|
1975
|
-
children:
|
|
1975
|
+
children: o.map((e, t) => /* @__PURE__ */ V(S, {
|
|
1976
1976
|
size: "small",
|
|
1977
|
-
title: `Item ${
|
|
1977
|
+
title: `Item ${t + 1}`,
|
|
1978
1978
|
extra: /* @__PURE__ */ V(x, {
|
|
1979
1979
|
type: "link",
|
|
1980
1980
|
danger: !0,
|
|
1981
1981
|
size: "small",
|
|
1982
|
-
onClick: () =>
|
|
1982
|
+
onClick: () => s(t),
|
|
1983
1983
|
children: "Remove"
|
|
1984
1984
|
}),
|
|
1985
|
-
children:
|
|
1986
|
-
|
|
1987
|
-
index:
|
|
1988
|
-
|
|
1989
|
-
|
|
1985
|
+
children: i({
|
|
1986
|
+
arrayName: a,
|
|
1987
|
+
index: t,
|
|
1988
|
+
name: (e) => Fn(a, t, e)
|
|
1989
|
+
})
|
|
1990
|
+
}, e.id))
|
|
1990
1991
|
}),
|
|
1991
1992
|
/* @__PURE__ */ V(x, {
|
|
1992
1993
|
type: "dashed",
|
|
1993
1994
|
style: { marginTop: 8 },
|
|
1994
|
-
onClick:
|
|
1995
|
+
onClick: c,
|
|
1995
1996
|
children: "Add item"
|
|
1996
1997
|
})
|
|
1997
1998
|
]
|
|
1998
|
-
}) : null;
|
|
1999
|
-
}
|
|
2000
|
-
function zn({ resource: e, label: t, children: n, name: r, layout: i = "tabular" }) {
|
|
2001
|
-
let a = Fn(e, r);
|
|
2002
|
-
return /* @__PURE__ */ H(Nn, {
|
|
2003
|
-
arrayName: a,
|
|
2004
|
-
layout: i,
|
|
2005
|
-
children: [n, V(i === "stacked" ? Rn : Ln, {
|
|
2006
|
-
arrayName: a,
|
|
2007
|
-
label: t
|
|
2008
|
-
})]
|
|
2009
1999
|
});
|
|
2010
2000
|
}
|
|
2011
2001
|
async function Bn(e, t) {
|
|
@@ -2047,120 +2037,158 @@ async function Vn(e, t, n, r) {
|
|
|
2047
2037
|
};
|
|
2048
2038
|
}
|
|
2049
2039
|
//#endregion
|
|
2050
|
-
//#region src/crud/
|
|
2040
|
+
//#region src/crud/utils/useResourceFormData.ts
|
|
2051
2041
|
function Hn(e) {
|
|
2052
|
-
return
|
|
2042
|
+
return Pn(e.resource, e.name);
|
|
2053
2043
|
}
|
|
2054
|
-
function Un({
|
|
2055
|
-
let
|
|
2056
|
-
if (
|
|
2057
|
-
s &&
|
|
2044
|
+
function Un({ dp: e, resource: t, id: n, isNew: r, form: a, message: o, defaultValues: s, inlines: c }) {
|
|
2045
|
+
let [u, d] = l(!r), [f, p] = l(0), [m, h] = l({}), g = i(async (i) => {
|
|
2046
|
+
if (r || !n) {
|
|
2047
|
+
s && a.reset({ ...s }), d(!1);
|
|
2058
2048
|
return;
|
|
2059
2049
|
}
|
|
2060
|
-
|
|
2050
|
+
d(!0);
|
|
2061
2051
|
try {
|
|
2062
|
-
let
|
|
2063
|
-
if (
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2052
|
+
let r = await e.getOne(t, n, { signal: i });
|
|
2053
|
+
if (i?.aborted) return;
|
|
2054
|
+
let o = r.data;
|
|
2055
|
+
if (c?.length) {
|
|
2056
|
+
let t = { ...o }, r = {};
|
|
2057
|
+
for (let i of c) {
|
|
2058
|
+
let a = Hn(i), { rows: o, ids: s } = await Vn(e, i.resource, i.foreignKey, n);
|
|
2059
|
+
t[a] = o, r[a] = s;
|
|
2068
2060
|
}
|
|
2069
|
-
|
|
2070
|
-
|
|
2061
|
+
if (i?.aborted) return;
|
|
2062
|
+
a.reset(t), h(r), p((e) => e + 1);
|
|
2063
|
+
} else a.reset(o), p((e) => e + 1);
|
|
2071
2064
|
} catch (e) {
|
|
2072
|
-
|
|
2065
|
+
vt(e) || o.error(e instanceof Error ? e.message : "Load failed");
|
|
2073
2066
|
} finally {
|
|
2074
|
-
|
|
2067
|
+
i?.aborted || d(!1);
|
|
2075
2068
|
}
|
|
2076
2069
|
}, [
|
|
2077
|
-
b,
|
|
2078
2070
|
e,
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2071
|
+
t,
|
|
2072
|
+
n,
|
|
2073
|
+
r,
|
|
2074
|
+
a,
|
|
2075
|
+
o,
|
|
2083
2076
|
s,
|
|
2084
|
-
|
|
2085
|
-
if (!p?.length) return;
|
|
2086
|
-
let t = {};
|
|
2087
|
-
for (let n of p) {
|
|
2088
|
-
let r = Hn(n), { rows: i, ids: a } = await Vn(b, n.resource, n.foreignKey, e);
|
|
2089
|
-
M.setValue(r, i), t[r] = a;
|
|
2090
|
-
}
|
|
2091
|
-
te(t);
|
|
2092
|
-
}, [
|
|
2093
|
-
b,
|
|
2094
|
-
p,
|
|
2095
|
-
M
|
|
2096
|
-
])
|
|
2097
|
-
]);
|
|
2098
|
-
o(() => {
|
|
2099
|
-
N();
|
|
2100
|
-
}, [N]), o(() => {
|
|
2101
|
-
m && (J(C, m, v ? "add" : "change") || w(r, { replace: !0 }));
|
|
2102
|
-
}, [
|
|
2103
|
-
m,
|
|
2104
|
-
v,
|
|
2105
|
-
C,
|
|
2106
|
-
w,
|
|
2107
|
-
r
|
|
2077
|
+
c
|
|
2108
2078
|
]);
|
|
2109
|
-
|
|
2110
|
-
|
|
2079
|
+
return yn((e) => g(e), [g]), {
|
|
2080
|
+
loading: u,
|
|
2081
|
+
formVersion: f,
|
|
2082
|
+
existingInlineIds: m
|
|
2083
|
+
};
|
|
2084
|
+
}
|
|
2085
|
+
function Wn({ dp: e, resource: t, id: n, isNew: r, form: a, message: o, navigate: s, listPath: c, submitFieldsRef: l, inlines: u, existingInlineIds: d, onSaved: f, stayOnPage: p }) {
|
|
2086
|
+
return i(async (i) => {
|
|
2111
2087
|
try {
|
|
2112
|
-
let
|
|
2113
|
-
if (
|
|
2114
|
-
let
|
|
2115
|
-
if (
|
|
2116
|
-
else if (
|
|
2117
|
-
id:
|
|
2118
|
-
data:
|
|
2119
|
-
})).data,
|
|
2088
|
+
let m = hn(i, Array.from(l.current));
|
|
2089
|
+
if (u?.length) for (let e of u) delete m[Hn(e)];
|
|
2090
|
+
let h;
|
|
2091
|
+
if (r) h = (await e.create(t, m)).data, o.success("Created");
|
|
2092
|
+
else if (n) h = (await e.update(t, {
|
|
2093
|
+
id: n,
|
|
2094
|
+
data: m
|
|
2095
|
+
})).data, o.success("Updated");
|
|
2120
2096
|
else return;
|
|
2121
|
-
let
|
|
2122
|
-
if (
|
|
2123
|
-
let
|
|
2124
|
-
if (!await Bn(
|
|
2125
|
-
resource:
|
|
2126
|
-
foreignKey:
|
|
2127
|
-
parentId:
|
|
2128
|
-
rows:
|
|
2129
|
-
existingIds:
|
|
2130
|
-
onRowError: (
|
|
2131
|
-
let
|
|
2132
|
-
return
|
|
2133
|
-
resource:
|
|
2134
|
-
mutation:
|
|
2135
|
-
inlineArrayName:
|
|
2136
|
-
rowIndex:
|
|
2097
|
+
let g = h.id;
|
|
2098
|
+
if (u?.length && g != null) for (let t of u) {
|
|
2099
|
+
let n = Hn(t), r = a.getValues(n) ?? [];
|
|
2100
|
+
if (!await Bn(e, {
|
|
2101
|
+
resource: t.resource,
|
|
2102
|
+
foreignKey: t.foreignKey,
|
|
2103
|
+
parentId: g,
|
|
2104
|
+
rows: r,
|
|
2105
|
+
existingIds: d[n] ?? [],
|
|
2106
|
+
onRowError: (i, s) => {
|
|
2107
|
+
let c = r[s]?.id;
|
|
2108
|
+
return vn(e, a, o, i, {
|
|
2109
|
+
resource: t.resource,
|
|
2110
|
+
mutation: c != null && (d[n] ?? []).some((e) => e === c) ? "update" : "create",
|
|
2111
|
+
inlineArrayName: n,
|
|
2112
|
+
rowIndex: s
|
|
2137
2113
|
});
|
|
2138
2114
|
}
|
|
2139
2115
|
})) return;
|
|
2140
2116
|
}
|
|
2141
|
-
|
|
2142
|
-
} catch (
|
|
2143
|
-
|
|
2144
|
-
resource:
|
|
2145
|
-
mutation:
|
|
2146
|
-
})
|
|
2117
|
+
f?.(h), p || s(c);
|
|
2118
|
+
} catch (n) {
|
|
2119
|
+
vn(e, a, o, n, {
|
|
2120
|
+
resource: t,
|
|
2121
|
+
mutation: r ? "create" : "update"
|
|
2122
|
+
}), o.error(n instanceof Error ? n.message : "Save failed");
|
|
2147
2123
|
}
|
|
2148
|
-
}
|
|
2124
|
+
}, [
|
|
2125
|
+
e,
|
|
2126
|
+
t,
|
|
2127
|
+
n,
|
|
2128
|
+
r,
|
|
2129
|
+
a,
|
|
2130
|
+
o,
|
|
2131
|
+
s,
|
|
2132
|
+
c,
|
|
2133
|
+
l,
|
|
2134
|
+
u,
|
|
2135
|
+
d,
|
|
2136
|
+
f,
|
|
2137
|
+
p
|
|
2138
|
+
]);
|
|
2139
|
+
}
|
|
2140
|
+
//#endregion
|
|
2141
|
+
//#region src/crud/ResourceForm.tsx
|
|
2142
|
+
function Gn({ resource: e, title: t, listPath: r, children: i, defaultValues: a, onSaved: s, stayOnPage: l, inlines: d, permissions: f }) {
|
|
2143
|
+
let { id: p } = _(), m = p === "new" || !p, h = mt(), v = q(), b = g(), { message: C } = y.useApp(), { token: w } = z.useToken(), ee = c(/* @__PURE__ */ new Set()), T = ye({ defaultValues: a }), { loading: E, formVersion: O, existingInlineIds: k } = Un({
|
|
2144
|
+
dp: h,
|
|
2145
|
+
resource: e,
|
|
2146
|
+
id: p,
|
|
2147
|
+
isNew: m,
|
|
2148
|
+
form: T,
|
|
2149
|
+
message: C,
|
|
2150
|
+
defaultValues: a,
|
|
2151
|
+
inlines: d
|
|
2152
|
+
}), A = Wn({
|
|
2153
|
+
dp: h,
|
|
2154
|
+
resource: e,
|
|
2155
|
+
id: p,
|
|
2156
|
+
isNew: m,
|
|
2157
|
+
form: T,
|
|
2158
|
+
message: C,
|
|
2159
|
+
navigate: b,
|
|
2160
|
+
listPath: r,
|
|
2161
|
+
submitFieldsRef: ee,
|
|
2162
|
+
inlines: d,
|
|
2163
|
+
existingInlineIds: k,
|
|
2164
|
+
onSaved: s,
|
|
2165
|
+
stayOnPage: l
|
|
2166
|
+
});
|
|
2167
|
+
o(() => {
|
|
2168
|
+
f && (J(v, f, m ? "add" : "change") || b(r, { replace: !0 }));
|
|
2169
|
+
}, [
|
|
2170
|
+
f,
|
|
2171
|
+
m,
|
|
2172
|
+
v,
|
|
2173
|
+
b,
|
|
2174
|
+
r
|
|
2175
|
+
]);
|
|
2176
|
+
let j = f ? J(v, f, m ? "add" : "change") : !0;
|
|
2149
2177
|
return /* @__PURE__ */ V(S, {
|
|
2150
|
-
title: /* @__PURE__ */ H(
|
|
2178
|
+
title: /* @__PURE__ */ H(I, { children: [/* @__PURE__ */ H(u, {
|
|
2151
2179
|
to: r,
|
|
2152
|
-
style: { color:
|
|
2180
|
+
style: { color: w.colorText },
|
|
2153
2181
|
children: [/* @__PURE__ */ V(U, {}), " Back"]
|
|
2154
2182
|
}), /* @__PURE__ */ V(R.Title, {
|
|
2155
2183
|
level: 5,
|
|
2156
2184
|
style: { margin: 0 },
|
|
2157
2185
|
children: t
|
|
2158
2186
|
})] }),
|
|
2159
|
-
children: /* @__PURE__ */ V(
|
|
2187
|
+
children: /* @__PURE__ */ V(nn, {
|
|
2160
2188
|
resource: e,
|
|
2161
|
-
isNew:
|
|
2162
|
-
children: /* @__PURE__ */ V(
|
|
2163
|
-
|
|
2189
|
+
isNew: m,
|
|
2190
|
+
children: /* @__PURE__ */ V(ln, {
|
|
2191
|
+
fieldsRef: ee,
|
|
2164
2192
|
children: /* @__PURE__ */ H("div", {
|
|
2165
2193
|
style: { position: "relative" },
|
|
2166
2194
|
children: [E ? /* @__PURE__ */ V("div", {
|
|
@@ -2172,23 +2200,23 @@ function Un({ resource: e, title: t, listPath: r, children: a, defaultValues: s,
|
|
|
2172
2200
|
justifyContent: "center",
|
|
2173
2201
|
zIndex: 1
|
|
2174
2202
|
},
|
|
2175
|
-
children: /* @__PURE__ */ V(
|
|
2203
|
+
children: /* @__PURE__ */ V(L, {})
|
|
2176
2204
|
}) : null, /* @__PURE__ */ n(_e, {
|
|
2177
|
-
...
|
|
2178
|
-
key:
|
|
2205
|
+
...T,
|
|
2206
|
+
key: O
|
|
2179
2207
|
}, /* @__PURE__ */ H(D, {
|
|
2180
2208
|
layout: "vertical",
|
|
2181
|
-
onFinish: () => void
|
|
2209
|
+
onFinish: () => void T.handleSubmit(A)(),
|
|
2182
2210
|
style: {
|
|
2183
2211
|
opacity: E ? .4 : 1,
|
|
2184
2212
|
pointerEvents: E ? "none" : void 0
|
|
2185
2213
|
},
|
|
2186
|
-
children: [
|
|
2214
|
+
children: [i, /* @__PURE__ */ V(D.Item, {
|
|
2187
2215
|
style: { marginTop: 16 },
|
|
2188
|
-
children: /* @__PURE__ */ H(
|
|
2216
|
+
children: /* @__PURE__ */ H(I, { children: [/* @__PURE__ */ V(x, {
|
|
2189
2217
|
type: "primary",
|
|
2190
2218
|
htmlType: "submit",
|
|
2191
|
-
disabled: E || !
|
|
2219
|
+
disabled: E || !j,
|
|
2192
2220
|
children: "Save"
|
|
2193
2221
|
}), /* @__PURE__ */ V(u, {
|
|
2194
2222
|
to: r,
|
|
@@ -2206,22 +2234,22 @@ function Un({ resource: e, title: t, listPath: r, children: a, defaultValues: s,
|
|
|
2206
2234
|
}
|
|
2207
2235
|
//#endregion
|
|
2208
2236
|
//#region src/crud/utils/formSectionErrors.ts
|
|
2209
|
-
function
|
|
2237
|
+
function Kn(e, t, n) {
|
|
2210
2238
|
for (let r of e) if (t(r, n).invalid) return !0;
|
|
2211
2239
|
return !1;
|
|
2212
2240
|
}
|
|
2213
|
-
function
|
|
2241
|
+
function qn(e) {
|
|
2214
2242
|
let t = c([]);
|
|
2215
2243
|
for (; t.current.length < e;) t.current.push({ current: /* @__PURE__ */ new Set() });
|
|
2216
2244
|
return t.current.length > e && (t.current.length = e), t.current;
|
|
2217
2245
|
}
|
|
2218
|
-
function
|
|
2246
|
+
function Jn(e, t) {
|
|
2219
2247
|
let { control: n, getFieldState: r, setFocus: i } = G(), a = K({ control: n }), s = c(0), l = c(0);
|
|
2220
2248
|
o(() => {
|
|
2221
2249
|
if (a.submitCount === 0) return;
|
|
2222
2250
|
let n = Object.keys(a.errors).length, o = a.submitCount !== s.current, c = !o && n > 0 && l.current === 0;
|
|
2223
2251
|
if (s.current = a.submitCount, l.current = n, !o && !c || n === 0) return;
|
|
2224
|
-
let u = e.findIndex((e) =>
|
|
2252
|
+
let u = e.findIndex((e) => Kn(e.current, r, a));
|
|
2225
2253
|
if (u < 0) return;
|
|
2226
2254
|
t(u);
|
|
2227
2255
|
let d = [...e[u].current].find((e) => r(e, a).invalid);
|
|
@@ -2240,22 +2268,22 @@ function Kn(e, t) {
|
|
|
2240
2268
|
}
|
|
2241
2269
|
//#endregion
|
|
2242
2270
|
//#region src/crud/FormTabs.tsx
|
|
2243
|
-
function
|
|
2271
|
+
function Yn(e) {
|
|
2244
2272
|
return null;
|
|
2245
2273
|
}
|
|
2246
|
-
function
|
|
2247
|
-
return r(e) && e.type ===
|
|
2274
|
+
function Xn(e) {
|
|
2275
|
+
return r(e) && e.type === Yn;
|
|
2248
2276
|
}
|
|
2249
|
-
function
|
|
2250
|
-
let { token: c } = z.useToken(), u = s(() => e.toArray(t).filter(
|
|
2277
|
+
function Zn({ children: t, defaultActiveKey: n, activeKey: r, onChange: a, ...o }) {
|
|
2278
|
+
let { token: c } = z.useToken(), u = s(() => e.toArray(t).filter(Xn).map((e, t) => ({
|
|
2251
2279
|
key: e.key ?? String(t),
|
|
2252
2280
|
label: e.props.label,
|
|
2253
2281
|
disabled: e.props.disabled,
|
|
2254
2282
|
children: e.props.children
|
|
2255
|
-
})), [t]), d =
|
|
2283
|
+
})), [t]), d = qn(u.length), f = r !== void 0, [p, m] = l(() => n ?? u[0]?.key ?? "0"), h = f ? r : p, g = i((e) => {
|
|
2256
2284
|
f || m(e), a?.(e);
|
|
2257
2285
|
}, [f, a]);
|
|
2258
|
-
|
|
2286
|
+
Jn(d, i((e) => {
|
|
2259
2287
|
let t = u[e]?.key;
|
|
2260
2288
|
t != null && g(t);
|
|
2261
2289
|
}, [g, u]));
|
|
@@ -2263,7 +2291,7 @@ function Yn({ children: t, defaultActiveKey: n, activeKey: r, onChange: a, ...o
|
|
|
2263
2291
|
return /* @__PURE__ */ V(ae, {
|
|
2264
2292
|
destroyOnHidden: !1,
|
|
2265
2293
|
items: s(() => u.map((e, t) => {
|
|
2266
|
-
let n =
|
|
2294
|
+
let n = Kn(d[t].current, v, y);
|
|
2267
2295
|
return {
|
|
2268
2296
|
key: e.key,
|
|
2269
2297
|
label: n ? /* @__PURE__ */ V("span", {
|
|
@@ -2271,7 +2299,7 @@ function Yn({ children: t, defaultActiveKey: n, activeKey: r, onChange: a, ...o
|
|
|
2271
2299
|
children: e.label
|
|
2272
2300
|
}) : e.label,
|
|
2273
2301
|
disabled: e.disabled,
|
|
2274
|
-
children: /* @__PURE__ */ V(
|
|
2302
|
+
children: /* @__PURE__ */ V(on, {
|
|
2275
2303
|
sourcesRef: d[t],
|
|
2276
2304
|
children: e.children
|
|
2277
2305
|
})
|
|
@@ -2290,17 +2318,17 @@ function Yn({ children: t, defaultActiveKey: n, activeKey: r, onChange: a, ...o
|
|
|
2290
2318
|
}
|
|
2291
2319
|
//#endregion
|
|
2292
2320
|
//#region src/crud/FormSteps.tsx
|
|
2293
|
-
function
|
|
2321
|
+
function Qn(e) {
|
|
2294
2322
|
return null;
|
|
2295
2323
|
}
|
|
2296
|
-
function
|
|
2297
|
-
return r(e) && e.type ===
|
|
2324
|
+
function $n(e) {
|
|
2325
|
+
return r(e) && e.type === Qn;
|
|
2298
2326
|
}
|
|
2299
|
-
function
|
|
2300
|
-
let m = s(() => e.toArray(t).filter(
|
|
2301
|
-
|
|
2327
|
+
function er({ children: t, initialStep: n = 0, showNavigation: r = !0, allowStepSelect: a = !1, stepsStyle: o, navigationStyle: c, size: u, direction: d, type: f, status: p }) {
|
|
2328
|
+
let m = s(() => e.toArray(t).filter($n), [t]), h = qn(m.length), [g, _] = l(n), v = m.length - 1;
|
|
2329
|
+
Jn(h, _);
|
|
2302
2330
|
let { control: y, getFieldState: b } = G(), S = K({ control: y }), C = s(() => m.map((e, t) => {
|
|
2303
|
-
let n =
|
|
2331
|
+
let n = Kn(h[t].current, b, S);
|
|
2304
2332
|
return {
|
|
2305
2333
|
title: e.props.title,
|
|
2306
2334
|
description: e.props.description,
|
|
@@ -2315,7 +2343,7 @@ function Qn({ children: t, initialStep: n = 0, showNavigation: r = !0, allowStep
|
|
|
2315
2343
|
_(e);
|
|
2316
2344
|
}, []);
|
|
2317
2345
|
return /* @__PURE__ */ H(B, { children: [
|
|
2318
|
-
/* @__PURE__ */ V(
|
|
2346
|
+
/* @__PURE__ */ V(ne, {
|
|
2319
2347
|
current: g,
|
|
2320
2348
|
items: C,
|
|
2321
2349
|
style: {
|
|
@@ -2330,12 +2358,12 @@ function Qn({ children: t, initialStep: n = 0, showNavigation: r = !0, allowStep
|
|
|
2330
2358
|
}),
|
|
2331
2359
|
m.map((e, t) => /* @__PURE__ */ V("div", {
|
|
2332
2360
|
style: { display: g === t ? void 0 : "none" },
|
|
2333
|
-
children: /* @__PURE__ */ V(
|
|
2361
|
+
children: /* @__PURE__ */ V(on, {
|
|
2334
2362
|
sourcesRef: h[t],
|
|
2335
2363
|
children: e.props.children
|
|
2336
2364
|
})
|
|
2337
2365
|
}, e.key ?? String(t))),
|
|
2338
|
-
r && m.length > 1 ? /* @__PURE__ */ H(
|
|
2366
|
+
r && m.length > 1 ? /* @__PURE__ */ H(I, {
|
|
2339
2367
|
style: {
|
|
2340
2368
|
marginTop: 16,
|
|
2341
2369
|
...c
|
|
@@ -2355,183 +2383,131 @@ function Qn({ children: t, initialStep: n = 0, showNavigation: r = !0, allowStep
|
|
|
2355
2383
|
}
|
|
2356
2384
|
//#endregion
|
|
2357
2385
|
//#region src/crud/fields/FieldWrapper.tsx
|
|
2358
|
-
function
|
|
2359
|
-
let { control:
|
|
2360
|
-
return
|
|
2361
|
-
name:
|
|
2362
|
-
control:
|
|
2386
|
+
function Q({ source: e, name: t, label: n, required: r, rules: i, hideLabel: a, children: o }) {
|
|
2387
|
+
let s = t ?? e, c = !s.includes("."), { control: l } = G(), u = rn(), d = a ? void 0 : n ?? e, f = n ?? e;
|
|
2388
|
+
return dn(e, c), fn(e, c), /* @__PURE__ */ V(ge, {
|
|
2389
|
+
name: s,
|
|
2390
|
+
control: l,
|
|
2363
2391
|
rules: {
|
|
2364
|
-
required:
|
|
2365
|
-
...
|
|
2392
|
+
required: r ? `${f} is required` : !1,
|
|
2393
|
+
...i
|
|
2366
2394
|
},
|
|
2367
2395
|
render: ({ field: e, fieldState: t }) => /* @__PURE__ */ V(D.Item, {
|
|
2368
|
-
label:
|
|
2396
|
+
label: d,
|
|
2369
2397
|
validateStatus: t.error ? "error" : void 0,
|
|
2370
2398
|
help: t.error?.message,
|
|
2371
|
-
required:
|
|
2372
|
-
|
|
2399
|
+
required: r && !a,
|
|
2400
|
+
style: a ? { marginBottom: 0 } : void 0,
|
|
2401
|
+
children: o({
|
|
2373
2402
|
value: e.value,
|
|
2374
2403
|
onChange: e.onChange,
|
|
2375
2404
|
onBlur: e.onBlur,
|
|
2376
|
-
disabled:
|
|
2377
|
-
|
|
2378
|
-
})
|
|
2379
|
-
});
|
|
2380
|
-
}
|
|
2381
|
-
function er({ name: e, label: t, required: n, rules: r, hideLabel: i, children: a }) {
|
|
2382
|
-
let { control: o } = G(), s = i ? void 0 : t;
|
|
2383
|
-
return /* @__PURE__ */ V(ge, {
|
|
2384
|
-
name: e,
|
|
2385
|
-
control: o,
|
|
2386
|
-
rules: {
|
|
2387
|
-
required: n ? `${t ?? "This field"} is required` : !1,
|
|
2388
|
-
...r
|
|
2389
|
-
},
|
|
2390
|
-
render: ({ field: e, fieldState: t }) => /* @__PURE__ */ V(D.Item, {
|
|
2391
|
-
label: s,
|
|
2392
|
-
validateStatus: t.error ? "error" : void 0,
|
|
2393
|
-
help: t.error?.message,
|
|
2394
|
-
required: n && !i,
|
|
2395
|
-
style: { marginBottom: 0 },
|
|
2396
|
-
children: a({
|
|
2397
|
-
value: e.value,
|
|
2398
|
-
onChange: e.onChange,
|
|
2399
|
-
onBlur: e.onBlur
|
|
2405
|
+
disabled: u?.disabled,
|
|
2406
|
+
name: s
|
|
2400
2407
|
})
|
|
2401
2408
|
})
|
|
2402
2409
|
});
|
|
2403
2410
|
}
|
|
2404
2411
|
//#endregion
|
|
2405
|
-
//#region src/crud/fields/
|
|
2406
|
-
function
|
|
2407
|
-
|
|
2408
|
-
f.current = i;
|
|
2409
|
-
let p = s(() => u ? {
|
|
2410
|
-
key: e,
|
|
2412
|
+
//#region src/crud/fields/TextField.tsx
|
|
2413
|
+
function tr({ source: e, name: t, label: n, required: r, rules: i, placeholder: a, inputStyle: o, hideLabel: s }) {
|
|
2414
|
+
return /* @__PURE__ */ V(Q, {
|
|
2411
2415
|
source: e,
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
onBlur: r,
|
|
2425
|
-
name: e,
|
|
2426
|
-
index: i
|
|
2427
|
-
})
|
|
2428
|
-
})
|
|
2429
|
-
} : null, [
|
|
2430
|
-
u,
|
|
2431
|
-
e,
|
|
2432
|
-
t,
|
|
2433
|
-
n,
|
|
2434
|
-
r,
|
|
2435
|
-
l?.layout,
|
|
2436
|
-
a?.width,
|
|
2437
|
-
a?.minWidth
|
|
2438
|
-
]), m = c(p);
|
|
2439
|
-
return m.current = p, o(() => {
|
|
2440
|
-
if (!u) return;
|
|
2441
|
-
let e = m.current;
|
|
2442
|
-
if (e) return u(e);
|
|
2443
|
-
}, [u, e]), d ? { mode: "inline" } : {
|
|
2444
|
-
mode: "form",
|
|
2445
|
-
element: /* @__PURE__ */ V($n, {
|
|
2446
|
-
source: e,
|
|
2447
|
-
label: t,
|
|
2448
|
-
required: n,
|
|
2449
|
-
rules: r,
|
|
2450
|
-
children: ({ value: e, onChange: t, onBlur: n, disabled: r }) => i({
|
|
2451
|
-
value: e,
|
|
2452
|
-
onChange: t,
|
|
2453
|
-
onBlur: n,
|
|
2454
|
-
disabled: r
|
|
2455
|
-
})
|
|
2416
|
+
name: t,
|
|
2417
|
+
label: n,
|
|
2418
|
+
required: r,
|
|
2419
|
+
rules: i,
|
|
2420
|
+
hideLabel: s,
|
|
2421
|
+
children: ({ value: e, onChange: t, onBlur: n, disabled: r }) => /* @__PURE__ */ V(k, {
|
|
2422
|
+
value: e,
|
|
2423
|
+
onChange: (e) => t(e.target.value),
|
|
2424
|
+
onBlur: n,
|
|
2425
|
+
placeholder: a,
|
|
2426
|
+
disabled: r,
|
|
2427
|
+
style: o
|
|
2456
2428
|
})
|
|
2457
|
-
};
|
|
2458
|
-
}
|
|
2459
|
-
//#endregion
|
|
2460
|
-
//#region src/crud/fields/TextField.tsx
|
|
2461
|
-
function tr({ source: e, label: t, required: n, rules: r, placeholder: i, width: a, minWidth: o, inputStyle: s }) {
|
|
2462
|
-
let c = Q(e, t, n, r, ({ value: e, onChange: t, onBlur: n, disabled: r }) => /* @__PURE__ */ V(k, {
|
|
2463
|
-
value: e,
|
|
2464
|
-
onChange: (e) => t(e.target.value),
|
|
2465
|
-
onBlur: n,
|
|
2466
|
-
placeholder: i,
|
|
2467
|
-
disabled: r,
|
|
2468
|
-
style: s
|
|
2469
|
-
}), {
|
|
2470
|
-
width: a,
|
|
2471
|
-
minWidth: o
|
|
2472
2429
|
});
|
|
2473
|
-
return c.mode === "inline" ? null : c.element;
|
|
2474
2430
|
}
|
|
2475
2431
|
//#endregion
|
|
2476
2432
|
//#region src/crud/fields/NumberField.tsx
|
|
2477
|
-
function nr({ source: e,
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
disabled: r,
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2433
|
+
function nr({ source: e, name: t, label: n, required: r, rules: i, min: a, max: o, step: s, inputStyle: c, hideLabel: l }) {
|
|
2434
|
+
return /* @__PURE__ */ V(Q, {
|
|
2435
|
+
source: e,
|
|
2436
|
+
name: t,
|
|
2437
|
+
label: n,
|
|
2438
|
+
required: r,
|
|
2439
|
+
rules: i,
|
|
2440
|
+
hideLabel: l,
|
|
2441
|
+
children: ({ value: e, onChange: t, onBlur: n, disabled: r }) => /* @__PURE__ */ V(A, {
|
|
2442
|
+
value: e,
|
|
2443
|
+
onChange: (e) => t(e),
|
|
2444
|
+
onBlur: n,
|
|
2445
|
+
min: a,
|
|
2446
|
+
max: o,
|
|
2447
|
+
step: s,
|
|
2448
|
+
disabled: r,
|
|
2449
|
+
style: {
|
|
2450
|
+
width: "100%",
|
|
2451
|
+
...c
|
|
2452
|
+
}
|
|
2453
|
+
})
|
|
2493
2454
|
});
|
|
2494
|
-
return u.mode === "inline" ? null : u.element;
|
|
2495
2455
|
}
|
|
2496
2456
|
//#endregion
|
|
2497
2457
|
//#region src/crud/fields/BooleanField.tsx
|
|
2498
|
-
function rr({ source: e,
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2458
|
+
function rr({ source: e, name: t, label: n, required: r, rules: i, hideLabel: a }) {
|
|
2459
|
+
return /* @__PURE__ */ V(Q, {
|
|
2460
|
+
source: e,
|
|
2461
|
+
name: t,
|
|
2462
|
+
label: n,
|
|
2463
|
+
required: r,
|
|
2464
|
+
rules: i,
|
|
2465
|
+
hideLabel: a,
|
|
2466
|
+
children: ({ value: e, onChange: t, disabled: n }) => /* @__PURE__ */ V(re, {
|
|
2467
|
+
checked: !!e,
|
|
2468
|
+
onChange: t,
|
|
2469
|
+
disabled: n
|
|
2470
|
+
})
|
|
2471
|
+
});
|
|
2505
2472
|
}
|
|
2506
2473
|
//#endregion
|
|
2507
2474
|
//#region src/crud/fields/DateField.tsx
|
|
2508
2475
|
var ir = "YYYY-MM-DD";
|
|
2509
|
-
function ar({ source: e,
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2476
|
+
function ar({ source: e, name: t, label: n, required: r, rules: i, showTime: a, hideLabel: o }) {
|
|
2477
|
+
return /* @__PURE__ */ V(Q, {
|
|
2478
|
+
source: e,
|
|
2479
|
+
name: t,
|
|
2480
|
+
label: n,
|
|
2481
|
+
required: r,
|
|
2482
|
+
rules: i,
|
|
2483
|
+
hideLabel: o,
|
|
2484
|
+
children: ({ value: e, onChange: t, onBlur: n, disabled: r }) => /* @__PURE__ */ V(w, {
|
|
2485
|
+
value: e ? xe(String(e)) : null,
|
|
2486
|
+
onChange: (e) => t(e ? e.format(a ? `${ir} HH:mm:ss` : ir) : null),
|
|
2487
|
+
onBlur: n,
|
|
2488
|
+
showTime: a,
|
|
2489
|
+
disabled: r,
|
|
2490
|
+
format: a ? `${ir} HH:mm:ss` : ir,
|
|
2491
|
+
style: { width: "100%" }
|
|
2492
|
+
})
|
|
2493
|
+
});
|
|
2520
2494
|
}
|
|
2521
2495
|
//#endregion
|
|
2522
2496
|
//#region src/crud/fields/SelectField.tsx
|
|
2523
|
-
function or({ source: e,
|
|
2524
|
-
return /* @__PURE__ */ V(
|
|
2497
|
+
function or({ source: e, name: t, label: n, required: r, rules: i, choices: a, mode: o, allowClear: s, hideLabel: c }) {
|
|
2498
|
+
return /* @__PURE__ */ V(Q, {
|
|
2525
2499
|
source: e,
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2500
|
+
name: t,
|
|
2501
|
+
label: n,
|
|
2502
|
+
required: r,
|
|
2503
|
+
rules: i,
|
|
2504
|
+
hideLabel: c,
|
|
2505
|
+
children: ({ value: e, onChange: t, disabled: n }) => /* @__PURE__ */ V(F, {
|
|
2530
2506
|
value: e,
|
|
2531
2507
|
onChange: t,
|
|
2532
|
-
options:
|
|
2533
|
-
mode:
|
|
2534
|
-
allowClear:
|
|
2508
|
+
options: a,
|
|
2509
|
+
mode: o,
|
|
2510
|
+
allowClear: s,
|
|
2535
2511
|
disabled: n,
|
|
2536
2512
|
style: { width: "100%" }
|
|
2537
2513
|
})
|
|
@@ -2539,48 +2515,51 @@ function or({ source: e, label: t, required: n, rules: r, choices: i, mode: a, a
|
|
|
2539
2515
|
}
|
|
2540
2516
|
//#endregion
|
|
2541
2517
|
//#region src/crud/fields/PasswordField.tsx
|
|
2542
|
-
function sr({ source: e,
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2518
|
+
function sr({ source: e, name: t, label: n, required: r, rules: i, autoComplete: a, hideLabel: o }) {
|
|
2519
|
+
return /* @__PURE__ */ V(Q, {
|
|
2520
|
+
source: e,
|
|
2521
|
+
name: t,
|
|
2522
|
+
label: n,
|
|
2523
|
+
required: r,
|
|
2524
|
+
rules: i,
|
|
2525
|
+
hideLabel: o,
|
|
2526
|
+
children: ({ value: e, onChange: t, onBlur: n, disabled: r }) => /* @__PURE__ */ V(k.Password, {
|
|
2527
|
+
value: e,
|
|
2528
|
+
onChange: (e) => t(e.target.value),
|
|
2529
|
+
onBlur: n,
|
|
2530
|
+
disabled: r,
|
|
2531
|
+
autoComplete: a
|
|
2532
|
+
})
|
|
2552
2533
|
});
|
|
2553
|
-
return s.mode === "inline" ? null : s.element;
|
|
2554
2534
|
}
|
|
2555
|
-
function cr({ source: e,
|
|
2535
|
+
function cr({ source: e, name: t, label: n, required: r, rules: i, confirmSource: a, confirmLabel: o = "Confirm password", autoComplete: s = "new-password", hideLabel: c }) {
|
|
2556
2536
|
let l = be({
|
|
2557
|
-
name: e,
|
|
2558
|
-
disabled: !
|
|
2537
|
+
name: t ?? e,
|
|
2538
|
+
disabled: !a
|
|
2559
2539
|
});
|
|
2560
|
-
return
|
|
2540
|
+
return a ? /* @__PURE__ */ H(B, { children: [/* @__PURE__ */ V(sr, {
|
|
2561
2541
|
source: e,
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2542
|
+
name: t,
|
|
2543
|
+
label: n,
|
|
2544
|
+
required: r,
|
|
2545
|
+
rules: i,
|
|
2546
|
+
autoComplete: s,
|
|
2547
|
+
hideLabel: c
|
|
2568
2548
|
}), /* @__PURE__ */ V(sr, {
|
|
2569
|
-
source:
|
|
2570
|
-
label:
|
|
2571
|
-
required:
|
|
2572
|
-
autoComplete:
|
|
2573
|
-
|
|
2574
|
-
minWidth: c,
|
|
2549
|
+
source: a,
|
|
2550
|
+
label: o,
|
|
2551
|
+
required: r,
|
|
2552
|
+
autoComplete: s,
|
|
2553
|
+
hideLabel: c,
|
|
2575
2554
|
rules: { validate: (e) => !l || e === l || "Passwords do not match" }
|
|
2576
2555
|
})] }) : /* @__PURE__ */ V(sr, {
|
|
2577
2556
|
source: e,
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2557
|
+
name: t,
|
|
2558
|
+
label: n,
|
|
2559
|
+
required: r,
|
|
2560
|
+
rules: i,
|
|
2561
|
+
autoComplete: s,
|
|
2562
|
+
hideLabel: c
|
|
2584
2563
|
});
|
|
2585
2564
|
}
|
|
2586
2565
|
//#endregion
|
|
@@ -2672,58 +2651,68 @@ function $(e, t, n = "name", r = "id", a) {
|
|
|
2672
2651
|
}
|
|
2673
2652
|
//#endregion
|
|
2674
2653
|
//#region src/crud/fields/ReferenceField.tsx
|
|
2675
|
-
function hr({ source: e,
|
|
2676
|
-
let [_, v] = l(), { options: y, loading: b, optionForValue: x } = $(
|
|
2654
|
+
function hr({ source: e, name: t, label: n, reference: r, choices: i, optionLabel: a = "name", optionValue: o = "id", required: c, rules: u, search: d, allowClear: f, disabled: p, hideLabel: m, inputStyle: h, onValueChange: g }) {
|
|
2655
|
+
let [_, v] = l(), { options: y, loading: b, optionForValue: x } = $(i, r, a, o, d ? _ : void 0), S = s(() => y.map((e) => ({
|
|
2677
2656
|
label: e.label,
|
|
2678
2657
|
value: e.value
|
|
2679
|
-
})), [y])
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2658
|
+
})), [y]);
|
|
2659
|
+
return /* @__PURE__ */ V(Q, {
|
|
2660
|
+
source: e,
|
|
2661
|
+
name: t,
|
|
2662
|
+
label: n,
|
|
2663
|
+
required: c,
|
|
2664
|
+
rules: u,
|
|
2665
|
+
hideLabel: m,
|
|
2666
|
+
children: ({ value: e, onChange: t, disabled: n, name: r }) => /* @__PURE__ */ V(F, {
|
|
2667
|
+
value: e,
|
|
2668
|
+
onChange: (e) => {
|
|
2669
|
+
t(e), g?.(e, x(e), { name: r });
|
|
2670
|
+
},
|
|
2671
|
+
options: S,
|
|
2672
|
+
loading: b && y.length === 0,
|
|
2673
|
+
showSearch: d,
|
|
2674
|
+
filterOption: d ? !1 : void 0,
|
|
2675
|
+
onSearch: d ? v : void 0,
|
|
2676
|
+
allowClear: f,
|
|
2677
|
+
disabled: n || p,
|
|
2678
|
+
optionFilterProp: "label",
|
|
2679
|
+
style: {
|
|
2680
|
+
width: "100%",
|
|
2681
|
+
minWidth: 160,
|
|
2682
|
+
...h
|
|
2683
|
+
}
|
|
2684
|
+
})
|
|
2703
2685
|
});
|
|
2704
|
-
return C.mode === "inline" ? null : C.element;
|
|
2705
2686
|
}
|
|
2706
2687
|
//#endregion
|
|
2707
2688
|
//#region src/crud/fields/ReferenceManyField.tsx
|
|
2708
|
-
function gr({ source: e,
|
|
2709
|
-
let [
|
|
2689
|
+
function gr({ source: e, name: t, label: n, reference: r, choices: i, optionLabel: a = "name", optionValue: o = "id", required: c, rules: u, search: d, allowClear: f = !0, hideLabel: p }) {
|
|
2690
|
+
let [m, h] = l(), { options: g, loading: _ } = $(i, r, a, o, d ? m : void 0), v = s(() => g.map((e) => ({
|
|
2710
2691
|
label: e.label,
|
|
2711
2692
|
value: e.value
|
|
2712
|
-
})), [
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2693
|
+
})), [g]);
|
|
2694
|
+
return /* @__PURE__ */ V(Q, {
|
|
2695
|
+
source: e,
|
|
2696
|
+
name: t,
|
|
2697
|
+
label: n,
|
|
2698
|
+
required: c,
|
|
2699
|
+
rules: u,
|
|
2700
|
+
hideLabel: p,
|
|
2701
|
+
children: ({ value: e, onChange: t, disabled: n }) => /* @__PURE__ */ V(F, {
|
|
2702
|
+
mode: "multiple",
|
|
2703
|
+
value: e ?? [],
|
|
2704
|
+
onChange: t,
|
|
2705
|
+
options: v,
|
|
2706
|
+
loading: _,
|
|
2707
|
+
showSearch: d,
|
|
2708
|
+
filterOption: d ? !1 : void 0,
|
|
2709
|
+
onSearch: d ? h : void 0,
|
|
2710
|
+
allowClear: f,
|
|
2711
|
+
disabled: n,
|
|
2712
|
+
optionFilterProp: "label",
|
|
2713
|
+
style: { width: "100%" }
|
|
2714
|
+
})
|
|
2715
|
+
});
|
|
2727
2716
|
}
|
|
2728
2717
|
//#endregion
|
|
2729
2718
|
//#region src/crud/columns/TextColumn.tsx
|
|
@@ -2746,7 +2735,7 @@ function _r({ source: e, label: t, sortable: n = !0 }) {
|
|
|
2746
2735
|
])), null;
|
|
2747
2736
|
}
|
|
2748
2737
|
function vr(e, t, n) {
|
|
2749
|
-
return typeof n == "function" ? n(e) : n ?
|
|
2738
|
+
return typeof n == "function" ? n(e) : n ? pn(e, n) : e[t];
|
|
2750
2739
|
}
|
|
2751
2740
|
//#endregion
|
|
2752
2741
|
//#region src/crud/columns/NumberColumn.tsx
|
|
@@ -2952,7 +2941,7 @@ function kr({ source: e, label: t }) {
|
|
|
2952
2941
|
key: e,
|
|
2953
2942
|
source: e,
|
|
2954
2943
|
label: t,
|
|
2955
|
-
render: ({ value: n, onChange: r }) => /* @__PURE__ */ V(
|
|
2944
|
+
render: ({ value: n, onChange: r }) => /* @__PURE__ */ V(F, {
|
|
2956
2945
|
allowClear: !0,
|
|
2957
2946
|
placeholder: t ?? e,
|
|
2958
2947
|
value: n,
|
|
@@ -2991,7 +2980,7 @@ function jr({ source: e, label: t, choices: n, multiple: r }) {
|
|
|
2991
2980
|
key: e,
|
|
2992
2981
|
source: e,
|
|
2993
2982
|
label: t,
|
|
2994
|
-
render: ({ value: i, onChange: a }) => /* @__PURE__ */ V(
|
|
2983
|
+
render: ({ value: i, onChange: a }) => /* @__PURE__ */ V(F, {
|
|
2995
2984
|
allowClear: !0,
|
|
2996
2985
|
mode: r ? "multiple" : void 0,
|
|
2997
2986
|
placeholder: t ?? e,
|
|
@@ -3011,7 +3000,7 @@ function jr({ source: e, label: t, choices: n, multiple: r }) {
|
|
|
3011
3000
|
//#region src/crud/filters/ReferenceFilter.tsx
|
|
3012
3001
|
function Mr({ source: e, label: t, reference: n, choices: r, optionLabel: i, optionValue: a, multiple: o, search: s, value: c, onChange: u }) {
|
|
3013
3002
|
let [d, f] = l(), { options: p, loading: m } = $(r, n, i, a, s ? d : void 0);
|
|
3014
|
-
return /* @__PURE__ */ V(
|
|
3003
|
+
return /* @__PURE__ */ V(F, {
|
|
3015
3004
|
allowClear: !0,
|
|
3016
3005
|
mode: o ? "multiple" : void 0,
|
|
3017
3006
|
placeholder: t ?? e,
|
|
@@ -3064,4 +3053,4 @@ function Pr(e) {
|
|
|
3064
3053
|
});
|
|
3065
3054
|
}
|
|
3066
3055
|
//#endregion
|
|
3067
|
-
export { dt as AdminApp, $e as AdminLayout, Oe as AppThemeProvider,
|
|
3056
|
+
export { dt as AdminApp, $e as AdminLayout, Oe as AppThemeProvider, Ht as AuthAlternateLink, Ut as AuthPageLayout, Ie as AuthProvider, br as BooleanColumn, rr as BooleanField, kr as BooleanFilter, Er as CustomColumn, pt as DataProvider, xr as DateColumn, ar as DateField, Ar as DateFilter, je as DensitySwitch, Q as FieldWrapper, Nn as FilterBar, Qn as FormStep, er as FormSteps, Yn as FormTab, Zn as FormTabs, et as Guard, nt as GuestOnly, Rn as InlineFormSet, zn as InlineFormSetStacked, Wt as LoginPage, yr as NumberColumn, nr as NumberField, Or as NumberFilter, cr as PasswordField, Ve as PermissionsProvider, Gt as PlaceholderPage, tt as Protected, Cr as ReferenceColumn, hr as ReferenceField, Nr as ReferenceFilter, Tr as ReferenceManyColumn, gr as ReferenceManyField, Pr as ReferenceManyFilter, rt as RequirePermission, Gn as ResourceForm, bn as ResourceFormModal, jn as ResourceList, or as SelectField, jr as SelectFilter, _r as TextColumn, tr as TextField, Dr as TextFilter, Ne as ThemeSwitch, Pe as ThemeToolbar, Ft as applyInMemoryListParams, xt as applyInlineFieldPaths, Y as asStringMessages, _t as combineResourceHandlers, ut as createAdminRouter, It as createMemoryResourceHandlers, He as createPermissionsChecker, Lt as createRestResourceHandlers, ze as createSessionStorageAuthAdapter, ct as deriveAuthPaths, We as filterNavByPermission, Nt as filterRows, St as finalizeFormErrors, pn as getByPath, bt as getErrorBody, it as getRouteAccess, At as getRowById, Pn as inlineArrayName, Fn as inlineFieldName, vt as isAbortError, Vn as loadInlineRows, wt as parseDjangoDRFFormErrors, Tt as parseDotNetFormErrors, Et as parseNodeFormErrors, at as partitionAdminRoutes, hn as pickBySources, Bn as saveInlineRows, zt as toDjangoRestOrdering, Vt as toJsonApiSort, Bt as toODataOrderBy, yn as useAbortableEffect, Le as useAuth, Ue as useCan, $ as useChoices, mt as useDataProvider, Dn as useListQueryState, q as usePermissions, kn as useResourceListContext, fn as useSectionField, dn as useSubmitField, ke as useThemeMode };
|