From 631ce1eaa0621fb1a4bc768ad620e84d8a863ad8 Mon Sep 17 00:00:00 2001 From: akai Date: Tue, 13 Dec 2022 11:24:07 +0800 Subject: [PATCH] feat: sync 2.4.8 --- src/components/Avatar/index.tsx | 3 +- src/components/Button/index.tsx | 6 ++- src/components/Button/style.less | 4 ++ src/components/Card/CardActions.tsx | 7 +-- src/components/Card/CardContent.tsx | 7 +-- src/components/Card/CardMedia.tsx | 7 +-- src/components/Card/CardText.tsx | 7 +-- src/components/Card/CardTitle.tsx | 7 +-- src/components/Carousel/Item.tsx | 3 +- src/components/Chat/index.tsx | 13 ++++- src/components/Chat/style.less | 3 ++ src/components/Checkbox/Checkbox.tsx | 2 +- src/components/Checkbox/CheckboxGroup.tsx | 2 +- src/components/ClickOutside/index.tsx | 7 +-- src/components/ComponentsProvider/index.tsx | 2 +- .../ComponentsProvider/interface.ts | 1 + src/components/Composer/Action.tsx | 2 +- src/components/Composer/ComposerInput.tsx | 10 ++-- src/components/Composer/ToolbarItem.tsx | 2 +- src/components/Composer/index.tsx | 33 +++++++++--- src/components/Composer/riseInput.ts | 25 ++++------ src/components/Divider/index.tsx | 7 +-- src/components/Empty/index.tsx | 7 +-- src/components/FileCard/index.tsx | 3 +- src/components/Flex/FlexItem.tsx | 2 +- src/components/Form/Form.tsx | 6 +-- src/components/Form/FormActions.tsx | 4 +- src/components/Form/FormItem.tsx | 7 +-- src/components/HelpText/index.tsx | 4 +- src/components/Icon/index.tsx | 15 ++++-- src/components/IconButton/index.tsx | 6 +-- src/components/Image/index.tsx | 6 ++- src/components/Label/index.tsx | 4 +- src/components/LazyComponent/SuspenseWrap.tsx | 2 +- src/components/LazyComponent/index.tsx | 4 +- src/components/List/List.tsx | 7 +-- src/components/List/ListItem.tsx | 3 +- src/components/Loading/index.tsx | 7 +-- src/components/LocaleProvider/index.tsx | 3 +- src/components/MediaObject/index.tsx | 2 +- src/components/Message/SystemMessage.tsx | 6 +-- src/components/Modal/Base.tsx | 29 +++++++---- src/components/Modal/Confirm.tsx | 50 +++++++++++++++---- src/components/Modal/Modal.tsx | 7 +-- src/components/Modal/Popup.tsx | 8 +-- src/components/Modal/style.less | 9 ++-- src/components/Navbar/index.tsx | 6 +-- src/components/Popover/index.tsx | 3 +- src/components/Portal/index.ts | 3 +- src/components/QuickReplies/style.less | 2 +- src/components/Radio/Radio.tsx | 2 +- src/components/Radio/RadioGroup.tsx | 2 +- src/components/RateActions/index.tsx | 6 +-- src/components/ScrollView/Item.tsx | 7 +-- src/components/SendConfirm/SendConfirm.tsx | 2 +- src/components/Skeleton/index.tsx | 20 ++++++++ src/components/Skeleton/style.less | 26 ++++++++++ src/components/Tabs/Tab.tsx | 3 +- src/components/Tabs/Tabs.tsx | 13 +++-- src/components/Text/index.tsx | 3 +- src/components/Time/Time.tsx | 2 +- src/components/Toast/Toast.tsx | 6 +-- src/components/Toast/index.tsx | 2 +- src/components/Toolbar/Toolbar.tsx | 2 +- src/components/Toolbar/ToolbarButton.tsx | 2 +- src/components/Toolbar/style.less | 6 ++- src/components/Typing/style.less | 32 +++++++----- src/components/Video/index.tsx | 2 +- src/hooks/useMount.ts | 12 +++-- src/index.ts | 2 + src/styles/index.less | 1 + src/styles/var.less | 2 +- src/utils/isSafari.ts | 1 - src/utils/mountComponent.ts | 4 +- src/utils/ua.ts | 18 +++++++ 75 files changed, 376 insertions(+), 177 deletions(-) create mode 100644 src/components/Skeleton/index.tsx create mode 100644 src/components/Skeleton/style.less delete mode 100644 src/utils/isSafari.ts create mode 100644 src/utils/ua.ts 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 (