@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.
Files changed (137) 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/KCheckbox/KCheckbox.global.d.vue.ts +1 -1
  15. package/dist/runtime/components/KCheckbox/KCheckbox.global.vue.d.ts +1 -1
  16. package/dist/runtime/components/KCombobox/KCombobox.global.d.vue.ts +5 -5
  17. package/dist/runtime/components/KCombobox/KCombobox.global.vue +6 -0
  18. package/dist/runtime/components/KCombobox/KCombobox.global.vue.d.ts +5 -5
  19. package/dist/runtime/components/KCombobox/KCombobox.logic.d.ts +3 -0
  20. package/dist/runtime/components/KCombobox/KCombobox.logic.js +192 -14
  21. package/dist/runtime/components/KCompositeInput/KCompositeInput.global.d.vue.ts +11 -11
  22. package/dist/runtime/components/KCompositeInput/KCompositeInput.global.vue.d.ts +11 -11
  23. package/dist/runtime/components/KCompositeInput/KCompositeInput.logic.d.ts +1 -1
  24. package/dist/runtime/components/KDatatable/KDataIterator.logic.js +23 -16
  25. package/dist/runtime/components/KDatatable/KDatatable.logic.d.ts +1 -1
  26. package/dist/runtime/components/KDatatable/KDatatable.logic.js +36 -27
  27. package/dist/runtime/components/KDatePicker/KDatePicker.global.d.vue.ts +6 -6
  28. package/dist/runtime/components/KDatePicker/KDatePicker.global.vue.d.ts +6 -6
  29. package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.d.vue.ts +7 -7
  30. package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.vue.d.ts +7 -7
  31. package/dist/runtime/components/KDropdown/KDropdown.global.d.vue.ts +1 -1
  32. package/dist/runtime/components/KDropdown/KDropdown.global.vue.d.ts +1 -1
  33. package/dist/runtime/components/KGrid/KGrid.global.d.vue.ts +1 -1
  34. package/dist/runtime/components/KGrid/KGrid.global.vue.d.ts +1 -1
  35. package/dist/runtime/components/KHourPicker/KHourPicker.global.d.vue.ts +2 -2
  36. package/dist/runtime/components/KHourPicker/KHourPicker.global.vue.d.ts +2 -2
  37. package/dist/runtime/components/KMaskTextbox/KMaskTextbox.global.d.vue.ts +2 -2
  38. package/dist/runtime/components/KMaskTextbox/KMaskTextbox.global.vue.d.ts +2 -2
  39. package/dist/runtime/components/KModal/KModal.global.d.vue.ts +15 -2
  40. package/dist/runtime/components/KModal/KModal.global.vue +6 -1
  41. package/dist/runtime/components/KModal/KModal.global.vue.d.ts +15 -2
  42. package/dist/runtime/components/KModal/KModal.logic.d.ts +8 -2
  43. package/dist/runtime/components/KModal/KModal.logic.js +21 -3
  44. package/dist/runtime/components/KPagination/KPagination.global.vue +2 -0
  45. package/dist/runtime/components/KPagination/KPagination.logic.d.ts +2 -1
  46. package/dist/runtime/components/KPagination/KPagination.logic.js +1 -0
  47. package/dist/runtime/components/KSlider/KSlider.global.d.vue.ts +1 -1
  48. package/dist/runtime/components/KSlider/KSlider.global.vue.d.ts +1 -1
  49. package/dist/runtime/components/KTabs/KTabItem.logic.js +20 -5
  50. package/dist/runtime/components/KTabs/KTabs.logic.js +18 -2
  51. package/dist/runtime/components/KTextbox/KTextbox.global.d.vue.ts +2 -2
  52. package/dist/runtime/components/KTextbox/KTextbox.global.vue.d.ts +2 -2
  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 +12 -3
  56. package/dist/runtime/components/KTree/KTree.global.vue +1 -0
  57. package/dist/runtime/components/KTree/KTree.global.vue.d.ts +12 -3
  58. package/dist/runtime/components/KTree/KTree.logic.d.ts +9 -4
  59. package/dist/runtime/components/KTree/KTree.logic.js +9 -6
  60. package/dist/runtime/components/KTreePicker/KTreePicker.global.d.vue.ts +4 -4
  61. package/dist/runtime/components/KTreePicker/KTreePicker.global.vue.d.ts +4 -4
  62. package/dist/runtime/components/KTreePicker/KTreePicker.logic.d.ts +3 -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 +26 -7
  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 +121 -90
  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/directives/clickOutside.d.ts +3 -2
  77. package/dist/runtime/directives/clickOutside.js +9 -2
  78. package/dist/runtime/hydration/NuxtHydrationAdapter.d.ts +10 -0
  79. package/dist/runtime/hydration/NuxtHydrationAdapter.js +88 -0
  80. package/dist/runtime/plugins/PresetPlugin.js +9 -1
  81. package/dist/runtime/plugins/nuxtCompatPlugin.d.ts +2 -3
  82. package/dist/runtime/plugins/nuxtCompatPlugin.js +6 -1
  83. package/dist/runtime/presets/default/components/KCalendar/KCalendar.d.vue.ts +1 -1
  84. package/dist/runtime/presets/default/components/KCalendar/KCalendar.vue +1 -1
  85. package/dist/runtime/presets/default/components/KCalendar/KCalendar.vue.d.ts +1 -1
  86. package/dist/runtime/presets/default/components/KCalendar/KCalendarMonth.d.vue.ts +1 -1
  87. package/dist/runtime/presets/default/components/KCalendar/KCalendarMonth.vue +1 -1
  88. package/dist/runtime/presets/default/components/KCalendar/KCalendarMonth.vue.d.ts +1 -1
  89. package/dist/runtime/presets/default/components/KCalendar/KCalendarWeek.d.vue.ts +1 -1
  90. package/dist/runtime/presets/default/components/KCalendar/KCalendarWeek.vue +1 -1
  91. package/dist/runtime/presets/default/components/KCalendar/KCalendarWeek.vue.d.ts +1 -1
  92. package/dist/runtime/presets/default/components/KCheckbox/KCheckbox.vue +24 -2
  93. package/dist/runtime/presets/default/components/KCombobox/KCombobox.d.vue.ts +4 -1
  94. package/dist/runtime/presets/default/components/KCombobox/KCombobox.vue +19 -6
  95. package/dist/runtime/presets/default/components/KCombobox/KCombobox.vue.d.ts +4 -1
  96. package/dist/runtime/presets/default/components/KCombobox/KComboboxList.d.vue.ts +4 -1
  97. package/dist/runtime/presets/default/components/KCombobox/KComboboxList.vue +36 -8
  98. package/dist/runtime/presets/default/components/KCombobox/KComboboxList.vue.d.ts +4 -1
  99. package/dist/runtime/presets/default/components/KCompositeInput/KCompositeInput.d.vue.ts +1 -1
  100. package/dist/runtime/presets/default/components/KCompositeInput/KCompositeInput.vue +1 -1
  101. package/dist/runtime/presets/default/components/KCompositeInput/KCompositeInput.vue.d.ts +1 -1
  102. package/dist/runtime/presets/default/components/KDatatable/KDatatable.vue +1 -0
  103. package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.d.vue.ts +1 -1
  104. package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.vue +1 -1
  105. package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.vue.d.ts +1 -1
  106. package/dist/runtime/presets/default/components/KDateTimePicker/KDateTimePicker.d.vue.ts +1 -1
  107. package/dist/runtime/presets/default/components/KDateTimePicker/KDateTimePicker.vue +1 -1
  108. package/dist/runtime/presets/default/components/KDateTimePicker/KDateTimePicker.vue.d.ts +1 -1
  109. package/dist/runtime/presets/default/components/KGantt/KGantt.vue +1 -20
  110. package/dist/runtime/presets/default/components/KHourPicker/KHourPicker.d.vue.ts +2 -2
  111. package/dist/runtime/presets/default/components/KHourPicker/KHourPicker.vue +2 -2
  112. package/dist/runtime/presets/default/components/KHourPicker/KHourPicker.vue.d.ts +2 -2
  113. package/dist/runtime/presets/default/components/KLoader/KLoader.vue +6 -2
  114. package/dist/runtime/presets/default/components/KMaskTextbox/KMaskTextbox.vue +1 -1
  115. package/dist/runtime/presets/default/components/KModal/KModal.vue +16 -4
  116. package/dist/runtime/presets/default/components/KPagination/KPagination.d.vue.ts +1 -0
  117. package/dist/runtime/presets/default/components/KPagination/KPagination.vue +5 -4
  118. package/dist/runtime/presets/default/components/KPagination/KPagination.vue.d.ts +1 -0
  119. package/dist/runtime/presets/default/components/KRangeSlider/KRangeSlider.vue +3 -1
  120. package/dist/runtime/presets/default/components/KSlider/KSlider.vue +2 -1
  121. package/dist/runtime/presets/default/components/KTabs/KTabs.vue +2 -1
  122. package/dist/runtime/presets/default/components/KToast/KToast.d.vue.ts +1 -1
  123. package/dist/runtime/presets/default/components/KToast/KToast.vue +1 -1
  124. package/dist/runtime/presets/default/components/KToast/KToast.vue.d.ts +1 -1
  125. package/dist/runtime/presets/default/components/KTooltip/KTooltip.vue +2 -0
  126. package/dist/runtime/presets/default/components/KTree/KTree.d.vue.ts +20 -10
  127. package/dist/runtime/presets/default/components/KTree/KTree.vue +34 -24
  128. package/dist/runtime/presets/default/components/KTree/KTree.vue.d.ts +20 -10
  129. package/dist/runtime/presets/default/components/KTreeView/KTreeCell.vue +2 -1
  130. package/dist/runtime/presets/default/components/KTreeView/KTreeView.d.vue.ts +8 -2
  131. package/dist/runtime/presets/default/components/KTreeView/KTreeView.vue +10 -1
  132. package/dist/runtime/presets/default/components/KTreeView/KTreeView.vue.d.ts +8 -2
  133. package/dist/runtime/server/middleware/session.d.ts +2 -0
  134. package/dist/runtime/server/middleware/session.js +36 -0
  135. package/dist/runtime/utils/PresetResolver.js +21 -7
  136. package/dist/runtime/utils/TemplateResolver.js +11 -5
  137. package/package.json +2 -2
@@ -1,5 +1,5 @@
1
1
  import { describe, it, expect } from "vitest";
2
- import { effectScope } from "vue";
2
+ import { effectScope, ref, nextTick } from "vue";
3
3
  import { CFlatClientDataProvider, EDataFilterOperator } from "@katlux/providers";
4
4
  import { useDataProvider } from "./useDataProvider.mjs";
5
5
  describe("useDataProvider Composable Adapter", () => {
@@ -83,4 +83,23 @@ describe("useDataProvider Composable Adapter", () => {
83
83
  scope.stop();
84
84
  provider.setData([{ id: 1 }, { id: 2 }]);
85
85
  });
86
+ it("should reactively switch providers when passed a getter function", async () => {
87
+ const providerA = new CFlatClientDataProvider();
88
+ providerA.setData([{ id: 1, title: "Old 1" }, { id: 2, title: "Old 2" }]);
89
+ const providerB = new CFlatClientDataProvider();
90
+ providerB.setData([{ id: 10, title: "New 1" }, { id: 20, title: "New 2" }, { id: 30, title: "New 3" }]);
91
+ const active = ref(providerA);
92
+ const scope = effectScope();
93
+ await scope.run(async () => {
94
+ const { pageData, rowCount } = useDataProvider(() => active.value);
95
+ expect(pageData.value.length).toBe(2);
96
+ expect(rowCount.value).toBe(2);
97
+ active.value = providerB;
98
+ await nextTick();
99
+ expect(pageData.value.length).toBe(3);
100
+ expect(rowCount.value).toBe(3);
101
+ expect(pageData.value[0].id).toBe(10);
102
+ });
103
+ scope.stop();
104
+ });
86
105
  });
@@ -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
+ }
@@ -0,0 +1,63 @@
1
+ import { describe, it, expect, beforeEach, afterEach, vi } from "vitest";
2
+ import { useKatluxContext } from "./useKatluxContext.mjs";
3
+ describe("useKatluxContext Composable", () => {
4
+ const originalWindow = globalThis.window;
5
+ const originalKatluxApp = globalThis.__KATLUX_APP__;
6
+ const originalUseRequestEvent = globalThis.useRequestEvent;
7
+ beforeEach(() => {
8
+ vi.restoreAllMocks();
9
+ delete globalThis.__KATLUX_APP__;
10
+ delete globalThis.useRequestEvent;
11
+ });
12
+ afterEach(() => {
13
+ if (originalKatluxApp !== void 0) {
14
+ ;
15
+ globalThis.__KATLUX_APP__ = originalKatluxApp;
16
+ } else {
17
+ delete globalThis.__KATLUX_APP__;
18
+ }
19
+ if (originalUseRequestEvent !== void 0) {
20
+ ;
21
+ globalThis.useRequestEvent = originalUseRequestEvent;
22
+ } else {
23
+ delete globalThis.useRequestEvent;
24
+ }
25
+ if (originalWindow !== void 0) {
26
+ ;
27
+ globalThis.window = originalWindow;
28
+ }
29
+ });
30
+ it("returns null on client environment", () => {
31
+ const clientContext = useKatluxContext();
32
+ expect(clientContext).toBeNull();
33
+ });
34
+ it("returns { event } on server via useRequestEvent", () => {
35
+ const mockEvent = { req: { url: "/test" }, context: {} };
36
+ globalThis.useRequestEvent = () => mockEvent;
37
+ const win = globalThis.window;
38
+ delete globalThis.window;
39
+ try {
40
+ const ctx = useKatluxContext();
41
+ expect(ctx).toEqual({ event: mockEvent });
42
+ } finally {
43
+ ;
44
+ globalThis.window = win;
45
+ }
46
+ });
47
+ it("returns { event } on server via __KATLUX_APP__.ssrContext.event", () => {
48
+ delete globalThis.useRequestEvent;
49
+ const mockSsrEvent = { id: "ssr-event-999" };
50
+ globalThis.__KATLUX_APP__ = {
51
+ ssrContext: { event: mockSsrEvent }
52
+ };
53
+ const win = globalThis.window;
54
+ delete globalThis.window;
55
+ try {
56
+ const ctx = useKatluxContext();
57
+ expect(ctx).toEqual({ event: mockSsrEvent });
58
+ } finally {
59
+ ;
60
+ globalThis.window = win;
61
+ }
62
+ });
63
+ });
@@ -1,31 +1,42 @@
1
1
  import { en, builtInLocales } from "./locales.mjs";
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,4 +1,4 @@
1
- import { useRuntimeConfig, useAppConfig, useCookie, useNuxtApp } from "#app";
1
+ import { useRuntimeConfig, useAppConfig, useCookie, useNuxtApp, useState } from "#app";
2
2
  export class PresetResolver {
3
3
  cache = {};
4
4
  activePreset = "default";
@@ -50,10 +50,12 @@ export class PresetResolver {
50
50
  hasCustomPreset: false,
51
51
  hasCustomStyles: false
52
52
  };
53
- const firstPreset = Array.isArray(this.activePreset) ? this.activePreset[0] : this.activePreset;
54
- if (firstPreset && firstPreset !== "default") {
55
- metadata.presetPath = `${this.presetsDir}/${firstPreset}/${componentName}.pug`;
56
- metadata.stylesPath = `${this.presetsDir}/${firstPreset}/${componentName}.scss`;
53
+ const presetList = Array.isArray(this.activePreset) ? this.activePreset : [this.activePreset];
54
+ const candidatePresets = presetList.filter((p) => p && p !== "default");
55
+ if (candidatePresets.length > 0) {
56
+ const targetPreset = candidatePresets[0];
57
+ metadata.presetPath = `${this.presetsDir}/${targetPreset}/${componentName}.pug`;
58
+ metadata.stylesPath = `${this.presetsDir}/${targetPreset}/${componentName}.scss`;
57
59
  metadata.hasCustomPreset = true;
58
60
  metadata.hasCustomStyles = true;
59
61
  }
@@ -74,8 +76,20 @@ export class PresetResolver {
74
76
  if (JSON.stringify(this.activePreset) !== JSON.stringify(presetName)) {
75
77
  this.activePreset = presetName;
76
78
  this.clearCache();
77
- const presetCookie = useCookie("katlux-active-preset");
78
- presetCookie.value = typeof presetName === "string" ? presetName : JSON.stringify(presetName);
79
+ try {
80
+ const activePresetState = useState("katlux-active-preset-state");
81
+ activePresetState.value = presetName;
82
+ } catch {
83
+ }
84
+ try {
85
+ const presetCookie = useCookie("katlux-active-preset");
86
+ presetCookie.value = typeof presetName === "string" ? presetName : JSON.stringify(presetName);
87
+ } catch {
88
+ if (typeof document !== "undefined") {
89
+ const val = typeof presetName === "string" ? presetName : JSON.stringify(presetName);
90
+ document.cookie = `katlux-active-preset=${encodeURIComponent(val)}; path=/; max-age=31536000; SameSite=Lax`;
91
+ }
92
+ }
79
93
  }
80
94
  }
81
95
  /**
@@ -1,4 +1,5 @@
1
1
  import { PresetResolver, usePresetResolver } from "./PresetResolver.mjs";
2
+ import { useNuxtApp } from "#app";
2
3
  export class TemplateResolver extends PresetResolver {
3
4
  resolveTemplate(componentName) {
4
5
  const presetMeta = this.resolvePreset(componentName);
@@ -18,14 +19,19 @@ export class TemplateResolver extends PresetResolver {
18
19
  }
19
20
  export function useTemplateResolver() {
20
21
  try {
22
+ const nuxtApp = useNuxtApp();
23
+ if (nuxtApp?.$templateResolver) {
24
+ return nuxtApp.$templateResolver;
25
+ }
21
26
  const nuxtPresetResolver = usePresetResolver();
27
+ const tr = new TemplateResolver();
22
28
  if (nuxtPresetResolver) {
23
- if (nuxtPresetResolver instanceof TemplateResolver) {
24
- return nuxtPresetResolver;
25
- }
26
- const tr = new TemplateResolver();
27
- return tr;
29
+ tr.setActivePreset(nuxtPresetResolver.getActivePreset());
30
+ }
31
+ if (nuxtApp?.provide) {
32
+ nuxtApp.provide("templateResolver", tr);
28
33
  }
34
+ return tr;
29
35
  } catch {
30
36
  }
31
37
  return new TemplateResolver();
package/dist/module.cjs CHANGED
@@ -19,39 +19,8 @@ const module$1 = kit.defineNuxtModule({
19
19
  const cssPath = resolve("./runtime/presets/default/assets/scss/index.css");
20
20
  const finalCssPath = node_fs.existsSync(scssPath) ? scssPath : cssPath;
21
21
  nuxt.options.css.push(finalCssPath);
22
- const sharedIgnored = [
23
- "**/node_modules/**",
24
- "**/.nuxt/**",
25
- "**/.output/**",
26
- "**/dist/**",
27
- "**/.git/**",
28
- "**/tmp/**",
29
- "**/.firebase/**"
30
- ];
31
- nuxt.options.watchers = nuxt.options.watchers || {};
32
- const chokidar = nuxt.options.watchers.chokidar = nuxt.options.watchers.chokidar || {};
33
- const existingIgnored = chokidar.ignored ? Array.isArray(chokidar.ignored) ? chokidar.ignored : [chokidar.ignored] : [];
34
- chokidar.ignored = [.../* @__PURE__ */ new Set([...existingIgnored, ...sharedIgnored])];
35
- chokidar.usePolling = true;
36
- chokidar.interval = 1e3;
37
- nuxt.options.nitro = nuxt.options.nitro || {};
38
- const watchOptions = nuxt.options.nitro.watchOptions = nuxt.options.nitro.watchOptions || {};
39
- watchOptions.usePolling = true;
40
- watchOptions.interval = 1e3;
41
- watchOptions.ignored = sharedIgnored;
42
22
  nuxt.hook("vite:extendConfig", (config) => {
43
23
  const server = config.server || (config.server = {});
44
- const watch = server.watch || (server.watch = {});
45
- const currentIgnored = watch.ignored || [];
46
- if (Array.isArray(currentIgnored)) {
47
- watch.ignored = [.../* @__PURE__ */ new Set([...currentIgnored, ...sharedIgnored])];
48
- } else if (currentIgnored) {
49
- watch.ignored = [currentIgnored, ...sharedIgnored];
50
- } else {
51
- watch.ignored = sharedIgnored;
52
- }
53
- watch.usePolling = true;
54
- watch.interval = 1e3;
55
24
  const fs = server.fs || (server.fs = {});
56
25
  const allow = fs.allow || (fs.allow = []);
57
26
  if (!allow.includes(runtimePath)) {
@@ -73,6 +42,9 @@ const module$1 = kit.defineNuxtModule({
73
42
  kit.addPlugin(resolve("./runtime/plugins/registerDirectives"));
74
43
  kit.addPlugin(resolve("./runtime/plugins/PresetPlugin"));
75
44
  kit.addPlugin(resolve("./runtime/plugins/nuxtCompatPlugin"));
45
+ kit.addServerHandler({
46
+ handler: resolve("./runtime/server/middleware/session")
47
+ });
76
48
  nuxt.options.alias["#toolkit"] = resolve("./runtime");
77
49
  nuxt.options.alias["#toolkit/*"] = resolve("./runtime/*");
78
50
  const userSrcDir = nuxt.options.srcDir || nuxt.options.rootDir;
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@katlux/toolkit",
3
3
  "configKey": "katluxToolkit",
4
- "version": "0.1.1-alpha.111",
4
+ "version": "0.1.1-alpha.112",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { defineNuxtModule, createResolver, addComponentsDir, addImportsDir, addPlugin, addPluginTemplate } from '@nuxt/kit';
1
+ import { defineNuxtModule, createResolver, addComponentsDir, addImportsDir, addPlugin, addServerHandler, addPluginTemplate } from '@nuxt/kit';
2
2
  import { existsSync } from 'node:fs';
3
3
  import { createRequire } from 'node:module';
4
4
 
@@ -16,39 +16,8 @@ const module$1 = defineNuxtModule({
16
16
  const cssPath = resolve("./runtime/presets/default/assets/scss/index.css");
17
17
  const finalCssPath = existsSync(scssPath) ? scssPath : cssPath;
18
18
  nuxt.options.css.push(finalCssPath);
19
- const sharedIgnored = [
20
- "**/node_modules/**",
21
- "**/.nuxt/**",
22
- "**/.output/**",
23
- "**/dist/**",
24
- "**/.git/**",
25
- "**/tmp/**",
26
- "**/.firebase/**"
27
- ];
28
- nuxt.options.watchers = nuxt.options.watchers || {};
29
- const chokidar = nuxt.options.watchers.chokidar = nuxt.options.watchers.chokidar || {};
30
- const existingIgnored = chokidar.ignored ? Array.isArray(chokidar.ignored) ? chokidar.ignored : [chokidar.ignored] : [];
31
- chokidar.ignored = [.../* @__PURE__ */ new Set([...existingIgnored, ...sharedIgnored])];
32
- chokidar.usePolling = true;
33
- chokidar.interval = 1e3;
34
- nuxt.options.nitro = nuxt.options.nitro || {};
35
- const watchOptions = nuxt.options.nitro.watchOptions = nuxt.options.nitro.watchOptions || {};
36
- watchOptions.usePolling = true;
37
- watchOptions.interval = 1e3;
38
- watchOptions.ignored = sharedIgnored;
39
19
  nuxt.hook("vite:extendConfig", (config) => {
40
20
  const server = config.server || (config.server = {});
41
- const watch = server.watch || (server.watch = {});
42
- const currentIgnored = watch.ignored || [];
43
- if (Array.isArray(currentIgnored)) {
44
- watch.ignored = [.../* @__PURE__ */ new Set([...currentIgnored, ...sharedIgnored])];
45
- } else if (currentIgnored) {
46
- watch.ignored = [currentIgnored, ...sharedIgnored];
47
- } else {
48
- watch.ignored = sharedIgnored;
49
- }
50
- watch.usePolling = true;
51
- watch.interval = 1e3;
52
21
  const fs = server.fs || (server.fs = {});
53
22
  const allow = fs.allow || (fs.allow = []);
54
23
  if (!allow.includes(runtimePath)) {
@@ -70,6 +39,9 @@ const module$1 = defineNuxtModule({
70
39
  addPlugin(resolve("./runtime/plugins/registerDirectives"));
71
40
  addPlugin(resolve("./runtime/plugins/PresetPlugin"));
72
41
  addPlugin(resolve("./runtime/plugins/nuxtCompatPlugin"));
42
+ addServerHandler({
43
+ handler: resolve("./runtime/server/middleware/session")
44
+ });
73
45
  nuxt.options.alias["#toolkit"] = resolve("./runtime");
74
46
  nuxt.options.alias["#toolkit/*"] = resolve("./runtime/*");
75
47
  const userSrcDir = nuxt.options.srcDir || nuxt.options.rootDir;
@@ -23,7 +23,7 @@ export declare function useKBulkActionsLogic(props: KBulkActionsProps): {
23
23
  type?: "default" | "primary" | "danger" | "success" | "warning" | "info" | "light" | "dark" | undefined;
24
24
  visible?: Function | undefined;
25
25
  } | null>;
26
- dp: CFlatClientDataProvider;
26
+ dp: CFlatClientDataProvider<TDataRow>;
27
27
  doAction: (action: any) => void;
28
28
  visibleBulkActions: import("vue").ComputedRef<IKDatatableAction[]>;
29
29
  getApplicableRows: typeof getApplicableRows;
@@ -54,9 +54,9 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
54
54
  }>> & Readonly<{
55
55
  "onUpdate:modelValue"?: ((value: any) => any) | undefined;
56
56
  }>, {
57
+ value: any;
57
58
  label: string;
58
59
  disabled: boolean;
59
- value: any;
60
60
  validation: "error" | "success" | "warning" | null | undefined;
61
61
  validationText: string;
62
62
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
@@ -54,9 +54,9 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
54
54
  }>> & Readonly<{
55
55
  "onUpdate:modelValue"?: ((value: any) => any) | undefined;
56
56
  }>, {
57
+ value: any;
57
58
  label: string;
58
59
  disabled: boolean;
59
- value: any;
60
60
  validation: "error" | "success" | "warning" | null | undefined;
61
61
  validationText: string;
62
62
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
@@ -181,22 +181,22 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
181
181
  label: string;
182
182
  disabled: boolean;
183
183
  validation: "error" | "success" | "warning" | null | undefined;
184
- modelValue: any;
185
- valueField: string;
186
- placeholder: string;
187
184
  searchbox: boolean;
188
- teleportTo: string;
189
- validationText: string;
190
185
  searchPlaceholder: string;
191
186
  virtualScroll: boolean;
192
187
  itemHeight: number;
193
188
  buffer: number;
194
189
  isOptionsOpen: boolean;
190
+ placeholder: string;
191
+ teleportTo: string;
195
192
  fullWidth: boolean;
193
+ validationText: string;
196
194
  closeOnSelect: boolean;
197
195
  multiSelect: boolean;
198
196
  maxSelectedDisplay: string | number | boolean;
199
197
  visibleFields: String[];
198
+ valueField: string;
199
+ modelValue: any;
200
200
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
201
201
  declare const _default: typeof __VLS_export;
202
202
  export default _default;
@@ -14,6 +14,9 @@ const {
14
14
  getSelectedContent,
15
15
  toggleDropdown,
16
16
  closeDropdown,
17
+ highlightedIndex,
18
+ onKeyDown,
19
+ setHighlightedIndex,
17
20
  filteredOptions,
18
21
  loading,
19
22
  loadingMore,
@@ -29,6 +32,9 @@ const templateProps = computed(() => ({
29
32
  label: props.label,
30
33
  disabled: props.disabled,
31
34
  isOptionsOpen: isOptionsOpen.value,
35
+ highlightedIndex: highlightedIndex.value,
36
+ onKeyDown,
37
+ setHighlightedIndex,
32
38
  labelField: props.labelField,
33
39
  placeholder: props.placeholder,
34
40
  searchbox: props.searchbox,
@@ -181,22 +181,22 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
181
181
  label: string;
182
182
  disabled: boolean;
183
183
  validation: "error" | "success" | "warning" | null | undefined;
184
- modelValue: any;
185
- valueField: string;
186
- placeholder: string;
187
184
  searchbox: boolean;
188
- teleportTo: string;
189
- validationText: string;
190
185
  searchPlaceholder: string;
191
186
  virtualScroll: boolean;
192
187
  itemHeight: number;
193
188
  buffer: number;
194
189
  isOptionsOpen: boolean;
190
+ placeholder: string;
191
+ teleportTo: string;
195
192
  fullWidth: boolean;
193
+ validationText: string;
196
194
  closeOnSelect: boolean;
197
195
  multiSelect: boolean;
198
196
  maxSelectedDisplay: string | number | boolean;
199
197
  visibleFields: String[];
198
+ valueField: string;
199
+ modelValue: any;
200
200
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
201
201
  declare const _default: typeof __VLS_export;
202
202
  export default _default;
@@ -119,6 +119,9 @@ export declare const KComboboxDefaultProps: {
119
119
  export declare function useKComboboxLogic(props: KComboboxProps, emit: KComboboxEmits): {
120
120
  selectedItems: import("vue").Ref<TDataRow[] | null, TDataRow[] | null>;
121
121
  isOptionsOpen: import("vue").Ref<boolean, boolean>;
122
+ highlightedIndex: import("vue").Ref<number, number>;
123
+ onKeyDown: (e: KeyboardEvent) => void;
124
+ setHighlightedIndex: (index: number) => void;
122
125
  searchtext: import("vue").Ref<string, string>;
123
126
  selectItem: (option: ComboboxItem) => void;
124
127
  isSelected: (option: ComboboxItem) => boolean | undefined;