@douyinfe/semi-foundation 2.51.0-beta.0 → 2.51.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/image/constants.ts +5 -1
- package/input/textareaFoundation.ts +32 -8
- package/lib/cjs/image/constants.d.ts +4 -1
- package/lib/cjs/image/constants.js +6 -2
- package/lib/cjs/input/textareaFoundation.js +34 -8
- package/lib/es/image/constants.d.ts +4 -1
- package/lib/es/image/constants.js +4 -1
- package/lib/es/input/textareaFoundation.js +34 -8
- package/package.json +3 -3
package/image/constants.ts
CHANGED
|
@@ -113,15 +113,21 @@ export default class TextAreaFoundation extends BaseFoundation<TextAreaAdapter>
|
|
|
113
113
|
*/
|
|
114
114
|
handleVisibleMaxLength(value: string) {
|
|
115
115
|
const { maxLength, getValueLength } = this._adapter.getProps();
|
|
116
|
-
if (isNumber(maxLength) && maxLength >= 0 &&
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
116
|
+
if (isNumber(maxLength) && maxLength >= 0 && isString(value)) {
|
|
117
|
+
if (isFunction(getValueLength)) {
|
|
118
|
+
const valueLength = getValueLength(value);
|
|
119
|
+
if (valueLength > maxLength) {
|
|
120
|
+
console.warn('[Semi TextArea] The input character is truncated because the input length exceeds the maximum length limit');
|
|
121
|
+
const truncatedValue = this.handleTruncateValue(value, maxLength);
|
|
122
|
+
return truncatedValue;
|
|
123
|
+
}
|
|
122
124
|
} else {
|
|
123
|
-
|
|
125
|
+
if (value.length > maxLength) {
|
|
126
|
+
console.warn('[Semi TextArea] The input character is truncated because the input length exceeds the maximum length limit');
|
|
127
|
+
return value.slice(0, maxLength);
|
|
128
|
+
}
|
|
124
129
|
}
|
|
130
|
+
return value;
|
|
125
131
|
}
|
|
126
132
|
return undefined;
|
|
127
133
|
}
|
|
@@ -158,8 +164,26 @@ export default class TextAreaFoundation extends BaseFoundation<TextAreaAdapter>
|
|
|
158
164
|
|
|
159
165
|
handleBlur(e: any) {
|
|
160
166
|
const { value } = this.getStates();
|
|
167
|
+
const { maxLength } = this.getProps();
|
|
168
|
+
let realValue = value;
|
|
169
|
+
if (maxLength) {
|
|
170
|
+
// 如果设置了 maxLength,在中文输输入过程中,如果点击外部触发 blur,则拼音字符的所有内容会回显,
|
|
171
|
+
// 该表现不符合 maxLength 规定,因此需要在 blur 的时候二次确认
|
|
172
|
+
// 详情见 https://github.com/DouyinFE/semi-design/issues/2005
|
|
173
|
+
// If maxLength is set, during the Chinese input process, if you click outside to trigger blur,
|
|
174
|
+
// all the contents of the Pinyin characters will be echoed.
|
|
175
|
+
// This behavior does not meet the maxLength requirement, so we need to confirm twice when blurring。
|
|
176
|
+
// For details, see https://github.com/DouyinFE/semi-design/issues/2005
|
|
177
|
+
realValue = this.handleVisibleMaxLength(value);
|
|
178
|
+
if (realValue !== value) {
|
|
179
|
+
if (!this._isControlledComponent()) {
|
|
180
|
+
this._adapter.setValue(realValue);
|
|
181
|
+
}
|
|
182
|
+
this._adapter.notifyChange(realValue, e);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
161
185
|
this._adapter.toggleFocusing(false);
|
|
162
|
-
this._adapter.notifyBlur(
|
|
186
|
+
this._adapter.notifyBlur(realValue, e);
|
|
163
187
|
}
|
|
164
188
|
|
|
165
189
|
handleKeyDown(e: any) {
|
|
@@ -3,9 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.cssClasses = void 0;
|
|
6
|
+
exports.numbers = exports.cssClasses = void 0;
|
|
7
7
|
var _constants = require("../base/constants");
|
|
8
8
|
const cssClasses = {
|
|
9
9
|
PREFIX: `${_constants.BASE_CLASS_PREFIX}-image`
|
|
10
10
|
};
|
|
11
|
-
exports.cssClasses = cssClasses;
|
|
11
|
+
exports.cssClasses = cssClasses;
|
|
12
|
+
const numbers = {
|
|
13
|
+
DEFAULT_Z_INDEX: 1070
|
|
14
|
+
};
|
|
15
|
+
exports.numbers = numbers;
|
|
@@ -123,15 +123,21 @@ class TextAreaFoundation extends _foundation.default {
|
|
|
123
123
|
maxLength,
|
|
124
124
|
getValueLength
|
|
125
125
|
} = this._adapter.getProps();
|
|
126
|
-
if ((0, _isNumber2.default)(maxLength) && maxLength >= 0 && (0,
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
126
|
+
if ((0, _isNumber2.default)(maxLength) && maxLength >= 0 && (0, _isString2.default)(value)) {
|
|
127
|
+
if ((0, _isFunction2.default)(getValueLength)) {
|
|
128
|
+
const valueLength = getValueLength(value);
|
|
129
|
+
if (valueLength > maxLength) {
|
|
130
|
+
console.warn('[Semi TextArea] The input character is truncated because the input length exceeds the maximum length limit');
|
|
131
|
+
const truncatedValue = this.handleTruncateValue(value, maxLength);
|
|
132
|
+
return truncatedValue;
|
|
133
|
+
}
|
|
132
134
|
} else {
|
|
133
|
-
|
|
135
|
+
if (value.length > maxLength) {
|
|
136
|
+
console.warn('[Semi TextArea] The input character is truncated because the input length exceeds the maximum length limit');
|
|
137
|
+
return value.slice(0, maxLength);
|
|
138
|
+
}
|
|
134
139
|
}
|
|
140
|
+
return value;
|
|
135
141
|
}
|
|
136
142
|
return undefined;
|
|
137
143
|
}
|
|
@@ -171,8 +177,28 @@ class TextAreaFoundation extends _foundation.default {
|
|
|
171
177
|
const {
|
|
172
178
|
value
|
|
173
179
|
} = this.getStates();
|
|
180
|
+
const {
|
|
181
|
+
maxLength
|
|
182
|
+
} = this.getProps();
|
|
183
|
+
let realValue = value;
|
|
184
|
+
if (maxLength) {
|
|
185
|
+
// 如果设置了 maxLength,在中文输输入过程中,如果点击外部触发 blur,则拼音字符的所有内容会回显,
|
|
186
|
+
// 该表现不符合 maxLength 规定,因此需要在 blur 的时候二次确认
|
|
187
|
+
// 详情见 https://github.com/DouyinFE/semi-design/issues/2005
|
|
188
|
+
// If maxLength is set, during the Chinese input process, if you click outside to trigger blur,
|
|
189
|
+
// all the contents of the Pinyin characters will be echoed.
|
|
190
|
+
// This behavior does not meet the maxLength requirement, so we need to confirm twice when blurring。
|
|
191
|
+
// For details, see https://github.com/DouyinFE/semi-design/issues/2005
|
|
192
|
+
realValue = this.handleVisibleMaxLength(value);
|
|
193
|
+
if (realValue !== value) {
|
|
194
|
+
if (!this._isControlledComponent()) {
|
|
195
|
+
this._adapter.setValue(realValue);
|
|
196
|
+
}
|
|
197
|
+
this._adapter.notifyChange(realValue, e);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
174
200
|
this._adapter.toggleFocusing(false);
|
|
175
|
-
this._adapter.notifyBlur(
|
|
201
|
+
this._adapter.notifyBlur(realValue, e);
|
|
176
202
|
}
|
|
177
203
|
handleKeyDown(e) {
|
|
178
204
|
this._adapter.notifyKeyDown(e);
|
|
@@ -116,15 +116,21 @@ export default class TextAreaFoundation extends BaseFoundation {
|
|
|
116
116
|
maxLength,
|
|
117
117
|
getValueLength
|
|
118
118
|
} = this._adapter.getProps();
|
|
119
|
-
if (_isNumber(maxLength) && maxLength >= 0 &&
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
119
|
+
if (_isNumber(maxLength) && maxLength >= 0 && _isString(value)) {
|
|
120
|
+
if (_isFunction(getValueLength)) {
|
|
121
|
+
const valueLength = getValueLength(value);
|
|
122
|
+
if (valueLength > maxLength) {
|
|
123
|
+
console.warn('[Semi TextArea] The input character is truncated because the input length exceeds the maximum length limit');
|
|
124
|
+
const truncatedValue = this.handleTruncateValue(value, maxLength);
|
|
125
|
+
return truncatedValue;
|
|
126
|
+
}
|
|
125
127
|
} else {
|
|
126
|
-
|
|
128
|
+
if (value.length > maxLength) {
|
|
129
|
+
console.warn('[Semi TextArea] The input character is truncated because the input length exceeds the maximum length limit');
|
|
130
|
+
return value.slice(0, maxLength);
|
|
131
|
+
}
|
|
127
132
|
}
|
|
133
|
+
return value;
|
|
128
134
|
}
|
|
129
135
|
return undefined;
|
|
130
136
|
}
|
|
@@ -164,8 +170,28 @@ export default class TextAreaFoundation extends BaseFoundation {
|
|
|
164
170
|
const {
|
|
165
171
|
value
|
|
166
172
|
} = this.getStates();
|
|
173
|
+
const {
|
|
174
|
+
maxLength
|
|
175
|
+
} = this.getProps();
|
|
176
|
+
let realValue = value;
|
|
177
|
+
if (maxLength) {
|
|
178
|
+
// 如果设置了 maxLength,在中文输输入过程中,如果点击外部触发 blur,则拼音字符的所有内容会回显,
|
|
179
|
+
// 该表现不符合 maxLength 规定,因此需要在 blur 的时候二次确认
|
|
180
|
+
// 详情见 https://github.com/DouyinFE/semi-design/issues/2005
|
|
181
|
+
// If maxLength is set, during the Chinese input process, if you click outside to trigger blur,
|
|
182
|
+
// all the contents of the Pinyin characters will be echoed.
|
|
183
|
+
// This behavior does not meet the maxLength requirement, so we need to confirm twice when blurring。
|
|
184
|
+
// For details, see https://github.com/DouyinFE/semi-design/issues/2005
|
|
185
|
+
realValue = this.handleVisibleMaxLength(value);
|
|
186
|
+
if (realValue !== value) {
|
|
187
|
+
if (!this._isControlledComponent()) {
|
|
188
|
+
this._adapter.setValue(realValue);
|
|
189
|
+
}
|
|
190
|
+
this._adapter.notifyChange(realValue, e);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
167
193
|
this._adapter.toggleFocusing(false);
|
|
168
|
-
this._adapter.notifyBlur(
|
|
194
|
+
this._adapter.notifyBlur(realValue, e);
|
|
169
195
|
}
|
|
170
196
|
handleKeyDown(e) {
|
|
171
197
|
this._adapter.notifyKeyDown(e);
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-foundation",
|
|
3
|
-
"version": "2.51.0
|
|
3
|
+
"version": "2.51.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.51.0
|
|
10
|
+
"@douyinfe/semi-animation": "2.51.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": "5a554bf517411b933e891ad51b874bd9eb6c87c6",
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@babel/plugin-transform-runtime": "^7.15.8",
|
|
29
29
|
"@babel/preset-env": "^7.15.8",
|