@rxap/schematic-angular 16.2.0-dev.20 → 16.2.0-dev.21

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 (179) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +1 -1
  3. package/collection.json +10 -0
  4. package/package.json +4 -4
  5. package/src/lib/coerce-form-component.js +15 -3
  6. package/src/lib/coerce-form-component.js.map +1 -1
  7. package/src/lib/data-grid-item.d.ts +3 -3
  8. package/src/lib/data-grid-item.js +2 -2
  9. package/src/lib/data-grid-item.js.map +1 -1
  10. package/src/lib/form/abstract-control.d.ts +29 -0
  11. package/src/lib/form/abstract-control.js +37 -0
  12. package/src/lib/form/abstract-control.js.map +1 -0
  13. package/src/lib/form/array/base-form-array.d.ts +18 -0
  14. package/src/lib/form/array/base-form-array.js +40 -0
  15. package/src/lib/form/array/base-form-array.js.map +1 -0
  16. package/src/lib/form/array/form-array-kind.d.ts +3 -0
  17. package/src/lib/form/array/form-array-kind.js +8 -0
  18. package/src/lib/form/array/form-array-kind.js.map +1 -0
  19. package/src/lib/form/array/form-array.d.ts +12 -0
  20. package/src/lib/form/array/form-array.js +18 -0
  21. package/src/lib/form/array/form-array.js.map +1 -0
  22. package/src/lib/form/coerce-control-component-imports.d.ts +3 -0
  23. package/src/lib/form/coerce-control-component-imports.js +18 -0
  24. package/src/lib/form/coerce-control-component-imports.js.map +1 -0
  25. package/src/lib/form/control/base-form-control.d.ts +14 -0
  26. package/src/lib/form/control/base-form-control.js +19 -0
  27. package/src/lib/form/control/base-form-control.js.map +1 -0
  28. package/src/lib/form/control/checkbox-form-control.d.ts +11 -0
  29. package/src/lib/form/control/checkbox-form-control.js +23 -0
  30. package/src/lib/form/control/checkbox-form-control.js.map +1 -0
  31. package/src/lib/form/control/form-control-kind.d.ts +8 -0
  32. package/src/lib/form/control/form-control-kind.js +13 -0
  33. package/src/lib/form/control/form-control-kind.js.map +1 -0
  34. package/src/lib/form/control/form-control.d.ts +18 -0
  35. package/src/lib/form/control/form-control.js +40 -0
  36. package/src/lib/form/control/form-control.js.map +1 -0
  37. package/src/lib/form/control/form-field-form-control.d.ts +33 -0
  38. package/src/lib/form/control/form-field-form-control.js +76 -0
  39. package/src/lib/form/control/form-field-form-control.js.map +1 -0
  40. package/src/lib/form/control/input-form-control.d.ts +14 -0
  41. package/src/lib/form/control/input-form-control.js +71 -0
  42. package/src/lib/form/control/input-form-control.js.map +1 -0
  43. package/src/lib/form/control/select-form-control.d.ts +18 -0
  44. package/src/lib/form/control/select-form-control.js +29 -0
  45. package/src/lib/form/control/select-form-control.js.map +1 -0
  46. package/src/lib/form/control/slide-toggle-form-control.d.ts +11 -0
  47. package/src/lib/form/control/slide-toggle-form-control.js +23 -0
  48. package/src/lib/form/control/slide-toggle-form-control.js.map +1 -0
  49. package/src/lib/form/control/table-select-form-control.d.ts +43 -0
  50. package/src/lib/form/control/table-select-form-control.js +69 -0
  51. package/src/lib/form/control/table-select-form-control.js.map +1 -0
  52. package/src/lib/form/control.d.ts +8 -0
  53. package/src/lib/form/control.js +38 -0
  54. package/src/lib/form/control.js.map +1 -0
  55. package/src/lib/form/generate-form-template.d.ts +2 -2
  56. package/src/lib/form/group/base-form-group.d.ts +17 -0
  57. package/src/lib/form/group/base-form-group.js +20 -0
  58. package/src/lib/form/group/base-form-group.js.map +1 -0
  59. package/src/lib/form/group/form-group-kind.d.ts +3 -0
  60. package/src/lib/form/group/form-group-kind.js +8 -0
  61. package/src/lib/form/group/form-group-kind.js.map +1 -0
  62. package/src/lib/form/group/form-group.d.ts +12 -0
  63. package/src/lib/form/group/form-group.js +18 -0
  64. package/src/lib/form/group/form-group.js.map +1 -0
  65. package/src/lib/table-column.d.ts +4 -3
  66. package/src/lib/table-column.js +5 -4
  67. package/src/lib/table-column.js.map +1 -1
  68. package/src/schema.json +1673 -1415
  69. package/src/schematic-input.schema.json +90 -156
  70. package/src/schematics/abstract-control.schema.json +78 -0
  71. package/src/schematics/accordion/accordion-component/schema.json +127 -127
  72. package/src/schematics/accordion/accordion-item-component/schema.json +18 -18
  73. package/src/schematics/accordion/item/accordion-item-data-grid-component/schema.json +602 -81
  74. package/src/schematics/accordion/item/accordion-item-switch-component/schema.json +76 -76
  75. package/src/schematics/accordion/item/accordion-item-table-component/schema.json +486 -111
  76. package/src/schematics/accordion/item/accordion-item-tree-table-component/schema.json +458 -83
  77. package/src/schematics/base-form-array.schema.json +45 -0
  78. package/src/schematics/base-form-control.schema.json +27 -0
  79. package/src/schematics/base-form-group.schema.json +42 -0
  80. package/src/schematics/checkbox-form-control.schema.json +30 -0
  81. package/src/schematics/control.schema.json +26 -0
  82. package/src/schematics/data-grid-component/index.js +4 -0
  83. package/src/schematics/data-grid-component/index.js.map +1 -1
  84. package/src/schematics/data-grid-component/schema.json +602 -81
  85. package/src/schematics/data-grid-item.schema.json +3 -3
  86. package/src/schematics/form/control/input-form-control/index.d.ts +1 -1
  87. package/src/schematics/form/control/input-form-control/index.js +4 -4
  88. package/src/schematics/form/control/input-form-control/index.js.map +1 -1
  89. package/src/schematics/form/control/input-form-control/schema.d.ts +2 -2
  90. package/src/schematics/form/control/input-form-control/schema.json +256 -86
  91. package/src/schematics/form/control/input-form-control/template.schema.json +16 -3
  92. package/src/schematics/form/control/select-form-control/index.d.ts +2 -2
  93. package/src/schematics/form/control/select-form-control/index.js +21 -14
  94. package/src/schematics/form/control/select-form-control/index.js.map +1 -1
  95. package/src/schematics/form/control/select-form-control/schema.d.ts +2 -3
  96. package/src/schematics/form/control/select-form-control/schema.json +249 -90
  97. package/src/schematics/form/control/select-form-control/template.schema.json +16 -3
  98. package/src/schematics/form/control/table-select-form-control/index.d.ts +3 -9
  99. package/src/schematics/form/control/table-select-form-control/index.js +24 -18
  100. package/src/schematics/form/control/table-select-form-control/index.js.map +1 -1
  101. package/src/schematics/form/control/table-select-form-control/schema.d.ts +2 -3
  102. package/src/schematics/form/control/table-select-form-control/schema.json +325 -123
  103. package/src/schematics/form/control/table-select-form-control/template.schema.json +16 -60
  104. package/src/schematics/form/form-array/index.d.ts +9 -0
  105. package/src/schematics/form/form-array/index.js +54 -0
  106. package/src/schematics/form/form-array/index.js.map +1 -0
  107. package/src/schematics/form/form-array/schema.d.ts +4 -0
  108. package/src/schematics/form/form-array/schema.json +823 -0
  109. package/src/schematics/form/form-array/template.schema.json +33 -0
  110. package/src/schematics/form/form-component/files/component/__componentName__.component.html.hbs +4 -1
  111. package/src/schematics/form/form-component/index.d.ts +2 -4
  112. package/src/schematics/form/form-component/index.js +8 -24
  113. package/src/schematics/form/form-component/index.js.map +1 -1
  114. package/src/schematics/form/form-component/schema.d.ts +2 -2
  115. package/src/schematics/form/form-component/schema.json +666 -86
  116. package/src/schematics/form/form-control/index.d.ts +3 -5
  117. package/src/schematics/form/form-control/index.js +8 -20
  118. package/src/schematics/form/form-control/index.js.map +1 -1
  119. package/src/schematics/form/form-control/schema.d.ts +2 -4
  120. package/src/schematics/form/form-control/schema.json +519 -62
  121. package/src/schematics/form/form-control/template.schema.json +1 -2
  122. package/src/schematics/form/form-definition/index.d.ts +2 -2
  123. package/src/schematics/form/form-definition/index.js +28 -15
  124. package/src/schematics/form/form-definition/index.js.map +1 -1
  125. package/src/schematics/form/form-definition/schema.d.ts +2 -2
  126. package/src/schematics/form/form-definition/schema.json +664 -60
  127. package/src/schematics/form/form-group/index.d.ts +9 -0
  128. package/src/schematics/form/form-group/index.js +54 -0
  129. package/src/schematics/form/form-group/index.js.map +1 -0
  130. package/src/schematics/form/form-group/schema.d.ts +4 -0
  131. package/src/schematics/form/form-group/schema.json +823 -0
  132. package/src/schematics/form/form-group/template.schema.json +33 -0
  133. package/src/schematics/form/templates/checkbox-form-control.hbs +1 -1
  134. package/src/schematics/form/templates/default-form-array.hbs +27 -0
  135. package/src/schematics/form/templates/default-form-group.hbs +13 -0
  136. package/src/schematics/form/templates/input-form-control.hbs +7 -7
  137. package/src/schematics/form/templates/select-form-control.hbs +5 -0
  138. package/src/schematics/form/templates/table-select-form-control.hbs +16 -16
  139. package/src/schematics/form-array.schema.json +40 -0
  140. package/src/schematics/form-control.schema.json +64 -55
  141. package/src/schematics/form-definition.schema.json +3 -3
  142. package/src/schematics/form-group.schema.json +40 -0
  143. package/src/schematics/input-form-control.schema.json +10 -6
  144. package/src/schematics/select-form-control.schema.json +8 -4
  145. package/src/schematics/slide-toggle-form-control.schema.json +30 -0
  146. package/src/schematics/table/action/dialog-table-action/schema.json +20 -20
  147. package/src/schematics/table/action/form-table-action/index.d.ts +2 -2
  148. package/src/schematics/table/action/form-table-action/index.js +3 -4
  149. package/src/schematics/table/action/form-table-action/index.js.map +1 -1
  150. package/src/schematics/table/action/form-table-action/schema.d.ts +2 -2
  151. package/src/schematics/table/action/form-table-action/schema.json +667 -87
  152. package/src/schematics/table/action/navigation-table-action/schema.json +20 -20
  153. package/src/schematics/table/action/open-api-table-action/schema.json +20 -20
  154. package/src/schematics/table/action/operation-table-action/schema.json +20 -20
  155. package/src/schematics/table/header-button/form-table-header-button/index.d.ts +2 -2
  156. package/src/schematics/table/header-button/form-table-header-button/index.js +2 -2
  157. package/src/schematics/table/header-button/form-table-header-button/index.js.map +1 -1
  158. package/src/schematics/table/header-button/form-table-header-button/schema.d.ts +2 -2
  159. package/src/schematics/table/header-button/form-table-header-button/schema.json +735 -81
  160. package/src/schematics/table/header-button/form-table-header-button/template.schema.json +4 -22
  161. package/src/schematics/table/header-button/navigation-table-header-button/schema.json +20 -20
  162. package/src/schematics/table/table-action/schema.json +47 -47
  163. package/src/schematics/table/table-component/index.d.ts +2 -2
  164. package/src/schematics/table/table-component/schema.json +470 -95
  165. package/src/schematics/table/table-header-button/schema.json +40 -40
  166. package/src/schematics/table/tree-table-component/files/component/__componentName__.component.html.hbs +1 -1
  167. package/src/schematics/table/tree-table-component/schema.json +453 -78
  168. package/src/schematics/table-select-form-control.schema.json +96 -0
  169. package/src/schematics/textarea-form-control.schema.json +32 -0
  170. package/src/template.schema.json +39 -0
  171. package/src/lib/form-component-control.d.ts +0 -8
  172. package/src/lib/form-component-control.js +0 -15
  173. package/src/lib/form-component-control.js.map +0 -1
  174. package/src/lib/form-control.d.ts +0 -136
  175. package/src/lib/form-control.js +0 -265
  176. package/src/lib/form-control.js.map +0 -1
  177. package/src/lib/form-definition-control.d.ts +0 -5
  178. package/src/lib/form-definition-control.js +0 -30
  179. package/src/lib/form-definition-control.js.map +0 -1
@@ -0,0 +1,96 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "$id": "table-select-form-control",
4
+ "allOf": [
5
+ {
6
+ "$ref": "#/definitions/baseFormControl"
7
+ },
8
+ {
9
+ "type": "object",
10
+ "properties": {
11
+ "formField": {
12
+ "$ref": "#/definitions/formField"
13
+ },
14
+ "kind": {
15
+ "type": "string",
16
+ "const": "table-select"
17
+ },
18
+ "placeholder": {
19
+ "type": "string"
20
+ },
21
+ "columnList": {
22
+ "alias": "column",
23
+ "type": "array",
24
+ "items": {
25
+ "description": "table column name",
26
+ "type": "object",
27
+ "properties": {
28
+ "name": {
29
+ "type": "string",
30
+ "description": "table column name"
31
+ },
32
+ "title": {
33
+ "type": "string",
34
+ "description": "table column label"
35
+ },
36
+ "hasFilter": {
37
+ "type": "boolean",
38
+ "description": "Whether the column has a filter"
39
+ },
40
+ "kind": {
41
+ "type": "string",
42
+ "description": "The kind of data in the column"
43
+ }
44
+ }
45
+ },
46
+ "description": "List of table column names"
47
+ },
48
+ "title": {
49
+ "type": "string",
50
+ "description": "The title of the table select window"
51
+ },
52
+ "toDisplay": {
53
+ "type": "object",
54
+ "properties": {
55
+ "property": {
56
+ "$ref": "#/definitions/property"
57
+ }
58
+ }
59
+ },
60
+ "toValue": {
61
+ "type": "object",
62
+ "properties": {
63
+ "property": {
64
+ "$ref": "#/definitions/property"
65
+ }
66
+ }
67
+ },
68
+ "upstream": {
69
+ "$ref": "#/definitions/upstream"
70
+ },
71
+ "resolver": {
72
+ "type": "object",
73
+ "properties": {
74
+ "upstream": {
75
+ "$ref": "#/definitions/upstream"
76
+ }
77
+ }
78
+ }
79
+ }
80
+ }
81
+ ],
82
+ "definitions": {
83
+ "property": {
84
+ "$ref": "./property.schema.json"
85
+ },
86
+ "upstream": {
87
+ "$ref": "./upstream.schema.json"
88
+ },
89
+ "formField": {
90
+ "$ref": "./form-field.schema.json"
91
+ },
92
+ "baseFormControl": {
93
+ "$ref": "./base-form-control.schema.json"
94
+ }
95
+ }
96
+ }
@@ -0,0 +1,32 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "$id": "textarea-form-control",
4
+ "allOf": [
5
+ {
6
+ "$ref": "#/definitions/baseFormControl"
7
+ },
8
+ {
9
+ "type": "object",
10
+ "properties": {
11
+ "formField": {
12
+ "$ref": "#/definitions/formField"
13
+ },
14
+ "kind": {
15
+ "type": "string",
16
+ "const": "textarea"
17
+ },
18
+ "placeholder": {
19
+ "type": "string"
20
+ }
21
+ }
22
+ }
23
+ ],
24
+ "definitions": {
25
+ "formField": {
26
+ "$ref": "./form-field.schema.json"
27
+ },
28
+ "baseFormControl": {
29
+ "$ref": "./base-form-control.schema.json"
30
+ }
31
+ }
32
+ }
@@ -67,6 +67,12 @@
67
67
  "formControlSchematic": {
68
68
  "$ref": "schematics/form/form-control/template.schema.json"
69
69
  },
70
+ "formGroupSchematic": {
71
+ "$ref": "schematics/form/form-group/template.schema.json"
72
+ },
73
+ "formArraySchematic": {
74
+ "$ref": "schematics/form/form-array/template.schema.json"
75
+ },
70
76
  "dialogTableActionSchematic": {
71
77
  "$ref": "schematics/table/action/dialog-table-action/template.schema.json"
72
78
  },
@@ -91,6 +97,9 @@
91
97
  "accordionItemTreeTableComponentSchematic": {
92
98
  "$ref": "schematics/accordion/item/accordion-item-tree-table-component/template.schema.json"
93
99
  },
100
+ "abstractControl": {
101
+ "$ref": "schematics/abstract-control.schema.json"
102
+ },
94
103
  "accordionIdentifier": {
95
104
  "$ref": "schematics/accordion-identifier.schema.json"
96
105
  },
@@ -103,15 +112,33 @@
103
112
  "backend": {
104
113
  "$ref": "schematics/backend.schema.json"
105
114
  },
115
+ "baseFormArray": {
116
+ "$ref": "schematics/base-form-array.schema.json"
117
+ },
118
+ "baseFormControl": {
119
+ "$ref": "schematics/base-form-control.schema.json"
120
+ },
121
+ "baseFormGroup": {
122
+ "$ref": "schematics/base-form-group.schema.json"
123
+ },
106
124
  "button": {
107
125
  "$ref": "schematics/button.schema.json"
108
126
  },
127
+ "checkboxFormControl": {
128
+ "$ref": "schematics/checkbox-form-control.schema.json"
129
+ },
130
+ "control": {
131
+ "$ref": "schematics/control.schema.json"
132
+ },
109
133
  "dataGridItem": {
110
134
  "$ref": "schematics/data-grid-item.schema.json"
111
135
  },
112
136
  "dataGrid": {
113
137
  "$ref": "schematics/data-grid.schema.json"
114
138
  },
139
+ "formArray": {
140
+ "$ref": "schematics/form-array.schema.json"
141
+ },
115
142
  "formComponent": {
116
143
  "$ref": "schematics/form-component.schema.json"
117
144
  },
@@ -124,6 +151,9 @@
124
151
  "formField": {
125
152
  "$ref": "schematics/form-field.schema.json"
126
153
  },
154
+ "formGroup": {
155
+ "$ref": "schematics/form-group.schema.json"
156
+ },
127
157
  "general": {
128
158
  "$ref": "schematics/general.schema.json"
129
159
  },
@@ -145,15 +175,24 @@
145
175
  "selectFormControl": {
146
176
  "$ref": "schematics/select-form-control.schema.json"
147
177
  },
178
+ "slideToggleFormControl": {
179
+ "$ref": "schematics/slide-toggle-form-control.schema.json"
180
+ },
148
181
  "tableAction": {
149
182
  "$ref": "schematics/table-action.schema.json"
150
183
  },
151
184
  "tableColumn": {
152
185
  "$ref": "schematics/table-column.schema.json"
153
186
  },
187
+ "tableSelectFormControl": {
188
+ "$ref": "schematics/table-select-form-control.schema.json"
189
+ },
154
190
  "table": {
155
191
  "$ref": "schematics/table.schema.json"
156
192
  },
193
+ "textareaFormControl": {
194
+ "$ref": "schematics/textarea-form-control.schema.json"
195
+ },
157
196
  "treeTable": {
158
197
  "$ref": "schematics/tree-table.schema.json"
159
198
  },
@@ -1,8 +0,0 @@
1
- import { Normalized } from '@rxap/utilities';
2
- import { FormDefinitionControl, NormalizedFormDefinitionControl } from './form-definition-control';
3
- export interface FormComponentControl extends FormDefinitionControl {
4
- }
5
- export interface NormalizedFormComponentControl extends Omit<Readonly<Normalized<FormComponentControl>>, 'type' | 'importList'>, NormalizedFormDefinitionControl {
6
- }
7
- export declare function NormalizeFormComponentControl(control: FormComponentControl): NormalizedFormComponentControl;
8
- export declare function NormalizeFormComponentControlList(controlList?: Array<FormComponentControl>): ReadonlyArray<NormalizedFormComponentControl>;
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NormalizeFormComponentControlList = exports.NormalizeFormComponentControl = void 0;
4
- const form_definition_control_1 = require("./form-definition-control");
5
- function NormalizeFormComponentControl(control) {
6
- const normalizedControl = (0, form_definition_control_1.NormalizeFormDefinitionControl)(control);
7
- return Object.freeze(Object.assign({}, normalizedControl));
8
- }
9
- exports.NormalizeFormComponentControl = NormalizeFormComponentControl;
10
- function NormalizeFormComponentControlList(controlList) {
11
- var _a;
12
- return Object.freeze((_a = controlList === null || controlList === void 0 ? void 0 : controlList.map(NormalizeFormComponentControl)) !== null && _a !== void 0 ? _a : []);
13
- }
14
- exports.NormalizeFormComponentControlList = NormalizeFormComponentControlList;
15
- //# sourceMappingURL=form-component-control.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"form-component-control.js","sourceRoot":"","sources":["../../../../../../packages/schematic/angular/src/lib/form-component-control.ts"],"names":[],"mappings":";;;AAEA,uEAImC;AAanC,SAAgB,6BAA6B,CAC3C,OAA6B;IAE7B,MAAM,iBAAiB,GAAG,IAAA,wDAA8B,EAAC,OAAO,CAAC,CAAC;IAClE,OAAO,MAAM,CAAC,MAAM,mBACf,iBAAiB,EACpB,CAAC;AACL,CAAC;AAPD,sEAOC;AAED,SAAgB,iCAAiC,CAC/C,WAAyC;;IAEzC,OAAO,MAAM,CAAC,MAAM,CAAC,MAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,GAAG,CAAC,6BAA6B,CAAC,mCAAI,EAAE,CAAC,CAAC;AAC9E,CAAC;AAJD,8EAIC"}
@@ -1,136 +0,0 @@
1
- import { DataProperty, NormalizedDataProperty, NormalizedTypeImport, NormalizedUpstreamOptions, TypeImport, UpstreamOptions } from '@rxap/ts-morph';
2
- import { ControlOption, Normalized } from '@rxap/utilities';
3
- import Handlebars from 'handlebars';
4
- import { BackendTypes } from './backend-types';
5
- import { NormalizedTableColumn, TableColumn } from './table-column';
6
- export declare enum FormControlKinds {
7
- DEFAULT = "default",
8
- INPUT = "input",
9
- SELECT = "select",
10
- CHECKBOX = "checkbox",
11
- SLIDE_TOGGLE = "slide-toggle",
12
- TABLE_SELECT = "table-select"
13
- }
14
- export interface BaseFormControl extends DataProperty {
15
- state?: string;
16
- isRequired?: boolean;
17
- isReadonly?: boolean;
18
- isDisabled?: boolean;
19
- validatorList?: string[];
20
- importList?: TypeImport[];
21
- kind: FormControlKinds;
22
- template?: string;
23
- label?: string;
24
- }
25
- export interface NormalizedBaseFormControl extends Readonly<Normalized<BaseFormControl> & NormalizedDataProperty> {
26
- type: NormalizedTypeImport;
27
- importList: NormalizedTypeImport[];
28
- handlebars: Handlebars.TemplateDelegate<{
29
- control: NormalizedBaseFormControl;
30
- }>;
31
- }
32
- export declare function NormalizeBaseFormControl(control: BaseFormControl): NormalizedBaseFormControl;
33
- export interface FormFieldButton {
34
- svgIcon?: string;
35
- icon?: string;
36
- directiveList?: TypeImport[];
37
- importList?: TypeImport[];
38
- }
39
- export interface FormField {
40
- label?: string;
41
- prefixButton?: FormFieldButton;
42
- suffixButton?: FormFieldButton;
43
- directiveList?: TypeImport[];
44
- hasClearButton?: boolean;
45
- }
46
- export type NormalizedFormField = Readonly<Normalized<FormField>>;
47
- export interface NormalizedFormFieldButton extends Readonly<Normalized<FormFieldButton>> {
48
- directiveList: NormalizedTypeImport[];
49
- importList: NormalizedTypeImport[];
50
- }
51
- export declare function NormalizeFormFieldButton(button?: FormFieldButton | null): NormalizedFormFieldButton | null;
52
- export declare function NormalizeFormField(formField: FormField, importList?: TypeImport[], defaultFormField?: Partial<FormField>): NormalizedFormField;
53
- export interface FormFieldFormControl extends BaseFormControl {
54
- formField?: FormField;
55
- }
56
- export interface NormalizedFormFieldFormControl extends Readonly<Normalized<Omit<FormFieldFormControl, 'type' | 'importList'>>>, NormalizedBaseFormControl {
57
- formField: NormalizedFormField;
58
- }
59
- export declare function IsFormFieldFormControl(control: BaseFormControl): control is FormFieldFormControl;
60
- export declare function IsNormalizedFormFieldFormControl(control: NormalizedBaseFormControl): control is NormalizedFormFieldFormControl;
61
- export interface InputFormControl extends BaseFormControl, FormFieldFormControl {
62
- inputType?: string;
63
- placeholder?: string;
64
- formField?: FormField;
65
- }
66
- export interface NormalizedInputFormControl extends Omit<Readonly<Normalized<InputFormControl>>, 'type' | 'importList' | 'formField'>, NormalizedBaseFormControl, NormalizedFormFieldFormControl {
67
- kind: FormControlKinds.INPUT;
68
- }
69
- export declare function IsNormalizedInputFormControlOptions(template: NormalizedBaseFormControl): template is NormalizedInputFormControl;
70
- export declare function NormalizeInputFormControl(control: InputFormControl): NormalizedInputFormControl;
71
- export interface SelectFormControl extends BaseFormControl, FormFieldFormControl {
72
- options?: ControlOption[];
73
- backend?: BackendTypes;
74
- multiple?: boolean;
75
- formField?: FormField;
76
- }
77
- export interface NormalizedSelectFormControl extends Readonly<Normalized<Omit<SelectFormControl, 'options' | 'type' | 'importList' | 'formField'>>>, NormalizedBaseFormControl, NormalizedFormFieldFormControl {
78
- kind: FormControlKinds.SELECT;
79
- options: ReadonlyArray<ControlOption> | null;
80
- backend: BackendTypes;
81
- }
82
- export declare function IsNormalizedSelectFormControl(template: NormalizedBaseFormControl): template is NormalizedSelectFormControl;
83
- export declare function NormalizeSelectFormControl(control: SelectFormControl): NormalizedSelectFormControl;
84
- export interface CheckboxFormControl extends BaseFormControl {
85
- labelPosition?: 'before' | 'after';
86
- }
87
- export interface NormalizedCheckboxFormControl extends Readonly<Normalized<Omit<CheckboxFormControl, 'type' | 'importList'>>>, NormalizedBaseFormControl {
88
- kind: FormControlKinds.CHECKBOX;
89
- }
90
- export declare function IsNormalizedCheckboxFormControl(template: NormalizedBaseFormControl): template is NormalizedCheckboxFormControl;
91
- export declare function NormalizeCheckboxFormControl(control: CheckboxFormControl): NormalizedCheckboxFormControl;
92
- export interface SlideToggleFormControl extends BaseFormControl {
93
- labelPosition?: 'before' | 'after';
94
- }
95
- export interface NormalizedSlideToggleFormControl extends Readonly<Normalized<Omit<SlideToggleFormControl, 'type' | 'importList'>>>, NormalizedBaseFormControl {
96
- kind: FormControlKinds.CHECKBOX;
97
- }
98
- export declare function IsNormalizedSlideToggleFormControl(template: NormalizedBaseFormControl): template is NormalizedSlideToggleFormControl;
99
- export declare function NormalizeSlideToggleFormControl(control: SlideToggleFormControl): NormalizedSlideToggleFormControl;
100
- export type TableSelectColumn = Pick<TableColumn, 'name' | 'title' | 'hasFilter' | 'kind' | 'propertyPath'> & DataProperty;
101
- export type NormalizedTableSelectColumn = Pick<NormalizedTableColumn, 'name' | 'title' | 'hasFilter' | 'kind' | 'propertyPath'> & NormalizedDataProperty;
102
- export declare function NormalizeTableSelectColumn(column: TableSelectColumn): NormalizedTableSelectColumn;
103
- export interface TableSelectToFunction {
104
- property: DataProperty;
105
- }
106
- export interface NormalizedTableSelectToFunction extends Readonly<Normalized<TableSelectToFunction>> {
107
- property: NormalizedDataProperty;
108
- }
109
- export declare function NormalizeTableSelectToFunction(toFunction: TableSelectToFunction | null | undefined, columnList: TableSelectColumn[], defaultType?: string): NormalizedTableSelectToFunction;
110
- export interface TableSelectFormControl extends BaseFormControl, FormFieldFormControl {
111
- backend?: BackendTypes;
112
- formField?: FormField;
113
- title?: string;
114
- propertyList?: DataProperty[];
115
- columnList?: TableSelectColumn[];
116
- toDisplay?: TableSelectToFunction;
117
- toValue?: TableSelectToFunction;
118
- upstream?: UpstreamOptions;
119
- resolver?: {
120
- upstream?: UpstreamOptions;
121
- };
122
- }
123
- export interface NormalizedTableSelectFormControl extends Readonly<Normalized<Omit<TableSelectFormControl, 'type' | 'importList' | 'columnList' | 'propertyList' | 'formField'>>>, NormalizedBaseFormControl, NormalizedFormFieldFormControl {
124
- kind: FormControlKinds.TABLE_SELECT;
125
- backend: BackendTypes;
126
- columnList: NormalizedTableSelectColumn[];
127
- propertyList: Array<NormalizedDataProperty>;
128
- toDisplay: NormalizedTableSelectToFunction;
129
- toValue: NormalizedTableSelectToFunction;
130
- upstream: NormalizedUpstreamOptions | null;
131
- resolver: {
132
- upstream: NormalizedUpstreamOptions | null;
133
- } | null;
134
- }
135
- export declare function IsNormalizedTableSelectFormControl(template: NormalizedBaseFormControl): template is NormalizedTableSelectFormControl;
136
- export declare function NormalizeTableSelectFormControl(control: TableSelectFormControl): NormalizedTableSelectFormControl;
@@ -1,265 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NormalizeTableSelectFormControl = exports.IsNormalizedTableSelectFormControl = exports.NormalizeTableSelectToFunction = exports.NormalizeTableSelectColumn = exports.NormalizeSlideToggleFormControl = exports.IsNormalizedSlideToggleFormControl = exports.NormalizeCheckboxFormControl = exports.IsNormalizedCheckboxFormControl = exports.NormalizeSelectFormControl = exports.IsNormalizedSelectFormControl = exports.NormalizeInputFormControl = exports.IsNormalizedInputFormControlOptions = exports.IsNormalizedFormFieldFormControl = exports.IsFormFieldFormControl = exports.NormalizeFormField = exports.NormalizeFormFieldButton = exports.NormalizeBaseFormControl = exports.FormControlKinds = void 0;
4
- const schematics_1 = require("@angular-devkit/schematics");
5
- const ts_morph_1 = require("@rxap/ts-morph");
6
- const utilities_1 = require("@rxap/utilities");
7
- const path_1 = require("path");
8
- const backend_types_1 = require("./backend-types");
9
- const load_handlebars_template_1 = require("./load-handlebars-template");
10
- const table_column_1 = require("./table-column");
11
- // region BaseFormControlOptions
12
- var FormControlKinds;
13
- (function (FormControlKinds) {
14
- FormControlKinds["DEFAULT"] = "default";
15
- FormControlKinds["INPUT"] = "input";
16
- FormControlKinds["SELECT"] = "select";
17
- FormControlKinds["CHECKBOX"] = "checkbox";
18
- FormControlKinds["SLIDE_TOGGLE"] = "slide-toggle";
19
- FormControlKinds["TABLE_SELECT"] = "table-select";
20
- })(FormControlKinds || (exports.FormControlKinds = FormControlKinds = {}));
21
- function NormalizeBaseFormControl(control) {
22
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
23
- if (!control.name) {
24
- throw new schematics_1.SchematicsException('The control name is required');
25
- }
26
- const state = (_a = control.state) !== null && _a !== void 0 ? _a : null;
27
- const isRequired = (_b = control.isRequired) !== null && _b !== void 0 ? _b : false;
28
- const validatorList = (_c = control.validatorList) !== null && _c !== void 0 ? _c : [];
29
- const importList = ((_d = control.importList) !== null && _d !== void 0 ? _d : []);
30
- const isReadonly = (_e = control.isReadonly) !== null && _e !== void 0 ? _e : false;
31
- const isDisabled = (_f = control.isDisabled) !== null && _f !== void 0 ? _f : false;
32
- const kind = (_g = control.kind) !== null && _g !== void 0 ? _g : FormControlKinds.DEFAULT;
33
- const template = (_h = control.template) !== null && _h !== void 0 ? _h : kind + '-form-control.hbs';
34
- return Object.freeze(Object.assign(Object.assign({}, (0, ts_morph_1.NormalizeDataProperty)(control)), { isRequired,
35
- state,
36
- isReadonly,
37
- isDisabled,
38
- validatorList, importList: (0, ts_morph_1.NormalizeTypeImportList)(importList), kind,
39
- template, handlebars: (0, load_handlebars_template_1.LoadHandlebarsTemplate)(template, (0, path_1.join)(__dirname, '..', 'schematics', 'form', 'templates')), label: (_j = control.label) !== null && _j !== void 0 ? _j : null }));
40
- }
41
- exports.NormalizeBaseFormControl = NormalizeBaseFormControl;
42
- function NormalizeFormFieldButton(button) {
43
- var _a, _b, _c;
44
- if ((!button || Object.keys(button).length === 0)) {
45
- return null;
46
- }
47
- const importList = (_a = button.importList) !== null && _a !== void 0 ? _a : [];
48
- (0, utilities_1.CoerceArrayItems)(importList, [
49
- {
50
- name: 'MatIconModule',
51
- moduleSpecifier: '@angular/material/icon',
52
- },
53
- {
54
- name: 'MatButtonModule',
55
- moduleSpecifier: '@angular/material/button',
56
- }
57
- ], (a, b) => a.name === b.name);
58
- return Object.freeze({
59
- svgIcon: (_b = button.svgIcon) !== null && _b !== void 0 ? _b : null,
60
- icon: (_c = button.icon) !== null && _c !== void 0 ? _c : null,
61
- directiveList: (0, ts_morph_1.NormalizeTypeImportList)(button.directiveList),
62
- importList: (0, ts_morph_1.NormalizeTypeImportList)(importList),
63
- });
64
- }
65
- exports.NormalizeFormFieldButton = NormalizeFormFieldButton;
66
- function NormalizeFormField(formField, importList = [], defaultFormField = {}) {
67
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
68
- defaultFormField = (0, utilities_1.DeleteEmptyProperties)(defaultFormField);
69
- const directiveList = (_a = defaultFormField.directiveList) !== null && _a !== void 0 ? _a : [];
70
- (0, utilities_1.CoerceArrayItems)(directiveList, (_b = defaultFormField.directiveList) !== null && _b !== void 0 ? _b : [], (a, b) => a.name === b.name);
71
- const normalizedFormField = {
72
- label: (_d = (_c = defaultFormField.label) !== null && _c !== void 0 ? _c : formField.label) !== null && _d !== void 0 ? _d : null,
73
- prefixButton: NormalizeFormFieldButton((_e = formField.prefixButton) !== null && _e !== void 0 ? _e : defaultFormField.prefixButton),
74
- suffixButton: NormalizeFormFieldButton((_f = formField.suffixButton) !== null && _f !== void 0 ? _f : defaultFormField.suffixButton),
75
- hasClearButton: (_h = (_g = formField.hasClearButton) !== null && _g !== void 0 ? _g : defaultFormField.hasClearButton) !== null && _h !== void 0 ? _h : true,
76
- directiveList: (0, ts_morph_1.NormalizeTypeImportList)(directiveList),
77
- };
78
- if (normalizedFormField.hasClearButton) {
79
- (_j = normalizedFormField.suffixButton) !== null && _j !== void 0 ? _j : (normalizedFormField.suffixButton = NormalizeFormFieldButton({
80
- icon: 'clear',
81
- directiveList: [
82
- {
83
- name: 'rxapInputClearButton',
84
- namedImport: 'InputClearButtonDirective',
85
- moduleSpecifier: '@rxap/material-form-system',
86
- },
87
- ],
88
- }));
89
- }
90
- (0, utilities_1.CoerceArrayItems)(importList, (_l = (_k = normalizedFormField.prefixButton) === null || _k === void 0 ? void 0 : _k.importList) !== null && _l !== void 0 ? _l : [], (a, b) => a.name === b.name && a.namedImport === b.namedImport);
91
- (0, utilities_1.CoerceArrayItems)(importList, (_o = (_m = normalizedFormField.suffixButton) === null || _m === void 0 ? void 0 : _m.importList) !== null && _o !== void 0 ? _o : [], (a, b) => a.name === b.name && a.namedImport === b.namedImport);
92
- (0, utilities_1.CoerceArrayItems)(importList, (_q = (_p = normalizedFormField.prefixButton) === null || _p === void 0 ? void 0 : _p.directiveList) !== null && _q !== void 0 ? _q : [], (a, b) => a.name === b.name && a.namedImport === b.namedImport);
93
- (0, utilities_1.CoerceArrayItems)(importList, (_s = (_r = normalizedFormField.suffixButton) === null || _r === void 0 ? void 0 : _r.directiveList) !== null && _s !== void 0 ? _s : [], (a, b) => a.name === b.name && a.namedImport === b.namedImport);
94
- return Object.freeze(normalizedFormField);
95
- }
96
- exports.NormalizeFormField = NormalizeFormField;
97
- function IsFormFieldFormControl(control) {
98
- return control.formField !== undefined;
99
- }
100
- exports.IsFormFieldFormControl = IsFormFieldFormControl;
101
- function IsNormalizedFormFieldFormControl(control) {
102
- return control.formField !== undefined;
103
- }
104
- exports.IsNormalizedFormFieldFormControl = IsNormalizedFormFieldFormControl;
105
- function IsNormalizedInputFormControlOptions(template) {
106
- return template.kind === FormControlKinds.INPUT;
107
- }
108
- exports.IsNormalizedInputFormControlOptions = IsNormalizedInputFormControlOptions;
109
- function NormalizeInputFormControl(control) {
110
- var _a, _b, _c, _d, _e;
111
- const type = (0, ts_morph_1.NormalizeTypeImport)(control.type);
112
- const validatorList = (_a = control.validatorList) !== null && _a !== void 0 ? _a : [];
113
- const importList = (_b = control.importList) !== null && _b !== void 0 ? _b : [];
114
- importList.push({
115
- name: 'MatInputModule',
116
- moduleSpecifier: '@angular/material/input',
117
- });
118
- const inputType = (_c = control.inputType) !== null && _c !== void 0 ? _c : 'text';
119
- switch (inputType) {
120
- case 'checkbox':
121
- type.name = 'boolean';
122
- break;
123
- case 'text':
124
- case 'password':
125
- case 'color':
126
- type.name = 'string';
127
- break;
128
- case 'email':
129
- type.name = 'string';
130
- (0, utilities_1.CoerceArrayItems)(validatorList, ['IsEmail()']);
131
- break;
132
- case 'tel':
133
- type.name = 'string';
134
- (0, utilities_1.CoerceArrayItems)(validatorList, ['IsTel()']);
135
- break;
136
- case 'url':
137
- type.name = 'string';
138
- (0, utilities_1.CoerceArrayItems)(validatorList, ['IsUrl()']);
139
- break;
140
- case 'number':
141
- type.name = 'number';
142
- break;
143
- case 'date':
144
- case 'time':
145
- case 'datetime-local':
146
- type.name = 'Date';
147
- (0, utilities_1.CoerceArrayItems)(validatorList, ['IsDate()']);
148
- break;
149
- case 'file':
150
- case 'hidden':
151
- case 'image':
152
- case 'month':
153
- case 'radio':
154
- case 'reset':
155
- case 'button':
156
- case 'search':
157
- case 'submit':
158
- case 'week':
159
- case 'range':
160
- throw new Error(`The input type "${inputType}" is not yet supported`);
161
- }
162
- const formField = NormalizeFormField((_d = control.formField) !== null && _d !== void 0 ? _d : {}, importList, { label: control.label });
163
- // TODO : auto add validators
164
- return Object.freeze(Object.assign(Object.assign({}, NormalizeBaseFormControl(control)), { type,
165
- validatorList, importList: (0, ts_morph_1.NormalizeTypeImportList)(importList), kind: FormControlKinds.INPUT, inputType, placeholder: (_e = control.placeholder) !== null && _e !== void 0 ? _e : null, formField }));
166
- }
167
- exports.NormalizeInputFormControl = NormalizeInputFormControl;
168
- function IsNormalizedSelectFormControl(template) {
169
- return template.kind === FormControlKinds.SELECT;
170
- }
171
- exports.IsNormalizedSelectFormControl = IsNormalizedSelectFormControl;
172
- function NormalizeSelectFormControl(control) {
173
- var _a, _b, _c, _d;
174
- const importList = (_a = control.importList) !== null && _a !== void 0 ? _a : [];
175
- importList.push({
176
- name: 'MatSelectModule',
177
- moduleSpecifier: '@angular/material/select',
178
- });
179
- const formField = NormalizeFormField((_b = control.formField) !== null && _b !== void 0 ? _b : {}, importList, { label: control.label });
180
- return Object.freeze(Object.assign(Object.assign({}, NormalizeBaseFormControl(control)), { importList: (0, ts_morph_1.NormalizeTypeImportList)(importList), kind: FormControlKinds.SELECT, formField, options: control.options && control.options.length ? Object.freeze(control.options) : null, backend: (_c = control.backend) !== null && _c !== void 0 ? _c : backend_types_1.BackendTypes.NONE, multiple: (_d = control.multiple) !== null && _d !== void 0 ? _d : false }));
181
- }
182
- exports.NormalizeSelectFormControl = NormalizeSelectFormControl;
183
- function IsNormalizedCheckboxFormControl(template) {
184
- return template.kind === FormControlKinds.CHECKBOX;
185
- }
186
- exports.IsNormalizedCheckboxFormControl = IsNormalizedCheckboxFormControl;
187
- function NormalizeCheckboxFormControl(control) {
188
- var _a, _b;
189
- const importList = (_a = control.importList) !== null && _a !== void 0 ? _a : [];
190
- importList.push({
191
- name: 'MatCheckboxModule',
192
- moduleSpecifier: '@angular/material/checkbox',
193
- });
194
- return Object.freeze(Object.assign(Object.assign({}, NormalizeBaseFormControl(control)), { importList: (0, ts_morph_1.NormalizeTypeImportList)(importList), kind: FormControlKinds.CHECKBOX, labelPosition: (_b = control.labelPosition) !== null && _b !== void 0 ? _b : 'after' }));
195
- }
196
- exports.NormalizeCheckboxFormControl = NormalizeCheckboxFormControl;
197
- function IsNormalizedSlideToggleFormControl(template) {
198
- return template.kind === FormControlKinds.CHECKBOX;
199
- }
200
- exports.IsNormalizedSlideToggleFormControl = IsNormalizedSlideToggleFormControl;
201
- function NormalizeSlideToggleFormControl(control) {
202
- var _a;
203
- return Object.freeze(Object.assign(Object.assign({}, NormalizeBaseFormControl(control)), { kind: FormControlKinds.CHECKBOX, labelPosition: (_a = control.labelPosition) !== null && _a !== void 0 ? _a : 'after' }));
204
- }
205
- exports.NormalizeSlideToggleFormControl = NormalizeSlideToggleFormControl;
206
- function NormalizeTableSelectColumn(column) {
207
- var _a, _b, _c, _d;
208
- const { name, propertyPath } = (0, table_column_1.TableColumnNameToPropertyPath)(column.name, column.propertyPath);
209
- const kind = (_a = column.kind) !== null && _a !== void 0 ? _a : table_column_1.TableColumnKind.DEFAULT;
210
- const type = (0, table_column_1.GuessColumnTypeType)(kind, (_b = column.type) !== null && _b !== void 0 ? _b : 'unknown');
211
- return Object.freeze(Object.assign(Object.assign({}, (0, ts_morph_1.NormalizeDataProperty)(Object.assign(Object.assign({}, column), { name,
212
- type }))), { title: (_c = column.title) !== null && _c !== void 0 ? _c : (0, utilities_1.dasherize)(name).split('-').map(part => (0, utilities_1.capitalize)(part)).join(' '), hasFilter: (_d = column.hasFilter) !== null && _d !== void 0 ? _d : false, kind,
213
- propertyPath }));
214
- }
215
- exports.NormalizeTableSelectColumn = NormalizeTableSelectColumn;
216
- function NormalizeTableSelectToFunction(toFunction, columnList, defaultType = 'unknown') {
217
- if (!toFunction || Object.keys(toFunction).length === 0) {
218
- return Object.freeze({
219
- property: (0, ts_morph_1.NormalizeDataProperty)(columnList[0].name, defaultType),
220
- });
221
- }
222
- return Object.freeze({
223
- property: (0, ts_morph_1.NormalizeDataProperty)(toFunction.property, defaultType),
224
- });
225
- }
226
- exports.NormalizeTableSelectToFunction = NormalizeTableSelectToFunction;
227
- function IsNormalizedTableSelectFormControl(template) {
228
- return template.kind === FormControlKinds.TABLE_SELECT;
229
- }
230
- exports.IsNormalizedTableSelectFormControl = IsNormalizedTableSelectFormControl;
231
- function NormalizeTableSelectFormControl(control) {
232
- var _a, _b, _c, _d, _e, _f;
233
- const importList = (_a = control.importList) !== null && _a !== void 0 ? _a : [];
234
- importList.push({
235
- name: 'TableSelectControlModule',
236
- moduleSpecifier: '@digitaix/eurogard-table-select',
237
- });
238
- if (!((_b = control.columnList) === null || _b === void 0 ? void 0 : _b.length)) {
239
- throw new Error('The column list must not be empty');
240
- }
241
- const propertyList = (0, ts_morph_1.NormalizeDataPropertyList)(control.propertyList);
242
- const toDisplay = NormalizeTableSelectToFunction(control.toDisplay, control.columnList, 'string');
243
- const toValue = NormalizeTableSelectToFunction(control.toValue, control.columnList);
244
- (0, utilities_1.CoerceArrayItems)(propertyList, [toDisplay.property, toValue.property], (a, b) => a.name === b.name);
245
- const formField = NormalizeFormField((_c = control.formField) !== null && _c !== void 0 ? _c : {}, importList, {
246
- label: control.label,
247
- directiveList: [
248
- {
249
- name: 'eurogardTableSelectControl',
250
- namedImport: 'TableSelectControlModule',
251
- moduleSpecifier: '@digitaix/eurogard-table-select',
252
- },
253
- ]
254
- });
255
- const columnList = control.columnList.map(NormalizeTableSelectColumn);
256
- (0, utilities_1.CoerceArrayItems)(propertyList, columnList, (a, b) => a.name === b.name);
257
- (_d = control.type) !== null && _d !== void 0 ? _d : (control.type = toValue.property.type);
258
- return Object.freeze(Object.assign(Object.assign({}, NormalizeBaseFormControl(control)), { resolver: control.resolver ? { upstream: (0, ts_morph_1.NormalizeUpstreamOptions)(control.resolver.upstream) } : null, importList: (0, ts_morph_1.NormalizeTypeImportList)(importList), kind: FormControlKinds.TABLE_SELECT, formField, backend: (_e = control.backend) !== null && _e !== void 0 ? _e : backend_types_1.BackendTypes.NONE, title: (_f = control.title) !== null && _f !== void 0 ? _f : null, columnList,
259
- toDisplay,
260
- toValue,
261
- propertyList, upstream: (0, ts_morph_1.NormalizeUpstreamOptions)(control.upstream) }));
262
- }
263
- exports.NormalizeTableSelectFormControl = NormalizeTableSelectFormControl;
264
- // endregion
265
- //# sourceMappingURL=form-control.js.map