@octopusdeploy/design-system-components
Version:
The design systems component library.
74 lines (73 loc) • 3.21 kB
TypeScript
import React from "react";
import type { DesignSystemLinkHref } from "../../routing/OctopusRoutingContext";
import type { MenuTargetAriaAttributes } from "../Menu";
import type { SimpleMenuItem } from "../MenuItems";
export interface PageActionsProps {
primaryAction?: PrimaryPageAction;
actions?: PageAction[];
overflowActions?: SimpleMenuItem[];
}
export declare function PageActions({ primaryAction, actions, overflowActions }: PageActionsProps): import("react/jsx-runtime").JSX.Element | null;
export declare function toInternalPrimaryPageAction(action: PrimaryPageAction): InternalPageAction;
export declare function toInternalPageAction(action: PageAction): InternalPageAction;
interface SharedPageActionProps {
hasPermissions?: boolean;
}
type RestrictButtonType<T extends {
buttonType: unknown;
}, K extends T["buttonType"]> = Omit<T, "buttonType"> & {
buttonType: K;
};
type ExcludeButtonType<T> = T extends {
buttonType: unknown;
} ? Omit<T, "buttonType"> : T;
type ConsumerAllowedNavigationButtonTypes = "secondary" | "tertiary" | "loud";
type InternalAllowedNavigationButtonTypes = "primary" | ConsumerAllowedNavigationButtonTypes;
interface InternalNavigatePageAction extends SharedPageActionProps {
type: "navigate";
label: string;
path: DesignSystemLinkHref;
onClick?: () => void;
disabled?: boolean;
titleAltText?: string;
accessibleName?: string;
buttonType: InternalAllowedNavigationButtonTypes;
external?: boolean;
icon?: JSX.Element;
isDownload?: boolean;
}
type NavigatePageAction = RestrictButtonType<InternalNavigatePageAction, ConsumerAllowedNavigationButtonTypes>;
type ConsumerAllowedButtonTypes = "secondary" | "tertiary" | "destructive";
type InternalAllowedButtonTypes = ConsumerAllowedButtonTypes | "primary";
interface InternalButtonPageAction extends SharedPageActionProps {
type: "button";
label: string;
formId?: string;
accessibleName?: string;
disabled?: boolean;
onClick: (event: React.MouseEvent | undefined) => Promise<unknown> | void;
menuButtonAttributes?: MenuTargetAriaAttributes;
buttonType: InternalAllowedButtonTypes;
busyLabel?: string;
icon?: JSX.Element;
}
type ButtonPageAction = RestrictButtonType<InternalButtonPageAction, ConsumerAllowedButtonTypes>;
interface ExtraContextForPageAction {
extraContext?: string;
}
interface InternalCustomPageAction extends SharedPageActionProps {
type: "custom";
key: string;
content: React.ReactNode;
}
type CustomPageAction = InternalCustomPageAction;
type AllPageActions = NavigatePageAction | ButtonPageAction | CustomPageAction;
export type PageAction = AllPageActions & ExtraContextForPageAction;
type AllInternalPageActions = InternalNavigatePageAction | InternalButtonPageAction | InternalCustomPageAction;
type InternalPageAction = AllInternalPageActions & ExtraContextForPageAction;
export type PrimaryPageAction = ExcludeButtonType<AllInternalPageActions> & ExtraContextForPageAction;
interface PageActionComponentProps {
item: InternalPageAction;
}
export declare function PageActionComponent({ item }: PageActionComponentProps): import("react/jsx-runtime").JSX.Element;
export {};