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.
Files changed (80) hide show
  1. package/dist/components/PageLayout/components/PageContent/index.d.ts +5 -0
  2. package/dist/components/PageLayout/components/PageContent/index.js +15 -0
  3. package/dist/components/PageLayout/components/PageHeader/index.d.ts +5 -0
  4. package/dist/components/PageLayout/components/PageHeader/index.js +5 -0
  5. package/dist/components/PageLayout/components/PageLayout/index.d.ts +10 -0
  6. package/dist/components/PageLayout/components/PageLayout/index.js +44 -0
  7. package/dist/components/{Page/components/Loading → PageLayout/components/PageLoading}/index.js +16 -6
  8. package/dist/components/{Page/context/page.d.ts → PageLayout/components/PageProvider/index.d.ts} +4 -4
  9. package/dist/components/{Page/context/page.js → PageLayout/components/PageProvider/index.js} +6 -3
  10. package/dist/components/PageLayout/components/PageSider/index.d.ts +7 -0
  11. package/dist/components/PageLayout/components/PageSider/index.js +43 -0
  12. package/dist/components/PageLayout/index.d.ts +4 -0
  13. package/dist/components/PageLayout/index.js +4 -0
  14. package/dist/context/index.d.ts +1 -1
  15. package/dist/demos/demo2.js +2 -2
  16. package/dist/demos/demo5.js +1 -1
  17. package/dist/features/ChatClient/components/ChatContent/index.js +1 -1
  18. package/dist/features/ChatClient/ui/Bubble/BubbleList.js +1 -1
  19. package/dist/features/ListPage/components/DataTable/index.d.ts +4 -0
  20. package/dist/{components/Page/components/ListPage/DataTable.js → features/ListPage/components/DataTable/index.js} +3 -3
  21. package/dist/features/ListPage/components/DataTable/renders/index.d.ts +7 -0
  22. package/dist/features/ListPage/components/DataTable/renders/index.js +13 -0
  23. package/dist/features/ListPage/components/DataTable/renders/link.d.ts +2 -0
  24. package/dist/features/ListPage/components/DataTable/renders/link.js +27 -0
  25. package/dist/features/ListPage/components/DataTable/renders/switch.d.ts +2 -0
  26. package/dist/features/ListPage/components/DataTable/renders/switch.js +10 -0
  27. package/dist/features/ListPage/components/DataTable/renders/tag.d.ts +2 -0
  28. package/dist/features/ListPage/components/DataTable/renders/tag.js +7 -0
  29. package/dist/features/ListPage/components/DataTable/renders/text.d.ts +2 -0
  30. package/dist/features/ListPage/components/DataTable/renders/text.js +10 -0
  31. package/dist/features/ListPage/components/DataTable/renders/time.d.ts +2 -0
  32. package/dist/features/ListPage/components/DataTable/renders/time.js +15 -0
  33. package/dist/features/ListPage/components/DataTable/types.d.ts +34 -0
  34. package/dist/features/ListPage/components/DataTable/types.js +0 -0
  35. package/dist/features/ListPage/components/DataTable/utils/render.d.ts +2 -0
  36. package/dist/features/ListPage/components/DataTable/utils/render.js +25 -0
  37. package/dist/features/ListPage/components/ListPageContainer/index.d.ts +17 -0
  38. package/dist/{components/Page/components/ListPage/v2.js → features/ListPage/components/ListPageContainer/index.js} +10 -24
  39. package/dist/features/ListPage/context/context.d.ts +4 -0
  40. package/dist/features/ListPage/context/context.js +22 -0
  41. package/dist/features/ListPage/context/index.d.ts +2 -0
  42. package/dist/features/ListPage/context/index.js +3 -0
  43. package/dist/features/ListPage/context/store.d.ts +37 -0
  44. package/dist/{components/Page/context/listpage.js → features/ListPage/context/store.js} +2 -42
  45. package/dist/features/ListPage/context/types.d.ts +12 -0
  46. package/dist/features/ListPage/context/types.js +0 -0
  47. package/dist/features/ListPage/hooks/useColumns.d.ts +3 -0
  48. package/dist/features/ListPage/hooks/useColumns.js +20 -0
  49. package/dist/{components/Page → features/ListPage}/hooks/useFloat.js +1 -1
  50. package/dist/features/ListPage/hooks/useHeader.d.ts +2 -0
  51. package/dist/{components/Page → features/ListPage}/hooks/useHeader.js +2 -2
  52. package/dist/{components/Page → features/ListPage}/hooks/usePagination.js +2 -2
  53. package/dist/{components/Page → features/ListPage}/hooks/useSelectionTools.js +1 -1
  54. package/dist/features/ListPage/index.d.ts +3 -0
  55. package/dist/features/ListPage/index.js +4 -0
  56. package/dist/{components/Page/components → features}/ListPage/styles.d.ts +3 -1
  57. package/dist/{components/Page/components → features}/ListPage/styles.js +15 -2
  58. package/dist/features/ListPage/types.d.ts +33 -0
  59. package/dist/features/ListPage/types.js +0 -0
  60. package/dist/features/ListPage/utils/index.d.ts +10 -0
  61. package/dist/features/ListPage/utils/index.js +23 -0
  62. package/dist/index.d.ts +2 -2
  63. package/dist/index.js +2 -2
  64. package/package.json +1 -1
  65. package/dist/components/Page/components/ListPage/DataTable.d.ts +0 -20
  66. package/dist/components/Page/components/ListPage/index.d.ts +0 -16
  67. package/dist/components/Page/components/ListPage/index.js +0 -51
  68. package/dist/components/Page/components/ListPage/v2.d.ts +0 -43
  69. package/dist/components/Page/components/PageContainer/index.d.ts +0 -10
  70. package/dist/components/Page/components/PageContainer/index.js +0 -82
  71. package/dist/components/Page/context/listpage.d.ts +0 -80
  72. package/dist/components/Page/hooks/useColumns.d.ts +0 -3
  73. package/dist/components/Page/hooks/useColumns.js +0 -10
  74. package/dist/components/Page/hooks/useHeader.d.ts +0 -7
  75. package/dist/components/Page/index.d.ts +0 -8
  76. package/dist/components/Page/index.js +0 -7
  77. /package/dist/components/{Page/components/Loading → PageLayout/components/PageLoading}/index.d.ts +0 -0
  78. /package/dist/{components/Page → features/ListPage}/hooks/useFloat.d.ts +0 -0
  79. /package/dist/{components/Page → features/ListPage}/hooks/usePagination.d.ts +0 -0
  80. /package/dist/{components/Page → features/ListPage}/hooks/useSelectionTools.d.ts +0 -0
@@ -0,0 +1,5 @@
1
+ import { ReactNode } from 'react';
2
+ export interface PageContentProps {
3
+ children?: ReactNode;
4
+ }
5
+ export declare const PageContent: (props: PageContentProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,15 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Layout } from "antd";
3
+ import { styled } from "styled-components";
4
+ const { Content } = Layout;
5
+ const PageContent = (props)=>{
6
+ const { children } = props;
7
+ return /*#__PURE__*/ jsx(ContentStyled, {
8
+ children: children
9
+ });
10
+ };
11
+ const ContentStyled = styled(Content)`
12
+ background-color: #fff;
13
+ overflow: auto;
14
+ `;
15
+ export { PageContent };
@@ -0,0 +1,5 @@
1
+ import { ReactNode } from 'react';
2
+ export interface PageHeaderProps {
3
+ children?: ReactNode;
4
+ }
5
+ export declare const PageHeader: (props: PageHeaderProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,5 @@
1
+ import { Fragment, jsx } from "react/jsx-runtime";
2
+ const PageHeader = (props)=>/*#__PURE__*/ jsx(Fragment, {
3
+ children: props.children
4
+ });
5
+ export { PageHeader };
@@ -0,0 +1,10 @@
1
+ import { SiderProps } from 'antd';
2
+ export interface PageLayoutProps {
3
+ sider?: React.ReactNode;
4
+ header?: React.ReactNode;
5
+ content?: React.ReactNode;
6
+ logo?: React.ReactNode;
7
+ defaultCollapsed?: boolean;
8
+ siderProps?: Omit<SiderProps, 'collapsed' | 'onCollapse'>;
9
+ }
10
+ export declare const PageLayout: (props: PageLayoutProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,44 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Layout } from "antd";
3
+ import { styled } from "styled-components";
4
+ import { PageSider } from "../PageSider/index.js";
5
+ import { PageHeader } from "../PageHeader/index.js";
6
+ import { PageContent } from "../PageContent/index.js";
7
+ import { PageProvider, usePageContext } from "../PageProvider/index.js";
8
+ const PageLayoutComponent = (props)=>{
9
+ const { siderProps, sider, header, content, logo } = props;
10
+ const { collapsed, setCollapsed } = usePageContext();
11
+ return /*#__PURE__*/ jsxs(LayoutStyled, {
12
+ children: [
13
+ /*#__PURE__*/ jsx(PageSider, {
14
+ ...siderProps,
15
+ logo: logo,
16
+ collapsed: collapsed,
17
+ onCollapse: setCollapsed,
18
+ children: sider
19
+ }),
20
+ /*#__PURE__*/ jsxs(Layout, {
21
+ hasSider: false,
22
+ children: [
23
+ /*#__PURE__*/ jsx(PageHeader, {
24
+ children: header
25
+ }),
26
+ /*#__PURE__*/ jsx(PageContent, {
27
+ children: content
28
+ })
29
+ ]
30
+ })
31
+ ]
32
+ });
33
+ };
34
+ const PageLayout = (props)=>/*#__PURE__*/ jsx(PageProvider, {
35
+ defaultCollapsed: props.defaultCollapsed,
36
+ children: /*#__PURE__*/ jsx(PageLayoutComponent, {
37
+ ...props
38
+ })
39
+ });
40
+ const LayoutStyled = styled(Layout)`
41
+ height: 100vh;
42
+ overflow: hidden;
43
+ `;
44
+ export { PageLayout };
@@ -15,7 +15,7 @@ const PageLoading = styled_components.div`
15
15
  &::after {
16
16
  animation: LoadingAnimation 1.5s linear infinite;
17
17
  border-radius: 5px;
18
- content: "";
18
+ content: '';
19
19
  height: 10px;
20
20
  left: 50%;
21
21
  position: absolute;
@@ -28,27 +28,37 @@ const PageLoading = styled_components.div`
28
28
 
29
29
  @keyframes LoadingAnimation {
30
30
  0% {
31
- box-shadow: -16px 20px 0 -5px #b89dfe, 0 20px 0 0 #2e6ee7,
31
+ box-shadow:
32
+ -16px 20px 0 -5px #b89dfe,
33
+ 0 20px 0 0 #2e6ee7,
32
34
  16px 20px 0 2px #b89dfe;
33
35
  }
34
36
 
35
37
  25% {
36
- box-shadow: -16px 20px 0 0 #b89dfe, 0 20px 0 2px #2e6ee7,
38
+ box-shadow:
39
+ -16px 20px 0 0 #b89dfe,
40
+ 0 20px 0 2px #2e6ee7,
37
41
  16px 20px 0 0 #b89dfe;
38
42
  }
39
43
 
40
44
  50% {
41
- box-shadow: -16px 20px 0 2px #b89dfe, 0 20px 0 0 #2e6ee7,
45
+ box-shadow:
46
+ -16px 20px 0 2px #b89dfe,
47
+ 0 20px 0 0 #2e6ee7,
42
48
  16px 20px 0 -5px #b89dfe;
43
49
  }
44
50
 
45
51
  75% {
46
- box-shadow: -16px 20px 0 0 #b89dfe, 0 20px 0 -5px #2e6ee7,
52
+ box-shadow:
53
+ -16px 20px 0 0 #b89dfe,
54
+ 0 20px 0 -5px #2e6ee7,
47
55
  16px 20px 0 0 #b89dfe;
48
56
  }
49
57
 
50
58
  to {
51
- box-shadow: -16px 20px 0 -5px #b89dfe, 0 20px 0 0 #2e6ee7,
59
+ box-shadow:
60
+ -16px 20px 0 -5px #b89dfe,
61
+ 0 20px 0 0 #2e6ee7,
52
62
  16px 20px 0 2px #b89dfe;
53
63
  }
54
64
  }
@@ -2,11 +2,11 @@ export declare const PageContext: import("react").Context<{
2
2
  collapsed: boolean;
3
3
  setCollapsed: (collapsed: boolean) => void;
4
4
  }>;
5
- export declare const PageContextProvider: ({ children, collapsed, setCollapsed, }: {
5
+ export interface PageProviderProps {
6
6
  children: React.ReactNode;
7
- collapsed: boolean;
8
- setCollapsed: (collapsed: boolean) => void;
9
- }) => import("react/jsx-runtime").JSX.Element;
7
+ defaultCollapsed?: boolean;
8
+ }
9
+ export declare const PageProvider: ({ children, defaultCollapsed, }: PageProviderProps) => import("react/jsx-runtime").JSX.Element;
10
10
  export declare const usePageContext: () => {
11
11
  collapsed: boolean;
12
12
  setCollapsed: (collapsed: boolean) => void;
@@ -1,15 +1,18 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { createContext, useContext } from "react";
2
+ import { createContext, useContext, useState } from "react";
3
3
  const PageContext = /*#__PURE__*/ createContext({
4
4
  collapsed: false,
5
5
  setCollapsed: ()=>{}
6
6
  });
7
- const PageContextProvider = ({ children, collapsed, setCollapsed })=>/*#__PURE__*/ jsx(PageContext.Provider, {
7
+ const PageProvider = ({ children, defaultCollapsed = false })=>{
8
+ const [collapsed, setCollapsed] = useState(defaultCollapsed);
9
+ return /*#__PURE__*/ jsx(PageContext.Provider, {
8
10
  value: {
9
11
  collapsed,
10
12
  setCollapsed
11
13
  },
12
14
  children: children
13
15
  });
16
+ };
14
17
  const usePageContext = ()=>useContext(PageContext);
15
- export { PageContext, PageContextProvider, usePageContext };
18
+ export { PageContext, PageProvider, usePageContext };
@@ -0,0 +1,7 @@
1
+ import { SiderProps } from 'antd';
2
+ import { ReactNode } from 'react';
3
+ export interface PageSiderProps extends Omit<SiderProps, 'children'> {
4
+ logo?: ReactNode;
5
+ children?: ReactNode;
6
+ }
7
+ export declare const PageSider: (props: PageSiderProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,43 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { styled } from "styled-components";
3
+ import { Layout } from "antd";
4
+ const PageSider = (props)=>{
5
+ const { logo, children, ...siderProps } = props;
6
+ return /*#__PURE__*/ jsx(SiderStyled, {
7
+ trigger: null,
8
+ width: 256,
9
+ collapsedWidth: 80,
10
+ breakpoint: "lg",
11
+ collapsible: true,
12
+ ...siderProps,
13
+ children: /*#__PURE__*/ jsxs(SiderContent, {
14
+ children: [
15
+ logo && /*#__PURE__*/ jsx(LogoContentWrapper, {
16
+ children: logo
17
+ }),
18
+ /*#__PURE__*/ jsx(SiderContentWrapper, {
19
+ children: children
20
+ })
21
+ ]
22
+ })
23
+ });
24
+ };
25
+ const SiderStyled = styled(Layout.Sider)`
26
+ background-color: #fff;
27
+ border-right: 1px solid #e5e5e5;
28
+ display: flex;
29
+ flex-direction: column;
30
+ `;
31
+ const SiderContent = styled.div`
32
+ display: flex;
33
+ flex-direction: column;
34
+ overflow: hidden;
35
+ `;
36
+ const SiderContentWrapper = styled.div`
37
+ flex: 1;
38
+ overflow: auto;
39
+ `;
40
+ const LogoContentWrapper = styled.div`
41
+ flex: 0;
42
+ `;
43
+ export { PageSider };
@@ -0,0 +1,4 @@
1
+ export { PageLoading } from './components/PageLoading';
2
+ export { PageLayout } from './components/PageLayout';
3
+ export type { PageLayoutProps } from './components/PageLayout';
4
+ export { PageContext, usePageContext } from './components/PageProvider';
@@ -0,0 +1,4 @@
1
+ import { PageLoading } from "./components/PageLoading/index.js";
2
+ import { PageLayout } from "./components/PageLayout/index.js";
3
+ import { PageContext, usePageContext } from "./components/PageProvider/index.js";
4
+ export { PageContext, PageLayout, PageLoading, usePageContext };
@@ -1 +1 @@
1
- export { FloatContext, FloatProvider, useFloatContext, type FloatComponentProps } from './float';
1
+ export { FloatContext, FloatProvider, useFloatContext } from './float';
@@ -1,5 +1,5 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { PageContainer } from "../components/Page/index.js";
2
+ import { PageLayout } from "../components/PageLayout/index.js";
3
3
  const Demo2 = ()=>{
4
4
  const sider = /*#__PURE__*/ jsx("div", {
5
5
  children: "侧边栏"
@@ -10,7 +10,7 @@ const Demo2 = ()=>{
10
10
  const header = /*#__PURE__*/ jsx("div", {
11
11
  children: "顶部"
12
12
  });
13
- return /*#__PURE__*/ jsx(PageContainer, {
13
+ return /*#__PURE__*/ jsx(PageLayout, {
14
14
  sider: sider,
15
15
  content: content,
16
16
  header: header
@@ -1,6 +1,6 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { Button, DatePicker, Input, Select, Space, Switch } from "antd";
3
- import { ListPage } from "../components/Page/components/ListPage/v2.js";
3
+ import { ListPage } from "../features/ListPage/index.js";
4
4
  const columns = [
5
5
  {
6
6
  key: 'enable',
@@ -5,7 +5,7 @@ import { styled } from "styled-components";
5
5
  import { ClientContentBody } from "./ClientContentBody.js";
6
6
  import { ClientContentHeader } from "./ClientContentHeader.js";
7
7
  import { MessageProvider, useChatClientContext } from "../../context/index.js";
8
- import { PageLoading } from "../../../../components/Page/components/Loading/index.js";
8
+ import { PageLoading } from "../../../../components/PageLayout/index.js";
9
9
  const ClientContentComponent = (props)=>{
10
10
  const { extra, style, header, sender, className, title, onTitleChange, onClickNewConversation, senderProps, bubbleProps } = props;
11
11
  return /*#__PURE__*/ jsxs(Container, {
@@ -1,7 +1,7 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { useRef } from "react";
3
3
  import { styled } from "styled-components";
4
- import { PageLoading } from "../../../../components/Page/index.js";
4
+ import { PageLoading } from "../../../../components/PageLayout/index.js";
5
5
  const BubbleList = (props)=>{
6
6
  const { loading, styles, messages, messageRender } = props;
7
7
  const bottomRef = useRef(null);
@@ -0,0 +1,4 @@
1
+ import { DataTableProps } from './types';
2
+ export declare const DataTable: (<FilterValue = any, RecordValue extends Record<string, any> = any>(props: DataTableProps<FilterValue, RecordValue>) => import("react/jsx-runtime").JSX.Element) & {
3
+ displayName: string;
4
+ };
@@ -1,13 +1,13 @@
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/listpage.js";
5
- import { TableContainer } from "../../../DataTable/index.js";
4
+ import { useListPageStore } from "../../context/index.js";
6
5
  import { usePagination } from "../../hooks/usePagination.js";
7
6
  import { useColumns } from "../../hooks/useColumns.js";
8
7
  import { useSelectionTools } from "../../hooks/useSelectionTools.js";
8
+ import { TableContainer } from "../../styles.js";
9
9
  const DataTable = observer((props)=>{
10
- const { title, extra, columns, rowTitleKey, rowSelectionType, tableProps } = props;
10
+ const { title, extra, columns = [], rowTitleKey, rowSelectionType, tableProps } = props;
11
11
  const store = useListPageStore();
12
12
  const paginationEle = usePagination(tableProps?.pagination);
13
13
  const newColumns = useColumns(columns);
@@ -0,0 +1,7 @@
1
+ export declare const renders: {
2
+ link: import("../types").ColumnRender<"link">;
3
+ text: import("../types").ColumnRender<"text">;
4
+ tag: import("../types").ColumnRender<"tag">;
5
+ switch: import("../types").ColumnRender<"switch">;
6
+ time: import("../types").ColumnRender<"time">;
7
+ };
@@ -0,0 +1,13 @@
1
+ import { linkRender } from "./link.js";
2
+ import { switchRender } from "./switch.js";
3
+ import { tagRender } from "./tag.js";
4
+ import { textRender } from "./text.js";
5
+ import { timeRender } from "./time.js";
6
+ const renders = {
7
+ link: linkRender,
8
+ text: textRender,
9
+ tag: tagRender,
10
+ switch: switchRender,
11
+ time: timeRender
12
+ };
13
+ export { renders };
@@ -0,0 +1,2 @@
1
+ import { ColumnRender } from '../types';
2
+ export declare const linkRender: ColumnRender<'link'>;
@@ -0,0 +1,27 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { styled } from "styled-components";
3
+ const LinkStyle = styled.a`
4
+ color: #1677ff;
5
+ &:hover {
6
+ color: #69b1ff;
7
+ }
8
+ outline: 0;
9
+ text-decoration: none;
10
+ transition: color 0.3s;
11
+ background-color: transparent;
12
+ cursor: pointer;
13
+ `;
14
+ const getPropName = (propName, record)=>{
15
+ if ('function' == typeof propName) return propName(record);
16
+ return record[propName];
17
+ };
18
+ const linkRender = (value, record, index, props)=>{
19
+ const title = getPropName(props?.titlePropName || 'title', record);
20
+ const href = getPropName(props?.hrefPropName || 'href', record);
21
+ return /*#__PURE__*/ jsx(LinkStyle, {
22
+ href: href,
23
+ target: props?.target,
24
+ children: title
25
+ });
26
+ };
27
+ export { linkRender };
@@ -0,0 +1,2 @@
1
+ import { ColumnRender } from '../types';
2
+ export declare const switchRender: ColumnRender<'switch'>;
@@ -0,0 +1,10 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { AsyncSwitch } from "../../../../../components/AsyncSwitch/index.js";
3
+ const switchRender = (value, record, index, props)=>/*#__PURE__*/ jsx(AsyncSwitch, {
4
+ defaultValue: value,
5
+ ...props,
6
+ syncChange: async (checked)=>{
7
+ await props?.syncChange?.(checked, record);
8
+ }
9
+ });
10
+ export { switchRender };
@@ -0,0 +1,2 @@
1
+ import { ColumnRender } from '../types';
2
+ export declare const tagRender: ColumnRender<'tag'>;
@@ -0,0 +1,7 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Tag } from "antd";
3
+ const tagRender = (value, record, index, props)=>/*#__PURE__*/ jsx(Tag, {
4
+ ...props,
5
+ children: value
6
+ });
7
+ export { tagRender };
@@ -0,0 +1,2 @@
1
+ import { ColumnRender } from '../types';
2
+ export declare const textRender: ColumnRender<'text'>;
@@ -0,0 +1,10 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Typography } from "antd";
3
+ const textRender = (value, record, index, props)=>/*#__PURE__*/ jsx(Typography.Text, {
4
+ ellipsis: {
5
+ tooltip: true
6
+ },
7
+ ...props,
8
+ children: value
9
+ });
10
+ export { textRender };
@@ -0,0 +1,2 @@
1
+ import { ColumnRender } from '../types';
2
+ export declare const timeRender: ColumnRender<'time'>;
@@ -0,0 +1,15 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import dayjs from "dayjs";
3
+ const timeRender = (value, record, index, props)=>{
4
+ try {
5
+ const time = value ? dayjs(value).format(props?.format) : '-';
6
+ return /*#__PURE__*/ jsx("span", {
7
+ children: time
8
+ });
9
+ } catch {
10
+ return /*#__PURE__*/ jsx("span", {
11
+ children: "-"
12
+ });
13
+ }
14
+ };
15
+ export { timeRender };
@@ -0,0 +1,34 @@
1
+ import { TableProps, TagProps, TypographyProps } from 'antd';
2
+ import { ColumnType } from 'antd/es/table';
3
+ import { HTMLAttributeAnchorTarget, ReactNode } from 'react';
4
+ import { ListPageStore } from '../../context';
5
+ export type ComponentType = 'text' | 'time' | 'tag' | 'link' | 'switch';
6
+ export type ComponentProps<RecordValue extends Record<string, any> = any> = {
7
+ text: TypographyProps['Text'];
8
+ time: {
9
+ format?: string;
10
+ };
11
+ tag: TagProps;
12
+ link: {
13
+ titlePropName?: string | ((record: RecordValue) => string);
14
+ hrefPropName?: string | ((record: RecordValue) => string);
15
+ target?: HTMLAttributeAnchorTarget;
16
+ };
17
+ switch: {
18
+ syncChange?: (value: boolean, record: RecordValue) => Promise<void>;
19
+ };
20
+ };
21
+ export type CustomColumnRender<RecordValue extends Record<string, any> = any, Context = any> = (value: RecordValue[keyof RecordValue], record: RecordValue, index: number, ctx: Context) => ReactNode;
22
+ export interface ListPageTableColumn<FilterValue = any, RecordValue extends Record<string, any> = any> extends ColumnType<RecordValue> {
23
+ component?: ComponentType | CustomColumnRender<RecordValue, ListPageStore<FilterValue, RecordValue>>;
24
+ props?: this['component'] extends ComponentType ? ComponentProps<RecordValue>[this['component']] : unknown;
25
+ }
26
+ export interface DataTableProps<FilterValue = any, RecordValue extends Record<string, any> = any> {
27
+ title?: ReactNode;
28
+ extra?: React.ReactNode | ((ctx: ListPageStore<FilterValue, RecordValue>) => React.ReactNode);
29
+ rowSelectionType?: 'checkbox' | 'radio';
30
+ rowTitleKey?: string;
31
+ columns?: ListPageTableColumn<FilterValue, RecordValue>[];
32
+ tableProps?: Omit<TableProps<RecordValue>, 'dataSource' | 'title' | 'columns'>;
33
+ }
34
+ export type ColumnRender<Type extends ComponentType, R extends Record<string, any> = any, K extends string = any> = (value: R[K], record: R, index: number, props: ComponentProps<R>[Type]) => ReactNode;
@@ -0,0 +1,2 @@
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;
@@ -0,0 +1,25 @@
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 };
@@ -0,0 +1,17 @@
1
+ import { ListPageFilterProps, ListPageFloatProps, ListPageHeaderProps, ListPageRequest, ListPageToolbarProps, StateValue } from '../../types';
2
+ import { DataTableProps } from '../DataTable/types';
3
+ export interface ListPageProps<FilterValue = any, RecordValue extends Record<string, any> = any> {
4
+ styles?: {
5
+ page?: React.CSSProperties;
6
+ };
7
+ request: ListPageRequest<FilterValue, RecordValue>;
8
+ storageKey?: string;
9
+ initialValues?: StateValue<FilterValue>;
10
+ state?: StateValue<FilterValue>;
11
+ header?: ListPageHeaderProps;
12
+ floats?: ListPageFloatProps[];
13
+ filter?: ListPageFilterProps<FilterValue>;
14
+ toolbar?: ListPageToolbarProps<FilterValue, RecordValue>;
15
+ table: DataTableProps<FilterValue, RecordValue>;
16
+ }
17
+ export declare const ListPage: (props: ListPageProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,31 +1,17 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { useImperativeHandle } from "react";
3
2
  import { observer } from "mobx-react-lite";
4
- import { useMount, useUpdateEffect } from "ahooks";
5
- import { toJS } from "mobx";
6
- import { ListPageProvider, useListPageStore } from "../../context/listpage.js";
7
- import { FilterSection, ListPageContainer, ToolbarSection } from "./styles.js";
8
- import { FilterForm } from "../../../FilterGroup/index.js";
3
+ import { FilterForm } from "../../../../components/FilterGroup/index.js";
4
+ import { ListPageProvider, useListPageStore } from "../../context/index.js";
9
5
  import { useFloat } from "../../hooks/useFloat.js";
10
- import { DataTable } from "./DataTable.js";
11
6
  import { useHeader } from "../../hooks/useHeader.js";
12
- const PureListPage = observer((props)=>{
13
- const { header, filter, toolbar, table, styles, pageRef } = props;
7
+ import { FilterSection, ListPageWrapper, ToolbarSection } from "../../styles.js";
8
+ import { DataTable } from "../DataTable/index.js";
9
+ const ListPageContainerComponent = observer((props)=>{
10
+ const { styles, header, filter, toolbar, table } = props;
14
11
  const store = useListPageStore();
15
- const floatEle = useFloat();
16
12
  const headerEle = useHeader(header);
17
- useMount(()=>{
18
- store.refreshTable();
19
- });
20
- useUpdateEffect(()=>{
21
- filter?.onChange?.(toJS(store.filters));
22
- }, [
23
- store.filters
24
- ]);
25
- useImperativeHandle(pageRef, ()=>store, [
26
- store
27
- ]);
28
- return /*#__PURE__*/ jsxs(ListPageContainer, {
13
+ const floatEle = useFloat();
14
+ return /*#__PURE__*/ jsxs(ListPageWrapper, {
29
15
  style: styles?.page,
30
16
  children: [
31
17
  headerEle,
@@ -54,8 +40,8 @@ const ListPage = (props)=>/*#__PURE__*/ jsx(ListPageProvider, {
54
40
  floats: props.floats,
55
41
  initialValues: props.initialValues,
56
42
  state: props.state,
57
- children: /*#__PURE__*/ jsx(PureListPage, {
43
+ children: /*#__PURE__*/ jsx(ListPageContainerComponent, {
58
44
  ...props
59
45
  })
60
46
  });
61
- export { ListPage, PureListPage };
47
+ export { ListPage };
@@ -0,0 +1,4 @@
1
+ import { ListPageStore } from './store';
2
+ import { ListPageProviderProps } from './types';
3
+ export declare const ListPageProvider: (props: ListPageProviderProps) => import("react/jsx-runtime").JSX.Element;
4
+ export declare function useListPageStore<FilterValue = any, RecordValue extends Record<string, any> = any>(): ListPageStore<FilterValue, RecordValue>;
@@ -0,0 +1,22 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { createContext, useContext, useMemo } from "react";
3
+ import { ListPageStore } from "./store.js";
4
+ const ListPageContext = /*#__PURE__*/ createContext({});
5
+ const ListPageProvider = (props)=>{
6
+ const { state, request, children, initialValues, storageKey, floats } = props;
7
+ const store = useMemo(()=>new ListPageStore({
8
+ state,
9
+ initialValues,
10
+ request,
11
+ floats,
12
+ storageKey
13
+ }), []);
14
+ return /*#__PURE__*/ jsx(ListPageContext.Provider, {
15
+ value: store,
16
+ children: children
17
+ });
18
+ };
19
+ function useListPageStore() {
20
+ return useContext(ListPageContext);
21
+ }
22
+ export { ListPageProvider, useListPageStore };
@@ -0,0 +1,2 @@
1
+ export { ListPageProvider, useListPageStore } from './context';
2
+ export { ListPageStore } from './store';
@@ -0,0 +1,3 @@
1
+ import { ListPageProvider, useListPageStore } from "./context.js";
2
+ import { ListPageStore } from "./store.js";
3
+ export { ListPageProvider, ListPageStore, useListPageStore };