@dataloop-ai/components 0.18.20 → 0.18.21

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.18.20",
3
+ "version": "0.18.21",
4
4
  "exports": {
5
5
  ".": "./index.ts",
6
6
  "./models": "./models.ts",
@@ -324,7 +324,8 @@ import {
324
324
  getIconSize,
325
325
  optionsValidator,
326
326
  DlSelectOptionType,
327
- getLabelOfSelectedOption
327
+ getLabelOfSelectedOption,
328
+ getCaseInsensitiveInput
328
329
  } from './utils'
329
330
  import DlSelectOption from './components/DlSelectOption.vue'
330
331
  import { isEqual } from 'lodash'
@@ -836,14 +837,15 @@ export default defineComponent({
836
837
  this.$emit('search-input', searchValue)
837
838
  },
838
839
  getOptionHtml(option: DlSelectOptionType) {
839
- let label = `${this.getOptionLabel(option)}`
840
- if (this.capitalizedOptions) {
841
- label = label.toLowerCase()
842
- }
840
+ const label = `${this.getOptionLabel(option)}`
841
+ const toReplace = new RegExp(this.searchInputValue, 'gi')
843
842
 
844
843
  const highlightedHtml = label.replace(
845
- this.searchInputValue,
846
- `<span style="background: var(--dl-color-warning)">${this.searchInputValue}</span>`
844
+ toReplace,
845
+ `<span style="background: var(--dl-color-warning)">${getCaseInsensitiveInput(
846
+ label,
847
+ this.searchInputValue
848
+ )}</span>`
847
849
  )
848
850
  const html = `<span>${highlightedHtml}</span>`
849
851
 
@@ -44,3 +44,9 @@ export const optionsValidator = (opts: DlSelectOptionType[]) => {
44
44
  return keys.includes('value') && keys.includes('label')
45
45
  })
46
46
  }
47
+
48
+ export const getCaseInsensitiveInput = (label: string, input: string) => {
49
+ const inputRegexp = new RegExp(input, 'gi')
50
+ const position = label.search(inputRegexp)
51
+ return label.slice(position, input.length)
52
+ }