@rxap/forms 12.7.4 → 13.0.0-next.2

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