From f3be5ddd0eae511a410fb81bffb4c742fa1c46fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=8D=E9=83=91?= <13414731+notzheng@users.noreply.github.com> Date: Sat, 13 May 2023 16:42:38 +0800 Subject: [PATCH 1/7] =?UTF-8?q?fix(Progress):=20prevent=20warning=20when?= =?UTF-8?q?=20size=20prop=20is=20not=20set=20for=20circle=20p=E2=80=A6=20(?= =?UTF-8?q?#41875)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(Progress): prevent warning when size prop is not set for circle progress * fix(Progress): add test case for #41875 --------- Co-authored-by: lijianan <574980606@qq.com> --- components/progress/Circle.tsx | 6 ++---- components/progress/__tests__/index.test.tsx | 7 +++++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/components/progress/Circle.tsx b/components/progress/Circle.tsx index 06cb3acb16..67cf06731f 100644 --- a/components/progress/Circle.tsx +++ b/components/progress/Circle.tsx @@ -28,12 +28,10 @@ const Circle: React.FC = (props) => { type, children, success, - size, + size = originWidth, } = props; - const mergedSize = size ?? [originWidth, originWidth]; - - const [width, height] = getSize(mergedSize, 'circle'); + const [width, height] = getSize(size, 'circle'); let { strokeWidth } = props; if (strokeWidth === undefined) { diff --git a/components/progress/__tests__/index.test.tsx b/components/progress/__tests__/index.test.tsx index ab2f75a30a..01449854f7 100644 --- a/components/progress/__tests__/index.test.tsx +++ b/components/progress/__tests__/index.test.tsx @@ -264,6 +264,13 @@ describe('Progress', () => { ); }); + it('should not warning if not pass the `size` prop in type Circle', () => { + const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); + errorSpy.mockClear(); + render(); + expect(errorSpy).not.toHaveBeenCalled(); + }); + it('should warnning if pass number[] into `size` in type dashboard', () => { const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); render(); From 828db969629717e4e03df5d9cd37b6d430ec61d3 Mon Sep 17 00:00:00 2001 From: qmhc <544022268@qq.com> Date: Sat, 13 May 2023 17:34:09 +0800 Subject: [PATCH 2/7] style: optimize ColorPicker code (#42326) * chore: fix ColorPicker parameters' type * chore: improve code * chore: update --- components/color-picker/ColorPicker.tsx | 2 +- components/color-picker/ColorPickerPanel.tsx | 2 +- components/color-picker/components/ColorPresets.tsx | 6 +++--- components/color-picker/hooks/useColorState.ts | 5 ++--- components/color-picker/index.en-US.md | 2 +- components/color-picker/{index.tsx => index.ts} | 0 components/color-picker/index.zh-CN.md | 2 +- 7 files changed, 9 insertions(+), 10 deletions(-) rename components/color-picker/{index.tsx => index.ts} (100%) diff --git a/components/color-picker/ColorPicker.tsx b/components/color-picker/ColorPicker.tsx index 77a05d2093..0a9a52cb10 100644 --- a/components/color-picker/ColorPicker.tsx +++ b/components/color-picker/ColorPicker.tsx @@ -28,7 +28,7 @@ export interface ColorPickerProps > { value?: Color | string; defaultValue?: Color | string; - children?: React.ReactElement; + children?: React.ReactNode; open?: boolean; disabled?: boolean; placement?: TriggerPlacement; diff --git a/components/color-picker/ColorPickerPanel.tsx b/components/color-picker/ColorPickerPanel.tsx index 15b2a1f129..b7e62e82e0 100644 --- a/components/color-picker/ColorPickerPanel.tsx +++ b/components/color-picker/ColorPickerPanel.tsx @@ -17,7 +17,7 @@ const ColorPickerPanel: FC = (props) => { const { prefixCls, allowClear, presets, onChange, onClear, color, ...injectProps } = props; const colorPickerPanelPrefixCls = `${prefixCls}-inner-panel`; - const extraPanelRender = (panel: React.ReactElement) => ( + const extraPanelRender = (panel: React.ReactNode) => (
{allowClear && ( { const genPresetColor = (list: PresetsItem[]) => list.map((value) => { - value.colors = value.colors.map((color) => generateColor(color)); + value.colors = value.colors.map(generateColor); return value; }); @@ -35,7 +35,7 @@ const ColorPresets: FC = ({ prefixCls, presets, value: color, const [locale] = useLocale('ColorPicker'); const [presetsValue] = useMergedState(genPresetColor(presets), { value: genPresetColor(presets), - postState: (item) => genPresetColor(item), + postState: genPresetColor, }); const colorPresetsPrefixCls = `${prefixCls}-presets`; @@ -57,7 +57,7 @@ const ColorPresets: FC = ({ prefixCls, presets, value: color, key={`panel-${preset?.label}`} >
- {Array.isArray(preset?.colors) && preset?.colors.length > 0 ? ( + {Array.isArray(preset?.colors) && preset?.colors.length ? ( preset.colors.map((presetColor: Color) => ( >] => { const { defaultValue, value } = option; const [colorValue, setColorValue] = useState(() => { - let mergeState; + let mergeState: string | Color | undefined; if (hasValue(value)) { mergeState = value; } else if (hasValue(defaultValue)) { @@ -23,8 +23,7 @@ const useColorState = ( } else { mergeState = defaultStateValue; } - const genColor = generateColor(mergeState || ''); - return genColor; + return generateColor(mergeState || ''); }); useEffect(() => { diff --git a/components/color-picker/index.en-US.md b/components/color-picker/index.en-US.md index 30e905c842..ff6f7013c8 100644 --- a/components/color-picker/index.en-US.md +++ b/components/color-picker/index.en-US.md @@ -41,7 +41,7 @@ Used when the user needs to customize the color selection | onChange | Callback when `value` is changed | `(value: Color, hex: string) => void` | - | | allowClear | Allow clearing color selected | boolean | false | | presets | Preset colors | `{ label: ReactNode, colors: Array }[]` | - | -| children | Trigger of ColorPicker | ReactElement | - | +| children | Trigger of ColorPicker | React.ReactNode | - | | trigger | ColorPicker trigger mode | `hover` \| `click` | `click` | | open | Whether to show popup | boolean | - | | onOpenChange | Callback when `open` is changed | `(open: boolean) => void` | - | diff --git a/components/color-picker/index.tsx b/components/color-picker/index.ts similarity index 100% rename from components/color-picker/index.tsx rename to components/color-picker/index.ts diff --git a/components/color-picker/index.zh-CN.md b/components/color-picker/index.zh-CN.md index faf8639088..887a03b77b 100644 --- a/components/color-picker/index.zh-CN.md +++ b/components/color-picker/index.zh-CN.md @@ -42,7 +42,7 @@ group: | onChange | 颜色变化的回调 | `(value: Color, hex: string) => void` | - | | allowClear | 允许清除选择的颜色 | boolean | false | | presets | 预设的颜色 | `{ label: ReactNode, colors: Array }[]` | - | -| children | 颜色选择器的触发器 | ReactElement | - | +| children | 颜色选择器的触发器 | React.ReactNode | - | | trigger | 颜色选择器的触发模式 | `hover` \| `click` | `click` | | open | 是否显示弹出窗口 | boolean | - | | onOpenChange | 当 `open` 被改变时的回调 | `(open: boolean) => void` | - | From d3093c9096f135dc3a5c8c4aef506721c11043ca Mon Sep 17 00:00:00 2001 From: lijianan <574980606@qq.com> Date: Sat, 13 May 2023 23:05:26 +0800 Subject: [PATCH 3/7] style: optimize ColorPicker code (#42329) * style: optimize ColorPicker code * style: optimize ColorPicker code * test --- components/color-picker/ColorPickerPanel.tsx | 20 ++++----- .../components/ColorAlphaInput.tsx | 2 +- .../color-picker/components/ColorClear.tsx | 2 +- .../color-picker/components/ColorHsbInput.tsx | 2 +- .../color-picker/components/ColorInput.tsx | 42 ++++++++----------- .../color-picker/components/ColorPresets.tsx | 9 ++-- .../color-picker/components/ColorRgbInput.tsx | 2 +- .../color-picker/components/ColorTrigger.tsx | 11 ++--- .../color-picker/hooks/useColorState.ts | 13 +++--- components/color-picker/interface.ts | 5 ++- 10 files changed, 49 insertions(+), 59 deletions(-) diff --git a/components/color-picker/ColorPickerPanel.tsx b/components/color-picker/ColorPickerPanel.tsx index b7e62e82e0..ec2fd60e6f 100644 --- a/components/color-picker/ColorPickerPanel.tsx +++ b/components/color-picker/ColorPickerPanel.tsx @@ -31,22 +31,11 @@ const ColorPickerPanel: FC = (props) => { /> )} {panel} - onChange?.(value)} - prefixCls={prefixCls} - {...injectProps} - /> - + {Array.isArray(presets) && ( <> - onChange?.(value)} - prefixCls={prefixCls} - /> + )}
@@ -60,4 +49,9 @@ const ColorPickerPanel: FC = (props) => { /> ); }; + +if (process.env.NODE_ENV !== 'production') { + ColorPickerPanel.displayName = 'ColorPickerPanel'; +} + export default ColorPickerPanel; diff --git a/components/color-picker/components/ColorAlphaInput.tsx b/components/color-picker/components/ColorAlphaInput.tsx index 4850937f82..b59f442dda 100644 --- a/components/color-picker/components/ColorAlphaInput.tsx +++ b/components/color-picker/components/ColorAlphaInput.tsx @@ -12,7 +12,7 @@ interface ColorAlphaInputProps extends Pick { const ColorAlphaInput: FC = ({ prefixCls, value, onChange }) => { const colorAlphaInputPrefixCls = `${prefixCls}-alpha-input`; - const [alphaValue, setAlphaValue] = useState(generateColor(value || '#000')); + const [alphaValue, setAlphaValue] = useState(generateColor(value || '#000')); // Update step value useEffect(() => { diff --git a/components/color-picker/components/ColorClear.tsx b/components/color-picker/components/ColorClear.tsx index 2c717e365f..d8f44f4f36 100644 --- a/components/color-picker/components/ColorClear.tsx +++ b/components/color-picker/components/ColorClear.tsx @@ -18,7 +18,7 @@ const ColorClear: FC = ({ prefixCls, value, onChange }) => { onChange?.(genColor); } }; - return
; }; + export default ColorClear; diff --git a/components/color-picker/components/ColorHsbInput.tsx b/components/color-picker/components/ColorHsbInput.tsx index 17fca48a9c..236d0d427a 100644 --- a/components/color-picker/components/ColorHsbInput.tsx +++ b/components/color-picker/components/ColorHsbInput.tsx @@ -14,7 +14,7 @@ interface ColorHsbInputProps extends Pick { const ColorHsbInput: FC = ({ prefixCls, value, onChange }) => { const colorHsbInputPrefixCls = `${prefixCls}-hsb-input`; - const [hsbValue, setHsbValue] = useState(generateColor(value || '#000')); + const [hsbValue, setHsbValue] = useState(generateColor(value || '#000')); // Update step value useEffect(() => { diff --git a/components/color-picker/components/ColorInput.tsx b/components/color-picker/components/ColorInput.tsx index 57b1abe791..65e84ab561 100644 --- a/components/color-picker/components/ColorInput.tsx +++ b/components/color-picker/components/ColorInput.tsx @@ -1,10 +1,10 @@ -import type { FC } from 'react'; -import React from 'react'; import useMergedState from 'rc-util/lib/hooks/useMergedState'; +import type { FC } from 'react'; +import React, { useMemo } from 'react'; import Select from '../../select'; +import type { Color } from '../color'; import type { ColorPickerBaseProps } from '../interface'; import { ColorFormat } from '../interface'; -import type { Color } from '../color'; import ColorAlphaInput from './ColorAlphaInput'; import ColorHexInput from './ColorHexInput'; import ColorHsbInput from './ColorHsbInput'; @@ -16,8 +16,13 @@ interface ColorInputProps onChange?: (value: Color) => void; } +const selectOptions = [ColorFormat.hex, ColorFormat.hsb, ColorFormat.rgb].map((format) => ({ + value: format, + label: format.toLocaleUpperCase(), +})); + const ColorInput: FC = (props) => { - const { prefixCls, format, onFormatChange, value, onChange } = props; + const { prefixCls, format, value, onFormatChange, onChange } = props; const [colorFormat, setColorFormat] = useMergedState('hex', { value: format, onChange: onFormatChange, @@ -29,17 +34,18 @@ const ColorInput: FC = (props) => { setColorFormat(newFormat); }; - const steppersRender = () => { + const steppersNode = useMemo(() => { + const inputProps = { value, prefixCls, onChange }; switch (colorFormat) { case ColorFormat.hsb: - return ; + return ; case ColorFormat.rgb: - return ; + return ; case ColorFormat.hex: default: - return ; + return ; } - }; + }, [colorFormat, prefixCls, value, onChange]); return (
@@ -52,24 +58,12 @@ const ColorInput: FC = (props) => { onChange={handleFormatChange} className={`${prefixCls}-format-select`} size="small" - options={[ - { - label: ColorFormat.hex.toLocaleUpperCase(), - value: ColorFormat.hex, - }, - { - label: ColorFormat.hsb.toLocaleUpperCase(), - value: ColorFormat.hsb, - }, - { - label: ColorFormat.rgb.toLocaleUpperCase(), - value: ColorFormat.rgb, - }, - ]} + options={selectOptions} /> -
{steppersRender()}
+
{steppersNode}
); }; + export default ColorInput; diff --git a/components/color-picker/components/ColorPresets.tsx b/components/color-picker/components/ColorPresets.tsx index aa595cc58e..26ad101440 100644 --- a/components/color-picker/components/ColorPresets.tsx +++ b/components/color-picker/components/ColorPresets.tsx @@ -1,8 +1,8 @@ +import { ColorBlock } from '@rc-component/color-picker'; import classNames from 'classnames'; import useMergedState from 'rc-util/lib/hooks/useMergedState'; import type { FC } from 'react'; import React, { useMemo } from 'react'; -import { ColorBlock } from '@rc-component/color-picker'; import Collapse from '../../collapse'; import { useLocale } from '../../locale'; import type { Color } from '../color'; @@ -39,7 +39,7 @@ const ColorPresets: FC = ({ prefixCls, presets, value: color, }); const colorPresetsPrefixCls = `${prefixCls}-presets`; - const activeKey = useMemo( + const activeKeys = useMemo( () => presetsValue.map((preset) => `panel-${preset.label}`), [presetsValue], ); @@ -50,14 +50,14 @@ const ColorPresets: FC = ({ prefixCls, presets, value: color, return (
- + {presetsValue.map((preset) => ( {preset?.label}
} key={`panel-${preset?.label}`} >
- {Array.isArray(preset?.colors) && preset?.colors.length ? ( + {Array.isArray(preset?.colors) && preset.colors?.length > 0 ? ( preset.colors.map((presetColor: Color) => ( = ({ prefixCls, presets, value: color,
); }; + export default ColorPresets; diff --git a/components/color-picker/components/ColorRgbInput.tsx b/components/color-picker/components/ColorRgbInput.tsx index 006eedef40..781043578b 100644 --- a/components/color-picker/components/ColorRgbInput.tsx +++ b/components/color-picker/components/ColorRgbInput.tsx @@ -13,7 +13,7 @@ interface ColorRgbInputProps extends Pick { const ColorRgbInput: FC = ({ prefixCls, value, onChange }) => { const colorRgbInputPrefixCls = `${prefixCls}-rgb-input`; - const [rgbValue, setRgbValue] = useState(generateColor(value || '#000')); + const [rgbValue, setRgbValue] = useState(generateColor(value || '#000')); // Update step value useEffect(() => { diff --git a/components/color-picker/components/ColorTrigger.tsx b/components/color-picker/components/ColorTrigger.tsx index 2096a23ca3..bb7880c8cb 100644 --- a/components/color-picker/components/ColorTrigger.tsx +++ b/components/color-picker/components/ColorTrigger.tsx @@ -1,7 +1,7 @@ +import { ColorBlock } from '@rc-component/color-picker'; import classNames from 'classnames'; import type { CSSProperties, MouseEventHandler } from 'react'; import React, { forwardRef, useMemo } from 'react'; -import { ColorBlock } from '@rc-component/color-picker'; import type { ColorPickerBaseProps } from '../interface'; import ColorClear from './ColorClear'; @@ -20,14 +20,14 @@ const ColorTrigger = forwardRef((props, ref) const { color, prefixCls, open, clearColor, disabled, className, ...rest } = props; const colorTriggerPrefixCls = `${prefixCls}-trigger`; - const containerRender = useMemo( + const containerNode = useMemo( () => clearColor ? ( ) : ( - + ), - [color, clearColor], + [color, clearColor, prefixCls], ); return ( @@ -39,8 +39,9 @@ const ColorTrigger = forwardRef((props, ref) })} {...rest} > - {containerRender} + {containerNode}
); }); + export default ColorTrigger; diff --git a/components/color-picker/hooks/useColorState.ts b/components/color-picker/hooks/useColorState.ts index 0a1849b357..6f90556c72 100644 --- a/components/color-picker/hooks/useColorState.ts +++ b/components/color-picker/hooks/useColorState.ts @@ -2,19 +2,16 @@ import { useEffect, useState } from 'react'; import type { Color } from '../color'; import { generateColor } from '../util'; -function hasValue(value: Color | string | undefined) { +function hasValue(value?: Color | string) { return value !== undefined; } const useColorState = ( defaultStateValue: Color | string, - option: { - defaultValue?: Color | string; - value?: Color | string; - }, -): [Color, React.Dispatch>] => { + option: { defaultValue?: Color | string; value?: Color | string }, +): readonly [Color, React.Dispatch>] => { const { defaultValue, value } = option; - const [colorValue, setColorValue] = useState(() => { + const [colorValue, setColorValue] = useState(() => { let mergeState: string | Color | undefined; if (hasValue(value)) { mergeState = value; @@ -32,7 +29,7 @@ const useColorState = ( } }, [value]); - return [colorValue, setColorValue]; + return [colorValue, setColorValue] as const; }; export default useColorState; diff --git a/components/color-picker/interface.ts b/components/color-picker/interface.ts index c7dbe0e3d5..37dce01490 100644 --- a/components/color-picker/interface.ts +++ b/components/color-picker/interface.ts @@ -8,7 +8,10 @@ export enum ColorFormat { hsb = 'hsb', } -export type PresetsItem = { label: ReactNode; colors: Array }; +export interface PresetsItem { + label: ReactNode; + colors: (string | Color)[]; +} export interface ColorPickerBaseProps { color?: Color; From f0c53e11a931285c10e0fbb24af196b58ce264ba Mon Sep 17 00:00:00 2001 From: bqy_fe <1743369777@qq.com> Date: Sun, 14 May 2023 11:43:21 +0800 Subject: [PATCH 4/7] fix(Divider): no dashed line in vertical (#40418) Co-authored-by: afc163 --- components/divider/style/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/divider/style/index.ts b/components/divider/style/index.ts index 4eb445ae27..adb3c87255 100644 --- a/components/divider/style/index.ts +++ b/components/divider/style/index.ts @@ -1,7 +1,7 @@ import type { CSSObject } from '@ant-design/cssinjs'; +import { resetComponent } from '../../style'; import type { FullToken, GenerateStyle } from '../../theme/internal'; import { genComponentStyleHook, mergeToken } from '../../theme/internal'; -import { resetComponent } from '../../style'; /** Component only token. Which will handle additional calculation of alias token */ export interface ComponentToken { @@ -105,7 +105,7 @@ const genSharedDividerStyle: GenerateStyle = (token): CSSObject => }, [`&-vertical${componentCls}-dashed`]: { - borderInlineStart: lineWidth, + borderInlineStartWidth: lineWidth, borderInlineEnd: 0, borderBlockStart: 0, borderBlockEnd: 0, From 0470646a5f27509967453d858be7cae612818ed3 Mon Sep 17 00:00:00 2001 From: lijianan <574980606@qq.com> Date: Sun, 14 May 2023 11:47:01 +0800 Subject: [PATCH 5/7] refactor: optimize ColorPicker code again (#42334) --- .../__snapshots__/demo-extend.test.ts.snap | 6 +++--- .../__tests__/__snapshots__/demo.test.ts.snap | 6 +++--- components/color-picker/demo/base.tsx | 2 +- components/color-picker/demo/format.tsx | 8 +++++--- components/color-picker/demo/pure-panel.tsx | 2 +- components/color-picker/demo/trigger.tsx | 15 ++++++++------- components/color-picker/index.en-US.md | 6 +++--- components/color-picker/index.zh-CN.md | 2 +- components/color-picker/style/index.ts | 10 +++++----- components/color-picker/style/picker.ts | 3 ++- 10 files changed, 32 insertions(+), 28 deletions(-) diff --git a/components/color-picker/__tests__/__snapshots__/demo-extend.test.ts.snap b/components/color-picker/__tests__/__snapshots__/demo-extend.test.ts.snap index bfaf7f26c3..33e423af1f 100644 --- a/components/color-picker/__tests__/__snapshots__/demo-extend.test.ts.snap +++ b/components/color-picker/__tests__/__snapshots__/demo-extend.test.ts.snap @@ -2187,7 +2187,7 @@ exports[`renders components/color-picker/demo/format.tsx extend context correctl > HSB: - hsb(215,91%,100%) + hsb(215, 91%, 100%)
@@ -2815,7 +2815,7 @@ exports[`renders components/color-picker/demo/format.tsx extend context correctl > RGB: - rgb(22,119,255) + rgb(22, 119, 255) @@ -3973,7 +3973,7 @@ Array [ style="margin-right: 8px;" >
HSB: - hsb(215,91%,100%) + hsb(215, 91%, 100%)
@@ -180,7 +180,7 @@ exports[`renders components/color-picker/demo/format.tsx correctly 1`] = ` > RGB: - rgb(22,119,255) + rgb(22, 119, 255) @@ -234,7 +234,7 @@ exports[`renders components/color-picker/demo/trigger.tsx correctly 1`] = ` style="margin-right:8px" >
{ diff --git a/components/color-picker/demo/format.tsx b/components/color-picker/demo/format.tsx index 5172a0be85..c75df886ed 100644 --- a/components/color-picker/demo/format.tsx +++ b/components/color-picker/demo/format.tsx @@ -1,20 +1,22 @@ import { Col, ColorPicker, Row, Space } from 'antd'; -import type { Color } from 'antd/lib/color-picker'; +import type { Color } from 'antd/es/color-picker'; import React, { useMemo, useState } from 'react'; export default () => { const [colorHex, setColorHex] = useState('#1677ff'); - const [colorHsb, setColorHsb] = useState('hsb(215,91%,100%)'); - const [colorRgb, setColorRgb] = useState('rgb(22,119,255)'); + const [colorHsb, setColorHsb] = useState('hsb(215, 91%, 100%)'); + const [colorRgb, setColorRgb] = useState('rgb(22, 119, 255)'); const hexString = useMemo( () => (typeof colorHex === 'string' ? colorHex : colorHex.toHexString()), [colorHex], ); + const hsbString = useMemo( () => (typeof colorHsb === 'string' ? colorHsb : colorHsb.toHsbString()), [colorHsb], ); + const rgbString = useMemo( () => (typeof colorRgb === 'string' ? colorRgb : colorRgb.toRgbString()), [colorRgb], diff --git a/components/color-picker/demo/pure-panel.tsx b/components/color-picker/demo/pure-panel.tsx index b2bef162bd..7e4bd31f6a 100644 --- a/components/color-picker/demo/pure-panel.tsx +++ b/components/color-picker/demo/pure-panel.tsx @@ -1,5 +1,5 @@ import { ColorPicker, theme } from 'antd'; -import type { Color } from 'antd/lib/color-picker'; +import type { Color } from 'antd/es/color-picker'; import React, { useState } from 'react'; const PureRenderColorPicker = ColorPicker._InternalPanelDoNotUseOrYouWillBeFired; diff --git a/components/color-picker/demo/trigger.tsx b/components/color-picker/demo/trigger.tsx index 26a1632ffa..3f244e8353 100644 --- a/components/color-picker/demo/trigger.tsx +++ b/components/color-picker/demo/trigger.tsx @@ -1,11 +1,12 @@ import { ColorPicker, Space, theme } from 'antd'; -import type { Color } from 'antd/lib/color-picker'; +import type { Color } from 'antd/es/color-picker'; import React, { useMemo, useState } from 'react'; export default () => { const { token } = theme.useToken(); const [color, setColor] = useState(token.colorPrimary); - const genColor = useMemo( + + const bgColor = useMemo( () => (typeof color === 'string' ? color : color.toHexString()), [color], ); @@ -15,13 +16,13 @@ export default () => {
- {genColor} + {bgColor} ); diff --git a/components/color-picker/index.en-US.md b/components/color-picker/index.en-US.md index ff6f7013c8..bc39c32bb2 100644 --- a/components/color-picker/index.en-US.md +++ b/components/color-picker/index.en-US.md @@ -10,11 +10,11 @@ group: title: Data Entry --- -Components providing color selection +Components providing color selection, Available since `5.5.0`. ## When To Use -Used when the user needs to customize the color selection +Used when the user needs to customize the color selection. ## Examples @@ -29,7 +29,7 @@ Used when the user needs to customize the color selection ## API -> This component is available since antd@5.5.0 +> This component is available since `antd@5.5.0`. | Property | Description | Type | Default | diff --git a/components/color-picker/index.zh-CN.md b/components/color-picker/index.zh-CN.md index 887a03b77b..42b8b69213 100644 --- a/components/color-picker/index.zh-CN.md +++ b/components/color-picker/index.zh-CN.md @@ -11,7 +11,7 @@ group: title: 数据录入 --- -提供颜色选取的组件 +提供颜色选取的组件,自 `5.5.0` 版本开始提供该组件。 ## 何时使用 diff --git a/components/color-picker/style/index.ts b/components/color-picker/style/index.ts index 63ae57dad2..7211e980e5 100644 --- a/components/color-picker/style/index.ts +++ b/components/color-picker/style/index.ts @@ -1,10 +1,10 @@ import type { CSSObject } from '@ant-design/cssinjs'; import type { FullToken, GenerateStyle } from '../../theme/internal'; import { genComponentStyleHook, mergeToken } from '../../theme/internal'; -import genPickerStyle from './picker'; -import genInputStyle from './input'; -import genPresetsStyle from './presets'; import genColorBlockStyle from './color-block'; +import genInputStyle from './input'; +import genPickerStyle from './picker'; +import genPresetsStyle from './presets'; export interface ComponentToken {} @@ -137,7 +137,7 @@ export default genComponentStyleHook('ColorPicker', (token) => { const colorPickerSliderHeight = 8; - const ColorPickerToken = mergeToken(token, { + const colorPickerToken = mergeToken(token, { colorPickerWidth: 234, colorPickerHandlerSize: 16, colorPickerHandlerSizeSM: 12, @@ -149,5 +149,5 @@ export default genComponentStyleHook('ColorPicker', (token) => { colorPickerPreviewSize: colorPickerSliderHeight * 2 + marginSM, }); - return [genColorPickerStyle(ColorPickerToken)]; + return [genColorPickerStyle(colorPickerToken)]; }); diff --git a/components/color-picker/style/picker.ts b/components/color-picker/style/picker.ts index 977f22e97f..4a5de9c74b 100644 --- a/components/color-picker/style/picker.ts +++ b/components/color-picker/style/picker.ts @@ -1,7 +1,7 @@ import type { CSSObject } from '@ant-design/cssinjs'; import type { GenerateStyle } from '../../theme/internal'; -import type { ColorPickerToken } from './index'; import genColorBlockStyle from './color-block'; +import type { ColorPickerToken } from './index'; const genPickerStyle: GenerateStyle = (token) => { const { @@ -41,6 +41,7 @@ const genPickerStyle: GenerateStyle = (token) => { border: `${lineWidthBold}px solid ${colorBgElevated}`, position: 'relative', borderRadius: '50%', + cursor: 'pointer', boxShadow: `${colorPickerInsetShadow}, 0 0 0 1px ${colorFillSecondary}`, '&-sm': { width: colorPickerHandlerSizeSM, From 4439d8065c323342ee1b9902cbcaf7b7a5c27507 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=BD=E5=AE=81?= Date: Sun, 14 May 2023 12:51:18 +0800 Subject: [PATCH 6/7] chore: remove redundant .gitignore file (#42336) --- .husky/.gitignore | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .husky/.gitignore diff --git a/.husky/.gitignore b/.husky/.gitignore deleted file mode 100644 index 31354ec138..0000000000 --- a/.husky/.gitignore +++ /dev/null @@ -1 +0,0 @@ -_ From 14574b11047b1005107e0464fa1bc4d8bc5e6b3d Mon Sep 17 00:00:00 2001 From: MD Rashid Hussain <64685317+m3rashid@users.noreply.github.com> Date: Sun, 14 May 2023 21:32:22 +0530 Subject: [PATCH 7/7] docs: remove duplicate DollarCircle in icons list (#42340) --- .dumi/theme/builtins/IconSearch/index.tsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.dumi/theme/builtins/IconSearch/index.tsx b/.dumi/theme/builtins/IconSearch/index.tsx index 0dc425a380..2f32af9dd2 100644 --- a/.dumi/theme/builtins/IconSearch/index.tsx +++ b/.dumi/theme/builtins/IconSearch/index.tsx @@ -85,8 +85,11 @@ const IconSearch: React.FC = () => { iconList = iconList.filter((iconName) => iconName.toLowerCase().includes(matchKey)); } - // CopyrightCircle is same as Copyright, don't show it - iconList = iconList.filter((icon) => icon !== 'CopyrightCircle'); + const ignore = [ + 'CopyrightCircle', // same as Copyright + 'DollarCircle', // same as Dollar + ]; + iconList = iconList.filter((icon) => !ignore.includes(icon)); return { category: key, @@ -121,11 +124,11 @@ const IconSearch: React.FC = () => { }; return ( -
+
{ style={{ flex: 1, marginInlineStart: 16 }} allowClear autoFocus - size="large" + size='large' onChange={handleSearchIcon} />