@katlux/toolkit 0.1.1-alpha.123 → 0.1.1-alpha.124
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/bin/cli.mjs +0 -0
- package/bin/create-preset.mjs +0 -0
- package/dist/compiled/composables/useDataProvider.mjs +6 -6
- package/dist/compiled/composables/useKatluxForm.mjs +23 -4
- package/dist/compiled/composables/usePresetComponent.mjs +1 -1
- package/dist/compiled/composables/useVirtualScroll.mjs +24 -11
- package/dist/compiled/utils/sanitize.mjs +39 -0
- package/dist/module.json +1 -1
- package/dist/runtime/components/KCheckbox/KCheckbox.global.d.vue.ts +11 -0
- package/dist/runtime/components/KCheckbox/KCheckbox.global.vue +4 -3
- package/dist/runtime/components/KCheckbox/KCheckbox.global.vue.d.ts +11 -0
- package/dist/runtime/components/KCheckbox/KCheckbox.logic.d.ts +5 -0
- package/dist/runtime/components/KCheckbox/KCheckbox.logic.js +4 -0
- package/dist/runtime/components/KCombobox/KCombobox.logic.js +3 -1
- package/dist/runtime/components/KDatatable/KDatatable.logic.d.ts +1 -1
- package/dist/runtime/components/KMaskTextbox/KMaskTextbox.logic.js +2 -0
- package/dist/runtime/components/KRadiobox/KRadiobox.global.vue +1 -1
- package/dist/runtime/components/KRangeSlider/KRangeSlider.global.vue +1 -1
- package/dist/runtime/components/KSlider/KSlider.global.vue +1 -1
- package/dist/runtime/components/KTextarea/KTextarea.global.vue +1 -1
- package/dist/runtime/components/KToast/KToast.global.d.vue.ts +1 -1
- package/dist/runtime/components/KToast/KToast.global.vue.d.ts +1 -1
- package/dist/runtime/components/KTree/KTree.global.d.vue.ts +1 -1
- package/dist/runtime/components/KTree/KTree.global.vue +2 -0
- package/dist/runtime/components/KTree/KTree.global.vue.d.ts +1 -1
- package/dist/runtime/components/KTree/KTree.logic.js +38 -12
- package/dist/runtime/composables/useDataProvider.d.ts +1 -1
- package/dist/runtime/composables/useDataProvider.js +6 -6
- package/dist/runtime/composables/useKatluxForm.js +23 -4
- package/dist/runtime/composables/usePresetComponent.js +1 -1
- package/dist/runtime/composables/useVirtualScroll.js +24 -11
- package/dist/runtime/presets/default/components/KCheckbox/KCheckbox.d.vue.ts +9 -3
- package/dist/runtime/presets/default/components/KCheckbox/KCheckbox.vue +35 -12
- package/dist/runtime/presets/default/components/KCheckbox/KCheckbox.vue.d.ts +9 -3
- package/dist/runtime/presets/default/components/KDatatable/KDatatable.vue +109 -19
- package/dist/runtime/presets/default/components/KIcon/KIcon.vue +5 -2
- package/dist/runtime/presets/default/components/KRadiobox/KRadiobox.vue +1 -0
- package/dist/runtime/presets/default/components/KTree/KTree.d.vue.ts +3 -3
- package/dist/runtime/presets/default/components/KTree/KTree.vue +245 -115
- package/dist/runtime/presets/default/components/KTree/KTree.vue.d.ts +3 -3
- package/dist/runtime/presets/default/components/KTree/KTreeNodeItem.d.vue.ts +27 -0
- package/dist/runtime/presets/default/components/KTree/KTreeNodeItem.vue +179 -0
- package/dist/runtime/presets/default/components/KTree/KTreeNodeItem.vue.d.ts +27 -0
- package/dist/runtime/utils/sanitize.d.ts +5 -0
- package/dist/runtime/utils/sanitize.js +39 -0
- package/package.json +6 -3
package/bin/cli.mjs
CHANGED
|
File without changes
|
package/bin/create-preset.mjs
CHANGED
|
File without changes
|
|
@@ -19,10 +19,10 @@ export function useDataProvider(provider, options) {
|
|
|
19
19
|
if (!activeProvider) return [];
|
|
20
20
|
if (Array.isArray(activeProvider.allVisibleRows) && activeProvider.allVisibleRows.length > 0) return activeProvider.allVisibleRows;
|
|
21
21
|
if (Array.isArray(activeProvider.allVisibleRows?.value) && activeProvider.allVisibleRows.value.length > 0) return activeProvider.allVisibleRows.value;
|
|
22
|
-
if (Array.isArray(activeProvider.rowMap)
|
|
23
|
-
if (Array.isArray(activeProvider.rowMap?.value)
|
|
24
|
-
if (Array.isArray(activeProvider.allVisibleNodes)
|
|
25
|
-
if (Array.isArray(activeProvider.allVisibleNodes?.value)
|
|
22
|
+
if (Array.isArray(activeProvider.rowMap)) return activeProvider.rowMap;
|
|
23
|
+
if (Array.isArray(activeProvider.rowMap?.value)) return activeProvider.rowMap.value;
|
|
24
|
+
if (Array.isArray(activeProvider.allVisibleNodes)) return activeProvider.allVisibleNodes;
|
|
25
|
+
if (Array.isArray(activeProvider.allVisibleNodes?.value)) return activeProvider.allVisibleNodes.value;
|
|
26
26
|
if (Array.isArray(activeProvider.allData) && activeProvider.allData.length > 0) return activeProvider.allData;
|
|
27
27
|
if (Array.isArray(activeProvider.allData?.value) && activeProvider.allData.value.length > 0) return activeProvider.allData.value;
|
|
28
28
|
if (Array.isArray(activeProvider.data) && activeProvider.data.length > 0) return activeProvider.data;
|
|
@@ -164,10 +164,10 @@ export function useDataProvider(provider, options) {
|
|
|
164
164
|
}
|
|
165
165
|
pageSize.value = size;
|
|
166
166
|
};
|
|
167
|
-
const setFilter = (f) => {
|
|
167
|
+
const setFilter = (f, immediate = false) => {
|
|
168
168
|
if (!activeProvider) return;
|
|
169
169
|
if (typeof activeProvider.setFilter === "function") {
|
|
170
|
-
activeProvider.setFilter(f);
|
|
170
|
+
activeProvider.setFilter(f, immediate);
|
|
171
171
|
} else if ("filter" in activeProvider) {
|
|
172
172
|
if (isRef(activeProvider.filter) || typeof activeProvider.filter === "object" && activeProvider.filter !== null && "value" in activeProvider.filter) {
|
|
173
173
|
activeProvider.filter.value = f;
|
|
@@ -144,6 +144,7 @@ export function useKatluxForm(options = {}) {
|
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
let validationSeq = 0;
|
|
147
|
+
let submitSeq = 0;
|
|
147
148
|
function validate(targetPath) {
|
|
148
149
|
const seq = ++validationSeq;
|
|
149
150
|
const result = runValidation(values);
|
|
@@ -195,6 +196,8 @@ export function useKatluxForm(options = {}) {
|
|
|
195
196
|
dirtyFields.value = {};
|
|
196
197
|
submitCount.value = 0;
|
|
197
198
|
isSubmitting.value = false;
|
|
199
|
+
submitSeq++;
|
|
200
|
+
validationSeq++;
|
|
198
201
|
}
|
|
199
202
|
function register(path, regOptions = {}) {
|
|
200
203
|
return {
|
|
@@ -267,25 +270,41 @@ export function useKatluxForm(options = {}) {
|
|
|
267
270
|
if (event && typeof event.preventDefault === "function") {
|
|
268
271
|
event.preventDefault();
|
|
269
272
|
}
|
|
273
|
+
const currentSubmitId = ++submitSeq;
|
|
270
274
|
submitCount.value += 1;
|
|
271
275
|
isSubmitting.value = true;
|
|
272
276
|
try {
|
|
273
|
-
const
|
|
277
|
+
const snapshotValues = deepClone(values);
|
|
278
|
+
const res = await runValidation(snapshotValues);
|
|
279
|
+
if (currentSubmitId !== submitSeq) {
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
274
282
|
const { valid, output, errors: newErrors } = res;
|
|
275
|
-
errors.value = newErrors;
|
|
276
283
|
if (!valid) {
|
|
284
|
+
const errorsToApply = {};
|
|
285
|
+
for (const [errPath, errMsg] of Object.entries(newErrors)) {
|
|
286
|
+
const currentVal = getByPath(values, errPath);
|
|
287
|
+
const snapVal = getByPath(snapshotValues, errPath);
|
|
288
|
+
if (JSON.stringify(currentVal) === JSON.stringify(snapVal)) {
|
|
289
|
+
errorsToApply[errPath] = errMsg;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
errors.value = errorsToApply;
|
|
277
293
|
const firstErrorKey = Object.keys(newErrors)[0];
|
|
278
294
|
if (focusOnError && firstErrorKey) {
|
|
279
295
|
focusFirstInvalid(firstErrorKey);
|
|
280
296
|
}
|
|
281
297
|
if (onInvalid) {
|
|
282
|
-
await onInvalid(newErrors,
|
|
298
|
+
await onInvalid(newErrors, snapshotValues);
|
|
283
299
|
}
|
|
284
300
|
return;
|
|
285
301
|
}
|
|
302
|
+
errors.value = {};
|
|
286
303
|
await onValid(output, event);
|
|
287
304
|
} finally {
|
|
288
|
-
|
|
305
|
+
if (currentSubmitId === submitSeq) {
|
|
306
|
+
isSubmitting.value = false;
|
|
307
|
+
}
|
|
289
308
|
}
|
|
290
309
|
};
|
|
291
310
|
}
|
|
@@ -48,7 +48,7 @@ export function usePresetComponent(componentBaseName, defaultComponent) {
|
|
|
48
48
|
const externalLoaders = _loadersRegistry[presetName];
|
|
49
49
|
if (externalLoaders) {
|
|
50
50
|
const key = `./components/${componentBaseName}/${componentBaseName}.vue`;
|
|
51
|
-
const candidate = externalLoaders[key];
|
|
51
|
+
const candidate = externalLoaders[key] || externalLoaders[componentBaseName] || externalLoaders[`${componentBaseName}.vue`];
|
|
52
52
|
if (candidate) {
|
|
53
53
|
if (isDirectComponent(candidate)) {
|
|
54
54
|
return candidate;
|
|
@@ -179,9 +179,10 @@ export function useVirtualScroll(options) {
|
|
|
179
179
|
const remainingRows = Math.max(0, totalRows.value - endRowIndex.value);
|
|
180
180
|
return remainingRows * baseItemHeight.value;
|
|
181
181
|
});
|
|
182
|
-
watch(totalHeight, (newTotal) => {
|
|
183
|
-
|
|
184
|
-
|
|
182
|
+
watch([totalHeight, viewportHeight], ([newTotal, newVp]) => {
|
|
183
|
+
const maxScroll = Math.max(0, newTotal - newVp);
|
|
184
|
+
if (scrollTop.value > maxScroll) {
|
|
185
|
+
scrollTop.value = maxScroll;
|
|
185
186
|
if (containerRef.value) {
|
|
186
187
|
containerRef.value.scrollTop = scrollTop.value;
|
|
187
188
|
}
|
|
@@ -212,10 +213,16 @@ export function useVirtualScroll(options) {
|
|
|
212
213
|
const targetScrollTop2 = Math.max(0, (rowOffsets.value[index] || 0) - offset);
|
|
213
214
|
scrollTop.value = targetScrollTop2;
|
|
214
215
|
if (containerRef.value) {
|
|
215
|
-
containerRef.value.
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
216
|
+
containerRef.value.scrollTop = targetScrollTop2;
|
|
217
|
+
if (typeof containerRef.value.scrollTo === "function") {
|
|
218
|
+
try {
|
|
219
|
+
containerRef.value.scrollTo({
|
|
220
|
+
top: targetScrollTop2,
|
|
221
|
+
behavior
|
|
222
|
+
});
|
|
223
|
+
} catch {
|
|
224
|
+
}
|
|
225
|
+
}
|
|
219
226
|
}
|
|
220
227
|
return;
|
|
221
228
|
}
|
|
@@ -223,10 +230,16 @@ export function useVirtualScroll(options) {
|
|
|
223
230
|
const targetScrollTop = Math.max(0, targetRow * baseItemHeight.value - offset);
|
|
224
231
|
scrollTop.value = targetScrollTop;
|
|
225
232
|
if (containerRef.value) {
|
|
226
|
-
containerRef.value.
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
233
|
+
containerRef.value.scrollTop = targetScrollTop;
|
|
234
|
+
if (typeof containerRef.value.scrollTo === "function") {
|
|
235
|
+
try {
|
|
236
|
+
containerRef.value.scrollTo({
|
|
237
|
+
top: targetScrollTop,
|
|
238
|
+
behavior
|
|
239
|
+
});
|
|
240
|
+
} catch {
|
|
241
|
+
}
|
|
242
|
+
}
|
|
230
243
|
}
|
|
231
244
|
};
|
|
232
245
|
return {
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
function decodeHtmlEntities(str) {
|
|
2
|
+
return str.replace(/&#x([0-9a-f]+);?/gi, (_, hex) => String.fromCharCode(parseInt(hex, 16))).replace(/&#([0-9]+);?/g, (_, dec) => String.fromCharCode(parseInt(dec, 10))).replace(/&tab;/gi, " ").replace(/&newline;/gi, "\n").replace(/:/gi, ":");
|
|
3
|
+
}
|
|
4
|
+
export function sanitizeHtml(input) {
|
|
5
|
+
if (!input || typeof input !== "string") return "";
|
|
6
|
+
let sanitized = input;
|
|
7
|
+
const dangerousTags = [
|
|
8
|
+
"script",
|
|
9
|
+
"iframe",
|
|
10
|
+
"object",
|
|
11
|
+
"embed",
|
|
12
|
+
"applet",
|
|
13
|
+
"meta",
|
|
14
|
+
"link",
|
|
15
|
+
"base",
|
|
16
|
+
"style",
|
|
17
|
+
"form",
|
|
18
|
+
"input",
|
|
19
|
+
"button",
|
|
20
|
+
"textarea"
|
|
21
|
+
];
|
|
22
|
+
for (const tag of dangerousTags) {
|
|
23
|
+
const tagRegex = new RegExp(`<${tag}\\b[\\s\\S]*?<\\/${tag}>|<${tag}\\b[^>]*\\/?>`, "gi");
|
|
24
|
+
sanitized = sanitized.replace(tagRegex, "");
|
|
25
|
+
}
|
|
26
|
+
sanitized = sanitized.replace(/[\s/]+on[a-zA-Z0-9_-]+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi, "");
|
|
27
|
+
sanitized = sanitized.replace(
|
|
28
|
+
/[\s/]+(?:href|xlink:href|src|action|data|formaction)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/gi,
|
|
29
|
+
(match, qDouble, qSingle, unquoted) => {
|
|
30
|
+
const rawVal = qDouble ?? qSingle ?? unquoted ?? "";
|
|
31
|
+
const normalized = decodeHtmlEntities(rawVal).replace(/[\u0000-\u001F\u007F-\u009F\s]/g, "").toLowerCase();
|
|
32
|
+
if (normalized.startsWith("javascript:") || normalized.startsWith("vbscript:") || normalized.startsWith("data:text/html") || normalized.startsWith("data:image/svg+xml")) {
|
|
33
|
+
return "";
|
|
34
|
+
}
|
|
35
|
+
return match;
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
return sanitized;
|
|
39
|
+
}
|
package/dist/module.json
CHANGED
|
@@ -25,6 +25,10 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
25
25
|
type: StringConstructor;
|
|
26
26
|
default: undefined;
|
|
27
27
|
};
|
|
28
|
+
indeterminate: {
|
|
29
|
+
type: BooleanConstructor;
|
|
30
|
+
default: boolean;
|
|
31
|
+
};
|
|
28
32
|
modelValue: {
|
|
29
33
|
type: import("vue").PropType<any>;
|
|
30
34
|
};
|
|
@@ -32,6 +36,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
32
36
|
"update:modelValue": (value: any) => any;
|
|
33
37
|
} & {
|
|
34
38
|
blur: (event: FocusEvent) => any;
|
|
39
|
+
"update:indeterminate": (value: boolean) => any;
|
|
35
40
|
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
36
41
|
disabled: {
|
|
37
42
|
type: BooleanConstructor;
|
|
@@ -58,18 +63,24 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
58
63
|
type: StringConstructor;
|
|
59
64
|
default: undefined;
|
|
60
65
|
};
|
|
66
|
+
indeterminate: {
|
|
67
|
+
type: BooleanConstructor;
|
|
68
|
+
default: boolean;
|
|
69
|
+
};
|
|
61
70
|
modelValue: {
|
|
62
71
|
type: import("vue").PropType<any>;
|
|
63
72
|
};
|
|
64
73
|
}>> & Readonly<{
|
|
65
74
|
"onUpdate:modelValue"?: ((value: any) => any) | undefined;
|
|
66
75
|
onBlur?: ((event: FocusEvent) => any) | undefined;
|
|
76
|
+
"onUpdate:indeterminate"?: ((value: boolean) => any) | undefined;
|
|
67
77
|
}>, {
|
|
68
78
|
label: string;
|
|
69
79
|
disabled: boolean;
|
|
70
80
|
validation: "error" | "success" | "warning" | null | undefined;
|
|
71
81
|
validationText: string;
|
|
72
82
|
idKey: string;
|
|
83
|
+
indeterminate: boolean;
|
|
73
84
|
value: any;
|
|
74
85
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
75
86
|
declare const _default: typeof __VLS_export;
|
|
@@ -7,7 +7,7 @@ const props = defineProps(KCheckboxDefaultProps);
|
|
|
7
7
|
const model = defineModel();
|
|
8
8
|
const { isDisabled, checkboxValue } = useKCheckboxLogic(props, model);
|
|
9
9
|
const presetComponent = usePresetComponent("KCheckbox", KCheckboxDefault);
|
|
10
|
-
defineEmits(["blur"]);
|
|
10
|
+
const emit = defineEmits(["blur", "update:indeterminate"]);
|
|
11
11
|
const templateProps = computed(() => ({
|
|
12
12
|
model: model.value,
|
|
13
13
|
checkboxValue: checkboxValue.value,
|
|
@@ -15,12 +15,13 @@ const templateProps = computed(() => ({
|
|
|
15
15
|
validation: props.validation,
|
|
16
16
|
validationText: props.validationText,
|
|
17
17
|
label: props.label,
|
|
18
|
-
idKey: props.idKey
|
|
18
|
+
idKey: props.idKey,
|
|
19
|
+
indeterminate: props.indeterminate
|
|
19
20
|
}));
|
|
20
21
|
</script>
|
|
21
22
|
|
|
22
23
|
<template lang="pug">
|
|
23
|
-
component(:is="presetComponent" v-bind="templateProps" @update:model="model = $event" @blur="
|
|
24
|
+
component(:is="presetComponent" v-bind="{ ...templateProps, ...$attrs }" @update:model="model = $event" @update:indeterminate="emit('update:indeterminate', $event)" @blur="emit('blur', $event)")
|
|
24
25
|
template(v-for="(_, slot) in $slots" #[slot]="scope")
|
|
25
26
|
slot(:name="slot" v-bind="scope")
|
|
26
27
|
</template>
|
|
@@ -25,6 +25,10 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
25
25
|
type: StringConstructor;
|
|
26
26
|
default: undefined;
|
|
27
27
|
};
|
|
28
|
+
indeterminate: {
|
|
29
|
+
type: BooleanConstructor;
|
|
30
|
+
default: boolean;
|
|
31
|
+
};
|
|
28
32
|
modelValue: {
|
|
29
33
|
type: import("vue").PropType<any>;
|
|
30
34
|
};
|
|
@@ -32,6 +36,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
32
36
|
"update:modelValue": (value: any) => any;
|
|
33
37
|
} & {
|
|
34
38
|
blur: (event: FocusEvent) => any;
|
|
39
|
+
"update:indeterminate": (value: boolean) => any;
|
|
35
40
|
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
36
41
|
disabled: {
|
|
37
42
|
type: BooleanConstructor;
|
|
@@ -58,18 +63,24 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
58
63
|
type: StringConstructor;
|
|
59
64
|
default: undefined;
|
|
60
65
|
};
|
|
66
|
+
indeterminate: {
|
|
67
|
+
type: BooleanConstructor;
|
|
68
|
+
default: boolean;
|
|
69
|
+
};
|
|
61
70
|
modelValue: {
|
|
62
71
|
type: import("vue").PropType<any>;
|
|
63
72
|
};
|
|
64
73
|
}>> & Readonly<{
|
|
65
74
|
"onUpdate:modelValue"?: ((value: any) => any) | undefined;
|
|
66
75
|
onBlur?: ((event: FocusEvent) => any) | undefined;
|
|
76
|
+
"onUpdate:indeterminate"?: ((value: boolean) => any) | undefined;
|
|
67
77
|
}>, {
|
|
68
78
|
label: string;
|
|
69
79
|
disabled: boolean;
|
|
70
80
|
validation: "error" | "success" | "warning" | null | undefined;
|
|
71
81
|
validationText: string;
|
|
72
82
|
idKey: string;
|
|
83
|
+
indeterminate: boolean;
|
|
73
84
|
value: any;
|
|
74
85
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
75
86
|
declare const _default: typeof __VLS_export;
|
|
@@ -6,6 +6,7 @@ export interface KCheckboxProps {
|
|
|
6
6
|
validationText?: string;
|
|
7
7
|
label?: string;
|
|
8
8
|
idKey?: string;
|
|
9
|
+
indeterminate?: boolean;
|
|
9
10
|
}
|
|
10
11
|
/**
|
|
11
12
|
* KCheckbox Logic Composable
|
|
@@ -47,4 +48,8 @@ export declare const KCheckboxDefaultProps: {
|
|
|
47
48
|
type: StringConstructor;
|
|
48
49
|
default: undefined;
|
|
49
50
|
};
|
|
51
|
+
indeterminate: {
|
|
52
|
+
type: BooleanConstructor;
|
|
53
|
+
default: boolean;
|
|
54
|
+
};
|
|
50
55
|
};
|
|
@@ -473,7 +473,7 @@ export function useKComboboxLogic(props, emit) {
|
|
|
473
473
|
}
|
|
474
474
|
}
|
|
475
475
|
function resolveSelectedFromValue() {
|
|
476
|
-
if (props.modelValue === void 0 || props.modelValue === null) {
|
|
476
|
+
if (props.modelValue === void 0 || props.modelValue === null || props.modelValue === "") {
|
|
477
477
|
selectedItems.value = null;
|
|
478
478
|
return;
|
|
479
479
|
}
|
|
@@ -490,6 +490,8 @@ export function useKComboboxLogic(props, emit) {
|
|
|
490
490
|
selectedItems.value = matchedItems;
|
|
491
491
|
} else if (typeof props.modelValue === "object") {
|
|
492
492
|
selectedItems.value = Array.isArray(props.modelValue) ? props.modelValue : [props.modelValue];
|
|
493
|
+
} else {
|
|
494
|
+
selectedItems.value = null;
|
|
493
495
|
}
|
|
494
496
|
}
|
|
495
497
|
resolveSelectedFromValue();
|
|
@@ -46,7 +46,7 @@ export declare function useKDatatableLogic(props: KDatatableProps, emit?: KDatat
|
|
|
46
46
|
setCurrentPage: (page: number) => void;
|
|
47
47
|
setPageSize: (size: number) => void;
|
|
48
48
|
setSortList: (sortList: IDataSort[]) => void;
|
|
49
|
-
setFilter: (filter: IDataFilter | null) => void;
|
|
49
|
+
setFilter: (filter: IDataFilter | null, immediate?: boolean) => void;
|
|
50
50
|
getRowKey: (row: any, index: number) => string | number;
|
|
51
51
|
pageData: import("vue").ComputedRef<any[]>;
|
|
52
52
|
};
|
|
@@ -71,6 +71,7 @@ function getMaskPatternDef(mask, position) {
|
|
|
71
71
|
const char = mask[position];
|
|
72
72
|
switch (char) {
|
|
73
73
|
case "9":
|
|
74
|
+
case "#":
|
|
74
75
|
return { pattern: /[0-9]/, length: 1 };
|
|
75
76
|
case "A":
|
|
76
77
|
return {
|
|
@@ -100,6 +101,7 @@ function getPatternLength(mask, position) {
|
|
|
100
101
|
return def ? def.length : 1;
|
|
101
102
|
}
|
|
102
103
|
export function applyMask(rawValue, mask) {
|
|
104
|
+
if (!rawValue) return "";
|
|
103
105
|
let result = "";
|
|
104
106
|
let valueIndex = 0;
|
|
105
107
|
let maskIndex = 0;
|
|
@@ -18,7 +18,7 @@ const templateProps = computed(() => ({
|
|
|
18
18
|
</script>
|
|
19
19
|
|
|
20
20
|
<template lang="pug">
|
|
21
|
-
component(:is="presetComponent" v-bind="templateProps" v-model="model")
|
|
21
|
+
component(:is="presetComponent" v-bind="{ ...templateProps, ...$attrs }" v-model="model")
|
|
22
22
|
template(v-for="(_, slot) in $slots" #[slot]="scope")
|
|
23
23
|
slot(:name="slot" v-bind="scope")
|
|
24
24
|
</template>
|
|
@@ -32,7 +32,7 @@ const handleUpdateValue = (val) => {
|
|
|
32
32
|
</script>
|
|
33
33
|
|
|
34
34
|
<template lang="pug">
|
|
35
|
-
component(:is="presetComponent" v-bind="templateProps" @update:value="handleUpdateValue")
|
|
35
|
+
component(:is="presetComponent" v-bind="{ ...templateProps, ...$attrs }" @update:value="handleUpdateValue")
|
|
36
36
|
template(v-for="(_, slot) in $slots" #[slot]="scope")
|
|
37
37
|
slot(:name="slot" v-bind="scope")
|
|
38
38
|
</template>
|
|
@@ -18,5 +18,5 @@ const templateProps = computed(() => ({
|
|
|
18
18
|
</script>
|
|
19
19
|
|
|
20
20
|
<template lang="pug">
|
|
21
|
-
component(:is="presetComponent" v-bind="templateProps" @update:text="text = $event")
|
|
21
|
+
component(:is="presetComponent" v-bind="{ ...templateProps, ...$attrs }" @update:text="text = $event")
|
|
22
22
|
</template>
|
|
@@ -73,8 +73,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
73
73
|
title: string;
|
|
74
74
|
text: string;
|
|
75
75
|
timeout: number;
|
|
76
|
-
teleport: boolean;
|
|
77
76
|
pauseOnHover: boolean;
|
|
77
|
+
teleport: boolean;
|
|
78
78
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
79
79
|
declare const _default: typeof __VLS_export;
|
|
80
80
|
export default _default;
|
|
@@ -73,8 +73,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
73
73
|
title: string;
|
|
74
74
|
text: string;
|
|
75
75
|
timeout: number;
|
|
76
|
-
teleport: boolean;
|
|
77
76
|
pauseOnHover: boolean;
|
|
77
|
+
teleport: boolean;
|
|
78
78
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
79
79
|
declare const _default: typeof __VLS_export;
|
|
80
80
|
export default _default;
|
|
@@ -162,8 +162,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
162
162
|
viewportHeight: number;
|
|
163
163
|
expandedNodes: (string | number)[] | Set<string | number>;
|
|
164
164
|
iconField: string;
|
|
165
|
-
isNodeSelected: (node: any) => boolean;
|
|
166
165
|
selectable: boolean;
|
|
166
|
+
isNodeSelected: (node: any) => boolean;
|
|
167
167
|
selectedNode: any;
|
|
168
168
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
169
169
|
declare const _default: typeof __VLS_export;
|
|
@@ -23,6 +23,8 @@ const templateProps = computed(() => ({
|
|
|
23
23
|
isNodeSelected: props.isNodeSelected,
|
|
24
24
|
selectable: props.selectable,
|
|
25
25
|
searchtext: props.searchtext,
|
|
26
|
+
modelValue: props.modelValue,
|
|
27
|
+
selectedNode: props.selectedNode,
|
|
26
28
|
toggleNode,
|
|
27
29
|
selectNode,
|
|
28
30
|
dataProvider: props.dataProvider,
|
|
@@ -162,8 +162,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
162
162
|
viewportHeight: number;
|
|
163
163
|
expandedNodes: (string | number)[] | Set<string | number>;
|
|
164
164
|
iconField: string;
|
|
165
|
-
isNodeSelected: (node: any) => boolean;
|
|
166
165
|
selectable: boolean;
|
|
166
|
+
isNodeSelected: (node: any) => boolean;
|
|
167
167
|
selectedNode: any;
|
|
168
168
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
169
169
|
declare const _default: typeof __VLS_export;
|
|
@@ -70,33 +70,58 @@ export const KTreeDefaultProps = {
|
|
|
70
70
|
export function useKTreeLogic(props, emit) {
|
|
71
71
|
const { pageData, setFilter } = useDataProvider(props.dataProvider);
|
|
72
72
|
const visibleRows = computed(() => pageData.value || []);
|
|
73
|
+
let isFirstSearchRun = true;
|
|
73
74
|
watch(() => props.searchtext, (newVal) => {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
75
|
+
const filterObj = newVal ? {
|
|
76
|
+
operator: EDataFilterOperator.In,
|
|
77
|
+
field: { [props.labelField || "name"]: newVal },
|
|
78
|
+
active: true
|
|
79
|
+
} : null;
|
|
80
|
+
if (typeof props.dataProvider?.setFilter === "function") {
|
|
81
|
+
props.dataProvider.setFilter(filterObj, true);
|
|
80
82
|
} else {
|
|
81
|
-
setFilter(
|
|
83
|
+
setFilter(filterObj, true);
|
|
82
84
|
}
|
|
83
|
-
if (newVal !== void 0) {
|
|
85
|
+
if (!isFirstSearchRun && newVal !== void 0) {
|
|
84
86
|
emit?.("update:searchtext", newVal);
|
|
85
87
|
}
|
|
86
|
-
|
|
88
|
+
isFirstSearchRun = false;
|
|
89
|
+
}, { immediate: true });
|
|
90
|
+
const syncProviderExpanded = (nodes) => {
|
|
91
|
+
if (props.dataProvider) {
|
|
92
|
+
props.dataProvider.expandedNodes = nodes;
|
|
93
|
+
if ("_allVisibleRowsCache" in props.dataProvider) {
|
|
94
|
+
props.dataProvider._allVisibleRowsCache = null;
|
|
95
|
+
}
|
|
96
|
+
if (typeof props.dataProvider.updatePageData === "function") {
|
|
97
|
+
props.dataProvider.updatePageData();
|
|
98
|
+
}
|
|
99
|
+
if (typeof props.dataProvider.notify === "function") {
|
|
100
|
+
props.dataProvider.notify();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
};
|
|
87
104
|
const rawExpanded = props.dataProvider?.expandedNodes;
|
|
88
105
|
const expandedNodes = ref(
|
|
89
106
|
props.expandedNodes ? props.expandedNodes instanceof Set ? props.expandedNodes : new Set(props.expandedNodes) : rawExpanded ? "value" in rawExpanded ? rawExpanded.value : rawExpanded : /* @__PURE__ */ new Set()
|
|
90
107
|
);
|
|
108
|
+
if (props.expandedNodes) {
|
|
109
|
+
syncProviderExpanded(expandedNodes.value);
|
|
110
|
+
}
|
|
91
111
|
watch(() => props.expandedNodes, (val) => {
|
|
92
112
|
if (val !== void 0) {
|
|
93
|
-
|
|
113
|
+
const setVal = val instanceof Set ? val : new Set(val);
|
|
114
|
+
expandedNodes.value = setVal;
|
|
115
|
+
syncProviderExpanded(setVal);
|
|
94
116
|
}
|
|
95
117
|
}, { deep: true });
|
|
96
118
|
const toggleNode = (nodeId) => {
|
|
97
119
|
if (props.disabled) return;
|
|
98
120
|
if (typeof props.dataProvider?.toggleNode === "function") {
|
|
99
121
|
props.dataProvider.toggleNode(nodeId);
|
|
122
|
+
const raw = props.dataProvider.expandedNodes;
|
|
123
|
+
const current = raw ? "value" in raw ? raw.value : raw : [];
|
|
124
|
+
expandedNodes.value = new Set(current);
|
|
100
125
|
} else {
|
|
101
126
|
if (expandedNodes.value.has(nodeId)) {
|
|
102
127
|
expandedNodes.value.delete(nodeId);
|
|
@@ -104,11 +129,12 @@ export function useKTreeLogic(props, emit) {
|
|
|
104
129
|
expandedNodes.value.add(nodeId);
|
|
105
130
|
}
|
|
106
131
|
}
|
|
132
|
+
const emitted = Array.isArray(props.expandedNodes) ? Array.from(expandedNodes.value) : expandedNodes.value;
|
|
107
133
|
emit?.("node-toggle", nodeId);
|
|
108
|
-
emit?.("update:expandedNodes",
|
|
134
|
+
emit?.("update:expandedNodes", emitted);
|
|
109
135
|
};
|
|
110
136
|
const selectNode = (node) => {
|
|
111
|
-
if (props.disabled
|
|
137
|
+
if (props.disabled) return;
|
|
112
138
|
emit?.("update:modelValue", node);
|
|
113
139
|
emit?.("update:selectedNode", node);
|
|
114
140
|
emit?.("select", node);
|
|
@@ -24,7 +24,7 @@ export interface IUseDataProviderReturn<T = TDataRow> {
|
|
|
24
24
|
selectAll: Ref<boolean>;
|
|
25
25
|
setCurrentPage: (page: number) => void;
|
|
26
26
|
setPageSize: (size: number) => void;
|
|
27
|
-
setFilter: (filter: IDataFilter | null) => void;
|
|
27
|
+
setFilter: (filter: IDataFilter | null, immediate?: boolean) => void;
|
|
28
28
|
setSortList: (sortList: IDataSort[]) => void;
|
|
29
29
|
refresh: (hardRefresh?: boolean) => Promise<void>;
|
|
30
30
|
loadPageData: (options?: {
|
|
@@ -19,10 +19,10 @@ export function useDataProvider(provider, options) {
|
|
|
19
19
|
if (!activeProvider) return [];
|
|
20
20
|
if (Array.isArray(activeProvider.allVisibleRows) && activeProvider.allVisibleRows.length > 0) return activeProvider.allVisibleRows;
|
|
21
21
|
if (Array.isArray(activeProvider.allVisibleRows?.value) && activeProvider.allVisibleRows.value.length > 0) return activeProvider.allVisibleRows.value;
|
|
22
|
-
if (Array.isArray(activeProvider.rowMap)
|
|
23
|
-
if (Array.isArray(activeProvider.rowMap?.value)
|
|
24
|
-
if (Array.isArray(activeProvider.allVisibleNodes)
|
|
25
|
-
if (Array.isArray(activeProvider.allVisibleNodes?.value)
|
|
22
|
+
if (Array.isArray(activeProvider.rowMap)) return activeProvider.rowMap;
|
|
23
|
+
if (Array.isArray(activeProvider.rowMap?.value)) return activeProvider.rowMap.value;
|
|
24
|
+
if (Array.isArray(activeProvider.allVisibleNodes)) return activeProvider.allVisibleNodes;
|
|
25
|
+
if (Array.isArray(activeProvider.allVisibleNodes?.value)) return activeProvider.allVisibleNodes.value;
|
|
26
26
|
if (Array.isArray(activeProvider.allData) && activeProvider.allData.length > 0) return activeProvider.allData;
|
|
27
27
|
if (Array.isArray(activeProvider.allData?.value) && activeProvider.allData.value.length > 0) return activeProvider.allData.value;
|
|
28
28
|
if (Array.isArray(activeProvider.data) && activeProvider.data.length > 0) return activeProvider.data;
|
|
@@ -164,10 +164,10 @@ export function useDataProvider(provider, options) {
|
|
|
164
164
|
}
|
|
165
165
|
pageSize.value = size;
|
|
166
166
|
};
|
|
167
|
-
const setFilter = (f) => {
|
|
167
|
+
const setFilter = (f, immediate = false) => {
|
|
168
168
|
if (!activeProvider) return;
|
|
169
169
|
if (typeof activeProvider.setFilter === "function") {
|
|
170
|
-
activeProvider.setFilter(f);
|
|
170
|
+
activeProvider.setFilter(f, immediate);
|
|
171
171
|
} else if ("filter" in activeProvider) {
|
|
172
172
|
if (isRef(activeProvider.filter) || typeof activeProvider.filter === "object" && activeProvider.filter !== null && "value" in activeProvider.filter) {
|
|
173
173
|
activeProvider.filter.value = f;
|