@katlux/toolkit 0.1.1-alpha.92 → 0.1.1-alpha.93

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.
@@ -1,15 +1,11 @@
1
- import { computed, defineAsyncComponent } from "vue";
2
- import { useAppConfig, useState } from "#app";
3
- export function usePresetLoadersRegistry() {
4
- return useState("katlux-preset-loaders-registry", () => ({}));
5
- }
1
+ import { computed, defineAsyncComponent, shallowReactive } from "vue";
2
+ import { useAppConfig } from "#app";
3
+ const _loadersRegistry = shallowReactive({});
6
4
  export function registerPresetComponents(presetName, loaders) {
7
- const registry = usePresetLoadersRegistry();
8
- registry.value[presetName] = loaders;
5
+ _loadersRegistry[presetName] = loaders;
9
6
  }
10
7
  export function usePresetComponent(componentBaseName, defaultComponent) {
11
8
  const appConfig = useAppConfig();
12
- const registry = usePresetLoadersRegistry();
13
9
  const presetStack = computed(() => {
14
10
  const raw = appConfig.katluxToolkit?.activePreset;
15
11
  const list = Array.isArray(raw) ? raw : raw ? [raw] : [];
@@ -19,7 +15,7 @@ export function usePresetComponent(componentBaseName, defaultComponent) {
19
15
  let loader;
20
16
  for (const presetName of presetStack.value) {
21
17
  if (presetName === "default") break;
22
- const externalLoaders = registry.value[presetName];
18
+ const externalLoaders = _loadersRegistry[presetName];
23
19
  if (externalLoaders) {
24
20
  const key = `./components/${componentBaseName}/${componentBaseName}.vue`;
25
21
  loader = externalLoaders[key];
@@ -47,9 +43,7 @@ export function usePresetComponent(componentBaseName, defaultComponent) {
47
43
  if (loader) break;
48
44
  }
49
45
  }
50
- if (loader) {
51
- break;
52
- }
46
+ if (loader) break;
53
47
  }
54
48
  if (!loader) {
55
49
  return defaultComponent;
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.92",
4
+ "version": "0.1.1-alpha.93",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -198,13 +198,13 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
198
198
  placeholder: string;
199
199
  teleportTo: string;
200
200
  valueField: string;
201
- mask: string;
202
- showClear: boolean;
203
201
  inputType: "number" | "text" | "url" | "search" | "password" | "email" | "tel" | undefined;
204
202
  selectionValue: string | number | Record<string, any> | unknown[];
205
203
  inputValue: string | number | Record<string, any> | unknown[];
206
204
  selectionSide: import("./KCompositeInput.logic.js").SelectionSide;
205
+ mask: string;
207
206
  inputPlaceholder: string;
207
+ showClear: boolean;
208
208
  inputConfigField: string;
209
209
  validateAll: boolean;
210
210
  inputFormat: string;
@@ -198,13 +198,13 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
198
198
  placeholder: string;
199
199
  teleportTo: string;
200
200
  valueField: string;
201
- mask: string;
202
- showClear: boolean;
203
201
  inputType: "number" | "text" | "url" | "search" | "password" | "email" | "tel" | undefined;
204
202
  selectionValue: string | number | Record<string, any> | unknown[];
205
203
  inputValue: string | number | Record<string, any> | unknown[];
206
204
  selectionSide: import("./KCompositeInput.logic.js").SelectionSide;
205
+ mask: string;
207
206
  inputPlaceholder: string;
207
+ showClear: boolean;
208
208
  inputConfigField: string;
209
209
  validateAll: boolean;
210
210
  inputFormat: string;
@@ -128,9 +128,9 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
128
128
  modelValue: string | Date;
129
129
  placeholder: string;
130
130
  teleportTo: string;
131
+ showClear: boolean;
131
132
  align: "left" | "right" | undefined;
132
133
  format: string;
133
- showClear: boolean;
134
134
  calendarDefinedDays: import("../KCalendar/types.js").IDefinedDay[];
135
135
  calendarMarkedDays: import("../KCalendar/types.js").IMarkedDay[];
136
136
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
@@ -128,9 +128,9 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
128
128
  modelValue: string | Date;
129
129
  placeholder: string;
130
130
  teleportTo: string;
131
+ showClear: boolean;
131
132
  align: "left" | "right" | undefined;
132
133
  format: string;
133
- showClear: boolean;
134
134
  calendarDefinedDays: import("../KCalendar/types.js").IDefinedDay[];
135
135
  calendarMarkedDays: import("../KCalendar/types.js").IMarkedDay[];
136
136
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
@@ -134,8 +134,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
134
134
  modelValue: string | Date;
135
135
  placeholder: string;
136
136
  teleportTo: string;
137
- format: string;
138
137
  showClear: boolean;
138
+ format: string;
139
139
  calendarDefinedDays: import("../KCalendar/types.js").IDefinedDay[];
140
140
  calendarMarkedDays: import("../KCalendar/types.js").IMarkedDay[];
141
141
  timeFormat: string;
@@ -134,8 +134,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
134
134
  modelValue: string | Date;
135
135
  placeholder: string;
136
136
  teleportTo: string;
137
- format: string;
138
137
  showClear: boolean;
138
+ format: string;
139
139
  calendarDefinedDays: import("../KCalendar/types.js").IDefinedDay[];
140
140
  calendarMarkedDays: import("../KCalendar/types.js").IMarkedDay[];
141
141
  timeFormat: string;
@@ -113,8 +113,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
113
113
  validationText: string;
114
114
  modelValue: string;
115
115
  placeholder: string;
116
- format: string;
117
116
  showClear: boolean;
117
+ format: string;
118
118
  step: number;
119
119
  startHour: string;
120
120
  endHour: string;
@@ -113,8 +113,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
113
113
  validationText: string;
114
114
  modelValue: string;
115
115
  placeholder: string;
116
- format: string;
117
116
  showClear: boolean;
117
+ format: string;
118
118
  step: number;
119
119
  startHour: string;
120
120
  endHour: string;
@@ -27,7 +27,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
27
27
  }>> & Readonly<{}>, {
28
28
  text: string;
29
29
  disabled: boolean;
30
- position: "top" | "left" | "right" | "bottom";
30
+ position: "left" | "right" | "top" | "bottom";
31
31
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
32
32
  declare const _default: typeof __VLS_export;
33
33
  export default _default;
@@ -27,7 +27,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
27
27
  }>> & Readonly<{}>, {
28
28
  text: string;
29
29
  disabled: boolean;
30
- position: "top" | "left" | "right" | "bottom";
30
+ position: "left" | "right" | "top" | "bottom";
31
31
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
32
32
  declare const _default: typeof __VLS_export;
33
33
  export default _default;
@@ -1,19 +1,13 @@
1
1
  import { type Component } from 'vue';
2
2
  /**
3
- * Registry mapping preset names to their respective module loaders (via import.meta.glob).
4
- * Preset modules inject their components via a Nuxt Plugin.
5
- * Uses Nuxt useState to prevent cross-request SSR state leakage.
6
- */
7
- export declare function usePresetLoadersRegistry(): import("vue").Ref<Record<string, Record<string, () => Promise<any>>>, Record<string, Record<string, () => Promise<any>>>>;
8
- /**
9
- * API for Nuxt modules to dynamically map their generated components
3
+ * API for Nuxt preset plugins to register their component loaders.
10
4
  */
11
5
  export declare function registerPresetComponents(presetName: string, loaders: Record<string, () => Promise<any>>): void;
12
6
  /**
13
- * Composable for dynamically loading preset components across a cascade of active presets
7
+ * Composable for dynamically loading preset components across a cascade of active presets.
14
8
  *
15
9
  * @param componentBaseName - Base name of the component (e.g., 'KButton')
16
10
  * @param defaultComponent - The default preset component to fall back to
17
- * @returns The resolved Async Component
11
+ * @returns A computed ref resolving to the correct Component for the active preset stack
18
12
  */
19
13
  export declare function usePresetComponent(componentBaseName: string, defaultComponent: Component): import("vue").ComputedRef<any>;
@@ -1,15 +1,11 @@
1
- import { computed, defineAsyncComponent } from "vue";
2
- import { useAppConfig, useState } from "#app";
3
- export function usePresetLoadersRegistry() {
4
- return useState("katlux-preset-loaders-registry", () => ({}));
5
- }
1
+ import { computed, defineAsyncComponent, shallowReactive } from "vue";
2
+ import { useAppConfig } from "#app";
3
+ const _loadersRegistry = shallowReactive({});
6
4
  export function registerPresetComponents(presetName, loaders) {
7
- const registry = usePresetLoadersRegistry();
8
- registry.value[presetName] = loaders;
5
+ _loadersRegistry[presetName] = loaders;
9
6
  }
10
7
  export function usePresetComponent(componentBaseName, defaultComponent) {
11
8
  const appConfig = useAppConfig();
12
- const registry = usePresetLoadersRegistry();
13
9
  const presetStack = computed(() => {
14
10
  const raw = appConfig.katluxToolkit?.activePreset;
15
11
  const list = Array.isArray(raw) ? raw : raw ? [raw] : [];
@@ -19,7 +15,7 @@ export function usePresetComponent(componentBaseName, defaultComponent) {
19
15
  let loader;
20
16
  for (const presetName of presetStack.value) {
21
17
  if (presetName === "default") break;
22
- const externalLoaders = registry.value[presetName];
18
+ const externalLoaders = _loadersRegistry[presetName];
23
19
  if (externalLoaders) {
24
20
  const key = `./components/${componentBaseName}/${componentBaseName}.vue`;
25
21
  loader = externalLoaders[key];
@@ -47,9 +43,7 @@ export function usePresetComponent(componentBaseName, defaultComponent) {
47
43
  if (loader) break;
48
44
  }
49
45
  }
50
- if (loader) {
51
- break;
52
- }
46
+ if (loader) break;
53
47
  }
54
48
  if (!loader) {
55
49
  return defaultComponent;
@@ -1,22 +1,21 @@
1
- import { defineNuxtPlugin, useHead, useState } from "#app";
2
- import { watch } from "vue";
1
+ import { defineNuxtPlugin, useHead, useAppConfig, useState } from "#app";
2
+ import { ref, watch } from "vue";
3
3
  import { PresetResolver } from "../utils/PresetResolver.js";
4
4
  export default defineNuxtPlugin((nuxtApp) => {
5
5
  const resolver = new PresetResolver();
6
+ const appConfig = useAppConfig();
6
7
  const activePresetState = useState("katlux-active-preset-state", () => resolver.getActivePreset());
7
- const activePreset = activePresetState.value;
8
- const updateRootAttribute = (preset) => {
9
- useHead({
10
- htmlAttrs: {
11
- "data-template": preset
12
- }
13
- });
14
- };
15
- updateRootAttribute(activePreset);
8
+ const resolvePresetString = (val) => Array.isArray(val) ? val[0] ?? "default" : val;
9
+ const currentPreset = ref(resolvePresetString(activePresetState.value));
10
+ useHead({
11
+ htmlAttrs: {
12
+ "data-template": currentPreset
13
+ }
14
+ });
16
15
  if (appConfig.katluxToolkit) {
17
16
  watch(() => appConfig.katluxToolkit?.activePreset, (newPreset) => {
18
17
  if (newPreset) {
19
- updateRootAttribute(newPreset);
18
+ currentPreset.value = resolvePresetString(newPreset);
20
19
  resolver.setActivePreset(newPreset);
21
20
  }
22
21
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@katlux/toolkit",
3
- "version": "0.1.1-alpha.92",
3
+ "version": "0.1.1-alpha.93",
4
4
  "description": "Core UI toolkit and utilities for the Katlux ecosystem",
5
5
  "author": "Katlux",
6
6
  "license": "Apache-2.0",