@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
@@ -1,5 +1,4 @@
1
1
  import { useAdminStore } from "../runtime/provider.mjs";
2
- import { c } from "react/compiler-runtime";
3
2
  import * as React from "react";
4
3
  import { useQuery } from "@tanstack/react-query";
5
4
  import { useFormContext, useWatch } from "react-hook-form";
@@ -41,46 +40,24 @@ function hashDeps(values) {
41
40
  return JSON.stringify(values, (_, v) => v === void 0 ? "__undef__" : v);
42
41
  }
43
42
  function useDebounced(value, delay) {
44
- const $ = c(4);
45
43
  const [debounced, setDebounced] = React.useState(value);
46
- let t0;
47
- let t1;
48
- if ($[0] !== delay || $[1] !== value) {
49
- t0 = () => {
50
- if (delay <= 0) {
51
- setDebounced(value);
52
- return;
53
- }
54
- const timer = setTimeout(() => setDebounced(value), delay);
55
- return () => clearTimeout(timer);
56
- };
57
- t1 = [value, delay];
58
- $[0] = delay;
59
- $[1] = value;
60
- $[2] = t0;
61
- $[3] = t1;
62
- } else {
63
- t0 = $[2];
64
- t1 = $[3];
65
- }
66
- React.useEffect(t0, t1);
44
+ React.useEffect(() => {
45
+ if (delay <= 0) {
46
+ setDebounced(value);
47
+ return;
48
+ }
49
+ const timer = setTimeout(() => setDebounced(value), delay);
50
+ return () => clearTimeout(timer);
51
+ }, [value, delay]);
67
52
  return debounced;
68
53
  }
69
54
  const EMPTY_PROPS = Object.freeze({});
70
- function useReactiveProps(t0) {
71
- const $ = c(52);
72
- const { entity, entityType: t1, field, props, enabled: t2, debounce: debounceOverride } = t0;
73
- const entityType = t1 === void 0 ? "collection" : t1;
74
- const enabled = t2 === void 0 ? true : t2;
75
- let dbMax;
76
- let dynamicOut;
77
- let staticOut;
78
- let watchSet;
79
- if ($[0] !== props) {
80
- staticOut = {};
81
- dynamicOut = [];
82
- watchSet = /* @__PURE__ */ new Set();
83
- dbMax = 0;
55
+ function useReactiveProps({ entity, entityType = "collection", field, props, enabled = true, debounce: debounceOverride }) {
56
+ const { staticProps, placeholders, watchUnion, debounceMax } = React.useMemo(() => {
57
+ const staticOut = {};
58
+ const dynamicOut = [];
59
+ const watchSet = /* @__PURE__ */ new Set();
60
+ let dbMax = 0;
84
61
  if (props) for (const [key, value] of Object.entries(props)) if (isReactivePropPlaceholder(value)) {
85
62
  dynamicOut.push({
86
63
  key,
@@ -89,105 +66,35 @@ function useReactiveProps(t0) {
89
66
  for (const dep of value.watch) watchSet.add(dep);
90
67
  if (typeof value.debounce === "number" && value.debounce > dbMax) dbMax = value.debounce;
91
68
  } else staticOut[key] = value;
92
- $[0] = props;
93
- $[1] = dbMax;
94
- $[2] = dynamicOut;
95
- $[3] = staticOut;
96
- $[4] = watchSet;
97
- } else {
98
- dbMax = $[1];
99
- dynamicOut = $[2];
100
- staticOut = $[3];
101
- watchSet = $[4];
102
- }
103
- const t3 = dynamicOut.length === 0 ? props ?? EMPTY_PROPS : staticOut;
104
- let t4;
105
- if ($[5] !== watchSet) {
106
- t4 = [...watchSet];
107
- $[5] = watchSet;
108
- $[6] = t4;
109
- } else t4 = $[6];
110
- let t5;
111
- if ($[7] !== dbMax || $[8] !== dynamicOut || $[9] !== t3 || $[10] !== t4) {
112
- t5 = {
113
- staticProps: t3,
69
+ return {
70
+ staticProps: dynamicOut.length === 0 ? props ?? EMPTY_PROPS : staticOut,
114
71
  placeholders: dynamicOut,
115
- watchUnion: t4,
72
+ watchUnion: [...watchSet],
116
73
  debounceMax: dbMax
117
74
  };
118
- $[7] = dbMax;
119
- $[8] = dynamicOut;
120
- $[9] = t3;
121
- $[10] = t4;
122
- $[11] = t5;
123
- } else t5 = $[11];
124
- const { staticProps, placeholders, watchUnion, debounceMax } = t5;
75
+ }, [props]);
125
76
  const debounce = debounceOverride ?? (debounceMax > 0 ? debounceMax : 100);
126
77
  const formContext = useFormContext();
127
- const t6 = formContext?.control;
128
- const t7 = watchUnion;
129
- const t8 = placeholders.length === 0 || !formContext || watchUnion.length === 0;
130
- let t9;
131
- if ($[12] !== t6 || $[13] !== t7 || $[14] !== t8) {
132
- t9 = {
133
- control: t6,
134
- name: t7,
135
- disabled: t8
136
- };
137
- $[12] = t6;
138
- $[13] = t7;
139
- $[14] = t8;
140
- $[15] = t9;
141
- } else t9 = $[15];
142
- const watchedRaw = useWatch(t9);
143
- let t10;
144
- bb0: {
145
- if (placeholders.length === 0) {
146
- let t11$2;
147
- if ($[16] === Symbol.for("react.memo_cache_sentinel")) {
148
- t11$2 = [];
149
- $[16] = t11$2;
150
- } else t11$2 = $[16];
151
- t10 = t11$2;
152
- break bb0;
153
- }
154
- if (watchUnion.length === 0) {
155
- let t11$2;
156
- if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
157
- t11$2 = [];
158
- $[17] = t11$2;
159
- } else t11$2 = $[17];
160
- t10 = t11$2;
161
- break bb0;
162
- }
163
- let t11$1;
164
- if ($[18] !== watchedRaw) {
165
- t11$1 = Array.isArray(watchedRaw) ? watchedRaw : [watchedRaw];
166
- $[18] = watchedRaw;
167
- $[19] = t11$1;
168
- } else t11$1 = $[19];
169
- t10 = t11$1;
170
- }
171
- const debouncedDeps = useDebounced(t10, debounce);
172
- let t11;
173
- if ($[20] !== debouncedDeps) {
174
- t11 = hashDeps(debouncedDeps);
175
- $[20] = debouncedDeps;
176
- $[21] = t11;
177
- } else t11 = $[21];
178
- const depHash = t11;
179
- let t12;
180
- if ($[22] !== placeholders) {
181
- t12 = placeholders.map(_temp).sort();
182
- $[22] = placeholders;
183
- $[23] = t12;
184
- } else t12 = $[23];
185
- const placeholderKeys = t12;
186
- const client = useAdminStore(_temp2);
78
+ const watchedRaw = useWatch({
79
+ control: formContext?.control,
80
+ name: watchUnion,
81
+ disabled: placeholders.length === 0 || !formContext || watchUnion.length === 0
82
+ });
83
+ const debouncedDeps = useDebounced(React.useMemo(() => {
84
+ if (placeholders.length === 0) return [];
85
+ if (watchUnion.length === 0) return [];
86
+ return Array.isArray(watchedRaw) ? watchedRaw : [watchedRaw];
87
+ }, [
88
+ placeholders.length,
89
+ watchUnion.length,
90
+ watchedRaw
91
+ ]), debounce);
92
+ const depHash = React.useMemo(() => hashDeps(debouncedDeps), [debouncedDeps]);
93
+ const placeholderKeys = React.useMemo(() => placeholders.map((p) => p.key).sort(), [placeholders]);
94
+ const client = useAdminStore((s) => s.client);
187
95
  const queryEnabled = enabled && placeholders.length > 0 && !!client;
188
- let t13;
189
- if ($[24] !== depHash || $[25] !== entity || $[26] !== entityType || $[27] !== field || $[28] !== placeholderKeys) {
190
- t13 = [
96
+ const query = useQuery({
97
+ queryKey: [
191
98
  "questpie",
192
99
  "reactive-props",
193
100
  entityType,
@@ -195,31 +102,19 @@ function useReactiveProps(t0) {
195
102
  field,
196
103
  placeholderKeys,
197
104
  depHash
198
- ];
199
- $[24] = depHash;
200
- $[25] = entity;
201
- $[26] = entityType;
202
- $[27] = field;
203
- $[28] = placeholderKeys;
204
- $[29] = t13;
205
- } else t13 = $[29];
206
- let t14;
207
- if ($[30] !== client || $[31] !== entity || $[32] !== entityType || $[33] !== field || $[34] !== formContext || $[35] !== placeholders) {
208
- t14 = async () => {
105
+ ],
106
+ queryFn: async () => {
209
107
  if (!client || placeholders.length === 0) return {};
210
108
  const formData = formContext?.getValues?.() ?? {};
211
109
  const response = await client.routes.batchReactive({
212
110
  collection: entity,
213
111
  type: entityType,
214
112
  formData,
215
- requests: placeholders.map((t15$1) => {
216
- const { key: key_0 } = t15$1;
217
- return {
218
- field,
219
- type: "prop",
220
- propPath: key_0
221
- };
222
- })
113
+ requests: placeholders.map(({ key }) => ({
114
+ field,
115
+ type: "prop",
116
+ propPath: key
117
+ }))
223
118
  });
224
119
  const out = {};
225
120
  for (const r of response.results) {
@@ -228,80 +123,27 @@ function useReactiveProps(t0) {
228
123
  out[r.propPath] = r.value;
229
124
  }
230
125
  return out;
231
- };
232
- $[30] = client;
233
- $[31] = entity;
234
- $[32] = entityType;
235
- $[33] = field;
236
- $[34] = formContext;
237
- $[35] = placeholders;
238
- $[36] = t14;
239
- } else t14 = $[36];
240
- let t15;
241
- if ($[37] !== queryEnabled || $[38] !== t13 || $[39] !== t14) {
242
- t15 = {
243
- queryKey: t13,
244
- queryFn: t14,
245
- enabled: queryEnabled,
246
- placeholderData: _temp3,
247
- staleTime: 3e4
248
- };
249
- $[37] = queryEnabled;
250
- $[38] = t13;
251
- $[39] = t14;
252
- $[40] = t15;
253
- } else t15 = $[40];
254
- const query = useQuery(t15);
255
- let t16;
256
- bb1: {
257
- if (placeholders.length === 0) {
258
- t16 = staticProps;
259
- break bb1;
260
- }
261
- let out_0;
262
- if ($[41] !== placeholders || $[42] !== query.data || $[43] !== staticProps) {
263
- out_0 = { ...staticProps };
264
- let t17$1;
265
- if ($[45] !== query.data) {
266
- t17$1 = query.data ?? {};
267
- $[45] = query.data;
268
- $[46] = t17$1;
269
- } else t17$1 = $[46];
270
- const resolved = t17$1;
271
- for (const { key: key_1 } of placeholders) out_0[key_1] = resolved[key_1];
272
- $[41] = placeholders;
273
- $[42] = query.data;
274
- $[43] = staticProps;
275
- $[44] = out_0;
276
- } else out_0 = $[44];
277
- t16 = out_0;
278
- }
279
- const merged = t16;
280
- const t17 = query.error ?? null;
281
- let t18;
282
- if ($[47] !== merged || $[48] !== query.isFetching || $[49] !== query.isLoading || $[50] !== t17) {
283
- t18 = {
284
- props: merged,
285
- isLoading: query.isLoading,
286
- isFetching: query.isFetching,
287
- error: t17
288
- };
289
- $[47] = merged;
290
- $[48] = query.isFetching;
291
- $[49] = query.isLoading;
292
- $[50] = t17;
293
- $[51] = t18;
294
- } else t18 = $[51];
295
- return t18;
296
- }
297
- function _temp3(prev) {
298
- return prev;
299
- }
300
- function _temp2(s) {
301
- return s.client;
302
- }
303
- function _temp(p) {
304
- return p.key;
126
+ },
127
+ enabled: queryEnabled,
128
+ placeholderData: (prev) => prev,
129
+ staleTime: 3e4
130
+ });
131
+ return {
132
+ props: React.useMemo(() => {
133
+ if (placeholders.length === 0) return staticProps;
134
+ const out = { ...staticProps };
135
+ const resolved = query.data ?? {};
136
+ for (const { key } of placeholders) out[key] = resolved[key];
137
+ return out;
138
+ }, [
139
+ staticProps,
140
+ placeholders,
141
+ query.data
142
+ ]),
143
+ isLoading: query.isLoading,
144
+ isFetching: query.isFetching,
145
+ error: query.error ?? null
146
+ };
305
147
  }
306
148
 
307
149
  //#endregion
@@ -1,4 +1,3 @@
1
- import { c } from "react/compiler-runtime";
2
1
  import { useEffect, useRef, useState } from "react";
3
2
 
4
3
  //#region src/client/hooks/use-realtime-highlight.ts
@@ -22,128 +21,66 @@ import { useEffect, useRef, useState } from "react";
22
21
  * ))}
23
22
  * ```
24
23
  */
25
- function useRealtimeHighlight(docs, t0) {
26
- const $ = c(18);
27
- let t1;
28
- if ($[0] !== t0) {
29
- t1 = t0 === void 0 ? {} : t0;
30
- $[0] = t0;
31
- $[1] = t1;
32
- } else t1 = $[1];
33
- const { highlightDuration: t2, enabled: t3, initializationGracePeriod: t4 } = t1;
34
- const highlightDuration = t2 === void 0 ? 1500 : t2;
35
- const enabled = t3 === void 0 ? true : t3;
36
- const initializationGracePeriod = t4 === void 0 ? 500 : t4;
37
- let t5;
38
- if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
39
- t5 = /* @__PURE__ */ new Set();
40
- $[2] = t5;
41
- } else t5 = $[2];
42
- const [highlightedIds, setHighlightedIds] = useState(t5);
43
- let t6;
44
- if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
45
- t6 = /* @__PURE__ */ new Map();
46
- $[3] = t6;
47
- } else t6 = $[3];
48
- const prevDocsRef = useRef(t6);
24
+ function useRealtimeHighlight(docs, options = {}) {
25
+ const { highlightDuration = 1500, enabled = true, initializationGracePeriod = 500 } = options;
26
+ const [highlightedIds, setHighlightedIds] = useState(/* @__PURE__ */ new Set());
27
+ const prevDocsRef = useRef(/* @__PURE__ */ new Map());
49
28
  const hasInitializedRef = useRef(false);
50
29
  const initializedAtRef = useRef(0);
51
- let t7;
52
- if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
53
- t7 = /* @__PURE__ */ new Set();
54
- $[4] = t7;
55
- } else t7 = $[4];
56
- const timersRef = useRef(t7);
57
- let t8;
58
- let t9;
59
- if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
60
- t8 = () => () => {
30
+ const timersRef = useRef(/* @__PURE__ */ new Set());
31
+ useEffect(() => {
32
+ return () => {
61
33
  for (const timer of timersRef.current) clearTimeout(timer);
62
34
  };
63
- t9 = [];
64
- $[5] = t8;
65
- $[6] = t9;
66
- } else {
67
- t8 = $[5];
68
- t9 = $[6];
69
- }
70
- useEffect(t8, t9);
71
- let t10;
72
- let t11;
73
- if ($[7] !== docs || $[8] !== enabled || $[9] !== highlightDuration || $[10] !== initializationGracePeriod) {
74
- t10 = () => {
75
- if (!enabled || !docs) return;
76
- const currentMap = /* @__PURE__ */ new Map();
77
- for (const doc of docs) currentMap.set(doc.id, getDocFingerprint(doc));
78
- if (!hasInitializedRef.current) {
79
- hasInitializedRef.current = true;
80
- initializedAtRef.current = Date.now();
81
- prevDocsRef.current = currentMap;
82
- return;
83
- }
84
- if (Date.now() - initializedAtRef.current < initializationGracePeriod) {
85
- prevDocsRef.current = currentMap;
86
- return;
87
- }
88
- const changedIds = [];
89
- for (const doc_0 of docs) {
90
- const prevFingerprint = prevDocsRef.current.get(doc_0.id);
91
- const currentFingerprint = currentMap.get(doc_0.id);
92
- if (!prevFingerprint) changedIds.push(doc_0.id);
93
- else if (prevFingerprint !== currentFingerprint) changedIds.push(doc_0.id);
94
- }
35
+ }, []);
36
+ useEffect(() => {
37
+ if (!enabled || !docs) return;
38
+ const currentMap = /* @__PURE__ */ new Map();
39
+ for (const doc of docs) currentMap.set(doc.id, getDocFingerprint(doc));
40
+ if (!hasInitializedRef.current) {
41
+ hasInitializedRef.current = true;
42
+ initializedAtRef.current = Date.now();
95
43
  prevDocsRef.current = currentMap;
96
- if (changedIds.length > 0) {
44
+ return;
45
+ }
46
+ if (Date.now() - initializedAtRef.current < initializationGracePeriod) {
47
+ prevDocsRef.current = currentMap;
48
+ return;
49
+ }
50
+ const changedIds = [];
51
+ for (const doc of docs) {
52
+ const prevFingerprint = prevDocsRef.current.get(doc.id);
53
+ const currentFingerprint = currentMap.get(doc.id);
54
+ if (!prevFingerprint) changedIds.push(doc.id);
55
+ else if (prevFingerprint !== currentFingerprint) changedIds.push(doc.id);
56
+ }
57
+ prevDocsRef.current = currentMap;
58
+ if (changedIds.length > 0) {
59
+ setHighlightedIds((prev) => {
60
+ const next = new Set(prev);
61
+ for (const id of changedIds) next.add(id);
62
+ return next;
63
+ });
64
+ const timer = setTimeout(() => {
97
65
  setHighlightedIds((prev) => {
98
66
  const next = new Set(prev);
99
- for (const id of changedIds) next.add(id);
67
+ for (const id of changedIds) next.delete(id);
100
68
  return next;
101
69
  });
102
- const timer_0 = setTimeout(() => {
103
- setHighlightedIds((prev_0) => {
104
- const next_0 = new Set(prev_0);
105
- for (const id_0 of changedIds) next_0.delete(id_0);
106
- return next_0;
107
- });
108
- timersRef.current.delete(timer_0);
109
- }, highlightDuration);
110
- timersRef.current.add(timer_0);
111
- }
112
- };
113
- t11 = [
114
- docs,
115
- enabled,
116
- highlightDuration,
117
- initializationGracePeriod
118
- ];
119
- $[7] = docs;
120
- $[8] = enabled;
121
- $[9] = highlightDuration;
122
- $[10] = initializationGracePeriod;
123
- $[11] = t10;
124
- $[12] = t11;
125
- } else {
126
- t10 = $[11];
127
- t11 = $[12];
128
- }
129
- useEffect(t10, t11);
130
- let t12;
131
- if ($[13] !== highlightedIds) {
132
- t12 = (id_1) => highlightedIds.has(id_1);
133
- $[13] = highlightedIds;
134
- $[14] = t12;
135
- } else t12 = $[14];
136
- let t13;
137
- if ($[15] !== highlightedIds || $[16] !== t12) {
138
- t13 = {
139
- highlightedIds,
140
- isHighlighted: t12
141
- };
142
- $[15] = highlightedIds;
143
- $[16] = t12;
144
- $[17] = t13;
145
- } else t13 = $[17];
146
- return t13;
70
+ timersRef.current.delete(timer);
71
+ }, highlightDuration);
72
+ timersRef.current.add(timer);
73
+ }
74
+ }, [
75
+ docs,
76
+ enabled,
77
+ highlightDuration,
78
+ initializationGracePeriod
79
+ ]);
80
+ return {
81
+ highlightedIds,
82
+ isHighlighted: (id) => highlightedIds.has(id)
83
+ };
147
84
  }
148
85
  /**
149
86
  * Create a fingerprint for a doc to detect changes
@@ -1,5 +1,4 @@
1
1
  import { useAdminStore } from "../runtime/provider.mjs";
2
- import { c } from "react/compiler-runtime";
3
2
  import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
4
3
 
5
4
  //#region src/client/hooks/use-saved-views.ts
@@ -10,22 +9,14 @@ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
10
9
  * If admin_saved_views collection is not available, returns empty array.
11
10
  */
12
11
  function useSavedViews(collectionName, userId) {
13
- const $ = c(11);
14
- const client = useAdminStore(_temp);
15
- let t0;
16
- if ($[0] !== collectionName || $[1] !== userId) {
17
- t0 = [
12
+ const client = useAdminStore((s) => s.client);
13
+ return useQuery({
14
+ queryKey: [
18
15
  "admin_saved_views",
19
16
  collectionName,
20
17
  userId
21
- ];
22
- $[0] = collectionName;
23
- $[1] = userId;
24
- $[2] = t0;
25
- } else t0 = $[2];
26
- let t1;
27
- if ($[3] !== client?.collections || $[4] !== collectionName || $[5] !== userId) {
28
- t1 = async () => {
18
+ ],
19
+ queryFn: async () => {
29
20
  const collections = client?.collections;
30
21
  if (!collections?.admin_saved_views) return { docs: [] };
31
22
  const where = userId ? {
@@ -33,40 +24,18 @@ function useSavedViews(collectionName, userId) {
33
24
  userId
34
25
  } : { collectionName };
35
26
  return { docs: (await collections.admin_saved_views.find({ where }))?.docs ?? [] };
36
- };
37
- $[3] = client?.collections;
38
- $[4] = collectionName;
39
- $[5] = userId;
40
- $[6] = t1;
41
- } else t1 = $[6];
42
- const t2 = !!client;
43
- let t3;
44
- if ($[7] !== t0 || $[8] !== t1 || $[9] !== t2) {
45
- t3 = {
46
- queryKey: t0,
47
- queryFn: t1,
48
- enabled: t2
49
- };
50
- $[7] = t0;
51
- $[8] = t1;
52
- $[9] = t2;
53
- $[10] = t3;
54
- } else t3 = $[10];
55
- return useQuery(t3);
27
+ },
28
+ enabled: !!client
29
+ });
56
30
  }
57
31
  /**
58
32
  * Hook to save a new view
59
33
  */
60
- function _temp(s) {
61
- return s.client;
62
- }
63
34
  function useSaveView(collectionName, userId) {
64
- const $ = c(11);
65
- const client = useAdminStore(_temp2);
35
+ const client = useAdminStore((s) => s.client);
66
36
  const queryClient = useQueryClient();
67
- let t0;
68
- if ($[0] !== client?.collections || $[1] !== collectionName || $[2] !== userId) {
69
- t0 = async (data) => {
37
+ return useMutation({
38
+ mutationFn: async (data) => {
70
39
  const collections = client?.collections;
71
40
  if (!collections?.admin_saved_views) throw new Error("admin_saved_views collection not available. Make sure to use the adminModule in your app setup.");
72
41
  return collections.admin_saved_views.create({
@@ -75,86 +44,36 @@ function useSaveView(collectionName, userId) {
75
44
  userId: data.userId || userId || "anonymous",
76
45
  isDefault: false
77
46
  });
78
- };
79
- $[0] = client?.collections;
80
- $[1] = collectionName;
81
- $[2] = userId;
82
- $[3] = t0;
83
- } else t0 = $[3];
84
- let t1;
85
- if ($[4] !== collectionName || $[5] !== queryClient || $[6] !== userId) {
86
- t1 = () => {
47
+ },
48
+ onSuccess: () => {
87
49
  queryClient.invalidateQueries({ queryKey: [
88
50
  "admin_saved_views",
89
51
  collectionName,
90
52
  userId
91
53
  ] });
92
- };
93
- $[4] = collectionName;
94
- $[5] = queryClient;
95
- $[6] = userId;
96
- $[7] = t1;
97
- } else t1 = $[7];
98
- let t2;
99
- if ($[8] !== t0 || $[9] !== t1) {
100
- t2 = {
101
- mutationFn: t0,
102
- onSuccess: t1
103
- };
104
- $[8] = t0;
105
- $[9] = t1;
106
- $[10] = t2;
107
- } else t2 = $[10];
108
- return useMutation(t2);
54
+ }
55
+ });
109
56
  }
110
57
  /**
111
58
  * Hook to delete a view
112
59
  */
113
- function _temp2(s) {
114
- return s.client;
115
- }
116
60
  function useDeleteSavedView(collectionName, userId) {
117
- const $ = c(9);
118
- const client = useAdminStore(_temp3);
61
+ const client = useAdminStore((s) => s.client);
119
62
  const queryClient = useQueryClient();
120
- let t0;
121
- if ($[0] !== client?.collections) {
122
- t0 = async (viewId) => {
63
+ return useMutation({
64
+ mutationFn: async (viewId) => {
123
65
  const collections = client?.collections;
124
66
  if (!collections?.admin_saved_views) throw new Error("admin_saved_views collection not available. Make sure to use the adminModule in your app setup.");
125
67
  return collections.admin_saved_views.delete({ id: viewId });
126
- };
127
- $[0] = client?.collections;
128
- $[1] = t0;
129
- } else t0 = $[1];
130
- let t1;
131
- if ($[2] !== collectionName || $[3] !== queryClient || $[4] !== userId) {
132
- t1 = () => {
68
+ },
69
+ onSuccess: () => {
133
70
  queryClient.invalidateQueries({ queryKey: [
134
71
  "admin_saved_views",
135
72
  collectionName,
136
73
  userId
137
74
  ] });
138
- };
139
- $[2] = collectionName;
140
- $[3] = queryClient;
141
- $[4] = userId;
142
- $[5] = t1;
143
- } else t1 = $[5];
144
- let t2;
145
- if ($[6] !== t0 || $[7] !== t1) {
146
- t2 = {
147
- mutationFn: t0,
148
- onSuccess: t1
149
- };
150
- $[6] = t0;
151
- $[7] = t1;
152
- $[8] = t2;
153
- } else t2 = $[8];
154
- return useMutation(t2);
155
- }
156
- function _temp3(s) {
157
- return s.client;
75
+ }
76
+ });
158
77
  }
159
78
 
160
79
  //#endregion