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

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 (120) hide show
  1. package/bin/create-preset.mjs +5 -4
  2. package/dist/compiled/composables/useKatluxContext.mjs +6 -3
  3. package/dist/compiled/composables/useKatluxForm.mjs +268 -0
  4. package/dist/compiled/composables/useToast.mjs +164 -0
  5. package/dist/compiled/composables/useVirtualScroll.mjs +176 -0
  6. package/dist/module.cjs +1 -0
  7. package/dist/module.json +1 -1
  8. package/dist/module.mjs +1 -0
  9. package/dist/runtime/components/KBulkActions/KBulkActions.global.d.vue.ts +6 -2
  10. package/dist/runtime/components/KBulkActions/KBulkActions.global.vue +3 -3
  11. package/dist/runtime/components/KBulkActions/KBulkActions.global.vue.d.ts +6 -2
  12. package/dist/runtime/components/KBulkActions/KBulkActions.logic.js +9 -0
  13. package/dist/runtime/components/KCombobox/KCombobox.global.d.vue.ts +9 -0
  14. package/dist/runtime/components/KCombobox/KCombobox.global.vue +2 -1
  15. package/dist/runtime/components/KCombobox/KCombobox.global.vue.d.ts +9 -0
  16. package/dist/runtime/components/KCombobox/KCombobox.logic.d.ts +5 -0
  17. package/dist/runtime/components/KCombobox/KCombobox.logic.js +22 -3
  18. package/dist/runtime/components/KDatatable/KDataIterator.global.d.vue.ts +8 -0
  19. package/dist/runtime/components/KDatatable/KDataIterator.global.vue +10 -2
  20. package/dist/runtime/components/KDatatable/KDataIterator.global.vue.d.ts +8 -0
  21. package/dist/runtime/components/KDatatable/KDataIterator.logic.d.ts +8 -0
  22. package/dist/runtime/components/KDatatable/KDataIterator.logic.js +10 -2
  23. package/dist/runtime/components/KDatatable/KDatatable.global.d.vue.ts +8 -0
  24. package/dist/runtime/components/KDatatable/KDatatable.global.vue +12 -4
  25. package/dist/runtime/components/KDatatable/KDatatable.global.vue.d.ts +8 -0
  26. package/dist/runtime/components/KDatatable/KDatatable.logic.d.ts +8 -0
  27. package/dist/runtime/components/KDatatable/KDatatable.logic.js +11 -3
  28. package/dist/runtime/components/KDatePicker/KDatePicker.global.d.vue.ts +2 -0
  29. package/dist/runtime/components/KDatePicker/KDatePicker.global.vue +5 -1
  30. package/dist/runtime/components/KDatePicker/KDatePicker.global.vue.d.ts +2 -0
  31. package/dist/runtime/components/KDatePicker/KDatePicker.logic.js +7 -6
  32. package/dist/runtime/components/KDateTimePicker/KDateTimePicker.logic.js +7 -6
  33. package/dist/runtime/components/KDropdown/KDropdown.global.d.vue.ts +9 -0
  34. package/dist/runtime/components/KDropdown/KDropdown.global.vue +2 -1
  35. package/dist/runtime/components/KDropdown/KDropdown.global.vue.d.ts +9 -0
  36. package/dist/runtime/components/KDropdown/KDropdown.logic.d.ts +5 -0
  37. package/dist/runtime/components/KDropdown/KDropdown.logic.js +10 -7
  38. package/dist/runtime/components/KGantt/KGantt.logic.js +11 -4
  39. package/dist/runtime/components/KPagination/KPagination.logic.js +7 -4
  40. package/dist/runtime/components/KToast/KToast.global.d.vue.ts +24 -1
  41. package/dist/runtime/components/KToast/KToast.global.vue +12 -2
  42. package/dist/runtime/components/KToast/KToast.global.vue.d.ts +24 -1
  43. package/dist/runtime/components/KToast/KToast.logic.d.ts +13 -0
  44. package/dist/runtime/components/KToast/KToast.logic.js +45 -5
  45. package/dist/runtime/components/KToastContainer/KToastContainer.global.d.vue.ts +3 -0
  46. package/dist/runtime/components/KToastContainer/KToastContainer.global.vue +11 -0
  47. package/dist/runtime/components/KToastContainer/KToastContainer.global.vue.d.ts +3 -0
  48. package/dist/runtime/components/KTooltip/KTooltip.global.d.vue.ts +1 -1
  49. package/dist/runtime/components/KTooltip/KTooltip.global.vue.d.ts +1 -1
  50. package/dist/runtime/components/KTree/KTree.global.d.vue.ts +38 -0
  51. package/dist/runtime/components/KTree/KTree.global.vue +7 -3
  52. package/dist/runtime/components/KTree/KTree.global.vue.d.ts +38 -0
  53. package/dist/runtime/components/KTree/KTree.logic.d.ts +21 -0
  54. package/dist/runtime/components/KTree/KTree.logic.js +17 -0
  55. package/dist/runtime/components/KTreePicker/KTreePicker.global.d.vue.ts +52 -1
  56. package/dist/runtime/components/KTreePicker/KTreePicker.global.vue +30 -3
  57. package/dist/runtime/components/KTreePicker/KTreePicker.global.vue.d.ts +52 -1
  58. package/dist/runtime/components/KTreePicker/KTreePicker.logic.d.ts +20 -0
  59. package/dist/runtime/components/KTreePicker/KTreePicker.logic.js +16 -0
  60. package/dist/runtime/components/KTreeView/KTreeView.global.d.vue.ts +36 -0
  61. package/dist/runtime/components/KTreeView/KTreeView.global.vue +5 -1
  62. package/dist/runtime/components/KTreeView/KTreeView.global.vue.d.ts +36 -0
  63. package/dist/runtime/components/KTreeView/KTreeView.logic.d.ts +20 -0
  64. package/dist/runtime/components/KTreeView/KTreeView.logic.js +16 -0
  65. package/dist/runtime/composables/useKatluxContext.js +6 -3
  66. package/dist/runtime/composables/useKatluxForm.d.ts +143 -0
  67. package/dist/runtime/composables/useKatluxForm.js +268 -0
  68. package/dist/runtime/composables/useToast.d.ts +49 -0
  69. package/dist/runtime/composables/useToast.js +164 -0
  70. package/dist/runtime/composables/useVirtualScroll.d.ts +34 -0
  71. package/dist/runtime/composables/useVirtualScroll.js +176 -0
  72. package/dist/runtime/plugins/PresetPlugin.js +9 -1
  73. package/dist/runtime/plugins/nuxtCompatPlugin.js +0 -1
  74. package/dist/runtime/plugins/toastPlugin.client.d.ts +2 -0
  75. package/dist/runtime/plugins/toastPlugin.client.js +16 -0
  76. package/dist/runtime/presets/default/components/KBulkActions/KBulkActions.vue +1 -0
  77. package/dist/runtime/presets/default/components/KCheckbox/KCheckbox.vue +36 -7
  78. package/dist/runtime/presets/default/components/KCombobox/KCombobox.d.vue.ts +1 -0
  79. package/dist/runtime/presets/default/components/KCombobox/KCombobox.vue +10 -4
  80. package/dist/runtime/presets/default/components/KCombobox/KCombobox.vue.d.ts +1 -0
  81. package/dist/runtime/presets/default/components/KCombobox/KComboboxList.d.vue.ts +1 -0
  82. package/dist/runtime/presets/default/components/KCombobox/KComboboxList.vue +7 -2
  83. package/dist/runtime/presets/default/components/KCombobox/KComboboxList.vue.d.ts +1 -0
  84. package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.d.vue.ts +10 -1
  85. package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.vue +128 -6
  86. package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.vue.d.ts +10 -1
  87. package/dist/runtime/presets/default/components/KDatatable/KDatatable.d.vue.ts +12 -1
  88. package/dist/runtime/presets/default/components/KDatatable/KDatatable.vue +206 -27
  89. package/dist/runtime/presets/default/components/KDatatable/KDatatable.vue.d.ts +12 -1
  90. package/dist/runtime/presets/default/components/KDropdown/KDropdown.d.vue.ts +1 -0
  91. package/dist/runtime/presets/default/components/KDropdown/KDropdown.vue +23 -2
  92. package/dist/runtime/presets/default/components/KDropdown/KDropdown.vue.d.ts +1 -0
  93. package/dist/runtime/presets/default/components/KLayout/KLayout.vue +4 -2
  94. package/dist/runtime/presets/default/components/KModal/KModal.vue +8 -1
  95. package/dist/runtime/presets/default/components/KTabs/KTabItem.vue +1 -1
  96. package/dist/runtime/presets/default/components/KTextbox/KTextbox.vue +6 -4
  97. package/dist/runtime/presets/default/components/KToast/KToast.d.vue.ts +6 -0
  98. package/dist/runtime/presets/default/components/KToast/KToast.vue +22 -4
  99. package/dist/runtime/presets/default/components/KToast/KToast.vue.d.ts +6 -0
  100. package/dist/runtime/presets/default/components/KToastContainer/KToastContainer.d.vue.ts +11 -0
  101. package/dist/runtime/presets/default/components/KToastContainer/KToastContainer.vue +207 -0
  102. package/dist/runtime/presets/default/components/KToastContainer/KToastContainer.vue.d.ts +11 -0
  103. package/dist/runtime/presets/default/components/KTree/KTree.d.vue.ts +15 -5
  104. package/dist/runtime/presets/default/components/KTree/KTree.vue +232 -13
  105. package/dist/runtime/presets/default/components/KTree/KTree.vue.d.ts +15 -5
  106. package/dist/runtime/presets/default/components/KTreePicker/KTreePicker.d.vue.ts +14 -1
  107. package/dist/runtime/presets/default/components/KTreePicker/KTreePicker.vue +118 -13
  108. package/dist/runtime/presets/default/components/KTreePicker/KTreePicker.vue.d.ts +14 -1
  109. package/dist/runtime/presets/default/components/KTreeView/KTreeCell.vue +12 -3
  110. package/dist/runtime/presets/default/components/KTreeView/KTreeView.d.vue.ts +4 -0
  111. package/dist/runtime/presets/default/components/KTreeView/KTreeView.vue +8 -0
  112. package/dist/runtime/presets/default/components/KTreeView/KTreeView.vue.d.ts +4 -0
  113. package/dist/runtime/server/middleware/session.js +1 -1
  114. package/package.json +3 -4
  115. package/dist/compiled/composables/useDataProvider.spec.mjs +0 -157
  116. package/dist/compiled/composables/useKatluxContext.spec.mjs +0 -63
  117. package/dist/compiled/composables/useKatluxI18n.spec.mjs +0 -10
  118. package/dist/compiled/composables/usePresetComponent.spec.mjs +0 -106
  119. package/dist/compiled/composables/useTemplate.spec.mjs +0 -30
  120. package/dist/compiled/utils/PresetResolver.spec.mjs +0 -68
@@ -15,6 +15,10 @@ type __VLS_Props = {
15
15
  columnWidths?: Record<string, string>;
16
16
  emptyStateText?: string;
17
17
  emptyFilterStateText?: string;
18
+ virtualScroll?: boolean;
19
+ itemHeight?: number;
20
+ viewportHeight?: number;
21
+ buffer?: number;
18
22
  };
19
23
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
20
24
  "update:currentPage": (value: number) => any;
@@ -26,6 +30,13 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
26
30
  "onUpdate:pageSize"?: ((value: number) => any) | undefined;
27
31
  "onUpdate:selectedRows"?: ((value: any[]) => any) | undefined;
28
32
  "onUpdate:selectAll"?: ((value: boolean) => any) | undefined;
29
- }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
33
+ }>, {
34
+ virtualScroll: boolean;
35
+ itemHeight: number;
36
+ buffer: number;
37
+ viewportHeight: number;
38
+ emptyStateText: string;
39
+ emptyFilterStateText: string;
40
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
30
41
  declare const _default: typeof __VLS_export;
31
42
  export default _default;
@@ -1,12 +1,22 @@
1
1
  <template lang="pug">
2
- .k-datatable(:style="{ '--page-size': props.dataProvider?.pageSize?.value || 10 }" role="region" :aria-label="t('Data Table')")
2
+ .k-datatable(
3
+ :class="{ 'is-virtual-scroll': props.virtualScroll }"
4
+ :style="props.virtualScroll ? { ...containerCssVars, '--k-datatable-viewport-height': (props.viewportHeight || 500) + 'px' } : { '--page-size': effectivePageSize }"
5
+ role="region"
6
+ :aria-label="t('Data Table')"
7
+ )
3
8
  KGrid(:flex-child="true" align="stretch" direction="column")
4
- .datatable-container
9
+ .datatable-container(
10
+ ref="containerRef"
11
+ @scroll="props.virtualScroll ? onScroll($event) : undefined"
12
+ @keydown="handleKeyDown"
13
+ :tabindex="props.virtualScroll ? 0 : undefined"
14
+ )
5
15
  KLoader(:loading="isLoading" overlay)
6
16
  table(role="grid" :aria-busy="isLoading")
7
17
  thead
8
18
  tr
9
- th.check(v-if="props.bulkActions && props.bulkActions.length>0")
19
+ th.check(v-if="props.bulkActions && props.bulkActions.length > 0")
10
20
  KCheckbox(v-model="selectAll")
11
21
  th(
12
22
  v-for="field in visibleFields || props.dataProvider.fields"
@@ -16,15 +26,25 @@
16
26
  )
17
27
  component(v-if="getHeaderSlot(field)" :is="getHeaderSlot(field)" :field="field")
18
28
  span(v-else) {{ columnHeaders?.[field] ?? field }}
19
- th(v-if="props.rowActions && props.rowActions.length>0")
29
+ th(v-if="props.rowActions && props.rowActions.length > 0")
20
30
 
21
31
  tbody
22
- tr.empty-row(v-if="!isLoading && (!pageRows || pageRows.length === 0)")
23
- td.empty-state(:colspan="(visibleFields || props.dataProvider.fields || []).length + (props.bulkActions && props.bulkActions.length > 0 ? 1 : 0) + (props.rowActions && props.rowActions.length > 0 ? 1 : 0)")
32
+ tr.empty-row(v-if="!isLoading && (!datatableItems || datatableItems.length === 0)")
33
+ td.empty-state(:colspan="totalColspan")
24
34
  span(v-if="dpFilter?.active || props.dataProvider.filter?.value?.active") {{ props.emptyFilterStateText || t('No result found for filter') }}
25
35
  span(v-else) {{ props.emptyStateText || t('No result') }}
26
- tr(v-for="(row, index) in pageRows" :key="getRowKey(row, index)")
27
- td.check(v-if="props.bulkActions && props.bulkActions.length>0")
36
+ tr.k-virtual-spacer.is-top(
37
+ v-if="props.virtualScroll && topSpacerHeight > 0"
38
+ :style="{ '--spacer-height': topSpacerHeight + 'px' }"
39
+ role="presentation"
40
+ )
41
+ td(:colspan="totalColspan")
42
+ tr(
43
+ v-for="(row, index) in displayRows"
44
+ :key="getRowKey(row, index)"
45
+ :class="{ 'selected': isRowSelected(row), 'active-focus': focusedIndex === (props.virtualScroll ? startIndex + index : index) }"
46
+ )
47
+ td.check(v-if="props.bulkActions && props.bulkActions.length > 0")
28
48
  KCheckbox(:value="row" v-model="selectedRows")
29
49
  td(
30
50
  v-for="visibleField in visibleFields || props.dataProvider.fields"
@@ -34,7 +54,7 @@
34
54
  )
35
55
  component(v-if="getCellSlot(visibleField)" :is="getCellSlot(visibleField)" :row="row" :field="visibleField" :value="row[visibleField]")
36
56
  span(v-else) {{ row[visibleField] }}
37
- td.rowAction(v-if="props.rowActions && props.rowActions.length>0")
57
+ td.rowAction(v-if="props.rowActions && props.rowActions.length > 0")
38
58
  template(v-for="rowAction in props.rowActions" :key="rowAction.label")
39
59
  KTooltip(
40
60
  v-if="!rowAction.visible || rowAction.visible(row)"
@@ -51,21 +71,30 @@
51
71
  template(#icon v-if="rowAction.icon")
52
72
  KIcon(:iconname="rowAction.icon" :width="16" :height="16")
53
73
  template(#default v-if="!rowAction.iconOnly && !rowAction.icon") {{rowAction.label}}
54
- .footer
55
- KBulkActions.bulk-actions(v-if="props.bulkActions && props.bulkActions.length>0" :bulkActions="props.bulkActions" :selectedRows="selectedRows" :selectAll="selectAll")
56
- KPagination.pagination(:dataProvider="props.dataProvider" :currentPage="props.currentPage" :pageSize="props.pageSize" @update:currentPage="emit('update:currentPage', $event)" @update:pageSize="emit('update:pageSize', $event)")
74
+ tr.k-virtual-spacer.is-bottom(
75
+ v-if="props.virtualScroll && bottomSpacerHeight > 0"
76
+ :style="{ '--spacer-height': bottomSpacerHeight + 'px' }"
77
+ role="presentation"
78
+ )
79
+ td(:colspan="totalColspan")
80
+ .footer(v-if="!props.virtualScroll")
81
+ KBulkActions.bulk-actions(v-if="props.bulkActions && props.bulkActions.length > 0" :bulkActions="props.bulkActions" :selectedRows="selectedRows" :selectAll="selectAll")
82
+ KPagination.pagination(:dataProvider="props.dataProvider" @update:currentPage="emit('update:currentPage', $event)" @update:pageSize="emit('update:pageSize', $event)")
83
+ .footer.virtual-footer(v-else-if="props.bulkActions && props.bulkActions.length > 0")
84
+ KBulkActions.bulk-actions(:bulkActions="props.bulkActions" :selectedRows="selectedRows" :selectAll="selectAll")
57
85
  </template>
58
86
 
59
87
  <script setup lang="ts">
60
- import { computed } from 'vue'
88
+ import { ref, computed, isRef } from 'vue'
61
89
  import { ADataProvider } from '@katlux/providers'
62
90
  import type { IKDatatableAction } from '@katlux/providers'
63
91
  import { useKatluxI18n } from '#toolkit/composables/useKatluxI18n'
64
92
  import { useDataProvider } from '#toolkit/composables/useDataProvider'
93
+ import { useVirtualScroll } from '#toolkit/composables/useVirtualScroll'
65
94
 
66
95
  const { t } = useKatluxI18n()
67
96
 
68
- const props = defineProps<{
97
+ const props = withDefaults(defineProps<{
69
98
  dataProvider: ADataProvider
70
99
  visibleFields: Array<string> | null
71
100
  rowActions: Array<IKDatatableAction>
@@ -80,7 +109,18 @@ const props = defineProps<{
80
109
  columnWidths?: Record<string, string>
81
110
  emptyStateText?: string
82
111
  emptyFilterStateText?: string
83
- }>()
112
+ virtualScroll?: boolean
113
+ itemHeight?: number
114
+ viewportHeight?: number
115
+ buffer?: number
116
+ }>(), {
117
+ virtualScroll: false,
118
+ itemHeight: 40,
119
+ viewportHeight: 500,
120
+ buffer: 5,
121
+ emptyStateText: 'no result',
122
+ emptyFilterStateText: 'no result found for filter',
123
+ })
84
124
 
85
125
  const emit = defineEmits<{
86
126
  (e: 'update:selectedRows', value: any[]): void
@@ -114,6 +154,12 @@ const getRowKey = (row: any, index: number): string | number => {
114
154
  return index
115
155
  }
116
156
 
157
+ const isRowSelected = (row: any) => {
158
+ const idKey = (props.dataProvider as any)?.idKey || 'id'
159
+ 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)
161
+ }
162
+
117
163
  const getCellSlot = (fieldName: string) => {
118
164
  const slotName = 'cell-' + fieldName
119
165
  return props.cellSlots?.[slotName]
@@ -133,9 +179,105 @@ const getColumnStyle = (field: string) => {
133
179
  const { pageData, filter: dpFilter, loading: dpLoading, initialLoad: dpInitialLoad } = useDataProvider(props.dataProvider)
134
180
  const pageRows = computed(() => pageData.value || [])
135
181
 
182
+ const effectivePageSize = computed(() => {
183
+ const ps = props.pageSize ?? props.dataProvider?.pageSize
184
+ return isRef(ps) ? ps.value : ((ps as any)?.value ?? ps ?? 10)
185
+ })
186
+
136
187
  const isLoading = computed(() => {
137
188
  return dpLoading.value || dpInitialLoad.value || false
138
189
  })
190
+
191
+ // Data source for virtualization: full items array when virtualScroll is true
192
+ const datatableItems = computed(() => {
193
+ const currentRows = pageRows.value
194
+ const dp = props.dataProvider as any
195
+ if (props.virtualScroll) {
196
+ if (Array.isArray(dp?.allVisibleRows)) return dp.allVisibleRows
197
+ if (Array.isArray(dp?.allVisibleRows?.value)) return dp.allVisibleRows.value
198
+ if (Array.isArray(dp?.allVisibleNodes)) return dp.allVisibleNodes
199
+ if (Array.isArray(dp?.allVisibleNodes?.value)) return dp.allVisibleNodes.value
200
+ if (Array.isArray(dp?.allData?.value)) return dp.allData.value
201
+ if (Array.isArray(dp?.allData)) return dp.allData
202
+ if (Array.isArray(dp?.data)) return dp.data
203
+ }
204
+ return currentRows
205
+ })
206
+
207
+ const {
208
+ visibleItems,
209
+ startIndex,
210
+ endIndex,
211
+ topSpacerHeight,
212
+ bottomSpacerHeight,
213
+ containerRef,
214
+ onScroll,
215
+ scrollToIndex,
216
+ containerCssVars
217
+ } = useVirtualScroll({
218
+ items: datatableItems,
219
+ itemHeight: props.itemHeight || 40,
220
+ containerHeight: props.viewportHeight || 500,
221
+ buffer: props.buffer ?? 5,
222
+ virtualScroll: computed(() => !!props.virtualScroll),
223
+ onThresholdReach: () => {
224
+ const dp = props.dataProvider as any
225
+ if (typeof dp?.loadMore === 'function') {
226
+ dp.loadMore()
227
+ } else if (typeof dp?.nextPage === 'function' && dp.hasMore) {
228
+ dp.nextPage()
229
+ }
230
+ }
231
+ })
232
+
233
+ const displayRows = computed(() => {
234
+ if (props.virtualScroll) {
235
+ return visibleItems.value
236
+ }
237
+ return pageRows.value
238
+ })
239
+
240
+ const totalColspan = computed(() => {
241
+ const fieldsCount = (props.visibleFields || (props.dataProvider as any)?.fields || []).length
242
+ const checkCount = props.bulkActions && props.bulkActions.length > 0 ? 1 : 0
243
+ const actionCount = props.rowActions && props.rowActions.length > 0 ? 1 : 0
244
+ return fieldsCount + checkCount + actionCount
245
+ })
246
+
247
+ const focusedIndex = ref<number>(-1)
248
+ const handleKeyDown = (e: KeyboardEvent) => {
249
+ if (!props.virtualScroll) return
250
+ const total = datatableItems.value.length
251
+ if (total === 0) return
252
+
253
+ if (e.key === 'ArrowDown') {
254
+ e.preventDefault()
255
+ focusedIndex.value = Math.min(total - 1, focusedIndex.value + 1)
256
+ scrollToIndex(focusedIndex.value)
257
+ } else if (e.key === 'ArrowUp') {
258
+ e.preventDefault()
259
+ focusedIndex.value = Math.max(0, focusedIndex.value - 1)
260
+ scrollToIndex(focusedIndex.value)
261
+ } else if (e.key === 'PageDown') {
262
+ e.preventDefault()
263
+ const step = Math.floor((props.viewportHeight || 500) / (props.itemHeight || 40))
264
+ focusedIndex.value = Math.min(total - 1, focusedIndex.value + step)
265
+ scrollToIndex(focusedIndex.value)
266
+ } else if (e.key === 'PageUp') {
267
+ e.preventDefault()
268
+ const step = Math.floor((props.viewportHeight || 500) / (props.itemHeight || 40))
269
+ focusedIndex.value = Math.max(0, focusedIndex.value - step)
270
+ scrollToIndex(focusedIndex.value)
271
+ } else if (e.key === 'Home') {
272
+ e.preventDefault()
273
+ focusedIndex.value = 0
274
+ scrollToIndex(0)
275
+ } else if (e.key === 'End') {
276
+ e.preventDefault()
277
+ focusedIndex.value = total - 1
278
+ scrollToIndex(total - 1)
279
+ }
280
+ }
139
281
  </script>
140
282
 
141
283
  <style lang="scss" scoped>
@@ -149,15 +291,15 @@ const isLoading = computed(() => {
149
291
  table {
150
292
  width: 100%;
151
293
  border-collapse: collapse;
152
- border: 1px solid var(--table-border-color);
294
+ border: 1px solid var(--table-border-color, #e2e8f0);
153
295
  thead {
154
296
  tr {
155
- background-color: var(--table-header-bg);
297
+ background-color: var(--table-header-bg, #f8fafc);
156
298
  height: var(--page-height);
157
299
  th {
158
- color: var(--table-header-color);
159
- border-bottom: 1px solid var(--table-border-color);
160
- border-left: 1px solid var(--table-border-color);
300
+ color: var(--table-header-color, #334155);
301
+ border-bottom: 1px solid var(--table-border-color, #e2e8f0);
302
+ border-left: 1px solid var(--table-border-color, #e2e8f0);
161
303
  padding: 5px;
162
304
  &:first-child {
163
305
  border-left: none;
@@ -168,18 +310,22 @@ const isLoading = computed(() => {
168
310
  tbody {
169
311
  tr {
170
312
  height: 40px;
171
- background-color: var(--table-row-bg);
172
- color: var(--table-row-text-color);
313
+ background-color: var(--table-row-bg, #ffffff);
314
+ color: var(--table-row-text-color, #1e293b);
173
315
  &:nth-child(2n + 1) {
174
- background-color: var(--table-row-alt-bg);
316
+ background-color: var(--table-row-alt-bg, #f8fafc);
175
317
  }
176
318
  &:hover {
177
- background-color: var(--table-row-hover-bg);
319
+ background-color: var(--table-row-hover-bg, #f1f5f9);
320
+ }
321
+ &.active-focus {
322
+ outline: 2px solid var(--color-primary, #3b82f6);
323
+ outline-offset: -2px;
178
324
  }
179
325
  td {
180
326
  padding: 5px;
181
- border-bottom: 1px solid var(--table-border-color);
182
- border-left: 1px solid var(--table-border-color);
327
+ border-bottom: 1px solid var(--table-border-color, #e2e8f0);
328
+ border-left: 1px solid var(--table-border-color, #e2e8f0);
183
329
  &:first-child {
184
330
  border-left: none;
185
331
  }
@@ -187,7 +333,7 @@ const isLoading = computed(() => {
187
333
  td.empty-state {
188
334
  text-align: center;
189
335
  padding: 20px;
190
- color: var(--font-color-secondary);
336
+ color: var(--font-color-secondary, #64748b);
191
337
  }
192
338
  }
193
339
  }
@@ -217,5 +363,38 @@ const isLoading = computed(() => {
217
363
  flex: 1;
218
364
  }
219
365
  }
366
+
367
+ &.is-virtual-scroll {
368
+ .datatable-container {
369
+ overflow-y: auto;
370
+ max-height: var(--k-datatable-viewport-height, 500px);
371
+ min-height: 0;
372
+ position: relative;
373
+ outline: none;
374
+ }
375
+ table thead {
376
+ position: sticky;
377
+ top: 0;
378
+ z-index: 2;
379
+ background-color: var(--table-header-bg, #f8fafc);
380
+ tr {
381
+ background-color: var(--table-header-bg, #f8fafc);
382
+ }
383
+ }
384
+ tr.k-virtual-spacer {
385
+ height: var(--spacer-height, 0px);
386
+ border: none;
387
+ padding: 0;
388
+ margin: 0;
389
+ background: transparent !important;
390
+ td {
391
+ height: var(--spacer-height, 0px);
392
+ border: none;
393
+ padding: 0;
394
+ margin: 0;
395
+ background: transparent !important;
396
+ }
397
+ }
398
+ }
220
399
  }
221
400
  </style>
@@ -15,6 +15,10 @@ type __VLS_Props = {
15
15
  columnWidths?: Record<string, string>;
16
16
  emptyStateText?: string;
17
17
  emptyFilterStateText?: string;
18
+ virtualScroll?: boolean;
19
+ itemHeight?: number;
20
+ viewportHeight?: number;
21
+ buffer?: number;
18
22
  };
19
23
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
20
24
  "update:currentPage": (value: number) => any;
@@ -26,6 +30,13 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
26
30
  "onUpdate:pageSize"?: ((value: number) => any) | undefined;
27
31
  "onUpdate:selectedRows"?: ((value: any[]) => any) | undefined;
28
32
  "onUpdate:selectAll"?: ((value: boolean) => any) | undefined;
29
- }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
33
+ }>, {
34
+ virtualScroll: boolean;
35
+ itemHeight: number;
36
+ buffer: number;
37
+ viewportHeight: number;
38
+ emptyStateText: string;
39
+ emptyFilterStateText: string;
40
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
30
41
  declare const _default: typeof __VLS_export;
31
42
  export default _default;
@@ -18,6 +18,7 @@ type __VLS_Props = {
18
18
  isInModal: boolean;
19
19
  align?: string;
20
20
  direction?: string;
21
+ updatePosition?: () => void;
21
22
  };
22
23
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
23
24
  declare const _default: typeof __VLS_export;
@@ -2,13 +2,13 @@
2
2
  .KDropdown-source
3
3
  Teleport(v-if="isMounted && open && teleportTarget" :to="teleportTarget")
4
4
  .KDropdown-teleported
5
- .KDropdown(v-click-outside="{ handler: clickoutside, extraInside: anchorEl }" :style="dialogStyle" v-bind="$attrs")
5
+ .KDropdown(ref="dropdownEl" v-click-outside="{ handler: clickoutside, extraInside: anchorEl }" :style="dialogStyle" v-bind="$attrs")
6
6
  KPanel.KDropdown-container(:class="{'fullWidth': fullWidth}" :style="contentStyle")
7
7
  slot
8
8
  </template>
9
9
 
10
10
  <script lang="ts" setup>
11
- import { computed, ref, onMounted, onBeforeUnmount, watch } from 'vue'
11
+ import { computed, ref, onMounted, onBeforeUnmount, watch, nextTick } from 'vue'
12
12
 
13
13
  defineOptions({
14
14
  inheritAttrs: false
@@ -34,9 +34,13 @@ const props = defineProps<{
34
34
  isInModal: boolean
35
35
  align?: string
36
36
  direction?: string
37
+ updatePosition?: () => void
37
38
  }>()
38
39
 
39
40
  const isMounted = ref(false)
41
+ const dropdownEl = ref<HTMLElement | null>(null)
42
+ let resizeObserver: ResizeObserver | null = null
43
+
40
44
  onMounted(() => {
41
45
  isMounted.value = true
42
46
  })
@@ -51,8 +55,21 @@ watch(() => props.open, (isOpen) => {
51
55
  if (typeof window !== 'undefined') {
52
56
  if (isOpen) {
53
57
  window.addEventListener('keydown', handleKeydown)
58
+ nextTick(() => {
59
+ if (dropdownEl.value && typeof ResizeObserver !== 'undefined') {
60
+ if (resizeObserver) resizeObserver.disconnect()
61
+ resizeObserver = new ResizeObserver(() => {
62
+ props.updatePosition?.()
63
+ })
64
+ resizeObserver.observe(dropdownEl.value)
65
+ }
66
+ })
54
67
  } else {
55
68
  window.removeEventListener('keydown', handleKeydown)
69
+ if (resizeObserver) {
70
+ resizeObserver.disconnect()
71
+ resizeObserver = null
72
+ }
56
73
  }
57
74
  }
58
75
  }, { immediate: true })
@@ -61,6 +78,10 @@ onBeforeUnmount(() => {
61
78
  if (typeof window !== 'undefined') {
62
79
  window.removeEventListener('keydown', handleKeydown)
63
80
  }
81
+ if (resizeObserver) {
82
+ resizeObserver.disconnect()
83
+ resizeObserver = null
84
+ }
64
85
  })
65
86
 
66
87
  const dialogStyle = computed(() => {
@@ -18,6 +18,7 @@ type __VLS_Props = {
18
18
  isInModal: boolean;
19
19
  align?: string;
20
20
  direction?: string;
21
+ updatePosition?: () => void;
21
22
  };
22
23
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
23
24
  declare const _default: typeof __VLS_export;
@@ -18,8 +18,10 @@
18
18
  <style lang="scss" scoped>
19
19
  .KLayout {
20
20
  display: grid;
21
- min-height: 100vh;
22
- grid-template-rows: auto 1fr auto;
21
+ height: 100vh;
22
+ max-height: 100vh;
23
+ overflow: hidden;
24
+ grid-template-rows: auto minmax(0, 1fr) auto;
23
25
  grid-template-columns: 1fr;
24
26
  grid-template-areas:
25
27
  "header"
@@ -1,5 +1,5 @@
1
1
  <template lang="pug">
2
- dialog.k-modal(ref="dialogRef" @close="closeModal" @click="handleBackdropClick" @mousedown="handleMouseDown" role="dialog" aria-modal="true" :aria-label="t('Dialog Window')")
2
+ dialog.k-modal(ref="dialogRef" @close="closeModal" @cancel="handleCancel" @click="handleBackdropClick" @mousedown="handleMouseDown" role="dialog" aria-modal="true" :aria-label="t('Dialog Window')")
3
3
  .modal-portal(:id="modalId")
4
4
  KPanel(no-gap flex-content scrollable).modal-container
5
5
  template(#header)
@@ -50,6 +50,13 @@ const handleMouseDown = (event: MouseEvent) => {
50
50
  isMouseDownOnBackdrop = event.target === dialogRef.value
51
51
  }
52
52
 
53
+ // Native dialogs fire cancel on Escape key; prevent it if non-dismissible
54
+ const handleCancel = (event: Event) => {
55
+ if (!props.closeOnOutsideClick) {
56
+ event.preventDefault()
57
+ }
58
+ }
59
+
53
60
  // Native dialogs require a script trick to close when clicking the ::backdrop pseudo-element
54
61
  const handleBackdropClick = (event: MouseEvent) => {
55
62
  if (props.closeOnOutsideClick && isMouseDownOnBackdrop && event.target === dialogRef.value) {
@@ -1,5 +1,5 @@
1
1
  <template lang="pug">
2
- .KTab-item(v-show="isOpen")
2
+ .KTab-item(v-show="isOpen" role="tabpanel" :aria-hidden="!isOpen")
3
3
  slot
4
4
  </template>
5
5
 
@@ -1,17 +1,18 @@
1
1
  <template lang="pug">
2
2
  .KTextbox-wrapper(:class="$attrs.class" :style="$attrs.style")
3
- label.k-input-label(v-if="label") {{ label }}
3
+ label.k-input-label(v-if="label" :for="inputId") {{ label }}
4
4
  .KTextbox(:class="validation ? `is-${validation}` : ''")
5
- input(v-bind="inputAttrs" :type="props.type" v-model="text" :placeholder="placeholder")
5
+ input(:id="inputId" v-bind="inputAttrs" :type="props.type" v-model="text" :placeholder="placeholder")
6
6
  KIcon(v-if="showClear" @click.stop="clear" @mousedown.stop iconname="close" width="10" height="10" role="button" :aria-label="t('Clear input')").closeIcon
7
7
  span.validation-text(v-if="validation && ['success', 'warning', 'error'].includes(validation) && validationText" :class="`is-${validation}`") {{ validationText }}
8
8
  </template>
9
9
 
10
10
  <script lang="ts" setup>
11
- import { computed, useAttrs } from 'vue'
11
+ import { computed, useAttrs, useId } from 'vue'
12
12
  import { useKatluxI18n } from '#toolkit/composables/useKatluxI18n'
13
13
 
14
14
  const { t } = useKatluxI18n()
15
+ const generatedId = useId()
15
16
 
16
17
  defineOptions({
17
18
  inheritAttrs: false
@@ -39,8 +40,9 @@ const text = computed({
39
40
  })
40
41
 
41
42
  const attrs = useAttrs()
43
+ const inputId = computed(() => (attrs.id as string) || generatedId)
42
44
  const inputAttrs = computed(() => {
43
- const { class: _, style: __, ...rest } = attrs
45
+ const { class: _, style: __, id: ___, ...rest } = attrs
44
46
  return rest
45
47
  })
46
48
  </script>
@@ -2,16 +2,22 @@ import type { KToastType } from '#toolkit/components/KToast/KToast.logic';
2
2
  type __VLS_Props = {
3
3
  modelValue: boolean;
4
4
  text?: string;
5
+ title?: string;
5
6
  timeout?: number;
6
7
  teleport?: boolean;
7
8
  type?: KToastType;
9
+ pauseOnHover?: boolean;
8
10
  };
9
11
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
10
12
  "update:modelValue": (...args: any[]) => void;
11
13
  close: (...args: any[]) => void;
14
+ mouseenter: (...args: any[]) => void;
15
+ mouseleave: (...args: any[]) => void;
12
16
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
13
17
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
14
18
  onClose?: ((...args: any[]) => any) | undefined;
19
+ onMouseenter?: ((...args: any[]) => any) | undefined;
20
+ onMouseleave?: ((...args: any[]) => any) | undefined;
15
21
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
16
22
  declare const _default: typeof __VLS_export;
17
23
  export default _default;
@@ -4,11 +4,17 @@ Teleport(to="body" :disabled="!teleport")
4
4
  .KToast(
5
5
  v-if="modelValue"
6
6
  :class="[`type-${type}`, { 'is-fixed': teleport }]"
7
+ :role="type === 'error' || type === 'danger' ? 'alert' : 'status'"
8
+ :aria-live="type === 'error' || type === 'danger' ? 'assertive' : 'polite'"
9
+ @mouseenter="$emit('mouseenter', $event)"
10
+ @mouseleave="$emit('mouseleave', $event)"
7
11
  )
8
12
  .KToast--content
9
- slot {{ text }}
13
+ .KToast--title(v-if="title") {{ title }}
14
+ .KToast--text
15
+ slot {{ text }}
10
16
  .KToast--actions
11
- button.close-btn(@click="$emit('close')")
17
+ button.close-btn(@click="$emit('close')" aria-label="Close notification")
12
18
  KIcon(iconname="close" :width="16" :height="16")
13
19
  </template>
14
20
 
@@ -18,12 +24,14 @@ import type { KToastType } from '#toolkit/components/KToast/KToast.logic'
18
24
  defineProps<{
19
25
  modelValue: boolean
20
26
  text?: string
27
+ title?: string
21
28
  timeout?: number
22
29
  teleport?: boolean
23
30
  type?: KToastType
31
+ pauseOnHover?: boolean
24
32
  }>()
25
33
 
26
- defineEmits(['update:modelValue', 'close'])
34
+ defineEmits(['update:modelValue', 'close', 'mouseenter', 'mouseleave'])
27
35
  </script>
28
36
 
29
37
  <style lang="scss" scoped>
@@ -74,12 +82,22 @@ defineEmits(['update:modelValue', 'close'])
74
82
 
75
83
  &--content {
76
84
  flex: 1;
77
- font-size: var(--font-size-md);
78
85
  color: var(--current-toast-text);
79
86
  margin-right: var(--gap-md);
80
87
  line-height: 1.4;
81
88
  }
82
89
 
90
+ &--title {
91
+ font-weight: 600;
92
+ font-size: var(--font-size-md, 0.95rem);
93
+ margin-bottom: 2px;
94
+ }
95
+
96
+ &--text {
97
+ font-size: var(--font-size-sm, 0.875rem);
98
+ }
99
+
100
+
83
101
  &--actions {
84
102
  display: flex;
85
103
  align-items: center;
@@ -2,16 +2,22 @@ import type { KToastType } from '#toolkit/components/KToast/KToast.logic';
2
2
  type __VLS_Props = {
3
3
  modelValue: boolean;
4
4
  text?: string;
5
+ title?: string;
5
6
  timeout?: number;
6
7
  teleport?: boolean;
7
8
  type?: KToastType;
9
+ pauseOnHover?: boolean;
8
10
  };
9
11
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
10
12
  "update:modelValue": (...args: any[]) => void;
11
13
  close: (...args: any[]) => void;
14
+ mouseenter: (...args: any[]) => void;
15
+ mouseleave: (...args: any[]) => void;
12
16
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
13
17
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
14
18
  onClose?: ((...args: any[]) => any) | undefined;
19
+ onMouseenter?: ((...args: any[]) => any) | undefined;
20
+ onMouseleave?: ((...args: any[]) => any) | undefined;
15
21
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
16
22
  declare const _default: typeof __VLS_export;
17
23
  export default _default;
@@ -0,0 +1,11 @@
1
+ import { type KToastPosition } from '#toolkit/composables/useToast';
2
+ type __VLS_Props = {
3
+ position?: KToastPosition;
4
+ teleport?: boolean;
5
+ maxToasts?: number;
6
+ };
7
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
8
+ teleport: boolean;
9
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
10
+ declare const _default: typeof __VLS_export;
11
+ export default _default;