@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
@@ -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
  }
@@ -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,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.110",
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;
@@ -73,6 +73,18 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
73
73
  type: BooleanConstructor;
74
74
  default: boolean;
75
75
  };
76
+ virtualScroll: {
77
+ type: BooleanConstructor;
78
+ default: boolean;
79
+ };
80
+ itemHeight: {
81
+ type: NumberConstructor;
82
+ default: number;
83
+ };
84
+ buffer: {
85
+ type: NumberConstructor;
86
+ default: number;
87
+ };
76
88
  }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
77
89
  "update:modelValue": (value: any) => any;
78
90
  "update:isOptionsOpen": (value: boolean) => any;
@@ -150,6 +162,18 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
150
162
  type: BooleanConstructor;
151
163
  default: boolean;
152
164
  };
165
+ virtualScroll: {
166
+ type: BooleanConstructor;
167
+ default: boolean;
168
+ };
169
+ itemHeight: {
170
+ type: NumberConstructor;
171
+ default: number;
172
+ };
173
+ buffer: {
174
+ type: NumberConstructor;
175
+ default: number;
176
+ };
153
177
  }>> & Readonly<{
154
178
  "onUpdate:modelValue"?: ((value: any) => any) | undefined;
155
179
  "onUpdate:isOptionsOpen"?: ((value: boolean) => any) | undefined;
@@ -157,19 +181,22 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
157
181
  label: string;
158
182
  disabled: boolean;
159
183
  validation: "error" | "success" | "warning" | null | undefined;
160
- validationText: string;
161
- modelValue: any;
162
184
  searchbox: boolean;
163
185
  searchPlaceholder: string;
186
+ virtualScroll: boolean;
187
+ itemHeight: number;
188
+ buffer: number;
164
189
  isOptionsOpen: boolean;
165
190
  placeholder: string;
166
191
  teleportTo: string;
167
192
  fullWidth: boolean;
193
+ validationText: string;
168
194
  closeOnSelect: boolean;
169
195
  multiSelect: boolean;
170
196
  maxSelectedDisplay: string | number | boolean;
171
197
  visibleFields: String[];
172
198
  valueField: string;
199
+ modelValue: any;
173
200
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
174
201
  declare const _default: typeof __VLS_export;
175
202
  export default _default;
@@ -14,8 +14,15 @@ const {
14
14
  getSelectedContent,
15
15
  toggleDropdown,
16
16
  closeDropdown,
17
+ highlightedIndex,
18
+ onKeyDown,
19
+ setHighlightedIndex,
17
20
  filteredOptions,
18
- loading
21
+ loading,
22
+ loadingMore,
23
+ initialLoading,
24
+ canLoadMore,
25
+ loadMore
19
26
  } = useKComboboxLogic(props, emit);
20
27
  watch(isOptionsOpen, (newVal) => {
21
28
  emit("update:isOptionsOpen", newVal);
@@ -25,6 +32,9 @@ const templateProps = computed(() => ({
25
32
  label: props.label,
26
33
  disabled: props.disabled,
27
34
  isOptionsOpen: isOptionsOpen.value,
35
+ highlightedIndex: highlightedIndex.value,
36
+ onKeyDown,
37
+ setHighlightedIndex,
28
38
  labelField: props.labelField,
29
39
  placeholder: props.placeholder,
30
40
  searchbox: props.searchbox,
@@ -37,6 +47,13 @@ const templateProps = computed(() => ({
37
47
  selectItem,
38
48
  isSelected,
39
49
  loading: loading.value,
50
+ loadingMore: loadingMore.value,
51
+ initialLoading: initialLoading.value,
52
+ canLoadMore: canLoadMore.value,
53
+ loadMore,
54
+ virtualScroll: props.virtualScroll,
55
+ itemHeight: props.itemHeight,
56
+ buffer: props.buffer,
40
57
  teleportTo: props.teleportTo,
41
58
  valueField: props.valueField,
42
59
  validation: props.validation,
@@ -73,6 +73,18 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
73
73
  type: BooleanConstructor;
74
74
  default: boolean;
75
75
  };
76
+ virtualScroll: {
77
+ type: BooleanConstructor;
78
+ default: boolean;
79
+ };
80
+ itemHeight: {
81
+ type: NumberConstructor;
82
+ default: number;
83
+ };
84
+ buffer: {
85
+ type: NumberConstructor;
86
+ default: number;
87
+ };
76
88
  }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
77
89
  "update:modelValue": (value: any) => any;
78
90
  "update:isOptionsOpen": (value: boolean) => any;
@@ -150,6 +162,18 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
150
162
  type: BooleanConstructor;
151
163
  default: boolean;
152
164
  };
165
+ virtualScroll: {
166
+ type: BooleanConstructor;
167
+ default: boolean;
168
+ };
169
+ itemHeight: {
170
+ type: NumberConstructor;
171
+ default: number;
172
+ };
173
+ buffer: {
174
+ type: NumberConstructor;
175
+ default: number;
176
+ };
153
177
  }>> & Readonly<{
154
178
  "onUpdate:modelValue"?: ((value: any) => any) | undefined;
155
179
  "onUpdate:isOptionsOpen"?: ((value: boolean) => any) | undefined;
@@ -157,19 +181,22 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
157
181
  label: string;
158
182
  disabled: boolean;
159
183
  validation: "error" | "success" | "warning" | null | undefined;
160
- validationText: string;
161
- modelValue: any;
162
184
  searchbox: boolean;
163
185
  searchPlaceholder: string;
186
+ virtualScroll: boolean;
187
+ itemHeight: number;
188
+ buffer: number;
164
189
  isOptionsOpen: boolean;
165
190
  placeholder: string;
166
191
  teleportTo: string;
167
192
  fullWidth: boolean;
193
+ validationText: string;
168
194
  closeOnSelect: boolean;
169
195
  multiSelect: boolean;
170
196
  maxSelectedDisplay: string | number | boolean;
171
197
  visibleFields: String[];
172
198
  valueField: string;
199
+ modelValue: any;
173
200
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
174
201
  declare const _default: typeof __VLS_export;
175
202
  export default _default;
@@ -21,6 +21,9 @@ export interface KComboboxProps {
21
21
  fullWidth?: boolean;
22
22
  validation?: 'success' | 'warning' | 'error' | null;
23
23
  validationText?: string;
24
+ virtualScroll?: boolean;
25
+ itemHeight?: number;
26
+ buffer?: number;
24
27
  }
25
28
  export interface KComboboxEmits {
26
29
  (e: 'update:modelValue', value: any): void;
@@ -100,10 +103,25 @@ export declare const KComboboxDefaultProps: {
100
103
  type: BooleanConstructor;
101
104
  default: boolean;
102
105
  };
106
+ virtualScroll: {
107
+ type: BooleanConstructor;
108
+ default: boolean;
109
+ };
110
+ itemHeight: {
111
+ type: NumberConstructor;
112
+ default: number;
113
+ };
114
+ buffer: {
115
+ type: NumberConstructor;
116
+ default: number;
117
+ };
103
118
  };
104
119
  export declare function useKComboboxLogic(props: KComboboxProps, emit: KComboboxEmits): {
105
120
  selectedItems: import("vue").Ref<TDataRow[] | null, TDataRow[] | null>;
106
121
  isOptionsOpen: import("vue").Ref<boolean, boolean>;
122
+ highlightedIndex: import("vue").Ref<number, number>;
123
+ onKeyDown: (e: KeyboardEvent) => void;
124
+ setHighlightedIndex: (index: number) => void;
107
125
  searchtext: import("vue").Ref<string, string>;
108
126
  selectItem: (option: ComboboxItem) => void;
109
127
  isSelected: (option: ComboboxItem) => boolean | undefined;
@@ -112,4 +130,11 @@ export declare function useKComboboxLogic(props: KComboboxProps, emit: KCombobox
112
130
  closeDropdown: () => void;
113
131
  filteredOptions: import("vue").ComputedRef<TDataRow[]>;
114
132
  loading: import("vue").Ref<boolean, boolean>;
133
+ loadingMore: import("vue").ComputedRef<boolean>;
134
+ initialLoading: import("vue").ComputedRef<boolean>;
135
+ canLoadMore: import("vue").ComputedRef<boolean>;
136
+ loadMore: () => void;
137
+ virtualScroll: boolean;
138
+ itemHeight: number;
139
+ buffer: number;
115
140
  };