@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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dataloop-ai/components",
3
- "version": "0.19.74",
3
+ "version": "0.19.76",
4
4
  "exports": {
5
5
  ".": "./index.ts",
6
6
  "./models": "./models.ts",
@@ -578,7 +578,7 @@ export default defineComponent({
578
578
  )
579
579
  }
580
580
  },
581
- selectedOption(): string | Record<string, string | number> | number {
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: string | Record<string, string | number> | number) =>
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 | Record<string, any>
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
- export const getLabelOfSelectedOption = (
23
- valueToSearch: string,
24
- options: DlSelectOptionType[]
23
+ const isValueSelected = (
24
+ option: DlSelectOptionType,
25
+ selected: string[] | string
25
26
  ) => {
26
- if (options.length === 0) return ''
27
-
28
- if (typeof options[0] === 'string') {
29
- return options.find((opt) => opt === valueToSearch)
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
- return (options.find((opt: any) => opt.value === valueToSearch) as any)
33
- .label
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'
@@ -8,7 +8,7 @@ import {
8
8
  } from '../types'
9
9
 
10
10
  export const useTableFilterProps = {
11
- filter: [String, Object],
11
+ filter: String,
12
12
  filterMethod: Function
13
13
  }
14
14
 
@@ -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) {