@blocklet/pages-kit-inner-components 0.5.52 → 0.5.54

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,566 @@
1
+ import { jsx as t, jsxs as N } from "react/jsx-runtime";
2
+ import { u as J, d as Q, e as gt, f as ft, g as ht, c as bt } from "./state-l--dTdHq.js";
3
+ import { useLocaleContext as X } from "@arcblock/ux/lib/Locale/context";
4
+ import Z from "@arcblock/ux/lib/Result";
5
+ import { useHeaderState as yt } from "@blocklet/pages-kit/builtin/page/header";
6
+ import { useColorConvert as vt } from "@blocklet/pages-kit/contexts/color";
7
+ import { setPageDataSource as tt } from "@blocklet/pages-kit/utils/data-source";
8
+ import { generateParamCombinations as wt } from "@blocklet/pages-kit/utils/route";
9
+ import xt from "@blocklet/ui-react/lib/Header";
10
+ import { cx as kt } from "@emotion/css";
11
+ import { Global as et, css as ot } from "@emotion/react";
12
+ import nt from "@emotion/styled";
13
+ import { Box as _, CircularProgress as Pt, useTheme as rt, Button as St, Stack as Ct, alpha as q, useMediaQuery as It } from "@mui/material";
14
+ import { useReactive as at, useScroll as jt } from "ahooks";
15
+ import Rt from "isomorphic-dompurify";
16
+ import A from "lodash/cloneDeep";
17
+ import Tt from "lodash/isEmpty";
18
+ import st from "lodash/isEqual";
19
+ import { useEffect as $, lazy as it, useMemo as P, useRef as lt, Suspense as Ot, useState as Et } from "react";
20
+ import { Helmet as Mt } from "react-helmet";
21
+ import { useSearchParams as ct, Routes as Bt, Route as O, Navigate as Ft, ScrollRestoration as $t } from "react-router-dom";
22
+ import { useAsync as ut } from "react-use";
23
+ import { joinURL as C } from "ufo";
24
+ import { S as _t, n as K, P as Dt, a as Lt, B as Nt, g as At } from "./array-c6HYTLze.js";
25
+ import { styled as pt, useTheme as Ht } from "@arcblock/ux/lib/Theme";
26
+ import zt from "@blocklet/ui-react/lib/Footer";
27
+ import "webfontloader";
28
+ import { u as Ut, a as Vt } from "./session-CVblGhSp.js";
29
+ const Gt = pt(zt, { shouldForwardProp: (e) => !!e })`
30
+ & > div > .MuiContainer-root {
31
+ max-width: unset;
32
+ }
33
+ `;
34
+ function Wt({ meta: e, ...n }) {
35
+ const a = Ht();
36
+ return /* @__PURE__ */ t(Gt, { ...n, meta: e, theme: a || {} });
37
+ }
38
+ function qt(e) {
39
+ return /* @__PURE__ */ t(_, { display: "flex", flex: 1, height: "100%", alignItems: "center", justifyContent: "center", ...e, children: /* @__PURE__ */ t(Pt, { size: 30 }) });
40
+ }
41
+ function Kt(e) {
42
+ return /* @__PURE__ */ t(Yt, { ...e });
43
+ }
44
+ const Yt = pt(_)`
45
+ position: fixed;
46
+ left: 0;
47
+ top: 0;
48
+ z-index: 999999999999;
49
+ width: 80px;
50
+ font-size: 12px;
51
+ text-align: center;
52
+ opacity: 0.7;
53
+ transform: translateX(-23%) translateY(70%) rotate(-45deg);
54
+ pointer-events: none;
55
+ `, Jt = `Avenir, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
56
+ sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'`;
57
+ function Qt({
58
+ titleFontFamily: e,
59
+ descriptionFontFamily: n
60
+ }) {
61
+ var o;
62
+ const a = rt(), s = (o = a == null ? void 0 : a.typography) == null ? void 0 : o.fontFamily;
63
+ $(() => {
64
+ }, [e, n]);
65
+ const i = `${s}, ${Jt}`;
66
+ return /* @__PURE__ */ t(
67
+ et,
68
+ {
69
+ styles: ot`
70
+ #app {
71
+ font-family: ${i};
72
+
73
+ .page-kit-section__title {
74
+ font-family: ${i};
75
+ }
76
+
77
+ .page-kit-section__description {
78
+ font-family: ${i};
79
+ }
80
+ }
81
+ `
82
+ }
83
+ );
84
+ }
85
+ function Me() {
86
+ const [e] = ct(), { session: n } = Ut(), a = Vt("owner", "admin", "pagesEditor", "member"), s = P(() => {
87
+ const o = e.get("mode");
88
+ return _t.includes(o) ? o : "production";
89
+ }, [e]), i = s === "production" ? s : n.user ? a ? s : "production" : null;
90
+ return i ? /* @__PURE__ */ t(Xt, { mode: i }) : null;
91
+ }
92
+ function Xt({ mode: e }) {
93
+ if (e !== "draft") {
94
+ const n = window.__PAGE_STATE__;
95
+ return n ? /* @__PURE__ */ t(U, { mode: e, state: n }) : /* @__PURE__ */ t(te, { mode: e, children: ({ state: a }) => /* @__PURE__ */ t(U, { mode: e, state: a }) });
96
+ }
97
+ return /* @__PURE__ */ t(Zt, { children: ({ state: n }) => /* @__PURE__ */ t(U, { mode: e, state: n }) });
98
+ }
99
+ const Zt = it(() => import("./draft-data-CWM--ooz.js"));
100
+ function te({
101
+ mode: e,
102
+ children: n
103
+ }) {
104
+ const a = document.querySelector('meta[property="pages:version"]'), s = a == null ? void 0 : a.content, i = J(), o = P(() => {
105
+ if (s === "{{pagesPublishedAt}}") {
106
+ const u = localStorage.getItem(bt(i ?? ""));
107
+ return Number(u) ? Number(u) : (/* @__PURE__ */ new Date()).getTime();
108
+ }
109
+ return Number(s);
110
+ }, [s]), { loading: d, value: l } = ut(() => At({ mode: e, version: o }), [e, o]);
111
+ return d ? /* @__PURE__ */ t(qt, {}) : l ? n({ state: l }) : null;
112
+ }
113
+ function U({ mode: e, state: n }) {
114
+ const { t: a, locale: s } = X(), [i] = ct(), o = J(), d = gt(), l = i.get("hiddenBadge") === "true", u = i.get("showPublish") === "true", {
115
+ pageIds: g,
116
+ pages: m,
117
+ routeIds: c,
118
+ routes: f,
119
+ supportedLocales: b,
120
+ config: { defaultLocale: y },
121
+ resources: I
122
+ } = n, h = Q(n), x = P(
123
+ () => b != null && b.some((p) => p.locale === s) ? s : void 0,
124
+ [s, b]
125
+ ), E = Object.values(f || {}).find((p) => (p == null ? void 0 : p.path) === "/") || Object.values(m).find((p) => (p == null ? void 0 : p.slug) === "/") ? void 0 : Object.values(m)[0], D = P(() => e === "production" ? g.map((p) => {
126
+ const r = m[p];
127
+ return r && {
128
+ id: r.id,
129
+ path: C("/", d || o || "", r.slug)
130
+ };
131
+ }).filter(K) : c.map((p) => {
132
+ const r = f[p];
133
+ return r ? {
134
+ id: r.id,
135
+ path: C("/", d || o || "", r.path, `?mode=${e}&showPublish=true`)
136
+ } : null;
137
+ }).filter(K), [g, m, e, f, c, o, d]), S = ([...p]) => (e !== "production" && u && p.unshift(
138
+ /* @__PURE__ */ t(Ot, { fallback: /* @__PURE__ */ t("div", {}), children: /* @__PURE__ */ t(ee, { mode: "production", state: n }) })
139
+ ), p);
140
+ return /* @__PURE__ */ N(Dt, { value: { pages: D }, children: [
141
+ /* @__PURE__ */ N(Bt, { children: [
142
+ E && /* @__PURE__ */ t(O, { index: !0, element: /* @__PURE__ */ t(Ft, { to: C("/", x || "", E.slug) }) }),
143
+ c == null ? void 0 : c.map((p) => {
144
+ var v, w, k, L;
145
+ const r = f == null ? void 0 : f[p];
146
+ if (!r || !r.displayTemplateId) return null;
147
+ const j = m[r.displayTemplateId];
148
+ if (!j) return null;
149
+ let R = [];
150
+ if (r.params && r.params.length > 0) {
151
+ const T = wt({
152
+ basePath: r.path,
153
+ params: r.params,
154
+ routeId: r.id,
155
+ paramsOptions: r.paramsOptions,
156
+ currentIndex: 0,
157
+ currentParams: [],
158
+ currentOptionIds: [],
159
+ result: []
160
+ });
161
+ R = T == null ? void 0 : T.map((M) => {
162
+ var F, V, G, W;
163
+ const B = M.paramOptionIds.join("-");
164
+ return /* @__PURE__ */ t(
165
+ O,
166
+ {
167
+ path: C(":projectIdOrSlug?", M.path),
168
+ element: /* @__PURE__ */ t(
169
+ Y,
170
+ {
171
+ mode: e,
172
+ components: h,
173
+ page: j,
174
+ locale: x,
175
+ defaultLocale: y,
176
+ headerAddons: S,
177
+ state: n,
178
+ pageData: (W = (G = (V = (F = r.dataSource) == null ? void 0 : F.pathDataMappings) == null ? void 0 : V[B]) == null ? void 0 : G.dataCache) == null ? void 0 : W[x || y || "en"]
179
+ }
180
+ )
181
+ },
182
+ B
183
+ );
184
+ });
185
+ }
186
+ return R.push(
187
+ /* @__PURE__ */ t(
188
+ O,
189
+ {
190
+ path: C(":projectIdOrSlug?", r.path),
191
+ element: /* @__PURE__ */ t(
192
+ Y,
193
+ {
194
+ mode: e,
195
+ components: h,
196
+ page: j,
197
+ locale: x,
198
+ defaultLocale: y,
199
+ headerAddons: S,
200
+ state: n,
201
+ pageData: (L = (k = (w = (v = r.dataSource) == null ? void 0 : v.pathDataMappings) == null ? void 0 : w[r.id]) == null ? void 0 : k.dataCache) == null ? void 0 : L[x || y || "en"]
202
+ }
203
+ )
204
+ },
205
+ r.id
206
+ )
207
+ ), R;
208
+ }),
209
+ g.map((p) => {
210
+ const r = m[p];
211
+ return r ? /* @__PURE__ */ t(
212
+ O,
213
+ {
214
+ path: C(":projectIdOrSlug?", r.slug),
215
+ element: /* @__PURE__ */ t(
216
+ H,
217
+ {
218
+ mode: e,
219
+ components: h,
220
+ page: r,
221
+ locale: x,
222
+ defaultLocale: y,
223
+ headerAddons: S
224
+ }
225
+ )
226
+ },
227
+ r.id
228
+ ) : null;
229
+ }),
230
+ I.pages && Object.values(I.pages).map(({ blockletId: p, page: r }) => /* @__PURE__ */ t(
231
+ O,
232
+ {
233
+ path: C("/", `@${p}`, r.slug),
234
+ element: /* @__PURE__ */ t(
235
+ H,
236
+ {
237
+ mode: e,
238
+ components: h,
239
+ page: r,
240
+ locale: x,
241
+ defaultLocale: y,
242
+ headerAddons: S
243
+ }
244
+ )
245
+ },
246
+ r.id
247
+ )),
248
+ /* @__PURE__ */ t(
249
+ O,
250
+ {
251
+ path: "*",
252
+ element: /* @__PURE__ */ t(_, { width: "100vw", height: "100vh", display: "flex", justifyContent: "center", alignItems: "center", children: /* @__PURE__ */ t(
253
+ Z,
254
+ {
255
+ status: 404,
256
+ extra: /* @__PURE__ */ t(dt, { href: "/", children: a("common.back") }),
257
+ sx: {
258
+ bgcolor: "transparent",
259
+ width: "100%",
260
+ height: "100%"
261
+ }
262
+ }
263
+ ) })
264
+ }
265
+ )
266
+ ] }),
267
+ e !== "production" && !l && /* @__PURE__ */ t(Kt, { sx: { bgcolor: "info.light" }, children: e }),
268
+ /* @__PURE__ */ t(Qt, {})
269
+ ] });
270
+ }
271
+ function Y({
272
+ mode: e,
273
+ pageData: n,
274
+ components: a,
275
+ page: s,
276
+ locale: i,
277
+ defaultLocale: o,
278
+ headerAddons: d,
279
+ state: l
280
+ }) {
281
+ const u = at({
282
+ page: null
283
+ });
284
+ $(() => {
285
+ const m = s || null;
286
+ m ? u.page = A(m) : u.page = null;
287
+ }, [s, JSON.stringify(s), u]);
288
+ const g = lt();
289
+ return $(() => {
290
+ st(n, g.current) || n && u.page && (tt(u.page, l, i, n), g.current = A(n));
291
+ }, [u.page, n, i, l]), u.page ? /* @__PURE__ */ t(
292
+ H,
293
+ {
294
+ mode: e,
295
+ components: a,
296
+ page: u.page,
297
+ locale: i,
298
+ defaultLocale: o,
299
+ headerAddons: d
300
+ }
301
+ ) : null;
302
+ }
303
+ function Be({
304
+ mode: e,
305
+ state: n,
306
+ path: a,
307
+ pageData: s
308
+ }) {
309
+ const { t: i, locale: o } = X(), {
310
+ pages: d,
311
+ supportedLocales: l,
312
+ config: { defaultLocale: u },
313
+ resources: g
314
+ } = n, m = Object.values(d).find((h) => (h == null ? void 0 : h.slug) === a), c = Object.values(g.pages || {}).find((h) => h.page.slug === a), f = P(
315
+ () => l != null && l.some((h) => h.locale === o) ? o : void 0,
316
+ [o, l]
317
+ ), b = at({
318
+ page: null
319
+ });
320
+ $(() => {
321
+ const h = m || (c == null ? void 0 : c.page) || null;
322
+ h ? b.page = A(h) : b.page = null;
323
+ }, [m, c]);
324
+ const y = lt();
325
+ if ($(() => {
326
+ st(s, y.current) || s && b.page && (tt(b.page, n, f, s), y.current = A(s));
327
+ }, [{}]), !m && !(c != null && c.page))
328
+ return /* @__PURE__ */ t(_, { width: "100vw", height: "100vh", display: "flex", justifyContent: "center", alignItems: "center", children: /* @__PURE__ */ t(Z, { style: { background: "inherit" }, status: 404, extra: /* @__PURE__ */ t(dt, { href: "/", children: i("common.back") }) }) });
329
+ const I = Q(n);
330
+ return b.page ? /* @__PURE__ */ t(
331
+ H,
332
+ {
333
+ mode: e,
334
+ components: I,
335
+ page: b.page,
336
+ locale: f,
337
+ defaultLocale: u
338
+ }
339
+ ) : null;
340
+ }
341
+ function H({
342
+ mode: e,
343
+ components: n,
344
+ page: a,
345
+ locale: s,
346
+ defaultLocale: i,
347
+ headerAddons: o
348
+ }) {
349
+ var x, z, E, D, S, p, r, j, R;
350
+ const d = vt(), l = ((x = a.locales) == null ? void 0 : x[s]) ?? ((z = a.locales) == null ? void 0 : z[i]) ?? {}, u = l.title || ((E = window.blocklet) == null ? void 0 : E.appName), g = l.description || ((D = window.blocklet) == null ? void 0 : D.appDescription), m = ft(ht(l.image), 540), { logo: c, brand: f, description: b, ...y } = yt(), I = P(
351
+ () => (v) => {
352
+ var k;
353
+ let w = (o == null ? void 0 : o(v)) ?? v;
354
+ return w = ((k = y.addons) == null ? void 0 : k.call(y, w)) ?? w, w;
355
+ },
356
+ [y.addons, o]
357
+ ), h = P(
358
+ () => {
359
+ var v;
360
+ return (v = l.header) != null && v.translucent ? ne : mt;
361
+ },
362
+ [(S = l.header) == null ? void 0 : S.translucent]
363
+ );
364
+ return /* @__PURE__ */ N(Lt, { page: a, defaultLocale: i, currentLocale: s, children: [
365
+ /* @__PURE__ */ t(
366
+ et,
367
+ {
368
+ styles: ot`
369
+ body {
370
+ background-color: ${d(
371
+ !l.backgroundColor || l.backgroundColor === "transparent" ? "background.default" : l.backgroundColor
372
+ )} !important;
373
+ }
374
+ `
375
+ }
376
+ ),
377
+ /* @__PURE__ */ t(
378
+ h,
379
+ {
380
+ hideNavMenu: !!((p = l.header) != null && p.hideNavMenus),
381
+ translucentTextColor: (r = l.header) == null ? void 0 : r.translucentTextColor,
382
+ ...c ? { logo: c } : {},
383
+ ...f ? { brand: f } : {},
384
+ ...b ? { description: b } : {},
385
+ className: kt(((j = l.header) == null ? void 0 : j.sticky) && "sticky", "page-header"),
386
+ maxWidth: !1,
387
+ addons: I
388
+ }
389
+ ),
390
+ /* @__PURE__ */ t($t, {}),
391
+ /* @__PURE__ */ N(Mt, { children: [
392
+ /* @__PURE__ */ t("title", { children: u }),
393
+ /* @__PURE__ */ t("meta", { name: "og:title", content: u }),
394
+ /* @__PURE__ */ t("meta", { name: "og:description", content: g }),
395
+ /* @__PURE__ */ t("meta", { name: "og:image", content: m }),
396
+ /* @__PURE__ */ t("meta", { name: "twitter:image:src", content: m }),
397
+ /* @__PURE__ */ t("meta", { name: "twitter:image", content: m }),
398
+ /* @__PURE__ */ t("meta", { property: "twitter:description", content: g }),
399
+ /* @__PURE__ */ t("meta", { property: "twitter:title", content: u }),
400
+ /* @__PURE__ */ t("meta", { name: "description", content: g })
401
+ ] }),
402
+ /* @__PURE__ */ t(
403
+ Ct,
404
+ {
405
+ flexGrow: 1,
406
+ className: "PageView-root",
407
+ sx: {
408
+ // 第一个 .BlockBase-root 的 pt 为 0
409
+ "& .BlockBase-root:first-child": {
410
+ pt: "0 !important"
411
+ }
412
+ },
413
+ children: a.sectionIds.map((v) => {
414
+ var T, M, B, F;
415
+ const w = a.sections[v];
416
+ if (!w || w.visibility === "hidden") return null;
417
+ const k = (M = (T = a.dataSource) == null ? void 0 : T[v]) == null ? void 0 : M[s], L = ((F = (B = a.dataSource) == null ? void 0 : B[v]) == null ? void 0 : F[i]) ?? {};
418
+ return /* @__PURE__ */ t(
419
+ Nt,
420
+ {
421
+ id: v,
422
+ type: w.component,
423
+ mode: e,
424
+ section: w,
425
+ config: {
426
+ ...Tt(k) ? L : k,
427
+ locale: s,
428
+ dev: e === "draft" ? {
429
+ mode: e,
430
+ components: n,
431
+ defaultLocale: i
432
+ } : {
433
+ mode: e,
434
+ defaultLocale: i
435
+ // 用于 fallback 的 locale
436
+ }
437
+ },
438
+ page: a
439
+ },
440
+ v
441
+ );
442
+ })
443
+ }
444
+ ),
445
+ !((R = l.footer) != null && R.hidden) && /* @__PURE__ */ t(Wt, {})
446
+ ] });
447
+ }
448
+ const ee = it(() => import("./publish-button-DBcyuR_L.js")), mt = nt(xt)`
449
+ &.sticky {
450
+ position: sticky;
451
+ top: 0;
452
+ }
453
+ `;
454
+ function oe({ logo: e }) {
455
+ const [n, a] = Et(), s = It((o) => o.breakpoints.down("sm")), { value: i } = ut(() => {
456
+ var l, u;
457
+ const o = new URL(
458
+ s ? ((l = window == null ? void 0 : window.blocklet) == null ? void 0 : l.appLogo) || "/.well-known/service/blocklet/logo" : ((u = window == null ? void 0 : window.blocklet) == null ? void 0 : u.appLogoRect) || "/.well-known/service/blocklet/logo-rect",
459
+ window.location.origin
460
+ );
461
+ o.searchParams.delete("imageFilter"), o.searchParams.delete("f");
462
+ const d = o.toString();
463
+ return new Promise((g) => {
464
+ fetch(d).then((m) => {
465
+ const c = m.headers.get("content-type");
466
+ c != null && c.includes("svg") && m.text().then((f) => {
467
+ a(f), g(null);
468
+ }), g(m.url);
469
+ });
470
+ });
471
+ }, [s]);
472
+ if (e)
473
+ return e;
474
+ if (n)
475
+ return /* @__PURE__ */ t(_, { sx: { filter: "initial !important" }, dangerouslySetInnerHTML: { __html: Rt.sanitize(n) } });
476
+ if (i) {
477
+ const o = new URL(i);
478
+ o.searchParams.set("imageFilter", "convert"), o.searchParams.set("f", "png"), o.searchParams.set("h", "80");
479
+ const d = o.toString();
480
+ return /* @__PURE__ */ t("img", { src: d, alt: "logo" });
481
+ }
482
+ return null;
483
+ }
484
+ function ne({
485
+ logo: e,
486
+ translucentTextColor: n,
487
+ ...a
488
+ }) {
489
+ const i = jt(document.getElementById("app"), (c) => c.top < 1200), o = rt(), d = Math.min((i == null ? void 0 : i.top) ?? 0, 800), l = P(() => {
490
+ let c = Math.min(d / 800, 1), f = "";
491
+ return c > 0.1 ? (c = Math.max(c, 0.6), f = q(o.palette.text.primary, c)) : f = n || "#EEEEEE", {
492
+ backgroundOpacity: c,
493
+ textColor: f,
494
+ isReversed: c < 0.7
495
+ };
496
+ }, [d, 800, o.palette.text.primary, n]), { backgroundOpacity: u, textColor: g, isReversed: m } = l;
497
+ return /* @__PURE__ */ t(
498
+ mt,
499
+ {
500
+ logo: /* @__PURE__ */ t(oe, { logo: e }),
501
+ ...a,
502
+ sx: {
503
+ // 基础布局和定位
504
+ position: "fixed !important",
505
+ top: 0,
506
+ left: 0,
507
+ right: 0,
508
+ zIndex: o.zIndex.appBar,
509
+ // 确保在顶层
510
+ backgroundColor: "transparent !important",
511
+ // 主元素始终透明
512
+ // 使用伪元素作为背景层
513
+ "&::before": {
514
+ content: '""',
515
+ position: "absolute",
516
+ top: 0,
517
+ left: 0,
518
+ right: 0,
519
+ bottom: 0,
520
+ zIndex: -1,
521
+ // 置于内容下方
522
+ // 背景样式(颜色和模糊)是固定的
523
+ backgroundColor: q(o.palette.background.default, u),
524
+ backdropFilter: u >= 0.6 ? "blur(10px)" : "blur(0px)",
525
+ // **性能关键**: 只对 opacity 进行动画
526
+ // opacity: backgroundOpacity,
527
+ // 让 CSS 平滑地处理透明度变化
528
+ transition: "backgroundColor 0.3s ease-in-out"
529
+ },
530
+ // --- 文字和图标颜色过渡 ---
531
+ // 直接为 Header 内所有相关元素设置颜色和过渡
532
+ // color: textColor,
533
+ transition: "color 0.3s ease-in-out",
534
+ // 覆盖子组件的颜色,使其继承父级的 `color`
535
+ ".navmenu-root>.navmenu-sub>span,\n .navmenu-root>.navmenu-item,\n .header-addons>button,\n .header-addons>a,\n .header-addons>div>button": {
536
+ color: `${g} !important`
537
+ // 使用 inherit 来同步颜色
538
+ },
539
+ ".header-logo": {
540
+ color: `${g} !important`
541
+ },
542
+ "& .navmenu--horizontal": {
543
+ bgcolor: "transparent !important"
544
+ },
545
+ // --- Logo 反色效果 ---
546
+ // filter 也是一个较昂贵的属性,但其影响远小于背景色的重绘
547
+ // 这里的逻辑保持不变,但可以考虑是否有更优的方案(如提供两个颜色的 Logo)
548
+ ".header-logo > div": {
549
+ filter: `invert(${m ? 1 : 0})`,
550
+ transition: "filter 0.3s ease-in-out"
551
+ }
552
+ }
553
+ }
554
+ );
555
+ }
556
+ const dt = nt(St)``;
557
+ export {
558
+ Me as H,
559
+ qt as L,
560
+ U as P,
561
+ ne as T,
562
+ Xt as a,
563
+ Y as b,
564
+ Be as c,
565
+ H as d
566
+ };
@@ -10,7 +10,7 @@ import { produce as Oe } from "immer";
10
10
  import ee from "lodash/difference";
11
11
  import { useState as j, useMemo as R, useCallback as v, forwardRef as je, useImperativeHandle as ve, useEffect as $, useRef as Te } from "react";
12
12
  import { useAsync as Re } from "react-use";
13
- import { L as ze } from "./home-DQjaiv2F.js";
13
+ import { L as ze } from "./home-BDXQ7G7E.js";
14
14
  import { p as Le, g as Be } from "./array-c6HYTLze.js";
15
15
  function Ee(s) {
16
16
  const [y, w] = j(!1);
package/lib/es/home.js CHANGED
@@ -22,7 +22,7 @@ import "react-router-dom";
22
22
  import "react-use";
23
23
  import "ufo";
24
24
  import "./chunks/array-c6HYTLze.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-DQjaiv2F.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-BDXQ7G7E.js";
26
26
  import "./chunks/session-CVblGhSp.js";
27
27
  export {
28
28
  R as HomeView,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/pages-kit-inner-components",
3
- "version": "0.5.52",
3
+ "version": "0.5.54",
4
4
  "description": "Pages Kit inner components library",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -204,8 +204,8 @@
204
204
  "yaml": "^2.5.0",
205
205
  "yjs": "^13.6.18",
206
206
  "zustand": "^4.5.5",
207
- "@blocklet/pages-kit": "^0.5.52",
208
- "@blocklet/pages-kit-block-studio": "^0.5.52"
207
+ "@blocklet/pages-kit": "^0.5.54",
208
+ "@blocklet/pages-kit-block-studio": "^0.5.54"
209
209
  },
210
210
  "devDependencies": {
211
211
  "@trivago/prettier-plugin-sort-imports": "^5.2.1",
@@ -1,38 +0,0 @@
1
- "use strict";const e=require("react/jsx-runtime"),R=require("./state-BVdbNJCA.js"),X=require("@arcblock/ux/lib/Locale/context"),ue=require("@arcblock/ux/lib/Result"),de=require("@blocklet/pages-kit/builtin/page/header"),pe=require("@blocklet/pages-kit/contexts/color"),Z=require("@blocklet/pages-kit/utils/data-source"),ge=require("@blocklet/pages-kit/utils/route"),me=require("@blocklet/ui-react/lib/Header"),fe=require("@emotion/css"),V=require("@emotion/react"),he=require("@emotion/styled"),y=require("@mui/material"),ee=require("ahooks"),xe=require("isomorphic-dompurify"),je=require("lodash/cloneDeep"),be=require("lodash/isEmpty"),ye=require("lodash/isEqual"),g=require("react"),ve=require("react-helmet"),w=require("react-router-dom"),te=require("react-use"),_=require("ufo"),E=require("./array-BqHuYyfx.js"),W=require("@arcblock/ux/lib/Theme"),Pe=require("@blocklet/ui-react/lib/Footer");require("webfontloader");const Q=require("./session-BA7Qrcia.js"),q=t=>t&&t.__esModule?t:{default:t},ne=q(ue),we=q(me),oe=q(he),ke=q(xe),z=q(je),Se=q(be),re=q(ye),Re=q(Pe),qe=W.styled(Re.default,{shouldForwardProp:t=>!!t})`
2
- & > div > .MuiContainer-root {
3
- max-width: unset;
4
- }
5
- `;function Ce({meta:t,...o}){const a=W.useTheme();return e.jsx(qe,{...o,meta:t,theme:a||{}})}function se(t){return e.jsx(y.Box,{display:"flex",flex:1,height:"100%",alignItems:"center",justifyContent:"center",...t,children:e.jsx(y.CircularProgress,{size:30})})}function _e(t){return e.jsx(Ee,{...t})}const Ee=W.styled(y.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
- `,Ie=`Avenir, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
17
- sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'`;function Me({titleFontFamily:t,descriptionFontFamily:o}){var n;const a=y.useTheme(),i=(n=a==null?void 0:a.typography)==null?void 0:n.fontFamily;g.useEffect(()=>{},[t,o]);const c=`${i}, ${Ie}`;return e.jsx(V.Global,{styles:V.css`
18
- #app {
19
- font-family: ${c};
20
-
21
- .page-kit-section__title {
22
- font-family: ${c};
23
- }
24
-
25
- .page-kit-section__description {
26
- font-family: ${c};
27
- }
28
- }
29
- `})}function Te(){const[t]=w.useSearchParams(),{session:o}=Q.useSessionContext(),a=Q.useIsRoleOrMultiTenant("owner","admin","pagesEditor","member"),i=g.useMemo(()=>{const n=t.get("mode");return E.STATE_MODES.includes(n)?n:"production"},[t]),c=i==="production"?i:o.user?a?i:"production":null;return c?e.jsx(ae,{mode:c}):null}function ae({mode:t}){if(t!=="draft"){const o=window.__PAGE_STATE__;return o?e.jsx(N,{mode:t,state:o}):e.jsx(Le,{mode:t,children:({state:a})=>e.jsx(N,{mode:t,state:a})})}return e.jsx(Be,{children:({state:o})=>e.jsx(N,{mode:t,state:o})})}const Be=g.lazy(()=>Promise.resolve().then(()=>require("./draft-data-CuZfaQ4s.js")));function Le({mode:t,children:o}){const a=document.querySelector('meta[property="pages:version"]'),i=a==null?void 0:a.content,c=R.useProjectId(),n=g.useMemo(()=>{if(i==="{{pagesPublishedAt}}"){const u=localStorage.getItem(R.getProjectPageVersionKey(c??""));return Number(u)?Number(u):new Date().getTime()}return Number(i)},[i]),{loading:m,value:r}=te.useAsync(()=>E.getPages({mode:t,version:n}),[t,n]);return m?e.jsx(se,{}):r?o({state:r}):null}function N({mode:t,state:o}){const{t:a,locale:i}=X.useLocaleContext(),[c]=w.useSearchParams(),n=R.useProjectId(),m=R.useProjectSlug(),r=c.get("hiddenBadge")==="true",u=c.get("showPublish")==="true",{pageIds:f,pages:l,routeIds:p,routes:h,supportedLocales:j,config:{defaultLocale:b},resources:I}=o,x=R.getAllComponents(o),k=g.useMemo(()=>j!=null&&j.some(d=>d.locale===i)?i:void 0,[i,j]),L=Object.values(h||{}).find(d=>(d==null?void 0:d.path)==="/")||Object.values(l).find(d=>(d==null?void 0:d.slug)==="/")?void 0:Object.values(l)[0],U=g.useMemo(()=>t==="production"?f.map(d=>{const s=l[d];return s&&{id:s.id,path:_.joinURL("/",m||n||"",s.slug)}}).filter(E.nonNullable):p.map(d=>{const s=h[d];return s?{id:s.id,path:_.joinURL("/",m||n||"",s.path,`?mode=${t}&showPublish=true`)}:null}).filter(E.nonNullable),[f,l,t,h,p,n,m]),C=([...d])=>(t!=="production"&&u&&d.unshift(e.jsx(g.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(De,{mode:"production",state:o})})),d);return e.jsxs(E.Provider,{value:{pages:U},children:[e.jsxs(w.Routes,{children:[L&&e.jsx(w.Route,{index:!0,element:e.jsx(w.Navigate,{to:_.joinURL("/",k||"",L.slug)})}),p==null?void 0:p.map(d=>{var P,v,S,A;const s=h==null?void 0:h[d];if(!s||!s.displayTemplateId)return null;const M=l[s.displayTemplateId];if(!M)return null;let T=[];if(s.params&&s.params.length>0){const B=ge.generateParamCombinations({basePath:s.path,params:s.params,routeId:s.id,paramsOptions:s.paramsOptions,currentIndex:0,currentParams:[],currentOptionIds:[],result:[]});T=B==null?void 0:B.map(O=>{var F,Y,K,J;const D=O.paramOptionIds.join("-");return e.jsx(w.Route,{path:_.joinURL(":projectIdOrSlug?",O.path),element:e.jsx(G,{mode:t,components:x,page:M,locale:k,defaultLocale:b,headerAddons:C,state:o,pageData:(J=(K=(Y=(F=s.dataSource)==null?void 0:F.pathDataMappings)==null?void 0:Y[D])==null?void 0:K.dataCache)==null?void 0:J[k||b||"en"]})},D)})}return T.push(e.jsx(w.Route,{path:_.joinURL(":projectIdOrSlug?",s.path),element:e.jsx(G,{mode:t,components:x,page:M,locale:k,defaultLocale:b,headerAddons:C,state:o,pageData:(A=(S=(v=(P=s.dataSource)==null?void 0:P.pathDataMappings)==null?void 0:v[s.id])==null?void 0:S.dataCache)==null?void 0:A[k||b||"en"]})},s.id)),T}),f.map(d=>{const s=l[d];return s?e.jsx(w.Route,{path:_.joinURL(":projectIdOrSlug?",s.slug),element:e.jsx(H,{mode:t,components:x,page:s,locale:k,defaultLocale:b,headerAddons:C})},s.id):null}),I.pages&&Object.values(I.pages).map(({blockletId:d,page:s})=>e.jsx(w.Route,{path:_.joinURL("/",`@${d}`,s.slug),element:e.jsx(H,{mode:t,components:x,page:s,locale:k,defaultLocale:b,headerAddons:C})},s.id)),e.jsx(w.Route,{path:"*",element:e.jsx(y.Box,{width:"100vw",height:"100vh",display:"flex",justifyContent:"center",alignItems:"center",children:e.jsx(ne.default,{status:404,extra:e.jsx(le,{href:"/",children:a("common.back")}),sx:{bgcolor:"transparent",width:"100%",height:"100%"}})})})]}),t!=="production"&&!r&&e.jsx(_e,{sx:{bgcolor:"info.light"},children:t}),e.jsx(Me,{})]})}function G({mode:t,pageData:o,components:a,page:i,locale:c,defaultLocale:n,headerAddons:m,state:r}){const u=ee.useReactive({page:null});g.useEffect(()=>{const l=i||null;l?u.page=z.default(l):u.page=null},[i,JSON.stringify(i),u]);const f=g.useRef();return g.useEffect(()=>{re.default(o,f.current)||o&&u.page&&(Z.setPageDataSource(u.page,r,c,o),f.current=z.default(o))},[u.page,o,c,r]),u.page?e.jsx(H,{mode:t,components:a,page:u.page,locale:c,defaultLocale:n,headerAddons:m}):null}function Oe({mode:t,state:o,path:a,pageData:i}){const{t:c,locale:n}=X.useLocaleContext(),{pages:m,supportedLocales:r,config:{defaultLocale:u},resources:f}=o,l=Object.values(m).find(x=>(x==null?void 0:x.slug)===a),p=Object.values(f.pages||{}).find(x=>x.page.slug===a),h=g.useMemo(()=>r!=null&&r.some(x=>x.locale===n)?n:void 0,[n,r]),j=ee.useReactive({page:null});g.useEffect(()=>{const x=l||(p==null?void 0:p.page)||null;x?j.page=z.default(x):j.page=null},[l,p]);const b=g.useRef();if(g.useEffect(()=>{re.default(i,b.current)||i&&j.page&&(Z.setPageDataSource(j.page,o,h,i),b.current=z.default(i))},[{}]),!l&&!(p!=null&&p.page))return e.jsx(y.Box,{width:"100vw",height:"100vh",display:"flex",justifyContent:"center",alignItems:"center",children:e.jsx(ne.default,{style:{background:"inherit"},status:404,extra:e.jsx(le,{href:"/",children:c("common.back")})})});const I=R.getAllComponents(o);return j.page?e.jsx(H,{mode:t,components:I,page:j.page,locale:h,defaultLocale:u}):null}function H({mode:t,components:o,page:a,locale:i,defaultLocale:c,headerAddons:n}){var k,$,L,U,C,d,s,M,T;const m=pe.useColorConvert(),r=((k=a.locales)==null?void 0:k[i])??(($=a.locales)==null?void 0:$[c])??{},u=r.title||((L=window.blocklet)==null?void 0:L.appName),f=r.description||((U=window.blocklet)==null?void 0:U.appDescription),l=R.autoResizeImage(R.getImageAbsoluteUrl(r.image),540),{logo:p,brand:h,description:j,...b}=de.useHeaderState(),I=g.useMemo(()=>P=>{var S;let v=(n==null?void 0:n(P))??P;return v=((S=b.addons)==null?void 0:S.call(b,v))??v,v},[b.addons,n]),x=(C=r.header)!=null&&C.translucent?ce:ie;return e.jsxs(E.PageProvider,{page:a,defaultLocale:c,currentLocale:i,children:[e.jsx(V.Global,{styles:V.css`
30
- body {
31
- background-color: ${m(!r.backgroundColor||r.backgroundColor==="transparent"?"background.default":r.backgroundColor)} !important;
32
- }
33
- `}),e.jsx(x,{hideNavMenu:!!((d=r.header)!=null&&d.hideNavMenus),translucentTextColor:(s=r.header)==null?void 0:s.translucentTextColor,...p?{logo:p}:{},...h?{brand:h}:{},...j?{description:j}:{},className:fe.cx(((M=r.header)==null?void 0:M.sticky)&&"sticky","page-header"),maxWidth:!1,addons:I}),e.jsx(w.ScrollRestoration,{}),e.jsxs(ve.Helmet,{children:[e.jsx("title",{children:u}),e.jsx("meta",{name:"og:title",content:u}),e.jsx("meta",{name:"og:description",content:f}),e.jsx("meta",{name:"og:image",content:l}),e.jsx("meta",{name:"twitter:image:src",content:l}),e.jsx("meta",{name:"twitter:image",content:l}),e.jsx("meta",{property:"twitter:description",content:f}),e.jsx("meta",{property:"twitter:title",content:u}),e.jsx("meta",{name:"description",content:f})]}),e.jsx(y.Stack,{flexGrow:1,className:"PageView-root",sx:{"& .BlockBase-root:first-child":{pt:"0 !important"}},children:a.sectionIds.map(P=>{var B,O,D,F;const v=a.sections[P];if(!v||v.visibility==="hidden")return null;const S=(O=(B=a.dataSource)==null?void 0:B[P])==null?void 0:O[i],A=((F=(D=a.dataSource)==null?void 0:D[P])==null?void 0:F[c])??{};return e.jsx(E.BlockRenderer,{id:P,type:v.component,mode:t,section:v,config:{...Se.default(S)?A:S,locale:i,dev:t==="draft"?{mode:t,components:o,defaultLocale:c}:{mode:t,defaultLocale:c}},page:a},P)})}),!((T=r.footer)!=null&&T.hidden)&&e.jsx(Ce,{})]})}const De=g.lazy(()=>Promise.resolve().then(()=>require("./publish-button-1xmfwN7o.js"))),ie=oe.default(we.default)`
34
- &.sticky {
35
- position: sticky;
36
- top: 0;
37
- }
38
- `;function Fe({logo:t}){const[o,a]=g.useState(),i=y.useMediaQuery(n=>n.breakpoints.down("sm")),{value:c}=te.useAsync(()=>{var r,u;const n=new URL(i?((r=window==null?void 0:window.blocklet)==null?void 0:r.appLogo)||"/.well-known/service/blocklet/logo":((u=window==null?void 0:window.blocklet)==null?void 0:u.appLogoRect)||"/.well-known/service/blocklet/logo-rect",window.location.origin);n.searchParams.delete("imageFilter"),n.searchParams.delete("f");const m=n.toString();return new Promise(f=>{fetch(m).then(l=>{const p=l.headers.get("content-type");p!=null&&p.includes("svg")&&l.text().then(h=>{a(h),f(null)}),f(l.url)})})},[i]);if(t)return t;if(o)return e.jsx(y.Box,{sx:{filter:"initial !important"},dangerouslySetInnerHTML:{__html:ke.default.sanitize(o)}});if(c){const n=new URL(c);n.searchParams.set("imageFilter","convert"),n.searchParams.set("f","png"),n.searchParams.set("h","80");const m=n.toString();return e.jsx("img",{src:m,alt:"logo"})}return null}function ce({logo:t,translucentTextColor:o,...a}){const[i,c]=g.useState(0),n=y.useTheme(),m=800;g.useEffect(()=>{const l=document.getElementById("app");if(!l)return;let p=!1;const h=()=>{p||(requestAnimationFrame(()=>{c(l.scrollTop),p=!1}),p=!0)};return l.addEventListener("scroll",h,{passive:!0}),c(l.scrollTop),()=>{l.removeEventListener("scroll",h)}},[]);let r=Math.min(i/m,1),u="";r>.1?(r=Math.max(r,.6),u=y.alpha(n.palette.text.primary,r)):u=o||"#EEEEEE";const f=r<.7;return e.jsx(ie,{logo:e.jsx(Fe,{logo:t}),...a,sx:{position:"fixed !important",top:0,left:0,right:0,zIndex:n.zIndex.appBar,backgroundColor:"transparent !important","&::before":{content:'""',position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:-1,backgroundColor:y.alpha(n.palette.background.default,r),backdropFilter:r>=.6?"blur(10px)":"blur(0px)",transition:"backgroundColor 0.3s ease-in-out"},transition:"color 0.3s ease-in-out",".navmenu-root>.navmenu-sub>span,\n .navmenu-root>.navmenu-item,\n .header-addons>button,\n .header-addons>a,\n .header-addons>div>button":{color:`${u} !important`},".header-logo":{color:`${u} !important`},"& .navmenu--horizontal":{bgcolor:"transparent !important"},".header-logo > div":{filter:`invert(${f?1:0})`,transition:"filter 0.3s ease-in-out"}}})}const le=oe.default(y.Button)``;exports.Home=Te;exports.HomeView=ae;exports.Loading=se;exports.PageRoutes=N;exports.PageView=H;exports.PageViewByPath=Oe;exports.PageViewWithDataSource=G;exports.TranslucentHeader=ce;