goodteditor-ui 1.0.21 → 1.0.23

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.
Files changed (114) hide show
  1. package/.eslintrc.js +7 -7
  2. package/.prettierrc +14 -14
  3. package/README.md +35 -35
  4. package/babel.config.js +5 -5
  5. package/index.js +53 -53
  6. package/jsconfig.json +13 -13
  7. package/package.json +66 -70
  8. package/src/App.vue +36 -36
  9. package/src/components/ui/Avatar.md +68 -68
  10. package/src/components/ui/Avatar.vue +180 -177
  11. package/src/components/ui/Badge.md +20 -20
  12. package/src/components/ui/Badge.vue +75 -75
  13. package/src/components/ui/Collapse.md +90 -90
  14. package/src/components/ui/Collapse.vue +86 -86
  15. package/src/components/ui/ColorPicker/Alpha.vue +114 -114
  16. package/src/components/ui/ColorPicker/Colors.vue +117 -117
  17. package/src/components/ui/ColorPicker/Hue.vue +113 -113
  18. package/src/components/ui/ColorPicker/Preview.vue +55 -55
  19. package/src/components/ui/ColorPicker/Saturation.vue +123 -123
  20. package/src/components/ui/ColorPicker/mixin.js +105 -105
  21. package/src/components/ui/ColorPicker.md +17 -17
  22. package/src/components/ui/ColorPicker.vue +314 -314
  23. package/src/components/ui/Datalist.md +41 -41
  24. package/src/components/ui/Datalist.vue +157 -157
  25. package/src/components/ui/DatePicker.md +168 -168
  26. package/src/components/ui/DatePicker.vue +527 -527
  27. package/src/components/ui/FileSelector.md +105 -105
  28. package/src/components/ui/FileSelector.vue +82 -82
  29. package/src/components/ui/Grid.md +130 -130
  30. package/src/components/ui/Grid.vue +92 -92
  31. package/src/components/ui/Image.md +59 -59
  32. package/src/components/ui/Image.vue +57 -57
  33. package/src/components/ui/InputAutocomplete.md +115 -115
  34. package/src/components/ui/InputAutocomplete.vue +341 -341
  35. package/src/components/ui/InputColorPicker.md +51 -51
  36. package/src/components/ui/InputColorPicker.vue +151 -151
  37. package/src/components/ui/InputDatePicker.md +121 -121
  38. package/src/components/ui/InputDatePicker.vue +326 -326
  39. package/src/components/ui/InputTags.md +51 -51
  40. package/src/components/ui/InputTags.vue +184 -184
  41. package/src/components/ui/InputTimePicker.md +25 -25
  42. package/src/components/ui/InputTimePicker.vue +253 -253
  43. package/src/components/ui/InputUnits.md +20 -20
  44. package/src/components/ui/InputUnits.vue +257 -257
  45. package/src/components/ui/Lazy.md +37 -37
  46. package/src/components/ui/Lazy.vue +92 -92
  47. package/src/components/ui/Pagination.md +74 -74
  48. package/src/components/ui/Pagination.vue +138 -138
  49. package/src/components/ui/Paginator.md +34 -34
  50. package/src/components/ui/Paginator.vue +83 -83
  51. package/src/components/ui/Popover.md +34 -34
  52. package/src/components/ui/Popover.vue +274 -274
  53. package/src/components/ui/Popup.md +59 -59
  54. package/src/components/ui/Popup.vue +150 -150
  55. package/src/components/ui/ResponsiveContainer.md +58 -58
  56. package/src/components/ui/ResponsiveContainer.vue +99 -99
  57. package/src/components/ui/Select.md +187 -187
  58. package/src/components/ui/Select.vue +421 -421
  59. package/src/components/ui/TimePicker.md +50 -50
  60. package/src/components/ui/TimePicker.vue +252 -252
  61. package/src/components/ui/Tooltip.md +54 -114
  62. package/src/components/ui/Tooltip.vue +113 -113
  63. package/src/components/ui/WysiwygEditor/WysiwygEditor.d.ts +119 -119
  64. package/src/components/ui/WysiwygEditor/constants.js +264 -264
  65. package/src/components/ui/WysiwygEditor/extensions/blockquote.js +15 -15
  66. package/src/components/ui/WysiwygEditor/extensions/bold.js +15 -15
  67. package/src/components/ui/WysiwygEditor/extensions/bullet-list.js +15 -15
  68. package/src/components/ui/WysiwygEditor/extensions/code-block.js +13 -13
  69. package/src/components/ui/WysiwygEditor/extensions/code.js +13 -13
  70. package/src/components/ui/WysiwygEditor/extensions/font-size.js +34 -34
  71. package/src/components/ui/WysiwygEditor/extensions/formatting.js +14 -14
  72. package/src/components/ui/WysiwygEditor/extensions/heading.js +13 -13
  73. package/src/components/ui/WysiwygEditor/extensions/horizontal-rule.js +15 -15
  74. package/src/components/ui/WysiwygEditor/extensions/image.js +19 -19
  75. package/src/components/ui/WysiwygEditor/extensions/index.d.ts +32 -32
  76. package/src/components/ui/WysiwygEditor/extensions/index.js +32 -32
  77. package/src/components/ui/WysiwygEditor/extensions/italic.js +15 -15
  78. package/src/components/ui/WysiwygEditor/extensions/link.js +16 -16
  79. package/src/components/ui/WysiwygEditor/extensions/list-item.js +15 -15
  80. package/src/components/ui/WysiwygEditor/extensions/ordered-list.js +15 -15
  81. package/src/components/ui/WysiwygEditor/extensions/paragraph.js +23 -23
  82. package/src/components/ui/WysiwygEditor/extensions/strike.js +15 -15
  83. package/src/components/ui/WysiwygEditor/extensions/table-cell.js +13 -13
  84. package/src/components/ui/WysiwygEditor/extensions/table-header.js +15 -15
  85. package/src/components/ui/WysiwygEditor/extensions/table-row.js +15 -15
  86. package/src/components/ui/WysiwygEditor/extensions/table.js +29 -29
  87. package/src/components/ui/WysiwygEditor/extensions/text-align.js +6 -6
  88. package/src/components/ui/WysiwygEditor/extensions/text-style.js +15 -15
  89. package/src/components/ui/WysiwygEditor/extensions/underline.js +15 -15
  90. package/src/components/ui/WysiwygEditor/index.d.ts +4 -4
  91. package/src/components/ui/WysiwygEditor/index.js +4 -4
  92. package/src/components/ui/WysiwygEditor/renders/Button.vue +28 -28
  93. package/src/components/ui/WysiwygEditor/renders/ColorPicker.vue +41 -41
  94. package/src/components/ui/WysiwygEditor/renders/InputAuto.vue +34 -34
  95. package/src/components/ui/WysiwygEditor/renders/InputBrowse.vue +35 -35
  96. package/src/components/ui/WysiwygEditor/renders/InputUnits.vue +38 -38
  97. package/src/components/ui/WysiwygEditor/renders/Link.vue +87 -87
  98. package/src/components/ui/WysiwygEditor/renders/Select.vue +47 -47
  99. package/src/components/ui/WysiwygEditor/renders/ToolbarPopover.vue +49 -49
  100. package/src/components/ui/WysiwygEditor/renders/index.d.ts +8 -8
  101. package/src/components/ui/WysiwygEditor/renders/index.js +8 -8
  102. package/src/components/ui/WysiwygEditor/renders/mixins/RenderMixin.js +39 -39
  103. package/src/components/ui/WysiwygEditor/renders/mixins/index.js +1 -1
  104. package/src/components/ui/WysiwygEditor/tools-and-commands.js +704 -704
  105. package/src/components/ui/WysiwygEditor/utils.js +72 -72
  106. package/src/components/ui/WysiwygEditor.md +18 -18
  107. package/src/components/ui/WysiwygEditor.vue +271 -271
  108. package/src/components/ui/utils/FormComponent.js +107 -107
  109. package/src/components/ui/utils/Helpers.js +84 -84
  110. package/src/components/ui/utils/WithPopover.js +81 -99
  111. package/src/main.js +8 -8
  112. package/styleguide.config.js +37 -37
  113. package/vue.config.js +8 -8
  114. package/dist/js.png +0 -0
@@ -1,341 +1,341 @@
1
- <template>
2
- <div
3
- class="ui-input-autocomplete form-elem"
4
- :class="cssClass"
5
- @focus="onRootFocus"
6
- tabindex="0"
7
- :data-popover="popoverTargetId"
8
- >
9
- <div style="flex: 1 0 0">
10
- <!--
11
- @slot Custom input slot
12
- @binding {String} id input id attribute value
13
- @binding {String} value input value
14
- @binding {Object} inputBinds input props (use v-bind)
15
- @binding {Object} inputEvents input events (use v-on)
16
- -->
17
- <slot name="input" v-bind="{ id: inputId, value, inputBinds, inputEvents }">
18
- <input
19
- :id="inputId"
20
- class="ui-input-autocomplete-input w-100"
21
- type="text"
22
- :value="value"
23
- v-bind="inputBinds"
24
- v-on="inputEvents"
25
- />
26
- </slot>
27
- </div>
28
- <!--
29
- @slot Loading custom content
30
- -->
31
- <slot name="loading" v-if="loading">
32
- <div class="icon w-auto h-auto">
33
- <div class="preloader"></div>
34
- </div>
35
- </slot>
36
- <ui-popover :show.sync="popoverShow" v-bind="popoverOptions">
37
- <ui-datalist
38
- class="w-100 pull-left"
39
- @select-option="onDatalistSelectOption"
40
- v-bind="{ size, options: suggestedOptions }"
41
- :cursorIndex.sync="dataListCursorIndex"
42
- ref="datalist"
43
- >
44
- <template #header>
45
- <!--
46
- @slot Dropdown header content
47
- -->
48
- <slot name="dropdown-header"></slot>
49
- <!--
50
- @slot No results content
51
- -->
52
- <slot name="noresults" v-if="!loading && !suggestedOptions.length"></slot>
53
- </template>
54
- <template
55
- #option="{
56
- option,
57
- index,
58
- cursorIndex,
59
- setCursorIndex,
60
- }"
61
- >
62
- <!--
63
- @slot Dropdown option
64
- @binding {String} option option label
65
- @binding {Number} optionIndex option index
66
- @binding {String} value current value
67
- @binding {String} valueLocal current delimited value
68
- @binding {Number} cursorIndex current dropdown selection index
69
- @binding {Function} selectOption function that select's the option
70
- @binding {Function} setCursorIndex function that sets the cursor index
71
- -->
72
- <slot
73
- name="option"
74
- v-bind="{
75
- option: option,
76
- optionIndex: index,
77
- value,
78
- valueLocal: delimitedValue,
79
- cursorIndex,
80
- selectOption,
81
- setCursorIndex,
82
- }"
83
- ></slot>
84
- </template>
85
- <template #footer>
86
- <slot name="dropdown-footer"></slot>
87
- </template>
88
- </ui-datalist>
89
- </ui-popover>
90
- </div>
91
- </template>
92
- <style lang="less" scoped>
93
- .ui-input-autocomplete {
94
- display: inline-flex;
95
- align-items: center;
96
- &-input {
97
- border: none;
98
- line-height: 1.5;
99
- margin: 0;
100
- padding: 0;
101
- color: inherit;
102
- background: transparent;
103
- outline: none;
104
- }
105
- }
106
- </style>
107
- <script>
108
- import { Key } from './utils/Helpers';
109
- import FormComponent from './utils/FormComponent';
110
- import WithPopover from './utils/WithPopover';
111
- import UiDatalist from './Datalist.vue';
112
- import UiPopover from './Popover.vue';
113
-
114
- export default {
115
- mixins: [FormComponent, WithPopover],
116
- components: { UiDatalist, UiPopover },
117
- props: {
118
- /**
119
- * Dropdown option (suggestions)
120
- */
121
- options: {
122
- type: Array,
123
- default() {
124
- return [];
125
- },
126
- },
127
- /**
128
- * Function which filters suggestions function(val, options):Promise<Array>
129
- */
130
- filter: {
131
- type: Function,
132
- default: null,
133
- },
134
- /**
135
- * Filter debounce delay in ms
136
- */
137
- filterDebounce: {
138
- type: Number,
139
- default: 0,
140
- },
141
- /**
142
- * Value delimiter for multiple autocomplete suggestions
143
- */
144
- delimiter: {
145
- type: String,
146
- default: ',',
147
- },
148
- /**
149
- * Show suggestions on focus event
150
- */
151
- suggestOnFocus: {
152
- type: Boolean,
153
- default: true,
154
- },
155
- /**
156
- * Min length to show suggestions
157
- */
158
- minLength: {
159
- type: Number,
160
- default: 0,
161
- },
162
- autoWidth: {
163
- default: true,
164
- },
165
- },
166
- data() {
167
- return {
168
- loading: false,
169
- suggestedOptions: [],
170
- caretIndex: 0,
171
- dataListCursorIndex: -1,
172
- filterTID: null,
173
- inputBinds: {
174
- placeholder: this.placeholder,
175
- readonly: this.readonly,
176
- },
177
- inputEvents: {
178
- change: this.onInputChange,
179
- input: this.onInputInput,
180
- keydown: this.onInputKeyDown,
181
- focus: this.onInputFocus,
182
- blur: this.onInputBlur,
183
- },
184
- delimitedValuePrev: null,
185
- };
186
- },
187
- computed: {
188
- delimitedIndex() {
189
- let sub = this.value.substring(0, this.caretIndex);
190
- let m = [];
191
- let i = -1;
192
- while ((i = sub.indexOf(this.delimiter, i + 1)) != -1) {
193
- m.push(i);
194
- }
195
- return m ? m.length : 0;
196
- },
197
- delimitedValue() {
198
- if (this.delimiter) {
199
- return this.value.split(this.delimiter)[this.delimitedIndex];
200
- }
201
- return this.value;
202
- },
203
- },
204
- methods: {
205
- defaultFilter(val, options) {
206
- return new Promise(resolve => {
207
- let arr = options.filter(opt => opt.toLowerCase().indexOf(val.toLowerCase()) === 0);
208
- resolve(arr);
209
- });
210
- },
211
- callFilter(val) {
212
- let prev = this.delimitedValuePrev;
213
- this.delimitedValuePrev = val;
214
- if (val === prev) {
215
- return;
216
- }
217
- if (!val.length && !this.filter) {
218
- this.suggestedOptions = this.options;
219
- this.dataListCursorIndex = -1;
220
- return;
221
- }
222
- this.loading = true;
223
- let h = this.filter ? this.filter : this.defaultFilter;
224
- h(val, this.options)
225
- .then(arr => {
226
- this.suggestedOptions = arr;
227
- this.dataListCursorIndex = -1;
228
- })
229
- .finally(() => (this.loading = false));
230
- },
231
- callFilterDebounced(val) {
232
- this.clearFilterTimeout();
233
- this.filterTID = setTimeout(() => this.callFilter(val), this.filterDebounce);
234
- },
235
- clearFilterTimeout() {
236
- if (this.filterTID) {
237
- clearTimeout(this.filterTID);
238
- this.filterTID = null;
239
- }
240
- },
241
- selectOption(opt) {
242
- let val = opt;
243
- if (this.delimiter) {
244
- let arr = this.value.split(this.delimiter);
245
- arr[this.delimitedIndex] = opt;
246
- val = arr.join(this.delimiter);
247
- }
248
- /**
249
- * Value change event
250
- * @property {String} value
251
- */
252
- this.$emit('input', val);
253
- /**
254
- * Value change event
255
- * @property {String} value
256
- */
257
- this.$emit('change', val);
258
- this.popoverShow = false;
259
- },
260
- getDatalistRef() {
261
- return this.$refs.datalist;
262
- },
263
- onRootFocus(e) {
264
- let input = this.getInputRef();
265
- input && input.focus();
266
- },
267
- onInputBlur(e) {
268
- this.rootHasFocus = false;
269
- },
270
- onInputFocus(e) {
271
- this.rootHasFocus = true;
272
- /**
273
- * Input focus event
274
- * @property {Node} node
275
- */
276
- this.$emit('focus', e.target);
277
-
278
- if (!this.suggestOnFocus) {
279
- return;
280
- }
281
-
282
- this.popoverShow = true;
283
- this.caretIndex = e.target ? e.target.selectionStart : 0;
284
- this.$nextTick(() => {
285
- if (this.delimitedValue.length < this.minLength) {
286
- this.popoverShow = false;
287
- this.suggestedOptions = [];
288
- this.delimitedValuePrev = this.delimitedValue;
289
- return;
290
- }
291
- this.callFilterDebounced(this.delimitedValue);
292
- });
293
- },
294
- onInputChange(e) {
295
- let val = e.target.value;
296
- /**
297
- * Change event
298
- * @property {String} value
299
- */
300
- this.$emit('change', val);
301
- },
302
- onInputInput(e) {
303
- let val = e.target.value;
304
- /**
305
- * input event
306
- * @property {String} value
307
- */
308
- this.$emit('input', val);
309
-
310
- this.popoverShow = true;
311
- this.caretIndex = e.target ? e.target.selectionStart : 0;
312
- this.$nextTick(() => {
313
- if (this.delimitedValue.length < this.minLength) {
314
- this.popoverShow = false;
315
- this.suggestedOptions = [];
316
- this.delimitedValuePrev = this.delimitedValue;
317
- return;
318
- }
319
- this.callFilterDebounced(this.delimitedValue);
320
- });
321
- },
322
- onInputKeyDown(e) {
323
- let list = this.getDatalistRef();
324
- if (e.key === Key.ESC) {
325
- this.popoverShow = false;
326
- }
327
- if (e.key === Key.ENTER) {
328
- if (!this.popoverShow) {
329
- this.popoverShow = true;
330
- }
331
- }
332
- if (this.popoverShow) {
333
- list && list.onKeyDown(e);
334
- }
335
- },
336
- onDatalistSelectOption({ option }) {
337
- this.selectOption(option);
338
- },
339
- },
340
- };
341
- </script>
1
+ <template>
2
+ <div
3
+ class="ui-input-autocomplete form-elem"
4
+ :class="cssClass"
5
+ @focus="onRootFocus"
6
+ tabindex="0"
7
+ :data-popover="popoverTargetId"
8
+ >
9
+ <div style="flex: 1 0 0">
10
+ <!--
11
+ @slot Custom input slot
12
+ @binding {String} id input id attribute value
13
+ @binding {String} value input value
14
+ @binding {Object} inputBinds input props (use v-bind)
15
+ @binding {Object} inputEvents input events (use v-on)
16
+ -->
17
+ <slot name="input" v-bind="{ id: inputId, value, inputBinds, inputEvents }">
18
+ <input
19
+ :id="inputId"
20
+ class="ui-input-autocomplete-input w-100"
21
+ type="text"
22
+ :value="value"
23
+ v-bind="inputBinds"
24
+ v-on="inputEvents"
25
+ />
26
+ </slot>
27
+ </div>
28
+ <!--
29
+ @slot Loading custom content
30
+ -->
31
+ <slot name="loading" v-if="loading">
32
+ <div class="icon w-auto h-auto">
33
+ <div class="preloader"></div>
34
+ </div>
35
+ </slot>
36
+ <ui-popover :show.sync="popoverShow" v-bind="popoverOptions">
37
+ <ui-datalist
38
+ class="w-100 pull-left"
39
+ @select-option="onDatalistSelectOption"
40
+ v-bind="{ size, options: suggestedOptions }"
41
+ :cursorIndex.sync="dataListCursorIndex"
42
+ ref="datalist"
43
+ >
44
+ <template #header>
45
+ <!--
46
+ @slot Dropdown header content
47
+ -->
48
+ <slot name="dropdown-header"></slot>
49
+ <!--
50
+ @slot No results content
51
+ -->
52
+ <slot name="noresults" v-if="!loading && !suggestedOptions.length"></slot>
53
+ </template>
54
+ <template
55
+ #option="{
56
+ option,
57
+ index,
58
+ cursorIndex,
59
+ setCursorIndex,
60
+ }"
61
+ >
62
+ <!--
63
+ @slot Dropdown option
64
+ @binding {String} option option label
65
+ @binding {Number} optionIndex option index
66
+ @binding {String} value current value
67
+ @binding {String} valueLocal current delimited value
68
+ @binding {Number} cursorIndex current dropdown selection index
69
+ @binding {Function} selectOption function that select's the option
70
+ @binding {Function} setCursorIndex function that sets the cursor index
71
+ -->
72
+ <slot
73
+ name="option"
74
+ v-bind="{
75
+ option: option,
76
+ optionIndex: index,
77
+ value,
78
+ valueLocal: delimitedValue,
79
+ cursorIndex,
80
+ selectOption,
81
+ setCursorIndex,
82
+ }"
83
+ ></slot>
84
+ </template>
85
+ <template #footer>
86
+ <slot name="dropdown-footer"></slot>
87
+ </template>
88
+ </ui-datalist>
89
+ </ui-popover>
90
+ </div>
91
+ </template>
92
+ <style lang="less" scoped>
93
+ .ui-input-autocomplete {
94
+ display: inline-flex;
95
+ align-items: center;
96
+ &-input {
97
+ border: none;
98
+ line-height: 1.5;
99
+ margin: 0;
100
+ padding: 0;
101
+ color: inherit;
102
+ background: transparent;
103
+ outline: none;
104
+ }
105
+ }
106
+ </style>
107
+ <script>
108
+ import { Key } from './utils/Helpers';
109
+ import FormComponent from './utils/FormComponent';
110
+ import WithPopover from './utils/WithPopover';
111
+ import UiDatalist from './Datalist.vue';
112
+ import UiPopover from './Popover.vue';
113
+
114
+ export default {
115
+ mixins: [FormComponent, WithPopover],
116
+ components: { UiDatalist, UiPopover },
117
+ props: {
118
+ /**
119
+ * Dropdown option (suggestions)
120
+ */
121
+ options: {
122
+ type: Array,
123
+ default() {
124
+ return [];
125
+ },
126
+ },
127
+ /**
128
+ * Function which filters suggestions function(val, options):Promise<Array>
129
+ */
130
+ filter: {
131
+ type: Function,
132
+ default: null,
133
+ },
134
+ /**
135
+ * Filter debounce delay in ms
136
+ */
137
+ filterDebounce: {
138
+ type: Number,
139
+ default: 0,
140
+ },
141
+ /**
142
+ * Value delimiter for multiple autocomplete suggestions
143
+ */
144
+ delimiter: {
145
+ type: String,
146
+ default: ',',
147
+ },
148
+ /**
149
+ * Show suggestions on focus event
150
+ */
151
+ suggestOnFocus: {
152
+ type: Boolean,
153
+ default: true,
154
+ },
155
+ /**
156
+ * Min length to show suggestions
157
+ */
158
+ minLength: {
159
+ type: Number,
160
+ default: 0,
161
+ },
162
+ autoWidth: {
163
+ default: true,
164
+ },
165
+ },
166
+ data() {
167
+ return {
168
+ loading: false,
169
+ suggestedOptions: [],
170
+ caretIndex: 0,
171
+ dataListCursorIndex: -1,
172
+ filterTID: null,
173
+ inputBinds: {
174
+ placeholder: this.placeholder,
175
+ readonly: this.readonly,
176
+ },
177
+ inputEvents: {
178
+ change: this.onInputChange,
179
+ input: this.onInputInput,
180
+ keydown: this.onInputKeyDown,
181
+ focus: this.onInputFocus,
182
+ blur: this.onInputBlur,
183
+ },
184
+ delimitedValuePrev: null,
185
+ };
186
+ },
187
+ computed: {
188
+ delimitedIndex() {
189
+ let sub = this.value.substring(0, this.caretIndex);
190
+ let m = [];
191
+ let i = -1;
192
+ while ((i = sub.indexOf(this.delimiter, i + 1)) != -1) {
193
+ m.push(i);
194
+ }
195
+ return m ? m.length : 0;
196
+ },
197
+ delimitedValue() {
198
+ if (this.delimiter) {
199
+ return this.value.split(this.delimiter)[this.delimitedIndex];
200
+ }
201
+ return this.value;
202
+ },
203
+ },
204
+ methods: {
205
+ defaultFilter(val, options) {
206
+ return new Promise(resolve => {
207
+ let arr = options.filter(opt => opt.toLowerCase().indexOf(val.toLowerCase()) === 0);
208
+ resolve(arr);
209
+ });
210
+ },
211
+ callFilter(val) {
212
+ let prev = this.delimitedValuePrev;
213
+ this.delimitedValuePrev = val;
214
+ if (val === prev) {
215
+ return;
216
+ }
217
+ if (!val.length && !this.filter) {
218
+ this.suggestedOptions = this.options;
219
+ this.dataListCursorIndex = -1;
220
+ return;
221
+ }
222
+ this.loading = true;
223
+ let h = this.filter ? this.filter : this.defaultFilter;
224
+ h(val, this.options)
225
+ .then(arr => {
226
+ this.suggestedOptions = arr;
227
+ this.dataListCursorIndex = -1;
228
+ })
229
+ .finally(() => (this.loading = false));
230
+ },
231
+ callFilterDebounced(val) {
232
+ this.clearFilterTimeout();
233
+ this.filterTID = setTimeout(() => this.callFilter(val), this.filterDebounce);
234
+ },
235
+ clearFilterTimeout() {
236
+ if (this.filterTID) {
237
+ clearTimeout(this.filterTID);
238
+ this.filterTID = null;
239
+ }
240
+ },
241
+ selectOption(opt) {
242
+ let val = opt;
243
+ if (this.delimiter) {
244
+ let arr = this.value.split(this.delimiter);
245
+ arr[this.delimitedIndex] = opt;
246
+ val = arr.join(this.delimiter);
247
+ }
248
+ /**
249
+ * Value change event
250
+ * @property {String} value
251
+ */
252
+ this.$emit('input', val);
253
+ /**
254
+ * Value change event
255
+ * @property {String} value
256
+ */
257
+ this.$emit('change', val);
258
+ this.popoverShow = false;
259
+ },
260
+ getDatalistRef() {
261
+ return this.$refs.datalist;
262
+ },
263
+ onRootFocus(e) {
264
+ let input = this.getInputRef();
265
+ input && input.focus();
266
+ },
267
+ onInputBlur(e) {
268
+ this.rootHasFocus = false;
269
+ },
270
+ onInputFocus(e) {
271
+ this.rootHasFocus = true;
272
+ /**
273
+ * Input focus event
274
+ * @property {Node} node
275
+ */
276
+ this.$emit('focus', e.target);
277
+
278
+ if (!this.suggestOnFocus) {
279
+ return;
280
+ }
281
+
282
+ this.popoverShow = true;
283
+ this.caretIndex = e.target ? e.target.selectionStart : 0;
284
+ this.$nextTick(() => {
285
+ if (this.delimitedValue.length < this.minLength) {
286
+ this.popoverShow = false;
287
+ this.suggestedOptions = [];
288
+ this.delimitedValuePrev = this.delimitedValue;
289
+ return;
290
+ }
291
+ this.callFilterDebounced(this.delimitedValue);
292
+ });
293
+ },
294
+ onInputChange(e) {
295
+ let val = e.target.value;
296
+ /**
297
+ * Change event
298
+ * @property {String} value
299
+ */
300
+ this.$emit('change', val);
301
+ },
302
+ onInputInput(e) {
303
+ let val = e.target.value;
304
+ /**
305
+ * input event
306
+ * @property {String} value
307
+ */
308
+ this.$emit('input', val);
309
+
310
+ this.popoverShow = true;
311
+ this.caretIndex = e.target ? e.target.selectionStart : 0;
312
+ this.$nextTick(() => {
313
+ if (this.delimitedValue.length < this.minLength) {
314
+ this.popoverShow = false;
315
+ this.suggestedOptions = [];
316
+ this.delimitedValuePrev = this.delimitedValue;
317
+ return;
318
+ }
319
+ this.callFilterDebounced(this.delimitedValue);
320
+ });
321
+ },
322
+ onInputKeyDown(e) {
323
+ let list = this.getDatalistRef();
324
+ if (e.key === Key.ESC) {
325
+ this.popoverShow = false;
326
+ }
327
+ if (e.key === Key.ENTER) {
328
+ if (!this.popoverShow) {
329
+ this.popoverShow = true;
330
+ }
331
+ }
332
+ if (this.popoverShow) {
333
+ list && list.onKeyDown(e);
334
+ }
335
+ },
336
+ onDatalistSelectOption({ option }) {
337
+ this.selectOption(option);
338
+ },
339
+ },
340
+ };
341
+ </script>