import React from 'react'; import { UIElement } from '@instructure/shared-types'; /** * Valid keys for the Query object */ type ValidQueryKey = 'minHeight' | 'maxHeight' | 'minWidth' | 'maxWidth'; /** * Query objects with keys representing the breakpoint condition and values representing a breakpoint value as a string or number. Ex. `{ maxWidth: 400 }`, `{ minWidth: '600em'}` */ type Query = { [queryKey in ValidQueryKey]?: string | number; }; /** * Consists of an object where the keys define the names of breakpoints and the values are Query objects. Ex. `{small: { maxWidth: 400 }, large: { minWidth: '600em'}}` */ type BreakpointQueries = { [breakpointName: string]: Query; }; /** * List of query names (breakpoints) currently matching */ type QueriesMatching = string[]; type UpdateMatches = (matches: QueriesMatching, cb?: (...args: any[]) => any) => void; /** * Signature for `addMediaQueryMatchListener` and `addElementQueryMatchListener` methods. * * Given an object of named queries, listens for changes * and notifies which queries match via a function * callback. The callback method is only called when the query * matches change, not on all window resizes. * * The [Responsive](Responsive) component with the `match` prop * set to `media` or `element` utilizes this function. * This is a low level utility method and, in most cases, * [Responsive](Responsive) should be used instead. * * @param {Object} query - object consisting of names and query objects * @param {Node|Window|React.ReactElement|React.Component|function} el - a DOM node or a function returning a DOM node * @param {function} cb - called with an array of the names of the currently matching queries whenever a matching query changes * @param {object} matchMedia - called with an array of the names of the currently matching queries whenever a matching query changes. Only used by `addMediaQueryMatchListener`. * @returns {function} remove() function to call to remove the listener */ type QueryMatchListener = (query: BreakpointQueries, el: Node | Window | React.ReactElement | React.Component | ((...args: any[]) => Node | Window | React.ReactElement | React.Component), cb: UpdateMatches, matchMedia?: (query: string, el: UIElement) => MediaQueryList | null | undefined) => { remove: () => void; }; export type { BreakpointQueries, Query, ValidQueryKey, QueriesMatching, UpdateMatches, QueryMatchListener }; //# sourceMappingURL=QueryType.d.ts.map