@kyro-cms/admin 0.1.5 → 0.1.7
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 +52 -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 +136 -27
- 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 +1417 -661
- package/src/components/BrandingHub.tsx +267 -0
- package/src/components/BulkActionsBar.tsx +3 -3
- package/src/components/CreateView.tsx +3 -3
- package/src/components/Dashboard.tsx +393 -0
- package/src/components/DetailView.tsx +199 -57
- package/src/components/DeveloperCenter.tsx +403 -0
- package/src/components/EnhancedListView.tsx +786 -0
- package/src/components/GraphQLExplorer.tsx +675 -0
- package/src/components/GraphQLPlayground.tsx +627 -0
- package/src/components/ListView.tsx +191 -53
- package/src/components/MediaGallery.tsx +1569 -0
- package/src/components/Modal.tsx +149 -0
- package/src/components/RestPlayground.tsx +951 -0
- package/src/components/Sidebar.astro +237 -0
- 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 +97 -0
- package/src/components/blocks/ArrayBlock.tsx +75 -0
- package/src/components/blocks/BlockEditModal.MARKER +12 -0
- package/src/components/blocks/BlockEditModal.tsx +774 -0
- package/src/components/blocks/ButtonBlock.tsx +165 -0
- package/src/components/blocks/ChildBlocksTree.tsx +551 -0
- package/src/components/blocks/CodeBlock.tsx +66 -0
- package/src/components/blocks/ColumnsBlock.tsx +151 -0
- package/src/components/blocks/DividerBlock.tsx +43 -0
- package/src/components/blocks/FileBlock.tsx +64 -0
- package/src/components/blocks/HeadingBlock.tsx +81 -0
- package/src/components/blocks/HeroBlock.tsx +157 -0
- package/src/components/blocks/ImageBlock.tsx +83 -0
- package/src/components/blocks/LinkBlock.tsx +71 -0
- package/src/components/blocks/ListBlock.tsx +39 -0
- package/src/components/blocks/ParagraphBlock.tsx +61 -0
- package/src/components/blocks/RelationshipBlock.tsx +279 -0
- package/src/components/blocks/VStackBlock.tsx +75 -0
- package/src/components/blocks/VideoBlock.tsx +45 -0
- package/src/components/blocks/index.ts +10 -0
- package/src/components/fields/BlocksField.tsx +323 -0
- package/src/components/fields/CheckboxField.tsx +15 -9
- package/src/components/fields/CodeField.tsx +234 -0
- package/src/components/fields/DateField.tsx +38 -11
- package/src/components/fields/EditorClient.tsx +271 -0
- package/src/components/fields/FileField.tsx +390 -0
- package/src/components/fields/HybridContentField.tsx +109 -0
- package/src/components/fields/ImageField.tsx +429 -0
- package/src/components/fields/JSONField.tsx +361 -0
- package/src/components/fields/MarkdownField.tsx +282 -0
- package/src/components/fields/NumberField.tsx +42 -12
- package/src/components/fields/PortableTextField.tsx +143 -0
- package/src/components/fields/PortableTextRenderer.tsx +68 -0
- package/src/components/fields/RelationshipField.tsx +231 -59
- package/src/components/fields/SelectField.tsx +25 -15
- package/src/components/fields/TextField.tsx +45 -14
- package/src/components/fields/extensions/blockComponents.tsx +237 -0
- package/src/components/fields/extensions/blocksStore.ts +273 -0
- package/src/components/fields/index.ts +13 -0
- package/src/components/index.ts +1 -2
- package/src/components/layout/Header.tsx +2 -2
- package/src/components/layout/Layout.tsx +2 -2
- 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 +50 -0
- package/src/lib/MediaService.ts +541 -0
- package/src/lib/auth/sqlite-adapter.ts +319 -0
- package/src/lib/config.ts +22 -6
- package/src/lib/dataStore.ts +132 -74
- 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/graphql/index.ts +1 -0
- package/src/lib/graphql/schema.ts +443 -0
- package/src/lib/rate-limit.ts +267 -0
- package/src/lib/storage.ts +374 -0
- package/src/lib/store.ts +85 -0
- package/src/middleware.ts +116 -28
- 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 +286 -0
- 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 +44 -0
- package/src/pages/api/[collection]/[id]/unpublish.ts +42 -0
- package/src/pages/api/[collection]/[id]/versions.ts +36 -0
- package/src/pages/api/[collection]/[id].ts +102 -159
- package/src/pages/api/[collection]/index.ts +151 -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 +50 -20
- 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 +82 -0
- package/src/pages/media.astro +10 -0
- package/src/pages/preview/[collection]/[id].astro +178 -0
- package/src/pages/register.astro +102 -0
- 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 +553 -128
- package/src/components/layout/Sidebar.tsx +0 -497
- package/src/pages/index.astro +0 -225
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useEffect,
|
|
3
|
+
useState,
|
|
4
|
+
useCallback,
|
|
5
|
+
createContext,
|
|
6
|
+
useContext,
|
|
7
|
+
type ReactNode,
|
|
8
|
+
} from "react";
|
|
9
|
+
import { AlertTriangle, HelpCircle } from "lucide-react";
|
|
10
|
+
|
|
11
|
+
export { Modal, ModalContent, ModalActions, ConfirmModal } from "./ui/Modal";
|
|
12
|
+
|
|
13
|
+
// ============================================================================
|
|
14
|
+
// Global Modal Context for programmatic access
|
|
15
|
+
// ============================================================================
|
|
16
|
+
|
|
17
|
+
type ModalVariant = "alert" | "confirm" | "prompt";
|
|
18
|
+
|
|
19
|
+
interface ModalState {
|
|
20
|
+
variant: ModalVariant;
|
|
21
|
+
open: boolean;
|
|
22
|
+
title: string;
|
|
23
|
+
message?: string;
|
|
24
|
+
placeholder?: string;
|
|
25
|
+
defaultValue?: string;
|
|
26
|
+
onConfirm?: (value?: string) => void;
|
|
27
|
+
onCancel?: () => void;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const initialState: ModalState = {
|
|
31
|
+
variant: "alert",
|
|
32
|
+
open: false,
|
|
33
|
+
title: "",
|
|
34
|
+
message: "",
|
|
35
|
+
onConfirm: () => {},
|
|
36
|
+
onCancel: () => {},
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
interface ModalContextType {
|
|
40
|
+
showAlert: (title: string, message?: string) => void;
|
|
41
|
+
showConfirm: (title: string, message: string, onConfirm: () => void) => void;
|
|
42
|
+
showPrompt: (
|
|
43
|
+
title: string,
|
|
44
|
+
message: string,
|
|
45
|
+
onConfirm: (value: string) => void,
|
|
46
|
+
options?: { placeholder?: string; defaultValue?: string },
|
|
47
|
+
) => void;
|
|
48
|
+
closeModal: () => void;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const ModalContext = createContext<ModalContextType | null>(null);
|
|
52
|
+
|
|
53
|
+
export function useModal() {
|
|
54
|
+
const context = useContext(ModalContext);
|
|
55
|
+
if (!context) {
|
|
56
|
+
throw new Error("useModal must be used within ModalProvider");
|
|
57
|
+
}
|
|
58
|
+
return context;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
interface ModalProviderProps {
|
|
62
|
+
children: ReactNode;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function ModalProvider({ children }: ModalProviderProps) {
|
|
66
|
+
const [state, setState] = useState<ModalState>(initialState);
|
|
67
|
+
const [inputValue, setInputValue] = useState(state.defaultValue || "");
|
|
68
|
+
|
|
69
|
+
const showAlert = useCallback((title: string, message?: string) => {
|
|
70
|
+
setState({
|
|
71
|
+
variant: "alert",
|
|
72
|
+
open: true,
|
|
73
|
+
title,
|
|
74
|
+
message,
|
|
75
|
+
onConfirm: () => setState((s) => ({ ...s, open: false })),
|
|
76
|
+
onCancel: () => setState((s) => ({ ...s, open: false })),
|
|
77
|
+
});
|
|
78
|
+
}, []);
|
|
79
|
+
|
|
80
|
+
const showConfirm = useCallback(
|
|
81
|
+
(title: string, message: string, onConfirm: () => void) => {
|
|
82
|
+
setState({
|
|
83
|
+
variant: "confirm",
|
|
84
|
+
open: true,
|
|
85
|
+
title,
|
|
86
|
+
message,
|
|
87
|
+
onConfirm: () => {
|
|
88
|
+
onConfirm();
|
|
89
|
+
setState((s) => ({ ...s, open: false }));
|
|
90
|
+
},
|
|
91
|
+
onCancel: () => setState((s) => ({ ...s, open: false })),
|
|
92
|
+
});
|
|
93
|
+
},
|
|
94
|
+
[],
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
const showPrompt = useCallback(
|
|
98
|
+
(
|
|
99
|
+
title: string,
|
|
100
|
+
message: string,
|
|
101
|
+
onConfirm: (value: string) => void,
|
|
102
|
+
options?: { placeholder?: string; defaultValue?: string },
|
|
103
|
+
) => {
|
|
104
|
+
setState({
|
|
105
|
+
variant: "prompt",
|
|
106
|
+
open: true,
|
|
107
|
+
title,
|
|
108
|
+
message,
|
|
109
|
+
placeholder: options?.placeholder,
|
|
110
|
+
defaultValue: options?.defaultValue,
|
|
111
|
+
onConfirm: (value) => {
|
|
112
|
+
onConfirm(value || "");
|
|
113
|
+
setState((s) => ({ ...s, open: false }));
|
|
114
|
+
},
|
|
115
|
+
onCancel: () => setState((s) => ({ ...s, open: false })),
|
|
116
|
+
});
|
|
117
|
+
},
|
|
118
|
+
[],
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
const closeModal = useCallback(() => {
|
|
122
|
+
setState((s) => ({ ...s, open: false }));
|
|
123
|
+
}, []);
|
|
124
|
+
|
|
125
|
+
// Re-order so imports come first, then showAlert
|
|
126
|
+
const handleShowAlert = (title: string, message?: string) => {
|
|
127
|
+
setState({
|
|
128
|
+
variant: "alert",
|
|
129
|
+
open: true,
|
|
130
|
+
title,
|
|
131
|
+
message,
|
|
132
|
+
onConfirm: () => setState((s) => ({ ...s, open: false })),
|
|
133
|
+
onCancel: () => setState((s) => ({ ...s, open: false })),
|
|
134
|
+
});
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
return (
|
|
138
|
+
<ModalContext.Provider
|
|
139
|
+
value={{
|
|
140
|
+
showAlert: handleShowAlert,
|
|
141
|
+
showConfirm,
|
|
142
|
+
showPrompt,
|
|
143
|
+
closeModal,
|
|
144
|
+
}}
|
|
145
|
+
>
|
|
146
|
+
{children}
|
|
147
|
+
</ModalContext.Provider>
|
|
148
|
+
);
|
|
149
|
+
}
|