Skip to content

Commit

Permalink
Remove useDeprecatedProps hook and update adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
brookewp committed Jan 17, 2024
1 parent a95b279 commit 559e758
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 107 deletions.
2 changes: 1 addition & 1 deletion packages/components/src/custom-select-control-v2/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Internal dependencies
*/
export { LegacyAdapter as CustomSelect } from './legacy-adapter';
export { DefaultExport as CustomSelect } from './legacy-adapter';
export { default as CustomSelectItem } from './custom-select-item';
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
/**
* Internal dependencies
*/
import CustomSelect from './custom-select';
import type { LegacyCustomSelectProps } from './types';
import { useDeprecatedProps } from './use-deprecated-props';
import _LegacyCustomSelect from './legacy-component';
import _NewCustomSelect from './default-component';
import type { CustomSelectProps, LegacyCustomSelectProps } from './types';

export function LegacyAdapter( props: LegacyCustomSelectProps ) {
function isLegacy( props: any ): props is LegacyCustomSelectProps {
return (
<CustomSelect
{ ...useDeprecatedProps( props ) }
hideLabelFromVision={ props.hideLabelFromVision }
/>
typeof props.options !== 'undefined' ||
props.__experimentalShowSelectedHint !== undefined
);
}

export function DefaultExport(
props: LegacyCustomSelectProps | CustomSelectProps
) {
if ( isLegacy( props ) ) {
return <_LegacyCustomSelect { ...props } />;
}

return <_NewCustomSelect { ...props } />;
}
4 changes: 2 additions & 2 deletions packages/components/src/custom-select-control-v2/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import type * as Ariakit from '@ariakit/react';
/**
* Internal dependencies
*/
import type { useDeprecatedProps } from './use-deprecated-props';

export type LegacyAdapterProps = Parameters< typeof useDeprecatedProps >[ 0 ];
export type CustomSelectStore = {
/**
* The store object returned by Ariakit's `useSelectStore` hook.
Expand Down Expand Up @@ -75,6 +73,8 @@ type Option = {
*/
type OnChangeObject = {
selectedItem: Option;
highlightedIndex?: number;
isOpen?: boolean;
};

export type LegacyCustomSelectProps = {
Expand Down

This file was deleted.

0 comments on commit 559e758

Please sign in to comment.