@kyro-cms/admin 0.10.4 → 0.10.6
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 +29 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/AutoForm.tsx +46 -1
- package/src/pages/[collection]/[id].astro +2 -34
- package/src/pages/settings/[slug].astro +1 -25
package/dist/index.d.cts
CHANGED
|
@@ -204,6 +204,7 @@ interface AutoFormProps {
|
|
|
204
204
|
disabled?: boolean;
|
|
205
205
|
collectionSlug?: string;
|
|
206
206
|
globalSlug?: string;
|
|
207
|
+
documentId?: string;
|
|
207
208
|
documentName?: string;
|
|
208
209
|
layout?: "split" | "single";
|
|
209
210
|
onActionSuccess?: (message: string) => void;
|
|
@@ -211,7 +212,7 @@ interface AutoFormProps {
|
|
|
211
212
|
justSaved?: boolean;
|
|
212
213
|
documentStatus?: string;
|
|
213
214
|
}
|
|
214
|
-
declare function AutoForm({ config: propConfig, data: initialData, errors, onChange, disabled: propDisabled, collectionSlug, globalSlug, documentName, layout, onActionSuccess, onActionError, justSaved, }: AutoFormProps): react_jsx_runtime.JSX.Element;
|
|
215
|
+
declare function AutoForm({ config: propConfig, data: initialData, errors, onChange, disabled: propDisabled, collectionSlug, globalSlug, documentId, documentName, layout, onActionSuccess, onActionError, justSaved, }: AutoFormProps): react_jsx_runtime.JSX.Element;
|
|
215
216
|
|
|
216
217
|
type DocumentStatus = "draft" | "published" | "scheduled" | "archived";
|
|
217
218
|
type SaveStatus = "idle" | "saving" | "saved" | "error";
|
package/dist/index.d.ts
CHANGED
|
@@ -204,6 +204,7 @@ interface AutoFormProps {
|
|
|
204
204
|
disabled?: boolean;
|
|
205
205
|
collectionSlug?: string;
|
|
206
206
|
globalSlug?: string;
|
|
207
|
+
documentId?: string;
|
|
207
208
|
documentName?: string;
|
|
208
209
|
layout?: "split" | "single";
|
|
209
210
|
onActionSuccess?: (message: string) => void;
|
|
@@ -211,7 +212,7 @@ interface AutoFormProps {
|
|
|
211
212
|
justSaved?: boolean;
|
|
212
213
|
documentStatus?: string;
|
|
213
214
|
}
|
|
214
|
-
declare function AutoForm({ config: propConfig, data: initialData, errors, onChange, disabled: propDisabled, collectionSlug, globalSlug, documentName, layout, onActionSuccess, onActionError, justSaved, }: AutoFormProps): react_jsx_runtime.JSX.Element;
|
|
215
|
+
declare function AutoForm({ config: propConfig, data: initialData, errors, onChange, disabled: propDisabled, collectionSlug, globalSlug, documentId, documentName, layout, onActionSuccess, onActionError, justSaved, }: AutoFormProps): react_jsx_runtime.JSX.Element;
|
|
215
216
|
|
|
216
217
|
type DocumentStatus = "draft" | "published" | "scheduled" | "archived";
|
|
217
218
|
type SaveStatus = "idle" | "saving" | "saved" | "error";
|
package/dist/index.js
CHANGED
|
@@ -9881,6 +9881,7 @@ function AutoForm({
|
|
|
9881
9881
|
disabled: propDisabled,
|
|
9882
9882
|
collectionSlug,
|
|
9883
9883
|
globalSlug,
|
|
9884
|
+
documentId,
|
|
9884
9885
|
documentName,
|
|
9885
9886
|
layout = "split",
|
|
9886
9887
|
onActionSuccess,
|
|
@@ -9943,6 +9944,25 @@ function AutoForm({
|
|
|
9943
9944
|
const [localSaveStatus, setLocalSaveStatus] = useState("idle");
|
|
9944
9945
|
const [now, setNow] = useState(Date.now());
|
|
9945
9946
|
const disabled = propDisabled;
|
|
9947
|
+
const [clientLoading, setClientLoading] = useState(false);
|
|
9948
|
+
const fetchedRef = useRef(false);
|
|
9949
|
+
useEffect(() => {
|
|
9950
|
+
const shouldFetchCollection = collectionSlug && documentId && documentId !== "new";
|
|
9951
|
+
const shouldFetchGlobal = globalSlug;
|
|
9952
|
+
if (!shouldFetchCollection && !shouldFetchGlobal) return;
|
|
9953
|
+
if (fetchedRef.current) return;
|
|
9954
|
+
if (initialData && Object.keys(initialData).length > 0) return;
|
|
9955
|
+
fetchedRef.current = true;
|
|
9956
|
+
setClientLoading(true);
|
|
9957
|
+
const url = globalSlug ? `/api/globals/${globalSlug}` : `/api/${collectionSlug}/${documentId}`;
|
|
9958
|
+
apiGet(url, { autoToast: false }).then((result) => {
|
|
9959
|
+
const docData = result.data || {};
|
|
9960
|
+
setFormData(docData);
|
|
9961
|
+
setClientLoading(false);
|
|
9962
|
+
}).catch(() => {
|
|
9963
|
+
setClientLoading(false);
|
|
9964
|
+
});
|
|
9965
|
+
}, [collectionSlug, documentId, globalSlug]);
|
|
9946
9966
|
useEffect(() => {
|
|
9947
9967
|
const id = setInterval(() => setNow(Date.now()), 1e4);
|
|
9948
9968
|
return () => clearInterval(id);
|
|
@@ -11282,6 +11302,15 @@ function AutoForm({
|
|
|
11282
11302
|
] })
|
|
11283
11303
|
] }) })
|
|
11284
11304
|
] }) });
|
|
11305
|
+
if (clientLoading) {
|
|
11306
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-6 p-4", children: [
|
|
11307
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
11308
|
+
/* @__PURE__ */ jsx(Shimmer, { variant: "text", className: "w-1/3" }),
|
|
11309
|
+
/* @__PURE__ */ jsx(Shimmer, { variant: "text", className: "w-2/3" })
|
|
11310
|
+
] }),
|
|
11311
|
+
/* @__PURE__ */ jsx("div", { className: "space-y-4", children: /* @__PURE__ */ jsx(Shimmer, { variant: "rect", count: 4 }) })
|
|
11312
|
+
] });
|
|
11313
|
+
}
|
|
11285
11314
|
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col h-full", children: [
|
|
11286
11315
|
layout !== "single" && renderHeader(),
|
|
11287
11316
|
layout === "single" && /* @__PURE__ */ jsxs(Fragment, { children: [
|