@katlux/toolkit 0.1.1-alpha.108 → 0.1.1-alpha.110
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/module.json +1 -1
- package/dist/runtime/components/KAlert/KAlert.global.d.vue.ts +0 -2
- package/dist/runtime/components/KAlert/KAlert.global.vue +5 -5
- package/dist/runtime/components/KAlert/KAlert.global.vue.d.ts +0 -2
- package/dist/runtime/components/KBulkActions/KBulkActions.logic.d.ts +2 -0
- package/dist/runtime/components/KBulkActions/KBulkActions.logic.js +46 -3
- package/dist/runtime/components/KButton/KButton.global.d.vue.ts +1 -1
- package/dist/runtime/components/KButton/KButton.global.vue.d.ts +1 -1
- package/dist/runtime/components/KCheckbox/KCheckbox.global.d.vue.ts +1 -1
- package/dist/runtime/components/KCheckbox/KCheckbox.global.vue.d.ts +1 -1
- package/dist/runtime/components/KContextMenu/KContextMenu.global.d.vue.ts +1 -1
- package/dist/runtime/components/KContextMenu/KContextMenu.global.vue.d.ts +1 -1
- package/dist/runtime/components/KDatatable/KDataIterator.global.d.vue.ts +1 -1
- package/dist/runtime/components/KDatatable/KDataIterator.global.vue.d.ts +1 -1
- package/dist/runtime/components/KDatatable/KDataIterator.logic.d.ts +5 -2
- package/dist/runtime/components/KDatatable/KDataIterator.logic.js +60 -9
- package/dist/runtime/components/KDatatable/KDatatable.logic.d.ts +2 -2
- package/dist/runtime/components/KDatatable/KDatatable.logic.js +28 -10
- package/dist/runtime/components/KIcon/KIcon.global.d.vue.ts +12 -2
- package/dist/runtime/components/KIcon/KIcon.global.vue.d.ts +12 -2
- package/dist/runtime/components/KIcon/KIcon.logic.d.ts +7 -2
- package/dist/runtime/components/KIcon/KIcon.logic.js +9 -4
- package/dist/runtime/components/KPagination/KPagination.logic.js +31 -16
- package/dist/runtime/components/KSlider/KSlider.global.d.vue.ts +1 -1
- package/dist/runtime/components/KSlider/KSlider.global.vue.d.ts +1 -1
- package/dist/runtime/components/KTextarea/KTextarea.global.d.vue.ts +1 -1
- package/dist/runtime/components/KTextarea/KTextarea.global.vue.d.ts +1 -1
- package/dist/runtime/components/KTreePicker/KTreePicker.global.d.vue.ts +3 -3
- package/dist/runtime/components/KTreePicker/KTreePicker.global.vue.d.ts +3 -3
- package/dist/runtime/components/KTreeView/KTreeView.global.d.vue.ts +3 -3
- package/dist/runtime/components/KTreeView/KTreeView.global.vue.d.ts +3 -3
- package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.d.vue.ts +3 -3
- package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.vue +38 -12
- package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.vue.d.ts +3 -3
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -5,9 +5,7 @@ declare const __VLS_export: import("vue").DefineComponent<KAlertProps, {}, {}, {
|
|
|
5
5
|
onDismiss?: (() => any) | undefined;
|
|
6
6
|
}>, {
|
|
7
7
|
type: import("./KAlert.logic.js").KAlertType;
|
|
8
|
-
title: string;
|
|
9
8
|
dismissible: boolean;
|
|
10
|
-
icon: string;
|
|
11
9
|
hideIcon: boolean;
|
|
12
10
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
13
11
|
declare const _default: typeof __VLS_export;
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
import { usePresetComponent } from "../../composables/usePresetComponent";
|
|
3
3
|
import KAlertDefault from "../../presets/default/components/KAlert/KAlert.vue";
|
|
4
4
|
import { KAlertDefaultProps } from "./KAlert.logic";
|
|
5
|
-
const props = defineProps(
|
|
6
|
-
type: { type: String, required: false },
|
|
5
|
+
const props = defineProps({
|
|
6
|
+
type: { type: String, required: false, default: "info" },
|
|
7
7
|
title: { type: String, required: false },
|
|
8
|
-
dismissible: { type: Boolean, required: false },
|
|
8
|
+
dismissible: { type: Boolean, required: false, default: false },
|
|
9
9
|
icon: { type: String, required: false },
|
|
10
|
-
hideIcon: { type: Boolean, required: false }
|
|
11
|
-
}
|
|
10
|
+
hideIcon: { type: Boolean, required: false, default: false }
|
|
11
|
+
});
|
|
12
12
|
const emit = defineEmits(["dismiss"]);
|
|
13
13
|
const presetComponent = usePresetComponent("KAlert", KAlertDefault);
|
|
14
14
|
</script>
|
|
@@ -5,9 +5,7 @@ declare const __VLS_export: import("vue").DefineComponent<KAlertProps, {}, {}, {
|
|
|
5
5
|
onDismiss?: (() => any) | undefined;
|
|
6
6
|
}>, {
|
|
7
7
|
type: import("./KAlert.logic.js").KAlertType;
|
|
8
|
-
title: string;
|
|
9
8
|
dismissible: boolean;
|
|
10
|
-
icon: string;
|
|
11
9
|
hideIcon: boolean;
|
|
12
10
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
13
11
|
declare const _default: typeof __VLS_export;
|
|
@@ -6,6 +6,7 @@ export interface KBulkActionsProps {
|
|
|
6
6
|
selectAll: boolean;
|
|
7
7
|
}
|
|
8
8
|
export declare const KBulkActionsDefaultProps: {};
|
|
9
|
+
export declare function getApplicableRows(action: IKDatatableAction, selectedRows: TDataRow[], selectAll: boolean): TDataRow[];
|
|
9
10
|
export declare function useKBulkActionsLogic(props: KBulkActionsProps): {
|
|
10
11
|
selected: import("vue").Ref<{
|
|
11
12
|
action: Function;
|
|
@@ -25,4 +26,5 @@ export declare function useKBulkActionsLogic(props: KBulkActionsProps): {
|
|
|
25
26
|
dp: CFlatClientDataProvider;
|
|
26
27
|
doAction: (action: any) => void;
|
|
27
28
|
visibleBulkActions: import("vue").ComputedRef<IKDatatableAction[]>;
|
|
29
|
+
getApplicableRows: typeof getApplicableRows;
|
|
28
30
|
};
|
|
@@ -1,17 +1,58 @@
|
|
|
1
1
|
import { ref, watch, computed } from "vue";
|
|
2
2
|
import { CFlatClientDataProvider } from "@katlux/providers";
|
|
3
3
|
export const KBulkActionsDefaultProps = {};
|
|
4
|
+
export function getApplicableRows(action, selectedRows, selectAll) {
|
|
5
|
+
if (!action.visible) {
|
|
6
|
+
return selectedRows || [];
|
|
7
|
+
}
|
|
8
|
+
if (!selectedRows || selectedRows.length === 0) {
|
|
9
|
+
return [];
|
|
10
|
+
}
|
|
11
|
+
let isPerRowPredicate = false;
|
|
12
|
+
try {
|
|
13
|
+
const testResult = action.visible(selectedRows[0]);
|
|
14
|
+
if (typeof testResult === "boolean") {
|
|
15
|
+
isPerRowPredicate = true;
|
|
16
|
+
}
|
|
17
|
+
} catch {
|
|
18
|
+
isPerRowPredicate = false;
|
|
19
|
+
}
|
|
20
|
+
if (isPerRowPredicate) {
|
|
21
|
+
return selectedRows.filter((row) => {
|
|
22
|
+
try {
|
|
23
|
+
return Boolean(action.visible(row));
|
|
24
|
+
} catch {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
const isVisible = action.visible(selectedRows, selectAll);
|
|
31
|
+
return isVisible ? selectedRows : [];
|
|
32
|
+
} catch {
|
|
33
|
+
return selectedRows;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
4
36
|
export function useKBulkActionsLogic(props) {
|
|
5
37
|
const selected = ref(null);
|
|
6
38
|
const dp = new CFlatClientDataProvider();
|
|
7
39
|
const visibleBulkActions = computed(() => {
|
|
8
40
|
return props.bulkActions.filter((action) => {
|
|
9
41
|
if (!action.visible) return true;
|
|
10
|
-
|
|
42
|
+
if (!props.selectedRows || props.selectedRows.length === 0) {
|
|
43
|
+
try {
|
|
44
|
+
return Boolean(action.visible([], props.selectAll));
|
|
45
|
+
} catch {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const applicable = getApplicableRows(action, props.selectedRows, props.selectAll);
|
|
50
|
+
return applicable.length > 0;
|
|
11
51
|
});
|
|
12
52
|
});
|
|
13
53
|
watch(visibleBulkActions, (actions) => {
|
|
14
54
|
dp.setData(actions.map((row) => ({
|
|
55
|
+
...row,
|
|
15
56
|
label: row.label,
|
|
16
57
|
action: row.action
|
|
17
58
|
})));
|
|
@@ -19,13 +60,15 @@ export function useKBulkActionsLogic(props) {
|
|
|
19
60
|
function doAction(action) {
|
|
20
61
|
const act = action;
|
|
21
62
|
if (act && act.action) {
|
|
22
|
-
act
|
|
63
|
+
const applicableRows = getApplicableRows(act, props.selectedRows, props.selectAll);
|
|
64
|
+
act.action(applicableRows, props.selectAll);
|
|
23
65
|
}
|
|
24
66
|
}
|
|
25
67
|
return {
|
|
26
68
|
selected,
|
|
27
69
|
dp,
|
|
28
70
|
doAction,
|
|
29
|
-
visibleBulkActions
|
|
71
|
+
visibleBulkActions,
|
|
72
|
+
getApplicableRows
|
|
30
73
|
};
|
|
31
74
|
}
|
|
@@ -56,10 +56,10 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
56
56
|
}>, {
|
|
57
57
|
size: "small" | "large" | "medium" | undefined;
|
|
58
58
|
type: "default" | "info" | "success" | "warning" | "danger" | "primary" | "light" | "dark" | undefined;
|
|
59
|
+
loading: boolean;
|
|
59
60
|
iconOnly: boolean;
|
|
60
61
|
disabled: boolean;
|
|
61
62
|
href: string;
|
|
62
|
-
loading: boolean;
|
|
63
63
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
64
64
|
declare const _default: typeof __VLS_export;
|
|
65
65
|
export default _default;
|
|
@@ -56,10 +56,10 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
56
56
|
}>, {
|
|
57
57
|
size: "small" | "large" | "medium" | undefined;
|
|
58
58
|
type: "default" | "info" | "success" | "warning" | "danger" | "primary" | "light" | "dark" | undefined;
|
|
59
|
+
loading: boolean;
|
|
59
60
|
iconOnly: boolean;
|
|
60
61
|
disabled: boolean;
|
|
61
62
|
href: string;
|
|
62
|
-
loading: boolean;
|
|
63
63
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
64
64
|
declare const _default: typeof __VLS_export;
|
|
65
65
|
export default _default;
|
|
@@ -54,11 +54,11 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
54
54
|
}>> & Readonly<{
|
|
55
55
|
"onUpdate:modelValue"?: ((value: any) => any) | undefined;
|
|
56
56
|
}>, {
|
|
57
|
+
value: any;
|
|
57
58
|
label: string;
|
|
58
59
|
disabled: boolean;
|
|
59
60
|
validation: "error" | "success" | "warning" | null | undefined;
|
|
60
61
|
validationText: string;
|
|
61
|
-
value: any;
|
|
62
62
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
63
63
|
declare const _default: typeof __VLS_export;
|
|
64
64
|
export default _default;
|
|
@@ -54,11 +54,11 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
54
54
|
}>> & Readonly<{
|
|
55
55
|
"onUpdate:modelValue"?: ((value: any) => any) | undefined;
|
|
56
56
|
}>, {
|
|
57
|
+
value: any;
|
|
57
58
|
label: string;
|
|
58
59
|
disabled: boolean;
|
|
59
60
|
validation: "error" | "success" | "warning" | null | undefined;
|
|
60
61
|
validationText: string;
|
|
61
|
-
value: any;
|
|
62
62
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
63
63
|
declare const _default: typeof __VLS_export;
|
|
64
64
|
export default _default;
|
|
@@ -46,8 +46,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
46
46
|
"onUpdate:isOpen"?: ((value: boolean) => any) | undefined;
|
|
47
47
|
}>, {
|
|
48
48
|
isOpen: boolean;
|
|
49
|
-
teleportTo: string;
|
|
50
49
|
x: number;
|
|
50
|
+
teleportTo: string;
|
|
51
51
|
y: number;
|
|
52
52
|
target: string | HTMLElement;
|
|
53
53
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -46,8 +46,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
46
46
|
"onUpdate:isOpen"?: ((value: boolean) => any) | undefined;
|
|
47
47
|
}>, {
|
|
48
48
|
isOpen: boolean;
|
|
49
|
-
teleportTo: string;
|
|
50
49
|
x: number;
|
|
50
|
+
teleportTo: string;
|
|
51
51
|
y: number;
|
|
52
52
|
target: string | HTMLElement;
|
|
53
53
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -12,8 +12,8 @@ interface Props {
|
|
|
12
12
|
}
|
|
13
13
|
declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {
|
|
14
14
|
search: string;
|
|
15
|
-
bulkActions: IKDatatableAction[];
|
|
16
15
|
loading: boolean;
|
|
16
|
+
bulkActions: IKDatatableAction[];
|
|
17
17
|
visibleFields: Array<string> | null;
|
|
18
18
|
rowActions: IKDatatableAction[];
|
|
19
19
|
itemsPerPage: number;
|
|
@@ -12,8 +12,8 @@ interface Props {
|
|
|
12
12
|
}
|
|
13
13
|
declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {
|
|
14
14
|
search: string;
|
|
15
|
-
bulkActions: IKDatatableAction[];
|
|
16
15
|
loading: boolean;
|
|
16
|
+
bulkActions: IKDatatableAction[];
|
|
17
17
|
visibleFields: Array<string> | null;
|
|
18
18
|
rowActions: IKDatatableAction[];
|
|
19
19
|
itemsPerPage: number;
|
|
@@ -15,6 +15,9 @@ export declare const KDataIteratorDefaultProps: {
|
|
|
15
15
|
page: number;
|
|
16
16
|
};
|
|
17
17
|
export declare function useKDataIteratorLogic(props: KDataIteratorProps): {
|
|
18
|
-
selectedRows: import("@katlux/providers").CompatRef<any[]>;
|
|
19
|
-
selectAll: import("@katlux/providers").CompatRef<boolean>;
|
|
18
|
+
selectedRows: import("@katlux/providers").CompatRef<any[]> | import("vue").Ref<any[], any[]>;
|
|
19
|
+
selectAll: import("vue").Ref<boolean, boolean> | import("@katlux/providers").CompatRef<boolean>;
|
|
20
|
+
pageData: import("vue").Ref<import("@katlux/providers").TDataRow[], import("@katlux/providers").TDataRow[]>;
|
|
21
|
+
loading: import("vue").Ref<boolean, boolean>;
|
|
22
|
+
initialLoad: import("vue").Ref<boolean, boolean>;
|
|
20
23
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { watch } from "vue";
|
|
2
|
+
import { useDataProvider } from "../../composables/useDataProvider.js";
|
|
2
3
|
export const KDataIteratorDefaultProps = {
|
|
3
4
|
visibleFields: null,
|
|
4
5
|
loading: false,
|
|
@@ -7,31 +8,81 @@ export const KDataIteratorDefaultProps = {
|
|
|
7
8
|
page: 1
|
|
8
9
|
};
|
|
9
10
|
export function useKDataIteratorLogic(props) {
|
|
10
|
-
const selectedRows = props.dataProvider
|
|
11
|
-
const
|
|
11
|
+
const { pageData, selectedRows: dpSelectedRows, selectAll: dpSelectAll, loading: dpLoading, initialLoad: dpInitialLoad } = useDataProvider(props.dataProvider);
|
|
12
|
+
const selectedRows = props.dataProvider?.selectedRows && !props.dataProvider?.selectedRows?.__v_skip ? props.dataProvider.selectedRows : dpSelectedRows;
|
|
13
|
+
const selectAll = props.dataProvider?.selectAll && !props.dataProvider?.selectAll?.__v_skip ? props.dataProvider.selectAll : dpSelectAll;
|
|
14
|
+
const idKey = props.dataProvider?.idKey || "id";
|
|
15
|
+
const getRowId = (row) => row?.[idKey] ?? row?.id ?? row;
|
|
16
|
+
let isInternalUpdating = false;
|
|
17
|
+
const getPageRows = () => (props.dataProvider?.pageData?.value ?? props.dataProvider?.pageData ?? pageData.value) || [];
|
|
18
|
+
const syncToProvider = () => {
|
|
19
|
+
if (props.dataProvider?.selectedRows && props.dataProvider.selectedRows !== selectedRows) {
|
|
20
|
+
props.dataProvider.selectedRows.value = selectedRows.value;
|
|
21
|
+
}
|
|
22
|
+
if (props.dataProvider?.selectAll && props.dataProvider.selectAll !== selectAll) {
|
|
23
|
+
props.dataProvider.selectAll.value = selectAll.value;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
12
26
|
watch(() => selectAll.value, (newVal) => {
|
|
27
|
+
if (isInternalUpdating) return;
|
|
28
|
+
const currentRows = getPageRows();
|
|
13
29
|
if (newVal === false) {
|
|
14
|
-
|
|
30
|
+
const pageIds = new Set(currentRows.map(getRowId));
|
|
31
|
+
selectedRows.value = selectedRows.value.filter((r) => !pageIds.has(getRowId(r)));
|
|
15
32
|
} else {
|
|
16
|
-
|
|
33
|
+
const currentSelectedIds = new Set(selectedRows.value.map(getRowId));
|
|
34
|
+
const newSelections = currentRows.filter((r) => !currentSelectedIds.has(getRowId(r)));
|
|
35
|
+
selectedRows.value = [...selectedRows.value, ...newSelections];
|
|
17
36
|
}
|
|
37
|
+
syncToProvider();
|
|
18
38
|
});
|
|
39
|
+
watch([getPageRows, () => selectedRows.value], () => {
|
|
40
|
+
const currentRows = getPageRows();
|
|
41
|
+
if (currentRows.length === 0) {
|
|
42
|
+
if (selectAll.value) {
|
|
43
|
+
isInternalUpdating = true;
|
|
44
|
+
selectAll.value = false;
|
|
45
|
+
isInternalUpdating = false;
|
|
46
|
+
syncToProvider();
|
|
47
|
+
}
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const currentSelectedIds = new Set(selectedRows.value.map(getRowId));
|
|
51
|
+
const allSelected = currentRows.every((r) => currentSelectedIds.has(getRowId(r)));
|
|
52
|
+
if (selectAll.value !== allSelected) {
|
|
53
|
+
isInternalUpdating = true;
|
|
54
|
+
selectAll.value = allSelected;
|
|
55
|
+
isInternalUpdating = false;
|
|
56
|
+
}
|
|
57
|
+
syncToProvider();
|
|
58
|
+
}, { deep: true });
|
|
19
59
|
watch(() => props.search, (newVal) => {
|
|
20
60
|
if (newVal !== void 0) {
|
|
21
61
|
}
|
|
22
62
|
});
|
|
23
63
|
watch(() => props.itemsPerPage, (newVal) => {
|
|
24
|
-
if (newVal !== void 0 && newVal !== props.dataProvider
|
|
25
|
-
props.dataProvider
|
|
64
|
+
if (newVal !== void 0 && newVal !== props.dataProvider?.pageSize?.value) {
|
|
65
|
+
if (typeof props.dataProvider?.setPageSize === "function") {
|
|
66
|
+
props.dataProvider.setPageSize(newVal);
|
|
67
|
+
} else if (props.dataProvider?.pageSize) {
|
|
68
|
+
props.dataProvider.pageSize.value = newVal;
|
|
69
|
+
}
|
|
26
70
|
}
|
|
27
71
|
});
|
|
28
72
|
watch(() => props.page, (newVal) => {
|
|
29
|
-
if (newVal !== void 0 && newVal !== props.dataProvider
|
|
30
|
-
props.dataProvider
|
|
73
|
+
if (newVal !== void 0 && newVal !== props.dataProvider?.currentPage?.value) {
|
|
74
|
+
if (typeof props.dataProvider?.setCurrentPage === "function") {
|
|
75
|
+
props.dataProvider.setCurrentPage(newVal);
|
|
76
|
+
} else if (props.dataProvider?.currentPage) {
|
|
77
|
+
props.dataProvider.currentPage.value = newVal;
|
|
78
|
+
}
|
|
31
79
|
}
|
|
32
80
|
});
|
|
33
81
|
return {
|
|
34
82
|
selectedRows,
|
|
35
|
-
selectAll
|
|
83
|
+
selectAll,
|
|
84
|
+
pageData,
|
|
85
|
+
loading: dpLoading,
|
|
86
|
+
initialLoad: dpInitialLoad
|
|
36
87
|
};
|
|
37
88
|
}
|
|
@@ -11,8 +11,8 @@ export declare const KDatatableDefaultProps: {
|
|
|
11
11
|
emptyFilterStateText: string;
|
|
12
12
|
};
|
|
13
13
|
export declare function useKDatatableLogic(props: KDatatableProps): {
|
|
14
|
-
selectedRows: import("@katlux/providers").CompatRef<any[]>;
|
|
15
|
-
selectAll: import("@katlux/providers").CompatRef<boolean>;
|
|
14
|
+
selectedRows: import("@katlux/providers").CompatRef<any[]> | import("vue").Ref<any[], any[]>;
|
|
15
|
+
selectAll: import("vue").Ref<boolean, boolean> | import("@katlux/providers").CompatRef<boolean>;
|
|
16
16
|
getRowKey: (row: any, index: number) => string | number;
|
|
17
17
|
pageData: import("vue").Ref<import("@katlux/providers").TDataRow[], import("@katlux/providers").TDataRow[]>;
|
|
18
18
|
};
|
|
@@ -7,10 +7,12 @@ export const KDatatableDefaultProps = {
|
|
|
7
7
|
};
|
|
8
8
|
export function useKDatatableLogic(props) {
|
|
9
9
|
const { pageData, selectedRows: dpSelectedRows, selectAll: dpSelectAll } = useDataProvider(props.dataProvider);
|
|
10
|
-
const selectedRows = props.dataProvider?.selectedRows
|
|
11
|
-
const selectAll = props.dataProvider?.selectAll
|
|
10
|
+
const selectedRows = props.dataProvider?.selectedRows && !props.dataProvider?.selectedRows?.__v_skip ? props.dataProvider.selectedRows : dpSelectedRows;
|
|
11
|
+
const selectAll = props.dataProvider?.selectAll && !props.dataProvider?.selectAll?.__v_skip ? props.dataProvider.selectAll : dpSelectAll;
|
|
12
12
|
const idKey = props.dataProvider?.idKey || "id";
|
|
13
13
|
const getRowId = (row) => row?.[idKey] ?? row?.id ?? row;
|
|
14
|
+
let isInternalUpdating = false;
|
|
15
|
+
const getPageRows = () => (props.dataProvider?.pageData?.value ?? props.dataProvider?.pageData ?? pageData.value) || [];
|
|
14
16
|
const getRowKey = (row, index) => {
|
|
15
17
|
if (row && row[idKey] !== void 0 && row[idKey] !== null) {
|
|
16
18
|
return row[idKey];
|
|
@@ -23,8 +25,14 @@ export function useKDatatableLogic(props) {
|
|
|
23
25
|
}
|
|
24
26
|
return index;
|
|
25
27
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
const syncToProvider = () => {
|
|
29
|
+
if (props.dataProvider?.selectedRows && props.dataProvider.selectedRows !== selectedRows) {
|
|
30
|
+
props.dataProvider.selectedRows.value = selectedRows.value;
|
|
31
|
+
}
|
|
32
|
+
if (props.dataProvider?.selectAll && props.dataProvider.selectAll !== selectAll) {
|
|
33
|
+
props.dataProvider.selectAll.value = selectAll.value;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
28
36
|
watch(() => selectAll.value, (newVal) => {
|
|
29
37
|
if (isInternalUpdating) return;
|
|
30
38
|
const currentRows = getPageRows();
|
|
@@ -36,21 +44,31 @@ export function useKDatatableLogic(props) {
|
|
|
36
44
|
const newSelections = currentRows.filter((r) => !currentSelectedIds.has(getRowId(r)));
|
|
37
45
|
selectedRows.value = [...selectedRows.value, ...newSelections];
|
|
38
46
|
}
|
|
47
|
+
syncToProvider();
|
|
39
48
|
});
|
|
40
49
|
watch([getPageRows, () => selectedRows.value], () => {
|
|
41
50
|
const currentRows = getPageRows();
|
|
42
51
|
if (currentRows.length === 0) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
52
|
+
if (selectAll.value) {
|
|
53
|
+
isInternalUpdating = true;
|
|
54
|
+
selectAll.value = false;
|
|
55
|
+
isInternalUpdating = false;
|
|
56
|
+
syncToProvider();
|
|
57
|
+
}
|
|
46
58
|
return;
|
|
47
59
|
}
|
|
48
60
|
const selectedIds = new Set(selectedRows.value.map(getRowId));
|
|
49
61
|
const allCurrentSelected = currentRows.every((r) => selectedIds.has(getRowId(r)));
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
62
|
+
if (selectAll.value !== allCurrentSelected) {
|
|
63
|
+
isInternalUpdating = true;
|
|
64
|
+
selectAll.value = allCurrentSelected;
|
|
65
|
+
isInternalUpdating = false;
|
|
66
|
+
}
|
|
67
|
+
syncToProvider();
|
|
53
68
|
}, { immediate: true });
|
|
69
|
+
watch(() => selectedRows.value, () => {
|
|
70
|
+
syncToProvider();
|
|
71
|
+
}, { deep: true });
|
|
54
72
|
return {
|
|
55
73
|
selectedRows,
|
|
56
74
|
selectAll,
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
2
2
|
iconname: {
|
|
3
3
|
type: StringConstructor;
|
|
4
|
-
|
|
4
|
+
default: string;
|
|
5
|
+
};
|
|
6
|
+
name: {
|
|
7
|
+
type: StringConstructor;
|
|
8
|
+
default: undefined;
|
|
5
9
|
};
|
|
6
10
|
width: {
|
|
7
11
|
type: (StringConstructor | NumberConstructor)[];
|
|
@@ -18,7 +22,11 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
18
22
|
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
19
23
|
iconname: {
|
|
20
24
|
type: StringConstructor;
|
|
21
|
-
|
|
25
|
+
default: string;
|
|
26
|
+
};
|
|
27
|
+
name: {
|
|
28
|
+
type: StringConstructor;
|
|
29
|
+
default: undefined;
|
|
22
30
|
};
|
|
23
31
|
width: {
|
|
24
32
|
type: (StringConstructor | NumberConstructor)[];
|
|
@@ -36,6 +44,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
36
44
|
width: string | number;
|
|
37
45
|
height: string | number;
|
|
38
46
|
rotate: string | number;
|
|
47
|
+
iconname: string;
|
|
48
|
+
name: string;
|
|
39
49
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
40
50
|
declare const _default: typeof __VLS_export;
|
|
41
51
|
export default _default;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
2
2
|
iconname: {
|
|
3
3
|
type: StringConstructor;
|
|
4
|
-
|
|
4
|
+
default: string;
|
|
5
|
+
};
|
|
6
|
+
name: {
|
|
7
|
+
type: StringConstructor;
|
|
8
|
+
default: undefined;
|
|
5
9
|
};
|
|
6
10
|
width: {
|
|
7
11
|
type: (StringConstructor | NumberConstructor)[];
|
|
@@ -18,7 +22,11 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
18
22
|
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
19
23
|
iconname: {
|
|
20
24
|
type: StringConstructor;
|
|
21
|
-
|
|
25
|
+
default: string;
|
|
26
|
+
};
|
|
27
|
+
name: {
|
|
28
|
+
type: StringConstructor;
|
|
29
|
+
default: undefined;
|
|
22
30
|
};
|
|
23
31
|
width: {
|
|
24
32
|
type: (StringConstructor | NumberConstructor)[];
|
|
@@ -36,6 +44,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
36
44
|
width: string | number;
|
|
37
45
|
height: string | number;
|
|
38
46
|
rotate: string | number;
|
|
47
|
+
iconname: string;
|
|
48
|
+
name: string;
|
|
39
49
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
40
50
|
declare const _default: typeof __VLS_export;
|
|
41
51
|
export default _default;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export interface KIconProps {
|
|
2
|
-
iconname
|
|
2
|
+
iconname?: string;
|
|
3
|
+
name?: string;
|
|
3
4
|
width?: number | string;
|
|
4
5
|
height?: number | string;
|
|
5
6
|
rotate?: number | string;
|
|
@@ -7,7 +8,11 @@ export interface KIconProps {
|
|
|
7
8
|
export declare const KIconDefaultProps: {
|
|
8
9
|
iconname: {
|
|
9
10
|
type: StringConstructor;
|
|
10
|
-
|
|
11
|
+
default: string;
|
|
12
|
+
};
|
|
13
|
+
name: {
|
|
14
|
+
type: StringConstructor;
|
|
15
|
+
default: undefined;
|
|
11
16
|
};
|
|
12
17
|
width: {
|
|
13
18
|
type: (StringConstructor | NumberConstructor)[];
|
|
@@ -2,7 +2,11 @@ import { computed, watch, shallowRef } from "vue";
|
|
|
2
2
|
export const KIconDefaultProps = {
|
|
3
3
|
iconname: {
|
|
4
4
|
type: String,
|
|
5
|
-
|
|
5
|
+
default: ""
|
|
6
|
+
},
|
|
7
|
+
name: {
|
|
8
|
+
type: String,
|
|
9
|
+
default: void 0
|
|
6
10
|
},
|
|
7
11
|
width: {
|
|
8
12
|
type: [Number, String],
|
|
@@ -62,9 +66,10 @@ export function formatIconSize(val) {
|
|
|
62
66
|
export function useKIconLogic(props) {
|
|
63
67
|
const widthPx = computed(() => formatIconSize(props.width));
|
|
64
68
|
const heightPx = computed(() => formatIconSize(props.height) || "12px");
|
|
69
|
+
const activeIconName = computed(() => props.iconname || props.name || "");
|
|
65
70
|
const asyncLoadedSvg = shallowRef(null);
|
|
66
71
|
watch(
|
|
67
|
-
() =>
|
|
72
|
+
() => activeIconName.value,
|
|
68
73
|
(name) => {
|
|
69
74
|
if (!name || name.startsWith("<svg") || _svgCache.has(name)) {
|
|
70
75
|
asyncLoadedSvg.value = null;
|
|
@@ -74,7 +79,7 @@ export function useKIconLogic(props) {
|
|
|
74
79
|
if (loader) {
|
|
75
80
|
loader().then((raw) => {
|
|
76
81
|
_svgCache.set(name, raw);
|
|
77
|
-
if (
|
|
82
|
+
if (activeIconName.value === name) {
|
|
78
83
|
asyncLoadedSvg.value = raw;
|
|
79
84
|
}
|
|
80
85
|
}).catch((err) => {
|
|
@@ -88,7 +93,7 @@ export function useKIconLogic(props) {
|
|
|
88
93
|
{ immediate: true }
|
|
89
94
|
);
|
|
90
95
|
const iconComponent = computed(() => {
|
|
91
|
-
const name =
|
|
96
|
+
const name = activeIconName.value;
|
|
92
97
|
if (!name) return null;
|
|
93
98
|
if (name.startsWith("<svg")) return name;
|
|
94
99
|
const cached = _svgCache.get(name);
|
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
import { computed } from "vue";
|
|
2
2
|
import { useRoute } from "vue-router";
|
|
3
|
+
import { useDataProvider } from "../../composables/useDataProvider.js";
|
|
3
4
|
export const KPaginationDefaultProps = {};
|
|
4
5
|
export function useKPaginationLogic(props) {
|
|
5
6
|
const dp = props.dataProvider;
|
|
6
|
-
const
|
|
7
|
+
const { rowCount: dpRowCount, pageSize: dpPageSize, currentPage: dpCurrentPage } = useDataProvider(props.dataProvider);
|
|
8
|
+
const rowCount = computed(() => dpRowCount.value ?? dp?.rowCount?.value ?? 0);
|
|
9
|
+
const pageSize = computed(() => dpPageSize.value ?? dp?.pageSize?.value ?? 10);
|
|
10
|
+
const currentPage = computed(() => dpCurrentPage.value ?? dp?.currentPage?.value ?? 1);
|
|
11
|
+
let route;
|
|
12
|
+
try {
|
|
13
|
+
route = useRoute();
|
|
14
|
+
} catch {
|
|
15
|
+
}
|
|
7
16
|
const totalPages = computed(
|
|
8
|
-
() => Math.ceil(
|
|
17
|
+
() => Math.ceil(rowCount.value / (pageSize.value || 10))
|
|
9
18
|
);
|
|
10
19
|
const maxVisiblePages = 10;
|
|
11
20
|
const getPageHref = (page) => {
|
|
12
|
-
|
|
13
|
-
|
|
21
|
+
const param = dp?.urlPageParam?.value ?? dp?.urlPageParam;
|
|
22
|
+
if (!param || !route?.path) return void 0;
|
|
23
|
+
const query = { ...route.query || {}, [param]: page.toString() };
|
|
14
24
|
const queryString = Object.entries(query).map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`).join("&");
|
|
15
25
|
return `${route.path}?${queryString}`;
|
|
16
26
|
};
|
|
@@ -18,7 +28,7 @@ export function useKPaginationLogic(props) {
|
|
|
18
28
|
if (totalPages.value <= maxVisiblePages) {
|
|
19
29
|
return Array.from({ length: totalPages.value }, (_, i) => i + 1);
|
|
20
30
|
}
|
|
21
|
-
const current =
|
|
31
|
+
const current = currentPage.value;
|
|
22
32
|
const total = totalPages.value;
|
|
23
33
|
const half = Math.floor(maxVisiblePages / 2);
|
|
24
34
|
let start = Math.max(1, current - half);
|
|
@@ -28,32 +38,37 @@ export function useKPaginationLogic(props) {
|
|
|
28
38
|
}
|
|
29
39
|
return Array.from({ length: end - start + 1 }, (_, i) => start + i);
|
|
30
40
|
});
|
|
31
|
-
const showPrevButton = computed(() =>
|
|
41
|
+
const showPrevButton = computed(() => currentPage.value > 1);
|
|
32
42
|
const showNextButton = computed(
|
|
33
|
-
() =>
|
|
43
|
+
() => currentPage.value < totalPages.value
|
|
34
44
|
);
|
|
35
|
-
const showFirstEllipsis = computed(() => visiblePages.value[0] > 2);
|
|
45
|
+
const showFirstEllipsis = computed(() => (visiblePages.value[0] || 0) > 2);
|
|
36
46
|
const showLastEllipsis = computed(
|
|
37
|
-
() => visiblePages.value[visiblePages.value.length - 1] < totalPages.value - 1
|
|
47
|
+
() => (visiblePages.value[visiblePages.value.length - 1] || 0) < totalPages.value - 1
|
|
38
48
|
);
|
|
39
49
|
const pageClicked = (item) => {
|
|
40
|
-
dp
|
|
50
|
+
if (typeof dp?.setCurrentPage === "function") {
|
|
51
|
+
dp.setCurrentPage(item);
|
|
52
|
+
} else if (dp?.currentPage) {
|
|
53
|
+
dp.currentPage.value = item;
|
|
54
|
+
}
|
|
55
|
+
dpCurrentPage.value = item;
|
|
41
56
|
};
|
|
42
57
|
const goToPrev = () => {
|
|
43
|
-
if (
|
|
44
|
-
|
|
58
|
+
if (currentPage.value > 1) {
|
|
59
|
+
pageClicked(currentPage.value - 1);
|
|
45
60
|
}
|
|
46
61
|
};
|
|
47
62
|
const goToNext = () => {
|
|
48
|
-
if (
|
|
49
|
-
|
|
63
|
+
if (currentPage.value < totalPages.value) {
|
|
64
|
+
pageClicked(currentPage.value + 1);
|
|
50
65
|
}
|
|
51
66
|
};
|
|
52
67
|
const goToFirst = () => {
|
|
53
|
-
|
|
68
|
+
pageClicked(1);
|
|
54
69
|
};
|
|
55
70
|
const goToLast = () => {
|
|
56
|
-
|
|
71
|
+
pageClicked(totalPages.value);
|
|
57
72
|
};
|
|
58
73
|
return {
|
|
59
74
|
dp,
|
|
@@ -53,9 +53,9 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
53
53
|
}>> & Readonly<{
|
|
54
54
|
"onUpdate:value"?: ((value: any) => any) | undefined;
|
|
55
55
|
}>, {
|
|
56
|
+
value: number;
|
|
56
57
|
label: string;
|
|
57
58
|
disabled: boolean;
|
|
58
|
-
value: number;
|
|
59
59
|
step: number;
|
|
60
60
|
min: number;
|
|
61
61
|
max: number;
|
|
@@ -53,9 +53,9 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
53
53
|
}>> & Readonly<{
|
|
54
54
|
"onUpdate:value"?: ((value: any) => any) | undefined;
|
|
55
55
|
}>, {
|
|
56
|
+
value: number;
|
|
56
57
|
label: string;
|
|
57
58
|
disabled: boolean;
|
|
58
|
-
value: number;
|
|
59
59
|
step: number;
|
|
60
60
|
min: number;
|
|
61
61
|
max: number;
|
|
@@ -57,10 +57,10 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
57
57
|
"onUpdate:modelValue"?: ((value: string) => any) | undefined;
|
|
58
58
|
}>, {
|
|
59
59
|
label: string;
|
|
60
|
+
rows: number;
|
|
60
61
|
validation: "error" | "success" | "warning" | null | undefined;
|
|
61
62
|
validationText: string;
|
|
62
63
|
placeholder: string;
|
|
63
|
-
rows: number;
|
|
64
64
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
65
65
|
declare const _default: typeof __VLS_export;
|
|
66
66
|
export default _default;
|
|
@@ -57,10 +57,10 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
57
57
|
"onUpdate:modelValue"?: ((value: string) => any) | undefined;
|
|
58
58
|
}>, {
|
|
59
59
|
label: string;
|
|
60
|
+
rows: number;
|
|
60
61
|
validation: "error" | "success" | "warning" | null | undefined;
|
|
61
62
|
validationText: string;
|
|
62
63
|
placeholder: string;
|
|
63
|
-
rows: number;
|
|
64
64
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
65
65
|
declare const _default: typeof __VLS_export;
|
|
66
66
|
export default _default;
|
|
@@ -164,9 +164,11 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
164
164
|
"onUpdate:modelValue"?: ((value: any) => any) | undefined;
|
|
165
165
|
"onUpdate:isOptionsOpen"?: ((value: boolean) => any) | undefined;
|
|
166
166
|
}>, {
|
|
167
|
+
parentKey: string;
|
|
168
|
+
loading: boolean;
|
|
169
|
+
idKey: string;
|
|
167
170
|
label: string;
|
|
168
171
|
disabled: boolean;
|
|
169
|
-
loading: boolean;
|
|
170
172
|
validation: "error" | "success" | "warning" | null | undefined;
|
|
171
173
|
validationText: string;
|
|
172
174
|
modelValue: any;
|
|
@@ -179,8 +181,6 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
179
181
|
multiSelect: boolean;
|
|
180
182
|
valueField: string;
|
|
181
183
|
iconField: string;
|
|
182
|
-
idKey: string;
|
|
183
|
-
parentKey: string;
|
|
184
184
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
185
185
|
declare const _default: typeof __VLS_export;
|
|
186
186
|
export default _default;
|
|
@@ -164,9 +164,11 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
164
164
|
"onUpdate:modelValue"?: ((value: any) => any) | undefined;
|
|
165
165
|
"onUpdate:isOptionsOpen"?: ((value: boolean) => any) | undefined;
|
|
166
166
|
}>, {
|
|
167
|
+
parentKey: string;
|
|
168
|
+
loading: boolean;
|
|
169
|
+
idKey: string;
|
|
167
170
|
label: string;
|
|
168
171
|
disabled: boolean;
|
|
169
|
-
loading: boolean;
|
|
170
172
|
validation: "error" | "success" | "warning" | null | undefined;
|
|
171
173
|
validationText: string;
|
|
172
174
|
modelValue: any;
|
|
@@ -179,8 +181,6 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
179
181
|
multiSelect: boolean;
|
|
180
182
|
valueField: string;
|
|
181
183
|
iconField: string;
|
|
182
|
-
idKey: string;
|
|
183
|
-
parentKey: string;
|
|
184
184
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
185
185
|
declare const _default: typeof __VLS_export;
|
|
186
186
|
export default _default;
|
|
@@ -81,14 +81,14 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
81
81
|
default: () => {};
|
|
82
82
|
};
|
|
83
83
|
}>> & Readonly<{}>, {
|
|
84
|
+
parentKey: string;
|
|
85
|
+
idKey: string;
|
|
86
|
+
expandedByDefault: boolean;
|
|
84
87
|
bulkActions: import("@katlux/providers").IKDatatableAction[];
|
|
85
88
|
rowActions: import("@katlux/providers").IKDatatableAction[];
|
|
86
89
|
cellSlots: Record<string, any>;
|
|
87
90
|
headerSlots: Record<string, any>;
|
|
88
91
|
treeColumnIndex: number;
|
|
89
|
-
idKey: string;
|
|
90
|
-
parentKey: string;
|
|
91
|
-
expandedByDefault: boolean;
|
|
92
92
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
93
93
|
declare const _default: typeof __VLS_export;
|
|
94
94
|
export default _default;
|
|
@@ -81,14 +81,14 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
81
81
|
default: () => {};
|
|
82
82
|
};
|
|
83
83
|
}>> & Readonly<{}>, {
|
|
84
|
+
parentKey: string;
|
|
85
|
+
idKey: string;
|
|
86
|
+
expandedByDefault: boolean;
|
|
84
87
|
bulkActions: import("@katlux/providers").IKDatatableAction[];
|
|
85
88
|
rowActions: import("@katlux/providers").IKDatatableAction[];
|
|
86
89
|
cellSlots: Record<string, any>;
|
|
87
90
|
headerSlots: Record<string, any>;
|
|
88
91
|
treeColumnIndex: number;
|
|
89
|
-
idKey: string;
|
|
90
|
-
parentKey: string;
|
|
91
|
-
expandedByDefault: boolean;
|
|
92
92
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
93
93
|
declare const _default: typeof __VLS_export;
|
|
94
94
|
export default _default;
|
|
@@ -2,9 +2,9 @@ import { ADataProvider } from '@katlux/providers';
|
|
|
2
2
|
import type { IKDatatableAction } from '@katlux/providers';
|
|
3
3
|
type __VLS_Props = {
|
|
4
4
|
dataProvider: ADataProvider;
|
|
5
|
-
visibleFields
|
|
6
|
-
rowActions
|
|
7
|
-
bulkActions
|
|
5
|
+
visibleFields?: Array<string> | null;
|
|
6
|
+
rowActions?: Array<IKDatatableAction>;
|
|
7
|
+
bulkActions?: Array<IKDatatableAction>;
|
|
8
8
|
selectedRows: any[];
|
|
9
9
|
selectAll: boolean;
|
|
10
10
|
loading?: boolean;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
<template lang="pug">
|
|
2
|
-
.k-data-iterator
|
|
2
|
+
.k-data-iterator(role="region" :aria-label="t('Data Iterator')")
|
|
3
3
|
KLoader(:loading="isLoading" overlay)
|
|
4
4
|
KGrid(v-if="hasData" direction="column" gap="10px" align="stretch")
|
|
5
5
|
KGrid(direction="column" gap="10px" align="stretch")
|
|
6
|
-
.k-data-iterator-item(v-for="row in
|
|
7
|
-
slot(name="row" :row="row" :rowActions="props.rowActions")
|
|
6
|
+
.k-data-iterator-item(v-for="(row, index) in pageRows" :key="getRowKey(row, index)")
|
|
7
|
+
slot(name="row" :row="row" :index="index" :rowActions="props.rowActions")
|
|
8
|
+
slot(:row="row" :index="index" :rowActions="props.rowActions")
|
|
8
9
|
|
|
9
10
|
.footer
|
|
10
11
|
KBulkActions(
|
|
@@ -14,22 +15,23 @@
|
|
|
14
15
|
:selectAll="selectAll"
|
|
15
16
|
)
|
|
16
17
|
KPagination(:dataProvider="props.dataProvider")
|
|
17
|
-
span(v-if="showNoRecord") No record
|
|
18
|
+
span.no-record(v-if="showNoRecord") {{ t('No record') }}
|
|
18
19
|
</template>
|
|
19
20
|
|
|
20
21
|
<script setup lang="ts">
|
|
21
22
|
import { computed } from 'vue'
|
|
22
23
|
import { ADataProvider } from '@katlux/providers'
|
|
23
24
|
import type { IKDatatableAction } from '@katlux/providers'
|
|
24
|
-
import
|
|
25
|
-
import
|
|
26
|
-
|
|
25
|
+
import { useKatluxI18n } from '#toolkit/composables/useKatluxI18n'
|
|
26
|
+
import { useDataProvider } from '#toolkit/composables/useDataProvider'
|
|
27
|
+
|
|
28
|
+
const { t } = useKatluxI18n()
|
|
27
29
|
|
|
28
30
|
const props = defineProps<{
|
|
29
31
|
dataProvider: ADataProvider
|
|
30
|
-
visibleFields
|
|
31
|
-
rowActions
|
|
32
|
-
bulkActions
|
|
32
|
+
visibleFields?: Array<string> | null
|
|
33
|
+
rowActions?: Array<IKDatatableAction>
|
|
34
|
+
bulkActions?: Array<IKDatatableAction>
|
|
33
35
|
selectedRows: any[]
|
|
34
36
|
selectAll: boolean
|
|
35
37
|
loading?: boolean
|
|
@@ -54,13 +56,37 @@ const selectAll = computed({
|
|
|
54
56
|
set: (val) => emit('update:selectAll', val)
|
|
55
57
|
})
|
|
56
58
|
|
|
57
|
-
const
|
|
58
|
-
const
|
|
59
|
+
const { pageData, loading: dpLoading, initialLoad: dpInitialLoad } = useDataProvider(props.dataProvider)
|
|
60
|
+
const pageRows = computed(() => pageData.value || [])
|
|
61
|
+
|
|
62
|
+
const isLoading = computed(() => props.loading || dpLoading.value || dpInitialLoad.value || false)
|
|
63
|
+
const hasData = computed(() => pageRows.value.length > 0)
|
|
59
64
|
const showNoRecord = computed(() => !isLoading.value && !hasData.value)
|
|
65
|
+
|
|
66
|
+
const getRowKey = (row: any, index: number): string | number => {
|
|
67
|
+
const idKey = (props.dataProvider as any)?.idKey || 'id'
|
|
68
|
+
if (row && row[idKey] !== undefined && row[idKey] !== null) {
|
|
69
|
+
return row[idKey]
|
|
70
|
+
}
|
|
71
|
+
if (row && row.id !== undefined && row.id !== null) {
|
|
72
|
+
return row.id
|
|
73
|
+
}
|
|
74
|
+
if (row && row._id !== undefined && row._id !== null) {
|
|
75
|
+
return row._id
|
|
76
|
+
}
|
|
77
|
+
return index
|
|
78
|
+
}
|
|
60
79
|
</script>
|
|
61
80
|
|
|
62
81
|
<style lang="scss" scoped>
|
|
63
82
|
.k-data-iterator {
|
|
64
83
|
position: relative;
|
|
84
|
+
width: 100%;
|
|
85
|
+
.no-record {
|
|
86
|
+
display: block;
|
|
87
|
+
padding: 1rem;
|
|
88
|
+
text-align: center;
|
|
89
|
+
color: var(--font-color-secondary, #6b7280);
|
|
90
|
+
}
|
|
65
91
|
}
|
|
66
92
|
</style>
|
|
@@ -2,9 +2,9 @@ import { ADataProvider } from '@katlux/providers';
|
|
|
2
2
|
import type { IKDatatableAction } from '@katlux/providers';
|
|
3
3
|
type __VLS_Props = {
|
|
4
4
|
dataProvider: ADataProvider;
|
|
5
|
-
visibleFields
|
|
6
|
-
rowActions
|
|
7
|
-
bulkActions
|
|
5
|
+
visibleFields?: Array<string> | null;
|
|
6
|
+
rowActions?: Array<IKDatatableAction>;
|
|
7
|
+
bulkActions?: Array<IKDatatableAction>;
|
|
8
8
|
selectedRows: any[];
|
|
9
9
|
selectAll: boolean;
|
|
10
10
|
loading?: boolean;
|