@deck.gl/widgets 9.1.3 → 9.1.5

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/dist.dev.js CHANGED
@@ -54,7 +54,11 @@ var __exports__ = (() => {
54
54
  FullscreenWidget: () => FullscreenWidget,
55
55
  LightGlassTheme: () => LightGlassTheme,
56
56
  LightTheme: () => LightTheme,
57
- ZoomWidget: () => ZoomWidget
57
+ ResetViewWidget: () => ResetViewWidget,
58
+ ScreenshotWidget: () => ScreenshotWidget,
59
+ ZoomWidget: () => ZoomWidget,
60
+ _WidgetImpl: () => WidgetImpl,
61
+ _components: () => components_exports
58
62
  });
59
63
 
60
64
  // ../core/bundle/peer-dependency.ts
@@ -234,37 +238,37 @@ var __exports__ = (() => {
234
238
  };
235
239
  }
236
240
  function O(n2, u3, t2, i3, o2, r2, f3, e2, c2, s2) {
237
- var a2, h2, p2, v2, w2, _2, g2, m, x2, C2, M2, P2, $2, I2, H, L2, T2 = u3.type;
241
+ var a2, h3, p2, v2, w2, _2, g2, m, x2, C2, M2, P2, $2, I2, H, L2, T2 = u3.type;
238
242
  if (void 0 !== u3.constructor)
239
243
  return null;
240
244
  128 & t2.__u && (c2 = !!(32 & t2.__u), r2 = [e2 = u3.__e = t2.__e]), (a2 = l.__b) && a2(u3);
241
245
  n:
242
246
  if ("function" == typeof T2)
243
247
  try {
244
- if (m = u3.props, x2 = "prototype" in T2 && T2.prototype.render, C2 = (a2 = T2.contextType) && i3[a2.__c], M2 = a2 ? C2 ? C2.props.value : a2.__ : i3, t2.__c ? g2 = (h2 = u3.__c = t2.__c).__ = h2.__E : (x2 ? u3.__c = h2 = new T2(m, M2) : (u3.__c = h2 = new b(m, M2), h2.constructor = T2, h2.render = q), C2 && C2.sub(h2), h2.props = m, h2.state || (h2.state = {}), h2.context = M2, h2.__n = i3, p2 = h2.__d = true, h2.__h = [], h2._sb = []), x2 && null == h2.__s && (h2.__s = h2.state), x2 && null != T2.getDerivedStateFromProps && (h2.__s == h2.state && (h2.__s = d({}, h2.__s)), d(h2.__s, T2.getDerivedStateFromProps(m, h2.__s))), v2 = h2.props, w2 = h2.state, h2.__v = u3, p2)
245
- x2 && null == T2.getDerivedStateFromProps && null != h2.componentWillMount && h2.componentWillMount(), x2 && null != h2.componentDidMount && h2.__h.push(h2.componentDidMount);
248
+ if (m = u3.props, x2 = "prototype" in T2 && T2.prototype.render, C2 = (a2 = T2.contextType) && i3[a2.__c], M2 = a2 ? C2 ? C2.props.value : a2.__ : i3, t2.__c ? g2 = (h3 = u3.__c = t2.__c).__ = h3.__E : (x2 ? u3.__c = h3 = new T2(m, M2) : (u3.__c = h3 = new b(m, M2), h3.constructor = T2, h3.render = q), C2 && C2.sub(h3), h3.props = m, h3.state || (h3.state = {}), h3.context = M2, h3.__n = i3, p2 = h3.__d = true, h3.__h = [], h3._sb = []), x2 && null == h3.__s && (h3.__s = h3.state), x2 && null != T2.getDerivedStateFromProps && (h3.__s == h3.state && (h3.__s = d({}, h3.__s)), d(h3.__s, T2.getDerivedStateFromProps(m, h3.__s))), v2 = h3.props, w2 = h3.state, h3.__v = u3, p2)
249
+ x2 && null == T2.getDerivedStateFromProps && null != h3.componentWillMount && h3.componentWillMount(), x2 && null != h3.componentDidMount && h3.__h.push(h3.componentDidMount);
246
250
  else {
247
- if (x2 && null == T2.getDerivedStateFromProps && m !== v2 && null != h2.componentWillReceiveProps && h2.componentWillReceiveProps(m, M2), !h2.__e && (null != h2.shouldComponentUpdate && false === h2.shouldComponentUpdate(m, h2.__s, M2) || u3.__v === t2.__v)) {
248
- for (u3.__v !== t2.__v && (h2.props = m, h2.state = h2.__s, h2.__d = false), u3.__e = t2.__e, u3.__k = t2.__k, u3.__k.forEach(function(n3) {
251
+ if (x2 && null == T2.getDerivedStateFromProps && m !== v2 && null != h3.componentWillReceiveProps && h3.componentWillReceiveProps(m, M2), !h3.__e && (null != h3.shouldComponentUpdate && false === h3.shouldComponentUpdate(m, h3.__s, M2) || u3.__v === t2.__v)) {
252
+ for (u3.__v !== t2.__v && (h3.props = m, h3.state = h3.__s, h3.__d = false), u3.__e = t2.__e, u3.__k = t2.__k, u3.__k.forEach(function(n3) {
249
253
  n3 && (n3.__ = u3);
250
- }), P2 = 0; P2 < h2._sb.length; P2++)
251
- h2.__h.push(h2._sb[P2]);
252
- h2._sb = [], h2.__h.length && f3.push(h2);
254
+ }), P2 = 0; P2 < h3._sb.length; P2++)
255
+ h3.__h.push(h3._sb[P2]);
256
+ h3._sb = [], h3.__h.length && f3.push(h3);
253
257
  break n;
254
258
  }
255
- null != h2.componentWillUpdate && h2.componentWillUpdate(m, h2.__s, M2), x2 && null != h2.componentDidUpdate && h2.__h.push(function() {
256
- h2.componentDidUpdate(v2, w2, _2);
259
+ null != h3.componentWillUpdate && h3.componentWillUpdate(m, h3.__s, M2), x2 && null != h3.componentDidUpdate && h3.__h.push(function() {
260
+ h3.componentDidUpdate(v2, w2, _2);
257
261
  });
258
262
  }
259
- if (h2.context = M2, h2.props = m, h2.__P = n2, h2.__e = false, $2 = l.__r, I2 = 0, x2) {
260
- for (h2.state = h2.__s, h2.__d = false, $2 && $2(u3), a2 = h2.render(h2.props, h2.state, h2.context), H = 0; H < h2._sb.length; H++)
261
- h2.__h.push(h2._sb[H]);
262
- h2._sb = [];
263
+ if (h3.context = M2, h3.props = m, h3.__P = n2, h3.__e = false, $2 = l.__r, I2 = 0, x2) {
264
+ for (h3.state = h3.__s, h3.__d = false, $2 && $2(u3), a2 = h3.render(h3.props, h3.state, h3.context), H = 0; H < h3._sb.length; H++)
265
+ h3.__h.push(h3._sb[H]);
266
+ h3._sb = [];
263
267
  } else
264
268
  do {
265
- h2.__d = false, $2 && $2(u3), a2 = h2.render(h2.props, h2.state, h2.context), h2.state = h2.__s;
266
- } while (h2.__d && ++I2 < 25);
267
- h2.state = h2.__s, null != h2.getChildContext && (i3 = d(d({}, i3), h2.getChildContext())), x2 && !p2 && null != h2.getSnapshotBeforeUpdate && (_2 = h2.getSnapshotBeforeUpdate(v2, w2)), S(n2, y(L2 = null != a2 && a2.type === k && null == a2.key ? a2.props.children : a2) ? L2 : [L2], u3, t2, i3, o2, r2, f3, e2, c2, s2), h2.base = u3.__e, u3.__u &= -161, h2.__h.length && f3.push(h2), g2 && (h2.__E = h2.__ = null);
269
+ h3.__d = false, $2 && $2(u3), a2 = h3.render(h3.props, h3.state, h3.context), h3.state = h3.__s;
270
+ } while (h3.__d && ++I2 < 25);
271
+ h3.state = h3.__s, null != h3.getChildContext && (i3 = d(d({}, i3), h3.getChildContext())), x2 && !p2 && null != h3.getSnapshotBeforeUpdate && (_2 = h3.getSnapshotBeforeUpdate(v2, w2)), S(n2, y(L2 = null != a2 && a2.type === k && null == a2.key ? a2.props.children : a2) ? L2 : [L2], u3, t2, i3, o2, r2, f3, e2, c2, s2), h3.base = u3.__e, u3.__u &= -161, h3.__h.length && f3.push(h3), g2 && (h3.__E = h3.__ = null);
268
272
  } catch (n3) {
269
273
  if (u3.__v = null, c2 || null != r2) {
270
274
  for (u3.__u |= c2 ? 160 : 32; e2 && 8 === e2.nodeType && e2.nextSibling; )
@@ -388,6 +392,14 @@ var __exports__ = (() => {
388
392
  return n2.__v.__b - l2.__v.__b;
389
393
  }, P.__r = 0, e = 0, c = F(false), s = F(true), a = 0;
390
394
 
395
+ // src/components.tsx
396
+ var components_exports = {};
397
+ __export(components_exports, {
398
+ ButtonGroup: () => ButtonGroup,
399
+ GroupedIconButton: () => GroupedIconButton,
400
+ IconButton: () => IconButton
401
+ });
402
+
391
403
  // ../../node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js
392
404
  var f2 = 0;
393
405
  var i2 = Array.isArray;
@@ -667,8 +679,8 @@ var __exports__ = (() => {
667
679
 
668
680
  // src/zoom-widget.tsx
669
681
  var import_core4 = __toESM(require_core(), 1);
670
- var ZoomWidget = class {
671
- constructor(props) {
682
+ var _ZoomWidget = class {
683
+ constructor(props = {}) {
672
684
  this.id = "zoom";
673
685
  this.placement = "top-left";
674
686
  this.viewId = null;
@@ -677,12 +689,8 @@ var __exports__ = (() => {
677
689
  this.viewId = props.viewId ?? this.viewId;
678
690
  this.placement = props.placement ?? this.placement;
679
691
  this.props = {
680
- ...props,
681
- orientation: props.orientation ?? "vertical",
682
- transitionDuration: props.transitionDuration ?? 200,
683
- zoomInLabel: props.zoomInLabel ?? "Zoom In",
684
- zoomOutLabel: props.zoomOutLabel ?? "Zoom Out",
685
- style: props.style ?? {}
692
+ ..._ZoomWidget.defaultProps,
693
+ ...props
686
694
  };
687
695
  }
688
696
  onAdd({ deck }) {
@@ -728,11 +736,13 @@ var __exports__ = (() => {
728
736
  const viewId = this.viewId || viewport?.id || "default-view";
729
737
  const nextViewState = {
730
738
  ...viewport,
731
- zoom: nextZoom,
732
- transitionDuration: this.props.transitionDuration,
733
- transitionInterpolator: new import_core4.FlyToInterpolator()
739
+ zoom: nextZoom
734
740
  };
735
- this.deck._onViewStateChange({ viewId, viewState: nextViewState, interactionState: {} });
741
+ if (this.props.transitionDuration > 0) {
742
+ nextViewState.transitionDuration = this.props.transitionDuration;
743
+ nextViewState.transitionInterpolator = "latitude" in nextViewState ? new import_core4.FlyToInterpolator() : new import_core4.LinearInterpolator();
744
+ }
745
+ this.setViewState(viewId, nextViewState);
736
746
  }
737
747
  handleZoomIn() {
738
748
  for (const viewport of Object.values(this.viewports)) {
@@ -744,6 +754,12 @@ var __exports__ = (() => {
744
754
  this.handleZoom(viewport, viewport.zoom - 1);
745
755
  }
746
756
  }
757
+ /**
758
+ * @todo - move to deck or widget manager
759
+ */
760
+ setViewState(viewId, viewState) {
761
+ this.deck._onViewStateChange({ viewId, viewState, interactionState: {} });
762
+ }
747
763
  update() {
748
764
  const element = this.element;
749
765
  if (!element) {
@@ -770,6 +786,188 @@ var __exports__ = (() => {
770
786
  B(ui, element);
771
787
  }
772
788
  };
789
+ var ZoomWidget = _ZoomWidget;
790
+ ZoomWidget.defaultProps = {
791
+ id: "zoom-widget",
792
+ style: {},
793
+ placement: "top-left",
794
+ className: void 0,
795
+ orientation: "vertical",
796
+ transitionDuration: 200,
797
+ zoomInLabel: "Zoom In",
798
+ zoomOutLabel: "Zoom Out",
799
+ viewId: void 0
800
+ };
801
+
802
+ // src/widget-impl.ts
803
+ var import_core5 = __toESM(require_core(), 1);
804
+ var WidgetImpl = class {
805
+ constructor(props) {
806
+ this.id = props.id || "widget";
807
+ this.props = props;
808
+ }
809
+ onAdd({ deck }) {
810
+ this.deck = deck;
811
+ const { style, className } = this.props;
812
+ const el = this._createRootElement({
813
+ widgetClassName: this.className,
814
+ className,
815
+ style
816
+ });
817
+ this.element = el;
818
+ this.onRenderHTML();
819
+ return this.element;
820
+ }
821
+ onRemove() {
822
+ this.deck = void 0;
823
+ this.element = void 0;
824
+ }
825
+ setProps(props) {
826
+ const oldProps = this.props;
827
+ const el = this.element;
828
+ if (el) {
829
+ if (oldProps.className !== props.className) {
830
+ if (oldProps.className)
831
+ el.classList.remove(oldProps.className);
832
+ if (props.className)
833
+ el.classList.add(props.className);
834
+ }
835
+ if (!(0, import_core5._deepEqual)(oldProps.style, props.style, 1)) {
836
+ (0, import_core5._removeStyles)(el, oldProps.style);
837
+ (0, import_core5._applyStyles)(el, props.style);
838
+ }
839
+ }
840
+ Object.assign(this.props, props);
841
+ this.onRenderHTML();
842
+ }
843
+ _createRootElement(props) {
844
+ const { widgetClassName, className, style } = props;
845
+ const element = document.createElement("div");
846
+ ["deck-widget", widgetClassName, className].filter((cls) => typeof cls === "string" && cls.length > 0).forEach((className2) => element.classList.add(className2));
847
+ (0, import_core5._applyStyles)(element, style);
848
+ return element;
849
+ }
850
+ };
851
+ WidgetImpl.defaultProps = {
852
+ id: "widget",
853
+ style: {},
854
+ className: ""
855
+ };
856
+
857
+ // src/screenshot-widget.tsx
858
+ var _ScreenshotWidget = class extends WidgetImpl {
859
+ constructor(props = {}) {
860
+ super({ ..._ScreenshotWidget.defaultProps, ...props });
861
+ this.className = "deck-widget-screenshot";
862
+ this.placement = "top-left";
863
+ this.placement = props.placement ?? this.placement;
864
+ }
865
+ setProps(props) {
866
+ this.placement = props.placement ?? this.placement;
867
+ super.setProps(props);
868
+ }
869
+ onRenderHTML() {
870
+ const element = this.element;
871
+ if (!element)
872
+ return;
873
+ B(
874
+ /* @__PURE__ */ u2(
875
+ IconButton,
876
+ {
877
+ className: "deck-widget-camera",
878
+ label: this.props.label,
879
+ onClick: this.handleClick.bind(this)
880
+ }
881
+ ),
882
+ element
883
+ );
884
+ }
885
+ handleClick() {
886
+ if (this.props.onCapture) {
887
+ this.props.onCapture(this);
888
+ return;
889
+ }
890
+ const dataURL = this.captureScreenToDataURL(this.props.imageFormat);
891
+ if (dataURL) {
892
+ this.downloadDataURL(dataURL, this.props.filename);
893
+ }
894
+ }
895
+ /** @note only captures canvas contents, not HTML DOM or CSS styles */
896
+ captureScreenToDataURL(imageFormat) {
897
+ const canvas = this.deck?.getCanvas();
898
+ return canvas?.toDataURL(imageFormat);
899
+ }
900
+ /** Download a data URL */
901
+ downloadDataURL(dataURL, filename) {
902
+ const link = document.createElement("a");
903
+ link.href = dataURL;
904
+ link.download = filename;
905
+ link.click();
906
+ }
907
+ };
908
+ var ScreenshotWidget = _ScreenshotWidget;
909
+ ScreenshotWidget.defaultProps = {
910
+ ...WidgetImpl.defaultProps,
911
+ id: "screenshot",
912
+ placement: "top-left",
913
+ label: "Screenshot",
914
+ filename: "screenshot.png",
915
+ imageFormat: "image/png",
916
+ onCapture: void 0
917
+ };
918
+
919
+ // src/reset-view-widget.tsx
920
+ var _ResetViewWidget = class extends WidgetImpl {
921
+ constructor(props = {}) {
922
+ super({ ..._ResetViewWidget.defaultProps, ...props });
923
+ this.className = "deck-widget-reset-view";
924
+ this.placement = "top-left";
925
+ this.placement = props.placement ?? this.placement;
926
+ }
927
+ setProps(props) {
928
+ this.placement = props.placement ?? this.placement;
929
+ super.setProps(props);
930
+ }
931
+ onRenderHTML() {
932
+ const element = this.element;
933
+ if (!element)
934
+ return;
935
+ B(
936
+ /* @__PURE__ */ u2(
937
+ IconButton,
938
+ {
939
+ className: "deck-widget-reset-focus",
940
+ label: this.props.label,
941
+ onClick: this.handleClick.bind(this)
942
+ }
943
+ ),
944
+ element
945
+ );
946
+ }
947
+ handleClick() {
948
+ const initialViewState = this.props.initialViewState || this.deck?.props.initialViewState;
949
+ this.setViewState(initialViewState);
950
+ }
951
+ setViewState(viewState) {
952
+ const viewId = this.props.viewId || viewState?.id || "default-view";
953
+ const nextViewState = {
954
+ ...viewState
955
+ // only works for geospatial?
956
+ // transitionDuration: this.props.transitionDuration,
957
+ // transitionInterpolator: new FlyToInterpolator()
958
+ };
959
+ this.deck._onViewStateChange({ viewId, viewState: nextViewState, interactionState: {} });
960
+ }
961
+ };
962
+ var ResetViewWidget = _ResetViewWidget;
963
+ ResetViewWidget.defaultProps = {
964
+ ...WidgetImpl.defaultProps,
965
+ id: "reset-view",
966
+ placement: "top-left",
967
+ label: "Reset View",
968
+ initialViewState: void 0,
969
+ viewId: void 0
970
+ };
773
971
 
774
972
  // src/themes.ts
775
973
  var LightTheme = {
package/dist/index.cjs CHANGED
@@ -26,7 +26,11 @@ __export(dist_exports, {
26
26
  FullscreenWidget: () => FullscreenWidget,
27
27
  LightGlassTheme: () => LightGlassTheme,
28
28
  LightTheme: () => LightTheme,
29
- ZoomWidget: () => ZoomWidget
29
+ ResetViewWidget: () => ResetViewWidget,
30
+ ScreenshotWidget: () => ScreenshotWidget,
31
+ ZoomWidget: () => ZoomWidget,
32
+ _WidgetImpl: () => WidgetImpl,
33
+ _components: () => components_exports
30
34
  });
31
35
  module.exports = __toCommonJS(dist_exports);
32
36
 
@@ -36,6 +40,12 @@ var import_core = require("@deck.gl/core");
36
40
  var import_preact = require("preact");
37
41
 
38
42
  // dist/components.js
43
+ var components_exports = {};
44
+ __export(components_exports, {
45
+ ButtonGroup: () => ButtonGroup,
46
+ GroupedIconButton: () => GroupedIconButton,
47
+ IconButton: () => IconButton
48
+ });
39
49
  var import_jsx_runtime = require("preact/jsx-runtime");
40
50
  var IconButton = (props) => {
41
51
  const { className, label, onClick } = props;
@@ -258,7 +268,7 @@ var import_jsx_runtime4 = require("preact/jsx-runtime");
258
268
  var import_core3 = require("@deck.gl/core");
259
269
  var import_preact3 = require("preact");
260
270
  var ZoomWidget = class {
261
- constructor(props) {
271
+ constructor(props = {}) {
262
272
  this.id = "zoom";
263
273
  this.placement = "top-left";
264
274
  this.viewId = null;
@@ -267,12 +277,8 @@ var ZoomWidget = class {
267
277
  this.viewId = props.viewId ?? this.viewId;
268
278
  this.placement = props.placement ?? this.placement;
269
279
  this.props = {
270
- ...props,
271
- orientation: props.orientation ?? "vertical",
272
- transitionDuration: props.transitionDuration ?? 200,
273
- zoomInLabel: props.zoomInLabel ?? "Zoom In",
274
- zoomOutLabel: props.zoomOutLabel ?? "Zoom Out",
275
- style: props.style ?? {}
280
+ ...ZoomWidget.defaultProps,
281
+ ...props
276
282
  };
277
283
  }
278
284
  onAdd({ deck }) {
@@ -318,11 +324,13 @@ var ZoomWidget = class {
318
324
  const viewId = this.viewId || (viewport == null ? void 0 : viewport.id) || "default-view";
319
325
  const nextViewState = {
320
326
  ...viewport,
321
- zoom: nextZoom,
322
- transitionDuration: this.props.transitionDuration,
323
- transitionInterpolator: new import_core3.FlyToInterpolator()
327
+ zoom: nextZoom
324
328
  };
325
- this.deck._onViewStateChange({ viewId, viewState: nextViewState, interactionState: {} });
329
+ if (this.props.transitionDuration > 0) {
330
+ nextViewState.transitionDuration = this.props.transitionDuration;
331
+ nextViewState.transitionInterpolator = "latitude" in nextViewState ? new import_core3.FlyToInterpolator() : new import_core3.LinearInterpolator();
332
+ }
333
+ this.setViewState(viewId, nextViewState);
326
334
  }
327
335
  handleZoomIn() {
328
336
  for (const viewport of Object.values(this.viewports)) {
@@ -334,6 +342,12 @@ var ZoomWidget = class {
334
342
  this.handleZoom(viewport, viewport.zoom - 1);
335
343
  }
336
344
  }
345
+ /**
346
+ * @todo - move to deck or widget manager
347
+ */
348
+ setViewState(viewId, viewState) {
349
+ this.deck._onViewStateChange({ viewId, viewState, interactionState: {} });
350
+ }
337
351
  update() {
338
352
  const element = this.element;
339
353
  if (!element) {
@@ -343,6 +357,173 @@ var ZoomWidget = class {
343
357
  (0, import_preact3.render)(ui, element);
344
358
  }
345
359
  };
360
+ ZoomWidget.defaultProps = {
361
+ id: "zoom-widget",
362
+ style: {},
363
+ placement: "top-left",
364
+ className: void 0,
365
+ orientation: "vertical",
366
+ transitionDuration: 200,
367
+ zoomInLabel: "Zoom In",
368
+ zoomOutLabel: "Zoom Out",
369
+ viewId: void 0
370
+ };
371
+
372
+ // dist/screenshot-widget.js
373
+ var import_jsx_runtime5 = require("preact/jsx-runtime");
374
+
375
+ // dist/widget-impl.js
376
+ var import_core4 = require("@deck.gl/core");
377
+ var WidgetImpl = class {
378
+ constructor(props) {
379
+ this.id = props.id || "widget";
380
+ this.props = props;
381
+ }
382
+ onAdd({ deck }) {
383
+ this.deck = deck;
384
+ const { style, className } = this.props;
385
+ const el = this._createRootElement({
386
+ widgetClassName: this.className,
387
+ className,
388
+ style
389
+ });
390
+ this.element = el;
391
+ this.onRenderHTML();
392
+ return this.element;
393
+ }
394
+ onRemove() {
395
+ this.deck = void 0;
396
+ this.element = void 0;
397
+ }
398
+ setProps(props) {
399
+ const oldProps = this.props;
400
+ const el = this.element;
401
+ if (el) {
402
+ if (oldProps.className !== props.className) {
403
+ if (oldProps.className)
404
+ el.classList.remove(oldProps.className);
405
+ if (props.className)
406
+ el.classList.add(props.className);
407
+ }
408
+ if (!(0, import_core4._deepEqual)(oldProps.style, props.style, 1)) {
409
+ (0, import_core4._removeStyles)(el, oldProps.style);
410
+ (0, import_core4._applyStyles)(el, props.style);
411
+ }
412
+ }
413
+ Object.assign(this.props, props);
414
+ this.onRenderHTML();
415
+ }
416
+ _createRootElement(props) {
417
+ const { widgetClassName, className, style } = props;
418
+ const element = document.createElement("div");
419
+ ["deck-widget", widgetClassName, className].filter((cls) => typeof cls === "string" && cls.length > 0).forEach((className2) => element.classList.add(className2));
420
+ (0, import_core4._applyStyles)(element, style);
421
+ return element;
422
+ }
423
+ };
424
+ WidgetImpl.defaultProps = {
425
+ id: "widget",
426
+ style: {},
427
+ className: ""
428
+ };
429
+
430
+ // dist/screenshot-widget.js
431
+ var import_preact4 = require("preact");
432
+ var ScreenshotWidget = class extends WidgetImpl {
433
+ constructor(props = {}) {
434
+ super({ ...ScreenshotWidget.defaultProps, ...props });
435
+ this.className = "deck-widget-screenshot";
436
+ this.placement = "top-left";
437
+ this.placement = props.placement ?? this.placement;
438
+ }
439
+ setProps(props) {
440
+ this.placement = props.placement ?? this.placement;
441
+ super.setProps(props);
442
+ }
443
+ onRenderHTML() {
444
+ const element = this.element;
445
+ if (!element)
446
+ return;
447
+ (0, import_preact4.render)((0, import_jsx_runtime5.jsx)(IconButton, { className: "deck-widget-camera", label: this.props.label, onClick: this.handleClick.bind(this) }), element);
448
+ }
449
+ handleClick() {
450
+ if (this.props.onCapture) {
451
+ this.props.onCapture(this);
452
+ return;
453
+ }
454
+ const dataURL = this.captureScreenToDataURL(this.props.imageFormat);
455
+ if (dataURL) {
456
+ this.downloadDataURL(dataURL, this.props.filename);
457
+ }
458
+ }
459
+ /** @note only captures canvas contents, not HTML DOM or CSS styles */
460
+ captureScreenToDataURL(imageFormat) {
461
+ var _a;
462
+ const canvas = (_a = this.deck) == null ? void 0 : _a.getCanvas();
463
+ return canvas == null ? void 0 : canvas.toDataURL(imageFormat);
464
+ }
465
+ /** Download a data URL */
466
+ downloadDataURL(dataURL, filename) {
467
+ const link = document.createElement("a");
468
+ link.href = dataURL;
469
+ link.download = filename;
470
+ link.click();
471
+ }
472
+ };
473
+ ScreenshotWidget.defaultProps = {
474
+ ...WidgetImpl.defaultProps,
475
+ id: "screenshot",
476
+ placement: "top-left",
477
+ label: "Screenshot",
478
+ filename: "screenshot.png",
479
+ imageFormat: "image/png",
480
+ onCapture: void 0
481
+ };
482
+
483
+ // dist/reset-view-widget.js
484
+ var import_jsx_runtime6 = require("preact/jsx-runtime");
485
+ var import_preact5 = require("preact");
486
+ var ResetViewWidget = class extends WidgetImpl {
487
+ constructor(props = {}) {
488
+ super({ ...ResetViewWidget.defaultProps, ...props });
489
+ this.className = "deck-widget-reset-view";
490
+ this.placement = "top-left";
491
+ this.placement = props.placement ?? this.placement;
492
+ }
493
+ setProps(props) {
494
+ this.placement = props.placement ?? this.placement;
495
+ super.setProps(props);
496
+ }
497
+ onRenderHTML() {
498
+ const element = this.element;
499
+ if (!element)
500
+ return;
501
+ (0, import_preact5.render)((0, import_jsx_runtime6.jsx)(IconButton, { className: "deck-widget-reset-focus", label: this.props.label, onClick: this.handleClick.bind(this) }), element);
502
+ }
503
+ handleClick() {
504
+ var _a;
505
+ const initialViewState = this.props.initialViewState || ((_a = this.deck) == null ? void 0 : _a.props.initialViewState);
506
+ this.setViewState(initialViewState);
507
+ }
508
+ setViewState(viewState) {
509
+ const viewId = this.props.viewId || (viewState == null ? void 0 : viewState.id) || "default-view";
510
+ const nextViewState = {
511
+ ...viewState
512
+ // only works for geospatial?
513
+ // transitionDuration: this.props.transitionDuration,
514
+ // transitionInterpolator: new FlyToInterpolator()
515
+ };
516
+ this.deck._onViewStateChange({ viewId, viewState: nextViewState, interactionState: {} });
517
+ }
518
+ };
519
+ ResetViewWidget.defaultProps = {
520
+ ...WidgetImpl.defaultProps,
521
+ id: "reset-view",
522
+ placement: "top-left",
523
+ label: "Reset View",
524
+ initialViewState: void 0,
525
+ viewId: void 0
526
+ };
346
527
 
347
528
  // dist/themes.js
348
529
  var LightTheme = {