@questpie/admin 3.2.4 → 3.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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.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 +39 -74
- 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 +200 -559
- package/dist/client/components/primitives/select-single.mjs +165 -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.d.mts +2 -2
- 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.d.mts +2 -2
- package/dist/client/scope/picker.mjs +86 -321
- package/dist/client/scope/provider.d.mts +2 -2
- package/dist/client/scope/provider.mjs +8 -17
- 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.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 +109 -363
- 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.mjs +41 -121
- package/dist/client/views/pages/reset-password-page.mjs +46 -173
- package/dist/client/views/pages/setup-page.mjs +33 -95
- package/dist/components/rich-text/rich-text-renderer.d.mts +2 -2
- package/dist/components/rich-text/rich-text-renderer.mjs +9 -33
- 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 +41 -41
- package/dist/server/modules/admin/collections/user.d.mts +63 -63
- package/dist/server/modules/admin/collections/verification.d.mts +36 -36
- 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/package.json +3 -5
|
@@ -37,7 +37,6 @@ import { detectManyToManyRelations, hasManyToManyRelations } from "../../utils/d
|
|
|
37
37
|
import { shouldHandleAdminShortcut } from "../../utils/keyboard-shortcuts.mjs";
|
|
38
38
|
import { AdminViewHeader } from "../layout/admin-view-layout.mjs";
|
|
39
39
|
import { FormViewSkeleton } from "./view-skeletons.mjs";
|
|
40
|
-
import { c } from "react/compiler-runtime";
|
|
41
40
|
import { Icon } from "@iconify/react";
|
|
42
41
|
import * as React from "react";
|
|
43
42
|
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
|
@@ -135,444 +134,220 @@ function normalizeInlineEditValue(message) {
|
|
|
135
134
|
* Component that manages reactive field states.
|
|
136
135
|
* Must be rendered inside FormProvider to access form context.
|
|
137
136
|
*/
|
|
138
|
-
function ReactiveFieldsManager(
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
$[1] = reactiveConfigs;
|
|
147
|
-
$[2] = t2;
|
|
148
|
-
} else t2 = $[2];
|
|
149
|
-
let t3;
|
|
150
|
-
if ($[3] !== collection || $[4] !== mode || $[5] !== reactiveConfigs || $[6] !== t2) {
|
|
151
|
-
t3 = {
|
|
152
|
-
collection,
|
|
153
|
-
mode,
|
|
154
|
-
reactiveConfigs,
|
|
155
|
-
enabled: t2,
|
|
156
|
-
debounce: 300
|
|
157
|
-
};
|
|
158
|
-
$[3] = collection;
|
|
159
|
-
$[4] = mode;
|
|
160
|
-
$[5] = reactiveConfigs;
|
|
161
|
-
$[6] = t2;
|
|
162
|
-
$[7] = t3;
|
|
163
|
-
} else t3 = $[7];
|
|
164
|
-
useReactiveFields(t3);
|
|
137
|
+
function ReactiveFieldsManager({ collection, mode = "collection", reactiveConfigs, enabled }) {
|
|
138
|
+
useReactiveFields({
|
|
139
|
+
collection,
|
|
140
|
+
mode,
|
|
141
|
+
reactiveConfigs,
|
|
142
|
+
enabled: enabled && Object.keys(reactiveConfigs).length > 0,
|
|
143
|
+
debounce: 300
|
|
144
|
+
});
|
|
165
145
|
return null;
|
|
166
146
|
}
|
|
167
|
-
const FormFieldsContent = React.memo(function FormFieldsContent$1(
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
let t5;
|
|
175
|
-
if ($[0] !== registry || $[1] !== t2 || $[2] !== t3 || $[3] !== t4) {
|
|
176
|
-
t5 = /* @__PURE__ */ jsx(AutoFormFields, {
|
|
177
|
-
collection: t2,
|
|
178
|
-
config: t3,
|
|
147
|
+
const FormFieldsContent = React.memo(function FormFieldsContent$1({ collection, config, registry, allCollectionsConfig }) {
|
|
148
|
+
return /* @__PURE__ */ jsx(RenderProfiler, {
|
|
149
|
+
id: `form.fields.${collection}`,
|
|
150
|
+
minDurationMs: 10,
|
|
151
|
+
children: /* @__PURE__ */ jsx(AutoFormFields, {
|
|
152
|
+
collection,
|
|
153
|
+
config,
|
|
179
154
|
registry,
|
|
180
|
-
allCollectionsConfig
|
|
181
|
-
})
|
|
182
|
-
|
|
183
|
-
$[1] = t2;
|
|
184
|
-
$[2] = t3;
|
|
185
|
-
$[3] = t4;
|
|
186
|
-
$[4] = t5;
|
|
187
|
-
} else t5 = $[4];
|
|
188
|
-
let t6;
|
|
189
|
-
if ($[5] !== t1 || $[6] !== t5) {
|
|
190
|
-
t6 = /* @__PURE__ */ jsx(RenderProfiler, {
|
|
191
|
-
id: t1,
|
|
192
|
-
minDurationMs: 10,
|
|
193
|
-
children: t5
|
|
194
|
-
});
|
|
195
|
-
$[5] = t1;
|
|
196
|
-
$[6] = t5;
|
|
197
|
-
$[7] = t6;
|
|
198
|
-
} else t6 = $[7];
|
|
199
|
-
return t6;
|
|
155
|
+
allCollectionsConfig
|
|
156
|
+
})
|
|
157
|
+
});
|
|
200
158
|
});
|
|
201
|
-
const FormStateRefBridge = React.memo(function FormStateRefBridge$1(
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
} else t1 = $[1];
|
|
210
|
-
const { isDirty, isSubmitting } = useFormState(t1);
|
|
211
|
-
let t2;
|
|
212
|
-
let t3;
|
|
213
|
-
if ($[2] !== isDirty || $[3] !== onDirtyChange) {
|
|
214
|
-
t2 = () => {
|
|
215
|
-
onDirtyChange(isDirty);
|
|
216
|
-
};
|
|
217
|
-
t3 = [isDirty, onDirtyChange];
|
|
218
|
-
$[2] = isDirty;
|
|
219
|
-
$[3] = onDirtyChange;
|
|
220
|
-
$[4] = t2;
|
|
221
|
-
$[5] = t3;
|
|
222
|
-
} else {
|
|
223
|
-
t2 = $[4];
|
|
224
|
-
t3 = $[5];
|
|
225
|
-
}
|
|
226
|
-
React.useEffect(t2, t3);
|
|
227
|
-
let t4;
|
|
228
|
-
let t5;
|
|
229
|
-
if ($[6] !== isSubmitting || $[7] !== onSubmittingChange) {
|
|
230
|
-
t4 = () => {
|
|
231
|
-
onSubmittingChange(isSubmitting);
|
|
232
|
-
};
|
|
233
|
-
t5 = [isSubmitting, onSubmittingChange];
|
|
234
|
-
$[6] = isSubmitting;
|
|
235
|
-
$[7] = onSubmittingChange;
|
|
236
|
-
$[8] = t4;
|
|
237
|
-
$[9] = t5;
|
|
238
|
-
} else {
|
|
239
|
-
t4 = $[8];
|
|
240
|
-
t5 = $[9];
|
|
241
|
-
}
|
|
242
|
-
React.useEffect(t4, t5);
|
|
159
|
+
const FormStateRefBridge = React.memo(function FormStateRefBridge$1({ control, onDirtyChange, onSubmittingChange }) {
|
|
160
|
+
const { isDirty, isSubmitting } = useFormState({ control });
|
|
161
|
+
React.useEffect(() => {
|
|
162
|
+
onDirtyChange(isDirty);
|
|
163
|
+
}, [isDirty, onDirtyChange]);
|
|
164
|
+
React.useEffect(() => {
|
|
165
|
+
onSubmittingChange(isSubmitting);
|
|
166
|
+
}, [isSubmitting, onSubmittingChange]);
|
|
243
167
|
return null;
|
|
244
168
|
});
|
|
245
|
-
const PreviewPatchBridge = React.memo(function PreviewPatchBridge$1(
|
|
246
|
-
const $ = c(5);
|
|
247
|
-
const { form, previewRef, enabled } = t0;
|
|
169
|
+
const PreviewPatchBridge = React.memo(function PreviewPatchBridge$1({ form, previewRef, enabled }) {
|
|
248
170
|
const previousSnapshotRef = React.useRef(null);
|
|
249
171
|
const snapshotVersionRef = React.useRef(void 0);
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
172
|
+
React.useEffect(() => {
|
|
173
|
+
if (!enabled) {
|
|
174
|
+
previousSnapshotRef.current = null;
|
|
175
|
+
snapshotVersionRef.current = void 0;
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
const initialSnapshot = cloneSnapshot(form.getValues());
|
|
179
|
+
previousSnapshotRef.current = initialSnapshot;
|
|
180
|
+
snapshotVersionRef.current = previewRef.current?.sendInitSnapshot(initialSnapshot);
|
|
181
|
+
let animationFrame = null;
|
|
182
|
+
const pendingOps = /* @__PURE__ */ new Map();
|
|
183
|
+
const flushPendingOps = () => {
|
|
184
|
+
animationFrame = null;
|
|
185
|
+
if (pendingOps.size === 0) return;
|
|
186
|
+
const ops = [...pendingOps.values()];
|
|
187
|
+
pendingOps.clear();
|
|
188
|
+
previewRef.current?.sendPatchBatch(ops, snapshotVersionRef.current);
|
|
189
|
+
};
|
|
190
|
+
const queuePatchOps = (ops) => {
|
|
191
|
+
for (const op of ops) if (op.path) pendingOps.set(op.path, op);
|
|
192
|
+
if (pendingOps.size === 0 || animationFrame !== null) return;
|
|
193
|
+
animationFrame = window.requestAnimationFrame(flushPendingOps);
|
|
194
|
+
};
|
|
195
|
+
const subscription = form.watch((values, info) => {
|
|
196
|
+
const previousSnapshot = previousSnapshotRef.current;
|
|
197
|
+
const nextValues = values;
|
|
198
|
+
if (!previousSnapshot) {
|
|
199
|
+
const nextSnapshot = cloneSnapshot(nextValues);
|
|
200
|
+
previousSnapshotRef.current = nextSnapshot;
|
|
201
|
+
snapshotVersionRef.current = previewRef.current?.sendInitSnapshot(nextSnapshot);
|
|
257
202
|
return;
|
|
258
203
|
}
|
|
259
|
-
const
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
animationFrame = null;
|
|
266
|
-
if (pendingOps.size === 0) return;
|
|
267
|
-
const ops = [...pendingOps.values()];
|
|
204
|
+
const changedPath = info?.name;
|
|
205
|
+
let ops = changedPath && isSafePreviewEditPath(changedPath) ? diffSnapshotAtPath(previousSnapshot, nextValues, changedPath) : diffSnapshot(previousSnapshot, nextValues);
|
|
206
|
+
if (ops.some((op) => !op.path)) {
|
|
207
|
+
const nextSnapshot = cloneSnapshot(nextValues);
|
|
208
|
+
previousSnapshotRef.current = nextSnapshot;
|
|
209
|
+
snapshotVersionRef.current = previewRef.current?.sendInitSnapshot(nextSnapshot);
|
|
268
210
|
pendingOps.clear();
|
|
269
|
-
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
if (!previousSnapshot) {
|
|
280
|
-
const nextSnapshot = cloneSnapshot(nextValues);
|
|
281
|
-
previousSnapshotRef.current = nextSnapshot;
|
|
282
|
-
snapshotVersionRef.current = previewRef.current?.sendInitSnapshot(nextSnapshot);
|
|
283
|
-
return;
|
|
284
|
-
}
|
|
285
|
-
const changedPath = info?.name;
|
|
286
|
-
let ops_1 = changedPath && isSafePreviewEditPath(changedPath) ? diffSnapshotAtPath(previousSnapshot, nextValues, changedPath) : diffSnapshot(previousSnapshot, nextValues);
|
|
287
|
-
if (ops_1.some(_temp)) {
|
|
288
|
-
const nextSnapshot_0 = cloneSnapshot(nextValues);
|
|
289
|
-
previousSnapshotRef.current = nextSnapshot_0;
|
|
290
|
-
snapshotVersionRef.current = previewRef.current?.sendInitSnapshot(nextSnapshot_0);
|
|
291
|
-
pendingOps.clear();
|
|
292
|
-
return;
|
|
293
|
-
}
|
|
294
|
-
ops_1 = ops_1.filter(_temp2);
|
|
295
|
-
if (ops_1.length === 0) return;
|
|
296
|
-
previousSnapshotRef.current = applyPatchBatchImmutable(previousSnapshot, ops_1);
|
|
297
|
-
queuePatchOps(ops_1);
|
|
298
|
-
});
|
|
299
|
-
return () => {
|
|
300
|
-
if (animationFrame !== null) window.cancelAnimationFrame(animationFrame);
|
|
301
|
-
subscription.unsubscribe();
|
|
302
|
-
};
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
ops = ops.filter((op) => op.path);
|
|
214
|
+
if (ops.length === 0) return;
|
|
215
|
+
previousSnapshotRef.current = applyPatchBatchImmutable(previousSnapshot, ops);
|
|
216
|
+
queuePatchOps(ops);
|
|
217
|
+
});
|
|
218
|
+
return () => {
|
|
219
|
+
if (animationFrame !== null) window.cancelAnimationFrame(animationFrame);
|
|
220
|
+
subscription.unsubscribe();
|
|
303
221
|
};
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
$[0] = enabled;
|
|
310
|
-
$[1] = form;
|
|
311
|
-
$[2] = previewRef;
|
|
312
|
-
$[3] = t1;
|
|
313
|
-
$[4] = t2;
|
|
314
|
-
} else {
|
|
315
|
-
t1 = $[3];
|
|
316
|
-
t2 = $[4];
|
|
317
|
-
}
|
|
318
|
-
React.useEffect(t1, t2);
|
|
222
|
+
}, [
|
|
223
|
+
enabled,
|
|
224
|
+
form,
|
|
225
|
+
previewRef
|
|
226
|
+
]);
|
|
319
227
|
return null;
|
|
320
228
|
});
|
|
321
|
-
const AutosaveManager = React.memo(function AutosaveManager$1(
|
|
322
|
-
const $ = c(19);
|
|
323
|
-
const { form, formElementRef, isEditMode, id, enabled, debounce, isDirtyRef, isSubmittingRef, updateMutation, onPreviewRefresh, onPreviewCommit, onSavingChange, onSaved } = t0;
|
|
229
|
+
const AutosaveManager = React.memo(function AutosaveManager$1({ form, formElementRef, isEditMode, id, enabled, debounce, isDirtyRef, isSubmittingRef, updateMutation, onPreviewRefresh, onPreviewCommit, onSavingChange, onSaved }) {
|
|
324
230
|
const { t } = useTranslation();
|
|
325
231
|
const timerRef = React.useRef(null);
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
onPreviewRefresh?.();
|
|
340
|
-
onSaved(/* @__PURE__ */ new Date());
|
|
341
|
-
onSavingChange(false);
|
|
342
|
-
}, () => {
|
|
343
|
-
onSavingChange(false);
|
|
344
|
-
})();
|
|
345
|
-
} catch (t2$1) {
|
|
346
|
-
const error = t2$1;
|
|
232
|
+
const runAutosave = React.useCallback(async () => {
|
|
233
|
+
if (!id || !isDirtyRef.current || isSubmittingRef.current) return;
|
|
234
|
+
try {
|
|
235
|
+
onSavingChange(true);
|
|
236
|
+
await form.handleSubmit(async (data) => {
|
|
237
|
+
const result = await updateMutation.mutateAsync({
|
|
238
|
+
id,
|
|
239
|
+
data
|
|
240
|
+
});
|
|
241
|
+
form.reset(result, { keepTouched: true });
|
|
242
|
+
onPreviewCommit?.(result);
|
|
243
|
+
onPreviewRefresh?.();
|
|
244
|
+
onSaved(/* @__PURE__ */ new Date());
|
|
347
245
|
onSavingChange(false);
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
}
|
|
246
|
+
}, () => {
|
|
247
|
+
onSavingChange(false);
|
|
248
|
+
})();
|
|
249
|
+
} catch (error) {
|
|
250
|
+
onSavingChange(false);
|
|
251
|
+
console.error("Autosave failed:", error);
|
|
252
|
+
toast.error(t("error.autosaveFailed"), { description: error instanceof Error ? error.message : void 0 });
|
|
253
|
+
}
|
|
254
|
+
}, [
|
|
255
|
+
form,
|
|
256
|
+
id,
|
|
257
|
+
isDirtyRef,
|
|
258
|
+
isSubmittingRef,
|
|
259
|
+
onSaved,
|
|
260
|
+
onSavingChange,
|
|
261
|
+
onPreviewCommit,
|
|
262
|
+
onPreviewRefresh,
|
|
263
|
+
t,
|
|
264
|
+
updateMutation
|
|
265
|
+
]);
|
|
266
|
+
React.useEffect(() => {
|
|
267
|
+
if (timerRef.current) clearTimeout(timerRef.current);
|
|
268
|
+
if (!enabled || !isEditMode || !id) return;
|
|
269
|
+
const target = formElementRef.current;
|
|
270
|
+
if (!target) return;
|
|
271
|
+
const scheduleAutosave = () => {
|
|
272
|
+
if (timerRef.current) clearTimeout(timerRef.current);
|
|
273
|
+
timerRef.current = setTimeout(() => {
|
|
274
|
+
runAutosave();
|
|
275
|
+
}, debounce);
|
|
351
276
|
};
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
$[5] = onPreviewRefresh;
|
|
358
|
-
$[6] = onSaved;
|
|
359
|
-
$[7] = onSavingChange;
|
|
360
|
-
$[8] = t;
|
|
361
|
-
$[9] = updateMutation;
|
|
362
|
-
$[10] = t1;
|
|
363
|
-
} else t1 = $[10];
|
|
364
|
-
const runAutosave = t1;
|
|
365
|
-
let t2;
|
|
366
|
-
let t3;
|
|
367
|
-
if ($[11] !== debounce || $[12] !== enabled || $[13] !== formElementRef || $[14] !== id || $[15] !== isEditMode || $[16] !== runAutosave) {
|
|
368
|
-
t2 = () => {
|
|
277
|
+
target.addEventListener("input", scheduleAutosave, { capture: true });
|
|
278
|
+
target.addEventListener("change", scheduleAutosave, { capture: true });
|
|
279
|
+
return () => {
|
|
280
|
+
target.removeEventListener("input", scheduleAutosave, { capture: true });
|
|
281
|
+
target.removeEventListener("change", scheduleAutosave, { capture: true });
|
|
369
282
|
if (timerRef.current) clearTimeout(timerRef.current);
|
|
370
|
-
if (!enabled || !isEditMode || !id) return;
|
|
371
|
-
const target = formElementRef.current;
|
|
372
|
-
if (!target) return;
|
|
373
|
-
const scheduleAutosave = () => {
|
|
374
|
-
if (timerRef.current) clearTimeout(timerRef.current);
|
|
375
|
-
timerRef.current = setTimeout(() => {
|
|
376
|
-
runAutosave();
|
|
377
|
-
}, debounce);
|
|
378
|
-
};
|
|
379
|
-
target.addEventListener("input", scheduleAutosave, { capture: true });
|
|
380
|
-
target.addEventListener("change", scheduleAutosave, { capture: true });
|
|
381
|
-
return () => {
|
|
382
|
-
target.removeEventListener("input", scheduleAutosave, { capture: true });
|
|
383
|
-
target.removeEventListener("change", scheduleAutosave, { capture: true });
|
|
384
|
-
if (timerRef.current) clearTimeout(timerRef.current);
|
|
385
|
-
};
|
|
386
283
|
};
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
$[11] = debounce;
|
|
396
|
-
$[12] = enabled;
|
|
397
|
-
$[13] = formElementRef;
|
|
398
|
-
$[14] = id;
|
|
399
|
-
$[15] = isEditMode;
|
|
400
|
-
$[16] = runAutosave;
|
|
401
|
-
$[17] = t2;
|
|
402
|
-
$[18] = t3;
|
|
403
|
-
} else {
|
|
404
|
-
t2 = $[17];
|
|
405
|
-
t3 = $[18];
|
|
406
|
-
}
|
|
407
|
-
React.useEffect(t2, t3);
|
|
284
|
+
}, [
|
|
285
|
+
debounce,
|
|
286
|
+
enabled,
|
|
287
|
+
formElementRef,
|
|
288
|
+
id,
|
|
289
|
+
isEditMode,
|
|
290
|
+
runAutosave
|
|
291
|
+
]);
|
|
408
292
|
return null;
|
|
409
293
|
});
|
|
410
|
-
const AutosaveIndicator = React.memo(function AutosaveIndicator$1(
|
|
411
|
-
const
|
|
412
|
-
const
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
} else t1 = $[1];
|
|
419
|
-
const { isDirty } = useFormState(t1);
|
|
420
|
-
const [, forceUpdate] = React.useReducer(_temp3, 0);
|
|
421
|
-
let t2;
|
|
422
|
-
if ($[2] !== forceUpdate || $[3] !== lastSaved) {
|
|
423
|
-
t2 = () => {
|
|
424
|
-
if (!lastSaved) return;
|
|
425
|
-
const interval = setInterval(forceUpdate, 1e4);
|
|
426
|
-
return () => clearInterval(interval);
|
|
427
|
-
};
|
|
428
|
-
$[2] = forceUpdate;
|
|
429
|
-
$[3] = lastSaved;
|
|
430
|
-
$[4] = t2;
|
|
431
|
-
} else t2 = $[4];
|
|
432
|
-
let t3;
|
|
433
|
-
if ($[5] !== lastSaved) {
|
|
434
|
-
t3 = [lastSaved];
|
|
435
|
-
$[5] = lastSaved;
|
|
436
|
-
$[6] = t3;
|
|
437
|
-
} else t3 = $[6];
|
|
438
|
-
React.useEffect(t2, t3);
|
|
294
|
+
const AutosaveIndicator = React.memo(function AutosaveIndicator$1({ control, enabled, indicator, isEditMode, isSaving, lastSaved, formatTimeAgo, t }) {
|
|
295
|
+
const { isDirty } = useFormState({ control });
|
|
296
|
+
const [, forceUpdate] = React.useReducer((x) => x + 1, 0);
|
|
297
|
+
React.useEffect(() => {
|
|
298
|
+
if (!lastSaved) return;
|
|
299
|
+
const interval = setInterval(forceUpdate, 1e4);
|
|
300
|
+
return () => clearInterval(interval);
|
|
301
|
+
}, [lastSaved]);
|
|
439
302
|
if (!enabled || !indicator || !isEditMode) return null;
|
|
440
|
-
if (isSaving) {
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
});
|
|
462
|
-
$[10] = t5;
|
|
463
|
-
$[11] = t6;
|
|
464
|
-
} else t6 = $[11];
|
|
465
|
-
return t6;
|
|
466
|
-
}
|
|
467
|
-
if (isDirty) {
|
|
468
|
-
let t4;
|
|
469
|
-
if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
|
|
470
|
-
t4 = /* @__PURE__ */ jsx(Icon, {
|
|
471
|
-
icon: "ph:clock-counter-clockwise",
|
|
472
|
-
className: "size-3"
|
|
473
|
-
});
|
|
474
|
-
$[12] = t4;
|
|
475
|
-
} else t4 = $[12];
|
|
476
|
-
let t5;
|
|
477
|
-
if ($[13] !== t) {
|
|
478
|
-
t5 = t("autosave.unsavedChanges");
|
|
479
|
-
$[13] = t;
|
|
480
|
-
$[14] = t5;
|
|
481
|
-
} else t5 = $[14];
|
|
482
|
-
let t6;
|
|
483
|
-
if ($[15] !== t5) {
|
|
484
|
-
t6 = /* @__PURE__ */ jsxs(Badge, {
|
|
485
|
-
variant: "outline",
|
|
486
|
-
className: "gap-1.5",
|
|
487
|
-
children: [t4, t5]
|
|
488
|
-
});
|
|
489
|
-
$[15] = t5;
|
|
490
|
-
$[16] = t6;
|
|
491
|
-
} else t6 = $[16];
|
|
492
|
-
return t6;
|
|
493
|
-
}
|
|
494
|
-
if (lastSaved) {
|
|
495
|
-
let t4;
|
|
496
|
-
if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
|
|
497
|
-
t4 = /* @__PURE__ */ jsx(Icon, {
|
|
303
|
+
if (isSaving) return /* @__PURE__ */ jsxs(Badge, {
|
|
304
|
+
variant: "secondary",
|
|
305
|
+
className: "gap-1.5",
|
|
306
|
+
children: [/* @__PURE__ */ jsx(Icon, {
|
|
307
|
+
icon: "ph:spinner-gap",
|
|
308
|
+
className: "size-3 animate-spin"
|
|
309
|
+
}), t("autosave.saving")]
|
|
310
|
+
});
|
|
311
|
+
if (isDirty) return /* @__PURE__ */ jsxs(Badge, {
|
|
312
|
+
variant: "outline",
|
|
313
|
+
className: "gap-1.5",
|
|
314
|
+
children: [/* @__PURE__ */ jsx(Icon, {
|
|
315
|
+
icon: "ph:clock-counter-clockwise",
|
|
316
|
+
className: "size-3"
|
|
317
|
+
}), t("autosave.unsavedChanges")]
|
|
318
|
+
});
|
|
319
|
+
if (lastSaved) return /* @__PURE__ */ jsxs(Badge, {
|
|
320
|
+
variant: "secondary",
|
|
321
|
+
className: "text-muted-foreground gap-1.5",
|
|
322
|
+
children: [
|
|
323
|
+
/* @__PURE__ */ jsx(Icon, {
|
|
498
324
|
icon: "ph:check",
|
|
499
325
|
className: "size-3"
|
|
500
|
-
})
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
$[18] = t;
|
|
507
|
-
$[19] = t5;
|
|
508
|
-
} else t5 = $[19];
|
|
509
|
-
let t6;
|
|
510
|
-
if ($[20] !== formatTimeAgo || $[21] !== lastSaved) {
|
|
511
|
-
t6 = formatTimeAgo(lastSaved);
|
|
512
|
-
$[20] = formatTimeAgo;
|
|
513
|
-
$[21] = lastSaved;
|
|
514
|
-
$[22] = t6;
|
|
515
|
-
} else t6 = $[22];
|
|
516
|
-
let t7;
|
|
517
|
-
if ($[23] !== t5 || $[24] !== t6) {
|
|
518
|
-
t7 = /* @__PURE__ */ jsxs(Badge, {
|
|
519
|
-
variant: "secondary",
|
|
520
|
-
className: "text-muted-foreground gap-1.5",
|
|
521
|
-
children: [
|
|
522
|
-
t4,
|
|
523
|
-
t5,
|
|
524
|
-
" ",
|
|
525
|
-
t6
|
|
526
|
-
]
|
|
527
|
-
});
|
|
528
|
-
$[23] = t5;
|
|
529
|
-
$[24] = t6;
|
|
530
|
-
$[25] = t7;
|
|
531
|
-
} else t7 = $[25];
|
|
532
|
-
return t7;
|
|
533
|
-
}
|
|
326
|
+
}),
|
|
327
|
+
t("autosave.saved"),
|
|
328
|
+
" ",
|
|
329
|
+
formatTimeAgo(lastSaved)
|
|
330
|
+
]
|
|
331
|
+
});
|
|
534
332
|
return null;
|
|
535
333
|
});
|
|
536
|
-
const SaveSubmitButton = React.memo(function SaveSubmitButton$1(
|
|
537
|
-
const
|
|
538
|
-
const { control, isMutationPending, t } = t0;
|
|
539
|
-
let t1;
|
|
540
|
-
if ($[0] !== control) {
|
|
541
|
-
t1 = { control };
|
|
542
|
-
$[0] = control;
|
|
543
|
-
$[1] = t1;
|
|
544
|
-
} else t1 = $[1];
|
|
545
|
-
const { isDirty, isSubmitting } = useFormState(t1);
|
|
334
|
+
const SaveSubmitButton = React.memo(function SaveSubmitButton$1({ control, isMutationPending, t }) {
|
|
335
|
+
const { isDirty, isSubmitting } = useFormState({ control });
|
|
546
336
|
const isSubmittingNow = isMutationPending || isSubmitting;
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
337
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
338
|
+
type: "submit",
|
|
339
|
+
size: "sm",
|
|
340
|
+
disabled: isSubmittingNow || !isDirty,
|
|
341
|
+
className: "gap-2",
|
|
342
|
+
children: isSubmittingNow ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Icon, {
|
|
551
343
|
icon: "ph:spinner-gap",
|
|
552
344
|
className: "size-4 animate-spin"
|
|
553
345
|
}), t("common.loading")] }) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Icon, {
|
|
554
346
|
icon: "ph:check",
|
|
555
347
|
width: 16,
|
|
556
348
|
height: 16
|
|
557
|
-
}), t("common.save")] })
|
|
558
|
-
|
|
559
|
-
$[3] = t;
|
|
560
|
-
$[4] = t3;
|
|
561
|
-
} else t3 = $[4];
|
|
562
|
-
let t4;
|
|
563
|
-
if ($[5] !== t2 || $[6] !== t3) {
|
|
564
|
-
t4 = /* @__PURE__ */ jsx(Button, {
|
|
565
|
-
type: "submit",
|
|
566
|
-
size: "sm",
|
|
567
|
-
disabled: t2,
|
|
568
|
-
className: "gap-2",
|
|
569
|
-
children: t3
|
|
570
|
-
});
|
|
571
|
-
$[5] = t2;
|
|
572
|
-
$[6] = t3;
|
|
573
|
-
$[7] = t4;
|
|
574
|
-
} else t4 = $[7];
|
|
575
|
-
return t4;
|
|
349
|
+
}), t("common.save")] })
|
|
350
|
+
});
|
|
576
351
|
});
|
|
577
352
|
/**
|
|
578
353
|
* FormView - Default form-based edit/create view for collections
|
|
@@ -694,8 +469,8 @@ function FormView({ collection, id, config, viewConfig, navigate, basePath = "/a
|
|
|
694
469
|
const allowedTransitions = React.useMemo(() => {
|
|
695
470
|
if (!workflowConfig?.stages || !currentStage) return [];
|
|
696
471
|
const stageNames = currentStageConfig?.transitions;
|
|
697
|
-
if (stageNames && stageNames.length > 0) return stageNames.map((name) => workflowConfig.stages.find((
|
|
698
|
-
return workflowConfig.stages.filter((
|
|
472
|
+
if (stageNames && stageNames.length > 0) return stageNames.map((name) => workflowConfig.stages.find((s) => s.name === name)).filter(Boolean);
|
|
473
|
+
return workflowConfig.stages.filter((s) => s.name !== currentStage);
|
|
699
474
|
}, [
|
|
700
475
|
workflowConfig,
|
|
701
476
|
currentStage,
|
|
@@ -741,8 +516,8 @@ function FormView({ collection, id, config, viewConfig, navigate, basePath = "/a
|
|
|
741
516
|
});
|
|
742
517
|
setTimeout(() => scrollFieldIntoView(message.path, { focus: false }), 0);
|
|
743
518
|
}, [form, schema]);
|
|
744
|
-
const handlePreviewResyncRequest = React.useCallback((
|
|
745
|
-
triggerPreviewFullResync(
|
|
519
|
+
const handlePreviewResyncRequest = React.useCallback((reason) => {
|
|
520
|
+
triggerPreviewFullResync(reason ?? "preview-request");
|
|
746
521
|
}, [triggerPreviewFullResync]);
|
|
747
522
|
/**
|
|
748
523
|
* Execute the confirmed workflow transition (immediate or scheduled).
|
|
@@ -762,10 +537,10 @@ function FormView({ collection, id, config, viewConfig, navigate, basePath = "/a
|
|
|
762
537
|
setTransitionSchedule(false);
|
|
763
538
|
setTransitionScheduledAt(null);
|
|
764
539
|
};
|
|
765
|
-
transitionMutation.mutateAsync(params).then((
|
|
766
|
-
if (
|
|
767
|
-
if (typeof
|
|
768
|
-
if ("id" in
|
|
540
|
+
transitionMutation.mutateAsync(params).then((result) => {
|
|
541
|
+
if (result) {
|
|
542
|
+
if (typeof result === "object") {
|
|
543
|
+
if ("id" in result) form.reset(result);
|
|
769
544
|
}
|
|
770
545
|
}
|
|
771
546
|
triggerPreviewFullResync("workflow-transition");
|
|
@@ -892,23 +667,23 @@ function FormView({ collection, id, config, viewConfig, navigate, basePath = "/a
|
|
|
892
667
|
const handleLocaleDialogOpenChange = React.useCallback((open) => {
|
|
893
668
|
if (!open) handleLocaleChangeCancel();
|
|
894
669
|
}, [handleLocaleChangeCancel]);
|
|
895
|
-
const onSubmit = React.useEffectEvent(async (
|
|
670
|
+
const onSubmit = React.useEffectEvent(async (data) => {
|
|
896
671
|
const savePromise = async () => {
|
|
897
672
|
if (isEditMode && id) return await updateMutation.mutateAsync({
|
|
898
673
|
id,
|
|
899
|
-
data
|
|
674
|
+
data
|
|
900
675
|
});
|
|
901
|
-
else return await createMutation.mutateAsync(
|
|
676
|
+
else return await createMutation.mutateAsync(data);
|
|
902
677
|
};
|
|
903
678
|
toast.promise(savePromise(), {
|
|
904
679
|
loading: isEditMode ? t("toast.saving") : t("toast.creating"),
|
|
905
|
-
success: (
|
|
906
|
-
if (onSuccess) onSuccess(
|
|
680
|
+
success: (result) => {
|
|
681
|
+
if (onSuccess) onSuccess(result);
|
|
907
682
|
else if (isEditMode) {
|
|
908
|
-
form.reset(
|
|
909
|
-
commitPreviewSnapshot(
|
|
683
|
+
form.reset(result);
|
|
684
|
+
commitPreviewSnapshot(result);
|
|
910
685
|
triggerPreviewRefresh();
|
|
911
|
-
} else if (
|
|
686
|
+
} else if (result?.id) navigate(`${basePath}/collections/${collection}/${result.id}`);
|
|
912
687
|
else navigate(`${basePath}/collections/${collection}`);
|
|
913
688
|
return isEditMode ? t("toast.saveSuccess") : t("toast.createSuccess");
|
|
914
689
|
},
|
|
@@ -920,9 +695,9 @@ function FormView({ collection, id, config, viewConfig, navigate, basePath = "/a
|
|
|
920
695
|
});
|
|
921
696
|
return t("toast.validationFailed");
|
|
922
697
|
}
|
|
923
|
-
const
|
|
924
|
-
onError?.(error instanceof Error ? error : new Error(
|
|
925
|
-
return `${t("toast.saveFailed")}: ${
|
|
698
|
+
const message = error instanceof Error ? error.message : t("error.unknown");
|
|
699
|
+
onError?.(error instanceof Error ? error : new Error(message));
|
|
700
|
+
return `${t("toast.saveFailed")}: ${message}`;
|
|
926
701
|
}
|
|
927
702
|
});
|
|
928
703
|
});
|
|
@@ -942,13 +717,13 @@ function FormView({ collection, id, config, viewConfig, navigate, basePath = "/a
|
|
|
942
717
|
onSubmitRef.current = onSubmit;
|
|
943
718
|
});
|
|
944
719
|
React.useEffect(() => {
|
|
945
|
-
const handleKeyDown = (
|
|
946
|
-
if (shouldHandleAdminShortcut(
|
|
720
|
+
const handleKeyDown = (e) => {
|
|
721
|
+
if (shouldHandleAdminShortcut(e, {
|
|
947
722
|
allowEditableTarget: true,
|
|
948
723
|
key: "s"
|
|
949
724
|
})) {
|
|
950
|
-
|
|
951
|
-
|
|
725
|
+
e.preventDefault();
|
|
726
|
+
e.stopPropagation();
|
|
952
727
|
form.handleSubmit(onSubmitRef.current, (errors) => {
|
|
953
728
|
console.warn("[FormView] Validation errors:", errors);
|
|
954
729
|
toast.error(t("toast.validationFailed"));
|
|
@@ -976,10 +751,10 @@ function FormView({ collection, id, config, viewConfig, navigate, basePath = "/a
|
|
|
976
751
|
const primary = [...base.primary ?? []];
|
|
977
752
|
const secondary = [...base.secondary ?? []];
|
|
978
753
|
const existingIds = new Set([...primary, ...secondary].map((a) => a.id));
|
|
979
|
-
for (const
|
|
980
|
-
if (existingIds.has(
|
|
981
|
-
secondary.push(
|
|
982
|
-
existingIds.add(
|
|
754
|
+
for (const action of scopedServerFormActions) {
|
|
755
|
+
if (existingIds.has(action.id)) continue;
|
|
756
|
+
secondary.push(action);
|
|
757
|
+
existingIds.add(action.id);
|
|
983
758
|
}
|
|
984
759
|
return {
|
|
985
760
|
primary,
|
|
@@ -1003,8 +778,8 @@ function FormView({ collection, id, config, viewConfig, navigate, basePath = "/a
|
|
|
1003
778
|
}), [client, contentLocale]);
|
|
1004
779
|
const actionQueryClient = React.useMemo(() => ({
|
|
1005
780
|
invalidateQueries: (filters) => queryClient.invalidateQueries(filters),
|
|
1006
|
-
refetchQueries: (
|
|
1007
|
-
resetQueries: (
|
|
781
|
+
refetchQueries: (filters) => queryClient.refetchQueries(filters),
|
|
782
|
+
resetQueries: (filters) => queryClient.resetQueries(filters)
|
|
1008
783
|
}), [queryClient]);
|
|
1009
784
|
const actionHelpers = React.useMemo(() => ({
|
|
1010
785
|
navigate: storeNavigate,
|
|
@@ -1030,18 +805,18 @@ function FormView({ collection, id, config, viewConfig, navigate, basePath = "/a
|
|
|
1030
805
|
contentLocale
|
|
1031
806
|
]) });
|
|
1032
807
|
},
|
|
1033
|
-
invalidateItem: async (itemId,
|
|
1034
|
-
const
|
|
808
|
+
invalidateItem: async (itemId, targetCollection) => {
|
|
809
|
+
const col = targetCollection || collection;
|
|
1035
810
|
await queryClient.invalidateQueries({ queryKey: queryOpts.key([
|
|
1036
811
|
"collections",
|
|
1037
|
-
|
|
812
|
+
col,
|
|
1038
813
|
"findOne",
|
|
1039
814
|
contentLocale,
|
|
1040
815
|
{ id: itemId }
|
|
1041
816
|
]) });
|
|
1042
817
|
await queryClient.invalidateQueries({ queryKey: queryOpts.key([
|
|
1043
818
|
"collections",
|
|
1044
|
-
|
|
819
|
+
col,
|
|
1045
820
|
"find",
|
|
1046
821
|
contentLocale
|
|
1047
822
|
]) });
|
|
@@ -1094,48 +869,48 @@ function FormView({ collection, id, config, viewConfig, navigate, basePath = "/a
|
|
|
1094
869
|
]);
|
|
1095
870
|
const filterVisibleActions = React.useCallback((actions) => {
|
|
1096
871
|
if (!actions) return [];
|
|
1097
|
-
return actions.filter((
|
|
1098
|
-
if (
|
|
1099
|
-
if (typeof
|
|
1100
|
-
return
|
|
872
|
+
return actions.filter((action) => {
|
|
873
|
+
if (action.visible === void 0) return true;
|
|
874
|
+
if (typeof action.visible === "function") return action.visible(actionContext);
|
|
875
|
+
return action.visible;
|
|
1101
876
|
});
|
|
1102
877
|
}, [actionContext]);
|
|
1103
878
|
const visiblePrimaryActions = React.useMemo(() => filterVisibleActions(formActions.primary), [formActions.primary, filterVisibleActions]);
|
|
1104
879
|
const visibleSecondaryActions = React.useMemo(() => filterVisibleActions(formActions.secondary), [formActions.secondary, filterVisibleActions]);
|
|
1105
|
-
const regularSecondary = visibleSecondaryActions.filter((
|
|
1106
|
-
const destructiveSecondary = visibleSecondaryActions.filter((
|
|
1107
|
-
const executeAction = async (
|
|
1108
|
-
const { handler } =
|
|
1109
|
-
const actionLabel = resolveText(
|
|
880
|
+
const regularSecondary = visibleSecondaryActions.filter((a) => a.variant !== "destructive");
|
|
881
|
+
const destructiveSecondary = visibleSecondaryActions.filter((a) => a.variant === "destructive");
|
|
882
|
+
const executeAction = async (action) => {
|
|
883
|
+
const { handler } = action;
|
|
884
|
+
const actionLabel = resolveText(action.label, action.id);
|
|
1110
885
|
switch (handler.type) {
|
|
1111
886
|
case "navigate":
|
|
1112
887
|
storeNavigate(typeof handler.path === "function" ? handler.path(transformedItem) : handler.path);
|
|
1113
888
|
break;
|
|
1114
889
|
case "api":
|
|
1115
890
|
if (handler.method === "POST" && handler.endpoint === "{id}/restore") {
|
|
1116
|
-
const
|
|
1117
|
-
if (!
|
|
891
|
+
const itemId = transformedItem?.id || id;
|
|
892
|
+
if (!itemId) {
|
|
1118
893
|
toast.error(t("collection.restoreError"));
|
|
1119
894
|
break;
|
|
1120
895
|
}
|
|
1121
896
|
setActionLoading(true);
|
|
1122
|
-
toast.promise(restoreMutation.mutateAsync({ id:
|
|
897
|
+
toast.promise(restoreMutation.mutateAsync({ id: itemId }).finally(() => {
|
|
1123
898
|
setActionLoading(false);
|
|
1124
899
|
}), {
|
|
1125
900
|
loading: t("collection.restoring"),
|
|
1126
901
|
success: t("collection.restoreSuccess"),
|
|
1127
|
-
error: (
|
|
902
|
+
error: (err) => err.message || t("collection.restoreError")
|
|
1128
903
|
});
|
|
1129
904
|
break;
|
|
1130
905
|
}
|
|
1131
906
|
if (handler.method === "DELETE") {
|
|
1132
|
-
const
|
|
1133
|
-
if (!
|
|
907
|
+
const itemId = transformedItem?.id || id;
|
|
908
|
+
if (!itemId) {
|
|
1134
909
|
toast.error(t("toast.deleteFailed"));
|
|
1135
910
|
break;
|
|
1136
911
|
}
|
|
1137
912
|
setActionLoading(true);
|
|
1138
|
-
toast.promise(deleteMutation.mutateAsync({ id:
|
|
913
|
+
toast.promise(deleteMutation.mutateAsync({ id: itemId }).finally(() => {
|
|
1139
914
|
setActionLoading(false);
|
|
1140
915
|
}), {
|
|
1141
916
|
loading: t("toast.deleting"),
|
|
@@ -1143,7 +918,7 @@ function FormView({ collection, id, config, viewConfig, navigate, basePath = "/a
|
|
|
1143
918
|
storeNavigate(`${storeBasePath || basePath}/collections/${collection}`);
|
|
1144
919
|
return t("toast.deleteSuccess");
|
|
1145
920
|
},
|
|
1146
|
-
error: (
|
|
921
|
+
error: (err) => err.message || t("toast.deleteFailed")
|
|
1147
922
|
});
|
|
1148
923
|
} else {
|
|
1149
924
|
let itemId_;
|
|
@@ -1156,15 +931,15 @@ function FormView({ collection, id, config, viewConfig, navigate, basePath = "/a
|
|
|
1156
931
|
setActionLoading(true);
|
|
1157
932
|
const apiPromise = async () => {
|
|
1158
933
|
const url = `${storeBasePath}/${collection}/${endpoint}`;
|
|
1159
|
-
const
|
|
934
|
+
const response = await fetch(url, {
|
|
1160
935
|
method,
|
|
1161
936
|
headers: { "Content-Type": "application/json" },
|
|
1162
937
|
body
|
|
1163
938
|
});
|
|
1164
|
-
if (!
|
|
939
|
+
if (!response.ok) {
|
|
1165
940
|
let errorBody = {};
|
|
1166
941
|
try {
|
|
1167
|
-
errorBody = await
|
|
942
|
+
errorBody = await response.json();
|
|
1168
943
|
} catch {}
|
|
1169
944
|
let errorMessage;
|
|
1170
945
|
if (errorBody.message) if (typeof errorBody.message === "string") errorMessage = errorBody.message;
|
|
@@ -1172,15 +947,15 @@ function FormView({ collection, id, config, viewConfig, navigate, basePath = "/a
|
|
|
1172
947
|
else errorMessage = t("toast.actionFailed");
|
|
1173
948
|
throw new Error(errorMessage);
|
|
1174
949
|
}
|
|
1175
|
-
return
|
|
950
|
+
return response.json();
|
|
1176
951
|
};
|
|
1177
952
|
const p = apiPromise();
|
|
1178
953
|
p.then(() => setActionLoading(false), () => setActionLoading(false));
|
|
1179
954
|
toast.promise(p, {
|
|
1180
955
|
loading: `${actionLabel}...`,
|
|
1181
956
|
success: t("toast.actionSuccess"),
|
|
1182
|
-
error: (
|
|
1183
|
-
if (
|
|
957
|
+
error: (err) => {
|
|
958
|
+
if (err.message) return err.message;
|
|
1184
959
|
return t("toast.actionFailed");
|
|
1185
960
|
}
|
|
1186
961
|
});
|
|
@@ -1193,7 +968,7 @@ function FormView({ collection, id, config, viewConfig, navigate, basePath = "/a
|
|
|
1193
968
|
toast.promise(customPromise.finally(() => setActionLoading(false)), {
|
|
1194
969
|
loading: `${actionLabel}...`,
|
|
1195
970
|
success: t("toast.actionSuccess"),
|
|
1196
|
-
error: (
|
|
971
|
+
error: (err) => err.message || t("toast.actionFailed")
|
|
1197
972
|
});
|
|
1198
973
|
}
|
|
1199
974
|
break;
|
|
@@ -1210,17 +985,17 @@ function FormView({ collection, id, config, viewConfig, navigate, basePath = "/a
|
|
|
1210
985
|
itemId: transformedItem?.id || id
|
|
1211
986
|
});
|
|
1212
987
|
if (!response?.success || response.result?.type === "error") throw new Error(response?.error ?? response?.result?.toast?.message ?? t("error.serverActionFailed"));
|
|
1213
|
-
const
|
|
1214
|
-
if (
|
|
988
|
+
const result = response.result;
|
|
989
|
+
if (result?.toast?.message) toast.success(result.toast.message);
|
|
1215
990
|
else toast.success(t("toast.actionSuccess"));
|
|
1216
|
-
if (
|
|
1217
|
-
else if (Array.isArray(
|
|
1218
|
-
if (
|
|
1219
|
-
if (
|
|
1220
|
-
else storeNavigate(
|
|
1221
|
-
if (
|
|
1222
|
-
} catch (
|
|
1223
|
-
toast.error(
|
|
991
|
+
if (result?.effects?.invalidate === true) await actionHelpers.invalidateAll();
|
|
992
|
+
else if (Array.isArray(result?.effects?.invalidate)) for (const col of result.effects.invalidate) await actionHelpers.invalidateCollection(col);
|
|
993
|
+
if (result?.effects?.redirect) storeNavigate(result.effects.redirect);
|
|
994
|
+
if (result?.type === "redirect" && result.url) if (result.external) window.open(result.url, "_blank");
|
|
995
|
+
else storeNavigate(result.url);
|
|
996
|
+
if (result?.effects?.closeModal) actionHelpers.closeDialog();
|
|
997
|
+
} catch (error) {
|
|
998
|
+
toast.error(error instanceof Error ? error.message : t("error.actionFailed"));
|
|
1224
999
|
} finally {
|
|
1225
1000
|
setActionLoading(false);
|
|
1226
1001
|
}
|
|
@@ -1237,31 +1012,31 @@ function FormView({ collection, id, config, viewConfig, navigate, basePath = "/a
|
|
|
1237
1012
|
const payload = { id };
|
|
1238
1013
|
if (typeof pendingRevertVersion.versionId === "string") payload.versionId = pendingRevertVersion.versionId;
|
|
1239
1014
|
else if (typeof pendingRevertVersion.versionNumber === "number") payload.version = pendingRevertVersion.versionNumber;
|
|
1240
|
-
const
|
|
1241
|
-
form.reset(
|
|
1015
|
+
const result = await revertVersionMutation.mutateAsync(payload);
|
|
1016
|
+
form.reset(result);
|
|
1242
1017
|
triggerPreviewFullResync("version-revert");
|
|
1243
1018
|
toast.success(t("version.revertSuccess"));
|
|
1244
1019
|
setPendingRevertVersion(null);
|
|
1245
1020
|
};
|
|
1246
|
-
const handleActionClick = (
|
|
1247
|
-
if (
|
|
1248
|
-
else if (
|
|
1249
|
-
else executeAction(
|
|
1021
|
+
const handleActionClick = (action) => {
|
|
1022
|
+
if (action.confirmation) setConfirmAction(action);
|
|
1023
|
+
else if (action.handler.type === "dialog" || action.handler.type === "form") setDialogAction(action);
|
|
1024
|
+
else executeAction(action);
|
|
1250
1025
|
};
|
|
1251
1026
|
const handleConfirm = async () => {
|
|
1252
1027
|
if (confirmAction) await executeAction(confirmAction);
|
|
1253
1028
|
};
|
|
1254
|
-
const handleConfirmActionOpenChange = React.useCallback((
|
|
1255
|
-
if (!
|
|
1029
|
+
const handleConfirmActionOpenChange = React.useCallback((open) => {
|
|
1030
|
+
if (!open) setConfirmAction(null);
|
|
1256
1031
|
}, []);
|
|
1257
|
-
const handleActionDialogOpenChange = React.useCallback((
|
|
1258
|
-
if (!
|
|
1032
|
+
const handleActionDialogOpenChange = React.useCallback((open) => {
|
|
1033
|
+
if (!open) setDialogAction(null);
|
|
1259
1034
|
}, []);
|
|
1260
|
-
const handleRevertDialogOpenChange = React.useCallback((
|
|
1261
|
-
if (!
|
|
1035
|
+
const handleRevertDialogOpenChange = React.useCallback((open) => {
|
|
1036
|
+
if (!open) setPendingRevertVersion(null);
|
|
1262
1037
|
}, []);
|
|
1263
|
-
const handleWorkflowDialogOpenChange = React.useCallback((
|
|
1264
|
-
if (!
|
|
1038
|
+
const handleWorkflowDialogOpenChange = React.useCallback((open) => {
|
|
1039
|
+
if (!open) {
|
|
1265
1040
|
setTransitionTarget(null);
|
|
1266
1041
|
setTransitionSchedule(false);
|
|
1267
1042
|
setTransitionScheduledAt(null);
|
|
@@ -1286,8 +1061,8 @@ function FormView({ collection, id, config, viewConfig, navigate, basePath = "/a
|
|
|
1286
1061
|
minute: "2-digit"
|
|
1287
1062
|
});
|
|
1288
1063
|
};
|
|
1289
|
-
const formatTimeAgo = (
|
|
1290
|
-
const seconds = Math.floor((Date.now() -
|
|
1064
|
+
const formatTimeAgo = (date) => {
|
|
1065
|
+
const seconds = Math.floor((Date.now() - date.getTime()) / 1e3);
|
|
1291
1066
|
if (seconds < 10) return t("autosave.justNow");
|
|
1292
1067
|
if (seconds < 60) return t("autosave.secondsAgo", { count: seconds });
|
|
1293
1068
|
const minutes = Math.floor(seconds / 60);
|
|
@@ -1309,7 +1084,7 @@ function FormView({ collection, id, config, viewConfig, navigate, basePath = "/a
|
|
|
1309
1084
|
for (const event of events) target.addEventListener(event, scheduleLockRefresh, { capture: true });
|
|
1310
1085
|
scheduleLockRefresh();
|
|
1311
1086
|
return () => {
|
|
1312
|
-
for (const
|
|
1087
|
+
for (const event of events) target.removeEventListener(event, scheduleLockRefresh, { capture: true });
|
|
1313
1088
|
if (lockRefreshTimerRef.current) clearTimeout(lockRefreshTimerRef.current);
|
|
1314
1089
|
};
|
|
1315
1090
|
}, [
|
|
@@ -1449,17 +1224,17 @@ function FormView({ collection, id, config, viewConfig, navigate, basePath = "/a
|
|
|
1449
1224
|
minDurationMs: 12,
|
|
1450
1225
|
children: /* @__PURE__ */ jsxs("form", {
|
|
1451
1226
|
ref: formElementRef,
|
|
1452
|
-
onSubmit: (
|
|
1453
|
-
|
|
1227
|
+
onSubmit: (e) => {
|
|
1228
|
+
e.stopPropagation();
|
|
1454
1229
|
if (isBlocked) {
|
|
1455
|
-
|
|
1230
|
+
e.preventDefault();
|
|
1456
1231
|
toast.error(t("lock.cannotSave"));
|
|
1457
1232
|
return;
|
|
1458
1233
|
}
|
|
1459
|
-
form.handleSubmit(onSubmit, (
|
|
1460
|
-
console.warn("[FormView] Validation errors:",
|
|
1234
|
+
form.handleSubmit(onSubmit, (errors) => {
|
|
1235
|
+
console.warn("[FormView] Validation errors:", errors);
|
|
1461
1236
|
toast.error(t("toast.validationFailed"), { description: t("toast.validationDescription") });
|
|
1462
|
-
})(
|
|
1237
|
+
})(e);
|
|
1463
1238
|
},
|
|
1464
1239
|
className: "qa-form-view__form space-y-4",
|
|
1465
1240
|
children: [
|
|
@@ -1569,13 +1344,13 @@ function FormView({ collection, id, config, viewConfig, navigate, basePath = "/a
|
|
|
1569
1344
|
}), stage.label || stage.name]
|
|
1570
1345
|
}, stage.name))
|
|
1571
1346
|
})] }),
|
|
1572
|
-
visiblePrimaryActions.map((
|
|
1573
|
-
action
|
|
1347
|
+
visiblePrimaryActions.map((action) => /* @__PURE__ */ jsx(ActionButton, {
|
|
1348
|
+
action,
|
|
1574
1349
|
collection,
|
|
1575
1350
|
helpers: actionHelpers,
|
|
1576
1351
|
size: "sm",
|
|
1577
|
-
onOpenDialog: (
|
|
1578
|
-
},
|
|
1352
|
+
onOpenDialog: (a) => setDialogAction(a)
|
|
1353
|
+
}, action.id)),
|
|
1579
1354
|
/* @__PURE__ */ jsx(SaveSubmitButton, {
|
|
1580
1355
|
control: form.control,
|
|
1581
1356
|
isMutationPending,
|
|
@@ -1593,21 +1368,21 @@ function FormView({ collection, id, config, viewConfig, navigate, basePath = "/a
|
|
|
1593
1368
|
}), /* @__PURE__ */ jsxs(DropdownMenuContent, {
|
|
1594
1369
|
align: "end",
|
|
1595
1370
|
children: [
|
|
1596
|
-
regularSecondary.map((
|
|
1371
|
+
regularSecondary.map((action) => {
|
|
1597
1372
|
return /* @__PURE__ */ jsxs(DropdownMenuItem, {
|
|
1598
|
-
onClick: () => handleActionClick(
|
|
1373
|
+
onClick: () => handleActionClick(action),
|
|
1599
1374
|
disabled: actionLoading,
|
|
1600
|
-
children: [resolveIconElement(
|
|
1601
|
-
},
|
|
1375
|
+
children: [resolveIconElement(action.icon, { className: "mr-2 size-4" }), resolveText(action.label)]
|
|
1376
|
+
}, action.id);
|
|
1602
1377
|
}),
|
|
1603
1378
|
regularSecondary.length > 0 && destructiveSecondary.length > 0 && /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
|
|
1604
|
-
destructiveSecondary.map((
|
|
1379
|
+
destructiveSecondary.map((action) => {
|
|
1605
1380
|
return /* @__PURE__ */ jsxs(DropdownMenuItem, {
|
|
1606
1381
|
variant: "destructive",
|
|
1607
|
-
onClick: () => handleActionClick(
|
|
1382
|
+
onClick: () => handleActionClick(action),
|
|
1608
1383
|
disabled: actionLoading,
|
|
1609
|
-
children: [resolveIconElement(
|
|
1610
|
-
},
|
|
1384
|
+
children: [resolveIconElement(action.icon, { className: "mr-2 size-4" }), resolveText(action.label)]
|
|
1385
|
+
}, action.id);
|
|
1611
1386
|
})
|
|
1612
1387
|
]
|
|
1613
1388
|
})] })
|
|
@@ -1678,8 +1453,8 @@ function FormView({ collection, id, config, viewConfig, navigate, basePath = "/a
|
|
|
1678
1453
|
fields: schema?.fields,
|
|
1679
1454
|
isLoadingVersions: versionsLoading,
|
|
1680
1455
|
isReverting: revertVersionMutation.isPending,
|
|
1681
|
-
onRevert: async (
|
|
1682
|
-
handleRevertVersion(
|
|
1456
|
+
onRevert: async (version) => {
|
|
1457
|
+
handleRevertVersion(version);
|
|
1683
1458
|
},
|
|
1684
1459
|
showVersionsTab: !!schema?.options?.versioning
|
|
1685
1460
|
}),
|
|
@@ -1781,15 +1556,6 @@ function FormView({ collection, id, config, viewConfig, navigate, basePath = "/a
|
|
|
1781
1556
|
children: formShell
|
|
1782
1557
|
});
|
|
1783
1558
|
}
|
|
1784
|
-
function _temp(op_0) {
|
|
1785
|
-
return !op_0.path;
|
|
1786
|
-
}
|
|
1787
|
-
function _temp2(op_1) {
|
|
1788
|
-
return op_1.path;
|
|
1789
|
-
}
|
|
1790
|
-
function _temp3(x) {
|
|
1791
|
-
return x + 1;
|
|
1792
|
-
}
|
|
1793
1559
|
|
|
1794
1560
|
//#endregion
|
|
1795
1561
|
export { FormView as default };
|