@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
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Table, Tooltip, Tag } from '@douyinfe/semi-ui';
|
|
3
|
+
|
|
4
|
+
App.storyName = 'fixed z-index bug';
|
|
5
|
+
export default function App() {
|
|
6
|
+
const columns = [
|
|
7
|
+
{
|
|
8
|
+
title: 'Name',
|
|
9
|
+
dataIndex: 'name',
|
|
10
|
+
width: 150,
|
|
11
|
+
fixed: true,
|
|
12
|
+
filters: [
|
|
13
|
+
{
|
|
14
|
+
text: 'King 3',
|
|
15
|
+
value: 'King 3',
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
text: 'King 4',
|
|
19
|
+
value: 'King 4',
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
onFilter: (value, record) => record.name.includes(value),
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
title: 'Age',
|
|
26
|
+
dataIndex: 'age',
|
|
27
|
+
width: 150,
|
|
28
|
+
sorter: (a, b) => (a.age - b.age > 0 ? 1 : -1),
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
title: 'Address',
|
|
32
|
+
width: 200,
|
|
33
|
+
dataIndex: 'address',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
title: 'Description',
|
|
37
|
+
// width: 400,
|
|
38
|
+
dataIndex: 'description',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
fixed: 'right',
|
|
42
|
+
width: 250,
|
|
43
|
+
render: (text, record) => <Tooltip content={record.description}><Tag color="green">Show Info</Tag></Tooltip>
|
|
44
|
+
}
|
|
45
|
+
];
|
|
46
|
+
|
|
47
|
+
let data = [];
|
|
48
|
+
|
|
49
|
+
const rowSelection = {
|
|
50
|
+
onChange: (selectedRowKeys, selectedRows) => {
|
|
51
|
+
// console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
|
|
52
|
+
},
|
|
53
|
+
getCheckboxProps: record => ({
|
|
54
|
+
disabled: record.name === 'Michael James', // Column configuration not to be checked
|
|
55
|
+
name: record.name,
|
|
56
|
+
}),
|
|
57
|
+
// fixed: true,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
for (let i = 0; i < 46; i++) {
|
|
61
|
+
let age = 40 + (Math.random() > 0.5 ? 1 : -1) * Math.ceil(i / 3);
|
|
62
|
+
let name = `Edward King ${i}`;
|
|
63
|
+
data.push({
|
|
64
|
+
key: `${ i}`,
|
|
65
|
+
name,
|
|
66
|
+
age,
|
|
67
|
+
address: `London, Park Lane no. ${i}`,
|
|
68
|
+
description: `My name is ${name}, I am ${age} years old, living in New York No. ${i + 1} Lake Park.`,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const scroll = { y: 300, x: 1500 };
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<div style={{ position: 'relative', height: '100vh' }}>
|
|
76
|
+
<div style={{ height: 60, background: 'red', position: 'absolute', top: 0, left: 0, right: 0, zIndex: 2 }}>
|
|
77
|
+
Fixed Header
|
|
78
|
+
</div>
|
|
79
|
+
<Table
|
|
80
|
+
columns={columns}
|
|
81
|
+
dataSource={data}
|
|
82
|
+
scroll={scroll}
|
|
83
|
+
rowSelection={rowSelection}
|
|
84
|
+
/>
|
|
85
|
+
</div>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
@@ -90,6 +90,7 @@ export type TimePickerProps = {
|
|
|
90
90
|
zIndex?: number | string;
|
|
91
91
|
onBlur?: React.FocusEventHandler<HTMLInputElement>;
|
|
92
92
|
onChange?: TimePickerAdapter['notifyChange'];
|
|
93
|
+
onChangeWithDateFirst?: boolean;
|
|
93
94
|
onFocus?: React.FocusEventHandler<HTMLInputElement>;
|
|
94
95
|
onOpenChange?: (open: boolean) => void;
|
|
95
96
|
};
|
|
@@ -187,6 +188,7 @@ export default class TimePicker extends BaseComponent<TimePickerProps, TimePicke
|
|
|
187
188
|
onFocus: noop,
|
|
188
189
|
onBlur: noop,
|
|
189
190
|
onChange: noop,
|
|
191
|
+
onChangeWithDateFirst: true,
|
|
190
192
|
use12Hours: false,
|
|
191
193
|
focusOnOpen: false,
|
|
192
194
|
onKeyDown: noop,
|
|
@@ -257,7 +259,7 @@ export default class TimePicker extends BaseComponent<TimePickerProps, TimePicke
|
|
|
257
259
|
}
|
|
258
260
|
},
|
|
259
261
|
notifyOpenChange: (...args) => this.props.onOpenChange(...args),
|
|
260
|
-
notifyChange: (
|
|
262
|
+
notifyChange: (agr1, arg2) => this.props.onChange && this.props.onChange(agr1, arg2),
|
|
261
263
|
notifyFocus: (...args) => this.props.onFocus && this.props.onFocus(...args),
|
|
262
264
|
notifyBlur: (...args) => this.props.onBlur && this.props.onBlur(...args),
|
|
263
265
|
isRangePicker: () => this.props.type === strings.TYPE_TIME_RANGE_PICKER,
|
|
@@ -22,11 +22,13 @@ describe(`TimePicker`, () => {
|
|
|
22
22
|
const defaultMinute = 24;
|
|
23
23
|
const defaultSeconds = 18;
|
|
24
24
|
|
|
25
|
-
const
|
|
25
|
+
const onFocus = sinon.spy();
|
|
26
|
+
const onChange = sinon.spy();
|
|
26
27
|
|
|
27
28
|
const elem = mount(
|
|
28
29
|
<TimePicker
|
|
29
|
-
|
|
30
|
+
onChange={onChange}
|
|
31
|
+
onFocus={onFocus}
|
|
30
32
|
panelHeader={<strong>Select Time</strong>}
|
|
31
33
|
locale={Locale.TimePicker}
|
|
32
34
|
localeCode={Locale.code}
|
|
@@ -59,7 +61,7 @@ describe(`TimePicker`, () => {
|
|
|
59
61
|
// focus
|
|
60
62
|
elem.find(`input`).simulate('focus');
|
|
61
63
|
await sleep(200);
|
|
62
|
-
expect(
|
|
64
|
+
expect(onFocus.calledOnce).toBeTruthy();
|
|
63
65
|
|
|
64
66
|
// input value
|
|
65
67
|
const newInputHour = 10;
|
|
@@ -82,6 +84,11 @@ describe(`TimePicker`, () => {
|
|
|
82
84
|
|
|
83
85
|
await sleep(200);
|
|
84
86
|
expect(elem.state('open')).toBe(false);
|
|
87
|
+
|
|
88
|
+
expect(onChange.called).toBeTruthy();
|
|
89
|
+
const args = onChange.getCall(0).args;
|
|
90
|
+
expect(args[0] instanceof Date).toBe(true);
|
|
91
|
+
expect(typeof args[1]).toBe('string');
|
|
85
92
|
});
|
|
86
93
|
|
|
87
94
|
it(`test controlled value`, async () => {
|
|
@@ -280,4 +287,28 @@ describe(`TimePicker`, () => {
|
|
|
280
287
|
expect(args[0]).toBe(undefined);
|
|
281
288
|
expect(args[1]).toBe('');
|
|
282
289
|
});
|
|
290
|
+
|
|
291
|
+
it('test onChangeWithDateFirst=false', async () => {
|
|
292
|
+
const onChange = sinon.spy();
|
|
293
|
+
let props = {
|
|
294
|
+
defaultValue: "10:23:15",
|
|
295
|
+
onChange,
|
|
296
|
+
defaultOpen: true,
|
|
297
|
+
onChangeWithDateFirst: false,
|
|
298
|
+
autofocus: true,
|
|
299
|
+
locale: Locale.TimePicker,
|
|
300
|
+
localeCode: Locale.code
|
|
301
|
+
};
|
|
302
|
+
const elem = mount(<TimePicker {...props} />);
|
|
303
|
+
// click minute
|
|
304
|
+
const minuteUl = elem.find(`.${BASE_CLASS_PREFIX}-timepicker-panel-list-minute .${BASE_CLASS_PREFIX}-scrolllist-list-outer ul`);
|
|
305
|
+
const minuteLis = minuteUl.find(`li`);
|
|
306
|
+
|
|
307
|
+
minuteUl.simulate('click', { target: minuteLis.at(0).getDOMNode(), nativeEvent: null });
|
|
308
|
+
|
|
309
|
+
expect(onChange.called).toBeTruthy();
|
|
310
|
+
const args = onChange.getCall(0).args;
|
|
311
|
+
expect(typeof args[0]).toBe('string');
|
|
312
|
+
expect(args[1] instanceof Date).toBe(true);
|
|
313
|
+
});
|
|
283
314
|
});
|
|
@@ -262,3 +262,21 @@ export const ShowClear = () => (
|
|
|
262
262
|
/>
|
|
263
263
|
</>
|
|
264
264
|
);
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
export const TimePickerWithOnChangeWithDateFirst = () => {
|
|
268
|
+
return (
|
|
269
|
+
<div>
|
|
270
|
+
onChangeWithDateFirst=true (default)
|
|
271
|
+
<TimePicker onChange={(...val) => console.log(...val)} />
|
|
272
|
+
<br />
|
|
273
|
+
onChangeWithDateFirst=false
|
|
274
|
+
<TimePicker onChangeWithDateFirst={false} onChange={(...val) => console.log(...val)} />
|
|
275
|
+
|
|
276
|
+
</div>
|
|
277
|
+
);
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
TimePickerWithOnChangeWithDateFirst.story = {
|
|
281
|
+
name: 'OnChangeWithDateFirst',
|
|
282
|
+
};
|
package/tree/treeNode.tsx
CHANGED
|
@@ -3,7 +3,7 @@ import cls from 'classnames';
|
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import { cssClasses } from '@douyinfe/semi-foundation/tree/constants';
|
|
5
5
|
import isEnterPress from '@douyinfe/semi-foundation/utils/isEnterPress';
|
|
6
|
-
import { debounce, isFunction, isString, get } from 'lodash';
|
|
6
|
+
import { debounce, isFunction, isString, get, isEmpty } from 'lodash';
|
|
7
7
|
import { IconTreeTriangleDown, IconFile, IconFolder, IconFolderOpen } from '@douyinfe/semi-icons';
|
|
8
8
|
import { Checkbox } from '../checkbox';
|
|
9
9
|
import TreeContext from './treeContext';
|
|
@@ -392,7 +392,14 @@ export default class TreeNode extends PureComponent<TreeNodeProps, TreeNodeState
|
|
|
392
392
|
...dragProps
|
|
393
393
|
});
|
|
394
394
|
} else {
|
|
395
|
-
|
|
395
|
+
if (isEmpty(style)) {
|
|
396
|
+
return customLabel;
|
|
397
|
+
} else {
|
|
398
|
+
// In virtualization, props.style will contain location information
|
|
399
|
+
return React.cloneElement(customLabel, {
|
|
400
|
+
style: { ...get(customLabel, ['props', 'style']), ...style }
|
|
401
|
+
});
|
|
402
|
+
}
|
|
396
403
|
}
|
|
397
404
|
}
|
|
398
405
|
const labelCls = cls(`${prefixcls}-label`, {
|