@katlux/toolkit 0.1.1-alpha.123 → 0.1.1-alpha.125

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 (68) hide show
  1. package/bin/cli.mjs +0 -0
  2. package/bin/create-preset.mjs +0 -0
  3. package/dist/compiled/composables/useDataProvider.mjs +7 -59
  4. package/dist/compiled/composables/useKatluxForm.mjs +23 -4
  5. package/dist/compiled/composables/usePresetComponent.mjs +1 -1
  6. package/dist/compiled/composables/useVirtualScroll.mjs +24 -11
  7. package/dist/compiled/utils/sanitize.mjs +39 -0
  8. package/dist/module.json +1 -1
  9. package/dist/runtime/components/KBulkActions/KBulkActions.global.d.vue.ts +3 -1
  10. package/dist/runtime/components/KBulkActions/KBulkActions.global.vue +2 -0
  11. package/dist/runtime/components/KBulkActions/KBulkActions.global.vue.d.ts +3 -1
  12. package/dist/runtime/components/KBulkActions/KBulkActions.logic.d.ts +2 -0
  13. package/dist/runtime/components/KBulkActions/KBulkActions.logic.js +22 -1
  14. package/dist/runtime/components/KCheckbox/KCheckbox.global.d.vue.ts +11 -0
  15. package/dist/runtime/components/KCheckbox/KCheckbox.global.vue +4 -3
  16. package/dist/runtime/components/KCheckbox/KCheckbox.global.vue.d.ts +11 -0
  17. package/dist/runtime/components/KCheckbox/KCheckbox.logic.d.ts +5 -0
  18. package/dist/runtime/components/KCheckbox/KCheckbox.logic.js +4 -0
  19. package/dist/runtime/components/KCombobox/KCombobox.logic.js +3 -1
  20. package/dist/runtime/components/KDatatable/KDataIterator.global.d.vue.ts +1 -1
  21. package/dist/runtime/components/KDatatable/KDataIterator.global.vue.d.ts +1 -1
  22. package/dist/runtime/components/KDatatable/KDataIterator.logic.js +3 -41
  23. package/dist/runtime/components/KDatatable/KDatatable.global.d.vue.ts +9 -1
  24. package/dist/runtime/components/KDatatable/KDatatable.global.vue +17 -1
  25. package/dist/runtime/components/KDatatable/KDatatable.global.vue.d.ts +9 -1
  26. package/dist/runtime/components/KDatatable/KDatatable.logic.d.ts +7 -1
  27. package/dist/runtime/components/KDatatable/KDatatable.logic.js +58 -54
  28. package/dist/runtime/components/KDatePicker/KDatePicker.global.d.vue.ts +1 -1
  29. package/dist/runtime/components/KDatePicker/KDatePicker.global.vue.d.ts +1 -1
  30. package/dist/runtime/components/KGantt/KGantt.logic.js +2 -4
  31. package/dist/runtime/components/KMaskTextbox/KMaskTextbox.logic.js +2 -0
  32. package/dist/runtime/components/KRadiobox/KRadiobox.global.vue +1 -1
  33. package/dist/runtime/components/KRangeSlider/KRangeSlider.global.vue +1 -1
  34. package/dist/runtime/components/KSlider/KSlider.global.vue +1 -1
  35. package/dist/runtime/components/KTextarea/KTextarea.global.vue +1 -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 +2 -0
  40. package/dist/runtime/components/KTree/KTree.global.vue.d.ts +1 -1
  41. package/dist/runtime/components/KTree/KTree.logic.js +38 -12
  42. package/dist/runtime/components/KTreeView/KTreeView.global.d.vue.ts +1 -1
  43. package/dist/runtime/components/KTreeView/KTreeView.global.vue.d.ts +1 -1
  44. package/dist/runtime/composables/useDataProvider.d.ts +1 -5
  45. package/dist/runtime/composables/useDataProvider.js +7 -59
  46. package/dist/runtime/composables/useKatluxForm.js +23 -4
  47. package/dist/runtime/composables/usePresetComponent.js +1 -1
  48. package/dist/runtime/composables/useVirtualScroll.js +24 -11
  49. package/dist/runtime/presets/default/components/KBulkActions/KBulkActions.d.vue.ts +1 -0
  50. package/dist/runtime/presets/default/components/KBulkActions/KBulkActions.vue +2 -1
  51. package/dist/runtime/presets/default/components/KBulkActions/KBulkActions.vue.d.ts +1 -0
  52. package/dist/runtime/presets/default/components/KCheckbox/KCheckbox.d.vue.ts +9 -3
  53. package/dist/runtime/presets/default/components/KCheckbox/KCheckbox.vue +35 -12
  54. package/dist/runtime/presets/default/components/KCheckbox/KCheckbox.vue.d.ts +9 -3
  55. package/dist/runtime/presets/default/components/KDatatable/KDatatable.d.vue.ts +8 -0
  56. package/dist/runtime/presets/default/components/KDatatable/KDatatable.vue +183 -31
  57. package/dist/runtime/presets/default/components/KDatatable/KDatatable.vue.d.ts +8 -0
  58. package/dist/runtime/presets/default/components/KIcon/KIcon.vue +5 -2
  59. package/dist/runtime/presets/default/components/KRadiobox/KRadiobox.vue +1 -0
  60. package/dist/runtime/presets/default/components/KTree/KTree.d.vue.ts +3 -3
  61. package/dist/runtime/presets/default/components/KTree/KTree.vue +245 -115
  62. package/dist/runtime/presets/default/components/KTree/KTree.vue.d.ts +3 -3
  63. package/dist/runtime/presets/default/components/KTree/KTreeNodeItem.d.vue.ts +27 -0
  64. package/dist/runtime/presets/default/components/KTree/KTreeNodeItem.vue +179 -0
  65. package/dist/runtime/presets/default/components/KTree/KTreeNodeItem.vue.d.ts +27 -0
  66. package/dist/runtime/utils/sanitize.d.ts +5 -0
  67. package/dist/runtime/utils/sanitize.js +39 -0
  68. package/package.json +6 -3
@@ -70,33 +70,58 @@ export const KTreeDefaultProps = {
70
70
  export function useKTreeLogic(props, emit) {
71
71
  const { pageData, setFilter } = useDataProvider(props.dataProvider);
72
72
  const visibleRows = computed(() => pageData.value || []);
73
+ let isFirstSearchRun = true;
73
74
  watch(() => props.searchtext, (newVal) => {
74
- if (newVal) {
75
- setFilter({
76
- operator: EDataFilterOperator.In,
77
- field: { [props.labelField || "name"]: newVal },
78
- active: true
79
- });
75
+ const filterObj = newVal ? {
76
+ operator: EDataFilterOperator.In,
77
+ field: { [props.labelField || "name"]: newVal },
78
+ active: true
79
+ } : null;
80
+ if (typeof props.dataProvider?.setFilter === "function") {
81
+ props.dataProvider.setFilter(filterObj, true);
80
82
  } else {
81
- setFilter(null);
83
+ setFilter(filterObj, true);
82
84
  }
83
- if (newVal !== void 0) {
85
+ if (!isFirstSearchRun && newVal !== void 0) {
84
86
  emit?.("update:searchtext", newVal);
85
87
  }
86
- });
88
+ isFirstSearchRun = false;
89
+ }, { immediate: true });
90
+ const syncProviderExpanded = (nodes) => {
91
+ if (props.dataProvider) {
92
+ props.dataProvider.expandedNodes = nodes;
93
+ if ("_allVisibleRowsCache" in props.dataProvider) {
94
+ props.dataProvider._allVisibleRowsCache = null;
95
+ }
96
+ if (typeof props.dataProvider.updatePageData === "function") {
97
+ props.dataProvider.updatePageData();
98
+ }
99
+ if (typeof props.dataProvider.notify === "function") {
100
+ props.dataProvider.notify();
101
+ }
102
+ }
103
+ };
87
104
  const rawExpanded = props.dataProvider?.expandedNodes;
88
105
  const expandedNodes = ref(
89
106
  props.expandedNodes ? props.expandedNodes instanceof Set ? props.expandedNodes : new Set(props.expandedNodes) : rawExpanded ? "value" in rawExpanded ? rawExpanded.value : rawExpanded : /* @__PURE__ */ new Set()
90
107
  );
108
+ if (props.expandedNodes) {
109
+ syncProviderExpanded(expandedNodes.value);
110
+ }
91
111
  watch(() => props.expandedNodes, (val) => {
92
112
  if (val !== void 0) {
93
- expandedNodes.value = val instanceof Set ? val : new Set(val);
113
+ const setVal = val instanceof Set ? val : new Set(val);
114
+ expandedNodes.value = setVal;
115
+ syncProviderExpanded(setVal);
94
116
  }
95
117
  }, { deep: true });
96
118
  const toggleNode = (nodeId) => {
97
119
  if (props.disabled) return;
98
120
  if (typeof props.dataProvider?.toggleNode === "function") {
99
121
  props.dataProvider.toggleNode(nodeId);
122
+ const raw = props.dataProvider.expandedNodes;
123
+ const current = raw ? "value" in raw ? raw.value : raw : [];
124
+ expandedNodes.value = new Set(current);
100
125
  } else {
101
126
  if (expandedNodes.value.has(nodeId)) {
102
127
  expandedNodes.value.delete(nodeId);
@@ -104,11 +129,12 @@ export function useKTreeLogic(props, emit) {
104
129
  expandedNodes.value.add(nodeId);
105
130
  }
106
131
  }
132
+ const emitted = Array.isArray(props.expandedNodes) ? Array.from(expandedNodes.value) : expandedNodes.value;
107
133
  emit?.("node-toggle", nodeId);
108
- emit?.("update:expandedNodes", expandedNodes.value);
134
+ emit?.("update:expandedNodes", emitted);
109
135
  };
110
136
  const selectNode = (node) => {
111
- if (props.disabled || !props.selectable) return;
137
+ if (props.disabled) return;
112
138
  emit?.("update:modelValue", node);
113
139
  emit?.("update:selectedNode", node);
114
140
  emit?.("select", node);
@@ -139,8 +139,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
139
139
  "onUpdate:expandedNodes"?: ((value: any) => any) | undefined;
140
140
  "onNode-toggle"?: ((nodeId: string | number) => any) | undefined;
141
141
  }>, {
142
- bulkActions: import("@katlux/providers").IKDatatableAction[];
143
142
  selectedRows: any[];
143
+ bulkActions: import("@katlux/providers").IKDatatableAction[];
144
144
  selectAll: boolean;
145
145
  idKey: string;
146
146
  virtualScroll: boolean;
@@ -139,8 +139,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
139
139
  "onUpdate:expandedNodes"?: ((value: any) => any) | undefined;
140
140
  "onNode-toggle"?: ((nodeId: string | number) => any) | undefined;
141
141
  }>, {
142
- bulkActions: import("@katlux/providers").IKDatatableAction[];
143
142
  selectedRows: any[];
143
+ bulkActions: import("@katlux/providers").IKDatatableAction[];
144
144
  selectAll: boolean;
145
145
  idKey: string;
146
146
  virtualScroll: boolean;
@@ -5,8 +5,6 @@ export interface IUseDataProviderOptions<TRow = any> {
5
5
  pageSize?: Ref<number> | WritableComputedRef<number>;
6
6
  filter?: Ref<IDataFilter | null> | WritableComputedRef<IDataFilter | null>;
7
7
  sortList?: Ref<IDataSort[]> | WritableComputedRef<IDataSort[]>;
8
- selectedRows?: Ref<TRow[]> | WritableComputedRef<TRow[]>;
9
- selectAll?: Ref<boolean> | WritableComputedRef<boolean>;
10
8
  }
11
9
  export interface IUseDataProviderReturn<T = TDataRow> {
12
10
  rawProvider: any;
@@ -20,11 +18,9 @@ export interface IUseDataProviderReturn<T = TDataRow> {
20
18
  error: Ref<any>;
21
19
  filter: Ref<IDataFilter | null>;
22
20
  sortList: Ref<IDataSort[]>;
23
- selectedRows: Ref<any[]>;
24
- selectAll: Ref<boolean>;
25
21
  setCurrentPage: (page: number) => void;
26
22
  setPageSize: (size: number) => void;
27
- setFilter: (filter: IDataFilter | null) => void;
23
+ setFilter: (filter: IDataFilter | null, immediate?: boolean) => void;
28
24
  setSortList: (sortList: IDataSort[]) => void;
29
25
  refresh: (hardRefresh?: boolean) => Promise<void>;
30
26
  loadPageData: (options?: {
@@ -19,10 +19,10 @@ export function useDataProvider(provider, options) {
19
19
  if (!activeProvider) return [];
20
20
  if (Array.isArray(activeProvider.allVisibleRows) && activeProvider.allVisibleRows.length > 0) return activeProvider.allVisibleRows;
21
21
  if (Array.isArray(activeProvider.allVisibleRows?.value) && activeProvider.allVisibleRows.value.length > 0) return activeProvider.allVisibleRows.value;
22
- if (Array.isArray(activeProvider.rowMap) && activeProvider.rowMap.length > 0) return activeProvider.rowMap;
23
- if (Array.isArray(activeProvider.rowMap?.value) && activeProvider.rowMap.value.length > 0) return activeProvider.rowMap.value;
24
- if (Array.isArray(activeProvider.allVisibleNodes) && activeProvider.allVisibleNodes.length > 0) return activeProvider.allVisibleNodes;
25
- if (Array.isArray(activeProvider.allVisibleNodes?.value) && activeProvider.allVisibleNodes.value.length > 0) return activeProvider.allVisibleNodes.value;
22
+ if (Array.isArray(activeProvider.rowMap)) return activeProvider.rowMap;
23
+ if (Array.isArray(activeProvider.rowMap?.value)) return activeProvider.rowMap.value;
24
+ if (Array.isArray(activeProvider.allVisibleNodes)) return activeProvider.allVisibleNodes;
25
+ if (Array.isArray(activeProvider.allVisibleNodes?.value)) return activeProvider.allVisibleNodes.value;
26
26
  if (Array.isArray(activeProvider.allData) && activeProvider.allData.length > 0) return activeProvider.allData;
27
27
  if (Array.isArray(activeProvider.allData?.value) && activeProvider.allData.value.length > 0) return activeProvider.allData.value;
28
28
  if (Array.isArray(activeProvider.data) && activeProvider.data.length > 0) return activeProvider.data;
@@ -39,8 +39,6 @@ export function useDataProvider(provider, options) {
39
39
  const error = ref(activeProvider ? extractVal(activeProvider.error, null) : null);
40
40
  const filter = options?.filter || ref(activeProvider ? extractVal(activeProvider.filter, null) : null);
41
41
  const sortList = options?.sortList || ref(activeProvider ? extractVal(activeProvider.sortList, []) : []);
42
- const selectedRows = options?.selectedRows || ref(activeProvider ? extractVal(activeProvider.selectedRows, []) : []);
43
- const selectAll = options?.selectAll || ref(activeProvider ? extractVal(activeProvider.selectAll, false) : false);
44
42
  let isSyncingFromProvider = false;
45
43
  let isSyncingToProvider = false;
46
44
  const syncFromProvider = () => {
@@ -55,8 +53,6 @@ export function useDataProvider(provider, options) {
55
53
  error.value = null;
56
54
  filter.value = null;
57
55
  sortList.value = [];
58
- selectedRows.value = [];
59
- selectAll.value = false;
60
56
  return;
61
57
  }
62
58
  isSyncingFromProvider = true;
@@ -83,14 +79,6 @@ export function useDataProvider(provider, options) {
83
79
  if (JSON.stringify(sortList.value) !== JSON.stringify(newSort)) {
84
80
  sortList.value = newSort;
85
81
  }
86
- const newSelected = extractVal(activeProvider.selectedRows, []);
87
- if (selectedRows.value !== newSelected) {
88
- selectedRows.value = newSelected;
89
- }
90
- const newSelectAll = extractVal(activeProvider.selectAll, false);
91
- if (selectAll.value !== newSelectAll) {
92
- selectAll.value = newSelectAll;
93
- }
94
82
  } finally {
95
83
  isSyncingFromProvider = false;
96
84
  }
@@ -164,10 +152,10 @@ export function useDataProvider(provider, options) {
164
152
  }
165
153
  pageSize.value = size;
166
154
  };
167
- const setFilter = (f) => {
155
+ const setFilter = (f, immediate = false) => {
168
156
  if (!activeProvider) return;
169
157
  if (typeof activeProvider.setFilter === "function") {
170
- activeProvider.setFilter(f);
158
+ activeProvider.setFilter(f, immediate);
171
159
  } else if ("filter" in activeProvider) {
172
160
  if (isRef(activeProvider.filter) || typeof activeProvider.filter === "object" && activeProvider.filter !== null && "value" in activeProvider.filter) {
173
161
  activeProvider.filter.value = f;
@@ -254,40 +242,6 @@ export function useDataProvider(provider, options) {
254
242
  }
255
243
  }, { deep: true });
256
244
  }
257
- if (options?.selectedRows) {
258
- watch(options.selectedRows, (newVal) => {
259
- if (isSyncingFromProvider || isSyncingToProvider) return;
260
- if (activeProvider) {
261
- isSyncingToProvider = true;
262
- try {
263
- if (typeof activeProvider.setSelectedRows === "function") {
264
- activeProvider.setSelectedRows(newVal);
265
- } else {
266
- activeProvider.selectedRows = newVal;
267
- }
268
- } finally {
269
- isSyncingToProvider = false;
270
- }
271
- }
272
- }, { deep: true });
273
- }
274
- if (options?.selectAll) {
275
- watch(options.selectAll, (newVal) => {
276
- if (isSyncingFromProvider || isSyncingToProvider) return;
277
- if (activeProvider && extractVal(activeProvider.selectAll, false) !== newVal) {
278
- isSyncingToProvider = true;
279
- try {
280
- if (typeof activeProvider.setSelectAll === "function") {
281
- activeProvider.setSelectAll(newVal);
282
- } else {
283
- activeProvider.selectAll = newVal;
284
- }
285
- } finally {
286
- isSyncingToProvider = false;
287
- }
288
- }
289
- });
290
- }
291
245
  const refresh = async (hardRefresh = false) => {
292
246
  if (!activeProvider) return;
293
247
  if (typeof activeProvider.refresh === "function") {
@@ -317,9 +271,7 @@ export function useDataProvider(provider, options) {
317
271
  initialLoad: initialLoad.value,
318
272
  error: error.value,
319
273
  filter: filter.value,
320
- sortList: sortList.value,
321
- selectedRows: selectedRows.value,
322
- selectAll: selectAll.value
274
+ sortList: sortList.value
323
275
  };
324
276
  };
325
277
  const setState = (partial) => {
@@ -330,8 +282,6 @@ export function useDataProvider(provider, options) {
330
282
  if (partial.pageSize !== void 0) setPageSize(partial.pageSize);
331
283
  if (partial.filter !== void 0) setFilter(partial.filter);
332
284
  if (partial.sortList !== void 0) setSortList(partial.sortList);
333
- if (partial.selectedRows !== void 0) selectedRows.value = partial.selectedRows;
334
- if (partial.selectAll !== void 0) selectAll.value = partial.selectAll;
335
285
  }
336
286
  };
337
287
  return {
@@ -348,8 +298,6 @@ export function useDataProvider(provider, options) {
348
298
  error,
349
299
  filter,
350
300
  sortList,
351
- selectedRows,
352
- selectAll,
353
301
  setCurrentPage,
354
302
  setPageSize,
355
303
  setFilter,
@@ -144,6 +144,7 @@ export function useKatluxForm(options = {}) {
144
144
  }
145
145
  }
146
146
  let validationSeq = 0;
147
+ let submitSeq = 0;
147
148
  function validate(targetPath) {
148
149
  const seq = ++validationSeq;
149
150
  const result = runValidation(values);
@@ -195,6 +196,8 @@ export function useKatluxForm(options = {}) {
195
196
  dirtyFields.value = {};
196
197
  submitCount.value = 0;
197
198
  isSubmitting.value = false;
199
+ submitSeq++;
200
+ validationSeq++;
198
201
  }
199
202
  function register(path, regOptions = {}) {
200
203
  return {
@@ -267,25 +270,41 @@ export function useKatluxForm(options = {}) {
267
270
  if (event && typeof event.preventDefault === "function") {
268
271
  event.preventDefault();
269
272
  }
273
+ const currentSubmitId = ++submitSeq;
270
274
  submitCount.value += 1;
271
275
  isSubmitting.value = true;
272
276
  try {
273
- const res = await runValidation(values);
277
+ const snapshotValues = deepClone(values);
278
+ const res = await runValidation(snapshotValues);
279
+ if (currentSubmitId !== submitSeq) {
280
+ return;
281
+ }
274
282
  const { valid, output, errors: newErrors } = res;
275
- errors.value = newErrors;
276
283
  if (!valid) {
284
+ const errorsToApply = {};
285
+ for (const [errPath, errMsg] of Object.entries(newErrors)) {
286
+ const currentVal = getByPath(values, errPath);
287
+ const snapVal = getByPath(snapshotValues, errPath);
288
+ if (JSON.stringify(currentVal) === JSON.stringify(snapVal)) {
289
+ errorsToApply[errPath] = errMsg;
290
+ }
291
+ }
292
+ errors.value = errorsToApply;
277
293
  const firstErrorKey = Object.keys(newErrors)[0];
278
294
  if (focusOnError && firstErrorKey) {
279
295
  focusFirstInvalid(firstErrorKey);
280
296
  }
281
297
  if (onInvalid) {
282
- await onInvalid(newErrors, values);
298
+ await onInvalid(newErrors, snapshotValues);
283
299
  }
284
300
  return;
285
301
  }
302
+ errors.value = {};
286
303
  await onValid(output, event);
287
304
  } finally {
288
- isSubmitting.value = false;
305
+ if (currentSubmitId === submitSeq) {
306
+ isSubmitting.value = false;
307
+ }
289
308
  }
290
309
  };
291
310
  }
@@ -48,7 +48,7 @@ export function usePresetComponent(componentBaseName, defaultComponent) {
48
48
  const externalLoaders = _loadersRegistry[presetName];
49
49
  if (externalLoaders) {
50
50
  const key = `./components/${componentBaseName}/${componentBaseName}.vue`;
51
- const candidate = externalLoaders[key];
51
+ const candidate = externalLoaders[key] || externalLoaders[componentBaseName] || externalLoaders[`${componentBaseName}.vue`];
52
52
  if (candidate) {
53
53
  if (isDirectComponent(candidate)) {
54
54
  return candidate;
@@ -179,9 +179,10 @@ export function useVirtualScroll(options) {
179
179
  const remainingRows = Math.max(0, totalRows.value - endRowIndex.value);
180
180
  return remainingRows * baseItemHeight.value;
181
181
  });
182
- watch(totalHeight, (newTotal) => {
183
- if (scrollTop.value > newTotal) {
184
- scrollTop.value = Math.max(0, newTotal - viewportHeight.value);
182
+ watch([totalHeight, viewportHeight], ([newTotal, newVp]) => {
183
+ const maxScroll = Math.max(0, newTotal - newVp);
184
+ if (scrollTop.value > maxScroll) {
185
+ scrollTop.value = maxScroll;
185
186
  if (containerRef.value) {
186
187
  containerRef.value.scrollTop = scrollTop.value;
187
188
  }
@@ -212,10 +213,16 @@ export function useVirtualScroll(options) {
212
213
  const targetScrollTop2 = Math.max(0, (rowOffsets.value[index] || 0) - offset);
213
214
  scrollTop.value = targetScrollTop2;
214
215
  if (containerRef.value) {
215
- containerRef.value.scrollTo({
216
- top: targetScrollTop2,
217
- behavior
218
- });
216
+ containerRef.value.scrollTop = targetScrollTop2;
217
+ if (typeof containerRef.value.scrollTo === "function") {
218
+ try {
219
+ containerRef.value.scrollTo({
220
+ top: targetScrollTop2,
221
+ behavior
222
+ });
223
+ } catch {
224
+ }
225
+ }
219
226
  }
220
227
  return;
221
228
  }
@@ -223,10 +230,16 @@ export function useVirtualScroll(options) {
223
230
  const targetScrollTop = Math.max(0, targetRow * baseItemHeight.value - offset);
224
231
  scrollTop.value = targetScrollTop;
225
232
  if (containerRef.value) {
226
- containerRef.value.scrollTo({
227
- top: targetScrollTop,
228
- behavior
229
- });
233
+ containerRef.value.scrollTop = targetScrollTop;
234
+ if (typeof containerRef.value.scrollTo === "function") {
235
+ try {
236
+ containerRef.value.scrollTo({
237
+ top: targetScrollTop,
238
+ behavior
239
+ });
240
+ } catch {
241
+ }
242
+ }
230
243
  }
231
244
  };
232
245
  return {
@@ -4,6 +4,7 @@ type __VLS_Props = {
4
4
  bulkActions: IKDatatableAction[];
5
5
  selectedRows: any[];
6
6
  selectAll: boolean;
7
+ unselectedRows?: any[];
7
8
  filter?: any;
8
9
  selected: any;
9
10
  dp: CFlatClientDataProvider;
@@ -19,7 +19,7 @@
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 {{ props.selectAll ? (props.filter?.active ? t('All filtered items selected') : t('All items selected')) : t('Selected {count} items').replace('{count}', props.selectedRows.length.toString()) }}
22
+ .info {{ props.selectAll ? (props.unselectedRows && props.unselectedRows.length > 0 ? (props.filter?.active ? t('All filtered items selected ({count} excluded)').replace('{count}', props.unselectedRows.length.toString()) : t('All items selected ({count} excluded)').replace('{count}', props.unselectedRows.length.toString())) : (props.filter?.active ? t('All filtered items selected') : 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">
@@ -34,6 +34,7 @@ const props = defineProps<{
34
34
  bulkActions: IKDatatableAction[]
35
35
  selectedRows: any[]
36
36
  selectAll: boolean
37
+ unselectedRows?: any[]
37
38
  filter?: any
38
39
  selected: any
39
40
  dp: CFlatClientDataProvider
@@ -4,6 +4,7 @@ type __VLS_Props = {
4
4
  bulkActions: IKDatatableAction[];
5
5
  selectedRows: any[];
6
6
  selectAll: boolean;
7
+ unselectedRows?: any[];
7
8
  filter?: any;
8
9
  selected: any;
9
10
  dp: CFlatClientDataProvider;
@@ -1,18 +1,24 @@
1
1
  type __VLS_Props = {
2
- model: any;
3
- checkboxValue: any;
4
- isDisabled: boolean;
2
+ model?: any;
3
+ modelValue?: any;
4
+ checkboxValue?: any;
5
+ isDisabled?: boolean;
5
6
  label?: string;
6
7
  validation?: 'success' | 'warning' | 'error' | null;
7
8
  validationText?: string;
8
9
  idKey?: string;
10
+ indeterminate?: boolean;
9
11
  };
10
12
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
13
+ "update:modelValue": (value: any) => any;
11
14
  blur: (event: FocusEvent) => any;
12
15
  "update:model": (value: any) => any;
16
+ "update:indeterminate": (value: boolean) => any;
13
17
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
18
+ "onUpdate:modelValue"?: ((value: any) => any) | undefined;
14
19
  onBlur?: ((event: FocusEvent) => any) | undefined;
15
20
  "onUpdate:model"?: ((value: any) => any) | undefined;
21
+ "onUpdate:indeterminate"?: ((value: boolean) => any) | undefined;
16
22
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
17
23
  declare const _default: typeof __VLS_export;
18
24
  export default _default;
@@ -2,15 +2,15 @@
2
2
  .KCheckbox-wrapper
3
3
  label.KCheckbox(
4
4
  role="checkbox"
5
- :aria-checked="isChecked"
5
+ :aria-checked="props.indeterminate ? 'mixed' : isChecked"
6
6
  :aria-disabled="isDisabled"
7
7
  tabindex="0"
8
8
  @keydown.space.prevent="handleSpaceKey"
9
9
  @blur="emit('blur', $event)"
10
10
  )
11
- input(type="checkbox" :checked="isChecked" :disabled="isDisabled" tabindex="-1" @change="toggleCheckbox")
12
- .icon-container(:class="validation ? `is-${validation}` : ''")
13
- KIcon.icon(iconname="check")
11
+ input(ref="inputRef" type="checkbox" :checked="isChecked" :indeterminate.prop="props.indeterminate" :disabled="isDisabled" tabindex="-1" @change="toggleCheckbox")
12
+ .icon-container(:class="[validation ? `is-${validation}` : '', { 'is-indeterminate': props.indeterminate }]")
13
+ KIcon.icon(:iconname="props.indeterminate ? 'minus' : 'check'")
14
14
  span
15
15
  slot(name="label")
16
16
  slot
@@ -19,29 +19,43 @@
19
19
  </template>
20
20
 
21
21
  <script lang="ts" setup>
22
- import { computed } from 'vue'
22
+ import { ref, computed, watch } from 'vue'
23
23
 
24
24
  // Default template for KCheckbox
25
25
  const props = defineProps<{
26
- model: any
27
- checkboxValue: any
28
- isDisabled: boolean
26
+ model?: any
27
+ modelValue?: any
28
+ checkboxValue?: any
29
+ isDisabled?: boolean
29
30
  label?: string
30
31
  validation?: 'success' | 'warning' | 'error' | null
31
32
  validationText?: string
32
33
  idKey?: string
34
+ indeterminate?: boolean
33
35
  }>()
34
36
 
35
37
  const emit = defineEmits<{
36
38
  (e: 'update:model', value: any): void
39
+ (e: 'update:modelValue', value: any): void
40
+ (e: 'update:indeterminate', value: boolean): void
37
41
  (e: 'blur', event: FocusEvent): void
38
42
  }>()
39
43
 
40
44
  const internalModel = computed({
41
- get: () => props.model,
42
- set: (value) => emit('update:model', value)
45
+ get: () => (props.modelValue !== undefined ? props.modelValue : props.model),
46
+ set: (value) => {
47
+ emit('update:model', value)
48
+ emit('update:modelValue', value)
49
+ }
43
50
  })
44
51
 
52
+ const inputRef = ref<HTMLInputElement | null>(null)
53
+ watch(() => props.indeterminate, (val) => {
54
+ if (inputRef.value) {
55
+ inputRef.value.indeterminate = !!val
56
+ }
57
+ }, { immediate: true, flush: 'post' })
58
+
45
59
  const getId = (item: any) => {
46
60
  if (item && typeof item === 'object') {
47
61
  const key = props.idKey
@@ -77,6 +91,9 @@ const isChecked = computed(() => {
77
91
 
78
92
  function toggleCheckbox() {
79
93
  if (props.isDisabled) return
94
+ if (props.indeterminate) {
95
+ emit('update:indeterminate', false)
96
+ }
80
97
  if (Array.isArray(internalModel.value)) {
81
98
  const val = props.checkboxValue
82
99
  const arr = [...internalModel.value]
@@ -88,7 +105,11 @@ function toggleCheckbox() {
88
105
  }
89
106
  internalModel.value = arr
90
107
  } else {
91
- internalModel.value = !internalModel.value
108
+ if (props.indeterminate) {
109
+ internalModel.value = true
110
+ } else {
111
+ internalModel.value = !internalModel.value
112
+ }
92
113
  }
93
114
  }
94
115
 
@@ -131,7 +152,9 @@ function handleSpaceKey() {
131
152
  display: none;
132
153
  }
133
154
 
134
- :checked + .icon-container > .icon {
155
+ :checked + .icon-container > .icon,
156
+ :indeterminate + .icon-container > .icon,
157
+ .icon-container.is-indeterminate > .icon {
135
158
  display: block;
136
159
  }
137
160
  }
@@ -1,18 +1,24 @@
1
1
  type __VLS_Props = {
2
- model: any;
3
- checkboxValue: any;
4
- isDisabled: boolean;
2
+ model?: any;
3
+ modelValue?: any;
4
+ checkboxValue?: any;
5
+ isDisabled?: boolean;
5
6
  label?: string;
6
7
  validation?: 'success' | 'warning' | 'error' | null;
7
8
  validationText?: string;
8
9
  idKey?: string;
10
+ indeterminate?: boolean;
9
11
  };
10
12
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
13
+ "update:modelValue": (value: any) => any;
11
14
  blur: (event: FocusEvent) => any;
12
15
  "update:model": (value: any) => any;
16
+ "update:indeterminate": (value: boolean) => any;
13
17
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
18
+ "onUpdate:modelValue"?: ((value: any) => any) | undefined;
14
19
  onBlur?: ((event: FocusEvent) => any) | undefined;
15
20
  "onUpdate:model"?: ((value: any) => any) | undefined;
21
+ "onUpdate:indeterminate"?: ((value: boolean) => any) | undefined;
16
22
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
17
23
  declare const _default: typeof __VLS_export;
18
24
  export default _default;
@@ -7,6 +7,8 @@ type __VLS_Props = {
7
7
  bulkActions: Array<IKDatatableAction>;
8
8
  selectedRows: any[];
9
9
  selectAll: boolean;
10
+ selectAllScope?: 'page' | 'dataset';
11
+ unselectedRows?: any[];
10
12
  currentPage?: number;
11
13
  pageSize?: number;
12
14
  cellSlots?: Record<string, any>;
@@ -25,16 +27,22 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
25
27
  "update:pageSize": (value: number) => any;
26
28
  "update:selectedRows": (value: any[]) => any;
27
29
  "update:selectAll": (value: boolean) => any;
30
+ "update:unselectedRows": (value: any[]) => any;
31
+ "update:selectAllScope": (value: "page" | "dataset") => any;
28
32
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
29
33
  "onUpdate:currentPage"?: ((value: number) => any) | undefined;
30
34
  "onUpdate:pageSize"?: ((value: number) => any) | undefined;
31
35
  "onUpdate:selectedRows"?: ((value: any[]) => any) | undefined;
32
36
  "onUpdate:selectAll"?: ((value: boolean) => any) | undefined;
37
+ "onUpdate:unselectedRows"?: ((value: any[]) => any) | undefined;
38
+ "onUpdate:selectAllScope"?: ((value: "page" | "dataset") => any) | undefined;
33
39
  }>, {
40
+ unselectedRows: any[];
34
41
  virtualScroll: boolean;
35
42
  itemHeight: number;
36
43
  buffer: number;
37
44
  viewportHeight: number;
45
+ selectAllScope: "page" | "dataset";
38
46
  emptyStateText: string;
39
47
  emptyFilterStateText: string;
40
48
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;