@lemon-fe/components 0.1.46 → 0.1.52

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,5 +1,5 @@
1
1
  var _excluded = ["onWidthChange", "width", "fullTableRef", "children", "className"],
2
- _excluded2 = ["id", "columns", "defaultColumnProps", "rowKey", "children", "summaryTitle", "summaryRecord", "dataSource", "onSortChange", "sort", "scroll", "virtual", "components", "pagination", "rowHeight", "tableLayout", "rowActions", "style"];
2
+ _excluded2 = ["id", "columns", "defaultColumnProps", "rowKey", "children", "summaryTitle", "summaryRecord", "dataSource", "onSortChange", "sort", "scroll", "virtual", "components", "pagination", "rowHeight", "tableLayout", "rowActions", "style", "locale"];
3
3
 
4
4
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
5
5
 
@@ -34,7 +34,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
34
34
  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; }
35
35
 
36
36
  /// <reference path="../../typings.d.ts" />
37
- import React, { useMemo, useState, useEffect, useRef, useLayoutEffect } from 'react';
37
+ import React, { useMemo, useState, useEffect, useRef } from 'react';
38
38
  import { Table as AntdTable } from 'antd';
39
39
  import { get } from 'lodash';
40
40
  import ResizeObserver from 'rc-resize-observer';
@@ -121,6 +121,7 @@ function BaseTable(props) {
121
121
  tableLayout = _props$tableLayout === void 0 ? 'fixed' : _props$tableLayout,
122
122
  rowActions = props.rowActions,
123
123
  style = props.style,
124
+ localeProp = props.locale,
124
125
  restProps = _objectWithoutProperties(props, _excluded2);
125
126
 
126
127
  var fullTableRef = useRef(null);
@@ -204,8 +205,8 @@ function BaseTable(props) {
204
205
  hasPagination = paginationProp !== undefined && !!paginationProp.total || dataSource.length > 0;
205
206
  }
206
207
 
207
- useLayoutEffect(function () {
208
- setScrollY(calcScrollY() || undefined);
208
+ useEffect(function () {
209
+ setScrollY(calcScrollY() || 0);
209
210
  }, [hasPagination]);
210
211
  useEffect(function () {
211
212
  if (scrollYProp !== true) {
@@ -416,13 +417,13 @@ function BaseTable(props) {
416
417
  style: scrollYProp === true ? _objectSpread(_objectSpread({}, style), {}, {
417
418
  height: '100%'
418
419
  }) : style,
419
- locale: {
420
+ locale: _objectSpread({
420
421
  emptyText: /*#__PURE__*/React.createElement("div", {
421
422
  className: "".concat(PREFIX_CLS, "-table-empty")
422
423
  }, /*#__PURE__*/React.createElement("img", {
423
424
  src: empty
424
425
  }), /*#__PURE__*/React.createElement("div", null, "\u6682\u65E0\u6570\u636E"))
425
- }
426
+ }, localeProp)
426
427
  }, restProps), {}, {
427
428
  pagination: paginationProp !== false ? _objectSpread({
428
429
  size: 'small',
@@ -439,7 +440,7 @@ function BaseTable(props) {
439
440
  if (scrollYProp === true) {
440
441
  tableNode = /*#__PURE__*/React.createElement(ResizeObserver, {
441
442
  onResize: function onResize(size) {
442
- return changeScrollY(size.height);
443
+ changeScrollY(size.height);
443
444
  }
444
445
  }, tableNode);
445
446
  }
@@ -172,9 +172,9 @@
172
172
  text-align: center;
173
173
 
174
174
  & > img {
175
- display: block;
176
175
  width: 120px;
177
176
  height: 120px;
177
+ vertical-align: top;
178
178
  }
179
179
  }
180
180
  }
@@ -172,39 +172,18 @@ function Filter(props) {
172
172
  width = _useState12[0],
173
173
  setWidth = _useState12[1];
174
174
 
175
- var _useState13 = useState(false),
175
+ var _useState13 = useState(true),
176
176
  _useState14 = _slicedToArray(_useState13, 2),
177
177
  collapsed = _useState14[0],
178
178
  setCollapsed = _useState14[1];
179
179
 
180
- var _useRequest = useRequest( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
181
- var tabsData;
182
- return regeneratorRuntime.wrap(function _callee$(_context) {
183
- while (1) {
184
- switch (_context.prev = _context.next) {
185
- case 0:
186
- if (storageKey) {
187
- _context.next = 2;
188
- break;
189
- }
190
-
191
- return _context.abrupt("return", null);
192
-
193
- case 2:
194
- _context.next = 4;
195
- return getStorageData(storageKey);
196
-
197
- case 4:
198
- tabsData = _context.sent;
199
- return _context.abrupt("return", tabsData);
180
+ var _useRequest = useRequest(function () {
181
+ if (!storageKey) {
182
+ return null;
183
+ }
200
184
 
201
- case 6:
202
- case "end":
203
- return _context.stop();
204
- }
205
- }
206
- }, _callee);
207
- })), {
185
+ return getStorageData(storageKey);
186
+ }, {
208
187
  loadingState: false,
209
188
  onSuccess: function onSuccess(res) {
210
189
  if (res !== null) {
@@ -236,8 +215,8 @@ function Filter(props) {
236
215
  onValuesChange === null || onValuesChange === void 0 ? void 0 : onValuesChange(changedValues, allValues, form);
237
216
  };
238
217
 
239
- var handleSave = function handleSave(_ref2) {
240
- var title = _ref2.name;
218
+ var handleSave = function handleSave(_ref) {
219
+ var title = _ref.name;
241
220
  var index = tabs.findIndex(function (item) {
242
221
  return item.title === title;
243
222
  });
@@ -266,36 +245,36 @@ function Filter(props) {
266
245
  };
267
246
 
268
247
  var handleOk = /*#__PURE__*/function () {
269
- var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
248
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
270
249
  var values;
271
- return regeneratorRuntime.wrap(function _callee2$(_context2) {
250
+ return regeneratorRuntime.wrap(function _callee$(_context) {
272
251
  while (1) {
273
- switch (_context2.prev = _context2.next) {
252
+ switch (_context.prev = _context.next) {
274
253
  case 0:
275
- _context2.prev = 0;
276
- _context2.next = 3;
254
+ _context.prev = 0;
255
+ _context.next = 3;
277
256
  return modalForm.validateFields();
278
257
 
279
258
  case 3:
280
- values = _context2.sent;
259
+ values = _context.sent;
281
260
  handleSave(values);
282
- _context2.next = 9;
261
+ _context.next = 9;
283
262
  break;
284
263
 
285
264
  case 7:
286
- _context2.prev = 7;
287
- _context2.t0 = _context2["catch"](0);
265
+ _context.prev = 7;
266
+ _context.t0 = _context["catch"](0);
288
267
 
289
268
  case 9:
290
269
  case "end":
291
- return _context2.stop();
270
+ return _context.stop();
292
271
  }
293
272
  }
294
- }, _callee2, null, [[0, 7]]);
273
+ }, _callee, null, [[0, 7]]);
295
274
  }));
296
275
 
297
276
  return function handleOk() {
298
- return _ref3.apply(this, arguments);
277
+ return _ref2.apply(this, arguments);
299
278
  };
300
279
  }();
301
280
 
@@ -574,18 +553,48 @@ function Filter(props) {
574
553
  style: {
575
554
  visibility: showCollapse ? 'visible' : 'hidden'
576
555
  },
577
- className: "".concat(prefixCls, "-btn"),
578
556
  onClick: function onClick() {
579
557
  return setCollapsed(function (prev) {
580
558
  return !prev;
581
559
  });
582
560
  },
583
- icon: /*#__PURE__*/React.createElement(Icons.CollapseUp, {
584
- style: {
585
- transform: collapsed ? 'rotateX(180deg)' : undefined
586
- }
587
- })
588
- })))))));
561
+ type: "link",
562
+ className: "".concat(prefixCls, "-collapse")
563
+ }, collapsed ? '高级搜索' : '收起搜索', /*#__PURE__*/React.createElement("svg", {
564
+ width: "10",
565
+ height: "10",
566
+ viewBox: "0 0 10 10",
567
+ xmlns: "http://www.w3.org/2000/svg",
568
+ xmlnsXlink: "http://www.w3.org/1999/xlink",
569
+ style: collapsed ? {
570
+ transform: 'rotate(180deg)'
571
+ } : undefined
572
+ }, /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("path", {
573
+ id: "a",
574
+ d: "M0 0h10v10H0z"
575
+ })), /*#__PURE__*/React.createElement("g", {
576
+ transform: "matrix(1 0 0 -1 0 10)",
577
+ fill: "none",
578
+ fillRule: "evenodd"
579
+ }, /*#__PURE__*/React.createElement("mask", {
580
+ id: "b",
581
+ fill: "#fff"
582
+ }, /*#__PURE__*/React.createElement("use", {
583
+ xlinkHref: "#a",
584
+ transform: "rotate(-90 5 5)"
585
+ })), /*#__PURE__*/React.createElement("use", {
586
+ fillOpacity: "0",
587
+ fill: "#C4C4C4",
588
+ transform: "rotate(-90 5 5)",
589
+ xlinkHref: "#a"
590
+ }), /*#__PURE__*/React.createElement("path", {
591
+ d: "M2.172 1.757 5 4.586l2.828-2.829M2.172 5.757 5 8.586l2.828-2.829",
592
+ stroke: "currentColor",
593
+ strokeLinecap: "round",
594
+ strokeLinejoin: "round",
595
+ strokeDasharray: "0,0",
596
+ mask: "url(#b)"
597
+ }))))))))));
589
598
  }
590
599
 
591
600
  Filter.setComponents = setComponents;
@@ -1,6 +1,10 @@
1
1
  .@{prefixCls}-filter {
2
2
  &-tab-bar {
3
- margin-bottom: 16px;
3
+ margin-bottom: 12px;
4
+
5
+ .@{prefixCls}-tab-bar-item {
6
+ padding: 8px 12px;
7
+ }
4
8
  }
5
9
 
6
10
  &-btn {
@@ -13,9 +17,19 @@
13
17
  }
14
18
  }
15
19
 
20
+ &-collapse {
21
+ padding: 4px 0;
22
+ font-size: 12px;
23
+ line-height: 1;
24
+
25
+ & > svg {
26
+ vertical-align: -1px;
27
+ }
28
+ }
29
+
16
30
  &-btns {
17
31
  display: flex;
18
- margin-bottom: 16px;
32
+ margin-bottom: 8px;
19
33
  padding: 0 8px;
20
34
  }
21
35
 
@@ -52,5 +66,5 @@
52
66
  }
53
67
 
54
68
  .@{prefixCls}-section-body > .@{prefixCls}-filter:not(.@{prefixCls}-filter-simple):first-child {
55
- margin-top: -16px;
69
+ margin-top: -12px;
56
70
  }
@@ -1,8 +1,9 @@
1
1
  @import '../theme.less';
2
2
 
3
3
  @spaceX: 16px;
4
- @spaceY: 16px;
5
- @minWidth: 300px;
4
+ @spaceY: 8px;
5
+ @minWidth: 350px;
6
+ @maxWidth: 94px + 422px;
6
7
 
7
8
  .wrapper() {
8
9
  margin-right: (-@spaceX / 2);
@@ -20,14 +21,15 @@
20
21
  flex-wrap: nowrap;
21
22
  width: percentage((@colSpan / 24));
22
23
  min-width: if((@colSpan >= 12), 2 * @minWidth, @minWidth);
24
+ max-width: if((@colSpan >= 12), 2 * @maxWidth, @maxWidth);
23
25
  padding: 0 (@spaceX / 2);
24
26
  }
25
27
 
26
28
  .@{prefixCls}-form {
27
29
  &-layout {
28
30
  .ant-form-item {
29
- margin-bottom: @spaceY;
30
31
  flex-wrap: nowrap;
32
+ margin-bottom: @spaceY;
31
33
 
32
34
  &-label {
33
35
  flex: 0 0 94px;
@@ -88,5 +90,6 @@
88
90
  &-layout-flex > div > .ant-form-item,
89
91
  &-layout-flex &-col {
90
92
  width: 100%;
93
+ max-width: 100%;
91
94
  }
92
95
  }
@@ -7,7 +7,7 @@
7
7
  background: #f2f2f2;
8
8
 
9
9
  &-header {
10
- padding: @space 0;
10
+ padding: 8px 0;
11
11
  background-color: #f2f2f2;
12
12
  }
13
13
 
@@ -16,7 +16,7 @@
16
16
  min-height: 0;
17
17
 
18
18
  &:first-child {
19
- margin-top: @space;
19
+ margin-top: 8px;
20
20
  }
21
21
  }
22
22
 
@@ -3,7 +3,7 @@
3
3
  .@{prefixCls}-section {
4
4
  position: relative;
5
5
  width: 100%;
6
- padding: @space;
6
+ padding: 12px 16px;
7
7
  color: #333;
8
8
 
9
9
  & + & {
@@ -24,8 +24,7 @@
24
24
  &-header {
25
25
  display: flex;
26
26
  align-items: flex-end;
27
- margin-bottom: @space;
28
- padding: 8px 0;
27
+ margin-bottom: 12px;
29
28
  }
30
29
 
31
30
  &-title {
@@ -1,5 +1,5 @@
1
1
  @indentWidth: 18px;
2
- @treeNodeHeight: 40px;
2
+ @treeNodeHeight: 36px;
3
3
 
4
4
  .@{prefixCls}-tree {
5
5
  &-wrapper {
package/es/Table/index.js CHANGED
@@ -30,6 +30,8 @@ import React, { useMemo, useState, useImperativeHandle, useEffect } from 'react'
30
30
  import { useRequest } from '@lemon-fe/hooks';
31
31
  import BaseTable from '../BaseTable';
32
32
  import { isSortValue } from './utils';
33
+ import empty from '../BaseTable/empty.png';
34
+ import { PREFIX_CLS } from '../constants';
33
35
  export default function Table(props) {
34
36
  var _props$dataSource = props.dataSource,
35
37
  dataSource = _props$dataSource === void 0 ? [] : _props$dataSource,
@@ -115,16 +117,19 @@ export default function Table(props) {
115
117
  onLoading(false);
116
118
  }
117
119
 
118
- setRemote(res.result);
120
+ setRemote(_objectSpread(_objectSpread({}, res.result), {}, {
121
+ error: undefined
122
+ }));
119
123
  },
120
- onError: function onError() {
124
+ onError: function onError(error) {
121
125
  if (onLoading) {
122
126
  onLoading(false);
123
127
  }
124
128
 
125
129
  setRemote({
126
130
  data: [],
127
- total: 0
131
+ total: 0,
132
+ error: error
128
133
  });
129
134
  }
130
135
  }),
@@ -215,6 +220,13 @@ export default function Table(props) {
215
220
  });
216
221
  }
217
222
  },
223
+ locale: remote.error ? {
224
+ emptyText: /*#__PURE__*/React.createElement("div", {
225
+ className: "".concat(PREFIX_CLS, "-table-empty")
226
+ }, /*#__PURE__*/React.createElement("img", {
227
+ src: empty
228
+ }), /*#__PURE__*/React.createElement("div", null, remote.error.message))
229
+ } : undefined,
218
230
  pagination: {
219
231
  current: current,
220
232
  pageSize: pageSize,
package/es/utils.less CHANGED
@@ -62,8 +62,10 @@
62
62
  height: 100%;
63
63
 
64
64
  & > .ant-tabs-nav {
65
+ margin-bottom: 12px;
66
+
65
67
  .ant-tabs-tab {
66
- padding: 12px 12px 14px;
68
+ padding: 8px 12px;
67
69
 
68
70
  &.ant-tabs-tab-active .ant-tabs-tab-btn {
69
71
  text-shadow: unset;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lemon-fe/components",
3
- "version": "0.1.46",
3
+ "version": "0.1.52",
4
4
  "description": "> TODO: description",
5
5
  "author": "鲁盛杰 <lusj@cnlemon.net>",
6
6
  "homepage": "",
@@ -41,5 +41,5 @@
41
41
  "react": "^17.0.2",
42
42
  "react-dom": "^17.0.2"
43
43
  },
44
- "gitHead": "e040d5b608a4786e7c3fd7e335f15cc57f4152cf"
44
+ "gitHead": "68713e81d8cf4c82bae68564ae4c2e70c4a8cc27"
45
45
  }