@douyinfe/semi-ui 2.3.1 → 2.4.0-beta.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/css/semi.css +15 -9
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +52 -14
- 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/input/textarea.tsx +5 -3
- package/inputNumber/__test__/inputNumber.test.js +36 -8
- package/lib/cjs/input/textarea.js +4 -2
- package/lib/cjs/select/index.js +1 -1
- package/lib/cjs/table/Table.js +9 -5
- package/lib/cjs/timePicker/TimePicker.d.ts +2 -0
- package/lib/cjs/timePicker/TimePicker.js +2 -3
- package/lib/cjs/timePicker/index.d.ts +1 -0
- package/lib/cjs/tree/treeNode.js +10 -1
- package/lib/es/input/textarea.js +4 -2
- package/lib/es/select/index.js +1 -1
- package/lib/es/table/Table.js +9 -5
- package/lib/es/timePicker/TimePicker.d.ts +2 -0
- package/lib/es/timePicker/TimePicker.js +2 -3
- package/lib/es/timePicker/index.d.ts +1 -0
- package/lib/es/tree/treeNode.js +9 -1
- package/package.json +8 -8
- package/select/index.tsx +6 -1
- package/table/Table.tsx +9 -6
- package/table/_story/table.stories.js +2 -0
- package/table/_story/v2/FixedColumnsChange/index.jsx +104 -0
- package/table/_story/v2/FixedZIndex/index.jsx +87 -0
- package/timePicker/TimePicker.tsx +3 -1
- package/timePicker/__test__/timePicker.test.js +34 -3
- package/timePicker/_story/timepicker.stories.js +18 -0
- package/tree/treeNode.tsx +9 -2
package/input/textarea.tsx
CHANGED
|
@@ -295,7 +295,8 @@ class TextArea extends BaseComponent<TextAreaProps, TextAreaState> {
|
|
|
295
295
|
className,
|
|
296
296
|
`${prefixCls}-textarea-wrapper`,
|
|
297
297
|
{
|
|
298
|
-
[`${prefixCls}-textarea-wrapper-disabled`]: disabled
|
|
298
|
+
[`${prefixCls}-textarea-wrapper-disabled`]: disabled,
|
|
299
|
+
[`${prefixCls}-textarea-wrapper-readonly`]: readonly,
|
|
299
300
|
[`${prefixCls}-textarea-wrapper-${validateStatus}`]: Boolean(validateStatus),
|
|
300
301
|
[`${prefixCls}-textarea-wrapper-focus`]: isFocus,
|
|
301
302
|
// [`${prefixCls}-textarea-wrapper-resize`]: !autosize && resize,
|
|
@@ -305,7 +306,8 @@ class TextArea extends BaseComponent<TextAreaProps, TextAreaState> {
|
|
|
305
306
|
const itemCls = cls(
|
|
306
307
|
`${prefixCls}-textarea`,
|
|
307
308
|
{
|
|
308
|
-
[`${prefixCls}-textarea-disabled`]: disabled
|
|
309
|
+
[`${prefixCls}-textarea-disabled`]: disabled,
|
|
310
|
+
[`${prefixCls}-textarea-readonly`]: readonly,
|
|
309
311
|
[`${prefixCls}-textarea-autosize`]: autosize,
|
|
310
312
|
[`${prefixCls}-textarea-showClear`]: showClear,
|
|
311
313
|
}
|
|
@@ -346,4 +348,4 @@ class TextArea extends BaseComponent<TextAreaProps, TextAreaState> {
|
|
|
346
348
|
|
|
347
349
|
const ForwardTextarea = React.forwardRef<HTMLTextAreaElement, Omit<TextAreaProps, 'forwardRef'>>((props, ref) => <TextArea {...props} forwardRef={ref} />);
|
|
348
350
|
|
|
349
|
-
export default ForwardTextarea;
|
|
351
|
+
export default ForwardTextarea;
|
|
@@ -5,6 +5,7 @@ import sinon from 'sinon';
|
|
|
5
5
|
import keyCode from '@douyinfe/semi-foundation/utils/keyCode';
|
|
6
6
|
import * as _ from 'lodash';
|
|
7
7
|
import { BASE_CLASS_PREFIX } from '../../../semi-foundation/base/constants';
|
|
8
|
+
import { numbers } from '@douyinfe/semi-foundation/inputNumber/constants';
|
|
8
9
|
import { Form, withField } from '../../index';
|
|
9
10
|
|
|
10
11
|
const log = (...args) => console.log(...args);
|
|
@@ -216,8 +217,8 @@ describe(`InputNumber`, () => {
|
|
|
216
217
|
const addCount = 3;
|
|
217
218
|
const minusCount = 1;
|
|
218
219
|
|
|
219
|
-
_.times(addCount, () => addBtn.simulate('mousedown'));
|
|
220
|
-
_.times(minusCount, () => minusBtn.simulate('mousedown'));
|
|
220
|
+
_.times(addCount, () => addBtn.simulate('mousedown', { button: numbers.MOUSE_BUTTON_LEFT }));
|
|
221
|
+
_.times(minusCount, () => minusBtn.simulate('mousedown', { button: numbers.MOUSE_BUTTON_LEFT }));
|
|
221
222
|
|
|
222
223
|
expect(inputElem.instance().value).toBe(String(defaultValue + addCount - minusCount));
|
|
223
224
|
expect(onUpClick.called).toBe(true);
|
|
@@ -243,8 +244,8 @@ describe(`InputNumber`, () => {
|
|
|
243
244
|
const addCount = 3;
|
|
244
245
|
const minusCount = 1;
|
|
245
246
|
|
|
246
|
-
_.times(addCount, () => addBtn.simulate('mousedown'));
|
|
247
|
-
_.times(minusCount, () => minusBtn.simulate('mousedown'));
|
|
247
|
+
_.times(addCount, () => addBtn.simulate('mousedown', { button: numbers.MOUSE_BUTTON_LEFT }));
|
|
248
|
+
_.times(minusCount, () => minusBtn.simulate('mousedown', { button: numbers.MOUSE_BUTTON_LEFT }));
|
|
248
249
|
|
|
249
250
|
expect(inputElem.instance().value).toBe(String(defaultValue + addCount - minusCount));
|
|
250
251
|
expect(onUpClick.called).toBe(true);
|
|
@@ -283,9 +284,9 @@ describe(`InputNumber`, () => {
|
|
|
283
284
|
// click button focus
|
|
284
285
|
const addCount = 3;
|
|
285
286
|
const minusCount = 1;
|
|
286
|
-
_.times(addCount, () => addBtn.simulate('mousedown'));
|
|
287
|
+
_.times(addCount, () => addBtn.simulate('mousedown', { button: numbers.MOUSE_BUTTON_LEFT }));
|
|
287
288
|
_.times(addCount, () => addBtn.simulate('mouseup'));
|
|
288
|
-
_.times(minusCount, () => minusBtn.simulate('mousedown'));
|
|
289
|
+
_.times(minusCount, () => minusBtn.simulate('mousedown', { button: numbers.MOUSE_BUTTON_LEFT }));
|
|
289
290
|
_.times(minusCount, () => minusBtn.simulate('mouseup'));
|
|
290
291
|
expect(inputElem.instance().value).toBe(String(defaultValue + addCount - minusCount));
|
|
291
292
|
expect(inputNumber.find(BaseInputNumber).state('focusing')).toBeTruthy();
|
|
@@ -338,7 +339,7 @@ describe(`InputNumber`, () => {
|
|
|
338
339
|
const btns = inputNumber.find(`.${BASE_CLASS_PREFIX}-input-number-suffix-btns .${BASE_CLASS_PREFIX}-input-number-button`);
|
|
339
340
|
const inputElem = inputNumber.find('input');
|
|
340
341
|
const addBtn = btns.first();
|
|
341
|
-
addBtn.simulate('mousedown');
|
|
342
|
+
addBtn.simulate('mousedown', { button: numbers.MOUSE_BUTTON_LEFT });
|
|
342
343
|
expect(inputElem.instance().value).toBe("1");
|
|
343
344
|
})
|
|
344
345
|
|
|
@@ -366,5 +367,32 @@ describe(`InputNumber`, () => {
|
|
|
366
367
|
inputElem.simulate('change', newEvent);
|
|
367
368
|
expect(onNumberChange.calledOnce).toBe(true);
|
|
368
369
|
expect(inputElem.instance().value).toBe('123');
|
|
369
|
-
})
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* test buttons right click
|
|
374
|
+
*/
|
|
375
|
+
it(`right click add/minus button`, async () => {
|
|
376
|
+
const defaultValue = 1000;
|
|
377
|
+
const onUpClick = sinon.spy();
|
|
378
|
+
const onDownClick = sinon.spy();
|
|
379
|
+
const MOUSE_BUTTON_RIGHT = 2;
|
|
380
|
+
|
|
381
|
+
const inputNumber = mount(
|
|
382
|
+
<InputNumber defaultValue={defaultValue} onUpClick={onUpClick} onDownClick={onDownClick} />
|
|
383
|
+
);
|
|
384
|
+
const inputElem = inputNumber.find('input');
|
|
385
|
+
|
|
386
|
+
const btns = inputNumber.find(`.${BASE_CLASS_PREFIX}-input-number-suffix-btns .${BASE_CLASS_PREFIX}-input-number-button`);
|
|
387
|
+
|
|
388
|
+
const addBtn = btns.first();
|
|
389
|
+
const minusBtn = btns.last();
|
|
390
|
+
|
|
391
|
+
_.times(1, () => addBtn.simulate('mousedown', { button: MOUSE_BUTTON_RIGHT }));
|
|
392
|
+
_.times(3, () => minusBtn.simulate('mousedown', { button: MOUSE_BUTTON_RIGHT }));
|
|
393
|
+
|
|
394
|
+
expect(inputElem.instance().value).toBe(String(defaultValue));
|
|
395
|
+
expect(onUpClick.called).toBe(false);
|
|
396
|
+
expect(onDownClick.called).toBe(false);
|
|
397
|
+
});
|
|
370
398
|
});
|
|
@@ -267,14 +267,16 @@ class TextArea extends _baseComponent.default {
|
|
|
267
267
|
minLength: stateMinLength
|
|
268
268
|
} = this.state;
|
|
269
269
|
const wrapperCls = (0, _classnames.default)(className, "".concat(prefixCls, "-textarea-wrapper"), {
|
|
270
|
-
["".concat(prefixCls, "-textarea-wrapper-disabled")]: disabled
|
|
270
|
+
["".concat(prefixCls, "-textarea-wrapper-disabled")]: disabled,
|
|
271
|
+
["".concat(prefixCls, "-textarea-wrapper-readonly")]: readonly,
|
|
271
272
|
[(0, _concat.default)(_context = "".concat(prefixCls, "-textarea-wrapper-")).call(_context, validateStatus)]: Boolean(validateStatus),
|
|
272
273
|
["".concat(prefixCls, "-textarea-wrapper-focus")]: isFocus // [`${prefixCls}-textarea-wrapper-resize`]: !autosize && resize,
|
|
273
274
|
|
|
274
275
|
}); // const ref = this.props.forwardRef || this.textAreaRef;
|
|
275
276
|
|
|
276
277
|
const itemCls = (0, _classnames.default)("".concat(prefixCls, "-textarea"), {
|
|
277
|
-
["".concat(prefixCls, "-textarea-disabled")]: disabled
|
|
278
|
+
["".concat(prefixCls, "-textarea-disabled")]: disabled,
|
|
279
|
+
["".concat(prefixCls, "-textarea-readonly")]: readonly,
|
|
278
280
|
["".concat(prefixCls, "-textarea-autosize")]: autosize,
|
|
279
281
|
["".concat(prefixCls, "-textarea-showClear")]: showClear
|
|
280
282
|
});
|
package/lib/cjs/select/index.js
CHANGED
|
@@ -563,7 +563,7 @@ class Select extends _baseComponent.default {
|
|
|
563
563
|
role: "button",
|
|
564
564
|
"aria-label": "Use the input box to create an optional item",
|
|
565
565
|
onClick: e => this.onSelect(option, optionIndex, e),
|
|
566
|
-
key:
|
|
566
|
+
key: option.key || option.label
|
|
567
567
|
}, customCreateItem)
|
|
568
568
|
);
|
|
569
569
|
}
|
package/lib/cjs/table/Table.js
CHANGED
|
@@ -1294,15 +1294,18 @@ class Table extends _baseComponent.default {
|
|
|
1294
1294
|
const _dataSource = [...dataSource];
|
|
1295
1295
|
const filteredSortedDataSource = this.foundation.getFilteredSortedDataSource(_dataSource, stateQueries);
|
|
1296
1296
|
this.foundation.setCachedFilteredSortedDataSource(filteredSortedDataSource);
|
|
1297
|
-
states.dataSource = filteredSortedDataSource;
|
|
1298
|
-
|
|
1299
|
-
states.pagination = (0, _isObject2.default)(statePagination) ? (0, _assign.default)((0, _assign.default)({}, statePagination), {
|
|
1300
|
-
currentPage: (0, _isObject2.default)(propsPagination) && propsPagination.currentPage ? propsPagination.currentPage : 1
|
|
1301
|
-
}) : statePagination;
|
|
1297
|
+
states.dataSource = filteredSortedDataSource;
|
|
1302
1298
|
|
|
1303
1299
|
if (this.props.groupBy) {
|
|
1304
1300
|
states.groups = null;
|
|
1305
1301
|
}
|
|
1302
|
+
} // when dataSource has change, should reset currentPage
|
|
1303
|
+
|
|
1304
|
+
|
|
1305
|
+
if (dataSource !== prevProps.dataSource) {
|
|
1306
|
+
states.pagination = (0, _isObject2.default)(statePagination) ? (0, _assign.default)((0, _assign.default)({}, statePagination), {
|
|
1307
|
+
currentPage: (0, _isObject2.default)(propsPagination) && propsPagination.currentPage ? propsPagination.currentPage : 1
|
|
1308
|
+
}) : statePagination;
|
|
1306
1309
|
}
|
|
1307
1310
|
|
|
1308
1311
|
if ((0, _keys.default)(states).length) {
|
|
@@ -1484,6 +1487,7 @@ class Table extends _baseComponent.default {
|
|
|
1484
1487
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
1485
1488
|
ref: this.rootWrapRef,
|
|
1486
1489
|
className: (0, _classnames.default)(className, "".concat(prefixCls, "-wrapper")),
|
|
1490
|
+
"data-column-fixed": anyColumnFixed,
|
|
1487
1491
|
style: wrapStyle,
|
|
1488
1492
|
id: id
|
|
1489
1493
|
}, /*#__PURE__*/_react.default.createElement(_TableContextProvider.default, (0, _assign.default)({}, tableContextValue), /*#__PURE__*/_react.default.createElement(_spin.default, {
|
|
@@ -69,6 +69,7 @@ export declare type TimePickerProps = {
|
|
|
69
69
|
zIndex?: number | string;
|
|
70
70
|
onBlur?: React.FocusEventHandler<HTMLInputElement>;
|
|
71
71
|
onChange?: TimePickerAdapter['notifyChange'];
|
|
72
|
+
onChangeWithDateFirst?: boolean;
|
|
72
73
|
onFocus?: React.FocusEventHandler<HTMLInputElement>;
|
|
73
74
|
onOpenChange?: (open: boolean) => void;
|
|
74
75
|
};
|
|
@@ -169,6 +170,7 @@ export default class TimePicker extends BaseComponent<TimePickerProps, TimePicke
|
|
|
169
170
|
onFocus: (...args: any[]) => void;
|
|
170
171
|
onBlur: (...args: any[]) => void;
|
|
171
172
|
onChange: (...args: any[]) => void;
|
|
173
|
+
onChangeWithDateFirst: boolean;
|
|
172
174
|
use12Hours: boolean;
|
|
173
175
|
focusOnOpen: boolean;
|
|
174
176
|
onKeyDown: (...args: any[]) => void;
|
|
@@ -183,9 +183,7 @@ class TimePicker extends _baseComponent.default {
|
|
|
183
183
|
notifyOpenChange: function () {
|
|
184
184
|
return _this2.props.onOpenChange(...arguments);
|
|
185
185
|
},
|
|
186
|
-
notifyChange:
|
|
187
|
-
return _this2.props.onChange && _this2.props.onChange(...arguments);
|
|
188
|
-
},
|
|
186
|
+
notifyChange: (agr1, arg2) => this.props.onChange && this.props.onChange(agr1, arg2),
|
|
189
187
|
notifyFocus: function () {
|
|
190
188
|
return _this2.props.onFocus && _this2.props.onFocus(...arguments);
|
|
191
189
|
},
|
|
@@ -503,6 +501,7 @@ TimePicker.defaultProps = (0, _assign.default)({
|
|
|
503
501
|
onFocus: _noop2.default,
|
|
504
502
|
onBlur: _noop2.default,
|
|
505
503
|
onChange: _noop2.default,
|
|
504
|
+
onChangeWithDateFirst: true,
|
|
506
505
|
use12Hours: false,
|
|
507
506
|
focusOnOpen: false,
|
|
508
507
|
onKeyDown: _noop2.default,
|
|
@@ -91,6 +91,7 @@ export default class LocaleTimePicker extends React.PureComponent<LocalePickerPr
|
|
|
91
91
|
onFocus: (...args: any[]) => void;
|
|
92
92
|
onBlur: (...args: any[]) => void;
|
|
93
93
|
onChange: (...args: any[]) => void;
|
|
94
|
+
onChangeWithDateFirst: boolean;
|
|
94
95
|
use12Hours: boolean;
|
|
95
96
|
focusOnOpen: boolean;
|
|
96
97
|
onKeyDown: (...args: any[]) => void;
|
package/lib/cjs/tree/treeNode.js
CHANGED
|
@@ -24,6 +24,8 @@ var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-st
|
|
|
24
24
|
|
|
25
25
|
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
|
26
26
|
|
|
27
|
+
var _isEmpty2 = _interopRequireDefault(require("lodash/isEmpty"));
|
|
28
|
+
|
|
27
29
|
var _get2 = _interopRequireDefault(require("lodash/get"));
|
|
28
30
|
|
|
29
31
|
var _isString2 = _interopRequireDefault(require("lodash/isString"));
|
|
@@ -506,7 +508,14 @@ class TreeNode extends _react.PureComponent {
|
|
|
506
508
|
ref: this.setRef
|
|
507
509
|
}, dragProps));
|
|
508
510
|
} else {
|
|
509
|
-
|
|
511
|
+
if ((0, _isEmpty2.default)(style)) {
|
|
512
|
+
return customLabel;
|
|
513
|
+
} else {
|
|
514
|
+
// In virtualization, props.style will contain location information
|
|
515
|
+
return /*#__PURE__*/_react.default.cloneElement(customLabel, {
|
|
516
|
+
style: (0, _assign.default)((0, _assign.default)({}, (0, _get2.default)(customLabel, ['props', 'style'])), style)
|
|
517
|
+
});
|
|
518
|
+
}
|
|
510
519
|
}
|
|
511
520
|
}
|
|
512
521
|
|
package/lib/es/input/textarea.js
CHANGED
|
@@ -241,14 +241,16 @@ class TextArea extends BaseComponent {
|
|
|
241
241
|
minLength: stateMinLength
|
|
242
242
|
} = this.state;
|
|
243
243
|
const wrapperCls = cls(className, "".concat(prefixCls, "-textarea-wrapper"), {
|
|
244
|
-
["".concat(prefixCls, "-textarea-wrapper-disabled")]: disabled
|
|
244
|
+
["".concat(prefixCls, "-textarea-wrapper-disabled")]: disabled,
|
|
245
|
+
["".concat(prefixCls, "-textarea-wrapper-readonly")]: readonly,
|
|
245
246
|
[_concatInstanceProperty(_context = "".concat(prefixCls, "-textarea-wrapper-")).call(_context, validateStatus)]: Boolean(validateStatus),
|
|
246
247
|
["".concat(prefixCls, "-textarea-wrapper-focus")]: isFocus // [`${prefixCls}-textarea-wrapper-resize`]: !autosize && resize,
|
|
247
248
|
|
|
248
249
|
}); // const ref = this.props.forwardRef || this.textAreaRef;
|
|
249
250
|
|
|
250
251
|
const itemCls = cls("".concat(prefixCls, "-textarea"), {
|
|
251
|
-
["".concat(prefixCls, "-textarea-disabled")]: disabled
|
|
252
|
+
["".concat(prefixCls, "-textarea-disabled")]: disabled,
|
|
253
|
+
["".concat(prefixCls, "-textarea-readonly")]: readonly,
|
|
252
254
|
["".concat(prefixCls, "-textarea-autosize")]: autosize,
|
|
253
255
|
["".concat(prefixCls, "-textarea-showClear")]: showClear
|
|
254
256
|
});
|
package/lib/es/select/index.js
CHANGED
|
@@ -506,7 +506,7 @@ class Select extends BaseComponent {
|
|
|
506
506
|
role: "button",
|
|
507
507
|
"aria-label": "Use the input box to create an optional item",
|
|
508
508
|
onClick: e => this.onSelect(option, optionIndex, e),
|
|
509
|
-
key:
|
|
509
|
+
key: option.key || option.label
|
|
510
510
|
}, customCreateItem)
|
|
511
511
|
);
|
|
512
512
|
}
|
package/lib/es/table/Table.js
CHANGED
|
@@ -1238,15 +1238,18 @@ class Table extends BaseComponent {
|
|
|
1238
1238
|
const _dataSource = [...dataSource];
|
|
1239
1239
|
const filteredSortedDataSource = this.foundation.getFilteredSortedDataSource(_dataSource, stateQueries);
|
|
1240
1240
|
this.foundation.setCachedFilteredSortedDataSource(filteredSortedDataSource);
|
|
1241
|
-
states.dataSource = filteredSortedDataSource;
|
|
1242
|
-
|
|
1243
|
-
states.pagination = _isObject(statePagination) ? _Object$assign(_Object$assign({}, statePagination), {
|
|
1244
|
-
currentPage: _isObject(propsPagination) && propsPagination.currentPage ? propsPagination.currentPage : 1
|
|
1245
|
-
}) : statePagination;
|
|
1241
|
+
states.dataSource = filteredSortedDataSource;
|
|
1246
1242
|
|
|
1247
1243
|
if (this.props.groupBy) {
|
|
1248
1244
|
states.groups = null;
|
|
1249
1245
|
}
|
|
1246
|
+
} // when dataSource has change, should reset currentPage
|
|
1247
|
+
|
|
1248
|
+
|
|
1249
|
+
if (dataSource !== prevProps.dataSource) {
|
|
1250
|
+
states.pagination = _isObject(statePagination) ? _Object$assign(_Object$assign({}, statePagination), {
|
|
1251
|
+
currentPage: _isObject(propsPagination) && propsPagination.currentPage ? propsPagination.currentPage : 1
|
|
1252
|
+
}) : statePagination;
|
|
1250
1253
|
}
|
|
1251
1254
|
|
|
1252
1255
|
if (_Object$keys(states).length) {
|
|
@@ -1433,6 +1436,7 @@ class Table extends BaseComponent {
|
|
|
1433
1436
|
return /*#__PURE__*/React.createElement("div", {
|
|
1434
1437
|
ref: this.rootWrapRef,
|
|
1435
1438
|
className: classnames(className, "".concat(prefixCls, "-wrapper")),
|
|
1439
|
+
"data-column-fixed": anyColumnFixed,
|
|
1436
1440
|
style: wrapStyle,
|
|
1437
1441
|
id: id
|
|
1438
1442
|
}, /*#__PURE__*/React.createElement(TableContextProvider, _Object$assign({}, tableContextValue), /*#__PURE__*/React.createElement(Spin, {
|
|
@@ -69,6 +69,7 @@ export declare type TimePickerProps = {
|
|
|
69
69
|
zIndex?: number | string;
|
|
70
70
|
onBlur?: React.FocusEventHandler<HTMLInputElement>;
|
|
71
71
|
onChange?: TimePickerAdapter['notifyChange'];
|
|
72
|
+
onChangeWithDateFirst?: boolean;
|
|
72
73
|
onFocus?: React.FocusEventHandler<HTMLInputElement>;
|
|
73
74
|
onOpenChange?: (open: boolean) => void;
|
|
74
75
|
};
|
|
@@ -169,6 +170,7 @@ export default class TimePicker extends BaseComponent<TimePickerProps, TimePicke
|
|
|
169
170
|
onFocus: (...args: any[]) => void;
|
|
170
171
|
onBlur: (...args: any[]) => void;
|
|
171
172
|
onChange: (...args: any[]) => void;
|
|
173
|
+
onChangeWithDateFirst: boolean;
|
|
172
174
|
use12Hours: boolean;
|
|
173
175
|
focusOnOpen: boolean;
|
|
174
176
|
onKeyDown: (...args: any[]) => void;
|
|
@@ -149,9 +149,7 @@ export default class TimePicker extends BaseComponent {
|
|
|
149
149
|
notifyOpenChange: function () {
|
|
150
150
|
return _this2.props.onOpenChange(...arguments);
|
|
151
151
|
},
|
|
152
|
-
notifyChange:
|
|
153
|
-
return _this2.props.onChange && _this2.props.onChange(...arguments);
|
|
154
|
-
},
|
|
152
|
+
notifyChange: (agr1, arg2) => this.props.onChange && this.props.onChange(agr1, arg2),
|
|
155
153
|
notifyFocus: function () {
|
|
156
154
|
return _this2.props.onFocus && _this2.props.onFocus(...arguments);
|
|
157
155
|
},
|
|
@@ -469,6 +467,7 @@ TimePicker.defaultProps = _Object$assign({
|
|
|
469
467
|
onFocus: _noop,
|
|
470
468
|
onBlur: _noop,
|
|
471
469
|
onChange: _noop,
|
|
470
|
+
onChangeWithDateFirst: true,
|
|
472
471
|
use12Hours: false,
|
|
473
472
|
focusOnOpen: false,
|
|
474
473
|
onKeyDown: _noop,
|
|
@@ -91,6 +91,7 @@ export default class LocaleTimePicker extends React.PureComponent<LocalePickerPr
|
|
|
91
91
|
onFocus: (...args: any[]) => void;
|
|
92
92
|
onBlur: (...args: any[]) => void;
|
|
93
93
|
onChange: (...args: any[]) => void;
|
|
94
|
+
onChangeWithDateFirst: boolean;
|
|
94
95
|
use12Hours: boolean;
|
|
95
96
|
focusOnOpen: boolean;
|
|
96
97
|
onKeyDown: (...args: any[]) => void;
|
package/lib/es/tree/treeNode.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _isEmpty from "lodash/isEmpty";
|
|
1
2
|
import _get from "lodash/get";
|
|
2
3
|
import _isString from "lodash/isString";
|
|
3
4
|
import _isFunction from "lodash/isFunction";
|
|
@@ -470,7 +471,14 @@ export default class TreeNode extends PureComponent {
|
|
|
470
471
|
ref: this.setRef
|
|
471
472
|
}, dragProps));
|
|
472
473
|
} else {
|
|
473
|
-
|
|
474
|
+
if (_isEmpty(style)) {
|
|
475
|
+
return customLabel;
|
|
476
|
+
} else {
|
|
477
|
+
// In virtualization, props.style will contain location information
|
|
478
|
+
return /*#__PURE__*/React.cloneElement(customLabel, {
|
|
479
|
+
style: _Object$assign(_Object$assign({}, _get(customLabel, ['props', 'style'])), style)
|
|
480
|
+
});
|
|
481
|
+
}
|
|
474
482
|
}
|
|
475
483
|
}
|
|
476
484
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-ui",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0-beta.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/es/index.js",
|
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@babel/runtime-corejs3": "^7.15.4",
|
|
17
|
-
"@douyinfe/semi-animation-react": "2.
|
|
18
|
-
"@douyinfe/semi-foundation": "2.
|
|
19
|
-
"@douyinfe/semi-icons": "2.
|
|
20
|
-
"@douyinfe/semi-illustrations": "2.
|
|
21
|
-
"@douyinfe/semi-theme-default": "2.
|
|
17
|
+
"@douyinfe/semi-animation-react": "2.4.0-beta.0",
|
|
18
|
+
"@douyinfe/semi-foundation": "2.4.0-beta.0",
|
|
19
|
+
"@douyinfe/semi-icons": "2.4.0-beta.0",
|
|
20
|
+
"@douyinfe/semi-illustrations": "2.4.0-beta.0",
|
|
21
|
+
"@douyinfe/semi-theme-default": "2.4.0-beta.0",
|
|
22
22
|
"@types/react-window": "^1.8.2",
|
|
23
23
|
"async-validator": "^3.5.0",
|
|
24
24
|
"classnames": "^2.2.6",
|
|
@@ -68,13 +68,13 @@
|
|
|
68
68
|
],
|
|
69
69
|
"author": "",
|
|
70
70
|
"license": "MIT",
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "ebf8a78f5152f9733af771cd567f042eccb8c4b9",
|
|
72
72
|
"devDependencies": {
|
|
73
73
|
"@babel/plugin-proposal-decorators": "^7.15.8",
|
|
74
74
|
"@babel/plugin-transform-runtime": "^7.15.8",
|
|
75
75
|
"@babel/preset-env": "^7.15.8",
|
|
76
76
|
"@babel/preset-react": "^7.14.5",
|
|
77
|
-
"@douyinfe/semi-scss-compile": "2.
|
|
77
|
+
"@douyinfe/semi-scss-compile": "2.4.0-beta.0",
|
|
78
78
|
"@storybook/addon-knobs": "^6.3.1",
|
|
79
79
|
"@types/lodash": "^4.14.176",
|
|
80
80
|
"babel-loader": "^8.2.2",
|
package/select/index.tsx
CHANGED
|
@@ -739,7 +739,12 @@ class Select extends BaseComponent<SelectProps, SelectState> {
|
|
|
739
739
|
|
|
740
740
|
return (
|
|
741
741
|
// eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/interactive-supports-focus
|
|
742
|
-
<div
|
|
742
|
+
<div
|
|
743
|
+
role="button"
|
|
744
|
+
aria-label="Use the input box to create an optional item"
|
|
745
|
+
onClick={e => this.onSelect(option, optionIndex, e)}
|
|
746
|
+
key={option.key || option.label}
|
|
747
|
+
>
|
|
743
748
|
{customCreateItem}
|
|
744
749
|
</div>
|
|
745
750
|
);
|
package/table/Table.tsx
CHANGED
|
@@ -534,7 +534,6 @@ class Table<RecordType extends Record<string, any>> extends BaseComponent<Normal
|
|
|
534
534
|
this.foundation.initExpandedRowKeys({ groups: stateGroups });
|
|
535
535
|
}
|
|
536
536
|
|
|
537
|
-
|
|
538
537
|
/**
|
|
539
538
|
* After dataSource is updated || (cachedColumns || cachedChildren updated)
|
|
540
539
|
* 1. Cache filtered sorted data and a collection of data rows, stored in this
|
|
@@ -547,17 +546,20 @@ class Table<RecordType extends Record<string, any>> extends BaseComponent<Normal
|
|
|
547
546
|
const filteredSortedDataSource = this.foundation.getFilteredSortedDataSource(_dataSource, stateQueries);
|
|
548
547
|
this.foundation.setCachedFilteredSortedDataSource(filteredSortedDataSource);
|
|
549
548
|
states.dataSource = filteredSortedDataSource;
|
|
550
|
-
// when dataSource has change, should reset currentPage
|
|
551
|
-
states.pagination = isObject(statePagination) ? {
|
|
552
|
-
...statePagination,
|
|
553
|
-
currentPage: isObject(propsPagination) && propsPagination.currentPage ? propsPagination.currentPage : 1,
|
|
554
|
-
} : statePagination;
|
|
555
549
|
|
|
556
550
|
if (this.props.groupBy) {
|
|
557
551
|
states.groups = null;
|
|
558
552
|
}
|
|
559
553
|
}
|
|
560
554
|
|
|
555
|
+
// when dataSource has change, should reset currentPage
|
|
556
|
+
if (dataSource !== prevProps.dataSource) {
|
|
557
|
+
states.pagination = isObject(statePagination) ? {
|
|
558
|
+
...statePagination,
|
|
559
|
+
currentPage: isObject(propsPagination) && propsPagination.currentPage ? propsPagination.currentPage : 1,
|
|
560
|
+
} : statePagination;
|
|
561
|
+
}
|
|
562
|
+
|
|
561
563
|
if (Object.keys(states).length) {
|
|
562
564
|
const {
|
|
563
565
|
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
@@ -1372,6 +1374,7 @@ class Table<RecordType extends Record<string, any>> extends BaseComponent<Normal
|
|
|
1372
1374
|
<div
|
|
1373
1375
|
ref={this.rootWrapRef}
|
|
1374
1376
|
className={classnames(className, `${prefixCls}-wrapper`)}
|
|
1377
|
+
data-column-fixed={anyColumnFixed}
|
|
1375
1378
|
style={wrapStyle}
|
|
1376
1379
|
id={id}
|
|
1377
1380
|
>
|
|
@@ -76,6 +76,8 @@ export { default as ScrollBar } from './ScrollBar';
|
|
|
76
76
|
export { default as TableSpan } from './TableSpan';
|
|
77
77
|
export { default as FixRenderReturnProps } from './FixRenderReturnProps';
|
|
78
78
|
export { default as WarnColumnWithoutDataIndex } from './WarnColumnWithoutDataIndex';
|
|
79
|
+
export { default as FixedColumnsChange } from './v2/FixedColumnsChange';
|
|
80
|
+
export { default as FixedZIndex } from './v2/FixedZIndex';
|
|
79
81
|
|
|
80
82
|
// empty table
|
|
81
83
|
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import React, { useState, useMemo } from 'react';
|
|
2
|
+
import { Table, Avatar } from '@douyinfe/semi-ui';
|
|
3
|
+
import * as dateFns from 'date-fns';
|
|
4
|
+
|
|
5
|
+
const DAY = 24 * 60 * 60 * 1000;
|
|
6
|
+
const figmaIconUrl = 'https://lf3-static.bytednsdoc.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/figma-icon.png';
|
|
7
|
+
|
|
8
|
+
const getData = () => {
|
|
9
|
+
const data = [];
|
|
10
|
+
for (let i = 0; i < 46; i++) {
|
|
11
|
+
const isSemiDesign = i % 2 === 0;
|
|
12
|
+
const randomNumber = (i * 1000) % 199;
|
|
13
|
+
data.push({
|
|
14
|
+
key: '' + i,
|
|
15
|
+
name: isSemiDesign ? `Semi Design 设计稿${i}.fig` : `Semi Pro 设计稿${i}.fig`,
|
|
16
|
+
owner: isSemiDesign ? '姜鹏志' : '郝宣',
|
|
17
|
+
size: randomNumber,
|
|
18
|
+
updateTime: new Date().valueOf() + randomNumber * DAY,
|
|
19
|
+
avatarBg: isSemiDesign ? 'grey' : 'red'
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return data;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const data = getData();
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* fix https://github.com/DouyinFE/semi-design/issues/381
|
|
29
|
+
*/
|
|
30
|
+
App.storyName = 'fixed columns change';
|
|
31
|
+
function App() {
|
|
32
|
+
const [dataSource, setData] = useState(data);
|
|
33
|
+
const [rowKeys, setRowKeys] = useState([]);
|
|
34
|
+
|
|
35
|
+
const columns = [
|
|
36
|
+
{
|
|
37
|
+
title: '标题',
|
|
38
|
+
dataIndex: 'name',
|
|
39
|
+
width: 400,
|
|
40
|
+
render: (text, record, index) => {
|
|
41
|
+
return (
|
|
42
|
+
<div>
|
|
43
|
+
<Avatar size="small" shape="square" src={figmaIconUrl} style={{ marginRight: 12 }}></Avatar>
|
|
44
|
+
{text}
|
|
45
|
+
</div>
|
|
46
|
+
);
|
|
47
|
+
},
|
|
48
|
+
filters: [
|
|
49
|
+
{
|
|
50
|
+
text: 'Semi Design 设计稿',
|
|
51
|
+
value: 'Semi Design 设计稿',
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
text: 'Semi Pro 设计稿',
|
|
55
|
+
value: 'Semi Pro 设计稿',
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
onFilter: (value, record) => record.name.includes(value),
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
title: '大小',
|
|
62
|
+
dataIndex: 'size',
|
|
63
|
+
sorter: (a, b) => a.size - b.size > 0 ? 1 : -1,
|
|
64
|
+
render: (text) => `${text} KB`
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
title: '所有者',
|
|
68
|
+
dataIndex: 'owner',
|
|
69
|
+
render: (text, record, index) => {
|
|
70
|
+
return (
|
|
71
|
+
<div>
|
|
72
|
+
<Avatar size="small" color={record.avatarBg} style={{ marginRight: 4 }}>{typeof text === 'string' && text.slice(0, 1)}</Avatar>
|
|
73
|
+
{text}
|
|
74
|
+
</div>
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
title: '更新日期',
|
|
80
|
+
dataIndex: 'updateTime',
|
|
81
|
+
sorter: (a, b) => a.updateTime - b.updateTime > 0 ? 1 : -1,
|
|
82
|
+
render: (value) => {
|
|
83
|
+
return dateFns.format(new Date(value), 'yyyy-MM-dd');
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
];
|
|
87
|
+
|
|
88
|
+
return (
|
|
89
|
+
<Table
|
|
90
|
+
columns={columns}
|
|
91
|
+
dataSource={dataSource}
|
|
92
|
+
pagination={{
|
|
93
|
+
pageSize: 5,
|
|
94
|
+
}}
|
|
95
|
+
rowSelection={{
|
|
96
|
+
onChange: rowKeys => setRowKeys(rowKeys),
|
|
97
|
+
selectedRowKeys: rowKeys,
|
|
98
|
+
}}
|
|
99
|
+
scroll={{ y: 300 }}
|
|
100
|
+
/>
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export default App;
|