@douyinfe/semi-ui 2.34.0-beta.0 → 2.34.0
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.
- package/dist/umd/semi-ui.js +931 -948
- package/dist/umd/semi-ui.js.map +1 -1
- package/dist/umd/semi-ui.min.js +1 -1
- package/dist/umd/semi-ui.min.js.map +1 -1
- package/lib/cjs/form/group.js +4 -2
- package/lib/cjs/image/image.d.ts +4 -0
- package/lib/cjs/image/image.js +23 -1
- package/lib/cjs/image/preview.d.ts +1 -1
- package/lib/cjs/image/preview.js +9 -16
- package/lib/cjs/image/previewContext.d.ts +1 -0
- package/lib/cjs/table/Table.js +12 -10
- package/lib/cjs/typography/util.js +5 -1
- package/lib/es/form/group.js +4 -2
- package/lib/es/image/image.d.ts +4 -0
- package/lib/es/image/image.js +23 -1
- package/lib/es/image/preview.d.ts +1 -1
- package/lib/es/image/preview.js +9 -16
- package/lib/es/image/previewContext.d.ts +1 -0
- package/lib/es/table/Table.js +11 -9
- package/lib/es/typography/util.js +5 -1
- package/package.json +8 -8
package/lib/cjs/form/group.js
CHANGED
|
@@ -99,7 +99,7 @@ class FormInputGroup extends _react.Component {
|
|
|
99
99
|
rest = __rest(_a, ["children", "label", "extraText", "extraTextPosition"]);
|
|
100
100
|
|
|
101
101
|
const updater = this.context;
|
|
102
|
-
const formProps = updater.getFormProps(['labelPosition', 'labelWidth', 'labelAlign', 'showValidateIcon', 'wrapperCol', 'labelCol']);
|
|
102
|
+
const formProps = updater.getFormProps(['labelPosition', 'labelWidth', 'labelAlign', 'showValidateIcon', 'wrapperCol', 'labelCol', 'disabled']);
|
|
103
103
|
const labelPosition = this.props.labelPosition || formProps.labelPosition;
|
|
104
104
|
const groupFieldSet = [];
|
|
105
105
|
|
|
@@ -126,7 +126,9 @@ class FormInputGroup extends _react.Component {
|
|
|
126
126
|
const labelColCls = labelCol ? `${prefix}-col-${labelAlign}` : '';
|
|
127
127
|
const labelContent = this.renderLabel(label, formProps);
|
|
128
128
|
|
|
129
|
-
const inputGroupContent = /*#__PURE__*/_react.default.createElement(_inputGroup.default, Object.assign({
|
|
129
|
+
const inputGroupContent = /*#__PURE__*/_react.default.createElement(_inputGroup.default, Object.assign({
|
|
130
|
+
disabled: formProps.disabled
|
|
131
|
+
}, rest), inner);
|
|
130
132
|
|
|
131
133
|
const groupErrorContent = /*#__PURE__*/_react.default.createElement(GroupError, {
|
|
132
134
|
fieldSet: groupFieldSet,
|
package/lib/cjs/image/image.d.ts
CHANGED
|
@@ -29,8 +29,12 @@ export default class Image extends BaseComponent<ImageProps, ImageStates> {
|
|
|
29
29
|
get adapter(): ImageAdapter<ImageProps, ImageStates>;
|
|
30
30
|
context: PreviewContextProps;
|
|
31
31
|
foundation: ImageFoundation;
|
|
32
|
+
imgRef: React.RefObject<HTMLImageElement>;
|
|
32
33
|
constructor(props: ImageProps);
|
|
33
34
|
static getDerivedStateFromProps(props: ImageProps, state: ImageStates): Partial<ImageStates>;
|
|
35
|
+
componentDidMount(): void;
|
|
36
|
+
componentDidUpdate(prevProps: ImageProps, prevState: ImageStates): void;
|
|
37
|
+
observeImage(): void;
|
|
34
38
|
isInGroup(): boolean;
|
|
35
39
|
isLazyLoad(): boolean;
|
|
36
40
|
handleClick: (e: any) => void;
|
package/lib/cjs/image/image.js
CHANGED
|
@@ -153,6 +153,7 @@ class Image extends _baseComponent.default {
|
|
|
153
153
|
previewVisible: false
|
|
154
154
|
};
|
|
155
155
|
this.foundation = new _imageFoundation.default(this.adapter);
|
|
156
|
+
this.imgRef = /*#__PURE__*/_react.default.createRef();
|
|
156
157
|
}
|
|
157
158
|
|
|
158
159
|
get adapter() {
|
|
@@ -182,6 +183,25 @@ class Image extends _baseComponent.default {
|
|
|
182
183
|
return willUpdateStates;
|
|
183
184
|
}
|
|
184
185
|
|
|
186
|
+
componentDidMount() {
|
|
187
|
+
this.observeImage();
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
componentDidUpdate(prevProps, prevState) {
|
|
191
|
+
prevProps.src !== this.props.src && this.observeImage();
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
observeImage() {
|
|
195
|
+
if (!this.isLazyLoad()) {
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const {
|
|
200
|
+
previewObserver
|
|
201
|
+
} = this.context;
|
|
202
|
+
previewObserver.observe(this.imgRef.current);
|
|
203
|
+
}
|
|
204
|
+
|
|
185
205
|
isInGroup() {
|
|
186
206
|
return Boolean(this.context && this.context.isGroup);
|
|
187
207
|
}
|
|
@@ -236,7 +256,9 @@ class Image extends _baseComponent.default {
|
|
|
236
256
|
style: outerStyle,
|
|
237
257
|
className: outerCls,
|
|
238
258
|
onClick: this.handleClick
|
|
239
|
-
}, /*#__PURE__*/_react.default.createElement("img", Object.assign({
|
|
259
|
+
}, /*#__PURE__*/_react.default.createElement("img", Object.assign({
|
|
260
|
+
ref: this.imgRef
|
|
261
|
+
}, restProps, {
|
|
240
262
|
src: this.isInGroup() && this.isLazyLoad() ? undefined : src,
|
|
241
263
|
"data-src": src,
|
|
242
264
|
alt: alt,
|
|
@@ -69,8 +69,8 @@ export default class Preview extends BaseComponent<PreviewProps, PreviewState> {
|
|
|
69
69
|
foundation: PreviewFoundation;
|
|
70
70
|
previewGroupId: string;
|
|
71
71
|
previewRef: React.RefObject<PreviewInner>;
|
|
72
|
+
previewObserver: IntersectionObserver;
|
|
72
73
|
constructor(props: any);
|
|
73
|
-
componentDidMount(): void;
|
|
74
74
|
static getDerivedStateFromProps(props: PreviewProps, state: PreviewState): Partial<PreviewState>;
|
|
75
75
|
handleVisibleChange: (newVisible: boolean) => void;
|
|
76
76
|
handleCurrentIndexChange: (index: number) => void;
|
package/lib/cjs/image/preview.js
CHANGED
|
@@ -112,19 +112,7 @@ class Preview extends _baseComponent.default {
|
|
|
112
112
|
length: 4
|
|
113
113
|
});
|
|
114
114
|
this.previewRef = /*#__PURE__*/_react.default.createRef();
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
get adapter() {
|
|
118
|
-
return Object.assign({}, super.adapter);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
componentDidMount() {
|
|
122
|
-
const {
|
|
123
|
-
lazyLoadMargin
|
|
124
|
-
} = this.props;
|
|
125
|
-
const allElement = document.querySelectorAll(`.${prefixCls}-img`); // use IntersectionObserver to lazy load image
|
|
126
|
-
|
|
127
|
-
const observer = new IntersectionObserver(entries => {
|
|
115
|
+
this.previewObserver = new IntersectionObserver(entries => {
|
|
128
116
|
entries.forEach(item => {
|
|
129
117
|
var _a;
|
|
130
118
|
|
|
@@ -132,14 +120,18 @@ class Preview extends _baseComponent.default {
|
|
|
132
120
|
|
|
133
121
|
if (item.isIntersecting && src) {
|
|
134
122
|
item.target.src = src;
|
|
135
|
-
|
|
123
|
+
item.target.removeAttribute("data-src");
|
|
124
|
+
this.previewObserver.unobserve(item.target);
|
|
136
125
|
}
|
|
137
126
|
});
|
|
138
127
|
}, {
|
|
139
128
|
root: document.querySelector(`#${this.previewGroupId}`),
|
|
140
|
-
rootMargin: lazyLoadMargin
|
|
129
|
+
rootMargin: props.lazyLoadMargin
|
|
141
130
|
});
|
|
142
|
-
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
get adapter() {
|
|
134
|
+
return Object.assign({}, super.adapter);
|
|
143
135
|
}
|
|
144
136
|
|
|
145
137
|
static getDerivedStateFromProps(props, state) {
|
|
@@ -184,6 +176,7 @@ class Preview extends _baseComponent.default {
|
|
|
184
176
|
currentIndex,
|
|
185
177
|
visible,
|
|
186
178
|
lazyLoad,
|
|
179
|
+
previewObserver: this.previewObserver,
|
|
187
180
|
setCurrentIndex: this.handleCurrentIndexChange,
|
|
188
181
|
handleVisibleChange: this.handleVisibleChange
|
|
189
182
|
}
|
|
@@ -6,6 +6,7 @@ export interface PreviewContextProps {
|
|
|
6
6
|
titles: ReactNode[];
|
|
7
7
|
currentIndex: number;
|
|
8
8
|
visible: boolean;
|
|
9
|
+
previewObserver: IntersectionObserver;
|
|
9
10
|
setCurrentIndex: (current: number) => void;
|
|
10
11
|
handleVisibleChange: (visible: boolean, preVisible?: boolean) => void;
|
|
11
12
|
}
|
package/lib/cjs/table/Table.js
CHANGED
|
@@ -5,14 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
+
var _isPlainObject2 = _interopRequireDefault(require("lodash/isPlainObject"));
|
|
9
|
+
|
|
8
10
|
var _isObject2 = _interopRequireDefault(require("lodash/isObject"));
|
|
9
11
|
|
|
10
12
|
var _isFunction2 = _interopRequireDefault(require("lodash/isFunction"));
|
|
11
13
|
|
|
12
14
|
var _difference2 = _interopRequireDefault(require("lodash/difference"));
|
|
13
15
|
|
|
14
|
-
var _isNull2 = _interopRequireDefault(require("lodash/isNull"));
|
|
15
|
-
|
|
16
16
|
var _omit2 = _interopRequireDefault(require("lodash/omit"));
|
|
17
17
|
|
|
18
18
|
var _each2 = _interopRequireDefault(require("lodash/each"));
|
|
@@ -881,6 +881,9 @@ class Table extends _baseComponent.default {
|
|
|
881
881
|
|
|
882
882
|
const queries = _foundation.default.initColumnsFilteredValueAndSorterOrder((0, _utils2.cloneDeep)(cachedflattenColumns));
|
|
883
883
|
|
|
884
|
+
const filteredSortedDataSource = this.foundation.getFilteredSortedDataSource(this.props.dataSource, queries);
|
|
885
|
+
const newPagination = (0, _isPlainObject2.default)(this.props.pagination) ? this.props.pagination : {};
|
|
886
|
+
const pageData = this.foundation.getCurrentPageData(filteredSortedDataSource, newPagination, queries);
|
|
884
887
|
this.state = {
|
|
885
888
|
/**
|
|
886
889
|
* Cached props
|
|
@@ -894,11 +897,11 @@ class Table extends _baseComponent.default {
|
|
|
894
897
|
* State calculated based on prop
|
|
895
898
|
*/
|
|
896
899
|
queries,
|
|
897
|
-
dataSource:
|
|
900
|
+
dataSource: pageData.dataSource,
|
|
898
901
|
flattenData: [],
|
|
899
902
|
expandedRowKeys: [...(props.expandedRowKeys || []), ...(props.defaultExpandedRowKeys || [])],
|
|
900
903
|
rowSelection: props.rowSelection ? (0, _isObject2.default)(props.rowSelection) ? Object.assign({}, props.rowSelection) : {} : null,
|
|
901
|
-
pagination:
|
|
904
|
+
pagination: pageData.pagination,
|
|
902
905
|
|
|
903
906
|
/**
|
|
904
907
|
* Internal state
|
|
@@ -1479,12 +1482,11 @@ class Table extends _baseComponent.default {
|
|
|
1479
1482
|
* TODO: After merging issue 1007, you can place it in the constructor to complete
|
|
1480
1483
|
* The reason is that #1007 exposes the parameters required by getCurrentPageData in the constructor
|
|
1481
1484
|
*/
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
}
|
|
1485
|
+
// if (isNull(dataSource)) {
|
|
1486
|
+
// const pageData: BasePageData<RecordType> = this.foundation.getCurrentPageData(this.props.dataSource);
|
|
1487
|
+
// dataSource = pageData.dataSource;
|
|
1488
|
+
// pagination = pageData.pagination;
|
|
1489
|
+
// }
|
|
1488
1490
|
|
|
1489
1491
|
const props = Object.assign(Object.assign(Object.assign({}, rest), this.state), {
|
|
1490
1492
|
// props not in rest
|
|
@@ -62,6 +62,7 @@ const getRenderText = function (originEle, rows) {
|
|
|
62
62
|
const lineHeight = pxToNumber(originStyle.lineHeight);
|
|
63
63
|
const maxHeight = Math.round(lineHeight * (rows + 1) + pxToNumber(originStyle.paddingTop) + pxToNumber(originStyle.paddingBottom)); // Set shadow
|
|
64
64
|
|
|
65
|
+
const maxWidth = parseInt(originStyle.width);
|
|
65
66
|
ellipsisContainer.setAttribute('style', originCSS);
|
|
66
67
|
ellipsisContainer.style.position = 'fixed';
|
|
67
68
|
ellipsisContainer.style.left = '0';
|
|
@@ -76,7 +77,10 @@ const getRenderText = function (originEle, rows) {
|
|
|
76
77
|
|
|
77
78
|
|
|
78
79
|
function inRange() {
|
|
79
|
-
|
|
80
|
+
if (originStyle.whiteSpace === 'nowrap') {
|
|
81
|
+
return ellipsisContainer.scrollWidth <= maxWidth;
|
|
82
|
+
}
|
|
83
|
+
|
|
80
84
|
return ellipsisContainer.scrollHeight < maxHeight;
|
|
81
85
|
} // ========================= Find match ellipsis content =========================
|
|
82
86
|
// Create origin content holder
|
package/lib/es/form/group.js
CHANGED
|
@@ -75,7 +75,7 @@ class FormInputGroup extends Component {
|
|
|
75
75
|
rest = __rest(_a, ["children", "label", "extraText", "extraTextPosition"]);
|
|
76
76
|
|
|
77
77
|
const updater = this.context;
|
|
78
|
-
const formProps = updater.getFormProps(['labelPosition', 'labelWidth', 'labelAlign', 'showValidateIcon', 'wrapperCol', 'labelCol']);
|
|
78
|
+
const formProps = updater.getFormProps(['labelPosition', 'labelWidth', 'labelAlign', 'showValidateIcon', 'wrapperCol', 'labelCol', 'disabled']);
|
|
79
79
|
const labelPosition = this.props.labelPosition || formProps.labelPosition;
|
|
80
80
|
const groupFieldSet = [];
|
|
81
81
|
const inner = React.Children.map(children, child => {
|
|
@@ -99,7 +99,9 @@ class FormInputGroup extends Component {
|
|
|
99
99
|
const appendCol = labelCol && wrapperCol;
|
|
100
100
|
const labelColCls = labelCol ? `${prefix}-col-${labelAlign}` : '';
|
|
101
101
|
const labelContent = this.renderLabel(label, formProps);
|
|
102
|
-
const inputGroupContent = /*#__PURE__*/React.createElement(InputGroup, Object.assign({
|
|
102
|
+
const inputGroupContent = /*#__PURE__*/React.createElement(InputGroup, Object.assign({
|
|
103
|
+
disabled: formProps.disabled
|
|
104
|
+
}, rest), inner);
|
|
103
105
|
const groupErrorContent = /*#__PURE__*/React.createElement(GroupError, {
|
|
104
106
|
fieldSet: groupFieldSet,
|
|
105
107
|
showValidateIcon: formProps.showValidateIcon,
|
package/lib/es/image/image.d.ts
CHANGED
|
@@ -29,8 +29,12 @@ export default class Image extends BaseComponent<ImageProps, ImageStates> {
|
|
|
29
29
|
get adapter(): ImageAdapter<ImageProps, ImageStates>;
|
|
30
30
|
context: PreviewContextProps;
|
|
31
31
|
foundation: ImageFoundation;
|
|
32
|
+
imgRef: React.RefObject<HTMLImageElement>;
|
|
32
33
|
constructor(props: ImageProps);
|
|
33
34
|
static getDerivedStateFromProps(props: ImageProps, state: ImageStates): Partial<ImageStates>;
|
|
35
|
+
componentDidMount(): void;
|
|
36
|
+
componentDidUpdate(prevProps: ImageProps, prevState: ImageStates): void;
|
|
37
|
+
observeImage(): void;
|
|
34
38
|
isInGroup(): boolean;
|
|
35
39
|
isLazyLoad(): boolean;
|
|
36
40
|
handleClick: (e: any) => void;
|
package/lib/es/image/image.js
CHANGED
|
@@ -129,6 +129,7 @@ export default class Image extends BaseComponent {
|
|
|
129
129
|
previewVisible: false
|
|
130
130
|
};
|
|
131
131
|
this.foundation = new ImageFoundation(this.adapter);
|
|
132
|
+
this.imgRef = /*#__PURE__*/React.createRef();
|
|
132
133
|
}
|
|
133
134
|
|
|
134
135
|
get adapter() {
|
|
@@ -158,6 +159,25 @@ export default class Image extends BaseComponent {
|
|
|
158
159
|
return willUpdateStates;
|
|
159
160
|
}
|
|
160
161
|
|
|
162
|
+
componentDidMount() {
|
|
163
|
+
this.observeImage();
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
componentDidUpdate(prevProps, prevState) {
|
|
167
|
+
prevProps.src !== this.props.src && this.observeImage();
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
observeImage() {
|
|
171
|
+
if (!this.isLazyLoad()) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const {
|
|
176
|
+
previewObserver
|
|
177
|
+
} = this.context;
|
|
178
|
+
previewObserver.observe(this.imgRef.current);
|
|
179
|
+
}
|
|
180
|
+
|
|
161
181
|
isInGroup() {
|
|
162
182
|
return Boolean(this.context && this.context.isGroup);
|
|
163
183
|
}
|
|
@@ -212,7 +232,9 @@ export default class Image extends BaseComponent {
|
|
|
212
232
|
style: outerStyle,
|
|
213
233
|
className: outerCls,
|
|
214
234
|
onClick: this.handleClick
|
|
215
|
-
}, /*#__PURE__*/React.createElement("img", Object.assign({
|
|
235
|
+
}, /*#__PURE__*/React.createElement("img", Object.assign({
|
|
236
|
+
ref: this.imgRef
|
|
237
|
+
}, restProps, {
|
|
216
238
|
src: this.isInGroup() && this.isLazyLoad() ? undefined : src,
|
|
217
239
|
"data-src": src,
|
|
218
240
|
alt: alt,
|
|
@@ -69,8 +69,8 @@ export default class Preview extends BaseComponent<PreviewProps, PreviewState> {
|
|
|
69
69
|
foundation: PreviewFoundation;
|
|
70
70
|
previewGroupId: string;
|
|
71
71
|
previewRef: React.RefObject<PreviewInner>;
|
|
72
|
+
previewObserver: IntersectionObserver;
|
|
72
73
|
constructor(props: any);
|
|
73
|
-
componentDidMount(): void;
|
|
74
74
|
static getDerivedStateFromProps(props: PreviewProps, state: PreviewState): Partial<PreviewState>;
|
|
75
75
|
handleVisibleChange: (newVisible: boolean) => void;
|
|
76
76
|
handleCurrentIndexChange: (index: number) => void;
|
package/lib/es/image/preview.js
CHANGED
|
@@ -93,19 +93,7 @@ export default class Preview extends BaseComponent {
|
|
|
93
93
|
length: 4
|
|
94
94
|
});
|
|
95
95
|
this.previewRef = /*#__PURE__*/React.createRef();
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
get adapter() {
|
|
99
|
-
return Object.assign({}, super.adapter);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
componentDidMount() {
|
|
103
|
-
const {
|
|
104
|
-
lazyLoadMargin
|
|
105
|
-
} = this.props;
|
|
106
|
-
const allElement = document.querySelectorAll(`.${prefixCls}-img`); // use IntersectionObserver to lazy load image
|
|
107
|
-
|
|
108
|
-
const observer = new IntersectionObserver(entries => {
|
|
96
|
+
this.previewObserver = new IntersectionObserver(entries => {
|
|
109
97
|
entries.forEach(item => {
|
|
110
98
|
var _a;
|
|
111
99
|
|
|
@@ -113,14 +101,18 @@ export default class Preview extends BaseComponent {
|
|
|
113
101
|
|
|
114
102
|
if (item.isIntersecting && src) {
|
|
115
103
|
item.target.src = src;
|
|
116
|
-
|
|
104
|
+
item.target.removeAttribute("data-src");
|
|
105
|
+
this.previewObserver.unobserve(item.target);
|
|
117
106
|
}
|
|
118
107
|
});
|
|
119
108
|
}, {
|
|
120
109
|
root: document.querySelector(`#${this.previewGroupId}`),
|
|
121
|
-
rootMargin: lazyLoadMargin
|
|
110
|
+
rootMargin: props.lazyLoadMargin
|
|
122
111
|
});
|
|
123
|
-
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
get adapter() {
|
|
115
|
+
return Object.assign({}, super.adapter);
|
|
124
116
|
}
|
|
125
117
|
|
|
126
118
|
static getDerivedStateFromProps(props, state) {
|
|
@@ -165,6 +157,7 @@ export default class Preview extends BaseComponent {
|
|
|
165
157
|
currentIndex,
|
|
166
158
|
visible,
|
|
167
159
|
lazyLoad,
|
|
160
|
+
previewObserver: this.previewObserver,
|
|
168
161
|
setCurrentIndex: this.handleCurrentIndexChange,
|
|
169
162
|
handleVisibleChange: this.handleVisibleChange
|
|
170
163
|
}
|
|
@@ -6,6 +6,7 @@ export interface PreviewContextProps {
|
|
|
6
6
|
titles: ReactNode[];
|
|
7
7
|
currentIndex: number;
|
|
8
8
|
visible: boolean;
|
|
9
|
+
previewObserver: IntersectionObserver;
|
|
9
10
|
setCurrentIndex: (current: number) => void;
|
|
10
11
|
handleVisibleChange: (visible: boolean, preVisible?: boolean) => void;
|
|
11
12
|
}
|
package/lib/es/table/Table.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import _isPlainObject from "lodash/isPlainObject";
|
|
1
2
|
import _isObject from "lodash/isObject";
|
|
2
3
|
import _isFunction from "lodash/isFunction";
|
|
3
4
|
import _difference from "lodash/difference";
|
|
4
|
-
import _isNull from "lodash/isNull";
|
|
5
5
|
import _omit from "lodash/omit";
|
|
6
6
|
import _each from "lodash/each";
|
|
7
7
|
import _flattenDeep from "lodash/flattenDeep";
|
|
@@ -835,6 +835,9 @@ class Table extends BaseComponent {
|
|
|
835
835
|
const columns = this.getColumns(props.columns, props.children);
|
|
836
836
|
const cachedflattenColumns = flattenColumns(columns);
|
|
837
837
|
const queries = TableFoundation.initColumnsFilteredValueAndSorterOrder(cloneDeep(cachedflattenColumns));
|
|
838
|
+
const filteredSortedDataSource = this.foundation.getFilteredSortedDataSource(this.props.dataSource, queries);
|
|
839
|
+
const newPagination = _isPlainObject(this.props.pagination) ? this.props.pagination : {};
|
|
840
|
+
const pageData = this.foundation.getCurrentPageData(filteredSortedDataSource, newPagination, queries);
|
|
838
841
|
this.state = {
|
|
839
842
|
/**
|
|
840
843
|
* Cached props
|
|
@@ -848,11 +851,11 @@ class Table extends BaseComponent {
|
|
|
848
851
|
* State calculated based on prop
|
|
849
852
|
*/
|
|
850
853
|
queries,
|
|
851
|
-
dataSource:
|
|
854
|
+
dataSource: pageData.dataSource,
|
|
852
855
|
flattenData: [],
|
|
853
856
|
expandedRowKeys: [...(props.expandedRowKeys || []), ...(props.defaultExpandedRowKeys || [])],
|
|
854
857
|
rowSelection: props.rowSelection ? _isObject(props.rowSelection) ? Object.assign({}, props.rowSelection) : {} : null,
|
|
855
|
-
pagination:
|
|
858
|
+
pagination: pageData.pagination,
|
|
856
859
|
|
|
857
860
|
/**
|
|
858
861
|
* Internal state
|
|
@@ -1436,12 +1439,11 @@ class Table extends BaseComponent {
|
|
|
1436
1439
|
* TODO: After merging issue 1007, you can place it in the constructor to complete
|
|
1437
1440
|
* The reason is that #1007 exposes the parameters required by getCurrentPageData in the constructor
|
|
1438
1441
|
*/
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
}
|
|
1442
|
+
// if (isNull(dataSource)) {
|
|
1443
|
+
// const pageData: BasePageData<RecordType> = this.foundation.getCurrentPageData(this.props.dataSource);
|
|
1444
|
+
// dataSource = pageData.dataSource;
|
|
1445
|
+
// pagination = pageData.pagination;
|
|
1446
|
+
// }
|
|
1445
1447
|
|
|
1446
1448
|
const props = Object.assign(Object.assign(Object.assign({}, rest), this.state), {
|
|
1447
1449
|
// props not in rest
|
|
@@ -51,6 +51,7 @@ const getRenderText = function (originEle, rows) {
|
|
|
51
51
|
const lineHeight = pxToNumber(originStyle.lineHeight);
|
|
52
52
|
const maxHeight = Math.round(lineHeight * (rows + 1) + pxToNumber(originStyle.paddingTop) + pxToNumber(originStyle.paddingBottom)); // Set shadow
|
|
53
53
|
|
|
54
|
+
const maxWidth = parseInt(originStyle.width);
|
|
54
55
|
ellipsisContainer.setAttribute('style', originCSS);
|
|
55
56
|
ellipsisContainer.style.position = 'fixed';
|
|
56
57
|
ellipsisContainer.style.left = '0';
|
|
@@ -64,7 +65,10 @@ const getRenderText = function (originEle, rows) {
|
|
|
64
65
|
ReactDOM.render( /*#__PURE__*/React.createElement(React.Fragment, null), ellipsisContainer); // Check if ellipsis in measure div is height enough for content
|
|
65
66
|
|
|
66
67
|
function inRange() {
|
|
67
|
-
|
|
68
|
+
if (originStyle.whiteSpace === 'nowrap') {
|
|
69
|
+
return ellipsisContainer.scrollWidth <= maxWidth;
|
|
70
|
+
}
|
|
71
|
+
|
|
68
72
|
return ellipsisContainer.scrollHeight < maxHeight;
|
|
69
73
|
} // ========================= Find match ellipsis content =========================
|
|
70
74
|
// Create origin content holder
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-ui",
|
|
3
|
-
"version": "2.34.0
|
|
3
|
+
"version": "2.34.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/es/index.js",
|
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
"lib/*"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@douyinfe/semi-animation": "2.34.0
|
|
21
|
-
"@douyinfe/semi-animation-react": "2.34.0
|
|
22
|
-
"@douyinfe/semi-foundation": "2.34.0
|
|
23
|
-
"@douyinfe/semi-icons": "2.34.0
|
|
24
|
-
"@douyinfe/semi-illustrations": "2.34.0
|
|
25
|
-
"@douyinfe/semi-theme-default": "2.34.0
|
|
20
|
+
"@douyinfe/semi-animation": "2.34.0",
|
|
21
|
+
"@douyinfe/semi-animation-react": "2.34.0",
|
|
22
|
+
"@douyinfe/semi-foundation": "2.34.0",
|
|
23
|
+
"@douyinfe/semi-icons": "2.34.0",
|
|
24
|
+
"@douyinfe/semi-illustrations": "2.34.0",
|
|
25
|
+
"@douyinfe/semi-theme-default": "2.34.0",
|
|
26
26
|
"async-validator": "^3.5.0",
|
|
27
27
|
"classnames": "^2.2.6",
|
|
28
28
|
"copy-text-to-clipboard": "^2.1.1",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
],
|
|
70
70
|
"author": "",
|
|
71
71
|
"license": "MIT",
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "2b01016b32a9da9a7e50424235dd5fc5c5fae3c2",
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@babel/plugin-proposal-decorators": "^7.15.8",
|
|
75
75
|
"@babel/plugin-transform-runtime": "^7.15.8",
|