goodteditor-ui 1.0.15 → 1.0.16
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/package.json
CHANGED
|
@@ -197,25 +197,30 @@ export default {
|
|
|
197
197
|
readonly: this.readonly || !this.editable,
|
|
198
198
|
},
|
|
199
199
|
inputEvents: {
|
|
200
|
+
input: this.onInputInput,
|
|
200
201
|
change: this.onInputChange,
|
|
201
202
|
focus: this.onInputFocus,
|
|
202
203
|
blur: this.onInputBlur,
|
|
203
204
|
},
|
|
205
|
+
inputValue: '',
|
|
206
|
+
inputValueRaw: '',
|
|
204
207
|
};
|
|
205
208
|
},
|
|
206
209
|
watch: {
|
|
207
210
|
value: {
|
|
208
211
|
handler(val) {
|
|
212
|
+
this.inputValueRaw = val;
|
|
213
|
+
|
|
209
214
|
if (this.isRange) {
|
|
210
|
-
|
|
211
|
-
|
|
215
|
+
const d = Array.isArray(val) ? val.map(this.toDate) : [];
|
|
216
|
+
const [s, e] = d;
|
|
212
217
|
if (s && e && isDateValid(s) && isDateValid(e) && s < e) {
|
|
213
218
|
this.date = d;
|
|
214
219
|
} else {
|
|
215
220
|
this.date = [];
|
|
216
221
|
}
|
|
217
222
|
} else {
|
|
218
|
-
|
|
223
|
+
const d = this.toDate(val);
|
|
219
224
|
this.date = isDateValid(d) ? d : null;
|
|
220
225
|
}
|
|
221
226
|
},
|
|
@@ -256,47 +261,31 @@ export default {
|
|
|
256
261
|
let input = this.getInputRef();
|
|
257
262
|
input && input.focus();
|
|
258
263
|
},
|
|
264
|
+
onInputInput({ target }) {
|
|
265
|
+
this.inputValueRaw = target.value;
|
|
266
|
+
},
|
|
259
267
|
onInputChange(e) {
|
|
260
|
-
|
|
261
|
-
let data = null;
|
|
262
|
-
|
|
263
|
-
if (this.isRange) {
|
|
264
|
-
let d = val.split(this.delimiter).map(this.toDate);
|
|
265
|
-
let [s, e] = d;
|
|
266
|
-
data = isDateValid(s) && isDateValid(e) && s < e ? d.map(this.toValue) : [];
|
|
267
|
-
} else {
|
|
268
|
-
let d = this.toDate(val);
|
|
269
|
-
data = isDateValid(d) ? this.toValue(d) : '';
|
|
270
|
-
}
|
|
271
|
-
/**
|
|
272
|
-
* Input event
|
|
273
|
-
* @property {String|Array} value
|
|
274
|
-
*/
|
|
275
|
-
this.$emit('input', data);
|
|
276
|
-
/**
|
|
277
|
-
* Change event
|
|
278
|
-
* @property {String|Array} value
|
|
279
|
-
*/
|
|
280
|
-
this.$emit('change', data);
|
|
268
|
+
this.setDateFromString(e.target.value);
|
|
281
269
|
},
|
|
282
270
|
onInputFocus(e) {
|
|
283
271
|
this.rootHasFocus = true;
|
|
284
272
|
},
|
|
285
273
|
onInputBlur(e) {
|
|
286
274
|
this.rootHasFocus = false;
|
|
275
|
+
this.setDateFromString(this.inputValueRaw);
|
|
287
276
|
},
|
|
288
277
|
onDpChange(date) {
|
|
289
|
-
|
|
278
|
+
const model = Array.isArray(date) ? date.map(this.toValue) : this.toValue(date);
|
|
290
279
|
/**
|
|
291
280
|
* Input event
|
|
292
|
-
* @property {String}
|
|
281
|
+
* @property {String|Array} value
|
|
293
282
|
*/
|
|
294
|
-
this.$emit('input',
|
|
283
|
+
this.$emit('input', model);
|
|
295
284
|
/**
|
|
296
285
|
* Change event
|
|
297
|
-
* @property {String}
|
|
286
|
+
* @property {String|Array} value
|
|
298
287
|
*/
|
|
299
|
-
this.$emit('change',
|
|
288
|
+
this.$emit('change', model);
|
|
300
289
|
},
|
|
301
290
|
onDpSetDate(date) {
|
|
302
291
|
/**
|
|
@@ -305,6 +294,33 @@ export default {
|
|
|
305
294
|
*/
|
|
306
295
|
this.$emit('set-date', date);
|
|
307
296
|
},
|
|
297
|
+
setDateFromString(value) {
|
|
298
|
+
if (value == this.inputValue) {
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
this.inputValue = value;
|
|
302
|
+
|
|
303
|
+
let model = null;
|
|
304
|
+
|
|
305
|
+
if (this.isRange) {
|
|
306
|
+
const d = value.split(this.delimiter).map(this.toDate);
|
|
307
|
+
const [s, e] = d;
|
|
308
|
+
model = isDateValid(s) && isDateValid(e) && s < e ? d.map(this.toValue) : [];
|
|
309
|
+
} else {
|
|
310
|
+
const d = this.toDate(value);
|
|
311
|
+
model = isDateValid(d) ? this.toValue(d) : '';
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Input event
|
|
315
|
+
* @property {String|Array} value
|
|
316
|
+
*/
|
|
317
|
+
this.$emit('input', model);
|
|
318
|
+
/**
|
|
319
|
+
* Change event
|
|
320
|
+
* @property {String|Array} value
|
|
321
|
+
*/
|
|
322
|
+
this.$emit('change', model);
|
|
323
|
+
},
|
|
308
324
|
},
|
|
309
325
|
};
|
|
310
326
|
</script>
|