Skip to content

Commit

Permalink
fix(react-chart): update ZoomAndPan plugin ts declaration (#2109)
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitryBogomolov authored Jun 25, 2019
1 parent be38da1 commit 6a81792
Show file tree
Hide file tree
Showing 20 changed files with 77 additions and 31 deletions.
2 changes: 1 addition & 1 deletion packages/dx-chart-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export * from './plugins/series/computeds';
export * from './plugins/stack/computeds';
export * from './plugins/animation/computeds';
export * from './plugins/tooltip/computeds';
export * from './plugins/zoom-pan/computeds';
export * from './plugins/zoom-and-pan/computeds';
export * from './utils/series';
export * from './utils/scale';
export * from './utils/legend';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
adjustLayout, getViewport, getDeltaForTouches, isKeyPressed, getWheelDelta, isMultiTouch,
attachEvents, detachEvents, getRect,
} from './computeds';
import { ScalesCache, ViewportOptions } from '../../types';
import { ScalesCache, Viewport } from '../../types';

jest.mock('../../utils/scale', () => ({
...require.requireActual('../../utils/scale'), // for `rangesEqual`
Expand Down Expand Up @@ -170,7 +170,7 @@ describe('ZoomAndPan', () => {
[ARGUMENT_DOMAIN]: argScale,
'domain-1': valScale,
} as any;
const viewport: ViewportOptions = {
const viewport: Viewport = {
argumentStart: 'A', argumentEnd: 'B',
valueStart: 100, valueEnd: 200,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from '../../utils/scale';
import {
NumberArray,
ViewportOptions,
Viewport,
ScalesCache,
DomainInfoCache,
RangesCache,
Expand All @@ -21,17 +21,17 @@ import {
} from '../../types';
import { Size } from '@devexpress/dx-react-core';

const getArgumentBounds = (viewport?: ViewportOptions): DomainBounds | null => (
const getArgumentBounds = (viewport?: Viewport): DomainBounds | null => (
viewport && viewport.argumentStart !== undefined && viewport.argumentEnd !== undefined
? [viewport.argumentStart, viewport.argumentEnd] : null
);

const getValueBounds = (viewport?: ViewportOptions): DomainBounds | null => (
const getValueBounds = (viewport?: Viewport): DomainBounds | null => (
viewport && viewport.valueStart !== undefined && viewport.valueEnd !== undefined
? [viewport.valueStart, viewport.valueEnd] : null
);

const getValueScaleName = (viewport?: ViewportOptions) => (
const getValueScaleName = (viewport?: Viewport) => (
getValueDomainName(viewport && viewport.scaleName)
);

Expand Down Expand Up @@ -66,7 +66,7 @@ const update = (

/** @internal */
export const adjustLayout = (
domains: DomainInfoCache, ranges: RangesCache, viewport?: ViewportOptions,
domains: DomainInfoCache, ranges: RangesCache, viewport?: Viewport,
) => {
const changes = {};
const argumentBounds = getArgumentBounds(viewport);
Expand Down Expand Up @@ -105,7 +105,7 @@ export const getViewport = (
deltas: Readonly<[number, number]> | null,
anchors: Readonly<[number, number]> | null,
ranges: Readonly<[NumberArray, NumberArray]> | null,
viewport?: ViewportOptions, onViewportChange?: OnViewportChangeFn,
viewport?: Viewport, onViewportChange?: OnViewportChangeFn,
) => {
const changes: any = {};
const argumentBounds = boundsForScale(
Expand Down
2 changes: 1 addition & 1 deletion packages/dx-chart-core/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export * from './plugins.scale.types';
export * from './plugins.layout-manager.types';
export * from './plugins.axis.types';
export * from './plugins.animation.types';
export * from './plugins.zoom-pan.types';
export * from './plugins.zoom-and-pan.types';
export * from './utils.event-tracker.types';
export * from './utils.hover-state.types';
export * from './utils.legend.types';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/** @internal */
export type DomainBounds = Readonly<[any, any]>;

export type ViewportOptions = {
export type Viewport = {
readonly argumentStart?: any;
readonly argumentEnd?: any;
readonly scaleName?: string;
readonly valueStart?: any;
readonly valueEnd?: any;
};

export type OnViewportChangeFn = (viewport: ViewportOptions) => void;
export type OnViewportChangeFn = (viewport: Viewport) => void;

export type Interaction = 'none' | 'pan' | 'zoom' | 'both';
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import { SplineSeries as SplineSeries_2 } from '@devexpress/dx-react-chart';
import { Title as Title_2 } from '@devexpress/dx-react-chart';
import { Tooltip as Tooltip_2 } from '@devexpress/dx-react-chart';
import { ValueAxis as ValueAxis_2 } from '@devexpress/dx-react-chart';
import { Viewport } from '@devexpress/dx-react-chart';
import { ZoomAndPan as ZoomAndPan_2 } from '@devexpress/dx-react-chart';

// @public (undocumented)
export namespace AreaSeries {
Expand Down Expand Up @@ -343,6 +345,27 @@ export interface ValueAxisProps {
tickSize?: number;
}

// @public (undocumented)
export namespace ZoomAndPan {
export type DragBoxProps = ZoomAndPan_2.DragBoxProps;
}

// @public
export const ZoomAndPan: React.ComponentType<ZoomAndPanProps> & {
DragBox: React.ComponentType<ZoomAndPan_2.DragBoxProps & { className?: string; style?: React.CSSProperties; [x: string]: any }>;
};

// @public (undocumented)
export interface ZoomAndPanProps {
defaultViewport?: Viewport;
dragBoxComponent?: React.ComponentType<ZoomAndPan_2.DragBoxProps>;
interactionWithArguments?: 'none' | 'pan' | 'zoom' | 'both';
interactionWithValues?: 'none' | 'pan' | 'zoom' | 'both';
onViewportChange?: (viewport: Viewport) => void;
viewport?: Viewport;
zoomRegionKey?: 'shift' | 'alt' | 'ctrl';
}


// (No @packageDocumentation comment for this package)

Expand Down
2 changes: 1 addition & 1 deletion packages/dx-react-chart-bootstrap4/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ export { ValueAxis } from './plugins/value-axis';
export { ArgumentAxis } from './plugins/argument-axis';

export { Tooltip } from './plugins/tooltip';
export { ZoomAndPan } from './plugins/zoom-pan';
export { ZoomAndPan } from './plugins/zoom-and-pan';
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ZoomAndPan as ZoomAndPanBase } from '@devexpress/dx-react-chart';
import { withComponents } from '@devexpress/dx-react-core';
import { DragBox } from '../templates/zoom-pan/drag-box';
import { DragBox } from '../templates/zoom-and-pan/drag-box';

export const ZoomAndPan = withComponents({ DragBox })(ZoomAndPanBase);
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import { SplineSeries as SplineSeries_2 } from '@devexpress/dx-react-chart';
import { Title as Title_2 } from '@devexpress/dx-react-chart';
import { Tooltip as Tooltip_2 } from '@devexpress/dx-react-chart';
import { ValueAxis as ValueAxis_2 } from '@devexpress/dx-react-chart';
import { Viewport } from '@devexpress/dx-react-chart';
import { ZoomAndPan as ZoomAndPan_2 } from '@devexpress/dx-react-chart';

// @public (undocumented)
export namespace AreaSeries {
Expand Down Expand Up @@ -343,6 +345,27 @@ export interface ValueAxisProps {
tickSize?: number;
}

// @public (undocumented)
export namespace ZoomAndPan {
export type DragBoxProps = ZoomAndPan_2.DragBoxProps;
}

// @public
export const ZoomAndPan: React.ComponentType<ZoomAndPanProps> & {
DragBox: React.ComponentType<ZoomAndPan_2.DragBoxProps & { className?: string; style?: React.CSSProperties; [x: string]: any }>;
};

// @public (undocumented)
export interface ZoomAndPanProps {
defaultViewport?: Viewport;
dragBoxComponent?: React.ComponentType<ZoomAndPan_2.DragBoxProps>;
interactionWithArguments?: 'none' | 'pan' | 'zoom' | 'both';
interactionWithValues?: 'none' | 'pan' | 'zoom' | 'both';
onViewportChange?: (viewport: Viewport) => void;
viewport?: Viewport;
zoomRegionKey?: 'shift' | 'alt' | 'ctrl';
}


// (No @packageDocumentation comment for this package)

Expand Down
2 changes: 1 addition & 1 deletion packages/dx-react-chart-material-ui/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ export { ValueAxis } from './plugins/value-axis';
export { ArgumentAxis } from './plugins/argument-axis';

export { Tooltip } from './plugins/tooltip';
export { ZoomAndPan } from './plugins/zoom-pan';
export { ZoomAndPan } from './plugins/zoom-and-pan';
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ZoomAndPan as ZoomAndPanBase } from '@devexpress/dx-react-chart';
import { withComponents } from '@devexpress/dx-react-core';
import { DragBox } from '../templates/zoom-pan/drag-box';
import { DragBox } from '../templates/zoom-and-pan/drag-box';

export const ZoomAndPan = withComponents({ DragBox })(ZoomAndPanBase);
8 changes: 4 additions & 4 deletions packages/dx-react-chart/api/dx-react-chart.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ export type NumberArray = [number, number];
export type OffsetFn = (series: StackData, order: number[]) => void;

// @public (undocumented)
export type OnViewportChangeFn = (viewport: ViewportOptions) => void;
export type OnViewportChangeFn = (viewport: Viewport) => void;

// @public (undocumented)
export type OrderFn = (series: StackData) => number[];
Expand Down Expand Up @@ -596,7 +596,7 @@ export interface ValueScaleProps extends ScaleProps {
}

// @public (undocumented)
export type ViewportOptions = {
export type Viewport = {
readonly argumentStart?: any;
readonly argumentEnd?: any;
readonly scaleName?: string;
Expand All @@ -617,12 +617,12 @@ export namespace ZoomAndPan {

// @public (undocumented)
export interface ZoomAndPanProps {
defaultViewport?: ViewportOptions;
defaultViewport?: Viewport;
dragBoxComponent: React.ComponentType<ZoomAndPan.DragBoxProps>;
interactionWithArguments?: Interaction;
interactionWithValues?: Interaction;
onViewportChange?: OnViewportChangeFn;
viewport?: ViewportOptions;
viewport?: Viewport;
zoomRegionKey?: 'shift' | 'alt' | 'ctrl';
}

Expand Down
8 changes: 4 additions & 4 deletions packages/dx-react-chart/docs/reference/zoom-and-pan.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ import { ZoomAndPan } from '@devexpress/dx-react-chart';

Name | Type | Default | Description
-----|------|---------|------------
defaultViewport? | [ZoomAndPan.Viewport](#zoomandpanviewport) | The default viewport.
viewport? | [ZoomAndPan.Viewport](#zoomandpanviewport) | The viewport.
onViewportChange? | (viewport: [ZoomAndPan.Viewport](#zoomandpanviewport)) => void | A function that is executed when the viewport changes.
defaultViewport? | [Viewport](#viewport) | The default viewport.
viewport? | [Viewport](#viewport) | The viewport.
onViewportChange? | (viewport: [Viewport](#viewport)) => void | A function that is executed when the viewport changes.
interactionWithArguments? | 'none' &#124; 'pan' &#124; 'zoom' &#124; 'both' | The type of interaction available for the argument scale.
interactionWithValues? | 'none' &#124; 'pan' &#124; 'zoom' &#124; 'both' | The type of interaction available for the value scale.
zoomRegionKey? | 'shift' &#124; 'alt' &#124; 'ctrl' | The key the allows a user to zoom a region by selecting it with the mouse drag gesture.
dragBoxComponent? | ComponentType&lt;[ZoomAndPan.DragBoxProps](#zoomandpandragboxprops)&gt; | A component that renders the rectangle that appears when a user zooms a region.

## Interfaces

### ZoomAndPan.Viewport
### Viewport

The viewport configuration.

Expand Down
2 changes: 1 addition & 1 deletion packages/dx-react-chart/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export { SplineSeries } from './plugins/spline-series';
export { Axis, ArgumentAxis, ValueAxis } from './plugins/axis';
export { Tooltip } from './plugins/tooltip';

export * from './plugins/zoom-pan';
export * from './plugins/zoom-and-pan';

export * from './plugins/event-tracker';
export * from './plugins/hover-state';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
pluginDepsToComponents, getComputedState,
} from '@devexpress/dx-testing';
import { adjustLayout, attachEvents, detachEvents } from '@devexpress/dx-chart-core';
import { ZoomAndPan } from './zoom-pan';
import { ZoomAndPan } from './zoom-and-pan';

jest.mock('@devexpress/dx-chart-core', () => ({
adjustLayout: jest.fn().mockReturnValue('adjusted-ranges'),
Expand Down
2 changes: 1 addition & 1 deletion packages/dx-react-chart/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export {
BBoxes, BBoxesChange,
StackList, StacksOptions, OffsetFn, OrderFn,
EventHandlers, NumberArray, Location,
DomainBounds, ViewportOptions, OnViewportChangeFn, EventHandlerFn,
DomainBounds, Viewport, OnViewportChangeFn, EventHandlerFn,

AreaSeries, LineSeries, SplineSeries, BarSeries, ScatterSeries, PieSeries,
SeriesProps, PathComponentProps, PathComponentPathProps, PointComponentProps,
Expand Down
8 changes: 4 additions & 4 deletions packages/dx-react-chart/src/types/plugins.zoom-pan.types.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import {
ViewportOptions,
Viewport,
OnViewportChangeFn,
EventHandlerFn,
Interaction,
} from './index';

export interface ZoomAndPanProps {
/** A default viewport */
defaultViewport?: ViewportOptions;
defaultViewport?: Viewport;
/** A viewport */
viewport?: ViewportOptions;
viewport?: Viewport;
/** A function that is executed when viewport changes */
onViewportChange?: OnViewportChangeFn;
/** Interaction with arguments */
Expand All @@ -26,7 +26,7 @@ type Rect = { x: number; y: number; width: number; height: number; };

/** @internal */
export type ZoomAndPanState = {
viewport?: ViewportOptions;
viewport?: Viewport;
rectBox?: Rect | null;
};

Expand Down

0 comments on commit 6a81792

Please sign in to comment.