Skip to content

Commit

Permalink
Components: Remove deprecation warnings for __next36pxDefaultSize (#…
Browse files Browse the repository at this point in the history
…58703)

* Components: Remove deprecation warnings for `__next36pxDefaultSize`

* Update changelog

Co-authored-by: mirka <[email protected]>
Co-authored-by: ciampo <[email protected]>
Co-authored-by: tyxla <[email protected]>
Co-authored-by: swissspidy <[email protected]>
Co-authored-by: aaronjorbin <[email protected]>
Co-authored-by: costdev <[email protected]>
Co-authored-by: richtabor <[email protected]>
Co-authored-by: peterwilsoncc <[email protected]>
  • Loading branch information
9 people authored Feb 7, 2024
1 parent bc3f367 commit 9bb75b3
Show file tree
Hide file tree
Showing 11 changed files with 12 additions and 60 deletions.
3 changes: 2 additions & 1 deletion packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
- `Button`: Update secondary variant to show the border even in a disabled state. ([#58606](https://github.com/WordPress/gutenberg/pull/58606)).
- `ConfirmDialog`: Add `__next40pxDefaultSize` to buttons ([#58421](https://github.com/WordPress/gutenberg/pull/58421)).
- `Snackbar`: Update the warning message ([#58591](https://github.com/WordPress/gutenberg/pull/58591)).
- `Composite`: Implementing `useCompositeState` with Ariakit ([#57304](https://github.com/WordPress/gutenberg/pull/57304))
- `Composite`: Implementing `useCompositeState` with Ariakit ([#57304](https://github.com/WordPress/gutenberg/pull/57304)).
- Remove deprecation warnings for `__next36pxDefaultSize` prop ([#58703](https://github.com/WordPress/gutenberg/pull/58703)).
- `CheckboxControl`: Remove ability for label prop to be false ([#58339](https://github.com/WordPress/gutenberg/pull/58339)).

### Bug Fix
Expand Down
5 changes: 1 addition & 4 deletions packages/components/src/combobox-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,7 @@ function ComboboxControl( props: ComboboxControlProps ) {
selected: __( 'Item selected.' ),
},
__experimentalRenderItem,
} = useDeprecated36pxDefaultSizeProp< ComboboxControlProps >(
props,
'wp.components.ComboboxControl'
);
} = useDeprecated36pxDefaultSizeProp( props );

const [ value, setValue ] = useControlledValue( {
value: valueProp,
Expand Down
6 changes: 1 addition & 5 deletions packages/components/src/custom-select-control/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,7 @@ export default function CustomSelectControl( props ) {
onFocus,
onBlur,
__experimentalShowSelectedHint = false,
} = useDeprecated36pxDefaultSizeProp(
props,
'wp.components.CustomSelectControl',
'6.4'
);
} = useDeprecated36pxDefaultSizeProp( props );

const {
getLabelProps,
Expand Down
5 changes: 1 addition & 4 deletions packages/components/src/form-token-field/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,7 @@ export function FormTokenField( props: FormTokenFieldProps ) {
__experimentalAutoSelectFirstMatch = false,
__nextHasNoMarginBottom = false,
tokenizeOnBlur = false,
} = useDeprecated36pxDefaultSizeProp< FormTokenFieldProps >(
props,
'wp.components.FormTokenField'
);
} = useDeprecated36pxDefaultSizeProp< FormTokenFieldProps >( props );

const instanceId = useInstanceId( FormTokenField );

Expand Down
6 changes: 1 addition & 5 deletions packages/components/src/input-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,7 @@ export function UnforwardedInputControl(
suffix,
value,
...restProps
} = useDeprecated36pxDefaultSizeProp< InputControlProps >(
props,
'wp.components.InputControl',
'6.4'
);
} = useDeprecated36pxDefaultSizeProp< InputControlProps >( props );

const [ isFocused, setIsFocused ] = useState( false );

Expand Down
4 changes: 1 addition & 3 deletions packages/components/src/input-control/input-base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,7 @@ export function InputBase(
suffix,
...restProps
} = useDeprecated36pxDefaultSizeProp(
useContextSystem( props, 'InputBase' ),
'wp.components.InputBase',
'6.4'
useContextSystem( props, 'InputBase' )
);

const id = useUniqueId( idProp );
Expand Down
6 changes: 1 addition & 5 deletions packages/components/src/number-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,7 @@ function UnforwardedNumberControl(
suffix,
onChange = noop,
...restProps
} = useDeprecated36pxDefaultSizeProp< NumberControlProps >(
props,
'wp.components.NumberControl',
'6.4'
);
} = useDeprecated36pxDefaultSizeProp< NumberControlProps >( props );

if ( hideHTMLArrows ) {
deprecated( 'wp.components.NumberControl hideHTMLArrows prop ', {
Expand Down
6 changes: 1 addition & 5 deletions packages/components/src/select-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,7 @@ function UnforwardedSelectControl(
__next40pxDefaultSize = false,
__nextHasNoMarginBottom = false,
...restProps
} = useDeprecated36pxDefaultSizeProp(
props,
'wp.components.SelectControl',
'6.4'
);
} = useDeprecated36pxDefaultSizeProp( props );
const [ isFocused, setIsFocused ] = useState( false );
const id = useUniqueId( idProp );
const helpId = help ? `${ id }__help` : undefined;
Expand Down
6 changes: 1 addition & 5 deletions packages/components/src/tree-select/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,7 @@ export function TreeSelect( props: TreeSelectProps ) {
selectedId,
tree = [],
...restProps
} = useDeprecated36pxDefaultSizeProp(
props,
'wp.components.TreeSelect',
'6.4'
);
} = useDeprecated36pxDefaultSizeProp( props );

const options = useMemo( () => {
return [
Expand Down
6 changes: 1 addition & 5 deletions packages/components/src/unit-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,7 @@ function UnforwardedUnitControl(
value: valueProp,
onFocus: onFocusProp,
...props
} = useDeprecated36pxDefaultSizeProp(
unitControlProps,
'wp.components.UnitControl',
'6.4'
);
} = useDeprecated36pxDefaultSizeProp( unitControlProps );

if ( 'unit' in unitControlProps ) {
deprecated( 'UnitControl unit prop', {
Expand Down
19 changes: 1 addition & 18 deletions packages/components/src/utils/use-deprecated-props.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,11 @@
/**
* WordPress dependencies
*/
import deprecated from '@wordpress/deprecated';

export function useDeprecated36pxDefaultSizeProp<
P extends Record< string, any > & {
__next36pxDefaultSize?: boolean;
__next40pxDefaultSize?: boolean;
},
>(
props: P,
/** The component identifier in dot notation, e.g. `wp.components.ComponentName`. */
componentIdentifier: string,
/** Version in which the prop was deprecated. */
since: string = '6.3'
) {
>( props: P ) {
const { __next36pxDefaultSize, __next40pxDefaultSize, ...otherProps } =
props;
if ( typeof __next36pxDefaultSize !== 'undefined' ) {
deprecated( '`__next36pxDefaultSize` prop in ' + componentIdentifier, {
alternative: '`__next40pxDefaultSize`',
since,
} );
}

return {
...otherProps,
Expand Down

0 comments on commit 9bb75b3

Please sign in to comment.