@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 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,25 @@ 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
+ const fetchedRef = React.useRef(false);
9970
+ React.useEffect(() => {
9971
+ const shouldFetchCollection = collectionSlug && documentId && documentId !== "new";
9972
+ const shouldFetchGlobal = globalSlug;
9973
+ if (!shouldFetchCollection && !shouldFetchGlobal) return;
9974
+ if (fetchedRef.current) return;
9975
+ if (initialData && Object.keys(initialData).length > 0) return;
9976
+ fetchedRef.current = true;
9977
+ setClientLoading(true);
9978
+ const url = globalSlug ? `/api/globals/${globalSlug}` : `/api/${collectionSlug}/${documentId}`;
9979
+ apiGet(url, { autoToast: false }).then((result) => {
9980
+ const docData = result.data || {};
9981
+ setFormData(docData);
9982
+ setClientLoading(false);
9983
+ }).catch(() => {
9984
+ setClientLoading(false);
9985
+ });
9986
+ }, [collectionSlug, documentId, globalSlug]);
9967
9987
  React.useEffect(() => {
9968
9988
  const id = setInterval(() => setNow(Date.now()), 1e4);
9969
9989
  return () => clearInterval(id);
@@ -11303,6 +11323,15 @@ function AutoForm({
11303
11323
  ] })
11304
11324
  ] }) })
11305
11325
  ] }) });
11326
+ if (clientLoading) {
11327
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-6 p-4", children: [
11328
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
11329
+ /* @__PURE__ */ jsxRuntime.jsx(Shimmer, { variant: "text", className: "w-1/3" }),
11330
+ /* @__PURE__ */ jsxRuntime.jsx(Shimmer, { variant: "text", className: "w-2/3" })
11331
+ ] }),
11332
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-4", children: /* @__PURE__ */ jsxRuntime.jsx(Shimmer, { variant: "rect", count: 4 }) })
11333
+ ] });
11334
+ }
11306
11335
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col h-full", children: [
11307
11336
  layout !== "single" && renderHeader(),
11308
11337
  layout === "single" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [