From dda231aa866263e8710ea2a62cca8cf90bf54383 Mon Sep 17 00:00:00 2001 From: yuyang Date: Tue, 4 Jul 2023 19:46:52 +0800 Subject: [PATCH 01/22] fix(taginput): clear input value when tag input on blur (#2342) --- src/_common | 2 +- src/select-input/SelectInput.tsx | 1 + src/select-input/useMultiple.tsx | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/_common b/src/_common index 020007983..00aab1efe 160000 --- a/src/_common +++ b/src/_common @@ -1 +1 @@ -Subproject commit 020007983da931c0d98abe476ce3ffdf98a72315 +Subproject commit 00aab1efedc2d90c22c744f9aed9170f235c9a57 diff --git a/src/select-input/SelectInput.tsx b/src/select-input/SelectInput.tsx index 4de64dec5..930c38fb5 100644 --- a/src/select-input/SelectInput.tsx +++ b/src/select-input/SelectInput.tsx @@ -74,6 +74,7 @@ const SelectInput = forwardRef((props: SelectInputProps, ref) => { commonInputProps, onInnerClear, popupVisible: visibleProps.visible, + allowInput: props.allowInput, }) : renderSelectSingle(visibleProps.visible)} diff --git a/src/select-input/useMultiple.tsx b/src/select-input/useMultiple.tsx index f92c83f92..d4de29359 100644 --- a/src/select-input/useMultiple.tsx +++ b/src/select-input/useMultiple.tsx @@ -11,6 +11,7 @@ export interface RenderSelectMultipleParams { commonInputProps: SelectInputCommonProperties; onInnerClear: (context: { e: MouseEvent }) => void; popupVisible: boolean; + allowInput: boolean; } const DEFAULT_KEYS = { @@ -56,7 +57,7 @@ export default function useMultiple(props: TdSelectInputProps) { valueDisplay={props.valueDisplay} placeholder={tPlaceholder} value={tags} - inputValue={tInputValue || ''} + inputValue={p.popupVisible && p.allowInput ? tInputValue : ''} onChange={onTagInputChange} onInputChange={(val, context) => { // 筛选器统一特性:筛选器按下回车时不清空输入框 From 9a15109b0aaaf6c5d6fe37a410acdfa73d8510d9 Mon Sep 17 00:00:00 2001 From: lijianan <574980606@qq.com> Date: Wed, 5 Jul 2023 15:09:42 +0800 Subject: [PATCH 02/22] =?UTF-8?q?fix:=20=F0=9F=90=9B=20=F0=9F=90=9B=20repl?= =?UTF-8?q?ace=20defaultProps=20with=20useDefaultProps=20(#2346)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/loading/Loading.tsx | 11 +++++------ src/loading/gradient.tsx | 1 + 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/loading/Loading.tsx b/src/loading/Loading.tsx index 36f20e35f..e65b8f681 100644 --- a/src/loading/Loading.tsx +++ b/src/loading/Loading.tsx @@ -1,6 +1,5 @@ -import React, { useState, useEffect, FC, useMemo, CSSProperties } from 'react'; +import React, { useState, useEffect, useMemo, CSSProperties } from 'react'; import classnames from 'classnames'; - import { addClass, canUseDocument, removeClass } from '../_util/dom'; import useConfig from '../hooks/useConfig'; import { StyledProps } from '../common'; @@ -8,10 +7,11 @@ import { TdLoadingProps } from './type'; import Portal from '../common/Portal'; import Gradient from './gradient'; import { loadingDefaultProps } from './defaultProps'; +import useDefaultProps from '../hooks/useDefaultProps'; export interface LoadingProps extends TdLoadingProps, StyledProps {} -const Loading: FC = (props) => { +const Loading: React.FC = (props) => { const { attach, indicator, @@ -28,7 +28,7 @@ const Loading: FC = (props) => { zIndex, className, style, - } = props; + } = useDefaultProps(props, loadingDefaultProps); const [showLoading, setShowLoading] = useState(delay ? false : loading); @@ -59,7 +59,7 @@ const Loading: FC = (props) => { }; }, [delay, loading]); - const calcStyles = useMemo(() => { + const calcStyles = useMemo(() => { const styles: CSSProperties = {}; if (zIndex !== undefined) { @@ -156,6 +156,5 @@ const Loading: FC = (props) => { }; Loading.displayName = 'Loading'; -Loading.defaultProps = loadingDefaultProps; export default Loading; diff --git a/src/loading/gradient.tsx b/src/loading/gradient.tsx index 1b1e47ca2..25bb03fe6 100644 --- a/src/loading/gradient.tsx +++ b/src/loading/gradient.tsx @@ -32,4 +32,5 @@ const GradientLoading: FC = () => { ); }; + export default GradientLoading; From 1b80ec383088c6de67ecf6b86eb72f5b61ee120f Mon Sep 17 00:00:00 2001 From: lijianan <574980606@qq.com> Date: Wed, 5 Jul 2023 15:10:30 +0800 Subject: [PATCH 03/22] =?UTF-8?q?fix:=20=F0=9F=90=9B=20replace=20defaultPr?= =?UTF-8?q?ops=20with=20useDefaultProps=20(#2345)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 🐛 fix: 🐛 replace defaultProps with useDefaultProps * fix: 🐛 fix type --- src/layout/Aside.tsx | 11 ++++------- src/layout/Layout.tsx | 42 +++++++++++++++++------------------------- 2 files changed, 21 insertions(+), 32 deletions(-) diff --git a/src/layout/Aside.tsx b/src/layout/Aside.tsx index 1be8a64c5..356e8c7e4 100644 --- a/src/layout/Aside.tsx +++ b/src/layout/Aside.tsx @@ -3,6 +3,7 @@ import classNames from 'classnames'; import useConfig from '../hooks/useConfig'; import { TdAsideProps } from './type'; import { StyledProps } from '../common'; +import useDefaultProps from '../hooks/useDefaultProps'; export interface AsideProps extends TdAsideProps, StyledProps { /** @@ -14,14 +15,14 @@ export interface AsideProps extends TdAsideProps, StyledProps { /** * Aside 组件 */ -const Aside = (props: AsideProps) => { - const { width, className, style, children, ...otherAsideProps } = props; +const Aside: React.FC = (props) => { + const { width, className, style, children, ...otherAsideProps } = useDefaultProps(props, { width: 232 }); const { classPrefix } = useConfig(); const asideClassNames = classNames(`${classPrefix}-layout__sider`, className); const asideWidth = isNaN(Number(width)) ? width : `${width}px`; - const asideStyle = { + const asideStyle: React.CSSProperties = { width: asideWidth, maxWidth: asideWidth, minWidth: asideWidth, @@ -36,10 +37,6 @@ const Aside = (props: AsideProps) => { ); }; -Aside.defaultProps = { - width: 232, -}; - Aside.displayName = 'Aside'; export default Aside; diff --git a/src/layout/Layout.tsx b/src/layout/Layout.tsx index 4b2cacd50..fc3d39e5b 100644 --- a/src/layout/Layout.tsx +++ b/src/layout/Layout.tsx @@ -18,46 +18,31 @@ export interface FooterProps extends TdFooterProps, StyledProps, React.HTMLAttri children?: React.ReactNode; } -const Header = (props: HeaderProps) => { +const Header: React.FC = (props) => { const { classPrefix } = useConfig(); const { className, style = {}, children, height, ...others } = props; const renderHeight = isNaN(Number(height)) ? height : `${height}px`; - const headerClassNames = classNames(`${classPrefix}-layout__header`, className); return ( -
+
{children}
); }; -const Footer = (props: FooterProps) => { +const Footer: React.FC = (props) => { const { classPrefix } = useConfig(); const { className, style = {}, children, height, ...others } = props; const renderHeight = isNaN(Number(height)) ? height : `${height}px`; const footerClassNames = classNames(`${classPrefix}-layout__footer`, className); return ( -