@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.cjs CHANGED
@@ -9902,6 +9902,7 @@ function AutoForm({
9902
9902
  disabled: propDisabled,
9903
9903
  collectionSlug,
9904
9904
  globalSlug,
9905
+ documentId,
9905
9906
  documentName,
9906
9907
  layout = "split",
9907
9908
  onActionSuccess,
@@ -9964,6 +9965,22 @@ function AutoForm({
9964
9965
  const [localSaveStatus, setLocalSaveStatus] = React.useState("idle");
9965
9966
  const [now, setNow] = React.useState(Date.now());
9966
9967
  const disabled = propDisabled;
9968
+ const [clientLoading, setClientLoading] = React.useState(false);
9969
+ React.useEffect(() => {
9970
+ const shouldFetchCollection = collectionSlug && documentId && documentId !== "new";
9971
+ const shouldFetchGlobal = globalSlug;
9972
+ if (!shouldFetchCollection && !shouldFetchGlobal) return;
9973
+ if (initialData && Object.keys(initialData).length > 0) return;
9974
+ setClientLoading(true);
9975
+ const url = globalSlug ? `/api/globals/${globalSlug}` : `/api/${collectionSlug}/${documentId}`;
9976
+ apiGet(url, { autoToast: false }).then((result) => {
9977
+ const docData = result.data || {};
9978
+ setFormData(docData);
9979
+ setClientLoading(false);
9980
+ }).catch(() => {
9981
+ setClientLoading(false);
9982
+ });
9983
+ }, [collectionSlug, documentId, globalSlug, initialData]);
9967
9984
  React.useEffect(() => {
9968
9985
  const id = setInterval(() => setNow(Date.now()), 1e4);
9969
9986
  return () => clearInterval(id);
@@ -11303,6 +11320,15 @@ function AutoForm({
11303
11320
  ] })
11304
11321
  ] }) })
11305
11322
  ] }) });
11323
+ if (clientLoading) {
11324
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-6 p-4", children: [
11325
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
11326
+ /* @__PURE__ */ jsxRuntime.jsx(Shimmer, { variant: "text", className: "w-1/3" }),
11327
+ /* @__PURE__ */ jsxRuntime.jsx(Shimmer, { variant: "text", className: "w-2/3" })
11328
+ ] }),
11329
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-4", children: /* @__PURE__ */ jsxRuntime.jsx(Shimmer, { variant: "rect", count: 4 }) })
11330
+ ] });
11331
+ }
11306
11332
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col h-full", children: [
11307
11333
  layout !== "single" && renderHeader(),
11308
11334
  layout === "single" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [