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