@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.
Files changed (152) hide show
  1. package/dist/compass-widget.js +5 -5
  2. package/dist/compass-widget.js.map +1 -1
  3. package/dist/context-menu-widget.d.ts +27 -20
  4. package/dist/context-menu-widget.d.ts.map +1 -1
  5. package/dist/context-menu-widget.js +45 -48
  6. package/dist/context-menu-widget.js.map +1 -1
  7. package/dist/dist.dev.js +3114 -869
  8. package/dist/fullscreen-widget.js +1 -1
  9. package/dist/fullscreen-widget.js.map +1 -1
  10. package/dist/geocoder-widget.d.ts +2 -4
  11. package/dist/geocoder-widget.d.ts.map +1 -1
  12. package/dist/geocoder-widget.js +16 -20
  13. package/dist/geocoder-widget.js.map +1 -1
  14. package/dist/gimbal-widget.d.ts +0 -3
  15. package/dist/gimbal-widget.d.ts.map +1 -1
  16. package/dist/gimbal-widget.js +4 -22
  17. package/dist/gimbal-widget.js.map +1 -1
  18. package/dist/icon-widget.d.ts +28 -0
  19. package/dist/icon-widget.d.ts.map +1 -0
  20. package/dist/icon-widget.js +35 -0
  21. package/dist/icon-widget.js.map +1 -0
  22. package/dist/index.cjs +1271 -561
  23. package/dist/index.cjs.map +4 -4
  24. package/dist/index.d.ts +16 -12
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +11 -10
  27. package/dist/index.js.map +1 -1
  28. package/dist/info-widget.d.ts +39 -17
  29. package/dist/info-widget.d.ts.map +1 -1
  30. package/dist/info-widget.js +46 -130
  31. package/dist/info-widget.js.map +1 -1
  32. package/dist/lib/components/dropdown-menu.d.ts +12 -5
  33. package/dist/lib/components/dropdown-menu.d.ts.map +1 -1
  34. package/dist/lib/components/dropdown-menu.js +20 -11
  35. package/dist/lib/components/dropdown-menu.js.map +1 -1
  36. package/dist/lib/components/icon-button.d.ts +3 -0
  37. package/dist/lib/components/icon-button.d.ts.map +1 -1
  38. package/dist/lib/components/icon-button.js +10 -2
  39. package/dist/lib/components/icon-button.js.map +1 -1
  40. package/dist/lib/components/popover.d.ts +30 -0
  41. package/dist/lib/components/popover.d.ts.map +1 -0
  42. package/dist/lib/components/popover.js +93 -0
  43. package/dist/lib/components/popover.js.map +1 -0
  44. package/dist/lib/components/range-input.d.ts +26 -0
  45. package/dist/lib/components/range-input.d.ts.map +1 -0
  46. package/dist/lib/components/range-input.js +261 -0
  47. package/dist/lib/components/range-input.js.map +1 -0
  48. package/dist/lib/components/user-content.d.ts +8 -0
  49. package/dist/lib/components/user-content.d.ts.map +1 -0
  50. package/dist/lib/components/user-content.js +15 -0
  51. package/dist/lib/components/user-content.js.map +1 -0
  52. package/dist/lib/data-url.d.ts +5 -0
  53. package/dist/lib/data-url.d.ts.map +1 -0
  54. package/dist/lib/data-url.js +7 -0
  55. package/dist/lib/data-url.js.map +1 -0
  56. package/dist/popup-widget.d.ts +64 -0
  57. package/dist/popup-widget.d.ts.map +1 -0
  58. package/dist/popup-widget.js +76 -0
  59. package/dist/popup-widget.js.map +1 -0
  60. package/dist/reset-view-widget.d.ts +1 -1
  61. package/dist/reset-view-widget.d.ts.map +1 -1
  62. package/dist/reset-view-widget.js +12 -11
  63. package/dist/reset-view-widget.js.map +1 -1
  64. package/dist/scrollbar-widget.d.ts +68 -0
  65. package/dist/scrollbar-widget.d.ts.map +1 -0
  66. package/dist/scrollbar-widget.js +181 -0
  67. package/dist/scrollbar-widget.js.map +1 -0
  68. package/dist/selector-widget.d.ts +44 -0
  69. package/dist/selector-widget.d.ts.map +1 -0
  70. package/dist/selector-widget.js +64 -0
  71. package/dist/selector-widget.js.map +1 -0
  72. package/dist/splitter-widget.d.ts +52 -11
  73. package/dist/splitter-widget.d.ts.map +1 -1
  74. package/dist/splitter-widget.js +177 -76
  75. package/dist/splitter-widget.js.map +1 -1
  76. package/dist/stats-widget.d.ts +6 -1
  77. package/dist/stats-widget.d.ts.map +1 -1
  78. package/dist/stats-widget.js +39 -10
  79. package/dist/stats-widget.js.map +1 -1
  80. package/dist/stylesheet.css +291 -39
  81. package/dist/theme-widget.d.ts.map +1 -1
  82. package/dist/theme-widget.js +7 -5
  83. package/dist/theme-widget.js.map +1 -1
  84. package/dist/themes.d.ts +30 -0
  85. package/dist/themes.d.ts.map +1 -1
  86. package/dist/themes.js +28 -4
  87. package/dist/themes.js.map +1 -1
  88. package/dist/timeline-widget.d.ts +25 -6
  89. package/dist/timeline-widget.d.ts.map +1 -1
  90. package/dist/timeline-widget.js +51 -18
  91. package/dist/timeline-widget.js.map +1 -1
  92. package/dist/toggle-widget.d.ts +38 -0
  93. package/dist/toggle-widget.d.ts.map +1 -0
  94. package/dist/toggle-widget.js +47 -0
  95. package/dist/toggle-widget.js.map +1 -0
  96. package/dist/zoom-widget.d.ts +2 -8
  97. package/dist/zoom-widget.d.ts.map +1 -1
  98. package/dist/zoom-widget.js +23 -18
  99. package/dist/zoom-widget.js.map +1 -1
  100. package/dist.min.js +2 -2
  101. package/package.json +4 -3
  102. package/src/compass-widget.tsx +5 -5
  103. package/src/context-menu-widget.tsx +88 -78
  104. package/src/fullscreen-widget.tsx +1 -1
  105. package/src/geocoder-widget.tsx +17 -24
  106. package/src/gimbal-widget.tsx +4 -26
  107. package/src/icon-widget.tsx +69 -0
  108. package/src/index.ts +22 -15
  109. package/src/info-widget.tsx +100 -157
  110. package/src/lib/components/dropdown-menu.tsx +58 -29
  111. package/src/lib/components/icon-button.tsx +15 -3
  112. package/src/lib/components/popover.tsx +167 -0
  113. package/src/lib/components/range-input.tsx +432 -0
  114. package/src/lib/components/user-content.tsx +30 -0
  115. package/src/lib/data-url.ts +5 -0
  116. package/src/popup-widget.tsx +170 -0
  117. package/src/reset-view-widget.tsx +12 -11
  118. package/src/scrollbar-widget.tsx +288 -0
  119. package/src/selector-widget.tsx +111 -0
  120. package/src/splitter-widget.tsx +281 -96
  121. package/src/stats-widget.tsx +59 -12
  122. package/src/stylesheet.css +291 -39
  123. package/src/theme-widget.tsx +7 -5
  124. package/src/themes.ts +35 -4
  125. package/src/timeline-widget.tsx +103 -33
  126. package/src/toggle-widget.tsx +101 -0
  127. package/src/zoom-widget.tsx +25 -21
  128. package/dist/fps-widget.d.ts +0 -28
  129. package/dist/fps-widget.d.ts.map +0 -1
  130. package/dist/fps-widget.js +0 -51
  131. package/dist/fps-widget.js.map +0 -1
  132. package/dist/lib/components/grouped-icon-button.d.ts +0 -10
  133. package/dist/lib/components/grouped-icon-button.d.ts.map +0 -1
  134. package/dist/lib/components/grouped-icon-button.js +0 -7
  135. package/dist/lib/components/grouped-icon-button.js.map +0 -1
  136. package/dist/lib/components/icon-menu.d.ts +0 -16
  137. package/dist/lib/components/icon-menu.d.ts.map +0 -1
  138. package/dist/lib/components/icon-menu.js +0 -34
  139. package/dist/lib/components/icon-menu.js.map +0 -1
  140. package/dist/lib/components/simple-menu.d.ts +0 -16
  141. package/dist/lib/components/simple-menu.d.ts.map +0 -1
  142. package/dist/lib/components/simple-menu.js +0 -30
  143. package/dist/lib/components/simple-menu.js.map +0 -1
  144. package/dist/view-selector-widget.d.ts +0 -35
  145. package/dist/view-selector-widget.d.ts.map +0 -1
  146. package/dist/view-selector-widget.js +0 -63
  147. package/dist/view-selector-widget.js.map +0 -1
  148. package/src/fps-widget.tsx +0 -77
  149. package/src/lib/components/grouped-icon-button.tsx +0 -27
  150. package/src/lib/components/icon-menu.tsx +0 -71
  151. package/src/lib/components/simple-menu.tsx +0 -52
  152. package/src/view-selector-widget.tsx +0 -151
@@ -1,35 +0,0 @@
1
- import { Widget, type WidgetProps, type WidgetPlacement } from '@deck.gl/core';
2
- /** The available view modes */
3
- export type ViewMode = 'single' | 'split-horizontal' | 'split-vertical';
4
- /** Properties for the ViewSelectorWidget */
5
- export type ViewSelectorWidgetProps = WidgetProps & {
6
- /** Widget positioning within the view. Default 'top-left'. */
7
- placement?: WidgetPlacement;
8
- /** View to attach to and interact with. Required when using multiple views. */
9
- viewId?: string | null;
10
- /** Tooltip label */
11
- label?: string;
12
- /** The initial view mode. Defaults to 'single'. */
13
- initialViewMode?: ViewMode;
14
- /** Callback invoked when the view mode changes */
15
- onViewModeChange?: (mode: ViewMode) => void;
16
- };
17
- /**
18
- * A widget that renders a popup menu for selecting a view mode.
19
- * It displays a button with the current view mode icon. Clicking the button
20
- * toggles a popup that shows three icons for:
21
- * - Single view
22
- * - Two views, split horizontally
23
- * - Two views, split vertically
24
- */
25
- export declare class ViewSelectorWidget extends Widget<ViewSelectorWidgetProps> {
26
- static defaultProps: Required<ViewSelectorWidgetProps>;
27
- className: string;
28
- placement: WidgetPlacement;
29
- viewMode: ViewMode;
30
- constructor(props?: ViewSelectorWidgetProps);
31
- setProps(props: Partial<ViewSelectorWidgetProps>): void;
32
- onRenderHTML(rootElement: HTMLElement): void;
33
- handleSelectMode: (viewMode: ViewMode) => void;
34
- }
35
- //# sourceMappingURL=view-selector-widget.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"view-selector-widget.d.ts","sourceRoot":"","sources":["../src/view-selector-widget.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAC,MAAM,EAAE,KAAK,WAAW,EAAE,KAAK,eAAe,EAAC,MAAM,eAAe,CAAC;AAG7E,+BAA+B;AAC/B,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,kBAAkB,GAAG,gBAAgB,CAAC;AAExE,4CAA4C;AAC5C,MAAM,MAAM,uBAAuB,GAAG,WAAW,GAAG;IAClD,8DAA8D;IAC9D,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,+EAA+E;IAC/E,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,oBAAoB;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mDAAmD;IACnD,eAAe,CAAC,EAAE,QAAQ,CAAC;IAC3B,kDAAkD;IAClD,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;CAC7C,CAAC;AAEF;;;;;;;GAOG;AACH,qBAAa,kBAAmB,SAAQ,MAAM,CAAC,uBAAuB,CAAC;IACrE,MAAM,CAAC,YAAY,EAAE,QAAQ,CAAC,uBAAuB,CAAC,CAQpD;IAEF,SAAS,SAA+B;IACxC,SAAS,EAAE,eAAe,CAAc;IACxC,QAAQ,EAAE,QAAQ,CAAC;gBAEP,KAAK,GAAE,uBAA4B;IAM/C,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,uBAAuB,CAAC;IAMhD,YAAY,CAAC,WAAW,EAAE,WAAW;IAerC,gBAAgB,aAAc,QAAQ,UAIpC;CACH"}
@@ -1,63 +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 { render } from 'preact';
6
- import { Widget } from '@deck.gl/core';
7
- import { IconMenu } from "./lib/components/icon-menu.js";
8
- /**
9
- * A widget that renders a popup menu for selecting a view mode.
10
- * It displays a button with the current view mode icon. Clicking the button
11
- * toggles a popup that shows three icons for:
12
- * - Single view
13
- * - Two views, split horizontally
14
- * - Two views, split vertically
15
- */
16
- export class ViewSelectorWidget extends Widget {
17
- constructor(props = {}) {
18
- super(props);
19
- this.className = 'deck-widget-view-selector';
20
- this.placement = 'top-left';
21
- this.handleSelectMode = (viewMode) => {
22
- this.viewMode = viewMode;
23
- this.updateHTML();
24
- this.props.onViewModeChange(viewMode);
25
- };
26
- this.viewMode = this.props.initialViewMode;
27
- this.setProps(this.props);
28
- }
29
- setProps(props) {
30
- this.placement = props.placement ?? this.placement;
31
- this.viewId = props.viewId ?? this.viewId;
32
- super.setProps(props);
33
- }
34
- onRenderHTML(rootElement) {
35
- render(_jsx(IconMenu, { className: "deck-widget-view-selector", menuItems: MENU_ITEMS.map(item => ({
36
- ...item,
37
- icon: item.icon()
38
- })), initialItem: this.props.initialViewMode, onItemSelected: this.handleSelectMode }), rootElement);
39
- }
40
- }
41
- ViewSelectorWidget.defaultProps = {
42
- ...Widget.defaultProps,
43
- id: 'view-selector',
44
- placement: 'top-left',
45
- viewId: null,
46
- label: 'Split View',
47
- initialViewMode: 'single',
48
- onViewModeChange: () => { }
49
- };
50
- const ICON_STYLE = { width: '24px', height: '24px' };
51
- // JSX wrapped in a function to fix deck's Node tests
52
- const ICONS = {
53
- single: () => (_jsx("svg", { width: "24", height: "24", style: ICON_STYLE, children: _jsx("rect", { x: "4", y: "4", width: "16", height: "16", stroke: "var(--button-icon-hover, rgb(24, 24, 26))", fill: "none", strokeWidth: "2" }) })),
54
- 'split-horizontal': () => (_jsxs("svg", { width: "24", height: "24", style: ICON_STYLE, children: [_jsx("rect", { x: "4", y: "4", width: "16", height: "7", stroke: "var(--button-icon-hover, rgb(24, 24, 26))", fill: "none", strokeWidth: "2" }), _jsx("rect", { x: "4", y: "13", width: "16", height: "7", stroke: "var(--button-icon-hover, rgb(24, 24, 26))", fill: "none", strokeWidth: "2" })] })),
55
- 'split-vertical': () => (_jsxs("svg", { width: "24", height: "24", style: ICON_STYLE, children: [_jsx("rect", { x: "4", y: "4", width: "7", height: "16", stroke: "var(--button-icon-hover, rgb(24, 24, 26))", fill: "none", strokeWidth: "2" }), _jsx("rect", { x: "13", y: "4", width: "7", height: "16", stroke: "var(--button-icon-hover, rgb(24, 24, 26))", fill: "none", strokeWidth: "2" })] }))
56
- };
57
- // Define menu items for the popup menu.
58
- const MENU_ITEMS = [
59
- { value: 'single', icon: ICONS.single, label: 'Single View' },
60
- { value: 'split-horizontal', icon: ICONS['split-horizontal'], label: 'Split Horizontal' },
61
- { value: 'split-vertical', icon: ICONS['split-vertical'], label: 'Split Vertical' }
62
- ];
63
- //# sourceMappingURL=view-selector-widget.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"view-selector-widget.js","sourceRoot":"","sources":["../src/view-selector-widget.tsx"],"names":[],"mappings":";AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,EAAC,MAAM,EAAM,MAAM,QAAQ,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AC,IAAI,EAAC,KAAK,EAAE,UAAU,aAC3C,eACE,CAAC,EAAC,GAAG,EACL,CAAC,EAAC,GAAG,EACL,KAAK,EAAC,GAAG,EACT,MAAM,EAAC,IAAI,EACX,MAAM,EAAC,2CAA2C,EAClD,IAAI,EAAC,MAAM,EACX,WAAW,EAAC,GAAG,GACf,EACF,eACE,CAAC,EAAC,IAAI,EACN,CAAC,EAAC,GAAG,EACL,KAAK,EAAC,GAAG,EACT,MAAM,EAAC,IAAI,EACX,MAAM,EAAC,2CAA2C,EAClD,IAAI,EAAC,MAAM,EACX,WAAW,EAAC,GAAG,GACf,IACE,CACP;CACF,CAAC;AAEF,wCAAwC;AACxC,MAAM,UAAU,GAAqE;IACnF,EAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,aAAa,EAAC;IAC3D,EAAC,KAAK,EAAE,kBAAkB,EAAE,IAAI,EAAE,KAAK,CAAC,kBAAkB,CAAC,EAAE,KAAK,EAAE,kBAAkB,EAAC;IACvF,EAAC,KAAK,EAAE,gBAAgB,EAAE,IAAI,EAAE,KAAK,CAAC,gBAAgB,CAAC,EAAE,KAAK,EAAE,gBAAgB,EAAC;CAClF,CAAC"}
@@ -1,77 +0,0 @@
1
- // deck.gl
2
- // SPDX-License-Identifier: MIT
3
- // Copyright (c) vis.gl contributors
4
-
5
- import {Widget} from '@deck.gl/core';
6
- import {render} from 'preact';
7
- import type {WidgetPlacement, Deck, WidgetProps} from '@deck.gl/core';
8
- import {IconButton} from './lib/components/icon-button';
9
-
10
- /** Properties for the FpsWidget. */
11
- export type FpsWidgetProps = WidgetProps & {
12
- /** Widget positioning within the view. Default 'top-left'. */
13
- placement?: WidgetPlacement;
14
- /** View to attach to and interact with. Required when using multiple views. */
15
- viewId?: string | null;
16
- };
17
-
18
- /**
19
- * Displays the average frames per second reported by the Deck instance.
20
- */
21
- export class FpsWidget extends Widget<FpsWidgetProps> {
22
- static defaultProps: Required<FpsWidgetProps> = {
23
- ...Widget.defaultProps,
24
- id: 'fps',
25
- placement: 'top-left',
26
- viewId: null
27
- };
28
-
29
- className = 'deck-widget-fps';
30
- placement: WidgetPlacement = 'top-left';
31
-
32
- private _lastFps: number = -1;
33
-
34
- constructor(props: FpsWidgetProps = {}) {
35
- super(props);
36
- this.setProps(this.props);
37
- }
38
-
39
- setProps(props: Partial<FpsWidgetProps>): void {
40
- this.placement = props.placement ?? this.placement;
41
- this.viewId = props.viewId ?? this.viewId;
42
- super.setProps(props);
43
- }
44
-
45
- onAdd({}: {deck: Deck<any>; viewId: string | null}): void {
46
- this._lastFps = this._getFps();
47
- requestAnimationFrame(() => this._animate());
48
- }
49
-
50
- onRenderHTML(rootElement: HTMLElement): void {
51
- const fps = this._getFps();
52
- render(
53
- <IconButton>
54
- <div className="text">
55
- FPS
56
- <br />
57
- {fps}
58
- </div>
59
- </IconButton>,
60
- rootElement
61
- );
62
- }
63
-
64
- _animate(): void {
65
- const fps = this._getFps();
66
- if (this._lastFps !== fps) {
67
- this._lastFps = fps;
68
- this.updateHTML();
69
- }
70
- requestAnimationFrame(() => this._animate());
71
- }
72
-
73
- _getFps(): number {
74
- // @ts-expect-error protected
75
- return Math.round(this.deck?.metrics.fps ?? 0);
76
- }
77
- }
@@ -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,71 +0,0 @@
1
- import type {JSX} from 'preact';
2
- import {useState, useRef, useEffect} from 'preact/hooks';
3
- import {IconButton} from './icon-button';
4
- import {ButtonGroup} from './button-group';
5
- import {GroupedIconButton} from './grouped-icon-button';
6
-
7
- export type IconMenuProps<KeyType = string> = {
8
- className: string;
9
- icon?: JSX.Element;
10
- label?: string;
11
- menuItems: {value: KeyType; icon: JSX.Element; label: string}[];
12
- initialItem: KeyType;
13
- onItemSelected: (item: KeyType) => void;
14
- };
15
-
16
- /** A component that renders an icon popup menu */
17
- export function IconMenu<KeyType extends string>(props: IconMenuProps<KeyType>) {
18
- const [menuOpen, setMenuOpen] = useState(false);
19
- const containerRef = useRef<HTMLDivElement>(null);
20
-
21
- // Close the menu when clicking outside.
22
- const handleClickOutside = (event: MouseEvent) => {
23
- if (containerRef.current && !containerRef.current.contains(event.target as Node)) {
24
- setMenuOpen(false);
25
- }
26
- };
27
-
28
- useEffect(() => {
29
- document.addEventListener('mousedown', handleClickOutside);
30
- return () => {
31
- document.removeEventListener('mousedown', handleClickOutside);
32
- };
33
- }, [containerRef]);
34
-
35
- const [selectedItem, setSelectedItem] = useState<KeyType>(props.initialItem);
36
-
37
- const handleSelectItem = (item: KeyType) => {
38
- setSelectedItem(item);
39
- setMenuOpen(false);
40
- props.onItemSelected(item);
41
- };
42
-
43
- const handleButtonClick = () => setMenuOpen(!menuOpen);
44
-
45
- const selectedMenuItem = props.menuItems.find(item => item.value === selectedItem);
46
- const label = props.label || selectedMenuItem?.label || '';
47
- const icon = (props.icon || selectedMenuItem?.icon)!;
48
-
49
- return (
50
- <div style={{position: 'relative', display: 'inline-block'}} ref={containerRef}>
51
- <IconButton className={props.className} label={label} onClick={handleButtonClick}>
52
- {icon}
53
- </IconButton>
54
- {menuOpen && (
55
- <div className="deck-widget-icon-menu">
56
- <ButtonGroup orientation="vertical">
57
- {props.menuItems.map(item => (
58
- <GroupedIconButton
59
- key={item.value}
60
- label={item.label}
61
- onClick={() => handleSelectItem(item.value)}
62
- >
63
- {item.icon}
64
- </GroupedIconButton>
65
- ))}
66
- </ButtonGroup>
67
- </div>
68
- )}
69
- </div>
70
- );
71
- }
@@ -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
- };
@@ -1,151 +0,0 @@
1
- // deck.gl
2
- // SPDX-License-Identifier: MIT
3
- // Copyright (c) vis.gl contributors
4
-
5
- import {render, JSX} from 'preact';
6
- import {Widget, type WidgetProps, type WidgetPlacement} from '@deck.gl/core';
7
- import {IconMenu} from './lib/components/icon-menu';
8
-
9
- /** The available view modes */
10
- export type ViewMode = 'single' | 'split-horizontal' | 'split-vertical';
11
-
12
- /** Properties for the ViewSelectorWidget */
13
- export type ViewSelectorWidgetProps = WidgetProps & {
14
- /** Widget positioning within the view. Default 'top-left'. */
15
- placement?: WidgetPlacement;
16
- /** View to attach to and interact with. Required when using multiple views. */
17
- viewId?: string | null;
18
- /** Tooltip label */
19
- label?: string;
20
- /** The initial view mode. Defaults to 'single'. */
21
- initialViewMode?: ViewMode;
22
- /** Callback invoked when the view mode changes */
23
- onViewModeChange?: (mode: ViewMode) => void;
24
- };
25
-
26
- /**
27
- * A widget that renders a popup menu for selecting a view mode.
28
- * It displays a button with the current view mode icon. Clicking the button
29
- * toggles a popup that shows three icons for:
30
- * - Single view
31
- * - Two views, split horizontally
32
- * - Two views, split vertically
33
- */
34
- export class ViewSelectorWidget extends Widget<ViewSelectorWidgetProps> {
35
- static defaultProps: Required<ViewSelectorWidgetProps> = {
36
- ...Widget.defaultProps,
37
- id: 'view-selector',
38
- placement: 'top-left',
39
- viewId: null,
40
- label: 'Split View',
41
- initialViewMode: 'single',
42
- onViewModeChange: () => {}
43
- };
44
-
45
- className = 'deck-widget-view-selector';
46
- placement: WidgetPlacement = 'top-left';
47
- viewMode: ViewMode;
48
-
49
- constructor(props: ViewSelectorWidgetProps = {}) {
50
- super(props);
51
- this.viewMode = this.props.initialViewMode;
52
- this.setProps(this.props);
53
- }
54
-
55
- setProps(props: Partial<ViewSelectorWidgetProps>) {
56
- this.placement = props.placement ?? this.placement;
57
- this.viewId = props.viewId ?? this.viewId;
58
- super.setProps(props);
59
- }
60
-
61
- onRenderHTML(rootElement: HTMLElement) {
62
- render(
63
- <IconMenu<ViewMode>
64
- className="deck-widget-view-selector"
65
- menuItems={MENU_ITEMS.map(item => ({
66
- ...item,
67
- icon: item.icon()
68
- }))}
69
- initialItem={this.props.initialViewMode}
70
- onItemSelected={this.handleSelectMode}
71
- />,
72
- rootElement
73
- );
74
- }
75
-
76
- handleSelectMode = (viewMode: ViewMode) => {
77
- this.viewMode = viewMode;
78
- this.updateHTML();
79
- this.props.onViewModeChange(viewMode);
80
- };
81
- }
82
-
83
- const ICON_STYLE = {width: '24px', height: '24px'};
84
-
85
- // JSX wrapped in a function to fix deck's Node tests
86
- const ICONS: Record<ViewMode, () => JSX.Element> = {
87
- single: () => (
88
- <svg width="24" height="24" style={ICON_STYLE}>
89
- <rect
90
- x="4"
91
- y="4"
92
- width="16"
93
- height="16"
94
- stroke="var(--button-icon-hover, rgb(24, 24, 26))"
95
- fill="none"
96
- strokeWidth="2"
97
- />
98
- </svg>
99
- ),
100
- 'split-horizontal': () => (
101
- <svg width="24" height="24" style={ICON_STYLE}>
102
- <rect
103
- x="4"
104
- y="4"
105
- width="16"
106
- height="7"
107
- stroke="var(--button-icon-hover, rgb(24, 24, 26))"
108
- fill="none"
109
- strokeWidth="2"
110
- />
111
- <rect
112
- x="4"
113
- y="13"
114
- width="16"
115
- height="7"
116
- stroke="var(--button-icon-hover, rgb(24, 24, 26))"
117
- fill="none"
118
- strokeWidth="2"
119
- />
120
- </svg>
121
- ),
122
- 'split-vertical': () => (
123
- <svg width="24" height="24" style={ICON_STYLE}>
124
- <rect
125
- x="4"
126
- y="4"
127
- width="7"
128
- height="16"
129
- stroke="var(--button-icon-hover, rgb(24, 24, 26))"
130
- fill="none"
131
- strokeWidth="2"
132
- />
133
- <rect
134
- x="13"
135
- y="4"
136
- width="7"
137
- height="16"
138
- stroke="var(--button-icon-hover, rgb(24, 24, 26))"
139
- fill="none"
140
- strokeWidth="2"
141
- />
142
- </svg>
143
- )
144
- };
145
-
146
- // Define menu items for the popup menu.
147
- const MENU_ITEMS: Array<{value: ViewMode; icon: () => JSX.Element; label: string}> = [
148
- {value: 'single', icon: ICONS.single, label: 'Single View'},
149
- {value: 'split-horizontal', icon: ICONS['split-horizontal'], label: 'Split Horizontal'},
150
- {value: 'split-vertical', icon: ICONS['split-vertical'], label: 'Split Vertical'}
151
- ];