@itwin/map-layers 4.0.0-dev.48 → 4.0.0-dev.50

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 (79) hide show
  1. package/lib/cjs/MapLayerPreferences.js +2 -1
  2. package/lib/cjs/MapLayerPreferences.js.map +1 -1
  3. package/lib/cjs/mapLayers.js +3 -2
  4. package/lib/cjs/mapLayers.js.map +1 -1
  5. package/lib/cjs/ui/FeatureInfoUiItemsProvider.js +3 -2
  6. package/lib/cjs/ui/FeatureInfoUiItemsProvider.js.map +1 -1
  7. package/lib/cjs/ui/MapLayersUiItemsProvider.js +2 -2
  8. package/lib/cjs/ui/MapLayersUiItemsProvider.js.map +1 -1
  9. package/lib/cjs/ui/widget/AttachLayerPopupButton.js +15 -12
  10. package/lib/cjs/ui/widget/AttachLayerPopupButton.js.map +1 -1
  11. package/lib/cjs/ui/widget/BasemapPanel.js +1 -1
  12. package/lib/cjs/ui/widget/BasemapPanel.js.map +1 -1
  13. package/lib/cjs/ui/widget/ConfirmMessageDialog.js +7 -4
  14. package/lib/cjs/ui/widget/ConfirmMessageDialog.js.map +1 -1
  15. package/lib/cjs/ui/widget/FeatureInfoDataProvider.d.ts +2 -7
  16. package/lib/cjs/ui/widget/FeatureInfoDataProvider.d.ts.map +1 -1
  17. package/lib/cjs/ui/widget/FeatureInfoDataProvider.js +27 -25
  18. package/lib/cjs/ui/widget/FeatureInfoDataProvider.js.map +1 -1
  19. package/lib/cjs/ui/widget/FeatureInfoWidget.d.ts.map +1 -1
  20. package/lib/cjs/ui/widget/FeatureInfoWidget.js +21 -10
  21. package/lib/cjs/ui/widget/FeatureInfoWidget.js.map +1 -1
  22. package/lib/cjs/ui/widget/MapLayerDroppable.js +7 -4
  23. package/lib/cjs/ui/widget/MapLayerDroppable.js.map +1 -1
  24. package/lib/cjs/ui/widget/MapLayerManager.js +19 -17
  25. package/lib/cjs/ui/widget/MapLayerManager.js.map +1 -1
  26. package/lib/cjs/ui/widget/MapLayerSettingsMenu.js +3 -2
  27. package/lib/cjs/ui/widget/MapLayerSettingsMenu.js.map +1 -1
  28. package/lib/cjs/ui/widget/MapLayerSettingsPopupButton.js +2 -2
  29. package/lib/cjs/ui/widget/MapLayerSettingsPopupButton.js.map +1 -1
  30. package/lib/cjs/ui/widget/MapLayersWidget.js +4 -4
  31. package/lib/cjs/ui/widget/MapLayersWidget.js.map +1 -1
  32. package/lib/cjs/ui/widget/MapUrlDialog.js +27 -24
  33. package/lib/cjs/ui/widget/MapUrlDialog.js.map +1 -1
  34. package/lib/cjs/ui/widget/SelectMapFormat.js +12 -7
  35. package/lib/cjs/ui/widget/SelectMapFormat.js.map +1 -1
  36. package/lib/cjs/ui/widget/SubLayersDataProvider.js +5 -4
  37. package/lib/cjs/ui/widget/SubLayersDataProvider.js.map +1 -1
  38. package/lib/cjs/ui/widget/SubLayersTree.js +34 -28
  39. package/lib/cjs/ui/widget/SubLayersTree.js.map +1 -1
  40. package/lib/esm/MapLayerPreferences.js +2 -1
  41. package/lib/esm/MapLayerPreferences.js.map +1 -1
  42. package/lib/esm/mapLayers.js +3 -2
  43. package/lib/esm/mapLayers.js.map +1 -1
  44. package/lib/esm/ui/FeatureInfoUiItemsProvider.js +3 -2
  45. package/lib/esm/ui/FeatureInfoUiItemsProvider.js.map +1 -1
  46. package/lib/esm/ui/MapLayersUiItemsProvider.js +2 -2
  47. package/lib/esm/ui/MapLayersUiItemsProvider.js.map +1 -1
  48. package/lib/esm/ui/widget/AttachLayerPopupButton.js +15 -12
  49. package/lib/esm/ui/widget/AttachLayerPopupButton.js.map +1 -1
  50. package/lib/esm/ui/widget/BasemapPanel.js +1 -1
  51. package/lib/esm/ui/widget/BasemapPanel.js.map +1 -1
  52. package/lib/esm/ui/widget/ConfirmMessageDialog.js +7 -4
  53. package/lib/esm/ui/widget/ConfirmMessageDialog.js.map +1 -1
  54. package/lib/esm/ui/widget/FeatureInfoDataProvider.d.ts +2 -7
  55. package/lib/esm/ui/widget/FeatureInfoDataProvider.d.ts.map +1 -1
  56. package/lib/esm/ui/widget/FeatureInfoDataProvider.js +27 -25
  57. package/lib/esm/ui/widget/FeatureInfoDataProvider.js.map +1 -1
  58. package/lib/esm/ui/widget/FeatureInfoWidget.d.ts.map +1 -1
  59. package/lib/esm/ui/widget/FeatureInfoWidget.js +23 -12
  60. package/lib/esm/ui/widget/FeatureInfoWidget.js.map +1 -1
  61. package/lib/esm/ui/widget/MapLayerDroppable.js +7 -4
  62. package/lib/esm/ui/widget/MapLayerDroppable.js.map +1 -1
  63. package/lib/esm/ui/widget/MapLayerManager.js +19 -17
  64. package/lib/esm/ui/widget/MapLayerManager.js.map +1 -1
  65. package/lib/esm/ui/widget/MapLayerSettingsMenu.js +3 -2
  66. package/lib/esm/ui/widget/MapLayerSettingsMenu.js.map +1 -1
  67. package/lib/esm/ui/widget/MapLayerSettingsPopupButton.js +2 -2
  68. package/lib/esm/ui/widget/MapLayerSettingsPopupButton.js.map +1 -1
  69. package/lib/esm/ui/widget/MapLayersWidget.js +4 -4
  70. package/lib/esm/ui/widget/MapLayersWidget.js.map +1 -1
  71. package/lib/esm/ui/widget/MapUrlDialog.js +27 -24
  72. package/lib/esm/ui/widget/MapUrlDialog.js.map +1 -1
  73. package/lib/esm/ui/widget/SelectMapFormat.js +12 -7
  74. package/lib/esm/ui/widget/SelectMapFormat.js.map +1 -1
  75. package/lib/esm/ui/widget/SubLayersDataProvider.js +5 -4
  76. package/lib/esm/ui/widget/SubLayersDataProvider.js.map +1 -1
  77. package/lib/esm/ui/widget/SubLayersTree.js +34 -28
  78. package/lib/esm/ui/widget/SubLayersTree.js.map +1 -1
  79. package/package.json +29 -22
@@ -5,7 +5,6 @@
5
5
  import { PropertyRecord } from "@itwin/appui-abstract";
6
6
  import { PropertyDataChangeEvent } from "@itwin/components-react";
7
7
  import { BeEvent } from "@itwin/core-bentley";
8
- // import { IPropertyDataProvider, PropertyCategory, PropertyData, PropertyDataChangeEvent } from ""
9
8
  /**
10
9
  * Implementation of [IPropertyDataProvider] that uses an associative array.
11
10
  * @public
@@ -15,25 +14,29 @@ export var MapFeatureInfoLoadState;
15
14
  MapFeatureInfoLoadState[MapFeatureInfoLoadState["DataLoadStart"] = 0] = "DataLoadStart";
16
15
  MapFeatureInfoLoadState[MapFeatureInfoLoadState["DataLoadEnd"] = 1] = "DataLoadEnd";
17
16
  })(MapFeatureInfoLoadState || (MapFeatureInfoLoadState = {}));
18
- export class FeatureInfoDataProvider {
19
- constructor(onMapHit) {
17
+ class SimplePropertyData {
18
+ constructor() {
20
19
  this.label = PropertyRecord.fromString("");
21
20
  this.categories = [];
22
21
  this.records = {};
22
+ }
23
+ }
24
+ export class FeatureInfoDataProvider {
25
+ constructor(onMapHit) {
23
26
  this.onDataChanged = new PropertyDataChangeEvent();
24
27
  this.onDataLoadStateChanged = new BeEvent();
25
28
  this.onDataUpdated = new BeEvent();
26
- // eslint-disable-next-line @typescript-eslint/unbound-method
29
+ this._data = new SimplePropertyData();
27
30
  this._removeListener = onMapHit.addListener(this._handleMapHit, this);
28
31
  }
29
32
  onUnload() {
30
33
  this._removeListener();
31
34
  }
32
35
  async _handleMapHit(mapHit) {
33
- this.records = {};
34
- this.categories = [];
36
+ var _a, _b;
37
+ this._data = new SimplePropertyData();
35
38
  let recordCount = 0;
36
- if (mapHit?.isMapHit) {
39
+ if (mapHit === null || mapHit === void 0 ? void 0 : mapHit.isMapHit) {
37
40
  this.onDataLoadStateChanged.raiseEvent(MapFeatureInfoLoadState.DataLoadStart);
38
41
  const mapInfo = await mapHit.viewport.getMapFeatureInfo(mapHit);
39
42
  this.onDataLoadStateChanged.raiseEvent(MapFeatureInfoLoadState.DataLoadEnd);
@@ -43,19 +46,19 @@ export class FeatureInfoDataProvider {
43
46
  let nbRecords = 0;
44
47
  const layerCategory = (layerCatIdx === -1 ?
45
48
  { name: curLayerInfo.layerName, label: curLayerInfo.layerName, expand: true, childCategories: [] }
46
- : this.categories[layerCatIdx]);
49
+ : this._data.categories[layerCatIdx]);
47
50
  if (curLayerInfo.info && !(curLayerInfo.info instanceof HTMLElement)) {
48
51
  // This is not an HTMLElement, so iterate over each sub-layer info
49
52
  for (const subLayerInfo of curLayerInfo.info) {
50
53
  nbRecords++;
51
- const subCatIdx = layerCategory.childCategories?.findIndex((testCategory) => {
54
+ const subCatIdx = (_a = layerCategory.childCategories) === null || _a === void 0 ? void 0 : _a.findIndex((testCategory) => {
52
55
  return testCategory.name === subLayerInfo.subLayerName;
53
56
  });
54
57
  let subLayerCategory;
55
58
  if (subCatIdx === -1) {
56
59
  subLayerCategory = { name: subLayerInfo.subLayerName, label: subLayerInfo.subLayerName, expand: true };
57
60
  this.addSubCategory(subLayerCategory.name);
58
- layerCategory.childCategories?.push(subLayerCategory);
61
+ (_b = layerCategory.childCategories) === null || _b === void 0 ? void 0 : _b.push(subLayerCategory);
59
62
  }
60
63
  if (subLayerInfo.records) {
61
64
  for (const record of subLayerInfo.records) {
@@ -75,61 +78,60 @@ export class FeatureInfoDataProvider {
75
78
  this.onDataChanged.raiseEvent();
76
79
  }
77
80
  addSubCategory(categoryName) {
78
- this.records[categoryName] = [];
81
+ this._data.records[categoryName] = [];
79
82
  }
80
83
  addCategory(category) {
81
- const categoryIdx = this.categories.push(category) - 1;
82
- this.records[this.categories[categoryIdx].name] = [];
84
+ const categoryIdx = this._data.categories.push(category) - 1;
85
+ this._data.records[this._data.categories[categoryIdx].name] = [];
83
86
  return categoryIdx;
84
87
  }
85
88
  findCategoryIndex(category) {
86
- const index = this.categories.findIndex((testCategory) => {
89
+ const index = this._data.categories.findIndex((testCategory) => {
87
90
  return testCategory.name === category.name;
88
91
  });
89
92
  return index;
90
93
  }
91
94
  findCategoryIndexByName(name) {
92
- const index = this.categories.findIndex((testCategory) => {
95
+ const index = this._data.categories.findIndex((testCategory) => {
93
96
  return testCategory.name === name;
94
97
  });
95
98
  return index;
96
99
  }
97
100
  addProperty(propertyRecord, categoryName) {
98
- const idx = this.records[categoryName].findIndex((prop) => prop.property.name === propertyRecord.property.name);
101
+ const idx = this._data.records[categoryName].findIndex((prop) => prop.property.name === propertyRecord.property.name);
99
102
  if (idx === -1) {
100
- this.records[categoryName].push(propertyRecord);
103
+ this._data.records[categoryName].push(propertyRecord);
101
104
  }
102
105
  else {
103
- this.records[categoryName][idx].isMerged = true;
104
- this.records[categoryName][idx].isReadonly = true;
106
+ this._data.records[categoryName][idx].isMerged = true;
107
+ this._data.records[categoryName][idx].isReadonly = true;
105
108
  }
106
109
  }
107
110
  removeProperty(propertyRecord, categoryIdx) {
108
- const index = this.records[this.categories[categoryIdx].name].findIndex((record) => {
111
+ const index = this._data.records[this._data.categories[categoryIdx].name].findIndex((record) => {
109
112
  return record === propertyRecord;
110
113
  });
111
114
  let result = false;
112
115
  if (index >= 0) {
113
- this.records[this.categories[categoryIdx].name].splice(index, 1);
116
+ this._data.records[this._data.categories[categoryIdx].name].splice(index, 1);
114
117
  this.onDataChanged.raiseEvent();
115
118
  result = true;
116
119
  }
117
120
  return result;
118
121
  }
119
122
  replaceProperty(propertyRecord, categoryIdx, newRecord) {
120
- const index = this.records[this.categories[categoryIdx].name].findIndex((record) => {
123
+ const index = this._data.records[this._data.categories[categoryIdx].name].findIndex((record) => {
121
124
  return record === propertyRecord;
122
125
  });
123
126
  let result = false;
124
- // istanbul ignore else
125
127
  if (index >= 0) {
126
- this.records[this.categories[categoryIdx].name].splice(index, 1, newRecord);
128
+ this._data.records[this._data.categories[categoryIdx].name].splice(index, 1, newRecord);
127
129
  result = true;
128
130
  }
129
131
  return result;
130
132
  }
131
133
  async getData() {
132
- return this;
134
+ return this._data;
133
135
  }
134
136
  }
135
137
  //# sourceMappingURL=FeatureInfoDataProvider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FeatureInfoDataProvider.js","sourceRoot":"","sources":["../../../../src/ui/widget/FeatureInfoDataProvider.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,EAAG,cAAc,EAAE,MAAM,uBAA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IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,MAAsB,EAAE,EAAE;YACjG,OAAO,MAAM,KAAK,cAAc,CAAC;QACnC,CAAC,CAAC,CAAC;QAEH,IAAI,MAAM,GAAG,KAAK,CAAC;QAEnB,uBAAuB;QACvB,IAAI,KAAK,IAAI,CAAC,EAAE;YACd,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,SAAS,CAAC,CAAC;YAC5E,MAAM,GAAG,IAAI,CAAC;SACf;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAEM,KAAK,CAAC,OAAO;QAClB,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport { PropertyRecord } from \"@itwin/appui-abstract\";\nimport { IPropertyDataProvider, PropertyCategory, PropertyData, PropertyDataChangeEvent } from \"@itwin/components-react\";\nimport { BeEvent } from \"@itwin/core-bentley\";\nimport { HitDetail } from \"@itwin/core-frontend\";\nimport { MapHitEvent } from \"../Interfaces\";\n// import { IPropertyDataProvider, PropertyCategory, PropertyData, PropertyDataChangeEvent } from \"\"\n\n/**\n * Implementation of [IPropertyDataProvider] that uses an associative array.\n * @public\n */\n\nexport enum MapFeatureInfoLoadState {DataLoadStart, DataLoadEnd}\nexport declare type MapFeatureInfoLoadListener = (state: MapFeatureInfoLoadState) => void;\n\nexport interface MapFeatureInfoDataUpdate {\n recordCount: number;\n}\nexport declare type MapFeatureInfoDataUpdatedListener = (data: MapFeatureInfoDataUpdate) => void;\n\nexport class FeatureInfoDataProvider implements IPropertyDataProvider, PropertyData {\n private _removeListener: () => void;\n public label: PropertyRecord = PropertyRecord.fromString(\"\");\n public description?: string;\n public categories: PropertyCategory[] = [];\n public records: { [categoryName: string]: PropertyRecord[] } = {};\n public onDataChanged = new PropertyDataChangeEvent();\n public onDataLoadStateChanged = new BeEvent<MapFeatureInfoLoadListener>();\n public onDataUpdated = new BeEvent<MapFeatureInfoDataUpdatedListener>();\n constructor(onMapHit: MapHitEvent) {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n this._removeListener = onMapHit.addListener(this._handleMapHit, this);\n }\n\n public onUnload() {\n this._removeListener();\n }\n\n private async _handleMapHit(mapHit: HitDetail) {\n this.records = {};\n this.categories = [];\n let recordCount = 0;\n if (mapHit?.isMapHit) {\n this.onDataLoadStateChanged.raiseEvent(MapFeatureInfoLoadState.DataLoadStart);\n const mapInfo = await mapHit.viewport.getMapFeatureInfo(mapHit);\n this.onDataLoadStateChanged.raiseEvent(MapFeatureInfoLoadState.DataLoadEnd);\n if (mapInfo.layerInfo !== undefined ) {\n for (const curLayerInfo of mapInfo.layerInfo) {\n const layerCatIdx = this.findCategoryIndexByName(curLayerInfo.layerName);\n let nbRecords = 0;\n const layerCategory = (\n layerCatIdx === -1 ?\n {name:curLayerInfo.layerName, label:curLayerInfo.layerName, expand:true, childCategories:[]}\n : this.categories[layerCatIdx] );\n\n if (curLayerInfo.info && !(curLayerInfo.info instanceof HTMLElement)) {\n // This is not an HTMLElement, so iterate over each sub-layer info\n for (const subLayerInfo of curLayerInfo.info) {\n nbRecords++;\n const subCatIdx = layerCategory.childCategories?.findIndex((testCategory: PropertyCategory) => {\n return testCategory.name === subLayerInfo.subLayerName;\n });\n let subLayerCategory;\n if (subCatIdx === -1) {\n subLayerCategory = {name:subLayerInfo.subLayerName, label:subLayerInfo.subLayerName, expand:true};\n this.addSubCategory(subLayerCategory.name);\n layerCategory.childCategories?.push(subLayerCategory);\n }\n if (subLayerInfo.records) {\n for (const record of subLayerInfo.records) {\n // Always use the string value for now\n this.addProperty(record, subLayerInfo.subLayerName);\n\n }\n }\n }\n }\n if (layerCatIdx === -1 && nbRecords>0)\n this.addCategory(layerCategory);\n\n recordCount = recordCount + nbRecords;\n }\n }\n }\n this.onDataUpdated.raiseEvent({recordCount});\n this.onDataChanged.raiseEvent();\n }\n\n public addSubCategory(categoryName: string) {\n this.records[categoryName] = [];\n }\n public addCategory(category: PropertyCategory): number {\n const categoryIdx = this.categories.push(category) - 1;\n this.records[this.categories[categoryIdx].name] = [];\n return categoryIdx;\n }\n\n public findCategoryIndex(category: PropertyCategory): number {\n const index = this.categories.findIndex((testCategory: PropertyCategory) => {\n return testCategory.name === category.name;\n });\n return index;\n }\n public findCategoryIndexByName(name: string): number {\n const index = this.categories.findIndex((testCategory: PropertyCategory) => {\n return testCategory.name === name;\n });\n return index;\n }\n\n public addProperty(propertyRecord: PropertyRecord, categoryName: string): void {\n const idx = this.records[categoryName].findIndex((prop)=> prop.property.name === propertyRecord.property.name);\n if (idx === -1) {\n this.records[categoryName].push(propertyRecord);\n } else {\n this.records[categoryName][idx].isMerged = true;\n this.records[categoryName][idx].isReadonly = true;\n }\n }\n\n public removeProperty(propertyRecord: PropertyRecord, categoryIdx: number): boolean {\n const index = this.records[this.categories[categoryIdx].name].findIndex((record: PropertyRecord) => {\n return record === propertyRecord;\n });\n\n let result = false;\n\n if (index >= 0) {\n this.records[this.categories[categoryIdx].name].splice(index, 1);\n this.onDataChanged.raiseEvent();\n result = true;\n }\n return result;\n }\n\n public replaceProperty(propertyRecord: PropertyRecord, categoryIdx: number, newRecord: PropertyRecord): boolean {\n const index = this.records[this.categories[categoryIdx].name].findIndex((record: PropertyRecord) => {\n return record === propertyRecord;\n });\n\n let result = false;\n\n // istanbul ignore else\n if (index >= 0) {\n this.records[this.categories[categoryIdx].name].splice(index, 1, newRecord);\n result = true;\n }\n return result;\n }\n\n public async getData(): Promise<PropertyData> {\n return this;\n }\n}\n"]}
1
+ {"version":3,"file":"FeatureInfoDataProvider.js","sourceRoot":"","sources":["../../../../src/ui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EAAE;YACd,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;YAC7E,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,CAAC;YAChC,MAAM,GAAG,IAAI,CAAC;SACf;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAEM,eAAe,CAAC,cAA8B,EAAE,WAAmB,EAAE,SAAyB;QACnG,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,MAAsB,EAAE,EAAE;YAC7G,OAAO,MAAM,KAAK,cAAc,CAAC;QACnC,CAAC,CAAC,CAAC;QAEH,IAAI,MAAM,GAAG,KAAK,CAAC;QAEnB,IAAI,KAAK,IAAI,CAAC,EAAE;YACd,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,SAAS,CAAC,CAAC;YACxF,MAAM,GAAG,IAAI,CAAC;SACf;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAEM,KAAK,CAAC,OAAO;QAClB,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport { PropertyRecord } from \"@itwin/appui-abstract\";\nimport { IPropertyDataProvider, PropertyCategory, PropertyData, PropertyDataChangeEvent } from \"@itwin/components-react\";\nimport { BeEvent } from \"@itwin/core-bentley\";\nimport { HitDetail } from \"@itwin/core-frontend\";\nimport { MapHitEvent } from \"../Interfaces\";\n\n/**\n * Implementation of [IPropertyDataProvider] that uses an associative array.\n * @public\n */\n\nexport enum MapFeatureInfoLoadState { DataLoadStart, DataLoadEnd }\nexport declare type MapFeatureInfoLoadListener = (state: MapFeatureInfoLoadState) => void;\n\nexport interface MapFeatureInfoDataUpdate {\n recordCount: number;\n}\nexport declare type MapFeatureInfoDataUpdatedListener = (data: MapFeatureInfoDataUpdate) => void;\n\nclass SimplePropertyData implements PropertyData {\n public label: PropertyRecord = PropertyRecord.fromString(\"\");\n public description?: string;\n public categories: PropertyCategory[] = [];\n public records: { [categoryName: string]: PropertyRecord[] } = {};\n}\n\nexport class FeatureInfoDataProvider implements IPropertyDataProvider {\n private _removeListener: () => void;\n public onDataChanged = new PropertyDataChangeEvent();\n public onDataLoadStateChanged = new BeEvent<MapFeatureInfoLoadListener>();\n public onDataUpdated = new BeEvent<MapFeatureInfoDataUpdatedListener>();\n private _data = new SimplePropertyData();\n constructor(onMapHit: MapHitEvent) {\n this._removeListener = onMapHit.addListener(this._handleMapHit, this);\n }\n\n public onUnload() {\n this._removeListener();\n }\n\n private async _handleMapHit(mapHit: HitDetail) {\n this._data = new SimplePropertyData();\n\n let recordCount = 0;\n if (mapHit?.isMapHit) {\n this.onDataLoadStateChanged.raiseEvent(MapFeatureInfoLoadState.DataLoadStart);\n const mapInfo = await mapHit.viewport.getMapFeatureInfo(mapHit);\n this.onDataLoadStateChanged.raiseEvent(MapFeatureInfoLoadState.DataLoadEnd);\n if (mapInfo.layerInfo !== undefined) {\n for (const curLayerInfo of mapInfo.layerInfo) {\n const layerCatIdx = this.findCategoryIndexByName(curLayerInfo.layerName);\n let nbRecords = 0;\n const layerCategory = (\n layerCatIdx === -1 ?\n { name: curLayerInfo.layerName, label: curLayerInfo.layerName, expand: true, childCategories: [] }\n : this._data.categories[layerCatIdx]);\n\n if (curLayerInfo.info && !(curLayerInfo.info instanceof HTMLElement)) {\n // This is not an HTMLElement, so iterate over each sub-layer info\n for (const subLayerInfo of curLayerInfo.info) {\n nbRecords++;\n const subCatIdx = layerCategory.childCategories?.findIndex((testCategory: PropertyCategory) => {\n return testCategory.name === subLayerInfo.subLayerName;\n });\n let subLayerCategory;\n if (subCatIdx === -1) {\n subLayerCategory = { name: subLayerInfo.subLayerName, label: subLayerInfo.subLayerName, expand: true };\n this.addSubCategory(subLayerCategory.name);\n layerCategory.childCategories?.push(subLayerCategory);\n }\n if (subLayerInfo.records) {\n for (const record of subLayerInfo.records) {\n // Always use the string value for now\n this.addProperty(record, subLayerInfo.subLayerName);\n\n }\n }\n }\n }\n if (layerCatIdx === -1 && nbRecords > 0)\n this.addCategory(layerCategory);\n\n recordCount = recordCount + nbRecords;\n }\n }\n }\n this.onDataUpdated.raiseEvent({ recordCount });\n this.onDataChanged.raiseEvent();\n }\n\n public addSubCategory(categoryName: string) {\n this._data.records[categoryName] = [];\n }\n public addCategory(category: PropertyCategory): number {\n\n const categoryIdx = this._data.categories.push(category) - 1;\n this._data.records[this._data.categories[categoryIdx].name] = [];\n return categoryIdx;\n }\n\n public findCategoryIndex(category: PropertyCategory): number {\n const index = this._data.categories.findIndex((testCategory: PropertyCategory) => {\n return testCategory.name === category.name;\n });\n return index;\n }\n public findCategoryIndexByName(name: string): number {\n const index = this._data.categories.findIndex((testCategory: PropertyCategory) => {\n return testCategory.name === name;\n });\n return index;\n }\n\n public addProperty(propertyRecord: PropertyRecord, categoryName: string): void {\n const idx = this._data.records[categoryName].findIndex((prop) => prop.property.name === propertyRecord.property.name);\n if (idx === -1) {\n this._data.records[categoryName].push(propertyRecord);\n } else {\n this._data.records[categoryName][idx].isMerged = true;\n this._data.records[categoryName][idx].isReadonly = true;\n }\n }\n\n public removeProperty(propertyRecord: PropertyRecord, categoryIdx: number): boolean {\n const index = this._data.records[this._data.categories[categoryIdx].name].findIndex((record: PropertyRecord) => {\n return record === propertyRecord;\n });\n\n let result = false;\n\n if (index >= 0) {\n this._data.records[this._data.categories[categoryIdx].name].splice(index, 1);\n this.onDataChanged.raiseEvent();\n result = true;\n }\n return result;\n }\n\n public replaceProperty(propertyRecord: PropertyRecord, categoryIdx: number, newRecord: PropertyRecord): boolean {\n const index = this._data.records[this._data.categories[categoryIdx].name].findIndex((record: PropertyRecord) => {\n return record === propertyRecord;\n });\n\n let result = false;\n\n if (index >= 0) {\n this._data.records[this._data.categories[categoryIdx].name].splice(index, 1, newRecord);\n result = true;\n }\n return result;\n }\n\n public async getData(): Promise<PropertyData> {\n return this._data;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"FeatureInfoWidget.d.ts","sourceRoot":"","sources":["../../../../src/ui/widget/FeatureInfoWidget.tsx"],"names":[],"mappings":"AAWA,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAGtD,UAAU,yBAAyB;IACjC,eAAe,EAAE,qBAAqB,CAAC;CACxC;AAGD,wBAAgB,oBAAoB,CAAC,EAAE,eAAe,EAAE,EAAE,yBAAyB,eAsDlF"}
1
+ {"version":3,"file":"FeatureInfoWidget.d.ts","sourceRoot":"","sources":["../../../../src/ui/widget/FeatureInfoWidget.tsx"],"names":[],"mappings":"AAWA,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAGtD,UAAU,yBAAyB;IACjC,eAAe,EAAE,qBAAqB,CAAC;CACxC;AAGD,wBAAgB,oBAAoB,CAAC,EAAE,eAAe,EAAE,EAAE,yBAAyB,eAoElF"}
@@ -3,17 +3,19 @@
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
  import * as React from "react";
6
- import { PropertyGrid } from "@itwin/components-react";
7
- import { FillCentered, Orientation } from "@itwin/core-react";
6
+ import { VirtualizedPropertyGridWithDataProvider } from "@itwin/components-react";
7
+ import { FillCentered, Orientation, ResizableContainerObserver } from "@itwin/core-react";
8
8
  import { FeatureInfoDataProvider, MapFeatureInfoLoadState } from "./FeatureInfoDataProvider";
9
9
  import { ProgressRadial } from "@itwin/itwinui-react";
10
10
  import { MapLayersUI } from "../../mapLayers";
11
11
  // eslint-disable-next-line @typescript-eslint/naming-convention
12
12
  export function MapFeatureInfoWidget({ featureInfoOpts }) {
13
+ var _a;
13
14
  const dataProvider = React.useRef();
14
15
  const [loadingData, setLoadingData] = React.useState(false);
15
16
  const [hasData, setHasData] = React.useState(false);
16
17
  const [noRecordsMessage] = React.useState(MapLayersUI.localization.getLocalizedString("mapLayers:FeatureInfoWidget.NoRecords"));
18
+ const [{ width, height }, setSize] = React.useState({ width: 0, height: 0 });
17
19
  const handleLoadStateChange = (state) => {
18
20
  setLoadingData(state === MapFeatureInfoLoadState.DataLoadStart);
19
21
  };
@@ -21,28 +23,36 @@ export function MapFeatureInfoWidget({ featureInfoOpts }) {
21
23
  setHasData(state.recordCount !== 0);
22
24
  };
23
25
  React.useEffect(() => {
24
- if (featureInfoOpts?.onMapHit) {
26
+ if (featureInfoOpts === null || featureInfoOpts === void 0 ? void 0 : featureInfoOpts.onMapHit) {
25
27
  dataProvider.current = new FeatureInfoDataProvider(featureInfoOpts.onMapHit);
26
28
  }
27
29
  return () => {
28
- dataProvider?.current?.onUnload();
30
+ var _a;
31
+ (_a = dataProvider === null || dataProvider === void 0 ? void 0 : dataProvider.current) === null || _a === void 0 ? void 0 : _a.onUnload();
29
32
  };
30
- }, [featureInfoOpts?.onMapHit]);
33
+ }, [featureInfoOpts === null || featureInfoOpts === void 0 ? void 0 : featureInfoOpts.onMapHit]);
31
34
  React.useEffect(() => {
32
- dataProvider.current?.onDataUpdated.addListener(handleDataUpdated);
35
+ var _a;
36
+ (_a = dataProvider.current) === null || _a === void 0 ? void 0 : _a.onDataUpdated.addListener(handleDataUpdated);
33
37
  return () => {
34
- dataProvider.current?.onDataUpdated.removeListener(handleDataUpdated);
38
+ var _a;
39
+ (_a = dataProvider.current) === null || _a === void 0 ? void 0 : _a.onDataUpdated.removeListener(handleDataUpdated);
35
40
  };
36
41
  }, []);
37
42
  React.useEffect(() => {
38
- if (featureInfoOpts?.showLoadProgressAnimation) {
39
- dataProvider.current?.onDataLoadStateChanged.addListener(handleLoadStateChange);
43
+ var _a;
44
+ if (featureInfoOpts === null || featureInfoOpts === void 0 ? void 0 : featureInfoOpts.showLoadProgressAnimation) {
45
+ (_a = dataProvider.current) === null || _a === void 0 ? void 0 : _a.onDataLoadStateChanged.addListener(handleLoadStateChange);
40
46
  return () => {
41
- dataProvider.current?.onDataLoadStateChanged.removeListener(handleLoadStateChange);
47
+ var _a;
48
+ (_a = dataProvider.current) === null || _a === void 0 ? void 0 : _a.onDataLoadStateChanged.removeListener(handleLoadStateChange);
42
49
  };
43
50
  }
44
51
  return;
45
- }, [featureInfoOpts?.showLoadProgressAnimation]);
52
+ }, [featureInfoOpts === null || featureInfoOpts === void 0 ? void 0 : featureInfoOpts.showLoadProgressAnimation]);
53
+ const handleResize = React.useCallback((w, h) => {
54
+ setSize({ width: w, height: h });
55
+ }, []);
46
56
  if (loadingData) {
47
57
  return (React.createElement(FillCentered, null,
48
58
  React.createElement(ProgressRadial, { indeterminate: true })));
@@ -54,7 +64,8 @@ export function MapFeatureInfoWidget({ featureInfoOpts }) {
54
64
  }
55
65
  else {
56
66
  if (dataProvider.current)
57
- return (React.createElement(PropertyGrid, { dataProvider: dataProvider.current, orientation: Orientation.Vertical, isPropertySelectionEnabled: featureInfoOpts?.propertyGridOptions?.isPropertySelectionEnabled }));
67
+ return (React.createElement(ResizableContainerObserver, { onResize: handleResize },
68
+ React.createElement(VirtualizedPropertyGridWithDataProvider, { width: width, height: height, dataProvider: dataProvider.current, orientation: Orientation.Vertical, isPropertySelectionEnabled: (_a = featureInfoOpts === null || featureInfoOpts === void 0 ? void 0 : featureInfoOpts.propertyGridOptions) === null || _a === void 0 ? void 0 : _a.isPropertySelectionEnabled })));
58
69
  else
59
70
  return (React.createElement(React.Fragment, null));
60
71
  }
@@ -1 +1 @@
1
- {"version":3,"file":"FeatureInfoWidget.js","sourceRoot":"","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E,eAAe,EAAE,mBAAmB,EAAE,0BAA0B,GAAI,CAAC,CAAC;;YAEpG,OAAO,CAAC,yCAAK,CAAC,CAAC;KAClB;AACH,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport * as React from \"react\";\n\nimport { PropertyGrid } from \"@itwin/components-react\";\nimport { FillCentered, Orientation } from \"@itwin/core-react\";\n\nimport { FeatureInfoDataProvider, MapFeatureInfoDataUpdate, MapFeatureInfoLoadState } from \"./FeatureInfoDataProvider\";\nimport { ProgressRadial } from \"@itwin/itwinui-react\";\nimport { MapFeatureInfoOptions } from \"../Interfaces\";\nimport { MapLayersUI } from \"../../mapLayers\";\n\ninterface MapFeatureInfoWidgetProps {\n featureInfoOpts: MapFeatureInfoOptions;\n}\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport function MapFeatureInfoWidget({ featureInfoOpts }: MapFeatureInfoWidgetProps) {\n\n const dataProvider = React.useRef<FeatureInfoDataProvider>();\n const [loadingData, setLoadingData] = React.useState<boolean>(false);\n const [hasData, setHasData] = React.useState<boolean>(false);\n const [noRecordsMessage] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:FeatureInfoWidget.NoRecords\"));\n\n const handleLoadStateChange = (state: MapFeatureInfoLoadState) => {\n setLoadingData(state === MapFeatureInfoLoadState.DataLoadStart);\n };\n const handleDataUpdated = (state: MapFeatureInfoDataUpdate) => {\n setHasData(state.recordCount !== 0);\n };\n\n React.useEffect(() => {\n if (featureInfoOpts?.onMapHit) {\n dataProvider.current = new FeatureInfoDataProvider(featureInfoOpts.onMapHit);\n }\n return () => {\n dataProvider?.current?.onUnload();\n };\n }, [featureInfoOpts?.onMapHit]);\n\n React.useEffect(() => {\n\n dataProvider.current?.onDataUpdated.addListener(handleDataUpdated);\n return () => {\n dataProvider.current?.onDataUpdated.removeListener(handleDataUpdated);\n };\n\n }, []);\n\n React.useEffect(() => {\n if (featureInfoOpts?.showLoadProgressAnimation) {\n dataProvider.current?.onDataLoadStateChanged.addListener(handleLoadStateChange);\n return () => {\n dataProvider.current?.onDataLoadStateChanged.removeListener(handleLoadStateChange);\n };\n }\n return;\n\n }, [featureInfoOpts?.showLoadProgressAnimation]);\n\n if (loadingData) {\n return (<FillCentered><ProgressRadial indeterminate={true}></ProgressRadial></FillCentered>);\n } else if (!hasData) {\n return (<FillCentered><span><i>{noRecordsMessage}</i></span></FillCentered>);\n } else {\n if (dataProvider.current)\n return (<PropertyGrid dataProvider={dataProvider.current} orientation={Orientation.Vertical} // eslint-disable-line deprecation/deprecation\n isPropertySelectionEnabled={featureInfoOpts?.propertyGridOptions?.isPropertySelectionEnabled} />);\n else\n return (<></>);\n }\n}\n"]}
1
+ {"version":3,"file":"FeatureInfoWidget.js","sourceRoot":"","sources":["../../../../src/ui/widget/FeatureInfoWidget.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,uCAAuC,EAAE,MAAM,yBAAyB,CAAC;AAClF,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAE1F,OAAO,EAAE,uBAAuB,EAA4B,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACvH,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAM9C,gEAAgE;AAChE,MAAM,UAAU,oBAAoB,CAAC,EAAE,eAAe,EAA6B;;IAEjF,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,EAA2B,CAAC;IAC7D,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAU,KAAK,CAAC,CAAC;IACrE,MAAM,CAAC,OAAO,EAAE,UAAU,C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aAAf,eAAe,uBAAf,eAAe,CAAE,mBAAmB,0CAAE,0BAA0B,GAAI,CACvE,CAC9B,CAAC;;YAEF,OAAO,CAAC,yCAAK,CAAC,CAAC;KAClB;AACH,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport * as React from \"react\";\n\nimport { VirtualizedPropertyGridWithDataProvider } from \"@itwin/components-react\";\nimport { FillCentered, Orientation, ResizableContainerObserver } from \"@itwin/core-react\";\n\nimport { FeatureInfoDataProvider, MapFeatureInfoDataUpdate, MapFeatureInfoLoadState } from \"./FeatureInfoDataProvider\";\nimport { ProgressRadial } from \"@itwin/itwinui-react\";\nimport { MapFeatureInfoOptions } from \"../Interfaces\";\nimport { MapLayersUI } from \"../../mapLayers\";\n\ninterface MapFeatureInfoWidgetProps {\n featureInfoOpts: MapFeatureInfoOptions;\n}\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport function MapFeatureInfoWidget({ featureInfoOpts }: MapFeatureInfoWidgetProps) {\n\n const dataProvider = React.useRef<FeatureInfoDataProvider>();\n const [loadingData, setLoadingData] = React.useState<boolean>(false);\n const [hasData, setHasData] = React.useState<boolean>(false);\n const [noRecordsMessage] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:FeatureInfoWidget.NoRecords\"));\n\n const [{ width, height }, setSize] = React.useState({ width: 0, height: 0 });\n\n const handleLoadStateChange = (state: MapFeatureInfoLoadState) => {\n setLoadingData(state === MapFeatureInfoLoadState.DataLoadStart);\n };\n const handleDataUpdated = (state: MapFeatureInfoDataUpdate) => {\n setHasData(state.recordCount !== 0);\n };\n\n React.useEffect(() => {\n if (featureInfoOpts?.onMapHit) {\n dataProvider.current = new FeatureInfoDataProvider(featureInfoOpts.onMapHit);\n }\n return () => {\n dataProvider?.current?.onUnload();\n };\n }, [featureInfoOpts?.onMapHit]);\n\n React.useEffect(() => {\n\n dataProvider.current?.onDataUpdated.addListener(handleDataUpdated);\n return () => {\n dataProvider.current?.onDataUpdated.removeListener(handleDataUpdated);\n };\n\n }, []);\n\n React.useEffect(() => {\n if (featureInfoOpts?.showLoadProgressAnimation) {\n dataProvider.current?.onDataLoadStateChanged.addListener(handleLoadStateChange);\n return () => {\n dataProvider.current?.onDataLoadStateChanged.removeListener(handleLoadStateChange);\n };\n }\n return;\n\n }, [featureInfoOpts?.showLoadProgressAnimation]);\n\n const handleResize = React.useCallback((w: number, h: number) => {\n setSize({ width: w, height: h });\n }, []);\n\n if (loadingData) {\n return (<FillCentered><ProgressRadial indeterminate={true}></ProgressRadial></FillCentered>);\n } else if (!hasData) {\n return (<FillCentered><span><i>{noRecordsMessage}</i></span></FillCentered>);\n } else {\n if (dataProvider.current)\n return (\n <ResizableContainerObserver onResize={handleResize}>\n <VirtualizedPropertyGridWithDataProvider\n width={width}\n height={height}\n dataProvider={dataProvider.current}\n orientation={Orientation.Vertical}\n isPropertySelectionEnabled={featureInfoOpts?.propertyGridOptions?.isPropertySelectionEnabled} />\n </ResizableContainerObserver>\n );\n else\n return (<></>);\n }\n}\n"]}
@@ -31,6 +31,7 @@ export function MapLayerDroppable(props) {
31
31
  const [dropLayerLabel] = React.useState(MapLayersUI.localization.getLocalizedString("mapLayers:Widget.DropLayerLabel"));
32
32
  const [outOfRangeTitle] = React.useState(MapLayersUI.localization.getLocalizedString("mapLayers:Widget.layerOutOfRange"));
33
33
  const renderItem = (dragProvided, _, rubric) => {
34
+ var _a;
34
35
  assert(props.layersList !== undefined);
35
36
  const activeLayer = props.layersList[rubric.source.index];
36
37
  const outOfRange = activeLayer.treeVisibility === MapTileTreeScaleRangeVisibility.Hidden;
@@ -40,13 +41,14 @@ export function MapLayerDroppable(props) {
40
41
  React.createElement("span", { className: props.disabled || outOfRange ? "map-manager-item-label-disabled" : "map-manager-item-label", title: outOfRange ? outOfRangeTitle : undefined, ...dragProvided.dragHandleProps }, activeLayer.name),
41
42
  React.createElement("div", { className: "map-manager-item-sub-layer-container" }, activeLayer.subLayers && activeLayer.subLayers.length > 1 &&
42
43
  React.createElement(SubLayersPopupButton, { mapLayerSettings: activeLayer, activeViewport: props.activeViewport })),
43
- activeLayer.provider?.status === MapLayerImageryProviderStatus.RequireAuth &&
44
+ ((_a = activeLayer.provider) === null || _a === void 0 ? void 0 : _a.status) === MapLayerImageryProviderStatus.RequireAuth &&
44
45
  React.createElement(Button, { disabled: props.disabled, size: "small", styleType: "borderless", onClick: () => {
45
- const indexInDisplayStyle = props.activeViewport?.displayStyle.findMapLayerIndexByNameAndSource(activeLayer.name, activeLayer.source, activeLayer.isOverlay);
46
+ var _a;
47
+ const indexInDisplayStyle = (_a = props.activeViewport) === null || _a === void 0 ? void 0 : _a.displayStyle.findMapLayerIndexByNameAndSource(activeLayer.name, activeLayer.source, activeLayer.isOverlay);
46
48
  if (indexInDisplayStyle !== undefined && indexInDisplayStyle >= 0) {
47
49
  const layerSettings = props.activeViewport.displayStyle.mapLayerAtIndex(indexInDisplayStyle, activeLayer.isOverlay);
48
50
  if (layerSettings instanceof ImageMapLayerSettings) {
49
- UiFramework.dialogs.modal.open(React.createElement(MapUrlDialog, { activeViewport: props.activeViewport, isOverlay: props.isOverlay, layerRequiringCredentials: layerSettings?.toJSON(), onOkResult: props.onItemEdited, mapTypesOptions: props.mapTypesOptions }));
51
+ UiFramework.dialogs.modal.open(React.createElement(MapUrlDialog, { activeViewport: props.activeViewport, isOverlay: props.isOverlay, layerRequiringCredentials: layerSettings === null || layerSettings === void 0 ? void 0 : layerSettings.toJSON(), onOkResult: props.onItemEdited, mapTypesOptions: props.mapTypesOptions }));
50
52
  }
51
53
  }
52
54
  }, title: requireAuthTooltip },
@@ -54,10 +56,11 @@ export function MapLayerDroppable(props) {
54
56
  React.createElement(MapLayerSettingsMenu, { activeViewport: props.activeViewport, mapLayerSettings: activeLayer, onMenuItemSelection: props.onMenuItemSelected, disabled: props.disabled })));
55
57
  };
56
58
  function renderDraggableContent(snapshot) {
59
+ var _a;
57
60
  let node;
58
61
  if (containsLayer) {
59
62
  // Render a <Draggable>
60
- node = (props.layersList?.map((mapLayerSettings, i) => React.createElement(Draggable, { isDragDisabled: props.disabled, key: mapLayerSettings.name, draggableId: mapLayerSettings.name, index: i }, renderItem)));
63
+ node = ((_a = props.layersList) === null || _a === void 0 ? void 0 : _a.map((mapLayerSettings, i) => React.createElement(Draggable, { isDragDisabled: props.disabled, key: mapLayerSettings.name, draggableId: mapLayerSettings.name, index: i }, renderItem)));
61
64
  }
62
65
  else {
63
66
  // Render a label that provide a 'Drop here' hint
@@ -1 +1 @@
1
- {"version":3,"file":"MapLayerDroppable.js","sourceRoot":"","sources":["../../../../src/ui/widget/MapLayerDroppable.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,2CAA2C;AAE3C,oEAAoE;AACpE,sDAAsD;AAEtD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAuB,SAAS,EAA6C,MAAM,qBAAqB,CAAC;AAC3H,OAAO,EAAE,6BAA6B,EAAE,+BAA+B,EAAkB,MAAM,sBAAsB,CAAC;AACtH,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAEzF,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,wBAAwB,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAA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MAAM,EAAE,IAAG,YAAY,CAAC,WAAW,CAAO,CACzF,CAAC,CAAC;IACZ,CAAC;IAED,OAAO,CACL,oBAAC,SAAS,IACR,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,UAAU,EACvB,oBAAoB,EAAE,KAAK,CAAC,oBAA2B,IAEtD,eAAe,CACN,CACb,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n// cSpell:ignore droppable Sublayer Basemap\n\n// the following quiet warning caused by react-beautiful-dnd package\n/* eslint-disable @typescript-eslint/unbound-method */\n\nimport * as React from \"react\";\nimport { Draggable, DraggableChildrenFn, Droppable, DroppableProvided, DroppableStateSnapshot } from \"react-beautiful-dnd\";\nimport { MapLayerImageryProviderStatus, MapTileTreeScaleRangeVisibility, ScreenViewport } from \"@itwin/core-frontend\";\nimport { Icon } from \"@itwin/core-react\";\nimport { assert } from \"@itwin/core-bentley\";\nimport { UiFramework } from \"@itwin/appui-react\";\nimport { Button } from \"@itwin/itwinui-react\";\nimport { SubLayersPopupButton } from \"./SubLayersPopupButton\";\nimport { AttachLayerButtonType, AttachLayerPopupButton } from \"./AttachLayerPopupButton\";\nimport { MapTypesOptions, StyleMapLayerSettings } from \"../Interfaces\";\nimport { MapLayerSettingsMenu } from \"./MapLayerSettingsMenu\";\nimport { MapUrlDialog } from \"./MapUrlDialog\";\nimport \"./MapLayerManager.scss\";\nimport { MapLayersUI } from \"../../mapLayers\";\nimport { ImageMapLayerSettings } from \"@itwin/core-common\";\n\n/** @internal */\ninterface MapLayerDroppableProps {\n isOverlay: boolean;\n layersList?: StyleMapLayerSettings[];\n mapTypesOptions?: MapTypesOptions;\n getContainerForClone: () => HTMLElement;\n activeViewport: ScreenViewport;\n onMenuItemSelected: (action: string, mapLayerSettings: StyleMapLayerSettings) => void;\n onItemVisibilityToggleClicked: (mapLayerSettings: StyleMapLayerSettings) => void;\n onItemEdited: () => void;\n disabled?: boolean;\n}\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport function MapLayerDroppable(props: MapLayerDroppableProps) {\n const containsLayer = props.layersList && props.layersList.length > 0;\n const droppableId = props.isOverlay ? \"overlayMapLayers\" : \"backgroundMapLayers\";\n const [toggleVisibility] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Widget.ToggleVisibility\"));\n const [requireAuthTooltip] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Widget.RequireAuthTooltip\"));\n const [noBackgroundMapsSpecifiedLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Widget.NoBackgroundLayers\"));\n const [noUnderlaysSpecifiedLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Widget.NoOverlayLayers\"));\n const [dropLayerLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Widget.DropLayerLabel\"));\n const [outOfRangeTitle] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Widget.layerOutOfRange\"));\n\n const renderItem: DraggableChildrenFn = (dragProvided, _, rubric) => {\n assert(props.layersList !== undefined);\n const activeLayer = props.layersList[rubric.source.index];\n const outOfRange = activeLayer.treeVisibility === MapTileTreeScaleRangeVisibility.Hidden;\n\n return (\n <div className=\"map-manager-source-item\" data-id={rubric.source.index} key={activeLayer.name}\n {...dragProvided.draggableProps}\n ref={dragProvided.innerRef} >\n {/* Visibility icon */}\n <Button disabled={props.disabled} size=\"small\" styleType=\"borderless\" className=\"map-manager-item-visibility\" title={toggleVisibility} onClick={() => { props.onItemVisibilityToggleClicked(activeLayer); }}>\n <Icon iconSpec={activeLayer.visible ? \"icon-visibility\" : \"icon-visibility-hide-2\"} />\n </Button>\n {/* Label */}\n <span className={props.disabled||outOfRange ? \"map-manager-item-label-disabled\" : \"map-manager-item-label\"}\n title = {outOfRange ? outOfRangeTitle : undefined }\n {...dragProvided.dragHandleProps}\n\n >\n {activeLayer.name}\n </span>\n <div className=\"map-manager-item-sub-layer-container\">\n {activeLayer.subLayers && activeLayer.subLayers.length > 1 &&\n <SubLayersPopupButton mapLayerSettings={activeLayer} activeViewport={props.activeViewport} />\n }\n </div>\n {activeLayer.provider?.status === MapLayerImageryProviderStatus.RequireAuth &&\n <Button\n disabled={props.disabled}\n size=\"small\"\n styleType=\"borderless\"\n onClick={() => {\n const indexInDisplayStyle = props.activeViewport?.displayStyle.findMapLayerIndexByNameAndSource(activeLayer.name, activeLayer.source, activeLayer.isOverlay);\n if (indexInDisplayStyle !== undefined && indexInDisplayStyle >= 0) {\n const layerSettings = props.activeViewport.displayStyle.mapLayerAtIndex(indexInDisplayStyle, activeLayer.isOverlay);\n if (layerSettings instanceof ImageMapLayerSettings) {\n UiFramework.dialogs.modal.open(<MapUrlDialog activeViewport={props.activeViewport}\n isOverlay={props.isOverlay}\n layerRequiringCredentials={layerSettings?.toJSON()}\n onOkResult={props.onItemEdited}\n mapTypesOptions={props.mapTypesOptions}></MapUrlDialog>);\n }\n }\n\n }}\n title={requireAuthTooltip}\n >\n <Icon className=\"map-layer-source-item-warnMessage-icon\" iconSpec=\"icon-status-warning\" />\n </Button>\n }\n <MapLayerSettingsMenu activeViewport={props.activeViewport} mapLayerSettings={activeLayer} onMenuItemSelection={props.onMenuItemSelected} disabled={props.disabled} />\n </div>\n );\n };\n\n function renderDraggableContent(snapshot: DroppableStateSnapshot): React.ReactNode {\n let node: React.ReactNode;\n if (containsLayer) {\n // Render a <Draggable>\n node = (props.layersList?.map((mapLayerSettings, i) =>\n <Draggable isDragDisabled={props.disabled} key={mapLayerSettings.name} draggableId={mapLayerSettings.name} index={i}>\n {renderItem}\n </Draggable>));\n } else {\n // Render a label that provide a 'Drop here' hint\n const label = props.isOverlay ? noUnderlaysSpecifiedLabel : noBackgroundMapsSpecifiedLabel;\n node =\n <div title={label} className=\"map-manager-no-layers-container\">\n {snapshot.isDraggingOver ?\n <span className=\"map-manager-no-layers-label\">{dropLayerLabel}</span>\n :\n <>\n <span className=\"map-manager-no-layers-label\">{label}</span>\n <AttachLayerPopupButton disabled={props.disabled} buttonType={AttachLayerButtonType.Blue} isOverlay={props.isOverlay} />\n </>\n }\n </div>;\n }\n return node;\n }\n\n function renderDraggable(dropProvided: DroppableProvided, dropSnapshot: DroppableStateSnapshot): React.ReactElement<HTMLElement> {\n return (\n <div className={`map-manager-attachments${dropSnapshot.isDraggingOver && containsLayer ? \" is-dragging-map-over\" : \"\"}`} ref={dropProvided.innerRef} {...dropProvided.droppableProps} >\n\n {renderDraggableContent(dropSnapshot)}\n\n {\n /* We don't want a placeholder when displaying the 'Drop here' message\n Unfortunately, if don't add it, 'react-beautiful-dnd' show an error message in the console.\n So I simply make it hidden. See https://github.com/atlassian/react-beautiful-dnd/issues/518 */\n }\n <div style={containsLayer ? undefined : { display: \"none\" }}>{dropProvided.placeholder}</div>\n </div>);\n }\n\n return (\n <Droppable\n droppableId={droppableId}\n renderClone={renderItem}\n getContainerForClone={props.getContainerForClone as any}\n >\n {renderDraggable}\n </Droppable>\n );\n}\n"]}
1
+ {"version":3,"file":"MapLayerDroppable.js","sourceRoot":"","sources":["../../../../src/ui/widget/MapLayerDroppable.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,2CAA2C;AAE3C,oEAAoE;AACpE,sDAAsD;AAEtD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAuB,SAAS,EAA6C,MAAM,qBAAqB,CAAC;AAC3H,OAAO,EAAE,6BAA6B,EAAE,+BAA+B,EAAkB,MAAM,sBAAsB,CAAC;AACtH,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,sBA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AAS,eAAe,CAAC,YAA+B,EAAE,YAAoC;QAC5F,OAAO,CACL,6BAAK,SAAS,EAAE,0BAA0B,YAAY,CAAC,cAAc,IAAI,aAAa,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,YAAY,CAAC,QAAQ,KAAM,YAAY,CAAC,cAAc;YAEjL,sBAAsB,CAAC,YAAY,CAAC;YAOrC,6BAAK,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,IAAG,YAAY,CAAC,WAAW,CAAO,CACzF,CAAC,CAAC;IACZ,CAAC;IAED,OAAO,CACL,oBAAC,SAAS,IACR,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,UAAU,EACvB,oBAAoB,EAAE,KAAK,CAAC,oBAA2B,IAEtD,eAAe,CACN,CACb,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n// cSpell:ignore droppable Sublayer Basemap\n\n// the following quiet warning caused by react-beautiful-dnd package\n/* eslint-disable @typescript-eslint/unbound-method */\n\nimport * as React from \"react\";\nimport { Draggable, DraggableChildrenFn, Droppable, DroppableProvided, DroppableStateSnapshot } from \"react-beautiful-dnd\";\nimport { MapLayerImageryProviderStatus, MapTileTreeScaleRangeVisibility, ScreenViewport } from \"@itwin/core-frontend\";\nimport { Icon } from \"@itwin/core-react\";\nimport { assert } from \"@itwin/core-bentley\";\nimport { UiFramework } from \"@itwin/appui-react\";\nimport { Button } from \"@itwin/itwinui-react\";\nimport { SubLayersPopupButton } from \"./SubLayersPopupButton\";\nimport { AttachLayerButtonType, AttachLayerPopupButton } from \"./AttachLayerPopupButton\";\nimport { MapTypesOptions, StyleMapLayerSettings } from \"../Interfaces\";\nimport { MapLayerSettingsMenu } from \"./MapLayerSettingsMenu\";\nimport { MapUrlDialog } from \"./MapUrlDialog\";\nimport \"./MapLayerManager.scss\";\nimport { MapLayersUI } from \"../../mapLayers\";\nimport { ImageMapLayerSettings } from \"@itwin/core-common\";\n\n/** @internal */\ninterface MapLayerDroppableProps {\n isOverlay: boolean;\n layersList?: StyleMapLayerSettings[];\n mapTypesOptions?: MapTypesOptions;\n getContainerForClone: () => HTMLElement;\n activeViewport: ScreenViewport;\n onMenuItemSelected: (action: string, mapLayerSettings: StyleMapLayerSettings) => void;\n onItemVisibilityToggleClicked: (mapLayerSettings: StyleMapLayerSettings) => void;\n onItemEdited: () => void;\n disabled?: boolean;\n}\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport function MapLayerDroppable(props: MapLayerDroppableProps) {\n const containsLayer = props.layersList && props.layersList.length > 0;\n const droppableId = props.isOverlay ? \"overlayMapLayers\" : \"backgroundMapLayers\";\n const [toggleVisibility] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Widget.ToggleVisibility\"));\n const [requireAuthTooltip] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Widget.RequireAuthTooltip\"));\n const [noBackgroundMapsSpecifiedLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Widget.NoBackgroundLayers\"));\n const [noUnderlaysSpecifiedLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Widget.NoOverlayLayers\"));\n const [dropLayerLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Widget.DropLayerLabel\"));\n const [outOfRangeTitle] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Widget.layerOutOfRange\"));\n\n const renderItem: DraggableChildrenFn = (dragProvided, _, rubric) => {\n assert(props.layersList !== undefined);\n const activeLayer = props.layersList[rubric.source.index];\n const outOfRange = activeLayer.treeVisibility === MapTileTreeScaleRangeVisibility.Hidden;\n\n return (\n <div className=\"map-manager-source-item\" data-id={rubric.source.index} key={activeLayer.name}\n {...dragProvided.draggableProps}\n ref={dragProvided.innerRef} >\n {/* Visibility icon */}\n <Button disabled={props.disabled} size=\"small\" styleType=\"borderless\" className=\"map-manager-item-visibility\" title={toggleVisibility} onClick={() => { props.onItemVisibilityToggleClicked(activeLayer); }}>\n <Icon iconSpec={activeLayer.visible ? \"icon-visibility\" : \"icon-visibility-hide-2\"} />\n </Button>\n {/* Label */}\n <span className={props.disabled||outOfRange ? \"map-manager-item-label-disabled\" : \"map-manager-item-label\"}\n title = {outOfRange ? outOfRangeTitle : undefined }\n {...dragProvided.dragHandleProps}\n\n >\n {activeLayer.name}\n </span>\n <div className=\"map-manager-item-sub-layer-container\">\n {activeLayer.subLayers && activeLayer.subLayers.length > 1 &&\n <SubLayersPopupButton mapLayerSettings={activeLayer} activeViewport={props.activeViewport} />\n }\n </div>\n {activeLayer.provider?.status === MapLayerImageryProviderStatus.RequireAuth &&\n <Button\n disabled={props.disabled}\n size=\"small\"\n styleType=\"borderless\"\n onClick={() => {\n const indexInDisplayStyle = props.activeViewport?.displayStyle.findMapLayerIndexByNameAndSource(activeLayer.name, activeLayer.source, activeLayer.isOverlay);\n if (indexInDisplayStyle !== undefined && indexInDisplayStyle >= 0) {\n const layerSettings = props.activeViewport.displayStyle.mapLayerAtIndex(indexInDisplayStyle, activeLayer.isOverlay);\n if (layerSettings instanceof ImageMapLayerSettings) {\n UiFramework.dialogs.modal.open(<MapUrlDialog activeViewport={props.activeViewport}\n isOverlay={props.isOverlay}\n layerRequiringCredentials={layerSettings?.toJSON()}\n onOkResult={props.onItemEdited}\n mapTypesOptions={props.mapTypesOptions}></MapUrlDialog>);\n }\n }\n\n }}\n title={requireAuthTooltip}\n >\n <Icon className=\"map-layer-source-item-warnMessage-icon\" iconSpec=\"icon-status-warning\" />\n </Button>\n }\n <MapLayerSettingsMenu activeViewport={props.activeViewport} mapLayerSettings={activeLayer} onMenuItemSelection={props.onMenuItemSelected} disabled={props.disabled} />\n </div>\n );\n };\n\n function renderDraggableContent(snapshot: DroppableStateSnapshot): React.ReactNode {\n let node: React.ReactNode;\n if (containsLayer) {\n // Render a <Draggable>\n node = (props.layersList?.map((mapLayerSettings, i) =>\n <Draggable isDragDisabled={props.disabled} key={mapLayerSettings.name} draggableId={mapLayerSettings.name} index={i}>\n {renderItem}\n </Draggable>));\n } else {\n // Render a label that provide a 'Drop here' hint\n const label = props.isOverlay ? noUnderlaysSpecifiedLabel : noBackgroundMapsSpecifiedLabel;\n node =\n <div title={label} className=\"map-manager-no-layers-container\">\n {snapshot.isDraggingOver ?\n <span className=\"map-manager-no-layers-label\">{dropLayerLabel}</span>\n :\n <>\n <span className=\"map-manager-no-layers-label\">{label}</span>\n <AttachLayerPopupButton disabled={props.disabled} buttonType={AttachLayerButtonType.Blue} isOverlay={props.isOverlay} />\n </>\n }\n </div>;\n }\n return node;\n }\n\n function renderDraggable(dropProvided: DroppableProvided, dropSnapshot: DroppableStateSnapshot): React.ReactElement<HTMLElement> {\n return (\n <div className={`map-manager-attachments${dropSnapshot.isDraggingOver && containsLayer ? \" is-dragging-map-over\" : \"\"}`} ref={dropProvided.innerRef} {...dropProvided.droppableProps} >\n\n {renderDraggableContent(dropSnapshot)}\n\n {\n /* We don't want a placeholder when displaying the 'Drop here' message\n Unfortunately, if don't add it, 'react-beautiful-dnd' show an error message in the console.\n So I simply make it hidden. See https://github.com/atlassian/react-beautiful-dnd/issues/518 */\n }\n <div style={containsLayer ? undefined : { display: \"none\" }}>{dropProvided.placeholder}</div>\n </div>);\n }\n\n return (\n <Droppable\n droppableId={droppableId}\n renderClone={renderItem}\n getContainerForClone={props.getContainerForClone as any}\n >\n {renderDraggable}\n </Droppable>\n );\n}\n"]}
@@ -63,14 +63,15 @@ function getMapLayerSettingsFromViewport(viewport, getBackgroundMap, populateSub
63
63
  }
64
64
  // eslint-disable-next-line @typescript-eslint/naming-convention
65
65
  export function MapLayerManager(props) {
66
+ var _a, _b;
66
67
  const [mapSources, setMapSources] = React.useState();
67
68
  const [loadingSources, setLoadingSources] = React.useState(false);
68
69
  const [baseSources, setBaseSources] = React.useState();
69
70
  const [overlaysLabel] = React.useState(MapLayersUI.localization.getLocalizedString("mapLayers:Widget.OverlayLayers"));
70
71
  const [underlaysLabel] = React.useState(MapLayersUI.localization.getLocalizedString("mapLayers:Widget.BackgroundLayers"));
71
72
  const { activeViewport, mapLayerOptions } = props;
72
- const hideExternalMapLayersSection = mapLayerOptions?.hideExternalMapLayers ? mapLayerOptions.hideExternalMapLayers : false;
73
- const fetchPublicMapLayerSources = mapLayerOptions?.fetchPublicMapLayerSources ? mapLayerOptions.fetchPublicMapLayerSources : false;
73
+ const hideExternalMapLayersSection = (mapLayerOptions === null || mapLayerOptions === void 0 ? void 0 : mapLayerOptions.hideExternalMapLayers) ? mapLayerOptions.hideExternalMapLayers : false;
74
+ const fetchPublicMapLayerSources = (mapLayerOptions === null || mapLayerOptions === void 0 ? void 0 : mapLayerOptions.fetchPublicMapLayerSources) ? mapLayerOptions.fetchPublicMapLayerSources : false;
74
75
  // map layer settings from display style
75
76
  const [backgroundMapLayers, setBackgroundMapLayers] = React.useState(getMapLayerSettingsFromViewport(activeViewport, true));
76
77
  const [overlayMapLayers, setOverlayMapLayers] = React.useState(getMapLayerSettingsFromViewport(activeViewport, false));
@@ -141,9 +142,9 @@ export function MapLayerManager(props) {
141
142
  loadMapLayerSettingsFromViewport(activeViewport);
142
143
  }
143
144
  };
144
- activeViewport?.displayStyle.settings.onMapImageryChanged.addListener(handleMapImageryChanged);
145
+ activeViewport === null || activeViewport === void 0 ? void 0 : activeViewport.displayStyle.settings.onMapImageryChanged.addListener(handleMapImageryChanged);
145
146
  return () => {
146
- activeViewport?.displayStyle.settings.onMapImageryChanged.removeListener(handleMapImageryChanged);
147
+ activeViewport === null || activeViewport === void 0 ? void 0 : activeViewport.displayStyle.settings.onMapImageryChanged.removeListener(handleMapImageryChanged);
147
148
  };
148
149
  }, [activeViewport, backgroundMapLayers, loadMapLayerSettingsFromViewport, overlayMapLayers]);
149
150
  const handleProviderStatusChanged = React.useCallback((_args) => {
@@ -151,11 +152,11 @@ export function MapLayerManager(props) {
151
152
  }, [loadMapLayerSettingsFromViewport, activeViewport]);
152
153
  // Triggered whenever a provider status change
153
154
  React.useEffect(() => {
154
- backgroundMapLayers?.forEach((layer) => { layer.provider?.onStatusChanged.addListener(handleProviderStatusChanged); });
155
- overlayMapLayers?.forEach((layer) => { layer.provider?.onStatusChanged.addListener(handleProviderStatusChanged); });
155
+ backgroundMapLayers === null || backgroundMapLayers === void 0 ? void 0 : backgroundMapLayers.forEach((layer) => { var _a; (_a = layer.provider) === null || _a === void 0 ? void 0 : _a.onStatusChanged.addListener(handleProviderStatusChanged); });
156
+ overlayMapLayers === null || overlayMapLayers === void 0 ? void 0 : overlayMapLayers.forEach((layer) => { var _a; (_a = layer.provider) === null || _a === void 0 ? void 0 : _a.onStatusChanged.addListener(handleProviderStatusChanged); });
156
157
  return () => {
157
- backgroundMapLayers?.forEach((layer) => { layer.provider?.onStatusChanged.removeListener(handleProviderStatusChanged); });
158
- overlayMapLayers?.forEach((layer) => { layer.provider?.onStatusChanged.removeListener(handleProviderStatusChanged); });
158
+ backgroundMapLayers === null || backgroundMapLayers === void 0 ? void 0 : backgroundMapLayers.forEach((layer) => { var _a; (_a = layer.provider) === null || _a === void 0 ? void 0 : _a.onStatusChanged.removeListener(handleProviderStatusChanged); });
159
+ overlayMapLayers === null || overlayMapLayers === void 0 ? void 0 : overlayMapLayers.forEach((layer) => { var _a; (_a = layer.provider) === null || _a === void 0 ? void 0 : _a.onStatusChanged.removeListener(handleProviderStatusChanged); });
159
160
  };
160
161
  }, [backgroundMapLayers, overlayMapLayers, activeViewport, loadMapLayerSettingsFromViewport, handleProviderStatusChanged]);
161
162
  // Monitor viewport updates, and refresh the widget accordingly.
@@ -173,9 +174,9 @@ export function MapLayerManager(props) {
173
174
  const sourceLayers = await MapLayerSources.create(undefined, (fetchPublicMapLayerSources && !hideExternalMapLayersSection));
174
175
  const iModel = IModelApp.viewManager.selectedView ? IModelApp.viewManager.selectedView.iModel : undefined;
175
176
  try {
176
- const preferenceSources = (iModel?.iTwinId === undefined
177
+ const preferenceSources = ((iModel === null || iModel === void 0 ? void 0 : iModel.iTwinId) === undefined
177
178
  ? []
178
- : await MapLayerPreferences.getSources(iModel?.iTwinId, iModel?.iModelId));
179
+ : await MapLayerPreferences.getSources(iModel === null || iModel === void 0 ? void 0 : iModel.iTwinId, iModel === null || iModel === void 0 ? void 0 : iModel.iModelId));
179
180
  for (const source of preferenceSources)
180
181
  await MapLayerSources.addSourceToMapLayerSources(source);
181
182
  }
@@ -188,9 +189,9 @@ export function MapLayerManager(props) {
188
189
  // This is where the list of layers first gets populated... I need to update it
189
190
  // MapUrlDialog gets around knowing MapLayerManager exists and vice versa by affecting the viewports displayStyle which MapLayerManager is listening for
190
191
  // We know when displayStyle changes we've added a layer, this layer may not be a custom layer
191
- sourceLayers?.layers.forEach((source) => { sources.push(source); });
192
+ sourceLayers === null || sourceLayers === void 0 ? void 0 : sourceLayers.layers.forEach((source) => { sources.push(source); });
192
193
  setMapSources(sources);
193
- sourceLayers?.bases.forEach((source) => { bases.push(source); });
194
+ sourceLayers === null || sourceLayers === void 0 ? void 0 : sourceLayers.bases.forEach((source) => { bases.push(source); });
194
195
  setBaseSources(bases);
195
196
  }
196
197
  setLoadingSources(true);
@@ -205,8 +206,9 @@ export function MapLayerManager(props) {
205
206
  });
206
207
  }, [setMapSources, fetchPublicMapLayerSources, hideExternalMapLayersSection]);
207
208
  const updateMapSources = React.useCallback(() => {
209
+ var _a, _b;
208
210
  const newSources = [];
209
- MapLayerSources.getInstance()?.layers?.forEach((sourceLayer) => { newSources.push(sourceLayer); });
211
+ (_b = (_a = MapLayerSources.getInstance()) === null || _a === void 0 ? void 0 : _a.layers) === null || _b === void 0 ? void 0 : _b.forEach((sourceLayer) => { newSources.push(sourceLayer); });
210
212
  setMapSources(newSources);
211
213
  }, [setMapSources]);
212
214
  /**
@@ -248,9 +250,9 @@ export function MapLayerManager(props) {
248
250
  const handleDisplayStyleChange = (vp) => {
249
251
  loadMapLayerSettingsFromViewport(vp);
250
252
  };
251
- activeViewport?.onDisplayStyleChanged.addListener(handleDisplayStyleChange);
253
+ activeViewport === null || activeViewport === void 0 ? void 0 : activeViewport.onDisplayStyleChanged.addListener(handleDisplayStyleChange);
252
254
  return () => {
253
- activeViewport?.onDisplayStyleChanged.removeListener(handleDisplayStyleChange);
255
+ activeViewport === null || activeViewport === void 0 ? void 0 : activeViewport.onDisplayStyleChanged.removeListener(handleDisplayStyleChange);
254
256
  };
255
257
  }, [activeViewport, loadMapLayerSettingsFromViewport]);
256
258
  const handleOnMenuItemSelection = React.useCallback((action, mapLayerSettings) => {
@@ -387,11 +389,11 @@ export function MapLayerManager(props) {
387
389
  React.createElement("div", { className: "map-manager-underlays" },
388
390
  React.createElement("span", { className: "map-manager-underlays-label" }, underlaysLabel),
389
391
  React.createElement(AttachLayerPopupButton, { disabled: !backgroundMapVisible, isOverlay: false })),
390
- React.createElement(MapLayerDroppable, { disabled: !backgroundMapVisible, isOverlay: false, layersList: backgroundMapLayers, mapTypesOptions: props.mapLayerOptions?.mapTypeOptions, getContainerForClone: props.getContainerForClone, activeViewport: props.activeViewport, onMenuItemSelected: handleOnMenuItemSelection, onItemVisibilityToggleClicked: handleLayerVisibilityChange, onItemEdited: handleRefreshFromStyle })),
392
+ React.createElement(MapLayerDroppable, { disabled: !backgroundMapVisible, isOverlay: false, layersList: backgroundMapLayers, mapTypesOptions: (_a = props.mapLayerOptions) === null || _a === void 0 ? void 0 : _a.mapTypeOptions, getContainerForClone: props.getContainerForClone, activeViewport: props.activeViewport, onMenuItemSelected: handleOnMenuItemSelection, onItemVisibilityToggleClicked: handleLayerVisibilityChange, onItemEdited: handleRefreshFromStyle })),
391
393
  React.createElement("div", { className: "map-manager-layer-wrapper" },
392
394
  React.createElement("div", { className: "map-manager-overlays" },
393
395
  React.createElement("span", { className: "map-manager-overlays-label" }, overlaysLabel),
394
396
  React.createElement(AttachLayerPopupButton, { disabled: !backgroundMapVisible, isOverlay: true })),
395
- React.createElement(MapLayerDroppable, { disabled: !backgroundMapVisible, isOverlay: true, layersList: overlayMapLayers, mapTypesOptions: props.mapLayerOptions?.mapTypeOptions, getContainerForClone: props.getContainerForClone, activeViewport: props.activeViewport, onMenuItemSelected: handleOnMenuItemSelection, onItemVisibilityToggleClicked: handleLayerVisibilityChange, onItemEdited: handleRefreshFromStyle }))))));
397
+ React.createElement(MapLayerDroppable, { disabled: !backgroundMapVisible, isOverlay: true, layersList: overlayMapLayers, mapTypesOptions: (_b = props.mapLayerOptions) === null || _b === void 0 ? void 0 : _b.mapTypeOptions, getContainerForClone: props.getContainerForClone, activeViewport: props.activeViewport, onMenuItemSelected: handleOnMenuItemSelection, onItemVisibilityToggleClicked: handleLayerVisibilityChange, onItemEdited: handleRefreshFromStyle }))))));
396
398
  }
397
399
  //# sourceMappingURL=MapLayerManager.js.map