@deck.gl/widgets 9.3.0 → 9.3.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.
Files changed (40) hide show
  1. package/dist/dist.dev.js +36 -53
  2. package/dist/geocoder-widget.d.ts.map +1 -1
  3. package/dist/geocoder-widget.js +1 -2
  4. package/dist/geocoder-widget.js.map +1 -1
  5. package/dist/index.cjs +41 -54
  6. package/dist/index.cjs.map +3 -3
  7. package/dist/lib/geocode/geocoders.js +6 -3
  8. package/dist/lib/geocode/geocoders.js.map +1 -1
  9. package/dist/popup-widget.d.ts.map +1 -1
  10. package/dist/popup-widget.js +1 -1
  11. package/dist/popup-widget.js.map +1 -1
  12. package/dist/reset-view-widget.d.ts.map +1 -1
  13. package/dist/reset-view-widget.js +1 -2
  14. package/dist/reset-view-widget.js.map +1 -1
  15. package/dist/scrollbar-widget.d.ts +1 -0
  16. package/dist/scrollbar-widget.d.ts.map +1 -1
  17. package/dist/scrollbar-widget.js +10 -3
  18. package/dist/scrollbar-widget.js.map +1 -1
  19. package/dist/splitter-widget.d.ts +7 -7
  20. package/dist/splitter-widget.d.ts.map +1 -1
  21. package/dist/splitter-widget.js.map +1 -1
  22. package/dist/stylesheet.css +5 -0
  23. package/dist/theme-widget.d.ts +2 -2
  24. package/dist/theme-widget.d.ts.map +1 -1
  25. package/dist/theme-widget.js +14 -34
  26. package/dist/theme-widget.js.map +1 -1
  27. package/dist/zoom-widget.d.ts.map +1 -1
  28. package/dist/zoom-widget.js +2 -4
  29. package/dist/zoom-widget.js.map +1 -1
  30. package/dist.min.js +2 -2
  31. package/package.json +2 -2
  32. package/src/geocoder-widget.tsx +1 -2
  33. package/src/lib/geocode/geocoders.ts +7 -3
  34. package/src/popup-widget.tsx +1 -3
  35. package/src/reset-view-widget.tsx +1 -2
  36. package/src/scrollbar-widget.tsx +11 -3
  37. package/src/splitter-widget.tsx +14 -11
  38. package/src/stylesheet.css +5 -0
  39. package/src/theme-widget.tsx +14 -40
  40. package/src/zoom-widget.tsx +2 -4
@@ -148,11 +148,11 @@ function evaluateViews(root: ManagedViewLayout): View[] {
148
148
  }
149
149
 
150
150
  /** Properties for the SplitterWidget */
151
- export type SplitterWidgetProps = WidgetProps & {
151
+ export type SplitterWidgetProps<ViewsT extends View[] = View[]> = WidgetProps & {
152
152
  /** Stacking views descriptor */
153
153
  viewLayout: ViewLayout;
154
154
  /** Callback invoked when the splitter is dragged with the new split value */
155
- onChange?: (views: View[]) => void;
155
+ onChange?: (views: ViewsT) => void;
156
156
  /** Callback invoked when dragging starts */
157
157
  onDragStart?: () => void;
158
158
  /** Callback invoked when dragging ends */
@@ -164,7 +164,10 @@ export type SplitterWidgetProps = WidgetProps & {
164
164
  * across the deck.gl canvas. It positions itself based on the split percentage
165
165
  * of the first view and provides callbacks when dragged.
166
166
  */
167
- export class SplitterWidget extends Widget<SplitterWidgetProps, View[]> {
167
+ export class SplitterWidget<ViewsT extends View[] = View[]> extends Widget<
168
+ SplitterWidgetProps<ViewsT>,
169
+ ViewsT
170
+ > {
168
171
  static defaultProps: Required<SplitterWidgetProps> = {
169
172
  ...Widget.defaultProps,
170
173
  id: 'splitter-widget',
@@ -178,17 +181,17 @@ export class SplitterWidget extends Widget<SplitterWidgetProps, View[]> {
178
181
  placement = 'fill' as const;
179
182
  viewLayouts!: ManagedViewLayout[];
180
183
  /** evaluated from the current viewLayouts */
181
- views!: View[];
184
+ views!: ViewsT;
182
185
  /** views set in the last update */
183
- lastViews?: View[];
186
+ lastViews?: ViewsT;
184
187
  needsUpdate = true;
185
188
 
186
- constructor(props: SplitterWidgetProps) {
189
+ constructor(props: SplitterWidgetProps<ViewsT>) {
187
190
  super(props);
188
191
  this.viewLayouts = parseViewLayout(this.props.viewLayout);
189
192
  }
190
193
 
191
- setProps(props: Partial<SplitterWidgetProps>) {
194
+ setProps(props: Partial<SplitterWidgetProps<ViewsT>>) {
192
195
  if (props.viewLayout && !deepEqual(props.viewLayout, this.props.viewLayout, -1)) {
193
196
  this.viewLayouts = parseViewLayout(props.viewLayout);
194
197
  this.views = undefined!;
@@ -207,9 +210,9 @@ export class SplitterWidget extends Widget<SplitterWidgetProps, View[]> {
207
210
  updateHTML() {
208
211
  if (!this.views) {
209
212
  // viewLayouts has changed, re-evaluate
210
- this.views = evaluateViews(this.viewLayouts[0]);
213
+ this.views = evaluateViews(this.viewLayouts[0]) as ViewsT;
211
214
  // we send a copy to the callback so that externally set views can be differentiated from internal
212
- this.props.onChange(this.views.slice());
215
+ this.props.onChange(this.views.slice() as ViewsT);
213
216
  }
214
217
  // This method is called inside deck.setProps > widgetManager.setProps > widget.setProps
215
218
  // Calling deck.setProps immediately would cause infinite loop
@@ -237,9 +240,9 @@ export class SplitterWidget extends Widget<SplitterWidgetProps, View[]> {
237
240
  private onChange(newSplit: number, layout: ManagedViewLayout) {
238
241
  layout.split = newSplit;
239
242
  // layout has updated, re-evaluate
240
- this.views = evaluateViews(this.viewLayouts[0]);
243
+ this.views = evaluateViews(this.viewLayouts[0]) as ViewsT;
241
244
  // we send a copy to the callback so that externally set views can be differentiated from internal
242
- this.props.onChange(this.views.slice());
245
+ this.props.onChange(this.views.slice() as ViewsT);
243
246
  this.doUpdate();
244
247
  }
245
248
 
@@ -486,6 +486,11 @@
486
486
  .deck-widget.deck-widget-popover {
487
487
  margin: 0 !important;
488
488
  }
489
+ .deck-widget-popup-marker {
490
+ position: absolute;
491
+ pointer-events: all;
492
+ cursor: pointer;
493
+ }
489
494
  .deck-widget-popup-content {
490
495
  border-radius: var(--button-corner-radius, 8px);
491
496
  background: var(--menu-background, #fff);
@@ -56,6 +56,7 @@ export class ThemeWidget extends Widget<ThemeWidgetProps> {
56
56
  className = 'deck-widget-theme';
57
57
  placement: WidgetPlacement = 'top-left';
58
58
  themeMode: 'light' | 'dark' = 'dark';
59
+ appliedTheme: DeckWidgetTheme = {};
59
60
 
60
61
  constructor(props: ThemeWidgetProps = {}) {
61
62
  super(props);
@@ -65,38 +66,15 @@ export class ThemeWidget extends Widget<ThemeWidgetProps> {
65
66
 
66
67
  // eslint-disable-next-line complexity
67
68
  setProps(props: Partial<ThemeWidgetProps>) {
68
- const {lightModeTheme, darkModeTheme, themeMode: prevThemeMode} = this.props;
69
69
  this.placement = props.placement ?? this.placement;
70
70
  this.viewId = props.viewId ?? this.viewId;
71
71
  super.setProps(props);
72
-
73
- const currentMode = this.getThemeMode();
74
-
75
- // Handle controlled mode - apply theme when controlled prop changes
76
- if (props.themeMode !== undefined && props.themeMode !== prevThemeMode) {
77
- this._applyTheme(props.themeMode);
78
- return;
79
- }
80
-
81
- switch (currentMode) {
82
- case 'light':
83
- if (props.lightModeTheme && !deepEqual(props.lightModeTheme, lightModeTheme, 1)) {
84
- this._applyTheme('light');
85
- }
86
- break;
87
- case 'dark':
88
- if (props.darkModeTheme && !deepEqual(props.darkModeTheme, darkModeTheme, 1)) {
89
- this._applyTheme('dark');
90
- }
91
- break;
92
- default:
93
- log.warn(`Invalid theme mode ${currentMode}`)();
94
- }
95
72
  }
96
73
 
97
74
  onRenderHTML(rootElement: HTMLElement): void {
98
75
  const {lightModeLabel, darkModeLabel} = this.props;
99
76
  const currentMode = this.getThemeMode();
77
+ this._applyTheme(currentMode, rootElement);
100
78
 
101
79
  render(
102
80
  <IconButton
@@ -108,11 +86,6 @@ export class ThemeWidget extends Widget<ThemeWidgetProps> {
108
86
  );
109
87
  }
110
88
 
111
- onAdd() {
112
- // Note: theme styling is applied in here onAdd() once DOM element is created
113
- this._applyTheme(this.getThemeMode());
114
- }
115
-
116
89
  /**
117
90
  * Returns the current theme mode.
118
91
  * In controlled mode, returns the themeMode prop.
@@ -132,24 +105,25 @@ export class ThemeWidget extends Widget<ThemeWidgetProps> {
132
105
  // Only update internal state if uncontrolled
133
106
  if (this.props.themeMode === undefined) {
134
107
  this.themeMode = nextMode;
135
- this._applyTheme(nextMode);
108
+ this.updateHTML();
136
109
  }
137
110
  // In controlled mode, parent will update themeMode prop which triggers _applyTheme via setProps
138
111
  }
139
112
 
140
113
  /** Apply theme styling without changing internal state */
141
- _applyTheme(themeMode: 'light' | 'dark') {
142
- const container = this.rootElement?.closest<HTMLDivElement>('.deck-widget-container');
143
- if (container) {
144
- const themeStyle =
145
- themeMode === 'dark' ? this.props.darkModeTheme : this.props.lightModeTheme;
146
- applyStyles(container, themeStyle);
114
+ _applyTheme(themeMode: 'light' | 'dark', rootElement: HTMLElement) {
115
+ const themeStyle = themeMode === 'dark' ? this.props.darkModeTheme : this.props.lightModeTheme;
116
+ if (deepEqual(themeStyle, this.appliedTheme, 1)) {
117
+ return;
118
+ }
119
+ const container = rootElement.closest<HTMLDivElement>('.deck-widget-container');
120
+ if (!container) return;
147
121
 
148
- const label = themeMode === 'dark' ? this.props.darkModeLabel : this.props.lightModeLabel;
149
- log.log(1, `Switched theme to ${label}`, themeStyle)();
122
+ applyStyles(container, themeStyle);
123
+ this.appliedTheme = themeStyle;
150
124
 
151
- this.updateHTML();
152
- }
125
+ const label = themeMode === 'dark' ? this.props.darkModeLabel : this.props.lightModeLabel;
126
+ log.log(1, `Switched theme to ${label}`, themeStyle)();
153
127
  }
154
128
 
155
129
  /** Read browser preference */
@@ -163,15 +163,13 @@ export class ZoomWidget extends Widget<ZoomWidgetProps> {
163
163
  }
164
164
 
165
165
  handleZoomIn() {
166
- const viewIds = this.viewId ? [this.viewId] : (this.deck?.getViews().map(v => v.id) ?? []);
167
- for (const viewId of viewIds) {
166
+ for (const viewId of this.viewIds) {
168
167
  this.handleZoom(viewId, 1);
169
168
  }
170
169
  }
171
170
 
172
171
  handleZoomOut() {
173
- const viewIds = this.viewId ? [this.viewId] : (this.deck?.getViews().map(v => v.id) ?? []);
174
- for (const viewId of viewIds) {
172
+ for (const viewId of this.viewIds) {
175
173
  this.handleZoom(viewId, -1);
176
174
  }
177
175
  }