@douyinfe/semi-ui 2.6.0 → 2.7.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/button/__test__/button.test.js +7 -0
- package/button/buttonGroup.tsx +5 -2
- package/cascader/__test__/cascader.test.js +159 -81
- package/cascader/_story/cascader.stories.js +36 -23
- package/cascader/index.tsx +26 -5
- package/datePicker/_story/v2/InsetInput.jsx +104 -0
- package/datePicker/_story/v2/InsetInputE2E.jsx +69 -0
- package/datePicker/_story/v2/index.js +2 -0
- package/datePicker/dateInput.tsx +95 -9
- package/datePicker/datePicker.tsx +89 -15
- package/datePicker/index.tsx +15 -0
- package/datePicker/insetInput.tsx +76 -0
- package/datePicker/monthsGrid.tsx +14 -7
- package/dist/css/semi.css +104 -2
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +902 -147
- 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/_story/input.stories.js +13 -0
- package/lib/cjs/button/buttonGroup.d.ts +1 -0
- package/lib/cjs/button/buttonGroup.js +6 -2
- package/lib/cjs/cascader/index.d.ts +1 -0
- package/lib/cjs/cascader/index.js +38 -9
- package/lib/cjs/datePicker/dateInput.d.ts +9 -2
- package/lib/cjs/datePicker/dateInput.js +92 -9
- package/lib/cjs/datePicker/datePicker.d.ts +7 -2
- package/lib/cjs/datePicker/datePicker.js +123 -18
- package/lib/cjs/datePicker/index.js +24 -2
- package/lib/cjs/datePicker/insetInput.d.ts +21 -0
- package/lib/cjs/datePicker/insetInput.js +80 -0
- package/lib/cjs/datePicker/monthsGrid.js +19 -7
- package/lib/cjs/tree/index.js +5 -3
- package/lib/cjs/tree/interface.d.ts +1 -0
- package/lib/cjs/tree/nodeList.js +2 -1
- package/lib/cjs/treeSelect/index.js +7 -3
- package/lib/es/button/buttonGroup.d.ts +1 -0
- package/lib/es/button/buttonGroup.js +5 -2
- package/lib/es/cascader/index.d.ts +1 -0
- package/lib/es/cascader/index.js +35 -6
- package/lib/es/datePicker/dateInput.d.ts +9 -2
- package/lib/es/datePicker/dateInput.js +91 -9
- package/lib/es/datePicker/datePicker.d.ts +7 -2
- package/lib/es/datePicker/datePicker.js +124 -18
- package/lib/es/datePicker/index.js +20 -0
- package/lib/es/datePicker/insetInput.d.ts +21 -0
- package/lib/es/datePicker/insetInput.js +65 -0
- package/lib/es/datePicker/monthsGrid.js +19 -7
- package/lib/es/tree/index.js +5 -3
- package/lib/es/tree/interface.d.ts +1 -0
- package/lib/es/tree/nodeList.js +2 -1
- package/lib/es/treeSelect/index.js +7 -3
- package/package.json +9 -9
- package/tree/__test__/tree.test.js +87 -2
- package/tree/_story/tree.stories.js +65 -5
- package/tree/index.tsx +4 -2
- package/tree/interface.ts +1 -0
- package/tree/nodeList.tsx +2 -2
- package/treeSelect/__test__/treeSelect.test.js +28 -0
- package/treeSelect/_story/treeSelect.stories.js +55 -2
- package/treeSelect/index.tsx +11 -3
|
@@ -8,6 +8,7 @@ describe('Button', () => {
|
|
|
8
8
|
it('button with custom className & style', () => {
|
|
9
9
|
const wrapper = mount(<Button className="test" style={{ color: 'red' }} />);
|
|
10
10
|
expect(wrapper.hasClass('test')).toEqual(true);
|
|
11
|
+
expect(wrapper.find('button').getDOMNode().style.color).toBe('red');
|
|
11
12
|
});
|
|
12
13
|
|
|
13
14
|
it(`button with icon`, () => {
|
|
@@ -61,4 +62,10 @@ describe('Button', () => {
|
|
|
61
62
|
);
|
|
62
63
|
expect(buttonGroup.getDOMNode().textContent).toEqual('1查询剪切');
|
|
63
64
|
});
|
|
65
|
+
|
|
66
|
+
it('button group with custom className & style', () => {
|
|
67
|
+
const wrapper = mount(<ButtonGroup className="test" style={{ color: 'red' }} />);
|
|
68
|
+
expect(wrapper.hasClass('test')).toEqual(true);
|
|
69
|
+
expect(wrapper.find('button').getDOMNode().style.color).toBe('red');
|
|
70
|
+
});
|
|
64
71
|
});
|
package/button/buttonGroup.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { isValidElement, cloneElement } from 'react';
|
|
2
2
|
import BaseComponent, { BaseProps } from '../_base/baseComponent';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
|
+
import classNames from 'classnames';
|
|
4
5
|
import { cssClasses, strings } from '@douyinfe/semi-foundation/button/constants';
|
|
5
6
|
import { Type, Size } from './Button';
|
|
6
7
|
|
|
@@ -13,6 +14,7 @@ export interface ButtonGroupProps extends BaseProps {
|
|
|
13
14
|
type?: Type;
|
|
14
15
|
size?: Size;
|
|
15
16
|
theme?: Theme;
|
|
17
|
+
className?: string;
|
|
16
18
|
'aria-label'?: React.AriaAttributes['aria-label'];
|
|
17
19
|
}
|
|
18
20
|
|
|
@@ -36,8 +38,9 @@ export default class ButtonGroup extends BaseComponent<ButtonGroupProps> {
|
|
|
36
38
|
};
|
|
37
39
|
|
|
38
40
|
render() {
|
|
39
|
-
const { children, disabled, size, type, 'aria-label': ariaLabel, ...rest } = this.props;
|
|
41
|
+
const { children, disabled, size, type, className, 'aria-label': ariaLabel, ...rest } = this.props;
|
|
40
42
|
let inner;
|
|
43
|
+
const cls = classNames(`${prefixCls}-group`, className);
|
|
41
44
|
|
|
42
45
|
if (children) {
|
|
43
46
|
inner = ((Array.isArray(children) ? children : [children])).map((itm, index) => (
|
|
@@ -46,6 +49,6 @@ export default class ButtonGroup extends BaseComponent<ButtonGroupProps> {
|
|
|
46
49
|
: itm
|
|
47
50
|
));
|
|
48
51
|
}
|
|
49
|
-
return <div className={
|
|
52
|
+
return <div className={cls} role="group" aria-label={ariaLabel}>{inner}</div>;
|
|
50
53
|
}
|
|
51
54
|
}
|
|
@@ -16,13 +16,13 @@ const getPopupContainer = () => document.querySelector(`.${BASE_CLASS_PREFIX}-ca
|
|
|
16
16
|
const treeData = [
|
|
17
17
|
{
|
|
18
18
|
label: '亚洲',
|
|
19
|
-
value: '
|
|
20
|
-
key: '
|
|
19
|
+
value: 'Asia',
|
|
20
|
+
key: 'Asia',
|
|
21
21
|
children: [
|
|
22
22
|
{
|
|
23
23
|
label: '中国',
|
|
24
|
-
value: '
|
|
25
|
-
key: '
|
|
24
|
+
value: 'China',
|
|
25
|
+
key: 'China',
|
|
26
26
|
children: [
|
|
27
27
|
{
|
|
28
28
|
label: '北京',
|
|
@@ -40,18 +40,18 @@ const treeData = [
|
|
|
40
40
|
},
|
|
41
41
|
{
|
|
42
42
|
label: '北美洲',
|
|
43
|
-
value: '
|
|
44
|
-
key: '
|
|
43
|
+
value: 'North America',
|
|
44
|
+
key: 'North America',
|
|
45
45
|
children: [
|
|
46
46
|
{
|
|
47
47
|
label: '美国',
|
|
48
|
-
value: '
|
|
49
|
-
key: '
|
|
48
|
+
value: 'United States',
|
|
49
|
+
key: 'United States',
|
|
50
50
|
},
|
|
51
51
|
{
|
|
52
52
|
label: '加拿大',
|
|
53
|
-
value: '
|
|
54
|
-
key: '
|
|
53
|
+
value: 'Canada',
|
|
54
|
+
key: 'Canada',
|
|
55
55
|
},
|
|
56
56
|
],
|
|
57
57
|
},
|
|
@@ -60,13 +60,13 @@ const treeData = [
|
|
|
60
60
|
const treeDataWithDisabled = [
|
|
61
61
|
{
|
|
62
62
|
label: '亚洲',
|
|
63
|
-
value: '
|
|
64
|
-
key: '
|
|
63
|
+
value: 'Asia',
|
|
64
|
+
key: 'Asia',
|
|
65
65
|
children: [
|
|
66
66
|
{
|
|
67
67
|
label: '中国',
|
|
68
|
-
value: '
|
|
69
|
-
key: '
|
|
68
|
+
value: 'China',
|
|
69
|
+
key: 'China',
|
|
70
70
|
disabled: true,
|
|
71
71
|
children: [
|
|
72
72
|
{
|
|
@@ -90,6 +90,38 @@ const treeDataWithDisabled = [
|
|
|
90
90
|
}
|
|
91
91
|
];
|
|
92
92
|
|
|
93
|
+
const treeDataWithReactNode = [
|
|
94
|
+
{
|
|
95
|
+
label: <strong>亚洲</strong>,
|
|
96
|
+
value: 'Asia',
|
|
97
|
+
key: 'Asia',
|
|
98
|
+
children: [
|
|
99
|
+
{
|
|
100
|
+
label: '中国',
|
|
101
|
+
value: 'China',
|
|
102
|
+
key: 'China',
|
|
103
|
+
children: [
|
|
104
|
+
{
|
|
105
|
+
label: '北京',
|
|
106
|
+
value: 'Beijing',
|
|
107
|
+
key: 'beijing',
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
label: <div>上海</div>,
|
|
111
|
+
value: 'Shanghai',
|
|
112
|
+
key: 'shanghai',
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
}
|
|
116
|
+
],
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
label: <p>北美洲</p>,
|
|
120
|
+
value: 'North America',
|
|
121
|
+
key: 'North America',
|
|
122
|
+
}
|
|
123
|
+
];
|
|
124
|
+
|
|
93
125
|
let commonProps = {
|
|
94
126
|
// Cascader use Popup Layer to show candidate option,
|
|
95
127
|
// but all Popup Layer which extends from Tooltip (eg Popover, Dropdown) have animation and delay.
|
|
@@ -197,7 +229,7 @@ describe('Cascader', () => {
|
|
|
197
229
|
|
|
198
230
|
it('dynamic treeData in multiple and uncontrolled mode', () => {
|
|
199
231
|
const cascader = render({
|
|
200
|
-
defaultValue: '
|
|
232
|
+
defaultValue: 'Asia',
|
|
201
233
|
multiple: true,
|
|
202
234
|
});
|
|
203
235
|
const opt = document.querySelectorAll(`.${BASE_CLASS_PREFIX}-cascader-selection-multiple .${BASE_CLASS_PREFIX}-tag`);
|
|
@@ -209,7 +241,7 @@ describe('Cascader', () => {
|
|
|
209
241
|
|
|
210
242
|
it('dynamic treeData in multiple and controlled mode', () => {
|
|
211
243
|
const cascader = render({
|
|
212
|
-
value: '
|
|
244
|
+
value: 'Asia',
|
|
213
245
|
multiple: true,
|
|
214
246
|
});
|
|
215
247
|
const opt = document.querySelectorAll(`.${BASE_CLASS_PREFIX}-cascader-selection-multiple .${BASE_CLASS_PREFIX}-tag`);
|
|
@@ -260,7 +292,7 @@ describe('Cascader', () => {
|
|
|
260
292
|
|
|
261
293
|
it('defaultValue', () => {
|
|
262
294
|
let cascader = render({
|
|
263
|
-
defaultValue: ['
|
|
295
|
+
defaultValue: ['Asia', 'China', 'Beijing'],
|
|
264
296
|
defaultOpen: true,
|
|
265
297
|
});
|
|
266
298
|
// await sleep();
|
|
@@ -282,25 +314,25 @@ describe('Cascader', () => {
|
|
|
282
314
|
|
|
283
315
|
it('displayProp', () => {
|
|
284
316
|
let cascader = render({
|
|
285
|
-
defaultValue: ['
|
|
317
|
+
defaultValue: ['Asia', 'China', 'Beijing'],
|
|
286
318
|
displayProp: 'value',
|
|
287
319
|
});
|
|
288
320
|
expect(cascader.find(`.${BASE_CLASS_PREFIX}-cascader-selection`).getDOMNode().textContent).toEqual(
|
|
289
|
-
'
|
|
321
|
+
'Asia / China / Beijing'
|
|
290
322
|
);
|
|
291
323
|
});
|
|
292
324
|
|
|
293
325
|
it('displayRender', () => {
|
|
294
326
|
let spyOnRender = sinon.spy(() => {});
|
|
295
327
|
let cascader = render({
|
|
296
|
-
defaultValue: ['
|
|
328
|
+
defaultValue: ['Asia', 'China', 'Beijing'],
|
|
297
329
|
displayRender: spyOnRender,
|
|
298
330
|
});
|
|
299
331
|
expect(spyOnRender.calledWithMatch(['亚洲', '中国', '北京'])).toEqual(true);
|
|
300
332
|
cascader.unmount();
|
|
301
333
|
|
|
302
334
|
let cusRender = render({
|
|
303
|
-
defaultValue: ['
|
|
335
|
+
defaultValue: ['Asia', 'China', 'Beijing'],
|
|
304
336
|
displayRender: list => '已选择:' + list.join(' -> '),
|
|
305
337
|
});
|
|
306
338
|
expect(cusRender.find(`.${BASE_CLASS_PREFIX}-cascader-selection`).getDOMNode().textContent).toEqual(
|
|
@@ -308,6 +340,52 @@ describe('Cascader', () => {
|
|
|
308
340
|
);
|
|
309
341
|
});
|
|
310
342
|
|
|
343
|
+
it('label is ReactNode when unsearchable and single-selection mode', () => {
|
|
344
|
+
const cascader = render({
|
|
345
|
+
defaultValue: ['Asia', 'China', 'Shanghai'],
|
|
346
|
+
treeData: treeDataWithReactNode
|
|
347
|
+
});
|
|
348
|
+
expect(cascader.find(`.${BASE_CLASS_PREFIX}-cascader-selection span strong`).getDOMNode().textContent).toEqual(
|
|
349
|
+
'亚洲'
|
|
350
|
+
);
|
|
351
|
+
expect(cascader.find(`.${BASE_CLASS_PREFIX}-cascader-selection span div`).getDOMNode().textContent).toEqual(
|
|
352
|
+
'上海'
|
|
353
|
+
);
|
|
354
|
+
expect(cascader.find(`.${BASE_CLASS_PREFIX}-cascader-selection span`).getDOMNode().textContent).toEqual(
|
|
355
|
+
'亚洲 / 中国 / 上海'
|
|
356
|
+
);
|
|
357
|
+
|
|
358
|
+
cascader.unmount();
|
|
359
|
+
|
|
360
|
+
const cascader2 = render({
|
|
361
|
+
defaultValue: ['North America'],
|
|
362
|
+
treeData: treeDataWithReactNode,
|
|
363
|
+
});
|
|
364
|
+
expect(cascader2.find(`.${BASE_CLASS_PREFIX}-cascader-selection span p`).getDOMNode().textContent).toEqual(
|
|
365
|
+
'北美洲'
|
|
366
|
+
);
|
|
367
|
+
expect(cascader2.find(`.${BASE_CLASS_PREFIX}-cascader-selection span`).getDOMNode().textContent).toEqual(
|
|
368
|
+
'北美洲'
|
|
369
|
+
);
|
|
370
|
+
cascader2.unmount();
|
|
371
|
+
|
|
372
|
+
const cascader3 = render({
|
|
373
|
+
defaultValue: ['Asia', 'China', 'Shanghai'],
|
|
374
|
+
treeData: treeDataWithReactNode,
|
|
375
|
+
separator: ' - '
|
|
376
|
+
});
|
|
377
|
+
expect(cascader3.find(`.${BASE_CLASS_PREFIX}-cascader-selection span strong`).getDOMNode().textContent).toEqual(
|
|
378
|
+
'亚洲'
|
|
379
|
+
);
|
|
380
|
+
expect(cascader3.find(`.${BASE_CLASS_PREFIX}-cascader-selection span div`).getDOMNode().textContent).toEqual(
|
|
381
|
+
'上海'
|
|
382
|
+
);
|
|
383
|
+
expect(cascader3.find(`.${BASE_CLASS_PREFIX}-cascader-selection span`).getDOMNode().textContent).toEqual(
|
|
384
|
+
'亚洲 - 中国 - 上海'
|
|
385
|
+
);
|
|
386
|
+
cascader3.unmount();
|
|
387
|
+
});
|
|
388
|
+
|
|
311
389
|
it('disabled', () => {
|
|
312
390
|
let cascader = render({
|
|
313
391
|
disabled: true,
|
|
@@ -330,7 +408,7 @@ describe('Cascader', () => {
|
|
|
330
408
|
const cascaderWithSingle = render({
|
|
331
409
|
treeData: treeDataWithDisabled,
|
|
332
410
|
changeOnSelect: true,
|
|
333
|
-
defaultValue:['
|
|
411
|
+
defaultValue:['Asia', 'China']
|
|
334
412
|
});
|
|
335
413
|
expect(
|
|
336
414
|
cascaderWithSingle
|
|
@@ -345,7 +423,7 @@ describe('Cascader', () => {
|
|
|
345
423
|
treeData: treeDataWithDisabled,
|
|
346
424
|
changeOnSelect: true,
|
|
347
425
|
filterTreeNode: true,
|
|
348
|
-
defaultValue:['
|
|
426
|
+
defaultValue:['Asia', 'China']
|
|
349
427
|
});
|
|
350
428
|
expect(
|
|
351
429
|
cascaderWithSingleFilter
|
|
@@ -358,7 +436,7 @@ describe('Cascader', () => {
|
|
|
358
436
|
const cascaderWithSingleControlled = render({
|
|
359
437
|
treeData: treeDataWithDisabled,
|
|
360
438
|
changeOnSelect: true,
|
|
361
|
-
value: ['
|
|
439
|
+
value: ['Asia', 'China'],
|
|
362
440
|
});
|
|
363
441
|
expect(cascaderWithSingleControlled.find(`.${BASE_CLASS_PREFIX}-cascader-selection span`).getDOMNode().textContent).toEqual(
|
|
364
442
|
'亚洲 / 中国'
|
|
@@ -368,7 +446,7 @@ describe('Cascader', () => {
|
|
|
368
446
|
const cascaderWithMultiple = render({
|
|
369
447
|
treeData: treeDataWithDisabled,
|
|
370
448
|
multiple: true,
|
|
371
|
-
defaultValue:['
|
|
449
|
+
defaultValue:['Asia', 'China']
|
|
372
450
|
});
|
|
373
451
|
expect(
|
|
374
452
|
cascaderWithMultiple
|
|
@@ -383,7 +461,7 @@ describe('Cascader', () => {
|
|
|
383
461
|
treeData: treeDataWithDisabled,
|
|
384
462
|
multiple: true,
|
|
385
463
|
filterTreeNode: true,
|
|
386
|
-
defaultValue:['
|
|
464
|
+
defaultValue:['Asia', 'China']
|
|
387
465
|
});
|
|
388
466
|
expect(
|
|
389
467
|
cascaderWithMultipleFilter
|
|
@@ -397,7 +475,7 @@ describe('Cascader', () => {
|
|
|
397
475
|
const cascaderWithMultipleControlled = render({
|
|
398
476
|
treeData: treeDataWithDisabled,
|
|
399
477
|
multiple: true,
|
|
400
|
-
value:['
|
|
478
|
+
value:['Asia', 'China']
|
|
401
479
|
});
|
|
402
480
|
expect(
|
|
403
481
|
cascaderWithMultipleControlled
|
|
@@ -450,7 +528,7 @@ describe('Cascader', () => {
|
|
|
450
528
|
expect(spyOnSelect.calledOnce).toBe(true);
|
|
451
529
|
expect(spyOnChange.calledOnce).toBe(true);
|
|
452
530
|
expect(spyOnSelect.calledWithMatch('Beijing')).toEqual(true);
|
|
453
|
-
expect(spyOnChange.calledWithMatch(['
|
|
531
|
+
expect(spyOnChange.calledWithMatch(['Asia', 'China', 'Beijing'])).toEqual(true);
|
|
454
532
|
expect(
|
|
455
533
|
lists[2]
|
|
456
534
|
.querySelectorAll(`.${BASE_CLASS_PREFIX}-cascader-option`)[0]
|
|
@@ -507,8 +585,8 @@ describe('Cascader', () => {
|
|
|
507
585
|
lists[0].querySelectorAll('li')[0].click();
|
|
508
586
|
expect(spyOnSelect.calledOnce).toBe(true);
|
|
509
587
|
expect(spyOnChange.calledOnce).toBe(true);
|
|
510
|
-
expect(spyOnSelect.calledWithMatch('
|
|
511
|
-
expect(spyOnChange.calledWithMatch(['
|
|
588
|
+
expect(spyOnSelect.calledWithMatch('Asia')).toEqual(true);
|
|
589
|
+
expect(spyOnChange.calledWithMatch(['Asia'])).toEqual(true);
|
|
512
590
|
expect(
|
|
513
591
|
lists[0]
|
|
514
592
|
.querySelectorAll(`.${BASE_CLASS_PREFIX}-cascader-option`)[0]
|
|
@@ -518,8 +596,8 @@ describe('Cascader', () => {
|
|
|
518
596
|
|
|
519
597
|
lists = document.querySelectorAll(`.${BASE_CLASS_PREFIX}-cascader-option-list`);
|
|
520
598
|
lists[1].querySelectorAll('li')[0].click();
|
|
521
|
-
expect(spyOnSelect.calledWithMatch('
|
|
522
|
-
expect(spyOnChange.calledWithMatch(['
|
|
599
|
+
expect(spyOnSelect.calledWithMatch('China')).toEqual(true);
|
|
600
|
+
expect(spyOnChange.calledWithMatch(['Asia', 'China'])).toEqual(true);
|
|
523
601
|
expect(
|
|
524
602
|
lists[0]
|
|
525
603
|
.querySelectorAll(`.${BASE_CLASS_PREFIX}-cascader-option`)[0]
|
|
@@ -574,7 +652,7 @@ describe('Cascader', () => {
|
|
|
574
652
|
|
|
575
653
|
// await sleep();
|
|
576
654
|
let resList = document.querySelectorAll(`.${BASE_CLASS_PREFIX}-cascader-option-label-highlight`);
|
|
577
|
-
expect(resList.length).toEqual(
|
|
655
|
+
expect(resList.length).toEqual(1);
|
|
578
656
|
// debugger
|
|
579
657
|
// expect(resList[0].textContent).toEqual('亚洲/中国/北京');
|
|
580
658
|
// done();
|
|
@@ -615,7 +693,7 @@ describe('Cascader', () => {
|
|
|
615
693
|
|
|
616
694
|
it('controlled: value shows correct', () => {
|
|
617
695
|
let cascader = render({
|
|
618
|
-
value: ['
|
|
696
|
+
value: ['Asia', 'China', 'Beijing'],
|
|
619
697
|
});
|
|
620
698
|
expect(cascader.find(`.${BASE_CLASS_PREFIX}-cascader-selection`).getDOMNode().textContent).toEqual(
|
|
621
699
|
'亚洲 / 中国 / 北京'
|
|
@@ -625,7 +703,7 @@ describe('Cascader', () => {
|
|
|
625
703
|
it('controlled: fire onChange and ui not update', () => {
|
|
626
704
|
let spyOnChange = sinon.spy(() => {});
|
|
627
705
|
let cascader = render({
|
|
628
|
-
value: ['
|
|
706
|
+
value: ['Asia', 'China', 'Beijing'],
|
|
629
707
|
defaultOpen: true,
|
|
630
708
|
onChange: spyOnChange,
|
|
631
709
|
changeOnSelect: true,
|
|
@@ -681,13 +759,13 @@ describe('Cascader', () => {
|
|
|
681
759
|
spyOnChange.calledWithMatch([
|
|
682
760
|
{
|
|
683
761
|
label: '亚洲',
|
|
684
|
-
value: '
|
|
685
|
-
key: '
|
|
762
|
+
value: 'Asia',
|
|
763
|
+
key: 'Asia',
|
|
686
764
|
children: [
|
|
687
765
|
{
|
|
688
766
|
label: '中国',
|
|
689
|
-
value: '
|
|
690
|
-
key: '
|
|
767
|
+
value: 'China',
|
|
768
|
+
key: 'China',
|
|
691
769
|
children: [
|
|
692
770
|
{
|
|
693
771
|
label: '北京',
|
|
@@ -705,8 +783,8 @@ describe('Cascader', () => {
|
|
|
705
783
|
},
|
|
706
784
|
{
|
|
707
785
|
label: '中国',
|
|
708
|
-
value: '
|
|
709
|
-
key: '
|
|
786
|
+
value: 'China',
|
|
787
|
+
key: 'China',
|
|
710
788
|
children: [
|
|
711
789
|
{
|
|
712
790
|
label: '北京',
|
|
@@ -753,13 +831,13 @@ describe('Cascader', () => {
|
|
|
753
831
|
spyOnChange.calledWithMatch([
|
|
754
832
|
{
|
|
755
833
|
label: '亚洲',
|
|
756
|
-
value: '
|
|
757
|
-
key: '
|
|
834
|
+
value: 'Asia',
|
|
835
|
+
key: 'Asia',
|
|
758
836
|
children: [
|
|
759
837
|
{
|
|
760
838
|
label: '中国',
|
|
761
|
-
value: '
|
|
762
|
-
key: '
|
|
839
|
+
value: 'China',
|
|
840
|
+
key: 'China',
|
|
763
841
|
children: [
|
|
764
842
|
{
|
|
765
843
|
label: '北京',
|
|
@@ -790,13 +868,13 @@ describe('Cascader', () => {
|
|
|
790
868
|
value: [
|
|
791
869
|
{
|
|
792
870
|
label: '亚洲',
|
|
793
|
-
value: '
|
|
794
|
-
key: '
|
|
871
|
+
value: 'Asia',
|
|
872
|
+
key: 'Asia',
|
|
795
873
|
children: [
|
|
796
874
|
{
|
|
797
875
|
label: '中国',
|
|
798
|
-
value: '
|
|
799
|
-
key: '
|
|
876
|
+
value: 'China',
|
|
877
|
+
key: 'China',
|
|
800
878
|
children: [
|
|
801
879
|
{
|
|
802
880
|
label: '北京',
|
|
@@ -814,8 +892,8 @@ describe('Cascader', () => {
|
|
|
814
892
|
},
|
|
815
893
|
{
|
|
816
894
|
label: '中国',
|
|
817
|
-
value: '
|
|
818
|
-
key: '
|
|
895
|
+
value: 'China',
|
|
896
|
+
key: 'China',
|
|
819
897
|
children: [
|
|
820
898
|
{
|
|
821
899
|
label: '北京',
|
|
@@ -845,7 +923,7 @@ describe('Cascader', () => {
|
|
|
845
923
|
it('onClear and showClear', () => {
|
|
846
924
|
const spyOnClear = sinon.spy(() => { });
|
|
847
925
|
const cascader = render({
|
|
848
|
-
defaultValue: ['
|
|
926
|
+
defaultValue: ['Asia', 'China', 'Beijing'],
|
|
849
927
|
showClear: true,
|
|
850
928
|
onClear: spyOnClear,
|
|
851
929
|
placeholder: "请选择所在地区"
|
|
@@ -989,25 +1067,25 @@ describe('Cascader', () => {
|
|
|
989
1067
|
defaultValue: [
|
|
990
1068
|
{
|
|
991
1069
|
label: '北美洲',
|
|
992
|
-
value: '
|
|
993
|
-
key: '
|
|
1070
|
+
value: 'North America',
|
|
1071
|
+
key: 'North America',
|
|
994
1072
|
children: [
|
|
995
1073
|
{
|
|
996
1074
|
label: '美国',
|
|
997
|
-
value: '
|
|
998
|
-
key: '
|
|
1075
|
+
value: 'United States',
|
|
1076
|
+
key: 'United States',
|
|
999
1077
|
},
|
|
1000
1078
|
{
|
|
1001
1079
|
label: '加拿大',
|
|
1002
|
-
value: '
|
|
1003
|
-
key: '
|
|
1080
|
+
value: 'Canada',
|
|
1081
|
+
key: 'Canada',
|
|
1004
1082
|
},
|
|
1005
1083
|
],
|
|
1006
1084
|
},
|
|
1007
1085
|
{
|
|
1008
1086
|
label: '美国',
|
|
1009
|
-
value: '
|
|
1010
|
-
key: '
|
|
1087
|
+
value: 'United States',
|
|
1088
|
+
key: 'United States',
|
|
1011
1089
|
}
|
|
1012
1090
|
]
|
|
1013
1091
|
});
|
|
@@ -1028,18 +1106,18 @@ describe('Cascader', () => {
|
|
|
1028
1106
|
treeData: [
|
|
1029
1107
|
{
|
|
1030
1108
|
label: '北美洲',
|
|
1031
|
-
value: '
|
|
1032
|
-
key: '
|
|
1109
|
+
value: 'North America',
|
|
1110
|
+
key: 'North America',
|
|
1033
1111
|
children: [
|
|
1034
1112
|
{
|
|
1035
1113
|
label: '美国',
|
|
1036
|
-
value: '
|
|
1037
|
-
key: '
|
|
1114
|
+
value: 'United States',
|
|
1115
|
+
key: 'United States',
|
|
1038
1116
|
},
|
|
1039
1117
|
{
|
|
1040
1118
|
label: '加拿大',
|
|
1041
|
-
value: '
|
|
1042
|
-
key: '
|
|
1119
|
+
value: 'Canada',
|
|
1120
|
+
key: 'Canada',
|
|
1043
1121
|
},
|
|
1044
1122
|
],
|
|
1045
1123
|
},
|
|
@@ -1096,18 +1174,18 @@ describe('Cascader', () => {
|
|
|
1096
1174
|
treeData: [
|
|
1097
1175
|
{
|
|
1098
1176
|
label: '北美洲',
|
|
1099
|
-
value: '
|
|
1100
|
-
key: '
|
|
1177
|
+
value: 'North America',
|
|
1178
|
+
key: 'North America',
|
|
1101
1179
|
children: [
|
|
1102
1180
|
{
|
|
1103
1181
|
label: '美国',
|
|
1104
|
-
value: '
|
|
1105
|
-
key: '
|
|
1182
|
+
value: 'United States',
|
|
1183
|
+
key: 'United States',
|
|
1106
1184
|
},
|
|
1107
1185
|
{
|
|
1108
1186
|
label: '加拿大',
|
|
1109
|
-
value: '
|
|
1110
|
-
key: '
|
|
1187
|
+
value: 'Canada',
|
|
1188
|
+
key: 'Canada',
|
|
1111
1189
|
},
|
|
1112
1190
|
],
|
|
1113
1191
|
},
|
|
@@ -1146,7 +1224,7 @@ describe('Cascader', () => {
|
|
|
1146
1224
|
it('separator', () => {
|
|
1147
1225
|
const cascader = render({
|
|
1148
1226
|
filterTreeNode: true,
|
|
1149
|
-
defaultValue: ['
|
|
1227
|
+
defaultValue: ['Asia', 'China', 'Beijing'],
|
|
1150
1228
|
separator: ' > ',
|
|
1151
1229
|
defaultOpen: true,
|
|
1152
1230
|
});
|
|
@@ -1169,7 +1247,7 @@ describe('Cascader', () => {
|
|
|
1169
1247
|
const cascaderAutoMerge = render({
|
|
1170
1248
|
multiple: true,
|
|
1171
1249
|
triggerRender: spyTriggerRender,
|
|
1172
|
-
defaultValue: '
|
|
1250
|
+
defaultValue: 'Asia'
|
|
1173
1251
|
});
|
|
1174
1252
|
cascaderAutoMerge.simulate('click');
|
|
1175
1253
|
const firstCall = spyTriggerRender.getCall(0);
|
|
@@ -1183,7 +1261,7 @@ describe('Cascader', () => {
|
|
|
1183
1261
|
const cascaderNoAutoMerge = render({
|
|
1184
1262
|
multiple: true,
|
|
1185
1263
|
triggerRender: spyTriggerRender2,
|
|
1186
|
-
defaultValue: '
|
|
1264
|
+
defaultValue: 'Asia',
|
|
1187
1265
|
autoMergeValue: false,
|
|
1188
1266
|
});
|
|
1189
1267
|
cascaderNoAutoMerge.simulate('click');
|
|
@@ -1199,7 +1277,7 @@ describe('Cascader', () => {
|
|
|
1199
1277
|
const cascader = render({
|
|
1200
1278
|
multiple: true,
|
|
1201
1279
|
autoMergeValue: false,
|
|
1202
|
-
defaultValue: '
|
|
1280
|
+
defaultValue: 'Asia',
|
|
1203
1281
|
});
|
|
1204
1282
|
const tags = cascader.find(`.${BASE_CLASS_PREFIX}-cascader-selection .${BASE_CLASS_PREFIX}-tag`)
|
|
1205
1283
|
expect(tags.length).toEqual(4);
|
|
@@ -1208,7 +1286,7 @@ describe('Cascader', () => {
|
|
|
1208
1286
|
const cascaderAutoMerge = render({
|
|
1209
1287
|
multiple: true,
|
|
1210
1288
|
autoMergeValue: true,
|
|
1211
|
-
defaultValue: '
|
|
1289
|
+
defaultValue: 'Asia',
|
|
1212
1290
|
});
|
|
1213
1291
|
const tags2 = cascaderAutoMerge.find(`.${BASE_CLASS_PREFIX}-cascader-selection .${BASE_CLASS_PREFIX}-tag`)
|
|
1214
1292
|
expect(tags2.length).toEqual(1);
|
|
@@ -1227,7 +1305,7 @@ describe('Cascader', () => {
|
|
|
1227
1305
|
multiple: true,
|
|
1228
1306
|
autoMergeValue: false,
|
|
1229
1307
|
leafOnly: false,
|
|
1230
|
-
defaultValue: '
|
|
1308
|
+
defaultValue: 'Asia',
|
|
1231
1309
|
});
|
|
1232
1310
|
const tags = cascader.find(`.${BASE_CLASS_PREFIX}-cascader-selection .${BASE_CLASS_PREFIX}-tag`)
|
|
1233
1311
|
expect(tags.length).toEqual(4);
|
|
@@ -1238,7 +1316,7 @@ describe('Cascader', () => {
|
|
|
1238
1316
|
multiple: true,
|
|
1239
1317
|
autoMergeValue: true,
|
|
1240
1318
|
leafOnly: true,
|
|
1241
|
-
defaultValue: '
|
|
1319
|
+
defaultValue: 'Asia',
|
|
1242
1320
|
});
|
|
1243
1321
|
const tags2 = cascader2.find(`.${BASE_CLASS_PREFIX}-cascader-selection .${BASE_CLASS_PREFIX}-tag`)
|
|
1244
1322
|
expect(tags2.length).toEqual(2);
|
|
@@ -1249,7 +1327,7 @@ describe('Cascader', () => {
|
|
|
1249
1327
|
multiple: true,
|
|
1250
1328
|
autoMergeValue: false,
|
|
1251
1329
|
leafOnly: true,
|
|
1252
|
-
defaultValue: '
|
|
1330
|
+
defaultValue: 'Asia',
|
|
1253
1331
|
});
|
|
1254
1332
|
const tags3 = cascader3.find(`.${BASE_CLASS_PREFIX}-cascader-selection .${BASE_CLASS_PREFIX}-tag`)
|
|
1255
1333
|
expect(tags3.length).toEqual(2);
|
|
@@ -1260,7 +1338,7 @@ describe('Cascader', () => {
|
|
|
1260
1338
|
multiple: true,
|
|
1261
1339
|
autoMergeValue: true,
|
|
1262
1340
|
leafOnly: false,
|
|
1263
|
-
defaultValue: '
|
|
1341
|
+
defaultValue: 'Asia',
|
|
1264
1342
|
});
|
|
1265
1343
|
const tags4 = cascader4.find(`.${BASE_CLASS_PREFIX}-cascader-selection .${BASE_CLASS_PREFIX}-tag`)
|
|
1266
1344
|
expect(tags4.length).toEqual(1);
|