listpage-next 0.0.171 → 0.0.172
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/PageLayout/index.d.ts +2 -1
- package/dist/components/PageLayout/components/PageLogo/index.d.ts +7 -0
- package/dist/components/PageLayout/components/PageLogo/index.js +37 -0
- package/dist/components/PageLayout/components/PageProvider/float.d.ts +20 -0
- package/dist/components/PageLayout/components/PageProvider/float.js +64 -0
- package/dist/components/PageLayout/components/PageProvider/index.d.ts +5 -1
- package/dist/components/PageLayout/components/PageProvider/index.js +21 -8
- package/dist/components/PageLayout/components/PageSider/index.d.ts +2 -1
- package/dist/components/PageLayout/components/PageSider/index.js +4 -5
- package/dist/features/ListPage/types.d.ts +2 -9
- package/package.json +1 -1
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { SiderProps } from 'antd';
|
|
2
|
+
import { PageLogoProps } from '../PageLogo';
|
|
2
3
|
export interface PageLayoutProps {
|
|
3
4
|
sider?: React.ReactNode;
|
|
4
5
|
header?: React.ReactNode;
|
|
5
6
|
content?: React.ReactNode;
|
|
6
|
-
logo?:
|
|
7
|
+
logo?: PageLogoProps;
|
|
7
8
|
defaultCollapsed?: boolean;
|
|
8
9
|
siderProps?: Omit<SiderProps, 'collapsed' | 'onCollapse'>;
|
|
9
10
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Avatar, Image } from "antd";
|
|
3
|
+
import { styled } from "styled-components";
|
|
4
|
+
const PageLogo = (props)=>{
|
|
5
|
+
const { src, icon, title } = props;
|
|
6
|
+
return /*#__PURE__*/ jsxs(LogoContentWrapper, {
|
|
7
|
+
children: [
|
|
8
|
+
src && /*#__PURE__*/ jsx(Image, {
|
|
9
|
+
width: 30,
|
|
10
|
+
height: 30,
|
|
11
|
+
src: src,
|
|
12
|
+
preview: true
|
|
13
|
+
}),
|
|
14
|
+
icon && /*#__PURE__*/ jsx(Avatar, {
|
|
15
|
+
icon: icon,
|
|
16
|
+
shape: "circle",
|
|
17
|
+
size: 30
|
|
18
|
+
}),
|
|
19
|
+
title && /*#__PURE__*/ jsx(TitleContentWrapper, {
|
|
20
|
+
children: title
|
|
21
|
+
})
|
|
22
|
+
]
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
const LogoContentWrapper = styled.div`
|
|
26
|
+
flex: 0;
|
|
27
|
+
display: flex;
|
|
28
|
+
align-items: center;
|
|
29
|
+
gap: 8px;
|
|
30
|
+
height: 48px;
|
|
31
|
+
`;
|
|
32
|
+
const TitleContentWrapper = styled.div`
|
|
33
|
+
font-size: 16px;
|
|
34
|
+
font-weight: 600;
|
|
35
|
+
color: #333;
|
|
36
|
+
`;
|
|
37
|
+
export { PageLogo };
|
|
@@ -0,0 +1,20 @@
|
|
|
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?: PageFloatProps[];
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export type FloatComponentProps<T extends Record<string, any> = any> = {
|
|
13
|
+
record: T;
|
|
14
|
+
visible: boolean;
|
|
15
|
+
onClose: () => void;
|
|
16
|
+
};
|
|
17
|
+
export type PageFloatProps<T extends Record<string, any> = any> = {
|
|
18
|
+
key: string;
|
|
19
|
+
render: (props: FloatComponentProps<T>) => JSX.Element;
|
|
20
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { 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 elesRef = useRef([]);
|
|
15
|
+
const [eles, setEles] = useState([]);
|
|
16
|
+
const hideFloat = useCallback((key)=>{
|
|
17
|
+
elesRef.current = elesRef.current.filter((ele)=>ele.key !== key);
|
|
18
|
+
setEles([
|
|
19
|
+
...elesRef.current.map((i)=>i.ele)
|
|
20
|
+
]);
|
|
21
|
+
}, [
|
|
22
|
+
eles
|
|
23
|
+
]);
|
|
24
|
+
const showFloat = useCallback((key, record, onCloseCallback)=>{
|
|
25
|
+
const Component = floats.find((i)=>i.key === key)?.render;
|
|
26
|
+
if (!Component) return;
|
|
27
|
+
const node = /*#__PURE__*/ jsx(Component, {
|
|
28
|
+
visible: true,
|
|
29
|
+
record: record,
|
|
30
|
+
onClose: ()=>{
|
|
31
|
+
onCloseCallback?.();
|
|
32
|
+
elesRef.current = elesRef.current.filter(({ ele })=>ele !== node);
|
|
33
|
+
setEles([
|
|
34
|
+
...elesRef.current.map((i)=>i.ele)
|
|
35
|
+
]);
|
|
36
|
+
}
|
|
37
|
+
}, key);
|
|
38
|
+
elesRef.current.push({
|
|
39
|
+
key,
|
|
40
|
+
ele: node
|
|
41
|
+
});
|
|
42
|
+
setEles([
|
|
43
|
+
...elesRef.current.map((i)=>i.ele)
|
|
44
|
+
]);
|
|
45
|
+
}, [
|
|
46
|
+
floats,
|
|
47
|
+
eles,
|
|
48
|
+
elesRef,
|
|
49
|
+
setEles
|
|
50
|
+
]);
|
|
51
|
+
return /*#__PURE__*/ jsx(FloatContext.Provider, {
|
|
52
|
+
value: {
|
|
53
|
+
showFloat,
|
|
54
|
+
hideFloat
|
|
55
|
+
},
|
|
56
|
+
children: /*#__PURE__*/ jsxs(Fragment, {
|
|
57
|
+
children: [
|
|
58
|
+
children,
|
|
59
|
+
eles
|
|
60
|
+
]
|
|
61
|
+
})
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
export { FloatContext, FloatProvider, useFloatContext };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PageFloatProps } from './float';
|
|
1
2
|
export declare const PageContext: import("react").Context<{
|
|
2
3
|
collapsed: boolean;
|
|
3
4
|
setCollapsed: (collapsed: boolean) => void;
|
|
@@ -5,9 +6,12 @@ export declare const PageContext: import("react").Context<{
|
|
|
5
6
|
export interface PageProviderProps {
|
|
6
7
|
children: React.ReactNode;
|
|
7
8
|
defaultCollapsed?: boolean;
|
|
9
|
+
floats?: PageFloatProps[];
|
|
8
10
|
}
|
|
9
|
-
export declare const PageProvider: ({ children, defaultCollapsed, }: PageProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare const PageProvider: ({ children, defaultCollapsed, floats, }: PageProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
12
|
export declare const usePageContext: () => {
|
|
11
13
|
collapsed: boolean;
|
|
12
14
|
setCollapsed: (collapsed: boolean) => void;
|
|
15
|
+
showFloat: (key: string, record: any, onCloseCallback?: () => void) => void;
|
|
16
|
+
hideFloat: (key: string) => void;
|
|
13
17
|
};
|
|
@@ -1,18 +1,31 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { createContext, useContext, useState } from "react";
|
|
3
|
+
import { FloatProvider, useFloatContext } from "./float.js";
|
|
3
4
|
const PageContext = /*#__PURE__*/ createContext({
|
|
4
5
|
collapsed: false,
|
|
5
6
|
setCollapsed: ()=>{}
|
|
6
7
|
});
|
|
7
|
-
const PageProvider = ({ children, defaultCollapsed = false })=>{
|
|
8
|
+
const PageProvider = ({ children, defaultCollapsed = false, floats = [] })=>{
|
|
8
9
|
const [collapsed, setCollapsed] = useState(defaultCollapsed);
|
|
9
|
-
return /*#__PURE__*/ jsx(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
return /*#__PURE__*/ jsx(FloatProvider, {
|
|
11
|
+
floats: floats,
|
|
12
|
+
children: /*#__PURE__*/ jsx(PageContext.Provider, {
|
|
13
|
+
value: {
|
|
14
|
+
collapsed,
|
|
15
|
+
setCollapsed
|
|
16
|
+
},
|
|
17
|
+
children: children
|
|
18
|
+
})
|
|
15
19
|
});
|
|
16
20
|
};
|
|
17
|
-
const usePageContext = ()=>
|
|
21
|
+
const usePageContext = ()=>{
|
|
22
|
+
const { showFloat, hideFloat } = useFloatContext();
|
|
23
|
+
const { collapsed, setCollapsed } = useContext(PageContext);
|
|
24
|
+
return {
|
|
25
|
+
collapsed,
|
|
26
|
+
setCollapsed,
|
|
27
|
+
showFloat,
|
|
28
|
+
hideFloat
|
|
29
|
+
};
|
|
30
|
+
};
|
|
18
31
|
export { PageContext, PageProvider, usePageContext };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { SiderProps } from 'antd';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
+
import { PageLogoProps } from '../PageLogo';
|
|
3
4
|
export interface PageSiderProps extends Omit<SiderProps, 'children'> {
|
|
4
|
-
logo?:
|
|
5
|
+
logo?: PageLogoProps;
|
|
5
6
|
children?: ReactNode;
|
|
6
7
|
}
|
|
7
8
|
export declare const PageSider: (props: PageSiderProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { styled } from "styled-components";
|
|
3
3
|
import { Layout } from "antd";
|
|
4
|
+
import { PageLogo } from "../PageLogo/index.js";
|
|
4
5
|
const PageSider = (props)=>{
|
|
5
6
|
const { logo, children, ...siderProps } = props;
|
|
6
7
|
return /*#__PURE__*/ jsx(SiderStyled, {
|
|
@@ -12,8 +13,8 @@ const PageSider = (props)=>{
|
|
|
12
13
|
...siderProps,
|
|
13
14
|
children: /*#__PURE__*/ jsxs(SiderContent, {
|
|
14
15
|
children: [
|
|
15
|
-
logo && /*#__PURE__*/ jsx(
|
|
16
|
-
|
|
16
|
+
logo && /*#__PURE__*/ jsx(PageLogo, {
|
|
17
|
+
...logo
|
|
17
18
|
}),
|
|
18
19
|
/*#__PURE__*/ jsx(SiderContentWrapper, {
|
|
19
20
|
children: children
|
|
@@ -32,12 +33,10 @@ const SiderContent = styled.div`
|
|
|
32
33
|
display: flex;
|
|
33
34
|
flex-direction: column;
|
|
34
35
|
overflow: hidden;
|
|
36
|
+
height: 100%;
|
|
35
37
|
`;
|
|
36
38
|
const SiderContentWrapper = styled.div`
|
|
37
39
|
flex: 1;
|
|
38
40
|
overflow: auto;
|
|
39
41
|
`;
|
|
40
|
-
const LogoContentWrapper = styled.div`
|
|
41
|
-
flex: 0;
|
|
42
|
-
`;
|
|
43
42
|
export { PageSider };
|
|
@@ -2,21 +2,14 @@ import { JSX, ReactNode } from 'react';
|
|
|
2
2
|
import { FilterFormOption } from '../../components/FilterGroup';
|
|
3
3
|
import type { ListPageStore } from './context';
|
|
4
4
|
import { BaseQueryParams, PaginationData } from '../../http-client';
|
|
5
|
+
import type { FloatComponentProps } from '../../components/PageLayout/components/PageProvider/float';
|
|
5
6
|
export type StateValue<FilterValue = any> = {
|
|
6
7
|
filterValues?: FilterValue;
|
|
7
8
|
pageSize?: number;
|
|
8
9
|
currentPage?: number;
|
|
9
10
|
};
|
|
10
|
-
export type FloatComponentProps
|
|
11
|
-
record?: T;
|
|
12
|
-
visible: boolean;
|
|
13
|
-
onClose: () => void;
|
|
14
|
-
};
|
|
11
|
+
export type { FloatComponentProps, PageFloatProps as ListPageFloatProps, } from '../../components/PageLayout/components/PageProvider/float';
|
|
15
12
|
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
13
|
export type ListPageFilterProps<FilterValue = any> = {
|
|
21
14
|
labelInline?: boolean;
|
|
22
15
|
options: FilterFormOption[];
|