UNPKG

synapse-react-client

Version:

[![npm version](https://badge.fury.io/js/synapse-react-client.svg)](https://badge.fury.io/js/synapse-react-client) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettie

66 lines 4.07 kB
import { UniqueFacetIdentifier } from '@/utils/types/UniqueFacetIdentifier'; import { QueryBundleRequest, QueryFilter } from '@sage-bionetworks/synapse-types'; import * as React from 'react'; import { ReadonlyDeep } from 'type-fest'; import { QueryChangeCommitOptions } from './useTableQueryReducer'; export type ImmutableTableQueryResult = { /** The ID of the table parsed from the SQL query */ entityId?: string; /** The version number of the table parsed from the SQL query */ versionNumber?: number; /** The current query request, which is passed on to the server for results */ currentQueryRequest: ReadonlyDeep<QueryBundleRequest>; /** The next (uncommitted) query request. This will become the current query request when commitChanges is called, or the configured debounced timer elapses. */ nextQueryRequest: ReadonlyDeep<QueryBundleRequest>; /** Resets the debounce timer to delay committing changes in `nextQueryRequest` */ resetDebounceTimer: () => void; /** Update the currentQueryRequest to be the nextQueryRequest */ commitChanges: () => void; getInitQueryRequest: () => QueryBundleRequest; getCurrentQueryRequest: () => QueryBundleRequest; setQuery: (queryRequest: React.SetStateAction<QueryBundleRequest>, commitOptions?: QueryChangeCommitOptions) => void; pageSize: number; /** The current page of results. The first page is `1` */ currentPage: number; setPageSize: (pageSize: number) => void; /** pageNumber is 1-indexed */ goToPage: (pageNumber: number) => void; /** Resets the query to the initial state, clearing all user-specified filters */ resetQuery: () => void; addValueToSelectedFacet: (facet: UniqueFacetIdentifier, value: string, commitOptions?: QueryChangeCommitOptions) => void; /** Removes a particular selected facet from the query */ removeSelectedFacet: (facet: UniqueFacetIdentifier | UniqueFacetIdentifier[]) => void; /** Removes a particular value from a selected facet. If the value is the last value in the FacetColumnRequest, the selected facet will be removed. */ removeValueFromSelectedFacet: (facet: UniqueFacetIdentifier, value: string, commitOptions?: QueryChangeCommitOptions) => void; setRangeFacetValue: (facet: UniqueFacetIdentifier, min?: string, max?: string, commitOptions?: QueryChangeCommitOptions) => void; /** Removes a particular QueryFilter from the query */ removeQueryFilter: (filter: QueryFilter) => void; /** Removes a particular value from a QueryFilter. If the value is the last value in the filter, the filter will be removed. */ removeValueFromQueryFilter: (filter: QueryFilter, value: string) => void; /** If `requireConfirmationOnChange` is true, this will become true when a function that triggers a query change is invoked. */ isConfirmingChange: boolean; /** If `isConfirmingChange` is true, invoke this function to complete the query change */ onConfirmChange: () => void; /** If `isConfirmingChange` is true, invoke this function to cancel the query change */ onCancelChange: () => void; }; export type UseImmutableTableQueryOptions = { /** The initial table query request object */ initQueryRequest: QueryBundleRequest; /** Whether the URL should update when the query is modified. */ shouldDeepLink?: boolean; /** Unique index for the component on the page so URL updates do not conflict between table query components */ componentIndex?: number; /** Callback invoked when the query is modified */ onQueryChange?: (newQueryJson: string) => void; /** Whether to require explicit user confirmation before changing the query. */ requireConfirmationOnChange?: boolean; }; export declare const DEBOUNCE_DELAY_MS = 750; /** * Custom hook that maintains and manages the state of a Synapse Table query. * @param options * @returns */ export default function useImmutableTableQuery(options: UseImmutableTableQueryOptions): ImmutableTableQueryResult; //# sourceMappingURL=useImmutableTableQuery.d.ts.map