@rxap/forms 12.7.3 → 13.0.0-next.0

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 (172) hide show
  1. package/esm2020/index.mjs +53 -0
  2. package/esm2020/lib/control-actions.mjs +77 -0
  3. package/esm2020/lib/control-value-accessor.mjs +14 -0
  4. package/esm2020/lib/decorators/control-async-validator.mjs +10 -0
  5. package/esm2020/lib/decorators/control-change.mjs +10 -0
  6. package/esm2020/lib/decorators/control-set-value.mjs +11 -0
  7. package/esm2020/lib/decorators/control-validator.mjs +10 -0
  8. package/esm2020/lib/decorators/form.mjs +7 -0
  9. package/esm2020/lib/decorators/metadata-keys.mjs +12 -0
  10. package/esm2020/lib/decorators/use-form-array.mjs +13 -0
  11. package/esm2020/lib/decorators/use-form-control.mjs +8 -0
  12. package/esm2020/lib/decorators/use-form-group.mjs +8 -0
  13. package/esm2020/lib/directives/form-control-error.directive.mjs +59 -0
  14. package/esm2020/lib/directives/form-control-mark-dirty.directive.mjs +31 -0
  15. package/esm2020/lib/directives/form-control-mark-pristine.directive.mjs +31 -0
  16. package/esm2020/lib/directives/form-control-mark-touched.directive.mjs +24 -0
  17. package/esm2020/lib/directives/form-control-mark-untouched.directive.mjs +31 -0
  18. package/esm2020/lib/directives/form-control-name.directive.mjs +64 -0
  19. package/esm2020/lib/directives/form-group-name.directive.mjs +61 -0
  20. package/esm2020/lib/directives/form-loaded.directive.mjs +41 -0
  21. package/esm2020/lib/directives/form-loading-error.directive.mjs +41 -0
  22. package/esm2020/lib/directives/form-loading.directive.mjs +41 -0
  23. package/esm2020/lib/directives/form-submit-failed.directive.mjs +41 -0
  24. package/esm2020/lib/directives/form-submit-invalid.directive.mjs +39 -0
  25. package/esm2020/lib/directives/form-submit-successful.directive.mjs +39 -0
  26. package/esm2020/lib/directives/form-submit.directive.mjs +74 -0
  27. package/esm2020/lib/directives/form-submitting.directive.mjs +41 -0
  28. package/esm2020/lib/directives/form.directive.mjs +541 -0
  29. package/esm2020/lib/directives/forms.module.mjs +100 -0
  30. package/esm2020/lib/directives/models.mjs +12 -0
  31. package/esm2020/lib/directives/parent-control-container.directive.mjs +25 -0
  32. package/esm2020/lib/directives/tokens.mjs +10 -0
  33. package/esm2020/lib/form-array.mjs +216 -0
  34. package/esm2020/lib/form-builder.mjs +374 -0
  35. package/esm2020/lib/form-control.mjs +169 -0
  36. package/esm2020/lib/form-group.mjs +181 -0
  37. package/esm2020/lib/model.mjs +2 -0
  38. package/esm2020/lib/tokens.mjs +4 -0
  39. package/esm2020/lib/types.mjs +2 -0
  40. package/esm2020/lib/validators/index.mjs +29 -0
  41. package/esm2020/lib/validators/is-array.mjs +18 -0
  42. package/esm2020/lib/validators/is-boolean.mjs +18 -0
  43. package/esm2020/lib/validators/is-complex.mjs +87 -0
  44. package/esm2020/lib/validators/is-date.mjs +18 -0
  45. package/esm2020/lib/validators/is-email.mjs +19 -0
  46. package/esm2020/lib/validators/is-enum.mjs +18 -0
  47. package/esm2020/lib/validators/is-int.mjs +19 -0
  48. package/esm2020/lib/validators/is-ip.mjs +19 -0
  49. package/esm2020/lib/validators/is-number.mjs +56 -0
  50. package/esm2020/lib/validators/is-object.mjs +18 -0
  51. package/esm2020/lib/validators/is-phone-number.mjs +19 -0
  52. package/esm2020/lib/validators/is-string.mjs +18 -0
  53. package/esm2020/lib/validators/is-url.mjs +19 -0
  54. package/esm2020/rxap-forms.mjs +5 -0
  55. package/fesm2015/rxap-forms.mjs +2713 -0
  56. package/fesm2015/rxap-forms.mjs.map +1 -0
  57. package/{fesm2015/rxap-forms.js → fesm2020/rxap-forms.mjs} +148 -142
  58. package/fesm2020/rxap-forms.mjs.map +1 -0
  59. package/package.json +35 -21
  60. package/src/schematics/ng-add/index.js +1 -1
  61. package/src/schematics/ng-add/index.js.map +1 -1
  62. package/bundles/rxap-forms.umd.js +0 -3521
  63. package/bundles/rxap-forms.umd.js.map +0 -1
  64. package/esm2015/index.js +0 -53
  65. package/esm2015/index.js.map +0 -1
  66. package/esm2015/lib/control-actions.js +0 -80
  67. package/esm2015/lib/control-actions.js.map +0 -1
  68. package/esm2015/lib/control-value-accessor.js +0 -14
  69. package/esm2015/lib/control-value-accessor.js.map +0 -1
  70. package/esm2015/lib/decorators/control-async-validator.js +0 -10
  71. package/esm2015/lib/decorators/control-async-validator.js.map +0 -1
  72. package/esm2015/lib/decorators/control-change.js +0 -10
  73. package/esm2015/lib/decorators/control-change.js.map +0 -1
  74. package/esm2015/lib/decorators/control-set-value.js +0 -8
  75. package/esm2015/lib/decorators/control-set-value.js.map +0 -1
  76. package/esm2015/lib/decorators/control-validator.js +0 -10
  77. package/esm2015/lib/decorators/control-validator.js.map +0 -1
  78. package/esm2015/lib/decorators/form.js +0 -7
  79. package/esm2015/lib/decorators/form.js.map +0 -1
  80. package/esm2015/lib/decorators/metadata-keys.js +0 -12
  81. package/esm2015/lib/decorators/metadata-keys.js.map +0 -1
  82. package/esm2015/lib/decorators/use-form-array.js +0 -13
  83. package/esm2015/lib/decorators/use-form-array.js.map +0 -1
  84. package/esm2015/lib/decorators/use-form-control.js +0 -8
  85. package/esm2015/lib/decorators/use-form-control.js.map +0 -1
  86. package/esm2015/lib/decorators/use-form-group.js +0 -8
  87. package/esm2015/lib/decorators/use-form-group.js.map +0 -1
  88. package/esm2015/lib/directives/form-control-error.directive.js +0 -61
  89. package/esm2015/lib/directives/form-control-error.directive.js.map +0 -1
  90. package/esm2015/lib/directives/form-control-mark-dirty.directive.js +0 -31
  91. package/esm2015/lib/directives/form-control-mark-dirty.directive.js.map +0 -1
  92. package/esm2015/lib/directives/form-control-mark-pristine.directive.js +0 -31
  93. package/esm2015/lib/directives/form-control-mark-pristine.directive.js.map +0 -1
  94. package/esm2015/lib/directives/form-control-mark-touched.directive.js +0 -25
  95. package/esm2015/lib/directives/form-control-mark-touched.directive.js.map +0 -1
  96. package/esm2015/lib/directives/form-control-mark-untouched.directive.js +0 -31
  97. package/esm2015/lib/directives/form-control-mark-untouched.directive.js.map +0 -1
  98. package/esm2015/lib/directives/form-control-name.directive.js +0 -64
  99. package/esm2015/lib/directives/form-control-name.directive.js.map +0 -1
  100. package/esm2015/lib/directives/form-group-name.directive.js +0 -61
  101. package/esm2015/lib/directives/form-group-name.directive.js.map +0 -1
  102. package/esm2015/lib/directives/form-loaded.directive.js +0 -42
  103. package/esm2015/lib/directives/form-loaded.directive.js.map +0 -1
  104. package/esm2015/lib/directives/form-loading-error.directive.js +0 -42
  105. package/esm2015/lib/directives/form-loading-error.directive.js.map +0 -1
  106. package/esm2015/lib/directives/form-loading.directive.js +0 -42
  107. package/esm2015/lib/directives/form-loading.directive.js.map +0 -1
  108. package/esm2015/lib/directives/form-submit-failed.directive.js +0 -42
  109. package/esm2015/lib/directives/form-submit-failed.directive.js.map +0 -1
  110. package/esm2015/lib/directives/form-submit-invalid.directive.js +0 -40
  111. package/esm2015/lib/directives/form-submit-invalid.directive.js.map +0 -1
  112. package/esm2015/lib/directives/form-submit-successful.directive.js +0 -40
  113. package/esm2015/lib/directives/form-submit-successful.directive.js.map +0 -1
  114. package/esm2015/lib/directives/form-submit.directive.js +0 -75
  115. package/esm2015/lib/directives/form-submit.directive.js.map +0 -1
  116. package/esm2015/lib/directives/form-submitting.directive.js +0 -42
  117. package/esm2015/lib/directives/form-submitting.directive.js.map +0 -1
  118. package/esm2015/lib/directives/form.directive.js +0 -544
  119. package/esm2015/lib/directives/form.directive.js.map +0 -1
  120. package/esm2015/lib/directives/forms.module.js +0 -100
  121. package/esm2015/lib/directives/forms.module.js.map +0 -1
  122. package/esm2015/lib/directives/models.js +0 -12
  123. package/esm2015/lib/directives/models.js.map +0 -1
  124. package/esm2015/lib/directives/parent-control-container.directive.js +0 -25
  125. package/esm2015/lib/directives/parent-control-container.directive.js.map +0 -1
  126. package/esm2015/lib/directives/tokens.js +0 -10
  127. package/esm2015/lib/directives/tokens.js.map +0 -1
  128. package/esm2015/lib/form-array.js +0 -217
  129. package/esm2015/lib/form-array.js.map +0 -1
  130. package/esm2015/lib/form-builder.js +0 -349
  131. package/esm2015/lib/form-builder.js.map +0 -1
  132. package/esm2015/lib/form-control.js +0 -170
  133. package/esm2015/lib/form-control.js.map +0 -1
  134. package/esm2015/lib/form-group.js +0 -183
  135. package/esm2015/lib/form-group.js.map +0 -1
  136. package/esm2015/lib/model.js +0 -2
  137. package/esm2015/lib/model.js.map +0 -1
  138. package/esm2015/lib/tokens.js +0 -4
  139. package/esm2015/lib/tokens.js.map +0 -1
  140. package/esm2015/lib/types.js +0 -2
  141. package/esm2015/lib/types.js.map +0 -1
  142. package/esm2015/lib/validators/index.js +0 -29
  143. package/esm2015/lib/validators/index.js.map +0 -1
  144. package/esm2015/lib/validators/is-array.js +0 -18
  145. package/esm2015/lib/validators/is-array.js.map +0 -1
  146. package/esm2015/lib/validators/is-boolean.js +0 -18
  147. package/esm2015/lib/validators/is-boolean.js.map +0 -1
  148. package/esm2015/lib/validators/is-complex.js +0 -87
  149. package/esm2015/lib/validators/is-complex.js.map +0 -1
  150. package/esm2015/lib/validators/is-date.js +0 -18
  151. package/esm2015/lib/validators/is-date.js.map +0 -1
  152. package/esm2015/lib/validators/is-email.js +0 -19
  153. package/esm2015/lib/validators/is-email.js.map +0 -1
  154. package/esm2015/lib/validators/is-enum.js +0 -18
  155. package/esm2015/lib/validators/is-enum.js.map +0 -1
  156. package/esm2015/lib/validators/is-int.js +0 -19
  157. package/esm2015/lib/validators/is-int.js.map +0 -1
  158. package/esm2015/lib/validators/is-ip.js +0 -19
  159. package/esm2015/lib/validators/is-ip.js.map +0 -1
  160. package/esm2015/lib/validators/is-number.js +0 -57
  161. package/esm2015/lib/validators/is-number.js.map +0 -1
  162. package/esm2015/lib/validators/is-object.js +0 -18
  163. package/esm2015/lib/validators/is-object.js.map +0 -1
  164. package/esm2015/lib/validators/is-phone-number.js +0 -19
  165. package/esm2015/lib/validators/is-phone-number.js.map +0 -1
  166. package/esm2015/lib/validators/is-string.js +0 -18
  167. package/esm2015/lib/validators/is-string.js.map +0 -1
  168. package/esm2015/lib/validators/is-url.js +0 -19
  169. package/esm2015/lib/validators/is-url.js.map +0 -1
  170. package/esm2015/rxap-forms.js +0 -5
  171. package/esm2015/rxap-forms.js.map +0 -1
  172. package/fesm2015/rxap-forms.js.map +0 -1
@@ -1,3521 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/forms'), require('rxjs/operators'), require('rxjs'), require('@rxap/utilities'), require('@angular/core'), require('@rxap/definition'), require('@rxap/utilities/reflect-metadata'), require('@rxap/services'), require('@rxap/utilities/rxjs'), require('@angular/router'), require('@rxap/directives'), require('@rxap/validator')) :
3
- typeof define === 'function' && define.amd ? define('@rxap/forms', ['exports', '@angular/forms', 'rxjs/operators', 'rxjs', '@rxap/utilities', '@angular/core', '@rxap/definition', '@rxap/utilities/reflect-metadata', '@rxap/services', '@rxap/utilities/rxjs', '@angular/router', '@rxap/directives', '@rxap/validator'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.rxap = global.rxap || {}, global.rxap.forms = {}), global.ng.forms, global.rxjs.operators, global.rxjs, global.utilities, global.ng.core, global.definition, global.reflectMetadata, global.i2, global.rxjs$1, global.ng.router, global.directives, global.validator));
5
- }(this, (function (exports, i1, operators, rxjs, utilities, i0, definition, reflectMetadata, i2, rxjs$1, i2$1, directives, validator) { 'use strict';
6
-
7
- function _interopNamespace(e) {
8
- if (e && e.__esModule) return e;
9
- var n = Object.create(null);
10
- if (e) {
11
- Object.keys(e).forEach(function (k) {
12
- if (k !== 'default') {
13
- var d = Object.getOwnPropertyDescriptor(e, k);
14
- Object.defineProperty(n, k, d.get ? d : {
15
- enumerable: true,
16
- get: function () {
17
- return e[k];
18
- }
19
- });
20
- }
21
- });
22
- }
23
- n['default'] = e;
24
- return Object.freeze(n);
25
- }
26
-
27
- var i1__namespace = /*#__PURE__*/_interopNamespace(i1);
28
- var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
29
- var i2__namespace = /*#__PURE__*/_interopNamespace(i2);
30
- var i2__namespace$1 = /*#__PURE__*/_interopNamespace(i2$1);
31
-
32
- /*! *****************************************************************************
33
- Copyright (c) Microsoft Corporation.
34
-
35
- Permission to use, copy, modify, and/or distribute this software for any
36
- purpose with or without fee is hereby granted.
37
-
38
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
39
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
40
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
41
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
42
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
43
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
44
- PERFORMANCE OF THIS SOFTWARE.
45
- ***************************************************************************** */
46
- /* global Reflect, Promise */
47
- var extendStatics = function (d, b) {
48
- extendStatics = Object.setPrototypeOf ||
49
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
50
- function (d, b) { for (var p in b)
51
- if (Object.prototype.hasOwnProperty.call(b, p))
52
- d[p] = b[p]; };
53
- return extendStatics(d, b);
54
- };
55
- function __extends(d, b) {
56
- if (typeof b !== "function" && b !== null)
57
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
58
- extendStatics(d, b);
59
- function __() { this.constructor = d; }
60
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
61
- }
62
- var __assign = function () {
63
- __assign = Object.assign || function __assign(t) {
64
- for (var s, i = 1, n = arguments.length; i < n; i++) {
65
- s = arguments[i];
66
- for (var p in s)
67
- if (Object.prototype.hasOwnProperty.call(s, p))
68
- t[p] = s[p];
69
- }
70
- return t;
71
- };
72
- return __assign.apply(this, arguments);
73
- };
74
- function __rest(s, e) {
75
- var t = {};
76
- for (var p in s)
77
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
78
- t[p] = s[p];
79
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
80
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
81
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
82
- t[p[i]] = s[p[i]];
83
- }
84
- return t;
85
- }
86
- function __decorate(decorators, target, key, desc) {
87
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
88
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
89
- r = Reflect.decorate(decorators, target, key, desc);
90
- else
91
- for (var i = decorators.length - 1; i >= 0; i--)
92
- if (d = decorators[i])
93
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
94
- return c > 3 && r && Object.defineProperty(target, key, r), r;
95
- }
96
- function __param(paramIndex, decorator) {
97
- return function (target, key) { decorator(target, key, paramIndex); };
98
- }
99
- function __metadata(metadataKey, metadataValue) {
100
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
101
- return Reflect.metadata(metadataKey, metadataValue);
102
- }
103
- function __awaiter(thisArg, _arguments, P, generator) {
104
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
105
- return new (P || (P = Promise))(function (resolve, reject) {
106
- function fulfilled(value) { try {
107
- step(generator.next(value));
108
- }
109
- catch (e) {
110
- reject(e);
111
- } }
112
- function rejected(value) { try {
113
- step(generator["throw"](value));
114
- }
115
- catch (e) {
116
- reject(e);
117
- } }
118
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
119
- step((generator = generator.apply(thisArg, _arguments || [])).next());
120
- });
121
- }
122
- function __generator(thisArg, body) {
123
- var _ = { label: 0, sent: function () { if (t[0] & 1)
124
- throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
125
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
126
- function verb(n) { return function (v) { return step([n, v]); }; }
127
- function step(op) {
128
- if (f)
129
- throw new TypeError("Generator is already executing.");
130
- while (_)
131
- try {
132
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
133
- return t;
134
- if (y = 0, t)
135
- op = [op[0] & 2, t.value];
136
- switch (op[0]) {
137
- case 0:
138
- case 1:
139
- t = op;
140
- break;
141
- case 4:
142
- _.label++;
143
- return { value: op[1], done: false };
144
- case 5:
145
- _.label++;
146
- y = op[1];
147
- op = [0];
148
- continue;
149
- case 7:
150
- op = _.ops.pop();
151
- _.trys.pop();
152
- continue;
153
- default:
154
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
155
- _ = 0;
156
- continue;
157
- }
158
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
159
- _.label = op[1];
160
- break;
161
- }
162
- if (op[0] === 6 && _.label < t[1]) {
163
- _.label = t[1];
164
- t = op;
165
- break;
166
- }
167
- if (t && _.label < t[2]) {
168
- _.label = t[2];
169
- _.ops.push(op);
170
- break;
171
- }
172
- if (t[2])
173
- _.ops.pop();
174
- _.trys.pop();
175
- continue;
176
- }
177
- op = body.call(thisArg, _);
178
- }
179
- catch (e) {
180
- op = [6, e];
181
- y = 0;
182
- }
183
- finally {
184
- f = t = 0;
185
- }
186
- if (op[0] & 5)
187
- throw op[1];
188
- return { value: op[0] ? op[1] : void 0, done: true };
189
- }
190
- }
191
- var __createBinding = Object.create ? (function (o, m, k, k2) {
192
- if (k2 === undefined)
193
- k2 = k;
194
- Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
195
- }) : (function (o, m, k, k2) {
196
- if (k2 === undefined)
197
- k2 = k;
198
- o[k2] = m[k];
199
- });
200
- function __exportStar(m, o) {
201
- for (var p in m)
202
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
203
- __createBinding(o, m, p);
204
- }
205
- function __values(o) {
206
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
207
- if (m)
208
- return m.call(o);
209
- if (o && typeof o.length === "number")
210
- return {
211
- next: function () {
212
- if (o && i >= o.length)
213
- o = void 0;
214
- return { value: o && o[i++], done: !o };
215
- }
216
- };
217
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
218
- }
219
- function __read(o, n) {
220
- var m = typeof Symbol === "function" && o[Symbol.iterator];
221
- if (!m)
222
- return o;
223
- var i = m.call(o), r, ar = [], e;
224
- try {
225
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
226
- ar.push(r.value);
227
- }
228
- catch (error) {
229
- e = { error: error };
230
- }
231
- finally {
232
- try {
233
- if (r && !r.done && (m = i["return"]))
234
- m.call(i);
235
- }
236
- finally {
237
- if (e)
238
- throw e.error;
239
- }
240
- }
241
- return ar;
242
- }
243
- /** @deprecated */
244
- function __spread() {
245
- for (var ar = [], i = 0; i < arguments.length; i++)
246
- ar = ar.concat(__read(arguments[i]));
247
- return ar;
248
- }
249
- /** @deprecated */
250
- function __spreadArrays() {
251
- for (var s = 0, i = 0, il = arguments.length; i < il; i++)
252
- s += arguments[i].length;
253
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
254
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
255
- r[k] = a[j];
256
- return r;
257
- }
258
- function __spreadArray(to, from) {
259
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
260
- to[j] = from[i];
261
- return to;
262
- }
263
- function __await(v) {
264
- return this instanceof __await ? (this.v = v, this) : new __await(v);
265
- }
266
- function __asyncGenerator(thisArg, _arguments, generator) {
267
- if (!Symbol.asyncIterator)
268
- throw new TypeError("Symbol.asyncIterator is not defined.");
269
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
270
- return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
271
- function verb(n) { if (g[n])
272
- i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
273
- function resume(n, v) { try {
274
- step(g[n](v));
275
- }
276
- catch (e) {
277
- settle(q[0][3], e);
278
- } }
279
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
280
- function fulfill(value) { resume("next", value); }
281
- function reject(value) { resume("throw", value); }
282
- function settle(f, v) { if (f(v), q.shift(), q.length)
283
- resume(q[0][0], q[0][1]); }
284
- }
285
- function __asyncDelegator(o) {
286
- var i, p;
287
- return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
288
- function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
289
- }
290
- function __asyncValues(o) {
291
- if (!Symbol.asyncIterator)
292
- throw new TypeError("Symbol.asyncIterator is not defined.");
293
- var m = o[Symbol.asyncIterator], i;
294
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
295
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
296
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
297
- }
298
- function __makeTemplateObject(cooked, raw) {
299
- if (Object.defineProperty) {
300
- Object.defineProperty(cooked, "raw", { value: raw });
301
- }
302
- else {
303
- cooked.raw = raw;
304
- }
305
- return cooked;
306
- }
307
- ;
308
- var __setModuleDefault = Object.create ? (function (o, v) {
309
- Object.defineProperty(o, "default", { enumerable: true, value: v });
310
- }) : function (o, v) {
311
- o["default"] = v;
312
- };
313
- function __importStar(mod) {
314
- if (mod && mod.__esModule)
315
- return mod;
316
- var result = {};
317
- if (mod != null)
318
- for (var k in mod)
319
- if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
320
- __createBinding(result, mod, k);
321
- __setModuleDefault(result, mod);
322
- return result;
323
- }
324
- function __importDefault(mod) {
325
- return (mod && mod.__esModule) ? mod : { default: mod };
326
- }
327
- function __classPrivateFieldGet(receiver, state, kind, f) {
328
- if (kind === "a" && !f)
329
- throw new TypeError("Private accessor was defined without a getter");
330
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
331
- throw new TypeError("Cannot read private member from an object whose class did not declare it");
332
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
333
- }
334
- function __classPrivateFieldSet(receiver, state, value, kind, f) {
335
- if (kind === "m")
336
- throw new TypeError("Private method is not writable");
337
- if (kind === "a" && !f)
338
- throw new TypeError("Private accessor was defined without a setter");
339
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
340
- throw new TypeError("Cannot write private member to an object whose class did not declare it");
341
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
342
- }
343
-
344
- function getControlValue(control) {
345
- if (control.getRawValue) {
346
- return control.getRawValue();
347
- }
348
- return control.value;
349
- }
350
- function controlValueChanges$(control) {
351
- return rxjs.merge(rxjs.defer(function () { return rxjs.of(getControlValue(control)); }), control.valueChanges.pipe(operators.map(function () { return getControlValue(control); })));
352
- }
353
- function controlDisabled$(control) {
354
- var _a;
355
- return rxjs.merge(rxjs.defer(function () { return rxjs.of(control.disabled); }), rxjs.merge(control.statusChanges, (_a = control.stateChanges) !== null && _a !== void 0 ? _a : rxjs.EMPTY).pipe(operators.map(function () { return control.disabled; }), operators.distinctUntilChanged()));
356
- }
357
- function controlEnabled$(control) {
358
- var _a;
359
- return rxjs.merge(rxjs.defer(function () { return rxjs.of(control.enabled); }), rxjs.merge(control.statusChanges, (_a = control.stateChanges) !== null && _a !== void 0 ? _a : rxjs.EMPTY).pipe(operators.map(function () { return control.enabled; }), operators.distinctUntilChanged()));
360
- }
361
- function controlReadonly$(control) {
362
- var _a;
363
- return rxjs.merge(rxjs.defer(function () { var _a; return rxjs.of((_a = control.readonly) !== null && _a !== void 0 ? _a : false); }), rxjs.merge(control.statusChanges, (_a = control.stateChanges) !== null && _a !== void 0 ? _a : rxjs.EMPTY).pipe(operators.map(function () { var _a; return (_a = control.readonly) !== null && _a !== void 0 ? _a : false; }), operators.distinctUntilChanged()));
364
- }
365
- function controlStatusChanges$(control) {
366
- return rxjs.merge(rxjs.defer(function () { return rxjs.of(control.status); }), control.statusChanges.pipe(operators.map(function () { return control.status; }), operators.distinctUntilChanged()));
367
- }
368
- function controlErrorChanges$(control) {
369
- return rxjs.merge(rxjs.defer(function () { return rxjs.of(control.errors); }), control.valueChanges.pipe(operators.map(function () { return control.errors; })), control.statusChanges.pipe(operators.map(function () { return control.errors; }))).pipe(operators.distinctUntilChanged(function (a, b) { return utilities.equals(a, b); }));
370
- }
371
- function enableControl(control, enabled, opts) {
372
- if (enabled) {
373
- control.enable(opts);
374
- }
375
- else {
376
- control.disable(opts);
377
- }
378
- }
379
- function disableControl(control, disabled, opts) {
380
- enableControl(control, !disabled, opts);
381
- }
382
- function controlDisabledWhile(control, observable, opts) {
383
- return observable.subscribe(function (isDisabled) { return disableControl(control, isDisabled, opts); });
384
- }
385
- function controlEnabledWhile(control, observable, opts) {
386
- return observable.subscribe(function (isEnabled) { return enableControl(control, isEnabled, opts); });
387
- }
388
- function mergeControlValidators(control, validators) {
389
- control.setValidators(__spreadArray(__spreadArray([], __read(utilities.coerceArray(control.validator))), __read(utilities.coerceArray(validators))));
390
- control.updateValueAndValidity();
391
- }
392
- function validateControlOn(control, validation) {
393
- return validation.subscribe(function (maybeError) {
394
- control.setErrors(maybeError);
395
- });
396
- }
397
- function hasErrorAndTouched(control, error, path) {
398
- var hasError = control.hasError(error, !path || path.length === 0 ? undefined : path);
399
- return hasError && control.touched;
400
- }
401
- function hasErrorAndDirty(control, error, path) {
402
- var hasError = control.hasError(error, !path || path.length === 0 ? undefined : path);
403
- return hasError && control.dirty;
404
- }
405
- function markAllDirty(control) {
406
- control.markAsDirty({ onlySelf: true });
407
- control._forEachChild(function (_control) { return _control.markAllAsDirty(); });
408
- }
409
- function markAllPristine(control) {
410
- control.markAsPristine({ onlySelf: true });
411
- control._forEachChild(function (_control) { return _control.markAllAsPristine(); });
412
- }
413
- function markAllUntouched(control) {
414
- control.markAsUntouched({ onlySelf: true });
415
- control._forEachChild(function (_control) { return _control.markAllAsUntouched(); });
416
- }
417
- function selectControlValue$(control, mapFn) {
418
- return control.value$.pipe(operators.map(mapFn), operators.distinctUntilChanged());
419
- }
420
-
421
- var RxapFormArray = /** @class */ (function (_super) {
422
- __extends(RxapFormArray, _super);
423
- function RxapFormArray(controls, options) {
424
- var _this = _super.call(this, controls, options) || this;
425
- _this.controls = controls;
426
- _this._readonly = false;
427
- _this.value$ = controlValueChanges$(_this);
428
- _this.disabled$ = controlDisabled$(_this);
429
- _this.enabled$ = controlEnabled$(_this);
430
- _this.status$ = controlStatusChanges$(_this);
431
- _this.errors$ = controlErrorChanges$(_this);
432
- _this.touchChanges = new rxjs.Subject();
433
- _this.touch$ = _this.touchChanges
434
- .asObservable()
435
- .pipe(operators.distinctUntilChanged());
436
- _this.dirtyChanges = new rxjs.Subject();
437
- _this.dirty$ = _this.dirtyChanges
438
- .asObservable()
439
- .pipe(operators.distinctUntilChanged());
440
- _this.controlId = options.controlId;
441
- _this._builder = options.builder;
442
- _this._controlInsertedFn = options.controlInsertedFn;
443
- _this._controlRemovedFn = options.controlRemovedFn;
444
- return _this;
445
- }
446
- Object.defineProperty(RxapFormArray.prototype, "readonly", {
447
- get: function () {
448
- var _a, _b;
449
- return (_b = (_a = this.parent) === null || _a === void 0 ? void 0 : _a.readonly) !== null && _b !== void 0 ? _b : this._readonly;
450
- },
451
- set: function (value) {
452
- this._readonly = value;
453
- this.controls.forEach(function (control) { var _a; return (_a = control.stateChanges) === null || _a === void 0 ? void 0 : _a.next(); });
454
- },
455
- enumerable: false,
456
- configurable: true
457
- });
458
- Object.defineProperty(RxapFormArray.prototype, "rxapFormDefinition", {
459
- /**
460
- * @internal
461
- */
462
- get: function () {
463
- return this.parent.rxapFormDefinition;
464
- },
465
- enumerable: false,
466
- configurable: true
467
- });
468
- Object.defineProperty(RxapFormArray.prototype, "controlPath", {
469
- get: function () {
470
- var parent = this.parent;
471
- if (parent) {
472
- if (parent.controlPath) {
473
- if (parent === this.root) {
474
- return this.controlId;
475
- }
476
- else {
477
- return [parent.controlPath, this.controlId].join('.');
478
- }
479
- }
480
- }
481
- return this.controlId;
482
- },
483
- enumerable: false,
484
- configurable: true
485
- });
486
- Object.defineProperty(RxapFormArray.prototype, "fullControlPath", {
487
- get: function () {
488
- var parent = this.parent;
489
- if (parent) {
490
- if (parent.fullControlPath) {
491
- return [parent.fullControlPath, this.controlId].join('.');
492
- }
493
- }
494
- return this.controlId;
495
- },
496
- enumerable: false,
497
- configurable: true
498
- });
499
- RxapFormArray.prototype.select = function (mapFn) {
500
- return this.value$.pipe(operators.map(mapFn), operators.distinctUntilChanged());
501
- };
502
- RxapFormArray.prototype.at = function (index) {
503
- return _super.prototype.at.call(this, index);
504
- };
505
- RxapFormArray.prototype.getRawValue = function () {
506
- return _super.prototype.getRawValue.call(this);
507
- };
508
- RxapFormArray.prototype.insert = function (index, control) {
509
- console.warn('It is not recommend to use the FormArray.insert method');
510
- return _super.prototype.insert.call(this, index, control);
511
- };
512
- /**
513
- * inserts a new control at the specified index. If the index is undefined
514
- * the new control will be added to the end.
515
- *
516
- * @param index (optional) the index where the control should be created
517
- * @param state (optional) the initial state of the new control
518
- */
519
- RxapFormArray.prototype.insertAt = function (index, state) {
520
- var insertIndex = index !== null && index !== void 0 ? index : this.controls.length;
521
- var controlOrDefinition = this._builder(state, {
522
- controlId: insertIndex.toFixed(0),
523
- });
524
- this._controlInsertedFn(insertIndex, controlOrDefinition);
525
- if (insertIndex < this.controls.length) {
526
- // update the control ids for all controls, that are moved.
527
- for (var i = insertIndex; i < this.controls.length; i++) {
528
- Reflect.set(this.controls[i], 'controlId', (i + 1).toFixed(0));
529
- }
530
- }
531
- // call the super insert after the update, bc the insert method will
532
- // trigger a change detection
533
- if (controlOrDefinition instanceof i1.AbstractControl) {
534
- _super.prototype.insert.call(this, insertIndex, controlOrDefinition);
535
- }
536
- else {
537
- _super.prototype.insert.call(this, insertIndex, controlOrDefinition.rxapFormGroup);
538
- }
539
- };
540
- RxapFormArray.prototype.disabledWhile = function (observable, options) {
541
- return controlDisabledWhile(this, observable, options);
542
- };
543
- RxapFormArray.prototype.enabledWhile = function (observable, options) {
544
- return controlEnabledWhile(this, observable, options);
545
- };
546
- RxapFormArray.prototype.mergeValidators = function (validators) {
547
- mergeControlValidators(this, validators);
548
- };
549
- RxapFormArray.prototype.mergeAsyncValidators = function (validators) {
550
- this.setAsyncValidators(__spreadArray(__spreadArray([], __read(utilities.coerceArray(this.asyncValidator))), __read(utilities.coerceArray(validators))));
551
- this.updateValueAndValidity();
552
- };
553
- RxapFormArray.prototype.markAllAsDirty = function () {
554
- markAllDirty(this);
555
- };
556
- RxapFormArray.prototype.markAllAsPristine = function () {
557
- markAllPristine(this);
558
- };
559
- RxapFormArray.prototype.setValue = function (valueOrObservable, options) {
560
- var _this = this;
561
- if (rxjs.isObservable(valueOrObservable)) {
562
- return valueOrObservable.subscribe(function (value) { return _super.prototype.setValue.call(_this, value, options); });
563
- }
564
- _super.prototype.setValue.call(this, valueOrObservable, options);
565
- };
566
- RxapFormArray.prototype.markAllAsUntouched = function () {
567
- markAllUntouched(this);
568
- };
569
- RxapFormArray.prototype.validateOn = function (observableValidation) {
570
- var _this = this;
571
- return observableValidation.subscribe(function (maybeError) {
572
- _this.setErrors(maybeError);
573
- });
574
- };
575
- RxapFormArray.prototype.hasErrorAndTouched = function (errorCode, path) {
576
- return hasErrorAndTouched(this, errorCode, path);
577
- };
578
- RxapFormArray.prototype.patchValue = function (valueOrObservable, options) {
579
- var _this = this;
580
- if (rxjs.isObservable(valueOrObservable)) {
581
- return valueOrObservable.subscribe(function (value) {
582
- _super.prototype.patchValue.call(_this, value, options);
583
- });
584
- }
585
- _super.prototype.patchValue.call(this, valueOrObservable, options);
586
- };
587
- RxapFormArray.prototype.hasErrorAndDirty = function (errorCode, path) {
588
- return hasErrorAndDirty(this, errorCode, path);
589
- };
590
- RxapFormArray.prototype.removeAt = function (index) {
591
- console.warn('It is not recommend to use the FormArray.removeAt method');
592
- _super.prototype.removeAt.call(this, index);
593
- this._controlRemovedFn(index);
594
- };
595
- RxapFormArray.prototype.setEnable = function (enable, opts) {
596
- if (enable === void 0) { enable = true; }
597
- enableControl(this, enable, opts);
598
- };
599
- RxapFormArray.prototype.push = function (control) {
600
- console.warn('It is not recommend to use the FormArray.push method');
601
- return _super.prototype.push.call(this, control);
602
- };
603
- RxapFormArray.prototype.setDisable = function (disable, opts) {
604
- if (disable === void 0) { disable = true; }
605
- disableControl(this, disable, opts);
606
- };
607
- RxapFormArray.prototype.setControl = function (index, control) {
608
- console.warn('It is not recommend to use the FormArray.setControl method');
609
- return _super.prototype.setControl.call(this, index, control);
610
- };
611
- RxapFormArray.prototype.markAsTouched = function (opts) {
612
- _super.prototype.markAsTouched.call(this, opts);
613
- this.touchChanges.next(true);
614
- };
615
- RxapFormArray.prototype.markAsUntouched = function (opts) {
616
- _super.prototype.markAsUntouched.call(this, opts);
617
- this.touchChanges.next(false);
618
- };
619
- RxapFormArray.prototype.markAsPristine = function (opts) {
620
- _super.prototype.markAsPristine.call(this, opts);
621
- this.dirtyChanges.next(false);
622
- };
623
- RxapFormArray.prototype.markAsDirty = function (opts) {
624
- _super.prototype.markAsDirty.call(this, opts);
625
- this.dirtyChanges.next(true);
626
- };
627
- RxapFormArray.prototype.reset = function (value, options) {
628
- _super.prototype.reset.call(this, value, options);
629
- };
630
- RxapFormArray.prototype.setValidators = function (newValidator, updateValueAndValidity) {
631
- if (updateValueAndValidity === void 0) { updateValueAndValidity = true; }
632
- _super.prototype.setValidators.call(this, newValidator);
633
- if (updateValueAndValidity) {
634
- _super.prototype.updateValueAndValidity.call(this);
635
- }
636
- };
637
- RxapFormArray.prototype.setAsyncValidators = function (newValidator, updateValueAndValidity) {
638
- if (updateValueAndValidity === void 0) { updateValueAndValidity = true; }
639
- _super.prototype.setAsyncValidators.call(this, newValidator);
640
- if (updateValueAndValidity) {
641
- _super.prototype.updateValueAndValidity.call(this);
642
- }
643
- };
644
- RxapFormArray.prototype.hasError = function (errorCode, path) {
645
- return _super.prototype.hasError.call(this, errorCode, path);
646
- };
647
- RxapFormArray.prototype.setErrors = function (errors, opts) {
648
- if (opts === void 0) { opts = {}; }
649
- return _super.prototype.setErrors.call(this, errors, opts);
650
- };
651
- RxapFormArray.prototype.getError = function (errorCode, path) {
652
- return _super.prototype.getError.call(this, errorCode, path);
653
- };
654
- return RxapFormArray;
655
- }(i1.FormArray));
656
-
657
- var MetadataKeys;
658
- (function (MetadataKeys) {
659
- MetadataKeys["CONTROL_VALIDATORS"] = "rxap/forms/control-validators";
660
- MetadataKeys["CONTROL_ASYNC_VALIDATORS"] = "rxap/forms/control-async-validators";
661
- MetadataKeys["CONTROL_CHANGES"] = "rxap/forms/control-changes";
662
- MetadataKeys["CONTROL_SET_VALUE"] = "rxap/forms/control-set-value";
663
- MetadataKeys["FORM_ARRAY_GROUPS"] = "rxap/forms/form-array-groups";
664
- MetadataKeys["FORM_ARRAY_CONTROLS"] = "rxap/forms/form-array-controls";
665
- MetadataKeys["FORM_GROUPS"] = "rxap/forms/form-groups";
666
- MetadataKeys["FORM_CONTROLS"] = "rxap/forms/form-controls";
667
- })(MetadataKeys || (MetadataKeys = {}));
668
-
669
- var RxapFormGroup = /** @class */ (function (_super) {
670
- __extends(RxapFormGroup, _super);
671
- function RxapFormGroup(controls, options) {
672
- var _this = _super.call(this, controls, options) || this;
673
- _this.controls = controls;
674
- _this._readonly = false;
675
- _this.touchChanges = new rxjs.Subject();
676
- _this.dirtyChanges = new rxjs.Subject();
677
- _this.touch$ = _this.touchChanges.asObservable().pipe(operators.distinctUntilChanged());
678
- _this.dirty$ = _this.dirtyChanges.asObservable().pipe(operators.distinctUntilChanged());
679
- _this.value$ = controlValueChanges$(_this);
680
- _this.disabled$ = controlDisabled$(_this);
681
- _this.enabled$ = controlEnabled$(_this);
682
- _this.status$ = controlStatusChanges$(_this);
683
- _this.errors$ = controlErrorChanges$(_this);
684
- _this.controlId = options.controlId;
685
- return _this;
686
- }
687
- Object.defineProperty(RxapFormGroup.prototype, "rxapFormDefinition", {
688
- /**
689
- * @internal
690
- */
691
- get: function () {
692
- if (!this.parent) {
693
- return this._rxapFormDefinition;
694
- }
695
- if (this._rxapFormDefinition) {
696
- return this._rxapFormDefinition;
697
- }
698
- return this.parent.rxapFormDefinition;
699
- },
700
- enumerable: false,
701
- configurable: true
702
- });
703
- Object.defineProperty(RxapFormGroup.prototype, "readonly", {
704
- get: function () {
705
- var _a, _b;
706
- return (_b = (_a = this.parent) === null || _a === void 0 ? void 0 : _a.readonly) !== null && _b !== void 0 ? _b : this._readonly;
707
- },
708
- set: function (value) {
709
- var _a;
710
- this._readonly = value;
711
- Object.values((_a = this.controls) !== null && _a !== void 0 ? _a : {}).forEach(function (control) { var _a; return (_a = control.stateChanges) === null || _a === void 0 ? void 0 : _a.next(); });
712
- },
713
- enumerable: false,
714
- configurable: true
715
- });
716
- Object.defineProperty(RxapFormGroup.prototype, "controlPath", {
717
- get: function () {
718
- var parent = this.parent;
719
- if (parent) {
720
- if (parent.controlPath) {
721
- if (parent === this.root) {
722
- return this.controlId;
723
- }
724
- else {
725
- return [parent.controlPath, this.controlId].join('.');
726
- }
727
- }
728
- }
729
- return '';
730
- },
731
- enumerable: false,
732
- configurable: true
733
- });
734
- Object.defineProperty(RxapFormGroup.prototype, "fullControlPath", {
735
- get: function () {
736
- var parent = this.parent;
737
- if (parent) {
738
- if (parent.fullControlPath) {
739
- return [parent.fullControlPath, this.controlId].join('.');
740
- }
741
- }
742
- return this.controlId;
743
- },
744
- enumerable: false,
745
- configurable: true
746
- });
747
- RxapFormGroup.prototype.select = function (mapFn) {
748
- return selectControlValue$(this, mapFn);
749
- };
750
- RxapFormGroup.prototype.getRawValue = function () {
751
- return _super.prototype.getRawValue.call(this);
752
- };
753
- RxapFormGroup.prototype.get = function (path) {
754
- return _super.prototype.get.call(this, path);
755
- };
756
- RxapFormGroup.prototype.getControl = function () {
757
- var names = [];
758
- for (var _i = 0; _i < arguments.length; _i++) {
759
- names[_i] = arguments[_i];
760
- }
761
- return this.get(names.join('.'));
762
- };
763
- RxapFormGroup.prototype.addControl = function (name, control) {
764
- _super.prototype.addControl.call(this, name, control);
765
- };
766
- RxapFormGroup.prototype.removeControl = function (name) {
767
- _super.prototype.removeControl.call(this, name);
768
- };
769
- RxapFormGroup.prototype.contains = function (controlName) {
770
- return _super.prototype.contains.call(this, controlName);
771
- };
772
- RxapFormGroup.prototype.setControl = function (name, control) {
773
- _super.prototype.setControl.call(this, name, control);
774
- };
775
- RxapFormGroup.prototype.setValue = function (valueOrObservable, options) {
776
- var _this = this;
777
- if (rxjs.isObservable(valueOrObservable)) {
778
- return valueOrObservable.subscribe(function (value) { return _super.prototype.setValue.call(_this, value, options); });
779
- }
780
- _super.prototype.setValue.call(this, valueOrObservable, options);
781
- };
782
- RxapFormGroup.prototype.patchValue = function (valueOrObservable, options) {
783
- var _this = this;
784
- if (rxjs.isObservable(valueOrObservable)) {
785
- return valueOrObservable.subscribe(function (value) { return _super.prototype.patchValue.call(_this, value, options); });
786
- }
787
- _super.prototype.patchValue.call(this, valueOrObservable, options);
788
- };
789
- RxapFormGroup.prototype.disabledWhile = function (observable, options) {
790
- return controlDisabledWhile(this, observable, options);
791
- };
792
- RxapFormGroup.prototype.enabledWhile = function (observable, options) {
793
- return controlEnabledWhile(this, observable, options);
794
- };
795
- RxapFormGroup.prototype.mergeValidators = function (validators) {
796
- mergeControlValidators(this, validators);
797
- };
798
- RxapFormGroup.prototype.mergeAsyncValidators = function (validators) {
799
- this.setAsyncValidators(__spreadArray(__spreadArray([], __read(utilities.coerceArray(this.asyncValidator))), __read(utilities.coerceArray(validators))));
800
- this.updateValueAndValidity();
801
- };
802
- RxapFormGroup.prototype.markAsTouched = function (opts) {
803
- _super.prototype.markAsTouched.call(this, opts);
804
- this.touchChanges.next(true);
805
- };
806
- RxapFormGroup.prototype.markAsUntouched = function (opts) {
807
- _super.prototype.markAsUntouched.call(this, opts);
808
- this.touchChanges.next(false);
809
- };
810
- RxapFormGroup.prototype.markAsPristine = function (opts) {
811
- _super.prototype.markAsPristine.call(this, opts);
812
- this.dirtyChanges.next(false);
813
- };
814
- RxapFormGroup.prototype.markAsDirty = function (opts) {
815
- _super.prototype.markAsDirty.call(this, opts);
816
- this.dirtyChanges.next(true);
817
- };
818
- RxapFormGroup.prototype.markAllAsDirty = function () {
819
- markAllDirty(this);
820
- };
821
- RxapFormGroup.prototype.markAllAsPristine = function () {
822
- markAllPristine(this);
823
- };
824
- RxapFormGroup.prototype.markAllAsUntouched = function () {
825
- markAllUntouched(this);
826
- };
827
- RxapFormGroup.prototype.reset = function (formState, options) {
828
- _super.prototype.reset.call(this, formState, options);
829
- };
830
- RxapFormGroup.prototype.setValidators = function (newValidator, updateValueAndValidity) {
831
- if (updateValueAndValidity === void 0) { updateValueAndValidity = true; }
832
- _super.prototype.setValidators.call(this, newValidator);
833
- if (updateValueAndValidity) {
834
- _super.prototype.updateValueAndValidity.call(this);
835
- }
836
- };
837
- RxapFormGroup.prototype.setAsyncValidators = function (newValidator, updateValueAndValidity) {
838
- if (updateValueAndValidity === void 0) { updateValueAndValidity = true; }
839
- _super.prototype.setAsyncValidators.call(this, newValidator);
840
- if (updateValueAndValidity) {
841
- _super.prototype.updateValueAndValidity.call(this);
842
- }
843
- };
844
- RxapFormGroup.prototype.validateOn = function (observableValidation) {
845
- return validateControlOn(this, observableValidation);
846
- };
847
- RxapFormGroup.prototype.hasError = function (errorCode, path) {
848
- return _super.prototype.hasError.call(this, errorCode, path);
849
- };
850
- RxapFormGroup.prototype.setErrors = function (errors, opts) {
851
- if (opts === void 0) { opts = {}; }
852
- return _super.prototype.setErrors.call(this, errors, opts);
853
- };
854
- RxapFormGroup.prototype.getError = function (errorCode, path) {
855
- return _super.prototype.getError.call(this, errorCode, path);
856
- };
857
- RxapFormGroup.prototype.hasErrorAndTouched = function (error) {
858
- var path = [];
859
- for (var _i = 1; _i < arguments.length; _i++) {
860
- path[_i - 1] = arguments[_i];
861
- }
862
- return hasErrorAndTouched.apply(void 0, __spreadArray([this, error], __read(path)));
863
- };
864
- RxapFormGroup.prototype.hasErrorAndDirty = function (error) {
865
- var path = [];
866
- for (var _i = 1; _i < arguments.length; _i++) {
867
- path[_i - 1] = arguments[_i];
868
- }
869
- return hasErrorAndDirty.apply(void 0, __spreadArray([this, error], __read(path)));
870
- };
871
- RxapFormGroup.prototype.setEnable = function (enable, opts) {
872
- if (enable === void 0) { enable = true; }
873
- enableControl(this, enable, opts);
874
- };
875
- RxapFormGroup.prototype.setDisable = function (disable, opts) {
876
- if (disable === void 0) { disable = true; }
877
- disableControl(this, disable, opts);
878
- };
879
- return RxapFormGroup;
880
- }(i1.FormGroup));
881
-
882
- var RxapFormControl = /** @class */ (function (_super) {
883
- __extends(RxapFormControl, _super);
884
- function RxapFormControl(formState, options) {
885
- var _this = _super.call(this, formState, options) || this;
886
- _this._readonly = false;
887
- _this.touchChanges = new rxjs.Subject();
888
- _this.dirtyChanges = new rxjs.Subject();
889
- _this.touch$ = _this.touchChanges
890
- .asObservable()
891
- .pipe(operators.distinctUntilChanged());
892
- _this.dirty$ = _this.dirtyChanges
893
- .asObservable()
894
- .pipe(operators.distinctUntilChanged());
895
- _this.value$ = controlValueChanges$(_this);
896
- _this.disabled$ = controlDisabled$(_this);
897
- _this.enabled$ = controlEnabled$(_this);
898
- _this.status$ = controlStatusChanges$(_this);
899
- _this.errors$ = controlErrorChanges$(_this);
900
- _this._onSetValue = [];
901
- _this.stateChanges = new rxjs.Subject();
902
- _this.readonly$ = controlReadonly$(_this);
903
- _this.controlId = options.controlId;
904
- _this.initialState = formState;
905
- return _this;
906
- }
907
- Object.defineProperty(RxapFormControl.prototype, "rxapFormDefinition", {
908
- /**
909
- * @internal
910
- */
911
- get: function () {
912
- return this.parent.rxapFormDefinition;
913
- },
914
- enumerable: false,
915
- configurable: true
916
- });
917
- Object.defineProperty(RxapFormControl.prototype, "readonly", {
918
- get: function () {
919
- var _a, _b;
920
- return (_b = (_a = this.parent) === null || _a === void 0 ? void 0 : _a.readonly) !== null && _b !== void 0 ? _b : this._readonly;
921
- },
922
- set: function (value) {
923
- this._readonly = value;
924
- this.stateChanges.next();
925
- },
926
- enumerable: false,
927
- configurable: true
928
- });
929
- Object.defineProperty(RxapFormControl.prototype, "controlPath", {
930
- get: function () {
931
- var parent = this.parent;
932
- if (parent) {
933
- if (parent.controlPath) {
934
- if (parent === this.root) {
935
- return this.controlId;
936
- }
937
- else {
938
- return [parent.controlPath, this.controlId].join('.');
939
- }
940
- }
941
- }
942
- return this.controlId;
943
- },
944
- enumerable: false,
945
- configurable: true
946
- });
947
- Object.defineProperty(RxapFormControl.prototype, "fullControlPath", {
948
- get: function () {
949
- var parent = this.parent;
950
- if (parent) {
951
- if (parent.fullControlPath) {
952
- return [parent.fullControlPath, this.controlId].join('.');
953
- }
954
- }
955
- return this.controlId;
956
- },
957
- enumerable: false,
958
- configurable: true
959
- });
960
- RxapFormControl.prototype.setValue = function (valueOrObservable, options) {
961
- var _this = this;
962
- if (rxjs.isObservable(valueOrObservable)) {
963
- return valueOrObservable.subscribe(function (value) {
964
- _super.prototype.setValue.call(_this, value, options);
965
- _this._onSetValue.forEach(function (setValueFn) { return setValueFn(value, options); });
966
- });
967
- }
968
- _super.prototype.setValue.call(this, valueOrObservable, options);
969
- this._onSetValue.forEach(function (setValueFn) { return setValueFn(valueOrObservable, options); });
970
- };
971
- RxapFormControl.prototype.patchValue = function (valueOrObservable, options) {
972
- var _this = this;
973
- if (rxjs.isObservable(valueOrObservable)) {
974
- return valueOrObservable.subscribe(function (value) { return _super.prototype.patchValue.call(_this, value, options); });
975
- }
976
- _super.prototype.patchValue.call(this, valueOrObservable, options);
977
- };
978
- RxapFormControl.prototype.disabledWhile = function (observable, options) {
979
- return controlDisabledWhile(this, observable, options);
980
- };
981
- RxapFormControl.prototype.enabledWhile = function (observable, options) {
982
- return controlEnabledWhile(this, observable, options);
983
- };
984
- RxapFormControl.prototype.mergeValidators = function (validators) {
985
- mergeControlValidators(this, validators);
986
- };
987
- RxapFormControl.prototype.mergeAsyncValidators = function (validators) {
988
- this.setAsyncValidators(__spreadArray([
989
- // TODO : remove 'as any' if solution for the type overwrite issue is found (above)
990
- this.asyncValidator
991
- ], __read(utilities.coerceArray(validators))));
992
- this.updateValueAndValidity();
993
- };
994
- RxapFormControl.prototype.markAsTouched = function (opts) {
995
- _super.prototype.markAsTouched.call(this, opts);
996
- this.touchChanges.next(true);
997
- };
998
- RxapFormControl.prototype.markAsUntouched = function (opts) {
999
- _super.prototype.markAsUntouched.call(this, opts);
1000
- this.touchChanges.next(false);
1001
- };
1002
- RxapFormControl.prototype.markAsPristine = function (opts) {
1003
- _super.prototype.markAsPristine.call(this, opts);
1004
- this.dirtyChanges.next(false);
1005
- };
1006
- RxapFormControl.prototype.markAsDirty = function (opts) {
1007
- _super.prototype.markAsDirty.call(this, opts);
1008
- this.dirtyChanges.next(true);
1009
- };
1010
- RxapFormControl.prototype.markAllAsDirty = function () {
1011
- this.markAsDirty({ onlySelf: true });
1012
- };
1013
- RxapFormControl.prototype.reset = function (formState, options) {
1014
- var newState = formState !== null && formState !== void 0 ? formState : this.initialState;
1015
- if (typeof newState === 'function') {
1016
- _super.prototype.reset.call(this, newState(), options);
1017
- }
1018
- else {
1019
- _super.prototype.reset.call(this, newState, options);
1020
- }
1021
- };
1022
- RxapFormControl.prototype.setValidators = function (newValidator, updateValueAndValidity) {
1023
- if (updateValueAndValidity === void 0) { updateValueAndValidity = true; }
1024
- _super.prototype.setValidators.call(this, newValidator);
1025
- if (updateValueAndValidity) {
1026
- _super.prototype.updateValueAndValidity.call(this);
1027
- }
1028
- };
1029
- RxapFormControl.prototype.setAsyncValidators = function (newValidator, updateValueAndValidity) {
1030
- if (updateValueAndValidity === void 0) { updateValueAndValidity = true; }
1031
- _super.prototype.setAsyncValidators.call(this, newValidator);
1032
- if (updateValueAndValidity) {
1033
- _super.prototype.updateValueAndValidity.call(this);
1034
- }
1035
- };
1036
- RxapFormControl.prototype.validateOn = function (observableValidation) {
1037
- return validateControlOn(this, observableValidation);
1038
- };
1039
- RxapFormControl.prototype.getError = function (errorCode) {
1040
- return _super.prototype.getError.call(this, errorCode);
1041
- };
1042
- RxapFormControl.prototype.hasError = function (errorCode) {
1043
- return _super.prototype.hasError.call(this, errorCode);
1044
- };
1045
- RxapFormControl.prototype.setErrors = function (errors, opts) {
1046
- if (opts === void 0) { opts = {}; }
1047
- return _super.prototype.setErrors.call(this, errors, opts);
1048
- };
1049
- RxapFormControl.prototype.setError = function (key, value, opts) {
1050
- var _c;
1051
- if (opts === void 0) { opts = {}; }
1052
- _super.prototype.setErrors.call(this, (_c = {}, _c[key] = value, _c), opts);
1053
- };
1054
- RxapFormControl.prototype.hasErrorAndTouched = function (error) {
1055
- return hasErrorAndTouched(this, error);
1056
- };
1057
- RxapFormControl.prototype.hasErrorAndDirty = function (error) {
1058
- return hasErrorAndDirty(this, error);
1059
- };
1060
- RxapFormControl.prototype.setEnable = function (enable, opts) {
1061
- if (enable === void 0) { enable = true; }
1062
- enableControl(this, enable, opts);
1063
- };
1064
- RxapFormControl.prototype.setDisable = function (disable, opts) {
1065
- if (disable === void 0) { disable = true; }
1066
- disableControl(this, disable, opts);
1067
- };
1068
- RxapFormControl.prototype.registerOnSetValue = function (setValueFn) {
1069
- this._onSetValue.push(setValueFn);
1070
- };
1071
- return RxapFormControl;
1072
- }(i1.FormControl));
1073
-
1074
- var FormArrayControlManager = /** @class */ (function () {
1075
- function FormArrayControlManager(form, controlId) {
1076
- this.form = form;
1077
- this.controlId = controlId;
1078
- }
1079
- FormArrayControlManager.prototype.inserted = function (index, controlOrDefinition) {
1080
- var controlContainer = this.form[this.controlId];
1081
- if (Array.isArray(controlContainer)) {
1082
- controlContainer.splice(index, 0, controlOrDefinition);
1083
- }
1084
- else {
1085
- throw new Error('Could not register inserted control or definition. The control id does not points to an array of control or definition instance!');
1086
- }
1087
- };
1088
- FormArrayControlManager.prototype.removed = function (index) {
1089
- var controlContainer = this.form[this.controlId];
1090
- if (Array.isArray(controlContainer)) {
1091
- controlContainer.splice(index, 1);
1092
- }
1093
- else {
1094
- throw new Error('Could not register inserted control or definition. The control id does not points to an array of control or definition instance!');
1095
- }
1096
- };
1097
- return FormArrayControlManager;
1098
- }());
1099
- var RxapFormBuilder = /** @class */ (function () {
1100
- function RxapFormBuilder(definition, injector, providers) {
1101
- if (injector === void 0) { injector = i0.Injector.NULL; }
1102
- if (providers === void 0) { providers = []; }
1103
- var _a;
1104
- this.definition = definition;
1105
- this.injector = injector;
1106
- this.formArrayGroups = this.extractArrayGroups();
1107
- this.formArrayControls = this.extractArrayControls();
1108
- this.formControls = this.extractControls();
1109
- this.formGroups = this.extractGroups();
1110
- this.validators = this.extractValidators();
1111
- this.asyncValidators = this.extractAsyncValidators();
1112
- this.controlChanges = this.extractControlChanges();
1113
- this.controlSetValue = this.extractControlSetValue();
1114
- var formOptions = (this.formOptions = this.extractFormOptions());
1115
- // merge the providers from the from options with the providers from the
1116
- // constructor. If the provider is defined in the form options and constructor
1117
- // then the provider from the constructor will be used.
1118
- this.providers = __spreadArray(__spreadArray([], __read(providers)), __read(((_a = formOptions.providers) !== null && _a !== void 0 ? _a : []))).filter(function (provider, index, self) { return provider.hasOwnProperty('provide') &&
1119
- self.findIndex(function (selfProvider) { return selfProvider.hasOwnProperty('provide') &&
1120
- selfProvider.provide === provider.provide; }) === index; });
1121
- }
1122
- RxapFormBuilder.prototype.build = function (state, options) {
1123
- var e_1, _c, e_2, _d;
1124
- if (state === void 0) { state = {}; }
1125
- if (options === void 0) { options = {}; }
1126
- var _a, _b;
1127
- var injector = i0.Injector.create({
1128
- name: "rxap/form-builder/" + this.formOptions.id,
1129
- parent: this.injector,
1130
- providers: this.providers
1131
- });
1132
- var form;
1133
- // don't use the notFoundValue feature of the injector.
1134
- // if used for each call of the get method an "empty" or "fallback"
1135
- // instance is created
1136
- try {
1137
- form = injector.get(this.definition);
1138
- }
1139
- catch (e) {
1140
- if (i0.isDevMode()) {
1141
- console.error("Could not inject the definition instance. Fallback and call the constructor of the definition class: " + e.message);
1142
- }
1143
- form = new this.definition();
1144
- }
1145
- var controls = {};
1146
- this.buildControls(state, form, controls);
1147
- this.buildGroups(state, form, controls);
1148
- this.buildArrayGroups(state, form, controls);
1149
- this.buildArrayControls(state, form, controls);
1150
- var formOptions = Object.assign(Object.assign(Object.assign({}, this.formOptions), { controlId: (_a = options.controlId) !== null && _a !== void 0 ? _a : (options.id ? options.id : this.formOptions.id) }), options);
1151
- form.rxapFormGroup = new RxapFormGroup(controls, formOptions);
1152
- Reflect.set(form.rxapFormGroup, '_rxapFormDefinition', form);
1153
- form.rxapMetadata = this.formOptions;
1154
- if (utilities.HasRxapOnInitMethod(form)) {
1155
- form.rxapOnInit();
1156
- }
1157
- try {
1158
- for (var _e = __values(Object.values(form.rxapFormGroup.controls)), _f = _e.next(); !_f.done; _f = _e.next()) {
1159
- var control = _f.value;
1160
- if (control.controlId) {
1161
- var controlSetValueOnInit = Array.from((_b = this.controlSetValue.get(control.controlId)) !== null && _b !== void 0 ? _b : []).filter(function (controlSetValueOptions) { return controlSetValueOptions.initial; });
1162
- try {
1163
- for (var _g = (e_2 = void 0, __values(this.coerceToFnArray(form, controlSetValueOnInit))), _h = _g.next(); !_h.done; _h = _g.next()) {
1164
- var onSetValue = _h.value;
1165
- onSetValue(control.value, { initial: true });
1166
- }
1167
- }
1168
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
1169
- finally {
1170
- try {
1171
- if (_h && !_h.done && (_d = _g.return)) _d.call(_g);
1172
- }
1173
- finally { if (e_2) throw e_2.error; }
1174
- }
1175
- }
1176
- }
1177
- }
1178
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1179
- finally {
1180
- try {
1181
- if (_f && !_f.done && (_c = _e.return)) _c.call(_e);
1182
- }
1183
- finally { if (e_1) throw e_1.error; }
1184
- }
1185
- return form;
1186
- };
1187
- RxapFormBuilder.prototype.buildArrayControls = function (builderFormState, form, controls) {
1188
- var e_3, _c;
1189
- try {
1190
- for (var _d = __values(this.formArrayControls.entries()), _e = _d.next(); !_e.done; _e = _d.next()) {
1191
- var _f = __read(_e.value, 2), controlId = _f[0], options = _f[1];
1192
- var formState = this.coerceToArrayFormState(controlId, [], builderFormState, options.state);
1193
- utilities.assertIsArray(formState);
1194
- var formControls = formState.map(function (fs, index) { return new RxapFormControl(fs, { controlId: index.toFixed(0) }); });
1195
- var manager = new FormArrayControlManager(form, controlId);
1196
- var formArray = (formControls.rxapFormArray =
1197
- controls[controlId] =
1198
- new RxapFormArray(
1199
- // TODO : add the formControlOptions property. To definition the form control options
1200
- formControls, Object.assign(Object.assign({}, options), { controlId: controlId, validators: [], asyncValidators: [], controlInsertedFn: manager.inserted.bind(manager), controlRemovedFn: manager.removed.bind(manager), builder: function (state, controlOptions) { return new RxapFormControl(state, controlOptions); } })));
1201
- // TODO : add support for injectable validators
1202
- formArray.setValidators(this.coerceToValidatorArray(form, options.validators, this.validators.get(controlId)), false);
1203
- formArray.setAsyncValidators(this.coerceToValidatorArray(form, options.asyncValidators, this.asyncValidators.get(controlId)), false);
1204
- Reflect.set(form, controlId, formControls);
1205
- }
1206
- }
1207
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
1208
- finally {
1209
- try {
1210
- if (_e && !_e.done && (_c = _d.return)) _c.call(_d);
1211
- }
1212
- finally { if (e_3) throw e_3.error; }
1213
- }
1214
- };
1215
- RxapFormBuilder.prototype.buildArrayGroups = function (builderFormState, form, controls) {
1216
- var e_4, _c;
1217
- var _loop_1 = function (controlId, options) {
1218
- var formState = this_1.coerceToArrayFormState(controlId, [], builderFormState, options.state);
1219
- utilities.assertIsArray(formState);
1220
- var formGroupBuilder = new RxapFormBuilder(options.definition, this_1.injector, this_1.providers);
1221
- // TODO : add the formGroupOptions property. To definition of the form group options
1222
- var formGroupDefinitions = formState.map(function (fs, index) { return formGroupBuilder.build(fs, { id: index.toFixed(0) }); });
1223
- var manager = new FormArrayControlManager(form, controlId);
1224
- var formArray = (formGroupDefinitions.rxapFormArray =
1225
- controls[controlId] =
1226
- new RxapFormArray(formGroupDefinitions.map(function (fgd) { return fgd.rxapFormGroup; }), Object.assign(Object.assign({}, options), { builder: formGroupBuilder.build.bind(formGroupBuilder), controlId: controlId, validators: [], asyncValidators: [], controlInsertedFn: manager.inserted.bind(manager), controlRemovedFn: manager.removed.bind(manager) })));
1227
- // TODO : add support for injectable validators
1228
- formArray.setValidators(this_1.coerceToValidatorArray(form, options.validators, this_1.validators.get(controlId)), false);
1229
- formArray.setAsyncValidators(this_1.coerceToValidatorArray(form, options.asyncValidators, this_1.asyncValidators.get(controlId)), false);
1230
- Reflect.set(form, controlId, formGroupDefinitions);
1231
- };
1232
- var this_1 = this;
1233
- try {
1234
- for (var _d = __values(this.formArrayGroups.entries()), _e = _d.next(); !_e.done; _e = _d.next()) {
1235
- var _f = __read(_e.value, 2), controlId = _f[0], options = _f[1];
1236
- _loop_1(controlId, options);
1237
- }
1238
- }
1239
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
1240
- finally {
1241
- try {
1242
- if (_e && !_e.done && (_c = _d.return)) _c.call(_d);
1243
- }
1244
- finally { if (e_4) throw e_4.error; }
1245
- }
1246
- };
1247
- RxapFormBuilder.prototype.buildGroups = function (builderFormState, form, controls) {
1248
- var e_5, _c;
1249
- try {
1250
- for (var _d = __values(this.formGroups.entries()), _e = _d.next(); !_e.done; _e = _d.next()) {
1251
- var _f = __read(_e.value, 2), controlId = _f[0], options = _f[1];
1252
- var formState = this.coerceToGroupFormState(controlId, {}, builderFormState, options.state);
1253
- utilities.assertIsObject(formState);
1254
- var formGroupDefinition = new RxapFormBuilder(options.definition, this.injector, this.providers).build(formState, Object.assign(Object.assign({}, options), { validators: [], asyncValidators: [] }));
1255
- controls[controlId] = formGroupDefinition.rxapFormGroup;
1256
- var formGroup = formGroupDefinition.rxapFormGroup;
1257
- // TODO : add support for injectable validators
1258
- formGroup.setValidators(this.coerceToValidatorArray(form, options.validators, this.validators.get(controlId)), false);
1259
- formGroup.setAsyncValidators(this.coerceToValidatorArray(form, options.asyncValidators, this.asyncValidators.get(controlId)), false);
1260
- // set the form group definition instance to the form definition instance
1261
- Reflect.set(form, controlId, formGroupDefinition);
1262
- }
1263
- }
1264
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
1265
- finally {
1266
- try {
1267
- if (_e && !_e.done && (_c = _d.return)) _c.call(_d);
1268
- }
1269
- finally { if (e_5) throw e_5.error; }
1270
- }
1271
- };
1272
- RxapFormBuilder.prototype.buildControls = function (builderFormState, form, controls) {
1273
- var e_6, _c;
1274
- var _a, _b;
1275
- var _loop_2 = function (controlId, options) {
1276
- var e_7, _g;
1277
- var control = (controls[controlId] = new ((_a = options.controlType) !== null && _a !== void 0 ? _a : RxapFormControl)(this_2.coerceToControlFormState(controlId, null, builderFormState, options.state), Object.assign(Object.assign({}, options), { controlId: controlId, validators: [], asyncValidators: [] })));
1278
- var injectValidators = [];
1279
- var injectAsyncValidators = [];
1280
- try {
1281
- for (var _h = (e_7 = void 0, __values((_b = options.injectValidators) !== null && _b !== void 0 ? _b : [])), _j = _h.next(); !_j.done; _j = _h.next()) {
1282
- var injectValidator = _j.value;
1283
- var injectableValidator = this_2.injector.get(injectValidator);
1284
- if (injectableValidator.validate) {
1285
- injectValidators.push(injectableValidator.validate.bind(injectableValidator));
1286
- }
1287
- if (injectableValidator.asyncValidate) {
1288
- injectAsyncValidators.push(injectableValidator.asyncValidate.bind(injectableValidator));
1289
- }
1290
- }
1291
- }
1292
- catch (e_7_1) { e_7 = { error: e_7_1 }; }
1293
- finally {
1294
- try {
1295
- if (_j && !_j.done && (_g = _h.return)) _g.call(_h);
1296
- }
1297
- finally { if (e_7) throw e_7.error; }
1298
- }
1299
- control.setValidators(this_2.coerceToValidatorArray(form, options.validators, this_2.validators.get(controlId), injectValidators), false);
1300
- control.setAsyncValidators(this_2.coerceToValidatorArray(form, options.asyncValidators, this_2.asyncValidators.get(controlId), injectAsyncValidators), false);
1301
- // register all control on change function with the form control
1302
- this_2.coerceToFnArray(form, this_2.controlChanges.get(controlId)).forEach(function (changeFn) { return control.registerOnChange(changeFn); });
1303
- // register all control on set value function with the form control
1304
- this_2.coerceToFnArray(form, this_2.controlSetValue.get(controlId)).forEach(function (setValueFn) { return control.registerOnSetValue(setValueFn); });
1305
- if (Array.isArray(options.validators)) {
1306
- if (options.validators.includes(i1.Validators.required) ||
1307
- options.validators.includes(i1.Validators.requiredTrue)) {
1308
- Reflect.set(control, 'hasRequiredValidator', true);
1309
- }
1310
- }
1311
- // set the form control instance to the form definition instance
1312
- Reflect.set(form, controlId, control);
1313
- };
1314
- var this_2 = this;
1315
- try {
1316
- for (var _d = __values(this.formControls.entries()), _e = _d.next(); !_e.done; _e = _d.next()) {
1317
- var _f = __read(_e.value, 2), controlId = _f[0], options = _f[1];
1318
- _loop_2(controlId, options);
1319
- }
1320
- }
1321
- catch (e_6_1) { e_6 = { error: e_6_1 }; }
1322
- finally {
1323
- try {
1324
- if (_e && !_e.done && (_c = _d.return)) _c.call(_d);
1325
- }
1326
- finally { if (e_6) throw e_6.error; }
1327
- }
1328
- };
1329
- /**
1330
- * Coerce to a function array.
1331
- *
1332
- * @param form the current form definition instance
1333
- * @param methodKeys A set of propertyKeys that points to form
1334
- * definition instance methods
1335
- */
1336
- RxapFormBuilder.prototype.coerceToFnArray = function (form, methodKeys) {
1337
- var e_8, _c;
1338
- var changes = [];
1339
- if (methodKeys) {
1340
- try {
1341
- for (var methodKeys_1 = __values(methodKeys), methodKeys_1_1 = methodKeys_1.next(); !methodKeys_1_1.done; methodKeys_1_1 = methodKeys_1.next()) {
1342
- var propertyKeyOrOptions = methodKeys_1_1.value;
1343
- var propertyKey = typeof propertyKeyOrOptions === 'string'
1344
- ? propertyKeyOrOptions
1345
- : propertyKeyOrOptions.propertyKey;
1346
- utilities.assertIsFunction(form[propertyKey]);
1347
- changes.push(form[propertyKey].bind(form));
1348
- }
1349
- }
1350
- catch (e_8_1) { e_8 = { error: e_8_1 }; }
1351
- finally {
1352
- try {
1353
- if (methodKeys_1_1 && !methodKeys_1_1.done && (_c = methodKeys_1.return)) _c.call(methodKeys_1);
1354
- }
1355
- finally { if (e_8) throw e_8.error; }
1356
- }
1357
- }
1358
- return changes;
1359
- };
1360
- /**
1361
- * Coerce to a validator function array.
1362
- *
1363
- * @param form the current form definition instance
1364
- * @param optionsValidators The options validator functions
1365
- * @param validatorMethodKeys A set of propertyKeys that points to form
1366
- * definition instance methods
1367
- * @param injectValidators Injected validator functions
1368
- */
1369
- RxapFormBuilder.prototype.coerceToValidatorArray = function (form, optionsValidators, validatorMethodKeys, injectValidators) {
1370
- var validators = optionsValidators
1371
- ? Array.isArray(optionsValidators)
1372
- ? optionsValidators
1373
- : [optionsValidators]
1374
- : [];
1375
- if (validatorMethodKeys) {
1376
- validatorMethodKeys.forEach(function (propertyKey) {
1377
- utilities.assertIsFunction(form[propertyKey]);
1378
- validators.push(form[propertyKey].bind(form));
1379
- });
1380
- }
1381
- if (injectValidators) {
1382
- validators.push.apply(validators, __spreadArray([], __read(injectValidators)));
1383
- }
1384
- return validators;
1385
- };
1386
- /**
1387
- * Coerce to the form state for the specified controlId. If none form state is
1388
- * found the default form state will be returned.
1389
- *
1390
- * @param controlId A control id
1391
- * @param defaultFormState The default form state
1392
- * @param builderFormState The form state provides as build state parameter
1393
- * @param optionsFormState The form state set by the decorator in the form definition
1394
- */
1395
- RxapFormBuilder.prototype.coerceToControlFormState = function (controlId, defaultFormState, builderFormState, optionsFormState) {
1396
- var formState = defaultFormState;
1397
- if (builderFormState && builderFormState[controlId] !== undefined) {
1398
- formState = builderFormState[controlId];
1399
- }
1400
- else if (optionsFormState !== undefined) {
1401
- formState = optionsFormState !== null && optionsFormState !== void 0 ? optionsFormState : null;
1402
- }
1403
- if (typeof formState === 'function') {
1404
- formState = formState();
1405
- }
1406
- return formState;
1407
- };
1408
- /**
1409
- * Coerce to the form state for the specified controlId. If none form state is
1410
- * found the default form state will be returned.
1411
- *
1412
- * The difference to the method coerceToControlFormState is that null will be
1413
- * handled as undefined and the defaultFormState is used
1414
- *
1415
- * @param controlId A control id
1416
- * @param defaultFormState The default form state
1417
- * @param builderFormState The form state provides as build state parameter
1418
- * @param optionsFormState The form state set by the decorator in the form definition
1419
- */
1420
- RxapFormBuilder.prototype.coerceToGroupFormState = function (controlId, defaultFormState, builderFormState, optionsFormState) {
1421
- var formState = defaultFormState;
1422
- if (builderFormState && builderFormState[controlId]) {
1423
- formState = builderFormState[controlId];
1424
- }
1425
- else if (optionsFormState) {
1426
- formState = optionsFormState;
1427
- }
1428
- if (typeof formState === 'function') {
1429
- formState = formState();
1430
- if (!formState) {
1431
- throw new Error("The form state function for the form group '" + controlId + "' returns a empty value (null/undefined)");
1432
- }
1433
- if (typeof formState !== 'object') {
1434
- throw new Error("The form state function for the form group '" + controlId + "' returns a non object like value instead '" + typeof formState + "'");
1435
- }
1436
- }
1437
- return formState;
1438
- };
1439
- /**
1440
- * Coerce to the form state for the specified controlId. If none form state is
1441
- * found the default form state will be returned.
1442
- *
1443
- * The difference to the method coerceToControlFormState is that null will be
1444
- * handled as undefined and the defaultFormState is used
1445
- *
1446
- * @param controlId A control id
1447
- * @param defaultFormState The default form state
1448
- * @param builderFormState The form state provides as build state parameter
1449
- * @param optionsFormState The form state set by the decorator in the form definition
1450
- */
1451
- RxapFormBuilder.prototype.coerceToArrayFormState = function (controlId, defaultFormState, builderFormState, optionsFormState) {
1452
- var formState = defaultFormState;
1453
- if (builderFormState && builderFormState[controlId] && Array.isArray(builderFormState[controlId])) {
1454
- formState = builderFormState[controlId];
1455
- }
1456
- else if (optionsFormState && Array.isArray(optionsFormState)) {
1457
- formState = optionsFormState;
1458
- }
1459
- if (typeof formState === 'function') {
1460
- formState = formState();
1461
- if (!formState) {
1462
- throw new Error("The form state function for the form array '" + controlId + "' returns a empty value (null/undefined)");
1463
- }
1464
- if (!Array.isArray(formState)) {
1465
- throw new Error("The form state function for the form array '" + controlId + "' returns a non array like value instead '" + typeof formState + "'");
1466
- }
1467
- }
1468
- return formState;
1469
- };
1470
- RxapFormBuilder.prototype.extractControlChanges = function () {
1471
- var _a;
1472
- return ((_a = reflectMetadata.getMetadata(MetadataKeys.CONTROL_CHANGES, this.definition.prototype)) !== null && _a !== void 0 ? _a : new Map());
1473
- };
1474
- RxapFormBuilder.prototype.extractControlSetValue = function () {
1475
- var _a;
1476
- return ((_a = reflectMetadata.getMetadata(MetadataKeys.CONTROL_SET_VALUE, this.definition.prototype)) !== null && _a !== void 0 ? _a : new Map());
1477
- };
1478
- RxapFormBuilder.prototype.extractValidators = function () {
1479
- var _a;
1480
- return ((_a = reflectMetadata.getMetadata(MetadataKeys.CONTROL_VALIDATORS, this.definition.prototype)) !== null && _a !== void 0 ? _a : new Map());
1481
- };
1482
- RxapFormBuilder.prototype.extractAsyncValidators = function () {
1483
- var _a;
1484
- return ((_a = reflectMetadata.getMetadata(MetadataKeys.CONTROL_ASYNC_VALIDATORS, this.definition.prototype)) !== null && _a !== void 0 ? _a : new Map());
1485
- };
1486
- RxapFormBuilder.prototype.extractArrayGroups = function () {
1487
- var _a;
1488
- return ((_a = reflectMetadata.getMetadata(MetadataKeys.FORM_ARRAY_GROUPS, this.definition.prototype)) !== null && _a !== void 0 ? _a : new Map());
1489
- };
1490
- RxapFormBuilder.prototype.extractArrayControls = function () {
1491
- var _a;
1492
- return ((_a = reflectMetadata.getMetadata(MetadataKeys.FORM_ARRAY_CONTROLS, this.definition.prototype)) !== null && _a !== void 0 ? _a : new Map());
1493
- };
1494
- RxapFormBuilder.prototype.extractGroups = function () {
1495
- var _a;
1496
- return ((_a = reflectMetadata.getMetadata(MetadataKeys.FORM_GROUPS, this.definition.prototype)) !== null && _a !== void 0 ? _a : new Map());
1497
- };
1498
- RxapFormBuilder.prototype.extractControls = function () {
1499
- var _a;
1500
- return ((_a = reflectMetadata.getMetadata(MetadataKeys.FORM_CONTROLS, this.definition.prototype)) !== null && _a !== void 0 ? _a : new Map());
1501
- };
1502
- RxapFormBuilder.prototype.extractFormOptions = function () {
1503
- var options = definition.GetDefinitionMetadata(this.definition);
1504
- if (!options || !options.hasOwnProperty('id')) {
1505
- throw new Error('Ensure that the @UseForm decorator is used.');
1506
- }
1507
- if (!options.providers) {
1508
- options.providers = [];
1509
- }
1510
- return options;
1511
- };
1512
- return RxapFormBuilder;
1513
- }());
1514
-
1515
- var ControlValueAccessor = /** @class */ (function () {
1516
- function ControlValueAccessor() {
1517
- this.onChange = function (value) { };
1518
- this.onTouched = function () { };
1519
- this.setDisabledState = function (isDisabled) { };
1520
- }
1521
- ControlValueAccessor.prototype.registerOnChange = function (fn) {
1522
- this.onChange = fn;
1523
- };
1524
- ControlValueAccessor.prototype.registerOnTouched = function (fn) {
1525
- this.onTouched = fn;
1526
- };
1527
- return ControlValueAccessor;
1528
- }());
1529
-
1530
- var RXAP_FORM_INITIAL_STATE = new i0.InjectionToken('rxap/forms/initial-state');
1531
- var RXAP_FORM_CONTEXT = new i0.InjectionToken('rxap/forms/context');
1532
-
1533
- function ControlAsyncValidator() {
1534
- var controlIds = [];
1535
- for (var _i = 0; _i < arguments.length; _i++) {
1536
- controlIds[_i] = arguments[_i];
1537
- }
1538
- return function (target, propertyKey) {
1539
- var e_1, _a;
1540
- try {
1541
- for (var controlIds_1 = __values(controlIds), controlIds_1_1 = controlIds_1.next(); !controlIds_1_1.done; controlIds_1_1 = controlIds_1.next()) {
1542
- var controlId = controlIds_1_1.value;
1543
- reflectMetadata.setMetadataMapSet(controlId, propertyKey, MetadataKeys.CONTROL_ASYNC_VALIDATORS, target);
1544
- }
1545
- }
1546
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1547
- finally {
1548
- try {
1549
- if (controlIds_1_1 && !controlIds_1_1.done && (_a = controlIds_1.return)) _a.call(controlIds_1);
1550
- }
1551
- finally { if (e_1) throw e_1.error; }
1552
- }
1553
- };
1554
- }
1555
-
1556
- function ControlChange() {
1557
- var controlIds = [];
1558
- for (var _i = 0; _i < arguments.length; _i++) {
1559
- controlIds[_i] = arguments[_i];
1560
- }
1561
- return function (target, propertyKey) {
1562
- var e_1, _a;
1563
- try {
1564
- for (var controlIds_1 = __values(controlIds), controlIds_1_1 = controlIds_1.next(); !controlIds_1_1.done; controlIds_1_1 = controlIds_1.next()) {
1565
- var controlId = controlIds_1_1.value;
1566
- reflectMetadata.setMetadataMapSet(controlId, propertyKey, MetadataKeys.CONTROL_CHANGES, target);
1567
- }
1568
- }
1569
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1570
- finally {
1571
- try {
1572
- if (controlIds_1_1 && !controlIds_1_1.done && (_a = controlIds_1.return)) _a.call(controlIds_1);
1573
- }
1574
- finally { if (e_1) throw e_1.error; }
1575
- }
1576
- };
1577
- }
1578
-
1579
- function ControlSetValue(controlId, options) {
1580
- if (options === void 0) { options = {}; }
1581
- return function (target, propertyKey) {
1582
- reflectMetadata.setMetadataMapSet(controlId, Object.assign(Object.assign({}, options), { propertyKey: propertyKey }), MetadataKeys.CONTROL_SET_VALUE, target);
1583
- };
1584
- }
1585
-
1586
- function ControlValidator() {
1587
- var controlIds = [];
1588
- for (var _i = 0; _i < arguments.length; _i++) {
1589
- controlIds[_i] = arguments[_i];
1590
- }
1591
- return function (target, propertyKey) {
1592
- var e_1, _a;
1593
- try {
1594
- for (var controlIds_1 = __values(controlIds), controlIds_1_1 = controlIds_1.next(); !controlIds_1_1.done; controlIds_1_1 = controlIds_1.next()) {
1595
- var controlId = controlIds_1_1.value;
1596
- reflectMetadata.setMetadataMapSet(controlId, propertyKey, MetadataKeys.CONTROL_VALIDATORS, target);
1597
- }
1598
- }
1599
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1600
- finally {
1601
- try {
1602
- if (controlIds_1_1 && !controlIds_1_1.done && (_a = controlIds_1.return)) _a.call(controlIds_1);
1603
- }
1604
- finally { if (e_1) throw e_1.error; }
1605
- }
1606
- };
1607
- }
1608
-
1609
- function UseFormArrayGroup(definition, options) {
1610
- if (options === void 0) { options = {}; }
1611
- return function (target, propertyKey) {
1612
- reflectMetadata.setMetadataMap(propertyKey, Object.assign(Object.assign({}, options), { definition: definition }), MetadataKeys.FORM_ARRAY_GROUPS, target);
1613
- };
1614
- }
1615
- function UseFormArrayControl(options) {
1616
- if (options === void 0) { options = {}; }
1617
- return function (target, propertyKey) {
1618
- reflectMetadata.setMetadataMap(propertyKey, options, MetadataKeys.FORM_ARRAY_CONTROLS, target);
1619
- };
1620
- }
1621
-
1622
- function UseFormControl(options) {
1623
- if (options === void 0) { options = {}; }
1624
- return function (target, propertyKey) {
1625
- reflectMetadata.setMetadataMap(propertyKey, options, MetadataKeys.FORM_CONTROLS, target);
1626
- };
1627
- }
1628
-
1629
- function UseFormGroup(definition, options) {
1630
- if (options === void 0) { options = {}; }
1631
- return function (target, propertyKey) {
1632
- reflectMetadata.setMetadataMap(propertyKey, Object.assign(Object.assign({}, options), { definition: definition }), MetadataKeys.FORM_GROUPS, target);
1633
- };
1634
- }
1635
-
1636
- function RxapForm(optionsOrId, className, packageName) {
1637
- if (className === void 0) { className = 'FormDefinition'; }
1638
- if (packageName === void 0) { packageName = '@rxap/forms'; }
1639
- return function (target) {
1640
- definition.DefinitionMetadata(optionsOrId, className, packageName)(target);
1641
- };
1642
- }
1643
-
1644
- var RXAP_FORM_DEFINITION = new i0.InjectionToken('rxap/forms/definition');
1645
- var RXAP_FORM_DEFINITION_BUILDER = new i0.InjectionToken('rxap/forms/definition-builder');
1646
- var RXAP_FORM_SUBMIT_METHOD = new i0.InjectionToken('rxap/form/submit-method');
1647
- var RXAP_FORM_SUBMIT_FAILED_METHOD = new i0.InjectionToken('rxap/form/submit-failed-method');
1648
- var RXAP_FORM_SUBMIT_SUCCESSFUL_METHOD = new i0.InjectionToken('rxap/form/submit-successful-method');
1649
- var RXAP_FORM_LOAD_METHOD = new i0.InjectionToken('rxap/form/load-method');
1650
- var RXAP_FORM_LOAD_FAILED_METHOD = new i0.InjectionToken('rxap/form/load-failed-method');
1651
- var RXAP_FORM_LOAD_SUCCESSFUL_METHOD = new i0.InjectionToken('rxap/form/load-successful-method');
1652
-
1653
- var FormDirective = /** @class */ (function (_super) {
1654
- __extends(FormDirective, _super);
1655
- function FormDirective(cdr, formDefinition,
1656
- // skip self, bc the token is set to null
1657
- submitMethod,
1658
- // skip self, bc the token is set to null
1659
- loadMethod,
1660
- // skip self, bc the token is set to null
1661
- loadFailedMethod,
1662
- // skip self, bc the token is set to null
1663
- loadSuccessfulMethod,
1664
- // skip self, bc the token is set to null
1665
- submitFailedMethod,
1666
- // skip self, bc the token is set to null
1667
- submitSuccessfulMethod,
1668
- // skip self, bc the token is set to null
1669
- formDefinitionBuilder, loadingIndicatorService) {
1670
- if (formDefinition === void 0) { formDefinition = null; }
1671
- if (submitMethod === void 0) { submitMethod = null; }
1672
- if (loadMethod === void 0) { loadMethod = null; }
1673
- if (loadFailedMethod === void 0) { loadFailedMethod = null; }
1674
- if (loadSuccessfulMethod === void 0) { loadSuccessfulMethod = null; }
1675
- if (submitFailedMethod === void 0) { submitFailedMethod = null; }
1676
- if (submitSuccessfulMethod === void 0) { submitSuccessfulMethod = null; }
1677
- if (formDefinitionBuilder === void 0) { formDefinitionBuilder = null; }
1678
- if (loadingIndicatorService === void 0) { loadingIndicatorService = null; }
1679
- var _this = this;
1680
- var _a, _b;
1681
- _this = _super.call(this, [], []) || this;
1682
- _this.cdr = cdr;
1683
- _this.loadMethod = loadMethod;
1684
- _this.loadFailedMethod = loadFailedMethod;
1685
- _this.loadSuccessfulMethod = loadSuccessfulMethod;
1686
- _this.submitFailedMethod = submitFailedMethod;
1687
- _this.submitSuccessfulMethod = submitSuccessfulMethod;
1688
- _this.formDefinitionBuilder = formDefinitionBuilder;
1689
- _this.loadingIndicatorService = loadingIndicatorService;
1690
- /**
1691
- * Emits when the submit method is executed without errors. The result of the
1692
- * submit method is passed as event object.
1693
- *
1694
- * If no submit method is defined then emit after the submit button
1695
- * is clicked.
1696
- */
1697
- _this.rxapSubmit = new i0.EventEmitter();
1698
- _this.invalidSubmit = new i0.EventEmitter();
1699
- _this.submitSuccessful$ = new i0.EventEmitter();
1700
- _this.submitting$ = new rxjs$1.ToggleSubject();
1701
- _this.submitError$ = new rxjs.BehaviorSubject(null);
1702
- _this.loading$ = new rxjs$1.ToggleSubject();
1703
- _this.loaded$ = new rxjs$1.ToggleSubject();
1704
- _this.loadingError$ = new rxjs.BehaviorSubject(null);
1705
- _this.submitMethod = null;
1706
- _this._autoSubmitSubscription = new rxjs.Subscription();
1707
- if (submitMethod) {
1708
- _this.submitMethod = submitMethod;
1709
- }
1710
- if (!formDefinition && formDefinitionBuilder) {
1711
- formDefinition = formDefinitionBuilder.build();
1712
- }
1713
- if (formDefinition) {
1714
- _this._formDefinition = formDefinition;
1715
- _this.form = formDefinition.rxapFormGroup;
1716
- }
1717
- (_a = _this.loadingIndicatorService) === null || _a === void 0 ? void 0 : _a.attachLoading(_this.loading$);
1718
- (_b = _this.loadingIndicatorService) === null || _b === void 0 ? void 0 : _b.attachLoading(_this.submitting$);
1719
- return _this;
1720
- }
1721
- Object.defineProperty(FormDirective.prototype, "submitting", {
1722
- get: function () {
1723
- return this.submitting$.value;
1724
- },
1725
- enumerable: false,
1726
- configurable: true
1727
- });
1728
- Object.defineProperty(FormDirective.prototype, "submitError", {
1729
- get: function () {
1730
- return this.submitError$.value;
1731
- },
1732
- enumerable: false,
1733
- configurable: true
1734
- });
1735
- Object.defineProperty(FormDirective.prototype, "loading", {
1736
- get: function () {
1737
- return this.loading$.value;
1738
- },
1739
- enumerable: false,
1740
- configurable: true
1741
- });
1742
- Object.defineProperty(FormDirective.prototype, "loaded", {
1743
- get: function () {
1744
- return this.loaded$.value;
1745
- },
1746
- enumerable: false,
1747
- configurable: true
1748
- });
1749
- Object.defineProperty(FormDirective.prototype, "loadingError", {
1750
- get: function () {
1751
- return this.loadingError$.value;
1752
- },
1753
- enumerable: false,
1754
- configurable: true
1755
- });
1756
- Object.defineProperty(FormDirective.prototype, "useFormDefinition", {
1757
- set: function (value) {
1758
- if (value) {
1759
- this._formDefinition = value;
1760
- this.form = value.rxapFormGroup;
1761
- }
1762
- },
1763
- enumerable: false,
1764
- configurable: true
1765
- });
1766
- Object.defineProperty(FormDirective.prototype, "formDefinition", {
1767
- get: function () {
1768
- return this._formDefinition;
1769
- },
1770
- enumerable: false,
1771
- configurable: true
1772
- });
1773
- FormDirective.prototype.ngOnChanges = function (changes) {
1774
- _super.prototype.ngOnChanges.call(this, changes);
1775
- var formChange = changes.form;
1776
- if (formChange && !formChange.firstChange) {
1777
- this.loadInitialState(formChange.currentValue);
1778
- }
1779
- };
1780
- FormDirective.prototype.ngOnInit = function () {
1781
- var _this = this;
1782
- if (!this.form) {
1783
- // TODO : replace with rxap error
1784
- throw new Error('The form definition instance is not defined');
1785
- }
1786
- this.loadInitialState(this.form);
1787
- function HasNgOnInitMethod(obj) {
1788
- return obj && typeof obj.ngOnInit === 'function';
1789
- }
1790
- if (HasNgOnInitMethod(this._formDefinition)) {
1791
- this._formDefinition.ngOnInit();
1792
- }
1793
- if (this._formDefinition.rxapMetadata.autoSubmit) {
1794
- var debounce = typeof this._formDefinition.rxapMetadata.autoSubmit === 'number'
1795
- ? this._formDefinition.rxapMetadata.autoSubmit
1796
- : 5000;
1797
- this._autoSubmitSubscription = this.form.valueChanges
1798
- .pipe(operators.debounceTime(debounce), operators.filter(function () { return _this.form.valid; }), operators.tap(function (value) { return console.debug("Auto submit form '" + _this._formDefinition.rxapMetadata.id + "'", value); }), operators.tap(function () { return _this.submit(); }))
1799
- .subscribe();
1800
- }
1801
- };
1802
- FormDirective.prototype.onSubmit = function ($event) {
1803
- $event.preventDefault();
1804
- _super.prototype.onSubmit.call(this, $event);
1805
- if (this.form.valid) {
1806
- this.submit();
1807
- }
1808
- else {
1809
- function reduceErrors(control, errors) {
1810
- var e_1, _c, e_2, _d;
1811
- if (errors === void 0) { errors = {}; }
1812
- if (control.invalid) {
1813
- if (control.controls) {
1814
- if (Array.isArray(control.controls)) {
1815
- var errorList = [];
1816
- try {
1817
- for (var _e = __values(control.controls), _f = _e.next(); !_f.done; _f = _e.next()) {
1818
- var item = _f.value;
1819
- errorList.push(reduceErrors(item));
1820
- }
1821
- }
1822
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1823
- finally {
1824
- try {
1825
- if (_f && !_f.done && (_c = _e.return)) _c.call(_e);
1826
- }
1827
- finally { if (e_1) throw e_1.error; }
1828
- }
1829
- errors[control.controlId] = errorList;
1830
- }
1831
- else {
1832
- var innerErrors = {};
1833
- try {
1834
- for (var _g = __values(Object.values(control.controls)), _h = _g.next(); !_h.done; _h = _g.next()) {
1835
- var child = _h.value;
1836
- reduceErrors(child, innerErrors);
1837
- }
1838
- }
1839
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
1840
- finally {
1841
- try {
1842
- if (_h && !_h.done && (_d = _g.return)) _d.call(_g);
1843
- }
1844
- finally { if (e_2) throw e_2.error; }
1845
- }
1846
- errors[control.controlId] = innerErrors;
1847
- }
1848
- }
1849
- else {
1850
- if (control.errors) {
1851
- errors[control.controlId] = control.errors;
1852
- }
1853
- }
1854
- }
1855
- return errors;
1856
- }
1857
- if (i0.isDevMode()) {
1858
- console.log('Form submit is not valid for: ' + this.form.controlId, this.form.errors);
1859
- function printErrorControls(control) {
1860
- var e_3, _c, e_4, _d;
1861
- if (!control.valid) {
1862
- console.group(control.controlId);
1863
- if (control.controls) {
1864
- if (Array.isArray(control.controls)) {
1865
- for (var i = 0; i < control.controls.length; i++) {
1866
- var child = control.controls[i];
1867
- if (!child.valid) {
1868
- console.group("index: " + i);
1869
- printErrorControls(child);
1870
- console.groupEnd();
1871
- }
1872
- }
1873
- }
1874
- else {
1875
- try {
1876
- for (var _e = __values(Object.values(control.controls)), _f = _e.next(); !_f.done; _f = _e.next()) {
1877
- var child = _f.value;
1878
- printErrorControls(child);
1879
- }
1880
- }
1881
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
1882
- finally {
1883
- try {
1884
- if (_f && !_f.done && (_c = _e.return)) _c.call(_e);
1885
- }
1886
- finally { if (e_3) throw e_3.error; }
1887
- }
1888
- }
1889
- }
1890
- else {
1891
- if (control.errors) {
1892
- try {
1893
- for (var _g = __values(Object.entries(control.errors)), _h = _g.next(); !_h.done; _h = _g.next()) {
1894
- var _j = __read(_h.value, 2), key = _j[0], value = _j[1];
1895
- console.group(key);
1896
- console.log(value);
1897
- console.groupEnd();
1898
- }
1899
- }
1900
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
1901
- finally {
1902
- try {
1903
- if (_h && !_h.done && (_d = _g.return)) _d.call(_g);
1904
- }
1905
- finally { if (e_4) throw e_4.error; }
1906
- }
1907
- }
1908
- console.log('value: ', control.value);
1909
- }
1910
- console.groupEnd();
1911
- }
1912
- }
1913
- printErrorControls(this.form);
1914
- }
1915
- this.invalidSubmit.emit(reduceErrors(this.form));
1916
- }
1917
- return false;
1918
- };
1919
- FormDirective.prototype.loadInitialState = function (form) {
1920
- var _this = this;
1921
- if (this.initial) {
1922
- if (i0.isDevMode()) {
1923
- console.log('use the value from input initial');
1924
- }
1925
- form.patchValue(this.initial);
1926
- }
1927
- else {
1928
- if (this.loadMethod) {
1929
- this.loading$.enable();
1930
- try {
1931
- var resultOrPromise = this.loadMethod.call();
1932
- if (utilities.isPromise(resultOrPromise)) {
1933
- resultOrPromise
1934
- .then(function (value) {
1935
- form.patchValue(value);
1936
- _this.loaded$.enable();
1937
- _this.loadSuccessful(value);
1938
- })
1939
- .catch(function (error) {
1940
- _this.loadingError$.next(error);
1941
- _this.loadFailed(error);
1942
- })
1943
- .finally(function () {
1944
- _this.loading$.disable();
1945
- _this.cdr.detectChanges();
1946
- });
1947
- }
1948
- else if (utilities.isObject(resultOrPromise)) {
1949
- form.patchValue(resultOrPromise);
1950
- this.loaded$.enable();
1951
- this.loadSuccessful(resultOrPromise);
1952
- this.loading$.disable();
1953
- }
1954
- }
1955
- catch (error) {
1956
- this.loaded$.disable();
1957
- this.loadingError$.next(error);
1958
- this.loadFailed(error);
1959
- this.loading$.disable();
1960
- }
1961
- }
1962
- else {
1963
- if (i0.isDevMode()) {
1964
- console.warn('The form loading method is not defined for: ' + this.form.controlId);
1965
- }
1966
- this.loaded$.enable();
1967
- }
1968
- }
1969
- };
1970
- FormDirective.prototype.loadSuccessful = function (value) {
1971
- if (this.loadSuccessfulMethod) {
1972
- this.loadSuccessfulMethod.call(value);
1973
- }
1974
- else if (i0.isDevMode()) {
1975
- console.warn('The load successful is not defined for: ' + this.form.controlId);
1976
- }
1977
- };
1978
- FormDirective.prototype.loadFailed = function (error) {
1979
- var _a;
1980
- console.debug('Load Error:', error);
1981
- console.error('Load Error:', error.message);
1982
- if (this.loadFailedMethod) {
1983
- (_a = this.loadFailedMethod) === null || _a === void 0 ? void 0 : _a.call(error);
1984
- }
1985
- else if (i0.isDevMode()) {
1986
- console.warn('The form loading failed for: ' + this.form.controlId);
1987
- }
1988
- };
1989
- FormDirective.prototype.getSubmitValue = function () {
1990
- var value = undefined;
1991
- if (typeof this._formDefinition['getSubmitValue'] === 'function') {
1992
- value = this._formDefinition.getSubmitValue();
1993
- }
1994
- else if (typeof this._formDefinition['toJSON'] === 'function') {
1995
- value = this._formDefinition.toJSON();
1996
- }
1997
- value = value !== null && value !== void 0 ? value : this.form.value;
1998
- return utilities.clone(value);
1999
- };
2000
- FormDirective.prototype.submit = function () {
2001
- var _this = this;
2002
- var value = this.getSubmitValue();
2003
- if (this.submitMethod) {
2004
- Reflect.set(this, 'submitted', false);
2005
- this.submitting$.enable();
2006
- this.submitError$.next(null);
2007
- try {
2008
- var resultOrPromise = this.submitMethod.call(value);
2009
- if (utilities.isPromise(resultOrPromise)) {
2010
- resultOrPromise
2011
- .then(function (result) {
2012
- Reflect.set(_this, 'submitted', true);
2013
- _this.rxapSubmit.emit(result);
2014
- _this.submitSuccessful(result);
2015
- })
2016
- .catch(function (error) {
2017
- _this.submitError$.next(error);
2018
- _this.submitFailed(error);
2019
- })
2020
- .finally(function () {
2021
- _this.submitting$.disable();
2022
- _this.cdr.detectChanges();
2023
- });
2024
- }
2025
- else {
2026
- Reflect.set(this, 'submitted', true);
2027
- this.rxapSubmit.emit(resultOrPromise);
2028
- this.submitSuccessful(resultOrPromise);
2029
- this.submitting$.disable();
2030
- }
2031
- }
2032
- catch (error) {
2033
- this.submitting$.disable();
2034
- this.submitError$.next(error);
2035
- this.submitFailed(error);
2036
- }
2037
- }
2038
- else {
2039
- if (i0.isDevMode()) {
2040
- console.warn('The form submit method is not defined for: ' + this.form.controlId);
2041
- }
2042
- this.rxapSubmit.emit(value);
2043
- this.submitSuccessful(value);
2044
- }
2045
- };
2046
- FormDirective.prototype.submitFailed = function (error) {
2047
- console.debug('Submit Error:', error);
2048
- console.error('Submit Error:', error.message);
2049
- if (this.submitFailedMethod) {
2050
- this.submitFailedMethod.call(error);
2051
- }
2052
- else if (i0.isDevMode()) {
2053
- console.warn('The form submit failed method is not defined for: ' +
2054
- this.form.controlId);
2055
- }
2056
- };
2057
- FormDirective.prototype.submitSuccessful = function (value) {
2058
- this.submitSuccessful$.next(value);
2059
- if (this.submitSuccessfulMethod) {
2060
- this.submitSuccessfulMethod.call(value);
2061
- }
2062
- else if (i0.isDevMode()) {
2063
- console.warn('The form submit successful method is not defined for: ' +
2064
- this.form.controlId);
2065
- }
2066
- };
2067
- FormDirective.prototype.ngOnDestroy = function () {
2068
- var _a;
2069
- _super.prototype.ngOnDestroy.call(this);
2070
- (_a = this._autoSubmitSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
2071
- function HasNgOnDestroyMethod(obj) {
2072
- return obj && typeof obj.ngOnDestroy === 'function';
2073
- }
2074
- if (HasNgOnDestroyMethod(this._formDefinition)) {
2075
- this._formDefinition.ngOnDestroy();
2076
- }
2077
- };
2078
- return FormDirective;
2079
- }(i1.FormGroupDirective));
2080
- FormDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: FormDirective, deps: [{ token: i0.ChangeDetectorRef }, { token: RXAP_FORM_DEFINITION, optional: true }, { token: RXAP_FORM_SUBMIT_METHOD, optional: true, skipSelf: true }, { token: RXAP_FORM_LOAD_METHOD, optional: true, skipSelf: true }, { token: RXAP_FORM_LOAD_FAILED_METHOD, optional: true, skipSelf: true }, { token: RXAP_FORM_LOAD_SUCCESSFUL_METHOD, optional: true, skipSelf: true }, { token: RXAP_FORM_SUBMIT_FAILED_METHOD, optional: true, skipSelf: true }, { token: RXAP_FORM_SUBMIT_SUCCESSFUL_METHOD, optional: true, skipSelf: true }, { token: RXAP_FORM_DEFINITION_BUILDER, optional: true, skipSelf: true }, { token: i2.LoadingIndicatorService, optional: true }], target: i0__namespace.ɵɵFactoryTarget.Directive });
2081
- FormDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.0.1", type: FormDirective, selector: "form[rxapForm]:not([formGroup]):not([ngForm]),rxap-form,form[rxapForm]", inputs: { initial: "initial", useFormDefinition: ["rxapForm", "useFormDefinition"], submitMethod: "submitMethod" }, outputs: { ngSubmit: "ngSubmit", rxapSubmit: "rxapSubmit", invalidSubmit: "invalidSubmit", submitSuccessful$: "submitSuccessful" }, host: { listeners: { "reset": "onReset()" }, properties: { "class.rxap-submitting": "this.submitting", "class.rxap-submit-error": "this.submitError", "class.rxap-loading": "this.loading", "class.rxap-loaded": "this.loaded", "class.rxap-loading-error": "this.loadingError" } }, providers: [
2082
- {
2083
- provide: i1.ControlContainer,
2084
- // ignore coverage
2085
- useExisting: i0.forwardRef(function () { return FormDirective; })
2086
- },
2087
- // region form provider clear
2088
- // form provider that are directly associated with the current form
2089
- // are cleared to prevent that inner forms can access this providers
2090
- // Example: The parent form has a submit method provider and the inner should
2091
- // not have a submit method provider. If the parent submit method provider is
2092
- // not cleared then the inner form uses the parent submit method provider on
2093
- // submit
2094
- {
2095
- provide: RXAP_FORM_SUBMIT_METHOD,
2096
- useValue: null,
2097
- },
2098
- {
2099
- provide: RXAP_FORM_LOAD_METHOD,
2100
- useValue: null,
2101
- },
2102
- {
2103
- provide: RXAP_FORM_LOAD_FAILED_METHOD,
2104
- useValue: null,
2105
- },
2106
- {
2107
- provide: RXAP_FORM_LOAD_SUCCESSFUL_METHOD,
2108
- useValue: null,
2109
- },
2110
- {
2111
- provide: RXAP_FORM_SUBMIT_FAILED_METHOD,
2112
- useValue: null,
2113
- },
2114
- {
2115
- provide: RXAP_FORM_SUBMIT_SUCCESSFUL_METHOD,
2116
- useValue: null,
2117
- },
2118
- {
2119
- provide: RXAP_FORM_DEFINITION_BUILDER,
2120
- useValue: null,
2121
- },
2122
- // endregion
2123
- ], exportAs: ["rxapForm"], usesInheritance: true, usesOnChanges: true, ngImport: i0__namespace });
2124
- __decorate([
2125
- utilities.Required,
2126
- __metadata("design:type", Object)
2127
- ], FormDirective.prototype, "_formDefinition", void 0);
2128
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: FormDirective, decorators: [{
2129
- type: i0.Directive,
2130
- args: [{
2131
- selector: 'form[rxapForm]:not([formGroup]):not([ngForm]),rxap-form,form[rxapForm]',
2132
- providers: [
2133
- {
2134
- provide: i1.ControlContainer,
2135
- // ignore coverage
2136
- useExisting: i0.forwardRef(function () { return FormDirective; })
2137
- },
2138
- // region form provider clear
2139
- // form provider that are directly associated with the current form
2140
- // are cleared to prevent that inner forms can access this providers
2141
- // Example: The parent form has a submit method provider and the inner should
2142
- // not have a submit method provider. If the parent submit method provider is
2143
- // not cleared then the inner form uses the parent submit method provider on
2144
- // submit
2145
- {
2146
- provide: RXAP_FORM_SUBMIT_METHOD,
2147
- useValue: null,
2148
- },
2149
- {
2150
- provide: RXAP_FORM_LOAD_METHOD,
2151
- useValue: null,
2152
- },
2153
- {
2154
- provide: RXAP_FORM_LOAD_FAILED_METHOD,
2155
- useValue: null,
2156
- },
2157
- {
2158
- provide: RXAP_FORM_LOAD_SUCCESSFUL_METHOD,
2159
- useValue: null,
2160
- },
2161
- {
2162
- provide: RXAP_FORM_SUBMIT_FAILED_METHOD,
2163
- useValue: null,
2164
- },
2165
- {
2166
- provide: RXAP_FORM_SUBMIT_SUCCESSFUL_METHOD,
2167
- useValue: null,
2168
- },
2169
- {
2170
- provide: RXAP_FORM_DEFINITION_BUILDER,
2171
- useValue: null,
2172
- },
2173
- // endregion
2174
- ],
2175
- host: { '(reset)': 'onReset()' },
2176
- outputs: ['ngSubmit'],
2177
- exportAs: 'rxapForm',
2178
- }]
2179
- }], ctorParameters: function () {
2180
- return [{ type: i0__namespace.ChangeDetectorRef, decorators: [{
2181
- type: i0.Inject,
2182
- args: [i0.ChangeDetectorRef]
2183
- }] }, { type: undefined, decorators: [{
2184
- type: i0.Optional
2185
- }, {
2186
- type: i0.Inject,
2187
- args: [RXAP_FORM_DEFINITION]
2188
- }] }, { type: undefined, decorators: [{
2189
- type: i0.SkipSelf
2190
- }, {
2191
- type: i0.Optional
2192
- }, {
2193
- type: i0.Inject,
2194
- args: [RXAP_FORM_SUBMIT_METHOD]
2195
- }] }, { type: undefined, decorators: [{
2196
- type: i0.SkipSelf
2197
- }, {
2198
- type: i0.Optional
2199
- }, {
2200
- type: i0.Inject,
2201
- args: [RXAP_FORM_LOAD_METHOD]
2202
- }] }, { type: undefined, decorators: [{
2203
- type: i0.SkipSelf
2204
- }, {
2205
- type: i0.Optional
2206
- }, {
2207
- type: i0.Inject,
2208
- args: [RXAP_FORM_LOAD_FAILED_METHOD]
2209
- }] }, { type: undefined, decorators: [{
2210
- type: i0.SkipSelf
2211
- }, {
2212
- type: i0.Optional
2213
- }, {
2214
- type: i0.Inject,
2215
- args: [RXAP_FORM_LOAD_SUCCESSFUL_METHOD]
2216
- }] }, { type: undefined, decorators: [{
2217
- type: i0.SkipSelf
2218
- }, {
2219
- type: i0.Optional
2220
- }, {
2221
- type: i0.Inject,
2222
- args: [RXAP_FORM_SUBMIT_FAILED_METHOD]
2223
- }] }, { type: undefined, decorators: [{
2224
- type: i0.SkipSelf
2225
- }, {
2226
- type: i0.Optional
2227
- }, {
2228
- type: i0.Inject,
2229
- args: [RXAP_FORM_SUBMIT_SUCCESSFUL_METHOD]
2230
- }] }, { type: RxapFormBuilder, decorators: [{
2231
- type: i0.SkipSelf
2232
- }, {
2233
- type: i0.Optional
2234
- }, {
2235
- type: i0.Inject,
2236
- args: [RXAP_FORM_DEFINITION_BUILDER]
2237
- }] }, { type: i2__namespace.LoadingIndicatorService, decorators: [{
2238
- type: i0.Optional
2239
- }, {
2240
- type: i0.Inject,
2241
- args: [i2.LoadingIndicatorService]
2242
- }] }];
2243
- }, propDecorators: { initial: [{
2244
- type: i0.Input
2245
- }], rxapSubmit: [{
2246
- type: i0.Output
2247
- }], invalidSubmit: [{
2248
- type: i0.Output
2249
- }], submitSuccessful$: [{
2250
- type: i0.Output,
2251
- args: ['submitSuccessful']
2252
- }], submitting: [{
2253
- type: i0.HostBinding,
2254
- args: ['class.rxap-submitting']
2255
- }], submitError: [{
2256
- type: i0.HostBinding,
2257
- args: ['class.rxap-submit-error']
2258
- }], loading: [{
2259
- type: i0.HostBinding,
2260
- args: ['class.rxap-loading']
2261
- }], loaded: [{
2262
- type: i0.HostBinding,
2263
- args: ['class.rxap-loaded']
2264
- }], loadingError: [{
2265
- type: i0.HostBinding,
2266
- args: ['class.rxap-loading-error']
2267
- }], useFormDefinition: [{
2268
- type: i0.Input,
2269
- args: ['rxapForm']
2270
- }], _formDefinition: [], submitMethod: [{
2271
- type: i0.Input
2272
- }] } });
2273
-
2274
- var FormSubmitFailedDirective = /** @class */ (function () {
2275
- function FormSubmitFailedDirective(formDirective, template, viewContainerRef) {
2276
- this.formDirective = formDirective;
2277
- this.template = template;
2278
- this.viewContainerRef = viewContainerRef;
2279
- }
2280
- FormSubmitFailedDirective.prototype.ngAfterViewInit = function () {
2281
- var _this = this;
2282
- this.subscription = this.formDirective.submitError$.pipe(operators.tap(function (error) {
2283
- _this.viewContainerRef.clear();
2284
- if (error !== null) {
2285
- _this.viewContainerRef.createEmbeddedView(_this.template, { $implicit: error });
2286
- }
2287
- })).subscribe();
2288
- };
2289
- FormSubmitFailedDirective.prototype.ngOnDestroy = function () {
2290
- var _a;
2291
- (_a = this.subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
2292
- };
2293
- return FormSubmitFailedDirective;
2294
- }());
2295
- FormSubmitFailedDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: FormSubmitFailedDirective, deps: [{ token: FormDirective }, { token: i0.TemplateRef }, { token: i0.ViewContainerRef }], target: i0__namespace.ɵɵFactoryTarget.Directive });
2296
- FormSubmitFailedDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.0.1", type: FormSubmitFailedDirective, selector: "[rxapFormSubmitFailed]", ngImport: i0__namespace });
2297
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: FormSubmitFailedDirective, decorators: [{
2298
- type: i0.Directive,
2299
- args: [{
2300
- selector: '[rxapFormSubmitFailed]'
2301
- }]
2302
- }], ctorParameters: function () {
2303
- return [{ type: FormDirective, decorators: [{
2304
- type: i0.Inject,
2305
- args: [FormDirective]
2306
- }] }, { type: i0__namespace.TemplateRef, decorators: [{
2307
- type: i0.Inject,
2308
- args: [i0.TemplateRef]
2309
- }] }, { type: i0__namespace.ViewContainerRef, decorators: [{
2310
- type: i0.Inject,
2311
- args: [i0.ViewContainerRef]
2312
- }] }];
2313
- } });
2314
-
2315
- var FormLoadingDirective = /** @class */ (function () {
2316
- function FormLoadingDirective(formDirective, template, viewContainerRef) {
2317
- this.formDirective = formDirective;
2318
- this.template = template;
2319
- this.viewContainerRef = viewContainerRef;
2320
- }
2321
- FormLoadingDirective.prototype.ngAfterViewInit = function () {
2322
- var _this = this;
2323
- this.subscription = this.formDirective.loading$.pipe(operators.distinctUntilChanged(), operators.tap(function (loading) {
2324
- _this.viewContainerRef.clear();
2325
- if (loading) {
2326
- _this.viewContainerRef.createEmbeddedView(_this.template);
2327
- }
2328
- })).subscribe();
2329
- };
2330
- FormLoadingDirective.prototype.ngOnDestroy = function () {
2331
- var _a;
2332
- (_a = this.subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
2333
- };
2334
- return FormLoadingDirective;
2335
- }());
2336
- FormLoadingDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: FormLoadingDirective, deps: [{ token: FormDirective }, { token: i0.TemplateRef }, { token: i0.ViewContainerRef }], target: i0__namespace.ɵɵFactoryTarget.Directive });
2337
- FormLoadingDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.0.1", type: FormLoadingDirective, selector: "[rxapFormLoading]", ngImport: i0__namespace });
2338
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: FormLoadingDirective, decorators: [{
2339
- type: i0.Directive,
2340
- args: [{
2341
- selector: '[rxapFormLoading]'
2342
- }]
2343
- }], ctorParameters: function () {
2344
- return [{ type: FormDirective, decorators: [{
2345
- type: i0.Inject,
2346
- args: [FormDirective]
2347
- }] }, { type: i0__namespace.TemplateRef, decorators: [{
2348
- type: i0.Inject,
2349
- args: [i0.TemplateRef]
2350
- }] }, { type: i0__namespace.ViewContainerRef, decorators: [{
2351
- type: i0.Inject,
2352
- args: [i0.ViewContainerRef]
2353
- }] }];
2354
- } });
2355
-
2356
- var FormSubmittingDirective = /** @class */ (function () {
2357
- function FormSubmittingDirective(formDirective, template, viewContainerRef) {
2358
- this.formDirective = formDirective;
2359
- this.template = template;
2360
- this.viewContainerRef = viewContainerRef;
2361
- }
2362
- FormSubmittingDirective.prototype.ngAfterViewInit = function () {
2363
- var _this = this;
2364
- this.subscription = this.formDirective.submitting$.pipe(operators.distinctUntilChanged(), operators.tap(function (loading) {
2365
- _this.viewContainerRef.clear();
2366
- if (loading) {
2367
- _this.viewContainerRef.createEmbeddedView(_this.template);
2368
- }
2369
- })).subscribe();
2370
- };
2371
- FormSubmittingDirective.prototype.ngOnDestroy = function () {
2372
- var _a;
2373
- (_a = this.subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
2374
- };
2375
- return FormSubmittingDirective;
2376
- }());
2377
- FormSubmittingDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: FormSubmittingDirective, deps: [{ token: FormDirective }, { token: i0.TemplateRef }, { token: i0.ViewContainerRef }], target: i0__namespace.ɵɵFactoryTarget.Directive });
2378
- FormSubmittingDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.0.1", type: FormSubmittingDirective, selector: "[rxapFormSubmitting]", ngImport: i0__namespace });
2379
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: FormSubmittingDirective, decorators: [{
2380
- type: i0.Directive,
2381
- args: [{
2382
- selector: '[rxapFormSubmitting]'
2383
- }]
2384
- }], ctorParameters: function () {
2385
- return [{ type: FormDirective, decorators: [{
2386
- type: i0.Inject,
2387
- args: [FormDirective]
2388
- }] }, { type: i0__namespace.TemplateRef, decorators: [{
2389
- type: i0.Inject,
2390
- args: [i0.TemplateRef]
2391
- }] }, { type: i0__namespace.ViewContainerRef, decorators: [{
2392
- type: i0.Inject,
2393
- args: [i0.ViewContainerRef]
2394
- }] }];
2395
- } });
2396
-
2397
- var FormLoadedDirective = /** @class */ (function () {
2398
- function FormLoadedDirective(formDirective, template, viewContainerRef) {
2399
- this.formDirective = formDirective;
2400
- this.template = template;
2401
- this.viewContainerRef = viewContainerRef;
2402
- }
2403
- FormLoadedDirective.prototype.ngAfterViewInit = function () {
2404
- var _this = this;
2405
- this.subscription = this.formDirective.loaded$.pipe(operators.distinctUntilChanged(), operators.tap(function (loading) {
2406
- _this.viewContainerRef.clear();
2407
- if (loading) {
2408
- _this.viewContainerRef.createEmbeddedView(_this.template);
2409
- }
2410
- })).subscribe();
2411
- };
2412
- FormLoadedDirective.prototype.ngOnDestroy = function () {
2413
- var _a;
2414
- (_a = this.subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
2415
- };
2416
- return FormLoadedDirective;
2417
- }());
2418
- FormLoadedDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: FormLoadedDirective, deps: [{ token: FormDirective }, { token: i0.TemplateRef }, { token: i0.ViewContainerRef }], target: i0__namespace.ɵɵFactoryTarget.Directive });
2419
- FormLoadedDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.0.1", type: FormLoadedDirective, selector: "[rxapFormLoaded]", ngImport: i0__namespace });
2420
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: FormLoadedDirective, decorators: [{
2421
- type: i0.Directive,
2422
- args: [{
2423
- selector: '[rxapFormLoaded]'
2424
- }]
2425
- }], ctorParameters: function () {
2426
- return [{ type: FormDirective, decorators: [{
2427
- type: i0.Inject,
2428
- args: [FormDirective]
2429
- }] }, { type: i0__namespace.TemplateRef, decorators: [{
2430
- type: i0.Inject,
2431
- args: [i0.TemplateRef]
2432
- }] }, { type: i0__namespace.ViewContainerRef, decorators: [{
2433
- type: i0.Inject,
2434
- args: [i0.ViewContainerRef]
2435
- }] }];
2436
- } });
2437
-
2438
- var FormLoadingErrorDirective = /** @class */ (function () {
2439
- function FormLoadingErrorDirective(formDirective, template, viewContainerRef) {
2440
- this.formDirective = formDirective;
2441
- this.template = template;
2442
- this.viewContainerRef = viewContainerRef;
2443
- }
2444
- FormLoadingErrorDirective.prototype.ngAfterViewInit = function () {
2445
- var _this = this;
2446
- this.subscription = this.formDirective.loadingError$.pipe(operators.tap(function (error) {
2447
- _this.viewContainerRef.clear();
2448
- if (error !== null) {
2449
- _this.viewContainerRef.createEmbeddedView(_this.template, { $implicit: error });
2450
- }
2451
- })).subscribe();
2452
- };
2453
- FormLoadingErrorDirective.prototype.ngOnDestroy = function () {
2454
- var _a;
2455
- (_a = this.subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
2456
- };
2457
- return FormLoadingErrorDirective;
2458
- }());
2459
- FormLoadingErrorDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: FormLoadingErrorDirective, deps: [{ token: FormDirective }, { token: i0.TemplateRef }, { token: i0.ViewContainerRef }], target: i0__namespace.ɵɵFactoryTarget.Directive });
2460
- FormLoadingErrorDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.0.1", type: FormLoadingErrorDirective, selector: "[rxapFormLoadingError]", ngImport: i0__namespace });
2461
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: FormLoadingErrorDirective, decorators: [{
2462
- type: i0.Directive,
2463
- args: [{
2464
- selector: '[rxapFormLoadingError]'
2465
- }]
2466
- }], ctorParameters: function () {
2467
- return [{ type: FormDirective, decorators: [{
2468
- type: i0.Inject,
2469
- args: [FormDirective]
2470
- }] }, { type: i0__namespace.TemplateRef, decorators: [{
2471
- type: i0.Inject,
2472
- args: [i0.TemplateRef]
2473
- }] }, { type: i0__namespace.ViewContainerRef, decorators: [{
2474
- type: i0.Inject,
2475
- args: [i0.ViewContainerRef]
2476
- }] }];
2477
- } });
2478
-
2479
- /**
2480
- * @deprecated removed
2481
- */
2482
- var FormControlErrorDirective = /** @class */ (function () {
2483
- function FormControlErrorDirective(template, parent, viewContainerRef) {
2484
- this.template = template;
2485
- this.parent = parent;
2486
- this.viewContainerRef = viewContainerRef;
2487
- }
2488
- FormControlErrorDirective.prototype.ngOnInit = function () {
2489
- var _this = this;
2490
- var _a;
2491
- var control = (_a = this.parent.control) === null || _a === void 0 ? void 0 : _a.get(this.name);
2492
- if (!control) {
2493
- throw new Error('Could not extract form control instance');
2494
- }
2495
- this.subscription = control.statusChanges.pipe(operators.startWith(control.status), operators.filter(function (status) { return status === 'INVALID'; }), operators.tap(function () {
2496
- _this.viewContainerRef.clear();
2497
- if (control.hasError(_this.errorKey)) {
2498
- _this.viewContainerRef.createEmbeddedView(_this.template, { $implicit: control.getError(_this.errorKey) });
2499
- }
2500
- })).subscribe();
2501
- };
2502
- FormControlErrorDirective.prototype.ngOnDestroy = function () {
2503
- var _a;
2504
- (_a = this.subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
2505
- };
2506
- return FormControlErrorDirective;
2507
- }());
2508
- FormControlErrorDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: FormControlErrorDirective, deps: [{ token: i0__namespace.TemplateRef }, { token: i1__namespace.ControlContainer, host: true, skipSelf: true }, { token: i0__namespace.ViewContainerRef }], target: i0__namespace.ɵɵFactoryTarget.Directive });
2509
- FormControlErrorDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.0.1", type: FormControlErrorDirective, selector: "[rxapFormControlError]", inputs: { name: ["rxapFormControlErrorFrom", "name"], errorKey: ["rxapFormControlErrorIf", "errorKey"] }, ngImport: i0__namespace });
2510
- __decorate([
2511
- utilities.Required,
2512
- __metadata("design:type", String)
2513
- ], FormControlErrorDirective.prototype, "name", void 0);
2514
- __decorate([
2515
- utilities.Required,
2516
- __metadata("design:type", String)
2517
- ], FormControlErrorDirective.prototype, "errorKey", void 0);
2518
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: FormControlErrorDirective, decorators: [{
2519
- type: i0.Directive,
2520
- args: [{
2521
- selector: '[rxapFormControlError]'
2522
- }]
2523
- }], ctorParameters: function () {
2524
- return [{ type: i0__namespace.TemplateRef }, { type: i1__namespace.ControlContainer, decorators: [{
2525
- type: i0.Host
2526
- }, {
2527
- type: i0.SkipSelf
2528
- }] }, { type: i0__namespace.ViewContainerRef }];
2529
- }, propDecorators: { name: [{
2530
- type: i0.Input,
2531
- args: ['rxapFormControlErrorFrom']
2532
- }], errorKey: [{
2533
- type: i0.Input,
2534
- args: ['rxapFormControlErrorIf']
2535
- }] } });
2536
-
2537
- var FormControlMarkDirtyDirective = /** @class */ (function () {
2538
- function FormControlMarkDirtyDirective(parent) {
2539
- this.parent = parent;
2540
- }
2541
- FormControlMarkDirtyDirective.prototype.onClick = function () {
2542
- var control = this.parent.control;
2543
- if (control && utilities.hasIndexSignature(control) && typeof control['markAllAsDirty'] === 'function') {
2544
- control.markAllAsDirty();
2545
- }
2546
- else {
2547
- control === null || control === void 0 ? void 0 : control.markAsDirty();
2548
- }
2549
- };
2550
- return FormControlMarkDirtyDirective;
2551
- }());
2552
- FormControlMarkDirtyDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: FormControlMarkDirtyDirective, deps: [{ token: i1__namespace.ControlContainer }], target: i0__namespace.ɵɵFactoryTarget.Directive });
2553
- FormControlMarkDirtyDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.0.1", type: FormControlMarkDirtyDirective, selector: "[rxapFormControlMarkDirty]", host: { listeners: { "click": "onClick()" } }, ngImport: i0__namespace });
2554
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: FormControlMarkDirtyDirective, decorators: [{
2555
- type: i0.Directive,
2556
- args: [{
2557
- selector: '[rxapFormControlMarkDirty]'
2558
- }]
2559
- }], ctorParameters: function () { return [{ type: i1__namespace.ControlContainer }]; }, propDecorators: { onClick: [{
2560
- type: i0.HostListener,
2561
- args: ['click']
2562
- }] } });
2563
-
2564
- var FormControlMarkTouchedDirective = /** @class */ (function () {
2565
- function FormControlMarkTouchedDirective(parent) {
2566
- this.parent = parent;
2567
- }
2568
- FormControlMarkTouchedDirective.prototype.onClick = function () {
2569
- var _a;
2570
- (_a = this.parent.control) === null || _a === void 0 ? void 0 : _a.markAllAsTouched();
2571
- };
2572
- return FormControlMarkTouchedDirective;
2573
- }());
2574
- FormControlMarkTouchedDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: FormControlMarkTouchedDirective, deps: [{ token: i1__namespace.ControlContainer }], target: i0__namespace.ɵɵFactoryTarget.Directive });
2575
- FormControlMarkTouchedDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.0.1", type: FormControlMarkTouchedDirective, selector: "[rxapFormControlMarkTouched]", host: { listeners: { "click": "onClick()" } }, ngImport: i0__namespace });
2576
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: FormControlMarkTouchedDirective, decorators: [{
2577
- type: i0.Directive,
2578
- args: [{
2579
- selector: '[rxapFormControlMarkTouched]'
2580
- }]
2581
- }], ctorParameters: function () { return [{ type: i1__namespace.ControlContainer }]; }, propDecorators: { onClick: [{
2582
- type: i0.HostListener,
2583
- args: ['click']
2584
- }] } });
2585
-
2586
- var FormControlMarkUntouchedDirective = /** @class */ (function () {
2587
- function FormControlMarkUntouchedDirective(parent) {
2588
- this.parent = parent;
2589
- }
2590
- FormControlMarkUntouchedDirective.prototype.onClick = function () {
2591
- var control = this.parent.control;
2592
- if (control && utilities.hasIndexSignature(control) && typeof control['markAllAsUntouched'] === 'function') {
2593
- control.markAllAsUntouched();
2594
- }
2595
- else {
2596
- control === null || control === void 0 ? void 0 : control.markAsUntouched();
2597
- }
2598
- };
2599
- return FormControlMarkUntouchedDirective;
2600
- }());
2601
- FormControlMarkUntouchedDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: FormControlMarkUntouchedDirective, deps: [{ token: i1__namespace.ControlContainer }], target: i0__namespace.ɵɵFactoryTarget.Directive });
2602
- FormControlMarkUntouchedDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.0.1", type: FormControlMarkUntouchedDirective, selector: "[rxapFormControlMarkUntouched]", host: { listeners: { "click": "onClick()" } }, ngImport: i0__namespace });
2603
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: FormControlMarkUntouchedDirective, decorators: [{
2604
- type: i0.Directive,
2605
- args: [{
2606
- selector: '[rxapFormControlMarkUntouched]'
2607
- }]
2608
- }], ctorParameters: function () { return [{ type: i1__namespace.ControlContainer }]; }, propDecorators: { onClick: [{
2609
- type: i0.HostListener,
2610
- args: ['click']
2611
- }] } });
2612
-
2613
- var FormControlMarkPristineDirective = /** @class */ (function () {
2614
- function FormControlMarkPristineDirective(parent) {
2615
- this.parent = parent;
2616
- }
2617
- FormControlMarkPristineDirective.prototype.onClick = function () {
2618
- var control = this.parent.control;
2619
- if (control && utilities.hasIndexSignature(control) && typeof control['markAllAsPristine'] === 'function') {
2620
- control.markAllAsPristine();
2621
- }
2622
- else {
2623
- control === null || control === void 0 ? void 0 : control.markAsPristine();
2624
- }
2625
- };
2626
- return FormControlMarkPristineDirective;
2627
- }());
2628
- FormControlMarkPristineDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: FormControlMarkPristineDirective, deps: [{ token: i1__namespace.ControlContainer }], target: i0__namespace.ɵɵFactoryTarget.Directive });
2629
- FormControlMarkPristineDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.0.1", type: FormControlMarkPristineDirective, selector: "[rxapFormControlMarkPristine]", host: { listeners: { "click": "onClick()" } }, ngImport: i0__namespace });
2630
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: FormControlMarkPristineDirective, decorators: [{
2631
- type: i0.Directive,
2632
- args: [{
2633
- selector: '[rxapFormControlMarkPristine]'
2634
- }]
2635
- }], ctorParameters: function () { return [{ type: i1__namespace.ControlContainer }]; }, propDecorators: { onClick: [{
2636
- type: i0.HostListener,
2637
- args: ['click']
2638
- }] } });
2639
-
2640
- var FormSubmitDirective = /** @class */ (function (_super) {
2641
- __extends(FormSubmitDirective, _super);
2642
- function FormSubmitDirective(formDirective, router) {
2643
- if (router === void 0) { router = null; }
2644
- var _this = _super.call(this) || this;
2645
- _this.formDirective = formDirective;
2646
- _this.router = router;
2647
- _this.type = 'button';
2648
- _this.afterSubmit = new i0.EventEmitter();
2649
- _this._resetAfterSubmit = false;
2650
- return _this;
2651
- }
2652
- Object.defineProperty(FormSubmitDirective.prototype, "resetAfterSubmit", {
2653
- set: function (value) {
2654
- this._resetAfterSubmit = utilities.coerceBoolean(value);
2655
- },
2656
- enumerable: false,
2657
- configurable: true
2658
- });
2659
- FormSubmitDirective.prototype.execute = function () {
2660
- var _this = this;
2661
- this.subscription = this.formDirective.rxapSubmit.pipe(operators.take(1), operators.tap(function (event) {
2662
- _this.afterSubmit.emit(event);
2663
- if (_this._resetAfterSubmit) {
2664
- _this.formDirective.reset();
2665
- }
2666
- if (_this.navigateAfterSubmit) {
2667
- if (!_this.router) {
2668
- throw new Error('Could not resolve the router!');
2669
- }
2670
- return _this.router.navigate(_this.navigateAfterSubmit);
2671
- }
2672
- return Promise.resolve();
2673
- })).subscribe();
2674
- this.formDirective.onSubmit(new Event('submit'));
2675
- };
2676
- FormSubmitDirective.prototype.ngOnDestroy = function () {
2677
- var _a;
2678
- (_a = this.subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
2679
- };
2680
- return FormSubmitDirective;
2681
- }(directives.ConfirmClick));
2682
- FormSubmitDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: FormSubmitDirective, deps: [{ token: FormDirective }, { token: i2$1.Router, optional: true }], target: i0__namespace.ɵɵFactoryTarget.Directive });
2683
- FormSubmitDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.0.1", type: FormSubmitDirective, selector: "[rxapFormSubmit]", inputs: { type: "type", resetAfterSubmit: "resetAfterSubmit", navigateAfterSubmit: "navigateAfterSubmit" }, outputs: { afterSubmit: "afterSubmit" }, host: { listeners: { "click": "onClick()", "confirmed": "onConfirm()" }, properties: { "type": "this.type" } }, usesInheritance: true, ngImport: i0__namespace });
2684
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: FormSubmitDirective, decorators: [{
2685
- type: i0.Directive,
2686
- args: [{
2687
- selector: '[rxapFormSubmit]',
2688
- host: {
2689
- '(click)': 'onClick()',
2690
- '(confirmed)': 'onConfirm()',
2691
- }
2692
- }]
2693
- }], ctorParameters: function () {
2694
- return [{ type: FormDirective, decorators: [{
2695
- type: i0.Inject,
2696
- args: [FormDirective]
2697
- }] }, { type: i2__namespace$1.Router, decorators: [{
2698
- type: i0.Optional
2699
- }, {
2700
- type: i0.Inject,
2701
- args: [i2$1.Router]
2702
- }] }];
2703
- }, propDecorators: { type: [{
2704
- type: i0.HostBinding,
2705
- args: ['type']
2706
- }, {
2707
- type: i0.Input
2708
- }], resetAfterSubmit: [{
2709
- type: i0.Input,
2710
- args: ['resetAfterSubmit']
2711
- }], navigateAfterSubmit: [{
2712
- type: i0.Input
2713
- }], afterSubmit: [{
2714
- type: i0.Output
2715
- }] } });
2716
-
2717
- /**
2718
- * A full exertion of FormGroupName from @angular/forms. The only change is the
2719
- * ability to access the control container outside of the current component
2720
- *
2721
- * @deprecated use the ParentControlContainerDirective
2722
- */
2723
- var FormGroupNameDirective = /** @class */ (function (_super) {
2724
- __extends(FormGroupNameDirective, _super);
2725
- function FormGroupNameDirective(parent, validators, asyncValidators) {
2726
- return _super.call(this, parent, validators, asyncValidators) || this;
2727
- }
2728
- Object.defineProperty(FormGroupNameDirective.prototype, "control", {
2729
- get: function () {
2730
- // TODO : add type check
2731
- return this.formDirective.getFormGroup(this);
2732
- },
2733
- enumerable: false,
2734
- configurable: true
2735
- });
2736
- return FormGroupNameDirective;
2737
- }(i1.FormGroupName));
2738
- FormGroupNameDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: FormGroupNameDirective, deps: [{ token: i1__namespace.ControlContainer, optional: true, skipSelf: true }, { token: i1.NG_VALIDATORS, optional: true, self: true }, { token: i1.NG_ASYNC_VALIDATORS, optional: true, self: true }], target: i0__namespace.ɵɵFactoryTarget.Directive });
2739
- FormGroupNameDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.0.1", type: FormGroupNameDirective, selector: "[rxapFormGroupName]", inputs: { name: ["rxapFormGroupName", "name"] }, providers: [
2740
- {
2741
- provide: i1.ControlContainer,
2742
- useExisting: i0.forwardRef(function () { return FormGroupNameDirective; })
2743
- }
2744
- ], exportAs: ["rxapFormGroup"], usesInheritance: true, ngImport: i0__namespace });
2745
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: FormGroupNameDirective, decorators: [{
2746
- type: i0.Directive,
2747
- args: [{
2748
- selector: '[rxapFormGroupName]',
2749
- providers: [
2750
- {
2751
- provide: i1.ControlContainer,
2752
- useExisting: i0.forwardRef(function () { return FormGroupNameDirective; })
2753
- }
2754
- ],
2755
- exportAs: 'rxapFormGroup'
2756
- }]
2757
- }], ctorParameters: function () {
2758
- return [{ type: i1__namespace.ControlContainer, decorators: [{
2759
- type: i0.Optional
2760
- }, {
2761
- type: i0.SkipSelf
2762
- }] }, { type: undefined, decorators: [{
2763
- type: i0.Optional
2764
- }, {
2765
- type: i0.Self
2766
- }, {
2767
- type: i0.Inject,
2768
- args: [i1.NG_VALIDATORS]
2769
- }] }, { type: undefined, decorators: [{
2770
- type: i0.Optional
2771
- }, {
2772
- type: i0.Self
2773
- }, {
2774
- type: i0.Inject,
2775
- args: [i1.NG_ASYNC_VALIDATORS]
2776
- }] }];
2777
- }, propDecorators: { name: [{
2778
- type: i0.Input,
2779
- args: ['rxapFormGroupName']
2780
- }] } });
2781
-
2782
- /**
2783
- * A full exertion of FormControlName from @angular/forms. The only change is the
2784
- * ability to access the control container outside of the current component
2785
- *
2786
- * @deprecated use the ParentControlContainerDirective
2787
- */
2788
- var FormControlNameDirective = /** @class */ (function (_super) {
2789
- __extends(FormControlNameDirective, _super);
2790
- function FormControlNameDirective(parent, validators, asyncValidators, valueAccessors) {
2791
- return _super.call(this, parent, validators, asyncValidators, valueAccessors, null) || this;
2792
- }
2793
- return FormControlNameDirective;
2794
- }(i1.FormControlName));
2795
- FormControlNameDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: FormControlNameDirective, deps: [{ token: i1__namespace.ControlContainer, optional: true, skipSelf: true }, { token: i1.NG_VALIDATORS, optional: true, self: true }, { token: i1.NG_ASYNC_VALIDATORS, optional: true, self: true }, { token: i1.NG_VALUE_ACCESSOR, optional: true, self: true }], target: i0__namespace.ɵɵFactoryTarget.Directive });
2796
- FormControlNameDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.0.1", type: FormControlNameDirective, selector: "[rxapFormControlName]", inputs: { name: ["rxapFormControlName", "name"] }, providers: [
2797
- {
2798
- provide: i1.NgControl,
2799
- useExisting: i0.forwardRef(function () { return FormControlNameDirective; })
2800
- }
2801
- ], exportAs: ["rxapFormControl"], usesInheritance: true, ngImport: i0__namespace });
2802
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: FormControlNameDirective, decorators: [{
2803
- type: i0.Directive,
2804
- args: [{
2805
- selector: '[rxapFormControlName]',
2806
- providers: [
2807
- {
2808
- provide: i1.NgControl,
2809
- useExisting: i0.forwardRef(function () { return FormControlNameDirective; })
2810
- }
2811
- ],
2812
- exportAs: 'rxapFormControl'
2813
- }]
2814
- }], ctorParameters: function () {
2815
- return [{ type: i1__namespace.ControlContainer, decorators: [{
2816
- type: i0.Optional
2817
- }, {
2818
- type: i0.SkipSelf
2819
- }] }, { type: Array, decorators: [{
2820
- type: i0.Optional
2821
- }, {
2822
- type: i0.Self
2823
- }, {
2824
- type: i0.Inject,
2825
- args: [i1.NG_VALIDATORS]
2826
- }] }, { type: Array, decorators: [{
2827
- type: i0.Optional
2828
- }, {
2829
- type: i0.Self
2830
- }, {
2831
- type: i0.Inject,
2832
- args: [i1.NG_ASYNC_VALIDATORS]
2833
- }] }, { type: undefined, decorators: [{
2834
- type: i0.Optional
2835
- }, {
2836
- type: i0.Self
2837
- }, {
2838
- type: i0.Inject,
2839
- args: [i1.NG_VALUE_ACCESSOR]
2840
- }] }];
2841
- }, propDecorators: { name: [{
2842
- type: i0.Input,
2843
- args: ['rxapFormControlName']
2844
- }] } });
2845
-
2846
- var ParentControlContainerDirective = /** @class */ (function () {
2847
- function ParentControlContainerDirective() {
2848
- }
2849
- return ParentControlContainerDirective;
2850
- }());
2851
- ParentControlContainerDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: ParentControlContainerDirective, deps: [], target: i0__namespace.ɵɵFactoryTarget.Directive });
2852
- ParentControlContainerDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.0.1", type: ParentControlContainerDirective, selector: "[formControlName][parentControlContainer],[formControlGroup][parentControlContainer]", providers: [
2853
- {
2854
- provide: i1.ControlContainer,
2855
- useExisting: i1.ControlContainer
2856
- }
2857
- ], ngImport: i0__namespace });
2858
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: ParentControlContainerDirective, decorators: [{
2859
- type: i0.Directive,
2860
- args: [{
2861
- selector: '[formControlName][parentControlContainer],[formControlGroup][parentControlContainer]',
2862
- providers: [
2863
- {
2864
- provide: i1.ControlContainer,
2865
- useExisting: i1.ControlContainer
2866
- }
2867
- ]
2868
- }]
2869
- }] });
2870
-
2871
- var FormSubmitSuccessfulDirective = /** @class */ (function () {
2872
- function FormSubmitSuccessfulDirective(formDirective, template, viewContainerRef) {
2873
- this.formDirective = formDirective;
2874
- this.template = template;
2875
- this.viewContainerRef = viewContainerRef;
2876
- }
2877
- FormSubmitSuccessfulDirective.prototype.ngAfterViewInit = function () {
2878
- var _this = this;
2879
- this.subscription = this.formDirective.submitSuccessful$.pipe(operators.tap(function (result) {
2880
- _this.viewContainerRef.clear();
2881
- _this.viewContainerRef.createEmbeddedView(_this.template, { $implicit: result });
2882
- })).subscribe();
2883
- };
2884
- FormSubmitSuccessfulDirective.prototype.ngOnDestroy = function () {
2885
- var _a;
2886
- (_a = this.subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
2887
- };
2888
- return FormSubmitSuccessfulDirective;
2889
- }());
2890
- FormSubmitSuccessfulDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: FormSubmitSuccessfulDirective, deps: [{ token: FormDirective }, { token: i0.TemplateRef }, { token: i0.ViewContainerRef }], target: i0__namespace.ɵɵFactoryTarget.Directive });
2891
- FormSubmitSuccessfulDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.0.1", type: FormSubmitSuccessfulDirective, selector: "[rxapFormSubmitSuccessful]", ngImport: i0__namespace });
2892
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: FormSubmitSuccessfulDirective, decorators: [{
2893
- type: i0.Directive,
2894
- args: [{
2895
- selector: '[rxapFormSubmitSuccessful]'
2896
- }]
2897
- }], ctorParameters: function () {
2898
- return [{ type: FormDirective, decorators: [{
2899
- type: i0.Inject,
2900
- args: [FormDirective]
2901
- }] }, { type: i0__namespace.TemplateRef, decorators: [{
2902
- type: i0.Inject,
2903
- args: [i0.TemplateRef]
2904
- }] }, { type: i0__namespace.ViewContainerRef, decorators: [{
2905
- type: i0.Inject,
2906
- args: [i0.ViewContainerRef]
2907
- }] }];
2908
- } });
2909
-
2910
- var FormSubmitInvalidDirective = /** @class */ (function () {
2911
- function FormSubmitInvalidDirective(formDirective, template, viewContainerRef) {
2912
- this.formDirective = formDirective;
2913
- this.template = template;
2914
- this.viewContainerRef = viewContainerRef;
2915
- }
2916
- FormSubmitInvalidDirective.prototype.ngAfterViewInit = function () {
2917
- var _this = this;
2918
- this.subscription = this.formDirective.invalidSubmit.pipe(operators.tap(function (result) {
2919
- _this.viewContainerRef.clear();
2920
- _this.viewContainerRef.createEmbeddedView(_this.template, { $implicit: result });
2921
- })).subscribe();
2922
- };
2923
- FormSubmitInvalidDirective.prototype.ngOnDestroy = function () {
2924
- var _a;
2925
- (_a = this.subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
2926
- };
2927
- return FormSubmitInvalidDirective;
2928
- }());
2929
- FormSubmitInvalidDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: FormSubmitInvalidDirective, deps: [{ token: FormDirective }, { token: i0.TemplateRef }, { token: i0.ViewContainerRef }], target: i0__namespace.ɵɵFactoryTarget.Directive });
2930
- FormSubmitInvalidDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.0.1", type: FormSubmitInvalidDirective, selector: "[rxapFormSubmitInvalid]", ngImport: i0__namespace });
2931
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: FormSubmitInvalidDirective, decorators: [{
2932
- type: i0.Directive,
2933
- args: [{
2934
- selector: '[rxapFormSubmitInvalid]'
2935
- }]
2936
- }], ctorParameters: function () {
2937
- return [{ type: FormDirective, decorators: [{
2938
- type: i0.Inject,
2939
- args: [FormDirective]
2940
- }] }, { type: i0__namespace.TemplateRef, decorators: [{
2941
- type: i0.Inject,
2942
- args: [i0.TemplateRef]
2943
- }] }, { type: i0__namespace.ViewContainerRef, decorators: [{
2944
- type: i0.Inject,
2945
- args: [i0.ViewContainerRef]
2946
- }] }];
2947
- } });
2948
-
2949
- var RxapFormsModule = /** @class */ (function () {
2950
- function RxapFormsModule() {
2951
- }
2952
- return RxapFormsModule;
2953
- }());
2954
- RxapFormsModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: RxapFormsModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
2955
- RxapFormsModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: RxapFormsModule, declarations: [FormDirective,
2956
- FormSubmitFailedDirective,
2957
- FormLoadingDirective,
2958
- FormSubmittingDirective,
2959
- FormLoadingErrorDirective,
2960
- FormLoadedDirective,
2961
- FormControlErrorDirective,
2962
- FormControlMarkDirtyDirective,
2963
- FormControlMarkTouchedDirective,
2964
- FormControlMarkUntouchedDirective,
2965
- FormControlMarkPristineDirective,
2966
- FormSubmitDirective,
2967
- FormGroupNameDirective,
2968
- FormControlNameDirective,
2969
- ParentControlContainerDirective,
2970
- FormSubmitSuccessfulDirective,
2971
- FormSubmitInvalidDirective], exports: [FormDirective,
2972
- FormSubmitFailedDirective,
2973
- FormLoadingDirective,
2974
- FormSubmittingDirective,
2975
- FormLoadingErrorDirective,
2976
- FormLoadedDirective,
2977
- FormControlErrorDirective,
2978
- FormControlMarkDirtyDirective,
2979
- FormControlMarkTouchedDirective,
2980
- FormControlMarkUntouchedDirective,
2981
- FormControlMarkPristineDirective,
2982
- FormSubmitDirective,
2983
- FormGroupNameDirective,
2984
- FormControlNameDirective,
2985
- ParentControlContainerDirective,
2986
- FormSubmitSuccessfulDirective,
2987
- FormSubmitInvalidDirective] });
2988
- RxapFormsModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: RxapFormsModule });
2989
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.0.1", ngImport: i0__namespace, type: RxapFormsModule, decorators: [{
2990
- type: i0.NgModule,
2991
- args: [{
2992
- declarations: [
2993
- FormDirective,
2994
- FormSubmitFailedDirective,
2995
- FormLoadingDirective,
2996
- FormSubmittingDirective,
2997
- FormLoadingErrorDirective,
2998
- FormLoadedDirective,
2999
- FormControlErrorDirective,
3000
- FormControlMarkDirtyDirective,
3001
- FormControlMarkTouchedDirective,
3002
- FormControlMarkUntouchedDirective,
3003
- FormControlMarkPristineDirective,
3004
- FormSubmitDirective,
3005
- FormGroupNameDirective,
3006
- FormControlNameDirective,
3007
- ParentControlContainerDirective,
3008
- FormSubmitSuccessfulDirective,
3009
- FormSubmitInvalidDirective,
3010
- ],
3011
- exports: [
3012
- FormDirective,
3013
- FormSubmitFailedDirective,
3014
- FormLoadingDirective,
3015
- FormSubmittingDirective,
3016
- FormLoadingErrorDirective,
3017
- FormLoadedDirective,
3018
- FormControlErrorDirective,
3019
- FormControlMarkDirtyDirective,
3020
- FormControlMarkTouchedDirective,
3021
- FormControlMarkUntouchedDirective,
3022
- FormControlMarkPristineDirective,
3023
- FormSubmitDirective,
3024
- FormGroupNameDirective,
3025
- FormControlNameDirective,
3026
- ParentControlContainerDirective,
3027
- FormSubmitSuccessfulDirective,
3028
- FormSubmitInvalidDirective,
3029
- ]
3030
- }]
3031
- }] });
3032
-
3033
- function ToFormMethod(call) {
3034
- return { call: call };
3035
- }
3036
- /**
3037
- * @deprecated use ToFormMethod instead
3038
- *
3039
- * @param call the call method implementation
3040
- */
3041
- function ToFormSubmitMethod(call) {
3042
- return ToFormMethod(call);
3043
- }
3044
-
3045
- /**
3046
- * Checks if a given value is a number.
3047
- */
3048
- function isNumber(value, options) {
3049
- if (options === void 0) { options = {}; }
3050
- var _a, _b;
3051
- if (typeof value !== 'number') {
3052
- return false;
3053
- }
3054
- if (value === Infinity || value === -Infinity) {
3055
- return (_a = options.allowInfinity) !== null && _a !== void 0 ? _a : false;
3056
- }
3057
- if (Number.isNaN(value)) {
3058
- return (_b = options.allowNaN) !== null && _b !== void 0 ? _b : false;
3059
- }
3060
- if (options.maxDecimalPlaces !== undefined) {
3061
- var decimalPlaces = 0;
3062
- if (value % 1 !== 0) {
3063
- decimalPlaces = value.toString().split('.')[1].length;
3064
- }
3065
- if (decimalPlaces > options.maxDecimalPlaces) {
3066
- return false;
3067
- }
3068
- }
3069
- return Number.isFinite(value);
3070
- }
3071
- /**
3072
- * @deprecated use RxapValidators.isNumber() instead
3073
- * @param control
3074
- * @constructor
3075
- */
3076
- function IsNumber(control) {
3077
- if (control.value === null) {
3078
- return null;
3079
- }
3080
- if (isNaN(Number(control.value))) {
3081
- return { isNumber: { expected: 'A number or a string representing a number', actual: control.value } };
3082
- }
3083
- return null;
3084
- }
3085
- function _IsNumber(_c) {
3086
- var _d = _c === void 0 ? {} : _c, message = _d.message, options = _d.options;
3087
- return function (control) {
3088
- if (control.value === null) {
3089
- return null;
3090
- }
3091
- if (!isNumber(!(options === null || options === void 0 ? void 0 : options.strict) && typeof control.value === 'string' ? Number(control.value) : control.value, options)) {
3092
- return {
3093
- isNumber: {
3094
- expected: 'A number value',
3095
- actual: control.value,
3096
- message: message
3097
- }
3098
- };
3099
- }
3100
- return null;
3101
- };
3102
- }
3103
-
3104
- function IsBoolean(_a) {
3105
- var _b = _a === void 0 ? {} : _a, message = _b.message;
3106
- return function (control) {
3107
- if (control.value === null) {
3108
- return null;
3109
- }
3110
- if (!(control.value instanceof Boolean || typeof control.value === 'boolean')) {
3111
- return {
3112
- isBoolean: {
3113
- expected: 'A boolean value',
3114
- actual: control.value,
3115
- message: message
3116
- }
3117
- };
3118
- }
3119
- return null;
3120
- };
3121
- }
3122
-
3123
- function IsObject(_a) {
3124
- var _b = _a === void 0 ? {} : _a, message = _b.message;
3125
- return function (control) {
3126
- if (control.value === null) {
3127
- return null;
3128
- }
3129
- if (!(control.value !== undefined && (typeof control.value === 'object' || typeof control.value === 'function') && !Array.isArray(control.value))) {
3130
- return {
3131
- isObject: {
3132
- expected: 'A object value',
3133
- actual: control.value,
3134
- message: message
3135
- }
3136
- };
3137
- }
3138
- return null;
3139
- };
3140
- }
3141
-
3142
- function IsString(_a) {
3143
- var _b = _a === void 0 ? {} : _a, message = _b.message;
3144
- return function (control) {
3145
- if (control.value === null) {
3146
- return null;
3147
- }
3148
- if (!(control.value instanceof String || typeof control.value === 'string')) {
3149
- return {
3150
- isString: {
3151
- expected: 'A string value',
3152
- actual: control.value,
3153
- message: message
3154
- }
3155
- };
3156
- }
3157
- return null;
3158
- };
3159
- }
3160
-
3161
- function IsInt(_a) {
3162
- var _b = _a === void 0 ? {} : _a, message = _b.message, options = _b.options;
3163
- return function (control) {
3164
- if (control.value === null) {
3165
- return null;
3166
- }
3167
- if (!isNumber(control.value, options) || Number.isInteger(control.value)) {
3168
- return {
3169
- isInt: {
3170
- expected: 'A int value',
3171
- actual: control.value,
3172
- message: message
3173
- }
3174
- };
3175
- }
3176
- return null;
3177
- };
3178
- }
3179
-
3180
- function IsEnum(_a) {
3181
- var message = _a.message, entity = _a.entity;
3182
- return function (control) {
3183
- if (control.value === null) {
3184
- return null;
3185
- }
3186
- if (Object.keys(entity).map(function (k) { return entity[k]; }).indexOf(control.value) === -1) {
3187
- return {
3188
- isEnum: {
3189
- expected: 'A enum value',
3190
- actual: control.value,
3191
- message: message
3192
- }
3193
- };
3194
- }
3195
- return null;
3196
- };
3197
- }
3198
-
3199
- function IsDate(_a) {
3200
- var _b = _a === void 0 ? {} : _a, message = _b.message;
3201
- return function (control) {
3202
- if (control.value === null) {
3203
- return null;
3204
- }
3205
- if (!(control.value instanceof Date && !isNaN(control.value.getTime()))) {
3206
- return {
3207
- isDate: {
3208
- expected: 'A date value',
3209
- actual: control.value,
3210
- message: message
3211
- }
3212
- };
3213
- }
3214
- return null;
3215
- };
3216
- }
3217
-
3218
- function IsArray(_a) {
3219
- var _b = _a === void 0 ? {} : _a, message = _b.message;
3220
- return function (control) {
3221
- if (control.value === null) {
3222
- return null;
3223
- }
3224
- if (!Array.isArray(control.value)) {
3225
- return {
3226
- isArray: {
3227
- expected: 'A array value',
3228
- actual: control.value,
3229
- message: message
3230
- }
3231
- };
3232
- }
3233
- return null;
3234
- };
3235
- }
3236
-
3237
- var regexOptions = {
3238
- uppercase: '.*[A-Z]',
3239
- special: '.*[^A-Za-z0-9]',
3240
- digit: '.*[0-9]',
3241
- lowercase: '.*[a-z]',
3242
- upperLower: '.*[a-zA-Z]',
3243
- alphaNumeric: '.*[a-zA-Z0-9]'
3244
- };
3245
- var lengthOptions = {
3246
- min: '.{n,}',
3247
- max: '.{0,n}',
3248
- range: '.{min,max}',
3249
- exact: '.{n}',
3250
- no_limit: '.*'
3251
- };
3252
- function inOperator(k, o) {
3253
- return k in o;
3254
- }
3255
- function create(options) {
3256
- var e_1, _a;
3257
- var regex = '^';
3258
- try {
3259
- for (var _b = __values(Object.entries(regexOptions)), _c = _b.next(); !_c.done; _c = _b.next()) {
3260
- var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
3261
- if (inOperator(key, options) && isNumber(options[key])) {
3262
- regex += '(?=' + value.repeat(options[key]) + ')';
3263
- }
3264
- }
3265
- }
3266
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
3267
- finally {
3268
- try {
3269
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
3270
- }
3271
- finally { if (e_1) throw e_1.error; }
3272
- }
3273
- if (isNumber(options.min) && isNumber(options.max)) {
3274
- regex += lengthOptions.range.replace('min', options.min.toFixed(0)).replace('max', options.max.toFixed(0));
3275
- }
3276
- else if (isNumber(options.max)) {
3277
- regex += lengthOptions.max.replace('n', options.max.toFixed(0));
3278
- }
3279
- else if (isNumber(options.min)) {
3280
- regex += lengthOptions.min.replace('n', options.min.toFixed(0));
3281
- }
3282
- else if (isNumber(options.exact)) {
3283
- regex += lengthOptions.exact.replace('n', options.exact.toFixed(0));
3284
- }
3285
- else {
3286
- regex += lengthOptions.no_limit;
3287
- }
3288
- regex += '$';
3289
- return regex;
3290
- }
3291
- function check(str, regexStringOrOptions) {
3292
- var regex;
3293
- var regexString;
3294
- if (typeof regexStringOrOptions === 'object') {
3295
- regexString = create(regexStringOrOptions);
3296
- }
3297
- else {
3298
- regexString = regexStringOrOptions;
3299
- }
3300
- regex = new RegExp(regexString);
3301
- return regex.test(str);
3302
- }
3303
- function checkError(str, options) {
3304
- var e_2, _a, _b;
3305
- var returnObject = {};
3306
- try {
3307
- for (var _c = __values(Object.entries(options)), _d = _c.next(); !_d.done; _d = _c.next()) {
3308
- var _e = __read(_d.value, 2), key = _e[0], value = _e[1];
3309
- returnObject[key] = check(str, (_b = {}, _b[key] = value, _b));
3310
- }
3311
- }
3312
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
3313
- finally {
3314
- try {
3315
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
3316
- }
3317
- finally { if (e_2) throw e_2.error; }
3318
- }
3319
- return returnObject;
3320
- }
3321
- function IsComplex(_a) {
3322
- var message = _a.message, options = _a.options;
3323
- return function (control) {
3324
- if (control.value === null) {
3325
- return null;
3326
- }
3327
- var isNotString = IsString({ message: message })(control);
3328
- if (isNotString !== null) {
3329
- return isNotString;
3330
- }
3331
- var errors = checkError(control.value, options);
3332
- if (Object.keys(errors).length && Object.values(errors).some(function (item) { return !item; })) {
3333
- return {
3334
- isComplex: {
3335
- expected: options,
3336
- actual: errors,
3337
- message: message
3338
- }
3339
- };
3340
- }
3341
- return null;
3342
- };
3343
- }
3344
-
3345
- function IsPhoneNumber(_a) {
3346
- var _b = _a === void 0 ? {} : _a, message = _b.message, locale = _b.locale, options = _b.options;
3347
- return function (control) {
3348
- if (control.value === null) {
3349
- return null;
3350
- }
3351
- if (!validator.isMobilePhone(control.value, locale, options)) {
3352
- return {
3353
- isPhoneNumber: {
3354
- expected: 'A phone number value',
3355
- actual: control.value,
3356
- message: message
3357
- }
3358
- };
3359
- }
3360
- return null;
3361
- };
3362
- }
3363
-
3364
- function IsEmail(_a) {
3365
- var _b = _a === void 0 ? {} : _a, message = _b.message, options = _b.options;
3366
- return function (control) {
3367
- if (control.value === null) {
3368
- return null;
3369
- }
3370
- if (!(typeof control.value === 'string' && validator.isEmail(control.value, options))) {
3371
- return {
3372
- isEmail: {
3373
- expected: 'A email value',
3374
- actual: control.value,
3375
- message: message
3376
- }
3377
- };
3378
- }
3379
- return null;
3380
- };
3381
- }
3382
-
3383
- function IsUrl(_a) {
3384
- var _b = _a === void 0 ? {} : _a, message = _b.message, options = _b.options;
3385
- return function (control) {
3386
- if (control.value === null) {
3387
- return null;
3388
- }
3389
- if (!(typeof control.value === 'string' && validator.isURL(control.value, options))) {
3390
- return {
3391
- isURL: {
3392
- expected: 'A url value',
3393
- actual: control.value,
3394
- message: message
3395
- }
3396
- };
3397
- }
3398
- return null;
3399
- };
3400
- }
3401
-
3402
- function IsIP(_a) {
3403
- var _b = _a === void 0 ? {} : _a, message = _b.message, version = _b.version;
3404
- return function (control) {
3405
- if (control.value === null) {
3406
- return null;
3407
- }
3408
- if (!(typeof control.value === 'string' && validator.isIP(control.value, version))) {
3409
- return {
3410
- isIp: {
3411
- expected: "A valid IPv" + (version !== null && version !== void 0 ? version : '4') + " value",
3412
- actual: control.value,
3413
- message: message
3414
- }
3415
- };
3416
- }
3417
- return null;
3418
- };
3419
- }
3420
-
3421
- var RxapValidators = {
3422
- IsNumber: _IsNumber,
3423
- IsBoolean: IsBoolean,
3424
- IsArray: IsArray,
3425
- IsDate: IsDate,
3426
- IsEnum: IsEnum,
3427
- IsInt: IsInt,
3428
- IsObject: IsObject,
3429
- IsString: IsString,
3430
- IsComplex: IsComplex,
3431
- IsPhoneNumber: IsPhoneNumber,
3432
- IsEmail: IsEmail,
3433
- IsUrl: IsUrl,
3434
- IsIP: IsIP
3435
- };
3436
-
3437
- // endregion
3438
-
3439
- /**
3440
- * Generated bundle index. Do not edit.
3441
- */
3442
-
3443
- exports.ControlAsyncValidator = ControlAsyncValidator;
3444
- exports.ControlChange = ControlChange;
3445
- exports.ControlSetValue = ControlSetValue;
3446
- exports.ControlValidator = ControlValidator;
3447
- exports.ControlValueAccessor = ControlValueAccessor;
3448
- exports.FormArrayControlManager = FormArrayControlManager;
3449
- exports.FormControlErrorDirective = FormControlErrorDirective;
3450
- exports.FormControlMarkDirtyDirective = FormControlMarkDirtyDirective;
3451
- exports.FormControlMarkPristineDirective = FormControlMarkPristineDirective;
3452
- exports.FormControlMarkTouchedDirective = FormControlMarkTouchedDirective;
3453
- exports.FormControlMarkUntouchedDirective = FormControlMarkUntouchedDirective;
3454
- exports.FormControlNameDirective = FormControlNameDirective;
3455
- exports.FormDirective = FormDirective;
3456
- exports.FormGroupNameDirective = FormGroupNameDirective;
3457
- exports.FormLoadedDirective = FormLoadedDirective;
3458
- exports.FormLoadingDirective = FormLoadingDirective;
3459
- exports.FormLoadingErrorDirective = FormLoadingErrorDirective;
3460
- exports.FormSubmitDirective = FormSubmitDirective;
3461
- exports.FormSubmitFailedDirective = FormSubmitFailedDirective;
3462
- exports.FormSubmitInvalidDirective = FormSubmitInvalidDirective;
3463
- exports.FormSubmitSuccessfulDirective = FormSubmitSuccessfulDirective;
3464
- exports.FormSubmittingDirective = FormSubmittingDirective;
3465
- exports.IsArray = IsArray;
3466
- exports.IsBoolean = IsBoolean;
3467
- exports.IsDate = IsDate;
3468
- exports.IsEnum = IsEnum;
3469
- exports.IsInt = IsInt;
3470
- exports.IsNumber = IsNumber;
3471
- exports.IsObject = IsObject;
3472
- exports.IsString = IsString;
3473
- exports.ParentControlContainerDirective = ParentControlContainerDirective;
3474
- exports.RXAP_FORM_CONTEXT = RXAP_FORM_CONTEXT;
3475
- exports.RXAP_FORM_DEFINITION = RXAP_FORM_DEFINITION;
3476
- exports.RXAP_FORM_DEFINITION_BUILDER = RXAP_FORM_DEFINITION_BUILDER;
3477
- exports.RXAP_FORM_INITIAL_STATE = RXAP_FORM_INITIAL_STATE;
3478
- exports.RXAP_FORM_LOAD_FAILED_METHOD = RXAP_FORM_LOAD_FAILED_METHOD;
3479
- exports.RXAP_FORM_LOAD_METHOD = RXAP_FORM_LOAD_METHOD;
3480
- exports.RXAP_FORM_LOAD_SUCCESSFUL_METHOD = RXAP_FORM_LOAD_SUCCESSFUL_METHOD;
3481
- exports.RXAP_FORM_SUBMIT_FAILED_METHOD = RXAP_FORM_SUBMIT_FAILED_METHOD;
3482
- exports.RXAP_FORM_SUBMIT_METHOD = RXAP_FORM_SUBMIT_METHOD;
3483
- exports.RXAP_FORM_SUBMIT_SUCCESSFUL_METHOD = RXAP_FORM_SUBMIT_SUCCESSFUL_METHOD;
3484
- exports.RxapForm = RxapForm;
3485
- exports.RxapFormArray = RxapFormArray;
3486
- exports.RxapFormBuilder = RxapFormBuilder;
3487
- exports.RxapFormControl = RxapFormControl;
3488
- exports.RxapFormGroup = RxapFormGroup;
3489
- exports.RxapFormsModule = RxapFormsModule;
3490
- exports.RxapValidators = RxapValidators;
3491
- exports.ToFormMethod = ToFormMethod;
3492
- exports.ToFormSubmitMethod = ToFormSubmitMethod;
3493
- exports.UseFormArrayControl = UseFormArrayControl;
3494
- exports.UseFormArrayGroup = UseFormArrayGroup;
3495
- exports.UseFormControl = UseFormControl;
3496
- exports.UseFormGroup = UseFormGroup;
3497
- exports._IsNumber = _IsNumber;
3498
- exports.controlDisabled$ = controlDisabled$;
3499
- exports.controlDisabledWhile = controlDisabledWhile;
3500
- exports.controlEnabled$ = controlEnabled$;
3501
- exports.controlEnabledWhile = controlEnabledWhile;
3502
- exports.controlErrorChanges$ = controlErrorChanges$;
3503
- exports.controlReadonly$ = controlReadonly$;
3504
- exports.controlStatusChanges$ = controlStatusChanges$;
3505
- exports.controlValueChanges$ = controlValueChanges$;
3506
- exports.disableControl = disableControl;
3507
- exports.enableControl = enableControl;
3508
- exports.hasErrorAndDirty = hasErrorAndDirty;
3509
- exports.hasErrorAndTouched = hasErrorAndTouched;
3510
- exports.isNumber = isNumber;
3511
- exports.markAllDirty = markAllDirty;
3512
- exports.markAllPristine = markAllPristine;
3513
- exports.markAllUntouched = markAllUntouched;
3514
- exports.mergeControlValidators = mergeControlValidators;
3515
- exports.selectControlValue$ = selectControlValue$;
3516
- exports.validateControlOn = validateControlOn;
3517
-
3518
- Object.defineProperty(exports, '__esModule', { value: true });
3519
-
3520
- })));
3521
- //# sourceMappingURL=rxap-forms.umd.js.map