@kyro-cms/admin 0.1.6 → 0.1.8

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 (179) hide show
  1. package/README.md +149 -51
  2. package/package.json +54 -5
  3. package/src/collections/auth/index.ts +2 -2
  4. package/src/collections/portfolio/index.ts +343 -0
  5. package/src/components/ActionBar.tsx +153 -16
  6. package/src/components/Admin.tsx +137 -28
  7. package/src/components/ApiExplorer.tsx +325 -0
  8. package/src/components/ApiKeysManager.tsx +563 -0
  9. package/src/components/AuditLogsPage.tsx +664 -0
  10. package/src/components/AutoForm.tsx +2155 -770
  11. package/src/components/BrandingHub.tsx +267 -0
  12. package/src/components/BulkActionsBar.tsx +3 -3
  13. package/src/components/CreateView.tsx +4 -4
  14. package/src/components/Dashboard.tsx +393 -0
  15. package/src/components/DetailView.tsx +200 -58
  16. package/src/components/DeveloperCenter.tsx +403 -0
  17. package/src/components/EnhancedListView.tsx +890 -0
  18. package/src/components/GraphQLExplorer.tsx +675 -0
  19. package/src/components/GraphQLPlayground.tsx +627 -0
  20. package/src/components/ListView.tsx +192 -54
  21. package/src/components/MediaGallery.tsx +1569 -0
  22. package/src/components/Modal.tsx +206 -0
  23. package/src/components/RestPlayground.tsx +951 -0
  24. package/src/components/Sidebar.astro +237 -0
  25. package/src/components/ThemeProvider.tsx +8 -2
  26. package/src/components/UserManagement.tsx +204 -0
  27. package/src/components/VersionHistoryPanel.tsx +3 -3
  28. package/src/components/WebhookManager.tsx +608 -0
  29. package/src/components/blocks/AccordionBlock.tsx +65 -0
  30. package/src/components/blocks/ArrayBlock.tsx +84 -0
  31. package/src/components/blocks/BlockEditModal.tsx +363 -0
  32. package/src/components/blocks/ButtonBlock.tsx +64 -0
  33. package/src/components/blocks/ChildBlocksTree.tsx +551 -0
  34. package/src/components/blocks/CodeBlock.tsx +114 -0
  35. package/src/components/blocks/ColumnsBlock.tsx +93 -0
  36. package/src/components/blocks/DividerBlock.tsx +43 -0
  37. package/src/components/blocks/FileBlock.tsx +63 -0
  38. package/src/components/blocks/HeadingBlock.tsx +59 -0
  39. package/src/components/blocks/HeroBlock.tsx +99 -0
  40. package/src/components/blocks/ImageBlock.tsx +82 -0
  41. package/src/components/blocks/LinkBlock.tsx +65 -0
  42. package/src/components/blocks/ListBlock.tsx +60 -0
  43. package/src/components/blocks/ParagraphBlock.tsx +61 -0
  44. package/src/components/blocks/RelationshipBlock.tsx +72 -0
  45. package/src/components/blocks/RichTextBlock.tsx +66 -0
  46. package/src/components/blocks/VStackBlock.tsx +61 -0
  47. package/src/components/blocks/VideoBlock.tsx +65 -0
  48. package/src/components/blocks/index.ts +10 -0
  49. package/src/components/fields/AccordionField.tsx +213 -0
  50. package/src/components/fields/ArrayField.tsx +241 -0
  51. package/src/components/fields/BlocksField.tsx +323 -0
  52. package/src/components/fields/ButtonField.tsx +53 -0
  53. package/src/components/fields/CheckboxField.tsx +18 -8
  54. package/src/components/fields/ChildrenField.tsx +48 -0
  55. package/src/components/fields/CodeField.tsx +294 -0
  56. package/src/components/fields/ColumnsField.tsx +137 -0
  57. package/src/components/fields/DateField.tsx +24 -12
  58. package/src/components/fields/EditorClient.tsx +537 -0
  59. package/src/components/fields/HeadingField.tsx +31 -0
  60. package/src/components/fields/HeroField.tsx +101 -0
  61. package/src/components/fields/JSONField.tsx +341 -0
  62. package/src/components/fields/LinkField.tsx +81 -0
  63. package/src/components/fields/ListField.tsx +74 -0
  64. package/src/components/fields/MarkdownField.tsx +260 -0
  65. package/src/components/fields/NumberField.tsx +25 -13
  66. package/src/components/fields/PortableTextField.tsx +155 -0
  67. package/src/components/fields/PortableTextRenderer.tsx +68 -0
  68. package/src/components/fields/RelationshipBlockField.tsx +233 -0
  69. package/src/components/fields/RelationshipField.tsx +278 -60
  70. package/src/components/fields/SelectField.tsx +28 -16
  71. package/src/components/fields/TextField.tsx +31 -15
  72. package/src/components/fields/UploadField.tsx +613 -0
  73. package/src/components/fields/VideoField.tsx +73 -0
  74. package/src/components/fields/extensions/blockComponents.tsx +247 -0
  75. package/src/components/fields/extensions/blocksStore.ts +273 -0
  76. package/src/components/fields/index.ts +24 -0
  77. package/src/components/index.ts +1 -2
  78. package/src/components/layout/Header.tsx +2 -2
  79. package/src/components/layout/Layout.tsx +3 -3
  80. package/src/components/ui/Badge.tsx +9 -4
  81. package/src/components/ui/BlockDrawer.tsx +79 -0
  82. package/src/components/ui/Button.tsx +1 -1
  83. package/src/components/ui/CommandPalette.tsx +362 -0
  84. package/src/components/ui/CommandPaletteWrapper.tsx +97 -0
  85. package/src/components/ui/Dropdown.tsx +1 -1
  86. package/src/components/ui/Modal.tsx +37 -12
  87. package/src/components/ui/PromptModal.tsx +94 -0
  88. package/src/components/ui/SlidePanel.tsx +43 -16
  89. package/src/components/ui/Toast.tsx +80 -14
  90. package/src/env.d.ts +16 -0
  91. package/src/env.ts +20 -0
  92. package/src/index.ts +0 -1
  93. package/src/layouts/AdminLayout.astro +164 -170
  94. package/src/layouts/AuthLayout.astro +23 -6
  95. package/src/lib/MediaService.ts +541 -0
  96. package/src/lib/api.ts +163 -0
  97. package/src/lib/auth/sqlite-adapter.ts +319 -0
  98. package/src/lib/config.ts +23 -7
  99. package/src/lib/dataStore.ts +188 -73
  100. package/src/lib/date-utils.ts +69 -0
  101. package/src/lib/db/adapter.ts +54 -0
  102. package/src/lib/db/drizzle-mysql-adapter.ts +194 -0
  103. package/src/lib/db/drizzle-mysql-auth-adapter.ts +327 -0
  104. package/src/lib/db/drizzle-postgres-adapter.ts +202 -0
  105. package/src/lib/db/drizzle-postgres-auth-adapter.ts +304 -0
  106. package/src/lib/db/drizzle-sqlite-adapter.ts +227 -0
  107. package/src/lib/db/drizzle-sqlite-auth-adapter.ts +548 -0
  108. package/src/lib/db/index.ts +449 -0
  109. package/src/lib/db/mongodb-adapter.ts +207 -0
  110. package/src/lib/db/mongodb-auth-adapter.ts +305 -0
  111. package/src/lib/db/schema/mysql-auth.ts +113 -0
  112. package/src/lib/db/schema/mysql-content.ts +20 -0
  113. package/src/lib/db/schema/postgres-auth.ts +116 -0
  114. package/src/lib/db/schema/postgres-content.ts +35 -0
  115. package/src/lib/db/schema/postgres-media.ts +52 -0
  116. package/src/lib/db/schema/postgres-settings.ts +11 -0
  117. package/src/lib/db/schema/sqlite-auth.ts +112 -0
  118. package/src/lib/db/schema/sqlite-content.ts +20 -0
  119. package/src/lib/db/version-adapter.ts +248 -0
  120. package/src/lib/graphql/index.ts +1 -0
  121. package/src/lib/graphql/schema.ts +443 -0
  122. package/src/lib/i18n.tsx +353 -0
  123. package/src/lib/rate-limit.ts +267 -0
  124. package/src/lib/slugify.ts +15 -0
  125. package/src/lib/storage.ts +374 -0
  126. package/src/lib/store.ts +85 -0
  127. package/src/lib/validation.ts +250 -0
  128. package/src/middleware.ts +70 -11
  129. package/src/pages/[collection]/[id].astro +178 -122
  130. package/src/pages/[collection]/index.astro +24 -156
  131. package/src/pages/admin/api-explorer.astro +98 -0
  132. package/src/pages/admin/graphql-explorer.astro +40 -0
  133. package/src/pages/admin/graphql.astro +97 -0
  134. package/src/pages/admin/index.astro +200 -139
  135. package/src/pages/admin/keys.astro +8 -0
  136. package/src/pages/admin/rest-playground.astro +44 -0
  137. package/src/pages/admin/webhooks.astro +8 -0
  138. package/src/pages/api/[collection]/[id]/publish.ts +52 -0
  139. package/src/pages/api/[collection]/[id]/unpublish.ts +42 -0
  140. package/src/pages/api/[collection]/[id]/versions.ts +66 -0
  141. package/src/pages/api/[collection]/[id].ts +114 -159
  142. package/src/pages/api/[collection]/index.ts +150 -230
  143. package/src/pages/api/auth/[id].ts +48 -69
  144. package/src/pages/api/auth/audit-logs.ts +20 -43
  145. package/src/pages/api/auth/login.ts +159 -45
  146. package/src/pages/api/auth/logout.ts +42 -24
  147. package/src/pages/api/auth/refresh.ts +119 -0
  148. package/src/pages/api/auth/register.ts +110 -40
  149. package/src/pages/api/auth/users.ts +22 -97
  150. package/src/pages/api/collections.ts +59 -0
  151. package/src/pages/api/globals/[slug]/test.ts +172 -0
  152. package/src/pages/api/globals/[slug].ts +42 -0
  153. package/src/pages/api/graphql.ts +90 -0
  154. package/src/pages/api/health.ts +417 -40
  155. package/src/pages/api/keys/[id].ts +26 -0
  156. package/src/pages/api/keys/index.ts +75 -0
  157. package/src/pages/api/media/[id].ts +309 -0
  158. package/src/pages/api/media/folders.ts +609 -0
  159. package/src/pages/api/media/index.ts +146 -0
  160. package/src/pages/api/media/resize.ts +267 -0
  161. package/src/pages/api/search.ts +82 -0
  162. package/src/pages/api/slug-availability.ts +70 -0
  163. package/src/pages/api/storage-config.ts +20 -0
  164. package/src/pages/api/storage-status.ts +206 -0
  165. package/src/pages/api/upload.ts +334 -0
  166. package/src/pages/api/webhooks/index.ts +71 -0
  167. package/src/pages/audit/index.astro +2 -104
  168. package/src/pages/login.astro +11 -11
  169. package/src/pages/media.astro +10 -0
  170. package/src/pages/preview/[collection]/[id].astro +178 -0
  171. package/src/pages/register.astro +13 -13
  172. package/src/pages/roles/index.astro +21 -21
  173. package/src/pages/settings/[slug].astro +162 -0
  174. package/src/pages/settings/index.astro +9 -0
  175. package/src/pages/users/[id].astro +29 -21
  176. package/src/pages/users/index.astro +22 -17
  177. package/src/pages/users/new.astro +18 -17
  178. package/src/styles/main.css +563 -128
  179. package/src/components/layout/Sidebar.tsx +0 -497
@@ -0,0 +1,206 @@
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
+ }