@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
package/bin/cli.mjs CHANGED
File without changes
File without changes
@@ -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 {
@@ -0,0 +1,39 @@
1
+ function decodeHtmlEntities(str) {
2
+ return str.replace(/&#x([0-9a-f]+);?/gi, (_, hex) => String.fromCharCode(parseInt(hex, 16))).replace(/&#([0-9]+);?/g, (_, dec) => String.fromCharCode(parseInt(dec, 10))).replace(/&tab;/gi, " ").replace(/&newline;/gi, "\n").replace(/:/gi, ":");
3
+ }
4
+ export function sanitizeHtml(input) {
5
+ if (!input || typeof input !== "string") return "";
6
+ let sanitized = input;
7
+ const dangerousTags = [
8
+ "script",
9
+ "iframe",
10
+ "object",
11
+ "embed",
12
+ "applet",
13
+ "meta",
14
+ "link",
15
+ "base",
16
+ "style",
17
+ "form",
18
+ "input",
19
+ "button",
20
+ "textarea"
21
+ ];
22
+ for (const tag of dangerousTags) {
23
+ const tagRegex = new RegExp(`<${tag}\\b[\\s\\S]*?<\\/${tag}>|<${tag}\\b[^>]*\\/?>`, "gi");
24
+ sanitized = sanitized.replace(tagRegex, "");
25
+ }
26
+ sanitized = sanitized.replace(/[\s/]+on[a-zA-Z0-9_-]+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi, "");
27
+ sanitized = sanitized.replace(
28
+ /[\s/]+(?:href|xlink:href|src|action|data|formaction)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/gi,
29
+ (match, qDouble, qSingle, unquoted) => {
30
+ const rawVal = qDouble ?? qSingle ?? unquoted ?? "";
31
+ const normalized = decodeHtmlEntities(rawVal).replace(/[\u0000-\u001F\u007F-\u009F\s]/g, "").toLowerCase();
32
+ if (normalized.startsWith("javascript:") || normalized.startsWith("vbscript:") || normalized.startsWith("data:text/html") || normalized.startsWith("data:image/svg+xml")) {
33
+ return "";
34
+ }
35
+ return match;
36
+ }
37
+ );
38
+ return sanitized;
39
+ }
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@katlux/toolkit",
3
3
  "configKey": "katluxToolkit",
4
- "version": "0.1.1-alpha.123",
4
+ "version": "0.1.1-alpha.125",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -3,12 +3,14 @@ interface Props {
3
3
  bulkActions?: IKDatatableAction[];
4
4
  selectedRows?: TDataRow[];
5
5
  selectAll?: boolean;
6
+ unselectedRows?: TDataRow[];
6
7
  filter?: any;
7
8
  }
8
9
  declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {
9
10
  filter: any;
10
- bulkActions: IKDatatableAction[];
11
11
  selectedRows: TDataRow[];
12
+ unselectedRows: TDataRow[];
13
+ bulkActions: IKDatatableAction[];
12
14
  selectAll: boolean;
13
15
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
14
16
  declare const _default: typeof __VLS_export;
@@ -7,6 +7,7 @@ const props = defineProps({
7
7
  bulkActions: { type: Array, required: false, default: () => [] },
8
8
  selectedRows: { type: Array, required: false, default: () => [] },
9
9
  selectAll: { type: Boolean, required: false, default: false },
10
+ unselectedRows: { type: Array, required: false, default: () => [] },
10
11
  filter: { type: null, required: false, default: void 0 }
11
12
  });
12
13
  const { selected, dp, doAction, visibleBulkActions } = useKBulkActionsLogic(props);
@@ -15,6 +16,7 @@ const templateProps = computed(() => ({
15
16
  bulkActions: visibleBulkActions.value,
16
17
  selectedRows: props.selectedRows,
17
18
  selectAll: props.selectAll,
19
+ unselectedRows: props.unselectedRows,
18
20
  filter: props.filter,
19
21
  selected: selected.value,
20
22
  dp,
@@ -3,12 +3,14 @@ interface Props {
3
3
  bulkActions?: IKDatatableAction[];
4
4
  selectedRows?: TDataRow[];
5
5
  selectAll?: boolean;
6
+ unselectedRows?: TDataRow[];
6
7
  filter?: any;
7
8
  }
8
9
  declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {
9
10
  filter: any;
10
- bulkActions: IKDatatableAction[];
11
11
  selectedRows: TDataRow[];
12
+ unselectedRows: TDataRow[];
13
+ bulkActions: IKDatatableAction[];
12
14
  selectAll: boolean;
13
15
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
14
16
  declare const _default: typeof __VLS_export;
@@ -4,7 +4,9 @@ export interface KBulkActionsProps {
4
4
  bulkActions: IKDatatableAction[];
5
5
  selectedRows: TDataRow[];
6
6
  selectAll: boolean;
7
+ unselectedRows?: TDataRow[];
7
8
  filter?: any;
9
+ idKey?: string;
8
10
  }
9
11
  export declare const KBulkActionsDefaultProps: {};
10
12
  export declare function getApplicableRows(action: IKDatatableAction, selectedRows: TDataRow[], selectAll: boolean): TDataRow[];
@@ -79,7 +79,28 @@ export function useKBulkActionsLogic(props) {
79
79
  const act = action;
80
80
  if (act && act.action) {
81
81
  const applicableRows = getApplicableRows(act, props.selectedRows, props.selectAll);
82
- act.action(applicableRows, props.selectAll, props.filter);
82
+ const idKey = props.idKey || "id";
83
+ const getRowKey = (r) => r?.[idKey] ?? r?.id ?? r?._id ?? r;
84
+ const selectedRowKeys = (props.selectedRows || []).map(getRowKey);
85
+ const unselectedRowKeys = (props.unselectedRows || []).map(getRowKey);
86
+ const context = {
87
+ isAllSelected: Boolean(props.selectAll),
88
+ selectedRows: props.selectedRows || [],
89
+ selectedRowKeys,
90
+ unselectedRows: props.unselectedRows || [],
91
+ unselectedRowKeys,
92
+ filter: props.filter
93
+ };
94
+ const payload = [...applicableRows];
95
+ Object.defineProperties(payload, {
96
+ isAllSelected: { value: Boolean(props.selectAll), enumerable: false, configurable: true, writable: true },
97
+ selectedRows: { value: props.selectedRows || [], enumerable: false, configurable: true, writable: true },
98
+ selectedRowKeys: { value: selectedRowKeys, enumerable: false, configurable: true, writable: true },
99
+ unselectedRows: { value: props.unselectedRows || [], enumerable: false, configurable: true, writable: true },
100
+ unselectedRowKeys: { value: unselectedRowKeys, enumerable: false, configurable: true, writable: true },
101
+ filter: { value: props.filter, enumerable: false, configurable: true, writable: true }
102
+ });
103
+ act.action(payload, props.selectAll, props.filter);
83
104
  }
84
105
  }
85
106
  return {
@@ -25,6 +25,10 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
25
25
  type: StringConstructor;
26
26
  default: undefined;
27
27
  };
28
+ indeterminate: {
29
+ type: BooleanConstructor;
30
+ default: boolean;
31
+ };
28
32
  modelValue: {
29
33
  type: import("vue").PropType<any>;
30
34
  };
@@ -32,6 +36,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
32
36
  "update:modelValue": (value: any) => any;
33
37
  } & {
34
38
  blur: (event: FocusEvent) => any;
39
+ "update:indeterminate": (value: boolean) => any;
35
40
  }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
36
41
  disabled: {
37
42
  type: BooleanConstructor;
@@ -58,18 +63,24 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
58
63
  type: StringConstructor;
59
64
  default: undefined;
60
65
  };
66
+ indeterminate: {
67
+ type: BooleanConstructor;
68
+ default: boolean;
69
+ };
61
70
  modelValue: {
62
71
  type: import("vue").PropType<any>;
63
72
  };
64
73
  }>> & Readonly<{
65
74
  "onUpdate:modelValue"?: ((value: any) => any) | undefined;
66
75
  onBlur?: ((event: FocusEvent) => any) | undefined;
76
+ "onUpdate:indeterminate"?: ((value: boolean) => any) | undefined;
67
77
  }>, {
68
78
  label: string;
69
79
  disabled: boolean;
70
80
  validation: "error" | "success" | "warning" | null | undefined;
71
81
  validationText: string;
72
82
  idKey: string;
83
+ indeterminate: boolean;
73
84
  value: any;
74
85
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
75
86
  declare const _default: typeof __VLS_export;
@@ -7,7 +7,7 @@ const props = defineProps(KCheckboxDefaultProps);
7
7
  const model = defineModel();
8
8
  const { isDisabled, checkboxValue } = useKCheckboxLogic(props, model);
9
9
  const presetComponent = usePresetComponent("KCheckbox", KCheckboxDefault);
10
- defineEmits(["blur"]);
10
+ const emit = defineEmits(["blur", "update:indeterminate"]);
11
11
  const templateProps = computed(() => ({
12
12
  model: model.value,
13
13
  checkboxValue: checkboxValue.value,
@@ -15,12 +15,13 @@ const templateProps = computed(() => ({
15
15
  validation: props.validation,
16
16
  validationText: props.validationText,
17
17
  label: props.label,
18
- idKey: props.idKey
18
+ idKey: props.idKey,
19
+ indeterminate: props.indeterminate
19
20
  }));
20
21
  </script>
21
22
 
22
23
  <template lang="pug">
23
- component(:is="presetComponent" v-bind="templateProps" @update:model="model = $event" @blur="$emit('blur', $event)")
24
+ component(:is="presetComponent" v-bind="{ ...templateProps, ...$attrs }" @update:model="model = $event" @update:indeterminate="emit('update:indeterminate', $event)" @blur="emit('blur', $event)")
24
25
  template(v-for="(_, slot) in $slots" #[slot]="scope")
25
26
  slot(:name="slot" v-bind="scope")
26
27
  </template>
@@ -25,6 +25,10 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
25
25
  type: StringConstructor;
26
26
  default: undefined;
27
27
  };
28
+ indeterminate: {
29
+ type: BooleanConstructor;
30
+ default: boolean;
31
+ };
28
32
  modelValue: {
29
33
  type: import("vue").PropType<any>;
30
34
  };
@@ -32,6 +36,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
32
36
  "update:modelValue": (value: any) => any;
33
37
  } & {
34
38
  blur: (event: FocusEvent) => any;
39
+ "update:indeterminate": (value: boolean) => any;
35
40
  }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
36
41
  disabled: {
37
42
  type: BooleanConstructor;
@@ -58,18 +63,24 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
58
63
  type: StringConstructor;
59
64
  default: undefined;
60
65
  };
66
+ indeterminate: {
67
+ type: BooleanConstructor;
68
+ default: boolean;
69
+ };
61
70
  modelValue: {
62
71
  type: import("vue").PropType<any>;
63
72
  };
64
73
  }>> & Readonly<{
65
74
  "onUpdate:modelValue"?: ((value: any) => any) | undefined;
66
75
  onBlur?: ((event: FocusEvent) => any) | undefined;
76
+ "onUpdate:indeterminate"?: ((value: boolean) => any) | undefined;
67
77
  }>, {
68
78
  label: string;
69
79
  disabled: boolean;
70
80
  validation: "error" | "success" | "warning" | null | undefined;
71
81
  validationText: string;
72
82
  idKey: string;
83
+ indeterminate: boolean;
73
84
  value: any;
74
85
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
75
86
  declare const _default: typeof __VLS_export;
@@ -6,6 +6,7 @@ export interface KCheckboxProps {
6
6
  validationText?: string;
7
7
  label?: string;
8
8
  idKey?: string;
9
+ indeterminate?: boolean;
9
10
  }
10
11
  /**
11
12
  * KCheckbox Logic Composable
@@ -47,4 +48,8 @@ export declare const KCheckboxDefaultProps: {
47
48
  type: StringConstructor;
48
49
  default: undefined;
49
50
  };
51
+ indeterminate: {
52
+ type: BooleanConstructor;
53
+ default: boolean;
54
+ };
50
55
  };
@@ -35,5 +35,9 @@ export const KCheckboxDefaultProps = {
35
35
  idKey: {
36
36
  type: String,
37
37
  default: void 0
38
+ },
39
+ indeterminate: {
40
+ type: Boolean,
41
+ default: false
38
42
  }
39
43
  };
@@ -473,7 +473,7 @@ export function useKComboboxLogic(props, emit) {
473
473
  }
474
474
  }
475
475
  function resolveSelectedFromValue() {
476
- if (props.modelValue === void 0 || props.modelValue === null) {
476
+ if (props.modelValue === void 0 || props.modelValue === null || props.modelValue === "") {
477
477
  selectedItems.value = null;
478
478
  return;
479
479
  }
@@ -490,6 +490,8 @@ export function useKComboboxLogic(props, emit) {
490
490
  selectedItems.value = matchedItems;
491
491
  } else if (typeof props.modelValue === "object") {
492
492
  selectedItems.value = Array.isArray(props.modelValue) ? props.modelValue : [props.modelValue];
493
+ } else {
494
+ selectedItems.value = null;
493
495
  }
494
496
  }
495
497
  resolveSelectedFromValue();
@@ -40,8 +40,8 @@ declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {},
40
40
  "onSearch-change"?: ((value: string) => any) | undefined;
41
41
  }>, {
42
42
  search: string;
43
- bulkActions: IKDatatableAction[];
44
43
  selectedRows: any[];
44
+ bulkActions: IKDatatableAction[];
45
45
  selectAll: boolean;
46
46
  loading: boolean;
47
47
  currentPage: number;
@@ -40,8 +40,8 @@ declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {},
40
40
  "onSearch-change"?: ((value: string) => any) | undefined;
41
41
  }>, {
42
42
  search: string;
43
- bulkActions: IKDatatableAction[];
44
43
  selectedRows: any[];
44
+ bulkActions: IKDatatableAction[];
45
45
  selectAll: boolean;
46
46
  loading: boolean;
47
47
  currentPage: number;