Skip to content

Commit

Permalink
Add helper FilterGroupsConfig type export
Browse files Browse the repository at this point in the history
  • Loading branch information
ncovercash committed Jan 5, 2024
1 parent 6550857 commit d5b170f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
1 change: 1 addition & 0 deletions components/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ export {
QueryParamFunc,
FilterGroupsConfigValue,
FilterGroupsConfigGroup,
FilterGroupsConfig,
FilterGroupsState,
} from './lib/FilterGroups';
export { default as FilterControlGroup, FilterControlGroupProps } from './lib/FilterControlGroup';
Expand Down
11 changes: 4 additions & 7 deletions components/lib/FilterGroups/FilterGroups.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ChangeEventHandler, FunctionComponent } from 'react';
import { FilterGroupsConfigGroup, FilterGroupsState } from './types';
import { FilterAccordionHeaderProps } from '../Accordion';
import { FilterGroupsConfig, FilterGroupsConfigGroup, FilterGroupsState } from './types';

export const FILTER_SEPARATOR: string;
export const FILTER_GROUP_SEPARATOR: string;
Expand All @@ -9,16 +9,13 @@ export type TransitionToParamsFunc = (params: { filters: string; query?: string
export type QueryParamFunc = (key: 'filters') => string | undefined;

/** @deprecated use {@link filterState} instead */
export function initialFilterState(
config: FilterGroupsConfigGroup[],
filters?: string,
): FilterGroupsState;
export function initialFilterState(config: FilterGroupsConfig, filters?: string): FilterGroupsState;

/** Convert stringified filters to a state object */
export function filterState(filters?: string): FilterGroupsState;

/** Convert filters to CQL */
export function filters2cql(config: FilterGroupsConfigGroup[], filters: string): string | undefined;
export function filters2cql(config: FilterGroupsConfig, filters: string): string | undefined;

/** @deprecated use {@link handleFilterChange} */
export function onChangeFilter(e: any): void;
Expand Down Expand Up @@ -49,7 +46,7 @@ export function handleClearAllFilters(this: {

export interface FilterGroupsProps {
/** Configuration for the filter groups */
config: FilterGroupsConfigGroup[];
config: FilterGroupsConfig;
/** Current filter state, as an object */
filters: FilterGroupsState;
/** React to changes in the filter via checkbox */
Expand Down
7 changes: 6 additions & 1 deletion components/lib/FilterGroups/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,9 @@ export {
QueryParamFunc,
} from './FilterGroups';

export type { FilterGroupsConfigValue, FilterGroupsConfigGroup, FilterGroupsState } from './types';
export type {
FilterGroupsConfigValue,
FilterGroupsConfigGroup,
FilterGroupsConfig,
FilterGroupsState,
} from './types';
1 change: 1 addition & 0 deletions components/lib/FilterGroups/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,4 @@ export type FilterGroupsConfigGroup = {
);

export type FilterGroupsState = Record<string, boolean>;
export type FilterGroupsConfig = FilterGroupsConfigGroup[];

0 comments on commit d5b170f

Please sign in to comment.