@douyinfe/semi-foundation 2.43.0-beta.0 → 2.43.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/lib/cjs/tagInput/foundation.js +28 -19
- package/lib/cjs/tree/foundation.d.ts +1 -1
- package/lib/cjs/treeSelect/foundation.d.ts +2 -2
- package/lib/es/tagInput/foundation.js +28 -19
- package/lib/es/tree/foundation.d.ts +1 -1
- package/lib/es/treeSelect/foundation.d.ts +2 -2
- package/package.json +3 -3
- package/tagInput/foundation.ts +26 -17
- package/tree/foundation.ts +1 -1
- package/treeSelect/foundation.ts +2 -2
|
@@ -41,10 +41,15 @@ class TagInputFoundation extends _foundation.default {
|
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
43
|
this.handleInputCompositionStart = e => {
|
|
44
|
+
const {
|
|
45
|
+
maxLength
|
|
46
|
+
} = this.getProps();
|
|
47
|
+
if (!(0, _isNumber2.default)(maxLength)) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
44
50
|
this._adapter.setEntering(true);
|
|
45
51
|
};
|
|
46
52
|
this.handleInputCompositionEnd = e => {
|
|
47
|
-
this._adapter.setEntering(false);
|
|
48
53
|
const {
|
|
49
54
|
value
|
|
50
55
|
} = e.target;
|
|
@@ -53,27 +58,31 @@ class TagInputFoundation extends _foundation.default {
|
|
|
53
58
|
onInputExceed,
|
|
54
59
|
separator
|
|
55
60
|
} = this.getProps();
|
|
61
|
+
if (!(0, _isNumber2.default)(maxLength)) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
this._adapter.setEntering(false);
|
|
56
65
|
let allowChange = true;
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if (inputArr[index].length > maxLength) {
|
|
65
|
-
allowChange = false;
|
|
66
|
-
(0, _isFunction2.default)(onInputExceed) && onInputExceed(value);
|
|
67
|
-
break;
|
|
68
|
-
}
|
|
66
|
+
const inputArr = (0, _getSplitedArray.default)(value, separator);
|
|
67
|
+
let index = 0;
|
|
68
|
+
for (; index < inputArr.length; index++) {
|
|
69
|
+
if (inputArr[index].length > maxLength) {
|
|
70
|
+
allowChange = false;
|
|
71
|
+
(0, _isFunction2.default)(onInputExceed) && onInputExceed(value);
|
|
72
|
+
break;
|
|
69
73
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
this._adapter.setInputValue(newInputArr.join(separator));
|
|
74
|
+
}
|
|
75
|
+
if (!allowChange) {
|
|
76
|
+
const newInputArr = inputArr.slice(0, index);
|
|
77
|
+
if (index < inputArr.length) {
|
|
78
|
+
newInputArr.push(inputArr[index].slice(0, maxLength));
|
|
76
79
|
}
|
|
80
|
+
this._adapter.setInputValue(newInputArr.join(separator));
|
|
81
|
+
} else {
|
|
82
|
+
// Why does it need to be updated here instead of in onChange when the value meets the maxLength limit?
|
|
83
|
+
// Because in firefox, the state change in InputCompositionEnd causes onChange to not be triggered after
|
|
84
|
+
// the composition input completes input.
|
|
85
|
+
this._adapter.setInputValue(value);
|
|
77
86
|
}
|
|
78
87
|
};
|
|
79
88
|
/**
|
|
@@ -169,7 +169,7 @@ export interface BasicTreeProps {
|
|
|
169
169
|
onLoad?: (loadedKeys?: Set<string>, treeNode?: BasicTreeNodeData) => void;
|
|
170
170
|
onContextMenu?: (e: any, node: BasicTreeNodeData) => void;
|
|
171
171
|
onSearch?: (sunInput: string, filteredExpandedKeys: string[]) => void;
|
|
172
|
-
onSelect?: (
|
|
172
|
+
onSelect?: (selectedKey: string, selected: boolean, selectedNode: BasicTreeNodeData) => void;
|
|
173
173
|
preventScroll?: boolean;
|
|
174
174
|
renderDraggingNode?: (nodeInstance: HTMLElement, node: BasicTreeNodeData) => HTMLElement;
|
|
175
175
|
renderFullLabel?: (renderFullLabelProps: BasicRenderFullLabelProps) => any;
|
|
@@ -64,7 +64,7 @@ export interface BasicTreeSelectProps extends Pick<BasicTreeProps, 'virtualize'
|
|
|
64
64
|
restTagsPopoverProps?: any;
|
|
65
65
|
clickTriggerToHide?: boolean;
|
|
66
66
|
loadData?: (data: BasicTreeNodeData) => Promise<void>;
|
|
67
|
-
onSelect?: (
|
|
67
|
+
onSelect?: (selectedKey: string, selected: boolean, selectedNode: BasicTreeNodeData) => void;
|
|
68
68
|
searchRender?: (inputProps: any) => any;
|
|
69
69
|
renderSelectedItem?: BasicRenderSelectedItem;
|
|
70
70
|
getPopupContainer?: () => HTMLElement;
|
|
@@ -89,7 +89,7 @@ export interface TreeSelectAdapter<P = Record<string, any>, S = Record<string, a
|
|
|
89
89
|
unregisterClickOutsideHandler: () => void;
|
|
90
90
|
rePositionDropdown: () => void;
|
|
91
91
|
updateState: (states: Partial<BasicTreeSelectInnerData>) => void;
|
|
92
|
-
notifySelect: (
|
|
92
|
+
notifySelect: (selectedKey: string, selected: boolean, selectedNode: BasicTreeNodeData) => void;
|
|
93
93
|
notifySearch: (input: string, filteredExpandedKeys: string[]) => void;
|
|
94
94
|
cacheFlattenNodes: (bool: boolean) => void;
|
|
95
95
|
openMenu: () => void;
|
|
@@ -34,10 +34,15 @@ class TagInputFoundation extends BaseFoundation {
|
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
36
|
this.handleInputCompositionStart = e => {
|
|
37
|
+
const {
|
|
38
|
+
maxLength
|
|
39
|
+
} = this.getProps();
|
|
40
|
+
if (!_isNumber(maxLength)) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
37
43
|
this._adapter.setEntering(true);
|
|
38
44
|
};
|
|
39
45
|
this.handleInputCompositionEnd = e => {
|
|
40
|
-
this._adapter.setEntering(false);
|
|
41
46
|
const {
|
|
42
47
|
value
|
|
43
48
|
} = e.target;
|
|
@@ -46,27 +51,31 @@ class TagInputFoundation extends BaseFoundation {
|
|
|
46
51
|
onInputExceed,
|
|
47
52
|
separator
|
|
48
53
|
} = this.getProps();
|
|
54
|
+
if (!_isNumber(maxLength)) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
this._adapter.setEntering(false);
|
|
49
58
|
let allowChange = true;
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (inputArr[index].length > maxLength) {
|
|
58
|
-
allowChange = false;
|
|
59
|
-
_isFunction(onInputExceed) && onInputExceed(value);
|
|
60
|
-
break;
|
|
61
|
-
}
|
|
59
|
+
const inputArr = getSplitedArray(value, separator);
|
|
60
|
+
let index = 0;
|
|
61
|
+
for (; index < inputArr.length; index++) {
|
|
62
|
+
if (inputArr[index].length > maxLength) {
|
|
63
|
+
allowChange = false;
|
|
64
|
+
_isFunction(onInputExceed) && onInputExceed(value);
|
|
65
|
+
break;
|
|
62
66
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
this._adapter.setInputValue(newInputArr.join(separator));
|
|
67
|
+
}
|
|
68
|
+
if (!allowChange) {
|
|
69
|
+
const newInputArr = inputArr.slice(0, index);
|
|
70
|
+
if (index < inputArr.length) {
|
|
71
|
+
newInputArr.push(inputArr[index].slice(0, maxLength));
|
|
69
72
|
}
|
|
73
|
+
this._adapter.setInputValue(newInputArr.join(separator));
|
|
74
|
+
} else {
|
|
75
|
+
// Why does it need to be updated here instead of in onChange when the value meets the maxLength limit?
|
|
76
|
+
// Because in firefox, the state change in InputCompositionEnd causes onChange to not be triggered after
|
|
77
|
+
// the composition input completes input.
|
|
78
|
+
this._adapter.setInputValue(value);
|
|
70
79
|
}
|
|
71
80
|
};
|
|
72
81
|
/**
|
|
@@ -169,7 +169,7 @@ export interface BasicTreeProps {
|
|
|
169
169
|
onLoad?: (loadedKeys?: Set<string>, treeNode?: BasicTreeNodeData) => void;
|
|
170
170
|
onContextMenu?: (e: any, node: BasicTreeNodeData) => void;
|
|
171
171
|
onSearch?: (sunInput: string, filteredExpandedKeys: string[]) => void;
|
|
172
|
-
onSelect?: (
|
|
172
|
+
onSelect?: (selectedKey: string, selected: boolean, selectedNode: BasicTreeNodeData) => void;
|
|
173
173
|
preventScroll?: boolean;
|
|
174
174
|
renderDraggingNode?: (nodeInstance: HTMLElement, node: BasicTreeNodeData) => HTMLElement;
|
|
175
175
|
renderFullLabel?: (renderFullLabelProps: BasicRenderFullLabelProps) => any;
|
|
@@ -64,7 +64,7 @@ export interface BasicTreeSelectProps extends Pick<BasicTreeProps, 'virtualize'
|
|
|
64
64
|
restTagsPopoverProps?: any;
|
|
65
65
|
clickTriggerToHide?: boolean;
|
|
66
66
|
loadData?: (data: BasicTreeNodeData) => Promise<void>;
|
|
67
|
-
onSelect?: (
|
|
67
|
+
onSelect?: (selectedKey: string, selected: boolean, selectedNode: BasicTreeNodeData) => void;
|
|
68
68
|
searchRender?: (inputProps: any) => any;
|
|
69
69
|
renderSelectedItem?: BasicRenderSelectedItem;
|
|
70
70
|
getPopupContainer?: () => HTMLElement;
|
|
@@ -89,7 +89,7 @@ export interface TreeSelectAdapter<P = Record<string, any>, S = Record<string, a
|
|
|
89
89
|
unregisterClickOutsideHandler: () => void;
|
|
90
90
|
rePositionDropdown: () => void;
|
|
91
91
|
updateState: (states: Partial<BasicTreeSelectInnerData>) => void;
|
|
92
|
-
notifySelect: (
|
|
92
|
+
notifySelect: (selectedKey: string, selected: boolean, selectedNode: BasicTreeNodeData) => void;
|
|
93
93
|
notifySearch: (input: string, filteredExpandedKeys: string[]) => void;
|
|
94
94
|
cacheFlattenNodes: (bool: boolean) => void;
|
|
95
95
|
openMenu: () => void;
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-foundation",
|
|
3
|
-
"version": "2.43.0
|
|
3
|
+
"version": "2.43.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build:lib": "node ./scripts/compileLib.js",
|
|
7
7
|
"prepublishOnly": "npm run build:lib"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@douyinfe/semi-animation": "2.43.0
|
|
10
|
+
"@douyinfe/semi-animation": "2.43.0",
|
|
11
11
|
"async-validator": "^3.5.0",
|
|
12
12
|
"classnames": "^2.2.6",
|
|
13
13
|
"date-fns": "^2.29.3",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"*.scss",
|
|
24
24
|
"*.css"
|
|
25
25
|
],
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "aa918000b24c716c67439b47d1e7fdf5707d30ff",
|
|
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
|
@@ -66,36 +66,45 @@ class TagInputFoundation extends BaseFoundation<TagInputAdapter> {
|
|
|
66
66
|
};
|
|
67
67
|
|
|
68
68
|
handleInputCompositionStart = (e: any) => {
|
|
69
|
+
const { maxLength } = this.getProps();
|
|
70
|
+
if (!isNumber(maxLength)) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
69
73
|
this._adapter.setEntering(true);
|
|
70
74
|
}
|
|
71
75
|
|
|
72
76
|
handleInputCompositionEnd = (e: any) => {
|
|
73
|
-
this._adapter.setEntering(false);
|
|
74
77
|
const { value } = e.target;
|
|
75
78
|
const {
|
|
76
79
|
maxLength,
|
|
77
80
|
onInputExceed,
|
|
78
81
|
separator
|
|
79
82
|
} = this.getProps();
|
|
83
|
+
if (!isNumber(maxLength)) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
this._adapter.setEntering(false);
|
|
80
87
|
let allowChange = true;
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
isFunction(onInputExceed) && onInputExceed(value);
|
|
89
|
-
break;
|
|
90
|
-
}
|
|
88
|
+
const inputArr = getSplitedArray(value, separator);
|
|
89
|
+
let index = 0;
|
|
90
|
+
for (; index < inputArr.length; index++) {
|
|
91
|
+
if (inputArr[index].length > maxLength) {
|
|
92
|
+
allowChange = false;
|
|
93
|
+
isFunction(onInputExceed) && onInputExceed(value);
|
|
94
|
+
break;
|
|
91
95
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
this._adapter.setInputValue(newInputArr.join(separator));
|
|
96
|
+
}
|
|
97
|
+
if (!allowChange) {
|
|
98
|
+
const newInputArr = inputArr.slice(0, index);
|
|
99
|
+
if (index < inputArr.length) {
|
|
100
|
+
newInputArr.push(inputArr[index].slice(0, maxLength));
|
|
98
101
|
}
|
|
102
|
+
this._adapter.setInputValue(newInputArr.join(separator));
|
|
103
|
+
} else {
|
|
104
|
+
// Why does it need to be updated here instead of in onChange when the value meets the maxLength limit?
|
|
105
|
+
// Because in firefox, the state change in InputCompositionEnd causes onChange to not be triggered after
|
|
106
|
+
// the composition input completes input.
|
|
107
|
+
this._adapter.setInputValue(value);
|
|
99
108
|
}
|
|
100
109
|
}
|
|
101
110
|
|
package/tree/foundation.ts
CHANGED
|
@@ -222,7 +222,7 @@ export interface BasicTreeProps {
|
|
|
222
222
|
onLoad?: (loadedKeys?: Set<string>, treeNode?: BasicTreeNodeData) => void;
|
|
223
223
|
onContextMenu?: (e: any, node: BasicTreeNodeData) => void;
|
|
224
224
|
onSearch?: (sunInput: string, filteredExpandedKeys: string[]) => void;
|
|
225
|
-
onSelect?: (
|
|
225
|
+
onSelect?: (selectedKey: string, selected: boolean, selectedNode: BasicTreeNodeData) => void;
|
|
226
226
|
preventScroll?: boolean;
|
|
227
227
|
renderDraggingNode?: (nodeInstance: HTMLElement, node: BasicTreeNodeData) => HTMLElement;
|
|
228
228
|
renderFullLabel?: (renderFullLabelProps: BasicRenderFullLabelProps) => any;
|
package/treeSelect/foundation.ts
CHANGED
|
@@ -133,7 +133,7 @@ export interface BasicTreeSelectProps extends Pick<BasicTreeProps,
|
|
|
133
133
|
restTagsPopoverProps?: any;
|
|
134
134
|
clickTriggerToHide?: boolean;
|
|
135
135
|
loadData?: (data: BasicTreeNodeData) => Promise<void>;
|
|
136
|
-
onSelect?: (
|
|
136
|
+
onSelect?: (selectedKey: string, selected: boolean, selectedNode: BasicTreeNodeData) => void;
|
|
137
137
|
searchRender?: (inputProps: any) => any;
|
|
138
138
|
renderSelectedItem?: BasicRenderSelectedItem;
|
|
139
139
|
getPopupContainer?: () => HTMLElement;
|
|
@@ -181,7 +181,7 @@ export interface TreeSelectAdapter<P = Record<string, any>, S = Record<string, a
|
|
|
181
181
|
unregisterClickOutsideHandler: () => void;
|
|
182
182
|
rePositionDropdown: () => void;
|
|
183
183
|
updateState: (states: Partial<BasicTreeSelectInnerData>) => void;
|
|
184
|
-
notifySelect: (
|
|
184
|
+
notifySelect: (selectedKey: string, selected: boolean, selectedNode: BasicTreeNodeData) => void;
|
|
185
185
|
notifySearch: (input: string, filteredExpandedKeys: string[]) => void;
|
|
186
186
|
cacheFlattenNodes: (bool: boolean) => void;
|
|
187
187
|
openMenu: () => void;
|