@dataloop-ai/components 0.19.19 → 0.19.21
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/DlSearches/DlSmartSearch/components/DlSmartSearchInput.vue +1 -0
- package/src/components/compound/DlTable/DlTable.vue +22 -9
- package/src/components/compound/DlTable/components/DlTh.vue +4 -1
- package/src/components/compound/DlTable/styles/dl-table-styles.scss +0 -2
- package/src/demos/DlTableDemo.vue +0 -1
- package/src/utils/table-columns.ts +5 -13
package/package.json
CHANGED
|
@@ -414,6 +414,7 @@
|
|
|
414
414
|
class="dl-table__middle scroll"
|
|
415
415
|
>
|
|
416
416
|
<table
|
|
417
|
+
ref="tableRef"
|
|
417
418
|
class="dl-table"
|
|
418
419
|
:class="additionalClasses"
|
|
419
420
|
>
|
|
@@ -1190,6 +1191,7 @@ export default defineComponent({
|
|
|
1190
1191
|
const getTableKey = () => tableKey.value
|
|
1191
1192
|
|
|
1192
1193
|
const rootRef = ref<HTMLDivElement>(null)
|
|
1194
|
+
const tableRef = ref<HTMLTableElement>(null)
|
|
1193
1195
|
const virtScrollRef = ref(null)
|
|
1194
1196
|
const hasVirtScroll = computed<boolean>(
|
|
1195
1197
|
() => virtualScroll.value === true
|
|
@@ -1313,9 +1315,9 @@ export default defineComponent({
|
|
|
1313
1315
|
})
|
|
1314
1316
|
|
|
1315
1317
|
onMounted(() => {
|
|
1316
|
-
tableEl =
|
|
1317
|
-
|
|
1318
|
-
|
|
1318
|
+
tableEl =
|
|
1319
|
+
tableRef.value ||
|
|
1320
|
+
(document.querySelector('table.dl-table') as HTMLTableElement)
|
|
1319
1321
|
nextTick(() => {
|
|
1320
1322
|
setAllColumnWidths(
|
|
1321
1323
|
tableEl,
|
|
@@ -1346,6 +1348,14 @@ export default defineComponent({
|
|
|
1346
1348
|
applyResizableColumns(tableEl, vm)
|
|
1347
1349
|
}
|
|
1348
1350
|
|
|
1351
|
+
nextTick(() => {
|
|
1352
|
+
setAllColumnWidths(
|
|
1353
|
+
tableRef.value,
|
|
1354
|
+
props.columns as DlTableColumn[],
|
|
1355
|
+
props.fitAllColumns
|
|
1356
|
+
)
|
|
1357
|
+
})
|
|
1358
|
+
|
|
1349
1359
|
if (hasDraggableColumns.value === true) {
|
|
1350
1360
|
applyDraggableColumns(
|
|
1351
1361
|
tableEl,
|
|
@@ -1366,11 +1376,13 @@ export default defineComponent({
|
|
|
1366
1376
|
watch(
|
|
1367
1377
|
columns,
|
|
1368
1378
|
(newColumns) => {
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1379
|
+
nextTick(() => {
|
|
1380
|
+
setAllColumnWidths(
|
|
1381
|
+
tableRef.value,
|
|
1382
|
+
newColumns as DlTableColumn[],
|
|
1383
|
+
props.fitAllColumns
|
|
1384
|
+
)
|
|
1385
|
+
})
|
|
1374
1386
|
},
|
|
1375
1387
|
{
|
|
1376
1388
|
flush: 'post'
|
|
@@ -1927,7 +1939,8 @@ export default defineComponent({
|
|
|
1927
1939
|
handleVisibleColumnsUpdate,
|
|
1928
1940
|
computedVisibleCols,
|
|
1929
1941
|
totalItemsCount,
|
|
1930
|
-
showRowActions
|
|
1942
|
+
showRowActions,
|
|
1943
|
+
tableRef
|
|
1931
1944
|
}
|
|
1932
1945
|
}
|
|
1933
1946
|
})
|
|
@@ -3,7 +3,7 @@ import { DlTableColumn } from '../types'
|
|
|
3
3
|
import { browseNestedNodes } from './browse-nested-nodes'
|
|
4
4
|
import { swapNodes } from './swap-nodes'
|
|
5
5
|
|
|
6
|
-
const DEFAULT_COL_WIDTH =
|
|
6
|
+
const DEFAULT_COL_WIDTH = 'fit-content'
|
|
7
7
|
|
|
8
8
|
export function setColumnVerticalBorder(
|
|
9
9
|
table: HTMLTableElement,
|
|
@@ -171,16 +171,6 @@ export function justifyMouseInsideTargetCell(
|
|
|
171
171
|
)
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
function fitWidthToContent(el: HTMLElement, colWidth: number) {
|
|
175
|
-
if (el.tagName !== 'TH') return colWidth
|
|
176
|
-
const textNode = Array.from(el.querySelector('.inner-th').childNodes).find(
|
|
177
|
-
(node) => node.nodeType === 3
|
|
178
|
-
)
|
|
179
|
-
const fontSize = parseInt(window.getComputedStyle(el).fontSize)
|
|
180
|
-
const width = (textNode.nodeValue.length * fontSize) / 2
|
|
181
|
-
return width > 100 ? width : 100
|
|
182
|
-
}
|
|
183
|
-
|
|
184
174
|
export function setAllColumnWidths(
|
|
185
175
|
table: HTMLElement,
|
|
186
176
|
columns: DlTableColumn[],
|
|
@@ -196,8 +186,10 @@ export function setAllColumnWidths(
|
|
|
196
186
|
(el.tagName === 'TH' || el.tagName === 'TD') &&
|
|
197
187
|
parseInt(el.dataset.colIndex) === i,
|
|
198
188
|
(targetEl) => {
|
|
199
|
-
|
|
200
|
-
|
|
189
|
+
targetEl.style.width = col.width
|
|
190
|
+
? `${col.width}px`
|
|
191
|
+
: DEFAULT_COL_WIDTH
|
|
192
|
+
// then
|
|
201
193
|
}
|
|
202
194
|
)
|
|
203
195
|
})
|