@abtnode/ux 1.16.20 → 1.16.21-beta-edf184e1

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.
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.DomainContext = exports.DomainConsumer = void 0;
7
+ exports.DomainProvider = DomainProvider;
8
+ exports.useDomainContext = useDomainContext;
9
+ var _context = require("@arcblock/ux/lib/Locale/context");
10
+ var _trim = _interopRequireDefault(require("lodash/trim"));
11
+ var _react = require("react");
12
+ var _useSetState = _interopRequireDefault(require("react-use/lib/useSetState"));
13
+ var _util = require("../util");
14
+ var _node = require("./node");
15
+ var _jsxRuntime = require("react/jsx-runtime");
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
+ const DomainContext = exports.DomainContext = /*#__PURE__*/(0, _react.createContext)({});
18
+ const {
19
+ Provider,
20
+ Consumer
21
+ } = DomainContext;
22
+
23
+ // eslint-disable-next-line react/prop-types
24
+ exports.DomainConsumer = Consumer;
25
+ function DomainProvider(_ref) {
26
+ let {
27
+ children
28
+ } = _ref;
29
+ const [state, setState] = (0, _useSetState.default)({
30
+ domain: '',
31
+ error: null
32
+ });
33
+ const {
34
+ locale,
35
+ t
36
+ } = (0, _context.useLocaleContext)();
37
+ const {
38
+ api
39
+ } = (0, _node.useNodeContext)();
40
+ const value = {
41
+ error: state.error,
42
+ domain: state.domain,
43
+ setError: error => {
44
+ setState({
45
+ error
46
+ });
47
+ },
48
+ setDomain: domain => {
49
+ const tmpDomain = (0, _trim.default)(domain);
50
+ const errMessage = (0, _util.validateDomain)(tmpDomain, locale);
51
+ setState({
52
+ domain: tmpDomain,
53
+ error: errMessage
54
+ });
55
+ },
56
+ validateDomain: async domain => {
57
+ if (!state.error) {
58
+ const result = await api.isDidDomain({
59
+ input: {
60
+ domain
61
+ }
62
+ });
63
+ if (result.value === true) {
64
+ setState({
65
+ error: t('router.domainAlias.add.isDidDomainError')
66
+ });
67
+ return false;
68
+ }
69
+ }
70
+ return true;
71
+ }
72
+ };
73
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(Provider, {
74
+ value: {
75
+ value
76
+ },
77
+ children: children
78
+ });
79
+ }
80
+ function useDomainContext() {
81
+ const {
82
+ value
83
+ } = (0, _react.useContext)(DomainContext);
84
+ return value;
85
+ }
@@ -0,0 +1,295 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = FormAutocompleteInput;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
+ var _Box = _interopRequireDefault(require("@mui/material/Box"));
10
+ var _CircularProgress = _interopRequireDefault(require("@mui/material/CircularProgress"));
11
+ var _Close = _interopRequireDefault(require("@mui/icons-material/Close"));
12
+ var _Done = _interopRequireDefault(require("@mui/icons-material/Done"));
13
+ var _IconButton = _interopRequireDefault(require("@mui/material/IconButton"));
14
+ var _Chip = _interopRequireDefault(require("@mui/material/Chip"));
15
+ var _FormHelperText = _interopRequireDefault(require("@mui/material/FormHelperText"));
16
+ var _Autocomplete = _interopRequireWildcard(require("@mui/material/Autocomplete"));
17
+ var _TextField = _interopRequireDefault(require("@mui/material/TextField"));
18
+ var _styled = _interopRequireDefault(require("@emotion/styled"));
19
+ var _Popper = _interopRequireDefault(require("@mui/material/Popper"));
20
+ var _required = _interopRequireDefault(require("./required"));
21
+ var _formWrapper = _interopRequireDefault(require("./form-wrapper"));
22
+ var _inputTriggers = _interopRequireDefault(require("./input-triggers"));
23
+ var _jsxRuntime = require("react/jsx-runtime");
24
+ var _templateObject;
25
+ const _excluded = ["label", "disabled", "required", "initialValue", "onChange", "style", "onSubmit", "triggers", "options", "formatterBeforeSubmit", "helperText", "placeholder", "renderImage", "filterKeys", "noEmpty"];
26
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
28
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
29
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
30
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
31
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
32
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
33
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
34
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
35
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
36
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
37
+ function FormAutocompleteInput(_ref) {
38
+ let {
39
+ label,
40
+ disabled,
41
+ required,
42
+ initialValue,
43
+ onChange,
44
+ style,
45
+ onSubmit,
46
+ triggers,
47
+ options,
48
+ formatterBeforeSubmit,
49
+ helperText,
50
+ placeholder,
51
+ renderImage,
52
+ filterKeys,
53
+ noEmpty
54
+ } = _ref,
55
+ rest = _objectWithoutProperties(_ref, _excluded);
56
+ const [editing, setEditing] = (0, _react.useState)(false);
57
+ const [loading, setLoading] = (0, _react.useState)(false);
58
+ const [inputValue, setInputValue] = _react.default.useState('');
59
+ const [defaultValue, setDefaultValue] = (0, _react.useState)(initialValue);
60
+ const [value, setValue] = (0, _react.useState)(defaultValue);
61
+ const optionsMap = (0, _react.useMemo)(() => {
62
+ if (!options) {
63
+ return {};
64
+ }
65
+ const cache = {};
66
+ options.forEach(v => {
67
+ cache[v.code] = v;
68
+ });
69
+ return cache;
70
+ }, [options]);
71
+ const filterOptions = () => {
72
+ if (!options) {
73
+ return [];
74
+ }
75
+ if (!inputValue) {
76
+ return options.map(v => v.code);
77
+ }
78
+ const reg = new RegExp(inputValue.toLowerCase());
79
+
80
+ // name 或者其他字段被检索到, 都可以被搜出
81
+ return options.filter(v => {
82
+ for (let i = 0; i < filterKeys.length; i++) {
83
+ var _v$key;
84
+ const key = filterKeys[i];
85
+ if (reg.test((_v$key = v[key]) === null || _v$key === void 0 ? void 0 : _v$key.toLowerCase())) {
86
+ return true;
87
+ }
88
+ }
89
+ return false;
90
+ }).map(v => v.code);
91
+ };
92
+ const handleSubmit = async () => {
93
+ setLoading(true);
94
+ try {
95
+ const shouldUpdate = await onSubmit(typeof formatterBeforeSubmit === 'function' ? formatterBeforeSubmit(value) : value);
96
+ if (shouldUpdate === false) {
97
+ setValue(defaultValue);
98
+ } else if (noEmpty && !value.length) {
99
+ setValue(initialValue);
100
+ setDefaultValue(initialValue);
101
+ } else {
102
+ setValue(value);
103
+ setDefaultValue(value);
104
+ }
105
+ } catch (err) {
106
+ setValue(defaultValue);
107
+ } finally {
108
+ setLoading(false);
109
+ setEditing(false);
110
+ }
111
+ };
112
+ const onSelectChange = (_, newValue) => {
113
+ // 确保 newValue 是数组, 并且每个元素都在 options 中
114
+ if (!Array.isArray(newValue)) {
115
+ setValue([]);
116
+ onChange([]);
117
+ return;
118
+ }
119
+ const nextValue = newValue.filter(x => optionsMap[x]);
120
+ if (!nextValue.length) {
121
+ setValue([]);
122
+ onChange([]);
123
+ return;
124
+ }
125
+ setValue(nextValue);
126
+ onChange(nextValue);
127
+ };
128
+ const input = editing ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Autocomplete.default, _objectSpread({
129
+ options: options,
130
+ value: value,
131
+ onChange: onSelectChange,
132
+ inputValue: inputValue,
133
+ onInputChange: (_, newInputValue) => {
134
+ setInputValue(newInputValue);
135
+ }
136
+ // eslint-disable-next-line no-use-before-define
137
+ ,
138
+ PopperComponent: StyledPopper,
139
+ fullWidth: true,
140
+ multiple: true,
141
+ variant: "outlined",
142
+ margin: "dense"
143
+ // size="small"
144
+ ,
145
+ filterOptions: filterOptions,
146
+ getOptionLabel: option => {
147
+ var _optionsMap$option;
148
+ return (_optionsMap$option = optionsMap[option]) === null || _optionsMap$option === void 0 ? void 0 : _optionsMap$option.name;
149
+ },
150
+ renderInput: params => /*#__PURE__*/(0, _jsxRuntime.jsx)(_TextField.default, _objectSpread(_objectSpread({}, params), {}, {
151
+ label: "",
152
+ placeholder: placeholder
153
+ })),
154
+ renderOption: (props, code) => {
155
+ var _optionsMap$code;
156
+ const selected = value.indexOf(code) !== -1;
157
+ return /*#__PURE__*/(0, _react.createElement)(Row, _objectSpread(_objectSpread({
158
+ component: "li"
159
+ }, props), {}, {
160
+ key: code
161
+ }), renderImage(optionsMap[code] || {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
162
+ sx: {
163
+ '& > img': {
164
+ mr: 2,
165
+ flexShrink: 0
166
+ }
167
+ },
168
+ style: {
169
+ flex: 1,
170
+ fontWeight: selected ? '700' : 'normal'
171
+ },
172
+ children: (_optionsMap$code = optionsMap[code]) === null || _optionsMap$code === void 0 ? void 0 : _optionsMap$code.name
173
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
174
+ component: _Close.default,
175
+ sx: {
176
+ opacity: 0.5,
177
+ width: 18,
178
+ height: 18
179
+ },
180
+ style: {
181
+ visibility: selected ? 'visible' : 'hidden'
182
+ }
183
+ }));
184
+ }
185
+ }, rest)) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
186
+ px: 1,
187
+ className: "form-item-input slot",
188
+ style: {
189
+ whiteSpace: 'pre-wrap'
190
+ },
191
+ children: value.filter(x => options.some(o => o.code === x)).map(x => /*#__PURE__*/(0, _jsxRuntime.jsx)(_Chip.default, {
192
+ label: options.find(o => o.code === x).name,
193
+ style: {
194
+ marginRight: 8
195
+ },
196
+ size: "small"
197
+ }, x))
198
+ });
199
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_formWrapper.default, {
200
+ className: "form",
201
+ style: style,
202
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
203
+ className: "form-item",
204
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
205
+ className: "form-item-label",
206
+ children: [label, required && /*#__PURE__*/(0, _jsxRuntime.jsx)(_required.default, {})]
207
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
208
+ className: "form-item-body",
209
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
210
+ className: "form-item-input",
211
+ children: input
212
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
213
+ className: "form-item-action",
214
+ children: editing ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
215
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.default, {
216
+ "data-cy": "schema-form-item-confirm",
217
+ onClick: handleSubmit,
218
+ disabled: disabled || loading,
219
+ size: "large",
220
+ children: loading ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_CircularProgress.default, {
221
+ size: 24
222
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_Done.default, {})
223
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.default, {
224
+ "data-cy": "schema-form-item-cancel",
225
+ onClick: () => {
226
+ setValue(defaultValue);
227
+ setEditing(false);
228
+ },
229
+ disabled: disabled || loading,
230
+ size: "large",
231
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Close.default, {})
232
+ })]
233
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_inputTriggers.default, {
234
+ triggers: triggers,
235
+ onEnterEdit: () => setEditing(true),
236
+ disabled: disabled
237
+ })
238
+ })]
239
+ }), editing && helperText && /*#__PURE__*/(0, _jsxRuntime.jsx)(_FormHelperText.default, {
240
+ children: helperText
241
+ })]
242
+ })
243
+ });
244
+ }
245
+ FormAutocompleteInput.propTypes = {
246
+ style: _propTypes.default.object,
247
+ onSubmit: _propTypes.default.func,
248
+ onChange: _propTypes.default.func,
249
+ label: _propTypes.default.string,
250
+ initialValue: _propTypes.default.string,
251
+ required: _propTypes.default.bool,
252
+ disabled: _propTypes.default.bool,
253
+ triggers: _propTypes.default.array,
254
+ options: _propTypes.default.array,
255
+ helperText: _propTypes.default.string,
256
+ formatterBeforeSubmit: _propTypes.default.func,
257
+ placeholder: _propTypes.default.string,
258
+ renderImage: _propTypes.default.func,
259
+ filterKeys: _propTypes.default.arrayOf(_propTypes.default.string),
260
+ noEmpty: _propTypes.default.bool
261
+ };
262
+ FormAutocompleteInput.defaultProps = {
263
+ style: {},
264
+ onSubmit: () => {},
265
+ onChange: () => {},
266
+ label: '',
267
+ initialValue: '',
268
+ required: false,
269
+ disabled: false,
270
+ triggers: [],
271
+ options: [],
272
+ helperText: '',
273
+ formatterBeforeSubmit: x => x.join(','),
274
+ placeholder: '',
275
+ filterKeys: ['name'],
276
+ renderImage: () => null,
277
+ noEmpty: false
278
+ };
279
+ const Row = _styled.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n justify-content: space-between;\n align-items: center;\n height: 48px;\n border-bottom: 1px solid rgba(0, 0, 0, 0.08);\n font-size: 1.1em;\n"])));
280
+ const StyledPopper = (0, _styled.default)(_Popper.default)(() => ({
281
+ ["& .".concat(_Autocomplete.autocompleteClasses.paper)]: {
282
+ boxShadow: '0px 8px 12px rgba(92, 92, 92, 0.04), 0px -10px 12px rgba(92, 92, 92, 0.04)',
283
+ borderRadius: '6px',
284
+ width: '100%',
285
+ border: '1px solid rgba(0, 0, 0, 0.12)',
286
+ color: 'inherit',
287
+ fontSize: 13,
288
+ position: 'absolute',
289
+ left: 0,
290
+ top: 0
291
+ },
292
+ ["& .".concat(_Autocomplete.autocompleteClasses.listbox)]: {
293
+ padding: 0
294
+ }
295
+ }));
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _notistack = require("notistack");
8
+ var _default = exports.default = _notistack.useSnackbar;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _styles = require("@mui/styles");
8
+ var _useMediaQuery = _interopRequireDefault(require("@mui/material/useMediaQuery"));
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ function useWidth() {
11
+ const theme = (0, _styles.useTheme)();
12
+ const keys = [...theme.breakpoints.keys].reverse();
13
+ return keys.reduce((output, key) => {
14
+ // eslint-disable-next-line
15
+ const matches = (0, _useMediaQuery.default)(theme.breakpoints.up(key));
16
+ return !output && matches ? key : output;
17
+ }, null) || 'xs';
18
+ }
19
+ var _default = exports.default = useWidth;
package/lib/locales/en.js CHANGED
@@ -941,8 +941,8 @@ var _default = exports.default = {
941
941
  description: 'Please provide a valid site domain'
942
942
  },
943
943
  setup: {
944
- tipStart: 'Please ensure that the domain name',
945
- tipEnd: 'has been correctly resolved',
944
+ tipStart: 'Add the DNS records for the domain',
945
+ tipEnd: 'as per the following guidelines',
946
946
  recordType: 'Record Type',
947
947
  recordValue: 'Record Value'
948
948
  },
@@ -963,25 +963,27 @@ var _default = exports.default = {
963
963
  domainAlias: {
964
964
  inputDomain: 'Manually config domain',
965
965
  nftDomain: 'Automatic config with DID Domain',
966
+ showTipHint: 'How do I configure domain name resolution?',
966
967
  add: {
967
968
  title: 'Add Additional Domain',
968
969
  domainDescription: 'Please provide a valid domain name',
969
970
  forceTip: 'Force add if domain name already exists',
970
- helperText: 'If an HTTP or HTTPS URL is entered, it will be automatically converted into a domain name.'
971
+ helperText: 'If an HTTP or HTTPS URL is entered, it will be automatically converted into a domain name.',
972
+ isDidDomainError: 'This domain is a DID Domain. Please add it using the method for automatic domain configuration.'
971
973
  },
972
974
  addCustomDomain: {
973
975
  name: 'Custom Domain'
974
976
  },
975
977
  addDomainNFT: {
976
- showNFT: 'Show NFT',
977
- tips: 'NFT Domain will do the domain name resolution automatically, no need to configure it manually, and the application will update the resolution record of the domain name automatically when needed.',
978
+ showNFT: 'Configure domain automatically',
979
+ tips: 'DID Domain will do the domain name resolution automatically, no need to configure it manually, and the application will update the resolution record of the domain name automatically when needed.',
978
980
  connect: {
979
981
  title: 'Please show your Domain NFT',
980
982
  scan: 'Scan following QR code with DID Wallet to authorize to blocklet to use your domain',
981
983
  confirm: 'Confirm on your DID Wallet',
982
984
  success: 'Authorization Successfully'
983
985
  },
984
- buyTip: "If your don't have domain yet, ",
986
+ buyTip: "If your don't have DID Domain NFT yet, ",
985
987
  buy: 'buy it now!'
986
988
  },
987
989
  delete: {
package/lib/locales/zh.js CHANGED
@@ -944,8 +944,8 @@ var _default = exports.default = {
944
944
  description: '请填写你所拥有的合法的站点域名'
945
945
  },
946
946
  setup: {
947
- tipStart: '请确保',
948
- tipEnd: '域名已经被正确解析',
947
+ tipStart: '请将',
948
+ tipEnd: '域名的 DNS 记录按照下面的提示添加',
949
949
  recordType: '记录类型',
950
950
  recordValue: '记录值'
951
951
  },
@@ -966,26 +966,28 @@ var _default = exports.default = {
966
966
  domainAlias: {
967
967
  inputDomain: '手动配置域名',
968
968
  nftDomain: '通过 DID Domain 自动配置域名',
969
+ showTipHint: '如何配置域名解析?',
969
970
  add: {
970
971
  title: '添加额外域名',
971
972
  domainDescription: '请填写有效的域名',
972
973
  forceTip: '当域名已存在时强制添加',
973
- helperText: '如果输入 HTTP 或者 HTTPS URL, 则会被自动转换为域名。'
974
+ helperText: '如果输入 HTTP 或者 HTTPS URL, 则会被自动转换为域名。',
975
+ isDidDomainError: '该域名是 DID Domain, 请使用自动配置域名的方式添加该域名。'
974
976
  },
975
977
  addCustomDomain: {
976
978
  name: '自定义域名'
977
979
  },
978
980
  addDomainNFT: {
979
981
  name: 'NFT 域名',
980
- showNFT: '出示 NFT',
981
- tips: 'NFT 域名会自动完成域名解析,无需手动配置,并且应用会在需要的时候自动更新该域名的解析记录。',
982
+ showNFT: '自动配置域名',
983
+ tips: 'DID 域名会自动完成域名解析,无需手动配置,并且应用会在需要的时候自动更新该域名的解析记录。',
982
984
  connect: {
983
985
  title: '请出示域名 NFT',
984
986
  scan: '用 DID 钱包扫描下面的二维码, 出示域名 NFT',
985
987
  confirm: '在您的 DID 钱包上确认',
986
988
  success: '授权成功'
987
989
  },
988
- buyTip: '如果还没有域名 NFT, ',
990
+ buyTip: '如果还没有 DID 域名 NFT, ',
989
991
  buy: '现在购买!'
990
992
  },
991
993
  delete: {
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = NotificationAddon;
7
+ var _react = require("react");
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
+ var _ClickAwayListener = _interopRequireDefault(require("@mui/material/ClickAwayListener"));
10
+ var _IconButton = _interopRequireDefault(require("@mui/material/IconButton"));
11
+ var _Paper = _interopRequireDefault(require("@mui/material/Paper"));
12
+ var _Badge = _interopRequireDefault(require("@mui/material/Badge"));
13
+ var _Popper = _interopRequireDefault(require("@mui/material/Popper"));
14
+ var _Notification = _interopRequireDefault(require("@arcblock/icons/lib/Notification"));
15
+ var _list = _interopRequireDefault(require("./list"));
16
+ var _jsxRuntime = require("react/jsx-runtime");
17
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
+ /* eslint-disable import/no-unresolved */
19
+ /* eslint-disable react/jsx-one-expression-per-line */
20
+
21
+ function NotificationAddon(_ref) {
22
+ let {
23
+ api,
24
+ notifications,
25
+ updateNotifications,
26
+ viewAllUrl,
27
+ teamDid
28
+ } = _ref;
29
+ const [notificationOpen, setNotificationOpen] = (0, _react.useState)(false);
30
+ const notificationAnchorRef = (0, _react.useRef)(null);
31
+ const onToggleNotification = () => {
32
+ setNotificationOpen(prevOpen => !prevOpen);
33
+ };
34
+ const onCloseNotification = e => {
35
+ if (notificationAnchorRef.current && notificationAnchorRef.current.contains(e.target)) {
36
+ return;
37
+ }
38
+ setNotificationOpen(false);
39
+ };
40
+ const unreadCount = notifications.filter(x => x.read === false).length;
41
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
42
+ className: "notification-addon",
43
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.default, {
44
+ ref: notificationAnchorRef,
45
+ "aria-controls": "notify-list-grow",
46
+ "aria-haspopup": "true",
47
+ "data-cy": "toggle-notification-btn",
48
+ onClick: onToggleNotification,
49
+ children: unreadCount > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Badge.default, {
50
+ badgeContent: unreadCount,
51
+ max: 99,
52
+ color: "primary",
53
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Notification.default, {
54
+ style: {
55
+ width: 'auto',
56
+ height: 24
57
+ }
58
+ })
59
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_Notification.default, {
60
+ style: {
61
+ width: 'auto',
62
+ height: 24
63
+ }
64
+ })
65
+ }), notificationOpen && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Popper.default, {
66
+ open: true,
67
+ anchorEl: notificationAnchorRef.current,
68
+ disablePortal: true,
69
+ placement: "bottom-end",
70
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Paper.default, {
71
+ id: "notify-list-grow",
72
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ClickAwayListener.default, {
73
+ onClickAway: onCloseNotification,
74
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
75
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_list.default, {
76
+ notifications: notifications,
77
+ updateNotifications: updateNotifications,
78
+ api: api,
79
+ viewAllUrl: viewAllUrl,
80
+ onHide: onCloseNotification,
81
+ teamDid: teamDid
82
+ })
83
+ })
84
+ })
85
+ })
86
+ })]
87
+ });
88
+ }
89
+ NotificationAddon.propTypes = {
90
+ notifications: _propTypes.default.arrayOf(_propTypes.default.object),
91
+ viewAllUrl: _propTypes.default.string.isRequired,
92
+ api: _propTypes.default.object.isRequired,
93
+ updateNotifications: _propTypes.default.func.isRequired,
94
+ teamDid: _propTypes.default.string
95
+ };
96
+ NotificationAddon.defaultProps = {
97
+ notifications: [],
98
+ teamDid: ''
99
+ };
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _SvgIcon = _interopRequireDefault(require("@mui/material/SvgIcon"));
8
+ var _jsxRuntime = require("react/jsx-runtime");
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
11
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
12
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
13
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
14
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
15
+ function CheckIcon(props) {
16
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_SvgIcon.default, _objectSpread(_objectSpread({}, props), {}, {
17
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
18
+ d: "M12 2C6.5 2 2 6.5 2 12S6.5 22 12 22 22 17.5 22 12 17.5 2 12 2M10 17L5 12L6.41 10.59L10 14.17L17.59 6.58L19 8L10 17Z"
19
+ })
20
+ }));
21
+ }
22
+ function WarningIcon(props) {
23
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_SvgIcon.default, _objectSpread(_objectSpread({}, props), {}, {
24
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
25
+ d: "M13,14H11V10H13M13,18H11V16H13M1,21H23L12,2L1,21Z"
26
+ })
27
+ }));
28
+ }
29
+ function ErrorIcon(props) {
30
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_SvgIcon.default, _objectSpread(_objectSpread({}, props), {}, {
31
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
32
+ d: "M12,2C17.53,2 22,6.47 22,12C22,17.53 17.53,22 12,22C6.47,22 2,17.53 2,12C2, 6.47 6.47,2 12,2M15.59,7L12,10.59L8.41,7L7,8.41L10.59,12L7,15.59L8.41,17L12, 13.41L15.59,17L17,15.59L13.41,12L17,8.41L15.59,7Z"
33
+ })
34
+ }));
35
+ }
36
+ function InfoIcon(props) {
37
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_SvgIcon.default, _objectSpread(_objectSpread({}, props), {}, {
38
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
39
+ d: "M13,9H11V7H13M13,17H11V11H13M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0, 0 22,12A10,10 0 0,0 12,2Z"
40
+ })
41
+ }));
42
+ }
43
+ const iconStyles = {
44
+ fontSize: 20,
45
+ marginInlineEnd: 8
46
+ };
47
+ const defaultIconVariants = {
48
+ success: /*#__PURE__*/(0, _jsxRuntime.jsx)(CheckIcon, {
49
+ style: iconStyles
50
+ }),
51
+ warning: /*#__PURE__*/(0, _jsxRuntime.jsx)(WarningIcon, {
52
+ style: iconStyles
53
+ }),
54
+ error: /*#__PURE__*/(0, _jsxRuntime.jsx)(ErrorIcon, {
55
+ style: iconStyles
56
+ }),
57
+ info: /*#__PURE__*/(0, _jsxRuntime.jsx)(InfoIcon, {
58
+ style: iconStyles
59
+ })
60
+ };
61
+ var _default = exports.default = defaultIconVariants;