@lemon-fe/components 0.1.4 → 0.1.7

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
- var _excluded = ["onWidthChange", "width", "fullTableRef"],
2
- _excluded2 = ["id", "columns", "defaultColumnProps", "rowKey", "children", "summaryTitle", "summaryRecord", "dataSource", "onSortChange", "sort", "scroll", "virtual", "components", "pagination", "onChange", "rowHeight", "tableLayout", "rowActions"];
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"];
3
3
 
4
4
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
5
5
 
@@ -37,7 +37,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
37
37
  import React, { useMemo, useState, useEffect, useRef } from 'react';
38
38
  import { Table as AntdTable } from 'antd';
39
39
  import { get } from 'lodash';
40
- import { useThrottle } from '@lemon-fe/hooks';
40
+ import ResizeObserver from 'rc-resize-observer';
41
41
  import { isColumnType, getColumnKey } from './utils';
42
42
  import ResizeHeaderCell from './ResizeHeaderCell';
43
43
  import { PREFIX_CLS } from '../constants';
@@ -69,10 +69,25 @@ function Th(props) {
69
69
  var onWidthChange = props.onWidthChange,
70
70
  width = props.width,
71
71
  fullTableRef = props.fullTableRef,
72
+ children = props.children,
73
+ className = props.className,
72
74
  restProps = _objectWithoutProperties(props, _excluded);
73
75
 
76
+ var reg = /\bant-table-cell-ellipsis\b/;
77
+ var content = children;
78
+ var mClassName = className;
79
+
80
+ if (mClassName && reg.test(mClassName)) {
81
+ mClassName = mClassName.replace(reg, '');
82
+ content = /*#__PURE__*/React.createElement("div", {
83
+ className: "ant-table-cell-ellipsis"
84
+ }, content);
85
+ }
86
+
74
87
  if (!width || !onWidthChange) {
75
- return /*#__PURE__*/React.createElement("th", _objectSpread({}, restProps));
88
+ return /*#__PURE__*/React.createElement("th", _objectSpread(_objectSpread({}, restProps), {}, {
89
+ className: mClassName
90
+ }), content);
76
91
  }
77
92
 
78
93
  return /*#__PURE__*/React.createElement(ResizeHeaderCell, {
@@ -80,7 +95,9 @@ function Th(props) {
80
95
  onChange: onWidthChange,
81
96
  fullTableRef: fullTableRef,
82
97
  prefixCls: "".concat(PREFIX_CLS, "-table")
83
- }, /*#__PURE__*/React.createElement("th", _objectSpread({}, restProps)));
98
+ }, /*#__PURE__*/React.createElement("th", _objectSpread(_objectSpread({}, restProps), {}, {
99
+ className: mClassName
100
+ }), content));
84
101
  }
85
102
 
86
103
  function BaseTable(props) {
@@ -99,26 +116,29 @@ function BaseTable(props) {
99
116
  virtual = props.virtual,
100
117
  componentsProp = props.components,
101
118
  paginationProp = props.pagination,
102
- onChangeProp = props.onChange,
103
119
  rowHeight = props.rowHeight,
104
120
  _props$tableLayout = props.tableLayout,
105
121
  tableLayout = _props$tableLayout === void 0 ? 'fixed' : _props$tableLayout,
106
122
  rowActions = props.rowActions,
123
+ style = props.style,
107
124
  restProps = _objectWithoutProperties(props, _excluded2);
108
125
 
109
126
  var fullTableRef = useRef(null);
110
127
 
111
- var _useState = useState(0),
128
+ var _useState = useState(new Map()),
112
129
  _useState2 = _slicedToArray(_useState, 2),
113
- scrollY = _useState2[0],
114
- setScrollY = _useState2[1];
130
+ colsState = _useState2[0],
131
+ setColsState = _useState2[1];
132
+
133
+ var scrollYProp = scroll === null || scroll === void 0 ? void 0 : scroll.y;
115
134
 
116
- var _useState3 = useState(new Map()),
135
+ var _useState3 = useState(scrollYProp === true ? 0 : scrollYProp),
117
136
  _useState4 = _slicedToArray(_useState3, 2),
118
- colsState = _useState4[0],
119
- setColsState = _useState4[1];
120
- /** auto scroll y */
137
+ scrollY = _useState4[0],
138
+ setScrollY = _useState4[1];
121
139
 
140
+ var memoHeight = useRef(0);
141
+ /** auto scroll y */
122
142
 
123
143
  var calcScrollY = function calcScrollY() {
124
144
  var wrapper = fullTableRef.current;
@@ -164,31 +184,34 @@ function BaseTable(props) {
164
184
  return contentHeight;
165
185
  };
166
186
 
167
- var changeScrollY = useThrottle(function () {
168
- var nextScrollY = scrollY;
169
-
170
- if ((scroll === null || scroll === void 0 ? void 0 : scroll.y) === true) {
171
- var y = calcScrollY();
172
- nextScrollY = y || undefined;
173
- } else {
174
- nextScrollY = scroll === null || scroll === void 0 ? void 0 : scroll.y;
187
+ var changeScrollY = function changeScrollY(height) {
188
+ if (height === memoHeight.current) {
189
+ return;
175
190
  }
176
191
 
177
- setScrollY(nextScrollY);
192
+ memoHeight.current = height;
193
+ setScrollY(calcScrollY() || undefined);
194
+ };
178
195
 
179
- if (fullTableRef.current !== null) {
196
+ useEffect(function () {
197
+ if (scrollYProp !== true) {
198
+ setScrollY(scrollYProp);
199
+ }
200
+ }, [scrollYProp]);
201
+ useEffect(function () {
202
+ if (scrollY !== undefined && fullTableRef.current !== null) {
180
203
  var body = fullTableRef.current.querySelector('.ant-table-body');
181
204
 
182
205
  if (body !== null) {
183
- var dataType = _typeof(nextScrollY);
206
+ var dataType = _typeof(scrollY);
184
207
 
185
208
  switch (dataType) {
186
209
  case 'string':
187
- body.style.height = nextScrollY;
210
+ body.style.height = scrollY;
188
211
  break;
189
212
 
190
213
  case 'number':
191
- body.style.height = nextScrollY + 'px';
214
+ body.style.height = scrollY + 'px';
192
215
  break;
193
216
 
194
217
  default:
@@ -196,29 +219,9 @@ function BaseTable(props) {
196
219
  }
197
220
  }
198
221
  }
199
- }, 100, {
200
- trailing: true
201
- });
202
- useEffect(function () {
203
- changeScrollY();
204
- }, [scroll === null || scroll === void 0 ? void 0 : scroll.y, dataSource]);
205
- useEffect(function () {
206
- window.addEventListener('resize', changeScrollY);
207
- return function () {
208
- window.removeEventListener('resize', changeScrollY);
209
- };
210
- }, []);
211
-
212
- var handleChange = function handleChange() {
213
- changeScrollY();
214
-
215
- if (onChangeProp) {
216
- onChangeProp.apply(void 0, arguments);
217
- }
218
- };
222
+ }, [scrollY]);
219
223
  /** resizable column */
220
224
 
221
-
222
225
  var _useMemo = useMemo(function () {
223
226
  var flattenCols = [];
224
227
  var isFixedLayout = tableLayout === 'fixed';
@@ -383,22 +386,22 @@ function BaseTable(props) {
383
386
  rowHeight: rowHeight
384
387
  };
385
388
  }, [scrollY, rowHeight]);
386
- return /*#__PURE__*/React.createElement(BaseTableContext.Provider, {
387
- value: ctx
388
- }, /*#__PURE__*/React.createElement(AntdTable, _objectSpread(_objectSpread({
389
+ var tableNode = /*#__PURE__*/React.createElement(AntdTable, _objectSpread(_objectSpread({
389
390
  size: "small",
390
391
  ref: fullTableRef,
391
392
  columns: formatedColumns,
392
393
  dataSource: dataSource,
393
394
  rowKey: rowKey,
394
395
  summary: summary,
396
+ components: components,
397
+ tableLayout: tableLayout,
395
398
  scroll: {
396
399
  x: (scroll === null || scroll === void 0 ? void 0 : scroll.x) || '100%',
397
400
  y: scrollY
398
401
  },
399
- components: components,
400
- onChange: handleChange,
401
- tableLayout: tableLayout,
402
+ style: scrollYProp === true ? _objectSpread(_objectSpread({}, style), {}, {
403
+ height: '100%'
404
+ }) : style,
402
405
  locale: {
403
406
  emptyText: /*#__PURE__*/React.createElement("div", {
404
407
  className: "".concat(PREFIX_CLS, "-table-empty")
@@ -417,7 +420,19 @@ function BaseTable(props) {
417
420
  },
418
421
  defaultPageSize: 20
419
422
  }, paginationProp) : false
420
- })));
423
+ }));
424
+
425
+ if (scrollYProp === true) {
426
+ tableNode = /*#__PURE__*/React.createElement(ResizeObserver, {
427
+ onResize: function onResize(size) {
428
+ return changeScrollY(size.height);
429
+ }
430
+ }, tableNode);
431
+ }
432
+
433
+ return /*#__PURE__*/React.createElement(BaseTableContext.Provider, {
434
+ value: ctx
435
+ }, tableNode);
421
436
  }
422
437
 
423
438
  BaseTable.Summary = AntdTable.Summary;
@@ -77,8 +77,12 @@
77
77
  content: '';
78
78
  }
79
79
 
80
- &-column::after {
81
- display: none !important;
80
+ &-column {
81
+ border-right: none !important;
82
+
83
+ &::after {
84
+ display: none !important;
85
+ }
82
86
  }
83
87
 
84
88
  &-item {
@@ -157,22 +161,28 @@
157
161
  width: 11px;
158
162
  height: 12px;
159
163
  margin-top: -6px;
164
+ padding: 0 5px;
165
+ background-color: #bbb;
166
+ background-clip: content-box;
160
167
  cursor: col-resize;
168
+ }
161
169
 
162
- & > div {
163
- width: 1px;
164
- height: 100%;
165
- margin: 0 auto;
166
- background-color: #bbb;
167
- }
170
+ .ant-table-bordered &-resizable-handle {
171
+ right: -6px;
172
+ background-color: transparent;
168
173
  }
169
174
 
170
175
  &-resizable-indicator {
171
176
  position: absolute;
172
177
  top: 0;
173
178
  z-index: 20;
174
- width: 1px;
179
+ box-sizing: border-box;
180
+ width: 11px;
181
+ margin-left: -5px;
182
+ padding: 0 5px;
175
183
  background-color: @resize-indicator-color;
184
+ background-clip: content-box;
185
+ cursor: col-resize;
176
186
  }
177
187
 
178
188
  &-resizing-col thead th {
@@ -1,3 +1,5 @@
1
+ var _excluded = ["prefixCls", "types", "options", "value", "dateFormat", "onChange"];
2
+
1
3
  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; }
2
4
 
3
5
  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; }
@@ -16,6 +18,10 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
16
18
 
17
19
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
18
20
 
21
+ 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; }
22
+
23
+ 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; }
24
+
19
25
  import React, { useMemo, useState, useEffect } from 'react';
20
26
  import { DatePicker, Dropdown, Menu } from 'antd';
21
27
  import moment from 'moment';
@@ -106,7 +112,9 @@ export default function DurationPicker(props) {
106
112
  valueProp = props.value,
107
113
  _props$dateFormat = props.dateFormat,
108
114
  dateFormat = _props$dateFormat === void 0 ? 'YYYY-MM-DD' : _props$dateFormat,
109
- onChange = props.onChange;
115
+ onChange = props.onChange,
116
+ restProps = _objectWithoutProperties(props, _excluded);
117
+
110
118
  var defaultValue = useMemo(function () {
111
119
  if (valueProp === undefined) {
112
120
  var _options$0$value, _options$;
@@ -218,9 +226,9 @@ export default function DurationPicker(props) {
218
226
  }))
219
227
  }, /*#__PURE__*/React.createElement("div", {
220
228
  className: "".concat(prefixCls, "-duration-option")
221
- }, (_result$option = result.option) === null || _result$option === void 0 ? void 0 : _result$option.label, /*#__PURE__*/React.createElement(Down, null))), /*#__PURE__*/React.createElement(DatePicker.RangePicker, {
229
+ }, (_result$option = result.option) === null || _result$option === void 0 ? void 0 : _result$option.label, /*#__PURE__*/React.createElement(Down, null))), /*#__PURE__*/React.createElement(DatePicker.RangePicker, _objectSpread({
222
230
  value: result.dates,
223
231
  onChange: handleChangeDates,
224
232
  disabled: ((_result$option2 = result.option) === null || _result$option2 === void 0 ? void 0 : _result$option2.value) !== null
225
- })));
233
+ }, restProps))));
226
234
  }
package/es/Icons/More.js CHANGED
@@ -15,7 +15,7 @@ var MoreSvg = function MoreSvg(props) {
15
15
  xmlns: "http://www.w3.org/2000/svg"
16
16
  }, props), /*#__PURE__*/React.createElement("g", {
17
17
  fill: "currentColor",
18
- "fill-rule": "evenodd"
18
+ fillRule: "evenodd"
19
19
  }, /*#__PURE__*/React.createElement("circle", {
20
20
  opacity: ".7",
21
21
  cx: "15",
@@ -2,19 +2,21 @@
2
2
  position: relative;
3
3
  display: flex;
4
4
  flex-direction: column;
5
- min-height: 100%;
5
+ height: 100%;
6
6
  padding: 0 @space;
7
7
  background: #f2f2f2;
8
8
 
9
9
  &-header {
10
10
  padding: @space 0;
11
+ background-color: #f2f2f2;
11
12
  }
12
13
 
13
14
  &-content {
14
15
  display: flex;
15
16
  flex: 1;
17
+ min-height: 0;
18
+ overflow: hidden;
16
19
  background-color: #fff;
17
- background-clip: content-box;
18
20
  border-top-left-radius: 8px;
19
21
  border-top-right-radius: 8px;
20
22
 
@@ -87,19 +89,18 @@
87
89
  }
88
90
 
89
91
  &-main {
92
+ display: flex;
90
93
  flex: 1;
94
+ flex-direction: column;
91
95
  min-width: 0;
96
+ overflow: auto;
92
97
  }
93
98
 
94
99
  &-footer {
95
- position: sticky;
96
- bottom: 0;
97
- z-index: 10;
98
100
  display: flex;
99
101
  align-items: center;
100
- justify-content: flex-end;
102
+ justify-content: center;
101
103
  box-sizing: border-box;
102
- width: 100%;
103
104
  height: 65px;
104
105
  padding: @space;
105
106
  background: #fff;
@@ -118,17 +119,3 @@
118
119
  background-color: rgba(255, 255, 255, 0.5);
119
120
  }
120
121
  }
121
-
122
- .@{prefixCls}-layout.@{prefixCls}-layout-full {
123
- height: 100%;
124
- min-height: 0;
125
-
126
- .@{prefixCls}-layout-content {
127
- min-height: 0;
128
- }
129
-
130
- .@{prefixCls}-layout-main {
131
- display: flex;
132
- flex-direction: column;
133
- }
134
- }
@@ -18,6 +18,7 @@
18
18
 
19
19
  &-flex &-body {
20
20
  flex: 1 1 100%;
21
+ min-height: 0;
21
22
  }
22
23
 
23
24
  &-header {
@@ -63,7 +63,8 @@ export default function TreeNodeTitle(props) {
63
63
  var others = (_operation$others = operation.others) === null || _operation$others === void 0 ? void 0 : _operation$others.call(operation, item);
64
64
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
65
65
  className: "".concat(prefixCls, "-title-content"),
66
- ref: trigger
66
+ ref: trigger,
67
+ title: item.title.toString()
67
68
  }, item.title), /*#__PURE__*/React.createElement("div", {
68
69
  className: "".concat(prefixCls, "-title-operators"),
69
70
  style: {
@@ -69,6 +69,7 @@
69
69
  &-unit {
70
70
  display: inline-block;
71
71
  width: @indentWidth;
72
+ vertical-align: top;
72
73
  }
73
74
  }
74
75
 
@@ -121,7 +122,7 @@
121
122
  flex: 1;
122
123
  align-items: center;
123
124
  justify-content: space-between;
124
- min-width: 0;
125
+ min-width: 56px;
125
126
  padding: 0 8px;
126
127
  border-radius: 4px;
127
128
  cursor: pointer;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lemon-fe/components",
3
- "version": "0.1.4",
3
+ "version": "0.1.7",
4
4
  "description": "> TODO: description",
5
5
  "author": "鲁盛杰 <lusj@cnlemon.net>",
6
6
  "homepage": "",
@@ -17,11 +17,8 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "@lemon-fe/hooks": "^0.1.2",
20
- "antd": "^4.20.2",
21
20
  "classnames": "^2.2.6",
22
21
  "lodash": "^4.17.21",
23
- "react": "^17.0.2",
24
- "react-dom": "^17.0.2",
25
22
  "react-resizable": "^3.0.4"
26
23
  },
27
24
  "peerDependencies": {
@@ -30,6 +27,7 @@
30
27
  "classnames": ">=2.2.6",
31
28
  "color-string": ">=1.0.0",
32
29
  "lodash": ">=4.17.0",
30
+ "rc-resize-observer": "^1.0.0",
33
31
  "rc-tree": ">=4.0.0",
34
32
  "react": ">=16.9.0",
35
33
  "react-dom": ">=16.9.0"
@@ -37,7 +35,11 @@
37
35
  "devDependencies": {
38
36
  "@types/color-string": "^1.5.2",
39
37
  "@types/lodash": "^4.14.179",
40
- "@types/react-resizable": "^1.7.4"
38
+ "@types/react-resizable": "^1.7.4",
39
+ "antd": "^4.20.2",
40
+ "rc-resize-observer": "^1.2.0",
41
+ "react": "^17.0.2",
42
+ "react-dom": "^17.0.2"
41
43
  },
42
- "gitHead": "f0f512c0a2e59bedb7ec800d545d395580f07038"
44
+ "gitHead": "84f94d37e2938930fa2c32d2da6573dfc517b458"
43
45
  }