@douyinfe/semi-foundation 2.26.0-beta.0 → 2.26.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.
|
@@ -14,6 +14,7 @@ export interface TagInputAdapter extends DefaultAdapter {
|
|
|
14
14
|
toggleFocusing(focused: boolean): void;
|
|
15
15
|
setHovering: (hovering: boolean) => void;
|
|
16
16
|
setActive: (active: boolean) => void;
|
|
17
|
+
setEntering: (entering: boolean) => void;
|
|
17
18
|
getClickOutsideHandler: () => any;
|
|
18
19
|
registerClickOutsideHandler: (cb: any) => void;
|
|
19
20
|
unregisterClickOutsideHandler: () => void;
|
|
@@ -31,6 +32,8 @@ declare class TagInputFoundation extends BaseFoundation<TagInputAdapter> {
|
|
|
31
32
|
* handler of input change
|
|
32
33
|
*/
|
|
33
34
|
handleInputChange: (e: TagInputChangeEvent) => void;
|
|
35
|
+
handleInputCompositionStart: (e: any) => void;
|
|
36
|
+
handleInputCompositionEnd: (e: any) => void;
|
|
34
37
|
/**
|
|
35
38
|
* check whether the input change is legal
|
|
36
39
|
*/
|
|
@@ -36,7 +36,66 @@ class TagInputFoundation extends _foundation.default {
|
|
|
36
36
|
const {
|
|
37
37
|
value
|
|
38
38
|
} = e.target;
|
|
39
|
-
|
|
39
|
+
const {
|
|
40
|
+
entering
|
|
41
|
+
} = this.getStates();
|
|
42
|
+
|
|
43
|
+
if (entering) {
|
|
44
|
+
// 如果处于输入法输入中,则先不检查输入是否有效,直接更新到inputValue,
|
|
45
|
+
// 因为对于输入法输入中而言,此时更新到 inputValue 的不是最后的结果,比如对于中文,此时 inputValue 中的内容是拼音
|
|
46
|
+
// 当输入法输入结束后,将在 handleInputCompositionEnd 中判断输入是否有效,处理结果
|
|
47
|
+
// If it is composition session, it does not check whether the input is valid, and directly updates to inputValue,
|
|
48
|
+
// Because for composition input, what is updated to inputValue at this time is not the final result.
|
|
49
|
+
// For example, for Chinese, the content in inputValue is pinyin at this time
|
|
50
|
+
// When the composition input is finished, it will be judged whether the input is valid in handleInputCompositionEnd and the result will be processed
|
|
51
|
+
this._onInputChange(value, e);
|
|
52
|
+
} else {
|
|
53
|
+
this._checkInputChangeValid(value) && this._onInputChange(value, e);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
this.handleInputCompositionStart = e => {
|
|
58
|
+
this._adapter.setEntering(true);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
this.handleInputCompositionEnd = e => {
|
|
62
|
+
this._adapter.setEntering(false);
|
|
63
|
+
|
|
64
|
+
const {
|
|
65
|
+
value
|
|
66
|
+
} = e.target;
|
|
67
|
+
const {
|
|
68
|
+
maxLength,
|
|
69
|
+
onInputExceed,
|
|
70
|
+
separator
|
|
71
|
+
} = this.getProps();
|
|
72
|
+
let allowChange = true;
|
|
73
|
+
const {
|
|
74
|
+
inputValue
|
|
75
|
+
} = this.getStates();
|
|
76
|
+
|
|
77
|
+
if ((0, _isNumber2.default)(maxLength)) {
|
|
78
|
+
const inputArr = (0, _getSplitedArray.default)(inputValue, separator);
|
|
79
|
+
let index = 0;
|
|
80
|
+
|
|
81
|
+
for (; index < inputArr.length; index++) {
|
|
82
|
+
if (inputArr[index].length > maxLength) {
|
|
83
|
+
allowChange = false;
|
|
84
|
+
(0, _isFunction2.default)(onInputExceed) && onInputExceed(value);
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (!allowChange) {
|
|
90
|
+
const newInputArr = inputArr.slice(0, index);
|
|
91
|
+
|
|
92
|
+
if (index < inputArr.length) {
|
|
93
|
+
newInputArr.push(inputArr[index].slice(0, maxLength));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
this._adapter.setInputValue(newInputArr.join(separator));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
40
99
|
};
|
|
41
100
|
/**
|
|
42
101
|
* check whether the input change is legal
|
|
@@ -14,6 +14,7 @@ export interface TagInputAdapter extends DefaultAdapter {
|
|
|
14
14
|
toggleFocusing(focused: boolean): void;
|
|
15
15
|
setHovering: (hovering: boolean) => void;
|
|
16
16
|
setActive: (active: boolean) => void;
|
|
17
|
+
setEntering: (entering: boolean) => void;
|
|
17
18
|
getClickOutsideHandler: () => any;
|
|
18
19
|
registerClickOutsideHandler: (cb: any) => void;
|
|
19
20
|
unregisterClickOutsideHandler: () => void;
|
|
@@ -31,6 +32,8 @@ declare class TagInputFoundation extends BaseFoundation<TagInputAdapter> {
|
|
|
31
32
|
* handler of input change
|
|
32
33
|
*/
|
|
33
34
|
handleInputChange: (e: TagInputChangeEvent) => void;
|
|
35
|
+
handleInputCompositionStart: (e: any) => void;
|
|
36
|
+
handleInputCompositionEnd: (e: any) => void;
|
|
34
37
|
/**
|
|
35
38
|
* check whether the input change is legal
|
|
36
39
|
*/
|
|
@@ -19,7 +19,66 @@ class TagInputFoundation extends BaseFoundation {
|
|
|
19
19
|
const {
|
|
20
20
|
value
|
|
21
21
|
} = e.target;
|
|
22
|
-
|
|
22
|
+
const {
|
|
23
|
+
entering
|
|
24
|
+
} = this.getStates();
|
|
25
|
+
|
|
26
|
+
if (entering) {
|
|
27
|
+
// 如果处于输入法输入中,则先不检查输入是否有效,直接更新到inputValue,
|
|
28
|
+
// 因为对于输入法输入中而言,此时更新到 inputValue 的不是最后的结果,比如对于中文,此时 inputValue 中的内容是拼音
|
|
29
|
+
// 当输入法输入结束后,将在 handleInputCompositionEnd 中判断输入是否有效,处理结果
|
|
30
|
+
// If it is composition session, it does not check whether the input is valid, and directly updates to inputValue,
|
|
31
|
+
// Because for composition input, what is updated to inputValue at this time is not the final result.
|
|
32
|
+
// For example, for Chinese, the content in inputValue is pinyin at this time
|
|
33
|
+
// When the composition input is finished, it will be judged whether the input is valid in handleInputCompositionEnd and the result will be processed
|
|
34
|
+
this._onInputChange(value, e);
|
|
35
|
+
} else {
|
|
36
|
+
this._checkInputChangeValid(value) && this._onInputChange(value, e);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
this.handleInputCompositionStart = e => {
|
|
41
|
+
this._adapter.setEntering(true);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
this.handleInputCompositionEnd = e => {
|
|
45
|
+
this._adapter.setEntering(false);
|
|
46
|
+
|
|
47
|
+
const {
|
|
48
|
+
value
|
|
49
|
+
} = e.target;
|
|
50
|
+
const {
|
|
51
|
+
maxLength,
|
|
52
|
+
onInputExceed,
|
|
53
|
+
separator
|
|
54
|
+
} = this.getProps();
|
|
55
|
+
let allowChange = true;
|
|
56
|
+
const {
|
|
57
|
+
inputValue
|
|
58
|
+
} = this.getStates();
|
|
59
|
+
|
|
60
|
+
if (_isNumber(maxLength)) {
|
|
61
|
+
const inputArr = getSplitedArray(inputValue, separator);
|
|
62
|
+
let index = 0;
|
|
63
|
+
|
|
64
|
+
for (; index < inputArr.length; index++) {
|
|
65
|
+
if (inputArr[index].length > maxLength) {
|
|
66
|
+
allowChange = false;
|
|
67
|
+
_isFunction(onInputExceed) && onInputExceed(value);
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (!allowChange) {
|
|
73
|
+
const newInputArr = inputArr.slice(0, index);
|
|
74
|
+
|
|
75
|
+
if (index < inputArr.length) {
|
|
76
|
+
newInputArr.push(inputArr[index].slice(0, maxLength));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
this._adapter.setInputValue(newInputArr.join(separator));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
23
82
|
};
|
|
24
83
|
/**
|
|
25
84
|
* check whether the input change is legal
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-foundation",
|
|
3
|
-
"version": "2.26.0
|
|
3
|
+
"version": "2.26.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build:lib": "node ./scripts/compileLib.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"*.scss",
|
|
24
24
|
"*.css"
|
|
25
25
|
],
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "7fed74a6b19a9bf9d45f56eb36c97fce0ac9de76",
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@babel/plugin-transform-runtime": "^7.15.8",
|
|
29
29
|
"@babel/preset-env": "^7.15.8",
|
package/tagInput/foundation.ts
CHANGED
|
@@ -27,6 +27,7 @@ export interface TagInputAdapter extends DefaultAdapter {
|
|
|
27
27
|
toggleFocusing(focused: boolean): void;
|
|
28
28
|
setHovering: (hovering: boolean) => void;
|
|
29
29
|
setActive: (active: boolean) => void;
|
|
30
|
+
setEntering: (entering: boolean) => void;
|
|
30
31
|
getClickOutsideHandler: () => any;
|
|
31
32
|
registerClickOutsideHandler: (cb: any) => void;
|
|
32
33
|
unregisterClickOutsideHandler: () => void;
|
|
@@ -49,9 +50,55 @@ class TagInputFoundation extends BaseFoundation<TagInputAdapter> {
|
|
|
49
50
|
*/
|
|
50
51
|
handleInputChange = (e: TagInputChangeEvent) => {
|
|
51
52
|
const { value } = e.target;
|
|
52
|
-
|
|
53
|
+
const { entering } = this.getStates();
|
|
54
|
+
if (entering) {
|
|
55
|
+
// 如果处于输入法输入中,则先不检查输入是否有效,直接更新到inputValue,
|
|
56
|
+
// 因为对于输入法输入中而言,此时更新到 inputValue 的不是最后的结果,比如对于中文,此时 inputValue 中的内容是拼音
|
|
57
|
+
// 当输入法输入结束后,将在 handleInputCompositionEnd 中判断输入是否有效,处理结果
|
|
58
|
+
// If it is composition session, it does not check whether the input is valid, and directly updates to inputValue,
|
|
59
|
+
// Because for composition input, what is updated to inputValue at this time is not the final result.
|
|
60
|
+
// For example, for Chinese, the content in inputValue is pinyin at this time
|
|
61
|
+
// When the composition input is finished, it will be judged whether the input is valid in handleInputCompositionEnd and the result will be processed
|
|
62
|
+
this._onInputChange(value, e);
|
|
63
|
+
} else {
|
|
64
|
+
this._checkInputChangeValid(value) && this._onInputChange(value, e);
|
|
65
|
+
}
|
|
53
66
|
};
|
|
54
67
|
|
|
68
|
+
handleInputCompositionStart = (e: any) => {
|
|
69
|
+
this._adapter.setEntering(true);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
handleInputCompositionEnd = (e: any) => {
|
|
73
|
+
this._adapter.setEntering(false);
|
|
74
|
+
const { value } = e.target;
|
|
75
|
+
const {
|
|
76
|
+
maxLength,
|
|
77
|
+
onInputExceed,
|
|
78
|
+
separator
|
|
79
|
+
} = this.getProps();
|
|
80
|
+
let allowChange = true;
|
|
81
|
+
const { inputValue } = this.getStates();
|
|
82
|
+
if (isNumber(maxLength)) {
|
|
83
|
+
const inputArr = getSplitedArray(inputValue, separator);
|
|
84
|
+
let index = 0;
|
|
85
|
+
for (; index < inputArr.length; index++) {
|
|
86
|
+
if (inputArr[index].length > maxLength) {
|
|
87
|
+
allowChange = false;
|
|
88
|
+
isFunction(onInputExceed) && onInputExceed(value);
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (!allowChange) {
|
|
93
|
+
const newInputArr = inputArr.slice(0, index);
|
|
94
|
+
if (index < inputArr.length) {
|
|
95
|
+
newInputArr.push(inputArr[index].slice(0, maxLength));
|
|
96
|
+
}
|
|
97
|
+
this._adapter.setInputValue(newInputArr.join(separator));
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
55
102
|
/**
|
|
56
103
|
* check whether the input change is legal
|
|
57
104
|
*/
|