UNPKG

@gechiui/block-editor

Version:
49 lines (42 loc) 1.3 kB
import _extends from "@babel/runtime/helpers/esm/extends"; import { createElement } from "@gechiui/element"; /** * GeChiUI dependencies */ import { Button, __unstableCompositeItem as CompositeItem } from '@gechiui/components'; import { forwardRef, useContext } from '@gechiui/element'; /** * Internal dependencies */ import InserterListboxContext from './context'; function InserterListboxItem(_ref, ref) { let { isFirst, as: Component, children, ...props } = _ref; const state = useContext(InserterListboxContext); return createElement(CompositeItem, _extends({ ref: ref, state: state, role: "option" // Use the CompositeItem `focusable` prop over Button's // isFocusable. The latter was shown to cause an issue // with tab order in the inserter list. , focusable: true }, props), htmlProps => { const propsWithTabIndex = { ...htmlProps, tabIndex: isFirst ? 0 : htmlProps.tabIndex }; if (Component) { return createElement(Component, propsWithTabIndex, children); } if (typeof children === 'function') { return children(propsWithTabIndex); } return createElement(Button, propsWithTabIndex, children); }); } export default forwardRef(InserterListboxItem); //# sourceMappingURL=item.js.map