@blocklet/ui-react 3.1.7 → 3.1.8

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.
@@ -1,34 +1,34 @@
1
- import { jsxs as v, jsx as a } from "react/jsx-runtime";
2
- import { useLocaleContext as j } from "@arcblock/ux/lib/Locale/context";
3
- import { Dialog as C, useTheme as D, useMediaQuery as E, Box as R, CircularProgress as M, Typography as A } from "@mui/material";
4
- import F from "lodash/merge";
1
+ import { jsxs as x, jsx as a } from "react/jsx-runtime";
2
+ import { useLocaleContext as T } from "@arcblock/ux/lib/Locale/context";
3
+ import { Dialog as R, useTheme as j, useMediaQuery as D, Box as v, CircularProgress as E, Typography as M } from "@mui/material";
4
+ import P from "lodash/merge";
5
5
  import t from "prop-types";
6
- import { useState as b, useRef as y, useEffect as s } from "react";
7
- import { withQuery as B, joinURL as Q } from "ufo";
8
- const _ = "/.well-known/service/onboard/bind-account";
9
- function H({
10
- onFinished: z = () => {
6
+ import { useState as h, useRef as b, useEffect as s } from "react";
7
+ import { withQuery as A, joinURL as F } from "ufo";
8
+ const B = "/.well-known/service/onboard/bind-account";
9
+ function Q({
10
+ onFinished: y = () => {
11
11
  },
12
12
  show: n = !1,
13
- onChangeVisible: k = () => {
13
+ onChangeVisible: C = () => {
14
14
  },
15
15
  loadingText: l = "",
16
- defaultPath: c = _,
16
+ defaultPath: c = B,
17
17
  ...d
18
18
  }) {
19
- const [r, i] = b(n), [u, f] = b(!1), [I, m] = b(() => {
19
+ const [r, i] = h(n), [u, f] = h(!1), [k, m] = h(() => {
20
20
  const e = localStorage.getItem("wizard-current-url");
21
21
  return e?.includes("/.well-known/service/onboard") ? e : c;
22
- }), x = y(z), p = y(), w = y(null), { locale: L } = j(), S = D(), g = E(S.breakpoints.down("sm"));
23
- if (x.current = z, p.current = () => {
24
- if (w.current?.contentWindow)
22
+ }), z = b(y), p = b(), g = b(null), { locale: I } = T(), L = j(), w = D(L.breakpoints.down("sm"));
23
+ if (z.current = y, p.current = () => {
24
+ if (g.current?.contentWindow)
25
25
  try {
26
- const o = new URL(w.current.contentWindow.location.href).pathname;
26
+ const o = new URL(g.current.contentWindow.location.href).pathname;
27
27
  localStorage.setItem("wizard-current-url", o), m(o);
28
28
  } catch (e) {
29
29
  m(c), console.warn("Failed to save wizard URL:", e);
30
30
  }
31
- localStorage.setItem("wizard-completed", "true"), i(!1), k(!1);
31
+ localStorage.setItem("wizard-completed", "true"), i(!1), C(!1);
32
32
  }, s(() => {
33
33
  n !== r && i(n);
34
34
  }, [n]), s(() => {
@@ -37,17 +37,13 @@ function H({
37
37
  const e = (o) => {
38
38
  if (o.origin !== window.location.origin)
39
39
  return;
40
- const { type: W, data: T } = o.data || {};
41
- switch (W) {
40
+ const { type: U, data: W } = o.data || {};
41
+ switch (U) {
42
42
  case "wizard.loaded":
43
43
  f(!0);
44
44
  break;
45
45
  case "wizard.finished": {
46
- i(!1), m(c), localStorage.removeItem("wizard-current-url"), localStorage.setItem("wizard-completed", "true");
47
- const h = x.current?.(T);
48
- h instanceof Promise ? h.then((P) => {
49
- P !== !1 && window.location.reload();
50
- }) : h !== !1 && window.location.reload();
46
+ i(!1), m(c), localStorage.removeItem("wizard-current-url"), localStorage.setItem("wizard-completed", "true"), z.current?.(W);
51
47
  break;
52
48
  }
53
49
  case "wizard.close": {
@@ -63,20 +59,20 @@ function H({
63
59
  localStorage.getItem("wizard-completed") || i(!0);
64
60
  }, []), !r)
65
61
  return null;
66
- const U = B(Q(window.location.origin, I), {
67
- locale: L
62
+ const S = A(F(window.location.origin, k), {
63
+ locale: I
68
64
  });
69
- return /* @__PURE__ */ v(
70
- C,
65
+ return /* @__PURE__ */ x(
66
+ R,
71
67
  {
72
68
  id: "wizard-dialog",
73
69
  open: r,
74
70
  onClose: () => p.current(),
75
71
  fullWidth: !0,
76
- maxWidth: g ? !1 : "md",
77
- fullScreen: g,
72
+ maxWidth: w ? !1 : "md",
73
+ fullScreen: w,
78
74
  ...d,
79
- slotProps: F(
75
+ slotProps: P(
80
76
  {},
81
77
  {
82
78
  paper: {
@@ -85,7 +81,7 @@ function H({
85
81
  borderRadius: 0,
86
82
  position: "relative",
87
83
  overflow: "hidden",
88
- ...g ? { borderRadius: 0 } : {
84
+ ...w ? { borderRadius: 0 } : {
89
85
  borderRadius: 1,
90
86
  height: "720px"
91
87
  }
@@ -104,9 +100,9 @@ function H({
104
100
  /* @__PURE__ */ a(
105
101
  "iframe",
106
102
  {
107
- ref: w,
103
+ ref: g,
108
104
  id: "wizard-iframe",
109
- src: U,
105
+ src: S,
110
106
  title: "Setup Wizard",
111
107
  style: {
112
108
  width: "100%",
@@ -121,7 +117,7 @@ function H({
121
117
  }
122
118
  ),
123
119
  u ? null : /* @__PURE__ */ a(
124
- R,
120
+ v,
125
121
  {
126
122
  sx: {
127
123
  position: "absolute",
@@ -134,9 +130,9 @@ function H({
134
130
  alignItems: "center",
135
131
  bgcolor: "background.paper"
136
132
  },
137
- children: /* @__PURE__ */ v(R, { sx: { display: "flex", alignItems: "center", flexDirection: "column", gap: 1 }, children: [
138
- /* @__PURE__ */ a(M, {}),
139
- typeof l == "string" ? /* @__PURE__ */ a(A, { variant: "body1", children: l }) : l
133
+ children: /* @__PURE__ */ x(v, { sx: { display: "flex", alignItems: "center", flexDirection: "column", gap: 1 }, children: [
134
+ /* @__PURE__ */ a(E, {}),
135
+ typeof l == "string" ? /* @__PURE__ */ a(M, { variant: "body1", children: l }) : l
140
136
  ] })
141
137
  }
142
138
  )
@@ -144,14 +140,14 @@ function H({
144
140
  }
145
141
  );
146
142
  }
147
- H.propTypes = {
143
+ Q.propTypes = {
148
144
  onFinished: t.func,
149
145
  show: t.bool,
150
146
  onChangeVisible: t.func,
151
147
  loadingText: t.node,
152
148
  defaultPath: t.string,
153
- ...C.propTypes
149
+ ...R.propTypes
154
150
  };
155
151
  export {
156
- H as default
152
+ Q as default
157
153
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/ui-react",
3
- "version": "3.1.7",
3
+ "version": "3.1.8",
4
4
  "description": "Some useful front-end web components that can be used in Blocklets.",
5
5
  "keywords": [
6
6
  "react",
@@ -35,9 +35,9 @@
35
35
  "dependencies": {
36
36
  "@abtnode/constant": "^1.16.47",
37
37
  "@abtnode/util": "^1.16.47",
38
- "@arcblock/bridge": "3.1.7",
39
- "@arcblock/icons": "3.1.7",
40
- "@arcblock/react-hooks": "3.1.7",
38
+ "@arcblock/bridge": "3.1.8",
39
+ "@arcblock/icons": "3.1.8",
40
+ "@arcblock/react-hooks": "3.1.8",
41
41
  "@arcblock/ws": "^1.21.2",
42
42
  "@blocklet/constant": "^1.16.47",
43
43
  "@blocklet/did-space-react": "^1.1.14",
@@ -84,7 +84,7 @@
84
84
  "access": "public"
85
85
  },
86
86
  "devDependencies": {
87
- "@arcblock/did-connect-react": "3.1.7",
87
+ "@arcblock/did-connect-react": "3.1.8",
88
88
  "@types/dompurify": "^3.2.0",
89
89
  "@types/ua-parser-js": "^0.7.39",
90
90
  "@types/validator": "^13.15.2",
@@ -92,5 +92,5 @@
92
92
  "jest": "^29.7.0",
93
93
  "unbuild": "^2.0.0"
94
94
  },
95
- "gitHead": "8f0b8300d7c73a1d82f7b76d3e7c293f921b260c"
95
+ "gitHead": "bb291c7f0f1afa39ca3dc07471c63b118a377cbe"
96
96
  }
@@ -82,16 +82,7 @@ export default function WizardModal({
82
82
  setCurrentUrl(defaultPath);
83
83
  localStorage.removeItem('wizard-current-url');
84
84
  localStorage.setItem('wizard-completed', 'true');
85
- const result = onFinishedRef.current?.(data);
86
- if (result instanceof Promise) {
87
- result.then((reload) => {
88
- if (reload !== false) {
89
- window.location.reload();
90
- }
91
- });
92
- } else if (result !== false) {
93
- window.location.reload();
94
- }
85
+ onFinishedRef.current?.(data);
95
86
  break;
96
87
  }
97
88
  case 'wizard.close': {