-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove useDeprecatedProps hook and update adapter
- Loading branch information
Showing
4 changed files
with
19 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; |
24 changes: 16 additions & 8 deletions
24
packages/components/src/custom-select-control-v2/legacy-adapter.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 } />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 0 additions & 96 deletions
96
packages/components/src/custom-select-control-v2/use-deprecated-props.tsx
This file was deleted.
Oops, something went wrong.