@dynamic-field-kit/angular 1.2.2 → 1.2.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 +58 -76
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,56 +1,65 @@
|
|
|
1
1
|
# @dynamic-field-kit/angular
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Angular adapter for `@dynamic-field-kit/core`.
|
|
4
4
|
|
|
5
|
-
This package
|
|
5
|
+
This package provides Angular components and a convenience module that render field schemas defined with `@dynamic-field-kit/core`.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- Exports `DynamicInput`, `FieldInput`, `MultiFieldInput`, layout components, and `DynamicFieldKitModule`.
|
|
9
|
-
- Uses the shared `fieldRegistry` from `@dynamic-field-kit/core` to resolve Angular field renderers at runtime.
|
|
10
|
-
- Can be consumed in two modes: npm package mode for external apps, or local development mode from `packages/angular/dist`.
|
|
11
|
-
- `MultiFieldInput` currently supports `column`, `row`, and `grid` layout values.
|
|
7
|
+
Demo app: https://github.com/vannt-dev/dynamic-field-kit-demo
|
|
12
8
|
|
|
13
|
-
|
|
9
|
+
## Install
|
|
14
10
|
|
|
15
|
-
|
|
11
|
+
```bash
|
|
12
|
+
npm install @dynamic-field-kit/core @dynamic-field-kit/angular
|
|
13
|
+
```
|
|
16
14
|
|
|
17
|
-
|
|
15
|
+
If you need to pin versions explicitly:
|
|
18
16
|
|
|
19
17
|
```bash
|
|
20
|
-
npm install @dynamic-field-kit/core @dynamic-field-kit/angular
|
|
18
|
+
npm install @dynamic-field-kit/core@^1.0.12 @dynamic-field-kit/angular@^1.2.3
|
|
21
19
|
```
|
|
22
20
|
|
|
23
|
-
|
|
21
|
+
## What it exports
|
|
22
|
+
|
|
23
|
+
- `DynamicInput`
|
|
24
|
+
- `FieldInput`
|
|
25
|
+
- `MultiFieldInput`
|
|
26
|
+
- `DynamicFieldKitModule`
|
|
27
|
+
- `fieldRegistry`
|
|
28
|
+
|
|
29
|
+
## Basic setup
|
|
30
|
+
|
|
31
|
+
1. Import `DynamicFieldKitModule` in your Angular module.
|
|
24
32
|
|
|
25
33
|
```ts
|
|
26
|
-
import {
|
|
27
|
-
|
|
28
|
-
@
|
|
29
|
-
|
|
30
|
-
|
|
34
|
+
import { BrowserModule } from "@angular/platform-browser"
|
|
35
|
+
import { NgModule } from "@angular/core"
|
|
36
|
+
import { DynamicFieldKitModule } from "@dynamic-field-kit/angular"
|
|
37
|
+
|
|
38
|
+
@NgModule({
|
|
39
|
+
imports: [BrowserModule, DynamicFieldKitModule],
|
|
40
|
+
})
|
|
31
41
|
export class AppModule {}
|
|
32
42
|
```
|
|
33
43
|
|
|
34
|
-
|
|
44
|
+
2. Register Angular field components before bootstrap.
|
|
35
45
|
|
|
36
46
|
```ts
|
|
37
|
-
|
|
38
|
-
import
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
41
|
-
import {
|
|
42
|
-
import {
|
|
43
|
-
import { NumberFieldComponent } from './app/components/number-field.component'
|
|
47
|
+
import "zone.js"
|
|
48
|
+
import { platformBrowserDynamic } from "@angular/platform-browser-dynamic"
|
|
49
|
+
import { fieldRegistry } from "@dynamic-field-kit/angular"
|
|
50
|
+
import { AppModule } from "./app/app.module"
|
|
51
|
+
import { TextFieldComponent } from "./app/components/text-field.component"
|
|
52
|
+
import { NumberFieldComponent } from "./app/components/number-field.component"
|
|
44
53
|
|
|
45
|
-
fieldRegistry.register(
|
|
46
|
-
fieldRegistry.register(
|
|
54
|
+
fieldRegistry.register("text", TextFieldComponent as any)
|
|
55
|
+
fieldRegistry.register("number", NumberFieldComponent as any)
|
|
47
56
|
|
|
48
57
|
platformBrowserDynamic()
|
|
49
58
|
.bootstrapModule(AppModule)
|
|
50
59
|
.catch((err) => console.error(err))
|
|
51
60
|
```
|
|
52
61
|
|
|
53
|
-
|
|
62
|
+
3. Render your schema in a template.
|
|
54
63
|
|
|
55
64
|
```html
|
|
56
65
|
<dfk-multi-field-input
|
|
@@ -60,20 +69,20 @@ platformBrowserDynamic()
|
|
|
60
69
|
></dfk-multi-field-input>
|
|
61
70
|
```
|
|
62
71
|
|
|
63
|
-
|
|
72
|
+
4. Define your field schema in the component.
|
|
64
73
|
|
|
65
74
|
```ts
|
|
66
|
-
import { Component } from
|
|
67
|
-
import { FieldDescription } from
|
|
75
|
+
import { Component } from "@angular/core"
|
|
76
|
+
import { FieldDescription } from "@dynamic-field-kit/core"
|
|
68
77
|
|
|
69
78
|
@Component({
|
|
70
|
-
selector:
|
|
71
|
-
templateUrl:
|
|
79
|
+
selector: "app-root",
|
|
80
|
+
templateUrl: "./app.component.html",
|
|
72
81
|
})
|
|
73
82
|
export class AppComponent {
|
|
74
83
|
fields: FieldDescription[] = [
|
|
75
|
-
{ name:
|
|
76
|
-
{ name:
|
|
84
|
+
{ name: "name", type: "text", label: "Name" },
|
|
85
|
+
{ name: "age", type: "number", label: "Age" },
|
|
77
86
|
]
|
|
78
87
|
|
|
79
88
|
data: any = {}
|
|
@@ -84,53 +93,26 @@ export class AppComponent {
|
|
|
84
93
|
}
|
|
85
94
|
```
|
|
86
95
|
|
|
87
|
-
|
|
96
|
+
## Type augmentation
|
|
88
97
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
1. Point your Angular app at the built package output instead of importing from `src/`:
|
|
98
|
+
```ts
|
|
99
|
+
import "@dynamic-field-kit/core"
|
|
92
100
|
|
|
93
|
-
|
|
94
|
-
{
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
"@dynamic-field-kit/angular": "file:../../packages/angular/dist"
|
|
101
|
+
declare module "@dynamic-field-kit/core" {
|
|
102
|
+
interface FieldTypeMap {
|
|
103
|
+
text: string
|
|
104
|
+
number: number
|
|
98
105
|
}
|
|
99
106
|
}
|
|
100
107
|
```
|
|
101
108
|
|
|
102
|
-
|
|
109
|
+
## Notes
|
|
103
110
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
3. When using a local `file:` dependency on Windows or via symlinked installs, set `preserveSymlinks: true` in the Angular builder options to avoid runtime issues with linked packages.
|
|
110
|
-
|
|
111
|
-
Build & publish
|
|
112
|
-
- Build locally with `ng-packagr`:
|
|
113
|
-
|
|
114
|
-
```bash
|
|
115
|
-
cd packages/angular
|
|
116
|
-
npm run build
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
- Publish to npm:
|
|
120
|
-
|
|
121
|
-
```bash
|
|
122
|
-
cd packages/angular
|
|
123
|
-
npm run build
|
|
124
|
-
npm run publish:dist
|
|
125
|
-
```
|
|
111
|
+
- Register Angular component classes in `fieldRegistry`.
|
|
112
|
+
- Do not register React or Vue renderers in the Angular adapter.
|
|
113
|
+
- `MultiFieldInput` supports `column`, `row`, and `grid` layouts.
|
|
114
|
+
- The shared schema and field types still come from `@dynamic-field-kit/core`.
|
|
126
115
|
|
|
127
|
-
|
|
128
|
-
- Register Angular component classes in `fieldRegistry`. Do not register React or Vue renderers when using the Angular adapter.
|
|
129
|
-
- `DynamicFieldKitModule` is the recommended integration path for consumer apps.
|
|
130
|
-
- Standalone exports are still available for advanced composition, but most apps should start with the module.
|
|
131
|
-
- Text fields default to an empty string when no value is present, so empty controls render as blank instead of `undefined`.
|
|
132
|
-
- Supported `layout` values are `column`, `row`, and `grid`.
|
|
116
|
+
## License
|
|
133
117
|
|
|
134
|
-
|
|
135
|
-
- See `example/angular-app/angular-instructions.md` for detailed wiring steps.
|
|
136
|
-
- Try the local scaffold at `example/angular-app/` for a hands-on demo.
|
|
118
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-field-kit/angular",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
4
4
|
"description": "Angular renderer for dynamic-field-kit",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"private": false,
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"peerDependencies": {
|
|
11
11
|
"@angular/common": ">=13 <22",
|
|
12
12
|
"@angular/core": ">=13 <22",
|
|
13
|
-
"@dynamic-field-kit/core": "^1.0.
|
|
13
|
+
"@dynamic-field-kit/core": "^1.0.13"
|
|
14
14
|
},
|
|
15
15
|
"publishConfig": {
|
|
16
16
|
"access": "public"
|