@dynamic-field-kit/angular 1.2.4 → 1.2.10
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 +54 -46
- package/dist/README.md +126 -0
- package/dist/components/BaseInput.d.ts +22 -0
- package/{components → dist/components}/DynamicInput.d.ts +24 -28
- package/dist/components/FieldInput.d.ts +14 -0
- package/{components → dist/components}/MultiFieldInput.d.ts +23 -23
- package/dist/esm2022/components/BaseInput.mjs +60 -0
- package/dist/esm2022/components/DynamicInput.mjs +162 -0
- package/dist/esm2022/components/FieldInput.mjs +71 -0
- package/dist/esm2022/components/MultiFieldInput.mjs +85 -0
- package/{esm2020 → dist/esm2022}/dynamic-field-kit-angular.mjs +4 -4
- package/dist/esm2022/layout/defaultLayouts.mjs +67 -0
- package/{esm2020 → dist/esm2022}/layout/index.mjs +2 -2
- package/dist/esm2022/lib/dynamic-field-kit.module.mjs +52 -0
- package/{esm2020 → dist/esm2022}/public-api.mjs +14 -14
- package/{esm2020 → dist/esm2022}/types/layout.mjs +2 -2
- package/{fesm2020 → dist/fesm2022}/dynamic-field-kit-angular.mjs +434 -337
- package/dist/fesm2022/dynamic-field-kit-angular.mjs.map +1 -0
- package/{index.d.ts → dist/index.d.ts} +5 -5
- package/{layout → dist/layout}/defaultLayouts.d.ts +13 -13
- package/dist/layout/index.d.ts +1 -0
- package/{lib → dist/lib}/dynamic-field-kit.module.d.ts +11 -11
- package/{public-api.d.ts → dist/public-api.d.ts} +9 -9
- package/dist/types/layout.d.ts +1 -0
- package/ng-package.json +7 -0
- package/package.json +31 -28
- package/src/adapters/tailwind.ts +13 -0
- package/src/components/BaseInput.ts +31 -0
- package/src/components/DynamicInput.ts +188 -0
- package/src/components/FieldInput.ts +49 -0
- package/src/components/MultiFieldInput.ts +75 -0
- package/src/components/imports.ts +3 -0
- package/src/examples/index.ts +4 -0
- package/src/examples/registerExample.ts +7 -0
- package/src/examples/text-field.component.ts +18 -0
- package/src/layout/defaultLayouts.ts +38 -0
- package/src/layout/index.ts +1 -0
- package/src/lib/dynamic-field-kit.module.ts +29 -0
- package/src/public-api.ts +24 -0
- package/src/types/layout.ts +1 -0
- package/src/types.ts +1 -0
- package/tsconfig.json +13 -0
- package/components/BaseInput.d.ts +0 -22
- package/components/FieldInput.d.ts +0 -14
- package/esm2020/components/BaseInput.mjs +0 -46
- package/esm2020/components/DynamicInput.mjs +0 -146
- package/esm2020/components/FieldInput.mjs +0 -66
- package/esm2020/components/MultiFieldInput.mjs +0 -79
- package/esm2020/layout/defaultLayouts.mjs +0 -43
- package/esm2020/lib/dynamic-field-kit.module.mjs +0 -20
- package/fesm2015/dynamic-field-kit-angular.mjs +0 -393
- package/fesm2015/dynamic-field-kit-angular.mjs.map +0 -1
- package/fesm2020/dynamic-field-kit-angular.mjs.map +0 -1
- package/layout/index.d.ts +0 -1
- package/types/layout.d.ts +0 -1
|
@@ -1,210 +1,240 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { EventEmitter,
|
|
2
|
+
import { EventEmitter, Output, Input, Component, SimpleChange, ViewContainerRef, ViewChild, NgModule } from '@angular/core';
|
|
3
3
|
import { CommonModule, NgIf, NgClass, NgFor } from '@angular/common';
|
|
4
4
|
import { fieldRegistry } from '@dynamic-field-kit/core';
|
|
5
5
|
export { fieldRegistry } from '@dynamic-field-kit/core';
|
|
6
6
|
|
|
7
|
-
class BaseInputComponent {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
type: Input
|
|
37
|
-
}],
|
|
38
|
-
type: Input
|
|
39
|
-
}],
|
|
40
|
-
type: Input
|
|
41
|
-
}],
|
|
42
|
-
type: Input
|
|
43
|
-
}],
|
|
44
|
-
type: Input
|
|
45
|
-
}],
|
|
46
|
-
type: Input
|
|
47
|
-
}],
|
|
48
|
-
type:
|
|
7
|
+
class BaseInputComponent {
|
|
8
|
+
cdr;
|
|
9
|
+
value;
|
|
10
|
+
label;
|
|
11
|
+
placeholder;
|
|
12
|
+
required;
|
|
13
|
+
disabled;
|
|
14
|
+
options;
|
|
15
|
+
className;
|
|
16
|
+
description;
|
|
17
|
+
errorMessage;
|
|
18
|
+
acceptFile;
|
|
19
|
+
maxLength;
|
|
20
|
+
minNumber;
|
|
21
|
+
maxNumber;
|
|
22
|
+
// Add more from mplis as needed
|
|
23
|
+
valueChange = new EventEmitter();
|
|
24
|
+
constructor(cdr) {
|
|
25
|
+
this.cdr = cdr;
|
|
26
|
+
}
|
|
27
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: BaseInputComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
28
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.20", type: BaseInputComponent, isStandalone: true, selector: "ng-component", inputs: { value: "value", label: "label", placeholder: "placeholder", required: "required", disabled: "disabled", options: "options", className: "className", description: "description", errorMessage: "errorMessage", acceptFile: "acceptFile", maxLength: "maxLength", minNumber: "minNumber", maxNumber: "maxNumber" }, outputs: { valueChange: "valueChange" }, ngImport: i0, template: '', isInline: true });
|
|
29
|
+
}
|
|
30
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: BaseInputComponent, decorators: [{
|
|
31
|
+
type: Component,
|
|
32
|
+
args: [{
|
|
33
|
+
template: '',
|
|
34
|
+
}]
|
|
35
|
+
}], ctorParameters: () => [{ type: i0.ChangeDetectorRef }], propDecorators: { value: [{
|
|
36
|
+
type: Input
|
|
37
|
+
}], label: [{
|
|
38
|
+
type: Input
|
|
39
|
+
}], placeholder: [{
|
|
40
|
+
type: Input
|
|
41
|
+
}], required: [{
|
|
42
|
+
type: Input
|
|
43
|
+
}], disabled: [{
|
|
44
|
+
type: Input
|
|
45
|
+
}], options: [{
|
|
46
|
+
type: Input
|
|
47
|
+
}], className: [{
|
|
48
|
+
type: Input
|
|
49
|
+
}], description: [{
|
|
50
|
+
type: Input
|
|
51
|
+
}], errorMessage: [{
|
|
52
|
+
type: Input
|
|
53
|
+
}], acceptFile: [{
|
|
54
|
+
type: Input
|
|
55
|
+
}], maxLength: [{
|
|
56
|
+
type: Input
|
|
57
|
+
}], minNumber: [{
|
|
58
|
+
type: Input
|
|
59
|
+
}], maxNumber: [{
|
|
60
|
+
type: Input
|
|
61
|
+
}], valueChange: [{
|
|
62
|
+
type: Output
|
|
49
63
|
}] } });
|
|
50
64
|
|
|
51
|
-
class DynamicInput extends BaseInputComponent {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
this.
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
this.
|
|
96
|
-
this.
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
65
|
+
class DynamicInput extends BaseInputComponent {
|
|
66
|
+
type;
|
|
67
|
+
valueChange = new EventEmitter();
|
|
68
|
+
onChange = new EventEmitter(); // backward compat
|
|
69
|
+
host;
|
|
70
|
+
compRef;
|
|
71
|
+
inputInstance;
|
|
72
|
+
subscriptions = [];
|
|
73
|
+
ngOnChanges(changes) {
|
|
74
|
+
if (changes['type'] && !changes['type'].firstChange && this.host) {
|
|
75
|
+
this.render();
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
if (this.inputInstance) {
|
|
79
|
+
this.applyKnownProps(this.inputInstance);
|
|
80
|
+
const childChanges = {};
|
|
81
|
+
for (const prop in changes) {
|
|
82
|
+
childChanges[prop] = new SimpleChange(changes[prop].previousValue, changes[prop].currentValue, changes[prop].firstChange);
|
|
83
|
+
}
|
|
84
|
+
this.inputInstance.ngOnChanges?.(childChanges);
|
|
85
|
+
this.compRef?.changeDetectorRef.detectChanges();
|
|
86
|
+
}
|
|
87
|
+
else if (this.host) {
|
|
88
|
+
this.render();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
ngAfterViewInit() {
|
|
92
|
+
this.render();
|
|
93
|
+
}
|
|
94
|
+
ngOnDestroy() {
|
|
95
|
+
this.cleanupSubscriptions();
|
|
96
|
+
this.cleanupRenderedComponent();
|
|
97
|
+
}
|
|
98
|
+
cleanupSubscriptions() {
|
|
99
|
+
this.subscriptions.forEach((s) => s.unsubscribe());
|
|
100
|
+
this.subscriptions = [];
|
|
101
|
+
}
|
|
102
|
+
render() {
|
|
103
|
+
const Renderer = fieldRegistry.get(this.type);
|
|
104
|
+
this.cleanupRenderedComponent();
|
|
105
|
+
this.cleanupSubscriptions();
|
|
106
|
+
this.host.clear();
|
|
107
|
+
if (!Renderer) {
|
|
108
|
+
const el = document.createElement('div');
|
|
109
|
+
el.textContent = `Unknown field type: ${this.type}`;
|
|
110
|
+
this.host.element.nativeElement.appendChild(el);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
try {
|
|
114
|
+
const compType = Renderer;
|
|
115
|
+
const compRef = this.host.createComponent(compType);
|
|
116
|
+
const instance = compRef.instance;
|
|
117
|
+
if (!instance) {
|
|
118
|
+
throw new Error(`Failed to create instance for ${this.type}`);
|
|
119
|
+
}
|
|
120
|
+
this.applyKnownProps(instance);
|
|
121
|
+
const subA = this.bindOutput(instance, 'valueChange');
|
|
122
|
+
if (subA) {
|
|
123
|
+
this.subscriptions.push(subA);
|
|
124
|
+
}
|
|
125
|
+
const subB = this.bindOutput(instance, 'onValueChange');
|
|
126
|
+
if (subB) {
|
|
127
|
+
this.subscriptions.push(subB);
|
|
128
|
+
}
|
|
129
|
+
instance.changeDetectorRef?.detectChanges();
|
|
130
|
+
this.compRef = compRef;
|
|
131
|
+
this.inputInstance = instance;
|
|
132
|
+
compRef.changeDetectorRef.detectChanges();
|
|
133
|
+
}
|
|
134
|
+
catch (err) {
|
|
135
|
+
// Fallback to function renderer
|
|
136
|
+
try {
|
|
137
|
+
const props = {
|
|
138
|
+
value: this.value,
|
|
139
|
+
onValueChange: (v) => this.emitValue(v),
|
|
140
|
+
label: this.label,
|
|
141
|
+
placeholder: this.placeholder,
|
|
142
|
+
required: this.required,
|
|
143
|
+
options: this.options,
|
|
144
|
+
className: this.className,
|
|
145
|
+
description: this.description,
|
|
146
|
+
disabled: this.disabled,
|
|
147
|
+
errorMessage: this.errorMessage,
|
|
148
|
+
};
|
|
149
|
+
const out = Renderer(props);
|
|
150
|
+
if (typeof out === 'string') {
|
|
151
|
+
const el = document.createElement('div');
|
|
152
|
+
el.innerHTML = out;
|
|
153
|
+
this.host.element.nativeElement.appendChild(el);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
catch (e) {
|
|
157
|
+
const el = document.createElement('div');
|
|
158
|
+
el.textContent = `Failed to render field: ${this.type}`;
|
|
159
|
+
this.host.element.nativeElement.appendChild(el);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
applyKnownProps(instance) {
|
|
164
|
+
const knownProps = [
|
|
165
|
+
'value',
|
|
166
|
+
'label',
|
|
167
|
+
'placeholder',
|
|
168
|
+
'required',
|
|
169
|
+
'disabled',
|
|
170
|
+
'options',
|
|
171
|
+
'className',
|
|
172
|
+
'description',
|
|
173
|
+
'errorMessage',
|
|
174
|
+
];
|
|
175
|
+
for (const prop of knownProps) {
|
|
176
|
+
if (prop in this && prop in instance) {
|
|
177
|
+
instance[prop] = this[prop];
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
bindOutput(instance, outputName) {
|
|
182
|
+
const output = instance?.[outputName];
|
|
183
|
+
if (!output || typeof output.subscribe !== 'function') {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
const sub = output.subscribe((value) => {
|
|
187
|
+
this.emitValue(value);
|
|
188
|
+
});
|
|
189
|
+
return sub;
|
|
190
|
+
}
|
|
191
|
+
emitValue(value) {
|
|
192
|
+
this.valueChange.emit(value);
|
|
193
|
+
this.onChange.emit(value);
|
|
194
|
+
}
|
|
195
|
+
cleanupRenderedComponent() {
|
|
196
|
+
this.compRef?.destroy();
|
|
197
|
+
this.compRef = undefined;
|
|
198
|
+
this.inputInstance = undefined;
|
|
199
|
+
}
|
|
200
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: DynamicInput, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
201
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.20", type: DynamicInput, isStandalone: true, selector: "dfk-dynamic-input", inputs: { type: "type" }, outputs: { valueChange: "valueChange", onChange: "onChange" }, viewQueries: [{ propertyName: "host", first: true, predicate: ["host"], descendants: true, read: ViewContainerRef }], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: `<div #host style="display: contents;"></div>`, isInline: true, dependencies: [{ kind: "ngmodule", type: CommonModule }] });
|
|
202
|
+
}
|
|
203
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: DynamicInput, decorators: [{
|
|
204
|
+
type: Component,
|
|
205
|
+
args: [{
|
|
206
|
+
selector: 'dfk-dynamic-input',
|
|
207
|
+
standalone: true,
|
|
208
|
+
imports: [CommonModule],
|
|
209
|
+
template: `<div #host style="display: contents;"></div>`,
|
|
210
|
+
}]
|
|
211
|
+
}], propDecorators: { type: [{
|
|
212
|
+
type: Input
|
|
213
|
+
}], valueChange: [{
|
|
214
|
+
type: Output
|
|
215
|
+
}], onChange: [{
|
|
216
|
+
type: Output
|
|
217
|
+
}], host: [{
|
|
218
|
+
type: ViewChild,
|
|
219
|
+
args: ['host', { read: ViewContainerRef, static: false }]
|
|
190
220
|
}] } });
|
|
191
221
|
|
|
192
|
-
class FieldInput {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
getFieldValue() {
|
|
197
|
-
if (!this.fieldDescription || !this.renderInfos)
|
|
198
|
-
return undefined;
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
|
|
222
|
+
class FieldInput {
|
|
223
|
+
fieldDescription;
|
|
224
|
+
renderInfos;
|
|
225
|
+
onValueChangeField = new EventEmitter();
|
|
226
|
+
getFieldValue() {
|
|
227
|
+
if (!this.fieldDescription || !this.renderInfos) {
|
|
228
|
+
return undefined;
|
|
229
|
+
}
|
|
230
|
+
const value = this.renderInfos[this.fieldDescription.name];
|
|
231
|
+
if (value === undefined && this.fieldDescription.type === 'text') {
|
|
232
|
+
return '';
|
|
233
|
+
}
|
|
234
|
+
return value;
|
|
235
|
+
}
|
|
236
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: FieldInput, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
237
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.20", type: FieldInput, isStandalone: true, selector: "dfk-field-input", inputs: { fieldDescription: "fieldDescription", renderInfos: "renderInfos" }, outputs: { onValueChangeField: "onValueChangeField" }, ngImport: i0, template: `
|
|
208
238
|
<dfk-dynamic-input
|
|
209
239
|
*ngIf="fieldDescription && renderInfos"
|
|
210
240
|
[type]="fieldDescription!.type"
|
|
@@ -212,20 +242,23 @@ FieldInput.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "1
|
|
|
212
242
|
[label]="fieldDescription!.label"
|
|
213
243
|
[placeholder]="fieldDescription!.placeholder"
|
|
214
244
|
[required]="fieldDescription!.required"
|
|
215
|
-
[description]="fieldDescription!.description"
|
|
216
|
-
[options]="fieldDescription!.options"
|
|
217
|
-
[className]="fieldDescription!.className"
|
|
218
|
-
(valueChange)="
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
245
|
+
[description]="fieldDescription!.description"
|
|
246
|
+
[options]="fieldDescription!.options"
|
|
247
|
+
[className]="fieldDescription!.className"
|
|
248
|
+
(valueChange)="
|
|
249
|
+
onValueChangeField.emit({ value: $event, key: fieldDescription!.name })
|
|
250
|
+
"
|
|
251
|
+
[disabled]="false"
|
|
252
|
+
[errorMessage]="''"
|
|
253
|
+
></dfk-dynamic-input>
|
|
254
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: DynamicInput, selector: "dfk-dynamic-input", inputs: ["type"], outputs: ["valueChange", "onChange"] }] });
|
|
255
|
+
}
|
|
256
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: FieldInput, decorators: [{
|
|
257
|
+
type: Component,
|
|
258
|
+
args: [{
|
|
259
|
+
selector: 'dfk-field-input',
|
|
260
|
+
standalone: true,
|
|
261
|
+
imports: [NgIf, DynamicInput],
|
|
229
262
|
template: `
|
|
230
263
|
<dfk-dynamic-input
|
|
231
264
|
*ngIf="fieldDescription && renderInfos"
|
|
@@ -234,60 +267,64 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
|
|
|
234
267
|
[label]="fieldDescription!.label"
|
|
235
268
|
[placeholder]="fieldDescription!.placeholder"
|
|
236
269
|
[required]="fieldDescription!.required"
|
|
237
|
-
[description]="fieldDescription!.description"
|
|
238
|
-
[options]="fieldDescription!.options"
|
|
239
|
-
[className]="fieldDescription!.className"
|
|
240
|
-
(valueChange)="
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
type: Input
|
|
250
|
-
}],
|
|
251
|
-
type:
|
|
270
|
+
[description]="fieldDescription!.description"
|
|
271
|
+
[options]="fieldDescription!.options"
|
|
272
|
+
[className]="fieldDescription!.className"
|
|
273
|
+
(valueChange)="
|
|
274
|
+
onValueChangeField.emit({ value: $event, key: fieldDescription!.name })
|
|
275
|
+
"
|
|
276
|
+
[disabled]="false"
|
|
277
|
+
[errorMessage]="''"
|
|
278
|
+
></dfk-dynamic-input>
|
|
279
|
+
`,
|
|
280
|
+
}]
|
|
281
|
+
}], propDecorators: { fieldDescription: [{
|
|
282
|
+
type: Input
|
|
283
|
+
}], renderInfos: [{
|
|
284
|
+
type: Input
|
|
285
|
+
}], onValueChangeField: [{
|
|
286
|
+
type: Output
|
|
252
287
|
}] } });
|
|
253
288
|
|
|
254
|
-
class MultiFieldInput {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
this.updateVisibleFields();
|
|
275
|
-
}
|
|
276
|
-
updateVisibleFields() {
|
|
277
|
-
this.visibleFields = this.fieldDescriptions.filter((f) => !f.appearCondition || f.appearCondition(this.data));
|
|
278
|
-
}
|
|
279
|
-
onFieldChange(event) {
|
|
280
|
-
this.data = { ...this.data, [event.key]: event.value };
|
|
281
|
-
this.updateVisibleFields();
|
|
282
|
-
this.onChange.emit(this.data);
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
289
|
+
class MultiFieldInput {
|
|
290
|
+
fieldDescriptions = [];
|
|
291
|
+
properties;
|
|
292
|
+
onChange = new EventEmitter();
|
|
293
|
+
layout = 'column';
|
|
294
|
+
data = {};
|
|
295
|
+
visibleFields = [];
|
|
296
|
+
trackByFn(index, field) {
|
|
297
|
+
return field.name || index;
|
|
298
|
+
}
|
|
299
|
+
ngOnInit() {
|
|
300
|
+
this.init();
|
|
301
|
+
}
|
|
302
|
+
ngOnChanges(_changes) {
|
|
303
|
+
this.init();
|
|
304
|
+
}
|
|
305
|
+
init() {
|
|
306
|
+
if (this.properties) {
|
|
307
|
+
this.data = { ...this.properties };
|
|
308
|
+
}
|
|
309
|
+
this.updateVisibleFields();
|
|
310
|
+
}
|
|
311
|
+
updateVisibleFields() {
|
|
312
|
+
this.visibleFields = this.fieldDescriptions.filter((f) => !f.appearCondition || f.appearCondition(this.data));
|
|
313
|
+
}
|
|
314
|
+
onFieldChange(event) {
|
|
315
|
+
this.data = { ...this.data, [event.key]: event.value };
|
|
316
|
+
this.updateVisibleFields();
|
|
317
|
+
this.onChange.emit(this.data);
|
|
318
|
+
}
|
|
319
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: MultiFieldInput, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
320
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.20", type: MultiFieldInput, isStandalone: true, selector: "dfk-multi-field-input", inputs: { fieldDescriptions: "fieldDescriptions", properties: "properties", layout: "layout" }, outputs: { onChange: "onChange" }, usesOnChanges: true, ngImport: i0, template: `
|
|
321
|
+
<div
|
|
322
|
+
class="flex flex-col gap-3 p-4 border rounded-lg bg-gray-50"
|
|
323
|
+
[ngClass]="{
|
|
324
|
+
'flex-row gap-3': layout === 'row',
|
|
325
|
+
'grid grid-cols-2 gap-3': layout === 'grid'
|
|
326
|
+
}"
|
|
327
|
+
>
|
|
291
328
|
<dfk-field-input
|
|
292
329
|
*ngFor="let field of visibleFields; trackBy: trackByFn"
|
|
293
330
|
[fieldDescription]="field"
|
|
@@ -295,18 +332,22 @@ MultiFieldInput.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", versio
|
|
|
295
332
|
(onValueChangeField)="onFieldChange($event)"
|
|
296
333
|
></dfk-field-input>
|
|
297
334
|
</div>
|
|
298
|
-
`, isInline: true, dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: NgFor, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "component", type: FieldInput, selector: "dfk-field-input", inputs: ["fieldDescription", "renderInfos"], outputs: ["onValueChangeField"] }] });
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
335
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: NgFor, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "component", type: FieldInput, selector: "dfk-field-input", inputs: ["fieldDescription", "renderInfos"], outputs: ["onValueChangeField"] }] });
|
|
336
|
+
}
|
|
337
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: MultiFieldInput, decorators: [{
|
|
338
|
+
type: Component,
|
|
339
|
+
args: [{
|
|
340
|
+
selector: 'dfk-multi-field-input',
|
|
341
|
+
standalone: true,
|
|
342
|
+
imports: [NgClass, NgFor, FieldInput],
|
|
305
343
|
template: `
|
|
306
|
-
<div
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
344
|
+
<div
|
|
345
|
+
class="flex flex-col gap-3 p-4 border rounded-lg bg-gray-50"
|
|
346
|
+
[ngClass]="{
|
|
347
|
+
'flex-row gap-3': layout === 'row',
|
|
348
|
+
'grid grid-cols-2 gap-3': layout === 'grid'
|
|
349
|
+
}"
|
|
350
|
+
>
|
|
310
351
|
<dfk-field-input
|
|
311
352
|
*ngFor="let field of visibleFields; trackBy: trackByFn"
|
|
312
353
|
[fieldDescription]="field"
|
|
@@ -314,76 +355,132 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
|
|
|
314
355
|
(onValueChangeField)="onFieldChange($event)"
|
|
315
356
|
></dfk-field-input>
|
|
316
357
|
</div>
|
|
317
|
-
`,
|
|
318
|
-
}]
|
|
319
|
-
}], propDecorators: { fieldDescriptions: [{
|
|
320
|
-
type: Input
|
|
321
|
-
}], properties: [{
|
|
322
|
-
type: Input
|
|
323
|
-
}], onChange: [{
|
|
324
|
-
type: Output
|
|
325
|
-
}], layout: [{
|
|
326
|
-
type: Input
|
|
358
|
+
`,
|
|
359
|
+
}]
|
|
360
|
+
}], propDecorators: { fieldDescriptions: [{
|
|
361
|
+
type: Input
|
|
362
|
+
}], properties: [{
|
|
363
|
+
type: Input
|
|
364
|
+
}], onChange: [{
|
|
365
|
+
type: Output
|
|
366
|
+
}], layout: [{
|
|
367
|
+
type: Input
|
|
327
368
|
}] } });
|
|
328
369
|
|
|
329
|
-
class ColumnLayout {
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
370
|
+
class ColumnLayout {
|
|
371
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: ColumnLayout, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
372
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.20", type: ColumnLayout, isStandalone: true, selector: "dfk-column-layout", ngImport: i0, template: `<div
|
|
373
|
+
style="display:flex;flex-direction:column;gap:var(--dfk-gap,12px)"
|
|
374
|
+
>
|
|
375
|
+
<ng-content></ng-content>
|
|
376
|
+
</div>`, isInline: true, dependencies: [{ kind: "ngmodule", type: CommonModule }] });
|
|
377
|
+
}
|
|
378
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: ColumnLayout, decorators: [{
|
|
379
|
+
type: Component,
|
|
380
|
+
args: [{
|
|
381
|
+
selector: 'dfk-column-layout',
|
|
382
|
+
standalone: true,
|
|
383
|
+
imports: [CommonModule],
|
|
384
|
+
template: `<div
|
|
385
|
+
style="display:flex;flex-direction:column;gap:var(--dfk-gap,12px)"
|
|
386
|
+
>
|
|
387
|
+
<ng-content></ng-content>
|
|
388
|
+
</div>`,
|
|
389
|
+
}]
|
|
390
|
+
}] });
|
|
391
|
+
class RowLayout {
|
|
392
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: RowLayout, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
393
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.20", type: RowLayout, isStandalone: true, selector: "dfk-row-layout", ngImport: i0, template: `<div
|
|
394
|
+
style="display:flex;flex-direction:row;gap:var(--dfk-gap,12px)"
|
|
395
|
+
>
|
|
396
|
+
<ng-content></ng-content>
|
|
397
|
+
</div>`, isInline: true, dependencies: [{ kind: "ngmodule", type: CommonModule }] });
|
|
398
|
+
}
|
|
399
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: RowLayout, decorators: [{
|
|
400
|
+
type: Component,
|
|
401
|
+
args: [{
|
|
402
|
+
selector: 'dfk-row-layout',
|
|
403
|
+
standalone: true,
|
|
404
|
+
imports: [CommonModule],
|
|
405
|
+
template: `<div
|
|
406
|
+
style="display:flex;flex-direction:row;gap:var(--dfk-gap,12px)"
|
|
407
|
+
>
|
|
408
|
+
<ng-content></ng-content>
|
|
409
|
+
</div>`,
|
|
410
|
+
}]
|
|
411
|
+
}] });
|
|
412
|
+
class GridLayout {
|
|
413
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: GridLayout, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
414
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.20", type: GridLayout, isStandalone: true, selector: "dfk-grid-layout", ngImport: i0, template: `<div
|
|
415
|
+
style="display:grid;grid-template-columns:repeat(var(--dfk-columns,2),1fr);gap:var(--dfk-gap,12px)"
|
|
416
|
+
>
|
|
417
|
+
<ng-content></ng-content>
|
|
418
|
+
</div>`, isInline: true, dependencies: [{ kind: "ngmodule", type: CommonModule }] });
|
|
419
|
+
}
|
|
420
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: GridLayout, decorators: [{
|
|
421
|
+
type: Component,
|
|
422
|
+
args: [{
|
|
423
|
+
selector: 'dfk-grid-layout',
|
|
424
|
+
standalone: true,
|
|
425
|
+
imports: [CommonModule],
|
|
426
|
+
template: `<div
|
|
427
|
+
style="display:grid;grid-template-columns:repeat(var(--dfk-columns,2),1fr);gap:var(--dfk-gap,12px)"
|
|
428
|
+
>
|
|
429
|
+
<ng-content></ng-content>
|
|
430
|
+
</div>`,
|
|
431
|
+
}]
|
|
367
432
|
}] });
|
|
368
433
|
|
|
369
|
-
class DynamicFieldKitModule {
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
434
|
+
class DynamicFieldKitModule {
|
|
435
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: DynamicFieldKitModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
436
|
+
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.20", ngImport: i0, type: DynamicFieldKitModule, imports: [CommonModule,
|
|
437
|
+
DynamicInput,
|
|
438
|
+
FieldInput,
|
|
439
|
+
MultiFieldInput,
|
|
440
|
+
ColumnLayout,
|
|
441
|
+
RowLayout,
|
|
442
|
+
GridLayout], exports: [DynamicInput,
|
|
443
|
+
FieldInput,
|
|
444
|
+
MultiFieldInput,
|
|
445
|
+
ColumnLayout,
|
|
446
|
+
RowLayout,
|
|
447
|
+
GridLayout] });
|
|
448
|
+
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: DynamicFieldKitModule, imports: [CommonModule,
|
|
449
|
+
DynamicInput,
|
|
450
|
+
FieldInput,
|
|
451
|
+
MultiFieldInput,
|
|
452
|
+
ColumnLayout,
|
|
453
|
+
RowLayout,
|
|
454
|
+
GridLayout] });
|
|
455
|
+
}
|
|
456
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: DynamicFieldKitModule, decorators: [{
|
|
457
|
+
type: NgModule,
|
|
458
|
+
args: [{
|
|
459
|
+
imports: [
|
|
460
|
+
CommonModule,
|
|
461
|
+
DynamicInput,
|
|
462
|
+
FieldInput,
|
|
463
|
+
MultiFieldInput,
|
|
464
|
+
ColumnLayout,
|
|
465
|
+
RowLayout,
|
|
466
|
+
GridLayout,
|
|
467
|
+
],
|
|
468
|
+
exports: [
|
|
469
|
+
DynamicInput,
|
|
470
|
+
FieldInput,
|
|
471
|
+
MultiFieldInput,
|
|
472
|
+
ColumnLayout,
|
|
473
|
+
RowLayout,
|
|
474
|
+
GridLayout,
|
|
475
|
+
],
|
|
476
|
+
}]
|
|
380
477
|
}] });
|
|
381
478
|
|
|
382
|
-
// public-api.ts
|
|
479
|
+
// public-api.ts
|
|
383
480
|
// Components
|
|
384
481
|
|
|
385
|
-
/**
|
|
386
|
-
* Generated bundle index. Do not edit.
|
|
482
|
+
/**
|
|
483
|
+
* Generated bundle index. Do not edit.
|
|
387
484
|
*/
|
|
388
485
|
|
|
389
486
|
export { BaseInputComponent, ColumnLayout, DynamicFieldKitModule, DynamicInput, FieldInput, GridLayout, MultiFieldInput, RowLayout };
|