tuain-ng-forms-lib 17.2.21 → 17.2.22

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 (106) 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 +2 -16
  9. package/src/lib/classes/forms/action.ts +117 -0
  10. package/src/lib/classes/forms/element.ts +26 -0
  11. package/src/lib/classes/forms/field.ts +522 -0
  12. package/src/lib/classes/forms/form.constants.ts +28 -0
  13. package/src/lib/classes/forms/form.ts +692 -0
  14. package/src/lib/classes/forms/piece-propagate.ts +47 -0
  15. package/src/lib/classes/forms/piece.ts +164 -0
  16. package/src/lib/classes/forms/section.ts +165 -0
  17. package/src/lib/classes/forms/subsection.ts +109 -0
  18. package/src/lib/classes/forms/table/action.ts +41 -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 +582 -0
  22. package/src/lib/components/elements/action.component.ts +70 -0
  23. package/src/lib/components/elements/field.component.ts +115 -0
  24. package/src/lib/components/elements/layout/element.component.ts +14 -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 +14 -0
  27. package/src/lib/components/elements/layout/piece.component.ts +60 -0
  28. package/src/lib/components/elements/layout/section.component.ts +52 -0
  29. package/src/lib/components/elements/layout/sub-section.component.ts +52 -0
  30. package/src/lib/components/elements/tables/table-record-action.component.ts +66 -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 +112 -0
  33. package/src/lib/components/forms/basic-form.ts +1464 -0
  34. package/src/lib/services/event-manager.service.ts +45 -0
  35. package/src/lib/services/file-manager.service.ts +7 -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/esm2022/lib/classes/forms/action.mjs +0 -106
  45. package/esm2022/lib/classes/forms/element.mjs +0 -25
  46. package/esm2022/lib/classes/forms/field.mjs +0 -474
  47. package/esm2022/lib/classes/forms/form.constants.mjs +0 -26
  48. package/esm2022/lib/classes/forms/form.mjs +0 -608
  49. package/esm2022/lib/classes/forms/piece-propagate.mjs +0 -39
  50. package/esm2022/lib/classes/forms/piece.mjs +0 -134
  51. package/esm2022/lib/classes/forms/section.mjs +0 -151
  52. package/esm2022/lib/classes/forms/subsection.mjs +0 -99
  53. package/esm2022/lib/classes/forms/table/action.mjs +0 -38
  54. package/esm2022/lib/classes/forms/table/column.mjs +0 -74
  55. package/esm2022/lib/classes/forms/table/row-data.mjs +0 -116
  56. package/esm2022/lib/classes/forms/table/table.mjs +0 -535
  57. package/esm2022/lib/components/elements/action.component.mjs +0 -70
  58. package/esm2022/lib/components/elements/field.component.mjs +0 -115
  59. package/esm2022/lib/components/elements/layout/element.component.mjs +0 -21
  60. package/esm2022/lib/components/elements/layout/form-error.component.mjs +0 -23
  61. package/esm2022/lib/components/elements/layout/form-header.component.mjs +0 -23
  62. package/esm2022/lib/components/elements/layout/piece.component.mjs +0 -64
  63. package/esm2022/lib/components/elements/layout/section.component.mjs +0 -56
  64. package/esm2022/lib/components/elements/layout/sub-section.component.mjs +0 -56
  65. package/esm2022/lib/components/elements/tables/table-record-action.component.mjs +0 -72
  66. package/esm2022/lib/components/elements/tables/table-record-field.component.mjs +0 -31
  67. package/esm2022/lib/components/elements/tables/table.component.mjs +0 -109
  68. package/esm2022/lib/components/forms/basic-form.mjs +0 -1399
  69. package/esm2022/lib/services/event-manager.service.mjs +0 -43
  70. package/esm2022/lib/services/file-manager.service.mjs +0 -7
  71. package/esm2022/lib/services/form-manager.service.mjs +0 -81
  72. package/esm2022/lib/tuain-ng-forms-lib.module.mjs +0 -71
  73. package/esm2022/public-api.mjs +0 -19
  74. package/esm2022/tuain-ng-forms-lib.mjs +0 -5
  75. package/fesm2022/tuain-ng-forms-lib.mjs +0 -4593
  76. package/fesm2022/tuain-ng-forms-lib.mjs.map +0 -1
  77. package/index.d.ts +0 -5
  78. package/lib/classes/forms/action.d.ts +0 -40
  79. package/lib/classes/forms/element.d.ts +0 -9
  80. package/lib/classes/forms/field.d.ts +0 -206
  81. package/lib/classes/forms/form.constants.d.ts +0 -25
  82. package/lib/classes/forms/form.d.ts +0 -232
  83. package/lib/classes/forms/piece-propagate.d.ts +0 -13
  84. package/lib/classes/forms/piece.d.ts +0 -51
  85. package/lib/classes/forms/section.d.ts +0 -43
  86. package/lib/classes/forms/subsection.d.ts +0 -42
  87. package/lib/classes/forms/table/action.d.ts +0 -16
  88. package/lib/classes/forms/table/column.d.ts +0 -33
  89. package/lib/classes/forms/table/row-data.d.ts +0 -14
  90. package/lib/classes/forms/table/table.d.ts +0 -145
  91. package/lib/components/elements/action.component.d.ts +0 -22
  92. package/lib/components/elements/field.component.d.ts +0 -47
  93. package/lib/components/elements/layout/element.component.d.ts +0 -8
  94. package/lib/components/elements/layout/form-error.component.d.ts +0 -8
  95. package/lib/components/elements/layout/form-header.component.d.ts +0 -9
  96. package/lib/components/elements/layout/piece.component.d.ts +0 -18
  97. package/lib/components/elements/layout/section.component.d.ts +0 -13
  98. package/lib/components/elements/layout/sub-section.component.d.ts +0 -13
  99. package/lib/components/elements/tables/table-record-action.component.d.ts +0 -18
  100. package/lib/components/elements/tables/table-record-field.component.d.ts +0 -12
  101. package/lib/components/elements/tables/table.component.d.ts +0 -44
  102. package/lib/components/forms/basic-form.d.ts +0 -256
  103. package/lib/services/event-manager.service.d.ts +0 -11
  104. package/lib/services/file-manager.service.d.ts +0 -6
  105. package/lib/services/form-manager.service.d.ts +0 -28
  106. package/lib/tuain-ng-forms-lib.module.d.ts +0 -20
@@ -0,0 +1,16 @@
1
+ # This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
2
+ # For additional information regarding the format and rule options, please see:
3
+ # https://github.com/browserslist/browserslist#queries
4
+
5
+ # For the full list of supported browsers by the Angular framework, please see:
6
+ # https://angular.io/guide/browser-support
7
+
8
+ # You can see what browsers were selected by your queries by running:
9
+ # npx browserslist
10
+
11
+ last 1 Chrome version
12
+ last 1 Firefox version
13
+ last 2 Edge major versions
14
+ # last 2 Safari major versions
15
+ last 2 iOS major versions
16
+ Firefox ESR
Binary file
package/karma.conf.js ADDED
@@ -0,0 +1,44 @@
1
+ // Karma configuration file, see link for more information
2
+ // https://karma-runner.github.io/1.0/config/configuration-file.html
3
+
4
+ module.exports = function (config) {
5
+ config.set({
6
+ basePath: '',
7
+ frameworks: ['jasmine', '@angular-devkit/build-angular'],
8
+ plugins: [
9
+ require('karma-jasmine'),
10
+ require('karma-chrome-launcher'),
11
+ require('karma-jasmine-html-reporter'),
12
+ require('karma-coverage'),
13
+ require('@angular-devkit/build-angular/plugins/karma')
14
+ ],
15
+ client: {
16
+ jasmine: {
17
+ // you can add configuration options for Jasmine here
18
+ // the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
19
+ // for example, you can disable the random execution with `random: false`
20
+ // or set a specific seed with `seed: 4321`
21
+ },
22
+ clearContext: false // leave Jasmine Spec Runner output visible in browser
23
+ },
24
+ jasmineHtmlReporter: {
25
+ suppressAll: true // removes the duplicated traces
26
+ },
27
+ coverageReporter: {
28
+ dir: require('path').join(__dirname, '../../coverage/tuain-ng-forms-lib'),
29
+ subdir: '.',
30
+ reporters: [
31
+ { type: 'html' },
32
+ { type: 'text-summary' }
33
+ ]
34
+ },
35
+ reporters: ['progress', 'kjhtml'],
36
+ port: 9876,
37
+ colors: true,
38
+ logLevel: config.LOG_INFO,
39
+ autoWatch: true,
40
+ browsers: ['Chrome'],
41
+ singleRun: false,
42
+ restartOnFileChange: true
43
+ });
44
+ };
@@ -0,0 +1,11 @@
1
+ {
2
+ "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3
+ "dest": "../../dist/tuain-ng-forms-lib",
4
+ "lib": {
5
+ "entryFile": "src/public-api.ts"
6
+ },
7
+ "allowedNonPeerDependencies": [
8
+ "nanoid",
9
+ "yn"
10
+ ]
11
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tuain-ng-forms-lib",
3
- "version": "17.2.21",
3
+ "version": "17.2.22",
4
4
  "description": "Componentes y Clases Angular para la gestión de formularios TUAIN",
5
5
  "author": "Mauricio Méndez, Imix Consulting",
6
6
  "license": "MIT",
@@ -22,19 +22,5 @@
22
22
  "nanoid": "^4.0.0",
23
23
  "tslib": "^2.4.0",
24
24
  "yn": "^5.0.0"
25
- },
26
- "module": "fesm2022/tuain-ng-forms-lib.mjs",
27
- "typings": "index.d.ts",
28
- "exports": {
29
- "./package.json": {
30
- "default": "./package.json"
31
- },
32
- ".": {
33
- "types": "./index.d.ts",
34
- "esm2022": "./esm2022/tuain-ng-forms-lib.mjs",
35
- "esm": "./esm2022/tuain-ng-forms-lib.mjs",
36
- "default": "./fesm2022/tuain-ng-forms-lib.mjs"
37
- }
38
- },
39
- "sideEffects": false
25
+ }
40
26
  }
@@ -0,0 +1,117 @@
1
+ import { Subject } from 'rxjs';
2
+ import { elementTypes } from './form.constants';
3
+ import { FormElement } from './element';
4
+
5
+ const HEADER = 'HEADER';
6
+
7
+ const attrs = {
8
+ actionCode: { name: '_actionCode', propagate: 'actionCode' },
9
+ actionName: { name: '_actionName', propagate: 'actionName' },
10
+ iconName: { name: '_iconName', propagate: 'iconName' },
11
+ inProgress: { name: '_inProgress', propagate: 'inProgress' },
12
+ restrictedOnField: { name: '_restrictedOnField', propagate: 'restrictedOnField' },
13
+ restrictedOnOperator: { name: '_restrictedOnOperator', propagate: 'restrictedOnOperator' },
14
+ restrictedOnValue: { name: '_restrictedOnValue', propagate: 'restrictedOnValue' },
15
+ }
16
+
17
+ export class FormAction extends FormElement {
18
+ private readonly _actionActivated = new Subject<string>();
19
+ private _actionCode: string = '';
20
+ private _actionName: string = '';
21
+ private _iconName: string = '';
22
+ private _inProgress = false;
23
+ private _newState: string;
24
+ private _backend: boolean;
25
+ private _restrictedOnField: string | null = null;
26
+ private _restrictedOnOperator: string | null = null;
27
+ private _restrictedOnValue: string | null = null;
28
+
29
+ constructor(actionDefinition, formConfig) {
30
+ super(actionDefinition, formConfig);
31
+ this.propagationCustomAttributes = this._formConfig?.propagationCustomAttributes?.actions ?? [];
32
+ this.elementType = elementTypes.action;
33
+ this.setAttr(attrs.actionCode, actionDefinition.actionCode ? actionDefinition.actionCode.toString() : '');
34
+ this.setAttr(attrs.actionName, actionDefinition.actionTitle);
35
+ this.setAttr(attrs.iconName, actionDefinition.iconName || this._actionCode);
36
+ this.setAttr(attrs.restrictedOnField, actionDefinition.fieldRestrictedCode?.toString() ?? null);
37
+ if (this._restrictedOnField) {
38
+ this.setAttr(attrs.restrictedOnOperator, actionDefinition.operatorRestricted || '');
39
+ this.setAttr(attrs.restrictedOnValue, actionDefinition.valueRestricted ?? '');
40
+ }
41
+ this._backend = actionDefinition?.serverAction ?? false;
42
+ this._newState = actionDefinition?.newState;
43
+ this.setCustomAttribute('location', actionDefinition.position || HEADER);
44
+ }
45
+
46
+ get actionCode() { return this._actionCode; }
47
+ get actionName() { return this._actionName; }
48
+ get iconName() { return this._iconName; }
49
+ get inProgress() { return this._inProgress; }
50
+ get newState() { return this._newState; }
51
+ get backend() { return this._backend; }
52
+ get restrictedOnField() { return this._restrictedOnField; }
53
+ get restrictedOnOperator() { return this._restrictedOnOperator; }
54
+ get restrictedOnValue() { return this._restrictedOnValue; }
55
+
56
+ set actionCode(actionCode) { this.setAttr(attrs.actionCode, actionCode); }
57
+ set actionName(actionName) { this.setAttr(attrs.actionName, actionName); }
58
+ set iconName(iconName) { this.setAttr(attrs.iconName, iconName); }
59
+ set inProgress(inProgress) { this.setAttr(attrs.inProgress, inProgress); }
60
+ set newState(newState) { this._newState, newState; }
61
+ set backend(backend) { this._backend, backend; }
62
+ set restrictedOnField(restrictedOnField) { this.setAttr(attrs.restrictedOnField, restrictedOnField); }
63
+ set restrictedOnOperator(restrictedOnOperator) { this.setAttr(attrs.restrictedOnOperator, restrictedOnOperator); }
64
+ set restrictedOnValue(restrictedOnValue) { this.setAttr(attrs.restrictedOnValue, restrictedOnValue); }
65
+
66
+ start() { this.inProgress = true; }
67
+ stop() { this.inProgress = false; }
68
+
69
+ override connectWithParentForm(form, formChangeSubject) {
70
+ super.connectWithParentForm(form, formChangeSubject);
71
+ if (this._restrictedOnField) {
72
+ const relatedField = this._form.fields?.[this._restrictedOnField];
73
+ if (relatedField) {
74
+ relatedField.editionFinish
75
+ .subscribe(event => this.updateRestrictedVisibility(event));
76
+ relatedField.editionPartial
77
+ .subscribe(event => this.updateRestrictedVisibility(event));
78
+ }
79
+ }
80
+ }
81
+
82
+ updateRestrictedVisibility(event) {
83
+ const newVisible = this._absoluteVisible && this.viewOnState(this._formState);
84
+ (this._visible !== newVisible) && this.setVisibility(newVisible);
85
+ }
86
+
87
+ override viewOnState(state: string): boolean {
88
+ const actionVisible = (this.visibleStates && state) ? this.visibleStates.includes(state) : false;
89
+ if (actionVisible && this._form && this._restrictedOnField) {
90
+ const relatedField = this._form.fields?.[this._restrictedOnField];
91
+ if (relatedField) {
92
+ const fieldValue = relatedField.value;
93
+ if ((this._restrictedOnOperator === '==' && fieldValue !== this._restrictedOnValue)
94
+ || (this._restrictedOnOperator === '!=' && fieldValue === this._restrictedOnValue)) {
95
+ return false;
96
+ }
97
+ }
98
+ }
99
+ return actionVisible;
100
+ }
101
+
102
+ get actionActivated() { return this._actionActivated.asObservable(); }
103
+
104
+ notifyActivation() { this._actionActivated.next(this._actionCode); }
105
+
106
+ updateFromServer(receivedAction) {
107
+ for (const propertyName in receivedAction) {
108
+ if (propertyName !== 'actionCode' && propertyName !== 'actionId') {
109
+ try {
110
+ this[propertyName] = receivedAction[propertyName];
111
+ } catch (e) {
112
+ console.log(`Error actualizando la propiedad ${propertyName} de la acción ${this.actionCode}. ${e}`);
113
+ }
114
+ }
115
+ }
116
+ }
117
+ }
@@ -0,0 +1,26 @@
1
+ import { FormPiecePropagate } from './piece-propagate';
2
+ import { elementTypes } from './form.constants';
3
+ export class FormElement extends FormPiecePropagate {
4
+ elementType: string | null = null;
5
+
6
+ constructor(elementDefinition: any, formConfig: any) {
7
+ super(elementDefinition, formConfig);
8
+ }
9
+
10
+ setAttr(attr: any, value: any) {
11
+ const { name: attrName, propagate: name } = attr;
12
+ try {
13
+ const currentValue = this[attrName];
14
+ if (currentValue !== value) {
15
+ this[attrName] = value;
16
+ name && this.propagateAttribute(name, value);
17
+ }
18
+ } catch (e) {
19
+ console.log(`Atributo ${attrName} no presente o valor ${value} inconsistente. ${e}`);
20
+ }
21
+ }
22
+
23
+ isField(): boolean { return this.elementType === elementTypes.field; }
24
+ isAction(): boolean { return this.elementType === elementTypes.action; }
25
+ isTable(): boolean { return this.elementType === elementTypes.table; }
26
+ }