@kyro-cms/admin 0.9.0 → 0.9.1
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/dist/index.cjs +11960 -11006
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +67 -65
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +563 -0
- package/dist/index.d.ts +7 -7
- package/dist/index.js +12183 -11238
- package/dist/index.js.map +1 -1
- package/package.json +15 -11
- package/src/components/ActionBar.tsx +27 -14
- package/src/components/Admin.tsx +1 -1
- package/src/components/ApiKeysManager.tsx +5 -5
- package/src/components/AutoForm.tsx +585 -369
- package/src/components/BrandingHub.tsx +7 -4
- package/src/components/CreateView.tsx +2 -0
- package/src/components/DetailView.tsx +71 -56
- package/src/components/DeveloperCenter.tsx +8 -6
- package/src/components/FieldRenderer.tsx +94 -19
- package/src/components/ListView.tsx +33 -20
- package/src/components/MediaGallery.tsx +219 -194
- package/src/components/PluginsManager.tsx +197 -70
- package/src/components/RestPlayground.tsx +7 -7
- package/src/components/SessionsManager.tsx +1 -1
- package/src/components/SettingsPage.tsx +22 -0
- package/src/components/Sidebar.astro +13 -41
- package/src/components/UserManagement.tsx +153 -15
- package/src/components/UserMenu.tsx +30 -4
- package/src/components/VersionHistoryPanel.tsx +112 -119
- package/src/components/WebhookManager.tsx +6 -4
- package/src/components/blocks/ArrayBlock.tsx +6 -23
- package/src/components/blocks/BlockEditModal.tsx +82 -309
- package/src/components/blocks/CardBlock.tsx +35 -0
- package/src/components/blocks/ChildBlocksTree.tsx +57 -31
- package/src/components/blocks/GenericBlock.tsx +44 -0
- package/src/components/blocks/HeadingSubheadingBlock.tsx +32 -0
- package/src/components/blocks/HeroBlock.tsx +5 -14
- package/src/components/blocks/RichTextBlock.tsx +5 -5
- package/src/components/blocks/index.ts +5 -3
- package/src/components/fields/AccordionField.tsx +2 -2
- package/src/components/fields/ArrayField.tsx +1 -1
- package/src/components/fields/ArrayLayout.tsx +120 -29
- package/src/components/fields/BlocksField.tsx +430 -50
- package/src/components/fields/CardField.tsx +73 -0
- package/src/components/fields/CheckboxField.tsx +7 -3
- package/src/components/fields/DateField.tsx +4 -1
- package/src/components/fields/GroupLayout.tsx +2 -2
- package/src/components/fields/HeadingSubheadingField.tsx +43 -0
- package/src/components/fields/ListField.tsx +2 -2
- package/src/components/fields/NumberField.tsx +4 -1
- package/src/components/fields/RelationshipField.tsx +153 -87
- package/src/components/fields/RichTextField.tsx +781 -0
- package/src/components/fields/SecretField.tsx +102 -0
- package/src/components/fields/SelectField.tsx +19 -6
- package/src/components/fields/TabsLayout.tsx +19 -9
- package/src/components/fields/TextField.tsx +4 -1
- package/src/components/fields/UploadField.tsx +122 -56
- package/src/components/fields/extensions/blockComponents.tsx +103 -174
- package/src/components/fields/extensions/blocksStore.ts +8 -1
- package/src/components/fields/index.ts +4 -2
- package/src/components/ui/PageHeader.tsx +5 -5
- package/src/components/ui/SlidePanel.tsx +8 -3
- package/src/components/ui/icons.tsx +109 -109
- package/src/components/users/UserDetail.tsx +79 -16
- package/src/hooks/useAutoFormState.ts +125 -62
- package/src/integration.ts +148 -46
- package/src/kyro-cms.d.ts +7 -2
- package/src/layouts/AuthLayout.astro +14 -2
- package/src/lib/autoform-store.ts +85 -52
- package/src/lib/change-source.ts +9 -0
- package/src/lib/config.ts +104 -8
- package/src/lib/globals.ts +44 -9
- package/src/lib/normalize-upload-fields.ts +41 -0
- package/src/lib/paths.ts +2 -2
- package/src/lib/resolve-field-value.ts +110 -0
- package/src/lib/shim/use-sync-external-store-with-selector.js +30 -0
- package/src/lib/shim/use-sync-external-store.js +1 -0
- package/src/lib/stores/index.ts +1 -0
- package/src/lib/useResourceManager.ts +4 -4
- package/src/lib/vite-shim-plugin.ts +100 -0
- package/src/pages/[collection]/[id].astro +1 -1
- package/src/pages/preview/[collection]/[id].astro +4 -4
- package/src/pages/settings/[slug].astro +2 -2
- package/src/styles/main.css +60 -54
- package/README.md +0 -46
- package/dist/EditorClient-Q23UXR37.cjs +0 -468
- package/dist/EditorClient-Q23UXR37.cjs.map +0 -1
- package/dist/EditorClient-T5PASFNR.js +0 -466
- package/dist/EditorClient-T5PASFNR.js.map +0 -1
- package/dist/chunk-3BGDYKTD.cjs +0 -348
- package/dist/chunk-3BGDYKTD.cjs.map +0 -1
- package/dist/chunk-EEFXLQVT.js +0 -3
- package/dist/chunk-EEFXLQVT.js.map +0 -1
- package/src/components/blocks/ButtonBlock.tsx +0 -64
- package/src/components/blocks/ColumnsBlock.tsx +0 -55
- package/src/components/blocks/DividerBlock.tsx +0 -43
- package/src/components/blocks/LinkBlock.tsx +0 -65
- package/src/components/blocks/VStackBlock.tsx +0 -29
- package/src/components/fields/EditorClient.tsx +0 -535
- package/src/components/fields/PortableTextField.tsx +0 -155
- package/src/components/fields/PortableTextRenderer.tsx +0 -68
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
useState,
|
|
3
|
-
useEffect,
|
|
4
|
-
useMemo,
|
|
5
|
-
useCallback,
|
|
6
|
-
lazy,
|
|
7
|
-
Suspense,
|
|
8
|
-
useRef,
|
|
9
|
-
} from "react";
|
|
10
|
-
|
|
11
|
-
interface PortableTextFieldProps {
|
|
12
|
-
field: {
|
|
13
|
-
name: string;
|
|
14
|
-
label?: string;
|
|
15
|
-
required?: boolean;
|
|
16
|
-
admin?: {
|
|
17
|
-
description?: string;
|
|
18
|
-
placeholder?: string;
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
value?: unknown;
|
|
22
|
-
onChange?: (value: unknown) => void;
|
|
23
|
-
error?: string;
|
|
24
|
-
disabled?: boolean;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const EditorLazy = lazy(() => import("./EditorClient"));
|
|
28
|
-
|
|
29
|
-
function toPortableTextArray(value: unknown): Record<string, unknown>[] {
|
|
30
|
-
if (Array.isArray(value)) {
|
|
31
|
-
if (
|
|
32
|
-
value.length > 0 &&
|
|
33
|
-
value[0] &&
|
|
34
|
-
typeof value[0] === "object" &&
|
|
35
|
-
"_type" in value[0]
|
|
36
|
-
) {
|
|
37
|
-
return value;
|
|
38
|
-
}
|
|
39
|
-
if (value.length === 0) return [];
|
|
40
|
-
}
|
|
41
|
-
if (typeof value === "string" && value.trim()) {
|
|
42
|
-
return [
|
|
43
|
-
{
|
|
44
|
-
_type: "block",
|
|
45
|
-
_key: "initial-block",
|
|
46
|
-
style: "normal",
|
|
47
|
-
markDefs: [],
|
|
48
|
-
children: [
|
|
49
|
-
{
|
|
50
|
-
_type: "span",
|
|
51
|
-
_key: "initial-span",
|
|
52
|
-
text: value,
|
|
53
|
-
marks: [],
|
|
54
|
-
},
|
|
55
|
-
],
|
|
56
|
-
},
|
|
57
|
-
];
|
|
58
|
-
}
|
|
59
|
-
return [];
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const PortableTextField: React.FC<PortableTextFieldProps> = ({
|
|
63
|
-
field,
|
|
64
|
-
value,
|
|
65
|
-
onChange,
|
|
66
|
-
error,
|
|
67
|
-
disabled,
|
|
68
|
-
}) => {
|
|
69
|
-
const [isMounted, setIsMounted] = useState(false);
|
|
70
|
-
const [editorKey, setEditorKey] = useState(0);
|
|
71
|
-
|
|
72
|
-
useEffect(() => {
|
|
73
|
-
setIsMounted(true);
|
|
74
|
-
}, []);
|
|
75
|
-
|
|
76
|
-
const ptValue = useMemo(() => toPortableTextArray(value), [value]);
|
|
77
|
-
|
|
78
|
-
const prevPtValueRef = useRef(ptValue);
|
|
79
|
-
useEffect(() => {
|
|
80
|
-
const hasChanged =
|
|
81
|
-
JSON.stringify(ptValue) !== JSON.stringify(prevPtValueRef.current);
|
|
82
|
-
if (hasChanged && isMounted) {
|
|
83
|
-
setEditorKey((k) => k + 1);
|
|
84
|
-
prevPtValueRef.current = ptValue;
|
|
85
|
-
}
|
|
86
|
-
}, [ptValue, isMounted]);
|
|
87
|
-
|
|
88
|
-
const handleChange = useCallback(
|
|
89
|
-
(blocks: Record<string, unknown>[]) => {
|
|
90
|
-
if (!blocks || !Array.isArray(blocks)) {
|
|
91
|
-
onChange?.([]);
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
onChange?.(blocks);
|
|
95
|
-
},
|
|
96
|
-
[onChange],
|
|
97
|
-
);
|
|
98
|
-
|
|
99
|
-
if (!isMounted) {
|
|
100
|
-
return (
|
|
101
|
-
<div className="space-y-1.5">
|
|
102
|
-
{field.label && (
|
|
103
|
-
<label className="block text-sm font-medium text-[var(--kyro-text-primary)]">
|
|
104
|
-
{field.label}
|
|
105
|
-
{field.required && (
|
|
106
|
-
<span className="text-[var(--kyro-error)] ml-1">*</span>
|
|
107
|
-
)}
|
|
108
|
-
</label>
|
|
109
|
-
)}
|
|
110
|
-
<div className="h-[200px] rounded-lg border border-[var(--kyro-border)] animate-pulse bg-[var(--kyro-bg-secondary)]" />
|
|
111
|
-
</div>
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
return (
|
|
116
|
-
<div className="space-y-1.5">
|
|
117
|
-
{field.label && (
|
|
118
|
-
<label className="block text-sm font-medium text-[var(--kyro-text-primary)]">
|
|
119
|
-
{field.label}
|
|
120
|
-
{field.required && (
|
|
121
|
-
<span className="text-[var(--kyro-error)] ml-1">*</span>
|
|
122
|
-
)}
|
|
123
|
-
</label>
|
|
124
|
-
)}
|
|
125
|
-
<div
|
|
126
|
-
className={`border border-[var(--kyro-border)] rounded-lg overflow-hidden ${disabled ? "opacity-50 cursor-not-allowed" : ""}`}
|
|
127
|
-
>
|
|
128
|
-
<Suspense
|
|
129
|
-
fallback={
|
|
130
|
-
<div className="h-[200px] flex items-center justify-center bg-[var(--kyro-bg-secondary)]">
|
|
131
|
-
<span className="text-sm text-[var(--kyro-text-muted)]">
|
|
132
|
-
Loading editor...
|
|
133
|
-
</span>
|
|
134
|
-
</div>
|
|
135
|
-
}
|
|
136
|
-
>
|
|
137
|
-
<EditorLazy
|
|
138
|
-
key={editorKey}
|
|
139
|
-
initialValue={ptValue}
|
|
140
|
-
onChange={handleChange}
|
|
141
|
-
disabled={disabled}
|
|
142
|
-
/>
|
|
143
|
-
</Suspense>
|
|
144
|
-
</div>
|
|
145
|
-
{field.admin?.description && !error && (
|
|
146
|
-
<p className="text-xs text-[var(--kyro-text-muted)]">
|
|
147
|
-
{field.admin.description}
|
|
148
|
-
</p>
|
|
149
|
-
)}
|
|
150
|
-
{error && <p className="text-xs text-[var(--kyro-error)]">{error}</p>}
|
|
151
|
-
</div>
|
|
152
|
-
);
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
export default PortableTextField;
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { PortableText } from "@portabletext/react";
|
|
3
|
-
import type { PortableTextComponents } from "@portabletext/react";
|
|
4
|
-
|
|
5
|
-
interface PortableTextRendererProps {
|
|
6
|
-
value: unknown[];
|
|
7
|
-
className?: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const components: PortableTextComponents = {
|
|
11
|
-
block: {
|
|
12
|
-
h1: ({ children }) => (
|
|
13
|
-
<h1 className="text-2xl font-bold mb-2">{children}</h1>
|
|
14
|
-
),
|
|
15
|
-
h2: ({ children }) => (
|
|
16
|
-
<h2 className="text-xl font-bold mb-2">{children}</h2>
|
|
17
|
-
),
|
|
18
|
-
h3: ({ children }) => (
|
|
19
|
-
<h3 className="text-lg font-semibold mb-2">{children}</h3>
|
|
20
|
-
),
|
|
21
|
-
blockquote: ({ children }) => (
|
|
22
|
-
<blockquote className="border-l-4 border-gray-300 pl-4 italic my-2">
|
|
23
|
-
{children}
|
|
24
|
-
</blockquote>
|
|
25
|
-
),
|
|
26
|
-
normal: ({ children }) => <p className="my-1">{children}</p>,
|
|
27
|
-
},
|
|
28
|
-
marks: {
|
|
29
|
-
strong: ({ children }) => <strong>{children}</strong>,
|
|
30
|
-
em: ({ children }) => <em>{children}</em>,
|
|
31
|
-
code: ({ children }) => (
|
|
32
|
-
<code className="bg-gray-100 px-1 rounded text-sm font-mono">
|
|
33
|
-
{children}
|
|
34
|
-
</code>
|
|
35
|
-
),
|
|
36
|
-
underline: ({ children }) => <u>{children}</u>,
|
|
37
|
-
strikeThrough: ({ children }) => <s>{children}</s>,
|
|
38
|
-
},
|
|
39
|
-
list: {
|
|
40
|
-
bullet: ({ children }) => (
|
|
41
|
-
<ul className="list-disc ml-4 my-2">{children}</ul>
|
|
42
|
-
),
|
|
43
|
-
number: ({ children }) => (
|
|
44
|
-
<ol className="list-decimal ml-4 my-2">{children}</ol>
|
|
45
|
-
),
|
|
46
|
-
},
|
|
47
|
-
listItem: {
|
|
48
|
-
bullet: ({ children }) => <li className="my-1">{children}</li>,
|
|
49
|
-
number: ({ children }) => <li className="my-1">{children}</li>,
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export const PortableTextRenderer: React.FC<PortableTextRendererProps> = ({
|
|
54
|
-
value,
|
|
55
|
-
className = "",
|
|
56
|
-
}) => {
|
|
57
|
-
if (!value || !Array.isArray(value) || value.length === 0) {
|
|
58
|
-
return null;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return (
|
|
62
|
-
<div className={className}>
|
|
63
|
-
<PortableText value={value} components={components} />
|
|
64
|
-
</div>
|
|
65
|
-
);
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
export default PortableTextRenderer;
|