@lemon-fe/kits 1.0.0-127 → 1.0.0-129
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import type { ComponentOption, FilterProps } from './typings';
|
|
3
3
|
declare function Filter<T extends Record<string, any> = Record<string, any>>(props: FilterProps<T>): JSX.Element;
|
|
4
4
|
declare namespace Filter {
|
|
@@ -12,5 +12,4 @@ declare namespace Filter {
|
|
|
12
12
|
}) => void | Promise<void>) => void;
|
|
13
13
|
var defaultProps: Partial<FilterProps<Record<string, any>>>;
|
|
14
14
|
}
|
|
15
|
-
|
|
16
|
-
export default _default;
|
|
15
|
+
export default Filter;
|
|
@@ -38,7 +38,7 @@ import { useDebounce, useRequest } from '@lemon-fe/hooks';
|
|
|
38
38
|
import { Button, Checkbox, Form, Input, Popover, Space, Modal, message, Select, Empty, InputNumber } from 'antd';
|
|
39
39
|
import classNames from 'classnames';
|
|
40
40
|
import ResizeObserver from 'rc-resize-observer';
|
|
41
|
-
import React, {
|
|
41
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
42
42
|
import Dropdown from "../Dropdown";
|
|
43
43
|
import DurationPicker from "../DurationPicker";
|
|
44
44
|
import FormLayout from "../FormLayout";
|
|
@@ -675,4 +675,4 @@ function Filter(props) {
|
|
|
675
675
|
Filter.setComponents = setComponents;
|
|
676
676
|
Filter.setStorage = setStorage;
|
|
677
677
|
Filter.defaultProps = {};
|
|
678
|
-
export default
|
|
678
|
+
export default Filter;
|
|
@@ -2,7 +2,7 @@ import { type ReactElement } from 'react';
|
|
|
2
2
|
import type { Key } from 'react';
|
|
3
3
|
import type { ColType, DataGridProps } from "../../components/DataGrid/typings";
|
|
4
4
|
declare type Result<ResultType> = Error | symbol | ResultType;
|
|
5
|
-
|
|
5
|
+
interface Props<RecordType extends Record<string, any> = Record<string, any>, ResultType = any> {
|
|
6
6
|
modalTitle: string;
|
|
7
7
|
handler: (record: RecordType) => Promise<ResultType>;
|
|
8
8
|
columns?: ColType<RecordType>[];
|
|
@@ -36,8 +36,9 @@ export default function useBatchOperate<RecordType extends Record<string, any> =
|
|
|
36
36
|
reload: () => any;
|
|
37
37
|
}) => ReactElement | string | number | null;
|
|
38
38
|
isError?: (result: ResultType) => boolean;
|
|
39
|
-
}
|
|
40
|
-
|
|
39
|
+
}
|
|
40
|
+
export default function useBatchOperate<RecordType extends Record<string, any> = Record<string, any>, ResultType = any>(options: Props<RecordType, ResultType>): {
|
|
41
41
|
run: (rows: RecordType[]) => void;
|
|
42
|
+
node: null;
|
|
42
43
|
};
|
|
43
44
|
export {};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
2
|
|
|
3
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
|
+
|
|
3
5
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
4
6
|
|
|
5
7
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
@@ -31,29 +33,34 @@ import { useThrottle } from '@lemon-fe/hooks';
|
|
|
31
33
|
import { Modal, Row, Spin } from 'antd';
|
|
32
34
|
import { get } from 'lodash';
|
|
33
35
|
import React, { useMemo, useState, useRef, useEffect } from 'react';
|
|
36
|
+
import { render } from 'react-dom';
|
|
37
|
+
import { unmountComponentAtNode } from 'react-dom';
|
|
34
38
|
import Actions from "../../components/Actions";
|
|
35
39
|
import DataGrid from "../../components/DataGrid";
|
|
36
40
|
import Icons from "../../components/Icons";
|
|
37
41
|
import Layout from "../../components/Layout";
|
|
38
42
|
import Section from "../../components/Section";
|
|
39
43
|
var loading = Symbol('loading');
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
44
|
+
|
|
45
|
+
function BatchOperate(props) {
|
|
46
|
+
var rows = props.rows,
|
|
47
|
+
_props$modalTitle = props.modalTitle,
|
|
48
|
+
modalTitle = _props$modalTitle === void 0 ? '批量操作' : _props$modalTitle,
|
|
49
|
+
handler = props.handler,
|
|
50
|
+
columns = props.columns,
|
|
51
|
+
onClose = props.onClose,
|
|
52
|
+
onBeforeClose = props.onBeforeClose,
|
|
53
|
+
rowKey = props.rowKey,
|
|
54
|
+
renderResult = props.renderResult,
|
|
55
|
+
isError = props.isError,
|
|
56
|
+
_afterClose = props.afterClose;
|
|
57
|
+
|
|
58
|
+
var _useState = useState(true),
|
|
52
59
|
_useState2 = _slicedToArray(_useState, 2),
|
|
53
60
|
visible = _useState2[0],
|
|
54
61
|
setVisible = _useState2[1];
|
|
55
62
|
|
|
56
|
-
var _useState3 = useState(
|
|
63
|
+
var _useState3 = useState(rows),
|
|
57
64
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
58
65
|
data = _useState4[0],
|
|
59
66
|
setData = _useState4[1];
|
|
@@ -209,11 +216,6 @@ export default function useBatchOperate(options) {
|
|
|
209
216
|
}, _callee2, null, [[6, 13]]);
|
|
210
217
|
})), 500);
|
|
211
218
|
|
|
212
|
-
var run = function run(rows) {
|
|
213
|
-
setVisible(true);
|
|
214
|
-
setData(rows);
|
|
215
|
-
};
|
|
216
|
-
|
|
217
219
|
var handleClose = /*#__PURE__*/function () {
|
|
218
220
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
219
221
|
var value;
|
|
@@ -394,11 +396,11 @@ export default function useBatchOperate(options) {
|
|
|
394
396
|
});
|
|
395
397
|
return cols;
|
|
396
398
|
}, [columns, paused, active]);
|
|
397
|
-
|
|
399
|
+
return /*#__PURE__*/React.createElement(Modal, {
|
|
398
400
|
title: modalTitle,
|
|
399
|
-
open: visible,
|
|
400
401
|
width: 1000,
|
|
401
402
|
centered: true,
|
|
403
|
+
open: visible,
|
|
402
404
|
onCancel: handleClose,
|
|
403
405
|
footer: null,
|
|
404
406
|
maskClosable: false,
|
|
@@ -411,6 +413,8 @@ export default function useBatchOperate(options) {
|
|
|
411
413
|
setPaused(true);
|
|
412
414
|
setActive(-1);
|
|
413
415
|
setData([]);
|
|
416
|
+
|
|
417
|
+
_afterClose();
|
|
414
418
|
},
|
|
415
419
|
keyboard: false
|
|
416
420
|
}, /*#__PURE__*/React.createElement(Layout, {
|
|
@@ -445,8 +449,22 @@ export default function useBatchOperate(options) {
|
|
|
445
449
|
columns: mCols,
|
|
446
450
|
rowKey: rowKey
|
|
447
451
|
}))));
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
export default function useBatchOperate(options) {
|
|
455
|
+
var run = function run(rows) {
|
|
456
|
+
var root = document.createDocumentFragment();
|
|
457
|
+
render( /*#__PURE__*/React.createElement(BatchOperate, _extends({
|
|
458
|
+
rows: rows
|
|
459
|
+
}, options, {
|
|
460
|
+
afterClose: function afterClose() {
|
|
461
|
+
unmountComponentAtNode(root);
|
|
462
|
+
}
|
|
463
|
+
})), root);
|
|
464
|
+
};
|
|
465
|
+
|
|
448
466
|
return {
|
|
449
|
-
|
|
450
|
-
|
|
467
|
+
run: run,
|
|
468
|
+
node: null
|
|
451
469
|
};
|
|
452
470
|
}
|