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

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 (84) hide show
  1. package/bin/add-ai-reference.mjs +152 -39
  2. package/bin/cli.mjs +20 -1
  3. package/dist/compiled/composables/useDataProvider.mjs +20 -0
  4. package/dist/compiled/composables/useKatluxForm.mjs +55 -12
  5. package/dist/compiled/composables/useVirtualScroll.mjs +78 -8
  6. package/dist/module.json +1 -1
  7. package/dist/runtime/components/KBulkActions/KBulkActions.logic.js +26 -17
  8. package/dist/runtime/components/KCheckbox/KCheckbox.global.d.vue.ts +12 -0
  9. package/dist/runtime/components/KCheckbox/KCheckbox.global.vue +4 -2
  10. package/dist/runtime/components/KCheckbox/KCheckbox.global.vue.d.ts +12 -0
  11. package/dist/runtime/components/KCheckbox/KCheckbox.logic.d.ts +5 -0
  12. package/dist/runtime/components/KCheckbox/KCheckbox.logic.js +4 -0
  13. package/dist/runtime/components/KCombobox/KCombobox.global.d.vue.ts +2 -0
  14. package/dist/runtime/components/KCombobox/KCombobox.global.vue +2 -2
  15. package/dist/runtime/components/KCombobox/KCombobox.global.vue.d.ts +2 -0
  16. package/dist/runtime/components/KCombobox/KCombobox.logic.d.ts +1 -0
  17. package/dist/runtime/components/KDatatable/KDataIterator.logic.js +5 -33
  18. package/dist/runtime/components/KDatatable/KDatatable.logic.js +30 -31
  19. package/dist/runtime/components/KDatePicker/KDatePicker.global.d.vue.ts +4 -2
  20. package/dist/runtime/components/KDatePicker/KDatePicker.global.vue +2 -1
  21. package/dist/runtime/components/KDatePicker/KDatePicker.global.vue.d.ts +4 -2
  22. package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.d.vue.ts +2 -2
  23. package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.vue.d.ts +2 -2
  24. package/dist/runtime/components/KDropdown/KDropdown.global.d.vue.ts +1 -1
  25. package/dist/runtime/components/KDropdown/KDropdown.global.vue.d.ts +1 -1
  26. package/dist/runtime/components/KGantt/KGantt.global.d.vue.ts +36 -0
  27. package/dist/runtime/components/KGantt/KGantt.global.vue +5 -1
  28. package/dist/runtime/components/KGantt/KGantt.global.vue.d.ts +36 -0
  29. package/dist/runtime/components/KGantt/KGantt.logic.d.ts +20 -0
  30. package/dist/runtime/components/KGantt/KGantt.logic.js +17 -6
  31. package/dist/runtime/components/KPagination/KPagination.global.d.vue.ts +2 -0
  32. package/dist/runtime/components/KPagination/KPagination.global.vue +1 -1
  33. package/dist/runtime/components/KPagination/KPagination.global.vue.d.ts +2 -0
  34. package/dist/runtime/components/KPagination/KPagination.logic.d.ts +1 -0
  35. package/dist/runtime/components/KPagination/KPagination.logic.js +6 -1
  36. package/dist/runtime/components/KTooltip/KTooltip.global.d.vue.ts +1 -1
  37. package/dist/runtime/components/KTooltip/KTooltip.global.vue.d.ts +1 -1
  38. package/dist/runtime/components/KTree/KTree.global.d.vue.ts +1 -1
  39. package/dist/runtime/components/KTree/KTree.global.vue +0 -1
  40. package/dist/runtime/components/KTree/KTree.global.vue.d.ts +1 -1
  41. package/dist/runtime/components/KTreePicker/KTreePicker.global.d.vue.ts +1 -1
  42. package/dist/runtime/components/KTreePicker/KTreePicker.global.vue.d.ts +1 -1
  43. package/dist/runtime/components/KTreeView/KTreeView.global.d.vue.ts +1 -1
  44. package/dist/runtime/components/KTreeView/KTreeView.global.vue.d.ts +1 -1
  45. package/dist/runtime/composables/useDataProvider.d.ts +1 -0
  46. package/dist/runtime/composables/useDataProvider.js +20 -0
  47. package/dist/runtime/composables/useFilterLogic.d.ts +1 -0
  48. package/dist/runtime/composables/useKatluxForm.d.ts +2 -0
  49. package/dist/runtime/composables/useKatluxForm.js +55 -12
  50. package/dist/runtime/composables/useVirtualScroll.d.ts +1 -1
  51. package/dist/runtime/composables/useVirtualScroll.js +78 -8
  52. package/dist/runtime/presets/default/assets/scss/css-variables.css +1 -0
  53. package/dist/runtime/presets/default/assets/scss/css-variables.scss +1 -0
  54. package/dist/runtime/presets/default/assets/scss/index.css +1 -0
  55. package/dist/runtime/presets/default/components/KBulkActions/KBulkActions.vue +4 -4
  56. package/dist/runtime/presets/default/components/KCheckbox/KCheckbox.d.vue.ts +3 -0
  57. package/dist/runtime/presets/default/components/KCheckbox/KCheckbox.vue +7 -0
  58. package/dist/runtime/presets/default/components/KCheckbox/KCheckbox.vue.d.ts +3 -0
  59. package/dist/runtime/presets/default/components/KCombobox/KCombobox.d.vue.ts +2 -0
  60. package/dist/runtime/presets/default/components/KCombobox/KCombobox.vue +3 -1
  61. package/dist/runtime/presets/default/components/KCombobox/KCombobox.vue.d.ts +2 -0
  62. package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.d.vue.ts +2 -0
  63. package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.vue +20 -6
  64. package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.vue.d.ts +2 -0
  65. package/dist/runtime/presets/default/components/KDatatable/KDatatable.vue +85 -15
  66. package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.d.vue.ts +3 -1
  67. package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.vue +3 -1
  68. package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.vue.d.ts +3 -1
  69. package/dist/runtime/presets/default/components/KGantt/KGantt.d.vue.ts +4 -0
  70. package/dist/runtime/presets/default/components/KGantt/KGantt.vue +16 -2
  71. package/dist/runtime/presets/default/components/KGantt/KGantt.vue.d.ts +4 -0
  72. package/dist/runtime/presets/default/components/KGrid/KGrid.vue +1 -0
  73. package/dist/runtime/presets/default/components/KLayout/KLayout.d.vue.ts +6 -1
  74. package/dist/runtime/presets/default/components/KLayout/KLayout.vue +53 -5
  75. package/dist/runtime/presets/default/components/KLayout/KLayout.vue.d.ts +6 -1
  76. package/dist/runtime/presets/default/components/KPagination/KPagination.vue +29 -7
  77. package/dist/runtime/presets/default/components/KTextarea/KTextarea.vue +1 -0
  78. package/dist/runtime/presets/default/components/KTextbox/KTextbox.vue +1 -1
  79. package/dist/runtime/presets/default/components/KToast/KToast.vue +0 -1
  80. package/dist/runtime/presets/default/components/KToastContainer/KToastContainer.vue +0 -1
  81. package/dist/runtime/presets/default/components/KTree/KTree.d.vue.ts +2 -3
  82. package/dist/runtime/presets/default/components/KTree/KTree.vue +7 -5
  83. package/dist/runtime/presets/default/components/KTree/KTree.vue.d.ts +2 -3
  84. package/package.json +2 -2
@@ -42,6 +42,7 @@ export function useVirtualScroll(options) {
42
42
  const val = unref(options.containerHeight);
43
43
  return typeof val === "number" && val > 0 ? val : 400;
44
44
  };
45
+ const configuredContainerHeight = computed(() => resolveContainerHeight());
45
46
  const viewportHeight = ref(resolveContainerHeight());
46
47
  watch(
47
48
  () => resolveContainerHeight(),
@@ -51,13 +52,13 @@ export function useVirtualScroll(options) {
51
52
  }
52
53
  }
53
54
  );
54
- watch(containerRef, (el, oldEl) => {
55
+ watch([containerRef, isVirtual], ([el, virtual], [oldEl]) => {
55
56
  if (typeof window === "undefined" || typeof ResizeObserver === "undefined") return;
56
57
  if (oldEl && oldEl.__vsObserver) {
57
58
  oldEl.__vsObserver.disconnect();
58
59
  delete oldEl.__vsObserver;
59
60
  }
60
- if (el) {
61
+ if (el && virtual) {
61
62
  const ro = new ResizeObserver((entries) => {
62
63
  for (const entry of entries) {
63
64
  const h = Math.round(entry.contentRect.height || el.clientHeight);
@@ -78,12 +79,42 @@ export function useVirtualScroll(options) {
78
79
  }
79
80
  });
80
81
  }
82
+ const isDynamicHeight = computed(() => typeof options.itemHeight === "function");
83
+ const rowOffsets = computed(() => {
84
+ if (!isDynamicHeight.value || colCount.value > 1) return [];
85
+ const items = allItems.value;
86
+ const offsets = new Array(items.length + 1);
87
+ offsets[0] = 0;
88
+ let current = 0;
89
+ for (let i = 0; i < items.length; i++) {
90
+ current += getItemHeight(items[i], i);
91
+ offsets[i + 1] = current;
92
+ }
93
+ return offsets;
94
+ });
81
95
  const totalRows = computed(() => {
82
96
  if (colCount.value <= 1) return totalCount.value;
83
97
  return Math.ceil(totalCount.value / colCount.value);
84
98
  });
85
99
  const startRowIndex = computed(() => {
86
100
  if (!isVirtual.value) return 0;
101
+ if (isDynamicHeight.value && colCount.value <= 1) {
102
+ const offsets = rowOffsets.value;
103
+ const top = Math.max(0, scrollTop.value);
104
+ let low = 0;
105
+ let high = totalRows.value - 1;
106
+ let idx = 0;
107
+ while (low <= high) {
108
+ const mid = low + high >> 1;
109
+ if (offsets[mid + 1] > top) {
110
+ idx = mid;
111
+ high = mid - 1;
112
+ } else {
113
+ low = mid + 1;
114
+ }
115
+ }
116
+ return Math.max(0, idx - buf.value);
117
+ }
87
118
  const rawRow = Math.floor(scrollTop.value / baseItemHeight.value);
88
119
  return Math.max(0, rawRow - buf.value);
89
120
  });
@@ -94,6 +125,23 @@ export function useVirtualScroll(options) {
94
125
  });
95
126
  const endRowIndex = computed(() => {
96
127
  if (!isVirtual.value) return totalRows.value;
128
+ if (isDynamicHeight.value && colCount.value <= 1) {
129
+ const offsets = rowOffsets.value;
130
+ const bottom = scrollTop.value + viewportHeight.value;
131
+ let low = startRowIndex.value;
132
+ let high = totalRows.value - 1;
133
+ let idx = totalRows.value;
134
+ while (low <= high) {
135
+ const mid = low + high >> 1;
136
+ if (offsets[mid] >= bottom) {
137
+ idx = mid;
138
+ high = mid - 1;
139
+ } else {
140
+ low = mid + 1;
141
+ }
142
+ }
143
+ return Math.min(totalRows.value, idx + buf.value);
144
+ }
97
145
  return Math.min(totalRows.value, startRowIndex.value + visibleRowsCount.value);
98
146
  });
99
147
  const startIndex = computed(() => {
@@ -110,16 +158,27 @@ export function useVirtualScroll(options) {
110
158
  });
111
159
  const topSpacerHeight = computed(() => {
112
160
  if (!isVirtual.value) return 0;
161
+ if (isDynamicHeight.value && colCount.value <= 1) {
162
+ return rowOffsets.value[startRowIndex.value] || 0;
163
+ }
113
164
  return Math.max(0, startRowIndex.value * baseItemHeight.value);
114
165
  });
166
+ const totalHeight = computed(() => {
167
+ if (isDynamicHeight.value && colCount.value <= 1) {
168
+ const offsets = rowOffsets.value;
169
+ return offsets.length > 0 ? offsets[offsets.length - 1] : 0;
170
+ }
171
+ return totalRows.value * baseItemHeight.value;
172
+ });
115
173
  const bottomSpacerHeight = computed(() => {
116
174
  if (!isVirtual.value) return 0;
175
+ if (isDynamicHeight.value && colCount.value <= 1) {
176
+ const endOffset = rowOffsets.value[endRowIndex.value] || totalHeight.value;
177
+ return Math.max(0, totalHeight.value - endOffset);
178
+ }
117
179
  const remainingRows = Math.max(0, totalRows.value - endRowIndex.value);
118
180
  return remainingRows * baseItemHeight.value;
119
181
  });
120
- const totalHeight = computed(() => {
121
- return totalRows.value * baseItemHeight.value;
122
- });
123
182
  watch(totalHeight, (newTotal) => {
124
183
  if (scrollTop.value > newTotal) {
125
184
  scrollTop.value = Math.max(0, newTotal - viewportHeight.value);
@@ -133,7 +192,7 @@ export function useVirtualScroll(options) {
133
192
  "--virtual-spacer-bottom": `${bottomSpacerHeight.value}px`,
134
193
  "--virtual-total-height": `${totalHeight.value}px`,
135
194
  "--virtual-item-height": `${baseItemHeight.value}px`,
136
- "--virtual-container-height": `${viewportHeight.value}px`
195
+ "--virtual-container-height": `${configuredContainerHeight.value}px`
137
196
  }));
138
197
  const scrollThreshold = options.scrollThreshold ?? 100;
139
198
  const onScroll = (e) => {
@@ -148,9 +207,20 @@ export function useVirtualScroll(options) {
148
207
  options.onThresholdReach();
149
208
  }
150
209
  };
151
- const scrollToIndex = (index, behavior = "auto") => {
210
+ const scrollToIndex = (index, behavior = "auto", offset = 0) => {
211
+ if (isDynamicHeight.value && colCount.value <= 1) {
212
+ const targetScrollTop2 = Math.max(0, (rowOffsets.value[index] || 0) - offset);
213
+ scrollTop.value = targetScrollTop2;
214
+ if (containerRef.value) {
215
+ containerRef.value.scrollTo({
216
+ top: targetScrollTop2,
217
+ behavior
218
+ });
219
+ }
220
+ return;
221
+ }
152
222
  const targetRow = colCount.value <= 1 ? index : Math.floor(index / colCount.value);
153
- const targetScrollTop = targetRow * baseItemHeight.value;
223
+ const targetScrollTop = Math.max(0, targetRow * baseItemHeight.value - offset);
154
224
  scrollTop.value = targetScrollTop;
155
225
  if (containerRef.value) {
156
226
  containerRef.value.scrollTo({
@@ -171,6 +171,7 @@
171
171
  --input-focus-border-color: var(--primary-500);
172
172
  --input-focus-shadow: 0 0 0 3px rgba(33, 150, 243, 0.2);
173
173
  --input-height: 40px;
174
+ --input-min-width: 140px;
174
175
  --input-label-color: var(--font-color-primary);
175
176
  --table-border-color: var(--neutral-300);
176
177
  --table-header-bg: var(--neutral-200);
@@ -243,6 +243,7 @@
243
243
  --input-focus-border-color: var(--primary-500);
244
244
  --input-focus-shadow: 0 0 0 3px rgba(33, 150, 243, 0.2);
245
245
  --input-height: 40px;
246
+ --input-min-width: 140px;
246
247
  --input-label-color: var(--font-color-primary);
247
248
 
248
249
  // Table
@@ -188,6 +188,7 @@ li {
188
188
  --input-focus-border-color: var(--primary-500);
189
189
  --input-focus-shadow: 0 0 0 3px rgba(33, 150, 243, 0.2);
190
190
  --input-height: 40px;
191
+ --input-min-width: 140px;
191
192
  --input-label-color: var(--font-color-primary);
192
193
  --table-border-color: var(--neutral-300);
193
194
  --table-header-bg: var(--neutral-200);
@@ -1,8 +1,8 @@
1
1
  <template lang="pug">
2
2
  .k-bulk-actions
3
3
  template(v-if="props.bulkActions.length>3")
4
- KCombobox(:dataProvider="dp" v-model="internalSelected" labelField="label" closeOnSelect :disabled="props.selectedRows.length === 0" :placeholder="t('Select an action')")
5
- KButton(@click="doAction(internalSelected)" size="small" :disabled="props.selectedRows.length === 0 || internalSelected == undefined") {{ t('Apply') }}
4
+ KCombobox(:dataProvider="dp" v-model="internalSelected" labelField="label" closeOnSelect :disabled="!props.selectAll && props.selectedRows.length === 0" :placeholder="t('Select an action')")
5
+ KButton(@click="doAction(internalSelected)" size="small" :disabled="(!props.selectAll && props.selectedRows.length === 0) || internalSelected == undefined") {{ t('Apply') }}
6
6
  template(v-else-if="props.bulkActions.length<=3" v-for="(action, index) in props.bulkActions")
7
7
  KTooltip(
8
8
  :text="action.label"
@@ -14,12 +14,12 @@
14
14
  :type="action.type || 'default'"
15
15
  :iconOnly="action.iconOnly || !!action.icon"
16
16
  :aria-label="action.label"
17
- :disabled="props.selectedRows.length === 0"
17
+ :disabled="!props.selectAll && props.selectedRows.length === 0"
18
18
  )
19
19
  template(#icon v-if="action.icon")
20
20
  KIcon(:iconname="action.icon" :width="16" :height="16")
21
21
  template(#default v-if="!action.iconOnly && !action.icon") {{action.label}}
22
- .info {{ t('Selected {count} items').replace('{count}', props.selectedRows.length.toString()) }}
22
+ .info {{ props.selectAll ? t('All items selected') : t('Selected {count} items').replace('{count}', props.selectedRows.length.toString()) }}
23
23
  </template>
24
24
 
25
25
  <script setup lang="ts">
@@ -5,10 +5,13 @@ type __VLS_Props = {
5
5
  label?: string;
6
6
  validation?: 'success' | 'warning' | 'error' | null;
7
7
  validationText?: string;
8
+ idKey?: string;
8
9
  };
9
10
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
11
+ blur: (event: FocusEvent) => any;
10
12
  "update:model": (value: any) => any;
11
13
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
14
+ onBlur?: ((event: FocusEvent) => any) | undefined;
12
15
  "onUpdate:model"?: ((value: any) => any) | undefined;
13
16
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
14
17
  declare const _default: typeof __VLS_export;
@@ -6,6 +6,7 @@
6
6
  :aria-disabled="isDisabled"
7
7
  tabindex="0"
8
8
  @keydown.space.prevent="handleSpaceKey"
9
+ @blur="emit('blur', $event)"
9
10
  )
10
11
  input(type="checkbox" :checked="isChecked" :disabled="isDisabled" tabindex="-1" @change="toggleCheckbox")
11
12
  .icon-container(:class="validation ? `is-${validation}` : ''")
@@ -28,10 +29,12 @@ const props = defineProps<{
28
29
  label?: string
29
30
  validation?: 'success' | 'warning' | 'error' | null
30
31
  validationText?: string
32
+ idKey?: string
31
33
  }>()
32
34
 
33
35
  const emit = defineEmits<{
34
36
  (e: 'update:model', value: any): void
37
+ (e: 'blur', event: FocusEvent): void
35
38
  }>()
36
39
 
37
40
  const internalModel = computed({
@@ -41,6 +44,10 @@ const internalModel = computed({
41
44
 
42
45
  const getId = (item: any) => {
43
46
  if (item && typeof item === 'object') {
47
+ const key = props.idKey
48
+ if (key && item[key] !== undefined && item[key] !== null) {
49
+ return item[key]
50
+ }
44
51
  return item.id ?? item._id ?? item
45
52
  }
46
53
  return item
@@ -5,10 +5,13 @@ type __VLS_Props = {
5
5
  label?: string;
6
6
  validation?: 'success' | 'warning' | 'error' | null;
7
7
  validationText?: string;
8
+ idKey?: string;
8
9
  };
9
10
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
11
+ blur: (event: FocusEvent) => any;
10
12
  "update:model": (value: any) => any;
11
13
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
14
+ onBlur?: ((event: FocusEvent) => any) | undefined;
12
15
  "onUpdate:model"?: ((value: any) => any) | undefined;
13
16
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
14
17
  declare const _default: typeof __VLS_export;
@@ -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
  }>, {
@@ -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({
@@ -129,7 +131,7 @@ watch(isOptionsOpenModel, (isOpen, oldOpen) => {
129
131
  display: flex;
130
132
  flex-direction: column;
131
133
  flex: 1;
132
- min-width: 0;
134
+ min-width: var(--input-min-width, 140px);
133
135
  }
134
136
 
135
137
  .KCombobox {
@@ -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(:model-value="isRowSelected(row)" @update:model-value="toggleRow(row)" :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,48 @@ 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) => {
171
+ if (selectAll.value) return true
158
172
  const idKey = (props.dataProvider as any)?.idKey || 'id'
159
173
  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)
174
+ return selectedRowIds.value.has(rowId) || selectedRowIds.value.has(row)
175
+ }
176
+
177
+ const toggleRow = (row: any) => {
178
+ const idKey = (props.dataProvider as any)?.idKey || 'id'
179
+ const rowId = row?.[idKey] ?? row?.id ?? row?._id ?? row
180
+ if (selectAll.value) {
181
+ selectAll.value = false
182
+ const activeRows = displayRows.value || pageRows.value
183
+ selectedRows.value = activeRows.filter((r: any) => {
184
+ const rId = r?.[idKey] ?? r?.id ?? r?._id ?? r
185
+ return rId !== rowId && r !== row
186
+ })
187
+ } else {
188
+ const isSelected = isRowSelected(row)
189
+ if (isSelected) {
190
+ selectedRows.value = (selectedRows.value || []).filter((r: any) => {
191
+ const rId = r?.[idKey] ?? r?.id ?? r?._id ?? r
192
+ return rId !== rowId && r !== row
193
+ })
194
+ } else {
195
+ selectedRows.value = [...(selectedRows.value || []), row]
196
+ }
197
+ }
161
198
  }
162
199
 
163
200
  const getCellSlot = (fieldName: string) => {
@@ -173,10 +210,14 @@ const getHeaderSlot = (fieldName: string) => {
173
210
  const getColumnStyle = (field: string) => {
174
211
  const w = props.columnWidths?.[field]
175
212
  if (!w) return undefined
176
- return { width: w, whiteSpace: 'nowrap' as const }
213
+ const style: Record<string, string> = { width: w, whiteSpace: 'nowrap' }
214
+ if (w !== '1%' && !w.endsWith('%')) {
215
+ style.minWidth = w
216
+ }
217
+ return style
177
218
  }
178
219
 
179
- const { pageData, filter: dpFilter, loading: dpLoading, initialLoad: dpInitialLoad } = useDataProvider(props.dataProvider)
220
+ const { pageData, virtualRows, filter: dpFilter, loading: dpLoading, initialLoad: dpInitialLoad } = useDataProvider(props.dataProvider)
180
221
  const pageRows = computed(() => pageData.value || [])
181
222
 
182
223
  const effectivePageSize = computed(() => {
@@ -193,6 +234,9 @@ const datatableItems = computed(() => {
193
234
  const currentRows = pageRows.value
194
235
  const dp = props.dataProvider as any
195
236
  if (props.virtualScroll) {
237
+ if (Array.isArray(dp?.rowMap)) return dp.rowMap
238
+ if (Array.isArray(dp?.rowMap?.value)) return dp.rowMap.value
239
+ if (Array.isArray(virtualRows?.value) && virtualRows.value.length > 0) return virtualRows.value
196
240
  if (Array.isArray(dp?.allVisibleRows)) return dp.allVisibleRows
197
241
  if (Array.isArray(dp?.allVisibleRows?.value)) return dp.allVisibleRows.value
198
242
  if (Array.isArray(dp?.allVisibleNodes)) return dp.allVisibleNodes
@@ -245,6 +289,7 @@ const totalColspan = computed(() => {
245
289
  })
246
290
 
247
291
  const focusedIndex = ref<number>(-1)
292
+ const theadStickyOffset = 40
248
293
  const handleKeyDown = (e: KeyboardEvent) => {
249
294
  if (!props.virtualScroll) return
250
295
  const total = datatableItems.value.length
@@ -253,21 +298,21 @@ const handleKeyDown = (e: KeyboardEvent) => {
253
298
  if (e.key === 'ArrowDown') {
254
299
  e.preventDefault()
255
300
  focusedIndex.value = Math.min(total - 1, focusedIndex.value + 1)
256
- scrollToIndex(focusedIndex.value)
301
+ scrollToIndex(focusedIndex.value, 'auto', focusedIndex.value > 0 ? theadStickyOffset : 0)
257
302
  } else if (e.key === 'ArrowUp') {
258
303
  e.preventDefault()
259
304
  focusedIndex.value = Math.max(0, focusedIndex.value - 1)
260
- scrollToIndex(focusedIndex.value)
305
+ scrollToIndex(focusedIndex.value, 'auto', focusedIndex.value > 0 ? theadStickyOffset : 0)
261
306
  } else if (e.key === 'PageDown') {
262
307
  e.preventDefault()
263
308
  const step = Math.floor((props.viewportHeight || 500) / (props.itemHeight || 40))
264
309
  focusedIndex.value = Math.min(total - 1, focusedIndex.value + step)
265
- scrollToIndex(focusedIndex.value)
310
+ scrollToIndex(focusedIndex.value, 'auto', focusedIndex.value > 0 ? theadStickyOffset : 0)
266
311
  } else if (e.key === 'PageUp') {
267
312
  e.preventDefault()
268
313
  const step = Math.floor((props.viewportHeight || 500) / (props.itemHeight || 40))
269
314
  focusedIndex.value = Math.max(0, focusedIndex.value - step)
270
- scrollToIndex(focusedIndex.value)
315
+ scrollToIndex(focusedIndex.value, 'auto', focusedIndex.value > 0 ? theadStickyOffset : 0)
271
316
  } else if (e.key === 'Home') {
272
317
  e.preventDefault()
273
318
  focusedIndex.value = 0
@@ -275,7 +320,7 @@ const handleKeyDown = (e: KeyboardEvent) => {
275
320
  } else if (e.key === 'End') {
276
321
  e.preventDefault()
277
322
  focusedIndex.value = total - 1
278
- scrollToIndex(total - 1)
323
+ scrollToIndex(total - 1, 'auto', theadStickyOffset)
279
324
  }
280
325
  }
281
326
  </script>
@@ -287,9 +332,13 @@ const handleKeyDown = (e: KeyboardEvent) => {
287
332
  .datatable-container {
288
333
  min-height: calc(var(--page-height) * (var(--page-size) + 1));
289
334
  position: relative; // Ensure loader overlay is contained
335
+ overflow-x: auto;
336
+ -webkit-overflow-scrolling: touch;
337
+ width: 100%;
290
338
  }
291
339
  table {
292
340
  width: 100%;
341
+ min-width: 100%;
293
342
  border-collapse: collapse;
294
343
  border: 1px solid var(--table-border-color, #e2e8f0);
295
344
  thead {
@@ -300,7 +349,8 @@ const handleKeyDown = (e: KeyboardEvent) => {
300
349
  color: var(--table-header-color, #334155);
301
350
  border-bottom: 1px solid var(--table-border-color, #e2e8f0);
302
351
  border-left: 1px solid var(--table-border-color, #e2e8f0);
303
- padding: 5px;
352
+ padding: 6px 8px;
353
+ white-space: nowrap;
304
354
  &:first-child {
305
355
  border-left: none;
306
356
  }
@@ -309,10 +359,10 @@ const handleKeyDown = (e: KeyboardEvent) => {
309
359
  }
310
360
  tbody {
311
361
  tr {
312
- height: 40px;
362
+ height: var(--virtual-item-height, 40px);
313
363
  background-color: var(--table-row-bg, #ffffff);
314
364
  color: var(--table-row-text-color, #1e293b);
315
- &:nth-child(2n + 1) {
365
+ &.alt-row {
316
366
  background-color: var(--table-row-alt-bg, #f8fafc);
317
367
  }
318
368
  &:hover {
@@ -323,9 +373,10 @@ const handleKeyDown = (e: KeyboardEvent) => {
323
373
  outline-offset: -2px;
324
374
  }
325
375
  td {
326
- padding: 5px;
376
+ padding: 6px 8px;
327
377
  border-bottom: 1px solid var(--table-border-color, #e2e8f0);
328
378
  border-left: 1px solid var(--table-border-color, #e2e8f0);
379
+ white-space: nowrap;
329
380
  &:first-child {
330
381
  border-left: none;
331
382
  }
@@ -334,6 +385,7 @@ const handleKeyDown = (e: KeyboardEvent) => {
334
385
  text-align: center;
335
386
  padding: 20px;
336
387
  color: var(--font-color-secondary, #64748b);
388
+ white-space: normal;
337
389
  }
338
390
  }
339
391
  }
@@ -359,13 +411,31 @@ const handleKeyDown = (e: KeyboardEvent) => {
359
411
  display: flex;
360
412
  justify-content: space-between;
361
413
  align-items: center;
414
+ gap: var(--spacing-md, 1rem);
415
+ margin-top: var(--spacing-sm, 0.5rem);
416
+
362
417
  .pagination {
363
418
  flex: 1;
364
419
  }
420
+
421
+ @media (max-width: 768px) {
422
+ flex-direction: column;
423
+ align-items: stretch;
424
+ gap: var(--spacing-sm, 0.75rem);
425
+
426
+ .bulk-actions {
427
+ width: 100%;
428
+ }
429
+
430
+ .pagination {
431
+ width: 100%;
432
+ }
433
+ }
365
434
  }
366
435
 
367
436
  &.is-virtual-scroll {
368
437
  .datatable-container {
438
+ overflow-x: auto;
369
439
  overflow-y: auto;
370
440
  max-height: var(--k-datatable-viewport-height, 500px);
371
441
  min-height: 0;