@katlux/preset-modern 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.
@@ -113,6 +113,7 @@
113
113
  --table-row-hover: var(--neutral-100);
114
114
  --table-row-selected: #eff6ff;
115
115
  --table-row-selected-text: var(--primary-900);
116
+ --k-datatable-row-height: 50px;
116
117
  --panel-bg-opacity: 0.5;
117
118
  --panel-blur: 16px;
118
119
  --panel-bg-default: var(--neutral-100);
@@ -131,4 +132,7 @@
131
132
  --layout-sidebar-width: 240px;
132
133
  --layout-sidebar-bg: var(--neutral-50);
133
134
  --layout-content-bg: #ffffff;
135
+ --calendar-range-bg: var(--primary-100);
136
+ --calendar-range-color: var(--primary-700);
137
+ --calendar-range-hover-bg: var(--primary-300);
134
138
  }
@@ -113,6 +113,7 @@
113
113
  --table-row-hover: var(--neutral-100);
114
114
  --table-row-selected: #eff6ff;
115
115
  --table-row-selected-text: var(--primary-900);
116
+ --k-datatable-row-height: 50px;
116
117
  --panel-bg-opacity: 0.5;
117
118
  --panel-blur: 16px;
118
119
  --panel-bg-default: var(--neutral-100);
@@ -131,6 +132,9 @@
131
132
  --layout-sidebar-width: 240px;
132
133
  --layout-sidebar-bg: var(--neutral-50);
133
134
  --layout-content-bg: #ffffff;
135
+ --calendar-range-bg: var(--primary-100);
136
+ --calendar-range-color: var(--primary-700);
137
+ --calendar-range-hover-bg: var(--primary-300);
134
138
  }
135
139
 
136
140
  .k-input-label {
@@ -10,10 +10,12 @@ type __VLS_Props = {
10
10
  indeterminate?: boolean;
11
11
  };
12
12
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
13
+ blur: (event: FocusEvent) => any;
13
14
  "update:model": (value: any) => any;
14
15
  "update:modelValue": (value: any) => any;
15
16
  "update:indeterminate": (value: boolean) => any;
16
17
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
18
+ onBlur?: ((event: FocusEvent) => any) | undefined;
17
19
  "onUpdate:model"?: ((value: any) => any) | undefined;
18
20
  "onUpdate:modelValue"?: ((value: any) => any) | undefined;
19
21
  "onUpdate:indeterminate"?: ((value: boolean) => any) | undefined;
@@ -6,8 +6,9 @@
6
6
  :aria-disabled="isDisabled"
7
7
  tabindex="0"
8
8
  @keydown.space.prevent="handleSpace"
9
+ @blur="emit('blur', $event)"
9
10
  )
10
- input(ref="inputRef" type="checkbox" :checked="isChecked" :indeterminate.prop="props.indeterminate" :value="checkboxValue" :disabled="isDisabled" tabindex="-1" @change="handleSpace")
11
+ input(ref="inputRef" type="checkbox" :checked="isChecked" :indeterminate.prop="props.indeterminate" :value="checkboxValue" :disabled="isDisabled" tabindex="-1" @change="handleSpace" @blur="emit('blur', $event)")
11
12
  .checkbox-box(:class="[validation ? `is-${validation}` : '', { 'is-indeterminate': props.indeterminate }]")
12
13
  .checkbox-checkmark
13
14
  KIcon.icon(:iconname="props.indeterminate ? 'minus' : 'check'")
@@ -31,7 +32,7 @@ const props = defineProps({
31
32
  idKey: { type: String, required: false },
32
33
  indeterminate: { type: Boolean, required: false }
33
34
  });
34
- const emit = defineEmits(["update:model", "update:modelValue", "update:indeterminate"]);
35
+ const emit = defineEmits(["update:model", "update:modelValue", "update:indeterminate", "blur"]);
35
36
  const formattedModel = computed({
36
37
  get: () => props.modelValue !== void 0 ? props.modelValue : props.model,
37
38
  set: (value) => {
@@ -10,10 +10,12 @@ type __VLS_Props = {
10
10
  indeterminate?: boolean;
11
11
  };
12
12
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
13
+ blur: (event: FocusEvent) => any;
13
14
  "update:model": (value: any) => any;
14
15
  "update:modelValue": (value: any) => any;
15
16
  "update:indeterminate": (value: boolean) => any;
16
17
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
18
+ onBlur?: ((event: FocusEvent) => any) | undefined;
17
19
  "onUpdate:model"?: ((value: any) => any) | undefined;
18
20
  "onUpdate:modelValue"?: ((value: any) => any) | undefined;
19
21
  "onUpdate:indeterminate"?: ((value: boolean) => any) | undefined;
@@ -18,9 +18,10 @@ type __VLS_Props = {
18
18
  emptyStateText?: string;
19
19
  emptyFilterStateText?: string;
20
20
  virtualScroll?: boolean;
21
- itemHeight?: number;
21
+ itemHeight?: number | ((row: any, index: number) => number);
22
22
  viewportHeight?: number;
23
23
  buffer?: number;
24
+ urlPageParam?: string;
24
25
  };
25
26
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
26
27
  "update:selectedRows": (value: any[]) => any;
@@ -41,6 +42,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
41
42
  bulkActions: Array<IKDatatableAction>;
42
43
  selectedRows: any[];
43
44
  selectAll: boolean;
45
+ viewportHeight: number;
44
46
  visibleFields: Array<string> | null;
45
47
  rowActions: Array<IKDatatableAction>;
46
48
  selectAllScope: "page" | "dataset";
@@ -52,8 +54,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
52
54
  emptyStateText: string;
53
55
  emptyFilterStateText: string;
54
56
  virtualScroll: boolean;
55
- itemHeight: number;
56
- viewportHeight: number;
57
+ itemHeight: number | ((row: any, index: number) => number);
58
+ urlPageParam: string;
57
59
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
58
60
  declare const _default: typeof __VLS_export;
59
61
  export default _default;
@@ -1,13 +1,13 @@
1
1
  <template lang="pug">
2
2
  .k-datatable.modern-datatable(
3
3
  :class="{ 'is-virtual-scroll': props.virtualScroll }"
4
- :style="props.virtualScroll ? { ...containerCssVars, '--k-datatable-viewport-height': (props.viewportHeight || 500) + 'px' } : { '--page-size': effectivePageSize }"
4
+ :style="rootStyle"
5
5
  role="region"
6
6
  :aria-label="t('Data Table')"
7
7
  )
8
8
  .header(v-if="props.bulkActions && props.bulkActions.length > 0 && (selectedRows.length > 0 || selectAll)")
9
- .selected-count {{ selectAll ? (unselectedRows && unselectedRows.length > 0 ? (props.dataProvider.filter?.active ? t('All filtered items selected ({count} excluded)').replace('{count}', unselectedRows.length.toString()) : t('All items selected ({count} excluded)').replace('{count}', unselectedRows.length.toString())) : (props.dataProvider.filter?.active ? t('All filtered items selected') : t('All items selected'))) : t('{count} items selected').replace('{count}', (selectedRows?.length || 0).toString()) }}
10
- KBulkActions.bulk-actions(:bulkActions="props.bulkActions" :selectedRows="selectedRows" :selectAll="selectAll" :unselectedRows="unselectedRows" :filter="props.dataProvider.filter")
9
+ .selected-count {{ selectedInfoText }}
10
+ KBulkActions.bulk-actions(:bulkActions="props.bulkActions" :selectedRows="selectedRows" :selectAll="selectAll" :unselectedRows="unselectedRows" :totalCount="dpRowCount" :filter="dpFilter")
11
11
 
12
12
  .k-datatable-wrapper(
13
13
  ref="containerRef"
@@ -27,7 +27,7 @@
27
27
  :indeterminate="isIndeterminate"
28
28
  @update:model-value="handleSelectAll"
29
29
  )
30
- th(v-for="field in visibleFields || props.dataProvider.fields" :key="field" :data-field="field" :style="getColumnStyle(field)")
30
+ th(v-for="field in visibleFields || dpFields" :key="field" :data-field="field" :style="getColumnStyle(field)")
31
31
  component(v-if="getHeaderSlot(field)" :is="getHeaderSlot(field)" :field="field")
32
32
  span(v-else) {{ columnHeaders?.[field] ?? field }}
33
33
  th.actions-cell(v-if="props.rowActions && props.rowActions.length > 0") {{ t('Actions') }}
@@ -35,7 +35,7 @@
35
35
  tbody
36
36
  tr.empty-row(v-if="!isLoading && (!datatableItems || datatableItems.length === 0)")
37
37
  td.empty-state(:colspan="totalColspan")
38
- span(v-if="dpFilter?.active || props.dataProvider.filter?.value?.active") {{ props.emptyFilterStateText || t('No result found for filter') }}
38
+ span(v-if="dpFilter?.active") {{ props.emptyFilterStateText || t('No result found for filter') }}
39
39
  span(v-else) {{ props.emptyStateText || t('No result') }}
40
40
  tr.k-virtual-spacer.is-top(
41
41
  v-if="props.virtualScroll && topSpacerHeight > 0"
@@ -50,8 +50,9 @@
50
50
  )
51
51
  td.check-cell(v-if="props.bulkActions && props.bulkActions.length > 0")
52
52
  KCheckbox(:model-value="isRowSelected(row)" @update:model-value="toggleRow(row)" :idKey="rowIdKey")
53
- td(v-for="visibleField in visibleFields || props.dataProvider.fields" :key="visibleField" :data-field="visibleField" :style="getColumnStyle(visibleField)")
54
- component(v-if="getCellSlot(visibleField)" :is="getCellSlot(visibleField)" :row="row" :field="visibleField" :value="row[visibleField]")
53
+ td(v-for="visibleField in visibleFields || dpFields" :key="visibleField" :data-field="visibleField" :style="getColumnStyle(visibleField)")
54
+ span.cell-skeleton(v-if="row?.__encrypted || isCellEncrypted(row?.[visibleField])" aria-hidden="true")
55
+ component(v-else-if="getCellSlot(visibleField)" :is="getCellSlot(visibleField)" :row="row" :field="visibleField" :value="row[visibleField]")
55
56
  span(v-else) {{ row[visibleField] }}
56
57
  td.actions-cell(v-if="props.rowActions && props.rowActions.length > 0")
57
58
  .action-buttons
@@ -78,15 +79,14 @@
78
79
  td(:colspan="totalColspan")
79
80
 
80
81
  .footer(v-if="!props.virtualScroll")
81
- KPagination.pagination(:dataProvider="props.dataProvider")
82
+ KPagination.pagination(:dataProvider="props.dataProvider" :urlPageParam="props.urlPageParam" @update:currentPage="emit('update:currentPage', $event)" @update:pageSize="emit('update:pageSize', $event)")
82
83
  </template>
83
84
 
84
85
  <script setup>
85
- import { ref, computed, isRef, watch, shallowRef } from "vue";
86
+ import { ref, computed } from "vue";
86
87
  import { ADataProvider } from "@katlux/providers";
87
88
  import { useKatluxI18n } from "#toolkit/composables/useKatluxI18n";
88
- import { useDataProvider } from "#toolkit/composables/useDataProvider";
89
- import { useVirtualScroll } from "#toolkit/composables/useVirtualScroll";
89
+ import { useVirtualDataset } from "#toolkit/composables/useVirtualDataset";
90
90
  const { t } = useKatluxI18n();
91
91
  const props = defineProps({
92
92
  dataProvider: { type: Object, required: true },
@@ -106,9 +106,10 @@ const props = defineProps({
106
106
  emptyStateText: { type: String, required: false, default: "" },
107
107
  emptyFilterStateText: { type: String, required: false, default: "" },
108
108
  virtualScroll: { type: Boolean, required: false, default: false },
109
- itemHeight: { type: Number, required: false, default: 50 },
109
+ itemHeight: { type: [Number, Function], required: false, default: 50 },
110
110
  viewportHeight: { type: Number, required: false, default: 500 },
111
- buffer: { type: Number, required: false, default: 5 }
111
+ buffer: { type: Number, required: false, default: 5 },
112
+ urlPageParam: { type: String, required: false, default: void 0 }
112
113
  });
113
114
  const emit = defineEmits(["update:selectedRows", "update:selectAll", "update:unselectedRows", "update:selectAllScope", "update:currentPage", "update:pageSize"]);
114
115
  const selectedRows = computed({
@@ -123,189 +124,17 @@ const unselectedRows = computed({
123
124
  get: () => props.unselectedRows || [],
124
125
  set: (val) => emit("update:unselectedRows", val)
125
126
  });
126
- const effectiveSelectAllScope = computed(() => {
127
- if (props.virtualScroll) {
128
- if (props.selectAllScope === "page") {
129
- console.warn('[KDatatable] virtualScroll is enabled with selectAllScope="page". Overriding selectAllScope to "dataset" because page-scoped selection is incompatible with virtual scrolling.');
130
- }
131
- return "dataset";
132
- }
133
- return props.selectAllScope || "page";
134
- });
135
- const effectivePageSize = computed(() => {
136
- const ps = props.pageSize ?? props.dataProvider?.pageSize;
137
- return isRef(ps) ? ps.value : ps?.value ?? ps ?? 10;
138
- });
139
- const getRowKey = (row, index) => {
140
- const idKey = props.dataProvider?.idKey || "id";
141
- if (row && row[idKey] !== void 0 && row[idKey] !== null) {
142
- return row[idKey];
143
- }
144
- if (row && row.id !== void 0 && row.id !== null) {
145
- return row.id;
146
- }
147
- if (row && row._id !== void 0 && row._id !== null) {
148
- return row._id;
149
- }
150
- return props.virtualScroll ? startIndex.value + index : index;
151
- };
152
- const selectedRowIds = computed(() => {
153
- const idKey = props.dataProvider?.idKey || "id";
154
- const set = /* @__PURE__ */ new Set();
155
- for (const r of selectedRows.value || []) {
156
- const id = r?.[idKey] ?? r?.id ?? r?._id ?? r;
157
- set.add(id);
158
- set.add(r);
159
- }
160
- return set;
161
- });
162
- const unselectedRowIds = computed(() => {
163
- const idKey = props.dataProvider?.idKey || "id";
164
- const set = /* @__PURE__ */ new Set();
165
- for (const r of unselectedRows.value || []) {
166
- const id = r?.[idKey] ?? r?.id ?? r?._id ?? r;
167
- set.add(id);
168
- set.add(r);
169
- }
170
- return set;
171
- });
172
- const rowIdKey = computed(() => props.dataProvider?.idKey || "id");
173
- const pageSelectedCount = computed(() => {
174
- if (!datatableItems.value || datatableItems.value.length === 0) return 0;
175
- let count = 0;
176
- const ids = selectedRowIds.value;
177
- const idKey = props.dataProvider?.idKey || "id";
178
- for (const r of datatableItems.value) {
179
- const id = r?.[idKey] ?? r?.id ?? r?._id ?? r;
180
- if (ids.has(id) || ids.has(r)) count++;
181
- }
182
- return count;
183
- });
184
- const isAllSelected = computed(() => {
185
- const total = datatableItems.value.length;
186
- if (total === 0) return false;
187
- if (effectiveSelectAllScope.value === "dataset") {
188
- return selectAll.value === true && unselectedRows.value.length === 0;
189
- }
190
- return pageSelectedCount.value === total;
191
- });
192
- const isIndeterminate = computed(() => {
193
- const total = datatableItems.value.length;
194
- if (total === 0) return false;
195
- if (effectiveSelectAllScope.value === "dataset") {
196
- if (selectAll.value === true) {
197
- return unselectedRows.value.length > 0;
198
- }
199
- return selectedRows.value && selectedRows.value.length > 0;
200
- }
201
- return pageSelectedCount.value > 0 && pageSelectedCount.value < total;
202
- });
203
- const handleSelectAll = () => {
204
- const total = datatableItems.value.length;
205
- if (total === 0) return;
206
- if (effectiveSelectAllScope.value === "dataset") {
207
- if (isAllSelected.value) {
208
- selectAll.value = false;
209
- unselectedRows.value = [];
210
- selectedRows.value = [];
211
- } else {
212
- selectAll.value = true;
213
- unselectedRows.value = [];
214
- selectedRows.value = [];
215
- }
216
- return;
217
- }
218
- const idKey = props.dataProvider?.idKey || "id";
219
- if (isAllSelected.value) {
220
- const pageIdSet = new Set(datatableItems.value.map((r) => r?.[idKey] ?? r?.id ?? r?._id ?? r));
221
- selectedRows.value = (selectedRows.value || []).filter((r) => {
222
- const id = r?.[idKey] ?? r?.id ?? r?._id ?? r;
223
- return !pageIdSet.has(id) && !pageIdSet.has(r);
224
- });
225
- unselectedRows.value = [];
226
- selectAll.value = false;
227
- } else {
228
- const existingIds = selectedRowIds.value;
229
- const toAdd = datatableItems.value.filter((r) => {
230
- const id = r?.[idKey] ?? r?.id ?? r?._id ?? r;
231
- return !existingIds.has(id) && !existingIds.has(r);
232
- });
233
- selectedRows.value = [...selectedRows.value || [], ...toAdd];
234
- unselectedRows.value = [];
235
- selectAll.value = false;
236
- }
237
- };
238
- const isRowSelected = (row) => {
239
- const idKey = props.dataProvider?.idKey || "id";
240
- const rowId = row?.[idKey] ?? row?.id ?? row?._id ?? row;
241
- if (effectiveSelectAllScope.value === "dataset" && selectAll.value) {
242
- return !unselectedRowIds.value.has(rowId) && !unselectedRowIds.value.has(row);
243
- }
244
- return selectedRowIds.value.has(rowId) || selectedRowIds.value.has(row);
245
- };
246
- const toggleRow = (row) => {
247
- const idKey = props.dataProvider?.idKey || "id";
248
- const rowId = row?.[idKey] ?? row?.id ?? row?._id ?? row;
249
- if (effectiveSelectAllScope.value === "dataset" && selectAll.value) {
250
- const isCurrentlyExcluded = unselectedRowIds.value.has(rowId) || unselectedRowIds.value.has(row);
251
- if (isCurrentlyExcluded) {
252
- unselectedRows.value = (unselectedRows.value || []).filter((r) => {
253
- const rId = r?.[idKey] ?? r?.id ?? r?._id ?? r;
254
- return rId !== rowId && r !== row;
255
- });
256
- } else {
257
- unselectedRows.value = [...unselectedRows.value || [], row];
258
- }
259
- return;
260
- }
261
- const isSelected = isRowSelected(row);
262
- if (isSelected) {
263
- const next = (selectedRows.value || []).filter((r) => {
264
- const rId = r?.[idKey] ?? r?.id ?? r?._id ?? r;
265
- return rId !== rowId && r !== row;
266
- });
267
- selectedRows.value = next;
268
- } else {
269
- selectedRows.value = [...selectedRows.value || [], row];
270
- }
271
- };
272
- const getCellSlot = (fieldName) => {
273
- const slotName = "cell-" + fieldName;
274
- return props.cellSlots?.[slotName];
275
- };
276
- const getHeaderSlot = (fieldName) => {
277
- const slotName = "header-" + fieldName;
278
- return props.headerSlots?.[slotName] || props.cellSlots?.[slotName];
279
- };
280
- const getColumnStyle = (field) => {
281
- const w = props.columnWidths?.[field];
282
- if (!w) return void 0;
283
- return { width: w, whiteSpace: "nowrap" };
284
- };
285
- const { pageData, virtualRows, filter: dpFilter, loading: dpLoading, initialLoad: dpInitialLoad, pageSize: dpPageSize } = useDataProvider(props.dataProvider);
286
- const pageRows = computed(() => pageData.value || []);
287
- const isLoading = computed(() => {
288
- return dpLoading.value || dpInitialLoad.value || false;
127
+ const selectAllScope = computed({
128
+ get: () => props.selectAllScope,
129
+ set: (val) => emit("update:selectAllScope", val)
289
130
  });
290
- const datatableItems = computed(() => {
291
- const currentRows = pageRows.value;
292
- const dp = props.dataProvider;
293
- if (props.virtualScroll) {
294
- if (Array.isArray(virtualRows?.value) && virtualRows.value.length > 0) return virtualRows.value;
295
- if (Array.isArray(dp?.rowMap)) return dp.rowMap;
296
- if (Array.isArray(dp?.rowMap?.value)) return dp.rowMap.value;
297
- if (Array.isArray(dp?.allVisibleRows)) return dp.allVisibleRows;
298
- if (Array.isArray(dp?.allVisibleRows?.value)) return dp.allVisibleRows.value;
299
- if (Array.isArray(dp?.allVisibleNodes)) return dp.allVisibleNodes;
300
- if (Array.isArray(dp?.allVisibleNodes?.value)) return dp.allVisibleNodes.value;
301
- if (Array.isArray(dp?.allData?.value)) return dp.allData.value;
302
- if (Array.isArray(dp?.allData)) return dp.allData;
303
- if (Array.isArray(dp?.data)) return dp.data;
304
- }
305
- return currentRows;
131
+ const pageSize = computed({
132
+ get: () => props.pageSize,
133
+ set: (val) => emit("update:pageSize", val)
306
134
  });
307
135
  const {
308
- visibleItems,
136
+ datatableItems,
137
+ displayRows,
309
138
  startIndex,
310
139
  endIndex,
311
140
  topSpacerHeight,
@@ -314,178 +143,89 @@ const {
314
143
  onScroll,
315
144
  scrollToIndex,
316
145
  containerCssVars,
317
- scrollTop
318
- } = useVirtualScroll({
319
- items: datatableItems,
146
+ scrollTop,
147
+ rowIdKey,
148
+ getRowKey,
149
+ isRowSelected,
150
+ isAllSelected,
151
+ isIndeterminate,
152
+ pageSelectedCount,
153
+ handleSelectAll,
154
+ toggleRow,
155
+ effectiveSelectAllScope,
156
+ focusedIndex,
157
+ handleKeyDown,
158
+ effectivePageSize,
159
+ isLoading,
160
+ pageRows,
161
+ dpRowCount,
162
+ dpFilter,
163
+ dpSortList,
164
+ dpFields,
165
+ activeFilter,
166
+ isCellEncrypted
167
+ } = useVirtualDataset({
168
+ dataProvider: () => props.dataProvider,
169
+ virtualScroll: computed(() => props.virtualScroll),
320
170
  itemHeight: computed(() => props.itemHeight || 50),
321
- containerHeight: computed(() => props.viewportHeight || 500),
171
+ viewportHeight: computed(() => props.viewportHeight || 500),
322
172
  buffer: computed(() => props.buffer ?? 5),
323
- virtualScroll: computed(() => !!props.virtualScroll),
324
- onThresholdReach: () => {
325
- const dp = props.dataProvider;
326
- if (typeof dp?.loadMore === "function") {
327
- dp.loadMore();
328
- } else if (typeof dp?.nextPage === "function" && dp.hasMore) {
329
- dp.nextPage();
330
- }
331
- }
173
+ pageSize,
174
+ selectedRows,
175
+ selectAll,
176
+ unselectedRows,
177
+ selectAllScope
332
178
  });
333
- const deliveredRowsCache = shallowRef(/* @__PURE__ */ new Map());
334
- const requestedPages = /* @__PURE__ */ new Set();
335
- watch(pageRows, (rows) => {
336
- if (Array.isArray(rows) && rows.length > 0) {
337
- const idKey = rowIdKey.value;
338
- const nextCache = new Map(deliveredRowsCache.value);
339
- for (const r of rows) {
340
- const id = r?.[idKey] ?? r?.id;
341
- if (id !== void 0 && id !== null) {
342
- nextCache.set(id, r);
179
+ const selectedInfoText = computed(() => {
180
+ const excluded = unselectedRows.value?.length || 0;
181
+ if (selectAll.value) {
182
+ if (dpRowCount?.value !== void 0) {
183
+ const count = Math.max(0, dpRowCount.value - excluded);
184
+ if (excluded > 0) {
185
+ return t("{count} items selected ({excluded} excluded)", { count, excluded });
343
186
  }
187
+ return t("{count} items selected", { count });
344
188
  }
345
- deliveredRowsCache.value = nextCache;
346
- }
347
- }, { immediate: true, deep: true });
348
- watch([dpFilter, () => props.dataProvider?.sortList], () => {
349
- deliveredRowsCache.value = /* @__PURE__ */ new Map();
350
- requestedPages.clear();
351
- const curPage = props.dataProvider?.currentPage || 1;
352
- requestedPages.add(curPage);
353
- }, { deep: true });
354
- let isFetchingPage = false;
355
- const pageQueue = [];
356
- const processPageQueue = async () => {
357
- if (isFetchingPage || pageQueue.length === 0) return;
358
- const nextPage = pageQueue.shift();
359
- const dp = props.dataProvider;
360
- if (dp && typeof dp.setCurrentPage === "function") {
361
- isFetchingPage = true;
362
- try {
363
- dp.setCurrentPage(nextPage);
364
- if (typeof dp.loadPageData === "function") {
365
- const res = dp.loadPageData();
366
- if (res instanceof Promise) await res;
367
- }
368
- } finally {
369
- isFetchingPage = false;
370
- if (pageQueue.length > 0) {
371
- processPageQueue();
372
- }
189
+ if (excluded > 0) {
190
+ return t("All items selected ({count} excluded)", { count: excluded });
373
191
  }
192
+ return t("All items selected");
374
193
  }
194
+ return t("{count} items selected", { count: selectedRows.value?.length || 0 });
195
+ });
196
+ const getCellSlot = (fieldName) => {
197
+ const slotName = "cell-" + fieldName;
198
+ return props.cellSlots?.[slotName];
375
199
  };
376
- const queuePage = (page) => {
377
- if (!requestedPages.has(page)) {
378
- requestedPages.add(page);
379
- pageQueue.push(page);
380
- processPageQueue();
381
- }
200
+ const getHeaderSlot = (fieldName) => {
201
+ const slotName = "header-" + fieldName;
202
+ return props.headerSlots?.[slotName] || props.cellSlots?.[slotName];
382
203
  };
383
- const ensureVisiblePagesLoaded = () => {
384
- if (!props.virtualScroll) return;
385
- const ps = dpPageSize?.value ?? props.pageSize ?? props.dataProvider?.pageSize ?? 10;
386
- if (!ps || ps <= 0) return;
387
- const start = startIndex.value;
388
- const end = endIndex.value;
389
- const startPage = Math.floor(start / ps) + 1;
390
- const endPage = Math.floor(Math.max(0, end - 1) / ps) + 1;
391
- for (let p = startPage; p <= endPage; p++) {
392
- queuePage(p);
393
- }
204
+ const getColumnStyle = (field) => {
205
+ const w = props.columnWidths?.[field];
206
+ if (!w) return void 0;
207
+ return { width: w, whiteSpace: "nowrap" };
394
208
  };
395
- watch([startIndex, endIndex], () => {
396
- ensureVisiblePagesLoaded();
397
- }, { immediate: true });
398
- const displayRows = computed(() => {
209
+ const rootStyle = computed(() => {
210
+ const rowHeight = `${props.itemHeight || 50}px`;
399
211
  if (props.virtualScroll) {
400
- const items = visibleItems.value;
401
- const cache = deliveredRowsCache.value;
402
- if (cache.size > 0) {
403
- const idKey = rowIdKey.value;
404
- return items.map((item) => {
405
- const id = item?.[idKey] ?? item?.id;
406
- if (id !== void 0 && id !== null && cache.has(id)) {
407
- return cache.get(id);
408
- }
409
- return item;
410
- });
411
- }
412
- return items;
212
+ return {
213
+ ...containerCssVars.value,
214
+ "--k-datatable-viewport-height": `${props.viewportHeight || 500}px`,
215
+ "--k-datatable-row-height": rowHeight
216
+ };
413
217
  }
414
- return pageRows.value;
218
+ return {
219
+ "--page-size": String(effectivePageSize.value),
220
+ "--k-datatable-row-height": rowHeight
221
+ };
415
222
  });
416
223
  const totalColspan = computed(() => {
417
- const fieldsCount = (props.visibleFields || props.dataProvider?.fields || []).length;
224
+ const fieldsCount = (props.visibleFields || dpFields.value || []).length;
418
225
  const checkCount = props.bulkActions && props.bulkActions.length > 0 ? 1 : 0;
419
226
  const actionCount = props.rowActions && props.rowActions.length > 0 ? 1 : 0;
420
227
  return fieldsCount + checkCount + actionCount;
421
228
  });
422
- const focusedIndex = ref(-1);
423
- const theadStickyOffset = 40;
424
- const handleKeyDown = (e) => {
425
- if (!props.virtualScroll) return;
426
- const total = datatableItems.value.length;
427
- if (total === 0) return;
428
- const itemH = props.itemHeight || 50;
429
- const vpH = props.viewportHeight || 500;
430
- const firstInView = Math.floor(scrollTop.value / itemH);
431
- const lastInView = Math.min(total - 1, Math.floor((scrollTop.value + vpH) / itemH) - 1);
432
- const ensureVisible = (index) => {
433
- const rowTop = index * itemH;
434
- const rowBottom = rowTop + itemH;
435
- if (rowTop < scrollTop.value) {
436
- scrollToIndex(index, "auto", index > 0 ? theadStickyOffset : 0);
437
- } else if (rowBottom > scrollTop.value + vpH) {
438
- const targetScroll = Math.max(0, rowBottom - vpH);
439
- scrollTop.value = targetScroll;
440
- if (containerRef.value) {
441
- containerRef.value.scrollTop = targetScroll;
442
- }
443
- }
444
- };
445
- if (e.key === "ArrowDown") {
446
- e.preventDefault();
447
- if (focusedIndex.value < firstInView || focusedIndex.value > lastInView) {
448
- focusedIndex.value = Math.min(total - 1, firstInView);
449
- } else {
450
- focusedIndex.value = Math.min(total - 1, focusedIndex.value + 1);
451
- }
452
- ensureVisible(focusedIndex.value);
453
- } else if (e.key === "ArrowUp") {
454
- e.preventDefault();
455
- if (focusedIndex.value < firstInView || focusedIndex.value > lastInView) {
456
- focusedIndex.value = Math.max(0, lastInView);
457
- } else {
458
- focusedIndex.value = Math.max(0, focusedIndex.value - 1);
459
- }
460
- ensureVisible(focusedIndex.value);
461
- } else if (e.key === "PageDown") {
462
- e.preventDefault();
463
- const step = Math.max(1, Math.floor(vpH / itemH));
464
- if (focusedIndex.value < firstInView || focusedIndex.value > lastInView) {
465
- focusedIndex.value = Math.min(total - 1, firstInView + step);
466
- } else {
467
- focusedIndex.value = Math.min(total - 1, focusedIndex.value + step);
468
- }
469
- ensureVisible(focusedIndex.value);
470
- } else if (e.key === "PageUp") {
471
- e.preventDefault();
472
- const step = Math.max(1, Math.floor(vpH / itemH));
473
- if (focusedIndex.value < firstInView || focusedIndex.value > lastInView) {
474
- focusedIndex.value = Math.max(0, lastInView - step);
475
- } else {
476
- focusedIndex.value = Math.max(0, focusedIndex.value - step);
477
- }
478
- ensureVisible(focusedIndex.value);
479
- } else if (e.key === "Home") {
480
- e.preventDefault();
481
- focusedIndex.value = 0;
482
- scrollToIndex(0);
483
- } else if (e.key === "End") {
484
- e.preventDefault();
485
- focusedIndex.value = total - 1;
486
- scrollToIndex(total - 1, "auto", theadStickyOffset);
487
- }
488
- };
489
229
  </script>
490
230
 
491
231
  <style scoped>
@@ -560,46 +300,72 @@ const handleKeyDown = (e) => {
560
300
  white-space: nowrap;
561
301
  text-align: right;
562
302
  }
563
- .modern-datatable table tbody tr {
303
+ .modern-datatable table tbody tr:not(.k-virtual-spacer):not(.empty-row) {
304
+ height: var(--k-datatable-row-height, 50px);
305
+ max-height: var(--k-datatable-row-height, 50px);
306
+ box-sizing: border-box;
564
307
  transition: background-color var(--transition-fast);
565
308
  }
566
- .modern-datatable table tbody tr:hover {
309
+ .modern-datatable table tbody tr:not(.k-virtual-spacer):not(.empty-row):hover {
567
310
  background-color: var(--table-row-hover-bg);
568
311
  }
569
- .modern-datatable table tbody tr.selected {
312
+ .modern-datatable table tbody tr:not(.k-virtual-spacer):not(.empty-row).selected {
570
313
  background-color: var(--table-row-selected-bg, rgba(var(--color-primary-rgb, 59, 130, 246), 0.08));
571
314
  }
572
- .modern-datatable table tbody tr.active-focus {
315
+ .modern-datatable table tbody tr:not(.k-virtual-spacer):not(.empty-row).active-focus {
573
316
  outline: 2px solid var(--color-primary, #3b82f6);
574
317
  outline-offset: -2px;
575
318
  }
576
- .modern-datatable table tbody tr td {
577
- padding: var(--gap-md);
319
+ .modern-datatable table tbody tr:not(.k-virtual-spacer):not(.empty-row) td {
320
+ height: var(--k-datatable-row-height, 50px);
321
+ max-height: var(--k-datatable-row-height, 50px);
322
+ box-sizing: border-box;
323
+ padding: 0 var(--gap-md);
578
324
  border-bottom: 1px solid var(--table-border-color);
579
325
  color: var(--table-row-text-color);
580
326
  font-size: var(--font-size-md);
581
327
  white-space: nowrap;
328
+ vertical-align: middle;
329
+ }
330
+ .modern-datatable table tbody tr:not(.k-virtual-spacer):not(.empty-row) td .cell-skeleton {
331
+ display: inline-block;
332
+ width: 65%;
333
+ min-width: 48px;
334
+ height: 1em;
335
+ border-radius: var(--border-radius-sm, 4px);
336
+ background: linear-gradient(90deg, var(--color-bg-subtle, rgba(0, 0, 0, 0.06)) 25%, var(--color-bg-muted, rgba(0, 0, 0, 0.12)) 50%, var(--color-bg-subtle, rgba(0, 0, 0, 0.06)) 75%);
337
+ background-size: 200% 100%;
338
+ animation: k-skeleton-pulse 1.5s ease-in-out infinite;
339
+ vertical-align: middle;
582
340
  }
583
- .modern-datatable table tbody tr td.check-cell {
341
+ .modern-datatable table tbody tr:not(.k-virtual-spacer):not(.empty-row) td.check-cell {
584
342
  text-align: center;
585
343
  }
586
- .modern-datatable table tbody tr td.actions-cell {
344
+ .modern-datatable table tbody tr:not(.k-virtual-spacer):not(.empty-row) td.actions-cell {
587
345
  text-align: right;
588
346
  }
589
- .modern-datatable table tbody tr td.actions-cell .action-buttons {
347
+ .modern-datatable table tbody tr:not(.k-virtual-spacer):not(.empty-row) td.actions-cell .action-buttons {
590
348
  display: inline-flex;
591
349
  gap: var(--gap-xs);
592
350
  justify-content: flex-end;
593
351
  }
594
- .modern-datatable table tbody tr td.empty-state {
352
+ .modern-datatable table tbody tr:not(.k-virtual-spacer):not(.empty-row) td.empty-state {
353
+ height: auto;
354
+ max-height: none;
595
355
  text-align: center;
596
356
  padding: var(--gap-xl);
597
357
  color: var(--font-color-secondary);
598
358
  white-space: normal;
599
359
  }
600
- .modern-datatable table tbody tr:last-child td {
360
+ .modern-datatable table tbody tr:not(.k-virtual-spacer):not(.empty-row):last-child td {
601
361
  border-bottom: none;
602
362
  }
363
+ .modern-datatable table tbody tr.empty-row td.empty-state {
364
+ text-align: center;
365
+ padding: var(--gap-xl);
366
+ color: var(--font-color-secondary);
367
+ white-space: normal;
368
+ }
603
369
  .modern-datatable .footer {
604
370
  display: flex;
605
371
  justify-content: flex-end;
@@ -646,4 +412,12 @@ const handleKeyDown = (e) => {
646
412
  margin: 0;
647
413
  background: transparent !important;
648
414
  }
415
+ @keyframes k-skeleton-pulse {
416
+ 0% {
417
+ background-position: 200% 0;
418
+ }
419
+ 100% {
420
+ background-position: -200% 0;
421
+ }
422
+ }
649
423
  </style>
@@ -18,9 +18,10 @@ type __VLS_Props = {
18
18
  emptyStateText?: string;
19
19
  emptyFilterStateText?: string;
20
20
  virtualScroll?: boolean;
21
- itemHeight?: number;
21
+ itemHeight?: number | ((row: any, index: number) => number);
22
22
  viewportHeight?: number;
23
23
  buffer?: number;
24
+ urlPageParam?: string;
24
25
  };
25
26
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
26
27
  "update:selectedRows": (value: any[]) => any;
@@ -41,6 +42,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
41
42
  bulkActions: Array<IKDatatableAction>;
42
43
  selectedRows: any[];
43
44
  selectAll: boolean;
45
+ viewportHeight: number;
44
46
  visibleFields: Array<string> | null;
45
47
  rowActions: Array<IKDatatableAction>;
46
48
  selectAllScope: "page" | "dataset";
@@ -52,8 +54,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
52
54
  emptyStateText: string;
53
55
  emptyFilterStateText: string;
54
56
  virtualScroll: boolean;
55
- itemHeight: number;
56
- viewportHeight: number;
57
+ itemHeight: number | ((row: any, index: number) => number);
58
+ urlPageParam: string;
57
59
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
58
60
  declare const _default: typeof __VLS_export;
59
61
  export default _default;
@@ -8,11 +8,11 @@ type __VLS_Props = {
8
8
  validationText?: string;
9
9
  };
10
10
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
11
- "update:maskedValue": (value: string) => any;
12
11
  clear: () => any;
12
+ "update:maskedValue": (value: string) => any;
13
13
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
14
- "onUpdate:maskedValue"?: ((value: string) => any) | undefined;
15
14
  onClear?: (() => any) | undefined;
15
+ "onUpdate:maskedValue"?: ((value: string) => any) | undefined;
16
16
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
17
17
  declare const _default: typeof __VLS_export;
18
18
  export default _default;
@@ -8,11 +8,11 @@ type __VLS_Props = {
8
8
  validationText?: string;
9
9
  };
10
10
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
11
- "update:maskedValue": (value: string) => any;
12
11
  clear: () => any;
12
+ "update:maskedValue": (value: string) => any;
13
13
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
14
- "onUpdate:maskedValue"?: ((value: string) => any) | undefined;
15
14
  onClear?: (() => any) | undefined;
15
+ "onUpdate:maskedValue"?: ((value: string) => any) | undefined;
16
16
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
17
17
  declare const _default: typeof __VLS_export;
18
18
  export default _default;
@@ -1,5 +1,5 @@
1
1
  import { defineNuxtPlugin } from "#app";
2
- import { registerPresetComponents } from "#imports";
2
+ import { registerPresetComponents } from "#toolkit/composables/usePresetComponent";
3
3
  export default defineNuxtPlugin(() => {
4
4
  const loaders = {
5
5
  "./components/KBulkActions/KBulkActions.vue": () => import("./components/KBulkActions/KBulkActions.vue"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@katlux/preset-modern",
3
- "version": "0.1.1-alpha.119",
3
+ "version": "0.1.1-alpha.120",
4
4
  "description": "Modern default design preset and styling variables for Katlux components",
5
5
  "author": "Katlux",
6
6
  "license": "Apache-2.0",
@@ -20,12 +20,13 @@
20
20
  "./dist/runtime/assets/*": "./dist/runtime/assets/*"
21
21
  },
22
22
  "sideEffects": [
23
+ "**/*.vue",
23
24
  "**/*.css",
24
25
  "**/*.scss",
25
26
  "**/*.sass"
26
27
  ],
27
28
  "dependencies": {
28
- "@katlux/toolkit": "^0.1.1-alpha.145",
29
+ "@katlux/toolkit": "^0.1.1-alpha.146",
29
30
  "@nuxt/kit": "^3.12.0"
30
31
  },
31
32
  "files": [