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

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 (42) hide show
  1. package/dist/compiled/utils/PresetResolver.mjs +10 -0
  2. package/dist/compiled/utils/PresetResolver.spec.mjs +68 -0
  3. package/dist/module.json +1 -1
  4. package/dist/runtime/components/KButton/KButton.global.d.vue.ts +1 -1
  5. package/dist/runtime/components/KButton/KButton.global.vue.d.ts +1 -1
  6. package/dist/runtime/components/KCheckbox/KCheckbox.global.d.vue.ts +1 -1
  7. package/dist/runtime/components/KCheckbox/KCheckbox.global.vue.d.ts +1 -1
  8. package/dist/runtime/components/KCombobox/KCombobox.global.d.vue.ts +3 -3
  9. package/dist/runtime/components/KCombobox/KCombobox.global.vue.d.ts +3 -3
  10. package/dist/runtime/components/KCompositeInput/KCompositeInput.global.d.vue.ts +6 -6
  11. package/dist/runtime/components/KCompositeInput/KCompositeInput.global.vue.d.ts +6 -6
  12. package/dist/runtime/components/KContextMenu/KContextMenu.global.d.vue.ts +1 -1
  13. package/dist/runtime/components/KContextMenu/KContextMenu.global.vue.d.ts +1 -1
  14. package/dist/runtime/components/KDatatable/KDataIterator.global.d.vue.ts +1 -1
  15. package/dist/runtime/components/KDatatable/KDataIterator.global.vue.d.ts +1 -1
  16. package/dist/runtime/components/KDatePicker/KDatePicker.global.d.vue.ts +4 -4
  17. package/dist/runtime/components/KDatePicker/KDatePicker.global.vue.d.ts +4 -4
  18. package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.d.vue.ts +4 -4
  19. package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.vue.d.ts +4 -4
  20. package/dist/runtime/components/KDropdown/KDropdown.global.d.vue.ts +2 -2
  21. package/dist/runtime/components/KDropdown/KDropdown.global.vue.d.ts +2 -2
  22. package/dist/runtime/components/KLayout/KLayout.global.d.vue.ts +3 -0
  23. package/dist/runtime/components/KLayout/KLayout.global.vue +11 -0
  24. package/dist/runtime/components/KLayout/KLayout.global.vue.d.ts +3 -0
  25. package/dist/runtime/components/KSlider/KSlider.global.d.vue.ts +1 -1
  26. package/dist/runtime/components/KSlider/KSlider.global.vue.d.ts +1 -1
  27. package/dist/runtime/components/KTextarea/KTextarea.global.d.vue.ts +1 -1
  28. package/dist/runtime/components/KTextarea/KTextarea.global.vue.d.ts +1 -1
  29. package/dist/runtime/components/KTree/KTree.global.d.vue.ts +2 -2
  30. package/dist/runtime/components/KTree/KTree.global.vue.d.ts +2 -2
  31. package/dist/runtime/components/KTreePicker/KTreePicker.global.d.vue.ts +5 -5
  32. package/dist/runtime/components/KTreePicker/KTreePicker.global.vue.d.ts +5 -5
  33. package/dist/runtime/components/KTreeView/KTreeView.global.d.vue.ts +3 -3
  34. package/dist/runtime/components/KTreeView/KTreeView.global.vue.d.ts +3 -3
  35. package/dist/runtime/plugins/PresetPlugin.js +13 -2
  36. package/dist/runtime/presets/default/components/KLayout/KLayout.d.vue.ts +3 -0
  37. package/dist/runtime/presets/default/components/KLayout/KLayout.vue +66 -0
  38. package/dist/runtime/presets/default/components/KLayout/KLayout.vue.d.ts +3 -0
  39. package/dist/runtime/presets/default/components/KTree/KTree.d.vue.ts +1 -1
  40. package/dist/runtime/presets/default/components/KTree/KTree.vue.d.ts +1 -1
  41. package/dist/runtime/utils/PresetResolver.js +10 -0
  42. package/package.json +1 -1
@@ -22,6 +22,9 @@ export class PresetResolver {
22
22
  } catch {
23
23
  this.activePreset = presetCookie.value;
24
24
  }
25
+ if (appConfig.katluxToolkit) {
26
+ appConfig.katluxToolkit.activePreset = this.activePreset;
27
+ }
25
28
  } else if (appConfig.katluxToolkit?.activePreset) {
26
29
  this.activePreset = appConfig.katluxToolkit.activePreset;
27
30
  }
@@ -76,6 +79,13 @@ export class PresetResolver {
76
79
  if (JSON.stringify(this.activePreset) !== JSON.stringify(presetName)) {
77
80
  this.activePreset = presetName;
78
81
  this.clearCache();
82
+ try {
83
+ const appConfig = useAppConfig();
84
+ if (appConfig?.katluxToolkit) {
85
+ appConfig.katluxToolkit.activePreset = presetName;
86
+ }
87
+ } catch {
88
+ }
79
89
  try {
80
90
  const activePresetState = useState("katlux-active-preset-state");
81
91
  activePresetState.value = presetName;
@@ -0,0 +1,68 @@
1
+ import { describe, it, expect, beforeEach, vi } from "vitest";
2
+ import * as appMock from "#app";
3
+ import { PresetResolver } from "./PresetResolver.mjs";
4
+ describe("PresetResolver Unit Tests", () => {
5
+ beforeEach(() => {
6
+ vi.restoreAllMocks();
7
+ });
8
+ it("initializes from appConfig when no cookie is set", () => {
9
+ vi.spyOn(appMock, "useCookie").mockReturnValue({ value: "" });
10
+ vi.spyOn(appMock, "useAppConfig").mockReturnValue({
11
+ katluxToolkit: {
12
+ activePreset: "default"
13
+ }
14
+ });
15
+ const resolver = new PresetResolver();
16
+ expect(resolver.getActivePreset()).toBe("default");
17
+ });
18
+ it("initializes from cookie and synchronizes appConfig when cookie is present", () => {
19
+ const appConfigObj = {
20
+ katluxToolkit: {
21
+ activePreset: "default"
22
+ }
23
+ };
24
+ vi.spyOn(appMock, "useCookie").mockReturnValue({ value: "modern" });
25
+ vi.spyOn(appMock, "useAppConfig").mockReturnValue(appConfigObj);
26
+ const resolver = new PresetResolver();
27
+ expect(resolver.getActivePreset()).toBe("modern");
28
+ expect(appConfigObj.katluxToolkit.activePreset).toBe("modern");
29
+ });
30
+ it("parses JSON stringified array preset from cookie", () => {
31
+ const appConfigObj = {
32
+ katluxToolkit: {
33
+ activePreset: "default"
34
+ }
35
+ };
36
+ vi.spyOn(appMock, "useCookie").mockReturnValue({ value: JSON.stringify(["dark", "modern"]) });
37
+ vi.spyOn(appMock, "useAppConfig").mockReturnValue(appConfigObj);
38
+ const resolver = new PresetResolver();
39
+ expect(resolver.getActivePreset()).toEqual(["dark", "modern"]);
40
+ expect(appConfigObj.katluxToolkit.activePreset).toEqual(["dark", "modern"]);
41
+ });
42
+ it("setActivePreset updates state, cookie, appConfig, and invalidates cache", () => {
43
+ const appConfigObj = {
44
+ katluxToolkit: {
45
+ activePreset: "default"
46
+ }
47
+ };
48
+ const cookieObj = { value: "default" };
49
+ const stateObj = { value: "default" };
50
+ vi.spyOn(appMock, "useCookie").mockReturnValue(cookieObj);
51
+ vi.spyOn(appMock, "useAppConfig").mockReturnValue(appConfigObj);
52
+ vi.spyOn(appMock, "useState").mockReturnValue(stateObj);
53
+ const resolver = new PresetResolver();
54
+ expect(resolver.getActivePreset()).toBe("default");
55
+ const meta1 = resolver.resolvePreset("KButton");
56
+ expect(meta1.hasCustomPreset).toBe(false);
57
+ expect(resolver.getCachedPresets()["default:KButton"]).toBeDefined();
58
+ resolver.setActivePreset("modern");
59
+ expect(resolver.getActivePreset()).toBe("modern");
60
+ expect(appConfigObj.katluxToolkit.activePreset).toBe("modern");
61
+ expect(stateObj.value).toBe("modern");
62
+ expect(cookieObj.value).toBe("modern");
63
+ expect(resolver.getCachedPresets()["default:KButton"]).toBeUndefined();
64
+ const meta2 = resolver.resolvePreset("KButton");
65
+ expect(meta2.hasCustomPreset).toBe(true);
66
+ expect(meta2.presetPath).toBe("~/presets/modern/KButton.pug");
67
+ });
68
+ });
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.113",
4
+ "version": "0.1.1-alpha.115",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -56,10 +56,10 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
56
56
  }>, {
57
57
  size: "small" | "large" | "medium" | undefined;
58
58
  type: "default" | "info" | "success" | "warning" | "danger" | "primary" | "light" | "dark" | undefined;
59
+ loading: boolean;
59
60
  iconOnly: boolean;
60
61
  disabled: boolean;
61
62
  href: string;
62
- loading: boolean;
63
63
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
64
64
  declare const _default: typeof __VLS_export;
65
65
  export default _default;
@@ -56,10 +56,10 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
56
56
  }>, {
57
57
  size: "small" | "large" | "medium" | undefined;
58
58
  type: "default" | "info" | "success" | "warning" | "danger" | "primary" | "light" | "dark" | undefined;
59
+ loading: boolean;
59
60
  iconOnly: boolean;
60
61
  disabled: boolean;
61
62
  href: string;
62
- loading: boolean;
63
63
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
64
64
  declare const _default: typeof __VLS_export;
65
65
  export default _default;
@@ -54,11 +54,11 @@ 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
60
  validation: "error" | "success" | "warning" | null | undefined;
60
61
  validationText: string;
61
- value: any;
62
62
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
63
63
  declare const _default: typeof __VLS_export;
64
64
  export default _default;
@@ -54,11 +54,11 @@ 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
60
  validation: "error" | "success" | "warning" | null | undefined;
60
61
  validationText: string;
61
- value: any;
62
62
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
63
63
  declare const _default: typeof __VLS_export;
64
64
  export default _default;
@@ -183,20 +183,20 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
183
183
  validation: "error" | "success" | "warning" | null | undefined;
184
184
  validationText: string;
185
185
  modelValue: any;
186
+ valueField: string;
187
+ placeholder: string;
186
188
  searchbox: boolean;
189
+ teleportTo: string;
187
190
  searchPlaceholder: string;
188
191
  virtualScroll: boolean;
189
192
  itemHeight: number;
190
193
  buffer: number;
191
194
  isOptionsOpen: boolean;
192
- placeholder: string;
193
- teleportTo: string;
194
195
  fullWidth: boolean;
195
196
  closeOnSelect: boolean;
196
197
  multiSelect: boolean;
197
198
  maxSelectedDisplay: string | number | boolean;
198
199
  visibleFields: String[];
199
- valueField: string;
200
200
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
201
201
  declare const _default: typeof __VLS_export;
202
202
  export default _default;
@@ -183,20 +183,20 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
183
183
  validation: "error" | "success" | "warning" | null | undefined;
184
184
  validationText: string;
185
185
  modelValue: any;
186
+ valueField: string;
187
+ placeholder: string;
186
188
  searchbox: boolean;
189
+ teleportTo: string;
187
190
  searchPlaceholder: string;
188
191
  virtualScroll: boolean;
189
192
  itemHeight: number;
190
193
  buffer: number;
191
194
  isOptionsOpen: boolean;
192
- placeholder: string;
193
- teleportTo: string;
194
195
  fullWidth: boolean;
195
196
  closeOnSelect: boolean;
196
197
  multiSelect: boolean;
197
198
  maxSelectedDisplay: string | number | boolean;
198
199
  visibleFields: String[];
199
- valueField: string;
200
200
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
201
201
  declare const _default: typeof __VLS_export;
202
202
  export default _default;
@@ -193,18 +193,18 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
193
193
  validation: "error" | "success" | "warning" | null | undefined;
194
194
  validationText: string;
195
195
  modelValue: import("./KCompositeInput.logic.js").ICompositeItem[];
196
- searchbox: boolean;
197
- labelField: string;
198
- placeholder: string;
199
- teleportTo: string;
200
- mask: string;
201
- valueField: string;
202
196
  inputType: "number" | "url" | "search" | "text" | "password" | "email" | "tel" | undefined;
203
197
  selectionValue: string | number | Record<string, any> | unknown[];
204
198
  inputValue: string | number | Record<string, any> | unknown[];
205
199
  selectionSide: import("./KCompositeInput.logic.js").SelectionSide;
200
+ mask: string;
201
+ labelField: string;
202
+ valueField: string;
203
+ placeholder: string;
206
204
  inputPlaceholder: string;
205
+ searchbox: boolean;
207
206
  showClear: boolean;
207
+ teleportTo: string;
208
208
  inputConfigField: string;
209
209
  validateAll: boolean;
210
210
  inputFormat: string;
@@ -193,18 +193,18 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
193
193
  validation: "error" | "success" | "warning" | null | undefined;
194
194
  validationText: string;
195
195
  modelValue: import("./KCompositeInput.logic.js").ICompositeItem[];
196
- searchbox: boolean;
197
- labelField: string;
198
- placeholder: string;
199
- teleportTo: string;
200
- mask: string;
201
- valueField: string;
202
196
  inputType: "number" | "url" | "search" | "text" | "password" | "email" | "tel" | undefined;
203
197
  selectionValue: string | number | Record<string, any> | unknown[];
204
198
  inputValue: string | number | Record<string, any> | unknown[];
205
199
  selectionSide: import("./KCompositeInput.logic.js").SelectionSide;
200
+ mask: string;
201
+ labelField: string;
202
+ valueField: string;
203
+ placeholder: string;
206
204
  inputPlaceholder: string;
205
+ searchbox: boolean;
207
206
  showClear: boolean;
207
+ teleportTo: string;
208
208
  inputConfigField: string;
209
209
  validateAll: boolean;
210
210
  inputFormat: string;
@@ -46,8 +46,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
46
46
  "onUpdate:isOpen"?: ((value: boolean) => any) | undefined;
47
47
  }>, {
48
48
  isOpen: boolean;
49
- teleportTo: string;
50
49
  x: number;
50
+ teleportTo: string;
51
51
  y: number;
52
52
  target: string | HTMLElement;
53
53
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
@@ -46,8 +46,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
46
46
  "onUpdate:isOpen"?: ((value: boolean) => any) | undefined;
47
47
  }>, {
48
48
  isOpen: boolean;
49
- teleportTo: string;
50
49
  x: number;
50
+ teleportTo: string;
51
51
  y: number;
52
52
  target: string | HTMLElement;
53
53
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
@@ -12,8 +12,8 @@ interface Props {
12
12
  }
13
13
  declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {
14
14
  search: string;
15
- bulkActions: IKDatatableAction[];
16
15
  loading: boolean;
16
+ bulkActions: IKDatatableAction[];
17
17
  visibleFields: Array<string> | null;
18
18
  rowActions: IKDatatableAction[];
19
19
  itemsPerPage: number;
@@ -12,8 +12,8 @@ interface Props {
12
12
  }
13
13
  declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {
14
14
  search: string;
15
- bulkActions: IKDatatableAction[];
16
15
  loading: boolean;
16
+ bulkActions: IKDatatableAction[];
17
17
  visibleFields: Array<string> | null;
18
18
  rowActions: IKDatatableAction[];
19
19
  itemsPerPage: number;
@@ -122,15 +122,15 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
122
122
  }>, {
123
123
  isOpen: boolean;
124
124
  label: string;
125
- definedDays: import("../KCalendar/types.js").IDefinedDay[];
126
- markedDays: import("../KCalendar/types.js").IMarkedDay[];
127
- day: string | Date;
128
125
  validation: "error" | "success" | "warning" | null | undefined;
129
126
  validationText: string;
130
127
  modelValue: string | Date;
128
+ definedDays: import("../KCalendar/types.js").IDefinedDay[];
129
+ markedDays: import("../KCalendar/types.js").IMarkedDay[];
130
+ day: string | Date;
131
131
  placeholder: string;
132
- teleportTo: string;
133
132
  showClear: boolean;
133
+ teleportTo: string;
134
134
  align: "left" | "right" | undefined;
135
135
  format: string;
136
136
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
@@ -122,15 +122,15 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
122
122
  }>, {
123
123
  isOpen: boolean;
124
124
  label: string;
125
- definedDays: import("../KCalendar/types.js").IDefinedDay[];
126
- markedDays: import("../KCalendar/types.js").IMarkedDay[];
127
- day: string | Date;
128
125
  validation: "error" | "success" | "warning" | null | undefined;
129
126
  validationText: string;
130
127
  modelValue: string | Date;
128
+ definedDays: import("../KCalendar/types.js").IDefinedDay[];
129
+ markedDays: import("../KCalendar/types.js").IMarkedDay[];
130
+ day: string | Date;
131
131
  placeholder: string;
132
- teleportTo: string;
133
132
  showClear: boolean;
133
+ teleportTo: string;
134
134
  align: "left" | "right" | undefined;
135
135
  format: string;
136
136
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
@@ -128,15 +128,15 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
128
128
  }>, {
129
129
  isOpen: boolean;
130
130
  label: string;
131
- definedDays: import("../KCalendar/types.js").IDefinedDay[];
132
- markedDays: import("../KCalendar/types.js").IMarkedDay[];
133
- day: string | Date;
134
131
  validation: "error" | "success" | "warning" | null | undefined;
135
132
  validationText: string;
136
133
  modelValue: string | Date;
134
+ definedDays: import("../KCalendar/types.js").IDefinedDay[];
135
+ markedDays: import("../KCalendar/types.js").IMarkedDay[];
136
+ day: string | Date;
137
137
  placeholder: string;
138
- teleportTo: string;
139
138
  showClear: boolean;
139
+ teleportTo: string;
140
140
  format: string;
141
141
  timeFormat: string;
142
142
  timeStep: number;
@@ -128,15 +128,15 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
128
128
  }>, {
129
129
  isOpen: boolean;
130
130
  label: string;
131
- definedDays: import("../KCalendar/types.js").IDefinedDay[];
132
- markedDays: import("../KCalendar/types.js").IMarkedDay[];
133
- day: string | Date;
134
131
  validation: "error" | "success" | "warning" | null | undefined;
135
132
  validationText: string;
136
133
  modelValue: string | Date;
134
+ definedDays: import("../KCalendar/types.js").IDefinedDay[];
135
+ markedDays: import("../KCalendar/types.js").IMarkedDay[];
136
+ day: string | Date;
137
137
  placeholder: string;
138
- teleportTo: string;
139
138
  showClear: boolean;
139
+ teleportTo: string;
140
140
  format: string;
141
141
  timeFormat: string;
142
142
  timeStep: number;
@@ -54,11 +54,11 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
54
54
  "onUpdate:isOpen"?: ((value: boolean) => any) | undefined;
55
55
  }>, {
56
56
  isOpen: boolean;
57
- direction: import("./KDropdown.logic.js").KDropdownDirection;
58
57
  teleportTo: string;
58
+ direction: import("./KDropdown.logic.js").KDropdownDirection;
59
59
  fullWidth: boolean;
60
- align: import("./KDropdown.logic.js").KDropdownAlign;
61
60
  anchorEl: HTMLElement;
61
+ align: import("./KDropdown.logic.js").KDropdownAlign;
62
62
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
63
63
  declare const _default: typeof __VLS_export;
64
64
  export default _default;
@@ -54,11 +54,11 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
54
54
  "onUpdate:isOpen"?: ((value: boolean) => any) | undefined;
55
55
  }>, {
56
56
  isOpen: boolean;
57
- direction: import("./KDropdown.logic.js").KDropdownDirection;
58
57
  teleportTo: string;
58
+ direction: import("./KDropdown.logic.js").KDropdownDirection;
59
59
  fullWidth: boolean;
60
- align: import("./KDropdown.logic.js").KDropdownAlign;
61
60
  anchorEl: HTMLElement;
61
+ align: import("./KDropdown.logic.js").KDropdownAlign;
62
62
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
63
63
  declare const _default: typeof __VLS_export;
64
64
  export default _default;
@@ -0,0 +1,3 @@
1
+ declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
+ declare const _default: typeof __VLS_export;
3
+ export default _default;
@@ -0,0 +1,11 @@
1
+ <script setup>
2
+ import { usePresetComponent } from "../../composables/usePresetComponent";
3
+ import KLayoutDefault from "../../presets/default/components/KLayout/KLayout.vue";
4
+ const presetComponent = usePresetComponent("KLayout", KLayoutDefault);
5
+ </script>
6
+
7
+ <template lang="pug">
8
+ component(:is="presetComponent" v-bind="$attrs")
9
+ template(v-for="(_, slot) in $slots" #[slot]="scope")
10
+ slot(:name="slot" v-bind="scope")
11
+ </template>
@@ -0,0 +1,3 @@
1
+ declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
+ declare const _default: typeof __VLS_export;
3
+ export default _default;
@@ -53,9 +53,9 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
53
53
  }>> & Readonly<{
54
54
  "onUpdate:value"?: ((value: any) => any) | undefined;
55
55
  }>, {
56
+ value: number;
56
57
  label: string;
57
58
  disabled: boolean;
58
- value: number;
59
59
  step: number;
60
60
  min: number;
61
61
  max: number;
@@ -53,9 +53,9 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
53
53
  }>> & Readonly<{
54
54
  "onUpdate:value"?: ((value: any) => any) | undefined;
55
55
  }>, {
56
+ value: number;
56
57
  label: string;
57
58
  disabled: boolean;
58
- value: number;
59
59
  step: number;
60
60
  min: number;
61
61
  max: number;
@@ -57,10 +57,10 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
57
57
  "onUpdate:modelValue"?: ((value: string) => any) | undefined;
58
58
  }>, {
59
59
  label: string;
60
+ rows: number;
60
61
  validation: "error" | "success" | "warning" | null | undefined;
61
62
  validationText: string;
62
63
  placeholder: string;
63
- rows: number;
64
64
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
65
65
  declare const _default: typeof __VLS_export;
66
66
  export default _default;
@@ -57,10 +57,10 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
57
57
  "onUpdate:modelValue"?: ((value: string) => any) | undefined;
58
58
  }>, {
59
59
  label: string;
60
+ rows: number;
60
61
  validation: "error" | "success" | "warning" | null | undefined;
61
62
  validationText: string;
62
63
  placeholder: string;
63
- rows: number;
64
64
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
65
65
  declare const _default: typeof __VLS_export;
66
66
  export default _default;
@@ -73,12 +73,12 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
73
73
  default: string;
74
74
  };
75
75
  }>> & Readonly<{}>, {
76
+ idKey: string;
76
77
  disabled: boolean;
77
- searchtext: string;
78
78
  labelField: string;
79
+ searchtext: string;
79
80
  multiSelect: boolean;
80
81
  iconField: string;
81
- idKey: string;
82
82
  isNodeSelected: (node: any) => boolean;
83
83
  selectable: boolean;
84
84
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
@@ -73,12 +73,12 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
73
73
  default: string;
74
74
  };
75
75
  }>> & Readonly<{}>, {
76
+ idKey: string;
76
77
  disabled: boolean;
77
- searchtext: string;
78
78
  labelField: string;
79
+ searchtext: string;
79
80
  multiSelect: boolean;
80
81
  iconField: string;
81
- idKey: string;
82
82
  isNodeSelected: (node: any) => boolean;
83
83
  selectable: boolean;
84
84
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
@@ -164,23 +164,23 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
164
164
  "onUpdate:modelValue"?: ((value: any) => any) | undefined;
165
165
  "onUpdate:isOptionsOpen"?: ((value: boolean) => any) | undefined;
166
166
  }>, {
167
+ parentKey: string;
168
+ loading: boolean;
169
+ idKey: string;
167
170
  label: string;
168
171
  disabled: boolean;
169
- loading: boolean;
170
172
  validation: "error" | "success" | "warning" | null | undefined;
171
173
  validationText: string;
172
174
  modelValue: any;
175
+ valueField: string;
176
+ placeholder: string;
173
177
  searchbox: boolean;
174
178
  searchPlaceholder: string;
175
179
  isOptionsOpen: boolean;
176
- placeholder: string;
177
180
  fullWidth: boolean;
178
181
  closeOnSelect: boolean;
179
182
  multiSelect: boolean;
180
- valueField: string;
181
- parentKey: string;
182
183
  iconField: string;
183
- idKey: string;
184
184
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
185
185
  declare const _default: typeof __VLS_export;
186
186
  export default _default;
@@ -164,23 +164,23 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
164
164
  "onUpdate:modelValue"?: ((value: any) => any) | undefined;
165
165
  "onUpdate:isOptionsOpen"?: ((value: boolean) => any) | undefined;
166
166
  }>, {
167
+ parentKey: string;
168
+ loading: boolean;
169
+ idKey: string;
167
170
  label: string;
168
171
  disabled: boolean;
169
- loading: boolean;
170
172
  validation: "error" | "success" | "warning" | null | undefined;
171
173
  validationText: string;
172
174
  modelValue: any;
175
+ valueField: string;
176
+ placeholder: string;
173
177
  searchbox: boolean;
174
178
  searchPlaceholder: string;
175
179
  isOptionsOpen: boolean;
176
- placeholder: string;
177
180
  fullWidth: boolean;
178
181
  closeOnSelect: boolean;
179
182
  multiSelect: boolean;
180
- valueField: string;
181
- parentKey: string;
182
183
  iconField: string;
183
- idKey: string;
184
184
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
185
185
  declare const _default: typeof __VLS_export;
186
186
  export default _default;
@@ -103,16 +103,16 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
103
103
  "onUpdate:selectedRows"?: ((value: any[]) => any) | undefined;
104
104
  "onUpdate:selectAll"?: ((value: boolean) => any) | undefined;
105
105
  }>, {
106
+ parentKey: string;
107
+ idKey: string;
108
+ expandedByDefault: boolean;
106
109
  bulkActions: import("@katlux/providers").IKDatatableAction[];
107
110
  selectedRows: any[];
108
111
  selectAll: boolean;
109
112
  rowActions: import("@katlux/providers").IKDatatableAction[];
110
113
  cellSlots: Record<string, any>;
111
114
  headerSlots: Record<string, any>;
112
- parentKey: string;
113
- expandedByDefault: boolean;
114
115
  treeColumnIndex: number;
115
- idKey: string;
116
116
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
117
117
  declare const _default: typeof __VLS_export;
118
118
  export default _default;
@@ -103,16 +103,16 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
103
103
  "onUpdate:selectedRows"?: ((value: any[]) => any) | undefined;
104
104
  "onUpdate:selectAll"?: ((value: boolean) => any) | undefined;
105
105
  }>, {
106
+ parentKey: string;
107
+ idKey: string;
108
+ expandedByDefault: boolean;
106
109
  bulkActions: import("@katlux/providers").IKDatatableAction[];
107
110
  selectedRows: any[];
108
111
  selectAll: boolean;
109
112
  rowActions: import("@katlux/providers").IKDatatableAction[];
110
113
  cellSlots: Record<string, any>;
111
114
  headerSlots: Record<string, any>;
112
- parentKey: string;
113
- expandedByDefault: boolean;
114
115
  treeColumnIndex: number;
115
- idKey: string;
116
116
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
117
117
  declare const _default: typeof __VLS_export;
118
118
  export default _default;
@@ -5,6 +5,9 @@ export default defineNuxtPlugin((nuxtApp) => {
5
5
  const resolver = new PresetResolver();
6
6
  const appConfig = useAppConfig();
7
7
  const activePresetState = useState("katlux-active-preset-state", () => resolver.getActivePreset());
8
+ if (appConfig?.katluxToolkit && activePresetState.value) {
9
+ appConfig.katluxToolkit.activePreset = activePresetState.value;
10
+ }
8
11
  const resolvePresetString = (val) => Array.isArray(val) ? val[0] ?? "default" : val;
9
12
  const currentPreset = ref(resolvePresetString(activePresetState.value));
10
13
  useHead({
@@ -15,13 +18,21 @@ export default defineNuxtPlugin((nuxtApp) => {
15
18
  watch(activePresetState, (newPreset) => {
16
19
  if (newPreset) {
17
20
  currentPreset.value = resolvePresetString(newPreset);
21
+ if (appConfig?.katluxToolkit && JSON.stringify(appConfig.katluxToolkit.activePreset) !== JSON.stringify(newPreset)) {
22
+ appConfig.katluxToolkit.activePreset = newPreset;
23
+ }
24
+ nuxtApp.runWithContext(() => {
25
+ resolver.setActivePreset(newPreset);
26
+ });
18
27
  }
19
28
  });
20
- if (appConfig.katluxToolkit) {
29
+ if (appConfig?.katluxToolkit) {
21
30
  watch(() => appConfig.katluxToolkit?.activePreset, (newPreset) => {
22
31
  if (newPreset) {
23
32
  currentPreset.value = resolvePresetString(newPreset);
24
- activePresetState.value = newPreset;
33
+ if (JSON.stringify(activePresetState.value) !== JSON.stringify(newPreset)) {
34
+ activePresetState.value = newPreset;
35
+ }
25
36
  nuxtApp.runWithContext(() => {
26
37
  resolver.setActivePreset(newPreset);
27
38
  });
@@ -0,0 +1,3 @@
1
+ declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
+ declare const _default: typeof __VLS_export;
3
+ export default _default;
@@ -0,0 +1,66 @@
1
+ <template lang="pug">
2
+ .KLayout(:class="{ 'has-aside': Boolean($slots.aside) }")
3
+ header.KLayout__header(v-if="$slots.header")
4
+ slot(name="header")
5
+ aside.KLayout__aside(v-if="$slots.aside")
6
+ slot(name="aside")
7
+ main.KLayout__main
8
+ slot(name="main")
9
+ slot
10
+ footer.KLayout__footer(v-if="$slots.footer")
11
+ slot(name="footer")
12
+ </template>
13
+
14
+ <script lang="ts" setup>
15
+ // Default preset component for KLayout
16
+ </script>
17
+
18
+ <style lang="scss" scoped>
19
+ .KLayout {
20
+ display: grid;
21
+ min-height: 100vh;
22
+ grid-template-rows: auto 1fr auto;
23
+ grid-template-columns: 1fr;
24
+ grid-template-areas:
25
+ "header"
26
+ "main"
27
+ "footer";
28
+ background-color: var(--layout-content-bg, #f8fafc);
29
+ color: var(--text-color, inherit);
30
+ box-sizing: border-box;
31
+
32
+ &.has-aside {
33
+ grid-template-columns: var(--layout-sidebar-width, 240px) 1fr;
34
+ grid-template-areas:
35
+ "header header"
36
+ "aside main"
37
+ "footer footer";
38
+ }
39
+
40
+ &__header {
41
+ grid-area: header;
42
+ position: sticky;
43
+ top: 0;
44
+ z-index: 100;
45
+ background-color: var(--layout-header-bg, #ffffff);
46
+ }
47
+
48
+ &__aside {
49
+ grid-area: aside;
50
+ background-color: var(--layout-sidebar-bg, #ffffff);
51
+ overflow-y: auto;
52
+ box-sizing: border-box;
53
+ }
54
+
55
+ &__main {
56
+ grid-area: main;
57
+ min-width: 0;
58
+ overflow-y: auto;
59
+ box-sizing: border-box;
60
+ }
61
+
62
+ &__footer {
63
+ grid-area: footer;
64
+ }
65
+ }
66
+ </style>
@@ -0,0 +1,3 @@
1
+ declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
+ declare const _default: typeof __VLS_export;
3
+ export default _default;
@@ -21,11 +21,11 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
21
21
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
22
22
  onSelect?: ((row: TTreeRow) => any) | undefined;
23
23
  }>, {
24
+ idKey: string;
24
25
  disabled: boolean;
25
26
  labelField: string;
26
27
  multiSelect: boolean;
27
28
  iconField: string;
28
- idKey: string;
29
29
  isNodeSelected: (node: any) => boolean;
30
30
  selectable: boolean;
31
31
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -21,11 +21,11 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
21
21
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
22
22
  onSelect?: ((row: TTreeRow) => any) | undefined;
23
23
  }>, {
24
+ idKey: string;
24
25
  disabled: boolean;
25
26
  labelField: string;
26
27
  multiSelect: boolean;
27
28
  iconField: string;
28
- idKey: string;
29
29
  isNodeSelected: (node: any) => boolean;
30
30
  selectable: boolean;
31
31
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -22,6 +22,9 @@ export class PresetResolver {
22
22
  } catch {
23
23
  this.activePreset = presetCookie.value;
24
24
  }
25
+ if (appConfig.katluxToolkit) {
26
+ appConfig.katluxToolkit.activePreset = this.activePreset;
27
+ }
25
28
  } else if (appConfig.katluxToolkit?.activePreset) {
26
29
  this.activePreset = appConfig.katluxToolkit.activePreset;
27
30
  }
@@ -76,6 +79,13 @@ export class PresetResolver {
76
79
  if (JSON.stringify(this.activePreset) !== JSON.stringify(presetName)) {
77
80
  this.activePreset = presetName;
78
81
  this.clearCache();
82
+ try {
83
+ const appConfig = useAppConfig();
84
+ if (appConfig?.katluxToolkit) {
85
+ appConfig.katluxToolkit.activePreset = presetName;
86
+ }
87
+ } catch {
88
+ }
79
89
  try {
80
90
  const activePresetState = useState("katlux-active-preset-state");
81
91
  activePresetState.value = presetName;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@katlux/toolkit",
3
- "version": "0.1.1-alpha.113",
3
+ "version": "0.1.1-alpha.115",
4
4
  "description": "Core UI toolkit and utilities for the Katlux ecosystem",
5
5
  "author": "Katlux",
6
6
  "license": "Apache-2.0",