@cedros/data-react 0.1.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.
- package/CHANGELOG.md +24 -0
- package/README.md +177 -0
- package/dist/admin/api.d.ts +19 -0
- package/dist/admin/api.js +108 -0
- package/dist/admin/components.d.ts +36 -0
- package/dist/admin/components.js +22 -0
- package/dist/admin/history.d.ts +17 -0
- package/dist/admin/history.js +103 -0
- package/dist/admin/icons.d.ts +15 -0
- package/dist/admin/icons.js +18 -0
- package/dist/admin/index.d.ts +13 -0
- package/dist/admin/index.js +12 -0
- package/dist/admin/permissions.d.ts +4 -0
- package/dist/admin/permissions.js +45 -0
- package/dist/admin/plugin.d.ts +4 -0
- package/dist/admin/plugin.js +180 -0
- package/dist/admin/primitives/ConfirmDialog.d.ts +14 -0
- package/dist/admin/primitives/ConfirmDialog.js +7 -0
- package/dist/admin/primitives/DataTable.d.ts +14 -0
- package/dist/admin/primitives/DataTable.js +7 -0
- package/dist/admin/primitives/DiffViewer.d.ts +11 -0
- package/dist/admin/primitives/DiffViewer.js +8 -0
- package/dist/admin/primitives/FormFieldRow.d.ts +23 -0
- package/dist/admin/primitives/FormFieldRow.js +16 -0
- package/dist/admin/primitives/JsonCodeEditor.d.ts +10 -0
- package/dist/admin/primitives/JsonCodeEditor.js +42 -0
- package/dist/admin/primitives/Pagination.d.ts +8 -0
- package/dist/admin/primitives/Pagination.js +8 -0
- package/dist/admin/primitives/Toolbar.d.ts +23 -0
- package/dist/admin/primitives/Toolbar.js +10 -0
- package/dist/admin/primitives/alerts.d.ts +21 -0
- package/dist/admin/primitives/alerts.js +44 -0
- package/dist/admin/sectionIds.d.ts +20 -0
- package/dist/admin/sectionIds.js +33 -0
- package/dist/admin/sections/CollectionsSection.d.ts +2 -0
- package/dist/admin/sections/CollectionsSection.js +125 -0
- package/dist/admin/sections/ContractVerifySection.d.ts +11 -0
- package/dist/admin/sections/ContractVerifySection.js +98 -0
- package/dist/admin/sections/CustomDataSection.d.ts +2 -0
- package/dist/admin/sections/CustomDataSection.js +256 -0
- package/dist/admin/sections/DataOpsSection.d.ts +26 -0
- package/dist/admin/sections/DataOpsSection.js +245 -0
- package/dist/admin/sections/HistorySection.d.ts +2 -0
- package/dist/admin/sections/HistorySection.js +26 -0
- package/dist/admin/sections/MonetizationSection.d.ts +2 -0
- package/dist/admin/sections/MonetizationSection.js +140 -0
- package/dist/admin/sections/NavigationSection.d.ts +13 -0
- package/dist/admin/sections/NavigationSection.js +195 -0
- package/dist/admin/sections/PagesSection.d.ts +2 -0
- package/dist/admin/sections/PagesSection.js +157 -0
- package/dist/admin/sections/SchemaDesignerSection.d.ts +2 -0
- package/dist/admin/sections/SchemaDesignerSection.js +167 -0
- package/dist/admin/sections/SiteSettingsSection.d.ts +12 -0
- package/dist/admin/sections/SiteSettingsSection.js +122 -0
- package/dist/admin/sections/TippingSection.d.ts +2 -0
- package/dist/admin/sections/TippingSection.js +178 -0
- package/dist/admin/sections/media/MediaDetail.d.ts +12 -0
- package/dist/admin/sections/media/MediaDetail.js +74 -0
- package/dist/admin/sections/media/MediaGrid.d.ts +14 -0
- package/dist/admin/sections/media/MediaGrid.js +22 -0
- package/dist/admin/sections/media/MediaSection.d.ts +2 -0
- package/dist/admin/sections/media/MediaSection.js +97 -0
- package/dist/admin/sections/media/MediaUploader.d.ts +7 -0
- package/dist/admin/sections/media/MediaUploader.js +72 -0
- package/dist/admin/sections/media/types.d.ts +33 -0
- package/dist/admin/sections/media/types.js +1 -0
- package/dist/admin/styles.css +533 -0
- package/dist/admin/types.d.ts +85 -0
- package/dist/admin/types.js +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +3 -0
- package/dist/react/CmsContent.d.ts +20 -0
- package/dist/react/CmsContent.js +31 -0
- package/dist/react/entries.d.ts +9 -0
- package/dist/react/entries.js +25 -0
- package/dist/react/fetch.d.ts +11 -0
- package/dist/react/fetch.js +32 -0
- package/dist/react/index.d.ts +10 -0
- package/dist/react/index.js +9 -0
- package/dist/react/metadata.d.ts +44 -0
- package/dist/react/metadata.js +142 -0
- package/dist/react/sanitize.d.ts +17 -0
- package/dist/react/sanitize.js +326 -0
- package/dist/react/server.d.ts +14 -0
- package/dist/react/server.js +13 -0
- package/dist/react/sitemap.d.ts +28 -0
- package/dist/react/sitemap.js +91 -0
- package/dist/react/slugs.d.ts +27 -0
- package/dist/react/slugs.js +52 -0
- package/dist/react/types.d.ts +85 -0
- package/dist/react/types.js +1 -0
- package/dist/react/visitor.d.ts +7 -0
- package/dist/react/visitor.js +18 -0
- package/dist/site-templates/BlogTemplates.d.ts +95 -0
- package/dist/site-templates/BlogTemplates.js +64 -0
- package/dist/site-templates/ContactPageTemplate.d.ts +14 -0
- package/dist/site-templates/ContactPageTemplate.js +5 -0
- package/dist/site-templates/DashboardOverviewTemplate.d.ts +29 -0
- package/dist/site-templates/DashboardOverviewTemplate.js +17 -0
- package/dist/site-templates/DashboardShell.d.ts +28 -0
- package/dist/site-templates/DashboardShell.js +10 -0
- package/dist/site-templates/DocsSidebar.d.ts +14 -0
- package/dist/site-templates/DocsSidebar.js +13 -0
- package/dist/site-templates/DocsTemplates.d.ts +60 -0
- package/dist/site-templates/DocsTemplates.js +47 -0
- package/dist/site-templates/HomePageTemplate.d.ts +15 -0
- package/dist/site-templates/HomePageTemplate.js +10 -0
- package/dist/site-templates/LegalPageTemplate.d.ts +12 -0
- package/dist/site-templates/LegalPageTemplate.js +6 -0
- package/dist/site-templates/MarkdownContent.d.ts +7 -0
- package/dist/site-templates/MarkdownContent.js +24 -0
- package/dist/site-templates/NotFoundTemplate.d.ts +9 -0
- package/dist/site-templates/NotFoundTemplate.js +5 -0
- package/dist/site-templates/SiteFooter.d.ts +13 -0
- package/dist/site-templates/SiteFooter.js +4 -0
- package/dist/site-templates/SiteLayout.d.ts +14 -0
- package/dist/site-templates/SiteLayout.js +6 -0
- package/dist/site-templates/TopNav.d.ts +10 -0
- package/dist/site-templates/TopNav.js +8 -0
- package/dist/site-templates/blogControls.d.ts +19 -0
- package/dist/site-templates/blogControls.js +37 -0
- package/dist/site-templates/codeBlock.d.ts +9 -0
- package/dist/site-templates/codeBlock.js +31 -0
- package/dist/site-templates/content-styles.css +410 -0
- package/dist/site-templates/contentIndex.d.ts +65 -0
- package/dist/site-templates/contentIndex.js +181 -0
- package/dist/site-templates/contentUi.d.ts +14 -0
- package/dist/site-templates/contentUi.js +24 -0
- package/dist/site-templates/docs-styles.css +259 -0
- package/dist/site-templates/docsNavigation.d.ts +18 -0
- package/dist/site-templates/docsNavigation.js +50 -0
- package/dist/site-templates/index.d.ts +28 -0
- package/dist/site-templates/index.js +25 -0
- package/dist/site-templates/monetization-styles.css +154 -0
- package/dist/site-templates/paywallControls.d.ts +22 -0
- package/dist/site-templates/paywallControls.js +9 -0
- package/dist/site-templates/routing.d.ts +12 -0
- package/dist/site-templates/routing.js +36 -0
- package/dist/site-templates/solanaAtaSetup.d.ts +11 -0
- package/dist/site-templates/solanaAtaSetup.js +38 -0
- package/dist/site-templates/solanaMicropayments.d.ts +65 -0
- package/dist/site-templates/solanaMicropayments.js +115 -0
- package/dist/site-templates/styles.css +332 -0
- package/dist/site-templates/tipControls.d.ts +24 -0
- package/dist/site-templates/tipControls.js +43 -0
- package/dist/site-templates/tocExtractor.d.ts +16 -0
- package/dist/site-templates/tocExtractor.js +58 -0
- package/dist/site-templates/tocScrollSpy.d.ts +16 -0
- package/dist/site-templates/tocScrollSpy.js +37 -0
- package/dist/templates.d.ts +8 -0
- package/dist/templates.js +20 -0
- package/package.json +58 -0
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { lazy } from "react";
|
|
2
|
+
import { Icons } from "./icons.js";
|
|
3
|
+
import { PERMISSION_MAP } from "./permissions.js";
|
|
4
|
+
import { CEDROS_DATA_GROUPS, CEDROS_DATA_SECTIONS } from "./sectionIds.js";
|
|
5
|
+
const PagesSection = lazy(() => import("./sections/PagesSection.js"));
|
|
6
|
+
const NavigationSection = lazy(() => import("./sections/NavigationSection.js"));
|
|
7
|
+
const SiteSettingsSection = lazy(() => import("./sections/SiteSettingsSection.js"));
|
|
8
|
+
const CollectionsSection = lazy(() => import("./sections/CollectionsSection.js"));
|
|
9
|
+
const SchemaDesignerSection = lazy(() => import("./sections/SchemaDesignerSection.js"));
|
|
10
|
+
const ContractVerifySection = lazy(() => import("./sections/ContractVerifySection.js"));
|
|
11
|
+
const CustomDataSection = lazy(() => import("./sections/CustomDataSection.js"));
|
|
12
|
+
const DataOpsSection = lazy(() => import("./sections/DataOpsSection.js"));
|
|
13
|
+
const MediaSection = lazy(() => import("./sections/media/MediaSection.js"));
|
|
14
|
+
const HistorySection = lazy(() => import("./sections/HistorySection.js"));
|
|
15
|
+
const TippingSection = lazy(() => import("./sections/TippingSection.js"));
|
|
16
|
+
const MonetizationSection = lazy(() => import("./sections/MonetizationSection.js"));
|
|
17
|
+
export const cedrosDataPlugin = {
|
|
18
|
+
id: "cedros-data",
|
|
19
|
+
name: "Cedros Data",
|
|
20
|
+
version: "1.0.0",
|
|
21
|
+
sections: [
|
|
22
|
+
{
|
|
23
|
+
id: CEDROS_DATA_SECTIONS.pages,
|
|
24
|
+
label: "Pages",
|
|
25
|
+
icon: Icons.pages,
|
|
26
|
+
group: CEDROS_DATA_GROUPS.content,
|
|
27
|
+
order: 0,
|
|
28
|
+
requiredPermission: "data:pages:read"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
id: CEDROS_DATA_SECTIONS.navigation,
|
|
32
|
+
label: "Navigation",
|
|
33
|
+
icon: Icons.navigation,
|
|
34
|
+
group: CEDROS_DATA_GROUPS.content,
|
|
35
|
+
order: 1,
|
|
36
|
+
requiredPermission: "data:navigation:read"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
id: CEDROS_DATA_SECTIONS.siteSettings,
|
|
40
|
+
label: "Site Settings",
|
|
41
|
+
icon: Icons.siteSettings,
|
|
42
|
+
group: CEDROS_DATA_GROUPS.content,
|
|
43
|
+
order: 2,
|
|
44
|
+
requiredPermission: "data:settings:read"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
id: CEDROS_DATA_SECTIONS.media,
|
|
48
|
+
label: "Media",
|
|
49
|
+
icon: Icons.media,
|
|
50
|
+
group: CEDROS_DATA_GROUPS.content,
|
|
51
|
+
order: 3,
|
|
52
|
+
requiredPermission: "data:media:read"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
id: CEDROS_DATA_SECTIONS.collections,
|
|
56
|
+
label: "Collections",
|
|
57
|
+
icon: Icons.collections,
|
|
58
|
+
group: CEDROS_DATA_GROUPS.dataModel,
|
|
59
|
+
order: 0,
|
|
60
|
+
requiredPermission: "data:collections:read"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
id: CEDROS_DATA_SECTIONS.schemaDesigner,
|
|
64
|
+
label: "Schema Designer",
|
|
65
|
+
icon: Icons.schemaDesigner,
|
|
66
|
+
group: CEDROS_DATA_GROUPS.dataModel,
|
|
67
|
+
order: 1,
|
|
68
|
+
requiredPermission: "data:ops:write"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
id: CEDROS_DATA_SECTIONS.contractVerify,
|
|
72
|
+
label: "Contract Verify",
|
|
73
|
+
icon: Icons.contractVerify,
|
|
74
|
+
group: CEDROS_DATA_GROUPS.dataModel,
|
|
75
|
+
order: 2,
|
|
76
|
+
requiredPermission: "data:contract:read"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
id: CEDROS_DATA_SECTIONS.customData,
|
|
80
|
+
label: "Custom Data",
|
|
81
|
+
icon: Icons.customData,
|
|
82
|
+
group: CEDROS_DATA_GROUPS.dataModel,
|
|
83
|
+
order: 3,
|
|
84
|
+
requiredPermission: "data:custom:read"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
id: CEDROS_DATA_SECTIONS.dataOps,
|
|
88
|
+
label: "Data Ops",
|
|
89
|
+
icon: Icons.dataOps,
|
|
90
|
+
group: CEDROS_DATA_GROUPS.operations,
|
|
91
|
+
order: 0,
|
|
92
|
+
requiredPermission: "data:ops:write"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
id: CEDROS_DATA_SECTIONS.history,
|
|
96
|
+
label: "History",
|
|
97
|
+
icon: Icons.history,
|
|
98
|
+
group: CEDROS_DATA_GROUPS.operations,
|
|
99
|
+
order: 1,
|
|
100
|
+
requiredPermission: "data:history:read"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
id: CEDROS_DATA_SECTIONS.tipping,
|
|
104
|
+
label: "Tipping",
|
|
105
|
+
icon: Icons.tipping,
|
|
106
|
+
group: CEDROS_DATA_GROUPS.content,
|
|
107
|
+
order: 4,
|
|
108
|
+
requiredPermission: "data:settings:read"
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
id: CEDROS_DATA_SECTIONS.monetization,
|
|
112
|
+
label: "Monetization",
|
|
113
|
+
icon: Icons.monetization,
|
|
114
|
+
group: CEDROS_DATA_GROUPS.content,
|
|
115
|
+
order: 5,
|
|
116
|
+
requiredPermission: "data:settings:read"
|
|
117
|
+
}
|
|
118
|
+
],
|
|
119
|
+
groups: [
|
|
120
|
+
{ id: "content", label: CEDROS_DATA_GROUPS.content, order: 1 },
|
|
121
|
+
{ id: "data-model", label: CEDROS_DATA_GROUPS.dataModel, order: 2 },
|
|
122
|
+
{ id: "operations", label: CEDROS_DATA_GROUPS.operations, order: 3 }
|
|
123
|
+
],
|
|
124
|
+
components: {
|
|
125
|
+
[CEDROS_DATA_SECTIONS.pages]: PagesSection,
|
|
126
|
+
[CEDROS_DATA_SECTIONS.navigation]: NavigationSection,
|
|
127
|
+
[CEDROS_DATA_SECTIONS.siteSettings]: SiteSettingsSection,
|
|
128
|
+
[CEDROS_DATA_SECTIONS.media]: MediaSection,
|
|
129
|
+
[CEDROS_DATA_SECTIONS.collections]: CollectionsSection,
|
|
130
|
+
[CEDROS_DATA_SECTIONS.schemaDesigner]: SchemaDesignerSection,
|
|
131
|
+
[CEDROS_DATA_SECTIONS.contractVerify]: ContractVerifySection,
|
|
132
|
+
[CEDROS_DATA_SECTIONS.customData]: CustomDataSection,
|
|
133
|
+
[CEDROS_DATA_SECTIONS.dataOps]: DataOpsSection,
|
|
134
|
+
[CEDROS_DATA_SECTIONS.history]: HistorySection,
|
|
135
|
+
[CEDROS_DATA_SECTIONS.tipping]: TippingSection,
|
|
136
|
+
[CEDROS_DATA_SECTIONS.monetization]: MonetizationSection
|
|
137
|
+
},
|
|
138
|
+
createPluginContext(hostContext) {
|
|
139
|
+
const custom = readCedrosDataCustomContext(hostContext);
|
|
140
|
+
const serverUrl = custom.serverUrl || hostContext.cedrosLogin?.serverUrl || "";
|
|
141
|
+
if (!serverUrl) {
|
|
142
|
+
throw new Error("cedros-data plugin requires serverUrl in hostContext.custom.cedrosData.serverUrl or hostContext.cedrosLogin.serverUrl");
|
|
143
|
+
}
|
|
144
|
+
return {
|
|
145
|
+
serverUrl,
|
|
146
|
+
userId: hostContext.cedrosLogin?.user?.id,
|
|
147
|
+
getAccessToken: hostContext.cedrosLogin?.getAccessToken ?? (() => null),
|
|
148
|
+
hasPermission: (permission) => this.checkPermission(permission, hostContext),
|
|
149
|
+
orgId: hostContext.org?.orgId
|
|
150
|
+
};
|
|
151
|
+
},
|
|
152
|
+
checkPermission(permission, hostContext) {
|
|
153
|
+
const loginUser = hostContext.cedrosLogin?.user;
|
|
154
|
+
if (!loginUser) {
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
const org = hostContext.org;
|
|
158
|
+
if (!org) {
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
const mapped = PERMISSION_MAP[permission];
|
|
162
|
+
if (!mapped) {
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
return mapped.some((required) => required === org.role || org.permissions.includes(required));
|
|
166
|
+
},
|
|
167
|
+
cssNamespace: "cedros-dashboard"
|
|
168
|
+
};
|
|
169
|
+
export { cedrosDataPlugin as dataPlugin };
|
|
170
|
+
export default cedrosDataPlugin;
|
|
171
|
+
function readCedrosDataCustomContext(hostContext) {
|
|
172
|
+
const raw = hostContext.custom?.cedrosData;
|
|
173
|
+
if (!raw || typeof raw !== "object") {
|
|
174
|
+
return {};
|
|
175
|
+
}
|
|
176
|
+
const maybe = raw;
|
|
177
|
+
return {
|
|
178
|
+
serverUrl: typeof maybe.serverUrl === "string" ? maybe.serverUrl : undefined
|
|
179
|
+
};
|
|
180
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
interface ConfirmDialogProps {
|
|
3
|
+
open: boolean;
|
|
4
|
+
title: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
confirmLabel?: string;
|
|
7
|
+
cancelLabel?: string;
|
|
8
|
+
tone?: "danger" | "neutral";
|
|
9
|
+
onConfirm: () => void;
|
|
10
|
+
onCancel: () => void;
|
|
11
|
+
children?: ReactNode;
|
|
12
|
+
}
|
|
13
|
+
export declare function ConfirmDialog({ open, title, description, confirmLabel, cancelLabel, tone, onConfirm, onCancel, children }: ConfirmDialogProps): React.JSX.Element | null;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
export function ConfirmDialog({ open, title, description, confirmLabel = "Confirm", cancelLabel = "Cancel", tone = "danger", onConfirm, onCancel, children }) {
|
|
3
|
+
if (!open) {
|
|
4
|
+
return null;
|
|
5
|
+
}
|
|
6
|
+
return (_jsx("div", { className: "cedros-data-dialog__overlay", role: "presentation", onClick: onCancel, children: _jsxs("div", { className: "cedros-data-dialog", role: "dialog", "aria-modal": "true", "aria-label": title, onClick: (event) => event.stopPropagation(), children: [_jsx("h3", { className: "cedros-data-dialog__title", children: title }), description && _jsx("p", { className: "cedros-data-dialog__description", children: description }), children, _jsxs("div", { className: "cedros-data-actions", children: [_jsx("button", { className: "cedros-data-btn cedros-data-btn--secondary", onClick: onCancel, children: cancelLabel }), _jsx("button", { className: `cedros-data-btn ${tone === "danger" ? "cedros-data-btn--danger" : "cedros-data-btn--primary"}`, onClick: onConfirm, children: confirmLabel })] })] }) }));
|
|
7
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export interface DataTableColumn<Row> {
|
|
3
|
+
key: string;
|
|
4
|
+
header: ReactNode;
|
|
5
|
+
cell: (row: Row, index: number) => ReactNode;
|
|
6
|
+
width?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface DataTableProps<Row> {
|
|
9
|
+
columns: DataTableColumn<Row>[];
|
|
10
|
+
rows: Row[];
|
|
11
|
+
rowKey: (row: Row, index: number) => string;
|
|
12
|
+
emptyText?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function DataTable<Row>({ columns, rows, rowKey, emptyText }: DataTableProps<Row>): React.JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
export function DataTable({ columns, rows, rowKey, emptyText = "No records." }) {
|
|
3
|
+
if (rows.length === 0) {
|
|
4
|
+
return _jsx("div", { className: "cedros-data-empty", children: emptyText });
|
|
5
|
+
}
|
|
6
|
+
return (_jsx("div", { className: "cedros-data-table-wrap", children: _jsxs("table", { className: "cedros-data-table", children: [_jsx("thead", { children: _jsx("tr", { children: columns.map((column) => (_jsx("th", { style: { width: column.width }, children: column.header }, column.key))) }) }), _jsx("tbody", { children: rows.map((row, index) => (_jsx("tr", { children: columns.map((column) => (_jsx("td", { children: column.cell(row, index) }, `${rowKey(row, index)}:${column.key}`))) }, rowKey(row, index)))) })] }) }));
|
|
7
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface DiffBlock {
|
|
2
|
+
title: string;
|
|
3
|
+
entries: string[];
|
|
4
|
+
tone?: "neutral" | "success" | "error";
|
|
5
|
+
}
|
|
6
|
+
interface DiffViewerProps {
|
|
7
|
+
blocks: DiffBlock[];
|
|
8
|
+
emptyText?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function DiffViewer({ blocks, emptyText }: DiffViewerProps): React.JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
export function DiffViewer({ blocks, emptyText = "No differences." }) {
|
|
3
|
+
const hasEntries = blocks.some((block) => block.entries.length > 0);
|
|
4
|
+
if (!hasEntries) {
|
|
5
|
+
return _jsx("div", { className: "cedros-data-empty", children: emptyText });
|
|
6
|
+
}
|
|
7
|
+
return (_jsx("div", { className: "cedros-data-diff", children: blocks.map((block) => (_jsxs("section", { className: "cedros-data-diff__block", children: [_jsx("h4", { className: "cedros-data-diff__title", children: block.title }), block.entries.length === 0 && _jsx("div", { className: "cedros-data-empty", children: "None." }), block.entries.map((entry) => (_jsx("div", { className: `cedros-data-diff__entry cedros-data-diff__entry--${block.tone || "neutral"}`, children: entry }, `${block.title}:${entry}`)))] }, block.title))) }));
|
|
8
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface FieldTypeOption {
|
|
2
|
+
value: string;
|
|
3
|
+
label: string;
|
|
4
|
+
}
|
|
5
|
+
export interface FormFieldRowValue {
|
|
6
|
+
name: string;
|
|
7
|
+
type: string;
|
|
8
|
+
required: boolean;
|
|
9
|
+
}
|
|
10
|
+
interface FieldTypeSelectProps {
|
|
11
|
+
value: string;
|
|
12
|
+
onChange: (value: string) => void;
|
|
13
|
+
options?: FieldTypeOption[];
|
|
14
|
+
}
|
|
15
|
+
export declare function FieldTypeSelect({ value, onChange, options }: FieldTypeSelectProps): React.JSX.Element;
|
|
16
|
+
interface FormFieldRowProps {
|
|
17
|
+
value: FormFieldRowValue;
|
|
18
|
+
onChange: (next: FormFieldRowValue) => void;
|
|
19
|
+
onRemove?: () => void;
|
|
20
|
+
typeOptions?: FieldTypeOption[];
|
|
21
|
+
}
|
|
22
|
+
export declare function FormFieldRow({ value, onChange, onRemove, typeOptions }: FormFieldRowProps): React.JSX.Element;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { AdminButton, SelectInput, TextInput } from "../components.js";
|
|
3
|
+
const DEFAULT_OPTIONS = [
|
|
4
|
+
{ value: "string", label: "String" },
|
|
5
|
+
{ value: "number", label: "Number" },
|
|
6
|
+
{ value: "boolean", label: "Boolean" },
|
|
7
|
+
{ value: "object", label: "Object" },
|
|
8
|
+
{ value: "array", label: "Array" },
|
|
9
|
+
{ value: "timestamp", label: "Timestamp" }
|
|
10
|
+
];
|
|
11
|
+
export function FieldTypeSelect({ value, onChange, options = DEFAULT_OPTIONS }) {
|
|
12
|
+
return (_jsx(SelectInput, { label: "Type", value: value, onChange: (event) => onChange(event.target.value), children: options.map((option) => (_jsx("option", { value: option.value, children: option.label }, option.value))) }));
|
|
13
|
+
}
|
|
14
|
+
export function FormFieldRow({ value, onChange, onRemove, typeOptions }) {
|
|
15
|
+
return (_jsxs("div", { className: "cedros-data-form-row", children: [_jsx(TextInput, { label: "Name", value: value.name, onChange: (event) => onChange({ ...value, name: event.target.value }), placeholder: "field_name" }), _jsx(FieldTypeSelect, { value: value.type, options: typeOptions, onChange: (type) => onChange({ ...value, type }) }), _jsxs(SelectInput, { label: "Required", value: value.required ? "yes" : "no", onChange: (event) => onChange({ ...value, required: event.target.value === "yes" }), children: [_jsx("option", { value: "yes", children: "Yes" }), _jsx("option", { value: "no", children: "No" })] }), onRemove && (_jsxs("div", { className: "cedros-data-field", children: [_jsx("span", { className: "cedros-data-label", children: "Action" }), _jsx(AdminButton, { variant: "danger", onClick: onRemove, children: "Remove" })] }))] }));
|
|
16
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
interface JsonCodeEditorProps {
|
|
2
|
+
value: string;
|
|
3
|
+
onChange: (value: string) => void;
|
|
4
|
+
label?: string;
|
|
5
|
+
placeholder?: string;
|
|
6
|
+
readOnly?: boolean;
|
|
7
|
+
onValidJson?: (value: unknown) => void;
|
|
8
|
+
}
|
|
9
|
+
export declare function JsonCodeEditor({ value, onChange, label, placeholder, readOnly, onValidJson }: JsonCodeEditorProps): React.JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useMemo } from "react";
|
|
3
|
+
export function JsonCodeEditor({ value, onChange, label, placeholder, readOnly = false, onValidJson }) {
|
|
4
|
+
const parsed = useMemo(() => {
|
|
5
|
+
if (!value.trim()) {
|
|
6
|
+
return {
|
|
7
|
+
isValid: false,
|
|
8
|
+
parseError: null,
|
|
9
|
+
value: undefined
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
try {
|
|
13
|
+
return {
|
|
14
|
+
isValid: true,
|
|
15
|
+
parseError: null,
|
|
16
|
+
value: JSON.parse(value)
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
return {
|
|
21
|
+
isValid: false,
|
|
22
|
+
parseError: error.message,
|
|
23
|
+
value: undefined
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
}, [value]);
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
if (!parsed.isValid) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
onValidJson?.(parsed.value);
|
|
32
|
+
}, [onValidJson, parsed]);
|
|
33
|
+
return (_jsxs("label", { className: "cedros-data-field", children: [label && _jsx("span", { className: "cedros-data-label", children: label }), _jsx("textarea", { className: "cedros-data-textarea cedros-data-textarea--code", value: value, readOnly: readOnly, placeholder: placeholder, onChange: (event) => onChange(event.target.value) }), _jsxs("div", { className: "cedros-data-actions", children: [_jsx("button", { className: "cedros-data-btn cedros-data-btn--secondary cedros-data-btn--sm", type: "button", disabled: readOnly, onClick: () => {
|
|
34
|
+
try {
|
|
35
|
+
const parsed = JSON.parse(value);
|
|
36
|
+
onChange(JSON.stringify(parsed, null, 2));
|
|
37
|
+
}
|
|
38
|
+
catch (_error) {
|
|
39
|
+
// no-op, error shown below
|
|
40
|
+
}
|
|
41
|
+
}, children: "Format JSON" }), parsed.parseError ? (_jsxs("span", { className: "cedros-data-key", style: { color: "var(--cd-error)" }, children: ["Invalid JSON: ", parsed.parseError] })) : (_jsx("span", { className: "cedros-data-key", children: "Valid JSON" }))] })] }));
|
|
42
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
export function Pagination({ page, pageSize, total, onPageChange }) {
|
|
3
|
+
const totalPages = Math.max(1, Math.ceil(total / Math.max(1, pageSize)));
|
|
4
|
+
const safePage = Math.min(Math.max(page, 1), totalPages);
|
|
5
|
+
const from = total === 0 ? 0 : (safePage - 1) * pageSize + 1;
|
|
6
|
+
const to = Math.min(total, safePage * pageSize);
|
|
7
|
+
return (_jsxs("div", { className: "cedros-data-pagination", children: [_jsxs("span", { className: "cedros-data-key", children: [from, "-", to, " of ", total] }), _jsxs("div", { className: "cedros-data-actions", children: [_jsx("button", { className: "cedros-data-btn cedros-data-btn--secondary cedros-data-btn--sm", disabled: safePage <= 1, onClick: () => onPageChange(safePage - 1), children: "Previous" }), _jsxs("span", { className: "cedros-data-pill", children: ["Page ", safePage, "/", totalPages] }), _jsx("button", { className: "cedros-data-btn cedros-data-btn--secondary cedros-data-btn--sm", disabled: safePage >= totalPages, onClick: () => onPageChange(safePage + 1), children: "Next" })] })] }));
|
|
8
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
interface ToolbarProps {
|
|
3
|
+
left?: ReactNode;
|
|
4
|
+
right?: ReactNode;
|
|
5
|
+
}
|
|
6
|
+
export declare function Toolbar({ left, right }: ToolbarProps): React.JSX.Element;
|
|
7
|
+
interface SearchInputProps {
|
|
8
|
+
value: string;
|
|
9
|
+
onChange: (value: string) => void;
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function SearchInput({ value, onChange, placeholder }: SearchInputProps): React.JSX.Element;
|
|
13
|
+
export interface FilterChipItem {
|
|
14
|
+
key: string;
|
|
15
|
+
label: string;
|
|
16
|
+
active: boolean;
|
|
17
|
+
}
|
|
18
|
+
interface FilterChipsProps {
|
|
19
|
+
items: FilterChipItem[];
|
|
20
|
+
onToggle: (key: string) => void;
|
|
21
|
+
}
|
|
22
|
+
export declare function FilterChips({ items, onToggle }: FilterChipsProps): React.JSX.Element;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
export function Toolbar({ left, right }) {
|
|
3
|
+
return (_jsxs("div", { className: "cedros-data-toolbar", children: [_jsx("div", { className: "cedros-data-toolbar__left", children: left }), _jsx("div", { className: "cedros-data-toolbar__right", children: right })] }));
|
|
4
|
+
}
|
|
5
|
+
export function SearchInput({ value, onChange, placeholder = "Search..." }) {
|
|
6
|
+
return (_jsx("input", { className: "cedros-data-input", value: value, onChange: (event) => onChange(event.target.value), placeholder: placeholder, type: "search" }));
|
|
7
|
+
}
|
|
8
|
+
export function FilterChips({ items, onToggle }) {
|
|
9
|
+
return (_jsx("div", { className: "cedros-data-chip-row", children: items.map((item) => (_jsx("button", { className: `cedros-data-chip ${item.active ? "cedros-data-chip--active" : ""}`, onClick: () => onToggle(item.key), children: item.label }, item.key))) }));
|
|
10
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export type AlertTone = "info" | "success" | "error";
|
|
3
|
+
interface ToastItem {
|
|
4
|
+
id: string;
|
|
5
|
+
message: string;
|
|
6
|
+
tone: AlertTone;
|
|
7
|
+
}
|
|
8
|
+
interface ToastContextValue {
|
|
9
|
+
push: (message: string, tone?: AlertTone) => void;
|
|
10
|
+
remove: (id: string) => void;
|
|
11
|
+
items: ToastItem[];
|
|
12
|
+
}
|
|
13
|
+
export declare function ToastProvider({ children }: {
|
|
14
|
+
children: ReactNode;
|
|
15
|
+
}): React.JSX.Element;
|
|
16
|
+
export declare function useToast(): ToastContextValue;
|
|
17
|
+
export declare function InlineAlert({ tone, children }: {
|
|
18
|
+
tone?: AlertTone;
|
|
19
|
+
children: ReactNode;
|
|
20
|
+
}): React.JSX.Element;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useCallback, useContext, useMemo, useRef, useState } from "react";
|
|
3
|
+
const ToastContext = createContext(null);
|
|
4
|
+
export function ToastProvider({ children }) {
|
|
5
|
+
const [items, setItems] = useState([]);
|
|
6
|
+
const timeoutIds = useRef(new Map());
|
|
7
|
+
const remove = useCallback((id) => {
|
|
8
|
+
setItems((previous) => previous.filter((item) => item.id !== id));
|
|
9
|
+
const timeout = timeoutIds.current.get(id);
|
|
10
|
+
if (timeout) {
|
|
11
|
+
clearTimeout(timeout);
|
|
12
|
+
timeoutIds.current.delete(id);
|
|
13
|
+
}
|
|
14
|
+
}, []);
|
|
15
|
+
const push = useCallback((message, tone = "info") => {
|
|
16
|
+
const id = `${Date.now()}-${Math.random().toString(16).slice(2, 8)}`;
|
|
17
|
+
setItems((previous) => [{ id, message, tone }, ...previous].slice(0, 6));
|
|
18
|
+
const timeout = setTimeout(() => remove(id), 4200);
|
|
19
|
+
timeoutIds.current.set(id, timeout);
|
|
20
|
+
}, [remove]);
|
|
21
|
+
const value = useMemo(() => ({
|
|
22
|
+
push,
|
|
23
|
+
remove,
|
|
24
|
+
items
|
|
25
|
+
}), [items, push, remove]);
|
|
26
|
+
return (_jsxs(ToastContext.Provider, { value: value, children: [children, _jsx(ToastViewport, {})] }));
|
|
27
|
+
}
|
|
28
|
+
export function useToast() {
|
|
29
|
+
const context = useContext(ToastContext);
|
|
30
|
+
if (!context) {
|
|
31
|
+
throw new Error("useToast must be used within ToastProvider");
|
|
32
|
+
}
|
|
33
|
+
return context;
|
|
34
|
+
}
|
|
35
|
+
export function InlineAlert({ tone = "info", children }) {
|
|
36
|
+
return _jsx("div", { className: `cedros-inline-alert cedros-inline-alert--${tone}`, children: children });
|
|
37
|
+
}
|
|
38
|
+
function ToastViewport() {
|
|
39
|
+
const context = useContext(ToastContext);
|
|
40
|
+
if (!context || context.items.length === 0) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
return (_jsx("div", { className: "cedros-toast-viewport", children: context.items.map((item) => (_jsx("button", { className: `cedros-toast cedros-toast--${item.tone}`, onClick: () => context.remove(item.id), children: item.message }, item.id))) }));
|
|
44
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare const CEDROS_DATA_SECTIONS: {
|
|
2
|
+
readonly pages: "pages";
|
|
3
|
+
readonly navigation: "navigation";
|
|
4
|
+
readonly siteSettings: "site-settings";
|
|
5
|
+
readonly media: "media";
|
|
6
|
+
readonly collections: "collections";
|
|
7
|
+
readonly schemaDesigner: "schema-designer";
|
|
8
|
+
readonly contractVerify: "contract-verify";
|
|
9
|
+
readonly customData: "custom-data";
|
|
10
|
+
readonly dataOps: "data-ops";
|
|
11
|
+
readonly history: "history";
|
|
12
|
+
readonly tipping: "tipping";
|
|
13
|
+
readonly monetization: "monetization";
|
|
14
|
+
};
|
|
15
|
+
export declare const CEDROS_DATA_SECTION_IDS: readonly ["cedros-data:pages", "cedros-data:navigation", "cedros-data:site-settings", "cedros-data:media", "cedros-data:collections", "cedros-data:schema-designer", "cedros-data:contract-verify", "cedros-data:custom-data", "cedros-data:data-ops", "cedros-data:history", "cedros-data:tipping", "cedros-data:monetization"];
|
|
16
|
+
export declare const CEDROS_DATA_GROUPS: {
|
|
17
|
+
readonly content: "Content";
|
|
18
|
+
readonly dataModel: "Data Model";
|
|
19
|
+
readonly operations: "Operations";
|
|
20
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export const CEDROS_DATA_SECTIONS = {
|
|
2
|
+
pages: "pages",
|
|
3
|
+
navigation: "navigation",
|
|
4
|
+
siteSettings: "site-settings",
|
|
5
|
+
media: "media",
|
|
6
|
+
collections: "collections",
|
|
7
|
+
schemaDesigner: "schema-designer",
|
|
8
|
+
contractVerify: "contract-verify",
|
|
9
|
+
customData: "custom-data",
|
|
10
|
+
dataOps: "data-ops",
|
|
11
|
+
history: "history",
|
|
12
|
+
tipping: "tipping",
|
|
13
|
+
monetization: "monetization"
|
|
14
|
+
};
|
|
15
|
+
export const CEDROS_DATA_SECTION_IDS = [
|
|
16
|
+
"cedros-data:pages",
|
|
17
|
+
"cedros-data:navigation",
|
|
18
|
+
"cedros-data:site-settings",
|
|
19
|
+
"cedros-data:media",
|
|
20
|
+
"cedros-data:collections",
|
|
21
|
+
"cedros-data:schema-designer",
|
|
22
|
+
"cedros-data:contract-verify",
|
|
23
|
+
"cedros-data:custom-data",
|
|
24
|
+
"cedros-data:data-ops",
|
|
25
|
+
"cedros-data:history",
|
|
26
|
+
"cedros-data:tipping",
|
|
27
|
+
"cedros-data:monetization"
|
|
28
|
+
];
|
|
29
|
+
export const CEDROS_DATA_GROUPS = {
|
|
30
|
+
content: "Content",
|
|
31
|
+
dataModel: "Data Model",
|
|
32
|
+
operations: "Operations"
|
|
33
|
+
};
|