refine-mantine 1.2.0 → 1.2.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.
- package/dist/index.js +14 -18
- package/package.json +1 -1
- package/src/components/table/Table.story.tsx +25 -3
- package/src/components/table/Table.tsx +41 -43
package/dist/index.js
CHANGED
|
@@ -1077,26 +1077,22 @@ const ColumnSorter = (p) => {
|
|
|
1077
1077
|
|
|
1078
1078
|
//#endregion
|
|
1079
1079
|
//#region src/components/table/Table.tsx
|
|
1080
|
-
const Table = ({ props, tableProps }) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */
|
|
1081
|
-
|
|
1082
|
-
children: /* @__PURE__ */
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
children:
|
|
1080
|
+
const Table = ({ props, tableProps }) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(Table$1, {
|
|
1081
|
+
...tableProps,
|
|
1082
|
+
children: [/* @__PURE__ */ jsx(Table$1.Thead, { children: props.reactTable.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx(Table$1.Tr, { children: headerGroup.headers.map((header) => /* @__PURE__ */ jsx(Table$1.Th, {
|
|
1083
|
+
colSpan: header.colSpan,
|
|
1084
|
+
rowSpan: header.rowSpan,
|
|
1085
|
+
style: { width: header.getSize() },
|
|
1086
|
+
children: !header.isPlaceholder && /* @__PURE__ */ jsxs(Group, {
|
|
1087
|
+
gap: "xs",
|
|
1088
|
+
wrap: "nowrap",
|
|
1089
|
+
children: [/* @__PURE__ */ jsx(Box, { children: flexRender(header.column.columnDef.header, header.getContext()) }), /* @__PURE__ */ jsxs(Group, {
|
|
1090
1090
|
gap: "xs",
|
|
1091
1091
|
wrap: "nowrap",
|
|
1092
|
-
children: [/* @__PURE__ */ jsx(
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
})]
|
|
1097
|
-
})
|
|
1098
|
-
}, header.id)) }, headerGroup.id)) }), /* @__PURE__ */ jsx(Table$1.Tbody, { children: props.reactTable.getRowModel().rows.map((row) => /* @__PURE__ */ jsx(Table$1.Tr, { children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx(Table$1.Td, { children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id)) }, row.id)) })]
|
|
1099
|
-
})
|
|
1092
|
+
children: [/* @__PURE__ */ jsx(ColumnSorter, { column: header.column }), /* @__PURE__ */ jsx(ColumnFilter, { column: header.column })]
|
|
1093
|
+
})]
|
|
1094
|
+
})
|
|
1095
|
+
}, header.id)) }, headerGroup.id)) }), /* @__PURE__ */ jsx(Table$1.Tbody, { children: props.reactTable.getRowModel().rows.map((row) => /* @__PURE__ */ jsx(Table$1.Tr, { children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx(Table$1.Td, { children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id)) }, row.id)) })]
|
|
1100
1096
|
}), /* @__PURE__ */ jsx(Group, {
|
|
1101
1097
|
justify: "flex-end",
|
|
1102
1098
|
mt: "xl",
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@ import { type CrudOperators, useSelect } from "@refinedev/core";
|
|
|
3
3
|
import { useTable } from "@refinedev/react-table";
|
|
4
4
|
import type { Meta } from "@storybook/react";
|
|
5
5
|
import type { ColumnDef } from "@tanstack/react-table";
|
|
6
|
-
import { useCallback, useMemo } from "react";
|
|
6
|
+
import { use, useCallback, useMemo } from "react";
|
|
7
7
|
import { Table } from "./Table";
|
|
8
8
|
|
|
9
9
|
export default {
|
|
@@ -29,8 +29,8 @@ interface CategoryRecord {
|
|
|
29
29
|
|
|
30
30
|
type ProductRecordKey = keyof ProductRecord;
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
const useTableProps = () => {
|
|
33
|
+
const categories = useSelect<CategoryRecord>({
|
|
34
34
|
resource: "categories",
|
|
35
35
|
optionLabel: category => category.title,
|
|
36
36
|
optionValue: category => category.id.toString(),
|
|
@@ -139,7 +139,29 @@ export const Default = () => {
|
|
|
139
139
|
columns,
|
|
140
140
|
});
|
|
141
141
|
|
|
142
|
+
return tableProps;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export const Default = () => {
|
|
146
|
+
const tableProps = useTableProps();
|
|
147
|
+
|
|
142
148
|
return (
|
|
143
149
|
<Table props={tableProps} />
|
|
144
150
|
);
|
|
145
151
|
}
|
|
152
|
+
|
|
153
|
+
export const Striped = () => {
|
|
154
|
+
const tableProps = useTableProps();
|
|
155
|
+
|
|
156
|
+
return (
|
|
157
|
+
<Table props={tableProps} tableProps={{ striped: true }} />
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export const StickyHeader = () => {
|
|
162
|
+
const tableProps = useTableProps();
|
|
163
|
+
|
|
164
|
+
return (
|
|
165
|
+
<Table props={tableProps} tableProps={{ stickyHeader: true }} />
|
|
166
|
+
);
|
|
167
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Box, Group, Table as MantineTable, Pagination, TableProps } from "@mantine/core";
|
|
1
|
+
import { Box, Group, Table as MantineTable, Pagination, TableProps, TableScrollContainerProps } from "@mantine/core";
|
|
2
2
|
import type { BaseRecord, HttpError } from "@refinedev/core";
|
|
3
3
|
import type { UseTableReturnType } from "@refinedev/react-table";
|
|
4
4
|
import { flexRender } from "@tanstack/react-table";
|
|
@@ -16,50 +16,48 @@ export const Table = <
|
|
|
16
16
|
tableProps?: TableProps;
|
|
17
17
|
}) => (
|
|
18
18
|
<>
|
|
19
|
-
<MantineTable
|
|
20
|
-
<MantineTable
|
|
21
|
-
|
|
22
|
-
{
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
19
|
+
<MantineTable {...tableProps}>
|
|
20
|
+
<MantineTable.Thead>
|
|
21
|
+
{props.reactTable.getHeaderGroups().map((headerGroup) => (
|
|
22
|
+
<MantineTable.Tr key={headerGroup.id}>
|
|
23
|
+
{headerGroup.headers.map((header) => (
|
|
24
|
+
<MantineTable.Th
|
|
25
|
+
key={header.id}
|
|
26
|
+
colSpan={header.colSpan}
|
|
27
|
+
rowSpan={header.rowSpan}
|
|
28
|
+
style={{width: header.getSize()}}
|
|
29
|
+
>
|
|
30
|
+
{!header.isPlaceholder && (
|
|
31
|
+
<Group gap="xs" wrap="nowrap">
|
|
32
|
+
<Box>
|
|
33
|
+
{flexRender(
|
|
34
|
+
header.column.columnDef.header,
|
|
35
|
+
header.getContext(),
|
|
36
|
+
)}
|
|
37
|
+
</Box>
|
|
32
38
|
<Group gap="xs" wrap="nowrap">
|
|
33
|
-
<
|
|
34
|
-
|
|
35
|
-
header.column.columnDef.header,
|
|
36
|
-
header.getContext(),
|
|
37
|
-
)}
|
|
38
|
-
</Box>
|
|
39
|
-
<Group gap="xs" wrap="nowrap">
|
|
40
|
-
<ColumnSorter column={header.column} />
|
|
41
|
-
<ColumnFilter column={header.column} />
|
|
42
|
-
</Group>
|
|
39
|
+
<ColumnSorter column={header.column} />
|
|
40
|
+
<ColumnFilter column={header.column} />
|
|
43
41
|
</Group>
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
</MantineTable>
|
|
62
|
-
</MantineTable
|
|
42
|
+
</Group>
|
|
43
|
+
)}
|
|
44
|
+
</MantineTable.Th>
|
|
45
|
+
))}
|
|
46
|
+
</MantineTable.Tr>
|
|
47
|
+
))}
|
|
48
|
+
</MantineTable.Thead>
|
|
49
|
+
<MantineTable.Tbody>
|
|
50
|
+
{props.reactTable.getRowModel().rows.map((row) => (
|
|
51
|
+
<MantineTable.Tr key={row.id}>
|
|
52
|
+
{row.getVisibleCells().map((cell) => (
|
|
53
|
+
<MantineTable.Td key={cell.id}>
|
|
54
|
+
{flexRender(cell.column.columnDef.cell, cell.getContext())}
|
|
55
|
+
</MantineTable.Td>
|
|
56
|
+
))}
|
|
57
|
+
</MantineTable.Tr>
|
|
58
|
+
))}
|
|
59
|
+
</MantineTable.Tbody>
|
|
60
|
+
</MantineTable>
|
|
63
61
|
<Group justify="flex-end" mt="xl">
|
|
64
62
|
<Pagination
|
|
65
63
|
total={props.refineCore.pageCount}
|