@dataloop-ai/components 0.19.18 → 0.19.20
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/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/hooks/use-suggestions.ts +53 -4
- 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
|
})
|
|
@@ -465,7 +465,8 @@ const isValidBoolean = (str: string) => {
|
|
|
465
465
|
const isValidString = (str: string) => {
|
|
466
466
|
const match = str.match(/(?<=\")(.*?)(?=\")|(?<=\')(.*?)(?=\')/)
|
|
467
467
|
if (!match) return false
|
|
468
|
-
|
|
468
|
+
const trimmed = str.trim()
|
|
469
|
+
return match[0] === trimmed.substring(1, trimmed.length - 1)
|
|
469
470
|
}
|
|
470
471
|
|
|
471
472
|
const getOperatorByDataType = (dataType: string) => {
|
|
@@ -595,12 +596,60 @@ const isNextCharSpace = (input: string, str: string) => {
|
|
|
595
596
|
const matchStringEnd = (input: string, str: string) =>
|
|
596
597
|
input.lastIndexOf(str + '" ') > -1 || input.lastIndexOf(str + "' ") > -1
|
|
597
598
|
|
|
598
|
-
|
|
599
|
+
const removeAllBrackets = (str: string) => {
|
|
599
600
|
return str.replace(/\(/g, '').replace(/\)/g, '')
|
|
600
601
|
}
|
|
601
602
|
|
|
602
|
-
const
|
|
603
|
-
|
|
603
|
+
export const removeBrackets = (str: string) => {
|
|
604
|
+
const quotesAt = []
|
|
605
|
+
for (let i = 0; i < str.length; i++) {
|
|
606
|
+
if (/['"]/.test(str.charAt(i))) {
|
|
607
|
+
quotesAt.push(i)
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
let result = removeAllBrackets(str.substring(0, quotesAt[0]))
|
|
612
|
+
|
|
613
|
+
let skipFrom = 0;
|
|
614
|
+
let skipTo = 1
|
|
615
|
+
while (quotesAt[skipFrom] !== undefined) {
|
|
616
|
+
// skip as far as isValidString fails
|
|
617
|
+
while (
|
|
618
|
+
!isValidString(
|
|
619
|
+
str.substring(
|
|
620
|
+
quotesAt[skipFrom],
|
|
621
|
+
(quotesAt[skipTo] || str.length) + 1
|
|
622
|
+
)
|
|
623
|
+
)
|
|
624
|
+
) {
|
|
625
|
+
skipTo++
|
|
626
|
+
if (!quotesAt[skipTo]) break
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
// this is either unifished invalid string or finished valid string - keep it as is
|
|
630
|
+
result += str.substring(
|
|
631
|
+
quotesAt[skipFrom],
|
|
632
|
+
(quotesAt[skipTo] || str.length) + 1
|
|
633
|
+
)
|
|
634
|
+
|
|
635
|
+
if (quotesAt[skipTo]) {
|
|
636
|
+
// there might still be something after the string
|
|
637
|
+
skipFrom = skipTo + 1
|
|
638
|
+
result += removeAllBrackets(
|
|
639
|
+
str.substring(
|
|
640
|
+
quotesAt[skipTo] + 1,
|
|
641
|
+
quotesAt[skipFrom] || str.length
|
|
642
|
+
)
|
|
643
|
+
)
|
|
644
|
+
|
|
645
|
+
skipTo = skipFrom + 1
|
|
646
|
+
} else {
|
|
647
|
+
// there is nothing left
|
|
648
|
+
break
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
return result
|
|
604
653
|
}
|
|
605
654
|
|
|
606
655
|
const getValueSuggestions = (dataType: string | string[], operator: string) => {
|
|
@@ -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
|
})
|