@bsol-oss/react-datatable5 1.0.5 → 1.0.6
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.d.ts +53 -0
- package/dist/index.js +188 -5
- package/dist/index.mjs +200 -0
- package/dist/index.mts +113 -0
- package/dist/index.ts +125 -0
- package/dist/types/components/DataTable.d.ts +1 -2
- package/dist/types/components/DataTableContext.d.ts +1 -2
- package/dist/types/components/EditFilterButton.d.ts +1 -2
- package/dist/types/components/EditSortingButton.d.ts +1 -2
- package/dist/types/components/EditViewButton.d.ts +1 -2
- package/dist/types/components/PageSizeControl.d.ts +1 -2
- package/dist/types/components/ResetFilteringButton.d.ts +1 -2
- package/dist/types/components/ResetSortingButton.d.ts +1 -2
- package/dist/types/components/Table.d.ts +1 -2
- package/dist/types/components/TableBody.d.ts +1 -2
- package/dist/types/components/TableCardContainer.d.ts +2 -3
- package/dist/types/components/TableCards.d.ts +1 -2
- package/dist/types/components/TableFilter.d.ts +1 -2
- package/dist/types/components/TableFooter.d.ts +0 -1
- package/dist/types/components/TableHeader.d.ts +1 -2
- package/dist/types/components/TablePagination.d.ts +1 -2
- package/dist/types/components/TableSorter.d.ts +1 -2
- package/dist/types/components/TextCell.d.ts +1 -2
- package/dist/types/components/useDataFromUrl.d.ts +3 -4
- package/package.json +11 -4
- package/.cache/storybook/default/dev-server/a5a8bf6e622aef57065c6498611f40c911543d7d-3920d97c51b8ad2521918fb1205babd22b0ed3d7 +0 -1
- package/.cache/storybook/default/dev-server/a5a8bf6e622aef57065c6498611f40c911543d7d-43fdebe5fc35e4e9fabee9a83c7faea931b05ea0 +0 -1
- package/.cache/storybook/default/dev-server/a5a8bf6e622aef57065c6498611f40c911543d7d-f086b87885981c04ce7a583ff90a49313de83de7 +0 -1
- package/.eslintrc.cjs +0 -19
- package/.prettierignore +0 -4
- package/.storybook/main.ts +0 -20
- package/.storybook/preview.ts +0 -14
- package/prettier.json +0 -6
- package/rollup.config.js +0 -10
- package/src/assets/react.svg +0 -1
- package/src/components/DataTable.tsx +0 -112
- package/src/components/DataTableContext.tsx +0 -12
- package/src/components/EditFilterButton.tsx +0 -37
- package/src/components/EditSortingButton.tsx +0 -37
- package/src/components/EditViewButton.tsx +0 -46
- package/src/components/PageSizeControl.tsx +0 -29
- package/src/components/ResetFilteringButton.tsx +0 -18
- package/src/components/ResetSortingButton.tsx +0 -18
- package/src/components/Table.tsx +0 -20
- package/src/components/TableBody.tsx +0 -23
- package/src/components/TableCardContainer.tsx +0 -22
- package/src/components/TableCards.tsx +0 -36
- package/src/components/TableFilter.tsx +0 -34
- package/src/components/TableFooter.tsx +0 -27
- package/src/components/TableHeader.tsx +0 -106
- package/src/components/TablePagination.tsx +0 -58
- package/src/components/TableSorter.tsx +0 -62
- package/src/components/TextCell.tsx +0 -18
- package/src/components/useDataFromUrl.tsx +0 -52
- package/src/components/useDataTable.tsx +0 -7
- package/src/index.tsx +0 -12
- package/src/stories/CardViewShowcase.tsx +0 -103
- package/src/stories/DataTable.stories.tsx +0 -30
- package/src/stories/TableViewShowcase.tsx +0 -105
- package/src/vite-env.d.ts +0 -1
- package/tsconfig.json +0 -26
- package/tsconfig.node.json +0 -11
- package/vite.config.ts +0 -7
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
// import React from 'react';
|
|
2
|
-
import { ButtonGroup, ChakraProvider, theme } from "@chakra-ui/react";
|
|
3
|
-
import { ColumnDef, createColumnHelper } from "@tanstack/react-table";
|
|
4
|
-
import DataTable from "../components/DataTable";
|
|
5
|
-
import EditFilterButton from "../components/EditFilterButton";
|
|
6
|
-
import EditSortingButton from "../components/EditSortingButton";
|
|
7
|
-
import EditViewButton from "../components/EditViewButton";
|
|
8
|
-
import PageSizeControl from "../components/PageSizeControl";
|
|
9
|
-
import TableCardContainer from "../components/TableCardContainer";
|
|
10
|
-
import TableCards from "../components/TableCards";
|
|
11
|
-
import TablePagination from "../components/TablePagination";
|
|
12
|
-
import TextCell from "../components/TextCell";
|
|
13
|
-
|
|
14
|
-
interface ChatRecord {
|
|
15
|
-
session_id: string;
|
|
16
|
-
last_user_message: string;
|
|
17
|
-
last_system_response: string;
|
|
18
|
-
total_token: number;
|
|
19
|
-
total_prompt_tokens: number;
|
|
20
|
-
total_completion_tokens: number;
|
|
21
|
-
total_normalise_tokens: number;
|
|
22
|
-
chat_type: string;
|
|
23
|
-
model: string;
|
|
24
|
-
created_by: string;
|
|
25
|
-
last_update: string;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
interface RowActionsProps {
|
|
29
|
-
row: ChatRecord;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const RowActions = ({ row }: RowActionsProps) => {
|
|
33
|
-
return <>no actions</>;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const CardViewShowcase = () => {
|
|
37
|
-
const columnHelper = createColumnHelper<ChatRecord>();
|
|
38
|
-
|
|
39
|
-
const columns: ColumnDef<ChatRecord>[] = [
|
|
40
|
-
// Display Column
|
|
41
|
-
columnHelper.display({
|
|
42
|
-
id: "actions",
|
|
43
|
-
header: () => <span>Actions</span>,
|
|
44
|
-
cell: (props) => <RowActions row={props.row.original} />,
|
|
45
|
-
}),
|
|
46
|
-
|
|
47
|
-
// Grouping Column
|
|
48
|
-
columnHelper.group({
|
|
49
|
-
header: "Information",
|
|
50
|
-
footer: (props) => props.column.id,
|
|
51
|
-
columns: [
|
|
52
|
-
columnHelper.accessor("session_id", {
|
|
53
|
-
cell: (props) => {
|
|
54
|
-
return <TextCell>{props.row.original.session_id}</TextCell>;
|
|
55
|
-
},
|
|
56
|
-
header: () => <span>Session Id</span>,
|
|
57
|
-
footer: (props) => props.column.id,
|
|
58
|
-
}),
|
|
59
|
-
columnHelper.accessor("last_user_message", {
|
|
60
|
-
cell: (props) => {
|
|
61
|
-
return <TextCell>{props.row.original.last_user_message}</TextCell>;
|
|
62
|
-
},
|
|
63
|
-
|
|
64
|
-
header: () => <span>User Message</span>,
|
|
65
|
-
footer: (props) => props.column.id,
|
|
66
|
-
}),
|
|
67
|
-
// Accessor Column
|
|
68
|
-
columnHelper.accessor("total_token", {
|
|
69
|
-
cell: (props) => {
|
|
70
|
-
return <TextCell>{props.row.original.total_token}</TextCell>;
|
|
71
|
-
},
|
|
72
|
-
header: () => <span>Total Token</span>,
|
|
73
|
-
footer: (props) => props.column.id,
|
|
74
|
-
sortDescFirst: false,
|
|
75
|
-
}),
|
|
76
|
-
],
|
|
77
|
-
}),
|
|
78
|
-
];
|
|
79
|
-
|
|
80
|
-
return (
|
|
81
|
-
<ChakraProvider theme={theme}>
|
|
82
|
-
<DataTable
|
|
83
|
-
columns={columns}
|
|
84
|
-
url={"http://localhost:8333/api/v1/gpt/chat/history/all"}
|
|
85
|
-
>
|
|
86
|
-
<TablePagination />
|
|
87
|
-
<ButtonGroup isAttached>
|
|
88
|
-
<EditViewButton />
|
|
89
|
-
<EditFilterButton />
|
|
90
|
-
<EditSortingButton />
|
|
91
|
-
</ButtonGroup>
|
|
92
|
-
|
|
93
|
-
<TableCardContainer>
|
|
94
|
-
<TableCards />
|
|
95
|
-
</TableCardContainer>
|
|
96
|
-
<PageSizeControl />
|
|
97
|
-
<TablePagination />
|
|
98
|
-
</DataTable>
|
|
99
|
-
</ChakraProvider>
|
|
100
|
-
);
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
export default CardViewShowcase;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
-
import TableViewShowcase from "./TableViewShowcase";
|
|
3
|
-
import CardViewShowcase from "./CardViewShowcase";
|
|
4
|
-
|
|
5
|
-
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
|
|
6
|
-
const meta = {
|
|
7
|
-
title: "DataTable/TableView",
|
|
8
|
-
component: TableViewShowcase,
|
|
9
|
-
parameters: {
|
|
10
|
-
},
|
|
11
|
-
|
|
12
|
-
argTypes: {
|
|
13
|
-
},
|
|
14
|
-
|
|
15
|
-
} satisfies Meta<typeof TableViewShowcase>;
|
|
16
|
-
|
|
17
|
-
export default meta;
|
|
18
|
-
type Story = StoryObj<typeof meta>;
|
|
19
|
-
|
|
20
|
-
export const TableView: Story = {
|
|
21
|
-
render: () => {
|
|
22
|
-
return <TableViewShowcase />;
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export const CardView = {
|
|
27
|
-
render: () => {
|
|
28
|
-
return <CardViewShowcase />;
|
|
29
|
-
},
|
|
30
|
-
};
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
// import React from 'react';
|
|
2
|
-
import { ChakraProvider, theme } from "@chakra-ui/react";
|
|
3
|
-
import { ColumnDef, createColumnHelper } from "@tanstack/react-table";
|
|
4
|
-
import DataTable from "../components/DataTable";
|
|
5
|
-
import EditViewButton from "../components/EditViewButton";
|
|
6
|
-
import PageSizeControl from "../components/PageSizeControl";
|
|
7
|
-
import ResetFilteringButton from "../components/ResetFilteringButton";
|
|
8
|
-
import ResetSortingButton from "../components/ResetSortingButton";
|
|
9
|
-
import Table from "../components/Table";
|
|
10
|
-
import TableBody from "../components/TableBody";
|
|
11
|
-
import TableFilter from "../components/TableFilter";
|
|
12
|
-
import TableFooter from "../components/TableFooter";
|
|
13
|
-
import TableHeader from "../components/TableHeader";
|
|
14
|
-
import TablePagination from "../components/TablePagination";
|
|
15
|
-
import TextCell from "../components/TextCell";
|
|
16
|
-
|
|
17
|
-
interface ChatRecord {
|
|
18
|
-
session_id: string;
|
|
19
|
-
last_user_message: string;
|
|
20
|
-
last_system_response: string;
|
|
21
|
-
total_token: number;
|
|
22
|
-
total_prompt_tokens: number;
|
|
23
|
-
total_completion_tokens: number;
|
|
24
|
-
total_normalise_tokens: number;
|
|
25
|
-
chat_type: string;
|
|
26
|
-
model: string;
|
|
27
|
-
created_by: string;
|
|
28
|
-
last_update: string;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
interface RowActionsProps {
|
|
32
|
-
row: ChatRecord;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const RowActions = ({ row }: RowActionsProps) => {
|
|
36
|
-
return <>has no actions</>;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const TableViewShowcase = () => {
|
|
40
|
-
const columnHelper = createColumnHelper<ChatRecord>();
|
|
41
|
-
|
|
42
|
-
const columns: ColumnDef<ChatRecord>[] = [
|
|
43
|
-
// Display Column
|
|
44
|
-
columnHelper.display({
|
|
45
|
-
id: "actions",
|
|
46
|
-
header: () => <span>Actions</span>,
|
|
47
|
-
cell: (props) => <RowActions row={props.row.original} />,
|
|
48
|
-
}),
|
|
49
|
-
|
|
50
|
-
// Grouping Column
|
|
51
|
-
columnHelper.group({
|
|
52
|
-
header: "Information",
|
|
53
|
-
footer: (props) => props.column.id,
|
|
54
|
-
columns: [
|
|
55
|
-
columnHelper.accessor("session_id", {
|
|
56
|
-
cell: (props) => {
|
|
57
|
-
return <TextCell>{props.row.original.session_id}</TextCell>;
|
|
58
|
-
},
|
|
59
|
-
header: () => <span>Session Id</span>,
|
|
60
|
-
footer: (props) => props.column.id,
|
|
61
|
-
}),
|
|
62
|
-
columnHelper.accessor("last_user_message", {
|
|
63
|
-
cell: (props) => {
|
|
64
|
-
return <TextCell>{props.row.original.last_user_message}</TextCell>;
|
|
65
|
-
},
|
|
66
|
-
|
|
67
|
-
header: () => <span>User Message</span>,
|
|
68
|
-
footer: (props) => props.column.id,
|
|
69
|
-
}),
|
|
70
|
-
// Accessor Column
|
|
71
|
-
columnHelper.accessor("total_token", {
|
|
72
|
-
cell: (props) => {
|
|
73
|
-
return <TextCell>{props.row.original.total_token}</TextCell>;
|
|
74
|
-
},
|
|
75
|
-
header: () => <span>Total Token</span>,
|
|
76
|
-
footer: (props) => props.column.id,
|
|
77
|
-
sortDescFirst: false,
|
|
78
|
-
}),
|
|
79
|
-
],
|
|
80
|
-
}),
|
|
81
|
-
];
|
|
82
|
-
|
|
83
|
-
return (
|
|
84
|
-
<ChakraProvider theme={theme}>
|
|
85
|
-
<DataTable
|
|
86
|
-
columns={columns}
|
|
87
|
-
url={"http://localhost:8333/api/v1/gpt/chat/history/all"}
|
|
88
|
-
>
|
|
89
|
-
<EditViewButton />
|
|
90
|
-
<ResetSortingButton />
|
|
91
|
-
<TableFilter />
|
|
92
|
-
<ResetFilteringButton />
|
|
93
|
-
<Table>
|
|
94
|
-
<TableHeader />
|
|
95
|
-
<TableBody />
|
|
96
|
-
<TableFooter />
|
|
97
|
-
</Table>
|
|
98
|
-
<PageSizeControl />
|
|
99
|
-
<TablePagination />
|
|
100
|
-
</DataTable>
|
|
101
|
-
</ChakraProvider>
|
|
102
|
-
);
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
export default TableViewShowcase;
|
package/src/vite-env.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/// <reference types="vite/client" />
|
package/tsconfig.json
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"declaration": true,
|
|
4
|
-
"outDir": "./dist/types",
|
|
5
|
-
"target": "ES2020",
|
|
6
|
-
"useDefineForClassFields": true,
|
|
7
|
-
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
|
8
|
-
"module": "ESNext",
|
|
9
|
-
"skipLibCheck": true,
|
|
10
|
-
|
|
11
|
-
/* Bundler mode */
|
|
12
|
-
"moduleResolution": "bundler",
|
|
13
|
-
"allowImportingTsExtensions": true,
|
|
14
|
-
"resolveJsonModule": true,
|
|
15
|
-
"isolatedModules": true,
|
|
16
|
-
"noEmit": true,
|
|
17
|
-
"jsx": "react-jsx",
|
|
18
|
-
/* Linting */
|
|
19
|
-
"strict": true,
|
|
20
|
-
"noUnusedLocals": true,
|
|
21
|
-
"noUnusedParameters": true,
|
|
22
|
-
"noFallthroughCasesInSwitch": true
|
|
23
|
-
},
|
|
24
|
-
"include": ["src"],
|
|
25
|
-
"references": [{ "path": "./tsconfig.node.json" }]
|
|
26
|
-
}
|
package/tsconfig.node.json
DELETED