@dataloop-ai/components 0.17.120 → 0.17.122

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.17.120",
3
+ "version": "0.17.122",
4
4
  "exports": {
5
5
  ".": "./index.ts",
6
6
  "./models": "./models.ts",
@@ -97,7 +97,7 @@ export default defineComponent({
97
97
  * The color of the button
98
98
  */
99
99
  color: {
100
- type: String! as PropType<keyof typeof colorNames>,
100
+ type: String! as PropType<keyof typeof colorNames | string>,
101
101
  default: ''
102
102
  },
103
103
  /**
@@ -1,7 +1,7 @@
1
1
  import { getColor } from '../../../utils'
2
2
  import { getLighterGradient } from '../../../utils/getLighterGradient'
3
3
 
4
- export type ButtonSizes = 's' | 'm' | 'l' | 'xl'
4
+ export type ButtonSizes = 's' | 'm' | 'l' | 'xl' | string
5
5
 
6
6
  const paddings = {
7
7
  s: '7px 16px',
@@ -9,6 +9,7 @@
9
9
  class="dl-smart-search__input-wrapper"
10
10
  >
11
11
  <dl-smart-search-input
12
+ ref="smartSearchInput"
12
13
  :status="computedStatus"
13
14
  :style-model="defineStyleModel"
14
15
  :with-save-button="true"
@@ -27,40 +28,44 @@
27
28
  />
28
29
  </div>
29
30
  <div class="dl-smart-search__buttons">
30
- <div
31
- style="height: 28px"
32
- class="dl-smart-search__search-btn-wrapper"
33
- >
34
- <dl-button
35
- icon="icon-dl-search"
36
- :styles="{
37
- height: '28px'
38
- }"
39
- :disabled="disabled"
40
- @click="emitSearchQuery"
41
- />
42
- </div>
43
-
44
- <dl-button
45
- class="dl-smart-search__buttons--filters"
46
- shaded
47
- outlined
48
- size="s"
49
- >
50
- Saved Filters
51
- <dl-menu
52
- v-model="filtersModel"
53
- :offset="[0, 5]"
54
- anchor="bottom middle"
55
- self="top middle"
31
+ <slot name="buttons">
32
+ <div
33
+ style="height: 28px"
34
+ class="dl-smart-search__search-btn-wrapper"
56
35
  >
57
- <dl-smart-search-filters
58
- :filters="filters"
59
- @filters-select="handleFiltersSelect"
60
- @filters-delete="handleFiltersDelete"
36
+ <dl-button
37
+ icon="icon-dl-search"
38
+ :styles="{
39
+ height: '28px'
40
+ }"
41
+ :disabled="disabled"
42
+ @click="emitSearchQuery"
61
43
  />
62
- </dl-menu>
63
- </dl-button>
44
+ </div>
45
+
46
+ <slot name="extra-actions" />
47
+
48
+ <dl-button
49
+ class="dl-smart-search__buttons--filters"
50
+ shaded
51
+ outlined
52
+ size="s"
53
+ >
54
+ Saved Filters
55
+ <dl-menu
56
+ v-model="filtersModel"
57
+ :offset="[0, 5]"
58
+ anchor="bottom middle"
59
+ self="top middle"
60
+ >
61
+ <dl-smart-search-filters
62
+ :filters="filters"
63
+ @filters-select="handleFiltersSelect"
64
+ @filters-delete="handleFiltersDelete"
65
+ />
66
+ </dl-menu>
67
+ </dl-button>
68
+ </slot>
64
69
  </div>
65
70
  <dl-dialog-box
66
71
  v-model="jsonEditorModel"
@@ -222,7 +227,13 @@ import {
222
227
  Alias,
223
228
  removeBrackets
224
229
  } from '../../../../hooks/use-suggestions'
225
- import { Filters, Query, ColorSchema, SearchStatus } from './types'
230
+ import {
231
+ Filters,
232
+ Query,
233
+ ColorSchema,
234
+ SearchStatus,
235
+ SyntaxColorSchema
236
+ } from './types'
226
237
  import {
227
238
  replaceAliases,
228
239
  setAliases,
@@ -480,11 +491,8 @@ export default defineComponent({
480
491
  '--dl-search-max-width': this.isFocused ? '100%' : this.width
481
492
  }
482
493
  },
483
- defineStyleModel(): Record<string, string> {
484
- return createColorSchema(
485
- this.colorSchema,
486
- this.aliases
487
- ) as any as Record<string, string>
494
+ defineStyleModel(): SyntaxColorSchema {
495
+ return createColorSchema(this.colorSchema, this.aliases)
488
496
  },
489
497
  computedStatus(): SearchStatus {
490
498
  if (this.isQuerying) return
@@ -1,5 +1,6 @@
1
1
  <template>
2
2
  <div
3
+ :id="`DlSmartSearchInput${uuid}`"
3
4
  class="dl-smart-search-input"
4
5
  :style="cssVars"
5
6
  >
@@ -19,7 +20,7 @@
19
20
  </div>
20
21
  <div class="dl-smart-search-input__textarea-wrapper">
21
22
  <div
22
- id="editor"
23
+ :id="`dl-smart-search-input-text-area-${uuid}`"
23
24
  ref="input"
24
25
  :class="inputClass"
25
26
  :style="textareaStyles"
@@ -27,7 +28,7 @@
27
28
  :contenteditable="!disabled"
28
29
  @keypress="keyPress"
29
30
  @input="handleValueChange"
30
- @click="focus"
31
+ @click.stop.prevent="focus"
31
32
  @blur="blur"
32
33
  />
33
34
  </div>
@@ -104,6 +105,7 @@
104
105
  </div>
105
106
  <dl-suggestions-dropdown
106
107
  v-model="suggestionModal"
108
+ :parent-id="`${uuid}`"
107
109
  :disabled="disabled"
108
110
  :suggestions="suggestions"
109
111
  :offset="menuOffset"
@@ -144,6 +146,7 @@ import {
144
146
  updateEditor,
145
147
  isEligibleToChange
146
148
  } from '../utils'
149
+ import { v4 } from 'uuid'
147
150
 
148
151
  export default defineComponent({
149
152
  components: {
@@ -298,6 +301,7 @@ export default defineComponent({
298
301
  )
299
302
 
300
303
  return {
304
+ uuid: v4(),
301
305
  input,
302
306
  label,
303
307
  hasEllipsis,
@@ -455,9 +459,7 @@ export default defineComponent({
455
459
  }
456
460
 
457
461
  if (!this.suggestionModal && val.length > 0 && this.focused) {
458
- nextTick(() => {
459
- this.suggestionModal = true
460
- })
462
+ this.suggestionModal = true
461
463
  }
462
464
  },
463
465
  expanded(value) {
@@ -10,6 +10,7 @@
10
10
  fit-container
11
11
  :model-value="modelValue"
12
12
  :arrow-nav-items="suggestions"
13
+ :auto-close="false"
13
14
  @update:modelValue="emitModelValue($event)"
14
15
  @show="onShow"
15
16
  @hide="onHide"
@@ -31,7 +32,7 @@
31
32
  </div>
32
33
  </template>
33
34
  <script lang="ts">
34
- import { defineComponent, PropType, ref } from 'vue-demi'
35
+ import { computed, defineComponent, PropType, ref } from 'vue-demi'
35
36
  import { DlMenu, DlList } from '../../../../essential'
36
37
  import { DlListItem } from '../../../../basic'
37
38
 
@@ -46,6 +47,10 @@ export default defineComponent({
46
47
  event: 'update:modelValue'
47
48
  },
48
49
  props: {
50
+ parentId: {
51
+ type: String,
52
+ required: true
53
+ },
49
54
  expanded: {
50
55
  type: Boolean,
51
56
  default: false
@@ -91,7 +96,12 @@ export default defineComponent({
91
96
  emit('set-input-value', item)
92
97
  }
93
98
 
99
+ const defaultTarget = computed(() => {
100
+ return `#dl-smart-search-input-text-area-${props.parentId}`
101
+ })
102
+
94
103
  return {
104
+ defaultTarget,
95
105
  setHighlightedIndex,
96
106
  handleSelectedItem,
97
107
  highlightedIndex,
@@ -100,11 +110,6 @@ export default defineComponent({
100
110
  emitModelValue,
101
111
  handleOption
102
112
  }
103
- },
104
- computed: {
105
- defaultTarget() {
106
- return '.dl-smart-search-input__textarea'
107
- }
108
113
  }
109
114
  })
110
115
  </script>
@@ -34,3 +34,17 @@ export type SyntaxColorSchema = {
34
34
  color: string
35
35
  }
36
36
  }
37
+
38
+ import {
39
+ Alias as DlSmartSearchAlias,
40
+ Schema as DlSmartSearchSchema
41
+ } from '../../../../hooks/use-suggestions'
42
+
43
+ type DlSmartSearchFilters = Filters & { [key: string]: any }
44
+
45
+ export type {
46
+ DlSmartSearchAlias,
47
+ DlSmartSearchSchema,
48
+ ColorSchema as DlSmartSearchColorSchema,
49
+ DlSmartSearchFilters
50
+ }
@@ -22,7 +22,7 @@
22
22
  <div
23
23
  v-else
24
24
  :id="uuid"
25
- style="display: inline"
25
+ :style="[inlineStyles, computedStyles]"
26
26
  @click="$emit('click', $event)"
27
27
  @mousedown="$emit('mousedown', $event)"
28
28
  @mouseup="$emit('mouseup', $event)"
@@ -156,7 +156,7 @@ export default defineComponent({
156
156
 
157
157
  <style scoped lang="scss">
158
158
  .dl-icon {
159
- display: inline-block;
159
+ display: inline-flex;
160
160
  color: var(--dl-icon-color);
161
161
  font-size: var(--dl-icon-font-size);
162
162
  }
@@ -36,13 +36,26 @@
36
36
  @search-query="handleSearchQuery"
37
37
  />
38
38
  {{ queryObject }}
39
+
40
+ <br>
41
+ <br>
42
+ <br>
43
+ <br>
44
+ <br>
45
+ Test second if they work on same page..
46
+ <dl-smart-search
47
+ v-model="queryObject"
48
+ :aliases="[]"
49
+ :schema="schema2"
50
+ :color-schema="colorSchema"
51
+ />
39
52
  </div>
40
53
  </template>
41
54
 
42
55
  <script lang="ts">
43
56
  import { defineComponent } from 'vue-demi'
44
57
  import { DlSmartSearch, DlCheckbox, DlInput } from '../../components'
45
- import { Query } from '../../components/types'
58
+ import { DlSmartSearchFilters, Query } from '../../components/types'
46
59
  import { parseSmartQuery } from '../../utils'
47
60
 
48
61
  export default defineComponent({
@@ -76,6 +89,43 @@ export default defineComponent({
76
89
  '*': 'any'
77
90
  }
78
91
  }
92
+ const schema2: any = {
93
+ type: [
94
+ 'class',
95
+ 'point',
96
+ 'line',
97
+ 'box',
98
+ 'cube',
99
+ 'segment',
100
+ 'ellipse',
101
+ 'binary',
102
+ 'note',
103
+ 'polyline',
104
+ 'comparison',
105
+ 'recording',
106
+ 'subtitle',
107
+ 'item_description',
108
+ 'text_mark',
109
+ 'pose',
110
+ 'cube_3d',
111
+ 'semantic_3d',
112
+ 'polyline_3d',
113
+ 'string'
114
+ ],
115
+ label: 'string',
116
+ itemId: 'string',
117
+ creator: 'string',
118
+ parentId: ['null', 'string'],
119
+ attributes: ['string', 'number', 'object', 'boolean'],
120
+ metadata: {
121
+ system: {
122
+ attributes: ['string', 'number', 'object', 'boolean'],
123
+ status: 'string',
124
+ '*': 'any'
125
+ },
126
+ '*': 'any'
127
+ }
128
+ }
79
129
 
80
130
  const colorSchema: any = {
81
131
  fields: 'var(--dl-color-secondary)',
@@ -98,8 +148,32 @@ export default defineComponent({
98
148
  }
99
149
  ]
100
150
 
151
+ const filters: DlSmartSearchFilters = {
152
+ saved: [
153
+ {
154
+ name: 'Query 1',
155
+ query: '{"q": 1}'
156
+ },
157
+ {
158
+ name: 'Query 2',
159
+ query: '{"query2": "query2"}'
160
+ },
161
+ {
162
+ name: 'Query 3',
163
+ query: '{"query3": "query3"}'
164
+ },
165
+ {
166
+ name: 'Query 4',
167
+ query: '{"age": 12, "name": "john"}'
168
+ }
169
+ ],
170
+ recent: [],
171
+ suggested: []
172
+ }
173
+
101
174
  return {
102
175
  schema,
176
+ schema2,
103
177
  aliases,
104
178
  colorSchema,
105
179
  switchState: false,
@@ -107,28 +181,7 @@ export default defineComponent({
107
181
  isLoading: false,
108
182
  queryObject: {},
109
183
  textQuery: '',
110
- filters: {
111
- saved: [
112
- {
113
- name: 'Query 1',
114
- query: '{"q": 1}'
115
- },
116
- {
117
- name: 'Query 2',
118
- query: '{"query2": "query2"}'
119
- },
120
- {
121
- name: 'Query 3',
122
- query: '{"query3": "query3"}'
123
- },
124
- {
125
- name: 'Query 4',
126
- query: '{"age": 12, "name": "john"}'
127
- }
128
- ],
129
- recent: [],
130
- suggested: []
131
- } as { [key: string]: Query[] }
184
+ filters
132
185
  }
133
186
  },
134
187
  watch: {
@@ -162,7 +215,6 @@ export default defineComponent({
162
215
  this.filters[type].push(query)
163
216
  }
164
217
  },
165
-
166
218
  handleRemoveQuery(query: Query, type: string) {
167
219
  this.filters[type] = this.filters[type].filter(
168
220
  (q: Query) => q.name !== query.name
@@ -17,6 +17,7 @@ interface AnchorEvent extends KeyboardEvent {
17
17
 
18
18
  export const useAnchorProps = {
19
19
  target: {
20
+ type: [String, Boolean],
20
21
  default: true
21
22
  },
22
23
  noParentEvent: Boolean,
@@ -144,7 +145,6 @@ export default function ({
144
145
  setAnchorEl(proxy.$el.parentNode as HTMLElement)
145
146
  } else {
146
147
  let el = props.target
147
-
148
148
  if (typeof props.target === 'string') {
149
149
  try {
150
150
  el = document.querySelector(props.target)