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