@blocklet/ui-react 2.9.20 → 2.9.21

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,5 +1,5 @@
1
1
  export default ComponentInstaller;
2
- declare function ComponentInstaller({ warnIcon, did, noPermissionMute, onInstalled, onError, children, closeByOutSize, onClose, fallback, roles, }: {
2
+ declare function ComponentInstaller({ warnIcon, did, noPermissionMute, onInstalled, onError, children, closeByOutSize, onClose, fallback, disabled, roles, }: {
3
3
  warnIcon: any;
4
4
  did: any;
5
5
  noPermissionMute: any;
@@ -9,10 +9,12 @@ declare function ComponentInstaller({ warnIcon, did, noPermissionMute, onInstall
9
9
  closeByOutSize: any;
10
10
  onClose: any;
11
11
  fallback: any;
12
+ disabled: any;
12
13
  roles?: string[] | undefined;
13
- }): import("react").JSX.Element;
14
+ }): any;
14
15
  declare namespace ComponentInstaller {
15
16
  namespace propTypes {
17
+ let disabled: any;
16
18
  let warnIcon: any;
17
19
  let did: any;
18
20
  let noPermissionMute: any;
@@ -25,6 +27,8 @@ declare namespace ComponentInstaller {
25
27
  let roles: any;
26
28
  }
27
29
  namespace defaultProps {
30
+ let disabled_1: boolean;
31
+ export { disabled_1 as disabled };
28
32
  let warnIcon_1: null;
29
33
  export { warnIcon_1 as warnIcon };
30
34
  let noPermissionMute_1: boolean;
@@ -21,6 +21,7 @@ function ComponentInstaller({
21
21
  closeByOutSize,
22
22
  onClose,
23
23
  fallback,
24
+ disabled,
24
25
  roles = ["owner", "admin"]
25
26
  }) {
26
27
  const { locale } = useLocaleContext();
@@ -46,6 +47,9 @@ function ComponentInstaller({
46
47
  window.location.reload();
47
48
  };
48
49
  const size = 60;
50
+ if (disabled) {
51
+ return children;
52
+ }
49
53
  return /* @__PURE__ */ jsx(SessionPermission, { session: sessionCtx?.session, roles, children: ({ hasPermission }) => {
50
54
  if (installed) {
51
55
  return children;
@@ -274,6 +278,7 @@ function ComponentInstaller({
274
278
  } });
275
279
  }
276
280
  ComponentInstaller.propTypes = {
281
+ disabled: PropTypes.bool,
277
282
  warnIcon: PropTypes.node,
278
283
  did: PropTypes.string.isRequired,
279
284
  noPermissionMute: PropTypes.bool,
@@ -286,6 +291,7 @@ ComponentInstaller.propTypes = {
286
291
  roles: PropTypes.array
287
292
  };
288
293
  ComponentInstaller.defaultProps = {
294
+ disabled: false,
289
295
  warnIcon: null,
290
296
  noPermissionMute: false,
291
297
  onInstalled: null,
@@ -6,8 +6,8 @@ declare function useComponentInstalled({ did, onInstalled, onError }: {
6
6
  }): {
7
7
  optionalComponent: any;
8
8
  installed: any;
9
- installUrl: string;
10
- storeUrl: string;
9
+ installUrl: any;
10
+ storeUrl: any;
11
11
  installStatus: string;
12
12
  setInstallStatus: import("react").Dispatch<import("react").SetStateAction<string>>;
13
13
  installStatusDone: boolean;
@@ -1,11 +1,14 @@
1
1
  import { AUTH_SERVICE_PREFIX } from '@arcblock/did-connect/lib/constant';
2
2
  import { useMemo, useRef, useState, useEffect } from 'react';
3
+ import urlJoin from 'url-join';
3
4
 
4
5
  function useComponentInstalled({ did, onInstalled, onError }) {
5
- const { optionalComponents, componentMountPoints } = window.blocklet;
6
+ const [installStatus, setInstallStatus] = useState('');
6
7
  const onInstalledRef = useRef({ onInstalled, onError });
7
8
  onInstalledRef.current = { onInstalled, onError };
8
9
 
10
+ const { optionalComponents, componentMountPoints } = window.blocklet;
11
+
9
12
  const optionalComponent = useMemo(() => {
10
13
  if (!optionalComponents || !optionalComponents.length) {
11
14
  return null;
@@ -22,9 +25,8 @@ function useComponentInstalled({ did, onInstalled, onError }) {
22
25
  return (componentMountPoints || []).find((item) => item.did === did);
23
26
  }, [optionalComponent, componentMountPoints, did]);
24
27
 
25
- const installUrl = `${window.blocklet.appUrl}/${AUTH_SERVICE_PREFIX}/admin/components?install-component=${did}`;
26
- const storeUrl = optionalComponent ? `${optionalComponent.meta.homepage}/blocklets/${did}` : '';
27
- const [installStatus, setInstallStatus] = useState('');
28
+ const installUrl = urlJoin(window.blocklet.appUrl, AUTH_SERVICE_PREFIX, `/admin/components?install-component=${did}`);
29
+ const storeUrl = optionalComponent ? urlJoin(optionalComponent.meta.homepage, 'blocklets', did) : '';
28
30
 
29
31
  useEffect(() => {
30
32
  const handle = (event) => {
@@ -1,5 +1,5 @@
1
1
  export default ComponentInstaller;
2
- declare function ComponentInstaller({ warnIcon, did, noPermissionMute, onInstalled, onError, children, closeByOutSize, onClose, fallback, roles, }: {
2
+ declare function ComponentInstaller({ warnIcon, did, noPermissionMute, onInstalled, onError, children, closeByOutSize, onClose, fallback, disabled, roles, }: {
3
3
  warnIcon: any;
4
4
  did: any;
5
5
  noPermissionMute: any;
@@ -9,10 +9,12 @@ declare function ComponentInstaller({ warnIcon, did, noPermissionMute, onInstall
9
9
  closeByOutSize: any;
10
10
  onClose: any;
11
11
  fallback: any;
12
+ disabled: any;
12
13
  roles?: string[] | undefined;
13
- }): import("react").JSX.Element;
14
+ }): any;
14
15
  declare namespace ComponentInstaller {
15
16
  namespace propTypes {
17
+ let disabled: any;
16
18
  let warnIcon: any;
17
19
  let did: any;
18
20
  let noPermissionMute: any;
@@ -25,6 +27,8 @@ declare namespace ComponentInstaller {
25
27
  let roles: any;
26
28
  }
27
29
  namespace defaultProps {
30
+ let disabled_1: boolean;
31
+ export { disabled_1 as disabled };
28
32
  let warnIcon_1: null;
29
33
  export { warnIcon_1 as warnIcon };
30
34
  let noPermissionMute_1: boolean;
@@ -28,6 +28,7 @@ function ComponentInstaller({
28
28
  closeByOutSize,
29
29
  onClose,
30
30
  fallback,
31
+ disabled,
31
32
  roles = ["owner", "admin"]
32
33
  }) {
33
34
  const {
@@ -63,6 +64,9 @@ function ComponentInstaller({
63
64
  window.location.reload();
64
65
  };
65
66
  const size = 60;
67
+ if (disabled) {
68
+ return children;
69
+ }
66
70
  return /* @__PURE__ */(0, _jsxRuntime.jsx)(_SessionPermission.default, {
67
71
  session: sessionCtx?.session,
68
72
  roles,
@@ -357,6 +361,7 @@ function ComponentInstaller({
357
361
  });
358
362
  }
359
363
  ComponentInstaller.propTypes = {
364
+ disabled: _propTypes.default.bool,
360
365
  warnIcon: _propTypes.default.node,
361
366
  did: _propTypes.default.string.isRequired,
362
367
  noPermissionMute: _propTypes.default.bool,
@@ -369,6 +374,7 @@ ComponentInstaller.propTypes = {
369
374
  roles: _propTypes.default.array
370
375
  };
371
376
  ComponentInstaller.defaultProps = {
377
+ disabled: false,
372
378
  warnIcon: null,
373
379
  noPermissionMute: false,
374
380
  onInstalled: null,
@@ -6,8 +6,8 @@ declare function useComponentInstalled({ did, onInstalled, onError }: {
6
6
  }): {
7
7
  optionalComponent: any;
8
8
  installed: any;
9
- installUrl: string;
10
- storeUrl: string;
9
+ installUrl: any;
10
+ storeUrl: any;
11
11
  installStatus: string;
12
12
  setInstallStatus: import("react").Dispatch<import("react").SetStateAction<string>>;
13
13
  installStatusDone: boolean;
@@ -6,15 +6,14 @@ Object.defineProperty(exports, "__esModule", {
6
6
 
7
7
  var _constant = require("@arcblock/did-connect/lib/constant");
8
8
  var _react = require("react");
9
+ var _urlJoin = _interopRequireDefault(require("url-join"));
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
11
  function useComponentInstalled({
10
12
  did,
11
13
  onInstalled,
12
14
  onError
13
15
  }) {
14
- const {
15
- optionalComponents,
16
- componentMountPoints
17
- } = window.blocklet;
16
+ const [installStatus, setInstallStatus] = (0, _react.useState)('');
18
17
  const onInstalledRef = (0, _react.useRef)({
19
18
  onInstalled,
20
19
  onError
@@ -23,6 +22,10 @@ function useComponentInstalled({
23
22
  onInstalled,
24
23
  onError
25
24
  };
25
+ const {
26
+ optionalComponents,
27
+ componentMountPoints
28
+ } = window.blocklet;
26
29
  const optionalComponent = (0, _react.useMemo)(() => {
27
30
  if (!optionalComponents || !optionalComponents.length) {
28
31
  return null;
@@ -37,9 +40,8 @@ function useComponentInstalled({
37
40
  }
38
41
  return (componentMountPoints || []).find(item => item.did === did);
39
42
  }, [optionalComponent, componentMountPoints, did]);
40
- const installUrl = `${window.blocklet.appUrl}/${_constant.AUTH_SERVICE_PREFIX}/admin/components?install-component=${did}`;
41
- const storeUrl = optionalComponent ? `${optionalComponent.meta.homepage}/blocklets/${did}` : '';
42
- const [installStatus, setInstallStatus] = (0, _react.useState)('');
43
+ const installUrl = (0, _urlJoin.default)(window.blocklet.appUrl, _constant.AUTH_SERVICE_PREFIX, `/admin/components?install-component=${did}`);
44
+ const storeUrl = optionalComponent ? (0, _urlJoin.default)(optionalComponent.meta.homepage, 'blocklets', did) : '';
43
45
  (0, _react.useEffect)(() => {
44
46
  const handle = event => {
45
47
  if (event.origin !== window.blocklet.appUrl) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/ui-react",
3
- "version": "2.9.20",
3
+ "version": "2.9.21",
4
4
  "description": "Some useful front-end web components that can be used in Blocklets.",
5
5
  "keywords": [
6
6
  "react",
@@ -63,8 +63,8 @@
63
63
  },
64
64
  "dependencies": {
65
65
  "@abtnode/constant": "1.16.23-beta-aeb9f5bd",
66
- "@arcblock/did-connect": "^2.9.20",
67
- "@arcblock/ux": "^2.9.20",
66
+ "@arcblock/did-connect": "^2.9.21",
67
+ "@arcblock/ux": "^2.9.21",
68
68
  "@blocklet/js-sdk": "1.16.23-beta-aeb9f5bd",
69
69
  "@emotion/react": "^11.10.4",
70
70
  "@emotion/styled": "^11.10.4",
@@ -80,7 +80,8 @@
80
80
  "lodash": "^4.17.21",
81
81
  "react-error-boundary": "^3.1.4",
82
82
  "react-placeholder": "^4.1.0",
83
- "ufo": "^1.3.2"
83
+ "ufo": "^1.3.2",
84
+ "url-join": "^4.0.1"
84
85
  },
85
86
  "peerDependencies": {
86
87
  "react": ">=18.1.0"
@@ -98,5 +99,5 @@
98
99
  "jest": "^28.1.3",
99
100
  "unbuild": "^2.0.0"
100
101
  },
101
- "gitHead": "56354c3f25c0d62ae39d79f07c648a7c0d9e66f7"
102
+ "gitHead": "800e32d5197a96b1b0a7dcf08f0bf11132c301e9"
102
103
  }
@@ -21,6 +21,7 @@ function ComponentInstaller({
21
21
  closeByOutSize,
22
22
  onClose,
23
23
  fallback,
24
+ disabled,
24
25
  roles = ['owner', 'admin'],
25
26
  }) {
26
27
  const { locale } = useLocaleContext();
@@ -53,6 +54,10 @@ function ComponentInstaller({
53
54
 
54
55
  const size = 60;
55
56
 
57
+ if (disabled) {
58
+ return children;
59
+ }
60
+
56
61
  return (
57
62
  <SessionPermission session={sessionCtx?.session} roles={roles}>
58
63
  {({ hasPermission }) => {
@@ -279,6 +284,7 @@ function ComponentInstaller({
279
284
  }
280
285
 
281
286
  ComponentInstaller.propTypes = {
287
+ disabled: PropTypes.bool,
282
288
  warnIcon: PropTypes.node,
283
289
  did: PropTypes.string.isRequired,
284
290
  noPermissionMute: PropTypes.bool,
@@ -292,6 +298,7 @@ ComponentInstaller.propTypes = {
292
298
  };
293
299
 
294
300
  ComponentInstaller.defaultProps = {
301
+ disabled: false,
295
302
  warnIcon: null,
296
303
  noPermissionMute: false,
297
304
  onInstalled: null,
@@ -1,11 +1,14 @@
1
1
  import { AUTH_SERVICE_PREFIX } from '@arcblock/did-connect/lib/constant';
2
2
  import { useMemo, useRef, useState, useEffect } from 'react';
3
+ import urlJoin from 'url-join';
3
4
 
4
5
  function useComponentInstalled({ did, onInstalled, onError }) {
5
- const { optionalComponents, componentMountPoints } = window.blocklet;
6
+ const [installStatus, setInstallStatus] = useState('');
6
7
  const onInstalledRef = useRef({ onInstalled, onError });
7
8
  onInstalledRef.current = { onInstalled, onError };
8
9
 
10
+ const { optionalComponents, componentMountPoints } = window.blocklet;
11
+
9
12
  const optionalComponent = useMemo(() => {
10
13
  if (!optionalComponents || !optionalComponents.length) {
11
14
  return null;
@@ -22,9 +25,8 @@ function useComponentInstalled({ did, onInstalled, onError }) {
22
25
  return (componentMountPoints || []).find((item) => item.did === did);
23
26
  }, [optionalComponent, componentMountPoints, did]);
24
27
 
25
- const installUrl = `${window.blocklet.appUrl}/${AUTH_SERVICE_PREFIX}/admin/components?install-component=${did}`;
26
- const storeUrl = optionalComponent ? `${optionalComponent.meta.homepage}/blocklets/${did}` : '';
27
- const [installStatus, setInstallStatus] = useState('');
28
+ const installUrl = urlJoin(window.blocklet.appUrl, AUTH_SERVICE_PREFIX, `/admin/components?install-component=${did}`);
29
+ const storeUrl = optionalComponent ? urlJoin(optionalComponent.meta.homepage, 'blocklets', did) : '';
28
30
 
29
31
  useEffect(() => {
30
32
  const handle = (event) => {