@deck.gl/widgets 9.0.0-beta.9 → 9.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/compass-widget.d.ts +46 -0
- package/dist/compass-widget.d.ts.map +1 -0
- package/dist/compass-widget.js +75 -0
- package/dist/components.d.ts +2 -0
- package/dist/components.d.ts.map +1 -1
- package/dist/components.js +9 -1
- package/dist/dist.dev.js +400 -178
- package/dist/fullscreen-widget.d.ts +6 -0
- package/dist/fullscreen-widget.d.ts.map +1 -1
- package/dist/index.cjs +165 -6
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/stylesheet.css +81 -11
- package/dist/themes.d.ts +8 -0
- package/dist/themes.d.ts.map +1 -1
- package/dist/themes.js +12 -4
- package/dist/zoom-widget.d.ts +55 -0
- package/dist/zoom-widget.d.ts.map +1 -0
- package/dist/zoom-widget.js +68 -0
- package/dist.min.js +1 -1
- package/package.json +3 -3
- package/src/compass-widget.tsx +133 -0
- package/src/components.tsx +21 -2
- package/src/fullscreen-widget.tsx +6 -0
- package/src/index.ts +2 -0
- package/src/stylesheet.css +81 -11
- package/src/themes.ts +12 -4
- package/src/zoom-widget.tsx +128 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { Deck, Viewport, Widget, WidgetPlacement } from '@deck.gl/core';
|
|
2
|
+
interface CompassWidgetProps {
|
|
3
|
+
id: string;
|
|
4
|
+
placement?: WidgetPlacement;
|
|
5
|
+
/**
|
|
6
|
+
* View to attach to and interact with. Required when using multiple views.
|
|
7
|
+
*/
|
|
8
|
+
viewId?: string | null;
|
|
9
|
+
/**
|
|
10
|
+
* Tooltip message.
|
|
11
|
+
*/
|
|
12
|
+
label?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Bearing and pitch reset transition duration in ms.
|
|
15
|
+
*/
|
|
16
|
+
transitionDuration?: number;
|
|
17
|
+
/**
|
|
18
|
+
* CSS inline style overrides.
|
|
19
|
+
*/
|
|
20
|
+
style?: Partial<CSSStyleDeclaration>;
|
|
21
|
+
/**
|
|
22
|
+
* Additional CSS class.
|
|
23
|
+
*/
|
|
24
|
+
className?: string;
|
|
25
|
+
}
|
|
26
|
+
export declare class CompassWidget implements Widget<CompassWidgetProps> {
|
|
27
|
+
id: string;
|
|
28
|
+
props: CompassWidgetProps;
|
|
29
|
+
placement: WidgetPlacement;
|
|
30
|
+
viewId?: string | null;
|
|
31
|
+
viewport?: Viewport;
|
|
32
|
+
deck?: Deck;
|
|
33
|
+
element?: HTMLDivElement;
|
|
34
|
+
constructor(props: CompassWidgetProps);
|
|
35
|
+
setProps(props: Partial<CompassWidgetProps>): void;
|
|
36
|
+
onViewportChange(viewport: any): void;
|
|
37
|
+
onAdd({ deck }: {
|
|
38
|
+
deck: Deck;
|
|
39
|
+
}): HTMLDivElement;
|
|
40
|
+
getRotation(): number[];
|
|
41
|
+
update(): void;
|
|
42
|
+
onRemove(): void;
|
|
43
|
+
handleCompassReset(): void;
|
|
44
|
+
}
|
|
45
|
+
export {};
|
|
46
|
+
//# sourceMappingURL=compass-widget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compass-widget.d.ts","sourceRoot":"","sources":["../src/compass-widget.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,eAAe,EAAC,MAAM,eAAe,CAAC;AAG3E,UAAU,kBAAkB;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACrC;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,aAAc,YAAW,MAAM,CAAC,kBAAkB,CAAC;IAC9D,EAAE,SAAa;IACf,KAAK,EAAE,kBAAkB,CAAC;IAC1B,SAAS,EAAE,eAAe,CAAc;IACxC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAQ;IAC9B,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,OAAO,CAAC,EAAE,cAAc,CAAC;gBAEb,KAAK,EAAE,kBAAkB;IAUrC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,kBAAkB,CAAC;IAI3C,gBAAgB,CAAC,QAAQ,KAAA;IAKzB,KAAK,CAAC,EAAC,IAAI,EAAC,EAAE;QAAC,IAAI,EAAE,IAAI,CAAA;KAAC,GAAG,cAAc;IAc3C,WAAW;IASX,MAAM;IAgCN,QAAQ;IAKR,kBAAkB;CAcnB"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
2
|
+
/* global document */
|
|
3
|
+
import { FlyToInterpolator, WebMercatorViewport, _GlobeViewport } from '@deck.gl/core';
|
|
4
|
+
import { render } from 'preact';
|
|
5
|
+
export class CompassWidget {
|
|
6
|
+
constructor(props) {
|
|
7
|
+
this.id = 'compass';
|
|
8
|
+
this.placement = 'top-left';
|
|
9
|
+
this.viewId = null;
|
|
10
|
+
this.id = props.id || 'compass';
|
|
11
|
+
this.viewId = props.viewId || null;
|
|
12
|
+
this.placement = props.placement || 'top-left';
|
|
13
|
+
props.transitionDuration = props.transitionDuration || 200;
|
|
14
|
+
props.label = props.label || 'Compass';
|
|
15
|
+
props.style = props.style || {};
|
|
16
|
+
this.props = props;
|
|
17
|
+
}
|
|
18
|
+
setProps(props) {
|
|
19
|
+
Object.assign(this.props, props);
|
|
20
|
+
}
|
|
21
|
+
onViewportChange(viewport) {
|
|
22
|
+
this.viewport = viewport;
|
|
23
|
+
this.update();
|
|
24
|
+
}
|
|
25
|
+
onAdd({ deck }) {
|
|
26
|
+
const { style, className } = this.props;
|
|
27
|
+
const element = document.createElement('div');
|
|
28
|
+
element.classList.add('deck-widget', 'deck-widget-compass');
|
|
29
|
+
if (className)
|
|
30
|
+
element.classList.add(className);
|
|
31
|
+
if (style) {
|
|
32
|
+
Object.entries(style).map(([key, value]) => element.style.setProperty(key, value));
|
|
33
|
+
}
|
|
34
|
+
this.deck = deck;
|
|
35
|
+
this.element = element;
|
|
36
|
+
this.update();
|
|
37
|
+
return element;
|
|
38
|
+
}
|
|
39
|
+
getRotation() {
|
|
40
|
+
if (this.viewport instanceof WebMercatorViewport) {
|
|
41
|
+
return [-this.viewport.bearing, this.viewport.pitch];
|
|
42
|
+
}
|
|
43
|
+
else if (this.viewport instanceof _GlobeViewport) {
|
|
44
|
+
return [0, Math.max(-80, Math.min(80, this.viewport.latitude))];
|
|
45
|
+
}
|
|
46
|
+
return [0, 0];
|
|
47
|
+
}
|
|
48
|
+
update() {
|
|
49
|
+
const [rz, rx] = this.getRotation();
|
|
50
|
+
const element = this.element;
|
|
51
|
+
if (!element) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const ui = (_jsx("div", { className: "deck-widget-button", style: { perspective: 100 }, children: _jsx("button", { type: "button", onClick: () => this.handleCompassReset(), label: this.props.label, style: { transform: `rotateX(${rx}deg)` }, children: _jsx("svg", { fill: "none", width: "100%", height: "100%", viewBox: "0 0 26 26", children: _jsxs("g", { transform: `rotate(${rz},13,13)`, children: [_jsx("path", { d: "M10 13.0001L12.9999 5L15.9997 13.0001H10Z", fill: "var(--icon-compass-north-color, #F05C44)" }), _jsx("path", { d: "M16.0002 12.9999L13.0004 21L10.0005 12.9999H16.0002Z", fill: "var(--icon-compass-south-color, #C2C2CC)" })] }) }) }) }));
|
|
55
|
+
render(ui, element);
|
|
56
|
+
}
|
|
57
|
+
onRemove() {
|
|
58
|
+
this.deck = undefined;
|
|
59
|
+
this.element = undefined;
|
|
60
|
+
}
|
|
61
|
+
handleCompassReset() {
|
|
62
|
+
const viewId = this.viewId || 'default-view';
|
|
63
|
+
if (this.viewport instanceof WebMercatorViewport) {
|
|
64
|
+
const nextViewState = {
|
|
65
|
+
...this.viewport,
|
|
66
|
+
bearing: 0,
|
|
67
|
+
...(this.getRotation()[0] === 0 ? { pitch: 0 } : {}),
|
|
68
|
+
transitionDuration: this.props.transitionDuration,
|
|
69
|
+
transitionInterpolator: new FlyToInterpolator()
|
|
70
|
+
};
|
|
71
|
+
// @ts-ignore Using private method temporary until there's a public one
|
|
72
|
+
this.deck._onViewStateChange({ viewId, viewState: nextViewState, interactionState: {} });
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
package/dist/components.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export declare const IconButton: (props: any) => import("preact").JSX.Element;
|
|
2
|
+
export declare const ButtonGroup: (props: any) => import("preact").JSX.Element;
|
|
3
|
+
export declare const GroupedIconButton: (props: any) => import("preact").JSX.Element;
|
|
2
4
|
//# sourceMappingURL=components.d.ts.map
|
package/dist/components.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../src/components.tsx"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,8CActB,CAAC"}
|
|
1
|
+
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../src/components.tsx"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,8CActB,CAAC;AAEF,eAAO,MAAM,WAAW,8CAGvB,CAAC;AAEF,eAAO,MAAM,iBAAiB,8CAY7B,CAAC"}
|
package/dist/components.js
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx } from "preact/jsx-runtime";
|
|
2
2
|
export const IconButton = props => {
|
|
3
3
|
const { className, label, onClick } = props;
|
|
4
|
-
return (_jsx("div", { className: "deck-widget-button
|
|
4
|
+
return (_jsx("div", { className: "deck-widget-button", children: _jsx("button", { className: `deck-widget-icon-button ${className}`, type: "button", onClick: onClick, title: label, children: _jsx("div", { className: "deck-widget-icon" }) }) }));
|
|
5
|
+
};
|
|
6
|
+
export const ButtonGroup = props => {
|
|
7
|
+
const { children, orientation } = props;
|
|
8
|
+
return _jsx("div", { className: `deck-widget-button-group ${orientation}`, children: children });
|
|
9
|
+
};
|
|
10
|
+
export const GroupedIconButton = props => {
|
|
11
|
+
const { className, label, onClick } = props;
|
|
12
|
+
return (_jsx("button", { className: `deck-widget-icon-button ${className}`, type: "button", onClick: onClick, title: label, children: _jsx("div", { className: "deck-widget-icon" }) }));
|
|
5
13
|
};
|