@ng-simplicity/forms-core 1.1.2 → 1.1.4
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 +22 -2
- package/fesm2022/ng-simplicity-forms-core.mjs +292 -75
- package/fesm2022/ng-simplicity-forms-core.mjs.map +1 -1
- package/index.d.ts +181 -82
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -9,12 +9,13 @@ The core engine package for **NG-Simplicity Forms**. This package manages form s
|
|
|
9
9
|
This core package is extended by styling integration packages that provide prebuilt themed form components:
|
|
10
10
|
- **[@ng-simplicity/forms-bootstrap](../forms-bootstrap/README.md)**: Dynamic forms pre-styled with Bootstrap form fields and layouts.
|
|
11
11
|
- **[@ng-simplicity/forms-material](../forms-material/README.md)**: Dynamic forms pre-styled with Angular Material inputs and controls.
|
|
12
|
+
- **[@ng-simplicity/forms-tailwind](../forms-tailwind/README.md)**: Dynamic forms styled with Tailwind CSS utility classes, with every class overridable through `provideNgsFormsTailwindClasses()`.
|
|
12
13
|
|
|
13
14
|
## Compatibility
|
|
14
15
|
|
|
15
16
|
| Package | Package version | Angular support |
|
|
16
17
|
|---|---:|---|
|
|
17
|
-
| `@ng-simplicity/forms-core` | `1.1.
|
|
18
|
+
| `@ng-simplicity/forms-core` | `1.1.4` | `17.x`–`22.x` |
|
|
18
19
|
|
|
19
20
|
---
|
|
20
21
|
|
|
@@ -26,6 +27,16 @@ Add this package to your Angular application:
|
|
|
26
27
|
npm install @ng-simplicity/forms-core
|
|
27
28
|
```
|
|
28
29
|
|
|
30
|
+
To render prebuilt inputs, add one styling package and register its components:
|
|
31
|
+
|
|
32
|
+
| Styling | Install | Register |
|
|
33
|
+
|---|---|---|
|
|
34
|
+
| Bootstrap 5 | `npm install @ng-simplicity/forms-bootstrap bootstrap` | `NgsFormsBootstrapModule.registerAllBootStrapComponents(registry)` |
|
|
35
|
+
| Angular Material | `npm install @ng-simplicity/forms-material` (after `ng add @angular/material`) | `NgsFormsMaterialModule.registerAllMaterialComponents(registry)` |
|
|
36
|
+
| Tailwind CSS | `npm install @ng-simplicity/forms-tailwind`, then add `@source '../node_modules/@ng-simplicity/forms-tailwind';` to your Tailwind stylesheet | `NgsFormsTailwindModule.registerAllTailwindComponents(registry)` |
|
|
37
|
+
|
|
38
|
+
Each `registerAll…` helper also registers the core structural components, so it is the only registration call you need. See each package's README for full setup.
|
|
39
|
+
|
|
29
40
|
---
|
|
30
41
|
|
|
31
42
|
## Architecture Overview
|
|
@@ -386,10 +397,17 @@ import { NgsFormsFormArrayRemoveItemComponent } from '@ng-simplicity/forms-core'
|
|
|
386
397
|
const removeContactBtn = NgsFormsFormArrayRemoveItemComponent.create({
|
|
387
398
|
buttonText: 'Delete',
|
|
388
399
|
buttonClass: 'btn btn-danger',
|
|
389
|
-
buttonIcon: 'trash-icon'
|
|
400
|
+
buttonIcon: 'trash-icon',
|
|
401
|
+
// Optional accessible name. Defaults to `${buttonText} item ${index + 1}`, for example "Delete item 2".
|
|
402
|
+
ariaLabel: (index) => `Delete contact ${index + 1}`,
|
|
390
403
|
});
|
|
391
404
|
```
|
|
392
405
|
|
|
406
|
+
The button always removes its own row, even after earlier rows have been removed. When the removed row held the focus, focus moves to the Remove button of the row that takes its place. Custom components inside a row can inject `NGS_FORMS_ARRAY_ROW` (the row's `UntypedFormGroup`) and use `formArray.controls.indexOf(row)` to find the row's current index; `NGS_FORMS_ITEM_INDEX` is the index the row had when it was created.
|
|
407
|
+
|
|
408
|
+
```typescript
|
|
409
|
+
```
|
|
410
|
+
|
|
393
411
|
### 5. Section (`section`)
|
|
394
412
|
A visual layout grouping with a title and subtitle.
|
|
395
413
|
- **Component**: `NgsFormsFormSectionComponent`
|
|
@@ -402,6 +420,7 @@ import { NgsFormsFormSectionComponent } from '@ng-simplicity/forms-core';
|
|
|
402
420
|
const personalSection = NgsFormsFormSectionComponent.create({
|
|
403
421
|
title: 'Personal Information',
|
|
404
422
|
titleClass: 'custom-title-class', // Optional, defaults to 'h3'
|
|
423
|
+
headingLevel: 2, // Optional heading level announced by screen readers, defaults to 3
|
|
405
424
|
subtitle: 'Tell us a bit about yourself',
|
|
406
425
|
subtitleClass: 'custom-subtitle-class', // Optional, defaults to 'lead'
|
|
407
426
|
items: [
|
|
@@ -521,6 +540,7 @@ Ensure your custom configuration type extends one of these core interfaces for f
|
|
|
521
540
|
Fully functional example applications demonstrating the form engine functionality are located in the [`apps/`](../../apps) folder of this monorepo:
|
|
522
541
|
- **`forms-bootstrap-demo`**: Integrates and showcases the `@ng-simplicity/forms-bootstrap` package.
|
|
523
542
|
- **`forms-material-demo`**: Integrates and showcases the `@ng-simplicity/forms-material` package.
|
|
543
|
+
- **`forms-tailwind-demo`**: Integrates and showcases the `@ng-simplicity/forms-tailwind` package.
|
|
524
544
|
|
|
525
545
|
---
|
|
526
546
|
|