@katlux/toolkit 0.1.1-alpha.111 → 0.1.1-alpha.113

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.
Files changed (149) hide show
  1. package/dist/compiled/composables/locales.mjs +195 -27
  2. package/dist/compiled/composables/useDataProvider.mjs +121 -90
  3. package/dist/compiled/composables/useDataProvider.spec.mjs +20 -1
  4. package/dist/compiled/composables/useKatluxContext.mjs +21 -0
  5. package/dist/compiled/composables/useKatluxContext.spec.mjs +63 -0
  6. package/dist/compiled/composables/useKatluxI18n.mjs +20 -9
  7. package/dist/compiled/composables/usePresetComponent.mjs +12 -3
  8. package/dist/compiled/utils/PresetResolver.mjs +21 -7
  9. package/dist/compiled/utils/TemplateResolver.mjs +11 -5
  10. package/dist/module.cjs +3 -31
  11. package/dist/module.json +1 -1
  12. package/dist/module.mjs +4 -32
  13. package/dist/runtime/components/KBulkActions/KBulkActions.logic.d.ts +1 -1
  14. package/dist/runtime/components/KButton/KButton.global.d.vue.ts +1 -1
  15. package/dist/runtime/components/KButton/KButton.global.vue.d.ts +1 -1
  16. package/dist/runtime/components/KCheckbox/KCheckbox.global.d.vue.ts +1 -1
  17. package/dist/runtime/components/KCheckbox/KCheckbox.global.vue.d.ts +1 -1
  18. package/dist/runtime/components/KCombobox/KCombobox.global.d.vue.ts +4 -4
  19. package/dist/runtime/components/KCombobox/KCombobox.global.vue +6 -0
  20. package/dist/runtime/components/KCombobox/KCombobox.global.vue.d.ts +4 -4
  21. package/dist/runtime/components/KCombobox/KCombobox.logic.d.ts +3 -0
  22. package/dist/runtime/components/KCombobox/KCombobox.logic.js +192 -14
  23. package/dist/runtime/components/KCompositeInput/KCompositeInput.global.d.vue.ts +11 -11
  24. package/dist/runtime/components/KCompositeInput/KCompositeInput.global.vue.d.ts +11 -11
  25. package/dist/runtime/components/KCompositeInput/KCompositeInput.logic.d.ts +1 -1
  26. package/dist/runtime/components/KContextMenu/KContextMenu.global.d.vue.ts +1 -1
  27. package/dist/runtime/components/KContextMenu/KContextMenu.global.vue.d.ts +1 -1
  28. package/dist/runtime/components/KDatatable/KDataIterator.global.d.vue.ts +1 -1
  29. package/dist/runtime/components/KDatatable/KDataIterator.global.vue.d.ts +1 -1
  30. package/dist/runtime/components/KDatatable/KDataIterator.logic.js +23 -16
  31. package/dist/runtime/components/KDatatable/KDatatable.logic.d.ts +1 -1
  32. package/dist/runtime/components/KDatatable/KDatatable.logic.js +36 -27
  33. package/dist/runtime/components/KDatePicker/KDatePicker.global.d.vue.ts +9 -9
  34. package/dist/runtime/components/KDatePicker/KDatePicker.global.vue +2 -2
  35. package/dist/runtime/components/KDatePicker/KDatePicker.global.vue.d.ts +9 -9
  36. package/dist/runtime/components/KDatePicker/KDatePicker.logic.d.ts +4 -4
  37. package/dist/runtime/components/KDatePicker/KDatePicker.logic.js +2 -2
  38. package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.d.vue.ts +8 -8
  39. package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.vue +2 -2
  40. package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.vue.d.ts +8 -8
  41. package/dist/runtime/components/KDateTimePicker/KDateTimePicker.logic.d.ts +4 -4
  42. package/dist/runtime/components/KDateTimePicker/KDateTimePicker.logic.js +2 -2
  43. package/dist/runtime/components/KDropdown/KDropdown.global.d.vue.ts +1 -1
  44. package/dist/runtime/components/KDropdown/KDropdown.global.vue.d.ts +1 -1
  45. package/dist/runtime/components/KGrid/KGrid.global.d.vue.ts +1 -1
  46. package/dist/runtime/components/KGrid/KGrid.global.vue.d.ts +1 -1
  47. package/dist/runtime/components/KHourPicker/KHourPicker.global.d.vue.ts +1 -1
  48. package/dist/runtime/components/KHourPicker/KHourPicker.global.vue.d.ts +1 -1
  49. package/dist/runtime/components/KMaskTextbox/KMaskTextbox.global.d.vue.ts +1 -1
  50. package/dist/runtime/components/KMaskTextbox/KMaskTextbox.global.vue.d.ts +1 -1
  51. package/dist/runtime/components/KModal/KModal.global.d.vue.ts +15 -2
  52. package/dist/runtime/components/KModal/KModal.global.vue +6 -1
  53. package/dist/runtime/components/KModal/KModal.global.vue.d.ts +15 -2
  54. package/dist/runtime/components/KModal/KModal.logic.d.ts +8 -2
  55. package/dist/runtime/components/KModal/KModal.logic.js +21 -3
  56. package/dist/runtime/components/KPagination/KPagination.global.vue +2 -0
  57. package/dist/runtime/components/KPagination/KPagination.logic.d.ts +2 -1
  58. package/dist/runtime/components/KPagination/KPagination.logic.js +1 -0
  59. package/dist/runtime/components/KTabs/KTabItem.logic.js +20 -5
  60. package/dist/runtime/components/KTabs/KTabs.logic.js +18 -2
  61. package/dist/runtime/components/KTextarea/KTextarea.global.d.vue.ts +2 -2
  62. package/dist/runtime/components/KTextarea/KTextarea.global.vue.d.ts +2 -2
  63. package/dist/runtime/components/KTextbox/KTextbox.global.d.vue.ts +1 -1
  64. package/dist/runtime/components/KTextbox/KTextbox.global.vue.d.ts +1 -1
  65. package/dist/runtime/components/KToast/KToast.global.d.vue.ts +1 -1
  66. package/dist/runtime/components/KToast/KToast.global.vue.d.ts +1 -1
  67. package/dist/runtime/components/KToast/KToast.logic.d.ts +1 -0
  68. package/dist/runtime/components/KToast/KToast.logic.js +19 -5
  69. package/dist/runtime/components/KTree/KTree.global.d.vue.ts +12 -3
  70. package/dist/runtime/components/KTree/KTree.global.vue +1 -0
  71. package/dist/runtime/components/KTree/KTree.global.vue.d.ts +12 -3
  72. package/dist/runtime/components/KTree/KTree.logic.d.ts +9 -4
  73. package/dist/runtime/components/KTree/KTree.logic.js +9 -6
  74. package/dist/runtime/components/KTreePicker/KTreePicker.global.d.vue.ts +6 -6
  75. package/dist/runtime/components/KTreePicker/KTreePicker.global.vue.d.ts +6 -6
  76. package/dist/runtime/components/KTreePicker/KTreePicker.logic.d.ts +3 -0
  77. package/dist/runtime/components/KTreeView/KTreeView.global.d.vue.ts +31 -7
  78. package/dist/runtime/components/KTreeView/KTreeView.global.vue +15 -1
  79. package/dist/runtime/components/KTreeView/KTreeView.global.vue.d.ts +31 -7
  80. package/dist/runtime/components/KTreeView/KTreeView.logic.d.ts +18 -4
  81. package/dist/runtime/components/KTreeView/KTreeView.logic.js +26 -7
  82. package/dist/runtime/composables/locales.js +195 -27
  83. package/dist/runtime/composables/useDataProvider.d.ts +1 -1
  84. package/dist/runtime/composables/useDataProvider.js +121 -90
  85. package/dist/runtime/composables/useDebounce.d.ts +1 -1
  86. package/dist/runtime/composables/useKatluxContext.d.ts +13 -0
  87. package/dist/runtime/composables/useKatluxContext.js +21 -0
  88. package/dist/runtime/composables/useKatluxI18n.js +20 -9
  89. package/dist/runtime/composables/usePresetComponent.js +12 -3
  90. package/dist/runtime/directives/clickOutside.d.ts +3 -2
  91. package/dist/runtime/directives/clickOutside.js +9 -2
  92. package/dist/runtime/hydration/NuxtHydrationAdapter.d.ts +10 -0
  93. package/dist/runtime/hydration/NuxtHydrationAdapter.js +88 -0
  94. package/dist/runtime/plugins/PresetPlugin.js +9 -1
  95. package/dist/runtime/plugins/nuxtCompatPlugin.d.ts +2 -3
  96. package/dist/runtime/plugins/nuxtCompatPlugin.js +6 -1
  97. package/dist/runtime/presets/default/components/KCalendar/KCalendar.d.vue.ts +1 -1
  98. package/dist/runtime/presets/default/components/KCalendar/KCalendar.vue +1 -1
  99. package/dist/runtime/presets/default/components/KCalendar/KCalendar.vue.d.ts +1 -1
  100. package/dist/runtime/presets/default/components/KCalendar/KCalendarMonth.d.vue.ts +1 -1
  101. package/dist/runtime/presets/default/components/KCalendar/KCalendarMonth.vue +1 -1
  102. package/dist/runtime/presets/default/components/KCalendar/KCalendarMonth.vue.d.ts +1 -1
  103. package/dist/runtime/presets/default/components/KCalendar/KCalendarWeek.d.vue.ts +1 -1
  104. package/dist/runtime/presets/default/components/KCalendar/KCalendarWeek.vue +1 -1
  105. package/dist/runtime/presets/default/components/KCalendar/KCalendarWeek.vue.d.ts +1 -1
  106. package/dist/runtime/presets/default/components/KCheckbox/KCheckbox.vue +24 -2
  107. package/dist/runtime/presets/default/components/KCombobox/KCombobox.d.vue.ts +4 -1
  108. package/dist/runtime/presets/default/components/KCombobox/KCombobox.vue +19 -6
  109. package/dist/runtime/presets/default/components/KCombobox/KCombobox.vue.d.ts +4 -1
  110. package/dist/runtime/presets/default/components/KCombobox/KComboboxList.d.vue.ts +4 -1
  111. package/dist/runtime/presets/default/components/KCombobox/KComboboxList.vue +36 -8
  112. package/dist/runtime/presets/default/components/KCombobox/KComboboxList.vue.d.ts +4 -1
  113. package/dist/runtime/presets/default/components/KCompositeInput/KCompositeInput.d.vue.ts +1 -1
  114. package/dist/runtime/presets/default/components/KCompositeInput/KCompositeInput.vue +1 -1
  115. package/dist/runtime/presets/default/components/KCompositeInput/KCompositeInput.vue.d.ts +1 -1
  116. package/dist/runtime/presets/default/components/KDatatable/KDatatable.vue +1 -0
  117. package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.d.vue.ts +3 -3
  118. package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.vue +4 -4
  119. package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.vue.d.ts +3 -3
  120. package/dist/runtime/presets/default/components/KDateTimePicker/KDateTimePicker.d.vue.ts +3 -3
  121. package/dist/runtime/presets/default/components/KDateTimePicker/KDateTimePicker.vue +4 -4
  122. package/dist/runtime/presets/default/components/KDateTimePicker/KDateTimePicker.vue.d.ts +3 -3
  123. package/dist/runtime/presets/default/components/KGantt/KGantt.vue +1 -20
  124. package/dist/runtime/presets/default/components/KHourPicker/KHourPicker.vue +2 -2
  125. package/dist/runtime/presets/default/components/KLoader/KLoader.vue +6 -2
  126. package/dist/runtime/presets/default/components/KMaskTextbox/KMaskTextbox.vue +1 -1
  127. package/dist/runtime/presets/default/components/KModal/KModal.vue +16 -4
  128. package/dist/runtime/presets/default/components/KPagination/KPagination.d.vue.ts +1 -0
  129. package/dist/runtime/presets/default/components/KPagination/KPagination.vue +5 -4
  130. package/dist/runtime/presets/default/components/KPagination/KPagination.vue.d.ts +1 -0
  131. package/dist/runtime/presets/default/components/KRangeSlider/KRangeSlider.vue +3 -1
  132. package/dist/runtime/presets/default/components/KSlider/KSlider.vue +2 -1
  133. package/dist/runtime/presets/default/components/KTabs/KTabs.vue +2 -1
  134. package/dist/runtime/presets/default/components/KToast/KToast.d.vue.ts +1 -1
  135. package/dist/runtime/presets/default/components/KToast/KToast.vue +1 -1
  136. package/dist/runtime/presets/default/components/KToast/KToast.vue.d.ts +1 -1
  137. package/dist/runtime/presets/default/components/KTooltip/KTooltip.vue +2 -0
  138. package/dist/runtime/presets/default/components/KTree/KTree.d.vue.ts +20 -10
  139. package/dist/runtime/presets/default/components/KTree/KTree.vue +34 -24
  140. package/dist/runtime/presets/default/components/KTree/KTree.vue.d.ts +20 -10
  141. package/dist/runtime/presets/default/components/KTreeView/KTreeCell.vue +2 -1
  142. package/dist/runtime/presets/default/components/KTreeView/KTreeView.d.vue.ts +8 -2
  143. package/dist/runtime/presets/default/components/KTreeView/KTreeView.vue +10 -1
  144. package/dist/runtime/presets/default/components/KTreeView/KTreeView.vue.d.ts +8 -2
  145. package/dist/runtime/server/middleware/session.d.ts +2 -0
  146. package/dist/runtime/server/middleware/session.js +36 -0
  147. package/dist/runtime/utils/PresetResolver.js +21 -7
  148. package/dist/runtime/utils/TemplateResolver.js +11 -5
  149. 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
- if (!provider) {
4
- const emptyArray = shallowRef([]);
5
- return {
6
- rawProvider: null,
7
- pageData: emptyArray,
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
- provider.pageData?.value !== void 0 ? provider.pageData.value : Array.isArray(provider.pageData) ? provider.pageData : extractVal(provider.pageData, [])
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(provider.rowCount, 0));
43
- const currentPage = ref(extractVal(provider.currentPage, 1));
44
- const pageSize = ref(extractVal(provider.pageSize, 10));
45
- const loading = ref(extractVal(provider.loading, false));
46
- const initialLoad = ref(extractVal(provider.initialLoad, false));
47
- const error = ref(extractVal(provider.error, null));
48
- const filter = ref(extractVal(provider.filter, null));
49
- const sortList = ref(extractVal(provider.sortList, []));
50
- const selectedRows = ref(extractVal(provider.selectedRows, []));
51
- const selectAll = ref(extractVal(provider.selectAll, false));
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
- pageData.value = provider.pageData?.value !== void 0 ? provider.pageData.value : Array.isArray(provider.pageData) ? provider.pageData : extractVal(provider.pageData, []);
54
- rowCount.value = extractVal(provider.rowCount, 0);
55
- currentPage.value = extractVal(provider.currentPage, 1);
56
- pageSize.value = extractVal(provider.pageSize, 10);
57
- loading.value = extractVal(provider.loading, false);
58
- initialLoad.value = extractVal(provider.initialLoad, false);
59
- error.value = extractVal(provider.error, null);
60
- filter.value = extractVal(provider.filter, null);
61
- sortList.value = extractVal(provider.sortList, []);
62
- selectedRows.value = extractVal(provider.selectedRows, []);
63
- selectAll.value = extractVal(provider.selectAll, false);
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
- if (typeof provider.subscribe === "function") {
66
- const unsubscribe = provider.subscribe(() => {
67
- syncFromProvider();
68
- });
69
- try {
70
- onScopeDispose(unsubscribe);
71
- } catch {
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 (typeof provider.setCurrentPage === "function") {
76
- provider.setCurrentPage(page);
77
- } else if ("currentPage" in provider) {
78
- if (isRef(provider.currentPage) || typeof provider.currentPage === "object" && provider.currentPage !== null && "value" in provider.currentPage) {
79
- provider.currentPage.value = page;
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
- provider.currentPage = page;
105
+ activeProvider.currentPage = page;
82
106
  }
83
107
  }
84
108
  currentPage.value = page;
85
109
  };
86
110
  const setPageSize = (size) => {
87
- if (typeof provider.setPageSize === "function") {
88
- provider.setPageSize(size);
89
- } else if ("pageSize" in provider) {
90
- if (isRef(provider.pageSize) || typeof provider.pageSize === "object" && provider.pageSize !== null && "value" in provider.pageSize) {
91
- provider.pageSize.value = size;
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
- provider.pageSize = size;
118
+ activeProvider.pageSize = size;
94
119
  }
95
120
  }
96
121
  pageSize.value = size;
97
122
  };
98
123
  const setFilter = (f) => {
99
- if (typeof provider.setFilter === "function") {
100
- provider.setFilter(f);
101
- } else if ("filter" in provider) {
102
- if (isRef(provider.filter) || typeof provider.filter === "object" && provider.filter !== null && "value" in provider.filter) {
103
- provider.filter.value = f;
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
- provider.filter = f;
131
+ activeProvider.filter = f;
106
132
  }
107
133
  }
108
134
  filter.value = f;
109
135
  };
110
136
  const setSortList = (s) => {
111
- if (typeof provider.setSortList === "function") {
112
- provider.setSortList(s);
113
- } else if ("sortList" in provider) {
114
- if (isRef(provider.sortList) || typeof provider.sortList === "object" && provider.sortList !== null && "value" in provider.sortList) {
115
- provider.sortList.value = s;
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
- provider.sortList = s;
144
+ activeProvider.sortList = s;
118
145
  }
119
146
  }
120
147
  sortList.value = s;
121
148
  };
122
149
  const refresh = async (hardRefresh = false) => {
123
- if (typeof provider.refresh === "function") {
124
- await provider.refresh(hardRefresh);
125
- } else if (typeof provider.loadPageData === "function") {
126
- await provider.loadPageData({ disableCache: hardRefresh });
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 (typeof provider.loadPageData === "function") {
132
- provider.loadPageData(options);
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: provider,
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) => ((...args: Parameters<T>) => void);
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
- if (typeof globalThis.useNuxtApp === "function") {
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
- if (typeof globalThis.useAppConfig === "function") {
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
- if (nuxtApp && typeof nuxtApp.$t === "function") {
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 = nuxtApp.$t(key, params);
33
+ const res = translateFn(key, params);
24
34
  if (res && res !== key) return res;
25
35
  } catch {
26
36
  }
27
37
  }
28
- const currentLocale = toolkitConfig.locale || nuxtApp?.i18n?.locale?.value || "en";
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
- const appConfig = useAppConfig();
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.katluxToolkit?.activePreset;
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 { Directive } from 'vue';
2
- export declare const clickOutside: Directive;
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" || !binding.value) return;
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 = binding.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
- resolver.setActivePreset(newPreset);
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
- * Bridges Nuxt 3 composables to globalThis so standalone framework-agnostic libraries
5
- * like @katlux/providers can access Nuxt runtime features (SSR hydration, caching, routing)
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
  });
@@ -1,4 +1,4 @@
1
- import type { IMarkedDay, IDefinedDay } from '../../../../components/KCalendar/types.js';
1
+ import type { IMarkedDay, IDefinedDay } from '#toolkit/components/KCalendar/types';
2
2
  type __VLS_Props = {
3
3
  view: string;
4
4
  viewCount: number;
@@ -34,7 +34,7 @@
34
34
  </template>
35
35
 
36
36
  <script lang="ts" setup>
37
- import type { IMarkedDay, IDefinedDay } from '../../../../components/KCalendar/types'
37
+ import type { IMarkedDay, IDefinedDay } from '#toolkit/components/KCalendar/types'
38
38
 
39
39
  const props = defineProps<{
40
40
  view: string
@@ -1,4 +1,4 @@
1
- import type { IMarkedDay, IDefinedDay } from '../../../../components/KCalendar/types.js';
1
+ import type { IMarkedDay, IDefinedDay } from '#toolkit/components/KCalendar/types';
2
2
  type __VLS_Props = {
3
3
  view: string;
4
4
  viewCount: number;
@@ -1,4 +1,4 @@
1
- import type { IMarkedDay } from '../../../../components/KCalendar/types.js';
1
+ import type { IMarkedDay } from '#toolkit/components/KCalendar/types';
2
2
  type __VLS_Props = {
3
3
  year: number;
4
4
  month: number;
@@ -22,7 +22,7 @@
22
22
  </template>
23
23
 
24
24
  <script lang="ts" setup>
25
- import type { IMarkedDay } from '../../../../components/KCalendar/types'
25
+ import type { IMarkedDay } from '#toolkit/components/KCalendar/types'
26
26
 
27
27
  const props = defineProps<{
28
28
  year: number
@@ -1,4 +1,4 @@
1
- import type { IMarkedDay } from '../../../../components/KCalendar/types.js';
1
+ import type { IMarkedDay } from '#toolkit/components/KCalendar/types';
2
2
  type __VLS_Props = {
3
3
  year: number;
4
4
  month: number;
@@ -1,4 +1,4 @@
1
- import type { IMarkedDay } from '../../../../components/KCalendar/types.js';
1
+ import type { IMarkedDay } from '#toolkit/components/KCalendar/types';
2
2
  type __VLS_Props = {
3
3
  currentDate?: Date | string;
4
4
  selectedDay?: Date | 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 '../../../../components/KCalendar/types'
38
+ import type { IMarkedDay } from '#toolkit/components/KCalendar/types'
39
39
 
40
40
  const timeContainerRef = ref<HTMLElement | null>(null)
41
41