@douyinfe/semi-foundation 2.16.1 → 2.17.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/collapse/collapse.scss +8 -0
- package/collapse/variables.scss +1 -0
- package/datePicker/constants.ts +1 -0
- package/datePicker/datePicker.scss +335 -17
- package/datePicker/foundation.ts +2 -0
- package/datePicker/monthsGridFoundation.ts +4 -1
- package/datePicker/rtl.scss +6 -6
- package/datePicker/variables.scss +58 -6
- package/datePicker/yearAndMonthFoundation.ts +4 -0
- package/lib/cjs/collapse/collapse.css +6 -0
- package/lib/cjs/collapse/collapse.scss +8 -0
- package/lib/cjs/collapse/variables.scss +1 -0
- package/lib/cjs/datePicker/constants.d.ts +1 -0
- package/lib/cjs/datePicker/constants.js +1 -0
- package/lib/cjs/datePicker/datePicker.css +267 -27
- package/lib/cjs/datePicker/datePicker.scss +335 -17
- package/lib/cjs/datePicker/foundation.d.ts +2 -0
- package/lib/cjs/datePicker/monthsGridFoundation.d.ts +5 -1
- package/lib/cjs/datePicker/rtl.scss +6 -6
- package/lib/cjs/datePicker/variables.scss +58 -6
- package/lib/cjs/datePicker/yearAndMonthFoundation.d.ts +5 -0
- package/lib/cjs/select/foundation.d.ts +11 -0
- package/lib/cjs/select/foundation.js +188 -44
- package/lib/cjs/select/select.css +5 -5
- package/lib/cjs/select/select.scss +9 -6
- package/lib/cjs/tagInput/foundation.d.ts +11 -0
- package/lib/cjs/tagInput/foundation.js +47 -1
- package/lib/cjs/tagInput/tagInput.css +11 -0
- package/lib/cjs/tagInput/tagInput.scss +17 -0
- package/lib/cjs/tagInput/variables.scss +2 -0
- package/lib/cjs/tooltip/foundation.js +13 -5
- package/lib/cjs/transfer/foundation.d.ts +0 -1
- package/lib/cjs/transfer/foundation.js +3 -11
- package/lib/cjs/utils/arrayMove.d.ts +1 -0
- package/lib/cjs/utils/arrayMove.js +21 -0
- package/lib/es/collapse/collapse.css +6 -0
- package/lib/es/collapse/collapse.scss +8 -0
- package/lib/es/collapse/variables.scss +1 -0
- package/lib/es/datePicker/constants.d.ts +1 -0
- package/lib/es/datePicker/constants.js +1 -0
- package/lib/es/datePicker/datePicker.css +267 -27
- package/lib/es/datePicker/datePicker.scss +335 -17
- package/lib/es/datePicker/foundation.d.ts +2 -0
- package/lib/es/datePicker/monthsGridFoundation.d.ts +5 -1
- package/lib/es/datePicker/rtl.scss +6 -6
- package/lib/es/datePicker/variables.scss +58 -6
- package/lib/es/datePicker/yearAndMonthFoundation.d.ts +5 -0
- package/lib/es/select/foundation.d.ts +11 -0
- package/lib/es/select/foundation.js +187 -44
- package/lib/es/select/select.css +5 -5
- package/lib/es/select/select.scss +9 -6
- package/lib/es/tagInput/foundation.d.ts +11 -0
- package/lib/es/tagInput/foundation.js +46 -1
- package/lib/es/tagInput/tagInput.css +11 -0
- package/lib/es/tagInput/tagInput.scss +17 -0
- package/lib/es/tagInput/variables.scss +2 -0
- package/lib/es/tooltip/foundation.js +13 -5
- package/lib/es/transfer/foundation.d.ts +0 -1
- package/lib/es/transfer/foundation.js +3 -12
- package/lib/es/utils/arrayMove.d.ts +1 -0
- package/lib/es/utils/arrayMove.js +9 -0
- package/package.json +2 -2
- package/select/foundation.ts +149 -36
- package/select/select.scss +9 -6
- package/tagInput/foundation.ts +39 -0
- package/tagInput/tagInput.scss +17 -0
- package/tagInput/variables.scss +2 -0
- package/tooltip/foundation.ts +8 -5
- package/transfer/foundation.ts +2 -6
- package/utils/arrayMove.ts +5 -0
|
@@ -36,6 +36,7 @@ import KeyCode, { ENTER_KEY } from '../utils/keyCode';
|
|
|
36
36
|
import warning from '../utils/warning';
|
|
37
37
|
import isNullOrUndefined from '../utils/isNullOrUndefined';
|
|
38
38
|
import isEnterPress from '../utils/isEnterPress';
|
|
39
|
+
import { handlePrevent } from '../utils/a11y';
|
|
39
40
|
export default class SelectFoundation extends BaseFoundation {
|
|
40
41
|
constructor(adapter) {
|
|
41
42
|
super(_Object$assign({}, adapter)); // keyboard event listner
|
|
@@ -66,14 +67,22 @@ export default class SelectFoundation extends BaseFoundation {
|
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
focus() {
|
|
69
|
-
this._focusTrigger();
|
|
70
|
-
|
|
71
70
|
const isFilterable = this._isFilterable();
|
|
72
71
|
|
|
72
|
+
const isMultiple = this._isMultiple();
|
|
73
|
+
|
|
73
74
|
this._adapter.updateFocusState(true);
|
|
74
75
|
|
|
75
|
-
|
|
76
|
+
this._adapter.setIsFocusInContainer(false);
|
|
77
|
+
|
|
78
|
+
if (isFilterable && isMultiple) {
|
|
79
|
+
// when filter and multiple, only focus input
|
|
80
|
+
this.focusInput();
|
|
81
|
+
} else if (isFilterable && !isMultiple) {
|
|
82
|
+
// when filter and not multiple, only show input and focus input
|
|
76
83
|
this.toggle2SearchInput(true);
|
|
84
|
+
} else {
|
|
85
|
+
this._focusTrigger();
|
|
77
86
|
}
|
|
78
87
|
}
|
|
79
88
|
|
|
@@ -83,9 +92,8 @@ export default class SelectFoundation extends BaseFoundation {
|
|
|
83
92
|
}
|
|
84
93
|
|
|
85
94
|
destroy() {
|
|
86
|
-
this._adapter.unregisterClickOutsideHandler();
|
|
95
|
+
this._adapter.unregisterClickOutsideHandler(); // this.unBindKeyBoardEvent();
|
|
87
96
|
|
|
88
|
-
this.unBindKeyBoardEvent();
|
|
89
97
|
}
|
|
90
98
|
|
|
91
99
|
_setDropdownWidth() {
|
|
@@ -411,6 +419,10 @@ export default class SelectFoundation extends BaseFoundation {
|
|
|
411
419
|
|
|
412
420
|
this._adapter.registerClickOutsideHandler(e => {
|
|
413
421
|
this.close(e);
|
|
422
|
+
|
|
423
|
+
this._notifyBlur(e);
|
|
424
|
+
|
|
425
|
+
this._adapter.updateFocusState(false);
|
|
414
426
|
});
|
|
415
427
|
}
|
|
416
428
|
|
|
@@ -418,15 +430,17 @@ export default class SelectFoundation extends BaseFoundation {
|
|
|
418
430
|
if (isShow) {
|
|
419
431
|
this._adapter.toggleInputShow(isShow, () => this.focusInput());
|
|
420
432
|
} else {
|
|
433
|
+
// only when choose the option and close the panel, the input can be hide
|
|
421
434
|
this._adapter.toggleInputShow(isShow, () => undefined);
|
|
422
435
|
}
|
|
423
436
|
}
|
|
424
437
|
|
|
425
438
|
close(e) {
|
|
439
|
+
// to support A11y, closing the panel trigger does not necessarily lose focus
|
|
426
440
|
const isFilterable = this._isFilterable();
|
|
427
441
|
|
|
428
442
|
if (isFilterable) {
|
|
429
|
-
this.unBindKeyBoardEvent();
|
|
443
|
+
// this.unBindKeyBoardEvent();
|
|
430
444
|
this.clearInput();
|
|
431
445
|
this.toggle2SearchInput(false);
|
|
432
446
|
}
|
|
@@ -435,13 +449,12 @@ export default class SelectFoundation extends BaseFoundation {
|
|
|
435
449
|
|
|
436
450
|
this._adapter.notifyDropdownVisibleChange(false);
|
|
437
451
|
|
|
438
|
-
this.unBindKeyBoardEvent();
|
|
452
|
+
this._adapter.setIsFocusInContainer(false); // this.unBindKeyBoardEvent();
|
|
453
|
+
// this._notifyBlur(e);
|
|
439
454
|
|
|
440
|
-
this._notifyBlur(e);
|
|
441
455
|
|
|
442
|
-
this._adapter.unregisterClickOutsideHandler();
|
|
456
|
+
this._adapter.unregisterClickOutsideHandler(); // this._adapter.updateFocusState(false);
|
|
443
457
|
|
|
444
|
-
this._adapter.updateFocusState(false);
|
|
445
458
|
}
|
|
446
459
|
|
|
447
460
|
onSelect(option, optionIndex, event) {
|
|
@@ -460,6 +473,8 @@ export default class SelectFoundation extends BaseFoundation {
|
|
|
460
473
|
|
|
461
474
|
if (!isMultiple) {
|
|
462
475
|
this._handleSingleSelect(option, event);
|
|
476
|
+
|
|
477
|
+
this._focusTrigger();
|
|
463
478
|
} else {
|
|
464
479
|
this._handleMultipleSelect(option, event);
|
|
465
480
|
}
|
|
@@ -684,6 +699,8 @@ export default class SelectFoundation extends BaseFoundation {
|
|
|
684
699
|
this._adapter.focusInput();
|
|
685
700
|
|
|
686
701
|
this._adapter.updateFocusState(true);
|
|
702
|
+
|
|
703
|
+
this._adapter.setIsFocusInContainer(false);
|
|
687
704
|
}
|
|
688
705
|
|
|
689
706
|
handleInputChange(sugInput) {
|
|
@@ -822,14 +839,17 @@ export default class SelectFoundation extends BaseFoundation {
|
|
|
822
839
|
|
|
823
840
|
_handleKeyDown(event) {
|
|
824
841
|
const key = event.keyCode;
|
|
842
|
+
const {
|
|
843
|
+
loading,
|
|
844
|
+
filter,
|
|
845
|
+
multiple,
|
|
846
|
+
disabled
|
|
847
|
+
} = this.getProps();
|
|
825
848
|
const {
|
|
826
849
|
isOpen
|
|
827
850
|
} = this.getStates();
|
|
828
|
-
const {
|
|
829
|
-
loading
|
|
830
|
-
} = this.getProps();
|
|
831
851
|
|
|
832
|
-
if (
|
|
852
|
+
if (loading || disabled) {
|
|
833
853
|
return;
|
|
834
854
|
}
|
|
835
855
|
|
|
@@ -860,16 +880,38 @@ export default class SelectFoundation extends BaseFoundation {
|
|
|
860
880
|
case KeyCode.ENTER:
|
|
861
881
|
// internal-issues:302
|
|
862
882
|
// prevent trigger form’s submit when use in form
|
|
863
|
-
event
|
|
864
|
-
event.stopPropagation();
|
|
883
|
+
handlePrevent(event);
|
|
865
884
|
|
|
866
885
|
this._handleEnterKeyDown(event);
|
|
867
886
|
|
|
868
887
|
break;
|
|
869
888
|
|
|
870
889
|
case KeyCode.ESC:
|
|
890
|
+
isOpen && this.close(event);
|
|
891
|
+
filter && !multiple && this._focusTrigger();
|
|
892
|
+
break;
|
|
893
|
+
|
|
894
|
+
case KeyCode.TAB:
|
|
895
|
+
// check if slot have focusable element
|
|
896
|
+
this._handleTabKeyDown(event);
|
|
897
|
+
|
|
898
|
+
break;
|
|
899
|
+
|
|
900
|
+
default:
|
|
901
|
+
break;
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
handleContainerKeyDown(event) {
|
|
906
|
+
// when focus in contanier, handle the key down
|
|
907
|
+
const key = event.keyCode;
|
|
908
|
+
const {
|
|
909
|
+
isOpen
|
|
910
|
+
} = this.getStates();
|
|
911
|
+
|
|
912
|
+
switch (key) {
|
|
871
913
|
case KeyCode.TAB:
|
|
872
|
-
this.
|
|
914
|
+
isOpen && this._handleTabKeyDown(event);
|
|
873
915
|
break;
|
|
874
916
|
|
|
875
917
|
default:
|
|
@@ -939,7 +981,84 @@ export default class SelectFoundation extends BaseFoundation {
|
|
|
939
981
|
}
|
|
940
982
|
|
|
941
983
|
_handleArrowKeyDown(offset) {
|
|
942
|
-
|
|
984
|
+
const {
|
|
985
|
+
isOpen
|
|
986
|
+
} = this.getStates();
|
|
987
|
+
isOpen ? this._getEnableFocusIndex(offset) : this.open();
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
_handleTabKeyDown(event) {
|
|
991
|
+
const {
|
|
992
|
+
isOpen
|
|
993
|
+
} = this.getStates();
|
|
994
|
+
|
|
995
|
+
this._adapter.updateFocusState(false);
|
|
996
|
+
|
|
997
|
+
if (isOpen) {
|
|
998
|
+
const container = this._adapter.getContainer();
|
|
999
|
+
|
|
1000
|
+
const focusableElements = this._adapter.getFocusableElements(container);
|
|
1001
|
+
|
|
1002
|
+
const focusableNum = focusableElements.length;
|
|
1003
|
+
|
|
1004
|
+
if (focusableNum > 0) {
|
|
1005
|
+
// Shift + Tab will move focus backward
|
|
1006
|
+
if (event.shiftKey) {
|
|
1007
|
+
this._handlePanelOpenShiftTabKeyDown(focusableElements, event);
|
|
1008
|
+
} else {
|
|
1009
|
+
this._handlePanelOpenTabKeyDown(focusableElements, event);
|
|
1010
|
+
}
|
|
1011
|
+
} else {
|
|
1012
|
+
// there are no focusable elements inside the container, tab to next element and trigger blur
|
|
1013
|
+
this.close();
|
|
1014
|
+
|
|
1015
|
+
this._notifyBlur(event);
|
|
1016
|
+
}
|
|
1017
|
+
} else {
|
|
1018
|
+
// tab or shift tab to next element and trigger blur
|
|
1019
|
+
this._notifyBlur(event);
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
_handlePanelOpenTabKeyDown(focusableElements, event) {
|
|
1024
|
+
const activeElement = this._adapter.getActiveElement();
|
|
1025
|
+
|
|
1026
|
+
const isFocusInContainer = this._adapter.getIsFocusInContainer();
|
|
1027
|
+
|
|
1028
|
+
if (!isFocusInContainer) {
|
|
1029
|
+
// focus in trigger, set next focus to the first element in container
|
|
1030
|
+
focusableElements[0].focus();
|
|
1031
|
+
|
|
1032
|
+
this._adapter.setIsFocusInContainer(true);
|
|
1033
|
+
|
|
1034
|
+
handlePrevent(event);
|
|
1035
|
+
} else if (activeElement === focusableElements[focusableElements.length - 1]) {
|
|
1036
|
+
// focus in the last element in container, focus back to trigger and close panel
|
|
1037
|
+
this._focusTrigger();
|
|
1038
|
+
|
|
1039
|
+
this.close();
|
|
1040
|
+
handlePrevent(event);
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
_handlePanelOpenShiftTabKeyDown(focusableElements, event) {
|
|
1045
|
+
const activeElement = this._adapter.getActiveElement();
|
|
1046
|
+
|
|
1047
|
+
const isFocusInContainer = this._adapter.getIsFocusInContainer();
|
|
1048
|
+
|
|
1049
|
+
if (!isFocusInContainer) {
|
|
1050
|
+
// focus in trigger, close the panel, shift tab to previe element and trigger blur
|
|
1051
|
+
this.close();
|
|
1052
|
+
|
|
1053
|
+
this._notifyBlur(event);
|
|
1054
|
+
} else if (activeElement === focusableElements[0]) {
|
|
1055
|
+
// focus in the first element in container, focus back to trigger
|
|
1056
|
+
this._focusTrigger();
|
|
1057
|
+
|
|
1058
|
+
this._adapter.setIsFocusInContainer(false);
|
|
1059
|
+
|
|
1060
|
+
handlePrevent(event);
|
|
1061
|
+
}
|
|
943
1062
|
}
|
|
944
1063
|
|
|
945
1064
|
_handleEnterKeyDown(event) {
|
|
@@ -949,27 +1068,33 @@ export default class SelectFoundation extends BaseFoundation {
|
|
|
949
1068
|
focusIndex
|
|
950
1069
|
} = this.getStates();
|
|
951
1070
|
|
|
952
|
-
if (
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
} = visibleOptions; // fix issue 1201
|
|
958
|
-
|
|
959
|
-
if (length <= focusIndex) {
|
|
960
|
-
return;
|
|
961
|
-
}
|
|
1071
|
+
if (!isOpen) {
|
|
1072
|
+
this.open();
|
|
1073
|
+
} else {
|
|
1074
|
+
if (focusIndex !== -1) {
|
|
1075
|
+
const visibleOptions = _filterInstanceProperty(options).call(options, item => item._show);
|
|
962
1076
|
|
|
963
|
-
|
|
964
|
-
|
|
1077
|
+
const {
|
|
1078
|
+
length
|
|
1079
|
+
} = visibleOptions; // fix issue 1201
|
|
965
1080
|
|
|
966
|
-
if (
|
|
1081
|
+
if (length <= focusIndex) {
|
|
967
1082
|
return;
|
|
968
1083
|
}
|
|
969
1084
|
|
|
970
|
-
|
|
1085
|
+
if (visibleOptions && length) {
|
|
1086
|
+
const selectedOption = visibleOptions[focusIndex];
|
|
1087
|
+
|
|
1088
|
+
if (selectedOption.disabled) {
|
|
1089
|
+
return;
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
this.onSelect(selectedOption, focusIndex, event);
|
|
1093
|
+
}
|
|
1094
|
+
} else {
|
|
1095
|
+
this.close();
|
|
971
1096
|
}
|
|
972
|
-
}
|
|
1097
|
+
}
|
|
973
1098
|
}
|
|
974
1099
|
|
|
975
1100
|
_handleBackspaceKeyDown() {
|
|
@@ -1114,15 +1239,16 @@ export default class SelectFoundation extends BaseFoundation {
|
|
|
1114
1239
|
this._adapter.notifyChange(values);
|
|
1115
1240
|
}
|
|
1116
1241
|
} // Scenes that may trigger blur:
|
|
1117
|
-
//
|
|
1118
|
-
//
|
|
1119
|
-
//
|
|
1242
|
+
// 1、clickOutSide
|
|
1243
|
+
// 2、 tab to next element/ shift tab to previous element
|
|
1244
|
+
// 3、[remove when add a11y] click option / press enter, and then select complete(when multiple is false
|
|
1245
|
+
// 4、[remove when add a11y] press esc when dropdown list open
|
|
1120
1246
|
|
|
1121
1247
|
|
|
1122
1248
|
_notifyBlur(e) {
|
|
1123
1249
|
this._adapter.notifyBlur(e);
|
|
1124
1250
|
} // Scenes that may trigger focus:
|
|
1125
|
-
//
|
|
1251
|
+
// 1、click selection
|
|
1126
1252
|
|
|
1127
1253
|
|
|
1128
1254
|
_notifyFocus(e) {
|
|
@@ -1175,11 +1301,15 @@ export default class SelectFoundation extends BaseFoundation {
|
|
|
1175
1301
|
|
|
1176
1302
|
handleListScroll(e) {
|
|
1177
1303
|
this._adapter.notifyListScroll(e);
|
|
1178
|
-
}
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
handleTriggerFocus(e) {
|
|
1307
|
+
this.bindKeyBoardEvent();
|
|
1308
|
+
|
|
1309
|
+
this._adapter.updateFocusState(true);
|
|
1182
1310
|
|
|
1311
|
+
this._adapter.setIsFocusInContainer(false);
|
|
1312
|
+
}
|
|
1183
1313
|
|
|
1184
1314
|
handleTriggerBlur(e) {
|
|
1185
1315
|
this._adapter.updateFocusState(false);
|
|
@@ -1191,15 +1321,28 @@ export default class SelectFoundation extends BaseFoundation {
|
|
|
1191
1321
|
const {
|
|
1192
1322
|
isOpen,
|
|
1193
1323
|
isFocus
|
|
1194
|
-
} = this.getStates(); // Under normal circumstances, blur will be accompanied by
|
|
1195
|
-
// But when autoFocus, because
|
|
1324
|
+
} = this.getStates(); // Under normal circumstances, blur will be accompanied by clickOutsideHandler, so the notify of blur can be called uniformly in clickOutsideHandler
|
|
1325
|
+
// But when autoFocus, because clickOutsideHandler is not register, you need to listen for the trigger's blur and trigger the notify callback
|
|
1196
1326
|
|
|
1197
1327
|
if (autoFocus && isFocus && !isOpen) {
|
|
1198
|
-
// blur when autoFocus & not open dropdown yet
|
|
1199
1328
|
this._notifyBlur(e);
|
|
1200
1329
|
}
|
|
1201
1330
|
}
|
|
1202
1331
|
|
|
1332
|
+
handleInputBlur(e) {
|
|
1333
|
+
const {
|
|
1334
|
+
filter,
|
|
1335
|
+
autoFocus
|
|
1336
|
+
} = this.getProps();
|
|
1337
|
+
|
|
1338
|
+
const isMultiple = this._isMultiple();
|
|
1339
|
+
|
|
1340
|
+
if (autoFocus && filter && !isMultiple) {
|
|
1341
|
+
// under this condition, when input blur, hide the input
|
|
1342
|
+
this.toggle2SearchInput(false);
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1203
1346
|
selectAll() {
|
|
1204
1347
|
const {
|
|
1205
1348
|
options
|
package/lib/es/select/select.css
CHANGED
|
@@ -93,10 +93,6 @@
|
|
|
93
93
|
background-color: var(--semi-color-fill-1);
|
|
94
94
|
border: 1px solid transparent;
|
|
95
95
|
}
|
|
96
|
-
.semi-select:active {
|
|
97
|
-
background-color: var(--semi-color-fill-2);
|
|
98
|
-
border: 1px solid var(--semi-color-focus-border);
|
|
99
|
-
}
|
|
100
96
|
.semi-select:focus {
|
|
101
97
|
border: 1px solid var(--semi-color-focus-border);
|
|
102
98
|
outline: 0;
|
|
@@ -122,6 +118,10 @@
|
|
|
122
118
|
background-color: var(--semi-color-fill-0);
|
|
123
119
|
border: 1px solid var(--semi-color-focus-border);
|
|
124
120
|
}
|
|
121
|
+
.semi-select-open:active, .semi-select-focus:active {
|
|
122
|
+
background-color: var(--semi-color-fill-2);
|
|
123
|
+
border: 1px solid var(--semi-color-focus-border);
|
|
124
|
+
}
|
|
125
125
|
.semi-select-warning {
|
|
126
126
|
background-color: var(--semi-color-warning-light-default);
|
|
127
127
|
border-color: var(--semi-color-warning-light-default);
|
|
@@ -162,7 +162,7 @@
|
|
|
162
162
|
background-color: var(--semi-color-disabled-fill);
|
|
163
163
|
}
|
|
164
164
|
.semi-select-disabled:focus {
|
|
165
|
-
border: 1px solid
|
|
165
|
+
border: 1px solid transparent;
|
|
166
166
|
}
|
|
167
167
|
.semi-select-disabled .semi-select-selection,
|
|
168
168
|
.semi-select-disabled .semi-select-selection-placeholder {
|
|
@@ -27,11 +27,6 @@ $multiple: #{$module}-multiple;
|
|
|
27
27
|
border: $width-select-border-hover solid $color-select-border-hover;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
&:active {
|
|
31
|
-
background-color: $color-select-bg-active;
|
|
32
|
-
border: $width-select-border-active solid $color-select-border-active;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
30
|
&:focus {
|
|
36
31
|
border: $width-select-border-focus solid $color-select-border-focus;
|
|
37
32
|
outline: 0;
|
|
@@ -59,6 +54,12 @@ $multiple: #{$module}-multiple;
|
|
|
59
54
|
background-color: $color-select-bg-default;
|
|
60
55
|
border: $border-thickness-control-focus solid $color-select_default-border-focus;
|
|
61
56
|
}
|
|
57
|
+
|
|
58
|
+
// when click the trigger, trigger get the focus state, active style should take effect
|
|
59
|
+
&:active {
|
|
60
|
+
background-color: $color-select-bg-active;
|
|
61
|
+
border: $width-select-border-active solid $color-select-border-active;
|
|
62
|
+
}
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
&-warning {
|
|
@@ -111,7 +112,9 @@ $multiple: #{$module}-multiple;
|
|
|
111
112
|
}
|
|
112
113
|
|
|
113
114
|
&:focus {
|
|
114
|
-
border: $border-thickness-control-focus solid $color-select_default-border-focus;
|
|
115
|
+
// border: $border-thickness-control-focus solid $color-select_default-border-focus;
|
|
116
|
+
// when select is disabled, the border should not have active color
|
|
117
|
+
border: $border-thickness-control-focus solid transparent;
|
|
115
118
|
}
|
|
116
119
|
|
|
117
120
|
.#{$module}-selection,
|
|
@@ -3,12 +3,20 @@ export declare type TagInputChangeEvent = any;
|
|
|
3
3
|
export declare type TagInputCursorEvent = any;
|
|
4
4
|
export declare type TagInputKeyboardEvent = any;
|
|
5
5
|
export declare type TagInputMouseEvent = any;
|
|
6
|
+
export interface OnSortEndProps {
|
|
7
|
+
oldIndex: number;
|
|
8
|
+
newIndex: number;
|
|
9
|
+
}
|
|
6
10
|
export interface TagInputAdapter extends DefaultAdapter {
|
|
7
11
|
setInputValue: (inputValue: string) => void;
|
|
8
12
|
setTagsArray: (tagsArray: string[]) => void;
|
|
9
13
|
setFocusing: (focusing: boolean) => void;
|
|
10
14
|
toggleFocusing(focused: boolean): void;
|
|
11
15
|
setHovering: (hovering: boolean) => void;
|
|
16
|
+
setActive: (active: boolean) => void;
|
|
17
|
+
getClickOutsideHandler: () => any;
|
|
18
|
+
registerClickOutsideHandler: (cb: any) => void;
|
|
19
|
+
unregisterClickOutsideHandler: () => void;
|
|
12
20
|
notifyBlur: (e: TagInputCursorEvent) => void;
|
|
13
21
|
notifyFocus: (e: TagInputCursorEvent) => void;
|
|
14
22
|
notifyInputChange: (v: string, e: TagInputChangeEvent) => void;
|
|
@@ -42,6 +50,8 @@ declare class TagInputFoundation extends BaseFoundation<TagInputAdapter> {
|
|
|
42
50
|
handleTagClose(index: number): void;
|
|
43
51
|
handleInputMouseEnter(): void;
|
|
44
52
|
handleInputMouseLeave(): void;
|
|
53
|
+
handleClick(e?: any): void;
|
|
54
|
+
clickOutsideCallBack(): void;
|
|
45
55
|
handleClickPrefixOrSuffix(e: any): void;
|
|
46
56
|
handlePreventMouseDown(e: any): void;
|
|
47
57
|
/**
|
|
@@ -56,5 +66,6 @@ declare class TagInputFoundation extends BaseFoundation<TagInputAdapter> {
|
|
|
56
66
|
* handler of input change
|
|
57
67
|
*/
|
|
58
68
|
_onInputChange(value: string, e: TagInputChangeEvent): void;
|
|
69
|
+
handleSortEnd(callbackProps: OnSortEndProps): void;
|
|
59
70
|
}
|
|
60
71
|
export default TagInputFoundation;
|
|
@@ -14,6 +14,7 @@ import BaseFoundation from '../base/foundation';
|
|
|
14
14
|
import keyCode from '../utils/keyCode';
|
|
15
15
|
import getSplitedArray from './utils/getSplitedArray';
|
|
16
16
|
import isEnterPress from '../utils/isEnterPress';
|
|
17
|
+
import arrayMove from '../utils/arrayMove';
|
|
17
18
|
|
|
18
19
|
class TagInputFoundation extends BaseFoundation {
|
|
19
20
|
constructor(adapter) {
|
|
@@ -193,7 +194,10 @@ class TagInputFoundation extends BaseFoundation {
|
|
|
193
194
|
|
|
194
195
|
if (inputValue.length > 0) {
|
|
195
196
|
this._onInputChange('', e);
|
|
196
|
-
}
|
|
197
|
+
} // Prevent event propagate to TagInput outermost div
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
e.stopPropagation();
|
|
197
201
|
}
|
|
198
202
|
|
|
199
203
|
handleTagClose(index) {
|
|
@@ -218,6 +222,30 @@ class TagInputFoundation extends BaseFoundation {
|
|
|
218
222
|
this._adapter.setHovering(false);
|
|
219
223
|
}
|
|
220
224
|
|
|
225
|
+
handleClick(e) {
|
|
226
|
+
const {
|
|
227
|
+
disabled
|
|
228
|
+
} = this.getProps();
|
|
229
|
+
|
|
230
|
+
if (disabled) {
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
const clickOutsideHandler = this._adapter.getClickOutsideHandler();
|
|
235
|
+
|
|
236
|
+
if (!clickOutsideHandler) {
|
|
237
|
+
this._adapter.setActive(true);
|
|
238
|
+
|
|
239
|
+
this._adapter.registerClickOutsideHandler(e => this.clickOutsideCallBack());
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
clickOutsideCallBack() {
|
|
244
|
+
this._adapter.unregisterClickOutsideHandler();
|
|
245
|
+
|
|
246
|
+
this._adapter.setActive(false);
|
|
247
|
+
}
|
|
248
|
+
|
|
221
249
|
handleClickPrefixOrSuffix(e) {
|
|
222
250
|
const {
|
|
223
251
|
disabled
|
|
@@ -276,6 +304,23 @@ class TagInputFoundation extends BaseFoundation {
|
|
|
276
304
|
this._adapter.notifyInputChange(value, e);
|
|
277
305
|
}
|
|
278
306
|
|
|
307
|
+
handleSortEnd(callbackProps) {
|
|
308
|
+
const {
|
|
309
|
+
oldIndex,
|
|
310
|
+
newIndex
|
|
311
|
+
} = callbackProps;
|
|
312
|
+
const {
|
|
313
|
+
tagsArray
|
|
314
|
+
} = this.getStates();
|
|
315
|
+
const newTagsArray = arrayMove(tagsArray, oldIndex, newIndex);
|
|
316
|
+
|
|
317
|
+
if (!this._isControlledComponent()) {
|
|
318
|
+
this._adapter.setTagsArray(newTagsArray);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
this._adapter.notifyTagChange(newTagsArray);
|
|
322
|
+
}
|
|
323
|
+
|
|
279
324
|
}
|
|
280
325
|
|
|
281
326
|
export default TagInputFoundation;
|
|
@@ -10,6 +10,14 @@
|
|
|
10
10
|
width: 100%;
|
|
11
11
|
box-sizing: border-box;
|
|
12
12
|
}
|
|
13
|
+
.semi-tagInput-drag-item {
|
|
14
|
+
display: flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
}
|
|
17
|
+
.semi-tagInput-drag-handler {
|
|
18
|
+
margin-right: 4px;
|
|
19
|
+
cursor: move;
|
|
20
|
+
}
|
|
13
21
|
.semi-tagInput-hover {
|
|
14
22
|
background-color: var(--semi-color-fill-1);
|
|
15
23
|
border: 1px transparent solid;
|
|
@@ -88,6 +96,9 @@
|
|
|
88
96
|
margin-top: 3px;
|
|
89
97
|
margin-bottom: 3px;
|
|
90
98
|
}
|
|
99
|
+
.semi-tagInput-wrapper-tag-icon {
|
|
100
|
+
padding-left: 4px;
|
|
101
|
+
}
|
|
91
102
|
.semi-tagInput-wrapper-typo {
|
|
92
103
|
font-size: 12px;
|
|
93
104
|
}
|
|
@@ -11,6 +11,19 @@ $module: #{$prefix}-tagInput;
|
|
|
11
11
|
width: 100%;
|
|
12
12
|
box-sizing: border-box;
|
|
13
13
|
|
|
14
|
+
&-drag {
|
|
15
|
+
|
|
16
|
+
&-item {
|
|
17
|
+
display: flex;
|
|
18
|
+
align-items: center;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
&-handler {
|
|
22
|
+
margin-right: $spacing-tagInput_drag_handler-marginRight;
|
|
23
|
+
cursor: move;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
14
27
|
&-hover {
|
|
15
28
|
background-color: $color-tagInput_default-bg-hover;
|
|
16
29
|
border: $width-tagInput-border-hover $color-tagInput-border-hover solid;
|
|
@@ -104,6 +117,10 @@ $module: #{$prefix}-tagInput;
|
|
|
104
117
|
margin-bottom: $spacing-tagInput_large-Y;
|
|
105
118
|
}
|
|
106
119
|
}
|
|
120
|
+
|
|
121
|
+
&-icon {
|
|
122
|
+
padding-left: $spacing-tagInput_tag_icon_paddingLeft;
|
|
123
|
+
}
|
|
107
124
|
}
|
|
108
125
|
|
|
109
126
|
&-typo {
|
|
@@ -32,6 +32,8 @@ $spacing-tagInput_small-Y: 1px; // 小尺寸标签输入框标签顶部外边距
|
|
|
32
32
|
$spacing-tagInput_default-Y: $spacing-super-tight; // 默认尺寸标签输入框标签顶部外边距
|
|
33
33
|
$spacing-tagInput_large-Y: 3px; // 大尺寸标签输入框标签顶部外边距
|
|
34
34
|
$spacing-tagInput_wrapper_n_paddingX: $spacing-tight; //标签输入框标签容器水平内边距
|
|
35
|
+
$spacing-tagInput_drag_handler-marginRight: 4px; // 拖拽handler icon的右外边距
|
|
36
|
+
$spacing-tagInput_tag_icon_paddingLeft: 4px; // tag中有handler icon时tag的左内边距
|
|
35
37
|
|
|
36
38
|
$height-tagInput-large: $height-control-large; // 大尺寸标签输入框高度
|
|
37
39
|
$height-tagInput-default: $height-control-default; // 默认尺寸标签输入框高度
|
|
@@ -361,11 +361,17 @@ export default class Tooltip extends BaseFoundation {
|
|
|
361
361
|
|
|
362
362
|
|
|
363
363
|
triggerEventSet[eventNames.focus] = () => {
|
|
364
|
-
|
|
364
|
+
const {
|
|
365
|
+
disableFocusListener
|
|
366
|
+
} = this.getProps();
|
|
367
|
+
!disableFocusListener && this.delayShow();
|
|
365
368
|
};
|
|
366
369
|
|
|
367
370
|
triggerEventSet[eventNames.blur] = () => {
|
|
368
|
-
|
|
371
|
+
const {
|
|
372
|
+
disableFocusListener
|
|
373
|
+
} = this.getProps();
|
|
374
|
+
!disableFocusListener && this.delayHide();
|
|
369
375
|
};
|
|
370
376
|
|
|
371
377
|
portalEventSet = _Object$assign({}, triggerEventSet);
|
|
@@ -926,7 +932,8 @@ export default class Tooltip extends BaseFoundation {
|
|
|
926
932
|
|
|
927
933
|
_handleTriggerKeydown(event) {
|
|
928
934
|
const {
|
|
929
|
-
closeOnEsc
|
|
935
|
+
closeOnEsc,
|
|
936
|
+
disableArrowKeyDown
|
|
930
937
|
} = this.getProps();
|
|
931
938
|
|
|
932
939
|
const container = this._adapter.getContainer();
|
|
@@ -942,11 +949,12 @@ export default class Tooltip extends BaseFoundation {
|
|
|
942
949
|
break;
|
|
943
950
|
|
|
944
951
|
case "ArrowUp":
|
|
945
|
-
|
|
952
|
+
// when disableArrowKeyDown is true, disable tooltip's arrow keyboard event action
|
|
953
|
+
!disableArrowKeyDown && focusableNum && this._handleTriggerArrowUpKeydown(focusableElements, event);
|
|
946
954
|
break;
|
|
947
955
|
|
|
948
956
|
case "ArrowDown":
|
|
949
|
-
focusableNum && this._handleTriggerArrowDownKeydown(focusableElements, event);
|
|
957
|
+
!disableArrowKeyDown && focusableNum && this._handleTriggerArrowDownKeydown(focusableElements, event);
|
|
950
958
|
break;
|
|
951
959
|
|
|
952
960
|
default:
|
|
@@ -47,5 +47,4 @@ export default class TransferFoundation<P = Record<string, any>, S = Record<stri
|
|
|
47
47
|
};
|
|
48
48
|
_notifyChange(selectedItems: DataItemMap): void;
|
|
49
49
|
handleSortEnd(callbackProps: OnSortEndProps): void;
|
|
50
|
-
_arrayMove(array: Array<BasicDataItem>, from: number, to: number): BasicDataItem[];
|
|
51
50
|
}
|