Skip to content

Commit

Permalink
BoxControl: Passive deprecate onMouseOver/onMouseOut
Browse files Browse the repository at this point in the history
  • Loading branch information
mirka committed Nov 26, 2024
1 parent eadf2dd commit 04c4e53
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 58 deletions.
4 changes: 2 additions & 2 deletions packages/components/src/box-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ function BoxControl( {
};

const inputControlProps = {
onMouseOver,
onMouseOut,
...inputProps,
onChange: handleOnChange,
onFocus: handleOnFocus,
Expand All @@ -150,8 +152,6 @@ function BoxControl( {
setSelectedUnits,
sides,
values: inputValues,
onMouseOver,
onMouseOut,
__next40pxDefaultSize,
};

Expand Down
127 changes: 71 additions & 56 deletions packages/components/src/box-control/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,70 +17,85 @@ export type CustomValueUnits = {

type UnitControlPassthroughProps = Omit<
UnitControlProps,
'label' | 'onChange' | 'onFocus' | 'onMouseOver' | 'onMouseOut' | 'units'
'label' | 'onChange' | 'onFocus' | 'units'
>;

export type BoxControlProps = Pick<
UnitControlProps,
'onMouseOver' | 'onMouseOut' | 'units'
> & {
/**
* If this property is true, a button to reset the box control is rendered.
*
* @default true
*/
allowReset?: boolean;
/**
* The id to use as a base for the unique HTML id attribute of the control.
*/
id?: string;
/**
* Props for the internal `UnitControl` components.
*
* @default { min: 0 }
*/
inputProps?: UnitControlPassthroughProps;
/**
* Heading label for the control.
*
* @default __( 'Box Control' )
*/
label?: string;
type DeprecatedBoxControlProps = {
/**
* A callback function when an input value changes.
* @deprecated Pass to the `inputProps` prop instead.
* @ignore
*/
onChange: ( next: BoxControlValue ) => void;
onMouseOver?: UnitControlProps[ 'onMouseOver' ];
/**
* The `top`, `right`, `bottom`, and `left` box dimension values to use when the control is reset.
*
* @default { top: undefined, right: undefined, bottom: undefined, left: undefined }
* @deprecated Pass to the `inputProps` prop instead.
* @ignore
*/
resetValues?: BoxControlValue;
/**
* Collection of sides to allow control of. If omitted or empty, all sides will be available.
*
* Allowed values are "top", "right", "bottom", "left", "vertical", and "horizontal".
*/
sides?: readonly ( keyof BoxControlValue | 'horizontal' | 'vertical' )[];
/**
* If this property is true, when the box control is unlinked, vertical and horizontal controls
* can be used instead of updating individual sides.
*
* @default false
*/
splitOnAxis?: boolean;
/**
* The current values of the control, expressed as an object of `top`, `right`, `bottom`, and `left` values.
*/
values?: BoxControlValue;
/**
* Start opting into the larger default height that will become the default size in a future version.
*
* @default false
*/
__next40pxDefaultSize?: boolean;
onMouseOut?: UnitControlProps[ 'onMouseOut' ];
};

export type BoxControlProps = Pick< UnitControlProps, 'units' > &
DeprecatedBoxControlProps & {
/**
* If this property is true, a button to reset the box control is rendered.
*
* @default true
*/
allowReset?: boolean;
/**
* The id to use as a base for the unique HTML id attribute of the control.
*/
id?: string;
/**
* Props for the internal `UnitControl` components.
*
* @default { min: 0 }
*/
inputProps?: UnitControlPassthroughProps;
/**
* Heading label for the control.
*
* @default __( 'Box Control' )
*/
label?: string;
/**
* A callback function when an input value changes.
*/
onChange: ( next: BoxControlValue ) => void;
/**
* The `top`, `right`, `bottom`, and `left` box dimension values to use when the control is reset.
*
* @default { top: undefined, right: undefined, bottom: undefined, left: undefined }
*/
resetValues?: BoxControlValue;
/**
* Collection of sides to allow control of. If omitted or empty, all sides will be available.
*
* Allowed values are "top", "right", "bottom", "left", "vertical", and "horizontal".
*/
sides?: readonly (
| keyof BoxControlValue
| 'horizontal'
| 'vertical'
)[];
/**
* If this property is true, when the box control is unlinked, vertical and horizontal controls
* can be used instead of updating individual sides.
*
* @default false
*/
splitOnAxis?: boolean;
/**
* The current values of the control, expressed as an object of `top`, `right`, `bottom`, and `left` values.
*/
values?: BoxControlValue;
/**
* Start opting into the larger default height that will become the default size in a future version.
*
* @default false
*/
__next40pxDefaultSize?: boolean;
};

export type BoxControlInputControlProps = UnitControlPassthroughProps & {
onChange?: ( nextValues: BoxControlValue ) => void;
onFocus?: (
Expand Down

0 comments on commit 04c4e53

Please sign in to comment.