lkt-table 1.2.26 → 1.3.1
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/README.md +11 -31
- package/dist/build.d.ts +892 -1016
- package/dist/build.js +550 -768
- package/package.json +3 -7
- package/src/components/LktHiddenRow.vue +3 -3
- package/src/components/LktTableCell.vue +35 -88
- package/src/components/LktTableRow.vue +2 -2
- package/src/components/TableHeader.vue +2 -2
- package/src/lib-components/LktTable.vue +9 -36
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lkt-table",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lkt",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"./theme": "./theme/default.css",
|
|
21
21
|
"./theme/default": "./theme/default.css"
|
|
22
22
|
},
|
|
23
|
-
"types": "./dist/
|
|
23
|
+
"types": "./dist/build.d.ts",
|
|
24
24
|
"files": [
|
|
25
25
|
"dist/*",
|
|
26
26
|
"src/**/*.vue",
|
|
@@ -50,11 +50,7 @@
|
|
|
50
50
|
"lkt-button": "^1.1.16",
|
|
51
51
|
"lkt-data-state": "^1.0.10",
|
|
52
52
|
"lkt-date-tools": "^1.0.4",
|
|
53
|
-
"lkt-field
|
|
54
|
-
"lkt-field-select": "^1.0.0",
|
|
55
|
-
"lkt-field-switch": "^1.0.0",
|
|
56
|
-
"lkt-field-text": "^1.0.0",
|
|
57
|
-
"lkt-field-textarea": "^1.1.3",
|
|
53
|
+
"lkt-field": "^0.0.14",
|
|
58
54
|
"lkt-http-client": "^1.0.19",
|
|
59
55
|
"lkt-i18n": "^1.0.4",
|
|
60
56
|
"lkt-loader": "^1.0.2",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import {getColumnDisplayContent} from "../functions/table-functions";
|
|
3
|
-
import {
|
|
3
|
+
import {Column} from "../instances/Column";
|
|
4
4
|
import LktTableCell from "./LktTableCell.vue";
|
|
5
5
|
import {ref, watch} from "vue";
|
|
6
6
|
import {LktObject} from "lkt-ts-interfaces";
|
|
@@ -14,8 +14,8 @@ const props = withDefaults(defineProps<{
|
|
|
14
14
|
hiddenIsVisible: boolean
|
|
15
15
|
i: number
|
|
16
16
|
hiddenColumnsColSpan: number
|
|
17
|
-
visibleColumns:
|
|
18
|
-
hiddenColumns:
|
|
17
|
+
visibleColumns: Column[]
|
|
18
|
+
hiddenColumns: Column[]
|
|
19
19
|
emptyColumns: string[]
|
|
20
20
|
}>(), {
|
|
21
21
|
modelValue: () => ({}),
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import {getColumnDisplayContent} from "../functions/table-functions";
|
|
3
|
-
import {
|
|
4
|
-
import {computed,
|
|
3
|
+
import {Column} from "../instances/Column";
|
|
4
|
+
import {computed, ref, watch} from "vue";
|
|
5
5
|
import {LktObject} from "lkt-ts-interfaces";
|
|
6
|
-
import {TypeOfColumn} from "
|
|
6
|
+
import {TypeOfColumn} from "../enums/TypeOfColumn";
|
|
7
7
|
|
|
8
8
|
const emit = defineEmits(['update:modelValue']);
|
|
9
9
|
|
|
10
10
|
const props = withDefaults(defineProps<{
|
|
11
11
|
modelValue: LktObject
|
|
12
|
-
column:
|
|
13
|
-
columns:
|
|
12
|
+
column: Column
|
|
13
|
+
columns: Column[]
|
|
14
14
|
i: number
|
|
15
15
|
editModeEnabled: boolean
|
|
16
16
|
}>(), {
|
|
17
17
|
modelValue: () => ({}),
|
|
18
|
-
column: () => (
|
|
18
|
+
column: () => (new Column()),
|
|
19
19
|
columns: () => [],
|
|
20
20
|
i: 0,
|
|
21
21
|
editModeEnabled: false
|
|
@@ -23,8 +23,7 @@ const props = withDefaults(defineProps<{
|
|
|
23
23
|
|
|
24
24
|
const item = ref(props.modelValue),
|
|
25
25
|
value = ref(item.value[props.column.key]),
|
|
26
|
-
inputElement = ref(null)
|
|
27
|
-
loadingColumn = ref(props.column.showLoading());
|
|
26
|
+
inputElement = ref(null);
|
|
28
27
|
|
|
29
28
|
watch(value, (v) => {
|
|
30
29
|
const payload = JSON.parse(JSON.stringify(item.value));
|
|
@@ -37,18 +36,29 @@ watch(() => props.modelValue, (v) => {
|
|
|
37
36
|
value.value = item.value[props.column.key];
|
|
38
37
|
});
|
|
39
38
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
const slotData = computed(() => {
|
|
40
|
+
return {...props.column.slotData, item: item.value};
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
const computedModalKey = computed(() => {
|
|
44
|
+
if (props.column.field?.modalKey.startsWith('prop:')) {
|
|
45
|
+
let prop = props.column.field?.modalKey.substring(5);
|
|
46
|
+
return item.value[prop];
|
|
43
47
|
}
|
|
44
|
-
|
|
48
|
+
return props.column.field?.modalKey;
|
|
49
|
+
});
|
|
45
50
|
|
|
46
|
-
|
|
47
|
-
props.column.
|
|
48
|
-
|
|
51
|
+
const computedOptions = computed(() => {
|
|
52
|
+
if (typeof props.column.field?.options === 'string' && props.column.field?.options.startsWith('prop:')) {
|
|
53
|
+
let prop = props.column.field?.options.substring(5);
|
|
54
|
+
return item.value[prop];
|
|
55
|
+
}
|
|
56
|
+
return props.column.field.options;
|
|
57
|
+
});
|
|
49
58
|
|
|
50
|
-
const
|
|
51
|
-
|
|
59
|
+
const computedColumnType = computed(() => {
|
|
60
|
+
if ([TypeOfColumn.Integer, TypeOfColumn.Float].includes(props.column.type)) return TypeOfColumn.Number;
|
|
61
|
+
return props.column.type;
|
|
52
62
|
})
|
|
53
63
|
</script>
|
|
54
64
|
|
|
@@ -61,81 +71,18 @@ const slotData = computed(() => {
|
|
|
61
71
|
<template v-else-if="column.type === TypeOfColumn.Action">
|
|
62
72
|
<a href="#" v-on:click="column.doAction(item)">{{ getColumnDisplayContent(column, item, i) }}</a>
|
|
63
73
|
</template>
|
|
64
|
-
<template v-else-if="column.type
|
|
65
|
-
<lkt-field
|
|
66
|
-
v-bind
|
|
67
|
-
:
|
|
68
|
-
:
|
|
69
|
-
:value-slot="column.valueSlot"
|
|
70
|
-
:slot-data="slotData"
|
|
71
|
-
v-model="value"/>
|
|
72
|
-
</template>
|
|
73
|
-
<template v-else-if="column.type === TypeOfColumn.Email">
|
|
74
|
-
<lkt-field-text
|
|
75
|
-
v-bind:read-mode="!column.editable || !editModeEnabled"
|
|
74
|
+
<template v-else-if="column.type !== ''">
|
|
75
|
+
<lkt-field
|
|
76
|
+
v-bind="column.field"
|
|
77
|
+
:type="computedColumnType"
|
|
78
|
+
:read-mode="!column.editable || !editModeEnabled"
|
|
76
79
|
:ref="(el:any) => inputElement = el"
|
|
77
|
-
:edit-slot="column.editSlot"
|
|
78
|
-
:value-slot="column.valueSlot"
|
|
79
80
|
:slot-data="slotData"
|
|
80
|
-
|
|
81
|
+
:label="column.type === 'switch' || column.type === 'check' ? column.label : ''"
|
|
82
|
+
:modal-key="computedModalKey"
|
|
83
|
+
:options="computedOptions"
|
|
81
84
|
v-model="value"/>
|
|
82
85
|
</template>
|
|
83
|
-
<template v-else-if="column.type === TypeOfColumn.Tel">
|
|
84
|
-
<lkt-field-text
|
|
85
|
-
v-bind:read-mode="!column.editable || !editModeEnabled"
|
|
86
|
-
:ref="(el:any) => inputElement = el"
|
|
87
|
-
:edit-slot="column.editSlot"
|
|
88
|
-
:value-slot="column.valueSlot"
|
|
89
|
-
:slot-data="slotData"
|
|
90
|
-
is-tel
|
|
91
|
-
v-model="value"/>
|
|
92
|
-
</template>
|
|
93
|
-
<template v-else-if="column.type === TypeOfColumn.Integer">
|
|
94
|
-
<lkt-field-text
|
|
95
|
-
v-bind:read-mode="!column.editable || !editModeEnabled"
|
|
96
|
-
:ref="(el:any) => inputElement = el"
|
|
97
|
-
:edit-slot="column.editSlot"
|
|
98
|
-
:value-slot="column.valueSlot"
|
|
99
|
-
:slot-data="slotData"
|
|
100
|
-
is-number
|
|
101
|
-
v-model="value"/>
|
|
102
|
-
</template>
|
|
103
|
-
<template v-else-if="column.type === TypeOfColumn.Float">
|
|
104
|
-
<lkt-field-text
|
|
105
|
-
v-bind:read-mode="!column.editable || !editModeEnabled"
|
|
106
|
-
:ref="(el:any) => inputElement = el"
|
|
107
|
-
:edit-slot="column.editSlot"
|
|
108
|
-
:value-slot="column.valueSlot"
|
|
109
|
-
:slot-data="slotData"
|
|
110
|
-
is-number
|
|
111
|
-
v-model="value"/>
|
|
112
|
-
</template>
|
|
113
|
-
<template v-else-if="column.type === TypeOfColumn.Check">
|
|
114
|
-
<lkt-field-switch is-check v-bind:read-mode="!column.editable || !editModeEnabled" :ref="(el:any) => inputElement = el" v-model="value"/>
|
|
115
|
-
</template>
|
|
116
|
-
<template v-else-if="column.type === TypeOfColumn.Switch">
|
|
117
|
-
<lkt-field-switch v-bind:read-mode="!column.editable || !editModeEnabled" :ref="(el:any) => inputElement = el" v-model="value"/>
|
|
118
|
-
</template>
|
|
119
|
-
<template v-else-if="column.type === TypeOfColumn.File">
|
|
120
|
-
<lkt-field-file v-bind:read-mode="!column.editable || !editModeEnabled" :ref="(el:any) => inputElement = el" v-model="value"/>
|
|
121
|
-
</template>
|
|
122
|
-
<template v-else-if="column.type === TypeOfColumn.Select">
|
|
123
|
-
<lkt-loader v-if="loadingColumn"></lkt-loader>
|
|
124
|
-
<lkt-field-select
|
|
125
|
-
v-else
|
|
126
|
-
v-bind:read-mode="!column.editable || !editModeEnabled"
|
|
127
|
-
:ref="(el:any) => inputElement = el"
|
|
128
|
-
v-model="value"
|
|
129
|
-
:slot-data="slotData"
|
|
130
|
-
v-bind:resource="column.resource"
|
|
131
|
-
v-bind:use-resource-slot="column.resourceSlot ? column.resourceSlot : column.resource"
|
|
132
|
-
v-bind:resource-data="column.resourceData"
|
|
133
|
-
v-bind:options="column.options"
|
|
134
|
-
v-bind:multiple="column.isMultiple"
|
|
135
|
-
v-bind:tags="column.tags"
|
|
136
|
-
v-bind:multiple-display="column.multipleDisplay"
|
|
137
|
-
v-bind:multiple-display-edition="column.multipleDisplayEdition"/>
|
|
138
|
-
</template>
|
|
139
86
|
<template v-else>
|
|
140
87
|
{{ getColumnDisplayContent(column, item, i, columns) }}
|
|
141
88
|
</template>
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
getColumnDisplayContent,
|
|
6
6
|
getHorizontalColSpan
|
|
7
7
|
} from "../functions/table-functions";
|
|
8
|
-
import {
|
|
8
|
+
import {Column} from "../instances/Column";
|
|
9
9
|
import LktTableCell from "./LktTableCell.vue";
|
|
10
10
|
import {computed, ref, watch} from "vue";
|
|
11
11
|
import {LktObject} from "lkt-ts-interfaces";
|
|
@@ -28,7 +28,7 @@ const props = withDefaults(defineProps<{
|
|
|
28
28
|
canEdit: boolean
|
|
29
29
|
editModeEnabled: boolean
|
|
30
30
|
i: number
|
|
31
|
-
visibleColumns:
|
|
31
|
+
visibleColumns: Column[]
|
|
32
32
|
emptyColumns: string[]
|
|
33
33
|
dropConfirm: string
|
|
34
34
|
dropText: string
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import {getVerticalColSpan} from "../functions/table-functions";
|
|
3
|
-
import {
|
|
3
|
+
import {Column} from "../instances/Column";
|
|
4
4
|
import {computed} from "vue";
|
|
5
5
|
import {LktObject} from "lkt-ts-interfaces";
|
|
6
6
|
import {__} from "lkt-i18n";
|
|
@@ -8,7 +8,7 @@ import {__} from "lkt-i18n";
|
|
|
8
8
|
const emit = defineEmits(['click']);
|
|
9
9
|
|
|
10
10
|
const props = withDefaults(defineProps<{
|
|
11
|
-
column:
|
|
11
|
+
column: Column,
|
|
12
12
|
sortBy: string,
|
|
13
13
|
sortDirection: string,
|
|
14
14
|
amountOfColumns: number,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {defaultTableSorter, getColumnByKey, getDefaultSortColumn} from "../functions/table-functions";
|
|
3
3
|
import LktTableRow from "../components/LktTableRow.vue";
|
|
4
4
|
import {computed, nextTick, onMounted, ref, useSlots, watch} from "vue";
|
|
5
|
-
import {
|
|
5
|
+
import {Column} from "../instances/Column";
|
|
6
6
|
import LktHiddenRow from "../components/LktHiddenRow.vue";
|
|
7
7
|
import {generateRandomString, replaceAll} from "lkt-string-tools";
|
|
8
8
|
import {LktObject} from "lkt-ts-interfaces";
|
|
@@ -21,7 +21,7 @@ const slots = useSlots();
|
|
|
21
21
|
|
|
22
22
|
const props = withDefaults(defineProps<{
|
|
23
23
|
modelValue: LktObject[]
|
|
24
|
-
columns:
|
|
24
|
+
columns: Column[]
|
|
25
25
|
sorter?: Function
|
|
26
26
|
draggableChecker?: Function
|
|
27
27
|
checkValidDrag?: Function
|
|
@@ -188,7 +188,7 @@ const uniqueId = generateRandomString(12);
|
|
|
188
188
|
const emptyColumns = computed(() => {
|
|
189
189
|
if (!props.hideEmptyColumns) return [];
|
|
190
190
|
let r: string[] = [];
|
|
191
|
-
Columns.value.forEach((column:
|
|
191
|
+
Columns.value.forEach((column: Column) => {
|
|
192
192
|
let key = column.key;
|
|
193
193
|
|
|
194
194
|
let ok = false;
|
|
@@ -204,10 +204,10 @@ const emptyColumns = computed(() => {
|
|
|
204
204
|
return r;
|
|
205
205
|
}),
|
|
206
206
|
visibleColumns = computed(() => {
|
|
207
|
-
return Columns.value.filter((c:
|
|
207
|
+
return Columns.value.filter((c: Column) => !c.hidden);
|
|
208
208
|
}),
|
|
209
209
|
hiddenColumns = computed(() => {
|
|
210
|
-
return Columns.value.filter((c:
|
|
210
|
+
return Columns.value.filter((c: Column) => c.hidden);
|
|
211
211
|
}),
|
|
212
212
|
hiddenColumnsColSpan = computed(() => {
|
|
213
213
|
let r = visibleColumns.value.length + 1;
|
|
@@ -215,7 +215,7 @@ const emptyColumns = computed(() => {
|
|
|
215
215
|
return r;
|
|
216
216
|
}),
|
|
217
217
|
rowKeyColumns = computed(() => {
|
|
218
|
-
return Columns.value.filter((c:
|
|
218
|
+
return Columns.value.filter((c: Column) => c.isForRowKey);
|
|
219
219
|
}),
|
|
220
220
|
displayHiddenColumnsIndicator = computed(() => {
|
|
221
221
|
return hiddenColumns.value.length > 0 && !props.sortable;
|
|
@@ -307,7 +307,7 @@ const getItemByEvent = (e: any) => {
|
|
|
307
307
|
isVisible = (index: number) => {
|
|
308
308
|
return Hidden.value['tr_' + index] === true;
|
|
309
309
|
},
|
|
310
|
-
sort = (column:
|
|
310
|
+
sort = (column: Column | null) => {
|
|
311
311
|
if (!column) return;
|
|
312
312
|
if (column.sortable) {
|
|
313
313
|
Items.value = Items.value.sort((a: any, b: any) => {
|
|
@@ -325,32 +325,6 @@ const getItemByEvent = (e: any) => {
|
|
|
325
325
|
let k = 'tr_' + i;
|
|
326
326
|
Hidden.value[k] = typeof Hidden.value[k] === 'undefined' ? true : !Hidden.value[k];
|
|
327
327
|
},
|
|
328
|
-
autoLoadSelectColumnsOptions = () => {
|
|
329
|
-
|
|
330
|
-
Columns.value.forEach(col => {
|
|
331
|
-
if (col.type === 'select' && col.autoLoadSelectOptions) {
|
|
332
|
-
|
|
333
|
-
let key = col.autoLoadSelectOptionsKey !== '' ? col.autoLoadSelectOptionsKey : col.key,
|
|
334
|
-
opts = [];
|
|
335
|
-
|
|
336
|
-
Items.value.forEach(item => {
|
|
337
|
-
if (Array.isArray(item[key])) {
|
|
338
|
-
item[key].forEach(opt => opts.push(opt));
|
|
339
|
-
}
|
|
340
|
-
});
|
|
341
|
-
|
|
342
|
-
let flags = {};
|
|
343
|
-
|
|
344
|
-
opts = opts.filter(function (opt) {
|
|
345
|
-
if (flags[opt.value]) return false;
|
|
346
|
-
flags[opt.value] = true;
|
|
347
|
-
return true;
|
|
348
|
-
});
|
|
349
|
-
|
|
350
|
-
col.setOptions(opts);
|
|
351
|
-
}
|
|
352
|
-
})
|
|
353
|
-
},
|
|
354
328
|
validDragChecker = (evt: any) => {
|
|
355
329
|
if (typeof props.checkValidDrag === 'function') return props.checkValidDrag(evt);
|
|
356
330
|
return true;
|
|
@@ -463,7 +437,6 @@ const getItemByEvent = (e: any) => {
|
|
|
463
437
|
};
|
|
464
438
|
|
|
465
439
|
onMounted(() => {
|
|
466
|
-
autoLoadSelectColumnsOptions();
|
|
467
440
|
if (props.initialSorting) {
|
|
468
441
|
sort(getColumnByKey(props.columns, SortBy.value));
|
|
469
442
|
}
|
|
@@ -482,7 +455,6 @@ watch(() => props.editMode, (v) => editModeEnabled.value = v);
|
|
|
482
455
|
watch(() => props.columns, (v) => Columns.value = v);
|
|
483
456
|
watch(() => props.modelValue, (v) => Items.value = v);
|
|
484
457
|
watch(Items, (v: any) => {
|
|
485
|
-
autoLoadSelectColumnsOptions();
|
|
486
458
|
dataState.value.increment({items: v});
|
|
487
459
|
emit('update:modelValue', v);
|
|
488
460
|
}, {deep: true});
|
|
@@ -549,7 +521,8 @@ const hasEmptySlot = computed(() => {
|
|
|
549
521
|
/>
|
|
550
522
|
|
|
551
523
|
<div class="switch-edition-mode">
|
|
552
|
-
<lkt-field
|
|
524
|
+
<lkt-field
|
|
525
|
+
type="switch"
|
|
553
526
|
v-show="switchEditionEnabled"
|
|
554
527
|
v-model="editModeEnabled"
|
|
555
528
|
:label="computedEditModeText"/>
|