@brandup/ui-textbox 1.0.39 → 1.0.40
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/package.json +4 -4
- package/source/textbox.ts +18 -1
package/package.json
CHANGED
|
@@ -24,15 +24,15 @@
|
|
|
24
24
|
"email": "it@brandup.online"
|
|
25
25
|
},
|
|
26
26
|
"license": "Apache-2.0",
|
|
27
|
-
"version": "1.0.
|
|
27
|
+
"version": "1.0.40",
|
|
28
28
|
"main": "source/index.ts",
|
|
29
29
|
"types": "source/index.ts",
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@brandup/ui": "^2.0.7",
|
|
32
32
|
"@brandup/ui-helpers": "^2.0.7",
|
|
33
|
-
"@brandup/ui-input": "^1.0.
|
|
34
|
-
"@brandup/ui-kit": "^1.0.
|
|
35
|
-
"@brandup/ui-richeditor": "^1.0.
|
|
33
|
+
"@brandup/ui-input": "^1.0.40",
|
|
34
|
+
"@brandup/ui-kit": "^1.0.40",
|
|
35
|
+
"@brandup/ui-richeditor": "^1.0.40"
|
|
36
36
|
},
|
|
37
37
|
"files": [
|
|
38
38
|
"source",
|
package/source/textbox.ts
CHANGED
|
@@ -189,7 +189,7 @@ export default class TextBox extends InputControl<HTMLInputElement | HTMLTextAre
|
|
|
189
189
|
toolbarContainer: container,
|
|
190
190
|
value: valueElem.value,
|
|
191
191
|
onReject: () => this.__toIncorrect(),
|
|
192
|
-
onEnter: () => this.
|
|
192
|
+
onEnter: () => this.__requestSubmit(),
|
|
193
193
|
};
|
|
194
194
|
|
|
195
195
|
// допустим ли вводимый символ по типу.
|
|
@@ -328,6 +328,23 @@ export default class TextBox extends InputControl<HTMLInputElement | HTMLTextAre
|
|
|
328
328
|
// валидация, отправка формы, сбор FormData.
|
|
329
329
|
protected override __syncValue(): void {
|
|
330
330
|
this.__editor.flushChange();
|
|
331
|
+
this.__refreshValidity();
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Собственное ограничение контрола объявляем полю через setCustomValidity — дальше всё
|
|
336
|
+
* делает браузер, как с нативными `required` и `pattern`: блокирует отправку и поднимает
|
|
337
|
+
* invalid. Иначе правило работало бы только в нашем validate(), а форма уезжала бы.
|
|
338
|
+
*
|
|
339
|
+
* Длину меряем по видимому тексту, а не по значению: при format/html в нём теги, в multiline —
|
|
340
|
+
* разделители абзацев. Нативный maxLength здесь не помощник: он ограничивает набор, но не
|
|
341
|
+
* помечает значение, выставленное из кода.
|
|
342
|
+
*/
|
|
343
|
+
private __refreshValidity(): void {
|
|
344
|
+
if (this.maxlength <= 0) return;
|
|
345
|
+
|
|
346
|
+
const tooLong = this.maxlength < this.__editor.getLength();
|
|
347
|
+
this.__valueElem.setCustomValidity(tooLong ? `Не больше ${this.maxlength} символов.` : "");
|
|
331
348
|
}
|
|
332
349
|
|
|
333
350
|
private __toIncorrect() {
|