@dataloop-ai/components 0.20.261-new-input.0 → 0.20.261-new-input.2
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
|
@@ -160,14 +160,15 @@
|
|
|
160
160
|
</div>
|
|
161
161
|
<dl-menu
|
|
162
162
|
v-if="showSuggestItems"
|
|
163
|
-
|
|
164
|
-
|
|
163
|
+
:model-value="isMenuOpen"
|
|
164
|
+
persistent
|
|
165
165
|
no-focus
|
|
166
|
+
no-refocus
|
|
166
167
|
:offset="[0, 3]"
|
|
167
168
|
fit-container
|
|
168
169
|
:fit-content="fitContent"
|
|
169
170
|
:arrow-nav-items="stringSuggestions"
|
|
170
|
-
@
|
|
171
|
+
@update:model-value="onSuggestionMenuModelUpdate"
|
|
171
172
|
@highlighted-item="setHighlightedIndex"
|
|
172
173
|
@selected-item="handleSelectedItem"
|
|
173
174
|
>
|
|
@@ -176,7 +177,10 @@
|
|
|
176
177
|
:style="{ maxWidth: suggestMenuWidth }"
|
|
177
178
|
>
|
|
178
179
|
<slot name="suggestion-header">
|
|
179
|
-
<dl-list-item
|
|
180
|
+
<dl-list-item
|
|
181
|
+
v-if="suggestionHeader"
|
|
182
|
+
class="dl-input__suggestion--header"
|
|
183
|
+
>
|
|
180
184
|
{{ suggestionHeader }}
|
|
181
185
|
</dl-list-item>
|
|
182
186
|
</slot>
|
|
@@ -193,6 +197,7 @@
|
|
|
193
197
|
:highlighted="
|
|
194
198
|
suggestIndex === highlightedIndex
|
|
195
199
|
"
|
|
200
|
+
@mousedown.prevent
|
|
196
201
|
@click="onClick($event, item)"
|
|
197
202
|
>
|
|
198
203
|
<slot
|
|
@@ -742,7 +747,10 @@ export default defineComponent({
|
|
|
742
747
|
const setHighlightedIndex = (value: any) => {
|
|
743
748
|
highlightedIndex.value = value
|
|
744
749
|
}
|
|
745
|
-
const handleSelectedItem = (value:
|
|
750
|
+
const handleSelectedItem = (value: unknown) => {
|
|
751
|
+
if (typeof value !== 'string') {
|
|
752
|
+
return
|
|
753
|
+
}
|
|
746
754
|
onAutoSuggestClick(null, value)
|
|
747
755
|
}
|
|
748
756
|
|
|
@@ -834,7 +842,11 @@ export default defineComponent({
|
|
|
834
842
|
}
|
|
835
843
|
|
|
836
844
|
const onAutoSuggestClick = (e: Event, item: string): void => {
|
|
837
|
-
|
|
845
|
+
if (typeof item !== 'string' || !item.trim().length) {
|
|
846
|
+
return
|
|
847
|
+
}
|
|
848
|
+
const currentValue = String(modelValue.value ?? '')
|
|
849
|
+
const newValue = clearSuggestion(currentValue, item)
|
|
838
850
|
if (!maxLength.value || newValue.length < maxLength.value) {
|
|
839
851
|
const toEmit = newValue.replace(new RegExp(' ', 'g'), ' ')
|
|
840
852
|
emit('input', toEmit, e)
|
|
@@ -843,6 +855,7 @@ export default defineComponent({
|
|
|
843
855
|
setCaretAtTheEnd(input.value)
|
|
844
856
|
isInternalChange.value = true
|
|
845
857
|
}
|
|
858
|
+
isMenuOpen.value = false
|
|
846
859
|
}
|
|
847
860
|
|
|
848
861
|
const emitAddFile = (file: DlInputFile) => {
|
|
@@ -1321,6 +1334,16 @@ export default defineComponent({
|
|
|
1321
1334
|
const inputRef = this.$refs.input as HTMLInputElement
|
|
1322
1335
|
inputRef.focus()
|
|
1323
1336
|
},
|
|
1337
|
+
openSuggestionMenuOnFocus(): void {
|
|
1338
|
+
if (!this.openSuggestionsOnFocus || !this.suggestItems?.length) {
|
|
1339
|
+
return
|
|
1340
|
+
}
|
|
1341
|
+
this.$nextTick(() => {
|
|
1342
|
+
if (this.focused) {
|
|
1343
|
+
this.isMenuOpen = true
|
|
1344
|
+
}
|
|
1345
|
+
})
|
|
1346
|
+
},
|
|
1324
1347
|
onFocus(e: InputEvent): void {
|
|
1325
1348
|
this.handleValueTrim()
|
|
1326
1349
|
const el = e.target as HTMLElement
|
|
@@ -1328,9 +1351,7 @@ export default defineComponent({
|
|
|
1328
1351
|
el.scroll(el.scrollWidth, 0)
|
|
1329
1352
|
}
|
|
1330
1353
|
this.focused = true
|
|
1331
|
-
|
|
1332
|
-
this.isMenuOpen = true
|
|
1333
|
-
}
|
|
1354
|
+
this.openSuggestionMenuOnFocus()
|
|
1334
1355
|
this.$emit('focus', e)
|
|
1335
1356
|
},
|
|
1336
1357
|
blur(): void {
|
|
@@ -1356,9 +1377,7 @@ export default defineComponent({
|
|
|
1356
1377
|
},
|
|
1357
1378
|
onNativeFocus(e: FocusEvent): void {
|
|
1358
1379
|
this.focused = true
|
|
1359
|
-
|
|
1360
|
-
this.isMenuOpen = true
|
|
1361
|
-
}
|
|
1380
|
+
this.openSuggestionMenuOnFocus()
|
|
1362
1381
|
this.$emit('focus', e)
|
|
1363
1382
|
},
|
|
1364
1383
|
onNativeBlur(e: FocusEvent): void {
|
|
@@ -1390,8 +1409,12 @@ export default defineComponent({
|
|
|
1390
1409
|
onPassShowClick(): void {
|
|
1391
1410
|
this.showPass = !this.showPass
|
|
1392
1411
|
},
|
|
1393
|
-
|
|
1394
|
-
this.
|
|
1412
|
+
onSuggestionMenuModelUpdate(value: boolean): void {
|
|
1413
|
+
if (!value && this.focused && this.openSuggestionsOnFocus) {
|
|
1414
|
+
this.openSuggestionMenuOnFocus()
|
|
1415
|
+
return
|
|
1416
|
+
}
|
|
1417
|
+
this.isMenuOpen = value
|
|
1395
1418
|
},
|
|
1396
1419
|
getSuggestWords(
|
|
1397
1420
|
item: string,
|
|
@@ -1741,6 +1764,13 @@ export default defineComponent({
|
|
|
1741
1764
|
}
|
|
1742
1765
|
|
|
1743
1766
|
&__suggestion {
|
|
1767
|
+
&--header {
|
|
1768
|
+
font-family: var(--dl-typography-body-body3-font-family);
|
|
1769
|
+
font-size: var(--dl-typography-body-body3-font-size);
|
|
1770
|
+
line-height: var(--dl-typography-body-body3-line-height);
|
|
1771
|
+
font-weight: var(--dl-typography-body-body3-font-weight);
|
|
1772
|
+
color: var(--dell-gray-600);
|
|
1773
|
+
}
|
|
1744
1774
|
&--highlighted {
|
|
1745
1775
|
background-color: var(--dl-color-warning);
|
|
1746
1776
|
border-radius: 2px;
|
|
@@ -16,7 +16,8 @@ export function addEventListenersToElement(
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export function clearSuggestion(text: string, suggestion: string) {
|
|
19
|
-
|
|
19
|
+
const prefix = text.split(' ').slice(0, -1).join(' ')
|
|
20
|
+
return prefix ? `${prefix} ${suggestion}` : suggestion
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
export function setInnerHTMLWithCursor(
|
|
@@ -124,6 +124,15 @@
|
|
|
124
124
|
/>
|
|
125
125
|
</template>
|
|
126
126
|
</dl-input>
|
|
127
|
+
<dl-input
|
|
128
|
+
v-model="headerSuggestionsValue"
|
|
129
|
+
style="width: 320px"
|
|
130
|
+
title="Suggestions with header and icons"
|
|
131
|
+
placeholder="Type to see suggestions"
|
|
132
|
+
suggestion-header="Suggested users"
|
|
133
|
+
:auto-suggest-items="headerSuggestionsItems"
|
|
134
|
+
open-suggestions-on-focus
|
|
135
|
+
/>
|
|
127
136
|
<div class="numberClip" style="max-width: 64px">
|
|
128
137
|
<dl-input
|
|
129
138
|
v-model="numberClip"
|
|
@@ -249,7 +258,10 @@
|
|
|
249
258
|
import { v4 } from 'uuid'
|
|
250
259
|
import { computed, defineComponent, ref } from 'vue-demi'
|
|
251
260
|
import { DlInput, DlButton, DlIcon, DlSwitch } from '../components'
|
|
252
|
-
import {
|
|
261
|
+
import {
|
|
262
|
+
DlInputFile,
|
|
263
|
+
DlInputSuggestion
|
|
264
|
+
} from '../components/compound/DlInput/types'
|
|
253
265
|
export default defineComponent({
|
|
254
266
|
name: 'DlInputDemo',
|
|
255
267
|
components: {
|
|
@@ -265,6 +277,21 @@ export default defineComponent({
|
|
|
265
277
|
const sizeSFieldValue = ref<string>('')
|
|
266
278
|
const errorFieldValue = ref<string>('')
|
|
267
279
|
const saveInputValue = ref<string>('Test vaaalueeee')
|
|
280
|
+
const headerSuggestionsValue = ref<string>('')
|
|
281
|
+
const headerSuggestionsItems = ref<DlInputSuggestion[]>([
|
|
282
|
+
{
|
|
283
|
+
suggestion: '@john-doe',
|
|
284
|
+
startIcon: 'icon-dl-user'
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
suggestion: '@jane-smith',
|
|
288
|
+
startIcon: 'icon-dl-user'
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
suggestion: '@team-design',
|
|
292
|
+
startIcon: 'icon-dl-users'
|
|
293
|
+
}
|
|
294
|
+
])
|
|
268
295
|
|
|
269
296
|
const files = ref<DlInputFile[]>([])
|
|
270
297
|
const addFile = (e: Event) => {
|
|
@@ -313,6 +340,8 @@ export default defineComponent({
|
|
|
313
340
|
warningFieldValue,
|
|
314
341
|
errorFieldValue,
|
|
315
342
|
saveInputValue,
|
|
343
|
+
headerSuggestionsValue,
|
|
344
|
+
headerSuggestionsItems,
|
|
316
345
|
sizeSFieldValue,
|
|
317
346
|
files,
|
|
318
347
|
updateFiles,
|