@firestitch/form 9.7.6 → 9.7.7

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 (131) hide show
  1. package/app/components/form-dialog-actions/form-dialog-actions.component.d.ts +18 -18
  2. package/app/consts/error-messages.const.d.ts +19 -19
  3. package/app/directives/form/form.directive.d.ts +102 -102
  4. package/app/directives/form-dialog-close.directive.d.ts +9 -9
  5. package/app/directives/submit-button.directive.d.ts +28 -28
  6. package/app/directives/validators/compare.directive.d.ts +12 -12
  7. package/app/directives/validators/control.directive.d.ts +45 -45
  8. package/app/directives/validators/daterange.directive.d.ts +10 -10
  9. package/app/directives/validators/email.directive.d.ts +10 -10
  10. package/app/directives/validators/emails.directive.d.ts +10 -10
  11. package/app/directives/validators/function.directive.d.ts +11 -11
  12. package/app/directives/validators/greater.directive.d.ts +10 -10
  13. package/app/directives/validators/integer.directive.d.ts +10 -10
  14. package/app/directives/validators/lesser.directive.d.ts +10 -10
  15. package/app/directives/validators/max.directive.d.ts +10 -10
  16. package/app/directives/validators/maxlength.directive.d.ts +10 -10
  17. package/app/directives/validators/min.directive.d.ts +10 -10
  18. package/app/directives/validators/minlength.directive.d.ts +10 -10
  19. package/app/directives/validators/numeric.directive.d.ts +10 -10
  20. package/app/directives/validators/pattern.directive.d.ts +10 -10
  21. package/app/directives/validators/phone.directive.d.ts +10 -10
  22. package/app/directives/validators/required.directive.d.ts +13 -13
  23. package/app/directives/validators/url.directive.d.ts +11 -11
  24. package/app/directives/validators/validate.directive.d.ts +11 -11
  25. package/app/enums/confirm-result.d.ts +7 -7
  26. package/app/enums/form-status.d.ts +9 -9
  27. package/app/fs-form.module.d.ts +4 -4
  28. package/app/guards/form-deactivate.guard.d.ts +9 -9
  29. package/app/helpers/confirm-result-continue.d.ts +1 -1
  30. package/app/helpers/confirm-unsaved.d.ts +5 -5
  31. package/app/helpers/get-form-errors.d.ts +2 -2
  32. package/app/helpers/index.d.ts +2 -2
  33. package/app/helpers/is-enabled.d.ts +1 -1
  34. package/app/interfaces/async-validator.d.ts +14 -14
  35. package/app/interfaces/confirm-config.d.ts +7 -7
  36. package/app/interfaces/confirm-tab-group.d.ts +10 -10
  37. package/app/interfaces/form-deactivate.d.ts +4 -4
  38. package/app/interfaces/index.d.ts +4 -4
  39. package/app/interfaces/submit-event.d.ts +5 -5
  40. package/app/interfaces/submitted-event.d.ts +6 -6
  41. package/app/interfaces/validator.d.ts +13 -13
  42. package/app/providers/validate-messages.provider.d.ts +25 -25
  43. package/app/services/fsform.service.d.ts +7 -7
  44. package/app/validators/validators.d.ts +12 -12
  45. package/bundles/firestitch-form.umd.js +2300 -2303
  46. package/bundles/firestitch-form.umd.js.map +1 -1
  47. package/bundles/firestitch-form.umd.min.js +1 -1
  48. package/bundles/firestitch-form.umd.min.js.map +1 -1
  49. package/esm2015/app/components/form-dialog-actions/form-dialog-actions.component.js +92 -92
  50. package/esm2015/app/consts/error-messages.const.js +19 -19
  51. package/esm2015/app/directives/form/form.directive.js +665 -668
  52. package/esm2015/app/directives/form-dialog-close.directive.js +32 -32
  53. package/esm2015/app/directives/submit-button.directive.js +137 -137
  54. package/esm2015/app/directives/validators/compare.directive.js +48 -48
  55. package/esm2015/app/directives/validators/control.directive.js +272 -272
  56. package/esm2015/app/directives/validators/daterange.directive.js +40 -40
  57. package/esm2015/app/directives/validators/email.directive.js +40 -40
  58. package/esm2015/app/directives/validators/emails.directive.js +40 -40
  59. package/esm2015/app/directives/validators/function.directive.js +30 -30
  60. package/esm2015/app/directives/validators/greater.directive.js +39 -39
  61. package/esm2015/app/directives/validators/integer.directive.js +40 -40
  62. package/esm2015/app/directives/validators/lesser.directive.js +39 -39
  63. package/esm2015/app/directives/validators/max.directive.js +35 -35
  64. package/esm2015/app/directives/validators/maxlength.directive.js +34 -34
  65. package/esm2015/app/directives/validators/min.directive.js +35 -35
  66. package/esm2015/app/directives/validators/minlength.directive.js +34 -34
  67. package/esm2015/app/directives/validators/numeric.directive.js +40 -40
  68. package/esm2015/app/directives/validators/pattern.directive.js +34 -34
  69. package/esm2015/app/directives/validators/phone.directive.js +40 -40
  70. package/esm2015/app/directives/validators/required.directive.js +72 -72
  71. package/esm2015/app/directives/validators/url.directive.js +48 -48
  72. package/esm2015/app/directives/validators/validate.directive.js +30 -30
  73. package/esm2015/app/enums/confirm-result.js +8 -8
  74. package/esm2015/app/enums/form-status.js +10 -10
  75. package/esm2015/app/fs-form.module.js +105 -105
  76. package/esm2015/app/guards/form-deactivate.guard.js +43 -43
  77. package/esm2015/app/helpers/confirm-result-continue.js +4 -4
  78. package/esm2015/app/helpers/confirm-unsaved.js +69 -69
  79. package/esm2015/app/helpers/get-form-errors.js +24 -24
  80. package/esm2015/app/helpers/index.js +2 -2
  81. package/esm2015/app/helpers/is-enabled.js +3 -3
  82. package/esm2015/app/providers/validate-messages.provider.js +10 -10
  83. package/esm2015/app/services/fsform.service.js +25 -25
  84. package/esm2015/app/validators/validators.js +96 -96
  85. package/esm2015/firestitch-form.js +26 -26
  86. package/esm2015/public_api.js +13 -13
  87. package/esm5/app/components/form-dialog-actions/form-dialog-actions.component.js +95 -95
  88. package/esm5/app/consts/error-messages.const.js +19 -19
  89. package/esm5/app/directives/form/form.directive.js +706 -709
  90. package/esm5/app/directives/form-dialog-close.directive.js +33 -33
  91. package/esm5/app/directives/submit-button.directive.js +143 -143
  92. package/esm5/app/directives/validators/compare.directive.js +59 -59
  93. package/esm5/app/directives/validators/control.directive.js +278 -278
  94. package/esm5/app/directives/validators/daterange.directive.js +49 -49
  95. package/esm5/app/directives/validators/email.directive.js +49 -49
  96. package/esm5/app/directives/validators/emails.directive.js +49 -49
  97. package/esm5/app/directives/validators/function.directive.js +35 -35
  98. package/esm5/app/directives/validators/greater.directive.js +48 -48
  99. package/esm5/app/directives/validators/integer.directive.js +49 -49
  100. package/esm5/app/directives/validators/lesser.directive.js +48 -48
  101. package/esm5/app/directives/validators/max.directive.js +44 -44
  102. package/esm5/app/directives/validators/maxlength.directive.js +43 -43
  103. package/esm5/app/directives/validators/min.directive.js +44 -44
  104. package/esm5/app/directives/validators/minlength.directive.js +43 -43
  105. package/esm5/app/directives/validators/numeric.directive.js +49 -49
  106. package/esm5/app/directives/validators/pattern.directive.js +43 -43
  107. package/esm5/app/directives/validators/phone.directive.js +49 -49
  108. package/esm5/app/directives/validators/required.directive.js +87 -87
  109. package/esm5/app/directives/validators/url.directive.js +55 -55
  110. package/esm5/app/directives/validators/validate.directive.js +35 -35
  111. package/esm5/app/enums/confirm-result.js +8 -8
  112. package/esm5/app/enums/form-status.js +10 -10
  113. package/esm5/app/fs-form.module.js +109 -109
  114. package/esm5/app/guards/form-deactivate.guard.js +44 -44
  115. package/esm5/app/helpers/confirm-result-continue.js +4 -4
  116. package/esm5/app/helpers/confirm-unsaved.js +69 -69
  117. package/esm5/app/helpers/get-form-errors.js +27 -27
  118. package/esm5/app/helpers/index.js +2 -2
  119. package/esm5/app/helpers/is-enabled.js +3 -3
  120. package/esm5/app/providers/validate-messages.provider.js +11 -11
  121. package/esm5/app/services/fsform.service.js +26 -26
  122. package/esm5/app/validators/validators.js +101 -101
  123. package/esm5/firestitch-form.js +26 -26
  124. package/esm5/public_api.js +13 -13
  125. package/fesm2015/firestitch-form.js +2074 -2077
  126. package/fesm2015/firestitch-form.js.map +1 -1
  127. package/fesm5/firestitch-form.js +2303 -2306
  128. package/fesm5/firestitch-form.js.map +1 -1
  129. package/firestitch-form.d.ts +26 -26
  130. package/package.json +1 -1
  131. package/public_api.d.ts +12 -12
@@ -218,2377 +218,2374 @@
218
218
  return value;
219
219
  }
220
220
 
221
- (function (ConfirmResult) {
222
- ConfirmResult["Save"] = "save";
223
- ConfirmResult["Discard"] = "discard";
224
- ConfirmResult["Review"] = "review";
225
- ConfirmResult["Invalid"] = "invalid";
226
- ConfirmResult["Pristine"] = "pristine";
221
+ (function (ConfirmResult) {
222
+ ConfirmResult["Save"] = "save";
223
+ ConfirmResult["Discard"] = "discard";
224
+ ConfirmResult["Review"] = "review";
225
+ ConfirmResult["Invalid"] = "invalid";
226
+ ConfirmResult["Pristine"] = "pristine";
227
227
  })(exports.ConfirmResult || (exports.ConfirmResult = {}));
228
228
 
229
- function confirmUnsaved(form, prompt) {
230
- return new rxjs.Observable(function (observer) {
231
- if (!form.confirm || !form.ngForm.dirty) {
232
- observer.next(exports.ConfirmResult.Pristine);
233
- observer.complete();
234
- return;
235
- }
236
- var title = 'You Have Unsaved Changes';
237
- var message = 'What would you like to do with your changes?';
238
- var saveLabel = 'Save & Continue';
239
- var discardLabel = 'Discard Changes & Continue';
240
- var cancelLabel = 'Review Changes';
241
- if (typeof form.confirm === 'object') {
242
- title = form.confirm.title || title;
243
- message = form.confirm.message || message;
244
- saveLabel = form.confirm.saveLabel || saveLabel;
245
- discardLabel = form.confirm.discardLabel || discardLabel;
246
- cancelLabel = form.confirm.cancelLabel || cancelLabel;
247
- }
248
- prompt.confirm({
249
- title: title,
250
- template: message,
251
- dialogConfig: { width: 'auto' },
252
- buttons: [
253
- {
254
- label: saveLabel,
255
- color: 'primary',
256
- value: 'save'
257
- },
258
- {
259
- label: discardLabel,
260
- value: 'discard'
261
- },
262
- {
263
- label: cancelLabel,
264
- cancel: true
265
- }
266
- ]
267
- }).subscribe(function (value) {
268
- if (value === 'discard') {
269
- observer.next(exports.ConfirmResult.Discard);
270
- observer.complete();
271
- form.reset();
272
- }
273
- if (value === 'save') {
274
- form.submitted
275
- .pipe(operators.first())
276
- .subscribe(function () {
277
- observer.next(exports.ConfirmResult.Save);
278
- observer.complete();
279
- });
280
- form.invalid
281
- .pipe(operators.first())
282
- .subscribe(function () {
283
- observer.next(exports.ConfirmResult.Invalid);
284
- observer.complete();
285
- });
286
- form.ngForm.control.markAsPristine();
287
- form.ngForm.ngSubmit.emit();
288
- }
289
- }, function (error) {
290
- observer.next(exports.ConfirmResult.Review);
291
- observer.complete();
292
- });
293
- });
229
+ function confirmUnsaved(form, prompt) {
230
+ return new rxjs.Observable(function (observer) {
231
+ if (!form.confirm || !form.ngForm.dirty) {
232
+ observer.next(exports.ConfirmResult.Pristine);
233
+ observer.complete();
234
+ return;
235
+ }
236
+ var title = 'You Have Unsaved Changes';
237
+ var message = 'What would you like to do with your changes?';
238
+ var saveLabel = 'Save & Continue';
239
+ var discardLabel = 'Discard Changes & Continue';
240
+ var cancelLabel = 'Review Changes';
241
+ if (typeof form.confirm === 'object') {
242
+ title = form.confirm.title || title;
243
+ message = form.confirm.message || message;
244
+ saveLabel = form.confirm.saveLabel || saveLabel;
245
+ discardLabel = form.confirm.discardLabel || discardLabel;
246
+ cancelLabel = form.confirm.cancelLabel || cancelLabel;
247
+ }
248
+ prompt.confirm({
249
+ title: title,
250
+ template: message,
251
+ dialogConfig: { width: 'auto' },
252
+ buttons: [
253
+ {
254
+ label: saveLabel,
255
+ color: 'primary',
256
+ value: 'save'
257
+ },
258
+ {
259
+ label: discardLabel,
260
+ value: 'discard'
261
+ },
262
+ {
263
+ label: cancelLabel,
264
+ cancel: true
265
+ }
266
+ ]
267
+ }).subscribe(function (value) {
268
+ if (value === 'discard') {
269
+ observer.next(exports.ConfirmResult.Discard);
270
+ observer.complete();
271
+ form.reset();
272
+ }
273
+ if (value === 'save') {
274
+ form.submitted
275
+ .pipe(operators.first())
276
+ .subscribe(function () {
277
+ observer.next(exports.ConfirmResult.Save);
278
+ observer.complete();
279
+ });
280
+ form.invalid
281
+ .pipe(operators.first())
282
+ .subscribe(function () {
283
+ observer.next(exports.ConfirmResult.Invalid);
284
+ observer.complete();
285
+ });
286
+ form.ngForm.control.markAsPristine();
287
+ form.ngForm.ngSubmit.emit();
288
+ }
289
+ }, function (error) {
290
+ observer.next(exports.ConfirmResult.Review);
291
+ observer.complete();
292
+ });
293
+ });
294
294
  }
295
295
 
296
- var FsFormDialogCloseDirective = /** @class */ (function () {
297
- function FsFormDialogCloseDirective() {
298
- this.clicked$ = new rxjs.Subject();
299
- this.registered = false;
300
- this.type = 'button';
301
- }
302
- FsFormDialogCloseDirective.prototype.click = function () {
303
- this.clicked$.next();
304
- };
305
- FsFormDialogCloseDirective.prototype.ngOnDestroy = function () {
306
- this.clicked$.complete();
307
- };
308
- __decorate([
309
- core.HostBinding('attr.type'),
310
- __metadata("design:type", Object)
311
- ], FsFormDialogCloseDirective.prototype, "type", void 0);
312
- __decorate([
313
- core.HostListener('click', ['$event.target']),
314
- __metadata("design:type", Function),
315
- __metadata("design:paramtypes", []),
316
- __metadata("design:returntype", void 0)
317
- ], FsFormDialogCloseDirective.prototype, "click", null);
318
- FsFormDialogCloseDirective = __decorate([
319
- core.Directive({
320
- selector: '[fsFormDialogClose],[fs-form-dialog-close]'
321
- })
322
- ], FsFormDialogCloseDirective);
323
- return FsFormDialogCloseDirective;
296
+ var FsFormDialogCloseDirective = /** @class */ (function () {
297
+ function FsFormDialogCloseDirective() {
298
+ this.clicked$ = new rxjs.Subject();
299
+ this.registered = false;
300
+ this.type = 'button';
301
+ }
302
+ FsFormDialogCloseDirective.prototype.click = function () {
303
+ this.clicked$.next();
304
+ };
305
+ FsFormDialogCloseDirective.prototype.ngOnDestroy = function () {
306
+ this.clicked$.complete();
307
+ };
308
+ __decorate([
309
+ core.HostBinding('attr.type'),
310
+ __metadata("design:type", Object)
311
+ ], FsFormDialogCloseDirective.prototype, "type", void 0);
312
+ __decorate([
313
+ core.HostListener('click', ['$event.target']),
314
+ __metadata("design:type", Function),
315
+ __metadata("design:paramtypes", []),
316
+ __metadata("design:returntype", void 0)
317
+ ], FsFormDialogCloseDirective.prototype, "click", null);
318
+ FsFormDialogCloseDirective = __decorate([
319
+ core.Directive({
320
+ selector: '[fsFormDialogClose],[fs-form-dialog-close]'
321
+ })
322
+ ], FsFormDialogCloseDirective);
323
+ return FsFormDialogCloseDirective;
324
324
  }());
325
325
 
326
- var FsForm = /** @class */ (function () {
327
- function FsForm() {
328
- this._eventBus = new rxjs.Subject();
329
- }
330
- FsForm.prototype.broadcast = function (key, data) {
331
- this._eventBus.next({ key: key, data: data });
332
- };
333
- FsForm.prototype.on = function (key) {
334
- return this._eventBus.asObservable()
335
- .pipe(operators.filter(function (event) { return event.key === key; }), operators.map(function (event) { return event.data; }));
336
- };
337
- FsForm.ɵprov = core.ɵɵdefineInjectable({ factory: function FsForm_Factory() { return new FsForm(); }, token: FsForm, providedIn: "root" });
338
- FsForm = __decorate([
339
- core.Injectable({
340
- providedIn: 'root',
341
- }),
342
- __metadata("design:paramtypes", [])
343
- ], FsForm);
344
- return FsForm;
326
+ var FsForm = /** @class */ (function () {
327
+ function FsForm() {
328
+ this._eventBus = new rxjs.Subject();
329
+ }
330
+ FsForm.prototype.broadcast = function (key, data) {
331
+ this._eventBus.next({ key: key, data: data });
332
+ };
333
+ FsForm.prototype.on = function (key) {
334
+ return this._eventBus.asObservable()
335
+ .pipe(operators.filter(function (event) { return event.key === key; }), operators.map(function (event) { return event.data; }));
336
+ };
337
+ FsForm.ɵprov = core.ɵɵdefineInjectable({ factory: function FsForm_Factory() { return new FsForm(); }, token: FsForm, providedIn: "root" });
338
+ FsForm = __decorate([
339
+ core.Injectable({
340
+ providedIn: 'root',
341
+ }),
342
+ __metadata("design:paramtypes", [])
343
+ ], FsForm);
344
+ return FsForm;
345
345
  }());
346
346
 
347
-
348
- (function (FormStatus) {
349
- FormStatus["Valid"] = "valid";
350
- FormStatus["Invalid"] = "invalid";
351
- FormStatus["Submitting"] = "submitting";
352
- FormStatus["Submitted"] = "submitted";
353
- FormStatus["Error"] = "error";
354
- FormStatus["Success"] = "success";
355
- FormStatus["Completing"] = "completing";
347
+
348
+ (function (FormStatus) {
349
+ FormStatus["Valid"] = "valid";
350
+ FormStatus["Invalid"] = "invalid";
351
+ FormStatus["Submitting"] = "submitting";
352
+ FormStatus["Submitted"] = "submitted";
353
+ FormStatus["Error"] = "error";
354
+ FormStatus["Success"] = "success";
355
+ FormStatus["Completing"] = "completing";
356
356
  })(exports.FormStatus || (exports.FormStatus = {}));
357
357
 
358
- function confirmResultContinue(result) {
359
- return result === exports.ConfirmResult.Discard || result === exports.ConfirmResult.Save || result === exports.ConfirmResult.Pristine;
358
+ function confirmResultContinue(result) {
359
+ return result === exports.ConfirmResult.Discard || result === exports.ConfirmResult.Save || result === exports.ConfirmResult.Pristine;
360
360
  }
361
361
 
362
- function getFormErrors(control, key) {
363
- var _a;
364
- var errors = null;
365
- if (control.invalid && control.errors) {
366
- errors = (_a = {},
367
- _a[key] = __assign({}, control.errors),
368
- _a);
369
- }
370
- if (control instanceof forms.FormGroup) {
371
- Object.entries(control.controls)
372
- .forEach(function (_a) {
373
- var _b = __read(_a, 2), name = _b[0], childControl = _b[1];
374
- var childErrors = getFormErrors(childControl, name);
375
- if (childErrors) {
376
- if (!errors) {
377
- errors = __assign({}, childErrors);
378
- }
379
- else {
380
- Object.assign(errors, childErrors);
381
- }
382
- }
383
- });
384
- }
385
- return errors;
362
+ function getFormErrors(control, key) {
363
+ var _a;
364
+ var errors = null;
365
+ if (control.invalid && control.errors) {
366
+ errors = (_a = {},
367
+ _a[key] = __assign({}, control.errors),
368
+ _a);
369
+ }
370
+ if (control instanceof forms.FormGroup) {
371
+ Object.entries(control.controls)
372
+ .forEach(function (_a) {
373
+ var _b = __read(_a, 2), name = _b[0], childControl = _b[1];
374
+ var childErrors = getFormErrors(childControl, name);
375
+ if (childErrors) {
376
+ if (!errors) {
377
+ errors = __assign({}, childErrors);
378
+ }
379
+ else {
380
+ Object.assign(errors, childErrors);
381
+ }
382
+ }
383
+ });
384
+ }
385
+ return errors;
386
386
  }
387
387
 
388
- var FsFormDirective = /** @class */ (function () {
389
- function FsFormDirective(ngForm, _form, _element, _message, _prompt, _ngZone, _dialogRef, _drawerRef) {
390
- this.ngForm = ngForm;
391
- this._form = _form;
392
- this._element = _element;
393
- this._message = _message;
394
- this._prompt = _prompt;
395
- this._ngZone = _ngZone;
396
- this._dialogRef = _dialogRef;
397
- this._drawerRef = _drawerRef;
398
- this.wrapperSelector = '.fs-form-wrapper,.mat-form-field';
399
- this.messageSelector = '.fs-form-message,.mat-form-field-subscript-wrapper';
400
- this.hintSelector = '.fs-form-hint,.mat-form-field-hint-wrapper';
401
- this.labelSelector = '.fs-form-label,.mat-form-field-label';
402
- this.autocomplete = false;
403
- this.shortcuts = true; // Ctrl + s
404
- this.confirm = true;
405
- this.confirmDialog = true;
406
- this.confirmDrawer = true;
407
- this.confirmBrowser = true;
408
- this.confirmTabs = true;
409
- this.dirtySubmitButton = true;
410
- this.successDelay = 0;
411
- this.errorDelay = 1000;
412
- this.submitEvent = new core.EventEmitter();
413
- this.invalid = new core.EventEmitter();
414
- this.valid = new core.EventEmitter();
415
- this.submitted = new core.EventEmitter();
416
- this.reseted = new core.EventEmitter();
417
- this.cleared = new core.EventEmitter();
418
- this.fsformClass = true;
419
- this._tabGroups = new core.QueryList();
420
- this._submitButtons = new core.QueryList();
421
- this._dialogBackdropEscape = false;
422
- this._snapshot = {};
423
- this._status$ = new rxjs.BehaviorSubject(exports.FormStatus.Valid);
424
- this._destroy$ = new rxjs.Subject();
425
- }
426
- Object.defineProperty(FsFormDirective.prototype, "submitting", {
427
- get: function () {
428
- return this._status$.getValue() === exports.FormStatus.Submitting;
429
- },
430
- enumerable: true,
431
- configurable: true
432
- });
433
- Object.defineProperty(FsFormDirective.prototype, "completing", {
434
- get: function () {
435
- return this._status$.getValue() === exports.FormStatus.Completing;
436
- },
437
- enumerable: true,
438
- configurable: true
439
- });
440
- Object.defineProperty(FsFormDirective.prototype, "_submitEvent", {
441
- get: function () {
442
- return {
443
- ngForm: this.ngForm,
444
- submitter: this._submitter,
445
- };
446
- },
447
- enumerable: true,
448
- configurable: true
449
- });
450
- Object.defineProperty(FsFormDirective.prototype, "_formValidState$", {
451
- get: function () {
452
- this._form.broadcast('valid', this._submitEvent);
453
- this.submitEvent.emit(this._submitEvent);
454
- this.valid.emit(this._submitEvent);
455
- var submittedEvent = {
456
- ngForm: this.ngForm,
457
- submitter: this._submitter,
458
- response: null
459
- };
460
- if (!this.submit) {
461
- return rxjs.of(submittedEvent);
462
- }
463
- var result = this.submit(this._submitEvent);
464
- if (!rxjs.isObservable(result)) {
465
- return rxjs.of(submittedEvent);
466
- }
467
- return result
468
- .pipe(operators.map(function (response) {
469
- submittedEvent.response = response;
470
- return submittedEvent;
471
- }));
472
- },
473
- enumerable: true,
474
- configurable: true
475
- });
476
- Object.defineProperty(FsFormDirective.prototype, "_formInvalidState$", {
477
- get: function () {
478
- this._form.broadcast('invalid', this._submitEvent);
479
- if (this.invalid) {
480
- this.invalid.emit(this._submitEvent);
481
- }
482
- var message$1 = 'Changes not saved. Please review errors highlighted in red.';
483
- this._message.error(message$1, { mode: message.MessageMode.Toast });
484
- var el = this._element.nativeElement.querySelector('.ng-invalid');
485
- if (el) {
486
- el.scrollIntoView({ behavior: 'smooth', block: 'center' });
487
- }
488
- return rxjs.throwError('Form validation error');
489
- },
490
- enumerable: true,
491
- configurable: true
492
- });
493
- Object.defineProperty(FsFormDirective.prototype, "_submitter", {
494
- get: function () {
495
- return this._activeSubmitButton
496
- ? this._activeSubmitButton.name
497
- : null;
498
- },
499
- enumerable: true,
500
- configurable: true
501
- });
502
- FsFormDirective.prototype.ngOnInit = function () {
503
- this._registerConfirmDialogBackdropEscape();
504
- this._listenHotKeys();
505
- this._listenWindowClose();
506
- this._listenSubmit();
507
- if (!this.autocomplete) {
508
- this._registerAutocomplete();
509
- }
510
- };
511
- FsFormDirective.prototype.ngOnChanges = function (changes) {
512
- if (changes.confirm) {
513
- this._updateDirtySubmitButtons();
514
- }
515
- };
516
- FsFormDirective.prototype.ngAfterContentInit = function () {
517
- this._registerConfirm();
518
- this._registerConfirmDialogClose();
519
- this._registerConfirmDrawerClose();
520
- this._registerConfirmTabs();
521
- this._registerDrawerClose();
522
- this._registerDirtySubmitButton();
523
- };
524
- FsFormDirective.prototype.ngOnDestroy = function () {
525
- this._destroy$.next();
526
- this._destroy$.complete();
527
- };
528
- FsFormDirective.prototype.createSnapshot = function () {
529
- this._snapshot = this.ngForm.value;
530
- };
531
- FsFormDirective.prototype.reset = function () {
532
- var _this = this;
533
- this.ngForm.resetForm();
534
- Object.keys(this.ngForm.controls)
535
- .forEach(function (name) {
536
- var control = _this.ngForm.controls[name];
537
- control.reset(_this._snapshot[name]);
538
- });
539
- this.reseted.emit();
540
- };
541
- FsFormDirective.prototype.clear = function () {
542
- this.ngForm.resetForm();
543
- this.cleared.emit();
544
- };
545
- FsFormDirective.prototype.dirty = function () {
546
- this.ngForm.form.markAsDirty();
547
- this._updateDirtySubmitButtons();
548
- };
549
- FsFormDirective.prototype.triggerSubmit = function () {
550
- this.ngForm.ngSubmit.next();
551
- };
552
- FsFormDirective.prototype.triggerConfirm = function () {
553
- var _this = this;
554
- var submitted = this.submitting ? this.submitted.asObservable() : rxjs.of({});
555
- return submitted
556
- .pipe(operators.take(1), operators.mergeMap(function () { return confirmUnsaved(_this, _this._prompt); }));
557
- };
558
- FsFormDirective.prototype.enable = function () {
559
- this.ngForm.control.enable();
560
- this._updateDirtySubmitButtons();
561
- };
562
- FsFormDirective.prototype.disable = function () {
563
- this.ngForm.control.disable();
564
- this._submitButtons.forEach(function (button) {
565
- button.disable();
566
- });
567
- };
568
- FsFormDirective.prototype.addSubmitButton = function (submitButton) {
569
- this._submitButtons.reset(__spread(this._submitButtons.toArray(), [
570
- submitButton,
571
- ]));
572
- };
573
- FsFormDirective.prototype.removeSubmitButton = function (submitButton) {
574
- this._submitButtons.reset(__spread(this._submitButtons.toArray()
575
- .filter(function (submitButton_) { return (submitButton !== submitButton_); })));
576
- };
577
- FsFormDirective.prototype._listenSubmit = function () {
578
- var _this = this;
579
- this.ngForm
580
- .ngSubmit
581
- .pipe(operators.tap(function (event) {
582
- event === null || event === void 0 ? void 0 : event.preventDefault();
583
- }), operators.filter(function () {
584
- return [exports.FormStatus.Valid, exports.FormStatus.Invalid]
585
- .includes(_this._status$.getValue());
586
- }), operators.tap(function () { return _this._markControlsAsTouchedAndUpdateValidity(); }), operators.tap(function () { return _this._broadcastSubmittingEvents(); }), operators.switchMap(function () { return _this._waitUntilStatusPending(); }), operators.tap(function () { return _this._setupActiveSubmitButton(); }), operators.mergeMap(function () {
587
- return _this.ngForm.status === 'INVALID'
588
- ? _this._formInvalidState$
589
- : _this._formValidState$;
590
- }), operators.catchError(function (e, source$) {
591
- _this._handleError(e);
592
- return source$;
593
- }), operators.tap(function (submittedEvent) {
594
- _this._completeSubmit(true, submittedEvent);
595
- }), operators.takeUntil(this._destroy$))
596
- .subscribe(function () { });
597
- };
598
- FsFormDirective.prototype._listenWindowClose = function () {
599
- var _this = this;
600
- rxjs.fromEvent(window, 'beforeunload')
601
- .pipe(operators.takeUntil(this._destroy$))
602
- .subscribe(function (event) {
603
- if (_this.confirm && _this.confirmBrowser && _this.ngForm.dirty) {
604
- event.returnValue = false;
605
- }
606
- });
607
- };
608
- FsFormDirective.prototype._listenHotKeys = function () {
609
- var _this = this;
610
- this._ngZone.runOutsideAngular(function () {
611
- rxjs.fromEvent(document, 'keydown')
612
- .pipe(operators.takeUntil(_this._destroy$))
613
- .subscribe(function (event) {
614
- if (_this._dialogBackdropEscape && event.code === 'Escape') {
615
- var dialog_1 = document.getElementById(_this._dialogRef.id);
616
- var paths = event.composedPath();
617
- if (paths) {
618
- paths.forEach(function (item) {
619
- if (dialog_1 === item) {
620
- _this._ngZone.run(function () {
621
- _this._formClose();
622
- });
623
- }
624
- });
625
- }
626
- }
627
- if ((event.ctrlKey || event.metaKey) && event.code === 'KeyS') {
628
- event.preventDefault();
629
- if (_this.shortcuts) {
630
- if (_this._elementInForm(document.activeElement)) {
631
- _this.ngForm.ngSubmit.next();
632
- }
633
- }
634
- }
635
- });
636
- });
637
- };
638
- FsFormDirective.prototype._formClose = function () {
639
- var _this = this;
640
- if (this.confirm && this.confirmDialog) {
641
- this.triggerConfirm()
642
- .pipe(operators.filter(function (result) { return confirmResultContinue(result); }), operators.switchMap(function (result) {
643
- return result === exports.ConfirmResult.Pristine || result === exports.ConfirmResult.Discard
644
- ? rxjs.of(null)
645
- : _this.submitted.asObservable();
646
- }), operators.takeUntil(this._destroy$))
647
- .subscribe(function (result) {
648
- _this._dialogRef.close(result === null || result === void 0 ? void 0 : result.response);
649
- });
650
- }
651
- else {
652
- this._dialogRef.close(null);
653
- }
654
- };
655
- FsFormDirective.prototype._registerDialogClose = function (directive) {
656
- var _this = this;
657
- if (!directive.registered) {
658
- directive.registered = true;
659
- directive.clicked$
660
- .pipe(operators.takeUntil(this._destroy$))
661
- .subscribe(function () {
662
- _this._formClose();
663
- });
664
- }
665
- };
666
- FsFormDirective.prototype._getActiveButton = function () {
667
- var activeButton = this._submitButtons.find(function (button) {
668
- return button.active;
669
- });
670
- return activeButton ? activeButton : this._submitButtons.first;
671
- };
672
- FsFormDirective.prototype._elementInForm = function (el) {
673
- if (el.isSameNode(this._element.nativeElement)) {
674
- return true;
675
- }
676
- else if (el.parentElement) {
677
- return this._elementInForm(el.parentElement);
678
- }
679
- return false;
680
- };
681
- FsFormDirective.prototype._completeSubmit = function (success, submitEvent) {
682
- var _this = this;
683
- if (success) {
684
- this.ngForm.control.markAsPristine();
685
- this.createSnapshot();
686
- this.submitted.emit(submitEvent);
687
- }
688
- else {
689
- this._resetButtons();
690
- }
691
- if (this._activeSubmitButton) {
692
- if (success) {
693
- this._activeSubmitButton.success();
694
- }
695
- else {
696
- this._activeSubmitButton.error();
697
- }
698
- }
699
- this._status$.next(exports.FormStatus.Submitted);
700
- if (success) {
701
- this._status$.next(exports.FormStatus.Success);
702
- }
703
- else {
704
- this._status$.next(exports.FormStatus.Error);
705
- }
706
- this._status$.next(exports.FormStatus.Completing);
707
- var resetDelay = success ? this.successDelay : this.errorDelay;
708
- rxjs.of(true)
709
- .pipe(operators.delay(resetDelay), operators.first(), operators.takeUntil(this._destroy$)).subscribe(function () {
710
- if (_this.ngForm.form.status === 'VALID') {
711
- _this._status$.next(exports.FormStatus.Valid);
712
- }
713
- else {
714
- _this._status$.next(exports.FormStatus.Invalid);
715
- }
716
- _this._resetButtons();
717
- _this._updateDirtySubmitButtons();
718
- });
719
- };
720
- FsFormDirective.prototype._resetButtons = function () {
721
- this._submitButtons.forEach(function (button) {
722
- button.reset();
723
- });
724
- };
725
- FsFormDirective.prototype._registerConfirm = function () {
726
- var _this = this;
727
- this.ngForm.form.valueChanges
728
- .pipe(operators.takeUntil(this._destroy$))
729
- .subscribe(function (changes) {
730
- if (_this.confirm) {
731
- var existing_1 = Object.keys(_this._snapshot);
732
- Object.keys(changes)
733
- .forEach(function (name) {
734
- if (existing_1.indexOf(name) === -1) {
735
- _this._snapshot[name] = changes[name];
736
- }
737
- });
738
- }
739
- });
740
- };
741
- FsFormDirective.prototype._registerDrawerClose = function () {
742
- var _this = this;
743
- if (this._drawerRef) {
744
- this._drawerRef.closeStart$
745
- .pipe(operators.takeUntil(this._destroy$))
746
- .subscribe(function (subscriber) {
747
- if (_this.submitting) {
748
- _this._status$
749
- .pipe(operators.filter(function (status) { return status === exports.FormStatus.Success || status === exports.FormStatus.Error; }), operators.takeUntil(_this._destroy$))
750
- .subscribe(function (status) {
751
- if (status === exports.FormStatus.Success) {
752
- subscriber.next();
753
- subscriber.complete();
754
- }
755
- else {
756
- subscriber.error();
757
- }
758
- });
759
- }
760
- else {
761
- subscriber.next();
762
- subscriber.complete();
763
- }
764
- });
765
- }
766
- };
767
- FsFormDirective.prototype._registerConfirmDrawerClose = function () {
768
- var _this = this;
769
- if (this._drawerRef) {
770
- this._drawerRef.closeStart$
771
- .pipe(operators.switchMap(function (subscriber) {
772
- return rxjs.iif(function () { return _this.confirm && _this.confirmDrawer; }, _this.triggerConfirm()
773
- .pipe(operators.map(function (result) { return confirmResultContinue(result); }), operators.tap(function (result) {
774
- if (result) {
775
- subscriber.next();
776
- subscriber.complete();
777
- }
778
- else {
779
- subscriber.error();
780
- }
781
- })), rxjs.defer(function () {
782
- subscriber.next();
783
- subscriber.complete();
784
- }));
785
- }), operators.takeUntil(this._destroy$))
786
- .subscribe();
787
- }
788
- };
789
- FsFormDirective.prototype._registerConfirmTabs = function () {
790
- var _this = this;
791
- if (this.tabGroup) {
792
- this.registerConfirmTabGroup(this.tabGroup);
793
- }
794
- this.registerConfirmTabGroups(this._tabGroups.toArray());
795
- this._tabGroups.changes
796
- .pipe(operators.takeUntil(this._destroy$))
797
- .subscribe(function () {
798
- _this.registerConfirmTabGroups(_this._tabGroups.toArray());
799
- });
800
- };
801
- FsFormDirective.prototype.registerConfirmTabGroups = function (tabGroups) {
802
- var _this = this;
803
- tabGroups.forEach(function (tabGroup) {
804
- _this.registerConfirmTabGroup(tabGroup);
805
- });
806
- };
807
- FsFormDirective.prototype.registerConfirmTabGroup = function (tabGroup) {
808
- var _this = this;
809
- var confirmTabGroup = tabGroup;
810
- if (!confirmTabGroup._originalHandleClick) {
811
- confirmTabGroup._originalHandleClick = tabGroup._handleClick;
812
- confirmTabGroup._handlClick$ = new rxjs.Subject();
813
- confirmTabGroup._handleClick = function (tab, tabHeader, idx) {
814
- if (confirmTabGroup._handlClick$.observers.length) {
815
- confirmTabGroup._handlClick$.next({ tab: tab, tabHeader: tabHeader, idx: idx });
816
- }
817
- else {
818
- confirmTabGroup._originalHandleClick(tab, tabHeader, idx);
819
- }
820
- };
821
- }
822
- confirmTabGroup._handlClick$
823
- .pipe(operators.takeUntil(this._destroy$))
824
- .subscribe(function (event) {
825
- if (!_this.submitting) {
826
- if (_this.confirm && _this.confirmTabs) {
827
- _this.triggerConfirm()
828
- .pipe(operators.takeUntil(_this._destroy$))
829
- .subscribe(function (result) {
830
- if (confirmResultContinue(result)) {
831
- confirmTabGroup.selectedIndex = event.idx;
832
- }
833
- });
834
- }
835
- else {
836
- confirmTabGroup._originalHandleClick(event.tab, event.tabHeader, event.idx);
837
- }
838
- }
839
- });
840
- };
841
- FsFormDirective.prototype._registerConfirmDialogClose = function () {
842
- var _this = this;
843
- if (this._dialogRef) {
844
- this.formDialogClose.forEach(function (item) {
845
- _this._registerDialogClose(item);
846
- });
847
- this.formDialogClose.changes
848
- .pipe(operators.takeUntil(this._destroy$))
849
- .subscribe(function (e) {
850
- e.forEach(function (item) {
851
- _this._registerDialogClose(item);
852
- });
853
- });
854
- }
855
- };
856
- FsFormDirective.prototype._registerConfirmDialogBackdropEscape = function () {
857
- var _this = this;
858
- this._dialogBackdropEscape = this._dialogRef && this._dialogRef.disableClose !== true;
859
- if (this._dialogRef && !this._dialogRef.disableClose) {
860
- this._dialogRef.disableClose = true;
861
- this._dialogRef.backdropClick()
862
- .pipe(operators.takeUntil(this._destroy$))
863
- .subscribe(function () {
864
- _this._formClose();
865
- });
866
- this._destroy$
867
- .subscribe(function () {
868
- _this._dialogRef.disableClose = false;
869
- });
870
- }
871
- };
872
- FsFormDirective.prototype._registerAutocomplete = function () {
873
- var _this = this;
874
- this._registerControl = this.ngForm.form.registerControl.bind(this.ngForm.form);
875
- this.ngForm.form.registerControl = function (name, control) {
876
- var el = _this._element.nativeElement.querySelector("input[name='" + name + "']");
877
- if (el) {
878
- el.setAttribute('name', name + '_' + common$1.guid());
879
- if (!el.getAttribute('autocomplete')) {
880
- el.setAttribute('autocomplete', 'none');
881
- }
882
- }
883
- return _this._registerControl(name, control);
884
- };
885
- };
886
- FsFormDirective.prototype._registerDirtySubmitButton = function () {
887
- var _this = this;
888
- if (!this.ngForm) {
889
- return;
890
- }
891
- this.ngForm.form.valueChanges
892
- .pipe(operators.takeUntil(this._destroy$))
893
- .subscribe(function () {
894
- _this._updateDirtySubmitButtons();
895
- });
896
- this._submitButtons.changes
897
- .pipe(operators.takeUntil(this._destroy$))
898
- .subscribe(function () {
899
- _this._updateDirtySubmitButtons();
900
- });
901
- };
902
- FsFormDirective.prototype._updateDirtySubmitButtons = function () {
903
- var _this = this;
904
- this._submitButtons
905
- .forEach(function (submitButton) {
906
- if (!_this.confirm || !_this.dirtySubmitButton || _this.ngForm.dirty || !submitButton.dirtySubmit) {
907
- submitButton.enable();
908
- }
909
- else {
910
- submitButton.disable();
911
- }
912
- });
913
- };
914
- FsFormDirective.prototype._broadcastSubmittingEvents = function () {
915
- this._status$.next(exports.FormStatus.Submitting);
916
- this._form.broadcast('submit', this.ngForm);
917
- };
918
- FsFormDirective.prototype._markControlsAsTouchedAndUpdateValidity = function () {
919
- Object.values(this.ngForm.controls)
920
- .forEach(function (control) {
921
- control.markAsDirty();
922
- control.markAsTouched();
923
- control.updateValueAndValidity();
924
- });
925
- };
926
- FsFormDirective.prototype._setupActiveSubmitButton = function () {
927
- this._activeSubmitButton = this._getActiveButton();
928
- this._resetButtons();
929
- if (this._activeSubmitButton) {
930
- this._activeSubmitButton.process();
931
- }
932
- };
933
- FsFormDirective.prototype._waitUntilStatusPending = function () {
934
- return this.ngForm.statusChanges
935
- .pipe(operators.startWith(this.ngForm.status), operators.first(function (state) { return state !== 'PENDING'; }));
936
- };
937
- FsFormDirective.prototype._handleError = function (e) {
938
- console.log('%c Form Submit ', 'color: white; background-color: #D33F49', 'Error occured');
939
- console.group('Error Details:');
940
- console.log('Message: ', e);
941
- console.log('FormRef: ', this);
942
- if (this.ngForm.invalid) {
943
- var errors = getFormErrors(this.ngForm.control, null);
944
- console.log('Validation Errors: ', errors);
945
- }
946
- console.groupEnd();
947
- this._completeSubmit(false, null);
948
- };
949
- FsFormDirective.ctorParameters = function () { return [
950
- { type: forms.NgForm, decorators: [{ type: core.Inject, args: [forms.NgForm,] }] },
951
- { type: FsForm },
952
- { type: core.ElementRef },
953
- { type: message.FsMessage },
954
- { type: prompt.FsPrompt },
955
- { type: core.NgZone },
956
- { type: dialog.MatDialogRef, decorators: [{ type: core.Optional }, { type: core.Inject, args: [dialog.MatDialogRef,] }] },
957
- { type: drawer.DrawerRef, decorators: [{ type: core.Optional }, { type: core.Inject, args: [drawer.DrawerRef,] }] }
958
- ]; };
959
- __decorate([
960
- core.Input(),
961
- __metadata("design:type", Object)
962
- ], FsFormDirective.prototype, "wrapperSelector", void 0);
963
- __decorate([
964
- core.Input(),
965
- __metadata("design:type", Object)
966
- ], FsFormDirective.prototype, "messageSelector", void 0);
967
- __decorate([
968
- core.Input(),
969
- __metadata("design:type", Object)
970
- ], FsFormDirective.prototype, "hintSelector", void 0);
971
- __decorate([
972
- core.Input(),
973
- __metadata("design:type", Object)
974
- ], FsFormDirective.prototype, "labelSelector", void 0);
975
- __decorate([
976
- core.Input(),
977
- __metadata("design:type", Object)
978
- ], FsFormDirective.prototype, "autocomplete", void 0);
979
- __decorate([
980
- core.Input(),
981
- __metadata("design:type", Object)
982
- ], FsFormDirective.prototype, "shortcuts", void 0);
983
- __decorate([
984
- core.Input(),
985
- __metadata("design:type", Object)
986
- ], FsFormDirective.prototype, "confirm", void 0);
987
- __decorate([
988
- core.Input(),
989
- __metadata("design:type", Object)
990
- ], FsFormDirective.prototype, "confirmDialog", void 0);
991
- __decorate([
992
- core.Input(),
993
- __metadata("design:type", Object)
994
- ], FsFormDirective.prototype, "confirmDrawer", void 0);
995
- __decorate([
996
- core.Input(),
997
- __metadata("design:type", Object)
998
- ], FsFormDirective.prototype, "confirmBrowser", void 0);
999
- __decorate([
1000
- core.Input(),
1001
- __metadata("design:type", Object)
1002
- ], FsFormDirective.prototype, "confirmTabs", void 0);
1003
- __decorate([
1004
- core.Input(),
1005
- __metadata("design:type", Object)
1006
- ], FsFormDirective.prototype, "dirtySubmitButton", void 0);
1007
- __decorate([
1008
- core.Input(),
1009
- __metadata("design:type", Function)
1010
- ], FsFormDirective.prototype, "submit", void 0);
1011
- __decorate([
1012
- core.Input(),
1013
- __metadata("design:type", Object)
1014
- ], FsFormDirective.prototype, "successDelay", void 0);
1015
- __decorate([
1016
- core.Input(),
1017
- __metadata("design:type", Object)
1018
- ], FsFormDirective.prototype, "errorDelay", void 0);
1019
- __decorate([
1020
- core.Input(),
1021
- __metadata("design:type", tabs.MatTabGroup)
1022
- ], FsFormDirective.prototype, "tabGroup", void 0);
1023
- __decorate([
1024
- core.Output('fsForm'),
1025
- __metadata("design:type", core.EventEmitter)
1026
- ], FsFormDirective.prototype, "submitEvent", void 0);
1027
- __decorate([
1028
- core.Output(),
1029
- __metadata("design:type", core.EventEmitter)
1030
- ], FsFormDirective.prototype, "invalid", void 0);
1031
- __decorate([
1032
- core.Output(),
1033
- __metadata("design:type", core.EventEmitter)
1034
- ], FsFormDirective.prototype, "valid", void 0);
1035
- __decorate([
1036
- core.Output(),
1037
- __metadata("design:type", core.EventEmitter)
1038
- ], FsFormDirective.prototype, "submitted", void 0);
1039
- __decorate([
1040
- core.Output(),
1041
- __metadata("design:type", core.EventEmitter)
1042
- ], FsFormDirective.prototype, "reseted", void 0);
1043
- __decorate([
1044
- core.Output(),
1045
- __metadata("design:type", core.EventEmitter)
1046
- ], FsFormDirective.prototype, "cleared", void 0);
1047
- __decorate([
1048
- core.HostBinding('class.fs-form'),
1049
- __metadata("design:type", Object)
1050
- ], FsFormDirective.prototype, "fsformClass", void 0);
1051
- __decorate([
1052
- core.ContentChildren(FsFormDialogCloseDirective, { descendants: true }),
1053
- __metadata("design:type", core.QueryList)
1054
- ], FsFormDirective.prototype, "formDialogClose", void 0);
1055
- __decorate([
1056
- core.ContentChildren(tabs.MatTabGroup, { descendants: true }),
1057
- __metadata("design:type", core.QueryList)
1058
- ], FsFormDirective.prototype, "_tabGroups", void 0);
1059
- FsFormDirective = __decorate([
1060
- core.Directive({
1061
- selector: '[fsForm]',
1062
- }),
1063
- __param(0, core.Inject(forms.NgForm)),
1064
- __param(6, core.Optional()), __param(6, core.Inject(dialog.MatDialogRef)),
1065
- __param(7, core.Optional()), __param(7, core.Inject(drawer.DrawerRef)),
1066
- __metadata("design:paramtypes", [forms.NgForm,
1067
- FsForm,
1068
- core.ElementRef,
1069
- message.FsMessage,
1070
- prompt.FsPrompt,
1071
- core.NgZone,
1072
- dialog.MatDialogRef,
1073
- drawer.DrawerRef])
1074
- ], FsFormDirective);
1075
- return FsFormDirective;
388
+ var FsFormDirective = /** @class */ (function () {
389
+ function FsFormDirective(ngForm, _form, _element, _message, _prompt, _ngZone, _dialogRef, _drawerRef) {
390
+ this.ngForm = ngForm;
391
+ this._form = _form;
392
+ this._element = _element;
393
+ this._message = _message;
394
+ this._prompt = _prompt;
395
+ this._ngZone = _ngZone;
396
+ this._dialogRef = _dialogRef;
397
+ this._drawerRef = _drawerRef;
398
+ this.wrapperSelector = '.fs-form-wrapper,.mat-form-field';
399
+ this.messageSelector = '.fs-form-message,.mat-form-field-subscript-wrapper';
400
+ this.hintSelector = '.fs-form-hint,.mat-form-field-hint-wrapper';
401
+ this.labelSelector = '.fs-form-label,.mat-form-field-label';
402
+ this.autocomplete = false;
403
+ this.shortcuts = true; // Ctrl + s
404
+ this.confirm = true;
405
+ this.confirmDialog = true;
406
+ this.confirmDrawer = true;
407
+ this.confirmBrowser = true;
408
+ this.confirmTabs = true;
409
+ this.dirtySubmitButton = true;
410
+ this.successDelay = 0;
411
+ this.errorDelay = 1000;
412
+ this.submitEvent = new core.EventEmitter();
413
+ this.invalid = new core.EventEmitter();
414
+ this.valid = new core.EventEmitter();
415
+ this.submitted = new core.EventEmitter();
416
+ this.reseted = new core.EventEmitter();
417
+ this.cleared = new core.EventEmitter();
418
+ this.fsformClass = true;
419
+ this._tabGroups = new core.QueryList();
420
+ this._submitButtons = new core.QueryList();
421
+ this._dialogBackdropEscape = false;
422
+ this._snapshot = {};
423
+ this._status$ = new rxjs.BehaviorSubject(exports.FormStatus.Valid);
424
+ this._destroy$ = new rxjs.Subject();
425
+ }
426
+ Object.defineProperty(FsFormDirective.prototype, "submitting", {
427
+ get: function () {
428
+ return this._status$.getValue() === exports.FormStatus.Submitting;
429
+ },
430
+ enumerable: true,
431
+ configurable: true
432
+ });
433
+ Object.defineProperty(FsFormDirective.prototype, "completing", {
434
+ get: function () {
435
+ return this._status$.getValue() === exports.FormStatus.Completing;
436
+ },
437
+ enumerable: true,
438
+ configurable: true
439
+ });
440
+ Object.defineProperty(FsFormDirective.prototype, "_submitEvent", {
441
+ get: function () {
442
+ return {
443
+ ngForm: this.ngForm,
444
+ submitter: this._submitter,
445
+ };
446
+ },
447
+ enumerable: true,
448
+ configurable: true
449
+ });
450
+ Object.defineProperty(FsFormDirective.prototype, "_formValidState$", {
451
+ get: function () {
452
+ this._form.broadcast('valid', this._submitEvent);
453
+ this.submitEvent.emit(this._submitEvent);
454
+ this.valid.emit(this._submitEvent);
455
+ var submittedEvent = {
456
+ ngForm: this.ngForm,
457
+ submitter: this._submitter,
458
+ response: null
459
+ };
460
+ if (!this.submit) {
461
+ return rxjs.of(submittedEvent);
462
+ }
463
+ var result = this.submit(this._submitEvent);
464
+ if (!rxjs.isObservable(result)) {
465
+ return rxjs.of(submittedEvent);
466
+ }
467
+ return result
468
+ .pipe(operators.map(function (response) {
469
+ submittedEvent.response = response;
470
+ return submittedEvent;
471
+ }));
472
+ },
473
+ enumerable: true,
474
+ configurable: true
475
+ });
476
+ Object.defineProperty(FsFormDirective.prototype, "_formInvalidState$", {
477
+ get: function () {
478
+ this._form.broadcast('invalid', this._submitEvent);
479
+ if (this.invalid) {
480
+ this.invalid.emit(this._submitEvent);
481
+ }
482
+ var message$1 = 'Changes not saved. Please review errors highlighted in red.';
483
+ this._message.error(message$1, { mode: message.MessageMode.Toast });
484
+ var el = this._element.nativeElement.querySelector('.ng-invalid');
485
+ if (el) {
486
+ el.scrollIntoView({ behavior: 'smooth', block: 'center' });
487
+ }
488
+ return rxjs.throwError('Form validation error');
489
+ },
490
+ enumerable: true,
491
+ configurable: true
492
+ });
493
+ Object.defineProperty(FsFormDirective.prototype, "_submitter", {
494
+ get: function () {
495
+ return this._activeSubmitButton
496
+ ? this._activeSubmitButton.name
497
+ : null;
498
+ },
499
+ enumerable: true,
500
+ configurable: true
501
+ });
502
+ FsFormDirective.prototype.ngOnInit = function () {
503
+ this._registerConfirmDialogBackdropEscape();
504
+ this._listenHotKeys();
505
+ this._listenWindowClose();
506
+ this._listenSubmit();
507
+ if (!this.autocomplete) {
508
+ this._registerAutocomplete();
509
+ }
510
+ };
511
+ FsFormDirective.prototype.ngOnChanges = function (changes) {
512
+ if (changes.confirm) {
513
+ this._updateDirtySubmitButtons();
514
+ }
515
+ };
516
+ FsFormDirective.prototype.ngAfterContentInit = function () {
517
+ this._registerConfirm();
518
+ this._registerConfirmDialogClose();
519
+ this._registerConfirmDrawerClose();
520
+ this._registerConfirmTabs();
521
+ this._registerDrawerClose();
522
+ this._registerDirtySubmitButton();
523
+ };
524
+ FsFormDirective.prototype.ngOnDestroy = function () {
525
+ this._destroy$.next();
526
+ this._destroy$.complete();
527
+ };
528
+ FsFormDirective.prototype.createSnapshot = function () {
529
+ this._snapshot = this.ngForm.value;
530
+ };
531
+ FsFormDirective.prototype.reset = function () {
532
+ var _this = this;
533
+ this.ngForm.resetForm();
534
+ Object.keys(this.ngForm.controls)
535
+ .forEach(function (name) {
536
+ var control = _this.ngForm.controls[name];
537
+ control.reset(_this._snapshot[name]);
538
+ });
539
+ this.reseted.emit();
540
+ };
541
+ FsFormDirective.prototype.clear = function () {
542
+ this.ngForm.resetForm();
543
+ this.cleared.emit();
544
+ };
545
+ FsFormDirective.prototype.dirty = function () {
546
+ this.ngForm.form.markAsDirty();
547
+ this._updateDirtySubmitButtons();
548
+ };
549
+ FsFormDirective.prototype.triggerSubmit = function () {
550
+ this.ngForm.ngSubmit.next();
551
+ };
552
+ FsFormDirective.prototype.triggerConfirm = function () {
553
+ var _this = this;
554
+ var submitted = this.submitting ? this.submitted.asObservable() : rxjs.of({});
555
+ return submitted
556
+ .pipe(operators.take(1), operators.mergeMap(function () { return confirmUnsaved(_this, _this._prompt); }));
557
+ };
558
+ FsFormDirective.prototype.enable = function () {
559
+ this.ngForm.control.enable();
560
+ this._updateDirtySubmitButtons();
561
+ };
562
+ FsFormDirective.prototype.disable = function () {
563
+ this.ngForm.control.disable();
564
+ this._submitButtons.forEach(function (button) {
565
+ button.disable();
566
+ });
567
+ };
568
+ FsFormDirective.prototype.addSubmitButton = function (submitButton) {
569
+ this._submitButtons.reset(__spread(this._submitButtons.toArray(), [
570
+ submitButton,
571
+ ]));
572
+ };
573
+ FsFormDirective.prototype.removeSubmitButton = function (submitButton) {
574
+ this._submitButtons.reset(__spread(this._submitButtons.toArray()
575
+ .filter(function (submitButton_) { return (submitButton !== submitButton_); })));
576
+ };
577
+ FsFormDirective.prototype._listenSubmit = function () {
578
+ var _this = this;
579
+ this.ngForm
580
+ .ngSubmit
581
+ .pipe(operators.tap(function (event) {
582
+ event === null || event === void 0 ? void 0 : event.preventDefault();
583
+ }), operators.filter(function () {
584
+ return [exports.FormStatus.Valid, exports.FormStatus.Invalid]
585
+ .includes(_this._status$.getValue());
586
+ }), operators.tap(function () { return _this._markControlsAsTouchedAndUpdateValidity(); }), operators.tap(function () { return _this._broadcastSubmittingEvents(); }), operators.switchMap(function () { return _this._waitUntilStatusPending(); }), operators.tap(function () { return _this._setupActiveSubmitButton(); }), operators.mergeMap(function () {
587
+ return _this.ngForm.status === 'INVALID'
588
+ ? _this._formInvalidState$
589
+ : _this._formValidState$;
590
+ }), operators.catchError(function (e, source$) {
591
+ _this._handleError(e);
592
+ return source$;
593
+ }), operators.tap(function (submittedEvent) {
594
+ _this._completeSubmit(true, submittedEvent);
595
+ }), operators.takeUntil(this._destroy$))
596
+ .subscribe(function () { });
597
+ };
598
+ FsFormDirective.prototype._listenWindowClose = function () {
599
+ var _this = this;
600
+ rxjs.fromEvent(window, 'beforeunload')
601
+ .pipe(operators.takeUntil(this._destroy$))
602
+ .subscribe(function (event) {
603
+ if (_this.confirm && _this.confirmBrowser && _this.ngForm.dirty) {
604
+ event.returnValue = false;
605
+ }
606
+ });
607
+ };
608
+ FsFormDirective.prototype._listenHotKeys = function () {
609
+ var _this = this;
610
+ this._ngZone.runOutsideAngular(function () {
611
+ rxjs.fromEvent(document, 'keydown')
612
+ .pipe(operators.takeUntil(_this._destroy$))
613
+ .subscribe(function (event) {
614
+ if (_this._dialogBackdropEscape && event.code === 'Escape') {
615
+ var dialog_1 = document.getElementById(_this._dialogRef.id);
616
+ var paths = event.composedPath();
617
+ if (paths) {
618
+ paths.forEach(function (item) {
619
+ if (dialog_1 === item) {
620
+ _this._ngZone.run(function () {
621
+ _this._formClose();
622
+ });
623
+ }
624
+ });
625
+ }
626
+ }
627
+ if ((event.ctrlKey || event.metaKey) && event.code === 'KeyS') {
628
+ event.preventDefault();
629
+ if (_this.shortcuts) {
630
+ if (_this._elementInForm(document.activeElement)) {
631
+ _this.ngForm.ngSubmit.next();
632
+ }
633
+ }
634
+ }
635
+ });
636
+ });
637
+ };
638
+ FsFormDirective.prototype._formClose = function () {
639
+ var _this = this;
640
+ if (this.confirm && this.confirmDialog) {
641
+ this.triggerConfirm()
642
+ .pipe(operators.filter(function (result) { return confirmResultContinue(result); }), operators.switchMap(function (result) {
643
+ return result === exports.ConfirmResult.Pristine || result === exports.ConfirmResult.Discard
644
+ ? rxjs.of(null)
645
+ : _this.submitted.asObservable();
646
+ }), operators.takeUntil(this._destroy$))
647
+ .subscribe(function (result) {
648
+ _this._dialogRef.close(result === null || result === void 0 ? void 0 : result.response);
649
+ });
650
+ }
651
+ else {
652
+ this._dialogRef.close(null);
653
+ }
654
+ };
655
+ FsFormDirective.prototype._registerDialogClose = function (directive) {
656
+ var _this = this;
657
+ if (!directive.registered) {
658
+ directive.registered = true;
659
+ directive.clicked$
660
+ .pipe(operators.takeUntil(this._destroy$))
661
+ .subscribe(function () {
662
+ _this._formClose();
663
+ });
664
+ }
665
+ };
666
+ FsFormDirective.prototype._getActiveButton = function () {
667
+ var activeButton = this._submitButtons.find(function (button) {
668
+ return button.active;
669
+ });
670
+ return activeButton ? activeButton : this._submitButtons.first;
671
+ };
672
+ FsFormDirective.prototype._elementInForm = function (el) {
673
+ if (el.isSameNode(this._element.nativeElement)) {
674
+ return true;
675
+ }
676
+ else if (el.parentElement) {
677
+ return this._elementInForm(el.parentElement);
678
+ }
679
+ return false;
680
+ };
681
+ FsFormDirective.prototype._completeSubmit = function (success, submitEvent) {
682
+ var _this = this;
683
+ if (success) {
684
+ this.ngForm.control.markAsPristine();
685
+ this.createSnapshot();
686
+ this.submitted.emit(submitEvent);
687
+ }
688
+ else {
689
+ this._resetButtons();
690
+ }
691
+ if (this._activeSubmitButton) {
692
+ if (success) {
693
+ this._activeSubmitButton.success();
694
+ }
695
+ else {
696
+ this._activeSubmitButton.error();
697
+ }
698
+ }
699
+ this._status$.next(exports.FormStatus.Submitted);
700
+ if (success) {
701
+ this._status$.next(exports.FormStatus.Success);
702
+ }
703
+ else {
704
+ this._status$.next(exports.FormStatus.Error);
705
+ }
706
+ this._status$.next(exports.FormStatus.Completing);
707
+ var resetDelay = success ? this.successDelay : this.errorDelay;
708
+ rxjs.of(true)
709
+ .pipe(operators.delay(resetDelay), operators.first(), operators.takeUntil(this._destroy$)).subscribe(function () {
710
+ if (_this.ngForm.form.status === 'VALID') {
711
+ _this._status$.next(exports.FormStatus.Valid);
712
+ }
713
+ else {
714
+ _this._status$.next(exports.FormStatus.Invalid);
715
+ }
716
+ _this._resetButtons();
717
+ _this._updateDirtySubmitButtons();
718
+ });
719
+ };
720
+ FsFormDirective.prototype._resetButtons = function () {
721
+ this._submitButtons.forEach(function (button) {
722
+ button.reset();
723
+ });
724
+ };
725
+ FsFormDirective.prototype._registerConfirm = function () {
726
+ var _this = this;
727
+ this.ngForm.form.valueChanges
728
+ .pipe(operators.takeUntil(this._destroy$))
729
+ .subscribe(function (changes) {
730
+ if (_this.confirm) {
731
+ var existing_1 = Object.keys(_this._snapshot);
732
+ Object.keys(changes)
733
+ .forEach(function (name) {
734
+ if (existing_1.indexOf(name) === -1) {
735
+ _this._snapshot[name] = changes[name];
736
+ }
737
+ });
738
+ }
739
+ });
740
+ };
741
+ FsFormDirective.prototype._registerDrawerClose = function () {
742
+ var _this = this;
743
+ if (this._drawerRef) {
744
+ this._drawerRef.closeStart$
745
+ .pipe(operators.takeUntil(this._destroy$))
746
+ .subscribe(function (subscriber) {
747
+ if (_this.submitting) {
748
+ _this._status$
749
+ .pipe(operators.filter(function (status) { return status === exports.FormStatus.Success || status === exports.FormStatus.Error; }), operators.takeUntil(_this._destroy$))
750
+ .subscribe(function (status) {
751
+ if (status === exports.FormStatus.Success) {
752
+ subscriber.next();
753
+ subscriber.complete();
754
+ }
755
+ else {
756
+ subscriber.error();
757
+ }
758
+ });
759
+ }
760
+ else {
761
+ subscriber.next();
762
+ subscriber.complete();
763
+ }
764
+ });
765
+ }
766
+ };
767
+ FsFormDirective.prototype._registerConfirmDrawerClose = function () {
768
+ var _this = this;
769
+ if (this._drawerRef) {
770
+ this._drawerRef.closeStart$
771
+ .pipe(operators.switchMap(function (subscriber) {
772
+ return rxjs.iif(function () { return _this.confirm && _this.confirmDrawer; }, _this.triggerConfirm()
773
+ .pipe(operators.map(function (result) { return confirmResultContinue(result); }), operators.tap(function (result) {
774
+ if (result) {
775
+ subscriber.next();
776
+ subscriber.complete();
777
+ }
778
+ })), rxjs.defer(function () {
779
+ subscriber.next();
780
+ subscriber.complete();
781
+ }));
782
+ }), operators.takeUntil(this._destroy$))
783
+ .subscribe();
784
+ }
785
+ };
786
+ FsFormDirective.prototype._registerConfirmTabs = function () {
787
+ var _this = this;
788
+ if (this.tabGroup) {
789
+ this.registerConfirmTabGroup(this.tabGroup);
790
+ }
791
+ this.registerConfirmTabGroups(this._tabGroups.toArray());
792
+ this._tabGroups.changes
793
+ .pipe(operators.takeUntil(this._destroy$))
794
+ .subscribe(function () {
795
+ _this.registerConfirmTabGroups(_this._tabGroups.toArray());
796
+ });
797
+ };
798
+ FsFormDirective.prototype.registerConfirmTabGroups = function (tabGroups) {
799
+ var _this = this;
800
+ tabGroups.forEach(function (tabGroup) {
801
+ _this.registerConfirmTabGroup(tabGroup);
802
+ });
803
+ };
804
+ FsFormDirective.prototype.registerConfirmTabGroup = function (tabGroup) {
805
+ var _this = this;
806
+ var confirmTabGroup = tabGroup;
807
+ if (!confirmTabGroup._originalHandleClick) {
808
+ confirmTabGroup._originalHandleClick = tabGroup._handleClick;
809
+ confirmTabGroup._handlClick$ = new rxjs.Subject();
810
+ confirmTabGroup._handleClick = function (tab, tabHeader, idx) {
811
+ if (confirmTabGroup._handlClick$.observers.length) {
812
+ confirmTabGroup._handlClick$.next({ tab: tab, tabHeader: tabHeader, idx: idx });
813
+ }
814
+ else {
815
+ confirmTabGroup._originalHandleClick(tab, tabHeader, idx);
816
+ }
817
+ };
818
+ }
819
+ confirmTabGroup._handlClick$
820
+ .pipe(operators.takeUntil(this._destroy$))
821
+ .subscribe(function (event) {
822
+ if (!_this.submitting) {
823
+ if (_this.confirm && _this.confirmTabs) {
824
+ _this.triggerConfirm()
825
+ .pipe(operators.takeUntil(_this._destroy$))
826
+ .subscribe(function (result) {
827
+ if (confirmResultContinue(result)) {
828
+ confirmTabGroup.selectedIndex = event.idx;
829
+ }
830
+ });
831
+ }
832
+ else {
833
+ confirmTabGroup._originalHandleClick(event.tab, event.tabHeader, event.idx);
834
+ }
835
+ }
836
+ });
837
+ };
838
+ FsFormDirective.prototype._registerConfirmDialogClose = function () {
839
+ var _this = this;
840
+ if (this._dialogRef) {
841
+ this.formDialogClose.forEach(function (item) {
842
+ _this._registerDialogClose(item);
843
+ });
844
+ this.formDialogClose.changes
845
+ .pipe(operators.takeUntil(this._destroy$))
846
+ .subscribe(function (e) {
847
+ e.forEach(function (item) {
848
+ _this._registerDialogClose(item);
849
+ });
850
+ });
851
+ }
852
+ };
853
+ FsFormDirective.prototype._registerConfirmDialogBackdropEscape = function () {
854
+ var _this = this;
855
+ this._dialogBackdropEscape = this._dialogRef && this._dialogRef.disableClose !== true;
856
+ if (this._dialogRef && !this._dialogRef.disableClose) {
857
+ this._dialogRef.disableClose = true;
858
+ this._dialogRef.backdropClick()
859
+ .pipe(operators.takeUntil(this._destroy$))
860
+ .subscribe(function () {
861
+ _this._formClose();
862
+ });
863
+ this._destroy$
864
+ .subscribe(function () {
865
+ _this._dialogRef.disableClose = false;
866
+ });
867
+ }
868
+ };
869
+ FsFormDirective.prototype._registerAutocomplete = function () {
870
+ var _this = this;
871
+ this._registerControl = this.ngForm.form.registerControl.bind(this.ngForm.form);
872
+ this.ngForm.form.registerControl = function (name, control) {
873
+ var el = _this._element.nativeElement.querySelector("input[name='" + name + "']");
874
+ if (el) {
875
+ el.setAttribute('name', name + '_' + common$1.guid());
876
+ if (!el.getAttribute('autocomplete')) {
877
+ el.setAttribute('autocomplete', 'none');
878
+ }
879
+ }
880
+ return _this._registerControl(name, control);
881
+ };
882
+ };
883
+ FsFormDirective.prototype._registerDirtySubmitButton = function () {
884
+ var _this = this;
885
+ if (!this.ngForm) {
886
+ return;
887
+ }
888
+ this.ngForm.form.valueChanges
889
+ .pipe(operators.takeUntil(this._destroy$))
890
+ .subscribe(function () {
891
+ _this._updateDirtySubmitButtons();
892
+ });
893
+ this._submitButtons.changes
894
+ .pipe(operators.takeUntil(this._destroy$))
895
+ .subscribe(function () {
896
+ _this._updateDirtySubmitButtons();
897
+ });
898
+ };
899
+ FsFormDirective.prototype._updateDirtySubmitButtons = function () {
900
+ var _this = this;
901
+ this._submitButtons
902
+ .forEach(function (submitButton) {
903
+ if (!_this.confirm || !_this.dirtySubmitButton || _this.ngForm.dirty || !submitButton.dirtySubmit) {
904
+ submitButton.enable();
905
+ }
906
+ else {
907
+ submitButton.disable();
908
+ }
909
+ });
910
+ };
911
+ FsFormDirective.prototype._broadcastSubmittingEvents = function () {
912
+ this._status$.next(exports.FormStatus.Submitting);
913
+ this._form.broadcast('submit', this.ngForm);
914
+ };
915
+ FsFormDirective.prototype._markControlsAsTouchedAndUpdateValidity = function () {
916
+ Object.values(this.ngForm.controls)
917
+ .forEach(function (control) {
918
+ control.markAsDirty();
919
+ control.markAsTouched();
920
+ control.updateValueAndValidity();
921
+ });
922
+ };
923
+ FsFormDirective.prototype._setupActiveSubmitButton = function () {
924
+ this._activeSubmitButton = this._getActiveButton();
925
+ this._resetButtons();
926
+ if (this._activeSubmitButton) {
927
+ this._activeSubmitButton.process();
928
+ }
929
+ };
930
+ FsFormDirective.prototype._waitUntilStatusPending = function () {
931
+ return this.ngForm.statusChanges
932
+ .pipe(operators.startWith(this.ngForm.status), operators.first(function (state) { return state !== 'PENDING'; }));
933
+ };
934
+ FsFormDirective.prototype._handleError = function (e) {
935
+ console.log('%c Form Submit ', 'color: white; background-color: #D33F49', 'Error occured');
936
+ console.group('Error Details:');
937
+ console.log('Message: ', e);
938
+ console.log('FormRef: ', this);
939
+ if (this.ngForm.invalid) {
940
+ var errors = getFormErrors(this.ngForm.control, null);
941
+ console.log('Validation Errors: ', errors);
942
+ }
943
+ console.groupEnd();
944
+ this._completeSubmit(false, null);
945
+ };
946
+ FsFormDirective.ctorParameters = function () { return [
947
+ { type: forms.NgForm, decorators: [{ type: core.Inject, args: [forms.NgForm,] }] },
948
+ { type: FsForm },
949
+ { type: core.ElementRef },
950
+ { type: message.FsMessage },
951
+ { type: prompt.FsPrompt },
952
+ { type: core.NgZone },
953
+ { type: dialog.MatDialogRef, decorators: [{ type: core.Optional }, { type: core.Inject, args: [dialog.MatDialogRef,] }] },
954
+ { type: drawer.DrawerRef, decorators: [{ type: core.Optional }, { type: core.Inject, args: [drawer.DrawerRef,] }] }
955
+ ]; };
956
+ __decorate([
957
+ core.Input(),
958
+ __metadata("design:type", Object)
959
+ ], FsFormDirective.prototype, "wrapperSelector", void 0);
960
+ __decorate([
961
+ core.Input(),
962
+ __metadata("design:type", Object)
963
+ ], FsFormDirective.prototype, "messageSelector", void 0);
964
+ __decorate([
965
+ core.Input(),
966
+ __metadata("design:type", Object)
967
+ ], FsFormDirective.prototype, "hintSelector", void 0);
968
+ __decorate([
969
+ core.Input(),
970
+ __metadata("design:type", Object)
971
+ ], FsFormDirective.prototype, "labelSelector", void 0);
972
+ __decorate([
973
+ core.Input(),
974
+ __metadata("design:type", Object)
975
+ ], FsFormDirective.prototype, "autocomplete", void 0);
976
+ __decorate([
977
+ core.Input(),
978
+ __metadata("design:type", Object)
979
+ ], FsFormDirective.prototype, "shortcuts", void 0);
980
+ __decorate([
981
+ core.Input(),
982
+ __metadata("design:type", Object)
983
+ ], FsFormDirective.prototype, "confirm", void 0);
984
+ __decorate([
985
+ core.Input(),
986
+ __metadata("design:type", Object)
987
+ ], FsFormDirective.prototype, "confirmDialog", void 0);
988
+ __decorate([
989
+ core.Input(),
990
+ __metadata("design:type", Object)
991
+ ], FsFormDirective.prototype, "confirmDrawer", void 0);
992
+ __decorate([
993
+ core.Input(),
994
+ __metadata("design:type", Object)
995
+ ], FsFormDirective.prototype, "confirmBrowser", void 0);
996
+ __decorate([
997
+ core.Input(),
998
+ __metadata("design:type", Object)
999
+ ], FsFormDirective.prototype, "confirmTabs", void 0);
1000
+ __decorate([
1001
+ core.Input(),
1002
+ __metadata("design:type", Object)
1003
+ ], FsFormDirective.prototype, "dirtySubmitButton", void 0);
1004
+ __decorate([
1005
+ core.Input(),
1006
+ __metadata("design:type", Function)
1007
+ ], FsFormDirective.prototype, "submit", void 0);
1008
+ __decorate([
1009
+ core.Input(),
1010
+ __metadata("design:type", Object)
1011
+ ], FsFormDirective.prototype, "successDelay", void 0);
1012
+ __decorate([
1013
+ core.Input(),
1014
+ __metadata("design:type", Object)
1015
+ ], FsFormDirective.prototype, "errorDelay", void 0);
1016
+ __decorate([
1017
+ core.Input(),
1018
+ __metadata("design:type", tabs.MatTabGroup)
1019
+ ], FsFormDirective.prototype, "tabGroup", void 0);
1020
+ __decorate([
1021
+ core.Output('fsForm'),
1022
+ __metadata("design:type", core.EventEmitter)
1023
+ ], FsFormDirective.prototype, "submitEvent", void 0);
1024
+ __decorate([
1025
+ core.Output(),
1026
+ __metadata("design:type", core.EventEmitter)
1027
+ ], FsFormDirective.prototype, "invalid", void 0);
1028
+ __decorate([
1029
+ core.Output(),
1030
+ __metadata("design:type", core.EventEmitter)
1031
+ ], FsFormDirective.prototype, "valid", void 0);
1032
+ __decorate([
1033
+ core.Output(),
1034
+ __metadata("design:type", core.EventEmitter)
1035
+ ], FsFormDirective.prototype, "submitted", void 0);
1036
+ __decorate([
1037
+ core.Output(),
1038
+ __metadata("design:type", core.EventEmitter)
1039
+ ], FsFormDirective.prototype, "reseted", void 0);
1040
+ __decorate([
1041
+ core.Output(),
1042
+ __metadata("design:type", core.EventEmitter)
1043
+ ], FsFormDirective.prototype, "cleared", void 0);
1044
+ __decorate([
1045
+ core.HostBinding('class.fs-form'),
1046
+ __metadata("design:type", Object)
1047
+ ], FsFormDirective.prototype, "fsformClass", void 0);
1048
+ __decorate([
1049
+ core.ContentChildren(FsFormDialogCloseDirective, { descendants: true }),
1050
+ __metadata("design:type", core.QueryList)
1051
+ ], FsFormDirective.prototype, "formDialogClose", void 0);
1052
+ __decorate([
1053
+ core.ContentChildren(tabs.MatTabGroup, { descendants: true }),
1054
+ __metadata("design:type", core.QueryList)
1055
+ ], FsFormDirective.prototype, "_tabGroups", void 0);
1056
+ FsFormDirective = __decorate([
1057
+ core.Directive({
1058
+ selector: '[fsForm]',
1059
+ }),
1060
+ __param(0, core.Inject(forms.NgForm)),
1061
+ __param(6, core.Optional()), __param(6, core.Inject(dialog.MatDialogRef)),
1062
+ __param(7, core.Optional()), __param(7, core.Inject(drawer.DrawerRef)),
1063
+ __metadata("design:paramtypes", [forms.NgForm,
1064
+ FsForm,
1065
+ core.ElementRef,
1066
+ message.FsMessage,
1067
+ prompt.FsPrompt,
1068
+ core.NgZone,
1069
+ dialog.MatDialogRef,
1070
+ drawer.DrawerRef])
1071
+ ], FsFormDirective);
1072
+ return FsFormDirective;
1076
1073
  }());
1077
1074
 
1078
- var ERROR_MESSAGES = {
1079
- required: 'This field is required',
1080
- email: 'This is not a valid email address',
1081
- emails: 'Input valid email addresses, comma separated',
1082
- phone: 'Invalid phone number',
1083
- numeric: 'Value should be numeric',
1084
- integer: 'Value should be an integer',
1085
- min: 'Value should not be less than $(1)',
1086
- max: 'Value should not be greater than $(1)',
1087
- minlength: 'Should not be shorter than $(1) characters',
1088
- maxlength: 'Should not be longer than $(1) characters',
1089
- compare: 'Inputs do not match',
1090
- pattern: 'Value should match pattern $(1)',
1091
- dateRange: 'Invalid date range',
1092
- url: 'This is not a valid url',
1093
- urlProtocol: 'Invalid URL. Proper http protocol is required. eg. https://google.com',
1094
- greater: 'Value must be greater than $(1)',
1095
- lesser: 'Value must be less than $(1)',
1075
+ var ERROR_MESSAGES = {
1076
+ required: 'This field is required',
1077
+ email: 'This is not a valid email address',
1078
+ emails: 'Input valid email addresses, comma separated',
1079
+ phone: 'Invalid phone number',
1080
+ numeric: 'Value should be numeric',
1081
+ integer: 'Value should be an integer',
1082
+ min: 'Value should not be less than $(1)',
1083
+ max: 'Value should not be greater than $(1)',
1084
+ minlength: 'Should not be shorter than $(1) characters',
1085
+ maxlength: 'Should not be longer than $(1) characters',
1086
+ compare: 'Inputs do not match',
1087
+ pattern: 'Value should match pattern $(1)',
1088
+ dateRange: 'Invalid date range',
1089
+ url: 'This is not a valid url',
1090
+ urlProtocol: 'Invalid URL. Proper http protocol is required. eg. https://google.com',
1091
+ greater: 'Value must be greater than $(1)',
1092
+ lesser: 'Value must be less than $(1)',
1096
1093
  };
1097
1094
 
1098
- var VALIDATE_MESSAGES = new core.InjectionToken('fs.form.validate-messages');
1099
- var VALIDATE_MESSAGE_PROVIDER = {
1100
- provide: VALIDATE_MESSAGES,
1101
- useFactory: messageProviderFactory,
1102
- };
1103
- function messageProviderFactory() {
1104
- return __assign({}, ERROR_MESSAGES);
1095
+ var VALIDATE_MESSAGES = new core.InjectionToken('fs.form.validate-messages');
1096
+ var VALIDATE_MESSAGE_PROVIDER = {
1097
+ provide: VALIDATE_MESSAGES,
1098
+ useFactory: messageProviderFactory,
1099
+ };
1100
+ function messageProviderFactory() {
1101
+ return __assign({}, ERROR_MESSAGES);
1105
1102
  }
1106
1103
 
1107
- var FsControlDirective = /** @class */ (function () {
1108
- function FsControlDirective(elementRef, renderer2, injector, _validateMessages, ngControl, formDirective) {
1109
- this.elementRef = elementRef;
1110
- this.renderer2 = renderer2;
1111
- this.injector = injector;
1112
- this._validateMessages = _validateMessages;
1113
- this.ngControl = ngControl;
1114
- this.formDirective = formDirective;
1115
- this.appendMessageClass = 'fs-form-message';
1116
- this.appendLabelClass = 'fs-form-label';
1117
- this.appendErrorClass = 'fs-form-error';
1118
- this.appendHintClass = 'fs-form-hint';
1119
- this.errors = [];
1120
- // protected _validateMessages = { ...ERROR_MESSAGES };
1121
- this._destroy$ = new rxjs.Subject();
1122
- if (ngControl) {
1123
- this._control = ngControl.control;
1124
- }
1125
- else {
1126
- console.error('The element does not have a valid ngModel', this.elementRef.nativeElement);
1127
- }
1128
- }
1129
- Object.defineProperty(FsControlDirective.prototype, "validateMessages", {
1130
- set: function (messages) {
1131
- this._validateMessages = __assign(__assign({}, this._validateMessages), messages);
1132
- },
1133
- enumerable: true,
1134
- configurable: true
1135
- });
1136
- FsControlDirective.prototype.ngOnInit = function () {
1137
- this._setupValidators();
1138
- };
1139
- FsControlDirective.prototype.ngOnDestroy = function () {
1140
- this._destroy$.next();
1141
- this._destroy$.complete();
1142
- };
1143
- FsControlDirective.prototype.ngAfterContentInit = function () {
1144
- if (this._control) {
1145
- /*
1146
- Ensure that statusChanges has one subscription per control. Multiple can happen
1147
- when multiple fsForm validation directives are applied to the same element
1148
- */
1149
- if (!this._control.statusChangesSubscribe) {
1150
- this._control.statusChanges
1151
- .pipe(operators.takeUntil(this._destroy$))
1152
- .subscribe(this.render.bind(this));
1153
- this._control.statusChangesSubscribe = true;
1154
- }
1155
- }
1156
- };
1157
- FsControlDirective.prototype.getMessageSelector = function () {
1158
- if (this.messageSelector === false) {
1159
- return '';
1160
- }
1161
- if (this.messageSelector) {
1162
- return this.messageSelector;
1163
- }
1164
- else if (this.formDirective && this.formDirective.messageSelector) {
1165
- return this.formDirective.messageSelector;
1166
- }
1167
- };
1168
- FsControlDirective.prototype.getHintWrapperSelector = function () {
1169
- if (this.hintSelector === false) {
1170
- return '';
1171
- }
1172
- if (this.hintSelector) {
1173
- return this.hintSelector;
1174
- }
1175
- else if (this.formDirective && this.formDirective.hintSelector) {
1176
- return this.formDirective.hintSelector;
1177
- }
1178
- };
1179
- FsControlDirective.prototype.getWrapperSelector = function () {
1180
- if (this.wrapperSelector === false) {
1181
- return '';
1182
- }
1183
- if (this.wrapperSelector) {
1184
- return this.wrapperSelector;
1185
- }
1186
- else if (this.formDirective && this.formDirective.wrapperSelector) {
1187
- return this.formDirective.wrapperSelector;
1188
- }
1189
- };
1190
- FsControlDirective.prototype.getlabelSelector = function () {
1191
- if (this.labelSelector === false) {
1192
- return '';
1193
- }
1194
- if (this.labelSelector) {
1195
- return this.labelSelector;
1196
- }
1197
- else if (this.formDirective && this.formDirective.labelSelector) {
1198
- return this.formDirective.labelSelector;
1199
- }
1200
- };
1201
- FsControlDirective.prototype.getWrapperElement = function () {
1202
- var wrapper = this.getWrapper(this.elementRef.nativeElement);
1203
- if (wrapper) {
1204
- return wrapper;
1205
- }
1206
- return this.elementRef.nativeElement;
1207
- };
1208
- /*
1209
- <mat-form-field class="mat-form-field"> <-- Field Wrapper Class. Look for parents from the native element with the matching wrapperSelector. If not found defaults to native element.
1210
- <input>
1211
- <div class="fs-form-message"> <-- Message Selector. Look for the element with class .fs-form-message or messageSelector
1212
- <div class="fs-form-message"></div>
1213
- <div class="fs-form-hint"></div> <-- Hint Selector. Look for the element with class .fs-form-hint or hintSelector
1214
- </div>
1215
- </mat-form-field>
1216
- */
1217
- FsControlDirective.prototype.render = function () {
1218
- var _a;
1219
- if (this.ngControl) {
1220
- var renderer = this.renderer2;
1221
- var wrapper = this.getWrapperElement();
1222
- var error = this.ngControl.dirty ? this.getError(this.ngControl) : null;
1223
- if (!this.getMessageSelector()) {
1224
- return;
1225
- }
1226
- var messageWrapper = wrapper.querySelector(this.getMessageSelector());
1227
- if (!messageWrapper) {
1228
- return console.warn('Failed to locate ' + this.getMessageSelector(), this.elementRef.nativeElement);
1229
- }
1230
- if (this.getlabelSelector()) {
1231
- var labelWrapper = wrapper.querySelector(this.getlabelSelector());
1232
- if (labelWrapper) {
1233
- if (this.appendLabelClass) {
1234
- this.renderer2.addClass(labelWrapper, this.appendLabelClass);
1235
- }
1236
- }
1237
- }
1238
- if (this.appendMessageClass) {
1239
- renderer.addClass(messageWrapper, this.appendMessageClass);
1240
- }
1241
- if (this.getHintWrapperSelector()) {
1242
- var hint = messageWrapper.querySelector(this.getHintWrapperSelector());
1243
- if (hint) {
1244
- renderer.setStyle(hint, 'display', error ? 'none' : 'block');
1245
- if (this.appendHintClass) {
1246
- renderer.addClass(hint, this.appendHintClass);
1247
- }
1248
- }
1249
- }
1250
- var errorWrapper = wrapper.querySelector('.fs-form-error-target');
1251
- if (errorWrapper) {
1252
- errorWrapper.remove();
1253
- }
1254
- wrapper.classList.remove('ng-invalid');
1255
- var shouldErrorBeRendered = this.ngControl.invalid
1256
- && (this.ngControl.dirty || ((_a = this.formDirective.ngForm) === null || _a === void 0 ? void 0 : _a.submitted));
1257
- if (!shouldErrorBeRendered || !error) {
1258
- return;
1259
- }
1260
- wrapper.classList.add('ng-invalid');
1261
- errorWrapper = renderer.createElement('div');
1262
- renderer.addClass(errorWrapper, 'fs-form-error-target');
1263
- renderer.addClass(errorWrapper, this.appendErrorClass);
1264
- renderer.addClass(errorWrapper, this.appendErrorClass + '-' + error.name);
1265
- var errorText = renderer.createText(error.message);
1266
- renderer.appendChild(errorWrapper, errorText);
1267
- messageWrapper.appendChild(errorWrapper);
1268
- }
1269
- };
1270
- FsControlDirective.prototype.getWrapper = function (node, count) {
1271
- if (count === void 0) { count = 0; }
1272
- if (!node || count > 10) {
1273
- return null;
1274
- }
1275
- if (node.parentNode && node.parentNode.querySelector(this.getWrapperSelector())) {
1276
- return node;
1277
- }
1278
- return this.getWrapper(node.parentNode, ++count);
1279
- };
1280
- FsControlDirective.prototype.parseErrorMessage = function (message, args) {
1281
- lodashEs.values(args)
1282
- .forEach(function (name) {
1283
- message = message.replace(/\$\(\d\)/, name);
1284
- });
1285
- return message;
1286
- };
1287
- FsControlDirective.prototype.getError = function (controlRef) {
1288
- var name = lodashEs.keys(controlRef.control.errors)[0];
1289
- if (!name) {
1290
- return null;
1291
- }
1292
- var message = controlRef.control.errors[name];
1293
- if (this._validateMessages[name]) {
1294
- message = this.parseErrorMessage(this._validateMessages[name], message);
1295
- }
1296
- return { name: name, message: message };
1297
- };
1298
- FsControlDirective.prototype._setupValidators = function () {
1299
- var control = this._control;
1300
- if (this.validate) {
1301
- var validators = control.validator
1302
- ? [control.validator, this.validate.bind(this)]
1303
- : this.validate.bind(this);
1304
- control.setValidators(validators);
1305
- }
1306
- if (this.validateAsync) {
1307
- var asyncValidators = control.asyncValidator
1308
- ? [control.asyncValidator, this.validateAsync.bind(this)]
1309
- : this.validateAsync.bind(this);
1310
- control.setAsyncValidators(asyncValidators);
1311
- }
1312
- control.updateValueAndValidity();
1313
- };
1314
- FsControlDirective.ctorParameters = function () { return [
1315
- { type: core.ElementRef },
1316
- { type: core.Renderer2 },
1317
- { type: core.Injector },
1318
- { type: undefined, decorators: [{ type: core.Self }, { type: core.Inject, args: [VALIDATE_MESSAGES,] }] },
1319
- { type: forms.NgControl, decorators: [{ type: core.Optional }] },
1320
- { type: FsFormDirective, decorators: [{ type: core.Optional }, { type: core.Inject, args: [FsFormDirective,] }] }
1321
- ]; };
1322
- __decorate([
1323
- core.Input(),
1324
- __metadata("design:type", Object)
1325
- ], FsControlDirective.prototype, "wrapperSelector", void 0);
1326
- __decorate([
1327
- core.Input(),
1328
- __metadata("design:type", Object)
1329
- ], FsControlDirective.prototype, "messageSelector", void 0);
1330
- __decorate([
1331
- core.Input(),
1332
- __metadata("design:type", Object)
1333
- ], FsControlDirective.prototype, "hintSelector", void 0);
1334
- __decorate([
1335
- core.Input(),
1336
- __metadata("design:type", Object)
1337
- ], FsControlDirective.prototype, "labelSelector", void 0);
1338
- __decorate([
1339
- core.Input(),
1340
- __metadata("design:type", Object)
1341
- ], FsControlDirective.prototype, "appendMessageClass", void 0);
1342
- __decorate([
1343
- core.Input(),
1344
- __metadata("design:type", Object)
1345
- ], FsControlDirective.prototype, "appendLabelClass", void 0);
1346
- __decorate([
1347
- core.Input(),
1348
- __metadata("design:type", Object)
1349
- ], FsControlDirective.prototype, "appendErrorClass", void 0);
1350
- __decorate([
1351
- core.Input(),
1352
- __metadata("design:type", Object)
1353
- ], FsControlDirective.prototype, "appendHintClass", void 0);
1354
- __decorate([
1355
- core.Input(),
1356
- __metadata("design:type", Object),
1357
- __metadata("design:paramtypes", [Object])
1358
- ], FsControlDirective.prototype, "validateMessages", null);
1359
- FsControlDirective = __decorate([
1360
- core.Directive({
1361
- selector: '[fsFormControl]',
1362
- providers: [
1363
- VALIDATE_MESSAGE_PROVIDER
1364
- ],
1365
- }),
1366
- __param(3, core.Self()), __param(3, core.Inject(VALIDATE_MESSAGES)),
1367
- __param(4, core.Optional()),
1368
- __param(5, core.Optional()), __param(5, core.Inject(FsFormDirective)),
1369
- __metadata("design:paramtypes", [core.ElementRef,
1370
- core.Renderer2,
1371
- core.Injector, Object, forms.NgControl,
1372
- FsFormDirective])
1373
- ], FsControlDirective);
1374
- return FsControlDirective;
1104
+ var FsControlDirective = /** @class */ (function () {
1105
+ function FsControlDirective(elementRef, renderer2, injector, _validateMessages, ngControl, formDirective) {
1106
+ this.elementRef = elementRef;
1107
+ this.renderer2 = renderer2;
1108
+ this.injector = injector;
1109
+ this._validateMessages = _validateMessages;
1110
+ this.ngControl = ngControl;
1111
+ this.formDirective = formDirective;
1112
+ this.appendMessageClass = 'fs-form-message';
1113
+ this.appendLabelClass = 'fs-form-label';
1114
+ this.appendErrorClass = 'fs-form-error';
1115
+ this.appendHintClass = 'fs-form-hint';
1116
+ this.errors = [];
1117
+ // protected _validateMessages = { ...ERROR_MESSAGES };
1118
+ this._destroy$ = new rxjs.Subject();
1119
+ if (ngControl) {
1120
+ this._control = ngControl.control;
1121
+ }
1122
+ else {
1123
+ console.error('The element does not have a valid ngModel', this.elementRef.nativeElement);
1124
+ }
1125
+ }
1126
+ Object.defineProperty(FsControlDirective.prototype, "validateMessages", {
1127
+ set: function (messages) {
1128
+ this._validateMessages = __assign(__assign({}, this._validateMessages), messages);
1129
+ },
1130
+ enumerable: true,
1131
+ configurable: true
1132
+ });
1133
+ FsControlDirective.prototype.ngOnInit = function () {
1134
+ this._setupValidators();
1135
+ };
1136
+ FsControlDirective.prototype.ngOnDestroy = function () {
1137
+ this._destroy$.next();
1138
+ this._destroy$.complete();
1139
+ };
1140
+ FsControlDirective.prototype.ngAfterContentInit = function () {
1141
+ if (this._control) {
1142
+ /*
1143
+ Ensure that statusChanges has one subscription per control. Multiple can happen
1144
+ when multiple fsForm validation directives are applied to the same element
1145
+ */
1146
+ if (!this._control.statusChangesSubscribe) {
1147
+ this._control.statusChanges
1148
+ .pipe(operators.takeUntil(this._destroy$))
1149
+ .subscribe(this.render.bind(this));
1150
+ this._control.statusChangesSubscribe = true;
1151
+ }
1152
+ }
1153
+ };
1154
+ FsControlDirective.prototype.getMessageSelector = function () {
1155
+ if (this.messageSelector === false) {
1156
+ return '';
1157
+ }
1158
+ if (this.messageSelector) {
1159
+ return this.messageSelector;
1160
+ }
1161
+ else if (this.formDirective && this.formDirective.messageSelector) {
1162
+ return this.formDirective.messageSelector;
1163
+ }
1164
+ };
1165
+ FsControlDirective.prototype.getHintWrapperSelector = function () {
1166
+ if (this.hintSelector === false) {
1167
+ return '';
1168
+ }
1169
+ if (this.hintSelector) {
1170
+ return this.hintSelector;
1171
+ }
1172
+ else if (this.formDirective && this.formDirective.hintSelector) {
1173
+ return this.formDirective.hintSelector;
1174
+ }
1175
+ };
1176
+ FsControlDirective.prototype.getWrapperSelector = function () {
1177
+ if (this.wrapperSelector === false) {
1178
+ return '';
1179
+ }
1180
+ if (this.wrapperSelector) {
1181
+ return this.wrapperSelector;
1182
+ }
1183
+ else if (this.formDirective && this.formDirective.wrapperSelector) {
1184
+ return this.formDirective.wrapperSelector;
1185
+ }
1186
+ };
1187
+ FsControlDirective.prototype.getlabelSelector = function () {
1188
+ if (this.labelSelector === false) {
1189
+ return '';
1190
+ }
1191
+ if (this.labelSelector) {
1192
+ return this.labelSelector;
1193
+ }
1194
+ else if (this.formDirective && this.formDirective.labelSelector) {
1195
+ return this.formDirective.labelSelector;
1196
+ }
1197
+ };
1198
+ FsControlDirective.prototype.getWrapperElement = function () {
1199
+ var wrapper = this.getWrapper(this.elementRef.nativeElement);
1200
+ if (wrapper) {
1201
+ return wrapper;
1202
+ }
1203
+ return this.elementRef.nativeElement;
1204
+ };
1205
+ /*
1206
+ <mat-form-field class="mat-form-field"> <-- Field Wrapper Class. Look for parents from the native element with the matching wrapperSelector. If not found defaults to native element.
1207
+ <input>
1208
+ <div class="fs-form-message"> <-- Message Selector. Look for the element with class .fs-form-message or messageSelector
1209
+ <div class="fs-form-message"></div>
1210
+ <div class="fs-form-hint"></div> <-- Hint Selector. Look for the element with class .fs-form-hint or hintSelector
1211
+ </div>
1212
+ </mat-form-field>
1213
+ */
1214
+ FsControlDirective.prototype.render = function () {
1215
+ var _a;
1216
+ if (this.ngControl) {
1217
+ var renderer = this.renderer2;
1218
+ var wrapper = this.getWrapperElement();
1219
+ var error = this.ngControl.dirty ? this.getError(this.ngControl) : null;
1220
+ if (!this.getMessageSelector()) {
1221
+ return;
1222
+ }
1223
+ var messageWrapper = wrapper.querySelector(this.getMessageSelector());
1224
+ if (!messageWrapper) {
1225
+ return console.warn('Failed to locate ' + this.getMessageSelector(), this.elementRef.nativeElement);
1226
+ }
1227
+ if (this.getlabelSelector()) {
1228
+ var labelWrapper = wrapper.querySelector(this.getlabelSelector());
1229
+ if (labelWrapper) {
1230
+ if (this.appendLabelClass) {
1231
+ this.renderer2.addClass(labelWrapper, this.appendLabelClass);
1232
+ }
1233
+ }
1234
+ }
1235
+ if (this.appendMessageClass) {
1236
+ renderer.addClass(messageWrapper, this.appendMessageClass);
1237
+ }
1238
+ if (this.getHintWrapperSelector()) {
1239
+ var hint = messageWrapper.querySelector(this.getHintWrapperSelector());
1240
+ if (hint) {
1241
+ renderer.setStyle(hint, 'display', error ? 'none' : 'block');
1242
+ if (this.appendHintClass) {
1243
+ renderer.addClass(hint, this.appendHintClass);
1244
+ }
1245
+ }
1246
+ }
1247
+ var errorWrapper = wrapper.querySelector('.fs-form-error-target');
1248
+ if (errorWrapper) {
1249
+ errorWrapper.remove();
1250
+ }
1251
+ wrapper.classList.remove('ng-invalid');
1252
+ var shouldErrorBeRendered = this.ngControl.invalid
1253
+ && (this.ngControl.dirty || ((_a = this.formDirective.ngForm) === null || _a === void 0 ? void 0 : _a.submitted));
1254
+ if (!shouldErrorBeRendered || !error) {
1255
+ return;
1256
+ }
1257
+ wrapper.classList.add('ng-invalid');
1258
+ errorWrapper = renderer.createElement('div');
1259
+ renderer.addClass(errorWrapper, 'fs-form-error-target');
1260
+ renderer.addClass(errorWrapper, this.appendErrorClass);
1261
+ renderer.addClass(errorWrapper, this.appendErrorClass + '-' + error.name);
1262
+ var errorText = renderer.createText(error.message);
1263
+ renderer.appendChild(errorWrapper, errorText);
1264
+ messageWrapper.appendChild(errorWrapper);
1265
+ }
1266
+ };
1267
+ FsControlDirective.prototype.getWrapper = function (node, count) {
1268
+ if (count === void 0) { count = 0; }
1269
+ if (!node || count > 10) {
1270
+ return null;
1271
+ }
1272
+ if (node.parentNode && node.parentNode.querySelector(this.getWrapperSelector())) {
1273
+ return node;
1274
+ }
1275
+ return this.getWrapper(node.parentNode, ++count);
1276
+ };
1277
+ FsControlDirective.prototype.parseErrorMessage = function (message, args) {
1278
+ lodashEs.values(args)
1279
+ .forEach(function (name) {
1280
+ message = message.replace(/\$\(\d\)/, name);
1281
+ });
1282
+ return message;
1283
+ };
1284
+ FsControlDirective.prototype.getError = function (controlRef) {
1285
+ var name = lodashEs.keys(controlRef.control.errors)[0];
1286
+ if (!name) {
1287
+ return null;
1288
+ }
1289
+ var message = controlRef.control.errors[name];
1290
+ if (this._validateMessages[name]) {
1291
+ message = this.parseErrorMessage(this._validateMessages[name], message);
1292
+ }
1293
+ return { name: name, message: message };
1294
+ };
1295
+ FsControlDirective.prototype._setupValidators = function () {
1296
+ var control = this._control;
1297
+ if (this.validate) {
1298
+ var validators = control.validator
1299
+ ? [control.validator, this.validate.bind(this)]
1300
+ : this.validate.bind(this);
1301
+ control.setValidators(validators);
1302
+ }
1303
+ if (this.validateAsync) {
1304
+ var asyncValidators = control.asyncValidator
1305
+ ? [control.asyncValidator, this.validateAsync.bind(this)]
1306
+ : this.validateAsync.bind(this);
1307
+ control.setAsyncValidators(asyncValidators);
1308
+ }
1309
+ control.updateValueAndValidity();
1310
+ };
1311
+ FsControlDirective.ctorParameters = function () { return [
1312
+ { type: core.ElementRef },
1313
+ { type: core.Renderer2 },
1314
+ { type: core.Injector },
1315
+ { type: undefined, decorators: [{ type: core.Self }, { type: core.Inject, args: [VALIDATE_MESSAGES,] }] },
1316
+ { type: forms.NgControl, decorators: [{ type: core.Optional }] },
1317
+ { type: FsFormDirective, decorators: [{ type: core.Optional }, { type: core.Inject, args: [FsFormDirective,] }] }
1318
+ ]; };
1319
+ __decorate([
1320
+ core.Input(),
1321
+ __metadata("design:type", Object)
1322
+ ], FsControlDirective.prototype, "wrapperSelector", void 0);
1323
+ __decorate([
1324
+ core.Input(),
1325
+ __metadata("design:type", Object)
1326
+ ], FsControlDirective.prototype, "messageSelector", void 0);
1327
+ __decorate([
1328
+ core.Input(),
1329
+ __metadata("design:type", Object)
1330
+ ], FsControlDirective.prototype, "hintSelector", void 0);
1331
+ __decorate([
1332
+ core.Input(),
1333
+ __metadata("design:type", Object)
1334
+ ], FsControlDirective.prototype, "labelSelector", void 0);
1335
+ __decorate([
1336
+ core.Input(),
1337
+ __metadata("design:type", Object)
1338
+ ], FsControlDirective.prototype, "appendMessageClass", void 0);
1339
+ __decorate([
1340
+ core.Input(),
1341
+ __metadata("design:type", Object)
1342
+ ], FsControlDirective.prototype, "appendLabelClass", void 0);
1343
+ __decorate([
1344
+ core.Input(),
1345
+ __metadata("design:type", Object)
1346
+ ], FsControlDirective.prototype, "appendErrorClass", void 0);
1347
+ __decorate([
1348
+ core.Input(),
1349
+ __metadata("design:type", Object)
1350
+ ], FsControlDirective.prototype, "appendHintClass", void 0);
1351
+ __decorate([
1352
+ core.Input(),
1353
+ __metadata("design:type", Object),
1354
+ __metadata("design:paramtypes", [Object])
1355
+ ], FsControlDirective.prototype, "validateMessages", null);
1356
+ FsControlDirective = __decorate([
1357
+ core.Directive({
1358
+ selector: '[fsFormControl]',
1359
+ providers: [
1360
+ VALIDATE_MESSAGE_PROVIDER
1361
+ ],
1362
+ }),
1363
+ __param(3, core.Self()), __param(3, core.Inject(VALIDATE_MESSAGES)),
1364
+ __param(4, core.Optional()),
1365
+ __param(5, core.Optional()), __param(5, core.Inject(FsFormDirective)),
1366
+ __metadata("design:paramtypes", [core.ElementRef,
1367
+ core.Renderer2,
1368
+ core.Injector, Object, forms.NgControl,
1369
+ FsFormDirective])
1370
+ ], FsControlDirective);
1371
+ return FsControlDirective;
1375
1372
  }());
1376
1373
 
1377
- function isEnabled(value) {
1378
- return value !== 'false' && (value || value === '');
1374
+ function isEnabled(value) {
1375
+ return value !== 'false' && (value || value === '');
1379
1376
  }
1380
1377
 
1381
- var FsFormRequiredDirective = /** @class */ (function (_super) {
1382
- __extends(FsFormRequiredDirective, _super);
1383
- function FsFormRequiredDirective() {
1384
- var _this = _super !== null && _super.apply(this, arguments) || this;
1385
- _this.required = false;
1386
- return _this;
1387
- }
1388
- Object.defineProperty(FsFormRequiredDirective.prototype, "setFsFormRequired", {
1389
- set: function (value) {
1390
- this.required = isEnabled(value);
1391
- },
1392
- enumerable: true,
1393
- configurable: true
1394
- });
1395
- Object.defineProperty(FsFormRequiredDirective.prototype, "setRequired", {
1396
- set: function (value) {
1397
- this.required = isEnabled(value);
1398
- },
1399
- enumerable: true,
1400
- configurable: true
1401
- });
1402
- Object.defineProperty(FsFormRequiredDirective.prototype, "validationMessage", {
1403
- set: function (value) {
1404
- this._validateMessages.required = value;
1405
- },
1406
- enumerable: true,
1407
- configurable: true
1408
- });
1409
- FsFormRequiredDirective.prototype.ngOnChanges = function () {
1410
- this._control.updateValueAndValidity();
1411
- };
1412
- FsFormRequiredDirective.prototype.validate = function (control) {
1413
- if (this.required) {
1414
- return forms.Validators.required(this._control);
1415
- }
1416
- else {
1417
- return null;
1418
- }
1419
- };
1420
- FsFormRequiredDirective.prototype.render = function () {
1421
- var wrapper = this.getWrapperElement();
1422
- if (wrapper && this.getlabelSelector()) {
1423
- var labelWrapper = wrapper.querySelector(this.getlabelSelector());
1424
- // Adding class fs-form-label-requried adds the * to the label
1425
- if (labelWrapper) {
1426
- if (this.required) {
1427
- this.renderer2.addClass(labelWrapper, 'fs-form-label-required');
1428
- }
1429
- else {
1430
- this.renderer2.removeClass(labelWrapper, 'fs-form-label-required');
1431
- }
1432
- }
1433
- }
1434
- _super.prototype.render.call(this);
1435
- };
1436
- __decorate([
1437
- core.Input('fsFormRequired'),
1438
- __metadata("design:type", Object),
1439
- __metadata("design:paramtypes", [Object])
1440
- ], FsFormRequiredDirective.prototype, "setFsFormRequired", null);
1441
- __decorate([
1442
- core.Input('required'),
1443
- __metadata("design:type", Object),
1444
- __metadata("design:paramtypes", [Object])
1445
- ], FsFormRequiredDirective.prototype, "setRequired", null);
1446
- __decorate([
1447
- core.Input('fsFormRequiredMessage'),
1448
- __metadata("design:type", String),
1449
- __metadata("design:paramtypes", [String])
1450
- ], FsFormRequiredDirective.prototype, "validationMessage", null);
1451
- FsFormRequiredDirective = __decorate([
1452
- core.Directive({
1453
- selector: '[fsFormRequired],[ngModel][required]',
1454
- providers: [
1455
- VALIDATE_MESSAGE_PROVIDER
1456
- ],
1457
- })
1458
- ], FsFormRequiredDirective);
1459
- return FsFormRequiredDirective;
1378
+ var FsFormRequiredDirective = /** @class */ (function (_super) {
1379
+ __extends(FsFormRequiredDirective, _super);
1380
+ function FsFormRequiredDirective() {
1381
+ var _this = _super !== null && _super.apply(this, arguments) || this;
1382
+ _this.required = false;
1383
+ return _this;
1384
+ }
1385
+ Object.defineProperty(FsFormRequiredDirective.prototype, "setFsFormRequired", {
1386
+ set: function (value) {
1387
+ this.required = isEnabled(value);
1388
+ },
1389
+ enumerable: true,
1390
+ configurable: true
1391
+ });
1392
+ Object.defineProperty(FsFormRequiredDirective.prototype, "setRequired", {
1393
+ set: function (value) {
1394
+ this.required = isEnabled(value);
1395
+ },
1396
+ enumerable: true,
1397
+ configurable: true
1398
+ });
1399
+ Object.defineProperty(FsFormRequiredDirective.prototype, "validationMessage", {
1400
+ set: function (value) {
1401
+ this._validateMessages.required = value;
1402
+ },
1403
+ enumerable: true,
1404
+ configurable: true
1405
+ });
1406
+ FsFormRequiredDirective.prototype.ngOnChanges = function () {
1407
+ this._control.updateValueAndValidity();
1408
+ };
1409
+ FsFormRequiredDirective.prototype.validate = function (control) {
1410
+ if (this.required) {
1411
+ return forms.Validators.required(this._control);
1412
+ }
1413
+ else {
1414
+ return null;
1415
+ }
1416
+ };
1417
+ FsFormRequiredDirective.prototype.render = function () {
1418
+ var wrapper = this.getWrapperElement();
1419
+ if (wrapper && this.getlabelSelector()) {
1420
+ var labelWrapper = wrapper.querySelector(this.getlabelSelector());
1421
+ // Adding class fs-form-label-requried adds the * to the label
1422
+ if (labelWrapper) {
1423
+ if (this.required) {
1424
+ this.renderer2.addClass(labelWrapper, 'fs-form-label-required');
1425
+ }
1426
+ else {
1427
+ this.renderer2.removeClass(labelWrapper, 'fs-form-label-required');
1428
+ }
1429
+ }
1430
+ }
1431
+ _super.prototype.render.call(this);
1432
+ };
1433
+ __decorate([
1434
+ core.Input('fsFormRequired'),
1435
+ __metadata("design:type", Object),
1436
+ __metadata("design:paramtypes", [Object])
1437
+ ], FsFormRequiredDirective.prototype, "setFsFormRequired", null);
1438
+ __decorate([
1439
+ core.Input('required'),
1440
+ __metadata("design:type", Object),
1441
+ __metadata("design:paramtypes", [Object])
1442
+ ], FsFormRequiredDirective.prototype, "setRequired", null);
1443
+ __decorate([
1444
+ core.Input('fsFormRequiredMessage'),
1445
+ __metadata("design:type", String),
1446
+ __metadata("design:paramtypes", [String])
1447
+ ], FsFormRequiredDirective.prototype, "validationMessage", null);
1448
+ FsFormRequiredDirective = __decorate([
1449
+ core.Directive({
1450
+ selector: '[fsFormRequired],[ngModel][required]',
1451
+ providers: [
1452
+ VALIDATE_MESSAGE_PROVIDER
1453
+ ],
1454
+ })
1455
+ ], FsFormRequiredDirective);
1456
+ return FsFormRequiredDirective;
1460
1457
  }(FsControlDirective));
1461
1458
 
1462
- var FsValidators = /** @class */ (function () {
1463
- function FsValidators() {
1464
- }
1465
- FsValidators.email = function (control) {
1466
- if (!control.value || common$1.email(control.value)) {
1467
- return null;
1468
- }
1469
- return { email: true };
1470
- };
1471
- FsValidators.emails = function (control) {
1472
- var model = control.value || '';
1473
- var hasInvalidEmails = model
1474
- .split(',')
1475
- .some(function (part) { return !common$1.email(part); });
1476
- return hasInvalidEmails ? { email: true } : null;
1477
- };
1478
- FsValidators.numeric = function (control) {
1479
- if (common$1.isEmpty(control.value) || common$1.isNumeric(control.value)) {
1480
- return null;
1481
- }
1482
- else {
1483
- return { numeric: true };
1484
- }
1485
- };
1486
- FsValidators.integer = function (control) {
1487
- if (!control.value || String(control.value) === '' || (control.value % 1 === 0)) {
1488
- return null;
1489
- }
1490
- else {
1491
- return { integer: true };
1492
- }
1493
- };
1494
- FsValidators.phone = function (control) {
1495
- if (!control.value || common$1.phone(control.value)) {
1496
- return null;
1497
- }
1498
- return { phone: true };
1499
- };
1500
- FsValidators.url = function (control, protocolRequired) {
1501
- if (protocolRequired === void 0) { protocolRequired = false; }
1502
- if (!control.value) {
1503
- return null;
1504
- }
1505
- if (!common$1.url(control.value)) {
1506
- return { url: true };
1507
- }
1508
- if (protocolRequired) {
1509
- var pattern = new RegExp(/^http(s)?:\/\//gm);
1510
- if (!String(control.value).match(pattern)) {
1511
- return { urlProtocol: true };
1512
- }
1513
- }
1514
- return null;
1515
- };
1516
- FsValidators.dateRange = function (control) {
1517
- if (!control.value) {
1518
- return null;
1519
- }
1520
- if (lodashEs.isObject(control.value)) {
1521
- var start = control.value.start;
1522
- var end = control.value.end;
1523
- if ((!start && !end) || (dateFns.isValid(start) && dateFns.isValid(end))) {
1524
- return null;
1525
- }
1526
- }
1527
- return { dateRange: true };
1528
- };
1529
- FsValidators.func = function (control, formFunction, data) {
1530
- var result;
1531
- var stream$;
1532
- try {
1533
- result = formFunction(control, data);
1534
- }
1535
- catch (err) {
1536
- err = err instanceof Error ? err.message : err;
1537
- stream$ = rxjs.throwError(err);
1538
- }
1539
- if (!stream$) {
1540
- if (result instanceof Promise) {
1541
- stream$ = rxjs.from(result);
1542
- }
1543
- else if (rxjs.isObservable(result)) {
1544
- stream$ = result;
1545
- }
1546
- else {
1547
- stream$ = rxjs.of(null);
1548
- }
1549
- }
1550
- return stream$
1551
- .pipe(operators.map(function () { return null; }), operators.catchError(function (err) {
1552
- return rxjs.of({ validationError: err });
1553
- }), operators.take(1));
1554
- };
1555
- return FsValidators;
1459
+ var FsValidators = /** @class */ (function () {
1460
+ function FsValidators() {
1461
+ }
1462
+ FsValidators.email = function (control) {
1463
+ if (!control.value || common$1.email(control.value)) {
1464
+ return null;
1465
+ }
1466
+ return { email: true };
1467
+ };
1468
+ FsValidators.emails = function (control) {
1469
+ var model = control.value || '';
1470
+ var hasInvalidEmails = model
1471
+ .split(',')
1472
+ .some(function (part) { return !common$1.email(part); });
1473
+ return hasInvalidEmails ? { email: true } : null;
1474
+ };
1475
+ FsValidators.numeric = function (control) {
1476
+ if (common$1.isEmpty(control.value) || common$1.isNumeric(control.value)) {
1477
+ return null;
1478
+ }
1479
+ else {
1480
+ return { numeric: true };
1481
+ }
1482
+ };
1483
+ FsValidators.integer = function (control) {
1484
+ if (!control.value || String(control.value) === '' || (control.value % 1 === 0)) {
1485
+ return null;
1486
+ }
1487
+ else {
1488
+ return { integer: true };
1489
+ }
1490
+ };
1491
+ FsValidators.phone = function (control) {
1492
+ if (!control.value || common$1.phone(control.value)) {
1493
+ return null;
1494
+ }
1495
+ return { phone: true };
1496
+ };
1497
+ FsValidators.url = function (control, protocolRequired) {
1498
+ if (protocolRequired === void 0) { protocolRequired = false; }
1499
+ if (!control.value) {
1500
+ return null;
1501
+ }
1502
+ if (!common$1.url(control.value)) {
1503
+ return { url: true };
1504
+ }
1505
+ if (protocolRequired) {
1506
+ var pattern = new RegExp(/^http(s)?:\/\//gm);
1507
+ if (!String(control.value).match(pattern)) {
1508
+ return { urlProtocol: true };
1509
+ }
1510
+ }
1511
+ return null;
1512
+ };
1513
+ FsValidators.dateRange = function (control) {
1514
+ if (!control.value) {
1515
+ return null;
1516
+ }
1517
+ if (lodashEs.isObject(control.value)) {
1518
+ var start = control.value.start;
1519
+ var end = control.value.end;
1520
+ if ((!start && !end) || (dateFns.isValid(start) && dateFns.isValid(end))) {
1521
+ return null;
1522
+ }
1523
+ }
1524
+ return { dateRange: true };
1525
+ };
1526
+ FsValidators.func = function (control, formFunction, data) {
1527
+ var result;
1528
+ var stream$;
1529
+ try {
1530
+ result = formFunction(control, data);
1531
+ }
1532
+ catch (err) {
1533
+ err = err instanceof Error ? err.message : err;
1534
+ stream$ = rxjs.throwError(err);
1535
+ }
1536
+ if (!stream$) {
1537
+ if (result instanceof Promise) {
1538
+ stream$ = rxjs.from(result);
1539
+ }
1540
+ else if (rxjs.isObservable(result)) {
1541
+ stream$ = result;
1542
+ }
1543
+ else {
1544
+ stream$ = rxjs.of(null);
1545
+ }
1546
+ }
1547
+ return stream$
1548
+ .pipe(operators.map(function () { return null; }), operators.catchError(function (err) {
1549
+ return rxjs.of({ validationError: err });
1550
+ }), operators.take(1));
1551
+ };
1552
+ return FsValidators;
1556
1553
  }());
1557
1554
 
1558
- var FsFormMinDirective = /** @class */ (function (_super) {
1559
- __extends(FsFormMinDirective, _super);
1560
- function FsFormMinDirective() {
1561
- return _super !== null && _super.apply(this, arguments) || this;
1562
- }
1563
- Object.defineProperty(FsFormMinDirective.prototype, "validationMessage", {
1564
- set: function (value) {
1565
- this._validateMessages.min = value;
1566
- },
1567
- enumerable: true,
1568
- configurable: true
1569
- });
1570
- FsFormMinDirective.prototype.ngOnChanges = function () {
1571
- this._control.updateValueAndValidity();
1572
- };
1573
- FsFormMinDirective.prototype.validate = function (control) {
1574
- return FsValidators.numeric(this._control) || forms.Validators.min(parseFloat(this.fsFormMin))(this._control);
1575
- };
1576
- __decorate([
1577
- core.Input(),
1578
- __metadata("design:type", Object)
1579
- ], FsFormMinDirective.prototype, "fsFormMin", void 0);
1580
- __decorate([
1581
- core.Input('fsFormMinMessage'),
1582
- __metadata("design:type", String),
1583
- __metadata("design:paramtypes", [String])
1584
- ], FsFormMinDirective.prototype, "validationMessage", null);
1585
- FsFormMinDirective = __decorate([
1586
- core.Directive({
1587
- selector: '[fsFormMin]',
1588
- providers: [
1589
- VALIDATE_MESSAGE_PROVIDER
1590
- ],
1591
- })
1592
- ], FsFormMinDirective);
1593
- return FsFormMinDirective;
1555
+ var FsFormMinDirective = /** @class */ (function (_super) {
1556
+ __extends(FsFormMinDirective, _super);
1557
+ function FsFormMinDirective() {
1558
+ return _super !== null && _super.apply(this, arguments) || this;
1559
+ }
1560
+ Object.defineProperty(FsFormMinDirective.prototype, "validationMessage", {
1561
+ set: function (value) {
1562
+ this._validateMessages.min = value;
1563
+ },
1564
+ enumerable: true,
1565
+ configurable: true
1566
+ });
1567
+ FsFormMinDirective.prototype.ngOnChanges = function () {
1568
+ this._control.updateValueAndValidity();
1569
+ };
1570
+ FsFormMinDirective.prototype.validate = function (control) {
1571
+ return FsValidators.numeric(this._control) || forms.Validators.min(parseFloat(this.fsFormMin))(this._control);
1572
+ };
1573
+ __decorate([
1574
+ core.Input(),
1575
+ __metadata("design:type", Object)
1576
+ ], FsFormMinDirective.prototype, "fsFormMin", void 0);
1577
+ __decorate([
1578
+ core.Input('fsFormMinMessage'),
1579
+ __metadata("design:type", String),
1580
+ __metadata("design:paramtypes", [String])
1581
+ ], FsFormMinDirective.prototype, "validationMessage", null);
1582
+ FsFormMinDirective = __decorate([
1583
+ core.Directive({
1584
+ selector: '[fsFormMin]',
1585
+ providers: [
1586
+ VALIDATE_MESSAGE_PROVIDER
1587
+ ],
1588
+ })
1589
+ ], FsFormMinDirective);
1590
+ return FsFormMinDirective;
1594
1591
  }(FsControlDirective));
1595
1592
 
1596
- var FsFormMaxDirective = /** @class */ (function (_super) {
1597
- __extends(FsFormMaxDirective, _super);
1598
- function FsFormMaxDirective() {
1599
- return _super !== null && _super.apply(this, arguments) || this;
1600
- }
1601
- Object.defineProperty(FsFormMaxDirective.prototype, "validationMessage", {
1602
- set: function (value) {
1603
- this._validateMessages.max = value;
1604
- },
1605
- enumerable: true,
1606
- configurable: true
1607
- });
1608
- FsFormMaxDirective.prototype.ngOnChanges = function () {
1609
- this._control.updateValueAndValidity();
1610
- };
1611
- FsFormMaxDirective.prototype.validate = function (control) {
1612
- return FsValidators.numeric(this._control) || forms.Validators.max(this.fsFormMax)(this._control);
1613
- };
1614
- __decorate([
1615
- core.Input(),
1616
- __metadata("design:type", Number)
1617
- ], FsFormMaxDirective.prototype, "fsFormMax", void 0);
1618
- __decorate([
1619
- core.Input('fsFormMaxMessage'),
1620
- __metadata("design:type", String),
1621
- __metadata("design:paramtypes", [String])
1622
- ], FsFormMaxDirective.prototype, "validationMessage", null);
1623
- FsFormMaxDirective = __decorate([
1624
- core.Directive({
1625
- selector: '[fsFormMax]',
1626
- providers: [
1627
- VALIDATE_MESSAGE_PROVIDER
1628
- ],
1629
- })
1630
- ], FsFormMaxDirective);
1631
- return FsFormMaxDirective;
1593
+ var FsFormMaxDirective = /** @class */ (function (_super) {
1594
+ __extends(FsFormMaxDirective, _super);
1595
+ function FsFormMaxDirective() {
1596
+ return _super !== null && _super.apply(this, arguments) || this;
1597
+ }
1598
+ Object.defineProperty(FsFormMaxDirective.prototype, "validationMessage", {
1599
+ set: function (value) {
1600
+ this._validateMessages.max = value;
1601
+ },
1602
+ enumerable: true,
1603
+ configurable: true
1604
+ });
1605
+ FsFormMaxDirective.prototype.ngOnChanges = function () {
1606
+ this._control.updateValueAndValidity();
1607
+ };
1608
+ FsFormMaxDirective.prototype.validate = function (control) {
1609
+ return FsValidators.numeric(this._control) || forms.Validators.max(this.fsFormMax)(this._control);
1610
+ };
1611
+ __decorate([
1612
+ core.Input(),
1613
+ __metadata("design:type", Number)
1614
+ ], FsFormMaxDirective.prototype, "fsFormMax", void 0);
1615
+ __decorate([
1616
+ core.Input('fsFormMaxMessage'),
1617
+ __metadata("design:type", String),
1618
+ __metadata("design:paramtypes", [String])
1619
+ ], FsFormMaxDirective.prototype, "validationMessage", null);
1620
+ FsFormMaxDirective = __decorate([
1621
+ core.Directive({
1622
+ selector: '[fsFormMax]',
1623
+ providers: [
1624
+ VALIDATE_MESSAGE_PROVIDER
1625
+ ],
1626
+ })
1627
+ ], FsFormMaxDirective);
1628
+ return FsFormMaxDirective;
1632
1629
  }(FsControlDirective));
1633
1630
 
1634
- var FsFormMinLengthDirective = /** @class */ (function (_super) {
1635
- __extends(FsFormMinLengthDirective, _super);
1636
- function FsFormMinLengthDirective() {
1637
- return _super !== null && _super.apply(this, arguments) || this;
1638
- }
1639
- Object.defineProperty(FsFormMinLengthDirective.prototype, "validationMessage", {
1640
- set: function (value) {
1641
- this._validateMessages.minlength = value;
1642
- },
1643
- enumerable: true,
1644
- configurable: true
1645
- });
1646
- FsFormMinLengthDirective.prototype.ngOnChanges = function () {
1647
- this._control.updateValueAndValidity();
1648
- };
1649
- FsFormMinLengthDirective.prototype.validate = function (control) {
1650
- return forms.Validators.minLength(this.fsFormMinLength)(this._control);
1651
- };
1652
- __decorate([
1653
- core.Input(),
1654
- __metadata("design:type", Number)
1655
- ], FsFormMinLengthDirective.prototype, "fsFormMinLength", void 0);
1656
- __decorate([
1657
- core.Input('fsFormMinLengthMessage'),
1658
- __metadata("design:type", String),
1659
- __metadata("design:paramtypes", [String])
1660
- ], FsFormMinLengthDirective.prototype, "validationMessage", null);
1661
- FsFormMinLengthDirective = __decorate([
1662
- core.Directive({
1663
- selector: '[fsFormMinLength]',
1664
- providers: [
1665
- VALIDATE_MESSAGE_PROVIDER
1666
- ],
1667
- })
1668
- ], FsFormMinLengthDirective);
1669
- return FsFormMinLengthDirective;
1631
+ var FsFormMinLengthDirective = /** @class */ (function (_super) {
1632
+ __extends(FsFormMinLengthDirective, _super);
1633
+ function FsFormMinLengthDirective() {
1634
+ return _super !== null && _super.apply(this, arguments) || this;
1635
+ }
1636
+ Object.defineProperty(FsFormMinLengthDirective.prototype, "validationMessage", {
1637
+ set: function (value) {
1638
+ this._validateMessages.minlength = value;
1639
+ },
1640
+ enumerable: true,
1641
+ configurable: true
1642
+ });
1643
+ FsFormMinLengthDirective.prototype.ngOnChanges = function () {
1644
+ this._control.updateValueAndValidity();
1645
+ };
1646
+ FsFormMinLengthDirective.prototype.validate = function (control) {
1647
+ return forms.Validators.minLength(this.fsFormMinLength)(this._control);
1648
+ };
1649
+ __decorate([
1650
+ core.Input(),
1651
+ __metadata("design:type", Number)
1652
+ ], FsFormMinLengthDirective.prototype, "fsFormMinLength", void 0);
1653
+ __decorate([
1654
+ core.Input('fsFormMinLengthMessage'),
1655
+ __metadata("design:type", String),
1656
+ __metadata("design:paramtypes", [String])
1657
+ ], FsFormMinLengthDirective.prototype, "validationMessage", null);
1658
+ FsFormMinLengthDirective = __decorate([
1659
+ core.Directive({
1660
+ selector: '[fsFormMinLength]',
1661
+ providers: [
1662
+ VALIDATE_MESSAGE_PROVIDER
1663
+ ],
1664
+ })
1665
+ ], FsFormMinLengthDirective);
1666
+ return FsFormMinLengthDirective;
1670
1667
  }(FsControlDirective));
1671
1668
 
1672
- var FsFormMaxLengthDirective = /** @class */ (function (_super) {
1673
- __extends(FsFormMaxLengthDirective, _super);
1674
- function FsFormMaxLengthDirective() {
1675
- return _super !== null && _super.apply(this, arguments) || this;
1676
- }
1677
- Object.defineProperty(FsFormMaxLengthDirective.prototype, "validationMessage", {
1678
- set: function (value) {
1679
- this._validateMessages.maxlength = value;
1680
- },
1681
- enumerable: true,
1682
- configurable: true
1683
- });
1684
- FsFormMaxLengthDirective.prototype.ngOnChanges = function () {
1685
- this._control.updateValueAndValidity();
1686
- };
1687
- FsFormMaxLengthDirective.prototype.validate = function (control) {
1688
- return forms.Validators.maxLength(this.fsFormMaxLength)(this._control);
1689
- };
1690
- __decorate([
1691
- core.Input(),
1692
- __metadata("design:type", Number)
1693
- ], FsFormMaxLengthDirective.prototype, "fsFormMaxLength", void 0);
1694
- __decorate([
1695
- core.Input('fsFormMaxLengthMessage'),
1696
- __metadata("design:type", String),
1697
- __metadata("design:paramtypes", [String])
1698
- ], FsFormMaxLengthDirective.prototype, "validationMessage", null);
1699
- FsFormMaxLengthDirective = __decorate([
1700
- core.Directive({
1701
- selector: '[fsFormMaxLength]',
1702
- providers: [
1703
- VALIDATE_MESSAGE_PROVIDER
1704
- ],
1705
- })
1706
- ], FsFormMaxLengthDirective);
1707
- return FsFormMaxLengthDirective;
1669
+ var FsFormMaxLengthDirective = /** @class */ (function (_super) {
1670
+ __extends(FsFormMaxLengthDirective, _super);
1671
+ function FsFormMaxLengthDirective() {
1672
+ return _super !== null && _super.apply(this, arguments) || this;
1673
+ }
1674
+ Object.defineProperty(FsFormMaxLengthDirective.prototype, "validationMessage", {
1675
+ set: function (value) {
1676
+ this._validateMessages.maxlength = value;
1677
+ },
1678
+ enumerable: true,
1679
+ configurable: true
1680
+ });
1681
+ FsFormMaxLengthDirective.prototype.ngOnChanges = function () {
1682
+ this._control.updateValueAndValidity();
1683
+ };
1684
+ FsFormMaxLengthDirective.prototype.validate = function (control) {
1685
+ return forms.Validators.maxLength(this.fsFormMaxLength)(this._control);
1686
+ };
1687
+ __decorate([
1688
+ core.Input(),
1689
+ __metadata("design:type", Number)
1690
+ ], FsFormMaxLengthDirective.prototype, "fsFormMaxLength", void 0);
1691
+ __decorate([
1692
+ core.Input('fsFormMaxLengthMessage'),
1693
+ __metadata("design:type", String),
1694
+ __metadata("design:paramtypes", [String])
1695
+ ], FsFormMaxLengthDirective.prototype, "validationMessage", null);
1696
+ FsFormMaxLengthDirective = __decorate([
1697
+ core.Directive({
1698
+ selector: '[fsFormMaxLength]',
1699
+ providers: [
1700
+ VALIDATE_MESSAGE_PROVIDER
1701
+ ],
1702
+ })
1703
+ ], FsFormMaxLengthDirective);
1704
+ return FsFormMaxLengthDirective;
1708
1705
  }(FsControlDirective));
1709
1706
 
1710
- var FsFormEmailDirective = /** @class */ (function (_super) {
1711
- __extends(FsFormEmailDirective, _super);
1712
- function FsFormEmailDirective() {
1713
- return _super !== null && _super.apply(this, arguments) || this;
1714
- }
1715
- Object.defineProperty(FsFormEmailDirective.prototype, "validationMessage", {
1716
- set: function (value) {
1717
- this._validateMessages.email = value;
1718
- },
1719
- enumerable: true,
1720
- configurable: true
1721
- });
1722
- FsFormEmailDirective.prototype.ngOnChanges = function () {
1723
- this._control.updateValueAndValidity();
1724
- };
1725
- FsFormEmailDirective.prototype.validate = function (control) {
1726
- if (isEnabled(this.fsFormEmail)) {
1727
- return FsValidators.email(this._control);
1728
- }
1729
- else {
1730
- return null;
1731
- }
1732
- };
1733
- __decorate([
1734
- core.Input(),
1735
- __metadata("design:type", Object)
1736
- ], FsFormEmailDirective.prototype, "fsFormEmail", void 0);
1737
- __decorate([
1738
- core.Input('fsFormEmailMessage'),
1739
- __metadata("design:type", String),
1740
- __metadata("design:paramtypes", [String])
1741
- ], FsFormEmailDirective.prototype, "validationMessage", null);
1742
- FsFormEmailDirective = __decorate([
1743
- core.Directive({
1744
- selector: '[fsFormEmail]',
1745
- providers: [
1746
- VALIDATE_MESSAGE_PROVIDER
1747
- ],
1748
- })
1749
- ], FsFormEmailDirective);
1750
- return FsFormEmailDirective;
1707
+ var FsFormEmailDirective = /** @class */ (function (_super) {
1708
+ __extends(FsFormEmailDirective, _super);
1709
+ function FsFormEmailDirective() {
1710
+ return _super !== null && _super.apply(this, arguments) || this;
1711
+ }
1712
+ Object.defineProperty(FsFormEmailDirective.prototype, "validationMessage", {
1713
+ set: function (value) {
1714
+ this._validateMessages.email = value;
1715
+ },
1716
+ enumerable: true,
1717
+ configurable: true
1718
+ });
1719
+ FsFormEmailDirective.prototype.ngOnChanges = function () {
1720
+ this._control.updateValueAndValidity();
1721
+ };
1722
+ FsFormEmailDirective.prototype.validate = function (control) {
1723
+ if (isEnabled(this.fsFormEmail)) {
1724
+ return FsValidators.email(this._control);
1725
+ }
1726
+ else {
1727
+ return null;
1728
+ }
1729
+ };
1730
+ __decorate([
1731
+ core.Input(),
1732
+ __metadata("design:type", Object)
1733
+ ], FsFormEmailDirective.prototype, "fsFormEmail", void 0);
1734
+ __decorate([
1735
+ core.Input('fsFormEmailMessage'),
1736
+ __metadata("design:type", String),
1737
+ __metadata("design:paramtypes", [String])
1738
+ ], FsFormEmailDirective.prototype, "validationMessage", null);
1739
+ FsFormEmailDirective = __decorate([
1740
+ core.Directive({
1741
+ selector: '[fsFormEmail]',
1742
+ providers: [
1743
+ VALIDATE_MESSAGE_PROVIDER
1744
+ ],
1745
+ })
1746
+ ], FsFormEmailDirective);
1747
+ return FsFormEmailDirective;
1751
1748
  }(FsControlDirective));
1752
1749
 
1753
- var FsFormEmailsDirective = /** @class */ (function (_super) {
1754
- __extends(FsFormEmailsDirective, _super);
1755
- function FsFormEmailsDirective() {
1756
- return _super !== null && _super.apply(this, arguments) || this;
1757
- }
1758
- Object.defineProperty(FsFormEmailsDirective.prototype, "validationMessage", {
1759
- set: function (value) {
1760
- this._validateMessages.emails = value;
1761
- },
1762
- enumerable: true,
1763
- configurable: true
1764
- });
1765
- FsFormEmailsDirective.prototype.ngOnChanges = function () {
1766
- this._control.updateValueAndValidity();
1767
- };
1768
- FsFormEmailsDirective.prototype.validate = function (control) {
1769
- if (isEnabled(this.fsFormEmails)) {
1770
- return FsValidators.emails(this._control);
1771
- }
1772
- else {
1773
- return null;
1774
- }
1775
- };
1776
- __decorate([
1777
- core.Input(),
1778
- __metadata("design:type", Object)
1779
- ], FsFormEmailsDirective.prototype, "fsFormEmails", void 0);
1780
- __decorate([
1781
- core.Input('fsFormEmailsMessage'),
1782
- __metadata("design:type", String),
1783
- __metadata("design:paramtypes", [String])
1784
- ], FsFormEmailsDirective.prototype, "validationMessage", null);
1785
- FsFormEmailsDirective = __decorate([
1786
- core.Directive({
1787
- selector: '[fsFormEmails]',
1788
- providers: [
1789
- VALIDATE_MESSAGE_PROVIDER
1790
- ],
1791
- })
1792
- ], FsFormEmailsDirective);
1793
- return FsFormEmailsDirective;
1750
+ var FsFormEmailsDirective = /** @class */ (function (_super) {
1751
+ __extends(FsFormEmailsDirective, _super);
1752
+ function FsFormEmailsDirective() {
1753
+ return _super !== null && _super.apply(this, arguments) || this;
1754
+ }
1755
+ Object.defineProperty(FsFormEmailsDirective.prototype, "validationMessage", {
1756
+ set: function (value) {
1757
+ this._validateMessages.emails = value;
1758
+ },
1759
+ enumerable: true,
1760
+ configurable: true
1761
+ });
1762
+ FsFormEmailsDirective.prototype.ngOnChanges = function () {
1763
+ this._control.updateValueAndValidity();
1764
+ };
1765
+ FsFormEmailsDirective.prototype.validate = function (control) {
1766
+ if (isEnabled(this.fsFormEmails)) {
1767
+ return FsValidators.emails(this._control);
1768
+ }
1769
+ else {
1770
+ return null;
1771
+ }
1772
+ };
1773
+ __decorate([
1774
+ core.Input(),
1775
+ __metadata("design:type", Object)
1776
+ ], FsFormEmailsDirective.prototype, "fsFormEmails", void 0);
1777
+ __decorate([
1778
+ core.Input('fsFormEmailsMessage'),
1779
+ __metadata("design:type", String),
1780
+ __metadata("design:paramtypes", [String])
1781
+ ], FsFormEmailsDirective.prototype, "validationMessage", null);
1782
+ FsFormEmailsDirective = __decorate([
1783
+ core.Directive({
1784
+ selector: '[fsFormEmails]',
1785
+ providers: [
1786
+ VALIDATE_MESSAGE_PROVIDER
1787
+ ],
1788
+ })
1789
+ ], FsFormEmailsDirective);
1790
+ return FsFormEmailsDirective;
1794
1791
  }(FsControlDirective));
1795
1792
 
1796
- var FsFormPhoneDirective = /** @class */ (function (_super) {
1797
- __extends(FsFormPhoneDirective, _super);
1798
- function FsFormPhoneDirective() {
1799
- return _super !== null && _super.apply(this, arguments) || this;
1800
- }
1801
- Object.defineProperty(FsFormPhoneDirective.prototype, "validationMessage", {
1802
- set: function (value) {
1803
- this._validateMessages.phone = value;
1804
- },
1805
- enumerable: true,
1806
- configurable: true
1807
- });
1808
- FsFormPhoneDirective.prototype.ngOnChanges = function () {
1809
- this._control.updateValueAndValidity();
1810
- };
1811
- FsFormPhoneDirective.prototype.validate = function (control) {
1812
- if (isEnabled(this.fsFormPhone)) {
1813
- return FsValidators.phone(this._control);
1814
- }
1815
- else {
1816
- return null;
1817
- }
1818
- };
1819
- __decorate([
1820
- core.Input(),
1821
- __metadata("design:type", Object)
1822
- ], FsFormPhoneDirective.prototype, "fsFormPhone", void 0);
1823
- __decorate([
1824
- core.Input('fsFormPhoneMessage'),
1825
- __metadata("design:type", String),
1826
- __metadata("design:paramtypes", [String])
1827
- ], FsFormPhoneDirective.prototype, "validationMessage", null);
1828
- FsFormPhoneDirective = __decorate([
1829
- core.Directive({
1830
- selector: '[fsFormPhone]',
1831
- providers: [
1832
- VALIDATE_MESSAGE_PROVIDER
1833
- ],
1834
- })
1835
- ], FsFormPhoneDirective);
1836
- return FsFormPhoneDirective;
1793
+ var FsFormPhoneDirective = /** @class */ (function (_super) {
1794
+ __extends(FsFormPhoneDirective, _super);
1795
+ function FsFormPhoneDirective() {
1796
+ return _super !== null && _super.apply(this, arguments) || this;
1797
+ }
1798
+ Object.defineProperty(FsFormPhoneDirective.prototype, "validationMessage", {
1799
+ set: function (value) {
1800
+ this._validateMessages.phone = value;
1801
+ },
1802
+ enumerable: true,
1803
+ configurable: true
1804
+ });
1805
+ FsFormPhoneDirective.prototype.ngOnChanges = function () {
1806
+ this._control.updateValueAndValidity();
1807
+ };
1808
+ FsFormPhoneDirective.prototype.validate = function (control) {
1809
+ if (isEnabled(this.fsFormPhone)) {
1810
+ return FsValidators.phone(this._control);
1811
+ }
1812
+ else {
1813
+ return null;
1814
+ }
1815
+ };
1816
+ __decorate([
1817
+ core.Input(),
1818
+ __metadata("design:type", Object)
1819
+ ], FsFormPhoneDirective.prototype, "fsFormPhone", void 0);
1820
+ __decorate([
1821
+ core.Input('fsFormPhoneMessage'),
1822
+ __metadata("design:type", String),
1823
+ __metadata("design:paramtypes", [String])
1824
+ ], FsFormPhoneDirective.prototype, "validationMessage", null);
1825
+ FsFormPhoneDirective = __decorate([
1826
+ core.Directive({
1827
+ selector: '[fsFormPhone]',
1828
+ providers: [
1829
+ VALIDATE_MESSAGE_PROVIDER
1830
+ ],
1831
+ })
1832
+ ], FsFormPhoneDirective);
1833
+ return FsFormPhoneDirective;
1837
1834
  }(FsControlDirective));
1838
1835
 
1839
- var FsFormCompareDirective = /** @class */ (function (_super) {
1840
- __extends(FsFormCompareDirective, _super);
1841
- function FsFormCompareDirective() {
1842
- return _super !== null && _super.apply(this, arguments) || this;
1843
- }
1844
- Object.defineProperty(FsFormCompareDirective.prototype, "validationMessage", {
1845
- set: function (value) {
1846
- this._validateMessages.compare = value;
1847
- },
1848
- enumerable: true,
1849
- configurable: true
1850
- });
1851
- FsFormCompareDirective.prototype.ngOnChanges = function () {
1852
- this._control.updateValueAndValidity();
1853
- };
1854
- FsFormCompareDirective.prototype.validate = function (control) {
1855
- if (this.fsFormCompare.value === this.elementRef.nativeElement.value) {
1856
- return null;
1857
- }
1858
- else {
1859
- return { compare: true };
1860
- }
1861
- };
1862
- FsFormCompareDirective.prototype.ngAfterViewInit = function () {
1863
- var _this = this;
1864
- this.fsFormCompare.addEventListener('keyup', function () {
1865
- _this._control.updateValueAndValidity();
1866
- }, false);
1867
- };
1868
- FsFormCompareDirective.prototype.ngOnDestroy = function () {
1869
- var _this = this;
1870
- this.fsFormCompare.removeEventListener('keyup', function () {
1871
- _this._control.updateValueAndValidity();
1872
- }, false);
1873
- };
1874
- __decorate([
1875
- core.Input(),
1876
- __metadata("design:type", Object)
1877
- ], FsFormCompareDirective.prototype, "fsFormCompare", void 0);
1878
- __decorate([
1879
- core.Input('fsFormCompareMessage'),
1880
- __metadata("design:type", String),
1881
- __metadata("design:paramtypes", [String])
1882
- ], FsFormCompareDirective.prototype, "validationMessage", null);
1883
- FsFormCompareDirective = __decorate([
1884
- core.Directive({
1885
- selector: '[fsFormCompare]',
1886
- providers: [
1887
- VALIDATE_MESSAGE_PROVIDER,
1888
- ],
1889
- })
1890
- ], FsFormCompareDirective);
1891
- return FsFormCompareDirective;
1836
+ var FsFormCompareDirective = /** @class */ (function (_super) {
1837
+ __extends(FsFormCompareDirective, _super);
1838
+ function FsFormCompareDirective() {
1839
+ return _super !== null && _super.apply(this, arguments) || this;
1840
+ }
1841
+ Object.defineProperty(FsFormCompareDirective.prototype, "validationMessage", {
1842
+ set: function (value) {
1843
+ this._validateMessages.compare = value;
1844
+ },
1845
+ enumerable: true,
1846
+ configurable: true
1847
+ });
1848
+ FsFormCompareDirective.prototype.ngOnChanges = function () {
1849
+ this._control.updateValueAndValidity();
1850
+ };
1851
+ FsFormCompareDirective.prototype.validate = function (control) {
1852
+ if (this.fsFormCompare.value === this.elementRef.nativeElement.value) {
1853
+ return null;
1854
+ }
1855
+ else {
1856
+ return { compare: true };
1857
+ }
1858
+ };
1859
+ FsFormCompareDirective.prototype.ngAfterViewInit = function () {
1860
+ var _this = this;
1861
+ this.fsFormCompare.addEventListener('keyup', function () {
1862
+ _this._control.updateValueAndValidity();
1863
+ }, false);
1864
+ };
1865
+ FsFormCompareDirective.prototype.ngOnDestroy = function () {
1866
+ var _this = this;
1867
+ this.fsFormCompare.removeEventListener('keyup', function () {
1868
+ _this._control.updateValueAndValidity();
1869
+ }, false);
1870
+ };
1871
+ __decorate([
1872
+ core.Input(),
1873
+ __metadata("design:type", Object)
1874
+ ], FsFormCompareDirective.prototype, "fsFormCompare", void 0);
1875
+ __decorate([
1876
+ core.Input('fsFormCompareMessage'),
1877
+ __metadata("design:type", String),
1878
+ __metadata("design:paramtypes", [String])
1879
+ ], FsFormCompareDirective.prototype, "validationMessage", null);
1880
+ FsFormCompareDirective = __decorate([
1881
+ core.Directive({
1882
+ selector: '[fsFormCompare]',
1883
+ providers: [
1884
+ VALIDATE_MESSAGE_PROVIDER,
1885
+ ],
1886
+ })
1887
+ ], FsFormCompareDirective);
1888
+ return FsFormCompareDirective;
1892
1889
  }(FsControlDirective));
1893
1890
 
1894
- var FsFormIntegerDirective = /** @class */ (function (_super) {
1895
- __extends(FsFormIntegerDirective, _super);
1896
- function FsFormIntegerDirective() {
1897
- return _super !== null && _super.apply(this, arguments) || this;
1898
- }
1899
- Object.defineProperty(FsFormIntegerDirective.prototype, "validationMessage", {
1900
- set: function (value) {
1901
- this._validateMessages.integer = value;
1902
- },
1903
- enumerable: true,
1904
- configurable: true
1905
- });
1906
- FsFormIntegerDirective.prototype.ngOnChanges = function () {
1907
- this._control.updateValueAndValidity();
1908
- };
1909
- FsFormIntegerDirective.prototype.validate = function (control) {
1910
- if (isEnabled(this.fsFormInteger)) {
1911
- return FsValidators.integer(this._control);
1912
- }
1913
- else {
1914
- return null;
1915
- }
1916
- };
1917
- __decorate([
1918
- core.Input(),
1919
- __metadata("design:type", Object)
1920
- ], FsFormIntegerDirective.prototype, "fsFormInteger", void 0);
1921
- __decorate([
1922
- core.Input('fsFormIntegerMessage'),
1923
- __metadata("design:type", String),
1924
- __metadata("design:paramtypes", [String])
1925
- ], FsFormIntegerDirective.prototype, "validationMessage", null);
1926
- FsFormIntegerDirective = __decorate([
1927
- core.Directive({
1928
- selector: '[fsFormInteger]',
1929
- providers: [
1930
- VALIDATE_MESSAGE_PROVIDER
1931
- ],
1932
- })
1933
- ], FsFormIntegerDirective);
1934
- return FsFormIntegerDirective;
1891
+ var FsFormIntegerDirective = /** @class */ (function (_super) {
1892
+ __extends(FsFormIntegerDirective, _super);
1893
+ function FsFormIntegerDirective() {
1894
+ return _super !== null && _super.apply(this, arguments) || this;
1895
+ }
1896
+ Object.defineProperty(FsFormIntegerDirective.prototype, "validationMessage", {
1897
+ set: function (value) {
1898
+ this._validateMessages.integer = value;
1899
+ },
1900
+ enumerable: true,
1901
+ configurable: true
1902
+ });
1903
+ FsFormIntegerDirective.prototype.ngOnChanges = function () {
1904
+ this._control.updateValueAndValidity();
1905
+ };
1906
+ FsFormIntegerDirective.prototype.validate = function (control) {
1907
+ if (isEnabled(this.fsFormInteger)) {
1908
+ return FsValidators.integer(this._control);
1909
+ }
1910
+ else {
1911
+ return null;
1912
+ }
1913
+ };
1914
+ __decorate([
1915
+ core.Input(),
1916
+ __metadata("design:type", Object)
1917
+ ], FsFormIntegerDirective.prototype, "fsFormInteger", void 0);
1918
+ __decorate([
1919
+ core.Input('fsFormIntegerMessage'),
1920
+ __metadata("design:type", String),
1921
+ __metadata("design:paramtypes", [String])
1922
+ ], FsFormIntegerDirective.prototype, "validationMessage", null);
1923
+ FsFormIntegerDirective = __decorate([
1924
+ core.Directive({
1925
+ selector: '[fsFormInteger]',
1926
+ providers: [
1927
+ VALIDATE_MESSAGE_PROVIDER
1928
+ ],
1929
+ })
1930
+ ], FsFormIntegerDirective);
1931
+ return FsFormIntegerDirective;
1935
1932
  }(FsControlDirective));
1936
1933
 
1937
- var FsFormNumericDirective = /** @class */ (function (_super) {
1938
- __extends(FsFormNumericDirective, _super);
1939
- function FsFormNumericDirective() {
1940
- return _super !== null && _super.apply(this, arguments) || this;
1941
- }
1942
- Object.defineProperty(FsFormNumericDirective.prototype, "validationMessage", {
1943
- set: function (value) {
1944
- this._validateMessages.numeric = value;
1945
- },
1946
- enumerable: true,
1947
- configurable: true
1948
- });
1949
- FsFormNumericDirective.prototype.ngOnChanges = function () {
1950
- this._control.updateValueAndValidity();
1951
- };
1952
- FsFormNumericDirective.prototype.validate = function (control) {
1953
- if (isEnabled(this.fsFormNumeric)) {
1954
- return FsValidators.numeric(this._control);
1955
- }
1956
- else {
1957
- return null;
1958
- }
1959
- };
1960
- __decorate([
1961
- core.Input(),
1962
- __metadata("design:type", Object)
1963
- ], FsFormNumericDirective.prototype, "fsFormNumeric", void 0);
1964
- __decorate([
1965
- core.Input('fsFormNumericMessage'),
1966
- __metadata("design:type", String),
1967
- __metadata("design:paramtypes", [String])
1968
- ], FsFormNumericDirective.prototype, "validationMessage", null);
1969
- FsFormNumericDirective = __decorate([
1970
- core.Directive({
1971
- selector: '[fsFormNumeric]',
1972
- providers: [
1973
- VALIDATE_MESSAGE_PROVIDER
1974
- ],
1975
- })
1976
- ], FsFormNumericDirective);
1977
- return FsFormNumericDirective;
1934
+ var FsFormNumericDirective = /** @class */ (function (_super) {
1935
+ __extends(FsFormNumericDirective, _super);
1936
+ function FsFormNumericDirective() {
1937
+ return _super !== null && _super.apply(this, arguments) || this;
1938
+ }
1939
+ Object.defineProperty(FsFormNumericDirective.prototype, "validationMessage", {
1940
+ set: function (value) {
1941
+ this._validateMessages.numeric = value;
1942
+ },
1943
+ enumerable: true,
1944
+ configurable: true
1945
+ });
1946
+ FsFormNumericDirective.prototype.ngOnChanges = function () {
1947
+ this._control.updateValueAndValidity();
1948
+ };
1949
+ FsFormNumericDirective.prototype.validate = function (control) {
1950
+ if (isEnabled(this.fsFormNumeric)) {
1951
+ return FsValidators.numeric(this._control);
1952
+ }
1953
+ else {
1954
+ return null;
1955
+ }
1956
+ };
1957
+ __decorate([
1958
+ core.Input(),
1959
+ __metadata("design:type", Object)
1960
+ ], FsFormNumericDirective.prototype, "fsFormNumeric", void 0);
1961
+ __decorate([
1962
+ core.Input('fsFormNumericMessage'),
1963
+ __metadata("design:type", String),
1964
+ __metadata("design:paramtypes", [String])
1965
+ ], FsFormNumericDirective.prototype, "validationMessage", null);
1966
+ FsFormNumericDirective = __decorate([
1967
+ core.Directive({
1968
+ selector: '[fsFormNumeric]',
1969
+ providers: [
1970
+ VALIDATE_MESSAGE_PROVIDER
1971
+ ],
1972
+ })
1973
+ ], FsFormNumericDirective);
1974
+ return FsFormNumericDirective;
1978
1975
  }(FsControlDirective));
1979
1976
 
1980
- var FsFormPatternDirective = /** @class */ (function (_super) {
1981
- __extends(FsFormPatternDirective, _super);
1982
- function FsFormPatternDirective() {
1983
- return _super !== null && _super.apply(this, arguments) || this;
1984
- }
1985
- Object.defineProperty(FsFormPatternDirective.prototype, "validationMessage", {
1986
- set: function (value) {
1987
- this._validateMessages.pattern = value;
1988
- },
1989
- enumerable: true,
1990
- configurable: true
1991
- });
1992
- FsFormPatternDirective.prototype.ngOnChanges = function () {
1993
- this._control.updateValueAndValidity();
1994
- };
1995
- FsFormPatternDirective.prototype.validate = function (control) {
1996
- return forms.Validators.pattern(this.fsFormPattern)(this._control);
1997
- };
1998
- __decorate([
1999
- core.Input(),
2000
- __metadata("design:type", RegExp)
2001
- ], FsFormPatternDirective.prototype, "fsFormPattern", void 0);
2002
- __decorate([
2003
- core.Input('fsFormPatternMessage'),
2004
- __metadata("design:type", String),
2005
- __metadata("design:paramtypes", [String])
2006
- ], FsFormPatternDirective.prototype, "validationMessage", null);
2007
- FsFormPatternDirective = __decorate([
2008
- core.Directive({
2009
- selector: '[fsFormPattern]',
2010
- providers: [
2011
- VALIDATE_MESSAGE_PROVIDER
2012
- ],
2013
- })
2014
- ], FsFormPatternDirective);
2015
- return FsFormPatternDirective;
1977
+ var FsFormPatternDirective = /** @class */ (function (_super) {
1978
+ __extends(FsFormPatternDirective, _super);
1979
+ function FsFormPatternDirective() {
1980
+ return _super !== null && _super.apply(this, arguments) || this;
1981
+ }
1982
+ Object.defineProperty(FsFormPatternDirective.prototype, "validationMessage", {
1983
+ set: function (value) {
1984
+ this._validateMessages.pattern = value;
1985
+ },
1986
+ enumerable: true,
1987
+ configurable: true
1988
+ });
1989
+ FsFormPatternDirective.prototype.ngOnChanges = function () {
1990
+ this._control.updateValueAndValidity();
1991
+ };
1992
+ FsFormPatternDirective.prototype.validate = function (control) {
1993
+ return forms.Validators.pattern(this.fsFormPattern)(this._control);
1994
+ };
1995
+ __decorate([
1996
+ core.Input(),
1997
+ __metadata("design:type", RegExp)
1998
+ ], FsFormPatternDirective.prototype, "fsFormPattern", void 0);
1999
+ __decorate([
2000
+ core.Input('fsFormPatternMessage'),
2001
+ __metadata("design:type", String),
2002
+ __metadata("design:paramtypes", [String])
2003
+ ], FsFormPatternDirective.prototype, "validationMessage", null);
2004
+ FsFormPatternDirective = __decorate([
2005
+ core.Directive({
2006
+ selector: '[fsFormPattern]',
2007
+ providers: [
2008
+ VALIDATE_MESSAGE_PROVIDER
2009
+ ],
2010
+ })
2011
+ ], FsFormPatternDirective);
2012
+ return FsFormPatternDirective;
2016
2013
  }(FsControlDirective));
2017
2014
 
2018
- var FsFormFunctionDirective = /** @class */ (function (_super) {
2019
- __extends(FsFormFunctionDirective, _super);
2020
- function FsFormFunctionDirective() {
2021
- return _super !== null && _super.apply(this, arguments) || this;
2022
- }
2023
- FsFormFunctionDirective.prototype.ngOnChanges = function () {
2024
- this._control.updateValueAndValidity();
2025
- };
2026
- FsFormFunctionDirective.prototype.validateAsync = function (control) {
2027
- return FsValidators.func(this._control, this.fsFormFunction, this.fsFormFunctionData);
2028
- };
2029
- __decorate([
2030
- core.Input(),
2031
- __metadata("design:type", Object)
2032
- ], FsFormFunctionDirective.prototype, "fsFormFunction", void 0);
2033
- __decorate([
2034
- core.Input(),
2035
- __metadata("design:type", Object)
2036
- ], FsFormFunctionDirective.prototype, "fsFormFunctionData", void 0);
2037
- FsFormFunctionDirective = __decorate([
2038
- core.Directive({
2039
- selector: '[fsFormFunction]',
2040
- providers: [
2041
- VALIDATE_MESSAGE_PROVIDER
2042
- ],
2043
- })
2044
- ], FsFormFunctionDirective);
2045
- return FsFormFunctionDirective;
2015
+ var FsFormFunctionDirective = /** @class */ (function (_super) {
2016
+ __extends(FsFormFunctionDirective, _super);
2017
+ function FsFormFunctionDirective() {
2018
+ return _super !== null && _super.apply(this, arguments) || this;
2019
+ }
2020
+ FsFormFunctionDirective.prototype.ngOnChanges = function () {
2021
+ this._control.updateValueAndValidity();
2022
+ };
2023
+ FsFormFunctionDirective.prototype.validateAsync = function (control) {
2024
+ return FsValidators.func(this._control, this.fsFormFunction, this.fsFormFunctionData);
2025
+ };
2026
+ __decorate([
2027
+ core.Input(),
2028
+ __metadata("design:type", Object)
2029
+ ], FsFormFunctionDirective.prototype, "fsFormFunction", void 0);
2030
+ __decorate([
2031
+ core.Input(),
2032
+ __metadata("design:type", Object)
2033
+ ], FsFormFunctionDirective.prototype, "fsFormFunctionData", void 0);
2034
+ FsFormFunctionDirective = __decorate([
2035
+ core.Directive({
2036
+ selector: '[fsFormFunction]',
2037
+ providers: [
2038
+ VALIDATE_MESSAGE_PROVIDER
2039
+ ],
2040
+ })
2041
+ ], FsFormFunctionDirective);
2042
+ return FsFormFunctionDirective;
2046
2043
  }(FsControlDirective));
2047
2044
 
2048
- var FsFormGreaterDirective = /** @class */ (function (_super) {
2049
- __extends(FsFormGreaterDirective, _super);
2050
- function FsFormGreaterDirective() {
2051
- return _super !== null && _super.apply(this, arguments) || this;
2052
- }
2053
- Object.defineProperty(FsFormGreaterDirective.prototype, "validationMessage", {
2054
- set: function (value) {
2055
- this._validateMessages.greater = value;
2056
- },
2057
- enumerable: true,
2058
- configurable: true
2059
- });
2060
- FsFormGreaterDirective.prototype.ngOnChanges = function () {
2061
- this._control.updateValueAndValidity();
2062
- };
2063
- FsFormGreaterDirective.prototype.validate = function (control) {
2064
- var greater = parseFloat(this.fsFormGreater);
2065
- var value = parseFloat(this._control.value);
2066
- if (!isNaN(greater) && !isNaN(value) && value <= greater) {
2067
- return { greater: { greater: greater, actual: value } };
2068
- }
2069
- return FsValidators.numeric(this._control);
2070
- };
2071
- __decorate([
2072
- core.Input(),
2073
- __metadata("design:type", Object)
2074
- ], FsFormGreaterDirective.prototype, "fsFormGreater", void 0);
2075
- __decorate([
2076
- core.Input('fsFormGreaterMessage'),
2077
- __metadata("design:type", String),
2078
- __metadata("design:paramtypes", [String])
2079
- ], FsFormGreaterDirective.prototype, "validationMessage", null);
2080
- FsFormGreaterDirective = __decorate([
2081
- core.Directive({
2082
- selector: '[fsFormGreater]',
2083
- providers: [
2084
- VALIDATE_MESSAGE_PROVIDER
2085
- ],
2086
- })
2087
- ], FsFormGreaterDirective);
2088
- return FsFormGreaterDirective;
2045
+ var FsFormGreaterDirective = /** @class */ (function (_super) {
2046
+ __extends(FsFormGreaterDirective, _super);
2047
+ function FsFormGreaterDirective() {
2048
+ return _super !== null && _super.apply(this, arguments) || this;
2049
+ }
2050
+ Object.defineProperty(FsFormGreaterDirective.prototype, "validationMessage", {
2051
+ set: function (value) {
2052
+ this._validateMessages.greater = value;
2053
+ },
2054
+ enumerable: true,
2055
+ configurable: true
2056
+ });
2057
+ FsFormGreaterDirective.prototype.ngOnChanges = function () {
2058
+ this._control.updateValueAndValidity();
2059
+ };
2060
+ FsFormGreaterDirective.prototype.validate = function (control) {
2061
+ var greater = parseFloat(this.fsFormGreater);
2062
+ var value = parseFloat(this._control.value);
2063
+ if (!isNaN(greater) && !isNaN(value) && value <= greater) {
2064
+ return { greater: { greater: greater, actual: value } };
2065
+ }
2066
+ return FsValidators.numeric(this._control);
2067
+ };
2068
+ __decorate([
2069
+ core.Input(),
2070
+ __metadata("design:type", Object)
2071
+ ], FsFormGreaterDirective.prototype, "fsFormGreater", void 0);
2072
+ __decorate([
2073
+ core.Input('fsFormGreaterMessage'),
2074
+ __metadata("design:type", String),
2075
+ __metadata("design:paramtypes", [String])
2076
+ ], FsFormGreaterDirective.prototype, "validationMessage", null);
2077
+ FsFormGreaterDirective = __decorate([
2078
+ core.Directive({
2079
+ selector: '[fsFormGreater]',
2080
+ providers: [
2081
+ VALIDATE_MESSAGE_PROVIDER
2082
+ ],
2083
+ })
2084
+ ], FsFormGreaterDirective);
2085
+ return FsFormGreaterDirective;
2089
2086
  }(FsControlDirective));
2090
2087
 
2091
- var FsFormDateRangeDirective = /** @class */ (function (_super) {
2092
- __extends(FsFormDateRangeDirective, _super);
2093
- function FsFormDateRangeDirective() {
2094
- return _super !== null && _super.apply(this, arguments) || this;
2095
- }
2096
- Object.defineProperty(FsFormDateRangeDirective.prototype, "validationMessage", {
2097
- set: function (value) {
2098
- this._validateMessages.dateRange = value;
2099
- },
2100
- enumerable: true,
2101
- configurable: true
2102
- });
2103
- FsFormDateRangeDirective.prototype.ngOnChanges = function () {
2104
- this._control.updateValueAndValidity();
2105
- };
2106
- FsFormDateRangeDirective.prototype.validate = function (control) {
2107
- if (isEnabled(this.fsFormDateRange)) {
2108
- return FsValidators.dateRange(this._control);
2109
- }
2110
- else {
2111
- return null;
2112
- }
2113
- };
2114
- __decorate([
2115
- core.Input(),
2116
- __metadata("design:type", Object)
2117
- ], FsFormDateRangeDirective.prototype, "fsFormDateRange", void 0);
2118
- __decorate([
2119
- core.Input('fsFormDateRangeMessage'),
2120
- __metadata("design:type", String),
2121
- __metadata("design:paramtypes", [String])
2122
- ], FsFormDateRangeDirective.prototype, "validationMessage", null);
2123
- FsFormDateRangeDirective = __decorate([
2124
- core.Directive({
2125
- selector: '[fsFormDateRange]',
2126
- providers: [
2127
- VALIDATE_MESSAGE_PROVIDER
2128
- ],
2129
- })
2130
- ], FsFormDateRangeDirective);
2131
- return FsFormDateRangeDirective;
2088
+ var FsFormDateRangeDirective = /** @class */ (function (_super) {
2089
+ __extends(FsFormDateRangeDirective, _super);
2090
+ function FsFormDateRangeDirective() {
2091
+ return _super !== null && _super.apply(this, arguments) || this;
2092
+ }
2093
+ Object.defineProperty(FsFormDateRangeDirective.prototype, "validationMessage", {
2094
+ set: function (value) {
2095
+ this._validateMessages.dateRange = value;
2096
+ },
2097
+ enumerable: true,
2098
+ configurable: true
2099
+ });
2100
+ FsFormDateRangeDirective.prototype.ngOnChanges = function () {
2101
+ this._control.updateValueAndValidity();
2102
+ };
2103
+ FsFormDateRangeDirective.prototype.validate = function (control) {
2104
+ if (isEnabled(this.fsFormDateRange)) {
2105
+ return FsValidators.dateRange(this._control);
2106
+ }
2107
+ else {
2108
+ return null;
2109
+ }
2110
+ };
2111
+ __decorate([
2112
+ core.Input(),
2113
+ __metadata("design:type", Object)
2114
+ ], FsFormDateRangeDirective.prototype, "fsFormDateRange", void 0);
2115
+ __decorate([
2116
+ core.Input('fsFormDateRangeMessage'),
2117
+ __metadata("design:type", String),
2118
+ __metadata("design:paramtypes", [String])
2119
+ ], FsFormDateRangeDirective.prototype, "validationMessage", null);
2120
+ FsFormDateRangeDirective = __decorate([
2121
+ core.Directive({
2122
+ selector: '[fsFormDateRange]',
2123
+ providers: [
2124
+ VALIDATE_MESSAGE_PROVIDER
2125
+ ],
2126
+ })
2127
+ ], FsFormDateRangeDirective);
2128
+ return FsFormDateRangeDirective;
2132
2129
  }(FsControlDirective));
2133
2130
 
2134
- var FsFormLesserDirective = /** @class */ (function (_super) {
2135
- __extends(FsFormLesserDirective, _super);
2136
- function FsFormLesserDirective() {
2137
- return _super !== null && _super.apply(this, arguments) || this;
2138
- }
2139
- Object.defineProperty(FsFormLesserDirective.prototype, "validationMessage", {
2140
- set: function (value) {
2141
- this._validateMessages.lesser = value;
2142
- },
2143
- enumerable: true,
2144
- configurable: true
2145
- });
2146
- FsFormLesserDirective.prototype.ngOnChanges = function () {
2147
- this._control.updateValueAndValidity();
2148
- };
2149
- FsFormLesserDirective.prototype.validate = function (control) {
2150
- var lesser = parseFloat(this.fsFormLesser);
2151
- var value = parseFloat(this._control.value);
2152
- if (!isNaN(lesser) && !isNaN(value) && value >= lesser) {
2153
- return { lesser: { lesser: lesser, actual: value } };
2154
- }
2155
- return FsValidators.numeric(this._control);
2156
- };
2157
- __decorate([
2158
- core.Input(),
2159
- __metadata("design:type", Object)
2160
- ], FsFormLesserDirective.prototype, "fsFormLesser", void 0);
2161
- __decorate([
2162
- core.Input('fsFormLesserMessage'),
2163
- __metadata("design:type", String),
2164
- __metadata("design:paramtypes", [String])
2165
- ], FsFormLesserDirective.prototype, "validationMessage", null);
2166
- FsFormLesserDirective = __decorate([
2167
- core.Directive({
2168
- selector: '[fsFormLesser]',
2169
- providers: [
2170
- VALIDATE_MESSAGE_PROVIDER
2171
- ],
2172
- })
2173
- ], FsFormLesserDirective);
2174
- return FsFormLesserDirective;
2131
+ var FsFormLesserDirective = /** @class */ (function (_super) {
2132
+ __extends(FsFormLesserDirective, _super);
2133
+ function FsFormLesserDirective() {
2134
+ return _super !== null && _super.apply(this, arguments) || this;
2135
+ }
2136
+ Object.defineProperty(FsFormLesserDirective.prototype, "validationMessage", {
2137
+ set: function (value) {
2138
+ this._validateMessages.lesser = value;
2139
+ },
2140
+ enumerable: true,
2141
+ configurable: true
2142
+ });
2143
+ FsFormLesserDirective.prototype.ngOnChanges = function () {
2144
+ this._control.updateValueAndValidity();
2145
+ };
2146
+ FsFormLesserDirective.prototype.validate = function (control) {
2147
+ var lesser = parseFloat(this.fsFormLesser);
2148
+ var value = parseFloat(this._control.value);
2149
+ if (!isNaN(lesser) && !isNaN(value) && value >= lesser) {
2150
+ return { lesser: { lesser: lesser, actual: value } };
2151
+ }
2152
+ return FsValidators.numeric(this._control);
2153
+ };
2154
+ __decorate([
2155
+ core.Input(),
2156
+ __metadata("design:type", Object)
2157
+ ], FsFormLesserDirective.prototype, "fsFormLesser", void 0);
2158
+ __decorate([
2159
+ core.Input('fsFormLesserMessage'),
2160
+ __metadata("design:type", String),
2161
+ __metadata("design:paramtypes", [String])
2162
+ ], FsFormLesserDirective.prototype, "validationMessage", null);
2163
+ FsFormLesserDirective = __decorate([
2164
+ core.Directive({
2165
+ selector: '[fsFormLesser]',
2166
+ providers: [
2167
+ VALIDATE_MESSAGE_PROVIDER
2168
+ ],
2169
+ })
2170
+ ], FsFormLesserDirective);
2171
+ return FsFormLesserDirective;
2175
2172
  }(FsControlDirective));
2176
2173
 
2177
- var FsFormUrlDirective = /** @class */ (function (_super) {
2178
- __extends(FsFormUrlDirective, _super);
2179
- function FsFormUrlDirective() {
2180
- var _this = _super !== null && _super.apply(this, arguments) || this;
2181
- _this.fsFormUrlProtocol = false;
2182
- return _this;
2183
- }
2184
- Object.defineProperty(FsFormUrlDirective.prototype, "validationMessage", {
2185
- set: function (value) {
2186
- this._validateMessages.url = value;
2187
- },
2188
- enumerable: true,
2189
- configurable: true
2190
- });
2191
- FsFormUrlDirective.prototype.ngOnChanges = function () {
2192
- this._control.updateValueAndValidity();
2193
- };
2194
- FsFormUrlDirective.prototype.validate = function (control) {
2195
- if (isEnabled(this.fsFormUrl)) {
2196
- return FsValidators.url(this._control, this.fsFormUrlProtocol);
2197
- }
2198
- else {
2199
- return null;
2200
- }
2201
- };
2202
- __decorate([
2203
- core.Input(),
2204
- __metadata("design:type", Object)
2205
- ], FsFormUrlDirective.prototype, "fsFormUrl", void 0);
2206
- __decorate([
2207
- core.Input(),
2208
- __metadata("design:type", Object)
2209
- ], FsFormUrlDirective.prototype, "fsFormUrlProtocol", void 0);
2210
- __decorate([
2211
- core.Input('fsFormUrlMessage'),
2212
- __metadata("design:type", String),
2213
- __metadata("design:paramtypes", [String])
2214
- ], FsFormUrlDirective.prototype, "validationMessage", null);
2215
- FsFormUrlDirective = __decorate([
2216
- core.Directive({
2217
- selector: '[fsFormUrl]',
2218
- providers: [
2219
- VALIDATE_MESSAGE_PROVIDER
2220
- ],
2221
- })
2222
- ], FsFormUrlDirective);
2223
- return FsFormUrlDirective;
2174
+ var FsFormUrlDirective = /** @class */ (function (_super) {
2175
+ __extends(FsFormUrlDirective, _super);
2176
+ function FsFormUrlDirective() {
2177
+ var _this = _super !== null && _super.apply(this, arguments) || this;
2178
+ _this.fsFormUrlProtocol = false;
2179
+ return _this;
2180
+ }
2181
+ Object.defineProperty(FsFormUrlDirective.prototype, "validationMessage", {
2182
+ set: function (value) {
2183
+ this._validateMessages.url = value;
2184
+ },
2185
+ enumerable: true,
2186
+ configurable: true
2187
+ });
2188
+ FsFormUrlDirective.prototype.ngOnChanges = function () {
2189
+ this._control.updateValueAndValidity();
2190
+ };
2191
+ FsFormUrlDirective.prototype.validate = function (control) {
2192
+ if (isEnabled(this.fsFormUrl)) {
2193
+ return FsValidators.url(this._control, this.fsFormUrlProtocol);
2194
+ }
2195
+ else {
2196
+ return null;
2197
+ }
2198
+ };
2199
+ __decorate([
2200
+ core.Input(),
2201
+ __metadata("design:type", Object)
2202
+ ], FsFormUrlDirective.prototype, "fsFormUrl", void 0);
2203
+ __decorate([
2204
+ core.Input(),
2205
+ __metadata("design:type", Object)
2206
+ ], FsFormUrlDirective.prototype, "fsFormUrlProtocol", void 0);
2207
+ __decorate([
2208
+ core.Input('fsFormUrlMessage'),
2209
+ __metadata("design:type", String),
2210
+ __metadata("design:paramtypes", [String])
2211
+ ], FsFormUrlDirective.prototype, "validationMessage", null);
2212
+ FsFormUrlDirective = __decorate([
2213
+ core.Directive({
2214
+ selector: '[fsFormUrl]',
2215
+ providers: [
2216
+ VALIDATE_MESSAGE_PROVIDER
2217
+ ],
2218
+ })
2219
+ ], FsFormUrlDirective);
2220
+ return FsFormUrlDirective;
2224
2221
  }(FsControlDirective));
2225
2222
 
2226
- var FsSubmitButtonDirective = /** @class */ (function () {
2227
- function FsSubmitButtonDirective(_matButton, _form, _elementRef, _cdRef) {
2228
- this._matButton = _matButton;
2229
- this._form = _form;
2230
- this._elementRef = _elementRef;
2231
- this._cdRef = _cdRef;
2232
- this.dirtySubmit = true;
2233
- this.transitionStyle = null;
2234
- this.active = false;
2235
- this._destroy$ = new rxjs.Subject();
2236
- }
2237
- FsSubmitButtonDirective.prototype.ngOnInit = function () {
2238
- var _this = this;
2239
- if (this._form) {
2240
- this._form.addSubmitButton(this);
2241
- rxjs.fromEvent(this.element, 'click')
2242
- .pipe(operators.takeUntil(this._destroy$))
2243
- .subscribe(function () {
2244
- _this.active = true;
2245
- });
2246
- if (this.dirtySubmit) {
2247
- if (this._form.dirtySubmitButton) {
2248
- if (!this._form.ngForm.dirty) {
2249
- this.disable();
2250
- }
2251
- }
2252
- }
2253
- this.transitionStyle = 'none';
2254
- setTimeout(function () {
2255
- _this.transitionStyle = null;
2256
- }, 500);
2257
- }
2258
- };
2259
- FsSubmitButtonDirective.prototype.disable = function () {
2260
- if (this._matButton) {
2261
- this._matButton.disabled = true;
2262
- this._cdRef.markForCheck();
2263
- }
2264
- };
2265
- FsSubmitButtonDirective.prototype.enable = function () {
2266
- if (this._matButton) {
2267
- this._matButton.disabled = false;
2268
- this._matButton.disableRipple = true;
2269
- this._cdRef.markForCheck();
2270
- }
2271
- };
2272
- FsSubmitButtonDirective.prototype.process = function () {
2273
- this.setClass('process');
2274
- this._matButton.disableRipple = true;
2275
- };
2276
- FsSubmitButtonDirective.prototype.success = function () {
2277
- this.setClass('success');
2278
- this._matButton.disableRipple = false;
2279
- };
2280
- FsSubmitButtonDirective.prototype.error = function () {
2281
- this.setClass('error');
2282
- this._matButton.disableRipple = false;
2283
- };
2284
- FsSubmitButtonDirective.prototype.setClass = function (cls) {
2285
- var svg = this._getSvg(cls);
2286
- this._resetClass();
2287
- this._disableShadowAnimation();
2288
- this.element.classList.add("submit-" + cls);
2289
- this.element.append(svg);
2290
- };
2291
- Object.defineProperty(FsSubmitButtonDirective.prototype, "element", {
2292
- get: function () {
2293
- return this._elementRef.nativeElement;
2294
- },
2295
- enumerable: true,
2296
- configurable: true
2297
- });
2298
- FsSubmitButtonDirective.prototype.reset = function () {
2299
- this.active = false;
2300
- this.enable();
2301
- this.element.querySelectorAll('.svg-icon')
2302
- .forEach(function (el) {
2303
- el.remove();
2304
- });
2305
- this._matButton.disableRipple = false;
2306
- this._resetClass();
2307
- };
2308
- FsSubmitButtonDirective.prototype.ngOnDestroy = function () {
2309
- this._destroy$.next();
2310
- this._destroy$.complete();
2311
- this._form.removeSubmitButton(this);
2312
- };
2313
- FsSubmitButtonDirective.prototype._disableShadowAnimation = function () {
2314
- // .mat-elevation-z2 removes the click shadow animation
2315
- //this.element.classList.add('mat-elevation-z2');
2316
- };
2317
- FsSubmitButtonDirective.prototype._resetClass = function () {
2318
- this.element.classList.remove('submit-success', 'submit-error', 'submit-process', 'mat-elevation-z2');
2319
- };
2320
- FsSubmitButtonDirective.prototype._getSvg = function (type) {
2321
- if (type === 'success') {
2322
- return new DOMParser().parseFromString("<svg class=\"svg-icon svg-icon-success\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" version=\"1.1\" x=\"0px\" y=\"0px\" viewBox=\"0 0 38 38\" style=\"enable-background:new 0 0 38 38;\" xml:space=\"preserve\" width=\"38px\" height=\"38px\">\n <g>\n <g class=\"check\">\n <g>\n <path d=\"M29.6,11.9c-0.5-0.5-1.3-0.5-1.8,0L16.3,23.4l-6.1-6.1c-0.5-0.5-1.3-0.5-1.8,0s-0.5,1.3,0,1.8l7,7c0.3,0.3,0.6,0.4,0.9,0.4s0.7-0.1,0.9-0.4l12.4-12.4C30.1,13.2,30.1,12.4,29.6,11.9z\"/>\n </g>\n </g>\n </g>\n </svg>", 'text/xml').firstChild;
2323
- }
2324
- if (type === 'process') {
2325
- return new DOMParser().parseFromString("<svg class=\"svg-icon svg-icon-process\" width=\"38\" height=\"38\" viewBox=\"0 0 38 38\" xmlns=\"http://www.w3.org/2000/svg\">\n <g fill=\"none\" fill-rule=\"evenodd\">\n <g transform=\"translate(1 1)\" stroke-width=\"2\"><circle stroke-opacity=\".5\" cx=\"18\" cy=\"18\" r=\"18\"/>\n <path d=\"M36 18c0-9.94-8.06-18-18-18\"><animateTransform attributeName=\"transform\" type=\"rotate\" from=\"0 18 18\" to=\"360 18 18\" dur=\".7s\" repeatCount=\"indefinite\"/></path>\n </g>\n </g>\n </svg>", 'text/xml').firstChild;
2326
- }
2327
- if (type === 'error') {
2328
- return new DOMParser().parseFromString("<svg class=\"svg-icon svg-icon-error\" xmlns=\"http://www.w3.org/2000/svg\" width=\"38px\" height=\"38px\" viewBox=\"0 0 16 16\"><g><path d=\"M8 1c3.9 0 7 3.1 7 7s-3.1 7-7 7-7-3.1-7-7 3.1-7 7-7zM8 0c-4.4 0-8 3.6-8 8s3.6 8 8 8 8-3.6 8-8-3.6-8-8-8v0z\" data-original=\"#444444\" data-old_color=\"#444444\"/><path d=\"M12.2 10.8l-2.8-2.8 2.8-2.8-1.4-1.4-2.8 2.8-2.8-2.8-1.4 1.4 2.8 2.8-2.8 2.8 1.4 1.4 2.8-2.8 2.8 2.8z\"/></g> </svg>", 'text/xml').firstChild;
2329
- }
2330
- };
2331
- FsSubmitButtonDirective.ctorParameters = function () { return [
2332
- { type: button.MatButton, decorators: [{ type: core.Optional }, { type: core.Host }] },
2333
- { type: FsFormDirective, decorators: [{ type: core.Optional }] },
2334
- { type: core.ElementRef },
2335
- { type: core.ChangeDetectorRef }
2336
- ]; };
2337
- __decorate([
2338
- core.Input(),
2339
- __metadata("design:type", Object)
2340
- ], FsSubmitButtonDirective.prototype, "name", void 0);
2341
- __decorate([
2342
- core.Input(),
2343
- __metadata("design:type", Object)
2344
- ], FsSubmitButtonDirective.prototype, "dirtySubmit", void 0);
2345
- __decorate([
2346
- core.HostBinding('style.transition'),
2347
- __metadata("design:type", Object)
2348
- ], FsSubmitButtonDirective.prototype, "transitionStyle", void 0);
2349
- FsSubmitButtonDirective = __decorate([
2350
- core.Directive({
2351
- selector: 'button[type="submit"]',
2352
- }),
2353
- __param(0, core.Optional()), __param(0, core.Host()),
2354
- __param(1, core.Optional()),
2355
- __metadata("design:paramtypes", [button.MatButton,
2356
- FsFormDirective,
2357
- core.ElementRef,
2358
- core.ChangeDetectorRef])
2359
- ], FsSubmitButtonDirective);
2360
- return FsSubmitButtonDirective;
2223
+ var FsSubmitButtonDirective = /** @class */ (function () {
2224
+ function FsSubmitButtonDirective(_matButton, _form, _elementRef, _cdRef) {
2225
+ this._matButton = _matButton;
2226
+ this._form = _form;
2227
+ this._elementRef = _elementRef;
2228
+ this._cdRef = _cdRef;
2229
+ this.dirtySubmit = true;
2230
+ this.transitionStyle = null;
2231
+ this.active = false;
2232
+ this._destroy$ = new rxjs.Subject();
2233
+ }
2234
+ FsSubmitButtonDirective.prototype.ngOnInit = function () {
2235
+ var _this = this;
2236
+ if (this._form) {
2237
+ this._form.addSubmitButton(this);
2238
+ rxjs.fromEvent(this.element, 'click')
2239
+ .pipe(operators.takeUntil(this._destroy$))
2240
+ .subscribe(function () {
2241
+ _this.active = true;
2242
+ });
2243
+ if (this.dirtySubmit) {
2244
+ if (this._form.dirtySubmitButton) {
2245
+ if (!this._form.ngForm.dirty) {
2246
+ this.disable();
2247
+ }
2248
+ }
2249
+ }
2250
+ this.transitionStyle = 'none';
2251
+ setTimeout(function () {
2252
+ _this.transitionStyle = null;
2253
+ }, 500);
2254
+ }
2255
+ };
2256
+ FsSubmitButtonDirective.prototype.disable = function () {
2257
+ if (this._matButton) {
2258
+ this._matButton.disabled = true;
2259
+ this._cdRef.markForCheck();
2260
+ }
2261
+ };
2262
+ FsSubmitButtonDirective.prototype.enable = function () {
2263
+ if (this._matButton) {
2264
+ this._matButton.disabled = false;
2265
+ this._matButton.disableRipple = true;
2266
+ this._cdRef.markForCheck();
2267
+ }
2268
+ };
2269
+ FsSubmitButtonDirective.prototype.process = function () {
2270
+ this.setClass('process');
2271
+ this._matButton.disableRipple = true;
2272
+ };
2273
+ FsSubmitButtonDirective.prototype.success = function () {
2274
+ this.setClass('success');
2275
+ this._matButton.disableRipple = false;
2276
+ };
2277
+ FsSubmitButtonDirective.prototype.error = function () {
2278
+ this.setClass('error');
2279
+ this._matButton.disableRipple = false;
2280
+ };
2281
+ FsSubmitButtonDirective.prototype.setClass = function (cls) {
2282
+ var svg = this._getSvg(cls);
2283
+ this._resetClass();
2284
+ this._disableShadowAnimation();
2285
+ this.element.classList.add("submit-" + cls);
2286
+ this.element.append(svg);
2287
+ };
2288
+ Object.defineProperty(FsSubmitButtonDirective.prototype, "element", {
2289
+ get: function () {
2290
+ return this._elementRef.nativeElement;
2291
+ },
2292
+ enumerable: true,
2293
+ configurable: true
2294
+ });
2295
+ FsSubmitButtonDirective.prototype.reset = function () {
2296
+ this.active = false;
2297
+ this.enable();
2298
+ this.element.querySelectorAll('.svg-icon')
2299
+ .forEach(function (el) {
2300
+ el.remove();
2301
+ });
2302
+ this._matButton.disableRipple = false;
2303
+ this._resetClass();
2304
+ };
2305
+ FsSubmitButtonDirective.prototype.ngOnDestroy = function () {
2306
+ this._destroy$.next();
2307
+ this._destroy$.complete();
2308
+ this._form.removeSubmitButton(this);
2309
+ };
2310
+ FsSubmitButtonDirective.prototype._disableShadowAnimation = function () {
2311
+ // .mat-elevation-z2 removes the click shadow animation
2312
+ //this.element.classList.add('mat-elevation-z2');
2313
+ };
2314
+ FsSubmitButtonDirective.prototype._resetClass = function () {
2315
+ this.element.classList.remove('submit-success', 'submit-error', 'submit-process', 'mat-elevation-z2');
2316
+ };
2317
+ FsSubmitButtonDirective.prototype._getSvg = function (type) {
2318
+ if (type === 'success') {
2319
+ return new DOMParser().parseFromString("<svg class=\"svg-icon svg-icon-success\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" version=\"1.1\" x=\"0px\" y=\"0px\" viewBox=\"0 0 38 38\" style=\"enable-background:new 0 0 38 38;\" xml:space=\"preserve\" width=\"38px\" height=\"38px\">\n <g>\n <g class=\"check\">\n <g>\n <path d=\"M29.6,11.9c-0.5-0.5-1.3-0.5-1.8,0L16.3,23.4l-6.1-6.1c-0.5-0.5-1.3-0.5-1.8,0s-0.5,1.3,0,1.8l7,7c0.3,0.3,0.6,0.4,0.9,0.4s0.7-0.1,0.9-0.4l12.4-12.4C30.1,13.2,30.1,12.4,29.6,11.9z\"/>\n </g>\n </g>\n </g>\n </svg>", 'text/xml').firstChild;
2320
+ }
2321
+ if (type === 'process') {
2322
+ return new DOMParser().parseFromString("<svg class=\"svg-icon svg-icon-process\" width=\"38\" height=\"38\" viewBox=\"0 0 38 38\" xmlns=\"http://www.w3.org/2000/svg\">\n <g fill=\"none\" fill-rule=\"evenodd\">\n <g transform=\"translate(1 1)\" stroke-width=\"2\"><circle stroke-opacity=\".5\" cx=\"18\" cy=\"18\" r=\"18\"/>\n <path d=\"M36 18c0-9.94-8.06-18-18-18\"><animateTransform attributeName=\"transform\" type=\"rotate\" from=\"0 18 18\" to=\"360 18 18\" dur=\".7s\" repeatCount=\"indefinite\"/></path>\n </g>\n </g>\n </svg>", 'text/xml').firstChild;
2323
+ }
2324
+ if (type === 'error') {
2325
+ return new DOMParser().parseFromString("<svg class=\"svg-icon svg-icon-error\" xmlns=\"http://www.w3.org/2000/svg\" width=\"38px\" height=\"38px\" viewBox=\"0 0 16 16\"><g><path d=\"M8 1c3.9 0 7 3.1 7 7s-3.1 7-7 7-7-3.1-7-7 3.1-7 7-7zM8 0c-4.4 0-8 3.6-8 8s3.6 8 8 8 8-3.6 8-8-3.6-8-8-8v0z\" data-original=\"#444444\" data-old_color=\"#444444\"/><path d=\"M12.2 10.8l-2.8-2.8 2.8-2.8-1.4-1.4-2.8 2.8-2.8-2.8-1.4 1.4 2.8 2.8-2.8 2.8 1.4 1.4 2.8-2.8 2.8 2.8z\"/></g> </svg>", 'text/xml').firstChild;
2326
+ }
2327
+ };
2328
+ FsSubmitButtonDirective.ctorParameters = function () { return [
2329
+ { type: button.MatButton, decorators: [{ type: core.Optional }, { type: core.Host }] },
2330
+ { type: FsFormDirective, decorators: [{ type: core.Optional }] },
2331
+ { type: core.ElementRef },
2332
+ { type: core.ChangeDetectorRef }
2333
+ ]; };
2334
+ __decorate([
2335
+ core.Input(),
2336
+ __metadata("design:type", Object)
2337
+ ], FsSubmitButtonDirective.prototype, "name", void 0);
2338
+ __decorate([
2339
+ core.Input(),
2340
+ __metadata("design:type", Object)
2341
+ ], FsSubmitButtonDirective.prototype, "dirtySubmit", void 0);
2342
+ __decorate([
2343
+ core.HostBinding('style.transition'),
2344
+ __metadata("design:type", Object)
2345
+ ], FsSubmitButtonDirective.prototype, "transitionStyle", void 0);
2346
+ FsSubmitButtonDirective = __decorate([
2347
+ core.Directive({
2348
+ selector: 'button[type="submit"]',
2349
+ }),
2350
+ __param(0, core.Optional()), __param(0, core.Host()),
2351
+ __param(1, core.Optional()),
2352
+ __metadata("design:paramtypes", [button.MatButton,
2353
+ FsFormDirective,
2354
+ core.ElementRef,
2355
+ core.ChangeDetectorRef])
2356
+ ], FsSubmitButtonDirective);
2357
+ return FsSubmitButtonDirective;
2361
2358
  }());
2362
2359
 
2363
- var FsFormValidateDirective = /** @class */ (function (_super) {
2364
- __extends(FsFormValidateDirective, _super);
2365
- function FsFormValidateDirective() {
2366
- return _super !== null && _super.apply(this, arguments) || this;
2367
- }
2368
- FsFormValidateDirective.prototype.ngOnChanges = function () {
2369
- this._control.updateValueAndValidity();
2370
- };
2371
- FsFormValidateDirective.prototype.validateAsync = function (control) {
2372
- return FsValidators.func(this._control, this.validateFn, this.validateFnData);
2373
- };
2374
- __decorate([
2375
- core.Input('validate'),
2376
- __metadata("design:type", Object)
2377
- ], FsFormValidateDirective.prototype, "validateFn", void 0);
2378
- __decorate([
2379
- core.Input('validateData'),
2380
- __metadata("design:type", Object)
2381
- ], FsFormValidateDirective.prototype, "validateFnData", void 0);
2382
- FsFormValidateDirective = __decorate([
2383
- core.Directive({
2384
- selector: '[validate]',
2385
- providers: [
2386
- VALIDATE_MESSAGE_PROVIDER
2387
- ],
2388
- })
2389
- ], FsFormValidateDirective);
2390
- return FsFormValidateDirective;
2360
+ var FsFormValidateDirective = /** @class */ (function (_super) {
2361
+ __extends(FsFormValidateDirective, _super);
2362
+ function FsFormValidateDirective() {
2363
+ return _super !== null && _super.apply(this, arguments) || this;
2364
+ }
2365
+ FsFormValidateDirective.prototype.ngOnChanges = function () {
2366
+ this._control.updateValueAndValidity();
2367
+ };
2368
+ FsFormValidateDirective.prototype.validateAsync = function (control) {
2369
+ return FsValidators.func(this._control, this.validateFn, this.validateFnData);
2370
+ };
2371
+ __decorate([
2372
+ core.Input('validate'),
2373
+ __metadata("design:type", Object)
2374
+ ], FsFormValidateDirective.prototype, "validateFn", void 0);
2375
+ __decorate([
2376
+ core.Input('validateData'),
2377
+ __metadata("design:type", Object)
2378
+ ], FsFormValidateDirective.prototype, "validateFnData", void 0);
2379
+ FsFormValidateDirective = __decorate([
2380
+ core.Directive({
2381
+ selector: '[validate]',
2382
+ providers: [
2383
+ VALIDATE_MESSAGE_PROVIDER
2384
+ ],
2385
+ })
2386
+ ], FsFormValidateDirective);
2387
+ return FsFormValidateDirective;
2391
2388
  }(FsControlDirective));
2392
2389
 
2393
- var FsFormDialogActionsComponent = /** @class */ (function () {
2394
- function FsFormDialogActionsComponent(_form, _dialogRef, _cdRef) {
2395
- this._form = _form;
2396
- this._dialogRef = _dialogRef;
2397
- this._cdRef = _cdRef;
2398
- this.save = true;
2399
- this.create = false;
2400
- this.close = false;
2401
- this.dirty = false;
2402
- this._destroy$ = new rxjs.Subject();
2403
- }
2404
- FsFormDialogActionsComponent.prototype.ngOnInit = function () {
2405
- var _this = this;
2406
- if (this._form) {
2407
- this._form.ngForm.valueChanges
2408
- .pipe(operators.filter(function () { return (!_this.dirty); }), operators.takeUntil(this._destroy$))
2409
- .subscribe(function () {
2410
- _this.dirty = _this._form.ngForm.dirty;
2411
- _this._cdRef.markForCheck();
2412
- });
2413
- this._form.submitted
2414
- .pipe(operators.delay(50), operators.takeUntil(this._destroy$))
2415
- .subscribe(function () {
2416
- _this.dirty = false;
2417
- _this._cdRef.markForCheck();
2418
- });
2419
- this._form.reseted
2420
- .pipe(operators.takeUntil(this._destroy$))
2421
- .subscribe(function () {
2422
- _this.dirty = false;
2423
- _this._cdRef.markForCheck();
2424
- });
2425
- }
2426
- };
2427
- FsFormDialogActionsComponent.prototype.closeClick = function () {
2428
- var _this = this;
2429
- if (this._form) {
2430
- this._form.triggerConfirm()
2431
- .pipe(operators.filter(function (confirmResult) { return (confirmResult !== exports.ConfirmResult.Review); }), operators.takeUntil(this._destroy$))
2432
- .subscribe(function () {
2433
- _this._dialogRef.close(null);
2434
- });
2435
- }
2436
- else {
2437
- this._dialogRef.close(null);
2438
- }
2439
- };
2440
- FsFormDialogActionsComponent.prototype.ngOnDestroy = function () {
2441
- this._destroy$.next();
2442
- this._destroy$.complete();
2443
- };
2444
- FsFormDialogActionsComponent.ctorParameters = function () { return [
2445
- { type: FsFormDirective, decorators: [{ type: core.Optional }] },
2446
- { type: dialog.MatDialogRef, decorators: [{ type: core.Optional }] },
2447
- { type: core.ChangeDetectorRef }
2448
- ]; };
2449
- __decorate([
2450
- core.Input(),
2451
- __metadata("design:type", Object)
2452
- ], FsFormDialogActionsComponent.prototype, "save", void 0);
2453
- __decorate([
2454
- core.Input(),
2455
- __metadata("design:type", Object)
2456
- ], FsFormDialogActionsComponent.prototype, "create", void 0);
2457
- __decorate([
2458
- core.Input(),
2459
- __metadata("design:type", Object)
2460
- ], FsFormDialogActionsComponent.prototype, "close", void 0);
2461
- __decorate([
2462
- core.Input(),
2463
- __metadata("design:type", String)
2464
- ], FsFormDialogActionsComponent.prototype, "name", void 0);
2465
- FsFormDialogActionsComponent = __decorate([
2466
- core.Component({
2467
- selector: 'fs-form-dialog-actions',
2468
- template: "<div class=\"buttons\">\r\n <ng-container *ngIf=\"save\">\r\n <button \r\n mat-button \r\n type=\"submit\"\r\n color=\"primary\" \r\n [name]=\"name\">\r\n {{create ? 'Create' : 'Save'}}\r\n </button>\r\n <button \r\n mat-button \r\n type=\"button\"\r\n [disabled]=\"close && !dirty && !create\"\r\n [matDialogClose]=\"null\">\r\n Cancel\r\n </button>\r\n </ng-container>\r\n\r\n <ng-content></ng-content>\r\n <div class=\"close\" *ngIf=\"close\">\r\n <button \r\n mat-button \r\n type=\"button\"\r\n [color]=\"dirty ? 'basic' : 'primary'\"\r\n (click)=\"closeClick()\">\r\n Close\r\n </button>\r\n </div>\r\n</div>",
2469
- changeDetection: core.ChangeDetectionStrategy.OnPush,
2470
- styles: [".buttons{display:flex;flex-grow:1;align-items:center}.buttons .close{display:flex;flex-grow:1;justify-content:flex-end}:host{display:flex;flex-grow:1}@media only screen and (max-width:599px){.buttons{flex-direction:column}}"]
2471
- }),
2472
- __param(0, core.Optional()),
2473
- __param(1, core.Optional()),
2474
- __metadata("design:paramtypes", [FsFormDirective,
2475
- dialog.MatDialogRef,
2476
- core.ChangeDetectorRef])
2477
- ], FsFormDialogActionsComponent);
2478
- return FsFormDialogActionsComponent;
2390
+ var FsFormDialogActionsComponent = /** @class */ (function () {
2391
+ function FsFormDialogActionsComponent(_form, _dialogRef, _cdRef) {
2392
+ this._form = _form;
2393
+ this._dialogRef = _dialogRef;
2394
+ this._cdRef = _cdRef;
2395
+ this.save = true;
2396
+ this.create = false;
2397
+ this.close = false;
2398
+ this.dirty = false;
2399
+ this._destroy$ = new rxjs.Subject();
2400
+ }
2401
+ FsFormDialogActionsComponent.prototype.ngOnInit = function () {
2402
+ var _this = this;
2403
+ if (this._form) {
2404
+ this._form.ngForm.valueChanges
2405
+ .pipe(operators.filter(function () { return (!_this.dirty); }), operators.takeUntil(this._destroy$))
2406
+ .subscribe(function () {
2407
+ _this.dirty = _this._form.ngForm.dirty;
2408
+ _this._cdRef.markForCheck();
2409
+ });
2410
+ this._form.submitted
2411
+ .pipe(operators.delay(50), operators.takeUntil(this._destroy$))
2412
+ .subscribe(function () {
2413
+ _this.dirty = false;
2414
+ _this._cdRef.markForCheck();
2415
+ });
2416
+ this._form.reseted
2417
+ .pipe(operators.takeUntil(this._destroy$))
2418
+ .subscribe(function () {
2419
+ _this.dirty = false;
2420
+ _this._cdRef.markForCheck();
2421
+ });
2422
+ }
2423
+ };
2424
+ FsFormDialogActionsComponent.prototype.closeClick = function () {
2425
+ var _this = this;
2426
+ if (this._form) {
2427
+ this._form.triggerConfirm()
2428
+ .pipe(operators.filter(function (confirmResult) { return (confirmResult !== exports.ConfirmResult.Review); }), operators.takeUntil(this._destroy$))
2429
+ .subscribe(function () {
2430
+ _this._dialogRef.close(null);
2431
+ });
2432
+ }
2433
+ else {
2434
+ this._dialogRef.close(null);
2435
+ }
2436
+ };
2437
+ FsFormDialogActionsComponent.prototype.ngOnDestroy = function () {
2438
+ this._destroy$.next();
2439
+ this._destroy$.complete();
2440
+ };
2441
+ FsFormDialogActionsComponent.ctorParameters = function () { return [
2442
+ { type: FsFormDirective, decorators: [{ type: core.Optional }] },
2443
+ { type: dialog.MatDialogRef, decorators: [{ type: core.Optional }] },
2444
+ { type: core.ChangeDetectorRef }
2445
+ ]; };
2446
+ __decorate([
2447
+ core.Input(),
2448
+ __metadata("design:type", Object)
2449
+ ], FsFormDialogActionsComponent.prototype, "save", void 0);
2450
+ __decorate([
2451
+ core.Input(),
2452
+ __metadata("design:type", Object)
2453
+ ], FsFormDialogActionsComponent.prototype, "create", void 0);
2454
+ __decorate([
2455
+ core.Input(),
2456
+ __metadata("design:type", Object)
2457
+ ], FsFormDialogActionsComponent.prototype, "close", void 0);
2458
+ __decorate([
2459
+ core.Input(),
2460
+ __metadata("design:type", String)
2461
+ ], FsFormDialogActionsComponent.prototype, "name", void 0);
2462
+ FsFormDialogActionsComponent = __decorate([
2463
+ core.Component({
2464
+ selector: 'fs-form-dialog-actions',
2465
+ template: "<div class=\"buttons\">\r\n <ng-container *ngIf=\"save\">\r\n <button \r\n mat-button \r\n type=\"submit\"\r\n color=\"primary\" \r\n [name]=\"name\">\r\n {{create ? 'Create' : 'Save'}}\r\n </button>\r\n <button \r\n mat-button \r\n type=\"button\"\r\n [disabled]=\"close && !dirty && !create\"\r\n [matDialogClose]=\"null\">\r\n Cancel\r\n </button>\r\n </ng-container>\r\n\r\n <ng-content></ng-content>\r\n <div class=\"close\" *ngIf=\"close\">\r\n <button \r\n mat-button \r\n type=\"button\"\r\n [color]=\"dirty ? 'basic' : 'primary'\"\r\n (click)=\"closeClick()\">\r\n Close\r\n </button>\r\n </div>\r\n</div>",
2466
+ changeDetection: core.ChangeDetectionStrategy.OnPush,
2467
+ styles: [".buttons{display:flex;flex-grow:1;align-items:center}.buttons .close{display:flex;flex-grow:1;justify-content:flex-end}:host{display:flex;flex-grow:1}@media only screen and (max-width:599px){.buttons{flex-direction:column}}"]
2468
+ }),
2469
+ __param(0, core.Optional()),
2470
+ __param(1, core.Optional()),
2471
+ __metadata("design:paramtypes", [FsFormDirective,
2472
+ dialog.MatDialogRef,
2473
+ core.ChangeDetectorRef])
2474
+ ], FsFormDialogActionsComponent);
2475
+ return FsFormDialogActionsComponent;
2479
2476
  }());
2480
2477
 
2481
- var FsFormModule = /** @class */ (function () {
2482
- function FsFormModule() {
2483
- }
2484
- FsFormModule_1 = FsFormModule;
2485
- FsFormModule.forRoot = function () {
2486
- return {
2487
- ngModule: FsFormModule_1,
2488
- };
2489
- };
2490
- var FsFormModule_1;
2491
- FsFormModule = FsFormModule_1 = __decorate([
2492
- core.NgModule({
2493
- imports: [
2494
- common.CommonModule,
2495
- forms.FormsModule,
2496
- button.MatButtonModule,
2497
- dialog.MatDialogModule,
2498
- ],
2499
- declarations: [
2500
- FsFormDirective,
2501
- FsControlDirective,
2502
- FsFormRequiredDirective,
2503
- FsFormMinDirective,
2504
- FsFormMaxDirective,
2505
- FsFormMinLengthDirective,
2506
- FsFormMaxLengthDirective,
2507
- FsFormEmailDirective,
2508
- FsFormEmailsDirective,
2509
- FsFormPhoneDirective,
2510
- FsFormCompareDirective,
2511
- FsFormIntegerDirective,
2512
- FsFormNumericDirective,
2513
- FsFormPatternDirective,
2514
- FsFormFunctionDirective,
2515
- FsFormDateRangeDirective,
2516
- FsFormGreaterDirective,
2517
- FsFormLesserDirective,
2518
- FsFormUrlDirective,
2519
- FsFormDialogCloseDirective,
2520
- FsSubmitButtonDirective,
2521
- FsFormValidateDirective,
2522
- FsFormDialogActionsComponent,
2523
- ],
2524
- exports: [
2525
- FsFormDirective,
2526
- FsControlDirective,
2527
- FsFormRequiredDirective,
2528
- FsFormMinDirective,
2529
- FsFormMaxDirective,
2530
- FsFormMinLengthDirective,
2531
- FsFormMaxLengthDirective,
2532
- FsFormEmailDirective,
2533
- FsFormEmailsDirective,
2534
- FsFormPhoneDirective,
2535
- FsFormCompareDirective,
2536
- FsFormIntegerDirective,
2537
- FsFormNumericDirective,
2538
- FsFormPatternDirective,
2539
- FsFormFunctionDirective,
2540
- FsFormDateRangeDirective,
2541
- FsFormGreaterDirective,
2542
- FsFormLesserDirective,
2543
- FsFormUrlDirective,
2544
- FsFormDialogCloseDirective,
2545
- FsSubmitButtonDirective,
2546
- FsFormValidateDirective,
2547
- FsFormDialogActionsComponent,
2548
- ],
2549
- providers: [
2550
- {
2551
- provide: core$1.ErrorStateMatcher,
2552
- useClass: core$1.ShowOnDirtyErrorStateMatcher,
2553
- },
2554
- ],
2555
- })
2556
- ], FsFormModule);
2557
- return FsFormModule;
2478
+ var FsFormModule = /** @class */ (function () {
2479
+ function FsFormModule() {
2480
+ }
2481
+ FsFormModule_1 = FsFormModule;
2482
+ FsFormModule.forRoot = function () {
2483
+ return {
2484
+ ngModule: FsFormModule_1,
2485
+ };
2486
+ };
2487
+ var FsFormModule_1;
2488
+ FsFormModule = FsFormModule_1 = __decorate([
2489
+ core.NgModule({
2490
+ imports: [
2491
+ common.CommonModule,
2492
+ forms.FormsModule,
2493
+ button.MatButtonModule,
2494
+ dialog.MatDialogModule,
2495
+ ],
2496
+ declarations: [
2497
+ FsFormDirective,
2498
+ FsControlDirective,
2499
+ FsFormRequiredDirective,
2500
+ FsFormMinDirective,
2501
+ FsFormMaxDirective,
2502
+ FsFormMinLengthDirective,
2503
+ FsFormMaxLengthDirective,
2504
+ FsFormEmailDirective,
2505
+ FsFormEmailsDirective,
2506
+ FsFormPhoneDirective,
2507
+ FsFormCompareDirective,
2508
+ FsFormIntegerDirective,
2509
+ FsFormNumericDirective,
2510
+ FsFormPatternDirective,
2511
+ FsFormFunctionDirective,
2512
+ FsFormDateRangeDirective,
2513
+ FsFormGreaterDirective,
2514
+ FsFormLesserDirective,
2515
+ FsFormUrlDirective,
2516
+ FsFormDialogCloseDirective,
2517
+ FsSubmitButtonDirective,
2518
+ FsFormValidateDirective,
2519
+ FsFormDialogActionsComponent,
2520
+ ],
2521
+ exports: [
2522
+ FsFormDirective,
2523
+ FsControlDirective,
2524
+ FsFormRequiredDirective,
2525
+ FsFormMinDirective,
2526
+ FsFormMaxDirective,
2527
+ FsFormMinLengthDirective,
2528
+ FsFormMaxLengthDirective,
2529
+ FsFormEmailDirective,
2530
+ FsFormEmailsDirective,
2531
+ FsFormPhoneDirective,
2532
+ FsFormCompareDirective,
2533
+ FsFormIntegerDirective,
2534
+ FsFormNumericDirective,
2535
+ FsFormPatternDirective,
2536
+ FsFormFunctionDirective,
2537
+ FsFormDateRangeDirective,
2538
+ FsFormGreaterDirective,
2539
+ FsFormLesserDirective,
2540
+ FsFormUrlDirective,
2541
+ FsFormDialogCloseDirective,
2542
+ FsSubmitButtonDirective,
2543
+ FsFormValidateDirective,
2544
+ FsFormDialogActionsComponent,
2545
+ ],
2546
+ providers: [
2547
+ {
2548
+ provide: core$1.ErrorStateMatcher,
2549
+ useClass: core$1.ShowOnDirtyErrorStateMatcher,
2550
+ },
2551
+ ],
2552
+ })
2553
+ ], FsFormModule);
2554
+ return FsFormModule;
2558
2555
  }());
2559
2556
 
2560
- var FormDeactivateGuard = /** @class */ (function () {
2561
- function FormDeactivateGuard(_prompt) {
2562
- this._prompt = _prompt;
2563
- }
2564
- FormDeactivateGuard.prototype.canDeactivate = function (directive) {
2565
- if (!('getForm' in directive)) {
2566
- var error = "Directive " + directive.constructor.name + " does not property implement interface FormDeactivate";
2567
- console.error(error);
2568
- return rxjs.of(true);
2569
- }
2570
- var form = directive.getForm();
2571
- if (!(form instanceof FsFormDirective)) {
2572
- var error = "Directive " + directive.constructor.name + ".getForm() does not return a valid FsFormDirective";
2573
- console.error(error);
2574
- return rxjs.of(true);
2575
- }
2576
- return confirmUnsaved(form, this._prompt)
2577
- .pipe(operators.map(function (result) {
2578
- return confirmResultContinue(result);
2579
- }));
2580
- };
2581
- FormDeactivateGuard.ctorParameters = function () { return [
2582
- { type: prompt.FsPrompt }
2583
- ]; };
2584
- FormDeactivateGuard.ɵprov = core.ɵɵdefineInjectable({ factory: function FormDeactivateGuard_Factory() { return new FormDeactivateGuard(core.ɵɵinject(prompt.FsPrompt)); }, token: FormDeactivateGuard, providedIn: "root" });
2585
- FormDeactivateGuard = __decorate([
2586
- core.Injectable({
2587
- providedIn: 'root'
2588
- }),
2589
- __metadata("design:paramtypes", [prompt.FsPrompt])
2590
- ], FormDeactivateGuard);
2591
- return FormDeactivateGuard;
2557
+ var FormDeactivateGuard = /** @class */ (function () {
2558
+ function FormDeactivateGuard(_prompt) {
2559
+ this._prompt = _prompt;
2560
+ }
2561
+ FormDeactivateGuard.prototype.canDeactivate = function (directive) {
2562
+ if (!('getForm' in directive)) {
2563
+ var error = "Directive " + directive.constructor.name + " does not property implement interface FormDeactivate";
2564
+ console.error(error);
2565
+ return rxjs.of(true);
2566
+ }
2567
+ var form = directive.getForm();
2568
+ if (!(form instanceof FsFormDirective)) {
2569
+ var error = "Directive " + directive.constructor.name + ".getForm() does not return a valid FsFormDirective";
2570
+ console.error(error);
2571
+ return rxjs.of(true);
2572
+ }
2573
+ return confirmUnsaved(form, this._prompt)
2574
+ .pipe(operators.map(function (result) {
2575
+ return confirmResultContinue(result);
2576
+ }));
2577
+ };
2578
+ FormDeactivateGuard.ctorParameters = function () { return [
2579
+ { type: prompt.FsPrompt }
2580
+ ]; };
2581
+ FormDeactivateGuard.ɵprov = core.ɵɵdefineInjectable({ factory: function FormDeactivateGuard_Factory() { return new FormDeactivateGuard(core.ɵɵinject(prompt.FsPrompt)); }, token: FormDeactivateGuard, providedIn: "root" });
2582
+ FormDeactivateGuard = __decorate([
2583
+ core.Injectable({
2584
+ providedIn: 'root'
2585
+ }),
2586
+ __metadata("design:paramtypes", [prompt.FsPrompt])
2587
+ ], FormDeactivateGuard);
2588
+ return FormDeactivateGuard;
2592
2589
  }());
2593
2590
 
2594
2591
  exports.FormDeactivateGuard = FormDeactivateGuard;