@douyinfe/semi-ui 2.12.1-alpha.1 → 2.13.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/autoComplete/_story/autoComplete.stories.js +0 -1
- package/autoComplete/index.tsx +1 -1
- package/avatar/index.tsx +2 -2
- package/backtop/index.tsx +7 -11
- package/badge/index.tsx +1 -1
- package/banner/index.tsx +5 -5
- package/breadcrumb/index.tsx +3 -5
- package/button/Button.tsx +8 -10
- package/card/index.tsx +41 -43
- package/carousel/CarouselArrow.tsx +0 -2
- package/carousel/index.tsx +0 -1
- package/cascader/index.tsx +126 -102
- package/cascader/item.tsx +1 -1
- package/checkbox/checkbox.tsx +28 -20
- package/checkbox/checkboxInner.tsx +11 -1
- package/collapsible/index.tsx +1 -8
- package/datePicker/dateInput.tsx +0 -1
- package/datePicker/datePicker.tsx +5 -13
- package/dist/css/semi.css +31 -1
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +5321 -3696
- 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/divider/index.tsx +4 -8
- package/dropdown/index.tsx +1 -1
- package/empty/index.tsx +5 -13
- package/form/hoc/withField.tsx +1 -1
- package/form/label.tsx +1 -1
- package/grid/col.tsx +1 -1
- package/grid/row.tsx +1 -1
- package/gulpfile.js +5 -5
- package/iconButton/index.tsx +1 -2
- package/input/index.tsx +11 -38
- package/inputNumber/__test__/inputNumber.test.js +2 -3
- package/inputNumber/_story/inputNumber.stories.js +53 -0
- package/inputNumber/index.tsx +0 -4
- package/lib/cjs/_base/base.css +22 -0
- package/lib/cjs/autoComplete/index.js +1 -1
- package/lib/cjs/avatar/index.js +2 -4
- package/lib/cjs/backtop/index.js +1 -2
- package/lib/cjs/badge/index.js +1 -2
- package/lib/cjs/banner/index.js +4 -9
- package/lib/cjs/breadcrumb/index.js +3 -4
- package/lib/cjs/button/Button.js +3 -13
- package/lib/cjs/card/index.js +5 -10
- package/lib/cjs/carousel/CarouselArrow.js +2 -6
- package/lib/cjs/carousel/CarouselIndicator.d.ts +1 -1
- package/lib/cjs/carousel/index.d.ts +1 -1
- package/lib/cjs/carousel/index.js +1 -2
- package/lib/cjs/cascader/index.js +10 -11
- package/lib/cjs/cascader/item.js +1 -2
- package/lib/cjs/checkbox/checkbox.d.ts +3 -2
- package/lib/cjs/checkbox/checkbox.js +33 -15
- package/lib/cjs/checkbox/checkboxInner.d.ts +6 -0
- package/lib/cjs/checkbox/checkboxInner.js +14 -4
- package/lib/cjs/collapsible/index.js +1 -2
- package/lib/cjs/datePicker/dateInput.d.ts +1 -1
- package/lib/cjs/datePicker/dateInput.js +1 -2
- package/lib/cjs/datePicker/datePicker.d.ts +1 -1
- package/lib/cjs/datePicker/datePicker.js +2 -4
- package/lib/cjs/datePicker/monthsGrid.d.ts +1 -1
- package/lib/cjs/divider/index.js +1 -2
- package/lib/cjs/dropdown/index.js +1 -2
- package/lib/cjs/empty/index.js +4 -8
- package/lib/cjs/form/baseForm.d.ts +1 -1
- package/lib/cjs/form/field.d.ts +1 -1
- package/lib/cjs/form/hoc/withField.js +1 -2
- package/lib/cjs/form/label.js +1 -2
- package/lib/cjs/grid/col.js +1 -2
- package/lib/cjs/grid/row.js +1 -2
- package/lib/cjs/iconButton/index.js +1 -3
- package/lib/cjs/input/index.js +5 -9
- package/lib/cjs/inputNumber/index.js +0 -4
- package/lib/cjs/list/index.js +3 -6
- package/lib/cjs/modal/ConfirmModal.js +1 -2
- package/lib/cjs/modal/Modal.js +2 -6
- package/lib/cjs/modal/ModalContent.js +6 -13
- package/lib/cjs/notification/notice.js +3 -6
- package/lib/cjs/pagination/index.js +2 -4
- package/lib/cjs/popconfirm/index.js +3 -6
- package/lib/cjs/popover/index.d.ts +1 -0
- package/lib/cjs/radio/radio.d.ts +1 -1
- package/lib/cjs/radio/radio.js +2 -4
- package/lib/cjs/radio/radioGroup.d.ts +1 -1
- package/lib/cjs/rating/item.js +1 -2
- package/lib/cjs/scrollList/index.js +3 -6
- package/lib/cjs/select/index.js +4 -8
- package/lib/cjs/select/option.js +1 -2
- package/lib/cjs/sideSheet/SideSheetContent.js +3 -6
- package/lib/cjs/skeleton/index.js +1 -3
- package/lib/cjs/space/index.js +1 -2
- package/lib/cjs/spin/index.js +3 -7
- package/lib/cjs/switch/index.js +4 -6
- package/lib/cjs/table/Table.js +3 -6
- package/lib/cjs/tabs/TabBar.js +1 -2
- package/lib/cjs/tabs/TabPane.js +2 -5
- package/lib/cjs/tagInput/index.d.ts +6 -1
- package/lib/cjs/tagInput/index.js +50 -17
- package/lib/cjs/timePicker/Combobox.js +1 -3
- package/lib/cjs/timePicker/TimePicker.d.ts +2 -2
- package/lib/cjs/timePicker/TimeShape.d.ts +1 -1
- package/lib/cjs/timePicker/index.d.ts +2 -2
- package/lib/cjs/toast/toast.js +3 -6
- package/lib/cjs/transfer/index.js +1 -2
- package/lib/cjs/tree/treeNode.js +1 -2
- package/lib/cjs/treeSelect/index.js +3 -6
- package/lib/cjs/typography/base.js +1 -2
- package/lib/cjs/typography/title.d.ts +1 -1
- package/lib/cjs/upload/index.d.ts +2 -2
- package/lib/cjs/upload/index.js +6 -13
- package/lib/es/_base/base.css +22 -0
- package/lib/es/autoComplete/index.js +1 -1
- package/lib/es/avatar/index.js +2 -4
- package/lib/es/backtop/index.js +1 -2
- package/lib/es/badge/index.js +1 -2
- package/lib/es/banner/index.js +4 -9
- package/lib/es/breadcrumb/index.js +3 -4
- package/lib/es/button/Button.js +3 -11
- package/lib/es/card/index.js +5 -10
- package/lib/es/carousel/CarouselArrow.js +2 -6
- package/lib/es/carousel/CarouselIndicator.d.ts +1 -1
- package/lib/es/carousel/index.d.ts +1 -1
- package/lib/es/carousel/index.js +1 -2
- package/lib/es/cascader/index.js +10 -11
- package/lib/es/cascader/item.js +1 -2
- package/lib/es/checkbox/checkbox.d.ts +3 -2
- package/lib/es/checkbox/checkbox.js +33 -15
- package/lib/es/checkbox/checkboxInner.d.ts +6 -0
- package/lib/es/checkbox/checkboxInner.js +14 -4
- package/lib/es/collapsible/index.js +1 -2
- package/lib/es/datePicker/dateInput.d.ts +1 -1
- package/lib/es/datePicker/dateInput.js +1 -2
- package/lib/es/datePicker/datePicker.d.ts +1 -1
- package/lib/es/datePicker/datePicker.js +2 -4
- package/lib/es/datePicker/monthsGrid.d.ts +1 -1
- package/lib/es/divider/index.js +1 -2
- package/lib/es/dropdown/index.js +1 -2
- package/lib/es/empty/index.js +4 -8
- package/lib/es/form/baseForm.d.ts +1 -1
- package/lib/es/form/field.d.ts +1 -1
- package/lib/es/form/hoc/withField.js +1 -2
- package/lib/es/form/label.js +1 -2
- package/lib/es/grid/col.js +1 -2
- package/lib/es/grid/row.js +1 -2
- package/lib/es/iconButton/index.js +1 -3
- package/lib/es/input/index.js +5 -9
- package/lib/es/inputNumber/index.js +0 -4
- package/lib/es/list/index.js +3 -6
- package/lib/es/modal/ConfirmModal.js +1 -2
- package/lib/es/modal/Modal.js +2 -6
- package/lib/es/modal/ModalContent.js +6 -13
- package/lib/es/notification/notice.js +3 -6
- package/lib/es/pagination/index.js +2 -4
- package/lib/es/popconfirm/index.js +3 -6
- package/lib/es/popover/index.d.ts +1 -0
- package/lib/es/radio/radio.d.ts +1 -1
- package/lib/es/radio/radio.js +2 -4
- package/lib/es/radio/radioGroup.d.ts +1 -1
- package/lib/es/rating/item.js +1 -2
- package/lib/es/scrollList/index.js +3 -6
- package/lib/es/select/index.js +4 -8
- package/lib/es/select/option.js +1 -2
- package/lib/es/sideSheet/SideSheetContent.js +3 -6
- package/lib/es/skeleton/index.js +1 -3
- package/lib/es/space/index.js +1 -2
- package/lib/es/spin/index.js +3 -7
- package/lib/es/switch/index.js +4 -6
- package/lib/es/table/Table.js +3 -6
- package/lib/es/tabs/TabBar.js +1 -2
- package/lib/es/tabs/TabPane.js +2 -5
- package/lib/es/tagInput/index.d.ts +6 -1
- package/lib/es/tagInput/index.js +47 -17
- package/lib/es/timePicker/Combobox.js +1 -3
- package/lib/es/timePicker/TimePicker.d.ts +2 -2
- package/lib/es/timePicker/TimeShape.d.ts +1 -1
- package/lib/es/timePicker/index.d.ts +2 -2
- package/lib/es/toast/toast.js +3 -6
- package/lib/es/transfer/index.js +1 -2
- package/lib/es/tree/treeNode.js +1 -2
- package/lib/es/treeSelect/index.js +3 -6
- package/lib/es/typography/base.js +1 -2
- package/lib/es/typography/title.d.ts +1 -1
- package/lib/es/upload/index.d.ts +2 -2
- package/lib/es/upload/index.js +6 -13
- package/list/index.tsx +4 -16
- package/modal/ConfirmModal.tsx +1 -1
- package/modal/Modal.tsx +0 -2
- package/modal/ModalContent.tsx +14 -27
- package/notification/notice.tsx +4 -16
- package/package.json +9 -9
- package/pagination/index.tsx +2 -16
- package/popconfirm/index.tsx +3 -11
- package/popover/index.tsx +1 -1
- package/radio/radio.tsx +2 -10
- package/rating/item.tsx +1 -1
- package/scrollList/index.tsx +3 -19
- package/select/_story/select.stories.js +11 -0
- package/select/index.tsx +4 -12
- package/select/option.tsx +1 -5
- package/sideSheet/SideSheetContent.tsx +3 -3
- package/skeleton/index.tsx +1 -1
- package/space/index.tsx +1 -1
- package/spin/index.tsx +9 -15
- package/switch/index.tsx +14 -9
- package/table/Table.tsx +3 -5
- package/table/_story/v2/FixedOnHeaderRow/index.jsx +3 -0
- package/tabs/TabBar.tsx +1 -1
- package/tabs/TabPane.tsx +4 -9
- package/tabs/_story/tabs.stories.js +36 -0
- package/tag/_story/tag.stories.js +1 -1
- package/tagInput/index.tsx +47 -22
- package/timePicker/Combobox.tsx +1 -6
- package/toast/toast.tsx +3 -3
- package/transfer/index.tsx +0 -1
- package/tree/treeNode.tsx +1 -1
- package/treeSelect/index.tsx +3 -15
- package/typography/base.tsx +1 -1
- package/upload/_story/upload.stories.js +152 -0
- package/upload/index.tsx +38 -107
- package/yarn-error.log +0 -26235
package/cascader/index.tsx
CHANGED
|
@@ -122,7 +122,7 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
122
122
|
PropTypes.shape({
|
|
123
123
|
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
124
124
|
label: PropTypes.any,
|
|
125
|
-
})
|
|
125
|
+
}),
|
|
126
126
|
),
|
|
127
127
|
treeNodeFilterProp: PropTypes.string,
|
|
128
128
|
suffix: PropTypes.node,
|
|
@@ -199,7 +199,7 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
199
199
|
onDropdownVisibleChange: noop,
|
|
200
200
|
onListScroll: noop,
|
|
201
201
|
enableLeafClick: false,
|
|
202
|
-
'aria-label': 'Cascader'
|
|
202
|
+
'aria-label': 'Cascader'
|
|
203
203
|
};
|
|
204
204
|
|
|
205
205
|
options: any;
|
|
@@ -247,7 +247,7 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
247
247
|
/* Keys of loading item */
|
|
248
248
|
loadingKeys: new Set(),
|
|
249
249
|
/* Mark whether this rendering has triggered asynchronous loading of data */
|
|
250
|
-
loading: false
|
|
250
|
+
loading: false
|
|
251
251
|
};
|
|
252
252
|
this.options = {};
|
|
253
253
|
this.isEmpty = false;
|
|
@@ -274,9 +274,10 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
274
274
|
}
|
|
275
275
|
},
|
|
276
276
|
};
|
|
277
|
-
const cascaderAdapter: Pick<
|
|
278
|
-
|
|
279
|
-
|
|
277
|
+
const cascaderAdapter: Pick<CascaderAdapter,
|
|
278
|
+
'registerClickOutsideHandler'
|
|
279
|
+
| 'unregisterClickOutsideHandler'
|
|
280
|
+
| 'rePositionDropdown'
|
|
280
281
|
> = {
|
|
281
282
|
registerClickOutsideHandler: cb => {
|
|
282
283
|
const clickOutsideHandler = (e: Event) => {
|
|
@@ -367,10 +368,17 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
367
368
|
}
|
|
368
369
|
|
|
369
370
|
static getDerivedStateFromProps(props: CascaderProps, prevState: CascaderState) {
|
|
370
|
-
const {
|
|
371
|
+
const {
|
|
372
|
+
multiple,
|
|
373
|
+
value,
|
|
374
|
+
defaultValue,
|
|
375
|
+
onChangeWithObject,
|
|
376
|
+
leafOnly,
|
|
377
|
+
autoMergeValue,
|
|
378
|
+
} = props;
|
|
371
379
|
const { prevProps } = prevState;
|
|
372
380
|
let keyEntities = prevState.keyEntities || {};
|
|
373
|
-
const newState: Partial<CascaderState> = {};
|
|
381
|
+
const newState: Partial<CascaderState> = { };
|
|
374
382
|
const needUpdate = (name: string) => {
|
|
375
383
|
const firstInProps = isEmpty(prevProps) && name in props;
|
|
376
384
|
const nameHasChange = prevProps && !isEqual(prevProps[name], props[name]);
|
|
@@ -400,18 +408,20 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
400
408
|
const realValue = needUpdate('value') ? value : defaultValue;
|
|
401
409
|
// eslint-disable-next-line max-depth
|
|
402
410
|
if (Array.isArray(realValue)) {
|
|
403
|
-
normallizedValue = Array.isArray(realValue[0])
|
|
404
|
-
|
|
405
|
-
|
|
411
|
+
normallizedValue = Array.isArray(realValue[0]) ?
|
|
412
|
+
realValue as SimpleValueType[][] :
|
|
413
|
+
[realValue] as SimpleValueType[][];
|
|
406
414
|
} else {
|
|
407
|
-
|
|
415
|
+
if (realValue !== undefined) {
|
|
416
|
+
normallizedValue = [[realValue]];
|
|
417
|
+
}
|
|
408
418
|
}
|
|
409
419
|
// formatValuePath is used to save value of valuePath
|
|
410
420
|
const formatValuePath: (string | number)[][] = [];
|
|
411
421
|
normallizedValue.forEach((valueItem: SimpleValueType[]) => {
|
|
412
|
-
const formatItem: (string | number)[] = onChangeWithObject
|
|
413
|
-
|
|
414
|
-
|
|
422
|
+
const formatItem: (string | number)[] = onChangeWithObject ?
|
|
423
|
+
(valueItem as CascaderData[]).map(i => i?.value) :
|
|
424
|
+
valueItem as (string | number)[];
|
|
415
425
|
formatValuePath.push(formatItem);
|
|
416
426
|
});
|
|
417
427
|
// formatKeys is used to save key of value
|
|
@@ -472,9 +482,12 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
472
482
|
renderTagItem = (value: string | Array<string>, idx: number, type: string) => {
|
|
473
483
|
const { keyEntities, disabledKeys } = this.state;
|
|
474
484
|
const { size, disabled, displayProp, displayRender, disableStrictly } = this.props;
|
|
475
|
-
const nodeKey = type === strings.IS_VALUE ?
|
|
476
|
-
|
|
477
|
-
|
|
485
|
+
const nodeKey = type === strings.IS_VALUE ?
|
|
486
|
+
findKeysForValues(value, keyEntities)[0] :
|
|
487
|
+
value;
|
|
488
|
+
const isDsiabled = disabled ||
|
|
489
|
+
keyEntities[nodeKey].data.disabled ||
|
|
490
|
+
(disableStrictly && disabledKeys.has(nodeKey));
|
|
478
491
|
if (!isEmpty(keyEntities) && !isEmpty(keyEntities[nodeKey])) {
|
|
479
492
|
const tagCls = cls(`${prefixcls}-selection-tag`, {
|
|
480
493
|
[`${prefixcls}-selection-tag-disabled`]: isDsiabled,
|
|
@@ -482,7 +495,7 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
482
495
|
// custom render tags
|
|
483
496
|
if (isFunction(displayRender)) {
|
|
484
497
|
return displayRender(keyEntities[nodeKey], idx);
|
|
485
|
-
|
|
498
|
+
// default render tags
|
|
486
499
|
} else {
|
|
487
500
|
return (
|
|
488
501
|
<Tag
|
|
@@ -506,11 +519,25 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
506
519
|
};
|
|
507
520
|
|
|
508
521
|
renderTagInput() {
|
|
509
|
-
const {
|
|
510
|
-
|
|
522
|
+
const {
|
|
523
|
+
size,
|
|
524
|
+
disabled,
|
|
525
|
+
placeholder,
|
|
526
|
+
maxTagCount,
|
|
527
|
+
showRestTagsPopover,
|
|
528
|
+
restTagsPopoverProps,
|
|
529
|
+
} = this.props;
|
|
530
|
+
const {
|
|
531
|
+
inputValue,
|
|
532
|
+
checkedKeys,
|
|
533
|
+
keyEntities,
|
|
534
|
+
resolvedCheckedKeys
|
|
535
|
+
} = this.state;
|
|
511
536
|
const tagInputcls = cls(`${prefixcls}-tagInput-wrapper`);
|
|
512
537
|
const tagValue: Array<Array<string>> = [];
|
|
513
|
-
const realKeys = this.mergeType === strings.NONE_MERGE_TYPE
|
|
538
|
+
const realKeys = this.mergeType === strings.NONE_MERGE_TYPE
|
|
539
|
+
? checkedKeys
|
|
540
|
+
: resolvedCheckedKeys;
|
|
514
541
|
[...realKeys].forEach(checkedKey => {
|
|
515
542
|
if (!isEmpty(keyEntities[checkedKey])) {
|
|
516
543
|
tagValue.push(keyEntities[checkedKey].valuePath);
|
|
@@ -523,7 +550,7 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
523
550
|
disabled={disabled}
|
|
524
551
|
size={size}
|
|
525
552
|
// TODO Modify logic, not modify type
|
|
526
|
-
value={
|
|
553
|
+
value={tagValue as unknown as string[]}
|
|
527
554
|
showRestTagsPopover={showRestTagsPopover}
|
|
528
555
|
restTagsPopoverProps={restTagsPopoverProps}
|
|
529
556
|
maxTagCount={maxTagCount}
|
|
@@ -531,7 +558,7 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
531
558
|
inputValue={inputValue}
|
|
532
559
|
onInputChange={this.handleInputChange}
|
|
533
560
|
// TODO Modify logic, not modify type
|
|
534
|
-
onRemove={v => this.handleTagRemove(null,
|
|
561
|
+
onRemove={v => this.handleTagRemove(null, v as unknown as (string | number)[])}
|
|
535
562
|
placeholder={placeholder}
|
|
536
563
|
/>
|
|
537
564
|
);
|
|
@@ -553,7 +580,11 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
553
580
|
});
|
|
554
581
|
return (
|
|
555
582
|
<div className={wrappercls}>
|
|
556
|
-
<Input
|
|
583
|
+
<Input
|
|
584
|
+
ref={this.inputRef as any}
|
|
585
|
+
size={size}
|
|
586
|
+
{...inputProps}
|
|
587
|
+
/>
|
|
557
588
|
</div>
|
|
558
589
|
);
|
|
559
590
|
}
|
|
@@ -583,7 +614,7 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
583
614
|
checkedKeys,
|
|
584
615
|
halfCheckedKeys,
|
|
585
616
|
loadedKeys,
|
|
586
|
-
loadingKeys
|
|
617
|
+
loadingKeys
|
|
587
618
|
} = this.state;
|
|
588
619
|
const {
|
|
589
620
|
filterTreeNode,
|
|
@@ -595,7 +626,7 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
595
626
|
topSlot,
|
|
596
627
|
bottomSlot,
|
|
597
628
|
showNext,
|
|
598
|
-
multiple
|
|
629
|
+
multiple
|
|
599
630
|
} = this.props;
|
|
600
631
|
const searchable = Boolean(filterTreeNode) && isSearching;
|
|
601
632
|
const popoverCls = cls(dropdownClassName, `${prefixcls}-popover`);
|
|
@@ -632,29 +663,37 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
632
663
|
renderPlusN = (hiddenTag: Array<ReactNode>) => {
|
|
633
664
|
const { disabled, showRestTagsPopover, restTagsPopoverProps } = this.props;
|
|
634
665
|
const plusNCls = cls(`${prefixcls}-selection-n`, {
|
|
635
|
-
[`${prefixcls}-selection-n-disabled`]: disabled
|
|
666
|
+
[`${prefixcls}-selection-n-disabled`]: disabled
|
|
636
667
|
});
|
|
637
|
-
const renderPlusNChildren =
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
668
|
+
const renderPlusNChildren = (
|
|
669
|
+
<span className={plusNCls}>
|
|
670
|
+
+{hiddenTag.length}
|
|
671
|
+
</span>
|
|
672
|
+
);
|
|
673
|
+
return (
|
|
674
|
+
showRestTagsPopover && !disabled ?
|
|
675
|
+
(
|
|
676
|
+
<Popover
|
|
677
|
+
content={hiddenTag}
|
|
678
|
+
showArrow
|
|
679
|
+
trigger="hover"
|
|
680
|
+
position="top"
|
|
681
|
+
autoAdjustOverflow
|
|
682
|
+
{...restTagsPopoverProps}
|
|
683
|
+
>
|
|
684
|
+
{renderPlusNChildren}
|
|
685
|
+
</Popover>
|
|
686
|
+
) :
|
|
687
|
+
renderPlusNChildren
|
|
651
688
|
);
|
|
652
689
|
};
|
|
653
690
|
|
|
654
691
|
renderMultipleTags = () => {
|
|
655
692
|
const { autoMergeValue, maxTagCount } = this.props;
|
|
656
693
|
const { checkedKeys, resolvedCheckedKeys } = this.state;
|
|
657
|
-
const realKeys = this.mergeType === strings.NONE_MERGE_TYPE
|
|
694
|
+
const realKeys = this.mergeType === strings.NONE_MERGE_TYPE
|
|
695
|
+
? checkedKeys
|
|
696
|
+
: resolvedCheckedKeys;
|
|
658
697
|
const displayTag: Array<ReactNode> = [];
|
|
659
698
|
const hiddenTag: Array<ReactNode> = [];
|
|
660
699
|
[...realKeys].forEach((checkedKey, idx) => {
|
|
@@ -683,22 +722,19 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
683
722
|
if (displayRender && typeof displayRender === 'function') {
|
|
684
723
|
displayText = displayRender(displayPath);
|
|
685
724
|
} else {
|
|
686
|
-
displayText = displayPath.map((path: ReactNode, index: number)
|
|
725
|
+
displayText = displayPath.map((path: ReactNode, index: number)=>(
|
|
687
726
|
<Fragment key={`${path}-${index}`}>
|
|
688
|
-
{
|
|
689
|
-
|
|
690
|
-
{path}
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
) : (
|
|
694
|
-
path
|
|
695
|
-
)}
|
|
727
|
+
{
|
|
728
|
+
index<displayPath.length-1
|
|
729
|
+
? <>{path}{separator}</>
|
|
730
|
+
: path
|
|
731
|
+
}
|
|
696
732
|
</Fragment>
|
|
697
733
|
));
|
|
698
734
|
}
|
|
699
735
|
}
|
|
700
736
|
return displayText;
|
|
701
|
-
}
|
|
737
|
+
}
|
|
702
738
|
|
|
703
739
|
renderSelectContent = () => {
|
|
704
740
|
const { placeholder, filterTreeNode, multiple } = this.props;
|
|
@@ -729,11 +765,7 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
729
765
|
[`${prefixcls}-suffix-text`]: suffix && isString(suffix),
|
|
730
766
|
[`${prefixcls}-suffix-icon`]: isSemiIcon(suffix),
|
|
731
767
|
});
|
|
732
|
-
return
|
|
733
|
-
<div className={suffixWrapperCls} x-semi-prop="suffix">
|
|
734
|
-
{suffix}
|
|
735
|
-
</div>
|
|
736
|
-
);
|
|
768
|
+
return <div className={suffixWrapperCls}>{suffix}</div>;
|
|
737
769
|
};
|
|
738
770
|
|
|
739
771
|
renderPrefix = () => {
|
|
@@ -748,11 +780,7 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
748
780
|
[`${prefixcls}-prefix-icon`]: isSemiIcon(labelNode),
|
|
749
781
|
});
|
|
750
782
|
|
|
751
|
-
return
|
|
752
|
-
<div className={prefixWrapperCls} id={insetLabelId} x-semi-prop="prefix,insetLabel">
|
|
753
|
-
{labelNode}
|
|
754
|
-
</div>
|
|
755
|
-
);
|
|
783
|
+
return <div className={prefixWrapperCls} id={insetLabelId}>{labelNode}</div>;
|
|
756
784
|
};
|
|
757
785
|
|
|
758
786
|
renderCustomTrigger = () => {
|
|
@@ -821,7 +849,7 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
821
849
|
className={clearCls}
|
|
822
850
|
onClick={this.handleClear}
|
|
823
851
|
onKeyPress={this.handleClearEnterPress}
|
|
824
|
-
role=
|
|
852
|
+
role='button'
|
|
825
853
|
tabIndex={0}
|
|
826
854
|
>
|
|
827
855
|
<IconClear />
|
|
@@ -837,11 +865,7 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
837
865
|
if (showClearBtn) {
|
|
838
866
|
return null;
|
|
839
867
|
}
|
|
840
|
-
return arrowIcon ? (
|
|
841
|
-
<div className={cls(`${prefixcls}-arrow`)} x-semi-prop="arrowIcon">
|
|
842
|
-
{arrowIcon}
|
|
843
|
-
</div>
|
|
844
|
-
) : null;
|
|
868
|
+
return arrowIcon ? <div className={cls(`${prefixcls}-arrow`)}>{arrowIcon}</div> : null;
|
|
845
869
|
};
|
|
846
870
|
|
|
847
871
|
renderSelection = () => {
|
|
@@ -863,40 +887,40 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
863
887
|
const { isOpen, isFocus, isInput, checkedKeys } = this.state;
|
|
864
888
|
const filterable = Boolean(filterTreeNode);
|
|
865
889
|
const useCustomTrigger = typeof triggerRender === 'function';
|
|
866
|
-
const classNames = useCustomTrigger
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
const mouseEvent = showClear
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
890
|
+
const classNames = useCustomTrigger ?
|
|
891
|
+
cls(className) :
|
|
892
|
+
cls(prefixcls, className, {
|
|
893
|
+
[`${prefixcls}-focus`]: isFocus || (isOpen && !isInput),
|
|
894
|
+
[`${prefixcls}-disabled`]: disabled,
|
|
895
|
+
[`${prefixcls}-single`]: true,
|
|
896
|
+
[`${prefixcls}-filterable`]: filterable,
|
|
897
|
+
[`${prefixcls}-error`]: validateStatus === 'error',
|
|
898
|
+
[`${prefixcls}-warning`]: validateStatus === 'warning',
|
|
899
|
+
[`${prefixcls}-small`]: size === 'small',
|
|
900
|
+
[`${prefixcls}-large`]: size === 'large',
|
|
901
|
+
[`${prefixcls}-with-prefix`]: prefix || insetLabel,
|
|
902
|
+
[`${prefixcls}-with-suffix`]: suffix,
|
|
903
|
+
});
|
|
904
|
+
const mouseEvent = showClear ?
|
|
905
|
+
{
|
|
906
|
+
onMouseEnter: () => this.handleMouseOver(),
|
|
907
|
+
onMouseLeave: () => this.handleMouseLeave(),
|
|
908
|
+
} :
|
|
909
|
+
{};
|
|
886
910
|
const sectionCls = cls(`${prefixcls}-selection`, {
|
|
887
911
|
[`${prefixcls}-selection-multiple`]: multiple && !isEmpty(checkedKeys),
|
|
888
912
|
});
|
|
889
|
-
const inner = useCustomTrigger
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
913
|
+
const inner = useCustomTrigger ?
|
|
914
|
+
this.renderCustomTrigger() :
|
|
915
|
+
[
|
|
916
|
+
<Fragment key={'prefix'}>{prefix || insetLabel ? this.renderPrefix() : null}</Fragment>,
|
|
917
|
+
<Fragment key={'selection'}>
|
|
918
|
+
<div className={sectionCls}>{this.renderSelectContent()}</div>
|
|
919
|
+
</Fragment>,
|
|
920
|
+
<Fragment key={'clearbtn'}>{this.renderClearBtn()}</Fragment>,
|
|
921
|
+
<Fragment key={'suffix'}>{suffix ? this.renderSuffix() : null}</Fragment>,
|
|
922
|
+
<Fragment key={'arrow'}>{this.renderArrow()}</Fragment>,
|
|
923
|
+
];
|
|
900
924
|
/**
|
|
901
925
|
* Reasons for disabling the a11y eslint rule:
|
|
902
926
|
* The following attributes(aria-controls,aria-expanded) will be automatically added by Tooltip, no need to declare here
|
|
@@ -912,12 +936,12 @@ class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
912
936
|
aria-errormessage={this.props['aria-errormessage']}
|
|
913
937
|
aria-label={this.props['aria-label']}
|
|
914
938
|
aria-labelledby={this.props['aria-labelledby']}
|
|
915
|
-
aria-describedby={this.props[
|
|
939
|
+
aria-describedby={this.props["aria-describedby"]}
|
|
916
940
|
aria-required={this.props['aria-required']}
|
|
917
941
|
id={id}
|
|
918
942
|
{...mouseEvent}
|
|
919
943
|
// eslint-disable-next-line jsx-a11y/role-has-required-aria-props
|
|
920
|
-
role=
|
|
944
|
+
role='combobox'
|
|
921
945
|
tabIndex={0}
|
|
922
946
|
>
|
|
923
947
|
{inner}
|
package/cascader/item.tsx
CHANGED
|
@@ -291,7 +291,7 @@ export default class Item extends PureComponent<CascaderItemProps> {
|
|
|
291
291
|
<LocaleConsumer componentName="Cascader">
|
|
292
292
|
{(locale: Locale['Cascader']) => (
|
|
293
293
|
<ul className={`${prefixcls} ${prefixcls}-empty`} key={'empty-list'}>
|
|
294
|
-
<span className={`${prefixcls}-label`}
|
|
294
|
+
<span className={`${prefixcls}-label`}>
|
|
295
295
|
{emptyContent || locale.emptyText}
|
|
296
296
|
</span>
|
|
297
297
|
</ul>
|
package/checkbox/checkbox.tsx
CHANGED
|
@@ -36,6 +36,7 @@ interface CheckboxState {
|
|
|
36
36
|
checked: boolean;
|
|
37
37
|
addonId?: string;
|
|
38
38
|
extraId?: string;
|
|
39
|
+
focusVisible?: boolean;
|
|
39
40
|
}
|
|
40
41
|
class Checkbox extends BaseComponent<CheckboxProps, CheckboxState> {
|
|
41
42
|
static contextType = Context;
|
|
@@ -99,13 +100,17 @@ class Checkbox extends BaseComponent<CheckboxProps, CheckboxState> {
|
|
|
99
100
|
},
|
|
100
101
|
setExtraId: () => {
|
|
101
102
|
this.setState({ extraId: getUuidShort({ prefix: 'extra' }) });
|
|
102
|
-
}
|
|
103
|
+
},
|
|
104
|
+
setFocusVisible: (focusVisible: boolean): void => {
|
|
105
|
+
this.setState({ focusVisible });
|
|
106
|
+
},
|
|
107
|
+
focusCheckboxEntity: () => {
|
|
108
|
+
this.focus();
|
|
109
|
+
},
|
|
103
110
|
};
|
|
104
111
|
}
|
|
105
112
|
|
|
106
113
|
foundation: CheckboxFoundation;
|
|
107
|
-
addonId: string;
|
|
108
|
-
extraId: string;
|
|
109
114
|
constructor(props: CheckboxProps) {
|
|
110
115
|
super(props);
|
|
111
116
|
|
|
@@ -115,6 +120,7 @@ class Checkbox extends BaseComponent<CheckboxProps, CheckboxState> {
|
|
|
115
120
|
checked: props.checked || props.defaultChecked || checked,
|
|
116
121
|
addonId: props.addonId,
|
|
117
122
|
extraId: props.extraId,
|
|
123
|
+
focusVisible: false
|
|
118
124
|
};
|
|
119
125
|
|
|
120
126
|
this.checkboxEntity = null;
|
|
@@ -147,6 +153,14 @@ class Checkbox extends BaseComponent<CheckboxProps, CheckboxState> {
|
|
|
147
153
|
|
|
148
154
|
handleEnterPress = (e: React.KeyboardEvent<HTMLSpanElement>) => this.foundation.handleEnterPress(e);
|
|
149
155
|
|
|
156
|
+
handleFocusVisible = (event: React.FocusEvent) => {
|
|
157
|
+
this.foundation.handleFocusVisible(event);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
handleBlur = (event: React.FocusEvent) => {
|
|
161
|
+
this.foundation.handleBlur();
|
|
162
|
+
}
|
|
163
|
+
|
|
150
164
|
render() {
|
|
151
165
|
const {
|
|
152
166
|
disabled,
|
|
@@ -163,7 +177,7 @@ class Checkbox extends BaseComponent<CheckboxProps, CheckboxState> {
|
|
|
163
177
|
tabIndex,
|
|
164
178
|
id
|
|
165
179
|
} = this.props;
|
|
166
|
-
const { checked, addonId, extraId } = this.state;
|
|
180
|
+
const { checked, addonId, extraId, focusVisible } = this.state;
|
|
167
181
|
const props: Record<string, any> = {
|
|
168
182
|
checked,
|
|
169
183
|
disabled,
|
|
@@ -186,6 +200,8 @@ class Checkbox extends BaseComponent<CheckboxProps, CheckboxState> {
|
|
|
186
200
|
|
|
187
201
|
const prefix = prefixCls || css.PREFIX;
|
|
188
202
|
|
|
203
|
+
const focusOuter = props.isCardType || props.isPureCardType;
|
|
204
|
+
|
|
189
205
|
const wrapper = classnames(prefix, {
|
|
190
206
|
[`${prefix}-disabled`]: props.disabled,
|
|
191
207
|
[`${prefix}-indeterminate`]: indeterminate,
|
|
@@ -197,32 +213,21 @@ class Checkbox extends BaseComponent<CheckboxProps, CheckboxState> {
|
|
|
197
213
|
[`${prefix}-cardType_checked`]: props.isCardType && props.checked && !props.disabled,
|
|
198
214
|
[`${prefix}-cardType_checked_disabled`]: props.isCardType && props.checked && props.disabled,
|
|
199
215
|
[className]: Boolean(className),
|
|
216
|
+
[`${prefix}-focus`]: focusVisible && focusOuter,
|
|
200
217
|
});
|
|
201
218
|
|
|
202
219
|
const extraCls = classnames(`${prefix}-extra`, {
|
|
203
220
|
[`${prefix}-cardType_extra_noChildren`]: props.isCardType && !children,
|
|
204
221
|
});
|
|
205
222
|
|
|
206
|
-
const name = inGroup && this.context.checkboxGroup.name;
|
|
207
|
-
const xSemiPropChildren = this.props['x-semi-children-alias'] || 'children';
|
|
208
|
-
|
|
209
223
|
const renderContent = () => (
|
|
210
224
|
<>
|
|
211
|
-
{children ?
|
|
212
|
-
|
|
213
|
-
{children}
|
|
214
|
-
</span>
|
|
215
|
-
) : null}
|
|
216
|
-
{extra ? (
|
|
217
|
-
<div id={this.extraId} className={extraCls} x-semi-prop="extra">
|
|
218
|
-
{extra}
|
|
219
|
-
</div>
|
|
220
|
-
) : null}
|
|
225
|
+
{children ? <span id={addonId} className={`${prefix}-addon`}>{children}</span> : null}
|
|
226
|
+
{extra ? <div id={extraId} className={extraCls}>{extra}</div> : null}
|
|
221
227
|
</>
|
|
222
228
|
);
|
|
223
229
|
return (
|
|
224
230
|
// label is better than span, however span is here which is to solve gitlab issue #364
|
|
225
|
-
// eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions
|
|
226
231
|
<span
|
|
227
232
|
role={role}
|
|
228
233
|
tabIndex={tabIndex}
|
|
@@ -238,12 +243,15 @@ class Checkbox extends BaseComponent<CheckboxProps, CheckboxState> {
|
|
|
238
243
|
<CheckboxInner
|
|
239
244
|
{...this.props}
|
|
240
245
|
{...props}
|
|
241
|
-
addonId={children &&
|
|
242
|
-
extraId={extra &&
|
|
246
|
+
addonId={children && addonId}
|
|
247
|
+
extraId={extra && extraId}
|
|
243
248
|
isPureCardType={props.isPureCardType}
|
|
244
249
|
ref={ref => {
|
|
245
250
|
this.checkboxEntity = ref;
|
|
246
251
|
}}
|
|
252
|
+
focusInner={focusVisible && !focusOuter}
|
|
253
|
+
onInputFocus={this.handleFocusVisible}
|
|
254
|
+
onInputBlur={this.handleBlur}
|
|
247
255
|
/>
|
|
248
256
|
{
|
|
249
257
|
props.isCardType ?
|
|
@@ -23,6 +23,9 @@ export interface CheckboxInnerProps {
|
|
|
23
23
|
addonId?: string;
|
|
24
24
|
extraId?: string;
|
|
25
25
|
'aria-label'?: React.AriaAttributes['aria-label'];
|
|
26
|
+
focusInner?: boolean;
|
|
27
|
+
onInputFocus?: (e: any) => void;
|
|
28
|
+
onInputBlur?: (e: any) => void;
|
|
26
29
|
}
|
|
27
30
|
|
|
28
31
|
class CheckboxInner extends PureComponent<CheckboxInnerProps> {
|
|
@@ -43,6 +46,9 @@ class CheckboxInner extends PureComponent<CheckboxInnerProps> {
|
|
|
43
46
|
isPureCardType: PropTypes.bool,
|
|
44
47
|
addonId: PropTypes.string,
|
|
45
48
|
extraId: PropTypes.string,
|
|
49
|
+
focusInner: PropTypes.bool,
|
|
50
|
+
onInputFocus: PropTypes.func,
|
|
51
|
+
onInputBlur: PropTypes.func,
|
|
46
52
|
};
|
|
47
53
|
|
|
48
54
|
static defaultProps = {
|
|
@@ -59,7 +65,7 @@ class CheckboxInner extends PureComponent<CheckboxInnerProps> {
|
|
|
59
65
|
}
|
|
60
66
|
|
|
61
67
|
render() {
|
|
62
|
-
const { indeterminate, checked, disabled, prefixCls, name, isPureCardType, addonId, extraId } = this.props;
|
|
68
|
+
const { indeterminate, checked, disabled, prefixCls, name, isPureCardType, addonId, extraId, focusInner, onInputFocus, onInputBlur } = this.props;
|
|
63
69
|
const prefix = prefixCls || css.PREFIX;
|
|
64
70
|
|
|
65
71
|
const wrapper = classnames(
|
|
@@ -73,6 +79,8 @@ class CheckboxInner extends PureComponent<CheckboxInnerProps> {
|
|
|
73
79
|
|
|
74
80
|
const inner = classnames({
|
|
75
81
|
[`${prefix}-inner-display`]: true,
|
|
82
|
+
[`${prefix}-focus`]: focusInner,
|
|
83
|
+
[`${prefix}-focus-border`]: focusInner && !checked,
|
|
76
84
|
});
|
|
77
85
|
|
|
78
86
|
const icon = checked ? (
|
|
@@ -95,6 +103,8 @@ class CheckboxInner extends PureComponent<CheckboxInnerProps> {
|
|
|
95
103
|
onChange: noop,
|
|
96
104
|
checked: checked,
|
|
97
105
|
disabled: disabled,
|
|
106
|
+
onFocus: onInputFocus,
|
|
107
|
+
onBlur: onInputBlur,
|
|
98
108
|
};
|
|
99
109
|
|
|
100
110
|
name && (inputProps['name'] = name);
|
package/collapsible/index.tsx
CHANGED
|
@@ -92,14 +92,7 @@ const Collapsible = (props: CollapsibleProps) => {
|
|
|
92
92
|
const wrapperCls = cls(`${cssClasses.PREFIX}-wrapper`, className);
|
|
93
93
|
return (
|
|
94
94
|
<div style={wrapperstyle} className={wrapperCls} ref={ref}>
|
|
95
|
-
<div
|
|
96
|
-
ref={setHeight}
|
|
97
|
-
style={{ overflow: 'hidden' }}
|
|
98
|
-
id={id}
|
|
99
|
-
x-semi-prop="children"
|
|
100
|
-
>
|
|
101
|
-
{children}
|
|
102
|
-
</div>
|
|
95
|
+
<div ref={setHeight} style={{ overflow: 'hidden' }} id={id}>{children}</div>
|
|
103
96
|
</div>
|
|
104
97
|
);
|
|
105
98
|
};
|
package/datePicker/dateInput.tsx
CHANGED
|
@@ -172,7 +172,6 @@ export default class DateInput extends BaseComponent<DateInputProps, {}> {
|
|
|
172
172
|
<div
|
|
173
173
|
className={`${prefixCls}-range-input-prefix`}
|
|
174
174
|
onClick={e => !disabled && !rangeInputFocus && this.handleRangeStartFocus(e)}
|
|
175
|
-
x-semi-prop="prefix,insetLabel"
|
|
176
175
|
>
|
|
177
176
|
{labelNode}
|
|
178
177
|
</div>
|
|
@@ -653,21 +653,13 @@ export default class DatePicker extends BaseComponent<DatePickerProps, DatePicke
|
|
|
653
653
|
|
|
654
654
|
return (
|
|
655
655
|
<div ref={this.panelRef} className={wrapCls} style={dropdownStyle}>
|
|
656
|
-
{topSlot &&
|
|
657
|
-
<div className={`${cssClasses.PREFIX}-topSlot`} x-semi-prop="topSlot">
|
|
658
|
-
{topSlot}
|
|
659
|
-
</div>
|
|
660
|
-
)}
|
|
656
|
+
{topSlot && <div className={`${cssClasses.PREFIX}-topSlot`}>{topSlot}</div>}
|
|
661
657
|
{insetInput && <DateInput {...insetInputProps} insetInput={true} />}
|
|
662
|
-
{this.adapter.typeIsYearOrMonth()
|
|
663
|
-
|
|
664
|
-
|
|
658
|
+
{this.adapter.typeIsYearOrMonth() ?
|
|
659
|
+
this.renderYearMonthPanel(locale, localeCode) :
|
|
660
|
+
this.renderMonthGrid(locale, localeCode, dateFnsLocale)}
|
|
665
661
|
{this.renderQuickControls()}
|
|
666
|
-
{bottomSlot &&
|
|
667
|
-
<div className={`${cssClasses.PREFIX}-bottomSlot`} x-semi-prop="bottomSlot">
|
|
668
|
-
{bottomSlot}
|
|
669
|
-
</div>
|
|
670
|
-
)}
|
|
662
|
+
{bottomSlot && <div className={`${cssClasses.PREFIX}-bottomSlot`}>{bottomSlot}</div>}
|
|
671
663
|
{this.renderFooter(locale, localeCode)}
|
|
672
664
|
</div>
|
|
673
665
|
);
|