@arcblock/did-connect-react 3.2.18 → 3.3.0

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 (52) hide show
  1. package/docs/assets/diagram/core-components-session-provider-01.ja.jpg +0 -0
  2. package/docs/assets/diagram/core-components-session-provider-01.jpg +0 -0
  3. package/docs/assets/diagram/core-components-session-provider-01.zh-TW.jpg +0 -0
  4. package/docs/assets/diagram/core-components-session-provider-01.zh.jpg +0 -0
  5. package/docs/assets/diagram/did-connect-diagram-0.ja.jpg +0 -0
  6. package/docs/assets/diagram/did-connect-diagram-0.jpg +0 -0
  7. package/docs/assets/diagram/did-connect-diagram-0.zh-TW.jpg +0 -0
  8. package/docs/assets/diagram/did-connect-diagram-0.zh.jpg +0 -0
  9. package/docs/assets/diagram/overview-01.ja.jpg +0 -0
  10. package/docs/assets/diagram/overview-01.jpg +0 -0
  11. package/docs/assets/diagram/overview-01.zh-TW.jpg +0 -0
  12. package/docs/assets/diagram/overview-01.zh.jpg +0 -0
  13. package/docs/assets/diagram/use-connect-diagram-0.ja.jpg +0 -0
  14. package/docs/assets/diagram/use-connect-diagram-0.jpg +0 -0
  15. package/docs/assets/diagram/use-connect-diagram-0.zh-TW.jpg +0 -0
  16. package/docs/assets/diagram/use-connect-diagram-0.zh.jpg +0 -0
  17. package/docs/core-components-did-connect.ja.md +3 -50
  18. package/docs/core-components-did-connect.md +5 -52
  19. package/docs/core-components-did-connect.zh-TW.md +3 -50
  20. package/docs/core-components-did-connect.zh.md +3 -50
  21. package/docs/core-components-session-provider.ja.md +3 -45
  22. package/docs/core-components-session-provider.md +3 -45
  23. package/docs/core-components-session-provider.zh-TW.md +3 -45
  24. package/docs/core-components-session-provider.zh.md +3 -45
  25. package/docs/hooks-use-connect.ja.md +3 -39
  26. package/docs/hooks-use-connect.md +4 -40
  27. package/docs/hooks-use-connect.zh-TW.md +3 -39
  28. package/docs/hooks-use-connect.zh.md +3 -39
  29. package/docs/overview.ja.md +3 -45
  30. package/docs/overview.md +3 -45
  31. package/docs/overview.zh-TW.md +3 -45
  32. package/docs/overview.zh.md +3 -45
  33. package/lib/Connect/assets/locale.js +4 -2
  34. package/lib/Connect/components/login-item/connect-choose-list.js +2 -2
  35. package/lib/Connect/components/login-item/connect-provider-list.js +299 -0
  36. package/lib/Connect/components/login-item/login-method-item.js +42 -41
  37. package/lib/Connect/hooks/provider-list.js +50 -0
  38. package/lib/Connect/index.js +180 -196
  39. package/lib/OAuth/context.js +33 -32
  40. package/lib/Session/hooks/use-verify.js +1 -1
  41. package/lib/Session/libs/locales.js +3 -3
  42. package/lib/package.json.js +1 -1
  43. package/package.json +9 -9
  44. package/src/Connect/assets/locale.js +2 -0
  45. package/src/Connect/components/login-item/connect-choose-list.jsx +5 -5
  46. package/src/Connect/components/login-item/connect-provider-list.jsx +392 -0
  47. package/src/Connect/components/login-item/login-method-item.jsx +31 -28
  48. package/src/Connect/hooks/provider-list.js +127 -0
  49. package/src/Connect/index.jsx +8 -27
  50. package/src/OAuth/context.jsx +10 -2
  51. package/src/Session/hooks/use-verify.jsx +1 -1
  52. package/src/Session/libs/locales.js +3 -3
@@ -1,25 +1,26 @@
1
- import { jsxs as i, jsx as o, Fragment as x } from "react/jsx-runtime";
2
- import { useTheme as g, Box as r, Typography as l } from "@mui/material";
3
- import { Icon as s } from "@iconify/react";
4
- import { isValidElement as y } from "react";
5
- import e from "prop-types";
6
- import { mergeSx as c } from "@arcblock/ux/lib/Util/style";
7
- import u from "@iconify-icons/material-symbols/arrow-right-alt-rounded";
8
- function b({
9
- title: m,
10
- description: n = null,
11
- icon: t,
1
+ import { jsxs as t, jsx as e, Fragment as x } from "react/jsx-runtime";
2
+ import { useTheme as g, Box as r, Tooltip as y, Typography as s } from "@mui/material";
3
+ import { Icon as c } from "@iconify/react";
4
+ import { isValidElement as u } from "react";
5
+ import o from "prop-types";
6
+ import { mergeSx as m } from "@arcblock/ux/lib/Util/style";
7
+ import b from "@iconify-icons/material-symbols/arrow-right-alt-rounded";
8
+ function _({
9
+ title: n,
10
+ description: a = null,
11
+ icon: i,
12
12
  iconScale: p = 0.95,
13
13
  slotProps: d = {},
14
14
  mode: f = "normal",
15
- ...a
15
+ ...l
16
16
  }) {
17
17
  const h = g();
18
- return /* @__PURE__ */ i(
18
+ return /* @__PURE__ */ t(
19
19
  r,
20
20
  {
21
- ...a,
22
- sx: c(
21
+ ...l,
22
+ className: "arc-login-item",
23
+ sx: m(
23
24
  {
24
25
  display: "flex",
25
26
  alignItems: "center",
@@ -46,14 +47,14 @@ function b({
46
47
  }
47
48
  }
48
49
  },
49
- a?.sx
50
+ l?.sx
50
51
  ),
51
52
  children: [
52
- /* @__PURE__ */ o(
53
+ /* @__PURE__ */ e(y, { title: n, children: /* @__PURE__ */ e(
53
54
  r,
54
55
  {
55
56
  className: "arc-login-item__icon",
56
- sx: c(
57
+ sx: m(
57
58
  {
58
59
  display: "flex",
59
60
  justifyContent: "center",
@@ -62,11 +63,11 @@ function b({
62
63
  },
63
64
  d?.icon?.sx
64
65
  ),
65
- children: y(t) ? t : /* @__PURE__ */ o(
66
+ children: u(i) ? i : /* @__PURE__ */ e(
66
67
  r,
67
68
  {
68
- component: s,
69
- icon: t,
69
+ component: c,
70
+ icon: i,
70
71
  sx: {
71
72
  transform: `scale(${p})`,
72
73
  width: 24,
@@ -75,11 +76,11 @@ function b({
75
76
  }
76
77
  )
77
78
  }
78
- ),
79
- f === "normal" ? /* @__PURE__ */ i(x, { children: [
80
- /* @__PURE__ */ i(r, { sx: { display: "flex", flexDirection: "column", flex: 1 }, children: [
81
- /* @__PURE__ */ o(
82
- l,
79
+ ) }),
80
+ f === "normal" ? /* @__PURE__ */ t(x, { children: [
81
+ /* @__PURE__ */ t(r, { className: "arc-login-item__body", sx: { display: "flex", flexDirection: "column", flex: 1 }, children: [
82
+ /* @__PURE__ */ e(
83
+ s,
83
84
  {
84
85
  sx: {
85
86
  fontSize: 14,
@@ -87,26 +88,26 @@ function b({
87
88
  color: "text.primary",
88
89
  whiteSpace: "nowrap"
89
90
  },
90
- children: m
91
+ children: n
91
92
  }
92
93
  ),
93
- n ? /* @__PURE__ */ o(
94
- l,
94
+ a ? /* @__PURE__ */ e(
95
+ s,
95
96
  {
96
97
  sx: {
97
98
  color: "text.secondary",
98
99
  fontSize: 12,
99
100
  lineHeight: 1
100
101
  },
101
- children: n
102
+ children: a
102
103
  }
103
104
  ) : null
104
105
  ] }),
105
- /* @__PURE__ */ o(
106
- s,
106
+ /* @__PURE__ */ e(
107
+ c,
107
108
  {
108
109
  className: "other-item-icon",
109
- icon: u,
110
+ icon: b,
110
111
  fontSize: "1.3rem",
111
112
  color: h.palette.primary.main
112
113
  }
@@ -116,14 +117,14 @@ function b({
116
117
  }
117
118
  );
118
119
  }
119
- b.propTypes = {
120
- title: e.string.isRequired,
121
- description: e.string,
122
- icon: e.any.isRequired,
123
- iconScale: e.number,
124
- slotProps: e.object,
125
- mode: e.oneOf(["simple", "normal"])
120
+ _.propTypes = {
121
+ title: o.string.isRequired,
122
+ description: o.string,
123
+ icon: o.any.isRequired,
124
+ iconScale: o.number,
125
+ slotProps: o.object,
126
+ mode: o.oneOf(["mini", "simple", "normal"])
126
127
  };
127
128
  export {
128
- b as default
129
+ _ as default
129
130
  };
@@ -0,0 +1,50 @@
1
+ import { useBrowser as m } from "@arcblock/react-hooks";
2
+ import { useRequest as v, useCreation as u } from "ahooks";
3
+ import c from "lodash/isNil";
4
+ import { LOGIN_PROVIDER as o } from "@arcblock/ux/lib/Util/constant";
5
+ import { getFederatedEnabled as w, getMaster as P, getBlockletData as E } from "@arcblock/ux/lib/Util/federated";
6
+ const k = async ({ sourceAppPid: n }) => {
7
+ const t = globalThis?.blocklet;
8
+ if (!t)
9
+ return {
10
+ [o.WALLET]: {
11
+ order: 0,
12
+ enabled: !0,
13
+ showQrcode: !0
14
+ },
15
+ [o.PASSKEY]: {
16
+ order: 1,
17
+ enabled: !0
18
+ }
19
+ };
20
+ const s = w(t), e = P(t);
21
+ return s && e?.appPid && n === e?.appPid ? (await E(e.appUrl))?.settings?.authentication || {} : t?.settings?.authentication || {};
22
+ }, y = async ({ sourceAppPid: n } = {}) => {
23
+ const t = await k({ sourceAppPid: n });
24
+ return Object.entries(t).map(([e, r]) => ({ ...r, provider: e })).filter((e) => e.enabled).sort((e, r) => !c(e?.order) && !c(r?.order) ? e.order - r.order : c(e?.order) ? 1 : -1);
25
+ };
26
+ function I({
27
+ allowWallet: n = !0,
28
+ passkeyBehavior: t = "none",
29
+ action: s,
30
+ sourceAppPid: e,
31
+ mode: r = "dialog",
32
+ blocklet: L = globalThis.blocklet,
33
+ isSmallView: f = !1
34
+ }) {
35
+ const h = ["login", "invite", "connect-to-did-space", "connect-to-did-domain", "destroy-self"], l = m(), { data: g = [] } = v(
36
+ async () => await y({ sourceAppPid: e }),
37
+ { refreshDeps: [e] }
38
+ ), d = u(() => g.filter((i) => i.name === o.WALLET ? n : i.name === o.PASSKEY ? t !== "none" && !l.wallet && !l.arcSphere : i.name === o.EMAIL ? L?.settings?.notification?.email?.enabled ?? !1 : !(i.type === "oauth" && !h.includes(s))), [g]), p = u(() => {
39
+ const a = r === "drawer" || f && l.mobile.any;
40
+ return globalThis?.blocklet ? !!(d.find((b) => b.provider === o.WALLET)?.showQrcode !== !0 || a) : !!a;
41
+ }, [r, f, d]);
42
+ return {
43
+ hideChooseList: u(() => !1),
44
+ hideQRCode: p,
45
+ providerList: d
46
+ };
47
+ }
48
+ export {
49
+ I as default
50
+ };