@dataloop-ai/components 0.19.244 → 0.19.248

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.19.244",
3
+ "version": "0.19.248",
4
4
  "exports": {
5
5
  ".": "./index.ts",
6
6
  "./models": "./models.ts",
@@ -27,6 +27,7 @@
27
27
  "@types/lodash": "^4.14.184",
28
28
  "@types/sortablejs": "^1.15.7",
29
29
  "chart.js": "^3.9.1",
30
+ "chartjs-plugin-datalabels": "^2.2.0",
30
31
  "flat": "^5.0.2",
31
32
  "highlight.js": "^11.8.0",
32
33
  "lodash": "^4.17.21",
@@ -40,8 +41,7 @@
40
41
  "vanilla-jsoneditor": "^0.10.2",
41
42
  "vue-demi": "^0.14.5",
42
43
  "vue-sortable": "^0.1.3",
43
- "vue2-teleport": "^1.0.1",
44
- "zero-md": "^2.5.3"
44
+ "vue2-teleport": "^1.0.1"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@babel/core": "^7.17.9",
@@ -17,6 +17,7 @@
17
17
  </template>
18
18
  </dl-input>
19
19
  <dl-tree-table
20
+ v-if="isFilterString(inputValue)"
20
21
  draggable="none"
21
22
  separator="none"
22
23
  :hide-pagination="true"
@@ -166,13 +167,28 @@ export default defineComponent({
166
167
  )
167
168
  )
168
169
  const rows = computed(() => mapItems.value)
170
+ const isFilterString = (input: string) => {
171
+ const stack = [...items.value]
172
+ const filter = (input ?? '').toLowerCase()
173
+ while (stack.length) {
174
+ const item = stack.pop()
175
+ if (item.displayLabel?.toLowerCase?.().includes(filter)) {
176
+ return true
177
+ }
178
+ if (item.children) {
179
+ stack.push(...item.children)
180
+ }
181
+ }
182
+ return false
183
+ }
169
184
  return {
170
185
  handleRowClick,
171
186
  inputValue,
172
187
  columns,
173
188
  placeHolderText,
174
189
  inputStyles,
175
- rows
190
+ rows,
191
+ isFilterString
176
192
  }
177
193
  }
178
194
  })
@@ -1,21 +1,9 @@
1
1
  <template>
2
2
  <div :class="chartWrapperClasses">
3
- <div
4
- class="canvas-container"
5
- :style="`height: ${wrapperHeight}`"
6
- >
7
- <dl-empty-state
8
- v-if="isEmpty"
9
- v-bind="emptyStateProps"
10
- >
11
- <template
12
- v-for="(_, slot) in $slots"
13
- #[slot]="props"
14
- >
15
- <slot
16
- :name="slot"
17
- v-bind="props"
18
- />
3
+ <div class="canvas-container" :style="`height: ${wrapperHeight}`">
4
+ <dl-empty-state v-if="isEmpty" v-bind="emptyStateProps">
5
+ <template v-for="(_, slot) in $slots" #[slot]="props">
6
+ <slot :name="slot" v-bind="props" />
19
7
  </template>
20
8
  </dl-empty-state>
21
9
  <Bar
@@ -26,11 +14,12 @@
26
14
  :style="chartStyles"
27
15
  :data="chartData"
28
16
  :options="chartOptions"
17
+ :plugins="chartPlugins"
29
18
  @mouseout="onChartLeave"
30
19
  @wheel.native="handleChartScroll"
31
20
  />
32
21
  <dl-chart-scroll-bar
33
- v-if="!isEmpty || (maxItems > thisItemsInView && !isEmpty)"
22
+ v-if="maxItems > thisItemsInView && !isEmpty"
34
23
  :wrapper-styles="{
35
24
  marginTop: '10px'
36
25
  }"
@@ -391,6 +380,8 @@ export default defineComponent({
391
380
  )
392
381
  )
393
382
 
383
+ const chartPlugins = props.plugins
384
+
394
385
  watch(
395
386
  () => chart.value?.scales?.x?.width,
396
387
  (val: string) => {
@@ -541,13 +532,14 @@ export default defineComponent({
541
532
  )
542
533
  )
543
534
 
544
- chart.value.update()
535
+ chart.value.update?.()
545
536
  })
546
537
 
547
538
  return {
548
539
  variables,
549
540
  chartData,
550
541
  chartOptions,
542
+ chartPlugins,
551
543
  xLabels,
552
544
  barChart,
553
545
  maxItems,
@@ -423,7 +423,10 @@ export default defineComponent({
423
423
  words.push(lastWord)
424
424
  }
425
425
  queryLeftSide = words.join('.')
426
- } else if (queryLeftSide.endsWith(' ')) {
426
+ } else if (
427
+ queryLeftSide.endsWith(' ') &&
428
+ (queryLeftSide.match(/'/g)?.length ?? 0) % 2 === 0
429
+ ) {
427
430
  // caret after space: only replace multiple spaces on the left
428
431
  queryLeftSide = queryLeftSide.trimEnd() + ' '
429
432
  } else if (/\.\S+$/.test(queryLeftSide)) {
@@ -440,7 +443,10 @@ export default defineComponent({
440
443
  queryRightSide = queryRightSide.trimStart()
441
444
  } else {
442
445
  // this|situation: replace whatever is there on both sides with the value
443
- queryLeftSide = queryLeftSide.replace(/\S+$/, '')
446
+ queryLeftSide = queryLeftSide.replace(
447
+ /('[^']+'?|[^'\s]+)$/,
448
+ ''
449
+ )
444
450
  queryRightSide =
445
451
  removeLeadingExpression(queryRightSide).trimStart()
446
452
  }
@@ -615,7 +621,18 @@ export default defineComponent({
615
621
  }
616
622
 
617
623
  const endsWithOperator = computed(() => {
618
- const operators = ['>=', '<=', '!=', '=', '>', '<', 'IN', 'NOT-IN']
624
+ const operators = [
625
+ '>=',
626
+ '<=',
627
+ '!=',
628
+ '=',
629
+ '>',
630
+ '<',
631
+ 'IN',
632
+ 'NOT-IN',
633
+ 'EXISTS',
634
+ 'DOESNT-EXIST'
635
+ ]
619
636
 
620
637
  for (const op of operators) {
621
638
  if (
@@ -4,7 +4,7 @@
4
4
  display: flex;
5
5
  width: 900px;
6
6
  flex-wrap: wrap;
7
- flex-direction: row;
7
+ flex-direction: column;
8
8
  gap: 0px;
9
9
  "
10
10
  >
@@ -22,6 +22,19 @@
22
22
  :items-in-view="6"
23
23
  is-empty
24
24
  />
25
+
26
+ <div style="color: var(--dl-color-darker); margin-bottom: 30px">
27
+ Customized DlBarChart with data labels
28
+ </div>
29
+ <!-- @vue-ignore -->
30
+ <dl-bar-chart
31
+ :data="cdlData"
32
+ :options="cdlOptions"
33
+ :plugins="cdlPlugins"
34
+ :items-in-view="data.labels.length + 1"
35
+ >
36
+ <template #legend><span /></template>
37
+ </dl-bar-chart>
25
38
  </div>
26
39
  </template>
27
40
 
@@ -29,6 +42,7 @@
29
42
  import { defineComponent } from 'vue-demi'
30
43
  import { ChartOptions } from 'chart.js'
31
44
  import { DlBarChart } from '../components'
45
+ import ChartDataLabels from 'chartjs-plugin-datalabels'
32
46
 
33
47
  const labelsFn = () => {
34
48
  const a = []
@@ -78,6 +92,76 @@ const options: ChartOptions = {
78
92
  }
79
93
  }
80
94
 
95
+ const cdlData = {
96
+ labels: labelsFn().map((l) => `Data [${l}]:`),
97
+ datasets: [
98
+ {
99
+ label: 'Duh',
100
+ backgroundColor: '--dl-color-secondary',
101
+ borderRadius: 4,
102
+ data: dataFn(),
103
+ datalabels: {
104
+ align: 'end',
105
+ anchor: 'start'
106
+ }
107
+ },
108
+ {
109
+ label: 'Duh',
110
+ backgroundColor: '--dl-color-info-background',
111
+ borderRadius: 4,
112
+ data: dataFn().map((n) => 20 - n),
113
+ datalabels: {
114
+ align: 'start',
115
+ anchor: 'end'
116
+ }
117
+ }
118
+ ]
119
+ }
120
+
121
+ const cdlOptions: ChartOptions = {
122
+ plugins: {
123
+ datalabels: {
124
+ color: '--dl-color-darker',
125
+ font: {
126
+ weight: 'bold'
127
+ },
128
+ formatter (value, context) {
129
+ switch (context.datasetIndex) {
130
+ case 0:
131
+ return context.chart.data.labels[context.dataIndex]
132
+ case 1:
133
+ return (
134
+ 'Value is ' +
135
+ context.chart.data.datasets[0].data[
136
+ context.dataIndex
137
+ ]
138
+ )
139
+ }
140
+ }
141
+ },
142
+ tooltip: {
143
+ callbacks: {
144
+ label (tooltipItem) {
145
+ return 'Value is ' + tooltipItem.formattedValue
146
+ }
147
+ },
148
+ filter (tooltipItem) {
149
+ return tooltipItem.datasetIndex === 0
150
+ }
151
+ }
152
+ },
153
+ scales: {
154
+ x: {
155
+ stacked: true,
156
+ display: false
157
+ },
158
+ y: {
159
+ stacked: true,
160
+ display: false
161
+ }
162
+ }
163
+ }
164
+
81
165
  export default defineComponent({
82
166
  name: 'DlChartDemo',
83
167
  components: {
@@ -85,6 +169,9 @@ export default defineComponent({
85
169
  },
86
170
  data() {
87
171
  return {
172
+ cdlData,
173
+ cdlOptions,
174
+ cdlPlugins: [ChartDataLabels],
88
175
  data,
89
176
  options,
90
177
  legendProps