@primer/components
Version:
Primer react components
64 lines (63 loc) • 2.06 kB
TypeScript
import React from 'react';
import { ForwardRefComponent as PolymorphicForwardRefComponent } from '@radix-ui/react-polymorphic';
import { SxProp } from '../sx';
import { AriaRole } from '../utils/types';
export declare const getVariantStyles: (variant: ItemProps['variant'], disabled: ItemProps['disabled']) => {
color: string;
iconColor: string;
annotationColor: string;
hoverColor?: undefined;
} | {
color: string;
iconColor: string;
annotationColor: string;
hoverColor: string;
};
export declare type ItemProps = {
/**
* Primary content for an Item
*/
children?: React.ReactNode;
/**
* Callback that will trigger both on click selection and keyboard selection.
*/
onSelect?: (event: React.MouseEvent<HTMLLIElement> | React.KeyboardEvent<HTMLLIElement>) => void;
/**
* Is the `Item` is currently selected?
*/
selected?: boolean;
/**
* Style variations associated with various `Item` types.
*
* - `"default"` - An action `Item`.
* - `"danger"` - A destructive action `Item`.
*/
variant?: 'default' | 'danger';
/**
* Items that are disabled can not be clicked, selected, or navigated through.
*/
disabled?: boolean;
/**
* The ARIA role describing the function of `Item` component. `option` is a common value.
*/
role?: AriaRole;
/**
* id to attach to the root element of the Item
*/
id?: string;
/**
* Private API for use internally only. Used by LinkItem to wrap contents in an anchor
*/
_PrivateItemWrapper?: React.FC;
} & SxProp;
declare const Slot: React.FC<{
name: "LeadingVisual" | "InlineDescription" | "BlockDescription" | "TrailingVisual";
children: React.ReactNode;
}>;
export { Slot };
export declare type ItemContext = Pick<ItemProps, 'variant' | 'disabled'> & {
inlineDescriptionId: string;
blockDescriptionId: string;
};
export declare const TEXT_ROW_HEIGHT = "20px";
export declare const Item: PolymorphicForwardRefComponent<"li", ItemProps>;