@katlux/toolkit 0.1.1-alpha.115 → 0.1.1-alpha.117

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 (130) hide show
  1. package/bin/cli.mjs +72 -0
  2. package/bin/create-preset.mjs +233 -0
  3. package/dist/compiled/composables/useDataProvider.mjs +176 -21
  4. package/dist/compiled/composables/useDataProvider.spec.mjs +52 -0
  5. package/dist/module.json +1 -1
  6. package/dist/runtime/components/KAccordion/KAccordion.global.d.vue.ts +23 -2
  7. package/dist/runtime/components/KAccordion/KAccordion.global.vue +7 -1
  8. package/dist/runtime/components/KAccordion/KAccordion.global.vue.d.ts +23 -2
  9. package/dist/runtime/components/KAccordion/KAccordion.logic.d.ts +12 -1
  10. package/dist/runtime/components/KAccordion/KAccordion.logic.js +32 -4
  11. package/dist/runtime/components/KAlert/KAlert.global.d.vue.ts +4 -1
  12. package/dist/runtime/components/KAlert/KAlert.global.vue +8 -2
  13. package/dist/runtime/components/KAlert/KAlert.global.vue.d.ts +4 -1
  14. package/dist/runtime/components/KAlert/KAlert.logic.d.ts +6 -1
  15. package/dist/runtime/components/KAlert/KAlert.logic.js +12 -2
  16. package/dist/runtime/components/KButton/KButton.global.d.vue.ts +1 -1
  17. package/dist/runtime/components/KButton/KButton.global.vue.d.ts +1 -1
  18. package/dist/runtime/components/KButton/KButton.logic.d.ts +1 -1
  19. package/dist/runtime/components/KCalendar/KCalendar.global.d.vue.ts +11 -0
  20. package/dist/runtime/components/KCalendar/KCalendar.global.vue +1 -1
  21. package/dist/runtime/components/KCalendar/KCalendar.global.vue.d.ts +11 -0
  22. package/dist/runtime/components/KCalendar/KCalendar.logic.d.ts +6 -0
  23. package/dist/runtime/components/KCalendar/KCalendar.logic.js +13 -4
  24. package/dist/runtime/components/KCheckbox/KCheckbox.global.d.vue.ts +1 -1
  25. package/dist/runtime/components/KCheckbox/KCheckbox.global.vue.d.ts +1 -1
  26. package/dist/runtime/components/KCombobox/KCombobox.global.d.vue.ts +40 -5
  27. package/dist/runtime/components/KCombobox/KCombobox.global.vue +11 -2
  28. package/dist/runtime/components/KCombobox/KCombobox.global.vue.d.ts +40 -5
  29. package/dist/runtime/components/KCombobox/KCombobox.logic.d.ts +18 -0
  30. package/dist/runtime/components/KCombobox/KCombobox.logic.js +24 -2
  31. package/dist/runtime/components/KCompositeInput/KCompositeInput.global.d.vue.ts +12 -12
  32. package/dist/runtime/components/KCompositeInput/KCompositeInput.global.vue.d.ts +12 -12
  33. package/dist/runtime/components/KCompositeInput/KCompositeInput.logic.d.ts +3 -3
  34. package/dist/runtime/components/KContextMenu/KContextMenu.global.d.vue.ts +1 -1
  35. package/dist/runtime/components/KContextMenu/KContextMenu.global.vue.d.ts +1 -1
  36. package/dist/runtime/components/KDatatable/KDataIterator.global.d.vue.ts +30 -2
  37. package/dist/runtime/components/KDatatable/KDataIterator.global.vue +29 -4
  38. package/dist/runtime/components/KDatatable/KDataIterator.global.vue.d.ts +30 -2
  39. package/dist/runtime/components/KDatatable/KDataIterator.logic.d.ts +21 -2
  40. package/dist/runtime/components/KDatatable/KDataIterator.logic.js +66 -31
  41. package/dist/runtime/components/KDatatable/KDatatable.global.d.vue.ts +35 -3
  42. package/dist/runtime/components/KDatatable/KDatatable.global.vue +44 -4
  43. package/dist/runtime/components/KDatatable/KDatatable.global.vue.d.ts +35 -3
  44. package/dist/runtime/components/KDatatable/KDatatable.logic.d.ts +27 -2
  45. package/dist/runtime/components/KDatatable/KDatatable.logic.js +77 -5
  46. package/dist/runtime/components/KDatePicker/KDatePicker.global.d.vue.ts +8 -8
  47. package/dist/runtime/components/KDatePicker/KDatePicker.global.vue.d.ts +8 -8
  48. package/dist/runtime/components/KDatePicker/KDatePicker.logic.d.ts +2 -2
  49. package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.d.vue.ts +8 -8
  50. package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.vue.d.ts +8 -8
  51. package/dist/runtime/components/KDateTimePicker/KDateTimePicker.logic.d.ts +2 -2
  52. package/dist/runtime/components/KDropdown/KDropdown.global.d.vue.ts +2 -2
  53. package/dist/runtime/components/KDropdown/KDropdown.global.vue.d.ts +2 -2
  54. package/dist/runtime/components/KGantt/KGantt.global.d.vue.ts +8 -8
  55. package/dist/runtime/components/KGantt/KGantt.global.vue.d.ts +8 -8
  56. package/dist/runtime/components/KGantt/KGantt.logic.d.ts +4 -4
  57. package/dist/runtime/components/KHourPicker/KHourPicker.global.d.vue.ts +1 -1
  58. package/dist/runtime/components/KHourPicker/KHourPicker.global.vue.d.ts +1 -1
  59. package/dist/runtime/components/KHourSelect/KHourSelect.global.d.vue.ts +1 -1
  60. package/dist/runtime/components/KHourSelect/KHourSelect.global.vue.d.ts +1 -1
  61. package/dist/runtime/components/KMaskTextbox/KMaskTextbox.global.d.vue.ts +1 -1
  62. package/dist/runtime/components/KMaskTextbox/KMaskTextbox.global.vue.d.ts +1 -1
  63. package/dist/runtime/components/KPagination/KPagination.global.d.vue.ts +24 -2
  64. package/dist/runtime/components/KPagination/KPagination.global.vue +8 -2
  65. package/dist/runtime/components/KPagination/KPagination.global.vue.d.ts +24 -2
  66. package/dist/runtime/components/KPagination/KPagination.logic.d.ts +18 -4
  67. package/dist/runtime/components/KPagination/KPagination.logic.js +59 -10
  68. package/dist/runtime/components/KRangeSlider/KRangeSlider.global.d.vue.ts +15 -4
  69. package/dist/runtime/components/KRangeSlider/KRangeSlider.global.vue +22 -4
  70. package/dist/runtime/components/KRangeSlider/KRangeSlider.global.vue.d.ts +15 -4
  71. package/dist/runtime/components/KRangeSlider/KRangeSlider.logic.d.ts +6 -0
  72. package/dist/runtime/components/KRangeSlider/KRangeSlider.logic.js +12 -6
  73. package/dist/runtime/components/KSlider/KSlider.global.d.vue.ts +14 -3
  74. package/dist/runtime/components/KSlider/KSlider.global.vue +9 -3
  75. package/dist/runtime/components/KSlider/KSlider.global.vue.d.ts +14 -3
  76. package/dist/runtime/components/KSlider/KSlider.logic.d.ts +5 -0
  77. package/dist/runtime/components/KSlider/KSlider.logic.js +5 -1
  78. package/dist/runtime/components/KTabs/KTabItem.global.d.vue.ts +18 -0
  79. package/dist/runtime/components/KTabs/KTabItem.global.vue.d.ts +18 -0
  80. package/dist/runtime/components/KTabs/KTabItem.logic.d.ts +11 -0
  81. package/dist/runtime/components/KTabs/KTabItem.logic.js +10 -1
  82. package/dist/runtime/components/KTabs/KTabs.global.d.vue.ts +35 -1
  83. package/dist/runtime/components/KTabs/KTabs.global.vue +13 -2
  84. package/dist/runtime/components/KTabs/KTabs.global.vue.d.ts +35 -1
  85. package/dist/runtime/components/KTabs/KTabs.logic.d.ts +22 -2
  86. package/dist/runtime/components/KTabs/KTabs.logic.js +118 -4
  87. package/dist/runtime/components/KTextarea/KTextarea.global.d.vue.ts +1 -1
  88. package/dist/runtime/components/KTextarea/KTextarea.global.vue.d.ts +1 -1
  89. package/dist/runtime/components/KTextbox/KTextbox.global.d.vue.ts +2 -2
  90. package/dist/runtime/components/KTextbox/KTextbox.global.vue.d.ts +2 -2
  91. package/dist/runtime/components/KToast/KToast.global.d.vue.ts +3 -3
  92. package/dist/runtime/components/KToast/KToast.global.vue.d.ts +3 -3
  93. package/dist/runtime/components/KTree/KTree.global.d.vue.ts +50 -4
  94. package/dist/runtime/components/KTree/KTree.global.vue +13 -2
  95. package/dist/runtime/components/KTree/KTree.global.vue.d.ts +50 -4
  96. package/dist/runtime/components/KTree/KTree.logic.d.ts +26 -2
  97. package/dist/runtime/components/KTree/KTree.logic.js +41 -6
  98. package/dist/runtime/components/KTreePicker/KTreePicker.global.d.vue.ts +30 -8
  99. package/dist/runtime/components/KTreePicker/KTreePicker.global.vue +1 -1
  100. package/dist/runtime/components/KTreePicker/KTreePicker.global.vue.d.ts +30 -8
  101. package/dist/runtime/components/KTreePicker/KTreePicker.logic.d.ts +16 -0
  102. package/dist/runtime/components/KTreePicker/KTreePicker.logic.js +8 -0
  103. package/dist/runtime/components/KTreeView/KTreeView.global.d.vue.ts +7 -3
  104. package/dist/runtime/components/KTreeView/KTreeView.global.vue +5 -2
  105. package/dist/runtime/components/KTreeView/KTreeView.global.vue.d.ts +7 -3
  106. package/dist/runtime/components/KTreeView/KTreeView.logic.d.ts +4 -1
  107. package/dist/runtime/components/KTreeView/KTreeView.logic.js +7 -1
  108. package/dist/runtime/composables/useDataProvider.d.ts +15 -4
  109. package/dist/runtime/composables/useDataProvider.js +176 -21
  110. package/dist/runtime/presets/default/assets/scss/css-variables.css +1 -0
  111. package/dist/runtime/presets/default/assets/scss/css-variables.scss +1 -0
  112. package/dist/runtime/presets/default/assets/scss/index.css +5 -3
  113. package/dist/runtime/presets/default/assets/scss/index.scss +4 -3
  114. package/dist/runtime/presets/default/components/KAlert/KAlert.d.vue.ts +3 -1
  115. package/dist/runtime/presets/default/components/KAlert/KAlert.vue +3 -3
  116. package/dist/runtime/presets/default/components/KAlert/KAlert.vue.d.ts +3 -1
  117. package/dist/runtime/presets/default/components/KContextMenu/KContextMenu.vue +86 -4
  118. package/dist/runtime/presets/default/components/KDatatable/KDatatable.d.vue.ts +6 -0
  119. package/dist/runtime/presets/default/components/KDatatable/KDatatable.vue +5 -1
  120. package/dist/runtime/presets/default/components/KDatatable/KDatatable.vue.d.ts +6 -0
  121. package/dist/runtime/presets/default/components/KRangeSlider/KRangeSlider.vue +9 -0
  122. package/dist/runtime/presets/default/components/KSlider/KSlider.vue +9 -0
  123. package/dist/runtime/presets/default/components/KTabs/KTabs.d.vue.ts +1 -0
  124. package/dist/runtime/presets/default/components/KTabs/KTabs.vue +23 -0
  125. package/dist/runtime/presets/default/components/KTabs/KTabs.vue.d.ts +1 -0
  126. package/dist/runtime/presets/default/components/KToast/KToast.d.vue.ts +2 -2
  127. package/dist/runtime/presets/default/components/KToast/KToast.vue.d.ts +2 -2
  128. package/dist/runtime/presets/default/components/KTree/KTree.d.vue.ts +1 -1
  129. package/dist/runtime/presets/default/components/KTree/KTree.vue.d.ts +1 -1
  130. package/package.json +5 -1
@@ -1,5 +1,5 @@
1
1
  import { ref, shallowRef, onScopeDispose, isRef, watch } from "vue";
2
- export function useDataProvider(provider) {
2
+ export function useDataProvider(provider, options) {
3
3
  const resolveProvider = () => {
4
4
  if (typeof provider === "function") return provider();
5
5
  return isRef(provider) ? provider.value : provider;
@@ -16,15 +16,17 @@ export function useDataProvider(provider) {
16
16
  activeProvider ? activeProvider.pageData?.value !== void 0 ? activeProvider.pageData.value : Array.isArray(activeProvider.pageData) ? activeProvider.pageData : extractVal(activeProvider.pageData, []) : []
17
17
  );
18
18
  const rowCount = ref(activeProvider ? extractVal(activeProvider.rowCount, 0) : 0);
19
- const currentPage = ref(activeProvider ? extractVal(activeProvider.currentPage, 1) : 1);
20
- const pageSize = ref(activeProvider ? extractVal(activeProvider.pageSize, 10) : 10);
19
+ const currentPage = options?.currentPage || ref(activeProvider ? extractVal(activeProvider.currentPage, 1) : 1);
20
+ const pageSize = options?.pageSize || ref(activeProvider ? extractVal(activeProvider.pageSize, 10) : 10);
21
21
  const loading = ref(activeProvider ? extractVal(activeProvider.loading, false) : false);
22
22
  const initialLoad = ref(activeProvider ? extractVal(activeProvider.initialLoad, false) : false);
23
23
  const error = ref(activeProvider ? extractVal(activeProvider.error, null) : null);
24
- const filter = ref(activeProvider ? extractVal(activeProvider.filter, null) : null);
25
- const sortList = ref(activeProvider ? extractVal(activeProvider.sortList, []) : []);
26
- const selectedRows = ref(activeProvider ? extractVal(activeProvider.selectedRows, []) : []);
27
- const selectAll = ref(activeProvider ? extractVal(activeProvider.selectAll, false) : false);
24
+ const filter = options?.filter || ref(activeProvider ? extractVal(activeProvider.filter, null) : null);
25
+ const sortList = options?.sortList || ref(activeProvider ? extractVal(activeProvider.sortList, []) : []);
26
+ const selectedRows = options?.selectedRows || ref(activeProvider ? extractVal(activeProvider.selectedRows, []) : []);
27
+ const selectAll = options?.selectAll || ref(activeProvider ? extractVal(activeProvider.selectAll, false) : false);
28
+ let isSyncingFromProvider = false;
29
+ let isSyncingToProvider = false;
28
30
  const syncFromProvider = () => {
29
31
  if (!activeProvider) {
30
32
  pageData.value = [];
@@ -40,17 +42,40 @@ export function useDataProvider(provider) {
40
42
  selectAll.value = false;
41
43
  return;
42
44
  }
43
- pageData.value = activeProvider.pageData?.value !== void 0 ? activeProvider.pageData.value : Array.isArray(activeProvider.pageData) ? activeProvider.pageData : extractVal(activeProvider.pageData, []);
44
- rowCount.value = extractVal(activeProvider.rowCount, 0);
45
- currentPage.value = extractVal(activeProvider.currentPage, 1);
46
- pageSize.value = extractVal(activeProvider.pageSize, 10);
47
- loading.value = extractVal(activeProvider.loading, false);
48
- initialLoad.value = extractVal(activeProvider.initialLoad, false);
49
- error.value = extractVal(activeProvider.error, null);
50
- filter.value = extractVal(activeProvider.filter, null);
51
- sortList.value = extractVal(activeProvider.sortList, []);
52
- selectedRows.value = extractVal(activeProvider.selectedRows, []);
53
- selectAll.value = extractVal(activeProvider.selectAll, false);
45
+ isSyncingFromProvider = true;
46
+ try {
47
+ pageData.value = activeProvider.pageData?.value !== void 0 ? activeProvider.pageData.value : Array.isArray(activeProvider.pageData) ? activeProvider.pageData : extractVal(activeProvider.pageData, []);
48
+ rowCount.value = extractVal(activeProvider.rowCount, 0);
49
+ const newPage = extractVal(activeProvider.currentPage, 1);
50
+ if (currentPage.value !== newPage) {
51
+ currentPage.value = newPage;
52
+ }
53
+ const newSize = extractVal(activeProvider.pageSize, 10);
54
+ if (pageSize.value !== newSize) {
55
+ pageSize.value = newSize;
56
+ }
57
+ loading.value = extractVal(activeProvider.loading, false);
58
+ initialLoad.value = extractVal(activeProvider.initialLoad, false);
59
+ error.value = extractVal(activeProvider.error, null);
60
+ const newFilter = extractVal(activeProvider.filter, null);
61
+ if (JSON.stringify(filter.value) !== JSON.stringify(newFilter)) {
62
+ filter.value = newFilter;
63
+ }
64
+ const newSort = extractVal(activeProvider.sortList, []);
65
+ if (JSON.stringify(sortList.value) !== JSON.stringify(newSort)) {
66
+ sortList.value = newSort;
67
+ }
68
+ const newSelected = extractVal(activeProvider.selectedRows, []);
69
+ if (selectedRows.value !== newSelected) {
70
+ selectedRows.value = newSelected;
71
+ }
72
+ const newSelectAll = extractVal(activeProvider.selectAll, false);
73
+ if (selectAll.value !== newSelectAll) {
74
+ selectAll.value = newSelectAll;
75
+ }
76
+ } finally {
77
+ isSyncingFromProvider = false;
78
+ }
54
79
  };
55
80
  let unsubscribe = null;
56
81
  const attachListener = () => {
@@ -146,6 +171,104 @@ export function useDataProvider(provider) {
146
171
  }
147
172
  sortList.value = s;
148
173
  };
174
+ if (options?.currentPage) {
175
+ if (options.currentPage.value !== void 0 && options.currentPage.value !== extractVal(activeProvider?.currentPage, 1)) {
176
+ setCurrentPage(options.currentPage.value);
177
+ }
178
+ watch(options.currentPage, (newVal) => {
179
+ if (isSyncingFromProvider || isSyncingToProvider) return;
180
+ if (activeProvider && extractVal(activeProvider.currentPage, 1) !== newVal) {
181
+ isSyncingToProvider = true;
182
+ try {
183
+ setCurrentPage(newVal);
184
+ } finally {
185
+ isSyncingToProvider = false;
186
+ }
187
+ }
188
+ });
189
+ }
190
+ if (options?.pageSize) {
191
+ if (options.pageSize.value !== void 0 && options.pageSize.value !== extractVal(activeProvider?.pageSize, 10)) {
192
+ setPageSize(options.pageSize.value);
193
+ }
194
+ watch(options.pageSize, (newVal) => {
195
+ if (isSyncingFromProvider || isSyncingToProvider) return;
196
+ if (activeProvider && extractVal(activeProvider.pageSize, 10) !== newVal) {
197
+ isSyncingToProvider = true;
198
+ try {
199
+ setPageSize(newVal);
200
+ } finally {
201
+ isSyncingToProvider = false;
202
+ }
203
+ }
204
+ });
205
+ }
206
+ if (options?.filter) {
207
+ if (options.filter.value !== void 0 && options.filter.value !== null) {
208
+ setFilter(options.filter.value);
209
+ }
210
+ watch(options.filter, (newVal) => {
211
+ if (isSyncingFromProvider || isSyncingToProvider) return;
212
+ if (activeProvider && JSON.stringify(extractVal(activeProvider.filter, null)) !== JSON.stringify(newVal)) {
213
+ isSyncingToProvider = true;
214
+ try {
215
+ setFilter(newVal);
216
+ } finally {
217
+ isSyncingToProvider = false;
218
+ }
219
+ }
220
+ }, { deep: true });
221
+ }
222
+ if (options?.sortList) {
223
+ if (options.sortList.value !== void 0 && options.sortList.value.length > 0) {
224
+ setSortList(options.sortList.value);
225
+ }
226
+ watch(options.sortList, (newVal) => {
227
+ if (isSyncingFromProvider || isSyncingToProvider) return;
228
+ if (activeProvider && JSON.stringify(extractVal(activeProvider.sortList, [])) !== JSON.stringify(newVal)) {
229
+ isSyncingToProvider = true;
230
+ try {
231
+ setSortList(newVal);
232
+ } finally {
233
+ isSyncingToProvider = false;
234
+ }
235
+ }
236
+ }, { deep: true });
237
+ }
238
+ if (options?.selectedRows) {
239
+ watch(options.selectedRows, (newVal) => {
240
+ if (isSyncingFromProvider || isSyncingToProvider) return;
241
+ if (activeProvider) {
242
+ isSyncingToProvider = true;
243
+ try {
244
+ if (typeof activeProvider.setSelectedRows === "function") {
245
+ activeProvider.setSelectedRows(newVal);
246
+ } else {
247
+ activeProvider.selectedRows = newVal;
248
+ }
249
+ } finally {
250
+ isSyncingToProvider = false;
251
+ }
252
+ }
253
+ }, { deep: true });
254
+ }
255
+ if (options?.selectAll) {
256
+ watch(options.selectAll, (newVal) => {
257
+ if (isSyncingFromProvider || isSyncingToProvider) return;
258
+ if (activeProvider && extractVal(activeProvider.selectAll, false) !== newVal) {
259
+ isSyncingToProvider = true;
260
+ try {
261
+ if (typeof activeProvider.setSelectAll === "function") {
262
+ activeProvider.setSelectAll(newVal);
263
+ } else {
264
+ activeProvider.selectAll = newVal;
265
+ }
266
+ } finally {
267
+ isSyncingToProvider = false;
268
+ }
269
+ }
270
+ });
271
+ }
149
272
  const refresh = async (hardRefresh = false) => {
150
273
  if (!activeProvider) return;
151
274
  if (typeof activeProvider.refresh === "function") {
@@ -155,13 +278,43 @@ export function useDataProvider(provider) {
155
278
  }
156
279
  syncFromProvider();
157
280
  };
158
- const loadPageData = (options) => {
281
+ const loadPageData = (options2) => {
159
282
  if (!activeProvider) return;
160
283
  if (typeof activeProvider.loadPageData === "function") {
161
- activeProvider.loadPageData(options);
284
+ activeProvider.loadPageData(options2);
162
285
  }
163
286
  syncFromProvider();
164
287
  };
288
+ const getState = () => {
289
+ if (activeProvider && typeof activeProvider.getState === "function") {
290
+ return activeProvider.getState();
291
+ }
292
+ return {
293
+ pageData: pageData.value,
294
+ rowCount: rowCount.value,
295
+ currentPage: currentPage.value,
296
+ pageSize: pageSize.value,
297
+ loading: loading.value,
298
+ initialLoad: initialLoad.value,
299
+ error: error.value,
300
+ filter: filter.value,
301
+ sortList: sortList.value,
302
+ selectedRows: selectedRows.value,
303
+ selectAll: selectAll.value
304
+ };
305
+ };
306
+ const setState = (partial) => {
307
+ if (activeProvider && typeof activeProvider.setState === "function") {
308
+ activeProvider.setState(partial);
309
+ } else {
310
+ if (partial.currentPage !== void 0) setCurrentPage(partial.currentPage);
311
+ if (partial.pageSize !== void 0) setPageSize(partial.pageSize);
312
+ if (partial.filter !== void 0) setFilter(partial.filter);
313
+ if (partial.sortList !== void 0) setSortList(partial.sortList);
314
+ if (partial.selectedRows !== void 0) selectedRows.value = partial.selectedRows;
315
+ if (partial.selectAll !== void 0) selectAll.value = partial.selectAll;
316
+ }
317
+ };
165
318
  return {
166
319
  get rawProvider() {
167
320
  return activeProvider;
@@ -182,6 +335,8 @@ export function useDataProvider(provider) {
182
335
  setFilter,
183
336
  setSortList,
184
337
  refresh,
185
- loadPageData
338
+ loadPageData,
339
+ getState,
340
+ setState
186
341
  };
187
342
  }
@@ -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-label-color: var(--font-color-primary);
174
175
  --table-border-color: var(--neutral-300);
175
176
  --table-header-bg: var(--neutral-200);
176
177
  --table-header-color: var(--neutral-900);
@@ -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-label-color: var(--font-color-primary);
246
247
 
247
248
  // Table
248
249
  --table-border-color: var(--neutral-300);
@@ -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-label-color: var(--font-color-primary);
191
192
  --table-border-color: var(--neutral-300);
192
193
  --table-header-bg: var(--neutral-200);
193
194
  --table-header-color: var(--neutral-900);
@@ -371,11 +372,12 @@ a:hover {
371
372
  }
372
373
 
373
374
  .k-input-label {
374
- font-size: var(--font-size-xs);
375
- color: var(--font-color-secondary);
376
- margin-bottom: calc(var(--gap-sm) / 2);
375
+ font-size: var(--font-size-sm, 13px);
376
+ color: var(--input-label-color, var(--font-color-primary, currentColor));
377
+ margin-bottom: calc(var(--gap-sm, 8px) / 2);
377
378
  display: block;
378
379
  font-weight: 500;
380
+ line-height: 1.4;
379
381
  }
380
382
 
381
383
  input, textarea, select {
@@ -69,11 +69,12 @@ a {
69
69
  border-color: var(--error-color) !important;
70
70
  }
71
71
  .k-input-label {
72
- font-size: var(--font-size-xs);
73
- color: var(--font-color-secondary);
74
- margin-bottom: calc(var(--gap-sm) / 2);
72
+ font-size: var(--font-size-sm, 13px);
73
+ color: var(--input-label-color, var(--font-color-primary, currentColor));
74
+ margin-bottom: calc(var(--gap-sm, 8px) / 2);
75
75
  display: block;
76
76
  font-weight: 500;
77
+ line-height: 1.4;
77
78
  }
78
79
 
79
80
  input, textarea, select {
@@ -1,7 +1,9 @@
1
1
  import { type KAlertProps } from '#toolkit/components/KAlert/KAlert.logic';
2
- declare const __VLS_export: import("vue").DefineComponent<KAlertProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
2
+ declare const __VLS_export: import("vue").DefineComponent<KAlertProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
3
+ "update:modelValue": (value: boolean) => any;
3
4
  dismiss: () => any;
4
5
  }, string, import("vue").PublicProps, Readonly<KAlertProps> & Readonly<{
6
+ "onUpdate:modelValue"?: ((value: boolean) => any) | undefined;
5
7
  onDismiss?: (() => any) | undefined;
6
8
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
7
9
  declare const _default: typeof __VLS_export;
@@ -12,12 +12,12 @@ Transition(name="k-alert-fade")
12
12
  </template>
13
13
 
14
14
  <script lang="ts" setup>
15
- import { useKAlertLogic, type KAlertProps } from '#toolkit/components/KAlert/KAlert.logic'
15
+ import { useKAlertLogic, type KAlertProps, type KAlertEmits } from '#toolkit/components/KAlert/KAlert.logic'
16
16
  import { useKatluxI18n } from '#toolkit/composables/useKatluxI18n'
17
17
 
18
18
  const props = defineProps<KAlertProps>()
19
- const emit = defineEmits<{ dismiss: [] }>()
20
- const { visible, dismiss, icon } = useKAlertLogic(props, () => emit('dismiss'))
19
+ const emit = defineEmits<KAlertEmits>()
20
+ const { visible, dismiss, icon } = useKAlertLogic(props, emit)
21
21
 
22
22
  const { t } = useKatluxI18n()
23
23
  </script>
@@ -1,7 +1,9 @@
1
1
  import { type KAlertProps } from '#toolkit/components/KAlert/KAlert.logic';
2
- declare const __VLS_export: import("vue").DefineComponent<KAlertProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
2
+ declare const __VLS_export: import("vue").DefineComponent<KAlertProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
3
+ "update:modelValue": (value: boolean) => any;
3
4
  dismiss: () => any;
4
5
  }, string, import("vue").PublicProps, Readonly<KAlertProps> & Readonly<{
6
+ "onUpdate:modelValue"?: ((value: boolean) => any) | undefined;
5
7
  onDismiss?: (() => any) | undefined;
6
8
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
7
9
  declare const _default: typeof __VLS_export;
@@ -6,6 +6,10 @@
6
6
  ref="internalMenuRef"
7
7
  v-click-outside="clickoutside"
8
8
  :style="menuStyle"
9
+ role="menu"
10
+ aria-orientation="vertical"
11
+ tabindex="-1"
12
+ @keydown="handleKeydown"
9
13
  v-bind="$attrs"
10
14
  )
11
15
  KPanel.KContextMenu-container(:style="containerStyle")
@@ -13,7 +17,7 @@
13
17
  </template>
14
18
 
15
19
  <script lang="ts" setup>
16
- import { ref, computed, watch, onBeforeUnmount } from 'vue'
20
+ import { ref, computed, watch, nextTick, onBeforeUnmount } from 'vue'
17
21
  import KPanel from '../KPanel/KPanel.vue'
18
22
 
19
23
  defineOptions({
@@ -42,8 +46,78 @@ const containerStyle = computed(() => ({
42
46
  maxHeight: `${props.menuRect.maxHeight}px`
43
47
  }))
44
48
 
49
+ const getFocusableItems = (): HTMLElement[] => {
50
+ if (!internalMenuRef.value) return []
51
+ return Array.from(
52
+ internalMenuRef.value.querySelectorAll<HTMLElement>(
53
+ 'a[href], button:not([disabled]), [role="menuitem"], [tabindex]:not([tabindex="-1"])'
54
+ )
55
+ ).filter(el => el.offsetParent !== null)
56
+ }
57
+
45
58
  const handleKeydown = (e: KeyboardEvent) => {
59
+ if (!props.open) return
60
+
61
+ if (e.key === 'Escape') {
62
+ e.preventDefault()
63
+ e.stopPropagation()
64
+ props.clickoutside()
65
+ return
66
+ }
67
+
68
+ if (e.key === 'Tab') {
69
+ e.stopPropagation()
70
+ props.clickoutside()
71
+ return
72
+ }
73
+
74
+ const items = getFocusableItems()
75
+ if (items.length === 0) return
76
+
77
+ const activeEl = typeof document !== 'undefined' ? (document.activeElement as HTMLElement) : null
78
+ const currentIndex = activeEl ? items.indexOf(activeEl) : -1
79
+
80
+ switch (e.key) {
81
+ case 'ArrowDown': {
82
+ e.preventDefault()
83
+ e.stopPropagation()
84
+ const nextIndex = currentIndex < items.length - 1 ? currentIndex + 1 : 0
85
+ items[nextIndex]?.focus()
86
+ break
87
+ }
88
+ case 'ArrowUp': {
89
+ e.preventDefault()
90
+ e.stopPropagation()
91
+ const prevIndex = currentIndex > 0 ? currentIndex - 1 : items.length - 1
92
+ items[prevIndex]?.focus()
93
+ break
94
+ }
95
+ case 'Home': {
96
+ e.preventDefault()
97
+ e.stopPropagation()
98
+ items[0]?.focus()
99
+ break
100
+ }
101
+ case 'End': {
102
+ e.preventDefault()
103
+ e.stopPropagation()
104
+ items[items.length - 1]?.focus()
105
+ break
106
+ }
107
+ case ' ': {
108
+ if (activeEl && activeEl.tagName === 'A') {
109
+ e.preventDefault()
110
+ e.stopPropagation()
111
+ activeEl.click()
112
+ }
113
+ break
114
+ }
115
+ }
116
+ }
117
+
118
+ const handleWindowKeydown = (e: KeyboardEvent) => {
46
119
  if (e.key === 'Escape' && props.open) {
120
+ e.preventDefault()
47
121
  props.clickoutside()
48
122
  }
49
123
  }
@@ -51,16 +125,24 @@ const handleKeydown = (e: KeyboardEvent) => {
51
125
  watch(() => props.open, (isOpen) => {
52
126
  if (typeof window !== 'undefined') {
53
127
  if (isOpen) {
54
- window.addEventListener('keydown', handleKeydown)
128
+ window.addEventListener('keydown', handleWindowKeydown)
129
+ nextTick(() => {
130
+ const items = getFocusableItems()
131
+ if (items.length > 0) {
132
+ items[0].focus()
133
+ } else if (internalMenuRef.value) {
134
+ internalMenuRef.value.focus()
135
+ }
136
+ })
55
137
  } else {
56
- window.removeEventListener('keydown', handleKeydown)
138
+ window.removeEventListener('keydown', handleWindowKeydown)
57
139
  }
58
140
  }
59
141
  }, { immediate: true })
60
142
 
61
143
  onBeforeUnmount(() => {
62
144
  if (typeof window !== 'undefined') {
63
- window.removeEventListener('keydown', handleKeydown)
145
+ window.removeEventListener('keydown', handleWindowKeydown)
64
146
  }
65
147
  })
66
148
 
@@ -7,6 +7,8 @@ type __VLS_Props = {
7
7
  bulkActions: Array<IKDatatableAction>;
8
8
  selectedRows: any[];
9
9
  selectAll: boolean;
10
+ currentPage?: number;
11
+ pageSize?: number;
10
12
  cellSlots?: Record<string, any>;
11
13
  headerSlots?: Record<string, any>;
12
14
  columnHeaders?: Record<string, string>;
@@ -15,9 +17,13 @@ type __VLS_Props = {
15
17
  emptyFilterStateText?: string;
16
18
  };
17
19
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
20
+ "update:currentPage": (value: number) => any;
21
+ "update:pageSize": (value: number) => any;
18
22
  "update:selectedRows": (value: any[]) => any;
19
23
  "update:selectAll": (value: boolean) => any;
20
24
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
25
+ "onUpdate:currentPage"?: ((value: number) => any) | undefined;
26
+ "onUpdate:pageSize"?: ((value: number) => any) | undefined;
21
27
  "onUpdate:selectedRows"?: ((value: any[]) => any) | undefined;
22
28
  "onUpdate:selectAll"?: ((value: boolean) => any) | undefined;
23
29
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -53,7 +53,7 @@
53
53
  template(#default v-if="!rowAction.iconOnly && !rowAction.icon") {{rowAction.label}}
54
54
  .footer
55
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")
56
+ KPagination.pagination(:dataProvider="props.dataProvider" :currentPage="props.currentPage" :pageSize="props.pageSize" @update:currentPage="emit('update:currentPage', $event)" @update:pageSize="emit('update:pageSize', $event)")
57
57
  </template>
58
58
 
59
59
  <script setup lang="ts">
@@ -72,6 +72,8 @@ const props = defineProps<{
72
72
  bulkActions: Array<IKDatatableAction>
73
73
  selectedRows: any[]
74
74
  selectAll: boolean
75
+ currentPage?: number
76
+ pageSize?: number
75
77
  cellSlots?: Record<string, any>
76
78
  headerSlots?: Record<string, any>
77
79
  columnHeaders?: Record<string, string>
@@ -83,6 +85,8 @@ const props = defineProps<{
83
85
  const emit = defineEmits<{
84
86
  (e: 'update:selectedRows', value: any[]): void
85
87
  (e: 'update:selectAll', value: boolean): void
88
+ (e: 'update:currentPage', value: number): void
89
+ (e: 'update:pageSize', value: number): void
86
90
  }>()
87
91
 
88
92
  // Bi-directional binding helpers
@@ -7,6 +7,8 @@ type __VLS_Props = {
7
7
  bulkActions: Array<IKDatatableAction>;
8
8
  selectedRows: any[];
9
9
  selectAll: boolean;
10
+ currentPage?: number;
11
+ pageSize?: number;
10
12
  cellSlots?: Record<string, any>;
11
13
  headerSlots?: Record<string, any>;
12
14
  columnHeaders?: Record<string, string>;
@@ -15,9 +17,13 @@ type __VLS_Props = {
15
17
  emptyFilterStateText?: string;
16
18
  };
17
19
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
20
+ "update:currentPage": (value: number) => any;
21
+ "update:pageSize": (value: number) => any;
18
22
  "update:selectedRows": (value: any[]) => any;
19
23
  "update:selectAll": (value: boolean) => any;
20
24
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
25
+ "onUpdate:currentPage"?: ((value: number) => any) | undefined;
26
+ "onUpdate:pageSize"?: ((value: number) => any) | undefined;
21
27
  "onUpdate:selectedRows"?: ((value: any[]) => any) | undefined;
22
28
  "onUpdate:selectAll"?: ((value: boolean) => any) | undefined;
23
29
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -101,6 +101,15 @@ const handleTrackClick = (event: MouseEvent) => {
101
101
  opacity: 0.5;
102
102
  cursor: not-allowed;
103
103
  }
104
+
105
+ .k-input-label {
106
+ font-size: var(--font-size-sm, 13px);
107
+ color: var(--input-label-color, var(--font-color-primary, currentColor));
108
+ margin-bottom: 8px;
109
+ display: block;
110
+ font-weight: 500;
111
+ line-height: 1.4;
112
+ }
104
113
 
105
114
  .slider-container {
106
115
  position: relative;
@@ -64,6 +64,15 @@ const handleTrackClick = (event: MouseEvent) => {
64
64
  opacity: 0.5;
65
65
  cursor: not-allowed;
66
66
  }
67
+
68
+ .k-input-label {
69
+ font-size: var(--font-size-sm, 13px);
70
+ color: var(--input-label-color, var(--font-color-primary, currentColor));
71
+ margin-bottom: 8px;
72
+ display: block;
73
+ font-weight: 500;
74
+ line-height: 1.4;
75
+ }
67
76
 
68
77
  .slider-container {
69
78
  position: relative;
@@ -2,6 +2,7 @@ type __VLS_Props = {
2
2
  items: any[];
3
3
  toggleItem: (index: number) => void;
4
4
  isOpen: (index: number) => boolean;
5
+ onTabKeyDown?: (e: KeyboardEvent, index: number) => number | void;
5
6
  };
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<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
7
8
  declare const _default: typeof __VLS_export;
@@ -10,6 +10,7 @@
10
10
  v-for="(item, index) of items"
11
11
  :key="index"
12
12
  @click="toggleItem(index)"
13
+ @keydown="handleTabKeyDown($event, index)"
13
14
  size="small"
14
15
  :type="isOpen(index) ? 'primary' : 'default'"
15
16
  :class="{ 'is-active': isOpen(index) }"
@@ -31,12 +32,34 @@ const props = defineProps<{
31
32
  items: any[]
32
33
  toggleItem: (index: number) => void
33
34
  isOpen: (index: number) => boolean
35
+ onTabKeyDown?: (e: KeyboardEvent, index: number) => number | void
34
36
  }>()
35
37
 
36
38
  const scrollArea = ref<HTMLElement | null>(null)
37
39
  const hasOverflow = ref(false)
38
40
  let resizeObserver: ResizeObserver | null = null
39
41
 
42
+ const focusTab = (index: number) => {
43
+ if (!scrollArea.value) return
44
+ const buttons = scrollArea.value.querySelectorAll<HTMLElement>('.k-tab-btn')
45
+ const targetBtn = buttons[index]
46
+ if (targetBtn) {
47
+ targetBtn.focus()
48
+ targetBtn.scrollIntoView({ behavior: 'smooth', block: 'nearest', inline: 'nearest' })
49
+ }
50
+ }
51
+
52
+ const handleTabKeyDown = (e: KeyboardEvent, index: number) => {
53
+ if (props.onTabKeyDown) {
54
+ const newIndex = props.onTabKeyDown(e, index)
55
+ if (typeof newIndex === 'number') {
56
+ nextTick(() => {
57
+ focusTab(newIndex)
58
+ })
59
+ }
60
+ }
61
+ }
62
+
40
63
  const checkOverflow = () => {
41
64
  if (!scrollArea.value) return
42
65
  const el = scrollArea.value
@@ -2,6 +2,7 @@ type __VLS_Props = {
2
2
  items: any[];
3
3
  toggleItem: (index: number) => void;
4
4
  isOpen: (index: number) => boolean;
5
+ onTabKeyDown?: (e: KeyboardEvent, index: number) => number | void;
5
6
  };
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<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
7
8
  declare const _default: typeof __VLS_export;
@@ -7,11 +7,11 @@ type __VLS_Props = {
7
7
  type?: KToastType;
8
8
  };
9
9
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
10
- close: (...args: any[]) => void;
11
10
  "update:modelValue": (...args: any[]) => void;
11
+ close: (...args: any[]) => void;
12
12
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
13
- onClose?: ((...args: any[]) => any) | undefined;
14
13
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
14
+ onClose?: ((...args: any[]) => any) | undefined;
15
15
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
16
16
  declare const _default: typeof __VLS_export;
17
17
  export default _default;
@@ -7,11 +7,11 @@ type __VLS_Props = {
7
7
  type?: KToastType;
8
8
  };
9
9
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
10
- close: (...args: any[]) => void;
11
10
  "update:modelValue": (...args: any[]) => void;
11
+ close: (...args: any[]) => void;
12
12
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
13
- onClose?: ((...args: any[]) => any) | undefined;
14
13
  "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
14
+ onClose?: ((...args: any[]) => any) | undefined;
15
15
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
16
16
  declare const _default: typeof __VLS_export;
17
17
  export default _default;