goodteditor-ui 1.0.15 → 1.0.17

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "goodteditor-ui",
3
- "version": "1.0.15",
3
+ "version": "1.0.17",
4
4
  "main": "index.js",
5
5
  "homepage": "https://goodt-ui.netlify.app/",
6
6
  "scripts": {
@@ -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
- let d = Array.isArray(val) ? val.map(this.toDate) : [];
211
- let [s, e] = d;
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
- let d = this.toDate(val);
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
- let val = e.target.value;
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
- let data = Array.isArray(date) ? date.map(this.toValue) : this.toValue(date);
278
+ const model = Array.isArray(date) ? date.map(this.toValue) : this.toValue(date);
290
279
  /**
291
280
  * Input event
292
- * @property {String} date
281
+ * @property {String|Array} value
293
282
  */
294
- this.$emit('input', data);
283
+ this.$emit('input', model);
295
284
  /**
296
285
  * Change event
297
- * @property {String} date
286
+ * @property {String|Array} value
298
287
  */
299
- this.$emit('change', data);
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>
@@ -10,7 +10,7 @@
10
10
  <div class="ui-select-label u-select-none">
11
11
  <template v-if="multiple">
12
12
  <template v-if="optionsSelected.length">
13
- <!--
13
+ <!--
14
14
  @slot Label slot for multiple mode
15
15
  @binding {Object} option option
16
16
  @binding {any} value option's value
@@ -41,7 +41,7 @@
41
41
  </slot>
42
42
  </template>
43
43
  <div class="ui-select-placeholder events-none" v-else>
44
- <!--
44
+ <!--
45
45
  @slot Placeholder slot
46
46
  -->
47
47
  <slot name="placeholder">
@@ -51,7 +51,7 @@
51
51
  </template>
52
52
 
53
53
  <template v-else>
54
- <!--
54
+ <!--
55
55
  @slot Label slot for single mode
56
56
  @binding {Object} option option
57
57
  @binding {any} value option's value
@@ -69,7 +69,7 @@
69
69
  {{ getOptionLabel(optionsSelected[0]) }}
70
70
  </slot>
71
71
  <div class="ui-select-placeholder events-none" v-else>
72
- <!--
72
+ <!--
73
73
  @slot Placeholder slot
74
74
  -->
75
75
  <slot name="placeholder">
@@ -78,7 +78,7 @@
78
78
  </div>
79
79
  </template>
80
80
  </div>
81
- <!--
81
+ <!--
82
82
  @slot Open state icon slot
83
83
  -->
84
84
  <slot name="icon-open" v-if="popoverShow">
@@ -86,7 +86,7 @@
86
86
  <i class="mdi mdi-chevron-up"></i>
87
87
  </div>
88
88
  </slot>
89
- <!--
89
+ <!--
90
90
  @slot Close state icon slot
91
91
  -->
92
92
  <slot name="icon-close" v-else>
@@ -105,13 +105,13 @@
105
105
  ref="datalist"
106
106
  >
107
107
  <template #header>
108
- <!--
108
+ <!--
109
109
  @slot Dropdown header slot
110
110
  -->
111
111
  <slot name="dropdown-header"></slot>
112
112
  </template>
113
113
  <template #option="{ option, index, cursorIndex }">
114
- <!--
114
+ <!--
115
115
  @slot Label slot for single mode
116
116
  @binding {Object} option option
117
117
  @binding {any} value option's value
@@ -121,7 +121,7 @@
121
121
  @binding {Number} cursorIndex current cursor index
122
122
  @binding {Function} selectOption function that selects option
123
123
  @binding {Function} deselectOption function that deselects option
124
- @binding {Function} toggleOption function that toggles option selection
124
+ @binding {Function} toggleOption function that toggles option selection
125
125
  @binding {Number} optionIndex option's index
126
126
  @binding {Boolean} isOptionSelected option selection status
127
127
  -->
@@ -148,6 +148,7 @@
148
148
  'bg-grey-lighter': index == cursorIndex,
149
149
  }"
150
150
  :key="index"
151
+ :title="getOptionLabel(option)"
151
152
  @click="toggleOption(option)"
152
153
  >
153
154
  <div class="row row-collapse" v-if="multiple">
@@ -174,7 +175,7 @@
174
175
  </slot>
175
176
  </template>
176
177
  <template #footer>
177
- <!--
178
+ <!--
178
179
  @slot Dropdown footer slot
179
180
  -->
180
181
  <slot name="dropdown-footer"></slot>