ding-react-admin 1.0.4 → 2.0.4

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