@base-ui-components/react
Version:
Base UI is a library of headless ('unstyled') React components and low-level hooks. You gain complete control over your app's CSS and accessibility features.
51 lines (50 loc) • 1.69 kB
JavaScript
;
'use client';
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.ToolbarGroup = void 0;
var React = _interopRequireWildcard(require("react"));
var _useRenderElement = require("../../utils/useRenderElement");
var _ToolbarRootContext = require("../root/ToolbarRootContext");
var _ToolbarGroupContext = require("./ToolbarGroupContext");
var _jsxRuntime = require("react/jsx-runtime");
/**
* Groups several toolbar items or toggles.
* Renders a `<div>` element.
*
* Documentation: [Base UI Toolbar](https://base-ui.com/react/components/toolbar)
*/
const ToolbarGroup = exports.ToolbarGroup = /*#__PURE__*/React.forwardRef(function ToolbarGroup(componentProps, forwardedRef) {
const {
className,
disabled: disabledProp = false,
render,
...elementProps
} = componentProps;
const {
orientation,
disabled: toolbarDisabled
} = (0, _ToolbarRootContext.useToolbarRootContext)();
const disabled = toolbarDisabled || disabledProp;
const contextValue = React.useMemo(() => ({
disabled
}), [disabled]);
const state = React.useMemo(() => ({
disabled,
orientation
}), [disabled, orientation]);
const element = (0, _useRenderElement.useRenderElement)('div', componentProps, {
state,
ref: forwardedRef,
props: [{
role: 'group'
}, elementProps]
});
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ToolbarGroupContext.ToolbarGroupContext.Provider, {
value: contextValue,
children: element
});
});
if (process.env.NODE_ENV !== "production") ToolbarGroup.displayName = "ToolbarGroup";