sprintify-ui 0.7.11 → 0.8.0
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.
- package/dist/sprintify-ui.es.js +10481 -10348
- package/dist/style.css +1 -1
- package/dist/types/components/BaseDataIterator.vue.d.ts +50 -4
- package/dist/types/components/BaseDataIteratorSectionColumns.vue.d.ts +156 -68
- package/dist/types/components/BaseDataTable.vue.d.ts +86 -6
- package/dist/types/components/BaseDataTableTemplate.vue.d.ts +44 -28
- package/dist/types/components/BaseTable.vue.d.ts +30 -7
- package/dist/types/components/BaseTableCell.vue.d.ts +19 -1
- package/dist/types/components/BaseTableColumn.vue.d.ts +50 -3
- package/dist/types/components/BaseTableHead.vue.d.ts +6 -5
- package/dist/types/components/BaseTableHeader.vue.d.ts +12 -2
- package/dist/types/components/BaseTableRow.vue.d.ts +5 -0
- package/dist/types/composables/isFirstColumn.d.ts +4 -0
- package/dist/types/composables/isLastColumn.d.ts +4 -0
- package/dist/types/composables/paginatedData.d.ts +5 -5
- package/dist/types/services/table/types.d.ts +6 -5
- package/dist/types/types/index.d.ts +7 -2
- package/dist/types/utils/getApiData.d.ts +1 -1
- package/package.json +2 -1
- package/src/assets/main.css +0 -1
- package/src/components/BaseAvatar.vue +1 -0
- package/src/components/BaseDataIterator.stories.js +96 -1
- package/src/components/BaseDataIterator.vue +135 -11
- package/src/components/BaseDataIteratorSectionColumns.vue +2 -2
- package/src/components/BaseDataTable.stories.js +140 -50
- package/src/components/BaseDataTable.vue +82 -48
- package/src/components/BaseDataTableTemplate.vue +207 -372
- package/src/components/BaseTable.stories.js +57 -15
- package/src/components/BaseTable.vue +71 -9
- package/src/components/BaseTableBody.vue +1 -1
- package/src/components/BaseTableCell.vue +94 -36
- package/src/components/BaseTableColumn.vue +25 -2
- package/src/components/BaseTableHead.vue +17 -5
- package/src/components/BaseTableHeader.vue +39 -10
- package/src/components/BaseTableRow.vue +27 -6
- package/src/composables/isFirstColumn.ts +31 -0
- package/src/composables/isLastColumn.ts +31 -0
- package/src/composables/paginatedData.ts +22 -10
- package/src/services/table/classes.ts +13 -9
- package/src/services/table/types.ts +6 -5
- package/src/stories/List.stories.js +5 -1
- package/src/types/index.ts +7 -2
- package/src/utils/getApiData.ts +1 -1
- package/src/assets/base-table.css +0 -17
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div
|
|
3
|
-
class="
|
|
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,204 @@
|
|
|
10
9
|
<slot />
|
|
11
10
|
</div>
|
|
12
11
|
|
|
13
|
-
<
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
<
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
-
<
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
+
<div
|
|
123
|
+
v-if="showDetailRowIcon"
|
|
124
|
+
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"
|
|
125
|
+
@click.stop="toggleDetails(row)"
|
|
63
126
|
>
|
|
64
|
-
<
|
|
65
|
-
|
|
66
|
-
|
|
127
|
+
<BaseIcon
|
|
128
|
+
v-if="hasDetailedVisible(row)"
|
|
129
|
+
icon="mdi:chevron-down"
|
|
130
|
+
class="h-5 w-5 duration-300"
|
|
67
131
|
:class="{
|
|
68
|
-
'
|
|
69
|
-
column.sortable && currentSortColumn === column,
|
|
132
|
+
'rotate-180': isVisibleDetailRow(row)
|
|
70
133
|
}"
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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"
|
|
134
|
+
/>
|
|
135
|
+
</div>
|
|
136
|
+
|
|
137
|
+
<div
|
|
138
|
+
v-if="checkable"
|
|
139
|
+
class="relative z-[1] || flex items-center group cursor-pointer bg-white"
|
|
140
|
+
@click.stop="checkRow(row, index, $event as MouseEvent)"
|
|
113
141
|
>
|
|
114
142
|
<input
|
|
115
|
-
autocomplete="off"
|
|
116
143
|
type="checkbox"
|
|
117
|
-
|
|
118
|
-
:disabled="
|
|
144
|
+
autocomplete="off"
|
|
145
|
+
:disabled="!isRowCheckable(row)"
|
|
146
|
+
:checked="isRowChecked(row)"
|
|
119
147
|
:class="checkboxStyle"
|
|
120
148
|
>
|
|
121
|
-
</
|
|
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>
|
|
149
|
+
</div>
|
|
237
150
|
</template>
|
|
238
151
|
|
|
239
|
-
<
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
152
|
+
<SlotComponent
|
|
153
|
+
:component="column"
|
|
154
|
+
scoped
|
|
155
|
+
name="default"
|
|
156
|
+
tag="div"
|
|
157
|
+
class="text-sm"
|
|
158
|
+
:data-label="column.label"
|
|
159
|
+
:props="{ row, column, index, columnIndex, toggleDetails }"
|
|
160
|
+
/>
|
|
161
|
+
</div>
|
|
162
|
+
</BaseTableCell>
|
|
163
|
+
</BaseTableRow>
|
|
164
|
+
|
|
165
|
+
<transition :name="detailTransition">
|
|
166
|
+
<BaseTableRow
|
|
167
|
+
v-if="isActiveDetailRow(row)"
|
|
168
|
+
:key="getRowKey(row) + 'detail'"
|
|
169
|
+
>
|
|
170
|
+
<BaseTableCell
|
|
171
|
+
:colspan="columnCount"
|
|
255
172
|
>
|
|
256
|
-
<
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
173
|
+
<slot
|
|
174
|
+
name="detail"
|
|
175
|
+
:row="row"
|
|
176
|
+
:index="index"
|
|
177
|
+
/>
|
|
178
|
+
</BaseTableCell>
|
|
179
|
+
</BaseTableRow>
|
|
180
|
+
</transition>
|
|
181
|
+
</template>
|
|
182
|
+
|
|
183
|
+
<BaseTableRow v-if="data.length == 0">
|
|
184
|
+
<BaseTableCell :colspan="columnCount">
|
|
185
|
+
<slot name="empty" />
|
|
186
|
+
</BaseTableCell>
|
|
187
|
+
</BaseTableRow>
|
|
188
|
+
</BaseTableBody>
|
|
189
|
+
</BaseTable>
|
|
272
190
|
</div>
|
|
273
191
|
</template>
|
|
274
192
|
|
|
275
193
|
<script lang="ts" setup>
|
|
276
|
-
import { PropType,
|
|
277
|
-
import { BaseTableColumnData, Row } from '@/types';
|
|
194
|
+
import { PropType, ref } from 'vue';
|
|
195
|
+
import { BaseTableColumnData, CollectionItem, Row } from '@/types';
|
|
278
196
|
import SlotComponent from './SlotComponent';
|
|
279
|
-
import {
|
|
280
|
-
import { debounce, isArray } from 'lodash';
|
|
281
|
-
import BaseSpinnerLarge from '../svg/BaseSpinnerLarge.vue';
|
|
197
|
+
import { isArray } from 'lodash';
|
|
282
198
|
import { Size } from '@/utils/sizes';
|
|
283
199
|
import objectHash from 'object-hash';
|
|
200
|
+
import BaseTable from './BaseTable.vue';
|
|
201
|
+
import BaseTableHead from './BaseTableHead.vue';
|
|
202
|
+
import BaseTableHeader from './BaseTableHeader.vue';
|
|
203
|
+
import BaseTableBody from './BaseTableBody.vue';
|
|
204
|
+
import BaseTableRow from './BaseTableRow.vue';
|
|
205
|
+
import BaseTableCell from './BaseTableCell.vue';
|
|
206
|
+
import { RouteLocationRaw } from 'vue-router';
|
|
284
207
|
|
|
285
208
|
const checkboxStyle =
|
|
286
209
|
'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
210
|
|
|
290
211
|
defineOptions({
|
|
291
212
|
name: 'BaseDataTableTemplate',
|
|
@@ -307,7 +228,7 @@ const props = defineProps({
|
|
|
307
228
|
},
|
|
308
229
|
visibleColumns: {
|
|
309
230
|
default: undefined,
|
|
310
|
-
type: Array as PropType<
|
|
231
|
+
type: Array as PropType<string[]>,
|
|
311
232
|
},
|
|
312
233
|
/** Allow row details */
|
|
313
234
|
detailed: {
|
|
@@ -319,14 +240,6 @@ const props = defineProps({
|
|
|
319
240
|
default: false,
|
|
320
241
|
type: Boolean,
|
|
321
242
|
},
|
|
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
243
|
/** Custom method to verify if a row is checkable, works when is checkable */
|
|
331
244
|
isRowCheckable: {
|
|
332
245
|
type: Function,
|
|
@@ -369,6 +282,18 @@ const props = defineProps({
|
|
|
369
282
|
type: String as PropType<Size>,
|
|
370
283
|
default: 'md',
|
|
371
284
|
},
|
|
285
|
+
rowTo: {
|
|
286
|
+
default: undefined,
|
|
287
|
+
type: Function as PropType<((row: CollectionItem) => RouteLocationRaw) | undefined>,
|
|
288
|
+
},
|
|
289
|
+
rowHref: {
|
|
290
|
+
default: undefined,
|
|
291
|
+
type: Function as PropType<((row: CollectionItem) => string) | undefined>,
|
|
292
|
+
},
|
|
293
|
+
onRowClick: {
|
|
294
|
+
default: undefined,
|
|
295
|
+
type: Function as PropType<((row: CollectionItem, index: number, event: MouseEvent) => void) | undefined>,
|
|
296
|
+
},
|
|
372
297
|
});
|
|
373
298
|
|
|
374
299
|
const emit = defineEmits([
|
|
@@ -380,6 +305,7 @@ const emit = defineEmits([
|
|
|
380
305
|
'update:openedDetailed',
|
|
381
306
|
'sort',
|
|
382
307
|
'cell-click',
|
|
308
|
+
'row-click',
|
|
383
309
|
]);
|
|
384
310
|
|
|
385
311
|
const visibleDetailRows = ref<string[]>([]);
|
|
@@ -392,20 +318,6 @@ const defaultSlots = ref<BaseTableColumnData[]>([]);
|
|
|
392
318
|
const sequence = ref(1);
|
|
393
319
|
|
|
394
320
|
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
321
|
|
|
410
322
|
const newColumns = computed(() => {
|
|
411
323
|
return defaultSlots.value;
|
|
@@ -749,38 +661,24 @@ function removeColumn(column: BaseTableColumnData) {
|
|
|
749
661
|
);
|
|
750
662
|
}
|
|
751
663
|
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
if (index < props.data.length - 1) {
|
|
756
|
-
return borderClasses;
|
|
757
|
-
}
|
|
758
|
-
|
|
759
|
-
if (isActiveDetailRow(row)) {
|
|
760
|
-
return borderClasses;
|
|
664
|
+
function rowBindings(row: CollectionItem, index: number) {
|
|
665
|
+
return {
|
|
666
|
+
onClick: props.onRowClick ? (event: MouseEvent) => props.onRowClick && props.onRowClick(row, index, event) : undefined,
|
|
761
667
|
}
|
|
762
|
-
|
|
763
|
-
return '';
|
|
764
668
|
}
|
|
765
669
|
|
|
766
|
-
function
|
|
767
|
-
if (
|
|
768
|
-
return
|
|
670
|
+
function onCellClick(row: CollectionItem, index: number, column: BaseTableColumnData, columnIndex: number) {
|
|
671
|
+
if (!column.onClick) {
|
|
672
|
+
return undefined;
|
|
769
673
|
}
|
|
770
674
|
|
|
771
|
-
return
|
|
772
|
-
|
|
675
|
+
return (event: MouseEvent) => {
|
|
676
|
+
if (!column.onClick) {
|
|
677
|
+
return;
|
|
678
|
+
}
|
|
773
679
|
|
|
774
|
-
|
|
775
|
-
|
|
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
|
-
}
|
|
680
|
+
column.onClick(row, index, column, columnIndex, event);
|
|
681
|
+
};
|
|
784
682
|
}
|
|
785
683
|
|
|
786
684
|
function nextSequence() {
|
|
@@ -800,80 +698,17 @@ function getRowKey(row: Row): string {
|
|
|
800
698
|
return objectHash(row);
|
|
801
699
|
}
|
|
802
700
|
|
|
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
701
|
provide('addColumn', addColumn);
|
|
871
702
|
provide('removeColumn', removeColumn);
|
|
872
703
|
provide('nextSequence', nextSequence);
|
|
873
704
|
|
|
705
|
+
const baseTableRef = ref<InstanceType<typeof BaseTable> | null>(null);
|
|
706
|
+
|
|
874
707
|
defineExpose({
|
|
875
708
|
newColumns,
|
|
876
709
|
uncheckAll,
|
|
877
|
-
scrollTop
|
|
710
|
+
scrollTop: () => {
|
|
711
|
+
baseTableRef.value?.scrollTop();
|
|
712
|
+
},
|
|
878
713
|
});
|
|
879
714
|
</script>
|