sprintify-ui 0.7.11 → 0.8.1

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 (44) hide show
  1. package/dist/sprintify-ui.es.js +10482 -10348
  2. package/dist/style.css +1 -1
  3. package/dist/types/components/BaseDataIterator.vue.d.ts +50 -4
  4. package/dist/types/components/BaseDataIteratorSectionColumns.vue.d.ts +156 -68
  5. package/dist/types/components/BaseDataTable.vue.d.ts +86 -6
  6. package/dist/types/components/BaseDataTableTemplate.vue.d.ts +44 -28
  7. package/dist/types/components/BaseTable.vue.d.ts +30 -7
  8. package/dist/types/components/BaseTableCell.vue.d.ts +19 -1
  9. package/dist/types/components/BaseTableColumn.vue.d.ts +50 -3
  10. package/dist/types/components/BaseTableHead.vue.d.ts +6 -5
  11. package/dist/types/components/BaseTableHeader.vue.d.ts +12 -2
  12. package/dist/types/components/BaseTableRow.vue.d.ts +5 -0
  13. package/dist/types/composables/isFirstColumn.d.ts +4 -0
  14. package/dist/types/composables/isLastColumn.d.ts +4 -0
  15. package/dist/types/composables/paginatedData.d.ts +5 -5
  16. package/dist/types/services/table/types.d.ts +6 -5
  17. package/dist/types/types/index.d.ts +7 -2
  18. package/dist/types/utils/getApiData.d.ts +1 -1
  19. package/package.json +2 -1
  20. package/src/assets/main.css +0 -1
  21. package/src/components/BaseAvatar.vue +1 -0
  22. package/src/components/BaseDataIterator.stories.js +96 -1
  23. package/src/components/BaseDataIterator.vue +135 -11
  24. package/src/components/BaseDataIteratorSectionColumns.vue +2 -2
  25. package/src/components/BaseDataTable.stories.js +140 -50
  26. package/src/components/BaseDataTable.vue +82 -48
  27. package/src/components/BaseDataTableTemplate.vue +208 -372
  28. package/src/components/BaseTable.stories.js +57 -15
  29. package/src/components/BaseTable.vue +71 -9
  30. package/src/components/BaseTableBody.vue +1 -1
  31. package/src/components/BaseTableCell.vue +94 -36
  32. package/src/components/BaseTableColumn.vue +25 -2
  33. package/src/components/BaseTableHead.vue +17 -5
  34. package/src/components/BaseTableHeader.vue +39 -10
  35. package/src/components/BaseTableRow.vue +27 -6
  36. package/src/composables/isFirstColumn.ts +31 -0
  37. package/src/composables/isLastColumn.ts +31 -0
  38. package/src/composables/paginatedData.ts +22 -10
  39. package/src/services/table/classes.ts +13 -9
  40. package/src/services/table/types.ts +6 -5
  41. package/src/stories/List.stories.js +5 -1
  42. package/src/types/index.ts +7 -2
  43. package/src/utils/getApiData.ts +1 -1
  44. package/src/assets/base-table.css +0 -17
@@ -1,7 +1,6 @@
1
1
  <template>
2
2
  <div
3
- class="base-table relative w-full overflow-hidden"
4
- :class="maxHeight ? 'base-table--has-max-height' : ''"
3
+ class="relative w-full overflow-hidden"
5
4
  >
6
5
  <div
7
6
  ref="slot"
@@ -10,282 +9,205 @@
10
9
  <slot />
11
10
  </div>
12
11
 
13
- <div class="flex flex-col">
14
- <div
15
- ref="scrollable"
16
- class="overflow-x-auto overflow-y-auto"
17
- data-scroll-lock-scrollable
18
- :style="{ maxHeight: maxHeight ? maxHeight + 'px' : undefined }"
19
- >
20
- <div class="inline-block min-w-full align-middle">
21
- <div class="relative min-h-[300px]">
22
- <table class="min-w-full border-separate border-spacing-0">
23
- <thead
24
- v-if="newColumns.length"
25
- ref="thead"
12
+ <BaseTable
13
+ ref="baseTableRef"
14
+ class="min-w-full"
15
+ :size="size"
16
+ :fixed-header="(maxHeight && maxHeight > 0) == true"
17
+ :fixed-column="true"
18
+ :max-height="maxHeight"
19
+ :loading="loading"
20
+ >
21
+ <BaseTableHead v-if="newColumns.length">
22
+ <BaseTableRow>
23
+ <BaseTableHeader
24
+ v-for="(column, index) in visibleColumns"
25
+ :key="column.newKey + ':' + index + 'header'"
26
+ v-bind="column.thAttrs && column.thAttrs(column)"
27
+ :style="column.style"
28
+ class="bg-slate-50"
29
+ >
30
+ <div class="flex gap-4">
31
+ <template v-if="index == 0">
32
+ <div
33
+ v-if="showDetailRowIcon"
34
+ class="flex h-5 w-5 shrink-0 grow-0"
35
+ />
36
+
37
+ <div
38
+ v-if="checkable"
39
+ class="flex items-center cursor-pointer"
40
+ @click="checkAll"
41
+ >
42
+ <input
43
+ type="checkbox"
44
+ autocomplete="off"
45
+ :checked="isAllChecked"
46
+ :disabled="isAllUncheckable"
47
+ :class="checkboxStyle"
48
+ >
49
+ </div>
50
+ </template>
51
+
52
+ <button
53
+ type="button"
54
+ class="flex gap-1 w-full items-center bg-transparent text-left text-sm font-medium leading-tight text-slate-900"
55
+ :class="{
56
+ 'cursor-pointer': column.sortable,
57
+ }"
58
+ @click="sort(column, undefined, $event as any)"
26
59
  >
27
- <tr>
28
- <th
29
- v-if="showDetailRowIcon"
30
- class="th"
31
- :style="detailsStyles(true)"
32
- />
33
- <th
34
- v-if="checkable && checkboxPosition === 'left'"
35
- class="th group cursor-pointer py-0 pl-3"
36
- align="left"
37
- :style="checkStyles(true)"
38
- @click="checkAll"
60
+ <span
61
+ class="whitespace-nowrap text-slate-600"
62
+ :class="{
63
+ 'text-[12px]': size == 'sm',
64
+ 'text-xs': size == 'md',
65
+ }"
66
+ >
67
+ {{ column.label }}
68
+ </span>
69
+ <div
70
+ v-if="column.sortable"
71
+ :class="[
72
+ currentSortColumn === column
73
+ ? ''
74
+ : 'opacity-0 duration-200 group-hover:opacity-100',
75
+ ]"
76
+ >
77
+ <svg
78
+ viewBox="0 0 20 20"
79
+ class="h-5 w-5"
39
80
  >
40
- <div class="flex items-center">
41
- <input
42
- type="checkbox"
43
- autocomplete="off"
44
- :checked="isAllChecked"
45
- :disabled="isAllUncheckable"
46
- :class="checkboxStyle"
47
- >
48
- </div>
49
- </th>
50
- <th
51
- v-for="(column, index) in visibleColumns"
52
- :key="column.newKey + ':' + index + 'header'"
53
- v-bind="column.thAttrs && column.thAttrs(column)"
54
- :style="[
55
- column.style,
56
- index == 0 ? firstColStyles(true) : {},
57
- ]"
58
- class="th group text-left px-3 py-2"
59
- :class="{
60
- 'cursor-pointer': column.sortable,
61
- }"
62
- @click.stop="sort(column, undefined, $event as any)"
81
+ <path
82
+ :opacity="!isAsc ? '0.5' : '1'"
83
+ fill="currentColor"
84
+ d="M9.116 4.823a1.25 1.25 0 0 1 1.768 0l2.646 2.647a.75.75 0 0 1-1.06 1.06l-2.47-2.47-2.47 2.47a.75.75 0 1 1-1.06-1.06l2.646-2.647Z"
85
+ ></path>
86
+ <path
87
+ :opacity="isAsc ? '0.5' : '1'"
88
+ fill="currentColor"
89
+ d="M9.116 15.177a1.25 1.25 0 0 0 1.768 0l2.646-2.647a.75.75 0 0 0-1.06-1.06l-2.47 2.47-2.47-2.47a.75.75 0 0 0-1.06 1.06l2.646 2.647Z"
90
+ ></path>
91
+ </svg>
92
+ </div>
93
+ </button>
94
+ </div>
95
+ </BaseTableHeader>
96
+ </BaseTableRow>
97
+ </BaseTableHead>
98
+
99
+ <BaseTableBody class="bg-white">
100
+ <template
101
+ v-for="(row, index) in data"
102
+ :key="getRowKey(row)"
103
+ >
104
+ <BaseTableRow
105
+ :to="rowTo ? rowTo(row) : undefined"
106
+ v-bind="rowBindings(row, index)"
107
+ >
108
+ <BaseTableCell
109
+ v-for="(column, columnIndex) in visibleColumns"
110
+ :key="column.newKey + index + ':' + columnIndex"
111
+ v-bind="column.tdAttrs && column.tdAttrs(row, column)"
112
+ :class="column.class"
113
+ :style="column.style"
114
+ :to="column.to ? column.to(row) : undefined"
115
+ :href="column.href ? column.href(row) : undefined"
116
+ :target="column.target"
117
+ :ignore-row-interactions="column.ignoreRowInteractions"
118
+ :on-click="onCellClick(row, index, column, columnIndex)"
119
+ >
120
+ <div :class="[columnIndex == 0 ? 'flex items-center gap-4' : '']">
121
+ <template v-if="columnIndex == 0">
122
+ <button
123
+ v-if="showDetailRowIcon"
124
+ type="button"
125
+ class="relative z-[1] || flex h-5 w-5 shrink-0 grow-0 appearance-none items-center justify-center rounded-full border border-slate-300 bg-white text-slate-400 shadow duration-100 hover:text-slate-600 hover:shadow-md"
126
+ @click.stop="toggleDetails(row)"
63
127
  >
64
- <button
65
- type="button"
66
- class="flex w-full items-center bg-transparent text-left text-sm font-medium leading-tight text-slate-900"
128
+ <BaseIcon
129
+ v-if="hasDetailedVisible(row)"
130
+ icon="mdi:chevron-down"
131
+ class="h-5 w-5 duration-300"
67
132
  :class="{
68
- 'text-blue-600':
69
- column.sortable && currentSortColumn === column,
133
+ 'rotate-180': isVisibleDetailRow(row)
70
134
  }"
71
- >
72
- <span
73
- class="whitespace-nowrap text-slate-600"
74
- :class="{
75
- 'text-[12px]': size == 'sm',
76
- 'text-xs': size == 'md',
77
- }"
78
- >
79
- {{ column.label }}
80
- </span>
81
- <div
82
- v-if="column.sortable"
83
- class="w-3"
84
- :class="[
85
- currentSortColumn === column
86
- ? ''
87
- : 'opacity-0 duration-200 group-hover:opacity-100',
88
- ]"
89
- >
90
- <svg
91
- viewBox="0 0 20 20"
92
- class="absolute top-1/2 h-5 w-5 -translate-y-1/2"
93
- >
94
- <path
95
- :opacity="!isAsc ? '0.5' : '1'"
96
- fill="currentColor"
97
- d="M9.116 4.823a1.25 1.25 0 0 1 1.768 0l2.646 2.647a.75.75 0 0 1-1.06 1.06l-2.47-2.47-2.47 2.47a.75.75 0 1 1-1.06-1.06l2.646-2.647Z"
98
- ></path>
99
- <path
100
- :opacity="isAsc ? '0.5' : '1'"
101
- fill="currentColor"
102
- d="M9.116 15.177a1.25 1.25 0 0 0 1.768 0l2.646-2.647a.75.75 0 0 0-1.06-1.06l-2.47 2.47-2.47-2.47a.75.75 0 0 0-1.06 1.06l2.646 2.647Z"
103
- ></path>
104
- </svg>
105
- </div>
106
- </button>
107
- </th>
108
- <th
109
- v-if="checkable && checkboxPosition === 'right'"
110
- class="th group cursor-pointer pr-3"
111
- align="right"
112
- @click="checkAll"
135
+ />
136
+ </button>
137
+
138
+ <div
139
+ v-if="checkable"
140
+ class="relative z-[1] || flex items-center group cursor-pointer bg-white"
141
+ @click.stop="checkRow(row, index, $event as MouseEvent)"
113
142
  >
114
143
  <input
115
- autocomplete="off"
116
144
  type="checkbox"
117
- :checked="isAllChecked"
118
- :disabled="isAllUncheckable"
145
+ autocomplete="off"
146
+ :disabled="!isRowCheckable(row)"
147
+ :checked="isRowChecked(row)"
119
148
  :class="checkboxStyle"
120
149
  >
121
- </th>
122
- </tr>
123
- </thead>
124
-
125
- <tbody class="bg-white">
126
- <template
127
- v-for="(row, index) in data"
128
- :key="getRowKey(row)"
129
- >
130
- <tr class="item-row">
131
- <td
132
- v-if="showDetailRowIcon"
133
- class="group cursor-pointer bg-white pl-3"
134
- :class="borderBottomClasses(index, row)"
135
- :style="detailsStyles(false)"
136
- @click.stop="toggleDetails(row)"
137
- >
138
- <button
139
- type="button"
140
- class="mr-0 flex h-5 w-5 appearance-none items-center justify-center rounded-full border border-slate-300 bg-white text-slate-400 shadow duration-100 group-hover:text-slate-600 group-hover:shadow-md"
141
- >
142
- <BaseIcon
143
- v-if="hasDetailedVisible(row)"
144
- icon="mdi:chevron-down"
145
- class="h-5 w-5 duration-300"
146
- :class="{
147
- 'rotate-180': isVisibleDetailRow(row),
148
- }"
149
- />
150
- </button>
151
- </td>
152
-
153
- <td
154
- v-if="checkable && checkboxPosition === 'left'"
155
- class="group z-[1] cursor-pointer bg-white pl-3"
156
- :class="borderBottomClasses(index, row)"
157
- :style="checkStyles(false)"
158
- @click="checkRow(row, index, $event as MouseEvent)"
159
- >
160
- <div class="flex items-center">
161
- <input
162
- type="checkbox"
163
- autocomplete="off"
164
- :disabled="!isRowCheckable(row)"
165
- :checked="isRowChecked(row)"
166
- :class="checkboxStyle"
167
- >
168
- </div>
169
- </td>
170
-
171
- <SlotComponent
172
- v-for="(column, colindex) in visibleColumns"
173
- :key="column.newKey + index + ':' + colindex"
174
- v-bind="column.tdAttrs && column.tdAttrs(row, column)"
175
- :component="column"
176
- scoped
177
- name="default"
178
- tag="td"
179
- class="bg-white text-sm"
180
- :class="[
181
- borderBottomClasses(index, row),
182
- column.clickable ? 'cursor-pointer' : '',
183
- {
184
- 'py-1 px-3': size == 'sm',
185
- 'py-2 px-3': size == 'md',
186
- }
187
- ]"
188
- :style="[
189
- column.style,
190
- colindex === 0 ? firstColStyles(false) : {}
191
- ]"
192
- :data-label="column.label"
193
- :props="{ row, column, index, colindex, toggleDetails }"
194
- @click="onColumnClick(row, column, index, colindex, $event)"
195
- />
196
-
197
- <td
198
- v-if="checkable && checkboxPosition === 'right'"
199
- class="group cursor-pointer"
200
- :class="[
201
- borderBottomClasses(index, row),
202
- {
203
- 'px-3 py-1': size == 'sm',
204
- 'p-3': size == 'md',
205
- }
206
- ]"
207
- align="right"
208
- @click="checkRow(row, index, $event as MouseEvent)"
209
- >
210
- <input
211
- type="checkbox"
212
- autocomplete="off"
213
- :disabled="!isRowCheckable(row)"
214
- :checked="isRowChecked(row)"
215
- :class="checkboxStyle"
216
- >
217
- </td>
218
- </tr>
219
-
220
- <transition :name="detailTransition">
221
- <tr
222
- v-if="isActiveDetailRow(row)"
223
- :key="getRowKey(row) + 'detail'"
224
- >
225
- <td
226
- :colspan="columnCount"
227
- :class="borderBottomDetailClasses(index)"
228
- >
229
- <slot
230
- name="detail"
231
- :row="row"
232
- :index="index"
233
- />
234
- </td>
235
- </tr>
236
- </transition>
150
+ </div>
237
151
  </template>
238
152
 
239
- <tr v-if="data.length == 0">
240
- <td :colspan="columnCount">
241
- <slot name="empty" />
242
- </td>
243
- </tr>
244
- </tbody>
245
- </table>
246
-
247
- <slot name="loading">
248
- <Transition
249
- enter-active-class="transition ease-out duration-200"
250
- enter-from-class="opacity-0"
251
- enter-to-class="opacity-100"
252
- leave-active-class="transition ease-in duration-200"
253
- leave-from-class="opacity-100"
254
- leave-to-class="opacity-0"
153
+ <SlotComponent
154
+ :component="column"
155
+ scoped
156
+ name="default"
157
+ tag="div"
158
+ class="text-sm"
159
+ :data-label="column.label"
160
+ :props="{ row, column, index, columnIndex, toggleDetails }"
161
+ />
162
+ </div>
163
+ </BaseTableCell>
164
+ </BaseTableRow>
165
+
166
+ <transition :name="detailTransition">
167
+ <BaseTableRow
168
+ v-if="isActiveDetailRow(row)"
169
+ :key="getRowKey(row) + 'detail'"
170
+ >
171
+ <BaseTableCell
172
+ :colspan="columnCount"
255
173
  >
256
- <div
257
- v-if="loading"
258
- class="absolute inset-0 z-[1] flex h-full w-full items-start justify-center"
259
- >
260
- <div class="absolute h-full w-full bg-white bg-opacity-60" />
261
-
262
- <div class="pt-20">
263
- <BaseSpinnerLarge class="h-10 w-10 text-blue-500" />
264
- </div>
265
- </div>
266
- </Transition>
267
- </slot>
268
- </div>
269
- </div>
270
- </div>
271
- </div>
174
+ <slot
175
+ name="detail"
176
+ :row="row"
177
+ :index="index"
178
+ />
179
+ </BaseTableCell>
180
+ </BaseTableRow>
181
+ </transition>
182
+ </template>
183
+
184
+ <BaseTableRow v-if="data.length == 0">
185
+ <BaseTableCell :colspan="columnCount">
186
+ <slot name="empty" />
187
+ </BaseTableCell>
188
+ </BaseTableRow>
189
+ </BaseTableBody>
190
+ </BaseTable>
272
191
  </div>
273
192
  </template>
274
193
 
275
194
  <script lang="ts" setup>
276
- import { PropType, StyleValue, ref } from 'vue';
277
- import { BaseTableColumnData, Row } from '@/types';
195
+ import { PropType, ref } from 'vue';
196
+ import { BaseTableColumnData, CollectionItem, Row } from '@/types';
278
197
  import SlotComponent from './SlotComponent';
279
- import { useResizeObserver, useScroll } from '@vueuse/core';
280
- import { debounce, isArray } from 'lodash';
281
- import BaseSpinnerLarge from '../svg/BaseSpinnerLarge.vue';
198
+ import { isArray } from 'lodash';
282
199
  import { Size } from '@/utils/sizes';
283
200
  import objectHash from 'object-hash';
201
+ import BaseTable from './BaseTable.vue';
202
+ import BaseTableHead from './BaseTableHead.vue';
203
+ import BaseTableHeader from './BaseTableHeader.vue';
204
+ import BaseTableBody from './BaseTableBody.vue';
205
+ import BaseTableRow from './BaseTableRow.vue';
206
+ import BaseTableCell from './BaseTableCell.vue';
207
+ import { RouteLocationRaw } from 'vue-router';
284
208
 
285
209
  const checkboxStyle =
286
210
  'disabled:bg-slate-100 group-hover:shadow-md disabled:border-slate-300 disabled:cursor-not-allowed duration-300 cursor-pointer focus:ring-blue-300 border border-slate-300 shadow h-[18px] w-[18px] rounded';
287
- const DETAIL_ROW_WIDTH = 36;
288
- const CHECK_ROW_WIDTH = 36;
289
211
 
290
212
  defineOptions({
291
213
  name: 'BaseDataTableTemplate',
@@ -307,7 +229,7 @@ const props = defineProps({
307
229
  },
308
230
  visibleColumns: {
309
231
  default: undefined,
310
- type: Array as PropType<number[]>,
232
+ type: Array as PropType<string[]>,
311
233
  },
312
234
  /** Allow row details */
313
235
  detailed: {
@@ -319,14 +241,6 @@ const props = defineProps({
319
241
  default: false,
320
242
  type: Boolean,
321
243
  },
322
- /**
323
- * Position of the checkbox (if checkable is true)
324
- * @values left, right
325
- */
326
- checkboxPosition: {
327
- type: String as PropType<'left' | 'right'>,
328
- default: 'left',
329
- },
330
244
  /** Custom method to verify if a row is checkable, works when is checkable */
331
245
  isRowCheckable: {
332
246
  type: Function,
@@ -369,6 +283,18 @@ const props = defineProps({
369
283
  type: String as PropType<Size>,
370
284
  default: 'md',
371
285
  },
286
+ rowTo: {
287
+ default: undefined,
288
+ type: Function as PropType<((row: CollectionItem) => RouteLocationRaw) | undefined>,
289
+ },
290
+ rowHref: {
291
+ default: undefined,
292
+ type: Function as PropType<((row: CollectionItem) => string) | undefined>,
293
+ },
294
+ onRowClick: {
295
+ default: undefined,
296
+ type: Function as PropType<((row: CollectionItem, index: number, event: MouseEvent) => void) | undefined>,
297
+ },
372
298
  });
373
299
 
374
300
  const emit = defineEmits([
@@ -380,6 +306,7 @@ const emit = defineEmits([
380
306
  'update:openedDetailed',
381
307
  'sort',
382
308
  'cell-click',
309
+ 'row-click',
383
310
  ]);
384
311
 
385
312
  const visibleDetailRows = ref<string[]>([]);
@@ -392,20 +319,6 @@ const defaultSlots = ref<BaseTableColumnData[]>([]);
392
319
  const sequence = ref(1);
393
320
 
394
321
  const slot = ref<HTMLElement | null>(null);
395
- const thead = ref<HTMLElement | null>(null);
396
- const theadHeight = ref(0);
397
-
398
- useResizeObserver(thead, () => setTheadHeightDebounce());
399
-
400
- const setTheadHeightDebounce = debounce(() => {
401
- setTheadHeight();
402
- }, 100);
403
-
404
- function setTheadHeight() {
405
- if (thead.value) {
406
- theadHeight.value = thead.value.clientHeight;
407
- }
408
- }
409
322
 
410
323
  const newColumns = computed(() => {
411
324
  return defaultSlots.value;
@@ -749,38 +662,24 @@ function removeColumn(column: BaseTableColumnData) {
749
662
  );
750
663
  }
751
664
 
752
- const borderClasses = 'border-b border-slate-200';
753
-
754
- function borderBottomClasses(index: number, row: Row): string {
755
- if (index < props.data.length - 1) {
756
- return borderClasses;
757
- }
758
-
759
- if (isActiveDetailRow(row)) {
760
- return borderClasses;
665
+ function rowBindings(row: CollectionItem, index: number) {
666
+ return {
667
+ onClick: props.onRowClick ? (event: MouseEvent) => props.onRowClick && props.onRowClick(row, index, event) : undefined,
761
668
  }
762
-
763
- return '';
764
669
  }
765
670
 
766
- function borderBottomDetailClasses(index: number): string {
767
- if (index < props.data.length - 1) {
768
- return borderClasses;
671
+ function onCellClick(row: CollectionItem, index: number, column: BaseTableColumnData, columnIndex: number) {
672
+ if (!column.onClick) {
673
+ return undefined;
769
674
  }
770
675
 
771
- return '';
772
- }
676
+ return (event: MouseEvent) => {
677
+ if (!column.onClick) {
678
+ return;
679
+ }
773
680
 
774
- function onColumnClick(
775
- row: Row,
776
- column: BaseTableColumnData,
777
- index: number,
778
- colindex: number,
779
- event: MouseEvent
780
- ) {
781
- if (column.clickable) {
782
- emit('cell-click', row, column, index, colindex, event);
783
- }
681
+ column.onClick(row, index, column, columnIndex, event);
682
+ };
784
683
  }
785
684
 
786
685
  function nextSequence() {
@@ -800,80 +699,17 @@ function getRowKey(row: Row): string {
800
699
  return objectHash(row);
801
700
  }
802
701
 
803
- // Sticky styles
804
-
805
- const horizontalScrolling = ref(false);
806
- const scrollable = ref<null | HTMLElement>(null);
807
-
808
- const { x } = useScroll(scrollable);
809
- watch(x, (value) => {
810
- horizontalScrolling.value = value > 0;
811
- });
812
-
813
- function zIndex(th: boolean) {
814
- if (th) {
815
- return props.maxHeight ? 3 : 2;
816
- }
817
- return 1;
818
- }
819
-
820
- function detailsStyles(th: boolean): StyleValue {
821
- if (props.detailed) {
822
- return {
823
- zIndex: zIndex(th) + 1,
824
- position: 'sticky',
825
- left: 0,
826
- width: DETAIL_ROW_WIDTH + 'px',
827
- minWidth: DETAIL_ROW_WIDTH + 'px',
828
- maxWidth: DETAIL_ROW_WIDTH + 'px',
829
- };
830
- }
831
- return {};
832
- }
833
-
834
- function checkStyles(th: boolean): StyleValue {
835
- if (props.checkable) {
836
- return {
837
- zIndex: zIndex(th) + 1,
838
- position: 'sticky',
839
- left: props.detailed ? DETAIL_ROW_WIDTH + 'px' : 0,
840
- width: CHECK_ROW_WIDTH + 'px',
841
- minWidth: CHECK_ROW_WIDTH + 'px',
842
- maxWidth: CHECK_ROW_WIDTH + 'px',
843
- };
844
- }
845
- return {};
846
- }
847
-
848
- function firstColStyles(th: boolean): StyleValue {
849
- let left = 0;
850
- if (props.checkable) {
851
- left += CHECK_ROW_WIDTH;
852
- }
853
- if (props.detailed) {
854
- left += DETAIL_ROW_WIDTH;
855
- }
856
- return {
857
- zIndex: zIndex(th) + 1,
858
- position: 'sticky',
859
- left: left + 'px',
860
- borderRight: horizontalScrolling.value ? '1px solid #e2e8f0' : 'none',
861
- };
862
- }
863
-
864
- function scrollTop() {
865
- if (scrollable.value) {
866
- scrollable.value.scrollTo({ top: 0, behavior: 'smooth' });
867
- }
868
- }
869
-
870
702
  provide('addColumn', addColumn);
871
703
  provide('removeColumn', removeColumn);
872
704
  provide('nextSequence', nextSequence);
873
705
 
706
+ const baseTableRef = ref<InstanceType<typeof BaseTable> | null>(null);
707
+
874
708
  defineExpose({
875
709
  newColumns,
876
710
  uncheckAll,
877
- scrollTop,
711
+ scrollTop: () => {
712
+ baseTableRef.value?.scrollTop();
713
+ },
878
714
  });
879
715
  </script>