maplibre-gl-geoagent 0.4.2 → 0.4.3

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 (34) hide show
  1. package/dist/{GeoAgentControl-CM-lWHhd.js → GeoAgentControl-D02UP5lT.js} +79 -41
  2. package/dist/{GeoAgentControl-CM-lWHhd.js.map → GeoAgentControl-D02UP5lT.js.map} +1 -1
  3. package/dist/{GeoAgentControl-NjhimZRg.cjs → GeoAgentControl-wFkbhvbu.cjs} +79 -41
  4. package/dist/{GeoAgentControl-NjhimZRg.cjs.map → GeoAgentControl-wFkbhvbu.cjs.map} +1 -1
  5. package/dist/{anthropic-qn30x05g.js → anthropic-CqhQTvtC.js} +2 -2
  6. package/dist/{anthropic-qn30x05g.js.map → anthropic-CqhQTvtC.js.map} +1 -1
  7. package/dist/{anthropic-poATb89G.cjs → anthropic-S2hd2NQm.cjs} +2 -2
  8. package/dist/{anthropic-poATb89G.cjs.map → anthropic-S2hd2NQm.cjs.map} +1 -1
  9. package/dist/{browser-CRRVT6sN.js → browser-DT7siLDs.js} +2 -2
  10. package/dist/{browser-CRRVT6sN.js.map → browser-DT7siLDs.js.map} +1 -1
  11. package/dist/{browser-DfKdZvWC.cjs → browser-wX4BKxTA.cjs} +2 -2
  12. package/dist/{browser-DfKdZvWC.cjs.map → browser-wX4BKxTA.cjs.map} +1 -1
  13. package/dist/{index-DUXFjmo_.cjs → index-9Vl-_b39.cjs} +2 -2
  14. package/dist/{index-DUXFjmo_.cjs.map → index-9Vl-_b39.cjs.map} +1 -1
  15. package/dist/{index-BHJHkcUd.cjs → index-B70XIdgV.cjs} +2 -2
  16. package/dist/{index-BHJHkcUd.cjs.map → index-B70XIdgV.cjs.map} +1 -1
  17. package/dist/{index-nbt2E_lW.js → index-CvWJMktS.js} +2 -2
  18. package/dist/{index-nbt2E_lW.js.map → index-CvWJMktS.js.map} +1 -1
  19. package/dist/{index-DMcVy720.js → index-ITGaM0CV.js} +2 -2
  20. package/dist/{index-DMcVy720.js.map → index-ITGaM0CV.js.map} +1 -1
  21. package/dist/{index-D8NXbhES.cjs → index-R5s1nbgn.cjs} +2 -2
  22. package/dist/{index-D8NXbhES.cjs.map → index-R5s1nbgn.cjs.map} +1 -1
  23. package/dist/{index-CCdoSNb8.js → index-_-KavWih.js} +2 -2
  24. package/dist/{index-CCdoSNb8.js.map → index-_-KavWih.js.map} +1 -1
  25. package/dist/index.cjs +1 -1
  26. package/dist/index.mjs +1 -1
  27. package/dist/maplibre-gl-geoagent.css +46 -22
  28. package/dist/react.cjs +1 -1
  29. package/dist/react.mjs +1 -1
  30. package/dist/types/lib/core/GeoAgentControl.d.ts +2 -1
  31. package/dist/types/lib/core/GeoAgentControl.d.ts.map +1 -1
  32. package/dist/types/lib/core/types.d.ts +18 -0
  33. package/dist/types/lib/core/types.d.ts.map +1 -1
  34. package/package.json +1 -1
@@ -3518,7 +3518,7 @@ class HttpProtocol extends SerdeContext {
3518
3518
  });
3519
3519
  }
3520
3520
  async loadEventStreamCapability() {
3521
- const { EventStreamSerde } = await import("./index-DMcVy720.js");
3521
+ const { EventStreamSerde } = await import("./index-ITGaM0CV.js");
3522
3522
  return new EventStreamSerde({
3523
3523
  marshaller: this.getEventStreamMarshaller(),
3524
3524
  serializer: this.serializer,
@@ -42664,7 +42664,7 @@ class EarthEngineService {
42664
42664
  }
42665
42665
  async loadEe() {
42666
42666
  if (!this.eePromise) {
42667
- this.eePromise = import("./browser-CRRVT6sN.js").then((n) => n.b).then((module) => {
42667
+ this.eePromise = import("./browser-DT7siLDs.js").then((n) => n.b).then((module) => {
42668
42668
  const imported = "default" in module ? module.default : module;
42669
42669
  const ee = imported;
42670
42670
  const scope2 = globalThis;
@@ -46024,7 +46024,6 @@ class GeoAgentControl {
46024
46024
  __publicField(this, "eventHandlers", new globalThis.Map());
46025
46025
  __publicField(this, "resizeHandler", null);
46026
46026
  __publicField(this, "mapResizeHandler", null);
46027
- __publicField(this, "clickOutsideHandler", null);
46028
46027
  __publicField(this, "panelResizeMoveHandler", null);
46029
46028
  __publicField(this, "panelResizeUpHandler", null);
46030
46029
  __publicField(this, "activeAbortController", null);
@@ -46036,6 +46035,9 @@ class GeoAgentControl {
46036
46035
  panelWidth: options.panelWidth ?? 390,
46037
46036
  panelMinWidth: options.panelMinWidth ?? 320,
46038
46037
  panelMaxWidth: options.panelMaxWidth ?? 720,
46038
+ panelHeight: options.panelHeight,
46039
+ panelMinHeight: options.panelMinHeight ?? 320,
46040
+ panelMaxHeight: options.panelMaxHeight ?? 2e3,
46039
46041
  className: options.className ?? "",
46040
46042
  defaultProvider: options.defaultProvider ?? DEFAULT_PROVIDER,
46041
46043
  storagePrefix: options.storagePrefix ?? DEFAULT_STORAGE_PREFIX,
@@ -46051,6 +46053,7 @@ class GeoAgentControl {
46051
46053
  this.state = {
46052
46054
  collapsed: this.options.collapsed,
46053
46055
  panelWidth: this.constrainPanelWidth(this.options.panelWidth),
46056
+ panelHeight: this.options.panelHeight !== void 0 ? this.constrainPanelHeight(this.options.panelHeight) : void 0,
46054
46057
  busy: false,
46055
46058
  providerId,
46056
46059
  modelId: this.initialModelId(providerId),
@@ -46098,10 +46101,6 @@ class GeoAgentControl {
46098
46101
  this.map.off("resize", this.mapResizeHandler);
46099
46102
  this.mapResizeHandler = null;
46100
46103
  }
46101
- if (this.clickOutsideHandler) {
46102
- document.removeEventListener("click", this.clickOutsideHandler);
46103
- this.clickOutsideHandler = null;
46104
- }
46105
46104
  this.stopPanelResize();
46106
46105
  (_a3 = this.activeAbortController) == null ? void 0 : _a3.abort();
46107
46106
  (_b3 = this.agent) == null ? void 0 : _b3.cancel();
@@ -46141,6 +46140,11 @@ class GeoAgentControl {
46141
46140
  this.state.panelWidth = panelWidth;
46142
46141
  this.panel.style.width = `${panelWidth}px`;
46143
46142
  }
46143
+ if (newState.panelHeight !== void 0 && this.panel) {
46144
+ const panelHeight = this.constrainPanelHeight(newState.panelHeight);
46145
+ this.state.panelHeight = panelHeight;
46146
+ this.panel.style.height = `${panelHeight}px`;
46147
+ }
46144
46148
  if (collapsedChanged) {
46145
46149
  if (this.state.collapsed) {
46146
46150
  (_a3 = this.panel) == null ? void 0 : _a3.classList.remove("expanded");
@@ -46266,6 +46270,9 @@ class GeoAgentControl {
46266
46270
  const panel = document.createElement("div");
46267
46271
  panel.className = "geoagent-panel";
46268
46272
  panel.style.width = `${this.state.panelWidth}px`;
46273
+ if (this.state.panelHeight !== void 0) {
46274
+ panel.style.height = `${this.state.panelHeight}px`;
46275
+ }
46269
46276
  const header = document.createElement("div");
46270
46277
  header.className = "geoagent-panel-header";
46271
46278
  const title2 = document.createElement("span");
@@ -46279,11 +46286,12 @@ class GeoAgentControl {
46279
46286
  const closeButton = document.createElement("button");
46280
46287
  closeButton.className = "geoagent-icon-button";
46281
46288
  closeButton.type = "button";
46282
- closeButton.title = "Collapse panel";
46283
- closeButton.setAttribute("aria-label", "Collapse panel");
46289
+ closeButton.title = "Close";
46290
+ closeButton.setAttribute("aria-label", "Close");
46284
46291
  closeButton.innerHTML = `
46285
46292
  <svg viewBox="0 0 24 24" fill="none" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
46286
- <path d="m18 15-6-6-6 6"></path>
46293
+ <path d="M18 6 6 18"></path>
46294
+ <path d="m6 6 12 12"></path>
46287
46295
  </svg>
46288
46296
  `;
46289
46297
  closeButton.addEventListener("click", () => this.collapse());
@@ -46349,13 +46357,9 @@ class GeoAgentControl {
46349
46357
  </div>
46350
46358
  </form>
46351
46359
  `;
46352
- const resizeHandle = document.createElement("div");
46353
- resizeHandle.className = "geoagent-panel-resize-handle";
46354
- resizeHandle.setAttribute("role", "separator");
46355
- resizeHandle.setAttribute("aria-orientation", "vertical");
46356
- resizeHandle.setAttribute("aria-label", "Resize GeoAgent panel");
46357
- resizeHandle.addEventListener("mousedown", (event) => this.startPanelResize(event));
46358
- panel.append(header, content, resizeHandle);
46360
+ const resizeHandleLeft = this.createResizeHandle("bottom-left");
46361
+ const resizeHandleRight = this.createResizeHandle("bottom-right");
46362
+ panel.append(header, content, resizeHandleLeft, resizeHandleRight);
46359
46363
  this.ui = {
46360
46364
  status,
46361
46365
  providerSelect: this.requiredElement(content, ".geoagent-provider"),
@@ -46378,7 +46382,8 @@ class GeoAgentControl {
46378
46382
  cancelButton: this.requiredElement(content, ".geoagent-cancel"),
46379
46383
  clearButton: this.requiredElement(content, ".geoagent-clear"),
46380
46384
  copyButton: this.requiredElement(content, ".geoagent-copy"),
46381
- resizeHandle,
46385
+ resizeHandleLeft,
46386
+ resizeHandleRight,
46382
46387
  closeButton
46383
46388
  };
46384
46389
  this.ui.permissionRow.hidden = !this.options.showPermissionToggles;
@@ -46575,13 +46580,6 @@ class GeoAgentControl {
46575
46580
  }
46576
46581
  setupEventListeners() {
46577
46582
  var _a3;
46578
- this.clickOutsideHandler = (event) => {
46579
- const target = event.target;
46580
- if (this.container && this.panel && !this.container.contains(target) && !this.panel.contains(target)) {
46581
- this.collapse();
46582
- }
46583
- };
46584
- document.addEventListener("click", this.clickOutsideHandler);
46585
46583
  this.resizeHandler = () => {
46586
46584
  if (!this.state.collapsed) {
46587
46585
  this.updatePanelPosition();
@@ -46654,23 +46652,67 @@ class GeoAgentControl {
46654
46652
  Math.min(this.options.panelMaxWidth, Math.round(width))
46655
46653
  );
46656
46654
  }
46657
- startPanelResize(event) {
46658
- if (!this.panel) {
46655
+ constrainPanelHeight(height) {
46656
+ var _a3;
46657
+ let max = this.options.panelMaxHeight;
46658
+ const mapHeight = ((_a3 = this.mapContainer) == null ? void 0 : _a3.clientHeight) ?? 0;
46659
+ if (mapHeight > 0) {
46660
+ max = Math.min(max, mapHeight - 20);
46661
+ }
46662
+ return Math.max(
46663
+ this.options.panelMinHeight,
46664
+ Math.min(max, Math.round(height))
46665
+ );
46666
+ }
46667
+ createResizeHandle(corner) {
46668
+ const handle = document.createElement("div");
46669
+ const side = corner === "bottom-left" ? "bl" : "br";
46670
+ handle.className = `geoagent-panel-resize-handle geoagent-panel-resize-handle-${side}`;
46671
+ handle.setAttribute("role", "separator");
46672
+ handle.setAttribute("aria-label", "Resize GeoAgent panel");
46673
+ handle.addEventListener("mousedown", (event) => this.startPanelResize(event, corner));
46674
+ return handle;
46675
+ }
46676
+ startPanelResize(event, corner) {
46677
+ if (!this.panel || !this.mapContainer) {
46659
46678
  return;
46660
46679
  }
46661
46680
  event.preventDefault();
46662
46681
  event.stopPropagation();
46663
- const position = this.getControlPosition();
46664
- const resizeDirection = position === "top-left" || position === "bottom-left" ? 1 : -1;
46665
- const startX = event.clientX;
46666
- const startWidth = this.panel.getBoundingClientRect().width || this.state.panelWidth;
46667
46682
  this.stopPanelResize();
46683
+ const panelRect = this.panel.getBoundingClientRect();
46684
+ const mapRect = this.mapContainer.getBoundingClientRect();
46685
+ this.panel.style.top = `${panelRect.top - mapRect.top}px`;
46686
+ this.panel.style.bottom = "";
46687
+ if (corner === "bottom-left") {
46688
+ this.panel.style.right = `${mapRect.right - panelRect.right}px`;
46689
+ this.panel.style.left = "";
46690
+ } else {
46691
+ this.panel.style.left = `${panelRect.left - mapRect.left}px`;
46692
+ this.panel.style.right = "";
46693
+ }
46694
+ const startX = event.clientX;
46695
+ const startY = event.clientY;
46696
+ const startWidth = panelRect.width || this.state.panelWidth;
46697
+ const startHeight = panelRect.height || this.state.panelHeight || this.options.panelMinHeight;
46698
+ const widthDirection = corner === "bottom-left" ? -1 : 1;
46699
+ const gap = 8;
46700
+ const hasLayout = mapRect.width > 0 && mapRect.height > 0;
46701
+ const maxWidth = !hasLayout ? Number.POSITIVE_INFINITY : corner === "bottom-left" ? panelRect.right - mapRect.left - gap : mapRect.right - panelRect.left - gap;
46702
+ const maxHeight = !hasLayout ? Number.POSITIVE_INFINITY : mapRect.bottom - panelRect.top - gap;
46668
46703
  this.panel.classList.add("resizing");
46669
46704
  document.body.classList.add("geoagent-panel-resizing");
46670
46705
  this.panelResizeMoveHandler = (moveEvent) => {
46671
46706
  moveEvent.preventDefault();
46672
- const nextWidth = startWidth + (moveEvent.clientX - startX) * resizeDirection;
46673
- this.setState({ panelWidth: nextWidth });
46707
+ const width = Math.min(
46708
+ maxWidth,
46709
+ startWidth + (moveEvent.clientX - startX) * widthDirection
46710
+ );
46711
+ const height = Math.min(
46712
+ maxHeight,
46713
+ startHeight + (moveEvent.clientY - startY)
46714
+ );
46715
+ this.setState({ panelWidth: width, panelHeight: height });
46674
46716
  };
46675
46717
  this.panelResizeUpHandler = () => this.stopPanelResize();
46676
46718
  document.addEventListener("mousemove", this.panelResizeMoveHandler);
@@ -46701,7 +46743,6 @@ class GeoAgentControl {
46701
46743
  this.ui.bedrockRegionLabel.hidden = this.state.providerId !== "bedrock";
46702
46744
  this.ui.allowCodeInput.checked = this.state.allowCodeExecution;
46703
46745
  this.ui.allowDestructiveInput.checked = this.state.allowDestructiveTools;
46704
- this.ui.closeButton.setAttribute("aria-expanded", String(!this.state.collapsed));
46705
46746
  }
46706
46747
  currentProviderId() {
46707
46748
  var _a3;
@@ -46844,7 +46885,7 @@ ${markdown.trim()}`;
46844
46885
  }
46845
46886
  async createProviderModel(providerId, modelId, apiKey, bedrockRegion) {
46846
46887
  if (providerId === "openai-responses" || providerId === "openai-chat") {
46847
- const { OpenAIModel } = await import("./index-CCdoSNb8.js");
46888
+ const { OpenAIModel } = await import("./index-_-KavWih.js");
46848
46889
  return new OpenAIModel({
46849
46890
  api: providerId === "openai-responses" ? "responses" : "chat",
46850
46891
  modelId,
@@ -46855,7 +46896,7 @@ ${markdown.trim()}`;
46855
46896
  });
46856
46897
  }
46857
46898
  if (providerId === "anthropic") {
46858
- const { AnthropicModel } = await import("./anthropic-qn30x05g.js");
46899
+ const { AnthropicModel } = await import("./anthropic-CqhQTvtC.js");
46859
46900
  return new AnthropicModel({
46860
46901
  modelId,
46861
46902
  apiKey,
@@ -46865,7 +46906,7 @@ ${markdown.trim()}`;
46865
46906
  });
46866
46907
  }
46867
46908
  if (providerId === "google") {
46868
- const { GoogleModel } = await import("./index-nbt2E_lW.js");
46909
+ const { GoogleModel } = await import("./index-CvWJMktS.js");
46869
46910
  return new GoogleModel({
46870
46911
  modelId,
46871
46912
  apiKey
@@ -47030,7 +47071,6 @@ ${BROWSER_MAPLIBRE_CODE_SYSTEM_PROMPT}` : BROWSER_MAPLIBRE_SYSTEM_PROMPT;
47030
47071
  const buttonRect = button.getBoundingClientRect();
47031
47072
  const mapRect = this.mapContainer.getBoundingClientRect();
47032
47073
  const position = this.getControlPosition();
47033
- const resizeOnLeft = position === "top-right" || position === "bottom-right";
47034
47074
  const buttonTop = buttonRect.top - mapRect.top;
47035
47075
  const buttonBottom = mapRect.bottom - buttonRect.bottom;
47036
47076
  const buttonLeft = buttonRect.left - mapRect.left;
@@ -47040,8 +47080,6 @@ ${BROWSER_MAPLIBRE_CODE_SYSTEM_PROMPT}` : BROWSER_MAPLIBRE_SYSTEM_PROMPT;
47040
47080
  this.panel.style.bottom = "";
47041
47081
  this.panel.style.left = "";
47042
47082
  this.panel.style.right = "";
47043
- this.panel.classList.toggle("resize-left", resizeOnLeft);
47044
- this.panel.classList.toggle("resize-right", !resizeOnLeft);
47045
47083
  switch (position) {
47046
47084
  case "top-left":
47047
47085
  this.panel.style.top = `${buttonTop + buttonRect.height + panelGap}px`;
@@ -47090,4 +47128,4 @@ export {
47090
47128
  toJsonValue as t,
47091
47129
  warnOnce as w
47092
47130
  };
47093
- //# sourceMappingURL=GeoAgentControl-CM-lWHhd.js.map
47131
+ //# sourceMappingURL=GeoAgentControl-D02UP5lT.js.map