@ngxs/form-plugin 3.7.6 → 3.8.0-dev.master-743a236

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.
@@ -1,611 +1,283 @@
1
1
  (function (global, factory) {
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@ngxs/store'), require('@angular/forms'), require('rxjs'), require('rxjs/operators')) :
3
3
  typeof define === 'function' && define.amd ? define('@ngxs/form-plugin', ['exports', '@angular/core', '@ngxs/store', '@angular/forms', 'rxjs', 'rxjs/operators'], factory) :
4
- (global = global || self, factory((global.ngxs = global.ngxs || {}, global.ngxs['form-plugin'] = {}), global.ng.core, global['ngxs-store'], global.ng.forms, global.rxjs, global.rxjs.operators));
5
- }(this, function (exports, core, store, forms, rxjs, operators) { 'use strict';
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.ngxs = global.ngxs || {}, global.ngxs["form-plugin"] = {}), global.ng.core, global["ngxs-store"], global.ng.forms, global.rxjs, global.rxjs.operators));
5
+ })(this, (function (exports, i0, i1, i2, rxjs, operators) { 'use strict';
6
6
 
7
- /*! *****************************************************************************
8
- Copyright (c) Microsoft Corporation.
9
-
10
- Permission to use, copy, modify, and/or distribute this software for any
11
- purpose with or without fee is hereby granted.
12
-
13
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
14
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
15
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
16
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
17
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
18
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19
- PERFORMANCE OF THIS SOFTWARE.
20
- ***************************************************************************** */
21
- /* global Reflect, Promise */
22
-
23
- var extendStatics = function(d, b) {
24
- extendStatics = Object.setPrototypeOf ||
25
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
26
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
27
- return extendStatics(d, b);
28
- };
29
-
30
- function __extends(d, b) {
31
- extendStatics(d, b);
32
- function __() { this.constructor = d; }
33
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
34
- }
35
-
36
- var __assign = function() {
37
- __assign = Object.assign || function __assign(t) {
38
- for (var s, i = 1, n = arguments.length; i < n; i++) {
39
- s = arguments[i];
40
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
41
- }
42
- return t;
43
- };
44
- return __assign.apply(this, arguments);
45
- };
46
-
47
- function __rest(s, e) {
48
- var t = {};
49
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
50
- t[p] = s[p];
51
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
52
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
53
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
54
- t[p[i]] = s[p[i]];
55
- }
56
- return t;
57
- }
58
-
59
- function __decorate(decorators, target, key, desc) {
60
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
61
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
62
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
63
- return c > 3 && r && Object.defineProperty(target, key, r), r;
64
- }
65
-
66
- function __param(paramIndex, decorator) {
67
- return function (target, key) { decorator(target, key, paramIndex); }
68
- }
69
-
70
- function __metadata(metadataKey, metadataValue) {
71
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
72
- }
73
-
74
- function __awaiter(thisArg, _arguments, P, generator) {
75
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
76
- return new (P || (P = Promise))(function (resolve, reject) {
77
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
78
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
79
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
80
- step((generator = generator.apply(thisArg, _arguments || [])).next());
81
- });
82
- }
83
-
84
- function __generator(thisArg, body) {
85
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
86
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
87
- function verb(n) { return function (v) { return step([n, v]); }; }
88
- function step(op) {
89
- if (f) throw new TypeError("Generator is already executing.");
90
- while (_) try {
91
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
92
- if (y = 0, t) op = [op[0] & 2, t.value];
93
- switch (op[0]) {
94
- case 0: case 1: t = op; break;
95
- case 4: _.label++; return { value: op[1], done: false };
96
- case 5: _.label++; y = op[1]; op = [0]; continue;
97
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
98
- default:
99
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
100
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
101
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
102
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
103
- if (t[2]) _.ops.pop();
104
- _.trys.pop(); continue;
105
- }
106
- op = body.call(thisArg, _);
107
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
108
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
109
- }
110
- }
111
-
112
- function __createBinding(o, m, k, k2) {
113
- if (k2 === undefined) k2 = k;
114
- o[k2] = m[k];
115
- }
116
-
117
- function __exportStar(m, exports) {
118
- for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) exports[p] = m[p];
119
- }
120
-
121
- function __values(o) {
122
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
123
- if (m) return m.call(o);
124
- if (o && typeof o.length === "number") return {
125
- next: function () {
126
- if (o && i >= o.length) o = void 0;
127
- return { value: o && o[i++], done: !o };
128
- }
129
- };
130
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
131
- }
132
-
133
- function __read(o, n) {
134
- var m = typeof Symbol === "function" && o[Symbol.iterator];
135
- if (!m) return o;
136
- var i = m.call(o), r, ar = [], e;
137
- try {
138
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
139
- }
140
- catch (error) { e = { error: error }; }
141
- finally {
142
- try {
143
- if (r && !r.done && (m = i["return"])) m.call(i);
144
- }
145
- finally { if (e) throw e.error; }
146
- }
147
- return ar;
148
- }
149
-
150
- function __spread() {
151
- for (var ar = [], i = 0; i < arguments.length; i++)
152
- ar = ar.concat(__read(arguments[i]));
153
- return ar;
154
- }
155
-
156
- function __spreadArrays() {
157
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
158
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
159
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
160
- r[k] = a[j];
161
- return r;
162
- };
163
-
164
- function __await(v) {
165
- return this instanceof __await ? (this.v = v, this) : new __await(v);
166
- }
167
-
168
- function __asyncGenerator(thisArg, _arguments, generator) {
169
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
170
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
171
- return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
172
- function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
173
- function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
174
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
175
- function fulfill(value) { resume("next", value); }
176
- function reject(value) { resume("throw", value); }
177
- function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
178
- }
179
-
180
- function __asyncDelegator(o) {
181
- var i, p;
182
- return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
183
- function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
184
- }
185
-
186
- function __asyncValues(o) {
187
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
188
- var m = o[Symbol.asyncIterator], i;
189
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
190
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
191
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
192
- }
193
-
194
- function __makeTemplateObject(cooked, raw) {
195
- if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
196
- return cooked;
197
- };
198
-
199
- function __importStar(mod) {
200
- if (mod && mod.__esModule) return mod;
201
- var result = {};
202
- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
203
- result.default = mod;
204
- return result;
205
- }
206
-
207
- function __importDefault(mod) {
208
- return (mod && mod.__esModule) ? mod : { default: mod };
209
- }
210
-
211
- function __classPrivateFieldGet(receiver, privateMap) {
212
- if (!privateMap.has(receiver)) {
213
- throw new TypeError("attempted to get private field on non-instance");
214
- }
215
- return privateMap.get(receiver);
216
- }
217
-
218
- function __classPrivateFieldSet(receiver, privateMap, value) {
219
- if (!privateMap.has(receiver)) {
220
- throw new TypeError("attempted to set private field on non-instance");
221
- }
222
- privateMap.set(receiver, value);
223
- return value;
7
+ function _interopNamespace(e) {
8
+ if (e && e.__esModule) return e;
9
+ var n = Object.create(null);
10
+ if (e) {
11
+ Object.keys(e).forEach(function (k) {
12
+ if (k !== 'default') {
13
+ var d = Object.getOwnPropertyDescriptor(e, k);
14
+ Object.defineProperty(n, k, d.get ? d : {
15
+ enumerable: true,
16
+ get: function () { return e[k]; }
17
+ });
18
+ }
19
+ });
20
+ }
21
+ n["default"] = e;
22
+ return Object.freeze(n);
224
23
  }
225
24
 
226
- /**
227
- * @fileoverview added by tsickle
228
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
229
- */
25
+ var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
26
+ var i1__namespace = /*#__PURE__*/_interopNamespace(i1);
27
+ var i2__namespace = /*#__PURE__*/_interopNamespace(i2);
28
+
230
29
  var UpdateFormStatus = /** @class */ (function () {
231
30
  function UpdateFormStatus(payload) {
232
31
  this.payload = payload;
233
32
  }
234
33
  Object.defineProperty(UpdateFormStatus, "type", {
235
- get: /**
236
- * @return {?}
237
- */
238
- function () {
34
+ get: function () {
239
35
  // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
240
36
  return '[Forms] Update Form Status';
241
37
  },
242
- enumerable: true,
38
+ enumerable: false,
243
39
  configurable: true
244
40
  });
245
41
  return UpdateFormStatus;
246
42
  }());
247
- if (false) {
248
- /** @type {?} */
249
- UpdateFormStatus.prototype.payload;
250
- }
251
43
  var UpdateFormValue = /** @class */ (function () {
252
44
  function UpdateFormValue(payload) {
253
45
  this.payload = payload;
254
46
  }
255
47
  Object.defineProperty(UpdateFormValue, "type", {
256
- get: /**
257
- * @return {?}
258
- */
259
- function () {
48
+ get: function () {
260
49
  // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
261
50
  return '[Forms] Update Form Value';
262
51
  },
263
- enumerable: true,
52
+ enumerable: false,
264
53
  configurable: true
265
54
  });
266
55
  return UpdateFormValue;
267
56
  }());
268
- if (false) {
269
- /** @type {?} */
270
- UpdateFormValue.prototype.payload;
271
- }
272
57
  var UpdateForm = /** @class */ (function () {
273
58
  function UpdateForm(payload) {
274
59
  this.payload = payload;
275
60
  }
276
61
  Object.defineProperty(UpdateForm, "type", {
277
- get: /**
278
- * @return {?}
279
- */
280
- function () {
62
+ get: function () {
281
63
  // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
282
64
  return '[Forms] Update Form';
283
65
  },
284
- enumerable: true,
66
+ enumerable: false,
285
67
  configurable: true
286
68
  });
287
69
  return UpdateForm;
288
70
  }());
289
- if (false) {
290
- /** @type {?} */
291
- UpdateForm.prototype.payload;
292
- }
293
71
  var UpdateFormDirty = /** @class */ (function () {
294
72
  function UpdateFormDirty(payload) {
295
73
  this.payload = payload;
296
74
  }
297
75
  Object.defineProperty(UpdateFormDirty, "type", {
298
- get: /**
299
- * @return {?}
300
- */
301
- function () {
76
+ get: function () {
302
77
  // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
303
78
  return '[Forms] Update Form Dirty';
304
79
  },
305
- enumerable: true,
80
+ enumerable: false,
306
81
  configurable: true
307
82
  });
308
83
  return UpdateFormDirty;
309
84
  }());
310
- if (false) {
311
- /** @type {?} */
312
- UpdateFormDirty.prototype.payload;
313
- }
314
85
  var SetFormDirty = /** @class */ (function () {
315
86
  function SetFormDirty(payload) {
316
87
  this.payload = payload;
317
88
  }
318
89
  Object.defineProperty(SetFormDirty, "type", {
319
- get: /**
320
- * @return {?}
321
- */
322
- function () {
90
+ get: function () {
323
91
  // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
324
92
  return '[Forms] Set Form Dirty';
325
93
  },
326
- enumerable: true,
94
+ enumerable: false,
327
95
  configurable: true
328
96
  });
329
97
  return SetFormDirty;
330
98
  }());
331
- if (false) {
332
- /** @type {?} */
333
- SetFormDirty.prototype.payload;
334
- }
335
99
  var SetFormPristine = /** @class */ (function () {
336
100
  function SetFormPristine(payload) {
337
101
  this.payload = payload;
338
102
  }
339
103
  Object.defineProperty(SetFormPristine, "type", {
340
- get: /**
341
- * @return {?}
342
- */
343
- function () {
104
+ get: function () {
344
105
  // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
345
106
  return '[Forms] Set Form Pristine';
346
107
  },
347
- enumerable: true,
108
+ enumerable: false,
348
109
  configurable: true
349
110
  });
350
111
  return SetFormPristine;
351
112
  }());
352
- if (false) {
353
- /** @type {?} */
354
- SetFormPristine.prototype.payload;
355
- }
356
113
  var UpdateFormErrors = /** @class */ (function () {
357
114
  function UpdateFormErrors(payload) {
358
115
  this.payload = payload;
359
116
  }
360
117
  Object.defineProperty(UpdateFormErrors, "type", {
361
- get: /**
362
- * @return {?}
363
- */
364
- function () {
118
+ get: function () {
365
119
  // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
366
120
  return '[Forms] Update Form Errors';
367
121
  },
368
- enumerable: true,
122
+ enumerable: false,
369
123
  configurable: true
370
124
  });
371
125
  return UpdateFormErrors;
372
126
  }());
373
- if (false) {
374
- /** @type {?} */
375
- UpdateFormErrors.prototype.payload;
376
- }
377
127
  var SetFormDisabled = /** @class */ (function () {
378
128
  function SetFormDisabled(payload) {
379
129
  this.payload = payload;
380
130
  }
381
131
  Object.defineProperty(SetFormDisabled, "type", {
382
- get: /**
383
- * @return {?}
384
- */
385
- function () {
132
+ get: function () {
386
133
  // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
387
134
  return '[Forms] Set Form Disabled';
388
135
  },
389
- enumerable: true,
136
+ enumerable: false,
390
137
  configurable: true
391
138
  });
392
139
  return SetFormDisabled;
393
140
  }());
394
- if (false) {
395
- /** @type {?} */
396
- SetFormDisabled.prototype.payload;
397
- }
398
141
  var SetFormEnabled = /** @class */ (function () {
399
142
  function SetFormEnabled(payload) {
400
143
  this.payload = payload;
401
144
  }
402
145
  Object.defineProperty(SetFormEnabled, "type", {
403
- get: /**
404
- * @return {?}
405
- */
406
- function () {
146
+ get: function () {
407
147
  // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
408
148
  return '[Forms] Set Form Enabled';
409
149
  },
410
- enumerable: true,
150
+ enumerable: false,
411
151
  configurable: true
412
152
  });
413
153
  return SetFormEnabled;
414
154
  }());
415
- if (false) {
416
- /** @type {?} */
417
- SetFormEnabled.prototype.payload;
418
- }
419
155
  var ResetForm = /** @class */ (function () {
420
156
  function ResetForm(payload) {
421
157
  this.payload = payload;
422
158
  }
423
159
  Object.defineProperty(ResetForm, "type", {
424
- get: /**
425
- * @return {?}
426
- */
427
- function () {
160
+ get: function () {
428
161
  // NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
429
162
  return '[Forms] Reset Form';
430
163
  },
431
- enumerable: true,
164
+ enumerable: false,
432
165
  configurable: true
433
166
  });
434
167
  return ResetForm;
435
168
  }());
436
- if (false) {
437
- /** @type {?} */
438
- ResetForm.prototype.payload;
439
- }
440
169
 
441
- /**
442
- * @fileoverview added by tsickle
443
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
444
- */
445
170
  var NgxsFormPlugin = /** @class */ (function () {
446
171
  function NgxsFormPlugin() {
447
172
  }
448
- /**
449
- * @param {?} state
450
- * @param {?} event
451
- * @param {?} next
452
- * @return {?}
453
- */
454
- NgxsFormPlugin.prototype.handle = /**
455
- * @param {?} state
456
- * @param {?} event
457
- * @param {?} next
458
- * @return {?}
459
- */
460
- function (state, event, next) {
461
- /** @type {?} */
462
- var type = store.getActionTypeFromInstance(event);
463
- /** @type {?} */
173
+ NgxsFormPlugin.prototype.handle = function (state, event, next) {
174
+ var type = i1.getActionTypeFromInstance(event);
464
175
  var nextState = state;
465
176
  if (type === UpdateFormValue.type || type === UpdateForm.type || type === ResetForm.type) {
466
177
  var value = event.payload.value;
467
- /** @type {?} */
468
178
  var payloadValue = Array.isArray(value)
469
179
  ? value.slice()
470
180
  : isObjectLike(value)
471
- ? __assign({}, value) : value;
472
- /** @type {?} */
181
+ ? Object.assign({}, value) : value;
473
182
  var path = this.joinPathWithPropertyPath(event);
474
- nextState = store.setValue(nextState, path, payloadValue);
183
+ nextState = i1.setValue(nextState, path, payloadValue);
475
184
  }
476
185
  if (type === ResetForm.type) {
477
- /** @type {?} */
478
- var model = store.getValue(nextState, event.payload.path + ".model");
479
- nextState = store.setValue(nextState, "" + event.payload.path, { model: model });
186
+ var model = i1.getValue(nextState, event.payload.path + ".model");
187
+ nextState = i1.setValue(nextState, "" + event.payload.path, { model: model });
480
188
  }
481
189
  if (type === UpdateFormStatus.type || type === UpdateForm.type) {
482
- nextState = store.setValue(nextState, event.payload.path + ".status", event.payload.status);
190
+ nextState = i1.setValue(nextState, event.payload.path + ".status", event.payload.status);
483
191
  }
484
192
  if (type === UpdateFormErrors.type || type === UpdateForm.type) {
485
- nextState = store.setValue(nextState, event.payload.path + ".errors", __assign({}, event.payload.errors));
193
+ nextState = i1.setValue(nextState, event.payload.path + ".errors", Object.assign({}, event.payload.errors));
486
194
  }
487
195
  if (type === UpdateFormDirty.type || type === UpdateForm.type) {
488
- nextState = store.setValue(nextState, event.payload.path + ".dirty", event.payload.dirty);
196
+ nextState = i1.setValue(nextState, event.payload.path + ".dirty", event.payload.dirty);
489
197
  }
490
198
  if (type === SetFormDirty.type) {
491
- nextState = store.setValue(nextState, event.payload + ".dirty", true);
199
+ nextState = i1.setValue(nextState, event.payload + ".dirty", true);
492
200
  }
493
201
  if (type === SetFormPristine.type) {
494
- nextState = store.setValue(nextState, event.payload + ".dirty", false);
202
+ nextState = i1.setValue(nextState, event.payload + ".dirty", false);
495
203
  }
496
204
  if (type === SetFormDisabled.type) {
497
- nextState = store.setValue(nextState, event.payload + ".disabled", true);
205
+ nextState = i1.setValue(nextState, event.payload + ".disabled", true);
498
206
  }
499
207
  if (type === SetFormEnabled.type) {
500
- nextState = store.setValue(nextState, event.payload + ".disabled", false);
208
+ nextState = i1.setValue(nextState, event.payload + ".disabled", false);
501
209
  }
502
210
  return next(nextState, event);
503
211
  };
504
- /**
505
- * @private
506
- * @param {?} __0
507
- * @return {?}
508
- */
509
- NgxsFormPlugin.prototype.joinPathWithPropertyPath = /**
510
- * @private
511
- * @param {?} __0
512
- * @return {?}
513
- */
514
- function (_a) {
212
+ NgxsFormPlugin.prototype.joinPathWithPropertyPath = function (_a) {
515
213
  var payload = _a.payload;
516
- /** @type {?} */
517
214
  var path = payload.path + ".model";
518
215
  if (payload.propertyPath) {
519
216
  path += "." + payload.propertyPath;
520
217
  }
521
218
  return path;
522
219
  };
523
- NgxsFormPlugin.decorators = [
524
- { type: core.Injectable }
525
- ];
526
220
  return NgxsFormPlugin;
527
221
  }());
528
- /**
529
- * @param {?} target
530
- * @return {?}
531
- */
222
+ /** @nocollapse */ NgxsFormPlugin.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NgxsFormPlugin, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
223
+ /** @nocollapse */ NgxsFormPlugin.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NgxsFormPlugin });
224
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NgxsFormPlugin, decorators: [{
225
+ type: i0.Injectable
226
+ }] });
532
227
  function isObjectLike(target) {
533
228
  return target !== null && typeof target === 'object';
534
229
  }
535
230
 
536
- /**
537
- * @fileoverview added by tsickle
538
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
539
- */
540
231
  var FormDirective = /** @class */ (function () {
541
232
  function FormDirective(_actions$, _store, _formGroupDirective, _cd) {
542
233
  this._actions$ = _actions$;
543
234
  this._store = _store;
544
235
  this._formGroupDirective = _formGroupDirective;
545
236
  this._cd = _cd;
546
- this.path = (/** @type {?} */ (null));
547
- this.debounce = 100;
237
+ this.path = null;
238
+ this._debounce = 100;
548
239
  this._clearDestroy = false;
549
- this._destroy$ = new rxjs.Subject();
550
240
  this._updating = false;
241
+ this._destroy$ = new rxjs.Subject();
551
242
  }
243
+ Object.defineProperty(FormDirective.prototype, "debounce", {
244
+ get: function () {
245
+ return this._debounce;
246
+ },
247
+ set: function (debounce) {
248
+ this._debounce = Number(debounce);
249
+ },
250
+ enumerable: false,
251
+ configurable: true
252
+ });
552
253
  Object.defineProperty(FormDirective.prototype, "clearDestroy", {
553
- get: /**
554
- * @return {?}
555
- */
556
- function () {
254
+ get: function () {
557
255
  return this._clearDestroy;
558
256
  },
559
- set: /**
560
- * @param {?} val
561
- * @return {?}
562
- */
563
- function (val) {
257
+ set: function (val) {
564
258
  this._clearDestroy = val != null && "" + val !== 'false';
565
259
  },
566
- enumerable: true,
260
+ enumerable: false,
567
261
  configurable: true
568
262
  });
569
- /**
570
- * @return {?}
571
- */
572
- FormDirective.prototype.ngOnInit = /**
573
- * @return {?}
574
- */
575
- function () {
263
+ FormDirective.prototype.ngOnInit = function () {
576
264
  var _this = this;
577
265
  this._actions$
578
- .pipe(store.ofActionDispatched(ResetForm), operators.filter((/**
579
- * @param {?} action
580
- * @return {?}
581
- */
582
- function (action) { return action.payload.path === _this.path; })), operators.takeUntil(this._destroy$))
583
- .subscribe((/**
584
- * @param {?} __0
585
- * @return {?}
586
- */
587
- function (_a) {
266
+ .pipe(i1.ofActionDispatched(ResetForm), operators.filter(function (action) { return action.payload.path === _this.path; }), operators.takeUntil(this._destroy$))
267
+ .subscribe(function (_a) {
588
268
  var value = _a.payload.value;
589
269
  _this.form.reset(value);
590
270
  _this.updateFormStateWithRawValue(true);
591
271
  _this._cd.markForCheck();
592
- }));
593
- this.getStateStream(this.path + ".model").subscribe((/**
594
- * @param {?} model
595
- * @return {?}
596
- */
597
- function (model) {
272
+ });
273
+ this.getStateStream(this.path + ".model").subscribe(function (model) {
598
274
  if (_this._updating || !model) {
599
275
  return;
600
276
  }
601
277
  _this.form.patchValue(model);
602
278
  _this._cd.markForCheck();
603
- }));
604
- this.getStateStream(this.path + ".dirty").subscribe((/**
605
- * @param {?} dirty
606
- * @return {?}
607
- */
608
- function (dirty) {
279
+ });
280
+ this.getStateStream(this.path + ".dirty").subscribe(function (dirty) {
609
281
  if (_this.form.dirty === dirty || typeof dirty !== 'boolean') {
610
282
  return;
611
283
  }
@@ -616,18 +288,11 @@
616
288
  _this.form.markAsPristine();
617
289
  }
618
290
  _this._cd.markForCheck();
619
- }));
291
+ });
620
292
  // On first state change, sync form model, status and dirty with state
621
293
  this._store
622
- .selectOnce((/**
623
- * @param {?} state
624
- * @return {?}
625
- */
626
- function (state) { return store.getValue(state, _this.path); }))
627
- .subscribe((/**
628
- * @return {?}
629
- */
630
- function () {
294
+ .selectOnce(function (state) { return i1.getValue(state, _this.path); })
295
+ .subscribe(function () {
631
296
  _this._store.dispatch([
632
297
  new UpdateFormValue({
633
298
  path: _this.path,
@@ -642,12 +307,8 @@
642
307
  dirty: _this.form.dirty
643
308
  })
644
309
  ]);
645
- }));
646
- this.getStateStream(this.path + ".disabled").subscribe((/**
647
- * @param {?} disabled
648
- * @return {?}
649
- */
650
- function (disabled) {
310
+ });
311
+ this.getStateStream(this.path + ".disabled").subscribe(function (disabled) {
651
312
  if (_this.form.disabled === disabled || typeof disabled !== 'boolean') {
652
313
  return;
653
314
  }
@@ -658,48 +319,26 @@
658
319
  _this.form.enable();
659
320
  }
660
321
  _this._cd.markForCheck();
661
- }));
662
- (/** @type {?} */ (this._formGroupDirective
663
- .valueChanges)).pipe(operators.distinctUntilChanged((/**
664
- * @param {?} a
665
- * @param {?} b
666
- * @return {?}
667
- */
668
- function (a, b) { return JSON.stringify(a) === JSON.stringify(b); })), this.debounceChange())
669
- .subscribe((/**
670
- * @return {?}
671
- */
672
- function () {
322
+ });
323
+ this._formGroupDirective
324
+ .valueChanges.pipe(operators.distinctUntilChanged(function (a, b) { return JSON.stringify(a) === JSON.stringify(b); }), this.debounceChange())
325
+ .subscribe(function () {
673
326
  _this.updateFormStateWithRawValue();
674
- }));
675
- (/** @type {?} */ (this._formGroupDirective
676
- .statusChanges)).pipe(operators.distinctUntilChanged(), this.debounceChange())
677
- .subscribe((/**
678
- * @param {?} status
679
- * @return {?}
680
- */
681
- function (status) {
327
+ });
328
+ this._formGroupDirective
329
+ .statusChanges.pipe(operators.distinctUntilChanged(), this.debounceChange())
330
+ .subscribe(function (status) {
682
331
  _this._store.dispatch(new UpdateFormStatus({
683
332
  status: status,
684
333
  path: _this.path
685
334
  }));
686
- }));
335
+ });
687
336
  };
688
- /**
689
- * @param {?=} withFormStatus
690
- * @return {?}
691
- */
692
- FormDirective.prototype.updateFormStateWithRawValue = /**
693
- * @param {?=} withFormStatus
694
- * @return {?}
695
- */
696
- function (withFormStatus) {
337
+ FormDirective.prototype.updateFormStateWithRawValue = function (withFormStatus) {
697
338
  var _this = this;
698
339
  if (this._updating)
699
340
  return;
700
- /** @type {?} */
701
341
  var value = this._formGroupDirective.control.getRawValue();
702
- /** @type {?} */
703
342
  var actions = [
704
343
  new UpdateFormValue({
705
344
  path: this.path,
@@ -722,25 +361,12 @@
722
361
  }
723
362
  this._updating = true;
724
363
  this._store.dispatch(actions).subscribe({
725
- error: (/**
726
- * @return {?}
727
- */
728
- function () { return (_this._updating = false); }),
729
- complete: (/**
730
- * @return {?}
731
- */
732
- function () { return (_this._updating = false); })
364
+ error: function () { return (_this._updating = false); },
365
+ complete: function () { return (_this._updating = false); }
733
366
  });
734
367
  };
735
- /**
736
- * @return {?}
737
- */
738
- FormDirective.prototype.ngOnDestroy = /**
739
- * @return {?}
740
- */
741
- function () {
368
+ FormDirective.prototype.ngOnDestroy = function () {
742
369
  this._destroy$.next();
743
- this._destroy$.complete();
744
370
  if (this.clearDestroy) {
745
371
  this._store.dispatch(new UpdateForm({
746
372
  path: this.path,
@@ -751,150 +377,77 @@
751
377
  }));
752
378
  }
753
379
  };
754
- /**
755
- * @private
756
- * @return {?}
757
- */
758
- FormDirective.prototype.debounceChange = /**
759
- * @private
760
- * @return {?}
761
- */
762
- function () {
380
+ FormDirective.prototype.debounceChange = function () {
763
381
  var _this = this;
764
- /** @type {?} */
765
- var skipDebounceTime = this._formGroupDirective.control.updateOn !== 'change' || this.debounce < 0;
382
+ var skipDebounceTime = this._formGroupDirective.control.updateOn !== 'change' || this._debounce < 0;
766
383
  return skipDebounceTime
767
- ? (/**
768
- * @param {?} change
769
- * @return {?}
770
- */
771
- function (change) { return change.pipe(operators.takeUntil(_this._destroy$)); })
772
- : (/**
773
- * @param {?} change
774
- * @return {?}
775
- */
776
- function (change) {
777
- return change.pipe(operators.debounceTime(_this.debounce), operators.takeUntil(_this._destroy$));
778
- });
384
+ ? function (change) { return change.pipe(operators.takeUntil(_this._destroy$)); }
385
+ : function (change) { return change.pipe(operators.debounceTime(_this._debounce), operators.takeUntil(_this._destroy$)); };
779
386
  };
780
387
  Object.defineProperty(FormDirective.prototype, "form", {
781
- get: /**
782
- * @private
783
- * @return {?}
784
- */
785
- function () {
388
+ get: function () {
786
389
  return this._formGroupDirective.form;
787
390
  },
788
- enumerable: true,
391
+ enumerable: false,
789
392
  configurable: true
790
393
  });
791
- /**
792
- * @private
793
- * @param {?} path
794
- * @return {?}
795
- */
796
- FormDirective.prototype.getStateStream = /**
797
- * @private
798
- * @param {?} path
799
- * @return {?}
800
- */
801
- function (path) {
802
- return this._store.select((/**
803
- * @param {?} state
804
- * @return {?}
805
- */
806
- function (state) { return store.getValue(state, path); })).pipe(operators.takeUntil(this._destroy$));
807
- };
808
- FormDirective.decorators = [
809
- { type: core.Directive, args: [{ selector: '[ngxsForm]' },] }
810
- ];
811
- /** @nocollapse */
812
- FormDirective.ctorParameters = function () { return [
813
- { type: store.Actions },
814
- { type: store.Store },
815
- { type: forms.FormGroupDirective },
816
- { type: core.ChangeDetectorRef }
817
- ]; };
818
- FormDirective.propDecorators = {
819
- path: [{ type: core.Input, args: ['ngxsForm',] }],
820
- debounce: [{ type: core.Input, args: ['ngxsFormDebounce',] }],
821
- clearDestroy: [{ type: core.Input, args: ['ngxsFormClearOnDestroy',] }]
394
+ FormDirective.prototype.getStateStream = function (path) {
395
+ return this._store.select(function (state) { return i1.getValue(state, path); }).pipe(operators.takeUntil(this._destroy$));
822
396
  };
823
397
  return FormDirective;
824
398
  }());
825
- if (false) {
826
- /** @type {?} */
827
- FormDirective.prototype.path;
828
- /** @type {?} */
829
- FormDirective.prototype.debounce;
830
- /** @type {?} */
831
- FormDirective.prototype._clearDestroy;
832
- /**
833
- * @type {?}
834
- * @private
835
- */
836
- FormDirective.prototype._destroy$;
837
- /**
838
- * @type {?}
839
- * @private
840
- */
841
- FormDirective.prototype._updating;
842
- /**
843
- * @type {?}
844
- * @private
845
- */
846
- FormDirective.prototype._actions$;
847
- /**
848
- * @type {?}
849
- * @private
850
- */
851
- FormDirective.prototype._store;
852
- /**
853
- * @type {?}
854
- * @private
855
- */
856
- FormDirective.prototype._formGroupDirective;
857
- /**
858
- * @type {?}
859
- * @private
860
- */
861
- FormDirective.prototype._cd;
862
- }
399
+ /** @nocollapse */ FormDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FormDirective, deps: [{ token: i1__namespace.Actions }, { token: i1__namespace.Store }, { token: i2__namespace.FormGroupDirective }, { token: i0__namespace.ChangeDetectorRef }], target: i0__namespace.ɵɵFactoryTarget.Directive });
400
+ /** @nocollapse */ FormDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.17", type: FormDirective, selector: "[ngxsForm]", inputs: { path: ["ngxsForm", "path"], debounce: ["ngxsFormDebounce", "debounce"], clearDestroy: ["ngxsFormClearOnDestroy", "clearDestroy"] }, ngImport: i0__namespace });
401
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FormDirective, decorators: [{
402
+ type: i0.Directive,
403
+ args: [{ selector: '[ngxsForm]' }]
404
+ }], ctorParameters: function () { return [{ type: i1__namespace.Actions }, { type: i1__namespace.Store }, { type: i2__namespace.FormGroupDirective }, { type: i0__namespace.ChangeDetectorRef }]; }, propDecorators: { path: [{
405
+ type: i0.Input,
406
+ args: ['ngxsForm']
407
+ }], debounce: [{
408
+ type: i0.Input,
409
+ args: ['ngxsFormDebounce']
410
+ }], clearDestroy: [{
411
+ type: i0.Input,
412
+ args: ['ngxsFormClearOnDestroy']
413
+ }] } });
863
414
 
864
- /**
865
- * @fileoverview added by tsickle
866
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
867
- */
868
415
  var NgxsFormPluginModule = /** @class */ (function () {
869
416
  function NgxsFormPluginModule() {
870
417
  }
871
- /**
872
- * @return {?}
873
- */
874
- NgxsFormPluginModule.forRoot = /**
875
- * @return {?}
876
- */
877
- function () {
418
+ NgxsFormPluginModule.forRoot = function () {
878
419
  return {
879
420
  ngModule: NgxsFormPluginModule,
880
421
  providers: [
881
422
  {
882
- provide: store.NGXS_PLUGINS,
423
+ provide: i1.NGXS_PLUGINS,
883
424
  useClass: NgxsFormPlugin,
884
425
  multi: true
885
426
  }
886
427
  ]
887
428
  };
888
429
  };
889
- NgxsFormPluginModule.decorators = [
890
- { type: core.NgModule, args: [{
891
- imports: [forms.ReactiveFormsModule],
892
- declarations: [FormDirective],
893
- exports: [FormDirective]
894
- },] }
895
- ];
896
430
  return NgxsFormPluginModule;
897
431
  }());
432
+ /** @nocollapse */ NgxsFormPluginModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NgxsFormPluginModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
433
+ /** @nocollapse */ NgxsFormPluginModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NgxsFormPluginModule, declarations: [FormDirective], imports: [i2.ReactiveFormsModule], exports: [FormDirective] });
434
+ /** @nocollapse */ NgxsFormPluginModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NgxsFormPluginModule, imports: [[i2.ReactiveFormsModule]] });
435
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: NgxsFormPluginModule, decorators: [{
436
+ type: i0.NgModule,
437
+ args: [{
438
+ imports: [i2.ReactiveFormsModule],
439
+ declarations: [FormDirective],
440
+ exports: [FormDirective]
441
+ }]
442
+ }] });
443
+
444
+ /**
445
+ * The public api for consumers of @ngxs/form-plugin
446
+ */
447
+
448
+ /**
449
+ * Generated bundle index. Do not edit.
450
+ */
898
451
 
899
452
  exports.NgxsFormPlugin = NgxsFormPlugin;
900
453
  exports.NgxsFormPluginModule = NgxsFormPluginModule;
@@ -908,7 +461,7 @@
908
461
  exports.UpdateFormErrors = UpdateFormErrors;
909
462
  exports.UpdateFormStatus = UpdateFormStatus;
910
463
  exports.UpdateFormValue = UpdateFormValue;
911
- exports.ɵa = FormDirective;
464
+ exports["ɵFormDirective"] = FormDirective;
912
465
 
913
466
  Object.defineProperty(exports, '__esModule', { value: true });
914
467