@questpie/admin 3.0.3 → 3.0.4
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/README.md +34 -5
- package/dist/client/blocks/block-renderer.d.mts +2 -2
- package/dist/client/blocks/block-renderer.mjs +4 -1
- package/dist/client/builder/types/action-types.d.mts +31 -3
- package/dist/client/builder/types/collection-types.d.mts +140 -0
- package/dist/client/builder/types/ui-config.d.mts +16 -2
- package/dist/client/builder/types/views.d.mts +57 -0
- package/dist/client/builder/types/widget-types.d.mts +5 -0
- package/dist/client/components/actions/action-button.mjs +137 -199
- package/dist/client/components/actions/action-dialog.mjs +198 -156
- package/dist/client/components/actions/confirmation-dialog.mjs +2 -2
- package/dist/client/components/actions/header-actions.mjs +52 -53
- package/dist/client/components/admin-link.d.mts +2 -2
- package/dist/client/components/auth/auth-loading.mjs +41 -18
- package/dist/client/components/blocks/block-fields-renderer.mjs +64 -28
- package/dist/client/components/blocks/block-insert-button.mjs +4 -4
- package/dist/client/components/blocks/block-item.mjs +2 -2
- package/dist/client/components/blocks/block-library-sidebar.mjs +2 -2
- package/dist/client/components/component-renderer.mjs +1 -1
- package/dist/client/components/fields/array-field.mjs +14 -14
- package/dist/client/components/fields/asset-preview-field.mjs +1 -1
- package/dist/client/components/fields/blocks-field/blocks-field.mjs +84 -104
- package/dist/client/components/fields/json-field.mjs +2 -2
- package/dist/client/components/fields/object-array-field.mjs +22 -22
- package/dist/client/components/fields/object-field.mjs +5 -5
- package/dist/client/components/fields/relation/displays/cards-display.mjs +16 -9
- package/dist/client/components/fields/relation/displays/chips-display.mjs +15 -12
- package/dist/client/components/fields/relation/displays/grid-display.mjs +15 -11
- package/dist/client/components/fields/relation/displays/list-display.mjs +33 -20
- package/dist/client/components/fields/relation/displays/table-display.mjs +62 -93
- package/dist/client/components/fields/relation/relation-items-display.mjs +1 -1
- package/dist/client/components/fields/relation-picker.mjs +7 -6
- package/dist/client/components/fields/relation-select.mjs +71 -47
- package/dist/client/components/fields/rich-text-editor/bubble-menu.mjs +392 -82
- package/dist/client/components/fields/rich-text-editor/extensions.mjs +54 -23
- package/dist/client/components/fields/rich-text-editor/image-popover.mjs +24 -50
- package/dist/client/components/fields/rich-text-editor/image-upload.mjs +66 -0
- package/dist/client/components/fields/rich-text-editor/index.d.mts +38 -0
- package/dist/client/components/fields/rich-text-editor/index.mjs +637 -376
- package/dist/client/components/fields/rich-text-editor/link-utils.mjs +26 -0
- package/dist/client/components/fields/rich-text-editor/presets.d.mts +10 -0
- package/dist/client/components/fields/rich-text-editor/slash-commands.mjs +27 -6
- package/dist/client/components/fields/rich-text-editor/toolbar.mjs +464 -346
- package/dist/client/components/fields/rich-text-editor/types.d.mts +77 -0
- package/dist/client/components/fields/upload-field.mjs +45 -49
- package/dist/client/components/filter-builder/columns-tab.mjs +69 -62
- package/dist/client/components/filter-builder/filter-builder-sheet.mjs +473 -308
- package/dist/client/components/filter-builder/filters-tab.mjs +109 -82
- package/dist/client/components/filter-builder/saved-views-tab.mjs +300 -198
- package/dist/client/components/history-sidebar.mjs +850 -340
- package/dist/client/components/layout/field-layout-renderer.mjs +6 -5
- package/dist/client/components/locale-switcher.mjs +8 -8
- package/dist/client/components/media/media-grid.mjs +12 -9
- package/dist/client/components/media/media-picker-dialog.mjs +242 -230
- package/dist/client/components/preview/live-preview-mode.mjs +1 -1
- package/dist/client/components/primitives/asset-preview.mjs +37 -22
- package/dist/client/components/primitives/date-input.mjs +212 -249
- package/dist/client/components/primitives/dropzone.mjs +192 -159
- package/dist/client/components/primitives/field-select-control.mjs +93 -0
- package/dist/client/components/primitives/select-multi.mjs +251 -230
- package/dist/client/components/primitives/select-single.mjs +345 -290
- package/dist/client/components/primitives/time-input.mjs +2 -2
- package/dist/client/components/sheets/resource-sheet.mjs +2 -0
- package/dist/client/components/ui/accordion.mjs +4 -4
- package/dist/client/components/ui/alert.mjs +3 -3
- package/dist/client/components/ui/badge.mjs +4 -4
- package/dist/client/components/ui/button.mjs +47 -37
- package/dist/client/components/ui/card.mjs +2 -2
- package/dist/client/components/ui/checkbox.mjs +1 -1
- package/dist/client/components/ui/command.mjs +5 -5
- package/dist/client/components/ui/dialog.mjs +3 -3
- package/dist/client/components/ui/drawer.mjs +1 -1
- package/dist/client/components/ui/dropdown-menu.mjs +157 -15
- package/dist/client/components/ui/empty-state.mjs +88 -59
- package/dist/client/components/ui/field.mjs +2 -2
- package/dist/client/components/ui/input-group.mjs +3 -3
- package/dist/client/components/ui/input.mjs +1 -1
- package/dist/client/components/ui/kbd.mjs +1 -1
- package/dist/client/components/ui/label.mjs +1 -1
- package/dist/client/components/ui/popover.mjs +19 -11
- package/dist/client/components/ui/scroll-fade.mjs +170 -0
- package/dist/client/components/ui/search-input.mjs +1 -1
- package/dist/client/components/ui/select.mjs +129 -27
- package/dist/client/components/ui/sheet.mjs +54 -34
- package/dist/client/components/ui/sidebar.mjs +15 -14
- package/dist/client/components/ui/skeleton.mjs +28 -12
- package/dist/client/components/ui/switch.mjs +2 -2
- package/dist/client/components/ui/table.mjs +82 -74
- package/dist/client/components/ui/tabs.mjs +26 -31
- package/dist/client/components/ui/textarea.mjs +1 -1
- package/dist/client/components/ui/tooltip.mjs +1 -1
- package/dist/client/components/widgets/chart-widget.mjs +134 -96
- package/dist/client/components/widgets/progress-widget.mjs +59 -34
- package/dist/client/components/widgets/quick-actions-widget.mjs +184 -113
- package/dist/client/components/widgets/recent-items-widget.mjs +144 -102
- package/dist/client/components/widgets/stats-widget.mjs +91 -72
- package/dist/client/components/widgets/table-widget.mjs +159 -246
- package/dist/client/components/widgets/timeline-widget.mjs +66 -43
- package/dist/client/components/widgets/value-widget.mjs +261 -152
- package/dist/client/components/widgets/widget-empty-state.mjs +88 -0
- package/dist/client/components/widgets/widget-skeletons.mjs +53 -20
- package/dist/client/contexts/focus-context.d.mts +2 -2
- package/dist/client/hooks/use-action.mjs +63 -55
- package/dist/client/hooks/use-audit-history.mjs +1 -65
- package/dist/client/hooks/use-collection-validation.mjs +36 -23
- package/dist/client/hooks/use-collection.mjs +96 -1
- package/dist/client/hooks/use-saved-views.mjs +70 -49
- package/dist/client/hooks/use-server-actions.mjs +59 -40
- package/dist/client/hooks/use-server-validation.mjs +156 -41
- package/dist/client/hooks/use-server-widget-data.mjs +1 -1
- package/dist/client/hooks/use-setup-status.d.mts +3 -3
- package/dist/client/hooks/use-setup-status.mjs +2 -2
- package/dist/client/hooks/use-transition-stage.mjs +2 -10
- package/dist/client/hooks/use-validation-error-map.mjs +31 -13
- package/dist/client/hooks/use-view-state.mjs +238 -174
- package/dist/client/i18n/date-locale.mjs +33 -0
- package/dist/client/i18n/hooks.mjs +17 -1
- package/dist/client/lib/utils.mjs +3 -2
- package/dist/client/preview/block-scope-context.d.mts +2 -2
- package/dist/client/preview/preview-banner.d.mts +2 -2
- package/dist/client/preview/preview-field.d.mts +4 -4
- package/dist/client/preview/preview-field.mjs +2 -2
- package/dist/client/runtime/provider.mjs +8 -1
- package/dist/client/runtime/translations-provider.mjs +1 -1
- package/dist/client/scope/picker.d.mts +2 -2
- package/dist/client/scope/provider.d.mts +2 -2
- package/dist/client/styles/base.css +1022 -0
- package/dist/client/styles/index.css +3 -589
- package/dist/client/utils/auto-expand-fields.mjs +4 -2
- package/dist/client/utils/keyboard-shortcuts.mjs +26 -0
- package/dist/client/utils/use-lazy-component.mjs +80 -0
- package/dist/client/views/auth/auth-layout.d.mts +18 -11
- package/dist/client/views/auth/auth-layout.mjs +291 -80
- package/dist/client/views/auth/forgot-password-form.d.mts +2 -2
- package/dist/client/views/auth/forgot-password-form.mjs +2 -2
- package/dist/client/views/auth/login-form.d.mts +2 -2
- package/dist/client/views/auth/login-form.mjs +1 -1
- package/dist/client/views/auth/reset-password-form.d.mts +2 -2
- package/dist/client/views/auth/reset-password-form.mjs +2 -2
- package/dist/client/views/auth/setup-form.d.mts +2 -2
- package/dist/client/views/collection/auto-form-fields.mjs +11 -9
- package/dist/client/views/collection/bulk-action-toolbar.mjs +173 -138
- package/dist/client/views/collection/cells/complex-cells.mjs +22 -22
- package/dist/client/views/collection/cells/primitive-cells.mjs +1 -1
- package/dist/client/views/collection/cells/relation-cells.mjs +147 -129
- package/dist/client/views/collection/cells/shared/asset-thumbnail.mjs +224 -278
- package/dist/client/views/collection/cells/shared/relation-chip.mjs +64 -36
- package/dist/client/views/collection/cells/upload-cells.mjs +199 -9
- package/dist/client/views/collection/columns/build-columns.mjs +29 -9
- package/dist/client/views/collection/columns/column-defaults.mjs +2 -2
- package/dist/client/views/collection/field-renderer.mjs +50 -89
- package/dist/client/views/collection/form-view.mjs +237 -227
- package/dist/client/views/collection/table-view.mjs +1162 -229
- package/dist/client/views/collection/view-skeletons.mjs +222 -79
- package/dist/client/views/common/global-search.mjs +29 -18
- package/dist/client/views/dashboard/dashboard-grid.mjs +678 -501
- package/dist/client/views/dashboard/dashboard-widget.mjs +6 -3
- package/dist/client/views/dashboard/widget-card.mjs +23 -14
- package/dist/client/views/globals/global-form-view.mjs +634 -589
- package/dist/client/views/layout/admin-layout-provider.mjs +67 -70
- package/dist/client/views/layout/admin-layout.d.mts +3 -6
- package/dist/client/views/layout/admin-layout.mjs +149 -172
- package/dist/client/views/layout/admin-router.mjs +747 -544
- package/dist/client/views/layout/admin-sidebar.d.mts +38 -1
- package/dist/client/views/layout/admin-sidebar.mjs +751 -591
- package/dist/client/views/layout/admin-theme.d.mts +10 -0
- package/dist/client/views/layout/admin-theme.mjs +84 -0
- package/dist/client/views/layout/admin-view-layout.mjs +161 -0
- package/dist/client/views/pages/accept-invite-page.d.mts +2 -2
- package/dist/client/views/pages/accept-invite-page.mjs +49 -26
- package/dist/client/views/pages/dashboard-page.d.mts +2 -2
- package/dist/client/views/pages/forgot-password-page.d.mts +2 -2
- package/dist/client/views/pages/forgot-password-page.mjs +2 -19
- package/dist/client/views/pages/invite-page.d.mts +2 -2
- package/dist/client/views/pages/invite-page.mjs +2 -19
- package/dist/client/views/pages/login-page.d.mts +1 -1
- package/dist/client/views/pages/login-page.mjs +4 -21
- package/dist/client/views/pages/reset-password-page.d.mts +2 -2
- package/dist/client/views/pages/reset-password-page.mjs +3 -20
- package/dist/client/views/pages/setup-page.d.mts +2 -2
- package/dist/client/views/pages/setup-page.mjs +3 -20
- package/dist/client.d.mts +6 -2
- package/dist/client.mjs +2 -1
- package/dist/components/rich-text/rich-text-renderer.d.mts +2 -2
- package/dist/index.d.mts +6 -2
- package/dist/index.mjs +2 -1
- package/dist/server/augmentation/dashboard.d.mts +67 -3
- package/dist/server/augmentation/form-layout.d.mts +21 -0
- package/dist/server/augmentation/index.d.mts +1 -1
- package/dist/server/codegen/admin-client-template.mjs +4 -0
- package/dist/server/fields/blocks.d.mts +1 -1
- package/dist/server/fields/blocks.mjs +12 -0
- package/dist/server/fields/rich-text.d.mts +1 -1
- package/dist/server/fields/rich-text.mjs +8 -0
- package/dist/server/i18n/index.mjs +17 -1
- package/dist/server/i18n/messages/cs.mjs +23 -0
- package/dist/server/i18n/messages/de.mjs +23 -0
- package/dist/server/i18n/messages/en.mjs +64 -1
- package/dist/server/i18n/messages/es.mjs +23 -0
- package/dist/server/i18n/messages/fr.mjs +23 -0
- package/dist/server/i18n/messages/pl.mjs +23 -0
- package/dist/server/i18n/messages/pt.mjs +23 -0
- package/dist/server/i18n/messages/sk.mjs +83 -1
- package/dist/server/modules/admin/block/introspection.mjs +4 -1
- package/dist/server/modules/admin/block/prefetch.mjs +12 -2
- package/dist/server/modules/admin/collections/account.d.mts +50 -50
- package/dist/server/modules/admin/collections/admin-locks.d.mts +54 -54
- 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 +20 -20
- package/dist/server/modules/admin/collections/assets.mjs +0 -1
- package/dist/server/modules/admin/collections/session.d.mts +42 -42
- package/dist/server/modules/admin/collections/user.d.mts +12 -0
- package/dist/server/modules/admin/collections/user.mjs +40 -9
- package/dist/server/modules/admin/collections/verification.d.mts +2 -2
- package/dist/server/modules/admin/dto/admin-config.dto.mjs +2 -0
- package/dist/server/modules/admin/factories.mjs +7 -18
- package/dist/server/modules/admin/index.d.mts +1 -1
- package/dist/server/modules/admin/routes/admin-config.d.mts +2 -2
- package/dist/server/modules/admin/routes/admin-config.mjs +34 -16
- package/dist/server/modules/admin/routes/execute-action.d.mts +9 -9
- package/dist/server/modules/admin/routes/execute-action.mjs +33 -0
- 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 +10 -10
- package/dist/server/modules/admin/routes/setup.mjs +7 -7
- package/dist/server/modules/admin/routes/translations.d.mts +4 -4
- package/dist/server/modules/admin/routes/translations.mjs +5 -1
- package/dist/server/modules/admin/routes/widget-data.d.mts +5 -5
- package/dist/server/modules/admin-preferences/collections/admin-preferences.mjs +1 -1
- package/dist/server/modules/admin-preferences/collections/saved-views.d.mts +27 -27
- package/dist/server/modules/audit/.generated/module.d.mts +1 -1
- package/dist/server/modules/audit/.generated/module.mjs +1 -1
- package/dist/server/modules/audit/collections/audit-log.d.mts +2 -2
- package/dist/server/modules/audit/collections/audit-log.mjs +1 -1
- package/dist/server/modules/audit/config/app.mjs +99 -42
- package/dist/server/modules/audit/jobs/audit-cleanup.mjs +1 -1
- package/dist/server/plugin.mjs +4 -2
- package/dist/server/proxy-factories.d.mts +4 -3
- package/dist/server/proxy-factories.mjs +34 -8
- package/dist/shared/types/saved-views.types.d.mts +2 -0
- package/package.json +6 -4
- package/dist/client/components/fields/rich-text-editor/link-popover.mjs +0 -85
- package/dist/client/components/ui/spinner.mjs +0 -52
- package/dist/client/components/ui/toolbar.mjs +0 -136
- package/dist/client/contexts/breadcrumb-context.mjs +0 -60
- package/dist/client/views/layout/admin-topbar.mjs +0 -236
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { useResolveText, useTranslation } from "../../i18n/hooks.mjs";
|
|
4
|
-
import {
|
|
4
|
+
import { cn } from "../../lib/utils.mjs";
|
|
5
|
+
import { selectAuthClient, selectClient, useAdminStore } from "../../runtime/provider.mjs";
|
|
5
6
|
import { resolveIconElement } from "../component-renderer.mjs";
|
|
6
7
|
import { Button } from "../ui/button.mjs";
|
|
7
8
|
import { ConfirmationDialog } from "./confirmation-dialog.mjs";
|
|
8
|
-
import { c } from "react/compiler-runtime";
|
|
9
9
|
import * as React from "react";
|
|
10
10
|
import { useQueryClient } from "@tanstack/react-query";
|
|
11
11
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -30,215 +30,153 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
|
30
30
|
* />
|
|
31
31
|
* ```
|
|
32
32
|
*/
|
|
33
|
-
function ActionButton(
|
|
34
|
-
const $ = c(47);
|
|
35
|
-
const { action, collection, item, items, helpers, size: t1, className, iconOnly: t2, onOpenDialog } = t0;
|
|
36
|
-
const size = t1 === void 0 ? "default" : t1;
|
|
37
|
-
const iconOnly = t2 === void 0 ? false : t2;
|
|
33
|
+
function ActionButton({ action, collection, item, items, helpers, size = "default", className, iconOnly = false, presentation = "button", onOpenDialog }) {
|
|
38
34
|
const resolveText = useResolveText();
|
|
39
35
|
const { t } = useTranslation();
|
|
40
36
|
const authClient = useAdminStore(selectAuthClient);
|
|
37
|
+
const client = useAdminStore(selectClient);
|
|
41
38
|
const queryClient = useQueryClient();
|
|
42
39
|
const [showConfirm, setShowConfirm] = React.useState(false);
|
|
43
40
|
const [isLoading, setIsLoading] = React.useState(false);
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
let t5;
|
|
75
|
-
bb0: {
|
|
76
|
-
if (action.visible === void 0) {
|
|
77
|
-
t5 = true;
|
|
78
|
-
break bb0;
|
|
79
|
-
}
|
|
80
|
-
if (typeof action.visible === "function") {
|
|
81
|
-
t5 = action.visible(ctx);
|
|
82
|
-
break bb0;
|
|
83
|
-
}
|
|
84
|
-
t5 = action.visible;
|
|
85
|
-
}
|
|
86
|
-
const isVisible = t5;
|
|
87
|
-
let t6;
|
|
88
|
-
bb1: {
|
|
89
|
-
if (action.disabled === void 0) {
|
|
90
|
-
t6 = false;
|
|
91
|
-
break bb1;
|
|
92
|
-
}
|
|
93
|
-
if (typeof action.disabled === "function") {
|
|
94
|
-
let t7$1;
|
|
95
|
-
if ($[9] !== action || $[10] !== ctx) {
|
|
96
|
-
t7$1 = action.disabled(ctx);
|
|
97
|
-
$[9] = action;
|
|
98
|
-
$[10] = ctx;
|
|
99
|
-
$[11] = t7$1;
|
|
100
|
-
} else t7$1 = $[11];
|
|
101
|
-
t6 = t7$1;
|
|
102
|
-
break bb1;
|
|
103
|
-
}
|
|
104
|
-
t6 = action.disabled;
|
|
105
|
-
}
|
|
106
|
-
const isDisabled = t6;
|
|
41
|
+
const actionQueryClient = React.useMemo(() => ({
|
|
42
|
+
invalidateQueries: (filters) => queryClient.invalidateQueries(filters),
|
|
43
|
+
refetchQueries: (filters_0) => queryClient.refetchQueries(filters_0),
|
|
44
|
+
resetQueries: (filters_1) => queryClient.resetQueries(filters_1)
|
|
45
|
+
}), [queryClient]);
|
|
46
|
+
const ctx = React.useMemo(() => ({
|
|
47
|
+
item,
|
|
48
|
+
items,
|
|
49
|
+
collection,
|
|
50
|
+
helpers,
|
|
51
|
+
queryClient: actionQueryClient,
|
|
52
|
+
authClient
|
|
53
|
+
}), [
|
|
54
|
+
item,
|
|
55
|
+
items,
|
|
56
|
+
collection,
|
|
57
|
+
helpers,
|
|
58
|
+
actionQueryClient,
|
|
59
|
+
authClient
|
|
60
|
+
]);
|
|
61
|
+
const isVisible = React.useMemo(() => {
|
|
62
|
+
if (action.visible === void 0) return true;
|
|
63
|
+
if (typeof action.visible === "function") return action.visible(ctx);
|
|
64
|
+
return action.visible;
|
|
65
|
+
}, [action, ctx]);
|
|
66
|
+
const isDisabled = React.useMemo(() => {
|
|
67
|
+
if (action.disabled === void 0) return false;
|
|
68
|
+
if (typeof action.disabled === "function") return action.disabled(ctx);
|
|
69
|
+
return action.disabled;
|
|
70
|
+
}, [action, ctx]);
|
|
107
71
|
if (!isVisible) return null;
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
const
|
|
124
|
-
|
|
72
|
+
const executeAction = async () => {
|
|
73
|
+
const { handler } = action;
|
|
74
|
+
switch (handler.type) {
|
|
75
|
+
case "navigate": {
|
|
76
|
+
const path = typeof handler.path === "function" ? handler.path(item) : handler.path;
|
|
77
|
+
helpers.navigate(`${helpers.basePath}/collections/${collection}/${path}`);
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
case "api": {
|
|
81
|
+
setIsLoading(true);
|
|
82
|
+
const itemAny = item;
|
|
83
|
+
const itemId_0 = itemAny != null ? String(itemAny.id) : "";
|
|
84
|
+
const method = handler.method ? handler.method : "POST";
|
|
85
|
+
const endpoint = handler.endpoint.replace("{id}", itemId_0);
|
|
86
|
+
try {
|
|
87
|
+
const collectionClient = client.collections?.[collection];
|
|
88
|
+
if (method === "DELETE" && collectionClient?.delete) {
|
|
89
|
+
if (!itemId_0) throw new Error(t("toast.deleteFailed"));
|
|
90
|
+
await collectionClient.delete({ id: itemId_0 });
|
|
91
|
+
helpers.toast.success(t("toast.deleteSuccess"));
|
|
92
|
+
await helpers.invalidateCollection(collection);
|
|
93
|
+
} else {
|
|
125
94
|
helpers.toast.info(`API call: ${method} ${endpoint}`);
|
|
126
95
|
helpers.refresh();
|
|
127
|
-
setIsLoading(false);
|
|
128
|
-
} catch (t8$1) {
|
|
129
|
-
helpers.toast.error(t("error.actionFailed"));
|
|
130
|
-
setIsLoading(false);
|
|
131
96
|
}
|
|
132
|
-
|
|
97
|
+
setIsLoading(false);
|
|
98
|
+
} catch (error_1) {
|
|
99
|
+
helpers.toast.error(error_1 instanceof Error ? error_1.message : t("error.actionFailed"));
|
|
100
|
+
setIsLoading(false);
|
|
133
101
|
}
|
|
134
|
-
|
|
135
|
-
setIsLoading(true);
|
|
136
|
-
try {
|
|
137
|
-
await handler.fn(ctx);
|
|
138
|
-
setIsLoading(false);
|
|
139
|
-
} catch (t9$1) {
|
|
140
|
-
helpers.toast.error(t("error.actionFailed"));
|
|
141
|
-
setIsLoading(false);
|
|
142
|
-
}
|
|
143
|
-
break bb39;
|
|
144
|
-
case "dialog":
|
|
145
|
-
case "form":
|
|
146
|
-
onOpenDialog?.(action);
|
|
147
|
-
break bb39;
|
|
148
|
-
case "server": onOpenDialog?.(action);
|
|
102
|
+
break;
|
|
149
103
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
loading: isLoading
|
|
227
|
-
});
|
|
228
|
-
$[39] = action.confirmation;
|
|
229
|
-
$[40] = handleConfirm;
|
|
230
|
-
$[41] = isLoading;
|
|
231
|
-
$[42] = showConfirm;
|
|
232
|
-
$[43] = t16;
|
|
233
|
-
} else t16 = $[43];
|
|
234
|
-
let t17;
|
|
235
|
-
if ($[44] !== t15 || $[45] !== t16) {
|
|
236
|
-
t17 = /* @__PURE__ */ jsxs(Fragment, { children: [t15, t16] });
|
|
237
|
-
$[44] = t15;
|
|
238
|
-
$[45] = t16;
|
|
239
|
-
$[46] = t17;
|
|
240
|
-
} else t17 = $[46];
|
|
241
|
-
return t17;
|
|
104
|
+
case "custom":
|
|
105
|
+
setIsLoading(true);
|
|
106
|
+
try {
|
|
107
|
+
await handler.fn(ctx);
|
|
108
|
+
setIsLoading(false);
|
|
109
|
+
} catch (error_0) {
|
|
110
|
+
helpers.toast.error(t("error.actionFailed"));
|
|
111
|
+
setIsLoading(false);
|
|
112
|
+
}
|
|
113
|
+
break;
|
|
114
|
+
case "dialog":
|
|
115
|
+
case "form":
|
|
116
|
+
onOpenDialog?.(action);
|
|
117
|
+
break;
|
|
118
|
+
case "server":
|
|
119
|
+
setIsLoading(true);
|
|
120
|
+
try {
|
|
121
|
+
const routes = client?.routes;
|
|
122
|
+
if (!routes?.executeAction) throw new Error(t("error.serverActionFailed"));
|
|
123
|
+
const serverHandler = handler;
|
|
124
|
+
const itemId = item && !Array.isArray(item) ? String(item.id ?? "") : void 0;
|
|
125
|
+
const itemIds = items?.map((it) => it?.id).filter(Boolean).map(String);
|
|
126
|
+
const response = await routes.executeAction({
|
|
127
|
+
collection: serverHandler.collection,
|
|
128
|
+
actionId: serverHandler.actionId,
|
|
129
|
+
itemId,
|
|
130
|
+
itemIds: itemIds?.length ? itemIds : void 0
|
|
131
|
+
});
|
|
132
|
+
if (!response?.success || response.result?.type === "error") {
|
|
133
|
+
const message = response?.error ?? response?.result?.toast?.message ?? t("error.serverActionFailed");
|
|
134
|
+
throw new Error(message);
|
|
135
|
+
}
|
|
136
|
+
const result = response.result;
|
|
137
|
+
if (result?.toast?.message) helpers.toast.success(result.toast.message);
|
|
138
|
+
else helpers.toast.success(t("toast.actionSuccess"));
|
|
139
|
+
if (result?.effects?.invalidate === true) await helpers.invalidateAll();
|
|
140
|
+
else if (Array.isArray(result?.effects?.invalidate)) for (const collectionName of result.effects.invalidate) await helpers.invalidateCollection(collectionName);
|
|
141
|
+
if (result?.effects?.redirect) helpers.navigate(result.effects.redirect);
|
|
142
|
+
if (result?.type === "redirect" && result.url) helpers.navigate(result.url);
|
|
143
|
+
if (result?.effects?.closeModal) helpers.closeDialog();
|
|
144
|
+
} catch (error) {
|
|
145
|
+
helpers.toast.error(error instanceof Error ? error.message : t("error.actionFailed"));
|
|
146
|
+
} finally {
|
|
147
|
+
setIsLoading(false);
|
|
148
|
+
}
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
const handleClick = (e) => {
|
|
153
|
+
e.stopPropagation();
|
|
154
|
+
if (action.confirmation) setShowConfirm(true);
|
|
155
|
+
else executeAction();
|
|
156
|
+
};
|
|
157
|
+
const handleConfirm = async () => {
|
|
158
|
+
await executeAction();
|
|
159
|
+
};
|
|
160
|
+
const iconElement = resolveIconElement(action.icon, { "data-icon": "inline-start" });
|
|
161
|
+
const label = resolveText(action.label);
|
|
162
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(Button, {
|
|
163
|
+
variant: presentation === "menu" ? "ghost" : action.variant || "default",
|
|
164
|
+
size: iconOnly ? "icon-sm" : size,
|
|
165
|
+
onClick: handleClick,
|
|
166
|
+
disabled: isDisabled || isLoading,
|
|
167
|
+
className: cn(presentation === "menu" && "w-full justify-start rounded-[calc(var(--surface-radius)-2px)] px-3 py-2 text-left", action.variant === "destructive" && presentation === "menu" && "text-destructive hover:bg-destructive/10 hover:text-destructive", className),
|
|
168
|
+
title: iconOnly ? label : void 0,
|
|
169
|
+
children: [iconElement, iconOnly ? /* @__PURE__ */ jsx("span", {
|
|
170
|
+
className: "sr-only",
|
|
171
|
+
children: label
|
|
172
|
+
}) : label]
|
|
173
|
+
}), action.confirmation && /* @__PURE__ */ jsx(ConfirmationDialog, {
|
|
174
|
+
open: showConfirm,
|
|
175
|
+
onOpenChange: setShowConfirm,
|
|
176
|
+
config: action.confirmation,
|
|
177
|
+
onConfirm: handleConfirm,
|
|
178
|
+
loading: isLoading
|
|
179
|
+
})] });
|
|
242
180
|
}
|
|
243
181
|
|
|
244
182
|
//#endregion
|