@dataloop-ai/components 0.19.67 → 0.19.69

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.67",
3
+ "version": "0.19.69",
4
4
  "exports": {
5
5
  ".": "./index.ts",
6
6
  "./models": "./models.ts",
@@ -743,6 +743,7 @@ export default defineComponent({
743
743
  emit('update:model-value', newValue)
744
744
  input.value.innerHTML = newValue
745
745
  setCaretAtTheEnd(input.value)
746
+ isInternalChange.value = true
746
747
  }
747
748
  }
748
749
 
@@ -524,6 +524,7 @@
524
524
  :props="getHeaderScope({ col })"
525
525
  :col-index="colIndex"
526
526
  :pagination="computedPagination"
527
+ :padding="isTreeTable ? '0' : '0 10px'"
527
528
  @click="onThClick($event, col.name)"
528
529
  >
529
530
  <span
@@ -543,6 +544,7 @@
543
544
  key="visibleColumnsSlot"
544
545
  :col-index="-1"
545
546
  no-tooltip
547
+ :padding="isTreeTable ? '0' : '0 10px'"
546
548
  >
547
549
  <slot
548
550
  name="header-cell-visible-columns-button"
@@ -17,6 +17,7 @@ import DlTable from '../DlTable/DlTable.vue'
17
17
  import DlTrTreeView from './views/DlTrTreeView.vue'
18
18
  import { DlTableColumn, DlTableProps, DlTableRow } from '../DlTable/types'
19
19
  import { useTreeTableRowSelection } from './utils/treeTableRowSelection'
20
+ import { useNestedTableFilter } from './hooks/nestedTableFilter'
20
21
  import { getFromChildren } from './utils/getFromChildren'
21
22
  import { emits } from './emits'
22
23
  import Sortable from '../DlTable/components/SortableJS.vue'
@@ -343,6 +344,21 @@ export default defineComponent({
343
344
  getRowKey as ComputedRef<(val: string | DlTableRow) => any>
344
345
  )
345
346
 
347
+ const { filteredRows } = useNestedTableFilter(
348
+ tableRows.value,
349
+ (row) => {
350
+ return row.name
351
+ .toLowerCase?.()
352
+ .includes(props.filter?.toLowerCase())
353
+ }
354
+ )
355
+
356
+ const computedFilter = computed(() =>
357
+ props.filter && filteredRows.value.length
358
+ ? filteredRows.value
359
+ : tableRows.value
360
+ )
361
+
346
362
  const updateExpandedRow = (
347
363
  isExpanded: boolean,
348
364
  name: string,
@@ -677,7 +693,7 @@ export default defineComponent({
677
693
 
678
694
  const renderTBody = () => {
679
695
  if (isEmpty(tableRootRef.value)) return null
680
- const children = tableRows.value.map((row, i) => {
696
+ const children = computedFilter.value.map((row, i) => {
681
697
  const rowBodySlot = slots['row-body']
682
698
  const [renderRow] = rowBodySlot
683
699
  ? rowBodySlot({ row })
@@ -776,7 +792,8 @@ export default defineComponent({
776
792
  uuid,
777
793
  mainTbodyUuid,
778
794
  vue2h,
779
- containerClass
795
+ containerClass,
796
+ computedFilter
780
797
  }
781
798
  },
782
799
  // adding ignore here as overloading the render function like this is not a known type
@@ -802,7 +819,7 @@ export default defineComponent({
802
819
  isTreeTable: true,
803
820
  selection: this.selection,
804
821
  loading: this.loading,
805
- rows: this.tableRows,
822
+ rows: this.computedFilter,
806
823
  resizable: this.resizable,
807
824
  rowKey: this.rowKey,
808
825
  color: this.color,
@@ -0,0 +1,37 @@
1
+ import { ref, computed, watchEffect } from 'vue'
2
+ import { DlTableRow } from '../../types'
3
+
4
+ export function useNestedTableFilter(
5
+ rows: DlTableRow[],
6
+ filerCriteria: (item: DlTableRow) => boolean
7
+ ) {
8
+ const nestedRows = ref<DlTableRow[]>(rows)
9
+ const criteria = ref(filerCriteria)
10
+
11
+ const recursiveSearch = (
12
+ array: DlTableRow[],
13
+ criteria: (item: DlTableRow) => boolean
14
+ ): DlTableRow[] => {
15
+ return array.reduce((result: DlTableRow[], item: DlTableRow) => {
16
+ if (criteria(item)) {
17
+ result.push(item)
18
+ }
19
+ if (item.children) {
20
+ result.push(...recursiveSearch(item.children, criteria))
21
+ }
22
+ return result
23
+ }, [])
24
+ }
25
+
26
+ const filteredRows = computed(() => {
27
+ return recursiveSearch(nestedRows.value, criteria.value)
28
+ })
29
+
30
+ watchEffect(() => {
31
+ recursiveSearch(nestedRows.value, criteria.value)
32
+ })
33
+
34
+ return {
35
+ filteredRows
36
+ }
37
+ }
@@ -601,7 +601,8 @@ import {
601
601
  DlOptionGroup,
602
602
  DlSwitch,
603
603
  DlInput,
604
- DlButton
604
+ DlButton,
605
+ DlAvatar
605
606
  } from '../components'
606
607
  import { defineComponent, ref, computed, nextTick } from 'vue-demi'
607
608
  import { times, cloneDeep, isNumber } from 'lodash'
@@ -904,7 +905,8 @@ export default defineComponent({
904
905
  DlSwitch,
905
906
  DlOptionGroup,
906
907
  DlInput,
907
- DlButton
908
+ DlButton,
909
+ DlAvatar
908
910
  },
909
911
  setup() {
910
912
  const filter = ref('')
@@ -1149,7 +1151,7 @@ export default defineComponent({
1149
1151
  align-items: flex-start;
1150
1152
  gap: 10px;
1151
1153
  padding: 10px;
1152
- background-color: #f4f4f4;
1154
+ background-color: var(--dl-color-panel-background);
1153
1155
  border-radius: 4px;
1154
1156
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.1);
1155
1157
  }