@brandup/ui-input 1.0.43 → 1.0.45
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/README.md +1 -1
- package/package.json +3 -3
- package/source/input.ts +12 -0
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ npm i @brandup/ui-input
|
|
|
12
12
|
|
|
13
13
|
## InputControl
|
|
14
14
|
|
|
15
|
-
`InputControl<T, TEvents>` — абстрактный класс, от которого наследуются все компоненты ввода (`TextBox`, `DropDown`). Расширяет `UIElementBound` из `@brandup/ui`.
|
|
15
|
+
`InputControl<T, TEvents>` — абстрактный класс, от которого наследуются все компоненты ввода (`TextBox`, `MessageEditor`, `DropDown`). Расширяет `UIElementBound` из `@brandup/ui`.
|
|
16
16
|
|
|
17
17
|
### Свойства
|
|
18
18
|
|
package/package.json
CHANGED
|
@@ -24,12 +24,12 @@
|
|
|
24
24
|
"email": "it@brandup.online"
|
|
25
25
|
},
|
|
26
26
|
"license": "Apache-2.0",
|
|
27
|
-
"version": "1.0.
|
|
27
|
+
"version": "1.0.45",
|
|
28
28
|
"main": "source/index.ts",
|
|
29
29
|
"types": "source/index.ts",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@brandup/ui": "^2.0.
|
|
32
|
-
"@brandup/ui-kit": "^1.0.
|
|
31
|
+
"@brandup/ui": "^2.0.9",
|
|
32
|
+
"@brandup/ui-kit": "^1.0.45"
|
|
33
33
|
},
|
|
34
34
|
"files": [
|
|
35
35
|
"source",
|
package/source/input.ts
CHANGED
|
@@ -64,6 +64,12 @@ export abstract class InputControl<T extends InputType, TEvents = {}>
|
|
|
64
64
|
* (например, редактор с отложенной сериализацией). Вызывается перед каждым чтением значения
|
|
65
65
|
* снаружи: валидация, отправка формы, сбор `FormData`. По умолчанию ничего не делает —
|
|
66
66
|
* у контролов, пишущих в поле сразу, синхронизировать нечего.
|
|
67
|
+
*
|
|
68
|
+
* Native constraint validation cannot be intercepted — it runs before the `submit` event.
|
|
69
|
+
* Submitting by button is unaffected: the click moves focus away first, and leaving the field
|
|
70
|
+
* brings the value over. What remains is submitting without losing focus — {@link __requestSubmit}
|
|
71
|
+
* covers the Enter case, while a host-driven `form.requestSubmit()` on a focused field must
|
|
72
|
+
* go through it as well.
|
|
67
73
|
*/
|
|
68
74
|
protected __syncValue(): void {}
|
|
69
75
|
|
|
@@ -120,6 +126,12 @@ export abstract class InputControl<T extends InputType, TEvents = {}>
|
|
|
120
126
|
const form = this.form;
|
|
121
127
|
if (this.readonly || this.disabled || !form) return;
|
|
122
128
|
|
|
129
|
+
// Constraint validation runs before the submit event, so syncing in its handler is too
|
|
130
|
+
// late — the browser would read the value element first. Losing focus normally brings the
|
|
131
|
+
// value over, but submitting by Enter happens without it, and a required field would
|
|
132
|
+
// refuse an empty value while the text is right there.
|
|
133
|
+
this.__syncValue();
|
|
134
|
+
|
|
123
135
|
if (typeof form.requestSubmit !== "function") {
|
|
124
136
|
this.__submitForm(); // движок без requestSubmit — хотя бы уведомим обработчиков
|
|
125
137
|
return;
|