@katlux/toolkit 0.1.1-alpha.119 → 0.1.1-alpha.120

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.
Files changed (59) hide show
  1. package/dist/compiled/composables/useDataProvider.mjs +20 -0
  2. package/dist/compiled/composables/useKatluxForm.mjs +55 -12
  3. package/dist/compiled/composables/useVirtualScroll.mjs +78 -8
  4. package/dist/module.json +1 -1
  5. package/dist/runtime/components/KBulkActions/KBulkActions.logic.js +13 -7
  6. package/dist/runtime/components/KCheckbox/KCheckbox.global.d.vue.ts +12 -0
  7. package/dist/runtime/components/KCheckbox/KCheckbox.global.vue +4 -2
  8. package/dist/runtime/components/KCheckbox/KCheckbox.global.vue.d.ts +12 -0
  9. package/dist/runtime/components/KCheckbox/KCheckbox.logic.d.ts +5 -0
  10. package/dist/runtime/components/KCheckbox/KCheckbox.logic.js +4 -0
  11. package/dist/runtime/components/KCombobox/KCombobox.global.d.vue.ts +2 -0
  12. package/dist/runtime/components/KCombobox/KCombobox.global.vue +2 -2
  13. package/dist/runtime/components/KCombobox/KCombobox.global.vue.d.ts +2 -0
  14. package/dist/runtime/components/KCombobox/KCombobox.logic.d.ts +1 -0
  15. package/dist/runtime/components/KDatatable/KDatatable.logic.js +17 -2
  16. package/dist/runtime/components/KDatePicker/KDatePicker.global.d.vue.ts +2 -0
  17. package/dist/runtime/components/KDatePicker/KDatePicker.global.vue +2 -1
  18. package/dist/runtime/components/KDatePicker/KDatePicker.global.vue.d.ts +2 -0
  19. package/dist/runtime/components/KGantt/KGantt.logic.js +1 -6
  20. package/dist/runtime/components/KPagination/KPagination.global.d.vue.ts +2 -0
  21. package/dist/runtime/components/KPagination/KPagination.global.vue +1 -1
  22. package/dist/runtime/components/KPagination/KPagination.global.vue.d.ts +2 -0
  23. package/dist/runtime/components/KPagination/KPagination.logic.d.ts +1 -0
  24. package/dist/runtime/components/KPagination/KPagination.logic.js +6 -1
  25. package/dist/runtime/components/KTree/KTree.global.d.vue.ts +1 -1
  26. package/dist/runtime/components/KTree/KTree.global.vue +0 -1
  27. package/dist/runtime/components/KTree/KTree.global.vue.d.ts +1 -1
  28. package/dist/runtime/components/KTreePicker/KTreePicker.global.d.vue.ts +1 -1
  29. package/dist/runtime/components/KTreePicker/KTreePicker.global.vue.d.ts +1 -1
  30. package/dist/runtime/components/KTreeView/KTreeView.global.d.vue.ts +1 -1
  31. package/dist/runtime/components/KTreeView/KTreeView.global.vue.d.ts +1 -1
  32. package/dist/runtime/composables/useDataProvider.d.ts +1 -0
  33. package/dist/runtime/composables/useDataProvider.js +20 -0
  34. package/dist/runtime/composables/useKatluxForm.d.ts +2 -0
  35. package/dist/runtime/composables/useKatluxForm.js +55 -12
  36. package/dist/runtime/composables/useVirtualScroll.d.ts +1 -1
  37. package/dist/runtime/composables/useVirtualScroll.js +78 -8
  38. package/dist/runtime/presets/default/components/KCheckbox/KCheckbox.d.vue.ts +3 -0
  39. package/dist/runtime/presets/default/components/KCheckbox/KCheckbox.vue +7 -0
  40. package/dist/runtime/presets/default/components/KCheckbox/KCheckbox.vue.d.ts +3 -0
  41. package/dist/runtime/presets/default/components/KCombobox/KCombobox.d.vue.ts +2 -0
  42. package/dist/runtime/presets/default/components/KCombobox/KCombobox.vue +2 -0
  43. package/dist/runtime/presets/default/components/KCombobox/KCombobox.vue.d.ts +2 -0
  44. package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.d.vue.ts +2 -0
  45. package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.vue +20 -6
  46. package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.vue.d.ts +2 -0
  47. package/dist/runtime/presets/default/components/KDatatable/KDatatable.vue +29 -12
  48. package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.d.vue.ts +3 -1
  49. package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.vue +3 -1
  50. package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.vue.d.ts +3 -1
  51. package/dist/runtime/presets/default/components/KLayout/KLayout.d.vue.ts +6 -1
  52. package/dist/runtime/presets/default/components/KLayout/KLayout.vue +37 -5
  53. package/dist/runtime/presets/default/components/KLayout/KLayout.vue.d.ts +6 -1
  54. package/dist/runtime/presets/default/components/KToast/KToast.vue +0 -1
  55. package/dist/runtime/presets/default/components/KToastContainer/KToastContainer.vue +0 -1
  56. package/dist/runtime/presets/default/components/KTree/KTree.d.vue.ts +2 -3
  57. package/dist/runtime/presets/default/components/KTree/KTree.vue +7 -5
  58. package/dist/runtime/presets/default/components/KTree/KTree.vue.d.ts +2 -3
  59. package/package.json +2 -2
@@ -6,6 +6,7 @@
6
6
  :id="comboboxId"
7
7
  @click.stop="toggleDropdown"
8
8
  @keydown="onKeyDown"
9
+ @blur="emit('blur', $event)"
9
10
  role="combobox"
10
11
  :aria-expanded="isOptionsOpen"
11
12
  aria-haspopup="listbox"
@@ -104,6 +105,7 @@ const props = withDefaults(defineProps<{
104
105
  const emit = defineEmits<{
105
106
  (e: 'update:searchtext', value: string): void
106
107
  (e: 'update:isOptionsOpen', value: boolean): void
108
+ (e: 'blur', event: FocusEvent): void
107
109
  }>()
108
110
 
109
111
  const searchtextModel = computed({
@@ -32,9 +32,11 @@ type __VLS_Props = {
32
32
  maxHeight?: number;
33
33
  };
34
34
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
35
+ blur: (event: FocusEvent) => any;
35
36
  "update:isOptionsOpen": (value: boolean) => any;
36
37
  "update:searchtext": (value: string) => any;
37
38
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
39
+ onBlur?: ((event: FocusEvent) => any) | undefined;
38
40
  "onUpdate:isOptionsOpen"?: ((value: boolean) => any) | undefined;
39
41
  "onUpdate:searchtext"?: ((value: string) => any) | undefined;
40
42
  }>, {
@@ -16,6 +16,7 @@ type __VLS_Props = {
16
16
  itemHeight?: number;
17
17
  viewportHeight?: number;
18
18
  buffer?: number;
19
+ gap?: number;
19
20
  };
20
21
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
21
22
  "update:selectedRows": (value: any[]) => any;
@@ -28,6 +29,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
28
29
  itemHeight: number;
29
30
  buffer: number;
30
31
  viewportHeight: number;
32
+ gap: number;
31
33
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
32
34
  declare const _default: typeof __VLS_export;
33
35
  export default _default;
@@ -71,11 +71,13 @@ const props = withDefaults(defineProps<{
71
71
  itemHeight?: number
72
72
  viewportHeight?: number
73
73
  buffer?: number
74
+ gap?: number
74
75
  }>(), {
75
76
  virtualScroll: false,
76
77
  itemHeight: 60,
77
78
  viewportHeight: 500,
78
- buffer: 5
79
+ buffer: 5,
80
+ gap: 10
79
81
  })
80
82
 
81
83
  const emit = defineEmits<{
@@ -93,7 +95,7 @@ const selectAll = computed({
93
95
  set: (val) => emit('update:selectAll', val)
94
96
  })
95
97
 
96
- const { pageData, loading: dpLoading, initialLoad: dpInitialLoad } = useDataProvider(props.dataProvider)
98
+ const { pageData, virtualRows, loading: dpLoading, initialLoad: dpInitialLoad } = useDataProvider(props.dataProvider)
97
99
  const pageRows = computed(() => pageData.value || [])
98
100
 
99
101
  // Virtual scroll data source
@@ -101,6 +103,11 @@ const iteratorItems = computed(() => {
101
103
  const currentRows = pageRows.value
102
104
  const dp = props.dataProvider as any
103
105
  if (props.virtualScroll) {
106
+ if (Array.isArray(dp?.rowMap)) return dp.rowMap
107
+ if (Array.isArray(dp?.rowMap?.value)) return dp.rowMap.value
108
+ if (Array.isArray(virtualRows?.value) && virtualRows.value.length > 0) return virtualRows.value
109
+ if (Array.isArray(dp?.allVisibleRows)) return dp.allVisibleRows
110
+ if (Array.isArray(dp?.allVisibleRows?.value)) return dp.allVisibleRows.value
104
111
  if (Array.isArray(dp?.allData?.value)) return dp.allData.value
105
112
  if (Array.isArray(dp?.allData)) return dp.allData
106
113
  if (Array.isArray(dp?.data)) return dp.data
@@ -108,6 +115,9 @@ const iteratorItems = computed(() => {
108
115
  return currentRows
109
116
  })
110
117
 
118
+ // Pitch height includes gap between items
119
+ const effectivePitchHeight = computed(() => (props.itemHeight || 60) + (props.gap ?? 10))
120
+
111
121
  const {
112
122
  visibleItems,
113
123
  startIndex,
@@ -120,7 +130,7 @@ const {
120
130
  containerCssVars
121
131
  } = useVirtualScroll({
122
132
  items: iteratorItems,
123
- itemHeight: props.itemHeight || 60,
133
+ itemHeight: effectivePitchHeight,
124
134
  containerHeight: props.viewportHeight || 500,
125
135
  buffer: props.buffer ?? 5,
126
136
  virtualScroll: computed(() => !!props.virtualScroll),
@@ -143,13 +153,13 @@ const displayRows = computed(() => {
143
153
 
144
154
  const onKeyDownDown = () => {
145
155
  if (containerRef.value) {
146
- containerRef.value.scrollTop += (props.itemHeight || 60)
156
+ containerRef.value.scrollTop += effectivePitchHeight.value
147
157
  }
148
158
  }
149
159
 
150
160
  const onKeyDownUp = () => {
151
161
  if (containerRef.value) {
152
- containerRef.value.scrollTop = Math.max(0, containerRef.value.scrollTop - (props.itemHeight || 60))
162
+ containerRef.value.scrollTop = Math.max(0, containerRef.value.scrollTop - effectivePitchHeight.value)
153
163
  }
154
164
  }
155
165
 
@@ -190,13 +200,17 @@ const getRowKey = (row: any, index: number): string | number => {
190
200
  position: relative;
191
201
  display: flex;
192
202
  flex-direction: column;
193
- gap: 10px;
203
+ gap: 0;
194
204
 
195
205
  &:focus-visible {
196
206
  outline: 2px solid var(--primary-color, #3b82f6);
197
207
  outline-offset: -2px;
198
208
  }
199
209
 
210
+ .k-data-iterator-item {
211
+ margin-bottom: 10px;
212
+ }
213
+
200
214
  .k-virtual-spacer {
201
215
  width: 100%;
202
216
  flex-shrink: 0;
@@ -16,6 +16,7 @@ type __VLS_Props = {
16
16
  itemHeight?: number;
17
17
  viewportHeight?: number;
18
18
  buffer?: number;
19
+ gap?: number;
19
20
  };
20
21
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
21
22
  "update:selectedRows": (value: any[]) => any;
@@ -28,6 +29,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
28
29
  itemHeight: number;
29
30
  buffer: number;
30
31
  viewportHeight: number;
32
+ gap: number;
31
33
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
32
34
  declare const _default: typeof __VLS_export;
33
35
  export default _default;
@@ -42,10 +42,10 @@
42
42
  tr(
43
43
  v-for="(row, index) in displayRows"
44
44
  :key="getRowKey(row, index)"
45
- :class="{ 'selected': isRowSelected(row), 'active-focus': focusedIndex === (props.virtualScroll ? startIndex + index : index) }"
45
+ :class="{ 'selected': isRowSelected(row), 'active-focus': focusedIndex === (props.virtualScroll ? startIndex + index : index), 'alt-row': (props.virtualScroll ? (startIndex + index) % 2 === 1 : index % 2 === 1) }"
46
46
  )
47
47
  td.check(v-if="props.bulkActions && props.bulkActions.length > 0")
48
- KCheckbox(:value="row" v-model="selectedRows")
48
+ KCheckbox(:value="row" v-model="selectedRows" :idKey="rowIdKey")
49
49
  td(
50
50
  v-for="visibleField in visibleFields || props.dataProvider.fields"
51
51
  :key="visibleField"
@@ -140,6 +140,8 @@ const selectAll = computed({
140
140
  set: (val) => emit('update:selectAll', val)
141
141
  })
142
142
 
143
+ const rowIdKey = computed(() => (props.dataProvider as any)?.idKey || 'id')
144
+
143
145
  const getRowKey = (row: any, index: number): string | number => {
144
146
  const idKey = (props.dataProvider as any)?.idKey || 'id'
145
147
  if (row && row[idKey] !== undefined && row[idKey] !== null) {
@@ -151,13 +153,24 @@ const getRowKey = (row: any, index: number): string | number => {
151
153
  if (row && row._id !== undefined && row._id !== null) {
152
154
  return row._id
153
155
  }
154
- return index
156
+ return props.virtualScroll ? startIndex.value + index : index
155
157
  }
156
158
 
159
+ const selectedRowIds = computed(() => {
160
+ const idKey = (props.dataProvider as any)?.idKey || 'id'
161
+ const set = new Set<any>()
162
+ for (const r of selectedRows.value || []) {
163
+ const id = r?.[idKey] ?? r?.id ?? r?._id ?? r
164
+ set.add(id)
165
+ set.add(r)
166
+ }
167
+ return set
168
+ })
169
+
157
170
  const isRowSelected = (row: any) => {
158
171
  const idKey = (props.dataProvider as any)?.idKey || 'id'
159
172
  const rowId = row?.[idKey] ?? row?.id ?? row?._id ?? row
160
- return (selectedRows.value || []).some((r: any) => (r?.[idKey] ?? r?.id ?? r?._id ?? r) === rowId || r === row)
173
+ return selectedRowIds.value.has(rowId) || selectedRowIds.value.has(row)
161
174
  }
162
175
 
163
176
  const getCellSlot = (fieldName: string) => {
@@ -176,7 +189,7 @@ const getColumnStyle = (field: string) => {
176
189
  return { width: w, whiteSpace: 'nowrap' as const }
177
190
  }
178
191
 
179
- const { pageData, filter: dpFilter, loading: dpLoading, initialLoad: dpInitialLoad } = useDataProvider(props.dataProvider)
192
+ const { pageData, virtualRows, filter: dpFilter, loading: dpLoading, initialLoad: dpInitialLoad } = useDataProvider(props.dataProvider)
180
193
  const pageRows = computed(() => pageData.value || [])
181
194
 
182
195
  const effectivePageSize = computed(() => {
@@ -193,6 +206,9 @@ const datatableItems = computed(() => {
193
206
  const currentRows = pageRows.value
194
207
  const dp = props.dataProvider as any
195
208
  if (props.virtualScroll) {
209
+ if (Array.isArray(dp?.rowMap)) return dp.rowMap
210
+ if (Array.isArray(dp?.rowMap?.value)) return dp.rowMap.value
211
+ if (Array.isArray(virtualRows?.value) && virtualRows.value.length > 0) return virtualRows.value
196
212
  if (Array.isArray(dp?.allVisibleRows)) return dp.allVisibleRows
197
213
  if (Array.isArray(dp?.allVisibleRows?.value)) return dp.allVisibleRows.value
198
214
  if (Array.isArray(dp?.allVisibleNodes)) return dp.allVisibleNodes
@@ -245,6 +261,7 @@ const totalColspan = computed(() => {
245
261
  })
246
262
 
247
263
  const focusedIndex = ref<number>(-1)
264
+ const theadStickyOffset = 40
248
265
  const handleKeyDown = (e: KeyboardEvent) => {
249
266
  if (!props.virtualScroll) return
250
267
  const total = datatableItems.value.length
@@ -253,21 +270,21 @@ const handleKeyDown = (e: KeyboardEvent) => {
253
270
  if (e.key === 'ArrowDown') {
254
271
  e.preventDefault()
255
272
  focusedIndex.value = Math.min(total - 1, focusedIndex.value + 1)
256
- scrollToIndex(focusedIndex.value)
273
+ scrollToIndex(focusedIndex.value, 'auto', focusedIndex.value > 0 ? theadStickyOffset : 0)
257
274
  } else if (e.key === 'ArrowUp') {
258
275
  e.preventDefault()
259
276
  focusedIndex.value = Math.max(0, focusedIndex.value - 1)
260
- scrollToIndex(focusedIndex.value)
277
+ scrollToIndex(focusedIndex.value, 'auto', focusedIndex.value > 0 ? theadStickyOffset : 0)
261
278
  } else if (e.key === 'PageDown') {
262
279
  e.preventDefault()
263
280
  const step = Math.floor((props.viewportHeight || 500) / (props.itemHeight || 40))
264
281
  focusedIndex.value = Math.min(total - 1, focusedIndex.value + step)
265
- scrollToIndex(focusedIndex.value)
282
+ scrollToIndex(focusedIndex.value, 'auto', focusedIndex.value > 0 ? theadStickyOffset : 0)
266
283
  } else if (e.key === 'PageUp') {
267
284
  e.preventDefault()
268
285
  const step = Math.floor((props.viewportHeight || 500) / (props.itemHeight || 40))
269
286
  focusedIndex.value = Math.max(0, focusedIndex.value - step)
270
- scrollToIndex(focusedIndex.value)
287
+ scrollToIndex(focusedIndex.value, 'auto', focusedIndex.value > 0 ? theadStickyOffset : 0)
271
288
  } else if (e.key === 'Home') {
272
289
  e.preventDefault()
273
290
  focusedIndex.value = 0
@@ -275,7 +292,7 @@ const handleKeyDown = (e: KeyboardEvent) => {
275
292
  } else if (e.key === 'End') {
276
293
  e.preventDefault()
277
294
  focusedIndex.value = total - 1
278
- scrollToIndex(total - 1)
295
+ scrollToIndex(total - 1, 'auto', theadStickyOffset)
279
296
  }
280
297
  }
281
298
  </script>
@@ -309,10 +326,10 @@ const handleKeyDown = (e: KeyboardEvent) => {
309
326
  }
310
327
  tbody {
311
328
  tr {
312
- height: 40px;
329
+ height: var(--virtual-item-height, 40px);
313
330
  background-color: var(--table-row-bg, #ffffff);
314
331
  color: var(--table-row-text-color, #1e293b);
315
- &:nth-child(2n + 1) {
332
+ &.alt-row {
316
333
  background-color: var(--table-row-alt-bg, #f8fafc);
317
334
  }
318
335
  &:hover {
@@ -14,14 +14,16 @@ type __VLS_Props = {
14
14
  dateSelected: (date: Date) => void;
15
15
  teleportTo?: string;
16
16
  placeholder?: string;
17
- validation?: 'success' | 'warning' | 'error' | null;
17
+ validation?: 'success' | 'warning' | null | 'error';
18
18
  validationText?: string;
19
19
  align?: 'left' | 'right';
20
20
  };
21
21
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
22
+ blur: (event: FocusEvent) => any;
22
23
  "update:maskedModel": (value: string) => any;
23
24
  "update:calendarShow": (value: boolean) => any;
24
25
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
26
+ onBlur?: ((event: FocusEvent) => any) | undefined;
25
27
  "onUpdate:maskedModel"?: ((value: string) => any) | undefined;
26
28
  "onUpdate:calendarShow"?: ((value: boolean) => any) | undefined;
27
29
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -9,6 +9,7 @@
9
9
  @click.stop="textboxClicked"
10
10
  :showClear="showClear"
11
11
  @clear="onClear"
12
+ @blur="emit('blur', $event)"
12
13
  :validation="validation"
13
14
  :validationText="validationText"
14
15
  )
@@ -39,7 +40,7 @@ const props = defineProps<{
39
40
  dateSelected: (date: Date) => void
40
41
  teleportTo?: string
41
42
  placeholder?: string
42
- validation?: 'success' | 'warning' | 'error' | null
43
+ validation?: 'success' | 'warning' | null | 'error'
43
44
  validationText?: string
44
45
  align?: 'left' | 'right'
45
46
  }>()
@@ -47,6 +48,7 @@ const props = defineProps<{
47
48
  const emit = defineEmits<{
48
49
  (e: 'update:maskedModel', value: string): void
49
50
  (e: 'update:calendarShow', value: boolean): void
51
+ (e: 'blur', event: FocusEvent): void
50
52
  }>()
51
53
 
52
54
  const maskedModel = computed({
@@ -14,14 +14,16 @@ type __VLS_Props = {
14
14
  dateSelected: (date: Date) => void;
15
15
  teleportTo?: string;
16
16
  placeholder?: string;
17
- validation?: 'success' | 'warning' | 'error' | null;
17
+ validation?: 'success' | 'warning' | null | 'error';
18
18
  validationText?: string;
19
19
  align?: 'left' | 'right';
20
20
  };
21
21
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
22
+ blur: (event: FocusEvent) => any;
22
23
  "update:maskedModel": (value: string) => any;
23
24
  "update:calendarShow": (value: boolean) => any;
24
25
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
26
+ onBlur?: ((event: FocusEvent) => any) | undefined;
25
27
  "onUpdate:maskedModel"?: ((value: string) => any) | undefined;
26
28
  "onUpdate:calendarShow"?: ((value: boolean) => any) | undefined;
27
29
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -1,3 +1,8 @@
1
- declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
1
+ type __VLS_Props = {
2
+ scrollMode?: 'window' | 'container';
3
+ };
4
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
5
+ scrollMode: "window" | "container";
6
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
2
7
  declare const _default: typeof __VLS_export;
3
8
  export default _default;
@@ -1,5 +1,5 @@
1
1
  <template lang="pug">
2
- .KLayout(:class="{ 'has-aside': Boolean($slots.aside) }")
2
+ .KLayout(:class="layoutClasses")
3
3
  header.KLayout__header(v-if="$slots.header")
4
4
  slot(name="header")
5
5
  aside.KLayout__aside(v-if="$slots.aside")
@@ -12,15 +12,27 @@
12
12
  </template>
13
13
 
14
14
  <script lang="ts" setup>
15
+ import { computed, useSlots } from 'vue'
16
+
17
+ const slots = useSlots()
15
18
  // Default preset component for KLayout
19
+ const props = withDefaults(defineProps<{
20
+ scrollMode?: 'window' | 'container'
21
+ }>(), {
22
+ scrollMode: 'container'
23
+ })
24
+
25
+ const layoutClasses = computed(() => [
26
+ { 'has-aside': Boolean(slots.aside) },
27
+ `is-scroll-${props.scrollMode || 'container'}`
28
+ ])
16
29
  </script>
17
30
 
18
31
  <style lang="scss" scoped>
19
32
  .KLayout {
20
33
  display: grid;
21
- height: 100vh;
22
- max-height: 100vh;
23
- overflow: hidden;
34
+ min-height: 100vh;
35
+ min-height: 100dvh;
24
36
  grid-template-rows: auto minmax(0, 1fr) auto;
25
37
  grid-template-columns: 1fr;
26
38
  grid-template-areas:
@@ -31,6 +43,27 @@
31
43
  color: var(--text-color, inherit);
32
44
  box-sizing: border-box;
33
45
 
46
+ &.is-scroll-container {
47
+ height: 100vh;
48
+ height: 100dvh;
49
+ max-height: 100dvh;
50
+ overflow: hidden;
51
+
52
+ .KLayout__main {
53
+ overflow-y: auto;
54
+ }
55
+ }
56
+
57
+ &.is-scroll-window {
58
+ min-height: 100vh;
59
+ min-height: 100dvh;
60
+ overflow: visible;
61
+
62
+ .KLayout__main {
63
+ overflow-y: visible;
64
+ }
65
+ }
66
+
34
67
  &.has-aside {
35
68
  grid-template-columns: var(--layout-sidebar-width, 240px) 1fr;
36
69
  grid-template-areas:
@@ -57,7 +90,6 @@
57
90
  &__main {
58
91
  grid-area: main;
59
92
  min-width: 0;
60
- overflow-y: auto;
61
93
  box-sizing: border-box;
62
94
  }
63
95
 
@@ -1,3 +1,8 @@
1
- declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
1
+ type __VLS_Props = {
2
+ scrollMode?: 'window' | 'container';
3
+ };
4
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
5
+ scrollMode: "window" | "container";
6
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
2
7
  declare const _default: typeof __VLS_export;
3
8
  export default _default;
@@ -5,7 +5,6 @@ Teleport(to="body" :disabled="!teleport")
5
5
  v-if="modelValue"
6
6
  :class="[`type-${type}`, { 'is-fixed': teleport }]"
7
7
  :role="type === 'error' || type === 'danger' ? 'alert' : 'status'"
8
- :aria-live="type === 'error' || type === 'danger' ? 'assertive' : 'polite'"
9
8
  @mouseenter="$emit('mouseenter', $event)"
10
9
  @mouseleave="$emit('mouseleave', $event)"
11
10
  )
@@ -7,7 +7,6 @@ Teleport(to="body" :disabled="!teleport")
7
7
  :class="[`pos-${pos}`]"
8
8
  role="region"
9
9
  aria-label="Notifications"
10
- aria-live="polite"
11
10
  @mouseenter="handleMouseEnter"
12
11
  @mouseleave="handleMouseLeave"
13
12
  )
@@ -9,6 +9,7 @@ type __VLS_Props = {
9
9
  multiSelect?: boolean;
10
10
  isNodeSelected?: (node: any) => boolean;
11
11
  toggleNode: (id: string | number) => void;
12
+ selectNode?: (node: any) => void;
12
13
  selectable?: boolean;
13
14
  dataProvider?: any;
14
15
  searchtext?: string;
@@ -20,13 +21,12 @@ type __VLS_Props = {
20
21
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
21
22
  select: (row: TTreeRow) => any;
22
23
  "node-toggle": (id: string | number) => any;
23
- "node-click": (row: TTreeRow) => any;
24
24
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
25
25
  onSelect?: ((row: TTreeRow) => any) | undefined;
26
26
  "onNode-toggle"?: ((id: string | number) => any) | undefined;
27
- "onNode-click"?: ((row: TTreeRow) => any) | undefined;
28
27
  }>, {
29
28
  disabled: boolean;
29
+ idKey: string;
30
30
  searchtext: string;
31
31
  virtualScroll: boolean;
32
32
  itemHeight: number;
@@ -35,7 +35,6 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
35
35
  multiSelect: boolean;
36
36
  viewportHeight: number;
37
37
  iconField: string;
38
- idKey: string;
39
38
  isNodeSelected: (node: any) => boolean;
40
39
  selectable: boolean;
41
40
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -1,5 +1,6 @@
1
1
  <template lang="pug">
2
2
  .KTree(
3
+ ref="treeRootRef"
3
4
  role="tree"
4
5
  :aria-label="t('Hierarchical Tree')"
5
6
  :class="{ 'is-virtual-scroll': props.virtualScroll }"
@@ -66,7 +67,7 @@
66
67
  //- Traditional standard tree list
67
68
  .tree-list(v-else)
68
69
  .tree-node(
69
- v-for="row in visibleRows"
70
+ v-for="(row, idx) in visibleRows"
70
71
  :key="row[idKey] || row.id"
71
72
  :class="{ 'has-children': row.__treeNode?.hasChildren }"
72
73
  :style="{ '--tree-depth': row.__treeNode?.depth || 0 }"
@@ -130,6 +131,7 @@ const props = withDefaults(
130
131
  multiSelect?: boolean
131
132
  isNodeSelected?: (node: any) => boolean
132
133
  toggleNode: (id: string | number) => void
134
+ selectNode?: (node: any) => void
133
135
  selectable?: boolean
134
136
  dataProvider?: any
135
137
  searchtext?: string
@@ -156,7 +158,6 @@ const props = withDefaults(
156
158
 
157
159
  const emit = defineEmits<{
158
160
  (e: 'select', row: TTreeRow): void
159
- (e: 'node-click', row: TTreeRow): void
160
161
  (e: 'node-toggle', id: string | number): void
161
162
  }>()
162
163
 
@@ -168,7 +169,6 @@ function toggleNode(id: string | number) {
168
169
  function onNodeClick(row: TTreeRow) {
169
170
  if (!props.disabled) {
170
171
  emit('select', row)
171
- emit('node-click', row)
172
172
  }
173
173
  }
174
174
 
@@ -244,13 +244,15 @@ const onNodeFocus = (row: TTreeRow, idx: number) => {
244
244
  focusedNodeId.value = getNodeKey(row, idx)
245
245
  }
246
246
 
247
+ const treeRootRef = ref<HTMLElement | null>(null)
248
+
247
249
  const focusNextNode = (currentIdx: number) => {
248
250
  const rows = props.virtualScroll ? displayRows.value : (props.visibleRows || [])
249
251
  if (currentIdx < rows.length - 1) {
250
252
  const nextRow = rows[currentIdx + 1]
251
253
  focusedNodeId.value = getNodeKey(nextRow, currentIdx + 1)
252
254
  nextTick(() => {
253
- const activeEl = document.querySelector<HTMLElement>(`.KTree .tree-node[tabindex="0"]`)
255
+ const activeEl = (treeRootRef.value || containerRef.value)?.querySelector<HTMLElement>(`.tree-node[tabindex="0"]`)
254
256
  activeEl?.focus()
255
257
  })
256
258
  }
@@ -263,7 +265,7 @@ const focusPrevNode = (currentIdx: number) => {
263
265
  const prevRow = rows[currentIdx - 1]
264
266
  focusedNodeId.value = getNodeKey(prevRow, currentIdx - 1)
265
267
  nextTick(() => {
266
- const activeEl = document.querySelector<HTMLElement>(`.KTree .tree-node[tabindex="0"]`)
268
+ const activeEl = (treeRootRef.value || containerRef.value)?.querySelector<HTMLElement>(`.tree-node[tabindex="0"]`)
267
269
  activeEl?.focus()
268
270
  })
269
271
  }
@@ -9,6 +9,7 @@ type __VLS_Props = {
9
9
  multiSelect?: boolean;
10
10
  isNodeSelected?: (node: any) => boolean;
11
11
  toggleNode: (id: string | number) => void;
12
+ selectNode?: (node: any) => void;
12
13
  selectable?: boolean;
13
14
  dataProvider?: any;
14
15
  searchtext?: string;
@@ -20,13 +21,12 @@ type __VLS_Props = {
20
21
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
21
22
  select: (row: TTreeRow) => any;
22
23
  "node-toggle": (id: string | number) => any;
23
- "node-click": (row: TTreeRow) => any;
24
24
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
25
25
  onSelect?: ((row: TTreeRow) => any) | undefined;
26
26
  "onNode-toggle"?: ((id: string | number) => any) | undefined;
27
- "onNode-click"?: ((row: TTreeRow) => any) | undefined;
28
27
  }>, {
29
28
  disabled: boolean;
29
+ idKey: string;
30
30
  searchtext: string;
31
31
  virtualScroll: boolean;
32
32
  itemHeight: number;
@@ -35,7 +35,6 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
35
35
  multiSelect: boolean;
36
36
  viewportHeight: number;
37
37
  iconField: string;
38
- idKey: string;
39
38
  isNodeSelected: (node: any) => boolean;
40
39
  selectable: boolean;
41
40
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@katlux/toolkit",
3
- "version": "0.1.1-alpha.119",
3
+ "version": "0.1.1-alpha.120",
4
4
  "description": "Core UI toolkit and utilities for the Katlux ecosystem",
5
5
  "author": "Katlux",
6
6
  "license": "Apache-2.0",
@@ -41,7 +41,7 @@
41
41
  "./dist/runtime/presets/*": "./dist/runtime/presets/*"
42
42
  },
43
43
  "dependencies": {
44
- "@katlux/providers": "^0.1.1-alpha.105",
44
+ "@katlux/providers": "^0.1.1-alpha.106",
45
45
  "@nuxt/kit": "^3.12.0",
46
46
  "@nuxtjs/i18n": "^10.4.0",
47
47
  "pug": "^3.0.0",