@blocklet/pages-kit-inner-components 0.4.106 → 0.4.107

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.
@@ -0,0 +1,475 @@
1
+ import { jsx as o, jsxs as M } from "react/jsx-runtime";
2
+ import { g as D, a as re, b as se, u as ie, c as ce } from "./state-DsXKwImw.js";
3
+ import { cloneDeep as P } from "lodash";
4
+ import { useLocaleContext as q } from "@arcblock/ux/lib/Locale/context";
5
+ import J from "@arcblock/ux/lib/Result";
6
+ import { useHeaderState as ae } from "@blocklet/pages-kit/builtin/page/header";
7
+ import { useColorConvert as le } from "@blocklet/pages-kit/contexts/color";
8
+ import ue from "@blocklet/ui-react/lib/Header";
9
+ import { cx as Q } from "@emotion/css";
10
+ import { Global as X, css as Y } from "@emotion/react";
11
+ import Z from "@emotion/styled";
12
+ import { Box as C, CircularProgress as me, useTheme as fe, Button as pe, Stack as de, useMediaQuery as ge } from "@mui/material";
13
+ import { useReactive as he } from "ahooks";
14
+ import be from "isomorphic-dompurify";
15
+ import G from "lodash/cloneDeep";
16
+ import ve from "lodash/isEmpty";
17
+ import ye from "lodash/isEqual";
18
+ import { useEffect as T, useContext as we, lazy as K, useMemo as w, useRef as Se, Suspense as ke, useState as xe } from "react";
19
+ import { Helmet as Pe } from "react-helmet";
20
+ import { useSearchParams as Ce, Routes as je, Route as E, Navigate as Ee, ScrollRestoration as Re } from "react-router-dom";
21
+ import { useWindowScroll as Me, useAsync as F } from "react-use";
22
+ import { joinURL as R } from "ufo";
23
+ import { S as $e, n as Ie, P as Te, a as Oe, B as Ne, g as _e } from "./array-C85JziT_.js";
24
+ import { styled as ee, useTheme as Be } from "@arcblock/ux/lib/Theme";
25
+ import Ae from "@blocklet/ui-react/lib/Footer";
26
+ import He from "webfontloader";
27
+ import { createAuthServiceSessionContext as Le } from "@arcblock/did-connect/lib/Session";
28
+ function Ue(e, r, t, s) {
29
+ e.locales || (e.locales = {}), e.locales[t] = P(e.locales[t] || {}), e.locales[t].title = s.title ?? e.locales[t].title, e.locales[t].image = s.image ?? e.locales[t].image, e.locales[t].description = s.description ?? e.locales[t].description, Object.entries(s.sectionsData).forEach(([c, n]) => {
30
+ var a, p, b, m;
31
+ const i = Object.values(e.sections).find(
32
+ (l) => l.id === c || l.name === c
33
+ );
34
+ if (i && i.isTemplateSection)
35
+ if (i.locales = P(i.locales || {}), i.locales[t] = P(i.locales[t] || {}), i.component === "custom-component") {
36
+ const l = (a = i.config) == null ? void 0 : a.componentId;
37
+ if (!l)
38
+ return;
39
+ const d = ((p = r.components[l]) == null ? void 0 : p.data) || ((m = (b = r.resources.components) == null ? void 0 : b[l]) == null ? void 0 : m.component);
40
+ if (!d)
41
+ return;
42
+ i.locales[t].properties = P(i.locales[t].properties || {}), Object.entries(n || {}).forEach(([g, u]) => {
43
+ var h, S;
44
+ const f = ((h = d == null ? void 0 : d.properties) == null ? void 0 : h[g]) || Object.values((d == null ? void 0 : d.properties) || {}).find((j) => {
45
+ var k;
46
+ return ((k = j.data) == null ? void 0 : k.key) === g;
47
+ });
48
+ f && (i.locales[t].properties[(S = f.data) == null ? void 0 : S.id] = {
49
+ value: u
50
+ });
51
+ });
52
+ } else
53
+ i.locales[t] = {
54
+ ...P(i.locales[t]),
55
+ ...n || {}
56
+ };
57
+ });
58
+ }
59
+ const ze = ee(Ae, { shouldForwardProp: (e) => !!e })`
60
+ & > div > .MuiContainer-root {
61
+ max-width: unset;
62
+ }
63
+ `;
64
+ function Ve({ meta: e, ...r }) {
65
+ const t = Be();
66
+ return /* @__PURE__ */ o(ze, { ...r, meta: e, theme: t || {} });
67
+ }
68
+ function Ge(e) {
69
+ return /* @__PURE__ */ o(C, { display: "flex", flex: 1, height: "100%", alignItems: "center", justifyContent: "center", ...e, children: /* @__PURE__ */ o(me, { size: 30 }) });
70
+ }
71
+ function We(e) {
72
+ return /* @__PURE__ */ o(De, { ...e });
73
+ }
74
+ const De = ee(C)`
75
+ position: fixed;
76
+ left: 0;
77
+ top: 0;
78
+ z-index: 999999999999;
79
+ width: 80px;
80
+ font-size: 12px;
81
+ text-align: center;
82
+ opacity: 0.7;
83
+ transform: translateX(-23%) translateY(70%) rotate(-45deg);
84
+ pointer-events: none;
85
+ `, qe = (e) => new Promise((r, t) => {
86
+ (e == null ? void 0 : e.length) > 0 ? He.load({
87
+ google: {
88
+ families: e
89
+ },
90
+ fontactive: () => {
91
+ r("success");
92
+ },
93
+ fontinactive: () => {
94
+ t(new Error("load font fail"));
95
+ }
96
+ }) : r("success");
97
+ }), $ = `Avenir, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
98
+ sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'`, W = {};
99
+ function Je({
100
+ titleFontFamily: e,
101
+ descriptionFontFamily: r
102
+ }) {
103
+ var n;
104
+ const t = fe(), s = (n = t == null ? void 0 : t.typography) == null ? void 0 : n.fontFamily, c = async (i) => {
105
+ if (i && !document.querySelectorAll(`link[href*="${i}" i]`).length)
106
+ try {
107
+ W[i] || (await qe([i]), W[i] = !0);
108
+ } catch (a) {
109
+ console.error(a);
110
+ }
111
+ };
112
+ return T(() => {
113
+ e && c(e), r && c(r);
114
+ }, [e, r]), /* @__PURE__ */ o(
115
+ X,
116
+ {
117
+ styles: Y`
118
+ #app {
119
+ font-family: ${JSON.stringify(s)}, ${$};
120
+
121
+ .page-kit-section__title {
122
+ font-family: ${JSON.stringify(e ?? s)}, ${$};
123
+ }
124
+
125
+ .page-kit-section__description {
126
+ font-family: ${JSON.stringify(r ?? s)}, ${$};
127
+ }
128
+ }
129
+ `
130
+ }
131
+ );
132
+ }
133
+ const { SessionProvider: $t, SessionContext: Qe, SessionConsumer: It, withSession: Tt } = Le();
134
+ function N() {
135
+ return we(Qe);
136
+ }
137
+ function Xe(...e) {
138
+ var t;
139
+ const { session: r } = N();
140
+ return e.includes((t = r.user) == null ? void 0 : t.role);
141
+ }
142
+ function Ye(...e) {
143
+ var s;
144
+ const { session: r } = N(), t = Xe(...e);
145
+ return ((s = window.blocklet) == null ? void 0 : s.tenantMode) === "multiple" ? !!r.user : t;
146
+ }
147
+ function Ot() {
148
+ const [e] = Ce(), { session: r } = N(), t = Ye("owner", "admin", "pagesEditor", "member"), s = w(() => {
149
+ const n = e.get("mode");
150
+ return $e.includes(n) ? n : "production";
151
+ }, [e]), c = s === "production" ? s : r.user ? t ? s : "production" : null;
152
+ return c ? /* @__PURE__ */ o(Ze, { mode: c }) : null;
153
+ }
154
+ function Ze({ mode: e }) {
155
+ if (e !== "draft") {
156
+ const r = window.__PAGE_STATE__;
157
+ return r ? /* @__PURE__ */ o(I, { mode: e, state: r }) : /* @__PURE__ */ o(Fe, { mode: e, children: ({ state: t }) => /* @__PURE__ */ o(I, { mode: e, state: t }) });
158
+ }
159
+ return /* @__PURE__ */ o(Ke, { children: ({ state: r }) => /* @__PURE__ */ o(I, { mode: e, state: r }) });
160
+ }
161
+ const Ke = K(() => import("./draft-data-0n1CKRWr.js"));
162
+ function Fe({
163
+ mode: e,
164
+ children: r
165
+ }) {
166
+ const t = document.querySelector('meta[property="pages:version"]'), s = t == null ? void 0 : t.content, c = ie(), n = w(() => {
167
+ if (s === "{{pagesPublishedAt}}") {
168
+ const p = localStorage.getItem(ce(c ?? ""));
169
+ return Number(p) ? Number(p) : (/* @__PURE__ */ new Date()).getTime();
170
+ }
171
+ return Number(s);
172
+ }, [s]), { loading: i, value: a } = F(() => _e({ mode: e, version: n }), [e, n]);
173
+ return i ? /* @__PURE__ */ o(Ge, {}) : a ? r({ state: a }) : null;
174
+ }
175
+ function I({ mode: e, state: r }) {
176
+ const { t, locale: s } = q(), {
177
+ pageIds: c,
178
+ pages: n,
179
+ supportedLocales: i,
180
+ config: { defaultLocale: a },
181
+ resources: p
182
+ } = r, b = D(r), m = w(
183
+ () => i != null && i.some((u) => u.locale === s) ? s : void 0,
184
+ [s, i]
185
+ ), l = Object.values(n).find((u) => (u == null ? void 0 : u.slug) === "/") ? void 0 : Object.values(n)[0], d = w(
186
+ () => c.map((u) => {
187
+ const f = n[u];
188
+ return f && {
189
+ id: f.id,
190
+ path: R("/", m || "", f.slug, e !== "production" ? `?mode=${e}` : "")
191
+ };
192
+ }).filter(Ie),
193
+ [c, n, m, e]
194
+ ), g = ([...u]) => (e !== "production" && u.unshift(
195
+ /* @__PURE__ */ o(ke, { fallback: /* @__PURE__ */ o("div", {}), children: /* @__PURE__ */ o(et, { mode: "production", state: r }) })
196
+ ), u);
197
+ return /* @__PURE__ */ M(Te, { value: { pages: d }, children: [
198
+ /* @__PURE__ */ M(je, { children: [
199
+ l && /* @__PURE__ */ o(E, { index: !0, element: /* @__PURE__ */ o(Ee, { to: R("/", m || "", l.slug) }) }),
200
+ c.map((u) => {
201
+ const f = n[u];
202
+ return f ? /* @__PURE__ */ o(
203
+ E,
204
+ {
205
+ path: R(":projectIdOrSlug?", f.slug),
206
+ element: /* @__PURE__ */ o(
207
+ O,
208
+ {
209
+ mode: e,
210
+ components: b,
211
+ page: f,
212
+ locale: m,
213
+ defaultLocale: a,
214
+ headerAddons: g
215
+ }
216
+ )
217
+ },
218
+ f.id
219
+ ) : null;
220
+ }),
221
+ p.pages && Object.values(p.pages).map(({ blockletId: u, page: f }) => /* @__PURE__ */ o(
222
+ E,
223
+ {
224
+ path: R("/", `@${u}`, f.slug),
225
+ element: /* @__PURE__ */ o(
226
+ O,
227
+ {
228
+ mode: e,
229
+ components: b,
230
+ page: f,
231
+ locale: m,
232
+ defaultLocale: a,
233
+ headerAddons: g
234
+ }
235
+ )
236
+ },
237
+ f.id
238
+ )),
239
+ /* @__PURE__ */ o(
240
+ E,
241
+ {
242
+ path: "*",
243
+ element: /* @__PURE__ */ o(C, { width: "100vw", height: "100vh", display: "flex", justifyContent: "center", alignItems: "center", children: /* @__PURE__ */ o(J, { status: 404, extra: /* @__PURE__ */ o(oe, { href: "/", children: t("common.back") }) }) })
244
+ }
245
+ )
246
+ ] }),
247
+ e !== "production" && /* @__PURE__ */ o(We, { sx: { bgcolor: "info.light" }, children: e }),
248
+ /* @__PURE__ */ o(Je, {})
249
+ ] });
250
+ }
251
+ function Nt({
252
+ mode: e,
253
+ state: r,
254
+ path: t,
255
+ pageData: s
256
+ }) {
257
+ const { t: c, locale: n } = q(), {
258
+ pages: i,
259
+ supportedLocales: a,
260
+ config: { defaultLocale: p },
261
+ resources: b
262
+ } = r, m = Object.values(i).find((h) => (h == null ? void 0 : h.slug) === t), l = Object.values(b.pages || {}).find((h) => h.page.slug === t), d = w(
263
+ () => a != null && a.some((h) => h.locale === n) ? n : void 0,
264
+ [n, a]
265
+ ), g = he({
266
+ page: null
267
+ });
268
+ T(() => {
269
+ const h = m || (l == null ? void 0 : l.page) || null;
270
+ h ? g.page = G(h) : g.page = null;
271
+ }, [m, l]);
272
+ const u = Se();
273
+ if (T(() => {
274
+ ye(s, u.current) || s && g.page && (Ue(g.page, r, d, s), u.current = G(s));
275
+ }, [{}]), !m && !(l != null && l.page))
276
+ return /* @__PURE__ */ o(C, { width: "100vw", height: "100vh", display: "flex", justifyContent: "center", alignItems: "center", children: /* @__PURE__ */ o(J, { style: { background: "inherit" }, status: 404, extra: /* @__PURE__ */ o(oe, { href: "/", children: c("common.back") }) }) });
277
+ const f = D(r);
278
+ return g.page ? /* @__PURE__ */ o(
279
+ O,
280
+ {
281
+ mode: e,
282
+ components: f,
283
+ page: g.page,
284
+ locale: d,
285
+ defaultLocale: p
286
+ }
287
+ ) : null;
288
+ }
289
+ function O({
290
+ mode: e,
291
+ components: r,
292
+ page: t,
293
+ locale: s,
294
+ defaultLocale: c,
295
+ headerAddons: n
296
+ }) {
297
+ var S, j, k, _, B, A, H, L, U;
298
+ const i = le(), a = ((S = t.locales) == null ? void 0 : S[s]) ?? ((j = t.locales) == null ? void 0 : j[c]) ?? {}, p = a.title || ((k = window.blocklet) == null ? void 0 : k.appName), b = a.description || ((_ = window.blocklet) == null ? void 0 : _.appDescription), m = re(se(a.image), 540), { logo: l, brand: d, description: g, ...u } = ae(), f = w(
299
+ () => (y) => {
300
+ var x;
301
+ let v = (n == null ? void 0 : n(y)) ?? y;
302
+ return v = ((x = u.addons) == null ? void 0 : x.call(u, v)) ?? v, v;
303
+ },
304
+ [u.addons, n]
305
+ ), h = (B = a.header) != null && B.translucent ? ot : te;
306
+ return /* @__PURE__ */ M(Oe, { page: t, defaultLocale: c, currentLocale: s, children: [
307
+ !!a.backgroundColor && /* @__PURE__ */ o(
308
+ X,
309
+ {
310
+ styles: Y`
311
+ body {
312
+ background-color: ${i(a.backgroundColor)} !important;
313
+ }
314
+ `
315
+ }
316
+ ),
317
+ /* @__PURE__ */ o(
318
+ h,
319
+ {
320
+ hideNavMenu: !!((A = a.header) != null && A.hideNavMenus),
321
+ translucentTextColor: (H = a.header) == null ? void 0 : H.translucentTextColor,
322
+ ...l ? { logo: l } : {},
323
+ ...d ? { brand: d } : {},
324
+ ...g ? { description: g } : {},
325
+ className: Q(((L = a.header) == null ? void 0 : L.sticky) && "sticky", "page-header"),
326
+ maxWidth: !1,
327
+ addons: f
328
+ }
329
+ ),
330
+ /* @__PURE__ */ o(Re, {}),
331
+ /* @__PURE__ */ M(Pe, { children: [
332
+ /* @__PURE__ */ o("title", { children: p }),
333
+ /* @__PURE__ */ o("meta", { name: "og:title", content: p }),
334
+ /* @__PURE__ */ o("meta", { name: "og:description", content: b }),
335
+ /* @__PURE__ */ o("meta", { name: "og:image", content: m }),
336
+ /* @__PURE__ */ o("meta", { name: "twitter:image:src", content: m }),
337
+ /* @__PURE__ */ o("meta", { name: "twitter:image", content: m }),
338
+ /* @__PURE__ */ o("meta", { property: "twitter:description", content: b }),
339
+ /* @__PURE__ */ o("meta", { property: "twitter:title", content: p }),
340
+ /* @__PURE__ */ o("meta", { name: "description", content: b })
341
+ ] }),
342
+ /* @__PURE__ */ o(
343
+ de,
344
+ {
345
+ flexGrow: 1,
346
+ className: "PageView-root",
347
+ sx: {
348
+ // 第一个 .BlockBase-root 的 pt 为 0
349
+ "& .BlockBase-root:first-child": {
350
+ pt: "0 !important"
351
+ }
352
+ },
353
+ children: t.sectionIds.map((y) => {
354
+ var z, V;
355
+ const v = t.sections[y];
356
+ if (!v || v.visibility === "hidden") return null;
357
+ const x = (z = v.locales) == null ? void 0 : z[s], ne = ((V = v.locales) == null ? void 0 : V[c]) ?? {};
358
+ return /* @__PURE__ */ o(
359
+ Ne,
360
+ {
361
+ id: y,
362
+ type: v.component,
363
+ mode: e,
364
+ section: v,
365
+ config: {
366
+ ...ve(x) ? ne : x,
367
+ locale: s,
368
+ dev: e === "draft" ? {
369
+ mode: e,
370
+ components: r,
371
+ defaultLocale: c
372
+ } : { mode: e }
373
+ }
374
+ },
375
+ y
376
+ );
377
+ })
378
+ }
379
+ ),
380
+ !((U = a.footer) != null && U.hidden) && /* @__PURE__ */ o(Ve, {})
381
+ ] });
382
+ }
383
+ const et = K(() => import("./publish-button-BJk6jKq-.js")), te = Z(ue)`
384
+ &.sticky {
385
+ position: sticky;
386
+ top: 0;
387
+ }
388
+ `;
389
+ function tt({ logo: e }) {
390
+ const [r, t] = xe(), s = ge((n) => n.breakpoints.down("sm")), { value: c } = F(() => {
391
+ var a, p;
392
+ const n = new URL(
393
+ s ? ((a = window == null ? void 0 : window.blocklet) == null ? void 0 : a.appLogo) || "/.well-known/service/blocklet/logo" : ((p = window == null ? void 0 : window.blocklet) == null ? void 0 : p.appLogoRect) || "/.well-known/service/blocklet/logo-rect",
394
+ window.location.origin
395
+ );
396
+ n.searchParams.delete("imageFilter"), n.searchParams.delete("f");
397
+ const i = n.toString();
398
+ return new Promise((b) => {
399
+ fetch(i).then((m) => {
400
+ const l = m.headers.get("content-type");
401
+ l != null && l.includes("svg") && m.text().then((d) => {
402
+ t(d), b(null);
403
+ }), b(m.url);
404
+ });
405
+ });
406
+ }, [s]);
407
+ if (e)
408
+ return e;
409
+ if (r)
410
+ return /* @__PURE__ */ o(C, { sx: { filter: "initial !important" }, dangerouslySetInnerHTML: { __html: be.sanitize(r) } });
411
+ if (c) {
412
+ const n = new URL(c);
413
+ n.searchParams.set("imageFilter", "convert"), n.searchParams.set("f", "png"), n.searchParams.set("h", "80");
414
+ const i = n.toString();
415
+ return /* @__PURE__ */ o("img", { src: i, alt: "logo" });
416
+ }
417
+ return null;
418
+ }
419
+ function ot({
420
+ logo: e,
421
+ translucentTextColor: r,
422
+ ...t
423
+ }) {
424
+ const { y: s } = Me();
425
+ let c = Math.min(s / 800, 1), n = "";
426
+ if (c > 0.1) {
427
+ c = Math.max(c, 0.6);
428
+ const i = Math.round(255 * Math.min(1 - c, 0.2));
429
+ n = `rgb(${i}, ${i}, ${i})`;
430
+ } else
431
+ n = r || "#EEEEEE";
432
+ return /* @__PURE__ */ o(
433
+ te,
434
+ {
435
+ logo: /* @__PURE__ */ o(tt, { logo: e }),
436
+ ...t,
437
+ className: Q(c <= 0.7 && "reverse-color"),
438
+ style: {
439
+ backgroundColor: `rgba(255,255,255,${c})`,
440
+ // @ts-ignore
441
+ "--logo-invert": c <= 0.7 ? 1 - c / 6 : 1 - c
442
+ },
443
+ sx: {
444
+ backdropFilter: c >= 0.6 ? "blur(10px)" : "blur(0px)",
445
+ transition: "all 0.3s ease",
446
+ position: "fixed !important",
447
+ left: 0,
448
+ top: 0,
449
+ right: 0,
450
+ bgcolor: "transparent",
451
+ "&.reverse-color": {
452
+ ".navmenu-root>.navmenu-sub>span,\n .navmenu-root>.navmenu-item,\n .header-addons>button,\n .header-addons>a,\n .header-addons>div>button": {
453
+ color: `${n} !important`
454
+ }
455
+ },
456
+ ".header-logo > div": {
457
+ filter: "invert(var(--logo-invert))"
458
+ },
459
+ ".header-logo": {
460
+ color: n
461
+ }
462
+ }
463
+ }
464
+ );
465
+ }
466
+ const oe = Z(pe)``;
467
+ export {
468
+ Ot as H,
469
+ Ge as L,
470
+ I as P,
471
+ ot as T,
472
+ Ze as a,
473
+ Nt as b,
474
+ O as c
475
+ };
@@ -9,7 +9,7 @@ import { produce as oe } from "immer";
9
9
  import N from "lodash/difference";
10
10
  import { useState as D, useMemo as j, useCallback as L, forwardRef as se, useImperativeHandle as le, useEffect as ce } from "react";
11
11
  import { useAsync as ae } from "react-use";
12
- import { L as de } from "./home-BkhNJi9S.js";
12
+ import { L as de } from "./home-Dlf4i27b.js";
13
13
  import { p as ue, g as me } from "./array-C85JziT_.js";
14
14
  function ge(r) {
15
15
  const [a, y] = D(!1);
package/lib/es/home.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import "react/jsx-runtime";
2
2
  import "./chunks/state-DsXKwImw.js";
3
- import { a as y, P as B, c as R, b as j, T as k, H as q } from "./chunks/home-BkhNJi9S.js";
3
+ import { a as y, P as B, c as R, b as j, T as k, H as q } from "./chunks/home-Dlf4i27b.js";
4
4
  import "@arcblock/ux/lib/Locale/context";
5
5
  import "@arcblock/ux/lib/Result";
6
6
  import "@blocklet/pages-kit/builtin/page/header";
package/lib/es/locales.js CHANGED
@@ -267,7 +267,7 @@ const t = e({
267
267
  invalidJson: "Invalid JSON format"
268
268
  },
269
269
  fabric: {
270
- fontFamily: "Font Family",
270
+ fontFamily: "Font Family (Deprecated)",
271
271
  basicComponent: {
272
272
  titleFontFamily: "Title Font Family",
273
273
  titleFontFamilyHelper: "* Globally modify the paragraph heading font",
@@ -370,6 +370,8 @@ const t = e({
370
370
  saved: "Saved",
371
371
  supportMarkdownSyntaxPlaceholder: "support markdown syntax",
372
372
  settings: {
373
+ appearanceTip: "Appearance settings have been migrated to the Blocklet management page, users with admin access can click the link below to configure",
374
+ appearanceLink: "Go to Appearance Settings >",
373
375
  tabs: {
374
376
  basic: "Basic",
375
377
  appearance: "Appearance",
@@ -686,7 +688,7 @@ const t = e({
686
688
  invalidJson: "JSON格式无效"
687
689
  },
688
690
  fabric: {
689
- fontFamily: "全局字体",
691
+ fontFamily: "全局字体(已废弃)",
690
692
  basicComponent: {
691
693
  titleFontFamily: "段落标题字体",
692
694
  titleFontFamilyHelper: "* 全局修改段落标题字体",
@@ -789,6 +791,8 @@ const t = e({
789
791
  saved: "保存成功",
790
792
  supportMarkdownSyntaxPlaceholder: "支持输入 markdown",
791
793
  settings: {
794
+ appearanceTip: "外观设置已迁移至 Blocklet 管理页面,持有管理员通行证的用户,可点击下方链接配置",
795
+ appearanceLink: "前往外观设置 >",
792
796
  tabs: {
793
797
  basic: "基础设置",
794
798
  appearance: "外观设置",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/pages-kit-inner-components",
3
- "version": "0.4.106",
3
+ "version": "0.4.107",
4
4
  "description": "Pages Kit inner components library",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -205,8 +205,8 @@
205
205
  "yaml": "^2.5.0",
206
206
  "yjs": "^13.6.18",
207
207
  "zustand": "^4.5.5",
208
- "@blocklet/pages-kit": "^0.4.106",
209
- "@blocklet/pages-kit-block-studio": "^0.4.106"
208
+ "@blocklet/pages-kit": "^0.4.107",
209
+ "@blocklet/pages-kit-block-studio": "^0.4.107"
210
210
  },
211
211
  "devDependencies": {
212
212
  "@trivago/prettier-plugin-sort-imports": "^5.2.1",
@@ -1,36 +0,0 @@
1
- "use strict";const t=require("react/jsx-runtime"),q=require("./state-BoXTl4DM.js"),M=require("lodash"),Q=require("@arcblock/ux/lib/Locale/context"),re=require("@arcblock/ux/lib/Result"),ie=require("@blocklet/pages-kit/builtin/page/header"),ce=require("@blocklet/pages-kit/contexts/color"),le=require("@blocklet/ui-react/lib/Header"),X=require("@emotion/css"),B=require("@emotion/react"),ae=require("@emotion/styled"),w=require("@mui/material"),ue=require("ahooks"),de=require("isomorphic-dompurify"),fe=require("lodash/cloneDeep"),me=require("lodash/isEmpty"),ge=require("lodash/isEqual"),h=require("react"),pe=require("react-helmet"),P=require("react-router-dom"),O=require("react-use"),E=require("ufo"),R=require("./array-BMkoDb_A.js"),H=require("@arcblock/ux/lib/Theme"),xe=require("@blocklet/ui-react/lib/Footer"),he=require("webfontloader"),je=require("@arcblock/did-connect/lib/Session"),S=e=>e&&e.__esModule?e:{default:e},Y=S(re),be=S(le),Z=S(ae),ve=S(de),W=S(fe),ye=S(me),we=S(ge),Se=S(xe),ke=S(he);function Pe(e,n,o,s){e.locales||(e.locales={}),e.locales[o]=M.cloneDeep(e.locales[o]||{}),e.locales[o].title=s.title??e.locales[o].title,e.locales[o].image=s.image??e.locales[o].image,e.locales[o].description=s.description??e.locales[o].description,Object.entries(s.sectionsData).forEach(([i,r])=>{var l,g,j,u;const c=Object.values(e.sections).find(a=>a.id===i||a.name===i);if(c&&c.isTemplateSection)if(c.locales=M.cloneDeep(c.locales||{}),c.locales[o]=M.cloneDeep(c.locales[o]||{}),c.component==="custom-component"){const a=(l=c.config)==null?void 0:l.componentId;if(!a)return;const p=((g=n.components[a])==null?void 0:g.data)||((u=(j=n.resources.components)==null?void 0:j[a])==null?void 0:u.component);if(!p)return;c.locales[o].properties=M.cloneDeep(c.locales[o].properties||{}),Object.entries(r||{}).forEach(([x,b])=>{var f,k;const y=((f=p==null?void 0:p.properties)==null?void 0:f[x])||Object.values((p==null?void 0:p.properties)||{}).find(d=>{var m;return((m=d.data)==null?void 0:m.key)===x});y&&(c.locales[o].properties[(k=y.data)==null?void 0:k.id]={value:b})})}else c.locales[o]={...M.cloneDeep(c.locales[o]),...r||{}}})}const _e=H.styled(Se.default,{shouldForwardProp:e=>!!e})`
2
- & > div > .MuiContainer-root {
3
- max-width: unset;
4
- }
5
- `;function qe({meta:e,...n}){const o=H.useTheme();return t.jsx(_e,{...n,meta:e,theme:o||{}})}function K(e){return t.jsx(w.Box,{display:"flex",flex:1,height:"100%",alignItems:"center",justifyContent:"center",...e,children:t.jsx(w.CircularProgress,{size:30})})}function Re(e){return t.jsx(Ce,{...e})}const Ce=H.styled(w.Box)`
6
- position: fixed;
7
- left: 0;
8
- top: 0;
9
- z-index: 999999999999;
10
- width: 80px;
11
- font-size: 12px;
12
- text-align: center;
13
- opacity: 0.7;
14
- transform: translateX(-23%) translateY(70%) rotate(-45deg);
15
- pointer-events: none;
16
- `,Me=e=>new Promise((n,o)=>{(e==null?void 0:e.length)>0?ke.default.load({google:{families:e},fontactive:()=>{n("success")},fontinactive:()=>{o(new Error("load font fail"))}}):n("success")}),F=`Avenir, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
17
- sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'`,J={};function Ee({titleFontFamily:e,descriptionFontFamily:n}){const o=async s=>{if(s&&!document.querySelectorAll(`link[href*="${s}" i]`).length)try{J[s]||(await Me([s]),J[s]=!0)}catch(i){console.error(i)}};return h.useEffect(()=>{e&&o(e),n&&o(n)},[e,n]),t.jsx(B.Global,{styles:B.css`
18
- #app {
19
- .page-kit-section__title {
20
- font-family: ${JSON.stringify(e)}, ${F};
21
- }
22
-
23
- .page-kit-section__description {
24
- font-family: ${JSON.stringify(n)}, ${F};
25
- }
26
- }
27
- `})}const{SessionProvider:De,SessionContext:Ie,SessionConsumer:Ve,withSession:$e}=je.createAuthServiceSessionContext();function N(){return h.useContext(Ie)}function Be(...e){var o;const{session:n}=N();return e.includes((o=n.user)==null?void 0:o.role)}function Te(...e){var s;const{session:n}=N(),o=Be(...e);return((s=window.blocklet)==null?void 0:s.tenantMode)==="multiple"?!!n.user:o}function Oe(){const[e]=P.useSearchParams(),{session:n}=N(),o=Te("owner","admin","pagesEditor","member"),s=h.useMemo(()=>{const r=e.get("mode");return R.STATE_MODES.includes(r)?r:"production"},[e]),i=s==="production"?s:n.user?o?s:"production":null;return i?t.jsx(ee,{mode:i}):null}function ee({mode:e}){if(e!=="draft"){const n=window.__PAGE_STATE__;return n?t.jsx(I,{mode:e,state:n}):t.jsx(Ne,{mode:e,children:({state:o})=>t.jsx(I,{mode:e,state:o})})}return t.jsx(He,{children:({state:n})=>t.jsx(I,{mode:e,state:n})})}const He=h.lazy(()=>Promise.resolve().then(()=>require("./draft-data-UP_7unuZ.js")));function Ne({mode:e,children:n}){const o=document.querySelector('meta[property="pages:version"]'),s=o==null?void 0:o.content,i=q.useProjectId(),r=h.useMemo(()=>{if(s==="{{pagesPublishedAt}}"){const g=localStorage.getItem(q.getProjectPageVersionKey(i??""));return Number(g)?Number(g):new Date().getTime()}return Number(s)},[s]),{loading:c,value:l}=O.useAsync(()=>R.getPages({mode:e,version:r}),[e,r]);return c?t.jsx(K,{}):l?n({state:l}):null}function I({mode:e,state:n}){var b,y,f,k;const{t:o,locale:s}=Q.useLocaleContext(),{pageIds:i,pages:r,supportedLocales:c,config:{defaultLocale:l},resources:g}=n,j=q.getAllComponents(n),u=h.useMemo(()=>c!=null&&c.some(d=>d.locale===s)?s:void 0,[s,c]),a=Object.values(r).find(d=>(d==null?void 0:d.slug)==="/")?void 0:Object.values(r)[0],p=h.useMemo(()=>i.map(d=>{const m=r[d];return m&&{id:m.id,path:E.joinURL("/",u||"",m.slug,e!=="production"?`?mode=${e}`:"")}}).filter(R.nonNullable),[i,r,u,e]),x=([...d])=>(e!=="production"&&d.unshift(t.jsx(h.Suspense,{fallback:t.jsx("div",{}),children:t.jsx(Le,{mode:"production",state:n})})),d);return t.jsxs(R.Provider,{value:{pages:p},children:[t.jsxs(P.Routes,{children:[a&&t.jsx(P.Route,{index:!0,element:t.jsx(P.Navigate,{to:E.joinURL("/",u||"",a.slug)})}),i.map(d=>{const m=r[d];return m?t.jsx(P.Route,{path:E.joinURL(":projectIdOrSlug?",m.slug),element:t.jsx(T,{mode:e,components:j,page:m,locale:u,defaultLocale:l,headerAddons:x})},m.id):null}),g.pages&&Object.values(g.pages).map(({blockletId:d,page:m})=>t.jsx(P.Route,{path:E.joinURL("/",`@${d}`,m.slug),element:t.jsx(T,{mode:e,components:j,page:m,locale:u,defaultLocale:l,headerAddons:x})},m.id)),t.jsx(P.Route,{path:"*",element:t.jsx(w.Box,{width:"100vw",height:"100vh",display:"flex",justifyContent:"center",alignItems:"center",children:t.jsx(Y.default,{status:404,extra:t.jsx(ne,{href:"/",children:o("common.back")})})})})]}),e!=="production"&&t.jsx(Re,{sx:{bgcolor:"info.light"},children:e}),t.jsx(Ee,{titleFontFamily:(y=(b=n.config)==null?void 0:b.fontFamily)==null?void 0:y.title,descriptionFontFamily:(k=(f=n.config)==null?void 0:f.fontFamily)==null?void 0:k.description})]})}function Ae({mode:e,state:n,path:o,pageData:s}){const{t:i,locale:r}=Q.useLocaleContext(),{pages:c,supportedLocales:l,config:{defaultLocale:g},resources:j}=n,u=Object.values(c).find(f=>(f==null?void 0:f.slug)===o),a=Object.values(j.pages||{}).find(f=>f.page.slug===o),p=h.useMemo(()=>l!=null&&l.some(f=>f.locale===r)?r:void 0,[r,l]),x=ue.useReactive({page:null});h.useEffect(()=>{const f=u||(a==null?void 0:a.page)||null;f?x.page=W.default(f):x.page=null},[u,a]);const b=h.useRef();if(h.useEffect(()=>{we.default(s,b.current)||s&&x.page&&(Pe(x.page,n,p,s),b.current=W.default(s))},[{}]),!u&&!(a!=null&&a.page))return t.jsx(w.Box,{width:"100vw",height:"100vh",display:"flex",justifyContent:"center",alignItems:"center",children:t.jsx(Y.default,{style:{background:"inherit"},status:404,extra:t.jsx(ne,{href:"/",children:i("common.back")})})});const y=q.getAllComponents(n);return x.page?t.jsx(T,{mode:e,components:y,page:x.page,locale:p,defaultLocale:g}):null}function T({mode:e,components:n,page:o,locale:s,defaultLocale:i,headerAddons:r}){var k,d,m,A,L,U,D,V,$;const c=ce.useColorConvert(),l=((k=o.locales)==null?void 0:k[s])??((d=o.locales)==null?void 0:d[i])??{},g=l.title||((m=window.blocklet)==null?void 0:m.appName),j=l.description||((A=window.blocklet)==null?void 0:A.appDescription),u=q.autoResizeImage(q.getImageAbsoluteUrl(l.image),540),{logo:a,brand:p,description:x,...b}=ie.useHeaderState(),y=h.useMemo(()=>_=>{var C;let v=(r==null?void 0:r(_))??_;return v=((C=b.addons)==null?void 0:C.call(b,v))??v,v},[b.addons,r]),f=(L=l.header)!=null&&L.translucent?oe:te;return t.jsxs(R.PageProvider,{page:o,defaultLocale:i,currentLocale:s,children:[!!l.backgroundColor&&t.jsx(B.Global,{styles:B.css`
28
- body {
29
- background-color: ${c(l.backgroundColor)} !important;
30
- }
31
- `}),t.jsx(f,{hideNavMenu:!!((U=l.header)!=null&&U.hideNavMenus),translucentTextColor:(D=l.header)==null?void 0:D.translucentTextColor,...a?{logo:a}:{},...p?{brand:p}:{},...x?{description:x}:{},className:X.cx(((V=l.header)==null?void 0:V.sticky)&&"sticky","page-header"),maxWidth:!1,addons:y}),t.jsx(P.ScrollRestoration,{}),t.jsxs(pe.Helmet,{children:[t.jsx("title",{children:g}),t.jsx("meta",{name:"og:title",content:g}),t.jsx("meta",{name:"og:description",content:j}),t.jsx("meta",{name:"og:image",content:u}),t.jsx("meta",{name:"twitter:image:src",content:u}),t.jsx("meta",{name:"twitter:image",content:u}),t.jsx("meta",{property:"twitter:description",content:j}),t.jsx("meta",{property:"twitter:title",content:g}),t.jsx("meta",{name:"description",content:j})]}),t.jsx(w.Stack,{flexGrow:1,className:"PageView-root",sx:{"& .BlockBase-root:first-child":{pt:"0 !important"}},children:o.sectionIds.map(_=>{var z,G;const v=o.sections[_];if(!v||v.visibility==="hidden")return null;const C=(z=v.locales)==null?void 0:z[s],se=((G=v.locales)==null?void 0:G[i])??{};return t.jsx(R.BlockRenderer,{id:_,type:v.component,mode:e,section:v,config:{...ye.default(C)?se:C,locale:s,dev:e==="draft"?{mode:e,components:n,defaultLocale:i}:{mode:e}}},_)})}),!(($=l.footer)!=null&&$.hidden)&&t.jsx(qe,{})]})}const Le=h.lazy(()=>Promise.resolve().then(()=>require("./publish-button-CgvaIqqI.js"))),te=Z.default(be.default)`
32
- &.sticky {
33
- position: sticky;
34
- top: 0;
35
- }
36
- `;function Ue({logo:e}){const[n,o]=h.useState(),s=w.useMediaQuery(r=>r.breakpoints.down("sm")),{value:i}=O.useAsync(()=>{var l,g;const r=new URL(s?((l=window==null?void 0:window.blocklet)==null?void 0:l.appLogo)||"/.well-known/service/blocklet/logo":((g=window==null?void 0:window.blocklet)==null?void 0:g.appLogoRect)||"/.well-known/service/blocklet/logo-rect",window.location.origin);r.searchParams.delete("imageFilter"),r.searchParams.delete("f");const c=r.toString();return new Promise(j=>{fetch(c).then(u=>{const a=u.headers.get("content-type");a!=null&&a.includes("svg")&&u.text().then(p=>{o(p),j(null)}),j(u.url)})})},[s]);if(e)return e;if(n)return t.jsx(w.Box,{sx:{filter:"initial !important"},dangerouslySetInnerHTML:{__html:ve.default.sanitize(n)}});if(i){const r=new URL(i);r.searchParams.set("imageFilter","convert"),r.searchParams.set("f","png"),r.searchParams.set("h","80");const c=r.toString();return t.jsx("img",{src:c,alt:"logo"})}return null}function oe({logo:e,translucentTextColor:n,...o}){const{y:s}=O.useWindowScroll();let i=Math.min(s/800,1),r="";if(i>.1){i=Math.max(i,.6);const c=Math.round(255*Math.min(1-i,.2));r=`rgb(${c}, ${c}, ${c})`}else r=n||"#EEEEEE";return t.jsx(te,{logo:t.jsx(Ue,{logo:e}),...o,className:X.cx(i<=.7&&"reverse-color"),style:{backgroundColor:`rgba(255,255,255,${i})`,"--logo-invert":i<=.7?1-i/6:1-i},sx:{backdropFilter:i>=.6?"blur(10px)":"blur(0px)",transition:"all 0.3s ease",position:"fixed !important",left:0,top:0,right:0,bgcolor:"transparent","&.reverse-color":{".navmenu-root>.navmenu-sub>span,\n .navmenu-root>.navmenu-item,\n .header-addons>button,\n .header-addons>a,\n .header-addons>div>button":{color:`${r} !important`}},".header-logo > div":{filter:"invert(var(--logo-invert))"},".header-logo":{color:r}}})}const ne=Z.default(w.Button)``;exports.Home=Oe;exports.HomeView=ee;exports.Loading=K;exports.PageRoutes=I;exports.PageView=T;exports.PageViewByPath=Ae;exports.TranslucentHeader=oe;