@dataloop-ai/components 0.18.66 → 0.18.67

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.
@@ -1,4 +1,3 @@
1
- import { DlSmartSearchInput } from './components'
2
1
  import DlSmartSearch from './DlSmartSearch.vue'
3
2
 
4
- export { DlSmartSearch, DlSmartSearchInput }
3
+ export { DlSmartSearch }
@@ -5,6 +5,9 @@ const SPAN_STYLES = `overflow: hidden;
5
5
  display: inline-block;
6
6
  max-width: 100%`
7
7
 
8
+ let editor = document.getElementById('editor')
9
+ let styleModel: SyntaxColorSchema
10
+
8
11
  function getTextSegments(element: HTMLElement) {
9
12
  if (!element) return
10
13
  const textSegments: { text: string; node: Node }[] = []
@@ -29,12 +32,10 @@ function getTextSegments(element: HTMLElement) {
29
32
  return textSegments
30
33
  }
31
34
 
32
- export function updateEditor(
33
- editor: HTMLElement,
34
- colorSchema: SyntaxColorSchema
35
- ) {
35
+ export function updateEditor(model: SyntaxColorSchema) {
36
+ styleModel = model
37
+ editor = document.getElementById('editor')
36
38
  if (!editor) return
37
-
38
39
  const sel = window.getSelection()
39
40
  const textSegments = getTextSegments(editor)
40
41
  const textContent = textSegments?.map(({ text }) => text).join('')
@@ -51,13 +52,12 @@ export function updateEditor(
51
52
  currentIndex += text.length
52
53
  })
53
54
 
54
- editor.innerHTML = renderText(textContent, colorSchema)
55
+ editor.innerHTML = renderText(textContent)
55
56
 
56
- restoreSelection(editor, anchorIndex, focusIndex)
57
+ restoreSelection(anchorIndex, focusIndex)
57
58
  }
58
59
 
59
60
  function restoreSelection(
60
- editor: HTMLElement,
61
61
  absoluteAnchorIndex: number,
62
62
  absoluteFocusIndex: number
63
63
  ) {
@@ -91,16 +91,16 @@ function restoreSelection(
91
91
  sel.setBaseAndExtent(anchorNode, anchorIndex, focusNode, focusIndex)
92
92
  }
93
93
 
94
- function renderText(text: string, colorSchema: SyntaxColorSchema) {
94
+ function renderText(text: string) {
95
95
  const words = text?.split(/(\s+)/)
96
96
  const output = words?.map((word) => {
97
- if (colorSchema) {
98
- if (colorSchema.keywords.values.includes(word)) {
99
- return `<strong style='${SPAN_STYLES}; color:${colorSchema.keywords.color}'>${word}</strong>`
100
- } else if (colorSchema.fields.values.includes(word)) {
101
- return `<span style='color:${colorSchema.fields.color}; ${SPAN_STYLES}'>${word}</span>`
102
- } else if (colorSchema.operators.values.includes(word)) {
103
- return `<span style='color:${colorSchema.operators.color}; ${SPAN_STYLES}'>${word}</span>`
97
+ if (styleModel) {
98
+ if (styleModel.keywords.values.includes(word)) {
99
+ return `<strong style='${SPAN_STYLES}; color:${styleModel.keywords.color}'>${word}</strong>`
100
+ } else if (styleModel.fields.values.includes(word)) {
101
+ return `<span style='color:${styleModel.fields.color}; ${SPAN_STYLES}'>${word}</span>`
102
+ } else if (styleModel.operators.values.includes(word)) {
103
+ return `<span style='color:${styleModel.operators.color}; ${SPAN_STYLES}'>${word}</span>`
104
104
  } else {
105
105
  return `<span style='${SPAN_STYLES}'>${word}</span>`
106
106
  }
@@ -9,8 +9,8 @@ import {
9
9
  datePatternNoBrackets,
10
10
  removeBrackets
11
11
  } from '../../../../../hooks/use-suggestions'
12
+ import { flatten, unflatten } from 'flat'
12
13
  import moment from 'moment'
13
- import { cloneDeep } from 'lodash'
14
14
 
15
15
  export const isEndOfString = (
16
16
  str: string,
@@ -109,26 +109,21 @@ export function replaceJSDatesWithStringifiedDates(
109
109
  return json
110
110
  }
111
111
 
112
- const toReturn = cloneDeep(json)
113
-
114
- for (const key of Object.keys(toReturn)) {
115
- if (typeof toReturn[key] === 'object') {
116
- toReturn[key] = replaceJSDatesWithStringifiedDates(
117
- toReturn[key],
118
- dateKeys
119
- )
112
+ for (const key of Object.keys(json)) {
113
+ if (typeof json[key] === 'object') {
114
+ json[key] = replaceJSDatesWithStringifiedDates(json[key], dateKeys)
120
115
  continue
121
116
  }
122
117
 
123
- const value = toReturn[key]
118
+ const value = json[key]
124
119
  const keyToCheck = key.split('.').pop()
125
120
 
126
121
  if (dateKeys.includes(keyToCheck)) {
127
- toReturn[key] = formatToStringDate(value)
122
+ json[key] = formatToStringDate(value)
128
123
  }
129
124
  }
130
125
 
131
- return toReturn
126
+ return json
132
127
  }
133
128
 
134
129
  export function revertAliases(json: string, aliases: Alias[]) {
@@ -231,13 +231,14 @@ export default defineComponent({
231
231
  }
232
232
  },
233
233
  methods: {
234
- handleChange(value: string) {
234
+ handleChange(value: number) {
235
235
  this.$emit('change', value)
236
236
  },
237
237
  handleResetButtonClick() {
238
238
  if (this.value === this.initialValue) return
239
239
 
240
240
  this.sliderValue = this.initialValue
241
+ this.handleChange(this.initialValue)
241
242
  }
242
243
  }
243
244
  })
@@ -13,4 +13,3 @@ export * from './DlCodeEditor/types'
13
13
  export * from './DlCard/types'
14
14
  export * from './DlThumbnailGallery/types'
15
15
  export * from './DlCounters/types'
16
- export * from './DlSelect/types'
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <div>
3
3
  <dl-slider
4
- v-model.number="value"
4
+ v-model="value"
5
5
  width="500px"
6
6
  text="slider"
7
7
  :step="1"
@@ -10,6 +10,7 @@
10
10
  :editable="editable"
11
11
  :readonly="readonly"
12
12
  :disabled="disabled"
13
+ @change="handleChange"
13
14
  />
14
15
  <div>
15
16
  <button @click="editable = !editable">
@@ -42,6 +43,16 @@ export default defineComponent({
42
43
  readonly: false
43
44
  }
44
45
  },
46
+ watch: {
47
+ value(newValue, oldValue) {
48
+ console.log(`@@@ value changed from ${oldValue} to ${newValue}`)
49
+ }
50
+ },
51
+ methods: {
52
+ handleChange(value: number) {
53
+ console.log(`@@@ value changed to ${value}`)
54
+ }
55
+ },
45
56
  template: 'dl-slider-demo'
46
57
  })
47
58
  </script>
@@ -32,7 +32,6 @@
32
32
  :disabled="switchState"
33
33
  :is-loading="isLoading"
34
34
  :strict="strictState"
35
- style="width: 600px"
36
35
  @remove-query="handleRemoveQuery"
37
36
  @save-query="handleSaveQuery"
38
37
  @search-query="handleSearchQuery"
@@ -43,28 +42,20 @@
43
42
  <br>
44
43
  <br>
45
44
  <br>
46
- Only the search
47
-
48
- <dl-smart-search-input
45
+ <br>
46
+ Test second if they work on same page..
47
+ <dl-smart-search
49
48
  v-model="queryObject2"
50
- :aliases="aliases"
51
- :schema="schema"
49
+ :aliases="[]"
50
+ :schema="schema2"
52
51
  :color-schema="colorSchema"
53
- :strict="strictState"
54
- :disabled="switchState"
55
52
  />
56
- {{ queryObject2 }}
57
53
  </div>
58
54
  </template>
59
55
 
60
56
  <script lang="ts">
61
57
  import { defineComponent } from 'vue-demi'
62
- import {
63
- DlSmartSearch,
64
- DlSmartSearchInput,
65
- DlCheckbox,
66
- DlInput
67
- } from '../../components'
58
+ import { DlSmartSearch, DlCheckbox, DlInput } from '../../components'
68
59
  import { DlSmartSearchFilters, Query } from '../../components/types'
69
60
  import { parseSmartQuery } from '../../utils'
70
61
 
@@ -72,7 +63,6 @@ export default defineComponent({
72
63
  name: 'DlSmartSearchDemo',
73
64
  components: {
74
65
  DlSmartSearch,
75
- DlSmartSearchInput,
76
66
  DlCheckbox,
77
67
  DlInput
78
68
  },
@@ -43,11 +43,7 @@ const Operators: string[] = ['>=', '<=', '!=', '=', '>', '<', 'IN', 'NOT-IN']
43
43
  * @param { string } query DlSmartSearch query string
44
44
  * @returns Mongo based JSON
45
45
  */
46
- export const parseSmartQuery = (
47
- query: string
48
- ): {
49
- [key: string]: any
50
- } => {
46
+ export const parseSmartQuery = (query: string) => {
51
47
  const queryArr = query.split(' OR ')
52
48
  for (let i = 0; i < queryArr.length; i++) {
53
49
  const term: string = queryArr[i]
@@ -66,7 +62,7 @@ export const parseSmartQuery = (
66
62
  const orTerms: { [key: string]: any }[] = []
67
63
 
68
64
  for (const query of queryArr) {
69
- const andTerms = query.split(' AND ').filter((q) => !!q.length)
65
+ const andTerms = query.split(' AND ')
70
66
  for (let i = 0; i < andTerms.length; i++) {
71
67
  const term: string = andTerms[i]
72
68
  let withOperator = false
@@ -192,7 +188,7 @@ export const parseSmartQuery = (
192
188
  * @param { { [key: string]: any } } query Mongo based JSON that represents a query
193
189
  * @returns DlSmartSearch query string
194
190
  */
195
- export const stringifySmartQuery = (query: { [key: string]: any }): string => {
191
+ export const stringifySmartQuery = (query: { [key: string]: any }) => {
196
192
  let result = ''
197
193
 
198
194
  for (const key in query) {
@@ -1,4 +0,0 @@
1
- export interface DlSelectOption {
2
- label: string
3
- value: any
4
- }