listpage-next 0.0.192 → 0.0.194
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/{http-client → api}/client/base_url.d.ts +2 -1
- package/dist/api/client/client.d.ts +2 -0
- package/dist/{http-client → api}/client/client.js +7 -1
- package/dist/api/client/headers.d.ts +2 -0
- package/dist/api/client/token.d.ts +2 -0
- package/dist/{http-client → api}/client/types.d.ts +2 -0
- package/dist/components/AsyncSelect/index.d.ts +1 -1
- package/dist/components/FilterGroup/components/FilterItem/index.d.ts +1 -1
- package/dist/components/FilterGroup/components/FilterItem/index.js +2 -2
- package/dist/components/FilterGroup/index.d.ts +1 -2
- package/dist/components/PageLayout/components/PageLayout/index.d.ts +4 -0
- package/dist/components/PageLayout/components/PageLayout/index.js +3 -2
- package/dist/components/PageLayout/components/PageLogo/index.js +10 -6
- package/dist/components/index.d.ts +9 -0
- package/dist/components/index.js +9 -0
- package/dist/features/ChatClient/ui/ChatDialog/useExtra.d.ts +1 -1
- package/dist/features/ListPage/components/DataTable/index.js +1 -1
- package/dist/features/ListPage/components/DataTable/renders/switch.js +1 -1
- package/dist/features/ListPage/types.d.ts +2 -2
- package/dist/index.d.ts +2 -10
- package/dist/index.js +2 -10
- package/package.json +1 -1
- package/dist/components/DataTable/components/DataTable.d.ts +0 -7
- package/dist/components/DataTable/components/DataTable.js +0 -85
- package/dist/components/DataTable/components/Render.d.ts +0 -17
- package/dist/components/DataTable/components/Render.js +0 -15
- package/dist/components/DataTable/hooks/useColumns.d.ts +0 -3
- package/dist/components/DataTable/hooks/useColumns.js +0 -9
- package/dist/components/DataTable/hooks/useData.d.ts +0 -20
- package/dist/components/DataTable/hooks/useData.js +0 -56
- package/dist/components/DataTable/index.d.ts +0 -2
- package/dist/components/DataTable/index.js +0 -1
- package/dist/components/DataTable/typings/index.d.ts +0 -25
- package/dist/components/DataTable/typings/index.js +0 -1
- package/dist/components/DataTable/typings/render.d.ts +0 -24
- package/dist/components/DataTable/typings/render.js +0 -0
- package/dist/components/DataTable/utils/render.d.ts +0 -2
- package/dist/components/DataTable/utils/render.js +0 -103
- package/dist/context/float.d.ts +0 -19
- package/dist/context/float.js +0 -59
- package/dist/context/index.d.ts +0 -1
- package/dist/context/index.js +0 -2
- package/dist/features/ListPage/components/DataTable/utils/render.d.ts +0 -2
- package/dist/features/ListPage/components/DataTable/utils/render.js +0 -25
- package/dist/http-client/client/client.d.ts +0 -1
- package/dist/http-client/client/headers.d.ts +0 -1
- package/dist/http-client/client/token.d.ts +0 -1
- /package/dist/{http-client → api}/client/base_url.js +0 -0
- /package/dist/{http-client → api}/client/headers.js +0 -0
- /package/dist/{http-client → api}/client/index.d.ts +0 -0
- /package/dist/{http-client → api}/client/index.js +0 -0
- /package/dist/{http-client → api}/client/token.js +0 -0
- /package/dist/{http-client → api}/client/types.js +0 -0
- /package/dist/{http-client → api}/index.d.ts +0 -0
- /package/dist/{http-client → api}/index.js +0 -0
- /package/dist/{http-client → api}/types.d.ts +0 -0
- /package/dist/{http-client → api}/types.js +0 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { ClientOptions } from './types';
|
|
2
|
-
|
|
2
|
+
import { type HttpClient as BaseHttpClient } from './index';
|
|
3
|
+
export declare function setupBaseUrl(HttpClient: typeof BaseHttpClient): void;
|
|
3
4
|
export declare function mergeServerConfig(server: ClientOptions['server']): ClientOptions['server'];
|
|
@@ -14,9 +14,11 @@ function setupClient(HttpClient) {
|
|
|
14
14
|
};
|
|
15
15
|
HttpClient.prototype.setup = function() {
|
|
16
16
|
const successCodes = this.options.successCodes || [
|
|
17
|
-
10000,
|
|
18
17
|
200
|
|
19
18
|
];
|
|
19
|
+
const unauthorizedCodes = this.options.unauthorizedCodes || [
|
|
20
|
+
401
|
|
21
|
+
];
|
|
20
22
|
const apiClient = this.createAxiosInstance();
|
|
21
23
|
apiClient.interceptors.request.use((config)=>{
|
|
22
24
|
config.headers.Authorization = `Bearer ${this.getToken()}`;
|
|
@@ -44,6 +46,10 @@ function setupClient(HttpClient) {
|
|
|
44
46
|
});
|
|
45
47
|
return Promise.reject(error);
|
|
46
48
|
}
|
|
49
|
+
if (this.options.loginPath && unauthorizedCodes?.includes(response.data.code)) {
|
|
50
|
+
this.setToken('');
|
|
51
|
+
window.location.href = this.options.loginPath;
|
|
52
|
+
}
|
|
47
53
|
return response;
|
|
48
54
|
}, (error)=>{
|
|
49
55
|
console.error('Response Error:', error);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Form, Input } from "antd";
|
|
3
|
-
import { LabelInline, LabelWrapper } from "../LabelWrapper/index.js";
|
|
4
2
|
import { cloneElement, useState } from "react";
|
|
3
|
+
import { Form, Input } from "antd";
|
|
5
4
|
import { omit } from "lodash";
|
|
5
|
+
import { LabelInline, LabelWrapper } from "../LabelWrapper/index.js";
|
|
6
6
|
const FilterItem = (props)=>{
|
|
7
7
|
const { label, children, formItemProps, labelInline } = props;
|
|
8
8
|
const [focus, setFocus] = useState(false);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export { FilterForm } from './components/FilterForm';
|
|
2
|
-
export type { FilterFormOption } from './components/FilterForm';
|
|
1
|
+
export { FilterForm, type FilterFormOption } from './components/FilterForm';
|
|
3
2
|
export { FilterGroup, type FilterGroupProps } from './components/FilterGroup';
|
|
4
3
|
export { cleanUpFormValues } from './utils/format';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
1
2
|
import { SiderProps } from 'antd';
|
|
2
3
|
import { usePageContext } from '../PageProvider';
|
|
3
4
|
import { PageLogoProps } from '../PageLogo';
|
|
@@ -11,5 +12,8 @@ export interface PageLayoutProps {
|
|
|
11
12
|
floats?: PageFloatProps[];
|
|
12
13
|
defaultCollapsed?: boolean;
|
|
13
14
|
siderProps?: Omit<SiderProps, 'collapsed' | 'onCollapse'>;
|
|
15
|
+
styles?: {
|
|
16
|
+
container?: CSSProperties;
|
|
17
|
+
};
|
|
14
18
|
}
|
|
15
19
|
export declare const PageLayout: (props: PageLayoutProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useImperativeHandle } from "react";
|
|
2
3
|
import { Layout } from "antd";
|
|
3
4
|
import { styled } from "styled-components";
|
|
4
5
|
import { PageSider } from "../PageSider/index.js";
|
|
5
6
|
import { PageHeader } from "../PageHeader/index.js";
|
|
6
7
|
import { PageContent } from "../PageContent/index.js";
|
|
7
8
|
import { PageProvider, usePageContext } from "../PageProvider/index.js";
|
|
8
|
-
import { useImperativeHandle } from "react";
|
|
9
9
|
const PageLayoutComponent = (props)=>{
|
|
10
|
-
const { siderProps, sider, header, content, logo, pageRef } = props;
|
|
10
|
+
const { siderProps, sider, header, content, logo, pageRef, styles } = props;
|
|
11
11
|
const context = usePageContext();
|
|
12
12
|
const { collapsed, setCollapsed } = context;
|
|
13
13
|
useImperativeHandle(pageRef, ()=>context, [
|
|
14
14
|
context
|
|
15
15
|
]);
|
|
16
16
|
return /*#__PURE__*/ jsxs(LayoutStyled, {
|
|
17
|
+
style: styles?.container,
|
|
17
18
|
children: [
|
|
18
19
|
/*#__PURE__*/ jsx(PageSider, {
|
|
19
20
|
...siderProps,
|
|
@@ -6,15 +6,15 @@ const PageLogo = (props)=>{
|
|
|
6
6
|
return /*#__PURE__*/ jsxs(LogoContentWrapper, {
|
|
7
7
|
children: [
|
|
8
8
|
src && /*#__PURE__*/ jsx(Image, {
|
|
9
|
-
width:
|
|
10
|
-
height:
|
|
9
|
+
width: 24,
|
|
10
|
+
height: 24,
|
|
11
11
|
src: src,
|
|
12
12
|
preview: true
|
|
13
13
|
}),
|
|
14
14
|
icon && /*#__PURE__*/ jsx(Avatar, {
|
|
15
15
|
icon: icon,
|
|
16
16
|
shape: "circle",
|
|
17
|
-
size:
|
|
17
|
+
size: 24
|
|
18
18
|
}),
|
|
19
19
|
title && /*#__PURE__*/ jsx(TitleContentWrapper, {
|
|
20
20
|
children: title
|
|
@@ -23,14 +23,18 @@ const PageLogo = (props)=>{
|
|
|
23
23
|
});
|
|
24
24
|
};
|
|
25
25
|
const LogoContentWrapper = styled.div`
|
|
26
|
-
flex: 0;
|
|
26
|
+
flex-shrink: 0;
|
|
27
|
+
flex-grow: 0;
|
|
27
28
|
display: flex;
|
|
28
29
|
align-items: center;
|
|
29
30
|
gap: 8px;
|
|
30
|
-
height:
|
|
31
|
+
height: 64px;
|
|
32
|
+
|
|
33
|
+
padding: 0 22px;
|
|
31
34
|
`;
|
|
32
35
|
const TitleContentWrapper = styled.div`
|
|
33
|
-
font-size:
|
|
36
|
+
font-size: 20px;
|
|
37
|
+
line-height: 24px;
|
|
34
38
|
font-weight: 600;
|
|
35
39
|
color: #333;
|
|
36
40
|
`;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './AsyncSelect';
|
|
2
|
+
export * from './AsyncButton';
|
|
3
|
+
export * from './AsyncSwitch';
|
|
4
|
+
export * from './CheckButton';
|
|
5
|
+
export * from './InfiniteList';
|
|
6
|
+
export * from './Menu';
|
|
7
|
+
export * from './TextOverflow';
|
|
8
|
+
export * from './PageLayout';
|
|
9
|
+
export * from './FilterGroup';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "./AsyncSelect/index.js";
|
|
2
|
+
export * from "./AsyncButton/index.js";
|
|
3
|
+
export * from "./AsyncSwitch/index.js";
|
|
4
|
+
export * from "./CheckButton/index.js";
|
|
5
|
+
export * from "./InfiniteList/index.js";
|
|
6
|
+
export * from "./Menu/index.js";
|
|
7
|
+
export * from "./TextOverflow/index.js";
|
|
8
|
+
export * from "./PageLayout/index.js";
|
|
9
|
+
export * from "./FilterGroup/index.js";
|
|
@@ -9,4 +9,4 @@ export interface ExtraOptions {
|
|
|
9
9
|
clear: ReactNode;
|
|
10
10
|
}) => ReactNode[];
|
|
11
11
|
}
|
|
12
|
-
export declare function useExtra(options: ExtraOptions): import("react/jsx-runtime").JSX.Element[]
|
|
12
|
+
export declare function useExtra(options: ExtraOptions): ReactNode[] | import("react/jsx-runtime").JSX.Element[];
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Card, Table } from "antd";
|
|
3
3
|
import { observer } from "mobx-react-lite";
|
|
4
|
-
import { useListPageStore } from "../../context/index.js";
|
|
5
4
|
import { usePagination } from "../../hooks/usePagination.js";
|
|
6
5
|
import { useColumns } from "../../hooks/useColumns.js";
|
|
7
6
|
import { useSelectionTools } from "../../hooks/useSelectionTools.js";
|
|
7
|
+
import { useListPageStore } from "../../context/index.js";
|
|
8
8
|
import { TableContainer } from "../../styles.js";
|
|
9
9
|
const DataTable = observer((props)=>{
|
|
10
10
|
const { title, extra, columns = [], rowTitleKey, rowSelectionType, tableProps } = props;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { AsyncSwitch } from "../../../../../components/
|
|
2
|
+
import { AsyncSwitch } from "../../../../../components/index.js";
|
|
3
3
|
const switchRender = (value, record, index, props)=>/*#__PURE__*/ jsx(AsyncSwitch, {
|
|
4
4
|
defaultValue: value,
|
|
5
5
|
...props,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { JSX, ReactNode } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { BaseQueryParams, PaginationData } from '../../api';
|
|
3
|
+
import { FilterFormOption } from '../../components';
|
|
3
4
|
import type { ListPageStore } from './context';
|
|
4
|
-
import { BaseQueryParams, PaginationData } from '../../http-client';
|
|
5
5
|
import type { FloatComponentProps } from '../../components/PageLayout/components/PageProvider/float';
|
|
6
6
|
export type StateValue<FilterValue = any> = {
|
|
7
7
|
filterValues?: FilterValue;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
import '@ant-design/v5-patch-for-react-19';
|
|
2
|
-
export * from './components
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './components/Menu';
|
|
5
|
-
export * from './components/DataTable';
|
|
6
|
-
export * from './components/AsyncSelect';
|
|
7
|
-
export * from './components/AsyncButton';
|
|
8
|
-
export * from './components/TextOverflow';
|
|
9
|
-
export * from './components/PageLayout';
|
|
10
|
-
export * from './components/CheckButton';
|
|
2
|
+
export * from './components';
|
|
3
|
+
export * from './api';
|
|
11
4
|
export * from './features/JsonEditor';
|
|
12
5
|
export * from './features/ChatClient';
|
|
13
6
|
export * from './features/ListPage';
|
|
14
|
-
export * from './http-client';
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
import "@ant-design/v5-patch-for-react-19";
|
|
2
|
-
export * from "./components/
|
|
3
|
-
export * from "./
|
|
4
|
-
export * from "./components/Menu/index.js";
|
|
5
|
-
export * from "./components/DataTable/index.js";
|
|
6
|
-
export * from "./components/AsyncSelect/index.js";
|
|
7
|
-
export * from "./components/AsyncButton/index.js";
|
|
8
|
-
export * from "./components/TextOverflow/index.js";
|
|
9
|
-
export * from "./components/PageLayout/index.js";
|
|
10
|
-
export * from "./components/CheckButton/index.js";
|
|
2
|
+
export * from "./components/index.js";
|
|
3
|
+
export * from "./api/index.js";
|
|
11
4
|
export * from "./features/JsonEditor/index.js";
|
|
12
5
|
export * from "./features/ChatClient/index.js";
|
|
13
6
|
export * from "./features/ListPage/index.js";
|
|
14
|
-
export * from "./http-client/index.js";
|
package/package.json
CHANGED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Ref } from 'react';
|
|
2
|
-
import { DataTableContext, DataTableProps } from '../typings';
|
|
3
|
-
export declare const PaginationContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
4
|
-
export declare const TableContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
5
|
-
export declare const DataTable: <Record = any>(props: DataTableProps<Record> & {
|
|
6
|
-
tableRef?: Ref<DataTableContext>;
|
|
7
|
-
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, useImperativeHandle } from "react";
|
|
3
|
-
import { Card, Pagination, Table } from "antd";
|
|
4
|
-
import styled_components from "styled-components";
|
|
5
|
-
import { useColumns } from "../hooks/useColumns.js";
|
|
6
|
-
import { useData } from "../hooks/useData.js";
|
|
7
|
-
import { FloatProvider, useFloatContext } from "../../../context/index.js";
|
|
8
|
-
const PaginationContainer = styled_components.div`
|
|
9
|
-
padding: 12px 16px 12px 0;
|
|
10
|
-
border-top: 1px solid #f0f0f0;
|
|
11
|
-
`;
|
|
12
|
-
const TableContainer = styled_components.div`
|
|
13
|
-
table {
|
|
14
|
-
tr:last-child {
|
|
15
|
-
td {
|
|
16
|
-
border-bottom: none;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
`;
|
|
21
|
-
const DataTableComponent = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
22
|
-
const { title, extra, dataSource, request, refreshDeps, ...restProps } = props;
|
|
23
|
-
const { data, loading, pagination, onPaginationChange, refresh } = useData({
|
|
24
|
-
dataSource,
|
|
25
|
-
request,
|
|
26
|
-
refreshDeps,
|
|
27
|
-
pagination: restProps.pagination
|
|
28
|
-
});
|
|
29
|
-
const floatCtx = useFloatContext();
|
|
30
|
-
const actions = {
|
|
31
|
-
refresh
|
|
32
|
-
};
|
|
33
|
-
const ctx = {
|
|
34
|
-
...floatCtx,
|
|
35
|
-
...actions
|
|
36
|
-
};
|
|
37
|
-
useImperativeHandle(ref, ()=>ctx, [
|
|
38
|
-
ctx
|
|
39
|
-
]);
|
|
40
|
-
const columns = useColumns(props, ctx);
|
|
41
|
-
return /*#__PURE__*/ jsxs(Card, {
|
|
42
|
-
title: title,
|
|
43
|
-
extra: extra,
|
|
44
|
-
styles: {
|
|
45
|
-
body: {
|
|
46
|
-
padding: 0
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
children: [
|
|
50
|
-
/*#__PURE__*/ jsx(TableContainer, {
|
|
51
|
-
children: /*#__PURE__*/ jsx(Table, {
|
|
52
|
-
bordered: false,
|
|
53
|
-
loading: loading,
|
|
54
|
-
...restProps,
|
|
55
|
-
columns: columns,
|
|
56
|
-
dataSource: data,
|
|
57
|
-
pagination: false
|
|
58
|
-
})
|
|
59
|
-
}),
|
|
60
|
-
false !== restProps.pagination && /*#__PURE__*/ jsx(PaginationContainer, {
|
|
61
|
-
children: /*#__PURE__*/ jsx(Pagination, {
|
|
62
|
-
align: "end",
|
|
63
|
-
...pagination,
|
|
64
|
-
...restProps?.pagination,
|
|
65
|
-
onChange: onPaginationChange
|
|
66
|
-
})
|
|
67
|
-
})
|
|
68
|
-
]
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
const DataTable = (props)=>{
|
|
72
|
-
const { tableRef, ...restProps } = props;
|
|
73
|
-
if (!props.floats) return /*#__PURE__*/ jsx(DataTableComponent, {
|
|
74
|
-
...restProps,
|
|
75
|
-
ref: tableRef
|
|
76
|
-
});
|
|
77
|
-
return /*#__PURE__*/ jsx(FloatProvider, {
|
|
78
|
-
floats: props.floats,
|
|
79
|
-
children: /*#__PURE__*/ jsx(DataTableComponent, {
|
|
80
|
-
...restProps,
|
|
81
|
-
ref: tableRef
|
|
82
|
-
})
|
|
83
|
-
});
|
|
84
|
-
};
|
|
85
|
-
export { DataTable, PaginationContainer, TableContainer };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { JSX } from 'react';
|
|
2
|
-
export interface RenderProps<T, Record, C> {
|
|
3
|
-
ctx: C;
|
|
4
|
-
defaultValue: T;
|
|
5
|
-
record: Record;
|
|
6
|
-
index: number;
|
|
7
|
-
render: (props: UserRenderComponentProps<T, Record, C>) => JSX.Element;
|
|
8
|
-
}
|
|
9
|
-
export type UserRenderComponentProps<T, Record, C> = {
|
|
10
|
-
ctx: C;
|
|
11
|
-
value: T;
|
|
12
|
-
onChange: (v: T) => void;
|
|
13
|
-
record: Record;
|
|
14
|
-
index: number;
|
|
15
|
-
};
|
|
16
|
-
export type ColumnRender<R, C = any> = <T = any>(props: UserRenderComponentProps<T, R, C>) => JSX.Element;
|
|
17
|
-
export declare const Render: <T = any, Record = any, C = any>(props: RenderProps<C, T, Record>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useControllableValue } from "ahooks";
|
|
3
|
-
import { toJS } from "mobx";
|
|
4
|
-
const Render = (props)=>{
|
|
5
|
-
const { render: Component, record, index, ctx } = props;
|
|
6
|
-
const [value, onChange] = useControllableValue(props);
|
|
7
|
-
return /*#__PURE__*/ jsx(Component, {
|
|
8
|
-
value: value,
|
|
9
|
-
onChange: onChange,
|
|
10
|
-
record: toJS(record),
|
|
11
|
-
index: index,
|
|
12
|
-
ctx: ctx
|
|
13
|
-
});
|
|
14
|
-
};
|
|
15
|
-
export { Render };
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { DataTableProps } from "../typings";
|
|
2
|
-
import { BaseQueryParams } from "../../../http-client";
|
|
3
|
-
export declare function useData<T = any>(props: DataTableProps<T>): {
|
|
4
|
-
data: T[];
|
|
5
|
-
loading: boolean;
|
|
6
|
-
pagination: BaseQueryParams;
|
|
7
|
-
refresh: () => void;
|
|
8
|
-
onPaginationChange: (page: number, pageSize: number) => void;
|
|
9
|
-
} | {
|
|
10
|
-
data: T[] | undefined;
|
|
11
|
-
loading: boolean;
|
|
12
|
-
refresh: () => void;
|
|
13
|
-
pagination: {
|
|
14
|
-
current?: number;
|
|
15
|
-
pageSize?: number;
|
|
16
|
-
sort?: string;
|
|
17
|
-
total: number | undefined;
|
|
18
|
-
};
|
|
19
|
-
onPaginationChange: (page: number, pageSize: number) => void;
|
|
20
|
-
};
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { useState } from "react";
|
|
2
|
-
import { useRequest, useUpdateEffect } from "ahooks";
|
|
3
|
-
function useData(props) {
|
|
4
|
-
const { dataSource = [], request, refreshDeps = [] } = props;
|
|
5
|
-
const pagination = props.pagination ?? {};
|
|
6
|
-
const [params, setParams] = useState({
|
|
7
|
-
current: pagination.current || pagination.defaultCurrent || 1,
|
|
8
|
-
pageSize: pagination.pageSize || pagination.defaultPageSize || 10
|
|
9
|
-
});
|
|
10
|
-
const { loading, data: response, refresh } = useRequest(async ()=>{
|
|
11
|
-
const response = await request?.(params);
|
|
12
|
-
return response;
|
|
13
|
-
}, {
|
|
14
|
-
ready: !!request,
|
|
15
|
-
refreshDeps: [
|
|
16
|
-
...refreshDeps,
|
|
17
|
-
params
|
|
18
|
-
]
|
|
19
|
-
});
|
|
20
|
-
useUpdateEffect(()=>{
|
|
21
|
-
setParams({
|
|
22
|
-
current: 1,
|
|
23
|
-
pageSize: params.pageSize || pagination?.pageSize || pagination.defaultPageSize || 10
|
|
24
|
-
});
|
|
25
|
-
}, [
|
|
26
|
-
...refreshDeps
|
|
27
|
-
]);
|
|
28
|
-
const onChange = (page, pageSize)=>{
|
|
29
|
-
const current = pageSize !== params.pageSize ? 1 : page;
|
|
30
|
-
setParams({
|
|
31
|
-
...params,
|
|
32
|
-
current,
|
|
33
|
-
pageSize
|
|
34
|
-
});
|
|
35
|
-
pagination?.onChange?.(current, pageSize);
|
|
36
|
-
};
|
|
37
|
-
if (!request) return {
|
|
38
|
-
data: dataSource,
|
|
39
|
-
loading: false,
|
|
40
|
-
pagination: params,
|
|
41
|
-
refresh,
|
|
42
|
-
onPaginationChange: onChange
|
|
43
|
-
};
|
|
44
|
-
const { list, total } = response || {};
|
|
45
|
-
return {
|
|
46
|
-
data: list,
|
|
47
|
-
loading,
|
|
48
|
-
refresh,
|
|
49
|
-
pagination: {
|
|
50
|
-
total,
|
|
51
|
-
...params
|
|
52
|
-
},
|
|
53
|
-
onPaginationChange: onChange
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
export { useData };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./components/DataTable.js";
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import React, { JSX } from 'react';
|
|
2
|
-
import { TableProps } from 'antd';
|
|
3
|
-
import { BaseQueryParams, PaginationData } from '../../../http-client';
|
|
4
|
-
import { ColumnType } from 'antd/es/table';
|
|
5
|
-
import { ColumnRenderProps } from './render';
|
|
6
|
-
export interface DataTableProps<Record = any> extends Omit<TableProps<Record>, 'dataSource' | 'title' | 'columns'> {
|
|
7
|
-
dataSource?: Record[];
|
|
8
|
-
request?: (pageParams: BaseQueryParams) => Promise<PaginationData<Record>>;
|
|
9
|
-
refreshDeps?: any[];
|
|
10
|
-
title?: React.ReactNode;
|
|
11
|
-
extra?: React.ReactNode;
|
|
12
|
-
columns?: DataTableColumns<Record, DataTableContext>[];
|
|
13
|
-
floats?: {
|
|
14
|
-
key: string;
|
|
15
|
-
content: JSX.Element;
|
|
16
|
-
}[];
|
|
17
|
-
}
|
|
18
|
-
export interface DataTableColumns<Record = any, Context = any> extends ColumnType<Record>, Omit<ColumnRenderProps<Record, Context>, 'render'> {
|
|
19
|
-
}
|
|
20
|
-
export interface DataTableContext {
|
|
21
|
-
showFloat: (key: string, record: any) => void;
|
|
22
|
-
hideFloat: (key: string) => void;
|
|
23
|
-
refresh: () => void;
|
|
24
|
-
}
|
|
25
|
-
export * from './render';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./render.js";
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { HTMLAttributeAnchorTarget } from 'react';
|
|
2
|
-
import { SwitchProps, TagProps, TypographyProps } from 'antd';
|
|
3
|
-
import { ColumnType } from 'antd/es/table';
|
|
4
|
-
import { ColumnRender } from '../components/Render';
|
|
5
|
-
export type ComponentType = 'text' | 'time' | 'tag' | 'link' | 'switch';
|
|
6
|
-
export type ComponentProps = ComponentType extends 'text' ? TextComponentProps : ComponentType extends 'time' ? TimeComponentProps : ComponentType extends 'tag' ? TagComponentProps : ComponentType extends 'link' ? LinkComponentProps : ComponentType extends 'switch' ? SwitchComponentProps : unknown;
|
|
7
|
-
export type TextComponentProps = TypographyProps['Text'];
|
|
8
|
-
export type TimeComponentProps = {
|
|
9
|
-
format?: string;
|
|
10
|
-
};
|
|
11
|
-
export type TagComponentProps = TagProps;
|
|
12
|
-
export type LinkComponentProps = {
|
|
13
|
-
titlePropName?: string | ((record: any) => string);
|
|
14
|
-
hrefPropName?: string | ((record: any) => string);
|
|
15
|
-
target?: HTMLAttributeAnchorTarget;
|
|
16
|
-
};
|
|
17
|
-
export type SwitchComponentProps = SwitchProps & {
|
|
18
|
-
syncChange?: (value: boolean, record: any) => Promise<void>;
|
|
19
|
-
};
|
|
20
|
-
export interface ColumnRenderProps<Record, Context> {
|
|
21
|
-
component?: ComponentType | ColumnRender<Record, Context>;
|
|
22
|
-
props?: ComponentProps;
|
|
23
|
-
render?: ColumnType<Record>['render'];
|
|
24
|
-
}
|
|
File without changes
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Tag, Typography } from "antd";
|
|
3
|
-
import { styled } from "styled-components";
|
|
4
|
-
import dayjs from "dayjs";
|
|
5
|
-
import { Render } from "../components/Render.js";
|
|
6
|
-
import { TextOverflow } from "../../TextOverflow/index.js";
|
|
7
|
-
import { AsyncSwitch } from "../../AsyncSwitch/index.js";
|
|
8
|
-
function createColumnRender(ctx, column) {
|
|
9
|
-
if (column.component) {
|
|
10
|
-
if ('text' === column.component) return function(value, record, index) {
|
|
11
|
-
return textRender(value, record, column.props);
|
|
12
|
-
};
|
|
13
|
-
if ('time' === column.component) return function(value, record, index) {
|
|
14
|
-
return timeRender(value, record, column.props);
|
|
15
|
-
};
|
|
16
|
-
if ('tag' === column.component) return function(value, record, index) {
|
|
17
|
-
return tagRender(value, record, column.props);
|
|
18
|
-
};
|
|
19
|
-
if ('link' === column.component) return function(value, record, index) {
|
|
20
|
-
return linkRender(value, record, column.props);
|
|
21
|
-
};
|
|
22
|
-
if ('switch' === column.component) return function(value, record, index) {
|
|
23
|
-
return switchRender(value, record, column.props);
|
|
24
|
-
};
|
|
25
|
-
return function(value, record, index) {
|
|
26
|
-
return /*#__PURE__*/ jsx(Render, {
|
|
27
|
-
render: column.component,
|
|
28
|
-
defaultValue: value,
|
|
29
|
-
record: record,
|
|
30
|
-
index: index,
|
|
31
|
-
ctx: ctx
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
return column.render;
|
|
36
|
-
}
|
|
37
|
-
function textRender(value, record, props) {
|
|
38
|
-
return /*#__PURE__*/ jsx(Typography.Text, {
|
|
39
|
-
ellipsis: {
|
|
40
|
-
tooltip: true
|
|
41
|
-
},
|
|
42
|
-
...props,
|
|
43
|
-
children: value
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
function timeRender(value, record, props) {
|
|
47
|
-
try {
|
|
48
|
-
const time = value ? dayjs(value).format(props?.format) : '-';
|
|
49
|
-
return /*#__PURE__*/ jsx("span", {
|
|
50
|
-
children: time
|
|
51
|
-
});
|
|
52
|
-
} catch {
|
|
53
|
-
return /*#__PURE__*/ jsx("span", {
|
|
54
|
-
children: "-"
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
function tagRender(value, record, props) {
|
|
59
|
-
return /*#__PURE__*/ jsx(Tag, {
|
|
60
|
-
...props,
|
|
61
|
-
children: value
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
function linkRender(value, record, props) {
|
|
65
|
-
const getPropName = (propName)=>{
|
|
66
|
-
if ('function' == typeof propName) return propName(record);
|
|
67
|
-
return record[propName];
|
|
68
|
-
};
|
|
69
|
-
const title = getPropName(props?.titlePropName || 'title');
|
|
70
|
-
const href = getPropName(props?.hrefPropName || 'href');
|
|
71
|
-
const aLink = /*#__PURE__*/ jsx(LinkStyle, {
|
|
72
|
-
href: href,
|
|
73
|
-
target: props?.target,
|
|
74
|
-
children: title
|
|
75
|
-
});
|
|
76
|
-
return /*#__PURE__*/ jsx(TextOverflow, {
|
|
77
|
-
text: aLink,
|
|
78
|
-
tooltipProps: {
|
|
79
|
-
title
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
function switchRender(value, record, props) {
|
|
84
|
-
return /*#__PURE__*/ jsx(AsyncSwitch, {
|
|
85
|
-
defaultValue: value,
|
|
86
|
-
...props,
|
|
87
|
-
syncChange: async (checked)=>{
|
|
88
|
-
await props?.syncChange?.(checked, record);
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
const LinkStyle = styled.a`
|
|
93
|
-
color: #1677ff;
|
|
94
|
-
&:hover {
|
|
95
|
-
color: #69b1ff;
|
|
96
|
-
}
|
|
97
|
-
outline: 0;
|
|
98
|
-
text-decoration: none;
|
|
99
|
-
transition: color 0.3s;
|
|
100
|
-
background-color: transparent;
|
|
101
|
-
cursor: pointer;
|
|
102
|
-
`;
|
|
103
|
-
export { createColumnRender };
|
package/dist/context/float.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import React, { JSX } from 'react';
|
|
2
|
-
export interface FloatContextProps {
|
|
3
|
-
showFloat: (key: string, record: any, onCloseCallback?: () => void) => void;
|
|
4
|
-
hideFloat: (key: string) => void;
|
|
5
|
-
}
|
|
6
|
-
export declare const FloatContext: React.Context<FloatContextProps | undefined>;
|
|
7
|
-
export declare const useFloatContext: () => FloatContextProps;
|
|
8
|
-
export declare const FloatProvider: (props: {
|
|
9
|
-
floats?: {
|
|
10
|
-
key: string;
|
|
11
|
-
content: JSX.Element;
|
|
12
|
-
}[];
|
|
13
|
-
children: React.ReactNode;
|
|
14
|
-
}) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
-
export type FloatComponentProps<T extends Record<string, any> = any> = {
|
|
16
|
-
record: T;
|
|
17
|
-
visible: boolean;
|
|
18
|
-
onClose: () => void;
|
|
19
|
-
};
|
package/dist/context/float.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { cloneElement, createContext, useCallback, useContext, useRef, useState } from "react";
|
|
3
|
-
const FloatContext = /*#__PURE__*/ createContext(void 0);
|
|
4
|
-
const useFloatContext = ()=>{
|
|
5
|
-
const context = useContext(FloatContext);
|
|
6
|
-
if (!context) return {
|
|
7
|
-
showFloat: ()=>{},
|
|
8
|
-
hideFloat: ()=>{}
|
|
9
|
-
};
|
|
10
|
-
return context;
|
|
11
|
-
};
|
|
12
|
-
const FloatProvider = (props)=>{
|
|
13
|
-
const { floats = [], children } = props;
|
|
14
|
-
const floatsMapRef = useRef({});
|
|
15
|
-
const [eles, setEles] = useState([]);
|
|
16
|
-
const hideFloat = useCallback((key)=>{
|
|
17
|
-
if (!floatsMapRef.current[key]) return;
|
|
18
|
-
setEles(eles.filter((i)=>i !== floatsMapRef.current[key]));
|
|
19
|
-
delete floatsMapRef.current[key];
|
|
20
|
-
}, [
|
|
21
|
-
eles
|
|
22
|
-
]);
|
|
23
|
-
const showFloat = useCallback((key, record, onCloseCallback)=>{
|
|
24
|
-
if (!floatsMapRef.current[key]) {
|
|
25
|
-
const content = floats.find((i)=>i.key === key)?.content;
|
|
26
|
-
if (!content) return;
|
|
27
|
-
const onClose = ()=>{
|
|
28
|
-
hideFloat(key);
|
|
29
|
-
onCloseCallback?.();
|
|
30
|
-
};
|
|
31
|
-
const newContent = /*#__PURE__*/ cloneElement(content, {
|
|
32
|
-
record,
|
|
33
|
-
onClose,
|
|
34
|
-
visible: true
|
|
35
|
-
});
|
|
36
|
-
floatsMapRef.current[key] = newContent;
|
|
37
|
-
setEles([
|
|
38
|
-
...eles,
|
|
39
|
-
newContent
|
|
40
|
-
]);
|
|
41
|
-
}
|
|
42
|
-
}, [
|
|
43
|
-
eles,
|
|
44
|
-
hideFloat
|
|
45
|
-
]);
|
|
46
|
-
return /*#__PURE__*/ jsx(FloatContext.Provider, {
|
|
47
|
-
value: {
|
|
48
|
-
showFloat,
|
|
49
|
-
hideFloat
|
|
50
|
-
},
|
|
51
|
-
children: /*#__PURE__*/ jsxs(Fragment, {
|
|
52
|
-
children: [
|
|
53
|
-
children,
|
|
54
|
-
eles
|
|
55
|
-
]
|
|
56
|
-
})
|
|
57
|
-
});
|
|
58
|
-
};
|
|
59
|
-
export { FloatContext, FloatProvider, useFloatContext };
|
package/dist/context/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { FloatContext, FloatProvider, useFloatContext } from './float';
|
package/dist/context/index.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { ComponentType } from '../types';
|
|
2
|
-
export declare function createColumnRender<RecordValue extends Record<string, any> = any, FilterValue = any>(component?: ComponentType, props?: any): ((value: any, record: RecordValue, index: number) => import("react").ReactNode) | undefined;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { textRender } from "../renders/text.js";
|
|
2
|
-
import { timeRender } from "../renders/time.js";
|
|
3
|
-
import { tagRender } from "../renders/tag.js";
|
|
4
|
-
import { linkRender } from "../renders/link.js";
|
|
5
|
-
import { switchRender } from "../renders/switch.js";
|
|
6
|
-
function createColumnRender(component, props) {
|
|
7
|
-
if (component) {
|
|
8
|
-
if ('text' === component) return function(value, record, index) {
|
|
9
|
-
return textRender(value, record, index, props);
|
|
10
|
-
};
|
|
11
|
-
if ('time' === component) return function(value, record, index) {
|
|
12
|
-
return timeRender(value, record, index, props);
|
|
13
|
-
};
|
|
14
|
-
if ('tag' === component) return function(value, record, index) {
|
|
15
|
-
return tagRender(value, record, index, props);
|
|
16
|
-
};
|
|
17
|
-
if ('link' === component) return function(value, record, index) {
|
|
18
|
-
return linkRender(value, record, index, props);
|
|
19
|
-
};
|
|
20
|
-
if ('switch' === component) return function(value, record, index) {
|
|
21
|
-
return switchRender(value, record, index, props);
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
export { createColumnRender };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function setupClient(HttpClient: typeof import('./index').HttpClient): void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function setupHeaders(HttpClient: typeof import('./index').HttpClient): void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function setupToken(HttpClient: typeof import('./index').HttpClient): void;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|