@questpie/admin 0.0.1 → 1.0.1
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-D7w7W1Hl.mjs +273 -0
- package/dist/bulk-upload-dialog-D7w7W1Hl.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-DbpZKSgH.d.mts +13585 -0
- package/dist/client-DbpZKSgH.d.mts.map +1 -0
- package/dist/client-njX1rZmi.mjs +22612 -0
- package/dist/client-njX1rZmi.mjs.map +1 -0
- package/dist/client.d.mts +3 -0
- package/dist/client.mjs +13 -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-mCY0pgZv.mjs +3 -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-CEwsdLwn.mjs +3 -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 +13 -0
- package/dist/login-page-BUnpCbCa.mjs +3 -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-CufHz3h3.mjs +3 -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-BNNzt_Z6.mjs +3 -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 -198
- 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
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AdminRouter Component
|
|
3
|
-
*
|
|
4
|
-
* Automatic routing for all collections from CMS + admin config
|
|
5
|
-
*
|
|
6
|
-
* URL Patterns:
|
|
7
|
-
* - /admin -> Dashboard
|
|
8
|
-
* - /admin/:collection -> List view
|
|
9
|
-
* - /admin/:collection/new -> Create form
|
|
10
|
-
* - /admin/:collection/:id -> Edit form
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import * as React from "react";
|
|
14
|
-
import { CollectionList } from "../collection/collection-list";
|
|
15
|
-
import { CollectionForm } from "../collection/collection-form";
|
|
16
|
-
import { AutoFormFields } from "../collection/auto-form-fields";
|
|
17
|
-
import { LocaleSwitcher } from "../common/locale-switcher";
|
|
18
|
-
import type { ComponentRegistry } from "../../config/component-registry";
|
|
19
|
-
|
|
20
|
-
export interface AdminRouterProps {
|
|
21
|
-
/**
|
|
22
|
-
* Admin configuration
|
|
23
|
-
*/
|
|
24
|
-
config: {
|
|
25
|
-
collections?: Record<
|
|
26
|
-
string,
|
|
27
|
-
{
|
|
28
|
-
label?: string;
|
|
29
|
-
list?: {
|
|
30
|
-
defaultColumns?: string[];
|
|
31
|
-
defaultSort?: { field: string; direction: "asc" | "desc" };
|
|
32
|
-
with?: string[];
|
|
33
|
-
};
|
|
34
|
-
fields?: Record<
|
|
35
|
-
string,
|
|
36
|
-
{
|
|
37
|
-
label?: string;
|
|
38
|
-
list?: {
|
|
39
|
-
renderCell?: string | React.ComponentType;
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
>;
|
|
43
|
-
}
|
|
44
|
-
>;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Current route segments (parsed from URL)
|
|
49
|
-
* Example: ["barbers", "123"] for /admin/barbers/123
|
|
50
|
-
*/
|
|
51
|
-
segments: string[];
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Navigate function (router-specific)
|
|
55
|
-
*/
|
|
56
|
-
navigate: (path: string) => void;
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Custom dashboard component
|
|
60
|
-
*/
|
|
61
|
-
DashboardComponent?: React.ComponentType;
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Custom collection components override
|
|
65
|
-
*/
|
|
66
|
-
collectionComponents?: Record<
|
|
67
|
-
string,
|
|
68
|
-
{
|
|
69
|
-
List?: React.ComponentType;
|
|
70
|
-
Form?: React.ComponentType;
|
|
71
|
-
}
|
|
72
|
-
>;
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Render custom form fields for collection
|
|
76
|
-
* If not provided, will use default field detection
|
|
77
|
-
*/
|
|
78
|
-
renderFormFields?: (collection: string) => React.ReactNode;
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Component registry
|
|
82
|
-
*/
|
|
83
|
-
registry?: ComponentRegistry;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Default Dashboard
|
|
88
|
-
*/
|
|
89
|
-
function DefaultDashboard() {
|
|
90
|
-
return (
|
|
91
|
-
<div className="container py-8">
|
|
92
|
-
<h1 className="mb-8 text-3xl font-bold">Dashboard</h1>
|
|
93
|
-
<div className="grid grid-cols-1 gap-6 md:grid-cols-2 lg:grid-cols-4">
|
|
94
|
-
<div className="rounded-lg border bg-card p-6">
|
|
95
|
-
<h3 className="font-semibold">Collections</h3>
|
|
96
|
-
<p className="mt-2 text-3xl font-bold">--</p>
|
|
97
|
-
</div>
|
|
98
|
-
</div>
|
|
99
|
-
</div>
|
|
100
|
-
);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export function AdminRouter({
|
|
104
|
-
config,
|
|
105
|
-
segments,
|
|
106
|
-
navigate,
|
|
107
|
-
DashboardComponent,
|
|
108
|
-
collectionComponents,
|
|
109
|
-
renderFormFields,
|
|
110
|
-
registry,
|
|
111
|
-
}: AdminRouterProps): React.ReactElement {
|
|
112
|
-
// Dashboard: no segments
|
|
113
|
-
if (segments.length === 0) {
|
|
114
|
-
const Dashboard = DashboardComponent || DefaultDashboard;
|
|
115
|
-
return <Dashboard />;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const [collection, idOrNew] = segments;
|
|
119
|
-
const collectionConfig = config.collections?.[collection];
|
|
120
|
-
|
|
121
|
-
// Custom collection component override
|
|
122
|
-
const customComponents = collectionComponents?.[collection];
|
|
123
|
-
|
|
124
|
-
// List view: /admin/:collection
|
|
125
|
-
if (!idOrNew) {
|
|
126
|
-
if (customComponents?.List) {
|
|
127
|
-
return <customComponents.List />;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
// Auto-generate columns from config
|
|
131
|
-
const columns = collectionConfig?.list?.defaultColumns?.map((field) => ({
|
|
132
|
-
accessorKey: field,
|
|
133
|
-
header: collectionConfig.fields?.[field]?.label || field,
|
|
134
|
-
})) || [{ accessorKey: "id", header: "ID" }];
|
|
135
|
-
|
|
136
|
-
const withRelations = collectionConfig?.list?.with;
|
|
137
|
-
|
|
138
|
-
return (
|
|
139
|
-
<div className="container py-8">
|
|
140
|
-
<CollectionList
|
|
141
|
-
collection={collection as any}
|
|
142
|
-
columns={columns as any}
|
|
143
|
-
baseFindOptions={
|
|
144
|
-
withRelations
|
|
145
|
-
? {
|
|
146
|
-
with: withRelations.reduce((acc, rel) => {
|
|
147
|
-
acc[rel] = true;
|
|
148
|
-
return acc;
|
|
149
|
-
}, {} as any),
|
|
150
|
-
}
|
|
151
|
-
: undefined
|
|
152
|
-
}
|
|
153
|
-
realtime={true}
|
|
154
|
-
headerActions={
|
|
155
|
-
<div className="flex items-center gap-2">
|
|
156
|
-
<LocaleSwitcher />
|
|
157
|
-
<button
|
|
158
|
-
type="button"
|
|
159
|
-
onClick={() => navigate(`/admin/${collection}/new`)}
|
|
160
|
-
className="rounded bg-primary px-4 py-2 text-primary-foreground"
|
|
161
|
-
>
|
|
162
|
-
Create {collectionConfig?.label || collection}
|
|
163
|
-
</button>
|
|
164
|
-
</div>
|
|
165
|
-
}
|
|
166
|
-
onRowClick={(item: any) => {
|
|
167
|
-
navigate(`/admin/${collection}/${item.id}`);
|
|
168
|
-
}}
|
|
169
|
-
/>
|
|
170
|
-
</div>
|
|
171
|
-
);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
// Form view: /admin/:collection/new or /admin/:collection/:id
|
|
175
|
-
const id = idOrNew === "new" ? undefined : idOrNew;
|
|
176
|
-
|
|
177
|
-
if (customComponents?.Form) {
|
|
178
|
-
return <customComponents.Form />;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
return (
|
|
182
|
-
<div className="container max-w-2xl py-8">
|
|
183
|
-
<CollectionForm
|
|
184
|
-
collection={collection as any}
|
|
185
|
-
id={id}
|
|
186
|
-
title={
|
|
187
|
-
id
|
|
188
|
-
? `Edit ${collectionConfig?.label || collection}`
|
|
189
|
-
: `New ${collectionConfig?.label || collection}`
|
|
190
|
-
}
|
|
191
|
-
headerActions={<LocaleSwitcher />}
|
|
192
|
-
onSuccess={() => navigate(`/admin/${collection}`)}
|
|
193
|
-
onCancel={() => navigate(`/admin/${collection}`)}
|
|
194
|
-
>
|
|
195
|
-
{renderFormFields?.(collection) || (
|
|
196
|
-
<AutoFormFields
|
|
197
|
-
collection={collection as any}
|
|
198
|
-
config={collectionConfig}
|
|
199
|
-
registry={registry}
|
|
200
|
-
allCollectionsConfig={config.collections}
|
|
201
|
-
/>
|
|
202
|
-
)}
|
|
203
|
-
</CollectionForm>
|
|
204
|
-
</div>
|
|
205
|
-
);
|
|
206
|
-
}
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AdminSidebar Component
|
|
3
|
-
*
|
|
4
|
-
* Automatically generated sidebar from admin config
|
|
5
|
-
* Fully customizable via config overrides
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import * as React from "react";
|
|
9
|
-
import { cn } from "../../lib/utils";
|
|
10
|
-
|
|
11
|
-
export interface AdminSidebarProps {
|
|
12
|
-
/**
|
|
13
|
-
* Admin configuration
|
|
14
|
-
*/
|
|
15
|
-
config: {
|
|
16
|
-
app?: {
|
|
17
|
-
brand?: {
|
|
18
|
-
name?: string;
|
|
19
|
-
logo?: React.ComponentType;
|
|
20
|
-
homeRoute?: string;
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
collections?: Record<
|
|
24
|
-
string,
|
|
25
|
-
{
|
|
26
|
-
label?: string;
|
|
27
|
-
icon?: string | React.ComponentType;
|
|
28
|
-
group?: string;
|
|
29
|
-
}
|
|
30
|
-
>;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Current active route (e.g., "/admin/barbers")
|
|
35
|
-
*/
|
|
36
|
-
activeRoute?: string;
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Link component (router-specific)
|
|
40
|
-
* Must accept: to, className, children
|
|
41
|
-
*/
|
|
42
|
-
LinkComponent: React.ComponentType<{
|
|
43
|
-
to: string;
|
|
44
|
-
className?: string;
|
|
45
|
-
children: React.ReactNode;
|
|
46
|
-
activeProps?: { className?: string };
|
|
47
|
-
}>;
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Custom class for sidebar container
|
|
51
|
-
*/
|
|
52
|
-
className?: string;
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Custom class for brand section
|
|
56
|
-
*/
|
|
57
|
-
brandClassName?: string;
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Custom class for nav section
|
|
61
|
-
*/
|
|
62
|
-
navClassName?: string;
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Render custom brand content
|
|
66
|
-
*/
|
|
67
|
-
renderBrand?: (config: AdminSidebarProps["config"]) => React.ReactNode;
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Render custom nav item
|
|
71
|
-
*/
|
|
72
|
-
renderNavItem?: (params: {
|
|
73
|
-
collectionName: string;
|
|
74
|
-
config: NonNullable<AdminSidebarProps["config"]["collections"]>[string];
|
|
75
|
-
isActive: boolean;
|
|
76
|
-
}) => React.ReactNode;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export function AdminSidebar({
|
|
80
|
-
config,
|
|
81
|
-
activeRoute,
|
|
82
|
-
LinkComponent,
|
|
83
|
-
className,
|
|
84
|
-
brandClassName,
|
|
85
|
-
navClassName,
|
|
86
|
-
renderBrand,
|
|
87
|
-
renderNavItem,
|
|
88
|
-
}: AdminSidebarProps): React.ReactElement {
|
|
89
|
-
const brand = config.app?.brand;
|
|
90
|
-
const collections = config.collections || {};
|
|
91
|
-
|
|
92
|
-
// Group collections if needed
|
|
93
|
-
const groupedCollections = React.useMemo(() => {
|
|
94
|
-
const groups: Record<string, typeof collections> = { "": {} };
|
|
95
|
-
|
|
96
|
-
Object.entries(collections).forEach(([name, collectionConfig]) => {
|
|
97
|
-
const group = collectionConfig.group || "";
|
|
98
|
-
if (!groups[group]) groups[group] = {};
|
|
99
|
-
groups[group][name] = collectionConfig;
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
return groups;
|
|
103
|
-
}, [collections]);
|
|
104
|
-
|
|
105
|
-
return (
|
|
106
|
-
<aside
|
|
107
|
-
className={cn(
|
|
108
|
-
"w-64 border-r bg-neutral-50 dark:bg-neutral-900",
|
|
109
|
-
className,
|
|
110
|
-
)}
|
|
111
|
-
>
|
|
112
|
-
{/* Brand Section */}
|
|
113
|
-
<div className={cn("p-4", brandClassName)}>
|
|
114
|
-
{renderBrand ? (
|
|
115
|
-
renderBrand(config)
|
|
116
|
-
) : (
|
|
117
|
-
<>
|
|
118
|
-
{brand?.logo && <brand.logo />}
|
|
119
|
-
<h1 className="text-xl font-bold">{brand?.name || "Admin"}</h1>
|
|
120
|
-
</>
|
|
121
|
-
)}
|
|
122
|
-
</div>
|
|
123
|
-
|
|
124
|
-
{/* Navigation */}
|
|
125
|
-
<nav className={cn("space-y-1 p-2", navClassName)}>
|
|
126
|
-
{Object.entries(groupedCollections).map(
|
|
127
|
-
([groupName, groupCollections]) => (
|
|
128
|
-
<div key={groupName}>
|
|
129
|
-
{/* Group Label */}
|
|
130
|
-
{groupName && (
|
|
131
|
-
<div className="px-3 py-2 text-xs font-semibold uppercase text-neutral-500">
|
|
132
|
-
{groupName}
|
|
133
|
-
</div>
|
|
134
|
-
)}
|
|
135
|
-
|
|
136
|
-
{/* Collection Links */}
|
|
137
|
-
{Object.entries(groupCollections).map(
|
|
138
|
-
([collectionName, collectionConfig]) => {
|
|
139
|
-
const isActive = activeRoute === `/admin/${collectionName}`;
|
|
140
|
-
|
|
141
|
-
if (renderNavItem) {
|
|
142
|
-
return (
|
|
143
|
-
<React.Fragment key={collectionName}>
|
|
144
|
-
{renderNavItem({
|
|
145
|
-
collectionName,
|
|
146
|
-
config: collectionConfig,
|
|
147
|
-
isActive,
|
|
148
|
-
})}
|
|
149
|
-
</React.Fragment>
|
|
150
|
-
);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
return (
|
|
154
|
-
<LinkComponent
|
|
155
|
-
key={collectionName}
|
|
156
|
-
to={`/admin/${collectionName}`}
|
|
157
|
-
className="block rounded px-3 py-2 hover:bg-neutral-100 dark:hover:bg-neutral-800"
|
|
158
|
-
activeProps={{
|
|
159
|
-
className:
|
|
160
|
-
"bg-neutral-100 dark:bg-neutral-800 font-medium",
|
|
161
|
-
}}
|
|
162
|
-
>
|
|
163
|
-
{/* Icon */}
|
|
164
|
-
{collectionConfig.icon &&
|
|
165
|
-
typeof collectionConfig.icon === "string" && (
|
|
166
|
-
<span className="mr-2">{collectionConfig.icon}</span>
|
|
167
|
-
)}
|
|
168
|
-
{collectionConfig.icon &&
|
|
169
|
-
typeof collectionConfig.icon !== "string" && (
|
|
170
|
-
<collectionConfig.icon />
|
|
171
|
-
)}
|
|
172
|
-
|
|
173
|
-
{/* Label */}
|
|
174
|
-
{collectionConfig.label || collectionName}
|
|
175
|
-
</LinkComponent>
|
|
176
|
-
);
|
|
177
|
-
},
|
|
178
|
-
)}
|
|
179
|
-
</div>
|
|
180
|
-
),
|
|
181
|
-
)}
|
|
182
|
-
</nav>
|
|
183
|
-
</aside>
|
|
184
|
-
);
|
|
185
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Layout views - admin layout and navigation
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
export { AdminLayout } from "./admin-layout";
|
|
6
|
-
export type { AdminLayoutProps } from "./admin-layout";
|
|
7
|
-
|
|
8
|
-
export { AdminSidebar } from "./admin-sidebar";
|
|
9
|
-
export type { AdminSidebarProps } from "./admin-sidebar";
|
|
10
|
-
|
|
11
|
-
export { AdminRouter } from "./admin-router";
|
|
12
|
-
export type { AdminRouterProps } from "./admin-router";
|
package/tsconfig.json
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "@questpie/typescript-config/react-library.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"outDir": "./dist",
|
|
5
|
-
"rootDir": "./src",
|
|
6
|
-
"baseUrl": ".",
|
|
7
|
-
"paths": {
|
|
8
|
-
"#questpie/admin/*": ["./src/*"]
|
|
9
|
-
}
|
|
10
|
-
},
|
|
11
|
-
"include": ["src/**/*"],
|
|
12
|
-
"exclude": ["node_modules", "dist", "**/*.spec.ts", "**/*.test.ts"]
|
|
13
|
-
}
|