@questpie/admin 3.2.4 → 3.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/blocks/block-renderer.d.mts +2 -2
- package/dist/client/blocks/block-renderer.mjs +164 -339
- package/dist/client/components/actions/action-button.mjs +9 -9
- package/dist/client/components/actions/action-dialog.mjs +195 -493
- package/dist/client/components/actions/confirmation-dialog.mjs +44 -159
- package/dist/client/components/actions/header-actions.mjs +73 -165
- package/dist/client/components/admin-link.d.mts +2 -2
- package/dist/client/components/admin-link.mjs +40 -126
- package/dist/client/components/auth/auth-loading.mjs +9 -44
- package/dist/client/components/blocks/block-canvas.mjs +31 -95
- package/dist/client/components/blocks/block-editor-context.mjs +13 -57
- package/dist/client/components/blocks/block-editor-layout.mjs +72 -166
- package/dist/client/components/blocks/block-editor-provider.mjs +184 -245
- package/dist/client/components/blocks/block-fields-renderer.mjs +54 -229
- package/dist/client/components/blocks/block-insert-button.mjs +49 -165
- package/dist/client/components/blocks/block-item-menu.mjs +102 -301
- package/dist/client/components/blocks/block-item.mjs +136 -370
- package/dist/client/components/blocks/block-library-sidebar.mjs +103 -230
- package/dist/client/components/blocks/block-tree.mjs +12 -68
- package/dist/client/components/blocks/block-type-icon.mjs +14 -56
- package/dist/client/components/brand-logo.mjs +35 -149
- package/dist/client/components/component-renderer.mjs +42 -118
- package/dist/client/components/error-boundary.mjs +14 -58
- package/dist/client/components/fields/array-field.mjs +209 -521
- package/dist/client/components/fields/asset-preview-field.mjs +41 -141
- package/dist/client/components/fields/blocks-field/blocks-field.mjs +60 -156
- package/dist/client/components/fields/boolean-field.mjs +29 -59
- package/dist/client/components/fields/date-field.mjs +7 -37
- package/dist/client/components/fields/datetime-field.mjs +7 -38
- package/dist/client/components/fields/email-field.mjs +25 -54
- package/dist/client/components/fields/field-wrapper.mjs +30 -105
- package/dist/client/components/fields/json-field.mjs +94 -296
- package/dist/client/components/fields/locale-badge.mjs +6 -15
- package/dist/client/components/fields/number-field.mjs +27 -60
- package/dist/client/components/fields/object-array-field.mjs +283 -659
- package/dist/client/components/fields/object-field.mjs +165 -633
- package/dist/client/components/fields/relation/displays/cards-display.mjs +106 -220
- package/dist/client/components/fields/relation/displays/chips-display.mjs +78 -150
- package/dist/client/components/fields/relation/displays/grid-display.mjs +92 -186
- package/dist/client/components/fields/relation/displays/list-display.mjs +122 -239
- package/dist/client/components/fields/relation/displays/table-display.mjs +70 -244
- package/dist/client/components/fields/relation/relation-items-display.mjs +30 -126
- package/dist/client/components/fields/relation-field.mjs +10 -66
- package/dist/client/components/fields/relation-picker.mjs +18 -18
- package/dist/client/components/fields/relation-select.mjs +12 -12
- package/dist/client/components/fields/rich-text-editor/bubble-menu.mjs +80 -180
- package/dist/client/components/fields/rich-text-editor/image-popover.mjs +2 -2
- package/dist/client/components/fields/rich-text-editor/image-upload.mjs +13 -29
- package/dist/client/components/fields/rich-text-editor/index.mjs +195 -513
- package/dist/client/components/fields/rich-text-editor/slash-commands.mjs +61 -111
- package/dist/client/components/fields/rich-text-editor/table-controls.mjs +105 -415
- package/dist/client/components/fields/rich-text-editor/toolbar.mjs +256 -511
- package/dist/client/components/fields/rich-text-field.mjs +14 -53
- package/dist/client/components/fields/select-field.mjs +61 -72
- package/dist/client/components/fields/text-field.mjs +26 -59
- package/dist/client/components/fields/textarea-field.mjs +26 -58
- package/dist/client/components/fields/time-field.mjs +7 -35
- package/dist/client/components/fields/upload-field.mjs +47 -165
- package/dist/client/components/filter-builder/columns-tab.mjs +80 -280
- package/dist/client/components/filter-builder/filter-builder-sheet.mjs +197 -540
- package/dist/client/components/filter-builder/filters-tab.mjs +96 -386
- package/dist/client/components/filter-builder/saved-views-tab.mjs +133 -351
- package/dist/client/components/history-sidebar.mjs +285 -605
- package/dist/client/components/layout/field-layout-renderer.mjs +106 -254
- package/dist/client/components/locale-switcher.mjs +106 -228
- package/dist/client/components/media/media-grid.mjs +84 -273
- package/dist/client/components/media/media-picker-dialog.mjs +176 -476
- package/dist/client/components/preview/live-preview-mode.mjs +233 -458
- package/dist/client/components/preview/preview-pane.mjs +22 -22
- package/dist/client/components/primitives/asset-preview.mjs +290 -666
- package/dist/client/components/primitives/checkbox-input.mjs +9 -35
- package/dist/client/components/primitives/date-input.mjs +109 -327
- package/dist/client/components/primitives/dropzone.mjs +209 -336
- package/dist/client/components/primitives/field-select-control.mjs +12 -80
- package/dist/client/components/primitives/number-input.mjs +4 -4
- package/dist/client/components/primitives/select-multi.mjs +229 -572
- package/dist/client/components/primitives/select-single.mjs +179 -499
- package/dist/client/components/primitives/time-input.mjs +43 -117
- package/dist/client/components/primitives/toggle-input.mjs +9 -29
- package/dist/client/components/sheets/resource-sheet.mjs +61 -70
- package/dist/client/components/ui/accordion.mjs +35 -155
- package/dist/client/components/ui/alert.mjs +13 -68
- package/dist/client/components/ui/badge.mjs +9 -51
- package/dist/client/components/ui/button.mjs +8 -54
- package/dist/client/components/ui/card.mjs +37 -193
- package/dist/client/components/ui/checkbox.mjs +12 -68
- package/dist/client/components/ui/command.mjs +48 -219
- package/dist/client/components/ui/dialog.mjs +50 -262
- package/dist/client/components/ui/drawer.mjs +55 -259
- package/dist/client/components/ui/dropdown-menu.mjs +86 -427
- package/dist/client/components/ui/empty-state.mjs +28 -98
- package/dist/client/components/ui/field.mjs +73 -309
- package/dist/client/components/ui/input-group.mjs +42 -167
- package/dist/client/components/ui/input.mjs +7 -37
- package/dist/client/components/ui/kbd.mjs +6 -36
- package/dist/client/components/ui/label.mjs +7 -37
- package/dist/client/components/ui/popover.mjs +34 -169
- package/dist/client/components/ui/responsive-dialog.mjs +67 -273
- package/dist/client/components/ui/scroll-fade.mjs +63 -158
- package/dist/client/components/ui/search-input.mjs +33 -100
- package/dist/client/components/ui/select.mjs +72 -393
- package/dist/client/components/ui/separator.mjs +7 -38
- package/dist/client/components/ui/sheet.mjs +49 -269
- package/dist/client/components/ui/sidebar.mjs +171 -690
- package/dist/client/components/ui/skeleton.mjs +7 -38
- package/dist/client/components/ui/sonner.mjs +11 -42
- package/dist/client/components/ui/switch.mjs +9 -45
- package/dist/client/components/ui/table.mjs +48 -266
- package/dist/client/components/ui/tabs.mjs +26 -139
- package/dist/client/components/ui/textarea.mjs +6 -32
- package/dist/client/components/ui/tooltip.mjs +27 -129
- package/dist/client/components/widgets/chart-widget.mjs +174 -522
- package/dist/client/components/widgets/progress-widget.mjs +66 -172
- package/dist/client/components/widgets/quick-actions-widget.mjs +102 -261
- package/dist/client/components/widgets/recent-items-widget.mjs +69 -195
- package/dist/client/components/widgets/stats-widget.mjs +41 -175
- package/dist/client/components/widgets/table-widget.mjs +9 -9
- package/dist/client/components/widgets/timeline-widget.mjs +86 -226
- package/dist/client/components/widgets/value-widget.mjs +74 -381
- package/dist/client/components/widgets/widget-empty-state.mjs +26 -76
- package/dist/client/components/widgets/widget-skeletons.mjs +138 -421
- package/dist/client/contexts/focus-context.mjs +63 -146
- package/dist/client/hooks/typed-hooks.mjs +241 -701
- package/dist/client/hooks/use-action.mjs +62 -198
- package/dist/client/hooks/use-admin-config.mjs +5 -35
- package/dist/client/hooks/use-admin-preferences.mjs +16 -88
- package/dist/client/hooks/use-admin-routes.mjs +22 -56
- package/dist/client/hooks/use-audit-history.mjs +21 -69
- package/dist/client/hooks/use-brand.mjs +1 -9
- package/dist/client/hooks/use-collection-fields.mjs +17 -57
- package/dist/client/hooks/use-collection-meta.mjs +12 -44
- package/dist/client/hooks/use-collection-schema.mjs +10 -33
- package/dist/client/hooks/use-collection-validation.mjs +23 -53
- package/dist/client/hooks/use-collection.mjs +194 -614
- package/dist/client/hooks/use-current-user.mjs +0 -1
- package/dist/client/hooks/use-field-hooks.mjs +10 -10
- package/dist/client/hooks/use-field-options.mjs +61 -202
- package/dist/client/hooks/use-global-fields.mjs +14 -46
- package/dist/client/hooks/use-global-meta.mjs +9 -30
- package/dist/client/hooks/use-global-schema.mjs +9 -30
- package/dist/client/hooks/use-global.mjs +63 -219
- package/dist/client/hooks/use-locks.mjs +117 -325
- package/dist/client/hooks/use-media-query.mjs +16 -36
- package/dist/client/hooks/use-prefill-params.mjs +0 -1
- package/dist/client/hooks/use-questpie-query-options.mjs +12 -29
- package/dist/client/hooks/use-reactive-fields.mjs +1 -1
- package/dist/client/hooks/use-reactive-prop.mjs +65 -223
- package/dist/client/hooks/use-realtime-highlight.mjs +51 -114
- package/dist/client/hooks/use-saved-views.mjs +22 -103
- package/dist/client/hooks/use-search-param-toggle.mjs +28 -79
- package/dist/client/hooks/use-search.mjs +31 -143
- package/dist/client/hooks/use-server-actions.mjs +18 -50
- package/dist/client/hooks/use-server-validation.mjs +72 -166
- package/dist/client/hooks/use-server-widget-data.mjs +7 -33
- package/dist/client/hooks/use-setup-status.mjs +12 -25
- package/dist/client/hooks/use-sidebar-search-param.mjs +33 -78
- package/dist/client/hooks/use-transition-stage.mjs +8 -38
- package/dist/client/hooks/use-upload.mjs +54 -152
- package/dist/client/hooks/use-validation-error-map.mjs +6 -26
- package/dist/client/hooks/use-view-state.mjs +187 -437
- package/dist/client/i18n/hooks.mjs +65 -197
- package/dist/client/lib/render-profiler.mjs +14 -41
- package/dist/client/preview/block-scope-context.mjs +14 -36
- package/dist/client/preview/preview-banner.d.mts +2 -2
- package/dist/client/preview/preview-banner.mjs +42 -108
- package/dist/client/preview/preview-field.d.mts +4 -4
- package/dist/client/preview/preview-field.mjs +167 -348
- package/dist/client/preview/use-collection-preview.mjs +121 -215
- package/dist/client/runtime/content-locales-provider.mjs +31 -83
- package/dist/client/runtime/locale-scope.mjs +22 -63
- package/dist/client/runtime/provider.mjs +100 -255
- package/dist/client/runtime/translations-provider.mjs +41 -107
- package/dist/client/scope/picker.mjs +86 -321
- package/dist/client/scope/provider.mjs +8 -17
- package/dist/client/utils/build-field-definitions-from-schema.mjs +4 -2
- package/dist/client/views/auth/accept-invite-form.d.mts +2 -2
- package/dist/client/views/auth/accept-invite-form.mjs +121 -412
- package/dist/client/views/auth/auth-layout.d.mts +3 -3
- package/dist/client/views/auth/auth-layout.mjs +104 -284
- package/dist/client/views/auth/forgot-password-form.d.mts +2 -2
- package/dist/client/views/auth/forgot-password-form.mjs +94 -325
- package/dist/client/views/auth/invite-form.mjs +107 -442
- package/dist/client/views/auth/login-form.d.mts +2 -2
- package/dist/client/views/auth/login-form.mjs +116 -337
- package/dist/client/views/auth/reset-password-form.d.mts +2 -2
- package/dist/client/views/auth/reset-password-form.mjs +128 -453
- package/dist/client/views/auth/setup-form.d.mts +2 -2
- package/dist/client/views/auth/setup-form.mjs +140 -478
- package/dist/client/views/collection/auto-form-fields.mjs +243 -615
- package/dist/client/views/collection/bulk-action-toolbar.mjs +212 -379
- package/dist/client/views/collection/cells/complex-cells.mjs +183 -611
- package/dist/client/views/collection/cells/primitive-cells.mjs +116 -356
- package/dist/client/views/collection/cells/relation-cells.mjs +86 -233
- package/dist/client/views/collection/cells/shared/asset-thumbnail.mjs +142 -371
- package/dist/client/views/collection/cells/shared/relation-chip.mjs +35 -131
- package/dist/client/views/collection/cells/upload-cells.mjs +60 -177
- package/dist/client/views/collection/columns/build-columns.mjs +8 -48
- package/dist/client/views/collection/field-renderer.mjs +58 -182
- package/dist/client/views/collection/form-view.mjs +284 -518
- package/dist/client/views/collection/table-view.mjs +231 -463
- package/dist/client/views/collection/view-skeletons.mjs +112 -237
- package/dist/client/views/common/global-search.mjs +241 -560
- package/dist/client/views/dashboard/dashboard-grid.mjs +256 -775
- package/dist/client/views/dashboard/dashboard-widget.mjs +38 -126
- package/dist/client/views/dashboard/widget-card.mjs +61 -269
- package/dist/client/views/globals/global-form-view.mjs +477 -1301
- package/dist/client/views/layout/admin-layout-provider.mjs +28 -88
- package/dist/client/views/layout/admin-layout.mjs +83 -246
- package/dist/client/views/layout/admin-router.mjs +458 -1274
- package/dist/client/views/layout/admin-sidebar.mjs +510 -1292
- package/dist/client/views/layout/admin-theme.mjs +30 -64
- package/dist/client/views/layout/admin-view-layout.mjs +40 -144
- package/dist/client/views/pages/accept-invite-page.d.mts +2 -2
- package/dist/client/views/pages/accept-invite-page.mjs +95 -290
- package/dist/client/views/pages/dashboard-page.d.mts +2 -2
- package/dist/client/views/pages/dashboard-page.mjs +11 -57
- package/dist/client/views/pages/forgot-password-page.d.mts +2 -2
- package/dist/client/views/pages/forgot-password-page.mjs +31 -83
- package/dist/client/views/pages/invite-page.d.mts +2 -2
- package/dist/client/views/pages/invite-page.mjs +35 -90
- package/dist/client/views/pages/login-page.d.mts +2 -2
- package/dist/client/views/pages/login-page.mjs +41 -121
- package/dist/client/views/pages/reset-password-page.d.mts +2 -2
- package/dist/client/views/pages/reset-password-page.mjs +46 -173
- package/dist/client/views/pages/setup-page.d.mts +2 -2
- package/dist/client/views/pages/setup-page.mjs +33 -95
- package/dist/components/rich-text/rich-text-renderer.mjs +9 -33
- package/dist/server/adapters/index.d.mts +2 -0
- package/dist/server/adapters/nextjs.d.mts +1 -0
- package/dist/server/auth-helpers.d.mts +1 -0
- package/dist/server/modules/admin/.generated/module.d.mts +1 -0
- package/dist/server/modules/admin/collections/account.d.mts +46 -46
- package/dist/server/modules/admin/collections/admin-locks.d.mts +50 -50
- package/dist/server/modules/admin/collections/admin-preferences.d.mts +39 -39
- package/dist/server/modules/admin/collections/admin-saved-views.d.mts +47 -47
- package/dist/server/modules/admin/collections/apikey.d.mts +68 -68
- package/dist/server/modules/admin/collections/assets.d.mts +39 -39
- package/dist/server/modules/admin/collections/session.d.mts +42 -42
- package/dist/server/modules/admin/collections/user.d.mts +62 -62
- package/dist/server/modules/admin/collections/verification.d.mts +23 -23
- package/dist/server/modules/admin/index.d.mts +20 -19
- package/dist/server/modules/admin/routes/admin-config.d.mts +2 -2
- package/dist/server/modules/admin/routes/execute-action.d.mts +9 -9
- package/dist/server/modules/admin/routes/locales.d.mts +2 -2
- package/dist/server/modules/admin/routes/preview.d.mts +11 -11
- package/dist/server/modules/admin/routes/reactive.d.mts +9 -9
- package/dist/server/modules/admin/routes/setup.d.mts +7 -7
- package/dist/server/modules/admin/routes/translations.d.mts +4 -4
- package/dist/server/modules/admin/routes/widget-data.d.mts +5 -5
- package/dist/server/modules/admin-preferences/collections/saved-views.d.mts +45 -45
- package/dist/server/modules/audit/.generated/module.d.mts +6 -6
- package/dist/server/modules/audit/collections/audit-log.d.mts +78 -78
- package/dist/server/modules/audit/jobs/audit-cleanup.d.mts +2 -2
- package/dist/server.d.mts +2 -0
- 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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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(
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
-
|
|
93
|
-
|
|
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:
|
|
72
|
+
watchUnion: [...watchSet],
|
|
116
73
|
debounceMax: dbMax
|
|
117
74
|
};
|
|
118
|
-
|
|
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
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
const
|
|
143
|
-
|
|
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
|
-
|
|
189
|
-
|
|
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
|
-
|
|
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((
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
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
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
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,
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
-
|
|
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.
|
|
67
|
+
for (const id of changedIds) next.delete(id);
|
|
100
68
|
return next;
|
|
101
69
|
});
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
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
|
-
|
|
38
|
-
|
|
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
|
|
65
|
-
const client = useAdminStore(_temp2);
|
|
35
|
+
const client = useAdminStore((s) => s.client);
|
|
66
36
|
const queryClient = useQueryClient();
|
|
67
|
-
|
|
68
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
118
|
-
const client = useAdminStore(_temp3);
|
|
61
|
+
const client = useAdminStore((s) => s.client);
|
|
119
62
|
const queryClient = useQueryClient();
|
|
120
|
-
|
|
121
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|