@katlux/toolkit 0.1.1-alpha.122 → 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.d.ts +17 -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/KBulkActions/KBulkActions.global.d.vue.ts +2 -0
- package/dist/runtime/components/KBulkActions/KBulkActions.global.vue +3 -1
- package/dist/runtime/components/KBulkActions/KBulkActions.global.vue.d.ts +2 -0
- package/dist/runtime/components/KBulkActions/KBulkActions.logic.d.ts +1 -0
- package/dist/runtime/components/KBulkActions/KBulkActions.logic.js +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/KBulkActions/KBulkActions.d.vue.ts +1 -0
- package/dist/runtime/presets/default/components/KBulkActions/KBulkActions.vue +2 -1
- package/dist/runtime/presets/default/components/KBulkActions/KBulkActions.vue.d.ts +1 -0
- 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 +111 -21
- 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 +17 -4
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
<template lang="pug">
|
|
2
|
+
.tree-node(
|
|
3
|
+
:data-node-id="node.key"
|
|
4
|
+
:class="{ 'has-children': hasChildren, 'is-selected': isSelected(node.row) }"
|
|
5
|
+
:style="{ '--tree-depth': node.row.__treeNode?.depth ?? node.row.depth ?? 0 }"
|
|
6
|
+
role="treeitem"
|
|
7
|
+
:aria-expanded="hasChildren ? isExpanded : undefined"
|
|
8
|
+
:aria-level="((node.row.__treeNode?.depth ?? node.row.depth ?? 0) + 1)"
|
|
9
|
+
:aria-selected="isSelected(node.row)"
|
|
10
|
+
:tabindex="isFocused ? 0 : -1"
|
|
11
|
+
@focus="$emit('focus', node.row, node.key)"
|
|
12
|
+
@keydown.stop="$emit('keydown', $event, node.row)"
|
|
13
|
+
)
|
|
14
|
+
.node-content
|
|
15
|
+
// Toggle
|
|
16
|
+
.tree-toggle(
|
|
17
|
+
v-if="hasChildren"
|
|
18
|
+
@click.stop="$emit('toggle', node.row.__treeNode?.id ?? node.row.id)"
|
|
19
|
+
:class="{ expanded: isExpanded }"
|
|
20
|
+
role="button"
|
|
21
|
+
:aria-label="t('Toggle node')"
|
|
22
|
+
tabindex="-1"
|
|
23
|
+
)
|
|
24
|
+
KIcon(iconname="chevron" :width="12" :height="12" :rotate="isExpanded ? '90' : '0'")
|
|
25
|
+
|
|
26
|
+
.tree-spacer(v-else)
|
|
27
|
+
|
|
28
|
+
// Content
|
|
29
|
+
.node-label(@click="$emit('click', node.row)")
|
|
30
|
+
.selection-control(v-if="selectable")
|
|
31
|
+
KCheckbox(
|
|
32
|
+
:modelValue="isSelected(node.row)"
|
|
33
|
+
@update:modelValue="$emit('click', node.row)"
|
|
34
|
+
@click.stop
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
slot(name="node" :node="node.row.__treeNode || node.row" :data="node.row")
|
|
38
|
+
slot(name="item" :node="node.row.__treeNode || node.row" :data="node.row")
|
|
39
|
+
slot(name="default" :node="node.row.__treeNode || node.row" :data="node.row")
|
|
40
|
+
.default-item
|
|
41
|
+
KIcon(v-if="iconField && node.row[iconField]" :iconname="node.row[iconField]" :width="16" :height="16")
|
|
42
|
+
span {{ node.row[labelField] }}
|
|
43
|
+
|
|
44
|
+
.tree-node-group(v-if="node.children && node.children.length > 0" role="group")
|
|
45
|
+
KTreeNodeItem(
|
|
46
|
+
v-for="child in node.children"
|
|
47
|
+
:key="child.key"
|
|
48
|
+
:node="child"
|
|
49
|
+
:labelField="labelField"
|
|
50
|
+
:iconField="iconField"
|
|
51
|
+
:selectable="selectable"
|
|
52
|
+
:focusedNodeId="focusedNodeId"
|
|
53
|
+
:isSelected="isSelected"
|
|
54
|
+
@focus="(row, key) => $emit('focus', row, key)"
|
|
55
|
+
@click="row => $emit('click', row)"
|
|
56
|
+
@toggle="id => $emit('toggle', id)"
|
|
57
|
+
@keydown="(e, row) => $emit('keydown', e, row)"
|
|
58
|
+
)
|
|
59
|
+
template(v-for="(_, slot) in $slots" #[slot]="scope")
|
|
60
|
+
slot(:name="slot" v-bind="scope")
|
|
61
|
+
</template>
|
|
62
|
+
|
|
63
|
+
<script lang="ts" setup>
|
|
64
|
+
import { computed } from 'vue'
|
|
65
|
+
import type { TTreeRow } from '@katlux/providers'
|
|
66
|
+
import { useKatluxI18n } from '#toolkit/composables/useKatluxI18n'
|
|
67
|
+
|
|
68
|
+
export interface ITreeRenderNode {
|
|
69
|
+
key: string | number
|
|
70
|
+
row: TTreeRow
|
|
71
|
+
children: ITreeRenderNode[]
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const { t } = useKatluxI18n()
|
|
75
|
+
|
|
76
|
+
const props = defineProps<{
|
|
77
|
+
node: ITreeRenderNode
|
|
78
|
+
labelField: string
|
|
79
|
+
iconField: string
|
|
80
|
+
selectable: boolean
|
|
81
|
+
focusedNodeId: string | number | null
|
|
82
|
+
isSelected: (row: TTreeRow) => boolean
|
|
83
|
+
}>()
|
|
84
|
+
|
|
85
|
+
defineEmits<{
|
|
86
|
+
(e: 'focus', row: TTreeRow, key: string | number): void
|
|
87
|
+
(e: 'click', row: TTreeRow): void
|
|
88
|
+
(e: 'toggle', id: string | number): void
|
|
89
|
+
(e: 'keydown', event: KeyboardEvent, row: TTreeRow): void
|
|
90
|
+
}>()
|
|
91
|
+
|
|
92
|
+
const hasChildren = computed(() => {
|
|
93
|
+
return Boolean(props.node.row.__treeNode?.hasChildren ?? props.node.row.hasChildren)
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
const isExpanded = computed(() => {
|
|
97
|
+
return Boolean(props.node.row.__treeNode?.isExpanded ?? props.node.row.isExpanded)
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
const isFocused = computed(() => {
|
|
101
|
+
return props.focusedNodeId === props.node.key
|
|
102
|
+
})
|
|
103
|
+
</script>
|
|
104
|
+
|
|
105
|
+
<style lang="scss" scoped>
|
|
106
|
+
.tree-node {
|
|
107
|
+
display: flex;
|
|
108
|
+
flex-direction: column;
|
|
109
|
+
width: 100%;
|
|
110
|
+
transition: background-color 0.2s;
|
|
111
|
+
|
|
112
|
+
&:focus-visible {
|
|
113
|
+
outline: 2px solid var(--primary-color, #3b82f6);
|
|
114
|
+
outline-offset: -2px;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.node-content {
|
|
118
|
+
display: flex;
|
|
119
|
+
align-items: center;
|
|
120
|
+
padding: 4px 8px 4px calc(8px + var(--tree-depth, 0) * var(--tree-indent, 20px));
|
|
121
|
+
min-height: 32px;
|
|
122
|
+
width: 100%;
|
|
123
|
+
gap: 4px;
|
|
124
|
+
cursor: pointer;
|
|
125
|
+
|
|
126
|
+
&:hover {
|
|
127
|
+
background-color: var(--border-color-light, rgba(0, 0, 0, 0.04));
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.tree-toggle {
|
|
132
|
+
cursor: pointer;
|
|
133
|
+
display: inline-flex;
|
|
134
|
+
align-items: center;
|
|
135
|
+
justify-content: center;
|
|
136
|
+
width: 20px;
|
|
137
|
+
height: 20px;
|
|
138
|
+
border-radius: 4px;
|
|
139
|
+
flex-shrink: 0;
|
|
140
|
+
|
|
141
|
+
&:hover {
|
|
142
|
+
background-color: var(--neutral-300, #e2e8f0);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.tree-spacer {
|
|
147
|
+
width: 20px;
|
|
148
|
+
height: 20px;
|
|
149
|
+
flex-shrink: 0;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.node-label {
|
|
153
|
+
flex: 1;
|
|
154
|
+
display: flex;
|
|
155
|
+
align-items: center;
|
|
156
|
+
overflow: hidden;
|
|
157
|
+
text-overflow: ellipsis;
|
|
158
|
+
white-space: nowrap;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.selection-control {
|
|
162
|
+
margin-right: 8px;
|
|
163
|
+
display: flex;
|
|
164
|
+
align-items: center;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.default-item {
|
|
168
|
+
display: flex;
|
|
169
|
+
align-items: center;
|
|
170
|
+
gap: 6px;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.tree-node-group {
|
|
174
|
+
display: flex;
|
|
175
|
+
flex-direction: column;
|
|
176
|
+
width: 100%;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
</style>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { TTreeRow } from '@katlux/providers';
|
|
2
|
+
export interface ITreeRenderNode {
|
|
3
|
+
key: string | number;
|
|
4
|
+
row: TTreeRow;
|
|
5
|
+
children: ITreeRenderNode[];
|
|
6
|
+
}
|
|
7
|
+
type __VLS_Props = {
|
|
8
|
+
node: ITreeRenderNode;
|
|
9
|
+
labelField: string;
|
|
10
|
+
iconField: string;
|
|
11
|
+
selectable: boolean;
|
|
12
|
+
focusedNodeId: string | number | null;
|
|
13
|
+
isSelected: (row: TTreeRow) => boolean;
|
|
14
|
+
};
|
|
15
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
16
|
+
click: (row: TTreeRow) => any;
|
|
17
|
+
focus: (row: TTreeRow, key: string | number) => any;
|
|
18
|
+
keydown: (event: KeyboardEvent, row: TTreeRow) => any;
|
|
19
|
+
toggle: (id: string | number) => any;
|
|
20
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
21
|
+
onClick?: ((row: TTreeRow) => any) | undefined;
|
|
22
|
+
onFocus?: ((row: TTreeRow, key: string | number) => any) | undefined;
|
|
23
|
+
onKeydown?: ((event: KeyboardEvent, row: TTreeRow) => any) | undefined;
|
|
24
|
+
onToggle?: ((id: string | number) => any) | undefined;
|
|
25
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
26
|
+
declare const _default: typeof __VLS_export;
|
|
27
|
+
export default _default;
|
|
@@ -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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@katlux/toolkit",
|
|
3
|
-
"version": "0.1.1-alpha.
|
|
3
|
+
"version": "0.1.1-alpha.124",
|
|
4
4
|
"description": "Core UI toolkit and utilities for the Katlux ecosystem",
|
|
5
5
|
"author": "Katlux",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -27,7 +27,10 @@
|
|
|
27
27
|
"require": "./dist/module.mjs"
|
|
28
28
|
},
|
|
29
29
|
"./package.json": "./package.json",
|
|
30
|
-
"./components/*":
|
|
30
|
+
"./components/*": {
|
|
31
|
+
"types": "./dist/runtime/components/*.d.ts",
|
|
32
|
+
"default": "./dist/runtime/components/*"
|
|
33
|
+
},
|
|
31
34
|
"./composables/*": {
|
|
32
35
|
"types": "./dist/runtime/composables/*.d.ts",
|
|
33
36
|
"default": "./dist/compiled/composables/*.mjs"
|
|
@@ -38,10 +41,20 @@
|
|
|
38
41
|
"default": "./dist/compiled/utils/*.mjs"
|
|
39
42
|
},
|
|
40
43
|
"./presets/*": "./dist/runtime/presets/*",
|
|
41
|
-
"./dist/runtime/presets/*": "./dist/runtime/presets/*"
|
|
44
|
+
"./dist/runtime/presets/*": "./dist/runtime/presets/*",
|
|
45
|
+
"./cli": {
|
|
46
|
+
"types": "./bin/create-preset.d.ts",
|
|
47
|
+
"import": "./bin/create-preset.mjs",
|
|
48
|
+
"default": "./bin/create-preset.mjs"
|
|
49
|
+
}
|
|
42
50
|
},
|
|
51
|
+
"sideEffects": [
|
|
52
|
+
"**/*.css",
|
|
53
|
+
"**/*.scss",
|
|
54
|
+
"**/*.sass"
|
|
55
|
+
],
|
|
43
56
|
"dependencies": {
|
|
44
|
-
"@katlux/providers": "^0.1.1-alpha.
|
|
57
|
+
"@katlux/providers": "^0.1.1-alpha.112",
|
|
45
58
|
"@nuxt/kit": "^3.12.0",
|
|
46
59
|
"@nuxtjs/i18n": "^10.4.0",
|
|
47
60
|
"pug": "^3.0.0",
|