listpage-next 0.0.82 → 0.0.83

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.
@@ -0,0 +1 @@
1
+ export declare const PageLoading: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
@@ -0,0 +1,56 @@
1
+ import styled_components from "styled-components";
2
+ const PageLoading = styled_components.div`
3
+ align-items: center;
4
+ bottom: 0;
5
+ display: flex;
6
+ height: 100%;
7
+ justify-content: center;
8
+ left: 0;
9
+ position: fixed;
10
+ right: 0;
11
+ top: 0;
12
+ width: 100%;
13
+ overflow: hidden;
14
+
15
+ &::after {
16
+ animation: LoadingAnimation 1.5s linear infinite;
17
+ border-radius: 5px;
18
+ content: "";
19
+ height: 10px;
20
+ left: 50%;
21
+ position: absolute;
22
+ top: calc(50% - 20px);
23
+ transform: translateX(-50%) translateY(-50%);
24
+ width: 10px;
25
+
26
+ box-sizing: border-box;
27
+ }
28
+
29
+ @keyframes LoadingAnimation {
30
+ 0% {
31
+ box-shadow: -16px 20px 0 -5px #b89dfe, 0 20px 0 0 #2e6ee7,
32
+ 16px 20px 0 2px #b89dfe;
33
+ }
34
+
35
+ 25% {
36
+ box-shadow: -16px 20px 0 0 #b89dfe, 0 20px 0 2px #2e6ee7,
37
+ 16px 20px 0 0 #b89dfe;
38
+ }
39
+
40
+ 50% {
41
+ box-shadow: -16px 20px 0 2px #b89dfe, 0 20px 0 0 #2e6ee7,
42
+ 16px 20px 0 -5px #b89dfe;
43
+ }
44
+
45
+ 75% {
46
+ box-shadow: -16px 20px 0 0 #b89dfe, 0 20px 0 -5px #2e6ee7,
47
+ 16px 20px 0 0 #b89dfe;
48
+ }
49
+
50
+ to {
51
+ box-shadow: -16px 20px 0 -5px #b89dfe, 0 20px 0 0 #2e6ee7,
52
+ 16px 20px 0 2px #b89dfe;
53
+ }
54
+ }
55
+ `;
56
+ export { PageLoading };
@@ -1,3 +1,4 @@
1
1
  export { PageContainer } from './components/PageContainer';
2
2
  export { ListPage, type ListPageProps } from './components/ListPage';
3
+ export { PageLoading } from './components/Loading';
3
4
  export { usePageContext } from './context/page';
@@ -1,4 +1,5 @@
1
1
  import { PageContainer } from "./components/PageContainer/index.js";
2
2
  import { ListPage } from "./components/ListPage/index.js";
3
+ import { PageLoading } from "./components/Loading/index.js";
3
4
  import { usePageContext } from "./context/page.js";
4
- export { ListPage, PageContainer, usePageContext };
5
+ export { ListPage, PageContainer, PageLoading, usePageContext };
@@ -1,6 +1,7 @@
1
1
  export interface ChatSenderProps {
2
2
  extra?: React.ReactNode;
3
3
  placeholder?: string;
4
+ submitting?: boolean;
4
5
  onSubmit?: (value: string) => any;
5
6
  onCancel?: () => Promise<void>;
6
7
  style?: React.CSSProperties;
@@ -4,9 +4,20 @@ import { ChatInputBottom, ChatInputContent, ChatInputPanel } from "./styles.js";
4
4
  import { useState } from "react";
5
5
  import { ArrowUpOutlined, PauseCircleTwoTone } from "@ant-design/icons";
6
6
  const ChatSender = (props)=>{
7
- const { placeholder, onSubmit, onCancel, extra, style, className } = props;
8
- const [loading, setLoading] = useState(false);
7
+ const { placeholder, onSubmit, onCancel, submitting, extra, style, className } = props;
9
8
  const [inputValue, setInputValue] = useState("");
9
+ const handleClick = async ()=>{
10
+ if (submitting && !onCancel) return;
11
+ if (submitting && onCancel) return void await onCancel();
12
+ onSubmit?.(inputValue);
13
+ setInputValue("");
14
+ };
15
+ const handleKeyDown = (e)=>{
16
+ if ('Enter' === e.key && !e.shiftKey) {
17
+ e.preventDefault();
18
+ if (!submitting && inputValue) handleClick();
19
+ }
20
+ };
10
21
  return /*#__PURE__*/ jsxs(ChatInputPanel, {
11
22
  style: style,
12
23
  className: className,
@@ -16,7 +27,8 @@ const ChatSender = (props)=>{
16
27
  placeholder: placeholder,
17
28
  value: inputValue,
18
29
  autoSize: false,
19
- onChange: (e)=>setInputValue?.(e.target.value)
30
+ onChange: (e)=>setInputValue?.(e.target.value),
31
+ onKeyDown: handleKeyDown
20
32
  })
21
33
  }),
22
34
  /*#__PURE__*/ jsxs(ChatInputBottom, {
@@ -28,27 +40,14 @@ const ChatSender = (props)=>{
28
40
  type: "vertical"
29
41
  }),
30
42
  /*#__PURE__*/ jsx(Button, {
31
- disabled: !inputValue && !loading,
32
- loading: loading,
43
+ disabled: !inputValue && !submitting,
44
+ loading: submitting,
33
45
  shape: "circle",
34
- icon: loading ? /*#__PURE__*/ jsx(PauseCircleTwoTone, {}) : /*#__PURE__*/ jsx(ArrowUpOutlined, {}),
46
+ icon: submitting ? /*#__PURE__*/ jsx(PauseCircleTwoTone, {}) : /*#__PURE__*/ jsx(ArrowUpOutlined, {}),
35
47
  type: "primary",
36
48
  variant: "filled",
37
- onClick: async ()=>{
38
- if (loading && !onCancel) return;
39
- if (loading && onCancel) {
40
- await onCancel();
41
- setLoading(false);
42
- return;
43
- }
44
- setLoading(true);
45
- try {
46
- setInputValue("");
47
- await onSubmit?.(inputValue);
48
- } finally{
49
- setLoading(false);
50
- }
51
- }
49
+ onKeyDown: handleKeyDown,
50
+ onClick: handleClick
52
51
  })
53
52
  ]
54
53
  })
@@ -5,7 +5,7 @@ export interface ClientContentProps {
5
5
  style?: React.CSSProperties;
6
6
  children?: React.ReactNode;
7
7
  headerProps?: HeaderProps;
8
- footerProps?: FooterProps;
8
+ footerProps?: Omit<FooterProps, 'submitting'>;
9
9
  loading?: boolean;
10
10
  }
11
11
  export declare const ClientContent: (props: ClientContentProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,15 +1,17 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { Spin } from "antd";
3
2
  import { Footer } from "./Footer.js";
4
3
  import { Header } from "./Header.js";
5
4
  import { Content } from "./Content.js";
6
5
  import { Container } from "./styles.js";
6
+ import { useChatClientContext } from "../../context/index.js";
7
+ import { PageLoading } from "../../../../components/Page/components/Loading/index.js";
7
8
  const ClientContent = (props)=>{
8
9
  const { style, className, children, headerProps, footerProps, loading } = props;
10
+ const { submitting } = useChatClientContext();
9
11
  if (loading) return /*#__PURE__*/ jsx(Container, {
10
12
  style: style,
11
13
  className: className,
12
- children: /*#__PURE__*/ jsx(Spin, {})
14
+ children: /*#__PURE__*/ jsx(PageLoading, {})
13
15
  });
14
16
  return /*#__PURE__*/ jsxs(Container, {
15
17
  style: style,
@@ -22,7 +24,8 @@ const ClientContent = (props)=>{
22
24
  children: children
23
25
  }),
24
26
  /*#__PURE__*/ jsx(Footer, {
25
- ...footerProps
27
+ ...footerProps,
28
+ submitting: submitting
26
29
  })
27
30
  ]
28
31
  });
@@ -1,6 +1,7 @@
1
1
  import { ReactNode } from "react";
2
2
  import { InfiniteListRef, RenderActions } from "../../../components/InfiniteList";
3
3
  export interface ChatClientContextProps<ConversationItemData = any> {
4
+ submitting: boolean;
4
5
  collapsed: boolean;
5
6
  setCollapsed: (collapsed: boolean) => void;
6
7
  showUpdateTitleModal: (title: string, onSubmit?: (title: string) => any) => void;
@@ -9,6 +10,7 @@ export interface ChatClientContextProps<ConversationItemData = any> {
9
10
  }
10
11
  export interface ChatClientProviderProps {
11
12
  children: ReactNode;
13
+ submitting?: boolean;
12
14
  }
13
15
  export declare const ChatClientContext: import("react").Context<ChatClientContextProps<any>>;
14
16
  export declare const ChatClientProvider: (props: ChatClientProviderProps) => import("react/jsx-runtime").JSX.Element;
@@ -4,12 +4,13 @@ import { useUpdateTitleModal } from "./useUpdateTitleModal.js";
4
4
  import { useConversationListRef } from "./useConversationListRef.js";
5
5
  const ChatClientContext = /*#__PURE__*/ createContext({});
6
6
  const ChatClientProvider = (props)=>{
7
- const { children } = props;
7
+ const { children, submitting = false } = props;
8
8
  const { updateTitleModalEle, showUpdateTitleModal } = useUpdateTitleModal();
9
9
  const [collapsed, setCollapsed] = useState(false);
10
10
  const { conversationListRef, ...conversationActions } = useConversationListRef();
11
11
  return /*#__PURE__*/ jsxs(ChatClientContext.Provider, {
12
12
  value: {
13
+ submitting,
13
14
  collapsed,
14
15
  setCollapsed,
15
16
  showUpdateTitleModal,
@@ -3,8 +3,8 @@ import { notification } from "antd";
3
3
  function setupClient(HttpClient) {
4
4
  HttpClient.prototype.createAxiosInstance = function() {
5
5
  const { config } = this.options;
6
- const baseURL = config?.baseURL || this.getBaseURL();
7
- const headers = config?.headers || this.getHeaders();
6
+ const baseURL = this.getBaseURL();
7
+ const headers = this.getHeaders();
8
8
  return axios.create({
9
9
  ...config,
10
10
  baseURL: baseURL,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "listpage-next",
3
- "version": "0.0.82",
3
+ "version": "0.0.83",
4
4
  "description": "A React component library for creating filter forms with Ant Design",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",