Skip to content

Commit

Permalink
NumberControl: Add opt-in prop for next 40px default size
Browse files Browse the repository at this point in the history
  • Loading branch information
mirka committed Aug 27, 2023
1 parent 339dbc1 commit 0b96c24
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions packages/components/src/number-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,20 @@ import type { NumberControlProps } from './types';
import { HStack } from '../h-stack';
import { Spacer } from '../spacer';
import { useCx } from '../utils';
import { useDeprecated36pxDefaultSizeProp } from '../utils/use-deprecated-props';

const noop = () => {};

function UnforwardedNumberControl(
{
props: WordPressComponentProps< NumberControlProps, 'input', false >,
forwardedRef: ForwardedRef< any >
) {
const {
__unstableStateReducer: stateReducerProp,
className,
dragDirection = 'n',
hideHTMLArrows = false,
spinControls = 'native',
spinControls = hideHTMLArrows ? 'none' : 'native',
isDragEnabled = true,
isShiftStepEnabled = true,
label,
Expand All @@ -49,17 +53,19 @@ function UnforwardedNumberControl(
size = 'default',
suffix,
onChange = noop,
...props
}: WordPressComponentProps< NumberControlProps, 'input', false >,
forwardedRef: ForwardedRef< any >
) {
...restProps
} = useDeprecated36pxDefaultSizeProp< NumberControlProps >(
props,
'wp.components.NumberControl',
'6.4'
);

if ( hideHTMLArrows ) {
deprecated( 'wp.components.NumberControl hideHTMLArrows prop ', {
alternative: 'spinControls="none"',
since: '6.2',
version: '6.3',
} );
spinControls = 'none';
}
const inputRef = useRef< HTMLInputElement >();
const mergedRef = useMergeRefs( [ inputRef, forwardedRef ] );
Expand Down Expand Up @@ -212,7 +218,7 @@ function UnforwardedNumberControl(
<Input
autoComplete={ autoComplete }
inputMode="numeric"
{ ...props }
{ ...restProps }
className={ classes }
dragDirection={ dragDirection }
hideHTMLArrows={ spinControls !== 'native' }
Expand Down

0 comments on commit 0b96c24

Please sign in to comment.