@questpie/admin 0.0.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +439 -424
- package/dist/auth-layout-M8K8_q5R.mjs +181 -0
- package/dist/auth-layout-M8K8_q5R.mjs.map +1 -0
- package/dist/bulk-upload-dialog-h7zXD78Y.mjs +274 -0
- package/dist/bulk-upload-dialog-h7zXD78Y.mjs.map +1 -0
- package/dist/{components/ui/card.mjs → card-BKHjBQfw.mjs} +8 -8
- package/dist/card-BKHjBQfw.mjs.map +1 -0
- package/dist/client/styles/index.css +434 -0
- package/dist/client-BCGpkAz6.mjs +22635 -0
- package/dist/client-BCGpkAz6.mjs.map +1 -0
- package/dist/client-CcWZbkBP.d.mts +13585 -0
- package/dist/client-CcWZbkBP.d.mts.map +1 -0
- package/dist/client.d.mts +3 -0
- package/dist/client.mjs +14 -0
- package/dist/content-locales-provider-BXvuIgfg.mjs +1650 -0
- package/dist/content-locales-provider-BXvuIgfg.mjs.map +1 -0
- package/dist/dashboard-page-B4PGEdc2.mjs +2500 -0
- package/dist/dashboard-page-B4PGEdc2.mjs.map +1 -0
- package/dist/dashboard-page-CVlyR40m.mjs +6 -0
- package/dist/dropzone-Do3awXKd.mjs +634 -0
- package/dist/dropzone-Do3awXKd.mjs.map +1 -0
- package/dist/{views/auth/forgot-password-form.mjs → forgot-password-page-Bcp-An4Y.mjs} +87 -14
- package/dist/forgot-password-page-Bcp-An4Y.mjs.map +1 -0
- package/dist/forgot-password-page-CIILVhfo.mjs +7 -0
- package/dist/index-B9Xwk4hi.d.mts +2753 -0
- package/dist/index-B9Xwk4hi.d.mts.map +1 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.mjs +14 -0
- package/dist/login-page-8K7fo0qK.mjs +7 -0
- package/dist/login-page-CP4gA-dl.mjs +298 -0
- package/dist/login-page-CP4gA-dl.mjs.map +1 -0
- package/dist/preview-utils-BKQ9-TMa.mjs +65 -0
- package/dist/preview-utils-BKQ9-TMa.mjs.map +1 -0
- package/dist/{views/auth/reset-password-form.mjs → reset-password-page-BqfDmLxA.mjs} +111 -14
- package/dist/reset-password-page-BqfDmLxA.mjs.map +1 -0
- package/dist/reset-password-page-DLATv0xQ.mjs +7 -0
- package/dist/runtime-6VZM878K.mjs +69 -0
- package/dist/runtime-6VZM878K.mjs.map +1 -0
- package/dist/saved-views.types-BMsz5mCy.d.mts +42 -0
- package/dist/saved-views.types-BMsz5mCy.d.mts.map +1 -0
- package/dist/server.d.mts +250 -0
- package/dist/server.d.mts.map +1 -0
- package/dist/server.mjs +832 -0
- package/dist/server.mjs.map +1 -0
- package/dist/setup-page-CMZ5P_OE.mjs +6 -0
- package/dist/setup-page-YAP_fzqh.mjs +264 -0
- package/dist/setup-page-YAP_fzqh.mjs.map +1 -0
- package/dist/shared.d.mts +57 -0
- package/dist/shared.d.mts.map +1 -0
- package/dist/shared.mjs +3 -0
- package/dist/{hooks/use-auth.mjs → use-auth-BoLmWtmU.mjs} +42 -30
- package/dist/use-auth-BoLmWtmU.mjs.map +1 -0
- package/package.json +48 -197
- package/.turbo/turbo-build.log +0 -108
- package/CHANGELOG.md +0 -10
- package/STATUS.md +0 -917
- package/VALIDATION.md +0 -602
- package/components.json +0 -24
- package/dist/__tests__/setup.mjs +0 -38
- package/dist/__tests__/test-utils.mjs +0 -45
- package/dist/__tests__/vitest.d.mjs +0 -3
- package/dist/components/admin-app.mjs +0 -69
- package/dist/components/fields/array-field.mjs +0 -190
- package/dist/components/fields/checkbox-field.mjs +0 -34
- package/dist/components/fields/custom-field.mjs +0 -32
- package/dist/components/fields/date-field.mjs +0 -41
- package/dist/components/fields/datetime-field.mjs +0 -42
- package/dist/components/fields/email-field.mjs +0 -37
- package/dist/components/fields/embedded-collection.mjs +0 -253
- package/dist/components/fields/field-types.mjs +0 -1
- package/dist/components/fields/field-utils.mjs +0 -10
- package/dist/components/fields/field-wrapper.mjs +0 -34
- package/dist/components/fields/index.mjs +0 -23
- package/dist/components/fields/json-field.mjs +0 -243
- package/dist/components/fields/locale-badge.mjs +0 -16
- package/dist/components/fields/number-field.mjs +0 -39
- package/dist/components/fields/password-field.mjs +0 -37
- package/dist/components/fields/relation-field.mjs +0 -104
- package/dist/components/fields/relation-picker.mjs +0 -229
- package/dist/components/fields/relation-select.mjs +0 -188
- package/dist/components/fields/rich-text-editor/index.mjs +0 -897
- package/dist/components/fields/select-field.mjs +0 -41
- package/dist/components/fields/switch-field.mjs +0 -34
- package/dist/components/fields/text-field.mjs +0 -38
- package/dist/components/fields/textarea-field.mjs +0 -38
- package/dist/components/index.mjs +0 -59
- package/dist/components/primitives/checkbox-input.mjs +0 -127
- package/dist/components/primitives/date-input.mjs +0 -303
- package/dist/components/primitives/index.mjs +0 -12
- package/dist/components/primitives/number-input.mjs +0 -104
- package/dist/components/primitives/select-input.mjs +0 -177
- package/dist/components/primitives/tag-input.mjs +0 -135
- package/dist/components/primitives/text-input.mjs +0 -39
- package/dist/components/primitives/textarea-input.mjs +0 -37
- package/dist/components/primitives/toggle-input.mjs +0 -31
- package/dist/components/primitives/types.mjs +0 -12
- package/dist/components/ui/accordion.mjs +0 -55
- package/dist/components/ui/avatar.mjs +0 -54
- package/dist/components/ui/badge.mjs +0 -34
- package/dist/components/ui/button.mjs +0 -48
- package/dist/components/ui/checkbox.mjs +0 -21
- package/dist/components/ui/combobox.mjs +0 -163
- package/dist/components/ui/dialog.mjs +0 -95
- package/dist/components/ui/dropdown-menu.mjs +0 -138
- package/dist/components/ui/field.mjs +0 -113
- package/dist/components/ui/input-group.mjs +0 -82
- package/dist/components/ui/input.mjs +0 -17
- package/dist/components/ui/label.mjs +0 -15
- package/dist/components/ui/popover.mjs +0 -56
- package/dist/components/ui/scroll-area.mjs +0 -38
- package/dist/components/ui/select.mjs +0 -100
- package/dist/components/ui/separator.mjs +0 -16
- package/dist/components/ui/sheet.mjs +0 -90
- package/dist/components/ui/sidebar.mjs +0 -387
- package/dist/components/ui/skeleton.mjs +0 -14
- package/dist/components/ui/spinner.mjs +0 -16
- package/dist/components/ui/switch.mjs +0 -22
- package/dist/components/ui/table.mjs +0 -68
- package/dist/components/ui/tabs.mjs +0 -48
- package/dist/components/ui/textarea.mjs +0 -15
- package/dist/components/ui/tooltip.mjs +0 -44
- package/dist/config/component-registry.mjs +0 -38
- package/dist/config/index.mjs +0 -129
- package/dist/hooks/admin-provider.mjs +0 -70
- package/dist/hooks/index.mjs +0 -7
- package/dist/hooks/store.mjs +0 -178
- package/dist/hooks/use-collection-db.mjs +0 -146
- package/dist/hooks/use-collection.mjs +0 -112
- package/dist/hooks/use-global.mjs +0 -46
- package/dist/hooks/use-mobile.mjs +0 -20
- package/dist/lib/utils.mjs +0 -10
- package/dist/styles/index.css +0 -336
- package/dist/styles/index.mjs +0 -1
- package/dist/utils/index.mjs +0 -9
- package/dist/views/auth/auth-layout.mjs +0 -52
- package/dist/views/auth/index.mjs +0 -6
- package/dist/views/auth/login-form.mjs +0 -156
- package/dist/views/collection/auto-form-fields.mjs +0 -525
- package/dist/views/collection/collection-form.mjs +0 -91
- package/dist/views/collection/collection-list.mjs +0 -76
- package/dist/views/collection/form-field.mjs +0 -42
- package/dist/views/collection/index.mjs +0 -6
- package/dist/views/common/index.mjs +0 -4
- package/dist/views/common/locale-switcher.mjs +0 -39
- package/dist/views/common/version-history.mjs +0 -272
- package/dist/views/index.mjs +0 -9
- package/dist/views/layout/admin-layout.mjs +0 -40
- package/dist/views/layout/admin-router.mjs +0 -95
- package/dist/views/layout/admin-sidebar.mjs +0 -63
- package/dist/views/layout/index.mjs +0 -5
- package/src/__tests__/setup.ts +0 -44
- package/src/__tests__/test-utils.tsx +0 -49
- package/src/__tests__/vitest.d.ts +0 -9
- package/src/components/admin-app.tsx +0 -221
- package/src/components/fields/array-field.tsx +0 -237
- package/src/components/fields/checkbox-field.tsx +0 -47
- package/src/components/fields/custom-field.tsx +0 -50
- package/src/components/fields/date-field.tsx +0 -65
- package/src/components/fields/datetime-field.tsx +0 -67
- package/src/components/fields/email-field.tsx +0 -51
- package/src/components/fields/embedded-collection.tsx +0 -315
- package/src/components/fields/field-types.ts +0 -162
- package/src/components/fields/field-utils.ts +0 -6
- package/src/components/fields/field-wrapper.tsx +0 -52
- package/src/components/fields/index.ts +0 -66
- package/src/components/fields/json-field.tsx +0 -440
- package/src/components/fields/locale-badge.tsx +0 -15
- package/src/components/fields/number-field.tsx +0 -57
- package/src/components/fields/password-field.tsx +0 -51
- package/src/components/fields/relation-field.tsx +0 -243
- package/src/components/fields/relation-picker.tsx +0 -402
- package/src/components/fields/relation-select.tsx +0 -327
- package/src/components/fields/rich-text-editor/index.tsx +0 -1337
- package/src/components/fields/select-field.tsx +0 -61
- package/src/components/fields/switch-field.tsx +0 -47
- package/src/components/fields/text-field.tsx +0 -55
- package/src/components/fields/textarea-field.tsx +0 -55
- package/src/components/index.ts +0 -40
- package/src/components/primitives/checkbox-input.tsx +0 -193
- package/src/components/primitives/date-input.tsx +0 -401
- package/src/components/primitives/index.ts +0 -24
- package/src/components/primitives/number-input.tsx +0 -132
- package/src/components/primitives/select-input.tsx +0 -296
- package/src/components/primitives/tag-input.tsx +0 -200
- package/src/components/primitives/text-input.tsx +0 -49
- package/src/components/primitives/textarea-input.tsx +0 -46
- package/src/components/primitives/toggle-input.tsx +0 -36
- package/src/components/primitives/types.ts +0 -235
- package/src/components/ui/accordion.tsx +0 -72
- package/src/components/ui/avatar.tsx +0 -106
- package/src/components/ui/badge.tsx +0 -48
- package/src/components/ui/button.tsx +0 -53
- package/src/components/ui/card.tsx +0 -94
- package/src/components/ui/checkbox.tsx +0 -27
- package/src/components/ui/combobox.tsx +0 -290
- package/src/components/ui/dialog.tsx +0 -151
- package/src/components/ui/dropdown-menu.tsx +0 -254
- package/src/components/ui/field.tsx +0 -227
- package/src/components/ui/input-group.tsx +0 -149
- package/src/components/ui/input.tsx +0 -20
- package/src/components/ui/label.tsx +0 -18
- package/src/components/ui/popover.tsx +0 -88
- package/src/components/ui/scroll-area.tsx +0 -53
- package/src/components/ui/select.tsx +0 -192
- package/src/components/ui/separator.tsx +0 -23
- package/src/components/ui/sheet.tsx +0 -127
- package/src/components/ui/sidebar.tsx +0 -723
- package/src/components/ui/skeleton.tsx +0 -13
- package/src/components/ui/spinner.tsx +0 -10
- package/src/components/ui/switch.tsx +0 -32
- package/src/components/ui/table.tsx +0 -99
- package/src/components/ui/tabs.tsx +0 -82
- package/src/components/ui/textarea.tsx +0 -18
- package/src/components/ui/tooltip.tsx +0 -70
- package/src/config/component-registry.ts +0 -190
- package/src/config/index.ts +0 -1099
- package/src/hooks/README.md +0 -269
- package/src/hooks/admin-provider.tsx +0 -110
- package/src/hooks/index.ts +0 -41
- package/src/hooks/store.ts +0 -248
- package/src/hooks/use-auth.ts +0 -168
- package/src/hooks/use-collection-db.ts +0 -209
- package/src/hooks/use-collection.ts +0 -156
- package/src/hooks/use-global.ts +0 -69
- package/src/hooks/use-mobile.ts +0 -21
- package/src/lib/utils.ts +0 -6
- package/src/styles/index.css +0 -340
- package/src/utils/index.ts +0 -6
- package/src/views/auth/auth-layout.tsx +0 -77
- package/src/views/auth/forgot-password-form.tsx +0 -192
- package/src/views/auth/index.ts +0 -21
- package/src/views/auth/login-form.tsx +0 -229
- package/src/views/auth/reset-password-form.tsx +0 -232
- package/src/views/collection/auto-form-fields.tsx +0 -982
- package/src/views/collection/collection-form.tsx +0 -186
- package/src/views/collection/collection-list.tsx +0 -223
- package/src/views/collection/form-field.tsx +0 -52
- package/src/views/collection/index.ts +0 -15
- package/src/views/common/index.ts +0 -8
- package/src/views/common/locale-switcher.tsx +0 -45
- package/src/views/common/version-history.tsx +0 -406
- package/src/views/index.ts +0 -25
- package/src/views/layout/admin-layout.tsx +0 -117
- package/src/views/layout/admin-router.tsx +0 -206
- package/src/views/layout/admin-sidebar.tsx +0 -185
- package/src/views/layout/index.ts +0 -12
- package/tsconfig.json +0 -13
- package/tsconfig.tsbuildinfo +0 -1
- package/tsdown.config.ts +0 -13
- package/vitest.config.ts +0 -29
package/src/config/index.ts
DELETED
|
@@ -1,1099 +0,0 @@
|
|
|
1
|
-
import type { Questpie } from "questpie";
|
|
2
|
-
import type { QuestpieClient } from "questpie/client";
|
|
3
|
-
|
|
4
|
-
// ============================================================================
|
|
5
|
-
// Base Types
|
|
6
|
-
// ============================================================================
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* I18n text can be a string, translation key object, or function
|
|
10
|
-
*/
|
|
11
|
-
export type I18nText =
|
|
12
|
-
| string
|
|
13
|
-
| { key: string; default?: string }
|
|
14
|
-
| ((ctx: AdminI18nContext) => string);
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* I18n context for translation and formatting
|
|
18
|
-
*/
|
|
19
|
-
export type AdminI18nContext = {
|
|
20
|
-
locale: string;
|
|
21
|
-
dir: "ltr" | "rtl";
|
|
22
|
-
t: (key: string, vars?: Record<string, unknown>, fallback?: string) => string;
|
|
23
|
-
formatDate: (v: Date | string, opts?: Intl.DateTimeFormatOptions) => string;
|
|
24
|
-
formatNumber: (v: number, opts?: Intl.NumberFormatOptions) => string;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Icon reference (component or icon name)
|
|
29
|
-
*/
|
|
30
|
-
export type IconRef = React.ComponentType<{ className?: string }> | string;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Component reference (React component)
|
|
34
|
-
*/
|
|
35
|
-
export type ComponentRef<TProps = any> = React.ComponentType<TProps>;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Dashboard widget configuration
|
|
39
|
-
*/
|
|
40
|
-
export type DashboardWidget = {
|
|
41
|
-
/**
|
|
42
|
-
* Widget ID
|
|
43
|
-
*/
|
|
44
|
-
id: string;
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Widget type (for built-in widgets) or component (for custom)
|
|
48
|
-
*/
|
|
49
|
-
type?: "stats" | "chart" | "recent-items" | "quick-actions" | "custom";
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Custom component
|
|
53
|
-
*/
|
|
54
|
-
component?: ComponentRef;
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Widget title
|
|
58
|
-
*/
|
|
59
|
-
title?: string;
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Widget description
|
|
63
|
-
*/
|
|
64
|
-
description?: string;
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Grid position
|
|
68
|
-
*/
|
|
69
|
-
position?: {
|
|
70
|
-
x: number;
|
|
71
|
-
y: number;
|
|
72
|
-
w: number; // width in grid units
|
|
73
|
-
h: number; // height in grid units
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Widget configuration (varies by type)
|
|
78
|
-
*/
|
|
79
|
-
config?: any;
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Dashboard configuration
|
|
84
|
-
*/
|
|
85
|
-
export type DashboardConfig = {
|
|
86
|
-
/**
|
|
87
|
-
* Dashboard title
|
|
88
|
-
*/
|
|
89
|
-
title?: string;
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Dashboard description
|
|
93
|
-
*/
|
|
94
|
-
description?: string;
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Widgets to display
|
|
98
|
-
*/
|
|
99
|
-
widgets?: DashboardWidget[];
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Grid columns (default: 12)
|
|
103
|
-
*/
|
|
104
|
-
columns?: number;
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Row height in pixels (default: 80)
|
|
108
|
-
*/
|
|
109
|
-
rowHeight?: number;
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Allow users to customize layout
|
|
113
|
-
*/
|
|
114
|
-
customizable?: boolean;
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Custom dashboard component (overrides widgets)
|
|
118
|
-
*/
|
|
119
|
-
component?: ComponentRef;
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Custom page configuration
|
|
124
|
-
*/
|
|
125
|
-
export type CustomPageConfig = {
|
|
126
|
-
/**
|
|
127
|
-
* Page ID (used in routing)
|
|
128
|
-
*/
|
|
129
|
-
id: string;
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Page label (shown in sidebar)
|
|
133
|
-
*/
|
|
134
|
-
label: string;
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Icon
|
|
138
|
-
*/
|
|
139
|
-
icon?: IconRef;
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Page path (e.g., "/admin/settings")
|
|
143
|
-
*/
|
|
144
|
-
path: string;
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Page component
|
|
148
|
-
*/
|
|
149
|
-
component: ComponentRef;
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Show in sidebar navigation
|
|
153
|
-
*/
|
|
154
|
-
showInNav?: boolean;
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Navigation group
|
|
158
|
-
*/
|
|
159
|
-
group?: string;
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Navigation order
|
|
163
|
-
*/
|
|
164
|
-
order?: number;
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Required permissions
|
|
168
|
-
*/
|
|
169
|
-
permissions?: string[];
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* Admin app configuration
|
|
174
|
-
*/
|
|
175
|
-
export type AdminAppConfig = {
|
|
176
|
-
brand?: {
|
|
177
|
-
name?: I18nText;
|
|
178
|
-
logo?: ComponentRef;
|
|
179
|
-
homeRoute?: string;
|
|
180
|
-
};
|
|
181
|
-
locales?: {
|
|
182
|
-
default: string;
|
|
183
|
-
available: string[];
|
|
184
|
-
};
|
|
185
|
-
preview?: {
|
|
186
|
-
enabled?: boolean;
|
|
187
|
-
route?: string;
|
|
188
|
-
};
|
|
189
|
-
debug?: {
|
|
190
|
-
showQueryDevtools?: boolean;
|
|
191
|
-
showRouterDevtools?: boolean;
|
|
192
|
-
};
|
|
193
|
-
/**
|
|
194
|
-
* Dashboard configuration
|
|
195
|
-
*/
|
|
196
|
-
dashboard?: DashboardConfig;
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* Custom pages
|
|
200
|
-
*/
|
|
201
|
-
pages?: CustomPageConfig[];
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* List view configuration
|
|
206
|
-
*/
|
|
207
|
-
export type ListConfig = {
|
|
208
|
-
/**
|
|
209
|
-
* Columns to display by default
|
|
210
|
-
*/
|
|
211
|
-
defaultColumns?: string[];
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* Default sort configuration
|
|
215
|
-
*/
|
|
216
|
-
defaultSort?: {
|
|
217
|
-
field: string;
|
|
218
|
-
direction: "asc" | "desc";
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
/**
|
|
222
|
-
* Relations to eager-load with the list
|
|
223
|
-
*/
|
|
224
|
-
with?: string[];
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* Items per page
|
|
228
|
-
*/
|
|
229
|
-
pageSize?: number;
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* Enable search
|
|
233
|
-
*/
|
|
234
|
-
searchable?: boolean;
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* Searchable fields
|
|
238
|
-
*/
|
|
239
|
-
searchFields?: string[];
|
|
240
|
-
};
|
|
241
|
-
|
|
242
|
-
/**
|
|
243
|
-
* Layout types for sections
|
|
244
|
-
*/
|
|
245
|
-
export type SectionLayout =
|
|
246
|
-
| "auto" // Automatic vertical stack
|
|
247
|
-
| "columns" // Multi-column layout
|
|
248
|
-
| "grid" // CSS grid layout
|
|
249
|
-
| "inline"; // Horizontal inline layout
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
* Field layout configuration
|
|
253
|
-
*/
|
|
254
|
-
export type FieldLayout = {
|
|
255
|
-
/**
|
|
256
|
-
* Field name
|
|
257
|
-
*/
|
|
258
|
-
field: string;
|
|
259
|
-
|
|
260
|
-
/**
|
|
261
|
-
* Column span (e.g., "1", "2", "full", "1/2", "2/3")
|
|
262
|
-
*/
|
|
263
|
-
span?: string | number;
|
|
264
|
-
|
|
265
|
-
/**
|
|
266
|
-
* Row span
|
|
267
|
-
*/
|
|
268
|
-
rowSpan?: number;
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
* Custom width (e.g., "200px", "50%", "auto")
|
|
272
|
-
*/
|
|
273
|
-
width?: string;
|
|
274
|
-
};
|
|
275
|
-
|
|
276
|
-
/**
|
|
277
|
-
* Section configuration
|
|
278
|
-
*/
|
|
279
|
-
export type SectionConfig = {
|
|
280
|
-
/**
|
|
281
|
-
* Section title
|
|
282
|
-
*/
|
|
283
|
-
title?: string;
|
|
284
|
-
|
|
285
|
-
/**
|
|
286
|
-
* Section description
|
|
287
|
-
*/
|
|
288
|
-
description?: string;
|
|
289
|
-
|
|
290
|
-
/**
|
|
291
|
-
* Fields in this section (simple array or advanced layout)
|
|
292
|
-
*/
|
|
293
|
-
fields: string[] | FieldLayout[];
|
|
294
|
-
|
|
295
|
-
/**
|
|
296
|
-
* Layout type
|
|
297
|
-
*/
|
|
298
|
-
layout?: SectionLayout;
|
|
299
|
-
|
|
300
|
-
/**
|
|
301
|
-
* Number of columns (for "columns" layout)
|
|
302
|
-
*/
|
|
303
|
-
columns?: number;
|
|
304
|
-
|
|
305
|
-
/**
|
|
306
|
-
* Grid configuration (for "grid" layout)
|
|
307
|
-
*/
|
|
308
|
-
grid?: {
|
|
309
|
-
/**
|
|
310
|
-
* Number of columns in grid
|
|
311
|
-
*/
|
|
312
|
-
columns: number;
|
|
313
|
-
|
|
314
|
-
/**
|
|
315
|
-
* Gap between items (in tailwind spacing units)
|
|
316
|
-
*/
|
|
317
|
-
gap?: number;
|
|
318
|
-
|
|
319
|
-
/**
|
|
320
|
-
* Responsive breakpoints
|
|
321
|
-
*/
|
|
322
|
-
responsive?: {
|
|
323
|
-
sm?: number; // columns at sm breakpoint
|
|
324
|
-
md?: number; // columns at md breakpoint
|
|
325
|
-
lg?: number; // columns at lg breakpoint
|
|
326
|
-
};
|
|
327
|
-
};
|
|
328
|
-
|
|
329
|
-
/**
|
|
330
|
-
* Is collapsible
|
|
331
|
-
*/
|
|
332
|
-
collapsible?: boolean;
|
|
333
|
-
|
|
334
|
-
/**
|
|
335
|
-
* Default open state (if collapsible)
|
|
336
|
-
*/
|
|
337
|
-
defaultOpen?: boolean;
|
|
338
|
-
|
|
339
|
-
/**
|
|
340
|
-
* Conditional visibility
|
|
341
|
-
*/
|
|
342
|
-
visible?: boolean | ((values: any) => boolean);
|
|
343
|
-
|
|
344
|
-
/**
|
|
345
|
-
* Custom CSS class
|
|
346
|
-
*/
|
|
347
|
-
className?: string;
|
|
348
|
-
};
|
|
349
|
-
|
|
350
|
-
/**
|
|
351
|
-
* Tab configuration
|
|
352
|
-
*/
|
|
353
|
-
export type TabConfig = {
|
|
354
|
-
/**
|
|
355
|
-
* Tab ID
|
|
356
|
-
*/
|
|
357
|
-
id: string;
|
|
358
|
-
|
|
359
|
-
/**
|
|
360
|
-
* Tab label
|
|
361
|
-
*/
|
|
362
|
-
label: string;
|
|
363
|
-
|
|
364
|
-
/**
|
|
365
|
-
* Icon (optional)
|
|
366
|
-
*/
|
|
367
|
-
icon?: string;
|
|
368
|
-
|
|
369
|
-
/**
|
|
370
|
-
* Sections within this tab
|
|
371
|
-
*/
|
|
372
|
-
sections?: SectionConfig[];
|
|
373
|
-
|
|
374
|
-
/**
|
|
375
|
-
* Or simple field list
|
|
376
|
-
*/
|
|
377
|
-
fields?: string[];
|
|
378
|
-
|
|
379
|
-
/**
|
|
380
|
-
* Conditional visibility
|
|
381
|
-
*/
|
|
382
|
-
visible?: boolean | ((values: any) => boolean);
|
|
383
|
-
};
|
|
384
|
-
|
|
385
|
-
/**
|
|
386
|
-
* Edit/Create form configuration
|
|
387
|
-
*/
|
|
388
|
-
export type EditConfig = {
|
|
389
|
-
/**
|
|
390
|
-
* Field order and visibility (auto-detected if not specified)
|
|
391
|
-
*/
|
|
392
|
-
fields?: string[];
|
|
393
|
-
|
|
394
|
-
/**
|
|
395
|
-
* Fields to exclude from form
|
|
396
|
-
*/
|
|
397
|
-
exclude?: string[];
|
|
398
|
-
|
|
399
|
-
/**
|
|
400
|
-
* Group fields into sections
|
|
401
|
-
*/
|
|
402
|
-
sections?: SectionConfig[];
|
|
403
|
-
|
|
404
|
-
/**
|
|
405
|
-
* Organize into tabs
|
|
406
|
-
*/
|
|
407
|
-
tabs?: TabConfig[];
|
|
408
|
-
|
|
409
|
-
/**
|
|
410
|
-
* Sidebar fields (meta info)
|
|
411
|
-
*/
|
|
412
|
-
sidebar?: {
|
|
413
|
-
/**
|
|
414
|
-
* Fields to show in sidebar
|
|
415
|
-
*/
|
|
416
|
-
fields: string[];
|
|
417
|
-
|
|
418
|
-
/**
|
|
419
|
-
* Sidebar position
|
|
420
|
-
*/
|
|
421
|
-
position?: "right" | "left";
|
|
422
|
-
|
|
423
|
-
/**
|
|
424
|
-
* Sidebar width
|
|
425
|
-
*/
|
|
426
|
-
width?: string;
|
|
427
|
-
};
|
|
428
|
-
|
|
429
|
-
/**
|
|
430
|
-
* Main content layout (when sidebar is present)
|
|
431
|
-
*/
|
|
432
|
-
layout?: "full" | "with-sidebar";
|
|
433
|
-
|
|
434
|
-
/**
|
|
435
|
-
* Show version history
|
|
436
|
-
*/
|
|
437
|
-
showVersionHistory?: boolean;
|
|
438
|
-
|
|
439
|
-
/**
|
|
440
|
-
* Enable draft mode
|
|
441
|
-
*/
|
|
442
|
-
enableDrafts?: boolean;
|
|
443
|
-
};
|
|
444
|
-
|
|
445
|
-
/**
|
|
446
|
-
* Field configuration
|
|
447
|
-
*/
|
|
448
|
-
export type FieldConfig = {
|
|
449
|
-
/**
|
|
450
|
-
* Field label
|
|
451
|
-
*/
|
|
452
|
-
label?: string;
|
|
453
|
-
|
|
454
|
-
/**
|
|
455
|
-
* Field description
|
|
456
|
-
*/
|
|
457
|
-
description?: string;
|
|
458
|
-
|
|
459
|
-
/**
|
|
460
|
-
* Placeholder text
|
|
461
|
-
*/
|
|
462
|
-
placeholder?: string;
|
|
463
|
-
|
|
464
|
-
/**
|
|
465
|
-
* Helper text
|
|
466
|
-
*/
|
|
467
|
-
helperText?: string;
|
|
468
|
-
|
|
469
|
-
/**
|
|
470
|
-
* Custom component (from registry or inline)
|
|
471
|
-
*/
|
|
472
|
-
component?: string | React.ComponentType<any>;
|
|
473
|
-
|
|
474
|
-
/**
|
|
475
|
-
* Conditional visibility
|
|
476
|
-
*/
|
|
477
|
-
visible?: boolean | ((values: any) => boolean);
|
|
478
|
-
|
|
479
|
-
/**
|
|
480
|
-
* Hide field entirely
|
|
481
|
-
*/
|
|
482
|
-
hidden?: boolean;
|
|
483
|
-
|
|
484
|
-
/**
|
|
485
|
-
* Conditional readonly
|
|
486
|
-
*/
|
|
487
|
-
readOnly?: boolean | ((values: any) => boolean);
|
|
488
|
-
|
|
489
|
-
/**
|
|
490
|
-
* Conditional disabled
|
|
491
|
-
*/
|
|
492
|
-
disabled?: boolean | ((values: any) => boolean);
|
|
493
|
-
|
|
494
|
-
/**
|
|
495
|
-
* Field type override
|
|
496
|
-
*/
|
|
497
|
-
type?: string;
|
|
498
|
-
|
|
499
|
-
/**
|
|
500
|
-
* Localized (i18n) field
|
|
501
|
-
*/
|
|
502
|
-
localized?: boolean;
|
|
503
|
-
|
|
504
|
-
/**
|
|
505
|
-
* Is required
|
|
506
|
-
*/
|
|
507
|
-
required?: boolean | ((values: any) => boolean);
|
|
508
|
-
|
|
509
|
-
/**
|
|
510
|
-
* Options for select/enum fields
|
|
511
|
-
*/
|
|
512
|
-
options?:
|
|
513
|
-
| Array<{ label: string; value: any }>
|
|
514
|
-
| ((values: any) => Array<{ label: string; value: any }>);
|
|
515
|
-
|
|
516
|
-
/**
|
|
517
|
-
* Array field configuration
|
|
518
|
-
*/
|
|
519
|
-
array?: {
|
|
520
|
-
/**
|
|
521
|
-
* Item type
|
|
522
|
-
*/
|
|
523
|
-
itemType?: "text" | "number" | "email" | "textarea" | "select";
|
|
524
|
-
|
|
525
|
-
/**
|
|
526
|
-
* Options for select items
|
|
527
|
-
*/
|
|
528
|
-
options?: Array<{ label: string; value: any }>;
|
|
529
|
-
|
|
530
|
-
/**
|
|
531
|
-
* Enable ordering
|
|
532
|
-
*/
|
|
533
|
-
orderable?: boolean;
|
|
534
|
-
|
|
535
|
-
/**
|
|
536
|
-
* Minimum number of items
|
|
537
|
-
*/
|
|
538
|
-
minItems?: number;
|
|
539
|
-
|
|
540
|
-
/**
|
|
541
|
-
* Maximum number of items
|
|
542
|
-
*/
|
|
543
|
-
maxItems?: number;
|
|
544
|
-
|
|
545
|
-
/**
|
|
546
|
-
* Placeholder for item input
|
|
547
|
-
*/
|
|
548
|
-
placeholder?: string;
|
|
549
|
-
};
|
|
550
|
-
|
|
551
|
-
/**
|
|
552
|
-
* Rich text editor configuration
|
|
553
|
-
*/
|
|
554
|
-
richText?: {
|
|
555
|
-
/**
|
|
556
|
-
* Output format
|
|
557
|
-
*/
|
|
558
|
-
outputFormat?: "json" | "html" | "markdown";
|
|
559
|
-
|
|
560
|
-
/**
|
|
561
|
-
* Enable image uploads
|
|
562
|
-
*/
|
|
563
|
-
enableImages?: boolean;
|
|
564
|
-
|
|
565
|
-
/**
|
|
566
|
-
* Max character limit
|
|
567
|
-
*/
|
|
568
|
-
maxCharacters?: number;
|
|
569
|
-
|
|
570
|
-
/**
|
|
571
|
-
* Show character count
|
|
572
|
-
*/
|
|
573
|
-
showCharacterCount?: boolean;
|
|
574
|
-
|
|
575
|
-
/**
|
|
576
|
-
* Custom Tiptap extensions
|
|
577
|
-
*/
|
|
578
|
-
extensions?: any[];
|
|
579
|
-
|
|
580
|
-
/**
|
|
581
|
-
* Feature toggles
|
|
582
|
-
*/
|
|
583
|
-
features?: {
|
|
584
|
-
toolbar?: boolean;
|
|
585
|
-
bubbleMenu?: boolean;
|
|
586
|
-
slashCommands?: boolean;
|
|
587
|
-
history?: boolean;
|
|
588
|
-
heading?: boolean;
|
|
589
|
-
bold?: boolean;
|
|
590
|
-
italic?: boolean;
|
|
591
|
-
underline?: boolean;
|
|
592
|
-
strike?: boolean;
|
|
593
|
-
code?: boolean;
|
|
594
|
-
codeBlock?: boolean;
|
|
595
|
-
blockquote?: boolean;
|
|
596
|
-
bulletList?: boolean;
|
|
597
|
-
orderedList?: boolean;
|
|
598
|
-
horizontalRule?: boolean;
|
|
599
|
-
align?: boolean;
|
|
600
|
-
link?: boolean;
|
|
601
|
-
image?: boolean;
|
|
602
|
-
table?: boolean;
|
|
603
|
-
tableControls?: boolean;
|
|
604
|
-
characterCount?: boolean;
|
|
605
|
-
};
|
|
606
|
-
|
|
607
|
-
/**
|
|
608
|
-
* Image upload handler
|
|
609
|
-
*/
|
|
610
|
-
onImageUpload?: (file: File) => Promise<string>;
|
|
611
|
-
};
|
|
612
|
-
|
|
613
|
-
/**
|
|
614
|
-
* Relation field configuration
|
|
615
|
-
*/
|
|
616
|
-
relation?: {
|
|
617
|
-
/**
|
|
618
|
-
* Target collection name
|
|
619
|
-
*/
|
|
620
|
-
targetCollection: string;
|
|
621
|
-
|
|
622
|
-
/**
|
|
623
|
-
* Mode: picker (multiple), inline, create
|
|
624
|
-
*/
|
|
625
|
-
mode?: "picker" | "inline" | "create";
|
|
626
|
-
|
|
627
|
-
/**
|
|
628
|
-
* Filter options based on form values
|
|
629
|
-
*/
|
|
630
|
-
filter?: (values: any) => any;
|
|
631
|
-
|
|
632
|
-
/**
|
|
633
|
-
* Enable drag-and-drop ordering (for multiple relations)
|
|
634
|
-
*/
|
|
635
|
-
orderable?: boolean;
|
|
636
|
-
};
|
|
637
|
-
|
|
638
|
-
/**
|
|
639
|
-
* Embedded collection configuration
|
|
640
|
-
*/
|
|
641
|
-
embedded?: {
|
|
642
|
-
/**
|
|
643
|
-
* Collection to embed
|
|
644
|
-
*/
|
|
645
|
-
collection: string;
|
|
646
|
-
|
|
647
|
-
/**
|
|
648
|
-
* Enable drag-and-drop ordering
|
|
649
|
-
*/
|
|
650
|
-
orderable?: boolean;
|
|
651
|
-
|
|
652
|
-
/**
|
|
653
|
-
* Display mode
|
|
654
|
-
*/
|
|
655
|
-
mode?: "inline" | "modal" | "drawer";
|
|
656
|
-
|
|
657
|
-
/**
|
|
658
|
-
* Row label
|
|
659
|
-
*/
|
|
660
|
-
rowLabel?: (item: any) => string;
|
|
661
|
-
};
|
|
662
|
-
|
|
663
|
-
/**
|
|
664
|
-
* List view configuration for this field
|
|
665
|
-
*/
|
|
666
|
-
list?: {
|
|
667
|
-
/**
|
|
668
|
-
* Custom cell renderer
|
|
669
|
-
*/
|
|
670
|
-
renderCell?: string | React.ComponentType<any>;
|
|
671
|
-
|
|
672
|
-
/**
|
|
673
|
-
* Column width
|
|
674
|
-
*/
|
|
675
|
-
width?: number;
|
|
676
|
-
|
|
677
|
-
/**
|
|
678
|
-
* Is sortable
|
|
679
|
-
*/
|
|
680
|
-
sortable?: boolean;
|
|
681
|
-
};
|
|
682
|
-
|
|
683
|
-
/**
|
|
684
|
-
* Validation function
|
|
685
|
-
*/
|
|
686
|
-
validate?: (value: any, values: any) => string | undefined;
|
|
687
|
-
};
|
|
688
|
-
|
|
689
|
-
/**
|
|
690
|
-
* Admin collection configuration (UI only)
|
|
691
|
-
*/
|
|
692
|
-
export type AdminCollectionConfig<
|
|
693
|
-
CMS extends Questpie<any>,
|
|
694
|
-
K extends keyof CMS["config"]["collections"],
|
|
695
|
-
> = {
|
|
696
|
-
label?: I18nText;
|
|
697
|
-
description?: I18nText;
|
|
698
|
-
icon?: IconRef;
|
|
699
|
-
group?: string;
|
|
700
|
-
|
|
701
|
-
/**
|
|
702
|
-
* List view configuration
|
|
703
|
-
*/
|
|
704
|
-
list?: ListConfig;
|
|
705
|
-
|
|
706
|
-
/**
|
|
707
|
-
* Edit/Create form configuration
|
|
708
|
-
*/
|
|
709
|
-
edit?: EditConfig;
|
|
710
|
-
|
|
711
|
-
/**
|
|
712
|
-
* Field-specific overrides
|
|
713
|
-
*/
|
|
714
|
-
fields?: Record<string, FieldConfig>;
|
|
715
|
-
|
|
716
|
-
/**
|
|
717
|
-
* Enable versioning for this collection
|
|
718
|
-
*/
|
|
719
|
-
versioned?: boolean;
|
|
720
|
-
|
|
721
|
-
/**
|
|
722
|
-
* Enable audit logging
|
|
723
|
-
*/
|
|
724
|
-
auditLog?:
|
|
725
|
-
| boolean
|
|
726
|
-
| {
|
|
727
|
-
/**
|
|
728
|
-
* Fields to track
|
|
729
|
-
*/
|
|
730
|
-
fields?: string[];
|
|
731
|
-
|
|
732
|
-
/**
|
|
733
|
-
* Track who made changes
|
|
734
|
-
*/
|
|
735
|
-
trackUser?: boolean;
|
|
736
|
-
|
|
737
|
-
/**
|
|
738
|
-
* Retention period (in days)
|
|
739
|
-
*/
|
|
740
|
-
retentionDays?: number;
|
|
741
|
-
};
|
|
742
|
-
};
|
|
743
|
-
|
|
744
|
-
/**
|
|
745
|
-
* Admin collections map (key = collection name)
|
|
746
|
-
*/
|
|
747
|
-
export type AdminCollectionMap<CMS extends Questpie<any>> = {
|
|
748
|
-
[K in keyof CMS["config"]["collections"]]?: AdminCollectionConfig<CMS, K>;
|
|
749
|
-
};
|
|
750
|
-
|
|
751
|
-
/**
|
|
752
|
-
* Complete admin configuration
|
|
753
|
-
*/
|
|
754
|
-
export type AdminConfig<CMS extends Questpie<any>> = {
|
|
755
|
-
app: AdminAppConfig;
|
|
756
|
-
collections?: AdminCollectionMap<CMS>;
|
|
757
|
-
};
|
|
758
|
-
|
|
759
|
-
/**
|
|
760
|
-
* Define admin configuration with type inference
|
|
761
|
-
*
|
|
762
|
-
* @example
|
|
763
|
-
* ```ts
|
|
764
|
-
* import { defineAdminConfig } from '@questpie/admin/config'
|
|
765
|
-
* import type { cms } from './server/cms'
|
|
766
|
-
*
|
|
767
|
-
* export const admin = defineAdminConfig<typeof cms>()({
|
|
768
|
-
* app: {
|
|
769
|
-
* brand: { name: "My CMS" }
|
|
770
|
-
* },
|
|
771
|
-
* collections: {
|
|
772
|
-
* posts: {
|
|
773
|
-
* label: "Posts",
|
|
774
|
-
* icon: "posts"
|
|
775
|
-
* }
|
|
776
|
-
* }
|
|
777
|
-
* })
|
|
778
|
-
* ```
|
|
779
|
-
*/
|
|
780
|
-
export const defineAdminConfig =
|
|
781
|
-
<CMS extends Questpie<any>>() =>
|
|
782
|
-
<TConfig extends AdminConfig<CMS>>(config: TConfig): TConfig => {
|
|
783
|
-
return config;
|
|
784
|
-
};
|
|
785
|
-
|
|
786
|
-
/**
|
|
787
|
-
* Define a single collection config (for modular configs)
|
|
788
|
-
*
|
|
789
|
-
* @example
|
|
790
|
-
* ```ts
|
|
791
|
-
* // collections/posts.admin.ts
|
|
792
|
-
* import { defineCollectionConfig } from '@questpie/admin/config'
|
|
793
|
-
* import type { cms } from '../server/cms'
|
|
794
|
-
*
|
|
795
|
-
* export const postsAdminConfig = defineCollectionConfig<typeof cms, "posts">()({
|
|
796
|
-
* label: "Blog Posts",
|
|
797
|
-
* icon: "article",
|
|
798
|
-
* list: {
|
|
799
|
-
* defaultColumns: ["title", "status", "createdAt"],
|
|
800
|
-
* },
|
|
801
|
-
* edit: {
|
|
802
|
-
* sections: [
|
|
803
|
-
* { title: "Content", fields: ["title", "content"] },
|
|
804
|
-
* { title: "Settings", fields: ["status", "publishedAt"] },
|
|
805
|
-
* ],
|
|
806
|
-
* },
|
|
807
|
-
* })
|
|
808
|
-
* ```
|
|
809
|
-
*/
|
|
810
|
-
export const defineCollectionConfig =
|
|
811
|
-
<CMS extends Questpie<any>, K extends keyof CMS["config"]["collections"]>() =>
|
|
812
|
-
<TConfig extends AdminCollectionConfig<CMS, K>>(config: TConfig): TConfig => {
|
|
813
|
-
return config;
|
|
814
|
-
};
|
|
815
|
-
|
|
816
|
-
/**
|
|
817
|
-
* Merge multiple admin configs into one
|
|
818
|
-
*
|
|
819
|
-
* @example
|
|
820
|
-
* ```ts
|
|
821
|
-
* const admin = defineAdminConfig<typeof cms>()(
|
|
822
|
-
* mergeAdminConfigs([
|
|
823
|
-
* baseConfig,
|
|
824
|
-
* postsConfig,
|
|
825
|
-
* productsConfig,
|
|
826
|
-
* ])
|
|
827
|
-
* )
|
|
828
|
-
* ```
|
|
829
|
-
*/
|
|
830
|
-
export function mergeAdminConfigs<CMS extends Questpie<any>>(
|
|
831
|
-
configs: Partial<AdminConfig<CMS>>[],
|
|
832
|
-
): AdminConfig<CMS> {
|
|
833
|
-
const result: AdminConfig<CMS> = { app: {} };
|
|
834
|
-
for (const config of configs) {
|
|
835
|
-
if (config.app) {
|
|
836
|
-
result.app = { ...result.app, ...config.app };
|
|
837
|
-
}
|
|
838
|
-
if (config.collections) {
|
|
839
|
-
result.collections = {
|
|
840
|
-
...result.collections,
|
|
841
|
-
...config.collections,
|
|
842
|
-
} as AdminCollectionMap<CMS>;
|
|
843
|
-
}
|
|
844
|
-
}
|
|
845
|
-
return result;
|
|
846
|
-
}
|
|
847
|
-
|
|
848
|
-
/**
|
|
849
|
-
* Define app config separately
|
|
850
|
-
*
|
|
851
|
-
* @example
|
|
852
|
-
* ```ts
|
|
853
|
-
* export const appConfig = defineAppConfig({
|
|
854
|
-
* brand: { name: "My CMS" },
|
|
855
|
-
* locales: { default: "en", available: ["en", "sk"] },
|
|
856
|
-
* })
|
|
857
|
-
* ```
|
|
858
|
-
*/
|
|
859
|
-
export const defineAppConfig = <TConfig extends AdminAppConfig>(
|
|
860
|
-
config: TConfig,
|
|
861
|
-
): TConfig => {
|
|
862
|
-
return config;
|
|
863
|
-
};
|
|
864
|
-
|
|
865
|
-
/**
|
|
866
|
-
* Define dashboard config
|
|
867
|
-
*
|
|
868
|
-
* @example
|
|
869
|
-
* ```ts
|
|
870
|
-
* export const dashboardConfig = defineDashboardConfig({
|
|
871
|
-
* widgets: [
|
|
872
|
-
* { id: "stats", type: "stats", position: { x: 0, y: 0, w: 4, h: 2 } },
|
|
873
|
-
* ],
|
|
874
|
-
* })
|
|
875
|
-
* ```
|
|
876
|
-
*/
|
|
877
|
-
export const defineDashboardConfig = <TConfig extends DashboardConfig>(
|
|
878
|
-
config: TConfig,
|
|
879
|
-
): TConfig => {
|
|
880
|
-
return config;
|
|
881
|
-
};
|
|
882
|
-
|
|
883
|
-
// ============================================================================
|
|
884
|
-
// Views Configuration
|
|
885
|
-
// ============================================================================
|
|
886
|
-
|
|
887
|
-
/**
|
|
888
|
-
* Props for auth layout view
|
|
889
|
-
*/
|
|
890
|
-
export type AuthLayoutViewProps = {
|
|
891
|
-
title: string;
|
|
892
|
-
description?: string;
|
|
893
|
-
logo?: React.ReactNode;
|
|
894
|
-
footer?: React.ReactNode;
|
|
895
|
-
children: React.ReactNode;
|
|
896
|
-
className?: string;
|
|
897
|
-
};
|
|
898
|
-
|
|
899
|
-
/**
|
|
900
|
-
* Props for login form view
|
|
901
|
-
*/
|
|
902
|
-
export type LoginFormViewProps = {
|
|
903
|
-
onSubmit: (values: {
|
|
904
|
-
email: string;
|
|
905
|
-
password: string;
|
|
906
|
-
rememberMe?: boolean;
|
|
907
|
-
}) => Promise<void>;
|
|
908
|
-
onSignUpClick?: () => void;
|
|
909
|
-
onForgotPasswordClick?: () => void;
|
|
910
|
-
showRememberMe?: boolean;
|
|
911
|
-
showSignUp?: boolean;
|
|
912
|
-
showForgotPassword?: boolean;
|
|
913
|
-
defaultValues?: { email?: string; password?: string; rememberMe?: boolean };
|
|
914
|
-
className?: string;
|
|
915
|
-
error?: string | null;
|
|
916
|
-
};
|
|
917
|
-
|
|
918
|
-
/**
|
|
919
|
-
* Props for forgot password form view
|
|
920
|
-
*/
|
|
921
|
-
export type ForgotPasswordFormViewProps = {
|
|
922
|
-
onSubmit: (values: { email: string }) => Promise<void>;
|
|
923
|
-
onBackToLoginClick?: () => void;
|
|
924
|
-
defaultValues?: { email?: string };
|
|
925
|
-
className?: string;
|
|
926
|
-
error?: string | null;
|
|
927
|
-
};
|
|
928
|
-
|
|
929
|
-
/**
|
|
930
|
-
* Props for reset password form view
|
|
931
|
-
*/
|
|
932
|
-
export type ResetPasswordFormViewProps = {
|
|
933
|
-
token: string;
|
|
934
|
-
onSubmit: (values: {
|
|
935
|
-
password: string;
|
|
936
|
-
confirmPassword: string;
|
|
937
|
-
token: string;
|
|
938
|
-
}) => Promise<void>;
|
|
939
|
-
onBackToLoginClick?: () => void;
|
|
940
|
-
minPasswordLength?: number;
|
|
941
|
-
className?: string;
|
|
942
|
-
error?: string | null;
|
|
943
|
-
};
|
|
944
|
-
|
|
945
|
-
/**
|
|
946
|
-
* Props for admin layout view
|
|
947
|
-
*/
|
|
948
|
-
export type AdminLayoutViewProps = {
|
|
949
|
-
children: React.ReactNode;
|
|
950
|
-
sidebar?: React.ReactNode;
|
|
951
|
-
header?: React.ReactNode;
|
|
952
|
-
className?: string;
|
|
953
|
-
};
|
|
954
|
-
|
|
955
|
-
/**
|
|
956
|
-
* Props for admin sidebar view
|
|
957
|
-
*/
|
|
958
|
-
export type AdminSidebarViewProps = {
|
|
959
|
-
collections?: Array<{
|
|
960
|
-
name: string;
|
|
961
|
-
label: string;
|
|
962
|
-
icon?: IconRef;
|
|
963
|
-
href: string;
|
|
964
|
-
}>;
|
|
965
|
-
globals?: Array<{
|
|
966
|
-
name: string;
|
|
967
|
-
label: string;
|
|
968
|
-
icon?: IconRef;
|
|
969
|
-
href: string;
|
|
970
|
-
}>;
|
|
971
|
-
customItems?: Array<{
|
|
972
|
-
id: string;
|
|
973
|
-
label: string;
|
|
974
|
-
icon?: IconRef;
|
|
975
|
-
href: string;
|
|
976
|
-
group?: string;
|
|
977
|
-
}>;
|
|
978
|
-
activeItem?: string;
|
|
979
|
-
onItemClick?: (item: string) => void;
|
|
980
|
-
collapsed?: boolean;
|
|
981
|
-
onCollapsedChange?: (collapsed: boolean) => void;
|
|
982
|
-
};
|
|
983
|
-
|
|
984
|
-
/**
|
|
985
|
-
* Props for collection list view
|
|
986
|
-
*/
|
|
987
|
-
export type CollectionListViewProps<TItem = any> = {
|
|
988
|
-
collection: string;
|
|
989
|
-
items: TItem[];
|
|
990
|
-
columns: Array<{
|
|
991
|
-
id: string;
|
|
992
|
-
header: string;
|
|
993
|
-
accessorKey?: string;
|
|
994
|
-
cell?: (item: TItem) => React.ReactNode;
|
|
995
|
-
}>;
|
|
996
|
-
isLoading?: boolean;
|
|
997
|
-
error?: Error | null;
|
|
998
|
-
onItemClick?: (item: TItem) => void;
|
|
999
|
-
onCreateClick?: () => void;
|
|
1000
|
-
onDeleteClick?: (item: TItem) => void;
|
|
1001
|
-
pagination?: {
|
|
1002
|
-
page: number;
|
|
1003
|
-
pageSize: number;
|
|
1004
|
-
total: number;
|
|
1005
|
-
onPageChange: (page: number) => void;
|
|
1006
|
-
};
|
|
1007
|
-
search?: {
|
|
1008
|
-
value: string;
|
|
1009
|
-
onChange: (value: string) => void;
|
|
1010
|
-
placeholder?: string;
|
|
1011
|
-
};
|
|
1012
|
-
};
|
|
1013
|
-
|
|
1014
|
-
/**
|
|
1015
|
-
* Props for collection form view
|
|
1016
|
-
*/
|
|
1017
|
-
export type CollectionFormViewProps<TItem = any> = {
|
|
1018
|
-
collection: string;
|
|
1019
|
-
item?: TItem | null;
|
|
1020
|
-
isLoading?: boolean;
|
|
1021
|
-
error?: Error | null;
|
|
1022
|
-
onSubmit: (data: Partial<TItem>) => Promise<void>;
|
|
1023
|
-
onCancel?: () => void;
|
|
1024
|
-
onDelete?: () => void;
|
|
1025
|
-
fields: React.ReactNode;
|
|
1026
|
-
isCreate?: boolean;
|
|
1027
|
-
};
|
|
1028
|
-
|
|
1029
|
-
/**
|
|
1030
|
-
* Props for locale switcher view
|
|
1031
|
-
*/
|
|
1032
|
-
export type LocaleSwitcherViewProps = {
|
|
1033
|
-
currentLocale: string;
|
|
1034
|
-
availableLocales: string[];
|
|
1035
|
-
onLocaleChange: (locale: string) => void;
|
|
1036
|
-
disabled?: boolean;
|
|
1037
|
-
};
|
|
1038
|
-
|
|
1039
|
-
/**
|
|
1040
|
-
* Props for version history view
|
|
1041
|
-
*/
|
|
1042
|
-
export type VersionHistoryViewProps = {
|
|
1043
|
-
versions: Array<{
|
|
1044
|
-
id: string;
|
|
1045
|
-
createdAt: Date;
|
|
1046
|
-
createdBy?: string;
|
|
1047
|
-
changes?: string[];
|
|
1048
|
-
}>;
|
|
1049
|
-
currentVersionId?: string;
|
|
1050
|
-
onVersionSelect?: (versionId: string) => void;
|
|
1051
|
-
onVersionRestore?: (versionId: string) => void;
|
|
1052
|
-
isLoading?: boolean;
|
|
1053
|
-
};
|
|
1054
|
-
|
|
1055
|
-
/**
|
|
1056
|
-
* All view components registry type
|
|
1057
|
-
*/
|
|
1058
|
-
export type AdminViewsConfig = {
|
|
1059
|
-
// Auth views
|
|
1060
|
-
AuthLayout?: ComponentRef<AuthLayoutViewProps>;
|
|
1061
|
-
LoginForm?: ComponentRef<LoginFormViewProps>;
|
|
1062
|
-
ForgotPasswordForm?: ComponentRef<ForgotPasswordFormViewProps>;
|
|
1063
|
-
ResetPasswordForm?: ComponentRef<ResetPasswordFormViewProps>;
|
|
1064
|
-
|
|
1065
|
-
// Layout views
|
|
1066
|
-
AdminLayout?: ComponentRef<AdminLayoutViewProps>;
|
|
1067
|
-
AdminSidebar?: ComponentRef<AdminSidebarViewProps>;
|
|
1068
|
-
|
|
1069
|
-
// Collection views
|
|
1070
|
-
CollectionList?: ComponentRef<CollectionListViewProps>;
|
|
1071
|
-
CollectionForm?: ComponentRef<CollectionFormViewProps>;
|
|
1072
|
-
|
|
1073
|
-
// Utility views
|
|
1074
|
-
LocaleSwitcher?: ComponentRef<LocaleSwitcherViewProps>;
|
|
1075
|
-
VersionHistory?: ComponentRef<VersionHistoryViewProps>;
|
|
1076
|
-
|
|
1077
|
-
// Allow custom views
|
|
1078
|
-
[key: string]: ComponentRef<any> | undefined;
|
|
1079
|
-
};
|
|
1080
|
-
|
|
1081
|
-
/**
|
|
1082
|
-
* Define views configuration
|
|
1083
|
-
*
|
|
1084
|
-
* @example
|
|
1085
|
-
* ```ts
|
|
1086
|
-
* import { defineViewsConfig } from '@questpie/admin/config'
|
|
1087
|
-
* import { CustomLoginForm } from './components/CustomLoginForm'
|
|
1088
|
-
*
|
|
1089
|
-
* export const viewsConfig = defineViewsConfig({
|
|
1090
|
-
* LoginForm: CustomLoginForm,
|
|
1091
|
-
* // Override any default view
|
|
1092
|
-
* })
|
|
1093
|
-
* ```
|
|
1094
|
-
*/
|
|
1095
|
-
export const defineViewsConfig = <TConfig extends AdminViewsConfig>(
|
|
1096
|
-
config: TConfig,
|
|
1097
|
-
): TConfig => {
|
|
1098
|
-
return config;
|
|
1099
|
-
};
|