@dataloop-ai/components 0.20.260 → 0.20.261-new-input.1
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
|
@@ -175,10 +175,16 @@
|
|
|
175
175
|
bordered
|
|
176
176
|
:style="{ maxWidth: suggestMenuWidth }"
|
|
177
177
|
>
|
|
178
|
+
<slot name="suggestion-header">
|
|
179
|
+
<dl-list-item v-if="suggestionHeader">
|
|
180
|
+
{{ suggestionHeader }}
|
|
181
|
+
</dl-list-item>
|
|
182
|
+
</slot>
|
|
178
183
|
<dl-list-item
|
|
179
184
|
v-for="(item, suggestIndex) in suggestItems"
|
|
180
185
|
:key="item.suggestion"
|
|
181
186
|
clickable
|
|
187
|
+
:start-icon="getSuggestionStartIcon(item)"
|
|
182
188
|
style="
|
|
183
189
|
font-size: var(
|
|
184
190
|
--dl-typography-body-body3-font-size
|
|
@@ -189,35 +195,44 @@
|
|
|
189
195
|
"
|
|
190
196
|
@click="onClick($event, item)"
|
|
191
197
|
>
|
|
192
|
-
<
|
|
193
|
-
|
|
194
|
-
:
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
<span
|
|
198
|
-
v-for="(word, index) in getSuggestWords(
|
|
199
|
-
item.suggestion,
|
|
200
|
-
modelValue
|
|
201
|
-
)"
|
|
202
|
-
:key="JSON.stringify(word) + index"
|
|
203
|
-
:class="{
|
|
204
|
-
'dl-input__suggestion--highlighted':
|
|
205
|
-
word.highlighted
|
|
206
|
-
}"
|
|
198
|
+
<slot
|
|
199
|
+
name="suggestion-item"
|
|
200
|
+
:item="item"
|
|
201
|
+
:keyword="modelValue"
|
|
202
|
+
:suggest-index="suggestIndex"
|
|
207
203
|
>
|
|
208
|
-
<
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
204
|
+
<img
|
|
205
|
+
v-if="item.image"
|
|
206
|
+
:src="item.image"
|
|
207
|
+
class="dl-input__suggestion--image"
|
|
208
|
+
/>
|
|
212
209
|
<span
|
|
213
|
-
v-
|
|
214
|
-
word
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
210
|
+
v-for="(
|
|
211
|
+
word, index
|
|
212
|
+
) in getSuggestWords(
|
|
213
|
+
item.suggestion,
|
|
214
|
+
modelValue
|
|
215
|
+
)"
|
|
216
|
+
:key="JSON.stringify(word) + index"
|
|
217
|
+
:class="{
|
|
218
|
+
'dl-input__suggestion--highlighted':
|
|
219
|
+
word.highlighted
|
|
220
|
+
}"
|
|
219
221
|
>
|
|
220
|
-
|
|
222
|
+
<span v-if="word.value[0] === ' '"
|
|
223
|
+
> </span
|
|
224
|
+
>
|
|
225
|
+
{{ word.value }}
|
|
226
|
+
<span
|
|
227
|
+
v-if="
|
|
228
|
+
word.value[
|
|
229
|
+
word.value.length - 1
|
|
230
|
+
] === ' '
|
|
231
|
+
"
|
|
232
|
+
> </span
|
|
233
|
+
>
|
|
234
|
+
</span>
|
|
235
|
+
</slot>
|
|
221
236
|
</dl-list-item>
|
|
222
237
|
</dl-list>
|
|
223
238
|
</dl-menu>
|
|
@@ -609,6 +624,20 @@ export default defineComponent({
|
|
|
609
624
|
type: String,
|
|
610
625
|
default: 'auto'
|
|
611
626
|
},
|
|
627
|
+
/**
|
|
628
|
+
* Text shown at the top of the suggestions list
|
|
629
|
+
*/
|
|
630
|
+
suggestionHeader: {
|
|
631
|
+
type: String,
|
|
632
|
+
default: ''
|
|
633
|
+
},
|
|
634
|
+
/**
|
|
635
|
+
* Open suggestion menu when input is focused
|
|
636
|
+
*/
|
|
637
|
+
openSuggestionsOnFocus: {
|
|
638
|
+
type: Boolean,
|
|
639
|
+
default: false
|
|
640
|
+
},
|
|
612
641
|
/**
|
|
613
642
|
* Tooltip showed when hovering over the clear button
|
|
614
643
|
*/
|
|
@@ -697,12 +726,17 @@ export default defineComponent({
|
|
|
697
726
|
const isInternalChange = ref(false)
|
|
698
727
|
|
|
699
728
|
const suggestItems = computed<DlInputSuggestion[]>(() => {
|
|
700
|
-
|
|
729
|
+
const inputValue =
|
|
730
|
+
modelValue.value === null || modelValue.value === undefined
|
|
731
|
+
? ''
|
|
732
|
+
: modelValue.value.toString()
|
|
701
733
|
return getSuggestItems(
|
|
702
734
|
autoSuggestItems.value,
|
|
703
|
-
|
|
735
|
+
inputValue
|
|
704
736
|
) as DlInputSuggestion[]
|
|
705
737
|
})
|
|
738
|
+
const getSuggestionStartIcon = (item: DlInputSuggestion) =>
|
|
739
|
+
(item as any).startIcon
|
|
706
740
|
const input = ref(null)
|
|
707
741
|
|
|
708
742
|
const setHighlightedIndex = (value: any) => {
|
|
@@ -977,6 +1011,7 @@ export default defineComponent({
|
|
|
977
1011
|
emitAddFile,
|
|
978
1012
|
emitRemoveFile,
|
|
979
1013
|
updateSyntax,
|
|
1014
|
+
getSuggestionStartIcon,
|
|
980
1015
|
stringSuggestions,
|
|
981
1016
|
showPlaceholder,
|
|
982
1017
|
spanText,
|
|
@@ -1124,7 +1159,14 @@ export default defineComponent({
|
|
|
1124
1159
|
return !this.$slots.append && this.type === 'password'
|
|
1125
1160
|
},
|
|
1126
1161
|
showSuggestItems(): boolean {
|
|
1127
|
-
|
|
1162
|
+
const hasValue =
|
|
1163
|
+
this.modelValue !== null &&
|
|
1164
|
+
this.modelValue !== undefined &&
|
|
1165
|
+
`${this.modelValue}`.length > 0
|
|
1166
|
+
return (
|
|
1167
|
+
!!this.suggestItems?.length &&
|
|
1168
|
+
(hasValue || (this.openSuggestionsOnFocus && this.focused))
|
|
1169
|
+
)
|
|
1128
1170
|
},
|
|
1129
1171
|
debouncedBlur(): any {
|
|
1130
1172
|
if (stateManager.disableDebounce) {
|
|
@@ -1279,6 +1321,16 @@ export default defineComponent({
|
|
|
1279
1321
|
const inputRef = this.$refs.input as HTMLInputElement
|
|
1280
1322
|
inputRef.focus()
|
|
1281
1323
|
},
|
|
1324
|
+
openSuggestionMenuOnFocus(): void {
|
|
1325
|
+
if (!this.openSuggestionsOnFocus || !this.suggestItems?.length) {
|
|
1326
|
+
return
|
|
1327
|
+
}
|
|
1328
|
+
this.$nextTick(() => {
|
|
1329
|
+
if (this.focused) {
|
|
1330
|
+
this.isMenuOpen = true
|
|
1331
|
+
}
|
|
1332
|
+
})
|
|
1333
|
+
},
|
|
1282
1334
|
onFocus(e: InputEvent): void {
|
|
1283
1335
|
this.handleValueTrim()
|
|
1284
1336
|
const el = e.target as HTMLElement
|
|
@@ -1286,6 +1338,7 @@ export default defineComponent({
|
|
|
1286
1338
|
el.scroll(el.scrollWidth, 0)
|
|
1287
1339
|
}
|
|
1288
1340
|
this.focused = true
|
|
1341
|
+
this.openSuggestionMenuOnFocus()
|
|
1289
1342
|
this.$emit('focus', e)
|
|
1290
1343
|
},
|
|
1291
1344
|
blur(): void {
|
|
@@ -1299,6 +1352,7 @@ export default defineComponent({
|
|
|
1299
1352
|
: el.innerText
|
|
1300
1353
|
el.scroll(0, 0)
|
|
1301
1354
|
this.focused = false
|
|
1355
|
+
this.isMenuOpen = false
|
|
1302
1356
|
this.$emit('blur', e)
|
|
1303
1357
|
this.handleValueTrim()
|
|
1304
1358
|
},
|
|
@@ -1310,10 +1364,12 @@ export default defineComponent({
|
|
|
1310
1364
|
},
|
|
1311
1365
|
onNativeFocus(e: FocusEvent): void {
|
|
1312
1366
|
this.focused = true
|
|
1367
|
+
this.openSuggestionMenuOnFocus()
|
|
1313
1368
|
this.$emit('focus', e)
|
|
1314
1369
|
},
|
|
1315
1370
|
onNativeBlur(e: FocusEvent): void {
|
|
1316
1371
|
this.focused = false
|
|
1372
|
+
this.isMenuOpen = false
|
|
1317
1373
|
this.$emit('blur', e)
|
|
1318
1374
|
},
|
|
1319
1375
|
onNativeEnterPress(e: KeyboardEvent): void {
|