diff --git a/src/components/Avatar/index.tsx b/src/components/Avatar/index.tsx index baea8120..26bf5469 100644 --- a/src/components/Avatar/index.tsx +++ b/src/components/Avatar/index.tsx @@ -12,9 +12,10 @@ export interface AvatarProps { url?: string; size?: AvatarSize; shape?: AvatarShape; + children?: React.ReactNode; } -export const Avatar: React.FC = (props) => { +export const Avatar = (props: AvatarProps) => { const { className, src, alt, url, size = 'md', shape = 'circle', children } = props; const Element = url ? 'a' : 'span'; diff --git a/src/components/Button/index.tsx b/src/components/Button/index.tsx index fdd94e7b..2052fb8a 100644 --- a/src/components/Button/index.tsx +++ b/src/components/Button/index.tsx @@ -12,6 +12,7 @@ export interface ButtonProps extends React.ButtonHTMLAttributes) => void; } @@ -19,7 +20,7 @@ function composeClass(type?: string) { return type && `Btn--${type}`; } -export const Button = (props: ButtonProps) => { +export const Button = React.forwardRef((props, ref) => { const { className, label, @@ -59,6 +60,7 @@ export const Button = (props: ButtonProps) => { type="button" disabled={disabled} onClick={handleClick} + ref={ref} {...other} > {icon && ( @@ -69,4 +71,4 @@ export const Button = (props: ButtonProps) => { {label || children} ); -}; +}); diff --git a/src/components/Button/style.less b/src/components/Button/style.less index 6990bb49..7c44c38f 100644 --- a/src/components/Button/style.less +++ b/src/components/Button/style.less @@ -74,6 +74,10 @@ } } +[data-old-ios] .Btn:not(.Btn--block) { + display: inline-block; +} + @media (hover: hover) { .Btn { &:hover { diff --git a/src/components/Card/CardActions.tsx b/src/components/Card/CardActions.tsx index 32c2a489..1af68c82 100644 --- a/src/components/Card/CardActions.tsx +++ b/src/components/Card/CardActions.tsx @@ -1,12 +1,13 @@ import React from 'react'; import clsx from 'clsx'; -export type CardActionsProps = { +export interface CardActionsProps { className?: string; direction?: 'column' | 'row'; -}; + children?: React.ReactNode; +} -export const CardActions: React.FC = (props) => { +export const CardActions = (props: CardActionsProps) => { const { children, className, direction, ...other } = props; return (
= (props) => { +export const CardContent = (props: CardContentProps) => { const { className, children, ...other } = props; return (
diff --git a/src/components/Card/CardMedia.tsx b/src/components/Card/CardMedia.tsx index 9b8a82cb..70e8d7b1 100644 --- a/src/components/Card/CardMedia.tsx +++ b/src/components/Card/CardMedia.tsx @@ -2,14 +2,15 @@ import React from 'react'; import clsx from 'clsx'; import { Flex } from '../Flex'; -export type CardMediaProps = { +export interface CardMediaProps { className?: string; aspectRatio?: 'square' | 'wide'; color?: string; image?: string; -}; + children?: React.ReactNode; +} -export const CardMedia: React.FC = (props) => { +export const CardMedia = (props: CardMediaProps) => { const { className, aspectRatio = 'square', color, image, children, ...other } = props; const bgStyle = { diff --git a/src/components/Card/CardText.tsx b/src/components/Card/CardText.tsx index 82de89ca..5c95b581 100644 --- a/src/components/Card/CardText.tsx +++ b/src/components/Card/CardText.tsx @@ -1,11 +1,12 @@ import React from 'react'; import clsx from 'clsx'; -export type CardTextProps = { +export interface CardTextProps { className?: string; -}; + children?: React.ReactNode; +} -export const CardText: React.FC = (props) => { +export const CardText = (props: CardTextProps) => { const { className, children, ...other } = props; return (
diff --git a/src/components/Card/CardTitle.tsx b/src/components/Card/CardTitle.tsx index 815c31db..49e5b28c 100644 --- a/src/components/Card/CardTitle.tsx +++ b/src/components/Card/CardTitle.tsx @@ -1,14 +1,15 @@ import React from 'react'; import clsx from 'clsx'; -export type CardTitleProps = { +export interface CardTitleProps { className?: string; title?: React.ReactNode; subtitle?: React.ReactNode; center?: boolean; -}; + children?: React.ReactNode; +} -export const CardTitle: React.FC = (props) => { +export const CardTitle = (props: CardTitleProps) => { const { className, title, subtitle, center, children, ...other } = props; return (
diff --git a/src/components/Carousel/Item.tsx b/src/components/Carousel/Item.tsx index d81a7f69..e3155282 100644 --- a/src/components/Carousel/Item.tsx +++ b/src/components/Carousel/Item.tsx @@ -2,9 +2,10 @@ import React from 'react'; interface CarouselItemProps { width: string; + children?: React.ReactNode; } -export const CarouselItem: React.FC = (props) => { +export const CarouselItem = (props: CarouselItemProps) => { const { width, children } = props; return ( diff --git a/src/components/Chat/index.tsx b/src/components/Chat/index.tsx index 8513b566..5e174e04 100644 --- a/src/components/Chat/index.tsx +++ b/src/components/Chat/index.tsx @@ -8,7 +8,7 @@ import { } from '../MessageContainer'; import { QuickReplies, QuickReplyItemProps } from '../QuickReplies'; import { Composer as DComposer, ComposerProps, ComposerHandle } from '../Composer'; -import isSafari from '../../utils/isSafari'; +import { isSafari, getIOSMajorVersion } from '../../utils/ua'; export type ChatProps = Omit & MessageContainerProps & { @@ -164,6 +164,7 @@ export const Chat = React.forwardRef((props, ref) => onQuickReplyScroll, renderQuickReplies, text, + textOnce, placeholder, onInputFocus, onInputChange, @@ -192,8 +193,15 @@ export const Chat = React.forwardRef((props, ref) => } useEffect(() => { + const rootEl = document.documentElement; if (isSafari()) { - document.documentElement.dataset.safari = ''; + rootEl.dataset.safari = ''; + } + + const v = getIOSMajorVersion(); + // iOS 9、10 不支持按钮使用 flex + if (v && v < 11) { + rootEl.dataset.oldIos = ''; } }, []); @@ -228,6 +236,7 @@ export const Chat = React.forwardRef((props, ref) => ref={composerRef} inputType={inputType} text={text} + textOnce={textOnce} inputOptions={inputOptions} placeholder={placeholder} onAccessoryToggle={onAccessoryToggle} diff --git a/src/components/Chat/style.less b/src/components/Chat/style.less index 99c8bac5..ce3cf32a 100644 --- a/src/components/Chat/style.less +++ b/src/components/Chat/style.less @@ -6,11 +6,14 @@ height: calc(100vh - calc(100vh - 100%)); } } + body, #root { height: 100%; } + body { + overflow: hidden; margin: 0; } } diff --git a/src/components/Checkbox/Checkbox.tsx b/src/components/Checkbox/Checkbox.tsx index 9447b117..eeac225f 100644 --- a/src/components/Checkbox/Checkbox.tsx +++ b/src/components/Checkbox/Checkbox.tsx @@ -8,7 +8,7 @@ export type CheckboxProps = React.InputHTMLAttributes & { label?: CheckboxValue; }; -export const Checkbox: React.FC = (props) => { +export const Checkbox = (props: CheckboxProps) => { const { className, label, checked, disabled, onChange, ...other } = props; return (