@kyro-cms/admin 0.9.0 → 0.9.2

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