listpage-next 0.0.170 → 0.0.171
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/components/PageLayout/components/PageContent/index.d.ts +5 -0
- package/dist/components/PageLayout/components/PageContent/index.js +15 -0
- package/dist/components/PageLayout/components/PageHeader/index.d.ts +5 -0
- package/dist/components/PageLayout/components/PageHeader/index.js +5 -0
- package/dist/components/PageLayout/components/PageLayout/index.d.ts +10 -0
- package/dist/components/PageLayout/components/PageLayout/index.js +44 -0
- package/dist/components/{Page/components/Loading → PageLayout/components/PageLoading}/index.js +16 -6
- package/dist/components/{Page/context/page.d.ts → PageLayout/components/PageProvider/index.d.ts} +4 -4
- package/dist/components/{Page/context/page.js → PageLayout/components/PageProvider/index.js} +6 -3
- package/dist/components/PageLayout/components/PageSider/index.d.ts +7 -0
- package/dist/components/PageLayout/components/PageSider/index.js +43 -0
- package/dist/components/PageLayout/index.d.ts +4 -0
- package/dist/components/PageLayout/index.js +4 -0
- package/dist/context/index.d.ts +1 -1
- package/dist/demos/demo2.js +2 -2
- package/dist/demos/demo5.js +1 -1
- package/dist/features/ChatClient/components/ChatContent/index.js +1 -1
- package/dist/features/ChatClient/ui/Bubble/BubbleList.js +1 -1
- package/dist/features/ListPage/components/DataTable/index.d.ts +4 -0
- package/dist/{components/Page/components/ListPage/DataTable.js → features/ListPage/components/DataTable/index.js} +3 -3
- package/dist/features/ListPage/components/DataTable/renders/index.d.ts +7 -0
- package/dist/features/ListPage/components/DataTable/renders/index.js +13 -0
- package/dist/features/ListPage/components/DataTable/renders/link.d.ts +2 -0
- package/dist/features/ListPage/components/DataTable/renders/link.js +27 -0
- package/dist/features/ListPage/components/DataTable/renders/switch.d.ts +2 -0
- package/dist/features/ListPage/components/DataTable/renders/switch.js +10 -0
- package/dist/features/ListPage/components/DataTable/renders/tag.d.ts +2 -0
- package/dist/features/ListPage/components/DataTable/renders/tag.js +7 -0
- package/dist/features/ListPage/components/DataTable/renders/text.d.ts +2 -0
- package/dist/features/ListPage/components/DataTable/renders/text.js +10 -0
- package/dist/features/ListPage/components/DataTable/renders/time.d.ts +2 -0
- package/dist/features/ListPage/components/DataTable/renders/time.js +15 -0
- package/dist/features/ListPage/components/DataTable/types.d.ts +34 -0
- package/dist/features/ListPage/components/DataTable/types.js +0 -0
- package/dist/features/ListPage/components/DataTable/utils/render.d.ts +2 -0
- package/dist/features/ListPage/components/DataTable/utils/render.js +25 -0
- package/dist/features/ListPage/components/ListPageContainer/index.d.ts +17 -0
- package/dist/{components/Page/components/ListPage/v2.js → features/ListPage/components/ListPageContainer/index.js} +10 -24
- package/dist/features/ListPage/context/context.d.ts +4 -0
- package/dist/features/ListPage/context/context.js +22 -0
- package/dist/features/ListPage/context/index.d.ts +2 -0
- package/dist/features/ListPage/context/index.js +3 -0
- package/dist/features/ListPage/context/store.d.ts +37 -0
- package/dist/{components/Page/context/listpage.js → features/ListPage/context/store.js} +2 -42
- package/dist/features/ListPage/context/types.d.ts +12 -0
- package/dist/features/ListPage/context/types.js +0 -0
- package/dist/features/ListPage/hooks/useColumns.d.ts +3 -0
- package/dist/features/ListPage/hooks/useColumns.js +20 -0
- package/dist/{components/Page → features/ListPage}/hooks/useFloat.js +1 -1
- package/dist/features/ListPage/hooks/useHeader.d.ts +2 -0
- package/dist/{components/Page → features/ListPage}/hooks/useHeader.js +2 -2
- package/dist/{components/Page → features/ListPage}/hooks/usePagination.js +2 -2
- package/dist/{components/Page → features/ListPage}/hooks/useSelectionTools.js +1 -1
- package/dist/features/ListPage/index.d.ts +3 -0
- package/dist/features/ListPage/index.js +4 -0
- package/dist/{components/Page/components → features}/ListPage/styles.d.ts +3 -1
- package/dist/{components/Page/components → features}/ListPage/styles.js +15 -2
- package/dist/features/ListPage/types.d.ts +33 -0
- package/dist/features/ListPage/types.js +0 -0
- package/dist/features/ListPage/utils/index.d.ts +10 -0
- package/dist/features/ListPage/utils/index.js +23 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
- package/dist/components/Page/components/ListPage/DataTable.d.ts +0 -20
- package/dist/components/Page/components/ListPage/index.d.ts +0 -16
- package/dist/components/Page/components/ListPage/index.js +0 -51
- package/dist/components/Page/components/ListPage/v2.d.ts +0 -43
- package/dist/components/Page/components/PageContainer/index.d.ts +0 -10
- package/dist/components/Page/components/PageContainer/index.js +0 -82
- package/dist/components/Page/context/listpage.d.ts +0 -80
- package/dist/components/Page/hooks/useColumns.d.ts +0 -3
- package/dist/components/Page/hooks/useColumns.js +0 -10
- package/dist/components/Page/hooks/useHeader.d.ts +0 -7
- package/dist/components/Page/index.d.ts +0 -8
- package/dist/components/Page/index.js +0 -7
- /package/dist/components/{Page/components/Loading → PageLayout/components/PageLoading}/index.d.ts +0 -0
- /package/dist/{components/Page → features/ListPage}/hooks/useFloat.d.ts +0 -0
- /package/dist/{components/Page → features/ListPage}/hooks/usePagination.d.ts +0 -0
- /package/dist/{components/Page → features/ListPage}/hooks/useSelectionTools.d.ts +0 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Key } from 'react';
|
|
2
|
+
import { ListPageFloatProps, ListPageRequest } from '../types';
|
|
3
|
+
import { ListPageStorageOption } from './types';
|
|
4
|
+
export declare class ListPageStore<FilterValue = any, RecordValue extends Record<string, any> = any> {
|
|
5
|
+
storageKey?: string;
|
|
6
|
+
filters: FilterValue;
|
|
7
|
+
tableDataRequest: ListPageRequest<FilterValue, RecordValue>;
|
|
8
|
+
floats: ListPageFloatProps[];
|
|
9
|
+
visibleFloat?: {
|
|
10
|
+
key: string;
|
|
11
|
+
record: RecordValue;
|
|
12
|
+
onCloseCallback?: true | (() => void);
|
|
13
|
+
};
|
|
14
|
+
loadingData: boolean;
|
|
15
|
+
dataSource: RecordValue[];
|
|
16
|
+
pagination: {
|
|
17
|
+
current: number;
|
|
18
|
+
pageSize: number;
|
|
19
|
+
total: number;
|
|
20
|
+
};
|
|
21
|
+
selection: {
|
|
22
|
+
selectedRowKeys: Key[];
|
|
23
|
+
selectedRows: RecordValue[];
|
|
24
|
+
};
|
|
25
|
+
listeners: Record<string, Function>;
|
|
26
|
+
constructor(options: ListPageStorageOption<FilterValue, RecordValue>);
|
|
27
|
+
submitFiltersChange(value?: FilterValue): void;
|
|
28
|
+
showFloat(key: string, record: any, onCloseCallback?: true | (() => void)): void;
|
|
29
|
+
hideFloat(): void;
|
|
30
|
+
updatePage(page: number, pageSize: number): void;
|
|
31
|
+
fetchTableData(): Promise<void>;
|
|
32
|
+
onSelectChange: (selectedRowKeys: Key[], selectedRows: RecordValue[]) => void;
|
|
33
|
+
clearSelection(): void;
|
|
34
|
+
refreshTable(): void;
|
|
35
|
+
listen(name: string, callback: (data: any) => void): void;
|
|
36
|
+
emit(name: string, data: any): void;
|
|
37
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
1
|
import { makeAutoObservable, runInAction } from "mobx";
|
|
3
|
-
import {
|
|
2
|
+
import { getDefaultValue, setDefaultValue } from "../utils/index.js";
|
|
4
3
|
class ListPageStore {
|
|
5
4
|
storageKey;
|
|
6
5
|
filters = {};
|
|
@@ -96,43 +95,4 @@ class ListPageStore {
|
|
|
96
95
|
this.listeners[name]?.(data);
|
|
97
96
|
}
|
|
98
97
|
}
|
|
99
|
-
|
|
100
|
-
const ListPageProvider = ({ children, initialValues, state, request, storageKey, floats = [] })=>{
|
|
101
|
-
const store = useMemo(()=>new ListPageStore({
|
|
102
|
-
state,
|
|
103
|
-
initialValues,
|
|
104
|
-
request,
|
|
105
|
-
floats,
|
|
106
|
-
storageKey
|
|
107
|
-
}), []);
|
|
108
|
-
return /*#__PURE__*/ jsx(ListPageContext.Provider, {
|
|
109
|
-
value: store,
|
|
110
|
-
children: children
|
|
111
|
-
});
|
|
112
|
-
};
|
|
113
|
-
function useListPageStore() {
|
|
114
|
-
return useContext(ListPageContext);
|
|
115
|
-
}
|
|
116
|
-
const getDefaultValue = (STORAGE_KEY)=>{
|
|
117
|
-
if (!STORAGE_KEY) return {
|
|
118
|
-
currentPage: 1,
|
|
119
|
-
pageSize: 10,
|
|
120
|
-
filterValues: void 0
|
|
121
|
-
};
|
|
122
|
-
const storageValue = localStorage.getItem(STORAGE_KEY);
|
|
123
|
-
const value = JSON.parse(storageValue ?? '{}');
|
|
124
|
-
return {
|
|
125
|
-
currentPage: value.currentPage || 1,
|
|
126
|
-
pageSize: value.pageSize || 10,
|
|
127
|
-
filterValues: value.filterValues || void 0
|
|
128
|
-
};
|
|
129
|
-
};
|
|
130
|
-
const setDefaultValue = (STORAGE_KEY, value)=>{
|
|
131
|
-
if (!STORAGE_KEY) return;
|
|
132
|
-
const defaultValue = getDefaultValue(STORAGE_KEY);
|
|
133
|
-
localStorage.setItem(STORAGE_KEY, JSON.stringify({
|
|
134
|
-
...defaultValue,
|
|
135
|
-
...value
|
|
136
|
-
}));
|
|
137
|
-
};
|
|
138
|
-
export { ListPageProvider, ListPageStore, useListPageStore };
|
|
98
|
+
export { ListPageStore };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { ListPageFloatProps, ListPageRequest, StateValue } from '../types';
|
|
3
|
+
export type ListPageStorageOption<FilterValue = any, RecordValue extends Record<string, any> = any> = {
|
|
4
|
+
storageKey?: string;
|
|
5
|
+
initialValues?: StateValue<FilterValue>;
|
|
6
|
+
state?: StateValue<FilterValue>;
|
|
7
|
+
request: ListPageRequest<FilterValue, RecordValue>;
|
|
8
|
+
floats?: ListPageFloatProps[];
|
|
9
|
+
};
|
|
10
|
+
export type ListPageProviderProps = ListPageStorageOption & {
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ColumnType } from 'antd/es/table';
|
|
2
|
+
import { ListPageTableColumn } from '../components/DataTable/types';
|
|
3
|
+
export declare function useColumns<FilterValue = any, RecordValue extends Record<string, any> = any>(columns: ListPageTableColumn<FilterValue, RecordValue>[]): ColumnType<RecordValue>[];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useListPageStore } from "../context/index.js";
|
|
2
|
+
import { renders } from "../components/DataTable/renders/index.js";
|
|
3
|
+
function useColumns(columns) {
|
|
4
|
+
const ctx = useListPageStore();
|
|
5
|
+
return columns.map((column)=>{
|
|
6
|
+
if (!column.render && column.component) column.render = createColumnRender(column.component, column.props, ctx);
|
|
7
|
+
return column;
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
function createColumnRender(component, props, ctx) {
|
|
11
|
+
if ('string' == typeof component) {
|
|
12
|
+
const render = renders[component];
|
|
13
|
+
if (render) return (value, record, index)=>render(value, record, index, props);
|
|
14
|
+
}
|
|
15
|
+
if ('function' == typeof component) return (value, record, index)=>{
|
|
16
|
+
const render = component;
|
|
17
|
+
return render(value, record, index, ctx);
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export { useColumns };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo } from "react";
|
|
3
|
-
import { useListPageStore } from "../context/
|
|
3
|
+
import { useListPageStore } from "../context/index.js";
|
|
4
4
|
function useFloat() {
|
|
5
5
|
const store = useListPageStore();
|
|
6
6
|
const visibleFloat = store.visibleFloat;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { useListPageStore } from "../context/index.js";
|
|
3
|
+
import { HeaderSection, Title } from "../styles.js";
|
|
4
4
|
function useHeader(props) {
|
|
5
5
|
const store = useListPageStore();
|
|
6
6
|
if (!props) return false;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Pagination } from "antd";
|
|
3
|
-
import { useListPageStore } from "../context/
|
|
4
|
-
import { PaginationContainer } from "
|
|
3
|
+
import { useListPageStore } from "../context/index.js";
|
|
4
|
+
import { PaginationContainer } from "../styles.js";
|
|
5
5
|
function usePagination(props) {
|
|
6
6
|
const store = useListPageStore();
|
|
7
7
|
const ele = false === props ? null : /*#__PURE__*/ jsx(PaginationContainer, {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Button, Tooltip } from "antd";
|
|
3
|
-
import { useListPageStore } from "../context/listpage.js";
|
|
4
3
|
import styled_components from "styled-components";
|
|
4
|
+
import { useListPageStore } from "../context/index.js";
|
|
5
5
|
function useSelectionTools(rowTitleKey) {
|
|
6
6
|
const store = useListPageStore();
|
|
7
7
|
const { selectedRowKeys, selectedRows } = store.selection;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const ListPageWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
2
2
|
export declare const HeaderSection: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
3
3
|
export declare const Title: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
4
4
|
export declare const FilterSection: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
5
5
|
export declare const ToolbarSection: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
6
6
|
export declare const BodySection: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
7
|
+
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;
|
|
8
|
+
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;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import styled_components from "styled-components";
|
|
2
|
-
const
|
|
2
|
+
const ListPageWrapper = styled_components.div`
|
|
3
3
|
width: 100%;
|
|
4
4
|
height: 100%;
|
|
5
5
|
box-sizing: border-box;
|
|
@@ -34,4 +34,17 @@ const BodySection = styled_components.div`
|
|
|
34
34
|
overflow: hidden;
|
|
35
35
|
height: 0;
|
|
36
36
|
`;
|
|
37
|
-
|
|
37
|
+
const PaginationContainer = styled_components.div`
|
|
38
|
+
padding: 12px 16px 12px 0;
|
|
39
|
+
border-top: 1px solid #f0f0f0;
|
|
40
|
+
`;
|
|
41
|
+
const TableContainer = styled_components.div`
|
|
42
|
+
table {
|
|
43
|
+
tr:last-child {
|
|
44
|
+
td {
|
|
45
|
+
border-bottom: none;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
`;
|
|
50
|
+
export { BodySection, FilterSection, HeaderSection, ListPageWrapper, PaginationContainer, TableContainer, Title, ToolbarSection };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { JSX, ReactNode } from 'react';
|
|
2
|
+
import { FilterFormOption } from '../../components/FilterGroup';
|
|
3
|
+
import type { ListPageStore } from './context';
|
|
4
|
+
import { BaseQueryParams, PaginationData } from '../../http-client';
|
|
5
|
+
export type StateValue<FilterValue = any> = {
|
|
6
|
+
filterValues?: FilterValue;
|
|
7
|
+
pageSize?: number;
|
|
8
|
+
currentPage?: number;
|
|
9
|
+
};
|
|
10
|
+
export type FloatComponentProps<T extends Record<string, any> = any> = {
|
|
11
|
+
record?: T;
|
|
12
|
+
visible: boolean;
|
|
13
|
+
onClose: () => void;
|
|
14
|
+
};
|
|
15
|
+
export type FloatRender<RecordValue extends Record<string, any> = any> = (props: FloatComponentProps<RecordValue>) => JSX.Element;
|
|
16
|
+
export type ListPageFloatProps<RecordValue extends Record<string, any> = any> = {
|
|
17
|
+
key: string;
|
|
18
|
+
render: FloatRender<RecordValue>;
|
|
19
|
+
};
|
|
20
|
+
export type ListPageFilterProps<FilterValue = any> = {
|
|
21
|
+
labelInline?: boolean;
|
|
22
|
+
options: FilterFormOption[];
|
|
23
|
+
onReset?: () => void;
|
|
24
|
+
onChange?: (value: FilterValue) => void;
|
|
25
|
+
};
|
|
26
|
+
export type ListPageHeaderProps = {
|
|
27
|
+
title?: ReactNode;
|
|
28
|
+
extra?: ReactNode | ((ctx: ListPageStore) => ReactNode);
|
|
29
|
+
};
|
|
30
|
+
export type ListPageToolbarProps<FilterValue, RecordValue extends Record<string, any> = any> = {
|
|
31
|
+
render: (ctx: ListPageStore<FilterValue, RecordValue>) => ReactNode;
|
|
32
|
+
};
|
|
33
|
+
export type ListPageRequest<FilterValue = any, RecordValue extends Record<string, any> = any> = (pageParams: BaseQueryParams, filterValues: FilterValue) => Promise<PaginationData<RecordValue>>;
|
|
File without changes
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const getDefaultValue: (STORAGE_KEY?: string) => {
|
|
2
|
+
currentPage: any;
|
|
3
|
+
pageSize: any;
|
|
4
|
+
filterValues: any;
|
|
5
|
+
};
|
|
6
|
+
export declare const setDefaultValue: (STORAGE_KEY: string, value: Partial<{
|
|
7
|
+
currentPage: number;
|
|
8
|
+
pageSize: number;
|
|
9
|
+
filterValues?: any;
|
|
10
|
+
}>) => void;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const getDefaultValue = (STORAGE_KEY)=>{
|
|
2
|
+
if (!STORAGE_KEY) return {
|
|
3
|
+
currentPage: 1,
|
|
4
|
+
pageSize: 10,
|
|
5
|
+
filterValues: void 0
|
|
6
|
+
};
|
|
7
|
+
const storageValue = localStorage.getItem(STORAGE_KEY);
|
|
8
|
+
const value = JSON.parse(storageValue ?? '{}');
|
|
9
|
+
return {
|
|
10
|
+
currentPage: value.currentPage || 1,
|
|
11
|
+
pageSize: value.pageSize || 10,
|
|
12
|
+
filterValues: value.filterValues || void 0
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
const setDefaultValue = (STORAGE_KEY, value)=>{
|
|
16
|
+
if (!STORAGE_KEY) return;
|
|
17
|
+
const defaultValue = getDefaultValue(STORAGE_KEY);
|
|
18
|
+
localStorage.setItem(STORAGE_KEY, JSON.stringify({
|
|
19
|
+
...defaultValue,
|
|
20
|
+
...value
|
|
21
|
+
}));
|
|
22
|
+
};
|
|
23
|
+
export { getDefaultValue, setDefaultValue };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import '@ant-design/v5-patch-for-react-19';
|
|
2
2
|
export * from './components/FilterGroup';
|
|
3
|
-
export * from './components/Page';
|
|
4
3
|
export * from './components/InfiniteList';
|
|
5
4
|
export * from './components/Menu';
|
|
6
5
|
export * from './components/DataTable';
|
|
7
6
|
export * from './components/AsyncSelect';
|
|
8
7
|
export * from './components/AsyncButton';
|
|
9
8
|
export * from './components/TextOverflow';
|
|
9
|
+
export * from './components/PageLayout';
|
|
10
10
|
export * from './features/JsonEditor';
|
|
11
11
|
export * from './features/ChatClient';
|
|
12
|
+
export * from './features/ListPage';
|
|
12
13
|
export * from './http-client';
|
|
13
|
-
export * from './context';
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import "@ant-design/v5-patch-for-react-19";
|
|
2
2
|
export * from "./components/FilterGroup/index.js";
|
|
3
|
-
export * from "./components/Page/index.js";
|
|
4
3
|
export * from "./components/InfiniteList/index.js";
|
|
5
4
|
export * from "./components/Menu/index.js";
|
|
6
5
|
export * from "./components/DataTable/index.js";
|
|
7
6
|
export * from "./components/AsyncSelect/index.js";
|
|
8
7
|
export * from "./components/AsyncButton/index.js";
|
|
9
8
|
export * from "./components/TextOverflow/index.js";
|
|
9
|
+
export * from "./components/PageLayout/index.js";
|
|
10
10
|
export * from "./features/JsonEditor/index.js";
|
|
11
11
|
export * from "./features/ChatClient/index.js";
|
|
12
|
+
export * from "./features/ListPage/index.js";
|
|
12
13
|
export * from "./http-client/index.js";
|
|
13
|
-
export * from "./context/index.js";
|
package/package.json
CHANGED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { TableProps } from 'antd';
|
|
2
|
-
import { ColumnType } from 'antd/es/table';
|
|
3
|
-
import { ListPageStore } from '../../context/listpage';
|
|
4
|
-
import { ColumnRender } from '../../../DataTable/components/Render';
|
|
5
|
-
import { ComponentProps, ComponentType } from '../../../DataTable/typings';
|
|
6
|
-
export interface DataTableProps<RecordValue extends Record<string, any> = any> {
|
|
7
|
-
title?: React.ReactNode;
|
|
8
|
-
rowSelectionType?: 'checkbox' | 'radio';
|
|
9
|
-
rowTitleKey?: string;
|
|
10
|
-
extra?: React.ReactNode | ((ctx: ListPageStore<any, RecordValue>) => React.ReactNode);
|
|
11
|
-
columns?: ListPageTableColumn<RecordValue>[];
|
|
12
|
-
tableProps?: Omit<TableProps<RecordValue>, 'dataSource' | 'title' | 'columns'>;
|
|
13
|
-
}
|
|
14
|
-
export interface ListPageTableColumn<RecordValue extends Record<string, any> = any, FilterValue = any> extends ColumnType<RecordValue> {
|
|
15
|
-
component?: ComponentType | ColumnRender<RecordValue, ListPageStore<FilterValue, RecordValue>>;
|
|
16
|
-
props?: ComponentProps;
|
|
17
|
-
}
|
|
18
|
-
export declare const DataTable: ((props: DataTableProps) => import("react/jsx-runtime").JSX.Element) & {
|
|
19
|
-
displayName: string;
|
|
20
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { JSX } from 'react';
|
|
2
|
-
import { FilterFormProps } from '../../../FilterGroup/components/FilterForm';
|
|
3
|
-
export interface ListPageProps {
|
|
4
|
-
title?: React.ReactNode;
|
|
5
|
-
extra?: React.ReactNode;
|
|
6
|
-
filter?: React.ReactNode;
|
|
7
|
-
filterProps?: FilterFormProps;
|
|
8
|
-
toolbar?: React.ReactNode;
|
|
9
|
-
body?: React.ReactNode;
|
|
10
|
-
floats?: {
|
|
11
|
-
key: string;
|
|
12
|
-
content: JSX.Element;
|
|
13
|
-
}[];
|
|
14
|
-
style?: React.CSSProperties;
|
|
15
|
-
}
|
|
16
|
-
export declare const ListPage: (props: ListPageProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo } from "react";
|
|
3
|
-
import { Card } from "antd";
|
|
4
|
-
import { FilterForm } from "../../../FilterGroup/components/FilterForm/index.js";
|
|
5
|
-
import { FloatProvider } from "../../../../context/index.js";
|
|
6
|
-
import { BodySection, FilterSection, HeaderSection, ListPageContainer, Title, ToolbarSection } from "./styles.js";
|
|
7
|
-
const ListPage = (props)=>{
|
|
8
|
-
const { title, extra, filterProps, toolbar, body, style, floats } = props;
|
|
9
|
-
const filter = useMemo(()=>{
|
|
10
|
-
if (props.filter) return props.filter;
|
|
11
|
-
if (filterProps) return /*#__PURE__*/ jsx(Card, {
|
|
12
|
-
children: /*#__PURE__*/ jsx(FilterForm, {
|
|
13
|
-
...filterProps
|
|
14
|
-
})
|
|
15
|
-
});
|
|
16
|
-
return null;
|
|
17
|
-
}, [
|
|
18
|
-
props.filter,
|
|
19
|
-
filterProps
|
|
20
|
-
]);
|
|
21
|
-
const page = /*#__PURE__*/ jsxs(ListPageContainer, {
|
|
22
|
-
style: style,
|
|
23
|
-
children: [
|
|
24
|
-
/*#__PURE__*/ jsxs(HeaderSection, {
|
|
25
|
-
children: [
|
|
26
|
-
/*#__PURE__*/ jsx(Title, {
|
|
27
|
-
children: title
|
|
28
|
-
}),
|
|
29
|
-
/*#__PURE__*/ jsx("div", {
|
|
30
|
-
children: extra
|
|
31
|
-
})
|
|
32
|
-
]
|
|
33
|
-
}),
|
|
34
|
-
filter && /*#__PURE__*/ jsx(FilterSection, {
|
|
35
|
-
children: filter
|
|
36
|
-
}),
|
|
37
|
-
toolbar && /*#__PURE__*/ jsx(ToolbarSection, {
|
|
38
|
-
children: toolbar
|
|
39
|
-
}),
|
|
40
|
-
/*#__PURE__*/ jsx(BodySection, {
|
|
41
|
-
children: body
|
|
42
|
-
})
|
|
43
|
-
]
|
|
44
|
-
});
|
|
45
|
-
if (!floats) return page;
|
|
46
|
-
return /*#__PURE__*/ jsx(FloatProvider, {
|
|
47
|
-
floats: floats,
|
|
48
|
-
children: page
|
|
49
|
-
});
|
|
50
|
-
};
|
|
51
|
-
export { ListPage };
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { ReactNode, RefObject } from 'react';
|
|
2
|
-
import { FloatRender, ListPageStore, TableRequest } from '../../context/listpage';
|
|
3
|
-
import { FilterFormOption } from '../../../FilterGroup';
|
|
4
|
-
import { DataTableProps } from './DataTable';
|
|
5
|
-
import { HeaderProps } from '../../hooks/useHeader';
|
|
6
|
-
import { ListPageContext } from '../..';
|
|
7
|
-
export interface ListPageProps<FilterValue = any, RecordValue extends Record<string, any> = any> {
|
|
8
|
-
pageRef?: RefObject<ListPageContext<FilterValue, RecordValue>>;
|
|
9
|
-
styles?: {
|
|
10
|
-
page?: React.CSSProperties;
|
|
11
|
-
};
|
|
12
|
-
storageKey?: string;
|
|
13
|
-
request: TableRequest<FilterValue, RecordValue>;
|
|
14
|
-
floats?: {
|
|
15
|
-
key: string;
|
|
16
|
-
render: FloatRender<RecordValue>;
|
|
17
|
-
}[];
|
|
18
|
-
state?: {
|
|
19
|
-
filterValues?: FilterValue;
|
|
20
|
-
pageSize?: number;
|
|
21
|
-
currentPage?: number;
|
|
22
|
-
};
|
|
23
|
-
initialValues?: {
|
|
24
|
-
filterValues?: FilterValue;
|
|
25
|
-
pageSize?: number;
|
|
26
|
-
currentPage?: number;
|
|
27
|
-
};
|
|
28
|
-
header?: HeaderProps;
|
|
29
|
-
filter?: {
|
|
30
|
-
labelInline?: boolean;
|
|
31
|
-
options: FilterFormOption[];
|
|
32
|
-
onReset?: () => void;
|
|
33
|
-
onChange?: (value: FilterValue) => void;
|
|
34
|
-
};
|
|
35
|
-
toolbar?: {
|
|
36
|
-
render: (ctx: ListPageStore<FilterValue, RecordValue>) => ReactNode;
|
|
37
|
-
};
|
|
38
|
-
table: DataTableProps<RecordValue>;
|
|
39
|
-
}
|
|
40
|
-
export declare const PureListPage: ((props: ListPageProps) => import("react/jsx-runtime").JSX.Element) & {
|
|
41
|
-
displayName: string;
|
|
42
|
-
};
|
|
43
|
-
export declare const ListPage: (props: ListPageProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { SiderProps } from 'antd';
|
|
3
|
-
export interface PageContainerProps {
|
|
4
|
-
sider?: React.ReactNode;
|
|
5
|
-
header?: React.ReactNode;
|
|
6
|
-
content?: React.ReactNode;
|
|
7
|
-
logo?: React.ReactNode;
|
|
8
|
-
siderProps?: SiderProps;
|
|
9
|
-
}
|
|
10
|
-
export declare const PageContainer: ({ logo, sider, header, content, siderProps, }: PageContainerProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import "react";
|
|
3
|
-
import styled_components from "styled-components";
|
|
4
|
-
import { Layout } from "antd";
|
|
5
|
-
import { useControllableValue } from "ahooks";
|
|
6
|
-
import { PageContextProvider } from "../../context/page.js";
|
|
7
|
-
const { Sider, Content } = Layout;
|
|
8
|
-
const LayoutStyled = styled_components(Layout)`
|
|
9
|
-
height: 100vh;
|
|
10
|
-
overflow: hidden;
|
|
11
|
-
`;
|
|
12
|
-
const SiderStyled = styled_components(Sider)`
|
|
13
|
-
background-color: #fff;
|
|
14
|
-
border-right: 1px solid #e5e5e5;
|
|
15
|
-
display: flex;
|
|
16
|
-
flex-direction: column;
|
|
17
|
-
`;
|
|
18
|
-
const ContentStyled = styled_components(Content)`
|
|
19
|
-
background-color: #fff;
|
|
20
|
-
overflow: auto;
|
|
21
|
-
`;
|
|
22
|
-
const SiderContentWrapper = styled_components.div`
|
|
23
|
-
flex: 1;
|
|
24
|
-
overflow: auto;
|
|
25
|
-
`;
|
|
26
|
-
const SiderContent = styled_components.div`
|
|
27
|
-
display: flex;
|
|
28
|
-
flex-direction: column;
|
|
29
|
-
overflow: hidden;
|
|
30
|
-
`;
|
|
31
|
-
const LogoContentWrapper = styled_components.div`
|
|
32
|
-
flex: 0;
|
|
33
|
-
`;
|
|
34
|
-
const PageContainer = ({ logo, sider, header, content, siderProps })=>{
|
|
35
|
-
const [collapsed, setCollapsed] = useControllableValue({
|
|
36
|
-
value: siderProps?.collapsed,
|
|
37
|
-
defaultValue: false,
|
|
38
|
-
onChange: (collapsed)=>{
|
|
39
|
-
siderProps?.onCollapse?.(collapsed, 'clickTrigger');
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
return /*#__PURE__*/ jsx(PageContextProvider, {
|
|
43
|
-
collapsed: collapsed,
|
|
44
|
-
setCollapsed: setCollapsed,
|
|
45
|
-
children: /*#__PURE__*/ jsxs(LayoutStyled, {
|
|
46
|
-
children: [
|
|
47
|
-
/*#__PURE__*/ jsx(SiderStyled, {
|
|
48
|
-
trigger: null,
|
|
49
|
-
width: 256,
|
|
50
|
-
collapsedWidth: 80,
|
|
51
|
-
breakpoint: "lg",
|
|
52
|
-
...siderProps,
|
|
53
|
-
collapsible: true,
|
|
54
|
-
collapsed: collapsed,
|
|
55
|
-
onCollapse: (collapsed)=>{
|
|
56
|
-
setCollapsed(collapsed);
|
|
57
|
-
},
|
|
58
|
-
children: /*#__PURE__*/ jsxs(SiderContent, {
|
|
59
|
-
children: [
|
|
60
|
-
logo && /*#__PURE__*/ jsx(LogoContentWrapper, {
|
|
61
|
-
children: logo
|
|
62
|
-
}),
|
|
63
|
-
/*#__PURE__*/ jsx(SiderContentWrapper, {
|
|
64
|
-
children: sider
|
|
65
|
-
})
|
|
66
|
-
]
|
|
67
|
-
})
|
|
68
|
-
}),
|
|
69
|
-
/*#__PURE__*/ jsxs(Layout, {
|
|
70
|
-
hasSider: false,
|
|
71
|
-
children: [
|
|
72
|
-
header,
|
|
73
|
-
/*#__PURE__*/ jsx(ContentStyled, {
|
|
74
|
-
children: content
|
|
75
|
-
})
|
|
76
|
-
]
|
|
77
|
-
})
|
|
78
|
-
]
|
|
79
|
-
})
|
|
80
|
-
});
|
|
81
|
-
};
|
|
82
|
-
export { PageContainer };
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { JSX, Key, ReactNode } from 'react';
|
|
2
|
-
import { FloatComponentProps } from '../../../context';
|
|
3
|
-
import { BaseQueryParams, PaginationData } from '../../../http-client/types';
|
|
4
|
-
export type TableRequest<FilterValue = any, RecordValue = any> = (pageParams: BaseQueryParams, filterValues: FilterValue) => Promise<PaginationData<RecordValue>>;
|
|
5
|
-
export type FloatRender<RecordValue extends Record<string, any> = any> = (props: FloatComponentProps<RecordValue>) => JSX.Element;
|
|
6
|
-
export type ListPageStorageOption<FilterValue = any, RecordValue extends Record<string, any> = any> = {
|
|
7
|
-
storageKey?: string;
|
|
8
|
-
initialValues?: {
|
|
9
|
-
filterValues?: FilterValue;
|
|
10
|
-
pageSize?: number;
|
|
11
|
-
currentPage?: number;
|
|
12
|
-
};
|
|
13
|
-
state?: {
|
|
14
|
-
currentPage?: number;
|
|
15
|
-
pageSize?: number;
|
|
16
|
-
filterValues?: FilterValue;
|
|
17
|
-
};
|
|
18
|
-
request: TableRequest<FilterValue, RecordValue>;
|
|
19
|
-
floats: {
|
|
20
|
-
key: string;
|
|
21
|
-
render: FloatRender<RecordValue>;
|
|
22
|
-
}[];
|
|
23
|
-
};
|
|
24
|
-
export declare class ListPageStore<FilterValue = any, RecordValue extends Record<string, any> = any> {
|
|
25
|
-
storageKey?: string;
|
|
26
|
-
filters: FilterValue;
|
|
27
|
-
tableDataRequest: TableRequest<FilterValue, RecordValue>;
|
|
28
|
-
floats: {
|
|
29
|
-
key: string;
|
|
30
|
-
render: FloatRender<RecordValue>;
|
|
31
|
-
}[];
|
|
32
|
-
visibleFloat?: {
|
|
33
|
-
key: string;
|
|
34
|
-
record: RecordValue;
|
|
35
|
-
onCloseCallback?: true | (() => void);
|
|
36
|
-
};
|
|
37
|
-
loadingData: boolean;
|
|
38
|
-
dataSource: RecordValue[];
|
|
39
|
-
pagination: {
|
|
40
|
-
current: number;
|
|
41
|
-
pageSize: number;
|
|
42
|
-
total: number;
|
|
43
|
-
};
|
|
44
|
-
selection: {
|
|
45
|
-
selectedRowKeys: Key[];
|
|
46
|
-
selectedRows: RecordValue[];
|
|
47
|
-
};
|
|
48
|
-
listeners: Record<string, Function>;
|
|
49
|
-
constructor(options: ListPageStorageOption<FilterValue, RecordValue>);
|
|
50
|
-
submitFiltersChange(value?: FilterValue): void;
|
|
51
|
-
showFloat(key: string, record: any, onCloseCallback?: true | (() => void)): void;
|
|
52
|
-
hideFloat(): void;
|
|
53
|
-
updatePage(page: number, pageSize: number): void;
|
|
54
|
-
fetchTableData(): Promise<void>;
|
|
55
|
-
onSelectChange: (selectedRowKeys: Key[], selectedRows: RecordValue[]) => void;
|
|
56
|
-
clearSelection(): void;
|
|
57
|
-
refreshTable(): void;
|
|
58
|
-
listen(name: string, callback: (data: any) => void): void;
|
|
59
|
-
emit(name: string, data: any): void;
|
|
60
|
-
}
|
|
61
|
-
export declare const ListPageProvider: ({ children, initialValues, state, request, storageKey, floats, }: {
|
|
62
|
-
children: ReactNode;
|
|
63
|
-
state?: {
|
|
64
|
-
filterValues?: any;
|
|
65
|
-
pageSize?: number;
|
|
66
|
-
currentPage?: number;
|
|
67
|
-
};
|
|
68
|
-
initialValues?: {
|
|
69
|
-
filterValues?: any;
|
|
70
|
-
pageSize?: number;
|
|
71
|
-
currentPage?: number;
|
|
72
|
-
};
|
|
73
|
-
storageKey?: string;
|
|
74
|
-
floats?: {
|
|
75
|
-
key: string;
|
|
76
|
-
render: FloatRender<any>;
|
|
77
|
-
}[];
|
|
78
|
-
request: TableRequest<any, any>;
|
|
79
|
-
}) => import("react/jsx-runtime").JSX.Element;
|
|
80
|
-
export declare function useListPageStore(): ListPageStore<any, any>;
|