@deck.gl/widgets 9.2.11 → 9.3.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.js +5 -5
- package/dist/compass-widget.js.map +1 -1
- package/dist/context-menu-widget.d.ts +23 -18
- package/dist/context-menu-widget.d.ts.map +1 -1
- package/dist/context-menu-widget.js +44 -48
- package/dist/context-menu-widget.js.map +1 -1
- package/dist/dist.dev.js +2533 -420
- package/dist/fullscreen-widget.js +1 -1
- package/dist/fullscreen-widget.js.map +1 -1
- package/dist/geocoder-widget.d.ts +2 -4
- package/dist/geocoder-widget.d.ts.map +1 -1
- package/dist/geocoder-widget.js +16 -20
- package/dist/geocoder-widget.js.map +1 -1
- package/dist/gimbal-widget.d.ts +0 -3
- package/dist/gimbal-widget.d.ts.map +1 -1
- package/dist/gimbal-widget.js +4 -22
- package/dist/gimbal-widget.js.map +1 -1
- package/dist/index.cjs +921 -370
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/info-widget.d.ts +38 -17
- package/dist/info-widget.d.ts.map +1 -1
- package/dist/info-widget.js +40 -130
- package/dist/info-widget.js.map +1 -1
- package/dist/lib/components/dropdown-menu.d.ts +10 -4
- package/dist/lib/components/dropdown-menu.d.ts.map +1 -1
- package/dist/lib/components/dropdown-menu.js +12 -7
- package/dist/lib/components/dropdown-menu.js.map +1 -1
- package/dist/lib/components/icon-menu.d.ts.map +1 -1
- package/dist/lib/components/icon-menu.js +2 -3
- package/dist/lib/components/icon-menu.js.map +1 -1
- package/dist/lib/components/popover.d.ts +30 -0
- package/dist/lib/components/popover.d.ts.map +1 -0
- package/dist/lib/components/popover.js +93 -0
- package/dist/lib/components/popover.js.map +1 -0
- package/dist/lib/components/range-input.d.ts +26 -0
- package/dist/lib/components/range-input.d.ts.map +1 -0
- package/dist/lib/components/range-input.js +261 -0
- package/dist/lib/components/range-input.js.map +1 -0
- package/dist/lib/components/user-content.d.ts +8 -0
- package/dist/lib/components/user-content.d.ts.map +1 -0
- package/dist/lib/components/user-content.js +15 -0
- package/dist/lib/components/user-content.js.map +1 -0
- package/dist/popup-widget.d.ts +63 -0
- package/dist/popup-widget.d.ts.map +1 -0
- package/dist/popup-widget.js +70 -0
- package/dist/popup-widget.js.map +1 -0
- package/dist/reset-view-widget.d.ts +1 -1
- package/dist/reset-view-widget.d.ts.map +1 -1
- package/dist/reset-view-widget.js +12 -11
- package/dist/reset-view-widget.js.map +1 -1
- package/dist/scrollbar-widget.d.ts +68 -0
- package/dist/scrollbar-widget.d.ts.map +1 -0
- package/dist/scrollbar-widget.js +181 -0
- package/dist/scrollbar-widget.js.map +1 -0
- package/dist/stats-widget.d.ts +4 -0
- package/dist/stats-widget.d.ts.map +1 -1
- package/dist/stats-widget.js +3 -3
- package/dist/stats-widget.js.map +1 -1
- package/dist/stylesheet.css +244 -29
- package/dist/theme-widget.d.ts.map +1 -1
- package/dist/theme-widget.js +7 -5
- package/dist/theme-widget.js.map +1 -1
- package/dist/themes.d.ts +30 -0
- package/dist/themes.d.ts.map +1 -1
- package/dist/themes.js +28 -4
- package/dist/themes.js.map +1 -1
- package/dist/timeline-widget.d.ts +25 -6
- package/dist/timeline-widget.d.ts.map +1 -1
- package/dist/timeline-widget.js +46 -18
- package/dist/timeline-widget.js.map +1 -1
- package/dist/zoom-widget.d.ts +2 -8
- package/dist/zoom-widget.d.ts.map +1 -1
- package/dist/zoom-widget.js +23 -18
- package/dist/zoom-widget.js.map +1 -1
- package/dist.min.js +2 -2
- package/package.json +4 -3
- package/src/compass-widget.tsx +5 -5
- package/src/context-menu-widget.tsx +86 -76
- package/src/fullscreen-widget.tsx +1 -1
- package/src/geocoder-widget.tsx +17 -24
- package/src/gimbal-widget.tsx +4 -26
- package/src/index.ts +11 -6
- package/src/info-widget.tsx +93 -157
- package/src/lib/components/dropdown-menu.tsx +42 -20
- package/src/lib/components/icon-menu.tsx +3 -4
- package/src/lib/components/popover.tsx +167 -0
- package/src/lib/components/range-input.tsx +432 -0
- package/src/lib/components/user-content.tsx +30 -0
- package/src/popup-widget.tsx +163 -0
- package/src/reset-view-widget.tsx +12 -11
- package/src/scrollbar-widget.tsx +288 -0
- package/src/stats-widget.tsx +10 -4
- package/src/stylesheet.css +244 -29
- package/src/theme-widget.tsx +7 -5
- package/src/themes.ts +35 -4
- package/src/timeline-widget.tsx +96 -33
- package/src/zoom-widget.tsx +25 -21
- package/dist/lib/components/grouped-icon-button.d.ts +0 -10
- package/dist/lib/components/grouped-icon-button.d.ts.map +0 -1
- package/dist/lib/components/grouped-icon-button.js +0 -7
- package/dist/lib/components/grouped-icon-button.js.map +0 -1
- package/dist/lib/components/simple-menu.d.ts +0 -16
- package/dist/lib/components/simple-menu.d.ts.map +0 -1
- package/dist/lib/components/simple-menu.js +0 -30
- package/dist/lib/components/simple-menu.js.map +0 -1
- package/src/lib/components/grouped-icon-button.tsx +0 -27
- package/src/lib/components/simple-menu.tsx +0 -52
package/src/themes.ts
CHANGED
|
@@ -30,6 +30,13 @@ export type DeckWidgetTheme = {
|
|
|
30
30
|
'--menu-shadow'?: string;
|
|
31
31
|
'--menu-text'?: string;
|
|
32
32
|
'--menu-item-hover'?: string;
|
|
33
|
+
// scrollbar
|
|
34
|
+
'--range-step-button-size'?: string;
|
|
35
|
+
'--range-track-size'?: string;
|
|
36
|
+
'--range-thumb-size'?: string;
|
|
37
|
+
'--range-track-color'?: string;
|
|
38
|
+
'--range-thumb-color'?: string;
|
|
39
|
+
'--range-decoration-active-color'?: string;
|
|
33
40
|
};
|
|
34
41
|
|
|
35
42
|
export const LightTheme = {
|
|
@@ -52,7 +59,13 @@ export const LightTheme = {
|
|
|
52
59
|
'--menu-border': 'unset',
|
|
53
60
|
'--menu-shadow': '0px 0px 8px 0px rgba(0, 0, 0, 0.25)',
|
|
54
61
|
'--menu-text': 'rgb(24, 24, 26, 1)',
|
|
55
|
-
'--menu-item-hover': 'rgba(0, 0, 0, 0.08)'
|
|
62
|
+
'--menu-item-hover': 'rgba(0, 0, 0, 0.08)',
|
|
63
|
+
'--range-step-button-size': '24px',
|
|
64
|
+
'--range-track-size': '16px',
|
|
65
|
+
'--range-thumb-size': '10px',
|
|
66
|
+
'--range-track-color': '#d8d8e5',
|
|
67
|
+
'--range-thumb-color': '#616166',
|
|
68
|
+
'--range-decoration-active-color': '#f8dd50'
|
|
56
69
|
} as const satisfies Required<DeckWidgetTheme>;
|
|
57
70
|
|
|
58
71
|
export const DarkTheme = {
|
|
@@ -75,7 +88,13 @@ export const DarkTheme = {
|
|
|
75
88
|
'--menu-border': 'unset',
|
|
76
89
|
'--menu-shadow': '0px 0px 8px 0px rgba(0, 0, 0, 0.25)',
|
|
77
90
|
'--menu-text': 'rgb(215, 214, 229, 1)',
|
|
78
|
-
'--menu-item-hover': 'rgba(255, 255, 255, 0.1)'
|
|
91
|
+
'--menu-item-hover': 'rgba(255, 255, 255, 0.1)',
|
|
92
|
+
'--range-step-button-size': '24px',
|
|
93
|
+
'--range-track-size': '16px',
|
|
94
|
+
'--range-thumb-size': '10px',
|
|
95
|
+
'--range-track-color': '#2c2c30',
|
|
96
|
+
'--range-thumb-color': '#9e9da8',
|
|
97
|
+
'--range-decoration-active-color': '#dd7d2c'
|
|
79
98
|
} as const satisfies Required<DeckWidgetTheme>;
|
|
80
99
|
|
|
81
100
|
export const LightGlassTheme = {
|
|
@@ -99,7 +118,13 @@ export const LightGlassTheme = {
|
|
|
99
118
|
'--menu-border': '1px solid rgba(255, 255, 255, 0.6)',
|
|
100
119
|
'--menu-shadow': '0px 0px 8px 0px rgba(0, 0, 0, 0.25), 0px 0px 8px 0px rgba(0, 0, 0, 0.1) inset',
|
|
101
120
|
'--menu-text': 'rgb(24, 24, 26, 1)',
|
|
102
|
-
'--menu-item-hover': 'rgba(0, 0, 0, 0.08)'
|
|
121
|
+
'--menu-item-hover': 'rgba(0, 0, 0, 0.08)',
|
|
122
|
+
'--range-step-button-size': '24px',
|
|
123
|
+
'--range-track-size': '16px',
|
|
124
|
+
'--range-thumb-size': '10px',
|
|
125
|
+
'--range-track-color': 'rgba(215, 214, 229, 0.3)',
|
|
126
|
+
'--range-thumb-color': 'rgba(97, 97, 102, 1)',
|
|
127
|
+
'--range-decoration-active-color': 'rgba(255, 215, 0, 0.6)'
|
|
103
128
|
} as const satisfies Required<DeckWidgetTheme>;
|
|
104
129
|
|
|
105
130
|
export const DarkGlassTheme = {
|
|
@@ -123,5 +148,11 @@ export const DarkGlassTheme = {
|
|
|
123
148
|
'--menu-border': '1px solid rgba(18, 18, 20, 0.75)',
|
|
124
149
|
'--menu-shadow': '0px 0px 8px 0px rgba(0, 0, 0, 0.25), 0px 0px 8px 0px rgba(0, 0, 0, 0.1) inset',
|
|
125
150
|
'--menu-text': 'rgb(215, 214, 229, 1)',
|
|
126
|
-
'--menu-item-hover': 'rgba(255, 255, 255, 0.1)'
|
|
151
|
+
'--menu-item-hover': 'rgba(255, 255, 255, 0.1)',
|
|
152
|
+
'--range-step-button-size': '24px',
|
|
153
|
+
'--range-track-size': '16px',
|
|
154
|
+
'--range-thumb-size': '10px',
|
|
155
|
+
'--range-track-color': 'rgba(24, 24, 26, 0.3)',
|
|
156
|
+
'--range-thumb-color': 'rgba(158, 157, 168, 1)',
|
|
157
|
+
'--range-decoration-active-color': 'rgba(255, 145, 0, 0.6)'
|
|
127
158
|
} as const satisfies Required<DeckWidgetTheme>;
|
package/src/timeline-widget.tsx
CHANGED
|
@@ -3,30 +3,50 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import {Widget, type WidgetPlacement, type WidgetProps} from '@deck.gl/core';
|
|
6
|
+
import type {Timeline} from '@luma.gl/engine';
|
|
6
7
|
import {render} from 'preact';
|
|
7
8
|
import {IconButton} from './lib/components/icon-button';
|
|
9
|
+
import {RangeInput} from './lib/components/range-input';
|
|
8
10
|
|
|
9
11
|
export type TimelineWidgetProps = WidgetProps & {
|
|
10
12
|
/** Widget positioning within the view. Default 'bottom-left'. */
|
|
11
13
|
placement?: WidgetPlacement;
|
|
12
14
|
/** View to attach to and interact with. Required when using multiple views. */
|
|
13
15
|
viewId?: string | null;
|
|
16
|
+
/** Timeline instance to manipulate. */
|
|
17
|
+
timeline?: Timeline | null;
|
|
14
18
|
/** Slider timeRange [min, max]. */
|
|
15
19
|
timeRange?: [number, number];
|
|
16
|
-
/** Slider step.
|
|
20
|
+
/** Slider step.
|
|
21
|
+
* @default 1
|
|
22
|
+
*/
|
|
17
23
|
step?: number;
|
|
18
|
-
/** Initial slider value.
|
|
24
|
+
/** Initial slider value.
|
|
25
|
+
* @default `timeRange[0]`
|
|
26
|
+
*/
|
|
19
27
|
initialTime?: number;
|
|
20
28
|
/** Callback when value changes. */
|
|
21
29
|
onTimeChange?: (value: number) => void;
|
|
22
|
-
/**
|
|
30
|
+
/** Start playing automatically
|
|
31
|
+
* @default false
|
|
32
|
+
*/
|
|
33
|
+
autoPlay?: boolean;
|
|
34
|
+
/** Start from the beginning whentime reaches the end
|
|
35
|
+
* @default false
|
|
36
|
+
*/
|
|
37
|
+
loop?: boolean;
|
|
38
|
+
/** Play interval in milliseconds.
|
|
39
|
+
* @default 1000
|
|
40
|
+
*/
|
|
23
41
|
playInterval?: number;
|
|
42
|
+
/** Callback to get label from time value */
|
|
43
|
+
formatLabel?: (value: number) => string;
|
|
24
44
|
};
|
|
25
45
|
|
|
26
46
|
export class TimelineWidget extends Widget<TimelineWidgetProps> {
|
|
27
47
|
id = 'timeline';
|
|
28
48
|
className = 'deck-widget-timeline';
|
|
29
|
-
placement: WidgetPlacement = '
|
|
49
|
+
placement: WidgetPlacement = 'fill';
|
|
30
50
|
|
|
31
51
|
private playing = false;
|
|
32
52
|
private timerId: number | null = null;
|
|
@@ -37,21 +57,25 @@ export class TimelineWidget extends Widget<TimelineWidgetProps> {
|
|
|
37
57
|
id: 'timeline',
|
|
38
58
|
placement: 'bottom-left',
|
|
39
59
|
viewId: null,
|
|
60
|
+
timeline: null,
|
|
40
61
|
timeRange: [0, 100],
|
|
41
62
|
step: 1,
|
|
42
63
|
initialTime: undefined!,
|
|
43
64
|
onTimeChange: () => {},
|
|
44
|
-
|
|
65
|
+
autoPlay: false,
|
|
66
|
+
loop: false,
|
|
67
|
+
playInterval: 1000,
|
|
68
|
+
formatLabel: String
|
|
45
69
|
};
|
|
46
70
|
|
|
47
71
|
constructor(props: TimelineWidgetProps = {}) {
|
|
48
72
|
super(props);
|
|
49
73
|
this.currentTime = this.props.initialTime ?? this.props.timeRange[0];
|
|
74
|
+
this.props.timeline?.setTime(this.currentTime);
|
|
50
75
|
this.setProps(this.props);
|
|
51
76
|
}
|
|
52
77
|
|
|
53
78
|
setProps(props: Partial<TimelineWidgetProps>): void {
|
|
54
|
-
this.placement = props.placement ?? this.placement;
|
|
55
79
|
this.viewId = props.viewId ?? this.viewId;
|
|
56
80
|
super.setProps(props);
|
|
57
81
|
}
|
|
@@ -59,6 +83,7 @@ export class TimelineWidget extends Widget<TimelineWidgetProps> {
|
|
|
59
83
|
onAdd(): void {
|
|
60
84
|
this.playing = false;
|
|
61
85
|
this.timerId = null;
|
|
86
|
+
if (this.props.autoPlay) this.play();
|
|
62
87
|
}
|
|
63
88
|
|
|
64
89
|
onRemove(): void {
|
|
@@ -66,19 +91,43 @@ export class TimelineWidget extends Widget<TimelineWidgetProps> {
|
|
|
66
91
|
}
|
|
67
92
|
|
|
68
93
|
onRenderHTML(rootElement: HTMLElement): void {
|
|
94
|
+
const {timeRange, step, formatLabel} = this.props;
|
|
95
|
+
const currentTime = this.currentTime;
|
|
96
|
+
|
|
97
|
+
rootElement.dataset.placement = this.props.placement;
|
|
98
|
+
|
|
69
99
|
render(
|
|
70
|
-
<div
|
|
71
|
-
|
|
72
|
-
<
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
100
|
+
<div className="deck-widget-button-group">
|
|
101
|
+
{this.playing ? (
|
|
102
|
+
<IconButton
|
|
103
|
+
label="Pause"
|
|
104
|
+
className="deck-widget-timeline-pause"
|
|
105
|
+
onClick={this.handlePlayPause}
|
|
106
|
+
/>
|
|
107
|
+
) : (
|
|
108
|
+
<IconButton
|
|
109
|
+
label="Play"
|
|
110
|
+
className="deck-widget-timeline-play"
|
|
111
|
+
onClick={this.handlePlayPause}
|
|
112
|
+
/>
|
|
113
|
+
)}
|
|
114
|
+
<RangeInput
|
|
115
|
+
min={timeRange[0]}
|
|
116
|
+
max={timeRange[1]}
|
|
117
|
+
orientation="horizontal"
|
|
118
|
+
step={step}
|
|
119
|
+
value={[currentTime, currentTime]}
|
|
120
|
+
onChange={this.handleTimeChange}
|
|
121
|
+
decorations={[
|
|
122
|
+
{
|
|
123
|
+
position: [currentTime, currentTime + step],
|
|
124
|
+
element: (
|
|
125
|
+
<div className="deck-widget-timeline-label deck-widget-timeline-label--current">
|
|
126
|
+
{formatLabel(currentTime)}
|
|
127
|
+
</div>
|
|
128
|
+
)
|
|
129
|
+
}
|
|
130
|
+
]}
|
|
82
131
|
/>
|
|
83
132
|
</div>,
|
|
84
133
|
rootElement
|
|
@@ -89,25 +138,24 @@ export class TimelineWidget extends Widget<TimelineWidgetProps> {
|
|
|
89
138
|
if (this.playing) {
|
|
90
139
|
this.stop();
|
|
91
140
|
} else {
|
|
92
|
-
this.
|
|
141
|
+
this.play();
|
|
93
142
|
}
|
|
94
143
|
};
|
|
95
144
|
|
|
96
|
-
private
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
this.
|
|
100
|
-
this.props.onTimeChange(val);
|
|
145
|
+
private handleTimeChange = ([value]: [number, number]): void => {
|
|
146
|
+
this.currentTime = value;
|
|
147
|
+
this.props.timeline?.setTime(value);
|
|
148
|
+
this.props.onTimeChange(value);
|
|
101
149
|
this.updateHTML();
|
|
102
150
|
};
|
|
103
151
|
|
|
104
|
-
|
|
152
|
+
public play(): void {
|
|
105
153
|
this.playing = true;
|
|
106
154
|
this.updateHTML();
|
|
107
155
|
this.tick();
|
|
108
156
|
}
|
|
109
157
|
|
|
110
|
-
|
|
158
|
+
public stop(): void {
|
|
111
159
|
this.playing = false;
|
|
112
160
|
if (this.timerId !== null) {
|
|
113
161
|
window.clearTimeout(this.timerId);
|
|
@@ -117,16 +165,31 @@ export class TimelineWidget extends Widget<TimelineWidgetProps> {
|
|
|
117
165
|
}
|
|
118
166
|
|
|
119
167
|
private tick = (): void => {
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
168
|
+
const {
|
|
169
|
+
timeRange: [min, max],
|
|
170
|
+
step,
|
|
171
|
+
loop
|
|
172
|
+
} = this.props;
|
|
173
|
+
if (step > 0) {
|
|
174
|
+
let next = Math.floor(this.currentTime / step) * step + step;
|
|
175
|
+
if (next > max) {
|
|
176
|
+
if (this.currentTime < max) {
|
|
177
|
+
next = max;
|
|
178
|
+
} else if (loop) {
|
|
179
|
+
next = min;
|
|
180
|
+
} else {
|
|
181
|
+
next = max;
|
|
182
|
+
this.playing = false;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
this.currentTime = next;
|
|
186
|
+
this.props.onTimeChange(next);
|
|
187
|
+
this.updateHTML();
|
|
124
188
|
}
|
|
125
|
-
this.currentTime = next;
|
|
126
|
-
this.props.onTimeChange(next);
|
|
127
|
-
this.updateHTML();
|
|
128
189
|
if (this.playing) {
|
|
129
190
|
this.timerId = window.setTimeout(this.tick, this.props.playInterval);
|
|
191
|
+
} else {
|
|
192
|
+
this.timerId = null;
|
|
130
193
|
}
|
|
131
194
|
};
|
|
132
195
|
}
|
package/src/zoom-widget.tsx
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import {Widget, FlyToInterpolator, LinearInterpolator} from '@deck.gl/core';
|
|
6
|
-
import type {
|
|
6
|
+
import type {WidgetProps, WidgetPlacement} from '@deck.gl/core';
|
|
7
7
|
import {render} from 'preact';
|
|
8
8
|
import {ButtonGroup} from './lib/components/button-group';
|
|
9
|
-
import {
|
|
9
|
+
import {IconButton} from './lib/components/icon-button';
|
|
10
10
|
|
|
11
11
|
export type ZoomWidgetProps = WidgetProps & {
|
|
12
12
|
/** Widget positioning within the view. Default 'top-left'. */
|
|
@@ -37,7 +37,6 @@ export class ZoomWidget extends Widget<ZoomWidgetProps> {
|
|
|
37
37
|
|
|
38
38
|
className = 'deck-widget-zoom';
|
|
39
39
|
placement: WidgetPlacement = 'top-left';
|
|
40
|
-
viewports: {[id: string]: Viewport} = {};
|
|
41
40
|
|
|
42
41
|
constructor(props: ZoomWidgetProps = {}) {
|
|
43
42
|
super(props);
|
|
@@ -53,12 +52,12 @@ export class ZoomWidget extends Widget<ZoomWidgetProps> {
|
|
|
53
52
|
onRenderHTML(rootElement: HTMLElement): void {
|
|
54
53
|
const ui = (
|
|
55
54
|
<ButtonGroup orientation={this.props.orientation}>
|
|
56
|
-
<
|
|
55
|
+
<IconButton
|
|
57
56
|
onClick={() => this.handleZoomIn()}
|
|
58
57
|
label={this.props.zoomInLabel}
|
|
59
58
|
className="deck-widget-zoom-in"
|
|
60
59
|
/>
|
|
61
|
-
<
|
|
60
|
+
<IconButton
|
|
62
61
|
onClick={() => this.handleZoomOut()}
|
|
63
62
|
label={this.props.zoomOutLabel}
|
|
64
63
|
className="deck-widget-zoom-out"
|
|
@@ -68,14 +67,21 @@ export class ZoomWidget extends Widget<ZoomWidgetProps> {
|
|
|
68
67
|
render(ui, rootElement);
|
|
69
68
|
}
|
|
70
69
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
handleZoom(viewId: string, nextZoom: number) {
|
|
71
|
+
// Respect minZoom/maxZoom constraints from the view state
|
|
72
|
+
const viewState = this.getViewState(viewId);
|
|
73
|
+
if (viewState) {
|
|
74
|
+
const {minZoom, maxZoom} = viewState as any;
|
|
75
|
+
if (Number.isFinite(minZoom)) {
|
|
76
|
+
nextZoom = Math.max(minZoom, nextZoom);
|
|
77
|
+
}
|
|
78
|
+
if (Number.isFinite(maxZoom)) {
|
|
79
|
+
nextZoom = Math.min(maxZoom, nextZoom);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
74
82
|
|
|
75
|
-
handleZoom(viewport: Viewport, nextZoom: number) {
|
|
76
|
-
const viewId = this.viewId || viewport?.id || 'default-view';
|
|
77
83
|
const nextViewState: Record<string, unknown> = {
|
|
78
|
-
...
|
|
84
|
+
...viewState,
|
|
79
85
|
zoom: nextZoom
|
|
80
86
|
};
|
|
81
87
|
if (this.props.transitionDuration > 0) {
|
|
@@ -91,20 +97,18 @@ export class ZoomWidget extends Widget<ZoomWidgetProps> {
|
|
|
91
97
|
}
|
|
92
98
|
|
|
93
99
|
handleZoomIn() {
|
|
94
|
-
|
|
95
|
-
|
|
100
|
+
const viewIds = this.viewId ? [this.viewId] : (this.deck?.getViews().map(v => v.id) ?? []);
|
|
101
|
+
for (const viewId of viewIds) {
|
|
102
|
+
const viewState = this.getViewState(viewId);
|
|
103
|
+
this.handleZoom(viewId, (viewState.zoom as number) + 1);
|
|
96
104
|
}
|
|
97
105
|
}
|
|
98
106
|
|
|
99
107
|
handleZoomOut() {
|
|
100
|
-
|
|
101
|
-
|
|
108
|
+
const viewIds = this.viewId ? [this.viewId] : (this.deck?.getViews().map(v => v.id) ?? []);
|
|
109
|
+
for (const viewId of viewIds) {
|
|
110
|
+
const viewState = this.getViewState(viewId);
|
|
111
|
+
this.handleZoom(viewId, (viewState.zoom as number) - 1);
|
|
102
112
|
}
|
|
103
113
|
}
|
|
104
|
-
|
|
105
|
-
/** @todo - move to deck or widget manager */
|
|
106
|
-
private setViewState(viewId: string, viewState: Record<string, unknown>): void {
|
|
107
|
-
// @ts-ignore Using private method temporary until there's a public one
|
|
108
|
-
this.deck._onViewStateChange({viewId, viewState, interactionState: {}});
|
|
109
|
-
}
|
|
110
114
|
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { ComponentChildren, JSX } from 'preact';
|
|
2
|
-
export type GroupedIconButtonProps = {
|
|
3
|
-
className?: string;
|
|
4
|
-
label?: string;
|
|
5
|
-
onClick?: JSX.MouseEventHandler<HTMLButtonElement>;
|
|
6
|
-
children?: ComponentChildren;
|
|
7
|
-
};
|
|
8
|
-
/** Renders an icon button as part of a ButtonGroup */
|
|
9
|
-
export declare const GroupedIconButton: (props: GroupedIconButtonProps) => JSX.Element;
|
|
10
|
-
//# sourceMappingURL=grouped-icon-button.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"grouped-icon-button.d.ts","sourceRoot":"","sources":["../../../src/lib/components/grouped-icon-button.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,iBAAiB,EAAE,GAAG,EAAC,MAAM,QAAQ,CAAC;AAEnD,MAAM,MAAM,sBAAsB,GAAG;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,GAAG,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;IACnD,QAAQ,CAAC,EAAE,iBAAiB,CAAC;CAC9B,CAAC;AAEF,sDAAsD;AACtD,eAAO,MAAM,iBAAiB,UAAW,sBAAsB,gBAY9D,CAAC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
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, children } = props;
|
|
5
|
-
return (_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=grouped-icon-button.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"grouped-icon-button.js","sourceRoot":"","sources":["../../../src/lib/components/grouped-icon-button.tsx"],"names":[],"mappings":";AAaA,sDAAsD;AACtD,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,KAA6B,EAAE,EAAE;IACjE,MAAM,EAAC,SAAS,GAAG,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAC,GAAG,KAAK,CAAC;IACzD,OAAO,CACL,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,CACV,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,30 +0,0 @@
|
|
|
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: 'var(--menu-gap, 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
|
|
@@ -1 +0,0 @@
|
|
|
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,sBAAsB;IACjC,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"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
// deck.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
|
|
5
|
-
import type {ComponentChildren, JSX} from 'preact';
|
|
6
|
-
|
|
7
|
-
export type GroupedIconButtonProps = {
|
|
8
|
-
className?: string;
|
|
9
|
-
label?: string;
|
|
10
|
-
onClick?: JSX.MouseEventHandler<HTMLButtonElement>;
|
|
11
|
-
children?: ComponentChildren;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
/** Renders an icon button as part of a ButtonGroup */
|
|
15
|
-
export const GroupedIconButton = (props: GroupedIconButtonProps) => {
|
|
16
|
-
const {className = '', label, onClick, children} = props;
|
|
17
|
-
return (
|
|
18
|
-
<button
|
|
19
|
-
className={`deck-widget-icon-button ${className}`}
|
|
20
|
-
type="button"
|
|
21
|
-
onClick={onClick}
|
|
22
|
-
title={label}
|
|
23
|
-
>
|
|
24
|
-
{children ? children : <div className="deck-widget-icon" />}
|
|
25
|
-
</button>
|
|
26
|
-
);
|
|
27
|
-
};
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import type {JSX} from 'preact';
|
|
2
|
-
|
|
3
|
-
const MENU_STYLE: JSX.CSSProperties = {
|
|
4
|
-
position: 'absolute',
|
|
5
|
-
top: '100%',
|
|
6
|
-
left: 0,
|
|
7
|
-
background: 'white',
|
|
8
|
-
border: '1px solid #ccc',
|
|
9
|
-
borderRadius: '4px',
|
|
10
|
-
marginTop: 'var(--menu-gap, 4px)',
|
|
11
|
-
zIndex: 100
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const MENU_ITEM_STYLE: JSX.CSSProperties = {
|
|
15
|
-
background: 'white',
|
|
16
|
-
border: 'none',
|
|
17
|
-
padding: '4px',
|
|
18
|
-
cursor: 'pointer',
|
|
19
|
-
pointerEvents: 'auto'
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export type SimpleMenuProps = {
|
|
23
|
-
menuItems: {key: string; label: string}[];
|
|
24
|
-
onItemSelected: (key: string) => void;
|
|
25
|
-
position: {x: number; y: number};
|
|
26
|
-
style?: JSX.CSSProperties;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
/** Renders a simple dropdown menu at an arbitrary position */
|
|
30
|
-
export const SimpleMenu = (props: SimpleMenuProps) => {
|
|
31
|
-
const {menuItems, onItemSelected, position, style} = props;
|
|
32
|
-
const styleOverride: JSX.CSSProperties = {
|
|
33
|
-
...MENU_STYLE,
|
|
34
|
-
...style,
|
|
35
|
-
left: `${position.x}px`,
|
|
36
|
-
top: `${position.y}px`
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
return (
|
|
40
|
-
<div style={styleOverride}>
|
|
41
|
-
{menuItems.map(({key, label}) => (
|
|
42
|
-
<button
|
|
43
|
-
key={key}
|
|
44
|
-
style={{...MENU_ITEM_STYLE, display: 'block'}}
|
|
45
|
-
onClick={_ => onItemSelected(key)}
|
|
46
|
-
>
|
|
47
|
-
{label}
|
|
48
|
-
</button>
|
|
49
|
-
))}
|
|
50
|
-
</div>
|
|
51
|
-
);
|
|
52
|
-
};
|