@abtnode/ux 1.16.27-beta-d1555a79 → 1.16.27-beta-f109b207

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.
@@ -2,10 +2,8 @@
2
2
  import PropTypes from 'prop-types';
3
3
  import { useEffect, useRef, useState } from 'react';
4
4
  import { useParams } from 'react-router-dom';
5
- import semver from 'semver';
6
5
  import { isInServerlessMode } from '@abtnode/util/lib/serverless';
7
6
  import Alert from '@arcblock/ux/lib/Alert';
8
- import { useTheme } from '@arcblock/ux/lib/Theme';
9
7
  import AnimationWaiter from '@arcblock/ux/lib/AnimationWaiter';
10
8
  import Button from '@arcblock/ux/lib/Button';
11
9
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
@@ -15,7 +13,6 @@ import ResultMessage from '@blocklet/launcher-layout/lib/launch-result-message';
15
13
  import PageHeader from '@blocklet/launcher-layout/lib/page-header';
16
14
  import styled from '@emotion/styled';
17
15
  import CheckIcon from '@mui/icons-material/Check';
18
- import UpgradeIcon from '@mui/icons-material/Upgrade';
19
16
  import AddIcon from '@mui/icons-material/Link';
20
17
  import Box from '@mui/material/Box';
21
18
  import Spinner from '@mui/material/CircularProgress';
@@ -106,9 +103,9 @@ export default function AddComponentCore({
106
103
  selectedMeta,
107
104
  showResourcesSwitch,
108
105
  showFromUrl,
109
- enableRunBackground
106
+ enableRunBackground,
107
+ showCategory
110
108
  }) {
111
- const theme = useTheme();
112
109
  const {
113
110
  t,
114
111
  locale
@@ -633,23 +630,6 @@ export default function AddComponentCore({
633
630
 
634
631
  // eslint-disable-next-line react-hooks/exhaustive-deps
635
632
  }, [selectedMeta, activeStep]);
636
- const getInstallOrUpgrade = item => {
637
- const exist = (blocklet?.children || []).find(x => x.meta.bundleDid === item.did);
638
- if (exist) {
639
- try {
640
- const currentVersion = exist.meta.version;
641
- const targetVersion = item.version;
642
- if (semver.gt(targetVersion, currentVersion)) {
643
- return 'upgrade';
644
- }
645
- } catch {
646
- // 如果比对版本报错,则还是允许安装
647
- return 'install';
648
- }
649
- return 'disable';
650
- }
651
- return 'install';
652
- };
653
633
  const steps = [{
654
634
  key: 'selectComponent',
655
635
  name: t('blocklet.component.selectComponent'),
@@ -728,6 +708,7 @@ export default function AddComponentCore({
728
708
  }) => {
729
709
  return /*#__PURE__*/_jsx(BlockletList, {
730
710
  showResourcesSwitch: showResourcesSwitch,
711
+ showCategory: showCategory,
731
712
  serverVersion: nodeInfo?.version,
732
713
  style: isMobile ? {
733
714
  // should remove other dom height/margin
@@ -752,36 +733,8 @@ export default function AddComponentCore({
752
733
  defaultRender
753
734
  }) => {
754
735
  const isChosen = params?.bundleDid && params?.bundleDid === blockletItem?.did;
755
- const actionType = getInstallOrUpgrade(blockletItem);
756
- if (actionType === 'disable') {
757
- return /*#__PURE__*/_jsxs(StoreBlockletItemWrapper, {
758
- style: {
759
- cursor: 'not-allowed',
760
- backgroundColor: theme.palette.grey['100']
761
- },
762
- title: t('blocklet.component.installed'),
763
- children: [/*#__PURE__*/_jsx("div", {
764
- className: "install-container",
765
- children: /*#__PURE__*/_jsx(CheckIcon, {
766
- className: "install-icon"
767
- })
768
- }), /*#__PURE__*/_jsx("div", {
769
- className: "installed-blocklet",
770
- style: {
771
- marginLeft: 16,
772
- pointerEvents: 'none'
773
- },
774
- children: defaultRender
775
- })]
776
- });
777
- }
778
736
  return /*#__PURE__*/_jsxs(StoreBlockletItemWrapper, {
779
- children: [actionType === 'upgrade' ? /*#__PURE__*/_jsx("div", {
780
- className: "upgrade-container",
781
- children: /*#__PURE__*/_jsx(UpgradeIcon, {
782
- className: "upgrade-icon"
783
- })
784
- }) : null, isChosen && /*#__PURE__*/_jsx("div", {
737
+ children: [isChosen && /*#__PURE__*/_jsx("div", {
785
738
  className: "check-container",
786
739
  children: /*#__PURE__*/_jsx(CheckIcon, {
787
740
  className: "check-icon"
@@ -1151,7 +1104,8 @@ AddComponentCore.propTypes = {
1151
1104
  selectedMeta: PropTypes.object,
1152
1105
  showResourcesSwitch: PropTypes.bool,
1153
1106
  showFromUrl: PropTypes.bool,
1154
- enableRunBackground: PropTypes.bool
1107
+ enableRunBackground: PropTypes.bool,
1108
+ showCategory: PropTypes.bool
1155
1109
  };
1156
1110
  AddComponentCore.defaultProps = {
1157
1111
  onClose: () => {},
@@ -1164,7 +1118,8 @@ AddComponentCore.defaultProps = {
1164
1118
  selectedMeta: null,
1165
1119
  showResourcesSwitch: true,
1166
1120
  showFromUrl: true,
1167
- enableRunBackground: true
1121
+ enableRunBackground: true,
1122
+ showCategory: true
1168
1123
  };
1169
1124
  const Wrapper = styled(Box)`
1170
1125
  .action-bar {
@@ -1230,63 +1185,6 @@ const StoreBlockletItemWrapper = styled.div`
1230
1185
  transition: all ease 0.2s;
1231
1186
  }
1232
1187
  }
1233
- .install-container {
1234
- position: absolute;
1235
- right: 0;
1236
- bottom: 0;
1237
- display: flex;
1238
- justify-content: flex-end;
1239
- align-items: flex-end;
1240
- width: 30px;
1241
- height: 30px;
1242
- border-radius: 0 0 8px 0;
1243
- color: ${props => props.theme.palette.common.white};
1244
- overflow: hidden;
1245
- transition: all ease 0.3s;
1246
- &:after {
1247
- position: absolute;
1248
- z-index: 0;
1249
- display: block;
1250
- width: 0;
1251
- height: 0;
1252
- border-top: transparent solid 15px;
1253
- border-left: transparent solid 15px;
1254
- border-bottom: ${props => props.theme.palette.grey['300']} solid 15px;
1255
- border-right: ${props => props.theme.palette.grey['300']} solid 15px;
1256
- transition: all ease 0.1s;
1257
- content: '';
1258
- }
1259
-
1260
- .install-icon {
1261
- position: relative;
1262
- z-index: 2;
1263
- margin: 0 1px 1px 0;
1264
- font-size: 16px;
1265
- transition: all ease 0.2s;
1266
- }
1267
- }
1268
- .upgrade-container {
1269
- position: absolute;
1270
- right: 6px;
1271
- top: 0;
1272
- display: flex;
1273
- justify-content: flex-end;
1274
- align-items: flex-end;
1275
- width: 30px;
1276
- height: 30px;
1277
- border-radius: 0 0 8px 0;
1278
- color: ${props => props.theme.palette.primary.main};
1279
- overflow: hidden;
1280
- transition: all ease 0.3s;
1281
-
1282
- .upgrade-icon {
1283
- position: relative;
1284
- z-index: 2;
1285
- margin: 0 1px 1px 0;
1286
- font-size: 24px;
1287
- transition: all ease 0.2s;
1288
- }
1289
- }
1290
1188
  `;
1291
1189
  const MessageDiv = styled.div`
1292
1190
  color: ${props => props.theme.palette.primary.main};
@@ -8,13 +8,16 @@ import Link from '@mui/material/Link';
8
8
  import { ErrorFallback } from '@arcblock/ux/lib/ErrorBoundary';
9
9
  import { ErrorBoundary } from 'react-error-boundary';
10
10
  import InnerList from '@blocklet/list';
11
+ import UpgradeIcon from '@mui/icons-material/Upgrade';
11
12
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
12
13
  import Blocklet, { ActionButton } from '@arcblock/ux/lib/Blocklet';
13
14
  import Spinner from '@mui/material/CircularProgress';
14
15
  import Button from '@arcblock/ux/lib/Button';
16
+ import semver from 'semver';
15
17
  import { isFreeBlocklet } from '@blocklet/meta/lib/util';
16
18
  import Toast from '@arcblock/ux/lib/Toast';
17
19
  import { formatRegistryLogoPath } from '../../util';
20
+ import { useBlockletContext } from '../../contexts/blocklet';
18
21
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
19
22
  const getStoreDetail = (meta, endpoint) => {
20
23
  return joinUrl(endpoint, `/blocklets/${meta.did}`);
@@ -55,7 +58,6 @@ function BlockletItem({
55
58
  }
56
59
  return true;
57
60
  };
58
- const btnTxt = requirePurchase(blocklet) ? t('common.purchase') : t('blocklet.component.choose');
59
61
  const onAction = async e => {
60
62
  e.preventDefault();
61
63
  e.stopPropagation();
@@ -72,6 +74,40 @@ function BlockletItem({
72
74
  setLoading(false);
73
75
  }
74
76
  };
77
+ const {
78
+ blocklet: pageBlocklet
79
+ } = useBlockletContext();
80
+ const getCurrentVersion = () => {
81
+ const exist = (pageBlocklet?.children || []).find(x => x.meta.bundleDid === blocklet.did);
82
+ const currentVersion = exist.meta.version;
83
+ return currentVersion;
84
+ };
85
+ const getInstallOrUpgrade = () => {
86
+ const exist = (pageBlocklet?.children || []).find(x => x.meta.bundleDid === blocklet.did);
87
+ if (exist) {
88
+ try {
89
+ const currentVersion = exist.meta.version;
90
+ const targetVersion = blocklet.version;
91
+ if (semver.gt(targetVersion, currentVersion)) {
92
+ return 'upgrade';
93
+ }
94
+ } catch {
95
+ // 如果比对版本报错,则还是允许安装
96
+ return 'install';
97
+ }
98
+ return 'disable';
99
+ }
100
+ return 'install';
101
+ };
102
+ const actionType = getInstallOrUpgrade();
103
+ let btnTxt = t('blocklet.component.choose');
104
+ if (actionType === 'upgrade') {
105
+ btnTxt = t('blocklet.component.upgrade');
106
+ } else if (actionType === 'disable') {
107
+ btnTxt = t('blocklet.component.installed');
108
+ } else if (requirePurchase(blocklet)) {
109
+ btnTxt = t('common.purchase');
110
+ }
75
111
  return /*#__PURE__*/_jsx(Link, {
76
112
  href: getStoreDetail(blocklet, endpoint),
77
113
  style: {
@@ -100,21 +136,26 @@ function BlockletItem({
100
136
  alignItems: 'center'
101
137
  },
102
138
  children: /*#__PURE__*/_jsx(ActionButton, {
103
- children: /*#__PURE__*/_jsx(Button, {
139
+ children: /*#__PURE__*/_jsxs(Button, {
104
140
  onClick: onAction,
105
141
  size: "small",
106
- disabled: loading,
142
+ disabled: loading || actionType === 'disable',
107
143
  variant: "outlined",
108
144
  color: "primary",
109
145
  "data-cy": "install-blocklet",
110
- children: loading ? /*#__PURE__*/_jsxs(_Fragment, {
146
+ title: actionType === 'upgrade' ? `${getCurrentVersion()} -> ${blocklet.version}` : '',
147
+ children: [loading ? /*#__PURE__*/_jsxs(_Fragment, {
111
148
  children: [/*#__PURE__*/_jsx(Spinner, {
112
149
  size: 16,
113
150
  style: {
114
151
  marginRight: 3
115
152
  }
116
153
  }), btnTxt]
117
- }) : btnTxt
154
+ }) : btnTxt, actionType === 'upgrade' ? /*#__PURE__*/_jsx(UpgradeIcon, {
155
+ style: {
156
+ fontSize: '1.2rem'
157
+ }
158
+ }) : null]
118
159
  }, blocklet.did)
119
160
  })
120
161
  })
@@ -142,6 +183,7 @@ export default function BlockletList({
142
183
  resourceType,
143
184
  resourceDid,
144
185
  showResourcesSwitch,
186
+ showCategory,
145
187
  ...rest
146
188
  }) {
147
189
  const {
@@ -175,6 +217,7 @@ export default function BlockletList({
175
217
  children: /*#__PURE__*/_jsx("div", {
176
218
  ...rest,
177
219
  children: initialized && /*#__PURE__*/_jsx(InnerList, {
220
+ showCategory: showCategory,
178
221
  showResourcesSwitch: showResourcesSwitch,
179
222
  blockletRender: blockletRenderProps => {
180
223
  const defaultProps = {
@@ -211,7 +254,8 @@ BlockletList.propTypes = {
211
254
  serverVersion: PropTypes.string,
212
255
  resourceType: PropTypes.string,
213
256
  resourceDid: PropTypes.string,
214
- showResourcesSwitch: PropTypes.bool
257
+ showResourcesSwitch: PropTypes.bool,
258
+ showCategory: PropTypes.bool
215
259
  };
216
260
  BlockletList.defaultProps = {
217
261
  handleButtonClick: null,
@@ -221,7 +265,8 @@ BlockletList.defaultProps = {
221
265
  serverVersion: '',
222
266
  resourceType: '',
223
267
  resourceDid: '',
224
- showResourcesSwitch: true
268
+ showResourcesSwitch: true,
269
+ showCategory: true
225
270
  };
226
271
  const StyledBlocklet = styled(Blocklet)`
227
272
  .ms-highlight {
package/lib/locales/ar.js CHANGED
@@ -613,7 +613,8 @@ export default {
613
613
  relatedComponents: 'النماذج المرتبطة',
614
614
  required: 'مطلوب',
615
615
  installed: 'مثبت',
616
- installingTip: 'جاري تثبيت المكون، الرجاء الانتظار...'
616
+ installingTip: 'جاري تثبيت المكون، الرجاء الانتظار...',
617
+ upgrade: 'ترقية'
617
618
  },
618
619
  router: {
619
620
  urlPath: 'مسار عنوان URL',
package/lib/locales/de.js CHANGED
@@ -613,7 +613,8 @@ export default {
613
613
  relatedComponents: 'Verwandte Blocklets',
614
614
  required: 'Erforderlich',
615
615
  installed: 'Installiert',
616
- installingTip: 'Komponente wird installiert, bitte warten...'
616
+ installingTip: 'Komponente wird installiert, bitte warten...',
617
+ upgrade: 'Upgrade'
617
618
  },
618
619
  router: {
619
620
  urlPath: 'URL Pfad',
package/lib/locales/en.js CHANGED
@@ -582,6 +582,7 @@ export default {
582
582
  requiredBy: 'The Blocklet is required by {name}'
583
583
  },
584
584
  choose: 'Choose',
585
+ upgrade: 'Upgrade',
585
586
  addWithName: 'Add Blocklet To {name}',
586
587
  relatedComponents: 'Related Blocklets',
587
588
  required: 'Required',
package/lib/locales/es.js CHANGED
@@ -613,7 +613,8 @@ export default {
613
613
  relatedComponents: 'Bloques relacionados',
614
614
  required: 'Requerido',
615
615
  installed: 'Instalado',
616
- installingTip: 'Instalando componente, por favor espere...'
616
+ installingTip: 'Instalando componente, por favor espere...',
617
+ upgrade: 'Mejorar'
617
618
  },
618
619
  router: {
619
620
  urlPath: 'URL Path',
package/lib/locales/fr.js CHANGED
@@ -613,7 +613,8 @@ export default {
613
613
  relatedComponents: 'Blocklets associés',
614
614
  required: 'Obligatoire',
615
615
  installed: 'Installé',
616
- installingTip: 'Installation du composant, veuillez patienter...'
616
+ installingTip: 'Installation du composant, veuillez patienter...',
617
+ upgrade: 'Mise à niveau'
617
618
  },
618
619
  router: {
619
620
  urlPath: "Chemin d'URL",
package/lib/locales/hi.js CHANGED
@@ -613,7 +613,8 @@ export default {
613
613
  relatedComponents: 'संबंधित ब्लॉकलेट्स',
614
614
  required: 'आवश्यक',
615
615
  installed: 'स्थापित',
616
- installingTip: 'घटक स्थापित हो रहा है, कृपया प्रतीक्षा करें...'
616
+ installingTip: 'घटक स्थापित हो रहा है, कृपया प्रतीक्षा करें...',
617
+ upgrade: 'अपग्रेड'
617
618
  },
618
619
  router: {
619
620
  urlPath: 'URL पथ',
Binary file
package/lib/locales/id.js CHANGED
@@ -613,7 +613,8 @@ export default {
613
613
  relatedComponents: 'Blocklet Terkait',
614
614
  required: 'Dibutuhkan',
615
615
  installed: 'Terpasang',
616
- installingTip: 'Sedang menginstal komponen, harap tunggu...'
616
+ installingTip: 'Sedang menginstal komponen, harap tunggu...',
617
+ upgrade: 'Tingkatkan'
617
618
  },
618
619
  router: {
619
620
  urlPath: 'URL Path',
package/lib/locales/ja.js CHANGED
@@ -613,7 +613,8 @@ export default {
613
613
  relatedComponents: '関連するブロック',
614
614
  required: '必要',
615
615
  installed: 'インストール',
616
- installingTip: 'コンポーネントをインストールしています、お待ちください...'
616
+ installingTip: 'コンポーネントをインストールしています、お待ちください...',
617
+ upgrade: 'アップグレード'
617
618
  },
618
619
  router: {
619
620
  urlPath: 'URLパス',
package/lib/locales/ko.js CHANGED
@@ -613,7 +613,8 @@ export default {
613
613
  relatedComponents: '관련된 블록',
614
614
  required: '필요한',
615
615
  installed: '설치됨',
616
- installingTip: '컴포넌트를 설치하는 중입니다. 기다려 주세요...'
616
+ installingTip: '컴포넌트를 설치하는 중입니다. 기다려 주세요...',
617
+ upgrade: '업그레이드'
617
618
  },
618
619
  router: {
619
620
  urlPath: 'URL 경로',
package/lib/locales/pt.js CHANGED
@@ -613,7 +613,8 @@ export default {
613
613
  relatedComponents: 'Blocos Relacionados',
614
614
  required: 'Obrigatório',
615
615
  installed: 'Instalado',
616
- installingTip: 'A instalar o componente, aguarde...'
616
+ installingTip: 'A instalar o componente, aguarde...',
617
+ upgrade: 'Atualizar'
617
618
  },
618
619
  router: {
619
620
  urlPath: 'URL Path',
package/lib/locales/ru.js CHANGED
@@ -613,7 +613,8 @@ export default {
613
613
  relatedComponents: 'Связанные блоклеты',
614
614
  required: 'Требуется',
615
615
  installed: 'Установлено',
616
- installingTip: 'Устанавливается компонент, пожалуйста, подождите...'
616
+ installingTip: 'Устанавливается компонент, пожалуйста, подождите...',
617
+ upgrade: 'Обновление'
617
618
  },
618
619
  router: {
619
620
  urlPath: 'Путь URL',
package/lib/locales/th.js CHANGED
@@ -613,7 +613,8 @@ export default {
613
613
  relatedComponents: 'บล็อกเล็ตที่เกี่ยวข้อง',
614
614
  required: 'ต้องการ',
615
615
  installed: 'ติดตั้ง',
616
- installingTip: 'กำลังติดตั้งส่วนประกอบ โปรดรอสักครู่... '
616
+ installingTip: 'กำลังติดตั้งส่วนประกอบ โปรดรอสักครู่... ',
617
+ upgrade: 'อัพเกรด'
617
618
  },
618
619
  router: {
619
620
  urlPath: 'URL Path',
package/lib/locales/vi.js CHANGED
@@ -613,7 +613,8 @@ export default {
613
613
  relatedComponents: 'Các khối liên quan',
614
614
  required: 'Cần thiết',
615
615
  installed: 'Đã cài đặt',
616
- installingTip: 'Đang cài đặt thành phần, vui lòng chờ...'
616
+ installingTip: 'Đang cài đặt thành phần, vui lòng chờ...',
617
+ upgrade: 'Nâng cấp'
617
618
  },
618
619
  router: {
619
620
  urlPath: 'URL Path',
@@ -613,7 +613,8 @@ export default {
613
613
  relatedComponents: '相關區塊',
614
614
  required: '需要',
615
615
  installed: '已安裝',
616
- installingTip: '安裝元件,請稍後...'
616
+ installingTip: '安裝元件,請稍後...',
617
+ upgrade: '升級'
617
618
  },
618
619
  router: {
619
620
  urlPath: 'URL路徑',
package/lib/locales/zh.js CHANGED
@@ -591,6 +591,7 @@ export default {
591
591
  requiredBy: '{name} 需要该 Blocklet'
592
592
  },
593
593
  choose: '选择',
594
+ upgrade: '升级',
594
595
  addWithName: '将 Blocklet 添加到 {name}',
595
596
  installed: '已安装',
596
597
  installingTip: '正在安装 Blocklet 中, 请等待安装结束',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abtnode/ux",
3
- "version": "1.16.27-beta-d1555a79",
3
+ "version": "1.16.27-beta-f109b207",
4
4
  "description": "UX components shared across abtnode packages",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -26,23 +26,23 @@
26
26
  "author": "linchen <linchen1987@foxmail.com> (http://github.com/linchen1987)",
27
27
  "license": "Apache-2.0",
28
28
  "dependencies": {
29
- "@abtnode/auth": "1.16.27-beta-d1555a79",
30
- "@abtnode/constant": "1.16.27-beta-d1555a79",
31
- "@abtnode/util": "1.16.27-beta-d1555a79",
29
+ "@abtnode/auth": "1.16.27-beta-f109b207",
30
+ "@abtnode/constant": "1.16.27-beta-f109b207",
31
+ "@abtnode/util": "1.16.27-beta-f109b207",
32
32
  "@ahooksjs/use-url-state": "^3.5.1",
33
33
  "@arcblock/did": "^1.18.121",
34
- "@arcblock/did-connect": "^2.9.82",
34
+ "@arcblock/did-connect": "^2.9.85",
35
35
  "@arcblock/did-motif": "^1.1.13",
36
- "@arcblock/icons": "^2.9.82",
37
- "@arcblock/nft-display": "2.9.82",
38
- "@arcblock/react-hooks": "^2.9.82",
39
- "@arcblock/terminal": "^2.9.82",
40
- "@arcblock/ux": "^2.9.82",
41
- "@blocklet/constant": "1.16.27-beta-d1555a79",
36
+ "@arcblock/icons": "^2.9.85",
37
+ "@arcblock/nft-display": "2.9.85",
38
+ "@arcblock/react-hooks": "^2.9.85",
39
+ "@arcblock/terminal": "^2.9.85",
40
+ "@arcblock/ux": "^2.9.85",
41
+ "@blocklet/constant": "1.16.27-beta-f109b207",
42
42
  "@blocklet/launcher-layout": "2.3.19",
43
- "@blocklet/list": "^0.12.97",
44
- "@blocklet/meta": "1.16.27-beta-d1555a79",
45
- "@blocklet/ui-react": "^2.9.82",
43
+ "@blocklet/list": "^0.12.99",
44
+ "@blocklet/meta": "1.16.27-beta-f109b207",
45
+ "@blocklet/ui-react": "^2.9.85",
46
46
  "@blocklet/uploader": "^0.1.6",
47
47
  "@emotion/react": "^11.10.4",
48
48
  "@emotion/styled": "^11.10.4",
@@ -107,5 +107,5 @@
107
107
  "jest": "^29.7.0",
108
108
  "jest-environment-jsdom": "^29.7.0"
109
109
  },
110
- "gitHead": "10055507ae6190a13ee83e2f6446fd64523dd298"
110
+ "gitHead": "1c1ba090d312cb41894d7c4bb7f1a1067f84c39a"
111
111
  }