ding-react-admin 1.0.4 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +254 -201
- package/dist/index.css +2 -0
- package/dist/index.js +2073 -1202
- package/dist/src/components/NavMenuLabel.d.ts +8 -0
- package/dist/src/components/NavMenuLabel.d.ts.map +1 -0
- package/dist/src/components/NavMenuSearch.d.ts +9 -0
- package/dist/src/components/NavMenuSearch.d.ts.map +1 -0
- package/dist/src/components/ScrollableArea.d.ts +10 -0
- package/dist/src/components/ScrollableArea.d.ts.map +1 -0
- package/dist/src/components/index.d.ts +3 -0
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/context/AuthProvider.d.ts +2 -0
- package/dist/src/context/AuthProvider.d.ts.map +1 -1
- package/dist/src/crud/FormGlobalErrorsAlert.d.ts +5 -0
- package/dist/src/crud/FormGlobalErrorsAlert.d.ts.map +1 -0
- package/dist/src/crud/InlineFormSet.d.ts +2 -17
- package/dist/src/crud/InlineFormSet.d.ts.map +1 -1
- package/dist/src/crud/ResourceForm.d.ts +2 -10
- package/dist/src/crud/ResourceForm.d.ts.map +1 -1
- package/dist/src/crud/ResourceFormModal.d.ts +7 -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/ResourceRecordForm.d.ts +27 -0
- package/dist/src/crud/ResourceRecordForm.d.ts.map +1 -0
- 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/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/ReferenceField.d.ts +12 -2
- package/dist/src/crud/fields/ReferenceField.d.ts.map +1 -1
- package/dist/src/crud/fields/ReferenceInputActions.d.ts +16 -0
- package/dist/src/crud/fields/ReferenceInputActions.d.ts.map +1 -0
- package/dist/src/crud/fields/ReferenceManyField.d.ts +10 -1
- package/dist/src/crud/fields/ReferenceManyField.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/filters/ReferenceFilter.d.ts +1 -1
- package/dist/src/crud/filters/ReferenceFilter.d.ts.map +1 -1
- package/dist/src/crud/index.d.ts +27 -9
- package/dist/src/crud/index.d.ts.map +1 -1
- package/dist/src/crud/types.d.ts +21 -7
- 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/choiceSelectionUtils.d.ts +10 -0
- package/dist/src/crud/utils/choiceSelectionUtils.d.ts.map +1 -0
- package/dist/src/crud/utils/choiceSelectionUtils.test.d.ts +2 -0
- package/dist/src/crud/utils/choiceSelectionUtils.test.d.ts.map +1 -0
- package/dist/src/crud/utils/formErrors.d.ts +18 -7
- package/dist/src/crud/utils/formErrors.d.ts.map +1 -1
- package/dist/src/crud/utils/formErrors.test.d.ts +2 -0
- package/dist/src/crud/utils/formErrors.test.d.ts.map +1 -0
- 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 +8 -0
- package/dist/src/crud/utils/prepareFormSubmitBody.d.ts.map +1 -0
- package/dist/src/crud/utils/referenceSelectNotFoundContent.d.ts +4 -0
- package/dist/src/crud/utils/referenceSelectNotFoundContent.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/uploadReferenceUtils.d.ts +5 -0
- package/dist/src/crud/utils/uploadReferenceUtils.d.ts.map +1 -0
- package/dist/src/crud/utils/useChoices.d.ts +27 -1
- package/dist/src/crud/utils/useChoices.d.ts.map +1 -1
- package/dist/src/crud/utils/useFormRecord.d.ts +44 -0
- package/dist/src/crud/utils/useFormRecord.d.ts.map +1 -0
- package/dist/src/data/createRestResourceHandlers.d.ts +5 -5
- package/dist/src/data/createRestResourceHandlers.d.ts.map +1 -1
- package/dist/src/data/dataProviderTypes.d.ts +6 -5
- package/dist/src/data/dataProviderTypes.d.ts.map +1 -1
- package/dist/src/data/parseFormErrorHelpers.d.ts +23 -6
- package/dist/src/data/parseFormErrorHelpers.d.ts.map +1 -1
- package/dist/src/data/resourceHandlers.d.ts +1 -1
- package/dist/src/data/resourceHandlers.d.ts.map +1 -1
- package/dist/src/index.d.ts +4 -4
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/layouts/AdminLayout.d.ts +1 -1
- package/dist/src/layouts/AdminLayout.d.ts.map +1 -1
- package/dist/src/layouts/AuthPageLayout.d.ts.map +1 -1
- package/dist/src/layouts/navFilter.d.ts +5 -0
- package/dist/src/layouts/navFilter.d.ts.map +1 -0
- package/dist/src/layouts/navMenuItems.d.ts +6 -0
- package/dist/src/layouts/navMenuItems.d.ts.map +1 -0
- package/dist/src/types.d.ts +12 -0
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +79 -59
- package/src/app/AdminApp.tsx +34 -34
- package/src/components/AuthAlternateLink.tsx +23 -23
- package/src/components/DensitySwitch.tsx +31 -31
- package/src/components/NavMenuLabel.tsx +26 -0
- package/src/components/NavMenuSearch.tsx +76 -0
- package/src/components/ScrollableArea.tsx +46 -0
- package/src/components/ThemeSwitch.tsx +28 -28
- package/src/components/ThemeToolbar.tsx +34 -34
- package/src/components/index.ts +7 -4
- package/src/components/navMenu.css +21 -0
- package/src/components/scrollable.css +28 -0
- package/src/context/AppThemeProvider.tsx +128 -128
- package/src/context/AuthProvider.tsx +89 -77
- package/src/context/DataProvider.tsx +30 -30
- package/src/context/PermissionsProvider.tsx +57 -57
- package/src/crud/FilterBar.tsx +36 -36
- package/src/crud/FormGlobalErrorsAlert.tsx +36 -0
- package/src/crud/FormSteps.tsx +135 -135
- package/src/crud/FormTabs.tsx +126 -126
- package/src/crud/InlineFormSet.tsx +162 -219
- package/src/crud/ListActionsBar.tsx +106 -106
- package/src/crud/ResourceForm.tsx +83 -166
- package/src/crud/ResourceFormModal.tsx +75 -133
- package/src/crud/ResourceList.tsx +1 -0
- package/src/crud/ResourceRecordForm.tsx +166 -0
- package/src/crud/columns/BooleanColumn.tsx +32 -32
- package/src/crud/columns/CustomColumn.tsx +33 -33
- package/src/crud/columns/DateColumn.tsx +28 -28
- package/src/crud/columns/ImageColumn.tsx +58 -0
- package/src/crud/columns/NumberColumn.tsx +31 -31
- package/src/crud/columns/ReferenceColumn.tsx +85 -85
- package/src/crud/columns/ReferenceManyColumn.tsx +67 -67
- package/src/crud/columns/TextColumn.tsx +38 -38
- package/src/crud/context/FilterContext.tsx +71 -71
- package/src/crud/context/FormContext.tsx +39 -39
- package/src/crud/context/FormSectionContext.tsx +22 -22
- package/src/crud/context/InlineFieldsRegistry.tsx +61 -0
- package/src/crud/context/ListContext.tsx +93 -93
- package/src/crud/context/PayloadFieldsContext.tsx +62 -0
- package/src/crud/fields/BooleanField.tsx +38 -38
- package/src/crud/fields/DateField.tsx +53 -53
- package/src/crud/fields/FieldWrapper.tsx +87 -87
- package/src/crud/fields/FileField.tsx +123 -0
- package/src/crud/fields/ImageField.tsx +120 -0
- package/src/crud/fields/NumberField.tsx +52 -52
- package/src/crud/fields/PasswordField.tsx +99 -99
- package/src/crud/fields/ReferenceField.tsx +237 -96
- package/src/crud/fields/ReferenceInputActions.tsx +106 -0
- package/src/crud/fields/ReferenceManyField.tsx +200 -76
- package/src/crud/fields/SelectField.tsx +48 -48
- package/src/crud/fields/TextField.tsx +46 -46
- package/src/crud/fields/uploadFieldUtils.ts +21 -0
- package/src/crud/fields/useUploadPreviewUrl.ts +20 -0
- package/src/crud/filters/BooleanFilter.tsx +38 -38
- package/src/crud/filters/DateFilter.tsx +35 -35
- package/src/crud/filters/NumberFilter.tsx +33 -33
- package/src/crud/filters/ReferenceFilter.tsx +192 -173
- package/src/crud/filters/SelectFilter.tsx +44 -44
- package/src/crud/filters/TextFilter.tsx +36 -36
- package/src/crud/index.ts +99 -90
- package/src/crud/types.ts +146 -132
- 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/choiceSelectionUtils.test.ts +45 -0
- package/src/crud/utils/choiceSelectionUtils.ts +116 -0
- package/src/crud/utils/formErrors.test.ts +168 -0
- package/src/crud/utils/formErrors.ts +138 -38
- package/src/crud/utils/formSectionErrors.ts +85 -85
- package/src/crud/utils/{getByPath.ts → getFormValue.ts} +13 -13
- package/src/crud/utils/hasUploadValues.ts +9 -0
- package/src/crud/utils/nestedFieldPath.ts +8 -0
- package/src/crud/utils/prepareFormSubmitBody.ts +22 -0
- package/src/crud/utils/referenceSelectNotFoundContent.tsx +7 -0
- package/src/crud/utils/{setByPath.ts → setFormValue.ts} +18 -18
- package/src/crud/utils/sortQueryParam.ts +37 -37
- package/src/crud/utils/toFormData.ts +79 -0
- package/src/crud/utils/uploadReferenceUtils.ts +44 -0
- package/src/crud/utils/useAbortableEffect.ts +17 -17
- package/src/crud/utils/useChoices.ts +330 -182
- package/src/crud/utils/useFormRecord.ts +179 -0
- package/src/crud/utils/useListQueryState.ts +191 -191
- package/src/data/abortError.test.ts +19 -19
- package/src/data/abortError.ts +10 -10
- package/src/data/createMemoryResourceHandlers.ts +78 -78
- package/src/data/createRestResourceHandlers.ts +63 -57
- package/src/data/dataProviderTypes.ts +7 -5
- package/src/data/dataUtils.test.ts +228 -108
- package/src/data/inMemoryList.ts +97 -97
- package/src/data/parseFormErrorHelpers.test.ts +201 -84
- package/src/data/parseFormErrorHelpers.ts +376 -224
- package/src/data/resourceHandlers.ts +1 -1
- package/src/data/sortHelpers.ts +48 -48
- package/src/index.ts +211 -195
- package/src/layouts/AdminLayout.tsx +530 -381
- package/src/layouts/AuthPageLayout.tsx +87 -81
- package/src/layouts/navFilter.ts +49 -0
- package/src/layouts/navMenuItems.tsx +44 -0
- package/src/pages/LoginPage.tsx +80 -80
- package/src/pages/PlaceholderPage.tsx +9 -9
- package/src/permissions/resourcePermissions.ts +47 -47
- package/src/router/createAdminRouter.tsx +64 -64
- package/src/router/guards.tsx +63 -63
- package/src/router/routeAccess.ts +89 -89
- package/src/types.ts +10 -0
- package/src/vite-env.d.ts +1 -1
- package/dist/src/crud/context/SubmitFieldsContext.d.ts +0 -18
- package/dist/src/crud/context/SubmitFieldsContext.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/inlineFieldName.d.ts +0 -3
- package/dist/src/crud/utils/inlineFieldName.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/dist/src/crud/utils/useResourceFormData.d.ts +0 -47
- package/dist/src/crud/utils/useResourceFormData.d.ts.map +0 -1
- package/src/crud/context/SubmitFieldsContext.tsx +0 -62
- package/src/crud/utils/inlineArrayName.ts +0 -4
- package/src/crud/utils/inlineFieldName.ts +0 -8
- package/src/crud/utils/pickBySources.ts +0 -24
- package/src/crud/utils/useResourceFormData.ts +0 -231
package/dist/index.js
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import { Children as e, createContext as t, createElement as n,
|
|
2
|
-
import { Link as
|
|
3
|
-
import { App as
|
|
4
|
-
import { Fragment as
|
|
5
|
-
import { ArrowLeftOutlined as
|
|
6
|
-
import { Controller as
|
|
7
|
-
import
|
|
1
|
+
import { Children as e, createContext as t, createElement as n, forwardRef as r, isValidElement as i, useCallback as a, useContext as o, useEffect as s, useMemo as c, useRef as l, useState as u } from "react";
|
|
2
|
+
import { Link as d, Navigate as f, Outlet as p, RouterProvider as m, createBrowserRouter as h, useLocation as g, useNavigate as _, useParams as v, useSearchParams as y } from "react-router-dom";
|
|
3
|
+
import { Alert as b, App as x, Avatar as S, Button as C, Card as w, ConfigProvider as T, DatePicker as E, Drawer as D, Dropdown as O, Flex as k, Form as A, Grid as j, Image as M, Input as N, InputNumber as P, Layout as F, Menu as ee, Modal as te, Popover as I, Segmented as ne, Select as L, Space as R, Spin as re, Steps as z, Switch as B, Table as ie, Tabs as V, Tooltip as H, Typography as U, theme as W } from "antd";
|
|
4
|
+
import { Fragment as G, jsx as K, jsxs as q } from "react/jsx-runtime";
|
|
5
|
+
import { ArrowLeftOutlined as ae, CaretDownOutlined as oe, CaretUpOutlined as se, ColumnHeightOutlined as ce, DeleteOutlined as le, DesktopOutlined as ue, EditOutlined as de, LayoutOutlined as fe, LogoutOutlined as pe, MenuOutlined as me, MoonOutlined as he, PaperClipOutlined as ge, PlusOutlined as _e, SearchOutlined as J, SettingOutlined as ve, SunOutlined as ye, UploadOutlined as be, UserOutlined as xe } from "@ant-design/icons";
|
|
6
|
+
import { Controller as Se, FormProvider as Ce, useFieldArray as we, useForm as Te, useFormContext as Ee, useFormState as De, useWatch as Oe } from "react-hook-form";
|
|
7
|
+
import ke from "dayjs";
|
|
8
8
|
//#region src/context/AppThemeProvider.tsx
|
|
9
|
-
var
|
|
10
|
-
function
|
|
9
|
+
var Ae = t(null);
|
|
10
|
+
function je(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 Me() {
|
|
18
18
|
return window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function Ne(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] =
|
|
30
|
-
|
|
27
|
+
var Pe = "ding-react-admin-theme-mode", Fe = "ding-react-admin-theme-density";
|
|
28
|
+
function Ie({ children: e, modeStorageKey: t = Pe, densityStorageKey: n = Fe }) {
|
|
29
|
+
let [r, i] = u(() => je(t)), [a, o] = u(() => Ne(n)), [l, d] = u(Me);
|
|
30
|
+
s(() => {
|
|
31
31
|
if (r !== "system") return;
|
|
32
32
|
let e = window.matchMedia("(prefers-color-scheme: dark)"), t = () => d(e.matches);
|
|
33
33
|
return t(), e.addEventListener("change", t), () => e.removeEventListener("change", t);
|
|
@@ -38,14 +38,14 @@ function Oe({ children: e, modeStorageKey: t = Ee, densityStorageKey: n = De })
|
|
|
38
38
|
localStorage.setItem(t, e);
|
|
39
39
|
} catch {}
|
|
40
40
|
}, p = (e) => {
|
|
41
|
-
|
|
41
|
+
o(e);
|
|
42
42
|
try {
|
|
43
43
|
localStorage.setItem(n, e);
|
|
44
44
|
} catch {}
|
|
45
|
-
}, m = r === "system" ?
|
|
46
|
-
let e = m === "dark" ?
|
|
47
|
-
return { algorithm: a === "compact" ? [e,
|
|
48
|
-
}, [m, a]), g =
|
|
45
|
+
}, m = r === "system" ? l ? "dark" : "light" : r, h = c(() => {
|
|
46
|
+
let e = m === "dark" ? W.darkAlgorithm : W.defaultAlgorithm;
|
|
47
|
+
return { algorithm: a === "compact" ? [e, W.compactAlgorithm] : e };
|
|
48
|
+
}, [m, a]), g = c(() => ({
|
|
49
49
|
mode: r,
|
|
50
50
|
setMode: f,
|
|
51
51
|
resolved: m,
|
|
@@ -58,120 +58,172 @@ function Oe({ children: e, modeStorageKey: t = Ee, densityStorageKey: n = De })
|
|
|
58
58
|
f,
|
|
59
59
|
p
|
|
60
60
|
]);
|
|
61
|
-
return /* @__PURE__ */
|
|
61
|
+
return /* @__PURE__ */ K(Ae.Provider, {
|
|
62
62
|
value: g,
|
|
63
|
-
children: /* @__PURE__ */
|
|
63
|
+
children: /* @__PURE__ */ K(T, {
|
|
64
64
|
theme: h,
|
|
65
65
|
children: e
|
|
66
66
|
})
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
|
-
function
|
|
70
|
-
let e =
|
|
69
|
+
function Le() {
|
|
70
|
+
let e = o(Ae);
|
|
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 Re = [{
|
|
77
77
|
label: "Comfortable",
|
|
78
78
|
value: "comfortable",
|
|
79
|
-
icon: /* @__PURE__ */
|
|
79
|
+
icon: /* @__PURE__ */ K(fe, {})
|
|
80
80
|
}, {
|
|
81
81
|
label: "Compact",
|
|
82
82
|
value: "compact",
|
|
83
|
-
icon: /* @__PURE__ */
|
|
83
|
+
icon: /* @__PURE__ */ K(ce, {})
|
|
84
84
|
}];
|
|
85
|
-
function
|
|
86
|
-
let { density: e, setDensity: t } =
|
|
87
|
-
return /* @__PURE__ */
|
|
85
|
+
function ze() {
|
|
86
|
+
let { density: e, setDensity: t } = Le();
|
|
87
|
+
return /* @__PURE__ */ K(ne, {
|
|
88
88
|
size: "small",
|
|
89
89
|
value: e,
|
|
90
|
-
options:
|
|
90
|
+
options: Re,
|
|
91
91
|
onChange: (e) => t(e)
|
|
92
92
|
});
|
|
93
93
|
}
|
|
94
94
|
//#endregion
|
|
95
95
|
//#region src/components/ThemeSwitch.tsx
|
|
96
|
-
var
|
|
96
|
+
var Be = [
|
|
97
97
|
{
|
|
98
98
|
label: "Light",
|
|
99
99
|
value: "light",
|
|
100
|
-
icon: /* @__PURE__ */
|
|
100
|
+
icon: /* @__PURE__ */ K(ye, {})
|
|
101
101
|
},
|
|
102
102
|
{
|
|
103
103
|
label: "Dark",
|
|
104
104
|
value: "dark",
|
|
105
|
-
icon: /* @__PURE__ */
|
|
105
|
+
icon: /* @__PURE__ */ K(he, {})
|
|
106
106
|
},
|
|
107
107
|
{
|
|
108
108
|
label: "Auto",
|
|
109
109
|
value: "system",
|
|
110
|
-
icon: /* @__PURE__ */
|
|
110
|
+
icon: /* @__PURE__ */ K(ue, {})
|
|
111
111
|
}
|
|
112
112
|
];
|
|
113
|
-
function
|
|
114
|
-
let { mode: e, setMode: t } =
|
|
115
|
-
return /* @__PURE__ */
|
|
113
|
+
function Ve() {
|
|
114
|
+
let { mode: e, setMode: t } = Le();
|
|
115
|
+
return /* @__PURE__ */ K(ne, {
|
|
116
116
|
size: "small",
|
|
117
117
|
value: e,
|
|
118
|
-
options:
|
|
118
|
+
options: Be,
|
|
119
119
|
onChange: (e) => t(e)
|
|
120
120
|
});
|
|
121
121
|
}
|
|
122
122
|
//#endregion
|
|
123
123
|
//#region src/components/ThemeToolbar.tsx
|
|
124
|
-
function
|
|
125
|
-
let { token: e } =
|
|
126
|
-
return /* @__PURE__ */
|
|
127
|
-
placement:
|
|
124
|
+
function He() {
|
|
125
|
+
let { token: e } = W.useToken();
|
|
126
|
+
return /* @__PURE__ */ K(I, {
|
|
127
|
+
placement: j.useBreakpoint().lg ? "bottomRight" : "bottom",
|
|
128
128
|
trigger: "click",
|
|
129
|
-
content: /* @__PURE__ */
|
|
129
|
+
content: /* @__PURE__ */ q(R, {
|
|
130
130
|
orientation: "vertical",
|
|
131
131
|
size: "middle",
|
|
132
132
|
style: {
|
|
133
133
|
minWidth: 240,
|
|
134
134
|
maxWidth: "min(92vw, 320px)"
|
|
135
135
|
},
|
|
136
|
-
children: [/* @__PURE__ */
|
|
136
|
+
children: [/* @__PURE__ */ K(Ve, {}), /* @__PURE__ */ K(ze, {})]
|
|
137
137
|
}),
|
|
138
138
|
styles: { content: { padding: e.paddingSM } },
|
|
139
|
-
children: /* @__PURE__ */
|
|
139
|
+
children: /* @__PURE__ */ K(C, {
|
|
140
140
|
type: "default",
|
|
141
|
-
icon: /* @__PURE__ */
|
|
141
|
+
icon: /* @__PURE__ */ K(ve, {}),
|
|
142
142
|
"aria-label": "Display and theme settings"
|
|
143
143
|
})
|
|
144
144
|
});
|
|
145
145
|
}
|
|
146
146
|
//#endregion
|
|
147
|
-
//#region src/
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
147
|
+
//#region src/components/NavMenuSearch.tsx
|
|
148
|
+
function Ue({ value: e, onChange: t, placeholder: n = "Search menu…", variant: r = "on-dark" }) {
|
|
149
|
+
let { token: i } = W.useToken(), a = r === "on-dark";
|
|
150
|
+
return /* @__PURE__ */ K("div", {
|
|
151
|
+
style: {
|
|
152
|
+
flexShrink: 0,
|
|
153
|
+
paddingInline: i.paddingSM,
|
|
154
|
+
paddingBlock: i.paddingXS
|
|
155
|
+
},
|
|
156
|
+
children: /* @__PURE__ */ K(T, {
|
|
157
|
+
theme: a ? { token: { colorTextPlaceholder: "rgba(255, 255, 255, 0.45)" } } : void 0,
|
|
158
|
+
children: /* @__PURE__ */ K(N, {
|
|
159
|
+
allowClear: !0,
|
|
160
|
+
size: "small",
|
|
161
|
+
value: e,
|
|
162
|
+
onChange: (e) => {
|
|
163
|
+
t(e.target.value);
|
|
164
|
+
},
|
|
165
|
+
placeholder: n,
|
|
166
|
+
prefix: /* @__PURE__ */ K(J, { style: { color: a ? "rgba(255, 255, 255, 0.45)" : i.colorTextDescription } }),
|
|
167
|
+
"aria-label": n,
|
|
168
|
+
styles: {
|
|
169
|
+
input: a ? { color: "rgba(255, 255, 255, 0.88)" } : void 0,
|
|
170
|
+
clear: a ? { color: "rgba(255, 255, 255, 0.45)" } : void 0
|
|
171
|
+
},
|
|
172
|
+
style: {
|
|
173
|
+
background: a ? "rgba(255, 255, 255, 0.08)" : i.colorFillTertiary,
|
|
174
|
+
borderColor: "transparent",
|
|
175
|
+
boxShadow: "none"
|
|
176
|
+
}
|
|
177
|
+
})
|
|
178
|
+
})
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
//#endregion
|
|
182
|
+
//#region src/components/ScrollableArea.tsx
|
|
183
|
+
var We = r(function({ children: e, className: t, style: n, variant: r = "default" }, i) {
|
|
184
|
+
let { token: a } = W.useToken(), o = r === "on-dark" ? "rgba(255, 255, 255, 0.22)" : a.colorTextQuaternary, s = r === "on-dark" ? "rgba(255, 255, 255, 0.38)" : a.colorTextTertiary;
|
|
185
|
+
return /* @__PURE__ */ K("div", {
|
|
186
|
+
ref: i,
|
|
187
|
+
className: ["ding-admin-scroll", t].filter(Boolean).join(" "),
|
|
188
|
+
style: {
|
|
189
|
+
...n,
|
|
190
|
+
"--ding-scroll-thumb": o,
|
|
191
|
+
"--ding-scroll-thumb-hover": s
|
|
192
|
+
},
|
|
193
|
+
children: e
|
|
194
|
+
});
|
|
195
|
+
}), Ge = t(null), Ke = "User";
|
|
196
|
+
function qe(e) {
|
|
197
|
+
return e.getUserLabel?.() ?? Ke;
|
|
198
|
+
}
|
|
199
|
+
function Je({ children: e, adapter: t }) {
|
|
200
|
+
let [n, r] = u(() => t.getToken()), [i, o] = u(() => qe(t)), s = a(async (e) => {
|
|
201
|
+
await t.login(e), r(t.getToken()), o(qe(t));
|
|
202
|
+
}, [t]), l = a(() => {
|
|
203
|
+
t.logout(), r(t.getToken()), o(qe(t));
|
|
204
|
+
}, [t]), d = c(() => ({
|
|
155
205
|
isAuthenticated: !!n,
|
|
156
|
-
|
|
157
|
-
|
|
206
|
+
userLabel: i,
|
|
207
|
+
login: s,
|
|
208
|
+
logout: l
|
|
158
209
|
}), [
|
|
159
210
|
n,
|
|
160
|
-
|
|
161
|
-
|
|
211
|
+
i,
|
|
212
|
+
s,
|
|
213
|
+
l
|
|
162
214
|
]);
|
|
163
|
-
return /* @__PURE__ */
|
|
164
|
-
value:
|
|
215
|
+
return /* @__PURE__ */ K(Ge.Provider, {
|
|
216
|
+
value: d,
|
|
165
217
|
children: e
|
|
166
218
|
});
|
|
167
219
|
}
|
|
168
|
-
function
|
|
169
|
-
let e =
|
|
220
|
+
function Ye() {
|
|
221
|
+
let e = o(Ge);
|
|
170
222
|
if (!e) throw Error("useAuth must be used within AuthProvider");
|
|
171
223
|
return e;
|
|
172
224
|
}
|
|
173
|
-
var
|
|
174
|
-
function
|
|
225
|
+
var Xe = "ding-react-admin-auth";
|
|
226
|
+
function Ze(e = Xe) {
|
|
175
227
|
return {
|
|
176
228
|
async login({ username: t, password: n }) {
|
|
177
229
|
if (!t.trim() || !n) throw Error("Invalid credentials");
|
|
@@ -187,37 +239,109 @@ function ze(e = Re) {
|
|
|
187
239
|
}
|
|
188
240
|
//#endregion
|
|
189
241
|
//#region src/context/PermissionsProvider.tsx
|
|
190
|
-
var
|
|
191
|
-
function
|
|
192
|
-
let n =
|
|
193
|
-
return /* @__PURE__ */
|
|
242
|
+
var Qe = t(null);
|
|
243
|
+
function $e({ children: e, can: t }) {
|
|
244
|
+
let n = c(() => t, [t]);
|
|
245
|
+
return /* @__PURE__ */ K(Qe.Provider, {
|
|
194
246
|
value: n,
|
|
195
247
|
children: e
|
|
196
248
|
});
|
|
197
249
|
}
|
|
198
|
-
function
|
|
199
|
-
let e =
|
|
250
|
+
function Y() {
|
|
251
|
+
let e = o(Qe);
|
|
200
252
|
if (!e) throw Error("usePermissions must be used within PermissionsProvider");
|
|
201
253
|
return e;
|
|
202
254
|
}
|
|
203
|
-
function
|
|
255
|
+
function et(e) {
|
|
204
256
|
return (t) => e()?.includes(t) ?? !1;
|
|
205
257
|
}
|
|
206
|
-
function
|
|
207
|
-
let t =
|
|
208
|
-
return
|
|
258
|
+
function tt(e) {
|
|
259
|
+
let t = Y();
|
|
260
|
+
return a(() => t(e), [t, e]);
|
|
261
|
+
}
|
|
262
|
+
//#endregion
|
|
263
|
+
//#region src/layouts/navFilter.ts
|
|
264
|
+
function nt(e) {
|
|
265
|
+
let { label: t } = e;
|
|
266
|
+
return typeof t == "string" ? t : typeof t == "number" ? String(t) : "";
|
|
267
|
+
}
|
|
268
|
+
function rt(e, t) {
|
|
269
|
+
let n = t.trim().toLowerCase();
|
|
270
|
+
if (!n) return e;
|
|
271
|
+
function r(e) {
|
|
272
|
+
let t = [];
|
|
273
|
+
for (let i of e) {
|
|
274
|
+
let e = nt(i).toLowerCase().includes(n);
|
|
275
|
+
if (i.children?.length) {
|
|
276
|
+
let n = r(i.children);
|
|
277
|
+
e ? t.push(i) : n.length > 0 && t.push({
|
|
278
|
+
...i,
|
|
279
|
+
children: n
|
|
280
|
+
});
|
|
281
|
+
} else e && t.push(i);
|
|
282
|
+
}
|
|
283
|
+
return t;
|
|
284
|
+
}
|
|
285
|
+
return r(e);
|
|
286
|
+
}
|
|
287
|
+
function it(e) {
|
|
288
|
+
let t = [];
|
|
289
|
+
function n(e) {
|
|
290
|
+
for (let r of e) r.children?.length && (t.push(r.path), n(r.children));
|
|
291
|
+
}
|
|
292
|
+
return n(e), t;
|
|
293
|
+
}
|
|
294
|
+
//#endregion
|
|
295
|
+
//#region src/components/NavMenuLabel.tsx
|
|
296
|
+
function at({ label: e, title: t }) {
|
|
297
|
+
return t ? /* @__PURE__ */ K(H, {
|
|
298
|
+
title: t,
|
|
299
|
+
placement: "right",
|
|
300
|
+
mouseEnterDelay: 1,
|
|
301
|
+
destroyOnHidden: !0,
|
|
302
|
+
children: /* @__PURE__ */ K("span", {
|
|
303
|
+
className: "ding-admin-menu-label",
|
|
304
|
+
children: e
|
|
305
|
+
})
|
|
306
|
+
}) : /* @__PURE__ */ K("span", {
|
|
307
|
+
className: "ding-admin-menu-label",
|
|
308
|
+
children: e
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
//#endregion
|
|
312
|
+
//#region src/layouts/navMenuItems.tsx
|
|
313
|
+
function ot(e, t) {
|
|
314
|
+
let n = t?.showLabelTooltip !== !1;
|
|
315
|
+
return e.map((e) => {
|
|
316
|
+
let r = e.Icon, i = r ? /* @__PURE__ */ K(r, {}) : void 0, a = nt(e), o = a && n ? /* @__PURE__ */ K(at, {
|
|
317
|
+
label: e.label,
|
|
318
|
+
title: a
|
|
319
|
+
}) : e.label, s = !n && a ? { title: a } : {};
|
|
320
|
+
return e.children?.length ? {
|
|
321
|
+
key: e.path,
|
|
322
|
+
icon: i,
|
|
323
|
+
label: o,
|
|
324
|
+
...s,
|
|
325
|
+
children: ot(e.children, t)
|
|
326
|
+
} : {
|
|
327
|
+
key: e.path,
|
|
328
|
+
icon: i,
|
|
329
|
+
label: o,
|
|
330
|
+
...s
|
|
331
|
+
};
|
|
332
|
+
});
|
|
209
333
|
}
|
|
210
334
|
//#endregion
|
|
211
335
|
//#region src/permissions/resourcePermissions.ts
|
|
212
|
-
function
|
|
336
|
+
function X(e, t, n) {
|
|
213
337
|
if (!t) return !0;
|
|
214
338
|
let r = t[n];
|
|
215
339
|
return n === "read" && !r && (r = t.list), r ? e(r) : !1;
|
|
216
340
|
}
|
|
217
|
-
function
|
|
341
|
+
function st(e, t) {
|
|
218
342
|
return e.map((e) => {
|
|
219
343
|
if (e.children?.length) {
|
|
220
|
-
let n =
|
|
344
|
+
let n = st(e.children, t);
|
|
221
345
|
return n.length === 0 ? null : {
|
|
222
346
|
...e,
|
|
223
347
|
children: n
|
|
@@ -228,25 +352,25 @@ function We(e, t) {
|
|
|
228
352
|
}
|
|
229
353
|
//#endregion
|
|
230
354
|
//#region src/layouts/AdminLayout.tsx
|
|
231
|
-
var
|
|
232
|
-
function
|
|
355
|
+
var ct = "#001529", lt = "ding-react-admin-sider-collapsed";
|
|
356
|
+
function ut(e) {
|
|
233
357
|
try {
|
|
234
358
|
return localStorage.getItem(e) === "1";
|
|
235
359
|
} catch {
|
|
236
360
|
return !1;
|
|
237
361
|
}
|
|
238
362
|
}
|
|
239
|
-
function
|
|
240
|
-
return
|
|
363
|
+
function dt() {
|
|
364
|
+
return j.useBreakpoint().lg !== !0;
|
|
241
365
|
}
|
|
242
|
-
function
|
|
366
|
+
function ft(e) {
|
|
243
367
|
let t = /* @__PURE__ */ new Set();
|
|
244
368
|
function n(e) {
|
|
245
369
|
for (let r of e) r.children?.length ? n(r.children) : t.add(r.path);
|
|
246
370
|
}
|
|
247
371
|
return n(e), t;
|
|
248
372
|
}
|
|
249
|
-
function
|
|
373
|
+
function pt(e, t) {
|
|
250
374
|
function n(e) {
|
|
251
375
|
for (let r of e) if (r.children?.length) {
|
|
252
376
|
let e = n(r.children);
|
|
@@ -256,27 +380,41 @@ function Xe(e, t) {
|
|
|
256
380
|
}
|
|
257
381
|
return n(e) ?? [];
|
|
258
382
|
}
|
|
259
|
-
function
|
|
260
|
-
return
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
383
|
+
function mt({ menuItems: e, selectedKeys: t, inlineCollapsed: n, openKeys: r, onOpenChange: i, onNavigate: a, navQuery: o, onNavQueryChange: s, showNavSearch: c, navSearchPlaceholder: l, scrollVariant: u, searchVariant: d }) {
|
|
384
|
+
return /* @__PURE__ */ q(G, { children: [c && !n ? /* @__PURE__ */ K(Ue, {
|
|
385
|
+
value: o,
|
|
386
|
+
onChange: s,
|
|
387
|
+
placeholder: l,
|
|
388
|
+
variant: d
|
|
389
|
+
}) : null, /* @__PURE__ */ K(We, {
|
|
390
|
+
variant: u,
|
|
391
|
+
style: {
|
|
392
|
+
flex: 1,
|
|
393
|
+
minHeight: 0,
|
|
394
|
+
overflowY: "auto",
|
|
395
|
+
overflowX: "hidden"
|
|
396
|
+
},
|
|
397
|
+
children: /* @__PURE__ */ K(ht, {
|
|
398
|
+
menuItems: e,
|
|
399
|
+
selectedKeys: t,
|
|
400
|
+
inlineCollapsed: n,
|
|
401
|
+
openKeys: r,
|
|
402
|
+
onOpenChange: i,
|
|
403
|
+
onNavigate: a
|
|
404
|
+
})
|
|
405
|
+
})] });
|
|
273
406
|
}
|
|
274
|
-
function
|
|
275
|
-
return /* @__PURE__ */
|
|
407
|
+
function ht({ menuItems: e, selectedKeys: t, inlineCollapsed: n, openKeys: r, onOpenChange: i, onNavigate: a }) {
|
|
408
|
+
return /* @__PURE__ */ K(ee, {
|
|
409
|
+
className: "ding-admin-nav-menu",
|
|
276
410
|
mode: "inline",
|
|
277
411
|
theme: "dark",
|
|
278
412
|
inlineCollapsed: n,
|
|
279
413
|
selectedKeys: t,
|
|
414
|
+
tooltip: {
|
|
415
|
+
placement: "right",
|
|
416
|
+
mouseEnterDelay: 1
|
|
417
|
+
},
|
|
280
418
|
...!n && r !== void 0 && i ? {
|
|
281
419
|
openKeys: r,
|
|
282
420
|
onOpenChange: i
|
|
@@ -289,203 +427,276 @@ function Qe({ menuItems: e, selectedKeys: t, inlineCollapsed: n, openKeys: r, on
|
|
|
289
427
|
}
|
|
290
428
|
});
|
|
291
429
|
}
|
|
292
|
-
function
|
|
293
|
-
let
|
|
294
|
-
|
|
295
|
-
},
|
|
296
|
-
|
|
430
|
+
function gt({ navItems: e, brand: t = "Admin", collapsedBrand: n = "A", mobileDrawerTitle: r, headerExtras: i, userMenuItems: o, onUserMenuClick: d, loginPath: f = "/login", siderCollapsedStorageKey: m = lt, navSearch: h = !0 }) {
|
|
431
|
+
let v = _(), y = g(), { resolved: b } = Le(), x = b === "dark", { logout: w, userLabel: T } = Ye(), E = Y(), [k, A] = u(() => ut(m)), [j, M] = u(!1), N = dt(), { token: P } = W.useToken(), ee = l(null), [te, I] = u(""), ne = h !== !1, L = typeof h == "object" ? h.placeholder : void 0, R = r ?? t, re = () => {
|
|
432
|
+
w(), v(f, { replace: !0 });
|
|
433
|
+
}, z = a((e) => {
|
|
434
|
+
A(e);
|
|
297
435
|
try {
|
|
298
|
-
localStorage.setItem(
|
|
436
|
+
localStorage.setItem(m, e ? "1" : "0");
|
|
299
437
|
} catch {}
|
|
300
|
-
}, [
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
}, [
|
|
304
|
-
|
|
305
|
-
}, [
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
}, [])
|
|
438
|
+
}, [m]);
|
|
439
|
+
s(() => {
|
|
440
|
+
N || M(!1);
|
|
441
|
+
}, [N]), s(() => {
|
|
442
|
+
M(!1);
|
|
443
|
+
}, [y.pathname]), s(() => {
|
|
444
|
+
ee.current?.scrollTo({
|
|
445
|
+
top: 0,
|
|
446
|
+
left: 0
|
|
447
|
+
});
|
|
448
|
+
}, [y.pathname]), s(() => {
|
|
449
|
+
k && I("");
|
|
450
|
+
}, [k]);
|
|
451
|
+
let B = c(() => st(e, E), [e, E]), ie = te.trim(), V = ie.length > 0, H = c(() => V ? rt(B, ie) : B, [
|
|
452
|
+
B,
|
|
453
|
+
ie,
|
|
454
|
+
V
|
|
455
|
+
]), G = c(() => ft(H), [H]), ae = c(() => ot(H, { showLabelTooltip: !k }), [H, k]), oe = c(() => it(H), [H]), se = c(() => pt(B, y.pathname), [B, y.pathname]), [ce, le] = u(() => pt(B, y.pathname));
|
|
456
|
+
s(() => {
|
|
457
|
+
le((e) => [...new Set([...e, ...se])]);
|
|
458
|
+
}, [se]);
|
|
459
|
+
let ue = a((e) => {
|
|
460
|
+
le(e);
|
|
461
|
+
}, []), de = V ? oe : ce, fe = a((e) => {
|
|
462
|
+
I(e);
|
|
463
|
+
}, []), he = c(() => [{
|
|
313
464
|
key: "logout",
|
|
314
|
-
icon: /* @__PURE__ */
|
|
465
|
+
icon: /* @__PURE__ */ K(pe, {}),
|
|
315
466
|
label: "Log out",
|
|
316
467
|
danger: !0
|
|
317
|
-
}], []),
|
|
318
|
-
if (
|
|
319
|
-
|
|
468
|
+
}], []), ge = o ?? he, _e = (e) => {
|
|
469
|
+
if (d) {
|
|
470
|
+
d(e);
|
|
320
471
|
return;
|
|
321
472
|
}
|
|
322
|
-
e.key === "logout" &&
|
|
323
|
-
},
|
|
324
|
-
|
|
473
|
+
e.key === "logout" && re();
|
|
474
|
+
}, J = x ? P.colorBgContainer : ct, ve = x ? "default" : "on-dark", ye = x ? "app" : "on-dark", be = [y.pathname], Se = (e) => {
|
|
475
|
+
G.has(e) && (v(e), N && M(!1));
|
|
325
476
|
};
|
|
326
|
-
return /* @__PURE__ */
|
|
477
|
+
return /* @__PURE__ */ q(F, {
|
|
327
478
|
style: {
|
|
328
|
-
|
|
479
|
+
height: "100vh",
|
|
329
480
|
width: "100%",
|
|
330
|
-
|
|
481
|
+
overflow: "hidden",
|
|
482
|
+
background: P.colorBgLayout
|
|
331
483
|
},
|
|
332
484
|
children: [
|
|
333
|
-
!
|
|
485
|
+
!N && /* @__PURE__ */ K(F.Sider, {
|
|
334
486
|
collapsible: !0,
|
|
335
|
-
collapsed:
|
|
336
|
-
onCollapse:
|
|
487
|
+
collapsed: k,
|
|
488
|
+
onCollapse: z,
|
|
337
489
|
collapsedWidth: 64,
|
|
338
490
|
style: {
|
|
339
|
-
background:
|
|
340
|
-
|
|
491
|
+
background: J,
|
|
492
|
+
height: "100vh",
|
|
493
|
+
overflow: "hidden",
|
|
494
|
+
borderInlineEnd: x ? `1px solid ${P.colorSplit}` : void 0
|
|
341
495
|
},
|
|
342
|
-
children:
|
|
496
|
+
children: /* @__PURE__ */ q("div", {
|
|
343
497
|
style: {
|
|
344
|
-
height: 64,
|
|
345
498
|
display: "flex",
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
499
|
+
flexDirection: "column",
|
|
500
|
+
height: "100%",
|
|
501
|
+
overflow: "hidden"
|
|
349
502
|
},
|
|
350
|
-
children: /* @__PURE__ */
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
503
|
+
children: [/* @__PURE__ */ K("div", {
|
|
504
|
+
style: {
|
|
505
|
+
height: 64,
|
|
506
|
+
flexShrink: 0,
|
|
507
|
+
display: "flex",
|
|
508
|
+
alignItems: "center",
|
|
509
|
+
justifyContent: "center",
|
|
510
|
+
fontWeight: 600
|
|
511
|
+
},
|
|
512
|
+
children: /* @__PURE__ */ K(U.Text, {
|
|
513
|
+
strong: !0,
|
|
514
|
+
style: { color: P.colorTextLightSolid },
|
|
515
|
+
children: k ? n : t
|
|
516
|
+
})
|
|
517
|
+
}), /* @__PURE__ */ K(mt, {
|
|
518
|
+
menuItems: ae,
|
|
519
|
+
selectedKeys: be,
|
|
520
|
+
inlineCollapsed: k,
|
|
521
|
+
openKeys: de,
|
|
522
|
+
onOpenChange: ue,
|
|
523
|
+
onNavigate: Se,
|
|
524
|
+
navQuery: te,
|
|
525
|
+
onNavQueryChange: fe,
|
|
526
|
+
showNavSearch: ne,
|
|
527
|
+
navSearchPlaceholder: L,
|
|
528
|
+
scrollVariant: ve,
|
|
529
|
+
searchVariant: ye
|
|
530
|
+
})]
|
|
531
|
+
})
|
|
363
532
|
}),
|
|
364
|
-
|
|
365
|
-
title: /* @__PURE__ */
|
|
533
|
+
N && /* @__PURE__ */ K(D, {
|
|
534
|
+
title: /* @__PURE__ */ K(U.Text, {
|
|
366
535
|
strong: !0,
|
|
367
|
-
style: { color:
|
|
368
|
-
children:
|
|
536
|
+
style: { color: P.colorTextLightSolid },
|
|
537
|
+
children: R
|
|
369
538
|
}),
|
|
370
539
|
placement: "left",
|
|
371
540
|
size: 280,
|
|
372
|
-
onClose: () =>
|
|
373
|
-
open:
|
|
541
|
+
onClose: () => M(!1),
|
|
542
|
+
open: j,
|
|
374
543
|
styles: {
|
|
375
544
|
header: {
|
|
376
|
-
background:
|
|
377
|
-
borderBottom: `1px solid ${
|
|
545
|
+
background: J,
|
|
546
|
+
borderBottom: `1px solid ${P.colorSplit}`
|
|
378
547
|
},
|
|
379
548
|
body: {
|
|
380
549
|
padding: 0,
|
|
381
|
-
background:
|
|
550
|
+
background: J
|
|
382
551
|
}
|
|
383
552
|
},
|
|
384
553
|
destroyOnHidden: !0,
|
|
385
|
-
children: /* @__PURE__ */
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
554
|
+
children: /* @__PURE__ */ K("div", {
|
|
555
|
+
style: {
|
|
556
|
+
display: "flex",
|
|
557
|
+
flexDirection: "column",
|
|
558
|
+
height: "100%",
|
|
559
|
+
overflow: "hidden"
|
|
560
|
+
},
|
|
561
|
+
children: /* @__PURE__ */ K(mt, {
|
|
562
|
+
menuItems: ae,
|
|
563
|
+
selectedKeys: be,
|
|
564
|
+
inlineCollapsed: !1,
|
|
565
|
+
openKeys: de,
|
|
566
|
+
onOpenChange: ue,
|
|
567
|
+
onNavigate: Se,
|
|
568
|
+
navQuery: te,
|
|
569
|
+
onNavQueryChange: fe,
|
|
570
|
+
showNavSearch: ne,
|
|
571
|
+
navSearchPlaceholder: L,
|
|
572
|
+
scrollVariant: ve,
|
|
573
|
+
searchVariant: ye
|
|
574
|
+
})
|
|
392
575
|
})
|
|
393
576
|
}),
|
|
394
|
-
/* @__PURE__ */
|
|
577
|
+
/* @__PURE__ */ q(F, {
|
|
395
578
|
style: {
|
|
396
|
-
|
|
397
|
-
|
|
579
|
+
minWidth: 0,
|
|
580
|
+
flex: 1,
|
|
581
|
+
height: "100vh",
|
|
582
|
+
overflow: "hidden",
|
|
398
583
|
display: "flex",
|
|
399
|
-
|
|
400
|
-
gap: A.marginSM,
|
|
401
|
-
lineHeight: "normal"
|
|
584
|
+
flexDirection: "column"
|
|
402
585
|
},
|
|
403
|
-
children: [
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
/* @__PURE__ */ V(Pe, {}),
|
|
416
|
-
/* @__PURE__ */ V(T, {
|
|
417
|
-
menu: {
|
|
418
|
-
items: B,
|
|
419
|
-
onClick: U
|
|
420
|
-
},
|
|
421
|
-
trigger: ["click"],
|
|
422
|
-
children: /* @__PURE__ */ H(x, {
|
|
586
|
+
children: [/* @__PURE__ */ q(F.Header, {
|
|
587
|
+
style: {
|
|
588
|
+
background: P.colorBgContainer,
|
|
589
|
+
paddingInline: P.paddingLG,
|
|
590
|
+
display: "flex",
|
|
591
|
+
alignItems: "center",
|
|
592
|
+
gap: P.marginSM,
|
|
593
|
+
lineHeight: "normal",
|
|
594
|
+
flexShrink: 0
|
|
595
|
+
},
|
|
596
|
+
children: [
|
|
597
|
+
N && /* @__PURE__ */ K(C, {
|
|
423
598
|
type: "text",
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
599
|
+
icon: /* @__PURE__ */ K(me, {}),
|
|
600
|
+
onClick: () => M(!0),
|
|
601
|
+
"aria-label": "Open navigation"
|
|
602
|
+
}),
|
|
603
|
+
/* @__PURE__ */ K("div", { style: {
|
|
604
|
+
flex: 1,
|
|
605
|
+
minWidth: 0
|
|
606
|
+
} }),
|
|
607
|
+
i,
|
|
608
|
+
/* @__PURE__ */ K(He, {}),
|
|
609
|
+
/* @__PURE__ */ K(O, {
|
|
610
|
+
menu: {
|
|
611
|
+
items: ge,
|
|
612
|
+
onClick: _e
|
|
430
613
|
},
|
|
431
|
-
|
|
432
|
-
children:
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
614
|
+
trigger: ["click"],
|
|
615
|
+
children: /* @__PURE__ */ q(C, {
|
|
616
|
+
type: "text",
|
|
617
|
+
style: {
|
|
618
|
+
display: "inline-flex",
|
|
619
|
+
alignItems: "center",
|
|
620
|
+
gap: P.marginXS,
|
|
621
|
+
maxWidth: N ? 44 : void 0,
|
|
622
|
+
paddingInline: N ? P.paddingXS : void 0
|
|
623
|
+
},
|
|
624
|
+
"aria-label": "Account menu",
|
|
625
|
+
children: [/* @__PURE__ */ K(S, {
|
|
626
|
+
size: "small",
|
|
627
|
+
icon: /* @__PURE__ */ K(xe, {})
|
|
628
|
+
}), !N && /* @__PURE__ */ K(U.Text, {
|
|
629
|
+
type: "secondary",
|
|
630
|
+
ellipsis: !0,
|
|
631
|
+
style: { maxWidth: 160 },
|
|
632
|
+
children: T
|
|
633
|
+
})]
|
|
634
|
+
})
|
|
439
635
|
})
|
|
636
|
+
]
|
|
637
|
+
}), /* @__PURE__ */ K(F.Content, {
|
|
638
|
+
style: {
|
|
639
|
+
minWidth: 0,
|
|
640
|
+
flex: 1,
|
|
641
|
+
minHeight: 0,
|
|
642
|
+
display: "flex",
|
|
643
|
+
flexDirection: "column"
|
|
644
|
+
},
|
|
645
|
+
children: /* @__PURE__ */ K(We, {
|
|
646
|
+
ref: ee,
|
|
647
|
+
style: {
|
|
648
|
+
margin: N ? P.marginSM : P.marginLG,
|
|
649
|
+
flex: 1,
|
|
650
|
+
minHeight: 0,
|
|
651
|
+
overflow: "auto"
|
|
652
|
+
},
|
|
653
|
+
children: /* @__PURE__ */ K(p, {})
|
|
440
654
|
})
|
|
441
|
-
]
|
|
442
|
-
})
|
|
443
|
-
style: { margin: k ? A.marginSM : A.marginLG },
|
|
444
|
-
children: /* @__PURE__ */ V(f, {})
|
|
445
|
-
})] })
|
|
655
|
+
})]
|
|
656
|
+
})
|
|
446
657
|
]
|
|
447
658
|
});
|
|
448
659
|
}
|
|
449
660
|
//#endregion
|
|
450
661
|
//#region src/router/guards.tsx
|
|
451
|
-
function
|
|
452
|
-
return e ? n : /* @__PURE__ */
|
|
662
|
+
function _t({ when: e, redirect: t, children: n }) {
|
|
663
|
+
return e ? n : /* @__PURE__ */ K(f, {
|
|
453
664
|
to: t,
|
|
454
665
|
replace: !0
|
|
455
666
|
});
|
|
456
667
|
}
|
|
457
|
-
function
|
|
458
|
-
let { isAuthenticated: n } =
|
|
459
|
-
return /* @__PURE__ */
|
|
668
|
+
function vt({ children: e, redirectTo: t = "/login" }) {
|
|
669
|
+
let { isAuthenticated: n } = Ye();
|
|
670
|
+
return /* @__PURE__ */ K(_t, {
|
|
460
671
|
when: n,
|
|
461
672
|
redirect: t,
|
|
462
673
|
children: e
|
|
463
674
|
});
|
|
464
675
|
}
|
|
465
|
-
function
|
|
466
|
-
let { isAuthenticated: n } =
|
|
467
|
-
return /* @__PURE__ */
|
|
676
|
+
function yt({ children: e, redirectTo: t = "/" }) {
|
|
677
|
+
let { isAuthenticated: n } = Ye();
|
|
678
|
+
return /* @__PURE__ */ K(_t, {
|
|
468
679
|
when: !n,
|
|
469
680
|
redirect: t,
|
|
470
681
|
children: e
|
|
471
682
|
});
|
|
472
683
|
}
|
|
473
|
-
function
|
|
474
|
-
return /* @__PURE__ */
|
|
475
|
-
when:
|
|
684
|
+
function bt({ permission: e, redirect: t, children: n }) {
|
|
685
|
+
return /* @__PURE__ */ K(_t, {
|
|
686
|
+
when: Y()(e),
|
|
476
687
|
redirect: t,
|
|
477
688
|
children: n
|
|
478
689
|
});
|
|
479
690
|
}
|
|
480
691
|
//#endregion
|
|
481
692
|
//#region src/router/routeAccess.ts
|
|
482
|
-
function
|
|
693
|
+
function xt(e) {
|
|
483
694
|
return e.access ?? "protected";
|
|
484
695
|
}
|
|
485
|
-
function
|
|
696
|
+
function St(e) {
|
|
486
697
|
let t = [], n = [], r = [];
|
|
487
698
|
for (let i of e) {
|
|
488
|
-
let e =
|
|
699
|
+
let e = xt(i);
|
|
489
700
|
e === "guest" ? t.push(i) : e === "public" ? n.push(i) : r.push(i);
|
|
490
701
|
}
|
|
491
702
|
return {
|
|
@@ -494,24 +705,24 @@ function at(e) {
|
|
|
494
705
|
protected: r
|
|
495
706
|
};
|
|
496
707
|
}
|
|
497
|
-
function
|
|
708
|
+
function Ct(e) {
|
|
498
709
|
return e.replace(/^\/+/, "");
|
|
499
710
|
}
|
|
500
|
-
function
|
|
501
|
-
return `/${
|
|
711
|
+
function wt(e) {
|
|
712
|
+
return `/${Ct(e)}`;
|
|
502
713
|
}
|
|
503
|
-
function
|
|
504
|
-
let { guest: n, protected: r } =
|
|
505
|
-
!s && i && "path" in i && i.path && (s =
|
|
714
|
+
function Tt(e, t) {
|
|
715
|
+
let { guest: n, protected: r } = St(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;
|
|
716
|
+
!s && i && "path" in i && i.path && (s = wt(i.path));
|
|
506
717
|
let c = t?.afterLogin;
|
|
507
|
-
if (c || (a ? c = "/" : o && "path" in o && o.path && (c =
|
|
718
|
+
if (c || (a ? c = "/" : o && "path" in o && o.path && (c = wt(o.path))), r.length > 0 && !s) throw Error("createAdminRouter: protected routes require redirects.unauthenticated or a guest route (access: \"guest\").");
|
|
508
719
|
if (n.length > 0 && !c) throw Error("createAdminRouter: guest routes require redirects.afterLogin or a protected route (index or path).");
|
|
509
720
|
return {
|
|
510
721
|
loginPath: s ?? "/",
|
|
511
722
|
homePath: c ?? "/"
|
|
512
723
|
};
|
|
513
724
|
}
|
|
514
|
-
function
|
|
725
|
+
function Et(e) {
|
|
515
726
|
return "index" in e && e.index ? {
|
|
516
727
|
index: !0,
|
|
517
728
|
element: e.element
|
|
@@ -522,42 +733,42 @@ function lt(e) {
|
|
|
522
733
|
}
|
|
523
734
|
//#endregion
|
|
524
735
|
//#region src/router/createAdminRouter.tsx
|
|
525
|
-
function
|
|
526
|
-
let { loginPath: i, homePath: a } =
|
|
736
|
+
function Dt({ navItems: e, children: t, layoutProps: n, redirects: r }) {
|
|
737
|
+
let { loginPath: i, homePath: a } = Tt(t, r), { guest: o, public: s, protected: c } = St(t), l = [];
|
|
527
738
|
for (let e of o) !("path" in e) || !e.path || l.push({
|
|
528
|
-
path:
|
|
529
|
-
element: /* @__PURE__ */
|
|
739
|
+
path: Ct(e.path),
|
|
740
|
+
element: /* @__PURE__ */ K(yt, {
|
|
530
741
|
redirectTo: a,
|
|
531
742
|
children: e.element
|
|
532
743
|
})
|
|
533
744
|
});
|
|
534
745
|
for (let e of s) !("path" in e) || !e.path || l.push({
|
|
535
|
-
path:
|
|
746
|
+
path: Ct(e.path),
|
|
536
747
|
element: e.element
|
|
537
748
|
});
|
|
538
749
|
return c.length > 0 && l.push({
|
|
539
750
|
path: "/",
|
|
540
|
-
element: /* @__PURE__ */
|
|
751
|
+
element: /* @__PURE__ */ K(vt, {
|
|
541
752
|
redirectTo: i,
|
|
542
|
-
children: /* @__PURE__ */
|
|
753
|
+
children: /* @__PURE__ */ K(gt, {
|
|
543
754
|
navItems: e,
|
|
544
755
|
loginPath: i,
|
|
545
756
|
...n
|
|
546
757
|
})
|
|
547
758
|
}),
|
|
548
|
-
children: c.map(
|
|
759
|
+
children: c.map(Et)
|
|
549
760
|
}), l.push({
|
|
550
761
|
path: "*",
|
|
551
|
-
element: /* @__PURE__ */
|
|
762
|
+
element: /* @__PURE__ */ K(f, {
|
|
552
763
|
to: a,
|
|
553
764
|
replace: !0
|
|
554
765
|
})
|
|
555
|
-
}),
|
|
766
|
+
}), h(l);
|
|
556
767
|
}
|
|
557
768
|
//#endregion
|
|
558
769
|
//#region src/app/AdminApp.tsx
|
|
559
|
-
function
|
|
560
|
-
let a =
|
|
770
|
+
function Ot({ navItems: e, routes: t, authRedirects: n, layoutProps: r, theme: i }) {
|
|
771
|
+
let a = c(() => Dt({
|
|
561
772
|
navItems: e,
|
|
562
773
|
children: t,
|
|
563
774
|
layoutProps: r,
|
|
@@ -568,74 +779,75 @@ function dt({ navItems: e, routes: t, authRedirects: n, layoutProps: r, theme: i
|
|
|
568
779
|
r,
|
|
569
780
|
n
|
|
570
781
|
]);
|
|
571
|
-
return /* @__PURE__ */
|
|
782
|
+
return /* @__PURE__ */ K(Ie, {
|
|
572
783
|
...i,
|
|
573
|
-
children: /* @__PURE__ */
|
|
784
|
+
children: /* @__PURE__ */ K(m, { router: a })
|
|
574
785
|
});
|
|
575
786
|
}
|
|
576
787
|
//#endregion
|
|
577
788
|
//#region src/context/DataProvider.tsx
|
|
578
|
-
var
|
|
579
|
-
function
|
|
580
|
-
let n =
|
|
581
|
-
return /* @__PURE__ */
|
|
789
|
+
var kt = t(null);
|
|
790
|
+
function At({ children: e, value: t }) {
|
|
791
|
+
let n = c(() => t, [t]);
|
|
792
|
+
return /* @__PURE__ */ K(kt.Provider, {
|
|
582
793
|
value: n,
|
|
583
794
|
children: e
|
|
584
795
|
});
|
|
585
796
|
}
|
|
586
|
-
function
|
|
587
|
-
let e =
|
|
797
|
+
function jt() {
|
|
798
|
+
let e = o(kt);
|
|
588
799
|
if (!e) throw Error("useDataProvider must be used within DataProvider");
|
|
589
800
|
return e;
|
|
590
801
|
}
|
|
591
802
|
//#endregion
|
|
592
803
|
//#region src/data/resourceHandlers.ts
|
|
593
|
-
function
|
|
804
|
+
function Mt(e) {
|
|
594
805
|
return "handlers" in e ? e : { handlers: e };
|
|
595
806
|
}
|
|
596
|
-
function
|
|
597
|
-
if (!(!e || !t) && !
|
|
807
|
+
function Nt(e, t, n) {
|
|
808
|
+
if (!(!e || !t) && !X(e, t, n)) throw Error("Forbidden");
|
|
598
809
|
}
|
|
599
|
-
function
|
|
810
|
+
function Pt(e, t) {
|
|
600
811
|
let { can: n, guard: r, parseFormError: i } = t ?? {}, a = (t) => {
|
|
601
812
|
let n = e[t];
|
|
602
813
|
if (!n) throw Error(`Unknown resource: ${t}`);
|
|
603
|
-
return
|
|
814
|
+
return Mt(n);
|
|
604
815
|
};
|
|
605
816
|
return {
|
|
606
817
|
async getList(e, t) {
|
|
607
818
|
let { handlers: i, permissions: o } = a(e);
|
|
608
|
-
return r?.(e, "list"),
|
|
819
|
+
return r?.(e, "list"), Nt(n, o, "list"), i.getList(t);
|
|
609
820
|
},
|
|
610
821
|
async getOne(e, t, i) {
|
|
611
822
|
let { handlers: o, permissions: s } = a(e);
|
|
612
|
-
return r?.(e, "read"),
|
|
823
|
+
return r?.(e, "read"), Nt(n, s, "read"), o.getOne(t, i);
|
|
613
824
|
},
|
|
614
825
|
async create(e, t) {
|
|
615
826
|
let { handlers: i, permissions: o } = a(e);
|
|
616
|
-
return r?.(e, "add"),
|
|
827
|
+
return r?.(e, "add"), Nt(n, o, "add"), i.create(t);
|
|
617
828
|
},
|
|
618
829
|
async update(e, t) {
|
|
619
830
|
let { handlers: i, permissions: o } = a(e);
|
|
620
|
-
return r?.(e, "change"),
|
|
831
|
+
return r?.(e, "change"), Nt(n, o, "change"), i.update(t);
|
|
621
832
|
},
|
|
622
833
|
async delete(e, t) {
|
|
623
834
|
let { handlers: i, permissions: o } = a(e);
|
|
624
|
-
return r?.(e, "delete"),
|
|
835
|
+
return r?.(e, "delete"), Nt(n, o, "delete"), i.delete(t);
|
|
625
836
|
},
|
|
626
837
|
parseFormError: i
|
|
627
838
|
};
|
|
628
839
|
}
|
|
629
840
|
//#endregion
|
|
630
841
|
//#region src/data/abortError.ts
|
|
631
|
-
function
|
|
842
|
+
function Ft(e) {
|
|
632
843
|
if (typeof e != "object" || !e) return !1;
|
|
633
844
|
let t = e;
|
|
634
845
|
return t.name === "AbortError" || t.name === "CanceledError" || t.code === "ERR_CANCELED";
|
|
635
846
|
}
|
|
636
847
|
//#endregion
|
|
637
848
|
//#region src/data/parseFormErrorHelpers.ts
|
|
638
|
-
|
|
849
|
+
var It = "Expected HTTP 400 with a JSON object such as `{ \"field_name\": [\"message\"] }` or `{ \"non_field_errors\": [\"message\"] }`.", Lt = 300;
|
|
850
|
+
function Z(e) {
|
|
639
851
|
if (typeof e == "string") return [e];
|
|
640
852
|
if (Array.isArray(e)) {
|
|
641
853
|
let t = e.filter((e) => typeof e == "string");
|
|
@@ -643,85 +855,149 @@ function Y(e) {
|
|
|
643
855
|
}
|
|
644
856
|
return [];
|
|
645
857
|
}
|
|
646
|
-
function
|
|
858
|
+
function Rt(e) {
|
|
647
859
|
return e.length === 1 ? e[0] : e;
|
|
648
860
|
}
|
|
649
|
-
function
|
|
861
|
+
function zt(e) {
|
|
862
|
+
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
863
|
+
}
|
|
864
|
+
function Bt(e) {
|
|
865
|
+
return typeof Response < "u" && e instanceof Response ? !0 : typeof e == "object" && !!e && typeof e.json == "function" && typeof e.status == "number" && e.headers != null;
|
|
866
|
+
}
|
|
867
|
+
function Vt(e, t) {
|
|
868
|
+
if (t) return t;
|
|
869
|
+
if (e === null) return "(no JSON body)";
|
|
870
|
+
try {
|
|
871
|
+
let t = JSON.stringify(e);
|
|
872
|
+
return t.length > Lt ? `${t.slice(0, Lt)}…` : t;
|
|
873
|
+
} catch {
|
|
874
|
+
return String(e);
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
function Ht(e, t) {
|
|
878
|
+
return `Non-standard validation response. ${It} Received: ${Vt(e, t?.hint)}`;
|
|
879
|
+
}
|
|
880
|
+
function Ut(e) {
|
|
881
|
+
if (!e || typeof e != "object") return null;
|
|
882
|
+
let t = e.response;
|
|
883
|
+
if (!t || typeof t != "object") return null;
|
|
884
|
+
let n = t.status;
|
|
885
|
+
return typeof n == "number" && (n === 400 || n === 422) ? n : null;
|
|
886
|
+
}
|
|
887
|
+
function Wt(e) {
|
|
888
|
+
if (!e || typeof e != "object") return null;
|
|
889
|
+
let t = e.response;
|
|
890
|
+
return Bt(t) ? t.headers.get("content-type") : null;
|
|
891
|
+
}
|
|
892
|
+
function Gt(e) {
|
|
650
893
|
if (!e || typeof e != "object") return null;
|
|
651
894
|
let t = e;
|
|
652
|
-
if (
|
|
895
|
+
if (zt(t.body)) return t.body;
|
|
896
|
+
if (zt(t.data)) return t.data;
|
|
653
897
|
let n = t.response;
|
|
654
898
|
if (n && typeof n == "object" && !Array.isArray(n)) {
|
|
655
899
|
let e = n.data;
|
|
656
|
-
if (
|
|
900
|
+
if (zt(e)) return e;
|
|
657
901
|
}
|
|
658
902
|
return null;
|
|
659
903
|
}
|
|
660
|
-
function
|
|
661
|
-
if (
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
904
|
+
function Kt(e) {
|
|
905
|
+
if (zt(e)) return e;
|
|
906
|
+
if (Array.isArray(e)) {
|
|
907
|
+
let t = Z(e);
|
|
908
|
+
return t.length ? { non_field_errors: Rt(t) } : null;
|
|
909
|
+
}
|
|
910
|
+
return null;
|
|
911
|
+
}
|
|
912
|
+
async function qt(e) {
|
|
913
|
+
let t = Gt(e);
|
|
914
|
+
if (t) return t;
|
|
915
|
+
if (!e || typeof e != "object") return null;
|
|
916
|
+
let n = e.response;
|
|
917
|
+
if (!Bt(n)) return null;
|
|
918
|
+
let r = n.headers.get("content-type");
|
|
919
|
+
if (!r || !/application\/json/i.test(r)) return null;
|
|
920
|
+
try {
|
|
921
|
+
return Kt(await n.clone().json());
|
|
922
|
+
} catch {
|
|
923
|
+
return null;
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
function Jt(e) {
|
|
927
|
+
return Array.isArray(e) ? e.some((e) => e && typeof e == "object" && !Array.isArray(e) && Object.values(e).some((e) => Z(e).length > 0)) : !1;
|
|
928
|
+
}
|
|
929
|
+
function Yt(e, t, n) {
|
|
930
|
+
t.forEach((t, r) => {
|
|
931
|
+
if (!(!t || typeof t != "object" || Array.isArray(t))) for (let [i, a] of Object.entries(t)) {
|
|
932
|
+
let t = Z(a);
|
|
933
|
+
t.length && (n[`${e}.${r}.${i}`] = Rt(t));
|
|
934
|
+
}
|
|
935
|
+
});
|
|
665
936
|
}
|
|
666
|
-
function
|
|
667
|
-
let r = xt(e, n);
|
|
937
|
+
function Xt(e, t) {
|
|
668
938
|
return {
|
|
669
|
-
fields: Object.keys(
|
|
939
|
+
fields: Object.keys(e).length ? e : void 0,
|
|
670
940
|
global: t.length ? t : void 0
|
|
671
941
|
};
|
|
672
942
|
}
|
|
673
|
-
var
|
|
674
|
-
function
|
|
675
|
-
let n =
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
943
|
+
var Zt = new Set(["non_field_errors", "detail"]);
|
|
944
|
+
function Qt(e) {
|
|
945
|
+
let t = {}, n = [];
|
|
946
|
+
for (let [r, i] of Object.entries(e)) {
|
|
947
|
+
if (Zt.has(r)) {
|
|
948
|
+
n.push(...Z(i));
|
|
949
|
+
continue;
|
|
950
|
+
}
|
|
951
|
+
if (Jt(i)) {
|
|
952
|
+
Yt(r, i, t);
|
|
681
953
|
continue;
|
|
682
954
|
}
|
|
683
|
-
let
|
|
684
|
-
|
|
955
|
+
let e = Z(i);
|
|
956
|
+
e.length && (t[r] = Rt(e));
|
|
685
957
|
}
|
|
686
|
-
return !Object.keys(
|
|
958
|
+
return !Object.keys(t).length && !n.length ? null : Xt(t, n);
|
|
687
959
|
}
|
|
688
|
-
function
|
|
689
|
-
let
|
|
960
|
+
function $t(e, t) {
|
|
961
|
+
let n = Gt(e);
|
|
962
|
+
return n ? Qt(n) : null;
|
|
963
|
+
}
|
|
964
|
+
function en(e, t, n) {
|
|
965
|
+
let r = Gt(e);
|
|
690
966
|
if (!r) return null;
|
|
691
967
|
let i = n?.camelCase ?? !0, a = n?.fieldMap, o = {}, s = [];
|
|
692
|
-
n?.includeSummary && (s.push(...
|
|
968
|
+
n?.includeSummary && (s.push(...Z(r.title)), s.push(...Z(r.message)));
|
|
693
969
|
let c = r.errors;
|
|
694
970
|
if (c && typeof c == "object" && !Array.isArray(c)) for (let [e, t] of Object.entries(c)) {
|
|
695
|
-
let n = a?.[e] ?? (i ?
|
|
696
|
-
r.length && (o[n] =
|
|
971
|
+
let n = a?.[e] ?? (i ? rn(e) : e), r = Z(t);
|
|
972
|
+
r.length && (o[n] = Rt(r));
|
|
697
973
|
}
|
|
698
|
-
return !Object.keys(o).length && !s.length ? null :
|
|
974
|
+
return !Object.keys(o).length && !s.length ? null : Xt(o, s);
|
|
699
975
|
}
|
|
700
|
-
function
|
|
701
|
-
let r =
|
|
976
|
+
function tn(e, t, n) {
|
|
977
|
+
let r = Gt(e);
|
|
702
978
|
if (!r) return null;
|
|
703
979
|
let i = {}, a = [], o = n?.fieldMap, s = r.errors;
|
|
704
980
|
if (Array.isArray(s)) for (let e of s) {
|
|
705
981
|
if (!e || typeof e != "object") continue;
|
|
706
|
-
let t = e, n = typeof t.path == "string" && t.path || typeof t.param == "string" && t.param || typeof t.field == "string" && t.field, r =
|
|
707
|
-
r && (n ?
|
|
982
|
+
let t = e, n = typeof t.path == "string" && t.path || typeof t.param == "string" && t.param || typeof t.field == "string" && t.field, r = Z(t.msg)[0] ?? Z(t.message)[0];
|
|
983
|
+
r && (n ? nn(i, o?.[n] ?? n, r) : a.push(r));
|
|
708
984
|
}
|
|
709
985
|
else if (s && typeof s == "object") for (let [e, t] of Object.entries(s)) {
|
|
710
|
-
let n = o?.[e] ?? e, r =
|
|
711
|
-
r.length && (i[n] =
|
|
986
|
+
let n = o?.[e] ?? e, r = Z(t);
|
|
987
|
+
r.length && (i[n] = Rt(r));
|
|
712
988
|
}
|
|
713
989
|
let c = r.details;
|
|
714
990
|
if (Array.isArray(c)) for (let e of c) {
|
|
715
991
|
if (!e || typeof e != "object") continue;
|
|
716
|
-
let t = e, n = (Array.isArray(t.path) ? t.path : []).map((e) => String(e)).join("."), r =
|
|
992
|
+
let t = e, n = (Array.isArray(t.path) ? t.path : []).map((e) => String(e)).join("."), r = Z(t.message)[0];
|
|
717
993
|
if (r) if (n) {
|
|
718
994
|
let e = o?.[n] ?? n;
|
|
719
995
|
i[e] = r;
|
|
720
996
|
} else a.push(r);
|
|
721
997
|
}
|
|
722
|
-
return a.push(...
|
|
998
|
+
return a.push(...Z(r.error)), !Object.keys(i).length && !a.length ? null : Xt(i, a);
|
|
723
999
|
}
|
|
724
|
-
function
|
|
1000
|
+
function nn(e, t, n) {
|
|
725
1001
|
let r = e[t];
|
|
726
1002
|
if (!r) {
|
|
727
1003
|
e[t] = n;
|
|
@@ -729,20 +1005,20 @@ function Dt(e, t, n) {
|
|
|
729
1005
|
}
|
|
730
1006
|
e[t] = Array.isArray(r) ? [...r, n] : [r, n];
|
|
731
1007
|
}
|
|
732
|
-
function
|
|
1008
|
+
function rn(e) {
|
|
733
1009
|
return e && e.charAt(0).toLowerCase() + e.slice(1);
|
|
734
1010
|
}
|
|
735
1011
|
//#endregion
|
|
736
1012
|
//#region src/data/inMemoryList.ts
|
|
737
|
-
function
|
|
1013
|
+
function an(e, t) {
|
|
738
1014
|
return e === t || String(e) === String(t);
|
|
739
1015
|
}
|
|
740
|
-
function
|
|
741
|
-
let n = e.find((e) =>
|
|
1016
|
+
function on(e, t) {
|
|
1017
|
+
let n = e.find((e) => an(e.id, t));
|
|
742
1018
|
if (!n) throw Error("Not found");
|
|
743
1019
|
return n;
|
|
744
1020
|
}
|
|
745
|
-
function
|
|
1021
|
+
function sn(e, t) {
|
|
746
1022
|
if (t.length === 0) return e;
|
|
747
1023
|
let n = (e) => e === "DESC" ? -1 : 1;
|
|
748
1024
|
return [...e].sort((e, r) => {
|
|
@@ -758,33 +1034,33 @@ function jt(e, t) {
|
|
|
758
1034
|
return 0;
|
|
759
1035
|
});
|
|
760
1036
|
}
|
|
761
|
-
function
|
|
1037
|
+
function cn(e, t) {
|
|
762
1038
|
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;
|
|
763
1039
|
}
|
|
764
|
-
function
|
|
765
|
-
return t ? e.filter((e) => Object.entries(t).every(([t, n]) =>
|
|
1040
|
+
function ln(e, t) {
|
|
1041
|
+
return t ? e.filter((e) => Object.entries(t).every(([t, n]) => cn(e[t], n))) : e;
|
|
766
1042
|
}
|
|
767
|
-
function
|
|
1043
|
+
function un(e, t, n) {
|
|
768
1044
|
let r = (t - 1) * n;
|
|
769
1045
|
return {
|
|
770
1046
|
data: e.slice(r, r + n),
|
|
771
1047
|
total: e.length
|
|
772
1048
|
};
|
|
773
1049
|
}
|
|
774
|
-
function
|
|
775
|
-
let { pagination: n, sort: r, filter: i } = t, a =
|
|
1050
|
+
function dn(e, t) {
|
|
1051
|
+
let { pagination: n, sort: r, filter: i } = t, a = ln(e, i);
|
|
776
1052
|
if (r) {
|
|
777
1053
|
let e = Array.isArray(r) ? r : [r];
|
|
778
|
-
e.length > 0 && e[0]?.field && (a =
|
|
1054
|
+
e.length > 0 && e[0]?.field && (a = sn(a, e));
|
|
779
1055
|
}
|
|
780
|
-
return n ?
|
|
1056
|
+
return n ? un(a, n.page, n.perPage) : {
|
|
781
1057
|
data: a,
|
|
782
1058
|
total: a.length
|
|
783
1059
|
};
|
|
784
1060
|
}
|
|
785
1061
|
//#endregion
|
|
786
1062
|
//#region src/data/createMemoryResourceHandlers.ts
|
|
787
|
-
function
|
|
1063
|
+
function fn(e) {
|
|
788
1064
|
let t = (e) => e, n = e.mapCreate ?? ((e, t) => ({
|
|
789
1065
|
...e,
|
|
790
1066
|
id: t
|
|
@@ -795,21 +1071,21 @@ function It(e) {
|
|
|
795
1071
|
}));
|
|
796
1072
|
return {
|
|
797
1073
|
async getList(n) {
|
|
798
|
-
return
|
|
1074
|
+
return dn(t(e.scopeList ? e.scopeList(e.getRows(), n) : e.getRows()), n);
|
|
799
1075
|
},
|
|
800
1076
|
async getOne(t, n) {
|
|
801
|
-
return { data:
|
|
1077
|
+
return { data: on(e.getRows(), t) };
|
|
802
1078
|
},
|
|
803
1079
|
async create(t) {
|
|
804
1080
|
let r = n(t, e.nextId());
|
|
805
1081
|
return e.getRows().push(r), { data: r };
|
|
806
1082
|
},
|
|
807
1083
|
async update({ id: t, data: n }) {
|
|
808
|
-
let i =
|
|
1084
|
+
let i = on(e.getRows(), t), a = r(i, n);
|
|
809
1085
|
return Object.assign(i, a), { data: i };
|
|
810
1086
|
},
|
|
811
1087
|
async delete(t) {
|
|
812
|
-
let n = e.getRows(), r = n.findIndex((e) =>
|
|
1088
|
+
let n = e.getRows(), r = n.findIndex((e) => an(e.id, t));
|
|
813
1089
|
if (r < 0) return { data: null };
|
|
814
1090
|
let [i] = n.splice(r, 1);
|
|
815
1091
|
return e.afterDelete?.(i), { data: i };
|
|
@@ -818,7 +1094,7 @@ function It(e) {
|
|
|
818
1094
|
}
|
|
819
1095
|
//#endregion
|
|
820
1096
|
//#region src/data/createRestResourceHandlers.ts
|
|
821
|
-
function
|
|
1097
|
+
function pn(e) {
|
|
822
1098
|
return {
|
|
823
1099
|
async getList(t) {
|
|
824
1100
|
return e.list(t);
|
|
@@ -827,11 +1103,11 @@ function Lt(e) {
|
|
|
827
1103
|
return { data: await e.retrieve(t, n) };
|
|
828
1104
|
},
|
|
829
1105
|
async create(t) {
|
|
830
|
-
let n = e.transformCreate ? e.transformCreate(t) : t;
|
|
1106
|
+
let n = t instanceof FormData ? t : e.transformCreate ? e.transformCreate(t) : t;
|
|
831
1107
|
return { data: await e.create(n) };
|
|
832
1108
|
},
|
|
833
1109
|
async update({ id: t, data: n }) {
|
|
834
|
-
let r = e.transformUpdate ? e.transformUpdate(n) : n;
|
|
1110
|
+
let r = n instanceof FormData ? n : e.transformUpdate ? e.transformUpdate(n) : n;
|
|
835
1111
|
return { data: await e.update(t, r) };
|
|
836
1112
|
},
|
|
837
1113
|
async delete(t) {
|
|
@@ -841,25 +1117,25 @@ function Lt(e) {
|
|
|
841
1117
|
}
|
|
842
1118
|
//#endregion
|
|
843
1119
|
//#region src/data/sortHelpers.ts
|
|
844
|
-
function
|
|
1120
|
+
function mn(e) {
|
|
845
1121
|
return e ? Array.isArray(e) ? e : [e] : [];
|
|
846
1122
|
}
|
|
847
|
-
function
|
|
848
|
-
let t =
|
|
1123
|
+
function hn(e) {
|
|
1124
|
+
let t = mn(e);
|
|
849
1125
|
if (t.length !== 0) return t.map((e) => e.order === "DESC" ? `-${e.field}` : e.field).join(",");
|
|
850
1126
|
}
|
|
851
|
-
function
|
|
852
|
-
let t =
|
|
1127
|
+
function gn(e) {
|
|
1128
|
+
let t = mn(e);
|
|
853
1129
|
if (t.length !== 0) return t.map((e) => `${e.field} ${e.order === "DESC" ? "desc" : "asc"}`).join(",");
|
|
854
1130
|
}
|
|
855
|
-
function
|
|
856
|
-
let t =
|
|
1131
|
+
function _n(e) {
|
|
1132
|
+
let t = mn(e);
|
|
857
1133
|
if (t.length !== 0) return t.map((e) => e.order === "DESC" ? `-${e.field}` : e.field).join(",");
|
|
858
1134
|
}
|
|
859
1135
|
//#endregion
|
|
860
1136
|
//#region src/components/AuthAlternateLink.tsx
|
|
861
|
-
function
|
|
862
|
-
return /* @__PURE__ */
|
|
1137
|
+
function vn({ prompt: e, linkText: t, to: n }) {
|
|
1138
|
+
return /* @__PURE__ */ q(U.Paragraph, {
|
|
863
1139
|
type: "secondary",
|
|
864
1140
|
style: {
|
|
865
1141
|
textAlign: "center",
|
|
@@ -868,7 +1144,7 @@ function Ht({ prompt: e, linkText: t, to: n }) {
|
|
|
868
1144
|
children: [
|
|
869
1145
|
e,
|
|
870
1146
|
" ",
|
|
871
|
-
/* @__PURE__ */
|
|
1147
|
+
/* @__PURE__ */ K(d, {
|
|
872
1148
|
to: n,
|
|
873
1149
|
children: t
|
|
874
1150
|
})
|
|
@@ -877,9 +1153,9 @@ function Ht({ prompt: e, linkText: t, to: n }) {
|
|
|
877
1153
|
}
|
|
878
1154
|
//#endregion
|
|
879
1155
|
//#region src/layouts/AuthPageLayout.tsx
|
|
880
|
-
function
|
|
881
|
-
let { token: i } =
|
|
882
|
-
return /* @__PURE__ */
|
|
1156
|
+
function yn({ children: e, brand: t, footer: n, showThemeToolbar: r = !0 }) {
|
|
1157
|
+
let { token: i } = W.useToken();
|
|
1158
|
+
return /* @__PURE__ */ q(k, {
|
|
883
1159
|
vertical: !0,
|
|
884
1160
|
align: "stretch",
|
|
885
1161
|
style: {
|
|
@@ -890,7 +1166,7 @@ function Ut({ children: e, brand: t, footer: n, showThemeToolbar: r = !0 }) {
|
|
|
890
1166
|
background: i.colorBgLayout
|
|
891
1167
|
},
|
|
892
1168
|
children: [
|
|
893
|
-
r ? /* @__PURE__ */
|
|
1169
|
+
r ? /* @__PURE__ */ K(k, {
|
|
894
1170
|
justify: "flex-end",
|
|
895
1171
|
style: {
|
|
896
1172
|
flexShrink: 0,
|
|
@@ -898,9 +1174,9 @@ function Ut({ children: e, brand: t, footer: n, showThemeToolbar: r = !0 }) {
|
|
|
898
1174
|
padding: 16,
|
|
899
1175
|
background: i.colorBgLayout
|
|
900
1176
|
},
|
|
901
|
-
children: /* @__PURE__ */
|
|
1177
|
+
children: /* @__PURE__ */ K(He, {})
|
|
902
1178
|
}) : null,
|
|
903
|
-
t ? /* @__PURE__ */
|
|
1179
|
+
t ? /* @__PURE__ */ K("div", {
|
|
904
1180
|
style: {
|
|
905
1181
|
flexShrink: 0,
|
|
906
1182
|
textAlign: "center",
|
|
@@ -908,54 +1184,58 @@ function Ut({ children: e, brand: t, footer: n, showThemeToolbar: r = !0 }) {
|
|
|
908
1184
|
},
|
|
909
1185
|
children: t
|
|
910
1186
|
}) : null,
|
|
911
|
-
/* @__PURE__ */
|
|
912
|
-
flex: 1,
|
|
913
|
-
vertical: !0,
|
|
914
|
-
align: "center",
|
|
915
|
-
justify: "flex-start",
|
|
1187
|
+
/* @__PURE__ */ K(We, {
|
|
916
1188
|
style: {
|
|
917
|
-
|
|
1189
|
+
flex: 1,
|
|
918
1190
|
minHeight: 0,
|
|
919
|
-
|
|
920
|
-
overflow: "auto",
|
|
921
|
-
overflowX: "hidden",
|
|
1191
|
+
width: "100%",
|
|
922
1192
|
background: i.colorBgLayout
|
|
923
1193
|
},
|
|
924
|
-
children:
|
|
1194
|
+
children: /* @__PURE__ */ q(k, {
|
|
1195
|
+
vertical: !0,
|
|
1196
|
+
align: "center",
|
|
1197
|
+
justify: "flex-start",
|
|
925
1198
|
style: {
|
|
926
|
-
marginTop: 16,
|
|
927
1199
|
width: "100%",
|
|
928
|
-
|
|
1200
|
+
minHeight: "100%",
|
|
1201
|
+
padding: "0 24px 24px"
|
|
929
1202
|
},
|
|
930
|
-
children: n
|
|
931
|
-
|
|
1203
|
+
children: [e, n ? /* @__PURE__ */ K("div", {
|
|
1204
|
+
style: {
|
|
1205
|
+
marginTop: 16,
|
|
1206
|
+
width: "100%",
|
|
1207
|
+
maxWidth: 520
|
|
1208
|
+
},
|
|
1209
|
+
children: n
|
|
1210
|
+
}) : null]
|
|
1211
|
+
})
|
|
932
1212
|
})
|
|
933
1213
|
]
|
|
934
1214
|
});
|
|
935
1215
|
}
|
|
936
1216
|
//#endregion
|
|
937
1217
|
//#region src/pages/LoginPage.tsx
|
|
938
|
-
function
|
|
939
|
-
let { login: l } =
|
|
940
|
-
return /* @__PURE__ */
|
|
1218
|
+
function bn({ 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 }) {
|
|
1219
|
+
let { login: l } = Ye(), u = _();
|
|
1220
|
+
return /* @__PURE__ */ K(yn, {
|
|
941
1221
|
brand: r ?? n,
|
|
942
|
-
footer: c ?? (s ? /* @__PURE__ */
|
|
1222
|
+
footer: c ?? (s ? /* @__PURE__ */ K(vn, {
|
|
943
1223
|
prompt: s.prompt ?? "Don't have an account?",
|
|
944
1224
|
linkText: s.linkText,
|
|
945
1225
|
to: s.to
|
|
946
1226
|
}) : null),
|
|
947
1227
|
showThemeToolbar: a,
|
|
948
|
-
children: /* @__PURE__ */
|
|
1228
|
+
children: /* @__PURE__ */ q(w, {
|
|
949
1229
|
style: {
|
|
950
1230
|
width: "100%",
|
|
951
1231
|
maxWidth: 360
|
|
952
1232
|
},
|
|
953
1233
|
title: e,
|
|
954
|
-
children: [t ? /* @__PURE__ */
|
|
1234
|
+
children: [t ? /* @__PURE__ */ K(U.Paragraph, {
|
|
955
1235
|
type: "secondary",
|
|
956
1236
|
style: { marginTop: 0 },
|
|
957
1237
|
children: t
|
|
958
|
-
}) : null, /* @__PURE__ */
|
|
1238
|
+
}) : null, /* @__PURE__ */ q(A, {
|
|
959
1239
|
layout: "vertical",
|
|
960
1240
|
onFinish: async (e) => {
|
|
961
1241
|
await l({
|
|
@@ -965,28 +1245,28 @@ function Wt({ title: e = "Sign in", description: t = "Use any username and passw
|
|
|
965
1245
|
}), u(o, { replace: !0 });
|
|
966
1246
|
},
|
|
967
1247
|
children: [
|
|
968
|
-
/* @__PURE__ */
|
|
1248
|
+
/* @__PURE__ */ K(A.Item, {
|
|
969
1249
|
name: "username",
|
|
970
1250
|
label: "Username",
|
|
971
1251
|
rules: [{
|
|
972
1252
|
required: !0,
|
|
973
1253
|
message: "Required"
|
|
974
1254
|
}],
|
|
975
|
-
children: /* @__PURE__ */
|
|
1255
|
+
children: /* @__PURE__ */ K(N, { autoComplete: "username" })
|
|
976
1256
|
}),
|
|
977
|
-
/* @__PURE__ */
|
|
1257
|
+
/* @__PURE__ */ K(A.Item, {
|
|
978
1258
|
name: "password",
|
|
979
1259
|
label: "Password",
|
|
980
1260
|
rules: [{
|
|
981
1261
|
required: !0,
|
|
982
1262
|
message: "Required"
|
|
983
1263
|
}],
|
|
984
|
-
children: /* @__PURE__ */
|
|
1264
|
+
children: /* @__PURE__ */ K(N.Password, { autoComplete: "current-password" })
|
|
985
1265
|
}),
|
|
986
1266
|
i,
|
|
987
|
-
/* @__PURE__ */
|
|
1267
|
+
/* @__PURE__ */ K(A.Item, {
|
|
988
1268
|
style: { marginBottom: 0 },
|
|
989
|
-
children: /* @__PURE__ */
|
|
1269
|
+
children: /* @__PURE__ */ K(C, {
|
|
990
1270
|
type: "primary",
|
|
991
1271
|
htmlType: "submit",
|
|
992
1272
|
block: !0,
|
|
@@ -1000,8 +1280,8 @@ function Wt({ title: e = "Sign in", description: t = "Use any username and passw
|
|
|
1000
1280
|
}
|
|
1001
1281
|
//#endregion
|
|
1002
1282
|
//#region src/pages/PlaceholderPage.tsx
|
|
1003
|
-
function
|
|
1004
|
-
return /* @__PURE__ */
|
|
1283
|
+
function xn({ title: e }) {
|
|
1284
|
+
return /* @__PURE__ */ K(U.Title, {
|
|
1005
1285
|
level: 3,
|
|
1006
1286
|
style: { marginTop: 0 },
|
|
1007
1287
|
children: e
|
|
@@ -1009,7 +1289,7 @@ function Gt({ title: e }) {
|
|
|
1009
1289
|
}
|
|
1010
1290
|
//#endregion
|
|
1011
1291
|
//#region src/crud/utils/sortQueryParam.ts
|
|
1012
|
-
function
|
|
1292
|
+
function Sn(e) {
|
|
1013
1293
|
if (!e) return [];
|
|
1014
1294
|
let t = [];
|
|
1015
1295
|
for (let n of e.split(",").map((e) => e.trim()).filter(Boolean)) {
|
|
@@ -1033,66 +1313,66 @@ function Kt(e) {
|
|
|
1033
1313
|
}
|
|
1034
1314
|
return t;
|
|
1035
1315
|
}
|
|
1036
|
-
function
|
|
1316
|
+
function Cn(e) {
|
|
1037
1317
|
return e.length === 0 ? null : e.map((e) => e.order === "DESC" ? `-${e.field}` : e.field).join(",");
|
|
1038
1318
|
}
|
|
1039
|
-
function
|
|
1319
|
+
function wn(e) {
|
|
1040
1320
|
return new Map(e.map((e, t) => [e.field, t + 1]));
|
|
1041
1321
|
}
|
|
1042
1322
|
//#endregion
|
|
1043
1323
|
//#region src/crud/context/ListContext.tsx
|
|
1044
|
-
var
|
|
1045
|
-
function
|
|
1046
|
-
let [r,
|
|
1324
|
+
var Tn = t(null);
|
|
1325
|
+
function En({ children: e, toggleSort: t, sort: n }) {
|
|
1326
|
+
let [r, i] = u([]), o = c(() => new Set(n.map((e) => e.field)), [n]), s = c(() => new Map(n.map((e) => [e.field, e.order])), [n]), l = c(() => wn(n), [n]), d = a((e) => (i((t) => {
|
|
1047
1327
|
let n = t.findIndex((t) => t.key === e.key);
|
|
1048
1328
|
if (n < 0) return [...t, e];
|
|
1049
1329
|
if (t[n] === e) return t;
|
|
1050
1330
|
let r = [...t];
|
|
1051
1331
|
return r[n] = e, r;
|
|
1052
1332
|
}), () => {
|
|
1053
|
-
|
|
1054
|
-
}), []), f =
|
|
1333
|
+
i((t) => t.filter((t) => t.key !== e.key));
|
|
1334
|
+
}), []), f = c(() => ({
|
|
1055
1335
|
columns: r,
|
|
1056
1336
|
toggleSort: t,
|
|
1057
1337
|
sortFields: o,
|
|
1058
|
-
sortOrders:
|
|
1059
|
-
sortPriorities:
|
|
1338
|
+
sortOrders: s,
|
|
1339
|
+
sortPriorities: l,
|
|
1060
1340
|
registerColumn: d
|
|
1061
1341
|
}), [
|
|
1062
1342
|
r,
|
|
1063
1343
|
t,
|
|
1064
1344
|
o,
|
|
1065
|
-
|
|
1066
|
-
|
|
1345
|
+
s,
|
|
1346
|
+
l,
|
|
1067
1347
|
d
|
|
1068
1348
|
]);
|
|
1069
|
-
return /* @__PURE__ */
|
|
1349
|
+
return /* @__PURE__ */ K(Tn.Provider, {
|
|
1070
1350
|
value: f,
|
|
1071
1351
|
children: e
|
|
1072
1352
|
});
|
|
1073
1353
|
}
|
|
1074
|
-
function
|
|
1075
|
-
let e =
|
|
1354
|
+
function Dn() {
|
|
1355
|
+
let e = o(Tn);
|
|
1076
1356
|
if (!e) throw Error("Column components must be used within ResourceList");
|
|
1077
1357
|
return e;
|
|
1078
1358
|
}
|
|
1079
|
-
function
|
|
1080
|
-
let { registerColumn: t } =
|
|
1081
|
-
|
|
1359
|
+
function Q(e) {
|
|
1360
|
+
let { registerColumn: t } = Dn();
|
|
1361
|
+
s(() => t(e), [t, e]);
|
|
1082
1362
|
}
|
|
1083
1363
|
//#endregion
|
|
1084
1364
|
//#region src/crud/context/FilterContext.tsx
|
|
1085
|
-
var
|
|
1086
|
-
function
|
|
1087
|
-
let [r,
|
|
1365
|
+
var On = t(null);
|
|
1366
|
+
function kn({ children: e, values: t, setFilterValue: n }) {
|
|
1367
|
+
let [r, i] = u([]), o = a((e) => (i((t) => {
|
|
1088
1368
|
let n = t.findIndex((t) => t.key === e.key);
|
|
1089
1369
|
if (n < 0) return [...t, e];
|
|
1090
1370
|
if (t[n] === e) return t;
|
|
1091
1371
|
let r = [...t];
|
|
1092
1372
|
return r[n] = e, r;
|
|
1093
1373
|
}), () => {
|
|
1094
|
-
|
|
1095
|
-
}), []),
|
|
1374
|
+
i((t) => t.filter((t) => t.key !== e.key));
|
|
1375
|
+
}), []), s = c(() => ({
|
|
1096
1376
|
filters: r,
|
|
1097
1377
|
values: t,
|
|
1098
1378
|
setFilterValue: n,
|
|
@@ -1103,25 +1383,25 @@ function $t({ children: e, values: t, setFilterValue: n }) {
|
|
|
1103
1383
|
n,
|
|
1104
1384
|
o
|
|
1105
1385
|
]);
|
|
1106
|
-
return /* @__PURE__ */
|
|
1107
|
-
value:
|
|
1386
|
+
return /* @__PURE__ */ K(On.Provider, {
|
|
1387
|
+
value: s,
|
|
1108
1388
|
children: e
|
|
1109
1389
|
});
|
|
1110
1390
|
}
|
|
1111
|
-
function
|
|
1112
|
-
return
|
|
1391
|
+
function An() {
|
|
1392
|
+
return o(On);
|
|
1113
1393
|
}
|
|
1114
|
-
function
|
|
1115
|
-
let t =
|
|
1116
|
-
|
|
1394
|
+
function jn(e) {
|
|
1395
|
+
let t = An()?.registerFilter;
|
|
1396
|
+
s(() => {
|
|
1117
1397
|
if (t) return t(e);
|
|
1118
1398
|
}, [t, e]);
|
|
1119
1399
|
}
|
|
1120
1400
|
//#endregion
|
|
1121
1401
|
//#region src/crud/context/FormContext.tsx
|
|
1122
|
-
var
|
|
1123
|
-
function
|
|
1124
|
-
return /* @__PURE__ */
|
|
1402
|
+
var Mn = t(null);
|
|
1403
|
+
function Nn({ children: e, resource: t, isNew: n, disabled: r }) {
|
|
1404
|
+
return /* @__PURE__ */ K(Mn.Provider, {
|
|
1125
1405
|
value: {
|
|
1126
1406
|
resource: t,
|
|
1127
1407
|
isNew: n,
|
|
@@ -1130,36 +1410,36 @@ function nn({ children: e, resource: t, isNew: n, disabled: r }) {
|
|
|
1130
1410
|
children: e
|
|
1131
1411
|
});
|
|
1132
1412
|
}
|
|
1133
|
-
function
|
|
1134
|
-
return
|
|
1413
|
+
function Pn() {
|
|
1414
|
+
return o(Mn);
|
|
1135
1415
|
}
|
|
1136
1416
|
//#endregion
|
|
1137
1417
|
//#region src/crud/context/FormSectionContext.tsx
|
|
1138
|
-
var
|
|
1139
|
-
function
|
|
1140
|
-
return /* @__PURE__ */
|
|
1418
|
+
var Fn = t(null);
|
|
1419
|
+
function In({ sourcesRef: e, children: t }) {
|
|
1420
|
+
return /* @__PURE__ */ K(Fn.Provider, {
|
|
1141
1421
|
value: e,
|
|
1142
1422
|
children: t
|
|
1143
1423
|
});
|
|
1144
1424
|
}
|
|
1145
|
-
function
|
|
1146
|
-
return
|
|
1425
|
+
function Ln() {
|
|
1426
|
+
return o(Fn);
|
|
1147
1427
|
}
|
|
1148
1428
|
//#endregion
|
|
1149
|
-
//#region src/crud/context/
|
|
1150
|
-
var
|
|
1151
|
-
function
|
|
1152
|
-
return /* @__PURE__ */
|
|
1429
|
+
//#region src/crud/context/PayloadFieldsContext.tsx
|
|
1430
|
+
var Rn = t(null);
|
|
1431
|
+
function zn({ children: e, fieldsRef: t }) {
|
|
1432
|
+
return /* @__PURE__ */ K(Rn.Provider, {
|
|
1153
1433
|
value: t,
|
|
1154
1434
|
children: e
|
|
1155
1435
|
});
|
|
1156
1436
|
}
|
|
1157
|
-
function
|
|
1158
|
-
return
|
|
1437
|
+
function Bn() {
|
|
1438
|
+
return o(Rn);
|
|
1159
1439
|
}
|
|
1160
|
-
function
|
|
1161
|
-
let n =
|
|
1162
|
-
|
|
1440
|
+
function Vn(e, t = !0) {
|
|
1441
|
+
let n = Bn();
|
|
1442
|
+
s(() => {
|
|
1163
1443
|
if (!(!t || !n)) return n.current.add(e), () => {
|
|
1164
1444
|
n.current.delete(e);
|
|
1165
1445
|
};
|
|
@@ -1169,9 +1449,9 @@ function dn(e, t = !0) {
|
|
|
1169
1449
|
t
|
|
1170
1450
|
]);
|
|
1171
1451
|
}
|
|
1172
|
-
function
|
|
1173
|
-
let n =
|
|
1174
|
-
|
|
1452
|
+
function Hn(e, t = !0) {
|
|
1453
|
+
let n = Ln();
|
|
1454
|
+
s(() => {
|
|
1175
1455
|
if (!(!t || !n)) return n.current.add(e), () => {
|
|
1176
1456
|
n.current.delete(e);
|
|
1177
1457
|
};
|
|
@@ -1182,8 +1462,62 @@ function fn(e, t = !0) {
|
|
|
1182
1462
|
]);
|
|
1183
1463
|
}
|
|
1184
1464
|
//#endregion
|
|
1185
|
-
//#region src/crud/
|
|
1186
|
-
|
|
1465
|
+
//#region src/crud/context/InlineFieldsRegistry.tsx
|
|
1466
|
+
var Un = t(null);
|
|
1467
|
+
function Wn({ children: e, registryRef: t }) {
|
|
1468
|
+
return /* @__PURE__ */ K(Un.Provider, {
|
|
1469
|
+
value: t,
|
|
1470
|
+
children: e
|
|
1471
|
+
});
|
|
1472
|
+
}
|
|
1473
|
+
function Gn() {
|
|
1474
|
+
return o(Un);
|
|
1475
|
+
}
|
|
1476
|
+
function Kn(e, t, n, r, i = !0) {
|
|
1477
|
+
let a = Gn();
|
|
1478
|
+
s(() => {
|
|
1479
|
+
if (!(!i || !a)) return a.current.set(e, {
|
|
1480
|
+
field: e,
|
|
1481
|
+
sources: t,
|
|
1482
|
+
payloadKey: n,
|
|
1483
|
+
transformRows: r
|
|
1484
|
+
}), () => {
|
|
1485
|
+
a.current.delete(e);
|
|
1486
|
+
};
|
|
1487
|
+
}, [
|
|
1488
|
+
a,
|
|
1489
|
+
e,
|
|
1490
|
+
t,
|
|
1491
|
+
n,
|
|
1492
|
+
r,
|
|
1493
|
+
i
|
|
1494
|
+
]);
|
|
1495
|
+
}
|
|
1496
|
+
//#endregion
|
|
1497
|
+
//#region src/crud/FormGlobalErrorsAlert.tsx
|
|
1498
|
+
function qn({ errors: e }) {
|
|
1499
|
+
return e.length ? e.length === 1 ? /* @__PURE__ */ K(b, {
|
|
1500
|
+
type: "error",
|
|
1501
|
+
title: e[0],
|
|
1502
|
+
showIcon: !0,
|
|
1503
|
+
style: { marginBottom: 16 }
|
|
1504
|
+
}) : /* @__PURE__ */ K(b, {
|
|
1505
|
+
type: "error",
|
|
1506
|
+
title: "Could not save",
|
|
1507
|
+
showIcon: !0,
|
|
1508
|
+
style: { marginBottom: 16 },
|
|
1509
|
+
description: /* @__PURE__ */ K("ul", {
|
|
1510
|
+
style: {
|
|
1511
|
+
margin: 0,
|
|
1512
|
+
paddingLeft: 20
|
|
1513
|
+
},
|
|
1514
|
+
children: e.map((e) => /* @__PURE__ */ K("li", { children: e }, e))
|
|
1515
|
+
})
|
|
1516
|
+
}) : null;
|
|
1517
|
+
}
|
|
1518
|
+
//#endregion
|
|
1519
|
+
//#region src/crud/utils/getFormValue.ts
|
|
1520
|
+
function Jn(e, t) {
|
|
1187
1521
|
let n = t.split("."), r = e;
|
|
1188
1522
|
for (let e of n) {
|
|
1189
1523
|
if (typeof r != "object" || !r) return;
|
|
@@ -1192,8 +1526,8 @@ function pn(e, t) {
|
|
|
1192
1526
|
return r;
|
|
1193
1527
|
}
|
|
1194
1528
|
//#endregion
|
|
1195
|
-
//#region src/crud/utils/
|
|
1196
|
-
function
|
|
1529
|
+
//#region src/crud/utils/setFormValue.ts
|
|
1530
|
+
function Yn(e, t, n) {
|
|
1197
1531
|
let r = t.split("."), i = e;
|
|
1198
1532
|
for (let e = 0; e < r.length - 1; e++) {
|
|
1199
1533
|
let t = r[e], n = i[t];
|
|
@@ -1202,143 +1536,388 @@ function mn(e, t, n) {
|
|
|
1202
1536
|
i[r[r.length - 1]] = n;
|
|
1203
1537
|
}
|
|
1204
1538
|
//#endregion
|
|
1205
|
-
//#region src/crud/utils/
|
|
1206
|
-
function
|
|
1539
|
+
//#region src/crud/utils/buildFormPayload.ts
|
|
1540
|
+
function Xn(e, t) {
|
|
1207
1541
|
if (t.length === 0) return { ...e };
|
|
1208
1542
|
let n = {};
|
|
1209
1543
|
for (let r of t) {
|
|
1210
|
-
let t =
|
|
1211
|
-
t !== void 0 &&
|
|
1544
|
+
let t = Jn(e, r);
|
|
1545
|
+
t !== void 0 && Yn(n, r, t);
|
|
1212
1546
|
}
|
|
1213
1547
|
return n;
|
|
1214
1548
|
}
|
|
1215
1549
|
//#endregion
|
|
1550
|
+
//#region src/crud/utils/buildInlineRowsPayload.ts
|
|
1551
|
+
function Zn(e, t, n) {
|
|
1552
|
+
if (!Array.isArray(e)) return [];
|
|
1553
|
+
let r = e.map((e) => {
|
|
1554
|
+
if (!e || typeof e != "object") return {};
|
|
1555
|
+
let n = e, r = {};
|
|
1556
|
+
for (let e of t) {
|
|
1557
|
+
let t = n[e];
|
|
1558
|
+
t !== void 0 && (r[e] = t);
|
|
1559
|
+
}
|
|
1560
|
+
let i = n.id;
|
|
1561
|
+
return i != null && (r.id = i), r;
|
|
1562
|
+
});
|
|
1563
|
+
return n?.transformRows ? n.transformRows(r) : r;
|
|
1564
|
+
}
|
|
1565
|
+
//#endregion
|
|
1566
|
+
//#region src/crud/utils/hasUploadValues.ts
|
|
1567
|
+
function Qn(e) {
|
|
1568
|
+
return e instanceof Blob ? !0 : Array.isArray(e) ? e.some(Qn) : e && typeof e == "object" ? Object.values(e).some(Qn) : !1;
|
|
1569
|
+
}
|
|
1570
|
+
//#endregion
|
|
1571
|
+
//#region src/crud/utils/uploadReferenceUtils.ts
|
|
1572
|
+
function $n(e) {
|
|
1573
|
+
return /^https?:\/\//i.test(e) || e.startsWith("/media/");
|
|
1574
|
+
}
|
|
1575
|
+
function er(e, t) {
|
|
1576
|
+
if (!t) return e;
|
|
1577
|
+
if (typeof e == "string") return $n(e) ? void 0 : e;
|
|
1578
|
+
if (Array.isArray(e)) return e.map((e) => er(e, t)).filter((e) => e !== void 0);
|
|
1579
|
+
if (e && typeof e == "object" && !(e instanceof Blob)) {
|
|
1580
|
+
let n = {};
|
|
1581
|
+
for (let [r, i] of Object.entries(e)) {
|
|
1582
|
+
let e = er(i, t);
|
|
1583
|
+
e !== void 0 && (n[r] = e);
|
|
1584
|
+
}
|
|
1585
|
+
return n;
|
|
1586
|
+
}
|
|
1587
|
+
return e;
|
|
1588
|
+
}
|
|
1589
|
+
function tr(e, t = !0) {
|
|
1590
|
+
return er(e, t);
|
|
1591
|
+
}
|
|
1592
|
+
//#endregion
|
|
1593
|
+
//#region src/crud/utils/toFormData.ts
|
|
1594
|
+
function nr(e, t, n, r) {
|
|
1595
|
+
if (n !== void 0) {
|
|
1596
|
+
if (n === null) {
|
|
1597
|
+
e.append(t, "");
|
|
1598
|
+
return;
|
|
1599
|
+
}
|
|
1600
|
+
if (n instanceof Blob) {
|
|
1601
|
+
e.append(t, n);
|
|
1602
|
+
return;
|
|
1603
|
+
}
|
|
1604
|
+
if (typeof n == "boolean" || typeof n == "number") {
|
|
1605
|
+
e.append(t, String(n));
|
|
1606
|
+
return;
|
|
1607
|
+
}
|
|
1608
|
+
if (typeof n == "string") {
|
|
1609
|
+
if (r.skipExistingUploadUrls && $n(n)) return;
|
|
1610
|
+
e.append(t, n);
|
|
1611
|
+
return;
|
|
1612
|
+
}
|
|
1613
|
+
if (Array.isArray(n)) {
|
|
1614
|
+
n.forEach((n, i) => {
|
|
1615
|
+
nr(e, `${t}[${i}]`, n, r);
|
|
1616
|
+
});
|
|
1617
|
+
return;
|
|
1618
|
+
}
|
|
1619
|
+
if (typeof n == "object") {
|
|
1620
|
+
for (let [i, a] of Object.entries(n)) nr(e, `${t}[${i}]`, a, r);
|
|
1621
|
+
return;
|
|
1622
|
+
}
|
|
1623
|
+
e.append(t, String(n));
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
function rr(e, t) {
|
|
1627
|
+
let n = { skipExistingUploadUrls: t?.skipExistingUploadUrls ?? !0 }, r = new FormData();
|
|
1628
|
+
for (let [t, i] of Object.entries(e)) nr(r, t, i, n);
|
|
1629
|
+
return r;
|
|
1630
|
+
}
|
|
1631
|
+
//#endregion
|
|
1632
|
+
//#region src/crud/utils/prepareFormSubmitBody.ts
|
|
1633
|
+
function ir(e, t) {
|
|
1634
|
+
let n = t?.skipExistingUploadUrls ?? !0;
|
|
1635
|
+
return Qn(e) ? rr(e, t) : tr(e, n);
|
|
1636
|
+
}
|
|
1637
|
+
//#endregion
|
|
1638
|
+
//#region src/crud/utils/buildResourceFormSubmitBody.ts
|
|
1639
|
+
function ar(e, t, n, r) {
|
|
1640
|
+
let i = Xn(e, t);
|
|
1641
|
+
if (n) for (let t of n) {
|
|
1642
|
+
let n = e[t.field], r = t.payloadKey ?? t.field;
|
|
1643
|
+
i[r] = Zn(n, t.sources, { transformRows: t.transformRows });
|
|
1644
|
+
}
|
|
1645
|
+
return ir(i, r);
|
|
1646
|
+
}
|
|
1647
|
+
//#endregion
|
|
1216
1648
|
//#region src/crud/utils/formErrors.ts
|
|
1217
|
-
function
|
|
1649
|
+
function or(e) {
|
|
1218
1650
|
return e ? Array.isArray(e) ? e : [e] : [];
|
|
1219
1651
|
}
|
|
1220
|
-
function
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1652
|
+
function sr(e) {
|
|
1653
|
+
return Array.isArray(e) ? e.join(", ") : e;
|
|
1654
|
+
}
|
|
1655
|
+
function cr(e, t, n) {
|
|
1656
|
+
if (t.has(e)) return !0;
|
|
1657
|
+
let r = e.match(/^([^.]+)\.(\d+)\.([^.]+)$/);
|
|
1658
|
+
if (!r) return !1;
|
|
1659
|
+
let [, i, , a] = r;
|
|
1660
|
+
return n.get(i)?.sources.includes(a) ?? !1;
|
|
1661
|
+
}
|
|
1662
|
+
function lr(e, t, n) {
|
|
1663
|
+
let r = {}, i = [...or(e.global)];
|
|
1664
|
+
for (let [a, o] of Object.entries(e.fields ?? {})) cr(a, t, n) ? r[a] = o : i.push(sr(o));
|
|
1665
|
+
return {
|
|
1666
|
+
fieldErrors: r,
|
|
1667
|
+
globalErrors: i
|
|
1668
|
+
};
|
|
1669
|
+
}
|
|
1670
|
+
function ur(e, t) {
|
|
1671
|
+
for (let [n, r] of Object.entries(t)) e.setError(n, {
|
|
1672
|
+
type: "server",
|
|
1673
|
+
message: sr(r)
|
|
1674
|
+
});
|
|
1675
|
+
}
|
|
1676
|
+
function dr(e) {
|
|
1677
|
+
let t = Wt(e);
|
|
1678
|
+
if (t && !/application\/json/i.test(t)) return `non-JSON response (Content-Type: ${t})`;
|
|
1229
1679
|
}
|
|
1230
|
-
function
|
|
1231
|
-
let a =
|
|
1232
|
-
if (
|
|
1233
|
-
|
|
1234
|
-
|
|
1680
|
+
async function fr(e, t, n, r, i) {
|
|
1681
|
+
let a = await qt(n);
|
|
1682
|
+
if (a != null) {
|
|
1683
|
+
let n = e.parseFormError?.({ body: a }, r);
|
|
1684
|
+
if (n) {
|
|
1685
|
+
let e = new Set(i.payloadFields), r = /* @__PURE__ */ new Map();
|
|
1686
|
+
for (let e of i.inlineRegistry) r.set(e.field, e);
|
|
1687
|
+
let { fieldErrors: a, globalErrors: o } = lr(n, e, r);
|
|
1688
|
+
if (Object.keys(a).length || o.length) return ur(t, a), {
|
|
1689
|
+
handled: !0,
|
|
1690
|
+
globalErrors: o
|
|
1691
|
+
};
|
|
1692
|
+
}
|
|
1693
|
+
return {
|
|
1694
|
+
handled: !0,
|
|
1695
|
+
globalErrors: [Ht(a)]
|
|
1696
|
+
};
|
|
1697
|
+
}
|
|
1698
|
+
return Ut(n) == null ? {
|
|
1699
|
+
handled: !1,
|
|
1700
|
+
globalErrors: []
|
|
1701
|
+
} : {
|
|
1702
|
+
handled: !0,
|
|
1703
|
+
globalErrors: [Ht(null, { hint: dr(n) })]
|
|
1704
|
+
};
|
|
1235
1705
|
}
|
|
1236
1706
|
//#endregion
|
|
1237
1707
|
//#region src/crud/utils/useAbortableEffect.ts
|
|
1238
|
-
function
|
|
1239
|
-
|
|
1708
|
+
function pr(e, t) {
|
|
1709
|
+
s(() => {
|
|
1240
1710
|
let t = new AbortController();
|
|
1241
1711
|
return e(t.signal), () => t.abort();
|
|
1242
1712
|
}, t);
|
|
1243
1713
|
}
|
|
1244
1714
|
//#endregion
|
|
1245
|
-
//#region src/crud/
|
|
1246
|
-
function
|
|
1247
|
-
let
|
|
1248
|
-
if (
|
|
1249
|
-
|
|
1715
|
+
//#region src/crud/utils/useFormRecord.ts
|
|
1716
|
+
function mr({ dp: e, resource: t, id: n, isNew: r, form: i, message: o, defaultValues: s, enabled: c = !0 }) {
|
|
1717
|
+
let [l, d] = u(!r), [f, p] = u(0), m = a(async (a) => {
|
|
1718
|
+
if (r || !n) {
|
|
1719
|
+
s ? i.reset({ ...s }) : i.reset({}), d(!1);
|
|
1250
1720
|
return;
|
|
1251
1721
|
}
|
|
1252
|
-
|
|
1722
|
+
d(!0);
|
|
1253
1723
|
try {
|
|
1254
|
-
let r = await
|
|
1255
|
-
if (
|
|
1256
|
-
|
|
1724
|
+
let r = await e.getOne(t, n, { signal: a });
|
|
1725
|
+
if (a?.aborted) return;
|
|
1726
|
+
i.reset(r.data), p((e) => e + 1);
|
|
1257
1727
|
} catch (e) {
|
|
1258
|
-
|
|
1728
|
+
Ft(e) || o.error(e instanceof Error ? e.message : "Load failed");
|
|
1259
1729
|
} finally {
|
|
1260
|
-
|
|
1730
|
+
a?.aborted || d(!1);
|
|
1261
1731
|
}
|
|
1262
1732
|
}, [
|
|
1263
|
-
u,
|
|
1264
1733
|
e,
|
|
1265
1734
|
t,
|
|
1735
|
+
n,
|
|
1736
|
+
r,
|
|
1737
|
+
i,
|
|
1266
1738
|
o,
|
|
1267
|
-
|
|
1268
|
-
d
|
|
1739
|
+
s
|
|
1269
1740
|
]);
|
|
1270
|
-
|
|
1271
|
-
if (
|
|
1272
|
-
}, [
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1741
|
+
return pr((e) => {
|
|
1742
|
+
if (c) return m(e);
|
|
1743
|
+
}, [c, m]), {
|
|
1744
|
+
loading: l,
|
|
1745
|
+
formVersion: f
|
|
1746
|
+
};
|
|
1747
|
+
}
|
|
1748
|
+
function hr({ dp: e, resource: t, id: n, isNew: r, form: i, message: o, payloadFieldsRef: s, inlineRegistryRef: c, setGlobalErrors: l, onSuccess: d }) {
|
|
1749
|
+
let [f, p] = u(!1);
|
|
1750
|
+
return {
|
|
1751
|
+
onSubmit: a(async (a) => {
|
|
1752
|
+
l([]), p(!0);
|
|
1753
|
+
try {
|
|
1754
|
+
let i = ar(a, Array.from(s.current), c.current.values()), l;
|
|
1755
|
+
if (r) l = (await e.create(t, i)).data, o.success("Created");
|
|
1756
|
+
else if (n) l = (await e.update(t, {
|
|
1757
|
+
id: n,
|
|
1758
|
+
data: i
|
|
1759
|
+
})).data, o.success("Updated");
|
|
1760
|
+
else return;
|
|
1761
|
+
d?.(l);
|
|
1762
|
+
} catch (n) {
|
|
1763
|
+
let { handled: a, globalErrors: u } = await fr(e, i, n, {
|
|
1764
|
+
resource: t,
|
|
1765
|
+
mutation: r ? "create" : "update",
|
|
1766
|
+
inlineFieldPaths: Array.from(c.current.keys())
|
|
1767
|
+
}, {
|
|
1768
|
+
payloadFields: s.current,
|
|
1769
|
+
inlineRegistry: c.current.values()
|
|
1770
|
+
});
|
|
1771
|
+
a ? (l(u), o.error(u[0] ?? "Save failed.")) : (l([]), o.error(n instanceof Error ? n.message : "Save failed"));
|
|
1772
|
+
} finally {
|
|
1773
|
+
p(!1);
|
|
1774
|
+
}
|
|
1775
|
+
}, [
|
|
1776
|
+
e,
|
|
1777
|
+
t,
|
|
1778
|
+
n,
|
|
1779
|
+
r,
|
|
1780
|
+
i,
|
|
1781
|
+
o,
|
|
1782
|
+
s,
|
|
1783
|
+
c,
|
|
1784
|
+
l,
|
|
1785
|
+
d
|
|
1786
|
+
]),
|
|
1787
|
+
saving: f
|
|
1788
|
+
};
|
|
1789
|
+
}
|
|
1790
|
+
//#endregion
|
|
1791
|
+
//#region src/crud/ResourceRecordForm.tsx
|
|
1792
|
+
function gr({ resource: e, id: t, children: r, defaultValues: i, enabled: a = !0, canSave: o = !0, onCancel: s, cancelHref: c, onSuccess: f, loadingMode: p = "overlay" }) {
|
|
1793
|
+
let m = t === "new" || !t, h = m ? void 0 : t, g = jt(), { message: _ } = x.useApp(), v = l(/* @__PURE__ */ new Set()), y = l(/* @__PURE__ */ new Map()), [b, S] = u([]), w = Te({ defaultValues: i }), { loading: T, formVersion: E } = mr({
|
|
1794
|
+
dp: g,
|
|
1795
|
+
resource: e,
|
|
1796
|
+
id: h,
|
|
1797
|
+
isNew: m,
|
|
1798
|
+
form: w,
|
|
1799
|
+
message: _,
|
|
1800
|
+
defaultValues: i,
|
|
1801
|
+
enabled: a
|
|
1802
|
+
}), { onSubmit: D, saving: O } = hr({
|
|
1803
|
+
dp: g,
|
|
1804
|
+
resource: e,
|
|
1805
|
+
id: h,
|
|
1806
|
+
isNew: m,
|
|
1807
|
+
form: w,
|
|
1808
|
+
message: _,
|
|
1809
|
+
payloadFieldsRef: v,
|
|
1810
|
+
inlineRegistryRef: y,
|
|
1811
|
+
setGlobalErrors: S,
|
|
1812
|
+
onSuccess: f
|
|
1813
|
+
}), k = T || O, j = () => {
|
|
1814
|
+
w.handleSubmit(D, () => {
|
|
1815
|
+
_.warning("Please fix the errors below.");
|
|
1816
|
+
})();
|
|
1817
|
+
}, M = /* @__PURE__ */ K(C, {
|
|
1818
|
+
disabled: k,
|
|
1819
|
+
onClick: c ? void 0 : s,
|
|
1820
|
+
children: "Cancel"
|
|
1821
|
+
}), N = /* @__PURE__ */ K(Nn, {
|
|
1822
|
+
resource: e,
|
|
1823
|
+
isNew: m,
|
|
1824
|
+
children: /* @__PURE__ */ K(zn, {
|
|
1825
|
+
fieldsRef: v,
|
|
1826
|
+
children: /* @__PURE__ */ K(Wn, {
|
|
1827
|
+
registryRef: y,
|
|
1828
|
+
children: /* @__PURE__ */ q("div", {
|
|
1829
|
+
style: { position: "relative" },
|
|
1830
|
+
children: [k && p === "overlay" ? /* @__PURE__ */ K("div", {
|
|
1831
|
+
style: {
|
|
1832
|
+
position: "absolute",
|
|
1833
|
+
inset: 0,
|
|
1834
|
+
display: "flex",
|
|
1835
|
+
alignItems: "center",
|
|
1836
|
+
justifyContent: "center",
|
|
1837
|
+
zIndex: 1
|
|
1838
|
+
},
|
|
1839
|
+
children: /* @__PURE__ */ K(re, {})
|
|
1840
|
+
}) : null, /* @__PURE__ */ n(Ce, {
|
|
1841
|
+
...w,
|
|
1842
|
+
key: E
|
|
1843
|
+
}, /* @__PURE__ */ q(A, {
|
|
1844
|
+
layout: "vertical",
|
|
1845
|
+
onFinish: j,
|
|
1846
|
+
style: p === "overlay" ? {
|
|
1847
|
+
opacity: k ? .4 : 1,
|
|
1848
|
+
pointerEvents: k ? "none" : void 0
|
|
1849
|
+
} : void 0,
|
|
1850
|
+
children: [
|
|
1851
|
+
/* @__PURE__ */ K(qn, { errors: b }),
|
|
1852
|
+
r,
|
|
1853
|
+
/* @__PURE__ */ K(A.Item, {
|
|
1854
|
+
style: {
|
|
1855
|
+
marginTop: 16,
|
|
1856
|
+
marginBottom: 0
|
|
1857
|
+
},
|
|
1858
|
+
children: /* @__PURE__ */ q(R, { children: [/* @__PURE__ */ K(C, {
|
|
1859
|
+
type: "primary",
|
|
1860
|
+
htmlType: "submit",
|
|
1861
|
+
loading: O,
|
|
1862
|
+
disabled: k || !o,
|
|
1863
|
+
children: "Save"
|
|
1864
|
+
}), c ? /* @__PURE__ */ K(d, {
|
|
1865
|
+
to: c,
|
|
1866
|
+
children: M
|
|
1867
|
+
}) : M] })
|
|
1868
|
+
})
|
|
1869
|
+
]
|
|
1870
|
+
}))]
|
|
1871
|
+
})
|
|
1872
|
+
})
|
|
1873
|
+
})
|
|
1874
|
+
});
|
|
1875
|
+
return T && !O && p === "replace" ? /* @__PURE__ */ K(re, {}) : N;
|
|
1876
|
+
}
|
|
1877
|
+
//#endregion
|
|
1878
|
+
//#region src/crud/ResourceFormModal.tsx
|
|
1879
|
+
function _r({ resource: e, editId: t, onClose: n, children: r, title: i, permissions: a, defaultValues: o, width: s = 560, onSuccess: c }) {
|
|
1880
|
+
let l = t === "new", u = t != null, d = Y(), f = i ?? (l ? `New ${e}` : `Edit ${e}`), p = a ? X(d, a, l ? "add" : "change") : !0;
|
|
1881
|
+
return /* @__PURE__ */ K(te, {
|
|
1882
|
+
open: u,
|
|
1883
|
+
title: f,
|
|
1884
|
+
onCancel: n,
|
|
1885
|
+
footer: null,
|
|
1886
|
+
destroyOnHidden: !0,
|
|
1887
|
+
width: s,
|
|
1888
|
+
maskClosable: !1,
|
|
1889
|
+
children: /* @__PURE__ */ K(x, { children: /* @__PURE__ */ K(gr, {
|
|
1890
|
+
resource: e,
|
|
1891
|
+
id: t ?? void 0,
|
|
1892
|
+
enabled: u,
|
|
1893
|
+
loadingMode: "overlay",
|
|
1894
|
+
defaultValues: o,
|
|
1895
|
+
canSave: p,
|
|
1896
|
+
onCancel: n,
|
|
1897
|
+
onSuccess: (e) => {
|
|
1898
|
+
c?.(e), n();
|
|
1899
|
+
},
|
|
1900
|
+
children: r
|
|
1901
|
+
}) })
|
|
1323
1902
|
});
|
|
1324
1903
|
}
|
|
1325
1904
|
//#endregion
|
|
1326
1905
|
//#region src/crud/ListActionsBar.tsx
|
|
1327
|
-
function
|
|
1328
|
-
let [p, m] =
|
|
1906
|
+
function vr({ selectedCount: e, total: t, allPageSelected: n, allMatchingSelected: r, onSelectAllMatching: i, onClearSelection: o, actions: s, onExecute: l, selectedIds: d, running: f = !1 }) {
|
|
1907
|
+
let [p, m] = u(), h = c(() => s.map((e) => ({
|
|
1329
1908
|
value: e.key,
|
|
1330
1909
|
label: e.label
|
|
1331
|
-
})), [
|
|
1332
|
-
let t =
|
|
1333
|
-
!t || e === 0 || (await
|
|
1910
|
+
})), [s]), g = a(async () => {
|
|
1911
|
+
let t = s.find((e) => e.key === p);
|
|
1912
|
+
!t || e === 0 || (await l(t, d), m(void 0));
|
|
1334
1913
|
}, [
|
|
1335
|
-
|
|
1914
|
+
s,
|
|
1336
1915
|
p,
|
|
1337
|
-
|
|
1916
|
+
l,
|
|
1338
1917
|
e,
|
|
1339
1918
|
d
|
|
1340
1919
|
]), _ = n && !r && t > e;
|
|
1341
|
-
return /* @__PURE__ */
|
|
1920
|
+
return /* @__PURE__ */ q(R, {
|
|
1342
1921
|
wrap: !0,
|
|
1343
1922
|
style: {
|
|
1344
1923
|
marginBottom: 16,
|
|
@@ -1346,7 +1925,7 @@ function xn({ selectedCount: e, total: t, allPageSelected: n, allMatchingSelecte
|
|
|
1346
1925
|
},
|
|
1347
1926
|
align: "center",
|
|
1348
1927
|
children: [
|
|
1349
|
-
/* @__PURE__ */
|
|
1928
|
+
/* @__PURE__ */ q(U.Text, {
|
|
1350
1929
|
type: "secondary",
|
|
1351
1930
|
children: [
|
|
1352
1931
|
e,
|
|
@@ -1355,20 +1934,20 @@ function xn({ selectedCount: e, total: t, allPageSelected: n, allMatchingSelecte
|
|
|
1355
1934
|
" selected"
|
|
1356
1935
|
]
|
|
1357
1936
|
}),
|
|
1358
|
-
e > 0 ? /* @__PURE__ */
|
|
1937
|
+
e > 0 ? /* @__PURE__ */ K(C, {
|
|
1359
1938
|
type: "link",
|
|
1360
1939
|
size: "small",
|
|
1361
1940
|
onClick: o,
|
|
1362
1941
|
style: { padding: 0 },
|
|
1363
1942
|
children: "Clear selection"
|
|
1364
1943
|
}) : null,
|
|
1365
|
-
_ ? /* @__PURE__ */
|
|
1944
|
+
_ ? /* @__PURE__ */ q(G, { children: [/* @__PURE__ */ K(U.Text, {
|
|
1366
1945
|
type: "secondary",
|
|
1367
1946
|
children: "·"
|
|
1368
|
-
}), /* @__PURE__ */
|
|
1947
|
+
}), /* @__PURE__ */ q(C, {
|
|
1369
1948
|
type: "link",
|
|
1370
1949
|
size: "small",
|
|
1371
|
-
onClick:
|
|
1950
|
+
onClick: i,
|
|
1372
1951
|
style: { padding: 0 },
|
|
1373
1952
|
children: [
|
|
1374
1953
|
"Select all ",
|
|
@@ -1376,10 +1955,10 @@ function xn({ selectedCount: e, total: t, allPageSelected: n, allMatchingSelecte
|
|
|
1376
1955
|
" items matching filter"
|
|
1377
1956
|
]
|
|
1378
1957
|
})] }) : null,
|
|
1379
|
-
r && t > 0 ? /* @__PURE__ */
|
|
1958
|
+
r && t > 0 ? /* @__PURE__ */ q(G, { children: [/* @__PURE__ */ K(U.Text, {
|
|
1380
1959
|
type: "secondary",
|
|
1381
1960
|
children: "·"
|
|
1382
|
-
}), /* @__PURE__ */
|
|
1961
|
+
}), /* @__PURE__ */ q(U.Text, {
|
|
1383
1962
|
type: "success",
|
|
1384
1963
|
children: [
|
|
1385
1964
|
"All ",
|
|
@@ -1387,7 +1966,7 @@ function xn({ selectedCount: e, total: t, allPageSelected: n, allMatchingSelecte
|
|
|
1387
1966
|
" items selected"
|
|
1388
1967
|
]
|
|
1389
1968
|
})] }) : null,
|
|
1390
|
-
/* @__PURE__ */
|
|
1969
|
+
/* @__PURE__ */ K(L, {
|
|
1391
1970
|
placeholder: "Action",
|
|
1392
1971
|
style: { minWidth: 200 },
|
|
1393
1972
|
options: h,
|
|
@@ -1396,7 +1975,7 @@ function xn({ selectedCount: e, total: t, allPageSelected: n, allMatchingSelecte
|
|
|
1396
1975
|
disabled: e === 0 || f,
|
|
1397
1976
|
allowClear: !0
|
|
1398
1977
|
}),
|
|
1399
|
-
/* @__PURE__ */
|
|
1978
|
+
/* @__PURE__ */ K(C, {
|
|
1400
1979
|
type: "primary",
|
|
1401
1980
|
onClick: () => void g(),
|
|
1402
1981
|
disabled: !p || e === 0 || f,
|
|
@@ -1408,14 +1987,14 @@ function xn({ selectedCount: e, total: t, allPageSelected: n, allMatchingSelecte
|
|
|
1408
1987
|
}
|
|
1409
1988
|
//#endregion
|
|
1410
1989
|
//#region src/crud/types.ts
|
|
1411
|
-
var
|
|
1990
|
+
var yr = new Set([
|
|
1412
1991
|
"page",
|
|
1413
1992
|
"perPage",
|
|
1414
1993
|
"sort",
|
|
1415
1994
|
"create",
|
|
1416
1995
|
"edit"
|
|
1417
|
-
]),
|
|
1418
|
-
function
|
|
1996
|
+
]), br = 1, xr = 10;
|
|
1997
|
+
function Sr(e) {
|
|
1419
1998
|
if (e.includes(",")) {
|
|
1420
1999
|
let t = e.split(",").map((e) => e.trim()), n = t.map(Number);
|
|
1421
2000
|
return n.every((e) => Number.isFinite(e)) ? n : t;
|
|
@@ -1423,16 +2002,16 @@ function Tn(e) {
|
|
|
1423
2002
|
let t = Number(e);
|
|
1424
2003
|
return e !== "" && Number.isFinite(t) && String(t) === e ? t : e === "true" ? !0 : e === "false" ? !1 : e;
|
|
1425
2004
|
}
|
|
1426
|
-
function
|
|
2005
|
+
function Cr(e) {
|
|
1427
2006
|
return e == null || e === "" ? null : Array.isArray(e) ? e.length === 0 ? null : e.map(String).join(",") : String(e);
|
|
1428
2007
|
}
|
|
1429
|
-
function
|
|
1430
|
-
let [t, n] =
|
|
1431
|
-
let n = t.get("page"), r = t.get("perPage"), i = n ? Math.max(1, Number(n) ||
|
|
2008
|
+
function wr(e) {
|
|
2009
|
+
let [t, n] = y(), r = c(() => {
|
|
2010
|
+
let n = t.get("page"), r = t.get("perPage"), i = n ? Math.max(1, Number(n) || br) : br, a = r ? Math.max(1, Number(r) || xr) : xr, o = t.getAll("sort"), s = o.length > 0 ? o.flatMap((e) => Sn(e)) : Sn(t.get("sort")), c = { ...e };
|
|
1432
2011
|
return t.forEach((e, n) => {
|
|
1433
|
-
if (
|
|
2012
|
+
if (yr.has(n)) return;
|
|
1434
2013
|
let r = c[n];
|
|
1435
|
-
r === void 0 ? t.getAll(n).length > 1 ? c[n] = t.getAll(n).map(
|
|
2014
|
+
r === void 0 ? t.getAll(n).length > 1 ? c[n] = t.getAll(n).map(Sr) : c[n] = Sr(e) : c[n] = [...Array.isArray(r) ? r : [r], Sr(e)];
|
|
1436
2015
|
}), {
|
|
1437
2016
|
page: i,
|
|
1438
2017
|
perPage: a,
|
|
@@ -1441,33 +2020,33 @@ function Dn(e) {
|
|
|
1441
2020
|
createModal: t.has("create"),
|
|
1442
2021
|
editId: t.get("edit")
|
|
1443
2022
|
};
|
|
1444
|
-
}, [t, e]),
|
|
2023
|
+
}, [t, e]), i = a((e) => {
|
|
1445
2024
|
n((t) => {
|
|
1446
2025
|
let n = new URLSearchParams(t);
|
|
1447
2026
|
return e(n), n;
|
|
1448
2027
|
}, { replace: !0 });
|
|
1449
2028
|
}, [n]);
|
|
1450
|
-
return [r,
|
|
2029
|
+
return [r, c(() => ({
|
|
1451
2030
|
setPage: (e) => {
|
|
1452
|
-
|
|
2031
|
+
i((t) => {
|
|
1453
2032
|
e <= 1 ? t.delete("page") : t.set("page", String(e));
|
|
1454
2033
|
});
|
|
1455
2034
|
},
|
|
1456
2035
|
setPerPage: (e) => {
|
|
1457
|
-
|
|
1458
|
-
e ===
|
|
2036
|
+
i((t) => {
|
|
2037
|
+
e === xr ? t.delete("perPage") : t.set("perPage", String(e)), t.delete("page");
|
|
1459
2038
|
});
|
|
1460
2039
|
},
|
|
1461
2040
|
setSort: (e) => {
|
|
1462
|
-
|
|
2041
|
+
i((t) => {
|
|
1463
2042
|
t.delete("sort");
|
|
1464
|
-
let n =
|
|
2043
|
+
let n = Cn(e);
|
|
1465
2044
|
n && t.set("sort", n);
|
|
1466
2045
|
});
|
|
1467
2046
|
},
|
|
1468
2047
|
toggleSort: (e) => {
|
|
1469
|
-
|
|
1470
|
-
let n = t.getAll("sort").flatMap((e) =>
|
|
2048
|
+
i((t) => {
|
|
2049
|
+
let n = t.getAll("sort").flatMap((e) => Sn(e)), r = n.findIndex((t) => t.field === e), i;
|
|
1471
2050
|
i = r < 0 ? [...n, {
|
|
1472
2051
|
field: e,
|
|
1473
2052
|
order: "ASC"
|
|
@@ -1475,54 +2054,54 @@ function Dn(e) {
|
|
|
1475
2054
|
...e,
|
|
1476
2055
|
order: "DESC"
|
|
1477
2056
|
} : e) : n.filter((e, t) => t !== r), t.delete("sort");
|
|
1478
|
-
let a =
|
|
2057
|
+
let a = Cn(i);
|
|
1479
2058
|
a && t.set("sort", a);
|
|
1480
2059
|
});
|
|
1481
2060
|
},
|
|
1482
2061
|
setFilter: (e, t) => {
|
|
1483
|
-
|
|
2062
|
+
i((n) => {
|
|
1484
2063
|
n.delete(e);
|
|
1485
|
-
let r =
|
|
2064
|
+
let r = Cr(t);
|
|
1486
2065
|
r != null && n.set(e, r), n.delete("page");
|
|
1487
2066
|
});
|
|
1488
2067
|
},
|
|
1489
2068
|
setFilters: (e) => {
|
|
1490
|
-
|
|
1491
|
-
for (let e of [...t.keys()])
|
|
2069
|
+
i((t) => {
|
|
2070
|
+
for (let e of [...t.keys()]) yr.has(e) || t.delete(e);
|
|
1492
2071
|
for (let [n, r] of Object.entries(e)) {
|
|
1493
|
-
let e =
|
|
2072
|
+
let e = Cr(r);
|
|
1494
2073
|
e != null && t.set(n, e);
|
|
1495
2074
|
}
|
|
1496
2075
|
t.delete("page");
|
|
1497
2076
|
});
|
|
1498
2077
|
},
|
|
1499
2078
|
openCreateModal: () => {
|
|
1500
|
-
|
|
2079
|
+
i((e) => {
|
|
1501
2080
|
e.set("create", "1"), e.delete("edit");
|
|
1502
2081
|
});
|
|
1503
2082
|
},
|
|
1504
2083
|
openEditModal: (e) => {
|
|
1505
|
-
|
|
2084
|
+
i((t) => {
|
|
1506
2085
|
t.set("edit", String(e)), t.delete("create");
|
|
1507
2086
|
});
|
|
1508
2087
|
},
|
|
1509
2088
|
closeModal: () => {
|
|
1510
|
-
|
|
2089
|
+
i((e) => {
|
|
1511
2090
|
e.delete("create"), e.delete("edit");
|
|
1512
2091
|
});
|
|
1513
2092
|
}
|
|
1514
|
-
}), [
|
|
2093
|
+
}), [i])];
|
|
1515
2094
|
}
|
|
1516
2095
|
//#endregion
|
|
1517
2096
|
//#region src/crud/ResourceList.tsx
|
|
1518
|
-
var
|
|
1519
|
-
function
|
|
1520
|
-
return
|
|
1521
|
-
}
|
|
1522
|
-
function
|
|
1523
|
-
let
|
|
1524
|
-
|
|
1525
|
-
}, []),
|
|
2097
|
+
var Tr = t(null);
|
|
2098
|
+
function Er() {
|
|
2099
|
+
return o(Tr);
|
|
2100
|
+
}
|
|
2101
|
+
function Dr({ resource: e, title: t, pathPrefix: n, newPath: r, editMode: i = "page", formChildren: o, actions: s, rowActions: l, headerExtra: f, bulkActions: p, bulkDelete: m = !0, bulkActionsEnabled: h = !0, permissions: g, queryState: _, queryActions: v }) {
|
|
2102
|
+
let y = jt(), b = Y(), { message: S, modal: T } = x.useApp(), { columns: E, sortOrders: D, sortPriorities: O } = Dn(), [k, A] = u(!1), [j, M] = u([]), [N, P] = u(0), [F, ee] = u(() => /* @__PURE__ */ new Set()), [te, I] = u(!1), ne = r ?? `${n}/new`, L = X(b, g, "add"), re = X(b, g, "change"), z = X(b, g, "delete"), B = re && (i === "page" || i === "both") && s?.edit !== !1, V = re && (i === "modal" || i === "both") && s?.quickEdit !== !1, H = z && s?.delete !== !1, W = B || V || H || l, ae = a(() => {
|
|
2103
|
+
ee(/* @__PURE__ */ new Set());
|
|
2104
|
+
}, []), ce = c(() => {
|
|
1526
2105
|
if (!h) return [];
|
|
1527
2106
|
let t = [];
|
|
1528
2107
|
return m && z && t.push({
|
|
@@ -1530,7 +2109,7 @@ function An({ resource: e, title: t, pathPrefix: n, newPath: r, editMode: a = "p
|
|
|
1530
2109
|
label: "Delete selected",
|
|
1531
2110
|
confirm: (e) => `Delete ${e.length} selected item(s)? This cannot be undone.`,
|
|
1532
2111
|
execute: async (t, { reload: n, clearSelection: r }) => {
|
|
1533
|
-
await Promise.all(t.map((t) =>
|
|
2112
|
+
await Promise.all(t.map((t) => y.delete(e, t))), r(), n(), S.success(`Deleted ${t.length} item(s)`);
|
|
1534
2113
|
}
|
|
1535
2114
|
}), [...t, ...p ?? []];
|
|
1536
2115
|
}, [
|
|
@@ -1538,43 +2117,43 @@ function An({ resource: e, title: t, pathPrefix: n, newPath: r, editMode: a = "p
|
|
|
1538
2117
|
m,
|
|
1539
2118
|
z,
|
|
1540
2119
|
p,
|
|
1541
|
-
|
|
2120
|
+
y,
|
|
1542
2121
|
e,
|
|
1543
|
-
|
|
1544
|
-
]),
|
|
1545
|
-
|
|
1546
|
-
let n = new Set(t), r =
|
|
2122
|
+
S
|
|
2123
|
+
]), le = ce.length > 0, ue = F.size, de = j.length > 0 && j.every((e) => F.has(e.id)), fe = N > 0 && ue >= N, pe = c(() => j.filter((e) => F.has(e.id)).map((e) => e.id), [j, F]), me = a((e) => {
|
|
2124
|
+
ee((t) => {
|
|
2125
|
+
let n = new Set(t), r = j.map((e) => e.id);
|
|
1547
2126
|
for (let t of r) e.includes(t) || n.delete(t);
|
|
1548
2127
|
for (let t of e) n.add(t);
|
|
1549
2128
|
return n;
|
|
1550
2129
|
});
|
|
1551
|
-
}, [
|
|
1552
|
-
if (!(
|
|
1553
|
-
|
|
2130
|
+
}, [j]), he = a(async () => {
|
|
2131
|
+
if (!(N <= 0)) {
|
|
2132
|
+
I(!0);
|
|
1554
2133
|
try {
|
|
1555
|
-
let t = _.sort.length === 0 ? void 0 : _.sort.length === 1 ? _.sort[0] : _.sort, n = await
|
|
2134
|
+
let t = _.sort.length === 0 ? void 0 : _.sort.length === 1 ? _.sort[0] : _.sort, n = await y.getList(e, {
|
|
1556
2135
|
pagination: {
|
|
1557
2136
|
page: 1,
|
|
1558
|
-
perPage:
|
|
2137
|
+
perPage: N
|
|
1559
2138
|
},
|
|
1560
2139
|
sort: t,
|
|
1561
2140
|
filter: _.filter
|
|
1562
2141
|
});
|
|
1563
|
-
|
|
2142
|
+
ee(new Set(n.data.map((e) => e.id)));
|
|
1564
2143
|
} catch (e) {
|
|
1565
|
-
|
|
2144
|
+
S.error(e instanceof Error ? e.message : "Load failed");
|
|
1566
2145
|
} finally {
|
|
1567
|
-
|
|
2146
|
+
I(!1);
|
|
1568
2147
|
}
|
|
1569
2148
|
}
|
|
1570
2149
|
}, [
|
|
1571
|
-
|
|
2150
|
+
y,
|
|
1572
2151
|
e,
|
|
1573
|
-
|
|
2152
|
+
N,
|
|
1574
2153
|
_.sort,
|
|
1575
2154
|
_.filter,
|
|
1576
|
-
|
|
1577
|
-
]),
|
|
2155
|
+
S
|
|
2156
|
+
]), ge = a((e) => {
|
|
1578
2157
|
let t = (e) => {
|
|
1579
2158
|
let t = e?.columnKey ?? e?.field;
|
|
1580
2159
|
return t == null ? null : String(Array.isArray(t) ? t[0] : t);
|
|
@@ -1595,7 +2174,7 @@ function An({ resource: e, title: t, pathPrefix: n, newPath: r, editMode: a = "p
|
|
|
1595
2174
|
return;
|
|
1596
2175
|
}
|
|
1597
2176
|
!e?.order && _.sort.length > 0 && v.setSort([]);
|
|
1598
|
-
}, [v, _.sort.length]),
|
|
2177
|
+
}, [v, _.sort.length]), _e = c(() => {
|
|
1599
2178
|
let e = _.sort.length === 0 ? void 0 : _.sort.length === 1 ? _.sort[0] : _.sort;
|
|
1600
2179
|
return {
|
|
1601
2180
|
pagination: {
|
|
@@ -1605,35 +2184,35 @@ function An({ resource: e, title: t, pathPrefix: n, newPath: r, editMode: a = "p
|
|
|
1605
2184
|
sort: e,
|
|
1606
2185
|
filter: _.filter
|
|
1607
2186
|
};
|
|
1608
|
-
}, [_]),
|
|
1609
|
-
|
|
2187
|
+
}, [_]), J = a(async (t) => {
|
|
2188
|
+
A(!0);
|
|
1610
2189
|
try {
|
|
1611
|
-
let n = await
|
|
1612
|
-
...
|
|
2190
|
+
let n = await y.getList(e, {
|
|
2191
|
+
..._e,
|
|
1613
2192
|
signal: t
|
|
1614
2193
|
});
|
|
1615
2194
|
if (t?.aborted) return;
|
|
1616
|
-
|
|
2195
|
+
M(n.data), P(n.total);
|
|
1617
2196
|
} catch (e) {
|
|
1618
|
-
|
|
2197
|
+
Ft(e) || S.error(e instanceof Error ? e.message : "Load failed");
|
|
1619
2198
|
} finally {
|
|
1620
|
-
t?.aborted ||
|
|
2199
|
+
t?.aborted || A(!1);
|
|
1621
2200
|
}
|
|
1622
2201
|
}, [
|
|
1623
|
-
|
|
2202
|
+
y,
|
|
1624
2203
|
e,
|
|
1625
|
-
|
|
1626
|
-
|
|
2204
|
+
_e,
|
|
2205
|
+
S
|
|
1627
2206
|
]);
|
|
1628
|
-
|
|
1629
|
-
let
|
|
1630
|
-
reload: () => void
|
|
1631
|
-
clearSelection:
|
|
1632
|
-
}), [
|
|
2207
|
+
pr((e) => J(e), [J]);
|
|
2208
|
+
let ve = c(() => ({
|
|
2209
|
+
reload: () => void J(),
|
|
2210
|
+
clearSelection: ae
|
|
2211
|
+
}), [J, ae]), ye = a(async (e, t) => {
|
|
1633
2212
|
if (e.confirm) {
|
|
1634
|
-
let n = typeof e.confirm == "function" ? await e.confirm(t,
|
|
2213
|
+
let n = typeof e.confirm == "function" ? await e.confirm(t, ve) : e.confirm;
|
|
1635
2214
|
if (n === !1 || !await new Promise((t) => {
|
|
1636
|
-
|
|
2215
|
+
T.confirm({
|
|
1637
2216
|
title: n,
|
|
1638
2217
|
okType: e.key === "__delete" ? "danger" : "primary",
|
|
1639
2218
|
onOk: () => t(!0),
|
|
@@ -1641,35 +2220,35 @@ function An({ resource: e, title: t, pathPrefix: n, newPath: r, editMode: a = "p
|
|
|
1641
2220
|
});
|
|
1642
2221
|
})) return;
|
|
1643
2222
|
}
|
|
1644
|
-
|
|
2223
|
+
I(!0);
|
|
1645
2224
|
try {
|
|
1646
|
-
await e.execute(t,
|
|
2225
|
+
await e.execute(t, ve);
|
|
1647
2226
|
} catch (e) {
|
|
1648
|
-
|
|
2227
|
+
S.error(e instanceof Error ? e.message : "Action failed");
|
|
1649
2228
|
} finally {
|
|
1650
|
-
|
|
2229
|
+
I(!1);
|
|
1651
2230
|
}
|
|
1652
2231
|
}, [
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
]),
|
|
2232
|
+
ve,
|
|
2233
|
+
T,
|
|
2234
|
+
S
|
|
2235
|
+
]), be = a(async (t) => {
|
|
1657
2236
|
if (z) try {
|
|
1658
|
-
await
|
|
2237
|
+
await y.delete(e, t.id), S.success("Deleted"), J();
|
|
1659
2238
|
} catch (e) {
|
|
1660
|
-
|
|
2239
|
+
S.error(e instanceof Error ? e.message : "Delete failed");
|
|
1661
2240
|
}
|
|
1662
2241
|
}, [
|
|
1663
2242
|
z,
|
|
1664
|
-
|
|
2243
|
+
y,
|
|
1665
2244
|
e,
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
]),
|
|
1669
|
-
let e =
|
|
2245
|
+
J,
|
|
2246
|
+
S
|
|
2247
|
+
]), xe = c(() => {
|
|
2248
|
+
let e = E.map((e) => {
|
|
1670
2249
|
let t = e.buildColumn();
|
|
1671
2250
|
if (e.sortable) {
|
|
1672
|
-
let n =
|
|
2251
|
+
let n = D.get(e.source), r = O.get(e.source), i = n === "ASC" ? "ascend" : n === "DESC" ? "descend" : void 0, a = i == null ? void 0 : /* @__PURE__ */ q("span", {
|
|
1673
2252
|
style: {
|
|
1674
2253
|
display: "inline-flex",
|
|
1675
2254
|
alignItems: "center",
|
|
@@ -1677,7 +2256,7 @@ function An({ resource: e, title: t, pathPrefix: n, newPath: r, editMode: a = "p
|
|
|
1677
2256
|
marginInlineStart: 4,
|
|
1678
2257
|
color: "var(--ant-color-primary)"
|
|
1679
2258
|
},
|
|
1680
|
-
children: [r == null ? null : /* @__PURE__ */
|
|
2259
|
+
children: [r == null ? null : /* @__PURE__ */ K("span", {
|
|
1681
2260
|
style: {
|
|
1682
2261
|
fontSize: 11,
|
|
1683
2262
|
fontWeight: 600,
|
|
@@ -1686,7 +2265,7 @@ function An({ resource: e, title: t, pathPrefix: n, newPath: r, editMode: a = "p
|
|
|
1686
2265
|
textAlign: "center"
|
|
1687
2266
|
},
|
|
1688
2267
|
children: r
|
|
1689
|
-
}),
|
|
2268
|
+
}), K(i === "ascend" ? se : oe, { style: { fontSize: 11 } })]
|
|
1690
2269
|
});
|
|
1691
2270
|
return {
|
|
1692
2271
|
...t,
|
|
@@ -1697,145 +2276,146 @@ function An({ resource: e, title: t, pathPrefix: n, newPath: r, editMode: a = "p
|
|
|
1697
2276
|
}
|
|
1698
2277
|
return t;
|
|
1699
2278
|
});
|
|
1700
|
-
if (!
|
|
2279
|
+
if (!W) return e;
|
|
1701
2280
|
let t = {
|
|
1702
|
-
reload: () => void
|
|
2281
|
+
reload: () => void J(),
|
|
1703
2282
|
openEditModal: v.openEditModal
|
|
1704
2283
|
}, r = {
|
|
1705
2284
|
title: "Actions",
|
|
1706
2285
|
key: "__actions",
|
|
1707
|
-
width:
|
|
1708
|
-
render: (e, r) => /* @__PURE__ */
|
|
2286
|
+
width: i === "both" ? 200 : 160,
|
|
2287
|
+
render: (e, r) => /* @__PURE__ */ q(R, {
|
|
1709
2288
|
size: "small",
|
|
1710
2289
|
wrap: !0,
|
|
1711
2290
|
children: [
|
|
1712
|
-
|
|
2291
|
+
B ? /* @__PURE__ */ K(d, {
|
|
1713
2292
|
to: `${n}/${String(r.id)}`,
|
|
1714
2293
|
children: "Edit"
|
|
1715
2294
|
}) : null,
|
|
1716
|
-
|
|
2295
|
+
V ? /* @__PURE__ */ K(C, {
|
|
1717
2296
|
type: "link",
|
|
1718
2297
|
size: "small",
|
|
1719
2298
|
style: { padding: 0 },
|
|
1720
2299
|
onClick: () => v.openEditModal(r.id),
|
|
1721
|
-
children:
|
|
2300
|
+
children: i === "both" ? "Quick edit" : "Edit"
|
|
1722
2301
|
}) : null,
|
|
1723
|
-
|
|
2302
|
+
H ? /* @__PURE__ */ K(C, {
|
|
1724
2303
|
type: "link",
|
|
1725
2304
|
danger: !0,
|
|
1726
2305
|
size: "small",
|
|
1727
|
-
onClick: () => void
|
|
2306
|
+
onClick: () => void be(r),
|
|
1728
2307
|
style: { padding: 0 },
|
|
1729
2308
|
children: "Delete"
|
|
1730
2309
|
}) : null,
|
|
1731
|
-
|
|
2310
|
+
l?.(r, t)
|
|
1732
2311
|
]
|
|
1733
2312
|
})
|
|
1734
2313
|
};
|
|
1735
2314
|
return [...e, r];
|
|
1736
2315
|
}, [
|
|
1737
|
-
|
|
1738
|
-
le,
|
|
1739
|
-
U,
|
|
2316
|
+
E,
|
|
1740
2317
|
W,
|
|
1741
|
-
|
|
1742
|
-
|
|
2318
|
+
B,
|
|
2319
|
+
V,
|
|
2320
|
+
H,
|
|
2321
|
+
i,
|
|
1743
2322
|
n,
|
|
1744
|
-
|
|
1745
|
-
E,
|
|
2323
|
+
be,
|
|
1746
2324
|
D,
|
|
2325
|
+
O,
|
|
1747
2326
|
v,
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
]),
|
|
1751
|
-
return /* @__PURE__ */
|
|
1752
|
-
title: /* @__PURE__ */
|
|
2327
|
+
l,
|
|
2328
|
+
J
|
|
2329
|
+
]), Se = o && (_.createModal || _.editId != null) && (i === "modal" || i === "both");
|
|
2330
|
+
return /* @__PURE__ */ q(G, { children: [/* @__PURE__ */ q(w, {
|
|
2331
|
+
title: /* @__PURE__ */ K(U.Title, {
|
|
1753
2332
|
level: 5,
|
|
1754
2333
|
style: { margin: 0 },
|
|
1755
2334
|
children: t
|
|
1756
2335
|
}),
|
|
1757
|
-
extra: f ||
|
|
2336
|
+
extra: f || L ? /* @__PURE__ */ q(R, { children: [f, L ? i === "modal" || i === "both" ? /* @__PURE__ */ q(G, { children: [i === "both" ? /* @__PURE__ */ K(d, {
|
|
1758
2337
|
to: ne,
|
|
1759
|
-
children: /* @__PURE__ */
|
|
1760
|
-
}) : null, /* @__PURE__ */
|
|
2338
|
+
children: /* @__PURE__ */ K(C, { children: "New page" })
|
|
2339
|
+
}) : null, /* @__PURE__ */ K(C, {
|
|
1761
2340
|
type: "primary",
|
|
1762
2341
|
onClick: () => v.openCreateModal(),
|
|
1763
2342
|
children: "New"
|
|
1764
|
-
})] }) : /* @__PURE__ */
|
|
2343
|
+
})] }) : /* @__PURE__ */ K(d, {
|
|
1765
2344
|
to: ne,
|
|
1766
|
-
children: /* @__PURE__ */
|
|
2345
|
+
children: /* @__PURE__ */ K(C, {
|
|
1767
2346
|
type: "primary",
|
|
1768
2347
|
children: "New"
|
|
1769
2348
|
})
|
|
1770
2349
|
}) : null] }) : null,
|
|
1771
|
-
children: [
|
|
1772
|
-
selectedCount:
|
|
1773
|
-
total:
|
|
1774
|
-
allPageSelected:
|
|
1775
|
-
allMatchingSelected:
|
|
1776
|
-
onSelectAllMatching: () => void
|
|
1777
|
-
onClearSelection:
|
|
1778
|
-
actions:
|
|
1779
|
-
onExecute:
|
|
1780
|
-
selectedIds: [...
|
|
1781
|
-
running:
|
|
1782
|
-
}) : null, /* @__PURE__ */
|
|
2350
|
+
children: [le ? /* @__PURE__ */ K(vr, {
|
|
2351
|
+
selectedCount: ue,
|
|
2352
|
+
total: N,
|
|
2353
|
+
allPageSelected: de,
|
|
2354
|
+
allMatchingSelected: fe,
|
|
2355
|
+
onSelectAllMatching: () => void he(),
|
|
2356
|
+
onClearSelection: ae,
|
|
2357
|
+
actions: ce,
|
|
2358
|
+
onExecute: ye,
|
|
2359
|
+
selectedIds: [...F],
|
|
2360
|
+
running: te || k
|
|
2361
|
+
}) : null, /* @__PURE__ */ K(ie, {
|
|
1783
2362
|
rowKey: "id",
|
|
1784
|
-
loading:
|
|
1785
|
-
columns:
|
|
1786
|
-
dataSource:
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
2363
|
+
loading: k,
|
|
2364
|
+
columns: xe,
|
|
2365
|
+
dataSource: j,
|
|
2366
|
+
scroll: { x: "max-content" },
|
|
2367
|
+
rowSelection: le ? {
|
|
2368
|
+
selectedRowKeys: pe,
|
|
2369
|
+
onChange: me,
|
|
1790
2370
|
preserveSelectedRowKeys: !0
|
|
1791
2371
|
} : void 0,
|
|
1792
2372
|
pagination: {
|
|
1793
2373
|
current: _.page,
|
|
1794
2374
|
pageSize: _.perPage,
|
|
1795
|
-
total:
|
|
2375
|
+
total: N,
|
|
1796
2376
|
showSizeChanger: !0,
|
|
1797
2377
|
onChange: (e, t) => {
|
|
1798
2378
|
v.setPage(e), t && v.setPerPage(t);
|
|
1799
2379
|
}
|
|
1800
2380
|
},
|
|
1801
2381
|
onChange: (e, t, n) => {
|
|
1802
|
-
|
|
2382
|
+
ge(n);
|
|
1803
2383
|
}
|
|
1804
2384
|
})]
|
|
1805
|
-
}),
|
|
2385
|
+
}), Se ? /* @__PURE__ */ K(_r, {
|
|
1806
2386
|
resource: e,
|
|
1807
2387
|
editId: _.createModal ? "new" : _.editId,
|
|
1808
2388
|
onClose: () => {
|
|
1809
|
-
v.closeModal(),
|
|
2389
|
+
v.closeModal(), J();
|
|
1810
2390
|
},
|
|
1811
2391
|
children: o
|
|
1812
2392
|
}) : null] });
|
|
1813
2393
|
}
|
|
1814
|
-
function
|
|
1815
|
-
let [v, y] =
|
|
1816
|
-
if (!
|
|
2394
|
+
function Or({ resource: e, title: t, pathPrefix: n, newPath: r, staticFilter: i, editMode: o = "page", syncQueryParams: s = !0, children: l, formChildren: u, actions: d, rowActions: f, headerExtra: p, bulkActions: m, bulkDelete: h, bulkActionsEnabled: g, permissions: _ }) {
|
|
2395
|
+
let [v, y] = wr(i), b = c(() => {
|
|
2396
|
+
if (!s) return i ?? {};
|
|
1817
2397
|
let e = {};
|
|
1818
|
-
for (let [t, n] of Object.entries(v.filter))
|
|
2398
|
+
for (let [t, n] of Object.entries(v.filter)) i && t in i || (e[t] = n);
|
|
1819
2399
|
return e;
|
|
1820
2400
|
}, [
|
|
1821
2401
|
v.filter,
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
]), x =
|
|
1825
|
-
|
|
1826
|
-
}, [
|
|
2402
|
+
i,
|
|
2403
|
+
s
|
|
2404
|
+
]), x = a((e, t) => {
|
|
2405
|
+
s && y.setFilter(e, t);
|
|
2406
|
+
}, [s, y]), S = c(() => ({
|
|
1827
2407
|
filterValues: b,
|
|
1828
2408
|
setFilterValue: x
|
|
1829
2409
|
}), [b, x]);
|
|
1830
|
-
return /* @__PURE__ */
|
|
2410
|
+
return /* @__PURE__ */ K(Tr.Provider, {
|
|
1831
2411
|
value: S,
|
|
1832
|
-
children: /* @__PURE__ */
|
|
2412
|
+
children: /* @__PURE__ */ K(kn, {
|
|
1833
2413
|
values: b,
|
|
1834
2414
|
setFilterValue: x,
|
|
1835
|
-
children: /* @__PURE__ */
|
|
2415
|
+
children: /* @__PURE__ */ q(En, {
|
|
1836
2416
|
toggleSort: y.toggleSort,
|
|
1837
2417
|
sort: v.sort,
|
|
1838
|
-
children: [l, /* @__PURE__ */
|
|
2418
|
+
children: [l, /* @__PURE__ */ K(Dr, {
|
|
1839
2419
|
resource: e,
|
|
1840
2420
|
title: t,
|
|
1841
2421
|
pathPrefix: n,
|
|
@@ -1858,16 +2438,16 @@ function jn({ resource: e, title: t, pathPrefix: n, newPath: r, staticFilter: a,
|
|
|
1858
2438
|
}
|
|
1859
2439
|
//#endregion
|
|
1860
2440
|
//#region src/crud/FilterBar.tsx
|
|
1861
|
-
function
|
|
1862
|
-
let e =
|
|
1863
|
-
return !e || e.filters.length === 0 ? null : /* @__PURE__ */
|
|
2441
|
+
function kr() {
|
|
2442
|
+
let e = An();
|
|
2443
|
+
return !e || e.filters.length === 0 ? null : /* @__PURE__ */ K(R, {
|
|
1864
2444
|
wrap: !0,
|
|
1865
2445
|
size: "middle",
|
|
1866
2446
|
style: { marginBottom: 16 },
|
|
1867
|
-
children: e.filters.map((t) => /* @__PURE__ */
|
|
2447
|
+
children: e.filters.map((t) => /* @__PURE__ */ q(R, {
|
|
1868
2448
|
orientation: "vertical",
|
|
1869
2449
|
size: 2,
|
|
1870
|
-
children: [t.label ? /* @__PURE__ */
|
|
2450
|
+
children: [t.label ? /* @__PURE__ */ K(U.Text, {
|
|
1871
2451
|
type: "secondary",
|
|
1872
2452
|
style: { fontSize: 12 },
|
|
1873
2453
|
children: t.label
|
|
@@ -1878,118 +2458,154 @@ function Mn() {
|
|
|
1878
2458
|
}, t.key))
|
|
1879
2459
|
});
|
|
1880
2460
|
}
|
|
1881
|
-
function
|
|
1882
|
-
return /* @__PURE__ */
|
|
2461
|
+
function Ar({ children: e }) {
|
|
2462
|
+
return /* @__PURE__ */ q(G, { children: [e, /* @__PURE__ */ K(kr, {})] });
|
|
1883
2463
|
}
|
|
1884
2464
|
//#endregion
|
|
1885
|
-
//#region src/crud/
|
|
1886
|
-
function
|
|
1887
|
-
|
|
2465
|
+
//#region src/crud/ResourceForm.tsx
|
|
2466
|
+
function jr({ resource: e, title: t, listPath: n, children: r, defaultValues: i, onSaved: a, stayOnPage: o, permissions: c }) {
|
|
2467
|
+
let { id: l } = v(), u = l === "new" || !l, f = Y(), p = _(), { token: m } = W.useToken();
|
|
2468
|
+
s(() => {
|
|
2469
|
+
c && (X(f, c, u ? "add" : "change") || p(n, { replace: !0 }));
|
|
2470
|
+
}, [
|
|
2471
|
+
c,
|
|
2472
|
+
u,
|
|
2473
|
+
f,
|
|
2474
|
+
p,
|
|
2475
|
+
n
|
|
2476
|
+
]);
|
|
2477
|
+
let h = c ? X(f, c, u ? "add" : "change") : !0;
|
|
2478
|
+
return /* @__PURE__ */ K(w, {
|
|
2479
|
+
title: /* @__PURE__ */ q(R, { children: [/* @__PURE__ */ q(d, {
|
|
2480
|
+
to: n,
|
|
2481
|
+
style: { color: m.colorText },
|
|
2482
|
+
children: [/* @__PURE__ */ K(ae, {}), " Back"]
|
|
2483
|
+
}), /* @__PURE__ */ K(U.Title, {
|
|
2484
|
+
level: 5,
|
|
2485
|
+
style: { margin: 0 },
|
|
2486
|
+
children: t
|
|
2487
|
+
})] }),
|
|
2488
|
+
children: /* @__PURE__ */ K(gr, {
|
|
2489
|
+
resource: e,
|
|
2490
|
+
id: l,
|
|
2491
|
+
defaultValues: i,
|
|
2492
|
+
canSave: h,
|
|
2493
|
+
cancelHref: n,
|
|
2494
|
+
onCancel: () => p(n),
|
|
2495
|
+
onSuccess: (e) => {
|
|
2496
|
+
a?.(e), o || p(n);
|
|
2497
|
+
},
|
|
2498
|
+
children: r
|
|
2499
|
+
})
|
|
2500
|
+
});
|
|
1888
2501
|
}
|
|
1889
2502
|
//#endregion
|
|
1890
|
-
//#region src/crud/utils/
|
|
1891
|
-
function
|
|
2503
|
+
//#region src/crud/utils/nestedFieldPath.ts
|
|
2504
|
+
function Mr(e, t, n) {
|
|
1892
2505
|
return `${e}.${t}.${n}`;
|
|
1893
2506
|
}
|
|
1894
2507
|
//#endregion
|
|
1895
2508
|
//#region src/crud/InlineFormSet.tsx
|
|
1896
|
-
function
|
|
2509
|
+
function Nr(e) {
|
|
1897
2510
|
let t = {};
|
|
1898
2511
|
for (let n of e) t[n] = void 0;
|
|
1899
2512
|
return t;
|
|
1900
2513
|
}
|
|
1901
|
-
function
|
|
1902
|
-
let { control: n } =
|
|
2514
|
+
function Pr(e, t) {
|
|
2515
|
+
let { control: n } = Ee(), { fields: r, append: i, remove: a } = we({
|
|
1903
2516
|
control: n,
|
|
1904
|
-
name: e
|
|
2517
|
+
name: e,
|
|
2518
|
+
keyName: "rowKey"
|
|
1905
2519
|
});
|
|
1906
2520
|
return {
|
|
1907
2521
|
fields: r,
|
|
1908
2522
|
remove: a,
|
|
1909
|
-
appendEmpty: () => i(
|
|
2523
|
+
appendEmpty: () => i(Nr(t))
|
|
1910
2524
|
};
|
|
1911
2525
|
}
|
|
1912
|
-
function
|
|
1913
|
-
let
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
2526
|
+
function Fr({ field: e, label: t, payloadKey: n, transformRows: r, columns: i }) {
|
|
2527
|
+
let a = c(() => i.map((e) => e.source), [i]), { fields: o, remove: s, appendEmpty: l } = Pr(e, a);
|
|
2528
|
+
Vn(e), Kn(e, a, n, r);
|
|
2529
|
+
let u = c(() => i.map((t) => ({
|
|
2530
|
+
title: t.label ?? t.source,
|
|
2531
|
+
key: t.source,
|
|
2532
|
+
width: t.width,
|
|
2533
|
+
onHeaderCell: () => t.minWidth == null ? {} : { style: { minWidth: t.minWidth } },
|
|
2534
|
+
onCell: () => t.minWidth == null ? {} : { style: { minWidth: t.minWidth } },
|
|
2535
|
+
render: (n, r, i) => t.cell({
|
|
2536
|
+
name: Mr(e, i, t.source),
|
|
2537
|
+
index: i,
|
|
2538
|
+
field: e
|
|
1923
2539
|
})
|
|
1924
|
-
})), [
|
|
1925
|
-
return /* @__PURE__ */
|
|
2540
|
+
})), [i, e]);
|
|
2541
|
+
return /* @__PURE__ */ q("div", {
|
|
1926
2542
|
style: { marginTop: 24 },
|
|
1927
2543
|
children: [
|
|
1928
|
-
/* @__PURE__ */
|
|
2544
|
+
/* @__PURE__ */ K(U.Title, {
|
|
1929
2545
|
level: 5,
|
|
1930
2546
|
children: t ?? "Related items"
|
|
1931
2547
|
}),
|
|
1932
|
-
/* @__PURE__ */
|
|
2548
|
+
/* @__PURE__ */ K(ie, {
|
|
1933
2549
|
size: "small",
|
|
1934
2550
|
pagination: !1,
|
|
1935
2551
|
scroll: { x: "max-content" },
|
|
1936
|
-
dataSource:
|
|
2552
|
+
dataSource: o.map((e) => ({
|
|
1937
2553
|
...e,
|
|
1938
|
-
key: e.
|
|
2554
|
+
key: e.rowKey
|
|
1939
2555
|
})),
|
|
1940
|
-
columns: [...
|
|
2556
|
+
columns: [...u, {
|
|
1941
2557
|
title: "",
|
|
1942
2558
|
key: "__remove",
|
|
1943
2559
|
width: 80,
|
|
1944
|
-
render: (e, t, n) => /* @__PURE__ */
|
|
2560
|
+
render: (e, t, n) => /* @__PURE__ */ K(C, {
|
|
1945
2561
|
type: "link",
|
|
1946
2562
|
danger: !0,
|
|
1947
2563
|
size: "small",
|
|
1948
|
-
onClick: () =>
|
|
2564
|
+
onClick: () => s(n),
|
|
1949
2565
|
children: "Remove"
|
|
1950
2566
|
})
|
|
1951
2567
|
}]
|
|
1952
2568
|
}),
|
|
1953
|
-
/* @__PURE__ */
|
|
2569
|
+
/* @__PURE__ */ K(C, {
|
|
1954
2570
|
type: "dashed",
|
|
1955
2571
|
style: { marginTop: 8 },
|
|
1956
|
-
onClick:
|
|
2572
|
+
onClick: l,
|
|
1957
2573
|
children: "Add row"
|
|
1958
2574
|
})
|
|
1959
2575
|
]
|
|
1960
2576
|
});
|
|
1961
2577
|
}
|
|
1962
|
-
function
|
|
1963
|
-
let
|
|
1964
|
-
return /* @__PURE__ */
|
|
2578
|
+
function Ir({ field: e, label: t, payloadKey: n, transformRows: r, sources: i, renderRow: a }) {
|
|
2579
|
+
let { fields: o, remove: s, appendEmpty: c } = Pr(e, i);
|
|
2580
|
+
return Vn(e), Kn(e, i, n, r), /* @__PURE__ */ q("div", {
|
|
1965
2581
|
style: { marginTop: 24 },
|
|
1966
2582
|
children: [
|
|
1967
|
-
/* @__PURE__ */
|
|
2583
|
+
/* @__PURE__ */ K(U.Title, {
|
|
1968
2584
|
level: 5,
|
|
1969
2585
|
children: t ?? "Related items"
|
|
1970
2586
|
}),
|
|
1971
|
-
/* @__PURE__ */
|
|
2587
|
+
/* @__PURE__ */ K(R, {
|
|
1972
2588
|
orientation: "vertical",
|
|
1973
2589
|
size: "middle",
|
|
1974
2590
|
style: { width: "100%" },
|
|
1975
|
-
children: o.map((
|
|
2591
|
+
children: o.map((t, n) => /* @__PURE__ */ K(w, {
|
|
1976
2592
|
size: "small",
|
|
1977
|
-
title: `Item ${
|
|
1978
|
-
extra: /* @__PURE__ */
|
|
2593
|
+
title: `Item ${n + 1}`,
|
|
2594
|
+
extra: /* @__PURE__ */ K(C, {
|
|
1979
2595
|
type: "link",
|
|
1980
2596
|
danger: !0,
|
|
1981
2597
|
size: "small",
|
|
1982
|
-
onClick: () => s(
|
|
2598
|
+
onClick: () => s(n),
|
|
1983
2599
|
children: "Remove"
|
|
1984
2600
|
}),
|
|
1985
|
-
children:
|
|
1986
|
-
|
|
1987
|
-
index:
|
|
1988
|
-
name: (
|
|
2601
|
+
children: a({
|
|
2602
|
+
field: e,
|
|
2603
|
+
index: n,
|
|
2604
|
+
name: (t) => Mr(e, n, t)
|
|
1989
2605
|
})
|
|
1990
|
-
},
|
|
2606
|
+
}, t.rowKey))
|
|
1991
2607
|
}),
|
|
1992
|
-
/* @__PURE__ */
|
|
2608
|
+
/* @__PURE__ */ K(C, {
|
|
1993
2609
|
type: "dashed",
|
|
1994
2610
|
style: { marginTop: 8 },
|
|
1995
2611
|
onClick: c,
|
|
@@ -1998,258 +2614,24 @@ function zn({ resource: e, label: t, name: n, sources: r, renderRow: i }) {
|
|
|
1998
2614
|
]
|
|
1999
2615
|
});
|
|
2000
2616
|
}
|
|
2001
|
-
async function Bn(e, t) {
|
|
2002
|
-
let { resource: n, foreignKey: r, parentId: i, rows: a, existingIds: o = [], onRowError: s } = t, c = [];
|
|
2003
|
-
for (let t = 0; t < a.length; t++) {
|
|
2004
|
-
let l = a[t];
|
|
2005
|
-
try {
|
|
2006
|
-
let { id: t, ...a } = l, s = {
|
|
2007
|
-
...a,
|
|
2008
|
-
[r]: i
|
|
2009
|
-
}, u = l.id;
|
|
2010
|
-
if (u != null && o.some((e) => e === u)) await e.update(n, {
|
|
2011
|
-
id: u,
|
|
2012
|
-
data: s
|
|
2013
|
-
}), c.push(u);
|
|
2014
|
-
else {
|
|
2015
|
-
let t = (await e.create(n, s)).data;
|
|
2016
|
-
c.push(t.id);
|
|
2017
|
-
}
|
|
2018
|
-
} catch (e) {
|
|
2019
|
-
if (s?.(e, t)) return !1;
|
|
2020
|
-
throw e;
|
|
2021
|
-
}
|
|
2022
|
-
}
|
|
2023
|
-
for (let t of o) c.some((e) => e === t) || await e.delete(n, t);
|
|
2024
|
-
return !0;
|
|
2025
|
-
}
|
|
2026
|
-
async function Vn(e, t, n, r) {
|
|
2027
|
-
let i = await e.getList(t, {
|
|
2028
|
-
filter: { [n]: Number(r) || r },
|
|
2029
|
-
pagination: {
|
|
2030
|
-
page: 1,
|
|
2031
|
-
perPage: 500
|
|
2032
|
-
}
|
|
2033
|
-
});
|
|
2034
|
-
return {
|
|
2035
|
-
rows: i.data,
|
|
2036
|
-
ids: i.data.map((e) => e.id)
|
|
2037
|
-
};
|
|
2038
|
-
}
|
|
2039
|
-
//#endregion
|
|
2040
|
-
//#region src/crud/utils/useResourceFormData.ts
|
|
2041
|
-
function Hn(e) {
|
|
2042
|
-
return Pn(e.resource, e.name);
|
|
2043
|
-
}
|
|
2044
|
-
function Un({ dp: e, resource: t, id: n, isNew: r, form: a, message: o, defaultValues: s, inlines: c }) {
|
|
2045
|
-
let [u, d] = l(!r), [f, p] = l(0), [m, h] = l({}), g = i(async (i) => {
|
|
2046
|
-
if (r || !n) {
|
|
2047
|
-
s && a.reset({ ...s }), d(!1);
|
|
2048
|
-
return;
|
|
2049
|
-
}
|
|
2050
|
-
d(!0);
|
|
2051
|
-
try {
|
|
2052
|
-
let r = await e.getOne(t, n, { signal: i });
|
|
2053
|
-
if (i?.aborted) return;
|
|
2054
|
-
let o = r.data;
|
|
2055
|
-
if (c?.length) {
|
|
2056
|
-
let t = { ...o }, r = {};
|
|
2057
|
-
for (let i of c) {
|
|
2058
|
-
let a = Hn(i), { rows: o, ids: s } = await Vn(e, i.resource, i.foreignKey, n);
|
|
2059
|
-
t[a] = o, r[a] = s;
|
|
2060
|
-
}
|
|
2061
|
-
if (i?.aborted) return;
|
|
2062
|
-
a.reset(t), h(r), p((e) => e + 1);
|
|
2063
|
-
} else a.reset(o), p((e) => e + 1);
|
|
2064
|
-
} catch (e) {
|
|
2065
|
-
vt(e) || o.error(e instanceof Error ? e.message : "Load failed");
|
|
2066
|
-
} finally {
|
|
2067
|
-
i?.aborted || d(!1);
|
|
2068
|
-
}
|
|
2069
|
-
}, [
|
|
2070
|
-
e,
|
|
2071
|
-
t,
|
|
2072
|
-
n,
|
|
2073
|
-
r,
|
|
2074
|
-
a,
|
|
2075
|
-
o,
|
|
2076
|
-
s,
|
|
2077
|
-
c
|
|
2078
|
-
]);
|
|
2079
|
-
return yn((e) => g(e), [g]), {
|
|
2080
|
-
loading: u,
|
|
2081
|
-
formVersion: f,
|
|
2082
|
-
existingInlineIds: m
|
|
2083
|
-
};
|
|
2084
|
-
}
|
|
2085
|
-
function Wn({ dp: e, resource: t, id: n, isNew: r, form: a, message: o, navigate: s, listPath: c, submitFieldsRef: l, inlines: u, existingInlineIds: d, onSaved: f, stayOnPage: p }) {
|
|
2086
|
-
return i(async (i) => {
|
|
2087
|
-
try {
|
|
2088
|
-
let m = hn(i, Array.from(l.current));
|
|
2089
|
-
if (u?.length) for (let e of u) delete m[Hn(e)];
|
|
2090
|
-
let h;
|
|
2091
|
-
if (r) h = (await e.create(t, m)).data, o.success("Created");
|
|
2092
|
-
else if (n) h = (await e.update(t, {
|
|
2093
|
-
id: n,
|
|
2094
|
-
data: m
|
|
2095
|
-
})).data, o.success("Updated");
|
|
2096
|
-
else return;
|
|
2097
|
-
let g = h.id;
|
|
2098
|
-
if (u?.length && g != null) for (let t of u) {
|
|
2099
|
-
let n = Hn(t), r = a.getValues(n) ?? [];
|
|
2100
|
-
if (!await Bn(e, {
|
|
2101
|
-
resource: t.resource,
|
|
2102
|
-
foreignKey: t.foreignKey,
|
|
2103
|
-
parentId: g,
|
|
2104
|
-
rows: r,
|
|
2105
|
-
existingIds: d[n] ?? [],
|
|
2106
|
-
onRowError: (i, s) => {
|
|
2107
|
-
let c = r[s]?.id;
|
|
2108
|
-
return vn(e, a, o, i, {
|
|
2109
|
-
resource: t.resource,
|
|
2110
|
-
mutation: c != null && (d[n] ?? []).some((e) => e === c) ? "update" : "create",
|
|
2111
|
-
inlineArrayName: n,
|
|
2112
|
-
rowIndex: s
|
|
2113
|
-
});
|
|
2114
|
-
}
|
|
2115
|
-
})) return;
|
|
2116
|
-
}
|
|
2117
|
-
f?.(h), p || s(c);
|
|
2118
|
-
} catch (n) {
|
|
2119
|
-
vn(e, a, o, n, {
|
|
2120
|
-
resource: t,
|
|
2121
|
-
mutation: r ? "create" : "update"
|
|
2122
|
-
}), o.error(n instanceof Error ? n.message : "Save failed");
|
|
2123
|
-
}
|
|
2124
|
-
}, [
|
|
2125
|
-
e,
|
|
2126
|
-
t,
|
|
2127
|
-
n,
|
|
2128
|
-
r,
|
|
2129
|
-
a,
|
|
2130
|
-
o,
|
|
2131
|
-
s,
|
|
2132
|
-
c,
|
|
2133
|
-
l,
|
|
2134
|
-
u,
|
|
2135
|
-
d,
|
|
2136
|
-
f,
|
|
2137
|
-
p
|
|
2138
|
-
]);
|
|
2139
|
-
}
|
|
2140
|
-
//#endregion
|
|
2141
|
-
//#region src/crud/ResourceForm.tsx
|
|
2142
|
-
function Gn({ resource: e, title: t, listPath: r, children: i, defaultValues: a, onSaved: s, stayOnPage: l, inlines: d, permissions: f }) {
|
|
2143
|
-
let { id: p } = _(), m = p === "new" || !p, h = mt(), v = q(), b = g(), { message: C } = y.useApp(), { token: w } = z.useToken(), ee = c(/* @__PURE__ */ new Set()), T = ye({ defaultValues: a }), { loading: E, formVersion: O, existingInlineIds: k } = Un({
|
|
2144
|
-
dp: h,
|
|
2145
|
-
resource: e,
|
|
2146
|
-
id: p,
|
|
2147
|
-
isNew: m,
|
|
2148
|
-
form: T,
|
|
2149
|
-
message: C,
|
|
2150
|
-
defaultValues: a,
|
|
2151
|
-
inlines: d
|
|
2152
|
-
}), A = Wn({
|
|
2153
|
-
dp: h,
|
|
2154
|
-
resource: e,
|
|
2155
|
-
id: p,
|
|
2156
|
-
isNew: m,
|
|
2157
|
-
form: T,
|
|
2158
|
-
message: C,
|
|
2159
|
-
navigate: b,
|
|
2160
|
-
listPath: r,
|
|
2161
|
-
submitFieldsRef: ee,
|
|
2162
|
-
inlines: d,
|
|
2163
|
-
existingInlineIds: k,
|
|
2164
|
-
onSaved: s,
|
|
2165
|
-
stayOnPage: l
|
|
2166
|
-
});
|
|
2167
|
-
o(() => {
|
|
2168
|
-
f && (J(v, f, m ? "add" : "change") || b(r, { replace: !0 }));
|
|
2169
|
-
}, [
|
|
2170
|
-
f,
|
|
2171
|
-
m,
|
|
2172
|
-
v,
|
|
2173
|
-
b,
|
|
2174
|
-
r
|
|
2175
|
-
]);
|
|
2176
|
-
let j = f ? J(v, f, m ? "add" : "change") : !0;
|
|
2177
|
-
return /* @__PURE__ */ V(S, {
|
|
2178
|
-
title: /* @__PURE__ */ H(I, { children: [/* @__PURE__ */ H(u, {
|
|
2179
|
-
to: r,
|
|
2180
|
-
style: { color: w.colorText },
|
|
2181
|
-
children: [/* @__PURE__ */ V(U, {}), " Back"]
|
|
2182
|
-
}), /* @__PURE__ */ V(R.Title, {
|
|
2183
|
-
level: 5,
|
|
2184
|
-
style: { margin: 0 },
|
|
2185
|
-
children: t
|
|
2186
|
-
})] }),
|
|
2187
|
-
children: /* @__PURE__ */ V(nn, {
|
|
2188
|
-
resource: e,
|
|
2189
|
-
isNew: m,
|
|
2190
|
-
children: /* @__PURE__ */ V(ln, {
|
|
2191
|
-
fieldsRef: ee,
|
|
2192
|
-
children: /* @__PURE__ */ H("div", {
|
|
2193
|
-
style: { position: "relative" },
|
|
2194
|
-
children: [E ? /* @__PURE__ */ V("div", {
|
|
2195
|
-
style: {
|
|
2196
|
-
position: "absolute",
|
|
2197
|
-
inset: 0,
|
|
2198
|
-
display: "flex",
|
|
2199
|
-
alignItems: "center",
|
|
2200
|
-
justifyContent: "center",
|
|
2201
|
-
zIndex: 1
|
|
2202
|
-
},
|
|
2203
|
-
children: /* @__PURE__ */ V(L, {})
|
|
2204
|
-
}) : null, /* @__PURE__ */ n(_e, {
|
|
2205
|
-
...T,
|
|
2206
|
-
key: O
|
|
2207
|
-
}, /* @__PURE__ */ H(D, {
|
|
2208
|
-
layout: "vertical",
|
|
2209
|
-
onFinish: () => void T.handleSubmit(A)(),
|
|
2210
|
-
style: {
|
|
2211
|
-
opacity: E ? .4 : 1,
|
|
2212
|
-
pointerEvents: E ? "none" : void 0
|
|
2213
|
-
},
|
|
2214
|
-
children: [i, /* @__PURE__ */ V(D.Item, {
|
|
2215
|
-
style: { marginTop: 16 },
|
|
2216
|
-
children: /* @__PURE__ */ H(I, { children: [/* @__PURE__ */ V(x, {
|
|
2217
|
-
type: "primary",
|
|
2218
|
-
htmlType: "submit",
|
|
2219
|
-
disabled: E || !j,
|
|
2220
|
-
children: "Save"
|
|
2221
|
-
}), /* @__PURE__ */ V(u, {
|
|
2222
|
-
to: r,
|
|
2223
|
-
children: /* @__PURE__ */ V(x, {
|
|
2224
|
-
disabled: E,
|
|
2225
|
-
children: "Cancel"
|
|
2226
|
-
})
|
|
2227
|
-
})] })
|
|
2228
|
-
})]
|
|
2229
|
-
}))]
|
|
2230
|
-
})
|
|
2231
|
-
})
|
|
2232
|
-
})
|
|
2233
|
-
});
|
|
2234
|
-
}
|
|
2235
2617
|
//#endregion
|
|
2236
2618
|
//#region src/crud/utils/formSectionErrors.ts
|
|
2237
|
-
function
|
|
2619
|
+
function Lr(e, t, n) {
|
|
2238
2620
|
for (let r of e) if (t(r, n).invalid) return !0;
|
|
2239
2621
|
return !1;
|
|
2240
2622
|
}
|
|
2241
|
-
function
|
|
2242
|
-
let t =
|
|
2623
|
+
function Rr(e) {
|
|
2624
|
+
let t = l([]);
|
|
2243
2625
|
for (; t.current.length < e;) t.current.push({ current: /* @__PURE__ */ new Set() });
|
|
2244
2626
|
return t.current.length > e && (t.current.length = e), t.current;
|
|
2245
2627
|
}
|
|
2246
|
-
function
|
|
2247
|
-
let { control: n, getFieldState: r, setFocus: i } =
|
|
2248
|
-
|
|
2628
|
+
function zr(e, t) {
|
|
2629
|
+
let { control: n, getFieldState: r, setFocus: i } = Ee(), a = De({ control: n }), o = l(0), c = l(0);
|
|
2630
|
+
s(() => {
|
|
2249
2631
|
if (a.submitCount === 0) return;
|
|
2250
|
-
let n = Object.keys(a.errors).length,
|
|
2251
|
-
if (
|
|
2252
|
-
let u = e.findIndex((e) =>
|
|
2632
|
+
let n = Object.keys(a.errors).length, s = a.submitCount !== o.current, l = !s && n > 0 && c.current === 0;
|
|
2633
|
+
if (o.current = a.submitCount, c.current = n, !s && !l || n === 0) return;
|
|
2634
|
+
let u = e.findIndex((e) => Lr(e.current, r, a));
|
|
2253
2635
|
if (u < 0) return;
|
|
2254
2636
|
t(u);
|
|
2255
2637
|
let d = [...e[u].current].find((e) => r(e, a).invalid);
|
|
@@ -2268,38 +2650,38 @@ function Jn(e, t) {
|
|
|
2268
2650
|
}
|
|
2269
2651
|
//#endregion
|
|
2270
2652
|
//#region src/crud/FormTabs.tsx
|
|
2271
|
-
function
|
|
2653
|
+
function Br(e) {
|
|
2272
2654
|
return null;
|
|
2273
2655
|
}
|
|
2274
|
-
function
|
|
2275
|
-
return
|
|
2656
|
+
function Vr(e) {
|
|
2657
|
+
return i(e) && e.type === Br;
|
|
2276
2658
|
}
|
|
2277
|
-
function
|
|
2278
|
-
let { token:
|
|
2659
|
+
function Hr({ children: t, defaultActiveKey: n, activeKey: r, onChange: i, ...o }) {
|
|
2660
|
+
let { token: s } = W.useToken(), l = c(() => e.toArray(t).filter(Vr).map((e, t) => ({
|
|
2279
2661
|
key: e.key ?? String(t),
|
|
2280
2662
|
label: e.props.label,
|
|
2281
2663
|
disabled: e.props.disabled,
|
|
2282
2664
|
children: e.props.children
|
|
2283
|
-
})), [t]), d =
|
|
2284
|
-
f || m(e),
|
|
2285
|
-
}, [f,
|
|
2286
|
-
|
|
2287
|
-
let t =
|
|
2665
|
+
})), [t]), d = Rr(l.length), f = r !== void 0, [p, m] = u(() => n ?? l[0]?.key ?? "0"), h = f ? r : p, g = a((e) => {
|
|
2666
|
+
f || m(e), i?.(e);
|
|
2667
|
+
}, [f, i]);
|
|
2668
|
+
zr(d, a((e) => {
|
|
2669
|
+
let t = l[e]?.key;
|
|
2288
2670
|
t != null && g(t);
|
|
2289
|
-
}, [g,
|
|
2290
|
-
let { control: _, getFieldState: v } =
|
|
2291
|
-
return /* @__PURE__ */ V
|
|
2671
|
+
}, [g, l]));
|
|
2672
|
+
let { control: _, getFieldState: v } = Ee(), y = De({ control: _ });
|
|
2673
|
+
return /* @__PURE__ */ K(V, {
|
|
2292
2674
|
destroyOnHidden: !1,
|
|
2293
|
-
items:
|
|
2294
|
-
let n =
|
|
2675
|
+
items: c(() => l.map((e, t) => {
|
|
2676
|
+
let n = Lr(d[t].current, v, y);
|
|
2295
2677
|
return {
|
|
2296
2678
|
key: e.key,
|
|
2297
|
-
label: n ? /* @__PURE__ */
|
|
2298
|
-
style: { color:
|
|
2679
|
+
label: n ? /* @__PURE__ */ K("span", {
|
|
2680
|
+
style: { color: s.colorError },
|
|
2299
2681
|
children: e.label
|
|
2300
2682
|
}) : e.label,
|
|
2301
2683
|
disabled: e.disabled,
|
|
2302
|
-
children: /* @__PURE__ */
|
|
2684
|
+
children: /* @__PURE__ */ K(In, {
|
|
2303
2685
|
sourcesRef: d[t],
|
|
2304
2686
|
children: e.children
|
|
2305
2687
|
})
|
|
@@ -2308,8 +2690,8 @@ function Zn({ children: t, defaultActiveKey: n, activeKey: r, onChange: a, ...o
|
|
|
2308
2690
|
y,
|
|
2309
2691
|
v,
|
|
2310
2692
|
d,
|
|
2311
|
-
|
|
2312
|
-
|
|
2693
|
+
l,
|
|
2694
|
+
s.colorError
|
|
2313
2695
|
]),
|
|
2314
2696
|
activeKey: h,
|
|
2315
2697
|
onChange: g,
|
|
@@ -2318,61 +2700,61 @@ function Zn({ children: t, defaultActiveKey: n, activeKey: r, onChange: a, ...o
|
|
|
2318
2700
|
}
|
|
2319
2701
|
//#endregion
|
|
2320
2702
|
//#region src/crud/FormSteps.tsx
|
|
2321
|
-
function
|
|
2703
|
+
function Ur(e) {
|
|
2322
2704
|
return null;
|
|
2323
2705
|
}
|
|
2324
|
-
function
|
|
2325
|
-
return
|
|
2706
|
+
function Wr(e) {
|
|
2707
|
+
return i(e) && e.type === Ur;
|
|
2326
2708
|
}
|
|
2327
|
-
function
|
|
2328
|
-
let m =
|
|
2329
|
-
|
|
2330
|
-
let { control: y, getFieldState: b } =
|
|
2331
|
-
let n =
|
|
2709
|
+
function Gr({ children: t, initialStep: n = 0, showNavigation: r = !0, allowStepSelect: i = !1, stepsStyle: o, navigationStyle: s, size: l, direction: d, type: f, status: p }) {
|
|
2710
|
+
let m = c(() => e.toArray(t).filter(Wr), [t]), h = Rr(m.length), [g, _] = u(n), v = m.length - 1;
|
|
2711
|
+
zr(h, _);
|
|
2712
|
+
let { control: y, getFieldState: b } = Ee(), x = De({ control: y }), S = c(() => m.map((e, t) => {
|
|
2713
|
+
let n = Lr(h[t].current, b, x);
|
|
2332
2714
|
return {
|
|
2333
2715
|
title: e.props.title,
|
|
2334
2716
|
description: e.props.description,
|
|
2335
2717
|
status: n ? "error" : void 0
|
|
2336
2718
|
};
|
|
2337
2719
|
}), [
|
|
2338
|
-
|
|
2720
|
+
x,
|
|
2339
2721
|
b,
|
|
2340
2722
|
h,
|
|
2341
2723
|
m
|
|
2342
|
-
]), w =
|
|
2724
|
+
]), w = a((e) => {
|
|
2343
2725
|
_(e);
|
|
2344
2726
|
}, []);
|
|
2345
|
-
return /* @__PURE__ */
|
|
2346
|
-
/* @__PURE__ */
|
|
2727
|
+
return /* @__PURE__ */ q(G, { children: [
|
|
2728
|
+
/* @__PURE__ */ K(z, {
|
|
2347
2729
|
current: g,
|
|
2348
|
-
items:
|
|
2730
|
+
items: S,
|
|
2349
2731
|
style: {
|
|
2350
2732
|
marginBottom: 24,
|
|
2351
2733
|
...o
|
|
2352
2734
|
},
|
|
2353
|
-
onChange:
|
|
2354
|
-
size:
|
|
2735
|
+
onChange: i ? w : void 0,
|
|
2736
|
+
size: l,
|
|
2355
2737
|
direction: d,
|
|
2356
2738
|
type: f,
|
|
2357
2739
|
status: p
|
|
2358
2740
|
}),
|
|
2359
|
-
m.map((e, t) => /* @__PURE__ */
|
|
2741
|
+
m.map((e, t) => /* @__PURE__ */ K("div", {
|
|
2360
2742
|
style: { display: g === t ? void 0 : "none" },
|
|
2361
|
-
children: /* @__PURE__ */
|
|
2743
|
+
children: /* @__PURE__ */ K(In, {
|
|
2362
2744
|
sourcesRef: h[t],
|
|
2363
2745
|
children: e.props.children
|
|
2364
2746
|
})
|
|
2365
2747
|
}, e.key ?? String(t))),
|
|
2366
|
-
r && m.length > 1 ? /* @__PURE__ */
|
|
2748
|
+
r && m.length > 1 ? /* @__PURE__ */ q(R, {
|
|
2367
2749
|
style: {
|
|
2368
2750
|
marginTop: 16,
|
|
2369
|
-
...
|
|
2751
|
+
...s
|
|
2370
2752
|
},
|
|
2371
|
-
children: [/* @__PURE__ */
|
|
2753
|
+
children: [/* @__PURE__ */ K(C, {
|
|
2372
2754
|
disabled: g === 0,
|
|
2373
2755
|
onClick: () => _((e) => e - 1),
|
|
2374
2756
|
children: "Previous"
|
|
2375
|
-
}), /* @__PURE__ */
|
|
2757
|
+
}), /* @__PURE__ */ K(C, {
|
|
2376
2758
|
type: "primary",
|
|
2377
2759
|
disabled: g === v,
|
|
2378
2760
|
onClick: () => _((e) => e + 1),
|
|
@@ -2383,16 +2765,16 @@ function er({ children: t, initialStep: n = 0, showNavigation: r = !0, allowStep
|
|
|
2383
2765
|
}
|
|
2384
2766
|
//#endregion
|
|
2385
2767
|
//#region src/crud/fields/FieldWrapper.tsx
|
|
2386
|
-
function
|
|
2387
|
-
let s = t ?? e, c = !s.includes("."), { control: l } =
|
|
2388
|
-
return
|
|
2768
|
+
function $({ source: e, name: t, label: n, required: r, rules: i, hideLabel: a, children: o }) {
|
|
2769
|
+
let s = t ?? e, c = !s.includes("."), { control: l } = Ee(), u = Pn(), d = a ? void 0 : n ?? e, f = n ?? e;
|
|
2770
|
+
return Vn(e, c), Hn(e, c), /* @__PURE__ */ K(Se, {
|
|
2389
2771
|
name: s,
|
|
2390
2772
|
control: l,
|
|
2391
2773
|
rules: {
|
|
2392
2774
|
required: r ? `${f} is required` : !1,
|
|
2393
2775
|
...i
|
|
2394
2776
|
},
|
|
2395
|
-
render: ({ field: e, fieldState: t }) => /* @__PURE__ */
|
|
2777
|
+
render: ({ field: e, fieldState: t }) => /* @__PURE__ */ K(A.Item, {
|
|
2396
2778
|
label: d,
|
|
2397
2779
|
validateStatus: t.error ? "error" : void 0,
|
|
2398
2780
|
help: t.error?.message,
|
|
@@ -2410,15 +2792,15 @@ function Q({ source: e, name: t, label: n, required: r, rules: i, hideLabel: a,
|
|
|
2410
2792
|
}
|
|
2411
2793
|
//#endregion
|
|
2412
2794
|
//#region src/crud/fields/TextField.tsx
|
|
2413
|
-
function
|
|
2414
|
-
return /* @__PURE__ */
|
|
2795
|
+
function Kr({ source: e, name: t, label: n, required: r, rules: i, placeholder: a, inputStyle: o, hideLabel: s }) {
|
|
2796
|
+
return /* @__PURE__ */ K($, {
|
|
2415
2797
|
source: e,
|
|
2416
2798
|
name: t,
|
|
2417
2799
|
label: n,
|
|
2418
2800
|
required: r,
|
|
2419
2801
|
rules: i,
|
|
2420
2802
|
hideLabel: s,
|
|
2421
|
-
children: ({ value: e, onChange: t, onBlur: n, disabled: r }) => /* @__PURE__ */
|
|
2803
|
+
children: ({ value: e, onChange: t, onBlur: n, disabled: r }) => /* @__PURE__ */ K(N, {
|
|
2422
2804
|
value: e,
|
|
2423
2805
|
onChange: (e) => t(e.target.value),
|
|
2424
2806
|
onBlur: n,
|
|
@@ -2430,15 +2812,15 @@ function tr({ source: e, name: t, label: n, required: r, rules: i, placeholder:
|
|
|
2430
2812
|
}
|
|
2431
2813
|
//#endregion
|
|
2432
2814
|
//#region src/crud/fields/NumberField.tsx
|
|
2433
|
-
function
|
|
2434
|
-
return /* @__PURE__ */
|
|
2815
|
+
function qr({ source: e, name: t, label: n, required: r, rules: i, min: a, max: o, step: s, inputStyle: c, hideLabel: l }) {
|
|
2816
|
+
return /* @__PURE__ */ K($, {
|
|
2435
2817
|
source: e,
|
|
2436
2818
|
name: t,
|
|
2437
2819
|
label: n,
|
|
2438
2820
|
required: r,
|
|
2439
2821
|
rules: i,
|
|
2440
2822
|
hideLabel: l,
|
|
2441
|
-
children: ({ value: e, onChange: t, onBlur: n, disabled: r }) => /* @__PURE__ */
|
|
2823
|
+
children: ({ value: e, onChange: t, onBlur: n, disabled: r }) => /* @__PURE__ */ K(P, {
|
|
2442
2824
|
value: e,
|
|
2443
2825
|
onChange: (e) => t(e),
|
|
2444
2826
|
onBlur: n,
|
|
@@ -2455,15 +2837,15 @@ function nr({ source: e, name: t, label: n, required: r, rules: i, min: a, max:
|
|
|
2455
2837
|
}
|
|
2456
2838
|
//#endregion
|
|
2457
2839
|
//#region src/crud/fields/BooleanField.tsx
|
|
2458
|
-
function
|
|
2459
|
-
return /* @__PURE__ */
|
|
2840
|
+
function Jr({ source: e, name: t, label: n, required: r, rules: i, hideLabel: a }) {
|
|
2841
|
+
return /* @__PURE__ */ K($, {
|
|
2460
2842
|
source: e,
|
|
2461
2843
|
name: t,
|
|
2462
2844
|
label: n,
|
|
2463
2845
|
required: r,
|
|
2464
2846
|
rules: i,
|
|
2465
2847
|
hideLabel: a,
|
|
2466
|
-
children: ({ value: e, onChange: t, disabled: n }) => /* @__PURE__ */
|
|
2848
|
+
children: ({ value: e, onChange: t, disabled: n }) => /* @__PURE__ */ K(B, {
|
|
2467
2849
|
checked: !!e,
|
|
2468
2850
|
onChange: t,
|
|
2469
2851
|
disabled: n
|
|
@@ -2472,37 +2854,37 @@ function rr({ source: e, name: t, label: n, required: r, rules: i, hideLabel: a
|
|
|
2472
2854
|
}
|
|
2473
2855
|
//#endregion
|
|
2474
2856
|
//#region src/crud/fields/DateField.tsx
|
|
2475
|
-
var
|
|
2476
|
-
function
|
|
2477
|
-
return /* @__PURE__ */
|
|
2857
|
+
var Yr = "YYYY-MM-DD";
|
|
2858
|
+
function Xr({ source: e, name: t, label: n, required: r, rules: i, showTime: a, hideLabel: o }) {
|
|
2859
|
+
return /* @__PURE__ */ K($, {
|
|
2478
2860
|
source: e,
|
|
2479
2861
|
name: t,
|
|
2480
2862
|
label: n,
|
|
2481
2863
|
required: r,
|
|
2482
2864
|
rules: i,
|
|
2483
2865
|
hideLabel: o,
|
|
2484
|
-
children: ({ value: e, onChange: t, onBlur: n, disabled: r }) => /* @__PURE__ */
|
|
2485
|
-
value: e ?
|
|
2486
|
-
onChange: (e) => t(e ? e.format(a ? `${
|
|
2866
|
+
children: ({ value: e, onChange: t, onBlur: n, disabled: r }) => /* @__PURE__ */ K(E, {
|
|
2867
|
+
value: e ? ke(String(e)) : null,
|
|
2868
|
+
onChange: (e) => t(e ? e.format(a ? `${Yr} HH:mm:ss` : Yr) : null),
|
|
2487
2869
|
onBlur: n,
|
|
2488
2870
|
showTime: a,
|
|
2489
2871
|
disabled: r,
|
|
2490
|
-
format: a ? `${
|
|
2872
|
+
format: a ? `${Yr} HH:mm:ss` : Yr,
|
|
2491
2873
|
style: { width: "100%" }
|
|
2492
2874
|
})
|
|
2493
2875
|
});
|
|
2494
2876
|
}
|
|
2495
2877
|
//#endregion
|
|
2496
2878
|
//#region src/crud/fields/SelectField.tsx
|
|
2497
|
-
function
|
|
2498
|
-
return /* @__PURE__ */
|
|
2879
|
+
function Zr({ source: e, name: t, label: n, required: r, rules: i, choices: a, mode: o, allowClear: s, hideLabel: c }) {
|
|
2880
|
+
return /* @__PURE__ */ K($, {
|
|
2499
2881
|
source: e,
|
|
2500
2882
|
name: t,
|
|
2501
2883
|
label: n,
|
|
2502
2884
|
required: r,
|
|
2503
2885
|
rules: i,
|
|
2504
2886
|
hideLabel: c,
|
|
2505
|
-
children: ({ value: e, onChange: t, disabled: n }) => /* @__PURE__ */
|
|
2887
|
+
children: ({ value: e, onChange: t, disabled: n }) => /* @__PURE__ */ K(L, {
|
|
2506
2888
|
value: e,
|
|
2507
2889
|
onChange: t,
|
|
2508
2890
|
options: a,
|
|
@@ -2515,15 +2897,15 @@ function or({ source: e, name: t, label: n, required: r, rules: i, choices: a, m
|
|
|
2515
2897
|
}
|
|
2516
2898
|
//#endregion
|
|
2517
2899
|
//#region src/crud/fields/PasswordField.tsx
|
|
2518
|
-
function
|
|
2519
|
-
return /* @__PURE__ */
|
|
2900
|
+
function Qr({ source: e, name: t, label: n, required: r, rules: i, autoComplete: a, hideLabel: o }) {
|
|
2901
|
+
return /* @__PURE__ */ K($, {
|
|
2520
2902
|
source: e,
|
|
2521
2903
|
name: t,
|
|
2522
2904
|
label: n,
|
|
2523
2905
|
required: r,
|
|
2524
2906
|
rules: i,
|
|
2525
2907
|
hideLabel: o,
|
|
2526
|
-
children: ({ value: e, onChange: t, onBlur: n, disabled: r }) => /* @__PURE__ */
|
|
2908
|
+
children: ({ value: e, onChange: t, onBlur: n, disabled: r }) => /* @__PURE__ */ K(N.Password, {
|
|
2527
2909
|
value: e,
|
|
2528
2910
|
onChange: (e) => t(e.target.value),
|
|
2529
2911
|
onBlur: n,
|
|
@@ -2532,12 +2914,12 @@ function sr({ source: e, name: t, label: n, required: r, rules: i, autoComplete:
|
|
|
2532
2914
|
})
|
|
2533
2915
|
});
|
|
2534
2916
|
}
|
|
2535
|
-
function
|
|
2536
|
-
let l =
|
|
2917
|
+
function $r({ source: e, name: t, label: n, required: r, rules: i, confirmSource: a, confirmLabel: o = "Confirm password", autoComplete: s = "new-password", hideLabel: c }) {
|
|
2918
|
+
let l = Oe({
|
|
2537
2919
|
name: t ?? e,
|
|
2538
2920
|
disabled: !a
|
|
2539
2921
|
});
|
|
2540
|
-
return a ? /* @__PURE__ */
|
|
2922
|
+
return a ? /* @__PURE__ */ q(G, { children: [/* @__PURE__ */ K(Qr, {
|
|
2541
2923
|
source: e,
|
|
2542
2924
|
name: t,
|
|
2543
2925
|
label: n,
|
|
@@ -2545,14 +2927,14 @@ function cr({ source: e, name: t, label: n, required: r, rules: i, confirmSource
|
|
|
2545
2927
|
rules: i,
|
|
2546
2928
|
autoComplete: s,
|
|
2547
2929
|
hideLabel: c
|
|
2548
|
-
}), /* @__PURE__ */
|
|
2930
|
+
}), /* @__PURE__ */ K(Qr, {
|
|
2549
2931
|
source: a,
|
|
2550
2932
|
label: o,
|
|
2551
2933
|
required: r,
|
|
2552
2934
|
autoComplete: s,
|
|
2553
2935
|
hideLabel: c,
|
|
2554
2936
|
rules: { validate: (e) => !l || e === l || "Passwords do not match" }
|
|
2555
|
-
})] }) : /* @__PURE__ */
|
|
2937
|
+
})] }) : /* @__PURE__ */ K(Qr, {
|
|
2556
2938
|
source: e,
|
|
2557
2939
|
name: t,
|
|
2558
2940
|
label: n,
|
|
@@ -2563,15 +2945,60 @@ function cr({ source: e, name: t, label: n, required: r, rules: i, confirmSource
|
|
|
2563
2945
|
});
|
|
2564
2946
|
}
|
|
2565
2947
|
//#endregion
|
|
2566
|
-
//#region src/crud/utils/
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2948
|
+
//#region src/crud/utils/choiceSelectionUtils.ts
|
|
2949
|
+
function ei(e, t) {
|
|
2950
|
+
return typeof e == "object" && !!e && !Array.isArray(e) && t in e;
|
|
2951
|
+
}
|
|
2952
|
+
function ti(e, t) {
|
|
2953
|
+
if (!(e == null || e === "")) {
|
|
2954
|
+
if (ei(e, t)) {
|
|
2955
|
+
let n = e[t];
|
|
2956
|
+
return typeof n == "string" || typeof n == "number" ? n : void 0;
|
|
2957
|
+
}
|
|
2958
|
+
if (typeof e == "string" || typeof e == "number") return e;
|
|
2959
|
+
}
|
|
2960
|
+
}
|
|
2961
|
+
function ni(e, t) {
|
|
2962
|
+
return Array.isArray(e) ? e.map((e) => ti(e, t)).filter((e) => e != null) : [];
|
|
2570
2963
|
}
|
|
2571
|
-
function
|
|
2964
|
+
function ri(e, t) {
|
|
2965
|
+
return e == null ? [] : (Array.isArray(e) ? e : [e]).filter((e) => e != null && e !== "").map((e) => ei(e, t) ? e[t] : e);
|
|
2966
|
+
}
|
|
2967
|
+
function ii(e, t, n) {
|
|
2968
|
+
let r = [];
|
|
2969
|
+
if (t != null && (Array.isArray(t) ? r.push(...t.filter((e) => ei(e, n))) : ei(t, n) && r.push(t)), e == null) return r;
|
|
2970
|
+
let i = Array.isArray(e) ? e : [e];
|
|
2971
|
+
for (let e of i) ei(e, n) && r.push(e);
|
|
2972
|
+
return r;
|
|
2973
|
+
}
|
|
2974
|
+
function ai(e, t) {
|
|
2572
2975
|
return typeof t == "function" ? t(e) : String(e[t] ?? "");
|
|
2573
2976
|
}
|
|
2574
|
-
|
|
2977
|
+
function oi(e, t, n) {
|
|
2978
|
+
return e.map((e) => ({
|
|
2979
|
+
label: ai(e, t),
|
|
2980
|
+
value: e[n],
|
|
2981
|
+
record: e
|
|
2982
|
+
}));
|
|
2983
|
+
}
|
|
2984
|
+
function si(e, t) {
|
|
2985
|
+
let n = /* @__PURE__ */ new Map();
|
|
2986
|
+
for (let t of e) n.set(t.value, t);
|
|
2987
|
+
for (let e of t) n.set(e.value, e);
|
|
2988
|
+
return Array.from(n.values());
|
|
2989
|
+
}
|
|
2990
|
+
//#endregion
|
|
2991
|
+
//#region src/crud/utils/referenceSelectNotFoundContent.tsx
|
|
2992
|
+
function ci(e) {
|
|
2993
|
+
return e ? /* @__PURE__ */ K(re, { size: "small" }) : void 0;
|
|
2994
|
+
}
|
|
2995
|
+
//#endregion
|
|
2996
|
+
//#region src/crud/utils/useChoices.ts
|
|
2997
|
+
var li = /* @__PURE__ */ new Map(), ui = /* @__PURE__ */ new Map();
|
|
2998
|
+
function di(e, t) {
|
|
2999
|
+
return typeof e == "function" ? `fn:${t ?? ""}` : Array.isArray(e) ? `static:${e.length}` : `res:${e.resource}:${JSON.stringify(e.filter ?? {})}:${t ?? ""}`;
|
|
3000
|
+
}
|
|
3001
|
+
async function fi(e, t, n, r, i) {
|
|
2575
3002
|
return typeof e == "function" ? e({
|
|
2576
3003
|
dataProvider: t,
|
|
2577
3004
|
search: i
|
|
@@ -2585,139 +3012,535 @@ async function pr(e, t, n, r, i) {
|
|
|
2585
3012
|
perPage: 500
|
|
2586
3013
|
}
|
|
2587
3014
|
})).data.map((e) => ({
|
|
2588
|
-
label:
|
|
3015
|
+
label: ai(e, n),
|
|
2589
3016
|
value: e[r],
|
|
2590
3017
|
record: e
|
|
2591
3018
|
}));
|
|
2592
3019
|
}
|
|
2593
|
-
function
|
|
2594
|
-
let
|
|
2595
|
-
if (
|
|
2596
|
-
|
|
3020
|
+
function pi(e, t, n, r, i, a) {
|
|
3021
|
+
let o = di(e, i);
|
|
3022
|
+
if (a) {
|
|
3023
|
+
let e = li.get(o);
|
|
3024
|
+
if (e && !i) return Promise.resolve(e);
|
|
3025
|
+
}
|
|
3026
|
+
let s = ui.get(o);
|
|
2597
3027
|
if (s) return s;
|
|
2598
|
-
let c =
|
|
2599
|
-
|
|
3028
|
+
let c = fi(e, t, n, r, i).then((e) => (a && !i && li.set(o, e), e)).finally(() => {
|
|
3029
|
+
ui.delete(o);
|
|
2600
3030
|
});
|
|
2601
|
-
return
|
|
3031
|
+
return ui.set(o, c), c;
|
|
2602
3032
|
}
|
|
2603
|
-
function
|
|
2604
|
-
let
|
|
3033
|
+
function mi(e, t, n = "name", r = "id", i, o = {}) {
|
|
3034
|
+
let { lazy: l = !1, active: d = !1, selectedValues: f, selectedRecords: p, fetchSelected: m = !0, cache: h } = o, g = h ?? !l, _ = jt(), v = c(() => {
|
|
2605
3035
|
if (e) return e;
|
|
2606
3036
|
if (t) return {
|
|
2607
3037
|
resource: t,
|
|
2608
|
-
filter:
|
|
3038
|
+
filter: i ? { q: i } : void 0
|
|
2609
3039
|
};
|
|
2610
3040
|
}, [
|
|
2611
3041
|
e,
|
|
2612
3042
|
t,
|
|
2613
|
-
|
|
2614
|
-
]),
|
|
2615
|
-
|
|
2616
|
-
|
|
3043
|
+
i
|
|
3044
|
+
]), y = v ? di(v, i) : void 0, b = c(() => ri(f, r), [f, r]), x = c(() => oi(ii(f, p, r), n, r), [
|
|
3045
|
+
f,
|
|
3046
|
+
p,
|
|
3047
|
+
n,
|
|
3048
|
+
r
|
|
3049
|
+
]), S = !!(v && (!l || d || Array.isArray(v))), [C, w] = u(() => x.length ? x : !y || i || l || !g ? [] : li.get(y) ?? []), [T, E] = u(() => S ? !g || !y || i ? !!v : !li.has(y) : !1);
|
|
3050
|
+
s(() => {
|
|
3051
|
+
x.length && w((e) => si(e, x));
|
|
3052
|
+
}, [x]);
|
|
3053
|
+
let D = a(async () => {
|
|
3054
|
+
if (!v || !S) {
|
|
3055
|
+
v || w(x), E(!1);
|
|
2617
3056
|
return;
|
|
2618
3057
|
}
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
3058
|
+
if (g) {
|
|
3059
|
+
let e = di(v, i), t = li.get(e);
|
|
3060
|
+
if (t && !i) {
|
|
3061
|
+
w(si(x, t)), E(!1);
|
|
3062
|
+
return;
|
|
3063
|
+
}
|
|
2623
3064
|
}
|
|
2624
|
-
|
|
3065
|
+
E(!0), l && w(x);
|
|
2625
3066
|
try {
|
|
2626
|
-
|
|
3067
|
+
w(si(x, await pi(v, _, n, r, i, g)));
|
|
2627
3068
|
} catch {
|
|
2628
|
-
|
|
3069
|
+
!b.length && !x.length ? w([]) : l && w(x);
|
|
2629
3070
|
} finally {
|
|
2630
|
-
|
|
3071
|
+
E(!1);
|
|
2631
3072
|
}
|
|
2632
3073
|
}, [
|
|
2633
|
-
|
|
2634
|
-
|
|
3074
|
+
v,
|
|
3075
|
+
S,
|
|
3076
|
+
g,
|
|
3077
|
+
_,
|
|
2635
3078
|
n,
|
|
2636
3079
|
r,
|
|
2637
|
-
|
|
3080
|
+
i,
|
|
3081
|
+
l,
|
|
3082
|
+
b.length,
|
|
3083
|
+
x
|
|
3084
|
+
]);
|
|
3085
|
+
s(() => {
|
|
3086
|
+
D();
|
|
3087
|
+
}, [D]), s(() => {
|
|
3088
|
+
l && !d && !i && (w(x), E(!1));
|
|
3089
|
+
}, [
|
|
3090
|
+
l,
|
|
3091
|
+
d,
|
|
3092
|
+
i,
|
|
3093
|
+
x
|
|
3094
|
+
]), s(() => {
|
|
3095
|
+
if (!m || !t || !b.length) return;
|
|
3096
|
+
let e = b.filter((e) => !x.some((t) => t.value === e));
|
|
3097
|
+
if (!e.length) return;
|
|
3098
|
+
let i = !1;
|
|
3099
|
+
return (async () => {
|
|
3100
|
+
let a = [];
|
|
3101
|
+
for (let i of e) try {
|
|
3102
|
+
let e = (await _.getOne(t, i)).data;
|
|
3103
|
+
a.push({
|
|
3104
|
+
label: ai(e, n),
|
|
3105
|
+
value: e[r],
|
|
3106
|
+
record: e
|
|
3107
|
+
});
|
|
3108
|
+
} catch {
|
|
3109
|
+
a.push({
|
|
3110
|
+
label: String(i),
|
|
3111
|
+
value: i
|
|
3112
|
+
});
|
|
3113
|
+
}
|
|
3114
|
+
i || !a.length || w((e) => {
|
|
3115
|
+
let t = a.filter((t) => !e.some((e) => e.value === t.value));
|
|
3116
|
+
return t.length ? si(e, t) : e;
|
|
3117
|
+
});
|
|
3118
|
+
})(), () => {
|
|
3119
|
+
i = !0;
|
|
3120
|
+
};
|
|
3121
|
+
}, [
|
|
3122
|
+
m,
|
|
3123
|
+
t,
|
|
3124
|
+
_,
|
|
3125
|
+
n,
|
|
3126
|
+
r,
|
|
3127
|
+
b,
|
|
3128
|
+
x
|
|
2638
3129
|
]);
|
|
2639
|
-
|
|
2640
|
-
g();
|
|
2641
|
-
}, [g]);
|
|
2642
|
-
let _ = i((e) => f.find((t) => t.value === e)?.label ?? String(e ?? "—"), [f]);
|
|
3130
|
+
let O = a((e) => C.find((t) => t.value === e)?.label ?? String(e ?? "—"), [C]);
|
|
2643
3131
|
return {
|
|
2644
|
-
options:
|
|
2645
|
-
loading:
|
|
2646
|
-
labelForValue:
|
|
2647
|
-
labelsForValues:
|
|
2648
|
-
optionForValue:
|
|
2649
|
-
reload:
|
|
3132
|
+
options: C,
|
|
3133
|
+
loading: T,
|
|
3134
|
+
labelForValue: O,
|
|
3135
|
+
labelsForValues: a((e) => e?.length ? e.map((e) => O(e)).join(", ") : "—", [O]),
|
|
3136
|
+
optionForValue: a((e) => C.find((t) => t.value === e), [C]),
|
|
3137
|
+
reload: D
|
|
2650
3138
|
};
|
|
2651
3139
|
}
|
|
2652
3140
|
//#endregion
|
|
3141
|
+
//#region src/crud/fields/ReferenceInputActions.tsx
|
|
3142
|
+
function hi({ reference: e, referenceForm: t, referencePermissions: n, referenceTitle: r, referenceDefaultValues: i, referenceModalWidth: a, selectedId: o, disabled: s, onCreated: c, onUpdated: l }) {
|
|
3143
|
+
let d = Y(), f = r ?? e, p = !!(e && t) && X(d, n, "add"), m = !!(e && t && o != null && o !== "") && X(d, n, "change"), [h, g] = u(null);
|
|
3144
|
+
return !p && !m ? null : /* @__PURE__ */ q(G, { children: [/* @__PURE__ */ q(R, {
|
|
3145
|
+
size: 4,
|
|
3146
|
+
children: [p ? /* @__PURE__ */ K(H, {
|
|
3147
|
+
title: `Add ${f ?? "record"}`,
|
|
3148
|
+
children: /* @__PURE__ */ K(C, {
|
|
3149
|
+
type: "default",
|
|
3150
|
+
icon: /* @__PURE__ */ K(_e, {}),
|
|
3151
|
+
disabled: s,
|
|
3152
|
+
"aria-label": `Add ${f ?? "record"}`,
|
|
3153
|
+
onClick: () => g("new")
|
|
3154
|
+
})
|
|
3155
|
+
}) : null, m ? /* @__PURE__ */ K(H, {
|
|
3156
|
+
title: `Edit ${f ?? "record"}`,
|
|
3157
|
+
children: /* @__PURE__ */ K(C, {
|
|
3158
|
+
type: "default",
|
|
3159
|
+
icon: /* @__PURE__ */ K(de, {}),
|
|
3160
|
+
disabled: s,
|
|
3161
|
+
"aria-label": `Edit ${f ?? "record"}`,
|
|
3162
|
+
onClick: () => g(String(o))
|
|
3163
|
+
})
|
|
3164
|
+
}) : null]
|
|
3165
|
+
}), e && t && h != null ? /* @__PURE__ */ K(_r, {
|
|
3166
|
+
resource: e,
|
|
3167
|
+
editId: h,
|
|
3168
|
+
onClose: () => g(null),
|
|
3169
|
+
title: h === "new" ? `New ${f ?? e}` : `Edit ${f ?? e}`,
|
|
3170
|
+
permissions: n,
|
|
3171
|
+
defaultValues: h === "new" ? i : void 0,
|
|
3172
|
+
width: a,
|
|
3173
|
+
onSuccess: (e) => {
|
|
3174
|
+
let t = e;
|
|
3175
|
+
h === "new" ? c?.(t) : l?.(t);
|
|
3176
|
+
},
|
|
3177
|
+
children: t
|
|
3178
|
+
}) : null] });
|
|
3179
|
+
}
|
|
3180
|
+
//#endregion
|
|
2653
3181
|
//#region src/crud/fields/ReferenceField.tsx
|
|
2654
|
-
function
|
|
2655
|
-
let [
|
|
3182
|
+
function gi({ reference: e, choices: t, optionLabel: n = "name", optionValue: r = "id", search: i, allowClear: a, disabled: o, inputStyle: s, onValueChange: l, lazy: d = !0, fetchSelected: f = !0, value: p, onChange: m, fieldName: h, selectedRecords: g, referenceForm: _, referencePermissions: v, referenceTitle: y, referenceDefaultValues: b, referenceModalWidth: x, referenceActions: S = !0 }) {
|
|
3183
|
+
let [C, w] = u(), [T, E] = u(!1), D = T || !!C, O = ti(p, r), { options: k, loading: A, optionForValue: j, reload: M } = mi(t, e, n, r, i ? C : void 0, {
|
|
3184
|
+
lazy: d,
|
|
3185
|
+
active: D,
|
|
3186
|
+
selectedValues: p,
|
|
3187
|
+
selectedRecords: g,
|
|
3188
|
+
fetchSelected: f
|
|
3189
|
+
}), N = c(() => k.map((e) => ({
|
|
2656
3190
|
label: e.label,
|
|
2657
3191
|
value: e.value
|
|
2658
|
-
})), [
|
|
2659
|
-
|
|
3192
|
+
})), [k]), P = (e) => {
|
|
3193
|
+
let t = e[r];
|
|
3194
|
+
m(t), l?.(t, {
|
|
3195
|
+
label: ai(e, n),
|
|
3196
|
+
value: t,
|
|
3197
|
+
record: e
|
|
3198
|
+
}, { name: h }), M();
|
|
3199
|
+
}, F = /* @__PURE__ */ K(L, {
|
|
3200
|
+
value: O,
|
|
3201
|
+
onChange: (e) => {
|
|
3202
|
+
m(e), l?.(e, j(e), { name: h });
|
|
3203
|
+
},
|
|
3204
|
+
options: N,
|
|
3205
|
+
loading: A,
|
|
3206
|
+
notFoundContent: ci(A),
|
|
3207
|
+
showSearch: i,
|
|
3208
|
+
filterOption: i ? !1 : void 0,
|
|
3209
|
+
onSearch: i ? w : void 0,
|
|
3210
|
+
onDropdownVisibleChange: (e) => {
|
|
3211
|
+
E(e), e || w(void 0);
|
|
3212
|
+
},
|
|
3213
|
+
allowClear: a,
|
|
3214
|
+
disabled: o,
|
|
3215
|
+
optionFilterProp: "label",
|
|
3216
|
+
style: {
|
|
3217
|
+
width: "100%",
|
|
3218
|
+
minWidth: 160,
|
|
3219
|
+
...s
|
|
3220
|
+
}
|
|
3221
|
+
});
|
|
3222
|
+
return S ? /* @__PURE__ */ q("div", {
|
|
3223
|
+
style: {
|
|
3224
|
+
display: "flex",
|
|
3225
|
+
gap: 8,
|
|
3226
|
+
width: "100%",
|
|
3227
|
+
alignItems: "flex-start"
|
|
3228
|
+
},
|
|
3229
|
+
children: [/* @__PURE__ */ K("div", {
|
|
3230
|
+
style: {
|
|
3231
|
+
flex: 1,
|
|
3232
|
+
minWidth: 0
|
|
3233
|
+
},
|
|
3234
|
+
children: F
|
|
3235
|
+
}), /* @__PURE__ */ K(hi, {
|
|
3236
|
+
reference: e,
|
|
3237
|
+
referenceForm: _,
|
|
3238
|
+
referencePermissions: v,
|
|
3239
|
+
referenceTitle: y,
|
|
3240
|
+
referenceDefaultValues: b,
|
|
3241
|
+
referenceModalWidth: x,
|
|
3242
|
+
selectedId: O,
|
|
3243
|
+
disabled: o,
|
|
3244
|
+
onCreated: P,
|
|
3245
|
+
onUpdated: () => void M()
|
|
3246
|
+
})]
|
|
3247
|
+
}) : F;
|
|
3248
|
+
}
|
|
3249
|
+
function _i({ source: e, name: t, label: n, reference: r, choices: i, optionLabel: a = "name", optionValue: o = "id", required: s, rules: c, search: l, allowClear: u, disabled: d, hideLabel: f, inputStyle: p, onValueChange: m, lazy: h = !0, recordSource: g, fetchSelected: _ = !0, referenceForm: v, referencePermissions: y, referenceTitle: b, referenceDefaultValues: x, referenceModalWidth: S, referenceActions: C = !0 }) {
|
|
3250
|
+
let w = Oe({
|
|
3251
|
+
name: g ?? "",
|
|
3252
|
+
disabled: !g
|
|
3253
|
+
});
|
|
3254
|
+
return /* @__PURE__ */ K($, {
|
|
2660
3255
|
source: e,
|
|
2661
3256
|
name: t,
|
|
2662
3257
|
label: n,
|
|
2663
|
-
required:
|
|
2664
|
-
rules:
|
|
2665
|
-
hideLabel:
|
|
2666
|
-
children: ({ value: e, onChange: t, disabled: n, name:
|
|
3258
|
+
required: s,
|
|
3259
|
+
rules: c,
|
|
3260
|
+
hideLabel: f,
|
|
3261
|
+
children: ({ value: e, onChange: t, disabled: n, name: s }) => /* @__PURE__ */ K(gi, {
|
|
3262
|
+
reference: r,
|
|
3263
|
+
choices: i,
|
|
3264
|
+
optionLabel: a,
|
|
3265
|
+
optionValue: o,
|
|
3266
|
+
search: l,
|
|
3267
|
+
allowClear: u,
|
|
3268
|
+
disabled: n || d,
|
|
3269
|
+
inputStyle: p,
|
|
3270
|
+
onValueChange: m,
|
|
3271
|
+
lazy: h,
|
|
3272
|
+
fetchSelected: _,
|
|
2667
3273
|
value: e,
|
|
2668
|
-
onChange:
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
3274
|
+
onChange: t,
|
|
3275
|
+
fieldName: s,
|
|
3276
|
+
selectedRecords: g ? w : void 0,
|
|
3277
|
+
referenceForm: v,
|
|
3278
|
+
referencePermissions: y,
|
|
3279
|
+
referenceTitle: b,
|
|
3280
|
+
referenceDefaultValues: x,
|
|
3281
|
+
referenceModalWidth: S,
|
|
3282
|
+
referenceActions: C
|
|
3283
|
+
})
|
|
3284
|
+
});
|
|
3285
|
+
}
|
|
3286
|
+
//#endregion
|
|
3287
|
+
//#region src/crud/fields/ReferenceManyField.tsx
|
|
3288
|
+
function vi({ reference: e, choices: t, optionLabel: n = "name", optionValue: r = "id", search: i, allowClear: a = !0, lazy: o = !0, fetchSelected: s = !0, value: l, onChange: d, disabled: f, selectedRecords: p, referenceForm: m, referencePermissions: h, referenceTitle: g, referenceDefaultValues: _, referenceModalWidth: v, referenceActions: y = !0 }) {
|
|
3289
|
+
let [b, x] = u(), [S, C] = u(!1), w = S || !!b, T = ni(l, r), { options: E, loading: D, reload: O } = mi(t, e, n, r, i ? b : void 0, {
|
|
3290
|
+
lazy: o,
|
|
3291
|
+
active: w,
|
|
3292
|
+
selectedValues: l,
|
|
3293
|
+
selectedRecords: p,
|
|
3294
|
+
fetchSelected: s
|
|
3295
|
+
}), k = /* @__PURE__ */ K(L, {
|
|
3296
|
+
mode: "multiple",
|
|
3297
|
+
value: T,
|
|
3298
|
+
onChange: d,
|
|
3299
|
+
options: c(() => E.map((e) => ({
|
|
3300
|
+
label: e.label,
|
|
3301
|
+
value: e.value
|
|
3302
|
+
})), [E]),
|
|
3303
|
+
loading: D,
|
|
3304
|
+
notFoundContent: ci(D),
|
|
3305
|
+
showSearch: i,
|
|
3306
|
+
filterOption: i ? !1 : void 0,
|
|
3307
|
+
onSearch: i ? x : void 0,
|
|
3308
|
+
onDropdownVisibleChange: (e) => {
|
|
3309
|
+
C(e), e || x(void 0);
|
|
3310
|
+
},
|
|
3311
|
+
allowClear: a,
|
|
3312
|
+
disabled: f,
|
|
3313
|
+
optionFilterProp: "label",
|
|
3314
|
+
style: { width: "100%" }
|
|
3315
|
+
});
|
|
3316
|
+
return y ? /* @__PURE__ */ q("div", {
|
|
3317
|
+
style: {
|
|
3318
|
+
display: "flex",
|
|
3319
|
+
gap: 8,
|
|
3320
|
+
width: "100%",
|
|
3321
|
+
alignItems: "flex-start"
|
|
3322
|
+
},
|
|
3323
|
+
children: [/* @__PURE__ */ K("div", {
|
|
2679
3324
|
style: {
|
|
2680
|
-
|
|
2681
|
-
minWidth:
|
|
2682
|
-
|
|
3325
|
+
flex: 1,
|
|
3326
|
+
minWidth: 0
|
|
3327
|
+
},
|
|
3328
|
+
children: k
|
|
3329
|
+
}), /* @__PURE__ */ K(hi, {
|
|
3330
|
+
reference: e,
|
|
3331
|
+
referenceForm: m,
|
|
3332
|
+
referencePermissions: h,
|
|
3333
|
+
referenceTitle: g,
|
|
3334
|
+
referenceDefaultValues: _,
|
|
3335
|
+
referenceModalWidth: v,
|
|
3336
|
+
disabled: f,
|
|
3337
|
+
onCreated: (e) => {
|
|
3338
|
+
let t = e[r], n = Array.isArray(T) ? T : [];
|
|
3339
|
+
if (n.some((e) => e === t)) {
|
|
3340
|
+
O();
|
|
3341
|
+
return;
|
|
3342
|
+
}
|
|
3343
|
+
d([...n, t]), O();
|
|
2683
3344
|
}
|
|
3345
|
+
})]
|
|
3346
|
+
}) : k;
|
|
3347
|
+
}
|
|
3348
|
+
function yi({ source: e, name: t, label: n, reference: r, choices: i, optionLabel: a = "name", optionValue: o = "id", required: s, rules: c, search: l, allowClear: u = !0, hideLabel: d, lazy: f = !0, recordSource: p, fetchSelected: m = !0, referenceForm: h, referencePermissions: g, referenceTitle: _, referenceDefaultValues: v, referenceModalWidth: y, referenceActions: b = !0 }) {
|
|
3349
|
+
let x = Oe({
|
|
3350
|
+
name: p ?? "",
|
|
3351
|
+
disabled: !p
|
|
3352
|
+
});
|
|
3353
|
+
return /* @__PURE__ */ K($, {
|
|
3354
|
+
source: e,
|
|
3355
|
+
name: t,
|
|
3356
|
+
label: n,
|
|
3357
|
+
required: s,
|
|
3358
|
+
rules: c,
|
|
3359
|
+
hideLabel: d,
|
|
3360
|
+
children: ({ value: e, onChange: t, disabled: n }) => /* @__PURE__ */ K(vi, {
|
|
3361
|
+
reference: r,
|
|
3362
|
+
choices: i,
|
|
3363
|
+
optionLabel: a,
|
|
3364
|
+
optionValue: o,
|
|
3365
|
+
search: l,
|
|
3366
|
+
allowClear: u,
|
|
3367
|
+
lazy: f,
|
|
3368
|
+
fetchSelected: m,
|
|
3369
|
+
value: e,
|
|
3370
|
+
onChange: t,
|
|
3371
|
+
disabled: n,
|
|
3372
|
+
selectedRecords: p ? x : void 0,
|
|
3373
|
+
referenceForm: h,
|
|
3374
|
+
referencePermissions: g,
|
|
3375
|
+
referenceTitle: _,
|
|
3376
|
+
referenceDefaultValues: v,
|
|
3377
|
+
referenceModalWidth: y,
|
|
3378
|
+
referenceActions: b
|
|
2684
3379
|
})
|
|
2685
3380
|
});
|
|
2686
3381
|
}
|
|
2687
3382
|
//#endregion
|
|
2688
|
-
//#region src/crud/fields/
|
|
2689
|
-
function
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
3383
|
+
//#region src/crud/fields/uploadFieldUtils.ts
|
|
3384
|
+
function bi(e) {
|
|
3385
|
+
return e instanceof File ? !0 : typeof e == "string" && e.length > 0;
|
|
3386
|
+
}
|
|
3387
|
+
function xi(e) {
|
|
3388
|
+
if (e instanceof File) return e.name;
|
|
3389
|
+
if (typeof e == "string" && e.length > 0) try {
|
|
3390
|
+
return new URL(e, "http://local").pathname.split("/").filter(Boolean).pop() || e;
|
|
3391
|
+
} catch {
|
|
3392
|
+
return e.split("/").filter(Boolean).pop() || e;
|
|
3393
|
+
}
|
|
3394
|
+
}
|
|
3395
|
+
//#endregion
|
|
3396
|
+
//#region src/crud/fields/useUploadPreviewUrl.ts
|
|
3397
|
+
function Si(e) {
|
|
3398
|
+
let [t, n] = u();
|
|
3399
|
+
if (s(() => {
|
|
3400
|
+
if (e instanceof File) {
|
|
3401
|
+
let t = URL.createObjectURL(e);
|
|
3402
|
+
return n(t), () => URL.revokeObjectURL(t);
|
|
3403
|
+
}
|
|
3404
|
+
n(void 0);
|
|
3405
|
+
}, [e]), e instanceof File) return t;
|
|
3406
|
+
if (typeof e == "string" && e.length > 0) return e;
|
|
3407
|
+
}
|
|
3408
|
+
//#endregion
|
|
3409
|
+
//#region src/crud/fields/ImageField.tsx
|
|
3410
|
+
function Ci({ value: e, onChange: t, disabled: n, clearable: r, accept: i = "image/*", previewWidth: a = 200 }) {
|
|
3411
|
+
let o = l(null), s = Si(e), c = r && bi(e);
|
|
3412
|
+
return /* @__PURE__ */ q(R, {
|
|
3413
|
+
direction: "vertical",
|
|
3414
|
+
size: "middle",
|
|
3415
|
+
style: { width: "100%" },
|
|
3416
|
+
children: [
|
|
3417
|
+
s ? /* @__PURE__ */ K(M, {
|
|
3418
|
+
src: s,
|
|
3419
|
+
alt: "",
|
|
3420
|
+
style: {
|
|
3421
|
+
maxWidth: a,
|
|
3422
|
+
maxHeight: a,
|
|
3423
|
+
objectFit: "contain"
|
|
3424
|
+
}
|
|
3425
|
+
}) : null,
|
|
3426
|
+
/* @__PURE__ */ q(R, {
|
|
3427
|
+
wrap: !0,
|
|
3428
|
+
children: [/* @__PURE__ */ K(C, {
|
|
3429
|
+
icon: /* @__PURE__ */ K(be, {}),
|
|
3430
|
+
disabled: n,
|
|
3431
|
+
onClick: () => o.current?.click(),
|
|
3432
|
+
children: "Choose image"
|
|
3433
|
+
}), c ? /* @__PURE__ */ K(C, {
|
|
3434
|
+
icon: /* @__PURE__ */ K(le, {}),
|
|
3435
|
+
disabled: n,
|
|
3436
|
+
onClick: () => {
|
|
3437
|
+
t(null), o.current && (o.current.value = "");
|
|
3438
|
+
},
|
|
3439
|
+
children: "Clear"
|
|
3440
|
+
}) : null]
|
|
3441
|
+
}),
|
|
3442
|
+
/* @__PURE__ */ K("input", {
|
|
3443
|
+
ref: o,
|
|
3444
|
+
type: "file",
|
|
3445
|
+
accept: i,
|
|
3446
|
+
disabled: n,
|
|
3447
|
+
tabIndex: -1,
|
|
3448
|
+
"aria-hidden": !0,
|
|
3449
|
+
style: { display: "none" },
|
|
3450
|
+
onChange: (e) => {
|
|
3451
|
+
let n = e.target.files?.[0];
|
|
3452
|
+
t(n ?? null), e.target.value = "";
|
|
3453
|
+
}
|
|
3454
|
+
})
|
|
3455
|
+
]
|
|
3456
|
+
});
|
|
3457
|
+
}
|
|
3458
|
+
function wi({ source: e, name: t, label: n, required: r, rules: i, hideLabel: a, clearable: o, accept: s, previewWidth: c }) {
|
|
3459
|
+
return /* @__PURE__ */ K($, {
|
|
2695
3460
|
source: e,
|
|
2696
3461
|
name: t,
|
|
2697
3462
|
label: n,
|
|
2698
|
-
required:
|
|
2699
|
-
rules:
|
|
2700
|
-
hideLabel:
|
|
2701
|
-
children: ({ value: e, onChange: t, disabled: n }) => /* @__PURE__ */
|
|
2702
|
-
|
|
2703
|
-
value: e ?? [],
|
|
3463
|
+
required: r,
|
|
3464
|
+
rules: i,
|
|
3465
|
+
hideLabel: a,
|
|
3466
|
+
children: ({ value: e, onChange: t, disabled: n }) => /* @__PURE__ */ K(Ci, {
|
|
3467
|
+
value: e,
|
|
2704
3468
|
onChange: t,
|
|
2705
|
-
options: v,
|
|
2706
|
-
loading: _,
|
|
2707
|
-
showSearch: d,
|
|
2708
|
-
filterOption: d ? !1 : void 0,
|
|
2709
|
-
onSearch: d ? h : void 0,
|
|
2710
|
-
allowClear: f,
|
|
2711
3469
|
disabled: n,
|
|
2712
|
-
|
|
2713
|
-
|
|
3470
|
+
clearable: o,
|
|
3471
|
+
accept: s,
|
|
3472
|
+
previewWidth: c
|
|
3473
|
+
})
|
|
3474
|
+
});
|
|
3475
|
+
}
|
|
3476
|
+
//#endregion
|
|
3477
|
+
//#region src/crud/fields/FileField.tsx
|
|
3478
|
+
function Ti({ value: e, onChange: t, disabled: n, clearable: r, accept: i }) {
|
|
3479
|
+
let a = l(null), o = xi(e), s = typeof e == "string" && e.length > 0 ? e : void 0, c = r && bi(e);
|
|
3480
|
+
return /* @__PURE__ */ q(R, {
|
|
3481
|
+
direction: "vertical",
|
|
3482
|
+
size: "middle",
|
|
3483
|
+
style: { width: "100%" },
|
|
3484
|
+
children: [
|
|
3485
|
+
o ? /* @__PURE__ */ q(R, { children: [/* @__PURE__ */ K(ge, {}), s ? /* @__PURE__ */ K(U.Link, {
|
|
3486
|
+
href: s,
|
|
3487
|
+
target: "_blank",
|
|
3488
|
+
rel: "noopener noreferrer",
|
|
3489
|
+
children: o
|
|
3490
|
+
}) : /* @__PURE__ */ K(U.Text, { children: o })] }) : null,
|
|
3491
|
+
/* @__PURE__ */ q(R, {
|
|
3492
|
+
wrap: !0,
|
|
3493
|
+
children: [/* @__PURE__ */ K(C, {
|
|
3494
|
+
icon: /* @__PURE__ */ K(be, {}),
|
|
3495
|
+
disabled: n,
|
|
3496
|
+
onClick: () => a.current?.click(),
|
|
3497
|
+
children: "Choose file"
|
|
3498
|
+
}), c ? /* @__PURE__ */ K(C, {
|
|
3499
|
+
icon: /* @__PURE__ */ K(le, {}),
|
|
3500
|
+
disabled: n,
|
|
3501
|
+
onClick: () => {
|
|
3502
|
+
t(null), a.current && (a.current.value = "");
|
|
3503
|
+
},
|
|
3504
|
+
children: "Clear"
|
|
3505
|
+
}) : null]
|
|
3506
|
+
}),
|
|
3507
|
+
/* @__PURE__ */ K("input", {
|
|
3508
|
+
ref: a,
|
|
3509
|
+
type: "file",
|
|
3510
|
+
accept: i,
|
|
3511
|
+
disabled: n,
|
|
3512
|
+
tabIndex: -1,
|
|
3513
|
+
"aria-hidden": !0,
|
|
3514
|
+
style: { display: "none" },
|
|
3515
|
+
onChange: (e) => {
|
|
3516
|
+
let n = e.target.files?.[0];
|
|
3517
|
+
t(n ?? null), e.target.value = "";
|
|
3518
|
+
}
|
|
3519
|
+
})
|
|
3520
|
+
]
|
|
3521
|
+
});
|
|
3522
|
+
}
|
|
3523
|
+
function Ei({ source: e, name: t, label: n, required: r, rules: i, hideLabel: a, clearable: o, accept: s }) {
|
|
3524
|
+
return /* @__PURE__ */ K($, {
|
|
3525
|
+
source: e,
|
|
3526
|
+
name: t,
|
|
3527
|
+
label: n,
|
|
3528
|
+
required: r,
|
|
3529
|
+
rules: i,
|
|
3530
|
+
hideLabel: a,
|
|
3531
|
+
children: ({ value: e, onChange: t, disabled: n }) => /* @__PURE__ */ K(Ti, {
|
|
3532
|
+
value: e,
|
|
3533
|
+
onChange: t,
|
|
3534
|
+
disabled: n,
|
|
3535
|
+
clearable: o,
|
|
3536
|
+
accept: s
|
|
2714
3537
|
})
|
|
2715
3538
|
});
|
|
2716
3539
|
}
|
|
2717
3540
|
//#endregion
|
|
2718
3541
|
//#region src/crud/columns/TextColumn.tsx
|
|
2719
|
-
function
|
|
2720
|
-
return
|
|
3542
|
+
function Di({ source: e, label: t, sortable: n = !0 }) {
|
|
3543
|
+
return Q(c(() => ({
|
|
2721
3544
|
key: e,
|
|
2722
3545
|
source: e,
|
|
2723
3546
|
label: t,
|
|
@@ -2734,13 +3557,13 @@ function _r({ source: e, label: t, sortable: n = !0 }) {
|
|
|
2734
3557
|
n
|
|
2735
3558
|
])), null;
|
|
2736
3559
|
}
|
|
2737
|
-
function
|
|
2738
|
-
return typeof n == "function" ? n(e) : n ?
|
|
3560
|
+
function Oi(e, t, n) {
|
|
3561
|
+
return typeof n == "function" ? n(e) : n ? Jn(e, n) : e[t];
|
|
2739
3562
|
}
|
|
2740
3563
|
//#endregion
|
|
2741
3564
|
//#region src/crud/columns/NumberColumn.tsx
|
|
2742
|
-
function
|
|
2743
|
-
return
|
|
3565
|
+
function ki({ source: e, label: t, sortable: n = !0 }) {
|
|
3566
|
+
return Q(c(() => ({
|
|
2744
3567
|
key: e,
|
|
2745
3568
|
source: e,
|
|
2746
3569
|
label: t,
|
|
@@ -2759,8 +3582,8 @@ function yr({ source: e, label: t, sortable: n = !0 }) {
|
|
|
2759
3582
|
}
|
|
2760
3583
|
//#endregion
|
|
2761
3584
|
//#region src/crud/columns/BooleanColumn.tsx
|
|
2762
|
-
function
|
|
2763
|
-
return
|
|
3585
|
+
function Ai({ source: e, label: t, sortable: n = !0 }) {
|
|
3586
|
+
return Q(c(() => ({
|
|
2764
3587
|
key: e,
|
|
2765
3588
|
source: e,
|
|
2766
3589
|
label: t,
|
|
@@ -2780,8 +3603,8 @@ function br({ source: e, label: t, sortable: n = !0 }) {
|
|
|
2780
3603
|
}
|
|
2781
3604
|
//#endregion
|
|
2782
3605
|
//#region src/crud/columns/DateColumn.tsx
|
|
2783
|
-
function
|
|
2784
|
-
return
|
|
3606
|
+
function ji({ source: e, label: t, sortable: n = !0 }) {
|
|
3607
|
+
return Q(c(() => ({
|
|
2785
3608
|
key: e,
|
|
2786
3609
|
source: e,
|
|
2787
3610
|
label: t,
|
|
@@ -2801,27 +3624,27 @@ function xr({ source: e, label: t, sortable: n = !0 }) {
|
|
|
2801
3624
|
}
|
|
2802
3625
|
//#endregion
|
|
2803
3626
|
//#region src/crud/columns/ReferenceColumn.tsx
|
|
2804
|
-
function
|
|
2805
|
-
let { labelForValue: s } =
|
|
2806
|
-
if (typeof n == "function") return /* @__PURE__ */
|
|
3627
|
+
function Mi({ record: e, source: t, display: n, reference: r, choices: i, optionLabel: a, optionValue: o }) {
|
|
3628
|
+
let { labelForValue: s } = mi(i, r, a, o), c = e[t];
|
|
3629
|
+
if (typeof n == "function") return /* @__PURE__ */ K(G, { children: n(e) });
|
|
2807
3630
|
if (n && n !== t) {
|
|
2808
|
-
let r =
|
|
2809
|
-
return /* @__PURE__ */
|
|
3631
|
+
let r = Oi(e, t, n);
|
|
3632
|
+
return /* @__PURE__ */ K(G, { children: r == null ? "—" : String(r) });
|
|
2810
3633
|
}
|
|
2811
|
-
return /* @__PURE__ */
|
|
3634
|
+
return /* @__PURE__ */ K(G, { children: s(c) });
|
|
2812
3635
|
}
|
|
2813
|
-
function
|
|
2814
|
-
return
|
|
3636
|
+
function Ni({ source: e, label: t, reference: n, choices: r, optionLabel: i = "name", optionValue: a = "id", display: o, sortable: s = !0 }) {
|
|
3637
|
+
return Q(c(() => ({
|
|
2815
3638
|
key: e,
|
|
2816
3639
|
source: e,
|
|
2817
3640
|
label: t,
|
|
2818
|
-
sortable:
|
|
3641
|
+
sortable: s,
|
|
2819
3642
|
buildColumn: () => ({
|
|
2820
3643
|
title: t ?? e,
|
|
2821
3644
|
dataIndex: e,
|
|
2822
3645
|
key: e,
|
|
2823
|
-
sorter:
|
|
2824
|
-
render: (s, c) => /* @__PURE__ */
|
|
3646
|
+
sorter: s ? !0 : void 0,
|
|
3647
|
+
render: (s, c) => /* @__PURE__ */ K(Mi, {
|
|
2825
3648
|
record: c,
|
|
2826
3649
|
source: e,
|
|
2827
3650
|
label: t,
|
|
@@ -2835,7 +3658,7 @@ function Cr({ source: e, label: t, reference: n, choices: r, optionLabel: i = "n
|
|
|
2835
3658
|
}), [
|
|
2836
3659
|
e,
|
|
2837
3660
|
t,
|
|
2838
|
-
|
|
3661
|
+
s,
|
|
2839
3662
|
n,
|
|
2840
3663
|
r,
|
|
2841
3664
|
i,
|
|
@@ -2845,12 +3668,12 @@ function Cr({ source: e, label: t, reference: n, choices: r, optionLabel: i = "n
|
|
|
2845
3668
|
}
|
|
2846
3669
|
//#endregion
|
|
2847
3670
|
//#region src/crud/columns/ReferenceManyColumn.tsx
|
|
2848
|
-
function
|
|
2849
|
-
let { labelsForValues: o } =
|
|
2850
|
-
return /* @__PURE__ */
|
|
3671
|
+
function Pi({ record: e, source: t, reference: n, choices: r, optionLabel: i, optionValue: a }) {
|
|
3672
|
+
let { labelsForValues: o } = mi(r, n, i, a), s = e[t];
|
|
3673
|
+
return /* @__PURE__ */ K(G, { children: o(Array.isArray(s) ? s : []) });
|
|
2851
3674
|
}
|
|
2852
|
-
function
|
|
2853
|
-
return
|
|
3675
|
+
function Fi({ source: e, label: t, reference: n, choices: r, optionLabel: i = "name", optionValue: a = "id", sortable: o = !1 }) {
|
|
3676
|
+
return Q(c(() => ({
|
|
2854
3677
|
key: e,
|
|
2855
3678
|
source: e,
|
|
2856
3679
|
label: t,
|
|
@@ -2860,7 +3683,7 @@ function Tr({ source: e, label: t, reference: n, choices: r, optionLabel: i = "n
|
|
|
2860
3683
|
dataIndex: e,
|
|
2861
3684
|
key: e,
|
|
2862
3685
|
sorter: o ? !0 : void 0,
|
|
2863
|
-
render: (t, o) => /* @__PURE__ */
|
|
3686
|
+
render: (t, o) => /* @__PURE__ */ K(Pi, {
|
|
2864
3687
|
record: o,
|
|
2865
3688
|
source: e,
|
|
2866
3689
|
reference: n,
|
|
@@ -2880,9 +3703,44 @@ function Tr({ source: e, label: t, reference: n, choices: r, optionLabel: i = "n
|
|
|
2880
3703
|
])), null;
|
|
2881
3704
|
}
|
|
2882
3705
|
//#endregion
|
|
3706
|
+
//#region src/crud/columns/ImageColumn.tsx
|
|
3707
|
+
function Ii({ source: e, label: t, sortable: n = !1, width: r = 40, height: i = 40, objectFit: a = "cover", borderRadius: o = 4, alt: s = "" }) {
|
|
3708
|
+
return Q(c(() => ({
|
|
3709
|
+
key: e,
|
|
3710
|
+
source: e,
|
|
3711
|
+
label: t,
|
|
3712
|
+
sortable: n,
|
|
3713
|
+
buildColumn: () => ({
|
|
3714
|
+
title: t ?? e,
|
|
3715
|
+
dataIndex: e,
|
|
3716
|
+
key: e,
|
|
3717
|
+
sorter: n ? !0 : void 0,
|
|
3718
|
+
render: (e) => e == null || e === "" ? null : /* @__PURE__ */ K("img", {
|
|
3719
|
+
src: String(e),
|
|
3720
|
+
alt: s,
|
|
3721
|
+
style: {
|
|
3722
|
+
width: r,
|
|
3723
|
+
height: i,
|
|
3724
|
+
objectFit: a,
|
|
3725
|
+
borderRadius: o
|
|
3726
|
+
}
|
|
3727
|
+
})
|
|
3728
|
+
})
|
|
3729
|
+
}), [
|
|
3730
|
+
e,
|
|
3731
|
+
t,
|
|
3732
|
+
n,
|
|
3733
|
+
r,
|
|
3734
|
+
i,
|
|
3735
|
+
a,
|
|
3736
|
+
o,
|
|
3737
|
+
s
|
|
3738
|
+
])), null;
|
|
3739
|
+
}
|
|
3740
|
+
//#endregion
|
|
2883
3741
|
//#region src/crud/columns/CustomColumn.tsx
|
|
2884
|
-
function
|
|
2885
|
-
return
|
|
3742
|
+
function Li({ source: e, label: t, sortable: n = !1, render: r }) {
|
|
3743
|
+
return Q(c(() => ({
|
|
2886
3744
|
key: e,
|
|
2887
3745
|
source: e,
|
|
2888
3746
|
label: t,
|
|
@@ -2901,12 +3759,12 @@ function Er({ source: e, label: t, sortable: n = !1, render: r }) {
|
|
|
2901
3759
|
}
|
|
2902
3760
|
//#endregion
|
|
2903
3761
|
//#region src/crud/filters/TextFilter.tsx
|
|
2904
|
-
function
|
|
2905
|
-
return
|
|
3762
|
+
function Ri({ source: e, label: t, placeholder: n }) {
|
|
3763
|
+
return jn(c(() => ({
|
|
2906
3764
|
key: e,
|
|
2907
3765
|
source: e,
|
|
2908
3766
|
label: t,
|
|
2909
|
-
render: ({ value: r, onChange: i }) => /* @__PURE__ */
|
|
3767
|
+
render: ({ value: r, onChange: i }) => /* @__PURE__ */ K(N, {
|
|
2910
3768
|
allowClear: !0,
|
|
2911
3769
|
placeholder: n ?? t ?? e,
|
|
2912
3770
|
value: r ?? "",
|
|
@@ -2921,12 +3779,12 @@ function Dr({ source: e, label: t, placeholder: n }) {
|
|
|
2921
3779
|
}
|
|
2922
3780
|
//#endregion
|
|
2923
3781
|
//#region src/crud/filters/NumberFilter.tsx
|
|
2924
|
-
function
|
|
2925
|
-
return
|
|
3782
|
+
function zi({ source: e, label: t }) {
|
|
3783
|
+
return jn(c(() => ({
|
|
2926
3784
|
key: e,
|
|
2927
3785
|
source: e,
|
|
2928
3786
|
label: t,
|
|
2929
|
-
render: ({ value: n, onChange: r }) => /* @__PURE__ */
|
|
3787
|
+
render: ({ value: n, onChange: r }) => /* @__PURE__ */ K(P, {
|
|
2930
3788
|
placeholder: t ?? e,
|
|
2931
3789
|
value: n,
|
|
2932
3790
|
onChange: (e) => r(e ?? void 0),
|
|
@@ -2936,12 +3794,12 @@ function Or({ source: e, label: t }) {
|
|
|
2936
3794
|
}
|
|
2937
3795
|
//#endregion
|
|
2938
3796
|
//#region src/crud/filters/BooleanFilter.tsx
|
|
2939
|
-
function
|
|
2940
|
-
return
|
|
3797
|
+
function Bi({ source: e, label: t }) {
|
|
3798
|
+
return jn(c(() => ({
|
|
2941
3799
|
key: e,
|
|
2942
3800
|
source: e,
|
|
2943
3801
|
label: t,
|
|
2944
|
-
render: ({ value: n, onChange: r }) => /* @__PURE__ */
|
|
3802
|
+
render: ({ value: n, onChange: r }) => /* @__PURE__ */ K(L, {
|
|
2945
3803
|
allowClear: !0,
|
|
2946
3804
|
placeholder: t ?? e,
|
|
2947
3805
|
value: n,
|
|
@@ -2959,15 +3817,15 @@ function kr({ source: e, label: t }) {
|
|
|
2959
3817
|
}
|
|
2960
3818
|
//#endregion
|
|
2961
3819
|
//#region src/crud/filters/DateFilter.tsx
|
|
2962
|
-
function
|
|
2963
|
-
return
|
|
3820
|
+
function Vi({ source: e, label: t }) {
|
|
3821
|
+
return jn(c(() => ({
|
|
2964
3822
|
key: e,
|
|
2965
3823
|
source: e,
|
|
2966
3824
|
label: t,
|
|
2967
|
-
render: ({ value: n, onChange: r }) => /* @__PURE__ */
|
|
3825
|
+
render: ({ value: n, onChange: r }) => /* @__PURE__ */ K(E, {
|
|
2968
3826
|
allowClear: !0,
|
|
2969
3827
|
placeholder: t ?? e,
|
|
2970
|
-
value: n ?
|
|
3828
|
+
value: n ? ke(String(n)) : null,
|
|
2971
3829
|
onChange: (e) => r(e ? e.format("YYYY-MM-DD") : void 0),
|
|
2972
3830
|
style: { minWidth: 160 }
|
|
2973
3831
|
})
|
|
@@ -2975,12 +3833,12 @@ function Ar({ source: e, label: t }) {
|
|
|
2975
3833
|
}
|
|
2976
3834
|
//#endregion
|
|
2977
3835
|
//#region src/crud/filters/SelectFilter.tsx
|
|
2978
|
-
function
|
|
2979
|
-
return
|
|
3836
|
+
function Hi({ source: e, label: t, choices: n, multiple: r }) {
|
|
3837
|
+
return jn(c(() => ({
|
|
2980
3838
|
key: e,
|
|
2981
3839
|
source: e,
|
|
2982
3840
|
label: t,
|
|
2983
|
-
render: ({ value: i, onChange: a }) => /* @__PURE__ */
|
|
3841
|
+
render: ({ value: i, onChange: a }) => /* @__PURE__ */ K(L, {
|
|
2984
3842
|
allowClear: !0,
|
|
2985
3843
|
mode: r ? "multiple" : void 0,
|
|
2986
3844
|
placeholder: t ?? e,
|
|
@@ -2998,32 +3856,41 @@ function jr({ source: e, label: t, choices: n, multiple: r }) {
|
|
|
2998
3856
|
}
|
|
2999
3857
|
//#endregion
|
|
3000
3858
|
//#region src/crud/filters/ReferenceFilter.tsx
|
|
3001
|
-
function
|
|
3002
|
-
let [
|
|
3003
|
-
|
|
3859
|
+
function Ui({ source: e, label: t, reference: n, choices: r, optionLabel: i, optionValue: a, multiple: o, search: s, lazy: c = !0, fetchSelected: l = !0, value: d, onChange: f }) {
|
|
3860
|
+
let [p, m] = u(), [h, g] = u(!1), { options: _, loading: v } = mi(r, n, i, a, s ? p : void 0, {
|
|
3861
|
+
lazy: c,
|
|
3862
|
+
active: h || !!p,
|
|
3863
|
+
selectedValues: d,
|
|
3864
|
+
fetchSelected: l
|
|
3865
|
+
});
|
|
3866
|
+
return /* @__PURE__ */ K(L, {
|
|
3004
3867
|
allowClear: !0,
|
|
3005
3868
|
mode: o ? "multiple" : void 0,
|
|
3006
3869
|
placeholder: t ?? e,
|
|
3007
|
-
value:
|
|
3008
|
-
onChange:
|
|
3009
|
-
options:
|
|
3870
|
+
value: d,
|
|
3871
|
+
onChange: f,
|
|
3872
|
+
options: _.map((e) => ({
|
|
3010
3873
|
label: e.label,
|
|
3011
3874
|
value: e.value
|
|
3012
3875
|
})),
|
|
3013
|
-
loading:
|
|
3876
|
+
loading: v,
|
|
3877
|
+
notFoundContent: ci(v),
|
|
3014
3878
|
showSearch: s,
|
|
3015
3879
|
filterOption: s ? !1 : void 0,
|
|
3016
|
-
onSearch: s ?
|
|
3880
|
+
onSearch: s ? m : void 0,
|
|
3881
|
+
onDropdownVisibleChange: (e) => {
|
|
3882
|
+
g(e), e || m(void 0);
|
|
3883
|
+
},
|
|
3017
3884
|
optionFilterProp: "label",
|
|
3018
3885
|
style: { minWidth: 180 }
|
|
3019
3886
|
});
|
|
3020
3887
|
}
|
|
3021
|
-
function
|
|
3022
|
-
return
|
|
3888
|
+
function Wi({ source: e, label: t, reference: n, choices: r, optionLabel: i = "name", optionValue: a = "id", multiple: o, search: s, lazy: l = !0, fetchSelected: u = !0 }) {
|
|
3889
|
+
return jn(c(() => ({
|
|
3023
3890
|
key: e,
|
|
3024
3891
|
source: e,
|
|
3025
3892
|
label: t,
|
|
3026
|
-
render: ({ value:
|
|
3893
|
+
render: ({ value: c, onChange: d }) => /* @__PURE__ */ K(Ui, {
|
|
3027
3894
|
source: e,
|
|
3028
3895
|
label: t,
|
|
3029
3896
|
reference: n,
|
|
@@ -3031,9 +3898,11 @@ function Nr({ source: e, label: t, reference: n, choices: r, optionLabel: i = "n
|
|
|
3031
3898
|
optionLabel: i,
|
|
3032
3899
|
optionValue: a,
|
|
3033
3900
|
multiple: o,
|
|
3034
|
-
search:
|
|
3035
|
-
|
|
3036
|
-
|
|
3901
|
+
search: s,
|
|
3902
|
+
lazy: l,
|
|
3903
|
+
fetchSelected: u,
|
|
3904
|
+
value: c,
|
|
3905
|
+
onChange: d
|
|
3037
3906
|
})
|
|
3038
3907
|
}), [
|
|
3039
3908
|
e,
|
|
@@ -3043,14 +3912,16 @@ function Nr({ source: e, label: t, reference: n, choices: r, optionLabel: i = "n
|
|
|
3043
3912
|
i,
|
|
3044
3913
|
a,
|
|
3045
3914
|
o,
|
|
3046
|
-
|
|
3915
|
+
s,
|
|
3916
|
+
l,
|
|
3917
|
+
u
|
|
3047
3918
|
])), null;
|
|
3048
3919
|
}
|
|
3049
|
-
function
|
|
3050
|
-
return /* @__PURE__ */
|
|
3920
|
+
function Gi(e) {
|
|
3921
|
+
return /* @__PURE__ */ K(Wi, {
|
|
3051
3922
|
...e,
|
|
3052
3923
|
multiple: !0
|
|
3053
3924
|
});
|
|
3054
3925
|
}
|
|
3055
3926
|
//#endregion
|
|
3056
|
-
export {
|
|
3927
|
+
export { Ot as AdminApp, gt as AdminLayout, Ie as AppThemeProvider, vn as AuthAlternateLink, yn as AuthPageLayout, Je as AuthProvider, Ai as BooleanColumn, Jr as BooleanField, Bi as BooleanFilter, Li as CustomColumn, At as DataProvider, ji as DateColumn, Xr as DateField, Vi as DateFilter, ze as DensitySwitch, It as EXPECTED_VALIDATION_BODY_HINT, $ as FieldWrapper, Ei as FileField, Ar as FilterBar, Ur as FormStep, Gr as FormSteps, Br as FormTab, Hr as FormTabs, _t as Guard, yt as GuestOnly, Ii as ImageColumn, wi as ImageField, Fr as InlineFormSet, Ir as InlineFormSetStacked, bn as LoginPage, ki as NumberColumn, qr as NumberField, zi as NumberFilter, $r as PasswordField, $e as PermissionsProvider, xn as PlaceholderPage, vt as Protected, Ni as ReferenceColumn, _i as ReferenceField, Wi as ReferenceFilter, Fi as ReferenceManyColumn, yi as ReferenceManyField, Gi as ReferenceManyFilter, bt as RequirePermission, jr as ResourceForm, _r as ResourceFormModal, Or as ResourceList, Zr as SelectField, Hi as SelectFilter, Di as TextColumn, Kr as TextField, Ri as TextFilter, Ve as ThemeSwitch, He as ThemeToolbar, dn as applyInMemoryListParams, Z as asStringMessages, Xn as buildFormPayload, Zn as buildInlineRowsPayload, ar as buildResourceFormSubmitBody, Pt as combineResourceHandlers, Dt as createAdminRouter, fn as createMemoryResourceHandlers, et as createPermissionsChecker, pn as createRestResourceHandlers, Ze as createSessionStorageAuthAdapter, Tt as deriveAuthPaths, Ht as describeNonStandardValidationBody, st as filterNavByPermission, ln as filterRows, Xt as finalizeFormErrors, Yt as flattenNestedArrayErrors, Gt as getErrorBody, Jn as getFormValue, xt as getRouteAccess, on as getRowById, Qn as hasUploadValues, Ft as isAbortError, Mr as nestedFieldPath, $t as parseDjangoDRFFormErrors, en as parseDotNetFormErrors, tn as parseNodeFormErrors, St as partitionAdminRoutes, ir as prepareFormSubmitBody, qt as resolveErrorBody, Yn as setFormValue, hn as toDjangoRestOrdering, rr as toFormData, _n as toJsonApiSort, gn as toODataOrderBy, pr as useAbortableEffect, Ye as useAuth, tt as useCan, mi as useChoices, jt as useDataProvider, wr as useListQueryState, Y as usePermissions, Vn as useRegisterPayloadField, Hn as useRegisterSectionField, Er as useResourceListContext, Le as useThemeMode };
|