@agentscope-ai/chat 1.1.45 → 1.1.46-beta.1767150237996

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,42 @@
1
+ import { useProviderContext } from '@agentscope-ai/chat'
2
+ import Style from './style';
3
+ import { useMemo } from 'react';
4
+
5
+
6
+ interface IBeforeUIContainerProps {
7
+ leftChildren?: React.ReactNode;
8
+ rightChildren?: React.ReactNode;
9
+ children?: React.ReactNode;
10
+ }
11
+
12
+
13
+
14
+ export default function BeforeUIContainer({ leftChildren, rightChildren, children }: IBeforeUIContainerProps) {
15
+ const prefixCls = useProviderContext().getPrefixCls('sender-before-ui-container');
16
+
17
+ const left = useMemo(() => {
18
+ if (leftChildren) return <div className={`${prefixCls}-left`}>{leftChildren}</div>;
19
+ return null;
20
+ }, [leftChildren]);
21
+
22
+ const right = useMemo(() => {
23
+ if (rightChildren) return <div className={`${prefixCls}-right`}>{rightChildren}</div>;
24
+ return null;
25
+ }, [rightChildren]);
26
+
27
+ return (
28
+ <>
29
+ <Style />
30
+ <div className={prefixCls}>
31
+ <div className={`${prefixCls}-content`}>
32
+ <div className={`${prefixCls}-content-children`}>
33
+ {children || <>
34
+ {left}
35
+ {right}
36
+ </>}
37
+ </div>
38
+ </div>
39
+ </div>
40
+ </>
41
+ );
42
+ }
@@ -0,0 +1,29 @@
1
+ import { createGlobalStyle } from 'antd-style';
2
+
3
+
4
+ export default createGlobalStyle`
5
+ .${p => p.theme.prefixCls}-sender-before-ui-container {
6
+ position: relative;
7
+ height: 40px;
8
+
9
+ &-content {
10
+ position: absolute;
11
+ top: 8px;
12
+ left: 0;
13
+ right: 0;
14
+ height: 40px;
15
+ border: 1px solid ${p => p.theme.colorBorderSecondary};
16
+ border-radius: ${p => p.theme.borderRadiusLG}px ${p => p.theme.borderRadiusLG}px 0 0;
17
+ background: ${p => p.theme.colorFillTertiary};
18
+ transition: all 0.3s;
19
+
20
+ &-children {
21
+ display: flex;
22
+ justify-content: space-between;
23
+ align-items: center;
24
+ height: 32px;
25
+ padding: 0 12px;
26
+ }
27
+ }
28
+ }
29
+ `
@@ -0,0 +1,8 @@
1
+ import { ChatInput } from "@agentscope-ai/chat";
2
+
3
+ export default function () {
4
+ return <div style={{ width: '100%' }}>
5
+ <ChatInput.BeforeUIContainer leftChildren={<div>Left</div>} rightChildren={<div>Right</div>} />
6
+ <ChatInput placeholder='Please type here...' ></ChatInput>
7
+ </div>
8
+ }
@@ -21,6 +21,7 @@ The following are examples and variations of this component
21
21
  <code src="./demo/withImage.tsx" center height="350">Upload Image</code>
22
22
  <code src="./demo/withFile.tsx" center height="350">Upload File</code>
23
23
  <code src="./demo/moreMode.tsx" center height="350">Custom Mode</code>
24
+ <code src="./demo/beforeUI.tsx" center height="350">Before UI</code>
24
25
  <code src="./demo/morePrefixAction.tsx" center height="350">Custom Functionality</code>
25
26
  <code src="./demo/asr.tsx" center height="350">Voice Input</code>
26
27
 
@@ -4,7 +4,7 @@ import { useMergedState } from 'rc-util';
4
4
  import pickAttrs from 'rc-util/lib/pickAttrs';
5
5
  import getValue from 'rc-util/lib/utils/get';
6
6
  import React, { useState } from 'react';
7
- import { useFocusWithin, useClickAway, useEventListener } from 'ahooks';
7
+ import { useFocusWithin, useEventListener } from 'ahooks';
8
8
  import useProxyImperativeHandle from '../Util/hooks/use-proxy-imperative-handle';
9
9
  import { useProviderContext } from '@agentscope-ai/chat';
10
10
  import SenderHeader, { SendHeaderContext } from './SenderHeader';
@@ -19,6 +19,7 @@ import ModeSelect from './ModeSelect';
19
19
  import type { InputRef as AntdInputRef, ButtonProps, GetProps } from 'antd';
20
20
  import { SparkEnlargeLine, SparkShrinkLine } from '@agentscope-ai/icons';
21
21
  import { IconButton } from '@agentscope-ai/design';
22
+ import BeforeUIContainer from './BeforeUIContainer';
22
23
 
23
24
 
24
25
  export type SubmitType = 'enter' | 'shiftEnter' | false;
@@ -399,7 +400,7 @@ const ForwardSender = React.forwardRef<SenderRef, SenderProps>((props, ref) => {
399
400
  .filter(item => item.kind === 'file')
400
401
  .map(item => item.getAsFile())
401
402
  .filter((file): file is File => file !== null);
402
- }
403
+ }
403
404
  if (files.length > 0) {
404
405
  files.forEach(file => onPasteFile(file));
405
406
  e.preventDefault();
@@ -547,10 +548,12 @@ const ForwardSender = React.forwardRef<SenderRef, SenderProps>((props, ref) => {
547
548
  type CompoundedSender = typeof ForwardSender & {
548
549
  Header: typeof SenderHeader;
549
550
  ModeSelect: typeof ModeSelect;
551
+ BeforeUIContainer: typeof BeforeUIContainer;
550
552
  };
551
553
 
552
554
  const Sender = ForwardSender as CompoundedSender;
553
555
  Sender.Header = SenderHeader;
554
556
  Sender.ModeSelect = ModeSelect;
557
+ Sender.BeforeUIContainer = BeforeUIContainer;
555
558
 
556
559
  export default Sender;
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ interface IBeforeUIContainerProps {
3
+ leftChildren?: React.ReactNode;
4
+ rightChildren?: React.ReactNode;
5
+ children?: React.ReactNode;
6
+ }
7
+ export default function BeforeUIContainer({ leftChildren, rightChildren, children }: IBeforeUIContainerProps): import("react/jsx-runtime").JSX.Element;
8
+ export {};
@@ -0,0 +1,40 @@
1
+ import { useProviderContext } from "../..";
2
+ import Style from "./style";
3
+ import { useMemo } from 'react';
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ import { Fragment as _Fragment } from "react/jsx-runtime";
6
+ import { jsxs as _jsxs } from "react/jsx-runtime";
7
+ export default function BeforeUIContainer(_ref) {
8
+ var leftChildren = _ref.leftChildren,
9
+ rightChildren = _ref.rightChildren,
10
+ children = _ref.children;
11
+ var prefixCls = useProviderContext().getPrefixCls('sender-before-ui-container');
12
+ var left = useMemo(function () {
13
+ if (leftChildren) return /*#__PURE__*/_jsx("div", {
14
+ className: "".concat(prefixCls, "-left"),
15
+ children: leftChildren
16
+ });
17
+ return null;
18
+ }, [leftChildren]);
19
+ var right = useMemo(function () {
20
+ if (rightChildren) return /*#__PURE__*/_jsx("div", {
21
+ className: "".concat(prefixCls, "-right"),
22
+ children: rightChildren
23
+ });
24
+ return null;
25
+ }, [rightChildren]);
26
+ return /*#__PURE__*/_jsxs(_Fragment, {
27
+ children: [/*#__PURE__*/_jsx(Style, {}), /*#__PURE__*/_jsx("div", {
28
+ className: prefixCls,
29
+ children: /*#__PURE__*/_jsx("div", {
30
+ className: "".concat(prefixCls, "-content"),
31
+ children: /*#__PURE__*/_jsx("div", {
32
+ className: "".concat(prefixCls, "-content-children"),
33
+ children: children || /*#__PURE__*/_jsxs(_Fragment, {
34
+ children: [left, right]
35
+ })
36
+ })
37
+ })
38
+ })]
39
+ });
40
+ }
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ declare const _default: import("react").NamedExoticComponent<object>;
3
+ export default _default;
@@ -0,0 +1,14 @@
1
+ var _templateObject;
2
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
3
+ import { createGlobalStyle } from 'antd-style';
4
+ export default createGlobalStyle(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n.", "-sender-before-ui-container {\n position: relative;\n height: 40px;\n\n &-content {\n position: absolute;\n top: 8px;\n left: 0;\n right: 0;\n height: 40px;\n border: 1px solid ", ";\n border-radius: ", "px ", "px 0 0;\n background: ", ";\n transition: all 0.3s;\n\n &-children {\n display: flex;\n justify-content: space-between; \n align-items: center;\n height: 32px;\n padding: 0 12px;\n }\n }\n}\n"])), function (p) {
5
+ return p.theme.prefixCls;
6
+ }, function (p) {
7
+ return p.theme.colorBorderSecondary;
8
+ }, function (p) {
9
+ return p.theme.borderRadiusLG;
10
+ }, function (p) {
11
+ return p.theme.borderRadiusLG;
12
+ }, function (p) {
13
+ return p.theme.colorFillTertiary;
14
+ });
@@ -3,6 +3,7 @@ import React from 'react';
3
3
  import SenderHeader from './SenderHeader';
4
4
  import ModeSelect from './ModeSelect';
5
5
  import type { InputRef as AntdInputRef, ButtonProps, GetProps } from 'antd';
6
+ import BeforeUIContainer from './BeforeUIContainer';
6
7
  export type SubmitType = 'enter' | 'shiftEnter' | false;
7
8
  type TextareaProps = GetProps<typeof Input.TextArea>;
8
9
  export interface SenderComponents {
@@ -167,6 +168,7 @@ declare const ForwardSender: React.ForwardRefExoticComponent<SenderProps & React
167
168
  type CompoundedSender = typeof ForwardSender & {
168
169
  Header: typeof SenderHeader;
169
170
  ModeSelect: typeof ModeSelect;
171
+ BeforeUIContainer: typeof BeforeUIContainer;
170
172
  };
171
173
  declare const Sender: CompoundedSender;
172
174
  export default Sender;
@@ -37,6 +37,7 @@ import useSpeech from "./useSpeech";
37
37
  import ModeSelect from "./ModeSelect";
38
38
  import { SparkEnlargeLine, SparkShrinkLine } from '@agentscope-ai/icons';
39
39
  import { IconButton } from '@agentscope-ai/design';
40
+ import BeforeUIContainer from "./BeforeUIContainer";
40
41
  import { jsx as _jsx } from "react/jsx-runtime";
41
42
  import { jsxs as _jsxs } from "react/jsx-runtime";
42
43
  import { Fragment as _Fragment } from "react/jsx-runtime";
@@ -348,4 +349,5 @@ var ForwardSender = /*#__PURE__*/React.forwardRef(function (props, ref) {
348
349
  var Sender = ForwardSender;
349
350
  Sender.Header = SenderHeader;
350
351
  Sender.ModeSelect = ModeSelect;
352
+ Sender.BeforeUIContainer = BeforeUIContainer;
351
353
  export default Sender;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentscope-ai/chat",
3
- "version": "1.1.45",
3
+ "version": "1.1.46-beta.1767150237996",
4
4
  "description": "a free and open-source chat framework for building excellent LLM-powered chat experiences",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": [