@questpie/admin 3.2.4 → 3.2.6

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 (255) hide show
  1. package/dist/client/blocks/block-renderer.d.mts +2 -2
  2. package/dist/client/blocks/block-renderer.mjs +164 -339
  3. package/dist/client/components/actions/action-button.mjs +9 -9
  4. package/dist/client/components/actions/action-dialog.mjs +195 -493
  5. package/dist/client/components/actions/confirmation-dialog.mjs +44 -159
  6. package/dist/client/components/actions/header-actions.mjs +73 -165
  7. package/dist/client/components/admin-link.d.mts +2 -2
  8. package/dist/client/components/admin-link.mjs +40 -126
  9. package/dist/client/components/auth/auth-loading.mjs +9 -44
  10. package/dist/client/components/blocks/block-canvas.mjs +31 -95
  11. package/dist/client/components/blocks/block-editor-context.mjs +13 -57
  12. package/dist/client/components/blocks/block-editor-layout.mjs +72 -166
  13. package/dist/client/components/blocks/block-editor-provider.mjs +184 -245
  14. package/dist/client/components/blocks/block-fields-renderer.mjs +54 -229
  15. package/dist/client/components/blocks/block-insert-button.mjs +49 -165
  16. package/dist/client/components/blocks/block-item-menu.mjs +102 -301
  17. package/dist/client/components/blocks/block-item.mjs +136 -370
  18. package/dist/client/components/blocks/block-library-sidebar.mjs +103 -230
  19. package/dist/client/components/blocks/block-tree.mjs +12 -68
  20. package/dist/client/components/blocks/block-type-icon.mjs +14 -56
  21. package/dist/client/components/brand-logo.mjs +35 -149
  22. package/dist/client/components/component-renderer.mjs +42 -118
  23. package/dist/client/components/error-boundary.mjs +14 -58
  24. package/dist/client/components/fields/array-field.mjs +209 -521
  25. package/dist/client/components/fields/asset-preview-field.mjs +41 -141
  26. package/dist/client/components/fields/blocks-field/blocks-field.mjs +60 -156
  27. package/dist/client/components/fields/boolean-field.mjs +29 -59
  28. package/dist/client/components/fields/date-field.mjs +7 -37
  29. package/dist/client/components/fields/datetime-field.mjs +7 -38
  30. package/dist/client/components/fields/email-field.mjs +25 -54
  31. package/dist/client/components/fields/field-wrapper.mjs +30 -105
  32. package/dist/client/components/fields/json-field.mjs +94 -296
  33. package/dist/client/components/fields/locale-badge.mjs +6 -15
  34. package/dist/client/components/fields/number-field.mjs +27 -60
  35. package/dist/client/components/fields/object-array-field.mjs +283 -659
  36. package/dist/client/components/fields/object-field.mjs +165 -633
  37. package/dist/client/components/fields/relation/displays/cards-display.mjs +106 -220
  38. package/dist/client/components/fields/relation/displays/chips-display.mjs +78 -150
  39. package/dist/client/components/fields/relation/displays/grid-display.mjs +92 -186
  40. package/dist/client/components/fields/relation/displays/list-display.mjs +122 -239
  41. package/dist/client/components/fields/relation/displays/table-display.mjs +70 -244
  42. package/dist/client/components/fields/relation/relation-items-display.mjs +30 -126
  43. package/dist/client/components/fields/relation-field.mjs +10 -66
  44. package/dist/client/components/fields/relation-picker.mjs +18 -18
  45. package/dist/client/components/fields/relation-select.mjs +12 -12
  46. package/dist/client/components/fields/rich-text-editor/bubble-menu.mjs +80 -180
  47. package/dist/client/components/fields/rich-text-editor/image-popover.mjs +2 -2
  48. package/dist/client/components/fields/rich-text-editor/image-upload.mjs +13 -29
  49. package/dist/client/components/fields/rich-text-editor/index.mjs +195 -513
  50. package/dist/client/components/fields/rich-text-editor/slash-commands.mjs +61 -111
  51. package/dist/client/components/fields/rich-text-editor/table-controls.mjs +105 -415
  52. package/dist/client/components/fields/rich-text-editor/toolbar.mjs +256 -511
  53. package/dist/client/components/fields/rich-text-field.mjs +14 -53
  54. package/dist/client/components/fields/select-field.mjs +61 -72
  55. package/dist/client/components/fields/text-field.mjs +26 -59
  56. package/dist/client/components/fields/textarea-field.mjs +26 -58
  57. package/dist/client/components/fields/time-field.mjs +7 -35
  58. package/dist/client/components/fields/upload-field.mjs +47 -165
  59. package/dist/client/components/filter-builder/columns-tab.mjs +80 -280
  60. package/dist/client/components/filter-builder/filter-builder-sheet.mjs +197 -540
  61. package/dist/client/components/filter-builder/filters-tab.mjs +96 -386
  62. package/dist/client/components/filter-builder/saved-views-tab.mjs +133 -351
  63. package/dist/client/components/history-sidebar.mjs +285 -605
  64. package/dist/client/components/layout/field-layout-renderer.mjs +106 -254
  65. package/dist/client/components/locale-switcher.mjs +106 -228
  66. package/dist/client/components/media/media-grid.mjs +84 -273
  67. package/dist/client/components/media/media-picker-dialog.mjs +176 -476
  68. package/dist/client/components/preview/live-preview-mode.mjs +233 -458
  69. package/dist/client/components/preview/preview-pane.mjs +22 -22
  70. package/dist/client/components/primitives/asset-preview.mjs +290 -666
  71. package/dist/client/components/primitives/checkbox-input.mjs +9 -35
  72. package/dist/client/components/primitives/date-input.mjs +109 -327
  73. package/dist/client/components/primitives/dropzone.mjs +209 -336
  74. package/dist/client/components/primitives/field-select-control.mjs +12 -80
  75. package/dist/client/components/primitives/number-input.mjs +4 -4
  76. package/dist/client/components/primitives/select-multi.mjs +229 -572
  77. package/dist/client/components/primitives/select-single.mjs +179 -499
  78. package/dist/client/components/primitives/time-input.mjs +43 -117
  79. package/dist/client/components/primitives/toggle-input.mjs +9 -29
  80. package/dist/client/components/sheets/resource-sheet.mjs +61 -70
  81. package/dist/client/components/ui/accordion.mjs +35 -155
  82. package/dist/client/components/ui/alert.mjs +13 -68
  83. package/dist/client/components/ui/badge.mjs +9 -51
  84. package/dist/client/components/ui/button.mjs +8 -54
  85. package/dist/client/components/ui/card.mjs +37 -193
  86. package/dist/client/components/ui/checkbox.mjs +12 -68
  87. package/dist/client/components/ui/command.mjs +48 -219
  88. package/dist/client/components/ui/dialog.mjs +50 -262
  89. package/dist/client/components/ui/drawer.mjs +55 -259
  90. package/dist/client/components/ui/dropdown-menu.mjs +86 -427
  91. package/dist/client/components/ui/empty-state.mjs +28 -98
  92. package/dist/client/components/ui/field.mjs +73 -309
  93. package/dist/client/components/ui/input-group.mjs +42 -167
  94. package/dist/client/components/ui/input.mjs +7 -37
  95. package/dist/client/components/ui/kbd.mjs +6 -36
  96. package/dist/client/components/ui/label.mjs +7 -37
  97. package/dist/client/components/ui/popover.mjs +34 -169
  98. package/dist/client/components/ui/responsive-dialog.mjs +67 -273
  99. package/dist/client/components/ui/scroll-fade.mjs +63 -158
  100. package/dist/client/components/ui/search-input.mjs +33 -100
  101. package/dist/client/components/ui/select.mjs +72 -393
  102. package/dist/client/components/ui/separator.mjs +7 -38
  103. package/dist/client/components/ui/sheet.mjs +49 -269
  104. package/dist/client/components/ui/sidebar.mjs +171 -690
  105. package/dist/client/components/ui/skeleton.mjs +7 -38
  106. package/dist/client/components/ui/sonner.mjs +11 -42
  107. package/dist/client/components/ui/switch.mjs +9 -45
  108. package/dist/client/components/ui/table.mjs +48 -266
  109. package/dist/client/components/ui/tabs.mjs +26 -139
  110. package/dist/client/components/ui/textarea.mjs +6 -32
  111. package/dist/client/components/ui/tooltip.mjs +27 -129
  112. package/dist/client/components/widgets/chart-widget.mjs +174 -522
  113. package/dist/client/components/widgets/progress-widget.mjs +66 -172
  114. package/dist/client/components/widgets/quick-actions-widget.mjs +102 -261
  115. package/dist/client/components/widgets/recent-items-widget.mjs +69 -195
  116. package/dist/client/components/widgets/stats-widget.mjs +41 -175
  117. package/dist/client/components/widgets/table-widget.mjs +9 -9
  118. package/dist/client/components/widgets/timeline-widget.mjs +86 -226
  119. package/dist/client/components/widgets/value-widget.mjs +74 -381
  120. package/dist/client/components/widgets/widget-empty-state.mjs +26 -76
  121. package/dist/client/components/widgets/widget-skeletons.mjs +138 -421
  122. package/dist/client/contexts/focus-context.mjs +63 -146
  123. package/dist/client/hooks/typed-hooks.mjs +241 -701
  124. package/dist/client/hooks/use-action.mjs +62 -198
  125. package/dist/client/hooks/use-admin-config.mjs +5 -35
  126. package/dist/client/hooks/use-admin-preferences.mjs +16 -88
  127. package/dist/client/hooks/use-admin-routes.mjs +22 -56
  128. package/dist/client/hooks/use-audit-history.mjs +21 -69
  129. package/dist/client/hooks/use-brand.mjs +1 -9
  130. package/dist/client/hooks/use-collection-fields.mjs +17 -57
  131. package/dist/client/hooks/use-collection-meta.mjs +12 -44
  132. package/dist/client/hooks/use-collection-schema.mjs +10 -33
  133. package/dist/client/hooks/use-collection-validation.mjs +23 -53
  134. package/dist/client/hooks/use-collection.mjs +194 -614
  135. package/dist/client/hooks/use-current-user.mjs +0 -1
  136. package/dist/client/hooks/use-field-hooks.mjs +10 -10
  137. package/dist/client/hooks/use-field-options.mjs +61 -202
  138. package/dist/client/hooks/use-global-fields.mjs +14 -46
  139. package/dist/client/hooks/use-global-meta.mjs +9 -30
  140. package/dist/client/hooks/use-global-schema.mjs +9 -30
  141. package/dist/client/hooks/use-global.mjs +63 -219
  142. package/dist/client/hooks/use-locks.mjs +117 -325
  143. package/dist/client/hooks/use-media-query.mjs +16 -36
  144. package/dist/client/hooks/use-prefill-params.mjs +0 -1
  145. package/dist/client/hooks/use-questpie-query-options.mjs +12 -29
  146. package/dist/client/hooks/use-reactive-fields.mjs +1 -1
  147. package/dist/client/hooks/use-reactive-prop.mjs +65 -223
  148. package/dist/client/hooks/use-realtime-highlight.mjs +51 -114
  149. package/dist/client/hooks/use-saved-views.mjs +22 -103
  150. package/dist/client/hooks/use-search-param-toggle.mjs +28 -79
  151. package/dist/client/hooks/use-search.mjs +31 -143
  152. package/dist/client/hooks/use-server-actions.mjs +18 -50
  153. package/dist/client/hooks/use-server-validation.mjs +72 -166
  154. package/dist/client/hooks/use-server-widget-data.mjs +7 -33
  155. package/dist/client/hooks/use-setup-status.mjs +12 -25
  156. package/dist/client/hooks/use-sidebar-search-param.mjs +33 -78
  157. package/dist/client/hooks/use-transition-stage.mjs +8 -38
  158. package/dist/client/hooks/use-upload.mjs +54 -152
  159. package/dist/client/hooks/use-validation-error-map.mjs +6 -26
  160. package/dist/client/hooks/use-view-state.mjs +187 -437
  161. package/dist/client/i18n/hooks.mjs +65 -197
  162. package/dist/client/lib/render-profiler.mjs +14 -41
  163. package/dist/client/preview/block-scope-context.mjs +14 -36
  164. package/dist/client/preview/preview-banner.d.mts +2 -2
  165. package/dist/client/preview/preview-banner.mjs +42 -108
  166. package/dist/client/preview/preview-field.d.mts +4 -4
  167. package/dist/client/preview/preview-field.mjs +167 -348
  168. package/dist/client/preview/use-collection-preview.mjs +121 -215
  169. package/dist/client/runtime/content-locales-provider.mjs +31 -83
  170. package/dist/client/runtime/locale-scope.mjs +22 -63
  171. package/dist/client/runtime/provider.mjs +100 -255
  172. package/dist/client/runtime/translations-provider.mjs +41 -107
  173. package/dist/client/scope/picker.mjs +86 -321
  174. package/dist/client/scope/provider.mjs +8 -17
  175. package/dist/client/utils/build-field-definitions-from-schema.mjs +4 -2
  176. package/dist/client/views/auth/accept-invite-form.d.mts +2 -2
  177. package/dist/client/views/auth/accept-invite-form.mjs +121 -412
  178. package/dist/client/views/auth/auth-layout.d.mts +3 -3
  179. package/dist/client/views/auth/auth-layout.mjs +104 -284
  180. package/dist/client/views/auth/forgot-password-form.d.mts +2 -2
  181. package/dist/client/views/auth/forgot-password-form.mjs +94 -325
  182. package/dist/client/views/auth/invite-form.mjs +107 -442
  183. package/dist/client/views/auth/login-form.d.mts +2 -2
  184. package/dist/client/views/auth/login-form.mjs +116 -337
  185. package/dist/client/views/auth/reset-password-form.d.mts +2 -2
  186. package/dist/client/views/auth/reset-password-form.mjs +128 -453
  187. package/dist/client/views/auth/setup-form.d.mts +2 -2
  188. package/dist/client/views/auth/setup-form.mjs +140 -478
  189. package/dist/client/views/collection/auto-form-fields.mjs +243 -615
  190. package/dist/client/views/collection/bulk-action-toolbar.mjs +212 -379
  191. package/dist/client/views/collection/cells/complex-cells.mjs +183 -611
  192. package/dist/client/views/collection/cells/primitive-cells.mjs +116 -356
  193. package/dist/client/views/collection/cells/relation-cells.mjs +86 -233
  194. package/dist/client/views/collection/cells/shared/asset-thumbnail.mjs +142 -371
  195. package/dist/client/views/collection/cells/shared/relation-chip.mjs +35 -131
  196. package/dist/client/views/collection/cells/upload-cells.mjs +60 -177
  197. package/dist/client/views/collection/columns/build-columns.mjs +8 -48
  198. package/dist/client/views/collection/field-renderer.mjs +58 -182
  199. package/dist/client/views/collection/form-view.mjs +284 -518
  200. package/dist/client/views/collection/table-view.mjs +231 -463
  201. package/dist/client/views/collection/view-skeletons.mjs +112 -237
  202. package/dist/client/views/common/global-search.mjs +241 -560
  203. package/dist/client/views/dashboard/dashboard-grid.mjs +256 -775
  204. package/dist/client/views/dashboard/dashboard-widget.mjs +38 -126
  205. package/dist/client/views/dashboard/widget-card.mjs +61 -269
  206. package/dist/client/views/globals/global-form-view.mjs +477 -1301
  207. package/dist/client/views/layout/admin-layout-provider.mjs +28 -88
  208. package/dist/client/views/layout/admin-layout.mjs +83 -246
  209. package/dist/client/views/layout/admin-router.mjs +458 -1274
  210. package/dist/client/views/layout/admin-sidebar.mjs +510 -1292
  211. package/dist/client/views/layout/admin-theme.mjs +30 -64
  212. package/dist/client/views/layout/admin-view-layout.mjs +40 -144
  213. package/dist/client/views/pages/accept-invite-page.d.mts +2 -2
  214. package/dist/client/views/pages/accept-invite-page.mjs +95 -290
  215. package/dist/client/views/pages/dashboard-page.d.mts +2 -2
  216. package/dist/client/views/pages/dashboard-page.mjs +11 -57
  217. package/dist/client/views/pages/forgot-password-page.d.mts +2 -2
  218. package/dist/client/views/pages/forgot-password-page.mjs +31 -83
  219. package/dist/client/views/pages/invite-page.d.mts +2 -2
  220. package/dist/client/views/pages/invite-page.mjs +35 -90
  221. package/dist/client/views/pages/login-page.d.mts +2 -2
  222. package/dist/client/views/pages/login-page.mjs +41 -121
  223. package/dist/client/views/pages/reset-password-page.d.mts +2 -2
  224. package/dist/client/views/pages/reset-password-page.mjs +46 -173
  225. package/dist/client/views/pages/setup-page.d.mts +2 -2
  226. package/dist/client/views/pages/setup-page.mjs +33 -95
  227. package/dist/components/rich-text/rich-text-renderer.mjs +9 -33
  228. package/dist/server/adapters/index.d.mts +2 -0
  229. package/dist/server/adapters/nextjs.d.mts +1 -0
  230. package/dist/server/auth-helpers.d.mts +1 -0
  231. package/dist/server/modules/admin/.generated/module.d.mts +1 -0
  232. package/dist/server/modules/admin/collections/account.d.mts +46 -46
  233. package/dist/server/modules/admin/collections/admin-locks.d.mts +50 -50
  234. package/dist/server/modules/admin/collections/admin-preferences.d.mts +39 -39
  235. package/dist/server/modules/admin/collections/admin-saved-views.d.mts +47 -47
  236. package/dist/server/modules/admin/collections/apikey.d.mts +68 -68
  237. package/dist/server/modules/admin/collections/assets.d.mts +39 -39
  238. package/dist/server/modules/admin/collections/session.d.mts +42 -42
  239. package/dist/server/modules/admin/collections/user.d.mts +62 -62
  240. package/dist/server/modules/admin/collections/verification.d.mts +23 -23
  241. package/dist/server/modules/admin/index.d.mts +20 -19
  242. package/dist/server/modules/admin/routes/admin-config.d.mts +2 -2
  243. package/dist/server/modules/admin/routes/execute-action.d.mts +9 -9
  244. package/dist/server/modules/admin/routes/locales.d.mts +2 -2
  245. package/dist/server/modules/admin/routes/preview.d.mts +11 -11
  246. package/dist/server/modules/admin/routes/reactive.d.mts +9 -9
  247. package/dist/server/modules/admin/routes/setup.d.mts +7 -7
  248. package/dist/server/modules/admin/routes/translations.d.mts +4 -4
  249. package/dist/server/modules/admin/routes/widget-data.d.mts +5 -5
  250. package/dist/server/modules/admin-preferences/collections/saved-views.d.mts +45 -45
  251. package/dist/server/modules/audit/.generated/module.d.mts +6 -6
  252. package/dist/server/modules/audit/collections/audit-log.d.mts +78 -78
  253. package/dist/server/modules/audit/jobs/audit-cleanup.d.mts +2 -2
  254. package/dist/server.d.mts +2 -0
  255. package/package.json +3 -5
@@ -8,7 +8,6 @@ import { buildValidationSchema } from "../../builder/validation.mjs";
8
8
  import { useValidationErrorMap } from "../../hooks/use-validation-error-map.mjs";
9
9
  import { AutoFormFields } from "../../views/collection/auto-form-fields.mjs";
10
10
  import { ResponsiveDialog, ResponsiveDialogContent, ResponsiveDialogDescription, ResponsiveDialogFooter, ResponsiveDialogHeader, ResponsiveDialogTitle } from "../ui/responsive-dialog.mjs";
11
- import { c } from "react/compiler-runtime";
12
11
  import * as React from "react";
13
12
  import { useQueryClient } from "@tanstack/react-query";
14
13
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -58,403 +57,180 @@ function createActionFormResolver(fields, errorMap) {
58
57
  * Uses buildValidationSchema for automatic Zod schema generation
59
58
  * from field definitions, providing full field system support.
60
59
  */
61
- function FormDialogContent(t0) {
62
- const $ = c(66);
63
- const { action, ctx, onClose } = t0;
60
+ function FormDialogContent({ action, ctx, onClose }) {
64
61
  const { config } = action.handler;
65
62
  const resolveText = useResolveText();
66
63
  const { t } = useTranslation();
67
64
  const errorMap = useValidationErrorMap();
68
- let values;
69
- if ($[0] !== config.fields) {
70
- values = {};
71
- for (const [fieldName, fieldDef] of Object.entries(config.fields)) {
72
- const options = fieldDef["~options"];
73
- if (options?.defaultValue !== void 0) values[fieldName] = options.defaultValue;
74
- }
75
- $[0] = config.fields;
76
- $[1] = values;
77
- } else values = $[1];
78
- let t1;
79
- if ($[2] !== config.defaultValues) {
80
- t1 = config.defaultValues || {};
81
- $[2] = config.defaultValues;
82
- $[3] = t1;
83
- } else t1 = $[3];
84
- let t2;
85
- if ($[4] !== t1 || $[5] !== values) {
86
- t2 = {
87
- ...values,
88
- ...t1
89
- };
90
- $[4] = t1;
91
- $[5] = values;
92
- $[6] = t2;
93
- } else t2 = $[6];
94
- const defaultValues = t2;
95
- let t3;
96
- if ($[7] !== config.fields || $[8] !== errorMap) {
97
- t3 = createActionFormResolver(config.fields, errorMap);
98
- $[7] = config.fields;
99
- $[8] = errorMap;
100
- $[9] = t3;
101
- } else t3 = $[9];
102
- const resolver = t3;
103
- let t4;
104
- if ($[10] !== defaultValues || $[11] !== resolver) {
105
- t4 = {
106
- defaultValues,
107
- resolver
108
- };
109
- $[10] = defaultValues;
110
- $[11] = resolver;
111
- $[12] = t4;
112
- } else t4 = $[12];
113
- const form = useForm(t4);
114
- const [isSubmitting, setIsSubmitting] = React.useState(false);
115
- let t5;
116
- if ($[13] !== config || $[14] !== ctx || $[15] !== form || $[16] !== onClose || $[17] !== t) {
117
- let t6$1;
118
- if ($[19] !== config || $[20] !== ctx || $[21] !== onClose || $[22] !== t) {
119
- t6$1 = async (data) => {
120
- setIsSubmitting(true);
121
- const submitPromise = async () => {
122
- await config.onSubmit(data, ctx);
123
- return data;
124
- };
125
- toast.promise(submitPromise(), {
126
- loading: t("toast.processing"),
127
- success: () => {
128
- onClose();
129
- return t("toast.actionSuccess");
130
- },
131
- error: (error) => error instanceof Error ? error.message : t("toast.actionFailed"),
132
- finally: () => {
133
- setIsSubmitting(false);
134
- }
135
- });
65
+ const form = useForm({
66
+ defaultValues: React.useMemo(() => {
67
+ const values = {};
68
+ for (const [fieldName, fieldDef] of Object.entries(config.fields)) {
69
+ const options = fieldDef["~options"];
70
+ if (options?.defaultValue !== void 0) values[fieldName] = options.defaultValue;
71
+ }
72
+ return {
73
+ ...values,
74
+ ...config.defaultValues || {}
136
75
  };
137
- $[19] = config;
138
- $[20] = ctx;
139
- $[21] = onClose;
140
- $[22] = t;
141
- $[23] = t6$1;
142
- } else t6$1 = $[23];
143
- t5 = form.handleSubmit(t6$1);
144
- $[13] = config;
145
- $[14] = ctx;
146
- $[15] = form;
147
- $[16] = onClose;
148
- $[17] = t;
149
- $[18] = t5;
150
- } else t5 = $[18];
151
- const handleSubmit = t5;
152
- const t6 = config.fields;
153
- let t7;
154
- if ($[24] !== t6) {
155
- t7 = { fields: t6 };
156
- $[24] = t6;
157
- $[25] = t7;
158
- } else t7 = $[25];
159
- const collectionConfig = t7;
160
- let t8;
161
- if ($[26] !== config.title || $[27] !== resolveText) {
162
- t8 = resolveText(config.title);
163
- $[26] = config.title;
164
- $[27] = resolveText;
165
- $[28] = t8;
166
- } else t8 = $[28];
167
- let t9;
168
- if ($[29] !== t8) {
169
- t9 = /* @__PURE__ */ jsx(ResponsiveDialogTitle, { children: t8 });
170
- $[29] = t8;
171
- $[30] = t9;
172
- } else t9 = $[30];
173
- let t10;
174
- if ($[31] !== config.description || $[32] !== resolveText) {
175
- t10 = config.description && /* @__PURE__ */ jsx(ResponsiveDialogDescription, { children: resolveText(config.description) });
176
- $[31] = config.description;
177
- $[32] = resolveText;
178
- $[33] = t10;
179
- } else t10 = $[33];
180
- let t11;
181
- if ($[34] !== t10 || $[35] !== t9) {
182
- t11 = /* @__PURE__ */ jsxs(ResponsiveDialogHeader, { children: [t9, t10] });
183
- $[34] = t10;
184
- $[35] = t9;
185
- $[36] = t11;
186
- } else t11 = $[36];
187
- let t12;
188
- if ($[37] !== collectionConfig) {
189
- t12 = /* @__PURE__ */ jsx(AutoFormFields, {
190
- collection: "__action__",
191
- config: collectionConfig
192
- });
193
- $[37] = collectionConfig;
194
- $[38] = t12;
195
- } else t12 = $[38];
196
- let t13;
197
- if ($[39] !== config.cancelLabel || $[40] !== resolveText || $[41] !== t) {
198
- t13 = resolveText(config.cancelLabel, t("common.cancel"));
199
- $[39] = config.cancelLabel;
200
- $[40] = resolveText;
201
- $[41] = t;
202
- $[42] = t13;
203
- } else t13 = $[42];
204
- let t14;
205
- if ($[43] !== isSubmitting || $[44] !== onClose || $[45] !== t13) {
206
- t14 = /* @__PURE__ */ jsx(Button, {
207
- type: "button",
208
- variant: "outline",
209
- onClick: onClose,
210
- disabled: isSubmitting,
211
- children: t13
212
- });
213
- $[43] = isSubmitting;
214
- $[44] = onClose;
215
- $[45] = t13;
216
- $[46] = t14;
217
- } else t14 = $[46];
218
- let t15;
219
- if ($[47] !== config.submitLabel || $[48] !== isSubmitting || $[49] !== resolveText || $[50] !== t) {
220
- t15 = isSubmitting ? t("common.loading") : resolveText(config.submitLabel, t("common.submit"));
221
- $[47] = config.submitLabel;
222
- $[48] = isSubmitting;
223
- $[49] = resolveText;
224
- $[50] = t;
225
- $[51] = t15;
226
- } else t15 = $[51];
227
- let t16;
228
- if ($[52] !== isSubmitting || $[53] !== t15) {
229
- t16 = /* @__PURE__ */ jsx(Button, {
230
- type: "submit",
231
- disabled: isSubmitting,
232
- children: t15
233
- });
234
- $[52] = isSubmitting;
235
- $[53] = t15;
236
- $[54] = t16;
237
- } else t16 = $[54];
238
- let t17;
239
- if ($[55] !== t14 || $[56] !== t16) {
240
- t17 = /* @__PURE__ */ jsxs(ResponsiveDialogFooter, {
241
- className: "mt-6",
242
- children: [t14, t16]
76
+ }, [config.fields, config.defaultValues]),
77
+ resolver: React.useMemo(() => {
78
+ return createActionFormResolver(config.fields, errorMap);
79
+ }, [config.fields, errorMap])
80
+ });
81
+ const [isSubmitting, setIsSubmitting] = React.useState(false);
82
+ const handleSubmit = form.handleSubmit(async (data) => {
83
+ setIsSubmitting(true);
84
+ const submitPromise = async () => {
85
+ await config.onSubmit(data, ctx);
86
+ return data;
87
+ };
88
+ toast.promise(submitPromise(), {
89
+ loading: t("toast.processing"),
90
+ success: () => {
91
+ onClose();
92
+ return t("toast.actionSuccess");
93
+ },
94
+ error: (error) => {
95
+ return error instanceof Error ? error.message : t("toast.actionFailed");
96
+ },
97
+ finally: () => {
98
+ setIsSubmitting(false);
99
+ }
243
100
  });
244
- $[55] = t14;
245
- $[56] = t16;
246
- $[57] = t17;
247
- } else t17 = $[57];
248
- let t18;
249
- if ($[58] !== handleSubmit || $[59] !== t12 || $[60] !== t17) {
250
- t18 = /* @__PURE__ */ jsxs("form", {
101
+ });
102
+ const collectionConfig = React.useMemo(() => ({ fields: config.fields }), [config.fields]);
103
+ return /* @__PURE__ */ jsxs(FormProvider, {
104
+ ...form,
105
+ children: [/* @__PURE__ */ jsxs(ResponsiveDialogHeader, { children: [/* @__PURE__ */ jsx(ResponsiveDialogTitle, { children: resolveText(config.title) }), config.description && /* @__PURE__ */ jsx(ResponsiveDialogDescription, { children: resolveText(config.description) })] }), /* @__PURE__ */ jsxs("form", {
251
106
  onSubmit: handleSubmit,
252
107
  className: "space-y-4",
253
- children: [t12, t17]
254
- });
255
- $[58] = handleSubmit;
256
- $[59] = t12;
257
- $[60] = t17;
258
- $[61] = t18;
259
- } else t18 = $[61];
260
- let t19;
261
- if ($[62] !== form || $[63] !== t11 || $[64] !== t18) {
262
- t19 = /* @__PURE__ */ jsxs(FormProvider, {
263
- ...form,
264
- children: [t11, t18]
265
- });
266
- $[62] = form;
267
- $[63] = t11;
268
- $[64] = t18;
269
- $[65] = t19;
270
- } else t19 = $[65];
271
- return t19;
108
+ children: [/* @__PURE__ */ jsx(AutoFormFields, {
109
+ collection: "__action__",
110
+ config: collectionConfig
111
+ }), /* @__PURE__ */ jsxs(ResponsiveDialogFooter, {
112
+ className: "mt-6",
113
+ children: [/* @__PURE__ */ jsx(Button, {
114
+ type: "button",
115
+ variant: "outline",
116
+ onClick: onClose,
117
+ disabled: isSubmitting,
118
+ children: resolveText(config.cancelLabel, t("common.cancel"))
119
+ }), /* @__PURE__ */ jsx(Button, {
120
+ type: "submit",
121
+ disabled: isSubmitting,
122
+ children: isSubmitting ? t("common.loading") : resolveText(config.submitLabel, t("common.submit"))
123
+ })]
124
+ })]
125
+ })]
126
+ });
272
127
  }
273
128
  /**
274
129
  * Custom Dialog content - renders lazy-loaded component
275
130
  */
276
- function CustomDialogContent(t0) {
277
- const $ = c(26);
278
- const { action, ctx, onClose } = t0;
131
+ function CustomDialogContent({ action, ctx, onClose }) {
279
132
  const { t } = useTranslation();
280
133
  const handler = action.handler;
281
134
  const [Component, setComponent] = React.useState(null);
282
135
  const [loading, setLoading] = React.useState(true);
283
136
  const [error, setError] = React.useState(null);
284
- let t1;
285
- let t2;
286
- if ($[0] !== handler.component || $[1] !== t) {
287
- t1 = () => {
288
- let mounted = true;
289
- (async function loadComponent() {
290
- try {
291
- const comp = handler.component;
292
- if (typeof comp === "function") {
293
- const lazyComp = comp;
294
- if (lazyComp._payload !== void 0) {
295
- const resolved = await lazyComp._payload();
137
+ React.useEffect(() => {
138
+ let mounted = true;
139
+ async function loadComponent() {
140
+ try {
141
+ const comp = handler.component;
142
+ if (typeof comp === "function") {
143
+ const lazyComp = comp;
144
+ if (lazyComp._payload !== void 0) {
145
+ const resolved = await lazyComp._payload();
146
+ if (mounted) {
147
+ let comp2;
148
+ if (resolved.default) comp2 = resolved.default;
149
+ else comp2 = resolved;
150
+ setComponent(() => comp2);
151
+ }
152
+ } else {
153
+ const result = comp();
154
+ let hasThen = false;
155
+ if (result != null) {
156
+ if (result.then) hasThen = true;
157
+ }
158
+ if (hasThen) {
159
+ const mod = await result;
296
160
  if (mounted) {
297
161
  let comp2;
298
- if (resolved.default) comp2 = resolved.default;
299
- else comp2 = resolved;
162
+ if (mod.default) comp2 = mod.default;
163
+ else comp2 = mod;
300
164
  setComponent(() => comp2);
301
165
  }
302
- } else {
303
- const result = comp();
304
- let hasThen = false;
305
- if (result != null) {
306
- if (result.then) hasThen = true;
307
- }
308
- if (hasThen) {
309
- const mod = await result;
310
- if (mounted) {
311
- let comp2_0;
312
- if (mod.default) comp2_0 = mod.default;
313
- else comp2_0 = mod;
314
- setComponent(() => comp2_0);
315
- }
316
- } else if (mounted) setComponent(() => comp);
317
- }
318
- } else if (mounted) setComponent(() => comp);
319
- if (mounted) setLoading(false);
320
- } catch (t3$1) {
321
- const err = t3$1;
322
- if (mounted) {
323
- if (err instanceof Error) setError(err);
324
- else setError(new Error(t("error.failedToLoad")));
325
- setLoading(false);
166
+ } else if (mounted) setComponent(() => comp);
326
167
  }
168
+ } else if (mounted) setComponent(() => comp);
169
+ if (mounted) setLoading(false);
170
+ } catch (err) {
171
+ if (mounted) {
172
+ if (err instanceof Error) setError(err);
173
+ else setError(new Error(t("error.failedToLoad")));
174
+ setLoading(false);
327
175
  }
328
- })();
329
- return () => {
330
- mounted = false;
331
- };
176
+ }
177
+ }
178
+ loadComponent();
179
+ return () => {
180
+ mounted = false;
332
181
  };
333
- t2 = [handler.component, t];
334
- $[0] = handler.component;
335
- $[1] = t;
336
- $[2] = t1;
337
- $[3] = t2;
338
- } else {
339
- t1 = $[2];
340
- t2 = $[3];
341
- }
342
- React.useEffect(t1, t2);
343
- if (loading) {
344
- let t3$1;
345
- if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
346
- t3$1 = /* @__PURE__ */ jsxs("div", {
347
- className: "space-y-2",
348
- children: [/* @__PURE__ */ jsx(Skeleton, {
349
- variant: "text",
350
- className: "h-4 w-24"
351
- }), /* @__PURE__ */ jsx(Skeleton, { className: "h-10 w-full" })]
352
- });
353
- $[4] = t3$1;
354
- } else t3$1 = $[4];
355
- let t4$1;
356
- if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
357
- t4$1 = /* @__PURE__ */ jsxs("div", {
358
- className: "space-y-4 py-2",
359
- "aria-busy": "true",
360
- children: [t3$1, /* @__PURE__ */ jsxs("div", {
361
- className: "space-y-2",
362
- children: [/* @__PURE__ */ jsx(Skeleton, {
363
- variant: "text",
364
- className: "h-4 w-32"
365
- }), /* @__PURE__ */ jsx(Skeleton, { className: "h-10 w-full" })]
366
- })]
367
- });
368
- $[5] = t4$1;
369
- } else t4$1 = $[5];
370
- return t4$1;
371
- }
372
- if (error) {
373
- let t3$1;
374
- if ($[6] !== error.message) {
375
- t3$1 = /* @__PURE__ */ jsx("p", {
376
- className: "text-destructive",
377
- children: error.message
378
- });
379
- $[6] = error.message;
380
- $[7] = t3$1;
381
- } else t3$1 = $[7];
382
- let t4$1;
383
- if ($[8] !== onClose) {
384
- t4$1 = /* @__PURE__ */ jsx(Button, {
385
- variant: "outline",
386
- onClick: onClose,
387
- className: "mt-4",
388
- children: "Close"
389
- });
390
- $[8] = onClose;
391
- $[9] = t4$1;
392
- } else t4$1 = $[9];
393
- let t5;
394
- if ($[10] !== t3$1 || $[11] !== t4$1) {
395
- t5 = /* @__PURE__ */ jsxs("div", {
396
- className: "p-4 text-center",
397
- children: [t3$1, t4$1]
398
- });
399
- $[10] = t3$1;
400
- $[11] = t4$1;
401
- $[12] = t5;
402
- } else t5 = $[12];
403
- return t5;
404
- }
405
- if (!Component) {
406
- let t3$1;
407
- if ($[13] === Symbol.for("react.memo_cache_sentinel")) {
408
- t3$1 = /* @__PURE__ */ jsx("p", {
409
- className: "text-muted-foreground",
410
- children: "Component not found"
411
- });
412
- $[13] = t3$1;
413
- } else t3$1 = $[13];
414
- let t4$1;
415
- if ($[14] !== onClose) {
416
- t4$1 = /* @__PURE__ */ jsxs("div", {
417
- className: "p-4 text-center",
418
- children: [t3$1, /* @__PURE__ */ jsx(Button, {
419
- variant: "outline",
420
- onClick: onClose,
421
- className: "mt-4",
422
- children: "Close"
423
- })]
424
- });
425
- $[14] = onClose;
426
- $[15] = t4$1;
427
- } else t4$1 = $[15];
428
- return t4$1;
429
- }
430
- let t3;
431
- if ($[16] !== ctx.helpers || $[17] !== onClose) {
432
- t3 = () => {
182
+ }, [handler.component, t]);
183
+ if (loading) return /* @__PURE__ */ jsxs("div", {
184
+ className: "space-y-4 py-2",
185
+ "aria-busy": "true",
186
+ children: [/* @__PURE__ */ jsxs("div", {
187
+ className: "space-y-2",
188
+ children: [/* @__PURE__ */ jsx(Skeleton, {
189
+ variant: "text",
190
+ className: "h-4 w-24"
191
+ }), /* @__PURE__ */ jsx(Skeleton, { className: "h-10 w-full" })]
192
+ }), /* @__PURE__ */ jsxs("div", {
193
+ className: "space-y-2",
194
+ children: [/* @__PURE__ */ jsx(Skeleton, {
195
+ variant: "text",
196
+ className: "h-4 w-32"
197
+ }), /* @__PURE__ */ jsx(Skeleton, { className: "h-10 w-full" })]
198
+ })]
199
+ });
200
+ if (error) return /* @__PURE__ */ jsxs("div", {
201
+ className: "p-4 text-center",
202
+ children: [/* @__PURE__ */ jsx("p", {
203
+ className: "text-destructive",
204
+ children: error.message
205
+ }), /* @__PURE__ */ jsx(Button, {
206
+ variant: "outline",
207
+ onClick: onClose,
208
+ className: "mt-4",
209
+ children: "Close"
210
+ })]
211
+ });
212
+ if (!Component) return /* @__PURE__ */ jsxs("div", {
213
+ className: "p-4 text-center",
214
+ children: [/* @__PURE__ */ jsx("p", {
215
+ className: "text-muted-foreground",
216
+ children: "Component not found"
217
+ }), /* @__PURE__ */ jsx(Button, {
218
+ variant: "outline",
219
+ onClick: onClose,
220
+ className: "mt-4",
221
+ children: "Close"
222
+ })]
223
+ });
224
+ return /* @__PURE__ */ jsx(Component, {
225
+ item: ctx.item,
226
+ items: ctx.items,
227
+ collection: ctx.collection,
228
+ onClose,
229
+ onSuccess: () => {
433
230
  ctx.helpers.refresh();
434
231
  onClose();
435
- };
436
- $[16] = ctx.helpers;
437
- $[17] = onClose;
438
- $[18] = t3;
439
- } else t3 = $[18];
440
- let t4;
441
- if ($[19] !== Component || $[20] !== ctx.collection || $[21] !== ctx.item || $[22] !== ctx.items || $[23] !== onClose || $[24] !== t3) {
442
- t4 = /* @__PURE__ */ jsx(Component, {
443
- item: ctx.item,
444
- items: ctx.items,
445
- collection: ctx.collection,
446
- onClose,
447
- onSuccess: t3
448
- });
449
- $[19] = Component;
450
- $[20] = ctx.collection;
451
- $[21] = ctx.item;
452
- $[22] = ctx.items;
453
- $[23] = onClose;
454
- $[24] = t3;
455
- $[25] = t4;
456
- } else t4 = $[25];
457
- return t4;
232
+ }
233
+ });
458
234
  }
459
235
  /**
460
236
  * ActionDialog - Renders dialog-type and form-type actions
@@ -471,130 +247,56 @@ function CustomDialogContent(t0) {
471
247
  * />
472
248
  * ```
473
249
  */
474
- function ActionDialog(t0) {
475
- const $ = c(35);
476
- const { open, onOpenChange, action, collection, item, items, helpers } = t0;
250
+ function ActionDialog({ open, onOpenChange, action, collection, item, items, helpers }) {
477
251
  const queryClient = useQueryClient();
478
- let t1;
479
- if ($[0] !== onOpenChange) {
480
- t1 = () => onOpenChange(false);
481
- $[0] = onOpenChange;
482
- $[1] = t1;
483
- } else t1 = $[1];
484
- let t2;
485
- if ($[2] !== helpers || $[3] !== t1) {
486
- t2 = {
252
+ const ctx = React.useMemo(() => ({
253
+ item,
254
+ items,
255
+ collection,
256
+ helpers: {
487
257
  ...helpers,
488
- closeDialog: t1
489
- };
490
- $[2] = helpers;
491
- $[3] = t1;
492
- $[4] = t2;
493
- } else t2 = $[4];
494
- let t3;
495
- if ($[5] !== queryClient) {
496
- t3 = {
258
+ closeDialog: () => onOpenChange(false)
259
+ },
260
+ queryClient: {
497
261
  invalidateQueries: (filters) => queryClient.invalidateQueries(filters),
498
- resetQueries: (filters_0) => queryClient.resetQueries(filters_0),
499
- refetchQueries: (filters_1) => queryClient.refetchQueries(filters_1)
500
- };
501
- $[5] = queryClient;
502
- $[6] = t3;
503
- } else t3 = $[6];
504
- let t4;
505
- if ($[7] !== collection || $[8] !== item || $[9] !== items || $[10] !== t2 || $[11] !== t3) {
506
- t4 = {
507
- item,
508
- items,
509
- collection,
510
- helpers: t2,
511
- queryClient: t3
512
- };
513
- $[7] = collection;
514
- $[8] = item;
515
- $[9] = items;
516
- $[10] = t2;
517
- $[11] = t3;
518
- $[12] = t4;
519
- } else t4 = $[12];
520
- const ctx = t4;
521
- let t5;
522
- if ($[13] !== onOpenChange) {
523
- t5 = () => onOpenChange(false);
524
- $[13] = onOpenChange;
525
- $[14] = t5;
526
- } else t5 = $[14];
527
- const handleClose = t5;
528
- let t6;
529
- if ($[15] !== action.handler) {
530
- t6 = () => {
531
- if (action.handler.type === "form") return {
532
- sm: "sm:max-w-sm",
533
- md: "sm:max-w-md",
534
- lg: "sm:max-w-lg",
535
- xl: "sm:max-w-xl"
536
- }[action.handler.config.width || "md"];
537
- if (action.handler.type === "dialog") return "sm:max-w-lg";
538
- return "sm:max-w-md";
539
- };
540
- $[15] = action.handler;
541
- $[16] = t6;
542
- } else t6 = $[16];
543
- const getDialogClassName = t6;
544
- let t7;
545
- if ($[17] !== getDialogClassName) {
546
- t7 = cn("qa-action-dialog", getDialogClassName());
547
- $[17] = getDialogClassName;
548
- $[18] = t7;
549
- } else t7 = $[18];
550
- let t8;
551
- if ($[19] !== action || $[20] !== ctx || $[21] !== handleClose) {
552
- t8 = action.handler.type === "form" && /* @__PURE__ */ jsx(FormDialogContent, {
553
- action,
554
- ctx,
555
- onClose: handleClose
556
- });
557
- $[19] = action;
558
- $[20] = ctx;
559
- $[21] = handleClose;
560
- $[22] = t8;
561
- } else t8 = $[22];
562
- let t9;
563
- if ($[23] !== action || $[24] !== ctx || $[25] !== handleClose) {
564
- t9 = action.handler.type === "dialog" && /* @__PURE__ */ jsx(CustomDialogContent, {
565
- action,
566
- ctx,
567
- onClose: handleClose
568
- });
569
- $[23] = action;
570
- $[24] = ctx;
571
- $[25] = handleClose;
572
- $[26] = t9;
573
- } else t9 = $[26];
574
- let t10;
575
- if ($[27] !== t7 || $[28] !== t8 || $[29] !== t9) {
576
- t10 = /* @__PURE__ */ jsxs(ResponsiveDialogContent, {
577
- className: t7,
578
- children: [t8, t9]
579
- });
580
- $[27] = t7;
581
- $[28] = t8;
582
- $[29] = t9;
583
- $[30] = t10;
584
- } else t10 = $[30];
585
- let t11;
586
- if ($[31] !== onOpenChange || $[32] !== open || $[33] !== t10) {
587
- t11 = /* @__PURE__ */ jsx(ResponsiveDialog, {
588
- open,
589
- onOpenChange,
590
- children: t10
591
- });
592
- $[31] = onOpenChange;
593
- $[32] = open;
594
- $[33] = t10;
595
- $[34] = t11;
596
- } else t11 = $[34];
597
- return t11;
262
+ resetQueries: (filters) => queryClient.resetQueries(filters),
263
+ refetchQueries: (filters) => queryClient.refetchQueries(filters)
264
+ }
265
+ }), [
266
+ item,
267
+ items,
268
+ collection,
269
+ helpers,
270
+ onOpenChange,
271
+ queryClient
272
+ ]);
273
+ const handleClose = () => onOpenChange(false);
274
+ const getDialogClassName = () => {
275
+ if (action.handler.type === "form") return {
276
+ sm: "sm:max-w-sm",
277
+ md: "sm:max-w-md",
278
+ lg: "sm:max-w-lg",
279
+ xl: "sm:max-w-xl"
280
+ }[action.handler.config.width || "md"];
281
+ if (action.handler.type === "dialog") return "sm:max-w-lg";
282
+ return "sm:max-w-md";
283
+ };
284
+ return /* @__PURE__ */ jsx(ResponsiveDialog, {
285
+ open,
286
+ onOpenChange,
287
+ children: /* @__PURE__ */ jsxs(ResponsiveDialogContent, {
288
+ className: cn("qa-action-dialog", getDialogClassName()),
289
+ children: [action.handler.type === "form" && /* @__PURE__ */ jsx(FormDialogContent, {
290
+ action,
291
+ ctx,
292
+ onClose: handleClose
293
+ }), action.handler.type === "dialog" && /* @__PURE__ */ jsx(CustomDialogContent, {
294
+ action,
295
+ ctx,
296
+ onClose: handleClose
297
+ })]
298
+ })
299
+ });
598
300
  }
599
301
 
600
302
  //#endregion