@kyro-cms/admin 0.2.10 → 0.3.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.
Files changed (67) hide show
  1. package/README.md +46 -272
  2. package/package.json +32 -7
  3. package/src/blocks/examples/sample-block-2.tsx +27 -0
  4. package/src/blocks/examples/sample-block.tsx +26 -0
  5. package/src/blocks/index.ts +14 -0
  6. package/src/blocks/registry.ts +38 -0
  7. package/src/blocks/types.ts +23 -0
  8. package/src/components/Admin.tsx +1 -1
  9. package/src/components/ApiKeysManager.tsx +1 -1
  10. package/src/components/AuditLogsPage.tsx +1 -1
  11. package/src/components/AutoForm.tsx +2 -2
  12. package/src/components/BrandingHub.tsx +1 -1
  13. package/src/components/CreateView.tsx +1 -1
  14. package/src/components/DetailView.tsx +1 -1
  15. package/src/components/DeveloperCenter.tsx +1 -1
  16. package/src/components/EnhancedListView.tsx +1 -1
  17. package/src/components/ListView.tsx +1 -1
  18. package/src/components/LoginPage.tsx +1 -1
  19. package/src/components/MediaGallery.tsx +1 -1
  20. package/src/components/UserManagement.tsx +1 -1
  21. package/src/components/WebhookManager.tsx +2 -2
  22. package/src/components/fields/RelationshipBlockField.tsx +1 -1
  23. package/src/components/fields/RelationshipField.tsx +1 -1
  24. package/src/components/fields/UploadField.tsx +1 -6
  25. package/src/components/ui/CommandPalette.tsx +1 -1
  26. package/src/fields/examples/sample-field-2.tsx +30 -0
  27. package/src/fields/examples/sample-field.tsx +30 -0
  28. package/src/fields/index.ts +33 -0
  29. package/src/fields/registry.tsx +46 -0
  30. package/src/fields/types.ts +24 -0
  31. package/src/hooks/data.ts +116 -0
  32. package/src/hooks/examples/sample-hook-2.ts +13 -0
  33. package/src/hooks/examples/sample-hook.ts +12 -0
  34. package/src/hooks/index.ts +19 -0
  35. package/src/hooks/lifecycle.ts +81 -0
  36. package/src/hooks/types.ts +40 -0
  37. package/src/index.ts +78 -0
  38. package/src/integration.ts +52 -0
  39. package/src/pages/api/[collection]/[id]/publish.ts +2 -2
  40. package/src/pages/api/[collection]/[id]/unpublish.ts +2 -2
  41. package/src/pages/api/[collection]/[id]/versions.ts +1 -1
  42. package/src/pages/api/[collection]/[id].ts +2 -2
  43. package/src/pages/api/[collection]/index.ts +2 -2
  44. package/src/pages/api/collections.ts +1 -1
  45. package/src/pages/api/globals/[slug].ts +2 -2
  46. package/src/pages/api/graphql.ts +3 -3
  47. package/src/pages/api/media/folders.ts +1 -1
  48. package/src/pages/api/media/index.ts +1 -1
  49. package/src/pages/api/media/resize.ts +1 -1
  50. package/src/pages/api/slug-availability.ts +2 -2
  51. package/src/pages/api/storage-config.ts +1 -1
  52. package/src/pages/api/storage-status.ts +1 -1
  53. package/src/pages/api/upload.ts +1 -1
  54. package/src/plugins/examples/sample-plugin-2.ts +21 -0
  55. package/src/plugins/examples/sample-plugin.ts +21 -0
  56. package/src/plugins/index.ts +10 -0
  57. package/src/plugins/registry.ts +36 -0
  58. package/src/plugins/types.ts +22 -0
  59. package/src/theme/ThemeProvider.tsx +238 -0
  60. package/src/theme/index.ts +20 -0
  61. package/src/theme/tokens.ts +222 -0
  62. package/src/components/Modal.tsx +0 -206
  63. package/src/components/index.ts +0 -29
  64. package/src/env.ts +0 -20
  65. package/src/lib/i18n.tsx +0 -353
  66. package/src/lib/validation.ts +0 -250
  67. package/src/pages/api/globals/[slug]/test.ts +0 -171
@@ -1,206 +0,0 @@
1
- import React, {
2
- createContext,
3
- useContext,
4
- useState,
5
- useCallback,
6
- type ReactNode,
7
- } from "react";
8
- import {
9
- Modal as UIModal,
10
- ModalContent,
11
- ModalActions,
12
- ConfirmModal,
13
- } from "./ui/Modal";
14
- import { PromptModal } from "./ui/PromptModal";
15
-
16
- export { UIModal as Modal, UIModal, ModalContent, ModalActions, ConfirmModal };
17
-
18
- // ============================================================================
19
- // Global Modal Context for programmatic access
20
- // ============================================================================
21
-
22
- type ModalVariant = "alert" | "confirm" | "prompt";
23
-
24
- interface ModalState {
25
- variant: ModalVariant;
26
- open: boolean;
27
- title: string;
28
- message?: string;
29
- placeholder?: string;
30
- defaultValue?: string;
31
- onConfirm?: (value?: string) => void;
32
- onCancel?: () => void;
33
- danger?: boolean;
34
- }
35
-
36
- const initialState: ModalState = {
37
- variant: "alert",
38
- open: false,
39
- title: "",
40
- message: "",
41
- onConfirm: () => {},
42
- onCancel: () => {},
43
- danger: false,
44
- };
45
-
46
- interface ModalContextType {
47
- showAlert: (title: string, message?: string) => void;
48
- showConfirm: (
49
- title: string,
50
- message: string,
51
- onConfirm: () => void,
52
- options?: { danger?: boolean },
53
- ) => void;
54
- showPrompt: (
55
- title: string,
56
- message: string,
57
- onConfirm: (value: string) => void,
58
- options?: { placeholder?: string; defaultValue?: string },
59
- ) => void;
60
- closeModal: () => void;
61
- }
62
-
63
- const ModalContext = createContext<ModalContextType | null>(null);
64
-
65
- export function useModal() {
66
- const context = useContext(ModalContext);
67
- if (!context) {
68
- throw new Error("useModal must be used within ModalProvider");
69
- }
70
- return context;
71
- }
72
-
73
- interface ModalProviderProps {
74
- children: ReactNode;
75
- }
76
-
77
- export function ModalProvider({ children }: ModalProviderProps) {
78
- const [state, setState] = useState<ModalState>(initialState);
79
- const [inputValue, setInputValue] = useState(state.defaultValue || "");
80
-
81
- const showAlert = useCallback((title: string, message?: string) => {
82
- setState({
83
- variant: "alert",
84
- open: true,
85
- title,
86
- message,
87
- onConfirm: () => setState((s) => ({ ...s, open: false })),
88
- onCancel: () => setState((s) => ({ ...s, open: false })),
89
- });
90
- }, []);
91
-
92
- const showConfirm = useCallback(
93
- (
94
- title: string,
95
- message: string,
96
- onConfirm: () => void,
97
- options?: { danger?: boolean },
98
- ) => {
99
- setState({
100
- variant: "confirm",
101
- open: true,
102
- title,
103
- message,
104
- danger: options?.danger,
105
- onConfirm: () => {
106
- onConfirm();
107
- setState((s) => ({ ...s, open: false }));
108
- },
109
- onCancel: () => setState((s) => ({ ...s, open: false })),
110
- });
111
- },
112
- [],
113
- );
114
-
115
- const showPrompt = useCallback(
116
- (
117
- title: string,
118
- message: string,
119
- onConfirm: (value: string) => void,
120
- options?: { placeholder?: string; defaultValue?: string },
121
- ) => {
122
- setState({
123
- variant: "prompt",
124
- open: true,
125
- title,
126
- message,
127
- placeholder: options?.placeholder,
128
- defaultValue: options?.defaultValue,
129
- onConfirm: (value) => {
130
- onConfirm(value || "");
131
- setState((s) => ({ ...s, open: false }));
132
- },
133
- onCancel: () => setState((s) => ({ ...s, open: false })),
134
- });
135
- },
136
- [],
137
- );
138
-
139
- const closeModal = useCallback(() => {
140
- setState((s) => ({ ...s, open: false }));
141
- }, []);
142
-
143
- // Re-order so imports come first, then showAlert
144
- const handleShowAlert = (title: string, message?: string) => {
145
- setState({
146
- variant: "alert",
147
- open: true,
148
- title,
149
- message,
150
- onConfirm: () => setState((s) => ({ ...s, open: false })),
151
- onCancel: () => setState((s) => ({ ...s, open: false })),
152
- });
153
- };
154
-
155
- return (
156
- <ModalContext.Provider
157
- value={{
158
- showAlert: handleShowAlert,
159
- showConfirm,
160
- showPrompt,
161
- closeModal,
162
- }}
163
- >
164
- {children}
165
- {state.variant === "confirm" && (
166
- <ConfirmModal
167
- open={state.open}
168
- onClose={state.onCancel || closeModal}
169
- onConfirm={() => state.onConfirm?.()}
170
- title={state.title}
171
- message={state.message || ""}
172
- variant={state.danger ? "danger" : "default"}
173
- />
174
- )}
175
- {state.variant === "alert" && (
176
- <UIModal
177
- open={state.open}
178
- onClose={state.onCancel || closeModal}
179
- title={state.title}
180
- size="sm"
181
- footer={
182
- <button
183
- type="button"
184
- onClick={() => state.onConfirm?.()}
185
- className="px-4 py-2 rounded-lg font-medium text-sm bg-[var(--kyro-sidebar-active)] text-[var(--kyro-sidebar-text-active)] hover:opacity-90 transition-colors"
186
- >
187
- OK
188
- </button>
189
- }
190
- >
191
- <p className="text-[var(--kyro-text-secondary)]">{state.message}</p>
192
- </UIModal>
193
- )}
194
- {state.variant === "prompt" && (
195
- <PromptModal
196
- open={state.open}
197
- onClose={state.onCancel || closeModal}
198
- onSubmit={(value) => state.onConfirm?.(value)}
199
- title={state.title}
200
- placeholder={state.placeholder}
201
- defaultValue={state.defaultValue}
202
- />
203
- )}
204
- </ModalContext.Provider>
205
- );
206
- }
@@ -1,29 +0,0 @@
1
- export { Admin } from "./Admin";
2
- export { ListView } from "./ListView";
3
- export { DetailView } from "./DetailView";
4
- export { CreateView } from "./CreateView";
5
- export { Dashboard } from "./Dashboard";
6
- export { AutoForm } from "./AutoForm";
7
- export {
8
- ActionBar,
9
- type ActionBarProps,
10
- type DocumentStatus,
11
- type SaveStatus,
12
- } from "./ActionBar";
13
- export { BulkActionsBar } from "./BulkActionsBar";
14
- export { StatusBadge, CountBadge } from "./StatusBadge";
15
- export { VersionHistoryPanel } from "./VersionHistoryPanel";
16
- export {
17
- ThemeProvider,
18
- LightThemeProvider,
19
- DarkThemeProvider,
20
- useTheme,
21
- type ThemeMode,
22
- } from "./ThemeProvider";
23
- export * from "./ui/Button";
24
- export * from "./ui/Badge";
25
- export * from "./ui/Spinner";
26
- export * from "./ui/Toast";
27
- export { Dropdown, DropdownItem, DropdownSeparator } from "./ui/Dropdown";
28
- export { Modal, ConfirmModal } from "./ui/Modal";
29
- export { SlidePanel } from "./ui/SlidePanel";
package/src/env.ts DELETED
@@ -1,20 +0,0 @@
1
- import fs from "fs";
2
- import path from "path";
3
-
4
- const envPath = path.join(process.cwd(), "..", ".env");
5
- if (fs.existsSync(envPath)) {
6
- const envContent = fs.readFileSync(envPath, "utf-8");
7
- envContent.split("\n").forEach((line) => {
8
- const trimmed = line.trim();
9
- if (trimmed && !trimmed.startsWith("#")) {
10
- const eqIndex = trimmed.indexOf("=");
11
- if (eqIndex > 0) {
12
- const key = trimmed.substring(0, eqIndex);
13
- const value = trimmed.substring(eqIndex + 1);
14
- if (!process.env[key]) {
15
- process.env[key] = value;
16
- }
17
- }
18
- }
19
- });
20
- }
package/src/lib/i18n.tsx DELETED
@@ -1,353 +0,0 @@
1
- import { create } from "zustand";
2
-
3
- export const en = {
4
- common: {
5
- save: "Save",
6
- cancel: "Cancel",
7
- delete: "Delete",
8
- edit: "Edit",
9
- create: "Create",
10
- add: "Add",
11
- update: "Update",
12
- confirm: "Confirm",
13
- clear: "Clear",
14
- close: "Close",
15
- back: "Back",
16
- next: "Next",
17
- submit: "Submit",
18
- remove: "Remove",
19
- loading: "Loading...",
20
- },
21
-
22
- status: {
23
- draft: "Draft",
24
- published: "Published",
25
- error: "Error",
26
- success: "Success",
27
- failed: "Failed",
28
- archived: "Archived",
29
- },
30
-
31
- form: {
32
- email: "Email",
33
- password: "Password",
34
- confirmPassword: "Confirm Password",
35
- name: "Name",
36
- label: "Label",
37
- title: "Title",
38
- description: "Description",
39
- role: "Role",
40
- },
41
-
42
- placeholder: {
43
- search: "Search...",
44
- searchByNameOrEmail: "Search by name or email...",
45
- searchFiles: "Search files...",
46
- searchMedia: "Search media...",
47
- searchTypes: "Search types...",
48
- enterHeading: "Enter heading text...",
49
- enterParagraph: "Enter paragraph text...",
50
- enterMarkdown: "Enter markdown content...",
51
- linkText: "Link text...",
52
- url: "https://...",
53
- value: "Value...",
54
- videoUrl: "MP4 URL, YouTube, or Vimeo link...",
55
- jsonPlaceholder: '{"key": "value"}',
56
- folderName: "Folder name",
57
- apiKey: "API Key",
58
- },
59
-
60
- tooltip: {
61
- moveUp: "Move up",
62
- moveDown: "Move down",
63
- remove: "Remove",
64
- edit: "Edit",
65
- delete: "Delete",
66
- livePreview: "Live Preview",
67
- toggleSidebar: "Toggle Sidebar",
68
- fullscreen: "Fullscreen",
69
- exitFullscreen: "Exit fullscreen",
70
- undo: "Undo",
71
- redo: "Redo",
72
- bold: "Bold",
73
- italic: "Italic",
74
- underline: "Underline",
75
- strikethrough: "Strikethrough",
76
- code: "Code",
77
- link: "Link",
78
- bulletList: "Bullet List",
79
- numberedList: "Numbered List",
80
- generateNewKey: "Generate new key",
81
- copyToClipboard: "Copy to clipboard",
82
- },
83
-
84
- media: {
85
- all: "All",
86
- images: "Images",
87
- videos: "Videos",
88
- audio: "Audio",
89
- documents: "Documents",
90
- archives: "Archives",
91
- noMediaFound: "No media files found",
92
- deleteMedia: "Delete Media",
93
- createFolder: "Create New Folder",
94
- deleteFolder: "Delete Folder",
95
- deleteSelected: "Delete Selected",
96
- downloadCollection: "Download Collection",
97
- editMetadata: "Edit metadata",
98
- download: "Download",
99
- },
100
-
101
- user: {
102
- teamManagement: "Team Management",
103
- inviteMember: "Invite Member",
104
- allUsers: "All Users",
105
- admins: "Admins",
106
- restricted: "Restricted",
107
- },
108
-
109
- auth: {
110
- signIn: "Sign In",
111
- createAccount: "Create Account",
112
- signingIn: "Signing in...",
113
- creatingAccount: "Creating account...",
114
- dontHaveAccount: "Don't have an account?",
115
- signUp: "Sign up",
116
- alreadyHaveAccount: "Already have an account?",
117
- },
118
-
119
- confirm: {
120
- deleteEntry: "Delete Entry",
121
- deleteConfirm: "Delete {item}?",
122
- actionCannotBeUndone: "This action cannot be undone.",
123
- deleteDocuments: "Delete Documents",
124
- },
125
-
126
- audit: {
127
- eventId: "Event ID",
128
- timestamp: "Timestamp",
129
- userEmail: "User Email",
130
- userId: "User ID",
131
- role: "Role",
132
- resource: "Resource",
133
- resourceId: "Resource ID",
134
- ipAddress: "IP Address",
135
- },
136
-
137
- collection: {
138
- pages: "Pages",
139
- posts: "Posts",
140
- categories: "Categories",
141
- media: "Media",
142
- settings: "Settings",
143
- navigation: "Navigation",
144
- users: "Users",
145
- },
146
-
147
- item: {
148
- item: "Item",
149
- itemCount: "Item {n}",
150
- items: "Items",
151
- noItems: 'No items. Click "Add Item" to create one.',
152
- },
153
-
154
- empty: {
155
- noResults: "No results found",
156
- loading: "Loading...",
157
- noData: "No data available",
158
- },
159
-
160
- validation: {
161
- required: "This field is required",
162
- email: "Please enter a valid email address",
163
- url: "Please enter a valid URL",
164
- minLength: "Minimum {min} characters required",
165
- maxLength: "Maximum {max} characters allowed",
166
- number: "Please enter a valid number",
167
- integer: "Please enter a whole number",
168
- range: "Please enter a value between {min} and {max}",
169
- json: "Please enter valid JSON",
170
- hexColor: "Please enter a valid hex color",
171
- phone: "Please enter a valid phone number",
172
- postalCode: "Please enter a valid postal code",
173
- matches: "Values do not match",
174
- pattern: "Invalid format",
175
- },
176
-
177
- errors: {
178
- generic: "Something went wrong. Please try again.",
179
- network: "Network error. Please check your connection.",
180
- unauthorized: "You are not authorized to perform this action.",
181
- notFound: "The requested resource was not found.",
182
- serverError: "Server error. Please try again later.",
183
- },
184
-
185
- actions: {
186
- save: "Save",
187
- cancel: "Cancel",
188
- delete: "Delete",
189
- edit: "Edit",
190
- create: "Create",
191
- add: "Add",
192
- update: "Update",
193
- confirm: "Confirm",
194
- clear: "Clear",
195
- close: "Close",
196
- back: "Back",
197
- next: "Next",
198
- submit: "Submit",
199
- remove: "Remove",
200
- search: "Search",
201
- filter: "Filter",
202
- sort: "Sort",
203
- refresh: "Refresh",
204
- reload: "Reload",
205
- export: "Export",
206
- import: "Import",
207
- upload: "Upload",
208
- download: "Download",
209
- copy: "Copy",
210
- select: "Select",
211
- selectAll: "Select All",
212
- deselectAll: "Deselect All",
213
- },
214
-
215
- pagination: {
216
- page: "Page",
217
- of: "of",
218
- first: "First",
219
- last: "Last",
220
- previous: "Previous",
221
- next: "Next",
222
- showing: "Showing",
223
- to: "to",
224
- from: "from",
225
- results: "results",
226
- perPage: "Per page",
227
- },
228
-
229
- filters: {
230
- all: "All",
231
- active: "Active",
232
- inactive: "Inactive",
233
- published: "Published",
234
- draft: "Draft",
235
- archived: "Archived",
236
- search: "Search",
237
- dateRange: "Date Range",
238
- clearFilters: "Clear Filters",
239
- applyFilters: "Apply Filters",
240
- },
241
-
242
- sort: {
243
- ascending: "Ascending",
244
- descending: "Descending",
245
- sortBy: "Sort by",
246
- },
247
-
248
- table: {
249
- noColumns: "No columns selected",
250
- toggleColumns: "Toggle Columns",
251
- rowsPerPage: "Rows per page",
252
- },
253
-
254
- blocks: {
255
- addBlock: "Add Block",
256
- removeBlock: "Remove Block",
257
- moveUp: "Move Up",
258
- moveDown: "Move Down",
259
- },
260
-
261
- richText: {
262
- bold: "Bold",
263
- italic: "Italic",
264
- underline: "Underline",
265
- strikethrough: "Strikethrough",
266
- bulletList: "Bullet List",
267
- numberedList: "Numbered List",
268
- heading: "Heading",
269
- link: "Link",
270
- code: "Code",
271
- },
272
-
273
- upload: {
274
- dragDrop: "Drag and drop files here",
275
- orBrowse: "or browse",
276
- uploading: "Uploading...",
277
- uploadComplete: "Upload complete",
278
- uploadFailed: "Upload failed",
279
- fileTooLarge: "File is too large",
280
- invalidType: "Invalid file type",
281
- },
282
-
283
- version: {
284
- versionHistory: "Version History",
285
- currentVersion: "Current Version",
286
- restoreVersion: "Restore Version",
287
- previewVersion: "Preview Version",
288
- compareVersion: "Compare Versions",
289
- autoSaved: "Auto-saved",
290
- manuallySaved: "Manually saved",
291
- },
292
- };
293
-
294
- type Translations = typeof en;
295
-
296
- interface I18nState {
297
- locale: string;
298
- translations: Translations;
299
- setLocale: (locale: string) => void;
300
- }
301
-
302
- export const useI18n = create<I18nState>((set) => ({
303
- locale: "en",
304
- translations: en,
305
- setLocale: (locale) => set({ locale }),
306
- }));
307
-
308
- export function getT(
309
- key: string,
310
- replacements?: Record<string, string>,
311
- ): string {
312
- const { translations } = useI18n.getState();
313
- const keys = key.split(".");
314
- let result: any = translations;
315
-
316
- for (const k of keys) {
317
- result = result?.[k];
318
- if (result === undefined) return key;
319
- }
320
-
321
- if (typeof result !== "string") return key;
322
-
323
- if (replacements) {
324
- return Object.entries(replacements).reduce(
325
- (str, [k, v]) => str.replace(new RegExp(`\\{${k}}`, "g"), v),
326
- result,
327
- );
328
- }
329
-
330
- return result;
331
- }
332
-
333
- export function useTranslation() {
334
- const translations = useI18n((state) => state.translations);
335
- return {
336
- t: (key: string, replacements?: Record<string, string>) => {
337
- const keys = key.split(".");
338
- let result: any = translations;
339
- for (const k of keys) {
340
- result = result?.[k];
341
- if (result === undefined) return key;
342
- }
343
- if (typeof result !== "string") return key;
344
- if (replacements) {
345
- return Object.entries(replacements).reduce(
346
- (str, [k, v]) => str.replace(new RegExp(`\\{${k}}`, "g"), v),
347
- result,
348
- );
349
- }
350
- return result;
351
- },
352
- };
353
- }