How to use the @wordpress/compose.useInstanceId function in @wordpress/compose

To help you get started, we’ve selected a few @wordpress/compose examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github WordPress / gutenberg / packages / components / src / custom-gradient-picker / control-points.js View on Github external
function ControlPointButton( {
	isOpen,
	position,
	color,
	onChange,
	gradientIndex,
	gradientAST,
	...additionalProps
} ) {
	const instanceId = useInstanceId( ControlPointButton );
	const descriptionId = `components-custom-gradient-picker__control-point-button-description-${ instanceId }`;
	return (
github WordPress / gutenberg / packages / components / src / form-token-field / token.js View on Github external
export default function Token( {
	value,
	status,
	title,
	displayTransform,
	isBorderless = false,
	disabled = false,
	onClickRemove = noop,
	onMouseEnter,
	onMouseLeave,
	messages,
	termPosition,
	termsCount,
} ) {
	const instanceId = useInstanceId( Token );
	const tokenClasses = classnames( 'components-form-token-field__token', {
		'is-error': 'error' === status,
		'is-success': 'success' === status,
		'is-validating': 'validating' === status,
		'is-borderless': isBorderless,
		'is-disabled': disabled,
	} );

	const onClick = () => onClickRemove( { value } );

	const transformedValue = displayTransform( value );
	const termPositionAndCount = sprintf(
		/* translators: 1: term name, 2: term position in a set of terms, 3: total term set count. */
		__( '%1$s (%2$s of %3$s)' ),
		transformedValue,
		termPosition,
github GraphQLAPI / graphql-api-for-wp / packages / components / src / components / multi-select-control / show-all.js View on Github external
export default function BlockManagerShowAll( { checked, onChange } ) {
	const instanceId = useInstanceId( BlockManagerShowAll );
	const id = 'edit-post-manage-blocks-modal__show-all-' + instanceId;

	return (
		<div>
			<label id="">
				{ /* translators: Checkbox toggle label */
				__( 'Show section' ) }
			</label>
			 onChange( event.target.checked ) }
			/&gt;</div>
github WordPress / gutenberg / packages / components / src / select-control / index.js View on Github external
export default function SelectControl( {
	help,
	label,
	multiple = false,
	onChange,
	options = [],
	className,
	hideLabelFromVision,
	...props
} ) {
	const instanceId = useInstanceId( SelectControl );
	const id = `inspector-select-control-${ instanceId }`;
	const onChangeValue = ( event ) =&gt; {
		if ( multiple ) {
			const selectedOptions = [ ...event.target.options ].filter( ( { selected } ) =&gt; selected );
			const newValues = selectedOptions.map( ( { value } ) =&gt; value );
			onChange( newValues );
			return;
		}
		onChange( event.target.value );
	};

	// Disable reason: A select with an onchange throws a warning

	/* eslint-disable jsx-a11y/no-onchange */
	return ! isEmpty( options ) &amp;&amp; (
github WordPress / gutenberg / packages / components / src / font-size-picker / index.js View on Github external
export default function FontSizePicker( {
	fallbackFontSize,
	fontSizes = [],
	disableCustomFontSizes = false,
	onChange,
	value,
	withSlider = false,
} ) {
	const instanceId = useInstanceId( FontSizePicker );
	const [ currentSelectValue, setCurrentSelectValue ] = useState( getSelectValueFromFontSize( fontSizes, value ) );

	if ( disableCustomFontSizes && ! fontSizes.length ) {
		return null;
	}

	const setFontSize = ( fontSizeKey, fontSizeValue ) => {
		setCurrentSelectValue( fontSizeKey );

		if ( fontSizeKey === DEFAULT_FONT_SIZE ) {
			onChange( undefined );
			return;
		}

		if ( ! fontSizeValue ) {
			return;
github WordPress / gutenberg / packages / block-editor / src / components / responsive-block-control / label.js View on Github external
export default function ResponsiveBlockControlLabel( { property, viewport, desc } ) {
	const instanceId = useInstanceId( ResponsiveBlockControlLabel );
	const accessibleLabel = desc || sprintf( _x( 'Controls the %1$s property for %2$s viewports.', 'Text labelling a interface as controlling a given layout property (eg: margin) for a given screen size.' ), property, viewport.label );
	return (
		
			<span aria-describedby="{">
				{ viewport.label }
			</span>
			<span id="{">{ accessibleLabel }</span>
		
	);
}
github WordPress / gutenberg / packages / components / src / textarea-control / index.js View on Github external
export default function TextareaControl( { label, hideLabelFromVision, value, help, onChange, rows = 4, className, ...props } ) {
	const instanceId = useInstanceId( TextareaControl );
	const id = `inspector-textarea-control-${ instanceId }`;
	const onChangeValue = ( event ) =&gt; onChange( event.target.value );

	return (
		
			<textarea value="{" aria-describedby="{" rows="{" id="{">		&lt;/BaseControl&gt;
	);</textarea>
github pods-framework / pods / ui / js / blocks / src / blocks / components / RenderedField.js View on Github external
key={ name }
					help={ help }
					options={ options }
					selected={ fieldValue }
					onChange={ changeHandler }
				/&gt;
			);
		}
		case 'SelectControl': {
			const {
				options,
				multiple,
				label,
			} = fieldOptions;

			const instanceId = useInstanceId( Select );
			const id = `inspector-select-control-${ instanceId }`;

			return (
github WordPress / gutenberg / packages / components / src / radio-control / index.js View on Github external
export default function RadioControl( { label, className, selected, help, onChange, options = [] } ) {
	const instanceId = useInstanceId( RadioControl );
	const id = `inspector-radio-control-${ instanceId }`;
	const onChangeValue = ( event ) =&gt; onChange( event.target.value );

	return ! isEmpty( options ) &amp;&amp; (
		
			{ options.map( ( option, index ) =&gt;
				<div id="">
					</div>
github WordPress / gutenberg / packages / components / src / menu-group / index.js View on Github external
export function MenuGroup( {
	children,
	className = '',
	label,
} ) {
	const instanceId = useInstanceId( MenuGroup );

	if ( ! Children.count( children ) ) {
		return null;
	}

	const labelId = `components-menu-group-label-${ instanceId }`;
	const classNames = classnames(
		className,
		'components-menu-group'
	);

	return (
		<div>
			{ label &amp;&amp;
				</div>