@questpie/admin 3.2.4 → 3.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/blocks/block-renderer.d.mts +2 -2
- package/dist/client/blocks/block-renderer.mjs +164 -339
- package/dist/client/components/actions/action-button.mjs +9 -9
- package/dist/client/components/actions/action-dialog.mjs +195 -493
- package/dist/client/components/actions/confirmation-dialog.mjs +44 -159
- package/dist/client/components/actions/header-actions.mjs +73 -165
- package/dist/client/components/admin-link.d.mts +2 -2
- package/dist/client/components/admin-link.mjs +40 -126
- package/dist/client/components/auth/auth-loading.mjs +9 -44
- package/dist/client/components/blocks/block-canvas.mjs +31 -95
- package/dist/client/components/blocks/block-editor-context.mjs +13 -57
- package/dist/client/components/blocks/block-editor-layout.mjs +72 -166
- package/dist/client/components/blocks/block-editor-provider.mjs +184 -245
- package/dist/client/components/blocks/block-fields-renderer.mjs +54 -229
- package/dist/client/components/blocks/block-insert-button.mjs +49 -165
- package/dist/client/components/blocks/block-item-menu.mjs +102 -301
- package/dist/client/components/blocks/block-item.mjs +136 -370
- package/dist/client/components/blocks/block-library-sidebar.mjs +103 -230
- package/dist/client/components/blocks/block-tree.mjs +12 -68
- package/dist/client/components/blocks/block-type-icon.mjs +14 -56
- package/dist/client/components/brand-logo.mjs +35 -149
- package/dist/client/components/component-renderer.mjs +42 -118
- package/dist/client/components/error-boundary.mjs +14 -58
- package/dist/client/components/fields/array-field.mjs +209 -521
- package/dist/client/components/fields/asset-preview-field.mjs +41 -141
- package/dist/client/components/fields/blocks-field/blocks-field.mjs +60 -156
- package/dist/client/components/fields/boolean-field.mjs +29 -59
- package/dist/client/components/fields/date-field.mjs +7 -37
- package/dist/client/components/fields/datetime-field.mjs +7 -38
- package/dist/client/components/fields/email-field.mjs +25 -54
- package/dist/client/components/fields/field-wrapper.mjs +30 -105
- package/dist/client/components/fields/json-field.mjs +94 -296
- package/dist/client/components/fields/locale-badge.mjs +6 -15
- package/dist/client/components/fields/number-field.mjs +27 -60
- package/dist/client/components/fields/object-array-field.mjs +283 -659
- package/dist/client/components/fields/object-field.mjs +165 -633
- package/dist/client/components/fields/relation/displays/cards-display.mjs +106 -220
- package/dist/client/components/fields/relation/displays/chips-display.mjs +78 -150
- package/dist/client/components/fields/relation/displays/grid-display.mjs +92 -186
- package/dist/client/components/fields/relation/displays/list-display.mjs +122 -239
- package/dist/client/components/fields/relation/displays/table-display.mjs +70 -244
- package/dist/client/components/fields/relation/relation-items-display.mjs +30 -126
- package/dist/client/components/fields/relation-field.mjs +10 -66
- package/dist/client/components/fields/relation-picker.mjs +18 -18
- package/dist/client/components/fields/relation-select.mjs +12 -12
- package/dist/client/components/fields/rich-text-editor/bubble-menu.mjs +80 -180
- package/dist/client/components/fields/rich-text-editor/image-popover.mjs +2 -2
- package/dist/client/components/fields/rich-text-editor/image-upload.mjs +13 -29
- package/dist/client/components/fields/rich-text-editor/index.mjs +195 -513
- package/dist/client/components/fields/rich-text-editor/slash-commands.mjs +61 -111
- package/dist/client/components/fields/rich-text-editor/table-controls.mjs +105 -415
- package/dist/client/components/fields/rich-text-editor/toolbar.mjs +256 -511
- package/dist/client/components/fields/rich-text-field.mjs +14 -53
- package/dist/client/components/fields/select-field.mjs +61 -72
- package/dist/client/components/fields/text-field.mjs +26 -59
- package/dist/client/components/fields/textarea-field.mjs +26 -58
- package/dist/client/components/fields/time-field.mjs +7 -35
- package/dist/client/components/fields/upload-field.mjs +47 -165
- package/dist/client/components/filter-builder/columns-tab.mjs +80 -280
- package/dist/client/components/filter-builder/filter-builder-sheet.mjs +197 -540
- package/dist/client/components/filter-builder/filters-tab.mjs +96 -386
- package/dist/client/components/filter-builder/saved-views-tab.mjs +133 -351
- package/dist/client/components/history-sidebar.mjs +285 -605
- package/dist/client/components/layout/field-layout-renderer.mjs +106 -254
- package/dist/client/components/locale-switcher.mjs +106 -228
- package/dist/client/components/media/media-grid.mjs +84 -273
- package/dist/client/components/media/media-picker-dialog.mjs +176 -476
- package/dist/client/components/preview/live-preview-mode.mjs +233 -458
- package/dist/client/components/preview/preview-pane.mjs +22 -22
- package/dist/client/components/primitives/asset-preview.mjs +290 -666
- package/dist/client/components/primitives/checkbox-input.mjs +9 -35
- package/dist/client/components/primitives/date-input.mjs +109 -327
- package/dist/client/components/primitives/dropzone.mjs +209 -336
- package/dist/client/components/primitives/field-select-control.mjs +12 -80
- package/dist/client/components/primitives/number-input.mjs +4 -4
- package/dist/client/components/primitives/select-multi.mjs +229 -572
- package/dist/client/components/primitives/select-single.mjs +179 -499
- package/dist/client/components/primitives/time-input.mjs +43 -117
- package/dist/client/components/primitives/toggle-input.mjs +9 -29
- package/dist/client/components/sheets/resource-sheet.mjs +61 -70
- package/dist/client/components/ui/accordion.mjs +35 -155
- package/dist/client/components/ui/alert.mjs +13 -68
- package/dist/client/components/ui/badge.mjs +9 -51
- package/dist/client/components/ui/button.mjs +8 -54
- package/dist/client/components/ui/card.mjs +37 -193
- package/dist/client/components/ui/checkbox.mjs +12 -68
- package/dist/client/components/ui/command.mjs +48 -219
- package/dist/client/components/ui/dialog.mjs +50 -262
- package/dist/client/components/ui/drawer.mjs +55 -259
- package/dist/client/components/ui/dropdown-menu.mjs +86 -427
- package/dist/client/components/ui/empty-state.mjs +28 -98
- package/dist/client/components/ui/field.mjs +73 -309
- package/dist/client/components/ui/input-group.mjs +42 -167
- package/dist/client/components/ui/input.mjs +7 -37
- package/dist/client/components/ui/kbd.mjs +6 -36
- package/dist/client/components/ui/label.mjs +7 -37
- package/dist/client/components/ui/popover.mjs +34 -169
- package/dist/client/components/ui/responsive-dialog.mjs +67 -273
- package/dist/client/components/ui/scroll-fade.mjs +63 -158
- package/dist/client/components/ui/search-input.mjs +33 -100
- package/dist/client/components/ui/select.mjs +72 -393
- package/dist/client/components/ui/separator.mjs +7 -38
- package/dist/client/components/ui/sheet.mjs +49 -269
- package/dist/client/components/ui/sidebar.mjs +171 -690
- package/dist/client/components/ui/skeleton.mjs +7 -38
- package/dist/client/components/ui/sonner.mjs +11 -42
- package/dist/client/components/ui/switch.mjs +9 -45
- package/dist/client/components/ui/table.mjs +48 -266
- package/dist/client/components/ui/tabs.mjs +26 -139
- package/dist/client/components/ui/textarea.mjs +6 -32
- package/dist/client/components/ui/tooltip.mjs +27 -129
- package/dist/client/components/widgets/chart-widget.mjs +174 -522
- package/dist/client/components/widgets/progress-widget.mjs +66 -172
- package/dist/client/components/widgets/quick-actions-widget.mjs +102 -261
- package/dist/client/components/widgets/recent-items-widget.mjs +69 -195
- package/dist/client/components/widgets/stats-widget.mjs +41 -175
- package/dist/client/components/widgets/table-widget.mjs +9 -9
- package/dist/client/components/widgets/timeline-widget.mjs +86 -226
- package/dist/client/components/widgets/value-widget.mjs +74 -381
- package/dist/client/components/widgets/widget-empty-state.mjs +26 -76
- package/dist/client/components/widgets/widget-skeletons.mjs +138 -421
- package/dist/client/contexts/focus-context.mjs +63 -146
- package/dist/client/hooks/typed-hooks.mjs +241 -701
- package/dist/client/hooks/use-action.mjs +62 -198
- package/dist/client/hooks/use-admin-config.mjs +5 -35
- package/dist/client/hooks/use-admin-preferences.mjs +16 -88
- package/dist/client/hooks/use-admin-routes.mjs +22 -56
- package/dist/client/hooks/use-audit-history.mjs +21 -69
- package/dist/client/hooks/use-brand.mjs +1 -9
- package/dist/client/hooks/use-collection-fields.mjs +17 -57
- package/dist/client/hooks/use-collection-meta.mjs +12 -44
- package/dist/client/hooks/use-collection-schema.mjs +10 -33
- package/dist/client/hooks/use-collection-validation.mjs +23 -53
- package/dist/client/hooks/use-collection.mjs +194 -614
- package/dist/client/hooks/use-current-user.mjs +0 -1
- package/dist/client/hooks/use-field-hooks.mjs +10 -10
- package/dist/client/hooks/use-field-options.mjs +61 -202
- package/dist/client/hooks/use-global-fields.mjs +14 -46
- package/dist/client/hooks/use-global-meta.mjs +9 -30
- package/dist/client/hooks/use-global-schema.mjs +9 -30
- package/dist/client/hooks/use-global.mjs +63 -219
- package/dist/client/hooks/use-locks.mjs +117 -325
- package/dist/client/hooks/use-media-query.mjs +16 -36
- package/dist/client/hooks/use-prefill-params.mjs +0 -1
- package/dist/client/hooks/use-questpie-query-options.mjs +12 -29
- package/dist/client/hooks/use-reactive-fields.mjs +1 -1
- package/dist/client/hooks/use-reactive-prop.mjs +65 -223
- package/dist/client/hooks/use-realtime-highlight.mjs +51 -114
- package/dist/client/hooks/use-saved-views.mjs +22 -103
- package/dist/client/hooks/use-search-param-toggle.mjs +28 -79
- package/dist/client/hooks/use-search.mjs +31 -143
- package/dist/client/hooks/use-server-actions.mjs +18 -50
- package/dist/client/hooks/use-server-validation.mjs +72 -166
- package/dist/client/hooks/use-server-widget-data.mjs +7 -33
- package/dist/client/hooks/use-setup-status.mjs +12 -25
- package/dist/client/hooks/use-sidebar-search-param.mjs +33 -78
- package/dist/client/hooks/use-transition-stage.mjs +8 -38
- package/dist/client/hooks/use-upload.mjs +54 -152
- package/dist/client/hooks/use-validation-error-map.mjs +6 -26
- package/dist/client/hooks/use-view-state.mjs +187 -437
- package/dist/client/i18n/hooks.mjs +65 -197
- package/dist/client/lib/render-profiler.mjs +14 -41
- package/dist/client/preview/block-scope-context.mjs +14 -36
- package/dist/client/preview/preview-banner.d.mts +2 -2
- package/dist/client/preview/preview-banner.mjs +42 -108
- package/dist/client/preview/preview-field.d.mts +4 -4
- package/dist/client/preview/preview-field.mjs +167 -348
- package/dist/client/preview/use-collection-preview.mjs +121 -215
- package/dist/client/runtime/content-locales-provider.mjs +31 -83
- package/dist/client/runtime/locale-scope.mjs +22 -63
- package/dist/client/runtime/provider.mjs +100 -255
- package/dist/client/runtime/translations-provider.mjs +41 -107
- package/dist/client/scope/picker.mjs +86 -321
- package/dist/client/scope/provider.mjs +8 -17
- package/dist/client/utils/build-field-definitions-from-schema.mjs +4 -2
- package/dist/client/views/auth/accept-invite-form.d.mts +2 -2
- package/dist/client/views/auth/accept-invite-form.mjs +121 -412
- package/dist/client/views/auth/auth-layout.d.mts +3 -3
- package/dist/client/views/auth/auth-layout.mjs +104 -284
- package/dist/client/views/auth/forgot-password-form.d.mts +2 -2
- package/dist/client/views/auth/forgot-password-form.mjs +94 -325
- package/dist/client/views/auth/invite-form.mjs +107 -442
- package/dist/client/views/auth/login-form.d.mts +2 -2
- package/dist/client/views/auth/login-form.mjs +116 -337
- package/dist/client/views/auth/reset-password-form.d.mts +2 -2
- package/dist/client/views/auth/reset-password-form.mjs +128 -453
- package/dist/client/views/auth/setup-form.d.mts +2 -2
- package/dist/client/views/auth/setup-form.mjs +140 -478
- package/dist/client/views/collection/auto-form-fields.mjs +243 -615
- package/dist/client/views/collection/bulk-action-toolbar.mjs +212 -379
- package/dist/client/views/collection/cells/complex-cells.mjs +183 -611
- package/dist/client/views/collection/cells/primitive-cells.mjs +116 -356
- package/dist/client/views/collection/cells/relation-cells.mjs +86 -233
- package/dist/client/views/collection/cells/shared/asset-thumbnail.mjs +142 -371
- package/dist/client/views/collection/cells/shared/relation-chip.mjs +35 -131
- package/dist/client/views/collection/cells/upload-cells.mjs +60 -177
- package/dist/client/views/collection/columns/build-columns.mjs +8 -48
- package/dist/client/views/collection/field-renderer.mjs +58 -182
- package/dist/client/views/collection/form-view.mjs +284 -518
- package/dist/client/views/collection/table-view.mjs +231 -463
- package/dist/client/views/collection/view-skeletons.mjs +112 -237
- package/dist/client/views/common/global-search.mjs +241 -560
- package/dist/client/views/dashboard/dashboard-grid.mjs +256 -775
- package/dist/client/views/dashboard/dashboard-widget.mjs +38 -126
- package/dist/client/views/dashboard/widget-card.mjs +61 -269
- package/dist/client/views/globals/global-form-view.mjs +477 -1301
- package/dist/client/views/layout/admin-layout-provider.mjs +28 -88
- package/dist/client/views/layout/admin-layout.mjs +83 -246
- package/dist/client/views/layout/admin-router.mjs +458 -1274
- package/dist/client/views/layout/admin-sidebar.mjs +510 -1292
- package/dist/client/views/layout/admin-theme.mjs +30 -64
- package/dist/client/views/layout/admin-view-layout.mjs +40 -144
- package/dist/client/views/pages/accept-invite-page.d.mts +2 -2
- package/dist/client/views/pages/accept-invite-page.mjs +95 -290
- package/dist/client/views/pages/dashboard-page.d.mts +2 -2
- package/dist/client/views/pages/dashboard-page.mjs +11 -57
- package/dist/client/views/pages/forgot-password-page.d.mts +2 -2
- package/dist/client/views/pages/forgot-password-page.mjs +31 -83
- package/dist/client/views/pages/invite-page.d.mts +2 -2
- package/dist/client/views/pages/invite-page.mjs +35 -90
- package/dist/client/views/pages/login-page.d.mts +2 -2
- package/dist/client/views/pages/login-page.mjs +41 -121
- package/dist/client/views/pages/reset-password-page.d.mts +2 -2
- package/dist/client/views/pages/reset-password-page.mjs +46 -173
- package/dist/client/views/pages/setup-page.d.mts +2 -2
- package/dist/client/views/pages/setup-page.mjs +33 -95
- package/dist/components/rich-text/rich-text-renderer.mjs +9 -33
- package/dist/server/adapters/index.d.mts +2 -0
- package/dist/server/adapters/nextjs.d.mts +1 -0
- package/dist/server/auth-helpers.d.mts +1 -0
- package/dist/server/modules/admin/.generated/module.d.mts +1 -0
- package/dist/server/modules/admin/collections/account.d.mts +46 -46
- package/dist/server/modules/admin/collections/admin-locks.d.mts +50 -50
- package/dist/server/modules/admin/collections/admin-preferences.d.mts +39 -39
- package/dist/server/modules/admin/collections/admin-saved-views.d.mts +47 -47
- package/dist/server/modules/admin/collections/apikey.d.mts +68 -68
- package/dist/server/modules/admin/collections/assets.d.mts +39 -39
- package/dist/server/modules/admin/collections/session.d.mts +42 -42
- package/dist/server/modules/admin/collections/user.d.mts +62 -62
- package/dist/server/modules/admin/collections/verification.d.mts +23 -23
- package/dist/server/modules/admin/index.d.mts +20 -19
- package/dist/server/modules/admin/routes/admin-config.d.mts +2 -2
- package/dist/server/modules/admin/routes/execute-action.d.mts +9 -9
- package/dist/server/modules/admin/routes/locales.d.mts +2 -2
- package/dist/server/modules/admin/routes/preview.d.mts +11 -11
- package/dist/server/modules/admin/routes/reactive.d.mts +9 -9
- package/dist/server/modules/admin/routes/setup.d.mts +7 -7
- package/dist/server/modules/admin/routes/translations.d.mts +4 -4
- package/dist/server/modules/admin/routes/widget-data.d.mts +5 -5
- package/dist/server/modules/admin-preferences/collections/saved-views.d.mts +45 -45
- package/dist/server/modules/audit/.generated/module.d.mts +6 -6
- package/dist/server/modules/audit/collections/audit-log.d.mts +78 -78
- package/dist/server/modules/audit/jobs/audit-cleanup.d.mts +2 -2
- package/dist/server.d.mts +2 -0
- package/package.json +3 -5
|
@@ -5,7 +5,6 @@ import { WidgetCard } from "../../views/dashboard/widget-card.mjs";
|
|
|
5
5
|
import { useServerWidgetData } from "../../hooks/use-server-widget-data.mjs";
|
|
6
6
|
import { WidgetEmptyState } from "./widget-empty-state.mjs";
|
|
7
7
|
import { RecentItemsWidgetSkeleton } from "./widget-skeletons.mjs";
|
|
8
|
-
import { c } from "react/compiler-runtime";
|
|
9
8
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
10
9
|
|
|
11
10
|
//#region src/client/components/widgets/recent-items-widget.tsx
|
|
@@ -23,203 +22,78 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
|
23
22
|
* - Configurable number of items
|
|
24
23
|
* - Links to edit each item
|
|
25
24
|
*/
|
|
26
|
-
function RecentItemsWidget(
|
|
27
|
-
const $ = c(53);
|
|
28
|
-
const { config } = t0;
|
|
25
|
+
function RecentItemsWidget({ config }) {
|
|
29
26
|
const resolveText = useResolveText();
|
|
30
27
|
const { t } = useTranslation();
|
|
31
|
-
const { collection, limit
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
refreshInterval
|
|
41
|
-
};
|
|
42
|
-
$[0] = refreshInterval;
|
|
43
|
-
$[1] = t4;
|
|
44
|
-
$[2] = t5;
|
|
45
|
-
} else t5 = $[2];
|
|
46
|
-
const serverQuery = useServerWidgetData(config.id, t5);
|
|
47
|
-
let t6;
|
|
48
|
-
if ($[3] !== dateField) {
|
|
49
|
-
t6 = { [dateField]: "desc" };
|
|
50
|
-
$[3] = dateField;
|
|
51
|
-
$[4] = t6;
|
|
52
|
-
} else t6 = $[4];
|
|
53
|
-
let t7;
|
|
54
|
-
if ($[5] !== limit || $[6] !== t6) {
|
|
55
|
-
t7 = {
|
|
56
|
-
orderBy: t6,
|
|
57
|
-
limit
|
|
58
|
-
};
|
|
59
|
-
$[5] = limit;
|
|
60
|
-
$[6] = t6;
|
|
61
|
-
$[7] = t7;
|
|
62
|
-
} else t7 = $[7];
|
|
63
|
-
const t8 = !hasLoader;
|
|
64
|
-
let t9;
|
|
65
|
-
if ($[8] !== t8) {
|
|
66
|
-
t9 = { enabled: t8 };
|
|
67
|
-
$[8] = t8;
|
|
68
|
-
$[9] = t9;
|
|
69
|
-
} else t9 = $[9];
|
|
70
|
-
let t10;
|
|
71
|
-
if ($[10] !== realtime) {
|
|
72
|
-
t10 = { realtime };
|
|
73
|
-
$[10] = realtime;
|
|
74
|
-
$[11] = t10;
|
|
75
|
-
} else t10 = $[11];
|
|
76
|
-
const collectionQuery = useCollectionList(collection, t7, t9, t10);
|
|
28
|
+
const { collection, limit = 5, label, titleField = "_title", dateField = "createdAt", subtitleFields, onItemClick, realtime, hasLoader, refreshInterval } = config;
|
|
29
|
+
const serverQuery = useServerWidgetData(config.id, {
|
|
30
|
+
enabled: !!hasLoader,
|
|
31
|
+
refreshInterval
|
|
32
|
+
});
|
|
33
|
+
const collectionQuery = useCollectionList(collection, {
|
|
34
|
+
orderBy: { [dateField]: "desc" },
|
|
35
|
+
limit
|
|
36
|
+
}, { enabled: !hasLoader }, { realtime });
|
|
77
37
|
const { data, isLoading, error, refetch, isFetching } = hasLoader ? serverQuery : collectionQuery;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
const dateValue = item_2[dateField];
|
|
138
|
-
const subtitle = getSubtitle(item_2);
|
|
139
|
-
return /* @__PURE__ */ jsx("button", {
|
|
140
|
-
type: "button",
|
|
141
|
-
onClick: () => handleItemClick(item_2),
|
|
142
|
-
className: "hover:bg-muted flex w-full cursor-pointer items-center gap-3 p-2 text-left transition-colors",
|
|
143
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
144
|
-
className: "min-w-0 flex-1",
|
|
145
|
-
children: [/* @__PURE__ */ jsx("p", {
|
|
146
|
-
className: "truncate text-sm font-medium",
|
|
147
|
-
children: getTitleValue(item_2)
|
|
148
|
-
}), /* @__PURE__ */ jsxs("div", {
|
|
149
|
-
className: "text-muted-foreground flex items-center gap-2 text-xs",
|
|
150
|
-
children: [dateValue && /* @__PURE__ */ jsx("span", { children: formatRelativeTime(new Date(dateValue)) }), subtitle && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", { children: "-" }), /* @__PURE__ */ jsx("span", {
|
|
151
|
-
className: "truncate",
|
|
152
|
-
children: subtitle
|
|
153
|
-
})] })]
|
|
154
|
-
})]
|
|
155
|
-
})
|
|
156
|
-
}, item_2.id);
|
|
157
|
-
})
|
|
158
|
-
});
|
|
159
|
-
$[25] = dateField;
|
|
160
|
-
$[26] = getSubtitle;
|
|
161
|
-
$[27] = getTitleValue;
|
|
162
|
-
$[28] = handleItemClick;
|
|
163
|
-
$[29] = items;
|
|
164
|
-
$[30] = t;
|
|
165
|
-
$[31] = t16;
|
|
166
|
-
} else t16 = $[31];
|
|
167
|
-
const listContent = t16;
|
|
168
|
-
let t17;
|
|
169
|
-
if ($[32] !== config.description || $[33] !== resolveText) {
|
|
170
|
-
t17 = config.description ? resolveText(config.description) : void 0;
|
|
171
|
-
$[32] = config.description;
|
|
172
|
-
$[33] = resolveText;
|
|
173
|
-
$[34] = t17;
|
|
174
|
-
} else t17 = $[34];
|
|
175
|
-
const t18 = isFetching && !isLoading;
|
|
176
|
-
let t19;
|
|
177
|
-
if ($[35] !== limit) {
|
|
178
|
-
t19 = /* @__PURE__ */ jsx(RecentItemsWidgetSkeleton, { count: limit });
|
|
179
|
-
$[35] = limit;
|
|
180
|
-
$[36] = t19;
|
|
181
|
-
} else t19 = $[36];
|
|
182
|
-
let t20;
|
|
183
|
-
if ($[37] !== error) {
|
|
184
|
-
t20 = error instanceof Error ? error : error ? new Error(String(error)) : null;
|
|
185
|
-
$[37] = error;
|
|
186
|
-
$[38] = t20;
|
|
187
|
-
} else t20 = $[38];
|
|
188
|
-
let t21;
|
|
189
|
-
if ($[39] !== refetch) {
|
|
190
|
-
t21 = () => refetch();
|
|
191
|
-
$[39] = refetch;
|
|
192
|
-
$[40] = t21;
|
|
193
|
-
} else t21 = $[40];
|
|
194
|
-
let t22;
|
|
195
|
-
if ($[41] !== config.actions || $[42] !== config.cardVariant || $[43] !== config.className || $[44] !== displayLabel || $[45] !== isLoading || $[46] !== listContent || $[47] !== t17 || $[48] !== t18 || $[49] !== t19 || $[50] !== t20 || $[51] !== t21) {
|
|
196
|
-
t22 = /* @__PURE__ */ jsx(WidgetCard, {
|
|
197
|
-
title: displayLabel,
|
|
198
|
-
description: t17,
|
|
199
|
-
variant: config.cardVariant,
|
|
200
|
-
isLoading,
|
|
201
|
-
isRefreshing: t18,
|
|
202
|
-
loadingSkeleton: t19,
|
|
203
|
-
error: t20,
|
|
204
|
-
onRefresh: t21,
|
|
205
|
-
actions: config.actions,
|
|
206
|
-
className: config.className,
|
|
207
|
-
children: listContent
|
|
208
|
-
});
|
|
209
|
-
$[41] = config.actions;
|
|
210
|
-
$[42] = config.cardVariant;
|
|
211
|
-
$[43] = config.className;
|
|
212
|
-
$[44] = displayLabel;
|
|
213
|
-
$[45] = isLoading;
|
|
214
|
-
$[46] = listContent;
|
|
215
|
-
$[47] = t17;
|
|
216
|
-
$[48] = t18;
|
|
217
|
-
$[49] = t19;
|
|
218
|
-
$[50] = t20;
|
|
219
|
-
$[51] = t21;
|
|
220
|
-
$[52] = t22;
|
|
221
|
-
} else t22 = $[52];
|
|
222
|
-
return t22;
|
|
38
|
+
const items = Array.isArray(data) ? data : Array.isArray(data?.docs) ? data.docs : [];
|
|
39
|
+
const displayLabel = config.title ? resolveText(config.title) : label ? resolveText(label) : `Recent ${formatLabel(collection)}`;
|
|
40
|
+
const getTitleValue = (item) => {
|
|
41
|
+
if (titleField && item[titleField]) return String(item[titleField]);
|
|
42
|
+
if (item._title) return String(item._title);
|
|
43
|
+
if (item.name) return String(item.name);
|
|
44
|
+
if (item.title) return String(item.title);
|
|
45
|
+
if (item.label) return String(item.label);
|
|
46
|
+
return `Item #${item.id}`;
|
|
47
|
+
};
|
|
48
|
+
const getSubtitle = (item) => {
|
|
49
|
+
if (!subtitleFields?.length) return null;
|
|
50
|
+
return subtitleFields.map((field) => item[field]).filter(Boolean).join(" - ");
|
|
51
|
+
};
|
|
52
|
+
const handleItemClick = (item) => {
|
|
53
|
+
if (onItemClick) onItemClick(item);
|
|
54
|
+
};
|
|
55
|
+
const listContent = items.length === 0 ? /* @__PURE__ */ jsx(WidgetEmptyState, {
|
|
56
|
+
iconName: "ph:clock-counter-clockwise",
|
|
57
|
+
title: t("widget.recentItems.emptyTitle"),
|
|
58
|
+
description: t("widget.recentItems.emptyDescription")
|
|
59
|
+
}) : /* @__PURE__ */ jsx("div", {
|
|
60
|
+
className: "space-y-1",
|
|
61
|
+
children: items.map((item) => {
|
|
62
|
+
const dateValue = item[dateField];
|
|
63
|
+
const subtitle = getSubtitle(item);
|
|
64
|
+
return /* @__PURE__ */ jsx("button", {
|
|
65
|
+
type: "button",
|
|
66
|
+
onClick: () => handleItemClick(item),
|
|
67
|
+
className: "hover:bg-muted flex w-full cursor-pointer items-center gap-3 p-2 text-left transition-colors",
|
|
68
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
69
|
+
className: "min-w-0 flex-1",
|
|
70
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
71
|
+
className: "truncate text-sm font-medium",
|
|
72
|
+
children: getTitleValue(item)
|
|
73
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
74
|
+
className: "text-muted-foreground flex items-center gap-2 text-xs",
|
|
75
|
+
children: [dateValue && /* @__PURE__ */ jsx("span", { children: formatRelativeTime(new Date(dateValue)) }), subtitle && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", { children: "-" }), /* @__PURE__ */ jsx("span", {
|
|
76
|
+
className: "truncate",
|
|
77
|
+
children: subtitle
|
|
78
|
+
})] })]
|
|
79
|
+
})]
|
|
80
|
+
})
|
|
81
|
+
}, item.id);
|
|
82
|
+
})
|
|
83
|
+
});
|
|
84
|
+
return /* @__PURE__ */ jsx(WidgetCard, {
|
|
85
|
+
title: displayLabel,
|
|
86
|
+
description: config.description ? resolveText(config.description) : void 0,
|
|
87
|
+
variant: config.cardVariant,
|
|
88
|
+
isLoading,
|
|
89
|
+
isRefreshing: isFetching && !isLoading,
|
|
90
|
+
loadingSkeleton: /* @__PURE__ */ jsx(RecentItemsWidgetSkeleton, { count: limit }),
|
|
91
|
+
error: error instanceof Error ? error : error ? new Error(String(error)) : null,
|
|
92
|
+
onRefresh: () => refetch(),
|
|
93
|
+
actions: config.actions,
|
|
94
|
+
className: config.className,
|
|
95
|
+
children: listContent
|
|
96
|
+
});
|
|
223
97
|
}
|
|
224
98
|
/**
|
|
225
99
|
* Format relative time
|
|
@@ -4,7 +4,7 @@ import { useCollectionCount } from "../../hooks/use-collection.mjs";
|
|
|
4
4
|
import { WidgetCard } from "../../views/dashboard/widget-card.mjs";
|
|
5
5
|
import { useServerWidgetData } from "../../hooks/use-server-widget-data.mjs";
|
|
6
6
|
import { StatsWidgetSkeleton } from "./widget-skeletons.mjs";
|
|
7
|
-
import {
|
|
7
|
+
import { useMemo } from "react";
|
|
8
8
|
import { jsx } from "react/jsx-runtime";
|
|
9
9
|
|
|
10
10
|
//#region src/client/components/widgets/stats-widget.tsx
|
|
@@ -90,190 +90,56 @@ const variantValueStyles = {
|
|
|
90
90
|
* - Optional icon
|
|
91
91
|
* - Color variant for visual distinction
|
|
92
92
|
*/
|
|
93
|
-
function StatsWidget(
|
|
94
|
-
const $ = c(53);
|
|
95
|
-
const { config } = t0;
|
|
93
|
+
function StatsWidget({ config }) {
|
|
96
94
|
const resolveText = useResolveText();
|
|
97
|
-
const { collection, label, filter, filterFn, dateFilter, icon: Icon, variant
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
enabled: t2,
|
|
104
|
-
refreshInterval
|
|
105
|
-
};
|
|
106
|
-
$[0] = refreshInterval;
|
|
107
|
-
$[1] = t2;
|
|
108
|
-
$[2] = t3;
|
|
109
|
-
} else t3 = $[2];
|
|
110
|
-
const serverQuery = useServerWidgetData(config.id, t3);
|
|
111
|
-
let t4;
|
|
112
|
-
if ($[3] !== dateFilter || $[4] !== filter || $[5] !== filterFn) {
|
|
95
|
+
const { collection, label, filter, filterFn, dateFilter, icon: Icon, variant = "default", realtime, hasLoader, refreshInterval } = config;
|
|
96
|
+
const serverQuery = useServerWidgetData(config.id, {
|
|
97
|
+
enabled: !!hasLoader,
|
|
98
|
+
refreshInterval
|
|
99
|
+
});
|
|
100
|
+
const computedFilter = useMemo(() => {
|
|
113
101
|
let result = {};
|
|
114
102
|
if (filter) result = {
|
|
115
103
|
...result,
|
|
116
104
|
...filter
|
|
117
105
|
};
|
|
118
|
-
if (filterFn) {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
t6$1 = filterFn();
|
|
123
|
-
$[7] = filterFn;
|
|
124
|
-
$[8] = t6$1;
|
|
125
|
-
} else t6$1 = $[8];
|
|
126
|
-
result = {
|
|
127
|
-
...t5$1,
|
|
128
|
-
...t6$1
|
|
129
|
-
};
|
|
130
|
-
}
|
|
106
|
+
if (filterFn) result = {
|
|
107
|
+
...result,
|
|
108
|
+
...filterFn()
|
|
109
|
+
};
|
|
131
110
|
if (dateFilter) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
t6$1 = lte.toISOString();
|
|
138
|
-
$[9] = dateFilter.range;
|
|
139
|
-
$[10] = t5$1;
|
|
140
|
-
$[11] = t6$1;
|
|
141
|
-
} else {
|
|
142
|
-
t5$1 = $[10];
|
|
143
|
-
t6$1 = $[11];
|
|
144
|
-
}
|
|
145
|
-
let t7$1;
|
|
146
|
-
if ($[12] !== t5$1 || $[13] !== t6$1) {
|
|
147
|
-
t7$1 = {
|
|
148
|
-
gte: t5$1,
|
|
149
|
-
lte: t6$1
|
|
150
|
-
};
|
|
151
|
-
$[12] = t5$1;
|
|
152
|
-
$[13] = t6$1;
|
|
153
|
-
$[14] = t7$1;
|
|
154
|
-
} else t7$1 = $[14];
|
|
155
|
-
result[dateFilter.field] = t7$1;
|
|
111
|
+
const { gte, lte } = getDateRange(dateFilter.range);
|
|
112
|
+
result[dateFilter.field] = {
|
|
113
|
+
gte: gte.toISOString(),
|
|
114
|
+
lte: lte.toISOString()
|
|
115
|
+
};
|
|
156
116
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
const
|
|
164
|
-
let t5;
|
|
165
|
-
if ($[15] !== computedFilter) {
|
|
166
|
-
t5 = computedFilter ? { where: computedFilter } : void 0;
|
|
167
|
-
$[15] = computedFilter;
|
|
168
|
-
$[16] = t5;
|
|
169
|
-
} else t5 = $[16];
|
|
170
|
-
const t6 = !hasLoader;
|
|
171
|
-
let t7;
|
|
172
|
-
if ($[17] !== t6) {
|
|
173
|
-
t7 = { enabled: t6 };
|
|
174
|
-
$[17] = t6;
|
|
175
|
-
$[18] = t7;
|
|
176
|
-
} else t7 = $[18];
|
|
177
|
-
let t8;
|
|
178
|
-
if ($[19] !== realtime) {
|
|
179
|
-
t8 = { realtime };
|
|
180
|
-
$[19] = realtime;
|
|
181
|
-
$[20] = t8;
|
|
182
|
-
} else t8 = $[20];
|
|
183
|
-
const collectionQuery = useCollectionCount(collection, t5, t7, t8);
|
|
117
|
+
return Object.keys(result).length > 0 ? result : void 0;
|
|
118
|
+
}, [
|
|
119
|
+
filter,
|
|
120
|
+
filterFn,
|
|
121
|
+
dateFilter
|
|
122
|
+
]);
|
|
123
|
+
const collectionQuery = useCollectionCount(collection, computedFilter ? { where: computedFilter } : void 0, { enabled: !hasLoader }, { realtime });
|
|
184
124
|
const { data: rawData, isLoading, error, refetch, isFetching } = hasLoader ? serverQuery : collectionQuery;
|
|
185
125
|
const count = hasLoader ? rawData?.count ?? 0 : rawData ?? 0;
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
}
|
|
203
|
-
const t11 = config.cardVariant;
|
|
204
|
-
const t12 = isFetching && !isLoading;
|
|
205
|
-
let t13;
|
|
206
|
-
if ($[29] === Symbol.for("react.memo_cache_sentinel")) {
|
|
207
|
-
t13 = /* @__PURE__ */ jsx(StatsWidgetSkeleton, {});
|
|
208
|
-
$[29] = t13;
|
|
209
|
-
} else t13 = $[29];
|
|
210
|
-
let t14;
|
|
211
|
-
if ($[30] !== error) {
|
|
212
|
-
t14 = error instanceof Error ? error : error ? new Error(String(error)) : null;
|
|
213
|
-
$[30] = error;
|
|
214
|
-
$[31] = t14;
|
|
215
|
-
} else t14 = $[31];
|
|
216
|
-
let t15;
|
|
217
|
-
if ($[32] !== refetch) {
|
|
218
|
-
t15 = () => refetch();
|
|
219
|
-
$[32] = refetch;
|
|
220
|
-
$[33] = t15;
|
|
221
|
-
} else t15 = $[33];
|
|
222
|
-
const t16 = config.actions;
|
|
223
|
-
const t17 = config.className;
|
|
224
|
-
const t18 = variantValueStyles[variant];
|
|
225
|
-
let t19;
|
|
226
|
-
if ($[34] !== t18) {
|
|
227
|
-
t19 = cn("text-2xl font-bold", t18);
|
|
228
|
-
$[34] = t18;
|
|
229
|
-
$[35] = t19;
|
|
230
|
-
} else t19 = $[35];
|
|
231
|
-
let t20;
|
|
232
|
-
if ($[36] !== count) {
|
|
233
|
-
t20 = count.toLocaleString();
|
|
234
|
-
$[36] = count;
|
|
235
|
-
$[37] = t20;
|
|
236
|
-
} else t20 = $[37];
|
|
237
|
-
let t21;
|
|
238
|
-
if ($[38] !== t19 || $[39] !== t20) {
|
|
239
|
-
t21 = /* @__PURE__ */ jsx("div", {
|
|
240
|
-
className: t19,
|
|
241
|
-
children: t20
|
|
242
|
-
});
|
|
243
|
-
$[38] = t19;
|
|
244
|
-
$[39] = t20;
|
|
245
|
-
$[40] = t21;
|
|
246
|
-
} else t21 = $[40];
|
|
247
|
-
let t22;
|
|
248
|
-
if ($[41] !== Icon || $[42] !== config.actions || $[43] !== config.cardVariant || $[44] !== config.className || $[45] !== displayLabel || $[46] !== isLoading || $[47] !== t10 || $[48] !== t12 || $[49] !== t14 || $[50] !== t15 || $[51] !== t21) {
|
|
249
|
-
t22 = /* @__PURE__ */ jsx(WidgetCard, {
|
|
250
|
-
title: displayLabel,
|
|
251
|
-
description: t10,
|
|
252
|
-
icon: Icon,
|
|
253
|
-
variant: t11,
|
|
254
|
-
isLoading,
|
|
255
|
-
isRefreshing: t12,
|
|
256
|
-
loadingSkeleton: t13,
|
|
257
|
-
error: t14,
|
|
258
|
-
onRefresh: t15,
|
|
259
|
-
actions: t16,
|
|
260
|
-
className: t17,
|
|
261
|
-
children: t21
|
|
262
|
-
});
|
|
263
|
-
$[41] = Icon;
|
|
264
|
-
$[42] = config.actions;
|
|
265
|
-
$[43] = config.cardVariant;
|
|
266
|
-
$[44] = config.className;
|
|
267
|
-
$[45] = displayLabel;
|
|
268
|
-
$[46] = isLoading;
|
|
269
|
-
$[47] = t10;
|
|
270
|
-
$[48] = t12;
|
|
271
|
-
$[49] = t14;
|
|
272
|
-
$[50] = t15;
|
|
273
|
-
$[51] = t21;
|
|
274
|
-
$[52] = t22;
|
|
275
|
-
} else t22 = $[52];
|
|
276
|
-
return t22;
|
|
126
|
+
return /* @__PURE__ */ jsx(WidgetCard, {
|
|
127
|
+
title: config.title ? resolveText(config.title) : label ? resolveText(label) : formatLabel(collection),
|
|
128
|
+
description: config.description ? resolveText(config.description) : void 0,
|
|
129
|
+
icon: Icon,
|
|
130
|
+
variant: config.cardVariant,
|
|
131
|
+
isLoading,
|
|
132
|
+
isRefreshing: isFetching && !isLoading,
|
|
133
|
+
loadingSkeleton: /* @__PURE__ */ jsx(StatsWidgetSkeleton, {}),
|
|
134
|
+
error: error instanceof Error ? error : error ? new Error(String(error)) : null,
|
|
135
|
+
onRefresh: () => refetch(),
|
|
136
|
+
actions: config.actions,
|
|
137
|
+
className: config.className,
|
|
138
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
139
|
+
className: cn("text-2xl font-bold", variantValueStyles[variant]),
|
|
140
|
+
children: count.toLocaleString()
|
|
141
|
+
})
|
|
142
|
+
});
|
|
277
143
|
}
|
|
278
144
|
|
|
279
145
|
//#endregion
|
|
@@ -127,7 +127,7 @@ function TableWidget({ config, basePath = "/admin", navigate }) {
|
|
|
127
127
|
className: "min-w-full table-fixed",
|
|
128
128
|
style: { minWidth: table.getTotalSize() },
|
|
129
129
|
children: [
|
|
130
|
-
/* @__PURE__ */ jsx("colgroup", { children: visibleColumns.map((
|
|
130
|
+
/* @__PURE__ */ jsx("colgroup", { children: visibleColumns.map((column) => /* @__PURE__ */ jsx("col", { style: { width: column.getSize() } }, column.id)) }),
|
|
131
131
|
/* @__PURE__ */ jsx(TableHeader, { children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx(TableRow, {
|
|
132
132
|
className: "hover:bg-transparent",
|
|
133
133
|
children: headerGroup.headers.map((header) => {
|
|
@@ -139,28 +139,28 @@ function TableWidget({ config, basePath = "/admin", navigate }) {
|
|
|
139
139
|
}, header.id);
|
|
140
140
|
})
|
|
141
141
|
}, headerGroup.id)) }),
|
|
142
|
-
/* @__PURE__ */ jsx(TableBody, { children: rows.map((
|
|
143
|
-
const canNavigate = !!linkToDetail && !!navigate && !!
|
|
142
|
+
/* @__PURE__ */ jsx(TableBody, { children: rows.map((row) => {
|
|
143
|
+
const canNavigate = !!linkToDetail && !!navigate && !!row.original?.id;
|
|
144
144
|
return /* @__PURE__ */ jsx(TableRow, {
|
|
145
145
|
role: canNavigate ? "link" : void 0,
|
|
146
146
|
tabIndex: canNavigate ? 0 : void 0,
|
|
147
147
|
className: cn(canNavigate && "cursor-pointer"),
|
|
148
|
-
onClick: canNavigate ? () => handleRowClick(
|
|
148
|
+
onClick: canNavigate ? () => handleRowClick(row.original) : void 0,
|
|
149
149
|
onKeyDown: canNavigate ? (event) => {
|
|
150
150
|
if (event.key === "Enter" || event.key === " ") {
|
|
151
151
|
event.preventDefault();
|
|
152
|
-
handleRowClick(
|
|
152
|
+
handleRowClick(row.original);
|
|
153
153
|
}
|
|
154
154
|
} : void 0,
|
|
155
|
-
children:
|
|
156
|
-
const
|
|
155
|
+
children: row.getVisibleCells().map((cell) => {
|
|
156
|
+
const meta = cell.column.columnDef.meta;
|
|
157
157
|
return /* @__PURE__ */ jsx(TableCell, {
|
|
158
|
-
className: cn(getAlignClass(
|
|
158
|
+
className: cn(getAlignClass(meta?.align), meta?.className),
|
|
159
159
|
style: getColumnSizeStyle(cell.column),
|
|
160
160
|
children: flexRender(cell.column.columnDef.cell, cell.getContext())
|
|
161
161
|
}, cell.id);
|
|
162
162
|
})
|
|
163
|
-
},
|
|
163
|
+
}, row.id);
|
|
164
164
|
}) })
|
|
165
165
|
]
|
|
166
166
|
})
|