@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
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import { useTranslation } from "../i18n/hooks.mjs";
|
|
4
4
|
import { selectBasePath, selectClient, selectContentLocale, selectNavigate, useAdminStore } from "../runtime/provider.mjs";
|
|
5
5
|
import { getDefaultActionsConfig } from "../builder/types/action-registry.mjs";
|
|
6
|
-
import { c } from "react/compiler-runtime";
|
|
7
6
|
import * as React from "react";
|
|
8
7
|
import { useQueryClient } from "@tanstack/react-query";
|
|
9
8
|
import { toast } from "sonner";
|
|
@@ -34,40 +33,27 @@ const QUERY_KEY_PREFIX = ["questpie", "collections"];
|
|
|
34
33
|
* );
|
|
35
34
|
* ```
|
|
36
35
|
*/
|
|
37
|
-
function useActionHelpers(
|
|
38
|
-
const $ = c(34);
|
|
39
|
-
const { collection, onRefresh } = t0;
|
|
36
|
+
function useActionHelpers({ collection, onRefresh }) {
|
|
40
37
|
const basePath = useAdminStore(selectBasePath);
|
|
41
38
|
const navigate = useAdminStore(selectNavigate);
|
|
42
39
|
const client = useAdminStore(selectClient);
|
|
43
40
|
const contentLocale = useAdminStore(selectContentLocale);
|
|
44
41
|
const queryClient = useQueryClient();
|
|
45
42
|
const { t } = useTranslation();
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
$[0] = contentLocale;
|
|
54
|
-
$[1] = t1;
|
|
55
|
-
$[2] = t2;
|
|
56
|
-
} else t2 = $[2];
|
|
57
|
-
const queryOpts = t2;
|
|
58
|
-
let t3;
|
|
59
|
-
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
|
60
|
-
t3 = {
|
|
43
|
+
const queryOpts = React.useMemo(() => createQuestpieQueryOptions(client, {
|
|
44
|
+
keyPrefix: QUERY_KEY_PREFIX,
|
|
45
|
+
locale: contentLocale
|
|
46
|
+
}), [client, contentLocale]);
|
|
47
|
+
return { helpers: React.useMemo(() => ({
|
|
48
|
+
navigate,
|
|
49
|
+
toast: {
|
|
61
50
|
success: toast.success,
|
|
62
51
|
error: toast.error,
|
|
63
52
|
info: toast.info,
|
|
64
53
|
warning: toast.warning
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
let t4;
|
|
69
|
-
if ($[4] !== collection || $[5] !== contentLocale || $[6] !== onRefresh || $[7] !== queryClient || $[8] !== queryOpts) {
|
|
70
|
-
t4 = async (targetCollection) => {
|
|
54
|
+
},
|
|
55
|
+
t,
|
|
56
|
+
invalidateCollection: async (targetCollection) => {
|
|
71
57
|
const col = targetCollection || collection;
|
|
72
58
|
await queryClient.invalidateQueries({ queryKey: queryOpts.key([
|
|
73
59
|
"collections",
|
|
@@ -82,51 +68,28 @@ function useActionHelpers(t0) {
|
|
|
82
68
|
contentLocale
|
|
83
69
|
]) });
|
|
84
70
|
onRefresh?.();
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
$[6] = onRefresh;
|
|
89
|
-
$[7] = queryClient;
|
|
90
|
-
$[8] = queryOpts;
|
|
91
|
-
$[9] = t4;
|
|
92
|
-
} else t4 = $[9];
|
|
93
|
-
let t5;
|
|
94
|
-
if ($[10] !== collection || $[11] !== contentLocale || $[12] !== queryClient || $[13] !== queryOpts) {
|
|
95
|
-
t5 = async (itemId, targetCollection_0) => {
|
|
96
|
-
const col_0 = targetCollection_0 || collection;
|
|
71
|
+
},
|
|
72
|
+
invalidateItem: async (itemId, targetCollection) => {
|
|
73
|
+
const col = targetCollection || collection;
|
|
97
74
|
await queryClient.invalidateQueries({ queryKey: queryOpts.key([
|
|
98
75
|
"collections",
|
|
99
|
-
|
|
76
|
+
col,
|
|
100
77
|
"findOne",
|
|
101
78
|
contentLocale,
|
|
102
79
|
{ id: itemId }
|
|
103
80
|
]) });
|
|
104
81
|
await queryClient.invalidateQueries({ queryKey: queryOpts.key([
|
|
105
82
|
"collections",
|
|
106
|
-
|
|
83
|
+
col,
|
|
107
84
|
"find",
|
|
108
85
|
contentLocale
|
|
109
86
|
]) });
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
$[11] = contentLocale;
|
|
113
|
-
$[12] = queryClient;
|
|
114
|
-
$[13] = queryOpts;
|
|
115
|
-
$[14] = t5;
|
|
116
|
-
} else t5 = $[14];
|
|
117
|
-
let t6;
|
|
118
|
-
if ($[15] !== onRefresh || $[16] !== queryClient) {
|
|
119
|
-
t6 = async () => {
|
|
87
|
+
},
|
|
88
|
+
invalidateAll: async () => {
|
|
120
89
|
await queryClient.invalidateQueries({ queryKey: [...QUERY_KEY_PREFIX] });
|
|
121
90
|
onRefresh?.();
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
$[16] = queryClient;
|
|
125
|
-
$[17] = t6;
|
|
126
|
-
} else t6 = $[17];
|
|
127
|
-
let t7;
|
|
128
|
-
if ($[18] !== collection || $[19] !== contentLocale || $[20] !== onRefresh || $[21] !== queryClient || $[22] !== queryOpts) {
|
|
129
|
-
t7 = () => {
|
|
91
|
+
},
|
|
92
|
+
refresh: () => {
|
|
130
93
|
queryClient.invalidateQueries({ queryKey: queryOpts.key([
|
|
131
94
|
"collections",
|
|
132
95
|
collection,
|
|
@@ -140,44 +103,19 @@ function useActionHelpers(t0) {
|
|
|
140
103
|
contentLocale
|
|
141
104
|
]) });
|
|
142
105
|
onRefresh?.();
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
t,
|
|
157
|
-
invalidateCollection: t4,
|
|
158
|
-
invalidateItem: t5,
|
|
159
|
-
invalidateAll: t6,
|
|
160
|
-
refresh: t7,
|
|
161
|
-
closeDialog: _temp,
|
|
162
|
-
basePath
|
|
163
|
-
};
|
|
164
|
-
$[24] = basePath;
|
|
165
|
-
$[25] = navigate;
|
|
166
|
-
$[26] = t;
|
|
167
|
-
$[27] = t4;
|
|
168
|
-
$[28] = t5;
|
|
169
|
-
$[29] = t6;
|
|
170
|
-
$[30] = t7;
|
|
171
|
-
$[31] = t8;
|
|
172
|
-
} else t8 = $[31];
|
|
173
|
-
const helpers = t8;
|
|
174
|
-
let t9;
|
|
175
|
-
if ($[32] !== helpers) {
|
|
176
|
-
t9 = { helpers };
|
|
177
|
-
$[32] = helpers;
|
|
178
|
-
$[33] = t9;
|
|
179
|
-
} else t9 = $[33];
|
|
180
|
-
return t9;
|
|
106
|
+
},
|
|
107
|
+
closeDialog: () => {},
|
|
108
|
+
basePath
|
|
109
|
+
}), [
|
|
110
|
+
navigate,
|
|
111
|
+
queryClient,
|
|
112
|
+
queryOpts,
|
|
113
|
+
collection,
|
|
114
|
+
contentLocale,
|
|
115
|
+
onRefresh,
|
|
116
|
+
basePath,
|
|
117
|
+
t
|
|
118
|
+
]) };
|
|
181
119
|
}
|
|
182
120
|
/**
|
|
183
121
|
* Hook to manage collection actions with dialog state
|
|
@@ -219,118 +157,44 @@ function useActionHelpers(t0) {
|
|
|
219
157
|
* );
|
|
220
158
|
* ```
|
|
221
159
|
*/
|
|
222
|
-
function
|
|
223
|
-
function useActions(t0) {
|
|
224
|
-
const $ = c(25);
|
|
225
|
-
const { collection, actionsConfig, onRefresh } = t0;
|
|
160
|
+
function useActions({ collection, actionsConfig, onRefresh }) {
|
|
226
161
|
const [dialogAction, setDialogAction] = React.useState(null);
|
|
227
162
|
const [dialogItem, setDialogItem] = React.useState(null);
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
$[0] = t1;
|
|
232
|
-
} else t1 = $[0];
|
|
233
|
-
const defaultActions = t1;
|
|
234
|
-
let t2;
|
|
235
|
-
if ($[1] !== actionsConfig) {
|
|
236
|
-
t2 = actionsConfig?.header !== void 0 ? actionsConfig.header : defaultActions.header ?? {
|
|
163
|
+
const defaultActions = React.useMemo(() => getDefaultActionsConfig(), []);
|
|
164
|
+
const actions = React.useMemo(() => ({
|
|
165
|
+
header: actionsConfig?.header !== void 0 ? actionsConfig.header : defaultActions.header ?? {
|
|
237
166
|
primary: [],
|
|
238
167
|
secondary: []
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
if ($[5] !== actionsConfig) {
|
|
251
|
-
t4 = actionsConfig?.bulk !== void 0 ? actionsConfig.bulk : defaultActions.bulk ?? [];
|
|
252
|
-
$[5] = actionsConfig;
|
|
253
|
-
$[6] = t4;
|
|
254
|
-
} else t4 = $[6];
|
|
255
|
-
let t5;
|
|
256
|
-
if ($[7] !== t2 || $[8] !== t3 || $[9] !== t4) {
|
|
257
|
-
t5 = {
|
|
258
|
-
header: t2,
|
|
259
|
-
row: t3,
|
|
260
|
-
bulk: t4
|
|
261
|
-
};
|
|
262
|
-
$[7] = t2;
|
|
263
|
-
$[8] = t3;
|
|
264
|
-
$[9] = t4;
|
|
265
|
-
$[10] = t5;
|
|
266
|
-
} else t5 = $[10];
|
|
267
|
-
const actions = t5;
|
|
268
|
-
let t6;
|
|
269
|
-
if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
|
|
270
|
-
t6 = () => {
|
|
271
|
-
setDialogAction(null);
|
|
272
|
-
setDialogItem(null);
|
|
273
|
-
};
|
|
274
|
-
$[11] = t6;
|
|
275
|
-
} else t6 = $[11];
|
|
276
|
-
const closeDialog = t6;
|
|
277
|
-
let t7;
|
|
278
|
-
if ($[12] !== onRefresh) {
|
|
279
|
-
t7 = () => {
|
|
168
|
+
},
|
|
169
|
+
row: actionsConfig?.row ?? [],
|
|
170
|
+
bulk: actionsConfig?.bulk !== void 0 ? actionsConfig.bulk : defaultActions.bulk ?? []
|
|
171
|
+
}), [actionsConfig, defaultActions]);
|
|
172
|
+
const closeDialog = React.useCallback(() => {
|
|
173
|
+
setDialogAction(null);
|
|
174
|
+
setDialogItem(null);
|
|
175
|
+
}, []);
|
|
176
|
+
const { helpers: baseHelpers } = useActionHelpers({
|
|
177
|
+
collection,
|
|
178
|
+
onRefresh: () => {
|
|
280
179
|
onRefresh?.();
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
let t8;
|
|
286
|
-
if ($[14] !== collection || $[15] !== t7) {
|
|
287
|
-
t8 = {
|
|
288
|
-
collection,
|
|
289
|
-
onRefresh: t7
|
|
290
|
-
};
|
|
291
|
-
$[14] = collection;
|
|
292
|
-
$[15] = t7;
|
|
293
|
-
$[16] = t8;
|
|
294
|
-
} else t8 = $[16];
|
|
295
|
-
const { helpers: baseHelpers } = useActionHelpers(t8);
|
|
296
|
-
let t9;
|
|
297
|
-
if ($[17] !== baseHelpers) {
|
|
298
|
-
t9 = {
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
return {
|
|
183
|
+
helpers: React.useMemo(() => ({
|
|
299
184
|
...baseHelpers,
|
|
300
185
|
closeDialog
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
t10 = (action, item) => {
|
|
186
|
+
}), [baseHelpers, closeDialog]),
|
|
187
|
+
actions,
|
|
188
|
+
dialogAction,
|
|
189
|
+
setDialogAction,
|
|
190
|
+
dialogItem,
|
|
191
|
+
setDialogItem,
|
|
192
|
+
openDialog: React.useCallback((action, item) => {
|
|
309
193
|
setDialogAction(action);
|
|
310
194
|
setDialogItem(item ?? null);
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
}
|
|
314
|
-
const openDialog = t10;
|
|
315
|
-
let t11;
|
|
316
|
-
if ($[20] !== actions || $[21] !== dialogAction || $[22] !== dialogItem || $[23] !== helpers) {
|
|
317
|
-
t11 = {
|
|
318
|
-
helpers,
|
|
319
|
-
actions,
|
|
320
|
-
dialogAction,
|
|
321
|
-
setDialogAction,
|
|
322
|
-
dialogItem,
|
|
323
|
-
setDialogItem,
|
|
324
|
-
openDialog,
|
|
325
|
-
closeDialog
|
|
326
|
-
};
|
|
327
|
-
$[20] = actions;
|
|
328
|
-
$[21] = dialogAction;
|
|
329
|
-
$[22] = dialogItem;
|
|
330
|
-
$[23] = helpers;
|
|
331
|
-
$[24] = t11;
|
|
332
|
-
} else t11 = $[24];
|
|
333
|
-
return t11;
|
|
195
|
+
}, []),
|
|
196
|
+
closeDialog
|
|
197
|
+
};
|
|
334
198
|
}
|
|
335
199
|
|
|
336
200
|
//#endregion
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { selectClient, useAdminStore } from "../runtime/provider.mjs";
|
|
2
|
-
import { c } from "react/compiler-runtime";
|
|
3
2
|
import { useQuery, useSuspenseQuery } from "@tanstack/react-query";
|
|
4
3
|
|
|
5
4
|
//#region src/client/hooks/use-admin-config.ts
|
|
@@ -26,43 +25,14 @@ function getAdminConfigQueryOptions(client) {
|
|
|
26
25
|
}
|
|
27
26
|
/** Standard query hook - returns loading/error states */
|
|
28
27
|
function useAdminConfig(queryOptions) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
t0 = getAdminConfigQueryOptions(client);
|
|
34
|
-
$[0] = client;
|
|
35
|
-
$[1] = t0;
|
|
36
|
-
} else t0 = $[1];
|
|
37
|
-
let t1;
|
|
38
|
-
if ($[2] !== queryOptions || $[3] !== t0) {
|
|
39
|
-
t1 = {
|
|
40
|
-
...t0,
|
|
41
|
-
...queryOptions
|
|
42
|
-
};
|
|
43
|
-
$[2] = queryOptions;
|
|
44
|
-
$[3] = t0;
|
|
45
|
-
$[4] = t1;
|
|
46
|
-
} else t1 = $[4];
|
|
47
|
-
return useQuery(t1);
|
|
28
|
+
return useQuery({
|
|
29
|
+
...getAdminConfigQueryOptions(useAdminStore(selectClient)),
|
|
30
|
+
...queryOptions
|
|
31
|
+
});
|
|
48
32
|
}
|
|
49
33
|
/** Suspense query hook - suspends until data is ready, no loading checks needed */
|
|
50
34
|
function useSuspenseAdminConfig() {
|
|
51
|
-
|
|
52
|
-
const client = useAdminStore(selectClient);
|
|
53
|
-
let t0;
|
|
54
|
-
if ($[0] !== client) {
|
|
55
|
-
t0 = getAdminConfigQueryOptions(client);
|
|
56
|
-
$[0] = client;
|
|
57
|
-
$[1] = t0;
|
|
58
|
-
} else t0 = $[1];
|
|
59
|
-
let t1;
|
|
60
|
-
if ($[2] !== t0) {
|
|
61
|
-
t1 = { ...t0 };
|
|
62
|
-
$[2] = t0;
|
|
63
|
-
$[3] = t1;
|
|
64
|
-
} else t1 = $[3];
|
|
65
|
-
return useSuspenseQuery(t1);
|
|
35
|
+
return useSuspenseQuery({ ...getAdminConfigQueryOptions(useAdminStore(selectClient)) });
|
|
66
36
|
}
|
|
67
37
|
|
|
68
38
|
//#endregion
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { useAdminStore } from "../runtime/provider.mjs";
|
|
2
2
|
import { useCurrentUser } from "./use-current-user.mjs";
|
|
3
|
-
import { c } from "react/compiler-runtime";
|
|
4
3
|
import { useMutation, useQuery, useQueryClient, useSuspenseQuery } from "@tanstack/react-query";
|
|
5
4
|
|
|
6
5
|
//#region src/client/hooks/use-admin-preferences.ts
|
|
@@ -28,49 +27,23 @@ function getAdminPreferenceQueryKey(userId, key) {
|
|
|
28
27
|
* ```
|
|
29
28
|
*/
|
|
30
29
|
function useAdminPreference(key) {
|
|
31
|
-
const
|
|
32
|
-
const client = useAdminStore(_temp);
|
|
30
|
+
const client = useAdminStore((s) => s.client);
|
|
33
31
|
const user = useCurrentUser();
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if ($[0] !== key || $[1] !== t0) {
|
|
37
|
-
t1 = [
|
|
32
|
+
return useQuery({
|
|
33
|
+
queryKey: [
|
|
38
34
|
"admin_preferences",
|
|
39
|
-
|
|
35
|
+
user?.id,
|
|
40
36
|
key
|
|
41
|
-
]
|
|
42
|
-
|
|
43
|
-
$[1] = t0;
|
|
44
|
-
$[2] = t1;
|
|
45
|
-
} else t1 = $[2];
|
|
46
|
-
let t2;
|
|
47
|
-
if ($[3] !== client || $[4] !== key || $[5] !== user) {
|
|
48
|
-
t2 = async () => {
|
|
37
|
+
],
|
|
38
|
+
queryFn: async () => {
|
|
49
39
|
if (!user?.id) return null;
|
|
50
40
|
return (await client.collections.admin_preferences.findOne({ where: {
|
|
51
41
|
userId: user.id,
|
|
52
42
|
key
|
|
53
43
|
} }))?.value ?? null;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
$[5] = user;
|
|
58
|
-
$[6] = t2;
|
|
59
|
-
} else t2 = $[6];
|
|
60
|
-
const t3 = !!client && !!user?.id;
|
|
61
|
-
let t4;
|
|
62
|
-
if ($[7] !== t1 || $[8] !== t2 || $[9] !== t3) {
|
|
63
|
-
t4 = {
|
|
64
|
-
queryKey: t1,
|
|
65
|
-
queryFn: t2,
|
|
66
|
-
enabled: t3
|
|
67
|
-
};
|
|
68
|
-
$[7] = t1;
|
|
69
|
-
$[8] = t2;
|
|
70
|
-
$[9] = t3;
|
|
71
|
-
$[10] = t4;
|
|
72
|
-
} else t4 = $[10];
|
|
73
|
-
return useQuery(t4);
|
|
44
|
+
},
|
|
45
|
+
enabled: !!client && !!user?.id
|
|
46
|
+
});
|
|
74
47
|
}
|
|
75
48
|
/**
|
|
76
49
|
* Hook to set an admin preference
|
|
@@ -89,17 +62,12 @@ function useAdminPreference(key) {
|
|
|
89
62
|
* };
|
|
90
63
|
* ```
|
|
91
64
|
*/
|
|
92
|
-
function _temp(s) {
|
|
93
|
-
return s.client;
|
|
94
|
-
}
|
|
95
65
|
function useSetAdminPreference(key) {
|
|
96
|
-
const
|
|
97
|
-
const client = useAdminStore(_temp2);
|
|
66
|
+
const client = useAdminStore((s) => s.client);
|
|
98
67
|
const user = useCurrentUser();
|
|
99
68
|
const queryClient = useQueryClient();
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
t0 = async (value) => {
|
|
69
|
+
return useMutation({
|
|
70
|
+
mutationFn: async (value) => {
|
|
103
71
|
if (!user?.id) throw new Error("User must be logged in to save preferences");
|
|
104
72
|
const collections = client?.collections;
|
|
105
73
|
if (!collections?.admin_preferences) throw new Error("admin_preferences collection not available. Make sure to use the adminModule in your app setup.");
|
|
@@ -116,55 +84,15 @@ function useSetAdminPreference(key) {
|
|
|
116
84
|
key,
|
|
117
85
|
value
|
|
118
86
|
});
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
$[1] = key;
|
|
122
|
-
$[2] = user;
|
|
123
|
-
$[3] = t0;
|
|
124
|
-
} else t0 = $[3];
|
|
125
|
-
let t1;
|
|
126
|
-
if ($[4] !== key || $[5] !== queryClient || $[6] !== user?.id) {
|
|
127
|
-
t1 = () => {
|
|
87
|
+
},
|
|
88
|
+
onSuccess: () => {
|
|
128
89
|
queryClient.invalidateQueries({ queryKey: [
|
|
129
90
|
"admin_preferences",
|
|
130
91
|
user?.id,
|
|
131
92
|
key
|
|
132
93
|
] });
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
$[5] = queryClient;
|
|
136
|
-
$[6] = user?.id;
|
|
137
|
-
$[7] = t1;
|
|
138
|
-
} else t1 = $[7];
|
|
139
|
-
let t2;
|
|
140
|
-
if ($[8] !== t0 || $[9] !== t1) {
|
|
141
|
-
t2 = {
|
|
142
|
-
mutationFn: t0,
|
|
143
|
-
onSuccess: t1
|
|
144
|
-
};
|
|
145
|
-
$[8] = t0;
|
|
146
|
-
$[9] = t1;
|
|
147
|
-
$[10] = t2;
|
|
148
|
-
} else t2 = $[10];
|
|
149
|
-
return useMutation(t2);
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Hook to delete an admin preference
|
|
153
|
-
*
|
|
154
|
-
* @param key - Preference key (e.g., "viewState:posts")
|
|
155
|
-
* @returns Mutation for deleting the preference
|
|
156
|
-
*
|
|
157
|
-
* @example
|
|
158
|
-
* ```tsx
|
|
159
|
-
* const { mutate: deletePreference } = useDeleteAdminPreference("viewState:posts");
|
|
160
|
-
*
|
|
161
|
-
* const handleReset = () => {
|
|
162
|
-
* deletePreference();
|
|
163
|
-
* };
|
|
164
|
-
* ```
|
|
165
|
-
*/
|
|
166
|
-
function _temp2(s) {
|
|
167
|
-
return s.client;
|
|
94
|
+
}
|
|
95
|
+
});
|
|
168
96
|
}
|
|
169
97
|
|
|
170
98
|
//#endregion
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { selectAdmin, selectBasePath, selectNavigate, useAdminStore } from "../runtime/provider.mjs";
|
|
2
2
|
import { createAdminRoutes, createNavigator } from "../utils/routes.mjs";
|
|
3
|
-
import
|
|
3
|
+
import * as React from "react";
|
|
4
4
|
|
|
5
5
|
//#region src/client/hooks/use-admin-routes.ts
|
|
6
6
|
/**
|
|
@@ -38,66 +38,32 @@ import { c } from "react/compiler-runtime";
|
|
|
38
38
|
* }
|
|
39
39
|
* ```
|
|
40
40
|
*/
|
|
41
|
-
function useAdminRoutes(
|
|
42
|
-
const $ = c(16);
|
|
43
|
-
let t1;
|
|
44
|
-
if ($[0] !== t0) {
|
|
45
|
-
t1 = t0 === void 0 ? {} : t0;
|
|
46
|
-
$[0] = t0;
|
|
47
|
-
$[1] = t1;
|
|
48
|
-
} else t1 = $[1];
|
|
49
|
-
const options = t1;
|
|
41
|
+
function useAdminRoutes(options = {}) {
|
|
50
42
|
const admin = useAdminStore(selectAdmin);
|
|
51
43
|
const storeBasePath = useAdminStore(selectBasePath);
|
|
52
44
|
const storeNavigate = useAdminStore(selectNavigate);
|
|
53
45
|
const basePath = options.basePath ?? storeBasePath;
|
|
54
|
-
|
|
55
|
-
if ($[2] !== admin || $[3] !== basePath) {
|
|
56
|
-
t2 = createAdminRoutes(admin, { basePath });
|
|
57
|
-
$[2] = admin;
|
|
58
|
-
$[3] = basePath;
|
|
59
|
-
$[4] = t2;
|
|
60
|
-
} else t2 = $[4];
|
|
61
|
-
const routes = t2;
|
|
46
|
+
const routes = React.useMemo(() => createAdminRoutes(admin, { basePath }), [admin, basePath]);
|
|
62
47
|
const navigate = storeNavigate;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
collectionUrl: routes.collections.list,
|
|
83
|
-
collectionCreateUrl: routes.collections.create,
|
|
84
|
-
collectionEditUrl: routes.collections.edit,
|
|
85
|
-
globalUrl: routes.globals.edit,
|
|
86
|
-
pageUrl: routes.pages.byId,
|
|
87
|
-
allPageUrls: routes.pages.all,
|
|
88
|
-
parse: routes.parse,
|
|
89
|
-
matches: routes.matches
|
|
90
|
-
};
|
|
91
|
-
$[8] = nav.collection;
|
|
92
|
-
$[9] = nav.collectionCreate;
|
|
93
|
-
$[10] = nav.collectionEdit;
|
|
94
|
-
$[11] = nav.dashboard;
|
|
95
|
-
$[12] = nav.global;
|
|
96
|
-
$[13] = nav.page;
|
|
97
|
-
$[14] = routes;
|
|
98
|
-
$[15] = t4;
|
|
99
|
-
} else t4 = $[15];
|
|
100
|
-
return t4;
|
|
48
|
+
const nav = React.useMemo(() => createNavigator(routes, navigate), [routes, navigate]);
|
|
49
|
+
return {
|
|
50
|
+
routes,
|
|
51
|
+
toDashboard: nav.dashboard,
|
|
52
|
+
toCollection: nav.collection,
|
|
53
|
+
toCollectionCreate: nav.collectionCreate,
|
|
54
|
+
toCollectionEdit: nav.collectionEdit,
|
|
55
|
+
toGlobal: nav.global,
|
|
56
|
+
toPage: nav.page,
|
|
57
|
+
dashboardUrl: routes.dashboard,
|
|
58
|
+
collectionUrl: routes.collections.list,
|
|
59
|
+
collectionCreateUrl: routes.collections.create,
|
|
60
|
+
collectionEditUrl: routes.collections.edit,
|
|
61
|
+
globalUrl: routes.globals.edit,
|
|
62
|
+
pageUrl: routes.pages.byId,
|
|
63
|
+
allPageUrls: routes.pages.all,
|
|
64
|
+
parse: routes.parse,
|
|
65
|
+
matches: routes.matches
|
|
66
|
+
};
|
|
101
67
|
}
|
|
102
68
|
/**
|
|
103
69
|
* Get href for admin link props
|