@primer/react
Version:
An implementation of GitHub's Primer Design System using React
76 lines (75 loc) • 2.81 kB
TypeScript
import { FCWithSlotMarker } from "../utils/types/Slots.js";
import { DistributiveOmit } from "../utils/modern-polymorphic.js";
import React from "react";
import { Icon } from "@primer/octicons-react";
//#region src/TreeView/TreeView.d.ts
type TreeViewProps = {
'aria-label'?: React.AriaAttributes['aria-label'];
'aria-labelledby'?: React.AriaAttributes['aria-labelledby'];
children: React.ReactNode;
flat?: boolean;
truncate?: boolean;
className?: string;
style?: React.CSSProperties;
};
type TreeViewSecondaryActions = {
label: string;
onClick: () => void;
icon: Icon;
count?: number | string;
className?: string;
};
type TreeViewItemBaseProps = {
'aria-label'?: React.AriaAttributes['aria-label'];
'aria-labelledby'?: React.AriaAttributes['aria-labelledby'];
id: string;
children: React.ReactNode;
containIntrinsicSize?: string;
current?: boolean;
defaultExpanded?: boolean;
expanded?: boolean | null;
onExpandedChange?: (expanded: boolean) => void;
onSelect?: (event: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>) => void;
className?: string;
secondaryActions?: TreeViewSecondaryActions[];
};
type TreeViewItemProps<As extends React.ElementType = 'li'> = DistributiveOmit<React.ComponentPropsWithoutRef<React.ElementType extends As ? 'li' : As>, 'as' | 'onSelect'> & TreeViewItemBaseProps & {
as?: As;
};
type SubTreeState = 'initial' | 'loading' | 'done' | 'error';
type TreeViewSubTreeProps = {
children?: React.ReactNode;
state?: SubTreeState;
/**
* Display a skeleton loading state with the specified count of items
*/
count?: number;
'aria-label'?: string;
};
type TreeViewVisualProps = {
children: React.ReactNode | ((props: {
isExpanded: boolean;
}) => React.ReactNode);
label?: string;
};
type TreeViewErrorDialogProps = {
children: React.ReactNode;
title?: string;
onRetry?: () => void;
onDismiss?: () => void;
};
declare const TreeView: React.FC<TreeViewProps> & {
Item: (<As extends React.ElementType = "li">(props: DistributiveOmit<React.PropsWithoutRef<React.ComponentProps<React.ElementType<any, keyof React.JSX.IntrinsicElements> extends As ? "li" : As>>, "as" | "onSelect"> & TreeViewItemBaseProps & {
as?: As | undefined;
} & React.RefAttributes<unknown>) => React.ReactNode) & {
displayName: string;
};
SubTree: FCWithSlotMarker<TreeViewSubTreeProps>;
LeadingAction: React.FC<TreeViewVisualProps>;
LeadingVisual: React.FC<TreeViewVisualProps>;
TrailingVisual: React.FC<TreeViewVisualProps>;
DirectoryIcon: () => React.JSX.Element;
ErrorDialog: React.FC<TreeViewErrorDialogProps>;
};
//#endregion
export { SubTreeState, TreeView, TreeViewErrorDialogProps, TreeViewItemProps, TreeViewProps, TreeViewSecondaryActions, TreeViewSubTreeProps, TreeViewVisualProps };