@dataloop-ai/components 0.20.20 → 0.20.22

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.20",
3
+ "version": "0.20.22",
4
4
  "exports": {
5
5
  ".": "./index.ts",
6
6
  "./models": "./models.ts",
@@ -17,7 +17,7 @@
17
17
  "lint": "eslint ./src --ext .ts,.vue ",
18
18
  "lint:fix": "eslint ./src --ext .ts,.vue --fix",
19
19
  "format": "prettier --write ./src",
20
- "lint-staged": "lint-staged",
20
+ "lint-staged": "npm run check-only && lint-staged",
21
21
  "test": "vitest",
22
22
  "test:coverage": "vitest run --coverage --silent",
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"
@@ -445,10 +445,11 @@ export default defineComponent({
445
445
  queryRightSide = queryRightSide.trimStart()
446
446
  } else {
447
447
  // this|situation: replace whatever is there on both sides with the value
448
- queryLeftSide = queryLeftSide.replace(
449
- /('[^']+'?|[^'\s]+)$/,
450
- ''
451
- )
448
+ if (/^[^']+('[^']?'[^']+)?'[^']+'?$/.test(queryLeftSide)) {
449
+ queryLeftSide = queryLeftSide.replace(/'[^']+'?$/, '')
450
+ } else {
451
+ queryLeftSide = queryLeftSide.replace(/[^'\s]+$/, '')
452
+ }
452
453
  queryRightSide =
453
454
  removeLeadingExpression(queryRightSide).trimStart()
454
455
  }
@@ -77,16 +77,14 @@
77
77
  </dl-tooltip>
78
78
  <div v-if="hasSelectedSlot" style="width: 100%">
79
79
  <slot
80
- v-if="shouldShowSelectedSlotContent"
80
+ v-if="!isActiveSearchInput"
81
81
  :opt="selectedOption"
82
82
  name="selected"
83
- />
84
- <span
85
- v-else-if="!isActiveSearchInput"
86
- class="root-container--placeholder"
87
83
  >
88
- {{ filterSelectLabel }}
89
- </span>
84
+ <span class="root-container--placeholder">
85
+ {{ filterSelectLabel }}
86
+ </span>
87
+ </slot>
90
88
  </div>
91
89
  <template v-else>
92
90
  <span
@@ -671,9 +669,6 @@ export default defineComponent({
671
669
  isActiveSearchInput(): boolean {
672
670
  return this.searchable && this.isExpanded
673
671
  },
674
- shouldShowSelectedSlotContent(): boolean {
675
- return this.hasSelectedSlotContent && !this.isActiveSearchInput
676
- },
677
672
  computedPlaceholder(): string {
678
673
  return this.placeholder || 'Select option'
679
674
  },
@@ -690,9 +685,34 @@ export default defineComponent({
690
685
  }
691
686
  },
692
687
  selectedOption(): DlSelectOptionType {
693
- return this.selectedIndex === -1
694
- ? this.computedPlaceholder
695
- : this.options[this.selectedIndex]
688
+ if (this.multiselect) {
689
+ if (this.modelValueLength === 1) {
690
+ return this.options.find((option: any) => {
691
+ return isEqual(
692
+ option.value,
693
+ Array.isArray(this.modelValue)
694
+ ? this.modelValue[0]
695
+ : this.modelValue
696
+ )
697
+ })
698
+ } else {
699
+ return {
700
+ label: this.filterSelectLabel,
701
+ value: this.modelValue,
702
+ readonly: true
703
+ }
704
+ }
705
+ }
706
+
707
+ if (this.selectedIndex === -1) {
708
+ return {
709
+ label: this.computedPlaceholder,
710
+ value: null,
711
+ readonly: true
712
+ }
713
+ }
714
+
715
+ return this.options[this.selectedIndex]
696
716
  },
697
717
  hasBeforeOptions(): boolean {
698
718
  return !!this.$slots['before-options']
@@ -625,6 +625,66 @@
625
625
  <dl-button label="Button" />
626
626
  </template>
627
627
  </dl-select>
628
+
629
+ Select with auto select selected
630
+ <dl-select
631
+ v-model="preSelectedValue"
632
+ width="84px"
633
+ without-borders
634
+ with-chips
635
+ align-right
636
+ searchable
637
+ :options="[
638
+ { label: 'High', value: 'high', bgColor: 'dl-color-negative' },
639
+ {
640
+ label: 'Medium',
641
+ value: 'medium',
642
+ bgColor: 'dl-color-warning',
643
+ textColor: 'dl-color-darker',
644
+ icon: 'icon-dl-search'
645
+ },
646
+ {
647
+ label: 'Low',
648
+ value: 'low',
649
+ bgColor: 'dl-color-positive',
650
+ textColor: 'dl-color-darker'
651
+ }
652
+ ]"
653
+ required
654
+ >
655
+ <template #selected="scope">
656
+ <dl-chip
657
+ :text-color="scope.opt.textColor"
658
+ :color="scope.opt.bgColor"
659
+ >
660
+ {{ scope.opt.label }}
661
+ </dl-chip>
662
+ </template>
663
+ <template #option="scope">
664
+ <div class="flex">
665
+ <dl-chip
666
+ :text-color="scope.opt.textColor"
667
+ :color="scope.opt.bgColor"
668
+ >
669
+ {{ scope.opt.label }}
670
+ </dl-chip>
671
+ </div>
672
+ </template>
673
+ </dl-select>
674
+
675
+ Select with multiselect auto expanded and fixed width and virtual scroll
676
+ with selected slot
677
+ <dl-select
678
+ v-model="selectedWithChildrenAndReadonly"
679
+ :options="alotOfOptionsExpanded"
680
+ multiselect
681
+ searchable
682
+ style="margin-bottom: 150px; width: 200px"
683
+ >
684
+ <template #selected="scope">
685
+ <div>{{ scope.opt.label }}</div>
686
+ </template>
687
+ </dl-select>
628
688
  </div>
629
689
  </template>
630
690
 
@@ -891,7 +951,8 @@ export default defineComponent({
891
951
  selectedWithChildrenCapitalized: [],
892
952
  tasksFilter: [],
893
953
  showAllOption: true,
894
- disabledSelected: 'disabled option'
954
+ disabledSelected: 'disabled option',
955
+ preSelectedValue: null
895
956
  }
896
957
  },
897
958
  computed: {
@@ -907,7 +968,7 @@ export default defineComponent({
907
968
  key: i,
908
969
  subLabel: 'not so high',
909
970
  label: 'High ' + i,
910
- value: 'high',
971
+ value: 'high' + i,
911
972
  bgColor: 'dl-color-negative'
912
973
  })
913
974
  }
@@ -922,7 +983,7 @@ export default defineComponent({
922
983
  key: i,
923
984
  subLabel: 'not so high',
924
985
  label: 'High ' + i,
925
- value: 'high',
986
+ value: 'high' + i,
926
987
  bgColor: 'dl-color-negative'
927
988
  })
928
989
  }