/** * WordPress dependencies */ import { SelectControl } from '@safe-wordpress/components'; import { _x } from '@safe-wordpress/i18n'; /** * External dependencies */ import { PostSearcher } from '@nab/components'; import { isEmpty, isMultiArray, isSingleton } from '@nab/utils'; import type { PostSearcherProps } from '@nab/components'; import type { ExperimentEditProps, EntityKind, Maybe } from '@nab/types'; /** * Internal dependencies */ import './style.scss'; import { usePostTypes } from '../../../post/hooks'; import type { ControlAttributes } from '../../types'; type Attributes< T extends string > = { [ K in keyof ControlAttributes ]: K extends 'postType' ? T : ControlAttributes[ K ]; }; export type OriginalProps< T extends string > = ExperimentEditProps< Attributes< T > > & { readonly disableExistingContentSelect?: boolean; readonly disableRunAsInlineTestSelect?: boolean; readonly validPostFilter?: PostSearcherProps[ 'filter' ]; }; export const Original = < T extends string >( { attributes, setAttributes, validPostFilter, experimentType, }: OriginalProps< T > ): JSX.Element => { const { postTypes, showSinglePostType, isLoadingPostTypes } = usePostTypes( experimentType ); const defaultPostType = postTypes[ 0 ]?.name; const postType = attributes.postType || defaultPostType; const selectablePostTypes = postTypes.map( ( type ) => ( { value: type.name, label: type.labels.singular_name, } ) ); return (