@katlux/toolkit 0.1.1-alpha.141 → 0.1.1-alpha.142
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/useKatluxForm.mjs +29 -21
- package/dist/module.json +1 -1
- package/dist/runtime/components/KButton/KButton.global.d.vue.ts +1 -1
- package/dist/runtime/components/KButton/KButton.global.vue.d.ts +1 -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 +1 -1
- package/dist/runtime/components/KCombobox/KCombobox.global.vue.d.ts +1 -1
- package/dist/runtime/components/KDatatable/KDataIterator.global.d.vue.ts +1 -1
- package/dist/runtime/components/KDatatable/KDataIterator.global.vue.d.ts +1 -1
- package/dist/runtime/components/KDatePicker/KDatePicker.global.d.vue.ts +2 -2
- package/dist/runtime/components/KDatePicker/KDatePicker.global.vue.d.ts +2 -2
- package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.d.vue.ts +2 -2
- package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.vue.d.ts +2 -2
- 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/KRangeSlider/KRangeSlider.global.d.vue.ts +1 -1
- package/dist/runtime/components/KRangeSlider/KRangeSlider.global.vue.d.ts +1 -1
- package/dist/runtime/components/KSlider/KSlider.global.d.vue.ts +1 -1
- package/dist/runtime/components/KSlider/KSlider.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/composables/useKatluxForm.d.ts +11 -11
- package/dist/runtime/composables/useKatluxForm.js +29 -21
- package/dist/skills/katlux-components/components/KAreaChart.md +1 -1
- package/dist/skills/katlux-components/components/KBarChart.md +1 -1
- package/dist/skills/katlux-components/components/KBulkActions.md +3 -3
- package/dist/skills/katlux-components/components/KCheckbox.md +2 -2
- package/dist/skills/katlux-components/components/KCombobox.md +3 -3
- package/dist/skills/katlux-components/components/KCompositeInput.md +4 -4
- package/dist/skills/katlux-components/components/KDataIterator.md +3 -3
- package/dist/skills/katlux-components/components/KDatatable.md +7 -7
- package/dist/skills/katlux-components/components/KDatePicker.md +3 -3
- package/dist/skills/katlux-components/components/KGantt.md +12 -12
- package/dist/skills/katlux-components/components/KHeatMap.md +1 -1
- package/dist/skills/katlux-components/components/KLineChart.md +1 -1
- package/dist/skills/katlux-components/components/KPieChart.md +1 -1
- package/dist/skills/katlux-components/components/KScatterChart.md +1 -1
- package/dist/skills/katlux-components/components/KTree.md +8 -8
- package/dist/skills/katlux-components/components/KTreePicker.md +3 -3
- package/dist/skills/katlux-components/components/KTreeView.md +3 -3
- package/dist/skills/katlux-config/SKILL.md +7 -7
- package/dist/skills/katlux-presets/SKILL.md +1 -1
- package/dist/skills/katlux-presets/creating-a-preset.md +1 -1
- package/dist/skills/katlux-providers/providers/ADataProvider.md +3 -3
- package/dist/skills/katlux-providers/providers/CAPIFlatClientDataProvider.md +3 -3
- package/dist/skills/katlux-providers/providers/CAPIFlatServerDataProvider.md +3 -3
- package/dist/skills/katlux-providers/providers/CFlatClientDataProvider.md +4 -4
- package/dist/skills/katlux-providers/providers/CFlatServerDataProvider.md +1 -1
- package/dist/skills/katlux-providers/providers/CTreeClientDataProvider.md +2 -2
- package/dist/skills/katlux-providers/providers/RequestProvider.md +4 -4
- package/dist/skills/katlux-providers/providers/caching.md +11 -11
- package/dist/skills/katlux-providers/providers/encryption-threat-model.md +2 -2
- package/dist/skills/katlux-providers/providers/types.md +5 -5
- package/dist/skills/katlux-providers/providers/useDataProvider.md +1 -1
- package/package.json +2 -2
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { ref, reactive, computed, nextTick } from "vue";
|
|
2
2
|
function getByPath(obj, path) {
|
|
3
|
-
if (!obj || !path) return void 0;
|
|
3
|
+
if (!obj || !path || typeof obj !== "object") return void 0;
|
|
4
4
|
const parts = path.replace(/\[(\w+)\]/g, ".$1").split(".");
|
|
5
5
|
let current = obj;
|
|
6
6
|
for (const part of parts) {
|
|
7
|
-
if (current == null) return void 0;
|
|
7
|
+
if (current == null || typeof current !== "object") return void 0;
|
|
8
8
|
current = current[part];
|
|
9
9
|
}
|
|
10
10
|
return current;
|
|
11
11
|
}
|
|
12
12
|
function setByPath(obj, path, value) {
|
|
13
|
-
if (!obj || !path) return;
|
|
13
|
+
if (!obj || !path || typeof obj !== "object") return;
|
|
14
14
|
const parts = path.replace(/\[(\w+)\]/g, ".$1").split(".");
|
|
15
15
|
let current = obj;
|
|
16
16
|
for (let i = 0; i < parts.length - 1; i++) {
|
|
@@ -62,26 +62,28 @@ export function useKatluxForm(options = {}) {
|
|
|
62
62
|
}
|
|
63
63
|
function parseValidationResult(rawResult, schemaType, dataToValidate) {
|
|
64
64
|
if (schemaType === "standard") {
|
|
65
|
-
|
|
65
|
+
const res = rawResult;
|
|
66
|
+
if (res.issues && res.issues.length > 0) {
|
|
66
67
|
const errorMap = {};
|
|
67
|
-
for (const issue of
|
|
68
|
-
const pathStr = issue.path && issue.path.length > 0 ? issue.path.map((seg) => typeof seg === "object" && seg !== null && "key" in seg ? seg.key : seg).join(".") : "";
|
|
68
|
+
for (const issue of res.issues) {
|
|
69
|
+
const pathStr = issue.path && issue.path.length > 0 ? issue.path.map((seg) => typeof seg === "object" && seg !== null && "key" in seg ? String(seg.key) : String(seg)).join(".") : "";
|
|
69
70
|
registerErrorPaths(errorMap, pathStr, issue.message);
|
|
70
71
|
}
|
|
71
72
|
return { valid: false, output: dataToValidate, errors: errorMap };
|
|
72
73
|
}
|
|
73
|
-
return { valid: true, output:
|
|
74
|
+
return { valid: true, output: res.value ?? dataToValidate, errors: {} };
|
|
74
75
|
}
|
|
75
76
|
if (schemaType === "zod") {
|
|
76
|
-
|
|
77
|
+
const res = rawResult;
|
|
78
|
+
if (!res.success) {
|
|
77
79
|
const errorMap = {};
|
|
78
|
-
for (const issue of
|
|
80
|
+
for (const issue of res.error.issues) {
|
|
79
81
|
const pathStr = issue.path ? issue.path.join(".") : "";
|
|
80
82
|
registerErrorPaths(errorMap, pathStr, issue.message);
|
|
81
83
|
}
|
|
82
84
|
return { valid: false, output: dataToValidate, errors: errorMap };
|
|
83
85
|
}
|
|
84
|
-
return { valid: true, output:
|
|
86
|
+
return { valid: true, output: res.data ?? dataToValidate, errors: {} };
|
|
85
87
|
}
|
|
86
88
|
if (schemaType === "custom") {
|
|
87
89
|
const errorMap = {};
|
|
@@ -99,19 +101,25 @@ export function useKatluxForm(options = {}) {
|
|
|
99
101
|
if (!schema) {
|
|
100
102
|
return { valid: true, output: dataToValidate, errors: {} };
|
|
101
103
|
}
|
|
102
|
-
if ("
|
|
103
|
-
const
|
|
104
|
-
if (
|
|
105
|
-
|
|
104
|
+
if (typeof schema === "object" && schema !== null && "~standard" in schema) {
|
|
105
|
+
const standardSchema = schema;
|
|
106
|
+
if (typeof standardSchema["~standard"]?.validate === "function") {
|
|
107
|
+
const res = standardSchema["~standard"].validate(dataToValidate);
|
|
108
|
+
if (res && typeof res.then === "function") {
|
|
109
|
+
return res.then((r) => parseValidationResult(r, "standard", dataToValidate));
|
|
110
|
+
}
|
|
111
|
+
return parseValidationResult(res, "standard", dataToValidate);
|
|
106
112
|
}
|
|
107
|
-
return parseValidationResult(res, "standard", dataToValidate);
|
|
108
|
-
}
|
|
109
|
-
if (typeof schema.safeParse === "function") {
|
|
110
|
-
const res = schema.safeParse(dataToValidate);
|
|
111
|
-
return parseValidationResult(res, "zod", dataToValidate);
|
|
112
113
|
}
|
|
113
|
-
if (typeof schema
|
|
114
|
-
|
|
114
|
+
if (typeof schema === "object" && schema !== null) {
|
|
115
|
+
const zodSchema = schema;
|
|
116
|
+
if (typeof zodSchema.safeParse === "function") {
|
|
117
|
+
const res = zodSchema.safeParse(dataToValidate);
|
|
118
|
+
return parseValidationResult(res, "zod", dataToValidate);
|
|
119
|
+
}
|
|
120
|
+
if (typeof zodSchema.safeParseAsync === "function") {
|
|
121
|
+
return zodSchema.safeParseAsync(dataToValidate).then((res) => parseValidationResult(res, "zod", dataToValidate));
|
|
122
|
+
}
|
|
115
123
|
}
|
|
116
124
|
if (typeof schema === "function") {
|
|
117
125
|
const res = schema(dataToValidate);
|
package/dist/module.json
CHANGED
|
@@ -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
|
+
iconOnly: boolean;
|
|
59
60
|
disabled: boolean;
|
|
60
61
|
href: string;
|
|
61
62
|
loading: boolean;
|
|
62
|
-
iconOnly: 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
|
+
iconOnly: boolean;
|
|
59
60
|
disabled: boolean;
|
|
60
61
|
href: string;
|
|
61
62
|
loading: boolean;
|
|
62
|
-
iconOnly: boolean;
|
|
63
63
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
64
64
|
declare const _default: typeof __VLS_export;
|
|
65
65
|
export default _default;
|
|
@@ -75,8 +75,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
75
75
|
onBlur?: ((event: FocusEvent) => any) | undefined;
|
|
76
76
|
"onUpdate:indeterminate"?: ((value: boolean) => any) | undefined;
|
|
77
77
|
}>, {
|
|
78
|
-
disabled: boolean;
|
|
79
78
|
label: string;
|
|
79
|
+
disabled: boolean;
|
|
80
80
|
validation: "error" | "success" | "warning" | null | undefined;
|
|
81
81
|
validationText: string;
|
|
82
82
|
idKey: string;
|
|
@@ -75,8 +75,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
75
75
|
onBlur?: ((event: FocusEvent) => any) | undefined;
|
|
76
76
|
"onUpdate:indeterminate"?: ((value: boolean) => any) | undefined;
|
|
77
77
|
}>, {
|
|
78
|
-
disabled: boolean;
|
|
79
78
|
label: string;
|
|
79
|
+
disabled: boolean;
|
|
80
80
|
validation: "error" | "success" | "warning" | null | undefined;
|
|
81
81
|
validationText: string;
|
|
82
82
|
idKey: string;
|
|
@@ -223,8 +223,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
223
223
|
}) => any) | undefined;
|
|
224
224
|
}>, {
|
|
225
225
|
modelValue: any;
|
|
226
|
-
disabled: boolean;
|
|
227
226
|
label: string;
|
|
227
|
+
disabled: boolean;
|
|
228
228
|
validation: "error" | "success" | "warning" | null | undefined;
|
|
229
229
|
validationText: string;
|
|
230
230
|
searchbox: boolean;
|
|
@@ -223,8 +223,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
223
223
|
}) => any) | undefined;
|
|
224
224
|
}>, {
|
|
225
225
|
modelValue: any;
|
|
226
|
-
disabled: boolean;
|
|
227
226
|
label: string;
|
|
227
|
+
disabled: boolean;
|
|
228
228
|
validation: "error" | "success" | "warning" | null | undefined;
|
|
229
229
|
validationText: string;
|
|
230
230
|
searchbox: boolean;
|
|
@@ -40,10 +40,10 @@ declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {},
|
|
|
40
40
|
"onSearch-change"?: ((value: string) => any) | undefined;
|
|
41
41
|
}>, {
|
|
42
42
|
search: string;
|
|
43
|
-
loading: boolean;
|
|
44
43
|
selectedRows: any[];
|
|
45
44
|
bulkActions: IKDatatableAction[];
|
|
46
45
|
selectAll: boolean;
|
|
46
|
+
loading: boolean;
|
|
47
47
|
currentPage: number;
|
|
48
48
|
pageSize: number;
|
|
49
49
|
virtualScroll: boolean;
|
|
@@ -40,10 +40,10 @@ declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {},
|
|
|
40
40
|
"onSearch-change"?: ((value: string) => any) | undefined;
|
|
41
41
|
}>, {
|
|
42
42
|
search: string;
|
|
43
|
-
loading: boolean;
|
|
44
43
|
selectedRows: any[];
|
|
45
44
|
bulkActions: IKDatatableAction[];
|
|
46
45
|
selectAll: boolean;
|
|
46
|
+
loading: boolean;
|
|
47
47
|
currentPage: number;
|
|
48
48
|
pageSize: number;
|
|
49
49
|
virtualScroll: boolean;
|
|
@@ -127,11 +127,11 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
127
127
|
modelValue: string | Date;
|
|
128
128
|
isOpen: boolean;
|
|
129
129
|
label: string;
|
|
130
|
+
validation: "error" | "success" | "warning" | null | undefined;
|
|
131
|
+
validationText: string;
|
|
130
132
|
definedDays: import("../KCalendar/types.js").IDefinedDay[];
|
|
131
133
|
markedDays: import("../KCalendar/types.js").IMarkedDay[];
|
|
132
134
|
day: string | Date;
|
|
133
|
-
validation: "error" | "success" | "warning" | null | undefined;
|
|
134
|
-
validationText: string;
|
|
135
135
|
placeholder: string;
|
|
136
136
|
teleportTo: string;
|
|
137
137
|
showClear: boolean;
|
|
@@ -127,11 +127,11 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
127
127
|
modelValue: string | Date;
|
|
128
128
|
isOpen: boolean;
|
|
129
129
|
label: string;
|
|
130
|
+
validation: "error" | "success" | "warning" | null | undefined;
|
|
131
|
+
validationText: string;
|
|
130
132
|
definedDays: import("../KCalendar/types.js").IDefinedDay[];
|
|
131
133
|
markedDays: import("../KCalendar/types.js").IMarkedDay[];
|
|
132
134
|
day: string | Date;
|
|
133
|
-
validation: "error" | "success" | "warning" | null | undefined;
|
|
134
|
-
validationText: string;
|
|
135
135
|
placeholder: string;
|
|
136
136
|
teleportTo: string;
|
|
137
137
|
showClear: boolean;
|
|
@@ -129,11 +129,11 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
129
129
|
modelValue: string | Date;
|
|
130
130
|
isOpen: boolean;
|
|
131
131
|
label: string;
|
|
132
|
+
validation: "error" | "success" | "warning" | null | undefined;
|
|
133
|
+
validationText: string;
|
|
132
134
|
definedDays: import("../KCalendar/types.js").IDefinedDay[];
|
|
133
135
|
markedDays: import("../KCalendar/types.js").IMarkedDay[];
|
|
134
136
|
day: string | Date;
|
|
135
|
-
validation: "error" | "success" | "warning" | null | undefined;
|
|
136
|
-
validationText: string;
|
|
137
137
|
placeholder: string;
|
|
138
138
|
teleportTo: string;
|
|
139
139
|
showClear: boolean;
|
|
@@ -129,11 +129,11 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
129
129
|
modelValue: string | Date;
|
|
130
130
|
isOpen: boolean;
|
|
131
131
|
label: string;
|
|
132
|
+
validation: "error" | "success" | "warning" | null | undefined;
|
|
133
|
+
validationText: string;
|
|
132
134
|
definedDays: import("../KCalendar/types.js").IDefinedDay[];
|
|
133
135
|
markedDays: import("../KCalendar/types.js").IMarkedDay[];
|
|
134
136
|
day: string | Date;
|
|
135
|
-
validation: "error" | "success" | "warning" | null | undefined;
|
|
136
|
-
validationText: string;
|
|
137
137
|
placeholder: string;
|
|
138
138
|
teleportTo: string;
|
|
139
139
|
showClear: boolean;
|
|
@@ -108,8 +108,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
108
108
|
}>, {
|
|
109
109
|
modelValue: string;
|
|
110
110
|
isOpen: boolean;
|
|
111
|
-
disabled: boolean;
|
|
112
111
|
label: string;
|
|
112
|
+
disabled: boolean;
|
|
113
113
|
validation: "error" | "success" | "warning" | null | undefined;
|
|
114
114
|
validationText: string;
|
|
115
115
|
placeholder: string;
|
|
@@ -108,8 +108,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
108
108
|
}>, {
|
|
109
109
|
modelValue: string;
|
|
110
110
|
isOpen: boolean;
|
|
111
|
-
disabled: boolean;
|
|
112
111
|
label: string;
|
|
112
|
+
disabled: boolean;
|
|
113
113
|
validation: "error" | "success" | "warning" | null | undefined;
|
|
114
114
|
validationText: string;
|
|
115
115
|
placeholder: string;
|
|
@@ -74,8 +74,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
74
74
|
"onUpdate:maxValue"?: ((value: number | undefined) => any) | undefined;
|
|
75
75
|
}>, {
|
|
76
76
|
modelValue: number[] | [number, number];
|
|
77
|
-
disabled: boolean;
|
|
78
77
|
label: string;
|
|
78
|
+
disabled: boolean;
|
|
79
79
|
step: number;
|
|
80
80
|
min: number;
|
|
81
81
|
max: number;
|
|
@@ -74,8 +74,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
74
74
|
"onUpdate:maxValue"?: ((value: number | undefined) => any) | undefined;
|
|
75
75
|
}>, {
|
|
76
76
|
modelValue: number[] | [number, number];
|
|
77
|
-
disabled: boolean;
|
|
78
77
|
label: string;
|
|
78
|
+
disabled: boolean;
|
|
79
79
|
step: number;
|
|
80
80
|
min: number;
|
|
81
81
|
max: number;
|
|
@@ -64,8 +64,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
64
64
|
"onUpdate:value"?: ((value: number | undefined) => any) | undefined;
|
|
65
65
|
}>, {
|
|
66
66
|
modelValue: number;
|
|
67
|
-
disabled: boolean;
|
|
68
67
|
label: string;
|
|
68
|
+
disabled: boolean;
|
|
69
69
|
value: number;
|
|
70
70
|
step: number;
|
|
71
71
|
min: number;
|
|
@@ -64,8 +64,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
64
64
|
"onUpdate:value"?: ((value: number | undefined) => any) | undefined;
|
|
65
65
|
}>, {
|
|
66
66
|
modelValue: number;
|
|
67
|
-
disabled: boolean;
|
|
68
67
|
label: string;
|
|
68
|
+
disabled: boolean;
|
|
69
69
|
value: number;
|
|
70
70
|
step: number;
|
|
71
71
|
min: number;
|
|
@@ -232,9 +232,9 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
232
232
|
"onNode-toggle"?: ((nodeId: string | number) => any) | undefined;
|
|
233
233
|
}>, {
|
|
234
234
|
modelValue: any;
|
|
235
|
+
label: string;
|
|
235
236
|
disabled: boolean;
|
|
236
237
|
loading: boolean;
|
|
237
|
-
label: string;
|
|
238
238
|
validation: "error" | "success" | "warning" | null | undefined;
|
|
239
239
|
validationText: string;
|
|
240
240
|
idKey: string;
|
|
@@ -232,9 +232,9 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
232
232
|
"onNode-toggle"?: ((nodeId: string | number) => any) | undefined;
|
|
233
233
|
}>, {
|
|
234
234
|
modelValue: any;
|
|
235
|
+
label: string;
|
|
235
236
|
disabled: boolean;
|
|
236
237
|
loading: boolean;
|
|
237
|
-
label: string;
|
|
238
238
|
validation: "error" | "success" | "warning" | null | undefined;
|
|
239
239
|
validationText: string;
|
|
240
240
|
idKey: string;
|
|
@@ -34,7 +34,7 @@ export declare namespace StandardSchemaV1 {
|
|
|
34
34
|
/**
|
|
35
35
|
* Zod-compatible schema interface
|
|
36
36
|
*/
|
|
37
|
-
export interface ZodLikeSchema<TOutput =
|
|
37
|
+
export interface ZodLikeSchema<TOutput = unknown> {
|
|
38
38
|
safeParse?: (data: unknown) => {
|
|
39
39
|
success: true;
|
|
40
40
|
data: TOutput;
|
|
@@ -63,10 +63,10 @@ export interface ZodLikeSchema<TOutput = any> {
|
|
|
63
63
|
/**
|
|
64
64
|
* Custom validation function
|
|
65
65
|
*/
|
|
66
|
-
export type CustomValidator<T =
|
|
67
|
-
export type KatluxFormSchema<T =
|
|
66
|
+
export type CustomValidator<T = unknown> = (values: T) => Record<string, string> | Promise<Record<string, string>>;
|
|
67
|
+
export type KatluxFormSchema<T = unknown> = StandardSchemaV1<unknown, T> | ZodLikeSchema<T> | CustomValidator<T>;
|
|
68
68
|
export type ValidationMode = 'onBlur' | 'onChange' | 'onSubmit';
|
|
69
|
-
export interface UseKatluxFormOptions<TValues extends Record<string,
|
|
69
|
+
export interface UseKatluxFormOptions<TValues extends Record<string, unknown> = Record<string, unknown>> {
|
|
70
70
|
/**
|
|
71
71
|
* Initial form values
|
|
72
72
|
*/
|
|
@@ -95,7 +95,7 @@ export interface RegisterOptions {
|
|
|
95
95
|
/**
|
|
96
96
|
* Transform value before saving to form state
|
|
97
97
|
*/
|
|
98
|
-
transform?: (value:
|
|
98
|
+
transform?: (value: unknown) => unknown;
|
|
99
99
|
/**
|
|
100
100
|
* Custom validation state override (e.g. 'warning')
|
|
101
101
|
*/
|
|
@@ -105,7 +105,7 @@ export interface RegisterOptions {
|
|
|
105
105
|
*/
|
|
106
106
|
validationText?: string;
|
|
107
107
|
}
|
|
108
|
-
export interface FieldBinding<T =
|
|
108
|
+
export interface FieldBinding<T = unknown> {
|
|
109
109
|
name: string;
|
|
110
110
|
modelValue: T;
|
|
111
111
|
'onUpdate:modelValue': (value: T) => void;
|
|
@@ -121,7 +121,7 @@ export interface FieldBinding<T = any> {
|
|
|
121
121
|
* Provides reactive form state, zero-boilerplate component binding (`v-bind="register('fieldName')"`),
|
|
122
122
|
* standard schema / Zod validation interoperability, granular triggers, and error focus handling.
|
|
123
123
|
*/
|
|
124
|
-
export declare function useKatluxForm<TValues extends Record<string,
|
|
124
|
+
export declare function useKatluxForm<TValues extends Record<string, unknown> = Record<string, unknown>, TOutput = TValues>(options?: UseKatluxFormOptions<TValues>): {
|
|
125
125
|
values: import("vue").Reactive<TValues>;
|
|
126
126
|
errors: Ref<Record<string, string>, Record<string, string>>;
|
|
127
127
|
touched: Ref<Record<string, boolean>, Record<string, boolean>>;
|
|
@@ -130,16 +130,16 @@ export declare function useKatluxForm<TValues extends Record<string, any> = Reco
|
|
|
130
130
|
isValid: ComputedRef<boolean>;
|
|
131
131
|
isSubmitting: Ref<boolean, boolean>;
|
|
132
132
|
submitCount: Ref<number, number>;
|
|
133
|
-
register: <T =
|
|
133
|
+
register: <T = unknown>(path: string, regOptions?: RegisterOptions) => FieldBinding<T>;
|
|
134
134
|
validate: (targetPath?: string) => boolean | Promise<boolean>;
|
|
135
|
-
setValue: (path: string, val:
|
|
135
|
+
setValue: (path: string, val: unknown, opts?: {
|
|
136
136
|
shouldDirty?: boolean;
|
|
137
137
|
shouldValidate?: boolean;
|
|
138
138
|
}) => void;
|
|
139
|
-
getValue: (path: string) =>
|
|
139
|
+
getValue: (path: string) => unknown;
|
|
140
140
|
setError: (path: string, message: string) => void;
|
|
141
141
|
clearErrors: (path?: string) => void;
|
|
142
142
|
setTouched: (path: string, isTouchedVal?: boolean) => void;
|
|
143
143
|
reset: (newValues?: Partial<TValues>) => void;
|
|
144
|
-
handleSubmit: (onValid: (values: TOutput, event?: Event) =>
|
|
144
|
+
handleSubmit: (onValid: (values: TOutput, event?: Event) => unknown | Promise<unknown>, onInvalid?: (errors: Record<string, string>, values: TValues) => unknown | Promise<unknown>) => (event?: Event) => Promise<void>;
|
|
145
145
|
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { ref, reactive, computed, nextTick } from "vue";
|
|
2
2
|
function getByPath(obj, path) {
|
|
3
|
-
if (!obj || !path) return void 0;
|
|
3
|
+
if (!obj || !path || typeof obj !== "object") return void 0;
|
|
4
4
|
const parts = path.replace(/\[(\w+)\]/g, ".$1").split(".");
|
|
5
5
|
let current = obj;
|
|
6
6
|
for (const part of parts) {
|
|
7
|
-
if (current == null) return void 0;
|
|
7
|
+
if (current == null || typeof current !== "object") return void 0;
|
|
8
8
|
current = current[part];
|
|
9
9
|
}
|
|
10
10
|
return current;
|
|
11
11
|
}
|
|
12
12
|
function setByPath(obj, path, value) {
|
|
13
|
-
if (!obj || !path) return;
|
|
13
|
+
if (!obj || !path || typeof obj !== "object") return;
|
|
14
14
|
const parts = path.replace(/\[(\w+)\]/g, ".$1").split(".");
|
|
15
15
|
let current = obj;
|
|
16
16
|
for (let i = 0; i < parts.length - 1; i++) {
|
|
@@ -62,26 +62,28 @@ export function useKatluxForm(options = {}) {
|
|
|
62
62
|
}
|
|
63
63
|
function parseValidationResult(rawResult, schemaType, dataToValidate) {
|
|
64
64
|
if (schemaType === "standard") {
|
|
65
|
-
|
|
65
|
+
const res = rawResult;
|
|
66
|
+
if (res.issues && res.issues.length > 0) {
|
|
66
67
|
const errorMap = {};
|
|
67
|
-
for (const issue of
|
|
68
|
-
const pathStr = issue.path && issue.path.length > 0 ? issue.path.map((seg) => typeof seg === "object" && seg !== null && "key" in seg ? seg.key : seg).join(".") : "";
|
|
68
|
+
for (const issue of res.issues) {
|
|
69
|
+
const pathStr = issue.path && issue.path.length > 0 ? issue.path.map((seg) => typeof seg === "object" && seg !== null && "key" in seg ? String(seg.key) : String(seg)).join(".") : "";
|
|
69
70
|
registerErrorPaths(errorMap, pathStr, issue.message);
|
|
70
71
|
}
|
|
71
72
|
return { valid: false, output: dataToValidate, errors: errorMap };
|
|
72
73
|
}
|
|
73
|
-
return { valid: true, output:
|
|
74
|
+
return { valid: true, output: res.value ?? dataToValidate, errors: {} };
|
|
74
75
|
}
|
|
75
76
|
if (schemaType === "zod") {
|
|
76
|
-
|
|
77
|
+
const res = rawResult;
|
|
78
|
+
if (!res.success) {
|
|
77
79
|
const errorMap = {};
|
|
78
|
-
for (const issue of
|
|
80
|
+
for (const issue of res.error.issues) {
|
|
79
81
|
const pathStr = issue.path ? issue.path.join(".") : "";
|
|
80
82
|
registerErrorPaths(errorMap, pathStr, issue.message);
|
|
81
83
|
}
|
|
82
84
|
return { valid: false, output: dataToValidate, errors: errorMap };
|
|
83
85
|
}
|
|
84
|
-
return { valid: true, output:
|
|
86
|
+
return { valid: true, output: res.data ?? dataToValidate, errors: {} };
|
|
85
87
|
}
|
|
86
88
|
if (schemaType === "custom") {
|
|
87
89
|
const errorMap = {};
|
|
@@ -99,19 +101,25 @@ export function useKatluxForm(options = {}) {
|
|
|
99
101
|
if (!schema) {
|
|
100
102
|
return { valid: true, output: dataToValidate, errors: {} };
|
|
101
103
|
}
|
|
102
|
-
if ("
|
|
103
|
-
const
|
|
104
|
-
if (
|
|
105
|
-
|
|
104
|
+
if (typeof schema === "object" && schema !== null && "~standard" in schema) {
|
|
105
|
+
const standardSchema = schema;
|
|
106
|
+
if (typeof standardSchema["~standard"]?.validate === "function") {
|
|
107
|
+
const res = standardSchema["~standard"].validate(dataToValidate);
|
|
108
|
+
if (res && typeof res.then === "function") {
|
|
109
|
+
return res.then((r) => parseValidationResult(r, "standard", dataToValidate));
|
|
110
|
+
}
|
|
111
|
+
return parseValidationResult(res, "standard", dataToValidate);
|
|
106
112
|
}
|
|
107
|
-
return parseValidationResult(res, "standard", dataToValidate);
|
|
108
|
-
}
|
|
109
|
-
if (typeof schema.safeParse === "function") {
|
|
110
|
-
const res = schema.safeParse(dataToValidate);
|
|
111
|
-
return parseValidationResult(res, "zod", dataToValidate);
|
|
112
113
|
}
|
|
113
|
-
if (typeof schema
|
|
114
|
-
|
|
114
|
+
if (typeof schema === "object" && schema !== null) {
|
|
115
|
+
const zodSchema = schema;
|
|
116
|
+
if (typeof zodSchema.safeParse === "function") {
|
|
117
|
+
const res = zodSchema.safeParse(dataToValidate);
|
|
118
|
+
return parseValidationResult(res, "zod", dataToValidate);
|
|
119
|
+
}
|
|
120
|
+
if (typeof zodSchema.safeParseAsync === "function") {
|
|
121
|
+
return zodSchema.safeParseAsync(dataToValidate).then((res) => parseValidationResult(res, "zod", dataToValidate));
|
|
122
|
+
}
|
|
115
123
|
}
|
|
116
124
|
if (typeof schema === "function") {
|
|
117
125
|
const res = schema(dataToValidate);
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
- **Props**:
|
|
4
4
|
| Prop | Type | Default | Description |
|
|
5
5
|
| --- | --- | --- | --- |
|
|
6
|
-
| `dataProvider` | `ADataProvider \|
|
|
6
|
+
| `dataProvider` | `ADataProvider \| Record<string, unknown>[]` | `undefined` | Data provider or raw data array |
|
|
7
7
|
| `xField` | `string` | `'x'` | Key for horizontal X-axis values |
|
|
8
8
|
| `yField` | `string` | `'y'` | Key for vertical Y-axis values |
|
|
9
9
|
| `seriesField` | `string` | `undefined` | Key for multi-series grouping |
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
- **Props**:
|
|
4
4
|
| Prop | Type | Default | Description |
|
|
5
5
|
| --- | --- | --- | --- |
|
|
6
|
-
| `dataProvider` | `ADataProvider \|
|
|
6
|
+
| `dataProvider` | `ADataProvider \| Record<string, unknown>[]` | `undefined` | Data source |
|
|
7
7
|
| `categoryField` | `string` | `'category'` | Key for categorical axis labels |
|
|
8
8
|
| `valueField` | `string` | `'value'` | Key for numeric bar lengths |
|
|
9
9
|
| `groupField` | `string` | `undefined` | Key for clustering or stacking subgroups |
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
| Prop | Type | Default | Description |
|
|
5
5
|
| --- | --- | --- | --- |
|
|
6
6
|
| `bulkActions` | `IKDatatableAction[]` | **Required** | Defined actions |
|
|
7
|
-
| `selectedRows` | `
|
|
7
|
+
| `selectedRows` | `Record<string, unknown>[]` | **Required** | Current selection array |
|
|
8
8
|
| `selectAll` | `boolean` | `false` | Global dataset selection flag |
|
|
9
|
-
| `unselectedRows` | `
|
|
10
|
-
| `filter` | `
|
|
9
|
+
| `unselectedRows` | `Record<string, unknown>[]` | `[]` | Excluded rows when selectAll is true in dataset scope |
|
|
10
|
+
| `filter` | `IDataFilter \| IDataFilterGroup` | `undefined` | Active data provider filter to pass to bulk action callbacks |
|
|
11
11
|
| `idKey` | `string` | `'id'` | Unique identifier field for row key extraction |
|
|
12
12
|
|
|
13
13
|
- **Feature — Interchangeable Row & Bulk Actions & Rich Context**:
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
- **Props**:
|
|
3
3
|
| Prop | Type | Default | Description |
|
|
4
4
|
| --- | --- | --- | --- |
|
|
5
|
-
| `v-model` | `
|
|
5
|
+
| `v-model` | `boolean \| string \| number \| unknown[]` | `null` | Binding state |
|
|
6
6
|
| `label` | `string` | `''` | Label text |
|
|
7
|
-
| `value` | `
|
|
7
|
+
| `value` | `string \| number \| boolean \| Record<string, unknown>` | `undefined` | Value when selected |
|
|
8
8
|
| `disabled` | `boolean` | `false` | Disable input |
|
|
9
9
|
| `validation` | `'success' \| 'warning' \| 'error' \| null` | `null` | Semantic validation state |
|
|
10
10
|
| `validationText`| `string` | `''` | message to display below input |
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
| `dataProvider` | `ADataProvider` | **Required** | Data source |
|
|
7
7
|
| `labelField` | `string` | **Required** | Field to display as label |
|
|
8
8
|
| `valueField` | `string` | `null` | Optional. Field to bind v-model with (primitive) |
|
|
9
|
-
| `v-model` | `
|
|
9
|
+
| `v-model` | `string \| number \| Record<string, unknown> \| (string \| number \| Record<string, unknown>)[] \| null` | `null` | Selected item(s) (Object or Primitive if valueField is set) |
|
|
10
10
|
| `v-model:isOptionsOpen` | `boolean` | `undefined` | Controls dropdown visibility externally |
|
|
11
11
|
| `multiSelect` | `boolean` | `false` | Allow multiple selections |
|
|
12
12
|
| `searchbox` | `boolean` | `false` | Enable live search |
|
|
@@ -27,11 +27,11 @@
|
|
|
27
27
|
- **Events / Emits**:
|
|
28
28
|
| Event | Payload | Description |
|
|
29
29
|
| --- | --- | --- |
|
|
30
|
-
| `@update:modelValue` | `(val:
|
|
30
|
+
| `@update:modelValue` | `(val: string \| number \| Record<string, unknown> \| (string \| number \| Record<string, unknown>)[] \| null)` | Emitted when selection changes |
|
|
31
31
|
| `@update:isOptionsOpen` | `(open: boolean)` | Emitted when dropdown visibility changes |
|
|
32
32
|
| `@update:searchtext` | `(text: string)` | Emitted when search input changes (`v-model:searchtext`) |
|
|
33
33
|
| `@scroll-state-change` | `(state: IVirtualScrollState)` | Emitted when virtual scroll window updates (`{ startIndex, endIndex, visibleCount, totalCount, scrollTop }`) |
|
|
34
|
-
| `@change` | `(val:
|
|
34
|
+
| `@change` | `(val: string \| number \| Record<string, unknown> \| null)` | Emitted on option selection |
|
|
35
35
|
- **Exposed Properties (via `ref`)**:
|
|
36
36
|
| Property | Type | Description |
|
|
37
37
|
| --- | --- | --- |
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
| Prop | Type | Default | Description |
|
|
5
5
|
| --- | --- | --- | --- |
|
|
6
6
|
| `label` | `string` | `''` | There will be a label. |
|
|
7
|
-
| `selectionValue` | `
|
|
8
|
-
| `inputValue` | `
|
|
7
|
+
| `selectionValue` | `string \| number \| null` | `null` | Current selection (e.g., language code) |
|
|
8
|
+
| `inputValue` | `unknown` | `''` | Input value for the active selection |
|
|
9
9
|
| `modelValue` | `ICompositeItem[]` | `[]` | Collection of active selection-value pairs |
|
|
10
10
|
| `dataProvider` | `ADataProvider` | **Required** | Data source for the selection combobox |
|
|
11
11
|
| `type` | `string` | `'textbox'` | Default input type: `'textbox'`, `'textarea'`, `'maskedtextbox'`, `'combobox'`, `'datepicker'`, `'datetimepicker'`, `'hourpicker'`. Can be overridden per-selection via `inputConfig`. |
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
- **Events**:
|
|
48
48
|
| Event | Payload | Description |
|
|
49
49
|
| --- | --- | --- |
|
|
50
|
-
| `update:selectionValue`| `
|
|
51
|
-
| `update:inputValue` | `
|
|
50
|
+
| `update:selectionValue`| `string \| number \| null` | Fired when the active selection changes |
|
|
51
|
+
| `update:inputValue` | `unknown` | Fired when the active input value changes |
|
|
52
52
|
| `update:modelValue` | `ICompositeItem[]` | Fired when the multi-value collection updates |
|
|
53
53
|
|
|
54
54
|
- **Usage Examples**:
|