@questpie/admin 3.2.3 → 3.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +106 -220
- 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 +107 -313
- 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 -182
- package/dist/client/components/fields/rich-text-editor/image-popover.mjs +8 -19
- package/dist/client/components/fields/rich-text-editor/image-upload.mjs +13 -29
- package/dist/client/components/fields/rich-text-editor/index.mjs +196 -530
- 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 +306 -611
- 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 +177 -494
- package/dist/client/components/preview/live-preview-mode.mjs +240 -438
- 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.d.mts +4 -0
- package/dist/client/contexts/focus-context.mjs +87 -150
- 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/diff.mjs +110 -0
- 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 +166 -409
- package/dist/client/preview/use-collection-preview.mjs +135 -201
- 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.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.mjs +128 -453
- 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 -400
- 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 +11 -24
- package/dist/client/views/collection/form-view.mjs +288 -560
- package/dist/client/views/collection/table-view.mjs +239 -469
- package/dist/client/views/collection/view-skeletons.mjs +112 -237
- package/dist/client/views/common/global-search.mjs +241 -543
- 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 +478 -1298
- 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 +457 -1289
- 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.mjs +95 -290
- package/dist/client/views/pages/dashboard-page.mjs +11 -57
- package/dist/client/views/pages/forgot-password-page.mjs +31 -83
- 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.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.d.mts +2 -2
- package/dist/components/rich-text/rich-text-renderer.mjs +9 -33
- 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 +34 -34
- package/dist/server/modules/admin/collections/session.d.mts +42 -42
- package/dist/server/modules/admin/collections/user.d.mts +53 -53
- package/dist/server/modules/admin/collections/verification.d.mts +36 -36
- package/dist/server/modules/admin/index.d.mts +21 -20
- 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 +27 -27
- package/package.json +3 -5
|
@@ -44,7 +44,6 @@ import { useRealtimeHighlight } from "../../hooks/use-realtime-highlight.mjs";
|
|
|
44
44
|
import { useDeleteSavedView, useSaveView, useSavedViews } from "../../hooks/use-saved-views.mjs";
|
|
45
45
|
import { useViewState } from "../../hooks/use-view-state.mjs";
|
|
46
46
|
import { BulkActionToolbar } from "./bulk-action-toolbar.mjs";
|
|
47
|
-
import { c } from "react/compiler-runtime";
|
|
48
47
|
import { Icon } from "@iconify/react";
|
|
49
48
|
import * as React from "react";
|
|
50
49
|
import { Suspense, useMemo, useState } from "react";
|
|
@@ -70,76 +69,38 @@ const REORDER_DROP_ANIMATION = {
|
|
|
70
69
|
duration: REORDER_DROP_DURATION,
|
|
71
70
|
easing: REORDER_MOVE_EASING
|
|
72
71
|
};
|
|
73
|
-
function UploadCollectionButton(
|
|
74
|
-
const $ = c(13);
|
|
75
|
-
const { collection, onUploaded } = t0;
|
|
72
|
+
function UploadCollectionButton({ collection, onUploaded }) {
|
|
76
73
|
const { t } = useTranslation();
|
|
77
74
|
const [open, setOpen] = React.useState(false);
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
75
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(Button, {
|
|
76
|
+
variant: "default",
|
|
77
|
+
size: "sm",
|
|
78
|
+
className: "gap-2",
|
|
79
|
+
onClick: () => setOpen(true),
|
|
80
|
+
children: [/* @__PURE__ */ jsx(Icon, {
|
|
83
81
|
icon: "ph:cloud-arrow-up",
|
|
84
82
|
className: "size-3.5"
|
|
85
|
-
})
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
let t3;
|
|
93
|
-
if ($[2] !== t) {
|
|
94
|
-
t3 = t("common.upload");
|
|
95
|
-
$[2] = t;
|
|
96
|
-
$[3] = t3;
|
|
97
|
-
} else t3 = $[3];
|
|
98
|
-
let t4;
|
|
99
|
-
if ($[4] !== t3) {
|
|
100
|
-
t4 = /* @__PURE__ */ jsxs(Button, {
|
|
101
|
-
variant: "default",
|
|
102
|
-
size: "sm",
|
|
103
|
-
className: "gap-2",
|
|
104
|
-
onClick: t1,
|
|
105
|
-
children: [t2, t3]
|
|
106
|
-
});
|
|
107
|
-
$[4] = t3;
|
|
108
|
-
$[5] = t4;
|
|
109
|
-
} else t4 = $[5];
|
|
110
|
-
let t5;
|
|
111
|
-
if ($[6] !== collection || $[7] !== onUploaded || $[8] !== open) {
|
|
112
|
-
t5 = /* @__PURE__ */ jsx(UploadCollectionSheet, {
|
|
113
|
-
open,
|
|
114
|
-
onOpenChange: setOpen,
|
|
115
|
-
collection,
|
|
116
|
-
onUploaded
|
|
117
|
-
});
|
|
118
|
-
$[6] = collection;
|
|
119
|
-
$[7] = onUploaded;
|
|
120
|
-
$[8] = open;
|
|
121
|
-
$[9] = t5;
|
|
122
|
-
} else t5 = $[9];
|
|
123
|
-
let t6;
|
|
124
|
-
if ($[10] !== t4 || $[11] !== t5) {
|
|
125
|
-
t6 = /* @__PURE__ */ jsxs(Fragment, { children: [t4, t5] });
|
|
126
|
-
$[10] = t4;
|
|
127
|
-
$[11] = t5;
|
|
128
|
-
$[12] = t6;
|
|
129
|
-
} else t6 = $[12];
|
|
130
|
-
return t6;
|
|
83
|
+
}), t("common.upload")]
|
|
84
|
+
}), /* @__PURE__ */ jsx(UploadCollectionSheet, {
|
|
85
|
+
open,
|
|
86
|
+
onOpenChange: setOpen,
|
|
87
|
+
collection,
|
|
88
|
+
onUploaded
|
|
89
|
+
})] });
|
|
131
90
|
}
|
|
132
91
|
function UploadCollectionSheet({ open, onOpenChange, collection, onUploaded }) {
|
|
133
92
|
const { t } = useTranslation();
|
|
134
93
|
const { uploadMany, isUploading, progress } = useUpload();
|
|
135
94
|
const [uploadedAssets, setUploadedAssets] = React.useState([]);
|
|
136
95
|
const [editAssetId, setEditAssetId] = React.useState(null);
|
|
137
|
-
React.
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
96
|
+
const resetUploadSheetState = React.useCallback(() => {
|
|
97
|
+
setUploadedAssets([]);
|
|
98
|
+
setEditAssetId(null);
|
|
99
|
+
}, []);
|
|
100
|
+
const handleOpenChange = React.useCallback((nextOpen) => {
|
|
101
|
+
if (!nextOpen) resetUploadSheetState();
|
|
102
|
+
onOpenChange(nextOpen);
|
|
103
|
+
}, [onOpenChange, resetUploadSheetState]);
|
|
143
104
|
const handleValidationError = React.useCallback((errors) => {
|
|
144
105
|
for (const validationError of errors) toast.error(validationError.message);
|
|
145
106
|
}, []);
|
|
@@ -166,7 +127,7 @@ function UploadCollectionSheet({ open, onOpenChange, collection, onUploaded }) {
|
|
|
166
127
|
]);
|
|
167
128
|
return /* @__PURE__ */ jsx(Sheet, {
|
|
168
129
|
open,
|
|
169
|
-
onOpenChange,
|
|
130
|
+
onOpenChange: handleOpenChange,
|
|
170
131
|
modal: false,
|
|
171
132
|
children: /* @__PURE__ */ jsxs(SheetContent, {
|
|
172
133
|
side: "right",
|
|
@@ -206,7 +167,7 @@ function UploadCollectionSheet({ open, onOpenChange, collection, onUploaded }) {
|
|
|
206
167
|
className: "border-t px-6 py-4",
|
|
207
168
|
children: /* @__PURE__ */ jsx(Button, {
|
|
208
169
|
variant: "outline",
|
|
209
|
-
onClick: () =>
|
|
170
|
+
onClick: () => handleOpenChange(false),
|
|
210
171
|
disabled: isUploading,
|
|
211
172
|
children: t("common.close")
|
|
212
173
|
})
|
|
@@ -326,247 +287,68 @@ function getGroupSortIndex(value, field) {
|
|
|
326
287
|
}
|
|
327
288
|
const ReorderRowContext = React.createContext(null);
|
|
328
289
|
function ReorderHandle() {
|
|
329
|
-
const $ = c(9);
|
|
330
290
|
const sortable = React.useContext(ReorderRowContext);
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
if ($[2] !== sortable?.listeners) {
|
|
340
|
-
t2 = sortable?.listeners ?? {};
|
|
341
|
-
$[2] = sortable?.listeners;
|
|
342
|
-
$[3] = t2;
|
|
343
|
-
} else t2 = $[3];
|
|
344
|
-
let t3;
|
|
345
|
-
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
|
|
346
|
-
t3 = /* @__PURE__ */ jsx(Icon, {
|
|
291
|
+
return /* @__PURE__ */ jsx("button", {
|
|
292
|
+
type: "button",
|
|
293
|
+
ref: sortable?.setActivatorNodeRef,
|
|
294
|
+
className: "text-muted-foreground/50 hover:text-muted-foreground focus-visible:ring-ring/40 flex h-8 w-full cursor-grab touch-none items-center justify-center rounded-md transition-colors select-none focus-visible:ring-2 focus-visible:outline-none active:cursor-grabbing",
|
|
295
|
+
"aria-label": "Drag to reorder",
|
|
296
|
+
...sortable?.attributes ?? {},
|
|
297
|
+
...sortable?.listeners ?? {},
|
|
298
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
347
299
|
icon: "ph:dots-six-vertical",
|
|
348
300
|
className: "size-3.5"
|
|
349
|
-
})
|
|
350
|
-
|
|
351
|
-
} else t3 = $[4];
|
|
352
|
-
let t4;
|
|
353
|
-
if ($[5] !== t0 || $[6] !== t1 || $[7] !== t2) {
|
|
354
|
-
t4 = /* @__PURE__ */ jsx("button", {
|
|
355
|
-
type: "button",
|
|
356
|
-
ref: t0,
|
|
357
|
-
className: "text-muted-foreground/50 hover:text-muted-foreground focus-visible:ring-ring/40 flex h-8 w-full cursor-grab touch-none items-center justify-center rounded-md transition-colors select-none focus-visible:ring-2 focus-visible:outline-none active:cursor-grabbing",
|
|
358
|
-
"aria-label": "Drag to reorder",
|
|
359
|
-
...t1,
|
|
360
|
-
...t2,
|
|
361
|
-
children: t3
|
|
362
|
-
});
|
|
363
|
-
$[5] = t0;
|
|
364
|
-
$[6] = t1;
|
|
365
|
-
$[7] = t2;
|
|
366
|
-
$[8] = t4;
|
|
367
|
-
} else t4 = $[8];
|
|
368
|
-
return t4;
|
|
301
|
+
})
|
|
302
|
+
});
|
|
369
303
|
}
|
|
370
|
-
function ReorderDragOverlay(
|
|
371
|
-
const $ = c(24);
|
|
372
|
-
const { row, columns, rect } = t0;
|
|
304
|
+
function ReorderDragOverlay({ row, columns, rect }) {
|
|
373
305
|
if (!row) return null;
|
|
374
|
-
|
|
375
|
-
let t2;
|
|
376
|
-
let t3;
|
|
377
|
-
let t4;
|
|
378
|
-
let t5;
|
|
379
|
-
if ($[0] !== columns || $[1] !== rect?.height || $[2] !== rect?.width || $[3] !== row) {
|
|
380
|
-
const cells = row.getVisibleCells?.() ?? [];
|
|
381
|
-
t4 = "bg-background text-foreground ring-border-strong pointer-events-none overflow-hidden rounded-md shadow-xl ring-1";
|
|
382
|
-
const t6$1 = rect?.width;
|
|
383
|
-
const t7$1 = rect?.height;
|
|
384
|
-
if ($[9] !== t6$1 || $[10] !== t7$1) {
|
|
385
|
-
t5 = {
|
|
386
|
-
width: t6$1,
|
|
387
|
-
height: t7$1
|
|
388
|
-
};
|
|
389
|
-
$[9] = t6$1;
|
|
390
|
-
$[10] = t7$1;
|
|
391
|
-
$[11] = t5;
|
|
392
|
-
} else t5 = $[11];
|
|
393
|
-
t1 = "grid h-full items-center";
|
|
394
|
-
let t8;
|
|
395
|
-
if ($[12] !== columns) {
|
|
396
|
-
t8 = columns.map(_temp3).join(" ");
|
|
397
|
-
$[12] = columns;
|
|
398
|
-
$[13] = t8;
|
|
399
|
-
} else t8 = $[13];
|
|
400
|
-
if ($[14] !== t8) {
|
|
401
|
-
t2 = { gridTemplateColumns: t8 };
|
|
402
|
-
$[14] = t8;
|
|
403
|
-
$[15] = t2;
|
|
404
|
-
} else t2 = $[15];
|
|
405
|
-
t3 = cells.map(_temp4);
|
|
406
|
-
$[0] = columns;
|
|
407
|
-
$[1] = rect?.height;
|
|
408
|
-
$[2] = rect?.width;
|
|
409
|
-
$[3] = row;
|
|
410
|
-
$[4] = t1;
|
|
411
|
-
$[5] = t2;
|
|
412
|
-
$[6] = t3;
|
|
413
|
-
$[7] = t4;
|
|
414
|
-
$[8] = t5;
|
|
415
|
-
} else {
|
|
416
|
-
t1 = $[4];
|
|
417
|
-
t2 = $[5];
|
|
418
|
-
t3 = $[6];
|
|
419
|
-
t4 = $[7];
|
|
420
|
-
t5 = $[8];
|
|
421
|
-
}
|
|
422
|
-
let t6;
|
|
423
|
-
if ($[16] !== t1 || $[17] !== t2 || $[18] !== t3) {
|
|
424
|
-
t6 = /* @__PURE__ */ jsx("div", {
|
|
425
|
-
className: t1,
|
|
426
|
-
style: t2,
|
|
427
|
-
children: t3
|
|
428
|
-
});
|
|
429
|
-
$[16] = t1;
|
|
430
|
-
$[17] = t2;
|
|
431
|
-
$[18] = t3;
|
|
432
|
-
$[19] = t6;
|
|
433
|
-
} else t6 = $[19];
|
|
434
|
-
let t7;
|
|
435
|
-
if ($[20] !== t4 || $[21] !== t5 || $[22] !== t6) {
|
|
436
|
-
t7 = /* @__PURE__ */ jsx("div", {
|
|
437
|
-
className: t4,
|
|
438
|
-
style: t5,
|
|
439
|
-
children: t6
|
|
440
|
-
});
|
|
441
|
-
$[20] = t4;
|
|
442
|
-
$[21] = t5;
|
|
443
|
-
$[22] = t6;
|
|
444
|
-
$[23] = t7;
|
|
445
|
-
} else t7 = $[23];
|
|
446
|
-
return t7;
|
|
447
|
-
}
|
|
448
|
-
function _temp4(cell, index) {
|
|
306
|
+
const cells = row.getVisibleCells?.() ?? [];
|
|
449
307
|
return /* @__PURE__ */ jsx("div", {
|
|
450
|
-
className:
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
308
|
+
className: "bg-background text-foreground ring-border-strong pointer-events-none overflow-hidden rounded-md shadow-xl ring-1",
|
|
309
|
+
style: {
|
|
310
|
+
width: rect?.width,
|
|
311
|
+
height: rect?.height
|
|
312
|
+
},
|
|
313
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
314
|
+
className: "grid h-full items-center",
|
|
315
|
+
style: { gridTemplateColumns: columns.map((column) => `${getColumnSize(column, 120)}px`).join(" ") },
|
|
316
|
+
children: cells.map((cell, index) => /* @__PURE__ */ jsx("div", {
|
|
317
|
+
className: cn("min-w-0 truncate px-3 py-1.5 text-sm whitespace-nowrap tabular-nums", index === 0 && "px-1.5 text-center"),
|
|
318
|
+
children: index === 0 ? /* @__PURE__ */ jsx(Icon, {
|
|
319
|
+
icon: "ph:dots-six-vertical",
|
|
320
|
+
className: "text-muted-foreground mx-auto size-3.5"
|
|
321
|
+
}) : flexRender(cell.column.columnDef.cell, cell.getContext())
|
|
322
|
+
}, cell.id))
|
|
323
|
+
})
|
|
324
|
+
});
|
|
459
325
|
}
|
|
460
|
-
function SortableTableRow(
|
|
461
|
-
const
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
let id;
|
|
465
|
-
let props;
|
|
466
|
-
if ($[0] !== t0) {
|
|
467
|
-
({id, className, children, ...props} = t0);
|
|
468
|
-
$[0] = t0;
|
|
469
|
-
$[1] = children;
|
|
470
|
-
$[2] = className;
|
|
471
|
-
$[3] = id;
|
|
472
|
-
$[4] = props;
|
|
473
|
-
} else {
|
|
474
|
-
children = $[1];
|
|
475
|
-
className = $[2];
|
|
476
|
-
id = $[3];
|
|
477
|
-
props = $[4];
|
|
478
|
-
}
|
|
479
|
-
let t1;
|
|
480
|
-
if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
|
|
481
|
-
t1 = {
|
|
326
|
+
function SortableTableRow({ id, className, children, ...props }) {
|
|
327
|
+
const { attributes, listeners, setNodeRef, setActivatorNodeRef, transform, transition, isDragging } = useSortable({
|
|
328
|
+
id,
|
|
329
|
+
transition: {
|
|
482
330
|
duration: REORDER_DROP_DURATION,
|
|
483
331
|
easing: REORDER_MOVE_EASING
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
transition:
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
$[8] = className;
|
|
502
|
-
$[9] = t3;
|
|
503
|
-
$[10] = t4;
|
|
504
|
-
} else t4 = $[10];
|
|
505
|
-
let t5;
|
|
506
|
-
if ($[11] !== isDragging || $[12] !== transform) {
|
|
507
|
-
t5 = isDragging ? void 0 : CSS.Transform.toString(transform);
|
|
508
|
-
$[11] = isDragging;
|
|
509
|
-
$[12] = transform;
|
|
510
|
-
$[13] = t5;
|
|
511
|
-
} else t5 = $[13];
|
|
512
|
-
const t6 = isDragging ? void 0 : transition;
|
|
513
|
-
let t7;
|
|
514
|
-
if ($[14] !== props.style) {
|
|
515
|
-
t7 = props.style ?? {};
|
|
516
|
-
$[14] = props.style;
|
|
517
|
-
$[15] = t7;
|
|
518
|
-
} else t7 = $[15];
|
|
519
|
-
let t8;
|
|
520
|
-
if ($[16] !== t5 || $[17] !== t6 || $[18] !== t7) {
|
|
521
|
-
t8 = {
|
|
522
|
-
transform: t5,
|
|
523
|
-
transition: t6,
|
|
524
|
-
...t7
|
|
525
|
-
};
|
|
526
|
-
$[16] = t5;
|
|
527
|
-
$[17] = t6;
|
|
528
|
-
$[18] = t7;
|
|
529
|
-
$[19] = t8;
|
|
530
|
-
} else t8 = $[19];
|
|
531
|
-
let t9;
|
|
532
|
-
if ($[20] !== attributes || $[21] !== listeners || $[22] !== setActivatorNodeRef) {
|
|
533
|
-
t9 = {
|
|
534
|
-
attributes,
|
|
535
|
-
listeners,
|
|
536
|
-
setActivatorNodeRef
|
|
537
|
-
};
|
|
538
|
-
$[20] = attributes;
|
|
539
|
-
$[21] = listeners;
|
|
540
|
-
$[22] = setActivatorNodeRef;
|
|
541
|
-
$[23] = t9;
|
|
542
|
-
} else t9 = $[23];
|
|
543
|
-
let t10;
|
|
544
|
-
if ($[24] !== children || $[25] !== t9) {
|
|
545
|
-
t10 = /* @__PURE__ */ jsx(ReorderRowContext.Provider, {
|
|
546
|
-
value: t9,
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
return /* @__PURE__ */ jsx(TableRow, {
|
|
335
|
+
ref: setNodeRef,
|
|
336
|
+
className: cn("select-none", isDragging && "bg-muted/[0.18] opacity-35", className),
|
|
337
|
+
style: {
|
|
338
|
+
transform: isDragging ? void 0 : CSS.Transform.toString(transform),
|
|
339
|
+
transition: isDragging ? void 0 : transition,
|
|
340
|
+
...props.style ?? {}
|
|
341
|
+
},
|
|
342
|
+
...props,
|
|
343
|
+
children: /* @__PURE__ */ jsx(ReorderRowContext.Provider, {
|
|
344
|
+
value: {
|
|
345
|
+
attributes,
|
|
346
|
+
listeners,
|
|
347
|
+
setActivatorNodeRef
|
|
348
|
+
},
|
|
547
349
|
children
|
|
548
|
-
})
|
|
549
|
-
|
|
550
|
-
$[25] = t9;
|
|
551
|
-
$[26] = t10;
|
|
552
|
-
} else t10 = $[26];
|
|
553
|
-
let t11;
|
|
554
|
-
if ($[27] !== props || $[28] !== setNodeRef || $[29] !== t10 || $[30] !== t4 || $[31] !== t8) {
|
|
555
|
-
t11 = /* @__PURE__ */ jsx(TableRow, {
|
|
556
|
-
ref: setNodeRef,
|
|
557
|
-
className: t4,
|
|
558
|
-
style: t8,
|
|
559
|
-
...props,
|
|
560
|
-
children: t10
|
|
561
|
-
});
|
|
562
|
-
$[27] = props;
|
|
563
|
-
$[28] = setNodeRef;
|
|
564
|
-
$[29] = t10;
|
|
565
|
-
$[30] = t4;
|
|
566
|
-
$[31] = t8;
|
|
567
|
-
$[32] = t11;
|
|
568
|
-
} else t11 = $[32];
|
|
569
|
-
return t11;
|
|
350
|
+
})
|
|
351
|
+
});
|
|
570
352
|
}
|
|
571
353
|
/**
|
|
572
354
|
* TableView - Default table-based list view for collections
|
|
@@ -595,22 +377,10 @@ function SortableTableRow(t0) {
|
|
|
595
377
|
* ```
|
|
596
378
|
*/
|
|
597
379
|
function TableView(props) {
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
$[0] = t0;
|
|
603
|
-
} else t0 = $[0];
|
|
604
|
-
let t1;
|
|
605
|
-
if ($[1] !== props) {
|
|
606
|
-
t1 = /* @__PURE__ */ jsx(Suspense, {
|
|
607
|
-
fallback: t0,
|
|
608
|
-
children: /* @__PURE__ */ jsx(TableViewInner, { ...props })
|
|
609
|
-
});
|
|
610
|
-
$[1] = props;
|
|
611
|
-
$[2] = t1;
|
|
612
|
-
} else t1 = $[2];
|
|
613
|
-
return t1;
|
|
380
|
+
return /* @__PURE__ */ jsx(Suspense, {
|
|
381
|
+
fallback: /* @__PURE__ */ jsx(TableViewSkeleton, {}),
|
|
382
|
+
children: /* @__PURE__ */ jsx(TableViewInner, { ...props })
|
|
383
|
+
});
|
|
614
384
|
}
|
|
615
385
|
/**
|
|
616
386
|
* Inner component that uses Suspense queries.
|
|
@@ -742,41 +512,41 @@ function TableViewInner({ collection, config, viewConfig, navigate, basePath = "
|
|
|
742
512
|
if (Array.isArray(val)) return val.length === 0;
|
|
743
513
|
return false;
|
|
744
514
|
};
|
|
745
|
-
const normalizeSelectValue = (
|
|
515
|
+
const normalizeSelectValue = (val, fieldOptions) => {
|
|
746
516
|
const optionsList = fieldOptions?.options;
|
|
747
|
-
if (!optionsList) return
|
|
517
|
+
if (!optionsList) return val;
|
|
748
518
|
const map = new Map(flattenOptions(optionsList).map((opt) => [String(opt.value), opt.value]));
|
|
749
519
|
const mapValue = (item) => map.get(String(item)) ?? item;
|
|
750
|
-
if (Array.isArray(
|
|
751
|
-
if (
|
|
752
|
-
return mapValue(
|
|
520
|
+
if (Array.isArray(val)) return val.map(mapValue);
|
|
521
|
+
if (val === void 0 || val === null) return val;
|
|
522
|
+
return mapValue(val);
|
|
753
523
|
};
|
|
754
|
-
const coerceValue = (
|
|
755
|
-
if (!fieldDef) return
|
|
524
|
+
const coerceValue = (val, fieldDef) => {
|
|
525
|
+
if (!fieldDef) return val;
|
|
756
526
|
const fieldType = fieldDef?.name ?? "text";
|
|
757
|
-
const
|
|
758
|
-
if (fieldType === "number" && typeof
|
|
759
|
-
const parsed = Number(
|
|
760
|
-
return Number.isNaN(parsed) ?
|
|
527
|
+
const fieldOptions = fieldDef?.["~options"] ?? {};
|
|
528
|
+
if (fieldType === "number" && typeof val === "string") {
|
|
529
|
+
const parsed = Number(val);
|
|
530
|
+
return Number.isNaN(parsed) ? val : parsed;
|
|
761
531
|
}
|
|
762
|
-
if ((fieldType === "checkbox" || fieldType === "switch") && typeof
|
|
763
|
-
if (
|
|
764
|
-
if (
|
|
532
|
+
if ((fieldType === "checkbox" || fieldType === "switch") && typeof val === "string") {
|
|
533
|
+
if (val === "true") return true;
|
|
534
|
+
if (val === "false") return false;
|
|
765
535
|
}
|
|
766
|
-
if (fieldType === "select") return normalizeSelectValue(
|
|
767
|
-
return
|
|
536
|
+
if (fieldType === "select") return normalizeSelectValue(val, fieldOptions);
|
|
537
|
+
return val;
|
|
768
538
|
};
|
|
769
|
-
const toArray = (
|
|
770
|
-
if (Array.isArray(
|
|
771
|
-
if (
|
|
772
|
-
return [
|
|
539
|
+
const toArray = (val) => {
|
|
540
|
+
if (Array.isArray(val)) return val;
|
|
541
|
+
if (val === void 0 || val === null || val === "") return [];
|
|
542
|
+
return [val];
|
|
773
543
|
};
|
|
774
|
-
const buildRelationCondition = (operator,
|
|
544
|
+
const buildRelationCondition = (operator, val, relationType) => {
|
|
775
545
|
const isMultiple = relationType === "multiple";
|
|
776
|
-
const ids = toArray(
|
|
546
|
+
const ids = toArray(val);
|
|
777
547
|
switch (operator) {
|
|
778
|
-
case "equals": return isMultiple ? { some: { id:
|
|
779
|
-
case "not_equals": return isMultiple ? { none: { id:
|
|
548
|
+
case "equals": return isMultiple ? { some: { id: val } } : { is: { id: val } };
|
|
549
|
+
case "not_equals": return isMultiple ? { none: { id: val } } : { isNot: { id: val } };
|
|
780
550
|
case "in": return isMultiple ? { some: { id: { in: ids } } } : { is: { id: { in: ids } } };
|
|
781
551
|
case "not_in": return isMultiple ? { none: { id: { in: ids } } } : { isNot: { id: { in: ids } } };
|
|
782
552
|
case "some": return { some: { id: { in: ids } } };
|
|
@@ -788,63 +558,63 @@ function TableViewInner({ collection, config, viewConfig, navigate, basePath = "
|
|
|
788
558
|
}
|
|
789
559
|
};
|
|
790
560
|
for (const filter of viewState.config.filters) {
|
|
791
|
-
const { field
|
|
792
|
-
if (!
|
|
793
|
-
const
|
|
794
|
-
const
|
|
795
|
-
const
|
|
796
|
-
const relationName =
|
|
561
|
+
const { field, operator, value } = filter;
|
|
562
|
+
if (!field || field === "_title") continue;
|
|
563
|
+
const fieldDef = resolvedFields?.[field];
|
|
564
|
+
const fieldType = fieldDef?.name ?? "text";
|
|
565
|
+
const fieldOptions = fieldDef?.["~options"] ?? {};
|
|
566
|
+
const relationName = fieldType === "relation" ? fieldOptions.relationName ?? field : void 0;
|
|
797
567
|
const hasRelation = relationName && (relationNames.length === 0 || relationNames.includes(relationName));
|
|
798
|
-
const isRelationField =
|
|
799
|
-
if (
|
|
800
|
-
const normalizedValue = coerceValue(value,
|
|
568
|
+
const isRelationField = fieldType === "relation" && !!hasRelation;
|
|
569
|
+
if (operator !== "is_empty" && operator !== "is_not_empty" && isEmptyValue(value)) continue;
|
|
570
|
+
const normalizedValue = coerceValue(value, fieldDef);
|
|
801
571
|
if (isRelationField && relationName) {
|
|
802
|
-
const condition = buildRelationCondition(
|
|
572
|
+
const condition = buildRelationCondition(operator, normalizedValue, fieldOptions.type === "multiple" ? "multiple" : "single");
|
|
803
573
|
if (condition) whereConditions[relationName] = condition;
|
|
804
574
|
continue;
|
|
805
575
|
}
|
|
806
|
-
switch (
|
|
576
|
+
switch (operator) {
|
|
807
577
|
case "equals":
|
|
808
|
-
whereConditions[
|
|
578
|
+
whereConditions[field] = normalizedValue;
|
|
809
579
|
break;
|
|
810
580
|
case "not_equals":
|
|
811
|
-
whereConditions[
|
|
581
|
+
whereConditions[field] = { ne: normalizedValue };
|
|
812
582
|
break;
|
|
813
583
|
case "contains":
|
|
814
|
-
whereConditions[
|
|
584
|
+
whereConditions[field] = { contains: normalizedValue };
|
|
815
585
|
break;
|
|
816
586
|
case "not_contains":
|
|
817
|
-
whereConditions[
|
|
587
|
+
whereConditions[field] = { notIlike: `%${normalizedValue}%` };
|
|
818
588
|
break;
|
|
819
589
|
case "starts_with":
|
|
820
|
-
whereConditions[
|
|
590
|
+
whereConditions[field] = { startsWith: normalizedValue };
|
|
821
591
|
break;
|
|
822
592
|
case "ends_with":
|
|
823
|
-
whereConditions[
|
|
593
|
+
whereConditions[field] = { endsWith: normalizedValue };
|
|
824
594
|
break;
|
|
825
595
|
case "greater_than":
|
|
826
|
-
whereConditions[
|
|
596
|
+
whereConditions[field] = { gt: normalizedValue };
|
|
827
597
|
break;
|
|
828
598
|
case "less_than":
|
|
829
|
-
whereConditions[
|
|
599
|
+
whereConditions[field] = { lt: normalizedValue };
|
|
830
600
|
break;
|
|
831
601
|
case "greater_than_or_equal":
|
|
832
|
-
whereConditions[
|
|
602
|
+
whereConditions[field] = { gte: normalizedValue };
|
|
833
603
|
break;
|
|
834
604
|
case "less_than_or_equal":
|
|
835
|
-
whereConditions[
|
|
605
|
+
whereConditions[field] = { lte: normalizedValue };
|
|
836
606
|
break;
|
|
837
607
|
case "in":
|
|
838
|
-
whereConditions[
|
|
608
|
+
whereConditions[field] = { in: Array.isArray(normalizedValue) ? normalizedValue : [normalizedValue] };
|
|
839
609
|
break;
|
|
840
610
|
case "not_in":
|
|
841
|
-
whereConditions[
|
|
611
|
+
whereConditions[field] = { notIn: Array.isArray(normalizedValue) ? normalizedValue : [normalizedValue] };
|
|
842
612
|
break;
|
|
843
613
|
case "is_empty":
|
|
844
|
-
whereConditions[
|
|
614
|
+
whereConditions[field] = { isNull: true };
|
|
845
615
|
break;
|
|
846
616
|
case "is_not_empty":
|
|
847
|
-
whereConditions[
|
|
617
|
+
whereConditions[field] = { isNotNull: true };
|
|
848
618
|
break;
|
|
849
619
|
}
|
|
850
620
|
}
|
|
@@ -896,12 +666,12 @@ function TableViewInner({ collection, config, viewConfig, navigate, basePath = "
|
|
|
896
666
|
const groupableNames = groupingConfig?.fields ?? [];
|
|
897
667
|
if (groupableNames.length === 0) return [];
|
|
898
668
|
const groupableSet = new Set(groupableNames);
|
|
899
|
-
return availableFields.filter((
|
|
669
|
+
return availableFields.filter((field) => groupableSet.has(field.name));
|
|
900
670
|
}, [availableFields, groupingConfig?.fields]);
|
|
901
671
|
const visibleColumnDefs = useMemo(() => {
|
|
902
672
|
const selectCol = {
|
|
903
673
|
id: "_select",
|
|
904
|
-
header: ({ table:
|
|
674
|
+
header: ({ table: t$1 }) => {
|
|
905
675
|
if (isReorderMode) return /* @__PURE__ */ jsx("div", {
|
|
906
676
|
className: "text-muted-foreground/60 flex h-8 items-center justify-center",
|
|
907
677
|
title: "Order",
|
|
@@ -911,16 +681,16 @@ function TableViewInner({ collection, config, viewConfig, navigate, basePath = "
|
|
|
911
681
|
className: "size-3.5"
|
|
912
682
|
})
|
|
913
683
|
});
|
|
914
|
-
const isAllSelected =
|
|
915
|
-
const isSomeSelected =
|
|
684
|
+
const isAllSelected = t$1.getIsAllPageRowsSelected();
|
|
685
|
+
const isSomeSelected = t$1.getIsSomePageRowsSelected();
|
|
916
686
|
return /* @__PURE__ */ jsx("div", {
|
|
917
687
|
role: "presentation",
|
|
918
688
|
onClick: (e) => e.stopPropagation(),
|
|
919
|
-
onKeyDown: (
|
|
689
|
+
onKeyDown: (e) => e.stopPropagation(),
|
|
920
690
|
children: /* @__PURE__ */ jsx(Checkbox, {
|
|
921
691
|
checked: isAllSelected,
|
|
922
692
|
indeterminate: !isAllSelected && isSomeSelected,
|
|
923
|
-
onCheckedChange: (checked) =>
|
|
693
|
+
onCheckedChange: (checked) => t$1.toggleAllPageRowsSelected(!!checked),
|
|
924
694
|
"aria-label": "Select all"
|
|
925
695
|
})
|
|
926
696
|
});
|
|
@@ -929,12 +699,12 @@ function TableViewInner({ collection, config, viewConfig, navigate, basePath = "
|
|
|
929
699
|
if (isReorderMode) return /* @__PURE__ */ jsx(ReorderHandle, {});
|
|
930
700
|
return /* @__PURE__ */ jsx("div", {
|
|
931
701
|
role: "presentation",
|
|
932
|
-
onClick: (
|
|
933
|
-
onKeyDown: (
|
|
702
|
+
onClick: (e) => e.stopPropagation(),
|
|
703
|
+
onKeyDown: (e) => e.stopPropagation(),
|
|
934
704
|
children: /* @__PURE__ */ jsx(Checkbox, {
|
|
935
705
|
checked: row.getIsSelected(),
|
|
936
706
|
disabled: !row.getCanSelect(),
|
|
937
|
-
onCheckedChange: (
|
|
707
|
+
onCheckedChange: (checked) => row.toggleSelected(!!checked),
|
|
938
708
|
"aria-label": "Select row"
|
|
939
709
|
})
|
|
940
710
|
});
|
|
@@ -946,13 +716,13 @@ function TableViewInner({ collection, config, viewConfig, navigate, basePath = "
|
|
|
946
716
|
const titleFieldName = collectionMeta?.title?.fieldName;
|
|
947
717
|
const titleColName = collectionMeta?.title?.type === "field" && titleFieldName ? titleFieldName : "_title";
|
|
948
718
|
const orderedColumns = [selectCol];
|
|
949
|
-
const titleCol = columns.find((c
|
|
719
|
+
const titleCol = columns.find((c) => c.accessorKey === titleColName || c.id === titleColName);
|
|
950
720
|
if (titleCol) orderedColumns.push(titleCol);
|
|
951
|
-
const columnsToShow = viewState.config.visibleColumns.length > 0 ? viewState.config.visibleColumns : defaultColumns.length > 0 ? defaultColumns : columns.map((
|
|
721
|
+
const columnsToShow = viewState.config.visibleColumns.length > 0 ? viewState.config.visibleColumns : defaultColumns.length > 0 ? defaultColumns : columns.map((c) => c.accessorKey || c.id).filter(Boolean);
|
|
952
722
|
const columnMap = /* @__PURE__ */ new Map();
|
|
953
|
-
for (const
|
|
954
|
-
const key =
|
|
955
|
-
if (key) columnMap.set(key,
|
|
723
|
+
for (const c of columns) {
|
|
724
|
+
const key = c.accessorKey || c.id;
|
|
725
|
+
if (key) columnMap.set(key, c);
|
|
956
726
|
}
|
|
957
727
|
for (const colName of columnsToShow) {
|
|
958
728
|
if (colName === titleColName) continue;
|
|
@@ -965,19 +735,19 @@ function TableViewInner({ collection, config, viewConfig, navigate, basePath = "
|
|
|
965
735
|
className: "sr-only",
|
|
966
736
|
children: t("common.actions")
|
|
967
737
|
}),
|
|
968
|
-
cell: ({ row
|
|
738
|
+
cell: ({ row }) => /* @__PURE__ */ jsx("div", {
|
|
969
739
|
role: "presentation",
|
|
970
740
|
className: "flex justify-end gap-1",
|
|
971
741
|
onClick: (event) => event.stopPropagation(),
|
|
972
|
-
onKeyDown: (
|
|
742
|
+
onKeyDown: (event) => event.stopPropagation(),
|
|
973
743
|
children: actions.row.map((action) => /* @__PURE__ */ jsx(ActionButton, {
|
|
974
744
|
action,
|
|
975
745
|
collection,
|
|
976
|
-
item:
|
|
746
|
+
item: row.original,
|
|
977
747
|
helpers: actionHelpers,
|
|
978
748
|
size: "icon-sm",
|
|
979
749
|
iconOnly: true,
|
|
980
|
-
onOpenDialog: (
|
|
750
|
+
onOpenDialog: (dialogAction$1) => openDialog(dialogAction$1, row.original)
|
|
981
751
|
}, action.id))
|
|
982
752
|
}),
|
|
983
753
|
size: 72,
|
|
@@ -1035,26 +805,26 @@ function TableViewInner({ collection, config, viewConfig, navigate, basePath = "
|
|
|
1035
805
|
return;
|
|
1036
806
|
}
|
|
1037
807
|
setOptimisticOrderIds((current) => {
|
|
1038
|
-
const itemIds = items.map((
|
|
808
|
+
const itemIds = items.map((item) => String(item.id));
|
|
1039
809
|
if (!current) return itemIds;
|
|
1040
810
|
const knownIds = new Set(itemIds);
|
|
1041
811
|
const next = current.filter((id) => knownIds.has(id));
|
|
1042
|
-
for (const
|
|
812
|
+
for (const id of itemIds) if (!next.includes(id)) next.push(id);
|
|
1043
813
|
return next;
|
|
1044
814
|
});
|
|
1045
815
|
}, [isReorderMode, items]);
|
|
1046
816
|
const filteredItems = useMemo(() => {
|
|
1047
817
|
if (!isReorderMode || !optimisticOrderIds) return items;
|
|
1048
|
-
const itemsById = new Map(items.map((
|
|
818
|
+
const itemsById = new Map(items.map((item) => [String(item.id), item]));
|
|
1049
819
|
const seen = /* @__PURE__ */ new Set();
|
|
1050
|
-
const ordered = optimisticOrderIds.map((
|
|
1051
|
-
const
|
|
1052
|
-
if (
|
|
1053
|
-
return
|
|
820
|
+
const ordered = optimisticOrderIds.map((id) => {
|
|
821
|
+
const item = itemsById.get(id);
|
|
822
|
+
if (item) seen.add(id);
|
|
823
|
+
return item;
|
|
1054
824
|
}).filter(Boolean);
|
|
1055
|
-
for (const
|
|
1056
|
-
const
|
|
1057
|
-
if (!seen.has(
|
|
825
|
+
for (const item of items) {
|
|
826
|
+
const id = String(item.id);
|
|
827
|
+
if (!seen.has(id)) ordered.push(item);
|
|
1058
828
|
}
|
|
1059
829
|
return ordered;
|
|
1060
830
|
}, [
|
|
@@ -1109,7 +879,7 @@ function TableViewInner({ collection, config, viewConfig, navigate, basePath = "
|
|
|
1109
879
|
onSortingChange: handleSortingChange,
|
|
1110
880
|
enableRowSelection: true,
|
|
1111
881
|
onRowSelectionChange: setRowSelection,
|
|
1112
|
-
getRowId: (
|
|
882
|
+
getRowId: (row) => row.id,
|
|
1113
883
|
state: {
|
|
1114
884
|
sorting,
|
|
1115
885
|
rowSelection
|
|
@@ -1119,31 +889,31 @@ function TableViewInner({ collection, config, viewConfig, navigate, basePath = "
|
|
|
1119
889
|
const visibleLeafColumns = table.getVisibleLeafColumns();
|
|
1120
890
|
const selectColumnWidth = getColumnSize(visibleLeafColumns[0], 40);
|
|
1121
891
|
const titleColumnWidth = getColumnSize(visibleLeafColumns[1], 360);
|
|
1122
|
-
const sortableRowIds = useMemo(() => tableRows.map((
|
|
1123
|
-
const activeReorderRow = useMemo(() => activeReorderId ? tableRows.find((
|
|
892
|
+
const sortableRowIds = useMemo(() => tableRows.map((row) => String(row.id)), [tableRows]);
|
|
893
|
+
const activeReorderRow = useMemo(() => activeReorderId ? tableRows.find((row) => String(row.id) === activeReorderId) : null, [activeReorderId, tableRows]);
|
|
1124
894
|
const reorderSensors = useSensors(useSensor(PointerSensor, { activationConstraint: { distance: 4 } }), useSensor(KeyboardSensor, { coordinateGetter: sortableKeyboardCoordinates }));
|
|
1125
|
-
const handleReorderDragStart = React.useCallback((
|
|
1126
|
-
const initialRect =
|
|
895
|
+
const handleReorderDragStart = React.useCallback((event) => {
|
|
896
|
+
const initialRect = event.active.rect.current.initial;
|
|
1127
897
|
clearReorderOverlay();
|
|
1128
898
|
reorderStartOrderIdsRef.current = sortableRowIds;
|
|
1129
|
-
setActiveReorderId(String(
|
|
899
|
+
setActiveReorderId(String(event.active.id));
|
|
1130
900
|
setActiveReorderRect(initialRect ? {
|
|
1131
901
|
width: initialRect.width,
|
|
1132
902
|
height: initialRect.height
|
|
1133
903
|
} : null);
|
|
1134
|
-
setOptimisticOrderIds((
|
|
904
|
+
setOptimisticOrderIds((current) => current ?? sortableRowIds);
|
|
1135
905
|
}, [clearReorderOverlay, sortableRowIds]);
|
|
1136
906
|
const handleReorderDragCancel = React.useCallback(() => {
|
|
1137
907
|
setOptimisticOrderIds(reorderStartOrderIdsRef.current);
|
|
1138
908
|
clearReorderOverlay();
|
|
1139
909
|
reorderStartOrderIdsRef.current = null;
|
|
1140
910
|
}, [clearReorderOverlay]);
|
|
1141
|
-
const handleReorderDragEnd = React.useCallback(async (
|
|
911
|
+
const handleReorderDragEnd = React.useCallback(async (event) => {
|
|
1142
912
|
if (updateBatchMutation.isPending) {
|
|
1143
913
|
clearReorderOverlay();
|
|
1144
914
|
return;
|
|
1145
915
|
}
|
|
1146
|
-
const { active
|
|
916
|
+
const { active, over } = event;
|
|
1147
917
|
const previousOrderIds = reorderStartOrderIdsRef.current ?? sortableRowIds;
|
|
1148
918
|
reorderStartOrderIdsRef.current = null;
|
|
1149
919
|
if (!over) {
|
|
@@ -1152,8 +922,8 @@ function TableViewInner({ collection, config, viewConfig, navigate, basePath = "
|
|
|
1152
922
|
return;
|
|
1153
923
|
}
|
|
1154
924
|
let nextOrderIds = previousOrderIds;
|
|
1155
|
-
if (
|
|
1156
|
-
const oldIndex = previousOrderIds.indexOf(String(
|
|
925
|
+
if (active.id !== over.id) {
|
|
926
|
+
const oldIndex = previousOrderIds.indexOf(String(active.id));
|
|
1157
927
|
const newIndex = previousOrderIds.indexOf(String(over.id));
|
|
1158
928
|
if (oldIndex === -1 || newIndex === -1 || oldIndex === newIndex) {
|
|
1159
929
|
clearReorderOverlay(REORDER_DROP_DURATION);
|
|
@@ -1167,11 +937,11 @@ function TableViewInner({ collection, config, viewConfig, navigate, basePath = "
|
|
|
1167
937
|
}
|
|
1168
938
|
setOptimisticOrderIds(nextOrderIds);
|
|
1169
939
|
clearReorderOverlay(REORDER_DROP_DURATION);
|
|
1170
|
-
const rowsById = new Map(tableRows.map((
|
|
1171
|
-
const reorderedRows = nextOrderIds.map((
|
|
940
|
+
const rowsById = new Map(tableRows.map((row) => [String(row.id), row]));
|
|
941
|
+
const reorderedRows = nextOrderIds.map((id) => rowsById.get(id)).filter((row) => !!row);
|
|
1172
942
|
try {
|
|
1173
|
-
await updateBatchMutation.mutateAsync({ updates: reorderedRows.map((
|
|
1174
|
-
id: String(
|
|
943
|
+
await updateBatchMutation.mutateAsync({ updates: reorderedRows.map((row, index) => ({
|
|
944
|
+
id: String(row.id),
|
|
1175
945
|
data: { [orderField]: (index + 1) * orderStep }
|
|
1176
946
|
})) });
|
|
1177
947
|
actionHelpers.toast.success(t("collection.orderSaved"));
|
|
@@ -1192,59 +962,59 @@ function TableViewInner({ collection, config, viewConfig, navigate, basePath = "
|
|
|
1192
962
|
]);
|
|
1193
963
|
const groupedRowModel = useMemo(() => {
|
|
1194
964
|
const rows = tableRows;
|
|
1195
|
-
const
|
|
1196
|
-
if (!
|
|
965
|
+
const groupBy = viewState.config.groupBy;
|
|
966
|
+
if (!groupBy) return rows.map((row) => ({
|
|
1197
967
|
type: "row",
|
|
1198
|
-
row
|
|
968
|
+
row
|
|
1199
969
|
}));
|
|
1200
|
-
const groupField = groupableFields.find((
|
|
970
|
+
const groupField = groupableFields.find((field) => field.name === groupBy);
|
|
1201
971
|
const collapsedGroups = new Set(viewState.config.collapsedGroups ?? []);
|
|
1202
972
|
const serverGroups = !isSearching ? listData?.groups : void 0;
|
|
1203
973
|
if (serverGroups?.length) {
|
|
1204
|
-
const
|
|
974
|
+
const rowsById = new Map(rows.map((row) => [row.id, row]));
|
|
1205
975
|
return serverGroups.flatMap((group) => {
|
|
1206
976
|
const label = stringifyGroupValue(group.value, groupField, resolveText, t, uiLocale, t("common.noValue"));
|
|
1207
|
-
const groupKey = `${
|
|
977
|
+
const groupKey = `${groupBy}:${label}`;
|
|
1208
978
|
const collapsed = collapsedGroups.has(groupKey);
|
|
1209
|
-
const groupRows = (group.docs ?? []).map((doc) =>
|
|
979
|
+
const groupRows = (group.docs ?? []).map((doc) => rowsById.get(String(doc.id))).filter(Boolean);
|
|
1210
980
|
return [{
|
|
1211
981
|
type: "group",
|
|
1212
982
|
key: groupKey,
|
|
1213
983
|
label,
|
|
1214
984
|
count: group.count,
|
|
1215
985
|
collapsed
|
|
1216
|
-
}, ...collapsed ? [] : groupRows.map((
|
|
986
|
+
}, ...collapsed ? [] : groupRows.map((row) => ({
|
|
1217
987
|
type: "row",
|
|
1218
|
-
row
|
|
988
|
+
row
|
|
1219
989
|
}))];
|
|
1220
990
|
});
|
|
1221
991
|
}
|
|
1222
992
|
const groups = /* @__PURE__ */ new Map();
|
|
1223
|
-
for (const
|
|
1224
|
-
const valueLabel = stringifyGroupValue(
|
|
1225
|
-
const
|
|
1226
|
-
const
|
|
1227
|
-
if (
|
|
1228
|
-
|
|
993
|
+
for (const row of rows) {
|
|
994
|
+
const valueLabel = stringifyGroupValue(row.original?.[groupBy], groupField, resolveText, t, uiLocale, t("common.noValue"));
|
|
995
|
+
const groupKey = `${groupBy}:${valueLabel}`;
|
|
996
|
+
const group = groups.get(groupKey);
|
|
997
|
+
if (group) {
|
|
998
|
+
group.rows.push(row);
|
|
1229
999
|
continue;
|
|
1230
1000
|
}
|
|
1231
|
-
groups.set(
|
|
1001
|
+
groups.set(groupKey, {
|
|
1232
1002
|
label: valueLabel,
|
|
1233
|
-
rows: [
|
|
1234
|
-
sortIndex: getGroupSortIndex(
|
|
1003
|
+
rows: [row],
|
|
1004
|
+
sortIndex: getGroupSortIndex(row.original?.[groupBy], groupField)
|
|
1235
1005
|
});
|
|
1236
1006
|
}
|
|
1237
|
-
return Array.from(groups.entries()).sort(([, a], [, b]) => a.sortIndex - b.sortIndex).flatMap(([
|
|
1238
|
-
const
|
|
1007
|
+
return Array.from(groups.entries()).sort(([, a], [, b]) => a.sortIndex - b.sortIndex).flatMap(([key, group]) => {
|
|
1008
|
+
const collapsed = collapsedGroups.has(key);
|
|
1239
1009
|
return [{
|
|
1240
1010
|
type: "group",
|
|
1241
|
-
key
|
|
1242
|
-
label:
|
|
1243
|
-
count:
|
|
1244
|
-
collapsed
|
|
1245
|
-
}, ...
|
|
1011
|
+
key,
|
|
1012
|
+
label: group.label,
|
|
1013
|
+
count: group.rows.length,
|
|
1014
|
+
collapsed
|
|
1015
|
+
}, ...collapsed ? [] : group.rows.map((row) => ({
|
|
1246
1016
|
type: "row",
|
|
1247
|
-
row
|
|
1017
|
+
row
|
|
1248
1018
|
}))];
|
|
1249
1019
|
});
|
|
1250
1020
|
}, [
|
|
@@ -1258,22 +1028,22 @@ function TableViewInner({ collection, config, viewConfig, navigate, basePath = "
|
|
|
1258
1028
|
t,
|
|
1259
1029
|
uiLocale
|
|
1260
1030
|
]);
|
|
1261
|
-
const handleSaveView = (name,
|
|
1031
|
+
const handleSaveView = (name, config$1) => {
|
|
1262
1032
|
saveViewMutation.mutate({
|
|
1263
1033
|
name,
|
|
1264
|
-
configuration:
|
|
1034
|
+
configuration: config$1
|
|
1265
1035
|
});
|
|
1266
1036
|
};
|
|
1267
1037
|
const handleDeleteView = (viewId) => {
|
|
1268
1038
|
deleteViewMutation.mutate(viewId);
|
|
1269
1039
|
};
|
|
1270
|
-
const handleRowClick = (
|
|
1271
|
-
navigate(`${basePath}/collections/${collection}/${
|
|
1040
|
+
const handleRowClick = (item) => {
|
|
1041
|
+
navigate(`${basePath}/collections/${collection}/${item.id}`);
|
|
1272
1042
|
};
|
|
1273
|
-
const handleBulkDelete = React.useCallback(async (
|
|
1274
|
-
const results = await Promise.allSettled(
|
|
1043
|
+
const handleBulkDelete = React.useCallback(async (ids) => {
|
|
1044
|
+
const results = await Promise.allSettled(ids.map((id) => deleteMutation.mutateAsync({ id })));
|
|
1275
1045
|
const successCount = results.filter((r) => r.status === "fulfilled").length;
|
|
1276
|
-
const failCount = results.filter((
|
|
1046
|
+
const failCount = results.filter((r) => r.status === "rejected").length;
|
|
1277
1047
|
if (failCount === 0) actionHelpers.toast.success(t("collection.bulkDeleteSuccess", { count: successCount }));
|
|
1278
1048
|
else if (successCount === 0) actionHelpers.toast.error(t("collection.bulkDeleteError"));
|
|
1279
1049
|
else actionHelpers.toast.warning(t("collection.bulkDeletePartial", {
|
|
@@ -1285,15 +1055,15 @@ function TableViewInner({ collection, config, viewConfig, navigate, basePath = "
|
|
|
1285
1055
|
actionHelpers,
|
|
1286
1056
|
t
|
|
1287
1057
|
]);
|
|
1288
|
-
const handleBulkRestore = React.useCallback(async (
|
|
1289
|
-
const
|
|
1290
|
-
const
|
|
1291
|
-
const
|
|
1292
|
-
if (
|
|
1293
|
-
else if (
|
|
1058
|
+
const handleBulkRestore = React.useCallback(async (ids) => {
|
|
1059
|
+
const results = await Promise.allSettled(ids.map((id) => restoreMutation.mutateAsync({ id })));
|
|
1060
|
+
const successCount = results.filter((r) => r.status === "fulfilled").length;
|
|
1061
|
+
const failCount = results.filter((r) => r.status === "rejected").length;
|
|
1062
|
+
if (failCount === 0) actionHelpers.toast.success(t("collection.bulkRestoreSuccess", { count: successCount }));
|
|
1063
|
+
else if (successCount === 0) actionHelpers.toast.error(t("collection.bulkRestoreError"));
|
|
1294
1064
|
else actionHelpers.toast.warning(t("collection.bulkRestorePartial", {
|
|
1295
|
-
success:
|
|
1296
|
-
failed:
|
|
1065
|
+
success: successCount,
|
|
1066
|
+
failed: failCount
|
|
1297
1067
|
}));
|
|
1298
1068
|
}, [
|
|
1299
1069
|
restoreMutation,
|
|
@@ -1402,7 +1172,7 @@ function TableViewInner({ collection, config, viewConfig, navigate, basePath = "
|
|
|
1402
1172
|
actions: actions.header,
|
|
1403
1173
|
collection,
|
|
1404
1174
|
helpers: actionHelpers,
|
|
1405
|
-
onOpenDialog: (
|
|
1175
|
+
onOpenDialog: (action) => openDialog(action)
|
|
1406
1176
|
})
|
|
1407
1177
|
] })
|
|
1408
1178
|
}),
|
|
@@ -1414,7 +1184,7 @@ function TableViewInner({ collection, config, viewConfig, navigate, basePath = "
|
|
|
1414
1184
|
className: "max-w-xl",
|
|
1415
1185
|
children: /* @__PURE__ */ jsx(SearchInput, {
|
|
1416
1186
|
value: searchTerm,
|
|
1417
|
-
onChange: (
|
|
1187
|
+
onChange: (e) => setSearchTerm(e.target.value),
|
|
1418
1188
|
onClear: () => setSearchTerm(""),
|
|
1419
1189
|
placeholder: t("common.search"),
|
|
1420
1190
|
containerClassName: "h-10"
|
|
@@ -1458,7 +1228,7 @@ function TableViewInner({ collection, config, viewConfig, navigate, basePath = "
|
|
|
1458
1228
|
helpers: actionHelpers,
|
|
1459
1229
|
totalCount: isSearching ? searchData?.total : listData?.totalDocs,
|
|
1460
1230
|
pageCount: filteredItems.length,
|
|
1461
|
-
onOpenDialog: (
|
|
1231
|
+
onOpenDialog: (action, items$1) => openDialog(action, items$1),
|
|
1462
1232
|
onBulkDelete: handleBulkDelete,
|
|
1463
1233
|
onBulkRestore: handleBulkRestore,
|
|
1464
1234
|
filterCount: viewState.config.filters.length,
|
|
@@ -1549,28 +1319,28 @@ function TableViewInner({ collection, config, viewConfig, navigate, basePath = "
|
|
|
1549
1319
|
})
|
|
1550
1320
|
]
|
|
1551
1321
|
}, entry.key);
|
|
1552
|
-
const
|
|
1553
|
-
const isRowDeleted = !!
|
|
1322
|
+
const row = entry.row;
|
|
1323
|
+
const isRowDeleted = !!row.original?.deletedAt;
|
|
1554
1324
|
return /* @__PURE__ */ jsx(isReorderMode ? SortableTableRow : TableRow, {
|
|
1555
|
-
id: String(
|
|
1556
|
-
"data-state":
|
|
1557
|
-
className: cn("group", isReorderMode && "bg-muted/[0.18]", isHighlighted(
|
|
1558
|
-
children:
|
|
1559
|
-
const
|
|
1560
|
-
const
|
|
1561
|
-
const
|
|
1325
|
+
id: String(row.id),
|
|
1326
|
+
"data-state": row.getIsSelected() && "selected",
|
|
1327
|
+
className: cn("group", isReorderMode && "bg-muted/[0.18]", isHighlighted(row.id) && "animate-realtime-pulse", isRowDeleted && "opacity-50"),
|
|
1328
|
+
children: row.getVisibleCells().map((cell, cellIndex) => {
|
|
1329
|
+
const isCheckboxCol = cellIndex === 0;
|
|
1330
|
+
const columnWidth = getColumnSize(cell.column, isCheckboxCol ? 40 : 120);
|
|
1331
|
+
const stickyLeft = cellIndex < STICKY_TABLE_COLUMN_COUNT ? getStickyLeftOffset(visibleLeafColumns, cellIndex) : void 0;
|
|
1562
1332
|
const isTitleCol = cellIndex === 1;
|
|
1563
1333
|
return /* @__PURE__ */ jsx(TableCell, {
|
|
1564
|
-
stickyLeft
|
|
1334
|
+
stickyLeft,
|
|
1565
1335
|
showStickyBorder: cellIndex === STICKY_TABLE_COLUMN_COUNT - 1,
|
|
1566
|
-
className:
|
|
1567
|
-
style: getColumnSizeStyle(
|
|
1336
|
+
className: isCheckboxCol ? "w-9 min-w-9 px-1.5" : void 0,
|
|
1337
|
+
style: getColumnSizeStyle(columnWidth),
|
|
1568
1338
|
children: isTitleCol ? /* @__PURE__ */ jsxs("div", {
|
|
1569
1339
|
className: "flex min-w-0 items-center gap-2",
|
|
1570
1340
|
children: [
|
|
1571
1341
|
/* @__PURE__ */ jsx("button", {
|
|
1572
1342
|
type: "button",
|
|
1573
|
-
onClick: () => handleRowClick(
|
|
1343
|
+
onClick: () => handleRowClick(row.original),
|
|
1574
1344
|
disabled: isReorderMode,
|
|
1575
1345
|
className: cn("decoration-muted-foreground/50 hover:decoration-foreground max-w-full min-w-0 text-left underline underline-offset-2 transition-colors disabled:cursor-default disabled:no-underline", !isReorderMode && "cursor-pointer"),
|
|
1576
1346
|
children: flexRender(cell.column.columnDef.cell, cell.getContext())
|
|
@@ -1582,14 +1352,14 @@ function TableViewInner({ collection, config, viewConfig, navigate, basePath = "
|
|
|
1582
1352
|
className: "size-3"
|
|
1583
1353
|
}), t("common.deleted")]
|
|
1584
1354
|
}),
|
|
1585
|
-
isDocLocked(
|
|
1586
|
-
const lock = getLock(
|
|
1587
|
-
const
|
|
1355
|
+
isDocLocked(row.id) && (() => {
|
|
1356
|
+
const lock = getLock(row.id);
|
|
1357
|
+
const user$1 = lock ? getLockUser(lock) : null;
|
|
1588
1358
|
return /* @__PURE__ */ jsxs("span", {
|
|
1589
1359
|
className: "text-muted-foreground bg-muted inline-flex items-center gap-1 rounded-full px-1.5 py-0.5 text-xs",
|
|
1590
|
-
title:
|
|
1591
|
-
children: [
|
|
1592
|
-
src:
|
|
1360
|
+
title: user$1?.name ?? user$1?.email ?? "Someone is editing",
|
|
1361
|
+
children: [user$1?.image ? /* @__PURE__ */ jsx("img", {
|
|
1362
|
+
src: user$1.image,
|
|
1593
1363
|
alt: "",
|
|
1594
1364
|
className: "image-outline size-4 rounded-full"
|
|
1595
1365
|
}) : /* @__PURE__ */ jsx(Icon, {
|
|
@@ -1597,7 +1367,7 @@ function TableViewInner({ collection, config, viewConfig, navigate, basePath = "
|
|
|
1597
1367
|
className: "size-3"
|
|
1598
1368
|
}), /* @__PURE__ */ jsx("span", {
|
|
1599
1369
|
className: "max-w-20 truncate",
|
|
1600
|
-
children:
|
|
1370
|
+
children: user$1?.name?.split(" ")[0] ?? t("table.editing")
|
|
1601
1371
|
})]
|
|
1602
1372
|
});
|
|
1603
1373
|
})()
|
|
@@ -1605,7 +1375,7 @@ function TableViewInner({ collection, config, viewConfig, navigate, basePath = "
|
|
|
1605
1375
|
}) : flexRender(cell.column.columnDef.cell, cell.getContext())
|
|
1606
1376
|
}, cell.id);
|
|
1607
1377
|
})
|
|
1608
|
-
},
|
|
1378
|
+
}, row.id);
|
|
1609
1379
|
}) })
|
|
1610
1380
|
})
|
|
1611
1381
|
]
|
|
@@ -1649,7 +1419,7 @@ function TableViewInner({ collection, config, viewConfig, navigate, basePath = "
|
|
|
1649
1419
|
children: t("table.show")
|
|
1650
1420
|
}), /* @__PURE__ */ jsxs(Select, {
|
|
1651
1421
|
value: String(viewState.config.pagination?.pageSize ?? 25),
|
|
1652
|
-
onValueChange: (
|
|
1422
|
+
onValueChange: (value) => viewState.setPageSize(Number(value)),
|
|
1653
1423
|
children: [/* @__PURE__ */ jsx(SelectTrigger, {
|
|
1654
1424
|
className: "h-8 w-[70px]",
|
|
1655
1425
|
children: /* @__PURE__ */ jsx(SelectValue, {})
|
|
@@ -1755,7 +1525,7 @@ function TableViewInner({ collection, config, viewConfig, navigate, basePath = "
|
|
|
1755
1525
|
}),
|
|
1756
1526
|
dialogAction && /* @__PURE__ */ jsx(ActionDialog, {
|
|
1757
1527
|
open: !!dialogAction,
|
|
1758
|
-
onOpenChange: (
|
|
1528
|
+
onOpenChange: (open) => !open && closeDialog(),
|
|
1759
1529
|
action: dialogAction,
|
|
1760
1530
|
collection,
|
|
1761
1531
|
item: dialogItem,
|