@questpie/admin 3.2.4 → 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 (248) 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.mjs +40 -126
  8. package/dist/client/components/auth/auth-loading.mjs +9 -44
  9. package/dist/client/components/blocks/block-canvas.mjs +31 -95
  10. package/dist/client/components/blocks/block-editor-context.mjs +13 -57
  11. package/dist/client/components/blocks/block-editor-layout.mjs +72 -166
  12. package/dist/client/components/blocks/block-editor-provider.mjs +184 -245
  13. package/dist/client/components/blocks/block-fields-renderer.mjs +54 -229
  14. package/dist/client/components/blocks/block-insert-button.mjs +49 -165
  15. package/dist/client/components/blocks/block-item-menu.mjs +102 -301
  16. package/dist/client/components/blocks/block-item.mjs +136 -370
  17. package/dist/client/components/blocks/block-library-sidebar.mjs +103 -230
  18. package/dist/client/components/blocks/block-tree.mjs +12 -68
  19. package/dist/client/components/blocks/block-type-icon.mjs +14 -56
  20. package/dist/client/components/brand-logo.mjs +35 -149
  21. package/dist/client/components/component-renderer.mjs +42 -118
  22. package/dist/client/components/error-boundary.mjs +14 -58
  23. package/dist/client/components/fields/array-field.mjs +209 -521
  24. package/dist/client/components/fields/asset-preview-field.mjs +41 -141
  25. package/dist/client/components/fields/blocks-field/blocks-field.mjs +60 -156
  26. package/dist/client/components/fields/boolean-field.mjs +29 -59
  27. package/dist/client/components/fields/date-field.mjs +7 -37
  28. package/dist/client/components/fields/datetime-field.mjs +7 -38
  29. package/dist/client/components/fields/email-field.mjs +25 -54
  30. package/dist/client/components/fields/field-wrapper.mjs +30 -105
  31. package/dist/client/components/fields/json-field.mjs +94 -296
  32. package/dist/client/components/fields/locale-badge.mjs +6 -15
  33. package/dist/client/components/fields/number-field.mjs +27 -60
  34. package/dist/client/components/fields/object-array-field.mjs +283 -659
  35. package/dist/client/components/fields/object-field.mjs +165 -633
  36. package/dist/client/components/fields/relation/displays/cards-display.mjs +106 -220
  37. package/dist/client/components/fields/relation/displays/chips-display.mjs +78 -150
  38. package/dist/client/components/fields/relation/displays/grid-display.mjs +92 -186
  39. package/dist/client/components/fields/relation/displays/list-display.mjs +122 -239
  40. package/dist/client/components/fields/relation/displays/table-display.mjs +70 -244
  41. package/dist/client/components/fields/relation/relation-items-display.mjs +30 -126
  42. package/dist/client/components/fields/relation-field.mjs +10 -66
  43. package/dist/client/components/fields/relation-picker.mjs +18 -18
  44. package/dist/client/components/fields/relation-select.mjs +12 -12
  45. package/dist/client/components/fields/rich-text-editor/bubble-menu.mjs +80 -180
  46. package/dist/client/components/fields/rich-text-editor/image-popover.mjs +2 -2
  47. package/dist/client/components/fields/rich-text-editor/image-upload.mjs +13 -29
  48. package/dist/client/components/fields/rich-text-editor/index.mjs +195 -513
  49. package/dist/client/components/fields/rich-text-editor/slash-commands.mjs +61 -111
  50. package/dist/client/components/fields/rich-text-editor/table-controls.mjs +105 -415
  51. package/dist/client/components/fields/rich-text-editor/toolbar.mjs +256 -511
  52. package/dist/client/components/fields/rich-text-field.mjs +14 -53
  53. package/dist/client/components/fields/select-field.mjs +39 -74
  54. package/dist/client/components/fields/text-field.mjs +26 -59
  55. package/dist/client/components/fields/textarea-field.mjs +26 -58
  56. package/dist/client/components/fields/time-field.mjs +7 -35
  57. package/dist/client/components/fields/upload-field.mjs +47 -165
  58. package/dist/client/components/filter-builder/columns-tab.mjs +80 -280
  59. package/dist/client/components/filter-builder/filter-builder-sheet.mjs +197 -540
  60. package/dist/client/components/filter-builder/filters-tab.mjs +96 -386
  61. package/dist/client/components/filter-builder/saved-views-tab.mjs +133 -351
  62. package/dist/client/components/history-sidebar.mjs +285 -605
  63. package/dist/client/components/layout/field-layout-renderer.mjs +106 -254
  64. package/dist/client/components/locale-switcher.mjs +106 -228
  65. package/dist/client/components/media/media-grid.mjs +84 -273
  66. package/dist/client/components/media/media-picker-dialog.mjs +176 -476
  67. package/dist/client/components/preview/live-preview-mode.mjs +233 -458
  68. package/dist/client/components/preview/preview-pane.mjs +22 -22
  69. package/dist/client/components/primitives/asset-preview.mjs +290 -666
  70. package/dist/client/components/primitives/checkbox-input.mjs +9 -35
  71. package/dist/client/components/primitives/date-input.mjs +109 -327
  72. package/dist/client/components/primitives/dropzone.mjs +209 -336
  73. package/dist/client/components/primitives/field-select-control.mjs +12 -80
  74. package/dist/client/components/primitives/number-input.mjs +4 -4
  75. package/dist/client/components/primitives/select-multi.mjs +200 -559
  76. package/dist/client/components/primitives/select-single.mjs +165 -499
  77. package/dist/client/components/primitives/time-input.mjs +43 -117
  78. package/dist/client/components/primitives/toggle-input.mjs +9 -29
  79. package/dist/client/components/sheets/resource-sheet.mjs +61 -70
  80. package/dist/client/components/ui/accordion.mjs +35 -155
  81. package/dist/client/components/ui/alert.mjs +13 -68
  82. package/dist/client/components/ui/badge.mjs +9 -51
  83. package/dist/client/components/ui/button.mjs +8 -54
  84. package/dist/client/components/ui/card.mjs +37 -193
  85. package/dist/client/components/ui/checkbox.mjs +12 -68
  86. package/dist/client/components/ui/command.mjs +48 -219
  87. package/dist/client/components/ui/dialog.mjs +50 -262
  88. package/dist/client/components/ui/drawer.mjs +55 -259
  89. package/dist/client/components/ui/dropdown-menu.mjs +86 -427
  90. package/dist/client/components/ui/empty-state.mjs +28 -98
  91. package/dist/client/components/ui/field.mjs +73 -309
  92. package/dist/client/components/ui/input-group.mjs +42 -167
  93. package/dist/client/components/ui/input.mjs +7 -37
  94. package/dist/client/components/ui/kbd.mjs +6 -36
  95. package/dist/client/components/ui/label.mjs +7 -37
  96. package/dist/client/components/ui/popover.mjs +34 -169
  97. package/dist/client/components/ui/responsive-dialog.mjs +67 -273
  98. package/dist/client/components/ui/scroll-fade.mjs +63 -158
  99. package/dist/client/components/ui/search-input.mjs +33 -100
  100. package/dist/client/components/ui/select.mjs +72 -393
  101. package/dist/client/components/ui/separator.mjs +7 -38
  102. package/dist/client/components/ui/sheet.mjs +49 -269
  103. package/dist/client/components/ui/sidebar.mjs +171 -690
  104. package/dist/client/components/ui/skeleton.mjs +7 -38
  105. package/dist/client/components/ui/sonner.mjs +11 -42
  106. package/dist/client/components/ui/switch.mjs +9 -45
  107. package/dist/client/components/ui/table.mjs +48 -266
  108. package/dist/client/components/ui/tabs.mjs +26 -139
  109. package/dist/client/components/ui/textarea.mjs +6 -32
  110. package/dist/client/components/ui/tooltip.mjs +27 -129
  111. package/dist/client/components/widgets/chart-widget.mjs +174 -522
  112. package/dist/client/components/widgets/progress-widget.mjs +66 -172
  113. package/dist/client/components/widgets/quick-actions-widget.mjs +102 -261
  114. package/dist/client/components/widgets/recent-items-widget.mjs +69 -195
  115. package/dist/client/components/widgets/stats-widget.mjs +41 -175
  116. package/dist/client/components/widgets/table-widget.mjs +9 -9
  117. package/dist/client/components/widgets/timeline-widget.mjs +86 -226
  118. package/dist/client/components/widgets/value-widget.mjs +74 -381
  119. package/dist/client/components/widgets/widget-empty-state.mjs +26 -76
  120. package/dist/client/components/widgets/widget-skeletons.mjs +138 -421
  121. package/dist/client/contexts/focus-context.mjs +63 -146
  122. package/dist/client/hooks/typed-hooks.mjs +241 -701
  123. package/dist/client/hooks/use-action.mjs +62 -198
  124. package/dist/client/hooks/use-admin-config.mjs +5 -35
  125. package/dist/client/hooks/use-admin-preferences.mjs +16 -88
  126. package/dist/client/hooks/use-admin-routes.mjs +22 -56
  127. package/dist/client/hooks/use-audit-history.mjs +21 -69
  128. package/dist/client/hooks/use-brand.mjs +1 -9
  129. package/dist/client/hooks/use-collection-fields.mjs +17 -57
  130. package/dist/client/hooks/use-collection-meta.mjs +12 -44
  131. package/dist/client/hooks/use-collection-schema.mjs +10 -33
  132. package/dist/client/hooks/use-collection-validation.mjs +23 -53
  133. package/dist/client/hooks/use-collection.mjs +194 -614
  134. package/dist/client/hooks/use-current-user.mjs +0 -1
  135. package/dist/client/hooks/use-field-hooks.mjs +10 -10
  136. package/dist/client/hooks/use-field-options.mjs +61 -202
  137. package/dist/client/hooks/use-global-fields.mjs +14 -46
  138. package/dist/client/hooks/use-global-meta.mjs +9 -30
  139. package/dist/client/hooks/use-global-schema.mjs +9 -30
  140. package/dist/client/hooks/use-global.mjs +63 -219
  141. package/dist/client/hooks/use-locks.mjs +117 -325
  142. package/dist/client/hooks/use-media-query.mjs +16 -36
  143. package/dist/client/hooks/use-prefill-params.mjs +0 -1
  144. package/dist/client/hooks/use-questpie-query-options.mjs +12 -29
  145. package/dist/client/hooks/use-reactive-fields.mjs +1 -1
  146. package/dist/client/hooks/use-reactive-prop.mjs +65 -223
  147. package/dist/client/hooks/use-realtime-highlight.mjs +51 -114
  148. package/dist/client/hooks/use-saved-views.mjs +22 -103
  149. package/dist/client/hooks/use-search-param-toggle.mjs +28 -79
  150. package/dist/client/hooks/use-search.mjs +31 -143
  151. package/dist/client/hooks/use-server-actions.mjs +18 -50
  152. package/dist/client/hooks/use-server-validation.mjs +72 -166
  153. package/dist/client/hooks/use-server-widget-data.mjs +7 -33
  154. package/dist/client/hooks/use-setup-status.mjs +12 -25
  155. package/dist/client/hooks/use-sidebar-search-param.mjs +33 -78
  156. package/dist/client/hooks/use-transition-stage.mjs +8 -38
  157. package/dist/client/hooks/use-upload.mjs +54 -152
  158. package/dist/client/hooks/use-validation-error-map.mjs +6 -26
  159. package/dist/client/hooks/use-view-state.mjs +187 -437
  160. package/dist/client/i18n/hooks.mjs +65 -197
  161. package/dist/client/lib/render-profiler.mjs +14 -41
  162. package/dist/client/preview/block-scope-context.d.mts +2 -2
  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.d.mts +2 -2
  174. package/dist/client/scope/picker.mjs +86 -321
  175. package/dist/client/scope/provider.d.mts +2 -2
  176. package/dist/client/scope/provider.mjs +8 -17
  177. package/dist/client/views/auth/accept-invite-form.d.mts +2 -2
  178. package/dist/client/views/auth/accept-invite-form.mjs +121 -412
  179. package/dist/client/views/auth/auth-layout.d.mts +3 -3
  180. package/dist/client/views/auth/auth-layout.mjs +104 -284
  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 +109 -363
  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.mjs +41 -121
  222. package/dist/client/views/pages/reset-password-page.mjs +46 -173
  223. package/dist/client/views/pages/setup-page.mjs +33 -95
  224. package/dist/components/rich-text/rich-text-renderer.d.mts +2 -2
  225. package/dist/components/rich-text/rich-text-renderer.mjs +9 -33
  226. package/dist/server/modules/admin/collections/account.d.mts +46 -46
  227. package/dist/server/modules/admin/collections/admin-locks.d.mts +50 -50
  228. package/dist/server/modules/admin/collections/admin-preferences.d.mts +39 -39
  229. package/dist/server/modules/admin/collections/admin-saved-views.d.mts +47 -47
  230. package/dist/server/modules/admin/collections/apikey.d.mts +68 -68
  231. package/dist/server/modules/admin/collections/assets.d.mts +39 -39
  232. package/dist/server/modules/admin/collections/session.d.mts +41 -41
  233. package/dist/server/modules/admin/collections/user.d.mts +63 -63
  234. package/dist/server/modules/admin/collections/verification.d.mts +36 -36
  235. package/dist/server/modules/admin/index.d.mts +20 -19
  236. package/dist/server/modules/admin/routes/admin-config.d.mts +2 -2
  237. package/dist/server/modules/admin/routes/execute-action.d.mts +9 -9
  238. package/dist/server/modules/admin/routes/locales.d.mts +2 -2
  239. package/dist/server/modules/admin/routes/preview.d.mts +11 -11
  240. package/dist/server/modules/admin/routes/reactive.d.mts +9 -9
  241. package/dist/server/modules/admin/routes/setup.d.mts +7 -7
  242. package/dist/server/modules/admin/routes/translations.d.mts +4 -4
  243. package/dist/server/modules/admin/routes/widget-data.d.mts +5 -5
  244. package/dist/server/modules/admin-preferences/collections/saved-views.d.mts +45 -45
  245. package/dist/server/modules/audit/.generated/module.d.mts +6 -6
  246. package/dist/server/modules/audit/collections/audit-log.d.mts +78 -78
  247. package/dist/server/modules/audit/jobs/audit-cleanup.d.mts +2 -2
  248. package/package.json +3 -5
@@ -1,7 +1,6 @@
1
1
  import { useQuestpieQueryOptions } from "./use-questpie-query-options.mjs";
2
2
  import { useCurrentUser } from "./use-current-user.mjs";
3
- import { c } from "react/compiler-runtime";
4
- import { useEffect, useRef } from "react";
3
+ import { useCallback, useEffect, useRef } from "react";
5
4
  import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
6
5
 
7
6
  //#region src/client/hooks/use-locks.ts
@@ -61,87 +60,31 @@ function getSessionId() {
61
60
  * ```
62
61
  */
63
62
  function useLocks(options) {
64
- const $ = c(22);
65
- const { resourceType, resource, realtime: t0 } = options;
66
- const realtime = t0 === void 0 ? true : t0;
63
+ const { resourceType, resource, realtime = true } = options;
67
64
  const { queryOpts } = useQuestpieQueryOptions();
68
65
  const currentUser = useCurrentUser();
69
- const t1 = queryOpts;
70
- let t2;
71
- if ($[0] !== realtime || $[1] !== resource || $[2] !== resourceType || $[3] !== t1.collections.admin_locks) {
72
- t2 = t1.collections.admin_locks.find({
73
- where: {
74
- resourceType,
75
- resource,
76
- expiresAt: { gt: /* @__PURE__ */ new Date() }
77
- },
78
- with: { user: true }
79
- }, { realtime });
80
- $[0] = realtime;
81
- $[1] = resource;
82
- $[2] = resourceType;
83
- $[3] = t1.collections.admin_locks;
84
- $[4] = t2;
85
- } else t2 = $[4];
86
- let t3;
87
- if ($[5] !== t2) {
88
- t3 = { ...t2 };
89
- $[5] = t2;
90
- $[6] = t3;
91
- } else t3 = $[6];
92
- const { data: rawData, isLoading } = useQuery(t3);
66
+ const { data: rawData, isLoading } = useQuery({ ...queryOpts.collections.admin_locks.find({
67
+ where: {
68
+ resourceType,
69
+ resource,
70
+ expiresAt: { gt: /* @__PURE__ */ new Date() }
71
+ },
72
+ with: { user: true }
73
+ }, { realtime }) });
93
74
  const data = rawData;
94
- let locks;
95
- if ($[7] !== data) {
96
- locks = /* @__PURE__ */ new Map();
97
- if (data?.docs) for (const lock of data.docs) locks.set(lock.resourceId, lock);
98
- $[7] = data;
99
- $[8] = locks;
100
- } else locks = $[8];
101
- let t4;
102
- if ($[9] !== locks) {
103
- t4 = (resourceId) => locks.has(resourceId);
104
- $[9] = locks;
105
- $[10] = t4;
106
- } else t4 = $[10];
107
- const isLocked = t4;
108
- let t5;
109
- if ($[11] !== locks) {
110
- t5 = (resourceId_0) => locks.get(resourceId_0);
111
- $[11] = locks;
112
- $[12] = t5;
113
- } else t5 = $[12];
114
- const getLock = t5;
115
- let t6;
116
- if ($[13] !== currentUser?.id || $[14] !== locks) {
117
- t6 = (resourceId_1) => {
118
- const lock_0 = locks.get(resourceId_1);
119
- if (!lock_0) return false;
120
- return getLockUserId(lock_0) === currentUser?.id;
121
- };
122
- $[13] = currentUser?.id;
123
- $[14] = locks;
124
- $[15] = t6;
125
- } else t6 = $[15];
126
- currentUser?.id;
127
- const isOwnLock = t6;
128
- let t7;
129
- if ($[16] !== getLock || $[17] !== isLoading || $[18] !== isLocked || $[19] !== isOwnLock || $[20] !== locks) {
130
- t7 = {
131
- locks,
132
- isLocked,
133
- getLock,
134
- isOwnLock,
135
- isLoading
136
- };
137
- $[16] = getLock;
138
- $[17] = isLoading;
139
- $[18] = isLocked;
140
- $[19] = isOwnLock;
141
- $[20] = locks;
142
- $[21] = t7;
143
- } else t7 = $[21];
144
- return t7;
75
+ const locks = /* @__PURE__ */ new Map();
76
+ if (data?.docs) for (const lock of data.docs) locks.set(lock.resourceId, lock);
77
+ return {
78
+ locks,
79
+ isLocked: useCallback((resourceId) => locks.has(resourceId), [locks]),
80
+ getLock: useCallback((resourceId) => locks.get(resourceId), [locks]),
81
+ isOwnLock: useCallback((resourceId) => {
82
+ const lock = locks.get(resourceId);
83
+ if (!lock) return false;
84
+ return getLockUserId(lock) === currentUser?.id;
85
+ }, [locks, currentUser?.id]),
86
+ isLoading
87
+ };
145
88
  }
146
89
  /**
147
90
  * Manage a document lock for editing.
@@ -166,17 +109,13 @@ function useLocks(options) {
166
109
  * ```
167
110
  */
168
111
  function useLock(options) {
169
- const $ = c(67);
170
- const { resourceType, resource, resourceId, autoAcquire: t0, onAcquired, onBlocked, onReleased } = options;
171
- const autoAcquire = t0 === void 0 ? true : t0;
112
+ const { resourceType, resource, resourceId, autoAcquire = true, onAcquired, onBlocked, onReleased } = options;
172
113
  const { queryOpts } = useQuestpieQueryOptions();
173
114
  const queryClient = useQueryClient();
174
115
  const currentUser = useCurrentUser();
175
116
  const lockIdRef = useRef(null);
176
- const t1 = queryOpts;
177
- let t2;
178
- if ($[0] !== resource || $[1] !== resourceId || $[2] !== resourceType || $[3] !== t1.collections.admin_locks) {
179
- t2 = t1.collections.admin_locks.find({
117
+ const { data: rawExistingLockData, isLoading: isCheckingLock } = useQuery({
118
+ ...queryOpts.collections.admin_locks.find({
180
119
  where: {
181
120
  resourceType,
182
121
  resource,
@@ -185,46 +124,17 @@ function useLock(options) {
185
124
  },
186
125
  with: { user: true },
187
126
  limit: 1
188
- });
189
- $[0] = resource;
190
- $[1] = resourceId;
191
- $[2] = resourceType;
192
- $[3] = t1.collections.admin_locks;
193
- $[4] = t2;
194
- } else t2 = $[4];
195
- const t3 = !!resourceId;
196
- let t4;
197
- if ($[5] !== t2 || $[6] !== t3) {
198
- t4 = {
199
- ...t2,
200
- enabled: t3
201
- };
202
- $[5] = t2;
203
- $[6] = t3;
204
- $[7] = t4;
205
- } else t4 = $[7];
206
- const { data: rawExistingLockData, isLoading: isCheckingLock } = useQuery(t4);
127
+ }),
128
+ enabled: !!resourceId
129
+ });
207
130
  const existingLock = rawExistingLockData?.docs?.[0] ?? null;
208
- let t5;
209
- if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
210
- t5 = getSessionId();
211
- $[8] = t5;
212
- } else t5 = $[8];
213
- const sessionId = t5;
131
+ const sessionId = getSessionId();
214
132
  const isOwnSession = existingLock?.sessionId === sessionId;
215
- let t6;
216
- if ($[9] !== currentUser?.id || $[10] !== existingLock) {
217
- t6 = existingLock ? getLockUserId(existingLock) === currentUser?.id : false;
218
- $[9] = currentUser?.id;
219
- $[10] = existingLock;
220
- $[11] = t6;
221
- } else t6 = $[11];
222
- const isOwnUser = t6;
133
+ const isOwnUser = existingLock ? getLockUserId(existingLock) === currentUser?.id : false;
223
134
  const blockedBy = existingLock && !isOwnUser ? existingLock : null;
224
135
  const ownLockElsewhere = existingLock && isOwnUser && !isOwnSession;
225
- let t7;
226
- if ($[12] !== currentUser || $[13] !== queryOpts || $[14] !== resource || $[15] !== resourceId || $[16] !== resourceType) {
227
- t7 = async () => {
136
+ const createMutation = useMutation({
137
+ mutationFn: async () => {
228
138
  if (!currentUser) throw new Error("Not authenticated");
229
139
  const expiresAt = new Date(Date.now() + LOCK_DURATION_MS);
230
140
  return await queryOpts.collections.admin_locks.create({
@@ -235,217 +145,99 @@ function useLock(options) {
235
145
  sessionId,
236
146
  expiresAt
237
147
  });
238
- };
239
- $[12] = currentUser;
240
- $[13] = queryOpts;
241
- $[14] = resource;
242
- $[15] = resourceId;
243
- $[16] = resourceType;
244
- $[17] = t7;
245
- } else t7 = $[17];
246
- let t8;
247
- if ($[18] !== onAcquired || $[19] !== queryClient) {
248
- t8 = (lock) => {
148
+ },
149
+ onSuccess: (lock) => {
249
150
  lockIdRef.current = lock.id;
250
151
  onAcquired?.(lock);
251
152
  queryClient.invalidateQueries({ queryKey: ["collections", "admin_locks"] });
252
- };
253
- $[18] = onAcquired;
254
- $[19] = queryClient;
255
- $[20] = t8;
256
- } else t8 = $[20];
257
- let t9;
258
- if ($[21] !== t7 || $[22] !== t8) {
259
- t9 = {
260
- mutationFn: t7,
261
- onSuccess: t8
262
- };
263
- $[21] = t7;
264
- $[22] = t8;
265
- $[23] = t9;
266
- } else t9 = $[23];
267
- const createMutation = useMutation(t9);
268
- let t10;
269
- if ($[24] !== queryOpts) {
270
- t10 = { mutationFn: async () => {
271
- if (!lockIdRef.current) return;
272
- const expiresAt_0 = new Date(Date.now() + LOCK_DURATION_MS);
273
- await queryOpts.collections.admin_locks.update({
274
- id: lockIdRef.current,
275
- data: { expiresAt: expiresAt_0 }
276
- });
277
- } };
278
- $[24] = queryOpts;
279
- $[25] = t10;
280
- } else t10 = $[25];
281
- const updateMutation = useMutation(t10);
282
- let t11;
283
- if ($[26] !== queryOpts) {
284
- t11 = async () => {
153
+ }
154
+ });
155
+ const updateMutation = useMutation({ mutationFn: async () => {
156
+ if (!lockIdRef.current) return;
157
+ const expiresAt = new Date(Date.now() + LOCK_DURATION_MS);
158
+ await queryOpts.collections.admin_locks.update({
159
+ id: lockIdRef.current,
160
+ data: { expiresAt }
161
+ });
162
+ } });
163
+ const deleteMutation = useMutation({
164
+ mutationFn: async () => {
285
165
  if (!lockIdRef.current) return;
286
166
  await queryOpts.collections.admin_locks.delete({ id: lockIdRef.current });
287
- };
288
- $[26] = queryOpts;
289
- $[27] = t11;
290
- } else t11 = $[27];
291
- let t12;
292
- if ($[28] !== onReleased || $[29] !== queryClient) {
293
- t12 = () => {
167
+ },
168
+ onSuccess: () => {
294
169
  lockIdRef.current = null;
295
170
  onReleased?.();
296
171
  queryClient.invalidateQueries({ queryKey: ["collections", "admin_locks"] });
172
+ }
173
+ });
174
+ const acquire = useCallback(async () => {
175
+ if (existingLock && !isOwnUser) {
176
+ onBlocked?.(existingLock);
177
+ return null;
178
+ }
179
+ if (isOwnSession && existingLock) {
180
+ lockIdRef.current = existingLock.id;
181
+ return existingLock;
182
+ }
183
+ try {
184
+ return await createMutation.mutateAsync();
185
+ } catch (error) {
186
+ console.error("Failed to acquire lock:", error);
187
+ return null;
188
+ }
189
+ }, [
190
+ existingLock,
191
+ isOwnUser,
192
+ isOwnSession,
193
+ createMutation,
194
+ onBlocked
195
+ ]);
196
+ const release = useCallback(async () => {
197
+ if (lockIdRef.current) try {
198
+ await deleteMutation.mutateAsync();
199
+ } catch (error) {
200
+ console.error("Failed to release lock:", error);
201
+ }
202
+ }, [deleteMutation]);
203
+ const refresh = useCallback(async () => {
204
+ if (lockIdRef.current) try {
205
+ await updateMutation.mutateAsync();
206
+ } catch (error) {
207
+ console.error("Failed to refresh lock:", error);
208
+ }
209
+ }, [updateMutation]);
210
+ useEffect(() => {
211
+ if (!autoAcquire || !resourceId || !currentUser || isCheckingLock) return;
212
+ if (existingLock !== void 0) if (blockedBy) onBlocked?.(blockedBy);
213
+ else acquire();
214
+ }, [
215
+ autoAcquire,
216
+ resourceId,
217
+ currentUser,
218
+ isCheckingLock,
219
+ existingLock,
220
+ blockedBy,
221
+ acquire,
222
+ onBlocked
223
+ ]);
224
+ useEffect(() => {
225
+ const mutate = deleteMutation.mutate;
226
+ return () => {
227
+ if (lockIdRef.current) mutate();
297
228
  };
298
- $[28] = onReleased;
299
- $[29] = queryClient;
300
- $[30] = t12;
301
- } else t12 = $[30];
302
- let t13;
303
- if ($[31] !== t11 || $[32] !== t12) {
304
- t13 = {
305
- mutationFn: t11,
306
- onSuccess: t12
307
- };
308
- $[31] = t11;
309
- $[32] = t12;
310
- $[33] = t13;
311
- } else t13 = $[33];
312
- const deleteMutation = useMutation(t13);
313
- let t14;
314
- if ($[34] !== createMutation || $[35] !== existingLock || $[36] !== isOwnSession || $[37] !== isOwnUser || $[38] !== onBlocked) {
315
- t14 = async () => {
316
- if (existingLock && !isOwnUser) {
317
- onBlocked?.(existingLock);
318
- return null;
319
- }
320
- if (isOwnSession && existingLock) {
321
- lockIdRef.current = existingLock.id;
322
- return existingLock;
323
- }
324
- try {
325
- return await createMutation.mutateAsync();
326
- } catch (t15$1) {
327
- const error = t15$1;
328
- console.error("Failed to acquire lock:", error);
329
- return null;
330
- }
331
- };
332
- $[34] = createMutation;
333
- $[35] = existingLock;
334
- $[36] = isOwnSession;
335
- $[37] = isOwnUser;
336
- $[38] = onBlocked;
337
- $[39] = t14;
338
- } else t14 = $[39];
339
- const acquire = t14;
340
- let t15;
341
- if ($[40] !== deleteMutation) {
342
- t15 = async () => {
343
- if (lockIdRef.current) try {
344
- await deleteMutation.mutateAsync();
345
- } catch (t16$1) {
346
- const error_0 = t16$1;
347
- console.error("Failed to release lock:", error_0);
348
- }
349
- };
350
- $[40] = deleteMutation;
351
- $[41] = t15;
352
- } else t15 = $[41];
353
- const release = t15;
354
- let t16;
355
- if ($[42] !== updateMutation) {
356
- t16 = async () => {
357
- if (lockIdRef.current) try {
358
- await updateMutation.mutateAsync();
359
- } catch (t17$1) {
360
- const error_1 = t17$1;
361
- console.error("Failed to refresh lock:", error_1);
362
- }
363
- };
364
- $[42] = updateMutation;
365
- $[43] = t16;
366
- } else t16 = $[43];
367
- const refresh = t16;
368
- let t17;
369
- let t18;
370
- if ($[44] !== acquire || $[45] !== autoAcquire || $[46] !== blockedBy || $[47] !== currentUser || $[48] !== existingLock || $[49] !== isCheckingLock || $[50] !== onBlocked || $[51] !== resourceId) {
371
- t17 = () => {
372
- if (!autoAcquire || !resourceId || !currentUser || isCheckingLock) return;
373
- if (existingLock !== void 0) if (blockedBy) onBlocked?.(blockedBy);
374
- else acquire();
375
- };
376
- t18 = [
377
- autoAcquire,
378
- resourceId,
379
- currentUser,
380
- isCheckingLock,
381
- existingLock,
382
- blockedBy,
383
- acquire,
384
- onBlocked
385
- ];
386
- $[44] = acquire;
387
- $[45] = autoAcquire;
388
- $[46] = blockedBy;
389
- $[47] = currentUser;
390
- $[48] = existingLock;
391
- $[49] = isCheckingLock;
392
- $[50] = onBlocked;
393
- $[51] = resourceId;
394
- $[52] = t17;
395
- $[53] = t18;
396
- } else {
397
- t17 = $[52];
398
- t18 = $[53];
399
- }
400
- useEffect(t17, t18);
401
- let t19;
402
- let t20;
403
- if ($[54] !== deleteMutation.mutate) {
404
- t19 = () => {
405
- const mutate = deleteMutation.mutate;
406
- return () => {
407
- if (lockIdRef.current) mutate();
408
- };
409
- };
410
- t20 = [deleteMutation.mutate];
411
- $[54] = deleteMutation.mutate;
412
- $[55] = t19;
413
- $[56] = t20;
414
- } else {
415
- t19 = $[55];
416
- t20 = $[56];
417
- }
418
- useEffect(t19, t20);
419
- const t21 = isOwnSession ? existingLock : null;
420
- const t22 = isOwnSession && !!existingLock;
421
- const t23 = !!blockedBy;
422
- const t24 = !!ownLockElsewhere;
423
- const t25 = isCheckingLock || createMutation.isPending || updateMutation.isPending || deleteMutation.isPending;
424
- let t26;
425
- if ($[57] !== acquire || $[58] !== blockedBy || $[59] !== refresh || $[60] !== release || $[61] !== t21 || $[62] !== t22 || $[63] !== t23 || $[64] !== t24 || $[65] !== t25) {
426
- t26 = {
427
- lock: t21,
428
- blockedBy,
429
- isLocked: t22,
430
- isBlocked: t23,
431
- isOpenElsewhere: t24,
432
- isPending: t25,
433
- acquire,
434
- release,
435
- refresh
436
- };
437
- $[57] = acquire;
438
- $[58] = blockedBy;
439
- $[59] = refresh;
440
- $[60] = release;
441
- $[61] = t21;
442
- $[62] = t22;
443
- $[63] = t23;
444
- $[64] = t24;
445
- $[65] = t25;
446
- $[66] = t26;
447
- } else t26 = $[66];
448
- return t26;
229
+ }, [deleteMutation.mutate]);
230
+ return {
231
+ lock: isOwnSession ? existingLock : null,
232
+ blockedBy,
233
+ isLocked: isOwnSession && !!existingLock,
234
+ isBlocked: !!blockedBy,
235
+ isOpenElsewhere: !!ownLockElsewhere,
236
+ isPending: isCheckingLock || createMutation.isPending || updateMutation.isPending || deleteMutation.isPending,
237
+ acquire,
238
+ release,
239
+ refresh
240
+ };
449
241
  }
450
242
 
451
243
  //#endregion
@@ -1,6 +1,5 @@
1
1
  "use client";
2
2
 
3
- import { c } from "react/compiler-runtime";
4
3
  import * as React from "react";
5
4
 
6
5
  //#region src/client/hooks/use-media-query.ts
@@ -15,43 +14,24 @@ import * as React from "react";
15
14
  * ```
16
15
  */
17
16
  function useMediaQuery(query) {
18
- const $ = c(5);
19
- let t0;
20
- if ($[0] !== query) {
21
- t0 = () => {
22
- if (typeof window === "undefined") return false;
23
- return window.matchMedia(query).matches;
17
+ const [matches, setMatches] = React.useState(() => {
18
+ if (typeof window === "undefined") return false;
19
+ return window.matchMedia(query).matches;
20
+ });
21
+ React.useEffect(() => {
22
+ if (typeof window === "undefined") return;
23
+ const mediaQuery = window.matchMedia(query);
24
+ setMatches(mediaQuery.matches);
25
+ const listener = (event) => {
26
+ setMatches(event.matches);
24
27
  };
25
- $[0] = query;
26
- $[1] = t0;
27
- } else t0 = $[1];
28
- const [matches, setMatches] = React.useState(t0);
29
- let t1;
30
- let t2;
31
- if ($[2] !== query) {
32
- t1 = () => {
33
- if (typeof window === "undefined") return;
34
- const mediaQuery = window.matchMedia(query);
35
- setMatches(mediaQuery.matches);
36
- const listener = (event) => {
37
- setMatches(event.matches);
38
- };
39
- if (mediaQuery.addEventListener) mediaQuery.addEventListener("change", listener);
40
- else mediaQuery.addListener(listener);
41
- return () => {
42
- if (mediaQuery.removeEventListener) mediaQuery.removeEventListener("change", listener);
43
- else mediaQuery.removeListener(listener);
44
- };
28
+ if (mediaQuery.addEventListener) mediaQuery.addEventListener("change", listener);
29
+ else mediaQuery.addListener(listener);
30
+ return () => {
31
+ if (mediaQuery.removeEventListener) mediaQuery.removeEventListener("change", listener);
32
+ else mediaQuery.removeListener(listener);
45
33
  };
46
- t2 = [query];
47
- $[2] = query;
48
- $[3] = t1;
49
- $[4] = t2;
50
- } else {
51
- t1 = $[3];
52
- t2 = $[4];
53
- }
54
- React.useEffect(t1, t2);
34
+ }, [query]);
55
35
  return matches;
56
36
  }
57
37
  /**
@@ -1,4 +1,3 @@
1
- import { c } from "react/compiler-runtime";
2
1
  import "react";
3
2
 
4
3
  //#region src/client/hooks/use-prefill-params.ts
@@ -1,6 +1,6 @@
1
1
  import { selectClient, useAdminStore } from "../runtime/provider.mjs";
2
2
  import { useScopedLocale } from "../runtime/locale-scope.mjs";
3
- import { c } from "react/compiler-runtime";
3
+ import * as React from "react";
4
4
  import { useQueryClient } from "@tanstack/react-query";
5
5
  import { createQuestpieQueryOptions } from "@questpie/tanstack-query";
6
6
 
@@ -10,40 +10,23 @@ const DEFAULT_KEY_PREFIX = ["questpie", "collections"];
10
10
  * Shared hook that creates questpie query options with the current client and scoped locale.
11
11
  * Deduplicates the common pattern used across collection/global hooks.
12
12
  */
13
- function useQuestpieQueryOptions(t0) {
14
- const $ = c(9);
15
- const keyPrefix = t0 === void 0 ? DEFAULT_KEY_PREFIX : t0;
13
+ function useQuestpieQueryOptions(keyPrefix = DEFAULT_KEY_PREFIX) {
16
14
  const client = useAdminStore(selectClient);
17
15
  const { locale } = useScopedLocale();
18
16
  const queryClient = useQueryClient();
19
- const t1 = client;
20
- let t2;
21
- if ($[0] !== keyPrefix || $[1] !== locale || $[2] !== t1) {
22
- t2 = createQuestpieQueryOptions(t1, {
17
+ return {
18
+ queryOpts: React.useMemo(() => createQuestpieQueryOptions(client, {
23
19
  keyPrefix,
24
20
  locale
25
- });
26
- $[0] = keyPrefix;
27
- $[1] = locale;
28
- $[2] = t1;
29
- $[3] = t2;
30
- } else t2 = $[3];
31
- const queryOpts = t2;
32
- let t3;
33
- if ($[4] !== client || $[5] !== locale || $[6] !== queryClient || $[7] !== queryOpts) {
34
- t3 = {
35
- queryOpts,
36
- queryClient,
21
+ }), [
22
+ client,
37
23
  locale,
38
- client
39
- };
40
- $[4] = client;
41
- $[5] = locale;
42
- $[6] = queryClient;
43
- $[7] = queryOpts;
44
- $[8] = t3;
45
- } else t3 = $[8];
46
- return t3;
24
+ keyPrefix
25
+ ]),
26
+ queryClient,
27
+ locale,
28
+ client
29
+ };
47
30
  }
48
31
 
49
32
  //#endregion
@@ -165,7 +165,7 @@ function useReactiveFields({ collection, mode = "collection", reactiveConfigs, d
165
165
  const affectedDescriptors = /* @__PURE__ */ new Map();
166
166
  for (const dep of changedDeps) {
167
167
  const depDescriptors = dependencyGraph.get(dep) ?? [];
168
- for (const descriptor_0 of depDescriptors) affectedDescriptors.set(`${descriptor_0.field}:${descriptor_0.type}`, descriptor_0);
168
+ for (const descriptor of depDescriptors) affectedDescriptors.set(`${descriptor.field}:${descriptor.type}`, descriptor);
169
169
  }
170
170
  if (affectedDescriptors.size === 0) return;
171
171
  if (debounceTimerRef.current) clearTimeout(debounceTimerRef.current);