Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion components/sender/demo/_semantic.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SmileOutlined } from '@ant-design/icons';
import { SmileOutlined, SunOutlined } from '@ant-design/icons';
import { Sender } from '@ant-design/x';
import { Button, Divider, Flex, Typography } from 'antd';
import React from 'react';
Expand All @@ -8,12 +8,14 @@ import useLocale from '../../../.dumi/hooks/useLocale';
const locales = {
cn: {
prefix: '前缀',
suffix: '后缀',
input: '输入框',
actions: '操作列表',
footer: '底部',
},
en: {
prefix: 'Prefix',
suffix: 'Suffix',
input: 'Input',
actions: 'Action List',
footer: 'Footer',
Expand Down Expand Up @@ -42,13 +44,15 @@ const App: React.FC = () => {
componentName="Sender"
semantics={[
{ name: 'prefix', desc: locale.prefix },
{ name: 'suffix', desc: locale.suffix },
{ name: 'input', desc: locale.input },
{ name: 'actions', desc: locale.actions },
{ name: 'footer', desc: locale.footer },
]}
>
<Sender
prefix={<Button type="text" icon={<SmileOutlined />} />}
suffix={<Button type="text" icon={<SunOutlined />} />}
footer={() => (
<Typography.Text type="secondary">
Deep thinking can understand the intent behind.
Expand Down
18 changes: 18 additions & 0 deletions components/sender/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,15 @@
components?: SenderComponents;
styles?: {
prefix?: React.CSSProperties;
suffix?: React.CSSProperties;
input?: React.CSSProperties;
actions?: React.CSSProperties;
footer?: React.CSSProperties;
};
rootClassName?: string;
classNames?: {
prefix?: string;
suffix?: string;
input?: string;
actions?: string;
footer?: string;
Expand All @@ -76,6 +78,7 @@
actions?: React.ReactNode | ActionsRender;
allowSpeech?: AllowSpeech;
prefix?: React.ReactNode;
suffix?: React.ReactNode;
footer?: React.ReactNode | FooterRender;
header?: React.ReactNode;
autoSize?: boolean | { minRows?: number; maxRows?: number };
Expand Down Expand Up @@ -124,6 +127,7 @@
disabled,
allowSpeech,
prefix,
suffix,
footer,
header,
onPaste,
Expand Down Expand Up @@ -351,6 +355,20 @@
variant="borderless"
readOnly={readOnly}
/>

{/* Suffix */}
{suffix && (
<div

Check warning on line 361 in components/sender/index.tsx

View check run for this annotation

Codecov / codecov/patch

components/sender/index.tsx#L361

Added line #L361 was not covered by tests
className={classnames(
`${prefixCls}-suffix`,
contextConfig.classNames.suffix,
classNames.suffix,
)}
style={{ ...contextConfig.styles.suffix, ...styles.suffix }}
>
{suffix}
</div>
)}
{/* Action List */}
{actionNode && (
<div
Expand Down
1 change: 1 addition & 0 deletions components/sender/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ coverDark: https://mdn.alipayobjects.com/huamei_iwk9zp/afts/img/A*cOfrS4fVkOMAAA
| loading | 是否加载中 | boolean | false | - |
| header | 头部面板 | ReactNode | - | - |
| prefix | 前缀内容 | ReactNode | - | - |
| suffix | 后缀内容 | ReactNode | - | - |
| footer | 底部内容 | ReactNode \| (info: { components: ActionsComponents }) => ReactNode | - | - |
| readOnly | 是否让输入框只读 | boolean | false | - |
| rootClassName | 根元素样式类 | string | - | - |
Expand Down
5 changes: 5 additions & 0 deletions components/sender/style/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ const genSenderStyle: GenerateStyle<SenderToken> = (token) => {
flex: 'none',
},

// ============================ Suffix =============================
[`${componentCls}-suffix`]: {
flex: 'none',
},

// ============================= Input =============================
[`${componentCls}-input`]: {
padding: 0,
Expand Down