ng-hub-ui-forms 21.0.0 → 22.1.1
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 +38 -1
- package/fesm2022/ng-hub-ui-forms.mjs +51 -12
- package/fesm2022/ng-hub-ui-forms.mjs.map +1 -1
- package/ng-hub-ui-forms-22.1.1.tgz +0 -0
- package/package.json +1 -1
- package/src/lib/styles/_field.scss +16 -0
- package/src/lib/styles/_tokens.scss +20 -10
- package/types/ng-hub-ui-forms.d.ts +20 -1
- package/ng-hub-ui-forms-21.0.0.tgz +0 -0
package/README.md
CHANGED
|
@@ -26,13 +26,16 @@ This library is part of the **ng-hub-ui** ecosystem:
|
|
|
26
26
|
- [**ng-hub-ui-breadcrumbs**](https://www.npmjs.com/package/ng-hub-ui-breadcrumbs)
|
|
27
27
|
- [**ng-hub-ui-calendar**](https://www.npmjs.com/package/ng-hub-ui-calendar)
|
|
28
28
|
- [**ng-hub-ui-dropdown**](https://www.npmjs.com/package/ng-hub-ui-dropdown)
|
|
29
|
+
- [**ng-hub-ui-ds**](https://www.npmjs.com/package/ng-hub-ui-ds)
|
|
29
30
|
- [**ng-hub-ui-forms**](https://www.npmjs.com/package/ng-hub-ui-forms) ← You are here
|
|
30
31
|
- [**ng-hub-ui-history**](https://www.npmjs.com/package/ng-hub-ui-history)
|
|
32
|
+
- [**ng-hub-ui-milestones**](https://www.npmjs.com/package/ng-hub-ui-milestones)
|
|
31
33
|
- [**ng-hub-ui-modal**](https://www.npmjs.com/package/ng-hub-ui-modal)
|
|
32
34
|
- [**ng-hub-ui-nav**](https://www.npmjs.com/package/ng-hub-ui-nav)
|
|
33
35
|
- [**ng-hub-ui-paginable**](https://www.npmjs.com/package/ng-hub-ui-paginable)
|
|
34
36
|
- [**ng-hub-ui-panels**](https://www.npmjs.com/package/ng-hub-ui-panels)
|
|
35
37
|
- [**ng-hub-ui-portal**](https://www.npmjs.com/package/ng-hub-ui-portal)
|
|
38
|
+
- [**ng-hub-ui-skeleton**](https://www.npmjs.com/package/ng-hub-ui-skeleton)
|
|
36
39
|
- [**ng-hub-ui-sortable**](https://www.npmjs.com/package/ng-hub-ui-sortable)
|
|
37
40
|
- [**ng-hub-ui-stepper**](https://www.npmjs.com/package/ng-hub-ui-stepper)
|
|
38
41
|
- [**ng-hub-ui-utils**](https://www.npmjs.com/package/ng-hub-ui-utils)
|
|
@@ -88,7 +91,7 @@ mode — no Bootstrap dependency.
|
|
|
88
91
|
|
|
89
92
|
## 🎯 Features
|
|
90
93
|
|
|
91
|
-
- **Fields** — `hub-input` (text/number/email/password/color/switch/checkbox/counter, with input-group addons & masks), `hub-otp`, `hub-textarea` (+ `hubAutoresize`), `hub-slider`, `hub-select` (dropdown / buttons / checkbox / radio formats, grouping, typeahead, custom templates), `hub-datepicker` (single & range, keyboard nav, i18n).
|
|
94
|
+
- **Fields** — `hub-input` (text/number/email/password/color/switch/checkbox/counter, with input-group addons & masks), `hub-otp-input`, `hub-textarea` (+ `hubAutoresize`), `hub-slider`, `hub-select` (dropdown / buttons / checkbox / radio formats, grouping, typeahead, custom templates), `hub-datepicker` (single & range, keyboard nav, i18n).
|
|
92
95
|
- **Automatic error display** — bind a field and its control errors render below it; `hub-fieldset`, `form[hubForm]` and `hub-legend` surface group- and form-level (cross-field) errors the same way, with zero wiring.
|
|
93
96
|
- **Containers** — `hub-fieldset` / `form[hubForm]` group fields and show their group errors; `hub-legend` renders an accessible legend.
|
|
94
97
|
- **Configurable** — `provideHubForms({ … })` sets the invalid-feedback templates, datepicker locale/labels and more, app-wide or per instance.
|
|
@@ -182,6 +185,22 @@ form = new FormGroup(
|
|
|
182
185
|
On submit, each invalid field shows its error and the cross-field `hubAreEqual`
|
|
183
186
|
error is surfaced by the fieldset/form — no manual error markup anywhere.
|
|
184
187
|
|
|
188
|
+
### Validation states (invalid is automatic, valid is opt-in)
|
|
189
|
+
|
|
190
|
+
The **invalid** state is always automatic: a touched, invalid field shows its
|
|
191
|
+
error styling and message with no configuration. The **valid / success** state is
|
|
192
|
+
strictly **opt-in** — success is *never* shown automatically. Enable it per field
|
|
193
|
+
with the `showValid` input, and optionally add a `validFeedback` message that
|
|
194
|
+
renders below the control once the field is touched and valid:
|
|
195
|
+
|
|
196
|
+
```html
|
|
197
|
+
<hub-input formControlName="username" label="Username" required [showValid]="true" validFeedback="Looks good!" />
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
To turn the success state on for every field at once, set it globally — see
|
|
201
|
+
[Configuration](#-configuration). A per-field `showValid` always overrides the
|
|
202
|
+
global default.
|
|
203
|
+
|
|
185
204
|
---
|
|
186
205
|
|
|
187
206
|
## 🛠️ Configuration
|
|
@@ -194,12 +213,18 @@ import { provideHubForms } from 'ng-hub-ui-forms';
|
|
|
194
213
|
bootstrapApplication(AppComponent, {
|
|
195
214
|
providers: [
|
|
196
215
|
provideHubForms({
|
|
216
|
+
showValid: true,
|
|
197
217
|
datepicker: { firstDayOfWeek: 1, displayFormat: 'dd/MM/yyyy' }
|
|
198
218
|
})
|
|
199
219
|
]
|
|
200
220
|
});
|
|
201
221
|
```
|
|
202
222
|
|
|
223
|
+
`showValid` (default `false`) turns the opt-in valid/success state on for every
|
|
224
|
+
field once it is touched and valid. The invalid state is unaffected — it is always
|
|
225
|
+
automatic; only success is gated behind this flag. A per-field `showValid` input
|
|
226
|
+
overrides the global default.
|
|
227
|
+
|
|
203
228
|
---
|
|
204
229
|
|
|
205
230
|
## 🎨 Styling
|
|
@@ -219,6 +244,18 @@ hub-select {
|
|
|
219
244
|
}
|
|
220
245
|
```
|
|
221
246
|
|
|
247
|
+
The opt-in valid/success state is themed through four tokens (chained to the
|
|
248
|
+
`--hub-sys-color-success` family by default):
|
|
249
|
+
|
|
250
|
+
```css
|
|
251
|
+
hub-input {
|
|
252
|
+
--hub-form-valid-color: #198754;
|
|
253
|
+
--hub-form-valid-border-color: #198754;
|
|
254
|
+
--hub-form-valid-focus-ring-color: rgba(25, 135, 84, 0.25);
|
|
255
|
+
--hub-form-valid-feedback-color: #198754;
|
|
256
|
+
}
|
|
257
|
+
```
|
|
258
|
+
|
|
222
259
|
---
|
|
223
260
|
|
|
224
261
|
## ✨ Signal Forms (opt-in)
|