@itwin/map-layers 4.0.0-dev.24 → 4.0.0-dev.28

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 (158) hide show
  1. package/CHANGELOG.md +9 -4
  2. package/lib/cjs/MapLayerPreferences.d.ts +88 -88
  3. package/lib/cjs/MapLayerPreferences.js +311 -312
  4. package/lib/cjs/MapLayerPreferences.js.map +1 -1
  5. package/lib/cjs/map-layers.d.ts +6 -6
  6. package/lib/cjs/map-layers.js +22 -22
  7. package/lib/cjs/mapLayers.d.ts +44 -44
  8. package/lib/cjs/mapLayers.js +61 -63
  9. package/lib/cjs/mapLayers.js.map +1 -1
  10. package/lib/cjs/ui/FeatureInfoUiItemsProvider.d.ts +11 -11
  11. package/lib/cjs/ui/FeatureInfoUiItemsProvider.js +51 -52
  12. package/lib/cjs/ui/FeatureInfoUiItemsProvider.js.map +1 -1
  13. package/lib/cjs/ui/Interfaces.d.ts +50 -50
  14. package/lib/cjs/ui/Interfaces.js +2 -2
  15. package/lib/cjs/ui/Interfaces.js.map +1 -1
  16. package/lib/cjs/ui/MapFeatureInfoTool.d.ts +13 -13
  17. package/lib/cjs/ui/MapFeatureInfoTool.js +50 -50
  18. package/lib/cjs/ui/MapFeatureInfoTool.js.map +1 -1
  19. package/lib/cjs/ui/MapLayersUiItemsProvider.d.ts +8 -8
  20. package/lib/cjs/ui/MapLayersUiItemsProvider.js +38 -38
  21. package/lib/cjs/ui/MapLayersUiItemsProvider.js.map +1 -1
  22. package/lib/cjs/ui/widget/AttachLayerPopupButton.d.ts +14 -14
  23. package/lib/cjs/ui/widget/AttachLayerPopupButton.js +335 -338
  24. package/lib/cjs/ui/widget/AttachLayerPopupButton.js.map +1 -1
  25. package/lib/cjs/ui/widget/BasemapPanel.d.ts +8 -8
  26. package/lib/cjs/ui/widget/BasemapPanel.js +156 -156
  27. package/lib/cjs/ui/widget/BasemapPanel.js.map +1 -1
  28. package/lib/cjs/ui/widget/BasemapPanel.scss +87 -87
  29. package/lib/cjs/ui/widget/ConfirmMessageDialog.d.ts +21 -21
  30. package/lib/cjs/ui/widget/ConfirmMessageDialog.js +22 -25
  31. package/lib/cjs/ui/widget/ConfirmMessageDialog.js.map +1 -1
  32. package/lib/cjs/ui/widget/FeatureInfoDataProvider.d.ts +40 -40
  33. package/lib/cjs/ui/widget/FeatureInfoDataProvider.js +138 -139
  34. package/lib/cjs/ui/widget/FeatureInfoDataProvider.js.map +1 -1
  35. package/lib/cjs/ui/widget/FeatureInfoWidget.d.ts +7 -7
  36. package/lib/cjs/ui/widget/FeatureInfoWidget.js +65 -71
  37. package/lib/cjs/ui/widget/FeatureInfoWidget.js.map +1 -1
  38. package/lib/cjs/ui/widget/MapLayerDroppable.d.ts +19 -19
  39. package/lib/cjs/ui/widget/MapLayerDroppable.js +85 -88
  40. package/lib/cjs/ui/widget/MapLayerDroppable.js.map +1 -1
  41. package/lib/cjs/ui/widget/MapLayerManager.d.ts +26 -26
  42. package/lib/cjs/ui/widget/MapLayerManager.js +401 -403
  43. package/lib/cjs/ui/widget/MapLayerManager.js.map +1 -1
  44. package/lib/cjs/ui/widget/MapLayerManager.scss +409 -409
  45. package/lib/cjs/ui/widget/MapLayerSettingsMenu.d.ts +12 -12
  46. package/lib/cjs/ui/widget/MapLayerSettingsMenu.js +82 -83
  47. package/lib/cjs/ui/widget/MapLayerSettingsMenu.js.map +1 -1
  48. package/lib/cjs/ui/widget/MapLayerSettingsPopupButton.d.ts +7 -7
  49. package/lib/cjs/ui/widget/MapLayerSettingsPopupButton.js +65 -65
  50. package/lib/cjs/ui/widget/MapLayerSettingsPopupButton.js.map +1 -1
  51. package/lib/cjs/ui/widget/MapLayerSettingsPopupButton.scss +20 -20
  52. package/lib/cjs/ui/widget/MapLayersWidget.d.ts +11 -11
  53. package/lib/cjs/ui/widget/MapLayersWidget.js +31 -31
  54. package/lib/cjs/ui/widget/MapLayersWidget.js.map +1 -1
  55. package/lib/cjs/ui/widget/MapManagerSettings.d.ts +3 -3
  56. package/lib/cjs/ui/widget/MapManagerSettings.js +200 -200
  57. package/lib/cjs/ui/widget/MapManagerSettings.js.map +1 -1
  58. package/lib/cjs/ui/widget/MapManagerSettings.scss +29 -29
  59. package/lib/cjs/ui/widget/MapUrlDialog.d.ts +23 -23
  60. package/lib/cjs/ui/widget/MapUrlDialog.js +524 -527
  61. package/lib/cjs/ui/widget/MapUrlDialog.js.map +1 -1
  62. package/lib/cjs/ui/widget/MapUrlDialog.scss +100 -100
  63. package/lib/cjs/ui/widget/SelectMapFormat.d.ts +18 -18
  64. package/lib/cjs/ui/widget/SelectMapFormat.js +54 -59
  65. package/lib/cjs/ui/widget/SelectMapFormat.js.map +1 -1
  66. package/lib/cjs/ui/widget/SubLayersDataProvider.d.ts +20 -20
  67. package/lib/cjs/ui/widget/SubLayersDataProvider.js +75 -76
  68. package/lib/cjs/ui/widget/SubLayersDataProvider.js.map +1 -1
  69. package/lib/cjs/ui/widget/SubLayersPopupButton.d.ts +10 -10
  70. package/lib/cjs/ui/widget/SubLayersPopupButton.js +40 -40
  71. package/lib/cjs/ui/widget/SubLayersPopupButton.js.map +1 -1
  72. package/lib/cjs/ui/widget/SubLayersTree.d.ts +15 -15
  73. package/lib/cjs/ui/widget/SubLayersTree.js +413 -419
  74. package/lib/cjs/ui/widget/SubLayersTree.js.map +1 -1
  75. package/lib/cjs/ui/widget/SubLayersTree.scss +69 -69
  76. package/lib/cjs/ui/widget/TransparencyPopupButton.d.ts +14 -14
  77. package/lib/cjs/ui/widget/TransparencyPopupButton.js +47 -47
  78. package/lib/cjs/ui/widget/TransparencyPopupButton.js.map +1 -1
  79. package/lib/cjs/ui/widget/TransparencyPopupButton.scss +36 -36
  80. package/lib/esm/MapLayerPreferences.d.ts +88 -88
  81. package/lib/esm/MapLayerPreferences.js +307 -308
  82. package/lib/esm/MapLayerPreferences.js.map +1 -1
  83. package/lib/esm/map-layers.d.ts +6 -6
  84. package/lib/esm/map-layers.js +10 -10
  85. package/lib/esm/mapLayers.d.ts +44 -44
  86. package/lib/esm/mapLayers.js +57 -59
  87. package/lib/esm/mapLayers.js.map +1 -1
  88. package/lib/esm/ui/FeatureInfoUiItemsProvider.d.ts +11 -11
  89. package/lib/esm/ui/FeatureInfoUiItemsProvider.js +47 -48
  90. package/lib/esm/ui/FeatureInfoUiItemsProvider.js.map +1 -1
  91. package/lib/esm/ui/Interfaces.d.ts +50 -50
  92. package/lib/esm/ui/Interfaces.js +1 -1
  93. package/lib/esm/ui/Interfaces.js.map +1 -1
  94. package/lib/esm/ui/MapFeatureInfoTool.d.ts +13 -13
  95. package/lib/esm/ui/MapFeatureInfoTool.js +45 -45
  96. package/lib/esm/ui/MapFeatureInfoTool.js.map +1 -1
  97. package/lib/esm/ui/MapLayersUiItemsProvider.d.ts +8 -8
  98. package/lib/esm/ui/MapLayersUiItemsProvider.js +34 -34
  99. package/lib/esm/ui/MapLayersUiItemsProvider.js.map +1 -1
  100. package/lib/esm/ui/widget/AttachLayerPopupButton.d.ts +14 -14
  101. package/lib/esm/ui/widget/AttachLayerPopupButton.js +331 -334
  102. package/lib/esm/ui/widget/AttachLayerPopupButton.js.map +1 -1
  103. package/lib/esm/ui/widget/BasemapPanel.d.ts +8 -8
  104. package/lib/esm/ui/widget/BasemapPanel.js +152 -152
  105. package/lib/esm/ui/widget/BasemapPanel.js.map +1 -1
  106. package/lib/esm/ui/widget/BasemapPanel.scss +87 -87
  107. package/lib/esm/ui/widget/ConfirmMessageDialog.d.ts +21 -21
  108. package/lib/esm/ui/widget/ConfirmMessageDialog.js +18 -21
  109. package/lib/esm/ui/widget/ConfirmMessageDialog.js.map +1 -1
  110. package/lib/esm/ui/widget/FeatureInfoDataProvider.d.ts +40 -40
  111. package/lib/esm/ui/widget/FeatureInfoDataProvider.js +134 -135
  112. package/lib/esm/ui/widget/FeatureInfoDataProvider.js.map +1 -1
  113. package/lib/esm/ui/widget/FeatureInfoWidget.d.ts +7 -7
  114. package/lib/esm/ui/widget/FeatureInfoWidget.js +61 -67
  115. package/lib/esm/ui/widget/FeatureInfoWidget.js.map +1 -1
  116. package/lib/esm/ui/widget/MapLayerDroppable.d.ts +19 -19
  117. package/lib/esm/ui/widget/MapLayerDroppable.js +81 -84
  118. package/lib/esm/ui/widget/MapLayerDroppable.js.map +1 -1
  119. package/lib/esm/ui/widget/MapLayerManager.d.ts +26 -26
  120. package/lib/esm/ui/widget/MapLayerManager.js +396 -398
  121. package/lib/esm/ui/widget/MapLayerManager.js.map +1 -1
  122. package/lib/esm/ui/widget/MapLayerManager.scss +409 -409
  123. package/lib/esm/ui/widget/MapLayerSettingsMenu.d.ts +12 -12
  124. package/lib/esm/ui/widget/MapLayerSettingsMenu.js +78 -79
  125. package/lib/esm/ui/widget/MapLayerSettingsMenu.js.map +1 -1
  126. package/lib/esm/ui/widget/MapLayerSettingsPopupButton.d.ts +7 -7
  127. package/lib/esm/ui/widget/MapLayerSettingsPopupButton.js +61 -61
  128. package/lib/esm/ui/widget/MapLayerSettingsPopupButton.js.map +1 -1
  129. package/lib/esm/ui/widget/MapLayerSettingsPopupButton.scss +20 -20
  130. package/lib/esm/ui/widget/MapLayersWidget.d.ts +11 -11
  131. package/lib/esm/ui/widget/MapLayersWidget.js +27 -27
  132. package/lib/esm/ui/widget/MapLayersWidget.js.map +1 -1
  133. package/lib/esm/ui/widget/MapManagerSettings.d.ts +3 -3
  134. package/lib/esm/ui/widget/MapManagerSettings.js +196 -196
  135. package/lib/esm/ui/widget/MapManagerSettings.js.map +1 -1
  136. package/lib/esm/ui/widget/MapManagerSettings.scss +29 -29
  137. package/lib/esm/ui/widget/MapUrlDialog.d.ts +23 -23
  138. package/lib/esm/ui/widget/MapUrlDialog.js +520 -523
  139. package/lib/esm/ui/widget/MapUrlDialog.js.map +1 -1
  140. package/lib/esm/ui/widget/MapUrlDialog.scss +100 -100
  141. package/lib/esm/ui/widget/SelectMapFormat.d.ts +18 -18
  142. package/lib/esm/ui/widget/SelectMapFormat.js +50 -55
  143. package/lib/esm/ui/widget/SelectMapFormat.js.map +1 -1
  144. package/lib/esm/ui/widget/SubLayersDataProvider.d.ts +20 -20
  145. package/lib/esm/ui/widget/SubLayersDataProvider.js +71 -72
  146. package/lib/esm/ui/widget/SubLayersDataProvider.js.map +1 -1
  147. package/lib/esm/ui/widget/SubLayersPopupButton.d.ts +10 -10
  148. package/lib/esm/ui/widget/SubLayersPopupButton.js +36 -36
  149. package/lib/esm/ui/widget/SubLayersPopupButton.js.map +1 -1
  150. package/lib/esm/ui/widget/SubLayersTree.d.ts +15 -15
  151. package/lib/esm/ui/widget/SubLayersTree.js +408 -414
  152. package/lib/esm/ui/widget/SubLayersTree.js.map +1 -1
  153. package/lib/esm/ui/widget/SubLayersTree.scss +69 -69
  154. package/lib/esm/ui/widget/TransparencyPopupButton.d.ts +14 -14
  155. package/lib/esm/ui/widget/TransparencyPopupButton.js +43 -43
  156. package/lib/esm/ui/widget/TransparencyPopupButton.js.map +1 -1
  157. package/lib/esm/ui/widget/TransparencyPopupButton.scss +36 -36
  158. package/package.json +14 -14
@@ -1,140 +1,139 @@
1
- "use strict";
2
- /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
- * See LICENSE.md in the project root for license terms and full copyright notice.
5
- *--------------------------------------------------------------------------------------------*/
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.FeatureInfoDataProvider = exports.MapFeatureInfoLoadState = void 0;
8
- const appui_abstract_1 = require("@itwin/appui-abstract");
9
- const components_react_1 = require("@itwin/components-react");
10
- const core_bentley_1 = require("@itwin/core-bentley");
11
- // import { IPropertyDataProvider, PropertyCategory, PropertyData, PropertyDataChangeEvent } from ""
12
- /**
13
- * Implementation of [IPropertyDataProvider] that uses an associative array.
14
- * @public
15
- */
16
- var MapFeatureInfoLoadState;
17
- (function (MapFeatureInfoLoadState) {
18
- MapFeatureInfoLoadState[MapFeatureInfoLoadState["DataLoadStart"] = 0] = "DataLoadStart";
19
- MapFeatureInfoLoadState[MapFeatureInfoLoadState["DataLoadEnd"] = 1] = "DataLoadEnd";
20
- })(MapFeatureInfoLoadState = exports.MapFeatureInfoLoadState || (exports.MapFeatureInfoLoadState = {}));
21
- class FeatureInfoDataProvider {
22
- constructor(onMapHit) {
23
- this.label = appui_abstract_1.PropertyRecord.fromString("");
24
- this.categories = [];
25
- this.records = {};
26
- this.onDataChanged = new components_react_1.PropertyDataChangeEvent();
27
- this.onDataLoadStateChanged = new core_bentley_1.BeEvent();
28
- this.onDataUpdated = new core_bentley_1.BeEvent();
29
- // eslint-disable-next-line @typescript-eslint/unbound-method
30
- this._removeListener = onMapHit.addListener(this._handleMapHit, this);
31
- }
32
- onUnload() {
33
- this._removeListener();
34
- }
35
- async _handleMapHit(mapHit) {
36
- var _a, _b;
37
- this.records = {};
38
- this.categories = [];
39
- let recordCount = 0;
40
- if (mapHit === null || mapHit === void 0 ? void 0 : mapHit.isMapHit) {
41
- this.onDataLoadStateChanged.raiseEvent(MapFeatureInfoLoadState.DataLoadStart);
42
- const mapInfo = await mapHit.viewport.getMapFeatureInfo(mapHit);
43
- this.onDataLoadStateChanged.raiseEvent(MapFeatureInfoLoadState.DataLoadEnd);
44
- if (mapInfo.layerInfo !== undefined) {
45
- for (const curLayerInfo of mapInfo.layerInfo) {
46
- const layerCatIdx = this.findCategoryIndexByName(curLayerInfo.layerName);
47
- let nbRecords = 0;
48
- const layerCategory = (layerCatIdx === -1 ?
49
- { name: curLayerInfo.layerName, label: curLayerInfo.layerName, expand: true, childCategories: [] }
50
- : this.categories[layerCatIdx]);
51
- if (curLayerInfo.info && !(curLayerInfo.info instanceof HTMLElement)) {
52
- // This is not an HTMLElement, so iterate over each sub-layer info
53
- for (const subLayerInfo of curLayerInfo.info) {
54
- nbRecords++;
55
- const subCatIdx = (_a = layerCategory.childCategories) === null || _a === void 0 ? void 0 : _a.findIndex((testCategory) => {
56
- return testCategory.name === subLayerInfo.subLayerName;
57
- });
58
- let subLayerCategory;
59
- if (subCatIdx === -1) {
60
- subLayerCategory = { name: subLayerInfo.subLayerName, label: subLayerInfo.subLayerName, expand: true };
61
- this.addSubCategory(subLayerCategory.name);
62
- (_b = layerCategory.childCategories) === null || _b === void 0 ? void 0 : _b.push(subLayerCategory);
63
- }
64
- if (subLayerInfo.records) {
65
- for (const record of subLayerInfo.records) {
66
- // Always use the string value for now
67
- this.addProperty(record, subLayerInfo.subLayerName);
68
- }
69
- }
70
- }
71
- }
72
- if (layerCatIdx === -1 && nbRecords > 0)
73
- this.addCategory(layerCategory);
74
- recordCount = recordCount + nbRecords;
75
- }
76
- }
77
- }
78
- this.onDataUpdated.raiseEvent({ recordCount });
79
- this.onDataChanged.raiseEvent();
80
- }
81
- addSubCategory(categoryName) {
82
- this.records[categoryName] = [];
83
- }
84
- addCategory(category) {
85
- const categoryIdx = this.categories.push(category) - 1;
86
- this.records[this.categories[categoryIdx].name] = [];
87
- return categoryIdx;
88
- }
89
- findCategoryIndex(category) {
90
- const index = this.categories.findIndex((testCategory) => {
91
- return testCategory.name === category.name;
92
- });
93
- return index;
94
- }
95
- findCategoryIndexByName(name) {
96
- const index = this.categories.findIndex((testCategory) => {
97
- return testCategory.name === name;
98
- });
99
- return index;
100
- }
101
- addProperty(propertyRecord, categoryName) {
102
- const idx = this.records[categoryName].findIndex((prop) => prop.property.name === propertyRecord.property.name);
103
- if (idx === -1) {
104
- this.records[categoryName].push(propertyRecord);
105
- }
106
- else {
107
- this.records[categoryName][idx].isMerged = true;
108
- this.records[categoryName][idx].isReadonly = true;
109
- }
110
- }
111
- removeProperty(propertyRecord, categoryIdx) {
112
- const index = this.records[this.categories[categoryIdx].name].findIndex((record) => {
113
- return record === propertyRecord;
114
- });
115
- let result = false;
116
- if (index >= 0) {
117
- this.records[this.categories[categoryIdx].name].splice(index, 1);
118
- this.onDataChanged.raiseEvent();
119
- result = true;
120
- }
121
- return result;
122
- }
123
- replaceProperty(propertyRecord, categoryIdx, newRecord) {
124
- const index = this.records[this.categories[categoryIdx].name].findIndex((record) => {
125
- return record === propertyRecord;
126
- });
127
- let result = false;
128
- // istanbul ignore else
129
- if (index >= 0) {
130
- this.records[this.categories[categoryIdx].name].splice(index, 1, newRecord);
131
- result = true;
132
- }
133
- return result;
134
- }
135
- async getData() {
136
- return this;
137
- }
138
- }
139
- exports.FeatureInfoDataProvider = FeatureInfoDataProvider;
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.FeatureInfoDataProvider = exports.MapFeatureInfoLoadState = void 0;
8
+ const appui_abstract_1 = require("@itwin/appui-abstract");
9
+ const components_react_1 = require("@itwin/components-react");
10
+ const core_bentley_1 = require("@itwin/core-bentley");
11
+ // import { IPropertyDataProvider, PropertyCategory, PropertyData, PropertyDataChangeEvent } from ""
12
+ /**
13
+ * Implementation of [IPropertyDataProvider] that uses an associative array.
14
+ * @public
15
+ */
16
+ var MapFeatureInfoLoadState;
17
+ (function (MapFeatureInfoLoadState) {
18
+ MapFeatureInfoLoadState[MapFeatureInfoLoadState["DataLoadStart"] = 0] = "DataLoadStart";
19
+ MapFeatureInfoLoadState[MapFeatureInfoLoadState["DataLoadEnd"] = 1] = "DataLoadEnd";
20
+ })(MapFeatureInfoLoadState = exports.MapFeatureInfoLoadState || (exports.MapFeatureInfoLoadState = {}));
21
+ class FeatureInfoDataProvider {
22
+ constructor(onMapHit) {
23
+ this.label = appui_abstract_1.PropertyRecord.fromString("");
24
+ this.categories = [];
25
+ this.records = {};
26
+ this.onDataChanged = new components_react_1.PropertyDataChangeEvent();
27
+ this.onDataLoadStateChanged = new core_bentley_1.BeEvent();
28
+ this.onDataUpdated = new core_bentley_1.BeEvent();
29
+ // eslint-disable-next-line @typescript-eslint/unbound-method
30
+ this._removeListener = onMapHit.addListener(this._handleMapHit, this);
31
+ }
32
+ onUnload() {
33
+ this._removeListener();
34
+ }
35
+ async _handleMapHit(mapHit) {
36
+ this.records = {};
37
+ this.categories = [];
38
+ let recordCount = 0;
39
+ if (mapHit?.isMapHit) {
40
+ this.onDataLoadStateChanged.raiseEvent(MapFeatureInfoLoadState.DataLoadStart);
41
+ const mapInfo = await mapHit.viewport.getMapFeatureInfo(mapHit);
42
+ this.onDataLoadStateChanged.raiseEvent(MapFeatureInfoLoadState.DataLoadEnd);
43
+ if (mapInfo.layerInfo !== undefined) {
44
+ for (const curLayerInfo of mapInfo.layerInfo) {
45
+ const layerCatIdx = this.findCategoryIndexByName(curLayerInfo.layerName);
46
+ let nbRecords = 0;
47
+ const layerCategory = (layerCatIdx === -1 ?
48
+ { name: curLayerInfo.layerName, label: curLayerInfo.layerName, expand: true, childCategories: [] }
49
+ : this.categories[layerCatIdx]);
50
+ if (curLayerInfo.info && !(curLayerInfo.info instanceof HTMLElement)) {
51
+ // This is not an HTMLElement, so iterate over each sub-layer info
52
+ for (const subLayerInfo of curLayerInfo.info) {
53
+ nbRecords++;
54
+ const subCatIdx = layerCategory.childCategories?.findIndex((testCategory) => {
55
+ return testCategory.name === subLayerInfo.subLayerName;
56
+ });
57
+ let subLayerCategory;
58
+ if (subCatIdx === -1) {
59
+ subLayerCategory = { name: subLayerInfo.subLayerName, label: subLayerInfo.subLayerName, expand: true };
60
+ this.addSubCategory(subLayerCategory.name);
61
+ layerCategory.childCategories?.push(subLayerCategory);
62
+ }
63
+ if (subLayerInfo.records) {
64
+ for (const record of subLayerInfo.records) {
65
+ // Always use the string value for now
66
+ this.addProperty(record, subLayerInfo.subLayerName);
67
+ }
68
+ }
69
+ }
70
+ }
71
+ if (layerCatIdx === -1 && nbRecords > 0)
72
+ this.addCategory(layerCategory);
73
+ recordCount = recordCount + nbRecords;
74
+ }
75
+ }
76
+ }
77
+ this.onDataUpdated.raiseEvent({ recordCount });
78
+ this.onDataChanged.raiseEvent();
79
+ }
80
+ addSubCategory(categoryName) {
81
+ this.records[categoryName] = [];
82
+ }
83
+ addCategory(category) {
84
+ const categoryIdx = this.categories.push(category) - 1;
85
+ this.records[this.categories[categoryIdx].name] = [];
86
+ return categoryIdx;
87
+ }
88
+ findCategoryIndex(category) {
89
+ const index = this.categories.findIndex((testCategory) => {
90
+ return testCategory.name === category.name;
91
+ });
92
+ return index;
93
+ }
94
+ findCategoryIndexByName(name) {
95
+ const index = this.categories.findIndex((testCategory) => {
96
+ return testCategory.name === name;
97
+ });
98
+ return index;
99
+ }
100
+ addProperty(propertyRecord, categoryName) {
101
+ const idx = this.records[categoryName].findIndex((prop) => prop.property.name === propertyRecord.property.name);
102
+ if (idx === -1) {
103
+ this.records[categoryName].push(propertyRecord);
104
+ }
105
+ else {
106
+ this.records[categoryName][idx].isMerged = true;
107
+ this.records[categoryName][idx].isReadonly = true;
108
+ }
109
+ }
110
+ removeProperty(propertyRecord, categoryIdx) {
111
+ const index = this.records[this.categories[categoryIdx].name].findIndex((record) => {
112
+ return record === propertyRecord;
113
+ });
114
+ let result = false;
115
+ if (index >= 0) {
116
+ this.records[this.categories[categoryIdx].name].splice(index, 1);
117
+ this.onDataChanged.raiseEvent();
118
+ result = true;
119
+ }
120
+ return result;
121
+ }
122
+ replaceProperty(propertyRecord, categoryIdx, newRecord) {
123
+ const index = this.records[this.categories[categoryIdx].name].findIndex((record) => {
124
+ return record === propertyRecord;
125
+ });
126
+ let result = false;
127
+ // istanbul ignore else
128
+ if (index >= 0) {
129
+ this.records[this.categories[categoryIdx].name].splice(index, 1, newRecord);
130
+ result = true;
131
+ }
132
+ return result;
133
+ }
134
+ async getData() {
135
+ return this;
136
+ }
137
+ }
138
+ exports.FeatureInfoDataProvider = FeatureInfoDataProvider;
140
139
  //# sourceMappingURL=FeatureInfoDataProvider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FeatureInfoDataProvider.js","sourceRoot":"","sources":["../../../../src/ui/widget/FeatureInfoDataProvider.ts"],"names":[],"mappings":";AAA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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;AArID,0DAqIC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport { PropertyRecord } from \"@itwin/appui-abstract\";\r\nimport { IPropertyDataProvider, PropertyCategory, PropertyData, PropertyDataChangeEvent } from \"@itwin/components-react\";\r\nimport { BeEvent } from \"@itwin/core-bentley\";\r\nimport { HitDetail } from \"@itwin/core-frontend\";\r\nimport { MapHitEvent } from \"../Interfaces\";\r\n// import { IPropertyDataProvider, PropertyCategory, PropertyData, PropertyDataChangeEvent } from \"\"\r\n\r\n/**\r\n * Implementation of [IPropertyDataProvider] that uses an associative array.\r\n * @public\r\n */\r\n\r\nexport enum MapFeatureInfoLoadState {DataLoadStart, DataLoadEnd}\r\nexport declare type MapFeatureInfoLoadListener = (state: MapFeatureInfoLoadState) => void;\r\n\r\nexport interface MapFeatureInfoDataUpdate {\r\n recordCount: number;\r\n}\r\nexport declare type MapFeatureInfoDataUpdatedListener = (data: MapFeatureInfoDataUpdate) => void;\r\n\r\nexport class FeatureInfoDataProvider implements IPropertyDataProvider, PropertyData {\r\n private _removeListener: () => void;\r\n public label: PropertyRecord = PropertyRecord.fromString(\"\");\r\n public description?: string;\r\n public categories: PropertyCategory[] = [];\r\n public records: { [categoryName: string]: PropertyRecord[] } = {};\r\n public onDataChanged = new PropertyDataChangeEvent();\r\n public onDataLoadStateChanged = new BeEvent<MapFeatureInfoLoadListener>();\r\n public onDataUpdated = new BeEvent<MapFeatureInfoDataUpdatedListener>();\r\n constructor(onMapHit: MapHitEvent) {\r\n // eslint-disable-next-line @typescript-eslint/unbound-method\r\n this._removeListener = onMapHit.addListener(this._handleMapHit, this);\r\n }\r\n\r\n public onUnload() {\r\n this._removeListener();\r\n }\r\n\r\n private async _handleMapHit(mapHit: HitDetail) {\r\n this.records = {};\r\n this.categories = [];\r\n let recordCount = 0;\r\n if (mapHit?.isMapHit) {\r\n this.onDataLoadStateChanged.raiseEvent(MapFeatureInfoLoadState.DataLoadStart);\r\n const mapInfo = await mapHit.viewport.getMapFeatureInfo(mapHit);\r\n this.onDataLoadStateChanged.raiseEvent(MapFeatureInfoLoadState.DataLoadEnd);\r\n if (mapInfo.layerInfo !== undefined ) {\r\n for (const curLayerInfo of mapInfo.layerInfo) {\r\n const layerCatIdx = this.findCategoryIndexByName(curLayerInfo.layerName);\r\n let nbRecords = 0;\r\n const layerCategory = (\r\n layerCatIdx === -1 ?\r\n {name:curLayerInfo.layerName, label:curLayerInfo.layerName, expand:true, childCategories:[]}\r\n : this.categories[layerCatIdx] );\r\n\r\n if (curLayerInfo.info && !(curLayerInfo.info instanceof HTMLElement)) {\r\n // This is not an HTMLElement, so iterate over each sub-layer info\r\n for (const subLayerInfo of curLayerInfo.info) {\r\n nbRecords++;\r\n const subCatIdx = layerCategory.childCategories?.findIndex((testCategory: PropertyCategory) => {\r\n return testCategory.name === subLayerInfo.subLayerName;\r\n });\r\n let subLayerCategory;\r\n if (subCatIdx === -1) {\r\n subLayerCategory = {name:subLayerInfo.subLayerName, label:subLayerInfo.subLayerName, expand:true};\r\n this.addSubCategory(subLayerCategory.name);\r\n layerCategory.childCategories?.push(subLayerCategory);\r\n }\r\n if (subLayerInfo.records) {\r\n for (const record of subLayerInfo.records) {\r\n // Always use the string value for now\r\n this.addProperty(record, subLayerInfo.subLayerName);\r\n\r\n }\r\n }\r\n }\r\n }\r\n if (layerCatIdx === -1 && nbRecords>0)\r\n this.addCategory(layerCategory);\r\n\r\n recordCount = recordCount + nbRecords;\r\n }\r\n }\r\n }\r\n this.onDataUpdated.raiseEvent({recordCount});\r\n this.onDataChanged.raiseEvent();\r\n }\r\n\r\n public addSubCategory(categoryName: string) {\r\n this.records[categoryName] = [];\r\n }\r\n public addCategory(category: PropertyCategory): number {\r\n const categoryIdx = this.categories.push(category) - 1;\r\n this.records[this.categories[categoryIdx].name] = [];\r\n return categoryIdx;\r\n }\r\n\r\n public findCategoryIndex(category: PropertyCategory): number {\r\n const index = this.categories.findIndex((testCategory: PropertyCategory) => {\r\n return testCategory.name === category.name;\r\n });\r\n return index;\r\n }\r\n public findCategoryIndexByName(name: string): number {\r\n const index = this.categories.findIndex((testCategory: PropertyCategory) => {\r\n return testCategory.name === name;\r\n });\r\n return index;\r\n }\r\n\r\n public addProperty(propertyRecord: PropertyRecord, categoryName: string): void {\r\n const idx = this.records[categoryName].findIndex((prop)=> prop.property.name === propertyRecord.property.name);\r\n if (idx === -1) {\r\n this.records[categoryName].push(propertyRecord);\r\n } else {\r\n this.records[categoryName][idx].isMerged = true;\r\n this.records[categoryName][idx].isReadonly = true;\r\n }\r\n }\r\n\r\n public removeProperty(propertyRecord: PropertyRecord, categoryIdx: number): boolean {\r\n const index = this.records[this.categories[categoryIdx].name].findIndex((record: PropertyRecord) => {\r\n return record === propertyRecord;\r\n });\r\n\r\n let result = false;\r\n\r\n if (index >= 0) {\r\n this.records[this.categories[categoryIdx].name].splice(index, 1);\r\n this.onDataChanged.raiseEvent();\r\n result = true;\r\n }\r\n return result;\r\n }\r\n\r\n public replaceProperty(propertyRecord: PropertyRecord, categoryIdx: number, newRecord: PropertyRecord): boolean {\r\n const index = this.records[this.categories[categoryIdx].name].findIndex((record: PropertyRecord) => {\r\n return record === propertyRecord;\r\n });\r\n\r\n let result = false;\r\n\r\n // istanbul ignore else\r\n if (index >= 0) {\r\n this.records[this.categories[categoryIdx].name].splice(index, 1, newRecord);\r\n result = true;\r\n }\r\n return result;\r\n }\r\n\r\n public async getData(): Promise<PropertyData> {\r\n return this;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"FeatureInfoDataProvider.js","sourceRoot":"","sources":["../../../../src/ui/widget/FeatureInfoDataProvider.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,0DAAwD;AACxD,8DAAyH;AACzH,sDAA8C;AAG9C,oGAAoG;AAEpG;;;GAGG;AAEH,IAAY,uBAAoD;AAAhE,WAAY,uBAAuB;IAAE,uFAAa,CAAA;IAAE,mFAAW,CAAA;AAAA,CAAC,EAApD,uBAAuB,GAAvB,+BAAuB,KAAvB,+BAAuB,QAA6B;AAQhE,MAAa,uBAAuB;IASlC,YAAY,QAAqB;QAP1B,UAAK,GAAmB,+BAAc,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;QAEtD,eAAU,GAAuB,EAAE,CAAC;QACpC,YAAO,GAAiD,EAAE,CAAC;QAC3D,kBAAa,GAAG,IAAI,0CAAuB,EAAE,CAAC;QAC9C,2BAAsB,GAAG,IAAI,sBAAO,EAA8B,CAAC;QACnE,kBAAa,GAAG,IAAI,sBAAO,EAAqC,CAAC;QAEtE,6DAA6D;QAC7D,IAAI,CAAC,eAAe,GAAG,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;IACxE,CAAC;IAEM,QAAQ;QACb,IAAI,CAAC,eAAe,EAAE,CAAC;IACzB,CAAC;IAEO,KAAK,CAAC,aAAa,CAAC,MAAiB;QAC3C,IAAI,CAAC,OAAO,GAAG,EAAE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AAK,CAAC;QAEnB,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,CAAC,CAAC;YACjE,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,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;AArID,0DAqIC","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,8 +1,8 @@
1
- /// <reference types="react" />
2
- import { MapFeatureInfoOptions } from "../Interfaces";
3
- interface MapFeatureInfoWidgetProps {
4
- featureInfoOpts: MapFeatureInfoOptions;
5
- }
6
- export declare function MapFeatureInfoWidget({ featureInfoOpts }: MapFeatureInfoWidgetProps): JSX.Element;
7
- export {};
1
+ /// <reference types="react" />
2
+ import { MapFeatureInfoOptions } from "../Interfaces";
3
+ interface MapFeatureInfoWidgetProps {
4
+ featureInfoOpts: MapFeatureInfoOptions;
5
+ }
6
+ export declare function MapFeatureInfoWidget({ featureInfoOpts }: MapFeatureInfoWidgetProps): JSX.Element;
7
+ export {};
8
8
  //# sourceMappingURL=FeatureInfoWidget.d.ts.map
@@ -1,72 +1,66 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MapFeatureInfoWidget = void 0;
4
- /*---------------------------------------------------------------------------------------------
5
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
6
- * See LICENSE.md in the project root for license terms and full copyright notice.
7
- *--------------------------------------------------------------------------------------------*/
8
- const React = require("react");
9
- const components_react_1 = require("@itwin/components-react");
10
- const core_react_1 = require("@itwin/core-react");
11
- const FeatureInfoDataProvider_1 = require("./FeatureInfoDataProvider");
12
- const itwinui_react_1 = require("@itwin/itwinui-react");
13
- const mapLayers_1 = require("../../mapLayers");
14
- // eslint-disable-next-line @typescript-eslint/naming-convention
15
- function MapFeatureInfoWidget({ featureInfoOpts }) {
16
- var _a;
17
- const dataProvider = React.useRef();
18
- const [loadingData, setLoadingData] = React.useState(false);
19
- const [hasData, setHasData] = React.useState(false);
20
- const [noRecordsMessage] = React.useState(mapLayers_1.MapLayersUI.localization.getLocalizedString("mapLayers:FeatureInfoWidget.NoRecords"));
21
- const handleLoadStateChange = (state) => {
22
- setLoadingData(state === FeatureInfoDataProvider_1.MapFeatureInfoLoadState.DataLoadStart);
23
- };
24
- const handleDataUpdated = (state) => {
25
- setHasData(state.recordCount !== 0);
26
- };
27
- React.useEffect(() => {
28
- if (featureInfoOpts === null || featureInfoOpts === void 0 ? void 0 : featureInfoOpts.onMapHit) {
29
- dataProvider.current = new FeatureInfoDataProvider_1.FeatureInfoDataProvider(featureInfoOpts.onMapHit);
30
- }
31
- return () => {
32
- var _a;
33
- (_a = dataProvider === null || dataProvider === void 0 ? void 0 : dataProvider.current) === null || _a === void 0 ? void 0 : _a.onUnload();
34
- };
35
- }, [featureInfoOpts === null || featureInfoOpts === void 0 ? void 0 : featureInfoOpts.onMapHit]);
36
- React.useEffect(() => {
37
- var _a;
38
- (_a = dataProvider.current) === null || _a === void 0 ? void 0 : _a.onDataUpdated.addListener(handleDataUpdated);
39
- return () => {
40
- var _a;
41
- (_a = dataProvider.current) === null || _a === void 0 ? void 0 : _a.onDataUpdated.removeListener(handleDataUpdated);
42
- };
43
- }, []);
44
- React.useEffect(() => {
45
- var _a;
46
- if (featureInfoOpts === null || featureInfoOpts === void 0 ? void 0 : featureInfoOpts.showLoadProgressAnimation) {
47
- (_a = dataProvider.current) === null || _a === void 0 ? void 0 : _a.onDataLoadStateChanged.addListener(handleLoadStateChange);
48
- return () => {
49
- var _a;
50
- (_a = dataProvider.current) === null || _a === void 0 ? void 0 : _a.onDataLoadStateChanged.removeListener(handleLoadStateChange);
51
- };
52
- }
53
- return;
54
- }, [featureInfoOpts === null || featureInfoOpts === void 0 ? void 0 : featureInfoOpts.showLoadProgressAnimation]);
55
- if (loadingData) {
56
- return (React.createElement(core_react_1.FillCentered, null,
57
- React.createElement(itwinui_react_1.ProgressRadial, { indeterminate: true })));
58
- }
59
- else if (!hasData) {
60
- return (React.createElement(core_react_1.FillCentered, null,
61
- React.createElement("span", null,
62
- React.createElement("i", null, noRecordsMessage))));
63
- }
64
- else {
65
- if (dataProvider.current)
66
- return (React.createElement(components_react_1.PropertyGrid, { dataProvider: dataProvider.current, orientation: core_react_1.Orientation.Vertical, isPropertySelectionEnabled: (_a = featureInfoOpts === null || featureInfoOpts === void 0 ? void 0 : featureInfoOpts.propertyGridOptions) === null || _a === void 0 ? void 0 : _a.isPropertySelectionEnabled }));
67
- else
68
- return (React.createElement(React.Fragment, null));
69
- }
70
- }
71
- exports.MapFeatureInfoWidget = MapFeatureInfoWidget;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MapFeatureInfoWidget = void 0;
4
+ /*---------------------------------------------------------------------------------------------
5
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
6
+ * See LICENSE.md in the project root for license terms and full copyright notice.
7
+ *--------------------------------------------------------------------------------------------*/
8
+ const React = require("react");
9
+ const components_react_1 = require("@itwin/components-react");
10
+ const core_react_1 = require("@itwin/core-react");
11
+ const FeatureInfoDataProvider_1 = require("./FeatureInfoDataProvider");
12
+ const itwinui_react_1 = require("@itwin/itwinui-react");
13
+ const mapLayers_1 = require("../../mapLayers");
14
+ // eslint-disable-next-line @typescript-eslint/naming-convention
15
+ function MapFeatureInfoWidget({ featureInfoOpts }) {
16
+ const dataProvider = React.useRef();
17
+ const [loadingData, setLoadingData] = React.useState(false);
18
+ const [hasData, setHasData] = React.useState(false);
19
+ const [noRecordsMessage] = React.useState(mapLayers_1.MapLayersUI.localization.getLocalizedString("mapLayers:FeatureInfoWidget.NoRecords"));
20
+ const handleLoadStateChange = (state) => {
21
+ setLoadingData(state === FeatureInfoDataProvider_1.MapFeatureInfoLoadState.DataLoadStart);
22
+ };
23
+ const handleDataUpdated = (state) => {
24
+ setHasData(state.recordCount !== 0);
25
+ };
26
+ React.useEffect(() => {
27
+ if (featureInfoOpts?.onMapHit) {
28
+ dataProvider.current = new FeatureInfoDataProvider_1.FeatureInfoDataProvider(featureInfoOpts.onMapHit);
29
+ }
30
+ return () => {
31
+ dataProvider?.current?.onUnload();
32
+ };
33
+ }, [featureInfoOpts?.onMapHit]);
34
+ React.useEffect(() => {
35
+ dataProvider.current?.onDataUpdated.addListener(handleDataUpdated);
36
+ return () => {
37
+ dataProvider.current?.onDataUpdated.removeListener(handleDataUpdated);
38
+ };
39
+ }, []);
40
+ React.useEffect(() => {
41
+ if (featureInfoOpts?.showLoadProgressAnimation) {
42
+ dataProvider.current?.onDataLoadStateChanged.addListener(handleLoadStateChange);
43
+ return () => {
44
+ dataProvider.current?.onDataLoadStateChanged.removeListener(handleLoadStateChange);
45
+ };
46
+ }
47
+ return;
48
+ }, [featureInfoOpts?.showLoadProgressAnimation]);
49
+ if (loadingData) {
50
+ return (React.createElement(core_react_1.FillCentered, null,
51
+ React.createElement(itwinui_react_1.ProgressRadial, { indeterminate: true })));
52
+ }
53
+ else if (!hasData) {
54
+ return (React.createElement(core_react_1.FillCentered, null,
55
+ React.createElement("span", null,
56
+ React.createElement("i", null, noRecordsMessage))));
57
+ }
58
+ else {
59
+ if (dataProvider.current)
60
+ return (React.createElement(components_react_1.PropertyGrid, { dataProvider: dataProvider.current, orientation: core_react_1.Orientation.Vertical, isPropertySelectionEnabled: featureInfoOpts?.propertyGridOptions?.isPropertySelectionEnabled }));
61
+ else
62
+ return (React.createElement(React.Fragment, null));
63
+ }
64
+ }
65
+ exports.MapFeatureInfoWidget = MapFeatureInfoWidget;
72
66
  //# sourceMappingURL=FeatureInfoWidget.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FeatureInfoWidget.js","sourceRoot":"","sources":["../../../../src/ui/widget/FeatureInfoWidget.tsx"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,+BAA+B;AAE/B,8DAAuD;AACvD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["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport * as React from \"react\";\r\n\r\nimport { PropertyGrid } from \"@itwin/components-react\";\r\nimport { FillCentered, Orientation } from \"@itwin/core-react\";\r\n\r\nimport { FeatureInfoDataProvider, MapFeatureInfoDataUpdate, MapFeatureInfoLoadState } from \"./FeatureInfoDataProvider\";\r\nimport { ProgressRadial } from \"@itwin/itwinui-react\";\r\nimport { MapFeatureInfoOptions } from \"../Interfaces\";\r\nimport { MapLayersUI } from \"../../mapLayers\";\r\n\r\ninterface MapFeatureInfoWidgetProps {\r\n featureInfoOpts: MapFeatureInfoOptions;\r\n}\r\n\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function MapFeatureInfoWidget({ featureInfoOpts }: MapFeatureInfoWidgetProps) {\r\n\r\n const dataProvider = React.useRef<FeatureInfoDataProvider>();\r\n const [loadingData, setLoadingData] = React.useState<boolean>(false);\r\n const [hasData, setHasData] = React.useState<boolean>(false);\r\n const [noRecordsMessage] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:FeatureInfoWidget.NoRecords\"));\r\n\r\n const handleLoadStateChange = (state: MapFeatureInfoLoadState) => {\r\n setLoadingData(state === MapFeatureInfoLoadState.DataLoadStart);\r\n };\r\n const handleDataUpdated = (state: MapFeatureInfoDataUpdate) => {\r\n setHasData(state.recordCount !== 0);\r\n };\r\n\r\n React.useEffect(() => {\r\n if (featureInfoOpts?.onMapHit) {\r\n dataProvider.current = new FeatureInfoDataProvider(featureInfoOpts.onMapHit);\r\n }\r\n return () => {\r\n dataProvider?.current?.onUnload();\r\n };\r\n }, [featureInfoOpts?.onMapHit]);\r\n\r\n React.useEffect(() => {\r\n\r\n dataProvider.current?.onDataUpdated.addListener(handleDataUpdated);\r\n return () => {\r\n dataProvider.current?.onDataUpdated.removeListener(handleDataUpdated);\r\n };\r\n\r\n }, []);\r\n\r\n React.useEffect(() => {\r\n if (featureInfoOpts?.showLoadProgressAnimation) {\r\n dataProvider.current?.onDataLoadStateChanged.addListener(handleLoadStateChange);\r\n return () => {\r\n dataProvider.current?.onDataLoadStateChanged.removeListener(handleLoadStateChange);\r\n };\r\n }\r\n return;\r\n\r\n }, [featureInfoOpts?.showLoadProgressAnimation]);\r\n\r\n if (loadingData) {\r\n return (<FillCentered><ProgressRadial indeterminate={true}></ProgressRadial></FillCentered>);\r\n } else if (!hasData) {\r\n return (<FillCentered><span><i>{noRecordsMessage}</i></span></FillCentered>);\r\n } else {\r\n if (dataProvider.current)\r\n return (<PropertyGrid dataProvider={dataProvider.current} orientation={Orientation.Vertical} // eslint-disable-line deprecation/deprecation\r\n isPropertySelectionEnabled={featureInfoOpts?.propertyGridOptions?.isPropertySelectionEnabled} />);\r\n else\r\n return (<></>);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"FeatureInfoWidget.js","sourceRoot":"","sources":["../../../../src/ui/widget/FeatureInfoWidget.tsx"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,+BAA+B;AAE/B,8DAAuD;AACvD,kDAA8D;AAE9D,uEAAuH;AACvH,wDAAsD;AAEtD,+CAA8C;AAM9C,gEAAgE;AAChE,SAAgB,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,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAU,KAAK,CAAC,CAAC;IAC7D,MAAM,CAAC,gBAAgB,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,uBAAW,CAAC,YAAY,CAAC,kBAAkB,CAAC,uCAAuC,CAAC,CAAC,CAAC;IAEhI,MAAM,qB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CAAC,oBAAC,yBAAY;YAAC,oBAAC,8BAAc,IAAC,aAAa,EAAE,IAAI,GAAmB,CAAe,CAAC,CAAC;KAC9F;SAAM,IAAI,CAAC,OAAO,EAAE;QACnB,OAAO,CAAC,oBAAC,yBAAY;YAAC;gBAAM,+BAAI,gBAAgB,CAAK,CAAO,CAAe,CAAC,CAAC;KAC9E;SAAM;QACL,IAAI,YAAY,CAAC,OAAO;YACtB,OAAO,CAAC,oBAAC,+BAAY,IAAC,YAAY,EAAE,YAAY,CAAC,OAAO,EAAE,WAAW,EAAE,wBAAW,CAAC,QAAQ,EACzF,0BAA0B,EAAE,eAAe,EAAE,mBAAmB,EAAE,0BAA0B,GAAI,CAAC,CAAC;;YAEpG,OAAO,CAAC,yCAAK,CAAC,CAAC;KAClB;AACH,CAAC;AAtDD,oDAsDC","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,20 +1,20 @@
1
- /// <reference types="react" />
2
- import { ScreenViewport } from "@itwin/core-frontend";
3
- import { MapTypesOptions, StyleMapLayerSettings } from "../Interfaces";
4
- import "./MapLayerManager.scss";
5
- /** @internal */
6
- interface MapLayerDroppableProps {
7
- isOverlay: boolean;
8
- layersList?: StyleMapLayerSettings[];
9
- mapTypesOptions?: MapTypesOptions;
10
- getContainerForClone: () => HTMLElement;
11
- activeViewport: ScreenViewport;
12
- onMenuItemSelected: (action: string, mapLayerSettings: StyleMapLayerSettings) => void;
13
- onItemVisibilityToggleClicked: (mapLayerSettings: StyleMapLayerSettings) => void;
14
- onItemEdited: () => void;
15
- disabled?: boolean;
16
- }
17
- /** @internal */
18
- export declare function MapLayerDroppable(props: MapLayerDroppableProps): JSX.Element;
19
- export {};
1
+ /// <reference types="react" />
2
+ import { ScreenViewport } from "@itwin/core-frontend";
3
+ import { MapTypesOptions, StyleMapLayerSettings } from "../Interfaces";
4
+ import "./MapLayerManager.scss";
5
+ /** @internal */
6
+ interface MapLayerDroppableProps {
7
+ isOverlay: boolean;
8
+ layersList?: StyleMapLayerSettings[];
9
+ mapTypesOptions?: MapTypesOptions;
10
+ getContainerForClone: () => HTMLElement;
11
+ activeViewport: ScreenViewport;
12
+ onMenuItemSelected: (action: string, mapLayerSettings: StyleMapLayerSettings) => void;
13
+ onItemVisibilityToggleClicked: (mapLayerSettings: StyleMapLayerSettings) => void;
14
+ onItemEdited: () => void;
15
+ disabled?: boolean;
16
+ }
17
+ /** @internal */
18
+ export declare function MapLayerDroppable(props: MapLayerDroppableProps): JSX.Element;
19
+ export {};
20
20
  //# sourceMappingURL=MapLayerDroppable.d.ts.map