@deck.gl/widgets 9.1.11 → 9.2.0-alpha.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 +11 -34
- package/dist/compass-widget.d.ts.map +1 -1
- package/dist/compass-widget.js +27 -62
- package/dist/compass-widget.js.map +1 -1
- package/dist/context-menu-widget.d.ts +37 -0
- package/dist/context-menu-widget.d.ts.map +1 -0
- package/dist/context-menu-widget.js +74 -0
- package/dist/context-menu-widget.js.map +1 -0
- package/dist/dist.dev.js +2271 -581
- package/dist/fps-widget.d.ts +29 -0
- package/dist/fps-widget.d.ts.map +1 -0
- package/dist/fps-widget.js +51 -0
- package/dist/fps-widget.js.map +1 -0
- package/dist/fullscreen-widget.d.ts +15 -33
- package/dist/fullscreen-widget.d.ts.map +1 -1
- package/dist/fullscreen-widget.js +20 -51
- package/dist/fullscreen-widget.js.map +1 -1
- package/dist/geocoder-widget.d.ts +51 -0
- package/dist/geocoder-widget.d.ts.map +1 -0
- package/dist/geocoder-widget.js +138 -0
- package/dist/geocoder-widget.js.map +1 -0
- package/dist/gimbal-widget.d.ts +33 -0
- package/dist/gimbal-widget.d.ts.map +1 -0
- package/dist/gimbal-widget.js +116 -0
- package/dist/gimbal-widget.js.map +1 -0
- package/dist/index.cjs +1587 -341
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +37 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +27 -7
- package/dist/index.js.map +1 -1
- package/dist/info-widget.d.ts +37 -0
- package/dist/info-widget.d.ts.map +1 -0
- package/dist/info-widget.js +183 -0
- package/dist/info-widget.js.map +1 -0
- package/dist/lib/components/button-group.d.ts +8 -0
- package/dist/lib/components/button-group.d.ts.map +1 -0
- package/dist/lib/components/button-group.js +7 -0
- package/dist/lib/components/button-group.js.map +1 -0
- package/dist/lib/components/dropdown-menu.d.ts +8 -0
- package/dist/lib/components/dropdown-menu.d.ts.map +1 -0
- package/dist/lib/components/dropdown-menu.js +55 -0
- package/dist/lib/components/dropdown-menu.js.map +1 -0
- package/dist/lib/components/grouped-icon-button.d.ts +8 -0
- package/dist/lib/components/grouped-icon-button.d.ts.map +1 -0
- package/dist/lib/components/grouped-icon-button.js +7 -0
- package/dist/lib/components/grouped-icon-button.js.map +1 -0
- package/dist/lib/components/icon-button.d.ts +11 -0
- package/dist/lib/components/icon-button.d.ts.map +1 -0
- package/dist/lib/components/icon-button.js +7 -0
- package/dist/lib/components/icon-button.js.map +1 -0
- package/dist/lib/components/icon-menu.d.ts +16 -0
- package/dist/lib/components/icon-menu.d.ts.map +1 -0
- package/dist/lib/components/icon-menu.js +49 -0
- package/dist/lib/components/icon-menu.js.map +1 -0
- package/dist/lib/components/simple-menu.d.ts +16 -0
- package/dist/lib/components/simple-menu.d.ts.map +1 -0
- package/dist/lib/components/simple-menu.js +30 -0
- package/dist/lib/components/simple-menu.js.map +1 -0
- package/dist/lib/geocode/geocoder-history.d.ts +23 -0
- package/dist/lib/geocode/geocoder-history.d.ts.map +1 -0
- package/dist/lib/geocode/geocoder-history.js +64 -0
- package/dist/lib/geocode/geocoder-history.js.map +1 -0
- package/dist/lib/geocode/geocoder.d.ts +15 -0
- package/dist/lib/geocode/geocoder.d.ts.map +1 -0
- package/dist/lib/geocode/geocoder.js +5 -0
- package/dist/lib/geocode/geocoder.js.map +1 -0
- package/dist/lib/geocode/geocoders.d.ts +68 -0
- package/dist/lib/geocode/geocoders.d.ts.map +1 -0
- package/dist/lib/geocode/geocoders.js +182 -0
- package/dist/lib/geocode/geocoders.js.map +1 -0
- package/dist/loading-widget.d.ts +26 -0
- package/dist/loading-widget.d.ts.map +1 -0
- package/dist/loading-widget.js +41 -0
- package/dist/loading-widget.js.map +1 -0
- package/dist/reset-view-widget.d.ts +4 -4
- package/dist/reset-view-widget.d.ts.map +1 -1
- package/dist/reset-view-widget.js +7 -10
- package/dist/reset-view-widget.js.map +1 -1
- package/dist/scale-widget.d.ts +28 -0
- package/dist/scale-widget.d.ts.map +1 -0
- package/dist/scale-widget.js +111 -0
- package/dist/scale-widget.js.map +1 -0
- package/dist/screenshot-widget.d.ts +4 -4
- package/dist/screenshot-widget.d.ts.map +1 -1
- package/dist/screenshot-widget.js +7 -14
- package/dist/screenshot-widget.js.map +1 -1
- package/dist/splitter-widget.d.ts +32 -0
- package/dist/splitter-widget.d.ts.map +1 -0
- package/dist/splitter-widget.js +123 -0
- package/dist/splitter-widget.js.map +1 -0
- package/dist/stats-widget.d.ts +36 -0
- package/dist/stats-widget.d.ts.map +1 -0
- package/dist/stats-widget.js +115 -0
- package/dist/stats-widget.js.map +1 -0
- package/dist/stylesheet.css +121 -4
- package/dist/theme-widget.d.ts +31 -0
- package/dist/theme-widget.d.ts.map +1 -0
- package/dist/theme-widget.js +83 -0
- package/dist/theme-widget.js.map +1 -0
- package/dist/themes.d.ts +65 -36
- package/dist/themes.d.ts.map +1 -1
- package/dist/themes.js +20 -8
- package/dist/themes.js.map +1 -1
- package/dist/timeline-widget.d.ts +59 -0
- package/dist/timeline-widget.d.ts.map +1 -0
- package/dist/timeline-widget.js +83 -0
- package/dist/timeline-widget.js.map +1 -0
- package/dist/view-selector-widget.d.ts +33 -0
- package/dist/view-selector-widget.d.ts.map +1 -0
- package/dist/view-selector-widget.js +62 -0
- package/dist/view-selector-widget.js.map +1 -0
- package/dist/zoom-widget.d.ts +14 -43
- package/dist/zoom-widget.d.ts.map +1 -1
- package/dist/zoom-widget.js +14 -56
- package/dist/zoom-widget.js.map +1 -1
- package/dist.min.js +3 -1
- package/package.json +4 -3
- package/src/compass-widget.tsx +44 -106
- package/src/context-menu-widget.tsx +115 -0
- package/src/fps-widget.tsx +67 -0
- package/src/fullscreen-widget.tsx +33 -86
- package/src/geocoder-widget.tsx +209 -0
- package/src/gimbal-widget.tsx +188 -0
- package/src/index.ts +58 -8
- package/src/info-widget.tsx +225 -0
- package/src/lib/components/button-group.tsx +16 -0
- package/src/lib/components/dropdown-menu.tsx +98 -0
- package/src/lib/components/grouped-icon-button.tsx +24 -0
- package/src/lib/components/icon-button.tsx +30 -0
- package/src/lib/components/icon-menu.tsx +89 -0
- package/src/lib/components/simple-menu.tsx +52 -0
- package/src/lib/geocode/geocoder-history.ts +73 -0
- package/src/lib/geocode/geocoder.ts +15 -0
- package/src/lib/geocode/geocoders.ts +199 -0
- package/src/loading-widget.tsx +67 -0
- package/src/reset-view-widget.tsx +8 -11
- package/src/scale-widget.tsx +183 -0
- package/src/screenshot-widget.tsx +9 -11
- package/src/splitter-widget.tsx +179 -0
- package/src/stats-widget.tsx +166 -0
- package/src/stylesheet.css +121 -4
- package/src/theme-widget.tsx +120 -0
- package/src/themes.ts +45 -12
- package/src/timeline-widget.tsx +155 -0
- package/src/view-selector-widget.tsx +108 -0
- package/src/zoom-widget.tsx +39 -113
- package/dist/components.d.ts +0 -4
- package/dist/components.d.ts.map +0 -1
- package/dist/components.js +0 -17
- package/dist/components.js.map +0 -1
- package/dist/widget-impl.d.ts +0 -29
- package/dist/widget-impl.d.ts.map +0 -1
- package/dist/widget-impl.js +0 -60
- package/dist/widget-impl.js.map +0 -1
- package/src/components.tsx +0 -38
- package/src/widget-impl.ts +0 -88
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Widget, WidgetProps } from '@deck.gl/core';
|
|
2
|
+
import type { Deck, PickingInfo, Viewport } from '@deck.gl/core';
|
|
3
|
+
export type InfoWidgetProps = WidgetProps & {
|
|
4
|
+
/** View to attach to and interact with. Required when using multiple views. */
|
|
5
|
+
viewId?: string | null;
|
|
6
|
+
/** InfoWidget mode */
|
|
7
|
+
mode: 'click' | 'hover' | 'static';
|
|
8
|
+
/** Get the popup contents from the selected element */
|
|
9
|
+
getTooltip?: (info: PickingInfo, widget: InfoWidget) => any;
|
|
10
|
+
/** Position at which to place popup (clicked point: [longitude, latitude]). */
|
|
11
|
+
position: [number, number];
|
|
12
|
+
/** Text of popup */
|
|
13
|
+
text?: string;
|
|
14
|
+
/** Visibility of info widget */
|
|
15
|
+
visible?: boolean;
|
|
16
|
+
/** Minimum offset (in pixels) to keep the popup away from the canvas edges. */
|
|
17
|
+
minOffset?: number;
|
|
18
|
+
onClick?: (widget: InfoWidget, info: PickingInfo) => boolean;
|
|
19
|
+
};
|
|
20
|
+
export declare class InfoWidget extends Widget<InfoWidgetProps> {
|
|
21
|
+
static defaultProps: Required<InfoWidgetProps>;
|
|
22
|
+
className: string;
|
|
23
|
+
placement: "fill";
|
|
24
|
+
viewId?: string | null;
|
|
25
|
+
viewport?: Viewport;
|
|
26
|
+
constructor(props: InfoWidgetProps);
|
|
27
|
+
setProps(props: Partial<InfoWidgetProps>): void;
|
|
28
|
+
onViewportChange(viewport: any): void;
|
|
29
|
+
onHover(info: PickingInfo): void;
|
|
30
|
+
onClick(info: PickingInfo): boolean;
|
|
31
|
+
onAdd({ deck, viewId }: {
|
|
32
|
+
deck: Deck<any>;
|
|
33
|
+
viewId: string | null;
|
|
34
|
+
}): HTMLDivElement;
|
|
35
|
+
onRenderHTML(rootElement: HTMLElement): void;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=info-widget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"info-widget.d.ts","sourceRoot":"","sources":["../src/info-widget.tsx"],"names":[],"mappings":"AACA,OAAO,EAAC,MAAM,EAAE,WAAW,EAAC,MAAM,eAAe,CAAC;AAClD,OAAO,KAAK,EAAC,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAC,MAAM,eAAe,CAAC;AAG/D,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG;IAC1C,+EAA+E;IAC/E,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,sBAAsB;IACtB,IAAI,EAAE,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAC;IACnC,uDAAuD;IACvD,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,KAAK,GAAG,CAAC;IAC5D,+EAA+E;IAC/E,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3B,oBAAoB;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gCAAgC;IAChC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,+EAA+E;IAC/E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,KAAK,OAAO,CAAC;CAC9D,CAAC;AAEF,qBAAa,UAAW,SAAQ,MAAM,CAAC,eAAe,CAAC;IACrD,MAAM,CAAC,YAAY,EAAE,QAAQ,CAAC,eAAe,CAAC,CAW5C;IAEF,SAAS,SAAsB;IAC/B,SAAS,SAAmB;IAC5B,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAQ;IAC9B,QAAQ,CAAC,EAAE,QAAQ,CAAC;gBAER,KAAK,EAAE,eAAe;IASlC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,eAAe,CAAC;IAIxC,gBAAgB,CAAC,QAAQ,KAAA;IAKzB,OAAO,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI;IAYhC,OAAO,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO;IAenC,KAAK,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,EAAE;QAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;QAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;KAAC,GAAG,cAAc;IAmB/E,YAAY,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI;CAsH7C"}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
2
|
+
/* global document */
|
|
3
|
+
import { Widget } from '@deck.gl/core';
|
|
4
|
+
import { render } from 'preact';
|
|
5
|
+
export class InfoWidget extends Widget {
|
|
6
|
+
constructor(props) {
|
|
7
|
+
super(props, InfoWidget.defaultProps);
|
|
8
|
+
this.className = 'deck-widget-info';
|
|
9
|
+
this.placement = 'fill';
|
|
10
|
+
this.viewId = null;
|
|
11
|
+
props.position = props.position || [0, 0];
|
|
12
|
+
props.text = props.text || '';
|
|
13
|
+
props.visible = props.visible || false;
|
|
14
|
+
// Set default minOffset if not provided
|
|
15
|
+
props.minOffset = props.minOffset ?? 0;
|
|
16
|
+
}
|
|
17
|
+
setProps(props) {
|
|
18
|
+
super.setProps(props);
|
|
19
|
+
}
|
|
20
|
+
onViewportChange(viewport) {
|
|
21
|
+
this.viewport = viewport;
|
|
22
|
+
this.updateHTML();
|
|
23
|
+
}
|
|
24
|
+
onHover(info) {
|
|
25
|
+
if (this.props.mode === 'hover' && this.props.getTooltip) {
|
|
26
|
+
const tooltip = this.props.getTooltip(info, this);
|
|
27
|
+
// hover tooltips should show over static and click infos
|
|
28
|
+
this.setProps({
|
|
29
|
+
visible: tooltip !== null,
|
|
30
|
+
...tooltip,
|
|
31
|
+
style: { zIndex: 1, ...tooltip?.style }
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
onClick(info) {
|
|
36
|
+
if (this.props.mode === 'click' && this.props.getTooltip) {
|
|
37
|
+
const tooltip = this.props.getTooltip(info, this);
|
|
38
|
+
this.setProps({
|
|
39
|
+
visible: tooltip !== null,
|
|
40
|
+
...tooltip
|
|
41
|
+
});
|
|
42
|
+
return tooltip !== null;
|
|
43
|
+
}
|
|
44
|
+
// Original behavior
|
|
45
|
+
return this.props.onClick?.(this, info) || false;
|
|
46
|
+
}
|
|
47
|
+
// TODO - Align with onCreateRootElement
|
|
48
|
+
onAdd({ deck, viewId }) {
|
|
49
|
+
const { className } = this.props;
|
|
50
|
+
const element = document.createElement('div');
|
|
51
|
+
element.classList.add('deck-widget', 'deck-widget-info');
|
|
52
|
+
if (className)
|
|
53
|
+
element.classList.add(className);
|
|
54
|
+
// Ensure absolute positioning relative to the deck container
|
|
55
|
+
const style = { margin: '0px', top: '0px', left: '0px', position: 'absolute' };
|
|
56
|
+
Object.entries(style).forEach(([key, value]) => element.style.setProperty(key, value));
|
|
57
|
+
this.deck = deck;
|
|
58
|
+
if (!viewId) {
|
|
59
|
+
this.viewport = deck.getViewports()[0];
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
this.viewport = deck.getViewports().find(viewport => viewport.id === viewId);
|
|
63
|
+
}
|
|
64
|
+
this.rootElement = element;
|
|
65
|
+
this.updateHTML();
|
|
66
|
+
return element;
|
|
67
|
+
}
|
|
68
|
+
onRenderHTML(rootElement) {
|
|
69
|
+
if (!this.viewport) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const [longitude, latitude] = this.props.position;
|
|
73
|
+
// Project the clicked geographic coordinate to canvas (x, y)
|
|
74
|
+
const [x, y] = this.viewport.project([longitude, latitude]);
|
|
75
|
+
const minOffset = this.props.minOffset || 0;
|
|
76
|
+
const gap = 10; // gap between clicked point and popup box
|
|
77
|
+
const arrowHeight = 8; // height of the triangle arrow
|
|
78
|
+
const arrowWidth = 16; // full width of the arrow
|
|
79
|
+
// Decide vertical orientation.
|
|
80
|
+
// If the clicked point is in the bottom half, place the popup above the point.
|
|
81
|
+
const isAbove = y > this.viewport.height / 2;
|
|
82
|
+
const background = (this.props.style && this.props.style.background) || 'rgba(255,255,255,0.9)';
|
|
83
|
+
// Render the popup container with a content box and a placeholder for the arrow.
|
|
84
|
+
// The container is positioned absolutely (initially at 0,0) and will be repositioned after measuring.
|
|
85
|
+
const ui = this.props.visible ? (_jsxs("div", { className: "popup-container", style: { position: 'absolute', left: 0, top: 0 }, children: [_jsx("div", { className: "popup-content", style: {
|
|
86
|
+
background,
|
|
87
|
+
padding: '10px',
|
|
88
|
+
position: 'relative',
|
|
89
|
+
// Include any additional styles
|
|
90
|
+
...this.props.style
|
|
91
|
+
}, children: this.props.text }), _jsx("div", { className: "popup-arrow", style: { position: 'absolute', width: '0px', height: '0px' } })] })) : null;
|
|
92
|
+
render(ui, rootElement);
|
|
93
|
+
// After rendering, measure the content and adjust positioning so that:
|
|
94
|
+
// - The popup (with its arrow) does not cover the clicked point.
|
|
95
|
+
// - The arrow's tip points to the clicked point.
|
|
96
|
+
// - The popup remains within the canvas bounds, with minOffset.
|
|
97
|
+
// eslint-disable-next-line max-statements, complexity
|
|
98
|
+
requestAnimationFrame(() => {
|
|
99
|
+
if (!this.props.visible || !rootElement.firstChild || !this.viewport)
|
|
100
|
+
return;
|
|
101
|
+
const container = rootElement.firstChild;
|
|
102
|
+
const contentEl = container.querySelector('.popup-content');
|
|
103
|
+
const arrowEl = container.querySelector('.popup-arrow');
|
|
104
|
+
if (!contentEl || !arrowEl)
|
|
105
|
+
return;
|
|
106
|
+
const contentRect = contentEl.getBoundingClientRect();
|
|
107
|
+
const popupWidth = contentRect.width;
|
|
108
|
+
const popupHeight = contentRect.height;
|
|
109
|
+
// Compute ideal horizontal position: center the popup on the clicked x
|
|
110
|
+
let computedLeft = x - popupWidth / 2;
|
|
111
|
+
// Compute vertical position based on orientation:
|
|
112
|
+
// If the popup is above, position its bottom edge (minus arrow & gap) at the clicked y.
|
|
113
|
+
// Otherwise, position its top edge (plus arrow & gap) at the clicked y.
|
|
114
|
+
let computedTop;
|
|
115
|
+
if (isAbove) {
|
|
116
|
+
computedTop = y - gap - arrowHeight - popupHeight;
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
computedTop = y + gap + arrowHeight;
|
|
120
|
+
}
|
|
121
|
+
// Ensure the popup (content) stays within horizontal bounds of the canvas
|
|
122
|
+
if (computedLeft < minOffset) {
|
|
123
|
+
computedLeft = minOffset;
|
|
124
|
+
}
|
|
125
|
+
if (computedLeft + popupWidth > this.viewport.width - minOffset) {
|
|
126
|
+
computedLeft = this.viewport.width - minOffset - popupWidth;
|
|
127
|
+
}
|
|
128
|
+
// Ensure the vertical position (including the arrow) stays within canvas bounds.
|
|
129
|
+
if (isAbove) {
|
|
130
|
+
if (computedTop < minOffset) {
|
|
131
|
+
computedTop = minOffset;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
else if (computedTop + popupHeight + arrowHeight > this.viewport.height - minOffset) {
|
|
135
|
+
computedTop = this.viewport.height - minOffset - popupHeight - arrowHeight;
|
|
136
|
+
}
|
|
137
|
+
// Update container position (remove any transform and set left/top explicitly)
|
|
138
|
+
container.style.left = `${computedLeft}px`;
|
|
139
|
+
container.style.top = `${computedTop}px`;
|
|
140
|
+
container.style.transform = '';
|
|
141
|
+
// Compute arrow's horizontal offset relative to the container.
|
|
142
|
+
// We want the arrow's tip to align with the clicked point.
|
|
143
|
+
let arrowLeft = x - computedLeft - arrowWidth / 2;
|
|
144
|
+
// Optionally constrain arrowLeft so it stays within the popup's width.
|
|
145
|
+
arrowLeft = Math.max(arrowLeft, 0);
|
|
146
|
+
arrowLeft = Math.min(arrowLeft, popupWidth - arrowWidth);
|
|
147
|
+
// Update arrow element's style based on orientation.
|
|
148
|
+
if (isAbove) {
|
|
149
|
+
// Popup is above the clicked point so arrow appears at the bottom of the popup.
|
|
150
|
+
arrowEl.style.left = `${arrowLeft}px`;
|
|
151
|
+
arrowEl.style.bottom = `-${arrowHeight}px`;
|
|
152
|
+
arrowEl.style.top = '';
|
|
153
|
+
arrowEl.style.borderLeft = `${arrowWidth / 2}px solid transparent`;
|
|
154
|
+
arrowEl.style.borderRight = `${arrowWidth / 2}px solid transparent`;
|
|
155
|
+
arrowEl.style.borderTop = `${arrowHeight}px solid ${background}`;
|
|
156
|
+
arrowEl.style.borderBottom = '';
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
// Popup is below the clicked point so arrow appears at the top.
|
|
160
|
+
arrowEl.style.left = `${arrowLeft}px`;
|
|
161
|
+
arrowEl.style.top = `-${arrowHeight}px`;
|
|
162
|
+
arrowEl.style.bottom = '';
|
|
163
|
+
arrowEl.style.borderLeft = `${arrowWidth / 2}px solid transparent`;
|
|
164
|
+
arrowEl.style.borderRight = `${arrowWidth / 2}px solid transparent`;
|
|
165
|
+
arrowEl.style.borderBottom = `${arrowHeight}px solid ${background}`;
|
|
166
|
+
arrowEl.style.borderTop = '';
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
InfoWidget.defaultProps = {
|
|
172
|
+
...Widget.defaultProps,
|
|
173
|
+
position: [0, 0],
|
|
174
|
+
text: '',
|
|
175
|
+
visible: false,
|
|
176
|
+
// Set default minOffset if not provided
|
|
177
|
+
minOffset: 0,
|
|
178
|
+
viewId: null,
|
|
179
|
+
mode: 'hover',
|
|
180
|
+
getTooltip: undefined,
|
|
181
|
+
onClick: undefined
|
|
182
|
+
};
|
|
183
|
+
//# sourceMappingURL=info-widget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"info-widget.js","sourceRoot":"","sources":["../src/info-widget.tsx"],"names":[],"mappings":";AAAA,qBAAqB;AACrB,OAAO,EAAC,MAAM,EAAc,MAAM,eAAe,CAAC;AAElD,OAAO,EAAC,MAAM,EAAM,MAAM,QAAQ,CAAC;AAoBnC,MAAM,OAAO,UAAW,SAAQ,MAAuB;IAmBrD,YAAY,KAAsB;QAChC,KAAK,CAAC,KAAK,EAAE,UAAU,CAAC,YAAY,CAAC,CAAC;QANxC,cAAS,GAAG,kBAAkB,CAAC;QAC/B,cAAS,GAAG,MAAe,CAAC;QAC5B,WAAM,GAAmB,IAAI,CAAC;QAK5B,KAAK,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAC1C,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC;QAC9B,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC;QACvC,wCAAwC;QACxC,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,IAAI,CAAC,CAAC;IACzC,CAAC;IAED,QAAQ,CAAC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
6
|
+
/** Renders a group of buttons with Widget CSS */
|
|
7
|
+
export declare const ButtonGroup: (props: ButtonGroupProps) => import("preact").JSX.Element;
|
|
8
|
+
//# sourceMappingURL=button-group.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"button-group.d.ts","sourceRoot":"","sources":["../../../src/lib/components/button-group.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,QAAQ,CAAC;AAE9C,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,WAAW,MAAC;CACb,CAAC;AAEF,iDAAiD;AACjD,eAAO,MAAM,WAAW,UAAW,gBAAgB,iCAGlD,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "preact/jsx-runtime";
|
|
2
|
+
/** Renders a group of buttons with Widget CSS */
|
|
3
|
+
export const ButtonGroup = (props) => {
|
|
4
|
+
const { children, orientation } = props;
|
|
5
|
+
return _jsx("div", { className: `deck-widget-button-group ${orientation}`, children: children });
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=button-group.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"button-group.js","sourceRoot":"","sources":["../../../src/lib/components/button-group.tsx"],"names":[],"mappings":";AAWA,iDAAiD;AACjD,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAuB,EAAE,EAAE;IACrD,MAAM,EAAC,QAAQ,EAAE,WAAW,EAAC,GAAG,KAAK,CAAC;IACtC,OAAO,cAAK,SAAS,EAAE,4BAA4B,WAAW,EAAE,YAAG,QAAQ,GAAO,CAAC;AACrF,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type JSX } from 'preact';
|
|
2
|
+
export type DropdownMenuProps = {
|
|
3
|
+
menuItems: string[];
|
|
4
|
+
onSelect: (value: string) => void;
|
|
5
|
+
style?: JSX.CSSProperties;
|
|
6
|
+
};
|
|
7
|
+
export declare const DropdownMenu: (props: DropdownMenuProps) => JSX.Element;
|
|
8
|
+
//# sourceMappingURL=dropdown-menu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dropdown-menu.d.ts","sourceRoot":"","sources":["../../../src/lib/components/dropdown-menu.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAC,KAAK,GAAG,EAAC,MAAM,QAAQ,CAAC;AAGhC,MAAM,MAAM,iBAAiB,GAAG;IAC9B,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,KAAK,CAAC,EAAE,GAAG,CAAC,aAAa,CAAC;CAC3B,CAAC;AAEF,eAAO,MAAM,YAAY,UAAW,iBAAiB,gBAoFpD,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
2
|
+
import { useState, useRef, useEffect } from 'preact/hooks';
|
|
3
|
+
export const DropdownMenu = (props) => {
|
|
4
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
5
|
+
const dropdownRef = useRef(null);
|
|
6
|
+
const toggleDropdown = () => setIsOpen(!isOpen);
|
|
7
|
+
const handleClickOutside = (event) => {
|
|
8
|
+
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
|
9
|
+
setIsOpen(false);
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
14
|
+
return () => {
|
|
15
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
16
|
+
};
|
|
17
|
+
}, []);
|
|
18
|
+
const handleSelect = (value) => {
|
|
19
|
+
props.onSelect(value);
|
|
20
|
+
setIsOpen(false);
|
|
21
|
+
};
|
|
22
|
+
return (_jsxs("div", { className: "dropdown-container", ref: dropdownRef, style: {
|
|
23
|
+
position: 'relative',
|
|
24
|
+
display: 'inline-block',
|
|
25
|
+
...props.style
|
|
26
|
+
}, children: [_jsx("button", { onClick: toggleDropdown, style: {
|
|
27
|
+
width: '30px',
|
|
28
|
+
height: '30px',
|
|
29
|
+
display: 'flex',
|
|
30
|
+
alignItems: 'center',
|
|
31
|
+
justifyContent: 'center',
|
|
32
|
+
border: '1px solid #ccc',
|
|
33
|
+
borderRadius: '4px',
|
|
34
|
+
background: '#fff',
|
|
35
|
+
cursor: 'pointer',
|
|
36
|
+
padding: 0
|
|
37
|
+
}, children: "\u25BC" }), isOpen && (_jsx("ul", { style: {
|
|
38
|
+
position: 'absolute',
|
|
39
|
+
top: '100%',
|
|
40
|
+
right: '100%',
|
|
41
|
+
background: '#fff',
|
|
42
|
+
border: '1px solid #ccc',
|
|
43
|
+
borderRadius: '4px',
|
|
44
|
+
listStyle: 'none',
|
|
45
|
+
padding: '4px 0',
|
|
46
|
+
margin: 0,
|
|
47
|
+
zIndex: 1000,
|
|
48
|
+
minWidth: '200px'
|
|
49
|
+
}, children: props.menuItems.map(item => (_jsx("li", { onClick: () => handleSelect(item), style: {
|
|
50
|
+
padding: '4px 8px',
|
|
51
|
+
cursor: 'pointer',
|
|
52
|
+
whiteSpace: 'nowrap'
|
|
53
|
+
}, children: item }, item))) }))] }));
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=dropdown-menu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dropdown-menu.js","sourceRoot":"","sources":["../../../src/lib/components/dropdown-menu.tsx"],"names":[],"mappings":";AAKA,OAAO,EAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAC,MAAM,cAAc,CAAC;AAQzD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAwB,EAAE,EAAE;IACvD,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC5C,MAAM,WAAW,G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M,IAAI,CACT,aACE,KAAK,EAAE;oBACL,QAAQ,EAAE,UAAU;oBACpB,GAAG,EAAE,MAAM;oBACX,KAAK,EAAE,MAAM;oBACb,UAAU,EAAE,MAAM;oBAClB,MAAM,EAAE,gBAAgB;oBACxB,YAAY,EAAE,KAAK;oBACnB,SAAS,EAAE,MAAM;oBACjB,OAAO,EAAE,OAAO;oBAChB,MAAM,EAAE,CAAC;oBACT,MAAM,EAAE,IAAI;oBACZ,QAAQ,EAAE,OAAO;iBAClB,YAEA,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAC3B,aAEE,OAAO,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,EACjC,KAAK,EAAE;wBACL,OAAO,EAAE,SAAS;wBAClB,MAAM,EAAE,SAAS;wBACjB,UAAU,EAAE,QAAQ;qBACrB,YAEA,IAAI,IARA,IAAI,CASN,CACN,CAAC,GACC,CACN,IACG,CACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type GroupedIconButtonProps = {
|
|
2
|
+
className?: string;
|
|
3
|
+
label: string;
|
|
4
|
+
onClick: () => void;
|
|
5
|
+
};
|
|
6
|
+
/** Renders an icon button as part of a ButtonGroup */
|
|
7
|
+
export declare const GroupedIconButton: (props: any) => import("preact").JSX.Element;
|
|
8
|
+
//# sourceMappingURL=grouped-icon-button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grouped-icon-button.d.ts","sourceRoot":"","sources":["../../../src/lib/components/grouped-icon-button.tsx"],"names":[],"mappings":"AAIA,MAAM,MAAM,sBAAsB,GAAG;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAEF,sDAAsD;AACtD,eAAO,MAAM,iBAAiB,8CAY7B,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "preact/jsx-runtime";
|
|
2
|
+
/** Renders an icon button as part of a ButtonGroup */
|
|
3
|
+
export const GroupedIconButton = props => {
|
|
4
|
+
const { className, label, onClick } = props;
|
|
5
|
+
return (_jsx("button", { className: `deck-widget-icon-button ${className || ''}`, type: "button", onClick: onClick, title: label, children: _jsx("div", { className: "deck-widget-icon" }) }));
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=grouped-icon-button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grouped-icon-button.js","sourceRoot":"","sources":["../../../src/lib/components/grouped-icon-button.tsx"],"names":[],"mappings":";AAUA,sDAAsD;AACtD,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,CAAC,EAAE;IACvC,MAAM,EAAC,SAAS,EAAE,KAAK,EAAE,OAAO,EAAC,GAAG,KAAK,CAAC;IAC1C,OAAO,CACL,iBACE,SAAS,EAAE,2BAA2B,SAAS,IAAI,EAAE,EAAE,EACvD,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,YAEZ,cAAK,SAAS,EAAC,kBAAkB,GAAG,GAC7B,CACV,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ComponentChildren } from 'preact';
|
|
2
|
+
export type IconButtonProps = {
|
|
3
|
+
className: string;
|
|
4
|
+
label: string;
|
|
5
|
+
onClick: (event?: any) => unknown;
|
|
6
|
+
/** Optional icon or element to render inside the button */
|
|
7
|
+
children?: ComponentChildren;
|
|
8
|
+
};
|
|
9
|
+
/** Renders a button component with widget CSS */
|
|
10
|
+
export declare const IconButton: (props: IconButtonProps) => import("preact").JSX.Element;
|
|
11
|
+
//# sourceMappingURL=icon-button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icon-button.d.ts","sourceRoot":"","sources":["../../../src/lib/components/icon-button.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,QAAQ,CAAC;AAE9C,MAAM,MAAM,eAAe,GAAG;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,CAAC,KAAK,CAAC,KAAA,KAAK,OAAO,CAAC;IAC7B,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,iBAAiB,CAAC;CAC9B,CAAC;AAEF,iDAAiD;AACjD,eAAO,MAAM,UAAU,UAAW,eAAe,iCAchD,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "preact/jsx-runtime";
|
|
2
|
+
/** Renders a button component with widget CSS */
|
|
3
|
+
export const IconButton = (props) => {
|
|
4
|
+
const { className, label, onClick, children } = props;
|
|
5
|
+
return (_jsx("div", { className: "deck-widget-button", children: _jsx("button", { className: `deck-widget-icon-button ${className}`, type: "button", onClick: onClick, title: label, children: children ? children : _jsx("div", { className: "deck-widget-icon" }) }) }));
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=icon-button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icon-button.js","sourceRoot":"","sources":["../../../src/lib/components/icon-button.tsx"],"names":[],"mappings":";AAcA,iDAAiD;AACjD,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAsB,EAAE,EAAE;IACnD,MAAM,EAAC,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAC,GAAG,KAAK,CAAC;IACpD,OAAO,CACL,cAAK,SAAS,EAAC,oBAAoB,YACjC,iBACE,SAAS,EAAE,2BAA2B,SAAS,EAAE,EACjD,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,YAEX,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,cAAK,SAAS,EAAC,kBAAkB,GAAG,GACpD,GACL,CACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { JSX } from 'preact';
|
|
2
|
+
export type IconMenuProps<KeyType = string> = {
|
|
3
|
+
className: string;
|
|
4
|
+
icon?: () => JSX.Element;
|
|
5
|
+
label?: string;
|
|
6
|
+
menuItems: {
|
|
7
|
+
value: KeyType;
|
|
8
|
+
icon: () => JSX.Element;
|
|
9
|
+
label: string;
|
|
10
|
+
}[];
|
|
11
|
+
initialItem: KeyType;
|
|
12
|
+
onItemSelected: (item: KeyType) => void;
|
|
13
|
+
};
|
|
14
|
+
/** A component that renders an icon popup menu */
|
|
15
|
+
export declare function IconMenu<KeyType extends string>(props: IconMenuProps<KeyType>): JSX.Element;
|
|
16
|
+
//# sourceMappingURL=icon-menu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icon-menu.d.ts","sourceRoot":"","sources":["../../../src/lib/components/icon-menu.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,GAAG,EAAC,MAAM,QAAQ,CAAC;AAuBhC,MAAM,MAAM,aAAa,CAAC,OAAO,GAAG,MAAM,IAAI;IAC5C,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,GAAG,CAAC,OAAO,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,EAAE;QAAC,KAAK,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,MAAM,GAAG,CAAC,OAAO,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC,EAAE,CAAC;IACtE,WAAW,EAAE,OAAO,CAAC;IACrB,cAAc,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;CACzC,CAAC;AAEF,kDAAkD;AAClD,wBAAgB,QAAQ,CAAC,OAAO,SAAS,MAAM,EAAE,KAAK,EAAE,aAAa,CAAC,OAAO,CAAC,eAuD7E"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
2
|
+
import { useState, useRef, useEffect } from 'preact/hooks';
|
|
3
|
+
import { IconButton } from "./icon-button.js";
|
|
4
|
+
const MENU_STYLE = {
|
|
5
|
+
position: 'absolute',
|
|
6
|
+
top: '100%',
|
|
7
|
+
left: 0,
|
|
8
|
+
background: 'white',
|
|
9
|
+
border: '1px solid #ccc',
|
|
10
|
+
borderRadius: '4px',
|
|
11
|
+
marginTop: '4px',
|
|
12
|
+
zIndex: 100
|
|
13
|
+
};
|
|
14
|
+
const MENU_ITEM_STYLE = {
|
|
15
|
+
background: 'white',
|
|
16
|
+
border: 'none',
|
|
17
|
+
padding: '4px',
|
|
18
|
+
cursor: 'pointer',
|
|
19
|
+
pointerEvents: 'auto'
|
|
20
|
+
};
|
|
21
|
+
/** A component that renders an icon popup menu */
|
|
22
|
+
export function IconMenu(props) {
|
|
23
|
+
const [menuOpen, setMenuOpen] = useState(false);
|
|
24
|
+
const containerRef = useRef(null);
|
|
25
|
+
// Close the menu when clicking outside.
|
|
26
|
+
const handleClickOutside = (event) => {
|
|
27
|
+
if (containerRef.current && !containerRef.current.contains(event.target)) {
|
|
28
|
+
setMenuOpen(false);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
33
|
+
return () => {
|
|
34
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
35
|
+
};
|
|
36
|
+
}, [containerRef]);
|
|
37
|
+
const [selectedItem, setSelectedItem] = useState(props.initialItem);
|
|
38
|
+
const handleSelectItem = (item) => {
|
|
39
|
+
setSelectedItem(item);
|
|
40
|
+
setMenuOpen(false);
|
|
41
|
+
props.onItemSelected(item);
|
|
42
|
+
};
|
|
43
|
+
const handleButtonClick = () => setMenuOpen(!menuOpen);
|
|
44
|
+
const selectedMenuItem = props.menuItems.find(item => item.value === selectedItem);
|
|
45
|
+
const label = props.label || selectedMenuItem?.label || '';
|
|
46
|
+
const Icon = (props.icon || selectedMenuItem?.icon);
|
|
47
|
+
return (_jsxs("div", { style: { position: 'relative', display: 'inline-block' }, ref: containerRef, children: [_jsx(IconButton, { className: props.className, label: label, onClick: handleButtonClick, children: _jsx(Icon, {}) }), menuOpen && (_jsx("div", { style: MENU_STYLE, children: _jsx("div", { style: { display: 'flex', flexDirection: 'column' }, children: props.menuItems.map(item => (_jsx("button", { style: MENU_ITEM_STYLE, title: item.label, onClick: () => handleSelectItem(item.value), children: item.icon }, item.value))) }) }))] }));
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=icon-menu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icon-menu.js","sourceRoot":"","sources":["../../../src/lib/components/icon-menu.tsx"],"names":[],"mappings":";AACA,OAAO,EAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAC,MAAM,cAAc,CAAC;AACzD,OAAO,EAAC,UAAU,EAAC,yBAAsB;AAEzC,MAAM,UAAU,GAAsB;IACpC,QAAQ,EAAE,UAAU;IACpB,GAAG,EAAE,MAAM;IACX,IAAI,EAAE,CAAC;IACP,UAAU,EAAE,OAAO;IACnB,MAAM,EAAE,gBAAgB;IACxB,YAAY,EAAE,KAAK;IACnB,SAAS,EAAE,KAAK;IAChB,MAAM,EAAE,GAAG;CACZ,CAAC;AAEF,MAAM,eAAe,GAAsB;IACzC,UAAU,EAAE,OAAO;IACnB,MAAM,EAAE,MAAM;IACd,OAAO,EAAE,KAAK;IACd,MAAM,EAAE,SAAS;IACjB,aAAa,EAAE,MAAM;CACtB,CAAC;AAWF,kDAAkD;AAClD,MAAM,UAAU,QAAQ,CAAyB,KAA6B;IAC5E,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAChD,MAAM,YAAY,GAAG,MAAM,CAAiB,IAAI,CAAC,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AU,EAAE,OAAO,EAAE,cAAc,EAAC,EAAE,GAAG,EAAE,YAAY,aAC5E,KAAC,UAAU,IAAC,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,iBAAiB,YAC9E,KAAC,IAAI,KAAG,GACG,EACZ,QAAQ,IAAI,CACX,cAAK,KAAK,EAAE,UAAU,YACpB,cAAK,KAAK,EAAE,EAAC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAC,YACnD,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAC3B,iBAEE,KAAK,EAAE,eAAe,EACtB,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,OAAO,EAAE,GAAG,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,YAE1C,IAAI,CAAC,IAAI,IALL,IAAI,CAAC,KAAK,CAMR,CACV,CAAC,GACE,GACF,CACP,IACG,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { JSX } from 'preact';
|
|
2
|
+
export type SimpleMenuProps = {
|
|
3
|
+
menuItems: {
|
|
4
|
+
key: string;
|
|
5
|
+
label: string;
|
|
6
|
+
}[];
|
|
7
|
+
onItemSelected: (key: string) => void;
|
|
8
|
+
position: {
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
};
|
|
12
|
+
style?: JSX.CSSProperties;
|
|
13
|
+
};
|
|
14
|
+
/** Renders a simple dropdown menu at an arbitrary position */
|
|
15
|
+
export declare const SimpleMenu: (props: SimpleMenuProps) => JSX.Element;
|
|
16
|
+
//# sourceMappingURL=simple-menu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"simple-menu.d.ts","sourceRoot":"","sources":["../../../src/lib/components/simple-menu.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,GAAG,EAAC,MAAM,QAAQ,CAAC;AAqBhC,MAAM,MAAM,eAAe,GAAG;IAC5B,SAAS,EAAE;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC,EAAE,CAAC;IAC1C,cAAc,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,QAAQ,EAAE;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAC,CAAC;IACjC,KAAK,CAAC,EAAE,GAAG,CAAC,aAAa,CAAC;CAC3B,CAAC;AAEF,8DAA8D;AAC9D,eAAO,MAAM,UAAU,UAAW,eAAe,gBAsBhD,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx } from "preact/jsx-runtime";
|
|
2
|
+
const MENU_STYLE = {
|
|
3
|
+
position: 'absolute',
|
|
4
|
+
top: '100%',
|
|
5
|
+
left: 0,
|
|
6
|
+
background: 'white',
|
|
7
|
+
border: '1px solid #ccc',
|
|
8
|
+
borderRadius: '4px',
|
|
9
|
+
marginTop: '4px',
|
|
10
|
+
zIndex: 100
|
|
11
|
+
};
|
|
12
|
+
const MENU_ITEM_STYLE = {
|
|
13
|
+
background: 'white',
|
|
14
|
+
border: 'none',
|
|
15
|
+
padding: '4px',
|
|
16
|
+
cursor: 'pointer',
|
|
17
|
+
pointerEvents: 'auto'
|
|
18
|
+
};
|
|
19
|
+
/** Renders a simple dropdown menu at an arbitrary position */
|
|
20
|
+
export const SimpleMenu = (props) => {
|
|
21
|
+
const { menuItems, onItemSelected, position, style } = props;
|
|
22
|
+
const styleOverride = {
|
|
23
|
+
...MENU_STYLE,
|
|
24
|
+
...style,
|
|
25
|
+
left: `${position.x}px`,
|
|
26
|
+
top: `${position.y}px`
|
|
27
|
+
};
|
|
28
|
+
return (_jsx("div", { style: styleOverride, children: menuItems.map(({ key, label }) => (_jsx("button", { style: { ...MENU_ITEM_STYLE, display: 'block' }, onClick: _ => onItemSelected(key), children: label }, key))) }));
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=simple-menu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"simple-menu.js","sourceRoot":"","sources":["../../../src/lib/components/simple-menu.tsx"],"names":[],"mappings":";AAEA,MAAM,UAAU,GAAsB;IACpC,QAAQ,EAAE,UAAU;IACpB,GAAG,EAAE,MAAM;IACX,IAAI,EAAE,CAAC;IACP,UAAU,EAAE,OAAO;IACnB,MAAM,EAAE,gBAAgB;IACxB,YAAY,EAAE,KAAK;IACnB,SAAS,EAAE,KAAK;IAChB,MAAM,EAAE,GAAG;CACZ,CAAC;AAEF,MAAM,eAAe,GAAsB;IACzC,UAAU,EAAE,OAAO;IACnB,MAAM,EAAE,MAAM;IACd,OAAO,EAAE,KAAK;IACd,MAAM,EAAE,SAAS;IACjB,aAAa,EAAE,MAAM;CACtB,CAAC;AASF,8DAA8D;AAC9D,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAsB,EAAE,EAAE;IACnD,MAAM,EAAC,SAAS,EAAE,cAAc,EAAE,QAAQ,EAAE,KAAK,EAAC,GAAG,KAAK,CAAC;IAC3D,MAAM,aAAa,GAAsB;QACvC,GAAG,UAAU;QACb,GAAG,KAAK;QACR,IAAI,EAAE,GAAG,QAAQ,CAAC,CAAC,IAAI;QACvB,GAAG,EAAE,GAAG,QAAQ,CAAC,CAAC,IAAI;KACvB,CAAC;IAEF,OAAO,CACL,cAAK,KAAK,EAAE,aAAa,YACtB,SAAS,CAAC,GAAG,CAAC,CAAC,EAAC,GAAG,EAAE,KAAK,EAAC,EAAE,EAAE,CAAC,CAC/B,iBAEE,KAAK,EAAE,EAAC,GAAG,eAAe,EAAE,OAAO,EAAE,OAAO,EAAC,EAC7C,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,cAAc,CAAC,GAAG,CAAC,YAEhC,KAAK,IAJD,GAAG,CAKD,CACV,CAAC,GACE,CACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type Geocoder } from "./geocoder.js";
|
|
2
|
+
export type GeocoderHistoryProps = {
|
|
3
|
+
maxEntries?: number;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* An internal, experimental helper class for storing a list of locations in local storage.
|
|
7
|
+
* @todo Remove the UI related state.
|
|
8
|
+
*/
|
|
9
|
+
export declare class GeocoderHistory {
|
|
10
|
+
props: Required<GeocoderHistoryProps>;
|
|
11
|
+
addressText: string;
|
|
12
|
+
errorText: string;
|
|
13
|
+
addressHistory: string[];
|
|
14
|
+
constructor(props: GeocoderHistoryProps);
|
|
15
|
+
/** PErform geocoding */
|
|
16
|
+
geocode(geocoder: Geocoder, address: string, apiKey: string): Promise<{
|
|
17
|
+
longitude: number;
|
|
18
|
+
latitude: number;
|
|
19
|
+
} | null>;
|
|
20
|
+
loadPreviousAddresses(): string[];
|
|
21
|
+
storeAddress(address: string): void;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=geocoder-history.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geocoder-history.d.ts","sourceRoot":"","sources":["../../../src/lib/geocode/geocoder-history.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,KAAK,QAAQ,EAAC,sBAAmB;AAKzC,MAAM,MAAM,oBAAoB,GAAG;IACjC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;GAGG;AACH,qBAAa,eAAe;IAC1B,KAAK,EAAE,QAAQ,CAAC,oBAAoB,CAAC,CAAC;IACtC,WAAW,SAAM;IACjB,SAAS,SAAM;IACf,cAAc,EAAE,MAAM,EAAE,CAAM;gBAElB,KAAK,EAAE,oBAAoB;IAKvC,wBAAwB;IAClB,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;;;;IAgBjE,qBAAqB,IAAI,MAAM,EAAE;IAcjC,YAAY,CAAC,OAAO,EAAE,MAAM;CAa7B"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
const CURRENT_LOCATION = 'current';
|
|
5
|
+
const LOCAL_STORAGE_KEY = 'deck-geocoder-history';
|
|
6
|
+
/**
|
|
7
|
+
* An internal, experimental helper class for storing a list of locations in local storage.
|
|
8
|
+
* @todo Remove the UI related state.
|
|
9
|
+
*/
|
|
10
|
+
export class GeocoderHistory {
|
|
11
|
+
constructor(props) {
|
|
12
|
+
this.addressText = '';
|
|
13
|
+
this.errorText = '';
|
|
14
|
+
this.addressHistory = [];
|
|
15
|
+
this.props = { maxEntries: 5, ...props };
|
|
16
|
+
this.addressHistory = this.loadPreviousAddresses();
|
|
17
|
+
}
|
|
18
|
+
/** PErform geocoding */
|
|
19
|
+
async geocode(geocoder, address, apiKey) {
|
|
20
|
+
this.errorText = '';
|
|
21
|
+
this.addressText = address;
|
|
22
|
+
try {
|
|
23
|
+
const coordinates = await geocoder.geocode(address, apiKey);
|
|
24
|
+
if (coordinates) {
|
|
25
|
+
this.storeAddress(this.addressText);
|
|
26
|
+
return coordinates;
|
|
27
|
+
}
|
|
28
|
+
this.errorText = 'Invalid address';
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
this.errorText = `${error.message}`;
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
loadPreviousAddresses() {
|
|
36
|
+
try {
|
|
37
|
+
const stored = window.localStorage.getItem(LOCAL_STORAGE_KEY);
|
|
38
|
+
const list = stored && JSON.parse(stored);
|
|
39
|
+
const addresses = Array.isArray(list)
|
|
40
|
+
? list.filter((v) => typeof v === 'string')
|
|
41
|
+
: [];
|
|
42
|
+
return addresses;
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
// ignore
|
|
46
|
+
}
|
|
47
|
+
return [];
|
|
48
|
+
}
|
|
49
|
+
storeAddress(address) {
|
|
50
|
+
const cleaned = address.trim();
|
|
51
|
+
if (!cleaned || cleaned === CURRENT_LOCATION) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const deduped = [cleaned, ...this.addressHistory.filter(a => a !== cleaned)];
|
|
55
|
+
this.addressHistory = deduped.slice(0, this.props.maxEntries);
|
|
56
|
+
try {
|
|
57
|
+
window.localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify(this.addressHistory));
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
// ignore
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=geocoder-history.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geocoder-history.js","sourceRoot":"","sources":["../../../src/lib/geocode/geocoder-history.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAIpC,MAAM,gBAAgB,GAAG,SAAS,CAAC;AACnC,MAAM,iBAAiB,GAAG,uBAAuB,CAAC;AAMlD;;;GAGG;AACH,MAAM,OAAO,eAAe;IAM1B,YAAY,KAA2B;QAJvC,gBAAW,GAAG,EAAE,CAAC;QACjB,cAAS,GAAG,EAAE,CAAC;QACf,mBAAc,GAAa,EAAE,CAAC;QAG5B,IAAI,CAAC,KAAK,GAAG,EAAC,UAAU,EAAE,CAAC,EAAE,GAAG,KAAK,EAAC,CAAC;QACvC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,qBAAqB,EAAE,CAAC;IACrD,CAAC;IAED,wBAAwB;IACxB,KAAK,CAAC,OAAO,CAAC,QAAkB,EAAE,OAAe,EAAE,MAAc;QAC/D,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QACpB,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC;QAC3B,IAAI,CAAC;YACH,MAAM,WAAW,GAAG,MAAM,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