UNPKG

@syncfusion/react-navigations

Version:

A package of Pure React navigation components such as Toolbar and Context-menu which is used to navigate from one page to another

34 lines (33 loc) 1.12 kB
import { jsx as _jsx } from "react/jsx-runtime"; import { forwardRef, useImperativeHandle, useRef, useMemo, memo } from 'react'; const CLS_ITEM = 'sf-toolbar-item'; /** * The ToolbarItem component allows for the rendering of individual items within a Toolbar. * * ```typescript * <Toolbar> * <ToolbarItem id='saveButton' className='action-button' style={{ backgroundColor: '#f0f0f0' }}> * <button type="button">Save</button> * </ToolbarItem> * </Toolbar> * ``` */ export const ToolbarItem = memo(forwardRef((props, ref) => { const { className = '', children, ...eleAttr } = props; const itemRef = useRef(null); const classes = useMemo(() => { const classes = [CLS_ITEM]; if (className) { classes.push(className); } return classes.join(' '); }, [className]); useImperativeHandle(ref, () => { return { element: itemRef.current }; }); return (_jsx("div", { ref: itemRef, className: classes, ...eleAttr, children: children })); })); ToolbarItem.displayName = 'ToolbarItem'; export default ToolbarItem;