@lemon-fe/kits 1.4.13 → 1.4.14-alpha.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.
- package/es/app-provider/index.d.ts +12 -1
- package/es/app-provider/index.js +17 -9
- package/es/hooks/use-batch-operator/index.d.ts +4 -0
- package/es/hooks/use-batch-operator/index.js +51 -28
- package/es/hooks/use-batch-operator/locale/en_US.js +2 -1
- package/es/hooks/use-batch-operator/locale/locale.d.ts +1 -0
- package/es/hooks/use-batch-operator/locale/vi.js +2 -1
- package/es/hooks/use-batch-operator/locale/zh_CN.js +2 -1
- package/es/hooks/use-batch-operator/locale/zh_Hant_HK.js +2 -1
- package/package.json +3 -3
|
@@ -1,9 +1,20 @@
|
|
|
1
|
-
import { type ReactNode } from 'react';
|
|
1
|
+
import React, { type ReactNode } from 'react';
|
|
2
2
|
import type { Locale } from '../locale/locale';
|
|
3
|
+
import { message, Modal } from '@lemon-fe/components';
|
|
4
|
+
import { type HooksOpts } from '@lemon-fe/hooks';
|
|
3
5
|
declare type AppConfigProps = {
|
|
4
6
|
children?: ReactNode | null;
|
|
5
7
|
locale?: Locale;
|
|
8
|
+
hooksConfig?: Partial<HooksOpts>;
|
|
9
|
+
batchOperatorConfig?: {
|
|
10
|
+
openError?: (err: Error) => void;
|
|
11
|
+
};
|
|
6
12
|
};
|
|
13
|
+
export declare const AppContext: React.Context<{
|
|
14
|
+
message: ReturnType<typeof message.useMessage>[0];
|
|
15
|
+
modal: ReturnType<typeof Modal.useModal>[0];
|
|
16
|
+
batchOperatorConfig?: AppConfigProps['batchOperatorConfig'];
|
|
17
|
+
}>;
|
|
7
18
|
declare function AppProvider(props: AppConfigProps): JSX.Element;
|
|
8
19
|
declare namespace AppProvider {
|
|
9
20
|
var useApp;
|
package/es/app-provider/index.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
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; }
|
|
3
|
+
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; }
|
|
4
|
+
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; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
1
7
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
8
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
9
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
@@ -9,7 +15,7 @@ import { PageLoading, message, Modal, ConfigProvider, Result, Button } from '@le
|
|
|
9
15
|
import { HooksConfigProvider } from '@lemon-fe/hooks';
|
|
10
16
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
17
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
-
var AppContext = /*#__PURE__*/createContext({
|
|
18
|
+
export var AppContext = /*#__PURE__*/createContext({
|
|
13
19
|
message: message,
|
|
14
20
|
modal: Modal
|
|
15
21
|
});
|
|
@@ -25,15 +31,17 @@ export default function AppProvider(props) {
|
|
|
25
31
|
_Modal$useModal2 = _slicedToArray(_Modal$useModal, 2),
|
|
26
32
|
modalApi = _Modal$useModal2[0],
|
|
27
33
|
modalContextHolder = _Modal$useModal2[1];
|
|
28
|
-
var
|
|
34
|
+
var localeCtx = useContext(ConfigProvider.ConfigContext).locale;
|
|
35
|
+
var locale = props.locale || localeCtx;
|
|
29
36
|
var appContext = useMemo(function () {
|
|
30
37
|
return {
|
|
31
38
|
message: messageApi,
|
|
32
|
-
modal: modalApi
|
|
39
|
+
modal: modalApi,
|
|
40
|
+
batchOperatorConfig: props.batchOperatorConfig
|
|
33
41
|
};
|
|
34
|
-
}, []);
|
|
42
|
+
}, [props.batchOperatorConfig, messageApi, modalApi]);
|
|
35
43
|
var hooksConfig = useMemo(function () {
|
|
36
|
-
var result = {
|
|
44
|
+
var result = _objectSpread({
|
|
37
45
|
showToast: function showToast() {
|
|
38
46
|
var _locale$Common;
|
|
39
47
|
return messageApi.loading(locale === null || locale === void 0 || (_locale$Common = locale.Common) === null || _locale$Common === void 0 ? void 0 : _locale$Common.waitingText, 0);
|
|
@@ -58,7 +66,7 @@ export default function AppProvider(props) {
|
|
|
58
66
|
});
|
|
59
67
|
},
|
|
60
68
|
errorResult: function errorResult(err, refresh) {
|
|
61
|
-
var
|
|
69
|
+
var _locale$Common2;
|
|
62
70
|
return /*#__PURE__*/_jsx(Result, {
|
|
63
71
|
status: "500",
|
|
64
72
|
title: "500",
|
|
@@ -66,13 +74,13 @@ export default function AppProvider(props) {
|
|
|
66
74
|
extra: /*#__PURE__*/_jsx(Button, {
|
|
67
75
|
type: "primary",
|
|
68
76
|
onClick: refresh,
|
|
69
|
-
children:
|
|
77
|
+
children: locale === null || locale === void 0 || (_locale$Common2 = locale.Common) === null || _locale$Common2 === void 0 ? void 0 : _locale$Common2.reloadPageText
|
|
70
78
|
})
|
|
71
79
|
});
|
|
72
80
|
}
|
|
73
|
-
};
|
|
81
|
+
}, props.hooksConfig);
|
|
74
82
|
return result;
|
|
75
|
-
}, [props.
|
|
83
|
+
}, [props.hooksConfig, messageApi, locale]);
|
|
76
84
|
return /*#__PURE__*/_jsxs(AppContext.Provider, {
|
|
77
85
|
value: appContext,
|
|
78
86
|
children: [messageContextHolder, modalContextHolder, /*#__PURE__*/_jsx(HooksConfigProvider, {
|
|
@@ -85,6 +85,10 @@ interface Props<RecordType extends Record<string, any> = Record<string, any>, Re
|
|
|
85
85
|
* @description 打开立即执行
|
|
86
86
|
*/
|
|
87
87
|
executeWhenOpen?: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* @description 显示完整信息,可点击
|
|
90
|
+
*/
|
|
91
|
+
openError?: (err: Error) => void;
|
|
88
92
|
}
|
|
89
93
|
export default function useBatchOperate<RecordType extends Record<string, any> = Record<string, any>, ResultType = any, ParamsType = any>(options: Props<RecordType, ResultType, ParamsType>): {
|
|
90
94
|
run: (rows: RecordType[], otherOpts?: Partial<Props<RecordType, ResultType, ParamsType>>) => void;
|
|
@@ -27,8 +27,10 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
|
27
27
|
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; }
|
|
28
28
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
29
29
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
30
|
+
import { Tooltip } from 'antd';
|
|
30
31
|
import React, { useContext, Component, createRef } from 'react';
|
|
31
32
|
import { unmountComponentAtNode, render } from 'react-dom';
|
|
33
|
+
import { AppContext } from "../../app-provider";
|
|
32
34
|
import defaultLocale from "./locale/zh_CN";
|
|
33
35
|
import { ConfigProvider, Modal, Row, Spin, Typography } from '@lemon-fe/components';
|
|
34
36
|
import { Actions, ComponentConfigureContext, DataGrid, Icons, Layout, Section } from '@lemon-fe/components';
|
|
@@ -49,6 +51,39 @@ var BatchOperate = /*#__PURE__*/function (_Component) {
|
|
|
49
51
|
_defineProperty(_assertThisInitialized(_this), "resultsSubject", new Subject());
|
|
50
52
|
_defineProperty(_assertThisInitialized(_this), "mounted", true);
|
|
51
53
|
_defineProperty(_assertThisInitialized(_this), "locale", defaultLocale);
|
|
54
|
+
_defineProperty(_assertThisInitialized(_this), "renderIconTip", function (type, err) {
|
|
55
|
+
if (!(err instanceof Error)) {
|
|
56
|
+
return /*#__PURE__*/_jsx(Icons.Tip, {
|
|
57
|
+
type: type,
|
|
58
|
+
style: {
|
|
59
|
+
marginRight: 2
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
var openError = _this.props.openError;
|
|
64
|
+
var clickToShowMore = _this.locale.clickToShowMore;
|
|
65
|
+
if (openError && type === 'error') {
|
|
66
|
+
return /*#__PURE__*/_jsx(Tooltip, {
|
|
67
|
+
title: clickToShowMore,
|
|
68
|
+
children: /*#__PURE__*/_jsx(Icons.Tip, {
|
|
69
|
+
type: type,
|
|
70
|
+
style: {
|
|
71
|
+
marginRight: 2
|
|
72
|
+
},
|
|
73
|
+
onClick: function onClick() {
|
|
74
|
+
return openError(err);
|
|
75
|
+
}
|
|
76
|
+
})
|
|
77
|
+
});
|
|
78
|
+
} else {
|
|
79
|
+
return /*#__PURE__*/_jsx(Icons.Tip, {
|
|
80
|
+
type: type,
|
|
81
|
+
style: {
|
|
82
|
+
marginRight: 2
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
});
|
|
52
87
|
_defineProperty(_assertThisInitialized(_this), "getRowKey", function (record) {
|
|
53
88
|
var rowKey = _this.props.rowKey;
|
|
54
89
|
var result = typeof rowKey === 'function' ? rowKey(record) : get(record, rowKey);
|
|
@@ -231,12 +266,7 @@ var BatchOperate = /*#__PURE__*/function (_Component) {
|
|
|
231
266
|
style: {
|
|
232
267
|
flex: 1
|
|
233
268
|
},
|
|
234
|
-
children: [/*#__PURE__*/
|
|
235
|
-
type: "warning",
|
|
236
|
-
style: {
|
|
237
|
-
marginRight: 2
|
|
238
|
-
}
|
|
239
|
-
}), /*#__PURE__*/_jsxs("span", {
|
|
269
|
+
children: [_this2.renderIconTip('warning', error), /*#__PURE__*/_jsxs("span", {
|
|
240
270
|
children: [error.message, " "]
|
|
241
271
|
})]
|
|
242
272
|
}), /*#__PURE__*/_jsx("a", {
|
|
@@ -257,12 +287,7 @@ var BatchOperate = /*#__PURE__*/function (_Component) {
|
|
|
257
287
|
ellipsis: {
|
|
258
288
|
tooltip: error.message
|
|
259
289
|
},
|
|
260
|
-
children: [/*#__PURE__*/_jsx(
|
|
261
|
-
type: "error",
|
|
262
|
-
style: {
|
|
263
|
-
marginRight: 2
|
|
264
|
-
}
|
|
265
|
-
}), /*#__PURE__*/_jsx("span", {
|
|
290
|
+
children: [_this2.renderIconTip('error', error), /*#__PURE__*/_jsx("span", {
|
|
266
291
|
children: error.message
|
|
267
292
|
})]
|
|
268
293
|
}), /*#__PURE__*/_jsx(Icons.Reload, {
|
|
@@ -388,6 +413,7 @@ var BatchOperate = /*#__PURE__*/function (_Component) {
|
|
|
388
413
|
}, {
|
|
389
414
|
key: "getProcess",
|
|
390
415
|
value: function getProcess() {
|
|
416
|
+
var _this4 = this;
|
|
391
417
|
var _this$props2 = this.props,
|
|
392
418
|
process = _this$props2.process,
|
|
393
419
|
_handler = _this$props2.handler,
|
|
@@ -424,12 +450,7 @@ var BatchOperate = /*#__PURE__*/function (_Component) {
|
|
|
424
450
|
ellipsis: {
|
|
425
451
|
tooltip: error.message
|
|
426
452
|
},
|
|
427
|
-
children: [/*#__PURE__*/_jsx(
|
|
428
|
-
type: "error",
|
|
429
|
-
style: {
|
|
430
|
-
marginRight: 2
|
|
431
|
-
}
|
|
432
|
-
}), /*#__PURE__*/_jsx("span", {
|
|
453
|
+
children: [_this4.renderIconTip('error', error), /*#__PURE__*/_jsx("span", {
|
|
433
454
|
children: error.message
|
|
434
455
|
})]
|
|
435
456
|
}), /*#__PURE__*/_jsx(Icons.Reload, {
|
|
@@ -487,7 +508,7 @@ var BatchOperate = /*#__PURE__*/function (_Component) {
|
|
|
487
508
|
}, {
|
|
488
509
|
key: "getCols",
|
|
489
510
|
value: function getCols() {
|
|
490
|
-
var
|
|
511
|
+
var _this5 = this;
|
|
491
512
|
var _this$props3 = this.props,
|
|
492
513
|
columns = _this$props3.columns,
|
|
493
514
|
rowKey = _this$props3.rowKey;
|
|
@@ -530,13 +551,13 @@ var BatchOperate = /*#__PURE__*/function (_Component) {
|
|
|
530
551
|
api.applyTransaction({
|
|
531
552
|
remove: [node.data]
|
|
532
553
|
});
|
|
533
|
-
|
|
554
|
+
_this5.setState(function (prev) {
|
|
534
555
|
var results = prev.results,
|
|
535
556
|
data = prev.data;
|
|
536
557
|
var newData = _toConsumableArray(data);
|
|
537
558
|
var newResults = results;
|
|
538
559
|
newData.splice(data.findIndex(function (item) {
|
|
539
|
-
return
|
|
560
|
+
return _this5.getRowKey(item) === node.id;
|
|
540
561
|
}), 1);
|
|
541
562
|
if (results.has(key)) {
|
|
542
563
|
newResults = new Map(results);
|
|
@@ -611,7 +632,7 @@ var BatchOperate = /*#__PURE__*/function (_Component) {
|
|
|
611
632
|
}, {
|
|
612
633
|
key: "render",
|
|
613
634
|
value: function render() {
|
|
614
|
-
var
|
|
635
|
+
var _this6 = this,
|
|
615
636
|
_results$get;
|
|
616
637
|
var _this$props4 = this.props,
|
|
617
638
|
modalTitle = _this$props4.modalTitle,
|
|
@@ -640,10 +661,10 @@ var BatchOperate = /*#__PURE__*/function (_Component) {
|
|
|
640
661
|
centered: true,
|
|
641
662
|
open: open,
|
|
642
663
|
onCancel: function onCancel() {
|
|
643
|
-
|
|
664
|
+
_this6.setState({
|
|
644
665
|
paused: true
|
|
645
666
|
}, function () {
|
|
646
|
-
|
|
667
|
+
_this6.handleClose();
|
|
647
668
|
});
|
|
648
669
|
},
|
|
649
670
|
footer: typeof footer === 'function' ? footer(data, {
|
|
@@ -651,7 +672,7 @@ var BatchOperate = /*#__PURE__*/function (_Component) {
|
|
|
651
672
|
}) : footer,
|
|
652
673
|
maskClosable: false,
|
|
653
674
|
afterClose: function afterClose() {
|
|
654
|
-
|
|
675
|
+
_this6.setState({
|
|
655
676
|
results: new Map(),
|
|
656
677
|
paused: true,
|
|
657
678
|
active: undefined,
|
|
@@ -675,7 +696,7 @@ var BatchOperate = /*#__PURE__*/function (_Component) {
|
|
|
675
696
|
disabled: data.length <= 0,
|
|
676
697
|
text: suspendExecText,
|
|
677
698
|
onClick: function onClick() {
|
|
678
|
-
|
|
699
|
+
_this6.setState({
|
|
679
700
|
paused: true
|
|
680
701
|
});
|
|
681
702
|
}
|
|
@@ -707,6 +728,8 @@ var BatchOperate = /*#__PURE__*/function (_Component) {
|
|
|
707
728
|
export default function useBatchOperate(options) {
|
|
708
729
|
var ctx = useContext(ConfigProvider.ConfigContext);
|
|
709
730
|
var componentCtx = useContext(ComponentConfigureContext);
|
|
731
|
+
var _useContext = useContext(AppContext),
|
|
732
|
+
batchOperatorConfig = _useContext.batchOperatorConfig;
|
|
710
733
|
var run = function run(rows) {
|
|
711
734
|
var otherOpts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
712
735
|
var root = document.createDocumentFragment();
|
|
@@ -718,9 +741,9 @@ export default function useBatchOperate(options) {
|
|
|
718
741
|
iconPrefixCls: iconPrefixCls,
|
|
719
742
|
children: /*#__PURE__*/_jsx(ComponentConfigureContext.Provider, {
|
|
720
743
|
value: componentCtx,
|
|
721
|
-
children: /*#__PURE__*/_jsx(BatchOperate, _objectSpread(_objectSpread(_objectSpread({
|
|
744
|
+
children: /*#__PURE__*/_jsx(BatchOperate, _objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
722
745
|
rows: rows
|
|
723
|
-
}, options), otherOpts), {}, {
|
|
746
|
+
}, options), otherOpts), batchOperatorConfig), {}, {
|
|
724
747
|
locale: locale,
|
|
725
748
|
afterClose: function afterClose() {
|
|
726
749
|
unmountComponentAtNode(root);
|
|
@@ -8,6 +8,7 @@ var locale = {
|
|
|
8
8
|
suspendExecText: 'Tạm dừng thực thi',
|
|
9
9
|
resultStateText: 'Trạng thái xử lý',
|
|
10
10
|
pendingStateText: 'Chờ xử lý',
|
|
11
|
-
progressStateText: 'Đang trong quá trình thực hiện'
|
|
11
|
+
progressStateText: 'Đang trong quá trình thực hiện',
|
|
12
|
+
clickToShowMore: 'Nhấn để hiển thị thêm'
|
|
12
13
|
};
|
|
13
14
|
export default locale;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lemon-fe/kits",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.14-alpha.0",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"homepage": "",
|
|
6
6
|
"license": "ISC",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@ant-design/icons": "^4.7.0",
|
|
27
|
-
"@lemon-fe/components": "^1.4.
|
|
27
|
+
"@lemon-fe/components": "^1.4.14-alpha.0",
|
|
28
28
|
"@lemon-fe/hooks": "^1.4.0",
|
|
29
29
|
"@lemon-fe/utils": "^1.3.0",
|
|
30
30
|
"ag-grid-community": "29.2.0",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"publishConfig": {
|
|
47
47
|
"registry": "https://registry.npmjs.org"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "0f2dec6feeb73340dad98b60197a6fe24be8b194"
|
|
50
50
|
}
|