@rxap/form-system 12.1.5 → 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 (62) hide show
  1. package/esm2020/index.mjs +26 -0
  2. package/esm2020/lib/control-data-source.mjs +40 -0
  3. package/esm2020/lib/control-with-data-source.mjs +2 -0
  4. package/esm2020/lib/decorators/metadata-keys.mjs +8 -0
  5. package/esm2020/lib/decorators/use-component.mjs +9 -0
  6. package/esm2020/lib/decorators/use-data-source.mjs +9 -0
  7. package/esm2020/lib/decorators/use-form-component.mjs +13 -0
  8. package/esm2020/lib/directives/control-hide-show.directive.mjs +183 -0
  9. package/esm2020/lib/directives/form-directives.module.mjs +21 -0
  10. package/esm2020/lib/directives/input-select-options.directive.mjs +205 -0
  11. package/esm2020/lib/error.mjs +7 -0
  12. package/esm2020/lib/form-system-control.directive.mjs +158 -0
  13. package/esm2020/lib/form-system.module.mjs +17 -0
  14. package/esm2020/lib/mixins/extract-control.mixin.mjs +21 -0
  15. package/esm2020/lib/mixins/extract-data-sources.mixin.mjs +16 -0
  16. package/esm2020/lib/mixins/extract-form-definition.mixin.mjs +12 -0
  17. package/esm2020/lib/validators/is-equal-to.mjs +70 -0
  18. package/esm2020/rxap-form-system.mjs +5 -0
  19. package/fesm2015/rxap-form-system.mjs +752 -0
  20. package/fesm2015/rxap-form-system.mjs.map +1 -0
  21. package/{fesm2015/rxap-form-system.js → fesm2020/rxap-form-system.mjs} +46 -55
  22. package/fesm2020/rxap-form-system.mjs.map +1 -0
  23. package/package.json +38 -24
  24. package/bundles/rxap-form-system.umd.js +0 -1204
  25. package/bundles/rxap-form-system.umd.js.map +0 -1
  26. package/esm2015/index.js +0 -26
  27. package/esm2015/index.js.map +0 -1
  28. package/esm2015/lib/control-data-source.js +0 -40
  29. package/esm2015/lib/control-data-source.js.map +0 -1
  30. package/esm2015/lib/control-with-data-source.js +0 -2
  31. package/esm2015/lib/control-with-data-source.js.map +0 -1
  32. package/esm2015/lib/decorators/metadata-keys.js +0 -8
  33. package/esm2015/lib/decorators/metadata-keys.js.map +0 -1
  34. package/esm2015/lib/decorators/use-component.js +0 -9
  35. package/esm2015/lib/decorators/use-component.js.map +0 -1
  36. package/esm2015/lib/decorators/use-data-source.js +0 -9
  37. package/esm2015/lib/decorators/use-data-source.js.map +0 -1
  38. package/esm2015/lib/decorators/use-form-component.js +0 -13
  39. package/esm2015/lib/decorators/use-form-component.js.map +0 -1
  40. package/esm2015/lib/directives/control-hide-show.directive.js +0 -187
  41. package/esm2015/lib/directives/control-hide-show.directive.js.map +0 -1
  42. package/esm2015/lib/directives/form-directives.module.js +0 -21
  43. package/esm2015/lib/directives/form-directives.module.js.map +0 -1
  44. package/esm2015/lib/directives/input-select-options.directive.js +0 -210
  45. package/esm2015/lib/directives/input-select-options.directive.js.map +0 -1
  46. package/esm2015/lib/error.js +0 -7
  47. package/esm2015/lib/error.js.map +0 -1
  48. package/esm2015/lib/form-system-control.directive.js +0 -158
  49. package/esm2015/lib/form-system-control.directive.js.map +0 -1
  50. package/esm2015/lib/form-system.module.js +0 -17
  51. package/esm2015/lib/form-system.module.js.map +0 -1
  52. package/esm2015/lib/mixins/extract-control.mixin.js +0 -21
  53. package/esm2015/lib/mixins/extract-control.mixin.js.map +0 -1
  54. package/esm2015/lib/mixins/extract-data-sources.mixin.js +0 -16
  55. package/esm2015/lib/mixins/extract-data-sources.mixin.js.map +0 -1
  56. package/esm2015/lib/mixins/extract-form-definition.mixin.js +0 -12
  57. package/esm2015/lib/mixins/extract-form-definition.mixin.js.map +0 -1
  58. package/esm2015/lib/validators/is-equal-to.js +0 -70
  59. package/esm2015/lib/validators/is-equal-to.js.map +0 -1
  60. package/esm2015/rxap-form-system.js +0 -5
  61. package/esm2015/rxap-form-system.js.map +0 -1
  62. package/fesm2015/rxap-form-system.js.map +0 -1
@@ -1,1204 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@rxap/utilities'), require('@angular/forms'), require('@rxap/forms'), require('@rxap/data-source'), require('@rxap/mixin'), require('@rxap/utilities/reflect-metadata'), require('rxjs/operators'), require('rxjs'), require('@angular/material/form-field')) :
3
- typeof define === 'function' && define.amd ? define('@rxap/form-system', ['exports', '@angular/core', '@rxap/utilities', '@angular/forms', '@rxap/forms', '@rxap/data-source', '@rxap/mixin', '@rxap/utilities/reflect-metadata', 'rxjs/operators', 'rxjs', '@angular/material/form-field'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.rxap = global.rxap || {}, global.rxap["form-system"] = {}), global.ng.core, global.utilities, global.ng.forms, global.forms, global.i2, global.mixin, global.reflectMetadata, global.rxjs.operators, global.rxjs, global.ng.material.formField));
5
- })(this, (function (exports, i0, utilities, i1, forms, i2, mixin, reflectMetadata, operators, rxjs, i3) { '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 i0__namespace = /*#__PURE__*/_interopNamespace(i0);
26
- var i1__namespace = /*#__PURE__*/_interopNamespace(i1);
27
- var i2__namespace = /*#__PURE__*/_interopNamespace(i2);
28
- var i3__namespace = /*#__PURE__*/_interopNamespace(i3);
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
- var RxapFormSystemError = /** @class */ (function (_super) {
343
- __extends(RxapFormSystemError, _super);
344
- function RxapFormSystemError(message, code, className) {
345
- return _super.call(this, '@rxap/form-system', message, code, className) || this;
346
- }
347
- return RxapFormSystemError;
348
- }(utilities.RxapError));
349
-
350
- exports.FormSystemMetadataKeys = void 0;
351
- (function (FormSystemMetadataKeys) {
352
- FormSystemMetadataKeys["COMPONENTS"] = "rxap/form-system/components";
353
- FormSystemMetadataKeys["DATA_SOURCES"] = "rxap/form-system/data-sources";
354
- FormSystemMetadataKeys["COMPONENTS_PROPERTIES"] = "rxap/form-system/components-properties";
355
- FormSystemMetadataKeys["FORM_COMPONENT"] = "rxap/window-form-system/form-component";
356
- })(exports.FormSystemMetadataKeys || (exports.FormSystemMetadataKeys = {}));
357
-
358
- var ExtractDataSourcesMixin = /** @class */ (function () {
359
- function ExtractDataSourcesMixin() {
360
- }
361
- ExtractDataSourcesMixin.prototype.extractDataSources = function (formDefinition, controlId) {
362
- var map = reflectMetadata.getMetadata(exports.FormSystemMetadataKeys.DATA_SOURCES, Object.getPrototypeOf(formDefinition));
363
- if (!map) {
364
- throw new RxapFormSystemError('Could not extract the use data source map from the form definition instance', '');
365
- }
366
- if (!map.has(controlId)) {
367
- throw new RxapFormSystemError('A use data source definition does not exists in the form definition metadata', '');
368
- }
369
- return map.get(controlId);
370
- };
371
- return ExtractDataSourcesMixin;
372
- }());
373
-
374
- exports.FormSystemControlDirective = /** @class */ (function () {
375
- function FormSystemControlDirective(parent, cfr, viewContainerRef, dataSourceLoader, injector) {
376
- this.parent = parent;
377
- this.cfr = cfr;
378
- this.viewContainerRef = viewContainerRef;
379
- this.dataSourceLoader = dataSourceLoader;
380
- this.injector = injector;
381
- }
382
- FormSystemControlDirective.prototype.ngOnInit = function () {
383
- this.control = this.extractControl();
384
- var formDefinition = this.extractFormDefinition();
385
- this.componentRef = this.createComponent(formDefinition);
386
- this.setDataSources(formDefinition, this.componentRef.instance);
387
- this.setComponentProperties(formDefinition, this.componentRef.instance);
388
- this.viewContainerRef.insert(this.componentRef.hostView);
389
- };
390
- FormSystemControlDirective.prototype.registerOnChange = function (fn) {
391
- this.componentRef.instance.registerOnChange(fn);
392
- };
393
- FormSystemControlDirective.prototype.registerOnTouched = function (fn) {
394
- this.componentRef.instance.registerOnTouched(fn);
395
- };
396
- FormSystemControlDirective.prototype.writeValue = function (value) {
397
- this.componentRef.instance.writeValue(value);
398
- };
399
- FormSystemControlDirective.prototype.setDisabledState = function (isDisabled) {
400
- if (this.componentRef.instance.setDisabledState) {
401
- this.componentRef.instance.setDisabledState(isDisabled);
402
- }
403
- };
404
- FormSystemControlDirective.prototype.setDataSources = function (formDefinition, component) {
405
- var e_1, _a;
406
- if (!component.setDataSource) {
407
- throw new RxapFormSystemError('The ControlWithDataSource interface is not implemented for the control component, but the control has defined data sources', '');
408
- }
409
- var useDataSourceValueMap = this.extractDataSources(formDefinition, this.controlId);
410
- try {
411
- for (var _b = __values(useDataSourceValueMap.entries()), _c = _b.next(); !_c.done; _c = _b.next()) {
412
- var _d = __read(_c.value, 2), name = _d[0], useDataSourceValue = _d[1];
413
- var dataSource = this.dataSourceLoader.load(useDataSourceValue.dataSource);
414
- var settings = useDataSourceValue.settings;
415
- if (settings === null || settings === void 0 ? void 0 : settings.transformer) {
416
- dataSource = new i2.PipeDataSource(dataSource, operators.map(settings.transformer));
417
- }
418
- component.setDataSource(name, dataSource, useDataSourceValue.settings);
419
- }
420
- }
421
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
422
- finally {
423
- try {
424
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
425
- }
426
- finally { if (e_1) throw e_1.error; }
427
- }
428
- };
429
- FormSystemControlDirective.prototype.setComponentProperties = function (formDefinition, component) {
430
- var e_2, _a;
431
- var componentProperties = this.extractComponentProperties(formDefinition);
432
- try {
433
- for (var _b = __values(Object.entries(componentProperties)), _c = _b.next(); !_c.done; _c = _b.next()) {
434
- var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
435
- Reflect.set(component, key, value);
436
- }
437
- }
438
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
439
- finally {
440
- try {
441
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
442
- }
443
- finally { if (e_2) throw e_2.error; }
444
- }
445
- };
446
- FormSystemControlDirective.prototype.createComponent = function (formDefinition) {
447
- var component = this.extractComponent(formDefinition);
448
- var componentFactory = this.cfr.resolveComponentFactory(component);
449
- return componentFactory.create(this.injector);
450
- };
451
- FormSystemControlDirective.prototype.extractControl = function () {
452
- if (!this.parent.control) {
453
- throw new RxapFormSystemError('The control property of ControlContainer is not defined', '');
454
- }
455
- var control = this.parent.control.get(this.controlId);
456
- if (!control) {
457
- throw new RxapFormSystemError('Could not find the control instance', '');
458
- }
459
- if (!(control instanceof forms.RxapFormControl)) {
460
- throw new RxapFormSystemError('The extracted control is not a RxapFormControl', '');
461
- }
462
- return control;
463
- };
464
- FormSystemControlDirective.prototype.extractFormDefinition = function () {
465
- var formDefinition = this.control.rxapFormDefinition;
466
- if (!formDefinition) {
467
- throw new RxapFormSystemError('Could not find the form definition instance', '');
468
- }
469
- return formDefinition;
470
- };
471
- FormSystemControlDirective.prototype.extractComponent = function (formDefinition) {
472
- var map = reflectMetadata.getMetadata(exports.FormSystemMetadataKeys.COMPONENTS, Object.getPrototypeOf(formDefinition));
473
- if (!map) {
474
- throw new RxapFormSystemError('Could not extract the use component map from the form definition instance', '');
475
- }
476
- if (!map.has(this.controlId)) {
477
- throw new RxapFormSystemError('A use component definition does not exists in the form definition metadata', '');
478
- }
479
- return map.get(this.controlId);
480
- };
481
- FormSystemControlDirective.prototype.extractComponentProperties = function (formDefinition) {
482
- var map = reflectMetadata.getMetadata(exports.FormSystemMetadataKeys.COMPONENTS_PROPERTIES, Object.getPrototypeOf(formDefinition));
483
- if (!map) {
484
- throw new RxapFormSystemError('Could not extract the use component properties map from the form definition instance', '');
485
- }
486
- if (!map.has(this.controlId)) {
487
- throw new RxapFormSystemError('A use component definition does not exists in the form definition metadata', '');
488
- }
489
- return map.get(this.controlId);
490
- };
491
- return FormSystemControlDirective;
492
- }());
493
- exports.FormSystemControlDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: exports.FormSystemControlDirective, deps: [{ token: i1.ControlContainer }, { token: i0.ComponentFactoryResolver }, { token: i0.ViewContainerRef }, { token: i2.DataSourceLoader }, { token: i0.INJECTOR }], target: i0__namespace.ɵɵFactoryTarget.Directive });
494
- exports.FormSystemControlDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: exports.FormSystemControlDirective, selector: "[rxapFormSystemControl]", inputs: { controlId: "controlId" }, ngImport: i0__namespace });
495
- __decorate([
496
- utilities.Required,
497
- __metadata("design:type", String)
498
- ], exports.FormSystemControlDirective.prototype, "controlId", void 0);
499
- __decorate([
500
- utilities.Required,
501
- __metadata("design:type", forms.RxapFormControl)
502
- ], exports.FormSystemControlDirective.prototype, "control", void 0);
503
- __decorate([
504
- utilities.Required,
505
- __metadata("design:type", i0.ComponentRef)
506
- ], exports.FormSystemControlDirective.prototype, "componentRef", void 0);
507
- exports.FormSystemControlDirective = __decorate([
508
- mixin.Mixin(ExtractDataSourcesMixin),
509
- __metadata("design:paramtypes", [i1.ControlContainer,
510
- i0.ComponentFactoryResolver,
511
- i0.ViewContainerRef,
512
- i2.DataSourceLoader,
513
- i0.Injector])
514
- ], exports.FormSystemControlDirective);
515
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: exports.FormSystemControlDirective, decorators: [{
516
- type: i0.Directive,
517
- args: [{
518
- selector: '[rxapFormSystemControl]'
519
- }]
520
- }], ctorParameters: function () {
521
- return [{ type: i1__namespace.ControlContainer, decorators: [{
522
- type: i0.Inject,
523
- args: [i1.ControlContainer]
524
- }] }, { type: i0__namespace.ComponentFactoryResolver, decorators: [{
525
- type: i0.Inject,
526
- args: [i0.ComponentFactoryResolver]
527
- }] }, { type: i0__namespace.ViewContainerRef, decorators: [{
528
- type: i0.Inject,
529
- args: [i0.ViewContainerRef]
530
- }] }, { type: i2__namespace.DataSourceLoader, decorators: [{
531
- type: i0.Inject,
532
- args: [i2.DataSourceLoader]
533
- }] }, { type: i0__namespace.Injector, decorators: [{
534
- type: i0.Inject,
535
- args: [i0.INJECTOR]
536
- }] }];
537
- }, propDecorators: { controlId: [{
538
- type: i0.Input
539
- }], control: [], componentRef: [] } });
540
-
541
- var FormSystemModule = /** @class */ (function () {
542
- function FormSystemModule() {
543
- }
544
- return FormSystemModule;
545
- }());
546
- FormSystemModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: FormSystemModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
547
- FormSystemModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: FormSystemModule, declarations: [exports.FormSystemControlDirective], exports: [exports.FormSystemControlDirective] });
548
- FormSystemModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: FormSystemModule, imports: [[]] });
549
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: FormSystemModule, decorators: [{
550
- type: i0.NgModule,
551
- args: [{
552
- declarations: [exports.FormSystemControlDirective],
553
- exports: [exports.FormSystemControlDirective],
554
- imports: []
555
- }]
556
- }] });
557
-
558
- var RXAP_FORM_CONTROL_SOURCE = new i0.InjectionToken('rxap/forms/data-source');
559
- var ControlDataSource = /** @class */ (function (_super) {
560
- __extends(ControlDataSource, _super);
561
- function ControlDataSource(control, metadata) {
562
- if (metadata === void 0) { metadata = null; }
563
- var _this = _super.call(this, metadata) || this;
564
- _this.control = control;
565
- return _this;
566
- }
567
- ControlDataSource.prototype.init = function () {
568
- if (this._initialised) {
569
- return;
570
- }
571
- _super.prototype.init.call(this);
572
- if (i0.isDevMode()) {
573
- console.log(this.control);
574
- }
575
- this._data$ = this.control.valueChanges.pipe(operators.startWith(this.control.value), operators.distinctUntilChanged(function (a, b) { return utilities.equals(a, b); }), operators.shareReplay(1));
576
- };
577
- return ControlDataSource;
578
- }(i2.BaseDataSource));
579
- ControlDataSource.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: ControlDataSource, deps: [{ token: RXAP_FORM_CONTROL_SOURCE }, { token: i2.RXAP_DATA_SOURCE_METADATA, optional: true }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
580
- ControlDataSource.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: ControlDataSource });
581
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: ControlDataSource, decorators: [{
582
- type: i0.Injectable
583
- }], ctorParameters: function () {
584
- return [{ type: undefined, decorators: [{
585
- type: i0.Inject,
586
- args: [RXAP_FORM_CONTROL_SOURCE]
587
- }] }, { type: undefined, decorators: [{
588
- type: i0.Optional
589
- }, {
590
- type: i0.Inject,
591
- args: [i2.RXAP_DATA_SOURCE_METADATA]
592
- }] }];
593
- } });
594
- function controlDataSource(control) {
595
- // TODO : remove as any (wait for @rxap/forms update)
596
- return new ControlDataSource(control, { id: control.controlId });
597
- }
598
-
599
- var ExtractControlMixin = /** @class */ (function () {
600
- function ExtractControlMixin() {
601
- }
602
- ExtractControlMixin.prototype.extractControl = function (parent, controlPath) {
603
- if (!controlPath) {
604
- throw new RxapFormSystemError('The control path is empty', '');
605
- }
606
- if (!parent.control) {
607
- throw new RxapFormSystemError('The control property of ControlContainer is not defined', '');
608
- }
609
- var control = parent.control.get(controlPath);
610
- if (!control) {
611
- throw new RxapFormSystemError('Could not find the control instance', '');
612
- }
613
- if (!(control instanceof forms.RxapFormControl) && !(control instanceof forms.RxapFormGroup) && !(control instanceof forms.RxapFormArray)) {
614
- throw new RxapFormSystemError('The extracted control is not a RxapFormControl', '');
615
- }
616
- return control;
617
- };
618
- return ExtractControlMixin;
619
- }());
620
-
621
- var ExtractFormDefinitionMixin = /** @class */ (function () {
622
- function ExtractFormDefinitionMixin() {
623
- }
624
- // TODO : change to AbstractControl from @rxap/forms
625
- ExtractFormDefinitionMixin.prototype.extractFormDefinition = function (control) {
626
- var formDefinition = control.rxapFormDefinition;
627
- if (!formDefinition) {
628
- throw new RxapFormSystemError('Could not find the form definition instance', '');
629
- }
630
- return formDefinition;
631
- };
632
- return ExtractFormDefinitionMixin;
633
- }());
634
-
635
- function UseComponent(component, setProperties) {
636
- if (setProperties === void 0) { setProperties = {}; }
637
- return function (target, propertyKey) {
638
- reflectMetadata.setMetadataMap(propertyKey, component, exports.FormSystemMetadataKeys.COMPONENTS, target);
639
- reflectMetadata.setMetadataMap(propertyKey, setProperties, exports.FormSystemMetadataKeys.COMPONENTS_PROPERTIES, target);
640
- };
641
- }
642
-
643
- function UseDataSource(dataSource, name, settings) {
644
- return function (target, propertyKey) {
645
- var value = { dataSource: dataSource, settings: settings };
646
- reflectMetadata.setMetadataMapMap(propertyKey, name, value, exports.FormSystemMetadataKeys.DATA_SOURCES, target);
647
- };
648
- }
649
-
650
- /**
651
- * Links a component with a form definition
652
- *
653
- * @param component
654
- */
655
- function UseFormComponent(component) {
656
- return function (target) {
657
- reflectMetadata.setMetadata(exports.FormSystemMetadataKeys.FORM_COMPONENT, component, target);
658
- };
659
- }
660
-
661
- var RXAP_FORM_SYSTEM_SHOW_METADATA = 'rxap/form-system/show-function';
662
- var RXAP_FORM_SYSTEM_HIDE_METADATA = 'rxap/form-system/hide-function';
663
- var RXAP_FORM_SYSTEM_HIDE_SHOW_OPTIONS = 'rxap/form-system/hide-show-options';
664
- function UseHideFunction(hideFunction, options) {
665
- if (options === void 0) { options = {}; }
666
- return function (target, propertyKey) {
667
- reflectMetadata.setMetadataMap(propertyKey, hideFunction, RXAP_FORM_SYSTEM_HIDE_METADATA, target);
668
- if (Object.keys(options).length) {
669
- reflectMetadata.setMetadataMap(propertyKey, options, RXAP_FORM_SYSTEM_HIDE_SHOW_OPTIONS, target);
670
- }
671
- };
672
- }
673
- function UseShowFunction(showFunction, options) {
674
- if (options === void 0) { options = {}; }
675
- return function (target, propertyKey) {
676
- reflectMetadata.setMetadataMap(propertyKey, showFunction, RXAP_FORM_SYSTEM_SHOW_METADATA, target);
677
- if (Object.keys(options).length) {
678
- reflectMetadata.setMetadataMap(propertyKey, options, RXAP_FORM_SYSTEM_HIDE_SHOW_OPTIONS, target);
679
- }
680
- };
681
- }
682
- exports.ControlHideShowDirective = /** @class */ (function () {
683
- function ControlHideShowDirective(renderer, elementRef, parent, ngControl) {
684
- this.renderer = renderer;
685
- this.elementRef = elementRef;
686
- this.parent = parent;
687
- this.ngControl = ngControl;
688
- this.subscription = new rxjs.Subscription();
689
- }
690
- ControlHideShowDirective.prototype.ngOnInit = function () {
691
- var _this = this;
692
- var _a, _b;
693
- if (!this.ngControl && !this.parent) {
694
- throw new Error('Easier the ControlContainer or NgControl must be injectable');
695
- }
696
- if (!this.ngControl && !this.controlId) {
697
- throw new Error('If the NgControl is not injectable then the control id must be defined!');
698
- }
699
- var control = (_b = (_a = this.ngControl) === null || _a === void 0 ? void 0 : _a.control) !== null && _b !== void 0 ? _b : this.extractControl(this.parent, this.controlId);
700
- if (!(control instanceof forms.RxapFormControl)) {
701
- throw new Error('The control is not an instance of RxapFormControl');
702
- }
703
- this.control = control;
704
- var formDefinition = this.extractFormDefinition(control);
705
- var hideFunction = this.extractHideFunction(formDefinition);
706
- var showFunction = this.extractShowFunction(formDefinition);
707
- var options = this.extractOptions(formDefinition);
708
- var changeTrigger = formDefinition.rxapFormGroup.valueChanges;
709
- if (options.rootChange) {
710
- changeTrigger = formDefinition.rxapFormGroup.root.valueChanges;
711
- }
712
- changeTrigger = changeTrigger.pipe(operators.startWith(null));
713
- if (showFunction) {
714
- this.subscription.add(changeTrigger.pipe(operators.tap(function () {
715
- // TODO : resubscribe if the showFunction throws an error
716
- var show = showFunction.call(formDefinition, control);
717
- switch (show) {
718
- case true:
719
- _this.show();
720
- break;
721
- case false:
722
- _this.hide();
723
- break;
724
- case null:
725
- _this.reset();
726
- break;
727
- }
728
- }), operators.catchError(function (err) {
729
- console.error(err);
730
- return rxjs.of(null);
731
- })).subscribe());
732
- }
733
- if (hideFunction) {
734
- this.subscription.add(changeTrigger.pipe(operators.tap(function () {
735
- // TODO : resubscribe if the hideFunction throws an error
736
- var hide = hideFunction.call(formDefinition, control);
737
- switch (hide) {
738
- case true:
739
- _this.hide();
740
- break;
741
- case false:
742
- _this.show();
743
- break;
744
- case null:
745
- _this.reset();
746
- break;
747
- }
748
- }), operators.catchError(function (err) {
749
- console.error(err);
750
- return rxjs.of(null);
751
- })).subscribe());
752
- }
753
- };
754
- ControlHideShowDirective.prototype.ngOnDestroy = function () {
755
- this.subscription.unsubscribe();
756
- };
757
- ControlHideShowDirective.prototype.extractOptions = function (formDefinition) {
758
- var _a;
759
- var map = (_a = reflectMetadata.getMetadata(RXAP_FORM_SYSTEM_HIDE_SHOW_OPTIONS, Object.getPrototypeOf(formDefinition))) !== null && _a !== void 0 ? _a : null;
760
- if (!map || !map.has(this.control.controlId)) {
761
- return {};
762
- }
763
- return map.get(this.control.controlId);
764
- };
765
- ControlHideShowDirective.prototype.extractHideFunction = function (formDefinition) {
766
- var _a;
767
- var map = (_a = reflectMetadata.getMetadata(RXAP_FORM_SYSTEM_HIDE_METADATA, Object.getPrototypeOf(formDefinition))) !== null && _a !== void 0 ? _a : null;
768
- if (!map || !map.has(this.control.controlId)) {
769
- return null;
770
- }
771
- return map.get(this.control.controlId);
772
- };
773
- ControlHideShowDirective.prototype.extractShowFunction = function (formDefinition) {
774
- var _a;
775
- var map = (_a = reflectMetadata.getMetadata(RXAP_FORM_SYSTEM_SHOW_METADATA, Object.getPrototypeOf(formDefinition))) !== null && _a !== void 0 ? _a : null;
776
- if (!map || !map.has(this.control.controlId)) {
777
- return null;
778
- }
779
- return map.get(this.control.controlId);
780
- };
781
- ControlHideShowDirective.prototype.hide = function () {
782
- this.renderer.setStyle(this.elementRef.nativeElement, 'display', 'none');
783
- };
784
- ControlHideShowDirective.prototype.show = function () {
785
- this.renderer.setStyle(this.elementRef.nativeElement, 'display', 'block');
786
- };
787
- ControlHideShowDirective.prototype.reset = function () {
788
- this.renderer.removeStyle(this.elementRef.nativeElement, 'display');
789
- };
790
- return ControlHideShowDirective;
791
- }());
792
- exports.ControlHideShowDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: exports.ControlHideShowDirective, deps: [{ token: i0.Renderer2 }, { token: i0.ElementRef }, { token: i1.ControlContainer, optional: true }, { token: i1.NgControl, optional: true, self: true }], target: i0__namespace.ɵɵFactoryTarget.Directive });
793
- exports.ControlHideShowDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: exports.ControlHideShowDirective, selector: "[rxapControlHideShow]", inputs: { controlId: ["rxapControlHideShow", "controlId"] }, ngImport: i0__namespace });
794
- exports.ControlHideShowDirective = __decorate([
795
- mixin.Mixin(ExtractControlMixin, ExtractFormDefinitionMixin),
796
- __metadata("design:paramtypes", [i0.Renderer2,
797
- i0.ElementRef, Object, Object])
798
- ], exports.ControlHideShowDirective);
799
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: exports.ControlHideShowDirective, decorators: [{
800
- type: i0.Directive,
801
- args: [{
802
- selector: '[rxapControlHideShow]'
803
- }]
804
- }], ctorParameters: function () {
805
- return [{ type: i0__namespace.Renderer2, decorators: [{
806
- type: i0.Inject,
807
- args: [i0.Renderer2]
808
- }] }, { type: i0__namespace.ElementRef, decorators: [{
809
- type: i0.Inject,
810
- args: [i0.ElementRef]
811
- }] }, { type: i1__namespace.ControlContainer, decorators: [{
812
- type: i0.Optional
813
- }, {
814
- type: i0.Inject,
815
- args: [i1.ControlContainer]
816
- }] }, { type: i1__namespace.NgControl, decorators: [{
817
- type: i0.Self
818
- }, {
819
- type: i0.Optional
820
- }, {
821
- type: i0.Inject,
822
- args: [i1.NgControl]
823
- }] }];
824
- }, propDecorators: { controlId: [{
825
- type: i0.Input,
826
- args: ['rxapControlHideShow']
827
- }] } });
828
- var ControlHideShowDirectiveModule = /** @class */ (function () {
829
- function ControlHideShowDirectiveModule() {
830
- }
831
- return ControlHideShowDirectiveModule;
832
- }());
833
- ControlHideShowDirectiveModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: ControlHideShowDirectiveModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
834
- ControlHideShowDirectiveModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: ControlHideShowDirectiveModule, declarations: [exports.ControlHideShowDirective], exports: [exports.ControlHideShowDirective] });
835
- ControlHideShowDirectiveModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: ControlHideShowDirectiveModule });
836
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: ControlHideShowDirectiveModule, decorators: [{
837
- type: i0.NgModule,
838
- args: [{
839
- declarations: [exports.ControlHideShowDirective],
840
- exports: [exports.ControlHideShowDirective]
841
- }]
842
- }] });
843
-
844
- var DATA_SOURCE_NAME = 'options';
845
- function ComposeOptionsTransformers() {
846
- var fnc = [];
847
- for (var _i = 0; _i < arguments.length; _i++) {
848
- fnc[_i] = arguments[_i];
849
- }
850
- return function (base) { return fnc.reduce(function (source, transform) { return transform(source); }, base); };
851
- }
852
- function UseOptionsDataSource(dataSource, settings) {
853
- return function (target, propertyKey) {
854
- UseDataSource(dataSource, DATA_SOURCE_NAME, settings)(target, propertyKey);
855
- };
856
- }
857
- exports.InputSelectOptionsDirective = /** @class */ (function () {
858
- function InputSelectOptionsDirective(template, dataSourceLoader, viewContainerRef, injector, cdr,
859
- // The ngControl could be unknown on construction
860
- // bc it is available after the content is init
861
- ngControl, matFormField) {
862
- if (ngControl === void 0) { ngControl = null; }
863
- if (matFormField === void 0) { matFormField = null; }
864
- this.template = template;
865
- this.dataSourceLoader = dataSourceLoader;
866
- this.viewContainerRef = viewContainerRef;
867
- this.injector = injector;
868
- this.cdr = cdr;
869
- this.ngControl = ngControl;
870
- this.matFormField = matFormField;
871
- this.viewer = { id: '[rxapInputSelectOptions]' };
872
- this.subscription = new rxjs.Subscription();
873
- this.options = null;
874
- }
875
- InputSelectOptionsDirective.prototype.ngAfterViewInit = function () {
876
- var _this = this;
877
- this.extractControl();
878
- this.extractDatasource();
879
- this.viewer = {
880
- id: '[rxapInputSelectOptions]' + this.control.controlId,
881
- viewChange: this.control.value$.pipe(operators.map(function (value) {
882
- var _a;
883
- if ((_a = _this.settings) === null || _a === void 0 ? void 0 : _a.ignoreSelectedValue) {
884
- return {};
885
- }
886
- return value;
887
- })),
888
- control: this.control,
889
- };
890
- this.loadOptions();
891
- if (this.matAutocomplete) {
892
- this.matAutocomplete.displayWith = this.toDisplay.bind(this);
893
- }
894
- };
895
- InputSelectOptionsDirective.prototype.extractDatasource = function (control) {
896
- if (control === void 0) { control = this.control; }
897
- var formDefinition = this.extractFormDefinition(control);
898
- var useDataSourceValueMap = this.extractDataSources(formDefinition, control.controlId);
899
- if (!useDataSourceValueMap.has(DATA_SOURCE_NAME)) {
900
- throw new Error("The data source with the name 'options' is not defined");
901
- }
902
- var useDataSourceValue = useDataSourceValueMap.get(DATA_SOURCE_NAME);
903
- this.settings = useDataSourceValue.settings;
904
- var dataSource;
905
- try {
906
- dataSource = this.dataSourceLoader.load(useDataSourceValue.dataSource, this.metadata, this.injector);
907
- }
908
- catch (e) {
909
- if (e.name && e.name === 'NullInjectorError') {
910
- if (i0.isDevMode()) {
911
- console.error('Cloud not inject the options data source', useDataSourceValue);
912
- }
913
- throw new Error('Cloud not inject the options data source:\n' + e.message);
914
- }
915
- throw e;
916
- }
917
- var settings = useDataSourceValue.settings;
918
- if (settings === null || settings === void 0 ? void 0 : settings.transformer) {
919
- dataSource = new i2.PipeDataSource(dataSource, operators.map(settings.transformer));
920
- }
921
- return this.dataSource = dataSource;
922
- };
923
- InputSelectOptionsDirective.prototype.toDisplay = function (value) {
924
- var _a, _b, _c;
925
- if (!value) {
926
- return '';
927
- }
928
- return (_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.find(function (option) { return option.value === value; })) === null || _b === void 0 ? void 0 : _b.display) !== null && _c !== void 0 ? _c : (i0.isDevMode() ? 'to display error' : '');
929
- };
930
- InputSelectOptionsDirective.prototype.extractControl = function (ngControl) {
931
- var _a, _b, _c, _d;
932
- if (ngControl === void 0) {
933
- ngControl = (_d = (_a = this.ngControl) !== null && _a !== void 0 ? _a : (_c = (_b = this.matFormField) === null || _b === void 0 ? void 0 : _b._control) === null || _c === void 0 ? void 0 : _c.ngControl) !== null && _d !== void 0 ? _d : null;
934
- }
935
- if (!ngControl) {
936
- throw new Error('The ngControl is not defined!');
937
- }
938
- this.ngControl = ngControl;
939
- var control = this.ngControl.control;
940
- if (!(control instanceof forms.RxapFormControl)) {
941
- throw new Error('Control is not a RxapFormControl!');
942
- }
943
- return this.control = control;
944
- };
945
- InputSelectOptionsDirective.prototype.ngOnDestroy = function () {
946
- var _a;
947
- (_a = this.subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
948
- };
949
- InputSelectOptionsDirective.prototype.loadOptions = function (dataSource) {
950
- var _this = this;
951
- if (dataSource === void 0) { dataSource = this.dataSource; }
952
- this.subscription.add(dataSource.connect(this.viewer).pipe(operators.tap(function (options) { return _this.renderTemplate(_this.options = options); })).subscribe());
953
- };
954
- InputSelectOptionsDirective.prototype.renderTemplate = function (options) {
955
- var e_1, _e, e_2, _f;
956
- if (options === void 0) { options = this.options; }
957
- this.viewContainerRef.clear();
958
- if (options) {
959
- if (!Array.isArray(options)) {
960
- try {
961
- for (var _g = __values(Object.entries(options)), _h = _g.next(); !_h.done; _h = _g.next()) {
962
- var _j = __read(_h.value, 2), value = _j[0], display = _j[1];
963
- this.viewContainerRef.createEmbeddedView(this.template, { $implicit: { value: value, display: display } });
964
- }
965
- }
966
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
967
- finally {
968
- try {
969
- if (_h && !_h.done && (_e = _g.return)) _e.call(_g);
970
- }
971
- finally { if (e_1) throw e_1.error; }
972
- }
973
- }
974
- else {
975
- try {
976
- for (var options_1 = __values(options), options_1_1 = options_1.next(); !options_1_1.done; options_1_1 = options_1.next()) {
977
- var option = options_1_1.value;
978
- this.viewContainerRef.createEmbeddedView(this.template, { $implicit: option });
979
- }
980
- }
981
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
982
- finally {
983
- try {
984
- if (options_1_1 && !options_1_1.done && (_f = options_1.return)) _f.call(options_1);
985
- }
986
- finally { if (e_2) throw e_2.error; }
987
- }
988
- }
989
- }
990
- else {
991
- if (i0.isDevMode()) {
992
- console.warn("The options for the control " + this.control.fullControlPath + " is empty/null/undefined!");
993
- }
994
- }
995
- this.cdr.detectChanges();
996
- };
997
- return InputSelectOptionsDirective;
998
- }());
999
- exports.InputSelectOptionsDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: exports.InputSelectOptionsDirective, deps: [{ token: i0.TemplateRef }, { token: i2.DataSourceLoader }, { token: i0.ViewContainerRef }, { token: i0.INJECTOR }, { token: i0.ChangeDetectorRef }, { token: i1.NgControl, optional: true }, { token: i3.MAT_FORM_FIELD, optional: true }], target: i0__namespace.ɵɵFactoryTarget.Directive });
1000
- exports.InputSelectOptionsDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: exports.InputSelectOptionsDirective, selector: "[rxapInputSelectOptions]", inputs: { viewer: ["rxapInputSelectOptionsViewer", "viewer"], metadata: ["rxapInputSelectOptionsMetadata", "metadata"], matAutocomplete: ["rxapInputSelectOptionsMatAutocomplete", "matAutocomplete"] }, ngImport: i0__namespace });
1001
- __decorate([
1002
- utilities.Required,
1003
- __metadata("design:type", forms.RxapFormControl)
1004
- ], exports.InputSelectOptionsDirective.prototype, "control", void 0);
1005
- __decorate([
1006
- utilities.Required,
1007
- __metadata("design:type", i2.BaseDataSource)
1008
- ], exports.InputSelectOptionsDirective.prototype, "dataSource", void 0);
1009
- exports.InputSelectOptionsDirective = __decorate([
1010
- mixin.Mixin(ExtractFormDefinitionMixin, ExtractDataSourcesMixin),
1011
- __metadata("design:paramtypes", [i0.TemplateRef,
1012
- i2.DataSourceLoader,
1013
- i0.ViewContainerRef,
1014
- i0.Injector,
1015
- i0.ChangeDetectorRef, Object, Object])
1016
- ], exports.InputSelectOptionsDirective);
1017
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: exports.InputSelectOptionsDirective, decorators: [{
1018
- type: i0.Directive,
1019
- args: [{
1020
- selector: '[rxapInputSelectOptions]'
1021
- }]
1022
- }], ctorParameters: function () {
1023
- return [{ type: i0__namespace.TemplateRef, decorators: [{
1024
- type: i0.Inject,
1025
- args: [i0.TemplateRef]
1026
- }] }, { type: i2__namespace.DataSourceLoader, decorators: [{
1027
- type: i0.Inject,
1028
- args: [i2.DataSourceLoader]
1029
- }] }, { type: i0__namespace.ViewContainerRef, decorators: [{
1030
- type: i0.Inject,
1031
- args: [i0.ViewContainerRef]
1032
- }] }, { type: i0__namespace.Injector, decorators: [{
1033
- type: i0.Inject,
1034
- args: [i0.INJECTOR]
1035
- }] }, { type: i0__namespace.ChangeDetectorRef, decorators: [{
1036
- type: i0.Inject,
1037
- args: [i0.ChangeDetectorRef]
1038
- }] }, { type: i1__namespace.NgControl, decorators: [{
1039
- type: i0.Optional
1040
- }, {
1041
- type: i0.Inject,
1042
- args: [i1.NgControl]
1043
- }] }, { type: i3__namespace.MatFormField, decorators: [{
1044
- type: i0.Optional
1045
- }, {
1046
- type: i0.Inject,
1047
- args: [i3.MAT_FORM_FIELD]
1048
- }] }];
1049
- }, propDecorators: { viewer: [{
1050
- type: i0.Input,
1051
- args: ['rxapInputSelectOptionsViewer']
1052
- }], metadata: [{
1053
- type: i0.Input,
1054
- args: ['rxapInputSelectOptionsMetadata']
1055
- }], matAutocomplete: [{
1056
- type: i0.Input,
1057
- args: ['rxapInputSelectOptionsMatAutocomplete']
1058
- }], control: [], dataSource: [] } });
1059
- var InputSelectOptionsDirectiveModule = /** @class */ (function () {
1060
- function InputSelectOptionsDirectiveModule() {
1061
- }
1062
- return InputSelectOptionsDirectiveModule;
1063
- }());
1064
- InputSelectOptionsDirectiveModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: InputSelectOptionsDirectiveModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1065
- InputSelectOptionsDirectiveModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: InputSelectOptionsDirectiveModule, declarations: [exports.InputSelectOptionsDirective], exports: [exports.InputSelectOptionsDirective] });
1066
- InputSelectOptionsDirectiveModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: InputSelectOptionsDirectiveModule });
1067
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: InputSelectOptionsDirectiveModule, decorators: [{
1068
- type: i0.NgModule,
1069
- args: [{
1070
- declarations: [exports.InputSelectOptionsDirective],
1071
- exports: [exports.InputSelectOptionsDirective]
1072
- }]
1073
- }] });
1074
-
1075
- var FormSystemDirectivesModule = /** @class */ (function () {
1076
- function FormSystemDirectivesModule() {
1077
- }
1078
- return FormSystemDirectivesModule;
1079
- }());
1080
- FormSystemDirectivesModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: FormSystemDirectivesModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1081
- FormSystemDirectivesModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: FormSystemDirectivesModule, exports: [InputSelectOptionsDirectiveModule,
1082
- ControlHideShowDirectiveModule] });
1083
- FormSystemDirectivesModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: FormSystemDirectivesModule, imports: [InputSelectOptionsDirectiveModule,
1084
- ControlHideShowDirectiveModule] });
1085
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: FormSystemDirectivesModule, decorators: [{
1086
- type: i0.NgModule,
1087
- args: [{
1088
- exports: [
1089
- InputSelectOptionsDirectiveModule,
1090
- ControlHideShowDirectiveModule
1091
- ]
1092
- }]
1093
- }] });
1094
-
1095
- var IsEqualToDirective = /** @class */ (function () {
1096
- function IsEqualToDirective() {
1097
- }
1098
- Object.defineProperty(IsEqualToDirective.prototype, "equalTo", {
1099
- set: function (value) {
1100
- this._equalTo = value;
1101
- if (this._onChange) {
1102
- this._onChange();
1103
- }
1104
- },
1105
- enumerable: false,
1106
- configurable: true
1107
- });
1108
- IsEqualToDirective.prototype.validate = function (control) {
1109
- if (this._equalTo === null || this._equalTo === control.value) {
1110
- return null;
1111
- }
1112
- return { isEqualTo: { value: this._equalTo, actualValue: control.value } };
1113
- };
1114
- /**
1115
- * @description
1116
- * Registers a callback function to call when the validator inputs change.
1117
- *
1118
- * @param fn The callback function
1119
- */
1120
- IsEqualToDirective.prototype.registerOnValidatorChange = function (fn) {
1121
- this._onChange = fn;
1122
- };
1123
- return IsEqualToDirective;
1124
- }());
1125
- IsEqualToDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: IsEqualToDirective, deps: [], target: i0__namespace.ɵɵFactoryTarget.Directive });
1126
- IsEqualToDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: IsEqualToDirective, selector: "[rxapIsEqualTo]", inputs: { equalTo: ["rxapIsEqualTo", "equalTo"] }, providers: [
1127
- {
1128
- provide: i1.NG_VALIDATORS,
1129
- multi: true,
1130
- useExisting: i0.forwardRef(function () { return IsEqualToDirective; })
1131
- }
1132
- ], ngImport: i0__namespace });
1133
- __decorate([
1134
- utilities.Required,
1135
- __metadata("design:type", Object),
1136
- __metadata("design:paramtypes", [Object])
1137
- ], IsEqualToDirective.prototype, "equalTo", null);
1138
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: IsEqualToDirective, decorators: [{
1139
- type: i0.Directive,
1140
- args: [{
1141
- selector: '[rxapIsEqualTo]',
1142
- providers: [
1143
- {
1144
- provide: i1.NG_VALIDATORS,
1145
- multi: true,
1146
- useExisting: i0.forwardRef(function () { return IsEqualToDirective; })
1147
- }
1148
- ]
1149
- }]
1150
- }], propDecorators: { equalTo: [{
1151
- type: i0.Input,
1152
- args: ['rxapIsEqualTo']
1153
- }] } });
1154
- var IsEqualToDirectiveModule = /** @class */ (function () {
1155
- function IsEqualToDirectiveModule() {
1156
- }
1157
- return IsEqualToDirectiveModule;
1158
- }());
1159
- IsEqualToDirectiveModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: IsEqualToDirectiveModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1160
- IsEqualToDirectiveModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: IsEqualToDirectiveModule, declarations: [IsEqualToDirective], exports: [IsEqualToDirective] });
1161
- IsEqualToDirectiveModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: IsEqualToDirectiveModule });
1162
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: IsEqualToDirectiveModule, decorators: [{
1163
- type: i0.NgModule,
1164
- args: [{
1165
- declarations: [IsEqualToDirective],
1166
- exports: [IsEqualToDirective]
1167
- }]
1168
- }] });
1169
-
1170
- // endregion
1171
-
1172
- /**
1173
- * Generated bundle index. Do not edit.
1174
- */
1175
-
1176
- exports.ComposeOptionsTransformers = ComposeOptionsTransformers;
1177
- exports.ControlDataSource = ControlDataSource;
1178
- exports.ControlHideShowDirectiveModule = ControlHideShowDirectiveModule;
1179
- exports.DATA_SOURCE_NAME = DATA_SOURCE_NAME;
1180
- exports.ExtractControlMixin = ExtractControlMixin;
1181
- exports.ExtractDataSourcesMixin = ExtractDataSourcesMixin;
1182
- exports.ExtractFormDefinitionMixin = ExtractFormDefinitionMixin;
1183
- exports.FormSystemDirectivesModule = FormSystemDirectivesModule;
1184
- exports.FormSystemModule = FormSystemModule;
1185
- exports.InputSelectOptionsDirectiveModule = InputSelectOptionsDirectiveModule;
1186
- exports.IsEqualToDirective = IsEqualToDirective;
1187
- exports.IsEqualToDirectiveModule = IsEqualToDirectiveModule;
1188
- exports.RXAP_FORM_CONTROL_SOURCE = RXAP_FORM_CONTROL_SOURCE;
1189
- exports.RXAP_FORM_SYSTEM_HIDE_METADATA = RXAP_FORM_SYSTEM_HIDE_METADATA;
1190
- exports.RXAP_FORM_SYSTEM_HIDE_SHOW_OPTIONS = RXAP_FORM_SYSTEM_HIDE_SHOW_OPTIONS;
1191
- exports.RXAP_FORM_SYSTEM_SHOW_METADATA = RXAP_FORM_SYSTEM_SHOW_METADATA;
1192
- exports.RxapFormSystemError = RxapFormSystemError;
1193
- exports.UseComponent = UseComponent;
1194
- exports.UseDataSource = UseDataSource;
1195
- exports.UseFormComponent = UseFormComponent;
1196
- exports.UseHideFunction = UseHideFunction;
1197
- exports.UseOptionsDataSource = UseOptionsDataSource;
1198
- exports.UseShowFunction = UseShowFunction;
1199
- exports.controlDataSource = controlDataSource;
1200
-
1201
- Object.defineProperty(exports, '__esModule', { value: true });
1202
-
1203
- }));
1204
- //# sourceMappingURL=rxap-form-system.umd.js.map