, or ). */
listClassName?: string;
/** CSS class name for the "Show more" button. */
showMoreClassName?: string;
/** The English noun (in singular form) describing what this connection contains. */
noun: string;
/** The English noun (in plural form) describing what this connection contains. */
pluralNoun: string;
/** Do not show a "Show more" button. */
noShowMore?: boolean;
/** Do not show a count summary if all nodes are visible in the list's first page. */
noSummaryIfAllNodesVisible?: boolean;
/** The component displayed when the list of nodes is empty. */
emptyElement?: JSX.Element;
}
/**
* Props for the FilteredConnection component's result nodes and associated summary/pagination controls.
*
* @template C The GraphQL connection type, such as GQL.IRepositoryConnection.
* @template N The node type of the GraphQL connection, such as GQL.IRepository (if C is GQL.IRepositoryConnection)
* @template NP Props passed to `nodeComponent` in addition to `{ node: N }`
*/
interface ConnectionPropsCommon extends ConnectionDisplayProps {
/** Header row to appear above all nodes. */
headComponent?: React.ComponentType<{
nodes: N[];
}>;
/** Footer row to appear below all nodes. */
footComponent?: React.ComponentType<{
nodes: N[];
}>;
/** The component type to use to display each node. */
nodeComponent: React.ComponentType<{
node: N;
} & NP>;
/** Props to pass to each nodeComponent in addition to `{ node: N }`. */
nodeComponentProps?: NP;
}
/** State related to the ConnectionNodes component. */
interface ConnectionStateCommon {
query: string;
first: number;
connectionQuery?: string;
/**
* Whether the connection is loading. It is not equivalent to connection === undefined because we preserve the
* old data for ~250msec while loading to reduce jitter.
*/
loading: boolean;
}
/**
* Fields that belong in FilteredConnectionProps and that don't depend on the type parameters. These are the fields
* that are most likely to be needed by callers, and it's simpler for them if they are in a parameter-less type.
*/
interface FilteredConnectionDisplayProps extends ConnectionDisplayProps {
history: H.History;
location: H.Location;
/** CSS class name for the root element. */
className?: string;
/** Whether to display it more compactly. */
compact?: boolean;
/**
* An observable that upon emission causes the connection to refresh the data (by calling queryConnection).
*
* In most cases, it's simpler to use updateOnChange.
*/
updates?: Observable;
/**
* Refresh the data when this value changes. It is typically constructed as a key from the query args.
*/
updateOnChange?: string;
/** The number of items to fetch, by default. */
defaultFirst?: number;
/** Hides the filter input field. */
hideSearch?: boolean;
/** Autofocuses the filter input field. */
autoFocus?: boolean;
/** Whether we will update the URL query string to reflect the filter and pagination state or not. */
shouldUpdateURLQuery?: boolean;
/**
* Filters to display next to the filter input field.
*
* Filters are mutually exclusive.
*/
filters?: FilteredConnectionFilter[];
/** Called when a filter is selected and on initial render. */
onFilterSelect?: (filterID: string | undefined) => void;
}
/**
* Props for the FilteredConnection component.
*
* @template C The GraphQL connection type, such as GQL.IRepositoryConnection.
* @template N The node type of the GraphQL connection, such as GQL.IRepository (if C is GQL.IRepositoryConnection)
* @template NP Props passed to `nodeComponent` in addition to `{ node: N }`
*/
interface FilteredConnectionProps, N, NP = {}> extends ConnectionPropsCommon, FilteredConnectionDisplayProps {
/** Called to fetch the connection data to populate this component. */
queryConnection: (args: FilteredConnectionQueryArgs) => Observable;
/** Called when the queryConnection Observable emits. */
onUpdate?: (value: C | ErrorLike | undefined) => void;
}
/**
* The arguments for the Props.queryConnection function.
*/
export interface FilteredConnectionQueryArgs {
first?: number;
query?: string;
}
/**
* A filter to display next to the filter input field.
*/
export interface FilteredConnectionFilter {
/** The UI label for the filter. */
label: string;
/**
* The URL string for this filter (conventionally the label, lowercased and without spaces and punctuation).
*/
id: string;
/** An optional tooltip to display for this filter. */
tooltip?: string;
/** Additional query args to pass to the queryConnection function when this filter is enabled. */
args: {
[name: string]: string | number | boolean;
};
}
interface FilteredConnectionState, N> extends ConnectionStateCommon {
/** The active filter's ID (FilteredConnectionFilter.id), if any. */
activeFilter: FilteredConnectionFilter | undefined;
/** The fetched connection data or an error (if an error occurred). */
connectionOrError?: C | ErrorLike;
}
/**
* See https://facebook.github.io/relay/graphql/connections.htm.
*/
export interface Connection {
/**
* The list of items (nodes) in this connection's current page.
*/
nodes: N[];
/**
* The total count of items in the connection (not subject to pagination). The type accounts
* for all known GraphQL XyzConnection types.
*
* If the value is a number, then the precise total count is known. If null, then the total
* count was not precisely computable for this particular query (but might be for other queries).
* If undefined, then the resolver never supports producing a total count.
*
* In the future, the UI might show `null` differently from `undefined`, but for now, the
* distinction is maintained solely for typechecking to pass.
*/
totalCount?: number | null;
/**
* If set, indicates whether there is a next page. Not all GraphQL XyzConnection types return
* pageInfo (if not, then they generally all do return totalCount).
*/
pageInfo?: {
hasNextPage: boolean;
};
/**
* If set, this error is displayed. Even when there is an error, the results are still displayed.
*/
error?: string | null;
}
/**
* Displays a collection of items with filtering and pagination. It is called
* "connection" because it is intended for use with GraphQL, which calls it that
* (see http://graphql.org/learn/pagination/).
*
* @template C The GraphQL connection type, such as GQL.IRepositoryConnection.
* @template N The node type of the GraphQL connection, such as GQL.IRepository (if C is GQL.IRepositoryConnection)
* @template NP Props passed to `nodeComponent` in addition to `{ node: N }`
*/
export declare class FilteredConnection = Connection> extends React.PureComponent, FilteredConnectionState> {
static defaultProps: Partial>;
private queryInputChanges;
private activeFilterChanges;
private showMoreClicks;
private componentUpdates;
private subscriptions;
private filterRef;
constructor(props: FilteredConnectionProps);
componentDidMount(): void;
private urlQuery;
componentWillReceiveProps(nextProps: FilteredConnectionProps): void;
componentWillUnmount(): void;
render(): JSX.Element | null;
private setFilterRef;
private focusFilter;
private onSubmit;
private onChange;
private onDidSelectFilter;
private onClickShowMore;
}
export {};
//# sourceMappingURL=FilteredConnection.d.ts.map