@katlux/toolkit 0.1.1-alpha.100 → 0.1.1-alpha.108
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/README.md +1 -1
- package/dist/compiled/composables/useDataProvider.mjs +140 -0
- package/dist/compiled/composables/useDataProvider.spec.mjs +86 -0
- package/dist/compiled/composables/useDebounce.mjs +3 -11
- package/dist/compiled/composables/useFilterLogic.mjs +23 -169
- package/dist/compiled/composables/usePresetComponent.mjs +62 -38
- package/dist/compiled/composables/usePresetComponent.spec.mjs +106 -0
- package/dist/compiled/composables/useRequestProvider.mjs +9 -0
- package/dist/compiled/composables/useSortLogic.mjs +3 -55
- package/dist/compiled/composables/useTemplate.spec.mjs +30 -0
- package/dist/compiled/composables/useUnregisterProvider.mjs +4 -0
- package/dist/compiled/utils/PresetResolver.mjs +1 -1
- package/dist/compiled/utils/TemplateResolver.mjs +32 -0
- package/dist/module.cjs +1 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -0
- package/dist/runtime/components/KAlert/KAlert.global.d.vue.ts +2 -0
- package/dist/runtime/components/KAlert/KAlert.global.vue +3 -1
- package/dist/runtime/components/KAlert/KAlert.global.vue.d.ts +2 -0
- package/dist/runtime/components/KAlert/KAlert.logic.d.ts +4 -2
- package/dist/runtime/components/KAlert/KAlert.logic.js +12 -6
- package/dist/runtime/components/KCalendar/KCalendar.logic.js +13 -6
- package/dist/runtime/components/KCalendar/KCalendarMonth.global.d.vue.ts +13 -13
- package/dist/runtime/components/KCalendar/KCalendarMonth.global.vue.d.ts +13 -13
- package/dist/runtime/components/KCalendar/KCalendarMonth.logic.d.ts +6 -5
- package/dist/runtime/components/KCalendar/KCalendarMonth.logic.js +4 -1
- package/dist/runtime/components/KCheckbox/KCheckbox.global.d.vue.ts +1 -1
- package/dist/runtime/components/KCheckbox/KCheckbox.global.vue.d.ts +1 -1
- package/dist/runtime/components/KCombobox/KCombobox.global.d.vue.ts +3 -3
- package/dist/runtime/components/KCombobox/KCombobox.global.vue.d.ts +3 -3
- package/dist/runtime/components/KCombobox/KCombobox.logic.d.ts +2 -2
- package/dist/runtime/components/KCombobox/KCombobox.logic.js +6 -9
- package/dist/runtime/components/KCompositeInput/KCompositeInput.global.d.vue.ts +1 -1
- package/dist/runtime/components/KCompositeInput/KCompositeInput.global.vue +0 -1
- package/dist/runtime/components/KCompositeInput/KCompositeInput.global.vue.d.ts +1 -1
- package/dist/runtime/components/KDatatable/KDataIterator.logic.d.ts +2 -2
- package/dist/runtime/components/KDatatable/KDataIterator.logic.js +1 -1
- package/dist/runtime/components/KDatatable/KDatatable.logic.d.ts +4 -2
- package/dist/runtime/components/KDatatable/KDatatable.logic.js +45 -6
- package/dist/runtime/components/KDatePicker/KDatePicker.global.d.vue.ts +5 -5
- package/dist/runtime/components/KDatePicker/KDatePicker.global.vue.d.ts +5 -5
- package/dist/runtime/components/KDatePicker/KDatePicker.logic.d.ts +2 -2
- package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.d.vue.ts +5 -5
- package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.vue.d.ts +5 -5
- package/dist/runtime/components/KDateTimePicker/KDateTimePicker.logic.d.ts +2 -2
- package/dist/runtime/components/KDropdown/KDropdown.global.d.vue.ts +1 -1
- package/dist/runtime/components/KDropdown/KDropdown.global.vue.d.ts +1 -1
- package/dist/runtime/components/KGantt/KGantt.global.d.vue.ts +8 -8
- package/dist/runtime/components/KGantt/KGantt.global.vue.d.ts +8 -8
- package/dist/runtime/components/KGantt/KGantt.logic.d.ts +4 -4
- package/dist/runtime/components/KGantt/KGantt.logic.js +21 -25
- package/dist/runtime/components/KGrid/KGrid.global.d.vue.ts +1 -1
- package/dist/runtime/components/KGrid/KGrid.global.vue.d.ts +1 -1
- package/dist/runtime/components/KGrid/KGrid.logic.d.ts +1 -0
- 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/KIcon/KIcon.logic.d.ts +14 -0
- package/dist/runtime/components/KIcon/KIcon.logic.js +74 -17
- package/dist/runtime/components/KMaskTextbox/KMaskTextbox.global.d.vue.ts +1 -1
- package/dist/runtime/components/KMaskTextbox/KMaskTextbox.global.vue.d.ts +1 -1
- package/dist/runtime/components/KRadiobox/KRadiobox.global.d.vue.ts +1 -1
- package/dist/runtime/components/KRadiobox/KRadiobox.global.vue.d.ts +1 -1
- package/dist/runtime/components/KTextarea/KTextarea.global.d.vue.ts +1 -1
- package/dist/runtime/components/KTextarea/KTextarea.global.vue.d.ts +1 -1
- package/dist/runtime/components/KTextbox/KTextbox.global.d.vue.ts +1 -1
- package/dist/runtime/components/KTextbox/KTextbox.global.vue.d.ts +1 -1
- package/dist/runtime/components/KTreePicker/KTreePicker.global.d.vue.ts +1 -1
- package/dist/runtime/components/KTreePicker/KTreePicker.global.vue.d.ts +1 -1
- package/dist/runtime/components/KTreePicker/KTreePicker.logic.d.ts +1 -1
- package/dist/runtime/components/MultiTabs/MultiTabs.logic.d.ts +1 -1
- package/dist/runtime/components/MultiTabs/MultiTabs.logic.js +25 -14
- package/dist/runtime/composables/useDataProvider.d.ts +37 -0
- package/dist/runtime/composables/useDataProvider.js +140 -0
- package/dist/runtime/composables/useDebounce.d.ts +2 -6
- package/dist/runtime/composables/useDebounce.js +3 -11
- package/dist/runtime/composables/useFilterLogic.d.ts +5 -4
- package/dist/runtime/composables/useFilterLogic.js +23 -169
- package/dist/runtime/composables/usePresetComponent.d.ts +14 -3
- package/dist/runtime/composables/usePresetComponent.js +62 -38
- package/dist/runtime/composables/useRequestProvider.d.ts +23 -0
- package/dist/runtime/composables/useRequestProvider.js +9 -0
- package/dist/runtime/composables/useSortLogic.d.ts +3 -2
- package/dist/runtime/composables/useSortLogic.js +3 -55
- package/dist/runtime/composables/useTemplate.d.ts +1 -1
- package/dist/runtime/composables/useTemplate.js +1 -1
- package/dist/runtime/composables/useUnregisterProvider.d.ts +25 -0
- package/dist/runtime/composables/useUnregisterProvider.js +4 -0
- package/dist/runtime/plugins/nuxtCompatPlugin.d.ts +9 -0
- package/dist/runtime/plugins/nuxtCompatPlugin.js +11 -0
- package/dist/runtime/presets/default/assets/scss/css-variables.css +2 -0
- package/dist/runtime/presets/default/assets/scss/css-variables.scss +2 -0
- package/dist/runtime/presets/default/assets/scss/index.css +2 -0
- package/dist/runtime/presets/default/components/KAlert/KAlert.d.vue.ts +1 -1
- package/dist/runtime/presets/default/components/KAlert/KAlert.vue +16 -9
- package/dist/runtime/presets/default/components/KAlert/KAlert.vue.d.ts +1 -1
- package/dist/runtime/presets/default/components/KCalendar/KCalendarMonth.vue +1 -1
- package/dist/runtime/presets/default/components/KContextMenu/KContextMenu.vue +45 -3
- package/dist/runtime/presets/default/components/KDatatable/KDatatable.vue +22 -4
- package/dist/runtime/presets/default/components/KDropdown/KDropdown.vue +28 -2
- package/dist/runtime/presets/default/components/KGantt/KGantt.vue +11 -2
- package/dist/runtime/presets/default/components/KLoader/KLoader.vue +1 -1
- package/dist/runtime/utils/PresetResolver.js +1 -1
- package/dist/runtime/utils/TemplateResolver.d.ts +14 -0
- package/dist/runtime/utils/TemplateResolver.js +32 -0
- package/package.json +1 -1
- package/dist/runtime/components/KThree/KThree.global.d.vue.ts +0 -3
- package/dist/runtime/components/KThree/KThree.global.vue +0 -7
- package/dist/runtime/components/KThree/KThree.global.vue.d.ts +0 -3
|
@@ -1,170 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
case EDataFilterOperator.Nand:
|
|
25
|
-
return !compareAnd(rowValue, filterValue);
|
|
26
|
-
case EDataFilterOperator.Nor:
|
|
27
|
-
return !compareOr(rowValue, filterValue);
|
|
28
|
-
case EDataFilterOperator.Equal:
|
|
29
|
-
return compareEqual(rowValue, filterValue);
|
|
30
|
-
case EDataFilterOperator.NotEqual:
|
|
31
|
-
return !compareEqual(rowValue, filterValue);
|
|
32
|
-
case EDataFilterOperator.GreaterThan:
|
|
33
|
-
return compareValues(rowValue, filterValue) > 0;
|
|
34
|
-
case EDataFilterOperator.LessThan:
|
|
35
|
-
return compareValues(rowValue, filterValue) < 0;
|
|
36
|
-
case EDataFilterOperator.GreaterThanOrEqual:
|
|
37
|
-
return compareValues(rowValue, filterValue) >= 0;
|
|
38
|
-
case EDataFilterOperator.LessThanOrEqual:
|
|
39
|
-
return compareValues(rowValue, filterValue) <= 0;
|
|
40
|
-
case EDataFilterOperator.In:
|
|
41
|
-
return compareIn(rowValue, filterValue);
|
|
42
|
-
case EDataFilterOperator.NotIn:
|
|
43
|
-
return !compareIn(rowValue, filterValue);
|
|
44
|
-
default:
|
|
45
|
-
return compareEqual(rowValue, filterValue);
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
const compareAnd = (row, nested) => {
|
|
49
|
-
const subFilters = Array.isArray(nested) ? nested : nested && typeof nested === "object" ? Object.values(nested) : [];
|
|
50
|
-
const validFilters = subFilters.filter((f) => f && typeof f === "object" && "operator" in f && "field" in f);
|
|
51
|
-
if (validFilters.length === 0) return true;
|
|
52
|
-
return validFilters.every((f) => {
|
|
53
|
-
const active = f.active !== false;
|
|
54
|
-
return active ? evaluateFilter(f, row) : true;
|
|
55
|
-
});
|
|
56
|
-
};
|
|
57
|
-
const compareOr = (row, nested) => {
|
|
58
|
-
const subFilters = Array.isArray(nested) ? nested : nested && typeof nested === "object" ? Object.values(nested) : [];
|
|
59
|
-
const validFilters = subFilters.filter((f) => f && typeof f === "object" && "operator" in f && "field" in f);
|
|
60
|
-
const activeFilters = validFilters.filter((f) => f.active !== false);
|
|
61
|
-
if (activeFilters.length === 0) return true;
|
|
62
|
-
return activeFilters.some((f) => {
|
|
63
|
-
return evaluateFilter(f, row);
|
|
64
|
-
});
|
|
65
|
-
};
|
|
66
|
-
const compareIn = (rowValue, filterValue) => {
|
|
67
|
-
if (typeof rowValue === "string" && typeof filterValue === "string") {
|
|
68
|
-
return rowValue.toLowerCase().includes(filterValue.toLowerCase());
|
|
69
|
-
}
|
|
70
|
-
return false;
|
|
71
|
-
};
|
|
72
|
-
const compareEqual = (rowValue, filterValue) => {
|
|
73
|
-
if (typeof rowValue === "string" && typeof filterValue === "string") {
|
|
74
|
-
return rowValue.toLowerCase() == filterValue.toLowerCase();
|
|
75
|
-
}
|
|
76
|
-
if (typeof rowValue === "number" && typeof filterValue === "number") {
|
|
77
|
-
return rowValue === filterValue;
|
|
78
|
-
}
|
|
79
|
-
if (typeof rowValue === "boolean" && typeof filterValue === "boolean") {
|
|
80
|
-
return rowValue === filterValue;
|
|
81
|
-
}
|
|
82
|
-
return rowValue === filterValue;
|
|
83
|
-
};
|
|
84
|
-
const compareValues = (rowValue, filterValue) => {
|
|
85
|
-
if (rowValue == null || filterValue == null) {
|
|
86
|
-
return rowValue == null ? -1 : 1;
|
|
87
|
-
}
|
|
88
|
-
if (typeof rowValue === "string" && typeof filterValue === "string") {
|
|
89
|
-
return rowValue.localeCompare(filterValue);
|
|
90
|
-
}
|
|
91
|
-
if (typeof rowValue === "number" && typeof filterValue === "number") {
|
|
92
|
-
return rowValue - filterValue;
|
|
93
|
-
}
|
|
94
|
-
return String(rowValue).localeCompare(String(filterValue));
|
|
95
|
-
};
|
|
96
|
-
const filterTreeData = (nodes, filter, options) => {
|
|
97
|
-
const { idKey, parentKey } = options;
|
|
98
|
-
const nodeMap = new Map(nodes.map((node) => [node[idKey], node]));
|
|
99
|
-
const childrenMap = /* @__PURE__ */ new Map();
|
|
100
|
-
nodes.forEach((node) => {
|
|
101
|
-
const pId = node[parentKey];
|
|
102
|
-
if (pId != null) {
|
|
103
|
-
if (!childrenMap.has(pId)) {
|
|
104
|
-
childrenMap.set(pId, []);
|
|
105
|
-
}
|
|
106
|
-
childrenMap.get(pId).push(node);
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
const matchingNodeIds = /* @__PURE__ */ new Set();
|
|
110
|
-
const expandedNodes = /* @__PURE__ */ new Set();
|
|
111
|
-
const visibleNodeIds = /* @__PURE__ */ new Set();
|
|
112
|
-
nodes.forEach((node) => {
|
|
113
|
-
const evalRow = node.data ? { ...node.data, ...node } : node;
|
|
114
|
-
if (evaluateFilter(filter, evalRow)) {
|
|
115
|
-
matchingNodeIds.add(node[idKey]);
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
const addDescendants = (nodeId) => {
|
|
119
|
-
const children = childrenMap.get(nodeId);
|
|
120
|
-
if (children && children.length > 0) {
|
|
121
|
-
expandedNodes.add(nodeId);
|
|
122
|
-
children.forEach((child) => {
|
|
123
|
-
visibleNodeIds.add(child[idKey]);
|
|
124
|
-
addDescendants(child[idKey]);
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
matchingNodeIds.forEach((id) => {
|
|
129
|
-
visibleNodeIds.add(id);
|
|
130
|
-
addDescendants(id);
|
|
131
|
-
let currentId = id;
|
|
132
|
-
while (currentId != null) {
|
|
133
|
-
visibleNodeIds.add(currentId);
|
|
134
|
-
const node = nodeMap.get(currentId);
|
|
135
|
-
if (node) {
|
|
136
|
-
if (node[parentKey] != null) {
|
|
137
|
-
expandedNodes.add(node[parentKey]);
|
|
138
|
-
currentId = node[parentKey];
|
|
139
|
-
} else {
|
|
140
|
-
currentId = null;
|
|
141
|
-
}
|
|
142
|
-
} else {
|
|
143
|
-
break;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
const visibleNodes = nodes.filter((node) => visibleNodeIds.has(node[idKey]));
|
|
148
|
-
return {
|
|
149
|
-
visibleNodes,
|
|
150
|
-
expandedNodes
|
|
151
|
-
};
|
|
152
|
-
};
|
|
153
|
-
const filterData = (data, filter, options) => {
|
|
154
|
-
if (options?.treeOptions) {
|
|
155
|
-
const { visibleNodes, expandedNodes } = filterTreeData(
|
|
156
|
-
data,
|
|
157
|
-
filter,
|
|
158
|
-
options.treeOptions
|
|
159
|
-
);
|
|
160
|
-
return { results: visibleNodes, expandedNodes };
|
|
161
|
-
}
|
|
162
|
-
const results = data.filter((row) => evaluateFilter(filter, row));
|
|
163
|
-
return { results };
|
|
164
|
-
};
|
|
165
|
-
return {
|
|
166
|
-
evaluateFilter,
|
|
167
|
-
filterTreeData,
|
|
168
|
-
filterData
|
|
169
|
-
};
|
|
1
|
+
import {
|
|
2
|
+
useFilterLogic as providersUseFilterLogic,
|
|
3
|
+
evaluateFilter,
|
|
4
|
+
filterTreeData,
|
|
5
|
+
filterData,
|
|
6
|
+
applyOperator,
|
|
7
|
+
compareAnd,
|
|
8
|
+
compareOr,
|
|
9
|
+
compareIn,
|
|
10
|
+
compareEqual,
|
|
11
|
+
compareValues
|
|
12
|
+
} from "@katlux/providers";
|
|
13
|
+
export const useFilterLogic = providersUseFilterLogic;
|
|
14
|
+
export {
|
|
15
|
+
evaluateFilter,
|
|
16
|
+
filterTreeData,
|
|
17
|
+
filterData,
|
|
18
|
+
applyOperator,
|
|
19
|
+
compareAnd,
|
|
20
|
+
compareOr,
|
|
21
|
+
compareIn,
|
|
22
|
+
compareEqual,
|
|
23
|
+
compareValues
|
|
170
24
|
};
|
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
import { type Component } from 'vue';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Type for preset component entries: either a direct Vue Component object/function,
|
|
4
|
+
* or a dynamic loader function returning a module with the Component.
|
|
4
5
|
*/
|
|
5
|
-
export
|
|
6
|
+
export type PresetComponentEntry = Component | (() => Promise<{
|
|
7
|
+
default?: Component;
|
|
8
|
+
} | Component | any>);
|
|
9
|
+
/**
|
|
10
|
+
* API for Nuxt preset plugins or tenant configurations to register their component loaders or components.
|
|
11
|
+
*/
|
|
12
|
+
export declare function registerPresetComponents(presetName: string, loaders: Record<string, PresetComponentEntry>): void;
|
|
13
|
+
/**
|
|
14
|
+
* Reset caches (useful for testing or hot reloading)
|
|
15
|
+
*/
|
|
16
|
+
export declare function clearPresetComponentCache(): void;
|
|
6
17
|
/**
|
|
7
18
|
* Composable for dynamically loading preset components across a cascade of active presets.
|
|
8
19
|
*
|
|
@@ -10,4 +21,4 @@ export declare function registerPresetComponents(presetName: string, loaders: Re
|
|
|
10
21
|
* @param defaultComponent - The default preset component to fall back to
|
|
11
22
|
* @returns A computed ref resolving to the correct Component for the active preset stack
|
|
12
23
|
*/
|
|
13
|
-
export declare function usePresetComponent(componentBaseName: string, defaultComponent: Component): import("vue").ComputedRef<
|
|
24
|
+
export declare function usePresetComponent(componentBaseName: string, defaultComponent: Component): import("vue").ComputedRef<Component | undefined>;
|
|
@@ -1,56 +1,80 @@
|
|
|
1
1
|
import { computed, defineAsyncComponent, shallowReactive } from "vue";
|
|
2
2
|
import { useAppConfig } from "#app";
|
|
3
3
|
const _loadersRegistry = shallowReactive({});
|
|
4
|
+
const _asyncComponentCache = /* @__PURE__ */ new Map();
|
|
5
|
+
const _internalPresetLoaders = import.meta.glob([
|
|
6
|
+
"../presets/**/*.vue",
|
|
7
|
+
"../../runtime/presets/**/*.vue",
|
|
8
|
+
"~/presets/**/*.vue",
|
|
9
|
+
"@/presets/**/*.vue"
|
|
10
|
+
]);
|
|
4
11
|
export function registerPresetComponents(presetName, loaders) {
|
|
5
12
|
_loadersRegistry[presetName] = loaders;
|
|
6
13
|
}
|
|
14
|
+
export function clearPresetComponentCache() {
|
|
15
|
+
_asyncComponentCache.clear();
|
|
16
|
+
for (const key in _loadersRegistry) {
|
|
17
|
+
delete _loadersRegistry[key];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function isDirectComponent(entry) {
|
|
21
|
+
if (!entry) return false;
|
|
22
|
+
if (typeof entry === "object") return true;
|
|
23
|
+
if (typeof entry === "function") {
|
|
24
|
+
return Boolean(entry.setup || entry.render || entry.__name || entry.__file);
|
|
25
|
+
}
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
7
28
|
export function usePresetComponent(componentBaseName, defaultComponent) {
|
|
8
29
|
const appConfig = useAppConfig();
|
|
9
|
-
const presetStack = computed(() => {
|
|
10
|
-
const raw = appConfig.katluxToolkit?.activePreset;
|
|
11
|
-
const list = Array.isArray(raw) ? raw : raw ? [raw] : [];
|
|
12
|
-
return [...list.filter((p) => p && p !== "default"), "default"];
|
|
13
|
-
});
|
|
14
30
|
return computed(() => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
31
|
+
const raw = appConfig.katluxToolkit?.activePreset;
|
|
32
|
+
if (!raw || raw === "default" || Array.isArray(raw) && (raw.length === 0 || raw.length === 1 && raw[0] === "default")) {
|
|
33
|
+
return defaultComponent;
|
|
34
|
+
}
|
|
35
|
+
const list = Array.isArray(raw) ? raw : [raw];
|
|
36
|
+
const activePresets = list.filter((p) => p && p !== "default");
|
|
37
|
+
for (const presetName of activePresets) {
|
|
38
|
+
const cacheKey = `${presetName}:${componentBaseName}`;
|
|
18
39
|
const externalLoaders = _loadersRegistry[presetName];
|
|
19
40
|
if (externalLoaders) {
|
|
20
41
|
const key = `./components/${componentBaseName}/${componentBaseName}.vue`;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"../presets/**/*.vue",
|
|
26
|
-
"../../runtime/presets/**/*.vue",
|
|
27
|
-
"~/presets/**/*.vue",
|
|
28
|
-
"@/presets/**/*.vue"
|
|
29
|
-
]);
|
|
30
|
-
const candidateKeys = [
|
|
31
|
-
`../presets/${presetName}/components/${componentBaseName}/${componentBaseName}.vue`,
|
|
32
|
-
`../../runtime/presets/${presetName}/components/${componentBaseName}/${componentBaseName}.vue`,
|
|
33
|
-
`/app/presets/${presetName}/components/${componentBaseName}/${componentBaseName}.vue`,
|
|
34
|
-
`/presets/${presetName}/components/${componentBaseName}/${componentBaseName}.vue`
|
|
35
|
-
];
|
|
36
|
-
for (const [key, importFn] of Object.entries(internalLoaders)) {
|
|
37
|
-
for (const candidate of candidateKeys) {
|
|
38
|
-
if (key.endsWith(candidate)) {
|
|
39
|
-
loader = importFn;
|
|
40
|
-
break;
|
|
41
|
-
}
|
|
42
|
+
const candidate = externalLoaders[key];
|
|
43
|
+
if (candidate) {
|
|
44
|
+
if (isDirectComponent(candidate)) {
|
|
45
|
+
return candidate;
|
|
42
46
|
}
|
|
43
|
-
|
|
47
|
+
let cached = _asyncComponentCache.get(cacheKey);
|
|
48
|
+
if (!cached) {
|
|
49
|
+
cached = defineAsyncComponent({
|
|
50
|
+
loader: candidate,
|
|
51
|
+
errorComponent: defaultComponent
|
|
52
|
+
});
|
|
53
|
+
_asyncComponentCache.set(cacheKey, cached);
|
|
54
|
+
}
|
|
55
|
+
return cached;
|
|
44
56
|
}
|
|
45
57
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
58
|
+
let internalLoader;
|
|
59
|
+
const targetSuffix = `/presets/${presetName}/components/${componentBaseName}/${componentBaseName}.vue`;
|
|
60
|
+
for (const [key, importFn] of Object.entries(_internalPresetLoaders)) {
|
|
61
|
+
if (key.endsWith(targetSuffix)) {
|
|
62
|
+
internalLoader = importFn;
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (internalLoader) {
|
|
67
|
+
let cached = _asyncComponentCache.get(cacheKey);
|
|
68
|
+
if (!cached) {
|
|
69
|
+
cached = defineAsyncComponent({
|
|
70
|
+
loader: internalLoader,
|
|
71
|
+
errorComponent: defaultComponent
|
|
72
|
+
});
|
|
73
|
+
_asyncComponentCache.set(cacheKey, cached);
|
|
74
|
+
}
|
|
75
|
+
return cached;
|
|
76
|
+
}
|
|
50
77
|
}
|
|
51
|
-
return
|
|
52
|
-
loader,
|
|
53
|
-
errorComponent: defaultComponent
|
|
54
|
-
});
|
|
78
|
+
return defaultComponent;
|
|
55
79
|
});
|
|
56
80
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { RequestProvider } from '@katlux/providers';
|
|
2
|
+
/**
|
|
3
|
+
* useRequestProvider
|
|
4
|
+
*
|
|
5
|
+
* Vue composable that registers a RequestProvider with the RequestProviderRegistry
|
|
6
|
+
* and automatically unregisters it when the component is destroyed.
|
|
7
|
+
*
|
|
8
|
+
* Works correctly with <keep-alive>:
|
|
9
|
+
* - Component hidden (onDeactivated) → stays registered → still receives auto-refresh ✅
|
|
10
|
+
* - Component evicted (onUnmounted) → unregistered → no leak ✅
|
|
11
|
+
* - Component destroyed normally → unregistered ✅
|
|
12
|
+
*
|
|
13
|
+
* Usage:
|
|
14
|
+
* const invoiceProvider = useRequestProvider(
|
|
15
|
+
* new CAPIFlatServerDataProvider(),
|
|
16
|
+
* ['invoices', 'sales']
|
|
17
|
+
* )
|
|
18
|
+
*
|
|
19
|
+
* @param provider The RequestProvider instance to register
|
|
20
|
+
* @param tags String tags linking this provider to mutations
|
|
21
|
+
* @returns The same provider instance (for chaining)
|
|
22
|
+
*/
|
|
23
|
+
export declare function useRequestProvider<T extends RequestProvider>(provider: T, tags: string[]): T;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { onUnmounted } from "vue";
|
|
2
|
+
import { RequestProviderRegistry } from "@katlux/providers";
|
|
3
|
+
export function useRequestProvider(provider, tags) {
|
|
4
|
+
RequestProviderRegistry.register(provider, tags);
|
|
5
|
+
onUnmounted(() => {
|
|
6
|
+
RequestProviderRegistry.unregister(provider);
|
|
7
|
+
});
|
|
8
|
+
return provider;
|
|
9
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { sortData } from '@katlux/providers';
|
|
2
2
|
export declare const useSortLogic: () => {
|
|
3
|
-
sortData: (sortList: IDataSort[], rows: TDataRow[]) => TDataRow[];
|
|
3
|
+
sortData: (sortList: import("@katlux/providers").IDataSort[], rows: import("@katlux/providers").TDataRow[]) => import("@katlux/providers").TDataRow[];
|
|
4
4
|
};
|
|
5
|
+
export { sortData };
|
|
@@ -1,55 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
return rows;
|
|
5
|
-
}
|
|
6
|
-
const sortedRows = [...rows];
|
|
7
|
-
const compare = (a, b) => {
|
|
8
|
-
for (const sort of sortList) {
|
|
9
|
-
const aVal = a[sort.field];
|
|
10
|
-
const bVal = b[sort.field];
|
|
11
|
-
if (aVal === null || aVal === void 0) {
|
|
12
|
-
if (bVal === null || bVal === void 0) continue;
|
|
13
|
-
return sort.direction === "asc" ? -1 : 1;
|
|
14
|
-
}
|
|
15
|
-
if (bVal === null || bVal === void 0) {
|
|
16
|
-
return sort.direction === "asc" ? 1 : -1;
|
|
17
|
-
}
|
|
18
|
-
if (aVal < bVal) {
|
|
19
|
-
return sort.direction === "asc" ? -1 : 1;
|
|
20
|
-
} else if (aVal > bVal) {
|
|
21
|
-
return sort.direction === "asc" ? 1 : -1;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return 0;
|
|
25
|
-
};
|
|
26
|
-
const merge = (left, right) => {
|
|
27
|
-
const result = [];
|
|
28
|
-
let leftIndex = 0;
|
|
29
|
-
let rightIndex = 0;
|
|
30
|
-
while (leftIndex < left.length && rightIndex < right.length) {
|
|
31
|
-
if (compare(left[leftIndex], right[rightIndex]) <= 0) {
|
|
32
|
-
result.push(left[leftIndex]);
|
|
33
|
-
leftIndex++;
|
|
34
|
-
} else {
|
|
35
|
-
result.push(right[rightIndex]);
|
|
36
|
-
rightIndex++;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return result.concat(left.slice(leftIndex)).concat(right.slice(rightIndex));
|
|
40
|
-
};
|
|
41
|
-
const mergeSort = (arr) => {
|
|
42
|
-
if (arr.length <= 1) {
|
|
43
|
-
return arr;
|
|
44
|
-
}
|
|
45
|
-
const mid = Math.floor(arr.length / 2);
|
|
46
|
-
const left = mergeSort(arr.slice(0, mid));
|
|
47
|
-
const right = mergeSort(arr.slice(mid));
|
|
48
|
-
return merge(left, right);
|
|
49
|
-
};
|
|
50
|
-
return mergeSort(sortedRows);
|
|
51
|
-
};
|
|
52
|
-
return {
|
|
53
|
-
sortData
|
|
54
|
-
};
|
|
55
|
-
};
|
|
1
|
+
import { useSortLogic as providersUseSortLogic, sortData } from "@katlux/providers";
|
|
2
|
+
export const useSortLogic = providersUseSortLogic;
|
|
3
|
+
export { sortData };
|
|
@@ -7,7 +7,7 @@ export interface UseTemplateOptions {
|
|
|
7
7
|
export interface UseTemplateReturn {
|
|
8
8
|
metadata: Ref<TemplateMetadata>;
|
|
9
9
|
isCustomTemplate: Ref<boolean>;
|
|
10
|
-
templateName: Ref<string>;
|
|
10
|
+
templateName: Ref<string | string[]>;
|
|
11
11
|
isLoading: Ref<boolean>;
|
|
12
12
|
error: Ref<Error | null>;
|
|
13
13
|
refreshTemplate: () => void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ref, computed, onMounted } from "vue";
|
|
2
|
-
import { useTemplateResolver } from "../utils/TemplateResolver";
|
|
2
|
+
import { useTemplateResolver } from "../utils/TemplateResolver.js";
|
|
3
3
|
export function useTemplate(options) {
|
|
4
4
|
const { componentName, fallbackToDefault = true } = options;
|
|
5
5
|
const resolver = useTemplateResolver();
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { RequestProvider } from '@katlux/providers';
|
|
2
|
+
/**
|
|
3
|
+
* useUnregisterProvider
|
|
4
|
+
*
|
|
5
|
+
* Explicitly removes a RequestProvider from the RequestProviderRegistry.
|
|
6
|
+
* After this call the provider will no longer receive auto-refresh signals
|
|
7
|
+
* from mutation notifications.
|
|
8
|
+
*
|
|
9
|
+
* Use cases:
|
|
10
|
+
* 1. Mid-lifecycle opt-out — stop receiving refreshes without waiting for unmount
|
|
11
|
+
* 2. <keep-alive> deactivation — opt-out while hidden, re-register on activation
|
|
12
|
+
* 3. Module-scoped providers — explicit cleanup outside component lifecycle
|
|
13
|
+
*
|
|
14
|
+
* Example with <keep-alive>:
|
|
15
|
+
* const provider = useRequestProvider(myProvider, ['invoices'])
|
|
16
|
+
*
|
|
17
|
+
* onDeactivated(() => useUnregisterProvider(provider)) // stop while hidden
|
|
18
|
+
* onActivated(() => RequestProviderRegistry.register(provider, ['invoices'])) // re-register
|
|
19
|
+
*
|
|
20
|
+
* Example on manual logout:
|
|
21
|
+
* RequestProviderRegistry.clear() // clears all — use instead of individual calls
|
|
22
|
+
*
|
|
23
|
+
* @param provider The RequestProvider instance to unregister
|
|
24
|
+
*/
|
|
25
|
+
export declare function useUnregisterProvider(provider: RequestProvider): void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* nuxtCompatPlugin
|
|
3
|
+
*
|
|
4
|
+
* Bridges Nuxt 3 composables to globalThis so standalone framework-agnostic libraries
|
|
5
|
+
* like @katlux/providers can access Nuxt runtime features (SSR hydration, caching, routing)
|
|
6
|
+
* without hard #app imports.
|
|
7
|
+
*/
|
|
8
|
+
declare const _default: import("#app").Plugin<Record<string, unknown>> & import("#app").ObjectPlugin<Record<string, unknown>>;
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { defineNuxtPlugin, useNuxtApp, useAsyncData, useNuxtData, clearNuxtData, useRoute, useRouter, onNuxtReady } from "#app";
|
|
2
|
+
export default defineNuxtPlugin((nuxtApp) => {
|
|
3
|
+
const _global = globalThis;
|
|
4
|
+
_global.useNuxtApp = useNuxtApp;
|
|
5
|
+
_global.useAsyncData = useAsyncData;
|
|
6
|
+
_global.useNuxtData = useNuxtData;
|
|
7
|
+
_global.clearNuxtData = clearNuxtData;
|
|
8
|
+
_global.useRoute = useRoute;
|
|
9
|
+
_global.useRouter = useRouter;
|
|
10
|
+
_global.onNuxtReady = onNuxtReady;
|
|
11
|
+
});
|
|
@@ -189,6 +189,8 @@
|
|
|
189
189
|
--grid-gap: var(--gap-md);
|
|
190
190
|
--component-gap: var(--gap-sm);
|
|
191
191
|
--layover: var(--neutral-600);
|
|
192
|
+
--component-overlay-bg: rgba(255, 255, 255, 0.7);
|
|
193
|
+
--table-overlay-bg: var(--component-overlay-bg);
|
|
192
194
|
--modal-overlay-bg: rgba(0, 0, 0, 0.5);
|
|
193
195
|
--modal-backdrop-blur: 0px;
|
|
194
196
|
--layout-header-height: 60px;
|
|
@@ -269,6 +269,8 @@
|
|
|
269
269
|
--grid-gap: var(--gap-md);
|
|
270
270
|
--component-gap: var(--gap-sm);
|
|
271
271
|
--layover: var(--neutral-600);
|
|
272
|
+
--component-overlay-bg: rgba(255, 255, 255, 0.7);
|
|
273
|
+
--table-overlay-bg: var(--component-overlay-bg);
|
|
272
274
|
--modal-overlay-bg: rgba(0, 0, 0, 0.5);
|
|
273
275
|
--modal-backdrop-blur: 0px;
|
|
274
276
|
|
|
@@ -206,6 +206,8 @@ li {
|
|
|
206
206
|
--grid-gap: var(--gap-md);
|
|
207
207
|
--component-gap: var(--gap-sm);
|
|
208
208
|
--layover: var(--neutral-600);
|
|
209
|
+
--component-overlay-bg: rgba(255, 255, 255, 0.7);
|
|
210
|
+
--table-overlay-bg: var(--component-overlay-bg);
|
|
209
211
|
--modal-overlay-bg: rgba(0, 0, 0, 0.5);
|
|
210
212
|
--modal-backdrop-blur: 0px;
|
|
211
213
|
--layout-header-height: 60px;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type KAlertProps } from '#toolkit/components/KAlert/KAlert.logic';
|
|
2
2
|
declare const __VLS_export: import("vue").DefineComponent<KAlertProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
3
3
|
dismiss: () => any;
|
|
4
4
|
}, string, import("vue").PublicProps, Readonly<KAlertProps> & Readonly<{
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
<template lang="pug">
|
|
2
2
|
Transition(name="k-alert-fade")
|
|
3
3
|
.KAlert(v-if="visible" :class="[props.type]" role="alert")
|
|
4
|
-
.alert-icon
|
|
4
|
+
.alert-icon(v-if="icon")
|
|
5
|
+
KIcon(:iconname="icon" :width="18" :height="18")
|
|
5
6
|
.alert-body
|
|
6
7
|
.alert-title(v-if="props.title") {{ props.title }}
|
|
7
8
|
.alert-content
|
|
8
9
|
slot
|
|
9
10
|
button.alert-dismiss(v-if="props.dismissible" @click="dismiss" :aria-label="t('Dismiss')")
|
|
10
|
-
|
|
11
|
+
KIcon(iconname="close" :width="14" :height="14")
|
|
11
12
|
</template>
|
|
12
13
|
|
|
13
14
|
<script lang="ts" setup>
|
|
14
|
-
import type
|
|
15
|
+
import { useKAlertLogic, type KAlertProps } from '#toolkit/components/KAlert/KAlert.logic'
|
|
15
16
|
import { useKatluxI18n } from '#toolkit/composables/useKatluxI18n'
|
|
16
17
|
|
|
17
18
|
const props = defineProps<KAlertProps>()
|
|
@@ -56,9 +57,11 @@ const { t } = useKatluxI18n()
|
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
.alert-icon {
|
|
59
|
-
|
|
60
|
+
display: flex;
|
|
61
|
+
align-items: center;
|
|
62
|
+
justify-content: center;
|
|
60
63
|
flex-shrink: 0;
|
|
61
|
-
margin-top:
|
|
64
|
+
margin-top: 2px;
|
|
62
65
|
}
|
|
63
66
|
|
|
64
67
|
.alert-body {
|
|
@@ -79,16 +82,20 @@ const { t } = useKatluxI18n()
|
|
|
79
82
|
background: none;
|
|
80
83
|
border: none;
|
|
81
84
|
cursor: pointer;
|
|
82
|
-
|
|
83
|
-
|
|
85
|
+
display: flex;
|
|
86
|
+
align-items: center;
|
|
87
|
+
justify-content: center;
|
|
84
88
|
opacity: 0.6;
|
|
85
89
|
color: inherit;
|
|
86
|
-
padding:
|
|
90
|
+
padding: 4px;
|
|
91
|
+
margin: -2px -4px 0 0;
|
|
92
|
+
border-radius: var(--border-radius-sm, 4px);
|
|
87
93
|
flex-shrink: 0;
|
|
88
|
-
transition: opacity var(--transition-fast, 0.15s ease);
|
|
94
|
+
transition: opacity var(--transition-fast, 0.15s ease), background-color var(--transition-fast, 0.15s ease);
|
|
89
95
|
|
|
90
96
|
&:hover {
|
|
91
97
|
opacity: 1;
|
|
98
|
+
background-color: rgba(0, 0, 0, 0.05);
|
|
92
99
|
}
|
|
93
100
|
}
|
|
94
101
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type KAlertProps } from '#toolkit/components/KAlert/KAlert.logic';
|
|
2
2
|
declare const __VLS_export: import("vue").DefineComponent<KAlertProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
3
3
|
dismiss: () => any;
|
|
4
4
|
}, string, import("vue").PublicProps, Readonly<KAlertProps> & Readonly<{
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
v-for="(day, index) of calendarDays"
|
|
8
8
|
:key="`${year}-${month}-${index}`"
|
|
9
9
|
:class="[{ marked: isMarked(day), empty: !day, selected: isSelectedDay(day) }, getMarkedDayClass(day)]"
|
|
10
|
-
@click="selectDay(day)"
|
|
10
|
+
@click="day ? selectDay(day) : null"
|
|
11
11
|
)
|
|
12
12
|
span.day-number(
|
|
13
13
|
v-if="day"
|