@dataloop-ai/components 0.19.131 → 0.19.133
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 +2 -1
- package/src/components/compound/DlSearches/DlSmartSearch/components/SuggestionsDropdown.vue +8 -1
- package/src/components/compound/DlTable/DlTable.vue +4 -1
- package/src/demos/DlTableDemo.vue +74 -2
- package/src/demos/SmartSearchDemo/DlSmartSearchDemo.vue +1 -0
- package/src/hooks/use-suggestions.ts +10 -6
package/package.json
CHANGED
|
@@ -346,7 +346,8 @@ export default defineComponent({
|
|
|
346
346
|
}
|
|
347
347
|
}
|
|
348
348
|
|
|
349
|
-
const setInputFromSuggestion = (
|
|
349
|
+
const setInputFromSuggestion = (suggestion: any) => {
|
|
350
|
+
const value = '' + suggestion
|
|
350
351
|
let stringValue = ''
|
|
351
352
|
let caretPosition = 0
|
|
352
353
|
if (searchQuery.value.length) {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
:highlighted="suggestionIndex === highlightedIndex"
|
|
29
29
|
@click="handleOption(item)"
|
|
30
30
|
>
|
|
31
|
-
{{ item }}
|
|
31
|
+
{{ removeQuotes(item) }}
|
|
32
32
|
</dl-list-item>
|
|
33
33
|
</dl-list>
|
|
34
34
|
</dl-menu>
|
|
@@ -115,11 +115,18 @@ export default defineComponent({
|
|
|
115
115
|
emit('update:model-value', false)
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
+
const removeQuotes = (item: any) => {
|
|
119
|
+
const str = '' + item
|
|
120
|
+
const match = str.match(/^'(.*)'$/)
|
|
121
|
+
return match ? match[1] : str
|
|
122
|
+
}
|
|
123
|
+
|
|
118
124
|
return {
|
|
119
125
|
defaultTarget,
|
|
120
126
|
setHighlightedIndex,
|
|
121
127
|
handleSelectedItem,
|
|
122
128
|
highlightedIndex,
|
|
129
|
+
removeQuotes,
|
|
123
130
|
onShow,
|
|
124
131
|
onHide,
|
|
125
132
|
emitModelValue,
|
|
@@ -139,6 +139,7 @@
|
|
|
139
139
|
:virtual-scroll="vScroll"
|
|
140
140
|
style="height: 500px"
|
|
141
141
|
:rows-per-page-options="rowsPerPageOptions"
|
|
142
|
+
:selected-rows-label="(val) => 'Selected rows ' + val"
|
|
142
143
|
@row-click="log"
|
|
143
144
|
@th-click="log"
|
|
144
145
|
@update:selected="updateSeleted"
|
|
@@ -677,6 +678,48 @@
|
|
|
677
678
|
</template>
|
|
678
679
|
</DlTable>
|
|
679
680
|
</div>
|
|
681
|
+
<div style="margin-top: 100px">
|
|
682
|
+
<p>Infinite scrolling With custom data and weird expandable</p>
|
|
683
|
+
<DlTable
|
|
684
|
+
:selected="selected"
|
|
685
|
+
:separator="separator"
|
|
686
|
+
:draggable="draggable"
|
|
687
|
+
:filter="filter"
|
|
688
|
+
:resizable="resizable"
|
|
689
|
+
:selection="selection"
|
|
690
|
+
:dense="dense"
|
|
691
|
+
title="Treats"
|
|
692
|
+
color="dl-color-secondary"
|
|
693
|
+
:loading="infiniteLoading"
|
|
694
|
+
:rows="generatedRows"
|
|
695
|
+
:columns="tableColumns"
|
|
696
|
+
style="height: 500px"
|
|
697
|
+
row-key="index"
|
|
698
|
+
virtual-scroll
|
|
699
|
+
expandable-rows
|
|
700
|
+
@virtual-scroll="onScrollGenerate"
|
|
701
|
+
@update:pagination="() => console.log('@@@@ hey')"
|
|
702
|
+
@col-update="updateColumns"
|
|
703
|
+
>
|
|
704
|
+
<template #body-cell-expandable-content="{ row }">
|
|
705
|
+
<div>
|
|
706
|
+
{{ row }}
|
|
707
|
+
</div>
|
|
708
|
+
<div>
|
|
709
|
+
{{ row }}
|
|
710
|
+
</div>
|
|
711
|
+
<div>
|
|
712
|
+
{{ row }}
|
|
713
|
+
</div>
|
|
714
|
+
<div>
|
|
715
|
+
{{ row }}
|
|
716
|
+
</div>
|
|
717
|
+
<div>
|
|
718
|
+
{{ row }}
|
|
719
|
+
</div>
|
|
720
|
+
</template>
|
|
721
|
+
</DlTable>
|
|
722
|
+
</div>
|
|
680
723
|
</div>
|
|
681
724
|
</template>
|
|
682
725
|
|
|
@@ -691,7 +734,7 @@ import {
|
|
|
691
734
|
} from '../components'
|
|
692
735
|
import { defineComponent, ref, computed, nextTick } from 'vue-demi'
|
|
693
736
|
import { times, cloneDeep, isNumber } from 'lodash'
|
|
694
|
-
import { DlTablePagination } from '../types'
|
|
737
|
+
import { DlTablePagination, DlVirtualScrollEvent } from '../types'
|
|
695
738
|
|
|
696
739
|
const columns = [
|
|
697
740
|
{
|
|
@@ -1037,6 +1080,10 @@ export default defineComponent({
|
|
|
1037
1080
|
allRows.slice(0, pageSize * (nextPageNumber.value - 1))
|
|
1038
1081
|
)
|
|
1039
1082
|
|
|
1083
|
+
const generatedRows = ref<any>(
|
|
1084
|
+
allRows.slice(0, pageSize * nextPageNumber.value)
|
|
1085
|
+
)
|
|
1086
|
+
|
|
1040
1087
|
const onScroll = ({ to, ref }: { to: number; ref: any }) => {
|
|
1041
1088
|
const lastIndex = computedRows.value.length - 1
|
|
1042
1089
|
|
|
@@ -1057,6 +1104,29 @@ export default defineComponent({
|
|
|
1057
1104
|
}
|
|
1058
1105
|
}
|
|
1059
1106
|
|
|
1107
|
+
const onScrollGenerate = ({ index, to, ref }: DlVirtualScrollEvent) => {
|
|
1108
|
+
const lastIndex = generatedRows.value.length - 1
|
|
1109
|
+
|
|
1110
|
+
const getRandomInt = (min: number, max: number) => {
|
|
1111
|
+
min = Math.ceil(min)
|
|
1112
|
+
max = Math.floor(max)
|
|
1113
|
+
return Math.floor(Math.random() * (max - min + 1)) + min
|
|
1114
|
+
}
|
|
1115
|
+
// todo: here we can see that even if we are loading the event keeps getting called with same payload. maybe we shouldnt send the same event payload over and over
|
|
1116
|
+
if (index >= lastIndex) {
|
|
1117
|
+
infiniteLoading.value = true
|
|
1118
|
+
|
|
1119
|
+
setTimeout(() => {
|
|
1120
|
+
generatedRows.value = generatedRows.value.concat(
|
|
1121
|
+
cloneDeep(generatedRows.value)
|
|
1122
|
+
.slice(-10)
|
|
1123
|
+
.map((r: any) => ({ ...r }))
|
|
1124
|
+
)
|
|
1125
|
+
infiniteLoading.value = false
|
|
1126
|
+
}, getRandomInt(500, 2000))
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1060
1130
|
const pagination = ref<DlTablePagination>({
|
|
1061
1131
|
sortBy: 'desc',
|
|
1062
1132
|
descending: false,
|
|
@@ -1166,7 +1236,9 @@ export default defineComponent({
|
|
|
1166
1236
|
isFirstPage,
|
|
1167
1237
|
rows2,
|
|
1168
1238
|
columns2,
|
|
1169
|
-
tableColumnsAligned
|
|
1239
|
+
tableColumnsAligned,
|
|
1240
|
+
generatedRows,
|
|
1241
|
+
onScrollGenerate
|
|
1170
1242
|
}
|
|
1171
1243
|
},
|
|
1172
1244
|
|
|
@@ -260,11 +260,15 @@ export const useSuggestions = (
|
|
|
260
260
|
}
|
|
261
261
|
|
|
262
262
|
if (Array.isArray(dataType)) {
|
|
263
|
-
localSuggestions = dataType
|
|
264
|
-
(
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
263
|
+
localSuggestions = dataType
|
|
264
|
+
.filter(
|
|
265
|
+
(type) =>
|
|
266
|
+
!knownDataTypes.includes(type as string) &&
|
|
267
|
+
typeof type !== 'object'
|
|
268
|
+
)
|
|
269
|
+
.map((type) =>
|
|
270
|
+
typeof type === 'string' ? `'${type}'` : type
|
|
271
|
+
) as string[]
|
|
268
272
|
|
|
269
273
|
if (!value) continue
|
|
270
274
|
|
|
@@ -704,7 +708,7 @@ const getValueSuggestions = (
|
|
|
704
708
|
!knownDataTypes.includes(type as string) &&
|
|
705
709
|
typeof type !== 'object'
|
|
706
710
|
) {
|
|
707
|
-
suggestion.push(type)
|
|
711
|
+
suggestion.push(typeof type === 'string' ? `'${type}'` : type)
|
|
708
712
|
}
|
|
709
713
|
}
|
|
710
714
|
}
|