bruce-cesium 7.8.6 → 7.8.7

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.
@@ -9670,6 +9670,11 @@
9670
9670
  if (!entityIds.length) {
9671
9671
  return;
9672
9672
  }
9673
+ if (this.options.reportClick) {
9674
+ const keys = event;
9675
+ this.visualRegister.ClickLabelEntities(entityIds, Boolean(keys.ctrlKey || keys.metaKey || keys.shiftKey));
9676
+ return;
9677
+ }
9673
9678
  this.visualRegister.ClearSelected({ requestRender: false });
9674
9679
  this.visualRegister.SetSelected({ entityIds, selected: true });
9675
9680
  };
@@ -10340,7 +10345,7 @@
10340
10345
  let displacement = { x: 0, y: 0 };
10341
10346
  let nudge = { x: 0, y: 0, fromX: 0, fromY: 0, targetX: 0, targetY: 0, start: 0 };
10342
10347
  const apply = (placement) => {
10343
- var _a, _b, _c, _d, _e;
10348
+ var _a, _b, _c, _d, _e, _f;
10344
10349
  const show = (placement === null || placement === void 0 ? void 0 : placement.visible) && placement.opacity > 0;
10345
10350
  if (!show && hiddenLast) {
10346
10351
  return;
@@ -10401,6 +10406,11 @@
10401
10406
  ele.style.opacity = String(opacity);
10402
10407
  ele.style.zIndex = String(placement.zIndex);
10403
10408
  ele.dataset.clusterCount = String(placement.members.length || 1);
10409
+ // Every Entity a cluster stands for, so a box selection takes them all, not only the one drawn.
10410
+ const clusterIds = placement.members.length ? placement.entityIds.join(" ") : "";
10411
+ if (((_d = ele.dataset.clusterIds) !== null && _d !== void 0 ? _d : "") !== clusterIds) {
10412
+ ele.dataset.clusterIds = clusterIds;
10413
+ }
10404
10414
  countElement.style.display = placement.members.length ? "block" : "none";
10405
10415
  countElement.style.order = placement.textSide === "left" ? "-1" : "0";
10406
10416
  const count = placement.members.length ? String(placement.members.length) : "";
@@ -10413,9 +10423,9 @@
10413
10423
  const stack = JSON.stringify(placement.icons || []);
10414
10424
  if (iconStack && stack !== displayedStack) {
10415
10425
  displayedStack = stack;
10416
- const looks = ((_d = placement.icons) === null || _d === void 0 ? void 0 : _d.length) ? [iconLook(this.options), ...placement.icons] : [];
10426
+ const looks = ((_e = placement.icons) === null || _e === void 0 ? void 0 : _e.length) ? [iconLook(this.options), ...placement.icons] : [];
10417
10427
  // One small size for all, so no icon in the arrangement reads as more important than another.
10418
- const size = (this.options.iconSize || 24) * ((_e = this.options.iconScale) !== null && _e !== void 0 ? _e : 1) * ICON_STACK_SCALE;
10428
+ const size = (this.options.iconSize || 24) * ((_f = this.options.iconScale) !== null && _f !== void 0 ? _f : 1) * ICON_STACK_SCALE;
10419
10429
  const built = looks.map(look => this.buildIcon({ ...(pin ? pinLook(look) : look), iconSize: size }, counter));
10420
10430
  // A stack is on show already, so its photos load straight away.
10421
10431
  built.forEach(({ start }) => start === null || start === void 0 ? void 0 : start());
@@ -11424,6 +11434,10 @@
11424
11434
  this.imagesAsking = new Set();
11425
11435
  this.imagesTimer = null;
11426
11436
  this.placesInteractive = false;
11437
+ // Whether a click on an Entity label is reported to the app instead of selecting the Entity.
11438
+ this.entitiesInteractive = false;
11439
+ // The Entity labels the app has picked, by group, drawn with the same glow as a picked place.
11440
+ this.selectedEntities = new Map();
11427
11441
  }
11428
11442
  notify() {
11429
11443
  try {
@@ -11626,6 +11640,42 @@
11626
11640
  }
11627
11641
  this.refresh(keys);
11628
11642
  }
11643
+ /*
11644
+ * Whether a click on an Entity label is reported to the app rather than selecting its Entity.
11645
+ */
11646
+ SetEntitiesInteractive(on) {
11647
+ if (this.entitiesInteractive === on) {
11648
+ return;
11649
+ }
11650
+ this.entitiesInteractive = on;
11651
+ const keys = new Set();
11652
+ for (const group of this.active.values()) {
11653
+ for (const [key, item] of group.items) {
11654
+ if (!item.placeId) {
11655
+ keys.add(key);
11656
+ }
11657
+ }
11658
+ }
11659
+ this.refresh(keys);
11660
+ }
11661
+ /*
11662
+ * Replaces which of a group's Entity labels glow as picked, redrawing only those that changed.
11663
+ */
11664
+ SetSelectedEntities(id, entityIds) {
11665
+ var _a;
11666
+ const before = (_a = this.selectedEntities.get(id)) !== null && _a !== void 0 ? _a : new Set();
11667
+ const after = new Set((entityIds !== null && entityIds !== void 0 ? entityIds : []).filter(key => typeof key === "string" && key && !IsPlaceKey(key)));
11668
+ const changed = new Set([...before, ...after].filter(key => before.has(key) !== after.has(key)));
11669
+ if (after.size) {
11670
+ this.selectedEntities.set(id, after);
11671
+ }
11672
+ else {
11673
+ this.selectedEntities.delete(id);
11674
+ }
11675
+ if (changed.size && this.active.has(id)) {
11676
+ this.refresh(changed);
11677
+ }
11678
+ }
11629
11679
  Get() {
11630
11680
  return Array.from(this.definitions.keys(), id => {
11631
11681
  var _a;
@@ -11676,7 +11726,7 @@
11676
11726
  * One member's label settings, with any image its own text links to but before its default image.
11677
11727
  */
11678
11728
  compose(group, entityId, menuItemId) {
11679
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
11729
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
11680
11730
  const item = group.items.get(entityId);
11681
11731
  const entity = (_a = item.entity) !== null && _a !== void 0 ? _a : { Bruce: { ID: entityId, Name: item.text } };
11682
11732
  let iconPriority = (_b = group.definition.options) === null || _b === void 0 ? void 0 : _b.iconPriority;
@@ -11734,6 +11784,13 @@
11734
11784
  options.iconClass = named.iconClass;
11735
11785
  options.iconUrl = named.iconUrl;
11736
11786
  }
11787
+ if (!item.placeId && this.entitiesInteractive) {
11788
+ options.selectOnClick = true;
11789
+ options.reportClick = true;
11790
+ }
11791
+ if (!item.placeId && ((_r = this.selectedEntities.get(group.definition.id)) === null || _r === void 0 ? void 0 : _r.has(entityId))) {
11792
+ options.highlightColor = PLACE_SELECTED_COLOR;
11793
+ }
11737
11794
  if (item.placeId) {
11738
11795
  // Clickable only when the app asks, and reported then, as there is no Entity to select.
11739
11796
  options.selectOnClick = this.placesInteractive;
@@ -11756,7 +11813,7 @@
11756
11813
  }
11757
11814
  if (options.attributes && item.entity && !(expression && resolvedText != null)) {
11758
11815
  options.text = [
11759
- (_t = (_r = options.text) !== null && _r !== void 0 ? _r : (_s = item.entity.Bruce) === null || _s === void 0 ? void 0 : _s.Name) !== null && _t !== void 0 ? _t : entityId,
11816
+ (_u = (_s = options.text) !== null && _s !== void 0 ? _s : (_t = item.entity.Bruce) === null || _t === void 0 ? void 0 : _t.Name) !== null && _u !== void 0 ? _u : entityId,
11760
11817
  ...options.attributes.map(path => BModels.Entity.GetValue({ entity: item.entity, path })).filter(value => value != null).map(String)
11761
11818
  ].join("\n");
11762
11819
  }
@@ -11918,6 +11975,7 @@
11918
11975
  Remove(id) {
11919
11976
  var _a;
11920
11977
  const known = this.definitions.delete(id);
11978
+ this.selectedEntities.delete(id);
11921
11979
  this.visibility.delete(id);
11922
11980
  this.errors.delete(id);
11923
11981
  (_a = this.pending.get(id)) === null || _a === void 0 ? void 0 : _a.abort();
@@ -11950,6 +12008,7 @@
11950
12008
  this.active.clear();
11951
12009
  this.members.clear();
11952
12010
  this.definitions.clear();
12011
+ this.selectedEntities.clear();
11953
12012
  this.visibility.clear();
11954
12013
  this.errors.clear();
11955
12014
  this.refresh(affected);
@@ -11969,6 +12028,7 @@
11969
12028
  this.active.clear();
11970
12029
  this.members.clear();
11971
12030
  this.definitions.clear();
12031
+ this.selectedEntities.clear();
11972
12032
  this.visibility.clear();
11973
12033
  this.errors.clear();
11974
12034
  }
@@ -13902,6 +13962,7 @@
13902
13962
  }
13903
13963
  get OnLabelGroupsChanged() { return this.labelGroupsChanged; }
13904
13964
  get OnLabelPlaceClick() { return this.labelPlaceClicked; }
13965
+ get OnLabelEntityClick() { return this.labelEntityClicked; }
13905
13966
  constructor(params) {
13906
13967
  var _a, _b, _c, _d, _e, _f, _g;
13907
13968
  this.id = BModels.ObjectUtils.UId();
@@ -13956,6 +14017,7 @@
13956
14017
  this.shadowsRemoval = null;
13957
14018
  this.labelGroupsChanged = new BModels.BruceEvent();
13958
14019
  this.labelPlaceClicked = new BModels.BruceEvent();
14020
+ this.labelEntityClicked = new BModels.BruceEvent();
13959
14021
  this.hoverRingState = {};
13960
14022
  this.retiringHoverLabels = new Map();
13961
14023
  /*
@@ -14956,6 +15018,7 @@
14956
15018
  (_c = this.labelGroups) === null || _c === void 0 ? void 0 : _c.Dispose();
14957
15019
  this.labelGroupsChanged.Clear();
14958
15020
  this.labelPlaceClicked.Clear();
15021
+ this.labelEntityClicked.Clear();
14959
15022
  for (const regos of Object.values(this.rego)) {
14960
15023
  for (const rego of regos)
14961
15024
  exports.EntityLabel.Detatch({ rego, force: true });
@@ -16751,6 +16814,35 @@
16751
16814
  this.labelPlaceClicked.Trigger({ places, additive });
16752
16815
  }
16753
16816
  }
16817
+ /*
16818
+ * Whether Entity label clicks go to OnLabelEntityClick rather than selecting. Off by default.
16819
+ */
16820
+ SetLabelEntitiesInteractive(on) {
16821
+ if (this.disposed) {
16822
+ return;
16823
+ }
16824
+ if (!this.labelGroups) {
16825
+ this.labelGroups = new exports.EntityLabelGroup.Manager(this, () => this.labelGroupsChanged.Trigger(undefined));
16826
+ }
16827
+ this.labelGroups.SetEntitiesInteractive(on);
16828
+ }
16829
+ /*
16830
+ * Called by a label clicked while Entity labels are interactive, with the Entities it stands for.
16831
+ */
16832
+ ClickLabelEntities(entityIds, additive) {
16833
+ const labels = entityIds.map(entityId => { var _a; return ({ groupId: (_a = this.GetLabelGroupFor(entityId)) === null || _a === void 0 ? void 0 : _a.groupId, entityId }); })
16834
+ .filter(label => label.groupId);
16835
+ if (labels.length) {
16836
+ this.labelEntityClicked.Trigger({ labels, additive });
16837
+ }
16838
+ }
16839
+ /*
16840
+ * Which of a group's Entity labels glow as picked by the app.
16841
+ */
16842
+ SetLabelGroupSelected(id, entityIds) {
16843
+ var _a;
16844
+ (_a = this.labelGroups) === null || _a === void 0 ? void 0 : _a.SetSelectedEntities(id, entityIds);
16845
+ }
16754
16846
  /*
16755
16847
  * Replaces a group's places without reading its source again. False when no such group was set.
16756
16848
  */
@@ -60898,7 +60990,7 @@ void main() {
60898
60990
  StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
60899
60991
  })(exports.StyleUtils || (exports.StyleUtils = {}));
60900
60992
 
60901
- const VERSION = "7.8.6";
60993
+ const VERSION = "7.8.7";
60902
60994
  /**
60903
60995
  * Updates the environment instance used by bruce-cesium to one specified.
60904
60996
  * This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.