@blocklet/ui-react 2.9.91 → 2.10.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 (209) hide show
  1. package/build.config.ts +1 -6
  2. package/lib/@types/index.d.ts +1 -0
  3. package/lib/@types/index.js +0 -1
  4. package/lib/BlockletStudio/index.js +50 -50
  5. package/lib/ComponentInstaller/index.js +122 -202
  6. package/lib/ComponentInstaller/installer-item.js +116 -138
  7. package/lib/ComponentInstaller/locales.js +5 -10
  8. package/lib/ComponentInstaller/use-component-installed.js +37 -41
  9. package/lib/ComponentManager/components/add-component.js +58 -67
  10. package/lib/ComponentManager/components/check-component.js +2 -9
  11. package/lib/ComponentManager/components/publish-component.js +50 -59
  12. package/lib/ComponentManager/components/resource-dialog.js +42 -39
  13. package/lib/ComponentManager/index.js +3 -27
  14. package/lib/ComponentManager/libs/locales.js +2 -8
  15. package/lib/Dashboard/index.js +74 -99
  16. package/lib/Footer/brand.js +21 -43
  17. package/lib/Footer/copyright.js +15 -24
  18. package/lib/Footer/index.js +47 -71
  19. package/lib/Footer/internal-footer.js +72 -100
  20. package/lib/Footer/layout/plain.js +26 -45
  21. package/lib/Footer/layout/row.js +12 -29
  22. package/lib/Footer/layout/standard.js +34 -64
  23. package/lib/Footer/links.js +74 -104
  24. package/lib/Footer/social-media.js +35 -42
  25. package/lib/Header/index.js +69 -117
  26. package/lib/Icon/index.js +18 -53
  27. package/{es/UserCenter/components/notification.d.ts → lib/UserCenter/components/config-profile.d.ts} +1 -1
  28. package/lib/UserCenter/components/config-profile.js +67 -0
  29. package/lib/UserCenter/components/notification.js +203 -186
  30. package/lib/UserCenter/components/passport.js +70 -79
  31. package/lib/UserCenter/components/privacy.js +86 -88
  32. package/lib/UserCenter/components/settings.js +74 -84
  33. package/lib/UserCenter/components/storage/connect-to.js +56 -75
  34. package/lib/UserCenter/components/storage/connected.js +16 -37
  35. package/lib/UserCenter/components/storage/delete.js +42 -51
  36. package/lib/UserCenter/components/storage/disconnect.js +15 -29
  37. package/lib/UserCenter/components/storage/index.js +20 -54
  38. package/lib/UserCenter/components/storage/item.js +94 -122
  39. package/lib/UserCenter/components/storage/preview-nft.js +77 -85
  40. package/lib/UserCenter/components/third-party-login/index.js +49 -61
  41. package/lib/UserCenter/components/third-party-login/third-party-item.js +159 -176
  42. package/lib/UserCenter/components/user-center.js +276 -287
  43. package/lib/UserCenter/components/user-info/index.js +3 -27
  44. package/lib/UserCenter/components/user-info/user-basic-info.js +134 -129
  45. package/lib/UserCenter/components/user-info/user-info-item.js +43 -37
  46. package/lib/UserCenter/components/user-info/user-info.js +41 -74
  47. package/lib/UserCenter/components/webhook-item.js +184 -177
  48. package/lib/UserCenter/index.js +1 -13
  49. package/lib/UserCenter/libs/api.js +4 -16
  50. package/lib/UserCenter/libs/locales.d.ts +10 -0
  51. package/lib/UserCenter/libs/locales.js +12 -8
  52. package/lib/UserCenter/libs/utils.js +7 -17
  53. package/lib/UserSessions/components/user-session-info.js +88 -85
  54. package/lib/UserSessions/components/user-sessions.js +177 -213
  55. package/lib/UserSessions/index.js +1 -13
  56. package/lib/UserSessions/libs/locales.js +2 -8
  57. package/lib/UserSessions/libs/utils.js +4 -11
  58. package/lib/blocklets.js +59 -63
  59. package/lib/common/header-addons.js +44 -60
  60. package/lib/common/link-blocker.js +9 -18
  61. package/lib/common/overridable-theme-provider.js +10 -23
  62. package/lib/common/wallet-hidden-topbar.js +7 -14
  63. package/lib/contexts/config-user-space.js +38 -46
  64. package/lib/hooks/use-mobile.js +5 -13
  65. package/lib/index.js +10 -100
  66. package/lib/libs/client.js +2 -8
  67. package/lib/libs/spaces.js +6 -13
  68. package/lib/types.js +39 -41
  69. package/lib/utils.js +25 -44
  70. package/package.json +8 -38
  71. package/src/@types/index.ts +1 -0
  72. package/src/Footer/brand.jsx +6 -1
  73. package/src/UserCenter/components/config-profile.tsx +70 -0
  74. package/src/UserCenter/components/notification.tsx +63 -47
  75. package/src/UserCenter/components/settings.tsx +6 -0
  76. package/src/UserCenter/libs/locales.ts +10 -0
  77. package/es/@types/index.d.ts +0 -101
  78. package/es/@types/index.js +0 -0
  79. package/es/@types/shims.d.ts +0 -16
  80. package/es/BlockletStudio/index.d.ts +0 -28
  81. package/es/BlockletStudio/index.js +0 -114
  82. package/es/ComponentInstaller/index.d.ts +0 -37
  83. package/es/ComponentInstaller/index.js +0 -200
  84. package/es/ComponentInstaller/installer-item.d.ts +0 -21
  85. package/es/ComponentInstaller/installer-item.js +0 -139
  86. package/es/ComponentInstaller/locales.d.ts +0 -28
  87. package/es/ComponentInstaller/locales.js +0 -22
  88. package/es/ComponentInstaller/use-component-installed.d.ts +0 -12
  89. package/es/ComponentInstaller/use-component-installed.js +0 -88
  90. package/es/ComponentManager/components/add-component.d.ts +0 -16
  91. package/es/ComponentManager/components/add-component.js +0 -114
  92. package/es/ComponentManager/components/check-component.d.ts +0 -2
  93. package/es/ComponentManager/components/check-component.js +0 -2
  94. package/es/ComponentManager/components/publish-component.d.ts +0 -10
  95. package/es/ComponentManager/components/publish-component.js +0 -76
  96. package/es/ComponentManager/components/resource-dialog.d.ts +0 -14
  97. package/es/ComponentManager/components/resource-dialog.js +0 -74
  98. package/es/ComponentManager/index.d.ts +0 -3
  99. package/es/ComponentManager/index.js +0 -3
  100. package/es/ComponentManager/libs/locales.d.ts +0 -14
  101. package/es/ComponentManager/libs/locales.js +0 -14
  102. package/es/Dashboard/index.d.ts +0 -40
  103. package/es/Dashboard/index.js +0 -118
  104. package/es/Footer/brand.d.ts +0 -22
  105. package/es/Footer/brand.js +0 -73
  106. package/es/Footer/copyright.d.ts +0 -18
  107. package/es/Footer/copyright.js +0 -25
  108. package/es/Footer/index.d.ts +0 -6
  109. package/es/Footer/index.js +0 -82
  110. package/es/Footer/internal-footer.d.ts +0 -29
  111. package/es/Footer/internal-footer.js +0 -117
  112. package/es/Footer/layout/plain.d.ts +0 -15
  113. package/es/Footer/layout/plain.js +0 -39
  114. package/es/Footer/layout/row.d.ts +0 -18
  115. package/es/Footer/layout/row.js +0 -41
  116. package/es/Footer/layout/standard.d.ts +0 -15
  117. package/es/Footer/layout/standard.js +0 -53
  118. package/es/Footer/links.d.ts +0 -22
  119. package/es/Footer/links.js +0 -207
  120. package/es/Footer/social-media.d.ts +0 -14
  121. package/es/Footer/social-media.js +0 -60
  122. package/es/Header/index.d.ts +0 -10
  123. package/es/Header/index.js +0 -155
  124. package/es/Icon/index.d.ts +0 -23
  125. package/es/Icon/index.js +0 -55
  126. package/es/UserCenter/assets/banner.png +0 -0
  127. package/es/UserCenter/components/notification.js +0 -248
  128. package/es/UserCenter/components/passport.d.ts +0 -6
  129. package/es/UserCenter/components/passport.js +0 -88
  130. package/es/UserCenter/components/privacy.d.ts +0 -11
  131. package/es/UserCenter/components/privacy.js +0 -99
  132. package/es/UserCenter/components/settings.d.ts +0 -9
  133. package/es/UserCenter/components/settings.js +0 -89
  134. package/es/UserCenter/components/storage/connect-to.d.ts +0 -7
  135. package/es/UserCenter/components/storage/connect-to.js +0 -108
  136. package/es/UserCenter/components/storage/connected.d.ts +0 -7
  137. package/es/UserCenter/components/storage/connected.js +0 -24
  138. package/es/UserCenter/components/storage/delete.d.ts +0 -7
  139. package/es/UserCenter/components/storage/delete.js +0 -62
  140. package/es/UserCenter/components/storage/disconnect.d.ts +0 -3
  141. package/es/UserCenter/components/storage/disconnect.js +0 -23
  142. package/es/UserCenter/components/storage/icons/empty-spaces-nft.svg +0 -58
  143. package/es/UserCenter/components/storage/icons/long-arrow.svg +0 -5
  144. package/es/UserCenter/components/storage/icons/space-connected.svg +0 -3
  145. package/es/UserCenter/components/storage/icons/space-disconnect.svg +0 -3
  146. package/es/UserCenter/components/storage/index.d.ts +0 -3
  147. package/es/UserCenter/components/storage/index.js +0 -27
  148. package/es/UserCenter/components/storage/item.d.ts +0 -9
  149. package/es/UserCenter/components/storage/item.js +0 -158
  150. package/es/UserCenter/components/storage/preview-nft.d.ts +0 -6
  151. package/es/UserCenter/components/storage/preview-nft.js +0 -80
  152. package/es/UserCenter/components/third-party-login/index.d.ts +0 -5
  153. package/es/UserCenter/components/third-party-login/index.js +0 -110
  154. package/es/UserCenter/components/third-party-login/third-party-item.d.ts +0 -13
  155. package/es/UserCenter/components/third-party-login/third-party-item.js +0 -224
  156. package/es/UserCenter/components/user-center.d.ts +0 -15
  157. package/es/UserCenter/components/user-center.js +0 -414
  158. package/es/UserCenter/components/user-info/index.d.ts +0 -3
  159. package/es/UserCenter/components/user-info/index.js +0 -3
  160. package/es/UserCenter/components/user-info/user-basic-info.d.ts +0 -11
  161. package/es/UserCenter/components/user-info/user-basic-info.js +0 -151
  162. package/es/UserCenter/components/user-info/user-info-item.d.ts +0 -11
  163. package/es/UserCenter/components/user-info/user-info-item.js +0 -47
  164. package/es/UserCenter/components/user-info/user-info.d.ts +0 -6
  165. package/es/UserCenter/components/user-info/user-info.js +0 -66
  166. package/es/UserCenter/components/webhook-item.d.ts +0 -3
  167. package/es/UserCenter/components/webhook-item.js +0 -243
  168. package/es/UserCenter/index.d.ts +0 -1
  169. package/es/UserCenter/index.js +0 -1
  170. package/es/UserCenter/libs/api.d.ts +0 -3
  171. package/es/UserCenter/libs/api.js +0 -4
  172. package/es/UserCenter/libs/locales.d.ts +0 -162
  173. package/es/UserCenter/libs/locales.js +0 -162
  174. package/es/UserCenter/libs/utils.d.ts +0 -4
  175. package/es/UserCenter/libs/utils.js +0 -14
  176. package/es/UserSessions/components/user-session-info.d.ts +0 -6
  177. package/es/UserSessions/components/user-session-info.js +0 -92
  178. package/es/UserSessions/components/user-sessions.d.ts +0 -9
  179. package/es/UserSessions/components/user-sessions.js +0 -265
  180. package/es/UserSessions/index.d.ts +0 -1
  181. package/es/UserSessions/index.js +0 -1
  182. package/es/UserSessions/libs/locales.d.ts +0 -58
  183. package/es/UserSessions/libs/locales.js +0 -58
  184. package/es/UserSessions/libs/utils.d.ts +0 -2
  185. package/es/UserSessions/libs/utils.js +0 -73
  186. package/es/blocklets.d.ts +0 -16
  187. package/es/blocklets.js +0 -178
  188. package/es/common/header-addons.d.ts +0 -21
  189. package/es/common/header-addons.js +0 -83
  190. package/es/common/link-blocker.d.ts +0 -7
  191. package/es/common/link-blocker.js +0 -18
  192. package/es/common/overridable-theme-provider.d.ts +0 -18
  193. package/es/common/overridable-theme-provider.js +0 -15
  194. package/es/common/wallet-hidden-topbar.d.ts +0 -1
  195. package/es/common/wallet-hidden-topbar.js +0 -14
  196. package/es/contexts/config-user-space.d.ts +0 -26
  197. package/es/contexts/config-user-space.js +0 -53
  198. package/es/hooks/use-mobile.d.ts +0 -4
  199. package/es/hooks/use-mobile.js +0 -5
  200. package/es/index.d.ts +0 -10
  201. package/es/index.js +0 -10
  202. package/es/libs/client.d.ts +0 -2
  203. package/es/libs/client.js +0 -2
  204. package/es/libs/spaces.d.ts +0 -2
  205. package/es/libs/spaces.js +0 -13
  206. package/es/types.d.ts +0 -2
  207. package/es/types.js +0 -43
  208. package/es/utils.d.ts +0 -8
  209. package/es/utils.js +0 -78
@@ -13,6 +13,7 @@ import { User, UserCenterTab } from '../../@types';
13
13
  import DidSpace from './storage';
14
14
  import { UserSessions } from '../../UserSessions';
15
15
  import ThirdPartyLogin from './third-party-login';
16
+ import ConfigProfile from './config-profile';
16
17
 
17
18
  export default function Settings({
18
19
  user,
@@ -42,6 +43,11 @@ export default function Settings({
42
43
  }, [settings?.userCenterTabs]);
43
44
  const tabs = useCreation(() => {
44
45
  return [
46
+ {
47
+ label: t('commonSetting.title'),
48
+ value: 'common',
49
+ content: <ConfigProfile user={user} />,
50
+ },
45
51
  {
46
52
  label: t('notificationManagement'),
47
53
  value: 'notification',
@@ -14,6 +14,7 @@ export const translations = {
14
14
  walletNotification: '钱包通知',
15
15
  emailNotification: '邮件通知',
16
16
  phoneNotification: '短信通知',
17
+ pushNotification: '推送消息(由 Push Kit 提供)',
17
18
  addWebhook: '新增外部通知',
18
19
  saveSuccess: '保存成功',
19
20
  saveFailed: '保存失败',
@@ -79,6 +80,10 @@ export const translations = {
79
80
  confirmUnbindDescription:
80
81
  '解绑后您将无法使用 {name} 登录至该账户。如果解绑后,您仍使用 {name} 登录,会自动创建一个新账户',
81
82
  },
83
+ commonSetting: {
84
+ title: '通用设置',
85
+ locale: '偏好语言',
86
+ },
82
87
  },
83
88
  en: {
84
89
  settings: 'Settings',
@@ -95,6 +100,7 @@ export const translations = {
95
100
  walletNotification: 'DID Wallet notification',
96
101
  emailNotification: 'Email notification',
97
102
  phoneNotification: 'SMS notification',
103
+ pushNotification: 'Push notification (powered by Push Kit)',
98
104
  addWebhook: 'Add external notification',
99
105
  saveSuccess: 'Save succeed',
100
106
  saveFailed: 'Save failed',
@@ -160,5 +166,9 @@ export const translations = {
160
166
  confirmUnbindDescription:
161
167
  'You will not be able to log in to this account using {name} after unbundling. If you are still logged in with {name} after unbundling, a new account will be created automatically!',
162
168
  },
169
+ commonSetting: {
170
+ title: 'Common Settings',
171
+ locale: 'Preferred language',
172
+ },
163
173
  },
164
174
  };
@@ -1,101 +0,0 @@
1
- import type { Axios } from 'axios';
2
- import type { UserPublicInfo } from '@blocklet/js-sdk';
3
- import { OAUTH_PROVIDER } from '@arcblock/ux/lib/Util/constant';
4
- export type SessionContext = {
5
- session: Session;
6
- api: Axios;
7
- };
8
- export type OAuthAccount = {
9
- provider: keyof typeof OAUTH_PROVIDER;
10
- id: string;
11
- did: string;
12
- pk: string;
13
- lastLoginAt: string;
14
- firstLoginAt: string;
15
- order?: number;
16
- userInfo?: {
17
- email: string;
18
- emailVerified: boolean;
19
- name: string;
20
- picture: string;
21
- sub: string;
22
- extraData: Object;
23
- };
24
- };
25
- export type WalletAccount = {
26
- provider: 'wallet';
27
- did: string;
28
- pk: string;
29
- lastLoginAt: string;
30
- firstLoginAt: string;
31
- };
32
- export type NFTAccount = {
33
- provider: 'nft';
34
- did: string;
35
- pk: string;
36
- owner: string;
37
- lastLoginAt: string;
38
- firstLoginAt: string;
39
- };
40
- export type ConnectedAccount = OAuthAccount | WalletAccount | NFTAccount;
41
- export type User = UserPublicInfo & {
42
- role: string;
43
- email?: string;
44
- phone?: string;
45
- sourceProvider?: string;
46
- sourceAppPid?: string;
47
- lastLoginAt?: string;
48
- lastLoginIp?: string;
49
- createdAt?: string;
50
- passports?: any[];
51
- didSpace?: Record<string, any>;
52
- connectedAccounts?: any[];
53
- };
54
- export type UserCenterTab = {
55
- value: string;
56
- label: string;
57
- url: string;
58
- protected: boolean;
59
- icon?: string;
60
- };
61
- export type Session = {
62
- loading: boolean;
63
- initialized: boolean;
64
- user?: User;
65
- login: any;
66
- logout: any;
67
- switch: any;
68
- switchDid: any;
69
- switchProfile: any;
70
- switchPassport: any;
71
- refresh: Function;
72
- useOAuth: Function;
73
- };
74
- export type WebhookType = 'slack' | 'api';
75
- export type WebhookItemData = {
76
- type: WebhookType;
77
- url: string;
78
- };
79
- export type WebhookItemProps = {
80
- onTest: (params: WebhookItemData) => void;
81
- onSave: (params: WebhookItemData) => void;
82
- onDelete?: (params: WebhookItemData) => void;
83
- onCancel?: () => void;
84
- edit: boolean;
85
- type?: WebhookType;
86
- url?: string;
87
- };
88
- export type CreatePassportProps = {
89
- issuer: string;
90
- title: string;
91
- issuerDid: string;
92
- issuerAvatarUrl: string;
93
- ownerDid: string;
94
- ownerName: string;
95
- ownerAvatarUrl: string;
96
- preferredColor?: string;
97
- revoked?: boolean;
98
- isDataUrl?: boolean;
99
- width?: string;
100
- height?: string;
101
- };
File without changes
@@ -1,16 +0,0 @@
1
- declare module '@arcblock/ux/*';
2
- declare module '@arcblock/ux/lib/DID';
3
- declare module '@arcblock/ux/lib/Tabs';
4
- declare module '@arcblock/ux/lib/Switch';
5
- declare module '@arcblock/ux/lib/ErrorBoundary';
6
-
7
- declare module '@arcblock/did-connect/*';
8
- declare module '@arcblock/did-connect/lib/Session';
9
-
10
- declare module 'is-url';
11
-
12
- declare module '*.png';
13
-
14
- declare interface Window {
15
- blocklet: any;
16
- }
@@ -1,28 +0,0 @@
1
- /// <reference types="react" />
2
- interface BlockletStudioProps {
3
- open: boolean;
4
- setOpen: (open: boolean) => void;
5
- onOpened?: () => void;
6
- componentDid: string;
7
- tenantScope?: string;
8
- resourcesParams?: Record<string, any>;
9
- mode?: string;
10
- title?: string;
11
- logo?: string;
12
- description?: string;
13
- introduction?: string;
14
- note?: string;
15
- onUploaded?: (data: unknown) => void;
16
- onReleased?: (data: unknown) => void;
17
- onConnected?: (data: unknown) => void;
18
- components?: Record<string, unknown>[];
19
- resources?: Record<string, unknown>;
20
- componentsTitle?: string;
21
- resourcesTitle?: string;
22
- style?: React.CSSProperties;
23
- zIndex?: number;
24
- dependentComponentsMode?: 'auto' | 'readonly';
25
- [key: string]: any;
26
- }
27
- declare function BlockletStudio({ open, setOpen, onOpened, componentDid, tenantScope, resourcesParams, mode, title, logo, description, introduction, note, componentsTitle, resourcesTitle, onUploaded, onReleased, onConnected, components, resources, style, zIndex, dependentComponentsMode, ...rest }: BlockletStudioProps): import("react").JSX.Element | null;
28
- export default BlockletStudio;
@@ -1,114 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { useEffect, useRef, useState } from "react";
3
- import { joinURL } from "ufo";
4
- const WELL_KNOWN_SERVICE_PATH = "/.well-known/service";
5
- function parseUrl(uri, params) {
6
- const url = new URL(uri);
7
- Object.keys(params).forEach((key) => {
8
- const value = params[key];
9
- if (value !== void 0) {
10
- url.searchParams.set(key, typeof value === "string" ? value : JSON.stringify(value));
11
- }
12
- });
13
- return url.pathname + url.search;
14
- }
15
- function BlockletStudio({
16
- open,
17
- setOpen,
18
- onOpened,
19
- componentDid,
20
- tenantScope,
21
- resourcesParams = {},
22
- mode = "dialog",
23
- title,
24
- logo,
25
- description,
26
- introduction,
27
- note,
28
- componentsTitle,
29
- resourcesTitle,
30
- onUploaded,
31
- onReleased,
32
- onConnected,
33
- components = [],
34
- resources = {},
35
- style = {},
36
- zIndex = 9999,
37
- dependentComponentsMode,
38
- ...rest
39
- }) {
40
- const [opened, setOpened] = useState(false);
41
- const didRef = useRef("");
42
- didRef.current = componentDid;
43
- const latestFunctionVersionRef = useRef({});
44
- latestFunctionVersionRef.current["resourceDialog.close"] = () => {
45
- setOpened(false);
46
- setOpen(false);
47
- };
48
- latestFunctionVersionRef.current["resourceDialog.loaded"] = () => {
49
- setOpened(true);
50
- onOpened?.();
51
- };
52
- latestFunctionVersionRef.current["studioDialog.uploaded"] = onUploaded;
53
- latestFunctionVersionRef.current["studioDialog.connected"] = onConnected;
54
- latestFunctionVersionRef.current["studioDialog.released"] = onReleased;
55
- useEffect(() => {
56
- const listener = (event) => {
57
- if (event?.data?.componentDid !== didRef.current) {
58
- return;
59
- }
60
- const fn = latestFunctionVersionRef.current[event?.data?.event];
61
- if (typeof fn === "function") {
62
- fn(event?.data?.data);
63
- }
64
- };
65
- window.addEventListener("message", listener);
66
- return () => {
67
- window.removeEventListener("message", listener);
68
- };
69
- }, []);
70
- if (!open) {
71
- return null;
72
- }
73
- const src = parseUrl(
74
- joinURL(window.location.origin, WELL_KNOWN_SERVICE_PATH, "/embed/resources", componentDid, "publish"),
75
- {
76
- title,
77
- logo,
78
- description,
79
- introduction,
80
- note,
81
- tenantScope,
82
- mode,
83
- resourcesParams,
84
- resources,
85
- components,
86
- resourcesTitle,
87
- componentsTitle,
88
- dependentComponentsMode
89
- }
90
- );
91
- return /* @__PURE__ */ jsx(
92
- "iframe",
93
- {
94
- src,
95
- title: "Blocklet Studio",
96
- style: {
97
- position: "fixed",
98
- top: 0,
99
- left: 0,
100
- width: "100vw",
101
- height: "100vh",
102
- zIndex,
103
- border: 0,
104
- padding: 0,
105
- margin: 0,
106
- pointerEvents: opened ? "auto" : "none",
107
- opacity: opened ? 1 : 0,
108
- ...style
109
- },
110
- ...rest
111
- }
112
- );
113
- }
114
- export default BlockletStudio;
@@ -1,37 +0,0 @@
1
- declare function WrapComponentInstaller(props: any): any;
2
- declare namespace WrapComponentInstaller {
3
- namespace propTypes {
4
- let children: any;
5
- let disabled: any;
6
- let warnIcon: any;
7
- let did: any;
8
- let noPermissionMute: any;
9
- let onInstalled: any;
10
- let onError: any;
11
- let closeByOutSize: any;
12
- let onClose: any;
13
- let fallback: any;
14
- let roles: any;
15
- }
16
- namespace defaultProps {
17
- let disabled_1: boolean;
18
- export { disabled_1 as disabled };
19
- let warnIcon_1: null;
20
- export { warnIcon_1 as warnIcon };
21
- let noPermissionMute_1: boolean;
22
- export { noPermissionMute_1 as noPermissionMute };
23
- let onInstalled_1: null;
24
- export { onInstalled_1 as onInstalled };
25
- let onError_1: null;
26
- export { onError_1 as onError };
27
- let closeByOutSize_1: boolean;
28
- export { closeByOutSize_1 as closeByOutSize };
29
- let onClose_1: null;
30
- export { onClose_1 as onClose };
31
- let fallback_1: null;
32
- export { fallback_1 as fallback };
33
- let roles_1: string[];
34
- export { roles_1 as roles };
35
- }
36
- }
37
- export default WrapComponentInstaller;
@@ -1,200 +0,0 @@
1
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
- import { SessionContext } from "@arcblock/did-connect/lib/Session";
3
- import { temp as colors } from "@arcblock/ux/lib/Colors";
4
- import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
5
- import { translate } from "@arcblock/ux/lib/Locale/util";
6
- import SessionPermission from "@arcblock/ux/lib/SessionPermission";
7
- import { Icon } from "@iconify/react";
8
- import CloseIcon from "@mui/icons-material/Close";
9
- import { Box, ClickAwayListener, Fade, IconButton, Paper } from "@mui/material";
10
- import { useMemoizedFn } from "ahooks";
11
- import PropTypes from "prop-types";
12
- import { useContext } from "react";
13
- import InstallerItem from "./installer-item.js";
14
- import translations from "./locales.js";
15
- import useComponentInstalled from "./use-component-installed.js";
16
- function ComponentInstaller({
17
- warnIcon,
18
- did,
19
- noPermissionMute,
20
- onInstalled,
21
- onError,
22
- children,
23
- closeByOutSize,
24
- onClose,
25
- fallback,
26
- disabled,
27
- roles = ["owner", "admin"]
28
- }) {
29
- const { locale } = useLocaleContext();
30
- const t = useMemoizedFn((key, data = {}) => {
31
- return translate(translations, key, locale, "en", data);
32
- });
33
- const { installed, optComponents, installStatus, definedInBlockletYML } = useComponentInstalled({
34
- did,
35
- onInstalled,
36
- onError
37
- });
38
- const sessionCtx = useContext(SessionContext);
39
- const handleClose = () => {
40
- onClose?.(false);
41
- };
42
- if (disabled) {
43
- return children;
44
- }
45
- return /* @__PURE__ */ jsx(SessionPermission, { session: sessionCtx?.session, roles, children: ({ hasPermission }) => {
46
- if (installed) {
47
- return children;
48
- }
49
- if (noPermissionMute && !hasPermission) {
50
- return fallback || null;
51
- }
52
- if (typeof children === "function") {
53
- return /* @__PURE__ */ jsxs(Fragment, { children: [
54
- fallback,
55
- children({
56
- hasPermission,
57
- optComponents,
58
- installStatus
59
- })
60
- ] });
61
- }
62
- return /* @__PURE__ */ jsxs(Fragment, { children: [
63
- fallback,
64
- /* @__PURE__ */ jsx(
65
- ClickAwayListener,
66
- {
67
- onClickAway: (e) => {
68
- e.preventDefault();
69
- e.stopPropagation();
70
- if (closeByOutSize) {
71
- handleClose();
72
- }
73
- },
74
- children: /* @__PURE__ */ jsx(Fade, { in: true, timeout: 350, children: /* @__PURE__ */ jsx(
75
- Paper,
76
- {
77
- variant: "outlined",
78
- sx: {
79
- position: "fixed",
80
- top: 20,
81
- right: 20,
82
- zIndex: 3e3,
83
- borderRadius: 3,
84
- width: 400,
85
- maxWidth: "90vw",
86
- borderColor: colors.lineStep,
87
- border: "0 !important",
88
- fontSize: "14px",
89
- textAlign: "left",
90
- boxShadow: `0px 8px 16px 0px ${colors.gray6}, 0px 0px 0px 1px ${colors.gray6}`
91
- },
92
- children: !definedInBlockletYML ? /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", flexDirection: "column" }, children: [
93
- /* @__PURE__ */ jsxs(
94
- Box,
95
- {
96
- sx: {
97
- padding: "20px 24px",
98
- marginLeft: 0,
99
- display: "flex",
100
- alignItems: "center",
101
- flexDirection: "row",
102
- justifyContent: "flex-start"
103
- },
104
- children: [
105
- warnIcon || /* @__PURE__ */ jsx(Icon, { icon: "mdi:warning-box", style: { color: "yellowgreen", fontSize: 24 } }),
106
- /* @__PURE__ */ jsx(Box, { sx: { marginLeft: 1, fontSize: "16px", fontWeight: "bold" }, children: t("componentInstallerTitle") }),
107
- /* @__PURE__ */ jsx(Box, { sx: { flex: 1 } }),
108
- onClose ? /* @__PURE__ */ jsx(IconButton, { variant: "outlined", className: "button", onClick: handleClose, children: /* @__PURE__ */ jsx(CloseIcon, {}) }) : null
109
- ]
110
- }
111
- ),
112
- /* @__PURE__ */ jsx(Box, { sx: { width: "100%", height: "1px", backgroundColor: colors.gray6 } }),
113
- /* @__PURE__ */ jsxs(Box, { sx: { padding: "20px 24px", marginTop: 0 }, children: [
114
- t("componentInstallerNoDefinedInBlockletYML"),
115
- ": ",
116
- did
117
- ] })
118
- ] }) : /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", flexDirection: "column" }, children: [
119
- /* @__PURE__ */ jsxs(
120
- Box,
121
- {
122
- sx: {
123
- padding: "20px 24px",
124
- marginLeft: 0,
125
- display: "flex",
126
- flexDirection: "row",
127
- alignItems: "center",
128
- justifyContent: "flex-start"
129
- },
130
- children: [
131
- warnIcon || /* @__PURE__ */ jsx(Icon, { icon: "mdi:warning-box", style: { color: "yellowgreen", fontSize: 24 } }),
132
- /* @__PURE__ */ jsx(Box, { sx: { marginLeft: 1, fontSize: "16px", fontWeight: "bold" }, children: t("componentInstallerTitle") }),
133
- /* @__PURE__ */ jsx(Box, { sx: { flex: 1 } }),
134
- onClose ? /* @__PURE__ */ jsx(IconButton, { variant: "outlined", className: "button", onClick: handleClose, children: /* @__PURE__ */ jsx(CloseIcon, {}) }) : null
135
- ]
136
- }
137
- ),
138
- /* @__PURE__ */ jsx(Box, { sx: { width: "100%", height: "1px", backgroundColor: colors.gray6 } }),
139
- /* @__PURE__ */ jsx(Box, { sx: { maxHeight: "70vh", overflowY: "auto" }, children: optComponents.map((optionalComponent, index) => {
140
- return /* @__PURE__ */ jsx(
141
- InstallerItem,
142
- {
143
- t,
144
- hasPermission,
145
- index,
146
- optionalComponent,
147
- installStatus: installStatus[optionalComponent.meta?.did]
148
- },
149
- optionalComponent.meta?.did || index
150
- );
151
- }) }),
152
- hasPermission ? null : /* @__PURE__ */ jsxs(Fragment, { children: [
153
- /* @__PURE__ */ jsx(Box, { sx: { width: "100%", height: "1px", backgroundColor: colors.gray6 } }),
154
- /* @__PURE__ */ jsx(Box, { sx: { padding: "20px 24px" }, children: /* @__PURE__ */ jsx(Box, { sx: { opacity: 1 }, children: t("componentInstallerSuggestions") }) })
155
- ] })
156
- ] })
157
- }
158
- ) })
159
- }
160
- )
161
- ] });
162
- } });
163
- }
164
- ComponentInstaller.propTypes = {
165
- disabled: PropTypes.bool,
166
- warnIcon: PropTypes.node,
167
- did: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]).isRequired,
168
- noPermissionMute: PropTypes.bool,
169
- onInstalled: PropTypes.func,
170
- onError: PropTypes.func,
171
- children: PropTypes.any.isRequired,
172
- closeByOutSize: PropTypes.bool,
173
- onClose: PropTypes.func,
174
- fallback: PropTypes.node,
175
- roles: PropTypes.array
176
- };
177
- ComponentInstaller.defaultProps = {
178
- disabled: false,
179
- warnIcon: null,
180
- noPermissionMute: false,
181
- onInstalled: null,
182
- onError: null,
183
- closeByOutSize: false,
184
- onClose: null,
185
- fallback: null,
186
- roles: ["owner", "admin"]
187
- };
188
- export default function WrapComponentInstaller(props) {
189
- if (window.blocklet) {
190
- return /* @__PURE__ */ jsx(ComponentInstaller, { ...props });
191
- }
192
- return props.children;
193
- }
194
- WrapComponentInstaller.propTypes = {
195
- ...ComponentInstaller.propTypes,
196
- children: PropTypes.any.isRequired
197
- };
198
- WrapComponentInstaller.defaultProps = {
199
- ...ComponentInstaller.defaultProps
200
- };
@@ -1,21 +0,0 @@
1
- declare function InstallerItem({ optionalComponent, index, installStatus, hasPermission, t }: {
2
- optionalComponent: any;
3
- index: any;
4
- installStatus: any;
5
- hasPermission: any;
6
- t: any;
7
- }): import("react").JSX.Element;
8
- declare namespace InstallerItem {
9
- namespace propTypes {
10
- let t: any;
11
- let optionalComponent: any;
12
- let index: any;
13
- let installStatus: any;
14
- let hasPermission: any;
15
- }
16
- namespace defaultProps {
17
- let installStatus_1: string;
18
- export { installStatus_1 as installStatus };
19
- }
20
- }
21
- export default InstallerItem;