@lemon-fe/kits 1.0.0-125 → 1.0.0-127

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
- /// <reference types="react" />
1
+ import React from '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 {
@@ -7,9 +7,10 @@ declare namespace Filter {
7
7
  title: string;
8
8
  value: Record<string | number, any>;
9
9
  }>(getData: (storageKey: string) => T[] | Promise<T[]>, setData: (storageKey: string, data: T[], action: {
10
- type: "delete" | "set";
10
+ type: "set" | "delete";
11
11
  target: T;
12
12
  }) => void | Promise<void>) => void;
13
13
  var defaultProps: Partial<FilterProps<Record<string, any>>>;
14
14
  }
15
- export default Filter;
15
+ declare const _default: React.MemoExoticComponent<typeof Filter>;
16
+ export default _default;
@@ -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, { useEffect, useMemo, useState } from 'react';
41
+ import React, { memo, useEffect, useMemo, useState } from 'react';
42
42
  import Dropdown from "../Dropdown";
43
43
  import DurationPicker from "../DurationPicker";
44
44
  import FormLayout from "../FormLayout";
@@ -190,14 +190,14 @@ function Filter(props) {
190
190
  collapsed = _useState14[0],
191
191
  setCollapsed = _useState14[1];
192
192
 
193
- var _useRequest = useRequest(function () {
193
+ useRequest(function () {
194
194
  if (!storageKey) {
195
195
  return null;
196
196
  }
197
197
 
198
198
  return getStorageData(storageKey);
199
199
  }, {
200
- loadingState: false,
200
+ manual: false,
201
201
  onSuccess: function onSuccess(res) {
202
202
  if (res !== null) {
203
203
  setTabs(function (prev) {
@@ -205,12 +205,7 @@ function Filter(props) {
205
205
  });
206
206
  }
207
207
  }
208
- }),
209
- init = _useRequest.run;
210
-
211
- useEffect(function () {
212
- init();
213
- }, []);
208
+ });
214
209
  useEffect(function () {
215
210
  if (value) {
216
211
  form.setFieldsValue(value);
@@ -357,7 +352,7 @@ function Filter(props) {
357
352
  var result = _objectSpread(_objectSpread({}, emptyValue), tabs[index].value);
358
353
 
359
354
  form.setFieldsValue(result);
360
- handleFinish(result, 'reset');
355
+ handleFinish(form.getFieldsValue(), 'reset');
361
356
  }
362
357
  };
363
358
 
@@ -680,4 +675,4 @@ function Filter(props) {
680
675
  Filter.setComponents = setComponents;
681
676
  Filter.setStorage = setStorage;
682
677
  Filter.defaultProps = {};
683
- export default Filter;
678
+ export default /*#__PURE__*/memo(Filter);
@@ -26,6 +26,9 @@ declare namespace FormLayout {
26
26
  children?: React.ReactNode;
27
27
  }>;
28
28
  var Col: React.FC<{
29
+ /**
30
+ * @description 最大24,设计上6为一列
31
+ */
29
32
  span?: number | undefined;
30
33
  children?: React.ReactNode;
31
34
  className?: string | undefined;
@@ -4,8 +4,8 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
4
4
 
5
5
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
6
 
7
- import React from 'react';
8
7
  import classNames from 'classnames';
8
+ import React from 'react';
9
9
  import { prefixClassName } from "../utils";
10
10
  var prefix = prefixClassName('form');
11
11
 
@@ -58,6 +58,7 @@
58
58
 
59
59
  &-control {
60
60
  flex: 1 1 0;
61
+ min-width: 0;
61
62
  }
62
63
  }
63
64
 
@@ -1,5 +1,5 @@
1
- import type { ComponentProps } from 'react';
2
1
  import Icon from '@ant-design/icons';
2
+ import type { ComponentProps } from 'react';
3
3
  export default function Tip(props: {
4
4
  type?: 'success' | 'error' | 'warning' | 'info';
5
5
  } & ComponentProps<typeof Icon>): JSX.Element;
@@ -6,131 +6,121 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
6
6
 
7
7
  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); }
8
8
 
9
- import React from 'react';
10
9
  import Icon from '@ant-design/icons';
10
+ import React from 'react';
11
11
 
12
12
  var ErrorSvg = function ErrorSvg(props) {
13
13
  return /*#__PURE__*/React.createElement("svg", _extends({
14
- width: "1em",
15
- height: "1em",
16
14
  xmlns: "http://www.w3.org/2000/svg",
17
15
  viewBox: "0 0 20 20"
18
16
  }, props), /*#__PURE__*/React.createElement("g", {
19
17
  fill: "none",
20
18
  fillRule: "evenodd"
21
19
  }, /*#__PURE__*/React.createElement("circle", {
22
- fill: "#EC4510",
23
20
  cx: "10",
24
21
  cy: "10",
25
- r: "10"
26
- }), /*#__PURE__*/React.createElement("g", {
27
- transform: "rotate(45 3.172 12.828)",
28
- fill: "#FFF"
29
- }, /*#__PURE__*/React.createElement("rect", {
30
- x: "4",
31
- width: "4",
32
- height: "12",
33
- rx: "1"
22
+ r: "10",
23
+ fill: "#FF4128"
24
+ }), /*#__PURE__*/React.createElement("rect", {
25
+ width: "2",
26
+ height: "10",
27
+ x: "9",
28
+ y: "5",
29
+ fill: "#FFF",
30
+ rx: "1",
31
+ transform: "rotate(45 10 10)"
34
32
  }), /*#__PURE__*/React.createElement("rect", {
35
- transform: "rotate(90 6 6)",
36
- x: "4",
37
- width: "4",
38
- height: "12",
39
- rx: "1"
40
- }))));
33
+ width: "2",
34
+ height: "10",
35
+ x: "9",
36
+ y: "5",
37
+ fill: "#FFF",
38
+ rx: "1",
39
+ transform: "scale(-1 1) rotate(45 0 -14.142)"
40
+ })));
41
41
  };
42
42
 
43
43
  var SuccessSvg = function SuccessSvg(props) {
44
44
  return /*#__PURE__*/React.createElement("svg", _extends({
45
- width: "1em",
46
- height: "1em",
47
45
  xmlns: "http://www.w3.org/2000/svg",
48
46
  viewBox: "0 0 20 20"
49
47
  }, props), /*#__PURE__*/React.createElement("g", {
50
48
  fill: "none",
51
49
  fillRule: "evenodd"
52
50
  }, /*#__PURE__*/React.createElement("circle", {
53
- fill: "#1ED07C",
54
51
  cx: "10",
55
52
  cy: "10",
56
- r: "10"
57
- }), /*#__PURE__*/React.createElement("g", {
58
- transform: "rotate(45 3.379 14.743)",
59
- fill: "#FFF"
60
- }, /*#__PURE__*/React.createElement("rect", {
61
- x: "4",
62
- width: "4",
63
- height: "12",
64
- rx: "1"
65
- }), /*#__PURE__*/React.createElement("rect", {
66
- transform: "rotate(90 4 10)",
67
- x: "2",
68
- y: "6",
69
- width: "4",
70
- height: "8",
71
- rx: "1"
72
- }))));
53
+ r: "10",
54
+ fill: "#22C07D"
55
+ }), /*#__PURE__*/React.createElement("path", {
56
+ stroke: "#FFF",
57
+ strokeLinecap: "round",
58
+ strokeLinejoin: "round",
59
+ strokeWidth: "2",
60
+ d: "m14.243 7.586-5.657 5.657-2.829-2.829"
61
+ })));
73
62
  };
74
63
 
75
64
  var WarningSvg = function WarningSvg(props) {
76
65
  return /*#__PURE__*/React.createElement("svg", _extends({
77
- width: "1em",
78
- height: "1em",
79
66
  xmlns: "http://www.w3.org/2000/svg",
80
67
  viewBox: "0 0 20 20"
81
68
  }, props), /*#__PURE__*/React.createElement("g", {
82
69
  fill: "none",
83
70
  fillRule: "evenodd"
84
71
  }, /*#__PURE__*/React.createElement("circle", {
85
- fill: "#FAAD14",
86
72
  cx: "10",
87
73
  cy: "10",
88
- r: "10"
74
+ r: "10",
75
+ fill: "#FF7F18"
89
76
  }), /*#__PURE__*/React.createElement("rect", {
77
+ width: "2",
78
+ height: "8",
79
+ x: "9",
80
+ y: "4",
90
81
  fill: "#FFF",
91
- x: "8",
92
- y: "13",
93
- width: "4",
94
- height: "4",
95
- rx: "1"
82
+ rx: "1",
83
+ transform: "matrix(-1 0 0 1 20 0)"
96
84
  }), /*#__PURE__*/React.createElement("rect", {
85
+ width: "2",
86
+ height: "2",
87
+ x: "9",
88
+ y: "13",
97
89
  fill: "#FFF",
98
- x: "8",
99
- y: "4",
100
- width: "4",
101
- height: "8",
102
- rx: "1"
90
+ rx: "1",
91
+ transform: "matrix(-1 0 0 1 20 0)"
103
92
  })));
104
93
  };
105
94
 
106
95
  var InfoSvg = function InfoSvg(props) {
107
96
  return /*#__PURE__*/React.createElement("svg", _extends({
108
- width: "1em",
109
- height: "1em",
110
97
  xmlns: "http://www.w3.org/2000/svg",
111
98
  viewBox: "0 0 20 20"
112
99
  }, props), /*#__PURE__*/React.createElement("g", {
113
100
  fill: "none",
114
- fillRule: "evenodd"
101
+ fillRule: "evenodd",
102
+ transform: "rotate(-180 10 10)"
115
103
  }, /*#__PURE__*/React.createElement("circle", {
116
- fill: "#2357DF",
117
104
  cx: "10",
118
105
  cy: "10",
119
- r: "10"
106
+ r: "10",
107
+ fill: "#226BF3"
120
108
  }), /*#__PURE__*/React.createElement("rect", {
121
- fill: "#FFF",
122
- x: "8",
109
+ width: "2",
110
+ height: "8",
111
+ x: "9",
123
112
  y: "4",
124
- width: "4",
125
- height: "4",
126
- rx: "1"
113
+ fill: "#FFF",
114
+ rx: "1",
115
+ transform: "matrix(-1 0 0 1 20 0)"
127
116
  }), /*#__PURE__*/React.createElement("rect", {
117
+ width: "2",
118
+ height: "2",
119
+ x: "9",
120
+ y: "13",
128
121
  fill: "#FFF",
129
- x: "8",
130
- y: "9",
131
- width: "4",
132
- height: "8",
133
- rx: "1"
122
+ rx: "1",
123
+ transform: "matrix(-1 0 0 1 20 0)"
134
124
  })));
135
125
  };
136
126
 
@@ -5,6 +5,10 @@
5
5
  height: 100%;
6
6
  background: #fff;
7
7
 
8
+ .@{ant-prefix}-modal-body & {
9
+ background: transparent;
10
+ }
11
+
8
12
  &-header {
9
13
  min-height: (46px - @space-v);
10
14
  padding: @space-v @space-h 0;
@@ -1,15 +1,22 @@
1
1
  import { type ReactElement } from 'react';
2
2
  import type { Key } from 'react';
3
3
  import type { ColType, DataGridProps } from "../../components/DataGrid/typings";
4
- declare type Result<ResultType = unknown> = void | string | Error | symbol | ResultType;
5
- export default function useBatchOperate<RecordType extends Record<string, any> = Record<string, any>, ResultType = unknown>(options: {
4
+ declare type Result<ResultType> = Error | symbol | ResultType;
5
+ export default function useBatchOperate<RecordType extends Record<string, any> = Record<string, any>, ResultType = any>(options: {
6
6
  modalTitle: string;
7
- handler: (record: RecordType) => Promise<string | void | ResultType>;
7
+ handler: (record: RecordType) => Promise<ResultType>;
8
8
  columns?: ColType<RecordType>[];
9
9
  rowKey: DataGridProps<RecordType>['rowKey'];
10
- onClose?: (results: Map<Key, Result<ResultType>>) => void;
10
+ /**
11
+ * 关闭时触发
12
+ * @param success 成功的结果
13
+ * @returns
14
+ */
15
+ onClose?: (success: Map<Key, ResultType>, others: {
16
+ results: Map<Key, Result<ResultType>>;
17
+ }) => void;
11
18
  /** 弹窗关闭前的检验,返回true校验通过关闭弹窗,false校验不通过 */
12
- onBeforeClose?: (results: Map<Key, Result>) => Promise<boolean>;
19
+ onBeforeClose?: (results: Map<Key, Result<ResultType>>) => Promise<boolean>;
13
20
  /**
14
21
  * 自定义渲染结果,不要依赖上下文
15
22
  * @param params
@@ -28,7 +35,7 @@ export default function useBatchOperate<RecordType extends Record<string, any> =
28
35
  };
29
36
  reload: () => any;
30
37
  }) => ReactElement | string | number | null;
31
- isError?: () => boolean;
38
+ isError?: (result: ResultType) => boolean;
32
39
  }): {
33
40
  node: JSX.Element;
34
41
  run: (rows: RecordType[]) => void;
@@ -45,7 +45,8 @@ export default function useBatchOperate(options) {
45
45
  onClose = options.onClose,
46
46
  onBeforeClose = options.onBeforeClose,
47
47
  rowKey = options.rowKey,
48
- renderResult = options.renderResult;
48
+ renderResult = options.renderResult,
49
+ isError = options.isError;
49
50
 
50
51
  var _useState = useState(false),
51
52
  _useState2 = _slicedToArray(_useState, 2),
@@ -215,37 +216,56 @@ export default function useBatchOperate(options) {
215
216
 
216
217
  var handleClose = /*#__PURE__*/function () {
217
218
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
218
- var beforeCloseResult;
219
+ var value;
219
220
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
220
221
  while (1) {
221
222
  switch (_context3.prev = _context3.next) {
222
223
  case 0:
223
- if (!onBeforeClose) {
224
- _context3.next = 6;
224
+ _context3.t0 = onBeforeClose;
225
+
226
+ if (!_context3.t0) {
227
+ _context3.next = 5;
225
228
  break;
226
229
  }
227
230
 
228
- _context3.next = 3;
231
+ _context3.next = 4;
229
232
  return onBeforeClose(results);
230
233
 
231
- case 3:
232
- beforeCloseResult = _context3.sent;
234
+ case 4:
235
+ _context3.t0 = !_context3.sent;
233
236
 
234
- if (beforeCloseResult) {
235
- _context3.next = 6;
237
+ case 5:
238
+ if (!_context3.t0) {
239
+ _context3.next = 7;
236
240
  break;
237
241
  }
238
242
 
239
243
  return _context3.abrupt("return");
240
244
 
241
- case 6:
245
+ case 7:
242
246
  setVisible(false);
243
247
 
244
248
  if (onClose) {
245
- onClose(results);
249
+ value = _toConsumableArray(results).filter(function (_ref4) {
250
+ var _ref5 = _slicedToArray(_ref4, 2),
251
+ val = _ref5[1];
252
+
253
+ if (val instanceof Error || val === loading) {
254
+ return false;
255
+ }
256
+
257
+ if (isError !== undefined) {
258
+ return !isError(val);
259
+ }
260
+
261
+ return true;
262
+ });
263
+ onClose(new Map(value), {
264
+ results: results
265
+ });
246
266
  }
247
267
 
248
- case 8:
268
+ case 9:
249
269
  case "end":
250
270
  return _context3.stop();
251
271
  }
@@ -263,8 +283,8 @@ export default function useBatchOperate(options) {
263
283
  title: '编号',
264
284
  colId: 'id',
265
285
  dataIndex: typeof rowKey === 'string' ? rowKey : undefined,
266
- render: function render(_1, _2, _3, _ref4) {
267
- var node = _ref4.node;
286
+ render: function render(_1, _2, _3, _ref6) {
287
+ var node = _ref6.node;
268
288
  return node.id || '';
269
289
  }
270
290
  }];
@@ -272,9 +292,9 @@ export default function useBatchOperate(options) {
272
292
  title: '',
273
293
  colId: '__delete__',
274
294
  width: 32,
275
- render: function render(_1, _2, index, _ref5) {
276
- var context = _ref5.context,
277
- node = _ref5.node;
295
+ render: function render(_1, _2, index, _ref7) {
296
+ var context = _ref7.context,
297
+ node = _ref7.node;
278
298
  var key = node.id;
279
299
  return /*#__PURE__*/React.createElement(Icons.Delete, {
280
300
  onClick: function onClick() {
@@ -313,9 +333,9 @@ export default function useBatchOperate(options) {
313
333
  dataIndex: 'status',
314
334
  flex: 1,
315
335
  resizable: false,
316
- render: function render(_, record, index, _ref6) {
317
- var context = _ref6.context,
318
- node = _ref6.node;
336
+ render: function render(_, record, index, _ref8) {
337
+ var context = _ref8.context,
338
+ node = _ref8.node;
319
339
  var key = node.id;
320
340
  var result = context.results.get(key);
321
341
 
@@ -377,7 +397,7 @@ export default function useBatchOperate(options) {
377
397
  var node = /*#__PURE__*/React.createElement(Modal, {
378
398
  title: modalTitle,
379
399
  open: visible,
380
- width: 896,
400
+ width: 1000,
381
401
  centered: true,
382
402
  onCancel: handleClose,
383
403
  footer: null,
package/es/init.js CHANGED
@@ -6,15 +6,14 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
6
6
 
7
7
  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); }
8
8
 
9
- import React from 'react';
10
- import { message, Modal, Select, ConfigProvider, Result, Button, DatePicker, Cascader, TreeSelect, Empty, Menu } from 'antd';
11
9
  import { config } from '@lemon-fe/hooks';
12
- import PageLoading from "./components/PageLoading";
10
+ import { message, Modal, Select, ConfigProvider, Result, Button, DatePicker, Cascader, TreeSelect, Empty, Menu } from 'antd';
11
+ import React from 'react';
13
12
  import Icons from "./components/Icons";
13
+ import PageLoading from "./components/PageLoading";
14
14
  import empty from "./styles/empty.png";
15
15
  var Tip = Icons.Tip,
16
16
  Down = Icons.Down,
17
- BigTip = Icons.BigTip,
18
17
  Close = Icons.Close,
19
18
  Clear = Icons.Clear;
20
19
  export default function init() {
@@ -71,10 +70,11 @@ export default function init() {
71
70
 
72
71
  Modal[item] = function () {
73
72
  return modalAPI(_objectSpread({
74
- icon: /*#__PURE__*/React.createElement(BigTip, {
73
+ title: '提示',
74
+ width: 400,
75
+ icon: /*#__PURE__*/React.createElement(Tip, {
75
76
  type: item
76
- }),
77
- title: '提示'
77
+ })
78
78
  }, arguments.length <= 0 ? undefined : arguments[0]));
79
79
  };
80
80
  });
@@ -82,9 +82,10 @@ export default function init() {
82
82
 
83
83
  Modal.confirm = function () {
84
84
  return modalConfirm(_objectSpread({
85
- icon: /*#__PURE__*/React.createElement(BigTip, {
85
+ icon: /*#__PURE__*/React.createElement(Tip, {
86
86
  type: "info"
87
87
  }),
88
+ width: 400,
88
89
  title: '提示'
89
90
  }, arguments.length <= 0 ? undefined : arguments[0]));
90
91
  };
@@ -66,57 +66,25 @@ a[title='站长统计'] {
66
66
 
67
67
  /** modal */
68
68
 
69
- .@{ant-prefix}-modal-content {
70
- border-radius: 8px;
71
- }
69
+ @modal-header-padding-horizontal: @padding-md;
70
+ @modal-body-padding: @padding-md;
71
+ @modal-footer-padding-horizontal: @padding-md;
72
+ @modal-confirm-body-padding: 20px;
73
+ @modal-border-radius: 8px;
72
74
 
73
- .@{ant-prefix}-modal-header {
74
- border-radius: 8px 8px 0 0;
75
+ .@{ant-prefix}-modal-confirm-body > .anticon {
76
+ margin-right: 8px;
75
77
  }
76
78
 
77
- .@{ant-prefix}-modal-confirm {
78
- .@{ant-prefix}-modal-body {
79
- padding: 0;
80
- }
81
-
82
- .@{ant-prefix}-modal-confirm-body {
83
- padding: 40px 48px;
84
- overflow: hidden;
85
-
86
- & > img:first-child {
87
- position: absolute;
88
- top: 40px;
89
- left: 48px;
90
- }
91
- }
92
-
93
- .@{ant-prefix}-modal-confirm-btns {
94
- float: none;
95
- margin-top: 0;
96
- padding: 10px 16px;
97
- text-align: right;
98
- background: transparent;
99
- border-top: 1px solid rgba(0, 0, 0, 0.06);
100
- border-radius: 0 0 2px 2px;
101
-
102
- & > .@{ant-prefix}-btn {
103
- min-width: 72px;
104
- }
105
- }
106
-
107
- .@{ant-prefix}-modal-confirm-title {
108
- float: none;
109
- margin-left: 56px;
110
- font-weight: 600;
111
- line-height: 24px;
112
- }
79
+ .@{ant-prefix}-modal-confirm-body
80
+ > .anticon
81
+ + .@{ant-prefix}-modal-confirm-title
82
+ + .@{ant-prefix}-modal-confirm-content {
83
+ margin-left: 30px;
84
+ }
113
85
 
114
- .@{ant-prefix}-modal-confirm-content {
115
- float: none;
116
- margin: 2px 0 0 56px;
117
- color: rgba(51, 51, 51, 0.5);
118
- line-height: 22px;
119
- }
86
+ .@{ant-prefix}-modal-confirm-body .@{ant-prefix}-modal-confirm-content {
87
+ color: fade(#333, 70);
120
88
  }
121
89
 
122
90
  /** pagination */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lemon-fe/kits",
3
- "version": "1.0.0-125",
3
+ "version": "1.0.0-127",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",
@@ -19,6 +19,7 @@
19
19
  "publishConfig": {
20
20
  "registry": "https://registry.npmjs.org"
21
21
  },
22
+ "sideEffects": false,
22
23
  "module": "es/index.js",
23
24
  "typings": "es/index.d.ts",
24
25
  "main": "es/index.js",