refactor(color-picker): rename defaultCollapsed => defaultOpen (#45655)

This commit is contained in:
2023-11-03 16:49:22 +08:00 committed by GitHub
parent 321dfd8cc9
commit f3c37a3be4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 7 additions and 7 deletions

View File

@ -248,7 +248,7 @@ describe('ColorPicker', () => {
{
label: 'Recent',
colors: ['#f00d', '#0f0d', '#00fd'],
defaultCollapsed: true,
defaultOpen: false,
},
]}
/>,

View File

@ -48,9 +48,8 @@ const ColorPresets: FC<ColorPresetsProps> = ({ prefixCls, presets, value: color,
const activeKeys = useMemo(
() =>
presetsValue.reduce<string[]>((acc, preset) => {
if (!preset.defaultCollapsed) {
acc.push(genCollapsePanelKey(preset));
}
const { defaultOpen = true } = preset;
if (defaultOpen) acc.push(genCollapsePanelKey(preset));
return acc;
}, []),
[presetsValue],

View File

@ -53,7 +53,7 @@ Common props ref[Common props](/docs/react/common-props)
| destroyTooltipOnHide | Whether destroy popover when hidden | `boolean` | false | 5.7.0 |
| format | Format of color | `rgb` \| `hex` \| `hsb` | `hex` | |
| open | Whether to show popup | boolean | - | |
| presets | Preset colors | `{ label: ReactNode, colors: Array<string \| Color>, defaultCollapsed?: boolean }[]` | - | `defaultCollapsed: 5.11.0` |
| presets | Preset colors | `{ label: ReactNode, colors: Array<string \| Color>, defaultOpen?: boolean }[]` | - | `defaultOpen: 5.11.0` |
| placement | Placement of popup | `top` \| `topLeft` \| `topRight` \| `bottom` \| `bottomLeft` \| `bottomRight` | `bottomLeft` | |
| panelRender | Custom Render Panel | `(panel: React.ReactNode, extra: { components: { Picker: FC; Presets: FC } }) => React.ReactNode` | - | 5.7.0 |
| showText | Show color text | boolean \| `(color: Color) => React.ReactNode` | - | 5.7.0 |

View File

@ -54,7 +54,7 @@ group:
| destroyTooltipOnHide | 关闭后是否销毁弹窗 | `boolean` | false | 5.7.0 |
| format | 颜色格式 | `rgb` \| `hex` \| `hsb` | `hex` | |
| open | 是否显示弹出窗口 | boolean | - | |
| presets | 预设的颜色 | `{ label: ReactNode, colors: Array<string \| Color>, defaultCollapsed?: boolean }[]` | - | `defaultCollapsed: 5.11.0` |
| presets | 预设的颜色 | `{ label: ReactNode, colors: Array<string \| Color>, defaultOpen?: boolean }[]` | - | `defaultOpen: 5.11.0` |
| placement | 弹出窗口的位置 | `top` \| `topLeft` \| `topRight` \| `bottom` \| `bottomLeft` \| `bottomRight` | `bottomLeft` | |
| panelRender | 自定义渲染面板 | `(panel: React.ReactNode, extra: { components: { Picker: FC; Presets: FC } }) => React.ReactNode` | - | 5.7.0 |
| showText | 显示颜色文本 | boolean \| `(color: Color) => React.ReactNode` | - | 5.7.0 |

View File

@ -14,8 +14,9 @@ export interface PresetsItem {
/**
* Whether the initial state is collapsed
* @since 5.11.0
* @default true
*/
defaultCollapsed?: boolean;
defaultOpen?: boolean;
}
export type TriggerType = 'click' | 'hover';