@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.
- package/README.md +149 -51
- package/package.json +54 -5
- package/src/collections/auth/index.ts +2 -2
- package/src/collections/portfolio/index.ts +343 -0
- package/src/components/ActionBar.tsx +153 -16
- package/src/components/Admin.tsx +137 -28
- package/src/components/ApiExplorer.tsx +325 -0
- package/src/components/ApiKeysManager.tsx +563 -0
- package/src/components/AuditLogsPage.tsx +664 -0
- package/src/components/AutoForm.tsx +2155 -770
- package/src/components/BrandingHub.tsx +267 -0
- package/src/components/BulkActionsBar.tsx +3 -3
- package/src/components/CreateView.tsx +4 -4
- package/src/components/Dashboard.tsx +393 -0
- package/src/components/DetailView.tsx +200 -58
- package/src/components/DeveloperCenter.tsx +403 -0
- package/src/components/EnhancedListView.tsx +890 -0
- package/src/components/GraphQLExplorer.tsx +675 -0
- package/src/components/GraphQLPlayground.tsx +627 -0
- package/src/components/ListView.tsx +192 -54
- package/src/components/MediaGallery.tsx +1569 -0
- package/src/components/Modal.tsx +206 -0
- package/src/components/RestPlayground.tsx +951 -0
- package/src/components/Sidebar.astro +237 -0
- package/src/components/ThemeProvider.tsx +8 -2
- package/src/components/UserManagement.tsx +204 -0
- package/src/components/VersionHistoryPanel.tsx +3 -3
- package/src/components/WebhookManager.tsx +608 -0
- package/src/components/blocks/AccordionBlock.tsx +65 -0
- package/src/components/blocks/ArrayBlock.tsx +84 -0
- package/src/components/blocks/BlockEditModal.tsx +363 -0
- package/src/components/blocks/ButtonBlock.tsx +64 -0
- package/src/components/blocks/ChildBlocksTree.tsx +551 -0
- package/src/components/blocks/CodeBlock.tsx +114 -0
- package/src/components/blocks/ColumnsBlock.tsx +93 -0
- package/src/components/blocks/DividerBlock.tsx +43 -0
- package/src/components/blocks/FileBlock.tsx +63 -0
- package/src/components/blocks/HeadingBlock.tsx +59 -0
- package/src/components/blocks/HeroBlock.tsx +99 -0
- package/src/components/blocks/ImageBlock.tsx +82 -0
- package/src/components/blocks/LinkBlock.tsx +65 -0
- package/src/components/blocks/ListBlock.tsx +60 -0
- package/src/components/blocks/ParagraphBlock.tsx +61 -0
- package/src/components/blocks/RelationshipBlock.tsx +72 -0
- package/src/components/blocks/RichTextBlock.tsx +66 -0
- package/src/components/blocks/VStackBlock.tsx +61 -0
- package/src/components/blocks/VideoBlock.tsx +65 -0
- package/src/components/blocks/index.ts +10 -0
- package/src/components/fields/AccordionField.tsx +213 -0
- package/src/components/fields/ArrayField.tsx +241 -0
- package/src/components/fields/BlocksField.tsx +323 -0
- package/src/components/fields/ButtonField.tsx +53 -0
- package/src/components/fields/CheckboxField.tsx +18 -8
- package/src/components/fields/ChildrenField.tsx +48 -0
- package/src/components/fields/CodeField.tsx +294 -0
- package/src/components/fields/ColumnsField.tsx +137 -0
- package/src/components/fields/DateField.tsx +24 -12
- package/src/components/fields/EditorClient.tsx +537 -0
- package/src/components/fields/HeadingField.tsx +31 -0
- package/src/components/fields/HeroField.tsx +101 -0
- package/src/components/fields/JSONField.tsx +341 -0
- package/src/components/fields/LinkField.tsx +81 -0
- package/src/components/fields/ListField.tsx +74 -0
- package/src/components/fields/MarkdownField.tsx +260 -0
- package/src/components/fields/NumberField.tsx +25 -13
- package/src/components/fields/PortableTextField.tsx +155 -0
- package/src/components/fields/PortableTextRenderer.tsx +68 -0
- package/src/components/fields/RelationshipBlockField.tsx +233 -0
- package/src/components/fields/RelationshipField.tsx +278 -60
- package/src/components/fields/SelectField.tsx +28 -16
- package/src/components/fields/TextField.tsx +31 -15
- package/src/components/fields/UploadField.tsx +613 -0
- package/src/components/fields/VideoField.tsx +73 -0
- package/src/components/fields/extensions/blockComponents.tsx +247 -0
- package/src/components/fields/extensions/blocksStore.ts +273 -0
- package/src/components/fields/index.ts +24 -0
- package/src/components/index.ts +1 -2
- package/src/components/layout/Header.tsx +2 -2
- package/src/components/layout/Layout.tsx +3 -3
- package/src/components/ui/Badge.tsx +9 -4
- package/src/components/ui/BlockDrawer.tsx +79 -0
- package/src/components/ui/Button.tsx +1 -1
- package/src/components/ui/CommandPalette.tsx +362 -0
- package/src/components/ui/CommandPaletteWrapper.tsx +97 -0
- package/src/components/ui/Dropdown.tsx +1 -1
- package/src/components/ui/Modal.tsx +37 -12
- package/src/components/ui/PromptModal.tsx +94 -0
- package/src/components/ui/SlidePanel.tsx +43 -16
- package/src/components/ui/Toast.tsx +80 -14
- package/src/env.d.ts +16 -0
- package/src/env.ts +20 -0
- package/src/index.ts +0 -1
- package/src/layouts/AdminLayout.astro +164 -170
- package/src/layouts/AuthLayout.astro +23 -6
- package/src/lib/MediaService.ts +541 -0
- package/src/lib/api.ts +163 -0
- package/src/lib/auth/sqlite-adapter.ts +319 -0
- package/src/lib/config.ts +23 -7
- package/src/lib/dataStore.ts +188 -73
- package/src/lib/date-utils.ts +69 -0
- package/src/lib/db/adapter.ts +54 -0
- package/src/lib/db/drizzle-mysql-adapter.ts +194 -0
- package/src/lib/db/drizzle-mysql-auth-adapter.ts +327 -0
- package/src/lib/db/drizzle-postgres-adapter.ts +202 -0
- package/src/lib/db/drizzle-postgres-auth-adapter.ts +304 -0
- package/src/lib/db/drizzle-sqlite-adapter.ts +227 -0
- package/src/lib/db/drizzle-sqlite-auth-adapter.ts +548 -0
- package/src/lib/db/index.ts +449 -0
- package/src/lib/db/mongodb-adapter.ts +207 -0
- package/src/lib/db/mongodb-auth-adapter.ts +305 -0
- package/src/lib/db/schema/mysql-auth.ts +113 -0
- package/src/lib/db/schema/mysql-content.ts +20 -0
- package/src/lib/db/schema/postgres-auth.ts +116 -0
- package/src/lib/db/schema/postgres-content.ts +35 -0
- package/src/lib/db/schema/postgres-media.ts +52 -0
- package/src/lib/db/schema/postgres-settings.ts +11 -0
- package/src/lib/db/schema/sqlite-auth.ts +112 -0
- package/src/lib/db/schema/sqlite-content.ts +20 -0
- package/src/lib/db/version-adapter.ts +248 -0
- package/src/lib/graphql/index.ts +1 -0
- package/src/lib/graphql/schema.ts +443 -0
- package/src/lib/i18n.tsx +353 -0
- package/src/lib/rate-limit.ts +267 -0
- package/src/lib/slugify.ts +15 -0
- package/src/lib/storage.ts +374 -0
- package/src/lib/store.ts +85 -0
- package/src/lib/validation.ts +250 -0
- package/src/middleware.ts +70 -11
- package/src/pages/[collection]/[id].astro +178 -122
- package/src/pages/[collection]/index.astro +24 -156
- package/src/pages/admin/api-explorer.astro +98 -0
- package/src/pages/admin/graphql-explorer.astro +40 -0
- package/src/pages/admin/graphql.astro +97 -0
- package/src/pages/admin/index.astro +200 -139
- package/src/pages/admin/keys.astro +8 -0
- package/src/pages/admin/rest-playground.astro +44 -0
- package/src/pages/admin/webhooks.astro +8 -0
- package/src/pages/api/[collection]/[id]/publish.ts +52 -0
- package/src/pages/api/[collection]/[id]/unpublish.ts +42 -0
- package/src/pages/api/[collection]/[id]/versions.ts +66 -0
- package/src/pages/api/[collection]/[id].ts +114 -159
- package/src/pages/api/[collection]/index.ts +150 -230
- package/src/pages/api/auth/[id].ts +48 -69
- package/src/pages/api/auth/audit-logs.ts +20 -43
- package/src/pages/api/auth/login.ts +159 -45
- package/src/pages/api/auth/logout.ts +42 -24
- package/src/pages/api/auth/refresh.ts +119 -0
- package/src/pages/api/auth/register.ts +110 -40
- package/src/pages/api/auth/users.ts +22 -97
- package/src/pages/api/collections.ts +59 -0
- package/src/pages/api/globals/[slug]/test.ts +172 -0
- package/src/pages/api/globals/[slug].ts +42 -0
- package/src/pages/api/graphql.ts +90 -0
- package/src/pages/api/health.ts +417 -40
- package/src/pages/api/keys/[id].ts +26 -0
- package/src/pages/api/keys/index.ts +75 -0
- package/src/pages/api/media/[id].ts +309 -0
- package/src/pages/api/media/folders.ts +609 -0
- package/src/pages/api/media/index.ts +146 -0
- package/src/pages/api/media/resize.ts +267 -0
- package/src/pages/api/search.ts +82 -0
- package/src/pages/api/slug-availability.ts +70 -0
- package/src/pages/api/storage-config.ts +20 -0
- package/src/pages/api/storage-status.ts +206 -0
- package/src/pages/api/upload.ts +334 -0
- package/src/pages/api/webhooks/index.ts +71 -0
- package/src/pages/audit/index.astro +2 -104
- package/src/pages/login.astro +11 -11
- package/src/pages/media.astro +10 -0
- package/src/pages/preview/[collection]/[id].astro +178 -0
- package/src/pages/register.astro +13 -13
- package/src/pages/roles/index.astro +21 -21
- package/src/pages/settings/[slug].astro +162 -0
- package/src/pages/settings/index.astro +9 -0
- package/src/pages/users/[id].astro +29 -21
- package/src/pages/users/index.astro +22 -17
- package/src/pages/users/new.astro +18 -17
- package/src/styles/main.css +563 -128
- 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
|
+
}
|