@blocklet/pages-kit-inner-components 0.4.133 → 0.4.134

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.
Files changed (38) hide show
  1. package/package.json +24 -24
  2. package/lib/.nojekyll +0 -0
  3. package/lib/cjs/add-component.js +0 -398
  4. package/lib/cjs/chunks/array-D-LDfLBW.js +0 -441
  5. package/lib/cjs/chunks/config-string-BMi-8GXv.js +0 -1
  6. package/lib/cjs/chunks/draft-data-C-aBMmuZ.js +0 -1
  7. package/lib/cjs/chunks/home-DSfBtFst.js +0 -38
  8. package/lib/cjs/chunks/publish-button-Cd5c5JJ4.js +0 -1
  9. package/lib/cjs/chunks/site-state-DM1kpHq_.js +0 -57
  10. package/lib/cjs/chunks/state-DPSTH2vo.js +0 -1
  11. package/lib/cjs/chunks-map.json +0 -1
  12. package/lib/cjs/components.js +0 -1
  13. package/lib/cjs/home.js +0 -1
  14. package/lib/cjs/locales.js +0 -1
  15. package/lib/cjs/project-html.js +0 -23
  16. package/lib/cjs/resources.js +0 -1
  17. package/lib/cjs/setting.js +0 -11
  18. package/lib/cjs/site-state.js +0 -1
  19. package/lib/cjs/theme.js +0 -239
  20. package/lib/cjs/uploader.js +0 -1
  21. package/lib/es/add-component.js +0 -3017
  22. package/lib/es/chunks/array-BfSgATE1.js +0 -1971
  23. package/lib/es/chunks/config-string-BObBTkZS.js +0 -88
  24. package/lib/es/chunks/draft-data-PScFOAJJ.js +0 -13
  25. package/lib/es/chunks/home-Bnr_eVpB.js +0 -530
  26. package/lib/es/chunks/publish-button-BPU8djxy.js +0 -455
  27. package/lib/es/chunks/site-state-iOveH30c.js +0 -1827
  28. package/lib/es/chunks/state-DGyH1TW3.js +0 -456
  29. package/lib/es/chunks-map.json +0 -1
  30. package/lib/es/components.js +0 -22
  31. package/lib/es/home.js +0 -34
  32. package/lib/es/locales.js +0 -972
  33. package/lib/es/project-html.js +0 -220
  34. package/lib/es/resources.js +0 -168
  35. package/lib/es/setting.js +0 -1728
  36. package/lib/es/site-state.js +0 -47
  37. package/lib/es/theme.js +0 -769
  38. package/lib/es/uploader.js +0 -8
@@ -1,455 +0,0 @@
1
- import { jsx as t, jsxs as f, Fragment as le } from "react/jsx-runtime";
2
- import { u as ce, c as de } from "./state-DGyH1TW3.js";
3
- import { useLocaleContext as U } from "@arcblock/ux/lib/Locale/context";
4
- import Q from "@arcblock/ux/lib/Toast";
5
- import { generateParamCombinations as me } from "@blocklet/pages-kit/utils/route";
6
- import { Warning as ue, Sync as te, VisibilityOff as ne, KeyboardArrowDown as pe, KeyboardArrowRight as he } from "@mui/icons-material";
7
- import { LoadingButton as ie } from "@mui/lab";
8
- import { createSvgIcon as ge, Dialog as fe, DialogTitle as ye, Box as S, IconButton as be, DialogContent as xe, DialogActions as we, Button as ke, Alert as Se, List as De, ListItem as $, ListItemButton as K, ListItemIcon as N, Checkbox as I, ListItemText as F, Tooltip as H, Collapse as Pe, Chip as Ae } from "@mui/material";
9
- import { produce as Oe } from "immer";
10
- import ee from "lodash/difference";
11
- import { useState as T, useMemo as R, useCallback as j, forwardRef as Te, useImperativeHandle as je, useEffect as W, useRef as ve } from "react";
12
- import { useAsync as Re } from "react-use";
13
- import { L as Ee } from "./home-Bnr_eVpB.js";
14
- import { p as ze, g as Be } from "./array-BfSgATE1.js";
15
- function Le(s) {
16
- const [y, w] = T(!1);
17
- return /* @__PURE__ */ t(
18
- ie,
19
- {
20
- ...s,
21
- loading: s.loading || y,
22
- onClick: (l) => {
23
- var b;
24
- const u = (b = s.onClick) == null ? void 0 : b.call(s, l);
25
- u instanceof Promise && (w(!0), u.finally(() => {
26
- w(!1);
27
- }));
28
- }
29
- }
30
- );
31
- }
32
- const Ce = ge(
33
- /* @__PURE__ */ f("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
34
- /* @__PURE__ */ t(
35
- "path",
36
- {
37
- d: "M7.75732 16.2426L16.2426 7.75736",
38
- stroke: "#4B5563",
39
- strokeWidth: "1.5",
40
- strokeLinecap: "round",
41
- strokeLinejoin: "round"
42
- }
43
- ),
44
- /* @__PURE__ */ t(
45
- "path",
46
- {
47
- d: "M16.2426 16.2426L7.75732 7.75735",
48
- stroke: "#4B5563",
49
- strokeWidth: "1.5",
50
- strokeLinecap: "round",
51
- strokeLinejoin: "round"
52
- }
53
- )
54
- ] }),
55
- "Close"
56
- );
57
- function Me() {
58
- const [s, y] = T(), w = R(() => s ? /* @__PURE__ */ t(fe, { ...s }) : null, [s]), l = j(() => {
59
- y(void 0);
60
- }, []), u = j(
61
- ({
62
- title: b,
63
- content: c,
64
- cancelText: D = "Cancel",
65
- okText: h = "Ok",
66
- onOk: g,
67
- onClose: a,
68
- okIcon: E,
69
- okColor: k = "primary",
70
- cancelColor: x = "primary",
71
- DialogContentProps: z,
72
- form: J,
73
- ...V
74
- }) => {
75
- y({
76
- ...V,
77
- open: !0,
78
- children: /* @__PURE__ */ f("form", { onSubmit: (M) => M.preventDefault(), children: [
79
- b && /* @__PURE__ */ f(
80
- ye,
81
- {
82
- className: "between",
83
- zIndex: "appBar",
84
- bgcolor: "background.paper",
85
- sx: { borderBottom: "1px solid #E5E7EB" },
86
- children: [
87
- /* @__PURE__ */ t(S, { children: b }),
88
- /* @__PURE__ */ t(
89
- be,
90
- {
91
- size: "small",
92
- onClick: async () => {
93
- l(), a == null || a();
94
- },
95
- children: /* @__PURE__ */ t(Ce, {})
96
- }
97
- )
98
- ]
99
- }
100
- ),
101
- c && /* @__PURE__ */ t(xe, { ...z, sx: { mt: -3, ...z == null ? void 0 : z.sx }, children: /* @__PURE__ */ t(S, { pt: 3, children: c }) }),
102
- /* @__PURE__ */ f(we, { children: [
103
- /* @__PURE__ */ t(ke, { variant: "outlined", color: x || "primary", onClick: a ?? l, children: D }),
104
- /* @__PURE__ */ t(
105
- Le,
106
- {
107
- variant: "contained",
108
- color: k || "primary",
109
- startIcon: E,
110
- loadingPosition: E ? "start" : "center",
111
- onClick: async () => {
112
- await (g == null ? void 0 : g()), l();
113
- },
114
- type: "submit",
115
- children: h
116
- }
117
- )
118
- ] })
119
- ] }),
120
- onClose: a ?? l
121
- });
122
- },
123
- [l]
124
- );
125
- return { dialog: w, showDialog: u, closeDialog: l };
126
- }
127
- const _e = Te(({ mode: s, state: y }, w) => {
128
- const { t: l } = U(), [u, b] = T(!1), { dialog: c, showDialog: D } = Me(), h = ce(), g = j(
129
- (E) => {
130
- let k = [];
131
- D({
132
- title: l("maker.publishToProduction"),
133
- content: /* @__PURE__ */ f(S, { sx: { minWidth: 300 }, children: [
134
- /* @__PURE__ */ t(Se, { color: "warning", icon: /* @__PURE__ */ t(ue, {}), children: l("maker.publishToProductionTip") }),
135
- /* @__PURE__ */ t(S, { maxHeight: "50vh", overflow: "auto", mt: 2, children: /* @__PURE__ */ t(
136
- $e,
137
- {
138
- state: y,
139
- toMode: s,
140
- onChange: (x) => k = x,
141
- defaultRouteIds: E
142
- }
143
- ) })
144
- ] }),
145
- okText: l("maker.publish"),
146
- cancelText: l("common.cancel"),
147
- onOk: async () => {
148
- if ((k == null ? void 0 : k.length) === 0) {
149
- const x = l("maker.publishSelectPagesMessage");
150
- throw Q.error(x), new Error(x);
151
- }
152
- localStorage.setItem(de(h ?? ""), String((/* @__PURE__ */ new Date()).getTime())), b(!0);
153
- try {
154
- await ze({ mode: s, routes: k }), Q.success(l("maker.publishSuccessMessage"));
155
- } catch (x) {
156
- throw Q.error(x.message), x;
157
- } finally {
158
- b(!1);
159
- }
160
- }
161
- });
162
- },
163
- [s, y, l, h, D]
164
- );
165
- je(w, () => ({
166
- openPublishDialog: g
167
- }));
168
- const a = j(() => {
169
- g();
170
- }, [g]);
171
- return /* @__PURE__ */ f(le, { children: [
172
- /* @__PURE__ */ t(
173
- ie,
174
- {
175
- color: "primary",
176
- variant: "contained",
177
- size: "small",
178
- sx: { mr: 1 },
179
- onClick: a,
180
- loading: u,
181
- disabled: u,
182
- children: l("maker.publishToProduction")
183
- }
184
- ),
185
- c
186
- ] });
187
- });
188
- function We({
189
- routePathInfo: s,
190
- checked: y,
191
- onClick: w,
192
- route: l
193
- }) {
194
- var c, D, h, g, a;
195
- const { t: u } = U(), b = !((c = s.routeMetaData) != null && c.publishedAt) || ((D = s.routeMetaData) == null ? void 0 : D.updatedAt) && new Date((h = s.routeMetaData) == null ? void 0 : h.updatedAt) > new Date((g = s.routeMetaData) == null ? void 0 : g.publishedAt);
196
- return /* @__PURE__ */ t(
197
- $,
198
- {
199
- sx: { pl: 4, pr: 3 },
200
- disablePadding: !0,
201
- secondaryAction: /* @__PURE__ */ f(S, { display: "flex", alignItems: "center", sx: { minWidth: "auto" }, children: [
202
- b && /* @__PURE__ */ t(
203
- S,
204
- {
205
- mr: 0.35,
206
- className: "visible",
207
- color: "warning.main",
208
- sx: { display: "flex", alignItems: "center" },
209
- title: u("maker.pages.needPublish"),
210
- children: /* @__PURE__ */ t(H, { title: u("maker.pages.needPublish"), children: /* @__PURE__ */ t(te, { fontSize: "small", sx: { fontSize: "16px" } }) })
211
- }
212
- ),
213
- (!((a = s.routeMetaData) != null && a.isPublic) || !l.isPublic) && /* @__PURE__ */ t(S, { className: "visible", color: "warning.main", children: /* @__PURE__ */ t(H, { title: u("maker.pages.notPublic"), children: /* @__PURE__ */ t(ne, { fontSize: "small", sx: { fontSize: "16px" } }) }) })
214
- ] }),
215
- children: /* @__PURE__ */ f(K, { onClick: w, dense: !0, children: [
216
- /* @__PURE__ */ t(N, { children: /* @__PURE__ */ t(I, { edge: "start", checked: y, tabIndex: -1 }) }),
217
- /* @__PURE__ */ t(
218
- F,
219
- {
220
- primary: s.path,
221
- primaryTypographyProps: {
222
- fontSize: "0.8rem",
223
- fontStyle: "italic",
224
- overflow: "hidden",
225
- textOverflow: "ellipsis",
226
- whiteSpace: "nowrap",
227
- pr: 1
228
- }
229
- }
230
- )
231
- ] })
232
- }
233
- );
234
- }
235
- function $e({
236
- state: s,
237
- toMode: y,
238
- onChange: w,
239
- defaultRouteIds: l
240
- }) {
241
- const { t: u, locale: b } = U(), [c, D] = T(!1), [h, g] = T(
242
- () => l ? Object.fromEntries(l.filter((e) => !e.includes("-")).map((e) => [e, !0])) : {}
243
- ), [a, E] = T({}), [k, x] = T(
244
- () => l ? Object.fromEntries(l.filter((e) => e.includes("-")).map((e) => [e, !0])) : {}
245
- ), [z, J] = T({}), { loading: V, error: M, value: m } = Re(() => Be({ mode: y }), [y]);
246
- if (M)
247
- throw M;
248
- const P = R(() => s.routeIds || [], [s]), q = R(() => (m == null ? void 0 : m.pageIds) || [], [m]), O = R(() => !P || !s.routes ? [] : JSON.parse(JSON.stringify(P)).sort((r, i) => {
249
- var p, d;
250
- const n = (p = s.routes) == null ? void 0 : p[r], o = (d = s.routes) == null ? void 0 : d[i];
251
- return n != null && n.publishedAt && new Date(n.publishedAt).getTime() < new Date(n.updatedAt).getTime() ? -1 : o != null && o.publishedAt && new Date(o.publishedAt).getTime() < new Date(o.updatedAt).getTime() ? 1 : new Date((n == null ? void 0 : n.updatedAt) ?? "").getTime() - new Date((o == null ? void 0 : o.updatedAt) ?? "").getTime();
252
- }), [s, P]), G = R(() => {
253
- if (!O) return [];
254
- if (!a) return O;
255
- const e = [...O].filter((r) => !a[r]);
256
- return Object.values(a).forEach((r) => {
257
- r.forEach((i) => {
258
- e.push(`${i.originalRouteId}-${i.paramOptionIds.join("-")}`);
259
- });
260
- }), e;
261
- }, [O, a]), v = R(
262
- () => !m || !q || !G ? [] : ee(q, G),
263
- [G, m, q]
264
- ), B = R(
265
- () => P ? [...P].concat(v) : v,
266
- [P, v]
267
- ), X = j(() => {
268
- const e = {};
269
- O == null || O.forEach((r) => {
270
- var n;
271
- const i = (n = s.routes) == null ? void 0 : n[r];
272
- if (i && i.params && i.params.length > 0 && i.paramsOptions && i.paramsOptions.length > 0) {
273
- const o = me({
274
- basePath: i.path,
275
- params: i.params,
276
- routeId: i.id,
277
- paramsOptions: i.paramsOptions,
278
- currentIndex: 0,
279
- currentParams: [],
280
- currentOptionIds: [],
281
- result: []
282
- });
283
- o.length > 0 && (e[i.id] = o);
284
- }
285
- }), E(e);
286
- }, [O, s.routes]);
287
- W(() => {
288
- X();
289
- }, [X]), W(() => {
290
- J((e) => {
291
- const r = { ...e };
292
- return Object.keys(a).forEach((i) => {
293
- var n;
294
- a[i] && ((n = a[i]) == null ? void 0 : n.length) > 0 && r[i] === void 0 && (r[i] = !0);
295
- }), r;
296
- });
297
- }, [a]);
298
- const Y = ve(!0);
299
- W(() => {
300
- x((e) => {
301
- const r = { ...e };
302
- return Object.keys(a).length === 0 || (Object.keys(a).forEach((i) => {
303
- const n = a[i] || [], o = c || !!h[i];
304
- n.forEach((p) => {
305
- const d = `${i}-${p.paramOptionIds.join("-")}`;
306
- Y.current ? r[d] = o || e[d] || !1 : r[d] = o;
307
- });
308
- }), Y.current = !1), r;
309
- });
310
- }, [h, a, c]);
311
- const re = (e, r) => {
312
- r.stopPropagation(), J((i) => {
313
- const n = { ...i };
314
- return n[e] = !n[e], n;
315
- });
316
- }, Z = j(
317
- (e) => {
318
- g((r) => {
319
- const i = Oe(r, (n) => {
320
- c ? (Object.assign(n, Object.fromEntries(B.map((o) => [o, !0]))), delete n[e]) : n[e] ? (delete n[e], v.includes(e) && (P || []).filter((o) => {
321
- var p, d;
322
- return ((p = s.pages[o]) == null ? void 0 : p.slug) === ((d = m == null ? void 0 : m.pages[e]) == null ? void 0 : d.slug);
323
- }).forEach((o) => {
324
- delete n[o];
325
- })) : (n[e] = !0, P && P.includes(e) && v.filter((o) => {
326
- var p, d;
327
- return ((p = m == null ? void 0 : m.pages[o]) == null ? void 0 : p.slug) === ((d = s.pages[e]) == null ? void 0 : d.slug);
328
- }).forEach((o) => {
329
- n[o] = !0;
330
- }));
331
- });
332
- return D(ee(B, Object.keys(i)).length === 0), i;
333
- });
334
- },
335
- [c, B, v, s, m, P]
336
- ), se = j(
337
- (e, r) => {
338
- const i = `${e}-${r.paramOptionIds.join("-")}`;
339
- x((n) => {
340
- var d;
341
- const o = { ...n };
342
- o[i] = !o[i];
343
- const p = ((d = a[e]) == null ? void 0 : d.every((A) => o[`${e}-${A.paramOptionIds.join("-")}`])) ?? !1;
344
- return g((A) => {
345
- if (p && !A[e])
346
- return { ...A, [e]: !0 };
347
- if (!p && A[e]) {
348
- const L = { ...A };
349
- return delete L[e], L;
350
- }
351
- return A;
352
- }), o;
353
- });
354
- },
355
- [a]
356
- ), oe = j(() => {
357
- D((e) => (e && g({}), !e));
358
- }, []);
359
- return W(() => {
360
- const e = c ? B : Object.keys(h), r = Object.entries(k).filter(([, n]) => n).map(([n]) => n).filter((n) => n !== void 0), i = Array.from(/* @__PURE__ */ new Set([...e, ...r]));
361
- w(c ? null : i);
362
- }, [c, h, k, B, w]), V ? /* @__PURE__ */ t(Ee, { sx: { my: 4 } }) : /* @__PURE__ */ f(De, { disablePadding: !0, sx: { maxWidth: 700 }, children: [
363
- /* @__PURE__ */ t($, { sx: { position: "sticky", top: 0, bgcolor: "background.paper", zIndex: 1 }, disablePadding: !0, children: /* @__PURE__ */ f(K, { onClick: oe, dense: !0, children: [
364
- /* @__PURE__ */ t(N, { children: /* @__PURE__ */ t(I, { edge: "start", checked: c, tabIndex: -1 }) }),
365
- /* @__PURE__ */ t(F, { primary: u("common.all") })
366
- ] }) }),
367
- O.map((e) => {
368
- var A, L;
369
- const r = (A = s.routes) == null ? void 0 : A[e];
370
- if (!r) return null;
371
- const i = !1, n = a && a[e] && ((L = a[e]) == null ? void 0 : L.length) > 0, o = z[e] !== !1, p = a[e] || [], d = !r.publishedAt || r.updatedAt && new Date(r.updatedAt).getTime() > new Date(r.publishedAt).getTime();
372
- return /* @__PURE__ */ f(S, { children: [
373
- /* @__PURE__ */ t(
374
- $,
375
- {
376
- sx: {
377
- pr: 4
378
- },
379
- disablePadding: !0,
380
- secondaryAction: /* @__PURE__ */ f(S, { sx: { display: "flex", alignItems: "center" }, children: [
381
- d && /* @__PURE__ */ t(H, { title: u("maker.pages.needPublish"), children: /* @__PURE__ */ t(te, { fontSize: "small", sx: { color: "warning.main", fontSize: 16, mr: 0.35 } }) }),
382
- !r.isPublic && /* @__PURE__ */ t(H, { title: u("maker.pages.notPublic"), children: /* @__PURE__ */ t(ne, { fontSize: "small", sx: { color: "warning.main", fontSize: 16, mr: 0.35 } }) }),
383
- i,
384
- n && /* @__PURE__ */ t(
385
- S,
386
- {
387
- onClick: (C) => re(e, C),
388
- sx: {
389
- display: "inline-flex",
390
- alignItems: "center",
391
- mr: 0.35,
392
- cursor: "pointer",
393
- color: "info.main"
394
- },
395
- children: o ? /* @__PURE__ */ t(pe, { fontSize: "small", sx: { fontSize: "18px" } }) : /* @__PURE__ */ t(he, { fontSize: "small", sx: { fontSize: "18px" } })
396
- }
397
- )
398
- ] }),
399
- children: /* @__PURE__ */ f(K, { onClick: () => Z(e), dense: !0, children: [
400
- /* @__PURE__ */ t(N, { children: /* @__PURE__ */ t(I, { edge: "start", checked: c || !!h[e], tabIndex: -1 }) }),
401
- /* @__PURE__ */ t(
402
- F,
403
- {
404
- primary: r.path,
405
- primaryTypographyProps: { noWrap: !0, textOverflow: "ellipsis" },
406
- secondaryTypographyProps: { noWrap: !0, textOverflow: "ellipsis" }
407
- }
408
- )
409
- ] })
410
- }
411
- ),
412
- n && /* @__PURE__ */ t(Pe, { in: o, children: /* @__PURE__ */ t(S, { children: p.map((C) => {
413
- const _ = `${e}-${C.paramOptionIds.join("-")}`, ae = k[_] || !1;
414
- return /* @__PURE__ */ t(
415
- We,
416
- {
417
- routePathInfo: C,
418
- checked: c || ae,
419
- onClick: () => se(e, C),
420
- route: r
421
- },
422
- _
423
- );
424
- }) }) })
425
- ] }, e);
426
- }),
427
- v.map((e) => {
428
- var i, n;
429
- const r = m == null ? void 0 : m.pages[e];
430
- return r ? /* @__PURE__ */ t(
431
- $,
432
- {
433
- disablePadding: !0,
434
- secondaryAction: /* @__PURE__ */ t(Ae, { color: "warning", label: "deleted", size: "small" }),
435
- children: /* @__PURE__ */ f(K, { onClick: () => Z(e), dense: !0, children: [
436
- /* @__PURE__ */ t(N, { children: /* @__PURE__ */ t(I, { edge: "start", checked: c || !!h[e], tabIndex: -1 }) }),
437
- /* @__PURE__ */ t(
438
- F,
439
- {
440
- primary: r.slug,
441
- secondary: (n = (i = r.locales) == null ? void 0 : i[b]) == null ? void 0 : n.title,
442
- primaryTypographyProps: { noWrap: !0, textOverflow: "ellipsis" },
443
- secondaryTypographyProps: { noWrap: !0, textOverflow: "ellipsis" }
444
- }
445
- )
446
- ] })
447
- },
448
- e
449
- ) : null;
450
- })
451
- ] });
452
- }
453
- export {
454
- _e as default
455
- };