@kyro-cms/admin 0.8.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.
Files changed (100) hide show
  1. package/dist/index.cjs +11960 -11006
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.css +67 -65
  4. package/dist/index.css.map +1 -1
  5. package/dist/index.d.cts +563 -0
  6. package/dist/index.d.ts +7 -7
  7. package/dist/index.js +12183 -11238
  8. package/dist/index.js.map +1 -1
  9. package/package.json +15 -11
  10. package/src/components/ActionBar.tsx +27 -14
  11. package/src/components/Admin.tsx +1 -1
  12. package/src/components/ApiKeysManager.tsx +5 -5
  13. package/src/components/AutoForm.tsx +585 -369
  14. package/src/components/BrandingHub.tsx +7 -4
  15. package/src/components/CreateView.tsx +2 -0
  16. package/src/components/DetailView.tsx +71 -56
  17. package/src/components/DeveloperCenter.tsx +8 -6
  18. package/src/components/FieldRenderer.tsx +94 -19
  19. package/src/components/ListView.tsx +33 -20
  20. package/src/components/MediaGallery.tsx +219 -194
  21. package/src/components/PluginsManager.tsx +197 -70
  22. package/src/components/RestPlayground.tsx +7 -7
  23. package/src/components/SessionsManager.tsx +1 -1
  24. package/src/components/SettingsPage.tsx +22 -0
  25. package/src/components/Sidebar.astro +13 -41
  26. package/src/components/UserManagement.tsx +153 -15
  27. package/src/components/UserMenu.tsx +30 -4
  28. package/src/components/VersionHistoryPanel.tsx +112 -119
  29. package/src/components/WebhookManager.tsx +6 -4
  30. package/src/components/blocks/ArrayBlock.tsx +6 -23
  31. package/src/components/blocks/BlockEditModal.tsx +82 -309
  32. package/src/components/blocks/CardBlock.tsx +35 -0
  33. package/src/components/blocks/ChildBlocksTree.tsx +57 -31
  34. package/src/components/blocks/GenericBlock.tsx +44 -0
  35. package/src/components/blocks/HeadingSubheadingBlock.tsx +32 -0
  36. package/src/components/blocks/HeroBlock.tsx +5 -14
  37. package/src/components/blocks/RichTextBlock.tsx +5 -5
  38. package/src/components/blocks/index.ts +5 -3
  39. package/src/components/fields/AccordionField.tsx +2 -2
  40. package/src/components/fields/ArrayField.tsx +1 -1
  41. package/src/components/fields/ArrayLayout.tsx +120 -29
  42. package/src/components/fields/BlocksField.tsx +430 -50
  43. package/src/components/fields/CardField.tsx +73 -0
  44. package/src/components/fields/CheckboxField.tsx +7 -3
  45. package/src/components/fields/DateField.tsx +4 -1
  46. package/src/components/fields/GroupLayout.tsx +2 -2
  47. package/src/components/fields/HeadingSubheadingField.tsx +43 -0
  48. package/src/components/fields/ListField.tsx +2 -2
  49. package/src/components/fields/NumberField.tsx +4 -1
  50. package/src/components/fields/RelationshipField.tsx +153 -87
  51. package/src/components/fields/RichTextField.tsx +781 -0
  52. package/src/components/fields/SecretField.tsx +102 -0
  53. package/src/components/fields/SelectField.tsx +19 -6
  54. package/src/components/fields/TabsLayout.tsx +19 -9
  55. package/src/components/fields/TextField.tsx +4 -1
  56. package/src/components/fields/UploadField.tsx +122 -56
  57. package/src/components/fields/extensions/blockComponents.tsx +103 -174
  58. package/src/components/fields/extensions/blocksStore.ts +8 -1
  59. package/src/components/fields/index.ts +4 -2
  60. package/src/components/ui/PageHeader.tsx +5 -5
  61. package/src/components/ui/SlidePanel.tsx +8 -3
  62. package/src/components/ui/icons.tsx +109 -109
  63. package/src/components/users/UserDetail.tsx +79 -16
  64. package/src/hooks/useAutoFormState.ts +125 -62
  65. package/src/integration.ts +148 -46
  66. package/src/kyro-cms.d.ts +7 -2
  67. package/src/layouts/AuthLayout.astro +14 -2
  68. package/src/lib/autoform-store.ts +85 -52
  69. package/src/lib/change-source.ts +9 -0
  70. package/src/lib/config.ts +104 -8
  71. package/src/lib/globals.ts +44 -9
  72. package/src/lib/normalize-upload-fields.ts +41 -0
  73. package/src/lib/paths.ts +2 -2
  74. package/src/lib/resolve-field-value.ts +110 -0
  75. package/src/lib/shim/use-sync-external-store-with-selector.js +30 -0
  76. package/src/lib/shim/use-sync-external-store.js +1 -0
  77. package/src/lib/stores/index.ts +1 -0
  78. package/src/lib/useResourceManager.ts +4 -4
  79. package/src/lib/vite-shim-plugin.ts +100 -0
  80. package/src/pages/[collection]/[id].astro +1 -1
  81. package/src/pages/preview/[collection]/[id].astro +4 -4
  82. package/src/pages/settings/[slug].astro +2 -2
  83. package/src/styles/main.css +60 -54
  84. package/README.md +0 -46
  85. package/dist/EditorClient-Q23UXR37.cjs +0 -468
  86. package/dist/EditorClient-Q23UXR37.cjs.map +0 -1
  87. package/dist/EditorClient-T5PASFNR.js +0 -466
  88. package/dist/EditorClient-T5PASFNR.js.map +0 -1
  89. package/dist/chunk-3BGDYKTD.cjs +0 -348
  90. package/dist/chunk-3BGDYKTD.cjs.map +0 -1
  91. package/dist/chunk-EEFXLQVT.js +0 -3
  92. package/dist/chunk-EEFXLQVT.js.map +0 -1
  93. package/src/components/blocks/ButtonBlock.tsx +0 -64
  94. package/src/components/blocks/ColumnsBlock.tsx +0 -55
  95. package/src/components/blocks/DividerBlock.tsx +0 -43
  96. package/src/components/blocks/LinkBlock.tsx +0 -65
  97. package/src/components/blocks/VStackBlock.tsx +0 -29
  98. package/src/components/fields/EditorClient.tsx +0 -535
  99. package/src/components/fields/PortableTextField.tsx +0 -155
  100. 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;