@katlux/toolkit 0.1.1-alpha.111 → 0.1.1-alpha.112
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/compiled/composables/locales.mjs +195 -27
- package/dist/compiled/composables/useDataProvider.mjs +121 -90
- package/dist/compiled/composables/useDataProvider.spec.mjs +20 -1
- package/dist/compiled/composables/useKatluxContext.mjs +21 -0
- package/dist/compiled/composables/useKatluxContext.spec.mjs +63 -0
- package/dist/compiled/composables/useKatluxI18n.mjs +20 -9
- package/dist/compiled/composables/usePresetComponent.mjs +12 -3
- package/dist/compiled/utils/PresetResolver.mjs +21 -7
- package/dist/compiled/utils/TemplateResolver.mjs +11 -5
- package/dist/module.cjs +3 -31
- package/dist/module.json +1 -1
- package/dist/module.mjs +4 -32
- package/dist/runtime/components/KBulkActions/KBulkActions.logic.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/KCombobox/KCombobox.global.d.vue.ts +5 -5
- package/dist/runtime/components/KCombobox/KCombobox.global.vue +6 -0
- package/dist/runtime/components/KCombobox/KCombobox.global.vue.d.ts +5 -5
- package/dist/runtime/components/KCombobox/KCombobox.logic.d.ts +3 -0
- package/dist/runtime/components/KCombobox/KCombobox.logic.js +192 -14
- package/dist/runtime/components/KCompositeInput/KCompositeInput.global.d.vue.ts +11 -11
- package/dist/runtime/components/KCompositeInput/KCompositeInput.global.vue.d.ts +11 -11
- package/dist/runtime/components/KCompositeInput/KCompositeInput.logic.d.ts +1 -1
- package/dist/runtime/components/KDatatable/KDataIterator.logic.js +23 -16
- package/dist/runtime/components/KDatatable/KDatatable.logic.d.ts +1 -1
- package/dist/runtime/components/KDatatable/KDatatable.logic.js +36 -27
- package/dist/runtime/components/KDatePicker/KDatePicker.global.d.vue.ts +6 -6
- package/dist/runtime/components/KDatePicker/KDatePicker.global.vue.d.ts +6 -6
- package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.d.vue.ts +7 -7
- package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.vue.d.ts +7 -7
- 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/KGrid/KGrid.global.d.vue.ts +1 -1
- package/dist/runtime/components/KGrid/KGrid.global.vue.d.ts +1 -1
- package/dist/runtime/components/KHourPicker/KHourPicker.global.d.vue.ts +2 -2
- package/dist/runtime/components/KHourPicker/KHourPicker.global.vue.d.ts +2 -2
- package/dist/runtime/components/KMaskTextbox/KMaskTextbox.global.d.vue.ts +2 -2
- package/dist/runtime/components/KMaskTextbox/KMaskTextbox.global.vue.d.ts +2 -2
- package/dist/runtime/components/KModal/KModal.global.d.vue.ts +15 -2
- package/dist/runtime/components/KModal/KModal.global.vue +6 -1
- package/dist/runtime/components/KModal/KModal.global.vue.d.ts +15 -2
- package/dist/runtime/components/KModal/KModal.logic.d.ts +8 -2
- package/dist/runtime/components/KModal/KModal.logic.js +21 -3
- package/dist/runtime/components/KPagination/KPagination.global.vue +2 -0
- package/dist/runtime/components/KPagination/KPagination.logic.d.ts +2 -1
- package/dist/runtime/components/KPagination/KPagination.logic.js +1 -0
- 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/KTabs/KTabItem.logic.js +20 -5
- package/dist/runtime/components/KTabs/KTabs.logic.js +18 -2
- package/dist/runtime/components/KTextbox/KTextbox.global.d.vue.ts +2 -2
- package/dist/runtime/components/KTextbox/KTextbox.global.vue.d.ts +2 -2
- package/dist/runtime/components/KToast/KToast.logic.d.ts +1 -0
- package/dist/runtime/components/KToast/KToast.logic.js +19 -5
- package/dist/runtime/components/KTree/KTree.global.d.vue.ts +12 -3
- package/dist/runtime/components/KTree/KTree.global.vue +1 -0
- package/dist/runtime/components/KTree/KTree.global.vue.d.ts +12 -3
- package/dist/runtime/components/KTree/KTree.logic.d.ts +9 -4
- package/dist/runtime/components/KTree/KTree.logic.js +9 -6
- package/dist/runtime/components/KTreePicker/KTreePicker.global.d.vue.ts +4 -4
- package/dist/runtime/components/KTreePicker/KTreePicker.global.vue.d.ts +4 -4
- package/dist/runtime/components/KTreePicker/KTreePicker.logic.d.ts +3 -0
- package/dist/runtime/components/KTreeView/KTreeView.global.d.vue.ts +28 -4
- package/dist/runtime/components/KTreeView/KTreeView.global.vue +15 -1
- package/dist/runtime/components/KTreeView/KTreeView.global.vue.d.ts +28 -4
- package/dist/runtime/components/KTreeView/KTreeView.logic.d.ts +18 -4
- package/dist/runtime/components/KTreeView/KTreeView.logic.js +26 -7
- package/dist/runtime/composables/locales.js +195 -27
- package/dist/runtime/composables/useDataProvider.d.ts +1 -1
- package/dist/runtime/composables/useDataProvider.js +121 -90
- package/dist/runtime/composables/useDebounce.d.ts +1 -1
- package/dist/runtime/composables/useKatluxContext.d.ts +13 -0
- package/dist/runtime/composables/useKatluxContext.js +21 -0
- package/dist/runtime/composables/useKatluxI18n.js +20 -9
- package/dist/runtime/composables/usePresetComponent.js +12 -3
- package/dist/runtime/directives/clickOutside.d.ts +3 -2
- package/dist/runtime/directives/clickOutside.js +9 -2
- package/dist/runtime/hydration/NuxtHydrationAdapter.d.ts +10 -0
- package/dist/runtime/hydration/NuxtHydrationAdapter.js +88 -0
- package/dist/runtime/plugins/PresetPlugin.js +9 -1
- package/dist/runtime/plugins/nuxtCompatPlugin.d.ts +2 -3
- package/dist/runtime/plugins/nuxtCompatPlugin.js +6 -1
- package/dist/runtime/presets/default/components/KCalendar/KCalendar.d.vue.ts +1 -1
- package/dist/runtime/presets/default/components/KCalendar/KCalendar.vue +1 -1
- package/dist/runtime/presets/default/components/KCalendar/KCalendar.vue.d.ts +1 -1
- package/dist/runtime/presets/default/components/KCalendar/KCalendarMonth.d.vue.ts +1 -1
- package/dist/runtime/presets/default/components/KCalendar/KCalendarMonth.vue +1 -1
- package/dist/runtime/presets/default/components/KCalendar/KCalendarMonth.vue.d.ts +1 -1
- package/dist/runtime/presets/default/components/KCalendar/KCalendarWeek.d.vue.ts +1 -1
- package/dist/runtime/presets/default/components/KCalendar/KCalendarWeek.vue +1 -1
- package/dist/runtime/presets/default/components/KCalendar/KCalendarWeek.vue.d.ts +1 -1
- package/dist/runtime/presets/default/components/KCheckbox/KCheckbox.vue +24 -2
- package/dist/runtime/presets/default/components/KCombobox/KCombobox.d.vue.ts +4 -1
- package/dist/runtime/presets/default/components/KCombobox/KCombobox.vue +19 -6
- package/dist/runtime/presets/default/components/KCombobox/KCombobox.vue.d.ts +4 -1
- package/dist/runtime/presets/default/components/KCombobox/KComboboxList.d.vue.ts +4 -1
- package/dist/runtime/presets/default/components/KCombobox/KComboboxList.vue +36 -8
- package/dist/runtime/presets/default/components/KCombobox/KComboboxList.vue.d.ts +4 -1
- package/dist/runtime/presets/default/components/KCompositeInput/KCompositeInput.d.vue.ts +1 -1
- package/dist/runtime/presets/default/components/KCompositeInput/KCompositeInput.vue +1 -1
- package/dist/runtime/presets/default/components/KCompositeInput/KCompositeInput.vue.d.ts +1 -1
- package/dist/runtime/presets/default/components/KDatatable/KDatatable.vue +1 -0
- package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.d.vue.ts +1 -1
- package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.vue +1 -1
- package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.vue.d.ts +1 -1
- package/dist/runtime/presets/default/components/KDateTimePicker/KDateTimePicker.d.vue.ts +1 -1
- package/dist/runtime/presets/default/components/KDateTimePicker/KDateTimePicker.vue +1 -1
- package/dist/runtime/presets/default/components/KDateTimePicker/KDateTimePicker.vue.d.ts +1 -1
- package/dist/runtime/presets/default/components/KGantt/KGantt.vue +1 -20
- package/dist/runtime/presets/default/components/KHourPicker/KHourPicker.d.vue.ts +2 -2
- package/dist/runtime/presets/default/components/KHourPicker/KHourPicker.vue +2 -2
- package/dist/runtime/presets/default/components/KHourPicker/KHourPicker.vue.d.ts +2 -2
- package/dist/runtime/presets/default/components/KLoader/KLoader.vue +6 -2
- package/dist/runtime/presets/default/components/KMaskTextbox/KMaskTextbox.vue +1 -1
- package/dist/runtime/presets/default/components/KModal/KModal.vue +16 -4
- package/dist/runtime/presets/default/components/KPagination/KPagination.d.vue.ts +1 -0
- package/dist/runtime/presets/default/components/KPagination/KPagination.vue +5 -4
- package/dist/runtime/presets/default/components/KPagination/KPagination.vue.d.ts +1 -0
- package/dist/runtime/presets/default/components/KRangeSlider/KRangeSlider.vue +3 -1
- package/dist/runtime/presets/default/components/KSlider/KSlider.vue +2 -1
- package/dist/runtime/presets/default/components/KTabs/KTabs.vue +2 -1
- package/dist/runtime/presets/default/components/KToast/KToast.d.vue.ts +1 -1
- package/dist/runtime/presets/default/components/KToast/KToast.vue +1 -1
- package/dist/runtime/presets/default/components/KToast/KToast.vue.d.ts +1 -1
- package/dist/runtime/presets/default/components/KTooltip/KTooltip.vue +2 -0
- package/dist/runtime/presets/default/components/KTree/KTree.d.vue.ts +20 -10
- package/dist/runtime/presets/default/components/KTree/KTree.vue +34 -24
- package/dist/runtime/presets/default/components/KTree/KTree.vue.d.ts +20 -10
- package/dist/runtime/presets/default/components/KTreeView/KTreeCell.vue +2 -1
- package/dist/runtime/presets/default/components/KTreeView/KTreeView.d.vue.ts +8 -2
- package/dist/runtime/presets/default/components/KTreeView/KTreeView.vue +10 -1
- package/dist/runtime/presets/default/components/KTreeView/KTreeView.vue.d.ts +8 -2
- package/dist/runtime/server/middleware/session.d.ts +2 -0
- package/dist/runtime/server/middleware/session.js +36 -0
- package/dist/runtime/utils/PresetResolver.js +21 -7
- package/dist/runtime/utils/TemplateResolver.js +11 -5
- package/package.json +2 -2
|
@@ -1,34 +1,10 @@
|
|
|
1
|
-
import { ref, shallowRef, onScopeDispose, isRef } from "vue";
|
|
1
|
+
import { ref, shallowRef, onScopeDispose, isRef, watch } from "vue";
|
|
2
2
|
export function useDataProvider(provider) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
return
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
rowCount: ref(0),
|
|
9
|
-
currentPage: ref(1),
|
|
10
|
-
pageSize: ref(10),
|
|
11
|
-
loading: ref(false),
|
|
12
|
-
initialLoad: ref(false),
|
|
13
|
-
error: ref(null),
|
|
14
|
-
filter: ref(null),
|
|
15
|
-
sortList: ref([]),
|
|
16
|
-
selectedRows: ref([]),
|
|
17
|
-
selectAll: ref(false),
|
|
18
|
-
setCurrentPage: () => {
|
|
19
|
-
},
|
|
20
|
-
setPageSize: () => {
|
|
21
|
-
},
|
|
22
|
-
setFilter: () => {
|
|
23
|
-
},
|
|
24
|
-
setSortList: () => {
|
|
25
|
-
},
|
|
26
|
-
refresh: async () => {
|
|
27
|
-
},
|
|
28
|
-
loadPageData: () => {
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
}
|
|
3
|
+
const resolveProvider = () => {
|
|
4
|
+
if (typeof provider === "function") return provider();
|
|
5
|
+
return isRef(provider) ? provider.value : provider;
|
|
6
|
+
};
|
|
7
|
+
let activeProvider = resolveProvider();
|
|
32
8
|
const extractVal = (prop, fallback) => {
|
|
33
9
|
if (prop === void 0 || prop === null) return fallback;
|
|
34
10
|
if (isRef(prop) || typeof prop === "object" && "value" in prop) {
|
|
@@ -37,104 +13,159 @@ export function useDataProvider(provider) {
|
|
|
37
13
|
return prop;
|
|
38
14
|
};
|
|
39
15
|
const pageData = shallowRef(
|
|
40
|
-
|
|
16
|
+
activeProvider ? activeProvider.pageData?.value !== void 0 ? activeProvider.pageData.value : Array.isArray(activeProvider.pageData) ? activeProvider.pageData : extractVal(activeProvider.pageData, []) : []
|
|
41
17
|
);
|
|
42
|
-
const rowCount = ref(extractVal(
|
|
43
|
-
const currentPage = ref(extractVal(
|
|
44
|
-
const pageSize = ref(extractVal(
|
|
45
|
-
const loading = ref(extractVal(
|
|
46
|
-
const initialLoad = ref(extractVal(
|
|
47
|
-
const error = ref(extractVal(
|
|
48
|
-
const filter = ref(extractVal(
|
|
49
|
-
const sortList = ref(extractVal(
|
|
50
|
-
const selectedRows = ref(extractVal(
|
|
51
|
-
const selectAll = ref(extractVal(
|
|
18
|
+
const rowCount = ref(activeProvider ? extractVal(activeProvider.rowCount, 0) : 0);
|
|
19
|
+
const currentPage = ref(activeProvider ? extractVal(activeProvider.currentPage, 1) : 1);
|
|
20
|
+
const pageSize = ref(activeProvider ? extractVal(activeProvider.pageSize, 10) : 10);
|
|
21
|
+
const loading = ref(activeProvider ? extractVal(activeProvider.loading, false) : false);
|
|
22
|
+
const initialLoad = ref(activeProvider ? extractVal(activeProvider.initialLoad, false) : false);
|
|
23
|
+
const error = ref(activeProvider ? extractVal(activeProvider.error, null) : null);
|
|
24
|
+
const filter = ref(activeProvider ? extractVal(activeProvider.filter, null) : null);
|
|
25
|
+
const sortList = ref(activeProvider ? extractVal(activeProvider.sortList, []) : []);
|
|
26
|
+
const selectedRows = ref(activeProvider ? extractVal(activeProvider.selectedRows, []) : []);
|
|
27
|
+
const selectAll = ref(activeProvider ? extractVal(activeProvider.selectAll, false) : false);
|
|
52
28
|
const syncFromProvider = () => {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
29
|
+
if (!activeProvider) {
|
|
30
|
+
pageData.value = [];
|
|
31
|
+
rowCount.value = 0;
|
|
32
|
+
currentPage.value = 1;
|
|
33
|
+
pageSize.value = 10;
|
|
34
|
+
loading.value = false;
|
|
35
|
+
initialLoad.value = false;
|
|
36
|
+
error.value = null;
|
|
37
|
+
filter.value = null;
|
|
38
|
+
sortList.value = [];
|
|
39
|
+
selectedRows.value = [];
|
|
40
|
+
selectAll.value = false;
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
pageData.value = activeProvider.pageData?.value !== void 0 ? activeProvider.pageData.value : Array.isArray(activeProvider.pageData) ? activeProvider.pageData : extractVal(activeProvider.pageData, []);
|
|
44
|
+
rowCount.value = extractVal(activeProvider.rowCount, 0);
|
|
45
|
+
currentPage.value = extractVal(activeProvider.currentPage, 1);
|
|
46
|
+
pageSize.value = extractVal(activeProvider.pageSize, 10);
|
|
47
|
+
loading.value = extractVal(activeProvider.loading, false);
|
|
48
|
+
initialLoad.value = extractVal(activeProvider.initialLoad, false);
|
|
49
|
+
error.value = extractVal(activeProvider.error, null);
|
|
50
|
+
filter.value = extractVal(activeProvider.filter, null);
|
|
51
|
+
sortList.value = extractVal(activeProvider.sortList, []);
|
|
52
|
+
selectedRows.value = extractVal(activeProvider.selectedRows, []);
|
|
53
|
+
selectAll.value = extractVal(activeProvider.selectAll, false);
|
|
64
54
|
};
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
55
|
+
let unsubscribe = null;
|
|
56
|
+
const attachListener = () => {
|
|
57
|
+
if (unsubscribe) {
|
|
58
|
+
try {
|
|
59
|
+
unsubscribe();
|
|
60
|
+
} catch {
|
|
61
|
+
}
|
|
62
|
+
unsubscribe = null;
|
|
63
|
+
}
|
|
64
|
+
if (activeProvider && typeof activeProvider.subscribe === "function") {
|
|
65
|
+
unsubscribe = activeProvider.subscribe(() => {
|
|
66
|
+
syncFromProvider();
|
|
67
|
+
});
|
|
72
68
|
}
|
|
69
|
+
};
|
|
70
|
+
attachListener();
|
|
71
|
+
try {
|
|
72
|
+
onScopeDispose(() => {
|
|
73
|
+
if (unsubscribe) {
|
|
74
|
+
try {
|
|
75
|
+
unsubscribe();
|
|
76
|
+
} catch {
|
|
77
|
+
}
|
|
78
|
+
unsubscribe = null;
|
|
79
|
+
}
|
|
80
|
+
try {
|
|
81
|
+
activeProvider?.cancelPending?.();
|
|
82
|
+
} catch {
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
} catch {
|
|
86
|
+
}
|
|
87
|
+
if (isRef(provider) || typeof provider === "function") {
|
|
88
|
+
watch(
|
|
89
|
+
resolveProvider,
|
|
90
|
+
(newProvider) => {
|
|
91
|
+
activeProvider = newProvider;
|
|
92
|
+
attachListener();
|
|
93
|
+
syncFromProvider();
|
|
94
|
+
}
|
|
95
|
+
);
|
|
73
96
|
}
|
|
74
97
|
const setCurrentPage = (page) => {
|
|
75
|
-
if (
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
98
|
+
if (!activeProvider) return;
|
|
99
|
+
if (typeof activeProvider.setCurrentPage === "function") {
|
|
100
|
+
activeProvider.setCurrentPage(page);
|
|
101
|
+
} else if ("currentPage" in activeProvider) {
|
|
102
|
+
if (isRef(activeProvider.currentPage) || typeof activeProvider.currentPage === "object" && activeProvider.currentPage !== null && "value" in activeProvider.currentPage) {
|
|
103
|
+
activeProvider.currentPage.value = page;
|
|
80
104
|
} else {
|
|
81
|
-
|
|
105
|
+
activeProvider.currentPage = page;
|
|
82
106
|
}
|
|
83
107
|
}
|
|
84
108
|
currentPage.value = page;
|
|
85
109
|
};
|
|
86
110
|
const setPageSize = (size) => {
|
|
87
|
-
if (
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
111
|
+
if (!activeProvider) return;
|
|
112
|
+
if (typeof activeProvider.setPageSize === "function") {
|
|
113
|
+
activeProvider.setPageSize(size);
|
|
114
|
+
} else if ("pageSize" in activeProvider) {
|
|
115
|
+
if (isRef(activeProvider.pageSize) || typeof activeProvider.pageSize === "object" && activeProvider.pageSize !== null && "value" in activeProvider.pageSize) {
|
|
116
|
+
activeProvider.pageSize.value = size;
|
|
92
117
|
} else {
|
|
93
|
-
|
|
118
|
+
activeProvider.pageSize = size;
|
|
94
119
|
}
|
|
95
120
|
}
|
|
96
121
|
pageSize.value = size;
|
|
97
122
|
};
|
|
98
123
|
const setFilter = (f) => {
|
|
99
|
-
if (
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
124
|
+
if (!activeProvider) return;
|
|
125
|
+
if (typeof activeProvider.setFilter === "function") {
|
|
126
|
+
activeProvider.setFilter(f);
|
|
127
|
+
} else if ("filter" in activeProvider) {
|
|
128
|
+
if (isRef(activeProvider.filter) || typeof activeProvider.filter === "object" && activeProvider.filter !== null && "value" in activeProvider.filter) {
|
|
129
|
+
activeProvider.filter.value = f;
|
|
104
130
|
} else {
|
|
105
|
-
|
|
131
|
+
activeProvider.filter = f;
|
|
106
132
|
}
|
|
107
133
|
}
|
|
108
134
|
filter.value = f;
|
|
109
135
|
};
|
|
110
136
|
const setSortList = (s) => {
|
|
111
|
-
if (
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
137
|
+
if (!activeProvider) return;
|
|
138
|
+
if (typeof activeProvider.setSortList === "function") {
|
|
139
|
+
activeProvider.setSortList(s);
|
|
140
|
+
} else if ("sortList" in activeProvider) {
|
|
141
|
+
if (isRef(activeProvider.sortList) || typeof activeProvider.sortList === "object" && activeProvider.sortList !== null && "value" in activeProvider.sortList) {
|
|
142
|
+
activeProvider.sortList.value = s;
|
|
116
143
|
} else {
|
|
117
|
-
|
|
144
|
+
activeProvider.sortList = s;
|
|
118
145
|
}
|
|
119
146
|
}
|
|
120
147
|
sortList.value = s;
|
|
121
148
|
};
|
|
122
149
|
const refresh = async (hardRefresh = false) => {
|
|
123
|
-
if (
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
150
|
+
if (!activeProvider) return;
|
|
151
|
+
if (typeof activeProvider.refresh === "function") {
|
|
152
|
+
await activeProvider.refresh(hardRefresh);
|
|
153
|
+
} else if (typeof activeProvider.loadPageData === "function") {
|
|
154
|
+
await activeProvider.loadPageData({ disableCache: hardRefresh });
|
|
127
155
|
}
|
|
128
156
|
syncFromProvider();
|
|
129
157
|
};
|
|
130
158
|
const loadPageData = (options) => {
|
|
131
|
-
if (
|
|
132
|
-
|
|
159
|
+
if (!activeProvider) return;
|
|
160
|
+
if (typeof activeProvider.loadPageData === "function") {
|
|
161
|
+
activeProvider.loadPageData(options);
|
|
133
162
|
}
|
|
134
163
|
syncFromProvider();
|
|
135
164
|
};
|
|
136
165
|
return {
|
|
137
|
-
rawProvider
|
|
166
|
+
get rawProvider() {
|
|
167
|
+
return activeProvider;
|
|
168
|
+
},
|
|
138
169
|
pageData,
|
|
139
170
|
rowCount,
|
|
140
171
|
currentPage,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { debounce } from '@katlux/providers';
|
|
2
|
-
export declare const useDebounce: <T extends (...args: any[]) => any>(callback: T, delay: number) => (
|
|
2
|
+
export declare const useDebounce: <T extends (...args: any[]) => any>(callback: T, delay: number) => import("@katlux/providers").IDebouncedFunction<T>;
|
|
3
3
|
export { debounce };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useKatluxContext
|
|
3
|
+
*
|
|
4
|
+
* Provides request-scoped context (including the active H3 event) during SSR.
|
|
5
|
+
* Pass this context to Katlux DataProviders (e.g. `new CAPIFlatServerDataProvider({ context: useKatluxContext() })`)
|
|
6
|
+
* so that in-flight request deduplication and user cookie forwarding are isolated per SSR request,
|
|
7
|
+
* avoiding cross-request data leaks.
|
|
8
|
+
*
|
|
9
|
+
* @returns An object containing `{ event }` on server when an active request event exists, or `null` on the client.
|
|
10
|
+
*/
|
|
11
|
+
export declare function useKatluxContext(): {
|
|
12
|
+
event: any;
|
|
13
|
+
} | null;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export function useKatluxContext() {
|
|
2
|
+
const isClient = typeof window !== "undefined" && !import.meta?.server;
|
|
3
|
+
if (isClient) {
|
|
4
|
+
return null;
|
|
5
|
+
}
|
|
6
|
+
try {
|
|
7
|
+
const getReqEvent = globalThis.useRequestEvent;
|
|
8
|
+
if (typeof getReqEvent === "function") {
|
|
9
|
+
const evt = getReqEvent();
|
|
10
|
+
if (evt) {
|
|
11
|
+
return { event: evt };
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
const app = globalThis.__KATLUX_APP__ || (globalThis.useNuxtApp ? globalThis.useNuxtApp() : null);
|
|
15
|
+
if (app?.ssrContext?.event) {
|
|
16
|
+
return { event: app.ssrContext.event };
|
|
17
|
+
}
|
|
18
|
+
} catch {
|
|
19
|
+
}
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
@@ -1,31 +1,42 @@
|
|
|
1
1
|
import { en, builtInLocales } from "./locales.js";
|
|
2
|
+
import { useNuxtApp, useAppConfig } from "#app";
|
|
2
3
|
export const defaultKatluxTranslations = en;
|
|
3
4
|
export function useKatluxI18n() {
|
|
4
5
|
let nuxtApp = null;
|
|
5
6
|
try {
|
|
6
|
-
|
|
7
|
-
nuxtApp = globalThis.useNuxtApp();
|
|
8
|
-
}
|
|
7
|
+
nuxtApp = typeof globalThis.useNuxtApp === "function" ? globalThis.useNuxtApp() : useNuxtApp();
|
|
9
8
|
} catch {
|
|
9
|
+
try {
|
|
10
|
+
if (typeof globalThis.useNuxtApp === "function") {
|
|
11
|
+
nuxtApp = globalThis.useNuxtApp();
|
|
12
|
+
}
|
|
13
|
+
} catch {
|
|
14
|
+
}
|
|
10
15
|
}
|
|
11
16
|
let appConfig = null;
|
|
12
17
|
try {
|
|
13
|
-
|
|
14
|
-
appConfig = globalThis.useAppConfig();
|
|
15
|
-
}
|
|
18
|
+
appConfig = typeof globalThis.useAppConfig === "function" ? globalThis.useAppConfig() : useAppConfig();
|
|
16
19
|
} catch {
|
|
20
|
+
try {
|
|
21
|
+
if (typeof globalThis.useAppConfig === "function") {
|
|
22
|
+
appConfig = globalThis.useAppConfig();
|
|
23
|
+
}
|
|
24
|
+
} catch {
|
|
25
|
+
}
|
|
17
26
|
}
|
|
18
27
|
const toolkitConfig = appConfig?.katluxToolkit || {};
|
|
19
28
|
const customTranslations = toolkitConfig.translations || {};
|
|
20
29
|
const t = (key, params) => {
|
|
21
|
-
|
|
30
|
+
const translateFn = nuxtApp && typeof nuxtApp.$t === "function" ? nuxtApp.$t : nuxtApp?.$i18n && typeof nuxtApp.$i18n.t === "function" ? nuxtApp.$i18n.t.bind(nuxtApp.$i18n) : null;
|
|
31
|
+
if (translateFn) {
|
|
22
32
|
try {
|
|
23
|
-
const res =
|
|
33
|
+
const res = translateFn(key, params);
|
|
24
34
|
if (res && res !== key) return res;
|
|
25
35
|
} catch {
|
|
26
36
|
}
|
|
27
37
|
}
|
|
28
|
-
const
|
|
38
|
+
const i18nLocale = nuxtApp?.$i18n?.locale?.value ?? nuxtApp?.$i18n?.locale ?? nuxtApp?.i18n?.locale?.value;
|
|
39
|
+
const currentLocale = toolkitConfig.locale || i18nLocale || "en";
|
|
29
40
|
if (customTranslations[currentLocale] && typeof customTranslations[currentLocale] === "object") {
|
|
30
41
|
const langDict = customTranslations[currentLocale];
|
|
31
42
|
if (langDict[key]) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { computed, defineAsyncComponent, shallowReactive } from "vue";
|
|
2
|
-
import { useAppConfig } from "#app";
|
|
2
|
+
import { useAppConfig, useState } from "#app";
|
|
3
3
|
const _loadersRegistry = shallowReactive({});
|
|
4
4
|
const _asyncComponentCache = /* @__PURE__ */ new Map();
|
|
5
5
|
const _internalPresetLoaders = import.meta.glob([
|
|
@@ -26,9 +26,18 @@ function isDirectComponent(entry) {
|
|
|
26
26
|
return false;
|
|
27
27
|
}
|
|
28
28
|
export function usePresetComponent(componentBaseName, defaultComponent) {
|
|
29
|
-
|
|
29
|
+
let activePresetState = null;
|
|
30
|
+
try {
|
|
31
|
+
activePresetState = useState("katlux-active-preset-state");
|
|
32
|
+
} catch {
|
|
33
|
+
}
|
|
34
|
+
let appConfig = null;
|
|
35
|
+
try {
|
|
36
|
+
appConfig = useAppConfig();
|
|
37
|
+
} catch {
|
|
38
|
+
}
|
|
30
39
|
return computed(() => {
|
|
31
|
-
const raw = appConfig
|
|
40
|
+
const raw = activePresetState?.value ?? appConfig?.katluxToolkit?.activePreset;
|
|
32
41
|
if (!raw || raw === "default" || Array.isArray(raw) && (raw.length === 0 || raw.length === 1 && raw[0] === "default")) {
|
|
33
42
|
return defaultComponent;
|
|
34
43
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const clickOutside:
|
|
1
|
+
import type { ObjectDirective, DirectiveBinding } from 'vue';
|
|
2
|
+
export declare const clickOutside: ObjectDirective;
|
|
3
3
|
declare global {
|
|
4
4
|
interface HTMLElement {
|
|
5
5
|
_clickOutside?: (event: Event) => void;
|
|
6
|
+
_clickOutsideBinding?: DirectiveBinding;
|
|
6
7
|
}
|
|
7
8
|
}
|
|
@@ -5,13 +5,16 @@ export const clickOutside = {
|
|
|
5
5
|
},
|
|
6
6
|
// Only run on client side
|
|
7
7
|
mounted(el, binding) {
|
|
8
|
-
if (typeof window === "undefined"
|
|
8
|
+
if (typeof window === "undefined") return;
|
|
9
|
+
el._clickOutsideBinding = binding;
|
|
9
10
|
el._clickOutside = (event) => {
|
|
11
|
+
const currentBinding = el._clickOutsideBinding;
|
|
12
|
+
if (!currentBinding || !currentBinding.value) return;
|
|
10
13
|
const target = event.target;
|
|
11
14
|
if (el === target || el.contains(target)) return;
|
|
12
15
|
let handler;
|
|
13
16
|
let extraInside;
|
|
14
|
-
const value =
|
|
17
|
+
const value = currentBinding.value;
|
|
15
18
|
if (typeof value === "function") {
|
|
16
19
|
handler = value;
|
|
17
20
|
} else if (value && typeof value === "object" && typeof value.handler === "function") {
|
|
@@ -36,10 +39,14 @@ export const clickOutside = {
|
|
|
36
39
|
};
|
|
37
40
|
document.addEventListener("click", el._clickOutside, true);
|
|
38
41
|
},
|
|
42
|
+
updated(el, binding) {
|
|
43
|
+
el._clickOutsideBinding = binding;
|
|
44
|
+
},
|
|
39
45
|
unmounted(el) {
|
|
40
46
|
if (el._clickOutside) {
|
|
41
47
|
document.removeEventListener("click", el._clickOutside, true);
|
|
42
48
|
delete el._clickOutside;
|
|
49
|
+
delete el._clickOutsideBinding;
|
|
43
50
|
}
|
|
44
51
|
}
|
|
45
52
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ISSRHydrationAdapter } from '@katlux/providers';
|
|
2
|
+
export declare class NuxtHydrationAdapter implements ISSRHydrationAdapter {
|
|
3
|
+
private fallback;
|
|
4
|
+
private getApp;
|
|
5
|
+
private extractVal;
|
|
6
|
+
getSSRData<T>(key: string, context?: any): T | null;
|
|
7
|
+
fetchWithSSR<T>(key: string, fetcher: () => Promise<T>, context?: any): Promise<T | null>;
|
|
8
|
+
clearSSRData(key: string, context?: any): void;
|
|
9
|
+
getSSRPayload(context?: any): Record<string, any> | null;
|
|
10
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { DefaultHydrationAdapter } from "@katlux/providers";
|
|
2
|
+
import { useNuxtApp, useNuxtData, useAsyncData, clearNuxtData } from "#app";
|
|
3
|
+
import { isRef, unref } from "vue";
|
|
4
|
+
export class NuxtHydrationAdapter {
|
|
5
|
+
fallback = new DefaultHydrationAdapter();
|
|
6
|
+
getApp(context) {
|
|
7
|
+
if (context?.runWithContext) return context;
|
|
8
|
+
if (context?.ssrContext) return context;
|
|
9
|
+
try {
|
|
10
|
+
return useNuxtApp();
|
|
11
|
+
} catch {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
extractVal(res) {
|
|
16
|
+
if (!res) return null;
|
|
17
|
+
if (typeof res === "object" && "data" in res) {
|
|
18
|
+
const dataRef = res.data;
|
|
19
|
+
const val2 = isRef(dataRef) ? unref(dataRef) : dataRef;
|
|
20
|
+
if (val2 !== void 0 && val2 !== null) return val2;
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
const val = isRef(res) ? unref(res) : res;
|
|
24
|
+
if (val !== void 0 && val !== null) return val;
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
getSSRData(key, context) {
|
|
28
|
+
const app = this.getApp(context);
|
|
29
|
+
if (app?.runWithContext) {
|
|
30
|
+
try {
|
|
31
|
+
const res = app.runWithContext(() => useNuxtData(key));
|
|
32
|
+
const val = this.extractVal(res);
|
|
33
|
+
if (val !== null) return val;
|
|
34
|
+
} catch {
|
|
35
|
+
}
|
|
36
|
+
} else {
|
|
37
|
+
try {
|
|
38
|
+
const res = useNuxtData(key);
|
|
39
|
+
const val = this.extractVal(res);
|
|
40
|
+
if (val !== null) return val;
|
|
41
|
+
} catch {
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return this.fallback.getSSRData(key, context);
|
|
45
|
+
}
|
|
46
|
+
async fetchWithSSR(key, fetcher, context) {
|
|
47
|
+
const cached = this.getSSRData(key, context);
|
|
48
|
+
if (cached !== null) return cached;
|
|
49
|
+
const app = this.getApp(context);
|
|
50
|
+
if (app?.runWithContext) {
|
|
51
|
+
try {
|
|
52
|
+
const res = await app.runWithContext(() => useAsyncData(key, fetcher, { dedupe: "defer" }));
|
|
53
|
+
const val = this.extractVal(res);
|
|
54
|
+
if (val !== null) return val;
|
|
55
|
+
} catch {
|
|
56
|
+
}
|
|
57
|
+
} else {
|
|
58
|
+
try {
|
|
59
|
+
const res = await useAsyncData(key, fetcher, { dedupe: "defer" });
|
|
60
|
+
const val = this.extractVal(res);
|
|
61
|
+
if (val !== null) return val;
|
|
62
|
+
} catch {
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return this.fallback.fetchWithSSR(key, fetcher, context);
|
|
66
|
+
}
|
|
67
|
+
clearSSRData(key, context) {
|
|
68
|
+
const app = this.getApp(context);
|
|
69
|
+
if (app?.runWithContext) {
|
|
70
|
+
try {
|
|
71
|
+
app.runWithContext(() => clearNuxtData(key));
|
|
72
|
+
} catch {
|
|
73
|
+
}
|
|
74
|
+
} else {
|
|
75
|
+
try {
|
|
76
|
+
clearNuxtData(key);
|
|
77
|
+
} catch {
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
this.fallback.clearSSRData?.(key, context);
|
|
81
|
+
}
|
|
82
|
+
getSSRPayload(context) {
|
|
83
|
+
const app = this.getApp(context);
|
|
84
|
+
const payload = app?.payload?.data || app?.ssrContext?.payload?.data;
|
|
85
|
+
if (payload) return payload;
|
|
86
|
+
return this.fallback.getSSRPayload?.(context) ?? null;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -12,11 +12,19 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|
|
12
12
|
"data-preset": currentPreset
|
|
13
13
|
}
|
|
14
14
|
});
|
|
15
|
+
watch(activePresetState, (newPreset) => {
|
|
16
|
+
if (newPreset) {
|
|
17
|
+
currentPreset.value = resolvePresetString(newPreset);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
15
20
|
if (appConfig.katluxToolkit) {
|
|
16
21
|
watch(() => appConfig.katluxToolkit?.activePreset, (newPreset) => {
|
|
17
22
|
if (newPreset) {
|
|
18
23
|
currentPreset.value = resolvePresetString(newPreset);
|
|
19
|
-
|
|
24
|
+
activePresetState.value = newPreset;
|
|
25
|
+
nuxtApp.runWithContext(() => {
|
|
26
|
+
resolver.setActivePreset(newPreset);
|
|
27
|
+
});
|
|
20
28
|
}
|
|
21
29
|
});
|
|
22
30
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* nuxtCompatPlugin
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* without hard #app imports.
|
|
4
|
+
* Configures the NuxtHydrationAdapter on @katlux/providers and bridges
|
|
5
|
+
* Nuxt 3 composables for platform integration.
|
|
7
6
|
*/
|
|
8
7
|
declare const _default: import("#app").Plugin<Record<string, unknown>> & import("#app").ObjectPlugin<Record<string, unknown>>;
|
|
9
8
|
export default _default;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import { defineNuxtPlugin, useNuxtApp, useAsyncData, useNuxtData, clearNuxtData, useRoute, useRouter, onNuxtReady } from "#app";
|
|
1
|
+
import { defineNuxtPlugin, useNuxtApp, useAsyncData, useNuxtData, clearNuxtData, useRoute, useRouter, onNuxtReady, useRequestEvent } from "#app";
|
|
2
|
+
import { setHydrationAdapter } from "@katlux/providers";
|
|
3
|
+
import { NuxtHydrationAdapter } from "../hydration/NuxtHydrationAdapter.js";
|
|
2
4
|
export default defineNuxtPlugin((nuxtApp) => {
|
|
5
|
+
setHydrationAdapter(new NuxtHydrationAdapter());
|
|
3
6
|
const _global = globalThis;
|
|
7
|
+
_global.__KATLUX_APP__ = nuxtApp;
|
|
4
8
|
_global.useNuxtApp = useNuxtApp;
|
|
5
9
|
_global.useAsyncData = useAsyncData;
|
|
6
10
|
_global.useNuxtData = useNuxtData;
|
|
@@ -8,4 +12,5 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|
|
8
12
|
_global.useRoute = useRoute;
|
|
9
13
|
_global.useRouter = useRouter;
|
|
10
14
|
_global.onNuxtReady = onNuxtReady;
|
|
15
|
+
_global.useRequestEvent = useRequestEvent;
|
|
11
16
|
});
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
</template>
|
|
35
35
|
|
|
36
36
|
<script lang="ts" setup>
|
|
37
|
-
import type { IMarkedDay, IDefinedDay } from '
|
|
37
|
+
import type { IMarkedDay, IDefinedDay } from '#toolkit/components/KCalendar/types'
|
|
38
38
|
|
|
39
39
|
const props = defineProps<{
|
|
40
40
|
view: string
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
|
|
36
36
|
<script lang="ts" setup>
|
|
37
37
|
import { computed, ref } from 'vue'
|
|
38
|
-
import type { IMarkedDay } from '
|
|
38
|
+
import type { IMarkedDay } from '#toolkit/components/KCalendar/types'
|
|
39
39
|
|
|
40
40
|
const timeContainerRef = ref<HTMLElement | null>(null)
|
|
41
41
|
|