@dataloop-ai/components 0.19.218 → 0.19.220

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.218",
3
+ "version": "0.19.220",
4
4
  "exports": {
5
5
  ".": "./index.ts",
6
6
  "./models": "./models.ts",
@@ -132,7 +132,7 @@ export default defineComponent({
132
132
  default: () => doughnutChartEmptyStateProps
133
133
  }
134
134
  },
135
- setup(props) {
135
+ setup(props, { attrs }) {
136
136
  /** Data */
137
137
  const doughnutChartRef = ref(null)
138
138
  const dlDoughnutChartWidgetRef = ref(null)
@@ -280,6 +280,8 @@ export default defineComponent({
280
280
  )
281
281
  defaultOptions.animation = mergedAnimation.value
282
282
 
283
+ type ItemClickHandler = (index: number) => void
284
+
283
285
  const doughnutOptions = computed(() =>
284
286
  merge(
285
287
  {
@@ -304,6 +306,22 @@ export default defineComponent({
304
306
  }
305
307
  }
306
308
  }
309
+ },
310
+ onClick: (e: Event & { chart: ChartJS }) => {
311
+ if (attrs.onItemClick) {
312
+ const intersects =
313
+ e.chart.getElementsAtEventForMode(
314
+ e,
315
+ 'nearest',
316
+ { intersect: true },
317
+ false
318
+ )
319
+ if (intersects.length > 0) {
320
+ ;(attrs.onItemClick as ItemClickHandler)(
321
+ intersects[0].index
322
+ )
323
+ }
324
+ }
307
325
  }
308
326
  },
309
327
  defaultOptions
@@ -425,6 +425,13 @@ export default defineComponent({
425
425
  selectChildren: {
426
426
  type: Boolean,
427
427
  default: true
428
+ },
429
+ /**
430
+ * the label to show when items are selected
431
+ */
432
+ selectedResourceLabel: {
433
+ type: String,
434
+ default: 'Selected Items'
428
435
  }
429
436
  },
430
437
  emits: [
@@ -616,7 +623,7 @@ export default defineComponent({
616
623
  return getLabelOfSelectedOption(valueToSearch, this.options)
617
624
  }
618
625
  return this.modelValueLength > 0
619
- ? `${this.modelValueLength} Selected Items`
626
+ ? `${this.modelValueLength} ${this.selectedResourceLabel}`
620
627
  : this.computedPlaceholder
621
628
  },
622
629
  computedAllItemsLabel(): string {
@@ -5,6 +5,7 @@
5
5
  <DlDoughnutChart
6
6
  :data="doughnutLessData"
7
7
  :animation="doughnutAnimation"
8
+ @itemClick="handleItemClick"
8
9
  >
9
10
  <template #default="{ item, index }">
10
11
  <span style="color: tomato">
@@ -230,7 +231,12 @@ export default defineComponent({
230
231
  return {
231
232
  doughnutData,
232
233
  doughnutLessData,
233
- doughnutAnimation
234
+ doughnutAnimation,
235
+ handleItemClick: (index: number) => {
236
+ alert(
237
+ `You clicked ${doughnutLessData.datasets[0].data[index]} 🍅`
238
+ )
239
+ }
234
240
  }
235
241
  }
236
242
  })