tuain-ng-forms-lib 14.0.0 → 14.0.1

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 (99) 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.0-9cb6dc5030-8c4aa6a3c5.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 +2 -22
  9. package/src/lib/classes/forms/action.ts +55 -0
  10. package/src/lib/classes/forms/element.ts +98 -0
  11. package/src/lib/classes/forms/field.ts +408 -0
  12. package/src/lib/classes/forms/form.constants.ts +28 -0
  13. package/src/lib/classes/forms/form.ts +495 -0
  14. package/src/lib/classes/forms/section.ts +154 -0
  15. package/src/lib/classes/forms/subsection.ts +91 -0
  16. package/src/lib/classes/forms/table/action.ts +41 -0
  17. package/src/lib/classes/forms/table/column.ts +91 -0
  18. package/src/lib/classes/forms/table/row-data.ts +118 -0
  19. package/src/lib/classes/forms/table/table.ts +438 -0
  20. package/src/lib/components/elements/action.component.ts +53 -0
  21. package/src/lib/components/elements/field.component.ts +118 -0
  22. package/src/lib/components/elements/layout/element.component.ts +28 -0
  23. package/src/lib/components/elements/layout/form-error.component.ts +11 -0
  24. package/src/lib/components/elements/layout/form-header.component.ts +17 -0
  25. package/src/lib/components/elements/layout/section.component.ts +16 -0
  26. package/src/lib/components/elements/layout/sub-section.component.ts +17 -0
  27. package/src/lib/components/elements/tables/table-record-action.component.ts +37 -0
  28. package/src/lib/components/elements/tables/table-record-field.component.ts +19 -0
  29. package/src/lib/components/elements/tables/table.component.ts +102 -0
  30. package/src/lib/components/forms/basic-form.ts +1496 -0
  31. package/src/lib/services/event-manager.service.ts +21 -0
  32. package/src/lib/services/file-manager.service.ts +6 -0
  33. package/src/lib/services/form-manager.service.ts +89 -0
  34. package/src/lib/services/icon-dictionary.service.ts +159 -0
  35. package/src/lib/tuain-ng-forms-lib.module.ts +40 -0
  36. package/{public-api.d.ts → src/public-api.ts} +5 -0
  37. package/src/test.ts +27 -0
  38. package/tsconfig.lib.json +15 -0
  39. package/tsconfig.lib.prod.json +10 -0
  40. package/tsconfig.spec.json +17 -0
  41. package/esm2020/lib/classes/forms/action.mjs +0 -35
  42. package/esm2020/lib/classes/forms/element.mjs +0 -76
  43. package/esm2020/lib/classes/forms/field.mjs +0 -321
  44. package/esm2020/lib/classes/forms/form.constants.mjs +0 -26
  45. package/esm2020/lib/classes/forms/form.mjs +0 -422
  46. package/esm2020/lib/classes/forms/section.mjs +0 -132
  47. package/esm2020/lib/classes/forms/subsection.mjs +0 -70
  48. package/esm2020/lib/classes/forms/table/action.mjs +0 -22
  49. package/esm2020/lib/classes/forms/table/column.mjs +0 -61
  50. package/esm2020/lib/classes/forms/table/row-data.mjs +0 -111
  51. package/esm2020/lib/classes/forms/table/table.mjs +0 -372
  52. package/esm2020/lib/components/elements/action.component.mjs +0 -58
  53. package/esm2020/lib/components/elements/field.component.mjs +0 -90
  54. package/esm2020/lib/components/elements/layout/element.component.mjs +0 -31
  55. package/esm2020/lib/components/elements/layout/form-error.component.mjs +0 -20
  56. package/esm2020/lib/components/elements/layout/form-header.component.mjs +0 -30
  57. package/esm2020/lib/components/elements/layout/section.component.mjs +0 -22
  58. package/esm2020/lib/components/elements/layout/sub-section.component.mjs +0 -24
  59. package/esm2020/lib/components/elements/tables/table-record-action.component.mjs +0 -40
  60. package/esm2020/lib/components/elements/tables/table-record-field.component.mjs +0 -25
  61. package/esm2020/lib/components/elements/tables/table.component.mjs +0 -95
  62. package/esm2020/lib/components/forms/basic-form.mjs +0 -1425
  63. package/esm2020/lib/services/event-manager.service.mjs +0 -18
  64. package/esm2020/lib/services/file-manager.service.mjs +0 -6
  65. package/esm2020/lib/services/form-manager.service.mjs +0 -80
  66. package/esm2020/lib/tuain-ng-forms-lib.module.mjs +0 -71
  67. package/esm2020/public-api.mjs +0 -19
  68. package/esm2020/tuain-ng-forms-lib.mjs +0 -5
  69. package/fesm2015/tuain-ng-forms-lib.mjs +0 -3803
  70. package/fesm2015/tuain-ng-forms-lib.mjs.map +0 -1
  71. package/fesm2020/tuain-ng-forms-lib.mjs +0 -3634
  72. package/fesm2020/tuain-ng-forms-lib.mjs.map +0 -1
  73. package/lib/classes/forms/action.d.ts +0 -22
  74. package/lib/classes/forms/element.d.ts +0 -41
  75. package/lib/classes/forms/field.d.ts +0 -109
  76. package/lib/classes/forms/form.constants.d.ts +0 -25
  77. package/lib/classes/forms/form.d.ts +0 -134
  78. package/lib/classes/forms/section.d.ts +0 -39
  79. package/lib/classes/forms/subsection.d.ts +0 -26
  80. package/lib/classes/forms/table/action.d.ts +0 -20
  81. package/lib/classes/forms/table/column.d.ts +0 -33
  82. package/lib/classes/forms/table/row-data.d.ts +0 -14
  83. package/lib/classes/forms/table/table.d.ts +0 -100
  84. package/lib/components/elements/action.component.d.ts +0 -21
  85. package/lib/components/elements/field.component.d.ts +0 -43
  86. package/lib/components/elements/layout/element.component.d.ts +0 -14
  87. package/lib/components/elements/layout/form-error.component.d.ts +0 -8
  88. package/lib/components/elements/layout/form-header.component.d.ts +0 -12
  89. package/lib/components/elements/layout/section.component.d.ts +0 -10
  90. package/lib/components/elements/layout/sub-section.component.d.ts +0 -11
  91. package/lib/components/elements/tables/table-record-action.component.d.ts +0 -15
  92. package/lib/components/elements/tables/table-record-field.component.d.ts +0 -11
  93. package/lib/components/elements/tables/table.component.d.ts +0 -47
  94. package/lib/components/forms/basic-form.d.ts +0 -307
  95. package/lib/services/event-manager.service.d.ts +0 -9
  96. package/lib/services/file-manager.service.d.ts +0 -5
  97. package/lib/services/form-manager.service.d.ts +0 -28
  98. package/lib/tuain-ng-forms-lib.module.d.ts +0 -20
  99. package/tuain-ng-forms-lib.d.ts +0 -5
@@ -0,0 +1,37 @@
1
+ import { Component, Input, Output, OnInit, EventEmitter, ChangeDetectionStrategy } from '@angular/core';
2
+ import { TableEvent, TableActionEvent } from '../../../classes/forms/table/table';
3
+
4
+ const INLINE_ACTION = 'INLINE';
5
+
6
+ @Component({
7
+ selector: 'lib-table-record-action',
8
+ template: `<ng-content></ng-content>`,
9
+ changeDetection: ChangeDetectionStrategy.OnPush
10
+ })
11
+
12
+ export class LibTableRecordActionComponent implements OnInit {
13
+ @Input() recordId: any;
14
+ @Input() recordData: any;
15
+ @Input() action: any;
16
+
17
+ @Output() actionSelected: EventEmitter<object> = new EventEmitter<object>();
18
+
19
+ constructor() { }
20
+
21
+ ngOnInit() {
22
+ this.start();
23
+ }
24
+
25
+ start() { }
26
+
27
+ onActivate() {
28
+ const tableEvent: TableActionEvent = {
29
+ actionCode: this.action.actionCode,
30
+ recordId: this.recordId,
31
+ recordData: this.recordData,
32
+ };
33
+ this.actionSelected.emit(tableEvent);
34
+ }
35
+
36
+ class() { }
37
+ }
@@ -0,0 +1,19 @@
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
+
14
+ ngOnInit() {
15
+ this.start();
16
+ }
17
+
18
+ start() { }
19
+ }
@@ -0,0 +1,102 @@
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
+
6
+ const changeViewAttributes = ['visibleRecords', 'currentPage', 'recordsPerPage'];
7
+
8
+ @Component({
9
+ selector: 'lib-table',
10
+ template: `<ng-content></ng-content>`,
11
+ changeDetection: ChangeDetectionStrategy.OnPush
12
+ })
13
+
14
+ export class LibTableComponent implements OnInit {
15
+ formConfig: any;
16
+ globalFilterString: string = '';
17
+
18
+ // Atributos sincronizados del objeto
19
+ code: any;
20
+ columns: any;
21
+ currentPage: number = 1;
22
+ globalSearch: boolean = false;
23
+ visibleRecords: any[];
24
+ selectedRecords: any[] = [];
25
+ recordsPerPage: any;
26
+ totalRecordsNumber: number = 0;
27
+ allSelected: boolean = false;
28
+ layout: string;
29
+
30
+ tableFieldStyles: any;
31
+ loaded = false;
32
+ selectable = false;
33
+ hasActions = false;
34
+ inlineActions: any;
35
+ globalActions: any;
36
+ selectionActions: any;
37
+
38
+ @Input() table: RecordTable;
39
+ @Input() tableRecords: TableRecordData[];
40
+ @Input() disabled: boolean = false;
41
+ @Input() state: string;
42
+ @Input() waiting: boolean;
43
+
44
+ ngOnInit() {
45
+ if (this.table) {
46
+ this.formConfig = this.table?._formConfig;
47
+ this.tableFieldStyles = this.formConfig.tableFieldStyles;
48
+ this.selectable = this.table.selectable;
49
+ this.hasActions = this.table.hasActions();
50
+ this.inlineActions = this.table.getActions(this.formConfig.tableActions.inline);
51
+ this.globalActions = this.table.getActions(this.formConfig.tableActions.global);
52
+ this.selectionActions = this.table.getActions(this.formConfig.tableActions.selection);
53
+ // Inicialización de campos mapeados del objeto
54
+ const mapping = Object.entries(this.formConfig.componentTableAttrMap);
55
+ for (let index = 0; index < mapping.length; index++) {
56
+ const [tableAttrRaw, compAttrRaw] = mapping[index];
57
+ const tableAttr = tableAttrRaw.toString();
58
+ const compAttr = compAttrRaw.toString();
59
+ this.syncAttribute(compAttr, this.table[tableAttr]);
60
+ }
61
+ // Subscripción a cambios en atributos
62
+ this.table.attributeChange.subscribe(event => {
63
+ const { name: tableAttr, value } = event;
64
+ const compAttr = this.formConfig.componentTableAttrMap[tableAttr];
65
+ this.syncAttribute(compAttr, value);
66
+ });
67
+ }
68
+ this.start();
69
+ }
70
+
71
+ start() { }
72
+ updateTableData() { }
73
+ tableGlobalAction(actionCode: string) { this.table.notifyGlobalAction(actionCode); }
74
+ tableSelectionAction(actionCode: string) { this.table.notifySelectionAction(actionCode); }
75
+ tableActionSelected(actionEvent: TableActionEvent) { this.table.notifyInlineAction(actionEvent); }
76
+ tableSelectionToggle(recordId: any) { this.table.notifyRecordSelection(recordId); }
77
+ toggleSelectAll() { return (this.allSelected) ? this.table.unSelectAll() : this.table.selectAll(); }
78
+ globalFilterCompleted() { this.changePage(1); }
79
+ changePage(requestedPage: number) { this.table.changePage(requestedPage); }
80
+ tableColumnSort(columnName: string, direction = null) { this.table.sort(columnName, direction ?? 'ascend'); }
81
+ globalFilterChanged() { this.table.setGlobalFilterString(this.globalFilterString?.trim() ?? ''); }
82
+
83
+ syncAttribute(name: string, value: any) {
84
+ try {
85
+ if (name === 'visibleRecords') {
86
+ this.updateTableData();
87
+ }
88
+ this[name] = value;
89
+ return true;
90
+ } catch {
91
+ return false;
92
+ }
93
+ }
94
+
95
+ filterHasChanged(column, values) {
96
+ if (!values || values.length === 0) {
97
+ this.table.removeColumnFilter(column.fieldCode);
98
+ } else {
99
+ this.table.addColumnFilter(column.fieldCode, values);
100
+ }
101
+ }
102
+ }