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

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 (59) hide show
  1. package/dist/compiled/composables/useDataProvider.mjs +20 -0
  2. package/dist/compiled/composables/useKatluxForm.mjs +55 -12
  3. package/dist/compiled/composables/useVirtualScroll.mjs +78 -8
  4. package/dist/module.json +1 -1
  5. package/dist/runtime/components/KBulkActions/KBulkActions.logic.js +13 -7
  6. package/dist/runtime/components/KCheckbox/KCheckbox.global.d.vue.ts +12 -0
  7. package/dist/runtime/components/KCheckbox/KCheckbox.global.vue +4 -2
  8. package/dist/runtime/components/KCheckbox/KCheckbox.global.vue.d.ts +12 -0
  9. package/dist/runtime/components/KCheckbox/KCheckbox.logic.d.ts +5 -0
  10. package/dist/runtime/components/KCheckbox/KCheckbox.logic.js +4 -0
  11. package/dist/runtime/components/KCombobox/KCombobox.global.d.vue.ts +2 -0
  12. package/dist/runtime/components/KCombobox/KCombobox.global.vue +2 -2
  13. package/dist/runtime/components/KCombobox/KCombobox.global.vue.d.ts +2 -0
  14. package/dist/runtime/components/KCombobox/KCombobox.logic.d.ts +1 -0
  15. package/dist/runtime/components/KDatatable/KDatatable.logic.js +17 -2
  16. package/dist/runtime/components/KDatePicker/KDatePicker.global.d.vue.ts +2 -0
  17. package/dist/runtime/components/KDatePicker/KDatePicker.global.vue +2 -1
  18. package/dist/runtime/components/KDatePicker/KDatePicker.global.vue.d.ts +2 -0
  19. package/dist/runtime/components/KGantt/KGantt.logic.js +1 -6
  20. package/dist/runtime/components/KPagination/KPagination.global.d.vue.ts +2 -0
  21. package/dist/runtime/components/KPagination/KPagination.global.vue +1 -1
  22. package/dist/runtime/components/KPagination/KPagination.global.vue.d.ts +2 -0
  23. package/dist/runtime/components/KPagination/KPagination.logic.d.ts +1 -0
  24. package/dist/runtime/components/KPagination/KPagination.logic.js +6 -1
  25. package/dist/runtime/components/KTree/KTree.global.d.vue.ts +1 -1
  26. package/dist/runtime/components/KTree/KTree.global.vue +0 -1
  27. package/dist/runtime/components/KTree/KTree.global.vue.d.ts +1 -1
  28. package/dist/runtime/components/KTreePicker/KTreePicker.global.d.vue.ts +1 -1
  29. package/dist/runtime/components/KTreePicker/KTreePicker.global.vue.d.ts +1 -1
  30. package/dist/runtime/components/KTreeView/KTreeView.global.d.vue.ts +1 -1
  31. package/dist/runtime/components/KTreeView/KTreeView.global.vue.d.ts +1 -1
  32. package/dist/runtime/composables/useDataProvider.d.ts +1 -0
  33. package/dist/runtime/composables/useDataProvider.js +20 -0
  34. package/dist/runtime/composables/useKatluxForm.d.ts +2 -0
  35. package/dist/runtime/composables/useKatluxForm.js +55 -12
  36. package/dist/runtime/composables/useVirtualScroll.d.ts +1 -1
  37. package/dist/runtime/composables/useVirtualScroll.js +78 -8
  38. package/dist/runtime/presets/default/components/KCheckbox/KCheckbox.d.vue.ts +3 -0
  39. package/dist/runtime/presets/default/components/KCheckbox/KCheckbox.vue +7 -0
  40. package/dist/runtime/presets/default/components/KCheckbox/KCheckbox.vue.d.ts +3 -0
  41. package/dist/runtime/presets/default/components/KCombobox/KCombobox.d.vue.ts +2 -0
  42. package/dist/runtime/presets/default/components/KCombobox/KCombobox.vue +2 -0
  43. package/dist/runtime/presets/default/components/KCombobox/KCombobox.vue.d.ts +2 -0
  44. package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.d.vue.ts +2 -0
  45. package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.vue +20 -6
  46. package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.vue.d.ts +2 -0
  47. package/dist/runtime/presets/default/components/KDatatable/KDatatable.vue +29 -12
  48. package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.d.vue.ts +3 -1
  49. package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.vue +3 -1
  50. package/dist/runtime/presets/default/components/KDatePicker/KDatePicker.vue.d.ts +3 -1
  51. package/dist/runtime/presets/default/components/KLayout/KLayout.d.vue.ts +6 -1
  52. package/dist/runtime/presets/default/components/KLayout/KLayout.vue +37 -5
  53. package/dist/runtime/presets/default/components/KLayout/KLayout.vue.d.ts +6 -1
  54. package/dist/runtime/presets/default/components/KToast/KToast.vue +0 -1
  55. package/dist/runtime/presets/default/components/KToastContainer/KToastContainer.vue +0 -1
  56. package/dist/runtime/presets/default/components/KTree/KTree.d.vue.ts +2 -3
  57. package/dist/runtime/presets/default/components/KTree/KTree.vue +7 -5
  58. package/dist/runtime/presets/default/components/KTree/KTree.vue.d.ts +2 -3
  59. package/package.json +2 -2
@@ -56,6 +56,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
56
56
  }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
57
57
  "update:modelValue": (value: string | Date) => any;
58
58
  change: (value: string | Date) => any;
59
+ blur: (event: FocusEvent) => any;
59
60
  "update:isOpen": (value: boolean) => any;
60
61
  "update:maskedModel": (value: string) => any;
61
62
  "update:calendarShow": (value: boolean) => any;
@@ -117,6 +118,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
117
118
  }>> & Readonly<{
118
119
  "onUpdate:modelValue"?: ((value: string | Date) => any) | undefined;
119
120
  onChange?: ((value: string | Date) => any) | undefined;
121
+ onBlur?: ((event: FocusEvent) => any) | undefined;
120
122
  "onUpdate:isOpen"?: ((value: boolean) => any) | undefined;
121
123
  "onUpdate:maskedModel"?: ((value: string) => any) | undefined;
122
124
  "onUpdate:calendarShow"?: ((value: boolean) => any) | undefined;
@@ -81,12 +81,7 @@ export const KGanttDefaultProps = {
81
81
  }
82
82
  };
83
83
  export function useKGanttLogic(props) {
84
- let baseNow = Date.now();
85
- try {
86
- const nuxtState = globalThis.useState?.("gantt-base-now", () => Date.now());
87
- if (nuxtState?.value) baseNow = nuxtState.value;
88
- } catch {
89
- }
84
+ const baseNow = Date.now();
90
85
  const globalDateRange = computed(() => {
91
86
  const now = baseNow;
92
87
  const msInDay = 24 * 60 * 60 * 1e3;
@@ -12,11 +12,13 @@ declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {},
12
12
  change: (value: number) => any;
13
13
  "update:currentPage": (value: number) => any;
14
14
  "update:pageSize": (value: number) => any;
15
+ "page-click": (value: number) => any;
15
16
  }, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
16
17
  "onUpdate:modelValue"?: ((value: number) => any) | undefined;
17
18
  onChange?: ((value: number) => any) | undefined;
18
19
  "onUpdate:currentPage"?: ((value: number) => any) | undefined;
19
20
  "onUpdate:pageSize"?: ((value: number) => any) | undefined;
21
+ "onPage-click"?: ((value: number) => any) | undefined;
20
22
  }>, {
21
23
  modelValue: number;
22
24
  currentPage: number;
@@ -12,7 +12,7 @@ const props = defineProps({
12
12
  totalItems: { type: Number, required: false, default: void 0 },
13
13
  maxVisiblePages: { type: Number, required: false, default: 10 }
14
14
  });
15
- const emit = defineEmits(["update:modelValue", "update:currentPage", "update:pageSize", "change"]);
15
+ const emit = defineEmits(["update:modelValue", "update:currentPage", "update:pageSize", "change", "page-click"]);
16
16
  const {
17
17
  dp,
18
18
  totalPages,
@@ -12,11 +12,13 @@ declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {},
12
12
  change: (value: number) => any;
13
13
  "update:currentPage": (value: number) => any;
14
14
  "update:pageSize": (value: number) => any;
15
+ "page-click": (value: number) => any;
15
16
  }, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
16
17
  "onUpdate:modelValue"?: ((value: number) => any) | undefined;
17
18
  onChange?: ((value: number) => any) | undefined;
18
19
  "onUpdate:currentPage"?: ((value: number) => any) | undefined;
19
20
  "onUpdate:pageSize"?: ((value: number) => any) | undefined;
21
+ "onPage-click"?: ((value: number) => any) | undefined;
20
22
  }>, {
21
23
  modelValue: number;
22
24
  currentPage: number;
@@ -12,6 +12,7 @@ export type KPaginationEmits = {
12
12
  (e: 'update:currentPage', page: number): void;
13
13
  (e: 'update:pageSize', size: number): void;
14
14
  (e: 'change', page: number): void;
15
+ (e: 'page-click', page: number): void;
15
16
  };
16
17
  export declare const KPaginationDefaultProps: {
17
18
  maxVisiblePages: number;
@@ -92,7 +92,11 @@ export function useKPaginationLogic(props, emit) {
92
92
  () => (visiblePages.value[visiblePages.value.length - 1] || 0) < totalPages.value - 1
93
93
  );
94
94
  const pageClicked = (item) => {
95
- if (item < 1 || item > totalPages.value || item === currentPage.value) return;
95
+ if (item < 1 || item > totalPages.value) return;
96
+ if (item === currentPage.value) {
97
+ emit?.("page-click", item);
98
+ return;
99
+ }
96
100
  localCurrentPage.value = item;
97
101
  if (typeof dp?.setCurrentPage === "function") {
98
102
  dp.setCurrentPage(item);
@@ -109,6 +113,7 @@ export function useKPaginationLogic(props, emit) {
109
113
  emit?.("update:modelValue", item);
110
114
  emit?.("update:currentPage", item);
111
115
  emit?.("change", item);
116
+ emit?.("page-click", item);
112
117
  };
113
118
  const goToPrev = () => {
114
119
  if (currentPage.value > 1) {
@@ -152,6 +152,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
152
152
  }>, {
153
153
  modelValue: any;
154
154
  disabled: boolean;
155
+ idKey: string;
155
156
  searchtext: string;
156
157
  virtualScroll: boolean;
157
158
  itemHeight: number;
@@ -161,7 +162,6 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
161
162
  viewportHeight: number;
162
163
  expandedNodes: (string | number)[] | Set<string | number>;
163
164
  iconField: string;
164
- idKey: string;
165
165
  isNodeSelected: (node: any) => boolean;
166
166
  selectable: boolean;
167
167
  selectedNode: any;
@@ -44,7 +44,6 @@ component(
44
44
  :is="presetComponent"
45
45
  v-bind="templateProps"
46
46
  @select="selectNode"
47
- @node-click="selectNode"
48
47
  )
49
48
  // Passes slots from parent to template (for custom node content)
50
49
  template(v-for="(_, slot) in $slots" v-slot:[slot]="scope")
@@ -152,6 +152,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
152
152
  }>, {
153
153
  modelValue: any;
154
154
  disabled: boolean;
155
+ idKey: string;
155
156
  searchtext: string;
156
157
  virtualScroll: boolean;
157
158
  itemHeight: number;
@@ -161,7 +162,6 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
161
162
  viewportHeight: number;
162
163
  expandedNodes: (string | number)[] | Set<string | number>;
163
164
  iconField: string;
164
- idKey: string;
165
165
  isNodeSelected: (node: any) => boolean;
166
166
  selectable: boolean;
167
167
  selectedNode: any;
@@ -237,6 +237,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
237
237
  loading: boolean;
238
238
  validation: "error" | "success" | "warning" | null | undefined;
239
239
  validationText: string;
240
+ idKey: string;
240
241
  searchbox: boolean;
241
242
  searchtext: string;
242
243
  searchPlaceholder: string;
@@ -253,7 +254,6 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
253
254
  expandedNodes: any;
254
255
  parentKey: string;
255
256
  iconField: string;
256
- idKey: string;
257
257
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
258
258
  declare const _default: typeof __VLS_export;
259
259
  export default _default;
@@ -237,6 +237,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
237
237
  loading: boolean;
238
238
  validation: "error" | "success" | "warning" | null | undefined;
239
239
  validationText: string;
240
+ idKey: string;
240
241
  searchbox: boolean;
241
242
  searchtext: string;
242
243
  searchPlaceholder: string;
@@ -253,7 +254,6 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
253
254
  expandedNodes: any;
254
255
  parentKey: string;
255
256
  iconField: string;
256
- idKey: string;
257
257
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
258
258
  declare const _default: typeof __VLS_export;
259
259
  export default _default;
@@ -142,6 +142,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
142
142
  bulkActions: import("@katlux/providers").IKDatatableAction[];
143
143
  selectedRows: any[];
144
144
  selectAll: boolean;
145
+ idKey: string;
145
146
  virtualScroll: boolean;
146
147
  itemHeight: number;
147
148
  buffer: number;
@@ -152,7 +153,6 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
152
153
  parentKey: string;
153
154
  expandedByDefault: boolean;
154
155
  treeColumnIndex: number;
155
- idKey: string;
156
156
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
157
157
  declare const _default: typeof __VLS_export;
158
158
  export default _default;
@@ -142,6 +142,7 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
142
142
  bulkActions: import("@katlux/providers").IKDatatableAction[];
143
143
  selectedRows: any[];
144
144
  selectAll: boolean;
145
+ idKey: string;
145
146
  virtualScroll: boolean;
146
147
  itemHeight: number;
147
148
  buffer: number;
@@ -152,7 +153,6 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
152
153
  parentKey: string;
153
154
  expandedByDefault: boolean;
154
155
  treeColumnIndex: number;
155
- idKey: string;
156
156
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
157
157
  declare const _default: typeof __VLS_export;
158
158
  export default _default;
@@ -11,6 +11,7 @@ export interface IUseDataProviderOptions<TRow = any> {
11
11
  export interface IUseDataProviderReturn<T = TDataRow> {
12
12
  rawProvider: any;
13
13
  pageData: Ref<T[]>;
14
+ virtualRows: Ref<T[]>;
14
15
  rowCount: Ref<number>;
15
16
  currentPage: Ref<number>;
16
17
  pageSize: Ref<number>;
@@ -15,6 +15,22 @@ export function useDataProvider(provider, options) {
15
15
  const pageData = shallowRef(
16
16
  activeProvider ? activeProvider.pageData?.value !== void 0 ? activeProvider.pageData.value : Array.isArray(activeProvider.pageData) ? activeProvider.pageData : extractVal(activeProvider.pageData, []) : []
17
17
  );
18
+ const getFullData = () => {
19
+ if (!activeProvider) return [];
20
+ if (Array.isArray(activeProvider.allVisibleRows) && activeProvider.allVisibleRows.length > 0) return activeProvider.allVisibleRows;
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;
26
+ if (Array.isArray(activeProvider.allData) && activeProvider.allData.length > 0) return activeProvider.allData;
27
+ if (Array.isArray(activeProvider.allData?.value) && activeProvider.allData.value.length > 0) return activeProvider.allData.value;
28
+ if (Array.isArray(activeProvider.data) && activeProvider.data.length > 0) return activeProvider.data;
29
+ if (Array.isArray(activeProvider.rowMap)) return activeProvider.rowMap;
30
+ if (Array.isArray(activeProvider.allVisibleRows)) return activeProvider.allVisibleRows;
31
+ return pageData.value;
32
+ };
33
+ const virtualRows = shallowRef(activeProvider ? getFullData() : []);
18
34
  const rowCount = ref(activeProvider ? extractVal(activeProvider.rowCount, 0) : 0);
19
35
  const currentPage = options?.currentPage || ref(activeProvider ? extractVal(activeProvider.currentPage, 1) : 1);
20
36
  const pageSize = options?.pageSize || ref(activeProvider ? extractVal(activeProvider.pageSize, 10) : 10);
@@ -30,6 +46,7 @@ export function useDataProvider(provider, options) {
30
46
  const syncFromProvider = () => {
31
47
  if (!activeProvider) {
32
48
  pageData.value = [];
49
+ virtualRows.value = [];
33
50
  rowCount.value = 0;
34
51
  currentPage.value = 1;
35
52
  pageSize.value = 10;
@@ -46,6 +63,7 @@ export function useDataProvider(provider, options) {
46
63
  try {
47
64
  pageData.value = activeProvider.pageData?.value !== void 0 ? activeProvider.pageData.value : Array.isArray(activeProvider.pageData) ? activeProvider.pageData : extractVal(activeProvider.pageData, []);
48
65
  rowCount.value = extractVal(activeProvider.rowCount, 0);
66
+ virtualRows.value = getFullData();
49
67
  const newPage = extractVal(activeProvider.currentPage, 1);
50
68
  if (currentPage.value !== newPage) {
51
69
  currentPage.value = newPage;
@@ -93,6 +111,7 @@ export function useDataProvider(provider, options) {
93
111
  }
94
112
  };
95
113
  attachListener();
114
+ syncFromProvider();
96
115
  try {
97
116
  onScopeDispose(() => {
98
117
  if (unsubscribe) {
@@ -320,6 +339,7 @@ export function useDataProvider(provider, options) {
320
339
  return activeProvider;
321
340
  },
322
341
  pageData,
342
+ virtualRows,
323
343
  rowCount,
324
344
  currentPage,
325
345
  pageSize,
@@ -112,6 +112,8 @@ export interface FieldBinding<T = any> {
112
112
  validation: 'error' | 'warning' | 'success' | null;
113
113
  validationText: string;
114
114
  onBlur: () => void;
115
+ 'aria-invalid'?: boolean;
116
+ 'aria-describedby'?: string;
115
117
  }
116
118
  /**
117
119
  * Schema-based Form Validation Composable
@@ -45,15 +45,28 @@ export function useKatluxForm(options = {}) {
45
45
  const submitCount = ref(0);
46
46
  const isDirty = computed(() => Object.values(dirtyFields.value).some(Boolean));
47
47
  const isValid = computed(() => Object.keys(errors.value).length === 0);
48
+ function registerErrorPaths(errorMap, pathStr, message) {
49
+ if (!pathStr) {
50
+ errorMap[""] = message;
51
+ return;
52
+ }
53
+ errorMap[pathStr] = message;
54
+ const bracketPath = pathStr.replace(/\.(\d+)(?=\.|$)/g, "[$1]");
55
+ if (bracketPath !== pathStr && !errorMap[bracketPath]) {
56
+ errorMap[bracketPath] = message;
57
+ }
58
+ const dotPath = pathStr.replace(/\[(\d+)\]/g, ".$1");
59
+ if (dotPath !== pathStr && !errorMap[dotPath]) {
60
+ errorMap[dotPath] = message;
61
+ }
62
+ }
48
63
  function parseValidationResult(rawResult, schemaType, dataToValidate) {
49
64
  if (schemaType === "standard") {
50
65
  if (rawResult.issues && rawResult.issues.length > 0) {
51
66
  const errorMap = {};
52
67
  for (const issue of rawResult.issues) {
53
68
  const pathStr = issue.path && issue.path.length > 0 ? issue.path.map((seg) => typeof seg === "object" && seg !== null && "key" in seg ? seg.key : seg).join(".") : "";
54
- if (!errorMap[pathStr]) {
55
- errorMap[pathStr] = issue.message;
56
- }
69
+ registerErrorPaths(errorMap, pathStr, issue.message);
57
70
  }
58
71
  return { valid: false, output: dataToValidate, errors: errorMap };
59
72
  }
@@ -64,16 +77,18 @@ export function useKatluxForm(options = {}) {
64
77
  const errorMap = {};
65
78
  for (const issue of rawResult.error.issues) {
66
79
  const pathStr = issue.path ? issue.path.join(".") : "";
67
- if (!errorMap[pathStr]) {
68
- errorMap[pathStr] = issue.message;
69
- }
80
+ registerErrorPaths(errorMap, pathStr, issue.message);
70
81
  }
71
82
  return { valid: false, output: dataToValidate, errors: errorMap };
72
83
  }
73
84
  return { valid: true, output: rawResult.data ?? dataToValidate, errors: {} };
74
85
  }
75
86
  if (schemaType === "custom") {
76
- const errorMap = rawResult || {};
87
+ const errorMap = {};
88
+ const rawErrors = rawResult || {};
89
+ for (const [key, msg] of Object.entries(rawErrors)) {
90
+ registerErrorPaths(errorMap, key, String(msg));
91
+ }
77
92
  const valid = Object.keys(errorMap).length === 0;
78
93
  return { valid, output: dataToValidate, errors: errorMap };
79
94
  }
@@ -109,12 +124,17 @@ export function useKatluxForm(options = {}) {
109
124
  }
110
125
  function applyErrors(targetPath, newErrors) {
111
126
  if (targetPath) {
112
- if (newErrors[targetPath]) {
113
- errors.value = { ...errors.value, [targetPath]: newErrors[targetPath] };
127
+ const bracketPath = targetPath.replace(/\.(\d+)(?=\.|$)/g, "[$1]");
128
+ const dotPath = targetPath.replace(/\[(\d+)\]/g, ".$1");
129
+ const err = newErrors[targetPath] || newErrors[bracketPath] || newErrors[dotPath];
130
+ if (err) {
131
+ errors.value = { ...errors.value, [targetPath]: err };
114
132
  return false;
115
133
  } else {
116
134
  const nextErrors = { ...errors.value };
117
135
  delete nextErrors[targetPath];
136
+ delete nextErrors[bracketPath];
137
+ delete nextErrors[dotPath];
118
138
  errors.value = nextErrors;
119
139
  return true;
120
140
  }
@@ -123,10 +143,17 @@ export function useKatluxForm(options = {}) {
123
143
  return Object.keys(newErrors).length === 0;
124
144
  }
125
145
  }
146
+ let validationSeq = 0;
126
147
  function validate(targetPath) {
148
+ const seq = ++validationSeq;
127
149
  const result = runValidation(values);
128
150
  if (result && typeof result.then === "function") {
129
- return result.then(({ errors: newErrors }) => applyErrors(targetPath, newErrors));
151
+ return result.then(({ errors: newErrors }) => {
152
+ if (seq !== validationSeq) {
153
+ return Object.keys(errors.value).length === 0;
154
+ }
155
+ return applyErrors(targetPath, newErrors);
156
+ });
130
157
  }
131
158
  return applyErrors(targetPath, result.errors);
132
159
  }
@@ -176,9 +203,18 @@ export function useKatluxForm(options = {}) {
176
203
  return getByPath(values, path);
177
204
  },
178
205
  "onUpdate:modelValue": (newVal) => {
179
- const transformed = regOptions.transform ? regOptions.transform(newVal) : newVal;
206
+ let transformed = newVal;
207
+ if (regOptions.transform) {
208
+ if (regOptions.transform === Number) {
209
+ transformed = newVal === "" || newVal === null || newVal === void 0 ? "" : Number(newVal);
210
+ } else {
211
+ transformed = regOptions.transform(newVal);
212
+ }
213
+ }
180
214
  setByPath(values, path, transformed);
181
- dirtyFields.value = { ...dirtyFields.value, [path]: true };
215
+ const initialVal = getByPath(initialValues, path);
216
+ const isFieldDirty = JSON.stringify(transformed) !== JSON.stringify(initialVal);
217
+ dirtyFields.value = { ...dirtyFields.value, [path]: isFieldDirty };
182
218
  const hasActiveError = !!errors.value[path];
183
219
  if (mode === "onChange" || hasActiveError && reValidateMode === "onChange") {
184
220
  validate(path);
@@ -196,6 +232,12 @@ export function useKatluxForm(options = {}) {
196
232
  }
197
233
  return errors.value[path] || "";
198
234
  },
235
+ get "aria-invalid"() {
236
+ return !!errors.value[path];
237
+ },
238
+ get "aria-describedby"() {
239
+ return errors.value[path] ? `${path}-error` : void 0;
240
+ },
199
241
  onBlur: () => {
200
242
  touched.value = { ...touched.value, [path]: true };
201
243
  const hasActiveError = !!errors.value[path];
@@ -221,6 +263,7 @@ export function useKatluxForm(options = {}) {
221
263
  }
222
264
  function handleSubmit(onValid, onInvalid) {
223
265
  return async (event) => {
266
+ if (isSubmitting.value) return;
224
267
  if (event && typeof event.preventDefault === "function") {
225
268
  event.preventDefault();
226
269
  }
@@ -28,7 +28,7 @@ export interface IUseVirtualScrollReturn<T> {
28
28
  viewportHeight: Ref<number>;
29
29
  containerRef: Ref<HTMLElement | null>;
30
30
  onScroll: (e: Event | UIEvent) => void;
31
- scrollToIndex: (index: number, behavior?: ScrollBehavior) => void;
31
+ scrollToIndex: (index: number, behavior?: ScrollBehavior, offset?: number) => void;
32
32
  containerCssVars: ComputedRef<Record<string, string>>;
33
33
  }
34
34
  export declare function useVirtualScroll<T = any>(options: IUseVirtualScrollOptions<T>): IUseVirtualScrollReturn<T>;
@@ -42,6 +42,7 @@ export function useVirtualScroll(options) {
42
42
  const val = unref(options.containerHeight);
43
43
  return typeof val === "number" && val > 0 ? val : 400;
44
44
  };
45
+ const configuredContainerHeight = computed(() => resolveContainerHeight());
45
46
  const viewportHeight = ref(resolveContainerHeight());
46
47
  watch(
47
48
  () => resolveContainerHeight(),
@@ -51,13 +52,13 @@ export function useVirtualScroll(options) {
51
52
  }
52
53
  }
53
54
  );
54
- watch(containerRef, (el, oldEl) => {
55
+ watch([containerRef, isVirtual], ([el, virtual], [oldEl]) => {
55
56
  if (typeof window === "undefined" || typeof ResizeObserver === "undefined") return;
56
57
  if (oldEl && oldEl.__vsObserver) {
57
58
  oldEl.__vsObserver.disconnect();
58
59
  delete oldEl.__vsObserver;
59
60
  }
60
- if (el) {
61
+ if (el && virtual) {
61
62
  const ro = new ResizeObserver((entries) => {
62
63
  for (const entry of entries) {
63
64
  const h = Math.round(entry.contentRect.height || el.clientHeight);
@@ -78,12 +79,42 @@ export function useVirtualScroll(options) {
78
79
  }
79
80
  });
80
81
  }
82
+ const isDynamicHeight = computed(() => typeof options.itemHeight === "function");
83
+ const rowOffsets = computed(() => {
84
+ if (!isDynamicHeight.value || colCount.value > 1) return [];
85
+ const items = allItems.value;
86
+ const offsets = new Array(items.length + 1);
87
+ offsets[0] = 0;
88
+ let current = 0;
89
+ for (let i = 0; i < items.length; i++) {
90
+ current += getItemHeight(items[i], i);
91
+ offsets[i + 1] = current;
92
+ }
93
+ return offsets;
94
+ });
81
95
  const totalRows = computed(() => {
82
96
  if (colCount.value <= 1) return totalCount.value;
83
97
  return Math.ceil(totalCount.value / colCount.value);
84
98
  });
85
99
  const startRowIndex = computed(() => {
86
100
  if (!isVirtual.value) return 0;
101
+ if (isDynamicHeight.value && colCount.value <= 1) {
102
+ const offsets = rowOffsets.value;
103
+ const top = Math.max(0, scrollTop.value);
104
+ let low = 0;
105
+ let high = totalRows.value - 1;
106
+ let idx = 0;
107
+ while (low <= high) {
108
+ const mid = low + high >> 1;
109
+ if (offsets[mid + 1] > top) {
110
+ idx = mid;
111
+ high = mid - 1;
112
+ } else {
113
+ low = mid + 1;
114
+ }
115
+ }
116
+ return Math.max(0, idx - buf.value);
117
+ }
87
118
  const rawRow = Math.floor(scrollTop.value / baseItemHeight.value);
88
119
  return Math.max(0, rawRow - buf.value);
89
120
  });
@@ -94,6 +125,23 @@ export function useVirtualScroll(options) {
94
125
  });
95
126
  const endRowIndex = computed(() => {
96
127
  if (!isVirtual.value) return totalRows.value;
128
+ if (isDynamicHeight.value && colCount.value <= 1) {
129
+ const offsets = rowOffsets.value;
130
+ const bottom = scrollTop.value + viewportHeight.value;
131
+ let low = startRowIndex.value;
132
+ let high = totalRows.value - 1;
133
+ let idx = totalRows.value;
134
+ while (low <= high) {
135
+ const mid = low + high >> 1;
136
+ if (offsets[mid] >= bottom) {
137
+ idx = mid;
138
+ high = mid - 1;
139
+ } else {
140
+ low = mid + 1;
141
+ }
142
+ }
143
+ return Math.min(totalRows.value, idx + buf.value);
144
+ }
97
145
  return Math.min(totalRows.value, startRowIndex.value + visibleRowsCount.value);
98
146
  });
99
147
  const startIndex = computed(() => {
@@ -110,16 +158,27 @@ export function useVirtualScroll(options) {
110
158
  });
111
159
  const topSpacerHeight = computed(() => {
112
160
  if (!isVirtual.value) return 0;
161
+ if (isDynamicHeight.value && colCount.value <= 1) {
162
+ return rowOffsets.value[startRowIndex.value] || 0;
163
+ }
113
164
  return Math.max(0, startRowIndex.value * baseItemHeight.value);
114
165
  });
166
+ const totalHeight = computed(() => {
167
+ if (isDynamicHeight.value && colCount.value <= 1) {
168
+ const offsets = rowOffsets.value;
169
+ return offsets.length > 0 ? offsets[offsets.length - 1] : 0;
170
+ }
171
+ return totalRows.value * baseItemHeight.value;
172
+ });
115
173
  const bottomSpacerHeight = computed(() => {
116
174
  if (!isVirtual.value) return 0;
175
+ if (isDynamicHeight.value && colCount.value <= 1) {
176
+ const endOffset = rowOffsets.value[endRowIndex.value] || totalHeight.value;
177
+ return Math.max(0, totalHeight.value - endOffset);
178
+ }
117
179
  const remainingRows = Math.max(0, totalRows.value - endRowIndex.value);
118
180
  return remainingRows * baseItemHeight.value;
119
181
  });
120
- const totalHeight = computed(() => {
121
- return totalRows.value * baseItemHeight.value;
122
- });
123
182
  watch(totalHeight, (newTotal) => {
124
183
  if (scrollTop.value > newTotal) {
125
184
  scrollTop.value = Math.max(0, newTotal - viewportHeight.value);
@@ -133,7 +192,7 @@ export function useVirtualScroll(options) {
133
192
  "--virtual-spacer-bottom": `${bottomSpacerHeight.value}px`,
134
193
  "--virtual-total-height": `${totalHeight.value}px`,
135
194
  "--virtual-item-height": `${baseItemHeight.value}px`,
136
- "--virtual-container-height": `${viewportHeight.value}px`
195
+ "--virtual-container-height": `${configuredContainerHeight.value}px`
137
196
  }));
138
197
  const scrollThreshold = options.scrollThreshold ?? 100;
139
198
  const onScroll = (e) => {
@@ -148,9 +207,20 @@ export function useVirtualScroll(options) {
148
207
  options.onThresholdReach();
149
208
  }
150
209
  };
151
- const scrollToIndex = (index, behavior = "auto") => {
210
+ const scrollToIndex = (index, behavior = "auto", offset = 0) => {
211
+ if (isDynamicHeight.value && colCount.value <= 1) {
212
+ const targetScrollTop2 = Math.max(0, (rowOffsets.value[index] || 0) - offset);
213
+ scrollTop.value = targetScrollTop2;
214
+ if (containerRef.value) {
215
+ containerRef.value.scrollTo({
216
+ top: targetScrollTop2,
217
+ behavior
218
+ });
219
+ }
220
+ return;
221
+ }
152
222
  const targetRow = colCount.value <= 1 ? index : Math.floor(index / colCount.value);
153
- const targetScrollTop = targetRow * baseItemHeight.value;
223
+ const targetScrollTop = Math.max(0, targetRow * baseItemHeight.value - offset);
154
224
  scrollTop.value = targetScrollTop;
155
225
  if (containerRef.value) {
156
226
  containerRef.value.scrollTo({
@@ -5,10 +5,13 @@ type __VLS_Props = {
5
5
  label?: string;
6
6
  validation?: 'success' | 'warning' | 'error' | null;
7
7
  validationText?: string;
8
+ idKey?: string;
8
9
  };
9
10
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
11
+ blur: (event: FocusEvent) => any;
10
12
  "update:model": (value: any) => any;
11
13
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
14
+ onBlur?: ((event: FocusEvent) => any) | undefined;
12
15
  "onUpdate:model"?: ((value: any) => any) | undefined;
13
16
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
14
17
  declare const _default: typeof __VLS_export;
@@ -6,6 +6,7 @@
6
6
  :aria-disabled="isDisabled"
7
7
  tabindex="0"
8
8
  @keydown.space.prevent="handleSpaceKey"
9
+ @blur="emit('blur', $event)"
9
10
  )
10
11
  input(type="checkbox" :checked="isChecked" :disabled="isDisabled" tabindex="-1" @change="toggleCheckbox")
11
12
  .icon-container(:class="validation ? `is-${validation}` : ''")
@@ -28,10 +29,12 @@ const props = defineProps<{
28
29
  label?: string
29
30
  validation?: 'success' | 'warning' | 'error' | null
30
31
  validationText?: string
32
+ idKey?: string
31
33
  }>()
32
34
 
33
35
  const emit = defineEmits<{
34
36
  (e: 'update:model', value: any): void
37
+ (e: 'blur', event: FocusEvent): void
35
38
  }>()
36
39
 
37
40
  const internalModel = computed({
@@ -41,6 +44,10 @@ const internalModel = computed({
41
44
 
42
45
  const getId = (item: any) => {
43
46
  if (item && typeof item === 'object') {
47
+ const key = props.idKey
48
+ if (key && item[key] !== undefined && item[key] !== null) {
49
+ return item[key]
50
+ }
44
51
  return item.id ?? item._id ?? item
45
52
  }
46
53
  return item
@@ -5,10 +5,13 @@ type __VLS_Props = {
5
5
  label?: string;
6
6
  validation?: 'success' | 'warning' | 'error' | null;
7
7
  validationText?: string;
8
+ idKey?: string;
8
9
  };
9
10
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
11
+ blur: (event: FocusEvent) => any;
10
12
  "update:model": (value: any) => any;
11
13
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
14
+ onBlur?: ((event: FocusEvent) => any) | undefined;
12
15
  "onUpdate:model"?: ((value: any) => any) | undefined;
13
16
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
14
17
  declare const _default: typeof __VLS_export;
@@ -32,9 +32,11 @@ type __VLS_Props = {
32
32
  maxHeight?: number;
33
33
  };
34
34
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
35
+ blur: (event: FocusEvent) => any;
35
36
  "update:isOptionsOpen": (value: boolean) => any;
36
37
  "update:searchtext": (value: string) => any;
37
38
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
39
+ onBlur?: ((event: FocusEvent) => any) | undefined;
38
40
  "onUpdate:isOptionsOpen"?: ((value: boolean) => any) | undefined;
39
41
  "onUpdate:searchtext"?: ((value: string) => any) | undefined;
40
42
  }>, {