@katlux/toolkit 0.1.1-alpha.110 → 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.
Files changed (139) hide show
  1. package/dist/compiled/composables/locales.mjs +195 -27
  2. package/dist/compiled/composables/useDataProvider.mjs +129 -82
  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/composables/useRequestQueue.mjs +35 -0
  9. package/dist/compiled/utils/PresetResolver.mjs +21 -7
  10. package/dist/compiled/utils/TemplateResolver.mjs +11 -5
  11. package/dist/module.cjs +3 -31
  12. package/dist/module.json +1 -1
  13. package/dist/module.mjs +4 -32
  14. package/dist/runtime/components/KBulkActions/KBulkActions.logic.d.ts +1 -1
  15. package/dist/runtime/components/KCombobox/KCombobox.global.d.vue.ts +29 -2
  16. package/dist/runtime/components/KCombobox/KCombobox.global.vue +18 -1
  17. package/dist/runtime/components/KCombobox/KCombobox.global.vue.d.ts +29 -2
  18. package/dist/runtime/components/KCombobox/KCombobox.logic.d.ts +25 -0
  19. package/dist/runtime/components/KCombobox/KCombobox.logic.js +298 -15
  20. package/dist/runtime/components/KCompositeInput/KCompositeInput.global.d.vue.ts +3 -3
  21. package/dist/runtime/components/KCompositeInput/KCompositeInput.global.vue.d.ts +3 -3
  22. package/dist/runtime/components/KCompositeInput/KCompositeInput.logic.d.ts +1 -1
  23. package/dist/runtime/components/KDatatable/KDataIterator.logic.d.ts +6 -5
  24. package/dist/runtime/components/KDatatable/KDataIterator.logic.js +48 -19
  25. package/dist/runtime/components/KDatatable/KDatatable.logic.d.ts +4 -3
  26. package/dist/runtime/components/KDatatable/KDatatable.logic.js +42 -18
  27. package/dist/runtime/components/KDatePicker/KDatePicker.global.d.vue.ts +5 -5
  28. package/dist/runtime/components/KDatePicker/KDatePicker.global.vue.d.ts +5 -5
  29. package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.d.vue.ts +5 -5
  30. package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.vue.d.ts +5 -5
  31. package/dist/runtime/components/KGrid/KGrid.global.d.vue.ts +1 -1
  32. package/dist/runtime/components/KGrid/KGrid.global.vue.d.ts +1 -1
  33. package/dist/runtime/components/KHourPicker/KHourPicker.global.d.vue.ts +1 -1
  34. package/dist/runtime/components/KHourPicker/KHourPicker.global.vue.d.ts +1 -1
  35. package/dist/runtime/components/KMaskTextbox/KMaskTextbox.global.d.vue.ts +1 -1
  36. package/dist/runtime/components/KMaskTextbox/KMaskTextbox.global.vue.d.ts +1 -1
  37. package/dist/runtime/components/KModal/KModal.global.d.vue.ts +15 -2
  38. package/dist/runtime/components/KModal/KModal.global.vue +6 -1
  39. package/dist/runtime/components/KModal/KModal.global.vue.d.ts +15 -2
  40. package/dist/runtime/components/KModal/KModal.logic.d.ts +8 -2
  41. package/dist/runtime/components/KModal/KModal.logic.js +21 -3
  42. package/dist/runtime/components/KPagination/KPagination.global.vue +2 -0
  43. package/dist/runtime/components/KPagination/KPagination.logic.d.ts +2 -1
  44. package/dist/runtime/components/KPagination/KPagination.logic.js +10 -5
  45. package/dist/runtime/components/KTabs/KTabItem.logic.js +20 -5
  46. package/dist/runtime/components/KTabs/KTabs.logic.js +18 -2
  47. package/dist/runtime/components/KTextarea/KTextarea.global.d.vue.ts +1 -1
  48. package/dist/runtime/components/KTextarea/KTextarea.global.vue.d.ts +1 -1
  49. package/dist/runtime/components/KTextbox/KTextbox.global.d.vue.ts +1 -1
  50. package/dist/runtime/components/KTextbox/KTextbox.global.vue.d.ts +1 -1
  51. package/dist/runtime/components/KToast/KToast.global.d.vue.ts +1 -1
  52. package/dist/runtime/components/KToast/KToast.global.vue.d.ts +1 -1
  53. package/dist/runtime/components/KToast/KToast.logic.d.ts +1 -0
  54. package/dist/runtime/components/KToast/KToast.logic.js +19 -5
  55. package/dist/runtime/components/KTree/KTree.global.d.vue.ts +11 -2
  56. package/dist/runtime/components/KTree/KTree.global.vue +1 -0
  57. package/dist/runtime/components/KTree/KTree.global.vue.d.ts +11 -2
  58. package/dist/runtime/components/KTree/KTree.logic.d.ts +9 -4
  59. package/dist/runtime/components/KTree/KTree.logic.js +14 -8
  60. package/dist/runtime/components/KTreePicker/KTreePicker.global.d.vue.ts +2 -2
  61. package/dist/runtime/components/KTreePicker/KTreePicker.global.vue.d.ts +2 -2
  62. package/dist/runtime/components/KTreePicker/KTreePicker.logic.d.ts +10 -0
  63. package/dist/runtime/components/KTreeView/KTreeView.global.d.vue.ts +28 -4
  64. package/dist/runtime/components/KTreeView/KTreeView.global.vue +15 -1
  65. package/dist/runtime/components/KTreeView/KTreeView.global.vue.d.ts +28 -4
  66. package/dist/runtime/components/KTreeView/KTreeView.logic.d.ts +18 -4
  67. package/dist/runtime/components/KTreeView/KTreeView.logic.js +28 -6
  68. package/dist/runtime/composables/locales.js +195 -27
  69. package/dist/runtime/composables/useDataProvider.d.ts +1 -1
  70. package/dist/runtime/composables/useDataProvider.js +129 -82
  71. package/dist/runtime/composables/useDebounce.d.ts +1 -1
  72. package/dist/runtime/composables/useKatluxContext.d.ts +13 -0
  73. package/dist/runtime/composables/useKatluxContext.js +21 -0
  74. package/dist/runtime/composables/useKatluxI18n.js +20 -9
  75. package/dist/runtime/composables/usePresetComponent.js +12 -3
  76. package/dist/runtime/composables/useRequestQueue.d.ts +25 -0
  77. package/dist/runtime/composables/useRequestQueue.js +35 -0
  78. package/dist/runtime/directives/clickOutside.d.ts +3 -2
  79. package/dist/runtime/directives/clickOutside.js +9 -2
  80. package/dist/runtime/hydration/NuxtHydrationAdapter.d.ts +10 -0
  81. package/dist/runtime/hydration/NuxtHydrationAdapter.js +88 -0
  82. package/dist/runtime/plugins/PresetPlugin.js +9 -1
  83. package/dist/runtime/plugins/nuxtCompatPlugin.d.ts +2 -3
  84. package/dist/runtime/plugins/nuxtCompatPlugin.js +6 -1
  85. package/dist/runtime/presets/default/components/KCalendar/KCalendar.d.vue.ts +1 -1
  86. package/dist/runtime/presets/default/components/KCalendar/KCalendar.vue +1 -1
  87. package/dist/runtime/presets/default/components/KCalendar/KCalendar.vue.d.ts +1 -1
  88. package/dist/runtime/presets/default/components/KCalendar/KCalendarMonth.d.vue.ts +1 -1
  89. package/dist/runtime/presets/default/components/KCalendar/KCalendarMonth.vue +1 -1
  90. package/dist/runtime/presets/default/components/KCalendar/KCalendarMonth.vue.d.ts +1 -1
  91. package/dist/runtime/presets/default/components/KCalendar/KCalendarWeek.d.vue.ts +1 -1
  92. package/dist/runtime/presets/default/components/KCalendar/KCalendarWeek.vue +1 -1
  93. package/dist/runtime/presets/default/components/KCalendar/KCalendarWeek.vue.d.ts +1 -1
  94. package/dist/runtime/presets/default/components/KCheckbox/KCheckbox.vue +24 -2
  95. package/dist/runtime/presets/default/components/KCombobox/KCombobox.d.vue.ts +19 -2
  96. package/dist/runtime/presets/default/components/KCombobox/KCombobox.vue +42 -8
  97. package/dist/runtime/presets/default/components/KCombobox/KCombobox.vue.d.ts +19 -2
  98. package/dist/runtime/presets/default/components/KCombobox/KComboboxList.d.vue.ts +19 -2
  99. package/dist/runtime/presets/default/components/KCombobox/KComboboxList.vue +203 -12
  100. package/dist/runtime/presets/default/components/KCombobox/KComboboxList.vue.d.ts +19 -2
  101. package/dist/runtime/presets/default/components/KCompositeInput/KCompositeInput.d.vue.ts +1 -1
  102. package/dist/runtime/presets/default/components/KCompositeInput/KCompositeInput.vue +1 -1
  103. package/dist/runtime/presets/default/components/KCompositeInput/KCompositeInput.vue.d.ts +1 -1
  104. package/dist/runtime/presets/default/components/KDatatable/KDatatable.vue +1 -0
  105. package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.d.vue.ts +1 -1
  106. package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.vue +1 -1
  107. package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.vue.d.ts +1 -1
  108. package/dist/runtime/presets/default/components/KDateTimePicker/KDateTimePicker.d.vue.ts +1 -1
  109. package/dist/runtime/presets/default/components/KDateTimePicker/KDateTimePicker.vue +1 -1
  110. package/dist/runtime/presets/default/components/KDateTimePicker/KDateTimePicker.vue.d.ts +1 -1
  111. package/dist/runtime/presets/default/components/KGantt/KGantt.vue +1 -20
  112. package/dist/runtime/presets/default/components/KHourPicker/KHourPicker.d.vue.ts +2 -2
  113. package/dist/runtime/presets/default/components/KHourPicker/KHourPicker.vue +2 -2
  114. package/dist/runtime/presets/default/components/KHourPicker/KHourPicker.vue.d.ts +2 -2
  115. package/dist/runtime/presets/default/components/KLoader/KLoader.vue +6 -2
  116. package/dist/runtime/presets/default/components/KMaskTextbox/KMaskTextbox.vue +1 -1
  117. package/dist/runtime/presets/default/components/KModal/KModal.vue +16 -4
  118. package/dist/runtime/presets/default/components/KPagination/KPagination.d.vue.ts +1 -0
  119. package/dist/runtime/presets/default/components/KPagination/KPagination.vue +5 -4
  120. package/dist/runtime/presets/default/components/KPagination/KPagination.vue.d.ts +1 -0
  121. package/dist/runtime/presets/default/components/KRangeSlider/KRangeSlider.vue +3 -1
  122. package/dist/runtime/presets/default/components/KSlider/KSlider.vue +2 -1
  123. package/dist/runtime/presets/default/components/KTabs/KTabs.vue +2 -1
  124. package/dist/runtime/presets/default/components/KToast/KToast.d.vue.ts +1 -1
  125. package/dist/runtime/presets/default/components/KToast/KToast.vue +1 -1
  126. package/dist/runtime/presets/default/components/KToast/KToast.vue.d.ts +1 -1
  127. package/dist/runtime/presets/default/components/KTooltip/KTooltip.vue +2 -0
  128. package/dist/runtime/presets/default/components/KTree/KTree.d.vue.ts +20 -10
  129. package/dist/runtime/presets/default/components/KTree/KTree.vue +34 -24
  130. package/dist/runtime/presets/default/components/KTree/KTree.vue.d.ts +20 -10
  131. package/dist/runtime/presets/default/components/KTreeView/KTreeCell.vue +2 -1
  132. package/dist/runtime/presets/default/components/KTreeView/KTreeView.d.vue.ts +8 -2
  133. package/dist/runtime/presets/default/components/KTreeView/KTreeView.vue +10 -1
  134. package/dist/runtime/presets/default/components/KTreeView/KTreeView.vue.d.ts +8 -2
  135. package/dist/runtime/server/middleware/session.d.ts +2 -0
  136. package/dist/runtime/server/middleware/session.js +36 -0
  137. package/dist/runtime/utils/PresetResolver.js +21 -7
  138. package/dist/runtime/utils/TemplateResolver.js +11 -5
  139. package/package.json +2 -2
@@ -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
  }
@@ -0,0 +1,25 @@
1
+ import { RequestQueue, type IQueuedOperation, type IDeadLetterItem } from '@katlux/providers';
2
+ /**
3
+ * useRequestQueue
4
+ *
5
+ * Idiomatic Vue 3 composable bridge for Katlux RequestQueue.
6
+ * Connects the pure framework-agnostic RequestQueue state to Vue 3 reactive refs.
7
+ */
8
+ export declare function useRequestQueue(): {
9
+ queue: import("vue").ShallowRef<IQueuedOperation[], IQueuedOperation[]>;
10
+ deadLetterQueue: import("vue").ShallowRef<IDeadLetterItem[], IDeadLetterItem[]>;
11
+ isFlushing: import("vue").Ref<boolean, boolean>;
12
+ init: typeof RequestQueue.init;
13
+ setStorageBackend: typeof RequestQueue.setStorageBackend;
14
+ enqueue: typeof RequestQueue.enqueue;
15
+ flushAll: typeof RequestQueue.flushAll;
16
+ flushOne: typeof RequestQueue.flushOne;
17
+ retryOne: typeof RequestQueue.retryOne;
18
+ discard: typeof RequestQueue.discard;
19
+ reorder: typeof RequestQueue.reorder;
20
+ getQueue: typeof RequestQueue.getQueue;
21
+ getDeadLetterQueue: typeof RequestQueue.getDeadLetterQueue;
22
+ onDeadLetter: typeof RequestQueue.onDeadLetter;
23
+ onFlushComplete: typeof RequestQueue.onFlushComplete;
24
+ onNetworkError: typeof RequestQueue.onNetworkError;
25
+ };
@@ -0,0 +1,35 @@
1
+ import { shallowRef, ref, onScopeDispose } from "vue";
2
+ import { RequestQueue } from "@katlux/providers";
3
+ export function useRequestQueue() {
4
+ const queue = shallowRef([...RequestQueue.queue]);
5
+ const deadLetterQueue = shallowRef([...RequestQueue.deadLetterQueue]);
6
+ const isFlushing = ref(RequestQueue.isFlushing);
7
+ const sync = () => {
8
+ queue.value = [...RequestQueue.queue];
9
+ deadLetterQueue.value = [...RequestQueue.deadLetterQueue];
10
+ isFlushing.value = RequestQueue.isFlushing;
11
+ };
12
+ const unsubscribe = RequestQueue.subscribe(sync);
13
+ try {
14
+ onScopeDispose(unsubscribe);
15
+ } catch {
16
+ }
17
+ return {
18
+ queue,
19
+ deadLetterQueue,
20
+ isFlushing,
21
+ init: RequestQueue.init.bind(RequestQueue),
22
+ setStorageBackend: RequestQueue.setStorageBackend.bind(RequestQueue),
23
+ enqueue: RequestQueue.enqueue.bind(RequestQueue),
24
+ flushAll: RequestQueue.flushAll.bind(RequestQueue),
25
+ flushOne: RequestQueue.flushOne.bind(RequestQueue),
26
+ retryOne: RequestQueue.retryOne.bind(RequestQueue),
27
+ discard: RequestQueue.discard.bind(RequestQueue),
28
+ reorder: RequestQueue.reorder.bind(RequestQueue),
29
+ getQueue: RequestQueue.getQueue.bind(RequestQueue),
30
+ getDeadLetterQueue: RequestQueue.getDeadLetterQueue.bind(RequestQueue),
31
+ onDeadLetter: RequestQueue.onDeadLetter.bind(RequestQueue),
32
+ onFlushComplete: RequestQueue.onFlushComplete.bind(RequestQueue),
33
+ onNetworkError: RequestQueue.onNetworkError.bind(RequestQueue)
34
+ };
35
+ }
@@ -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
 
@@ -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;
@@ -2,10 +2,10 @@
2
2
  .KCheckbox-wrapper
3
3
  label.KCheckbox(
4
4
  role="checkbox"
5
- :aria-checked="!!internalModel"
5
+ :aria-checked="isChecked"
6
6
  :aria-disabled="isDisabled"
7
7
  tabindex="0"
8
- @keydown.space.prevent="internalModel = !internalModel"
8
+ @keydown.space.prevent="handleSpaceKey"
9
9
  )
10
10
  input(type="checkbox" v-model="internalModel" :value="checkboxValue" :disabled="isDisabled" tabindex="-1")
11
11
  .icon-container(:class="validation ? `is-${validation}` : ''")
@@ -38,6 +38,28 @@ const internalModel = computed({
38
38
  get: () => props.model,
39
39
  set: (value) => emit('update:model', value)
40
40
  })
41
+
42
+ // Correctly compute checked state for both boolean and array models
43
+ const isChecked = computed(() => {
44
+ if (Array.isArray(internalModel.value)) {
45
+ return internalModel.value.includes(props.checkboxValue)
46
+ }
47
+ return !!internalModel.value
48
+ })
49
+
50
+ // Handle Space key correctly for both boolean and array models
51
+ function handleSpaceKey() {
52
+ if (Array.isArray(internalModel.value)) {
53
+ const val = props.checkboxValue
54
+ const arr = [...internalModel.value]
55
+ const idx = arr.indexOf(val)
56
+ if (idx === -1) arr.push(val)
57
+ else arr.splice(idx, 1)
58
+ internalModel.value = arr
59
+ } else {
60
+ internalModel.value = !internalModel.value
61
+ }
62
+ }
41
63
  </script>
42
64
 
43
65
  <style lang="scss" scoped>
@@ -1,4 +1,4 @@
1
- import type { ComboboxItem } from '../../../../components/KCombobox/KCombobox.logic.js';
1
+ import type { ComboboxItem } from '#toolkit/components/KCombobox/KCombobox.logic';
2
2
  type __VLS_Props = {
3
3
  label?: string;
4
4
  disabled: boolean;
@@ -15,8 +15,18 @@ type __VLS_Props = {
15
15
  selectItem: (option: ComboboxItem) => void;
16
16
  isSelected: (option: ComboboxItem) => boolean;
17
17
  loading: boolean;
18
+ loadingMore?: boolean;
19
+ initialLoading?: boolean;
20
+ canLoadMore?: boolean;
21
+ loadMore?: () => void;
22
+ virtualScroll?: boolean;
23
+ itemHeight?: number;
24
+ buffer?: number;
18
25
  teleportTo?: string;
19
26
  fullWidth: boolean;
27
+ highlightedIndex?: number;
28
+ onKeyDown?: (e: KeyboardEvent) => void;
29
+ setHighlightedIndex?: (idx: number) => void;
20
30
  validation?: 'success' | 'warning' | 'error' | null;
21
31
  validationText?: string;
22
32
  };
@@ -26,6 +36,13 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
26
36
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
27
37
  "onUpdate:isOptionsOpen"?: ((value: boolean) => any) | undefined;
28
38
  "onUpdate:searchtext"?: ((value: string) => any) | undefined;
29
- }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
39
+ }>, {
40
+ loadingMore: boolean;
41
+ initialLoading: boolean;
42
+ canLoadMore: boolean;
43
+ virtualScroll: boolean;
44
+ itemHeight: number;
45
+ buffer: number;
46
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
30
47
  declare const _default: typeof __VLS_export;
31
48
  export default _default;
@@ -4,13 +4,13 @@
4
4
  .KCombobox(ref="activatorRef" :class="{ disabled: disabled, open: isOptionsOpen, ... (validation ? { [`is-${validation}`]: true } : {}) }")
5
5
  KGrid(
6
6
  @click.stop="toggleDropdown"
7
- @keydown.enter.prevent="toggleDropdown"
8
- @keydown.space.prevent="toggleDropdown"
9
- @keydown.escape.prevent="closeDropdown"
7
+ @keydown="onKeyDown"
10
8
  role="combobox"
11
9
  :aria-expanded="isOptionsOpen"
12
10
  aria-haspopup="listbox"
13
- tabindex="0"
11
+ :aria-activedescendant="highlightedIndex !== undefined && highlightedIndex >= 0 ? `k-combobox-opt-${highlightedIndex}` : undefined"
12
+ :aria-disabled="disabled"
13
+ :tabindex="disabled ? -1 : 0"
14
14
  align="center"
15
15
  justify="space-between"
16
16
  ).KCombobox__selected-content-container
@@ -31,22 +31,32 @@
31
31
  :searchPlaceholder="searchPlaceholder"
32
32
  v-model:searchtext="searchtextModel"
33
33
  :loading="loading"
34
+ :loadingMore="loadingMore"
35
+ :initialLoading="initialLoading"
36
+ :canLoadMore="canLoadMore"
37
+ :loadMore="loadMore"
38
+ :virtualScroll="virtualScroll"
39
+ :itemHeight="itemHeight"
40
+ :buffer="buffer"
34
41
  :filteredOptions="filteredOptions"
35
42
  :labelField="labelField"
36
43
  :selectItem="selectItem"
37
44
  :isSelected="isSelected"
45
+ :highlightedIndex="highlightedIndex"
46
+ :onKeyDown="onKeyDown"
47
+ :setHighlightedIndex="setHighlightedIndex"
38
48
  )
39
49
  span.validation-text(v-if="validation && ['success', 'warning', 'error'].includes(validation) && validationText" :class="`is-${validation}`") {{ validationText }}
40
50
  </template>
41
51
 
42
52
  <script lang="ts" setup>
43
- import { computed, ref, useSlots } from 'vue'
53
+ import { computed, ref, useSlots, watch } from 'vue'
44
54
  const activatorRef = ref<HTMLElement | null>(null)
45
55
  const slots = useSlots()
46
56
  import KComboboxList from './KComboboxList.vue'
47
- import type { ComboboxItem } from '../../../../components/KCombobox/KCombobox.logic'
57
+ import type { ComboboxItem } from '#toolkit/components/KCombobox/KCombobox.logic'
48
58
 
49
- const props = defineProps<{
59
+ const props = withDefaults(defineProps<{
50
60
  label?: string
51
61
  disabled: boolean
52
62
  isOptionsOpen: boolean
@@ -62,11 +72,28 @@ const props = defineProps<{
62
72
  selectItem: (option: ComboboxItem) => void
63
73
  isSelected: (option: ComboboxItem) => boolean
64
74
  loading: boolean
75
+ loadingMore?: boolean
76
+ initialLoading?: boolean
77
+ canLoadMore?: boolean
78
+ loadMore?: () => void
79
+ virtualScroll?: boolean
80
+ itemHeight?: number
81
+ buffer?: number
65
82
  teleportTo?: string
66
83
  fullWidth: boolean
84
+ highlightedIndex?: number
85
+ onKeyDown?: (e: KeyboardEvent) => void
86
+ setHighlightedIndex?: (idx: number) => void
67
87
  validation?: 'success' | 'warning' | 'error' | null
68
88
  validationText?: string
69
- }>()
89
+ }>(), {
90
+ virtualScroll: true,
91
+ itemHeight: 40,
92
+ buffer: 5,
93
+ loadingMore: false,
94
+ initialLoading: false,
95
+ canLoadMore: false,
96
+ })
70
97
 
71
98
  const emit = defineEmits<{
72
99
  (e: 'update:searchtext', value: string): void
@@ -82,6 +109,13 @@ const isOptionsOpenModel = computed({
82
109
  get: () => props.isOptionsOpen,
83
110
  set: (value) => emit('update:isOptionsOpen', value)
84
111
  })
112
+
113
+ watch(isOptionsOpenModel, (isOpen, oldOpen) => {
114
+ if (oldOpen && !isOpen && activatorRef.value) {
115
+ const trigger = activatorRef.value.querySelector<HTMLElement>('[role="combobox"]')
116
+ trigger?.focus()
117
+ }
118
+ })
85
119
  </script>
86
120
 
87
121
  <style lang="scss" scoped>