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