@katlux/toolkit 0.1.1-alpha.108 → 0.1.1-alpha.109
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/KButton/KButton.logic.d.ts +1 -1
- package/dist/runtime/components/KCombobox/KCombobox.global.d.vue.ts +3 -3
- package/dist/runtime/components/KCombobox/KCombobox.global.vue.d.ts +3 -3
- package/dist/runtime/components/KCompositeInput/KCompositeInput.global.d.vue.ts +5 -5
- package/dist/runtime/components/KCompositeInput/KCompositeInput.global.vue.d.ts +5 -5
- 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/KDatePicker/KDatePicker.global.d.vue.ts +1 -1
- package/dist/runtime/components/KDatePicker/KDatePicker.global.vue.d.ts +1 -1
- package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.d.vue.ts +1 -1
- package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.vue.d.ts +1 -1
- package/dist/runtime/components/KDropdown/KDropdown.global.d.vue.ts +1 -1
- package/dist/runtime/components/KDropdown/KDropdown.global.vue.d.ts +1 -1
- 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/KTree/KTree.global.d.vue.ts +1 -1
- package/dist/runtime/components/KTree/KTree.global.vue.d.ts +1 -1
- package/dist/runtime/components/KTreePicker/KTreePicker.global.d.vue.ts +2 -2
- package/dist/runtime/components/KTreePicker/KTreePicker.global.vue.d.ts +2 -2
- 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;
|
|
@@ -23,7 +23,7 @@ export interface KButtonEmits {
|
|
|
23
23
|
export declare function useKButtonLogic(props: KButtonProps, emit: KButtonEmits): {
|
|
24
24
|
isLink: import("vue").ComputedRef<boolean>;
|
|
25
25
|
isDisabled: import("vue").ComputedRef<boolean | undefined>;
|
|
26
|
-
buttonClasses: import("vue").ComputedRef<("default" | "
|
|
26
|
+
buttonClasses: import("vue").ComputedRef<("default" | "small" | "info" | "success" | "warning" | "danger" | "primary" | "light" | "dark" | "large" | "medium" | {
|
|
27
27
|
disabled: boolean | undefined;
|
|
28
28
|
'icon-only': boolean | undefined;
|
|
29
29
|
})[]>;
|
|
@@ -159,17 +159,17 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
159
159
|
validation: "error" | "success" | "warning" | null | undefined;
|
|
160
160
|
validationText: string;
|
|
161
161
|
modelValue: any;
|
|
162
|
+
valueField: string;
|
|
163
|
+
placeholder: string;
|
|
162
164
|
searchbox: boolean;
|
|
165
|
+
teleportTo: string;
|
|
163
166
|
searchPlaceholder: string;
|
|
164
167
|
isOptionsOpen: boolean;
|
|
165
|
-
placeholder: string;
|
|
166
|
-
teleportTo: string;
|
|
167
168
|
fullWidth: boolean;
|
|
168
169
|
closeOnSelect: boolean;
|
|
169
170
|
multiSelect: boolean;
|
|
170
171
|
maxSelectedDisplay: string | number | boolean;
|
|
171
172
|
visibleFields: String[];
|
|
172
|
-
valueField: string;
|
|
173
173
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
174
174
|
declare const _default: typeof __VLS_export;
|
|
175
175
|
export default _default;
|
|
@@ -159,17 +159,17 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
159
159
|
validation: "error" | "success" | "warning" | null | undefined;
|
|
160
160
|
validationText: string;
|
|
161
161
|
modelValue: any;
|
|
162
|
+
valueField: string;
|
|
163
|
+
placeholder: string;
|
|
162
164
|
searchbox: boolean;
|
|
165
|
+
teleportTo: string;
|
|
163
166
|
searchPlaceholder: string;
|
|
164
167
|
isOptionsOpen: boolean;
|
|
165
|
-
placeholder: string;
|
|
166
|
-
teleportTo: string;
|
|
167
168
|
fullWidth: boolean;
|
|
168
169
|
closeOnSelect: boolean;
|
|
169
170
|
multiSelect: boolean;
|
|
170
171
|
maxSelectedDisplay: string | number | boolean;
|
|
171
172
|
visibleFields: String[];
|
|
172
|
-
valueField: string;
|
|
173
173
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
174
174
|
declare const _default: typeof __VLS_export;
|
|
175
175
|
export default _default;
|
|
@@ -193,18 +193,18 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
193
193
|
validation: "error" | "success" | "warning" | null | undefined;
|
|
194
194
|
validationText: string;
|
|
195
195
|
modelValue: import("./KCompositeInput.logic.js").ICompositeItem[];
|
|
196
|
-
searchbox: boolean;
|
|
197
|
-
labelField: string;
|
|
198
|
-
placeholder: string;
|
|
199
|
-
teleportTo: string;
|
|
200
|
-
valueField: string;
|
|
201
196
|
inputType: "number" | "url" | "search" | "text" | "password" | "email" | "tel" | undefined;
|
|
202
197
|
selectionValue: string | number | Record<string, any> | unknown[];
|
|
203
198
|
inputValue: string | number | Record<string, any> | unknown[];
|
|
204
199
|
selectionSide: import("./KCompositeInput.logic.js").SelectionSide;
|
|
205
200
|
mask: string;
|
|
201
|
+
labelField: string;
|
|
202
|
+
valueField: string;
|
|
203
|
+
placeholder: string;
|
|
206
204
|
inputPlaceholder: string;
|
|
205
|
+
searchbox: boolean;
|
|
207
206
|
showClear: boolean;
|
|
207
|
+
teleportTo: string;
|
|
208
208
|
inputConfigField: string;
|
|
209
209
|
validateAll: boolean;
|
|
210
210
|
inputFormat: string;
|
|
@@ -193,18 +193,18 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
193
193
|
validation: "error" | "success" | "warning" | null | undefined;
|
|
194
194
|
validationText: string;
|
|
195
195
|
modelValue: import("./KCompositeInput.logic.js").ICompositeItem[];
|
|
196
|
-
searchbox: boolean;
|
|
197
|
-
labelField: string;
|
|
198
|
-
placeholder: string;
|
|
199
|
-
teleportTo: string;
|
|
200
|
-
valueField: string;
|
|
201
196
|
inputType: "number" | "url" | "search" | "text" | "password" | "email" | "tel" | undefined;
|
|
202
197
|
selectionValue: string | number | Record<string, any> | unknown[];
|
|
203
198
|
inputValue: string | number | Record<string, any> | unknown[];
|
|
204
199
|
selectionSide: import("./KCompositeInput.logic.js").SelectionSide;
|
|
205
200
|
mask: string;
|
|
201
|
+
labelField: string;
|
|
202
|
+
valueField: string;
|
|
203
|
+
placeholder: string;
|
|
206
204
|
inputPlaceholder: string;
|
|
205
|
+
searchbox: boolean;
|
|
207
206
|
showClear: boolean;
|
|
207
|
+
teleportTo: string;
|
|
208
208
|
inputConfigField: string;
|
|
209
209
|
validateAll: boolean;
|
|
210
210
|
inputFormat: string;
|
|
@@ -11,8 +11,8 @@ interface Props {
|
|
|
11
11
|
page?: number;
|
|
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
|
-
search: string;
|
|
15
14
|
bulkActions: IKDatatableAction[];
|
|
15
|
+
search: string;
|
|
16
16
|
loading: boolean;
|
|
17
17
|
visibleFields: Array<string> | null;
|
|
18
18
|
rowActions: IKDatatableAction[];
|
|
@@ -11,8 +11,8 @@ interface Props {
|
|
|
11
11
|
page?: number;
|
|
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
|
-
search: string;
|
|
15
14
|
bulkActions: IKDatatableAction[];
|
|
15
|
+
search: string;
|
|
16
16
|
loading: boolean;
|
|
17
17
|
visibleFields: Array<string> | null;
|
|
18
18
|
rowActions: IKDatatableAction[];
|
|
@@ -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
|
}
|
|
@@ -127,8 +127,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
127
127
|
validationText: string;
|
|
128
128
|
modelValue: string | Date;
|
|
129
129
|
placeholder: string;
|
|
130
|
-
teleportTo: string;
|
|
131
130
|
showClear: boolean;
|
|
131
|
+
teleportTo: string;
|
|
132
132
|
align: "left" | "right" | undefined;
|
|
133
133
|
format: string;
|
|
134
134
|
calendarDefinedDays: import("../KCalendar/types.js").IDefinedDay[];
|
|
@@ -127,8 +127,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
127
127
|
validationText: string;
|
|
128
128
|
modelValue: string | Date;
|
|
129
129
|
placeholder: string;
|
|
130
|
-
teleportTo: string;
|
|
131
130
|
showClear: boolean;
|
|
131
|
+
teleportTo: string;
|
|
132
132
|
align: "left" | "right" | undefined;
|
|
133
133
|
format: string;
|
|
134
134
|
calendarDefinedDays: import("../KCalendar/types.js").IDefinedDay[];
|
|
@@ -133,8 +133,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
133
133
|
validationText: string;
|
|
134
134
|
modelValue: string | Date;
|
|
135
135
|
placeholder: string;
|
|
136
|
-
teleportTo: string;
|
|
137
136
|
showClear: boolean;
|
|
137
|
+
teleportTo: string;
|
|
138
138
|
format: string;
|
|
139
139
|
calendarDefinedDays: import("../KCalendar/types.js").IDefinedDay[];
|
|
140
140
|
calendarMarkedDays: import("../KCalendar/types.js").IMarkedDay[];
|
|
@@ -133,8 +133,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
133
133
|
validationText: string;
|
|
134
134
|
modelValue: string | Date;
|
|
135
135
|
placeholder: string;
|
|
136
|
-
teleportTo: string;
|
|
137
136
|
showClear: boolean;
|
|
137
|
+
teleportTo: string;
|
|
138
138
|
format: string;
|
|
139
139
|
calendarDefinedDays: import("../KCalendar/types.js").IDefinedDay[];
|
|
140
140
|
calendarMarkedDays: import("../KCalendar/types.js").IMarkedDay[];
|
|
@@ -54,8 +54,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
54
54
|
"onUpdate:isOpen"?: ((value: boolean) => any) | undefined;
|
|
55
55
|
}>, {
|
|
56
56
|
isOpen: boolean;
|
|
57
|
-
direction: import("./KDropdown.logic.js").KDropdownDirection;
|
|
58
57
|
teleportTo: string;
|
|
58
|
+
direction: import("./KDropdown.logic.js").KDropdownDirection;
|
|
59
59
|
fullWidth: boolean;
|
|
60
60
|
align: import("./KDropdown.logic.js").KDropdownAlign;
|
|
61
61
|
anchorEl: HTMLElement;
|
|
@@ -54,8 +54,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
54
54
|
"onUpdate:isOpen"?: ((value: boolean) => any) | undefined;
|
|
55
55
|
}>, {
|
|
56
56
|
isOpen: boolean;
|
|
57
|
-
direction: import("./KDropdown.logic.js").KDropdownDirection;
|
|
58
57
|
teleportTo: string;
|
|
58
|
+
direction: import("./KDropdown.logic.js").KDropdownDirection;
|
|
59
59
|
fullWidth: boolean;
|
|
60
60
|
align: import("./KDropdown.logic.js").KDropdownAlign;
|
|
61
61
|
anchorEl: HTMLElement;
|
|
@@ -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,
|
|
@@ -66,8 +66,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
66
66
|
};
|
|
67
67
|
}>> & Readonly<{}>, {
|
|
68
68
|
disabled: boolean;
|
|
69
|
-
searchtext: string;
|
|
70
69
|
labelField: string;
|
|
70
|
+
searchtext: string;
|
|
71
71
|
multiSelect: boolean;
|
|
72
72
|
iconField: string;
|
|
73
73
|
isNodeSelected: (node: any) => boolean;
|
|
@@ -66,8 +66,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
66
66
|
};
|
|
67
67
|
}>> & Readonly<{}>, {
|
|
68
68
|
disabled: boolean;
|
|
69
|
-
searchtext: string;
|
|
70
69
|
labelField: string;
|
|
70
|
+
searchtext: string;
|
|
71
71
|
multiSelect: boolean;
|
|
72
72
|
iconField: string;
|
|
73
73
|
isNodeSelected: (node: any) => boolean;
|
|
@@ -170,14 +170,14 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
170
170
|
validation: "error" | "success" | "warning" | null | undefined;
|
|
171
171
|
validationText: string;
|
|
172
172
|
modelValue: any;
|
|
173
|
+
valueField: string;
|
|
174
|
+
placeholder: string;
|
|
173
175
|
searchbox: boolean;
|
|
174
176
|
searchPlaceholder: string;
|
|
175
177
|
isOptionsOpen: boolean;
|
|
176
|
-
placeholder: string;
|
|
177
178
|
fullWidth: boolean;
|
|
178
179
|
closeOnSelect: boolean;
|
|
179
180
|
multiSelect: boolean;
|
|
180
|
-
valueField: string;
|
|
181
181
|
iconField: string;
|
|
182
182
|
idKey: string;
|
|
183
183
|
parentKey: string;
|
|
@@ -170,14 +170,14 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
170
170
|
validation: "error" | "success" | "warning" | null | undefined;
|
|
171
171
|
validationText: string;
|
|
172
172
|
modelValue: any;
|
|
173
|
+
valueField: string;
|
|
174
|
+
placeholder: string;
|
|
173
175
|
searchbox: boolean;
|
|
174
176
|
searchPlaceholder: string;
|
|
175
177
|
isOptionsOpen: boolean;
|
|
176
|
-
placeholder: string;
|
|
177
178
|
fullWidth: boolean;
|
|
178
179
|
closeOnSelect: boolean;
|
|
179
180
|
multiSelect: boolean;
|
|
180
|
-
valueField: string;
|
|
181
181
|
iconField: string;
|
|
182
182
|
idKey: string;
|
|
183
183
|
parentKey: string;
|
|
@@ -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;
|