@aloudata/aloudata-design 0.4.8-beta.14 → 0.4.8-beta.16

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.
Files changed (73) hide show
  1. package/dist/Avatar/component/Avatar/index.js +16 -5
  2. package/dist/Breadcrumb/index.js +16 -6
  3. package/dist/Button/index.js +32 -15
  4. package/dist/Button/style/variables.less +3 -3
  5. package/dist/Checkbox/component/CheckboxGroup/index.js +10 -4
  6. package/dist/Checkbox/index.js +8 -1
  7. package/dist/Checkbox/type.js +1 -0
  8. package/dist/ConfigProvider/defaultRenderEmpty.js +5 -0
  9. package/dist/ConfigProvider/sizeContext.js +1 -1
  10. package/dist/Divider/index.js +3 -0
  11. package/dist/DoubleCircleIcon/index.js +9 -7
  12. package/dist/Dropdown/Button.js +11 -7
  13. package/dist/Dropdown/index.js +9 -3
  14. package/dist/Dropdown/style/index.less +4 -0
  15. package/dist/Empty/image/Data.js +2 -0
  16. package/dist/Empty/image/Search.js +2 -0
  17. package/dist/Empty/image/SearchSmall.js +2 -0
  18. package/dist/Empty/image/User.js +2 -0
  19. package/dist/Empty/image/WorkBook.js +2 -0
  20. package/dist/Empty/index.js +23 -13
  21. package/dist/Icon/components/Icon.js +13 -9
  22. package/dist/Icon/components/createFromScripts.js +8 -2
  23. package/dist/Input/components/Group/index.js +9 -4
  24. package/dist/Input/components/Input/index.js +9 -3
  25. package/dist/Input/components/Password/index.js +10 -5
  26. package/dist/Input/components/TextArea/index.js +11 -6
  27. package/dist/Input/style/index.less +1 -1
  28. package/dist/InputNumber/index.js +12 -7
  29. package/dist/Menu/SubMenu.js +6 -1
  30. package/dist/Menu/index.js +7 -2
  31. package/dist/Menu/style/index.less +5 -0
  32. package/dist/Modal/index.js +129 -107
  33. package/dist/Modal/locale.js +6 -4
  34. package/dist/Modal/style/index.less +2 -1
  35. package/dist/Navigator/components/Header/index.js +2 -0
  36. package/dist/Navigator/components/Menu/index.js +19 -8
  37. package/dist/Navigator/components/MenuItem/index.js +9 -6
  38. package/dist/Navigator/index.js +7 -5
  39. package/dist/Popconfirm/index.js +27 -19
  40. package/dist/Popover/index.js +9 -2
  41. package/dist/Radio/components/Group/index.js +34 -26
  42. package/dist/Radio/components/Radio/index.js +18 -10
  43. package/dist/Select/components/MultipleOption.js +6 -4
  44. package/dist/Select/components/SingleOption.js +7 -5
  45. package/dist/Select/index.js +94 -44
  46. package/dist/Select/style/index.less +1 -0
  47. package/dist/Spin/CustomIcon/index.js +2 -0
  48. package/dist/Spin/index.js +10 -1
  49. package/dist/Steps/components/ProcessIcon/index.js +2 -0
  50. package/dist/Steps/components/Step/index.js +8 -2
  51. package/dist/Steps/index.js +10 -8
  52. package/dist/Switch/index.js +30 -18
  53. package/dist/Table/Table.js +129 -86
  54. package/dist/Table/components/Empty/index.js +2 -0
  55. package/dist/Table/components/Loading/index.js +2 -0
  56. package/dist/Table/components/TableBodyRowList/index.js +39 -19
  57. package/dist/Table/components/TableHead/index.js +86 -55
  58. package/dist/Table/hooks/useFrame.js +24 -9
  59. package/dist/Table/style/index.less +1 -1
  60. package/dist/Table/utils.js +27 -8
  61. package/dist/Tabs/index.js +32 -17
  62. package/dist/Tooltip/index.js +12 -12
  63. package/dist/Tooltip/style/index.less +7 -1
  64. package/dist/Tree/index.js +4 -2
  65. package/dist/_utils/hooks/useControlledState.js +21 -9
  66. package/dist/_utils/hooks/useId.js +5 -4
  67. package/dist/_utils/hooks/usePrefixCls.js +5 -2
  68. package/dist/index.js +1 -2
  69. package/dist/locale-provider/index.js +33 -8
  70. package/dist/message/index.js +7 -3
  71. package/dist/notification/demo/index.js +1 -0
  72. package/dist/notification/index.js +48 -39
  73. package/package.json +2 -2
@@ -1,52 +1,69 @@
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
1
  var _excluded = ["style"];
2
+
3
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
+
4
5
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
6
+
5
7
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
- 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; }
7
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
8
- 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); }
8
+
9
+ 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; }
10
+
9
11
  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; }
12
+
10
13
  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; }
14
+
11
15
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
16
+
12
17
  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."); }
18
+
13
19
  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); }
14
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
15
- function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
20
+
21
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
22
+
23
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
24
+
16
25
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
26
+
17
27
  import classnames from 'classnames';
18
28
  import React, { useCallback, useState } from 'react';
19
29
  import usePrefixCls from "../../../_utils/hooks/usePrefixCls";
20
30
  import { getValidWidthByNumber } from "../../utils";
31
+
21
32
  function TableBodyRowList(props) {
22
33
  var _props$ellipsis = props.ellipsis,
23
- ellipsis = _props$ellipsis === void 0 ? true : _props$ellipsis,
24
- data = props.data,
25
- rows = props.rows,
26
- prepareRow = props.prepareRow,
27
- columnsTotalWidthRef = props.columnsTotalWidthRef,
28
- _props$rowClassName = props.rowClassName,
29
- rowClassName = _props$rowClassName === void 0 ? '' : _props$rowClassName,
30
- onRowSelected = props.onRowSelected;
34
+ ellipsis = _props$ellipsis === void 0 ? true : _props$ellipsis,
35
+ data = props.data,
36
+ rows = props.rows,
37
+ prepareRow = props.prepareRow,
38
+ columnsTotalWidthRef = props.columnsTotalWidthRef,
39
+ _props$rowClassName = props.rowClassName,
40
+ rowClassName = _props$rowClassName === void 0 ? '' : _props$rowClassName,
41
+ onRowSelected = props.onRowSelected;
42
+
31
43
  var _useState = useState(null),
32
- _useState2 = _slicedToArray(_useState, 2),
33
- selectedRowId = _useState2[0],
34
- setSelectedRowId = _useState2[1];
44
+ _useState2 = _slicedToArray(_useState, 2),
45
+ selectedRowId = _useState2[0],
46
+ setSelectedRowId = _useState2[1];
47
+
35
48
  var prefixCls = usePrefixCls('', 'ald-table');
36
49
  var onRowClick = useCallback(function (row) {
37
50
  if (!onRowSelected) {
38
51
  return;
39
52
  }
53
+
40
54
  setSelectedRowId(row.id);
41
55
  onRowSelected(row.original);
42
56
  }, [onRowSelected, setSelectedRowId]);
43
57
  return /*#__PURE__*/React.createElement(React.Fragment, null, data.map(function (item, index) {
44
58
  var _classnames;
59
+
45
60
  var row = rows[index];
46
61
  prepareRow(row);
62
+
47
63
  var _row$getRowProps = row.getRowProps(),
48
- rowStyle = _row$getRowProps.style,
49
- rowProps = _objectWithoutProperties(_row$getRowProps, _excluded);
64
+ rowStyle = _row$getRowProps.style,
65
+ rowProps = _objectWithoutProperties(_row$getRowProps, _excluded);
66
+
50
67
  return /*#__PURE__*/React.createElement("div", _extends({}, rowProps, {
51
68
  style: _objectSpread(_objectSpread({}, rowStyle), {}, {
52
69
  width: columnsTotalWidthRef.current
@@ -58,7 +75,9 @@ function TableBodyRowList(props) {
58
75
  key: row.id
59
76
  }), row.cells.map(function (cell, index) {
60
77
  var _cell$getCellProps$st, _cell$getCellProps$st2;
78
+
61
79
  var currentRenderWidth = Number((_cell$getCellProps$st = cell.getCellProps().style) === null || _cell$getCellProps$st === void 0 ? void 0 : (_cell$getCellProps$st2 = _cell$getCellProps$st.width) === null || _cell$getCellProps$st2 === void 0 ? void 0 : _cell$getCellProps$st2.toString().replace('px', '')); // 表格内置计算的宽度 'px'
80
+
62
81
  return /*#__PURE__*/React.createElement("div", _extends({
63
82
  key: index
64
83
  }, cell.getCellProps(), {
@@ -72,4 +91,5 @@ function TableBodyRowList(props) {
72
91
  }));
73
92
  }));
74
93
  }
94
+
75
95
  export default TableBodyRowList;
@@ -1,19 +1,29 @@
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
1
  var _excluded = ["style"];
2
+
3
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
+
4
5
  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; }
6
+
5
7
  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; }
8
+
6
9
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
10
+
7
11
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
8
- 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; }
9
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
10
- 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); }
12
+
13
+ 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; }
14
+
11
15
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
16
+
12
17
  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."); }
18
+
13
19
  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); }
14
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
15
- function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
20
+
21
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
22
+
23
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
24
+
16
25
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
26
+
17
27
  import React, { useState } from 'react';
18
28
  import usePrefixCls from "../../../_utils/hooks/usePrefixCls";
19
29
  import classnames from 'classnames';
@@ -22,50 +32,52 @@ import _ from 'lodash';
22
32
  import { getValidWidthByNumber } from "../../utils";
23
33
  import message from "../../../message";
24
34
  var ARRAY_FIRST_INDEX = 0;
35
+
25
36
  function TableHead(props) {
26
37
  var headerGroups = props.headerGroups,
27
- canResizeColumn = props.canResizeColumn,
28
- defaultSort = props.defaultSort,
29
- _props$sortable = props.sortable,
30
- sortable = _props$sortable === void 0 ? false : _props$sortable,
31
- _props$columns = props.columns,
32
- columns = _props$columns === void 0 ? [{
33
- accessor: '',
34
- sortOrder: 'descend'
35
- }] : _props$columns,
36
- allSortDirections = props.sortDirections,
37
- setSortBy = props.setSortBy,
38
- _props$onChange = props.onChange,
39
- onChange = _props$onChange === void 0 ? function () {} : _props$onChange,
40
- columnsWidthMapRef = props.columnsWidthMapRef,
41
- columnsTotalWidthRef = props.columnsTotalWidthRef;
42
- var prefixCls = usePrefixCls('', 'ald-table');
43
-
44
- // 第一列的情况 默认或者恢复是需要用到
38
+ canResizeColumn = props.canResizeColumn,
39
+ defaultSort = props.defaultSort,
40
+ _props$sortable = props.sortable,
41
+ sortable = _props$sortable === void 0 ? false : _props$sortable,
42
+ _props$columns = props.columns,
43
+ columns = _props$columns === void 0 ? [{
44
+ accessor: '',
45
+ sortOrder: 'descend'
46
+ }] : _props$columns,
47
+ allSortDirections = props.sortDirections,
48
+ setSortBy = props.setSortBy,
49
+ _props$onChange = props.onChange,
50
+ onChange = _props$onChange === void 0 ? function () {} : _props$onChange,
51
+ columnsWidthMapRef = props.columnsWidthMapRef,
52
+ columnsTotalWidthRef = props.columnsTotalWidthRef;
53
+ var prefixCls = usePrefixCls('', 'ald-table'); // 第一列的情况 默认或者恢复是需要用到
54
+
45
55
  var defaultSortObject = {
46
56
  id: columns[ARRAY_FIRST_INDEX].accessor,
47
57
  desc: !!(columns[ARRAY_FIRST_INDEX].sortOrder && columns[ARRAY_FIRST_INDEX].sortOrder === 'descend')
48
- };
49
-
50
- // 如果支持排序
58
+ }; // 如果支持排序
51
59
  // 1. 有默认排序 则按照默认排序
52
60
  // 2. 如果没有默认排序,再判断第一列是否符合排序条件,若满足 => 则按第一列排序
61
+
53
62
  var getInitialSortDirection = function getInitialSortDirection() {
54
63
  if (defaultSort && defaultSort.id) {
55
64
  return defaultSort;
56
65
  }
66
+
57
67
  if (!defaultSortObject.id) {
58
68
  message.error('开启了排序,但是没有给予默认排序列,并且第一列不支持排序');
59
69
  }
70
+
60
71
  return defaultSortObject;
61
72
  };
62
- var _useState = useState(getInitialSortDirection()),
63
- _useState2 = _slicedToArray(_useState, 2),
64
- sortDirection = _useState2[0],
65
- setSortDirection = _useState2[1];
66
73
 
67
- // 排序的方向 倒叙{ id: 'xx', desc: true }、正序{ id: 'xx', desc: false }、无序 { id: '', desc: undefined }
74
+ var _useState = useState(getInitialSortDirection()),
75
+ _useState2 = _slicedToArray(_useState, 2),
76
+ sortDirection = _useState2[0],
77
+ setSortDirection = _useState2[1]; // 排序的方向 倒叙{ id: 'xx', desc: true }、正序{ id: 'xx', desc: false }、无序 { id: '', desc: undefined }
68
78
  // 获取排序方向以及排序的id
79
+
80
+
69
81
  var getSortBy = function getSortBy(id) {
70
82
  var sortDirections = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ['ascend', 'descend'];
71
83
  var sortOrder // 如果传了列的默认排序方式,则不可以更改
@@ -73,68 +85,74 @@ function TableHead(props) {
73
85
  var res = {
74
86
  id: id,
75
87
  desc: undefined // 给个默认的排序
76
- };
77
88
 
89
+ };
78
90
  var isSameCol = sortDirection.id === id;
79
91
  var descMap = new Map([['ascend', false], ['descend', true]]);
80
- var directions = allSortDirections || sortDirections;
92
+ var directions = allSortDirections || sortDirections; // 如果不是同一列 则返回默认排序 或者排序顺序的第一个
81
93
 
82
- // 如果不是同一列 则返回默认排序 或者排序顺序的第一个
83
94
  if (!isSameCol) {
84
95
  if (sortOrder === 'ascend' || sortOrder === 'descend') {
85
96
  res.desc = descMap.get(sortOrder);
86
97
  } else {
87
98
  res.desc = sortOrder || descMap.get(directions[ARRAY_FIRST_INDEX]);
88
99
  }
89
- return res;
90
- }
91
100
 
92
- // 如果是同一列
101
+ return res;
102
+ } // 如果是同一列
93
103
  // 如果列给了默认的sortOrder则不在变化
104
+
105
+
94
106
  if (sortOrder === 'ascend' || sortOrder === 'descend') {
95
107
  res.desc = descMap.get(sortOrder);
96
108
  return res;
97
- }
109
+ } // 在所有方向上 往后取一个
110
+
98
111
 
99
- // 在所有方向上 往后取一个
100
112
  var lastSortDirection = sortDirection.desc ? 'descend' : 'ascend';
113
+
101
114
  var index = _.findIndex(directions, function (item) {
102
115
  return item === lastSortDirection;
103
116
  });
117
+
104
118
  var nextIndex = index + 1;
105
- res.desc = descMap.get(directions[nextIndex]);
119
+ res.desc = descMap.get(directions[nextIndex]); // 如果没有排序方向,则返回默认排序对象
106
120
 
107
- // 如果没有排序方向,则返回默认排序对象
108
121
  if (res.desc === undefined) {
109
122
  res.id = '';
110
123
  }
124
+
111
125
  return res;
112
126
  };
127
+
113
128
  var getHeaderProps = function getHeaderProps(column) {
114
129
  // @ts-ignore
115
130
  var id = column.id,
116
- canSort = column.canSort,
117
- sorter = column.sorter,
118
- sortOrder = column.sortOrder,
119
- sortDirections = column.sortDirections;
120
- var toggleProps = column.getSortByToggleProps();
131
+ canSort = column.canSort,
132
+ sorter = column.sorter,
133
+ sortOrder = column.sortOrder,
134
+ sortDirections = column.sortDirections;
135
+ var toggleProps = column.getSortByToggleProps(); // 仅在Table设置sortable时,所有列的canSort为true,此时为前端排序
121
136
 
122
- // 仅在Table设置sortable时,所有列的canSort为true,此时为前端排序
123
137
  if (canSort) {
124
138
  // client sort
125
139
  return _objectSpread(_objectSpread({}, column.getHeaderProps(_objectSpread({}, toggleProps))), {}, {
126
140
  onClick: function onClick(e) {
127
141
  e.stopPropagation();
142
+
128
143
  if (typeof toggleProps.onClick === 'function') {
129
144
  var _sortBy = getSortBy(id, sortDirections, sortOrder);
145
+
130
146
  setSortBy(_sortBy.desc === undefined ? [defaultSortObject] : [_sortBy]); // 客户端排序时 需要重新设置排序
147
+
131
148
  setSortDirection(_sortBy);
132
149
  onChange(_sortBy);
133
150
  }
134
151
  }
135
152
  });
136
- }
137
- // 当列设置sorter属性时,则为服务端排序
153
+ } // 当列设置sorter属性时,则为服务端排序
154
+
155
+
138
156
  if (sorter) {
139
157
  // server sort
140
158
  return _objectSpread(_objectSpread({}, column.getHeaderProps({
@@ -150,15 +168,19 @@ function TableHead(props) {
150
168
  }
151
169
  });
152
170
  }
171
+
153
172
  return column.getHeaderProps();
154
173
  };
174
+
155
175
  var SortIcons = function SortIcons(_ref) {
156
176
  var id = _ref.id;
157
177
  var currentSortId = sortDirection.id,
158
- desc = sortDirection.desc;
178
+ desc = sortDirection.desc;
179
+
159
180
  if (id !== currentSortId || !sortable) {
160
181
  return null;
161
182
  }
183
+
162
184
  return desc ? /*#__PURE__*/React.createElement(FoldDownFill, {
163
185
  className: "".concat(prefixCls, "-sortIcon"),
164
186
  fill: "currentColor",
@@ -168,12 +190,14 @@ function TableHead(props) {
168
190
  fill: "currentColor",
169
191
  size: 12
170
192
  });
171
- };
193
+ }; // 在页面拖拽完成之后 更新表格整体宽度以及每个列对应的列宽map
194
+
172
195
 
173
- // 在页面拖拽完成之后 更新表格整体宽度以及每个列对应的列宽map
174
196
  var adjustColumnsMapAfterDrag = function adjustColumnsMapAfterDrag(key, width) {
175
197
  var _columnsWidthMapRef$c, _columnsWidthMapRef$c2;
198
+
176
199
  var newMap = _.cloneDeep(columnsWidthMapRef.current);
200
+
177
201
  var originWidth = (_columnsWidthMapRef$c = columnsWidthMapRef.current) === null || _columnsWidthMapRef$c === void 0 ? void 0 : (_columnsWidthMapRef$c2 = _columnsWidthMapRef$c.get(key)) === null || _columnsWidthMapRef$c2 === void 0 ? void 0 : _columnsWidthMapRef$c2.width;
178
202
  var newWidth = getValidWidthByNumber(width);
179
203
  newMap.set(key, {
@@ -183,19 +207,24 @@ function TableHead(props) {
183
207
  columnsWidthMapRef.current = newMap;
184
208
  columnsTotalWidthRef.current = columnsTotalWidthRef.current - originWidth + newWidth;
185
209
  };
210
+
186
211
  var handleStyleAndReturn = function handleStyleAndReturn(column, index) {
187
212
  var _get, _getHeaderProps$style, _getHeaderProps$style2;
213
+
188
214
  var key = index.toString();
189
215
  var lastColumnsMapWidth = (_get = columnsWidthMapRef.current.get(key)) === null || _get === void 0 ? void 0 : _get.width; // 在拖动之前记录宽度map
216
+
190
217
  var currentRenderWidth = Number((_getHeaderProps$style = getHeaderProps(column).style) === null || _getHeaderProps$style === void 0 ? void 0 : (_getHeaderProps$style2 = _getHeaderProps$style.width) === null || _getHeaderProps$style2 === void 0 ? void 0 : _getHeaderProps$style2.toString().replace('px', '')); // 表格内置计算的宽度 'px'
191
218
 
192
219
  if (currentRenderWidth !== lastColumnsMapWidth) {
193
220
  adjustColumnsMapAfterDrag(key, currentRenderWidth);
194
221
  }
222
+
195
223
  return _objectSpread(_objectSpread({}, getHeaderProps(column).style), {}, {
196
224
  width: getValidWidthByNumber(currentRenderWidth)
197
225
  });
198
226
  };
227
+
199
228
  return /*#__PURE__*/React.createElement("div", {
200
229
  className: "".concat(prefixCls, "-thead"),
201
230
  style: {
@@ -203,8 +232,9 @@ function TableHead(props) {
203
232
  }
204
233
  }, headerGroups.map(function (headerGroup) {
205
234
  var _headerGroup$getHeade = headerGroup.getHeaderGroupProps(),
206
- style = _headerGroup$getHeade.style,
207
- headerGroupProps = _objectWithoutProperties(_headerGroup$getHeade, _excluded);
235
+ style = _headerGroup$getHeade.style,
236
+ headerGroupProps = _objectWithoutProperties(_headerGroup$getHeade, _excluded);
237
+
208
238
  return /*#__PURE__*/React.createElement("div", _extends({}, headerGroupProps, {
209
239
  className: "".concat(prefixCls, "-row")
210
240
  }), headerGroup.headers.map(function (column, index) {
@@ -228,4 +258,5 @@ function TableHead(props) {
228
258
  }));
229
259
  }));
230
260
  }
261
+
231
262
  export default TableHead;
@@ -1,25 +1,35 @@
1
1
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+
2
3
  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."); }
4
+
3
5
  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); }
4
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
- function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
6
+
7
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
8
+
9
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
10
+
6
11
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
+
7
13
  // @ts-nocheck
8
14
  import { useRef, useState, useEffect } from 'react';
15
+
9
16
  /**
10
17
  * Execute code before next frame but async
11
18
  */
12
19
  export function useLayoutState(defaultState) {
13
20
  var stateRef = useRef(defaultState);
21
+
14
22
  var _useState = useState({}),
15
- _useState2 = _slicedToArray(_useState, 2),
16
- forceUpdate = _useState2[1];
23
+ _useState2 = _slicedToArray(_useState, 2),
24
+ forceUpdate = _useState2[1];
25
+
17
26
  var lastPromiseRef = useRef(null);
18
27
  var updateBatchRef = useRef([]);
28
+
19
29
  function setFrameState(updater) {
20
30
  updateBatchRef.current.push(updater);
21
- var promise = Promise.resolve();
22
- // @ts-ignore;
31
+ var promise = Promise.resolve(); // @ts-ignore;
32
+
23
33
  lastPromiseRef.current = promise;
24
34
  promise.then(function () {
25
35
  if (lastPromiseRef.current === promise) {
@@ -28,16 +38,17 @@ export function useLayoutState(defaultState) {
28
38
  updateBatchRef.current = [];
29
39
  prevBatch.forEach(function (batchUpdater) {
30
40
  stateRef.current = batchUpdater(stateRef.current);
31
- });
41
+ }); // @ts-ignore;
32
42
 
33
- // @ts-ignore;
34
43
  lastPromiseRef.current = null;
44
+
35
45
  if (prevState !== stateRef.current) {
36
46
  forceUpdate({});
37
47
  }
38
48
  }
39
49
  });
40
50
  }
51
+
41
52
  useEffect(function () {
42
53
  return function () {
43
54
  // @ts-ignore;
@@ -46,15 +57,17 @@ export function useLayoutState(defaultState) {
46
57
  }, []);
47
58
  return [stateRef.current, setFrameState];
48
59
  }
49
-
50
60
  /** Lock frame, when frame pass reset the lock. */
61
+
51
62
  export function useTimeoutLock(defaultState) {
52
63
  var frameRef = useRef(defaultState || null);
53
64
  var timeoutRef = useRef();
54
65
  var TIMEOUT_DELAY = 50;
66
+
55
67
  function cleanUp() {
56
68
  window.clearTimeout(timeoutRef.current);
57
69
  }
70
+
58
71
  function setState(newState) {
59
72
  // @ts-ignore;
60
73
  frameRef.current = newState;
@@ -65,9 +78,11 @@ export function useTimeoutLock(defaultState) {
65
78
  timeoutRef.current = undefined;
66
79
  }, TIMEOUT_DELAY);
67
80
  }
81
+
68
82
  function getState() {
69
83
  return frameRef.current;
70
84
  }
85
+
71
86
  useEffect(function () {
72
87
  return cleanUp;
73
88
  }, []);
@@ -41,7 +41,7 @@
41
41
  color: inherit;
42
42
  text-align: left;
43
43
  word-break: break-all;
44
- border-bottom: 1px solid @BG70;
44
+ border-bottom: 1px solid @BG80;
45
45
 
46
46
  &-content {
47
47
  flex: 1;
@@ -8,9 +8,11 @@ export function isPercentageWidth(width) {
8
8
  export function isSpecificPxWidth(width) {
9
9
  return /[0-9]{1,}(px)$/.test(width);
10
10
  }
11
+
11
12
  function isSpecificWidth(width) {
12
13
  return typeof width === 'number' || !!(width && isSpecificPxWidth(width));
13
14
  }
15
+
14
16
  export function getValidWidthByNumber(width) {
15
17
  return width < COLUMN_MIN_WIDTH ? COLUMN_MIN_WIDTH : width;
16
18
  }
@@ -23,6 +25,7 @@ export function getPxValue(px) {
23
25
  }
24
26
  export function getValidScrollThreshold(height, clientHeight) {
25
27
  var scrollThreshold = ZERO;
28
+
26
29
  if (typeof height === 'string') {
27
30
  if (isPercentageWidth(height)) {
28
31
  scrollThreshold = getPercentageValue(height, clientHeight);
@@ -32,25 +35,32 @@ export function getValidScrollThreshold(height, clientHeight) {
32
35
  } else {
33
36
  scrollThreshold = height;
34
37
  }
38
+
35
39
  return scrollThreshold;
36
40
  }
41
+
37
42
  function getWidthByColumnsWidth(clientWidth, width, widthFlex) {
38
43
  if (width === undefined || widthFlex) {
39
44
  return NOT_SET;
40
45
  }
46
+
41
47
  if (typeof width === 'number') {
42
48
  return getValidWidthByNumber(width);
43
49
  }
50
+
44
51
  if (isPercentageWidth(width)) {
45
52
  return getPercentageValue(width, clientWidth);
46
53
  }
54
+
47
55
  if (isSpecificPxWidth(width)) {
48
56
  var specificNum = getPxValue(width);
49
57
  return getValidWidthByNumber(specificNum);
50
58
  }
59
+
51
60
  return NOT_SET;
52
- }
53
- // TODO: 添加单侧
61
+ } // TODO: 添加单侧
62
+
63
+
54
64
  export function getColumnsWidthMap(columns, clientWidth, lastWidthMap // 容器宽度变化之后才会传入一个最新的map
55
65
  ) {
56
66
  var settedTotalWidth = ZERO;
@@ -60,55 +70,64 @@ export function getColumnsWidthMap(columns, clientWidth, lastWidthMap // 容器
60
70
  columns.forEach(function (item, index) {
61
71
  var key = index.toString();
62
72
  var widthFlex = item.widthFlex;
63
- var width = getWidthByColumnsWidth(clientWidth, item.width, widthFlex);
64
- // 首先判断是否是否是容器宽度的变化
73
+ var width = getWidthByColumnsWidth(clientWidth, item.width, widthFlex); // 首先判断是否是否是容器宽度的变化
74
+
65
75
  var isSpecific;
76
+
66
77
  if (widthFlex) {
67
78
  isSpecific = false;
68
79
  } else {
69
80
  var _lastWidthMap$get;
81
+
70
82
  isSpecific = lastWidthMap ? (_lastWidthMap$get = lastWidthMap.get(key)) === null || _lastWidthMap$get === void 0 ? void 0 : _lastWidthMap$get.isSpecific : isSpecificWidth(item.width);
71
83
  }
84
+
72
85
  if (lastWidthMap && isSpecific) {
73
86
  var _lastWidthMap$get2;
87
+
74
88
  width = (_lastWidthMap$get2 = lastWidthMap.get(key)) === null || _lastWidthMap$get2 === void 0 ? void 0 : _lastWidthMap$get2.width;
75
89
  }
90
+
76
91
  if (width === NOT_SET) {
77
92
  unsetWidthIndex.push(key);
78
93
  } else {
79
94
  settedTotalWidth += width;
80
95
  }
96
+
81
97
  widthMap.set(key, {
82
98
  width: width,
83
99
  isSpecific: isSpecific
84
100
  });
85
- });
101
+ }); // 设定宽度大于容器宽度时
86
102
 
87
- // 设定宽度大于容器宽度时
88
103
  if (settedTotalWidth < clientWidth) {
89
104
  unsetWidthIndex.map(function (item) {
90
105
  var _widthMap$get;
106
+
91
107
  return widthMap.set(item, {
92
108
  isSpecific: (_widthMap$get = widthMap.get(item)) === null || _widthMap$get === void 0 ? void 0 : _widthMap$get.isSpecific,
93
109
  width: COLUMN_MIN_WIDTH
94
110
  });
95
111
  });
96
- }
112
+ } // 设定宽度小于容器宽度时
113
+
97
114
 
98
- // 设定宽度小于容器宽度时
99
115
  if (unsetWidthIndex.length > ZERO) {
100
116
  var leftWidth = clientWidth - settedTotalWidth;
101
117
  var average = getValidWidthByNumber(leftWidth / unsetWidthIndex.length);
102
118
  unsetWidthIndex.map(function (item) {
103
119
  var _widthMap$get2;
120
+
104
121
  return widthMap.set(item, {
105
122
  isSpecific: (_widthMap$get2 = widthMap.get(item)) === null || _widthMap$get2 === void 0 ? void 0 : _widthMap$get2.isSpecific,
106
123
  width: average
107
124
  });
108
125
  });
109
126
  }
127
+
110
128
  columns.forEach(function (item, index) {
111
129
  var _widthMap$get3;
130
+
112
131
  var key = index.toString();
113
132
  var width = (_widthMap$get3 = widthMap.get(key)) === null || _widthMap$get3 === void 0 ? void 0 : _widthMap$get3.width;
114
133
  totalColumnWidth += width;