@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.
- package/bundles/ngxs-form-plugin.umd.js +147 -594
- package/bundles/ngxs-form-plugin.umd.js.map +1 -1
- package/esm2015/index.js +2 -6
- package/esm2015/ngxs-form-plugin.js +2 -7
- package/esm2015/src/actions.js +1 -105
- package/esm2015/src/directive.js +54 -184
- package/esm2015/src/form.module.js +13 -15
- package/esm2015/src/form.plugin.js +7 -29
- package/esm2015/src/public_api.js +3 -6
- package/fesm2015/ngxs-form-plugin.js +76 -343
- package/fesm2015/ngxs-form-plugin.js.map +1 -1
- package/ngxs-form-plugin.d.ts +1 -1
- package/package.json +5 -8
- package/src/actions.d.ts +10 -10
- package/src/directive.d.ts +11 -5
- package/src/form.module.d.ts +6 -0
- package/src/form.plugin.d.ts +3 -0
- package/src/public_api.d.ts +1 -0
- package/bundles/ngxs-form-plugin.umd.min.js +0 -16
- package/bundles/ngxs-form-plugin.umd.min.js.map +0 -1
- package/esm5/index.js +0 -9
- package/esm5/ngxs-form-plugin.js +0 -10
- package/esm5/src/actions.js +0 -225
- package/esm5/src/directive.js +0 -335
- package/esm5/src/form.module.js +0 -41
- package/esm5/src/form.plugin.js +0 -100
- package/esm5/src/public_api.js +0 -8
- package/fesm5/ngxs-form-plugin.js +0 -697
- package/fesm5/ngxs-form-plugin.js.map +0 -1
- package/ngxs-form-plugin.metadata.json +0 -1
|
@@ -1,233 +1,117 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Injectable, Directive, Input, NgModule } from '@angular/core';
|
|
3
|
+
import * as i1 from '@ngxs/store';
|
|
4
|
+
import { getActionTypeFromInstance, setValue, getValue, ofActionDispatched, NGXS_PLUGINS } from '@ngxs/store';
|
|
5
|
+
import * as i2 from '@angular/forms';
|
|
6
|
+
import { ReactiveFormsModule } from '@angular/forms';
|
|
4
7
|
import { Subject } from 'rxjs';
|
|
5
8
|
import { filter, takeUntil, distinctUntilChanged, debounceTime } from 'rxjs/operators';
|
|
6
9
|
|
|
7
|
-
/**
|
|
8
|
-
* @fileoverview added by tsickle
|
|
9
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
10
|
-
*/
|
|
11
10
|
class UpdateFormStatus {
|
|
12
|
-
/**
|
|
13
|
-
* @param {?} payload
|
|
14
|
-
*/
|
|
15
11
|
constructor(payload) {
|
|
16
12
|
this.payload = payload;
|
|
17
13
|
}
|
|
18
|
-
/**
|
|
19
|
-
* @return {?}
|
|
20
|
-
*/
|
|
21
14
|
static get type() {
|
|
22
15
|
// NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
|
|
23
16
|
return '[Forms] Update Form Status';
|
|
24
17
|
}
|
|
25
18
|
}
|
|
26
|
-
if (false) {
|
|
27
|
-
/** @type {?} */
|
|
28
|
-
UpdateFormStatus.prototype.payload;
|
|
29
|
-
}
|
|
30
19
|
class UpdateFormValue {
|
|
31
|
-
/**
|
|
32
|
-
* @param {?} payload
|
|
33
|
-
*/
|
|
34
20
|
constructor(payload) {
|
|
35
21
|
this.payload = payload;
|
|
36
22
|
}
|
|
37
|
-
/**
|
|
38
|
-
* @return {?}
|
|
39
|
-
*/
|
|
40
23
|
static get type() {
|
|
41
24
|
// NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
|
|
42
25
|
return '[Forms] Update Form Value';
|
|
43
26
|
}
|
|
44
27
|
}
|
|
45
|
-
if (false) {
|
|
46
|
-
/** @type {?} */
|
|
47
|
-
UpdateFormValue.prototype.payload;
|
|
48
|
-
}
|
|
49
28
|
class UpdateForm {
|
|
50
|
-
/**
|
|
51
|
-
* @param {?} payload
|
|
52
|
-
*/
|
|
53
29
|
constructor(payload) {
|
|
54
30
|
this.payload = payload;
|
|
55
31
|
}
|
|
56
|
-
/**
|
|
57
|
-
* @return {?}
|
|
58
|
-
*/
|
|
59
32
|
static get type() {
|
|
60
33
|
// NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
|
|
61
34
|
return '[Forms] Update Form';
|
|
62
35
|
}
|
|
63
36
|
}
|
|
64
|
-
if (false) {
|
|
65
|
-
/** @type {?} */
|
|
66
|
-
UpdateForm.prototype.payload;
|
|
67
|
-
}
|
|
68
37
|
class UpdateFormDirty {
|
|
69
|
-
/**
|
|
70
|
-
* @param {?} payload
|
|
71
|
-
*/
|
|
72
38
|
constructor(payload) {
|
|
73
39
|
this.payload = payload;
|
|
74
40
|
}
|
|
75
|
-
/**
|
|
76
|
-
* @return {?}
|
|
77
|
-
*/
|
|
78
41
|
static get type() {
|
|
79
42
|
// NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
|
|
80
43
|
return '[Forms] Update Form Dirty';
|
|
81
44
|
}
|
|
82
45
|
}
|
|
83
|
-
if (false) {
|
|
84
|
-
/** @type {?} */
|
|
85
|
-
UpdateFormDirty.prototype.payload;
|
|
86
|
-
}
|
|
87
46
|
class SetFormDirty {
|
|
88
|
-
/**
|
|
89
|
-
* @param {?} payload
|
|
90
|
-
*/
|
|
91
47
|
constructor(payload) {
|
|
92
48
|
this.payload = payload;
|
|
93
49
|
}
|
|
94
|
-
/**
|
|
95
|
-
* @return {?}
|
|
96
|
-
*/
|
|
97
50
|
static get type() {
|
|
98
51
|
// NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
|
|
99
52
|
return '[Forms] Set Form Dirty';
|
|
100
53
|
}
|
|
101
54
|
}
|
|
102
|
-
if (false) {
|
|
103
|
-
/** @type {?} */
|
|
104
|
-
SetFormDirty.prototype.payload;
|
|
105
|
-
}
|
|
106
55
|
class SetFormPristine {
|
|
107
|
-
/**
|
|
108
|
-
* @param {?} payload
|
|
109
|
-
*/
|
|
110
56
|
constructor(payload) {
|
|
111
57
|
this.payload = payload;
|
|
112
58
|
}
|
|
113
|
-
/**
|
|
114
|
-
* @return {?}
|
|
115
|
-
*/
|
|
116
59
|
static get type() {
|
|
117
60
|
// NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
|
|
118
61
|
return '[Forms] Set Form Pristine';
|
|
119
62
|
}
|
|
120
63
|
}
|
|
121
|
-
if (false) {
|
|
122
|
-
/** @type {?} */
|
|
123
|
-
SetFormPristine.prototype.payload;
|
|
124
|
-
}
|
|
125
64
|
class UpdateFormErrors {
|
|
126
|
-
/**
|
|
127
|
-
* @param {?} payload
|
|
128
|
-
*/
|
|
129
65
|
constructor(payload) {
|
|
130
66
|
this.payload = payload;
|
|
131
67
|
}
|
|
132
|
-
/**
|
|
133
|
-
* @return {?}
|
|
134
|
-
*/
|
|
135
68
|
static get type() {
|
|
136
69
|
// NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
|
|
137
70
|
return '[Forms] Update Form Errors';
|
|
138
71
|
}
|
|
139
72
|
}
|
|
140
|
-
if (false) {
|
|
141
|
-
/** @type {?} */
|
|
142
|
-
UpdateFormErrors.prototype.payload;
|
|
143
|
-
}
|
|
144
73
|
class SetFormDisabled {
|
|
145
|
-
/**
|
|
146
|
-
* @param {?} payload
|
|
147
|
-
*/
|
|
148
74
|
constructor(payload) {
|
|
149
75
|
this.payload = payload;
|
|
150
76
|
}
|
|
151
|
-
/**
|
|
152
|
-
* @return {?}
|
|
153
|
-
*/
|
|
154
77
|
static get type() {
|
|
155
78
|
// NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
|
|
156
79
|
return '[Forms] Set Form Disabled';
|
|
157
80
|
}
|
|
158
81
|
}
|
|
159
|
-
if (false) {
|
|
160
|
-
/** @type {?} */
|
|
161
|
-
SetFormDisabled.prototype.payload;
|
|
162
|
-
}
|
|
163
82
|
class SetFormEnabled {
|
|
164
|
-
/**
|
|
165
|
-
* @param {?} payload
|
|
166
|
-
*/
|
|
167
83
|
constructor(payload) {
|
|
168
84
|
this.payload = payload;
|
|
169
85
|
}
|
|
170
|
-
/**
|
|
171
|
-
* @return {?}
|
|
172
|
-
*/
|
|
173
86
|
static get type() {
|
|
174
87
|
// NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
|
|
175
88
|
return '[Forms] Set Form Enabled';
|
|
176
89
|
}
|
|
177
90
|
}
|
|
178
|
-
if (false) {
|
|
179
|
-
/** @type {?} */
|
|
180
|
-
SetFormEnabled.prototype.payload;
|
|
181
|
-
}
|
|
182
91
|
class ResetForm {
|
|
183
|
-
/**
|
|
184
|
-
* @param {?} payload
|
|
185
|
-
*/
|
|
186
92
|
constructor(payload) {
|
|
187
93
|
this.payload = payload;
|
|
188
94
|
}
|
|
189
|
-
/**
|
|
190
|
-
* @return {?}
|
|
191
|
-
*/
|
|
192
95
|
static get type() {
|
|
193
96
|
// NOTE: Not necessary to declare the type in this way in your code. See https://github.com/ngxs/store/pull/644#issuecomment-436003138
|
|
194
97
|
return '[Forms] Reset Form';
|
|
195
98
|
}
|
|
196
99
|
}
|
|
197
|
-
if (false) {
|
|
198
|
-
/** @type {?} */
|
|
199
|
-
ResetForm.prototype.payload;
|
|
200
|
-
}
|
|
201
100
|
|
|
202
|
-
/**
|
|
203
|
-
* @fileoverview added by tsickle
|
|
204
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
205
|
-
*/
|
|
206
101
|
class NgxsFormPlugin {
|
|
207
|
-
/**
|
|
208
|
-
* @param {?} state
|
|
209
|
-
* @param {?} event
|
|
210
|
-
* @param {?} next
|
|
211
|
-
* @return {?}
|
|
212
|
-
*/
|
|
213
102
|
handle(state, event, next) {
|
|
214
|
-
/** @type {?} */
|
|
215
103
|
const type = getActionTypeFromInstance(event);
|
|
216
|
-
/** @type {?} */
|
|
217
104
|
let nextState = state;
|
|
218
105
|
if (type === UpdateFormValue.type || type === UpdateForm.type || type === ResetForm.type) {
|
|
219
106
|
const { value } = event.payload;
|
|
220
|
-
/** @type {?} */
|
|
221
107
|
const payloadValue = Array.isArray(value)
|
|
222
108
|
? value.slice()
|
|
223
109
|
: isObjectLike(value)
|
|
224
110
|
? Object.assign({}, value) : value;
|
|
225
|
-
/** @type {?} */
|
|
226
111
|
const path = this.joinPathWithPropertyPath(event);
|
|
227
112
|
nextState = setValue(nextState, path, payloadValue);
|
|
228
113
|
}
|
|
229
114
|
if (type === ResetForm.type) {
|
|
230
|
-
/** @type {?} */
|
|
231
115
|
const model = getValue(nextState, `${event.payload.path}.model`);
|
|
232
116
|
nextState = setValue(nextState, `${event.payload.path}`, { model: model });
|
|
233
117
|
}
|
|
@@ -254,13 +138,7 @@ class NgxsFormPlugin {
|
|
|
254
138
|
}
|
|
255
139
|
return next(nextState, event);
|
|
256
140
|
}
|
|
257
|
-
/**
|
|
258
|
-
* @private
|
|
259
|
-
* @param {?} __0
|
|
260
|
-
* @return {?}
|
|
261
|
-
*/
|
|
262
141
|
joinPathWithPropertyPath({ payload }) {
|
|
263
|
-
/** @type {?} */
|
|
264
142
|
let path = `${payload.path}.model`;
|
|
265
143
|
if (payload.propertyPath) {
|
|
266
144
|
path += `.${payload.propertyPath}`;
|
|
@@ -268,87 +146,55 @@ class NgxsFormPlugin {
|
|
|
268
146
|
return path;
|
|
269
147
|
}
|
|
270
148
|
}
|
|
271
|
-
NgxsFormPlugin
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
* @return {?}
|
|
277
|
-
*/
|
|
149
|
+
/** @nocollapse */ NgxsFormPlugin.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsFormPlugin, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
150
|
+
/** @nocollapse */ NgxsFormPlugin.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsFormPlugin });
|
|
151
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsFormPlugin, decorators: [{
|
|
152
|
+
type: Injectable
|
|
153
|
+
}] });
|
|
278
154
|
function isObjectLike(target) {
|
|
279
155
|
return target !== null && typeof target === 'object';
|
|
280
156
|
}
|
|
281
157
|
|
|
282
|
-
/**
|
|
283
|
-
* @fileoverview added by tsickle
|
|
284
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
285
|
-
*/
|
|
286
158
|
class FormDirective {
|
|
287
|
-
/**
|
|
288
|
-
* @param {?} _actions$
|
|
289
|
-
* @param {?} _store
|
|
290
|
-
* @param {?} _formGroupDirective
|
|
291
|
-
* @param {?} _cd
|
|
292
|
-
*/
|
|
293
159
|
constructor(_actions$, _store, _formGroupDirective, _cd) {
|
|
294
160
|
this._actions$ = _actions$;
|
|
295
161
|
this._store = _store;
|
|
296
162
|
this._formGroupDirective = _formGroupDirective;
|
|
297
163
|
this._cd = _cd;
|
|
298
|
-
this.path =
|
|
299
|
-
this.
|
|
164
|
+
this.path = null;
|
|
165
|
+
this._debounce = 100;
|
|
300
166
|
this._clearDestroy = false;
|
|
301
|
-
this._destroy$ = new Subject();
|
|
302
167
|
this._updating = false;
|
|
168
|
+
this._destroy$ = new Subject();
|
|
169
|
+
}
|
|
170
|
+
set debounce(debounce) {
|
|
171
|
+
this._debounce = Number(debounce);
|
|
172
|
+
}
|
|
173
|
+
get debounce() {
|
|
174
|
+
return this._debounce;
|
|
303
175
|
}
|
|
304
|
-
/**
|
|
305
|
-
* @param {?} val
|
|
306
|
-
* @return {?}
|
|
307
|
-
*/
|
|
308
176
|
set clearDestroy(val) {
|
|
309
177
|
this._clearDestroy = val != null && `${val}` !== 'false';
|
|
310
178
|
}
|
|
311
|
-
/**
|
|
312
|
-
* @return {?}
|
|
313
|
-
*/
|
|
314
179
|
get clearDestroy() {
|
|
315
180
|
return this._clearDestroy;
|
|
316
181
|
}
|
|
317
|
-
/**
|
|
318
|
-
* @return {?}
|
|
319
|
-
*/
|
|
320
182
|
ngOnInit() {
|
|
321
183
|
this._actions$
|
|
322
|
-
.pipe(ofActionDispatched(ResetForm), filter((
|
|
323
|
-
|
|
324
|
-
* @return {?}
|
|
325
|
-
*/
|
|
326
|
-
(action) => action.payload.path === this.path)), takeUntil(this._destroy$))
|
|
327
|
-
.subscribe((/**
|
|
328
|
-
* @param {?} __0
|
|
329
|
-
* @return {?}
|
|
330
|
-
*/
|
|
331
|
-
({ payload: { value } }) => {
|
|
184
|
+
.pipe(ofActionDispatched(ResetForm), filter((action) => action.payload.path === this.path), takeUntil(this._destroy$))
|
|
185
|
+
.subscribe(({ payload: { value } }) => {
|
|
332
186
|
this.form.reset(value);
|
|
333
187
|
this.updateFormStateWithRawValue(true);
|
|
334
188
|
this._cd.markForCheck();
|
|
335
|
-
})
|
|
336
|
-
this.getStateStream(`${this.path}.model`).subscribe(
|
|
337
|
-
* @param {?} model
|
|
338
|
-
* @return {?}
|
|
339
|
-
*/
|
|
340
|
-
model => {
|
|
189
|
+
});
|
|
190
|
+
this.getStateStream(`${this.path}.model`).subscribe(model => {
|
|
341
191
|
if (this._updating || !model) {
|
|
342
192
|
return;
|
|
343
193
|
}
|
|
344
194
|
this.form.patchValue(model);
|
|
345
195
|
this._cd.markForCheck();
|
|
346
|
-
})
|
|
347
|
-
this.getStateStream(`${this.path}.dirty`).subscribe(
|
|
348
|
-
* @param {?} dirty
|
|
349
|
-
* @return {?}
|
|
350
|
-
*/
|
|
351
|
-
dirty => {
|
|
196
|
+
});
|
|
197
|
+
this.getStateStream(`${this.path}.dirty`).subscribe(dirty => {
|
|
352
198
|
if (this.form.dirty === dirty || typeof dirty !== 'boolean') {
|
|
353
199
|
return;
|
|
354
200
|
}
|
|
@@ -359,18 +205,11 @@ class FormDirective {
|
|
|
359
205
|
this.form.markAsPristine();
|
|
360
206
|
}
|
|
361
207
|
this._cd.markForCheck();
|
|
362
|
-
})
|
|
208
|
+
});
|
|
363
209
|
// On first state change, sync form model, status and dirty with state
|
|
364
210
|
this._store
|
|
365
|
-
.selectOnce((
|
|
366
|
-
|
|
367
|
-
* @return {?}
|
|
368
|
-
*/
|
|
369
|
-
state => getValue(state, this.path)))
|
|
370
|
-
.subscribe((/**
|
|
371
|
-
* @return {?}
|
|
372
|
-
*/
|
|
373
|
-
() => {
|
|
211
|
+
.selectOnce(state => getValue(state, this.path))
|
|
212
|
+
.subscribe(() => {
|
|
374
213
|
this._store.dispatch([
|
|
375
214
|
new UpdateFormValue({
|
|
376
215
|
path: this.path,
|
|
@@ -385,12 +224,8 @@ class FormDirective {
|
|
|
385
224
|
dirty: this.form.dirty
|
|
386
225
|
})
|
|
387
226
|
]);
|
|
388
|
-
})
|
|
389
|
-
this.getStateStream(`${this.path}.disabled`).subscribe(
|
|
390
|
-
* @param {?} disabled
|
|
391
|
-
* @return {?}
|
|
392
|
-
*/
|
|
393
|
-
disabled => {
|
|
227
|
+
});
|
|
228
|
+
this.getStateStream(`${this.path}.disabled`).subscribe(disabled => {
|
|
394
229
|
if (this.form.disabled === disabled || typeof disabled !== 'boolean') {
|
|
395
230
|
return;
|
|
396
231
|
}
|
|
@@ -401,43 +236,25 @@ class FormDirective {
|
|
|
401
236
|
this.form.enable();
|
|
402
237
|
}
|
|
403
238
|
this._cd.markForCheck();
|
|
404
|
-
})
|
|
405
|
-
|
|
406
|
-
.valueChanges
|
|
407
|
-
|
|
408
|
-
* @param {?} b
|
|
409
|
-
* @return {?}
|
|
410
|
-
*/
|
|
411
|
-
(a, b) => JSON.stringify(a) === JSON.stringify(b))), this.debounceChange())
|
|
412
|
-
.subscribe((/**
|
|
413
|
-
* @return {?}
|
|
414
|
-
*/
|
|
415
|
-
() => {
|
|
239
|
+
});
|
|
240
|
+
this._formGroupDirective
|
|
241
|
+
.valueChanges.pipe(distinctUntilChanged((a, b) => JSON.stringify(a) === JSON.stringify(b)), this.debounceChange())
|
|
242
|
+
.subscribe(() => {
|
|
416
243
|
this.updateFormStateWithRawValue();
|
|
417
|
-
})
|
|
418
|
-
|
|
419
|
-
.statusChanges
|
|
420
|
-
.subscribe((
|
|
421
|
-
* @param {?} status
|
|
422
|
-
* @return {?}
|
|
423
|
-
*/
|
|
424
|
-
(status) => {
|
|
244
|
+
});
|
|
245
|
+
this._formGroupDirective
|
|
246
|
+
.statusChanges.pipe(distinctUntilChanged(), this.debounceChange())
|
|
247
|
+
.subscribe((status) => {
|
|
425
248
|
this._store.dispatch(new UpdateFormStatus({
|
|
426
249
|
status,
|
|
427
250
|
path: this.path
|
|
428
251
|
}));
|
|
429
|
-
})
|
|
252
|
+
});
|
|
430
253
|
}
|
|
431
|
-
/**
|
|
432
|
-
* @param {?=} withFormStatus
|
|
433
|
-
* @return {?}
|
|
434
|
-
*/
|
|
435
254
|
updateFormStateWithRawValue(withFormStatus) {
|
|
436
255
|
if (this._updating)
|
|
437
256
|
return;
|
|
438
|
-
/** @type {?} */
|
|
439
257
|
const value = this._formGroupDirective.control.getRawValue();
|
|
440
|
-
/** @type {?} */
|
|
441
258
|
const actions = [
|
|
442
259
|
new UpdateFormValue({
|
|
443
260
|
path: this.path,
|
|
@@ -460,22 +277,12 @@ class FormDirective {
|
|
|
460
277
|
}
|
|
461
278
|
this._updating = true;
|
|
462
279
|
this._store.dispatch(actions).subscribe({
|
|
463
|
-
error: (
|
|
464
|
-
|
|
465
|
-
*/
|
|
466
|
-
() => (this._updating = false)),
|
|
467
|
-
complete: (/**
|
|
468
|
-
* @return {?}
|
|
469
|
-
*/
|
|
470
|
-
() => (this._updating = false))
|
|
280
|
+
error: () => (this._updating = false),
|
|
281
|
+
complete: () => (this._updating = false)
|
|
471
282
|
});
|
|
472
283
|
}
|
|
473
|
-
/**
|
|
474
|
-
* @return {?}
|
|
475
|
-
*/
|
|
476
284
|
ngOnDestroy() {
|
|
477
285
|
this._destroy$.next();
|
|
478
|
-
this._destroy$.complete();
|
|
479
286
|
if (this.clearDestroy) {
|
|
480
287
|
this._store.dispatch(new UpdateForm({
|
|
481
288
|
path: this.path,
|
|
@@ -486,107 +293,36 @@ class FormDirective {
|
|
|
486
293
|
}));
|
|
487
294
|
}
|
|
488
295
|
}
|
|
489
|
-
/**
|
|
490
|
-
* @private
|
|
491
|
-
* @return {?}
|
|
492
|
-
*/
|
|
493
296
|
debounceChange() {
|
|
494
|
-
|
|
495
|
-
const skipDebounceTime = this._formGroupDirective.control.updateOn !== 'change' || this.debounce < 0;
|
|
297
|
+
const skipDebounceTime = this._formGroupDirective.control.updateOn !== 'change' || this._debounce < 0;
|
|
496
298
|
return skipDebounceTime
|
|
497
|
-
? (
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
*/
|
|
501
|
-
(change) => change.pipe(takeUntil(this._destroy$)))
|
|
502
|
-
: (/**
|
|
503
|
-
* @param {?} change
|
|
504
|
-
* @return {?}
|
|
505
|
-
*/
|
|
506
|
-
(change) => change.pipe(debounceTime(this.debounce), takeUntil(this._destroy$)));
|
|
507
|
-
}
|
|
508
|
-
/**
|
|
509
|
-
* @private
|
|
510
|
-
* @return {?}
|
|
511
|
-
*/
|
|
299
|
+
? (change) => change.pipe(takeUntil(this._destroy$))
|
|
300
|
+
: (change) => change.pipe(debounceTime(this._debounce), takeUntil(this._destroy$));
|
|
301
|
+
}
|
|
512
302
|
get form() {
|
|
513
303
|
return this._formGroupDirective.form;
|
|
514
304
|
}
|
|
515
|
-
/**
|
|
516
|
-
* @private
|
|
517
|
-
* @param {?} path
|
|
518
|
-
* @return {?}
|
|
519
|
-
*/
|
|
520
305
|
getStateStream(path) {
|
|
521
|
-
return this._store.select((
|
|
522
|
-
* @param {?} state
|
|
523
|
-
* @return {?}
|
|
524
|
-
*/
|
|
525
|
-
state => getValue(state, path))).pipe(takeUntil(this._destroy$));
|
|
306
|
+
return this._store.select(state => getValue(state, path)).pipe(takeUntil(this._destroy$));
|
|
526
307
|
}
|
|
527
308
|
}
|
|
528
|
-
FormDirective
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
};
|
|
543
|
-
if (false) {
|
|
544
|
-
/** @type {?} */
|
|
545
|
-
FormDirective.prototype.path;
|
|
546
|
-
/** @type {?} */
|
|
547
|
-
FormDirective.prototype.debounce;
|
|
548
|
-
/** @type {?} */
|
|
549
|
-
FormDirective.prototype._clearDestroy;
|
|
550
|
-
/**
|
|
551
|
-
* @type {?}
|
|
552
|
-
* @private
|
|
553
|
-
*/
|
|
554
|
-
FormDirective.prototype._destroy$;
|
|
555
|
-
/**
|
|
556
|
-
* @type {?}
|
|
557
|
-
* @private
|
|
558
|
-
*/
|
|
559
|
-
FormDirective.prototype._updating;
|
|
560
|
-
/**
|
|
561
|
-
* @type {?}
|
|
562
|
-
* @private
|
|
563
|
-
*/
|
|
564
|
-
FormDirective.prototype._actions$;
|
|
565
|
-
/**
|
|
566
|
-
* @type {?}
|
|
567
|
-
* @private
|
|
568
|
-
*/
|
|
569
|
-
FormDirective.prototype._store;
|
|
570
|
-
/**
|
|
571
|
-
* @type {?}
|
|
572
|
-
* @private
|
|
573
|
-
*/
|
|
574
|
-
FormDirective.prototype._formGroupDirective;
|
|
575
|
-
/**
|
|
576
|
-
* @type {?}
|
|
577
|
-
* @private
|
|
578
|
-
*/
|
|
579
|
-
FormDirective.prototype._cd;
|
|
580
|
-
}
|
|
309
|
+
/** @nocollapse */ FormDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: FormDirective, deps: [{ token: i1.Actions }, { token: i1.Store }, { token: i2.FormGroupDirective }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
310
|
+
/** @nocollapse */ FormDirective.ɵdir = i0.ɵɵ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 });
|
|
311
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: FormDirective, decorators: [{
|
|
312
|
+
type: Directive,
|
|
313
|
+
args: [{ selector: '[ngxsForm]' }]
|
|
314
|
+
}], ctorParameters: function () { return [{ type: i1.Actions }, { type: i1.Store }, { type: i2.FormGroupDirective }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { path: [{
|
|
315
|
+
type: Input,
|
|
316
|
+
args: ['ngxsForm']
|
|
317
|
+
}], debounce: [{
|
|
318
|
+
type: Input,
|
|
319
|
+
args: ['ngxsFormDebounce']
|
|
320
|
+
}], clearDestroy: [{
|
|
321
|
+
type: Input,
|
|
322
|
+
args: ['ngxsFormClearOnDestroy']
|
|
323
|
+
}] } });
|
|
581
324
|
|
|
582
|
-
/**
|
|
583
|
-
* @fileoverview added by tsickle
|
|
584
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
585
|
-
*/
|
|
586
325
|
class NgxsFormPluginModule {
|
|
587
|
-
/**
|
|
588
|
-
* @return {?}
|
|
589
|
-
*/
|
|
590
326
|
static forRoot() {
|
|
591
327
|
return {
|
|
592
328
|
ngModule: NgxsFormPluginModule,
|
|
@@ -600,28 +336,25 @@ class NgxsFormPluginModule {
|
|
|
600
336
|
};
|
|
601
337
|
}
|
|
602
338
|
}
|
|
603
|
-
NgxsFormPluginModule
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
]
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
*/
|
|
339
|
+
/** @nocollapse */ NgxsFormPluginModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsFormPluginModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
340
|
+
/** @nocollapse */ NgxsFormPluginModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsFormPluginModule, declarations: [FormDirective], imports: [ReactiveFormsModule], exports: [FormDirective] });
|
|
341
|
+
/** @nocollapse */ NgxsFormPluginModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsFormPluginModule, imports: [[ReactiveFormsModule]] });
|
|
342
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: NgxsFormPluginModule, decorators: [{
|
|
343
|
+
type: NgModule,
|
|
344
|
+
args: [{
|
|
345
|
+
imports: [ReactiveFormsModule],
|
|
346
|
+
declarations: [FormDirective],
|
|
347
|
+
exports: [FormDirective]
|
|
348
|
+
}]
|
|
349
|
+
}] });
|
|
615
350
|
|
|
616
351
|
/**
|
|
617
|
-
*
|
|
618
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
352
|
+
* The public api for consumers of @ngxs/form-plugin
|
|
619
353
|
*/
|
|
620
354
|
|
|
621
355
|
/**
|
|
622
|
-
*
|
|
623
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
356
|
+
* Generated bundle index. Do not edit.
|
|
624
357
|
*/
|
|
625
358
|
|
|
626
|
-
export { NgxsFormPlugin, NgxsFormPluginModule, ResetForm, SetFormDirty, SetFormDisabled, SetFormEnabled, SetFormPristine, UpdateForm, UpdateFormDirty, UpdateFormErrors, UpdateFormStatus, UpdateFormValue, FormDirective as
|
|
359
|
+
export { NgxsFormPlugin, NgxsFormPluginModule, ResetForm, SetFormDirty, SetFormDisabled, SetFormEnabled, SetFormPristine, UpdateForm, UpdateFormDirty, UpdateFormErrors, UpdateFormStatus, UpdateFormValue, FormDirective as ɵFormDirective };
|
|
627
360
|
//# sourceMappingURL=ngxs-form-plugin.js.map
|