Skip to content

Commit

Permalink
chore: 透出组件类型定义 (antvis#1175)
Browse files Browse the repository at this point in the history
* chore: 透出组件类型定义

* chore: 修复类型导出问题

* chore: 代码格式化
  • Loading branch information
lvisei authored Jun 22, 2022
1 parent c8720eb commit d29bcfb
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 60 deletions.
13 changes: 4 additions & 9 deletions packages/component/src/control/layer.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
import { IControlOption, PositionName, PositionType } from '@antv/l7-core';
import { bindAll, DOM, lnglatDistance } from '@antv/l7-utils';
import { PositionType } from '@antv/l7-core';
import { bindAll, DOM } from '@antv/l7-utils';
import { ILayerControlOption } from '../interface';
import Control from './BaseControl';
export interface ILayerControlOption extends IControlOption {
collapsed: boolean;
autoZIndex: boolean;
hideSingleBase: boolean;
sortLayers: boolean;

sortFunction: (...args: any[]) => any;
}
interface IInputItem extends HTMLInputElement {
layerId: string;
}

export default class Layers extends Control {
private layerControlInputs: any[];
private layers: any[];
Expand Down
1 change: 1 addition & 0 deletions packages/component/src/control/logo.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { IControlOption } from '@antv/l7-core';
import { DOM } from '@antv/l7-utils';
import Control, { PositionType } from './BaseControl';

export default class Logo extends Control {
public getDefault() {
return {
Expand Down
10 changes: 2 additions & 8 deletions packages/component/src/control/scale.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
import { IControlOption } from '@antv/l7-core';
import { bindAll, DOM, lnglatDistance } from '@antv/l7-utils';

import { IScaleControlOption } from '../interface';
import Control, { PositionType } from './BaseControl';
export interface IScaleControlOption extends IControlOption {
maxWidth: number;
metric: boolean;
updateWhenIdle: boolean;
imperial: boolean;
}

export default class Scale extends Control {
private mScale: HTMLElement;
private iScale: HTMLElement;
Expand Down
9 changes: 2 additions & 7 deletions packages/component/src/control/zoom.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import { IControlOption } from '@antv/l7-core';
import { bindAll, DOM } from '@antv/l7-utils';
import { IZoomControlOption } from '../interface';
import Control, { PositionType } from './BaseControl';
export interface IZoomControlOption extends IControlOption {
zoomInText: string;
zoomInTitle: string;
zoomOutText: string;
zoomOutTitle: string;
}

export default class Zoom extends Control {
private disabled: boolean;
private zoomInButton: HTMLElement;
Expand Down
25 changes: 7 additions & 18 deletions packages/component/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,16 @@
import Control from './control/BaseControl';
import Layers, { ILayerControlOption } from './control/layer';
import Layers from './control/layer';
import Logo from './control/logo';
import Scale, { IScaleControlOption } from './control/scale';
import Zoom, { IZoomControlOption } from './control/zoom';
import Scale from './control/scale';
import Zoom from './control/zoom';
import Marker from './marker';
import MarkerLayer, { IMarkerLayerOption } from './markerlayer';
import MarkerLayer from './marker-layer';
import Popup from './popup';

// 引入样式
// TODO: 使用 Less 或者 Sass,每个组件单独引用自身样式
import './css/l7.css';

export {
Control,
Logo,
Scale,
IScaleControlOption,
Zoom,
IZoomControlOption,
Layers,
ILayerControlOption,
Marker,
Popup,
MarkerLayer,
IMarkerLayerOption,
};
export { Control, Logo, Scale, Zoom, Layers, Marker, Popup, MarkerLayer };

export * from './interface';
41 changes: 41 additions & 0 deletions packages/component/src/interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { IControlOption } from '@antv/l7-core';

export interface ILayerControlOption extends IControlOption {
collapsed: boolean;
autoZIndex: boolean;
hideSingleBase: boolean;
sortLayers: boolean;

sortFunction: (...args: any[]) => any;
}

export interface IScaleControlOption extends IControlOption {
maxWidth: number;
metric: boolean;
updateWhenIdle: boolean;
imperial: boolean;
}

export interface IZoomControlOption extends IControlOption {
zoomInText: string;
zoomInTitle: string;
zoomOutText: string;
zoomOutTitle: string;
}

export interface IMarkerStyleOption {
element?: (...args: any[]) => any;
style: { [key: string]: any } | ((...args: any[]) => any);
className: string;
field?: string;
method?: 'sum' | 'max' | 'min' | 'mean';
radius: number;
maxZoom: number;
minZoom: number;
zoom: number;
}

export interface IMarkerLayerOption {
cluster: boolean;
clusterOption: Partial<IMarkerStyleOption>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,9 @@ import { merge } from 'lodash';
// @ts-ignore
// tslint:disable-next-line:no-submodule-imports
import Supercluster from 'supercluster/dist/supercluster';
import { IMarkerLayerOption, IMarkerStyleOption } from './interface';
import Marker from './marker';

type CallBack = (...args: any[]) => any;
export interface IMarkerStyleOption {
element?: CallBack;
style: { [key: string]: any } | CallBack;
className: string;
field?: string;
method?: 'sum' | 'max' | 'min' | 'mean';
radius: number;
maxZoom: number;
minZoom: number;
zoom: number;
}

export interface IMarkerLayerOption {
cluster: boolean;
clusterOption: Partial<IMarkerStyleOption>;
}

interface IPointFeature {
geometry: {
type: 'Point';
Expand Down

0 comments on commit d29bcfb

Please sign in to comment.