@questpie/admin 3.0.3 → 3.0.5

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 (253) hide show
  1. package/README.md +34 -5
  2. package/dist/client/blocks/block-renderer.d.mts +2 -2
  3. package/dist/client/blocks/block-renderer.mjs +4 -1
  4. package/dist/client/builder/types/action-types.d.mts +31 -3
  5. package/dist/client/builder/types/collection-types.d.mts +140 -0
  6. package/dist/client/builder/types/ui-config.d.mts +16 -2
  7. package/dist/client/builder/types/views.d.mts +57 -0
  8. package/dist/client/builder/types/widget-types.d.mts +5 -0
  9. package/dist/client/components/actions/action-button.mjs +137 -199
  10. package/dist/client/components/actions/action-dialog.mjs +198 -156
  11. package/dist/client/components/actions/confirmation-dialog.mjs +2 -2
  12. package/dist/client/components/actions/header-actions.mjs +52 -53
  13. package/dist/client/components/admin-link.d.mts +2 -2
  14. package/dist/client/components/auth/auth-loading.mjs +41 -18
  15. package/dist/client/components/blocks/block-editor-layout.mjs +2 -2
  16. package/dist/client/components/blocks/block-fields-renderer.mjs +64 -28
  17. package/dist/client/components/blocks/block-insert-button.mjs +4 -4
  18. package/dist/client/components/blocks/block-item.mjs +2 -2
  19. package/dist/client/components/blocks/block-library-sidebar.mjs +91 -63
  20. package/dist/client/components/component-renderer.mjs +1 -1
  21. package/dist/client/components/fields/array-field.mjs +14 -14
  22. package/dist/client/components/fields/asset-preview-field.mjs +1 -1
  23. package/dist/client/components/fields/blocks-field/blocks-field.mjs +84 -104
  24. package/dist/client/components/fields/json-field.mjs +2 -2
  25. package/dist/client/components/fields/object-array-field.mjs +22 -22
  26. package/dist/client/components/fields/object-field.mjs +5 -5
  27. package/dist/client/components/fields/relation/displays/cards-display.mjs +16 -9
  28. package/dist/client/components/fields/relation/displays/chips-display.mjs +15 -12
  29. package/dist/client/components/fields/relation/displays/grid-display.mjs +15 -11
  30. package/dist/client/components/fields/relation/displays/list-display.mjs +33 -20
  31. package/dist/client/components/fields/relation/displays/table-display.mjs +62 -93
  32. package/dist/client/components/fields/relation/relation-items-display.mjs +1 -1
  33. package/dist/client/components/fields/relation-picker.mjs +7 -6
  34. package/dist/client/components/fields/relation-select.mjs +71 -47
  35. package/dist/client/components/fields/rich-text-editor/bubble-menu.mjs +392 -82
  36. package/dist/client/components/fields/rich-text-editor/extensions.mjs +54 -23
  37. package/dist/client/components/fields/rich-text-editor/image-popover.mjs +24 -50
  38. package/dist/client/components/fields/rich-text-editor/image-upload.mjs +66 -0
  39. package/dist/client/components/fields/rich-text-editor/index.d.mts +38 -0
  40. package/dist/client/components/fields/rich-text-editor/index.mjs +637 -376
  41. package/dist/client/components/fields/rich-text-editor/link-utils.mjs +26 -0
  42. package/dist/client/components/fields/rich-text-editor/presets.d.mts +10 -0
  43. package/dist/client/components/fields/rich-text-editor/slash-commands.mjs +27 -6
  44. package/dist/client/components/fields/rich-text-editor/toolbar.mjs +464 -346
  45. package/dist/client/components/fields/rich-text-editor/types.d.mts +77 -0
  46. package/dist/client/components/fields/upload-field.mjs +45 -49
  47. package/dist/client/components/filter-builder/columns-tab.mjs +69 -62
  48. package/dist/client/components/filter-builder/filter-builder-sheet.mjs +473 -308
  49. package/dist/client/components/filter-builder/filters-tab.mjs +109 -82
  50. package/dist/client/components/filter-builder/saved-views-tab.mjs +300 -198
  51. package/dist/client/components/history-sidebar.mjs +850 -340
  52. package/dist/client/components/layout/field-layout-renderer.mjs +6 -5
  53. package/dist/client/components/locale-switcher.mjs +8 -8
  54. package/dist/client/components/media/media-grid.mjs +106 -86
  55. package/dist/client/components/media/media-picker-dialog.mjs +242 -230
  56. package/dist/client/components/preview/live-preview-mode.mjs +1 -1
  57. package/dist/client/components/primitives/asset-preview.mjs +37 -22
  58. package/dist/client/components/primitives/date-input.mjs +212 -249
  59. package/dist/client/components/primitives/dropzone.mjs +192 -159
  60. package/dist/client/components/primitives/field-select-control.mjs +93 -0
  61. package/dist/client/components/primitives/select-multi.mjs +406 -365
  62. package/dist/client/components/primitives/select-single.mjs +391 -323
  63. package/dist/client/components/primitives/time-input.mjs +2 -2
  64. package/dist/client/components/sheets/resource-sheet.mjs +2 -0
  65. package/dist/client/components/ui/accordion.mjs +4 -4
  66. package/dist/client/components/ui/alert.mjs +3 -3
  67. package/dist/client/components/ui/badge.mjs +4 -4
  68. package/dist/client/components/ui/button.mjs +47 -37
  69. package/dist/client/components/ui/card.mjs +2 -2
  70. package/dist/client/components/ui/checkbox.mjs +1 -1
  71. package/dist/client/components/ui/command.mjs +5 -5
  72. package/dist/client/components/ui/dialog.mjs +3 -3
  73. package/dist/client/components/ui/drawer.mjs +1 -1
  74. package/dist/client/components/ui/dropdown-menu.mjs +157 -15
  75. package/dist/client/components/ui/empty-state.mjs +88 -59
  76. package/dist/client/components/ui/field.mjs +2 -2
  77. package/dist/client/components/ui/input-group.mjs +3 -3
  78. package/dist/client/components/ui/input.mjs +1 -1
  79. package/dist/client/components/ui/kbd.mjs +1 -1
  80. package/dist/client/components/ui/label.mjs +1 -1
  81. package/dist/client/components/ui/popover.mjs +19 -11
  82. package/dist/client/components/ui/scroll-fade.mjs +170 -0
  83. package/dist/client/components/ui/search-input.mjs +1 -1
  84. package/dist/client/components/ui/select.mjs +129 -27
  85. package/dist/client/components/ui/sheet.mjs +54 -34
  86. package/dist/client/components/ui/sidebar.mjs +15 -14
  87. package/dist/client/components/ui/skeleton.mjs +28 -12
  88. package/dist/client/components/ui/switch.mjs +2 -2
  89. package/dist/client/components/ui/table.mjs +82 -74
  90. package/dist/client/components/ui/tabs.mjs +26 -31
  91. package/dist/client/components/ui/textarea.mjs +1 -1
  92. package/dist/client/components/ui/tooltip.mjs +1 -1
  93. package/dist/client/components/widgets/chart-widget.mjs +154 -100
  94. package/dist/client/components/widgets/progress-widget.mjs +63 -36
  95. package/dist/client/components/widgets/quick-actions-widget.mjs +207 -115
  96. package/dist/client/components/widgets/recent-items-widget.mjs +147 -103
  97. package/dist/client/components/widgets/stats-widget.mjs +91 -72
  98. package/dist/client/components/widgets/table-widget.mjs +161 -247
  99. package/dist/client/components/widgets/timeline-widget.mjs +119 -78
  100. package/dist/client/components/widgets/value-widget.mjs +286 -157
  101. package/dist/client/components/widgets/widget-empty-state.mjs +88 -0
  102. package/dist/client/components/widgets/widget-skeletons.mjs +53 -20
  103. package/dist/client/contexts/focus-context.d.mts +2 -2
  104. package/dist/client/hooks/use-action.mjs +63 -55
  105. package/dist/client/hooks/use-audit-history.mjs +1 -65
  106. package/dist/client/hooks/use-collection-validation.mjs +36 -23
  107. package/dist/client/hooks/use-collection.mjs +96 -1
  108. package/dist/client/hooks/use-saved-views.mjs +70 -49
  109. package/dist/client/hooks/use-server-actions.mjs +70 -46
  110. package/dist/client/hooks/use-server-validation.mjs +156 -41
  111. package/dist/client/hooks/use-server-widget-data.mjs +1 -1
  112. package/dist/client/hooks/use-setup-status.d.mts +3 -3
  113. package/dist/client/hooks/use-setup-status.mjs +2 -2
  114. package/dist/client/hooks/use-transition-stage.mjs +2 -10
  115. package/dist/client/hooks/use-validation-error-map.mjs +31 -13
  116. package/dist/client/hooks/use-view-state.mjs +238 -174
  117. package/dist/client/i18n/date-locale.mjs +33 -0
  118. package/dist/client/i18n/hooks.mjs +17 -1
  119. package/dist/client/lib/utils.mjs +3 -2
  120. package/dist/client/preview/block-scope-context.d.mts +2 -2
  121. package/dist/client/preview/preview-banner.d.mts +2 -2
  122. package/dist/client/preview/preview-banner.mjs +75 -46
  123. package/dist/client/preview/preview-field.d.mts +4 -4
  124. package/dist/client/preview/preview-field.mjs +2 -2
  125. package/dist/client/runtime/provider.mjs +8 -1
  126. package/dist/client/runtime/translations-provider.mjs +1 -1
  127. package/dist/client/scope/picker.d.mts +2 -2
  128. package/dist/client/scope/provider.d.mts +2 -2
  129. package/dist/client/styles/base.css +1022 -0
  130. package/dist/client/styles/index.css +3 -589
  131. package/dist/client/utils/auto-expand-fields.mjs +4 -2
  132. package/dist/client/utils/keyboard-shortcuts.mjs +26 -0
  133. package/dist/client/utils/use-lazy-component.mjs +80 -0
  134. package/dist/client/views/auth/accept-invite-form.d.mts +2 -2
  135. package/dist/client/views/auth/auth-layout.d.mts +17 -10
  136. package/dist/client/views/auth/auth-layout.mjs +291 -80
  137. package/dist/client/views/auth/forgot-password-form.d.mts +2 -2
  138. package/dist/client/views/auth/forgot-password-form.mjs +2 -2
  139. package/dist/client/views/auth/login-form.d.mts +2 -2
  140. package/dist/client/views/auth/login-form.mjs +1 -1
  141. package/dist/client/views/auth/reset-password-form.d.mts +2 -2
  142. package/dist/client/views/auth/reset-password-form.mjs +2 -2
  143. package/dist/client/views/auth/setup-form.d.mts +2 -2
  144. package/dist/client/views/collection/auto-form-fields.mjs +11 -9
  145. package/dist/client/views/collection/bulk-action-toolbar.mjs +173 -138
  146. package/dist/client/views/collection/cells/complex-cells.mjs +22 -22
  147. package/dist/client/views/collection/cells/primitive-cells.mjs +1 -1
  148. package/dist/client/views/collection/cells/relation-cells.mjs +147 -129
  149. package/dist/client/views/collection/cells/shared/asset-thumbnail.mjs +224 -278
  150. package/dist/client/views/collection/cells/shared/relation-chip.mjs +64 -36
  151. package/dist/client/views/collection/cells/upload-cells.mjs +199 -9
  152. package/dist/client/views/collection/columns/build-columns.mjs +29 -9
  153. package/dist/client/views/collection/columns/column-defaults.mjs +2 -2
  154. package/dist/client/views/collection/field-renderer.mjs +50 -89
  155. package/dist/client/views/collection/form-view.mjs +237 -227
  156. package/dist/client/views/collection/table-view.mjs +1167 -234
  157. package/dist/client/views/collection/view-skeletons.mjs +222 -79
  158. package/dist/client/views/common/global-search.mjs +29 -18
  159. package/dist/client/views/dashboard/dashboard-grid.mjs +678 -501
  160. package/dist/client/views/dashboard/dashboard-widget.mjs +6 -3
  161. package/dist/client/views/dashboard/widget-card.mjs +23 -14
  162. package/dist/client/views/globals/global-form-view.mjs +634 -589
  163. package/dist/client/views/layout/admin-layout-provider.mjs +67 -70
  164. package/dist/client/views/layout/admin-layout.d.mts +3 -6
  165. package/dist/client/views/layout/admin-layout.mjs +152 -155
  166. package/dist/client/views/layout/admin-router.mjs +936 -616
  167. package/dist/client/views/layout/admin-sidebar.d.mts +38 -1
  168. package/dist/client/views/layout/admin-sidebar.mjs +762 -592
  169. package/dist/client/views/layout/admin-theme.d.mts +10 -0
  170. package/dist/client/views/layout/admin-theme.mjs +84 -0
  171. package/dist/client/views/layout/admin-view-layout.mjs +161 -0
  172. package/dist/client/views/pages/accept-invite-page.d.mts +2 -2
  173. package/dist/client/views/pages/accept-invite-page.mjs +49 -26
  174. package/dist/client/views/pages/dashboard-page.d.mts +2 -2
  175. package/dist/client/views/pages/forgot-password-page.d.mts +2 -2
  176. package/dist/client/views/pages/forgot-password-page.mjs +2 -19
  177. package/dist/client/views/pages/invite-page.d.mts +2 -2
  178. package/dist/client/views/pages/invite-page.mjs +2 -19
  179. package/dist/client/views/pages/login-page.d.mts +3 -3
  180. package/dist/client/views/pages/login-page.mjs +4 -21
  181. package/dist/client/views/pages/reset-password-page.d.mts +2 -2
  182. package/dist/client/views/pages/reset-password-page.mjs +3 -20
  183. package/dist/client/views/pages/setup-page.d.mts +2 -2
  184. package/dist/client/views/pages/setup-page.mjs +70 -71
  185. package/dist/client.d.mts +6 -2
  186. package/dist/client.mjs +2 -1
  187. package/dist/components/rich-text/rich-text-renderer.d.mts +2 -2
  188. package/dist/index.d.mts +6 -2
  189. package/dist/index.mjs +2 -1
  190. package/dist/server/augmentation/dashboard.d.mts +67 -3
  191. package/dist/server/augmentation/form-layout.d.mts +21 -0
  192. package/dist/server/augmentation/index.d.mts +1 -1
  193. package/dist/server/codegen/admin-client-template.mjs +4 -0
  194. package/dist/server/fields/blocks.d.mts +1 -1
  195. package/dist/server/fields/blocks.mjs +12 -0
  196. package/dist/server/fields/rich-text.d.mts +1 -1
  197. package/dist/server/fields/rich-text.mjs +8 -0
  198. package/dist/server/i18n/index.mjs +29 -7
  199. package/dist/server/i18n/messages/cs.mjs +414 -1
  200. package/dist/server/i18n/messages/de.mjs +412 -1
  201. package/dist/server/i18n/messages/en.mjs +166 -1
  202. package/dist/server/i18n/messages/es.mjs +412 -1
  203. package/dist/server/i18n/messages/fr.mjs +412 -1
  204. package/dist/server/i18n/messages/pl.mjs +416 -1
  205. package/dist/server/i18n/messages/pt.mjs +409 -1
  206. package/dist/server/i18n/messages/sk.mjs +216 -2
  207. package/dist/server/modules/admin/block/introspection.mjs +4 -1
  208. package/dist/server/modules/admin/block/prefetch.mjs +12 -2
  209. package/dist/server/modules/admin/collections/account.d.mts +2 -2
  210. package/dist/server/modules/admin/collections/admin-locks.d.mts +2 -2
  211. package/dist/server/modules/admin/collections/admin-preferences.d.mts +39 -39
  212. package/dist/server/modules/admin/collections/admin-saved-views.d.mts +47 -47
  213. package/dist/server/modules/admin/collections/apikey.d.mts +42 -42
  214. package/dist/server/modules/admin/collections/assets.d.mts +20 -20
  215. package/dist/server/modules/admin/collections/assets.mjs +0 -1
  216. package/dist/server/modules/admin/collections/session.d.mts +42 -42
  217. package/dist/server/modules/admin/collections/user.d.mts +40 -28
  218. package/dist/server/modules/admin/collections/user.mjs +40 -9
  219. package/dist/server/modules/admin/collections/verification.d.mts +36 -36
  220. package/dist/server/modules/admin/dto/admin-config.dto.mjs +2 -0
  221. package/dist/server/modules/admin/factories.mjs +7 -18
  222. package/dist/server/modules/admin/index.d.mts +1 -1
  223. package/dist/server/modules/admin/routes/admin-config.d.mts +2 -2
  224. package/dist/server/modules/admin/routes/admin-config.mjs +34 -16
  225. package/dist/server/modules/admin/routes/execute-action.d.mts +9 -9
  226. package/dist/server/modules/admin/routes/execute-action.mjs +67 -28
  227. package/dist/server/modules/admin/routes/i18n-helpers.mjs +34 -0
  228. package/dist/server/modules/admin/routes/locales.d.mts +2 -2
  229. package/dist/server/modules/admin/routes/preview.mjs +25 -17
  230. package/dist/server/modules/admin/routes/reactive.d.mts +9 -9
  231. package/dist/server/modules/admin/routes/route-helpers.mjs +1 -1
  232. package/dist/server/modules/admin/routes/setup.d.mts +10 -10
  233. package/dist/server/modules/admin/routes/setup.mjs +16 -13
  234. package/dist/server/modules/admin/routes/translations.d.mts +4 -4
  235. package/dist/server/modules/admin/routes/translations.mjs +5 -1
  236. package/dist/server/modules/admin-preferences/collections/admin-preferences.mjs +1 -1
  237. package/dist/server/modules/admin-preferences/collections/saved-views.d.mts +2 -2
  238. package/dist/server/modules/audit/.generated/module.d.mts +1 -1
  239. package/dist/server/modules/audit/.generated/module.mjs +1 -1
  240. package/dist/server/modules/audit/collections/audit-log.d.mts +2 -2
  241. package/dist/server/modules/audit/collections/audit-log.mjs +1 -1
  242. package/dist/server/modules/audit/config/app.mjs +99 -42
  243. package/dist/server/modules/audit/jobs/audit-cleanup.mjs +1 -1
  244. package/dist/server/plugin.mjs +4 -2
  245. package/dist/server/proxy-factories.d.mts +4 -3
  246. package/dist/server/proxy-factories.mjs +34 -8
  247. package/dist/shared/types/saved-views.types.d.mts +2 -0
  248. package/package.json +6 -4
  249. package/dist/client/components/fields/rich-text-editor/link-popover.mjs +0 -85
  250. package/dist/client/components/ui/spinner.mjs +0 -52
  251. package/dist/client/components/ui/toolbar.mjs +0 -136
  252. package/dist/client/contexts/breadcrumb-context.mjs +0 -60
  253. package/dist/client/views/layout/admin-topbar.mjs +0 -236
@@ -1,3 +1,4 @@
1
+ import { useValidationTranslator } from "./use-validation-error-map.mjs";
1
2
  import { useCollectionSchema } from "./use-collection-schema.mjs";
2
3
  import { useGlobalSchema } from "./use-global-schema.mjs";
3
4
  import { c } from "react/compiler-runtime";
@@ -37,6 +38,112 @@ function stripAdditionalProperties(schema) {
37
38
  if (s.items) s.items = stripAdditionalProperties(s.items);
38
39
  return s;
39
40
  }
41
+ function translateResolverErrors(errors, translate, parentPath = "") {
42
+ const translatedErrors = Array.isArray(errors) ? [...errors] : { ...errors };
43
+ for (const [key, value] of Object.entries(translatedErrors)) {
44
+ if (!value || typeof value !== "object") continue;
45
+ const path = parentPath ? `${parentPath}.${key}` : key;
46
+ if (isFieldError(value)) translatedErrors[key] = translateFieldError(value, translate, path);
47
+ else translatedErrors[key] = translateResolverErrors(value, translate, path);
48
+ }
49
+ return translatedErrors;
50
+ }
51
+ function isFieldError(value) {
52
+ return "message" in value || "type" in value;
53
+ }
54
+ function translateFieldError(error, translate, path) {
55
+ const translated = translateAjvMessage(error, translate, path);
56
+ const types = error.types && typeof error.types === "object" ? Object.fromEntries(Object.entries(error.types).map(([key, value]) => [key, Array.isArray(value) ? value.map((message) => translateAjvMessage({
57
+ ...error,
58
+ type: key,
59
+ message: String(message)
60
+ }, translate, path)) : translateAjvMessage({
61
+ ...error,
62
+ type: key,
63
+ message: String(value)
64
+ }, translate, path)])) : error.types;
65
+ return {
66
+ ...error,
67
+ message: translated,
68
+ ...types && { types }
69
+ };
70
+ }
71
+ function translateAjvMessage(error, translate, field) {
72
+ const message = typeof error.message === "string" ? error.message : "";
73
+ const type = typeof error.type === "string" ? error.type : "";
74
+ const baseParams = { field };
75
+ if (message.startsWith("validation.")) return translate(message, baseParams);
76
+ switch (type) {
77
+ case "required": return translate("validation.required", baseParams);
78
+ case "type": return translate("validation.invalidType", {
79
+ ...baseParams,
80
+ expected: extractExpectedType(message) ?? "unknown",
81
+ received: extractReceivedType(message) ?? "unknown"
82
+ });
83
+ case "enum": return translate("validation.enum.invalid", baseParams);
84
+ case "minLength": return translate("validation.string.min", {
85
+ ...baseParams,
86
+ min: extractFirstNumber(message) ?? ""
87
+ });
88
+ case "maxLength": return translate("validation.string.max", {
89
+ ...baseParams,
90
+ max: extractFirstNumber(message) ?? ""
91
+ });
92
+ case "pattern": return translate("validation.string.regex", baseParams);
93
+ case "format": return translate(formatMessageToValidationKey(message), baseParams);
94
+ case "minimum":
95
+ case "exclusiveMinimum": return translate("validation.number.min", {
96
+ ...baseParams,
97
+ min: extractFirstNumber(message) ?? ""
98
+ });
99
+ case "maximum":
100
+ case "exclusiveMaximum": return translate("validation.number.max", {
101
+ ...baseParams,
102
+ max: extractFirstNumber(message) ?? ""
103
+ });
104
+ case "minItems": return translate("validation.array.min", {
105
+ ...baseParams,
106
+ min: extractFirstNumber(message) ?? ""
107
+ });
108
+ case "maxItems": return translate("validation.array.max", {
109
+ ...baseParams,
110
+ max: extractFirstNumber(message) ?? ""
111
+ });
112
+ default: return interpolateMessage(message, baseParams);
113
+ }
114
+ }
115
+ function extractFirstNumber(message) {
116
+ const match = message.match(/\d+/);
117
+ return match ? Number(match[0]) : void 0;
118
+ }
119
+ function extractExpectedType(message) {
120
+ return message.match(/must be (?:a |an )?([A-Za-z_][\w-]*)/)?.[1] ?? message.match(/expected ([A-Za-z_][\w-]*)/)?.[1];
121
+ }
122
+ function extractReceivedType(message) {
123
+ return message.match(/received ([A-Za-z_][\w-]*)/)?.[1];
124
+ }
125
+ function formatMessageToValidationKey(message) {
126
+ if (message.includes("\"email\"")) return "validation.string.email";
127
+ if (message.includes("\"uri\"") || message.includes("\"url\"")) return "validation.string.url";
128
+ if (message.includes("\"date-time\"")) return "validation.string.datetime";
129
+ if (message.includes("\"time\"")) return "validation.time.invalid";
130
+ return "validation.string.regex";
131
+ }
132
+ function interpolateMessage(message, params) {
133
+ return message.replace(/\{\{(\w+)\}\}/g, (_, key) => {
134
+ const value = params[key];
135
+ return value !== void 0 ? String(value) : "";
136
+ });
137
+ }
138
+ function withTranslatedResolver(resolver, translate) {
139
+ return async (values, context, options) => {
140
+ const result = await resolver(values, context, options);
141
+ return {
142
+ ...result,
143
+ errors: translateResolverErrors(result.errors, translate)
144
+ };
145
+ };
146
+ }
40
147
  /**
41
148
  * Hook to create a react-hook-form resolver using server's JSON Schema
42
149
  *
@@ -80,77 +187,82 @@ function stripAdditionalProperties(schema) {
80
187
  * ```
81
188
  */
82
189
  function useServerValidation(collection, t0) {
83
- const $ = c(17);
190
+ const $ = c(18);
84
191
  let t1;
85
192
  if ($[0] !== t0) {
86
193
  t1 = t0 === void 0 ? {} : t0;
87
194
  $[0] = t0;
88
195
  $[1] = t1;
89
196
  } else t1 = $[1];
90
- const { mode: t2, enabled: t3 } = t1;
197
+ const { mode: t2, enabled: t3, schema: schemaOverride } = t1;
91
198
  const mode = t2 === void 0 ? "create" : t2;
92
199
  const enabled = t3 === void 0 ? true : t3;
200
+ const translateValidation = useValidationTranslator();
201
+ const shouldFetchSchema = enabled && !schemaOverride;
93
202
  let t4;
94
- if ($[2] !== enabled) {
95
- t4 = { enabled };
96
- $[2] = enabled;
203
+ if ($[2] !== shouldFetchSchema) {
204
+ t4 = { enabled: shouldFetchSchema };
205
+ $[2] = shouldFetchSchema;
97
206
  $[3] = t4;
98
207
  } else t4 = $[3];
99
- const { data: schema, isLoading, error } = useCollectionSchema(collection, t4);
208
+ const { data: queriedSchema, isLoading: queriedIsLoading, error: queriedError } = useCollectionSchema(collection, t4);
209
+ const schema = schemaOverride ?? queriedSchema;
210
+ const isLoading = schemaOverride ? false : queriedIsLoading;
211
+ const error = schemaOverride ? null : queriedError;
100
212
  let t5;
101
- if ($[4] !== collection || $[5] !== error || $[6] !== isLoading || $[7] !== mode || $[8] !== schema?.validation?.insert || $[9] !== schema?.validation?.update) {
213
+ if ($[4] !== collection || $[5] !== error || $[6] !== isLoading || $[7] !== mode || $[8] !== schema?.validation?.insert || $[9] !== schema?.validation?.update || $[10] !== translateValidation) {
102
214
  bb0: {
103
215
  const jsonSchema = stripAdditionalProperties(mode === "create" ? schema?.validation?.insert : schema?.validation?.update);
104
216
  if (!jsonSchema || typeof jsonSchema !== "object") {
105
217
  const t6 = error ?? null;
106
218
  let t7;
107
- if ($[11] !== isLoading || $[12] !== t6) {
219
+ if ($[12] !== isLoading || $[13] !== t6) {
108
220
  t7 = {
109
221
  resolver: void 0,
110
222
  hasServerSchema: false,
111
223
  isLoading,
112
224
  error: t6
113
225
  };
114
- $[11] = isLoading;
115
- $[12] = t6;
116
- $[13] = t7;
117
- } else t7 = $[13];
226
+ $[12] = isLoading;
227
+ $[13] = t6;
228
+ $[14] = t7;
229
+ } else t7 = $[14];
118
230
  t5 = t7;
119
231
  break bb0;
120
232
  }
121
233
  try {
122
- const resolver = ajvResolver(jsonSchema, {
234
+ const resolver = withTranslatedResolver(ajvResolver(jsonSchema, {
123
235
  allErrors: true,
124
236
  strict: false,
125
237
  coerceTypes: true,
126
238
  useDefaults: true,
127
239
  formats: {}
128
- }, { mode: "async" });
240
+ }, { mode: "async" }), translateValidation);
129
241
  let t7;
130
- if ($[14] !== resolver) {
242
+ if ($[15] !== resolver) {
131
243
  t7 = {
132
244
  resolver,
133
245
  hasServerSchema: true,
134
246
  isLoading: false,
135
247
  error: null
136
248
  };
137
- $[14] = resolver;
138
- $[15] = t7;
139
- } else t7 = $[15];
249
+ $[15] = resolver;
250
+ $[16] = t7;
251
+ } else t7 = $[16];
140
252
  t5 = t7;
141
253
  } catch (t6) {
142
254
  const e = t6;
143
255
  console.warn(`[useServerValidation] Failed to compile JSON Schema for ${collection}:`, e);
144
256
  let t7;
145
- if ($[16] === Symbol.for("react.memo_cache_sentinel")) {
257
+ if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
146
258
  t7 = {
147
259
  resolver: void 0,
148
260
  hasServerSchema: false,
149
261
  isLoading: false,
150
262
  error: e instanceof Error ? e : new Error(String(e))
151
263
  };
152
- $[16] = t7;
153
- } else t7 = $[16];
264
+ $[17] = t7;
265
+ } else t7 = $[17];
154
266
  t5 = t7;
155
267
  }
156
268
  }
@@ -160,8 +272,9 @@ function useServerValidation(collection, t0) {
160
272
  $[7] = mode;
161
273
  $[8] = schema?.validation?.insert;
162
274
  $[9] = schema?.validation?.update;
163
- $[10] = t5;
164
- } else t5 = $[10];
275
+ $[10] = translateValidation;
276
+ $[11] = t5;
277
+ } else t5 = $[11];
165
278
  return t5;
166
279
  }
167
280
  /**
@@ -206,7 +319,7 @@ function usePreferServerValidation(collection, t0, fallbackResolver) {
206
319
  * @returns Server validation result with resolver
207
320
  */
208
321
  function useGlobalServerValidation(globalName, t0) {
209
- const $ = c(15);
322
+ const $ = c(16);
210
323
  let t1;
211
324
  if ($[0] !== t0) {
212
325
  t1 = t0 === void 0 ? {} : t0;
@@ -215,6 +328,7 @@ function useGlobalServerValidation(globalName, t0) {
215
328
  } else t1 = $[1];
216
329
  const { enabled: t2 } = t1;
217
330
  const enabled = t2 === void 0 ? true : t2;
331
+ const translateValidation = useValidationTranslator();
218
332
  let t3;
219
333
  if ($[2] !== enabled) {
220
334
  t3 = { enabled };
@@ -223,58 +337,58 @@ function useGlobalServerValidation(globalName, t0) {
223
337
  } else t3 = $[3];
224
338
  const { data: schema, isLoading, error } = useGlobalSchema(globalName, t3);
225
339
  let t4;
226
- if ($[4] !== error || $[5] !== globalName || $[6] !== isLoading || $[7] !== schema?.validation?.update) {
340
+ if ($[4] !== error || $[5] !== globalName || $[6] !== isLoading || $[7] !== schema?.validation?.update || $[8] !== translateValidation) {
227
341
  bb0: {
228
342
  const jsonSchema = stripAdditionalProperties(schema?.validation?.update);
229
343
  if (!jsonSchema || typeof jsonSchema !== "object") {
230
344
  const t5 = error ?? null;
231
345
  let t6;
232
- if ($[9] !== isLoading || $[10] !== t5) {
346
+ if ($[10] !== isLoading || $[11] !== t5) {
233
347
  t6 = {
234
348
  resolver: void 0,
235
349
  hasServerSchema: false,
236
350
  isLoading,
237
351
  error: t5
238
352
  };
239
- $[9] = isLoading;
240
- $[10] = t5;
241
- $[11] = t6;
242
- } else t6 = $[11];
353
+ $[10] = isLoading;
354
+ $[11] = t5;
355
+ $[12] = t6;
356
+ } else t6 = $[12];
243
357
  t4 = t6;
244
358
  break bb0;
245
359
  }
246
360
  try {
247
- const resolver = ajvResolver(jsonSchema, {
361
+ const resolver = withTranslatedResolver(ajvResolver(jsonSchema, {
248
362
  allErrors: true,
249
363
  strict: false,
250
364
  coerceTypes: true,
251
365
  useDefaults: true
252
- }, { mode: "async" });
366
+ }, { mode: "async" }), translateValidation);
253
367
  let t6;
254
- if ($[12] !== resolver) {
368
+ if ($[13] !== resolver) {
255
369
  t6 = {
256
370
  resolver,
257
371
  hasServerSchema: true,
258
372
  isLoading: false,
259
373
  error: null
260
374
  };
261
- $[12] = resolver;
262
- $[13] = t6;
263
- } else t6 = $[13];
375
+ $[13] = resolver;
376
+ $[14] = t6;
377
+ } else t6 = $[14];
264
378
  t4 = t6;
265
379
  } catch (t5) {
266
380
  const e = t5;
267
381
  console.warn(`[useGlobalServerValidation] Failed to compile JSON Schema for ${globalName}:`, e);
268
382
  let t6;
269
- if ($[14] === Symbol.for("react.memo_cache_sentinel")) {
383
+ if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
270
384
  t6 = {
271
385
  resolver: void 0,
272
386
  hasServerSchema: false,
273
387
  isLoading: false,
274
388
  error: e instanceof Error ? e : new Error(String(e))
275
389
  };
276
- $[14] = t6;
277
- } else t6 = $[14];
390
+ $[15] = t6;
391
+ } else t6 = $[15];
278
392
  t4 = t6;
279
393
  }
280
394
  }
@@ -282,8 +396,9 @@ function useGlobalServerValidation(globalName, t0) {
282
396
  $[5] = globalName;
283
397
  $[6] = isLoading;
284
398
  $[7] = schema?.validation?.update;
285
- $[8] = t4;
286
- } else t4 = $[8];
399
+ $[8] = translateValidation;
400
+ $[9] = t4;
401
+ } else t4 = $[9];
287
402
  return t4;
288
403
  }
289
404
 
@@ -42,7 +42,7 @@ function useServerWidgetData(widgetId, options) {
42
42
  $[3] = widgetId;
43
43
  $[4] = t1;
44
44
  } else t1 = $[4];
45
- const t2 = options?.enabled ?? true;
45
+ const t2 = !!widgetId && (options?.enabled ?? true);
46
46
  const t3 = options?.refreshInterval;
47
47
  let t4;
48
48
  if ($[5] !== t0 || $[6] !== t1 || $[7] !== t2 || $[8] !== t3) {
@@ -5,17 +5,17 @@ import * as _tanstack_react_query0 from "@tanstack/react-query";
5
5
  /**
6
6
  * Setup Status Hook
7
7
  *
8
- * Hook to check if the app setup is required (no users exist).
8
+ * Hook to check if the app setup is required (no admin users exist).
9
9
  * Useful for redirecting to setup page on first visit.
10
10
  */
11
11
  interface SetupStatus {
12
- /** Whether setup is required (no users exist) */
12
+ /** Whether setup is required (no admin users exist) */
13
13
  required: boolean;
14
14
  }
15
15
  /**
16
16
  * Check if setup is required.
17
17
  *
18
- * Returns `required: true` if no users exist in the system,
18
+ * Returns `required: true` if no admin users exist in the system,
19
19
  * meaning the setup page should be shown to create the first admin.
20
20
  *
21
21
  * @example
@@ -6,13 +6,13 @@ import { useQuery } from "@tanstack/react-query";
6
6
  /**
7
7
  * Setup Status Hook
8
8
  *
9
- * Hook to check if the app setup is required (no users exist).
9
+ * Hook to check if the app setup is required (no admin users exist).
10
10
  * Useful for redirecting to setup page on first visit.
11
11
  */
12
12
  /**
13
13
  * Check if setup is required.
14
14
  *
15
- * Returns `required: true` if no users exist in the system,
15
+ * Returns `required: true` if no admin users exist in the system,
16
16
  * meaning the setup page should be shown to create the first admin.
17
17
  *
18
18
  * @example
@@ -80,16 +80,8 @@ function useTransitionStage(resourceName, options) {
80
80
  let t2;
81
81
  if ($[6] !== mode || $[7] !== queryClient || $[8] !== resourceName) {
82
82
  t2 = () => {
83
- if (mode === "collection") queryClient.invalidateQueries({ queryKey: [
84
- "questpie",
85
- "collections",
86
- resourceName
87
- ] });
88
- else queryClient.invalidateQueries({ queryKey: [
89
- "questpie",
90
- "globals",
91
- resourceName
92
- ] });
83
+ if (mode === "collection") queryClient.invalidateQueries({ queryKey: ["questpie", "collections"] });
84
+ else queryClient.invalidateQueries({ queryKey: ["questpie", "globals"] });
93
85
  queryClient.invalidateQueries({ queryKey: [
94
86
  "questpie",
95
87
  "audit",
@@ -1,6 +1,6 @@
1
1
  import { useSafeI18n } from "../i18n/hooks.mjs";
2
2
  import { c } from "react/compiler-runtime";
3
- import { createZodErrorMap } from "questpie/shared";
3
+ import { createValidationTranslator, createZodErrorMap } from "questpie/shared";
4
4
 
5
5
  //#region src/client/hooks/use-validation-error-map.ts
6
6
  /**
@@ -33,25 +33,43 @@ import { createZodErrorMap } from "questpie/shared";
33
33
  * }
34
34
  * ```
35
35
  */
36
+ function useValidationTranslator() {
37
+ const $ = c(5);
38
+ const i18n = useSafeI18n();
39
+ const t0 = i18n?.locale;
40
+ let t1;
41
+ if ($[0] !== t0) {
42
+ t1 = createValidationTranslator(void 0, t0);
43
+ $[0] = t0;
44
+ $[1] = t1;
45
+ } else t1 = $[1];
46
+ const fallbackTranslate = t1;
47
+ let t2;
48
+ if ($[2] !== fallbackTranslate || $[3] !== i18n) {
49
+ t2 = (key, params) => {
50
+ if (i18n) {
51
+ const translated = i18n.t(key, params);
52
+ if (translated !== key) return translated;
53
+ }
54
+ return fallbackTranslate(key, params);
55
+ };
56
+ $[2] = fallbackTranslate;
57
+ $[3] = i18n;
58
+ $[4] = t2;
59
+ } else t2 = $[4];
60
+ return t2;
61
+ }
36
62
  function useValidationErrorMap() {
37
63
  const $ = c(2);
38
- const i18n = useSafeI18n();
64
+ const translate = useValidationTranslator();
39
65
  let t0;
40
- if ($[0] !== i18n) {
41
- const translate = (key, params) => {
42
- if (i18n) return i18n.t(key, params);
43
- if (!params) return key;
44
- return key.replace(/\{\{(\w+)\}\}/g, (_, paramKey) => {
45
- const value = params[paramKey];
46
- return value !== void 0 ? String(value) : `{{${paramKey}}}`;
47
- });
48
- };
66
+ if ($[0] !== translate) {
49
67
  t0 = createZodErrorMap(translate);
50
- $[0] = i18n;
68
+ $[0] = translate;
51
69
  $[1] = t0;
52
70
  } else t0 = $[1];
53
71
  return t0;
54
72
  }
55
73
 
56
74
  //#endregion
57
- export { useValidationErrorMap };
75
+ export { useValidationErrorMap, useValidationTranslator };