Skip to content

Commit 1a9c7ca

Browse files
authored
🤖 Merge PR DefinitelyTyped#73993 [@types/wordpress__block-editor] Fix PanelColorSettings type definitions by @rafaucau
1 parent 2de26ec commit 1a9c7ca

File tree

2 files changed

+43
-11
lines changed

2 files changed

+43
-11
lines changed

‎types/wordpress__block-editor/components/panel-color-settings.d.ts‎

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,44 @@
1-
import { ColorPalette, PanelBody } from "@wordpress/components";
2-
import { ComponentProps, ComponentType } from "react";
1+
import { ColorPalette, GradientPicker } from "@wordpress/components";
2+
import type { ComponentProps, ComponentType, ReactNode } from "react";
33

44
declare namespace PanelColorSettings {
5-
type ColorSetting =
6-
& Partial<ComponentProps<typeof ColorPalette>>
7-
& Pick<ComponentProps<typeof ColorPalette>, "onChange" | "value">
8-
& { label: string };
9-
interface Props extends Omit<ComponentProps<typeof PanelBody>, "children"> {
10-
colorSettings: ColorSetting[];
11-
disableCustomColors?: boolean | undefined;
5+
interface ColorSetting {
6+
/** The current color of the setting. */
7+
value: string;
8+
/** Callback on change of the setting. */
9+
onChange: (value: string | undefined) => void;
10+
/** Label of the setting. */
11+
label: string;
12+
/** Colors palette for this specific setting. */
13+
colors?: ComponentProps<typeof ColorPalette>["colors"];
14+
/** Whether to disable custom colors for this specific setting. */
15+
disableCustomColors?: boolean;
16+
/** Whether to disable custom gradients for this specific setting. */
17+
disableCustomGradients?: boolean;
18+
}
19+
interface Props {
20+
/** A user-provided set of color settings. */
21+
colorSettings?: ColorSetting[];
22+
/** Added to the underlying ToolsPanel instance. */
23+
className?: string;
24+
/** Array of colors to be used. */
25+
colors?: ComponentProps<typeof ColorPalette>["colors"];
26+
/** Not recommended to be used since `PanelColorSettings` resets it. */
27+
gradients?: ComponentProps<typeof GradientPicker>["gradients"];
28+
/** Whether the addition of custom colors is enabled. */
29+
disableCustomColors?: boolean;
30+
/** Not recommended to be used since `PanelColorSettings` sets it. */
31+
disableCustomGradients?: boolean;
32+
/** Displayed below the underlying `PanelColorGradientSettings` instance. */
33+
children?: ReactNode;
34+
/** Title of the underlying `ToolsPanel`. */
35+
title?: string;
36+
/** Whether to show the title of the `ToolsPanel`. */
37+
showTitle?: boolean;
38+
/** Whether this is rendered in the sidebar. */
39+
__experimentalIsRenderedInSidebar?: boolean;
40+
/** Whether to enable setting opacity when specifying a color. */
41+
enableAlpha?: boolean;
1242
}
1343
}
1444
declare const PanelColorSettings: ComponentType<PanelColorSettings.Props>;

‎types/wordpress__block-editor/wordpress__block-editor-tests.tsx‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,15 +299,13 @@ be.withFontSizes("fontSize")(() => <h1>Hello World</h1>);
299299
//
300300
<be.PanelColorSettings
301301
title="Color Settings"
302-
initialOpen={false}
303302
colorSettings={[
304303
{
305304
value: "#ff0000",
306305
onChange(color) {
307306
color && console.log(color);
308307
},
309308
label: "Background Color",
310-
disableCustomColors: true,
311309
colors: [
312310
{
313311
color: "#ff0000",
@@ -318,8 +316,12 @@ be.withFontSizes("fontSize")(() => <h1>Hello World</h1>);
318316
name: "Yellow",
319317
},
320318
],
319+
disableCustomColors: false,
321320
},
322321
]}
322+
disableCustomColors={true}
323+
showTitle={true}
324+
enableAlpha={true}
323325
/>;
324326
<be.PanelColorSettings
325327
colorSettings={[

0 commit comments

Comments
 (0)