thingsboard/ui-ngx/src/typings/leaflet-extend-tb.d.ts

158 lines
4.7 KiB
TypeScript
Raw Normal View History

///
2024-01-09 10:46:16 +02:00
/// Copyright © 2016-2024 The Thingsboard Authors
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
import { FormattedData } from '@shared/models/widget.models';
2025-01-27 17:56:33 +02:00
import L, { Control, ControlOptions } from 'leaflet';
2025-01-21 19:42:21 +02:00
import { TbMapDatasource } from '@home/components/widget/lib/maps/models/map.models';
// redeclare module, maintains compatibility with @types/leaflet
declare module 'leaflet' {
interface MarkerOptions {
2025-01-21 19:42:21 +02:00
tbMarkerData?: FormattedData<TbMapDatasource>;
}
2025-01-03 19:37:04 +02:00
interface TileLayer {
_url: string;
_getSubdomain(tilePoint: L.Coords): string;
_globalTileRange: L.Bounds;
}
2024-12-27 15:26:19 +02:00
namespace TB {
2024-12-30 19:29:15 +02:00
interface SidebarControlOptions extends ControlOptions {
container: JQuery<HTMLElement>;
paneWidth?: number;
}
class SidebarControl extends Control<SidebarControlOptions> {
constructor(options: SidebarControlOptions);
2025-01-10 18:03:40 +02:00
addPane(pane: JQuery<HTMLElement>, button: JQuery<HTMLElement>): this;
2024-12-30 19:29:15 +02:00
togglePane(pane: JQuery<HTMLElement>, button: JQuery<HTMLElement>): void;
}
interface SidebarPaneControlOptions extends ControlOptions {
sidebar: SidebarControl;
uiClass: string;
buttonTitle?: string;
paneTitle: string;
}
class SidebarPaneControl<O extends SidebarPaneControlOptions> extends Control<O> {
constructor(options: O);
onAddPane(map: Map, button: JQuery<HTMLElement>, $ui: JQuery<HTMLElement>, toggle: (e: JQuery.MouseEventBase) => void);
}
interface LayerData {
title: string;
2025-01-03 19:37:04 +02:00
attributionPrefix?: string;
2024-12-30 19:29:15 +02:00
layer: Layer;
mini: Layer;
}
interface LayersControlOptions extends SidebarPaneControlOptions {
layers: LayerData[];
}
class LayersControl extends SidebarPaneControl<LayersControlOptions> {
constructor(options: LayersControlOptions);
}
2025-01-10 18:03:40 +02:00
interface DataLayer {
toggleGroup(group: string): boolean;
}
interface GroupData {
title: string;
group: string;
enabled: boolean;
dataLayers: DataLayer[];
}
interface GroupsControlOptions extends SidebarPaneControlOptions {
groups: GroupData[];
}
class GroupsControl extends SidebarPaneControl<GroupsControlOptions> {
constructor(options: GroupsControlOptions);
}
2025-01-28 15:51:44 +02:00
interface ToolbarButtonOptions extends ControlOptions {
id: string;
2025-01-27 17:56:33 +02:00
title: string;
click: (e: MouseEvent, button: ToolbarButton) => void;
iconClass: string;
2025-01-29 21:06:11 +02:00
showText?: boolean;
2025-01-27 17:56:33 +02:00
}
class ToolbarButton extends Control<ToolbarButtonOptions>{
constructor(options: ToolbarButtonOptions);
2025-01-28 15:51:44 +02:00
setActive(active: boolean): void;
isActive(): boolean;
setDisabled(disabled: boolean): void;
isDisabled(): boolean;
2025-01-27 17:56:33 +02:00
}
class ToolbarControl extends Control<ControlOptions> {
constructor(options: ControlOptions);
toolbarButton(options: ToolbarButtonOptions): ToolbarButton;
}
2025-01-27 17:56:33 +02:00
interface BottomToolbarControlOptions extends ControlOptions {
mapElement: JQuery<HTMLElement>;
closeTitle: string;
2025-01-28 15:51:44 +02:00
onClose: () => boolean;
2025-01-27 17:56:33 +02:00
}
class BottomToolbarControl extends Control<BottomToolbarControlOptions> {
constructor(options: BottomToolbarControlOptions);
2025-01-28 15:51:44 +02:00
getButton(id: string): ToolbarButton | undefined;
2025-01-29 21:06:11 +02:00
open(buttons: ToolbarButtonOptions[], showCloseButton?: boolean): void;
2025-01-27 17:56:33 +02:00
close(): void;
container: HTMLElement;
}
2024-12-30 19:29:15 +02:00
function sidebar(options: SidebarControlOptions): SidebarControl;
function sidebarPane<O extends SidebarPaneControlOptions>(options: O): SidebarPaneControl<O>;
function layers(options: LayersControlOptions): LayersControl;
2025-01-03 19:37:04 +02:00
2025-01-10 18:03:40 +02:00
function groups(options: GroupsControlOptions): GroupsControl;
function toolbar(options: ControlOptions): ToolbarControl;
2025-01-27 17:56:33 +02:00
function bottomToolbar(options: BottomToolbarControlOptions): BottomToolbarControl;
2025-01-03 19:37:04 +02:00
namespace TileLayer {
interface ChinaProvidersData {
[provider: string]: {
[type: string]: string;
Subdomains: string;
};
}
class ChinaProvider extends L.TileLayer {
constructor(type: string, options?: TileLayerOptions);
}
}
namespace tileLayer {
function chinaProvider(type: string, options?: TileLayerOptions): TileLayer.ChinaProvider;
}
2024-12-27 15:26:19 +02:00
}
}