@decaf-ts/for-angular 0.0.3 → 0.0.5

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.
Files changed (87) hide show
  1. package/LICENSE.md +659 -21
  2. package/README.md +37 -242
  3. package/dist/lib/README.md +92 -0
  4. package/dist/lib/assets/i18n/en.json +131 -0
  5. package/dist/lib/assets/images/angular-logo.svg +45 -0
  6. package/dist/lib/assets/images/decaf-logo-black.svg +22 -0
  7. package/dist/lib/assets/images/decaf-logo-lw.svg +50 -0
  8. package/dist/lib/assets/images/decaf-logo-white.svg +22 -0
  9. package/dist/lib/assets/images/decaf-logo.svg +54 -0
  10. package/dist/lib/components/component-renderer/component-renderer.component.d.ts +267 -0
  11. package/dist/lib/components/crud-field/crud-field.component.d.ts +447 -0
  12. package/dist/lib/components/crud-form/crud-form.component.d.ts +102 -0
  13. package/dist/lib/components/model-renderer/model-renderer.component.d.ts +97 -0
  14. package/dist/lib/engine/DynamicModule.d.ts +17 -0
  15. package/dist/{for-angular → lib}/engine/NgxCrudFormField.d.ts +37 -30
  16. package/dist/lib/engine/NgxFormService.d.ts +167 -0
  17. package/dist/lib/engine/NgxRenderingEngine.d.ts +128 -0
  18. package/dist/lib/engine/NgxRenderingEngine2.d.ts +251 -0
  19. package/dist/lib/engine/ValidatorFactory.d.ts +15 -0
  20. package/dist/lib/engine/constants.d.ts +151 -0
  21. package/dist/lib/engine/decorators.d.ts +25 -0
  22. package/dist/lib/engine/index.d.ts +15 -0
  23. package/dist/lib/engine/types.d.ts +293 -0
  24. package/dist/lib/esm2022/components/component-renderer/component-renderer.component.mjs +309 -0
  25. package/dist/lib/esm2022/components/crud-field/crud-field.component.mjs +288 -0
  26. package/dist/lib/esm2022/components/crud-form/constants.mjs +14 -0
  27. package/dist/lib/esm2022/components/crud-form/crud-form.component.mjs +140 -0
  28. package/dist/lib/esm2022/components/crud-form/types.mjs +2 -0
  29. package/dist/lib/esm2022/components/model-renderer/model-renderer.component.mjs +137 -0
  30. package/dist/lib/esm2022/engine/DynamicModule.mjs +18 -0
  31. package/dist/lib/esm2022/engine/NgxCrudFormField.mjs +117 -0
  32. package/dist/lib/esm2022/engine/NgxFormService.mjs +315 -0
  33. package/dist/lib/esm2022/engine/NgxRenderingEngine.mjs +194 -0
  34. package/dist/lib/esm2022/engine/NgxRenderingEngine2.mjs +333 -0
  35. package/dist/lib/esm2022/engine/ValidatorFactory.mjs +102 -0
  36. package/dist/lib/esm2022/engine/constants.mjs +160 -0
  37. package/dist/lib/esm2022/engine/decorators.mjs +38 -0
  38. package/dist/lib/esm2022/engine/index.mjs +16 -0
  39. package/dist/lib/esm2022/engine/types.mjs +2 -0
  40. package/dist/lib/esm2022/for-angular.module.mjs +118 -0
  41. package/dist/lib/esm2022/interfaces.mjs +2 -0
  42. package/dist/lib/esm2022/public-apis.mjs +13 -0
  43. package/dist/lib/fesm2022/decaf-ts-for-angular.mjs +2138 -0
  44. package/dist/lib/fesm2022/decaf-ts-for-angular.mjs.map +1 -0
  45. package/dist/lib/for-angular.module.d.ts +44 -0
  46. package/dist/lib/interfaces.d.ts +28 -0
  47. package/dist/lib/public-apis.d.ts +12 -0
  48. package/package.json +74 -25
  49. package/dist/for-angular/README.md +0 -297
  50. package/dist/for-angular/assets/i18n/en.json +0 -21
  51. package/dist/for-angular/components/decaf-crud-field/decaf-crud-field.component.d.ts +0 -22
  52. package/dist/for-angular/components/decaf-crud-form/decaf-crud-form.component.d.ts +0 -28
  53. package/dist/for-angular/components/decaf-model-renderer/decaf-model-renderer.component.d.ts +0 -20
  54. package/dist/for-angular/directives/decaf-field.directive.d.ts +0 -8
  55. package/dist/for-angular/engine/DynamicModule.d.ts +0 -2
  56. package/dist/for-angular/engine/NgxFormService.d.ts +0 -119
  57. package/dist/for-angular/engine/NgxRenderingEngine.d.ts +0 -17
  58. package/dist/for-angular/engine/ValidatorFactory.d.ts +0 -4
  59. package/dist/for-angular/engine/constants.d.ts +0 -10
  60. package/dist/for-angular/engine/decorators.d.ts +0 -1
  61. package/dist/for-angular/engine/index.d.ts +0 -5
  62. package/dist/for-angular/engine/types.d.ts +0 -32
  63. package/dist/for-angular/esm2022/components/decaf-crud-field/decaf-crud-field.component.mjs +0 -66
  64. package/dist/for-angular/esm2022/components/decaf-crud-form/constants.mjs +0 -14
  65. package/dist/for-angular/esm2022/components/decaf-crud-form/decaf-crud-form.component.mjs +0 -84
  66. package/dist/for-angular/esm2022/components/decaf-crud-form/types.mjs +0 -2
  67. package/dist/for-angular/esm2022/components/decaf-model-renderer/decaf-model-renderer.component.mjs +0 -46
  68. package/dist/for-angular/esm2022/directives/decaf-field.directive.mjs +0 -23
  69. package/dist/for-angular/esm2022/engine/DynamicModule.mjs +0 -3
  70. package/dist/for-angular/esm2022/engine/NgxCrudFormField.mjs +0 -118
  71. package/dist/for-angular/esm2022/engine/NgxFormService.mjs +0 -232
  72. package/dist/for-angular/esm2022/engine/NgxRenderingEngine.mjs +0 -35
  73. package/dist/for-angular/esm2022/engine/ValidatorFactory.mjs +0 -48
  74. package/dist/for-angular/esm2022/engine/constants.mjs +0 -12
  75. package/dist/for-angular/esm2022/engine/decorators.mjs +0 -17
  76. package/dist/for-angular/esm2022/engine/index.mjs +0 -6
  77. package/dist/for-angular/esm2022/engine/types.mjs +0 -2
  78. package/dist/for-angular/esm2022/interfaces.mjs +0 -2
  79. package/dist/for-angular/esm2022/public-apis.mjs +0 -5
  80. package/dist/for-angular/fesm2022/decaf-ts-for-angular.mjs +0 -675
  81. package/dist/for-angular/fesm2022/decaf-ts-for-angular.mjs.map +0 -1
  82. package/dist/for-angular/interfaces.d.ts +0 -8
  83. package/dist/for-angular/public-apis.d.ts +0 -4
  84. /package/dist/{for-angular/components/decaf-crud-form → lib/components/crud-form}/constants.d.ts +0 -0
  85. /package/dist/{for-angular/components/decaf-crud-form → lib/components/crud-form}/types.d.ts +0 -0
  86. /package/dist/{for-angular → lib}/esm2022/decaf-ts-for-angular.mjs +0 -0
  87. /package/dist/{for-angular → lib}/index.d.ts +0 -0
@@ -1,675 +0,0 @@
1
- import * as i0 from '@angular/core';
2
- import { Component, Input, Directive, HostBinding, ElementRef, CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA, ViewChild, EventEmitter, Output } from '@angular/core';
3
- import { Model, Validation, ValidationKeys, sf } from '@decaf-ts/decorator-validation';
4
- import { IonSkeletonText, IonInput, IonItem, IonCheckbox, IonRadioGroup, IonRadio, IonSelect, IonSelectOption } from '@ionic/angular/standalone';
5
- import { NgComponentOutlet, NgClass } from '@angular/common';
6
- import * as i1 from '@angular/forms';
7
- import { FormGroup, FormControl, Validators, ReactiveFormsModule } from '@angular/forms';
8
- import { UIKeys, RenderingEngine, HTML5CheckTypes, escapeHtml, HTML5InputTypes, parseToNumber } from '@decaf-ts/ui-decorators';
9
- import { TranslatePipe } from '@ngx-translate/core';
10
- import { OperationKeys, InternalError } from '@decaf-ts/db-decorators';
11
- import * as i1$1 from '@ionic/angular';
12
- import { IonicModule } from '@ionic/angular';
13
- import { apply, metadata } from '@decaf-ts/reflection';
14
-
15
- class DecafModelRendererComponent {
16
- //
17
- // @ViewChild('componentElementContainer', {
18
- // static: true,
19
- // read: ViewContainerRef,
20
- // })
21
- // componentElementContainer!: ViewContainerRef;
22
- constructor(vcr) {
23
- this.vcr = vcr;
24
- }
25
- ngOnInit() {
26
- this.model =
27
- typeof this.model === 'string'
28
- ? Model.build({}, JSON.parse(this.model))
29
- : this.model;
30
- // this.output = RenderingEngine.render(this.model as unknown as Model);
31
- // this.component = NgxRenderingEngine.components(this.output.tag);
32
- // this.props = this.output.props;
33
- // this.content = this.output.children?.map((child) => {
34
- // return this.vcr.createEmbeddedView();
35
- // });
36
- }
37
- ngOnChanges(changes) {
38
- if (changes['model']) {
39
- const { currentValue, previousValue, firstChange } = changes['model'];
40
- }
41
- if (changes['details']) {
42
- const { currentValue, previousValue, firstChange } = changes['details'];
43
- }
44
- }
45
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: DecafModelRendererComponent, deps: [{ token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Component }); }
46
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.13", type: DecafModelRendererComponent, isStandalone: true, selector: "decaf-model-renderer", inputs: { model: "model" }, usesOnChanges: true, ngImport: i0, template: "<!--<div #loadingElement>-->\n<!-- <ion-skeleton-text [animated]=\"true\" style=\"width: 100%;\"></ion-skeleton-text>-->\n<!--</div>-->\n@if (output?.children?.length){\n @for (item of output.children; track item.props.name){\n <ng-template>{{item.props.name}}</ng-template>\n }\n}\n<ng-container *ngComponentOutlet=\"component;\n inputs: props;\n content: content;\">\n</ng-container>\n", styles: [""], dependencies: [{ kind: "directive", type: NgComponentOutlet, selector: "[ngComponentOutlet]", inputs: ["ngComponentOutlet", "ngComponentOutletInputs", "ngComponentOutletInjector", "ngComponentOutletContent", "ngComponentOutletNgModule", "ngComponentOutletNgModuleFactory"] }] }); }
47
- }
48
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: DecafModelRendererComponent, decorators: [{
49
- type: Component,
50
- args: [{ standalone: true, imports: [IonSkeletonText, NgComponentOutlet], selector: 'decaf-model-renderer', template: "<!--<div #loadingElement>-->\n<!-- <ion-skeleton-text [animated]=\"true\" style=\"width: 100%;\"></ion-skeleton-text>-->\n<!--</div>-->\n@if (output?.children?.length){\n @for (item of output.children; track item.props.name){\n <ng-template>{{item.props.name}}</ng-template>\n }\n}\n<ng-container *ngComponentOutlet=\"component;\n inputs: props;\n content: content;\">\n</ng-container>\n" }]
51
- }], ctorParameters: () => [{ type: i0.ViewContainerRef }], propDecorators: { model: [{
52
- type: Input,
53
- args: [{ required: true }]
54
- }] } });
55
-
56
- class DecafFieldDirective {
57
- constructor() {
58
- this.name = this.fieldName;
59
- }
60
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: DecafFieldDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
61
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.13", type: DecafFieldDirective, isStandalone: true, selector: "[appDecafField]", inputs: { fieldName: ["appDecafField", "fieldName"] }, host: { properties: { "#name": "this.name" } }, ngImport: i0 }); }
62
- }
63
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: DecafFieldDirective, decorators: [{
64
- type: Directive,
65
- args: [{
66
- selector: '[appDecafField]',
67
- standalone: true,
68
- }]
69
- }], ctorParameters: () => [], propDecorators: { fieldName: [{
70
- type: Input,
71
- args: [{ alias: 'appDecafField' }]
72
- }], name: [{
73
- type: HostBinding,
74
- args: ['#name']
75
- }] } });
76
-
77
- const AngularEngineKeys = {
78
- REFLECT: `${UIKeys.REFLECT}.angular.`,
79
- DYNAMIC: 'dynamic-component',
80
- ANNOTATIONS: '__annotations__',
81
- NG_REFLECT: 'ng-reflect-',
82
- };
83
- const FormConstants = {
84
- VALID: 'VALID',
85
- INVALID: 'INVALID',
86
- };
87
-
88
- class ValidatorFactory {
89
- static spawn(key, arg) {
90
- if (!Validation.keys().includes(key))
91
- throw new Error('Unsupported custom validation');
92
- /**
93
- * TODO: This is only needed until the validator refacture
94
- * @param arg
95
- */
96
- const parseArgs = (arg) => {
97
- switch (key) {
98
- case ValidationKeys.REQUIRED:
99
- case ValidationKeys.EMAIL:
100
- case ValidationKeys.URL:
101
- case ValidationKeys.PASSWORD:
102
- return [];
103
- case ValidationKeys.TYPE:
104
- arg = RenderingEngine.get().translate(arg, false);
105
- }
106
- return [arg];
107
- };
108
- const validatorFn = (control) => {
109
- const validator = Validation.get(key);
110
- const value = control.value;
111
- const actualArg = parseArgs(arg);
112
- if (key === ValidationKeys.TYPE) {
113
- }
114
- let errs;
115
- try {
116
- errs = validator.hasErrors(value, ...actualArg);
117
- }
118
- catch (e) {
119
- console.warn(`${key} validator failed to validate: ${e}`);
120
- }
121
- if (!errs)
122
- return null;
123
- const result = {};
124
- result[key] = true;
125
- return result;
126
- };
127
- Object.defineProperty(validatorFn, 'name', {
128
- value: `${key}Validator`,
129
- });
130
- return validatorFn;
131
- }
132
- }
133
-
134
- /**
135
- * @summary Service for managing Angular forms and form controls.
136
- * @description
137
- * The NgxFormService provides utility methods for handling form initialization,
138
- * validation, data retrieval, and form control management in Angular applications.
139
- * It offers a centralized way to manage form controls, perform validations, and
140
- * handle form-related operations.
141
- */
142
- class NgxFormService {
143
- /**
144
- * @summary Storage for form controls.
145
- * @description
146
- * A static object that stores form controls indexed by form ID and field name.
147
- * @type {Record<string, Record<string, { control: FormGroup; props: AngularFieldDefinition }>>}
148
- */
149
- static { this.controls = {}; }
150
- // eslint-disable-next-line @typescript-eslint/no-empty-function
151
- constructor() { }
152
- /**
153
- * Initializes the form after the view has been initialized.
154
- * This method sets up the form controls and creates a FormGroup.
155
- *
156
- * @param el - The form element to initialize.
157
- * @param formId - The unique identifier for the form.
158
- * @param formUpdateMode - The update mode for the form. Defaults to 'blur'.
159
- */
160
- /**
161
- * @summary Initializes the form after view initialization.
162
- * @description
163
- * Sets up form controls and creates a FormGroup for the given form element.
164
- *
165
- * @param {FormElement} el - The form element to initialize.
166
- * @param {string} formId - The unique identifier for the form.
167
- * @param {FieldUpdateMode} [formUpdateMode='blur'] - The update mode for the form.
168
- */
169
- static formAfterViewInit(el, formId, formUpdateMode = 'blur') {
170
- const selector = `*[${AngularEngineKeys.NG_REFLECT}name]`;
171
- const elements = Array.from(el.component.nativeElement.querySelectorAll(selector));
172
- const controls = elements.map((f) => {
173
- const fieldName = f
174
- .attributes[`${AngularEngineKeys.NG_REFLECT}name`].value;
175
- const control = NgxFormService.getFieldByName(formId, fieldName);
176
- return control.control;
177
- });
178
- el.formGroup = new FormGroup(controls, {
179
- updateOn: formUpdateMode,
180
- });
181
- }
182
- /**
183
- * @summary Handles form component destruction.
184
- * @description
185
- * Unregisters the form from the service when the component is destroyed.
186
- *
187
- * @param {FormElement} el - The form element being destroyed.
188
- * @param {string} formId - The unique identifier of the form to unregister.
189
- */
190
- static forOnDestroy(el, formId) {
191
- NgxFormService.unregister(formId, el.component.nativeElement);
192
- }
193
- /**
194
- * @summary Retrieves form data for a given form ID.
195
- * @description
196
- * Processes form controls and returns their values as an object.
197
- *
198
- * @param {string} formId - The unique identifier of the form to retrieve data from.
199
- * @returns {Record<string, unknown>} An object containing the form data.
200
- * @throws {Error} If the form with the given ID is not found.
201
- */
202
- static getFormData(formId) {
203
- if (!(formId in this.controls))
204
- throw new Error(`form ${formId} not found`);
205
- const form = this.controls[formId];
206
- let control;
207
- let val;
208
- const data = {};
209
- for (const key in form) {
210
- control = form[key].control;
211
- if (!HTML5CheckTypes.includes(form[key].props.type)) {
212
- switch (form[key].props.type) {
213
- case HTML5InputTypes.NUMBER:
214
- val = parseToNumber(control.value);
215
- break;
216
- case HTML5InputTypes.DATE:
217
- case HTML5InputTypes.DATETIME_LOCAL:
218
- val = new Date(control.value[key]);
219
- break;
220
- default:
221
- val = escapeHtml(control.value[key]);
222
- }
223
- }
224
- else {
225
- val = control.value;
226
- }
227
- data[key] = val;
228
- }
229
- return data;
230
- }
231
- /**
232
- * @summary Validates form fields.
233
- * @description
234
- * Validates either a specific field or all fields in the form group.
235
- *
236
- * @param {FormGroup} formGroup - The FormGroup to validate.
237
- * @param {string} [fieldName] - Optional name of a specific field to validate.
238
- * @returns {boolean} Indicates whether the validation passed (true) or failed (false).
239
- */
240
- static validateFields(formGroup, fieldName) {
241
- function isValid(formGroup, fieldName) {
242
- const control = formGroup.get(fieldName);
243
- if (control instanceof FormControl) {
244
- control.markAsTouched();
245
- control.markAsDirty();
246
- return !control.invalid;
247
- }
248
- else {
249
- throw new Error('This should be impossible');
250
- }
251
- }
252
- if (fieldName)
253
- return isValid(formGroup, fieldName);
254
- let isValidForm = true;
255
- for (const fg of formGroup.controls) {
256
- for (const key in fg.controls) {
257
- const validate = isValid(fg, key);
258
- if (!validate)
259
- isValidForm = false;
260
- }
261
- }
262
- return isValidForm;
263
- }
264
- /**
265
- * @summary Creates a FormGroup from field properties.
266
- * @description
267
- * Generates a new FormGroup instance based on the provided field definition and update mode.
268
- *
269
- * @param {AngularFieldDefinition} props - The Angular field definition properties.
270
- * @param {FieldUpdateMode} updateMode - The update mode for the form group.
271
- * @returns {FormGroup} A new FormGroup instance.
272
- */
273
- static fromProps(props, updateMode) {
274
- const controls = {};
275
- const validators = this.validatorsFromProps(props);
276
- const composed = validators.length ? Validators.compose(validators) : null;
277
- controls[props.name] = new FormControl({
278
- value: props.value && props.type !== HTML5InputTypes.CHECKBOX
279
- ? props.value
280
- : undefined,
281
- disabled: props.disabled,
282
- }, composed);
283
- return new FormGroup(controls, { updateOn: updateMode });
284
- }
285
- /**
286
- * Retrieves a form by its ID from the stored controls.
287
- *
288
- * @param id - The unique identifier of the form to retrieve.
289
- * @returns The form controls associated with the given ID.
290
- * @throws Error if the form with the given ID is not found.
291
- */
292
- static getFormById(id) {
293
- if (!(id in NgxFormService.controls))
294
- throw new Error(`Could not find formId ${id}`);
295
- return NgxFormService.controls[id];
296
- }
297
- /**
298
- * Retrieves a specific field from a form by its name.
299
- *
300
- * @param formId - The unique identifier of the form.
301
- * @param name - The name of the field to retrieve.
302
- * @returns The field control and properties.
303
- * @throws Error if the field is not found in the form.
304
- */
305
- static getFieldByName(formId, name) {
306
- const form = NgxFormService.getFormById(formId);
307
- if (!(name in form))
308
- throw new Error(`Could not find field ${name} in form`);
309
- return form[name];
310
- }
311
- /**
312
- * Generates an array of validator functions from the provided field properties.
313
- *
314
- * @param props - The field properties containing validation rules.
315
- * @returns An array of ValidatorFn instances.
316
- */
317
- static validatorsFromProps(props) {
318
- const supportedValidationKeys = Validation.keys();
319
- return Object.keys(props)
320
- .filter((k) => supportedValidationKeys.includes(k))
321
- .map((k) => ValidatorFactory.spawn(k, props[k]));
322
- }
323
- /**
324
- *
325
- * @param el
326
- * @param tag
327
- *
328
- * @throws {Error} when no parent exists with the provided tag
329
- */
330
- static getParentEl(el, tag) {
331
- let parent;
332
- while ((parent = el.parentElement) !== null) {
333
- if (parent.tagName.toLowerCase() === tag.toLowerCase()) {
334
- return parent;
335
- }
336
- el = parent;
337
- }
338
- throw new Error(`No parent with the tag ${tag} was found for provided element`);
339
- }
340
- static register(formId, control, props) {
341
- this.controls[formId] = this.controls[formId] || {};
342
- this.controls[formId][props.name] = {
343
- control: control,
344
- props: props,
345
- };
346
- }
347
- /**
348
- * Unregisters a form or a specific field from the service.
349
- *
350
- * @param formId - The unique identifier of the form.
351
- * @param field - Optional. The specific field to unregister. If not provided, the entire form is unregistered.
352
- */
353
- static unregister(formId, field) {
354
- if (!field)
355
- delete this.controls[formId];
356
- else
357
- delete this.controls[formId][field.name];
358
- }
359
- }
360
-
361
- /**
362
- * @class NgxCrudFormField
363
- * @implements {CrudFormField<AngularFieldDefinition>}
364
- * @implements {ControlValueAccessor}
365
- * @summary Abstract class representing a CRUD form field for Angular applications
366
- * @description This class provides the base implementation for CRUD form fields in Angular,
367
- * implementing both CrudFormField and ControlValueAccessor interfaces.
368
- */
369
- class NgxCrudFormField {
370
- constructor() {
371
- /**
372
- * @summary String formatting function
373
- * @description Provides access to the sf function for error message formatting
374
- */
375
- this.sf = sf;
376
- /**
377
- * @summary Change callback function
378
- * @description Function called when the field value changes
379
- */
380
- this.onChange = () => { };
381
- /**
382
- * @summary Touch callback function
383
- * @description Function called when the field is touched
384
- */
385
- this.onTouch = () => { };
386
- }
387
- /**
388
- * @summary Write value to the field
389
- * @description Sets the value of the field
390
- * @param {string} obj - The value to be set
391
- */
392
- writeValue(obj) {
393
- this.value = obj;
394
- }
395
- /**
396
- * @summary Register change callback
397
- * @description Registers a function to be called when the field value changes
398
- * @param {() => unknown} fn - The function to be called on change
399
- */
400
- registerOnChange(fn) {
401
- this.onChange = fn;
402
- }
403
- /**
404
- * @summary Register touch callback
405
- * @description Registers a function to be called when the field is touched
406
- * @param {() => unknown} fn - The function to be called on touch
407
- */
408
- registerOnTouched(fn) {
409
- this.onTouch = fn;
410
- }
411
- /**
412
- * @summary Set disabled state
413
- * @description Sets the disabled state of the field
414
- * @param {boolean} isDisabled - Whether the field should be disabled
415
- */
416
- setDisabledState(isDisabled) {
417
- this.props.disabled = isDisabled;
418
- }
419
- /**
420
- * @summary After view initialization logic
421
- * @description Performs necessary setup after the view has been initialized
422
- * @returns {HTMLElement} The parent element of the field
423
- */
424
- afterViewInit() {
425
- let parent;
426
- switch (this.operation) {
427
- case OperationKeys.CREATE:
428
- case OperationKeys.UPDATE:
429
- case OperationKeys.DELETE:
430
- try {
431
- parent = NgxFormService.getParentEl(this.component.nativeElement, 'form');
432
- }
433
- catch (e) {
434
- throw new Error(`Unable to retrieve parent form element for the ${this.operation}: ${e instanceof Error ? e.message : e}`);
435
- }
436
- NgxFormService.register(parent.id, this.formGroup, this.props);
437
- return parent;
438
- default:
439
- throw new Error(`Invalid operation: ${this.operation}`);
440
- }
441
- }
442
- /**
443
- * @summary Cleanup on component destruction
444
- * @description Unregisters the field when the component is destroyed
445
- */
446
- onDestroy() {
447
- if (this.parent)
448
- NgxFormService.unregister(this.parent.id, this.component.nativeElement);
449
- }
450
- /**
451
- * @summary Initialize the field
452
- * @description Sets up the form group and field name
453
- * @param {FieldUpdateMode} updateOn - The update mode for the field
454
- */
455
- onInit(updateOn) {
456
- if (!this.props || !this.operation)
457
- throw new InternalError(`props and operation are required`);
458
- this.formGroup = NgxFormService.fromProps(this.props, updateOn);
459
- this.name = this.props.name;
460
- }
461
- /**
462
- * @summary Get field errors
463
- * @description Retrieves all errors associated with the field
464
- * @returns {{key: string, message: string}[]} An array of error objects
465
- */
466
- getErrors() {
467
- return Object.entries(this.formGroup.controls).reduce((accum, [prop, control]) => {
468
- Object.entries(control.errors).forEach(([k, c]) => {
469
- accum.push({ key: k, message: k });
470
- });
471
- return accum;
472
- }, []);
473
- }
474
- }
475
-
476
- // @Dynamic()
477
- class DecafCrudFieldComponent extends NgxCrudFormField {
478
- constructor() {
479
- super(...arguments);
480
- this.updateOn = 'change';
481
- this.translatable = true;
482
- this.HTML5InputTypes = Object.values(HTML5InputTypes);
483
- }
484
- ngAfterViewInit() {
485
- super.afterViewInit();
486
- }
487
- ngOnDestroy() {
488
- this.onDestroy();
489
- }
490
- ngOnInit() {
491
- super.onInit(this.updateOn);
492
- }
493
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: DecafCrudFieldComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
494
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.13", type: DecafCrudFieldComponent, isStandalone: true, selector: "decaf-crud-field", inputs: { updateOn: "updateOn", operation: "operation", props: "props", name: "name", options: "options", formGroup: "formGroup", translatable: "translatable" }, viewQueries: [{ propertyName: "component", first: true, predicate: ["component"], descendants: true, read: ElementRef }], usesInheritance: true, ngImport: i0, template: "<ng-container #component [formGroup]=\"formGroup\">\n @if(props.type === 'textarea') {\n <ion-item>\n <ion-textarea\n [ngClass]=\"props.className\"\n [mode]=\"props.mode\"\n [hidden]=\"props.hidden\"\n [required]=\"props.required !== undefined ? props.required : null\"\n [minlength]=\"props.minlength !== undefined ? props.minlength : null\"\n [maxlength]=\"props.maxlength !== undefined ? props.maxlength : null\"\n [readonly]=\"props.readonly !== undefined ? props.readonly : null\"\n [inputmode]=\"props.inputmode\"\n [spellcheck]=\"props.spellcheck\"\n [rows]=\"props.rows\"\n [labelPlacement]=\"props.labelPlacement\"\n [value]=\"props.value\"\n [fill]=\"props.fill\"\n [placeholder]=\"translatable ? (props.placeholder | translate) : props.placeholder\"\n [formControlName]=\"props.name\"\n [label]=\"translatable ? (props.label | translate) : props.label\">\n </ion-textarea>\n </ion-item>\n }\n @if(props.type === 'checkbox') {\n <ion-item [formControlName]=\"props.name\">\n <ion-checkbox\n #checkboxElement\n [name]=\"props.name\"\n [ngClass]=\"props.className\"\n [mode]=\"props.mode\"\n [hidden]=\"props.hidden\"\n [labelPlacement]=\"props.labelPlacement\"\n [alignment]=\"props.alignment\"\n [justify]=\"props.justify\"\n [disabled]=\"props.disabled || props.readonly\"\n [attr.checkedValue]=\"props.value\"\n [value]=\"props.value\"\n [checked]=\"props.checked\"\n (ionChange)=\"props.checked = !props.checked\"\n [formControlName]=\"props.name\">\n <span [innerHTML]=\"props.label | translate\"></span>\n </ion-checkbox>\n </ion-item>\n }\n @else if(props.type === 'radio') {\n <ion-radio-group [ngClass]=\"props.className\" [formControlName]=\"props.name\" [name]=\"props.name\" [value]=\"props.value\">\n <label class=\"radio-group-label\">{{props.label | translate}}</label>\n @for(option of options; track option.value) {\n <ion-item>\n <ion-radio\n [mode]=\"props.mode\"\n [hidden]=\"props.hidden\"\n [disabled]=\"props.readonly || props.disabled\"\n [labelPlacement]=\"props.labelPlacement\"\n [alignment]=\"props.alignment\"\n [justify]=\"props.justify\"\n [value]=\"option.value\"\n >{{ option.text | translate }}</ion-radio>\n </ion-item>\n }\n </ion-radio-group>\n }\n @else if(props.type === 'select') {\n <ion-item>\n <ion-select\n [name]=\"props.name\"\n [ngClass]=\"props.className\"\n [mode]=\"props.mode\"\n [hidden]=\"props.hidden\"\n [labelPlacement]=\"props.labelPlacement\"\n [cancelText]=\"props.cancelText | translate\"\n [label]=\"translatable ? (props.label | translate) : props.label\"\n [value]=\"props.value\"\n [fill]=\"props.fill\"\n [disabled]=\"props.readonly || props.disabled\"\n [placeholder]=\"props.placeholder | translate\"\n [formControlName]=\"props.name\"\n [interface]=\"props.interface\">\n @for(option of options; track option.value) {\n <ion-select-option [value]=\"option.value\">\n {{ translatable ? (option.text | translate) : option.text }}\n </ion-select-option>\n }\n </ion-select>\n </ion-item>\n }\n @else if(HTML5InputTypes.includes(props.type)) {\n <ion-item>\n <ion-input\n [ngClass]=\"props.className\"\n [type]=\"props.type\"\n [mode]=\"props.mode\"\n [hidden]=\"props.hidden\"\n [inputmode]=\"props.inputmode\"\n [autocomplete]=\"props.autocomplete\"\n [spellcheck]=\"props.spellcheck\"\n [labelPlacement]=\"props.labelPlacement\"\n [required]=\"props.required !== undefined ? props.required : false\"\n [minlength]=\"props.minlength !== undefined ? props.minlength : null\"\n [maxlength]=\"props.maxlength !== undefined ? props.maxlength : null\"\n [readonly]=\"props.readonly !== undefined ? props.readonly : null\"\n [max]=\"props.max !== undefined ? props.max : null\"\n [min]=\"props.min !== undefined ? props.min : null\"\n [pattern]=\"props.pattern !== undefined ? props.pattern : null\"\n [step]=\"props.step !== undefined ? props.step : null\"\n [value]=\"props.value\"\n [fill]=\"props.fill\"\n [placeholder]=\"props.placeholder | translate\"\n [formControlName]=\"props.name\"\n [label]=\"props.label | translate\">\n </ion-input>\n </ion-item>\n }\n @else {\n <h1>INVALID FIELD TYPE</h1>\n }\n @if((!formGroup.pristine || formGroup.touched) && !formGroup.valid) {\n <div class=\"error uk-flex uk-flex-top\">\n @for(item of getErrors(); track item.key) {\n <p>\n <span color=\"danger\" class=\"ti ti-alert-triangle\"></span>\n <span>{{item.key}} - {{ sf((\"errors.\" + item.message) | translate, props[item.key]) }}</span>\n </p>\n }\n </div>\n }\n</ng-container>\n", styles: [".disabled{opacity:.7;pointer-events:none;touch-action:none}.disabled *{pointer-events:none;touch-action:none}.proccessing,.proccessing *{pointer-events:none;touch-action:none;cursor:text}ion-item{--border-color: transparent;--padding-start: .75rem;--background: transparent;--background-hover-opacity: .1;--background-hover: var(--ion-color-primary);--background-activated-opacity: .15;--background-focused: var(--ion-color-primary);--background-focused-opacity: .15}ion-textarea textarea{scrollbar-width:thin!important;margin-bottom:.5rem!important}ion-select.select-label-placement-floating::part(label){line-height:1.2rem!important}.radio-group-label{margin-left:.5rem}.radio-group-label+ion-item{margin-top:.5rem}ion-checkbox{--size: 1.5rem;--checkbox-background-checked: var(--ion-color-primary);--checkmark-width: 2px}ion-checkbox::part(container){border-radius:50%;border:2px solid var(--ion-color-primary);padding:3px}ion-item+.helper,ion-radio-group+.helper{padding-left:.75rem;position:relative}\n"], dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i1.MinLengthValidator, selector: "[minlength][formControlName],[minlength][formControl],[minlength][ngModel]", inputs: ["minlength"] }, { kind: "directive", type: i1.MaxLengthValidator, selector: "[maxlength][formControlName],[maxlength][formControl],[maxlength][ngModel]", inputs: ["maxlength"] }, { kind: "directive", type: i1.PatternValidator, selector: "[pattern][formControlName],[pattern][formControl],[pattern][ngModel]", inputs: ["pattern"] }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "component", type: IonInput, selector: "ion-input", inputs: ["accept", "autocapitalize", "autocomplete", "autocorrect", "autofocus", "clearInput", "clearOnEdit", "color", "counter", "counterFormatter", "debounce", "disabled", "enterkeyhint", "errorText", "fill", "helperText", "inputmode", "label", "labelPlacement", "max", "maxlength", "min", "minlength", "mode", "multiple", "name", "pattern", "placeholder", "readonly", "required", "shape", "size", "spellcheck", "step", "type", "value"] }, { kind: "component", type: IonItem, selector: "ion-item", inputs: ["button", "color", "detail", "detailIcon", "disabled", "download", "href", "lines", "mode", "rel", "routerAnimation", "routerDirection", "target", "type"] }, { kind: "component", type: IonCheckbox, selector: "ion-checkbox", inputs: ["checked", "color", "disabled", "indeterminate", "justify", "labelPlacement", "mode", "name", "value"] }, { kind: "component", type: IonRadioGroup, selector: "ion-radio-group", inputs: ["allowEmptySelection", "compareWith", "name", "value"] }, { kind: "component", type: IonRadio, selector: "ion-radio", inputs: ["alignment", "color", "disabled", "justify", "labelPlacement", "mode", "name", "value"] }, { kind: "component", type: IonSelect, selector: "ion-select", inputs: ["cancelText", "color", "compareWith", "disabled", "expandedIcon", "fill", "interface", "interfaceOptions", "justify", "label", "labelPlacement", "mode", "multiple", "name", "okText", "placeholder", "selectedText", "shape", "toggleIcon", "value"] }, { kind: "pipe", type: TranslatePipe, name: "translate" }, { kind: "component", type: IonSelectOption, selector: "ion-select-option", inputs: ["disabled", "value"] }] }); }
495
- }
496
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: DecafCrudFieldComponent, decorators: [{
497
- type: Component,
498
- args: [{ standalone: true, imports: [
499
- ReactiveFormsModule,
500
- NgClass,
501
- IonInput,
502
- IonItem,
503
- IonCheckbox,
504
- IonRadioGroup,
505
- IonRadio,
506
- IonSelect,
507
- TranslatePipe,
508
- IonSelectOption,
509
- DecafFieldDirective,
510
- ], schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA], selector: 'decaf-crud-field', template: "<ng-container #component [formGroup]=\"formGroup\">\n @if(props.type === 'textarea') {\n <ion-item>\n <ion-textarea\n [ngClass]=\"props.className\"\n [mode]=\"props.mode\"\n [hidden]=\"props.hidden\"\n [required]=\"props.required !== undefined ? props.required : null\"\n [minlength]=\"props.minlength !== undefined ? props.minlength : null\"\n [maxlength]=\"props.maxlength !== undefined ? props.maxlength : null\"\n [readonly]=\"props.readonly !== undefined ? props.readonly : null\"\n [inputmode]=\"props.inputmode\"\n [spellcheck]=\"props.spellcheck\"\n [rows]=\"props.rows\"\n [labelPlacement]=\"props.labelPlacement\"\n [value]=\"props.value\"\n [fill]=\"props.fill\"\n [placeholder]=\"translatable ? (props.placeholder | translate) : props.placeholder\"\n [formControlName]=\"props.name\"\n [label]=\"translatable ? (props.label | translate) : props.label\">\n </ion-textarea>\n </ion-item>\n }\n @if(props.type === 'checkbox') {\n <ion-item [formControlName]=\"props.name\">\n <ion-checkbox\n #checkboxElement\n [name]=\"props.name\"\n [ngClass]=\"props.className\"\n [mode]=\"props.mode\"\n [hidden]=\"props.hidden\"\n [labelPlacement]=\"props.labelPlacement\"\n [alignment]=\"props.alignment\"\n [justify]=\"props.justify\"\n [disabled]=\"props.disabled || props.readonly\"\n [attr.checkedValue]=\"props.value\"\n [value]=\"props.value\"\n [checked]=\"props.checked\"\n (ionChange)=\"props.checked = !props.checked\"\n [formControlName]=\"props.name\">\n <span [innerHTML]=\"props.label | translate\"></span>\n </ion-checkbox>\n </ion-item>\n }\n @else if(props.type === 'radio') {\n <ion-radio-group [ngClass]=\"props.className\" [formControlName]=\"props.name\" [name]=\"props.name\" [value]=\"props.value\">\n <label class=\"radio-group-label\">{{props.label | translate}}</label>\n @for(option of options; track option.value) {\n <ion-item>\n <ion-radio\n [mode]=\"props.mode\"\n [hidden]=\"props.hidden\"\n [disabled]=\"props.readonly || props.disabled\"\n [labelPlacement]=\"props.labelPlacement\"\n [alignment]=\"props.alignment\"\n [justify]=\"props.justify\"\n [value]=\"option.value\"\n >{{ option.text | translate }}</ion-radio>\n </ion-item>\n }\n </ion-radio-group>\n }\n @else if(props.type === 'select') {\n <ion-item>\n <ion-select\n [name]=\"props.name\"\n [ngClass]=\"props.className\"\n [mode]=\"props.mode\"\n [hidden]=\"props.hidden\"\n [labelPlacement]=\"props.labelPlacement\"\n [cancelText]=\"props.cancelText | translate\"\n [label]=\"translatable ? (props.label | translate) : props.label\"\n [value]=\"props.value\"\n [fill]=\"props.fill\"\n [disabled]=\"props.readonly || props.disabled\"\n [placeholder]=\"props.placeholder | translate\"\n [formControlName]=\"props.name\"\n [interface]=\"props.interface\">\n @for(option of options; track option.value) {\n <ion-select-option [value]=\"option.value\">\n {{ translatable ? (option.text | translate) : option.text }}\n </ion-select-option>\n }\n </ion-select>\n </ion-item>\n }\n @else if(HTML5InputTypes.includes(props.type)) {\n <ion-item>\n <ion-input\n [ngClass]=\"props.className\"\n [type]=\"props.type\"\n [mode]=\"props.mode\"\n [hidden]=\"props.hidden\"\n [inputmode]=\"props.inputmode\"\n [autocomplete]=\"props.autocomplete\"\n [spellcheck]=\"props.spellcheck\"\n [labelPlacement]=\"props.labelPlacement\"\n [required]=\"props.required !== undefined ? props.required : false\"\n [minlength]=\"props.minlength !== undefined ? props.minlength : null\"\n [maxlength]=\"props.maxlength !== undefined ? props.maxlength : null\"\n [readonly]=\"props.readonly !== undefined ? props.readonly : null\"\n [max]=\"props.max !== undefined ? props.max : null\"\n [min]=\"props.min !== undefined ? props.min : null\"\n [pattern]=\"props.pattern !== undefined ? props.pattern : null\"\n [step]=\"props.step !== undefined ? props.step : null\"\n [value]=\"props.value\"\n [fill]=\"props.fill\"\n [placeholder]=\"props.placeholder | translate\"\n [formControlName]=\"props.name\"\n [label]=\"props.label | translate\">\n </ion-input>\n </ion-item>\n }\n @else {\n <h1>INVALID FIELD TYPE</h1>\n }\n @if((!formGroup.pristine || formGroup.touched) && !formGroup.valid) {\n <div class=\"error uk-flex uk-flex-top\">\n @for(item of getErrors(); track item.key) {\n <p>\n <span color=\"danger\" class=\"ti ti-alert-triangle\"></span>\n <span>{{item.key}} - {{ sf((\"errors.\" + item.message) | translate, props[item.key]) }}</span>\n </p>\n }\n </div>\n }\n</ng-container>\n", styles: [".disabled{opacity:.7;pointer-events:none;touch-action:none}.disabled *{pointer-events:none;touch-action:none}.proccessing,.proccessing *{pointer-events:none;touch-action:none;cursor:text}ion-item{--border-color: transparent;--padding-start: .75rem;--background: transparent;--background-hover-opacity: .1;--background-hover: var(--ion-color-primary);--background-activated-opacity: .15;--background-focused: var(--ion-color-primary);--background-focused-opacity: .15}ion-textarea textarea{scrollbar-width:thin!important;margin-bottom:.5rem!important}ion-select.select-label-placement-floating::part(label){line-height:1.2rem!important}.radio-group-label{margin-left:.5rem}.radio-group-label+ion-item{margin-top:.5rem}ion-checkbox{--size: 1.5rem;--checkbox-background-checked: var(--ion-color-primary);--checkmark-width: 2px}ion-checkbox::part(container){border-radius:50%;border:2px solid var(--ion-color-primary);padding:3px}ion-item+.helper,ion-radio-group+.helper{padding-left:.75rem;position:relative}\n"] }]
511
- }], propDecorators: { updateOn: [{
512
- type: Input
513
- }], component: [{
514
- type: ViewChild,
515
- args: ['component', { read: ElementRef }]
516
- }], operation: [{
517
- type: Input,
518
- args: [{ required: true }]
519
- }], props: [{
520
- type: Input,
521
- args: [{ required: true }]
522
- }], name: [{
523
- type: Input
524
- }], options: [{
525
- type: Input
526
- }], formGroup: [{
527
- type: Input
528
- }], translatable: [{
529
- type: Input
530
- }] } });
531
-
532
- const CssClasses = {
533
- BUTTONS_CONTAINER: 'buttons-container',
534
- };
535
- const DefaultFormReactiveOptions = {
536
- buttons: {
537
- submit: {
538
- text: 'Submit',
539
- },
540
- clear: {
541
- text: 'Clear',
542
- },
543
- },
544
- };
545
-
546
- class DecafCrudFormComponent {
547
- constructor() {
548
- this.updateOn = 'change';
549
- this.target = '_self';
550
- this.method = 'event';
551
- this.formGroup = new FormGroup({});
552
- this.submitEvent = new EventEmitter();
553
- }
554
- ngAfterViewInit() {
555
- NgxFormService.formAfterViewInit(this, this.formId);
556
- }
557
- ngOnInit() {
558
- this.options = Object.assign({}, DefaultFormReactiveOptions, this.options || {});
559
- if (!this.formId)
560
- this.formId = Date.now().toString();
561
- }
562
- ngOnDestroy() {
563
- NgxFormService.forOnDestroy(this, this.formId);
564
- }
565
- /**
566
- * @param {Event} event
567
- */
568
- submit(event) {
569
- event.preventDefault();
570
- event.stopImmediatePropagation();
571
- event.stopPropagation();
572
- if (!this.formGroup.valid)
573
- return NgxFormService.validateFields(this.formGroup);
574
- console.log('onSubmit');
575
- // fix para valores de campos radio e check
576
- const data = NgxFormService.getFormData(this.formId);
577
- const submitEvent = {
578
- data: data,
579
- };
580
- if (this.action)
581
- return this.component.nativeElement.dispatchEvent(new CustomEvent('submit', data));
582
- this.submitEvent.emit(submitEvent);
583
- // self.emitEvent({
584
- // role: button?.role || FORM_BUTTON_ROLES.SUBMIT,
585
- // data,
586
- // reset: button?.reset,
587
- // operation: self.operation,
588
- // eventName: self.eventName,
589
- // event,
590
- // } as FormReactiveSubmitEvent);
591
- }
592
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: DecafCrudFormComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
593
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.13", type: DecafCrudFormComponent, isStandalone: true, selector: "decaf-crud-form", inputs: { updateOn: "updateOn", target: "target", method: "method", options: "options", action: "action", operation: "operation", formGroup: "formGroup", formId: "formId" }, outputs: { submitEvent: "submitEvent" }, viewQueries: [{ propertyName: "component", first: true, predicate: ["reactiveForm"], descendants: true, read: ElementRef }], ngImport: i0, template: "<form #reactiveForm [id]=\"formId\" [formGroup]=\"formGroup\" (submit)=\"submit($event)\" [target]=\"target\">\n <ng-content #formContent></ng-content>\n <div class=\"buttons-container\">\n <ion-button\n type=\"submit\">\n<!-- [shape]=\"buttons?.submit?.shape || 'round'\"-->\n<!-- [color]=\"buttons?.submit?.color || 'primary'\"-->\n<!-- [size]=\"buttons?.submit?.size || 'default'\"-->\n<!-- [fill]=\"buttons?.submit?.fill || 'solid'\"-->\n<!-- [disabled]=\"buttons?.submit?.disabled || false\"-->\n<!-- expand=\"block\"-->\n<!-- [disabled]=\"disableSubmitButtonWhenInvalid ? !form.valid : false\"-->\n @if(options.buttons.submit.icon) {\n <ion-icon [slot]=\"options.buttons.submit.iconSlot\" [name]=\"options.buttons.submit.icon\"></ion-icon>\n }\n {{options.buttons.submit.text}}\n </ion-button>\n @if(options.buttons.clear) {\n <ion-button>\n<!-- type=\"clear\"-->\n<!-- (click)=\"clear($event)\"-->\n<!-- [shape]=\"buttons?.clear?.shape || 'round'\"-->\n<!-- [color]=\"buttons?.clear?.color || 'primary'\"-->\n<!-- [size]=\"buttons?.clear?.size || 'default'\"-->\n<!-- [fill]=\"buttons?.clear?.fill || 'clear'\"-->\n<!-- [disabled]=\"buttons?.clear?.disabled || false\"-->\n<!-- expand=\"block\"-->\n @if(options.buttons.clear?.icon) {\n <ion-icon [slot]=\"options.buttons.clear?.iconSlot\" [name]=\"options.buttons.clear?.icon\"></ion-icon>\n }\n {{options.buttons.clear?.text}}\n </ion-button>\n }\n </div>\n</form>\n", styles: [""], dependencies: [{ kind: "ngmodule", type: IonicModule }, { kind: "component", type: i1$1.IonButton, selector: "ion-button", inputs: ["buttonType", "color", "disabled", "download", "expand", "fill", "form", "href", "mode", "rel", "routerAnimation", "routerDirection", "shape", "size", "strong", "target", "type"] }, { kind: "component", type: i1$1.IonIcon, selector: "ion-icon", inputs: ["color", "flipRtl", "icon", "ios", "lazy", "md", "mode", "name", "sanitize", "size", "src"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }] }); }
594
- }
595
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: DecafCrudFormComponent, decorators: [{
596
- type: Component,
597
- args: [{ standalone: true, selector: 'decaf-crud-form', imports: [IonicModule, ReactiveFormsModule], template: "<form #reactiveForm [id]=\"formId\" [formGroup]=\"formGroup\" (submit)=\"submit($event)\" [target]=\"target\">\n <ng-content #formContent></ng-content>\n <div class=\"buttons-container\">\n <ion-button\n type=\"submit\">\n<!-- [shape]=\"buttons?.submit?.shape || 'round'\"-->\n<!-- [color]=\"buttons?.submit?.color || 'primary'\"-->\n<!-- [size]=\"buttons?.submit?.size || 'default'\"-->\n<!-- [fill]=\"buttons?.submit?.fill || 'solid'\"-->\n<!-- [disabled]=\"buttons?.submit?.disabled || false\"-->\n<!-- expand=\"block\"-->\n<!-- [disabled]=\"disableSubmitButtonWhenInvalid ? !form.valid : false\"-->\n @if(options.buttons.submit.icon) {\n <ion-icon [slot]=\"options.buttons.submit.iconSlot\" [name]=\"options.buttons.submit.icon\"></ion-icon>\n }\n {{options.buttons.submit.text}}\n </ion-button>\n @if(options.buttons.clear) {\n <ion-button>\n<!-- type=\"clear\"-->\n<!-- (click)=\"clear($event)\"-->\n<!-- [shape]=\"buttons?.clear?.shape || 'round'\"-->\n<!-- [color]=\"buttons?.clear?.color || 'primary'\"-->\n<!-- [size]=\"buttons?.clear?.size || 'default'\"-->\n<!-- [fill]=\"buttons?.clear?.fill || 'clear'\"-->\n<!-- [disabled]=\"buttons?.clear?.disabled || false\"-->\n<!-- expand=\"block\"-->\n @if(options.buttons.clear?.icon) {\n <ion-icon [slot]=\"options.buttons.clear?.iconSlot\" [name]=\"options.buttons.clear?.icon\"></ion-icon>\n }\n {{options.buttons.clear?.text}}\n </ion-button>\n }\n </div>\n</form>\n" }]
598
- }], propDecorators: { updateOn: [{
599
- type: Input
600
- }], component: [{
601
- type: ViewChild,
602
- args: ['reactiveForm', { static: false, read: ElementRef }]
603
- }], target: [{
604
- type: Input
605
- }], method: [{
606
- type: Input
607
- }], options: [{
608
- type: Input
609
- }], action: [{
610
- type: Input
611
- }], operation: [{
612
- type: Input,
613
- args: [{ required: true }]
614
- }], formGroup: [{
615
- type: Input
616
- }], formId: [{
617
- type: Input
618
- }], submitEvent: [{
619
- type: Output
620
- }] } });
621
-
622
- class NgxRenderingEngine extends RenderingEngine {
623
- constructor() {
624
- super('angular');
625
- }
626
- async initialize(...args) {
627
- if (this.initialized)
628
- return;
629
- // ValidatableByType[]
630
- this.initialized = true;
631
- }
632
- static registerComponent(name, constructor, metadata) {
633
- if (!this._components)
634
- this._components = {};
635
- if (name in this._components)
636
- throw new InternalError(`Component already registered under ${name}`);
637
- this._components[name] = {
638
- constructor: constructor,
639
- metadata: metadata,
640
- };
641
- }
642
- static components(selector) {
643
- if (!selector)
644
- return Object.values(this._components);
645
- if (!(selector in this._components))
646
- throw new InternalError(`No Component registered under ${selector}`);
647
- return this._components[selector];
648
- }
649
- static key(key) {
650
- return `${AngularEngineKeys.REFLECT}${key}`;
651
- }
652
- }
653
-
654
- function Dynamic() {
655
- return apply((original) => {
656
- const annotation = Object.getOwnPropertyDescriptor(original, AngularEngineKeys.ANNOTATIONS);
657
- if (!annotation || !annotation.value)
658
- throw new InternalError(`Could not find Component metadata. @Dynamic decorator must come above @Component`);
659
- // console.log(
660
- // `Could not find Component metadata. @Dynamic decorator must come above @Component`,
661
- // );
662
- const decorator = annotation.value[0];
663
- NgxRenderingEngine.registerComponent(decorator.selector, original, decorator);
664
- }, metadata(NgxRenderingEngine.key(AngularEngineKeys.DYNAMIC), true));
665
- }
666
-
667
- class DynamicModule {
668
- }
669
-
670
- /**
671
- * Generated bundle index. Do not edit.
672
- */
673
-
674
- export { AngularEngineKeys, DecafCrudFieldComponent, DecafCrudFormComponent, DecafModelRendererComponent, Dynamic, DynamicModule, FormConstants, NgxRenderingEngine };
675
- //# sourceMappingURL=decaf-ts-for-angular.mjs.map