@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.
- package/dist/compiled/composables/usePresetComponent.mjs +6 -12
- package/dist/module.json +1 -1
- package/dist/runtime/components/KCompositeInput/KCompositeInput.global.d.vue.ts +2 -2
- package/dist/runtime/components/KCompositeInput/KCompositeInput.global.vue.d.ts +2 -2
- package/dist/runtime/components/KDatePicker/KDatePicker.global.d.vue.ts +1 -1
- package/dist/runtime/components/KDatePicker/KDatePicker.global.vue.d.ts +1 -1
- package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.d.vue.ts +1 -1
- package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.vue.d.ts +1 -1
- package/dist/runtime/components/KHourPicker/KHourPicker.global.d.vue.ts +1 -1
- package/dist/runtime/components/KHourPicker/KHourPicker.global.vue.d.ts +1 -1
- package/dist/runtime/components/KTooltip/KTooltip.global.d.vue.ts +1 -1
- package/dist/runtime/components/KTooltip/KTooltip.global.vue.d.ts +1 -1
- package/dist/runtime/composables/usePresetComponent.d.ts +3 -9
- package/dist/runtime/composables/usePresetComponent.js +6 -12
- package/dist/runtime/plugins/PresetPlugin.js +11 -12
- package/package.json +1 -1
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
import { computed, defineAsyncComponent } from "vue";
|
|
2
|
-
import { useAppConfig
|
|
3
|
-
|
|
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
|
-
|
|
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 =
|
|
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
|
@@ -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: "
|
|
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: "
|
|
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
|
-
*
|
|
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
|
|
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
|
|
3
|
-
|
|
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
|
-
|
|
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 =
|
|
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
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
18
|
+
currentPreset.value = resolvePresetString(newPreset);
|
|
20
19
|
resolver.setActivePreset(newPreset);
|
|
21
20
|
}
|
|
22
21
|
});
|