@deck.gl/widgets 9.2.11 → 9.3.0-alpha.2
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 +27 -20
- package/dist/context-menu-widget.d.ts.map +1 -1
- package/dist/context-menu-widget.js +45 -48
- package/dist/context-menu-widget.js.map +1 -1
- package/dist/dist.dev.js +3114 -869
- 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/icon-widget.d.ts +28 -0
- package/dist/icon-widget.d.ts.map +1 -0
- package/dist/icon-widget.js +35 -0
- package/dist/icon-widget.js.map +1 -0
- package/dist/index.cjs +1271 -561
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +16 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -10
- package/dist/index.js.map +1 -1
- package/dist/info-widget.d.ts +39 -17
- package/dist/info-widget.d.ts.map +1 -1
- package/dist/info-widget.js +46 -130
- package/dist/info-widget.js.map +1 -1
- package/dist/lib/components/dropdown-menu.d.ts +12 -5
- package/dist/lib/components/dropdown-menu.d.ts.map +1 -1
- package/dist/lib/components/dropdown-menu.js +20 -11
- package/dist/lib/components/dropdown-menu.js.map +1 -1
- package/dist/lib/components/icon-button.d.ts +3 -0
- package/dist/lib/components/icon-button.d.ts.map +1 -1
- package/dist/lib/components/icon-button.js +10 -2
- package/dist/lib/components/icon-button.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/lib/data-url.d.ts +5 -0
- package/dist/lib/data-url.d.ts.map +1 -0
- package/dist/lib/data-url.js +7 -0
- package/dist/lib/data-url.js.map +1 -0
- package/dist/popup-widget.d.ts +64 -0
- package/dist/popup-widget.d.ts.map +1 -0
- package/dist/popup-widget.js +76 -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/selector-widget.d.ts +44 -0
- package/dist/selector-widget.d.ts.map +1 -0
- package/dist/selector-widget.js +64 -0
- package/dist/selector-widget.js.map +1 -0
- package/dist/splitter-widget.d.ts +52 -11
- package/dist/splitter-widget.d.ts.map +1 -1
- package/dist/splitter-widget.js +177 -76
- package/dist/splitter-widget.js.map +1 -1
- package/dist/stats-widget.d.ts +6 -1
- package/dist/stats-widget.d.ts.map +1 -1
- package/dist/stats-widget.js +39 -10
- package/dist/stats-widget.js.map +1 -1
- package/dist/stylesheet.css +291 -39
- 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 +51 -18
- package/dist/timeline-widget.js.map +1 -1
- package/dist/toggle-widget.d.ts +38 -0
- package/dist/toggle-widget.d.ts.map +1 -0
- package/dist/toggle-widget.js +47 -0
- package/dist/toggle-widget.js.map +1 -0
- 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 +88 -78
- package/src/fullscreen-widget.tsx +1 -1
- package/src/geocoder-widget.tsx +17 -24
- package/src/gimbal-widget.tsx +4 -26
- package/src/icon-widget.tsx +69 -0
- package/src/index.ts +22 -15
- package/src/info-widget.tsx +100 -157
- package/src/lib/components/dropdown-menu.tsx +58 -29
- package/src/lib/components/icon-button.tsx +15 -3
- 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/lib/data-url.ts +5 -0
- package/src/popup-widget.tsx +170 -0
- package/src/reset-view-widget.tsx +12 -11
- package/src/scrollbar-widget.tsx +288 -0
- package/src/selector-widget.tsx +111 -0
- package/src/splitter-widget.tsx +281 -96
- package/src/stats-widget.tsx +59 -12
- package/src/stylesheet.css +291 -39
- package/src/theme-widget.tsx +7 -5
- package/src/themes.ts +35 -4
- package/src/timeline-widget.tsx +103 -33
- package/src/toggle-widget.tsx +101 -0
- package/src/zoom-widget.tsx +25 -21
- package/dist/fps-widget.d.ts +0 -28
- package/dist/fps-widget.d.ts.map +0 -1
- package/dist/fps-widget.js +0 -51
- package/dist/fps-widget.js.map +0 -1
- 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/icon-menu.d.ts +0 -16
- package/dist/lib/components/icon-menu.d.ts.map +0 -1
- package/dist/lib/components/icon-menu.js +0 -34
- package/dist/lib/components/icon-menu.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/dist/view-selector-widget.d.ts +0 -35
- package/dist/view-selector-widget.d.ts.map +0 -1
- package/dist/view-selector-widget.js +0 -63
- package/dist/view-selector-widget.js.map +0 -1
- package/src/fps-widget.tsx +0 -77
- package/src/lib/components/grouped-icon-button.tsx +0 -27
- package/src/lib/components/icon-menu.tsx +0 -71
- package/src/lib/components/simple-menu.tsx +0 -52
- package/src/view-selector-widget.tsx +0 -151
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,31 @@ 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;
|
|
154
|
+
const {
|
|
155
|
+
timeRange: [min, max]
|
|
156
|
+
} = this.props;
|
|
157
|
+
if (this.currentTime >= max) {
|
|
158
|
+
this.currentTime = min;
|
|
159
|
+
this.props.onTimeChange(min);
|
|
160
|
+
}
|
|
106
161
|
this.updateHTML();
|
|
107
162
|
this.tick();
|
|
108
163
|
}
|
|
109
164
|
|
|
110
|
-
|
|
165
|
+
public stop(): void {
|
|
111
166
|
this.playing = false;
|
|
112
167
|
if (this.timerId !== null) {
|
|
113
168
|
window.clearTimeout(this.timerId);
|
|
@@ -117,16 +172,31 @@ export class TimelineWidget extends Widget<TimelineWidgetProps> {
|
|
|
117
172
|
}
|
|
118
173
|
|
|
119
174
|
private tick = (): void => {
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
175
|
+
const {
|
|
176
|
+
timeRange: [min, max],
|
|
177
|
+
step,
|
|
178
|
+
loop
|
|
179
|
+
} = this.props;
|
|
180
|
+
if (step > 0) {
|
|
181
|
+
let next = Math.round(this.currentTime / step) * step + step;
|
|
182
|
+
if (next > max) {
|
|
183
|
+
if (this.currentTime < max) {
|
|
184
|
+
next = max;
|
|
185
|
+
} else if (loop) {
|
|
186
|
+
next = min;
|
|
187
|
+
} else {
|
|
188
|
+
next = max;
|
|
189
|
+
this.playing = false;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
this.currentTime = next;
|
|
193
|
+
this.props.onTimeChange(next);
|
|
194
|
+
this.updateHTML();
|
|
124
195
|
}
|
|
125
|
-
this.currentTime = next;
|
|
126
|
-
this.props.onTimeChange(next);
|
|
127
|
-
this.updateHTML();
|
|
128
196
|
if (this.playing) {
|
|
129
197
|
this.timerId = window.setTimeout(this.tick, this.props.playInterval);
|
|
198
|
+
} else {
|
|
199
|
+
this.timerId = null;
|
|
130
200
|
}
|
|
131
201
|
};
|
|
132
202
|
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {WidgetPlacement, WidgetProps} from '@deck.gl/core';
|
|
6
|
+
import {render, type JSX} from 'preact';
|
|
7
|
+
import {Widget} from '@deck.gl/core';
|
|
8
|
+
import {IconButton} from './lib/components/icon-button';
|
|
9
|
+
|
|
10
|
+
export type ToggleWidgetProps = WidgetProps & {
|
|
11
|
+
/** Widget positioning within the view. Default 'bottom-left'. */
|
|
12
|
+
placement?: WidgetPlacement;
|
|
13
|
+
/** View to attach to and interact with. Required when using multiple views. */
|
|
14
|
+
viewId?: string | null;
|
|
15
|
+
/** If the toggle is checked when first added */
|
|
16
|
+
initialChecked?: boolean;
|
|
17
|
+
/** Data url to display as icon */
|
|
18
|
+
icon: string;
|
|
19
|
+
/** Data url to display as icon when it is checked */
|
|
20
|
+
onIcon?: string;
|
|
21
|
+
/** Tooltip label */
|
|
22
|
+
label?: string;
|
|
23
|
+
/** Tooltip label when it is checked */
|
|
24
|
+
onLabel?: string;
|
|
25
|
+
/** Icon color, a CSS Color string */
|
|
26
|
+
color?: string;
|
|
27
|
+
/** Icon color when it is checked, a CSS Color string */
|
|
28
|
+
onColor?: string;
|
|
29
|
+
/** Callback when the widget is clicked */
|
|
30
|
+
onChange?: (checked: boolean) => void;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* A generic widget that displays a button with icon or text content.
|
|
35
|
+
*/
|
|
36
|
+
export class ToggleWidget extends Widget<ToggleWidgetProps> {
|
|
37
|
+
static defaultProps: Required<ToggleWidgetProps> = {
|
|
38
|
+
...Widget.defaultProps,
|
|
39
|
+
id: 'icon',
|
|
40
|
+
placement: 'top-left',
|
|
41
|
+
viewId: null,
|
|
42
|
+
initialChecked: false,
|
|
43
|
+
icon: '',
|
|
44
|
+
onIcon: undefined!,
|
|
45
|
+
label: '',
|
|
46
|
+
onLabel: undefined!,
|
|
47
|
+
color: '',
|
|
48
|
+
onColor: undefined!,
|
|
49
|
+
onChange: undefined!
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
className = 'deck-widget-toggle';
|
|
53
|
+
placement: WidgetPlacement = 'top-left';
|
|
54
|
+
checked: boolean;
|
|
55
|
+
|
|
56
|
+
constructor(props: ToggleWidgetProps) {
|
|
57
|
+
super(props);
|
|
58
|
+
this.checked = this.props.initialChecked;
|
|
59
|
+
this.setProps(this.props);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
setProps(props: Partial<ToggleWidgetProps>) {
|
|
63
|
+
this.placement = props.placement ?? this.placement;
|
|
64
|
+
this.viewId = props.viewId;
|
|
65
|
+
super.setProps(props);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
onRenderHTML(rootElement: HTMLElement): void {
|
|
69
|
+
const {
|
|
70
|
+
className,
|
|
71
|
+
style,
|
|
72
|
+
icon,
|
|
73
|
+
label,
|
|
74
|
+
color,
|
|
75
|
+
onIcon = icon,
|
|
76
|
+
onLabel = label,
|
|
77
|
+
onColor = color
|
|
78
|
+
} = this.props;
|
|
79
|
+
const on = this.checked;
|
|
80
|
+
|
|
81
|
+
rootElement.dataset.checked = String(on);
|
|
82
|
+
|
|
83
|
+
render(
|
|
84
|
+
<IconButton
|
|
85
|
+
className={className}
|
|
86
|
+
style={style as JSX.CSSProperties}
|
|
87
|
+
icon={on ? onIcon : icon}
|
|
88
|
+
label={on ? onLabel : label}
|
|
89
|
+
color={on ? onColor : color}
|
|
90
|
+
onClick={this._toggle}
|
|
91
|
+
/>,
|
|
92
|
+
rootElement
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
private _toggle = () => {
|
|
97
|
+
this.checked = !this.checked;
|
|
98
|
+
this.props.onChange?.(this.checked);
|
|
99
|
+
this.updateHTML();
|
|
100
|
+
};
|
|
101
|
+
}
|
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
|
}
|
package/dist/fps-widget.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { Widget } from '@deck.gl/core';
|
|
2
|
-
import type { WidgetPlacement, Deck, WidgetProps } from '@deck.gl/core';
|
|
3
|
-
/** Properties for the FpsWidget. */
|
|
4
|
-
export type FpsWidgetProps = WidgetProps & {
|
|
5
|
-
/** Widget positioning within the view. Default 'top-left'. */
|
|
6
|
-
placement?: WidgetPlacement;
|
|
7
|
-
/** View to attach to and interact with. Required when using multiple views. */
|
|
8
|
-
viewId?: string | null;
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* Displays the average frames per second reported by the Deck instance.
|
|
12
|
-
*/
|
|
13
|
-
export declare class FpsWidget extends Widget<FpsWidgetProps> {
|
|
14
|
-
static defaultProps: Required<FpsWidgetProps>;
|
|
15
|
-
className: string;
|
|
16
|
-
placement: WidgetPlacement;
|
|
17
|
-
private _lastFps;
|
|
18
|
-
constructor(props?: FpsWidgetProps);
|
|
19
|
-
setProps(props: Partial<FpsWidgetProps>): void;
|
|
20
|
-
onAdd({}: {
|
|
21
|
-
deck: Deck<any>;
|
|
22
|
-
viewId: string | null;
|
|
23
|
-
}): void;
|
|
24
|
-
onRenderHTML(rootElement: HTMLElement): void;
|
|
25
|
-
_animate(): void;
|
|
26
|
-
_getFps(): number;
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=fps-widget.d.ts.map
|
package/dist/fps-widget.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fps-widget.d.ts","sourceRoot":"","sources":["../src/fps-widget.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAC,MAAM,EAAC,MAAM,eAAe,CAAC;AAErC,OAAO,KAAK,EAAC,eAAe,EAAE,IAAI,EAAE,WAAW,EAAC,MAAM,eAAe,CAAC;AAGtE,oCAAoC;AACpC,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG;IACzC,8DAA8D;IAC9D,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,+EAA+E;IAC/E,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB,CAAC;AAEF;;GAEG;AACH,qBAAa,SAAU,SAAQ,MAAM,CAAC,cAAc,CAAC;IACnD,MAAM,CAAC,YAAY,EAAE,QAAQ,CAAC,cAAc,CAAC,CAK3C;IAEF,SAAS,SAAqB;IAC9B,SAAS,EAAE,eAAe,CAAc;IAExC,OAAO,CAAC,QAAQ,CAAc;gBAElB,KAAK,GAAE,cAAmB;IAKtC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,IAAI;IAM9C,KAAK,CAAC,EAAE,EAAE;QAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;QAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;KAAC,GAAG,IAAI;IAKzD,YAAY,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI;IAc5C,QAAQ,IAAI,IAAI;IAShB,OAAO,IAAI,MAAM;CAIlB"}
|
package/dist/fps-widget.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
2
|
-
// deck.gl
|
|
3
|
-
// SPDX-License-Identifier: MIT
|
|
4
|
-
// Copyright (c) vis.gl contributors
|
|
5
|
-
import { Widget } from '@deck.gl/core';
|
|
6
|
-
import { render } from 'preact';
|
|
7
|
-
import { IconButton } from "./lib/components/icon-button.js";
|
|
8
|
-
/**
|
|
9
|
-
* Displays the average frames per second reported by the Deck instance.
|
|
10
|
-
*/
|
|
11
|
-
export class FpsWidget extends Widget {
|
|
12
|
-
constructor(props = {}) {
|
|
13
|
-
super(props);
|
|
14
|
-
this.className = 'deck-widget-fps';
|
|
15
|
-
this.placement = 'top-left';
|
|
16
|
-
this._lastFps = -1;
|
|
17
|
-
this.setProps(this.props);
|
|
18
|
-
}
|
|
19
|
-
setProps(props) {
|
|
20
|
-
this.placement = props.placement ?? this.placement;
|
|
21
|
-
this.viewId = props.viewId ?? this.viewId;
|
|
22
|
-
super.setProps(props);
|
|
23
|
-
}
|
|
24
|
-
onAdd({}) {
|
|
25
|
-
this._lastFps = this._getFps();
|
|
26
|
-
requestAnimationFrame(() => this._animate());
|
|
27
|
-
}
|
|
28
|
-
onRenderHTML(rootElement) {
|
|
29
|
-
const fps = this._getFps();
|
|
30
|
-
render(_jsx(IconButton, { children: _jsxs("div", { className: "text", children: ["FPS", _jsx("br", {}), fps] }) }), rootElement);
|
|
31
|
-
}
|
|
32
|
-
_animate() {
|
|
33
|
-
const fps = this._getFps();
|
|
34
|
-
if (this._lastFps !== fps) {
|
|
35
|
-
this._lastFps = fps;
|
|
36
|
-
this.updateHTML();
|
|
37
|
-
}
|
|
38
|
-
requestAnimationFrame(() => this._animate());
|
|
39
|
-
}
|
|
40
|
-
_getFps() {
|
|
41
|
-
// @ts-expect-error protected
|
|
42
|
-
return Math.round(this.deck?.metrics.fps ?? 0);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
FpsWidget.defaultProps = {
|
|
46
|
-
...Widget.defaultProps,
|
|
47
|
-
id: 'fps',
|
|
48
|
-
placement: 'top-left',
|
|
49
|
-
viewId: null
|
|
50
|
-
};
|
|
51
|
-
//# sourceMappingURL=fps-widget.js.map
|
package/dist/fps-widget.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fps-widget.js","sourceRoot":"","sources":["../src/fps-widget.tsx"],"names":[],"mappings":";AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,EAAC,MAAM,EAAC,MAAM,eAAe,CAAC;AACrC,OAAO,EAAC,MAAM,EAAC,MAAM,QAAQ,CAAC;AAE9B,OAAO,EAAC,UAAU,EAAC,wCAAqC;AAUxD;;GAEG;AACH,MAAM,OAAO,SAAU,SAAQ,MAAsB;IAanD,YAAY,QAAwB,EAAE;QACpC,KAAK,CAAC,KAAK,CAAC,CAAC;QANf,cAAS,GAAG,iBAAiB,CAAC;QAC9B,cAAS,GAAoB,UAAU,CAAC;QAEhC,aAAQ,GAAW,CAAC,CAAC,CAAC;QAI5B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED,QAAQ,CAAC,KAA8B;QACrC,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,IAAI,IAAI,CAAC,SAAS,CAAC;QACnD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC;QAC1C,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,EAA4C;QAChD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;QAC/B,qBAAqB,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC/C,CAAC;IAED,YAAY,CAAC,WAAwB;QACnC,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;QAC3B,MAAM,CACJ,KAAC,UAAU,cACT,eAAK,SAAS,EAAC,MAAM,oBAEnB,cAAM,EACL,GAAG,IACA,GACK,EACb,WAAW,CACZ,CAAC;IACJ,CAAC;IAED,QAAQ;QACN,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;QAC3B,IAAI,IAAI,CAAC,QAAQ,KAAK,GAAG,EAAE,CAAC;YAC1B,IAAI,CAAC,QAAQ,GAAG,GAAG,CAAC;YACpB,IAAI,CAAC,UAAU,EAAE,CAAC;QACpB,CAAC;QACD,qBAAqB,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC/C,CAAC;IAED,OAAO;QACL,6BAA6B;QAC7B,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;IACjD,CAAC;;AAtDM,sBAAY,GAA6B;IAC9C,GAAG,MAAM,CAAC,YAAY;IACtB,EAAE,EAAE,KAAK;IACT,SAAS,EAAE,UAAU;IACrB,MAAM,EAAE,IAAI;CACb,AALkB,CAKjB"}
|
|
@@ -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 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
|
|
@@ -1 +0,0 @@
|
|
|
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;AAMhC,MAAM,MAAM,aAAa,CAAC,OAAO,GAAG,MAAM,IAAI;IAC5C,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,EAAE;QAAC,KAAK,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC,EAAE,CAAC;IAChE,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,eAsD7E"}
|
|
@@ -1,34 +0,0 @@
|
|
|
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
|
-
import { ButtonGroup } from "./button-group.js";
|
|
5
|
-
import { GroupedIconButton } from "./grouped-icon-button.js";
|
|
6
|
-
/** A component that renders an icon popup menu */
|
|
7
|
-
export function IconMenu(props) {
|
|
8
|
-
const [menuOpen, setMenuOpen] = useState(false);
|
|
9
|
-
const containerRef = useRef(null);
|
|
10
|
-
// Close the menu when clicking outside.
|
|
11
|
-
const handleClickOutside = (event) => {
|
|
12
|
-
if (containerRef.current && !containerRef.current.contains(event.target)) {
|
|
13
|
-
setMenuOpen(false);
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
useEffect(() => {
|
|
17
|
-
document.addEventListener('mousedown', handleClickOutside);
|
|
18
|
-
return () => {
|
|
19
|
-
document.removeEventListener('mousedown', handleClickOutside);
|
|
20
|
-
};
|
|
21
|
-
}, [containerRef]);
|
|
22
|
-
const [selectedItem, setSelectedItem] = useState(props.initialItem);
|
|
23
|
-
const handleSelectItem = (item) => {
|
|
24
|
-
setSelectedItem(item);
|
|
25
|
-
setMenuOpen(false);
|
|
26
|
-
props.onItemSelected(item);
|
|
27
|
-
};
|
|
28
|
-
const handleButtonClick = () => setMenuOpen(!menuOpen);
|
|
29
|
-
const selectedMenuItem = props.menuItems.find(item => item.value === selectedItem);
|
|
30
|
-
const label = props.label || selectedMenuItem?.label || '';
|
|
31
|
-
const icon = (props.icon || selectedMenuItem?.icon);
|
|
32
|
-
return (_jsxs("div", { style: { position: 'relative', display: 'inline-block' }, ref: containerRef, children: [_jsx(IconButton, { className: props.className, label: label, onClick: handleButtonClick, children: icon }), menuOpen && (_jsx("div", { className: "deck-widget-icon-menu", children: _jsx(ButtonGroup, { orientation: "vertical", children: props.menuItems.map(item => (_jsx(GroupedIconButton, { label: item.label, onClick: () => handleSelectItem(item.value), children: item.icon }, item.value))) }) }))] }));
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=icon-menu.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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;AACzC,OAAO,EAAC,WAAW,EAAC,0BAAuB;AAC3C,OAAO,EAAC,iBAAiB,EAAC,iCAA8B;AAWxD,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,CAAC;IAElD,wCAAwC;IACxC,MAAM,kBAAkB,GAAG,CAAC,KAAiB,EAAE,EAAE;QAC/C,IAAI,YAAY,CAAC,OAAO,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAc,CAAC,EAAE,CAAC;YACjF,WAAW,CAAC,KAAK,CAAC,CAAC;QACrB,CAAC;IACH,CAAC,CAAC;IAEF,SAAS,CAAC,GAAG,EAAE;QACb,QAAQ,CAAC,gBAAgB,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC;QAC3D,OAAO,GAAG,EAAE;YACV,QAAQ,CAAC,mBAAmB,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC;QAChE,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;IAEnB,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAU,KAAK,CAAC,WAAW,CAAC,CAAC;IAE7E,MAAM,gBAAgB,GAAG,CAAC,IAAa,EAAE,EAAE;QACzC,eAAe,CAAC,IAAI,CAAC,CAAC;QACtB,WAAW,CAAC,KAAK,CAAC,CAAC;QACnB,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC,CAAC;IAEF,MAAM,iBAAiB,GAAG,GAAG,EAAE,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC,CAAC;IAEvD,MAAM,gBAAgB,GAAG,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,KAAK,YAAY,CAAC,CAAC;IACnF,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,gBAAgB,EAAE,KAAK,IAAI,EAAE,CAAC;IAC3D,MAAM,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,IAAI,gBAAgB,EAAE,IAAI,CAAE,CAAC;IAErD,OAAO,CACL,eAAK,KAAK,EAAE,EAAC,QAAQ,EAAE,UAAU,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,YAC7E,IAAI,GACM,EACZ,QAAQ,IAAI,CACX,cAAK,SAAS,EAAC,uBAAuB,YACpC,KAAC,WAAW,IAAC,WAAW,EAAC,UAAU,YAChC,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAC3B,KAAC,iBAAiB,IAEhB,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,OAAO,EAAE,GAAG,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,YAE1C,IAAI,CAAC,IAAI,IAJL,IAAI,CAAC,KAAK,CAKG,CACrB,CAAC,GACU,GACV,CACP,IACG,CACP,CAAC;AACJ,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"}
|