// // Copyright 2023 DXOS.org // import { Primitive } from '@radix-ui/react-primitive'; import { Slot } from '@radix-ui/react-slot'; import type { ToggleGroupItemProps as ToggleGroupItemPrimitiveProps } from '@radix-ui/react-toggle-group'; import * as ToolbarPrimitive from '@radix-ui/react-toolbar'; import React, { type MouseEventHandler, forwardRef } from 'react'; import { useTranslation } from 'react-i18next'; import { type SlottableProps } from '@dxos/ui-types'; import { translationKey } from '#translations'; import { useThemeContext } from '../../hooks'; import { type ToolbarStyleProps } from '../../theme'; import { composable, composableProps, slottable } from '../../util'; import { Button, ButtonGroup, type ButtonGroupProps, type ButtonProps, IconButton, type IconButtonProps, Toggle, type ToggleGroupItemProps, type ToggleProps, } from '../Button'; import { Link, type LinkProps } from '../Link'; import { DropdownMenu } from '../Menu'; import { Separator, type SeparatorProps } from '../Separator'; // // Root // type ToolbarRootProps = ToolbarPrimitive.ToolbarProps & ToolbarStyleProps; const ToolbarRoot = composable( ({ children, density, disabled, layoutManaged, orientation, ...props }, forwardedRef) => { const { className, role, ...rest } = composableProps(props); const { tx } = useThemeContext(); return ( {children} ); }, ); ToolbarRoot.displayName = 'Toolbar.Root'; // // Text // type ToolbarTextProps = SlottableProps; const ToolbarText = slottable(({ children, asChild, ...props }, forwardedRef) => { const { className, ...rest } = composableProps(props); const Comp = asChild ? Slot : Primitive.div; const { tx } = useThemeContext(); return ( {children} ); }); ToolbarText.displayName = 'Toolbar.Text'; // // Button // type ToolbarButtonProps = ButtonProps; const ToolbarButton = forwardRef((props, forwardedRef) => { return (