woocommerce-paypal-payments/modules/ppcp-settings/resources/js/Components/ReusableComponents/SettingsBlocks/InputSettingsBlock.js
2025-01-21 18:57:36 +01:00

42 lines
1 KiB
JavaScript

import { TextControl } from '@wordpress/components';
import SettingsBlock from '../SettingsBlock';
import { Title, Action, Description, SupplementaryLabel } from '../Elements';
const InputSettingsBlock = ( {
title,
description,
supplementaryLabel,
showDescriptionFirst = false,
actionProps = {},
...props
} ) => {
const TheDescription = <Description>{ description }</Description>;
return (
<SettingsBlock { ...props } className="ppcp-r-settings-block__input">
<Title>
{ title }
{ supplementaryLabel && (
<SupplementaryLabel>
{ supplementaryLabel }
</SupplementaryLabel>
) }
</Title>
{ showDescriptionFirst && TheDescription }
<Action>
<TextControl
className="ppcp-r-vertical-text-control"
placeholder={ actionProps.placeholder }
value={ actionProps.value }
onChange={ ( newValue ) =>
actionProps.callback( actionProps.key, newValue )
}
/>
</Action>
{ ! showDescriptionFirst && TheDescription }
</SettingsBlock>
);
};
export default InputSettingsBlock;