UNPKG

@wordpress/block-editor

Version:
69 lines (64 loc) 2.17 kB
import { createElement, Fragment } from "@wordpress/element"; /** * External dependencies */ import classnames from 'classnames'; /** * WordPress dependencies */ import { Button, VisuallyHidden } from '@wordpress/components'; import { useInstanceId } from '@wordpress/compose'; import { forwardRef } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; /** * Internal dependencies */ import BlockIcon from '../block-icon'; import Indentation from './indentation'; import useBlockDisplayInformation from '../use-block-display-information'; import { getBlockPositionDescription } from './utils'; import BlockTitle from '../block-title'; function BlockNavigationBlockSelectButton({ className, block: { clientId }, isSelected, onClick, position, siblingBlockCount, level, tabIndex, onFocus, onDragStart, onDragEnd, draggable }, ref) { const blockInformation = useBlockDisplayInformation(clientId); const instanceId = useInstanceId(BlockNavigationBlockSelectButton); const descriptionId = `block-navigation-block-select-button__${instanceId}`; const blockPositionDescription = getBlockPositionDescription(position, siblingBlockCount, level); return createElement(Fragment, null, createElement(Button, { className: classnames('block-editor-block-navigation-block-select-button', className), onClick: onClick, "aria-describedby": descriptionId, ref: ref, tabIndex: tabIndex, onFocus: onFocus, onDragStart: onDragStart, onDragEnd: onDragEnd, draggable: draggable }, createElement(Indentation, { level: level }), createElement(BlockIcon, { icon: blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.icon, showColors: true }), createElement(BlockTitle, { clientId: clientId }), isSelected && createElement(VisuallyHidden, null, __('(selected block)'))), createElement("div", { className: "block-editor-block-navigation-block-select-button__description", id: descriptionId }, blockPositionDescription)); } export default forwardRef(BlockNavigationBlockSelectButton); //# sourceMappingURL=block-select-button.js.map