@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.
- package/lib/cjs/add-component.js +1 -1
- package/lib/cjs/chunks/{draft-data-BM4piqW0.js → draft-data-CBA2Fr-1.js} +1 -1
- package/lib/cjs/chunks/{home-DHalB2t8.js → home-2n7dbQz5.js} +3 -3
- package/lib/cjs/chunks/{index-D5dbumB6.js → index-CaivrAu8.js} +1 -1
- package/lib/cjs/chunks/{publish-button-B1tpen-s.js → publish-button-CRQmmzK4.js} +1 -1
- package/lib/cjs/chunks/state-B5PBvcI6.js +1 -0
- package/lib/cjs/home.js +1 -1
- package/lib/cjs/setting.js +1 -1
- package/lib/es/add-component.js +2 -2
- package/lib/es/chunks/{draft-data-CpCuyq4R.js → draft-data-mNAXJMtq.js} +1 -1
- package/lib/es/chunks/{home-geXez-Pe.js → home-DK0hbr0h.js} +4 -4
- package/lib/es/chunks/{index-BB4iH1hV.js → index-DOEiNkBX.js} +1 -1
- package/lib/es/chunks/{publish-button-BtQimyJM.js → publish-button-C6Ixf5NB.js} +3 -3
- package/lib/es/chunks/{state-DSo43FAB.js → state-DRjnlQY_.js} +148 -145
- package/lib/es/home.js +3 -3
- package/lib/es/setting.js +1 -1
- package/package.json +3 -3
- package/lib/cjs/chunks/state-tEydRMV8.js +0 -1
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
import { jsx as K } from "react/jsx-runtime";
|
|
2
|
-
import { joinURL as
|
|
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
|
|
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
|
|
15
|
-
import
|
|
16
|
-
import { createContext as oe, useState as
|
|
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,
|
|
24
|
-
if (!
|
|
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
|
|
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
|
|
34
|
+
const J = window.blocklet?.prefix || "/", B = z({
|
|
35
35
|
timeout: 200 * 1e3
|
|
36
|
-
}), ue = window.location.protocol === "https:" ? "wss" : "ws", We = (n) =>
|
|
37
|
-
blocklet?.componentMountPoints.find((n) => n.did === pe)?.mountPoint ||
|
|
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 +
|
|
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,
|
|
42
|
+
function Ve(n, o, f) {
|
|
43
43
|
if (!n || /\.gif/.test(n)) return n;
|
|
44
|
-
const l = (fe ? o / 1.5 : o) * (
|
|
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
|
|
51
|
+
return B.get(`/api/projects/${n}`).then((o) => o.data);
|
|
52
52
|
}
|
|
53
53
|
async function Se(n) {
|
|
54
|
-
return
|
|
54
|
+
return B.post(`/api/projects/${n.id}/update`, n).then((o) => o.data);
|
|
55
55
|
}
|
|
56
|
-
const Pe = 500,
|
|
56
|
+
const Pe = 500, U = oe(null);
|
|
57
57
|
function ze({
|
|
58
58
|
url: n,
|
|
59
59
|
name: o,
|
|
60
|
-
children:
|
|
60
|
+
children: f,
|
|
61
61
|
waitingSynced: l
|
|
62
62
|
}) {
|
|
63
|
-
const [w, g] =
|
|
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
|
|
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(
|
|
82
|
+
), c = y(() => H(a), [a]);
|
|
83
83
|
y(() => new ie(e, c), [e, c]);
|
|
84
|
-
const
|
|
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
|
-
|
|
92
|
-
}, [
|
|
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
|
-
), [
|
|
107
|
+
), [h, C] = D(null), [M, N] = D(!1), [x, A] = D(void 0), b = $(async () => {
|
|
108
108
|
if (m) {
|
|
109
|
-
|
|
109
|
+
N(!0);
|
|
110
110
|
try {
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
} catch (
|
|
114
|
-
console.error("Failed to fetch project:",
|
|
111
|
+
const p = await me(m);
|
|
112
|
+
C(p);
|
|
113
|
+
} catch (p) {
|
|
114
|
+
console.error("Failed to fetch project:", p);
|
|
115
115
|
} finally {
|
|
116
|
-
|
|
116
|
+
N(!1);
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
|
-
}, [m]),
|
|
120
|
-
async (
|
|
121
|
-
if (
|
|
122
|
-
P?.optimisticUpdate &&
|
|
119
|
+
}, [m]), j = $(
|
|
120
|
+
async (p, P) => {
|
|
121
|
+
if (A(void 0), !!m) {
|
|
122
|
+
P?.optimisticUpdate && h && C((I) => ({
|
|
123
123
|
...I,
|
|
124
|
-
...
|
|
124
|
+
...p
|
|
125
125
|
}));
|
|
126
126
|
try {
|
|
127
127
|
const I = await Se({
|
|
128
|
-
...
|
|
128
|
+
...p
|
|
129
129
|
});
|
|
130
|
-
|
|
130
|
+
C(I);
|
|
131
131
|
} catch (I) {
|
|
132
|
-
console.error("Failed to update project:", I), P?.optimisticUpdate &&
|
|
132
|
+
console.error("Failed to update project:", I), P?.optimisticUpdate && C(h), A(I?.response?.data);
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
},
|
|
136
|
-
[m,
|
|
136
|
+
[m, h]
|
|
137
137
|
);
|
|
138
|
-
|
|
139
|
-
m &&
|
|
140
|
-
}, [m,
|
|
141
|
-
const
|
|
138
|
+
_(() => {
|
|
139
|
+
m && b();
|
|
140
|
+
}, [m, b]);
|
|
141
|
+
const R = y(
|
|
142
142
|
() => ({
|
|
143
143
|
doc: c,
|
|
144
|
-
state:
|
|
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: (
|
|
150
|
+
setLocalState: (p) => s(typeof p == "function" ? (P) => p(P ?? {}) : p),
|
|
151
151
|
undoManager: S,
|
|
152
152
|
projectState: {
|
|
153
|
-
project:
|
|
154
|
-
isLoadingProject:
|
|
155
|
-
error:
|
|
153
|
+
project: h,
|
|
154
|
+
isLoadingProject: M,
|
|
155
|
+
error: x
|
|
156
156
|
},
|
|
157
|
-
updateProject:
|
|
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
|
-
|
|
163
|
+
a,
|
|
164
164
|
JSON.stringify(t),
|
|
165
165
|
// resolve the problem of react warning
|
|
166
166
|
s,
|
|
167
167
|
S,
|
|
168
|
-
|
|
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
|
|
177
|
-
S.on("stack-item-added", ({ stackItem:
|
|
178
|
-
const { currentPageId: P, currentLocale: I, pages:
|
|
179
|
-
|
|
180
|
-
}), S.on("stack-item-popped", ({ stackItem:
|
|
181
|
-
const P =
|
|
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]),
|
|
185
|
-
|
|
186
|
-
}, [
|
|
187
|
-
|
|
188
|
-
const
|
|
189
|
-
s((
|
|
190
|
-
...
|
|
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((
|
|
195
|
-
...
|
|
194
|
+
s((v) => ({
|
|
195
|
+
...v,
|
|
196
196
|
networkStatus: "offline"
|
|
197
197
|
}));
|
|
198
|
-
}, I =
|
|
199
|
-
|
|
198
|
+
}, I = G(({ status: v }) => {
|
|
199
|
+
v === "connected" ? p() : v === "disconnected" && P();
|
|
200
200
|
}, Pe);
|
|
201
|
-
return
|
|
202
|
-
|
|
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
|
-
}, [
|
|
204
|
+
}, [i, s]), l && !w ? null : /* @__PURE__ */ K(U.Provider, { value: R, children: f });
|
|
205
205
|
}
|
|
206
206
|
const Ie = () => {
|
|
207
|
-
const n = re(
|
|
207
|
+
const n = re(U);
|
|
208
208
|
if (!n)
|
|
209
209
|
throw new Error("Context is null");
|
|
210
|
-
const o = ee(n.state), { setLocalState:
|
|
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:
|
|
241
|
-
return
|
|
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:
|
|
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(
|
|
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(
|
|
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
|
-
|
|
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 =
|
|
318
|
-
|
|
319
|
-
(r) => L(r, (
|
|
320
|
-
|
|
321
|
-
...
|
|
322
|
-
...
|
|
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,
|
|
327
|
+
return (r, a) => {
|
|
328
328
|
const c = e[r] ?? {};
|
|
329
|
-
Object.assign(c,
|
|
329
|
+
Object.assign(c, a), e[r] = c, t = r, s();
|
|
330
330
|
};
|
|
331
331
|
})(),
|
|
332
332
|
setRouteGenerateProcess: (e) => {
|
|
333
|
-
|
|
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
|
-
|
|
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
|
-
[
|
|
353
|
-
),
|
|
352
|
+
[f, w, g, u]
|
|
353
|
+
), O = y(
|
|
354
354
|
() => ({
|
|
355
355
|
addPage: (e, t) => {
|
|
356
|
-
const s = e?.id ??
|
|
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 ??
|
|
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
|
|
418
|
-
if (!
|
|
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 ??
|
|
422
|
+
id: t.id ?? E(),
|
|
423
423
|
isTemplateSection: t.isTemplateSection ?? !0,
|
|
424
424
|
llmConfig: t.llmConfig ?? {}
|
|
425
|
-
},
|
|
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
|
-
|
|
432
|
-
|
|
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 = [],
|
|
441
|
-
if (
|
|
442
|
-
const
|
|
443
|
-
|
|
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((
|
|
451
|
-
const d = s.sectionIds.indexOf(
|
|
452
|
-
d !== -1 && s.sectionIds.splice(d, 1), s.sections[
|
|
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
|
|
466
|
-
|
|
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),
|
|
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(
|
|
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(
|
|
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
|
|
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[
|
|
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 = (
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
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 &&
|
|
505
|
+
c.sectionIds && a.sectionIds && S(c, a);
|
|
503
506
|
}
|
|
504
|
-
m.setCurrentSectionId(e,
|
|
507
|
+
m.setCurrentSectionId(e, i);
|
|
505
508
|
}
|
|
506
509
|
return c;
|
|
507
510
|
},
|
|
508
511
|
addDataSource: (e) => {
|
|
509
|
-
const t = e.id ??
|
|
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:
|
|
533
|
+
actions: O,
|
|
531
534
|
localActions: m,
|
|
532
535
|
...u
|
|
533
536
|
};
|
|
534
|
-
},
|
|
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
|
|
545
|
+
const f = {};
|
|
543
546
|
return window?.blocklet?.componentMountPoints?.forEach((l) => {
|
|
544
|
-
|
|
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:
|
|
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
|
|
564
|
-
const o = JSON.parse(JSON.stringify(n)),
|
|
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 =
|
|
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
|
-
[
|
|
574
|
+
[O]: {
|
|
572
575
|
...o.config?.gridSettings?.[e]?.[g],
|
|
573
|
-
id:
|
|
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:
|
|
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
|
-
|
|
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
|
-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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.
|
|
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.
|
|
207
|
-
"@blocklet/pages-kit": "^0.6.
|
|
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",
|