@dataloop-ai/components 0.20.8 → 0.20.11
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": "@dataloop-ai/components",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.11",
|
|
4
4
|
"exports": {
|
|
5
5
|
".": "./index.ts",
|
|
6
6
|
"./models": "./models.ts",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"check-only": "if grep -E -H -r --exclude-dir=.git --exclude-dir=node_modules --exclude=*.json --exclude=*.yml '^(describe|it).only' .; then echo 'Found only in test files' && exit 1; fi"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@dataloop-ai/icons": "^3.0.
|
|
26
|
+
"@dataloop-ai/icons": "^3.0.101",
|
|
27
27
|
"@types/flat": "^5.0.2",
|
|
28
28
|
"@types/lodash": "^4.14.184",
|
|
29
29
|
"@types/sortablejs": "^1.15.7",
|
|
@@ -104,11 +104,15 @@ export default defineComponent({
|
|
|
104
104
|
hideNoData: {
|
|
105
105
|
type: Boolean,
|
|
106
106
|
default: false
|
|
107
|
+
},
|
|
108
|
+
initialSelection: {
|
|
109
|
+
type: Object as PropType<DlLabelPickerItem>,
|
|
110
|
+
default: null
|
|
107
111
|
}
|
|
108
112
|
},
|
|
109
113
|
emits: ['selected-label', 'click', 'focus', 'blur', 'clear'],
|
|
110
114
|
setup(props, { emit, slots }) {
|
|
111
|
-
const { items } = toRefs(props)
|
|
115
|
+
const { items, initialSelection } = toRefs(props)
|
|
112
116
|
|
|
113
117
|
const columns: DlTableColumn[] = [
|
|
114
118
|
{
|
|
@@ -124,9 +128,8 @@ export default defineComponent({
|
|
|
124
128
|
|
|
125
129
|
const inputValue = ref('')
|
|
126
130
|
const currentSelectedLabel = ref<DlLabelPickerItem>(
|
|
127
|
-
|
|
131
|
+
(initialSelection?.value ?? items.value?.[0]) || null
|
|
128
132
|
)
|
|
129
|
-
|
|
130
133
|
const table = ref()
|
|
131
134
|
const handleRowClick = (event: MouseEvent, item: DlLabelPickerItem) => {
|
|
132
135
|
table.value.$el
|
|
@@ -203,9 +206,9 @@ export default defineComponent({
|
|
|
203
206
|
|
|
204
207
|
onMounted(() => {
|
|
205
208
|
nextTick(() => {
|
|
206
|
-
if (
|
|
209
|
+
if (currentSelectedLabel.value.identifier) {
|
|
207
210
|
const target = table.value.$el.querySelector(
|
|
208
|
-
`[data-label-picker-identifier="${
|
|
211
|
+
`[data-label-picker-identifier="${currentSelectedLabel.value.identifier}"]`
|
|
209
212
|
)
|
|
210
213
|
target?.closest('tr')?.classList.add('selected')
|
|
211
214
|
}
|
|
@@ -77,10 +77,16 @@
|
|
|
77
77
|
</dl-tooltip>
|
|
78
78
|
<div v-if="hasSelectedSlot" style="width: 100%">
|
|
79
79
|
<slot
|
|
80
|
-
v-if="
|
|
80
|
+
v-if="shouldShowSelectedSlotContent"
|
|
81
81
|
:opt="selectedOption"
|
|
82
82
|
name="selected"
|
|
83
83
|
/>
|
|
84
|
+
<span
|
|
85
|
+
v-else-if="!isActiveSearchInput"
|
|
86
|
+
class="root-container--placeholder"
|
|
87
|
+
>
|
|
88
|
+
{{ filterSelectLabel }}
|
|
89
|
+
</span>
|
|
84
90
|
</div>
|
|
85
91
|
<template v-else>
|
|
86
92
|
<span
|
|
@@ -477,6 +483,14 @@ export default defineComponent({
|
|
|
477
483
|
}
|
|
478
484
|
|
|
479
485
|
const hasSlotByName = (name: string) => !!slots[name]
|
|
486
|
+
const hasSlotContent = (name: string) => {
|
|
487
|
+
const slot = slots[name]
|
|
488
|
+
if (slot) {
|
|
489
|
+
const newSlot = typeof slot === 'function' ? slot() : slot
|
|
490
|
+
return newSlot?.length > 0
|
|
491
|
+
}
|
|
492
|
+
return false
|
|
493
|
+
}
|
|
480
494
|
|
|
481
495
|
return {
|
|
482
496
|
uuid: `dl-select-${v4()}`,
|
|
@@ -489,7 +503,8 @@ export default defineComponent({
|
|
|
489
503
|
handleModelValueUpdate,
|
|
490
504
|
searchTerm, // todo: merge this sometime
|
|
491
505
|
searchInputValue,
|
|
492
|
-
hasSlotByName
|
|
506
|
+
hasSlotByName,
|
|
507
|
+
hasSlotContent
|
|
493
508
|
}
|
|
494
509
|
},
|
|
495
510
|
computed: {
|
|
@@ -650,6 +665,15 @@ export default defineComponent({
|
|
|
650
665
|
hasSelectedSlot(): boolean {
|
|
651
666
|
return !!this.hasSlotByName('selected')
|
|
652
667
|
},
|
|
668
|
+
hasSelectedSlotContent(): boolean {
|
|
669
|
+
return this.hasSlotContent('selected')
|
|
670
|
+
},
|
|
671
|
+
isActiveSearchInput(): boolean {
|
|
672
|
+
return this.searchable && this.isExpanded
|
|
673
|
+
},
|
|
674
|
+
shouldShowSelectedSlotContent(): boolean {
|
|
675
|
+
return this.hasSelectedSlotContent && !this.isActiveSearchInput
|
|
676
|
+
},
|
|
653
677
|
computedPlaceholder(): string {
|
|
654
678
|
return this.placeholder || 'Select option'
|
|
655
679
|
},
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
title: '',
|
|
8
8
|
icon: ''
|
|
9
9
|
}"
|
|
10
|
+
:initial-selection="initialSelection"
|
|
10
11
|
hide-bottom
|
|
11
12
|
hide-no-data
|
|
12
13
|
@selected-label="setSelectedEvent"
|
|
@@ -72,11 +73,12 @@ export default defineComponent({
|
|
|
72
73
|
},
|
|
73
74
|
setup() {
|
|
74
75
|
const items = ref(rows)
|
|
76
|
+
const initialSelection = ref(rows[1])
|
|
75
77
|
const lastSelected = ref<DlLabelPickerItem>(null)
|
|
76
78
|
const setSelectedEvent = (item: DlLabelPickerItem) => {
|
|
77
79
|
lastSelected.value = item
|
|
78
80
|
}
|
|
79
|
-
return { items, lastSelected, setSelectedEvent }
|
|
81
|
+
return { items, lastSelected, setSelectedEvent, initialSelection }
|
|
80
82
|
}
|
|
81
83
|
})
|
|
82
84
|
</script>
|