@deck.gl/widgets 9.1.12 → 9.2.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 (157) hide show
  1. package/dist/compass-widget.d.ts +11 -34
  2. package/dist/compass-widget.d.ts.map +1 -1
  3. package/dist/compass-widget.js +27 -62
  4. package/dist/compass-widget.js.map +1 -1
  5. package/dist/context-menu-widget.d.ts +37 -0
  6. package/dist/context-menu-widget.d.ts.map +1 -0
  7. package/dist/context-menu-widget.js +74 -0
  8. package/dist/context-menu-widget.js.map +1 -0
  9. package/dist/dist.dev.js +2271 -581
  10. package/dist/fps-widget.d.ts +29 -0
  11. package/dist/fps-widget.d.ts.map +1 -0
  12. package/dist/fps-widget.js +51 -0
  13. package/dist/fps-widget.js.map +1 -0
  14. package/dist/fullscreen-widget.d.ts +15 -33
  15. package/dist/fullscreen-widget.d.ts.map +1 -1
  16. package/dist/fullscreen-widget.js +20 -51
  17. package/dist/fullscreen-widget.js.map +1 -1
  18. package/dist/geocoder-widget.d.ts +51 -0
  19. package/dist/geocoder-widget.d.ts.map +1 -0
  20. package/dist/geocoder-widget.js +138 -0
  21. package/dist/geocoder-widget.js.map +1 -0
  22. package/dist/gimbal-widget.d.ts +33 -0
  23. package/dist/gimbal-widget.d.ts.map +1 -0
  24. package/dist/gimbal-widget.js +116 -0
  25. package/dist/gimbal-widget.js.map +1 -0
  26. package/dist/index.cjs +1587 -341
  27. package/dist/index.cjs.map +4 -4
  28. package/dist/index.d.ts +37 -8
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +27 -7
  31. package/dist/index.js.map +1 -1
  32. package/dist/info-widget.d.ts +37 -0
  33. package/dist/info-widget.d.ts.map +1 -0
  34. package/dist/info-widget.js +183 -0
  35. package/dist/info-widget.js.map +1 -0
  36. package/dist/lib/components/button-group.d.ts +8 -0
  37. package/dist/lib/components/button-group.d.ts.map +1 -0
  38. package/dist/lib/components/button-group.js +7 -0
  39. package/dist/lib/components/button-group.js.map +1 -0
  40. package/dist/lib/components/dropdown-menu.d.ts +8 -0
  41. package/dist/lib/components/dropdown-menu.d.ts.map +1 -0
  42. package/dist/lib/components/dropdown-menu.js +55 -0
  43. package/dist/lib/components/dropdown-menu.js.map +1 -0
  44. package/dist/lib/components/grouped-icon-button.d.ts +8 -0
  45. package/dist/lib/components/grouped-icon-button.d.ts.map +1 -0
  46. package/dist/lib/components/grouped-icon-button.js +7 -0
  47. package/dist/lib/components/grouped-icon-button.js.map +1 -0
  48. package/dist/lib/components/icon-button.d.ts +11 -0
  49. package/dist/lib/components/icon-button.d.ts.map +1 -0
  50. package/dist/lib/components/icon-button.js +7 -0
  51. package/dist/lib/components/icon-button.js.map +1 -0
  52. package/dist/lib/components/icon-menu.d.ts +16 -0
  53. package/dist/lib/components/icon-menu.d.ts.map +1 -0
  54. package/dist/lib/components/icon-menu.js +49 -0
  55. package/dist/lib/components/icon-menu.js.map +1 -0
  56. package/dist/lib/components/simple-menu.d.ts +16 -0
  57. package/dist/lib/components/simple-menu.d.ts.map +1 -0
  58. package/dist/lib/components/simple-menu.js +30 -0
  59. package/dist/lib/components/simple-menu.js.map +1 -0
  60. package/dist/lib/geocode/geocoder-history.d.ts +23 -0
  61. package/dist/lib/geocode/geocoder-history.d.ts.map +1 -0
  62. package/dist/lib/geocode/geocoder-history.js +64 -0
  63. package/dist/lib/geocode/geocoder-history.js.map +1 -0
  64. package/dist/lib/geocode/geocoder.d.ts +15 -0
  65. package/dist/lib/geocode/geocoder.d.ts.map +1 -0
  66. package/dist/lib/geocode/geocoder.js +5 -0
  67. package/dist/lib/geocode/geocoder.js.map +1 -0
  68. package/dist/lib/geocode/geocoders.d.ts +68 -0
  69. package/dist/lib/geocode/geocoders.d.ts.map +1 -0
  70. package/dist/lib/geocode/geocoders.js +182 -0
  71. package/dist/lib/geocode/geocoders.js.map +1 -0
  72. package/dist/loading-widget.d.ts +26 -0
  73. package/dist/loading-widget.d.ts.map +1 -0
  74. package/dist/loading-widget.js +41 -0
  75. package/dist/loading-widget.js.map +1 -0
  76. package/dist/reset-view-widget.d.ts +4 -4
  77. package/dist/reset-view-widget.d.ts.map +1 -1
  78. package/dist/reset-view-widget.js +7 -10
  79. package/dist/reset-view-widget.js.map +1 -1
  80. package/dist/scale-widget.d.ts +28 -0
  81. package/dist/scale-widget.d.ts.map +1 -0
  82. package/dist/scale-widget.js +111 -0
  83. package/dist/scale-widget.js.map +1 -0
  84. package/dist/screenshot-widget.d.ts +4 -4
  85. package/dist/screenshot-widget.d.ts.map +1 -1
  86. package/dist/screenshot-widget.js +7 -14
  87. package/dist/screenshot-widget.js.map +1 -1
  88. package/dist/splitter-widget.d.ts +32 -0
  89. package/dist/splitter-widget.d.ts.map +1 -0
  90. package/dist/splitter-widget.js +123 -0
  91. package/dist/splitter-widget.js.map +1 -0
  92. package/dist/stats-widget.d.ts +36 -0
  93. package/dist/stats-widget.d.ts.map +1 -0
  94. package/dist/stats-widget.js +115 -0
  95. package/dist/stats-widget.js.map +1 -0
  96. package/dist/stylesheet.css +121 -4
  97. package/dist/theme-widget.d.ts +31 -0
  98. package/dist/theme-widget.d.ts.map +1 -0
  99. package/dist/theme-widget.js +83 -0
  100. package/dist/theme-widget.js.map +1 -0
  101. package/dist/themes.d.ts +65 -36
  102. package/dist/themes.d.ts.map +1 -1
  103. package/dist/themes.js +20 -8
  104. package/dist/themes.js.map +1 -1
  105. package/dist/timeline-widget.d.ts +59 -0
  106. package/dist/timeline-widget.d.ts.map +1 -0
  107. package/dist/timeline-widget.js +83 -0
  108. package/dist/timeline-widget.js.map +1 -0
  109. package/dist/view-selector-widget.d.ts +33 -0
  110. package/dist/view-selector-widget.d.ts.map +1 -0
  111. package/dist/view-selector-widget.js +62 -0
  112. package/dist/view-selector-widget.js.map +1 -0
  113. package/dist/zoom-widget.d.ts +14 -43
  114. package/dist/zoom-widget.d.ts.map +1 -1
  115. package/dist/zoom-widget.js +14 -56
  116. package/dist/zoom-widget.js.map +1 -1
  117. package/dist.min.js +3 -1
  118. package/package.json +4 -3
  119. package/src/compass-widget.tsx +44 -106
  120. package/src/context-menu-widget.tsx +115 -0
  121. package/src/fps-widget.tsx +67 -0
  122. package/src/fullscreen-widget.tsx +33 -86
  123. package/src/geocoder-widget.tsx +209 -0
  124. package/src/gimbal-widget.tsx +188 -0
  125. package/src/index.ts +58 -8
  126. package/src/info-widget.tsx +225 -0
  127. package/src/lib/components/button-group.tsx +16 -0
  128. package/src/lib/components/dropdown-menu.tsx +98 -0
  129. package/src/lib/components/grouped-icon-button.tsx +24 -0
  130. package/src/lib/components/icon-button.tsx +30 -0
  131. package/src/lib/components/icon-menu.tsx +89 -0
  132. package/src/lib/components/simple-menu.tsx +52 -0
  133. package/src/lib/geocode/geocoder-history.ts +73 -0
  134. package/src/lib/geocode/geocoder.ts +15 -0
  135. package/src/lib/geocode/geocoders.ts +199 -0
  136. package/src/loading-widget.tsx +67 -0
  137. package/src/reset-view-widget.tsx +8 -11
  138. package/src/scale-widget.tsx +183 -0
  139. package/src/screenshot-widget.tsx +9 -11
  140. package/src/splitter-widget.tsx +179 -0
  141. package/src/stats-widget.tsx +166 -0
  142. package/src/stylesheet.css +121 -4
  143. package/src/theme-widget.tsx +120 -0
  144. package/src/themes.ts +45 -12
  145. package/src/timeline-widget.tsx +155 -0
  146. package/src/view-selector-widget.tsx +108 -0
  147. package/src/zoom-widget.tsx +39 -113
  148. package/dist/components.d.ts +0 -4
  149. package/dist/components.d.ts.map +0 -1
  150. package/dist/components.js +0 -17
  151. package/dist/components.js.map +0 -1
  152. package/dist/widget-impl.d.ts +0 -29
  153. package/dist/widget-impl.d.ts.map +0 -1
  154. package/dist/widget-impl.js +0 -60
  155. package/dist/widget-impl.js.map +0 -1
  156. package/src/components.tsx +0 -38
  157. package/src/widget-impl.ts +0 -88
@@ -2,68 +2,32 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- /* global document */
6
- import {
7
- FlyToInterpolator,
8
- LinearInterpolator,
9
- _deepEqual as deepEqual,
10
- _applyStyles as applyStyles,
11
- _removeStyles as removeStyles
12
- } from '@deck.gl/core';
13
- import type {Deck, Viewport, Widget, WidgetPlacement} from '@deck.gl/core';
5
+ import {Widget, FlyToInterpolator, LinearInterpolator} from '@deck.gl/core';
6
+ import {Viewport, WidgetProps, WidgetPlacement} from '@deck.gl/core';
14
7
  import {render} from 'preact';
15
- import {ButtonGroup, GroupedIconButton} from './components';
8
+ import {ButtonGroup} from './lib/components/button-group';
9
+ import {GroupedIconButton} from './lib/components/grouped-icon-button';
16
10
 
17
- export type ZoomWidgetProps = {
18
- id?: string;
19
- /**
20
- * Widget positioning within the view. Default 'top-left'.
21
- */
11
+ export type ZoomWidgetProps = WidgetProps & {
12
+ /** Widget positioning within the view. Default 'top-left'. */
22
13
  placement?: WidgetPlacement;
23
- /**
24
- * View to attach to and interact with. Required when using multiple views.
25
- */
14
+ /** View to attach to and interact with. Required when using multiple views. */
26
15
  viewId?: string | null;
27
- /**
28
- * Button orientation.
29
- */
16
+ /** Button orientation. */
30
17
  orientation?: 'vertical' | 'horizontal';
31
- /**
32
- * Tooltip message on zoom in button.
33
- */
18
+ /** Tooltip message on zoom in button. */
34
19
  zoomInLabel?: string;
35
- /**
36
- * Tooltip message on zoom out button.
37
- */
20
+ /** Tooltip message on zoom out button. */
38
21
  zoomOutLabel?: string;
39
- /**
40
- * Zoom transition duration in ms. 0 disables the transition
41
- */
22
+ /** Zoom transition duration in ms. 0 disables the transition */
42
23
  transitionDuration?: number;
43
- /**
44
- * CSS inline style overrides.
45
- */
46
- style?: Partial<CSSStyleDeclaration>;
47
- /**
48
- * Additional CSS class.
49
- */
50
- className?: string;
51
24
  };
52
25
 
53
- export class ZoomWidget implements Widget<ZoomWidgetProps> {
54
- id = 'zoom';
55
- props: Required<ZoomWidgetProps>;
56
- placement: WidgetPlacement = 'top-left';
57
- viewId?: string | null = null;
58
- viewports: {[id: string]: Viewport} = {};
59
- deck?: Deck<any>;
60
- element?: HTMLDivElement;
61
-
26
+ export class ZoomWidget extends Widget<ZoomWidgetProps> {
62
27
  static defaultProps: Required<ZoomWidgetProps> = {
63
- id: 'zoom-widget',
64
- style: {},
28
+ ...Widget.defaultProps,
29
+ id: 'zoom',
65
30
  placement: 'top-left',
66
- className: undefined!,
67
31
  orientation: 'vertical',
68
32
  transitionDuration: 200,
69
33
  zoomInLabel: 'Zoom In',
@@ -71,53 +35,39 @@ export class ZoomWidget implements Widget<ZoomWidgetProps> {
71
35
  viewId: undefined!
72
36
  };
73
37
 
38
+ className = 'deck-widget-zoom';
39
+ placement: WidgetPlacement = 'top-left';
40
+ viewId?: string | null = null;
41
+ viewports: {[id: string]: Viewport} = {};
42
+
74
43
  constructor(props: ZoomWidgetProps = {}) {
75
- this.id = props.id ?? this.id;
44
+ super(props, ZoomWidget.defaultProps);
76
45
  this.viewId = props.viewId ?? this.viewId;
77
46
  this.placement = props.placement ?? this.placement;
78
-
79
- this.props = {
80
- ...ZoomWidget.defaultProps,
81
- ...props
82
- };
83
- }
84
-
85
- onAdd({deck}: {deck: Deck<any>}): HTMLDivElement {
86
- const {style, className} = this.props;
87
- const element = document.createElement('div');
88
- element.classList.add('deck-widget', 'deck-widget-zoom');
89
- if (className) element.classList.add(className);
90
- applyStyles(element, style);
91
- this.deck = deck;
92
- this.element = element;
93
- this.update();
94
- return element;
95
- }
96
-
97
- onRemove() {
98
- this.deck = undefined;
99
- this.element = undefined;
100
47
  }
101
48
 
102
49
  setProps(props: Partial<ZoomWidgetProps>) {
103
50
  this.placement = props.placement ?? this.placement;
104
51
  this.viewId = props.viewId ?? this.viewId;
105
- const oldProps = this.props;
106
- const el = this.element;
107
- if (el) {
108
- if (oldProps.className !== props.className) {
109
- if (oldProps.className) el.classList.remove(oldProps.className);
110
- if (props.className) el.classList.add(props.className);
111
- }
112
-
113
- if (!deepEqual(oldProps.style, props.style, 1)) {
114
- removeStyles(el, oldProps.style);
115
- applyStyles(el, props.style);
116
- }
117
- }
52
+ super.setProps(props);
53
+ }
118
54
 
119
- Object.assign(this.props, props);
120
- this.update();
55
+ onRenderHTML(rootElement: HTMLElement): void {
56
+ const ui = (
57
+ <ButtonGroup orientation={this.props.orientation}>
58
+ <GroupedIconButton
59
+ onClick={() => this.handleZoomIn()}
60
+ label={this.props.zoomInLabel}
61
+ className="deck-widget-zoom-in"
62
+ />
63
+ <GroupedIconButton
64
+ onClick={() => this.handleZoomOut()}
65
+ label={this.props.zoomOutLabel}
66
+ className="deck-widget-zoom-out"
67
+ />
68
+ </ButtonGroup>
69
+ );
70
+ render(ui, rootElement);
121
71
  }
122
72
 
123
73
  onViewportChange(viewport: Viewport) {
@@ -150,33 +100,9 @@ export class ZoomWidget implements Widget<ZoomWidgetProps> {
150
100
  }
151
101
  }
152
102
 
153
- /**
154
- * @todo - move to deck or widget manager
155
- */
103
+ /** @todo - move to deck or widget manager */
156
104
  private setViewState(viewId: string, viewState: Record<string, unknown>): void {
157
105
  // @ts-ignore Using private method temporary until there's a public one
158
106
  this.deck._onViewStateChange({viewId, viewState, interactionState: {}});
159
107
  }
160
-
161
- private update() {
162
- const element = this.element;
163
- if (!element) {
164
- return;
165
- }
166
- const ui = (
167
- <ButtonGroup orientation={this.props.orientation}>
168
- <GroupedIconButton
169
- onClick={() => this.handleZoomIn()}
170
- label={this.props.zoomInLabel}
171
- className="deck-widget-zoom-in"
172
- />
173
- <GroupedIconButton
174
- onClick={() => this.handleZoomOut()}
175
- label={this.props.zoomOutLabel}
176
- className="deck-widget-zoom-out"
177
- />
178
- </ButtonGroup>
179
- );
180
- render(ui, element);
181
- }
182
108
  }
@@ -1,4 +0,0 @@
1
- export declare const IconButton: (props: any) => import("preact").JSX.Element;
2
- export declare const ButtonGroup: (props: any) => import("preact").JSX.Element;
3
- export declare const GroupedIconButton: (props: any) => import("preact").JSX.Element;
4
- //# sourceMappingURL=components.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../src/components.tsx"],"names":[],"mappings":"AAIA,eAAO,MAAM,UAAU,8CActB,CAAC;AAEF,eAAO,MAAM,WAAW,8CAGvB,CAAC;AAEF,eAAO,MAAM,iBAAiB,8CAY7B,CAAC"}
@@ -1,17 +0,0 @@
1
- import { jsx as _jsx } from "preact/jsx-runtime";
2
- // deck.gl
3
- // SPDX-License-Identifier: MIT
4
- // Copyright (c) vis.gl contributors
5
- export const IconButton = props => {
6
- const { className, label, onClick } = props;
7
- return (_jsx("div", { className: "deck-widget-button", children: _jsx("button", { className: `deck-widget-icon-button ${className}`, type: "button", onClick: onClick, title: label, children: _jsx("div", { className: "deck-widget-icon" }) }) }));
8
- };
9
- export const ButtonGroup = props => {
10
- const { children, orientation } = props;
11
- return _jsx("div", { className: `deck-widget-button-group ${orientation}`, children: children });
12
- };
13
- export const GroupedIconButton = props => {
14
- const { className, label, onClick } = props;
15
- return (_jsx("button", { className: `deck-widget-icon-button ${className}`, type: "button", onClick: onClick, title: label, children: _jsx("div", { className: "deck-widget-icon" }) }));
16
- };
17
- //# sourceMappingURL=components.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"components.js","sourceRoot":"","sources":["../src/components.tsx"],"names":[],"mappings":";AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,CAAC,EAAE;IAChC,MAAM,EAAC,SAAS,EAAE,KAAK,EAAE,OAAO,EAAC,GAAG,KAAK,CAAC;IAC1C,OAAO,CACL,cAAK,SAAS,EAAC,oBAAoB,YACjC,iBACE,SAAS,EAAE,2BAA2B,SAAS,EAAE,EACjD,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,YAEZ,cAAK,SAAS,EAAC,kBAAkB,GAAG,GAC7B,GACL,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,CAAC,EAAE;IACjC,MAAM,EAAC,QAAQ,EAAE,WAAW,EAAC,GAAG,KAAK,CAAC;IACtC,OAAO,cAAK,SAAS,EAAE,4BAA4B,WAAW,EAAE,YAAG,QAAQ,GAAO,CAAC;AACrF,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,CAAC,EAAE;IACvC,MAAM,EAAC,SAAS,EAAE,KAAK,EAAE,OAAO,EAAC,GAAG,KAAK,CAAC;IAC1C,OAAO,CACL,iBACE,SAAS,EAAE,2BAA2B,SAAS,EAAE,EACjD,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,YAEZ,cAAK,SAAS,EAAC,kBAAkB,GAAG,GAC7B,CACV,CAAC;AACJ,CAAC,CAAC"}
@@ -1,29 +0,0 @@
1
- import type { Deck, Widget } from '@deck.gl/core';
2
- export type WidgetImplProps = {
3
- id?: string;
4
- /** CSS inline style overrides. */
5
- style?: Partial<CSSStyleDeclaration>;
6
- /** Additional CSS class. */
7
- className?: string;
8
- };
9
- export declare abstract class WidgetImpl<PropsT extends WidgetImplProps> implements Widget<PropsT> {
10
- id: string;
11
- props: Required<PropsT>;
12
- deck?: Deck<any>;
13
- element?: HTMLDivElement;
14
- static defaultProps: Required<WidgetImplProps>;
15
- abstract className: Required<string>;
16
- constructor(props: Required<PropsT>);
17
- abstract onRenderHTML(): void;
18
- onAdd({ deck }: {
19
- deck: Deck<any>;
20
- }): HTMLDivElement;
21
- onRemove(): void;
22
- setProps(props: Partial<PropsT>): void;
23
- _createRootElement(props: {
24
- widgetClassName: string;
25
- className?: string;
26
- style?: Partial<CSSStyleDeclaration>;
27
- }): HTMLDivElement;
28
- }
29
- //# sourceMappingURL=widget-impl.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"widget-impl.d.ts","sourceRoot":"","sources":["../src/widget-impl.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAC,IAAI,EAAE,MAAM,EAAC,MAAM,eAAe,CAAC;AAEhD,MAAM,MAAM,eAAe,GAAG;IAC5B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,kCAAkC;IAClC,KAAK,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACrC,4BAA4B;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AACF,8BAAsB,UAAU,CAAC,MAAM,SAAS,eAAe,CAAE,YAAW,MAAM,CAAC,MAAM,CAAC;IACxF,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAExB,IAAI,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;IACjB,OAAO,CAAC,EAAE,cAAc,CAAC;IAEzB,MAAM,CAAC,YAAY,EAAE,QAAQ,CAAC,eAAe,CAAC,CAI5C;IAEF,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;gBAEzB,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC;IAKnC,QAAQ,CAAC,YAAY,IAAI,IAAI;IAE7B,KAAK,CAAC,EAAC,IAAI,EAAC,EAAE;QAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAA;KAAC,GAAG,cAAc;IAahD,QAAQ;IAKR,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC;IAmB/B,kBAAkB,CAAC,KAAK,EAAE;QACxB,eAAe,EAAE,MAAM,CAAC;QACxB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,KAAK,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC;KACtC;CASF"}
@@ -1,60 +0,0 @@
1
- // deck.gl
2
- // SPDX-License-Identifier: MIT
3
- // Copyright (c) vis.gl contributors
4
- /* global document */
5
- import { _deepEqual, _applyStyles, _removeStyles } from '@deck.gl/core';
6
- export class WidgetImpl {
7
- constructor(props) {
8
- this.id = props.id || 'widget';
9
- this.props = props;
10
- }
11
- onAdd({ deck }) {
12
- this.deck = deck;
13
- const { style, className } = this.props;
14
- const el = this._createRootElement({
15
- widgetClassName: this.className,
16
- className,
17
- style
18
- });
19
- this.element = el;
20
- this.onRenderHTML();
21
- return this.element;
22
- }
23
- onRemove() {
24
- this.deck = undefined;
25
- this.element = undefined;
26
- }
27
- setProps(props) {
28
- const oldProps = this.props;
29
- const el = this.element;
30
- if (el) {
31
- if (oldProps.className !== props.className) {
32
- if (oldProps.className)
33
- el.classList.remove(oldProps.className);
34
- if (props.className)
35
- el.classList.add(props.className);
36
- }
37
- if (!_deepEqual(oldProps.style, props.style, 1)) {
38
- _removeStyles(el, oldProps.style);
39
- _applyStyles(el, props.style);
40
- }
41
- }
42
- Object.assign(this.props, props);
43
- this.onRenderHTML();
44
- }
45
- _createRootElement(props) {
46
- const { widgetClassName, className, style } = props;
47
- const element = document.createElement('div');
48
- ['deck-widget', widgetClassName, className]
49
- .filter((cls) => typeof cls === 'string' && cls.length > 0)
50
- .forEach(className => element.classList.add(className));
51
- _applyStyles(element, style);
52
- return element;
53
- }
54
- }
55
- WidgetImpl.defaultProps = {
56
- id: 'widget',
57
- style: {},
58
- className: ''
59
- };
60
- //# sourceMappingURL=widget-impl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"widget-impl.js","sourceRoot":"","sources":["../src/widget-impl.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,qBAAqB;AACrB,OAAO,EAAC,UAAU,EAAE,YAAY,EAAE,aAAa,EAAC,MAAM,eAAe,CAAC;AAUtE,MAAM,OAAgB,UAAU;IAe9B,YAAY,KAAuB;QACjC,IAAI,CAAC,EAAE,GAAG,KAAK,CAAC,EAAE,IAAI,QAAQ,CAAC;QAC/B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAID,KAAK,CAAC,EAAC,IAAI,EAAoB;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,MAAM,EAAC,KAAK,EAAE,SAAS,EAAC,GAAG,IAAI,CAAC,KAAK,CAAC;QACtC,MAAM,EAAE,GAAG,IAAI,CAAC,kBAAkB,CAAC;YACjC,eAAe,EAAE,IAAI,CAAC,SAAS;YAC/B,SAAS;YACT,KAAK;SACN,CAAC,CAAC;QACH,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QAClB,IAAI,CAAC,YAAY,EAAE,CAAC;QACpB,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,QAAQ;QACN,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;IAC3B,CAAC;IAED,QAAQ,CAAC,KAAsB;QAC7B,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC;QAC5B,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;QACxB,IAAI,EAAE,EAAE,CAAC;YACP,IAAI,QAAQ,CAAC,SAAS,KAAK,KAAK,CAAC,SAAS,EAAE,CAAC;gBAC3C,IAAI,QAAQ,CAAC,SAAS;oBAAE,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;gBAChE,IAAI,KAAK,CAAC,SAAS;oBAAE,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;YACzD,CAAC;YAED,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,CAAC;gBAChD,aAAa,CAAC,EAAE,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;gBAClC,YAAY,CAAC,EAAE,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;YAChC,CAAC;QACH,CAAC;QAED,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QACjC,IAAI,CAAC,YAAY,EAAE,CAAC;IACtB,CAAC;IAED,kBAAkB,CAAC,KAIlB;QACC,MAAM,EAAC,eAAe,EAAE,SAAS,EAAE,KAAK,EAAC,GAAG,KAAK,CAAC;QAClD,MAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAC9C,CAAC,aAAa,EAAE,eAAe,EAAE,SAAS,CAAC;aACxC,MAAM,CAAC,CAAC,GAAG,EAAiB,EAAE,CAAC,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC;aACzE,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC;QAC1D,YAAY,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAC7B,OAAO,OAAO,CAAC;IACjB,CAAC;;AAhEM,uBAAY,GAA8B;IAC/C,EAAE,EAAE,QAAQ;IACZ,KAAK,EAAE,EAAE;IACT,SAAS,EAAE,EAAE;CACd,CAAC"}
@@ -1,38 +0,0 @@
1
- // deck.gl
2
- // SPDX-License-Identifier: MIT
3
- // Copyright (c) vis.gl contributors
4
-
5
- export const IconButton = props => {
6
- const {className, label, onClick} = props;
7
- return (
8
- <div className="deck-widget-button">
9
- <button
10
- className={`deck-widget-icon-button ${className}`}
11
- type="button"
12
- onClick={onClick}
13
- title={label}
14
- >
15
- <div className="deck-widget-icon" />
16
- </button>
17
- </div>
18
- );
19
- };
20
-
21
- export const ButtonGroup = props => {
22
- const {children, orientation} = props;
23
- return <div className={`deck-widget-button-group ${orientation}`}>{children}</div>;
24
- };
25
-
26
- export const GroupedIconButton = props => {
27
- const {className, label, onClick} = props;
28
- return (
29
- <button
30
- className={`deck-widget-icon-button ${className}`}
31
- type="button"
32
- onClick={onClick}
33
- title={label}
34
- >
35
- <div className="deck-widget-icon" />
36
- </button>
37
- );
38
- };
@@ -1,88 +0,0 @@
1
- // deck.gl
2
- // SPDX-License-Identifier: MIT
3
- // Copyright (c) vis.gl contributors
4
-
5
- /* global document */
6
- import {_deepEqual, _applyStyles, _removeStyles} from '@deck.gl/core';
7
- import type {Deck, Widget} from '@deck.gl/core';
8
-
9
- export type WidgetImplProps = {
10
- id?: string;
11
- /** CSS inline style overrides. */
12
- style?: Partial<CSSStyleDeclaration>;
13
- /** Additional CSS class. */
14
- className?: string;
15
- };
16
- export abstract class WidgetImpl<PropsT extends WidgetImplProps> implements Widget<PropsT> {
17
- id: string;
18
- props: Required<PropsT>;
19
-
20
- deck?: Deck<any>;
21
- element?: HTMLDivElement;
22
-
23
- static defaultProps: Required<WidgetImplProps> = {
24
- id: 'widget',
25
- style: {},
26
- className: ''
27
- };
28
-
29
- abstract className: Required<string>;
30
-
31
- constructor(props: Required<PropsT>) {
32
- this.id = props.id || 'widget';
33
- this.props = props;
34
- }
35
-
36
- abstract onRenderHTML(): void;
37
-
38
- onAdd({deck}: {deck: Deck<any>}): HTMLDivElement {
39
- this.deck = deck;
40
- const {style, className} = this.props;
41
- const el = this._createRootElement({
42
- widgetClassName: this.className,
43
- className,
44
- style
45
- });
46
- this.element = el;
47
- this.onRenderHTML();
48
- return this.element;
49
- }
50
-
51
- onRemove() {
52
- this.deck = undefined;
53
- this.element = undefined;
54
- }
55
-
56
- setProps(props: Partial<PropsT>) {
57
- const oldProps = this.props;
58
- const el = this.element;
59
- if (el) {
60
- if (oldProps.className !== props.className) {
61
- if (oldProps.className) el.classList.remove(oldProps.className);
62
- if (props.className) el.classList.add(props.className);
63
- }
64
-
65
- if (!_deepEqual(oldProps.style, props.style, 1)) {
66
- _removeStyles(el, oldProps.style);
67
- _applyStyles(el, props.style);
68
- }
69
- }
70
-
71
- Object.assign(this.props, props);
72
- this.onRenderHTML();
73
- }
74
-
75
- _createRootElement(props: {
76
- widgetClassName: string;
77
- className?: string;
78
- style?: Partial<CSSStyleDeclaration>;
79
- }) {
80
- const {widgetClassName, className, style} = props;
81
- const element = document.createElement('div');
82
- ['deck-widget', widgetClassName, className]
83
- .filter((cls): cls is string => typeof cls === 'string' && cls.length > 0)
84
- .forEach(className => element.classList.add(className));
85
- _applyStyles(element, style);
86
- return element;
87
- }
88
- }