ding-react-admin 1.0.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -13
- package/dist/index.js +1317 -1060
- package/dist/src/crud/InlineFormSet.d.ts +12 -25
- package/dist/src/crud/InlineFormSet.d.ts.map +1 -1
- package/dist/src/crud/ResourceForm.d.ts +7 -4
- 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/columns/ImageColumn.d.ts +14 -0
- package/dist/src/crud/columns/ImageColumn.d.ts.map +1 -0
- package/dist/src/crud/context/InlineFieldsRegistry.d.ts +15 -0
- package/dist/src/crud/context/InlineFieldsRegistry.d.ts.map +1 -0
- package/dist/src/crud/context/PayloadFieldsContext.d.ts +18 -0
- package/dist/src/crud/context/PayloadFieldsContext.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/FileField.d.ts +12 -0
- package/dist/src/crud/fields/FileField.d.ts.map +1 -0
- package/dist/src/crud/fields/ImageField.d.ts +14 -0
- package/dist/src/crud/fields/ImageField.d.ts.map +1 -0
- 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/fields/uploadFieldUtils.d.ts +5 -0
- package/dist/src/crud/fields/uploadFieldUtils.d.ts.map +1 -0
- package/dist/src/crud/fields/useUploadPreviewUrl.d.ts +4 -0
- package/dist/src/crud/fields/useUploadPreviewUrl.d.ts.map +1 -0
- package/dist/src/crud/index.d.ts +26 -9
- package/dist/src/crud/index.d.ts.map +1 -1
- package/dist/src/crud/types.d.ts +23 -20
- package/dist/src/crud/types.d.ts.map +1 -1
- package/dist/src/crud/utils/buildFormPayload.d.ts +6 -0
- package/dist/src/crud/utils/buildFormPayload.d.ts.map +1 -0
- package/dist/src/crud/utils/buildInlineRowsPayload.d.ts +6 -0
- package/dist/src/crud/utils/buildInlineRowsPayload.d.ts.map +1 -0
- package/dist/src/crud/utils/buildResourceFormSubmitBody.d.ts +5 -0
- package/dist/src/crud/utils/buildResourceFormSubmitBody.d.ts.map +1 -0
- package/dist/src/crud/utils/formErrors.d.ts +1 -1
- package/dist/src/crud/utils/formErrors.d.ts.map +1 -1
- package/dist/src/crud/utils/getFormValue.d.ts +3 -0
- package/dist/src/crud/utils/getFormValue.d.ts.map +1 -0
- package/dist/src/crud/utils/hasUploadValues.d.ts +3 -0
- package/dist/src/crud/utils/hasUploadValues.d.ts.map +1 -0
- package/dist/src/crud/utils/nestedFieldPath.d.ts +3 -0
- package/dist/src/crud/utils/nestedFieldPath.d.ts.map +1 -0
- package/dist/src/crud/utils/prepareFormSubmitBody.d.ts +7 -0
- package/dist/src/crud/utils/prepareFormSubmitBody.d.ts.map +1 -0
- package/dist/src/crud/utils/setFormValue.d.ts +3 -0
- package/dist/src/crud/utils/setFormValue.d.ts.map +1 -0
- package/dist/src/crud/utils/toFormData.d.ts +13 -0
- package/dist/src/crud/utils/toFormData.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/useFormRecord.d.ts +42 -0
- package/dist/src/crud/utils/useFormRecord.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 +6 -6
- package/dist/src/data/createRestResourceHandlers.d.ts.map +1 -1
- package/dist/src/data/dataProviderTypes.d.ts +13 -6
- package/dist/src/data/dataProviderTypes.d.ts.map +1 -1
- package/dist/src/data/parseFormErrorHelpers.d.ts +44 -6
- package/dist/src/data/parseFormErrorHelpers.d.ts.map +1 -1
- package/dist/src/data/resourceHandlers.d.ts +3 -3
- package/dist/src/data/resourceHandlers.d.ts.map +1 -1
- package/dist/src/index.d.ts +5 -4
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/layouts/AdminLayout.d.ts.map +1 -1
- package/package.json +59 -59
- package/src/crud/InlineFormSet.tsx +90 -159
- package/src/crud/ResourceForm.tsx +83 -204
- package/src/crud/ResourceFormModal.tsx +57 -45
- package/src/crud/ResourceList.tsx +36 -26
- package/src/crud/columns/ImageColumn.tsx +58 -0
- package/src/crud/columns/TextColumn.tsx +2 -2
- package/src/crud/context/InlineFieldsRegistry.tsx +61 -0
- package/src/crud/context/PayloadFieldsContext.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 +87 -109
- package/src/crud/fields/FileField.tsx +123 -0
- package/src/crud/fields/ImageField.tsx +120 -0
- 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/fields/uploadFieldUtils.ts +21 -0
- package/src/crud/fields/useUploadPreviewUrl.ts +20 -0
- package/src/crud/index.ts +35 -14
- package/src/crud/types.ts +134 -130
- package/src/crud/utils/buildFormPayload.ts +24 -0
- package/src/crud/utils/buildInlineRowsPayload.ts +37 -0
- package/src/crud/utils/buildResourceFormSubmitBody.ts +29 -0
- package/src/crud/utils/formErrors.ts +42 -38
- package/src/crud/utils/{getByPath.ts → getFormValue.ts} +2 -2
- package/src/crud/utils/hasUploadValues.ts +9 -0
- package/src/crud/utils/nestedFieldPath.ts +8 -0
- package/src/crud/utils/prepareFormSubmitBody.ts +17 -0
- package/src/crud/utils/{setByPath.ts → setFormValue.ts} +2 -2
- package/src/crud/utils/toFormData.ts +81 -0
- package/src/crud/utils/useAbortableEffect.ts +17 -0
- package/src/crud/utils/useFormRecord.ts +156 -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 +22 -16
- package/src/data/dataProviderTypes.ts +15 -5
- package/src/data/dataUtils.test.ts +118 -6
- package/src/data/parseFormErrorHelpers.test.ts +138 -84
- package/src/data/parseFormErrorHelpers.ts +311 -224
- package/src/data/resourceHandlers.ts +5 -4
- package/src/index.ts +34 -9
- package/src/layouts/AdminLayout.tsx +2 -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/dist/src/crud/utils/getByPath.d.ts +0 -3
- package/dist/src/crud/utils/getByPath.d.ts.map +0 -1
- package/dist/src/crud/utils/inlineArrayName.d.ts +0 -3
- package/dist/src/crud/utils/inlineArrayName.d.ts.map +0 -1
- package/dist/src/crud/utils/pickBySources.d.ts +0 -6
- package/dist/src/crud/utils/pickBySources.d.ts.map +0 -1
- package/dist/src/crud/utils/setByPath.d.ts +0 -3
- package/dist/src/crud/utils/setByPath.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/src/crud/utils/inlineArrayName.ts +0 -4
- package/src/crud/utils/pickBySources.ts +0 -24
package/dist/index.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
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, Image as k, Input as A, InputNumber as te, Layout as j, Menu as ne, Modal as M, Popover as N, Segmented as re, Select as P, Space as F, Spin as I, Steps as ie, Switch as ae, Table as oe, Tabs as L, 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
|
-
import { ArrowLeftOutlined as U, CaretDownOutlined as
|
|
6
|
-
import { Controller as
|
|
7
|
-
import
|
|
5
|
+
import { ArrowLeftOutlined as U, CaretDownOutlined as se, CaretUpOutlined as ce, ColumnHeightOutlined as le, DeleteOutlined as ue, DesktopOutlined as de, LayoutOutlined as fe, LogoutOutlined as pe, MenuOutlined as me, MoonOutlined as he, PaperClipOutlined as ge, SettingOutlined as _e, SunOutlined as ve, UploadOutlined as ye, UserOutlined as be } from "@ant-design/icons";
|
|
6
|
+
import { Controller as xe, FormProvider as W, useFieldArray as Se, useForm as Ce, useFormContext as G, useFormState as we, useWatch as Te } from "react-hook-form";
|
|
7
|
+
import Ee from "dayjs";
|
|
8
8
|
//#region src/context/AppThemeProvider.tsx
|
|
9
|
-
var
|
|
10
|
-
function
|
|
9
|
+
var De = t(null);
|
|
10
|
+
function Oe(e) {
|
|
11
11
|
try {
|
|
12
12
|
let t = localStorage.getItem(e);
|
|
13
13
|
if (t === "light" || t === "dark" || t === "system") return t;
|
|
14
14
|
} catch {}
|
|
15
15
|
return "system";
|
|
16
16
|
}
|
|
17
|
-
function
|
|
17
|
+
function ke() {
|
|
18
18
|
return window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function Ae(e) {
|
|
21
21
|
try {
|
|
22
22
|
let t = localStorage.getItem(e);
|
|
23
23
|
if (t === "comfortable" || t === "compact") return t;
|
|
24
24
|
} catch {}
|
|
25
25
|
return "comfortable";
|
|
26
26
|
}
|
|
27
|
-
var
|
|
28
|
-
function
|
|
29
|
-
let [r, i] = l(() =>
|
|
27
|
+
var je = "ding-react-admin-theme-mode", Me = "ding-react-admin-theme-density";
|
|
28
|
+
function Ne({ children: e, modeStorageKey: t = je, densityStorageKey: n = Me }) {
|
|
29
|
+
let [r, i] = l(() => Oe(t)), [a, c] = l(() => Ae(n)), [u, d] = l(ke);
|
|
30
30
|
o(() => {
|
|
31
31
|
if (r !== "system") return;
|
|
32
32
|
let e = window.matchMedia("(prefers-color-scheme: dark)"), t = () => d(e.matches);
|
|
@@ -58,7 +58,7 @@ function Oe({ children: e, modeStorageKey: t = Ee, densityStorageKey: n = De })
|
|
|
58
58
|
f,
|
|
59
59
|
p
|
|
60
60
|
]);
|
|
61
|
-
return /* @__PURE__ */ V(
|
|
61
|
+
return /* @__PURE__ */ V(De.Provider, {
|
|
62
62
|
value: g,
|
|
63
63
|
children: /* @__PURE__ */ V(C, {
|
|
64
64
|
theme: h,
|
|
@@ -66,64 +66,64 @@ function Oe({ children: e, modeStorageKey: t = Ee, densityStorageKey: n = De })
|
|
|
66
66
|
})
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
|
-
function
|
|
70
|
-
let e = a(
|
|
69
|
+
function Pe() {
|
|
70
|
+
let e = a(De);
|
|
71
71
|
if (!e) throw Error("useThemeMode must be used within AppThemeProvider");
|
|
72
72
|
return e;
|
|
73
73
|
}
|
|
74
74
|
//#endregion
|
|
75
75
|
//#region src/components/DensitySwitch.tsx
|
|
76
|
-
var
|
|
76
|
+
var Fe = [{
|
|
77
77
|
label: "Comfortable",
|
|
78
78
|
value: "comfortable",
|
|
79
|
-
icon: /* @__PURE__ */ V(
|
|
79
|
+
icon: /* @__PURE__ */ V(fe, {})
|
|
80
80
|
}, {
|
|
81
81
|
label: "Compact",
|
|
82
82
|
value: "compact",
|
|
83
|
-
icon: /* @__PURE__ */ V(
|
|
83
|
+
icon: /* @__PURE__ */ V(le, {})
|
|
84
84
|
}];
|
|
85
|
-
function
|
|
86
|
-
let { density: e, setDensity: t } =
|
|
87
|
-
return /* @__PURE__ */ V(
|
|
85
|
+
function Ie() {
|
|
86
|
+
let { density: e, setDensity: t } = Pe();
|
|
87
|
+
return /* @__PURE__ */ V(re, {
|
|
88
88
|
size: "small",
|
|
89
89
|
value: e,
|
|
90
|
-
options:
|
|
90
|
+
options: Fe,
|
|
91
91
|
onChange: (e) => t(e)
|
|
92
92
|
});
|
|
93
93
|
}
|
|
94
94
|
//#endregion
|
|
95
95
|
//#region src/components/ThemeSwitch.tsx
|
|
96
|
-
var
|
|
96
|
+
var Le = [
|
|
97
97
|
{
|
|
98
98
|
label: "Light",
|
|
99
99
|
value: "light",
|
|
100
|
-
icon: /* @__PURE__ */ V(
|
|
100
|
+
icon: /* @__PURE__ */ V(ve, {})
|
|
101
101
|
},
|
|
102
102
|
{
|
|
103
103
|
label: "Dark",
|
|
104
104
|
value: "dark",
|
|
105
|
-
icon: /* @__PURE__ */ V(
|
|
105
|
+
icon: /* @__PURE__ */ V(he, {})
|
|
106
106
|
},
|
|
107
107
|
{
|
|
108
108
|
label: "Auto",
|
|
109
109
|
value: "system",
|
|
110
|
-
icon: /* @__PURE__ */ V(
|
|
110
|
+
icon: /* @__PURE__ */ V(de, {})
|
|
111
111
|
}
|
|
112
112
|
];
|
|
113
|
-
function
|
|
114
|
-
let { mode: e, setMode: t } =
|
|
115
|
-
return /* @__PURE__ */ V(
|
|
113
|
+
function Re() {
|
|
114
|
+
let { mode: e, setMode: t } = Pe();
|
|
115
|
+
return /* @__PURE__ */ V(re, {
|
|
116
116
|
size: "small",
|
|
117
117
|
value: e,
|
|
118
|
-
options:
|
|
118
|
+
options: Le,
|
|
119
119
|
onChange: (e) => t(e)
|
|
120
120
|
});
|
|
121
121
|
}
|
|
122
122
|
//#endregion
|
|
123
123
|
//#region src/components/ThemeToolbar.tsx
|
|
124
|
-
function
|
|
124
|
+
function ze() {
|
|
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
129
|
content: /* @__PURE__ */ H(F, {
|
|
@@ -133,20 +133,20 @@ function Pe() {
|
|
|
133
133
|
minWidth: 240,
|
|
134
134
|
maxWidth: "min(92vw, 320px)"
|
|
135
135
|
},
|
|
136
|
-
children: [/* @__PURE__ */ V(
|
|
136
|
+
children: [/* @__PURE__ */ V(Re, {}), /* @__PURE__ */ V(Ie, {})]
|
|
137
137
|
}),
|
|
138
138
|
styles: { content: { padding: e.paddingSM } },
|
|
139
139
|
children: /* @__PURE__ */ V(x, {
|
|
140
140
|
type: "default",
|
|
141
|
-
icon: /* @__PURE__ */ V(
|
|
141
|
+
icon: /* @__PURE__ */ V(_e, {}),
|
|
142
142
|
"aria-label": "Display and theme settings"
|
|
143
143
|
})
|
|
144
144
|
});
|
|
145
145
|
}
|
|
146
146
|
//#endregion
|
|
147
147
|
//#region src/context/AuthProvider.tsx
|
|
148
|
-
var
|
|
149
|
-
function
|
|
148
|
+
var Be = t(null);
|
|
149
|
+
function Ve({ children: e, adapter: t }) {
|
|
150
150
|
let [n, r] = l(() => t.getToken()), a = i(async (e) => {
|
|
151
151
|
await t.login(e), r(t.getToken());
|
|
152
152
|
}, [t]), o = i(() => {
|
|
@@ -160,18 +160,18 @@ function Ie({ children: e, adapter: t }) {
|
|
|
160
160
|
a,
|
|
161
161
|
o
|
|
162
162
|
]);
|
|
163
|
-
return /* @__PURE__ */ V(
|
|
163
|
+
return /* @__PURE__ */ V(Be.Provider, {
|
|
164
164
|
value: c,
|
|
165
165
|
children: e
|
|
166
166
|
});
|
|
167
167
|
}
|
|
168
|
-
function
|
|
169
|
-
let e = a(
|
|
168
|
+
function He() {
|
|
169
|
+
let e = a(Be);
|
|
170
170
|
if (!e) throw Error("useAuth must be used within AuthProvider");
|
|
171
171
|
return e;
|
|
172
172
|
}
|
|
173
|
-
var
|
|
174
|
-
function
|
|
173
|
+
var Ue = "ding-react-admin-auth";
|
|
174
|
+
function We(e = Ue) {
|
|
175
175
|
return {
|
|
176
176
|
async login({ username: t, password: n }) {
|
|
177
177
|
if (!t.trim() || !n) throw Error("Invalid credentials");
|
|
@@ -187,37 +187,37 @@ function ze(e = Re) {
|
|
|
187
187
|
}
|
|
188
188
|
//#endregion
|
|
189
189
|
//#region src/context/PermissionsProvider.tsx
|
|
190
|
-
var
|
|
191
|
-
function
|
|
190
|
+
var Ge = t(null);
|
|
191
|
+
function Ke({ children: e, can: t }) {
|
|
192
192
|
let n = s(() => t, [t]);
|
|
193
|
-
return /* @__PURE__ */ V(
|
|
193
|
+
return /* @__PURE__ */ V(Ge.Provider, {
|
|
194
194
|
value: n,
|
|
195
195
|
children: e
|
|
196
196
|
});
|
|
197
197
|
}
|
|
198
|
-
function
|
|
199
|
-
let e = a(
|
|
198
|
+
function K() {
|
|
199
|
+
let e = a(Ge);
|
|
200
200
|
if (!e) throw Error("usePermissions must be used within PermissionsProvider");
|
|
201
201
|
return e;
|
|
202
202
|
}
|
|
203
|
-
function
|
|
203
|
+
function qe(e) {
|
|
204
204
|
return (t) => e()?.includes(t) ?? !1;
|
|
205
205
|
}
|
|
206
|
-
function
|
|
207
|
-
let t =
|
|
206
|
+
function Je(e) {
|
|
207
|
+
let t = K();
|
|
208
208
|
return i(() => t(e), [t, e]);
|
|
209
209
|
}
|
|
210
210
|
//#endregion
|
|
211
211
|
//#region src/permissions/resourcePermissions.ts
|
|
212
|
-
function
|
|
212
|
+
function q(e, t, n) {
|
|
213
213
|
if (!t) return !0;
|
|
214
214
|
let r = t[n];
|
|
215
215
|
return n === "read" && !r && (r = t.list), r ? e(r) : !1;
|
|
216
216
|
}
|
|
217
|
-
function
|
|
217
|
+
function Ye(e, t) {
|
|
218
218
|
return e.map((e) => {
|
|
219
219
|
if (e.children?.length) {
|
|
220
|
-
let n =
|
|
220
|
+
let n = Ye(e.children, t);
|
|
221
221
|
return n.length === 0 ? null : {
|
|
222
222
|
...e,
|
|
223
223
|
children: n
|
|
@@ -228,25 +228,25 @@ function We(e, t) {
|
|
|
228
228
|
}
|
|
229
229
|
//#endregion
|
|
230
230
|
//#region src/layouts/AdminLayout.tsx
|
|
231
|
-
var
|
|
232
|
-
function
|
|
231
|
+
var Xe = "#001529", Ze = "ding-react-admin-sider-collapsed";
|
|
232
|
+
function Qe(e) {
|
|
233
233
|
try {
|
|
234
234
|
return localStorage.getItem(e) === "1";
|
|
235
235
|
} catch {
|
|
236
236
|
return !1;
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
|
-
function
|
|
239
|
+
function $e() {
|
|
240
240
|
return O.useBreakpoint().lg !== !0;
|
|
241
241
|
}
|
|
242
|
-
function
|
|
242
|
+
function et(e) {
|
|
243
243
|
let t = /* @__PURE__ */ new Set();
|
|
244
244
|
function n(e) {
|
|
245
245
|
for (let r of e) r.children?.length ? n(r.children) : t.add(r.path);
|
|
246
246
|
}
|
|
247
247
|
return n(e), t;
|
|
248
248
|
}
|
|
249
|
-
function
|
|
249
|
+
function tt(e, t) {
|
|
250
250
|
function n(e) {
|
|
251
251
|
for (let r of e) if (r.children?.length) {
|
|
252
252
|
let e = n(r.children);
|
|
@@ -256,14 +256,14 @@ function Xe(e, t) {
|
|
|
256
256
|
}
|
|
257
257
|
return n(e) ?? [];
|
|
258
258
|
}
|
|
259
|
-
function
|
|
259
|
+
function nt(e) {
|
|
260
260
|
return e.map((e) => {
|
|
261
261
|
let t = e.Icon, n = t ? /* @__PURE__ */ V(t, {}) : void 0;
|
|
262
262
|
return e.children?.length ? {
|
|
263
263
|
key: e.path,
|
|
264
264
|
icon: n,
|
|
265
265
|
label: e.label,
|
|
266
|
-
children:
|
|
266
|
+
children: nt(e.children)
|
|
267
267
|
} : {
|
|
268
268
|
key: e.path,
|
|
269
269
|
icon: n,
|
|
@@ -271,8 +271,8 @@ function Ze(e) {
|
|
|
271
271
|
};
|
|
272
272
|
});
|
|
273
273
|
}
|
|
274
|
-
function
|
|
275
|
-
return /* @__PURE__ */ V(
|
|
274
|
+
function rt({ menuItems: e, selectedKeys: t, inlineCollapsed: n, openKeys: r, onOpenChange: i, onNavigate: a }) {
|
|
275
|
+
return /* @__PURE__ */ V(ne, {
|
|
276
276
|
mode: "inline",
|
|
277
277
|
theme: "dark",
|
|
278
278
|
inlineCollapsed: n,
|
|
@@ -289,10 +289,10 @@ function Qe({ menuItems: e, selectedKeys: t, inlineCollapsed: n, openKeys: r, on
|
|
|
289
289
|
}
|
|
290
290
|
});
|
|
291
291
|
}
|
|
292
|
-
function
|
|
293
|
-
let m = g(), _ = h(), { resolved: v } =
|
|
292
|
+
function it({ navItems: e, brand: t = "Admin", collapsedBrand: n = "A", mobileDrawerTitle: r, headerExtras: a, userMenuItems: c, onUserMenuClick: u, loginPath: d = "/login", siderCollapsedStorageKey: p = Ze }) {
|
|
293
|
+
let m = g(), _ = h(), { resolved: v } = Pe(), y = v === "dark", { logout: S } = He(), C = K(), [w, E] = l(() => Qe(p)), [D, O] = l(!1), k = $e(), { token: A } = z.useToken(), te = r ?? t, ne = () => {
|
|
294
294
|
S(), m(d, { replace: !0 });
|
|
295
|
-
},
|
|
295
|
+
}, M = i((e) => {
|
|
296
296
|
E(e);
|
|
297
297
|
try {
|
|
298
298
|
localStorage.setItem(p, e ? "1" : "0");
|
|
@@ -303,25 +303,25 @@ function $e({ navItems: e, brand: t = "Admin", collapsedBrand: n = "A", mobileDr
|
|
|
303
303
|
}, [k]), o(() => {
|
|
304
304
|
O(!1);
|
|
305
305
|
}, [_.pathname]);
|
|
306
|
-
let N = s(() =>
|
|
306
|
+
let N = s(() => Ye(e, C), [e, C]), re = s(() => et(N), [N]), P = s(() => nt(N), [N]), F = s(() => tt(N, _.pathname), [N, _.pathname]), [I, ie] = l(() => tt(N, _.pathname));
|
|
307
307
|
o(() => {
|
|
308
|
-
|
|
309
|
-
}, [
|
|
310
|
-
let
|
|
311
|
-
|
|
312
|
-
}, []),
|
|
308
|
+
ie((e) => [...new Set([...e, ...F])]);
|
|
309
|
+
}, [F]);
|
|
310
|
+
let ae = i((e) => {
|
|
311
|
+
ie(e);
|
|
312
|
+
}, []), oe = s(() => [{
|
|
313
313
|
key: "logout",
|
|
314
|
-
icon: /* @__PURE__ */ V(
|
|
314
|
+
icon: /* @__PURE__ */ V(pe, {}),
|
|
315
315
|
label: "Log out",
|
|
316
316
|
danger: !0
|
|
317
|
-
}], []),
|
|
317
|
+
}], []), L = c ?? oe, B = (e) => {
|
|
318
318
|
if (u) {
|
|
319
319
|
u(e);
|
|
320
320
|
return;
|
|
321
321
|
}
|
|
322
|
-
e.key === "logout" &&
|
|
323
|
-
},
|
|
324
|
-
|
|
322
|
+
e.key === "logout" && ne();
|
|
323
|
+
}, U = y ? A.colorBgContainer : Xe, se = [_.pathname], ce = (e) => {
|
|
324
|
+
re.has(e) && (m(e), k && O(!1));
|
|
325
325
|
};
|
|
326
326
|
return /* @__PURE__ */ H(j, {
|
|
327
327
|
style: {
|
|
@@ -333,10 +333,10 @@ 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: M,
|
|
337
337
|
collapsedWidth: 64,
|
|
338
338
|
style: {
|
|
339
|
-
background:
|
|
339
|
+
background: U,
|
|
340
340
|
borderInlineEnd: y ? `1px solid ${A.colorSplit}` : void 0
|
|
341
341
|
},
|
|
342
342
|
children: [/* @__PURE__ */ V("div", {
|
|
@@ -352,16 +352,16 @@ function $e({ navItems: e, brand: t = "Admin", collapsedBrand: n = "A", mobileDr
|
|
|
352
352
|
style: { color: A.colorTextLightSolid },
|
|
353
353
|
children: w ? n : t
|
|
354
354
|
})
|
|
355
|
-
}), /* @__PURE__ */ V(
|
|
356
|
-
menuItems:
|
|
355
|
+
}), /* @__PURE__ */ V(rt, {
|
|
356
|
+
menuItems: P,
|
|
357
357
|
selectedKeys: se,
|
|
358
358
|
inlineCollapsed: w,
|
|
359
|
-
openKeys:
|
|
360
|
-
onOpenChange:
|
|
361
|
-
onNavigate:
|
|
359
|
+
openKeys: I,
|
|
360
|
+
onOpenChange: ae,
|
|
361
|
+
onNavigate: ce
|
|
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 },
|
|
@@ -373,119 +373,125 @@ function $e({ navItems: e, brand: t = "Admin", collapsedBrand: n = "A", mobileDr
|
|
|
373
373
|
open: D,
|
|
374
374
|
styles: {
|
|
375
375
|
header: {
|
|
376
|
-
background:
|
|
376
|
+
background: U,
|
|
377
377
|
borderBottom: `1px solid ${A.colorSplit}`
|
|
378
378
|
},
|
|
379
379
|
body: {
|
|
380
380
|
padding: 0,
|
|
381
|
-
background:
|
|
381
|
+
background: U
|
|
382
382
|
}
|
|
383
383
|
},
|
|
384
384
|
destroyOnHidden: !0,
|
|
385
|
-
children: /* @__PURE__ */ V(
|
|
386
|
-
menuItems:
|
|
385
|
+
children: /* @__PURE__ */ V(rt, {
|
|
386
|
+
menuItems: P,
|
|
387
387
|
selectedKeys: se,
|
|
388
388
|
inlineCollapsed: !1,
|
|
389
|
-
openKeys:
|
|
390
|
-
onOpenChange:
|
|
391
|
-
onNavigate:
|
|
389
|
+
openKeys: I,
|
|
390
|
+
onOpenChange: ae,
|
|
391
|
+
onNavigate: ce
|
|
392
392
|
})
|
|
393
393
|
}),
|
|
394
|
-
/* @__PURE__ */ H(j, {
|
|
395
|
-
style: {
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
onClick: () => O(!0),
|
|
408
|
-
"aria-label": "Open navigation"
|
|
409
|
-
}),
|
|
410
|
-
/* @__PURE__ */ V("div", { style: {
|
|
411
|
-
flex: 1,
|
|
412
|
-
minWidth: 0
|
|
413
|
-
} }),
|
|
414
|
-
a,
|
|
415
|
-
/* @__PURE__ */ V(Pe, {}),
|
|
416
|
-
/* @__PURE__ */ V(ee, {
|
|
417
|
-
menu: {
|
|
418
|
-
items: B,
|
|
419
|
-
onClick: U
|
|
420
|
-
},
|
|
421
|
-
trigger: ["click"],
|
|
422
|
-
children: /* @__PURE__ */ H(x, {
|
|
394
|
+
/* @__PURE__ */ H(j, {
|
|
395
|
+
style: { minWidth: 0 },
|
|
396
|
+
children: [/* @__PURE__ */ H(j.Header, {
|
|
397
|
+
style: {
|
|
398
|
+
background: A.colorBgContainer,
|
|
399
|
+
paddingInline: A.paddingLG,
|
|
400
|
+
display: "flex",
|
|
401
|
+
alignItems: "center",
|
|
402
|
+
gap: A.marginSM,
|
|
403
|
+
lineHeight: "normal"
|
|
404
|
+
},
|
|
405
|
+
children: [
|
|
406
|
+
k && /* @__PURE__ */ V(x, {
|
|
423
407
|
type: "text",
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
408
|
+
icon: /* @__PURE__ */ V(me, {}),
|
|
409
|
+
onClick: () => O(!0),
|
|
410
|
+
"aria-label": "Open navigation"
|
|
411
|
+
}),
|
|
412
|
+
/* @__PURE__ */ V("div", { style: {
|
|
413
|
+
flex: 1,
|
|
414
|
+
minWidth: 0
|
|
415
|
+
} }),
|
|
416
|
+
a,
|
|
417
|
+
/* @__PURE__ */ V(ze, {}),
|
|
418
|
+
/* @__PURE__ */ V(T, {
|
|
419
|
+
menu: {
|
|
420
|
+
items: L,
|
|
421
|
+
onClick: B
|
|
430
422
|
},
|
|
431
|
-
|
|
432
|
-
children:
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
423
|
+
trigger: ["click"],
|
|
424
|
+
children: /* @__PURE__ */ H(x, {
|
|
425
|
+
type: "text",
|
|
426
|
+
style: {
|
|
427
|
+
display: "inline-flex",
|
|
428
|
+
alignItems: "center",
|
|
429
|
+
gap: A.marginXS,
|
|
430
|
+
maxWidth: k ? 44 : void 0,
|
|
431
|
+
paddingInline: k ? A.paddingXS : void 0
|
|
432
|
+
},
|
|
433
|
+
"aria-label": "Account menu",
|
|
434
|
+
children: [/* @__PURE__ */ V(b, {
|
|
435
|
+
size: "small",
|
|
436
|
+
icon: /* @__PURE__ */ V(be, {})
|
|
437
|
+
}), !k && /* @__PURE__ */ V(R.Text, {
|
|
438
|
+
type: "secondary",
|
|
439
|
+
children: "User"
|
|
440
|
+
})]
|
|
441
|
+
})
|
|
439
442
|
})
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
443
|
+
]
|
|
444
|
+
}), /* @__PURE__ */ V(j.Content, {
|
|
445
|
+
style: {
|
|
446
|
+
margin: k ? A.marginSM : A.marginLG,
|
|
447
|
+
minWidth: 0
|
|
448
|
+
},
|
|
449
|
+
children: /* @__PURE__ */ V(f, {})
|
|
450
|
+
})]
|
|
451
|
+
})
|
|
446
452
|
]
|
|
447
453
|
});
|
|
448
454
|
}
|
|
449
455
|
//#endregion
|
|
450
456
|
//#region src/router/guards.tsx
|
|
451
|
-
function
|
|
457
|
+
function at({ when: e, redirect: t, children: n }) {
|
|
452
458
|
return e ? n : /* @__PURE__ */ V(d, {
|
|
453
459
|
to: t,
|
|
454
460
|
replace: !0
|
|
455
461
|
});
|
|
456
462
|
}
|
|
457
|
-
function
|
|
458
|
-
let { isAuthenticated: n } =
|
|
459
|
-
return /* @__PURE__ */ V(
|
|
463
|
+
function ot({ children: e, redirectTo: t = "/login" }) {
|
|
464
|
+
let { isAuthenticated: n } = He();
|
|
465
|
+
return /* @__PURE__ */ V(at, {
|
|
460
466
|
when: n,
|
|
461
467
|
redirect: t,
|
|
462
468
|
children: e
|
|
463
469
|
});
|
|
464
470
|
}
|
|
465
|
-
function
|
|
466
|
-
let { isAuthenticated: n } =
|
|
467
|
-
return /* @__PURE__ */ V(
|
|
471
|
+
function st({ children: e, redirectTo: t = "/" }) {
|
|
472
|
+
let { isAuthenticated: n } = He();
|
|
473
|
+
return /* @__PURE__ */ V(at, {
|
|
468
474
|
when: !n,
|
|
469
475
|
redirect: t,
|
|
470
476
|
children: e
|
|
471
477
|
});
|
|
472
478
|
}
|
|
473
|
-
function
|
|
474
|
-
return /* @__PURE__ */ V(
|
|
475
|
-
when:
|
|
479
|
+
function ct({ permission: e, redirect: t, children: n }) {
|
|
480
|
+
return /* @__PURE__ */ V(at, {
|
|
481
|
+
when: K()(e),
|
|
476
482
|
redirect: t,
|
|
477
483
|
children: n
|
|
478
484
|
});
|
|
479
485
|
}
|
|
480
486
|
//#endregion
|
|
481
487
|
//#region src/router/routeAccess.ts
|
|
482
|
-
function
|
|
488
|
+
function lt(e) {
|
|
483
489
|
return e.access ?? "protected";
|
|
484
490
|
}
|
|
485
|
-
function
|
|
491
|
+
function ut(e) {
|
|
486
492
|
let t = [], n = [], r = [];
|
|
487
493
|
for (let i of e) {
|
|
488
|
-
let e =
|
|
494
|
+
let e = lt(i);
|
|
489
495
|
e === "guest" ? t.push(i) : e === "public" ? n.push(i) : r.push(i);
|
|
490
496
|
}
|
|
491
497
|
return {
|
|
@@ -494,24 +500,24 @@ function at(e) {
|
|
|
494
500
|
protected: r
|
|
495
501
|
};
|
|
496
502
|
}
|
|
497
|
-
function
|
|
503
|
+
function dt(e) {
|
|
498
504
|
return e.replace(/^\/+/, "");
|
|
499
505
|
}
|
|
500
|
-
function
|
|
501
|
-
return `/${
|
|
506
|
+
function ft(e) {
|
|
507
|
+
return `/${dt(e)}`;
|
|
502
508
|
}
|
|
503
|
-
function
|
|
504
|
-
let { guest: n, protected: r } =
|
|
505
|
-
!s && i && "path" in i && i.path && (s =
|
|
509
|
+
function pt(e, t) {
|
|
510
|
+
let { guest: n, protected: r } = ut(e), i = n.find((e) => "path" in e && e.path), a = r.find((e) => "index" in e && e.index), o = r.find((e) => "path" in e && e.path), s = t?.unauthenticated;
|
|
511
|
+
!s && i && "path" in i && i.path && (s = ft(i.path));
|
|
506
512
|
let c = t?.afterLogin;
|
|
507
|
-
if (c || (a ? c = "/" : o && "path" in o && o.path && (c =
|
|
513
|
+
if (c || (a ? c = "/" : o && "path" in o && o.path && (c = ft(o.path))), r.length > 0 && !s) throw Error("createAdminRouter: protected routes require redirects.unauthenticated or a guest route (access: \"guest\").");
|
|
508
514
|
if (n.length > 0 && !c) throw Error("createAdminRouter: guest routes require redirects.afterLogin or a protected route (index or path).");
|
|
509
515
|
return {
|
|
510
516
|
loginPath: s ?? "/",
|
|
511
517
|
homePath: c ?? "/"
|
|
512
518
|
};
|
|
513
519
|
}
|
|
514
|
-
function
|
|
520
|
+
function mt(e) {
|
|
515
521
|
return "index" in e && e.index ? {
|
|
516
522
|
index: !0,
|
|
517
523
|
element: e.element
|
|
@@ -522,30 +528,30 @@ function lt(e) {
|
|
|
522
528
|
}
|
|
523
529
|
//#endregion
|
|
524
530
|
//#region src/router/createAdminRouter.tsx
|
|
525
|
-
function
|
|
526
|
-
let { loginPath: i, homePath: a } =
|
|
531
|
+
function ht({ navItems: e, children: t, layoutProps: n, redirects: r }) {
|
|
532
|
+
let { loginPath: i, homePath: a } = pt(t, r), { guest: o, public: s, protected: c } = ut(t), l = [];
|
|
527
533
|
for (let e of o) !("path" in e) || !e.path || l.push({
|
|
528
|
-
path:
|
|
529
|
-
element: /* @__PURE__ */ V(
|
|
534
|
+
path: dt(e.path),
|
|
535
|
+
element: /* @__PURE__ */ V(st, {
|
|
530
536
|
redirectTo: a,
|
|
531
537
|
children: e.element
|
|
532
538
|
})
|
|
533
539
|
});
|
|
534
540
|
for (let e of s) !("path" in e) || !e.path || l.push({
|
|
535
|
-
path:
|
|
541
|
+
path: dt(e.path),
|
|
536
542
|
element: e.element
|
|
537
543
|
});
|
|
538
544
|
return c.length > 0 && l.push({
|
|
539
545
|
path: "/",
|
|
540
|
-
element: /* @__PURE__ */ V(
|
|
546
|
+
element: /* @__PURE__ */ V(ot, {
|
|
541
547
|
redirectTo: i,
|
|
542
|
-
children: /* @__PURE__ */ V(
|
|
548
|
+
children: /* @__PURE__ */ V(it, {
|
|
543
549
|
navItems: e,
|
|
544
550
|
loginPath: i,
|
|
545
551
|
...n
|
|
546
552
|
})
|
|
547
553
|
}),
|
|
548
|
-
children: c.map(
|
|
554
|
+
children: c.map(mt)
|
|
549
555
|
}), l.push({
|
|
550
556
|
path: "*",
|
|
551
557
|
element: /* @__PURE__ */ V(d, {
|
|
@@ -556,8 +562,8 @@ function ut({ navItems: e, children: t, layoutProps: n, redirects: r }) {
|
|
|
556
562
|
}
|
|
557
563
|
//#endregion
|
|
558
564
|
//#region src/app/AdminApp.tsx
|
|
559
|
-
function
|
|
560
|
-
let a = s(() =>
|
|
565
|
+
function gt({ navItems: e, routes: t, authRedirects: n, layoutProps: r, theme: i }) {
|
|
566
|
+
let a = s(() => ht({
|
|
561
567
|
navItems: e,
|
|
562
568
|
children: t,
|
|
563
569
|
layoutProps: r,
|
|
@@ -568,65 +574,72 @@ function dt({ navItems: e, routes: t, authRedirects: n, layoutProps: r, theme: i
|
|
|
568
574
|
r,
|
|
569
575
|
n
|
|
570
576
|
]);
|
|
571
|
-
return /* @__PURE__ */ V(
|
|
577
|
+
return /* @__PURE__ */ V(Ne, {
|
|
572
578
|
...i,
|
|
573
579
|
children: /* @__PURE__ */ V(p, { router: a })
|
|
574
580
|
});
|
|
575
581
|
}
|
|
576
582
|
//#endregion
|
|
577
583
|
//#region src/context/DataProvider.tsx
|
|
578
|
-
var
|
|
579
|
-
function
|
|
584
|
+
var _t = t(null);
|
|
585
|
+
function vt({ children: e, value: t }) {
|
|
580
586
|
let n = s(() => t, [t]);
|
|
581
|
-
return /* @__PURE__ */ V(
|
|
587
|
+
return /* @__PURE__ */ V(_t.Provider, {
|
|
582
588
|
value: n,
|
|
583
589
|
children: e
|
|
584
590
|
});
|
|
585
591
|
}
|
|
586
|
-
function
|
|
587
|
-
let e = a(
|
|
592
|
+
function yt() {
|
|
593
|
+
let e = a(_t);
|
|
588
594
|
if (!e) throw Error("useDataProvider must be used within DataProvider");
|
|
589
595
|
return e;
|
|
590
596
|
}
|
|
591
597
|
//#endregion
|
|
592
598
|
//#region src/data/resourceHandlers.ts
|
|
593
|
-
function
|
|
599
|
+
function bt(e) {
|
|
594
600
|
return "handlers" in e ? e : { handlers: e };
|
|
595
601
|
}
|
|
596
|
-
function
|
|
597
|
-
if (!(!e || !t) && !
|
|
602
|
+
function J(e, t, n) {
|
|
603
|
+
if (!(!e || !t) && !q(e, t, n)) throw Error("Forbidden");
|
|
598
604
|
}
|
|
599
|
-
function
|
|
605
|
+
function xt(e, t) {
|
|
600
606
|
let { can: n, guard: r, parseFormError: i } = t ?? {}, a = (t) => {
|
|
601
607
|
let n = e[t];
|
|
602
608
|
if (!n) throw Error(`Unknown resource: ${t}`);
|
|
603
|
-
return
|
|
609
|
+
return bt(n);
|
|
604
610
|
};
|
|
605
611
|
return {
|
|
606
612
|
async getList(e, t) {
|
|
607
613
|
let { handlers: i, permissions: o } = a(e);
|
|
608
|
-
return r?.(e, "list"),
|
|
614
|
+
return r?.(e, "list"), J(n, o, "list"), i.getList(t);
|
|
609
615
|
},
|
|
610
|
-
async getOne(e, t) {
|
|
611
|
-
let { handlers:
|
|
612
|
-
return r?.(e, "read"),
|
|
616
|
+
async getOne(e, t, i) {
|
|
617
|
+
let { handlers: o, permissions: s } = a(e);
|
|
618
|
+
return r?.(e, "read"), J(n, s, "read"), o.getOne(t, i);
|
|
613
619
|
},
|
|
614
620
|
async create(e, t) {
|
|
615
621
|
let { handlers: i, permissions: o } = a(e);
|
|
616
|
-
return r?.(e, "add"),
|
|
622
|
+
return r?.(e, "add"), J(n, o, "add"), i.create(t);
|
|
617
623
|
},
|
|
618
624
|
async update(e, t) {
|
|
619
625
|
let { handlers: i, permissions: o } = a(e);
|
|
620
|
-
return r?.(e, "change"),
|
|
626
|
+
return r?.(e, "change"), J(n, o, "change"), i.update(t);
|
|
621
627
|
},
|
|
622
628
|
async delete(e, t) {
|
|
623
629
|
let { handlers: i, permissions: o } = a(e);
|
|
624
|
-
return r?.(e, "delete"),
|
|
630
|
+
return r?.(e, "delete"), J(n, o, "delete"), i.delete(t);
|
|
625
631
|
},
|
|
626
632
|
parseFormError: i
|
|
627
633
|
};
|
|
628
634
|
}
|
|
629
635
|
//#endregion
|
|
636
|
+
//#region src/data/abortError.ts
|
|
637
|
+
function St(e) {
|
|
638
|
+
if (typeof e != "object" || !e) return !1;
|
|
639
|
+
let t = e;
|
|
640
|
+
return t.name === "AbortError" || t.name === "CanceledError" || t.code === "ERR_CANCELED";
|
|
641
|
+
}
|
|
642
|
+
//#endregion
|
|
630
643
|
//#region src/data/parseFormErrorHelpers.ts
|
|
631
644
|
function Y(e) {
|
|
632
645
|
if (typeof e == "string") return [e];
|
|
@@ -636,72 +649,104 @@ function Y(e) {
|
|
|
636
649
|
}
|
|
637
650
|
return [];
|
|
638
651
|
}
|
|
639
|
-
function
|
|
652
|
+
function Ct(e) {
|
|
640
653
|
return e.length === 1 ? e[0] : e;
|
|
641
654
|
}
|
|
642
|
-
function
|
|
655
|
+
function wt(e) {
|
|
656
|
+
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
657
|
+
}
|
|
658
|
+
function Tt(e) {
|
|
659
|
+
return typeof Response < "u" && e instanceof Response ? !0 : typeof e == "object" && !!e && typeof e.json == "function" && typeof e.status == "number" && e.headers != null;
|
|
660
|
+
}
|
|
661
|
+
function Et(e) {
|
|
643
662
|
if (!e || typeof e != "object") return null;
|
|
644
663
|
let t = e;
|
|
645
|
-
if (
|
|
664
|
+
if (wt(t.body)) return t.body;
|
|
665
|
+
if (wt(t.data)) return t.data;
|
|
646
666
|
let n = t.response;
|
|
647
667
|
if (n && typeof n == "object" && !Array.isArray(n)) {
|
|
648
668
|
let e = n.data;
|
|
649
|
-
if (
|
|
669
|
+
if (wt(e)) return e;
|
|
650
670
|
}
|
|
651
671
|
return null;
|
|
652
672
|
}
|
|
653
|
-
function
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
673
|
+
async function Dt(e) {
|
|
674
|
+
let t = Et(e);
|
|
675
|
+
if (t) return t;
|
|
676
|
+
if (!e || typeof e != "object") return null;
|
|
677
|
+
let n = e.response;
|
|
678
|
+
if (!Tt(n)) return null;
|
|
679
|
+
let r = n.headers.get("content-type");
|
|
680
|
+
if (!r || !/application\/json/i.test(r)) return null;
|
|
681
|
+
try {
|
|
682
|
+
let e = await n.clone().json();
|
|
683
|
+
return wt(e) ? e : null;
|
|
684
|
+
} catch {
|
|
685
|
+
return null;
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
function Ot(e) {
|
|
689
|
+
return Array.isArray(e) ? e.some((e) => e && typeof e == "object" && !Array.isArray(e) && Object.values(e).some((e) => Y(e).length > 0)) : !1;
|
|
658
690
|
}
|
|
659
|
-
function
|
|
660
|
-
|
|
691
|
+
function kt(e, t, n) {
|
|
692
|
+
t.forEach((t, r) => {
|
|
693
|
+
if (!(!t || typeof t != "object" || Array.isArray(t))) for (let [i, a] of Object.entries(t)) {
|
|
694
|
+
let t = Y(a);
|
|
695
|
+
t.length && (n[`${e}.${r}.${i}`] = Ct(t));
|
|
696
|
+
}
|
|
697
|
+
});
|
|
698
|
+
}
|
|
699
|
+
function At(e, t) {
|
|
661
700
|
return {
|
|
662
|
-
fields: Object.keys(
|
|
701
|
+
fields: Object.keys(e).length ? e : void 0,
|
|
663
702
|
global: t.length ? t : void 0
|
|
664
703
|
};
|
|
665
704
|
}
|
|
666
|
-
var
|
|
667
|
-
function
|
|
668
|
-
let n =
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
705
|
+
var jt = new Set(["non_field_errors", "detail"]);
|
|
706
|
+
function Mt(e) {
|
|
707
|
+
let t = {}, n = [];
|
|
708
|
+
for (let [r, i] of Object.entries(e)) {
|
|
709
|
+
if (jt.has(r)) {
|
|
710
|
+
n.push(...Y(i));
|
|
711
|
+
continue;
|
|
712
|
+
}
|
|
713
|
+
if (Ot(i)) {
|
|
714
|
+
kt(r, i, t);
|
|
674
715
|
continue;
|
|
675
716
|
}
|
|
676
|
-
let
|
|
677
|
-
|
|
717
|
+
let e = Y(i);
|
|
718
|
+
e.length && (t[r] = Ct(e));
|
|
678
719
|
}
|
|
679
|
-
return !Object.keys(
|
|
720
|
+
return !Object.keys(t).length && !n.length ? null : At(t, n);
|
|
721
|
+
}
|
|
722
|
+
function Nt(e, t) {
|
|
723
|
+
let n = Et(e);
|
|
724
|
+
return n ? Mt(n) : null;
|
|
680
725
|
}
|
|
681
|
-
function
|
|
682
|
-
let r =
|
|
726
|
+
function Pt(e, t, n) {
|
|
727
|
+
let r = Et(e);
|
|
683
728
|
if (!r) return null;
|
|
684
729
|
let i = n?.camelCase ?? !0, a = n?.fieldMap, o = {}, s = [];
|
|
685
730
|
n?.includeSummary && (s.push(...Y(r.title)), s.push(...Y(r.message)));
|
|
686
731
|
let c = r.errors;
|
|
687
732
|
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] =
|
|
733
|
+
let n = a?.[e] ?? (i ? Lt(e) : e), r = Y(t);
|
|
734
|
+
r.length && (o[n] = Ct(r));
|
|
690
735
|
}
|
|
691
|
-
return !Object.keys(o).length && !s.length ? null :
|
|
736
|
+
return !Object.keys(o).length && !s.length ? null : At(o, s);
|
|
692
737
|
}
|
|
693
|
-
function
|
|
694
|
-
let r =
|
|
738
|
+
function Ft(e, t, n) {
|
|
739
|
+
let r = Et(e);
|
|
695
740
|
if (!r) return null;
|
|
696
741
|
let i = {}, a = [], o = n?.fieldMap, s = r.errors;
|
|
697
742
|
if (Array.isArray(s)) for (let e of s) {
|
|
698
743
|
if (!e || typeof e != "object") continue;
|
|
699
744
|
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 ?
|
|
745
|
+
r && (n ? It(i, o?.[n] ?? n, r) : a.push(r));
|
|
701
746
|
}
|
|
702
747
|
else if (s && typeof s == "object") for (let [e, t] of Object.entries(s)) {
|
|
703
748
|
let n = o?.[e] ?? e, r = Y(t);
|
|
704
|
-
r.length && (i[n] =
|
|
749
|
+
r.length && (i[n] = Ct(r));
|
|
705
750
|
}
|
|
706
751
|
let c = r.details;
|
|
707
752
|
if (Array.isArray(c)) for (let e of c) {
|
|
@@ -712,9 +757,9 @@ function Tt(e, t, n) {
|
|
|
712
757
|
i[e] = r;
|
|
713
758
|
} else a.push(r);
|
|
714
759
|
}
|
|
715
|
-
return a.push(...Y(r.error)), !Object.keys(i).length && !a.length ? null :
|
|
760
|
+
return a.push(...Y(r.error)), !Object.keys(i).length && !a.length ? null : At(i, a);
|
|
716
761
|
}
|
|
717
|
-
function
|
|
762
|
+
function It(e, t, n) {
|
|
718
763
|
let r = e[t];
|
|
719
764
|
if (!r) {
|
|
720
765
|
e[t] = n;
|
|
@@ -722,20 +767,20 @@ function Et(e, t, n) {
|
|
|
722
767
|
}
|
|
723
768
|
e[t] = Array.isArray(r) ? [...r, n] : [r, n];
|
|
724
769
|
}
|
|
725
|
-
function
|
|
770
|
+
function Lt(e) {
|
|
726
771
|
return e && e.charAt(0).toLowerCase() + e.slice(1);
|
|
727
772
|
}
|
|
728
773
|
//#endregion
|
|
729
774
|
//#region src/data/inMemoryList.ts
|
|
730
|
-
function
|
|
775
|
+
function Rt(e, t) {
|
|
731
776
|
return e === t || String(e) === String(t);
|
|
732
777
|
}
|
|
733
|
-
function
|
|
734
|
-
let n = e.find((e) =>
|
|
778
|
+
function zt(e, t) {
|
|
779
|
+
let n = e.find((e) => Rt(e.id, t));
|
|
735
780
|
if (!n) throw Error("Not found");
|
|
736
781
|
return n;
|
|
737
782
|
}
|
|
738
|
-
function
|
|
783
|
+
function Bt(e, t) {
|
|
739
784
|
if (t.length === 0) return e;
|
|
740
785
|
let n = (e) => e === "DESC" ? -1 : 1;
|
|
741
786
|
return [...e].sort((e, r) => {
|
|
@@ -751,33 +796,33 @@ function At(e, t) {
|
|
|
751
796
|
return 0;
|
|
752
797
|
});
|
|
753
798
|
}
|
|
754
|
-
function
|
|
799
|
+
function Vt(e, t) {
|
|
755
800
|
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
801
|
}
|
|
757
|
-
function
|
|
758
|
-
return t ? e.filter((e) => Object.entries(t).every(([t, n]) =>
|
|
802
|
+
function Ht(e, t) {
|
|
803
|
+
return t ? e.filter((e) => Object.entries(t).every(([t, n]) => Vt(e[t], n))) : e;
|
|
759
804
|
}
|
|
760
|
-
function
|
|
805
|
+
function Ut(e, t, n) {
|
|
761
806
|
let r = (t - 1) * n;
|
|
762
807
|
return {
|
|
763
808
|
data: e.slice(r, r + n),
|
|
764
809
|
total: e.length
|
|
765
810
|
};
|
|
766
811
|
}
|
|
767
|
-
function
|
|
768
|
-
let { pagination: n, sort: r, filter: i } = t, a =
|
|
812
|
+
function Wt(e, t) {
|
|
813
|
+
let { pagination: n, sort: r, filter: i } = t, a = Ht(e, i);
|
|
769
814
|
if (r) {
|
|
770
815
|
let e = Array.isArray(r) ? r : [r];
|
|
771
|
-
e.length > 0 && e[0]?.field && (a =
|
|
816
|
+
e.length > 0 && e[0]?.field && (a = Bt(a, e));
|
|
772
817
|
}
|
|
773
|
-
return n ?
|
|
818
|
+
return n ? Ut(a, n.page, n.perPage) : {
|
|
774
819
|
data: a,
|
|
775
820
|
total: a.length
|
|
776
821
|
};
|
|
777
822
|
}
|
|
778
823
|
//#endregion
|
|
779
824
|
//#region src/data/createMemoryResourceHandlers.ts
|
|
780
|
-
function
|
|
825
|
+
function Gt(e) {
|
|
781
826
|
let t = (e) => e, n = e.mapCreate ?? ((e, t) => ({
|
|
782
827
|
...e,
|
|
783
828
|
id: t
|
|
@@ -788,21 +833,21 @@ function Ft(e) {
|
|
|
788
833
|
}));
|
|
789
834
|
return {
|
|
790
835
|
async getList(n) {
|
|
791
|
-
return
|
|
836
|
+
return Wt(t(e.scopeList ? e.scopeList(e.getRows(), n) : e.getRows()), n);
|
|
792
837
|
},
|
|
793
|
-
async getOne(t) {
|
|
794
|
-
return { data:
|
|
838
|
+
async getOne(t, n) {
|
|
839
|
+
return { data: zt(e.getRows(), t) };
|
|
795
840
|
},
|
|
796
841
|
async create(t) {
|
|
797
842
|
let r = n(t, e.nextId());
|
|
798
843
|
return e.getRows().push(r), { data: r };
|
|
799
844
|
},
|
|
800
845
|
async update({ id: t, data: n }) {
|
|
801
|
-
let i =
|
|
846
|
+
let i = zt(e.getRows(), t), a = r(i, n);
|
|
802
847
|
return Object.assign(i, a), { data: i };
|
|
803
848
|
},
|
|
804
849
|
async delete(t) {
|
|
805
|
-
let n = e.getRows(), r = n.findIndex((e) =>
|
|
850
|
+
let n = e.getRows(), r = n.findIndex((e) => Rt(e.id, t));
|
|
806
851
|
if (r < 0) return { data: null };
|
|
807
852
|
let [i] = n.splice(r, 1);
|
|
808
853
|
return e.afterDelete?.(i), { data: i };
|
|
@@ -811,20 +856,20 @@ function Ft(e) {
|
|
|
811
856
|
}
|
|
812
857
|
//#endregion
|
|
813
858
|
//#region src/data/createRestResourceHandlers.ts
|
|
814
|
-
function
|
|
859
|
+
function Kt(e) {
|
|
815
860
|
return {
|
|
816
861
|
async getList(t) {
|
|
817
862
|
return e.list(t);
|
|
818
863
|
},
|
|
819
|
-
async getOne(t) {
|
|
820
|
-
return { data: await e.retrieve(t) };
|
|
864
|
+
async getOne(t, n) {
|
|
865
|
+
return { data: await e.retrieve(t, n) };
|
|
821
866
|
},
|
|
822
867
|
async create(t) {
|
|
823
|
-
let n = e.transformCreate ? e.transformCreate(t) : t;
|
|
868
|
+
let n = t instanceof FormData ? t : e.transformCreate ? e.transformCreate(t) : t;
|
|
824
869
|
return { data: await e.create(n) };
|
|
825
870
|
},
|
|
826
871
|
async update({ id: t, data: n }) {
|
|
827
|
-
let r = e.transformUpdate ? e.transformUpdate(n) : n;
|
|
872
|
+
let r = n instanceof FormData ? n : e.transformUpdate ? e.transformUpdate(n) : n;
|
|
828
873
|
return { data: await e.update(t, r) };
|
|
829
874
|
},
|
|
830
875
|
async delete(t) {
|
|
@@ -834,24 +879,24 @@ function It(e) {
|
|
|
834
879
|
}
|
|
835
880
|
//#endregion
|
|
836
881
|
//#region src/data/sortHelpers.ts
|
|
837
|
-
function
|
|
882
|
+
function qt(e) {
|
|
838
883
|
return e ? Array.isArray(e) ? e : [e] : [];
|
|
839
884
|
}
|
|
840
|
-
function
|
|
841
|
-
let t =
|
|
885
|
+
function Jt(e) {
|
|
886
|
+
let t = qt(e);
|
|
842
887
|
if (t.length !== 0) return t.map((e) => e.order === "DESC" ? `-${e.field}` : e.field).join(",");
|
|
843
888
|
}
|
|
844
|
-
function
|
|
845
|
-
let t =
|
|
889
|
+
function Yt(e) {
|
|
890
|
+
let t = qt(e);
|
|
846
891
|
if (t.length !== 0) return t.map((e) => `${e.field} ${e.order === "DESC" ? "desc" : "asc"}`).join(",");
|
|
847
892
|
}
|
|
848
|
-
function
|
|
849
|
-
let t =
|
|
893
|
+
function Xt(e) {
|
|
894
|
+
let t = qt(e);
|
|
850
895
|
if (t.length !== 0) return t.map((e) => e.order === "DESC" ? `-${e.field}` : e.field).join(",");
|
|
851
896
|
}
|
|
852
897
|
//#endregion
|
|
853
898
|
//#region src/components/AuthAlternateLink.tsx
|
|
854
|
-
function
|
|
899
|
+
function Zt({ prompt: e, linkText: t, to: n }) {
|
|
855
900
|
return /* @__PURE__ */ H(R.Paragraph, {
|
|
856
901
|
type: "secondary",
|
|
857
902
|
style: {
|
|
@@ -870,7 +915,7 @@ function Vt({ prompt: e, linkText: t, to: n }) {
|
|
|
870
915
|
}
|
|
871
916
|
//#endregion
|
|
872
917
|
//#region src/layouts/AuthPageLayout.tsx
|
|
873
|
-
function
|
|
918
|
+
function Qt({ children: e, brand: t, footer: n, showThemeToolbar: r = !0 }) {
|
|
874
919
|
let { token: i } = z.useToken();
|
|
875
920
|
return /* @__PURE__ */ H(E, {
|
|
876
921
|
vertical: !0,
|
|
@@ -891,7 +936,7 @@ function Ht({ children: e, brand: t, footer: n, showThemeToolbar: r = !0 }) {
|
|
|
891
936
|
padding: 16,
|
|
892
937
|
background: i.colorBgLayout
|
|
893
938
|
},
|
|
894
|
-
children: /* @__PURE__ */ V(
|
|
939
|
+
children: /* @__PURE__ */ V(ze, {})
|
|
895
940
|
}) : null,
|
|
896
941
|
t ? /* @__PURE__ */ V("div", {
|
|
897
942
|
style: {
|
|
@@ -928,11 +973,11 @@ function Ht({ children: e, brand: t, footer: n, showThemeToolbar: r = !0 }) {
|
|
|
928
973
|
}
|
|
929
974
|
//#endregion
|
|
930
975
|
//#region src/pages/LoginPage.tsx
|
|
931
|
-
function
|
|
932
|
-
let { login: l } =
|
|
933
|
-
return /* @__PURE__ */ V(
|
|
976
|
+
function $t({ 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 }) {
|
|
977
|
+
let { login: l } = He(), u = g();
|
|
978
|
+
return /* @__PURE__ */ V(Qt, {
|
|
934
979
|
brand: r ?? n,
|
|
935
|
-
footer: c ?? (s ? /* @__PURE__ */ V(
|
|
980
|
+
footer: c ?? (s ? /* @__PURE__ */ V(Zt, {
|
|
936
981
|
prompt: s.prompt ?? "Don't have an account?",
|
|
937
982
|
linkText: s.linkText,
|
|
938
983
|
to: s.to
|
|
@@ -965,7 +1010,7 @@ function Ut({ title: e = "Sign in", description: t = "Use any username and passw
|
|
|
965
1010
|
required: !0,
|
|
966
1011
|
message: "Required"
|
|
967
1012
|
}],
|
|
968
|
-
children: /* @__PURE__ */ V(
|
|
1013
|
+
children: /* @__PURE__ */ V(A, { autoComplete: "username" })
|
|
969
1014
|
}),
|
|
970
1015
|
/* @__PURE__ */ V(D.Item, {
|
|
971
1016
|
name: "password",
|
|
@@ -974,7 +1019,7 @@ function Ut({ title: e = "Sign in", description: t = "Use any username and passw
|
|
|
974
1019
|
required: !0,
|
|
975
1020
|
message: "Required"
|
|
976
1021
|
}],
|
|
977
|
-
children: /* @__PURE__ */ V(
|
|
1022
|
+
children: /* @__PURE__ */ V(A.Password, { autoComplete: "current-password" })
|
|
978
1023
|
}),
|
|
979
1024
|
i,
|
|
980
1025
|
/* @__PURE__ */ V(D.Item, {
|
|
@@ -993,7 +1038,7 @@ function Ut({ title: e = "Sign in", description: t = "Use any username and passw
|
|
|
993
1038
|
}
|
|
994
1039
|
//#endregion
|
|
995
1040
|
//#region src/pages/PlaceholderPage.tsx
|
|
996
|
-
function
|
|
1041
|
+
function en({ title: e }) {
|
|
997
1042
|
return /* @__PURE__ */ V(R.Title, {
|
|
998
1043
|
level: 3,
|
|
999
1044
|
style: { marginTop: 0 },
|
|
@@ -1002,7 +1047,7 @@ function Wt({ title: e }) {
|
|
|
1002
1047
|
}
|
|
1003
1048
|
//#endregion
|
|
1004
1049
|
//#region src/crud/utils/sortQueryParam.ts
|
|
1005
|
-
function
|
|
1050
|
+
function tn(e) {
|
|
1006
1051
|
if (!e) return [];
|
|
1007
1052
|
let t = [];
|
|
1008
1053
|
for (let n of e.split(",").map((e) => e.trim()).filter(Boolean)) {
|
|
@@ -1026,17 +1071,17 @@ function Gt(e) {
|
|
|
1026
1071
|
}
|
|
1027
1072
|
return t;
|
|
1028
1073
|
}
|
|
1029
|
-
function
|
|
1074
|
+
function nn(e) {
|
|
1030
1075
|
return e.length === 0 ? null : e.map((e) => e.order === "DESC" ? `-${e.field}` : e.field).join(",");
|
|
1031
1076
|
}
|
|
1032
|
-
function
|
|
1077
|
+
function rn(e) {
|
|
1033
1078
|
return new Map(e.map((e, t) => [e.field, t + 1]));
|
|
1034
1079
|
}
|
|
1035
1080
|
//#endregion
|
|
1036
1081
|
//#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(() =>
|
|
1082
|
+
var an = t(null);
|
|
1083
|
+
function on({ children: e, toggleSort: t, sort: n }) {
|
|
1084
|
+
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(() => rn(n), [n]), d = i((e) => (a((t) => {
|
|
1040
1085
|
let n = t.findIndex((t) => t.key === e.key);
|
|
1041
1086
|
if (n < 0) return [...t, e];
|
|
1042
1087
|
if (t[n] === e) return t;
|
|
@@ -1059,24 +1104,24 @@ function Yt({ children: e, toggleSort: t, sort: n }) {
|
|
|
1059
1104
|
u,
|
|
1060
1105
|
d
|
|
1061
1106
|
]);
|
|
1062
|
-
return /* @__PURE__ */ V(
|
|
1107
|
+
return /* @__PURE__ */ V(an.Provider, {
|
|
1063
1108
|
value: f,
|
|
1064
1109
|
children: e
|
|
1065
1110
|
});
|
|
1066
1111
|
}
|
|
1067
|
-
function
|
|
1068
|
-
let e = a(
|
|
1112
|
+
function sn() {
|
|
1113
|
+
let e = a(an);
|
|
1069
1114
|
if (!e) throw Error("Column components must be used within ResourceList");
|
|
1070
1115
|
return e;
|
|
1071
1116
|
}
|
|
1072
1117
|
function X(e) {
|
|
1073
|
-
let { registerColumn: t } =
|
|
1118
|
+
let { registerColumn: t } = sn();
|
|
1074
1119
|
o(() => t(e), [t, e]);
|
|
1075
1120
|
}
|
|
1076
1121
|
//#endregion
|
|
1077
1122
|
//#region src/crud/context/FilterContext.tsx
|
|
1078
|
-
var
|
|
1079
|
-
function
|
|
1123
|
+
var cn = t(null);
|
|
1124
|
+
function ln({ children: e, values: t, setFilterValue: n }) {
|
|
1080
1125
|
let [r, a] = l([]), o = i((e) => (a((t) => {
|
|
1081
1126
|
let n = t.findIndex((t) => t.key === e.key);
|
|
1082
1127
|
if (n < 0) return [...t, e];
|
|
@@ -1096,25 +1141,25 @@ function Qt({ children: e, values: t, setFilterValue: n }) {
|
|
|
1096
1141
|
n,
|
|
1097
1142
|
o
|
|
1098
1143
|
]);
|
|
1099
|
-
return /* @__PURE__ */ V(
|
|
1144
|
+
return /* @__PURE__ */ V(cn.Provider, {
|
|
1100
1145
|
value: c,
|
|
1101
1146
|
children: e
|
|
1102
1147
|
});
|
|
1103
1148
|
}
|
|
1104
|
-
function
|
|
1105
|
-
return a(
|
|
1149
|
+
function un() {
|
|
1150
|
+
return a(cn);
|
|
1106
1151
|
}
|
|
1107
1152
|
function Z(e) {
|
|
1108
|
-
let t =
|
|
1153
|
+
let t = un()?.registerFilter;
|
|
1109
1154
|
o(() => {
|
|
1110
1155
|
if (t) return t(e);
|
|
1111
1156
|
}, [t, e]);
|
|
1112
1157
|
}
|
|
1113
1158
|
//#endregion
|
|
1114
1159
|
//#region src/crud/context/FormContext.tsx
|
|
1115
|
-
var
|
|
1116
|
-
function
|
|
1117
|
-
return /* @__PURE__ */ V(
|
|
1160
|
+
var dn = t(null);
|
|
1161
|
+
function fn({ children: e, resource: t, isNew: n, disabled: r }) {
|
|
1162
|
+
return /* @__PURE__ */ V(dn.Provider, {
|
|
1118
1163
|
value: {
|
|
1119
1164
|
resource: t,
|
|
1120
1165
|
isNew: n,
|
|
@@ -1123,56 +1168,60 @@ function tn({ children: e, resource: t, isNew: n, disabled: r }) {
|
|
|
1123
1168
|
children: e
|
|
1124
1169
|
});
|
|
1125
1170
|
}
|
|
1126
|
-
function
|
|
1127
|
-
return a(
|
|
1171
|
+
function pn() {
|
|
1172
|
+
return a(dn);
|
|
1128
1173
|
}
|
|
1129
1174
|
//#endregion
|
|
1130
1175
|
//#region src/crud/context/FormSectionContext.tsx
|
|
1131
|
-
var
|
|
1132
|
-
function
|
|
1133
|
-
return /* @__PURE__ */ V(
|
|
1176
|
+
var mn = t(null);
|
|
1177
|
+
function hn({ sourcesRef: e, children: t }) {
|
|
1178
|
+
return /* @__PURE__ */ V(mn.Provider, {
|
|
1134
1179
|
value: e,
|
|
1135
1180
|
children: t
|
|
1136
1181
|
});
|
|
1137
1182
|
}
|
|
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,
|
|
1183
|
+
function gn() {
|
|
1184
|
+
return a(mn);
|
|
1185
|
+
}
|
|
1186
|
+
//#endregion
|
|
1187
|
+
//#region src/crud/context/PayloadFieldsContext.tsx
|
|
1188
|
+
var _n = t(null);
|
|
1189
|
+
function vn({ children: e, fieldsRef: t }) {
|
|
1190
|
+
return /* @__PURE__ */ V(_n.Provider, {
|
|
1191
|
+
value: t,
|
|
1153
1192
|
children: e
|
|
1154
1193
|
});
|
|
1155
1194
|
}
|
|
1156
|
-
function
|
|
1157
|
-
return a(
|
|
1195
|
+
function yn() {
|
|
1196
|
+
return a(_n);
|
|
1158
1197
|
}
|
|
1159
|
-
function
|
|
1160
|
-
let
|
|
1198
|
+
function bn(e, t = !0) {
|
|
1199
|
+
let n = yn();
|
|
1161
1200
|
o(() => {
|
|
1162
|
-
if (!t) return
|
|
1163
|
-
|
|
1164
|
-
return n?.current.add(e), () => {
|
|
1165
|
-
r(), n?.current.delete(e);
|
|
1201
|
+
if (!(!t || !n)) return n.current.add(e), () => {
|
|
1202
|
+
n.current.delete(e);
|
|
1166
1203
|
};
|
|
1167
1204
|
}, [
|
|
1168
|
-
t,
|
|
1169
1205
|
n,
|
|
1170
|
-
e
|
|
1206
|
+
e,
|
|
1207
|
+
t
|
|
1208
|
+
]);
|
|
1209
|
+
}
|
|
1210
|
+
function xn(e, t = !0) {
|
|
1211
|
+
let n = gn();
|
|
1212
|
+
o(() => {
|
|
1213
|
+
if (!(!t || !n)) return n.current.add(e), () => {
|
|
1214
|
+
n.current.delete(e);
|
|
1215
|
+
};
|
|
1216
|
+
}, [
|
|
1217
|
+
n,
|
|
1218
|
+
e,
|
|
1219
|
+
t
|
|
1171
1220
|
]);
|
|
1172
1221
|
}
|
|
1173
1222
|
//#endregion
|
|
1174
|
-
//#region src/crud/utils/
|
|
1175
|
-
function
|
|
1223
|
+
//#region src/crud/utils/getFormValue.ts
|
|
1224
|
+
function Sn(e, t) {
|
|
1176
1225
|
let n = t.split("."), r = e;
|
|
1177
1226
|
for (let e of n) {
|
|
1178
1227
|
if (typeof r != "object" || !r) return;
|
|
@@ -1181,8 +1230,8 @@ function dn(e, t) {
|
|
|
1181
1230
|
return r;
|
|
1182
1231
|
}
|
|
1183
1232
|
//#endregion
|
|
1184
|
-
//#region src/crud/utils/
|
|
1185
|
-
function
|
|
1233
|
+
//#region src/crud/utils/setFormValue.ts
|
|
1234
|
+
function Cn(e, t, n) {
|
|
1186
1235
|
let r = t.split("."), i = e;
|
|
1187
1236
|
for (let e = 0; e < r.length - 1; e++) {
|
|
1188
1237
|
let t = r[e], n = i[t];
|
|
@@ -1191,23 +1240,101 @@ function fn(e, t, n) {
|
|
|
1191
1240
|
i[r[r.length - 1]] = n;
|
|
1192
1241
|
}
|
|
1193
1242
|
//#endregion
|
|
1194
|
-
//#region src/crud/utils/
|
|
1195
|
-
function
|
|
1243
|
+
//#region src/crud/utils/buildFormPayload.ts
|
|
1244
|
+
function wn(e, t) {
|
|
1196
1245
|
if (t.length === 0) return { ...e };
|
|
1197
1246
|
let n = {};
|
|
1198
1247
|
for (let r of t) {
|
|
1199
|
-
let t =
|
|
1200
|
-
t !== void 0 &&
|
|
1248
|
+
let t = Sn(e, r);
|
|
1249
|
+
t !== void 0 && Cn(n, r, t);
|
|
1201
1250
|
}
|
|
1202
1251
|
return n;
|
|
1203
1252
|
}
|
|
1204
1253
|
//#endregion
|
|
1254
|
+
//#region src/crud/utils/buildInlineRowsPayload.ts
|
|
1255
|
+
function Tn(e, t, n) {
|
|
1256
|
+
if (!Array.isArray(e)) return [];
|
|
1257
|
+
let r = e.map((e) => {
|
|
1258
|
+
if (!e || typeof e != "object") return {};
|
|
1259
|
+
let n = e, r = {};
|
|
1260
|
+
for (let e of t) {
|
|
1261
|
+
let t = n[e];
|
|
1262
|
+
t !== void 0 && (r[e] = t);
|
|
1263
|
+
}
|
|
1264
|
+
let i = n.id;
|
|
1265
|
+
return i != null && (r.id = i), r;
|
|
1266
|
+
});
|
|
1267
|
+
return n?.transformRows ? n.transformRows(r) : r;
|
|
1268
|
+
}
|
|
1269
|
+
//#endregion
|
|
1270
|
+
//#region src/crud/utils/hasUploadValues.ts
|
|
1271
|
+
function En(e) {
|
|
1272
|
+
return e instanceof Blob ? !0 : Array.isArray(e) ? e.some(En) : e && typeof e == "object" ? Object.values(e).some(En) : !1;
|
|
1273
|
+
}
|
|
1274
|
+
//#endregion
|
|
1275
|
+
//#region src/crud/utils/toFormData.ts
|
|
1276
|
+
function Dn(e) {
|
|
1277
|
+
return /^https?:\/\//i.test(e);
|
|
1278
|
+
}
|
|
1279
|
+
function On(e, t, n, r) {
|
|
1280
|
+
if (n !== void 0) {
|
|
1281
|
+
if (n === null) {
|
|
1282
|
+
e.append(t, "");
|
|
1283
|
+
return;
|
|
1284
|
+
}
|
|
1285
|
+
if (n instanceof Blob) {
|
|
1286
|
+
e.append(t, n);
|
|
1287
|
+
return;
|
|
1288
|
+
}
|
|
1289
|
+
if (typeof n == "boolean" || typeof n == "number") {
|
|
1290
|
+
e.append(t, String(n));
|
|
1291
|
+
return;
|
|
1292
|
+
}
|
|
1293
|
+
if (typeof n == "string") {
|
|
1294
|
+
if (r.skipExistingUploadUrls && Dn(n)) return;
|
|
1295
|
+
e.append(t, n);
|
|
1296
|
+
return;
|
|
1297
|
+
}
|
|
1298
|
+
if (Array.isArray(n)) {
|
|
1299
|
+
n.forEach((n, i) => {
|
|
1300
|
+
On(e, `${t}[${i}]`, n, r);
|
|
1301
|
+
});
|
|
1302
|
+
return;
|
|
1303
|
+
}
|
|
1304
|
+
if (typeof n == "object") {
|
|
1305
|
+
for (let [i, a] of Object.entries(n)) On(e, `${t}[${i}]`, a, r);
|
|
1306
|
+
return;
|
|
1307
|
+
}
|
|
1308
|
+
e.append(t, String(n));
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
function kn(e, t) {
|
|
1312
|
+
let n = { skipExistingUploadUrls: t?.skipExistingUploadUrls ?? !0 }, r = new FormData();
|
|
1313
|
+
for (let [t, i] of Object.entries(e)) On(r, t, i, n);
|
|
1314
|
+
return r;
|
|
1315
|
+
}
|
|
1316
|
+
//#endregion
|
|
1317
|
+
//#region src/crud/utils/prepareFormSubmitBody.ts
|
|
1318
|
+
function An(e, t) {
|
|
1319
|
+
return En(e) ? kn(e, t) : e;
|
|
1320
|
+
}
|
|
1321
|
+
//#endregion
|
|
1322
|
+
//#region src/crud/utils/buildResourceFormSubmitBody.ts
|
|
1323
|
+
function jn(e, t, n, r) {
|
|
1324
|
+
let i = wn(e, t);
|
|
1325
|
+
if (n) for (let t of n) {
|
|
1326
|
+
let n = e[t.field], r = t.payloadKey ?? t.field;
|
|
1327
|
+
i[r] = Tn(n, t.sources, { transformRows: t.transformRows });
|
|
1328
|
+
}
|
|
1329
|
+
return An(i, r);
|
|
1330
|
+
}
|
|
1331
|
+
//#endregion
|
|
1205
1332
|
//#region src/crud/utils/formErrors.ts
|
|
1206
|
-
function
|
|
1333
|
+
function Mn(e) {
|
|
1207
1334
|
return e ? Array.isArray(e) ? e : [e] : [];
|
|
1208
1335
|
}
|
|
1209
|
-
function
|
|
1210
|
-
for (let e of
|
|
1336
|
+
function Nn(e, t, n) {
|
|
1337
|
+
for (let e of Mn(t.global)) n.error(e);
|
|
1211
1338
|
for (let [n, r] of Object.entries(t.fields ?? {})) {
|
|
1212
1339
|
let t = Array.isArray(r) ? r.join(", ") : r;
|
|
1213
1340
|
e.setError(n, {
|
|
@@ -1216,71 +1343,80 @@ function hn(e, t, n) {
|
|
|
1216
1343
|
});
|
|
1217
1344
|
}
|
|
1218
1345
|
}
|
|
1219
|
-
function
|
|
1220
|
-
let a = e.parseFormError?.(
|
|
1221
|
-
if (!
|
|
1222
|
-
let
|
|
1223
|
-
return !
|
|
1346
|
+
async function Pn(e, t, n, r, i) {
|
|
1347
|
+
let a = await Dt(r), o = a == null ? r : { body: a }, s = e.parseFormError?.(o, i);
|
|
1348
|
+
if (!s) return !1;
|
|
1349
|
+
let c = Object.keys(s.fields ?? {}).length > 0, l = Mn(s.global).length > 0;
|
|
1350
|
+
return !c && !l ? !1 : (Nn(t, s, n), !0);
|
|
1351
|
+
}
|
|
1352
|
+
//#endregion
|
|
1353
|
+
//#region src/crud/utils/useAbortableEffect.ts
|
|
1354
|
+
function Fn(e, t) {
|
|
1355
|
+
o(() => {
|
|
1356
|
+
let t = new AbortController();
|
|
1357
|
+
return e(t.signal), () => t.abort();
|
|
1358
|
+
}, t);
|
|
1224
1359
|
}
|
|
1225
1360
|
//#endregion
|
|
1226
1361
|
//#region src/crud/ResourceFormModal.tsx
|
|
1227
|
-
function
|
|
1228
|
-
let
|
|
1229
|
-
if (
|
|
1230
|
-
|
|
1362
|
+
function In({ resource: e, editId: t, onClose: n, children: r, title: a }) {
|
|
1363
|
+
let o = t === "new" || t == null, s = t != null, u = yt(), { message: d } = y.useApp(), [f, p] = l(!o), m = Ce(), h = c(/* @__PURE__ */ new Set()), g = i(async (n) => {
|
|
1364
|
+
if (o || !t) {
|
|
1365
|
+
m.reset({}), p(!1);
|
|
1231
1366
|
return;
|
|
1232
1367
|
}
|
|
1233
|
-
|
|
1368
|
+
p(!0);
|
|
1234
1369
|
try {
|
|
1235
|
-
let
|
|
1236
|
-
|
|
1370
|
+
let r = await u.getOne(e, t, { signal: n });
|
|
1371
|
+
if (n?.aborted) return;
|
|
1372
|
+
m.reset(r.data);
|
|
1237
1373
|
} catch (e) {
|
|
1238
|
-
|
|
1374
|
+
St(e) || d.error(e instanceof Error ? e.message : "Load failed");
|
|
1239
1375
|
} finally {
|
|
1240
|
-
|
|
1376
|
+
n?.aborted || p(!1);
|
|
1241
1377
|
}
|
|
1242
1378
|
}, [
|
|
1243
|
-
|
|
1379
|
+
u,
|
|
1244
1380
|
e,
|
|
1245
1381
|
t,
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1382
|
+
o,
|
|
1383
|
+
m,
|
|
1384
|
+
d
|
|
1249
1385
|
]);
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
}, [
|
|
1253
|
-
async function
|
|
1386
|
+
Fn((e) => {
|
|
1387
|
+
if (s) return g(e);
|
|
1388
|
+
}, [s, g]);
|
|
1389
|
+
async function _(r) {
|
|
1254
1390
|
try {
|
|
1255
|
-
let i =
|
|
1256
|
-
|
|
1391
|
+
let i = jn(r, Array.from(h.current));
|
|
1392
|
+
o ? (await u.create(e, i), d.success("Created")) : t && (await u.update(e, {
|
|
1257
1393
|
id: t,
|
|
1258
1394
|
data: i
|
|
1259
|
-
}),
|
|
1395
|
+
}), d.success("Updated")), n();
|
|
1260
1396
|
} catch (t) {
|
|
1261
|
-
|
|
1397
|
+
await Pn(u, m, d, t, {
|
|
1262
1398
|
resource: e,
|
|
1263
|
-
mutation:
|
|
1264
|
-
}) ||
|
|
1399
|
+
mutation: o ? "create" : "update"
|
|
1400
|
+
}) || d.error(t instanceof Error ? t.message : "Save failed");
|
|
1265
1401
|
}
|
|
1266
1402
|
}
|
|
1267
1403
|
return /* @__PURE__ */ V(M, {
|
|
1268
|
-
open:
|
|
1269
|
-
title: a ?? (
|
|
1404
|
+
open: s,
|
|
1405
|
+
title: a ?? (o ? `New ${e}` : `Edit ${e}`),
|
|
1270
1406
|
onCancel: n,
|
|
1271
1407
|
footer: null,
|
|
1272
1408
|
destroyOnHidden: !0,
|
|
1273
1409
|
width: 560,
|
|
1274
|
-
children:
|
|
1410
|
+
children: f ? /* @__PURE__ */ V(I, {}) : /* @__PURE__ */ V(fn, {
|
|
1275
1411
|
resource: e,
|
|
1276
|
-
isNew:
|
|
1277
|
-
children: /* @__PURE__ */ V(
|
|
1278
|
-
|
|
1279
|
-
children: /* @__PURE__ */ V(
|
|
1280
|
-
...
|
|
1412
|
+
isNew: o,
|
|
1413
|
+
children: /* @__PURE__ */ V(vn, {
|
|
1414
|
+
fieldsRef: h,
|
|
1415
|
+
children: /* @__PURE__ */ V(W, {
|
|
1416
|
+
...m,
|
|
1281
1417
|
children: /* @__PURE__ */ H(D, {
|
|
1282
1418
|
layout: "vertical",
|
|
1283
|
-
onFinish: () => void
|
|
1419
|
+
onFinish: () => void m.handleSubmit(_)(),
|
|
1284
1420
|
children: [r, /* @__PURE__ */ H(D.Item, {
|
|
1285
1421
|
style: {
|
|
1286
1422
|
marginTop: 16,
|
|
@@ -1304,7 +1440,7 @@ function _n({ resource: e, editId: t, onClose: n, children: r, title: a }) {
|
|
|
1304
1440
|
}
|
|
1305
1441
|
//#endregion
|
|
1306
1442
|
//#region src/crud/ListActionsBar.tsx
|
|
1307
|
-
function
|
|
1443
|
+
function Ln({ selectedCount: e, total: t, allPageSelected: n, allMatchingSelected: r, onSelectAllMatching: a, onClearSelection: o, actions: c, onExecute: u, selectedIds: d, running: f = !1 }) {
|
|
1308
1444
|
let [p, m] = l(), h = s(() => c.map((e) => ({
|
|
1309
1445
|
value: e.key,
|
|
1310
1446
|
label: e.label
|
|
@@ -1388,14 +1524,14 @@ function vn({ selectedCount: e, total: t, allPageSelected: n, allMatchingSelecte
|
|
|
1388
1524
|
}
|
|
1389
1525
|
//#endregion
|
|
1390
1526
|
//#region src/crud/types.ts
|
|
1391
|
-
var
|
|
1527
|
+
var Rn = new Set([
|
|
1392
1528
|
"page",
|
|
1393
1529
|
"perPage",
|
|
1394
1530
|
"sort",
|
|
1395
1531
|
"create",
|
|
1396
1532
|
"edit"
|
|
1397
|
-
]),
|
|
1398
|
-
function
|
|
1533
|
+
]), zn = 1, Bn = 10;
|
|
1534
|
+
function Vn(e) {
|
|
1399
1535
|
if (e.includes(",")) {
|
|
1400
1536
|
let t = e.split(",").map((e) => e.trim()), n = t.map(Number);
|
|
1401
1537
|
return n.every((e) => Number.isFinite(e)) ? n : t;
|
|
@@ -1403,16 +1539,16 @@ function Sn(e) {
|
|
|
1403
1539
|
let t = Number(e);
|
|
1404
1540
|
return e !== "" && Number.isFinite(t) && String(t) === e ? t : e === "true" ? !0 : e === "false" ? !1 : e;
|
|
1405
1541
|
}
|
|
1406
|
-
function
|
|
1542
|
+
function Hn(e) {
|
|
1407
1543
|
return e == null || e === "" ? null : Array.isArray(e) ? e.length === 0 ? null : e.map(String).join(",") : String(e);
|
|
1408
1544
|
}
|
|
1409
|
-
function
|
|
1545
|
+
function Un(e) {
|
|
1410
1546
|
let [t, n] = v(), r = s(() => {
|
|
1411
|
-
let n = t.get("page"), r = t.get("perPage"), i = n ? Math.max(1, Number(n) ||
|
|
1547
|
+
let n = t.get("page"), r = t.get("perPage"), i = n ? Math.max(1, Number(n) || zn) : zn, a = r ? Math.max(1, Number(r) || Bn) : Bn, o = t.getAll("sort"), s = o.length > 0 ? o.flatMap((e) => tn(e)) : tn(t.get("sort")), c = { ...e };
|
|
1412
1548
|
return t.forEach((e, n) => {
|
|
1413
|
-
if (
|
|
1549
|
+
if (Rn.has(n)) return;
|
|
1414
1550
|
let r = c[n];
|
|
1415
|
-
r === void 0 ? t.getAll(n).length > 1 ? c[n] = t.getAll(n).map(
|
|
1551
|
+
r === void 0 ? t.getAll(n).length > 1 ? c[n] = t.getAll(n).map(Vn) : c[n] = Vn(e) : c[n] = [...Array.isArray(r) ? r : [r], Vn(e)];
|
|
1416
1552
|
}), {
|
|
1417
1553
|
page: i,
|
|
1418
1554
|
perPage: a,
|
|
@@ -1435,19 +1571,19 @@ function wn(e) {
|
|
|
1435
1571
|
},
|
|
1436
1572
|
setPerPage: (e) => {
|
|
1437
1573
|
a((t) => {
|
|
1438
|
-
e ===
|
|
1574
|
+
e === Bn ? t.delete("perPage") : t.set("perPage", String(e)), t.delete("page");
|
|
1439
1575
|
});
|
|
1440
1576
|
},
|
|
1441
1577
|
setSort: (e) => {
|
|
1442
1578
|
a((t) => {
|
|
1443
1579
|
t.delete("sort");
|
|
1444
|
-
let n =
|
|
1580
|
+
let n = nn(e);
|
|
1445
1581
|
n && t.set("sort", n);
|
|
1446
1582
|
});
|
|
1447
1583
|
},
|
|
1448
1584
|
toggleSort: (e) => {
|
|
1449
1585
|
a((t) => {
|
|
1450
|
-
let n = t.getAll("sort").flatMap((e) =>
|
|
1586
|
+
let n = t.getAll("sort").flatMap((e) => tn(e)), r = n.findIndex((t) => t.field === e), i;
|
|
1451
1587
|
i = r < 0 ? [...n, {
|
|
1452
1588
|
field: e,
|
|
1453
1589
|
order: "ASC"
|
|
@@ -1455,22 +1591,22 @@ function wn(e) {
|
|
|
1455
1591
|
...e,
|
|
1456
1592
|
order: "DESC"
|
|
1457
1593
|
} : e) : n.filter((e, t) => t !== r), t.delete("sort");
|
|
1458
|
-
let a =
|
|
1594
|
+
let a = nn(i);
|
|
1459
1595
|
a && t.set("sort", a);
|
|
1460
1596
|
});
|
|
1461
1597
|
},
|
|
1462
1598
|
setFilter: (e, t) => {
|
|
1463
1599
|
a((n) => {
|
|
1464
1600
|
n.delete(e);
|
|
1465
|
-
let r =
|
|
1601
|
+
let r = Hn(t);
|
|
1466
1602
|
r != null && n.set(e, r), n.delete("page");
|
|
1467
1603
|
});
|
|
1468
1604
|
},
|
|
1469
1605
|
setFilters: (e) => {
|
|
1470
1606
|
a((t) => {
|
|
1471
|
-
for (let e of [...t.keys()])
|
|
1607
|
+
for (let e of [...t.keys()]) Rn.has(e) || t.delete(e);
|
|
1472
1608
|
for (let [n, r] of Object.entries(e)) {
|
|
1473
|
-
let e =
|
|
1609
|
+
let e = Hn(r);
|
|
1474
1610
|
e != null && t.set(n, e);
|
|
1475
1611
|
}
|
|
1476
1612
|
t.delete("page");
|
|
@@ -1495,66 +1631,66 @@ function wn(e) {
|
|
|
1495
1631
|
}
|
|
1496
1632
|
//#endregion
|
|
1497
1633
|
//#region src/crud/ResourceList.tsx
|
|
1498
|
-
var
|
|
1499
|
-
function
|
|
1500
|
-
return a(
|
|
1634
|
+
var Wn = t(null);
|
|
1635
|
+
function Gn() {
|
|
1636
|
+
return a(Wn);
|
|
1501
1637
|
}
|
|
1502
|
-
function
|
|
1503
|
-
let
|
|
1504
|
-
|
|
1638
|
+
function Kn({ 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 }) {
|
|
1639
|
+
let b = yt(), C = K(), { message: w, modal: ee } = y.useApp(), { columns: T, sortOrders: E, sortPriorities: D } = sn(), [O, k] = l(!1), [A, te] = l([]), [j, ne] = l(0), [M, N] = l(() => /* @__PURE__ */ new Set()), [re, P] = l(!1), I = r ?? `${n}/new`, ie = q(C, g, "add"), ae = q(C, g, "change"), L = q(C, g, "delete"), z = ae && (a === "page" || a === "both") && c?.edit !== !1, U = ae && (a === "modal" || a === "both") && c?.quickEdit !== !1, le = L && c?.delete !== !1, ue = z || U || le || d, de = i(() => {
|
|
1640
|
+
N(/* @__PURE__ */ new Set());
|
|
1505
1641
|
}, []), fe = s(() => {
|
|
1506
|
-
if (!
|
|
1642
|
+
if (!h) return [];
|
|
1507
1643
|
let t = [];
|
|
1508
|
-
return
|
|
1644
|
+
return m && L && t.push({
|
|
1509
1645
|
key: "__delete",
|
|
1510
1646
|
label: "Delete selected",
|
|
1511
1647
|
confirm: (e) => `Delete ${e.length} selected item(s)? This cannot be undone.`,
|
|
1512
1648
|
execute: async (t, { reload: n, clearSelection: r }) => {
|
|
1513
|
-
await Promise.all(t.map((t) =>
|
|
1649
|
+
await Promise.all(t.map((t) => b.delete(e, t))), r(), n(), w.success(`Deleted ${t.length} item(s)`);
|
|
1514
1650
|
}
|
|
1515
|
-
}), [...t, ...
|
|
1651
|
+
}), [...t, ...p ?? []];
|
|
1516
1652
|
}, [
|
|
1517
|
-
g,
|
|
1518
1653
|
h,
|
|
1519
|
-
U,
|
|
1520
1654
|
m,
|
|
1521
|
-
|
|
1655
|
+
L,
|
|
1656
|
+
p,
|
|
1657
|
+
b,
|
|
1522
1658
|
e,
|
|
1523
|
-
|
|
1524
|
-
]), pe = fe.length > 0, me =
|
|
1525
|
-
|
|
1526
|
-
let n = new Set(t), r =
|
|
1659
|
+
w
|
|
1660
|
+
]), pe = fe.length > 0, me = M.size, he = A.length > 0 && A.every((e) => M.has(e.id)), ge = j > 0 && me >= j, _e = s(() => A.filter((e) => M.has(e.id)).map((e) => e.id), [A, M]), ve = i((e) => {
|
|
1661
|
+
N((t) => {
|
|
1662
|
+
let n = new Set(t), r = A.map((e) => e.id);
|
|
1527
1663
|
for (let t of r) e.includes(t) || n.delete(t);
|
|
1528
1664
|
for (let t of e) n.add(t);
|
|
1529
1665
|
return n;
|
|
1530
1666
|
});
|
|
1531
|
-
}, [
|
|
1532
|
-
if (!(
|
|
1533
|
-
|
|
1667
|
+
}, [A]), ye = i(async () => {
|
|
1668
|
+
if (!(j <= 0)) {
|
|
1669
|
+
P(!0);
|
|
1534
1670
|
try {
|
|
1535
|
-
let t =
|
|
1671
|
+
let t = _.sort.length === 0 ? void 0 : _.sort.length === 1 ? _.sort[0] : _.sort, n = await b.getList(e, {
|
|
1536
1672
|
pagination: {
|
|
1537
1673
|
page: 1,
|
|
1538
|
-
perPage:
|
|
1674
|
+
perPage: j
|
|
1539
1675
|
},
|
|
1540
1676
|
sort: t,
|
|
1541
|
-
filter:
|
|
1677
|
+
filter: _.filter
|
|
1542
1678
|
});
|
|
1543
|
-
|
|
1679
|
+
N(new Set(n.data.map((e) => e.id)));
|
|
1544
1680
|
} catch (e) {
|
|
1545
|
-
|
|
1681
|
+
w.error(e instanceof Error ? e.message : "Load failed");
|
|
1546
1682
|
} finally {
|
|
1547
|
-
|
|
1683
|
+
P(!1);
|
|
1548
1684
|
}
|
|
1549
1685
|
}
|
|
1550
1686
|
}, [
|
|
1551
|
-
|
|
1687
|
+
b,
|
|
1552
1688
|
e,
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
]),
|
|
1689
|
+
j,
|
|
1690
|
+
_.sort,
|
|
1691
|
+
_.filter,
|
|
1692
|
+
w
|
|
1693
|
+
]), be = i((e) => {
|
|
1558
1694
|
let t = (e) => {
|
|
1559
1695
|
let t = e?.columnKey ?? e?.field;
|
|
1560
1696
|
return t == null ? null : String(Array.isArray(t) ? t[0] : t);
|
|
@@ -1563,50 +1699,55 @@ function Dn({ resource: e, title: t, pathPrefix: n, newPath: r, editMode: a = "p
|
|
|
1563
1699
|
let n = e.find((e) => e?.order);
|
|
1564
1700
|
if (n) {
|
|
1565
1701
|
let e = t(n);
|
|
1566
|
-
e &&
|
|
1702
|
+
e && v.toggleSort(e);
|
|
1567
1703
|
return;
|
|
1568
1704
|
}
|
|
1569
|
-
|
|
1705
|
+
_.sort.length > 0 && v.setSort([]);
|
|
1570
1706
|
return;
|
|
1571
1707
|
}
|
|
1572
1708
|
let n = t(e);
|
|
1573
1709
|
if (n) {
|
|
1574
|
-
|
|
1710
|
+
v.toggleSort(n);
|
|
1575
1711
|
return;
|
|
1576
1712
|
}
|
|
1577
|
-
!e?.order &&
|
|
1578
|
-
}, [
|
|
1579
|
-
|
|
1713
|
+
!e?.order && _.sort.length > 0 && v.setSort([]);
|
|
1714
|
+
}, [v, _.sort.length]), xe = s(() => {
|
|
1715
|
+
let e = _.sort.length === 0 ? void 0 : _.sort.length === 1 ? _.sort[0] : _.sort;
|
|
1716
|
+
return {
|
|
1717
|
+
pagination: {
|
|
1718
|
+
page: _.page,
|
|
1719
|
+
perPage: _.perPage
|
|
1720
|
+
},
|
|
1721
|
+
sort: e,
|
|
1722
|
+
filter: _.filter
|
|
1723
|
+
};
|
|
1724
|
+
}, [_]), W = i(async (t) => {
|
|
1725
|
+
k(!0);
|
|
1580
1726
|
try {
|
|
1581
|
-
let
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
perPage: v.perPage
|
|
1585
|
-
},
|
|
1586
|
-
sort: t,
|
|
1587
|
-
filter: v.filter
|
|
1727
|
+
let n = await b.getList(e, {
|
|
1728
|
+
...xe,
|
|
1729
|
+
signal: t
|
|
1588
1730
|
});
|
|
1731
|
+
if (t?.aborted) return;
|
|
1589
1732
|
te(n.data), ne(n.total);
|
|
1590
1733
|
} catch (e) {
|
|
1591
|
-
|
|
1734
|
+
St(e) || w.error(e instanceof Error ? e.message : "Load failed");
|
|
1592
1735
|
} finally {
|
|
1593
|
-
|
|
1736
|
+
t?.aborted || k(!1);
|
|
1594
1737
|
}
|
|
1595
1738
|
}, [
|
|
1596
|
-
|
|
1739
|
+
b,
|
|
1597
1740
|
e,
|
|
1598
|
-
|
|
1599
|
-
|
|
1741
|
+
xe,
|
|
1742
|
+
w
|
|
1600
1743
|
]);
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
let be = s(() => ({
|
|
1605
|
-
reload: () => void K(),
|
|
1744
|
+
Fn((e) => W(e), [W]);
|
|
1745
|
+
let Se = s(() => ({
|
|
1746
|
+
reload: () => void W(),
|
|
1606
1747
|
clearSelection: de
|
|
1607
|
-
}), [
|
|
1748
|
+
}), [W, de]), Ce = i(async (e, t) => {
|
|
1608
1749
|
if (e.confirm) {
|
|
1609
|
-
let n = typeof e.confirm == "function" ? await e.confirm(t,
|
|
1750
|
+
let n = typeof e.confirm == "function" ? await e.confirm(t, Se) : e.confirm;
|
|
1610
1751
|
if (n === !1 || !await new Promise((t) => {
|
|
1611
1752
|
ee.confirm({
|
|
1612
1753
|
title: n,
|
|
@@ -1616,35 +1757,35 @@ function Dn({ resource: e, title: t, pathPrefix: n, newPath: r, editMode: a = "p
|
|
|
1616
1757
|
});
|
|
1617
1758
|
})) return;
|
|
1618
1759
|
}
|
|
1619
|
-
|
|
1760
|
+
P(!0);
|
|
1620
1761
|
try {
|
|
1621
|
-
await e.execute(t,
|
|
1762
|
+
await e.execute(t, Se);
|
|
1622
1763
|
} catch (e) {
|
|
1623
|
-
|
|
1764
|
+
w.error(e instanceof Error ? e.message : "Action failed");
|
|
1624
1765
|
} finally {
|
|
1625
|
-
|
|
1766
|
+
P(!1);
|
|
1626
1767
|
}
|
|
1627
1768
|
}, [
|
|
1628
|
-
|
|
1769
|
+
Se,
|
|
1629
1770
|
ee,
|
|
1630
|
-
|
|
1631
|
-
]),
|
|
1632
|
-
if (
|
|
1633
|
-
await
|
|
1771
|
+
w
|
|
1772
|
+
]), G = i(async (t) => {
|
|
1773
|
+
if (L) try {
|
|
1774
|
+
await b.delete(e, t.id), w.success("Deleted"), W();
|
|
1634
1775
|
} catch (e) {
|
|
1635
|
-
|
|
1776
|
+
w.error(e instanceof Error ? e.message : "Delete failed");
|
|
1636
1777
|
}
|
|
1637
1778
|
}, [
|
|
1638
|
-
|
|
1639
|
-
|
|
1779
|
+
L,
|
|
1780
|
+
b,
|
|
1640
1781
|
e,
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
]),
|
|
1644
|
-
let e =
|
|
1782
|
+
W,
|
|
1783
|
+
w
|
|
1784
|
+
]), we = s(() => {
|
|
1785
|
+
let e = T.map((e) => {
|
|
1645
1786
|
let t = e.buildColumn();
|
|
1646
1787
|
if (e.sortable) {
|
|
1647
|
-
let n =
|
|
1788
|
+
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
1789
|
style: {
|
|
1649
1790
|
display: "inline-flex",
|
|
1650
1791
|
alignItems: "center",
|
|
@@ -1661,7 +1802,7 @@ function Dn({ resource: e, title: t, pathPrefix: n, newPath: r, editMode: a = "p
|
|
|
1661
1802
|
textAlign: "center"
|
|
1662
1803
|
},
|
|
1663
1804
|
children: r
|
|
1664
|
-
}), V(i === "ascend" ?
|
|
1805
|
+
}), V(i === "ascend" ? ce : se, { style: { fontSize: 11 } })]
|
|
1665
1806
|
});
|
|
1666
1807
|
return {
|
|
1667
1808
|
...t,
|
|
@@ -1674,8 +1815,8 @@ function Dn({ resource: e, title: t, pathPrefix: n, newPath: r, editMode: a = "p
|
|
|
1674
1815
|
});
|
|
1675
1816
|
if (!ue) return e;
|
|
1676
1817
|
let t = {
|
|
1677
|
-
reload: () => void
|
|
1678
|
-
openEditModal:
|
|
1818
|
+
reload: () => void W(),
|
|
1819
|
+
openEditModal: v.openEditModal
|
|
1679
1820
|
}, r = {
|
|
1680
1821
|
title: "Actions",
|
|
1681
1822
|
key: "__actions",
|
|
@@ -1684,110 +1825,111 @@ function Dn({ resource: e, title: t, pathPrefix: n, newPath: r, editMode: a = "p
|
|
|
1684
1825
|
size: "small",
|
|
1685
1826
|
wrap: !0,
|
|
1686
1827
|
children: [
|
|
1687
|
-
|
|
1828
|
+
z ? /* @__PURE__ */ V(u, {
|
|
1688
1829
|
to: `${n}/${String(r.id)}`,
|
|
1689
1830
|
children: "Edit"
|
|
1690
1831
|
}) : null,
|
|
1691
|
-
|
|
1832
|
+
U ? /* @__PURE__ */ V(x, {
|
|
1692
1833
|
type: "link",
|
|
1693
1834
|
size: "small",
|
|
1694
1835
|
style: { padding: 0 },
|
|
1695
|
-
onClick: () =>
|
|
1836
|
+
onClick: () => v.openEditModal(r.id),
|
|
1696
1837
|
children: a === "both" ? "Quick edit" : "Edit"
|
|
1697
1838
|
}) : null,
|
|
1698
1839
|
le ? /* @__PURE__ */ V(x, {
|
|
1699
1840
|
type: "link",
|
|
1700
1841
|
danger: !0,
|
|
1701
1842
|
size: "small",
|
|
1702
|
-
onClick: () => void
|
|
1843
|
+
onClick: () => void G(r),
|
|
1703
1844
|
style: { padding: 0 },
|
|
1704
1845
|
children: "Delete"
|
|
1705
1846
|
}) : null,
|
|
1706
|
-
|
|
1847
|
+
d?.(r, t)
|
|
1707
1848
|
]
|
|
1708
1849
|
})
|
|
1709
1850
|
};
|
|
1710
1851
|
return [...e, r];
|
|
1711
1852
|
}, [
|
|
1712
|
-
|
|
1853
|
+
T,
|
|
1713
1854
|
ue,
|
|
1714
|
-
|
|
1715
|
-
|
|
1855
|
+
z,
|
|
1856
|
+
U,
|
|
1716
1857
|
le,
|
|
1717
1858
|
a,
|
|
1718
1859
|
n,
|
|
1719
|
-
|
|
1860
|
+
G,
|
|
1861
|
+
E,
|
|
1720
1862
|
D,
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
]), we = c && (v.createModal || v.editId != null) && (a === "modal" || a === "both");
|
|
1863
|
+
v,
|
|
1864
|
+
d,
|
|
1865
|
+
W
|
|
1866
|
+
]), Te = o && (_.createModal || _.editId != null) && (a === "modal" || a === "both");
|
|
1726
1867
|
return /* @__PURE__ */ H(B, { children: [/* @__PURE__ */ H(S, {
|
|
1727
1868
|
title: /* @__PURE__ */ V(R.Title, {
|
|
1728
1869
|
level: 5,
|
|
1729
1870
|
style: { margin: 0 },
|
|
1730
1871
|
children: t
|
|
1731
1872
|
}),
|
|
1732
|
-
extra:
|
|
1733
|
-
to:
|
|
1873
|
+
extra: f || ie ? /* @__PURE__ */ H(F, { children: [f, ie ? a === "modal" || a === "both" ? /* @__PURE__ */ H(B, { children: [a === "both" ? /* @__PURE__ */ V(u, {
|
|
1874
|
+
to: I,
|
|
1734
1875
|
children: /* @__PURE__ */ V(x, { children: "New page" })
|
|
1735
1876
|
}) : null, /* @__PURE__ */ V(x, {
|
|
1736
1877
|
type: "primary",
|
|
1737
|
-
onClick: () =>
|
|
1878
|
+
onClick: () => v.openCreateModal(),
|
|
1738
1879
|
children: "New"
|
|
1739
1880
|
})] }) : /* @__PURE__ */ V(u, {
|
|
1740
|
-
to:
|
|
1881
|
+
to: I,
|
|
1741
1882
|
children: /* @__PURE__ */ V(x, {
|
|
1742
1883
|
type: "primary",
|
|
1743
1884
|
children: "New"
|
|
1744
1885
|
})
|
|
1745
1886
|
}) : null] }) : null,
|
|
1746
|
-
children: [pe ? /* @__PURE__ */ V(
|
|
1887
|
+
children: [pe ? /* @__PURE__ */ V(Ln, {
|
|
1747
1888
|
selectedCount: me,
|
|
1748
|
-
total:
|
|
1889
|
+
total: j,
|
|
1749
1890
|
allPageSelected: he,
|
|
1750
1891
|
allMatchingSelected: ge,
|
|
1751
1892
|
onSelectAllMatching: () => void ye(),
|
|
1752
1893
|
onClearSelection: de,
|
|
1753
1894
|
actions: fe,
|
|
1754
|
-
onExecute:
|
|
1755
|
-
selectedIds: [...
|
|
1756
|
-
running:
|
|
1757
|
-
}) : null, /* @__PURE__ */ V(
|
|
1895
|
+
onExecute: Ce,
|
|
1896
|
+
selectedIds: [...M],
|
|
1897
|
+
running: re || O
|
|
1898
|
+
}) : null, /* @__PURE__ */ V(oe, {
|
|
1758
1899
|
rowKey: "id",
|
|
1759
|
-
loading:
|
|
1760
|
-
columns:
|
|
1761
|
-
dataSource:
|
|
1900
|
+
loading: O,
|
|
1901
|
+
columns: we,
|
|
1902
|
+
dataSource: A,
|
|
1903
|
+
scroll: { x: "max-content" },
|
|
1762
1904
|
rowSelection: pe ? {
|
|
1763
1905
|
selectedRowKeys: _e,
|
|
1764
1906
|
onChange: ve,
|
|
1765
1907
|
preserveSelectedRowKeys: !0
|
|
1766
1908
|
} : void 0,
|
|
1767
1909
|
pagination: {
|
|
1768
|
-
current:
|
|
1769
|
-
pageSize:
|
|
1770
|
-
total:
|
|
1910
|
+
current: _.page,
|
|
1911
|
+
pageSize: _.perPage,
|
|
1912
|
+
total: j,
|
|
1771
1913
|
showSizeChanger: !0,
|
|
1772
1914
|
onChange: (e, t) => {
|
|
1773
|
-
|
|
1915
|
+
v.setPage(e), t && v.setPerPage(t);
|
|
1774
1916
|
}
|
|
1775
1917
|
},
|
|
1776
1918
|
onChange: (e, t, n) => {
|
|
1777
|
-
|
|
1919
|
+
be(n);
|
|
1778
1920
|
}
|
|
1779
1921
|
})]
|
|
1780
|
-
}),
|
|
1922
|
+
}), Te ? /* @__PURE__ */ V(In, {
|
|
1781
1923
|
resource: e,
|
|
1782
|
-
editId:
|
|
1924
|
+
editId: _.createModal ? "new" : _.editId,
|
|
1783
1925
|
onClose: () => {
|
|
1784
|
-
|
|
1926
|
+
v.closeModal(), W();
|
|
1785
1927
|
},
|
|
1786
|
-
children:
|
|
1928
|
+
children: o
|
|
1787
1929
|
}) : null] });
|
|
1788
1930
|
}
|
|
1789
|
-
function
|
|
1790
|
-
let [v, y] =
|
|
1931
|
+
function qn({ 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: _ }) {
|
|
1932
|
+
let [v, y] = Un(a), b = s(() => {
|
|
1791
1933
|
if (!c) return a ?? {};
|
|
1792
1934
|
let e = {};
|
|
1793
1935
|
for (let [t, n] of Object.entries(v.filter)) a && t in a || (e[t] = n);
|
|
@@ -1802,15 +1944,15 @@ function On({ resource: e, title: t, pathPrefix: n, newPath: r, staticFilter: a,
|
|
|
1802
1944
|
filterValues: b,
|
|
1803
1945
|
setFilterValue: x
|
|
1804
1946
|
}), [b, x]);
|
|
1805
|
-
return /* @__PURE__ */ V(
|
|
1947
|
+
return /* @__PURE__ */ V(Wn.Provider, {
|
|
1806
1948
|
value: S,
|
|
1807
|
-
children: /* @__PURE__ */ V(
|
|
1949
|
+
children: /* @__PURE__ */ V(ln, {
|
|
1808
1950
|
values: b,
|
|
1809
1951
|
setFilterValue: x,
|
|
1810
|
-
children: /* @__PURE__ */ H(
|
|
1952
|
+
children: /* @__PURE__ */ H(on, {
|
|
1811
1953
|
toggleSort: y.toggleSort,
|
|
1812
1954
|
sort: v.sort,
|
|
1813
|
-
children: [l, /* @__PURE__ */ V(
|
|
1955
|
+
children: [l, /* @__PURE__ */ V(Kn, {
|
|
1814
1956
|
resource: e,
|
|
1815
1957
|
title: t,
|
|
1816
1958
|
pathPrefix: n,
|
|
@@ -1833,8 +1975,8 @@ function On({ resource: e, title: t, pathPrefix: n, newPath: r, staticFilter: a,
|
|
|
1833
1975
|
}
|
|
1834
1976
|
//#endregion
|
|
1835
1977
|
//#region src/crud/FilterBar.tsx
|
|
1836
|
-
function
|
|
1837
|
-
let e =
|
|
1978
|
+
function Jn() {
|
|
1979
|
+
let e = un();
|
|
1838
1980
|
return !e || e.filters.length === 0 ? null : /* @__PURE__ */ V(F, {
|
|
1839
1981
|
wrap: !0,
|
|
1840
1982
|
size: "middle",
|
|
@@ -1853,91 +1995,258 @@ function kn() {
|
|
|
1853
1995
|
}, t.key))
|
|
1854
1996
|
});
|
|
1855
1997
|
}
|
|
1856
|
-
function
|
|
1857
|
-
return /* @__PURE__ */ H(B, { children: [e, /* @__PURE__ */ V(
|
|
1998
|
+
function Yn({ children: e }) {
|
|
1999
|
+
return /* @__PURE__ */ H(B, { children: [e, /* @__PURE__ */ V(Jn, {})] });
|
|
1858
2000
|
}
|
|
1859
2001
|
//#endregion
|
|
1860
|
-
//#region src/crud/context/
|
|
1861
|
-
var
|
|
1862
|
-
function
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
2002
|
+
//#region src/crud/context/InlineFieldsRegistry.tsx
|
|
2003
|
+
var Xn = t(null);
|
|
2004
|
+
function Zn({ children: e, registryRef: t }) {
|
|
2005
|
+
return /* @__PURE__ */ V(Xn.Provider, {
|
|
2006
|
+
value: t,
|
|
2007
|
+
children: e
|
|
2008
|
+
});
|
|
2009
|
+
}
|
|
2010
|
+
function Qn() {
|
|
2011
|
+
return a(Xn);
|
|
2012
|
+
}
|
|
2013
|
+
function $n(e, t, n, r, i = !0) {
|
|
2014
|
+
let a = Qn();
|
|
2015
|
+
o(() => {
|
|
2016
|
+
if (!(!i || !a)) return a.current.set(e, {
|
|
2017
|
+
field: e,
|
|
2018
|
+
sources: t,
|
|
2019
|
+
payloadKey: n,
|
|
2020
|
+
transformRows: r
|
|
2021
|
+
}), () => {
|
|
2022
|
+
a.current.delete(e);
|
|
2023
|
+
};
|
|
2024
|
+
}, [
|
|
2025
|
+
a,
|
|
2026
|
+
e,
|
|
2027
|
+
t,
|
|
2028
|
+
n,
|
|
2029
|
+
r,
|
|
2030
|
+
i
|
|
2031
|
+
]);
|
|
2032
|
+
}
|
|
2033
|
+
//#endregion
|
|
2034
|
+
//#region src/crud/utils/useFormRecord.ts
|
|
2035
|
+
function er({ dp: e, resource: t, id: n, isNew: r, form: a, message: o, defaultValues: s }) {
|
|
2036
|
+
let [c, u] = l(!r), [d, f] = l(0), p = i(async (i) => {
|
|
2037
|
+
if (r || !n) {
|
|
2038
|
+
s && a.reset({ ...s }), u(!1);
|
|
2039
|
+
return;
|
|
2040
|
+
}
|
|
2041
|
+
u(!0);
|
|
2042
|
+
try {
|
|
2043
|
+
let r = await e.getOne(t, n, { signal: i });
|
|
2044
|
+
if (i?.aborted) return;
|
|
2045
|
+
a.reset(r.data), f((e) => e + 1);
|
|
2046
|
+
} catch (e) {
|
|
2047
|
+
St(e) || o.error(e instanceof Error ? e.message : "Load failed");
|
|
2048
|
+
} finally {
|
|
2049
|
+
i?.aborted || u(!1);
|
|
2050
|
+
}
|
|
2051
|
+
}, [
|
|
2052
|
+
e,
|
|
1870
2053
|
t,
|
|
2054
|
+
n,
|
|
2055
|
+
r,
|
|
2056
|
+
a,
|
|
1871
2057
|
o,
|
|
1872
|
-
|
|
2058
|
+
s
|
|
1873
2059
|
]);
|
|
1874
|
-
return
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
2060
|
+
return Fn((e) => p(e), [p]), {
|
|
2061
|
+
loading: c,
|
|
2062
|
+
formVersion: d
|
|
2063
|
+
};
|
|
2064
|
+
}
|
|
2065
|
+
function tr({ dp: e, resource: t, id: n, isNew: r, form: a, message: o, navigate: s, listPath: c, payloadFieldsRef: l, inlineRegistryRef: u, onSaved: d, stayOnPage: f }) {
|
|
2066
|
+
return i(async (i) => {
|
|
2067
|
+
try {
|
|
2068
|
+
let a = jn(i, Array.from(l.current), u.current.values()), p;
|
|
2069
|
+
if (r) p = (await e.create(t, a)).data, o.success("Created");
|
|
2070
|
+
else if (n) p = (await e.update(t, {
|
|
2071
|
+
id: n,
|
|
2072
|
+
data: a
|
|
2073
|
+
})).data, o.success("Updated");
|
|
2074
|
+
else return;
|
|
2075
|
+
d?.(p), f || s(c);
|
|
2076
|
+
} catch (n) {
|
|
2077
|
+
let i = Array.from(u.current.keys());
|
|
2078
|
+
await Pn(e, a, o, n, {
|
|
2079
|
+
resource: t,
|
|
2080
|
+
mutation: r ? "create" : "update",
|
|
2081
|
+
inlineFieldPaths: i
|
|
2082
|
+
}) || o.error(n instanceof Error ? n.message : "Save failed");
|
|
2083
|
+
}
|
|
2084
|
+
}, [
|
|
2085
|
+
e,
|
|
2086
|
+
t,
|
|
2087
|
+
n,
|
|
2088
|
+
r,
|
|
2089
|
+
a,
|
|
2090
|
+
o,
|
|
2091
|
+
s,
|
|
2092
|
+
c,
|
|
2093
|
+
l,
|
|
2094
|
+
u,
|
|
2095
|
+
d,
|
|
2096
|
+
f
|
|
2097
|
+
]);
|
|
2098
|
+
}
|
|
2099
|
+
//#endregion
|
|
2100
|
+
//#region src/crud/ResourceForm.tsx
|
|
2101
|
+
function nr({ resource: e, title: t, listPath: r, children: i, defaultValues: a, onSaved: s, stayOnPage: l, permissions: d }) {
|
|
2102
|
+
let { id: f } = _(), p = f === "new" || !f, m = yt(), h = K(), v = g(), { message: b } = y.useApp(), { token: C } = z.useToken(), w = c(/* @__PURE__ */ new Set()), ee = c(/* @__PURE__ */ new Map()), T = Ce({ defaultValues: a }), { loading: E, formVersion: O } = er({
|
|
2103
|
+
dp: m,
|
|
2104
|
+
resource: e,
|
|
2105
|
+
id: f,
|
|
2106
|
+
isNew: p,
|
|
2107
|
+
form: T,
|
|
2108
|
+
message: b,
|
|
2109
|
+
defaultValues: a
|
|
2110
|
+
}), k = tr({
|
|
2111
|
+
dp: m,
|
|
2112
|
+
resource: e,
|
|
2113
|
+
id: f,
|
|
2114
|
+
isNew: p,
|
|
2115
|
+
form: T,
|
|
2116
|
+
message: b,
|
|
2117
|
+
navigate: v,
|
|
2118
|
+
listPath: r,
|
|
2119
|
+
payloadFieldsRef: w,
|
|
2120
|
+
inlineRegistryRef: ee,
|
|
2121
|
+
onSaved: s,
|
|
2122
|
+
stayOnPage: l
|
|
2123
|
+
});
|
|
2124
|
+
o(() => {
|
|
2125
|
+
d && (q(h, d, p ? "add" : "change") || v(r, { replace: !0 }));
|
|
2126
|
+
}, [
|
|
2127
|
+
d,
|
|
2128
|
+
p,
|
|
2129
|
+
h,
|
|
2130
|
+
v,
|
|
2131
|
+
r
|
|
2132
|
+
]);
|
|
2133
|
+
let A = d ? q(h, d, p ? "add" : "change") : !0;
|
|
2134
|
+
return /* @__PURE__ */ V(S, {
|
|
2135
|
+
title: /* @__PURE__ */ H(F, { children: [/* @__PURE__ */ H(u, {
|
|
2136
|
+
to: r,
|
|
2137
|
+
style: { color: C.colorText },
|
|
2138
|
+
children: [/* @__PURE__ */ V(U, {}), " Back"]
|
|
2139
|
+
}), /* @__PURE__ */ V(R.Title, {
|
|
2140
|
+
level: 5,
|
|
2141
|
+
style: { margin: 0 },
|
|
2142
|
+
children: t
|
|
2143
|
+
})] }),
|
|
2144
|
+
children: /* @__PURE__ */ V(fn, {
|
|
2145
|
+
resource: e,
|
|
2146
|
+
isNew: p,
|
|
2147
|
+
children: /* @__PURE__ */ V(vn, {
|
|
2148
|
+
fieldsRef: w,
|
|
2149
|
+
children: /* @__PURE__ */ V(Zn, {
|
|
2150
|
+
registryRef: ee,
|
|
2151
|
+
children: /* @__PURE__ */ H("div", {
|
|
2152
|
+
style: { position: "relative" },
|
|
2153
|
+
children: [E ? /* @__PURE__ */ V("div", {
|
|
2154
|
+
style: {
|
|
2155
|
+
position: "absolute",
|
|
2156
|
+
inset: 0,
|
|
2157
|
+
display: "flex",
|
|
2158
|
+
alignItems: "center",
|
|
2159
|
+
justifyContent: "center",
|
|
2160
|
+
zIndex: 1
|
|
2161
|
+
},
|
|
2162
|
+
children: /* @__PURE__ */ V(I, {})
|
|
2163
|
+
}) : null, /* @__PURE__ */ n(W, {
|
|
2164
|
+
...T,
|
|
2165
|
+
key: O
|
|
2166
|
+
}, /* @__PURE__ */ H(D, {
|
|
2167
|
+
layout: "vertical",
|
|
2168
|
+
onFinish: () => void T.handleSubmit(k)(),
|
|
2169
|
+
style: {
|
|
2170
|
+
opacity: E ? .4 : 1,
|
|
2171
|
+
pointerEvents: E ? "none" : void 0
|
|
2172
|
+
},
|
|
2173
|
+
children: [i, /* @__PURE__ */ V(D.Item, {
|
|
2174
|
+
style: { marginTop: 16 },
|
|
2175
|
+
children: /* @__PURE__ */ H(F, { children: [/* @__PURE__ */ V(x, {
|
|
2176
|
+
type: "primary",
|
|
2177
|
+
htmlType: "submit",
|
|
2178
|
+
disabled: E || !A,
|
|
2179
|
+
children: "Save"
|
|
2180
|
+
}), /* @__PURE__ */ V(u, {
|
|
2181
|
+
to: r,
|
|
2182
|
+
children: /* @__PURE__ */ V(x, {
|
|
2183
|
+
disabled: E,
|
|
2184
|
+
children: "Cancel"
|
|
2185
|
+
})
|
|
2186
|
+
})] })
|
|
2187
|
+
})]
|
|
2188
|
+
}))]
|
|
2189
|
+
})
|
|
2190
|
+
})
|
|
2191
|
+
})
|
|
1879
2192
|
})
|
|
1880
2193
|
});
|
|
1881
2194
|
}
|
|
1882
|
-
function Pn() {
|
|
1883
|
-
let e = a(jn), t = a(Mn);
|
|
1884
|
-
return e ? {
|
|
1885
|
-
...e,
|
|
1886
|
-
fields: t
|
|
1887
|
-
} : null;
|
|
1888
|
-
}
|
|
1889
2195
|
//#endregion
|
|
1890
|
-
//#region src/crud/utils/
|
|
1891
|
-
function
|
|
1892
|
-
return
|
|
2196
|
+
//#region src/crud/utils/nestedFieldPath.ts
|
|
2197
|
+
function rr(e, t, n) {
|
|
2198
|
+
return `${e}.${t}.${n}`;
|
|
1893
2199
|
}
|
|
1894
2200
|
//#endregion
|
|
1895
2201
|
//#region src/crud/InlineFormSet.tsx
|
|
1896
|
-
function
|
|
1897
|
-
let t =
|
|
2202
|
+
function ir(e) {
|
|
2203
|
+
let t = {};
|
|
2204
|
+
for (let n of e) t[n] = void 0;
|
|
2205
|
+
return t;
|
|
2206
|
+
}
|
|
2207
|
+
function ar(e, t) {
|
|
2208
|
+
let { control: n } = G(), { fields: r, append: i, remove: a } = Se({
|
|
1898
2209
|
control: n,
|
|
1899
|
-
name: e
|
|
2210
|
+
name: e,
|
|
2211
|
+
keyName: "rowKey"
|
|
1900
2212
|
});
|
|
1901
2213
|
return {
|
|
1902
|
-
ctx: t,
|
|
1903
2214
|
fields: r,
|
|
1904
2215
|
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
|
-
}
|
|
2216
|
+
appendEmpty: () => i(ir(t))
|
|
1911
2217
|
};
|
|
1912
2218
|
}
|
|
1913
|
-
function
|
|
1914
|
-
let
|
|
2219
|
+
function or({ field: e, label: t, payloadKey: n, transformRows: r, columns: i }) {
|
|
2220
|
+
let a = s(() => i.map((e) => e.source), [i]), { fields: o, remove: c, appendEmpty: l } = ar(e, a);
|
|
2221
|
+
bn(e), $n(e, a, n, r);
|
|
2222
|
+
let u = s(() => i.map((t) => ({
|
|
1915
2223
|
title: t.label ?? t.source,
|
|
1916
2224
|
key: t.source,
|
|
1917
2225
|
width: t.width,
|
|
1918
2226
|
onHeaderCell: () => t.minWidth == null ? {} : { style: { minWidth: t.minWidth } },
|
|
1919
2227
|
onCell: () => t.minWidth == null ? {} : { style: { minWidth: t.minWidth } },
|
|
1920
|
-
render: (n, r, i) => t.
|
|
1921
|
-
name:
|
|
1922
|
-
index: i
|
|
2228
|
+
render: (n, r, i) => t.cell({
|
|
2229
|
+
name: rr(e, i, t.source),
|
|
2230
|
+
index: i,
|
|
2231
|
+
field: e
|
|
1923
2232
|
})
|
|
1924
|
-
}))
|
|
1925
|
-
return
|
|
2233
|
+
})), [i, e]);
|
|
2234
|
+
return /* @__PURE__ */ H("div", {
|
|
1926
2235
|
style: { marginTop: 24 },
|
|
1927
2236
|
children: [
|
|
1928
2237
|
/* @__PURE__ */ V(R.Title, {
|
|
1929
2238
|
level: 5,
|
|
1930
2239
|
children: t ?? "Related items"
|
|
1931
2240
|
}),
|
|
1932
|
-
/* @__PURE__ */ V(
|
|
2241
|
+
/* @__PURE__ */ V(oe, {
|
|
1933
2242
|
size: "small",
|
|
1934
2243
|
pagination: !1,
|
|
1935
2244
|
scroll: { x: "max-content" },
|
|
1936
|
-
dataSource:
|
|
2245
|
+
dataSource: o.map((e) => ({
|
|
1937
2246
|
...e,
|
|
1938
|
-
key: e.
|
|
2247
|
+
key: e.rowKey
|
|
1939
2248
|
})),
|
|
1940
|
-
columns: [...
|
|
2249
|
+
columns: [...u, {
|
|
1941
2250
|
title: "",
|
|
1942
2251
|
key: "__remove",
|
|
1943
2252
|
width: 80,
|
|
@@ -1945,7 +2254,7 @@ function Ln({ arrayName: e, label: t }) {
|
|
|
1945
2254
|
type: "link",
|
|
1946
2255
|
danger: !0,
|
|
1947
2256
|
size: "small",
|
|
1948
|
-
onClick: () =>
|
|
2257
|
+
onClick: () => c(n),
|
|
1949
2258
|
children: "Remove"
|
|
1950
2259
|
})
|
|
1951
2260
|
}]
|
|
@@ -1953,15 +2262,15 @@ function Ln({ arrayName: e, label: t }) {
|
|
|
1953
2262
|
/* @__PURE__ */ V(x, {
|
|
1954
2263
|
type: "dashed",
|
|
1955
2264
|
style: { marginTop: 8 },
|
|
1956
|
-
onClick:
|
|
2265
|
+
onClick: l,
|
|
1957
2266
|
children: "Add row"
|
|
1958
2267
|
})
|
|
1959
2268
|
]
|
|
1960
|
-
})
|
|
2269
|
+
});
|
|
1961
2270
|
}
|
|
1962
|
-
function
|
|
1963
|
-
let {
|
|
1964
|
-
return n
|
|
2271
|
+
function sr({ field: e, label: t, payloadKey: n, transformRows: r, sources: i, renderRow: a }) {
|
|
2272
|
+
let { fields: o, remove: s, appendEmpty: c } = ar(e, i);
|
|
2273
|
+
return bn(e), $n(e, i, n, r), /* @__PURE__ */ H("div", {
|
|
1965
2274
|
style: { marginTop: 24 },
|
|
1966
2275
|
children: [
|
|
1967
2276
|
/* @__PURE__ */ V(R.Title, {
|
|
@@ -1972,256 +2281,50 @@ function Rn({ arrayName: e, label: t }) {
|
|
|
1972
2281
|
orientation: "vertical",
|
|
1973
2282
|
size: "middle",
|
|
1974
2283
|
style: { width: "100%" },
|
|
1975
|
-
children:
|
|
2284
|
+
children: o.map((t, n) => /* @__PURE__ */ V(S, {
|
|
1976
2285
|
size: "small",
|
|
1977
|
-
title: `Item ${
|
|
2286
|
+
title: `Item ${n + 1}`,
|
|
1978
2287
|
extra: /* @__PURE__ */ V(x, {
|
|
1979
2288
|
type: "link",
|
|
1980
2289
|
danger: !0,
|
|
1981
2290
|
size: "small",
|
|
1982
|
-
onClick: () =>
|
|
2291
|
+
onClick: () => s(n),
|
|
1983
2292
|
children: "Remove"
|
|
1984
2293
|
}),
|
|
1985
|
-
children:
|
|
1986
|
-
|
|
1987
|
-
index:
|
|
1988
|
-
|
|
1989
|
-
|
|
2294
|
+
children: a({
|
|
2295
|
+
field: e,
|
|
2296
|
+
index: n,
|
|
2297
|
+
name: (t) => rr(e, n, t)
|
|
2298
|
+
})
|
|
2299
|
+
}, t.rowKey))
|
|
1990
2300
|
}),
|
|
1991
2301
|
/* @__PURE__ */ V(x, {
|
|
1992
2302
|
type: "dashed",
|
|
1993
2303
|
style: { marginTop: 8 },
|
|
1994
|
-
onClick:
|
|
2304
|
+
onClick: c,
|
|
1995
2305
|
children: "Add item"
|
|
1996
2306
|
})
|
|
1997
2307
|
]
|
|
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
|
-
});
|
|
2010
|
-
}
|
|
2011
|
-
async function Bn(e, t) {
|
|
2012
|
-
let { resource: n, foreignKey: r, parentId: i, rows: a, existingIds: o = [], onRowError: s } = t, c = [];
|
|
2013
|
-
for (let t = 0; t < a.length; t++) {
|
|
2014
|
-
let l = a[t];
|
|
2015
|
-
try {
|
|
2016
|
-
let { id: t, ...a } = l, s = {
|
|
2017
|
-
...a,
|
|
2018
|
-
[r]: i
|
|
2019
|
-
}, u = l.id;
|
|
2020
|
-
if (u != null && o.some((e) => e === u)) await e.update(n, {
|
|
2021
|
-
id: u,
|
|
2022
|
-
data: s
|
|
2023
|
-
}), c.push(u);
|
|
2024
|
-
else {
|
|
2025
|
-
let t = (await e.create(n, s)).data;
|
|
2026
|
-
c.push(t.id);
|
|
2027
|
-
}
|
|
2028
|
-
} catch (e) {
|
|
2029
|
-
if (s?.(e, t)) return !1;
|
|
2030
|
-
throw e;
|
|
2031
|
-
}
|
|
2032
|
-
}
|
|
2033
|
-
for (let t of o) c.some((e) => e === t) || await e.delete(n, t);
|
|
2034
|
-
return !0;
|
|
2035
|
-
}
|
|
2036
|
-
async function Vn(e, t, n, r) {
|
|
2037
|
-
let i = await e.getList(t, {
|
|
2038
|
-
filter: { [n]: Number(r) || r },
|
|
2039
|
-
pagination: {
|
|
2040
|
-
page: 1,
|
|
2041
|
-
perPage: 500
|
|
2042
|
-
}
|
|
2043
|
-
});
|
|
2044
|
-
return {
|
|
2045
|
-
rows: i.data,
|
|
2046
|
-
ids: i.data.map((e) => e.id)
|
|
2047
|
-
};
|
|
2048
|
-
}
|
|
2049
|
-
//#endregion
|
|
2050
|
-
//#region src/crud/ResourceForm.tsx
|
|
2051
|
-
function Hn(e) {
|
|
2052
|
-
return Fn(e.resource, e.name);
|
|
2053
|
-
}
|
|
2054
|
-
function Un({ resource: e, title: t, listPath: r, children: a, defaultValues: s, onSaved: d, stayOnPage: f, inlines: p, permissions: m }) {
|
|
2055
|
-
let { id: h } = _(), v = h === "new" || !h, b = mt(), C = q(), w = g(), { message: T } = y.useApp(), { token: ee } = z.useToken(), [E, O] = l(!v), [k, A] = l(0), [j, te] = l({}), M = ye({ defaultValues: s }), ne = c(/* @__PURE__ */ new Set()), N = i(async () => {
|
|
2056
|
-
if (v || !h) {
|
|
2057
|
-
s && M.reset({ ...s }), O(!1);
|
|
2058
|
-
return;
|
|
2059
|
-
}
|
|
2060
|
-
O(!0);
|
|
2061
|
-
try {
|
|
2062
|
-
let t = (await b.getOne(e, h)).data;
|
|
2063
|
-
if (p?.length) {
|
|
2064
|
-
let e = { ...t }, n = {};
|
|
2065
|
-
for (let t of p) {
|
|
2066
|
-
let r = Hn(t), { rows: i, ids: a } = await Vn(b, t.resource, t.foreignKey, h);
|
|
2067
|
-
e[r] = i, n[r] = a;
|
|
2068
|
-
}
|
|
2069
|
-
M.reset(e), te(n), A((e) => e + 1);
|
|
2070
|
-
} else M.reset(t), A((e) => e + 1);
|
|
2071
|
-
} catch (e) {
|
|
2072
|
-
T.error(e instanceof Error ? e.message : "Load failed");
|
|
2073
|
-
} finally {
|
|
2074
|
-
O(!1);
|
|
2075
|
-
}
|
|
2076
|
-
}, [
|
|
2077
|
-
b,
|
|
2078
|
-
e,
|
|
2079
|
-
h,
|
|
2080
|
-
v,
|
|
2081
|
-
M,
|
|
2082
|
-
T,
|
|
2083
|
-
s,
|
|
2084
|
-
i(async (e) => {
|
|
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
|
|
2108
|
-
]);
|
|
2109
|
-
let P = m ? J(C, m, v ? "add" : "change") : !0;
|
|
2110
|
-
async function L(t) {
|
|
2111
|
-
try {
|
|
2112
|
-
let n = pn(t, Array.from(ne.current));
|
|
2113
|
-
if (p?.length) for (let e of p) delete n[Hn(e)];
|
|
2114
|
-
let i;
|
|
2115
|
-
if (v) i = (await b.create(e, n)).data, T.success("Created");
|
|
2116
|
-
else if (h) i = (await b.update(e, {
|
|
2117
|
-
id: h,
|
|
2118
|
-
data: n
|
|
2119
|
-
})).data, T.success("Updated");
|
|
2120
|
-
else return;
|
|
2121
|
-
let a = i.id;
|
|
2122
|
-
if (p?.length && a != null) for (let e of p) {
|
|
2123
|
-
let t = Hn(e), n = M.getValues(t) ?? [];
|
|
2124
|
-
if (!await Bn(b, {
|
|
2125
|
-
resource: e.resource,
|
|
2126
|
-
foreignKey: e.foreignKey,
|
|
2127
|
-
parentId: a,
|
|
2128
|
-
rows: n,
|
|
2129
|
-
existingIds: j[t] ?? [],
|
|
2130
|
-
onRowError: (r, i) => {
|
|
2131
|
-
let a = n[i]?.id;
|
|
2132
|
-
return gn(b, M, T, r, {
|
|
2133
|
-
resource: e.resource,
|
|
2134
|
-
mutation: a != null && (j[t] ?? []).some((e) => e === a) ? "update" : "create",
|
|
2135
|
-
inlineArrayName: t,
|
|
2136
|
-
rowIndex: i
|
|
2137
|
-
});
|
|
2138
|
-
}
|
|
2139
|
-
})) return;
|
|
2140
|
-
}
|
|
2141
|
-
d?.(i), f || w(r);
|
|
2142
|
-
} catch (t) {
|
|
2143
|
-
gn(b, M, T, t, {
|
|
2144
|
-
resource: e,
|
|
2145
|
-
mutation: v ? "create" : "update"
|
|
2146
|
-
}) || T.error(t instanceof Error ? t.message : "Save failed");
|
|
2147
|
-
}
|
|
2148
|
-
}
|
|
2149
|
-
return /* @__PURE__ */ V(S, {
|
|
2150
|
-
title: /* @__PURE__ */ H(F, { children: [/* @__PURE__ */ H(u, {
|
|
2151
|
-
to: r,
|
|
2152
|
-
style: { color: ee.colorText },
|
|
2153
|
-
children: [/* @__PURE__ */ V(U, {}), " Back"]
|
|
2154
|
-
}), /* @__PURE__ */ V(R.Title, {
|
|
2155
|
-
level: 5,
|
|
2156
|
-
style: { margin: 0 },
|
|
2157
|
-
children: t
|
|
2158
|
-
})] }),
|
|
2159
|
-
children: /* @__PURE__ */ V(tn, {
|
|
2160
|
-
resource: e,
|
|
2161
|
-
isNew: v,
|
|
2162
|
-
children: /* @__PURE__ */ V(cn, {
|
|
2163
|
-
sourcesRef: ne,
|
|
2164
|
-
children: /* @__PURE__ */ H("div", {
|
|
2165
|
-
style: { position: "relative" },
|
|
2166
|
-
children: [E ? /* @__PURE__ */ V("div", {
|
|
2167
|
-
style: {
|
|
2168
|
-
position: "absolute",
|
|
2169
|
-
inset: 0,
|
|
2170
|
-
display: "flex",
|
|
2171
|
-
alignItems: "center",
|
|
2172
|
-
justifyContent: "center",
|
|
2173
|
-
zIndex: 1
|
|
2174
|
-
},
|
|
2175
|
-
children: /* @__PURE__ */ V(I, {})
|
|
2176
|
-
}) : null, /* @__PURE__ */ n(_e, {
|
|
2177
|
-
...M,
|
|
2178
|
-
key: k
|
|
2179
|
-
}, /* @__PURE__ */ H(D, {
|
|
2180
|
-
layout: "vertical",
|
|
2181
|
-
onFinish: () => void M.handleSubmit(L)(),
|
|
2182
|
-
style: {
|
|
2183
|
-
opacity: E ? .4 : 1,
|
|
2184
|
-
pointerEvents: E ? "none" : void 0
|
|
2185
|
-
},
|
|
2186
|
-
children: [a, /* @__PURE__ */ V(D.Item, {
|
|
2187
|
-
style: { marginTop: 16 },
|
|
2188
|
-
children: /* @__PURE__ */ H(F, { children: [/* @__PURE__ */ V(x, {
|
|
2189
|
-
type: "primary",
|
|
2190
|
-
htmlType: "submit",
|
|
2191
|
-
disabled: E || !P,
|
|
2192
|
-
children: "Save"
|
|
2193
|
-
}), /* @__PURE__ */ V(u, {
|
|
2194
|
-
to: r,
|
|
2195
|
-
children: /* @__PURE__ */ V(x, {
|
|
2196
|
-
disabled: E,
|
|
2197
|
-
children: "Cancel"
|
|
2198
|
-
})
|
|
2199
|
-
})] })
|
|
2200
|
-
})]
|
|
2201
|
-
}))]
|
|
2202
|
-
})
|
|
2203
|
-
})
|
|
2204
|
-
})
|
|
2205
2308
|
});
|
|
2206
2309
|
}
|
|
2207
2310
|
//#endregion
|
|
2208
2311
|
//#region src/crud/utils/formSectionErrors.ts
|
|
2209
|
-
function
|
|
2312
|
+
function cr(e, t, n) {
|
|
2210
2313
|
for (let r of e) if (t(r, n).invalid) return !0;
|
|
2211
2314
|
return !1;
|
|
2212
2315
|
}
|
|
2213
|
-
function
|
|
2316
|
+
function lr(e) {
|
|
2214
2317
|
let t = c([]);
|
|
2215
2318
|
for (; t.current.length < e;) t.current.push({ current: /* @__PURE__ */ new Set() });
|
|
2216
2319
|
return t.current.length > e && (t.current.length = e), t.current;
|
|
2217
2320
|
}
|
|
2218
|
-
function
|
|
2219
|
-
let { control: n, getFieldState: r, setFocus: i } = G(), a =
|
|
2321
|
+
function ur(e, t) {
|
|
2322
|
+
let { control: n, getFieldState: r, setFocus: i } = G(), a = we({ control: n }), s = c(0), l = c(0);
|
|
2220
2323
|
o(() => {
|
|
2221
2324
|
if (a.submitCount === 0) return;
|
|
2222
2325
|
let n = Object.keys(a.errors).length, o = a.submitCount !== s.current, c = !o && n > 0 && l.current === 0;
|
|
2223
2326
|
if (s.current = a.submitCount, l.current = n, !o && !c || n === 0) return;
|
|
2224
|
-
let u = e.findIndex((e) =>
|
|
2327
|
+
let u = e.findIndex((e) => cr(e.current, r, a));
|
|
2225
2328
|
if (u < 0) return;
|
|
2226
2329
|
t(u);
|
|
2227
2330
|
let d = [...e[u].current].find((e) => r(e, a).invalid);
|
|
@@ -2240,30 +2343,30 @@ function Kn(e, t) {
|
|
|
2240
2343
|
}
|
|
2241
2344
|
//#endregion
|
|
2242
2345
|
//#region src/crud/FormTabs.tsx
|
|
2243
|
-
function
|
|
2346
|
+
function dr(e) {
|
|
2244
2347
|
return null;
|
|
2245
2348
|
}
|
|
2246
|
-
function
|
|
2247
|
-
return r(e) && e.type ===
|
|
2349
|
+
function fr(e) {
|
|
2350
|
+
return r(e) && e.type === dr;
|
|
2248
2351
|
}
|
|
2249
|
-
function
|
|
2250
|
-
let { token: c } = z.useToken(), u = s(() => e.toArray(t).filter(
|
|
2352
|
+
function pr({ children: t, defaultActiveKey: n, activeKey: r, onChange: a, ...o }) {
|
|
2353
|
+
let { token: c } = z.useToken(), u = s(() => e.toArray(t).filter(fr).map((e, t) => ({
|
|
2251
2354
|
key: e.key ?? String(t),
|
|
2252
2355
|
label: e.props.label,
|
|
2253
2356
|
disabled: e.props.disabled,
|
|
2254
2357
|
children: e.props.children
|
|
2255
|
-
})), [t]), d =
|
|
2358
|
+
})), [t]), d = lr(u.length), f = r !== void 0, [p, m] = l(() => n ?? u[0]?.key ?? "0"), h = f ? r : p, g = i((e) => {
|
|
2256
2359
|
f || m(e), a?.(e);
|
|
2257
2360
|
}, [f, a]);
|
|
2258
|
-
|
|
2361
|
+
ur(d, i((e) => {
|
|
2259
2362
|
let t = u[e]?.key;
|
|
2260
2363
|
t != null && g(t);
|
|
2261
2364
|
}, [g, u]));
|
|
2262
|
-
let { control: _, getFieldState: v } = G(), y =
|
|
2263
|
-
return /* @__PURE__ */ V(
|
|
2365
|
+
let { control: _, getFieldState: v } = G(), y = we({ control: _ });
|
|
2366
|
+
return /* @__PURE__ */ V(L, {
|
|
2264
2367
|
destroyOnHidden: !1,
|
|
2265
2368
|
items: s(() => u.map((e, t) => {
|
|
2266
|
-
let n =
|
|
2369
|
+
let n = cr(d[t].current, v, y);
|
|
2267
2370
|
return {
|
|
2268
2371
|
key: e.key,
|
|
2269
2372
|
label: n ? /* @__PURE__ */ V("span", {
|
|
@@ -2271,7 +2374,7 @@ function Yn({ children: t, defaultActiveKey: n, activeKey: r, onChange: a, ...o
|
|
|
2271
2374
|
children: e.label
|
|
2272
2375
|
}) : e.label,
|
|
2273
2376
|
disabled: e.disabled,
|
|
2274
|
-
children: /* @__PURE__ */ V(
|
|
2377
|
+
children: /* @__PURE__ */ V(hn, {
|
|
2275
2378
|
sourcesRef: d[t],
|
|
2276
2379
|
children: e.children
|
|
2277
2380
|
})
|
|
@@ -2290,17 +2393,17 @@ function Yn({ children: t, defaultActiveKey: n, activeKey: r, onChange: a, ...o
|
|
|
2290
2393
|
}
|
|
2291
2394
|
//#endregion
|
|
2292
2395
|
//#region src/crud/FormSteps.tsx
|
|
2293
|
-
function
|
|
2396
|
+
function mr(e) {
|
|
2294
2397
|
return null;
|
|
2295
2398
|
}
|
|
2296
|
-
function
|
|
2297
|
-
return r(e) && e.type ===
|
|
2399
|
+
function hr(e) {
|
|
2400
|
+
return r(e) && e.type === mr;
|
|
2298
2401
|
}
|
|
2299
|
-
function
|
|
2300
|
-
let m = s(() => e.toArray(t).filter(
|
|
2301
|
-
|
|
2302
|
-
let { control: y, getFieldState: b } = G(), S =
|
|
2303
|
-
let n =
|
|
2402
|
+
function gr({ children: t, initialStep: n = 0, showNavigation: r = !0, allowStepSelect: a = !1, stepsStyle: o, navigationStyle: c, size: u, direction: d, type: f, status: p }) {
|
|
2403
|
+
let m = s(() => e.toArray(t).filter(hr), [t]), h = lr(m.length), [g, _] = l(n), v = m.length - 1;
|
|
2404
|
+
ur(h, _);
|
|
2405
|
+
let { control: y, getFieldState: b } = G(), S = we({ control: y }), C = s(() => m.map((e, t) => {
|
|
2406
|
+
let n = cr(h[t].current, b, S);
|
|
2304
2407
|
return {
|
|
2305
2408
|
title: e.props.title,
|
|
2306
2409
|
description: e.props.description,
|
|
@@ -2315,7 +2418,7 @@ function Qn({ children: t, initialStep: n = 0, showNavigation: r = !0, allowStep
|
|
|
2315
2418
|
_(e);
|
|
2316
2419
|
}, []);
|
|
2317
2420
|
return /* @__PURE__ */ H(B, { children: [
|
|
2318
|
-
/* @__PURE__ */ V(
|
|
2421
|
+
/* @__PURE__ */ V(ie, {
|
|
2319
2422
|
current: g,
|
|
2320
2423
|
items: C,
|
|
2321
2424
|
style: {
|
|
@@ -2330,7 +2433,7 @@ function Qn({ children: t, initialStep: n = 0, showNavigation: r = !0, allowStep
|
|
|
2330
2433
|
}),
|
|
2331
2434
|
m.map((e, t) => /* @__PURE__ */ V("div", {
|
|
2332
2435
|
style: { display: g === t ? void 0 : "none" },
|
|
2333
|
-
children: /* @__PURE__ */ V(
|
|
2436
|
+
children: /* @__PURE__ */ V(hn, {
|
|
2334
2437
|
sourcesRef: h[t],
|
|
2335
2438
|
children: e.props.children
|
|
2336
2439
|
})
|
|
@@ -2355,183 +2458,131 @@ function Qn({ children: t, initialStep: n = 0, showNavigation: r = !0, allowStep
|
|
|
2355
2458
|
}
|
|
2356
2459
|
//#endregion
|
|
2357
2460
|
//#region src/crud/fields/FieldWrapper.tsx
|
|
2358
|
-
function
|
|
2359
|
-
let { control:
|
|
2360
|
-
return
|
|
2361
|
-
name:
|
|
2362
|
-
control:
|
|
2461
|
+
function Q({ source: e, name: t, label: n, required: r, rules: i, hideLabel: a, children: o }) {
|
|
2462
|
+
let s = t ?? e, c = !s.includes("."), { control: l } = G(), u = pn(), d = a ? void 0 : n ?? e, f = n ?? e;
|
|
2463
|
+
return bn(e, c), xn(e, c), /* @__PURE__ */ V(xe, {
|
|
2464
|
+
name: s,
|
|
2465
|
+
control: l,
|
|
2363
2466
|
rules: {
|
|
2364
|
-
required:
|
|
2365
|
-
...
|
|
2467
|
+
required: r ? `${f} is required` : !1,
|
|
2468
|
+
...i
|
|
2366
2469
|
},
|
|
2367
2470
|
render: ({ field: e, fieldState: t }) => /* @__PURE__ */ V(D.Item, {
|
|
2368
|
-
label:
|
|
2471
|
+
label: d,
|
|
2369
2472
|
validateStatus: t.error ? "error" : void 0,
|
|
2370
2473
|
help: t.error?.message,
|
|
2371
|
-
required:
|
|
2372
|
-
|
|
2474
|
+
required: r && !a,
|
|
2475
|
+
style: a ? { marginBottom: 0 } : void 0,
|
|
2476
|
+
children: o({
|
|
2373
2477
|
value: e.value,
|
|
2374
2478
|
onChange: e.onChange,
|
|
2375
2479
|
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
|
|
2480
|
+
disabled: u?.disabled,
|
|
2481
|
+
name: s
|
|
2400
2482
|
})
|
|
2401
2483
|
})
|
|
2402
2484
|
});
|
|
2403
2485
|
}
|
|
2404
2486
|
//#endregion
|
|
2405
|
-
//#region src/crud/fields/
|
|
2406
|
-
function
|
|
2407
|
-
|
|
2408
|
-
f.current = i;
|
|
2409
|
-
let p = s(() => u ? {
|
|
2410
|
-
key: e,
|
|
2487
|
+
//#region src/crud/fields/TextField.tsx
|
|
2488
|
+
function _r({ source: e, name: t, label: n, required: r, rules: i, placeholder: a, inputStyle: o, hideLabel: s }) {
|
|
2489
|
+
return /* @__PURE__ */ V(Q, {
|
|
2411
2490
|
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
|
-
})
|
|
2491
|
+
name: t,
|
|
2492
|
+
label: n,
|
|
2493
|
+
required: r,
|
|
2494
|
+
rules: i,
|
|
2495
|
+
hideLabel: s,
|
|
2496
|
+
children: ({ value: e, onChange: t, onBlur: n, disabled: r }) => /* @__PURE__ */ V(A, {
|
|
2497
|
+
value: e,
|
|
2498
|
+
onChange: (e) => t(e.target.value),
|
|
2499
|
+
onBlur: n,
|
|
2500
|
+
placeholder: a,
|
|
2501
|
+
disabled: r,
|
|
2502
|
+
style: o
|
|
2456
2503
|
})
|
|
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
2504
|
});
|
|
2473
|
-
return c.mode === "inline" ? null : c.element;
|
|
2474
2505
|
}
|
|
2475
2506
|
//#endregion
|
|
2476
2507
|
//#region src/crud/fields/NumberField.tsx
|
|
2477
|
-
function
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
disabled: r,
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2508
|
+
function vr({ source: e, name: t, label: n, required: r, rules: i, min: a, max: o, step: s, inputStyle: c, hideLabel: l }) {
|
|
2509
|
+
return /* @__PURE__ */ V(Q, {
|
|
2510
|
+
source: e,
|
|
2511
|
+
name: t,
|
|
2512
|
+
label: n,
|
|
2513
|
+
required: r,
|
|
2514
|
+
rules: i,
|
|
2515
|
+
hideLabel: l,
|
|
2516
|
+
children: ({ value: e, onChange: t, onBlur: n, disabled: r }) => /* @__PURE__ */ V(te, {
|
|
2517
|
+
value: e,
|
|
2518
|
+
onChange: (e) => t(e),
|
|
2519
|
+
onBlur: n,
|
|
2520
|
+
min: a,
|
|
2521
|
+
max: o,
|
|
2522
|
+
step: s,
|
|
2523
|
+
disabled: r,
|
|
2524
|
+
style: {
|
|
2525
|
+
width: "100%",
|
|
2526
|
+
...c
|
|
2527
|
+
}
|
|
2528
|
+
})
|
|
2493
2529
|
});
|
|
2494
|
-
return u.mode === "inline" ? null : u.element;
|
|
2495
2530
|
}
|
|
2496
2531
|
//#endregion
|
|
2497
2532
|
//#region src/crud/fields/BooleanField.tsx
|
|
2498
|
-
function
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2533
|
+
function yr({ source: e, name: t, label: n, required: r, rules: i, hideLabel: a }) {
|
|
2534
|
+
return /* @__PURE__ */ V(Q, {
|
|
2535
|
+
source: e,
|
|
2536
|
+
name: t,
|
|
2537
|
+
label: n,
|
|
2538
|
+
required: r,
|
|
2539
|
+
rules: i,
|
|
2540
|
+
hideLabel: a,
|
|
2541
|
+
children: ({ value: e, onChange: t, disabled: n }) => /* @__PURE__ */ V(ae, {
|
|
2542
|
+
checked: !!e,
|
|
2543
|
+
onChange: t,
|
|
2544
|
+
disabled: n
|
|
2545
|
+
})
|
|
2546
|
+
});
|
|
2505
2547
|
}
|
|
2506
2548
|
//#endregion
|
|
2507
2549
|
//#region src/crud/fields/DateField.tsx
|
|
2508
|
-
var
|
|
2509
|
-
function
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2550
|
+
var br = "YYYY-MM-DD";
|
|
2551
|
+
function xr({ source: e, name: t, label: n, required: r, rules: i, showTime: a, hideLabel: o }) {
|
|
2552
|
+
return /* @__PURE__ */ V(Q, {
|
|
2553
|
+
source: e,
|
|
2554
|
+
name: t,
|
|
2555
|
+
label: n,
|
|
2556
|
+
required: r,
|
|
2557
|
+
rules: i,
|
|
2558
|
+
hideLabel: o,
|
|
2559
|
+
children: ({ value: e, onChange: t, onBlur: n, disabled: r }) => /* @__PURE__ */ V(w, {
|
|
2560
|
+
value: e ? Ee(String(e)) : null,
|
|
2561
|
+
onChange: (e) => t(e ? e.format(a ? `${br} HH:mm:ss` : br) : null),
|
|
2562
|
+
onBlur: n,
|
|
2563
|
+
showTime: a,
|
|
2564
|
+
disabled: r,
|
|
2565
|
+
format: a ? `${br} HH:mm:ss` : br,
|
|
2566
|
+
style: { width: "100%" }
|
|
2567
|
+
})
|
|
2568
|
+
});
|
|
2520
2569
|
}
|
|
2521
2570
|
//#endregion
|
|
2522
2571
|
//#region src/crud/fields/SelectField.tsx
|
|
2523
|
-
function
|
|
2524
|
-
return /* @__PURE__ */ V(
|
|
2572
|
+
function Sr({ source: e, name: t, label: n, required: r, rules: i, choices: a, mode: o, allowClear: s, hideLabel: c }) {
|
|
2573
|
+
return /* @__PURE__ */ V(Q, {
|
|
2525
2574
|
source: e,
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2575
|
+
name: t,
|
|
2576
|
+
label: n,
|
|
2577
|
+
required: r,
|
|
2578
|
+
rules: i,
|
|
2579
|
+
hideLabel: c,
|
|
2529
2580
|
children: ({ value: e, onChange: t, disabled: n }) => /* @__PURE__ */ V(P, {
|
|
2530
2581
|
value: e,
|
|
2531
2582
|
onChange: t,
|
|
2532
|
-
options:
|
|
2533
|
-
mode:
|
|
2534
|
-
allowClear:
|
|
2583
|
+
options: a,
|
|
2584
|
+
mode: o,
|
|
2585
|
+
allowClear: s,
|
|
2535
2586
|
disabled: n,
|
|
2536
2587
|
style: { width: "100%" }
|
|
2537
2588
|
})
|
|
@@ -2539,60 +2590,63 @@ function or({ source: e, label: t, required: n, rules: r, choices: i, mode: a, a
|
|
|
2539
2590
|
}
|
|
2540
2591
|
//#endregion
|
|
2541
2592
|
//#region src/crud/fields/PasswordField.tsx
|
|
2542
|
-
function
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2593
|
+
function Cr({ source: e, name: t, label: n, required: r, rules: i, autoComplete: a, hideLabel: o }) {
|
|
2594
|
+
return /* @__PURE__ */ V(Q, {
|
|
2595
|
+
source: e,
|
|
2596
|
+
name: t,
|
|
2597
|
+
label: n,
|
|
2598
|
+
required: r,
|
|
2599
|
+
rules: i,
|
|
2600
|
+
hideLabel: o,
|
|
2601
|
+
children: ({ value: e, onChange: t, onBlur: n, disabled: r }) => /* @__PURE__ */ V(A.Password, {
|
|
2602
|
+
value: e,
|
|
2603
|
+
onChange: (e) => t(e.target.value),
|
|
2604
|
+
onBlur: n,
|
|
2605
|
+
disabled: r,
|
|
2606
|
+
autoComplete: a
|
|
2607
|
+
})
|
|
2552
2608
|
});
|
|
2553
|
-
return s.mode === "inline" ? null : s.element;
|
|
2554
2609
|
}
|
|
2555
|
-
function
|
|
2556
|
-
let l =
|
|
2557
|
-
name: e,
|
|
2558
|
-
disabled: !
|
|
2610
|
+
function wr({ source: e, name: t, label: n, required: r, rules: i, confirmSource: a, confirmLabel: o = "Confirm password", autoComplete: s = "new-password", hideLabel: c }) {
|
|
2611
|
+
let l = Te({
|
|
2612
|
+
name: t ?? e,
|
|
2613
|
+
disabled: !a
|
|
2559
2614
|
});
|
|
2560
|
-
return
|
|
2615
|
+
return a ? /* @__PURE__ */ H(B, { children: [/* @__PURE__ */ V(Cr, {
|
|
2561
2616
|
source: e,
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
}), /* @__PURE__ */ V(
|
|
2569
|
-
source:
|
|
2570
|
-
label:
|
|
2571
|
-
required:
|
|
2572
|
-
autoComplete:
|
|
2573
|
-
|
|
2574
|
-
minWidth: c,
|
|
2617
|
+
name: t,
|
|
2618
|
+
label: n,
|
|
2619
|
+
required: r,
|
|
2620
|
+
rules: i,
|
|
2621
|
+
autoComplete: s,
|
|
2622
|
+
hideLabel: c
|
|
2623
|
+
}), /* @__PURE__ */ V(Cr, {
|
|
2624
|
+
source: a,
|
|
2625
|
+
label: o,
|
|
2626
|
+
required: r,
|
|
2627
|
+
autoComplete: s,
|
|
2628
|
+
hideLabel: c,
|
|
2575
2629
|
rules: { validate: (e) => !l || e === l || "Passwords do not match" }
|
|
2576
|
-
})] }) : /* @__PURE__ */ V(
|
|
2630
|
+
})] }) : /* @__PURE__ */ V(Cr, {
|
|
2577
2631
|
source: e,
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2632
|
+
name: t,
|
|
2633
|
+
label: n,
|
|
2634
|
+
required: r,
|
|
2635
|
+
rules: i,
|
|
2636
|
+
autoComplete: s,
|
|
2637
|
+
hideLabel: c
|
|
2584
2638
|
});
|
|
2585
2639
|
}
|
|
2586
2640
|
//#endregion
|
|
2587
2641
|
//#region src/crud/utils/useChoices.ts
|
|
2588
|
-
var
|
|
2589
|
-
function
|
|
2642
|
+
var Tr = /* @__PURE__ */ new Map(), Er = /* @__PURE__ */ new Map();
|
|
2643
|
+
function Dr(e, t) {
|
|
2590
2644
|
return typeof e == "function" ? `fn:${t ?? ""}` : Array.isArray(e) ? `static:${e.length}` : `res:${e.resource}:${JSON.stringify(e.filter ?? {})}:${t ?? ""}`;
|
|
2591
2645
|
}
|
|
2592
|
-
function
|
|
2646
|
+
function Or(e, t) {
|
|
2593
2647
|
return typeof t == "function" ? t(e) : String(e[t] ?? "");
|
|
2594
2648
|
}
|
|
2595
|
-
async function
|
|
2649
|
+
async function kr(e, t, n, r, i) {
|
|
2596
2650
|
return typeof e == "function" ? e({
|
|
2597
2651
|
dataProvider: t,
|
|
2598
2652
|
search: i
|
|
@@ -2606,23 +2660,23 @@ async function pr(e, t, n, r, i) {
|
|
|
2606
2660
|
perPage: 500
|
|
2607
2661
|
}
|
|
2608
2662
|
})).data.map((e) => ({
|
|
2609
|
-
label:
|
|
2663
|
+
label: Or(e, n),
|
|
2610
2664
|
value: e[r],
|
|
2611
2665
|
record: e
|
|
2612
2666
|
}));
|
|
2613
2667
|
}
|
|
2614
|
-
function
|
|
2615
|
-
let a =
|
|
2668
|
+
function Ar(e, t, n, r, i) {
|
|
2669
|
+
let a = Dr(e, i), o = Tr.get(a);
|
|
2616
2670
|
if (o && !i) return Promise.resolve(o);
|
|
2617
|
-
let s =
|
|
2671
|
+
let s = Er.get(a);
|
|
2618
2672
|
if (s) return s;
|
|
2619
|
-
let c =
|
|
2620
|
-
|
|
2673
|
+
let c = kr(e, t, n, r, i).then((e) => (i || Tr.set(a, e), e)).finally(() => {
|
|
2674
|
+
Er.delete(a);
|
|
2621
2675
|
});
|
|
2622
|
-
return
|
|
2676
|
+
return Er.set(a, c), c;
|
|
2623
2677
|
}
|
|
2624
2678
|
function $(e, t, n = "name", r = "id", a) {
|
|
2625
|
-
let c =
|
|
2679
|
+
let c = yt(), u = s(() => {
|
|
2626
2680
|
if (e) return e;
|
|
2627
2681
|
if (t) return {
|
|
2628
2682
|
resource: t,
|
|
@@ -2632,19 +2686,19 @@ function $(e, t, n = "name", r = "id", a) {
|
|
|
2632
2686
|
e,
|
|
2633
2687
|
t,
|
|
2634
2688
|
a
|
|
2635
|
-
]), d = u ?
|
|
2689
|
+
]), d = u ? Dr(u, a) : void 0, [f, p] = l(() => !d || a ? [] : Tr.get(d) ?? []), [m, h] = l(() => !d || a ? !!u : !Tr.has(d)), g = i(async () => {
|
|
2636
2690
|
if (!u) {
|
|
2637
2691
|
p([]), h(!1);
|
|
2638
2692
|
return;
|
|
2639
2693
|
}
|
|
2640
|
-
let e =
|
|
2694
|
+
let e = Dr(u, a), t = Tr.get(e);
|
|
2641
2695
|
if (t && !a) {
|
|
2642
2696
|
p(t), h(!1);
|
|
2643
2697
|
return;
|
|
2644
2698
|
}
|
|
2645
2699
|
h(!0);
|
|
2646
2700
|
try {
|
|
2647
|
-
p(await
|
|
2701
|
+
p(await Ar(u, c, n, r, a));
|
|
2648
2702
|
} catch {
|
|
2649
2703
|
p([]);
|
|
2650
2704
|
} finally {
|
|
@@ -2672,62 +2726,230 @@ function $(e, t, n = "name", r = "id", a) {
|
|
|
2672
2726
|
}
|
|
2673
2727
|
//#endregion
|
|
2674
2728
|
//#region src/crud/fields/ReferenceField.tsx
|
|
2675
|
-
function
|
|
2676
|
-
let [_, v] = l(), { options: y, loading: b, optionForValue: x } = $(
|
|
2729
|
+
function jr({ 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 }) {
|
|
2730
|
+
let [_, v] = l(), { options: y, loading: b, optionForValue: x } = $(i, r, a, o, d ? _ : void 0), S = s(() => y.map((e) => ({
|
|
2677
2731
|
label: e.label,
|
|
2678
2732
|
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
|
-
|
|
2733
|
+
})), [y]);
|
|
2734
|
+
return /* @__PURE__ */ V(Q, {
|
|
2735
|
+
source: e,
|
|
2736
|
+
name: t,
|
|
2737
|
+
label: n,
|
|
2738
|
+
required: c,
|
|
2739
|
+
rules: u,
|
|
2740
|
+
hideLabel: m,
|
|
2741
|
+
children: ({ value: e, onChange: t, disabled: n, name: r }) => /* @__PURE__ */ V(P, {
|
|
2742
|
+
value: e,
|
|
2743
|
+
onChange: (e) => {
|
|
2744
|
+
t(e), g?.(e, x(e), { name: r });
|
|
2745
|
+
},
|
|
2746
|
+
options: S,
|
|
2747
|
+
loading: b && y.length === 0,
|
|
2748
|
+
showSearch: d,
|
|
2749
|
+
filterOption: d ? !1 : void 0,
|
|
2750
|
+
onSearch: d ? v : void 0,
|
|
2751
|
+
allowClear: f,
|
|
2752
|
+
disabled: n || p,
|
|
2753
|
+
optionFilterProp: "label",
|
|
2754
|
+
style: {
|
|
2755
|
+
width: "100%",
|
|
2756
|
+
minWidth: 160,
|
|
2757
|
+
...h
|
|
2758
|
+
}
|
|
2759
|
+
})
|
|
2703
2760
|
});
|
|
2704
|
-
return C.mode === "inline" ? null : C.element;
|
|
2705
2761
|
}
|
|
2706
2762
|
//#endregion
|
|
2707
2763
|
//#region src/crud/fields/ReferenceManyField.tsx
|
|
2708
|
-
function
|
|
2709
|
-
let [
|
|
2764
|
+
function Mr({ 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 }) {
|
|
2765
|
+
let [m, h] = l(), { options: g, loading: _ } = $(i, r, a, o, d ? m : void 0), v = s(() => g.map((e) => ({
|
|
2710
2766
|
label: e.label,
|
|
2711
2767
|
value: e.value
|
|
2712
|
-
})), [
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2768
|
+
})), [g]);
|
|
2769
|
+
return /* @__PURE__ */ V(Q, {
|
|
2770
|
+
source: e,
|
|
2771
|
+
name: t,
|
|
2772
|
+
label: n,
|
|
2773
|
+
required: c,
|
|
2774
|
+
rules: u,
|
|
2775
|
+
hideLabel: p,
|
|
2776
|
+
children: ({ value: e, onChange: t, disabled: n }) => /* @__PURE__ */ V(P, {
|
|
2777
|
+
mode: "multiple",
|
|
2778
|
+
value: e ?? [],
|
|
2779
|
+
onChange: t,
|
|
2780
|
+
options: v,
|
|
2781
|
+
loading: _,
|
|
2782
|
+
showSearch: d,
|
|
2783
|
+
filterOption: d ? !1 : void 0,
|
|
2784
|
+
onSearch: d ? h : void 0,
|
|
2785
|
+
allowClear: f,
|
|
2786
|
+
disabled: n,
|
|
2787
|
+
optionFilterProp: "label",
|
|
2788
|
+
style: { width: "100%" }
|
|
2789
|
+
})
|
|
2790
|
+
});
|
|
2791
|
+
}
|
|
2792
|
+
//#endregion
|
|
2793
|
+
//#region src/crud/fields/uploadFieldUtils.ts
|
|
2794
|
+
function Nr(e) {
|
|
2795
|
+
return e instanceof File ? !0 : typeof e == "string" && e.length > 0;
|
|
2796
|
+
}
|
|
2797
|
+
function Pr(e) {
|
|
2798
|
+
if (e instanceof File) return e.name;
|
|
2799
|
+
if (typeof e == "string" && e.length > 0) try {
|
|
2800
|
+
return new URL(e, "http://local").pathname.split("/").filter(Boolean).pop() || e;
|
|
2801
|
+
} catch {
|
|
2802
|
+
return e.split("/").filter(Boolean).pop() || e;
|
|
2803
|
+
}
|
|
2804
|
+
}
|
|
2805
|
+
//#endregion
|
|
2806
|
+
//#region src/crud/fields/useUploadPreviewUrl.ts
|
|
2807
|
+
function Fr(e) {
|
|
2808
|
+
let [t, n] = l();
|
|
2809
|
+
if (o(() => {
|
|
2810
|
+
if (e instanceof File) {
|
|
2811
|
+
let t = URL.createObjectURL(e);
|
|
2812
|
+
return n(t), () => URL.revokeObjectURL(t);
|
|
2813
|
+
}
|
|
2814
|
+
n(void 0);
|
|
2815
|
+
}, [e]), e instanceof File) return t;
|
|
2816
|
+
if (typeof e == "string" && e.length > 0) return e;
|
|
2817
|
+
}
|
|
2818
|
+
//#endregion
|
|
2819
|
+
//#region src/crud/fields/ImageField.tsx
|
|
2820
|
+
function Ir({ value: e, onChange: t, disabled: n, clearable: r, accept: i = "image/*", previewWidth: a = 200 }) {
|
|
2821
|
+
let o = c(null), s = Fr(e), l = r && Nr(e);
|
|
2822
|
+
return /* @__PURE__ */ H(F, {
|
|
2823
|
+
direction: "vertical",
|
|
2824
|
+
size: "middle",
|
|
2825
|
+
style: { width: "100%" },
|
|
2826
|
+
children: [
|
|
2827
|
+
s ? /* @__PURE__ */ V(k, {
|
|
2828
|
+
src: s,
|
|
2829
|
+
alt: "",
|
|
2830
|
+
style: {
|
|
2831
|
+
maxWidth: a,
|
|
2832
|
+
maxHeight: a,
|
|
2833
|
+
objectFit: "contain"
|
|
2834
|
+
}
|
|
2835
|
+
}) : null,
|
|
2836
|
+
/* @__PURE__ */ H(F, {
|
|
2837
|
+
wrap: !0,
|
|
2838
|
+
children: [/* @__PURE__ */ V(x, {
|
|
2839
|
+
icon: /* @__PURE__ */ V(ye, {}),
|
|
2840
|
+
disabled: n,
|
|
2841
|
+
onClick: () => o.current?.click(),
|
|
2842
|
+
children: "Choose image"
|
|
2843
|
+
}), l ? /* @__PURE__ */ V(x, {
|
|
2844
|
+
icon: /* @__PURE__ */ V(ue, {}),
|
|
2845
|
+
disabled: n,
|
|
2846
|
+
onClick: () => {
|
|
2847
|
+
t(null), o.current && (o.current.value = "");
|
|
2848
|
+
},
|
|
2849
|
+
children: "Clear"
|
|
2850
|
+
}) : null]
|
|
2851
|
+
}),
|
|
2852
|
+
/* @__PURE__ */ V("input", {
|
|
2853
|
+
ref: o,
|
|
2854
|
+
type: "file",
|
|
2855
|
+
accept: i,
|
|
2856
|
+
disabled: n,
|
|
2857
|
+
tabIndex: -1,
|
|
2858
|
+
"aria-hidden": !0,
|
|
2859
|
+
style: { display: "none" },
|
|
2860
|
+
onChange: (e) => {
|
|
2861
|
+
let n = e.target.files?.[0];
|
|
2862
|
+
t(n ?? null), e.target.value = "";
|
|
2863
|
+
}
|
|
2864
|
+
})
|
|
2865
|
+
]
|
|
2866
|
+
});
|
|
2867
|
+
}
|
|
2868
|
+
function Lr({ source: e, name: t, label: n, required: r, rules: i, hideLabel: a, clearable: o, accept: s, previewWidth: c }) {
|
|
2869
|
+
return /* @__PURE__ */ V(Q, {
|
|
2870
|
+
source: e,
|
|
2871
|
+
name: t,
|
|
2872
|
+
label: n,
|
|
2873
|
+
required: r,
|
|
2874
|
+
rules: i,
|
|
2875
|
+
hideLabel: a,
|
|
2876
|
+
children: ({ value: e, onChange: t, disabled: n }) => /* @__PURE__ */ V(Ir, {
|
|
2877
|
+
value: e,
|
|
2878
|
+
onChange: t,
|
|
2879
|
+
disabled: n,
|
|
2880
|
+
clearable: o,
|
|
2881
|
+
accept: s,
|
|
2882
|
+
previewWidth: c
|
|
2883
|
+
})
|
|
2884
|
+
});
|
|
2885
|
+
}
|
|
2886
|
+
//#endregion
|
|
2887
|
+
//#region src/crud/fields/FileField.tsx
|
|
2888
|
+
function Rr({ value: e, onChange: t, disabled: n, clearable: r, accept: i }) {
|
|
2889
|
+
let a = c(null), o = Pr(e), s = typeof e == "string" && e.length > 0 ? e : void 0, l = r && Nr(e);
|
|
2890
|
+
return /* @__PURE__ */ H(F, {
|
|
2891
|
+
direction: "vertical",
|
|
2892
|
+
size: "middle",
|
|
2893
|
+
style: { width: "100%" },
|
|
2894
|
+
children: [
|
|
2895
|
+
o ? /* @__PURE__ */ H(F, { children: [/* @__PURE__ */ V(ge, {}), s ? /* @__PURE__ */ V(R.Link, {
|
|
2896
|
+
href: s,
|
|
2897
|
+
target: "_blank",
|
|
2898
|
+
rel: "noopener noreferrer",
|
|
2899
|
+
children: o
|
|
2900
|
+
}) : /* @__PURE__ */ V(R.Text, { children: o })] }) : null,
|
|
2901
|
+
/* @__PURE__ */ H(F, {
|
|
2902
|
+
wrap: !0,
|
|
2903
|
+
children: [/* @__PURE__ */ V(x, {
|
|
2904
|
+
icon: /* @__PURE__ */ V(ye, {}),
|
|
2905
|
+
disabled: n,
|
|
2906
|
+
onClick: () => a.current?.click(),
|
|
2907
|
+
children: "Choose file"
|
|
2908
|
+
}), l ? /* @__PURE__ */ V(x, {
|
|
2909
|
+
icon: /* @__PURE__ */ V(ue, {}),
|
|
2910
|
+
disabled: n,
|
|
2911
|
+
onClick: () => {
|
|
2912
|
+
t(null), a.current && (a.current.value = "");
|
|
2913
|
+
},
|
|
2914
|
+
children: "Clear"
|
|
2915
|
+
}) : null]
|
|
2916
|
+
}),
|
|
2917
|
+
/* @__PURE__ */ V("input", {
|
|
2918
|
+
ref: a,
|
|
2919
|
+
type: "file",
|
|
2920
|
+
accept: i,
|
|
2921
|
+
disabled: n,
|
|
2922
|
+
tabIndex: -1,
|
|
2923
|
+
"aria-hidden": !0,
|
|
2924
|
+
style: { display: "none" },
|
|
2925
|
+
onChange: (e) => {
|
|
2926
|
+
let n = e.target.files?.[0];
|
|
2927
|
+
t(n ?? null), e.target.value = "";
|
|
2928
|
+
}
|
|
2929
|
+
})
|
|
2930
|
+
]
|
|
2931
|
+
});
|
|
2932
|
+
}
|
|
2933
|
+
function zr({ source: e, name: t, label: n, required: r, rules: i, hideLabel: a, clearable: o, accept: s }) {
|
|
2934
|
+
return /* @__PURE__ */ V(Q, {
|
|
2935
|
+
source: e,
|
|
2936
|
+
name: t,
|
|
2937
|
+
label: n,
|
|
2938
|
+
required: r,
|
|
2939
|
+
rules: i,
|
|
2940
|
+
hideLabel: a,
|
|
2941
|
+
children: ({ value: e, onChange: t, disabled: n }) => /* @__PURE__ */ V(Rr, {
|
|
2942
|
+
value: e,
|
|
2943
|
+
onChange: t,
|
|
2944
|
+
disabled: n,
|
|
2945
|
+
clearable: o,
|
|
2946
|
+
accept: s
|
|
2947
|
+
})
|
|
2948
|
+
});
|
|
2727
2949
|
}
|
|
2728
2950
|
//#endregion
|
|
2729
2951
|
//#region src/crud/columns/TextColumn.tsx
|
|
2730
|
-
function
|
|
2952
|
+
function Br({ source: e, label: t, sortable: n = !0 }) {
|
|
2731
2953
|
return X(s(() => ({
|
|
2732
2954
|
key: e,
|
|
2733
2955
|
source: e,
|
|
@@ -2745,12 +2967,12 @@ function _r({ source: e, label: t, sortable: n = !0 }) {
|
|
|
2745
2967
|
n
|
|
2746
2968
|
])), null;
|
|
2747
2969
|
}
|
|
2748
|
-
function
|
|
2749
|
-
return typeof n == "function" ? n(e) : n ?
|
|
2970
|
+
function Vr(e, t, n) {
|
|
2971
|
+
return typeof n == "function" ? n(e) : n ? Sn(e, n) : e[t];
|
|
2750
2972
|
}
|
|
2751
2973
|
//#endregion
|
|
2752
2974
|
//#region src/crud/columns/NumberColumn.tsx
|
|
2753
|
-
function
|
|
2975
|
+
function Hr({ source: e, label: t, sortable: n = !0 }) {
|
|
2754
2976
|
return X(s(() => ({
|
|
2755
2977
|
key: e,
|
|
2756
2978
|
source: e,
|
|
@@ -2770,7 +2992,7 @@ function yr({ source: e, label: t, sortable: n = !0 }) {
|
|
|
2770
2992
|
}
|
|
2771
2993
|
//#endregion
|
|
2772
2994
|
//#region src/crud/columns/BooleanColumn.tsx
|
|
2773
|
-
function
|
|
2995
|
+
function Ur({ source: e, label: t, sortable: n = !0 }) {
|
|
2774
2996
|
return X(s(() => ({
|
|
2775
2997
|
key: e,
|
|
2776
2998
|
source: e,
|
|
@@ -2791,7 +3013,7 @@ function br({ source: e, label: t, sortable: n = !0 }) {
|
|
|
2791
3013
|
}
|
|
2792
3014
|
//#endregion
|
|
2793
3015
|
//#region src/crud/columns/DateColumn.tsx
|
|
2794
|
-
function
|
|
3016
|
+
function Wr({ source: e, label: t, sortable: n = !0 }) {
|
|
2795
3017
|
return X(s(() => ({
|
|
2796
3018
|
key: e,
|
|
2797
3019
|
source: e,
|
|
@@ -2812,16 +3034,16 @@ function xr({ source: e, label: t, sortable: n = !0 }) {
|
|
|
2812
3034
|
}
|
|
2813
3035
|
//#endregion
|
|
2814
3036
|
//#region src/crud/columns/ReferenceColumn.tsx
|
|
2815
|
-
function
|
|
3037
|
+
function Gr({ record: e, source: t, display: n, reference: r, choices: i, optionLabel: a, optionValue: o }) {
|
|
2816
3038
|
let { labelForValue: s } = $(i, r, a, o), c = e[t];
|
|
2817
3039
|
if (typeof n == "function") return /* @__PURE__ */ V(B, { children: n(e) });
|
|
2818
3040
|
if (n && n !== t) {
|
|
2819
|
-
let r =
|
|
3041
|
+
let r = Vr(e, t, n);
|
|
2820
3042
|
return /* @__PURE__ */ V(B, { children: r == null ? "—" : String(r) });
|
|
2821
3043
|
}
|
|
2822
3044
|
return /* @__PURE__ */ V(B, { children: s(c) });
|
|
2823
3045
|
}
|
|
2824
|
-
function
|
|
3046
|
+
function Kr({ source: e, label: t, reference: n, choices: r, optionLabel: i = "name", optionValue: a = "id", display: o, sortable: c = !0 }) {
|
|
2825
3047
|
return X(s(() => ({
|
|
2826
3048
|
key: e,
|
|
2827
3049
|
source: e,
|
|
@@ -2832,7 +3054,7 @@ function Cr({ source: e, label: t, reference: n, choices: r, optionLabel: i = "n
|
|
|
2832
3054
|
dataIndex: e,
|
|
2833
3055
|
key: e,
|
|
2834
3056
|
sorter: c ? !0 : void 0,
|
|
2835
|
-
render: (s, c) => /* @__PURE__ */ V(
|
|
3057
|
+
render: (s, c) => /* @__PURE__ */ V(Gr, {
|
|
2836
3058
|
record: c,
|
|
2837
3059
|
source: e,
|
|
2838
3060
|
label: t,
|
|
@@ -2856,11 +3078,11 @@ function Cr({ source: e, label: t, reference: n, choices: r, optionLabel: i = "n
|
|
|
2856
3078
|
}
|
|
2857
3079
|
//#endregion
|
|
2858
3080
|
//#region src/crud/columns/ReferenceManyColumn.tsx
|
|
2859
|
-
function
|
|
3081
|
+
function qr({ record: e, source: t, reference: n, choices: r, optionLabel: i, optionValue: a }) {
|
|
2860
3082
|
let { labelsForValues: o } = $(r, n, i, a), s = e[t];
|
|
2861
3083
|
return /* @__PURE__ */ V(B, { children: o(Array.isArray(s) ? s : []) });
|
|
2862
3084
|
}
|
|
2863
|
-
function
|
|
3085
|
+
function Jr({ source: e, label: t, reference: n, choices: r, optionLabel: i = "name", optionValue: a = "id", sortable: o = !1 }) {
|
|
2864
3086
|
return X(s(() => ({
|
|
2865
3087
|
key: e,
|
|
2866
3088
|
source: e,
|
|
@@ -2871,7 +3093,7 @@ function Tr({ source: e, label: t, reference: n, choices: r, optionLabel: i = "n
|
|
|
2871
3093
|
dataIndex: e,
|
|
2872
3094
|
key: e,
|
|
2873
3095
|
sorter: o ? !0 : void 0,
|
|
2874
|
-
render: (t, o) => /* @__PURE__ */ V(
|
|
3096
|
+
render: (t, o) => /* @__PURE__ */ V(qr, {
|
|
2875
3097
|
record: o,
|
|
2876
3098
|
source: e,
|
|
2877
3099
|
reference: n,
|
|
@@ -2891,8 +3113,43 @@ function Tr({ source: e, label: t, reference: n, choices: r, optionLabel: i = "n
|
|
|
2891
3113
|
])), null;
|
|
2892
3114
|
}
|
|
2893
3115
|
//#endregion
|
|
3116
|
+
//#region src/crud/columns/ImageColumn.tsx
|
|
3117
|
+
function Yr({ source: e, label: t, sortable: n = !1, width: r = 40, height: i = 40, objectFit: a = "cover", borderRadius: o = 4, alt: c = "" }) {
|
|
3118
|
+
return X(s(() => ({
|
|
3119
|
+
key: e,
|
|
3120
|
+
source: e,
|
|
3121
|
+
label: t,
|
|
3122
|
+
sortable: n,
|
|
3123
|
+
buildColumn: () => ({
|
|
3124
|
+
title: t ?? e,
|
|
3125
|
+
dataIndex: e,
|
|
3126
|
+
key: e,
|
|
3127
|
+
sorter: n ? !0 : void 0,
|
|
3128
|
+
render: (e) => e == null || e === "" ? null : /* @__PURE__ */ V("img", {
|
|
3129
|
+
src: String(e),
|
|
3130
|
+
alt: c,
|
|
3131
|
+
style: {
|
|
3132
|
+
width: r,
|
|
3133
|
+
height: i,
|
|
3134
|
+
objectFit: a,
|
|
3135
|
+
borderRadius: o
|
|
3136
|
+
}
|
|
3137
|
+
})
|
|
3138
|
+
})
|
|
3139
|
+
}), [
|
|
3140
|
+
e,
|
|
3141
|
+
t,
|
|
3142
|
+
n,
|
|
3143
|
+
r,
|
|
3144
|
+
i,
|
|
3145
|
+
a,
|
|
3146
|
+
o,
|
|
3147
|
+
c
|
|
3148
|
+
])), null;
|
|
3149
|
+
}
|
|
3150
|
+
//#endregion
|
|
2894
3151
|
//#region src/crud/columns/CustomColumn.tsx
|
|
2895
|
-
function
|
|
3152
|
+
function Xr({ source: e, label: t, sortable: n = !1, render: r }) {
|
|
2896
3153
|
return X(s(() => ({
|
|
2897
3154
|
key: e,
|
|
2898
3155
|
source: e,
|
|
@@ -2912,12 +3169,12 @@ function Er({ source: e, label: t, sortable: n = !1, render: r }) {
|
|
|
2912
3169
|
}
|
|
2913
3170
|
//#endregion
|
|
2914
3171
|
//#region src/crud/filters/TextFilter.tsx
|
|
2915
|
-
function
|
|
3172
|
+
function Zr({ source: e, label: t, placeholder: n }) {
|
|
2916
3173
|
return Z(s(() => ({
|
|
2917
3174
|
key: e,
|
|
2918
3175
|
source: e,
|
|
2919
3176
|
label: t,
|
|
2920
|
-
render: ({ value: r, onChange: i }) => /* @__PURE__ */ V(
|
|
3177
|
+
render: ({ value: r, onChange: i }) => /* @__PURE__ */ V(A, {
|
|
2921
3178
|
allowClear: !0,
|
|
2922
3179
|
placeholder: n ?? t ?? e,
|
|
2923
3180
|
value: r ?? "",
|
|
@@ -2932,12 +3189,12 @@ function Dr({ source: e, label: t, placeholder: n }) {
|
|
|
2932
3189
|
}
|
|
2933
3190
|
//#endregion
|
|
2934
3191
|
//#region src/crud/filters/NumberFilter.tsx
|
|
2935
|
-
function
|
|
3192
|
+
function Qr({ source: e, label: t }) {
|
|
2936
3193
|
return Z(s(() => ({
|
|
2937
3194
|
key: e,
|
|
2938
3195
|
source: e,
|
|
2939
3196
|
label: t,
|
|
2940
|
-
render: ({ value: n, onChange: r }) => /* @__PURE__ */ V(
|
|
3197
|
+
render: ({ value: n, onChange: r }) => /* @__PURE__ */ V(te, {
|
|
2941
3198
|
placeholder: t ?? e,
|
|
2942
3199
|
value: n,
|
|
2943
3200
|
onChange: (e) => r(e ?? void 0),
|
|
@@ -2947,7 +3204,7 @@ function Or({ source: e, label: t }) {
|
|
|
2947
3204
|
}
|
|
2948
3205
|
//#endregion
|
|
2949
3206
|
//#region src/crud/filters/BooleanFilter.tsx
|
|
2950
|
-
function
|
|
3207
|
+
function $r({ source: e, label: t }) {
|
|
2951
3208
|
return Z(s(() => ({
|
|
2952
3209
|
key: e,
|
|
2953
3210
|
source: e,
|
|
@@ -2970,7 +3227,7 @@ function kr({ source: e, label: t }) {
|
|
|
2970
3227
|
}
|
|
2971
3228
|
//#endregion
|
|
2972
3229
|
//#region src/crud/filters/DateFilter.tsx
|
|
2973
|
-
function
|
|
3230
|
+
function ei({ source: e, label: t }) {
|
|
2974
3231
|
return Z(s(() => ({
|
|
2975
3232
|
key: e,
|
|
2976
3233
|
source: e,
|
|
@@ -2978,7 +3235,7 @@ function Ar({ source: e, label: t }) {
|
|
|
2978
3235
|
render: ({ value: n, onChange: r }) => /* @__PURE__ */ V(w, {
|
|
2979
3236
|
allowClear: !0,
|
|
2980
3237
|
placeholder: t ?? e,
|
|
2981
|
-
value: n ?
|
|
3238
|
+
value: n ? Ee(String(n)) : null,
|
|
2982
3239
|
onChange: (e) => r(e ? e.format("YYYY-MM-DD") : void 0),
|
|
2983
3240
|
style: { minWidth: 160 }
|
|
2984
3241
|
})
|
|
@@ -2986,7 +3243,7 @@ function Ar({ source: e, label: t }) {
|
|
|
2986
3243
|
}
|
|
2987
3244
|
//#endregion
|
|
2988
3245
|
//#region src/crud/filters/SelectFilter.tsx
|
|
2989
|
-
function
|
|
3246
|
+
function ti({ source: e, label: t, choices: n, multiple: r }) {
|
|
2990
3247
|
return Z(s(() => ({
|
|
2991
3248
|
key: e,
|
|
2992
3249
|
source: e,
|
|
@@ -3009,7 +3266,7 @@ function jr({ source: e, label: t, choices: n, multiple: r }) {
|
|
|
3009
3266
|
}
|
|
3010
3267
|
//#endregion
|
|
3011
3268
|
//#region src/crud/filters/ReferenceFilter.tsx
|
|
3012
|
-
function
|
|
3269
|
+
function ni({ source: e, label: t, reference: n, choices: r, optionLabel: i, optionValue: a, multiple: o, search: s, value: c, onChange: u }) {
|
|
3013
3270
|
let [d, f] = l(), { options: p, loading: m } = $(r, n, i, a, s ? d : void 0);
|
|
3014
3271
|
return /* @__PURE__ */ V(P, {
|
|
3015
3272
|
allowClear: !0,
|
|
@@ -3029,12 +3286,12 @@ function Mr({ source: e, label: t, reference: n, choices: r, optionLabel: i, opt
|
|
|
3029
3286
|
style: { minWidth: 180 }
|
|
3030
3287
|
});
|
|
3031
3288
|
}
|
|
3032
|
-
function
|
|
3289
|
+
function ri({ source: e, label: t, reference: n, choices: r, optionLabel: i = "name", optionValue: a = "id", multiple: o, search: c }) {
|
|
3033
3290
|
return Z(s(() => ({
|
|
3034
3291
|
key: e,
|
|
3035
3292
|
source: e,
|
|
3036
3293
|
label: t,
|
|
3037
|
-
render: ({ value: s, onChange: l }) => /* @__PURE__ */ V(
|
|
3294
|
+
render: ({ value: s, onChange: l }) => /* @__PURE__ */ V(ni, {
|
|
3038
3295
|
source: e,
|
|
3039
3296
|
label: t,
|
|
3040
3297
|
reference: n,
|
|
@@ -3057,11 +3314,11 @@ function Nr({ source: e, label: t, reference: n, choices: r, optionLabel: i = "n
|
|
|
3057
3314
|
c
|
|
3058
3315
|
])), null;
|
|
3059
3316
|
}
|
|
3060
|
-
function
|
|
3061
|
-
return /* @__PURE__ */ V(
|
|
3317
|
+
function ii(e) {
|
|
3318
|
+
return /* @__PURE__ */ V(ri, {
|
|
3062
3319
|
...e,
|
|
3063
3320
|
multiple: !0
|
|
3064
3321
|
});
|
|
3065
3322
|
}
|
|
3066
3323
|
//#endregion
|
|
3067
|
-
export {
|
|
3324
|
+
export { gt as AdminApp, it as AdminLayout, Ne as AppThemeProvider, Zt as AuthAlternateLink, Qt as AuthPageLayout, Ve as AuthProvider, Ur as BooleanColumn, yr as BooleanField, $r as BooleanFilter, Xr as CustomColumn, vt as DataProvider, Wr as DateColumn, xr as DateField, ei as DateFilter, Ie as DensitySwitch, Q as FieldWrapper, zr as FileField, Yn as FilterBar, mr as FormStep, gr as FormSteps, dr as FormTab, pr as FormTabs, at as Guard, st as GuestOnly, Yr as ImageColumn, Lr as ImageField, or as InlineFormSet, sr as InlineFormSetStacked, $t as LoginPage, Hr as NumberColumn, vr as NumberField, Qr as NumberFilter, wr as PasswordField, Ke as PermissionsProvider, en as PlaceholderPage, ot as Protected, Kr as ReferenceColumn, jr as ReferenceField, ri as ReferenceFilter, Jr as ReferenceManyColumn, Mr as ReferenceManyField, ii as ReferenceManyFilter, ct as RequirePermission, nr as ResourceForm, In as ResourceFormModal, qn as ResourceList, Sr as SelectField, ti as SelectFilter, Br as TextColumn, _r as TextField, Zr as TextFilter, Re as ThemeSwitch, ze as ThemeToolbar, Wt as applyInMemoryListParams, Y as asStringMessages, wn as buildFormPayload, Tn as buildInlineRowsPayload, jn as buildResourceFormSubmitBody, xt as combineResourceHandlers, ht as createAdminRouter, Gt as createMemoryResourceHandlers, qe as createPermissionsChecker, Kt as createRestResourceHandlers, We as createSessionStorageAuthAdapter, pt as deriveAuthPaths, Ye as filterNavByPermission, Ht as filterRows, At as finalizeFormErrors, kt as flattenNestedArrayErrors, Et as getErrorBody, Sn as getFormValue, lt as getRouteAccess, zt as getRowById, En as hasUploadValues, St as isAbortError, rr as nestedFieldPath, Nt as parseDjangoDRFFormErrors, Pt as parseDotNetFormErrors, Ft as parseNodeFormErrors, ut as partitionAdminRoutes, An as prepareFormSubmitBody, Dt as resolveErrorBody, Cn as setFormValue, Jt as toDjangoRestOrdering, kn as toFormData, Xt as toJsonApiSort, Yt as toODataOrderBy, Fn as useAbortableEffect, He as useAuth, Je as useCan, $ as useChoices, yt as useDataProvider, Un as useListQueryState, K as usePermissions, bn as useRegisterPayloadField, xn as useRegisterSectionField, Gn as useResourceListContext, Pe as useThemeMode };
|