UNPKG

@primer/react

Version:

An implementation of GitHub's Primer Design System using React

121 lines • 6.58 kB
import { AriaRole } from "../utils/types/AriaRole.js"; import { FCWithSlotMarker, SlotMarker, WithSlotMarker } from "../utils/types/Slots.js"; import { ForwardRefComponent } from "../utils/polymorphic.js"; import { DistributiveOmit, PolymorphicProps } from "../utils/modern-polymorphic.js"; import { ActionListTrailingActionProps } from "./TrailingAction.js"; import { ActionListGroupHeadingTrailingActionProps } from "./GroupHeadingTrailingAction.js"; import { ActionListItemProps, ActionListProps } from "./shared.js"; import { ActionListHeadingProps } from "./Heading.js"; import { ActionListGroupHeadingProps, ActionListGroupProps } from "./Group.js"; import { ActionListDividerProps } from "./Divider.js"; import { ActionListDescriptionProps } from "./Description.js"; import { ActionListLeadingVisualProps, ActionListTrailingVisualProps, VisualProps } from "./Visuals.js"; import { ActionListLinkItemProps } from "./LinkItem.js"; //#region src/ActionList/index.d.ts /** * Collection of list-related components. */ declare const ActionList: (<As extends React.ElementType = "ul">(props: DistributiveOmit<import("react").ComponentPropsWithRef<import("react").ElementType extends As ? "ul" : As> & { variant?: "inset" | "horizontal-inset" | "full"; selectionVariant?: "single" | "radio" | "multiple"; showDividers?: boolean; role?: AriaRole; disableFocusZone?: boolean; className?: string; } & { children?: import("react").ReactNode | undefined; }, "as"> & { as?: As | undefined; } & import("react").RefAttributes<unknown>) => React.ReactNode) & { /** Context for the `ActionList` container. */ContainerContext: import("react").Context<{ container?: string; listRole?: AriaRole; selectionVariant?: "single" | "multiple" | "radio"; selectionAttribute?: "aria-selected" | "aria-checked"; listLabelledBy?: string; afterSelect?: Function; enableFocusZone?: boolean; defaultTrailingVisual?: React.ReactElement<any>; }>; /** Collects related `Items` in an `ActionList`. */ Group: FCWithSlotMarker<import("react").PropsWithChildren<ActionListGroupProps>>; /** An actionable or selectable `Item` */ Item: (<As extends React.ElementType = "li">(props: (PolymorphicProps<As, "li"> extends infer T ? T extends PolymorphicProps<As, "li"> ? T extends any ? Omit<T, "onSelect"> : never : never : never) & { children?: React.ReactNode; onSelect?: (event: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>) => void; selected?: boolean; active?: boolean; variant?: "default" | "danger"; size?: "medium" | "large"; disabled?: boolean; role?: AriaRole; id?: string; inactiveText?: string; loading?: boolean; _PrivateItemWrapper?: React.FC<React.PropsWithChildren<{ onClick?: (event: React.MouseEvent<HTMLElement>) => void; onKeyPress?: (event: React.KeyboardEvent<HTMLElement>) => void; 'aria-disabled'?: boolean; tabIndex?: number; 'aria-labelledby'?: string; 'aria-describedby'?: string; role?: string; className?: string; }>>; className?: string; groupId?: string; renderItem?: (item: React.FC<React.PropsWithChildren<{ onClick?: (event: React.MouseEvent<HTMLElement>) => void; onKeyPress?: (event: React.KeyboardEvent<HTMLElement>) => void; 'aria-disabled'?: boolean; tabIndex?: number; 'aria-labelledby'?: string; 'aria-describedby'?: string; role?: string; className?: string; }>>) => React.ReactNode; handleAddItem?: (item: React.FC<React.PropsWithChildren<{ onClick?: (event: React.MouseEvent<HTMLElement>) => void; onKeyPress?: (event: React.KeyboardEvent<HTMLElement>) => void; 'aria-disabled'?: boolean; tabIndex?: number; 'aria-labelledby'?: string; 'aria-describedby'?: string; role?: string; className?: string; }>>) => void; as?: As | undefined; } & import("react").RefAttributes<any>) => React.ReactNode) & { displayName: string; __SLOT__: symbol; }; /** A `Item` that renders a full-size anchor inside ListItem */ LinkItem: WithSlotMarker<(<As extends React.ElementType = "a">(props: DistributiveOmit<import("react").ComponentPropsWithRef<import("react").ElementType extends As ? "a" : As> & Pick<ActionListItemProps, "active" | "children" | "inactiveText" | "size" | "variant"> & { download?: string; href?: string; hrefLang?: string; media?: string; ping?: string; rel?: string; target?: string; type?: string; referrerPolicy?: React.AnchorHTMLAttributes<HTMLAnchorElement>["referrerPolicy"]; className?: string; }, "as"> & { as?: As | undefined; } & import("react").RefAttributes<unknown>) => React.ReactNode)>; /** Visually separates `Item`s or `Group`s in an `ActionList`. */ Divider: FCWithSlotMarker<import("react").PropsWithChildren<ActionListDividerProps>>; /** Secondary text which provides additional information about an `Item`. */ Description: FCWithSlotMarker<import("react").PropsWithChildren<ActionListDescriptionProps>>; /** Icon (or similar) positioned before `Item` text. */ LeadingVisual: FCWithSlotMarker<import("react").PropsWithChildren<VisualProps>>; /** Icon (or similar) positioned after `Item` text. */ TrailingVisual: FCWithSlotMarker<import("react").PropsWithChildren<VisualProps>>; /** Heading for an `ActionList`. */ Heading: ForwardRefComponent<"h1" | "h2" | "h3" | "h4" | "h5" | "h6", ActionListHeadingProps>; /** Context for `ActionList.Group` to propagate selectionVariant and other group-level props. */ GroupContext: import("react").Context<Pick<ActionListGroupProps, "selectionVariant"> & { groupHeadingId: string | undefined; }>; /** Heading for `ActionList.Group` */ GroupHeading: import("react").FC<import("react").PropsWithChildren<ActionListGroupHeadingProps>> & SlotMarker & { TrailingAction: ForwardRefComponent<"a" | "button", ActionListGroupHeadingTrailingActionProps> & { __SLOT__?: SlotMarker; displayName?: string; }; }; /** Secondary action */ TrailingAction: ForwardRefComponent<"a" | "button", ActionListTrailingActionProps>; }; //#endregion export { ActionList, type ActionListDescriptionProps, type ActionListDividerProps, type ActionListGroupHeadingProps, type ActionListGroupHeadingTrailingActionProps, type ActionListGroupProps, type ActionListItemProps, type ActionListLeadingVisualProps, type ActionListLinkItemProps, type ActionListProps, type ActionListTrailingActionProps, type ActionListTrailingVisualProps };