@hackplan/polaris
Version:
Shopify’s product component library
51 lines (50 loc) • 2.55 kB
TypeScript
/// <reference types="hoist-non-react-statics" />
import React from 'react';
import { DisableableAction } from '../../types';
import { Props as AvatarProps } from '../Avatar';
import { Props as ThumbnailProps } from '../Thumbnail';
import { WithAppProviderProps } from '../../utilities/with-app-provider';
import { ResourceListContext } from '../../utilities/resource-list';
export declare type ExceptionStatus = 'neutral' | 'warning' | 'critical';
export declare type MediaSize = 'small' | 'medium' | 'large';
export declare type MediaType = 'avatar' | 'thumbnail';
interface WithContextTypes<IJ> {
context: IJ;
}
export interface Props {
/** Visually hidden text for screen readers */
accessibilityLabel?: string;
/** Id of the element the item onClick controls */
ariaControls?: string;
/** Tells screen reader the controlled element is expanded */
ariaExpanded?: boolean;
/** Unique identifier for the item */
id: string;
/** Content for the media area at the left of the item, usually an Avatar or Thumbnail */
media?: React.ReactElement<AvatarProps | ThumbnailProps>;
/** Makes the shortcut actions always visible */
persistActions?: boolean;
/** 1 or 2 shortcut actions; must be available on the page linked to by url */
shortcutActions?: DisableableAction[];
/** The order the item is rendered */
sortOrder?: number;
/** URL for the resource’s details page (required unless onClick is provided) */
url?: string;
/** Callback when clicked (required if url is omitted) */
onClick?(id?: string): void;
/** Content for the details area */
children?: React.ReactNode;
}
export interface PropsWithUrl extends Props {
url: string;
onClick?(id?: string): void;
}
export interface PropsWithClick extends Props {
url?: string;
onClick(id?: string): void;
}
export declare type ConditionalProps = PropsWithUrl | PropsWithClick;
export declare type CombinedProps = (PropsWithUrl & WithAppProviderProps & WithContextTypes<React.ContextType<typeof ResourceListContext>>) | (PropsWithClick & WithAppProviderProps & WithContextTypes<React.ContextType<typeof ResourceListContext>>);
declare function ResourceItem(props: CombinedProps): JSX.Element;
declare const _default: React.FunctionComponent<Props> & import("hoist-non-react-statics").NonReactStatics<(React.ComponentClass<Props & WithAppProviderProps, any> & typeof ResourceItem) | (React.FunctionComponent<Props & WithAppProviderProps> & typeof ResourceItem), {}>;
export default _default;