@questpie/admin 0.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.
Files changed (203) hide show
  1. package/.turbo/turbo-build.log +108 -0
  2. package/CHANGELOG.md +10 -0
  3. package/README.md +556 -0
  4. package/STATUS.md +917 -0
  5. package/VALIDATION.md +602 -0
  6. package/components.json +24 -0
  7. package/dist/__tests__/setup.mjs +38 -0
  8. package/dist/__tests__/test-utils.mjs +45 -0
  9. package/dist/__tests__/vitest.d.mjs +3 -0
  10. package/dist/components/admin-app.mjs +69 -0
  11. package/dist/components/fields/array-field.mjs +190 -0
  12. package/dist/components/fields/checkbox-field.mjs +34 -0
  13. package/dist/components/fields/custom-field.mjs +32 -0
  14. package/dist/components/fields/date-field.mjs +41 -0
  15. package/dist/components/fields/datetime-field.mjs +42 -0
  16. package/dist/components/fields/email-field.mjs +37 -0
  17. package/dist/components/fields/embedded-collection.mjs +253 -0
  18. package/dist/components/fields/field-types.mjs +1 -0
  19. package/dist/components/fields/field-utils.mjs +10 -0
  20. package/dist/components/fields/field-wrapper.mjs +34 -0
  21. package/dist/components/fields/index.mjs +23 -0
  22. package/dist/components/fields/json-field.mjs +243 -0
  23. package/dist/components/fields/locale-badge.mjs +16 -0
  24. package/dist/components/fields/number-field.mjs +39 -0
  25. package/dist/components/fields/password-field.mjs +37 -0
  26. package/dist/components/fields/relation-field.mjs +104 -0
  27. package/dist/components/fields/relation-picker.mjs +229 -0
  28. package/dist/components/fields/relation-select.mjs +188 -0
  29. package/dist/components/fields/rich-text-editor/index.mjs +897 -0
  30. package/dist/components/fields/select-field.mjs +41 -0
  31. package/dist/components/fields/switch-field.mjs +34 -0
  32. package/dist/components/fields/text-field.mjs +38 -0
  33. package/dist/components/fields/textarea-field.mjs +38 -0
  34. package/dist/components/index.mjs +59 -0
  35. package/dist/components/primitives/checkbox-input.mjs +127 -0
  36. package/dist/components/primitives/date-input.mjs +303 -0
  37. package/dist/components/primitives/index.mjs +12 -0
  38. package/dist/components/primitives/number-input.mjs +104 -0
  39. package/dist/components/primitives/select-input.mjs +177 -0
  40. package/dist/components/primitives/tag-input.mjs +135 -0
  41. package/dist/components/primitives/text-input.mjs +39 -0
  42. package/dist/components/primitives/textarea-input.mjs +37 -0
  43. package/dist/components/primitives/toggle-input.mjs +31 -0
  44. package/dist/components/primitives/types.mjs +12 -0
  45. package/dist/components/ui/accordion.mjs +55 -0
  46. package/dist/components/ui/avatar.mjs +54 -0
  47. package/dist/components/ui/badge.mjs +34 -0
  48. package/dist/components/ui/button.mjs +48 -0
  49. package/dist/components/ui/card.mjs +58 -0
  50. package/dist/components/ui/checkbox.mjs +21 -0
  51. package/dist/components/ui/combobox.mjs +163 -0
  52. package/dist/components/ui/dialog.mjs +95 -0
  53. package/dist/components/ui/dropdown-menu.mjs +138 -0
  54. package/dist/components/ui/field.mjs +113 -0
  55. package/dist/components/ui/input-group.mjs +82 -0
  56. package/dist/components/ui/input.mjs +17 -0
  57. package/dist/components/ui/label.mjs +15 -0
  58. package/dist/components/ui/popover.mjs +56 -0
  59. package/dist/components/ui/scroll-area.mjs +38 -0
  60. package/dist/components/ui/select.mjs +100 -0
  61. package/dist/components/ui/separator.mjs +16 -0
  62. package/dist/components/ui/sheet.mjs +90 -0
  63. package/dist/components/ui/sidebar.mjs +387 -0
  64. package/dist/components/ui/skeleton.mjs +14 -0
  65. package/dist/components/ui/spinner.mjs +16 -0
  66. package/dist/components/ui/switch.mjs +22 -0
  67. package/dist/components/ui/table.mjs +68 -0
  68. package/dist/components/ui/tabs.mjs +48 -0
  69. package/dist/components/ui/textarea.mjs +15 -0
  70. package/dist/components/ui/tooltip.mjs +44 -0
  71. package/dist/config/component-registry.mjs +38 -0
  72. package/dist/config/index.mjs +129 -0
  73. package/dist/hooks/admin-provider.mjs +70 -0
  74. package/dist/hooks/index.mjs +7 -0
  75. package/dist/hooks/store.mjs +178 -0
  76. package/dist/hooks/use-auth.mjs +76 -0
  77. package/dist/hooks/use-collection-db.mjs +146 -0
  78. package/dist/hooks/use-collection.mjs +112 -0
  79. package/dist/hooks/use-global.mjs +46 -0
  80. package/dist/hooks/use-mobile.mjs +20 -0
  81. package/dist/lib/utils.mjs +10 -0
  82. package/dist/styles/index.css +336 -0
  83. package/dist/styles/index.mjs +1 -0
  84. package/dist/utils/index.mjs +9 -0
  85. package/dist/views/auth/auth-layout.mjs +52 -0
  86. package/dist/views/auth/forgot-password-form.mjs +148 -0
  87. package/dist/views/auth/index.mjs +6 -0
  88. package/dist/views/auth/login-form.mjs +156 -0
  89. package/dist/views/auth/reset-password-form.mjs +184 -0
  90. package/dist/views/collection/auto-form-fields.mjs +525 -0
  91. package/dist/views/collection/collection-form.mjs +91 -0
  92. package/dist/views/collection/collection-list.mjs +76 -0
  93. package/dist/views/collection/form-field.mjs +42 -0
  94. package/dist/views/collection/index.mjs +6 -0
  95. package/dist/views/common/index.mjs +4 -0
  96. package/dist/views/common/locale-switcher.mjs +39 -0
  97. package/dist/views/common/version-history.mjs +272 -0
  98. package/dist/views/index.mjs +9 -0
  99. package/dist/views/layout/admin-layout.mjs +40 -0
  100. package/dist/views/layout/admin-router.mjs +95 -0
  101. package/dist/views/layout/admin-sidebar.mjs +63 -0
  102. package/dist/views/layout/index.mjs +5 -0
  103. package/package.json +276 -0
  104. package/src/__tests__/setup.ts +44 -0
  105. package/src/__tests__/test-utils.tsx +49 -0
  106. package/src/__tests__/vitest.d.ts +9 -0
  107. package/src/components/admin-app.tsx +221 -0
  108. package/src/components/fields/array-field.tsx +237 -0
  109. package/src/components/fields/checkbox-field.tsx +47 -0
  110. package/src/components/fields/custom-field.tsx +50 -0
  111. package/src/components/fields/date-field.tsx +65 -0
  112. package/src/components/fields/datetime-field.tsx +67 -0
  113. package/src/components/fields/email-field.tsx +51 -0
  114. package/src/components/fields/embedded-collection.tsx +315 -0
  115. package/src/components/fields/field-types.ts +162 -0
  116. package/src/components/fields/field-utils.ts +6 -0
  117. package/src/components/fields/field-wrapper.tsx +52 -0
  118. package/src/components/fields/index.ts +66 -0
  119. package/src/components/fields/json-field.tsx +440 -0
  120. package/src/components/fields/locale-badge.tsx +15 -0
  121. package/src/components/fields/number-field.tsx +57 -0
  122. package/src/components/fields/password-field.tsx +51 -0
  123. package/src/components/fields/relation-field.tsx +243 -0
  124. package/src/components/fields/relation-picker.tsx +402 -0
  125. package/src/components/fields/relation-select.tsx +327 -0
  126. package/src/components/fields/rich-text-editor/index.tsx +1337 -0
  127. package/src/components/fields/select-field.tsx +61 -0
  128. package/src/components/fields/switch-field.tsx +47 -0
  129. package/src/components/fields/text-field.tsx +55 -0
  130. package/src/components/fields/textarea-field.tsx +55 -0
  131. package/src/components/index.ts +40 -0
  132. package/src/components/primitives/checkbox-input.tsx +193 -0
  133. package/src/components/primitives/date-input.tsx +401 -0
  134. package/src/components/primitives/index.ts +24 -0
  135. package/src/components/primitives/number-input.tsx +132 -0
  136. package/src/components/primitives/select-input.tsx +296 -0
  137. package/src/components/primitives/tag-input.tsx +200 -0
  138. package/src/components/primitives/text-input.tsx +49 -0
  139. package/src/components/primitives/textarea-input.tsx +46 -0
  140. package/src/components/primitives/toggle-input.tsx +36 -0
  141. package/src/components/primitives/types.ts +235 -0
  142. package/src/components/ui/accordion.tsx +72 -0
  143. package/src/components/ui/avatar.tsx +106 -0
  144. package/src/components/ui/badge.tsx +48 -0
  145. package/src/components/ui/button.tsx +53 -0
  146. package/src/components/ui/card.tsx +94 -0
  147. package/src/components/ui/checkbox.tsx +27 -0
  148. package/src/components/ui/combobox.tsx +290 -0
  149. package/src/components/ui/dialog.tsx +151 -0
  150. package/src/components/ui/dropdown-menu.tsx +254 -0
  151. package/src/components/ui/field.tsx +227 -0
  152. package/src/components/ui/input-group.tsx +149 -0
  153. package/src/components/ui/input.tsx +20 -0
  154. package/src/components/ui/label.tsx +18 -0
  155. package/src/components/ui/popover.tsx +88 -0
  156. package/src/components/ui/scroll-area.tsx +53 -0
  157. package/src/components/ui/select.tsx +192 -0
  158. package/src/components/ui/separator.tsx +23 -0
  159. package/src/components/ui/sheet.tsx +127 -0
  160. package/src/components/ui/sidebar.tsx +723 -0
  161. package/src/components/ui/skeleton.tsx +13 -0
  162. package/src/components/ui/spinner.tsx +10 -0
  163. package/src/components/ui/switch.tsx +32 -0
  164. package/src/components/ui/table.tsx +99 -0
  165. package/src/components/ui/tabs.tsx +82 -0
  166. package/src/components/ui/textarea.tsx +18 -0
  167. package/src/components/ui/tooltip.tsx +70 -0
  168. package/src/config/component-registry.ts +190 -0
  169. package/src/config/index.ts +1099 -0
  170. package/src/hooks/README.md +269 -0
  171. package/src/hooks/admin-provider.tsx +110 -0
  172. package/src/hooks/index.ts +41 -0
  173. package/src/hooks/store.ts +248 -0
  174. package/src/hooks/use-auth.ts +168 -0
  175. package/src/hooks/use-collection-db.ts +209 -0
  176. package/src/hooks/use-collection.ts +156 -0
  177. package/src/hooks/use-global.ts +69 -0
  178. package/src/hooks/use-mobile.ts +21 -0
  179. package/src/lib/utils.ts +6 -0
  180. package/src/styles/index.css +340 -0
  181. package/src/utils/index.ts +6 -0
  182. package/src/views/auth/auth-layout.tsx +77 -0
  183. package/src/views/auth/forgot-password-form.tsx +192 -0
  184. package/src/views/auth/index.ts +21 -0
  185. package/src/views/auth/login-form.tsx +229 -0
  186. package/src/views/auth/reset-password-form.tsx +232 -0
  187. package/src/views/collection/auto-form-fields.tsx +982 -0
  188. package/src/views/collection/collection-form.tsx +186 -0
  189. package/src/views/collection/collection-list.tsx +223 -0
  190. package/src/views/collection/form-field.tsx +52 -0
  191. package/src/views/collection/index.ts +15 -0
  192. package/src/views/common/index.ts +8 -0
  193. package/src/views/common/locale-switcher.tsx +45 -0
  194. package/src/views/common/version-history.tsx +406 -0
  195. package/src/views/index.ts +25 -0
  196. package/src/views/layout/admin-layout.tsx +117 -0
  197. package/src/views/layout/admin-router.tsx +206 -0
  198. package/src/views/layout/admin-sidebar.tsx +185 -0
  199. package/src/views/layout/index.ts +12 -0
  200. package/tsconfig.json +13 -0
  201. package/tsconfig.tsbuildinfo +1 -0
  202. package/tsdown.config.ts +13 -0
  203. package/vitest.config.ts +29 -0
@@ -0,0 +1,186 @@
1
+ import React from "react";
2
+ import { useForm, FormProvider } from "react-hook-form";
3
+ import type { Questpie } from "questpie";
4
+ import type { QuestpieClient } from "questpie/client";
5
+ import {
6
+ useCollection,
7
+ useCollectionItemById,
8
+ } from "../../hooks/use-collection-db";
9
+ import { Button } from "../../components/ui/button";
10
+ import {
11
+ Card,
12
+ CardContent,
13
+ CardFooter,
14
+ CardHeader,
15
+ CardTitle,
16
+ } from "../../components/ui/card";
17
+
18
+ /**
19
+ * Collection item type helper
20
+ */
21
+ type CollectionItem<
22
+ T extends Questpie<any>,
23
+ K extends keyof QuestpieClient<T>["collections"],
24
+ > = Awaited<ReturnType<QuestpieClient<T>["collections"][K]["find"]>> extends {
25
+ docs: Array<infer TItem>;
26
+ }
27
+ ? TItem
28
+ : never;
29
+
30
+ /**
31
+ * CollectionForm props
32
+ */
33
+ export type CollectionFormProps<
34
+ T extends Questpie<any>,
35
+ K extends keyof QuestpieClient<T>["collections"],
36
+ > = {
37
+ /**
38
+ * Collection name
39
+ */
40
+ collection: K;
41
+
42
+ /**
43
+ * Item ID (for edit mode)
44
+ */
45
+ id?: string;
46
+
47
+ /**
48
+ * Default values (for create mode)
49
+ */
50
+ defaultValues?: Partial<CollectionItem<T, K>>;
51
+
52
+ /**
53
+ * Custom field renderer
54
+ */
55
+ children: React.ReactNode;
56
+
57
+ /**
58
+ * On submit success callback
59
+ */
60
+ onSuccess?: (item: CollectionItem<T, K>) => void;
61
+
62
+ /**
63
+ * On cancel callback
64
+ */
65
+ onCancel?: () => void;
66
+
67
+ /**
68
+ * Form title
69
+ */
70
+ title?: string;
71
+
72
+ /**
73
+ * Header actions (e.g. locale switcher)
74
+ */
75
+ headerActions?: React.ReactNode;
76
+
77
+ /**
78
+ * Submit button text
79
+ */
80
+ submitText?: string;
81
+
82
+ /**
83
+ * Cancel button text
84
+ */
85
+ cancelText?: string;
86
+ };
87
+
88
+ /**
89
+ * CollectionForm - Form wrapper for CMS collections
90
+ * Uses React Hook Form + TanStack DB Collection for optimistic updates
91
+ *
92
+ * @example
93
+ * ```tsx
94
+ * import { CollectionForm } from '@questpie/admin/views'
95
+ * import type { cms } from './server/cms'
96
+ *
97
+ * function PostForm({ id }: { id?: string }) {
98
+ * return (
99
+ * <CollectionForm<typeof cms, 'posts'>
100
+ * collection="posts"
101
+ * id={id}
102
+ * title={id ? 'Edit Post' : 'Create Post'}
103
+ * onSuccess={() => router.push('/posts')}
104
+ * >
105
+ * <FormField name="title" label="Title" />
106
+ * <FormField name="content" label="Content" type="textarea" />
107
+ * </CollectionForm>
108
+ * )
109
+ * }
110
+ * ```
111
+ */
112
+ export function CollectionForm<
113
+ T extends Questpie<any>,
114
+ K extends keyof QuestpieClient<T>["collections"],
115
+ >({
116
+ collection,
117
+ id,
118
+ defaultValues,
119
+ children,
120
+ onSuccess,
121
+ onCancel,
122
+ title,
123
+ headerActions,
124
+ submitText = "Save",
125
+ cancelText = "Cancel",
126
+ }: CollectionFormProps<T, K>): React.ReactElement {
127
+ const collectionData = useCollection<T, K>(collection);
128
+ // Get item from collection - useCollectionItemById returns undefined if not found
129
+ const item = id
130
+ ? collectionData.toArray.find((i) => collectionData.config.getKey(i) === id)
131
+ : undefined;
132
+
133
+ const form = useForm({
134
+ defaultValues: (item ?? defaultValues ?? {}) as any,
135
+ });
136
+
137
+ React.useEffect(() => {
138
+ form.reset((item ?? defaultValues ?? {}) as any);
139
+ }, [form, item, defaultValues]);
140
+
141
+ const onSubmit = async (data: any) => {
142
+ try {
143
+ let result: any;
144
+
145
+ if (id) {
146
+ // Update existing item
147
+ await collectionData.update(id, data);
148
+ result = { ...item, ...data };
149
+ } else {
150
+ // Create new item
151
+ result = await collectionData.insert(data);
152
+ }
153
+
154
+ onSuccess?.(result);
155
+ } catch (error) {
156
+ console.error("Form submission error:", error);
157
+ // TODO: Show error toast
158
+ }
159
+ };
160
+
161
+ return (
162
+ <FormProvider {...form}>
163
+ <form onSubmit={form.handleSubmit(onSubmit)}>
164
+ <Card>
165
+ {(title || headerActions) && (
166
+ <CardHeader className="flex flex-wrap items-center justify-between gap-3">
167
+ {title && <CardTitle>{title}</CardTitle>}
168
+ {headerActions && <div>{headerActions}</div>}
169
+ </CardHeader>
170
+ )}
171
+ <CardContent className="space-y-4">{children}</CardContent>
172
+ <CardFooter className="flex justify-end gap-2">
173
+ {onCancel && (
174
+ <Button type="button" variant="outline" onClick={onCancel}>
175
+ {cancelText}
176
+ </Button>
177
+ )}
178
+ <Button type="submit" disabled={form.formState.isSubmitting}>
179
+ {form.formState.isSubmitting ? "Saving..." : submitText}
180
+ </Button>
181
+ </CardFooter>
182
+ </Card>
183
+ </form>
184
+ </FormProvider>
185
+ );
186
+ }
@@ -0,0 +1,223 @@
1
+ import React from "react";
2
+ import {
3
+ type ColumnDef,
4
+ flexRender,
5
+ getCoreRowModel,
6
+ useReactTable,
7
+ getSortedRowModel,
8
+ type SortingState,
9
+ } from "@tanstack/react-table";
10
+ import type { Questpie } from "questpie";
11
+ import type { QuestpieClient } from "questpie/client";
12
+ import { useCollection } from "../../hooks/use-collection-db";
13
+ import {
14
+ Table,
15
+ TableBody,
16
+ TableCell,
17
+ TableHead,
18
+ TableHeader,
19
+ TableRow,
20
+ } from "../../components/ui/table";
21
+ import { Button } from "../../components/ui/button";
22
+
23
+ /**
24
+ * Collection item type helper
25
+ */
26
+ type CollectionItem<
27
+ T extends Questpie<any>,
28
+ K extends keyof QuestpieClient<T>["collections"],
29
+ > = Awaited<ReturnType<QuestpieClient<T>["collections"][K]["find"]>> extends {
30
+ docs: Array<infer TItem>;
31
+ }
32
+ ? TItem
33
+ : never;
34
+
35
+ /**
36
+ * CollectionList props
37
+ */
38
+ export type CollectionListProps<
39
+ T extends Questpie<any>,
40
+ K extends keyof QuestpieClient<T>["collections"],
41
+ > = {
42
+ /**
43
+ * Collection name
44
+ */
45
+ collection: K;
46
+
47
+ /**
48
+ * Column definitions
49
+ */
50
+ columns: ColumnDef<CollectionItem<T, K>>[];
51
+
52
+ /**
53
+ * Base query options (filters, sorting, relations)
54
+ */
55
+ baseFindOptions?: Parameters<QuestpieClient<T>["collections"][K]["find"]>[0];
56
+
57
+ /**
58
+ * Enable realtime sync
59
+ */
60
+ realtime?: boolean;
61
+
62
+ /**
63
+ * Custom row actions
64
+ */
65
+ rowActions?: (item: CollectionItem<T, K>) => React.ReactNode;
66
+
67
+ /**
68
+ * Custom header actions
69
+ */
70
+ headerActions?: React.ReactNode;
71
+
72
+ /**
73
+ * Custom empty state
74
+ */
75
+ emptyState?: React.ReactNode;
76
+
77
+ /**
78
+ * On row click handler
79
+ */
80
+ onRowClick?: (item: CollectionItem<T, K>) => void;
81
+ };
82
+
83
+ /**
84
+ * CollectionList - Table view for CMS collections
85
+ * Uses TanStack DB Collection for offline-first, realtime data
86
+ *
87
+ * @example
88
+ * ```tsx
89
+ * import { CollectionList } from '@questpie/admin/views'
90
+ * import type { cms } from './server/cms'
91
+ *
92
+ * function PostsList() {
93
+ * return (
94
+ * <CollectionList<typeof cms, 'posts'>
95
+ * collection="posts"
96
+ * columns={[
97
+ * { accessorKey: 'title', header: 'Title' },
98
+ * { accessorKey: 'createdAt', header: 'Created' },
99
+ * ]}
100
+ * realtime={true}
101
+ * onRowClick={(post) => router.push(`/posts/${post.id}`)}
102
+ * />
103
+ * )
104
+ * }
105
+ * ```
106
+ */
107
+ export function CollectionList<
108
+ T extends Questpie<any>,
109
+ K extends keyof QuestpieClient<T>["collections"],
110
+ >({
111
+ collection,
112
+ columns,
113
+ baseFindOptions,
114
+ realtime = false,
115
+ rowActions,
116
+ headerActions,
117
+ emptyState,
118
+ onRowClick,
119
+ }: CollectionListProps<T, K>): React.ReactElement {
120
+ const collectionData = useCollection<T, K>(collection, {
121
+ baseFindOptions,
122
+ realtime,
123
+ });
124
+
125
+ const [sorting, setSorting] = React.useState<SortingState>([]);
126
+
127
+ const items = collectionData.toArray;
128
+
129
+ const table = useReactTable({
130
+ data: items as any[],
131
+ columns: columns as ColumnDef<any>[],
132
+ getCoreRowModel: getCoreRowModel(),
133
+ getSortedRowModel: getSortedRowModel(),
134
+ onSortingChange: setSorting,
135
+ state: {
136
+ sorting,
137
+ },
138
+ });
139
+
140
+ return (
141
+ <div className="space-y-4">
142
+ {/* Header */}
143
+ {headerActions && (
144
+ <div className="flex items-center justify-between">
145
+ <div className="text-sm text-muted-foreground">
146
+ {items.length} items
147
+ </div>
148
+ <div>{headerActions}</div>
149
+ </div>
150
+ )}
151
+
152
+ {/* Table */}
153
+ <div className="rounded-md border">
154
+ <Table>
155
+ <TableHeader>
156
+ {table.getHeaderGroups().map((headerGroup) => (
157
+ <TableRow key={headerGroup.id}>
158
+ {headerGroup.headers.map((header) => (
159
+ <TableHead key={header.id}>
160
+ {header.isPlaceholder ? null : (
161
+ <div
162
+ className={
163
+ header.column.getCanSort()
164
+ ? "cursor-pointer select-none flex items-center gap-2"
165
+ : ""
166
+ }
167
+ onClick={header.column.getToggleSortingHandler()}
168
+ >
169
+ {flexRender(
170
+ header.column.columnDef.header,
171
+ header.getContext(),
172
+ )}
173
+ {header.column.getIsSorted() && (
174
+ <span>
175
+ {header.column.getIsSorted() === "asc" ? "↑" : "↓"}
176
+ </span>
177
+ )}
178
+ </div>
179
+ )}
180
+ </TableHead>
181
+ ))}
182
+ {rowActions && <TableHead>Actions</TableHead>}
183
+ </TableRow>
184
+ ))}
185
+ </TableHeader>
186
+ <TableBody>
187
+ {table.getRowModel().rows?.length ? (
188
+ table.getRowModel().rows.map((row) => (
189
+ <TableRow
190
+ key={row.id}
191
+ data-state={row.getIsSelected() && "selected"}
192
+ onClick={() => onRowClick?.(row.original)}
193
+ className={onRowClick ? "cursor-pointer" : ""}
194
+ >
195
+ {row.getVisibleCells().map((cell) => (
196
+ <TableCell key={cell.id}>
197
+ {flexRender(
198
+ cell.column.columnDef.cell,
199
+ cell.getContext(),
200
+ )}
201
+ </TableCell>
202
+ ))}
203
+ {rowActions && (
204
+ <TableCell>{rowActions(row.original)}</TableCell>
205
+ )}
206
+ </TableRow>
207
+ ))
208
+ ) : (
209
+ <TableRow>
210
+ <TableCell
211
+ colSpan={columns.length + (rowActions ? 1 : 0)}
212
+ className="h-24 text-center"
213
+ >
214
+ {emptyState || "No results."}
215
+ </TableCell>
216
+ </TableRow>
217
+ )}
218
+ </TableBody>
219
+ </Table>
220
+ </div>
221
+ </div>
222
+ );
223
+ }
@@ -0,0 +1,52 @@
1
+ import * as React from "react";
2
+ import type { FormFieldProps } from "../../components/fields/field-types";
3
+ import { CheckboxField } from "../../components/fields/checkbox-field";
4
+ import { CustomField } from "../../components/fields/custom-field";
5
+ import { DateField } from "../../components/fields/date-field";
6
+ import { DatetimeField } from "../../components/fields/datetime-field";
7
+ import { EmailField } from "../../components/fields/email-field";
8
+ import { NumberField } from "../../components/fields/number-field";
9
+ import { PasswordField } from "../../components/fields/password-field";
10
+ import { SelectField } from "../../components/fields/select-field";
11
+ import { SwitchField } from "../../components/fields/switch-field";
12
+ import { TextareaField } from "../../components/fields/textarea-field";
13
+ import { TextField } from "../../components/fields/text-field";
14
+
15
+ export type { FormFieldProps } from "../../components/fields/field-types";
16
+
17
+ /**
18
+ * FormField - Generic form field with React Hook Form integration
19
+ */
20
+ export function FormField({
21
+ type = "text",
22
+ component,
23
+ options,
24
+ ...baseProps
25
+ }: FormFieldProps): React.ReactElement {
26
+ if (component) {
27
+ return <CustomField {...baseProps} component={component} />;
28
+ }
29
+
30
+ switch (type) {
31
+ case "textarea":
32
+ return <TextareaField {...baseProps} />;
33
+ case "checkbox":
34
+ return <CheckboxField {...baseProps} />;
35
+ case "switch":
36
+ return <SwitchField {...baseProps} />;
37
+ case "select":
38
+ return <SelectField {...baseProps} options={options} />;
39
+ case "number":
40
+ return <NumberField {...baseProps} />;
41
+ case "date":
42
+ return <DateField {...baseProps} />;
43
+ case "datetime":
44
+ return <DatetimeField {...baseProps} />;
45
+ case "email":
46
+ return <EmailField {...baseProps} />;
47
+ case "password":
48
+ return <PasswordField {...baseProps} />;
49
+ default:
50
+ return <TextField {...baseProps} />;
51
+ }
52
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Collection views - CRUD for CMS collections
3
+ */
4
+
5
+ export { CollectionList } from "./collection-list";
6
+ export type { CollectionListProps } from "./collection-list";
7
+
8
+ export { CollectionForm } from "./collection-form";
9
+ export type { CollectionFormProps } from "./collection-form";
10
+
11
+ export { FormField } from "./form-field";
12
+ export type { FormFieldProps } from "./form-field";
13
+
14
+ export { AutoFormFields } from "./auto-form-fields";
15
+ export type { AutoFormFieldsProps } from "./auto-form-fields";
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Common views - shared utility views
3
+ */
4
+
5
+ export { LocaleSwitcher } from "./locale-switcher";
6
+
7
+ export { VersionHistory } from "./version-history";
8
+ export type { VersionHistoryProps } from "./version-history";
@@ -0,0 +1,45 @@
1
+ import * as React from "react";
2
+ import { useAdminContext } from "../../hooks/admin-provider";
3
+ import {
4
+ Select,
5
+ SelectContent,
6
+ SelectItem,
7
+ SelectTrigger,
8
+ } from "../../components/ui/select";
9
+ import { Badge } from "../../components/ui/badge";
10
+
11
+ export function LocaleSwitcher() {
12
+ const { locale, setLocale, locales } = useAdminContext<any>();
13
+ const available = locales?.available ?? [];
14
+
15
+ if (!setLocale || available.length <= 1) return null;
16
+
17
+ const currentLocale = locale ?? locales?.default ?? available[0];
18
+
19
+ return (
20
+ <div className="flex items-center gap-2">
21
+ <Badge variant="outline" className="uppercase text-[10px] tracking-wide">
22
+ Locale
23
+ </Badge>
24
+ <Select
25
+ value={currentLocale}
26
+ onValueChange={(value) => {
27
+ if (value) setLocale(value);
28
+ }}
29
+ >
30
+ <SelectTrigger className="h-8 w-[120px]">
31
+ <span className="truncate">
32
+ {currentLocale?.toUpperCase() ?? "Locale"}
33
+ </span>
34
+ </SelectTrigger>
35
+ <SelectContent>
36
+ {available.map((code: string) => (
37
+ <SelectItem key={code} value={code}>
38
+ {code.toUpperCase()}
39
+ </SelectItem>
40
+ ))}
41
+ </SelectContent>
42
+ </Select>
43
+ </div>
44
+ );
45
+ }