lkt-table 2.0.40 → 2.0.42
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/dist/build.d.ts +8 -8
- package/dist/build.js +1163 -1107
- package/dist/components/LktTableRow.vue.d.ts +13 -7
- package/package.json +1 -1
- package/src/components/LktTableCell.vue +13 -0
- package/src/components/LktTableRow.vue +30 -3
- package/src/lib-components/LktTable.vue +73 -12
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Component } from "vue";
|
|
2
|
+
import { Column, LktObject, TablePermission, ValidTableRowTypeValue } from "lkt-vue-kernel";
|
|
2
3
|
type __VLS_Props = {
|
|
3
4
|
modelValue: LktObject;
|
|
4
5
|
isDraggable: boolean;
|
|
@@ -19,8 +20,12 @@ type __VLS_Props = {
|
|
|
19
20
|
renderDrag?: boolean | Function;
|
|
20
21
|
disabledDrag?: boolean | Function;
|
|
21
22
|
itemContainerClass?: string | Function;
|
|
23
|
+
itemSlotComponent?: string | Function | Component;
|
|
24
|
+
itemSlotData?: LktObject | Function;
|
|
25
|
+
itemSlotEvents?: LktObject | Function;
|
|
26
|
+
permissions?: Array<TablePermission>;
|
|
22
27
|
};
|
|
23
|
-
declare var
|
|
28
|
+
declare var __VLS_30: `item-${number}`, __VLS_31: {
|
|
24
29
|
item: LktObject;
|
|
25
30
|
index: number;
|
|
26
31
|
editing: boolean;
|
|
@@ -30,7 +35,7 @@ declare var __VLS_26: `item-${number}`, __VLS_27: {
|
|
|
30
35
|
canDrop: boolean;
|
|
31
36
|
isLoading: boolean;
|
|
32
37
|
doDrop: () => void;
|
|
33
|
-
},
|
|
38
|
+
}, __VLS_33: {
|
|
34
39
|
item: LktObject;
|
|
35
40
|
index: number;
|
|
36
41
|
editing: boolean;
|
|
@@ -40,18 +45,18 @@ declare var __VLS_26: `item-${number}`, __VLS_27: {
|
|
|
40
45
|
canDrop: boolean;
|
|
41
46
|
isLoading: boolean;
|
|
42
47
|
doDrop: () => void;
|
|
43
|
-
},
|
|
48
|
+
}, __VLS_36: string, __VLS_37: {
|
|
44
49
|
value: any;
|
|
45
50
|
item: LktObject;
|
|
46
51
|
column: Column;
|
|
47
52
|
i: number;
|
|
48
53
|
};
|
|
49
54
|
type __VLS_Slots = {} & {
|
|
50
|
-
[K in NonNullable<typeof
|
|
55
|
+
[K in NonNullable<typeof __VLS_30>]?: (props: typeof __VLS_31) => any;
|
|
51
56
|
} & {
|
|
52
|
-
[K in NonNullable<typeof
|
|
57
|
+
[K in NonNullable<typeof __VLS_36>]?: (props: typeof __VLS_37) => any;
|
|
53
58
|
} & {
|
|
54
|
-
item?: (props: typeof
|
|
59
|
+
item?: (props: typeof __VLS_33) => any;
|
|
55
60
|
};
|
|
56
61
|
declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
57
62
|
"update:modelValue": (...args: any[]) => void;
|
|
@@ -81,6 +86,7 @@ declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {}, {}
|
|
|
81
86
|
renderDrag: boolean | Function;
|
|
82
87
|
disabledDrag: boolean | Function;
|
|
83
88
|
itemContainerClass: string | Function;
|
|
89
|
+
permissions: Array<TablePermission>;
|
|
84
90
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
85
91
|
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
86
92
|
export default _default;
|
package/package.json
CHANGED
|
@@ -112,6 +112,19 @@ const computedFieldLabel = computed(() => {
|
|
|
112
112
|
:prop="item"
|
|
113
113
|
@click="onClickInlineDrop"
|
|
114
114
|
>{{ getColumnDisplayContent(column, item, i) }}</lkt-button>
|
|
115
|
+
|
|
116
|
+
<lkt-field
|
|
117
|
+
v-else-if="column.type === ColumnType.ColumnIndex && column.field"
|
|
118
|
+
v-bind="<FieldConfig>{
|
|
119
|
+
...computedFieldConfig,
|
|
120
|
+
modelValue: getColumnDisplayContent(column, item, i, columns),
|
|
121
|
+
readMode: true,
|
|
122
|
+
slotData,
|
|
123
|
+
label: computedFieldLabel,
|
|
124
|
+
modalData: computedModalData,
|
|
125
|
+
prop: item,
|
|
126
|
+
}"
|
|
127
|
+
/>
|
|
115
128
|
<template v-else>
|
|
116
129
|
{{ getColumnDisplayContent(column, item, i, columns) }}
|
|
117
130
|
</template>
|
|
@@ -7,9 +7,16 @@ import {
|
|
|
7
7
|
getHorizontalColSpan
|
|
8
8
|
} from "../functions/table-functions";
|
|
9
9
|
import LktTableCell from "./LktTableCell.vue";
|
|
10
|
-
import {computed, ref, useSlots, watch} from "vue";
|
|
10
|
+
import {Component, computed, ref, useSlots, watch} from "vue";
|
|
11
11
|
import {Settings} from "../settings/Settings";
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
Column,
|
|
14
|
+
ItemSlotComponentConfig,
|
|
15
|
+
LktObject,
|
|
16
|
+
TablePermission,
|
|
17
|
+
TableRowType,
|
|
18
|
+
ValidTableRowTypeValue
|
|
19
|
+
} from "lkt-vue-kernel";
|
|
13
20
|
|
|
14
21
|
const slots = useSlots();
|
|
15
22
|
const emit = defineEmits([
|
|
@@ -40,6 +47,10 @@ const props = withDefaults(defineProps<{
|
|
|
40
47
|
renderDrag?: boolean | Function
|
|
41
48
|
disabledDrag?: boolean | Function
|
|
42
49
|
itemContainerClass?: string | Function
|
|
50
|
+
itemSlotComponent?: string | Function | Component
|
|
51
|
+
itemSlotData?: LktObject | Function
|
|
52
|
+
itemSlotEvents?: LktObject | Function
|
|
53
|
+
permissions?: Array<TablePermission>
|
|
43
54
|
}>(), {
|
|
44
55
|
modelValue: () => ({}),
|
|
45
56
|
isDraggable: true,
|
|
@@ -56,6 +67,7 @@ const props = withDefaults(defineProps<{
|
|
|
56
67
|
renderDrag: true,
|
|
57
68
|
disabledDrag: true,
|
|
58
69
|
itemContainerClass: '',
|
|
70
|
+
permissions: () => [],
|
|
59
71
|
});
|
|
60
72
|
|
|
61
73
|
const Item = ref(props.modelValue);
|
|
@@ -156,7 +168,22 @@ const canRenderDragIndicator = computed(() => {
|
|
|
156
168
|
</lkt-button>
|
|
157
169
|
</div>
|
|
158
170
|
</td>
|
|
159
|
-
<template v-if="
|
|
171
|
+
<template v-if="itemSlotComponent">
|
|
172
|
+
<td :key="'td' + i" :colspan="visibleColumns.length">
|
|
173
|
+
<component
|
|
174
|
+
:is="itemSlotComponent"
|
|
175
|
+
v-bind="<ItemSlotComponentConfig>{
|
|
176
|
+
item: Item,
|
|
177
|
+
index: i,
|
|
178
|
+
editing: editModeEnabled,
|
|
179
|
+
perms: permissions,
|
|
180
|
+
data: itemSlotData,
|
|
181
|
+
events: itemSlotEvents
|
|
182
|
+
}"
|
|
183
|
+
/>
|
|
184
|
+
</td>
|
|
185
|
+
</template>
|
|
186
|
+
<template v-else-if="canCustomItem && slots[`item-${i}`]">
|
|
160
187
|
<td :key="'td' + i" :colspan="visibleColumns.length">
|
|
161
188
|
<slot
|
|
162
189
|
:name="`item-${i}`"
|
|
@@ -6,11 +6,11 @@ import {computed, nextTick, onMounted, ref, useSlots, watch} from "vue";
|
|
|
6
6
|
import {
|
|
7
7
|
AccordionConfig,
|
|
8
8
|
ButtonConfig,
|
|
9
|
-
ButtonType,
|
|
9
|
+
ButtonType, ClickEventArgs,
|
|
10
10
|
Column, ColumnConfig,
|
|
11
11
|
ensureButtonConfig,
|
|
12
12
|
extractI18nValue,
|
|
13
|
-
getDefaultValues, ItemSlotComponentConfig,
|
|
13
|
+
getDefaultValues, HeaderConfig, ItemSlotComponentConfig,
|
|
14
14
|
LktObject,
|
|
15
15
|
LktSettings,
|
|
16
16
|
PaginatorType,
|
|
@@ -70,6 +70,7 @@ const Page = ref(props.paginator?.modelValue),
|
|
|
70
70
|
editModeEnabled = ref(props.editMode),
|
|
71
71
|
updateTimeStamp = ref(0),
|
|
72
72
|
sortableContainer = ref(<HTMLElement | null>null),
|
|
73
|
+
activeType = ref(props.type),
|
|
73
74
|
currentSlide = ref(props.carousel?.currentSlide || 0)
|
|
74
75
|
;
|
|
75
76
|
|
|
@@ -310,7 +311,7 @@ const getItemByEvent = (e: any) => {
|
|
|
310
311
|
if (typeof props.newValueGenerator === 'function') {
|
|
311
312
|
let newValue = props.newValueGenerator();
|
|
312
313
|
|
|
313
|
-
if (typeof newValue === 'object' ||
|
|
314
|
+
if (typeof newValue === 'object' || computedType.value !== TableType.Table) {
|
|
314
315
|
Items.value.push(newValue);
|
|
315
316
|
return;
|
|
316
317
|
}
|
|
@@ -431,7 +432,7 @@ const getItemByEvent = (e: any) => {
|
|
|
431
432
|
|| (hasModalCreatePerm.value && editModeEnabled.value);
|
|
432
433
|
}),
|
|
433
434
|
computedIsList = computed(() => {
|
|
434
|
-
return [TableType.Ol, TableType.Ul].includes(
|
|
435
|
+
return [TableType.Ol, TableType.Ul].includes(computedType.value);
|
|
435
436
|
}),
|
|
436
437
|
canDisplayItem = (item: LktObject, index: number) => {
|
|
437
438
|
if (typeof props.itemDisplayChecker === 'function') return props.itemDisplayChecker(item, index);
|
|
@@ -541,13 +542,69 @@ const hasEmptySlot = computed(() => {
|
|
|
541
542
|
displayLktHeader = computed(() => {
|
|
542
543
|
return typeof props.header === 'object'
|
|
543
544
|
&& Object.keys(props.header).length > 0;
|
|
545
|
+
}),
|
|
546
|
+
computedType = computed(() => {
|
|
547
|
+
if (!Array.isArray(props.switchableTypes)) return props.type;
|
|
548
|
+
if (props.switchableTypes.length > 0) {
|
|
549
|
+
return activeType.value;
|
|
550
|
+
}
|
|
551
|
+
return props.type;
|
|
544
552
|
});
|
|
545
553
|
|
|
554
|
+
const availableTypes = computed(() => {
|
|
555
|
+
if (!Array.isArray(props.switchableTypes)) return [];
|
|
556
|
+
if (props.switchableTypes.length > 0) {
|
|
557
|
+
if (!props.switchableTypes.includes(props.type)) {
|
|
558
|
+
return [
|
|
559
|
+
props.type,
|
|
560
|
+
...props.switchableTypes,
|
|
561
|
+
]
|
|
562
|
+
}
|
|
563
|
+
return props.switchableTypes;
|
|
564
|
+
}
|
|
565
|
+
return [];
|
|
566
|
+
}),
|
|
567
|
+
computedSwitchTypesButtons = computed(() => {
|
|
568
|
+
let r: Array<ButtonConfig> = [];
|
|
569
|
+
availableTypes.value.forEach(type => {
|
|
570
|
+
r.push(<ButtonConfig>{
|
|
571
|
+
...props.switchableTypesButtons[type],
|
|
572
|
+
events: {
|
|
573
|
+
click: (args: ClickEventArgs) => {
|
|
574
|
+
|
|
575
|
+
activeType.value = type;
|
|
576
|
+
|
|
577
|
+
if (typeof props.switchableTypesButtons[type] === 'function') {
|
|
578
|
+
props.switchableTypesButtons[type](args);
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
});
|
|
583
|
+
});
|
|
584
|
+
return r;
|
|
585
|
+
}),
|
|
586
|
+
computedHeaderConfig = computed(() => {
|
|
587
|
+
return <HeaderConfig>{
|
|
588
|
+
...props.header,
|
|
589
|
+
topEndButtons: [
|
|
590
|
+
...typeof props.header?.topEndButtons === 'undefined' ? [] : props.header?.topEndButtons,
|
|
591
|
+
...computedSwitchTypesButtons.value,
|
|
592
|
+
]
|
|
593
|
+
}
|
|
594
|
+
});
|
|
595
|
+
|
|
596
|
+
const checkUseItemSlot = (item: LktObject, index: number) => {
|
|
597
|
+
|
|
598
|
+
if (typeof props.useItemSlot === 'function') return props.useItemSlot({item, index}) === true;
|
|
599
|
+
|
|
600
|
+
return props.useItemSlot;
|
|
601
|
+
}
|
|
602
|
+
|
|
546
603
|
</script>
|
|
547
604
|
|
|
548
605
|
<template>
|
|
549
606
|
<section ref="element" class="lkt-table-page" :id="'lkt-table-page-' + uniqueId">
|
|
550
|
-
<lkt-header v-if="displayLktHeader" v-bind="
|
|
607
|
+
<lkt-header v-if="displayLktHeader" v-bind="computedHeaderConfig"/>
|
|
551
608
|
<header v-else-if="computedTitle || slots.title" :class="headerClass">
|
|
552
609
|
<component :is="computedTitleTag" v-if="computedTitle">
|
|
553
610
|
<i v-if="titleIcon" :class="titleIcon"/>
|
|
@@ -713,7 +770,7 @@ const hasEmptySlot = computed(() => {
|
|
|
713
770
|
</div>
|
|
714
771
|
|
|
715
772
|
<div v-show="computedShowItems" class="lkt-table">
|
|
716
|
-
<table v-if="
|
|
773
|
+
<table v-if="computedType === TableType.Table">
|
|
717
774
|
<thead v-if="!hideTableHeader">
|
|
718
775
|
<tr>
|
|
719
776
|
<th v-if="computedDragModeEnabled && editModeEnabled" data-role="drag-indicator"/>
|
|
@@ -759,12 +816,16 @@ const hasEmptySlot = computed(() => {
|
|
|
759
816
|
:disabled-drag="computedDisabledDrag"
|
|
760
817
|
:is-loading="isLoading"
|
|
761
818
|
:item-container-class="itemContainerClass"
|
|
819
|
+
:item-slot-component="computedItemSlotComponent"
|
|
820
|
+
:item-slot-data="computedItemSlotData"
|
|
821
|
+
:item-slot-events="itemSlotEvents"
|
|
822
|
+
:permissions="permissions"
|
|
762
823
|
@click="onClick"
|
|
763
824
|
@item-up="onItemUp"
|
|
764
825
|
@item-down="onItemDown"
|
|
765
826
|
@item-drop="onItemDrop"
|
|
766
827
|
>
|
|
767
|
-
<template v-if="slots[`item-${i}`]" v-slot:[`item-${i}`]="row">
|
|
828
|
+
<template v-if="slots[`item-${i}`] && checkUseItemSlot(row, i)" v-slot:[`item-${i}`]="row">
|
|
768
829
|
<slot
|
|
769
830
|
:name="`item-${i}`"
|
|
770
831
|
:[slotItemVar]="row.item"
|
|
@@ -778,7 +839,7 @@ const hasEmptySlot = computed(() => {
|
|
|
778
839
|
v-bind:do-drop="row.doDrop"
|
|
779
840
|
/>
|
|
780
841
|
</template>
|
|
781
|
-
<template v-else-if="slots.item" #item="row">
|
|
842
|
+
<template v-else-if="slots.item && checkUseItemSlot(row, i)" #item="row">
|
|
782
843
|
<slot
|
|
783
844
|
name="item"
|
|
784
845
|
:[slotItemVar]="row.item"
|
|
@@ -806,7 +867,7 @@ const hasEmptySlot = computed(() => {
|
|
|
806
867
|
</tbody>
|
|
807
868
|
</table>
|
|
808
869
|
|
|
809
|
-
<div v-else-if="
|
|
870
|
+
<div v-else-if="computedType === TableType.Item"
|
|
810
871
|
ref="tableBody"
|
|
811
872
|
:id="'lkt-table-body-' + uniqueId"
|
|
812
873
|
class="lkt-table-items-container"
|
|
@@ -864,7 +925,7 @@ const hasEmptySlot = computed(() => {
|
|
|
864
925
|
</template>
|
|
865
926
|
</div>
|
|
866
927
|
|
|
867
|
-
<div v-else-if="
|
|
928
|
+
<div v-else-if="computedType === TableType.Accordion"
|
|
868
929
|
ref="tableBody"
|
|
869
930
|
:id="'lkt-table-body-' + uniqueId"
|
|
870
931
|
class="lkt-table-items-container"
|
|
@@ -941,7 +1002,7 @@ const hasEmptySlot = computed(() => {
|
|
|
941
1002
|
</template>
|
|
942
1003
|
</div>
|
|
943
1004
|
|
|
944
|
-
<component :is="
|
|
1005
|
+
<component :is="computedType" v-else-if="computedIsList" class="lkt-table-items-container"
|
|
945
1006
|
:class="itemsContainerClass">
|
|
946
1007
|
<template
|
|
947
1008
|
v-for="(item, i) in Items" :key="getRowKey(item, i)">
|
|
@@ -975,7 +1036,7 @@ const hasEmptySlot = computed(() => {
|
|
|
975
1036
|
</template>
|
|
976
1037
|
</component>
|
|
977
1038
|
|
|
978
|
-
<div v-else-if="
|
|
1039
|
+
<div v-else-if="computedType === TableType.Carousel"
|
|
979
1040
|
ref="tableBody"
|
|
980
1041
|
:id="'lkt-table-body-' + uniqueId"
|
|
981
1042
|
class="lkt-table-items-container"
|