@soft-stech/bootsman-ui-shadcn 1.4.25 → 1.4.27
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/BuiDataTableColumnList.vue_vue_type_script_setup_true_lang-BOdkTG0_.js +1338 -0
- package/dist/BuiTable.vue_vue_type_script_setup_true_lang-QoPGiEYZ.js +28 -0
- package/dist/{BuiTableHeader.vue_vue_type_script_setup_true_lang-B2getNR7.js → BuiTableHeader.vue_vue_type_script_setup_true_lang-BXgL487_.js} +1 -1
- package/dist/assets/main.css +1 -1
- package/dist/components/ui/table/BuiDataTable.vue.d.ts +13 -2
- package/dist/components/ui/table/BuiDataTableColumnList.js +4 -0
- package/dist/components/ui/table/BuiDataTableColumnList.vue.d.ts +24 -0
- package/dist/components/ui/table/BuiTable.js +1 -1
- package/dist/components/ui/table/BuiTable.vue.d.ts +1 -0
- package/dist/components/ui/table/BuiTableHeader.js +1 -1
- package/dist/components/ui/table/index.d.ts +1 -0
- package/dist/components/ui/table/index.js +311 -190
- package/dist/index.js +17 -15
- package/package.json +7 -5
- package/src/components/stories/BuiDataTable.story.vue +22 -4
- package/src/components/ui/table/BuiDataTable.vue +137 -20
- package/src/components/ui/table/BuiDataTableColumnList.vue +34 -0
- package/src/components/ui/table/BuiTable.vue +1 -0
- package/src/components/ui/table/BuiTableHeader.vue +2 -2
- package/src/components/ui/table/index.ts +9 -6
- package/dist/BuiTable.vue_vue_type_script_setup_true_lang-D8Tseif4.js +0 -27
package/dist/index.js
CHANGED
@@ -145,11 +145,11 @@ import { _ as ai } from "./BuiAlertDescription.vue_vue_type_script_setup_true_la
|
|
145
145
|
import { _ as ui } from "./BuiAvatarImage.vue_vue_type_script_setup_true_lang-DELf2i8H.js";
|
146
146
|
import { _ as si } from "./BuiAvatarFallback.vue_vue_type_script_setup_true_lang-B1ncuXZ0.js";
|
147
147
|
import "./BuiCalendar.vue_vue_type_style_index_0_lang-DK4yUiXC.js";
|
148
|
-
import { _ as Bi } from "./BuiTable.vue_vue_type_script_setup_true_lang-
|
148
|
+
import { _ as Bi } from "./BuiTable.vue_vue_type_script_setup_true_lang-QoPGiEYZ.js";
|
149
149
|
import { _ as fi } from "./BuiTableBody.vue_vue_type_script_setup_true_lang-DblqmDim.js";
|
150
150
|
import { _ as _i } from "./BuiTableCell.vue_vue_type_script_setup_true_lang-CYBx0oJL.js";
|
151
151
|
import { _ as di } from "./BuiTableHead.vue_vue_type_script_setup_true_lang-BDSRArVd.js";
|
152
|
-
import { _ as Ci } from "./BuiTableHeader.vue_vue_type_script_setup_true_lang-
|
152
|
+
import { _ as Ci } from "./BuiTableHeader.vue_vue_type_script_setup_true_lang-BXgL487_.js";
|
153
153
|
import { _ as Fi } from "./BuiTableRow.vue_vue_type_script_setup_true_lang-Bl4nF6yV.js";
|
154
154
|
import { _ as Si } from "./BuiTableCaption.vue_vue_type_script_setup_true_lang-CTEP1Sde.js";
|
155
155
|
import { _ as Ai } from "./BuiTableEmpty.vue_vue_type_script_setup_true_lang-BTyX0sT5.js";
|
@@ -165,12 +165,13 @@ import { _ as ji } from "./BuiSheetHeader.vue_vue_type_script_setup_true_lang-vG
|
|
165
165
|
import { _ as Ji } from "./BuiSheetTitle.vue_vue_type_script_setup_true_lang-D-bamlaT.js";
|
166
166
|
import { _ as Ui } from "./BuiSheetTrigger.vue_vue_type_script_setup_true_lang-Bo3F1V-i.js";
|
167
167
|
import { Form as zi, Field as Qi, FieldArray as Wi, useField as Xi, useFieldArray as Zi, useForm as $i } from "vee-validate";
|
168
|
-
import { _ as ru } from "./
|
169
|
-
import { _ as tu } from "./
|
170
|
-
import { _ as iu } from "./
|
171
|
-
import { _ as pu } from "./
|
172
|
-
import { _ as mu } from "./
|
173
|
-
import {
|
168
|
+
import { _ as ru } from "./BuiDataTableColumnList.vue_vue_type_script_setup_true_lang-BOdkTG0_.js";
|
169
|
+
import { _ as tu } from "./BuiToastViewport.vue_vue_type_script_setup_true_lang-BBDzM6Br.js";
|
170
|
+
import { _ as iu } from "./BuiToastClose.vue_vue_type_script_setup_true_lang-fLjieQsa.js";
|
171
|
+
import { _ as pu } from "./BuiToastTitle.vue_vue_type_script_setup_true_lang-D1VfRzjv.js";
|
172
|
+
import { _ as mu } from "./BuiToastDescription.vue_vue_type_script_setup_true_lang-CZ5Gk9K4.js";
|
173
|
+
import { _ as xu } from "./BuiToastProvider.vue_vue_type_script_setup_true_lang-ZXzJkgBD.js";
|
174
|
+
import { toast as nu, useToast as _u } from "./components/ui/toast/use-toast.js";
|
174
175
|
export {
|
175
176
|
a as BuiAccordion,
|
176
177
|
u as BuiAccordionContent,
|
@@ -244,6 +245,7 @@ export {
|
|
244
245
|
pr as BuiContextMenuSubTrigger,
|
245
246
|
Oo as BuiContextMenuTrigger,
|
246
247
|
vt as BuiDataTable,
|
248
|
+
ru as BuiDataTableColumnList,
|
247
249
|
xr as BuiDialog,
|
248
250
|
nr as BuiDialogClose,
|
249
251
|
br as BuiDialogContent,
|
@@ -343,11 +345,11 @@ export {
|
|
343
345
|
Nt as BuiTextarea,
|
344
346
|
Jt as BuiToast,
|
345
347
|
vi as BuiToastAction,
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
348
|
+
iu as BuiToastClose,
|
349
|
+
mu as BuiToastDescription,
|
350
|
+
xu as BuiToastProvider,
|
351
|
+
pu as BuiToastTitle,
|
352
|
+
tu as BuiToastViewport,
|
351
353
|
Kt as BuiToaster,
|
352
354
|
ea as BuiToggle,
|
353
355
|
ia as BuiToggleGroup,
|
@@ -380,12 +382,12 @@ export {
|
|
380
382
|
Ot as tabsTriggerVariants,
|
381
383
|
oi as tailwind,
|
382
384
|
jt as textareaVariants,
|
383
|
-
|
385
|
+
nu as toast,
|
384
386
|
Ut as toastVariants,
|
385
387
|
ta as toggleVariants,
|
386
388
|
Xi as useBuiField,
|
387
389
|
Zi as useBuiFieldArray,
|
388
390
|
$i as useBuiForm,
|
389
|
-
|
391
|
+
_u as useToast,
|
390
392
|
$ as valueUpdater
|
391
393
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@soft-stech/bootsman-ui-shadcn",
|
3
|
-
"version": "1.4.
|
3
|
+
"version": "1.4.27",
|
4
4
|
"type": "module",
|
5
5
|
"files": [
|
6
6
|
"dist",
|
@@ -15,19 +15,21 @@
|
|
15
15
|
"url": "https://github.com/soft-stech/bootsman-ui-shadcn"
|
16
16
|
},
|
17
17
|
"peerDependencies": {
|
18
|
-
"vue": "^3.5.6",
|
19
|
-
"zod": "^3.23.6",
|
20
|
-
"vee-validate": "^4.13.2",
|
21
18
|
"@tanstack/vue-table": "8.20.5",
|
22
19
|
"@vee-validate/zod": "4.13.2",
|
23
|
-
"@vueuse/core": "11.1.0"
|
20
|
+
"@vueuse/core": "11.1.0",
|
21
|
+
"vee-validate": "^4.13.2",
|
22
|
+
"vue": "^3.5.6",
|
23
|
+
"zod": "^3.23.6"
|
24
24
|
},
|
25
25
|
"dependencies": {
|
26
26
|
"@internationalized/date": "^3.5.5",
|
27
|
+
"@vueuse/integrations": "^13.0.0",
|
27
28
|
"class-variance-authority": "0.7.0",
|
28
29
|
"clsx": "2.1.1",
|
29
30
|
"lucide-vue-next": "0.441.0",
|
30
31
|
"radix-vue": "1.9.8",
|
32
|
+
"sortablejs": "^1",
|
31
33
|
"tailwind-merge": "2.5.2",
|
32
34
|
"tailwindcss-animate": "1.0.7",
|
33
35
|
"v-calendar": "3.1.2"
|
@@ -3,7 +3,15 @@ import { BuiDataTable } from '@/components/ui/table'
|
|
3
3
|
import RowActionsMenuContent from './components/ActionsMenuContent.vue'
|
4
4
|
import { BuiButton, BuiCheckbox, BuiTabs, BuiTabsList, BuiTabsTrigger } from '@/index'
|
5
5
|
import { tableColumnSortCommon } from '@/lib/utils'
|
6
|
-
import type {
|
6
|
+
import type {
|
7
|
+
ColumnDef,
|
8
|
+
PaginationState,
|
9
|
+
Row,
|
10
|
+
RowSelectionState,
|
11
|
+
ColumnSizingState,
|
12
|
+
VisibilityState,
|
13
|
+
ColumnOrderState
|
14
|
+
} from '@tanstack/vue-table'
|
7
15
|
import { sort, type ISortByObjectSorter } from 'fast-sort'
|
8
16
|
import { logEvent } from 'histoire/client'
|
9
17
|
import {
|
@@ -55,7 +63,9 @@ const columns: ColumnDef<Task>[] = [
|
|
55
63
|
ariaLabel: 'Select row'
|
56
64
|
}),
|
57
65
|
`${row.getValue('id')}`
|
58
|
-
])
|
66
|
+
]),
|
67
|
+
enableHiding: false,
|
68
|
+
meta: { title: 'ID', pinLeft: true }
|
59
69
|
},
|
60
70
|
{
|
61
71
|
accessorKey: 'title',
|
@@ -63,7 +73,8 @@ const columns: ColumnDef<Task>[] = [
|
|
63
73
|
},
|
64
74
|
{
|
65
75
|
accessorKey: 'status',
|
66
|
-
header: ({ column }) => tableColumnSortCommon(column, 'Status')
|
76
|
+
header: ({ column }) => tableColumnSortCommon(column, 'Status'),
|
77
|
+
meta: { title: 'Статус таска' }
|
67
78
|
},
|
68
79
|
{
|
69
80
|
accessorKey: 'priority',
|
@@ -96,6 +107,10 @@ function updateSelection(val: RowSelectionState) {
|
|
96
107
|
selection.value = val
|
97
108
|
}
|
98
109
|
|
110
|
+
const columnVisibility = ref<VisibilityState>({ hiddenColumn: false })
|
111
|
+
const columnSizing = ref<ColumnSizingState>({ title: 300 })
|
112
|
+
const columnOrder = ref<ColumnOrderState>()
|
113
|
+
|
99
114
|
type GroupBy = 'none' | 'status' | 'priority'
|
100
115
|
const groupBy = ref<GroupBy>('none')
|
101
116
|
const groupLabels = {
|
@@ -175,6 +190,9 @@ function groupName(group: string | number) {
|
|
175
190
|
:data="sortedData"
|
176
191
|
v-model:sorting="sorting"
|
177
192
|
v-model:pagination="pagination"
|
193
|
+
v-model:column-sizing="columnSizing"
|
194
|
+
v-model:column-visibility="columnVisibility"
|
195
|
+
v-model:column-order="columnOrder"
|
178
196
|
@update:selection="updateSelection"
|
179
197
|
:total-items="totalItems"
|
180
198
|
class="caption-top"
|
@@ -183,7 +201,7 @@ function groupName(group: string | number) {
|
|
183
201
|
:groupBy="groupBy === 'none' ? undefined : groupBy"
|
184
202
|
:groupLabels="groupLabels"
|
185
203
|
:renderSubComponent="renderSubComponent"
|
186
|
-
|
204
|
+
enable-column-list-control
|
187
205
|
>
|
188
206
|
<template #caption="{ table }">
|
189
207
|
<div class="flex justify-between">
|
@@ -6,9 +6,12 @@ import {
|
|
6
6
|
} from '@/components/ui/collapsible'
|
7
7
|
import { BuiPaginationCommon, type PageSize } from '@/components/ui/pagination'
|
8
8
|
import BuiTableRowSubrow from '@/components/ui/table/BuiTableRowSubrow.vue'
|
9
|
-
import { valueUpdater } from '@/lib/utils'
|
9
|
+
import { valueUpdater, cn } from '@/lib/utils'
|
10
10
|
import type {
|
11
|
+
Column,
|
11
12
|
ColumnDef,
|
13
|
+
ColumnOrderState,
|
14
|
+
ColumnSizingState,
|
12
15
|
PaginationState,
|
13
16
|
Row,
|
14
17
|
RowSelectionState,
|
@@ -22,7 +25,7 @@ import {
|
|
22
25
|
getSortedRowModel,
|
23
26
|
useVueTable
|
24
27
|
} from '@tanstack/vue-table'
|
25
|
-
import { computed, watchEffect } from 'vue'
|
28
|
+
import { computed, watchEffect, ref, watch } from 'vue'
|
26
29
|
import {
|
27
30
|
BuiTable,
|
28
31
|
BuiTableBody,
|
@@ -31,8 +34,19 @@ import {
|
|
31
34
|
BuiTableHead,
|
32
35
|
BuiTableHeader,
|
33
36
|
BuiTableRow,
|
34
|
-
getPinningStyle
|
37
|
+
getPinningStyle,
|
38
|
+
BuiDataTableColumnList
|
35
39
|
} from './'
|
40
|
+
import {
|
41
|
+
BuiCommand,
|
42
|
+
BuiCommandEmpty,
|
43
|
+
BuiCommandInput,
|
44
|
+
BuiCommandList
|
45
|
+
} from '@/components/ui/command'
|
46
|
+
import { BuiPopover, BuiPopoverContent, BuiPopoverTrigger } from '@/components/ui/popover'
|
47
|
+
import { BuiScrollArea } from '@/components/ui/scroll-area'
|
48
|
+
import { BuiButton } from '@/components/ui/button'
|
49
|
+
import { Settings2Icon } from 'lucide-vue-next'
|
36
50
|
|
37
51
|
const NO_GROUP_KEY = '#UNDEFINED#'
|
38
52
|
|
@@ -50,21 +64,38 @@ const props = withDefaults(
|
|
50
64
|
getRowId?: (originalRow: TData, index: number, parent?: Row<TData>) => string
|
51
65
|
renderSubComponent?: (row: Row<TData>) => (() => any) | undefined
|
52
66
|
freezeHeader?: boolean
|
67
|
+
enableColumnListControl?: boolean
|
68
|
+
columnSearchPlaceholder?: string
|
69
|
+
columnSearchNotFound?: string
|
53
70
|
}>(),
|
54
|
-
{
|
71
|
+
{
|
72
|
+
pageSize: 10,
|
73
|
+
showPagination: true,
|
74
|
+
manualPagination: true,
|
75
|
+
manualSorting: true,
|
76
|
+
totalItems: 0,
|
77
|
+
columnSearchPlaceholder: 'Column name',
|
78
|
+
columnSearchNotFound: 'Not found'
|
79
|
+
}
|
55
80
|
)
|
56
81
|
|
57
82
|
const sorting = defineModel<SortingState>('sorting')
|
58
83
|
const pagination = defineModel<PaginationState>('pagination')
|
59
84
|
const rowSelection = defineModel<RowSelectionState>('selection')
|
60
85
|
const columnVisibility = defineModel<VisibilityState>('columnVisibility')
|
86
|
+
const columnSizing = defineModel<ColumnSizingState>('columnSizing')
|
87
|
+
const columnOrder = defineModel<ColumnOrderState>('columnOrder')
|
61
88
|
const computedItems = computed(() =>
|
62
89
|
props.manualPagination ? props.totalItems : props.data.length
|
63
90
|
)
|
91
|
+
const pinnedColumns = props.columns
|
92
|
+
.map((col) => (col.meta?.pinLeft && col.id ? col.id : ''))
|
93
|
+
.filter(Boolean)
|
94
|
+
|
64
95
|
const table = useVueTable({
|
65
96
|
initialState: {
|
66
97
|
// TODO: column freeze
|
67
|
-
|
98
|
+
columnPinning: { left: pinnedColumns },
|
68
99
|
pagination: { pageSize: props.pageSize }
|
69
100
|
},
|
70
101
|
get data() {
|
@@ -85,9 +116,21 @@ const table = useVueTable({
|
|
85
116
|
onRowSelectionChange: (updaterOrValue) => {
|
86
117
|
valueUpdater(updaterOrValue, rowSelection)
|
87
118
|
},
|
119
|
+
onColumnVisibilityChange: (updaterOrValue) => {
|
120
|
+
valueUpdater(updaterOrValue, columnVisibility)
|
121
|
+
},
|
122
|
+
onColumnSizingChange: (updaterOrValue) => {
|
123
|
+
valueUpdater(updaterOrValue, columnSizing)
|
124
|
+
},
|
125
|
+
onColumnOrderChange: (updaterOrValue) => {
|
126
|
+
valueUpdater(updaterOrValue, columnOrder)
|
127
|
+
},
|
88
128
|
autoResetPageIndex: false,
|
89
129
|
manualPagination: props.manualPagination, // set to false to enable client-side pagination
|
90
130
|
manualSorting: props.manualSorting,
|
131
|
+
enableColumnResizing: true,
|
132
|
+
columnResizeMode: 'onChange',
|
133
|
+
columnResizeDirection: 'ltr',
|
91
134
|
state: {
|
92
135
|
get sorting() {
|
93
136
|
return sorting.value
|
@@ -100,6 +143,12 @@ const table = useVueTable({
|
|
100
143
|
},
|
101
144
|
get columnVisibility() {
|
102
145
|
return columnVisibility.value
|
146
|
+
},
|
147
|
+
get columnSizing() {
|
148
|
+
return columnSizing.value
|
149
|
+
},
|
150
|
+
get columnOrder() {
|
151
|
+
return columnOrder.value
|
103
152
|
}
|
104
153
|
},
|
105
154
|
getRowId: props.getRowId
|
@@ -150,6 +199,31 @@ function getGroupLabel(index: number) {
|
|
150
199
|
const labels = props.groupBy && props.groupLabels ? props.groupLabels[props.groupBy] || [] : []
|
151
200
|
return labels[index]
|
152
201
|
}
|
202
|
+
|
203
|
+
const columnsList = ref<Column<TData, unknown>[]>(
|
204
|
+
table
|
205
|
+
.getAllColumns()
|
206
|
+
.filter((column) => typeof column.accessorFn !== 'undefined' && column.getCanHide())
|
207
|
+
.sort((a, b) => {
|
208
|
+
if (!columnOrder.value) return 0
|
209
|
+
else if (columnOrder.value?.indexOf(a.id) < 0 && columnOrder.value?.indexOf(b.id) >= 0)
|
210
|
+
return 1
|
211
|
+
else if (columnOrder.value?.indexOf(a.id) >= 0 && columnOrder.value?.indexOf(b.id) < 0)
|
212
|
+
return -1
|
213
|
+
else return columnOrder.value?.indexOf(a.id) - columnOrder.value?.indexOf(b.id)
|
214
|
+
})
|
215
|
+
)
|
216
|
+
const columnsListIds = computed(() => columnsList.value.map((col) => col.id))
|
217
|
+
const open = ref(false)
|
218
|
+
const searchColumn = ref('')
|
219
|
+
|
220
|
+
const tableHeaders = computed(() =>
|
221
|
+
table.getHeaderGroups().length > 0 ? table.getHeaderGroups()[0].headers : undefined
|
222
|
+
)
|
223
|
+
|
224
|
+
watch(columnsListIds, () => {
|
225
|
+
table.setColumnOrder(columnsListIds.value)
|
226
|
+
})
|
153
227
|
</script>
|
154
228
|
|
155
229
|
<template>
|
@@ -157,21 +231,64 @@ function getGroupLabel(index: number) {
|
|
157
231
|
<slot name="caption" :table="table" />
|
158
232
|
</div>
|
159
233
|
<BuiTable>
|
160
|
-
<
|
161
|
-
<
|
162
|
-
<
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
234
|
+
<template v-if="enableColumnListControl" #columnVisibility>
|
235
|
+
<BuiPopover v-model:open="open">
|
236
|
+
<BuiPopoverTrigger as-child>
|
237
|
+
<div class="absolute right-0 top-0 z-10 h-10 bg-background">
|
238
|
+
<div
|
239
|
+
class="flex h-full items-center border-l border-border/[0.16] bg-foreground/[0.04] px-1"
|
240
|
+
>
|
241
|
+
<BuiButton
|
242
|
+
variant="ghost"
|
243
|
+
class="flex h-8 w-8 items-center justify-center text-foreground"
|
244
|
+
>
|
245
|
+
<Settings2Icon class="h-4 w-4 flex-shrink-0 opacity-50" />
|
246
|
+
</BuiButton>
|
247
|
+
</div>
|
248
|
+
</div>
|
249
|
+
</BuiPopoverTrigger>
|
250
|
+
<BuiPopoverContent class="w-[250px] p-0" align="start">
|
251
|
+
<BuiCommand>
|
252
|
+
<BuiCommandInput
|
253
|
+
:placeholder="columnSearchPlaceholder"
|
254
|
+
v-model="searchColumn"
|
255
|
+
@input="(event) => (searchColumn = event.target.value)"
|
256
|
+
/>
|
257
|
+
<BuiCommandList>
|
258
|
+
<BuiScrollArea class="h-[300px]">
|
259
|
+
<BuiCommandEmpty>{{ columnSearchNotFound }}</BuiCommandEmpty>
|
260
|
+
<BuiDataTableColumnList
|
261
|
+
v-model:columns-list="columnsList as Column<TData, unknown>[]"
|
262
|
+
/>
|
263
|
+
</BuiScrollArea>
|
264
|
+
</BuiCommandList>
|
265
|
+
</BuiCommand>
|
266
|
+
</BuiPopoverContent>
|
267
|
+
</BuiPopover>
|
268
|
+
</template>
|
269
|
+
<BuiTableHeader v-if="tableHeaders" :freeze-header="props.freezeHeader">
|
270
|
+
<BuiTableHead
|
271
|
+
v-for="header in tableHeaders"
|
272
|
+
:key="header.id"
|
273
|
+
:style="{ ...getPinningStyle(header.column), width: header.getSize() + 'px' }"
|
274
|
+
:freeze-header="props.freezeHeader"
|
275
|
+
>
|
276
|
+
<FlexRender
|
277
|
+
v-if="!header.isPlaceholder"
|
278
|
+
:render="header.column.columnDef.header"
|
279
|
+
:props="header.getContext()"
|
280
|
+
/>
|
281
|
+
<div
|
282
|
+
@dblclick="() => header.column.resetSize()"
|
283
|
+
@mousedown="header.getResizeHandler()?.($event)"
|
284
|
+
:className="
|
285
|
+
cn(
|
286
|
+
'absolute top-0 right-0 h-full w-1 bg-muted-foreground opacity-0 cursor-col-resize select-none touch-none hover:opacity-50',
|
287
|
+
header.column.getIsResizing() ? 'bg-primary opacity-50' : ''
|
288
|
+
)
|
289
|
+
"
|
290
|
+
/>
|
291
|
+
</BuiTableHead>
|
175
292
|
</BuiTableHeader>
|
176
293
|
<BuiTableBody>
|
177
294
|
<template v-if="table.getRowModel().rows?.length">
|
@@ -0,0 +1,34 @@
|
|
1
|
+
<script setup lang="ts" generic="TData, TValue">
|
2
|
+
import type { Column } from '@tanstack/vue-table'
|
3
|
+
import { useTemplateRef } from 'vue'
|
4
|
+
|
5
|
+
import { BuiCommandItem } from '@/components/ui/command'
|
6
|
+
import { BuiCheckbox } from '@/components/ui/checkbox'
|
7
|
+
import { useSortable } from '@vueuse/integrations/useSortable'
|
8
|
+
|
9
|
+
const columnsListRef = useTemplateRef<HTMLElement>('columnsListRef')
|
10
|
+
const columnsList = defineModel<Column<TData, unknown>[]>('columnsList', {
|
11
|
+
default: [],
|
12
|
+
required: true
|
13
|
+
})
|
14
|
+
useSortable(columnsListRef, columnsList, { handle: '.dragHandler' })
|
15
|
+
</script>
|
16
|
+
|
17
|
+
<template>
|
18
|
+
<div ref="columnsListRef">
|
19
|
+
<BuiCommandItem
|
20
|
+
v-for="col in columnsList"
|
21
|
+
:key="`column-${col.id}`"
|
22
|
+
:value="col.id"
|
23
|
+
class="flex gap-4 px-2 py-1.5 text-xs font-medium capitalize text-muted-foreground"
|
24
|
+
@select="col.toggleVisibility()"
|
25
|
+
>
|
26
|
+
<BuiCheckbox :checked="col.getIsVisible()" />
|
27
|
+
<div class="dragHandler grow">
|
28
|
+
{{
|
29
|
+
col.columnDef.meta?.title || col.id.replace(/^values\./, '').replace(/([A-Z])/g, ' $1')
|
30
|
+
}}
|
31
|
+
</div>
|
32
|
+
</BuiCommandItem>
|
33
|
+
</div>
|
34
|
+
</template>
|
@@ -7,6 +7,7 @@ const props = defineProps<{ class?: string }>()
|
|
7
7
|
|
8
8
|
<template>
|
9
9
|
<BuiScrollArea class="w-full grow overflow-auto rounded border border-border/[0.16]">
|
10
|
+
<slot name="columnVisibility" />
|
10
11
|
<table :class="cn('w-full caption-top text-sm', props.class)">
|
11
12
|
<slot />
|
12
13
|
</table>
|
@@ -14,8 +14,8 @@ const props = defineProps<{
|
|
14
14
|
'[&_tr]:border-border/[0.16]',
|
15
15
|
props.class,
|
16
16
|
props.freezeHeader
|
17
|
-
? 'sticky top-0 z-[1] [&_th:first-child>div>div]:pl-6 [&_th:last-child>div>div]:border-r-0 [&_th:last-child>div>div]:pr-
|
18
|
-
: '[&_th:first-child>div]:pl-6 [&_th:last-child>div]:border-0 [&_th:last-child>div]:pr-
|
17
|
+
? 'sticky top-0 z-[1] [&_th:first-child>div>div]:pl-6 [&_th:last-child>div>div]:border-r-0 [&_th:last-child>div>div]:pr-14 [&_tr:last-child]:border-b-0'
|
18
|
+
: '[&_th:first-child>div]:pl-6 [&_th:last-child>div]:border-0 [&_th:last-child>div]:pr-14 [&_tr]:border-b'
|
19
19
|
)
|
20
20
|
"
|
21
21
|
>
|
@@ -12,12 +12,15 @@ export { default as BuiTableCaption } from './BuiTableCaption.vue'
|
|
12
12
|
export { default as BuiTableEmpty } from './BuiTableEmpty.vue'
|
13
13
|
export { default as BuiTableFooter } from './BuiTableFooter.vue'
|
14
14
|
export { default as BuiDataTable } from './BuiDataTable.vue'
|
15
|
+
export { default as BuiDataTableColumnList } from './BuiDataTableColumnList.vue'
|
15
16
|
|
16
17
|
export function getPinningStyle<TData>(column: Column<TData, unknown>): CSSProperties {
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
// FYI sticky columns not possible with transparent background colors
|
19
|
+
// const isPinned = column.getIsPinned()
|
20
|
+
// return {
|
21
|
+
// left: isPinned === 'left' ? '0' : undefined,
|
22
|
+
// position: isPinned ? 'sticky' : 'relative',
|
23
|
+
// zIndex: isPinned ? '1' : '0'
|
24
|
+
// }
|
25
|
+
return { position: 'relative' }
|
23
26
|
}
|
@@ -1,27 +0,0 @@
|
|
1
|
-
import { defineComponent as a, openBlock as s, createBlock as n, unref as o, withCtx as l, createElementVNode as c, normalizeClass as m, renderSlot as i, createVNode as f } from "vue";
|
2
|
-
import { _ as p } from "./BuiScrollArea.vue_vue_type_script_setup_true_lang-D-nqw_Ka.js";
|
3
|
-
import { _ } from "./BuiScrollBar.vue_vue_type_script_setup_true_lang-DNZ_v7U0.js";
|
4
|
-
import { g as d } from "./utils-CwP7Up6y.js";
|
5
|
-
const B = /* @__PURE__ */ a({
|
6
|
-
__name: "BuiTable",
|
7
|
-
props: {
|
8
|
-
class: {}
|
9
|
-
},
|
10
|
-
setup(e) {
|
11
|
-
const r = e;
|
12
|
-
return (t, u) => (s(), n(o(p), { class: "w-full grow overflow-auto rounded border border-border/[0.16]" }, {
|
13
|
-
default: l(() => [
|
14
|
-
c("table", {
|
15
|
-
class: m(o(d)("w-full caption-top text-sm", r.class))
|
16
|
-
}, [
|
17
|
-
i(t.$slots, "default")
|
18
|
-
], 2),
|
19
|
-
f(o(_), { orientation: "horizontal" })
|
20
|
-
]),
|
21
|
-
_: 3
|
22
|
-
}));
|
23
|
-
}
|
24
|
-
});
|
25
|
-
export {
|
26
|
-
B as _
|
27
|
-
};
|