@dataloop-ai/components 0.17.123 → 0.17.125

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.123",
3
+ "version": "0.17.125",
4
4
  "exports": {
5
5
  ".": "./index.ts",
6
6
  "./models": "./models.ts",
@@ -29,42 +29,44 @@
29
29
  </div>
30
30
  <div class="dl-smart-search__buttons">
31
31
  <slot name="buttons">
32
- <div
33
- style="height: 28px"
34
- class="dl-smart-search__search-btn-wrapper"
35
- >
36
- <dl-button
37
- icon="icon-dl-search"
38
- :styles="{
39
- height: '28px'
40
- }"
41
- :disabled="disabled"
42
- @click="emitSearchQuery"
43
- />
44
- </div>
32
+ <div style="display: flex; align-items: center">
33
+ <div
34
+ style="height: 28px"
35
+ class="dl-smart-search__search-btn-wrapper"
36
+ >
37
+ <dl-button
38
+ icon="icon-dl-search"
39
+ :styles="{
40
+ height: '28px'
41
+ }"
42
+ :disabled="disabled"
43
+ @click="emitSearchQuery"
44
+ />
45
+ </div>
45
46
 
46
- <slot name="extra-actions" />
47
+ <slot name="extra-actions" />
47
48
 
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"
49
+ <dl-button
50
+ class="dl-smart-search__buttons--filters"
51
+ shaded
52
+ outlined
53
+ size="s"
60
54
  >
61
- <dl-smart-search-filters
62
- :filters="filters"
63
- @filters-select="handleFiltersSelect"
64
- @filters-delete="handleFiltersDelete"
65
- />
66
- </dl-menu>
67
- </dl-button>
55
+ Saved Filters
56
+ <dl-menu
57
+ v-model="filtersModel"
58
+ :offset="[0, 5]"
59
+ anchor="bottom middle"
60
+ self="top middle"
61
+ >
62
+ <dl-smart-search-filters
63
+ :filters="filters"
64
+ @filters-select="handleFiltersSelect"
65
+ @filters-delete="handleFiltersDelete"
66
+ />
67
+ </dl-menu>
68
+ </dl-button>
69
+ </div>
68
70
  </slot>
69
71
  </div>
70
72
  <dl-dialog-box
@@ -235,7 +237,7 @@ import {
235
237
  SyntaxColorSchema
236
238
  } from './types'
237
239
  import {
238
- replaceAliases,
240
+ revertAliases,
239
241
  setAliases,
240
242
  replaceStringifiedDatesWithJSDates,
241
243
  createColorSchema,
@@ -354,9 +356,10 @@ export default defineComponent({
354
356
  )
355
357
 
356
358
  const handleInputModel = (value: string) => {
357
- inputModel.value = value
359
+ const aliased = setAliases(value, props.aliases)
360
+ inputModel.value = aliased
358
361
  const bracketless = removeBrackets(value)
359
- const cleanedAliases = replaceAliases(bracketless, props.aliases)
362
+ const cleanedAliases = revertAliases(bracketless, props.aliases)
360
363
  const json = toJSON(cleanedAliases)
361
364
  if (!isEqual(json, props.modelValue)) {
362
365
  emit('update:modelValue', json)
@@ -364,10 +367,10 @@ export default defineComponent({
364
367
  const stringified = JSON.stringify(json)
365
368
  activeQuery.value.query = stringified
366
369
  nextTick(() => {
367
- findSuggestions(value)
370
+ findSuggestions(aliased)
368
371
  })
369
372
  isQuerying.value = false
370
- oldInputQuery.value = value
373
+ oldInputQuery.value = aliased
371
374
  }
372
375
 
373
376
  const debouncedInputModel = debounce(handleInputModel, 300)
@@ -548,7 +551,7 @@ export default defineComponent({
548
551
  const json = JSON.stringify(
549
552
  this.toJSON(removeBrackets(this.inputModel))
550
553
  )
551
- const newQuery = replaceAliases(json, this.aliases)
554
+ const newQuery = revertAliases(json, this.aliases)
552
555
  if (newQuery && newQuery !== '{}') {
553
556
  this.jsonEditorQuery = newQuery
554
557
  }
@@ -268,11 +268,25 @@ export default defineComponent({
268
268
  .join(' ')
269
269
  .replace(' ', ' ')
270
270
  } else {
271
- query.splice(-1)
271
+ if (query[query.length - 1].endsWith('.')) {
272
+ query[query.length - 1] = query[
273
+ query.length - 1
274
+ ].replace('.', '')
275
+ } else {
276
+ query.splice(-1)
277
+ }
272
278
  stringValue = [...query, value, ''].join(' ')
273
279
  }
274
280
  } else {
275
- stringValue = [value, ''].join(' ')
281
+ if (query[query.length - 1].endsWith('.')) {
282
+ query[query.length - 1] = query[query.length - 1].replace(
283
+ '.',
284
+ ''
285
+ )
286
+ stringValue = [...query, value, ''].join(' ')
287
+ } else {
288
+ stringValue = [value, ''].join(' ')
289
+ }
276
290
  }
277
291
 
278
292
  // to handle date suggestion modal to open automatically.
@@ -283,6 +297,7 @@ export default defineComponent({
283
297
  const specialSuggestions = props.suggestions.filter((suggestion) =>
284
298
  suggestion.startsWith('.')
285
299
  )
300
+
286
301
  for (const suggestion of specialSuggestions) {
287
302
  if (stringValue.includes(suggestion)) {
288
303
  stringValue = stringValue.replace(
@@ -109,26 +109,29 @@ export function replaceJSDatesWithStringifiedDates(
109
109
  return json
110
110
  }
111
111
 
112
- const flat: { [key: string]: any } = flatten(json)
113
- for (const key of Object.keys(flat)) {
114
- const value = flat[key]
112
+ for (const key of Object.keys(json)) {
113
+ if (typeof json[key] === 'object') {
114
+ json[key] = replaceJSDatesWithStringifiedDates(json[key], dateKeys)
115
+ continue
116
+ }
117
+
118
+ const value = json[key]
115
119
  const keyToCheck = key.split('.').pop()
116
120
 
117
121
  if (dateKeys.includes(keyToCheck)) {
118
- flat[key] = formatToStringDate(value)
122
+ json[key] = formatToStringDate(value)
119
123
  }
120
124
  }
121
125
 
122
- return unflatten(flat) as {
123
- [key: string]: any
124
- }
126
+ return json
125
127
  }
126
128
 
127
- export function replaceAliases(json: string, aliases: Alias[]) {
129
+ export function revertAliases(json: string, aliases: Alias[]) {
128
130
  let newJson = json
129
- aliases.forEach((alias) => {
130
- newJson = newJson.replaceAll(alias.alias, alias.key)
131
- })
131
+ for (const alias of aliases) {
132
+ const regex = new RegExp(`${alias.alias}`, 'gi')
133
+ newJson = newJson.replace(regex, alias.key)
134
+ }
132
135
  return newJson
133
136
  }
134
137
 
@@ -53,7 +53,6 @@ export default defineComponent({
53
53
 
54
54
  <style scoped lang="scss">
55
55
  .dl-item__section {
56
- display: flex;
57
56
  padding-left: 0;
58
57
  padding-right: 0;
59
58
  font-size: var(--dl-font-size-body);
@@ -16,6 +16,20 @@
16
16
  label="Option 3"
17
17
  :value="3"
18
18
  />
19
+ disabled
20
+
21
+ <dl-radio
22
+ v-model="disabledModel"
23
+ label="Option Disabled"
24
+ :value="4"
25
+ disabled
26
+ />
27
+ <dl-radio
28
+ v-model="disabledModel"
29
+ label="Option Disabled not selected"
30
+ :value="5"
31
+ disabled
32
+ />
19
33
  </div>
20
34
  </template>
21
35
 
@@ -28,7 +42,8 @@ export default {
28
42
  },
29
43
  data() {
30
44
  return {
31
- checkModel: 1
45
+ checkModel: 1,
46
+ disabledModel: 4
32
47
  }
33
48
  }
34
49
  }
@@ -22,6 +22,7 @@
22
22
  style="width: 100px"
23
23
  class="props"
24
24
  />
25
+ { "metadata.system.width": 5 }
25
26
  <dl-smart-search
26
27
  v-model="queryObject"
27
28
  :aliases="aliases"
@@ -44,7 +45,7 @@
44
45
  <br>
45
46
  Test second if they work on same page..
46
47
  <dl-smart-search
47
- v-model="queryObject"
48
+ v-model="queryObject2"
48
49
  :aliases="[]"
49
50
  :schema="schema2"
50
51
  :color-schema="colorSchema"
@@ -180,6 +181,7 @@ export default defineComponent({
180
181
  strictState: false,
181
182
  isLoading: false,
182
183
  queryObject: {},
184
+ queryObject2: {},
183
185
  textQuery: '',
184
186
  filters
185
187
  }