@blocklet/pages-kit-inner-components 0.4.116 → 0.4.118

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 (41) hide show
  1. package/lib/cjs/add-component.js +8 -8
  2. package/lib/cjs/chunks/array-CeBRUkLo.js +441 -0
  3. package/lib/cjs/chunks/{config-color-C8L0QSPJ.js → config-color-C8kj-s2C.js} +1 -1
  4. package/lib/cjs/chunks/{draft-data-DPTVTTlh.js → draft-data-CRdesc3Z.js} +1 -1
  5. package/lib/cjs/chunks/home-DpGYsQ1r.js +38 -0
  6. package/lib/cjs/chunks/publish-button-DXSPVfAC.js +1 -0
  7. package/lib/cjs/chunks/site-state-BMf96RZL.js +57 -0
  8. package/lib/cjs/chunks/state-oc52fQ0j.js +1 -0
  9. package/lib/cjs/components.js +1 -1
  10. package/lib/cjs/home.js +1 -1
  11. package/lib/cjs/locales.js +1 -1
  12. package/lib/cjs/project-html.js +1 -1
  13. package/lib/cjs/resources.js +1 -1
  14. package/lib/cjs/setting.js +1 -1
  15. package/lib/cjs/site-state.js +1 -1
  16. package/lib/es/add-component.js +125 -120
  17. package/lib/es/chunks/array-k2vnX696.js +1966 -0
  18. package/lib/es/chunks/{config-color-JrBPRsTv.js → config-color-CXt_ZsC_.js} +1 -1
  19. package/lib/es/chunks/{draft-data-BFlmvWXx.js → draft-data-BwyMBf8Y.js} +1 -1
  20. package/lib/es/chunks/home-DAvVGR8Z.js +505 -0
  21. package/lib/es/chunks/publish-button-CxrZAPBF.js +295 -0
  22. package/lib/es/chunks/site-state-kjir-UCL.js +1718 -0
  23. package/lib/es/chunks/state-Dz3GnGWC.js +437 -0
  24. package/lib/es/components.js +1 -1
  25. package/lib/es/home.js +10 -8
  26. package/lib/es/locales.js +81 -17
  27. package/lib/es/project-html.js +1 -1
  28. package/lib/es/resources.js +1 -1
  29. package/lib/es/setting.js +2 -2
  30. package/lib/es/site-state.js +13 -12
  31. package/package.json +9 -9
  32. package/lib/cjs/chunks/array-BwGaBJVb.js +0 -513
  33. package/lib/cjs/chunks/home-CXupaCeO.js +0 -38
  34. package/lib/cjs/chunks/publish-button-TrJpN62K.js +0 -1
  35. package/lib/cjs/chunks/site-state-D15mduKB.js +0 -57
  36. package/lib/cjs/chunks/state-DDwYX2mu.js +0 -1
  37. package/lib/es/chunks/array-Chju-apt.js +0 -2142
  38. package/lib/es/chunks/home-47HCvpbj.js +0 -475
  39. package/lib/es/chunks/publish-button-DhT2I-bw.js +0 -282
  40. package/lib/es/chunks/site-state-DJ_KkVbi.js +0 -1548
  41. package/lib/es/chunks/state-BgKqNapt.js +0 -425
@@ -1,475 +0,0 @@
1
- import { jsx as o, jsxs as M } from "react/jsx-runtime";
2
- import { f as D, h as re, b as se, u as ie, d as ce } from "./state-BgKqNapt.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 F, 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 K } 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-Chju-apt.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(Ke, { mode: e, children: ({ state: t }) => /* @__PURE__ */ o(I, { mode: e, state: t }) });
158
- }
159
- return /* @__PURE__ */ o(Fe, { children: ({ state: r }) => /* @__PURE__ */ o(I, { mode: e, state: r }) });
160
- }
161
- const Fe = F(() => import("./draft-data-BFlmvWXx.js"));
162
- function Ke({
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 } = K(() => _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 = F(() => import("./publish-button-DhT2I-bw.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 } = K(() => {
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
- };