@dataloop-ai/components 0.19.10 → 0.19.12
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 +1 -1
- package/src/components/compound/DlCharts/charts/DlConfusionMatrix/DlConfusionMatrix.vue +46 -22
- package/src/components/compound/DlSearches/DlSmartSearch/components/DlSmartSearchInput.vue +5 -2
- package/src/demos/DlConfusionMatrixDemo.vue +7 -1
- package/src/hooks/use-suggestions.ts +34 -12
- package/src/hooks/use-theme.ts +3 -3
package/package.json
CHANGED
|
@@ -54,7 +54,10 @@
|
|
|
54
54
|
class="legend-avatar"
|
|
55
55
|
:src="labelImages[index]"
|
|
56
56
|
>
|
|
57
|
-
<span
|
|
57
|
+
<span
|
|
58
|
+
v-else
|
|
59
|
+
class="label"
|
|
60
|
+
>
|
|
58
61
|
{{ label }}
|
|
59
62
|
</span>
|
|
60
63
|
<dl-tooltip :offset="[0, 0]">
|
|
@@ -121,10 +124,7 @@
|
|
|
121
124
|
</div>
|
|
122
125
|
</div>
|
|
123
126
|
</div>
|
|
124
|
-
<div
|
|
125
|
-
class="x-axis"
|
|
126
|
-
style="margin-top: 10px"
|
|
127
|
-
>
|
|
127
|
+
<div class="x-axis">
|
|
128
128
|
<div
|
|
129
129
|
v-for="(label, index) in visibleLabels"
|
|
130
130
|
:key="index"
|
|
@@ -133,6 +133,7 @@
|
|
|
133
133
|
flex-grow: 100;
|
|
134
134
|
width: 100%;
|
|
135
135
|
justify-content: center;
|
|
136
|
+
overflow: hidden;
|
|
136
137
|
"
|
|
137
138
|
>
|
|
138
139
|
<span
|
|
@@ -156,16 +157,20 @@
|
|
|
156
157
|
class="legend-avatar"
|
|
157
158
|
:src="labelImages[index]"
|
|
158
159
|
>
|
|
159
|
-
<span
|
|
160
|
+
<span
|
|
161
|
+
v-else
|
|
162
|
+
class="label"
|
|
163
|
+
>
|
|
160
164
|
{{ label }}
|
|
161
165
|
</span>
|
|
162
166
|
</span>
|
|
163
|
-
<dl-tooltip
|
|
164
|
-
self="top middle"
|
|
165
|
-
:offset="debouncedCalculateXAxisElOffset(index)"
|
|
166
|
-
>
|
|
167
|
-
{{ labelStrings[index] }}</dl-tooltip>
|
|
168
167
|
</span>
|
|
168
|
+
<dl-tooltip
|
|
169
|
+
self="top middle"
|
|
170
|
+
:offset="debouncedCalculateXAxisElOffset(index)"
|
|
171
|
+
>
|
|
172
|
+
{{ labelStrings[index] }}
|
|
173
|
+
</dl-tooltip>
|
|
169
174
|
</div>
|
|
170
175
|
</div>
|
|
171
176
|
<dl-brush
|
|
@@ -292,7 +297,7 @@ export default defineComponent({
|
|
|
292
297
|
},
|
|
293
298
|
setup(props) {
|
|
294
299
|
const vm = getCurrentInstance()
|
|
295
|
-
const { variables } = useThemeVariables()
|
|
300
|
+
const { variables, isDark = { value: false } } = useThemeVariables()
|
|
296
301
|
const currentBrushState = ref<{ min: number; max: number }>({
|
|
297
302
|
min: 0,
|
|
298
303
|
max: Math.min(props.matrix.length, props.cellDisplayLimit)
|
|
@@ -312,13 +317,22 @@ export default defineComponent({
|
|
|
312
317
|
}
|
|
313
318
|
|
|
314
319
|
const getCellTextColor = (value: number) => {
|
|
315
|
-
|
|
316
|
-
document.documentElement.getAttribute('data-theme') ===
|
|
317
|
-
'dark-mode'
|
|
318
|
-
if (isDark) return 'var(--dl-color-text-buttons)'
|
|
320
|
+
if (isDark.value) return 'var(--dl-color-text-buttons)'
|
|
319
321
|
return `var(--dl-color-text${value < 0.5 ? '-darker' : ''}-buttons)`
|
|
320
322
|
}
|
|
321
323
|
|
|
324
|
+
const gradationDarkColor = computed(() => {
|
|
325
|
+
return isDark.value
|
|
326
|
+
? getCellBackground()
|
|
327
|
+
: 'var(--dl-color-secondary)'
|
|
328
|
+
})
|
|
329
|
+
|
|
330
|
+
const gradationLightColor = computed(() => {
|
|
331
|
+
return isDark.value
|
|
332
|
+
? 'var(--dl-color-text-darker-buttons)'
|
|
333
|
+
: 'var(--dl-color-text-buttons)'
|
|
334
|
+
})
|
|
335
|
+
|
|
322
336
|
const calculateXAxisElOffset = (index: number): number[] => {
|
|
323
337
|
let el = vm.refs[`xAxis-${index}`] as HTMLElement
|
|
324
338
|
if (!el) return null
|
|
@@ -330,7 +344,7 @@ export default defineComponent({
|
|
|
330
344
|
}
|
|
331
345
|
const height = el.clientHeight
|
|
332
346
|
const offsetHeight = -1 * (height / 2)
|
|
333
|
-
return [0, offsetHeight]
|
|
347
|
+
return [0, offsetHeight + 30]
|
|
334
348
|
}
|
|
335
349
|
|
|
336
350
|
const debouncedCalculateXAxisElOffset = computed(() => {
|
|
@@ -350,7 +364,9 @@ export default defineComponent({
|
|
|
350
364
|
rotateXLabels,
|
|
351
365
|
calculateXAxisElOffset,
|
|
352
366
|
debouncedCalculateXAxisElOffset,
|
|
353
|
-
isDisposed
|
|
367
|
+
isDisposed,
|
|
368
|
+
gradationDarkColor,
|
|
369
|
+
gradationLightColor
|
|
354
370
|
}
|
|
355
371
|
},
|
|
356
372
|
computed: {
|
|
@@ -384,7 +400,8 @@ export default defineComponent({
|
|
|
384
400
|
return {
|
|
385
401
|
'--matrix-rows': this.matrix.length,
|
|
386
402
|
'--cell-dimensions': `${this.cellWidth}px`,
|
|
387
|
-
'--
|
|
403
|
+
'--gradation-dark': this.gradationDarkColor,
|
|
404
|
+
'--gradation-light': this.gradationLightColor
|
|
388
405
|
}
|
|
389
406
|
},
|
|
390
407
|
gradationValues(): number[] {
|
|
@@ -524,6 +541,12 @@ export default defineComponent({
|
|
|
524
541
|
align-items: center;
|
|
525
542
|
}
|
|
526
543
|
|
|
544
|
+
.label {
|
|
545
|
+
transform: translateX(40%);
|
|
546
|
+
display: block;
|
|
547
|
+
text-align: start;
|
|
548
|
+
}
|
|
549
|
+
|
|
527
550
|
.label-tag {
|
|
528
551
|
font-size: 0.8em;
|
|
529
552
|
color: var(--dl-color-medium);
|
|
@@ -541,7 +564,7 @@ export default defineComponent({
|
|
|
541
564
|
width: 100%;
|
|
542
565
|
display: flex;
|
|
543
566
|
justify-content: space-evenly;
|
|
544
|
-
margin
|
|
567
|
+
margin: 10px 0px 15px 0px;
|
|
545
568
|
min-height: 100px;
|
|
546
569
|
max-height: 100px;
|
|
547
570
|
&__element {
|
|
@@ -568,6 +591,7 @@ export default defineComponent({
|
|
|
568
591
|
}
|
|
569
592
|
.y-axis-outer {
|
|
570
593
|
overflow: hidden;
|
|
594
|
+
margin-right: 10px;
|
|
571
595
|
width: 200px;
|
|
572
596
|
}
|
|
573
597
|
.y-axis,
|
|
@@ -615,8 +639,8 @@ export default defineComponent({
|
|
|
615
639
|
&__gradient {
|
|
616
640
|
width: 40%;
|
|
617
641
|
background-image: linear-gradient(
|
|
618
|
-
var(--
|
|
619
|
-
var(--
|
|
642
|
+
var(--gradation-dark),
|
|
643
|
+
var(--gradation-light)
|
|
620
644
|
);
|
|
621
645
|
}
|
|
622
646
|
&__gradation {
|
|
@@ -237,8 +237,8 @@ export default defineComponent({
|
|
|
237
237
|
// todo: these can be stale data. we need to update them on schema change.
|
|
238
238
|
const { hasEllipsis } = useSizeObserver(input)
|
|
239
239
|
const { suggestions, error, findSuggestions } = useSuggestions(
|
|
240
|
-
schema
|
|
241
|
-
aliases
|
|
240
|
+
schema,
|
|
241
|
+
aliases,
|
|
242
242
|
{ strict }
|
|
243
243
|
)
|
|
244
244
|
//#endregion
|
|
@@ -465,6 +465,9 @@ export default defineComponent({
|
|
|
465
465
|
if (!focused.value) {
|
|
466
466
|
focus()
|
|
467
467
|
}
|
|
468
|
+
nextTick(() => {
|
|
469
|
+
findSuggestions('')
|
|
470
|
+
})
|
|
468
471
|
}
|
|
469
472
|
|
|
470
473
|
const endsWithOperator = computed(() => {
|
|
@@ -61,7 +61,13 @@ const getMatrix = (size: number) => {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
const getLabels = (size: number) => {
|
|
64
|
-
const items = [
|
|
64
|
+
const items = [
|
|
65
|
+
'Van',
|
|
66
|
+
'Truck',
|
|
67
|
+
'MotorcycleLooooooooooooooooooooooooooong',
|
|
68
|
+
'Car',
|
|
69
|
+
'Bus'
|
|
70
|
+
]
|
|
65
71
|
|
|
66
72
|
// const items = [
|
|
67
73
|
// { title: 'Van', image: 'https://picsum.photos/200/200' },
|
|
@@ -117,20 +117,20 @@ const mergeWords = (words: string[]) => {
|
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
export const useSuggestions = (
|
|
120
|
-
schema: Schema
|
|
121
|
-
aliases: Alias[]
|
|
120
|
+
schema: Ref<Schema>,
|
|
121
|
+
aliases: Ref<Alias[]>,
|
|
122
122
|
options: { strict?: Ref<boolean> } = {}
|
|
123
123
|
) => {
|
|
124
124
|
const { strict } = options
|
|
125
125
|
const initialSuggestions = Object.keys(schema)
|
|
126
|
-
const aliasedKeys = aliases.map((alias) => alias.key)
|
|
126
|
+
const aliasedKeys = aliases.value.map((alias) => alias.key)
|
|
127
127
|
const aliasedSuggestions = initialSuggestions.map((suggestion) =>
|
|
128
128
|
aliasedKeys.includes(suggestion)
|
|
129
|
-
? aliases.find((alias) => alias.key === suggestion)?.alias
|
|
129
|
+
? aliases.value.find((alias) => alias.key === suggestion)?.alias
|
|
130
130
|
: suggestion
|
|
131
131
|
)
|
|
132
132
|
|
|
133
|
-
for (const alias of aliases) {
|
|
133
|
+
for (const alias of aliases.value) {
|
|
134
134
|
if (aliasedSuggestions.includes(alias.alias)) {
|
|
135
135
|
continue
|
|
136
136
|
}
|
|
@@ -185,7 +185,11 @@ export const useSuggestions = (
|
|
|
185
185
|
continue
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
-
const dataType = getDataType(
|
|
188
|
+
const dataType = getDataType(
|
|
189
|
+
schema.value,
|
|
190
|
+
aliases.value,
|
|
191
|
+
matchedField
|
|
192
|
+
)
|
|
189
193
|
if (!dataType) {
|
|
190
194
|
localSuggestions = []
|
|
191
195
|
continue
|
|
@@ -207,7 +211,7 @@ export const useSuggestions = (
|
|
|
207
211
|
|
|
208
212
|
if (!operator) {
|
|
209
213
|
const dotSeparated = matchedField.split('.').filter((el) => el)
|
|
210
|
-
let fieldOf = schema
|
|
214
|
+
let fieldOf = schema.value
|
|
211
215
|
for (const key of dotSeparated) {
|
|
212
216
|
fieldOf = fieldOf[key] as Schema
|
|
213
217
|
}
|
|
@@ -276,7 +280,7 @@ export const useSuggestions = (
|
|
|
276
280
|
}
|
|
277
281
|
|
|
278
282
|
error.value = input.length
|
|
279
|
-
? getError(schema, aliases, expressions, { strict })
|
|
283
|
+
? getError(schema.value, aliases.value, expressions, { strict })
|
|
280
284
|
: null
|
|
281
285
|
|
|
282
286
|
suggestions.value = localSuggestions
|
|
@@ -337,7 +341,8 @@ const getError = (
|
|
|
337
341
|
.filter(({ field, value }) => field !== null && value !== null)
|
|
338
342
|
.reduce<string | null>((acc, { field, value, operator }, _, arr) => {
|
|
339
343
|
if (acc === 'warning') return acc
|
|
340
|
-
const
|
|
344
|
+
const fieldKey: string =
|
|
345
|
+
getAliasObjByAlias(aliases, field)?.key ?? field
|
|
341
346
|
|
|
342
347
|
/**
|
|
343
348
|
* Handle nested keys to validate if the key exists in the schema or not.
|
|
@@ -352,14 +357,31 @@ const getError = (
|
|
|
352
357
|
}
|
|
353
358
|
}
|
|
354
359
|
|
|
355
|
-
|
|
356
|
-
|
|
360
|
+
function hasValidExpression(
|
|
361
|
+
arr: string[],
|
|
362
|
+
pattern: RegExp
|
|
363
|
+
): boolean {
|
|
364
|
+
for (const item of arr) {
|
|
365
|
+
if (pattern.test(item)) {
|
|
366
|
+
return true
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
return false
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
const pattern = new RegExp(`${fieldKey}\\.\\d`)
|
|
373
|
+
const isValid = isInputAllowed(fieldKey, keys)
|
|
374
|
+
if (
|
|
375
|
+
!keys.includes(fieldKey) &&
|
|
376
|
+
!hasValidExpression(keys, pattern) &&
|
|
377
|
+
!isValid
|
|
378
|
+
) {
|
|
357
379
|
return strict.value ? errors.INVALID_EXPRESSION : 'warning'
|
|
358
380
|
}
|
|
359
381
|
|
|
360
382
|
const valid = isValidByDataType(
|
|
361
383
|
validateBracketValues(value),
|
|
362
|
-
getDataType(schema, aliases,
|
|
384
|
+
getDataType(schema, aliases, fieldKey),
|
|
363
385
|
operator
|
|
364
386
|
)
|
|
365
387
|
|
package/src/hooks/use-theme.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { getRootStyles } from '../utils/getRootStyles'
|
|
2
|
-
import { inject, watch, reactive } from 'vue-demi'
|
|
2
|
+
import { inject, watch, reactive, Ref } from 'vue-demi'
|
|
3
3
|
|
|
4
4
|
export const useThemeVariables = () => {
|
|
5
|
-
const isDark = inject('theme')
|
|
5
|
+
const isDark = inject('theme') as Ref
|
|
6
6
|
|
|
7
7
|
const variables = reactive(getRootStyles())
|
|
8
8
|
|
|
@@ -14,6 +14,6 @@ export const useThemeVariables = () => {
|
|
|
14
14
|
{ deep: true }
|
|
15
15
|
)
|
|
16
16
|
|
|
17
|
-
if (variables) return { variables }
|
|
17
|
+
if (variables) return { variables, isDark }
|
|
18
18
|
return
|
|
19
19
|
}
|