@kyro-cms/admin 0.10.4 → 0.10.5

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.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,22 @@ 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
+ useEffect(() => {
9949
+ const shouldFetchCollection = collectionSlug && documentId && documentId !== "new";
9950
+ const shouldFetchGlobal = globalSlug;
9951
+ if (!shouldFetchCollection && !shouldFetchGlobal) return;
9952
+ if (initialData && Object.keys(initialData).length > 0) return;
9953
+ setClientLoading(true);
9954
+ const url = globalSlug ? `/api/globals/${globalSlug}` : `/api/${collectionSlug}/${documentId}`;
9955
+ apiGet(url, { autoToast: false }).then((result) => {
9956
+ const docData = result.data || {};
9957
+ setFormData(docData);
9958
+ setClientLoading(false);
9959
+ }).catch(() => {
9960
+ setClientLoading(false);
9961
+ });
9962
+ }, [collectionSlug, documentId, globalSlug, initialData]);
9946
9963
  useEffect(() => {
9947
9964
  const id = setInterval(() => setNow(Date.now()), 1e4);
9948
9965
  return () => clearInterval(id);
@@ -11282,6 +11299,15 @@ function AutoForm({
11282
11299
  ] })
11283
11300
  ] }) })
11284
11301
  ] }) });
11302
+ if (clientLoading) {
11303
+ return /* @__PURE__ */ jsxs("div", { className: "space-y-6 p-4", children: [
11304
+ /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
11305
+ /* @__PURE__ */ jsx(Shimmer, { variant: "text", className: "w-1/3" }),
11306
+ /* @__PURE__ */ jsx(Shimmer, { variant: "text", className: "w-2/3" })
11307
+ ] }),
11308
+ /* @__PURE__ */ jsx("div", { className: "space-y-4", children: /* @__PURE__ */ jsx(Shimmer, { variant: "rect", count: 4 }) })
11309
+ ] });
11310
+ }
11285
11311
  return /* @__PURE__ */ jsxs("div", { className: "flex flex-col h-full", children: [
11286
11312
  layout !== "single" && renderHeader(),
11287
11313
  layout === "single" && /* @__PURE__ */ jsxs(Fragment, { children: [