@ngxs/form-plugin 3.7.4 → 3.7.5
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 +665 -658
- package/bundles/ngxs-form-plugin.umd.js.map +1 -1
- package/bundles/ngxs-form-plugin.umd.min.js +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 +306 -299
- package/esm2015/src/form.module.js +34 -34
- package/esm2015/src/form.plugin.js +83 -83
- 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 +335 -328
- package/esm5/src/form.module.js +41 -41
- package/esm5/src/form.plugin.js +100 -100
- package/esm5/src/public_api.js +8 -8
- package/fesm2015/ngxs-form-plugin.js +605 -598
- package/fesm2015/ngxs-form-plugin.js.map +1 -1
- package/fesm5/ngxs-form-plugin.js +674 -667
- 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 +2 -2
- 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,616 +4,623 @@ 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)
|
|
222
|
-
? value.slice()
|
|
223
|
-
: isObjectLike(value)
|
|
224
|
-
? Object.assign({}, value) : value;
|
|
225
|
-
/** @type {?} */
|
|
226
|
-
const path = this.joinPathWithPropertyPath(event);
|
|
227
|
-
nextState = setValue(nextState, path, payloadValue);
|
|
228
|
-
}
|
|
229
|
-
if (type === ResetForm.type) {
|
|
230
|
-
/** @type {?} */
|
|
231
|
-
const model = getValue(nextState, `${event.payload.path}.model`);
|
|
232
|
-
nextState = setValue(nextState, `${event.payload.path}`, { model: model });
|
|
233
|
-
}
|
|
234
|
-
if (type === UpdateFormStatus.type || type === UpdateForm.type) {
|
|
235
|
-
nextState = setValue(nextState, `${event.payload.path}.status`, event.payload.status);
|
|
236
|
-
}
|
|
237
|
-
if (type === UpdateFormErrors.type || type === UpdateForm.type) {
|
|
238
|
-
nextState = setValue(nextState, `${event.payload.path}.errors`, Object.assign({}, event.payload.errors));
|
|
239
|
-
}
|
|
240
|
-
if (type === UpdateFormDirty.type || type === UpdateForm.type) {
|
|
241
|
-
nextState = setValue(nextState, `${event.payload.path}.dirty`, event.payload.dirty);
|
|
242
|
-
}
|
|
243
|
-
if (type === SetFormDirty.type) {
|
|
244
|
-
nextState = setValue(nextState, `${event.payload}.dirty`, true);
|
|
245
|
-
}
|
|
246
|
-
if (type === SetFormPristine.type) {
|
|
247
|
-
nextState = setValue(nextState, `${event.payload}.dirty`, false);
|
|
248
|
-
}
|
|
249
|
-
if (type === SetFormDisabled.type) {
|
|
250
|
-
nextState = setValue(nextState, `${event.payload}.disabled`, true);
|
|
251
|
-
}
|
|
252
|
-
if (type === SetFormEnabled.type) {
|
|
253
|
-
nextState = setValue(nextState, `${event.payload}.disabled`, false);
|
|
254
|
-
}
|
|
255
|
-
return next(nextState, event);
|
|
256
|
-
}
|
|
257
|
-
/**
|
|
258
|
-
* @private
|
|
259
|
-
* @param {?} __0
|
|
260
|
-
* @return {?}
|
|
261
|
-
*/
|
|
262
|
-
joinPathWithPropertyPath({ payload }) {
|
|
263
|
-
/** @type {?} */
|
|
264
|
-
let path = `${payload.path}.model`;
|
|
265
|
-
if (payload.propertyPath) {
|
|
266
|
-
path += `.${payload.propertyPath}`;
|
|
267
|
-
}
|
|
268
|
-
return path;
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
NgxsFormPlugin.decorators = [
|
|
272
|
-
{ type: Injectable }
|
|
273
|
-
];
|
|
274
|
-
/**
|
|
275
|
-
* @param {?} target
|
|
276
|
-
* @return {?}
|
|
277
|
-
*/
|
|
278
|
-
function isObjectLike(target) {
|
|
279
|
-
return target !== null && typeof target === 'object';
|
|
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)
|
|
222
|
+
? value.slice()
|
|
223
|
+
: isObjectLike(value)
|
|
224
|
+
? Object.assign({}, value) : value;
|
|
225
|
+
/** @type {?} */
|
|
226
|
+
const path = this.joinPathWithPropertyPath(event);
|
|
227
|
+
nextState = setValue(nextState, path, payloadValue);
|
|
228
|
+
}
|
|
229
|
+
if (type === ResetForm.type) {
|
|
230
|
+
/** @type {?} */
|
|
231
|
+
const model = getValue(nextState, `${event.payload.path}.model`);
|
|
232
|
+
nextState = setValue(nextState, `${event.payload.path}`, { model: model });
|
|
233
|
+
}
|
|
234
|
+
if (type === UpdateFormStatus.type || type === UpdateForm.type) {
|
|
235
|
+
nextState = setValue(nextState, `${event.payload.path}.status`, event.payload.status);
|
|
236
|
+
}
|
|
237
|
+
if (type === UpdateFormErrors.type || type === UpdateForm.type) {
|
|
238
|
+
nextState = setValue(nextState, `${event.payload.path}.errors`, Object.assign({}, event.payload.errors));
|
|
239
|
+
}
|
|
240
|
+
if (type === UpdateFormDirty.type || type === UpdateForm.type) {
|
|
241
|
+
nextState = setValue(nextState, `${event.payload.path}.dirty`, event.payload.dirty);
|
|
242
|
+
}
|
|
243
|
+
if (type === SetFormDirty.type) {
|
|
244
|
+
nextState = setValue(nextState, `${event.payload}.dirty`, true);
|
|
245
|
+
}
|
|
246
|
+
if (type === SetFormPristine.type) {
|
|
247
|
+
nextState = setValue(nextState, `${event.payload}.dirty`, false);
|
|
248
|
+
}
|
|
249
|
+
if (type === SetFormDisabled.type) {
|
|
250
|
+
nextState = setValue(nextState, `${event.payload}.disabled`, true);
|
|
251
|
+
}
|
|
252
|
+
if (type === SetFormEnabled.type) {
|
|
253
|
+
nextState = setValue(nextState, `${event.payload}.disabled`, false);
|
|
254
|
+
}
|
|
255
|
+
return next(nextState, event);
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* @private
|
|
259
|
+
* @param {?} __0
|
|
260
|
+
* @return {?}
|
|
261
|
+
*/
|
|
262
|
+
joinPathWithPropertyPath({ payload }) {
|
|
263
|
+
/** @type {?} */
|
|
264
|
+
let path = `${payload.path}.model`;
|
|
265
|
+
if (payload.propertyPath) {
|
|
266
|
+
path += `.${payload.propertyPath}`;
|
|
267
|
+
}
|
|
268
|
+
return path;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
NgxsFormPlugin.decorators = [
|
|
272
|
+
{ type: Injectable }
|
|
273
|
+
];
|
|
274
|
+
/**
|
|
275
|
+
* @param {?} target
|
|
276
|
+
* @return {?}
|
|
277
|
+
*/
|
|
278
|
+
function isObjectLike(target) {
|
|
279
|
+
return target !== null && typeof target === 'object';
|
|
280
280
|
}
|
|
281
281
|
|
|
282
|
-
/**
|
|
283
|
-
* @fileoverview added by tsickle
|
|
284
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
285
|
-
*/
|
|
286
|
-
class FormDirective {
|
|
287
|
-
/**
|
|
288
|
-
* @param {?} _actions$
|
|
289
|
-
* @param {?} _store
|
|
290
|
-
* @param {?} _formGroupDirective
|
|
291
|
-
* @param {?} _cd
|
|
292
|
-
*/
|
|
293
|
-
constructor(_actions$, _store, _formGroupDirective, _cd) {
|
|
294
|
-
this._actions$ = _actions$;
|
|
295
|
-
this._store = _store;
|
|
296
|
-
this._formGroupDirective = _formGroupDirective;
|
|
297
|
-
this._cd = _cd;
|
|
298
|
-
this.path = (/** @type {?} */ (null));
|
|
299
|
-
this.debounce = 100;
|
|
300
|
-
this._clearDestroy = false;
|
|
301
|
-
this._destroy$ = new Subject();
|
|
302
|
-
this._updating = false;
|
|
303
|
-
}
|
|
304
|
-
/**
|
|
305
|
-
* @param {?} val
|
|
306
|
-
* @return {?}
|
|
307
|
-
*/
|
|
308
|
-
set clearDestroy(val) {
|
|
309
|
-
this._clearDestroy = val != null && `${val}` !== 'false';
|
|
310
|
-
}
|
|
311
|
-
/**
|
|
312
|
-
* @return {?}
|
|
313
|
-
*/
|
|
314
|
-
get clearDestroy() {
|
|
315
|
-
return this._clearDestroy;
|
|
316
|
-
}
|
|
317
|
-
/**
|
|
318
|
-
* @return {?}
|
|
319
|
-
*/
|
|
320
|
-
ngOnInit() {
|
|
321
|
-
this._actions$
|
|
322
|
-
.pipe(ofActionDispatched(ResetForm), filter((/**
|
|
323
|
-
* @param {?} action
|
|
324
|
-
* @return {?}
|
|
325
|
-
*/
|
|
326
|
-
(action) => action.payload.path === this.path)), takeUntil(this._destroy$))
|
|
327
|
-
.subscribe((/**
|
|
328
|
-
* @param {?} __0
|
|
329
|
-
* @return {?}
|
|
330
|
-
*/
|
|
331
|
-
({ payload: { value } }) => {
|
|
332
|
-
this.form.reset(value);
|
|
333
|
-
this.updateFormStateWithRawValue(true);
|
|
334
|
-
this._cd.markForCheck();
|
|
335
|
-
}));
|
|
336
|
-
this.getStateStream(`${this.path}.model`).subscribe((/**
|
|
337
|
-
* @param {?} model
|
|
338
|
-
* @return {?}
|
|
339
|
-
*/
|
|
340
|
-
model => {
|
|
341
|
-
if (this._updating || !model) {
|
|
342
|
-
return;
|
|
343
|
-
}
|
|
344
|
-
this.form.patchValue(model);
|
|
345
|
-
this._cd.markForCheck();
|
|
346
|
-
}));
|
|
347
|
-
this.getStateStream(`${this.path}.dirty`).subscribe((/**
|
|
348
|
-
* @param {?} dirty
|
|
349
|
-
* @return {?}
|
|
350
|
-
*/
|
|
351
|
-
dirty => {
|
|
352
|
-
if (this.form.dirty === dirty || typeof dirty !== 'boolean') {
|
|
353
|
-
return;
|
|
354
|
-
}
|
|
355
|
-
if (dirty) {
|
|
356
|
-
this.form.markAsDirty();
|
|
357
|
-
}
|
|
358
|
-
else {
|
|
359
|
-
this.form.markAsPristine();
|
|
360
|
-
}
|
|
361
|
-
this._cd.markForCheck();
|
|
362
|
-
}));
|
|
363
|
-
// On first state change, sync form model, status and dirty with state
|
|
364
|
-
this._store
|
|
365
|
-
.selectOnce((/**
|
|
366
|
-
* @param {?} state
|
|
367
|
-
* @return {?}
|
|
368
|
-
*/
|
|
369
|
-
state => getValue(state, this.path)))
|
|
370
|
-
.subscribe((/**
|
|
371
|
-
* @return {?}
|
|
372
|
-
*/
|
|
373
|
-
() => {
|
|
374
|
-
this._store.dispatch([
|
|
375
|
-
new UpdateFormValue({
|
|
376
|
-
path: this.path,
|
|
377
|
-
value: this.form.getRawValue()
|
|
378
|
-
}),
|
|
379
|
-
new UpdateFormStatus({
|
|
380
|
-
path: this.path,
|
|
381
|
-
status: this.form.status
|
|
382
|
-
}),
|
|
383
|
-
new UpdateFormDirty({
|
|
384
|
-
path: this.path,
|
|
385
|
-
dirty: this.form.dirty
|
|
386
|
-
})
|
|
387
|
-
]);
|
|
388
|
-
}));
|
|
389
|
-
this.getStateStream(`${this.path}.disabled`).subscribe((/**
|
|
390
|
-
* @param {?} disabled
|
|
391
|
-
* @return {?}
|
|
392
|
-
*/
|
|
393
|
-
disabled => {
|
|
394
|
-
if (this.form.disabled === disabled || typeof disabled !== 'boolean') {
|
|
395
|
-
return;
|
|
396
|
-
}
|
|
397
|
-
if (disabled) {
|
|
398
|
-
this.form.disable();
|
|
399
|
-
}
|
|
400
|
-
else {
|
|
401
|
-
this.form.enable();
|
|
402
|
-
}
|
|
403
|
-
this._cd.markForCheck();
|
|
404
|
-
}));
|
|
405
|
-
(/** @type {?} */ (this._formGroupDirective
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
(
|
|
412
|
-
.
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
}
|
|
508
|
-
/**
|
|
509
|
-
* @private
|
|
510
|
-
* @
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
{ type:
|
|
530
|
-
];
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
FormDirective.prototype.
|
|
548
|
-
/**
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
282
|
+
/**
|
|
283
|
+
* @fileoverview added by tsickle
|
|
284
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
285
|
+
*/
|
|
286
|
+
class FormDirective {
|
|
287
|
+
/**
|
|
288
|
+
* @param {?} _actions$
|
|
289
|
+
* @param {?} _store
|
|
290
|
+
* @param {?} _formGroupDirective
|
|
291
|
+
* @param {?} _cd
|
|
292
|
+
*/
|
|
293
|
+
constructor(_actions$, _store, _formGroupDirective, _cd) {
|
|
294
|
+
this._actions$ = _actions$;
|
|
295
|
+
this._store = _store;
|
|
296
|
+
this._formGroupDirective = _formGroupDirective;
|
|
297
|
+
this._cd = _cd;
|
|
298
|
+
this.path = (/** @type {?} */ (null));
|
|
299
|
+
this.debounce = 100;
|
|
300
|
+
this._clearDestroy = false;
|
|
301
|
+
this._destroy$ = new Subject();
|
|
302
|
+
this._updating = false;
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* @param {?} val
|
|
306
|
+
* @return {?}
|
|
307
|
+
*/
|
|
308
|
+
set clearDestroy(val) {
|
|
309
|
+
this._clearDestroy = val != null && `${val}` !== 'false';
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* @return {?}
|
|
313
|
+
*/
|
|
314
|
+
get clearDestroy() {
|
|
315
|
+
return this._clearDestroy;
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* @return {?}
|
|
319
|
+
*/
|
|
320
|
+
ngOnInit() {
|
|
321
|
+
this._actions$
|
|
322
|
+
.pipe(ofActionDispatched(ResetForm), filter((/**
|
|
323
|
+
* @param {?} action
|
|
324
|
+
* @return {?}
|
|
325
|
+
*/
|
|
326
|
+
(action) => action.payload.path === this.path)), takeUntil(this._destroy$))
|
|
327
|
+
.subscribe((/**
|
|
328
|
+
* @param {?} __0
|
|
329
|
+
* @return {?}
|
|
330
|
+
*/
|
|
331
|
+
({ payload: { value } }) => {
|
|
332
|
+
this.form.reset(value);
|
|
333
|
+
this.updateFormStateWithRawValue(true);
|
|
334
|
+
this._cd.markForCheck();
|
|
335
|
+
}));
|
|
336
|
+
this.getStateStream(`${this.path}.model`).subscribe((/**
|
|
337
|
+
* @param {?} model
|
|
338
|
+
* @return {?}
|
|
339
|
+
*/
|
|
340
|
+
model => {
|
|
341
|
+
if (this._updating || !model) {
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
this.form.patchValue(model);
|
|
345
|
+
this._cd.markForCheck();
|
|
346
|
+
}));
|
|
347
|
+
this.getStateStream(`${this.path}.dirty`).subscribe((/**
|
|
348
|
+
* @param {?} dirty
|
|
349
|
+
* @return {?}
|
|
350
|
+
*/
|
|
351
|
+
dirty => {
|
|
352
|
+
if (this.form.dirty === dirty || typeof dirty !== 'boolean') {
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
if (dirty) {
|
|
356
|
+
this.form.markAsDirty();
|
|
357
|
+
}
|
|
358
|
+
else {
|
|
359
|
+
this.form.markAsPristine();
|
|
360
|
+
}
|
|
361
|
+
this._cd.markForCheck();
|
|
362
|
+
}));
|
|
363
|
+
// On first state change, sync form model, status and dirty with state
|
|
364
|
+
this._store
|
|
365
|
+
.selectOnce((/**
|
|
366
|
+
* @param {?} state
|
|
367
|
+
* @return {?}
|
|
368
|
+
*/
|
|
369
|
+
state => getValue(state, this.path)))
|
|
370
|
+
.subscribe((/**
|
|
371
|
+
* @return {?}
|
|
372
|
+
*/
|
|
373
|
+
() => {
|
|
374
|
+
this._store.dispatch([
|
|
375
|
+
new UpdateFormValue({
|
|
376
|
+
path: this.path,
|
|
377
|
+
value: this.form.getRawValue()
|
|
378
|
+
}),
|
|
379
|
+
new UpdateFormStatus({
|
|
380
|
+
path: this.path,
|
|
381
|
+
status: this.form.status
|
|
382
|
+
}),
|
|
383
|
+
new UpdateFormDirty({
|
|
384
|
+
path: this.path,
|
|
385
|
+
dirty: this.form.dirty
|
|
386
|
+
})
|
|
387
|
+
]);
|
|
388
|
+
}));
|
|
389
|
+
this.getStateStream(`${this.path}.disabled`).subscribe((/**
|
|
390
|
+
* @param {?} disabled
|
|
391
|
+
* @return {?}
|
|
392
|
+
*/
|
|
393
|
+
disabled => {
|
|
394
|
+
if (this.form.disabled === disabled || typeof disabled !== 'boolean') {
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
if (disabled) {
|
|
398
|
+
this.form.disable();
|
|
399
|
+
}
|
|
400
|
+
else {
|
|
401
|
+
this.form.enable();
|
|
402
|
+
}
|
|
403
|
+
this._cd.markForCheck();
|
|
404
|
+
}));
|
|
405
|
+
(/** @type {?} */ (this._formGroupDirective
|
|
406
|
+
.valueChanges)).pipe(distinctUntilChanged((/**
|
|
407
|
+
* @param {?} a
|
|
408
|
+
* @param {?} b
|
|
409
|
+
* @return {?}
|
|
410
|
+
*/
|
|
411
|
+
(a, b) => JSON.stringify(a) === JSON.stringify(b))), this.debounceChange())
|
|
412
|
+
.subscribe((/**
|
|
413
|
+
* @return {?}
|
|
414
|
+
*/
|
|
415
|
+
() => {
|
|
416
|
+
this.updateFormStateWithRawValue();
|
|
417
|
+
}));
|
|
418
|
+
(/** @type {?} */ (this._formGroupDirective
|
|
419
|
+
.statusChanges)).pipe(distinctUntilChanged(), this.debounceChange())
|
|
420
|
+
.subscribe((/**
|
|
421
|
+
* @param {?} status
|
|
422
|
+
* @return {?}
|
|
423
|
+
*/
|
|
424
|
+
(status) => {
|
|
425
|
+
this._store.dispatch(new UpdateFormStatus({
|
|
426
|
+
status,
|
|
427
|
+
path: this.path
|
|
428
|
+
}));
|
|
429
|
+
}));
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* @param {?=} withFormStatus
|
|
433
|
+
* @return {?}
|
|
434
|
+
*/
|
|
435
|
+
updateFormStateWithRawValue(withFormStatus) {
|
|
436
|
+
if (this._updating)
|
|
437
|
+
return;
|
|
438
|
+
/** @type {?} */
|
|
439
|
+
const value = this._formGroupDirective.control.getRawValue();
|
|
440
|
+
/** @type {?} */
|
|
441
|
+
const actions = [
|
|
442
|
+
new UpdateFormValue({
|
|
443
|
+
path: this.path,
|
|
444
|
+
value
|
|
445
|
+
}),
|
|
446
|
+
new UpdateFormDirty({
|
|
447
|
+
path: this.path,
|
|
448
|
+
dirty: this._formGroupDirective.dirty
|
|
449
|
+
}),
|
|
450
|
+
new UpdateFormErrors({
|
|
451
|
+
path: this.path,
|
|
452
|
+
errors: this._formGroupDirective.errors
|
|
453
|
+
})
|
|
454
|
+
];
|
|
455
|
+
if (withFormStatus) {
|
|
456
|
+
actions.push(new UpdateFormStatus({
|
|
457
|
+
path: this.path,
|
|
458
|
+
status: this._formGroupDirective.status
|
|
459
|
+
}));
|
|
460
|
+
}
|
|
461
|
+
this._updating = true;
|
|
462
|
+
this._store.dispatch(actions).subscribe({
|
|
463
|
+
error: (/**
|
|
464
|
+
* @return {?}
|
|
465
|
+
*/
|
|
466
|
+
() => (this._updating = false)),
|
|
467
|
+
complete: (/**
|
|
468
|
+
* @return {?}
|
|
469
|
+
*/
|
|
470
|
+
() => (this._updating = false))
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* @return {?}
|
|
475
|
+
*/
|
|
476
|
+
ngOnDestroy() {
|
|
477
|
+
this._destroy$.next();
|
|
478
|
+
this._destroy$.complete();
|
|
479
|
+
if (this.clearDestroy) {
|
|
480
|
+
this._store.dispatch(new UpdateForm({
|
|
481
|
+
path: this.path,
|
|
482
|
+
value: null,
|
|
483
|
+
dirty: null,
|
|
484
|
+
status: null,
|
|
485
|
+
errors: null
|
|
486
|
+
}));
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* @private
|
|
491
|
+
* @return {?}
|
|
492
|
+
*/
|
|
493
|
+
debounceChange() {
|
|
494
|
+
/** @type {?} */
|
|
495
|
+
const skipDebounceTime = this._formGroupDirective.control.updateOn !== 'change' || this.debounce < 0;
|
|
496
|
+
return skipDebounceTime
|
|
497
|
+
? (/**
|
|
498
|
+
* @param {?} change
|
|
499
|
+
* @return {?}
|
|
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
|
+
*/
|
|
512
|
+
get form() {
|
|
513
|
+
return this._formGroupDirective.form;
|
|
514
|
+
}
|
|
515
|
+
/**
|
|
516
|
+
* @private
|
|
517
|
+
* @param {?} path
|
|
518
|
+
* @return {?}
|
|
519
|
+
*/
|
|
520
|
+
getStateStream(path) {
|
|
521
|
+
return this._store.select((/**
|
|
522
|
+
* @param {?} state
|
|
523
|
+
* @return {?}
|
|
524
|
+
*/
|
|
525
|
+
state => getValue(state, path))).pipe(takeUntil(this._destroy$));
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
FormDirective.decorators = [
|
|
529
|
+
{ type: Directive, args: [{ selector: '[ngxsForm]' },] }
|
|
530
|
+
];
|
|
531
|
+
/** @nocollapse */
|
|
532
|
+
FormDirective.ctorParameters = () => [
|
|
533
|
+
{ type: Actions },
|
|
534
|
+
{ type: Store },
|
|
535
|
+
{ type: FormGroupDirective },
|
|
536
|
+
{ type: ChangeDetectorRef }
|
|
537
|
+
];
|
|
538
|
+
FormDirective.propDecorators = {
|
|
539
|
+
path: [{ type: Input, args: ['ngxsForm',] }],
|
|
540
|
+
debounce: [{ type: Input, args: ['ngxsFormDebounce',] }],
|
|
541
|
+
clearDestroy: [{ type: Input, args: ['ngxsFormClearOnDestroy',] }]
|
|
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;
|
|
573
580
|
}
|
|
574
581
|
|
|
575
|
-
/**
|
|
576
|
-
* @fileoverview added by tsickle
|
|
577
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
578
|
-
*/
|
|
579
|
-
class NgxsFormPluginModule {
|
|
580
|
-
/**
|
|
581
|
-
* @return {?}
|
|
582
|
-
*/
|
|
583
|
-
static forRoot() {
|
|
584
|
-
return {
|
|
585
|
-
ngModule: NgxsFormPluginModule,
|
|
586
|
-
providers: [
|
|
587
|
-
{
|
|
588
|
-
provide: NGXS_PLUGINS,
|
|
589
|
-
useClass: NgxsFormPlugin,
|
|
590
|
-
multi: true
|
|
591
|
-
}
|
|
592
|
-
]
|
|
593
|
-
};
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
NgxsFormPluginModule.decorators = [
|
|
597
|
-
{ type: NgModule, args: [{
|
|
598
|
-
imports: [ReactiveFormsModule],
|
|
599
|
-
declarations: [FormDirective],
|
|
600
|
-
exports: [FormDirective]
|
|
601
|
-
},] }
|
|
582
|
+
/**
|
|
583
|
+
* @fileoverview added by tsickle
|
|
584
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
585
|
+
*/
|
|
586
|
+
class NgxsFormPluginModule {
|
|
587
|
+
/**
|
|
588
|
+
* @return {?}
|
|
589
|
+
*/
|
|
590
|
+
static forRoot() {
|
|
591
|
+
return {
|
|
592
|
+
ngModule: NgxsFormPluginModule,
|
|
593
|
+
providers: [
|
|
594
|
+
{
|
|
595
|
+
provide: NGXS_PLUGINS,
|
|
596
|
+
useClass: NgxsFormPlugin,
|
|
597
|
+
multi: true
|
|
598
|
+
}
|
|
599
|
+
]
|
|
600
|
+
};
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
NgxsFormPluginModule.decorators = [
|
|
604
|
+
{ type: NgModule, args: [{
|
|
605
|
+
imports: [ReactiveFormsModule],
|
|
606
|
+
declarations: [FormDirective],
|
|
607
|
+
exports: [FormDirective]
|
|
608
|
+
},] }
|
|
602
609
|
];
|
|
603
610
|
|
|
604
|
-
/**
|
|
605
|
-
* @fileoverview added by tsickle
|
|
606
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
611
|
+
/**
|
|
612
|
+
* @fileoverview added by tsickle
|
|
613
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
607
614
|
*/
|
|
608
615
|
|
|
609
|
-
/**
|
|
610
|
-
* @fileoverview added by tsickle
|
|
611
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
616
|
+
/**
|
|
617
|
+
* @fileoverview added by tsickle
|
|
618
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
612
619
|
*/
|
|
613
620
|
|
|
614
|
-
/**
|
|
615
|
-
* @fileoverview added by tsickle
|
|
616
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
621
|
+
/**
|
|
622
|
+
* @fileoverview added by tsickle
|
|
623
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
617
624
|
*/
|
|
618
625
|
|
|
619
626
|
export { NgxsFormPlugin, NgxsFormPluginModule, ResetForm, SetFormDirty, SetFormDisabled, SetFormEnabled, SetFormPristine, UpdateForm, UpdateFormDirty, UpdateFormErrors, UpdateFormStatus, UpdateFormValue, FormDirective as ɵa };
|