@mantine-vue/table 2.2.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/README.md +340 -0
- package/cjs/index.cjs +5345 -0
- package/cjs/index.cjs.map +1 -0
- package/esm/index.mjs +5214 -0
- package/esm/index.mjs.map +1 -0
- package/lib/components/MVT_TableSlots.d.ts +103 -0
- package/lib/components/MantineVueTable.d.ts +18 -0
- package/lib/components/body/MVT_TableBody.d.ts +64 -0
- package/lib/components/body/MVT_TableBodyCell.d.ts +136 -0
- package/lib/components/body/MVT_TableBodyCellValue.d.ts +40 -0
- package/lib/components/body/MVT_TableBodyEmptyRow.d.ts +42 -0
- package/lib/components/body/MVT_TableBodyRow.d.ts +170 -0
- package/lib/components/body/MVT_TableBodyRowGrabHandle.d.ts +31 -0
- package/lib/components/body/MVT_TableBodyRowPinButton.d.ts +23 -0
- package/lib/components/body/MVT_TableDetailPanel.d.ts +68 -0
- package/lib/components/buttons/MVT_ColumnPinningButtons.d.ts +23 -0
- package/lib/components/buttons/MVT_CopyButton.d.ts +23 -0
- package/lib/components/buttons/MVT_EditActionButtons.d.ts +33 -0
- package/lib/components/buttons/MVT_ExpandAllButton.d.ts +15 -0
- package/lib/components/buttons/MVT_ExpandButton.d.ts +23 -0
- package/lib/components/buttons/MVT_GrabHandleButton.d.ts +41 -0
- package/lib/components/buttons/MVT_RowPinButton.d.ts +31 -0
- package/lib/components/buttons/MVT_ShowHideColumnsButton.d.ts +15 -0
- package/lib/components/buttons/MVT_ToggleDensePaddingButton.d.ts +15 -0
- package/lib/components/buttons/MVT_ToggleFiltersButton.d.ts +15 -0
- package/lib/components/buttons/MVT_ToggleFullScreenButton.d.ts +15 -0
- package/lib/components/buttons/MVT_ToggleGlobalFilterButton.d.ts +15 -0
- package/lib/components/buttons/MVT_ToggleRowActionMenuButton.d.ts +31 -0
- package/lib/components/footer/MVT_TableFooter.d.ts +25 -0
- package/lib/components/footer/MVT_TableFooterCell.d.ts +33 -0
- package/lib/components/footer/MVT_TableFooterRow.d.ts +33 -0
- package/lib/components/head/MVT_TableHead.d.ts +25 -0
- package/lib/components/head/MVT_TableHeadCell.d.ts +42 -0
- package/lib/components/head/MVT_TableHeadCellFilterContainer.d.ts +23 -0
- package/lib/components/head/MVT_TableHeadCellFilterLabel.d.ts +23 -0
- package/lib/components/head/MVT_TableHeadCellGrabHandle.d.ts +31 -0
- package/lib/components/head/MVT_TableHeadCellResizeHandle.d.ts +23 -0
- package/lib/components/head/MVT_TableHeadCellSortLabel.d.ts +23 -0
- package/lib/components/head/MVT_TableHeadRow.d.ts +33 -0
- package/lib/components/inputs/MVT_EditCellTextInput.d.ts +23 -0
- package/lib/components/inputs/MVT_FilterCheckbox.d.ts +23 -0
- package/lib/components/inputs/MVT_FilterRangeFields.d.ts +23 -0
- package/lib/components/inputs/MVT_FilterRangeSlider.d.ts +23 -0
- package/lib/components/inputs/MVT_FilterTextInput.d.ts +33 -0
- package/lib/components/inputs/MVT_GlobalFilterTextInput.d.ts +15 -0
- package/lib/components/inputs/MVT_SelectCheckbox.d.ts +34 -0
- package/lib/components/menus/MVT_ColumnActionMenu.d.ts +42 -0
- package/lib/components/menus/MVT_FilterOptionMenu.d.ts +35 -0
- package/lib/components/menus/MVT_RowActionMenu.d.ts +31 -0
- package/lib/components/menus/MVT_ShowHideColumnsMenu.d.ts +15 -0
- package/lib/components/menus/MVT_ShowHideColumnsMenuItems.d.ts +54 -0
- package/lib/components/modals/MVT_EditRowModal.d.ts +29 -0
- package/lib/components/table/MVT_Table.d.ts +15 -0
- package/lib/components/table/MVT_TableContainer.d.ts +15 -0
- package/lib/components/table/MVT_TablePaper.d.ts +15 -0
- package/lib/components/toolbar/MVT_BottomToolbar.d.ts +15 -0
- package/lib/components/toolbar/MVT_ProgressBar.d.ts +23 -0
- package/lib/components/toolbar/MVT_TablePagination.d.ts +25 -0
- package/lib/components/toolbar/MVT_ToolbarAlertBanner.d.ts +25 -0
- package/lib/components/toolbar/MVT_ToolbarDropZone.d.ts +15 -0
- package/lib/components/toolbar/MVT_ToolbarInternalButtons.d.ts +15 -0
- package/lib/components/toolbar/MVT_TopToolbar.d.ts +15 -0
- package/lib/fns/aggregationFns.d.ts +11 -0
- package/lib/fns/filterFns.d.ts +70 -0
- package/lib/fns/sortingFns.d.ts +12 -0
- package/lib/hooks/display-columns/getMVT_RowActionsColumnDef.d.ts +2 -0
- package/lib/hooks/display-columns/getMVT_RowDragColumnDef.d.ts +2 -0
- package/lib/hooks/display-columns/getMVT_RowExpandColumnDef.d.ts +2 -0
- package/lib/hooks/display-columns/getMVT_RowNumbersColumnDef.d.ts +2 -0
- package/lib/hooks/display-columns/getMVT_RowPinningColumnDef.d.ts +2 -0
- package/lib/hooks/display-columns/getMVT_RowSelectColumnDef.d.ts +2 -0
- package/lib/hooks/display-columns/getMVT_RowSpacerColumnDef.d.ts +2 -0
- package/lib/hooks/useMVT_ColumnVirtualizer.d.ts +3 -0
- package/lib/hooks/useMVT_Effects.d.ts +5 -0
- package/lib/hooks/useMVT_RowVirtualizer.d.ts +3 -0
- package/lib/hooks/useMVT_Rows.d.ts +6 -0
- package/lib/hooks/useMVT_TableInstance.d.ts +10 -0
- package/lib/hooks/useMVT_TableOptions.d.ts +25 -0
- package/lib/hooks/useMantineVueTable.d.ts +2 -0
- package/lib/icons.d.ts +36 -0
- package/lib/index.d.mts +75 -0
- package/lib/index.d.ts +75 -0
- package/lib/locales/ar.d.ts +2 -0
- package/lib/locales/az.d.ts +2 -0
- package/lib/locales/bg.d.ts +2 -0
- package/lib/locales/cs.d.ts +2 -0
- package/lib/locales/da.d.ts +2 -0
- package/lib/locales/de.d.ts +2 -0
- package/lib/locales/el.d.ts +2 -0
- package/lib/locales/en.d.ts +2 -0
- package/lib/locales/es.d.ts +2 -0
- package/lib/locales/et.d.ts +2 -0
- package/lib/locales/fa.d.ts +2 -0
- package/lib/locales/fi.d.ts +2 -0
- package/lib/locales/fr.d.ts +2 -0
- package/lib/locales/he.d.ts +2 -0
- package/lib/locales/hr.d.ts +2 -0
- package/lib/locales/hu.d.ts +2 -0
- package/lib/locales/hy.d.ts +2 -0
- package/lib/locales/id.d.ts +2 -0
- package/lib/locales/it.d.ts +2 -0
- package/lib/locales/ja.d.ts +2 -0
- package/lib/locales/ko.d.ts +2 -0
- package/lib/locales/nl.d.ts +2 -0
- package/lib/locales/no.d.ts +2 -0
- package/lib/locales/np.d.ts +2 -0
- package/lib/locales/pl.d.ts +2 -0
- package/lib/locales/pt-BR.d.ts +2 -0
- package/lib/locales/pt.d.ts +2 -0
- package/lib/locales/ro.d.ts +2 -0
- package/lib/locales/ru.d.ts +2 -0
- package/lib/locales/sk.d.ts +2 -0
- package/lib/locales/sr-Cyrl-RS.d.ts +2 -0
- package/lib/locales/sr-Latn-RS.d.ts +2 -0
- package/lib/locales/sv.d.ts +2 -0
- package/lib/locales/th.d.ts +2 -0
- package/lib/locales/tr.d.ts +2 -0
- package/lib/locales/uk.d.ts +2 -0
- package/lib/locales/vi.d.ts +2 -0
- package/lib/locales/zh-Hans.d.ts +2 -0
- package/lib/locales/zh-Hant.d.ts +2 -0
- package/lib/mantine.types.d.ts +32 -0
- package/lib/types.d.ts +887 -0
- package/lib/utils/column.utils.d.ts +9 -0
- package/lib/utils/displayColumn.utils.d.ts +17 -0
- package/lib/utils/row.utils.d.ts +16 -0
- package/lib/utils/style.utils.d.ts +8 -0
- package/lib/utils/tanstack.helpers.d.ts +14 -0
- package/lib/utils/utils.d.ts +1 -0
- package/lib/utils/virtualization.utils.d.ts +2 -0
- package/locales/ar.cjs +97 -0
- package/locales/ar.mjs +96 -0
- package/locales/az.cjs +97 -0
- package/locales/az.mjs +96 -0
- package/locales/bg.cjs +97 -0
- package/locales/bg.mjs +96 -0
- package/locales/cs.cjs +97 -0
- package/locales/cs.mjs +96 -0
- package/locales/da.cjs +97 -0
- package/locales/da.mjs +96 -0
- package/locales/de.cjs +97 -0
- package/locales/de.mjs +96 -0
- package/locales/el.cjs +97 -0
- package/locales/el.mjs +96 -0
- package/locales/en.cjs +97 -0
- package/locales/en.mjs +96 -0
- package/locales/es.cjs +97 -0
- package/locales/es.mjs +96 -0
- package/locales/et.cjs +97 -0
- package/locales/et.mjs +96 -0
- package/locales/fa.cjs +97 -0
- package/locales/fa.mjs +96 -0
- package/locales/fi.cjs +97 -0
- package/locales/fi.mjs +96 -0
- package/locales/fr.cjs +97 -0
- package/locales/fr.mjs +96 -0
- package/locales/he.cjs +97 -0
- package/locales/he.mjs +96 -0
- package/locales/hr.cjs +97 -0
- package/locales/hr.mjs +96 -0
- package/locales/hu.cjs +97 -0
- package/locales/hu.mjs +96 -0
- package/locales/hy.cjs +97 -0
- package/locales/hy.mjs +96 -0
- package/locales/id.cjs +97 -0
- package/locales/id.mjs +96 -0
- package/locales/it.cjs +97 -0
- package/locales/it.mjs +96 -0
- package/locales/ja.cjs +97 -0
- package/locales/ja.mjs +96 -0
- package/locales/ko.cjs +97 -0
- package/locales/ko.mjs +96 -0
- package/locales/nl.cjs +97 -0
- package/locales/nl.mjs +96 -0
- package/locales/no.cjs +97 -0
- package/locales/no.mjs +96 -0
- package/locales/np.cjs +97 -0
- package/locales/np.mjs +96 -0
- package/locales/pl.cjs +97 -0
- package/locales/pl.mjs +96 -0
- package/locales/pt-BR.cjs +97 -0
- package/locales/pt-BR.mjs +96 -0
- package/locales/pt.cjs +97 -0
- package/locales/pt.mjs +96 -0
- package/locales/ro.cjs +97 -0
- package/locales/ro.mjs +96 -0
- package/locales/ru.cjs +97 -0
- package/locales/ru.mjs +96 -0
- package/locales/sk.cjs +97 -0
- package/locales/sk.mjs +96 -0
- package/locales/sr-Cyrl-RS.cjs +97 -0
- package/locales/sr-Cyrl-RS.mjs +96 -0
- package/locales/sr-Latn-RS.cjs +97 -0
- package/locales/sr-Latn-RS.mjs +96 -0
- package/locales/sv.cjs +97 -0
- package/locales/sv.mjs +96 -0
- package/locales/th.cjs +97 -0
- package/locales/th.mjs +96 -0
- package/locales/tr.cjs +97 -0
- package/locales/tr.mjs +96 -0
- package/locales/uk.cjs +97 -0
- package/locales/uk.mjs +96 -0
- package/locales/vi.cjs +97 -0
- package/locales/vi.mjs +96 -0
- package/locales/zh-Hans.cjs +97 -0
- package/locales/zh-Hans.mjs +96 -0
- package/locales/zh-Hant.cjs +97 -0
- package/locales/zh-Hant.mjs +96 -0
- package/package.json +79 -0
- package/styles.css +1118 -0
- package/styles.layer.css +1120 -0
package/README.md
ADDED
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
# @mantine-vue/table
|
|
2
|
+
|
|
3
|
+
A fully featured Vue 3 data table built on [TanStack Table v8](https://tanstack.com/table/v8) and [Mantine Vue](https://github.com/) — a community port of [Mantine React Table](https://www.mantine-react-table.com/) to Vue.
|
|
4
|
+
|
|
5
|
+
> Mantine Vue is an independent community port of [Mantine](https://mantine.dev/) for Vue 3. It is not affiliated with or endorsed by the Mantine team. `@mantine-vue/table` is a port of Kevin Vandy's [Mantine React Table](https://www.mantine-react-table.com/); huge credit to that project and to [TanStack Table](https://tanstack.com/table/v8).
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- Sorting, filtering (per-column + global fuzzy), and pagination
|
|
10
|
+
- Row selection with checkboxes/radios/switches, including **shift-click range selection**
|
|
11
|
+
- Column ordering, pinning, resizing, hiding, and a per-column actions menu
|
|
12
|
+
- Row ordering (drag & drop) and row pinning
|
|
13
|
+
- Editing (cell, row, table, and modal display modes)
|
|
14
|
+
- Expandable detail panels and sub-row grouping/aggregation
|
|
15
|
+
- Row & column virtualization for large datasets
|
|
16
|
+
- Click-to-copy cells, sticky header/footer, full-screen, density toggle
|
|
17
|
+
- **Vue-native named slots** for every renderable section, alongside the equivalent render-prop options
|
|
18
|
+
- Fully reactive, controlled or uncontrolled state
|
|
19
|
+
- Written in strict TypeScript with complete type inference from your data
|
|
20
|
+
- Localization (i18n) support
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
`@mantine-vue/table` builds on Mantine Vue and TanStack, which are peer dependencies:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# npm
|
|
28
|
+
npm i @mantine-vue/table @mantine-vue/core @mantine-vue/hooks @mantine-vue/dates \
|
|
29
|
+
@tanstack/vue-table @tanstack/vue-virtual @tanstack/match-sorter-utils \
|
|
30
|
+
@tabler/icons-vue clsx dayjs
|
|
31
|
+
|
|
32
|
+
# yarn
|
|
33
|
+
yarn add @mantine-vue/table @mantine-vue/core @mantine-vue/hooks @mantine-vue/dates \
|
|
34
|
+
@tanstack/vue-table @tanstack/vue-virtual @tanstack/match-sorter-utils \
|
|
35
|
+
@tabler/icons-vue clsx dayjs
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Your app must be wrapped in a `MantineProvider` (from `@mantine-vue/core`), and you need to import the table styles once:
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
// main.ts
|
|
42
|
+
import '@mantine-vue/core/styles.css'
|
|
43
|
+
import '@mantine-vue/table/styles.css'
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Quick start
|
|
47
|
+
|
|
48
|
+
The recommended pattern is to build the table instance with the `useMantineVueTable` composable and pass it to the `<MantineVueTable>` component:
|
|
49
|
+
|
|
50
|
+
```vue
|
|
51
|
+
<script setup lang="ts">
|
|
52
|
+
import { ref } from 'vue'
|
|
53
|
+
import { MantineVueTable, useMantineVueTable, type MVT_ColumnDef } from '@mantine-vue/table'
|
|
54
|
+
|
|
55
|
+
interface Person {
|
|
56
|
+
age: number
|
|
57
|
+
firstName: string
|
|
58
|
+
lastName: string
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Define columns once (they should be stable).
|
|
62
|
+
const columns: MVT_ColumnDef<Person>[] = [
|
|
63
|
+
{ accessorKey: 'firstName', header: 'First Name' },
|
|
64
|
+
{ accessorKey: 'lastName', header: 'Last Name' },
|
|
65
|
+
{ accessorKey: 'age', header: 'Age' },
|
|
66
|
+
]
|
|
67
|
+
|
|
68
|
+
const data = ref<Person[]>([
|
|
69
|
+
{ firstName: 'Jane', lastName: 'Doe', age: 30 },
|
|
70
|
+
{ firstName: 'John', lastName: 'Smith', age: 25 },
|
|
71
|
+
])
|
|
72
|
+
|
|
73
|
+
// Build the instance with reactive getters so data/columns stay reactive.
|
|
74
|
+
const table = useMantineVueTable<Person>({
|
|
75
|
+
get columns() {
|
|
76
|
+
return columns
|
|
77
|
+
},
|
|
78
|
+
get data() {
|
|
79
|
+
return data.value
|
|
80
|
+
},
|
|
81
|
+
})
|
|
82
|
+
</script>
|
|
83
|
+
|
|
84
|
+
<template>
|
|
85
|
+
<MantineVueTable :table="table" />
|
|
86
|
+
</template>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
> **Why getters?** `useMantineVueTable` reads your options once. Passing `data`/`columns` as getters (`get data() { return data.value }`) keeps them reactive, so the table updates whenever your `ref` changes.
|
|
90
|
+
|
|
91
|
+
You can also pass options directly to the component without the composable — handy for simple, static tables:
|
|
92
|
+
|
|
93
|
+
```vue
|
|
94
|
+
<MantineVueTable :columns="columns" :data="data" />
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Columns
|
|
98
|
+
|
|
99
|
+
Columns are TanStack column definitions with extra options. Use `accessorKey` (supports dot-notation) or an `accessorFn` + `id`:
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
const columns: MVT_ColumnDef<Person>[] = [
|
|
103
|
+
{ accessorKey: 'name.first', header: 'First' }, // deep key
|
|
104
|
+
{ accessorFn: (row) => `${row.first} ${row.last}`, id: 'name', header: 'Name' },
|
|
105
|
+
{
|
|
106
|
+
accessorKey: 'age',
|
|
107
|
+
header: 'Age',
|
|
108
|
+
// Custom cell renderer (a function returning a Vue VNode)
|
|
109
|
+
Cell: ({ cell }) => h('strong', `${cell.getValue<number>()} yrs`),
|
|
110
|
+
},
|
|
111
|
+
]
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
A typed column helper is also available:
|
|
115
|
+
|
|
116
|
+
```ts
|
|
117
|
+
import { createMVTColumnHelper } from '@mantine-vue/table'
|
|
118
|
+
|
|
119
|
+
const columnHelper = createMVTColumnHelper<Person>()
|
|
120
|
+
const columns = [
|
|
121
|
+
columnHelper.accessor('firstName', { header: 'First Name' }),
|
|
122
|
+
columnHelper.accessor((row) => row.age, { id: 'age', header: 'Age' }),
|
|
123
|
+
]
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Features at a glance
|
|
127
|
+
|
|
128
|
+
Every feature is an `enable*` option. A few examples:
|
|
129
|
+
|
|
130
|
+
```ts
|
|
131
|
+
useMantineVueTable<Person>({
|
|
132
|
+
get columns() {
|
|
133
|
+
return columns
|
|
134
|
+
},
|
|
135
|
+
get data() {
|
|
136
|
+
return data.value
|
|
137
|
+
},
|
|
138
|
+
|
|
139
|
+
// interaction
|
|
140
|
+
enableSorting: true, // on by default
|
|
141
|
+
enableColumnFilters: true, // on by default
|
|
142
|
+
enableGlobalFilter: true, // on by default
|
|
143
|
+
enablePagination: true, // on by default
|
|
144
|
+
|
|
145
|
+
// selection
|
|
146
|
+
enableRowSelection: true,
|
|
147
|
+
enableBatchRowSelection: true, // shift-click range selection
|
|
148
|
+
|
|
149
|
+
// columns
|
|
150
|
+
enableColumnOrdering: true, // drag columns to reorder
|
|
151
|
+
enableColumnPinning: true,
|
|
152
|
+
enableColumnResizing: true,
|
|
153
|
+
|
|
154
|
+
// rows
|
|
155
|
+
enableRowOrdering: true, // drag rows (you apply the reorder, see below)
|
|
156
|
+
enableRowActions: true,
|
|
157
|
+
enableExpanding: true,
|
|
158
|
+
|
|
159
|
+
// performance
|
|
160
|
+
enableRowVirtualization: true,
|
|
161
|
+
})
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Reading & controlling state
|
|
165
|
+
|
|
166
|
+
State can be read at any time and controlled externally:
|
|
167
|
+
|
|
168
|
+
```ts
|
|
169
|
+
const table = useMantineVueTable<Person>({
|
|
170
|
+
/* … */
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
// read
|
|
174
|
+
table.getState().rowSelection
|
|
175
|
+
table.getSelectedRowModel().rows
|
|
176
|
+
|
|
177
|
+
// imperative
|
|
178
|
+
table.setPageIndex(0)
|
|
179
|
+
table.resetSorting()
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
To fully control a piece of state, pass it in `state` and handle the matching `onXChange`:
|
|
183
|
+
|
|
184
|
+
```ts
|
|
185
|
+
const sorting = ref<MVT_SortingState>([])
|
|
186
|
+
useMantineVueTable<Person>({
|
|
187
|
+
get columns() {
|
|
188
|
+
return columns
|
|
189
|
+
},
|
|
190
|
+
get data() {
|
|
191
|
+
return data.value
|
|
192
|
+
},
|
|
193
|
+
state: {
|
|
194
|
+
get sorting() {
|
|
195
|
+
return sorting.value
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
onSortingChange: (updater) => {
|
|
199
|
+
sorting.value = typeof updater === 'function' ? updater(sorting.value) : updater
|
|
200
|
+
},
|
|
201
|
+
})
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Row drag-and-drop
|
|
205
|
+
|
|
206
|
+
The table tracks the drag state (`draggingRow` / `hoveredRow`); you own the data, so apply the reorder on drop:
|
|
207
|
+
|
|
208
|
+
```ts
|
|
209
|
+
useMantineVueTable<Person>({
|
|
210
|
+
get columns() {
|
|
211
|
+
return columns
|
|
212
|
+
},
|
|
213
|
+
get data() {
|
|
214
|
+
return data.value
|
|
215
|
+
},
|
|
216
|
+
enableRowOrdering: true,
|
|
217
|
+
enableSorting: false,
|
|
218
|
+
mantineRowDragHandleProps: ({ table }) => ({
|
|
219
|
+
onDragEnd: () => {
|
|
220
|
+
const { draggingRow, hoveredRow } = table.getState()
|
|
221
|
+
if (hoveredRow && draggingRow) {
|
|
222
|
+
data.value.splice(hoveredRow.index, 0, data.value.splice(draggingRow.index, 1)[0])
|
|
223
|
+
data.value = [...data.value]
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
}),
|
|
227
|
+
})
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
> Use the `*Ordering` flags (`enableColumnOrdering` / `enableRowOrdering`) to reorder — the `*Dragging` flags only render a drag handle for custom use and do not track the drop target.
|
|
231
|
+
|
|
232
|
+
### Editing
|
|
233
|
+
|
|
234
|
+
```ts
|
|
235
|
+
useMantineVueTable<Person>({
|
|
236
|
+
get columns() {
|
|
237
|
+
return columns
|
|
238
|
+
},
|
|
239
|
+
get data() {
|
|
240
|
+
return data.value
|
|
241
|
+
},
|
|
242
|
+
enableEditing: true,
|
|
243
|
+
editDisplayMode: 'modal', // 'cell' | 'row' | 'table' | 'modal'
|
|
244
|
+
onEditingRowSave: ({ row, values, exitEditingMode }) => {
|
|
245
|
+
data.value[row.index] = values as Person
|
|
246
|
+
data.value = [...data.value]
|
|
247
|
+
exitEditingMode()
|
|
248
|
+
},
|
|
249
|
+
})
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
## Named slots (Vue-native) vs. render props
|
|
253
|
+
|
|
254
|
+
Every renderable section can be customized **either** with a Vue named slot on `<MantineVueTable>` **or** the equivalent `renderX` option. A named slot takes precedence, and both receive the same scoped argument:
|
|
255
|
+
|
|
256
|
+
```vue
|
|
257
|
+
<MantineVueTable :table="table">
|
|
258
|
+
<template #detailPanel="{ row }">Age: {{ row.original.age }}</template>
|
|
259
|
+
<template #rowActionMenuItems="{ row, table }">
|
|
260
|
+
<Menu.Item @click="() => table.setEditingRow(row)">Edit</Menu.Item>
|
|
261
|
+
</template>
|
|
262
|
+
<template #topToolbarCustomActions>
|
|
263
|
+
<Button>Export</Button>
|
|
264
|
+
</template>
|
|
265
|
+
</MantineVueTable>
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
| Named slot | Equivalent option |
|
|
269
|
+
| ---------------------------- | ---------------------------------- |
|
|
270
|
+
| `detailPanel` | `renderDetailPanel` |
|
|
271
|
+
| `rowActions` | `renderRowActions` |
|
|
272
|
+
| `rowActionMenuItems` | `renderRowActionMenuItems` |
|
|
273
|
+
| `columnActionsMenuItems` | `renderColumnActionsMenuItems` |
|
|
274
|
+
| `topToolbarCustomActions` | `renderTopToolbarCustomActions` |
|
|
275
|
+
| `bottomToolbarCustomActions` | `renderBottomToolbarCustomActions` |
|
|
276
|
+
| `toolbarInternalActions` | `renderToolbarInternalActions` |
|
|
277
|
+
| `emptyRowsFallback` | `renderEmptyRowsFallback` |
|
|
278
|
+
|
|
279
|
+
Column-level renderers (`Cell`, `Header`, `Footer`, `Edit`) stay on the column definition.
|
|
280
|
+
|
|
281
|
+
## Styling
|
|
282
|
+
|
|
283
|
+
- Import `@mantine-vue/table/styles.css` once (or `styles.layer.css` to use CSS layers).
|
|
284
|
+
- Pass Mantine props to any internal component via the `mantineXProps` options — e.g. `mantineTableProps`, `mantinePaperProps`, `mantineTableBodyCellProps`, `mantineRowDragHandleProps`. Each accepts an object or a function of context.
|
|
285
|
+
- Override the exposed `mvt-*` global classes (e.g. `.mvt-table-paper`, `.mvt-table-body-cell`) from your own CSS.
|
|
286
|
+
|
|
287
|
+
```ts
|
|
288
|
+
useMantineVueTable<Person>({
|
|
289
|
+
get columns() {
|
|
290
|
+
return columns
|
|
291
|
+
},
|
|
292
|
+
get data() {
|
|
293
|
+
return data.value
|
|
294
|
+
},
|
|
295
|
+
mantineTableProps: { striped: true, highlightOnHover: true },
|
|
296
|
+
mantinePaperProps: { shadow: 'md', radius: 'lg' },
|
|
297
|
+
})
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
## Localization
|
|
301
|
+
|
|
302
|
+
The English locale ships by default. Pass a custom `localization` (partial is merged over English):
|
|
303
|
+
|
|
304
|
+
```ts
|
|
305
|
+
import { MVT_Localization_EN } from '@mantine-vue/table/locales/en'
|
|
306
|
+
|
|
307
|
+
useMantineVueTable<Person>({
|
|
308
|
+
get columns() {
|
|
309
|
+
return columns
|
|
310
|
+
},
|
|
311
|
+
get data() {
|
|
312
|
+
return data.value
|
|
313
|
+
},
|
|
314
|
+
localization: { ...MVT_Localization_EN, actions: 'Options' },
|
|
315
|
+
})
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
## TypeScript
|
|
319
|
+
|
|
320
|
+
Everything is generic over your row type. Pass `<Person>` to `useMantineVueTable`/`MVT_ColumnDef` and cell/row callbacks are fully typed. Public types are exported with the `MVT_` prefix (`MVT_TableInstance`, `MVT_ColumnDef`, `MVT_Row`, `MVT_Cell`, `MVT_TableOptions`, `MVT_TableState`, …).
|
|
321
|
+
|
|
322
|
+
## Examples
|
|
323
|
+
|
|
324
|
+
Runnable demos live in [`examples/`](./examples):
|
|
325
|
+
|
|
326
|
+
- [`BasicExample.vue`](./examples/BasicExample.vue) — full-featured (ordering, pinning, resizing, selection, drag rows)
|
|
327
|
+
- [`MinimalExample.vue`](./examples/MinimalExample.vue) — the smallest possible table
|
|
328
|
+
- [`RowSelectionExample.vue`](./examples/RowSelectionExample.vue) — selection + batch + reading selected rows
|
|
329
|
+
- [`EditingExample.vue`](./examples/EditingExample.vue) — modal row editing with save
|
|
330
|
+
- [`DetailPanelSlotExample.vue`](./examples/DetailPanelSlotExample.vue) — named slots for detail panel & row actions
|
|
331
|
+
- [`RemoteDataExample.vue`](./examples/RemoteDataExample.vue) — server-side pagination/sorting/filtering
|
|
332
|
+
- [`VirtualizedExample.vue`](./examples/VirtualizedExample.vue) — 10,000 rows with row virtualization
|
|
333
|
+
|
|
334
|
+
## Credits
|
|
335
|
+
|
|
336
|
+
Ported from [Mantine React Table](https://www.mantine-react-table.com/) by Kevin Vandy. Built on [TanStack Table](https://tanstack.com/table/v8) and [TanStack Virtual](https://tanstack.com/virtual). Styled with [Mantine Vue](https://github.com/).
|
|
337
|
+
|
|
338
|
+
## License
|
|
339
|
+
|
|
340
|
+
MIT
|