Skip to content

Commit

Permalink
fix(@cubejs-client/react): type fixes (#2140)
Browse files Browse the repository at this point in the history
* fix(@cubejs-client/react): type fixes

* typos
  • Loading branch information
vasilev-alex committed Feb 18, 2021
1 parent 6fad355 commit bca1ff7
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
6 changes: 6 additions & 0 deletions packages/cubejs-client-core/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,12 @@ declare module '@cubejs-client/core' {

export type MemberType = 'measures' | 'dimensions' | 'segments';

type TOrderMember = {
id: string;
title: string;
order: QueryOrder | 'none'
}

type TCubeMemberType = 'time' | 'number' | 'string' | 'boolean';

type TCubeMember = {
Expand Down
51 changes: 50 additions & 1 deletion packages/cubejs-client-react/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import {
TCubeMember,
ProgressResponse,
TDryRunResponse,
TOrderMember,
QueryOrder,
TQueryOrderArray,
TSourceAxis,
} from '@cubejs-client/core';

/**
Expand Down Expand Up @@ -134,7 +138,7 @@ declare module '@cubejs-client/react' {
*/
export class QueryRenderer extends React.Component<QueryRendererProps> {}

type ChartType = 'line' | 'bar' | 'table' | 'area';
type ChartType = 'line' | 'bar' | 'table' | 'area' | 'number' | 'pie';

type VizState = {
[key: string]: any;
Expand Down Expand Up @@ -214,10 +218,39 @@ declare module '@cubejs-client/react' {
updateDimensions: MemberUpdater;
updateSegments: MemberUpdater;
updateTimeDimensions: MemberUpdater;
updateFilters: MemberUpdater;
/**
* Used for partial of full query update
*/
updateQuery: (query: Query) => void;
filters: Filter[];
/**
* All possible order members for the query
*/
orderMembers: TOrderMember[];
/**
* Used for query order update
*/
updateOrder: OrderUpdater;
/**
* See [Pivot Config](@cubejs-client-core#types-pivot-config)
*/
pivotConfig: PivotConfig;
/**
* Helper method for `pivotConfig` updates
*/
updatePivotConfig: PivotConfigUpdater;

/**
* Selected chart type
*/
chartType: ChartType;

/**
* Used for chart type update
*/
updateChartType: (chartType: ChartType) => void;
validatedQuery: Query;
};

/**
Expand Down Expand Up @@ -449,4 +482,20 @@ declare module '@cubejs-client/react' {
remove: (member: MemberType) => void;
update: (member: MemberType, updateWith: MemberType) => void;
};

type OrderUpdater = {
set: (memberId: string, order: QueryOrder | 'none') => void;
update: (order: TQueryOrderArray) => void;
reorder: (sourceIndex: number, destinationIndex: number) => void;
};

type PivotConfigUpdater = {
moveItem: (
sourceIndex: number,
destinationIndex: number,
sourceAxis: TSourceAxis,
destinationAxis: TSourceAxis
) => void;
update: (pivotConfig: PivotConfig & { limit: number }) => void;
};
}

0 comments on commit bca1ff7

Please sign in to comment.