Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,6 @@ function GridControls( {
>
<FlexItem style={ { width: '50%' } }>
<InputControl
size="__unstable-large"
label={ __( 'Column span' ) }
type="number"
onChange={ ( value ) => {
Expand All @@ -331,7 +330,6 @@ function GridControls( {
</FlexItem>
<FlexItem style={ { width: '50%' } }>
<InputControl
size="__unstable-large"
label={ __( 'Row span' ) }
type="number"
onChange={ ( value ) => {
Expand Down Expand Up @@ -369,7 +367,6 @@ function GridControls( {
>
<FlexItem style={ { width: '50%' } }>
<InputControl
size="__unstable-large"
label={ __( 'Column' ) }
type="number"
onChange={ ( value ) => {
Expand Down Expand Up @@ -404,7 +401,6 @@ function GridControls( {
</FlexItem>
<FlexItem style={ { width: '50%' } }>
<InputControl
size="__unstable-large"
label={ __( 'Row' ) }
type="number"
onChange={ ( value ) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ const InsertFromURLPopover = ( {
onSubmit={ onSubmit }
>
<InputControl
__next40pxDefaultSize
label={ __( 'URL' ) }
type="text" // Use text instead of URL to allow relative paths (e.g., /image/image.jpg)
hideLabelFromVision
Expand Down
1 change: 0 additions & 1 deletion packages/block-library/src/embed/embed-placeholder.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export default function EmbedPlaceholder( {
>
<form onSubmit={ onSubmit }>
<InputControl
__next40pxDefaultSize
type="url"
value={ value || '' }
className="wp-block-embed__placeholder-input"
Expand Down
1 change: 0 additions & 1 deletion packages/block-library/src/rss/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ export default function RSSEdit( { attributes, setAttributes, name } ) {
className="wp-block-rss__placeholder-form"
>
<InputControl
__next40pxDefaultSize
label={ label }
type="url"
hideLabelFromVision
Expand Down
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- `FontSizePicker` ([#79481](https://github.com/WordPress/gutenberg/pull/79481))
- `FormFileUpload` ([#79655](https://github.com/WordPress/gutenberg/pull/79655))
- `FormTokenField` ([#79720](https://github.com/WordPress/gutenberg/pull/79720))
- `InputControl` ([#79962](https://github.com/WordPress/gutenberg/pull/79962))
- `RangeControl` ([#79590](https://github.com/WordPress/gutenberg/pull/79590))
- `Radio` ([#79657](https://github.com/WordPress/gutenberg/pull/79657))
- `SelectControl` ([#79797](https://github.com/WordPress/gutenberg/pull/79797))
Expand Down
1 change: 0 additions & 1 deletion packages/components/src/color-picker/hex-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ export const HexInput = ( { color, onChange, enableAlpha }: HexInputProps ) => {
maxLength={ enableAlpha ? 9 : 7 }
label={ __( 'Hex color' ) }
hideLabelFromVision
size="__unstable-large"
__unstableStateReducer={ stateReducer }
__unstableInputWidth="9em"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,7 @@ function CustomSelect(
>
{ label }
</Ariakit.SelectLabel>
<InputBase
__next40pxDefaultSize
size={ size }
suffix={ <SelectControlChevronDown /> }
>
<InputBase size={ size } suffix={ <SelectControlChevronDown /> }>
<CustomSelectButton
{ ...restProps }
size={ size }
Expand Down
8 changes: 0 additions & 8 deletions packages/components/src/input-control/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const Example = () => {

return (
<InputControl
__next40pxDefaultSize
value={ value }
onChange={ ( nextValue ) => setValue( nextValue ?? '' ) }
/>
Expand Down Expand Up @@ -109,10 +108,3 @@ The current value of the input.
- Type: `String`
- Required: No

### __next40pxDefaultSize

Start opting into the larger default height that will become the default size in a future version.

- Type: `Boolean`
- Required: No
- Default: `false`
21 changes: 5 additions & 16 deletions packages/components/src/input-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import type { InputControlProps } from './types';
import { space } from '../utils/space';
import { useDraft } from './utils';
import BaseControl from '../base-control';
import { useDeprecated36pxDefaultSizeProp } from '../utils/use-deprecated-props';
import { maybeWarnDeprecated36pxSize } from '../utils/deprecated-36px-size';

const noop = () => {};

Expand All @@ -36,8 +34,10 @@ export function UnforwardedInputControl(
ref: ForwardedRef< HTMLInputElement >
) {
const {
__next40pxDefaultSize,
__shouldNotWarnDeprecated36pxSize,
// Prevent passing legacy props to internal components.
__next40pxDefaultSize: _next40pxDefaultSize,
__next36pxDefaultSize: _next36pxDefaultSize,
__shouldNotWarnDeprecated36pxSize: _shouldNotWarnDeprecated36pxSize,
__unstableStateReducer: stateReducer = ( state ) => state,
__unstableInputWidth,
className,
Expand All @@ -57,7 +57,7 @@ export function UnforwardedInputControl(
suffix,
value,
...restProps
} = useDeprecated36pxDefaultSizeProp< InputControlProps >( props );
} = props;

const id = useUniqueId( idProp );
const classes = clsx( 'components-input-control', className );
Expand All @@ -70,17 +70,9 @@ export function UnforwardedInputControl(

const helpProp = !! help ? { 'aria-describedby': `${ id }__help` } : {};

maybeWarnDeprecated36pxSize( {
componentName: 'InputControl',
__next40pxDefaultSize,
size,
__shouldNotWarnDeprecated36pxSize,
} );

return (
<BaseControl className={ classes } help={ help } id={ id }>
<InputBase
__next40pxDefaultSize={ __next40pxDefaultSize }
__unstableInputWidth={ __unstableInputWidth }
disabled={ disabled }
gap={ 3 }
Expand All @@ -97,7 +89,6 @@ export function UnforwardedInputControl(
<InputField
{ ...restProps }
{ ...helpProp }
__next40pxDefaultSize={ __next40pxDefaultSize }
className="components-input-control__input"
disabled={ disabled }
id={ id }
Expand Down Expand Up @@ -129,7 +120,6 @@ export function UnforwardedInputControl(
*
* return (
* <InputControl
* __next40pxDefaultSize
* value={ value }
* onChange={ ( nextValue ) => setValue( nextValue ?? '' ) }
* />
Expand All @@ -138,6 +128,5 @@ export function UnforwardedInputControl(
* ```
*/
export const InputControl = forwardRef( UnforwardedInputControl );
InputControl.displayName = 'InputControl';

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to the PR, but I noticed this was causing the Storybook props table to break.


export default InputControl;
12 changes: 4 additions & 8 deletions packages/components/src/input-control/input-base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
contextConnect,
useContextSystem,
} from '../context';
import { useDeprecated36pxDefaultSizeProp } from '../utils/use-deprecated-props';

function useUniqueId( idProp?: string ) {
const instanceId = useInstanceId( InputBase );
Expand Down Expand Up @@ -63,7 +62,6 @@ function InputBase(
ref: ForwardedRef< HTMLDivElement >
) {
const {
__next40pxDefaultSize,
__unstableInputWidth,
children,
className,
Expand All @@ -77,19 +75,17 @@ function InputBase(
size = 'default',
suffix,
...restProps
} = useDeprecated36pxDefaultSizeProp(
useContextSystem( props, 'InputBase' )
);
} = useContextSystem( props, 'InputBase' );

const id = useUniqueId( idProp );
const hideLabel = hideLabelFromVision || ! label;

const prefixSuffixContextValue = useMemo( () => {
return {
InputControlPrefixWrapper: { __next40pxDefaultSize, size },
InputControlSuffixWrapper: { __next40pxDefaultSize, size },
InputControlPrefixWrapper: { size },
InputControlSuffixWrapper: { size },
};
}, [ __next40pxDefaultSize, size ] );
}, [ size ] );

return (
// @ts-expect-error The `direction` prop from Flex (FlexDirection) conflicts with legacy SVGAttributes `direction` (string) that come from React intrinsic prop definitions.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,13 @@ const meta: Meta< typeof InputControl > = {
export default meta;

const Template: StoryFn< typeof InputControl > = ( args ) => (
<InputControl __next40pxDefaultSize { ...args } />
<InputControl { ...args } />
);

export const Default = Template.bind( {} );
Default.args = {
label: 'Value',
placeholder: 'Placeholder',
__next40pxDefaultSize: true,
};

export const WithHelpText = Template.bind( {} );
Expand Down Expand Up @@ -128,7 +127,6 @@ export const ShowPassword: StoryFn< typeof InputControl > = ( args ) => {
const [ visible, setVisible ] = useState( false );
return (
<InputControl
__next40pxDefaultSize
type={ visible ? 'text' : 'password' }
suffix={
<InputControlSuffixWrapper variant="control">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ export const Container = styled.div< ContainerProps >`
`;

type InputProps = {
__next40pxDefaultSize?: boolean;
disabled?: boolean;
inputSize?: Size;
isDragging?: boolean;
Expand Down Expand Up @@ -177,10 +176,7 @@ export const fontSizeStyles = ( { inputSize: size }: InputProps ) => {
`;
};

export const getSizeConfig = ( {
inputSize: size,
__next40pxDefaultSize,
}: InputProps ) => {
export const getSizeConfig = ( { inputSize: size }: InputProps ) => {
// Paddings may be overridden by the custom paddings props.
const sizes = {
default: {
Expand Down Expand Up @@ -213,10 +209,6 @@ export const getSizeConfig = ( {
},
};

if ( ! __next40pxDefaultSize ) {
sizes.default = sizes.compact;
}

return sizes[ size as Size ] || sizes.default;
};

Expand Down Expand Up @@ -332,12 +324,10 @@ export const LabelWrapper = styled( FlexItem )`
const prefixSuffixWrapperStyles = ( {
variant = 'default',
size,
__next40pxDefaultSize,
isPrefix,
}: PrefixSuffixWrapperProps & { isPrefix?: boolean } ) => {
const { paddingLeft: padding } = getSizeConfig( {
inputSize: size,
__next40pxDefaultSize,
} );

const paddingProperty = isPrefix
Expand Down
8 changes: 1 addition & 7 deletions packages/components/src/input-control/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,7 @@ const getInput = () => screen.getByTestId( 'input' );

describe( 'InputControl', () => {
const InputControl = ( props ) => {
return (
<BaseInputControl
{ ...props }
__next40pxDefaultSize
data-testid="input"
/>
);
return <BaseInputControl { ...props } data-testid="input" />;
};

describe( 'Basic rendering', () => {
Expand Down
50 changes: 21 additions & 29 deletions packages/components/src/input-control/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,6 @@ export type DragProps = Parameters< Parameters< typeof useDrag >[ 0 ] >[ 0 ];
export type Size = 'default' | 'small' | 'compact' | '__unstable-large';

interface BaseProps {
/**
* Deprecated. Use `__next40pxDefaultSize` instead.
*
* @default false
* @deprecated
* @ignore
*/
__next36pxDefaultSize?: boolean;
/**
* Start opting into the larger default height that will become the default size in a future version.
*
* @default false
*/
__next40pxDefaultSize?: boolean;
/**
* Do not throw a warning for the deprecated 36px default size.
* For internal components of other components that already throw the warning.
*
* @ignore
*/
__shouldNotWarnDeprecated36pxSize?: boolean;
__unstableInputWidth?: CSSProperties[ 'width' ];
/**
* If true, the label will only be visible to screen readers.
Expand All @@ -73,8 +52,7 @@ export type InputChangeCallback< P = {} > = (
extra: { event: SyntheticEvent } & P
) => void;

export interface InputFieldProps
extends Omit< BaseProps, '__next36pxDefaultSize' > {
export interface InputFieldProps extends BaseProps {
/**
* Determines the drag axis.
*
Expand Down Expand Up @@ -208,6 +186,26 @@ export interface InputControlProps
| 'paddingInlineStart'
| 'paddingInlineEnd'
> {
/**
* Deprecated. Use `__next40pxDefaultSize` instead.
*
* @default false
* @deprecated
* @ignore
*/
__next36pxDefaultSize?: boolean;
/**
* @deprecated Default behavior since WordPress 7.1. Prop can be safely removed.
* @ignore
*/
__next40pxDefaultSize?: boolean;
/**
* Do not throw a warning for the deprecated 36px default size.
* For internal components of other components that already throw the warning.
*
* @ignore
*/
__shouldNotWarnDeprecated36pxSize?: boolean;
__unstableStateReducer?: InputFieldProps[ 'stateReducer' ];
}

Expand All @@ -229,12 +227,6 @@ export type PrefixSuffixWrapperProps = {
* @ignore
*/
size?: BaseProps[ 'size' ];
/**
* Internal prop used to control the padding size of the wrapper.
*
* @ignore
*/
__next40pxDefaultSize?: BaseProps[ '__next40pxDefaultSize' ];
/**
* Adjust the wrapper based on the prefix or suffix content.
*
Expand Down
5 changes: 1 addition & 4 deletions packages/components/src/modal/stories/index.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,7 @@ const Template: StoryFn< typeof Modal > = ( { onRequestClose, ...args } ) => {
anim id est laborum.
</p>

<InputControl
__next40pxDefaultSize
style={ { marginBottom: '20px' } }
/>
<InputControl style={ { marginBottom: '20px' } } />

<Button
__next40pxDefaultSize
Expand Down
1 change: 0 additions & 1 deletion packages/components/src/number-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ function UnforwardedNumberControl(
value={ valueProp }
__unstableStateReducer={ numberControlStateReducer }
size={ size }
__next40pxDefaultSize
suffix={
spinControls === 'custom' ? (
<>
Expand Down
Loading
Loading