@dataloop-ai/components 0.19.74 → 0.19.76
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
|
@@ -578,7 +578,7 @@ export default defineComponent({
|
|
|
578
578
|
)
|
|
579
579
|
}
|
|
580
580
|
},
|
|
581
|
-
selectedOption():
|
|
581
|
+
selectedOption(): DlSelectOptionType {
|
|
582
582
|
return this.selectedIndex === -1
|
|
583
583
|
? this.computedPlaceholder
|
|
584
584
|
: this.options[this.selectedIndex]
|
|
@@ -719,12 +719,7 @@ export default defineComponent({
|
|
|
719
719
|
|
|
720
720
|
if (this.emitValue) {
|
|
721
721
|
this.selectedIndex = this.options.findIndex(
|
|
722
|
-
(
|
|
723
|
-
option:
|
|
724
|
-
| string
|
|
725
|
-
| Record<string, string | number>
|
|
726
|
-
| number
|
|
727
|
-
) =>
|
|
722
|
+
(option: DlSelectOptionType) =>
|
|
728
723
|
isEqual(
|
|
729
724
|
(option as any).value,
|
|
730
725
|
this.modelValue as string | number
|
|
@@ -735,19 +730,13 @@ export default defineComponent({
|
|
|
735
730
|
|
|
736
731
|
if (this.isModelValuePrimitiveType) {
|
|
737
732
|
this.selectedIndex = this.options.findIndex(
|
|
738
|
-
(
|
|
739
|
-
option:
|
|
740
|
-
| string
|
|
741
|
-
| Record<string, string | number>
|
|
742
|
-
| number
|
|
743
|
-
) => option === this.modelValue
|
|
733
|
+
(option: DlSelectOptionType) => option === this.modelValue
|
|
744
734
|
)
|
|
745
735
|
return
|
|
746
736
|
}
|
|
747
737
|
|
|
748
738
|
this.selectedIndex = this.options.findIndex(
|
|
749
|
-
(option:
|
|
750
|
-
isEqual(option, this.modelValue)
|
|
739
|
+
(option: DlSelectOptionType) => isEqual(option, this.modelValue)
|
|
751
740
|
)
|
|
752
741
|
},
|
|
753
742
|
handleSelectedItem(value: DlSelectOptionType) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { TInputSizes } from '../../../utils/input-sizes'
|
|
2
|
+
import { DlSelectOption } from './types'
|
|
2
3
|
|
|
3
|
-
export type DlSelectOptionType = string | number |
|
|
4
|
+
export type DlSelectOptionType = string | number | DlSelectOption
|
|
4
5
|
|
|
5
6
|
export const getLabel = (option: any) => {
|
|
6
7
|
if (typeof option === 'object' && 'label' in option) {
|
|
@@ -19,18 +20,38 @@ const ICON_SIZES = {
|
|
|
19
20
|
large: '16px'
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
const isValueSelected = (
|
|
24
|
+
option: DlSelectOptionType,
|
|
25
|
+
selected: string[] | string
|
|
25
26
|
) => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
let isSelected = false
|
|
28
|
+
if (!Array.isArray(selected)) {
|
|
29
|
+
isSelected =
|
|
30
|
+
selected === (typeof option === 'object' ? option.value : option)
|
|
31
|
+
} else {
|
|
32
|
+
selected.forEach((val) => {
|
|
33
|
+
isSelected =
|
|
34
|
+
val === (typeof option === 'object' ? option.value : option)
|
|
35
|
+
})
|
|
30
36
|
}
|
|
37
|
+
return isSelected
|
|
38
|
+
}
|
|
31
39
|
|
|
32
|
-
|
|
33
|
-
|
|
40
|
+
export const getLabelOfSelectedOption = (
|
|
41
|
+
selected: string[] | string,
|
|
42
|
+
options: DlSelectOptionType[] | string[]
|
|
43
|
+
): string | undefined => {
|
|
44
|
+
for (const option of options) {
|
|
45
|
+
if (typeof option === 'string' && typeof selected === 'string') {
|
|
46
|
+
return option
|
|
47
|
+
} else if (
|
|
48
|
+
typeof option === 'object' &&
|
|
49
|
+
isValueSelected(option, selected)
|
|
50
|
+
) {
|
|
51
|
+
return option.label
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return '1 Option Selected'
|
|
34
55
|
}
|
|
35
56
|
|
|
36
57
|
export const getIconSize = (size: TInputSizes) => ICON_SIZES[size] ?? '14px'
|
|
@@ -759,7 +759,7 @@ export default defineComponent({
|
|
|
759
759
|
// @ts-ignore
|
|
760
760
|
return defaultOptions.includes(this.selectedBySearch as any)
|
|
761
761
|
},
|
|
762
|
-
alotOfOptions(): DlSelectOptionType {
|
|
762
|
+
alotOfOptions(): DlSelectOptionType[] {
|
|
763
763
|
const arr = [] as any[]
|
|
764
764
|
|
|
765
765
|
for (let i = 0; i < 1000; ++i) {
|