@hw-component/table 0.0.6-beta-v9 → 0.0.6-beta-v12

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.
Files changed (50) hide show
  1. package/es/src/components/HTableHeader/index.d.ts +3 -0
  2. package/es/src/components/Table.d.ts +3 -0
  3. package/es/src/components/context.d.ts +23 -0
  4. package/es/src/components/hooks/index.d.ts +1 -0
  5. package/es/src/components/index.d.ts +11 -0
  6. package/es/src/components/modal.d.ts +100 -0
  7. package/lib/src/components/HTableHeader/index.d.ts +3 -0
  8. package/lib/src/components/Table.d.ts +3 -0
  9. package/lib/src/components/context.d.ts +23 -0
  10. package/lib/src/components/hooks/index.d.ts +1 -0
  11. package/lib/src/components/index.d.ts +11 -0
  12. package/lib/src/components/modal.d.ts +100 -0
  13. package/package.json +2 -2
  14. package/src/Layout.tsx +61 -0
  15. package/src/app.tsx +33 -0
  16. package/src/components/GoTop/goTop.png +0 -0
  17. package/src/components/GoTop/index.tsx +37 -0
  18. package/src/components/HTableBody/AlertMsg.tsx +37 -0
  19. package/src/components/HTableBody/RowSelection.tsx +143 -0
  20. package/src/components/HTableBody/hooks.tsx +72 -0
  21. package/src/components/HTableBody/index.tsx +148 -0
  22. package/src/components/HTableFooter/index.tsx +78 -0
  23. package/src/components/HTableHeader/defaultSubComponent.tsx +62 -0
  24. package/src/components/HTableHeader/hooks.tsx +164 -0
  25. package/src/components/HTableHeader/index.tsx +58 -0
  26. package/src/components/HTableHeader/modal.d.ts +15 -0
  27. package/src/components/HTablePagination/index.tsx +91 -0
  28. package/src/components/ModalTable/hooks.ts +60 -0
  29. package/src/components/ModalTable/index.tsx +78 -0
  30. package/src/components/Table.tsx +85 -0
  31. package/src/components/TableConfig.tsx +30 -0
  32. package/src/components/TableCustomize.tsx +71 -0
  33. package/src/components/context.ts +28 -0
  34. package/src/components/hooks/index.ts +14 -0
  35. package/src/components/hooks/useCurrentTable.ts +32 -0
  36. package/src/components/hooks/useDispatch.ts +8 -0
  37. package/src/components/hooks/useHTable.tsx +26 -0
  38. package/src/components/hooks/useReq.ts +65 -0
  39. package/src/components/hooks/useRowObj.ts +27 -0
  40. package/src/components/index.less +46 -0
  41. package/src/components/index.tsx +11 -0
  42. package/src/components/modal.ts +130 -0
  43. package/src/components/styles/local.less +1 -0
  44. package/src/index.less +21 -0
  45. package/src/index.tsx +12 -0
  46. package/src/pages/ModalTable/index.tsx +101 -0
  47. package/src/pages/Table/index.tsx +108 -0
  48. package/src/pages/TableCustomize/index.tsx +79 -0
  49. package/src/routes.tsx +37 -0
  50. package/src/typings.d.ts +46 -0
@@ -0,0 +1,130 @@
1
+ import type { ProColumns } from "@ant-design/pro-table/lib/typing";
2
+ import type { ProTableProps } from "@ant-design/pro-table";
3
+ import type {
4
+ HItemProps,
5
+ HFormInstance,
6
+ } from "@hw-component/form/es/Form/modal";
7
+ import type { ColProps } from "antd";
8
+ import type React from "react";
9
+ import type { ModalProps } from "antd";
10
+ import type { TableProps } from "antd/lib/table";
11
+ import type { AffixProps } from "antd/lib/affix";
12
+
13
+ export interface RowObj {
14
+ keys?: React.Key[];
15
+ rowData?: any[];
16
+ selectAll?: boolean;
17
+ }
18
+ export interface ResultModal {
19
+ records: any[];
20
+ current: string;
21
+ size: string;
22
+ total: string;
23
+ }
24
+ export interface ParamsModal extends Record<string, any> {
25
+ size?: number;
26
+ current?: number;
27
+ }
28
+ interface HColumns extends Omit<ProColumns, "render"> {
29
+ render?: (
30
+ dom: React.ReactNode,
31
+ data: any,
32
+ index: number,
33
+ tableInstance: HTableInstance
34
+ ) => React.ReactNode;
35
+ showSearch?: boolean;
36
+ searchType?: HItemProps["type"];
37
+ searchRender?: HItemProps["render"];
38
+ }
39
+ export type ConfigItemModal = Omit<HItemProps, "render" | "type"> & HColumns;
40
+ export type ConfigDataModal = ConfigItemModal[];
41
+ export type ActionRenderFn = (
42
+ selectedRowKeys: RowObj,
43
+ tableInstance: HTableInstance
44
+ ) => React.ReactNode;
45
+ export type FooterBtnRenderFn = (
46
+ dom: React.ReactNode,
47
+ total: string,
48
+ selectedRowKeys: RowObj,
49
+ setAllCheck: (row: RowObj) => void
50
+ ) => React.ReactNode;
51
+ export type actionFn = (...arg) => void;
52
+ type FooterRenderFn = (
53
+ tableInstance: HTableInstance,
54
+ selectedRowData: RowObj,
55
+ data?: ResultModal
56
+ ) => React.ReactNode;
57
+
58
+ export interface RowSelectionOuter {
59
+ allPageCheck?: boolean;
60
+ }
61
+ export type HRowSelection = RowSelectionOuter &
62
+ (TableProps<any>["rowSelection"] & {
63
+ alwaysShowAlert?: boolean;
64
+ });
65
+ export interface HTableProps
66
+ extends Omit<
67
+ ProTableProps<any, any>,
68
+ "request" | "dataSource" | "rowKey" | "rowSelection"
69
+ > {
70
+ request?: (params: ParamsModal) => Promise<ResultModal>;
71
+ configData: ConfigDataModal;
72
+ searchSpan?: ColProps;
73
+ table?: HTableInstance;
74
+ actionRender?: ActionRenderFn;
75
+ emptyRender?: (tableInstance: HTableInstance) => React.ReactNode;
76
+ errorRender?: (
77
+ tableInstance: HTableInstance,
78
+ error: Error
79
+ ) => React.ReactNode;
80
+ hideHeader?: boolean;
81
+ action?: Record<string, actionFn>;
82
+ headerStyle?: React.CSSProperties;
83
+ tableStyle?: React.CSSProperties;
84
+ spaceSize?: number;
85
+ className?: string;
86
+ error?: Error;
87
+ reload?: (params: any) => Promise<any>;
88
+ manual?: boolean;
89
+ dataSource?: ResultModal;
90
+ paginationStyle?: React.CSSProperties;
91
+ rowKey?: string;
92
+ allPageCheck?: boolean;
93
+ rowSelection?: HRowSelection | false;
94
+ affixProps?: AffixProps | false;
95
+ goTop?: boolean;
96
+ }
97
+ export interface TableInstance {
98
+ reload: (params?: ParamsModal) => Promise<any>;
99
+ setSelectedRowData: (keys: React.Key[], data: any) => void;
100
+ dispatch: (key: string, params: any) => void;
101
+ reloadWithParams: (params?: ParamsModal) => Promise<any>;
102
+ getParams: () => any;
103
+ }
104
+ export interface HTableInstance {
105
+ form: HFormInstance;
106
+ table: TableInstance;
107
+ }
108
+ export interface DialogParamsModal {
109
+ configData?: HTableProps["configData"];
110
+ request?: HTableProps["request"];
111
+ params?: Record<string, any>;
112
+ title?: string;
113
+ }
114
+ export interface HOnDiaLogTableInstance {
115
+ show: (params?: DialogParamsModal) => void;
116
+ hide: () => void;
117
+ }
118
+ export interface HDiaLogTableInstance {
119
+ form: HFormInstance;
120
+ table: TableInstance;
121
+ show: (params?: DialogParamsModal) => void;
122
+ hide: () => void;
123
+ }
124
+ export interface ModalTableProps extends ModalProps {
125
+ tableProps?: Omit<HTableProps, "configData" | "request">;
126
+ dialogTable?: HDiaLogTableInstance;
127
+ params?: Record<string, any>;
128
+ configData?: HTableProps["configData"];
129
+ request?: HTableProps["request"];
130
+ }
@@ -0,0 +1 @@
1
+ @ant-prefix: ant;
package/src/index.less ADDED
@@ -0,0 +1,21 @@
1
+ .layout {
2
+ position: fixed;
3
+ top: 0;
4
+ right: 0;
5
+ bottom: 0;
6
+ left: 0;
7
+ display: flex;
8
+ }
9
+ .menu {
10
+ width: 256px !important;
11
+ height: 100vh;
12
+ }
13
+
14
+ .body {
15
+ width: calc(100vw - 256px);
16
+ height: 100vh;
17
+ padding: 16px;
18
+ overflow: auto;
19
+ background-color: #ccc;
20
+
21
+ }
package/src/index.tsx ADDED
@@ -0,0 +1,12 @@
1
+ import { render } from "react-dom";
2
+ import App from "./app";
3
+ import React from "react";
4
+ import "antd/dist/antd.css";
5
+ import zhCN from "antd/es/locale/zh_CN";
6
+ import { ConfigProvider } from "antd";
7
+ render(
8
+ <ConfigProvider locale={zhCN}>
9
+ <App />
10
+ </ConfigProvider>,
11
+ document.getElementById("root")
12
+ );
@@ -0,0 +1,101 @@
1
+ import { Button } from "antd";
2
+ import { HModalTable, HTable, useHDialogTable } from "../../components";
3
+ const configData = [
4
+ {
5
+ title: "座位",
6
+ showSearch: true,
7
+ searchType: "select",
8
+ dataIndex: "name",
9
+ itemProps: {
10
+ options: [{ label: "1", value: 1 }],
11
+ },
12
+ },
13
+ {
14
+ title: "操作",
15
+ name: "aaa",
16
+ fixed: "right",
17
+ width: 200,
18
+ showSearch: true,
19
+ render: () => {
20
+ return <div>fff</div>;
21
+ },
22
+ },
23
+ ];
24
+ const req1 = (params) => {
25
+ console.log(params, "req1");
26
+ const { current = 1 } = params;
27
+ return new Promise((resolve, reject) => {
28
+ setTimeout(() => {
29
+ // reject(new Error("错误"));
30
+ resolve({
31
+ size: "10",
32
+ current: current.toString(10),
33
+ total: "100",
34
+ records: [
35
+ {
36
+ id: 1,
37
+ name: "111",
38
+ },
39
+ ],
40
+ });
41
+ }, 2000);
42
+ });
43
+ };
44
+
45
+ const req2 = (params) => {
46
+ console.log(params, "req2");
47
+ const { current = 1 } = params;
48
+ return new Promise((resolve, reject) => {
49
+ setTimeout(() => {
50
+ // reject(new Error("错误"));
51
+ resolve({
52
+ size: "10",
53
+ current: current.toString(10),
54
+ total: "100",
55
+ records: [
56
+ {
57
+ id: 1,
58
+ name: "111",
59
+ },
60
+ ],
61
+ });
62
+ }, 2000);
63
+ });
64
+ };
65
+ const Test = () => {
66
+ const dialogTable1 = useHDialogTable();
67
+
68
+ return (
69
+ <>
70
+ <HModalTable
71
+ dialogTable={dialogTable1}
72
+ title="111"
73
+ configData={configData}
74
+ />
75
+ <Button
76
+ onClick={() => {
77
+ dialogTable1.show();
78
+ }}
79
+ >
80
+ 点我
81
+ </Button>
82
+ </>
83
+ );
84
+ };
85
+ export default () => {
86
+ const dialogTable = useHDialogTable();
87
+ const dialogTable1 = useHDialogTable();
88
+ return (
89
+ <>
90
+ <Button
91
+ onClick={() => {
92
+ dialogTable.show({ title: "3333", request: req2 });
93
+ }}
94
+ >
95
+ 点我333
96
+ </Button>
97
+ <HModalTable dialogTable={dialogTable} configData={configData} />
98
+ <HTable configData={[]} headerTitle={<Test />} />
99
+ </>
100
+ );
101
+ };
@@ -0,0 +1,108 @@
1
+ import { HTable, useHTable } from "../../components";
2
+ import { Button } from "antd";
3
+ import { HFormConfigProvider } from "@hw-component/form";
4
+
5
+ const configData = [
6
+ {
7
+ title: "座位",
8
+ showSearch: true,
9
+ searchType: "select",
10
+ dataIndex: "name",
11
+ itemProps: {
12
+ options: [{ label: "1", value: 1 }],
13
+ },
14
+ },
15
+ {
16
+ title: "座位断开",
17
+ showSearch: true,
18
+ dataIndex: "name",
19
+ itemProps: {
20
+ options: [{ label: "1", value: 1 }],
21
+ },
22
+ },
23
+ {
24
+ title: "座位",
25
+ showSearch: true,
26
+ dataIndex: "name",
27
+ itemProps: {
28
+ options: [{ label: "1", value: 1 }],
29
+ },
30
+ },
31
+ {
32
+ title: "座位",
33
+ showSearch: true,
34
+ searchType: "select",
35
+ dataIndex: "name",
36
+ itemProps: {
37
+ options: [{ label: "1", value: 1 }],
38
+ },
39
+ },
40
+ {
41
+ title: "操作",
42
+ name: "aaa",
43
+ fixed: "right",
44
+ width: 200,
45
+ showSearch: true,
46
+ render: () => {
47
+ return <div>fff</div>;
48
+ },
49
+ },
50
+ ];
51
+ const Test = ({ name, selectedRowData }) => {
52
+ console.log(selectedRowData);
53
+ return <div>{name}</div>;
54
+ };
55
+ export default () => {
56
+ const hTable = useHTable();
57
+ return (
58
+ <HFormConfigProvider>
59
+ <div>
60
+ <HTable
61
+ configData={configData}
62
+ rowKey={"id"}
63
+ table={hTable}
64
+ rowSelection={{
65
+ getCheckboxProps: (item) => {
66
+ return {
67
+ disabled: item.id === 2,
68
+ };
69
+ },
70
+ }}
71
+ affixProps={{
72
+ target: () => document.querySelector(".body"),
73
+ }}
74
+ options={{
75
+ reload: false,
76
+ setting: false,
77
+ density: false,
78
+ }}
79
+ actionRender={() => {
80
+ return <Button>你大爷</Button>;
81
+ }}
82
+ headerTitle={<Button type={"primary"}>操作</Button>}
83
+ request={(params) => {
84
+ const { current = 1 } = params;
85
+ const arrayData = [];
86
+ for (let i = 0; i < 100; i = i + 1) {
87
+ arrayData.push({
88
+ id: i,
89
+ name: "11",
90
+ });
91
+ }
92
+ return new Promise((resolve, reject) => {
93
+ setTimeout(() => {
94
+ // reject(new Error("错误"));
95
+ resolve({
96
+ size: "100",
97
+ current: current.toString(10),
98
+ total: "100",
99
+ records: arrayData,
100
+ });
101
+ }, 2000);
102
+ });
103
+ }}
104
+ />
105
+ </div>
106
+ </HFormConfigProvider>
107
+ );
108
+ };
@@ -0,0 +1,79 @@
1
+ import {
2
+ TableCustomize,
3
+ HTableHeader,
4
+ HTableBody,
5
+ HTableFooter,
6
+ HTablePagination,
7
+ } from "../../components";
8
+ import { useRequest } from "ahooks";
9
+ import { Space } from "antd";
10
+
11
+ const configData = [
12
+ {
13
+ title: "座位",
14
+ showSearch: true,
15
+ searchType: "select",
16
+ dataIndex: "name",
17
+ },
18
+ {
19
+ title: "操作",
20
+ name: "aaa",
21
+ showSearch: true,
22
+ fixed: "right",
23
+ searchType: "rangePicker",
24
+ },
25
+ ];
26
+ const AddBtn = (props) => {
27
+ console.log(props);
28
+ return <div>fff</div>;
29
+ };
30
+ export default () => {
31
+ const { run, loading, error, data } = useRequest(
32
+ (params) => {
33
+ const { current = 1 } = params;
34
+ const arrayData = [];
35
+ for (let i = 0; i < 100; i = i + 1) {
36
+ arrayData.push({
37
+ id: i,
38
+ name: "11",
39
+ });
40
+ }
41
+ return new Promise((resolve, reject) => {
42
+ setTimeout(() => {
43
+ // reject(new Error("错误"));
44
+ resolve({
45
+ size: "10",
46
+ current: current.toString(10),
47
+ total: "100",
48
+ records: arrayData,
49
+ });
50
+ }, 2000);
51
+ });
52
+ },
53
+ { manual: true }
54
+ );
55
+ return (
56
+ <TableCustomize
57
+ configData={configData}
58
+ loading={loading}
59
+ error={error}
60
+ dataSource={data}
61
+ reload={run}
62
+ >
63
+ <Space direction={"vertical"} style={{ width: "100%" }}>
64
+ <HTableHeader />
65
+ <HTableBody
66
+ headerTitle={<AddBtn />}
67
+ affixProps={{
68
+ target: () => document.querySelector(".body"),
69
+ }}
70
+ rowSelection={{
71
+ onChange: () => {
72
+ console.log("rowSelection");
73
+ },
74
+ }}
75
+ />
76
+ </Space>
77
+ </TableCustomize>
78
+ );
79
+ };
package/src/routes.tsx ADDED
@@ -0,0 +1,37 @@
1
+ import React from "react";
2
+ import { Navigate } from "react-router-dom";
3
+ import Table from "./pages/Table";
4
+ import ModalTable from "./pages/ModalTable";
5
+ import TableCustomize from "./pages/TableCustomize";
6
+ export interface RouteModal {
7
+ path?: string;
8
+ name?: string;
9
+ children?: RouteModal[];
10
+ element?: JSX.Element;
11
+ index?: boolean;
12
+ errorElement?: JSX.Element;
13
+ }
14
+
15
+ const routes: RouteModal[] = [
16
+ {
17
+ index: true,
18
+ element: <Navigate to="/table" replace={true} />,
19
+ },
20
+ {
21
+ path: "/table",
22
+ name: "table",
23
+ element: <Table />,
24
+ },
25
+ {
26
+ path: "/tableCustomize",
27
+ name: "tableCustomize",
28
+ element: <TableCustomize />,
29
+ },
30
+ {
31
+ path: "/modalTable",
32
+ name: "ModalTable",
33
+ element: <ModalTable />,
34
+ },
35
+ ];
36
+
37
+ export default routes;
@@ -0,0 +1,46 @@
1
+ declare module "slash2";
2
+ declare module "*.css";
3
+ declare module "*.less";
4
+ declare module "*.scss";
5
+ declare module "*.sass";
6
+ declare module "*.svg";
7
+ declare module "*.png";
8
+ declare module "*.jpg";
9
+ declare module "*.jpeg";
10
+ declare module "*.gif";
11
+ declare module "*.bmp";
12
+ declare module "*.tiff";
13
+ declare module "omit.js";
14
+ declare module "numeral";
15
+ declare module "@antv/data-set";
16
+ declare module "mockjs";
17
+ declare module "react-fittext";
18
+ declare module "bizcharts-plugin-slider";
19
+
20
+ // google analytics interface
21
+ type GAFieldsObject = {
22
+ eventCategory: string;
23
+ eventAction: string;
24
+ eventLabel?: string;
25
+ eventValue?: number;
26
+ nonInteraction?: boolean;
27
+ };
28
+
29
+ interface Window {
30
+ ga: (
31
+ command: "send",
32
+ hitType: "event" | "pageview",
33
+ fieldsObject: GAFieldsObject | string
34
+ ) => void;
35
+ reloadAuthorized: () => void;
36
+ }
37
+
38
+ declare let ga: () => void;
39
+
40
+ // preview.pro.ant.design only do not use in your production ;
41
+ // preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。
42
+ declare let ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION:
43
+ | "site"
44
+ | undefined;
45
+
46
+ declare const REACT_APP_ENV: "test" | "dev" | "pre" | false;