@blocklet/pages-kit-inner-components 0.6.30 → 0.6.32

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.
@@ -1,29 +1,29 @@
1
1
  import { jsx as K } from "react/jsx-runtime";
2
- import { joinURL as N, withQuery as V } from "ufo";
2
+ import { joinURL as k, withQuery as V } from "ufo";
3
3
  import { createAxios as z } from "@blocklet/js-sdk";
4
4
  import Q from "lodash/isEmpty";
5
5
  import * as X from "yaml";
6
6
  import { useLocaleContext as q } from "@arcblock/ux/lib/Locale/context";
7
- import { nextId as M } from "@blocklet/pages-kit/utils/common";
7
+ import { nextId as E } from "@blocklet/pages-kit/utils/common";
8
8
  import { getPageTemplateModel as Y } from "@blocklet/pages-kit/utils/page-model";
9
9
  import "@mui/material";
10
10
  import Z, { getYjsDoc as H } from "@syncedstore/core";
11
11
  import { useSyncedStore as ee } from "@syncedstore/react";
12
12
  import { useLocalStorageState as te } from "ahooks";
13
13
  import { produce as L } from "immer";
14
- import J from "lodash/cloneDeep";
15
- import T from "lodash/debounce";
16
- import { createContext as oe, useState as R, useRef as ne, useMemo as y, useCallback as _, useEffect as D, useContext as re } from "react";
14
+ import T from "lodash/cloneDeep";
15
+ import G from "lodash/debounce";
16
+ import { createContext as oe, useState as D, useRef as ne, useMemo as y, useCallback as $, useEffect as _, useContext as re } from "react";
17
17
  import { useParams as se, useNavigate as ce } from "react-router-dom";
18
18
  import { IndexeddbPersistence as ie } from "y-indexeddb";
19
19
  import { WebsocketProvider as ae } from "y-websocket";
20
20
  import { UndoManager as de } from "yjs";
21
21
  import "@blocklet/pages-kit/types";
22
22
  function le() {
23
- const { pathname: n } = window.location, p = n.match(/\/admin\/(maker|previewer)\/([^/]+)/)?.[2], l = window.__PROJECT_ID__;
24
- if (!p && !l)
23
+ const { pathname: n } = window.location, f = n.match(/\/admin\/(maker|previewer)\/([^/]+)/)?.[2], l = window.__PROJECT_ID__;
24
+ if (!f && !l)
25
25
  throw new Error("Unable to get projectId from pathname");
26
- return p || l;
26
+ return f || l;
27
27
  }
28
28
  function Ue(n) {
29
29
  return `${n}:pages:version`;
@@ -31,41 +31,41 @@ function Ue(n) {
31
31
  function Fe(n, o) {
32
32
  return o === "yaml" ? Q(n) ? "" : X.stringify(n, { indent: 2 }) : o === "json" ? JSON.parse(JSON.stringify(n || {})) : o === "array" ? JSON.parse(JSON.stringify(n || [])) : n;
33
33
  }
34
- const $ = window.blocklet?.prefix || "/", G = z({
34
+ const J = window.blocklet?.prefix || "/", B = z({
35
35
  timeout: 200 * 1e3
36
- }), ue = window.location.protocol === "https:" ? "wss" : "ws", We = (n) => N(`${ue}://${window.location.hostname}`, $, `api/${n}/ws/pages`), pe = "z8ia1mAXo8ZE7ytGF36L5uBf9kD2kenhqFGp9";
37
- blocklet?.componentMountPoints.find((n) => n.did === pe)?.mountPoint || N($, "/image-bin");
36
+ }), ue = window.location.protocol === "https:" ? "wss" : "ws", We = (n) => k(`${ue}://${window.location.hostname}`, J, `api/${n}/ws/pages`), pe = "z8ia1mAXo8ZE7ytGF36L5uBf9kD2kenhqFGp9";
37
+ blocklet?.componentMountPoints.find((n) => n.did === pe)?.mountPoint || k(J, "/image-bin");
38
38
  function Ke(n) {
39
- return n && !/^(https?:\/\/|\/)/.test(n) ? window.location.origin + N($, "uploads", n) : n;
39
+ return n && !/^(https?:\/\/|\/)/.test(n) ? window.location.origin + k(J, "uploads", n) : n;
40
40
  }
41
41
  const fe = window.innerWidth <= 750;
42
- function Ve(n, o, p) {
42
+ function Ve(n, o, f) {
43
43
  if (!n || /\.gif/.test(n)) return n;
44
- const l = (fe ? o / 1.5 : o) * (p === "quality" ? 1.5 : 1);
44
+ const l = (fe ? o / 1.5 : o) * (f === "quality" ? 1.5 : 1);
45
45
  return ge(n, { imageFilter: "resize", w: l, f: "webp" });
46
46
  }
47
47
  function ge(n, o) {
48
48
  return !n || !o ? n : V(n, o);
49
49
  }
50
50
  async function me(n) {
51
- return G.get(`/api/projects/${n}`).then((o) => o.data);
51
+ return B.get(`/api/projects/${n}`).then((o) => o.data);
52
52
  }
53
53
  async function Se(n) {
54
- return G.post(`/api/projects/${n.id}/update`, n).then((o) => o.data);
54
+ return B.post(`/api/projects/${n.id}/update`, n).then((o) => o.data);
55
55
  }
56
- const Pe = 500, B = oe(null);
56
+ const Pe = 500, U = oe(null);
57
57
  function ze({
58
58
  url: n,
59
59
  name: o,
60
- children: p,
60
+ children: f,
61
61
  waitingSynced: l
62
62
  }) {
63
- const [w, g] = R(!1), { locale: u } = q(), m = U(), C = `${m}:MakerLocalState`, e = `${m}:${o}`, [t, s] = te(C, {
63
+ const [w, g] = D(!1), { locale: u } = q(), m = F(), O = `${m}:MakerLocalState`, e = `${m}:${o}`, [t, s] = te(O, {
64
64
  defaultValue: {},
65
65
  listenStorageChange: !0
66
66
  }), r = ne(t);
67
67
  r.current = t;
68
- const i = y(
68
+ const a = y(
69
69
  () => Z({
70
70
  dataSourceIds: [],
71
71
  dataSources: {},
@@ -79,17 +79,17 @@ function ze({
79
79
  resources: {}
80
80
  }),
81
81
  []
82
- ), c = y(() => H(i), [i]);
82
+ ), c = y(() => H(a), [a]);
83
83
  y(() => new ie(e, c), [e, c]);
84
- const a = y(
84
+ const i = y(
85
85
  () => new ae(n, e, c, {
86
86
  params: {},
87
87
  resyncInterval: 5 * 60 * 1e3
88
88
  }),
89
89
  [n, e, c]
90
- ), d = _(() => {
91
- a && (a.disconnect(), a.connect());
92
- }, [a]), S = y(
90
+ ), d = $(() => {
91
+ i && (i.disconnect(), i.connect());
92
+ }, [i]), S = y(
93
93
  () => new de(
94
94
  [
95
95
  c.getArray("pageIds"),
@@ -104,110 +104,110 @@ function ze({
104
104
  { doc: c }
105
105
  ),
106
106
  [c]
107
- ), [v, b] = R(null), [x, A] = R(!1), [O, E] = R(void 0), j = _(async () => {
107
+ ), [h, C] = D(null), [M, N] = D(!1), [x, A] = D(void 0), b = $(async () => {
108
108
  if (m) {
109
- A(!0);
109
+ N(!0);
110
110
  try {
111
- const f = await me(m);
112
- b(f);
113
- } catch (f) {
114
- console.error("Failed to fetch project:", f);
111
+ const p = await me(m);
112
+ C(p);
113
+ } catch (p) {
114
+ console.error("Failed to fetch project:", p);
115
115
  } finally {
116
- A(!1);
116
+ N(!1);
117
117
  }
118
118
  }
119
- }, [m]), k = _(
120
- async (f, P) => {
121
- if (E(void 0), !!m) {
122
- P?.optimisticUpdate && v && b((I) => ({
119
+ }, [m]), j = $(
120
+ async (p, P) => {
121
+ if (A(void 0), !!m) {
122
+ P?.optimisticUpdate && h && C((I) => ({
123
123
  ...I,
124
- ...f
124
+ ...p
125
125
  }));
126
126
  try {
127
127
  const I = await Se({
128
- ...f
128
+ ...p
129
129
  });
130
- b(I);
130
+ C(I);
131
131
  } catch (I) {
132
- console.error("Failed to update project:", I), P?.optimisticUpdate && b(v), E(I?.response?.data);
132
+ console.error("Failed to update project:", I), P?.optimisticUpdate && C(h), A(I?.response?.data);
133
133
  }
134
134
  }
135
135
  },
136
- [m, v]
136
+ [m, h]
137
137
  );
138
- D(() => {
139
- m && j();
140
- }, [m, j]);
141
- const W = y(
138
+ _(() => {
139
+ m && b();
140
+ }, [m, b]);
141
+ const R = y(
142
142
  () => ({
143
143
  doc: c,
144
- state: i,
144
+ state: a,
145
145
  localState: {
146
146
  ...t,
147
147
  // always use the locale from the context
148
148
  currentLocale: u
149
149
  },
150
- setLocalState: (f) => s(typeof f == "function" ? (P) => f(P ?? {}) : f),
150
+ setLocalState: (p) => s(typeof p == "function" ? (P) => p(P ?? {}) : p),
151
151
  undoManager: S,
152
152
  projectState: {
153
- project: v,
154
- isLoadingProject: x,
155
- error: O
153
+ project: h,
154
+ isLoadingProject: M,
155
+ error: x
156
156
  },
157
- updateProject: k,
157
+ updateProject: j,
158
158
  forceSync: d
159
159
  }),
160
160
  // eslint-disable-next-line react-hooks/exhaustive-deps
161
161
  [
162
162
  c,
163
- i,
163
+ a,
164
164
  JSON.stringify(t),
165
165
  // resolve the problem of react warning
166
166
  s,
167
167
  S,
168
- v,
168
+ h,
169
+ M,
170
+ j,
169
171
  x,
170
- k,
171
- O,
172
172
  u,
173
173
  d
174
174
  ]
175
175
  );
176
- return D(() => {
177
- S.on("stack-item-added", ({ stackItem: f }) => {
178
- const { currentPageId: P, currentLocale: I, pages: h } = r.current;
179
- f.meta.set("localState", { currentPageId: P, currentLocale: I, pages: h });
180
- }), S.on("stack-item-popped", ({ stackItem: f }) => {
181
- const P = f.meta.get("localState");
176
+ return _(() => {
177
+ S.on("stack-item-added", ({ stackItem: p }) => {
178
+ const { currentPageId: P, currentLocale: I, pages: v } = r.current;
179
+ p.meta.set("localState", { currentPageId: P, currentLocale: I, pages: v });
180
+ }), S.on("stack-item-popped", ({ stackItem: p }) => {
181
+ const P = p.meta.get("localState");
182
182
  P && s((I) => ({ ...I, ...P }));
183
183
  });
184
- }, [S, s]), D(() => {
185
- a.awareness.setLocalState(t);
186
- }, [a, t]), D(() => {
187
- a.once("synced", () => g(!0));
188
- const f = () => {
189
- s((h) => ({
190
- ...h,
184
+ }, [S, s]), _(() => {
185
+ i.awareness.setLocalState(t);
186
+ }, [i, t]), _(() => {
187
+ i.once("synced", () => g(!0));
188
+ const p = () => {
189
+ s((v) => ({
190
+ ...v,
191
191
  networkStatus: void 0
192
192
  }));
193
193
  }, P = () => {
194
- s((h) => ({
195
- ...h,
194
+ s((v) => ({
195
+ ...v,
196
196
  networkStatus: "offline"
197
197
  }));
198
- }, I = T(({ status: h }) => {
199
- h === "connected" ? f() : h === "disconnected" && P();
198
+ }, I = G(({ status: v }) => {
199
+ v === "connected" ? p() : v === "disconnected" && P();
200
200
  }, Pe);
201
- return a.on("status", I), window.addEventListener("online", f), window.addEventListener("offline", P), () => {
202
- a.off("status", I), window.removeEventListener("online", f), window.removeEventListener("offline", P);
201
+ return i.on("status", I), window.addEventListener("online", p), window.addEventListener("offline", P), () => {
202
+ i.off("status", I), window.removeEventListener("online", p), window.removeEventListener("offline", P);
203
203
  };
204
- }, [a, s]), l && !w ? null : /* @__PURE__ */ K(B.Provider, { value: W, children: p });
204
+ }, [i, s]), l && !w ? null : /* @__PURE__ */ K(U.Provider, { value: R, children: f });
205
205
  }
206
206
  const Ie = () => {
207
- const n = re(B);
207
+ const n = re(U);
208
208
  if (!n)
209
209
  throw new Error("Context is null");
210
- const o = ee(n.state), { setLocalState: p, localState: l } = n, w = ce(), g = U(), u = y(
210
+ const o = ee(n.state), { setLocalState: f, localState: l } = n, w = ce(), g = F(), u = y(
211
211
  () => ({
212
212
  get currentPage() {
213
213
  const {
@@ -237,8 +237,8 @@ const Ie = () => {
237
237
  const r = o.pages[e]?.dataSource?.[s];
238
238
  if (!r)
239
239
  return;
240
- const { currentLocale: i } = this.currentLocaleMap;
241
- return i ? r[i] : void 0;
240
+ const { currentLocale: a } = this.currentLocaleMap;
241
+ return a ? r[a] : void 0;
242
242
  },
243
243
  get currentSectionPropertiesWithFallback() {
244
244
  const {
@@ -252,13 +252,13 @@ const Ie = () => {
252
252
  const r = o.pages[e]?.dataSource?.[s];
253
253
  if (!r)
254
254
  return;
255
- const { currentLocale: i, defaultLocale: c, fallbackLocale: a } = this.currentLocaleMap;
256
- if (i && r[i])
257
- return r[i];
258
- if (c && r[c])
259
- return r[c];
255
+ const { currentLocale: a, defaultLocale: c, fallbackLocale: i } = this.currentLocaleMap;
260
256
  if (a && r[a])
261
257
  return r[a];
258
+ if (c && r[c])
259
+ return r[c];
260
+ if (i && r[i])
261
+ return r[i];
262
262
  },
263
263
  get currentLocaleMap() {
264
264
  const {
@@ -290,21 +290,21 @@ const Ie = () => {
290
290
  ), m = y(
291
291
  () => ({
292
292
  setCurrentSectionId: (e, t) => {
293
- e === l.currentPageId && t === l.pages?.[e]?.currentSectionId || (w(N("/admin/maker", g ?? "", "pages", e)), p(
293
+ e === l.currentPageId && t === l.pages?.[e]?.currentSectionId || (w(k("/admin/maker", g ?? "", "pages", e)), f(
294
294
  (s) => L(s, (r) => {
295
295
  r.currentPageId = e, r.currentComponentId = void 0, t !== void 0 && (r.pages ??= {}, r.pages[e] ??= {}, r.pages[e].currentSectionId = t ?? void 0), t ? window.sessionStorage.setItem("iframe_show_id", `"${t}"`) : window.sessionStorage.removeItem("iframe_show_id");
296
296
  })
297
297
  ));
298
298
  },
299
299
  setCurrentComponentId: (e) => {
300
- e !== l.currentComponentId && (w(N("/admin/maker", g ?? "", "components", e)), p(
300
+ e !== l.currentComponentId && (w(k("/admin/maker", g ?? "", "components", e)), f(
301
301
  (t) => L(t, (s) => {
302
302
  s.currentComponentId = e;
303
303
  })
304
304
  ));
305
305
  },
306
306
  setCurrentRouteId: ({ routeId: e, dynamicParams: t }) => {
307
- p(
307
+ f(
308
308
  (s) => L(s, (r) => {
309
309
  r.currentRouteId = e, r.currentDynamicParams = t;
310
310
  })
@@ -314,23 +314,23 @@ const Ie = () => {
314
314
  setCustomComponentPreviewerProperties: (() => {
315
315
  const e = {};
316
316
  let t = "";
317
- const s = T(() => {
318
- p(
319
- (r) => L(r, (i) => {
320
- i.customComponentPreviewerProperties ??= {}, i.customComponentPreviewerProperties[t] = {
321
- ...i.customComponentPreviewerProperties[t],
322
- ...J(e[t])
317
+ const s = G(() => {
318
+ f(
319
+ (r) => L(r, (a) => {
320
+ a.customComponentPreviewerProperties ??= {}, a.customComponentPreviewerProperties[t] = {
321
+ ...a.customComponentPreviewerProperties[t],
322
+ ...T(e[t])
323
323
  }, delete e[t];
324
324
  })
325
325
  );
326
326
  }, 5);
327
- return (r, i) => {
327
+ return (r, a) => {
328
328
  const c = e[r] ?? {};
329
- Object.assign(c, i), e[r] = c, t = r, s();
329
+ Object.assign(c, a), e[r] = c, t = r, s();
330
330
  };
331
331
  })(),
332
332
  setRouteGenerateProcess: (e) => {
333
- p(
333
+ f(
334
334
  (t) => L(t, (s) => {
335
335
  e ? s.routeGenerateProcess = {
336
336
  ...s.routeGenerateProcess,
@@ -340,7 +340,7 @@ const Ie = () => {
340
340
  );
341
341
  },
342
342
  resetRouteGenerateProcess: () => {
343
- p(
343
+ f(
344
344
  (e) => L(e, (t) => {
345
345
  t.routeGenerateProcess = {
346
346
  progress: "complete"
@@ -349,11 +349,11 @@ const Ie = () => {
349
349
  );
350
350
  }
351
351
  }),
352
- [p, w, g, u]
353
- ), C = y(
352
+ [f, w, g, u]
353
+ ), O = y(
354
354
  () => ({
355
355
  addPage: (e, t) => {
356
- const s = e?.id ?? M(), r = {
356
+ const s = e?.id ?? E(), r = {
357
357
  ...e,
358
358
  id: s,
359
359
  createdAt: e?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
@@ -377,7 +377,7 @@ const Ie = () => {
377
377
  }), r;
378
378
  },
379
379
  addRoute: (e, t) => {
380
- const s = e?.id ?? M(), r = {
380
+ const s = e?.id ?? E(), r = {
381
381
  ...e,
382
382
  id: s,
383
383
  createdAt: e?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
@@ -414,22 +414,22 @@ const Ie = () => {
414
414
  r >= 0 && s.splice(t, 0, ...s.splice(r, 1));
415
415
  },
416
416
  addSection: (e, t, s, r) => {
417
- const i = o.pages[e];
418
- if (!i)
417
+ const a = o.pages[e];
418
+ if (!a)
419
419
  throw new Error(`Page ${e} is not exists`);
420
420
  const c = {
421
421
  ...t,
422
- id: t.id ?? M(),
422
+ id: t.id ?? E(),
423
423
  isTemplateSection: t.isTemplateSection ?? !0,
424
424
  llmConfig: t.llmConfig ?? {}
425
- }, a = J(c.locales);
425
+ }, i = T(c.locales);
426
426
  return delete c.locales, n.doc.transact(() => {
427
427
  if (r && r.component === "layout-block") {
428
428
  const d = u.currentPageModel?.getComponentById(r.id);
429
429
  d && (d.model.sections ??= {}, d.model.sections[c.id] = c, d.model.sectionIds ??= [], d.model.sectionIds.push(c.id));
430
430
  } else
431
- i.sections[c.id] = c, i.sectionIds.splice(s ?? i.sectionIds.length, 0, c.id);
432
- a && (i.dataSource ??= {}, i.dataSource[c.id] = a);
431
+ a.sections[c.id] = c, a.sectionIds.splice(s ?? a.sectionIds.length, 0, c.id);
432
+ i && (a.dataSource ??= {}, a.dataSource[c.id] = i);
433
433
  }), c;
434
434
  },
435
435
  deleteSection: (e, t) => {
@@ -437,19 +437,19 @@ const Ie = () => {
437
437
  if (!s)
438
438
  throw new Error(`Page ${e} is not exists`);
439
439
  n.doc.transact(() => {
440
- const r = [], i = u.currentPageModel?.getComponentById(t), c = i?.parent;
441
- if (i && (r.push(i.model.id, ...i.all().map((a) => a.model.id)), c?.model.component === "layout-block")) {
442
- const a = c.model.sectionIds?.indexOf(t);
443
- a !== void 0 && a !== -1 && (c.model.sectionIds?.splice(a, 1), delete c.model.sections?.[t]), c.model.config?.gridSettings && Object.keys(c.model.config.gridSettings).forEach((d) => {
440
+ const r = [], a = u.currentPageModel?.getComponentById(t), c = a?.parent;
441
+ if (a && (r.push(a.model.id, ...a.all().map((i) => i.model.id)), c?.model.component === "layout-block")) {
442
+ const i = c.model.sectionIds?.indexOf(t);
443
+ i !== void 0 && i !== -1 && (c.model.sectionIds?.splice(i, 1), delete c.model.sections?.[t]), c.model.config?.gridSettings && Object.keys(c.model.config.gridSettings).forEach((d) => {
444
444
  try {
445
445
  delete c.model.config.gridSettings[d]?.[t];
446
446
  } catch {
447
447
  }
448
448
  }), c.model.config?.backgroundSectionId === t && (c.model.config.backgroundSectionId = void 0);
449
449
  }
450
- r.forEach((a) => {
451
- const d = s.sectionIds.indexOf(a);
452
- d !== -1 && s.sectionIds.splice(d, 1), s.sections[a] && delete s.sections[a], s.dataSource?.[a] && delete s.dataSource?.[a];
450
+ r.forEach((i) => {
451
+ const d = s.sectionIds.indexOf(i);
452
+ d !== -1 && s.sectionIds.splice(d, 1), s.sections[i] && delete s.sections[i], s.dataSource?.[i] && delete s.dataSource?.[i];
453
453
  });
454
454
  });
455
455
  },
@@ -462,18 +462,18 @@ const Ie = () => {
462
462
  toggleSectionVisibility: (e, t, s) => {
463
463
  if (!o.pages[e])
464
464
  throw new Error(`Page ${e} is not exists`);
465
- const i = u.currentPageModel?.getComponentById(t)?.model;
466
- i && (i.visibility = s);
465
+ const a = u.currentPageModel?.getComponentById(t)?.model;
466
+ a && (a.visibility = s);
467
467
  },
468
468
  moveSection: (e, t, s, r) => {
469
469
  if (!o.pages[e])
470
470
  throw new Error(`Page ${e} is not exists`);
471
471
  if (r && r !== t) {
472
- const c = u.currentPageModel?.getComponentById(t), a = u.currentPageModel?.getComponentById(r), d = c?.parent, S = a?.parent;
472
+ const c = u.currentPageModel?.getComponentById(t), i = u.currentPageModel?.getComponentById(r), d = c?.parent, S = i?.parent;
473
473
  S && d && S?.model?.id === d?.model?.id ? n.doc.transact(() => {
474
- d.model.sectionIds.splice(c.getIndex(), 1), d.model.sectionIds.splice(a.getIndex(), 0, t);
474
+ d.model.sectionIds.splice(c.getIndex(), 1), d.model.sectionIds.splice(i.getIndex(), 0, t);
475
475
  }) : S && d && S?.model?.id !== d?.model?.id && t !== r && !c?.model?.sectionIds?.includes(r) && n.doc.transact(() => {
476
- S.model.sections[t] = JSON.parse(JSON.stringify(c.model)), S.model.sectionIds.splice(a.getIndex(), 0, t), d.model.sectionIds.splice(c.getIndex(), 1), delete d.model.sections[t];
476
+ S.model.sections[t] = JSON.parse(JSON.stringify(c.model)), S.model.sectionIds.splice(i.getIndex(), 0, t), d.model.sectionIds.splice(c.getIndex(), 1), delete d.model.sections[t];
477
477
  });
478
478
  }
479
479
  },
@@ -483,30 +483,33 @@ const Ie = () => {
483
483
  const r = u.currentPageModel?.getComponentById(t);
484
484
  if (!r?.model)
485
485
  throw new Error(`Section ${t} is not exists`);
486
- const i = JSON.parse(JSON.stringify(r.model)), c = F(i), a = c.id, d = r?.parent;
486
+ const a = JSON.parse(JSON.stringify(r.model)), c = W(a), i = c.id, d = r?.parent;
487
487
  if (d) {
488
- if (d.model.sections[a] = c, d.model.sectionIds.push(a), u.currentPage?.dataSource?.[t] && (u.currentPage.dataSource[a] = JSON.parse(
488
+ if (d.model.sections[i] = c, d.model.sectionIds.push(i), u.currentPage?.dataSource?.[t] && (u.currentPage.dataSource[i] = JSON.parse(
489
489
  JSON.stringify(u.currentPage.dataSource[t])
490
490
  ), c.component === "layout-block")) {
491
- const S = (v, b) => {
492
- v?.forEach((x, A) => {
493
- const O = b?.[A];
494
- if (O && u.currentPage?.dataSource) {
495
- const E = u.currentPage.dataSource[O];
496
- E && (u.currentPage.dataSource[x] = JSON.parse(JSON.stringify(E)));
497
- const j = c.sections?.[x], k = i.sections?.[O];
498
- j?.component === "layout-block" && j.sectionIds && k?.sectionIds && S(j.sectionIds, k.sectionIds);
491
+ const S = (h, C) => {
492
+ const M = h.sectionIds, N = C.sectionIds;
493
+ M?.forEach((x, A) => {
494
+ const b = N?.[A];
495
+ if (b) {
496
+ if (b && u.currentPage?.dataSource) {
497
+ const p = u.currentPage.dataSource[b];
498
+ p && (u.currentPage.dataSource[x] = JSON.parse(JSON.stringify(p)));
499
+ }
500
+ const j = h.sections?.[x], R = C?.sections?.[b];
501
+ j?.component === "layout-block" && j.sectionIds && R?.sectionIds && S(j, R);
499
502
  }
500
503
  });
501
504
  };
502
- c.sectionIds && i.sectionIds && S(c.sectionIds, i.sectionIds);
505
+ c.sectionIds && a.sectionIds && S(c, a);
503
506
  }
504
- m.setCurrentSectionId(e, a);
507
+ m.setCurrentSectionId(e, i);
505
508
  }
506
509
  return c;
507
510
  },
508
511
  addDataSource: (e) => {
509
- const t = e.id ?? M(), s = {
512
+ const t = e.id ?? E(), s = {
510
513
  ...e ?? {},
511
514
  id: t,
512
515
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
@@ -527,11 +530,11 @@ const Ie = () => {
527
530
  return {
528
531
  ...n,
529
532
  state: o,
530
- actions: C,
533
+ actions: O,
531
534
  localActions: m,
532
535
  ...u
533
536
  };
534
- }, U = () => {
537
+ }, F = () => {
535
538
  const { projectId: n } = se();
536
539
  return n ?? le() ?? "";
537
540
  }, Qe = () => window.__PROJECT_SLUG__ ?? "";
@@ -539,13 +542,13 @@ function we(n) {
539
542
  const { resources: o } = n;
540
543
  if (!o.components)
541
544
  return {};
542
- const p = {};
545
+ const f = {};
543
546
  return window?.blocklet?.componentMountPoints?.forEach((l) => {
544
- p[l.did] = l;
547
+ f[l.did] = l;
545
548
  }), Object.fromEntries(
546
549
  Object.entries(o.components).map(([l, { blockletId: w, component: g }]) => [
547
550
  l,
548
- { data: g, blockletId: w, blockletTitle: p[w]?.title || w }
551
+ { data: g, blockletId: w, blockletTitle: f[w]?.title || w }
549
552
  ])
550
553
  );
551
554
  }
@@ -560,17 +563,17 @@ function he(n) {
560
563
  };
561
564
  }
562
565
  const Xe = () => he(Ie().state);
563
- function F(n) {
564
- const o = JSON.parse(JSON.stringify(n)), p = M();
566
+ function W(n) {
567
+ const o = JSON.parse(JSON.stringify(n)), f = E();
565
568
  if (o.component === "layout-block") {
566
569
  const l = { ...o.config ?? {} }, w = o.sectionIds?.map((g) => {
567
- const u = o.sections?.[g], m = F(o.sections?.[g]), C = m.id;
570
+ const u = o.sections?.[g], m = W(o.sections?.[g]), O = m.id;
568
571
  return u?.id === o.config?.backgroundSectionId && (l.backgroundSectionId = m.id), o.config?.gridSettings && Object.keys(o.config.gridSettings).forEach((e) => {
569
572
  l.gridSettings[e] = {
570
573
  ...l.gridSettings[e] ?? {},
571
- [C]: {
574
+ [O]: {
572
575
  ...o.config?.gridSettings?.[e]?.[g],
573
- id: C
576
+ id: O
574
577
  }
575
578
  }, delete o.config?.gridSettings?.[e]?.[g];
576
579
  }), m;
@@ -579,7 +582,7 @@ function F(n) {
579
582
  }
580
583
  return {
581
584
  ...o,
582
- id: p
585
+ id: f
583
586
  };
584
587
  }
585
588
  export {
@@ -592,10 +595,10 @@ export {
592
595
  Ke as f,
593
596
  We as g,
594
597
  Xe as h,
595
- G as i,
598
+ B as i,
596
599
  ye as j,
597
600
  we as k,
598
601
  le as l,
599
602
  Fe as t,
600
- U as u
603
+ F as u
601
604
  };
package/lib/es/home.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "react/jsx-runtime";
2
- import "./chunks/state-DSo43FAB.js";
2
+ import "./chunks/state-DRjnlQY_.js";
3
3
  import "@arcblock/ux/lib/Locale/context";
4
4
  import "@arcblock/ux/lib/Result";
5
5
  import "@arcblock/ux/lib/Theme";
@@ -21,8 +21,8 @@ import "react-helmet";
21
21
  import "react-router-dom";
22
22
  import "react-use";
23
23
  import "ufo";
24
- import "./chunks/index-BB4iH1hV.js";
25
- import { a as R, P as S, d as W, c as j, b as k, T as q, H as v } from "./chunks/home-geXez-Pe.js";
24
+ import "./chunks/index-DOEiNkBX.js";
25
+ import { a as R, P as S, d as W, c as j, b as k, T as q, H as v } from "./chunks/home-DK0hbr0h.js";
26
26
  import "./chunks/session-C72Dq8zg.js";
27
27
  export {
28
28
  R as HomeView,
package/lib/es/setting.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsx as r, jsxs as v, Fragment as F } from "react/jsx-runtime";
2
2
  import { Box as P, Alert as Xe, Typography as T, TextField as z, Stack as k, FormLabel as ee, TableContainer as Ze, Paper as G, Table as Ne, TableHead as je, TableRow as re, TableCell as te, TableBody as ze, Button as E, IconButton as Y, FormControlLabel as ge, Switch as Ve, InputAdornment as $, alpha as ae, Tooltip as _, buttonClasses as er, Dialog as ye, DialogTitle as Re, DialogContent as Ee, DialogActions as Ae, Checkbox as rr, Autocomplete as Te, MenuItem as ce, Collapse as tr, Divider as nr, Popper as ir } from "@mui/material";
3
- import { t as xe, f as ne, a as oe, h as ve } from "./chunks/state-DSo43FAB.js";
3
+ import { t as xe, f as ne, a as oe, h as ve } from "./chunks/state-DRjnlQY_.js";
4
4
  import q from "@arcblock/ux/lib/Empty";
5
5
  import { useLocaleContext as V } from "@arcblock/ux/lib/Locale/context";
6
6
  import { CodeEditor as Ce } from "@blocklet/code-editor";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/pages-kit-inner-components",
3
- "version": "0.6.30",
3
+ "version": "0.6.32",
4
4
  "description": "Pages Kit inner components library",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -203,8 +203,8 @@
203
203
  "yaml": "^2.5.0",
204
204
  "yjs": "^13.6.18",
205
205
  "zustand": "^4.5.5",
206
- "@blocklet/pages-kit-block-studio": "^0.6.30",
207
- "@blocklet/pages-kit": "^0.6.30"
206
+ "@blocklet/pages-kit-block-studio": "^0.6.32",
207
+ "@blocklet/pages-kit": "^0.6.32"
208
208
  },
209
209
  "devDependencies": {
210
210
  "@trivago/prettier-plugin-sort-imports": "^5.2.1",