tuain-ng-forms-lib 14.4.90 → 14.4.93

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 (108) hide show
  1. package/.browserslistrc +16 -0
  2. package/.yarn/cache/nanoid-npm-4.0.0-924f5c6312-7d5946df5c.zip +0 -0
  3. package/.yarn/cache/tslib-npm-2.4.1-36f0ed04db-19480d6e03.zip +0 -0
  4. package/.yarn/cache/yn-npm-5.0.0-b001dab23c-f0ec7710d3.zip +0 -0
  5. package/.yarn/install-state.gz +0 -0
  6. package/karma.conf.js +44 -0
  7. package/ng-package.json +11 -0
  8. package/package.json +6 -24
  9. package/src/lib/classes/forms/action.ts +56 -0
  10. package/src/lib/classes/forms/element.ts +29 -0
  11. package/src/lib/classes/forms/field.ts +500 -0
  12. package/src/lib/classes/forms/form.constants.ts +28 -0
  13. package/src/lib/classes/forms/form.ts +508 -0
  14. package/src/lib/classes/forms/piece-propagate.ts +46 -0
  15. package/src/lib/classes/forms/piece.ts +122 -0
  16. package/src/lib/classes/forms/section.ts +152 -0
  17. package/src/lib/classes/forms/subsection.ts +90 -0
  18. package/src/lib/classes/forms/table/action.ts +32 -0
  19. package/src/lib/classes/forms/table/column.ts +94 -0
  20. package/src/lib/classes/forms/table/row-data.ts +121 -0
  21. package/src/lib/classes/forms/table/table.ts +478 -0
  22. package/src/lib/components/elements/action.component.ts +59 -0
  23. package/src/lib/components/elements/field.component.ts +92 -0
  24. package/src/lib/components/elements/layout/element.component.ts +13 -0
  25. package/src/lib/components/elements/layout/form-error.component.ts +11 -0
  26. package/src/lib/components/elements/layout/form-header.component.ts +17 -0
  27. package/src/lib/components/elements/layout/piece.component.ts +34 -0
  28. package/src/lib/components/elements/layout/section.component.ts +31 -0
  29. package/src/lib/components/elements/layout/sub-section.component.ts +31 -0
  30. package/src/lib/components/elements/tables/table-record-action.component.ts +50 -0
  31. package/src/lib/components/elements/tables/table-record-field.component.ts +20 -0
  32. package/src/lib/components/elements/tables/table.component.ts +86 -0
  33. package/src/lib/components/forms/basic-form.ts +1588 -0
  34. package/src/lib/services/event-manager.service.ts +21 -0
  35. package/src/lib/services/file-manager.service.ts +6 -0
  36. package/src/lib/services/form-manager.service.ts +89 -0
  37. package/src/lib/services/icon-dictionary.service.ts +159 -0
  38. package/src/lib/tuain-ng-forms-lib.module.ts +40 -0
  39. package/{public-api.d.ts → src/public-api.ts} +5 -0
  40. package/src/test.ts +27 -0
  41. package/tsconfig.lib.json +15 -0
  42. package/tsconfig.lib.prod.json +10 -0
  43. package/tsconfig.spec.json +17 -0
  44. package/esm2020/lib/classes/forms/action.mjs +0 -35
  45. package/esm2020/lib/classes/forms/element.mjs +0 -26
  46. package/esm2020/lib/classes/forms/field.mjs +0 -444
  47. package/esm2020/lib/classes/forms/form.constants.mjs +0 -26
  48. package/esm2020/lib/classes/forms/form.mjs +0 -431
  49. package/esm2020/lib/classes/forms/piece-propagate.mjs +0 -30
  50. package/esm2020/lib/classes/forms/piece.mjs +0 -95
  51. package/esm2020/lib/classes/forms/section.mjs +0 -137
  52. package/esm2020/lib/classes/forms/subsection.mjs +0 -80
  53. package/esm2020/lib/classes/forms/table/action.mjs +0 -18
  54. package/esm2020/lib/classes/forms/table/column.mjs +0 -74
  55. package/esm2020/lib/classes/forms/table/row-data.mjs +0 -116
  56. package/esm2020/lib/classes/forms/table/table.mjs +0 -415
  57. package/esm2020/lib/components/elements/action.component.mjs +0 -71
  58. package/esm2020/lib/components/elements/field.component.mjs +0 -80
  59. package/esm2020/lib/components/elements/layout/element.component.mjs +0 -20
  60. package/esm2020/lib/components/elements/layout/form-error.component.mjs +0 -20
  61. package/esm2020/lib/components/elements/layout/form-header.component.mjs +0 -31
  62. package/esm2020/lib/components/elements/layout/piece.component.mjs +0 -22
  63. package/esm2020/lib/components/elements/layout/section.component.mjs +0 -37
  64. package/esm2020/lib/components/elements/layout/sub-section.component.mjs +0 -37
  65. package/esm2020/lib/components/elements/tables/table-record-action.component.mjs +0 -56
  66. package/esm2020/lib/components/elements/tables/table-record-field.component.mjs +0 -30
  67. package/esm2020/lib/components/elements/tables/table.component.mjs +0 -93
  68. package/esm2020/lib/components/forms/basic-form.mjs +0 -1514
  69. package/esm2020/lib/services/event-manager.service.mjs +0 -18
  70. package/esm2020/lib/services/file-manager.service.mjs +0 -6
  71. package/esm2020/lib/services/form-manager.service.mjs +0 -80
  72. package/esm2020/lib/tuain-ng-forms-lib.module.mjs +0 -71
  73. package/esm2020/public-api.mjs +0 -19
  74. package/esm2020/tuain-ng-forms-lib.mjs +0 -5
  75. package/fesm2015/tuain-ng-forms-lib.mjs +0 -4229
  76. package/fesm2015/tuain-ng-forms-lib.mjs.map +0 -1
  77. package/fesm2020/tuain-ng-forms-lib.mjs +0 -4048
  78. package/fesm2020/tuain-ng-forms-lib.mjs.map +0 -1
  79. package/lib/classes/forms/action.d.ts +0 -22
  80. package/lib/classes/forms/element.d.ts +0 -17
  81. package/lib/classes/forms/field.d.ts +0 -205
  82. package/lib/classes/forms/form.constants.d.ts +0 -25
  83. package/lib/classes/forms/form.d.ts +0 -137
  84. package/lib/classes/forms/piece-propagate.d.ts +0 -11
  85. package/lib/classes/forms/piece.d.ts +0 -41
  86. package/lib/classes/forms/section.d.ts +0 -32
  87. package/lib/classes/forms/subsection.d.ts +0 -24
  88. package/lib/classes/forms/table/action.d.ts +0 -15
  89. package/lib/classes/forms/table/column.d.ts +0 -33
  90. package/lib/classes/forms/table/row-data.d.ts +0 -14
  91. package/lib/classes/forms/table/table.d.ts +0 -100
  92. package/lib/components/elements/action.component.d.ts +0 -17
  93. package/lib/components/elements/field.component.d.ts +0 -38
  94. package/lib/components/elements/layout/element.component.d.ts +0 -9
  95. package/lib/components/elements/layout/form-error.component.d.ts +0 -8
  96. package/lib/components/elements/layout/form-header.component.d.ts +0 -12
  97. package/lib/components/elements/layout/piece.component.d.ts +0 -10
  98. package/lib/components/elements/layout/section.component.d.ts +0 -11
  99. package/lib/components/elements/layout/sub-section.component.d.ts +0 -11
  100. package/lib/components/elements/tables/table-record-action.component.d.ts +0 -16
  101. package/lib/components/elements/tables/table-record-field.component.d.ts +0 -12
  102. package/lib/components/elements/tables/table.component.d.ts +0 -35
  103. package/lib/components/forms/basic-form.d.ts +0 -353
  104. package/lib/services/event-manager.service.d.ts +0 -9
  105. package/lib/services/file-manager.service.d.ts +0 -5
  106. package/lib/services/form-manager.service.d.ts +0 -28
  107. package/lib/tuain-ng-forms-lib.module.d.ts +0 -20
  108. package/tuain-ng-forms-lib.d.ts +0 -5
@@ -0,0 +1,34 @@
1
+ import { Component } from '@angular/core';
2
+
3
+ const CUSTOM_ATTRIBUTES = 'customAttributes';
4
+ @Component({
5
+ selector: 'lib-piece',
6
+ template: `<ng-content></ng-content>`
7
+ })
8
+ export class PieceComponent {
9
+ formConfig: any;
10
+ visible: boolean = true;
11
+ disabled: boolean = false;
12
+ customAttributes: any = {};
13
+
14
+ defaultProcessAttributeChange(attribute: string, value?: any): boolean {
15
+ if (!attribute || attribute.trim() === '') {
16
+ return false;
17
+ }
18
+ const attributeParts = attribute.split('.');
19
+ if (attributeParts?.length > 1) {
20
+ const [attributeType, subAttribute] = attributeParts;
21
+ if (attributeType === CUSTOM_ATTRIBUTES) {
22
+ this.customAttributes[subAttribute] = value;
23
+ this.customAttributeChange(subAttribute, value);
24
+ }
25
+ } else {
26
+ this[attribute] = value;
27
+ }
28
+ return true;
29
+ }
30
+
31
+ customProcessAttributeChange(attribute: string, value?: any) { }
32
+
33
+ customAttributeChange(subAttribute: string, value?: any) { }
34
+ }
@@ -0,0 +1,31 @@
1
+ import { Component, Input, OnInit } from '@angular/core';
2
+ import { PieceComponent } from './piece.component';
3
+
4
+ @Component({
5
+ selector: 'lib-section',
6
+ template: `<ng-content></ng-content>`
7
+ })
8
+ export class SectionComponent extends PieceComponent implements OnInit {
9
+ @Input() section: any;
10
+ @Input() form: any;
11
+
12
+ ngOnInit() {
13
+ this.formConfig = this.section?._formConfig;
14
+ const mapping = this.formConfig?.sectionPropagateAttributes;
15
+ for (let index = 0; index < mapping.length; index++) {
16
+ const attrName = mapping[index].toString();
17
+ const attributeValue = this.section?.[attrName];
18
+ this.defaultProcessAttributeChange(attrName, attributeValue);
19
+ this.customProcessAttributeChange(attrName, attributeValue);
20
+ }
21
+ // Subscripción a cambios en atributos
22
+ this.section?.attributeChange.subscribe(event => {
23
+ const { name: attrName, value } = event;
24
+ this.defaultProcessAttributeChange(attrName, value);
25
+ this.customProcessAttributeChange(attrName, value);
26
+ });
27
+ this.start();
28
+ }
29
+
30
+ start() { }
31
+ }
@@ -0,0 +1,31 @@
1
+ import { Component, Input, OnInit } from '@angular/core';
2
+ import { PieceComponent } from './piece.component';
3
+
4
+ @Component({
5
+ selector: 'lib-subsection',
6
+ template: `<ng-content></ng-content>`
7
+ })
8
+ export class SubSectionComponent extends PieceComponent implements OnInit {
9
+ @Input() subSection: any;
10
+ @Input() form: any;
11
+
12
+ ngOnInit() {
13
+ this.formConfig = this.subSection?._formConfig;
14
+ const mapping = this.formConfig?.subSectionPropagateAttributes;
15
+ for (let index = 0; index < mapping.length; index++) {
16
+ const attrName = mapping[index].toString();
17
+ const attributeValue = this.subSection?.[attrName];
18
+ this.defaultProcessAttributeChange(attrName, attributeValue);
19
+ this.customProcessAttributeChange(attrName, attributeValue);
20
+ }
21
+ // Subscripción a cambios en atributos
22
+ this.subSection?.attributeChange.subscribe(event => {
23
+ const { name: attrName, value } = event;
24
+ this.defaultProcessAttributeChange(attrName, value);
25
+ this.customProcessAttributeChange(attrName, value);
26
+ });
27
+ this.start();
28
+ }
29
+
30
+ start() { }
31
+ }
@@ -0,0 +1,50 @@
1
+ import { Component, Input, Output, OnInit, EventEmitter, ChangeDetectionStrategy } from '@angular/core';
2
+ import { PieceComponent } from '../layout/piece.component';
3
+ import { TableEvent, TableActionEvent } from '../../../classes/forms/table/table';
4
+
5
+ const INLINE_ACTION = 'INLINE';
6
+
7
+ @Component({
8
+ selector: 'lib-table-record-action',
9
+ template: `<ng-content></ng-content>`,
10
+ changeDetection: ChangeDetectionStrategy.OnPush
11
+ })
12
+
13
+ export class LibTableRecordActionComponent extends PieceComponent implements OnInit {
14
+ @Input() recordId: any;
15
+ @Input() recordData: any;
16
+ @Input() action: any;
17
+
18
+ @Output() actionSelected: EventEmitter<TableActionEvent> = new EventEmitter<TableActionEvent>();
19
+
20
+ ngOnInit() {
21
+ this.formConfig = this.action?._formConfig;
22
+ const mapping = this.formConfig?.actionPropagateAttributes;
23
+ for (let index = 0; index < mapping.length; index++) {
24
+ const attrName = mapping[index].toString();
25
+ const attributeValue = this.action?.[attrName];
26
+ this.defaultProcessAttributeChange(attrName, attributeValue);
27
+ this.customProcessAttributeChange(attrName, attributeValue);
28
+ }
29
+ // Subscripción a cambios en atributos
30
+ this.action?.attributeChange.subscribe(event => {
31
+ const { name: attrName, value } = event;
32
+ this.defaultProcessAttributeChange(attrName, value);
33
+ this.customProcessAttributeChange(attrName, value);
34
+ });
35
+ this.start();
36
+ }
37
+
38
+ start() { }
39
+
40
+ onActivate() {
41
+ const tableEvent: TableActionEvent = {
42
+ actionCode: this.action.actionCode,
43
+ recordId: this.recordId,
44
+ recordData: this.recordData,
45
+ };
46
+ this.actionSelected.emit(tableEvent);
47
+ }
48
+
49
+ class() { }
50
+ }
@@ -0,0 +1,20 @@
1
+ import { Component, Input, OnInit, ChangeDetectionStrategy } from '@angular/core';
2
+
3
+ @Component({
4
+ selector: 'lib-table-record-field',
5
+ template: `<ng-content></ng-content>`,
6
+ changeDetection: ChangeDetectionStrategy.OnPush
7
+ })
8
+
9
+ export class LibTableRecordFieldComponent implements OnInit {
10
+ @Input() fieldCode: any;
11
+ @Input() fieldType: any;
12
+ @Input() fieldValue: any;
13
+ @Input() column: any = null;
14
+
15
+ ngOnInit() {
16
+ this.start();
17
+ }
18
+
19
+ start() { }
20
+ }
@@ -0,0 +1,86 @@
1
+ import { Component, OnInit, Input, ChangeDetectionStrategy } from '@angular/core';
2
+ import { TableRecordData } from '../../../classes/forms/table/row-data';
3
+ import { TableActionEvent } from '../../../classes/forms/table/table';
4
+ import { RecordTable, TableEvent } from '../../../classes/forms/table/table';
5
+ import { ElementComponent } from '../layout/element.component';
6
+
7
+ @Component({
8
+ selector: 'lib-table',
9
+ template: `<ng-content></ng-content>`,
10
+ changeDetection: ChangeDetectionStrategy.OnPush
11
+ })
12
+
13
+ export class LibTableComponent extends ElementComponent implements OnInit {
14
+ // Atributos sincronizados del objeto
15
+ code: any;
16
+ globalFilterString: string = '';
17
+
18
+ tableFieldStyles: any;
19
+ loaded = false;
20
+ selectable = false;
21
+ hasActions = false;
22
+ inlineActions: any;
23
+ globalActions: any;
24
+ selectionActions: any;
25
+
26
+ @Input() table: RecordTable | null = null;
27
+ @Input() visibleRecords: TableRecordData[] = [];
28
+ @Input() waiting: boolean = false;
29
+
30
+ ngOnInit() {
31
+ if (!this.table) { return; }
32
+ this.formConfig = this.table?._formConfig;
33
+ this.tableFieldStyles = this.formConfig?.tableFieldStyles;
34
+ this.selectable = this.table?.selectable;
35
+ this.hasActions = this.table?.hasActions();
36
+ this.inlineActions = this.table?.getActions(this.formConfig?.tableActions.inline);
37
+ this.globalActions = this.table?.getActions(this.formConfig?.tableActions.global);
38
+ this.selectionActions = this.table?.getActions(this.formConfig?.tableActions.selection);
39
+ // Inicialización de campos mapeados del objeto
40
+ const mapping = Object.entries(this.formConfig?.tablePropagationAttributes);
41
+ for (let index = 0; index < mapping.length; index++) {
42
+ const tableAttr = mapping[index]?.[0];
43
+ const componentAttr = mapping[index]?.[1]?.toString() ?? '';
44
+ const attributeValue = this.table?.[tableAttr];
45
+ this.defaultProcessAttributeChange(componentAttr, attributeValue);
46
+ this.customProcessAttributeChange(componentAttr, attributeValue);
47
+ }
48
+ // Subscripción a cambios en atributos
49
+ this.table?.attributeChange.subscribe(event => {
50
+ const { name: attrName, value } = event;
51
+ this.defaultProcessAttributeChange(attrName, value);
52
+ this.customProcessAttributeChange(attrName, value);
53
+ });
54
+ this.start();
55
+ }
56
+
57
+ updateTableData() { }
58
+ tableGlobalAction(actionCode: string) { this.table?.notifyGlobalAction(actionCode); }
59
+ tableSelectionAction(actionCode: string) { this.table?.notifySelectionAction(actionCode); }
60
+ tableActionSelected(actionEvent: TableActionEvent) { this.table?.notifyInlineAction(actionEvent); }
61
+ tableSelectionToggle(recordId: any) { this.table?.notifyRecordSelection(recordId); }
62
+ toggleSelectAll() { return (this.table?.allSelected) ? this.table?.unSelectAll() : this.table?.selectAll(); }
63
+ globalFilterCompleted() { this.changePage(1); }
64
+ changePage(requestedPage: number) { this.table?.changePage(requestedPage); }
65
+ tableColumnSort(columnName: string, direction = null) { this.table?.sort(columnName, direction ?? 'ascend'); }
66
+ globalFilterChanged() { this.table?.setGlobalFilterString(this.globalFilterString?.trim() ?? '', false); }
67
+
68
+ override defaultProcessAttributeChange(attribute: string, value?: any): boolean {
69
+ try {
70
+ if (attribute === 'visibleRecords') {
71
+ this.updateTableData();
72
+ }
73
+ return super.defaultProcessAttributeChange(attribute, value);
74
+ } catch {
75
+ return false;
76
+ }
77
+ }
78
+
79
+ filterHasChanged(column, values) {
80
+ if (!values || values.length === 0) {
81
+ this.table?.removeColumnFilter(column.fieldCode);
82
+ } else {
83
+ this.table?.addColumnFilter(column.fieldCode, values);
84
+ }
85
+ }
86
+ }