@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
@@ -24,7 +24,6 @@ import { detectManyToManyRelations, hasManyToManyRelations } from "../../utils/d
24
24
  import { shouldHandleAdminShortcut } from "../../utils/keyboard-shortcuts.mjs";
25
25
  import { AdminViewHeader } from "../layout/admin-view-layout.mjs";
26
26
  import { useGlobalAuditHistory } from "../../hooks/use-audit-history.mjs";
27
- import { c } from "react/compiler-runtime";
28
27
  import { Icon } from "@iconify/react";
29
28
  import * as React from "react";
30
29
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -50,1350 +49,527 @@ function extractReactiveConfigs(schema) {
50
49
  return configs;
51
50
  }
52
51
  function GlobalFormViewSkeleton() {
53
- const $ = c(5);
54
- let t0;
55
- if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
56
- t0 = /* @__PURE__ */ jsx("span", {
57
- className: "sr-only",
58
- children: "Loading global form"
59
- });
60
- $[0] = t0;
61
- } else t0 = $[0];
62
- let t1;
63
- if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
64
- t1 = /* @__PURE__ */ jsx(AdminViewHeader, {
65
- title: /* @__PURE__ */ jsx(Skeleton, {
66
- variant: "text",
67
- className: "h-7 w-48"
52
+ return /* @__PURE__ */ jsxs("div", {
53
+ className: "qa-global-form w-full space-y-4",
54
+ "aria-busy": "true",
55
+ children: [
56
+ /* @__PURE__ */ jsx("span", {
57
+ className: "sr-only",
58
+ children: "Loading global form"
68
59
  }),
69
- meta: /* @__PURE__ */ jsx(Skeleton, {
70
- variant: "text",
71
- className: "h-3 w-36"
60
+ /* @__PURE__ */ jsx(AdminViewHeader, {
61
+ title: /* @__PURE__ */ jsx(Skeleton, {
62
+ variant: "text",
63
+ className: "h-7 w-48"
64
+ }),
65
+ meta: /* @__PURE__ */ jsx(Skeleton, {
66
+ variant: "text",
67
+ className: "h-3 w-36"
68
+ }),
69
+ actions: /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Skeleton, { className: "size-8" }), /* @__PURE__ */ jsx(Skeleton, { className: "h-8 w-20" })] })
72
70
  }),
73
- actions: /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Skeleton, { className: "size-8" }), /* @__PURE__ */ jsx(Skeleton, { className: "h-8 w-20" })] })
74
- });
75
- $[1] = t1;
76
- } else t1 = $[1];
77
- let t2;
78
- if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
79
- t2 = /* @__PURE__ */ jsxs("div", {
80
- className: "space-y-2",
81
- children: [/* @__PURE__ */ jsx(Skeleton, {
82
- variant: "text",
83
- className: "h-4 w-24"
84
- }), /* @__PURE__ */ jsx(Skeleton, { className: "h-10 w-full" })]
85
- });
86
- $[2] = t2;
87
- } else t2 = $[2];
88
- let t3;
89
- if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
90
- t3 = /* @__PURE__ */ jsxs("div", {
91
- className: "space-y-2",
92
- children: [/* @__PURE__ */ jsx(Skeleton, {
93
- variant: "text",
94
- className: "h-4 w-32"
95
- }), /* @__PURE__ */ jsx(Skeleton, { className: "h-10 w-full" })]
96
- });
97
- $[3] = t3;
98
- } else t3 = $[3];
99
- let t4;
100
- if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
101
- t4 = /* @__PURE__ */ jsxs("div", {
102
- className: "qa-global-form w-full space-y-4",
103
- "aria-busy": "true",
104
- children: [
105
- t0,
106
- t1,
107
- /* @__PURE__ */ jsxs("div", {
108
- className: "space-y-4",
109
- children: [
110
- t2,
111
- t3,
112
- /* @__PURE__ */ jsxs("div", {
113
- className: "space-y-2",
114
- children: [/* @__PURE__ */ jsx(Skeleton, {
115
- variant: "text",
116
- className: "h-4 w-28"
117
- }), /* @__PURE__ */ jsx(Skeleton, { className: "h-32 w-full" })]
118
- })
119
- ]
120
- })
121
- ]
122
- });
123
- $[4] = t4;
124
- } else t4 = $[4];
125
- return t4;
71
+ /* @__PURE__ */ jsxs("div", {
72
+ className: "space-y-4",
73
+ children: [
74
+ /* @__PURE__ */ jsxs("div", {
75
+ className: "space-y-2",
76
+ children: [/* @__PURE__ */ jsx(Skeleton, {
77
+ variant: "text",
78
+ className: "h-4 w-24"
79
+ }), /* @__PURE__ */ jsx(Skeleton, { className: "h-10 w-full" })]
80
+ }),
81
+ /* @__PURE__ */ jsxs("div", {
82
+ className: "space-y-2",
83
+ children: [/* @__PURE__ */ jsx(Skeleton, {
84
+ variant: "text",
85
+ className: "h-4 w-32"
86
+ }), /* @__PURE__ */ jsx(Skeleton, { className: "h-10 w-full" })]
87
+ }),
88
+ /* @__PURE__ */ jsxs("div", {
89
+ className: "space-y-2",
90
+ children: [/* @__PURE__ */ jsx(Skeleton, {
91
+ variant: "text",
92
+ className: "h-4 w-28"
93
+ }), /* @__PURE__ */ jsx(Skeleton, { className: "h-32 w-full" })]
94
+ })
95
+ ]
96
+ })
97
+ ]
98
+ });
126
99
  }
127
100
  /**
128
101
  * GlobalFormView - Default form-based edit view for globals
129
102
  */
130
- function GlobalFormView(t0) {
131
- const $ = c(312);
132
- const { global: globalName, config, viewConfig, registry, showMeta: t1, headerActions, onSuccess, onError } = t0;
133
- const showMeta = t1 === void 0 ? true : t1;
103
+ function GlobalFormView({ global: globalName, config, viewConfig, registry, showMeta = true, headerActions, onSuccess, onError }) {
134
104
  const { t } = useTranslation();
135
105
  const resolveText = useResolveText();
136
106
  const { fields: schemaFields, schema: globalSchema } = useGlobalFields(globalName);
137
- config?.fields;
138
- const t2 = config?.fields;
139
- const t3 = globalSchema;
140
- let t4;
141
- if ($[0] !== t2 || $[1] !== t3) {
142
- t4 = detectManyToManyRelations({
143
- fields: t2,
144
- schema: t3
145
- });
146
- $[0] = t2;
147
- $[1] = t3;
148
- $[2] = t4;
149
- } else t4 = $[2];
150
- const withRelations = t4;
151
- let t5;
152
- if ($[3] !== withRelations) {
153
- t5 = hasManyToManyRelations(withRelations) ? { with: withRelations } : void 0;
154
- $[3] = withRelations;
155
- $[4] = t5;
156
- } else t5 = $[4];
157
- const { data: globalDataRaw, isLoading: dataLoading, error: dataError } = useGlobal(globalName, t5);
158
- let t6;
159
- bb0: {
160
- if (!globalDataRaw || !hasManyToManyRelations(withRelations)) {
161
- t6 = globalDataRaw;
162
- break bb0;
107
+ const withRelations = React.useMemo(() => detectManyToManyRelations({
108
+ fields: config?.fields,
109
+ schema: globalSchema
110
+ }), [config?.fields, globalSchema]);
111
+ const { data: globalDataRaw, isLoading: dataLoading, error: dataError } = useGlobal(globalName, hasManyToManyRelations(withRelations) ? { with: withRelations } : void 0);
112
+ const globalData = React.useMemo(() => {
113
+ if (!globalDataRaw || !hasManyToManyRelations(withRelations)) return globalDataRaw;
114
+ const result = { ...globalDataRaw };
115
+ for (const key of Object.keys(withRelations)) {
116
+ const value = result[key];
117
+ if (Array.isArray(value) && value.length > 0 && typeof value[0] === "object" && value[0]?.id) result[key] = value.map((v) => v.id);
163
118
  }
164
- const t7$1 = globalDataRaw;
165
- let result;
166
- if ($[5] !== t7$1 || $[6] !== withRelations) {
167
- result = { ...t7$1 };
168
- for (const key of Object.keys(withRelations)) {
169
- const value = result[key];
170
- if (Array.isArray(value) && value.length > 0 && typeof value[0] === "object" && value[0]?.id) result[key] = value.map(_temp);
171
- }
172
- $[5] = t7$1;
173
- $[6] = withRelations;
174
- $[7] = result;
175
- } else result = $[7];
176
- t6 = result;
177
- }
178
- const globalData = t6;
119
+ return result;
120
+ }, [globalDataRaw, withRelations]);
179
121
  const { locale: contentLocale, setLocale: setContentLocale } = useScopedLocale();
180
- const contentLocales = useSafeContentLocales();
181
- let t7;
182
- if ($[8] !== contentLocales?.locales) {
183
- t7 = contentLocales?.locales ?? [];
184
- $[8] = contentLocales?.locales;
185
- $[9] = t7;
186
- } else t7 = $[9];
187
- const localeOptions = t7;
188
- let t8;
189
- if ($[10] !== onSuccess || $[11] !== t) {
190
- t8 = (data) => {
122
+ const localeOptions = useSafeContentLocales()?.locales ?? [];
123
+ const updateMutation = useGlobalUpdate(globalName, {
124
+ onSuccess: (data) => {
191
125
  toast.success(t("toast.saveSuccess"));
192
126
  onSuccess?.(data);
193
- };
194
- $[10] = onSuccess;
195
- $[11] = t;
196
- $[12] = t8;
197
- } else t8 = $[12];
198
- let t9;
199
- if ($[13] !== onError) {
200
- t9 = (error) => {
127
+ },
128
+ onError: (error) => {
201
129
  onError?.(error);
202
- };
203
- $[13] = onError;
204
- $[14] = t9;
205
- } else t9 = $[14];
206
- let t10;
207
- if ($[15] !== t8 || $[16] !== t9) {
208
- t10 = {
209
- onSuccess: t8,
210
- onError: t9
211
- };
212
- $[15] = t8;
213
- $[16] = t9;
214
- $[17] = t10;
215
- } else t10 = $[17];
216
- const updateMutation = useGlobalUpdate(globalName, t10);
130
+ }
131
+ });
217
132
  const revertVersionMutation = useGlobalRevertVersion(globalName);
218
- let t11;
219
- if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
220
- t11 = { legacyKey: "history" };
221
- $[18] = t11;
222
- } else t11 = $[18];
223
- const [isHistoryOpen, setIsHistoryOpen] = useSidebarSearchParam("history", t11);
133
+ const [isHistoryOpen, setIsHistoryOpen] = useSidebarSearchParam("history", { legacyKey: "history" });
224
134
  const [pendingRevertVersion, setPendingRevertVersion] = React.useState(null);
225
- const t12 = globalData?.id;
226
- let t13;
227
- if ($[19] !== t12) {
228
- t13 = {
229
- id: t12,
230
- limit: 50
231
- };
232
- $[19] = t12;
233
- $[20] = t13;
234
- } else t13 = $[20];
235
- const t14 = isHistoryOpen && !!globalSchema?.options?.versioning;
236
- let t15;
237
- if ($[21] !== t14) {
238
- t15 = { enabled: t14 };
239
- $[21] = t14;
240
- $[22] = t15;
241
- } else t15 = $[22];
242
- const { data: versionsData, isLoading: versionsLoading } = useGlobalVersions(globalName, t13, t15);
243
- let t16;
244
- if ($[23] === Symbol.for("react.memo_cache_sentinel")) {
245
- t16 = { limit: 50 };
246
- $[23] = t16;
247
- } else t16 = $[23];
248
- let t17;
249
- if ($[24] !== isHistoryOpen) {
250
- t17 = { enabled: isHistoryOpen };
251
- $[24] = isHistoryOpen;
252
- $[25] = t17;
253
- } else t17 = $[25];
254
- const { data: auditData, isLoading: auditLoading } = useGlobalAuditHistory(globalName, t16, t17);
135
+ const { data: versionsData, isLoading: versionsLoading } = useGlobalVersions(globalName, {
136
+ id: globalData?.id,
137
+ limit: 50
138
+ }, { enabled: isHistoryOpen && !!globalSchema?.options?.versioning });
139
+ const { data: auditData, isLoading: auditLoading } = useGlobalAuditHistory(globalName, { limit: 50 }, { enabled: isHistoryOpen });
255
140
  const workflowConfig = globalSchema?.options?.workflow;
256
141
  const workflowEnabled = !!workflowConfig?.enabled;
257
- const t18 = globalData?.id;
258
- let t19;
259
- if ($[26] !== t18) {
260
- t19 = {
261
- id: t18,
262
- limit: 1
263
- };
264
- $[26] = t18;
265
- $[27] = t19;
266
- } else t19 = $[27];
267
- const t20 = workflowEnabled && !!globalData?.id;
268
- let t21;
269
- if ($[28] !== t20) {
270
- t21 = { enabled: t20 };
271
- $[28] = t20;
272
- $[29] = t21;
273
- } else t21 = $[29];
274
- const { data: latestVersionData } = useGlobalVersions(globalName, t19, t21);
142
+ /** Lightweight versions query (limit: 1) to read the current stage. */
143
+ const { data: latestVersionData } = useGlobalVersions(globalName, {
144
+ id: globalData?.id,
145
+ limit: 1
146
+ }, { enabled: workflowEnabled && !!globalData?.id });
275
147
  const currentStage = latestVersionData?.[0]?.versionStage ?? workflowConfig?.initialStage ?? null;
276
- workflowConfig?.stages;
277
- let t22;
278
- if ($[30] !== currentStage || $[31] !== workflowConfig?.stages) {
279
- t22 = workflowConfig?.stages?.find((s) => s.name === currentStage) ?? null;
280
- $[30] = currentStage;
281
- $[31] = workflowConfig?.stages;
282
- $[32] = t22;
283
- } else t22 = $[32];
284
- const currentStageConfig = t22;
148
+ const currentStageConfig = React.useMemo(() => workflowConfig?.stages?.find((s) => s.name === currentStage) ?? null, [workflowConfig?.stages, currentStage]);
285
149
  const currentStageLabel = currentStageConfig?.label ?? currentStage ?? "";
286
- let t23;
287
- bb1: {
288
- if (!workflowConfig?.stages || !currentStage) {
289
- let t24$2;
290
- if ($[33] === Symbol.for("react.memo_cache_sentinel")) {
291
- t24$2 = [];
292
- $[33] = t24$2;
293
- } else t24$2 = $[33];
294
- t23 = t24$2;
295
- break bb1;
296
- }
150
+ /** Allowed transitions from the current stage. */
151
+ const allowedTransitions = React.useMemo(() => {
152
+ if (!workflowConfig?.stages || !currentStage) return [];
297
153
  const stageNames = currentStageConfig?.transitions;
298
- if (stageNames && stageNames.length > 0) {
299
- let t24$2;
300
- if ($[34] !== stageNames || $[35] !== workflowConfig) {
301
- let t25$1;
302
- if ($[37] !== workflowConfig) {
303
- t25$1 = (name) => workflowConfig.stages.find((s_0) => s_0.name === name);
304
- $[37] = workflowConfig;
305
- $[38] = t25$1;
306
- } else t25$1 = $[38];
307
- t24$2 = stageNames.map(t25$1).filter(Boolean);
308
- $[34] = stageNames;
309
- $[35] = workflowConfig;
310
- $[36] = t24$2;
311
- } else t24$2 = $[36];
312
- t23 = t24$2;
313
- break bb1;
314
- }
315
- let t24$1;
316
- if ($[39] !== currentStage || $[40] !== workflowConfig.stages) {
317
- let t25$1;
318
- if ($[42] !== currentStage) {
319
- t25$1 = (s_1) => s_1.name !== currentStage;
320
- $[42] = currentStage;
321
- $[43] = t25$1;
322
- } else t25$1 = $[43];
323
- t24$1 = workflowConfig.stages.filter(t25$1);
324
- $[39] = currentStage;
325
- $[40] = workflowConfig.stages;
326
- $[41] = t24$1;
327
- } else t24$1 = $[41];
328
- t23 = t24$1;
329
- }
330
- const allowedTransitions = t23;
331
- let t24;
332
- if ($[44] === Symbol.for("react.memo_cache_sentinel")) {
333
- t24 = { mode: "global" };
334
- $[44] = t24;
335
- } else t24 = $[44];
336
- const transitionMutation = useTransitionStage(globalName, t24);
154
+ if (stageNames && stageNames.length > 0) return stageNames.map((name) => workflowConfig.stages.find((s) => s.name === name)).filter(Boolean);
155
+ return workflowConfig.stages.filter((s) => s.name !== currentStage);
156
+ }, [
157
+ workflowConfig,
158
+ currentStage,
159
+ currentStageConfig
160
+ ]);
161
+ const transitionMutation = useTransitionStage(globalName, { mode: "global" });
337
162
  const [transitionTarget, setTransitionTarget] = React.useState(null);
338
163
  const [transitionSchedule, setTransitionSchedule] = React.useState(false);
339
164
  const [transitionScheduledAt, setTransitionScheduledAt] = React.useState(null);
340
165
  const { resolver } = useGlobalServerValidation(globalName);
341
- let t25;
342
- if ($[45] !== globalData) {
343
- t25 = globalData ?? {};
344
- $[45] = globalData;
345
- $[46] = t25;
346
- } else t25 = $[46];
347
- const t26 = t25;
348
- let t27;
349
- if ($[47] !== resolver || $[48] !== t26) {
350
- t27 = {
351
- defaultValues: t26,
352
- resolver
166
+ const form = useForm({
167
+ defaultValues: globalData ?? {},
168
+ resolver
169
+ });
170
+ /** Execute the confirmed workflow transition (immediate or scheduled). */
171
+ const confirmTransition = React.useCallback(() => {
172
+ if (!transitionTarget) return;
173
+ const params = { stage: transitionTarget.name };
174
+ if (transitionSchedule) {
175
+ if (transitionScheduledAt) params.scheduledAt = transitionScheduledAt;
176
+ }
177
+ const stageLabel = transitionTarget.label ? transitionTarget.label : transitionTarget.name;
178
+ const resetTransitionState = () => {
179
+ setTransitionTarget(null);
180
+ setTransitionSchedule(false);
181
+ setTransitionScheduledAt(null);
353
182
  };
354
- $[47] = resolver;
355
- $[48] = t26;
356
- $[49] = t27;
357
- } else t27 = $[49];
358
- const form = useForm(t27);
359
- let t28;
360
- if ($[50] !== form || $[51] !== t || $[52] !== transitionMutation || $[53] !== transitionSchedule || $[54] !== transitionScheduledAt || $[55] !== transitionTarget) {
361
- t28 = () => {
362
- if (!transitionTarget) return;
363
- const params = { stage: transitionTarget.name };
364
- if (transitionSchedule) {
365
- if (transitionScheduledAt) params.scheduledAt = transitionScheduledAt;
183
+ transitionMutation.mutateAsync(params).then((result) => {
184
+ if (result) {
185
+ if (typeof result === "object") form.reset(result);
366
186
  }
367
- const stageLabel = transitionTarget.label ? transitionTarget.label : transitionTarget.name;
368
- const resetTransitionState = () => {
369
- setTransitionTarget(null);
370
- setTransitionSchedule(false);
371
- setTransitionScheduledAt(null);
372
- };
373
- transitionMutation.mutateAsync(params).then((result_0) => {
374
- if (result_0) {
375
- if (typeof result_0 === "object") form.reset(result_0);
376
- }
377
- if (transitionSchedule) if (transitionScheduledAt) toast.success(t("workflow.scheduledSuccess", {
378
- stage: stageLabel,
379
- date: transitionScheduledAt.toLocaleString()
380
- }));
381
- else toast.success(t("workflow.transitionSuccess", { stage: stageLabel }));
382
- else toast.success(t("workflow.transitionSuccess", { stage: stageLabel }));
383
- resetTransitionState();
384
- }, (err) => {
385
- let description;
386
- if (err instanceof Error) description = err.message;
387
- else description = t("error.unknown");
388
- toast.error(t("workflow.transitionFailed"), { description });
389
- resetTransitionState();
390
- });
391
- };
392
- $[50] = form;
393
- $[51] = t;
394
- $[52] = transitionMutation;
395
- $[53] = transitionSchedule;
396
- $[54] = transitionScheduledAt;
397
- $[55] = transitionTarget;
398
- $[56] = t28;
399
- } else t28 = $[56];
400
- const confirmTransition = t28;
187
+ if (transitionSchedule) if (transitionScheduledAt) toast.success(t("workflow.scheduledSuccess", {
188
+ stage: stageLabel,
189
+ date: transitionScheduledAt.toLocaleString()
190
+ }));
191
+ else toast.success(t("workflow.transitionSuccess", { stage: stageLabel }));
192
+ else toast.success(t("workflow.transitionSuccess", { stage: stageLabel }));
193
+ resetTransitionState();
194
+ }, (err) => {
195
+ let description;
196
+ if (err instanceof Error) description = err.message;
197
+ else description = t("error.unknown");
198
+ toast.error(t("workflow.transitionFailed"), { description });
199
+ resetTransitionState();
200
+ });
201
+ }, [
202
+ transitionTarget,
203
+ transitionSchedule,
204
+ transitionScheduledAt,
205
+ transitionMutation,
206
+ form,
207
+ t
208
+ ]);
401
209
  const prevLocaleRef = React.useRef(contentLocale);
402
210
  const skipResetRef = React.useRef(false);
403
211
  const localeSnapshotRef = React.useRef(null);
404
- let t29;
405
- if ($[57] === Symbol.for("react.memo_cache_sentinel")) {
406
- t29 = {
212
+ const [localeChangeDialog, setLocaleChangeDialog] = React.useState({
213
+ open: false,
214
+ pendingLocale: null
215
+ });
216
+ const handleContentLocaleChange = React.useCallback((nextLocale) => {
217
+ if (nextLocale === prevLocaleRef.current) return;
218
+ if (form.formState.isDirty && !localeChangeDialog.open) {
219
+ skipResetRef.current = true;
220
+ localeSnapshotRef.current = form.getValues();
221
+ setLocaleChangeDialog({
222
+ open: true,
223
+ pendingLocale: nextLocale
224
+ });
225
+ return;
226
+ }
227
+ prevLocaleRef.current = nextLocale;
228
+ skipResetRef.current = false;
229
+ setContentLocale(nextLocale);
230
+ }, [
231
+ form,
232
+ form.formState.isDirty,
233
+ localeChangeDialog.open,
234
+ setContentLocale
235
+ ]);
236
+ const handleLocaleChangeConfirm = React.useCallback(() => {
237
+ skipResetRef.current = false;
238
+ localeSnapshotRef.current = null;
239
+ if (localeChangeDialog.pendingLocale) {
240
+ prevLocaleRef.current = localeChangeDialog.pendingLocale;
241
+ setContentLocale(localeChangeDialog.pendingLocale);
242
+ }
243
+ setLocaleChangeDialog({
244
+ open: false,
245
+ pendingLocale: null
246
+ });
247
+ }, [localeChangeDialog.pendingLocale, setContentLocale]);
248
+ React.useEffect(() => {
249
+ if (!localeChangeDialog.open) prevLocaleRef.current = contentLocale;
250
+ }, [contentLocale, localeChangeDialog.open]);
251
+ const handleLocaleChangeCancel = React.useCallback(() => {
252
+ skipResetRef.current = false;
253
+ if (localeSnapshotRef.current) form.reset(localeSnapshotRef.current, {
254
+ keepDirty: true,
255
+ keepDirtyValues: true,
256
+ keepErrors: true,
257
+ keepTouched: true
258
+ });
259
+ localeSnapshotRef.current = null;
260
+ setLocaleChangeDialog({
407
261
  open: false,
408
262
  pendingLocale: null
263
+ });
264
+ }, [form]);
265
+ React.useEffect(() => {
266
+ if (skipResetRef.current) return;
267
+ if (globalData) form.reset(globalData);
268
+ }, [form, globalData]);
269
+ const reactiveConfigs = React.useMemo(() => extractReactiveConfigs(globalSchema), [globalSchema]);
270
+ useReactiveFields({
271
+ collection: globalName,
272
+ mode: "global",
273
+ reactiveConfigs,
274
+ enabled: !dataLoading && Object.keys(reactiveConfigs).length > 0,
275
+ debounce: 300,
276
+ form
277
+ });
278
+ const resolvedConfig = React.useMemo(() => {
279
+ if (!viewConfig) return config;
280
+ return {
281
+ ...config ?? {},
282
+ form: viewConfig
409
283
  };
410
- $[57] = t29;
411
- } else t29 = $[57];
412
- const [localeChangeDialog, setLocaleChangeDialog] = React.useState(t29);
413
- let t30;
414
- if ($[58] !== form || $[59] !== localeChangeDialog.open || $[60] !== setContentLocale) {
415
- t30 = (nextLocale) => {
416
- if (nextLocale === prevLocaleRef.current) return;
417
- if (form.formState.isDirty && !localeChangeDialog.open) {
418
- skipResetRef.current = true;
419
- localeSnapshotRef.current = form.getValues();
420
- setLocaleChangeDialog({
421
- open: true,
422
- pendingLocale: nextLocale
284
+ }, [config, viewConfig]);
285
+ const onSubmit = React.useCallback(async (data) => {
286
+ try {
287
+ const result = await updateMutation.mutateAsync({ data });
288
+ if (result) form.reset(result);
289
+ } catch (error) {
290
+ if (error instanceof QuestpieClientError && error.fieldErrors && error.fieldErrors.length > 0) {
291
+ for (const fieldError of error.fieldErrors) form.setError(fieldError.path, {
292
+ type: "server",
293
+ message: fieldError.message
423
294
  });
295
+ toast.error(t("toast.validationFailed"), { description: t("toast.validationDescription") });
424
296
  return;
425
297
  }
426
- prevLocaleRef.current = nextLocale;
427
- skipResetRef.current = false;
428
- setContentLocale(nextLocale);
429
- };
430
- $[58] = form;
431
- $[59] = localeChangeDialog.open;
432
- $[60] = setContentLocale;
433
- $[61] = t30;
434
- } else t30 = $[61];
435
- const handleContentLocaleChange = t30;
436
- let t31;
437
- if ($[62] !== localeChangeDialog.pendingLocale || $[63] !== setContentLocale) {
438
- t31 = () => {
439
- skipResetRef.current = false;
440
- localeSnapshotRef.current = null;
441
- if (localeChangeDialog.pendingLocale) {
442
- prevLocaleRef.current = localeChangeDialog.pendingLocale;
443
- setContentLocale(localeChangeDialog.pendingLocale);
444
- }
445
- setLocaleChangeDialog({
446
- open: false,
447
- pendingLocale: null
448
- });
449
- };
450
- $[62] = localeChangeDialog.pendingLocale;
451
- $[63] = setContentLocale;
452
- $[64] = t31;
453
- } else t31 = $[64];
454
- const handleLocaleChangeConfirm = t31;
455
- let t32;
456
- let t33;
457
- if ($[65] !== contentLocale || $[66] !== localeChangeDialog.open) {
458
- t32 = () => {
459
- if (!localeChangeDialog.open) prevLocaleRef.current = contentLocale;
460
- };
461
- t33 = [contentLocale, localeChangeDialog.open];
462
- $[65] = contentLocale;
463
- $[66] = localeChangeDialog.open;
464
- $[67] = t32;
465
- $[68] = t33;
466
- } else {
467
- t32 = $[67];
468
- t33 = $[68];
469
- }
470
- React.useEffect(t32, t33);
471
- let t34;
472
- if ($[69] !== form) {
473
- t34 = () => {
474
- skipResetRef.current = false;
475
- if (localeSnapshotRef.current) form.reset(localeSnapshotRef.current, {
476
- keepDirty: true,
477
- keepDirtyValues: true,
478
- keepErrors: true,
479
- keepTouched: true
480
- });
481
- localeSnapshotRef.current = null;
482
- setLocaleChangeDialog({
483
- open: false,
484
- pendingLocale: null
485
- });
486
- };
487
- $[69] = form;
488
- $[70] = t34;
489
- } else t34 = $[70];
490
- const handleLocaleChangeCancel = t34;
491
- let t35;
492
- let t36;
493
- if ($[71] !== form || $[72] !== globalData) {
494
- t35 = () => {
495
- if (skipResetRef.current) return;
496
- if (globalData) form.reset(globalData);
497
- };
498
- t36 = [form, globalData];
499
- $[71] = form;
500
- $[72] = globalData;
501
- $[73] = t35;
502
- $[74] = t36;
503
- } else {
504
- t35 = $[73];
505
- t36 = $[74];
506
- }
507
- React.useEffect(t35, t36);
508
- let t37;
509
- if ($[75] !== globalSchema) {
510
- t37 = extractReactiveConfigs(globalSchema);
511
- $[75] = globalSchema;
512
- $[76] = t37;
513
- } else t37 = $[76];
514
- const reactiveConfigs = t37;
515
- let t38;
516
- if ($[77] !== dataLoading || $[78] !== reactiveConfigs) {
517
- t38 = !dataLoading && Object.keys(reactiveConfigs).length > 0;
518
- $[77] = dataLoading;
519
- $[78] = reactiveConfigs;
520
- $[79] = t38;
521
- } else t38 = $[79];
522
- let t39;
523
- if ($[80] !== form || $[81] !== globalName || $[82] !== reactiveConfigs || $[83] !== t38) {
524
- t39 = {
525
- collection: globalName,
526
- mode: "global",
527
- reactiveConfigs,
528
- enabled: t38,
529
- debounce: 300,
530
- form
531
- };
532
- $[80] = form;
533
- $[81] = globalName;
534
- $[82] = reactiveConfigs;
535
- $[83] = t38;
536
- $[84] = t39;
537
- } else t39 = $[84];
538
- useReactiveFields(t39);
539
- let t40;
540
- bb2: {
541
- if (!viewConfig) {
542
- t40 = config;
543
- break bb2;
298
+ const message = error instanceof Error ? error.message : t("error.unknown");
299
+ toast.error(t("toast.settingsSaveFailed") || "Failed to save settings", { description: message });
544
300
  }
545
- let t41$1;
546
- if ($[85] !== config) {
547
- t41$1 = config ?? {};
548
- $[85] = config;
549
- $[86] = t41$1;
550
- } else t41$1 = $[86];
551
- let t42$1;
552
- if ($[87] !== t41$1 || $[88] !== viewConfig) {
553
- t42$1 = {
554
- ...t41$1,
555
- form: viewConfig
556
- };
557
- $[87] = t41$1;
558
- $[88] = viewConfig;
559
- $[89] = t42$1;
560
- } else t42$1 = $[89];
561
- t40 = t42$1;
562
- }
563
- const resolvedConfig = t40;
564
- let t41;
565
- if ($[90] !== form || $[91] !== t || $[92] !== updateMutation) {
566
- t41 = async (data_0) => {
567
- try {
568
- const result_1 = await updateMutation.mutateAsync({ data: data_0 });
569
- if (result_1) form.reset(result_1);
570
- } catch (t42$1) {
571
- const error_0 = t42$1;
572
- if (error_0 instanceof QuestpieClientError && error_0.fieldErrors && error_0.fieldErrors.length > 0) {
573
- for (const fieldError of error_0.fieldErrors) form.setError(fieldError.path, {
574
- type: "server",
575
- message: fieldError.message
576
- });
577
- toast.error(t("toast.validationFailed"), { description: t("toast.validationDescription") });
578
- return;
579
- }
580
- const message = error_0 instanceof Error ? error_0.message : t("error.unknown");
581
- toast.error(t("toast.settingsSaveFailed") || "Failed to save settings", { description: message });
301
+ }, [
302
+ updateMutation,
303
+ form,
304
+ t
305
+ ]);
306
+ React.useEffect(() => {
307
+ const handleKeyDown = (e) => {
308
+ if (shouldHandleAdminShortcut(e, {
309
+ allowEditableTarget: true,
310
+ key: "s"
311
+ })) {
312
+ e.preventDefault();
313
+ form.handleSubmit(onSubmit)();
582
314
  }
583
315
  };
584
- $[90] = form;
585
- $[91] = t;
586
- $[92] = updateMutation;
587
- $[93] = t41;
588
- } else t41 = $[93];
589
- const onSubmit = t41;
590
- let t42;
591
- let t43;
592
- if ($[94] !== form || $[95] !== onSubmit) {
593
- t42 = () => {
594
- const handleKeyDown = (e) => {
595
- if (shouldHandleAdminShortcut(e, {
596
- allowEditableTarget: true,
597
- key: "s"
598
- })) {
599
- e.preventDefault();
600
- form.handleSubmit(onSubmit)();
601
- }
602
- };
603
- document.addEventListener("keydown", handleKeyDown);
604
- return () => document.removeEventListener("keydown", handleKeyDown);
605
- };
606
- t43 = [form, onSubmit];
607
- $[94] = form;
608
- $[95] = onSubmit;
609
- $[96] = t42;
610
- $[97] = t43;
611
- } else {
612
- t42 = $[96];
613
- t43 = $[97];
614
- }
615
- React.useEffect(t42, t43);
316
+ document.addEventListener("keydown", handleKeyDown);
317
+ return () => document.removeEventListener("keydown", handleKeyDown);
318
+ }, [form, onSubmit]);
616
319
  const isSubmitting = updateMutation.isPending || form.formState.isSubmitting;
617
- let t44;
618
- if ($[98] !== form || $[99] !== globalData || $[100] !== pendingRevertVersion || $[101] !== revertVersionMutation || $[102] !== t) {
619
- t44 = async () => {
620
- if (!pendingRevertVersion) return;
621
- const payload = {};
622
- if (typeof globalData?.id === "string") payload.id = globalData.id;
623
- if (typeof pendingRevertVersion.versionId === "string") payload.versionId = pendingRevertVersion.versionId;
624
- else if (typeof pendingRevertVersion.versionNumber === "number") payload.version = pendingRevertVersion.versionNumber;
625
- const result_2 = await revertVersionMutation.mutateAsync(payload);
626
- form.reset(result_2);
627
- toast.success(t("version.revertSuccess"));
628
- setPendingRevertVersion(null);
629
- };
630
- $[98] = form;
631
- $[99] = globalData;
632
- $[100] = pendingRevertVersion;
633
- $[101] = revertVersionMutation;
634
- $[102] = t;
635
- $[103] = t44;
636
- } else t44 = $[103];
637
- const confirmRevertVersion = t44;
638
- const formatDate = _temp2;
639
- if (dataError) {
640
- let t45$1;
641
- if ($[104] !== t) {
642
- t45$1 = t("error.failedToLoad");
643
- $[104] = t;
644
- $[105] = t45$1;
645
- } else t45$1 = $[105];
646
- const t46$1 = dataError instanceof Error ? dataError.message : void 0;
647
- let t47$1;
648
- if ($[106] === Symbol.for("react.memo_cache_sentinel")) {
649
- t47$1 = /* @__PURE__ */ jsx(Icon, {
650
- icon: "ph:arrow-clockwise",
651
- className: "size-3.5"
652
- });
653
- $[106] = t47$1;
654
- } else t47$1 = $[106];
655
- let t48$1;
656
- if ($[107] !== t) {
657
- t48$1 = t("common.retry");
658
- $[107] = t;
659
- $[108] = t48$1;
660
- } else t48$1 = $[108];
661
- let t49$1;
662
- if ($[109] !== t48$1) {
663
- t49$1 = /* @__PURE__ */ jsxs(Button, {
664
- variant: "outline",
665
- size: "sm",
666
- className: "gap-2",
667
- onClick: _temp3,
668
- children: [t47$1, t48$1]
669
- });
670
- $[109] = t48$1;
671
- $[110] = t49$1;
672
- } else t49$1 = $[110];
673
- let t50$1;
674
- if ($[111] !== t45$1 || $[112] !== t46$1 || $[113] !== t49$1) {
675
- t50$1 = /* @__PURE__ */ jsx(EmptyState, {
676
- variant: "error",
677
- iconName: "ph:warning-circle",
678
- title: t45$1,
679
- description: t46$1,
680
- height: "h-64",
681
- action: t49$1
682
- });
683
- $[111] = t45$1;
684
- $[112] = t46$1;
685
- $[113] = t49$1;
686
- $[114] = t50$1;
687
- } else t50$1 = $[114];
688
- return t50$1;
689
- }
690
- if (dataLoading) {
691
- let t45$1;
692
- if ($[115] === Symbol.for("react.memo_cache_sentinel")) {
693
- t45$1 = /* @__PURE__ */ jsx(GlobalFormViewSkeleton, {});
694
- $[115] = t45$1;
695
- } else t45$1 = $[115];
696
- return t45$1;
697
- }
698
- const t45 = resolvedConfig?.label ?? schemaFields?._globalLabel;
699
- let t46;
700
- if ($[116] !== globalName || $[117] !== resolveText || $[118] !== t45) {
701
- t46 = resolveText(t45, globalName);
702
- $[116] = globalName;
703
- $[117] = resolveText;
704
- $[118] = t45;
705
- $[119] = t46;
706
- } else t46 = $[119];
707
- const globalLabel = t46;
708
- let t47;
709
- if ($[120] !== form || $[121] !== onSubmit) {
710
- t47 = form.handleSubmit(onSubmit);
711
- $[120] = form;
712
- $[121] = onSubmit;
713
- $[122] = t47;
714
- } else t47 = $[122];
715
- let t48;
716
- if ($[123] !== contentLocale || $[124] !== handleContentLocaleChange || $[125] !== localeOptions) {
717
- t48 = localeOptions.length > 0 && /* @__PURE__ */ jsx(LocaleSwitcher, {
718
- locales: localeOptions,
719
- value: contentLocale,
720
- onChange: handleContentLocaleChange
721
- });
722
- $[123] = contentLocale;
723
- $[124] = handleContentLocaleChange;
724
- $[125] = localeOptions;
725
- $[126] = t48;
726
- } else t48 = $[126];
727
- let t49;
728
- if ($[127] !== currentStage || $[128] !== currentStageLabel || $[129] !== workflowEnabled) {
729
- t49 = workflowEnabled && currentStage && /* @__PURE__ */ jsxs(Badge, {
730
- variant: "outline",
731
- className: "gap-1.5",
732
- children: [/* @__PURE__ */ jsx(Icon, {
733
- icon: "ph:git-branch",
734
- className: "size-3"
735
- }), currentStageLabel]
736
- });
737
- $[127] = currentStage;
738
- $[128] = currentStageLabel;
739
- $[129] = workflowEnabled;
740
- $[130] = t49;
741
- } else t49 = $[130];
742
- let t50;
743
- if ($[131] !== t48 || $[132] !== t49) {
744
- t50 = /* @__PURE__ */ jsxs(Fragment, { children: [t48, t49] });
745
- $[131] = t48;
746
- $[132] = t49;
747
- $[133] = t50;
748
- } else t50 = $[133];
749
- let t51;
750
- if ($[134] !== globalData || $[135] !== showMeta || $[136] !== t) {
751
- t51 = showMeta && globalData?.updatedAt ? /* @__PURE__ */ jsxs("span", { children: [
752
- t("form.lastUpdated"),
753
- ": ",
754
- formatDate(globalData.updatedAt)
755
- ] }) : void 0;
756
- $[134] = globalData;
757
- $[135] = showMeta;
758
- $[136] = t;
759
- $[137] = t51;
760
- } else t51 = $[137];
761
- let t52;
762
- if ($[138] !== allowedTransitions || $[139] !== t || $[140] !== workflowEnabled) {
763
- t52 = workflowEnabled && allowedTransitions.length > 0 && /* @__PURE__ */ jsxs(DropdownMenu, { children: [/* @__PURE__ */ jsxs(DropdownMenuTrigger, {
764
- render: /* @__PURE__ */ jsx(Button, {
765
- type: "button",
766
- variant: "outline",
767
- size: "sm",
768
- className: "gap-2"
769
- }),
770
- children: [/* @__PURE__ */ jsx(Icon, {
771
- icon: "ph:arrows-left-right",
772
- className: "size-3.5"
773
- }), t("workflow.transition")]
774
- }), /* @__PURE__ */ jsx(DropdownMenuContent, {
775
- align: "end",
776
- children: allowedTransitions.map((stage) => /* @__PURE__ */ jsxs(DropdownMenuItem, {
777
- onClick: () => setTransitionTarget({
778
- name: stage.name,
779
- label: stage.label
780
- }),
781
- children: [/* @__PURE__ */ jsx(Icon, {
782
- icon: "ph:arrow-right",
783
- className: "mr-2 size-4"
784
- }), stage.label || stage.name]
785
- }, stage.name))
786
- })] });
787
- $[138] = allowedTransitions;
788
- $[139] = t;
789
- $[140] = workflowEnabled;
790
- $[141] = t52;
791
- } else t52 = $[141];
792
- let t53;
793
- if ($[142] !== setIsHistoryOpen) {
794
- t53 = () => setIsHistoryOpen(true);
795
- $[142] = setIsHistoryOpen;
796
- $[143] = t53;
797
- } else t53 = $[143];
798
- let t54;
799
- if ($[144] !== t) {
800
- t54 = t("history.title");
801
- $[144] = t;
802
- $[145] = t54;
803
- } else t54 = $[145];
804
- let t55;
805
- if ($[146] === Symbol.for("react.memo_cache_sentinel")) {
806
- t55 = /* @__PURE__ */ jsx(Icon, {
807
- icon: "ph:clock-counter-clockwise",
808
- className: "size-3.5"
809
- });
810
- $[146] = t55;
811
- } else t55 = $[146];
812
- let t56;
813
- if ($[147] !== t) {
814
- t56 = t("history.title");
815
- $[147] = t;
816
- $[148] = t56;
817
- } else t56 = $[148];
818
- let t57;
819
- if ($[149] !== t56) {
820
- t57 = /* @__PURE__ */ jsx("span", {
821
- className: "sr-only",
822
- children: t56
823
- });
824
- $[149] = t56;
825
- $[150] = t57;
826
- } else t57 = $[150];
827
- let t58;
828
- if ($[151] !== t53 || $[152] !== t54 || $[153] !== t57) {
829
- t58 = /* @__PURE__ */ jsxs(Button, {
830
- type: "button",
320
+ const confirmRevertVersion = React.useCallback(async () => {
321
+ if (!pendingRevertVersion) return;
322
+ const payload = {};
323
+ if (typeof globalData?.id === "string") payload.id = globalData.id;
324
+ if (typeof pendingRevertVersion.versionId === "string") payload.versionId = pendingRevertVersion.versionId;
325
+ else if (typeof pendingRevertVersion.versionNumber === "number") payload.version = pendingRevertVersion.versionNumber;
326
+ const result = await revertVersionMutation.mutateAsync(payload);
327
+ form.reset(result);
328
+ toast.success(t("version.revertSuccess"));
329
+ setPendingRevertVersion(null);
330
+ }, [
331
+ pendingRevertVersion,
332
+ globalData,
333
+ revertVersionMutation,
334
+ form,
335
+ t
336
+ ]);
337
+ const formatDate = (date) => {
338
+ return new Date(date).toLocaleDateString(void 0, {
339
+ year: "numeric",
340
+ month: "short",
341
+ day: "numeric",
342
+ hour: "2-digit",
343
+ minute: "2-digit"
344
+ });
345
+ };
346
+ if (dataError) return /* @__PURE__ */ jsx(EmptyState, {
347
+ variant: "error",
348
+ iconName: "ph:warning-circle",
349
+ title: t("error.failedToLoad"),
350
+ description: dataError instanceof Error ? dataError.message : void 0,
351
+ height: "h-64",
352
+ action: /* @__PURE__ */ jsxs(Button, {
831
353
  variant: "outline",
832
- size: "icon-sm",
833
- onClick: t53,
834
- title: t54,
835
- children: [t55, t57]
836
- });
837
- $[151] = t53;
838
- $[152] = t54;
839
- $[153] = t57;
840
- $[154] = t58;
841
- } else t58 = $[154];
842
- let t59;
843
- if ($[155] !== isSubmitting || $[156] !== t) {
844
- t59 = isSubmitting ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Icon, {
845
- icon: "ph:spinner-gap",
846
- className: "size-4 animate-spin"
847
- }), t("common.loading")] }) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Icon, {
848
- icon: "ph:check",
849
- width: 16,
850
- height: 16
851
- }), t("common.save")] });
852
- $[155] = isSubmitting;
853
- $[156] = t;
854
- $[157] = t59;
855
- } else t59 = $[157];
856
- let t60;
857
- if ($[158] !== isSubmitting || $[159] !== t59) {
858
- t60 = /* @__PURE__ */ jsx(Button, {
859
- type: "submit",
860
354
  size: "sm",
861
- disabled: isSubmitting,
862
- className: "gap-2",
863
- children: t59
864
- });
865
- $[158] = isSubmitting;
866
- $[159] = t59;
867
- $[160] = t60;
868
- } else t60 = $[160];
869
- let t61;
870
- if ($[161] !== headerActions || $[162] !== t52 || $[163] !== t58 || $[164] !== t60) {
871
- t61 = /* @__PURE__ */ jsxs(Fragment, { children: [
872
- headerActions,
873
- t52,
874
- t58,
875
- t60
876
- ] });
877
- $[161] = headerActions;
878
- $[162] = t52;
879
- $[163] = t58;
880
- $[164] = t60;
881
- $[165] = t61;
882
- } else t61 = $[165];
883
- let t62;
884
- if ($[166] !== globalLabel || $[167] !== t50 || $[168] !== t51 || $[169] !== t61) {
885
- t62 = /* @__PURE__ */ jsx(AdminViewHeader, {
886
- className: "qa-global-form__header",
887
- title: globalLabel,
888
- titleAccessory: t50,
889
- meta: t51,
890
- actions: t61
891
- });
892
- $[166] = globalLabel;
893
- $[167] = t50;
894
- $[168] = t51;
895
- $[169] = t61;
896
- $[170] = t62;
897
- } else t62 = $[170];
898
- let t63;
899
- if ($[171] !== globalName || $[172] !== registry || $[173] !== resolvedConfig) {
900
- t63 = /* @__PURE__ */ jsx(AutoFormFields, {
901
- collection: globalName,
902
- mode: "global",
903
- config: resolvedConfig,
904
- registry
905
- });
906
- $[171] = globalName;
907
- $[172] = registry;
908
- $[173] = resolvedConfig;
909
- $[174] = t63;
910
- } else t63 = $[174];
911
- let t64;
912
- if ($[175] !== t47 || $[176] !== t62 || $[177] !== t63) {
913
- t64 = /* @__PURE__ */ jsxs("form", {
914
- onSubmit: t47,
915
- className: "qa-global-form w-full space-y-4",
916
- children: [t62, t63]
917
- });
918
- $[175] = t47;
919
- $[176] = t62;
920
- $[177] = t63;
921
- $[178] = t64;
922
- } else t64 = $[178];
923
- let t65;
924
- if ($[179] !== auditData) {
925
- t65 = auditData ?? [];
926
- $[179] = auditData;
927
- $[180] = t65;
928
- } else t65 = $[180];
929
- let t66;
930
- if ($[181] !== versionsData) {
931
- t66 = versionsData ?? [];
932
- $[181] = versionsData;
933
- $[182] = t66;
934
- } else t66 = $[182];
935
- const t67 = t66;
936
- const t68 = globalSchema?.fields;
937
- let t69;
938
- if ($[183] === Symbol.for("react.memo_cache_sentinel")) {
939
- t69 = async (version) => {
940
- setPendingRevertVersion(version);
941
- };
942
- $[183] = t69;
943
- } else t69 = $[183];
944
- const t70 = !!globalSchema?.options?.versioning;
945
- let t71;
946
- if ($[184] !== auditLoading || $[185] !== isHistoryOpen || $[186] !== revertVersionMutation.isPending || $[187] !== setIsHistoryOpen || $[188] !== t65 || $[189] !== t67 || $[190] !== t68 || $[191] !== t70 || $[192] !== versionsLoading) {
947
- t71 = /* @__PURE__ */ jsx(HistorySidebar, {
948
- open: isHistoryOpen,
949
- onOpenChange: setIsHistoryOpen,
950
- auditEntries: t65,
951
- isLoadingAudit: auditLoading,
952
- versions: t67,
953
- fields: t68,
954
- isLoadingVersions: versionsLoading,
955
- isReverting: revertVersionMutation.isPending,
956
- onRevert: t69,
957
- showVersionsTab: t70
958
- });
959
- $[184] = auditLoading;
960
- $[185] = isHistoryOpen;
961
- $[186] = revertVersionMutation.isPending;
962
- $[187] = setIsHistoryOpen;
963
- $[188] = t65;
964
- $[189] = t67;
965
- $[190] = t68;
966
- $[191] = t70;
967
- $[192] = versionsLoading;
968
- $[193] = t71;
969
- } else t71 = $[193];
970
- const t72 = !!pendingRevertVersion;
971
- let t73;
972
- if ($[194] === Symbol.for("react.memo_cache_sentinel")) {
973
- t73 = (open) => {
974
- if (!open) setPendingRevertVersion(null);
975
- };
976
- $[194] = t73;
977
- } else t73 = $[194];
978
- let t74;
979
- if ($[195] !== t) {
980
- t74 = t("version.revertConfirmTitle");
981
- $[195] = t;
982
- $[196] = t74;
983
- } else t74 = $[196];
984
- const t75 = pendingRevertVersion?.versionNumber ?? pendingRevertVersion?.versionId ?? "-";
985
- let t76;
986
- if ($[197] !== t || $[198] !== t75) {
987
- t76 = t("version.revertConfirmDescription", { number: t75 });
988
- $[197] = t;
989
- $[198] = t75;
990
- $[199] = t76;
991
- } else t76 = $[199];
992
- let t77;
993
- if ($[200] !== t) {
994
- t77 = t("version.revert");
995
- $[200] = t;
996
- $[201] = t77;
997
- } else t77 = $[201];
998
- let t78;
999
- if ($[202] !== t) {
1000
- t78 = t("common.cancel");
1001
- $[202] = t;
1002
- $[203] = t78;
1003
- } else t78 = $[203];
1004
- let t79;
1005
- if ($[204] !== t74 || $[205] !== t76 || $[206] !== t77 || $[207] !== t78) {
1006
- t79 = {
1007
- title: t74,
1008
- description: t76,
1009
- confirmLabel: t77,
1010
- cancelLabel: t78,
1011
- destructive: false
1012
- };
1013
- $[204] = t74;
1014
- $[205] = t76;
1015
- $[206] = t77;
1016
- $[207] = t78;
1017
- $[208] = t79;
1018
- } else t79 = $[208];
1019
- let t80;
1020
- if ($[209] !== confirmRevertVersion || $[210] !== revertVersionMutation.isPending || $[211] !== t72 || $[212] !== t79) {
1021
- t80 = /* @__PURE__ */ jsx(ConfirmationDialog, {
1022
- open: t72,
1023
- onOpenChange: t73,
1024
- config: t79,
1025
- onConfirm: confirmRevertVersion,
1026
- loading: revertVersionMutation.isPending
1027
- });
1028
- $[209] = confirmRevertVersion;
1029
- $[210] = revertVersionMutation.isPending;
1030
- $[211] = t72;
1031
- $[212] = t79;
1032
- $[213] = t80;
1033
- } else t80 = $[213];
1034
- const t81 = !!transitionTarget;
1035
- let t82;
1036
- if ($[214] === Symbol.for("react.memo_cache_sentinel")) {
1037
- t82 = (open_0) => {
1038
- if (!open_0) {
1039
- setTransitionTarget(null);
1040
- setTransitionSchedule(false);
1041
- setTransitionScheduledAt(null);
1042
- }
1043
- };
1044
- $[214] = t82;
1045
- } else t82 = $[214];
1046
- let t83;
1047
- if ($[215] === Symbol.for("react.memo_cache_sentinel")) {
1048
- t83 = /* @__PURE__ */ jsx(Icon, {
1049
- icon: "ph:arrows-left-right",
1050
- className: "size-5"
1051
- });
1052
- $[215] = t83;
1053
- } else t83 = $[215];
1054
- const t84 = transitionTarget?.label ?? transitionTarget?.name ?? "";
1055
- let t85;
1056
- if ($[216] !== t || $[217] !== t84) {
1057
- t85 = t("workflow.transitionTo", { stage: t84 });
1058
- $[216] = t;
1059
- $[217] = t84;
1060
- $[218] = t85;
1061
- } else t85 = $[218];
1062
- let t86;
1063
- if ($[219] !== t85) {
1064
- t86 = /* @__PURE__ */ jsxs(DialogTitle, {
1065
- className: "flex items-center gap-2",
1066
- children: [t83, t85]
1067
- });
1068
- $[219] = t85;
1069
- $[220] = t86;
1070
- } else t86 = $[220];
1071
- const t87 = transitionTarget?.label ?? transitionTarget?.name ?? "";
1072
- let t88;
1073
- if ($[221] !== currentStageLabel || $[222] !== t || $[223] !== t87) {
1074
- t88 = t("workflow.transitionDescription", {
1075
- from: currentStageLabel,
1076
- to: t87
1077
- });
1078
- $[221] = currentStageLabel;
1079
- $[222] = t;
1080
- $[223] = t87;
1081
- $[224] = t88;
1082
- } else t88 = $[224];
1083
- let t89;
1084
- if ($[225] !== t88) {
1085
- t89 = /* @__PURE__ */ jsx(DialogDescription, { children: t88 });
1086
- $[225] = t88;
1087
- $[226] = t89;
1088
- } else t89 = $[226];
1089
- let t90;
1090
- if ($[227] !== t86 || $[228] !== t89) {
1091
- t90 = /* @__PURE__ */ jsxs(DialogHeader, { children: [t86, t89] });
1092
- $[227] = t86;
1093
- $[228] = t89;
1094
- $[229] = t90;
1095
- } else t90 = $[229];
1096
- let t91;
1097
- if ($[230] === Symbol.for("react.memo_cache_sentinel")) {
1098
- t91 = (val) => {
1099
- setTransitionSchedule(!!val);
1100
- if (!val) setTransitionScheduledAt(null);
1101
- };
1102
- $[230] = t91;
1103
- } else t91 = $[230];
1104
- let t92;
1105
- if ($[231] !== transitionSchedule) {
1106
- t92 = /* @__PURE__ */ jsx(Checkbox, {
1107
- checked: transitionSchedule,
1108
- onCheckedChange: t91,
1109
- id: "global-transition-schedule"
1110
- });
1111
- $[231] = transitionSchedule;
1112
- $[232] = t92;
1113
- } else t92 = $[232];
1114
- let t93;
1115
- if ($[233] !== t) {
1116
- t93 = t("workflow.scheduleLabel");
1117
- $[233] = t;
1118
- $[234] = t93;
1119
- } else t93 = $[234];
1120
- let t94;
1121
- if ($[235] !== t93) {
1122
- t94 = /* @__PURE__ */ jsx(Label, {
1123
- htmlFor: "global-transition-schedule",
1124
- className: "cursor-pointer text-sm",
1125
- children: t93
1126
- });
1127
- $[235] = t93;
1128
- $[236] = t94;
1129
- } else t94 = $[236];
1130
- let t95;
1131
- if ($[237] !== t92 || $[238] !== t94) {
1132
- t95 = /* @__PURE__ */ jsxs("div", {
1133
- className: "flex items-center gap-2",
1134
- children: [t92, t94]
1135
- });
1136
- $[237] = t92;
1137
- $[238] = t94;
1138
- $[239] = t95;
1139
- } else t95 = $[239];
1140
- let t96;
1141
- if ($[240] !== t || $[241] !== transitionSchedule || $[242] !== transitionScheduledAt) {
1142
- t96 = transitionSchedule && /* @__PURE__ */ jsxs("div", {
1143
- className: "space-y-1.5 pl-6",
1144
- children: [
1145
- /* @__PURE__ */ jsx(Label, {
1146
- className: "text-muted-foreground text-xs",
1147
- children: t("workflow.scheduledAt")
1148
- }),
1149
- /* @__PURE__ */ jsx(DateTimeInput, {
1150
- value: transitionScheduledAt,
1151
- onChange: setTransitionScheduledAt,
1152
- minDate: /* @__PURE__ */ new Date()
1153
- }),
1154
- /* @__PURE__ */ jsx("p", {
1155
- className: "text-muted-foreground text-xs",
1156
- children: t("workflow.scheduledDescription")
1157
- })
1158
- ]
1159
- });
1160
- $[240] = t;
1161
- $[241] = transitionSchedule;
1162
- $[242] = transitionScheduledAt;
1163
- $[243] = t96;
1164
- } else t96 = $[243];
1165
- let t97;
1166
- if ($[244] !== t95 || $[245] !== t96) {
1167
- t97 = /* @__PURE__ */ jsxs("div", {
1168
- className: "space-y-3 py-2",
1169
- children: [t95, t96]
1170
- });
1171
- $[244] = t95;
1172
- $[245] = t96;
1173
- $[246] = t97;
1174
- } else t97 = $[246];
1175
- let t98;
1176
- if ($[247] === Symbol.for("react.memo_cache_sentinel")) {
1177
- t98 = () => {
1178
- setTransitionTarget(null);
1179
- setTransitionSchedule(false);
1180
- setTransitionScheduledAt(null);
1181
- };
1182
- $[247] = t98;
1183
- } else t98 = $[247];
1184
- let t99;
1185
- if ($[248] !== t) {
1186
- t99 = t("common.cancel");
1187
- $[248] = t;
1188
- $[249] = t99;
1189
- } else t99 = $[249];
1190
- let t100;
1191
- if ($[250] !== t99) {
1192
- t100 = /* @__PURE__ */ jsx(Button, {
1193
- type: "button",
1194
- variant: "outline",
1195
- onClick: t98,
1196
- children: t99
1197
- });
1198
- $[250] = t99;
1199
- $[251] = t100;
1200
- } else t100 = $[251];
1201
- const t101 = transitionMutation.isPending || transitionSchedule && !transitionScheduledAt;
1202
- let t102;
1203
- if ($[252] !== transitionMutation.isPending) {
1204
- t102 = transitionMutation.isPending && /* @__PURE__ */ jsx(Icon, {
1205
- icon: "ph:spinner-gap",
1206
- className: "size-4 animate-spin"
1207
- });
1208
- $[252] = transitionMutation.isPending;
1209
- $[253] = t102;
1210
- } else t102 = $[253];
1211
- let t103;
1212
- if ($[254] !== t || $[255] !== transitionSchedule) {
1213
- t103 = transitionSchedule ? t("workflow.scheduleLabel") : t("workflow.transition");
1214
- $[254] = t;
1215
- $[255] = transitionSchedule;
1216
- $[256] = t103;
1217
- } else t103 = $[256];
1218
- let t104;
1219
- if ($[257] !== confirmTransition || $[258] !== t101 || $[259] !== t102 || $[260] !== t103) {
1220
- t104 = /* @__PURE__ */ jsxs(Button, {
1221
- type: "button",
1222
- onClick: confirmTransition,
1223
- disabled: t101,
1224
355
  className: "gap-2",
1225
- children: [t102, t103]
1226
- });
1227
- $[257] = confirmTransition;
1228
- $[258] = t101;
1229
- $[259] = t102;
1230
- $[260] = t103;
1231
- $[261] = t104;
1232
- } else t104 = $[261];
1233
- let t105;
1234
- if ($[262] !== t100 || $[263] !== t104) {
1235
- t105 = /* @__PURE__ */ jsxs(DialogFooter, { children: [t100, t104] });
1236
- $[262] = t100;
1237
- $[263] = t104;
1238
- $[264] = t105;
1239
- } else t105 = $[264];
1240
- let t106;
1241
- if ($[265] !== t105 || $[266] !== t90 || $[267] !== t97) {
1242
- t106 = /* @__PURE__ */ jsxs(DialogContent, { children: [
1243
- t90,
1244
- t97,
1245
- t105
1246
- ] });
1247
- $[265] = t105;
1248
- $[266] = t90;
1249
- $[267] = t97;
1250
- $[268] = t106;
1251
- } else t106 = $[268];
1252
- let t107;
1253
- if ($[269] !== t106 || $[270] !== t81) {
1254
- t107 = /* @__PURE__ */ jsx(Dialog, {
1255
- open: t81,
1256
- onOpenChange: t82,
1257
- children: t106
1258
- });
1259
- $[269] = t106;
1260
- $[270] = t81;
1261
- $[271] = t107;
1262
- } else t107 = $[271];
1263
- const t108 = localeChangeDialog.open;
1264
- let t109;
1265
- if ($[272] !== handleLocaleChangeCancel) {
1266
- t109 = (open_1) => !open_1 && handleLocaleChangeCancel();
1267
- $[272] = handleLocaleChangeCancel;
1268
- $[273] = t109;
1269
- } else t109 = $[273];
1270
- let t110;
1271
- if ($[274] !== t) {
1272
- t110 = t("locale.unsavedChanges");
1273
- $[274] = t;
1274
- $[275] = t110;
1275
- } else t110 = $[275];
1276
- let t111;
1277
- if ($[276] !== t110) {
1278
- t111 = /* @__PURE__ */ jsx(DialogTitle, { children: t110 });
1279
- $[276] = t110;
1280
- $[277] = t111;
1281
- } else t111 = $[277];
1282
- let t112;
1283
- if ($[278] !== t) {
1284
- t112 = t("locale.unsavedChangesDescription");
1285
- $[278] = t;
1286
- $[279] = t112;
1287
- } else t112 = $[279];
1288
- let t113;
1289
- if ($[280] !== t112) {
1290
- t113 = /* @__PURE__ */ jsx(DialogDescription, { children: t112 });
1291
- $[280] = t112;
1292
- $[281] = t113;
1293
- } else t113 = $[281];
1294
- let t114;
1295
- if ($[282] !== t111 || $[283] !== t113) {
1296
- t114 = /* @__PURE__ */ jsxs(DialogHeader, { children: [t111, t113] });
1297
- $[282] = t111;
1298
- $[283] = t113;
1299
- $[284] = t114;
1300
- } else t114 = $[284];
1301
- let t115;
1302
- if ($[285] !== t) {
1303
- t115 = t("common.cancel");
1304
- $[285] = t;
1305
- $[286] = t115;
1306
- } else t115 = $[286];
1307
- let t116;
1308
- if ($[287] !== handleLocaleChangeCancel || $[288] !== t115) {
1309
- t116 = /* @__PURE__ */ jsx(Button, {
1310
- variant: "outline",
1311
- onClick: handleLocaleChangeCancel,
1312
- children: t115
1313
- });
1314
- $[287] = handleLocaleChangeCancel;
1315
- $[288] = t115;
1316
- $[289] = t116;
1317
- } else t116 = $[289];
1318
- let t117;
1319
- if ($[290] !== t) {
1320
- t117 = t("locale.discardChanges");
1321
- $[290] = t;
1322
- $[291] = t117;
1323
- } else t117 = $[291];
1324
- let t118;
1325
- if ($[292] !== handleLocaleChangeConfirm || $[293] !== t117) {
1326
- t118 = /* @__PURE__ */ jsx(Button, {
1327
- variant: "default",
1328
- onClick: handleLocaleChangeConfirm,
1329
- children: t117
1330
- });
1331
- $[292] = handleLocaleChangeConfirm;
1332
- $[293] = t117;
1333
- $[294] = t118;
1334
- } else t118 = $[294];
1335
- let t119;
1336
- if ($[295] !== t116 || $[296] !== t118) {
1337
- t119 = /* @__PURE__ */ jsxs(DialogFooter, { children: [t116, t118] });
1338
- $[295] = t116;
1339
- $[296] = t118;
1340
- $[297] = t119;
1341
- } else t119 = $[297];
1342
- let t120;
1343
- if ($[298] !== t114 || $[299] !== t119) {
1344
- t120 = /* @__PURE__ */ jsxs(DialogContent, { children: [t114, t119] });
1345
- $[298] = t114;
1346
- $[299] = t119;
1347
- $[300] = t120;
1348
- } else t120 = $[300];
1349
- let t121;
1350
- if ($[301] !== localeChangeDialog.open || $[302] !== t109 || $[303] !== t120) {
1351
- t121 = /* @__PURE__ */ jsx(Dialog, {
1352
- open: t108,
1353
- onOpenChange: t109,
1354
- children: t120
1355
- });
1356
- $[301] = localeChangeDialog.open;
1357
- $[302] = t109;
1358
- $[303] = t120;
1359
- $[304] = t121;
1360
- } else t121 = $[304];
1361
- let t122;
1362
- if ($[305] !== form || $[306] !== t107 || $[307] !== t121 || $[308] !== t64 || $[309] !== t71 || $[310] !== t80) {
1363
- t122 = /* @__PURE__ */ jsxs(FormProvider, {
1364
- ...form,
1365
- children: [
1366
- t64,
1367
- t71,
1368
- t80,
1369
- t107,
1370
- t121
1371
- ]
1372
- });
1373
- $[305] = form;
1374
- $[306] = t107;
1375
- $[307] = t121;
1376
- $[308] = t64;
1377
- $[309] = t71;
1378
- $[310] = t80;
1379
- $[311] = t122;
1380
- } else t122 = $[311];
1381
- return t122;
1382
- }
1383
- function _temp3() {
1384
- return window.location.reload();
1385
- }
1386
- function _temp2(date) {
1387
- return new Date(date).toLocaleDateString(void 0, {
1388
- year: "numeric",
1389
- month: "short",
1390
- day: "numeric",
1391
- hour: "2-digit",
1392
- minute: "2-digit"
356
+ onClick: () => window.location.reload(),
357
+ children: [/* @__PURE__ */ jsx(Icon, {
358
+ icon: "ph:arrow-clockwise",
359
+ className: "size-3.5"
360
+ }), t("common.retry")]
361
+ })
362
+ });
363
+ if (dataLoading) return /* @__PURE__ */ jsx(GlobalFormViewSkeleton, {});
364
+ const globalLabel = resolveText(resolvedConfig?.label ?? schemaFields?._globalLabel, globalName);
365
+ return /* @__PURE__ */ jsxs(FormProvider, {
366
+ ...form,
367
+ children: [
368
+ /* @__PURE__ */ jsxs("form", {
369
+ onSubmit: form.handleSubmit(onSubmit),
370
+ className: "qa-global-form w-full space-y-4",
371
+ children: [/* @__PURE__ */ jsx(AdminViewHeader, {
372
+ className: "qa-global-form__header",
373
+ title: globalLabel,
374
+ titleAccessory: /* @__PURE__ */ jsxs(Fragment, { children: [localeOptions.length > 0 && /* @__PURE__ */ jsx(LocaleSwitcher, {
375
+ locales: localeOptions,
376
+ value: contentLocale,
377
+ onChange: handleContentLocaleChange
378
+ }), workflowEnabled && currentStage && /* @__PURE__ */ jsxs(Badge, {
379
+ variant: "outline",
380
+ className: "gap-1.5",
381
+ children: [/* @__PURE__ */ jsx(Icon, {
382
+ icon: "ph:git-branch",
383
+ className: "size-3"
384
+ }), currentStageLabel]
385
+ })] }),
386
+ meta: showMeta && globalData?.updatedAt ? /* @__PURE__ */ jsxs("span", { children: [
387
+ t("form.lastUpdated"),
388
+ ": ",
389
+ formatDate(globalData.updatedAt)
390
+ ] }) : void 0,
391
+ actions: /* @__PURE__ */ jsxs(Fragment, { children: [
392
+ headerActions,
393
+ workflowEnabled && allowedTransitions.length > 0 && /* @__PURE__ */ jsxs(DropdownMenu, { children: [/* @__PURE__ */ jsxs(DropdownMenuTrigger, {
394
+ render: /* @__PURE__ */ jsx(Button, {
395
+ type: "button",
396
+ variant: "outline",
397
+ size: "sm",
398
+ className: "gap-2"
399
+ }),
400
+ children: [/* @__PURE__ */ jsx(Icon, {
401
+ icon: "ph:arrows-left-right",
402
+ className: "size-3.5"
403
+ }), t("workflow.transition")]
404
+ }), /* @__PURE__ */ jsx(DropdownMenuContent, {
405
+ align: "end",
406
+ children: allowedTransitions.map((stage) => /* @__PURE__ */ jsxs(DropdownMenuItem, {
407
+ onClick: () => setTransitionTarget({
408
+ name: stage.name,
409
+ label: stage.label
410
+ }),
411
+ children: [/* @__PURE__ */ jsx(Icon, {
412
+ icon: "ph:arrow-right",
413
+ className: "mr-2 size-4"
414
+ }), stage.label || stage.name]
415
+ }, stage.name))
416
+ })] }),
417
+ /* @__PURE__ */ jsxs(Button, {
418
+ type: "button",
419
+ variant: "outline",
420
+ size: "icon-sm",
421
+ onClick: () => setIsHistoryOpen(true),
422
+ title: t("history.title"),
423
+ children: [/* @__PURE__ */ jsx(Icon, {
424
+ icon: "ph:clock-counter-clockwise",
425
+ className: "size-3.5"
426
+ }), /* @__PURE__ */ jsx("span", {
427
+ className: "sr-only",
428
+ children: t("history.title")
429
+ })]
430
+ }),
431
+ /* @__PURE__ */ jsx(Button, {
432
+ type: "submit",
433
+ size: "sm",
434
+ disabled: isSubmitting,
435
+ className: "gap-2",
436
+ children: isSubmitting ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Icon, {
437
+ icon: "ph:spinner-gap",
438
+ className: "size-4 animate-spin"
439
+ }), t("common.loading")] }) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Icon, {
440
+ icon: "ph:check",
441
+ width: 16,
442
+ height: 16
443
+ }), t("common.save")] })
444
+ })
445
+ ] })
446
+ }), /* @__PURE__ */ jsx(AutoFormFields, {
447
+ collection: globalName,
448
+ mode: "global",
449
+ config: resolvedConfig,
450
+ registry
451
+ })]
452
+ }),
453
+ /* @__PURE__ */ jsx(HistorySidebar, {
454
+ open: isHistoryOpen,
455
+ onOpenChange: setIsHistoryOpen,
456
+ auditEntries: auditData ?? [],
457
+ isLoadingAudit: auditLoading,
458
+ versions: versionsData ?? [],
459
+ fields: globalSchema?.fields,
460
+ isLoadingVersions: versionsLoading,
461
+ isReverting: revertVersionMutation.isPending,
462
+ onRevert: async (version) => {
463
+ setPendingRevertVersion(version);
464
+ },
465
+ showVersionsTab: !!globalSchema?.options?.versioning
466
+ }),
467
+ /* @__PURE__ */ jsx(ConfirmationDialog, {
468
+ open: !!pendingRevertVersion,
469
+ onOpenChange: (open) => {
470
+ if (!open) setPendingRevertVersion(null);
471
+ },
472
+ config: {
473
+ title: t("version.revertConfirmTitle"),
474
+ description: t("version.revertConfirmDescription", { number: pendingRevertVersion?.versionNumber ?? pendingRevertVersion?.versionId ?? "-" }),
475
+ confirmLabel: t("version.revert"),
476
+ cancelLabel: t("common.cancel"),
477
+ destructive: false
478
+ },
479
+ onConfirm: confirmRevertVersion,
480
+ loading: revertVersionMutation.isPending
481
+ }),
482
+ /* @__PURE__ */ jsx(Dialog, {
483
+ open: !!transitionTarget,
484
+ onOpenChange: (open) => {
485
+ if (!open) {
486
+ setTransitionTarget(null);
487
+ setTransitionSchedule(false);
488
+ setTransitionScheduledAt(null);
489
+ }
490
+ },
491
+ children: /* @__PURE__ */ jsxs(DialogContent, { children: [
492
+ /* @__PURE__ */ jsxs(DialogHeader, { children: [/* @__PURE__ */ jsxs(DialogTitle, {
493
+ className: "flex items-center gap-2",
494
+ children: [/* @__PURE__ */ jsx(Icon, {
495
+ icon: "ph:arrows-left-right",
496
+ className: "size-5"
497
+ }), t("workflow.transitionTo", { stage: transitionTarget?.label ?? transitionTarget?.name ?? "" })]
498
+ }), /* @__PURE__ */ jsx(DialogDescription, { children: t("workflow.transitionDescription", {
499
+ from: currentStageLabel,
500
+ to: transitionTarget?.label ?? transitionTarget?.name ?? ""
501
+ }) })] }),
502
+ /* @__PURE__ */ jsxs("div", {
503
+ className: "space-y-3 py-2",
504
+ children: [/* @__PURE__ */ jsxs("div", {
505
+ className: "flex items-center gap-2",
506
+ children: [/* @__PURE__ */ jsx(Checkbox, {
507
+ checked: transitionSchedule,
508
+ onCheckedChange: (val) => {
509
+ setTransitionSchedule(!!val);
510
+ if (!val) setTransitionScheduledAt(null);
511
+ },
512
+ id: "global-transition-schedule"
513
+ }), /* @__PURE__ */ jsx(Label, {
514
+ htmlFor: "global-transition-schedule",
515
+ className: "cursor-pointer text-sm",
516
+ children: t("workflow.scheduleLabel")
517
+ })]
518
+ }), transitionSchedule && /* @__PURE__ */ jsxs("div", {
519
+ className: "space-y-1.5 pl-6",
520
+ children: [
521
+ /* @__PURE__ */ jsx(Label, {
522
+ className: "text-muted-foreground text-xs",
523
+ children: t("workflow.scheduledAt")
524
+ }),
525
+ /* @__PURE__ */ jsx(DateTimeInput, {
526
+ value: transitionScheduledAt,
527
+ onChange: setTransitionScheduledAt,
528
+ minDate: /* @__PURE__ */ new Date()
529
+ }),
530
+ /* @__PURE__ */ jsx("p", {
531
+ className: "text-muted-foreground text-xs",
532
+ children: t("workflow.scheduledDescription")
533
+ })
534
+ ]
535
+ })]
536
+ }),
537
+ /* @__PURE__ */ jsxs(DialogFooter, { children: [/* @__PURE__ */ jsx(Button, {
538
+ type: "button",
539
+ variant: "outline",
540
+ onClick: () => {
541
+ setTransitionTarget(null);
542
+ setTransitionSchedule(false);
543
+ setTransitionScheduledAt(null);
544
+ },
545
+ children: t("common.cancel")
546
+ }), /* @__PURE__ */ jsxs(Button, {
547
+ type: "button",
548
+ onClick: confirmTransition,
549
+ disabled: transitionMutation.isPending || transitionSchedule && !transitionScheduledAt,
550
+ className: "gap-2",
551
+ children: [transitionMutation.isPending && /* @__PURE__ */ jsx(Icon, {
552
+ icon: "ph:spinner-gap",
553
+ className: "size-4 animate-spin"
554
+ }), transitionSchedule ? t("workflow.scheduleLabel") : t("workflow.transition")]
555
+ })] })
556
+ ] })
557
+ }),
558
+ /* @__PURE__ */ jsx(Dialog, {
559
+ open: localeChangeDialog.open,
560
+ onOpenChange: (open) => !open && handleLocaleChangeCancel(),
561
+ children: /* @__PURE__ */ jsxs(DialogContent, { children: [/* @__PURE__ */ jsxs(DialogHeader, { children: [/* @__PURE__ */ jsx(DialogTitle, { children: t("locale.unsavedChanges") }), /* @__PURE__ */ jsx(DialogDescription, { children: t("locale.unsavedChangesDescription") })] }), /* @__PURE__ */ jsxs(DialogFooter, { children: [/* @__PURE__ */ jsx(Button, {
562
+ variant: "outline",
563
+ onClick: handleLocaleChangeCancel,
564
+ children: t("common.cancel")
565
+ }), /* @__PURE__ */ jsx(Button, {
566
+ variant: "default",
567
+ onClick: handleLocaleChangeConfirm,
568
+ children: t("locale.discardChanges")
569
+ })] })] })
570
+ })
571
+ ]
1393
572
  });
1394
- }
1395
- function _temp(v) {
1396
- return v.id;
1397
573
  }
1398
574
 
1399
575
  //#endregion