@blocklet/discuss-kit-ux 2.1.210 → 2.1.211

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,19 @@
1
+ /// <reference types="react" />
2
+ type PaywallType = 'blog' | 'post' | 'bookmark' | 'doc';
3
+ interface PaywallProps {
4
+ children?: React.ReactNode;
5
+ cta: React.ReactNode;
6
+ }
7
+ interface SubscriptionPaywallProps {
8
+ fetchPaymentLink: (params: {
9
+ type: PaywallType;
10
+ redirect: string;
11
+ }) => Promise<{
12
+ link: string;
13
+ }>;
14
+ children?: React.ReactNode;
15
+ type: PaywallType;
16
+ }
17
+ export declare function Paywall({ children, cta, ...rest }: PaywallProps): import("react/jsx-runtime").JSX.Element;
18
+ export declare function SubscriptionPaywall({ type, fetchPaymentLink, ...rest }: SubscriptionPaywallProps): import("react/jsx-runtime").JSX.Element;
19
+ export {};
@@ -20,3 +20,4 @@ export declare const isInDiscussKitApp: boolean | "" | undefined;
20
20
  export declare const openProfile: (did: string, newTab?: boolean) => void;
21
21
  export declare const randomId: () => string;
22
22
  export declare const getDiscussKitClientId: () => string;
23
+ export declare const getPaymentKitMountPoint: () => string | undefined;
@@ -4,7 +4,7 @@ import { OnContentChangePlugin } from "@blocklet/editor/lib/ext/OnContentChangeP
4
4
  import { CtrlsShortcutPlugin } from "@blocklet/editor/lib/ext/ShortcutPlugin";
5
5
  import { SafeAreaPlugin } from "@blocklet/editor/lib/ext/SafeAreaPlugin";
6
6
  import { lazyRetry } from "@arcblock/ux/lib/Util";
7
- import { i as inferInitialEditorState, I as ImagePathFixerPlugin, V as VideoPathFixerPlugin, a as isEmptyContent, s as stringify, g as getExcerptSync } from "./index-Cm1TeDDQ.mjs";
7
+ import { i as inferInitialEditorState, I as ImagePathFixerPlugin, V as VideoPathFixerPlugin, a as isEmptyContent, s as stringify, g as getExcerptSync } from "./index-DoRK59kW.mjs";
8
8
  const BlockletEditor = lazyRetry(() => import("@blocklet/editor"));
9
9
  const Root = styled(Box)`
10
10
  .be-editable,
@@ -1,7 +1,7 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- var _a, _b, _c, _d, _e, _f;
4
+ var _a, _b, _c, _d, _e, _f, _i, _j;
5
5
  import { Labels2, LabelPicker } from "@blocklet/labels";
6
6
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
7
7
  import { useTheme, ThemeProvider, styled as styled$2 } from "@mui/material/styles";
@@ -369,6 +369,11 @@ const getDiscussKitClientId = () => {
369
369
  }
370
370
  return window.__discuss_kit_client_id__;
371
371
  };
372
+ const getPaymentKitMountPoint = () => {
373
+ var _a2, _b2;
374
+ const info = (_b2 = (_a2 = window.blocklet) == null ? void 0 : _a2.componentMountPoints) == null ? void 0 : _b2.find((x) => x.did === "z2qaCNvKMv5GjouKdcDWexv6WqtHbpNPQDnAk");
375
+ return info == null ? void 0 : info.mountPoint;
376
+ };
372
377
  const utils = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
373
378
  __proto__: null,
374
379
  blockletExists,
@@ -380,6 +385,7 @@ const utils = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePropert
380
385
  getDraftSessionKeyPrefix,
381
386
  getExcerptFromLexicalContent,
382
387
  getLastItem,
388
+ getPaymentKitMountPoint,
383
389
  getPreference,
384
390
  getResizedAvatar,
385
391
  isInDiscussKitApp,
@@ -4918,7 +4924,7 @@ function Back({ url, fallbackUrl, iconOnly, sx, icon, ...rest }) {
4918
4924
  }
4919
4925
  const tablerSend = (props) => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", width: "1.2em", height: "1.2em", ...props, children: /* @__PURE__ */ jsx("path", { fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M10 14L21 3m0 0l-6.5 18a.55.55 0 0 1-1 0L10 14l-7-3.5a.55.55 0 0 1 0-1z" }) });
4920
4926
  const tablerLetterCase = (props) => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", width: "1.2em", height: "1.2em", ...props, children: /* @__PURE__ */ jsx("path", { fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M14 15.5a3.5 3.5 0 1 0 7 0a3.5 3.5 0 1 0-7 0M3 19V8.5a3.5 3.5 0 0 1 7 0V19m-7-6h7m11-1v7" }) });
4921
- const Editor = lazyRetry(() => import("./editor-ft4Hsx-A.mjs"));
4927
+ const Editor = lazyRetry(() => import("./editor-DVSYQ5XN.mjs"));
4922
4928
  function LazyEditor(props) {
4923
4929
  const fallback2 = /* @__PURE__ */ jsxs(Box, { sx: { px: 3 }, children: [
4924
4930
  /* @__PURE__ */ jsx(Skeleton, {}),
@@ -12432,6 +12438,109 @@ function SegmentedControl({ value, options, onChange, sx, ...rest }) {
12432
12438
  }
12433
12439
  ) });
12434
12440
  }
12441
+ const paymentKitMountPoint = getPaymentKitMountPoint();
12442
+ const buttonDisabledProps = {
12443
+ color: "inherit",
12444
+ variant: "contained",
12445
+ sx: {
12446
+ color: "grey.800",
12447
+ cursor: "not-allowed"
12448
+ }
12449
+ };
12450
+ const isBlurSubscriptionPublicType = ((_j = (_i = window == null ? void 0 : window.blocklet) == null ? void 0 : _i.preferences) == null ? void 0 : _j.subscriptionPublicType) === "blur";
12451
+ function Paywall({ children, cta, ...rest }) {
12452
+ return /* @__PURE__ */ jsxs(Box, { ...rest, children: [
12453
+ /* @__PURE__ */ jsx(
12454
+ Box,
12455
+ {
12456
+ sx: {
12457
+ ...isBlurSubscriptionPublicType && {
12458
+ maxHeight: "70vh",
12459
+ overflow: "hidden",
12460
+ position: "relative"
12461
+ }
12462
+ },
12463
+ children
12464
+ }
12465
+ ),
12466
+ /* @__PURE__ */ jsx(
12467
+ Box,
12468
+ {
12469
+ className: "paywall",
12470
+ sx: {
12471
+ display: "flex",
12472
+ flexDirection: "column",
12473
+ alignItems: "center",
12474
+ py: 6,
12475
+ color: "#fff",
12476
+ bgcolor: "#000",
12477
+ borderRadius: 2,
12478
+ position: "sticky",
12479
+ bottom: 16,
12480
+ // 向上白色渐变背景
12481
+ ":before": {
12482
+ content: '""',
12483
+ position: "absolute",
12484
+ left: 0,
12485
+ right: 0,
12486
+ top: "-50%",
12487
+ height: "50%",
12488
+ background: "linear-gradient(transparent, rgba(255, 255, 255, 0.9) 85%)"
12489
+ }
12490
+ },
12491
+ children: cta
12492
+ }
12493
+ )
12494
+ ] });
12495
+ }
12496
+ function SubscriptionPaywall({ type, fetchPaymentLink, ...rest }) {
12497
+ const { session } = useSessionContext();
12498
+ const { t } = useLocaleContext();
12499
+ const { data, loading } = useRequest(() => fetchPaymentLink({ type, redirect: window.location.href }));
12500
+ const paymentLink = paymentKitMountPoint && (data == null ? void 0 : data.link) ? joinURL(paymentKitMountPoint, data.link) : null;
12501
+ const loginAndReloadPage = () => {
12502
+ session.login(() => {
12503
+ window.location.reload();
12504
+ });
12505
+ };
12506
+ const isDisabled = !paymentLink && !loading;
12507
+ return /* @__PURE__ */ jsx(
12508
+ Paywall,
12509
+ {
12510
+ ...rest,
12511
+ cta: /* @__PURE__ */ jsxs(Fragment, { children: [
12512
+ /* @__PURE__ */ jsx(Typography$1, { variant: "h2", sx: { fontWeight: "bold" }, children: t("paywall.subscription.title") }),
12513
+ /* @__PURE__ */ jsx(Typography$1, { variant: "body1", sx: { maxWidth: 600, mt: 1, mx: 4, textAlign: "center" }, children: t("paywall.subscription.desc") }),
12514
+ /* @__PURE__ */ jsx(Box, { sx: { mt: 6 }, children: /* @__PURE__ */ jsxs(
12515
+ Button$1,
12516
+ {
12517
+ href: paymentLink || "#",
12518
+ color: "primary",
12519
+ variant: "contained",
12520
+ size: "large",
12521
+ ...isDisabled ? buttonDisabledProps : {},
12522
+ children: [
12523
+ t("paywall.subscription.subscribeNow"),
12524
+ loading && /* @__PURE__ */ jsx(CircularProgress, { size: 16, sx: { ml: 1, color: "#fff" } })
12525
+ ]
12526
+ }
12527
+ ) }),
12528
+ !(session == null ? void 0 : session.user) && /* @__PURE__ */ jsxs(Typography$1, { variant: "body1", sx: { mt: 2, color: "grey.400" }, children: [
12529
+ /* @__PURE__ */ jsx(Box, { component: "span", sx: { display: "inline-block", mr: 1 }, children: t("paywall.subscription.alreadySubscribe") }),
12530
+ /* @__PURE__ */ jsx(
12531
+ Box,
12532
+ {
12533
+ component: "span",
12534
+ sx: { textDecoration: "underline", fontWeight: "bold", cursor: "pointer" },
12535
+ onClick: loginAndReloadPage,
12536
+ children: t("common.connect")
12537
+ }
12538
+ )
12539
+ ] })
12540
+ ] })
12541
+ }
12542
+ );
12543
+ }
12435
12544
  export {
12436
12545
  ChatListInWallet as $,
12437
12546
  Avatar as A,
@@ -12473,6 +12582,8 @@ export {
12473
12582
  useConfirm as a8,
12474
12583
  ConfirmProvider as a9,
12475
12584
  useArcSphereDialog as aA,
12585
+ Paywall as aB,
12586
+ SubscriptionPaywall as aC,
12476
12587
  SecureLabelPicker as aa,
12477
12588
  useApiErrorHandler as ab,
12478
12589
  useDefaultApiErrorHandler as ac,
package/dist/index.d.ts CHANGED
@@ -30,3 +30,4 @@ export * from './ws';
30
30
  export * from './components/toast';
31
31
  export * from './components/arcsphere';
32
32
  export { default as RelativeTime } from './components/shared/relative-time';
33
+ export * from './components/paywall';
package/dist/index.es.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export * from "@blocklet/labels";
2
- import { U, o, X, A, n, ae, B, G, L, K, N, aq, Z, Y, a0, _, $, a2, x, C, y, z, F, a6, a7, ai, a9, Q, T, ad, D, ah, ag, J, H, b, m, af, M, P, ap, w, v, R, S, aa, ar, q, a3, a5, aj, am, al, az, as, O, an, at, aw, ax, l, ay, h, p, r, k, av, t, j, ab, aA, W, c, a1, E, a8, ac, e, u, ao, d, au, a4, ak, f } from "./index-Cm1TeDDQ.mjs";
2
+ import { U, o, X, A, n, ae, B, G, L, K, N, aq, Z, Y, a0, _, $, a2, x, C, y, z, F, a6, a7, ai, a9, Q, T, ad, D, ah, ag, J, H, b, m, af, M, P, aB, ap, w, v, R, S, aa, ar, aC, q, a3, a5, aj, am, al, az, as, O, an, at, aw, ax, l, ay, h, p, r, k, av, t, j, ab, aA, W, c, a1, E, a8, ac, e, u, ao, d, au, a4, ak, f } from "./index-DoRK59kW.mjs";
3
3
  import "react/jsx-runtime";
4
4
  import "react";
5
5
  import "@mui/material/Box";
@@ -49,6 +49,7 @@ export {
49
49
  af as LazyEditor,
50
50
  M as Menu,
51
51
  P as Pagination,
52
+ aB as Paywall,
52
53
  ap as PointUpProvider,
53
54
  w as Post,
54
55
  v as PostContent,
@@ -56,6 +57,7 @@ export {
56
57
  S as ScrollableEditorWrapper,
57
58
  aa as SecureLabelPicker,
58
59
  ar as SegmentedControl,
60
+ aC as SubscriptionPaywall,
59
61
  q as SystemUser,
60
62
  a3 as UnreadNotificationContext,
61
63
  a5 as UnreadNotificationProvider,
package/dist/index.umd.js CHANGED
@@ -5,7 +5,7 @@
5
5
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
6
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
7
7
 
8
- var _a, _b, _c, _d, _e, _f;
8
+ var _a, _b, _c, _d, _e, _f, _i, _j;
9
9
  const typography = {
10
10
  h1: {
11
11
  fontSize: "1.875rem",
@@ -293,6 +293,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
293
293
  }
294
294
  return window.__discuss_kit_client_id__;
295
295
  };
296
+ const getPaymentKitMountPoint = () => {
297
+ var _a2, _b2;
298
+ const info = (_b2 = (_a2 = window.blocklet) == null ? void 0 : _a2.componentMountPoints) == null ? void 0 : _b2.find((x) => x.did === "z2qaCNvKMv5GjouKdcDWexv6WqtHbpNPQDnAk");
299
+ return info == null ? void 0 : info.mountPoint;
300
+ };
296
301
  const utils = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
297
302
  __proto__: null,
298
303
  blockletExists,
@@ -304,6 +309,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
304
309
  getDraftSessionKeyPrefix,
305
310
  getExcerptFromLexicalContent,
306
311
  getLastItem,
312
+ getPaymentKitMountPoint,
307
313
  getPreference,
308
314
  getResizedAvatar,
309
315
  isInDiscussKitApp,
@@ -12356,6 +12362,109 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
12356
12362
  }
12357
12363
  ) });
12358
12364
  }
12365
+ const paymentKitMountPoint = getPaymentKitMountPoint();
12366
+ const buttonDisabledProps = {
12367
+ color: "inherit",
12368
+ variant: "contained",
12369
+ sx: {
12370
+ color: "grey.800",
12371
+ cursor: "not-allowed"
12372
+ }
12373
+ };
12374
+ const isBlurSubscriptionPublicType = ((_j = (_i = window == null ? void 0 : window.blocklet) == null ? void 0 : _i.preferences) == null ? void 0 : _j.subscriptionPublicType) === "blur";
12375
+ function Paywall({ children, cta, ...rest }) {
12376
+ return /* @__PURE__ */ jsxRuntime.jsxs(material.Box, { ...rest, children: [
12377
+ /* @__PURE__ */ jsxRuntime.jsx(
12378
+ material.Box,
12379
+ {
12380
+ sx: {
12381
+ ...isBlurSubscriptionPublicType && {
12382
+ maxHeight: "70vh",
12383
+ overflow: "hidden",
12384
+ position: "relative"
12385
+ }
12386
+ },
12387
+ children
12388
+ }
12389
+ ),
12390
+ /* @__PURE__ */ jsxRuntime.jsx(
12391
+ material.Box,
12392
+ {
12393
+ className: "paywall",
12394
+ sx: {
12395
+ display: "flex",
12396
+ flexDirection: "column",
12397
+ alignItems: "center",
12398
+ py: 6,
12399
+ color: "#fff",
12400
+ bgcolor: "#000",
12401
+ borderRadius: 2,
12402
+ position: "sticky",
12403
+ bottom: 16,
12404
+ // 向上白色渐变背景
12405
+ ":before": {
12406
+ content: '""',
12407
+ position: "absolute",
12408
+ left: 0,
12409
+ right: 0,
12410
+ top: "-50%",
12411
+ height: "50%",
12412
+ background: "linear-gradient(transparent, rgba(255, 255, 255, 0.9) 85%)"
12413
+ }
12414
+ },
12415
+ children: cta
12416
+ }
12417
+ )
12418
+ ] });
12419
+ }
12420
+ function SubscriptionPaywall({ type, fetchPaymentLink, ...rest }) {
12421
+ const { session } = useSessionContext();
12422
+ const { t } = context.useLocaleContext();
12423
+ const { data, loading } = ahooks.useRequest(() => fetchPaymentLink({ type, redirect: window.location.href }));
12424
+ const paymentLink = paymentKitMountPoint && (data == null ? void 0 : data.link) ? ufo.joinURL(paymentKitMountPoint, data.link) : null;
12425
+ const loginAndReloadPage = () => {
12426
+ session.login(() => {
12427
+ window.location.reload();
12428
+ });
12429
+ };
12430
+ const isDisabled = !paymentLink && !loading;
12431
+ return /* @__PURE__ */ jsxRuntime.jsx(
12432
+ Paywall,
12433
+ {
12434
+ ...rest,
12435
+ cta: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
12436
+ /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "h2", sx: { fontWeight: "bold" }, children: t("paywall.subscription.title") }),
12437
+ /* @__PURE__ */ jsxRuntime.jsx(material.Typography, { variant: "body1", sx: { maxWidth: 600, mt: 1, mx: 4, textAlign: "center" }, children: t("paywall.subscription.desc") }),
12438
+ /* @__PURE__ */ jsxRuntime.jsx(material.Box, { sx: { mt: 6 }, children: /* @__PURE__ */ jsxRuntime.jsxs(
12439
+ material.Button,
12440
+ {
12441
+ href: paymentLink || "#",
12442
+ color: "primary",
12443
+ variant: "contained",
12444
+ size: "large",
12445
+ ...isDisabled ? buttonDisabledProps : {},
12446
+ children: [
12447
+ t("paywall.subscription.subscribeNow"),
12448
+ loading && /* @__PURE__ */ jsxRuntime.jsx(material.CircularProgress, { size: 16, sx: { ml: 1, color: "#fff" } })
12449
+ ]
12450
+ }
12451
+ ) }),
12452
+ !(session == null ? void 0 : session.user) && /* @__PURE__ */ jsxRuntime.jsxs(material.Typography, { variant: "body1", sx: { mt: 2, color: "grey.400" }, children: [
12453
+ /* @__PURE__ */ jsxRuntime.jsx(material.Box, { component: "span", sx: { display: "inline-block", mr: 1 }, children: t("paywall.subscription.alreadySubscribe") }),
12454
+ /* @__PURE__ */ jsxRuntime.jsx(
12455
+ material.Box,
12456
+ {
12457
+ component: "span",
12458
+ sx: { textDecoration: "underline", fontWeight: "bold", cursor: "pointer" },
12459
+ onClick: loginAndReloadPage,
12460
+ children: t("common.connect")
12461
+ }
12462
+ )
12463
+ ] })
12464
+ ] })
12465
+ }
12466
+ );
12467
+ }
12359
12468
  const BlockletEditor = Util.lazyRetry(() => import("@blocklet/editor"));
12360
12469
  const Root = material.styled(material.Box)`
12361
12470
  .be-editable,
@@ -12435,6 +12544,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
12435
12544
  exports2.LazyEditor = LazyEditor;
12436
12545
  exports2.Menu = Menu;
12437
12546
  exports2.Pagination = Pagination;
12547
+ exports2.Paywall = Paywall;
12438
12548
  exports2.PointUpProvider = PointUpProvider;
12439
12549
  exports2.Post = PostComponent;
12440
12550
  exports2.PostContent = PostContent;
@@ -12442,6 +12552,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
12442
12552
  exports2.ScrollableEditorWrapper = ScrollableEditorWrapper;
12443
12553
  exports2.SecureLabelPicker = SecureLabelPicker;
12444
12554
  exports2.SegmentedControl = SegmentedControl;
12555
+ exports2.SubscriptionPaywall = SubscriptionPaywall;
12445
12556
  exports2.SystemUser = SystemUser;
12446
12557
  exports2.UnreadNotificationContext = UnreadNotificationContext;
12447
12558
  exports2.UnreadNotificationProvider = UnreadNotificationProvider;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/discuss-kit-ux",
3
- "version": "2.1.210",
3
+ "version": "2.1.211",
4
4
  "files": [
5
5
  "dist"
6
6
  ],
@@ -45,8 +45,8 @@
45
45
  "ufo": "^1.5.4",
46
46
  "unstated-next": "^1.1.0",
47
47
  "url-join": "^4.0.1",
48
- "@blocklet/editor": "^2.1.210",
49
- "@blocklet/labels": "^2.1.210"
48
+ "@blocklet/editor": "^2.1.211",
49
+ "@blocklet/labels": "^2.1.211"
50
50
  },
51
51
  "peerDependencies": {
52
52
  "@arcblock/did-connect": "^2.10.36",