@kizmann/nano-ui 0.8.2 → 0.8.4

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kizmann/nano-ui",
3
- "version": "0.8.2",
3
+ "version": "0.8.4",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "author": "Eduard Kizmann <kizmann@protonmail.ch>",
@@ -186,7 +186,7 @@ export default {
186
186
  $scope: this.scope, $model: this.tempValue, $global: window
187
187
  };
188
188
 
189
- if ( Obj.get(sources, prop, -1337) === -1337 ) {
189
+ if ( ! Any.isNull(fallback) && Obj.get(sources, prop, -1337) === -1337 ) {
190
190
  Obj.set(sources, prop, fallback);
191
191
  }
192
192
 
@@ -61,6 +61,14 @@ export default {
61
61
  type: [Boolean]
62
62
  },
63
63
 
64
+ ignore: {
65
+ default()
66
+ {
67
+ return ['modified', 'dragid'];
68
+ },
69
+ type: [Boolean]
70
+ },
71
+
64
72
  forceChange: {
65
73
  default()
66
74
  {
@@ -93,6 +101,33 @@ export default {
93
101
 
94
102
  },
95
103
 
104
+ data()
105
+ {
106
+ return {
107
+ uid: UUID(), elements: [], blocked: true,
108
+ };
109
+ },
110
+
111
+ provide()
112
+ {
113
+ return {
114
+ NForm: this
115
+ };
116
+ },
117
+
118
+ mounted()
119
+ {
120
+ Any.delay(this.ctor('ready'), 500);
121
+ },
122
+
123
+ ready()
124
+ {
125
+ this.$watch('form', this.emitChange,
126
+ { deep: true });
127
+
128
+ this.resetChange();
129
+ },
130
+
96
131
  methods: {
97
132
 
98
133
  onSubmit(event)
@@ -123,36 +158,42 @@ export default {
123
158
  });
124
159
  },
125
160
 
126
- emitChange(form)
161
+ resetChange(timeout = 500)
127
162
  {
128
- this.$emit('change');
163
+ clearTimeout(this.timeout);
164
+
165
+ this.timeout = setTimeout(() => {
166
+ this.blocked = false;
167
+ }, timeout);
168
+
169
+ this.blocked = true;
170
+
171
+ let value = Obj.except(this.form,
172
+ this.ignore);
173
+
174
+ this.prevState = JSON.stringify(value);
129
175
  },
130
176
 
131
- },
177
+ emitChange()
178
+ {
179
+ if ( this.blocked ) {
180
+ return;
181
+ }
132
182
 
133
- data()
134
- {
135
- return {
136
- uid: UUID(),
137
- elements: []
138
- };
139
- },
183
+ let value = Obj.except(this.form,
184
+ this.ignore);
140
185
 
141
- provide()
142
- {
143
- return {
144
- NForm: this
145
- };
146
- },
186
+ let nextState = JSON.stringify(value);
147
187
 
148
- mounted()
149
- {
150
- Any.delay(this.ctor('ready'), 1000);
151
- },
188
+ if ( this.prevState == nextState ) {
189
+ return;
190
+ }
191
+
192
+ this.prevState = nextState;
193
+
194
+ this.$emit('change');
195
+ },
152
196
 
153
- ready()
154
- {
155
- this.$watch('form', Any.debounce(this.emitChange, 300), { deep: true });
156
197
  },
157
198
 
158
199
  render()