@itwin/map-layers 4.0.0-dev.49 → 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.
- package/lib/cjs/ui/widget/FeatureInfoDataProvider.d.ts +2 -7
- package/lib/cjs/ui/widget/FeatureInfoDataProvider.d.ts.map +1 -1
- package/lib/cjs/ui/widget/FeatureInfoDataProvider.js +23 -22
- package/lib/cjs/ui/widget/FeatureInfoDataProvider.js.map +1 -1
- package/lib/cjs/ui/widget/FeatureInfoWidget.d.ts.map +1 -1
- package/lib/cjs/ui/widget/FeatureInfoWidget.js +6 -1
- package/lib/cjs/ui/widget/FeatureInfoWidget.js.map +1 -1
- package/lib/esm/ui/widget/FeatureInfoDataProvider.d.ts +2 -7
- package/lib/esm/ui/widget/FeatureInfoDataProvider.d.ts.map +1 -1
- package/lib/esm/ui/widget/FeatureInfoDataProvider.js +23 -22
- package/lib/esm/ui/widget/FeatureInfoDataProvider.js.map +1 -1
- package/lib/esm/ui/widget/FeatureInfoWidget.d.ts.map +1 -1
- package/lib/esm/ui/widget/FeatureInfoWidget.js +8 -3
- package/lib/esm/ui/widget/FeatureInfoWidget.js.map +1 -1
- package/package.json +11 -11
|
@@ -15,17 +15,12 @@ export interface MapFeatureInfoDataUpdate {
|
|
|
15
15
|
recordCount: number;
|
|
16
16
|
}
|
|
17
17
|
export declare type MapFeatureInfoDataUpdatedListener = (data: MapFeatureInfoDataUpdate) => void;
|
|
18
|
-
export declare class FeatureInfoDataProvider implements IPropertyDataProvider
|
|
18
|
+
export declare class FeatureInfoDataProvider implements IPropertyDataProvider {
|
|
19
19
|
private _removeListener;
|
|
20
|
-
label: PropertyRecord;
|
|
21
|
-
description?: string;
|
|
22
|
-
categories: PropertyCategory[];
|
|
23
|
-
records: {
|
|
24
|
-
[categoryName: string]: PropertyRecord[];
|
|
25
|
-
};
|
|
26
20
|
onDataChanged: PropertyDataChangeEvent;
|
|
27
21
|
onDataLoadStateChanged: BeEvent<MapFeatureInfoLoadListener>;
|
|
28
22
|
onDataUpdated: BeEvent<MapFeatureInfoDataUpdatedListener>;
|
|
23
|
+
private _data;
|
|
29
24
|
constructor(onMapHit: MapHitEvent);
|
|
30
25
|
onUnload(): void;
|
|
31
26
|
private _handleMapHit;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FeatureInfoDataProvider.d.ts","sourceRoot":"","sources":["../../../../src/ui/widget/FeatureInfoDataProvider.ts"],"names":[],"mappings":"AAKA,OAAO,
|
|
1
|
+
{"version":3,"file":"FeatureInfoDataProvider.d.ts","sourceRoot":"","sources":["../../../../src/ui/widget/FeatureInfoDataProvider.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AACzH,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;GAGG;AAEH,oBAAY,uBAAuB;IAAG,aAAa,IAAA;IAAE,WAAW,IAAA;CAAE;AAClE,MAAM,CAAC,OAAO,MAAM,0BAA0B,GAAG,CAAC,KAAK,EAAE,uBAAuB,KAAK,IAAI,CAAC;AAE1F,MAAM,WAAW,wBAAwB;IACvC,WAAW,EAAE,MAAM,CAAC;CACrB;AACD,MAAM,CAAC,OAAO,MAAM,iCAAiC,GAAG,CAAC,IAAI,EAAE,wBAAwB,KAAK,IAAI,CAAC;AASjG,qBAAa,uBAAwB,YAAW,qBAAqB;IACnE,OAAO,CAAC,eAAe,CAAa;IAC7B,aAAa,0BAAiC;IAC9C,sBAAsB,sCAA6C;IACnE,aAAa,6CAAoD;IACxE,OAAO,CAAC,KAAK,CAA4B;gBAC7B,QAAQ,EAAE,WAAW;IAI1B,QAAQ;YAID,aAAa;IAkDpB,cAAc,CAAC,YAAY,EAAE,MAAM;IAGnC,WAAW,CAAC,QAAQ,EAAE,gBAAgB,GAAG,MAAM;IAO/C,iBAAiB,CAAC,QAAQ,EAAE,gBAAgB,GAAG,MAAM;IAMrD,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAO7C,WAAW,CAAC,cAAc,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI;IAUvE,cAAc,CAAC,cAAc,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO;IAe5E,eAAe,CAAC,cAAc,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,GAAG,OAAO;IAclG,OAAO,IAAI,OAAO,CAAC,YAAY,CAAC;CAG9C"}
|
|
@@ -8,7 +8,6 @@ exports.FeatureInfoDataProvider = exports.MapFeatureInfoLoadState = void 0;
|
|
|
8
8
|
const appui_abstract_1 = require("@itwin/appui-abstract");
|
|
9
9
|
const components_react_1 = require("@itwin/components-react");
|
|
10
10
|
const core_bentley_1 = require("@itwin/core-bentley");
|
|
11
|
-
// import { IPropertyDataProvider, PropertyCategory, PropertyData, PropertyDataChangeEvent } from ""
|
|
12
11
|
/**
|
|
13
12
|
* Implementation of [IPropertyDataProvider] that uses an associative array.
|
|
14
13
|
* @public
|
|
@@ -18,15 +17,19 @@ var MapFeatureInfoLoadState;
|
|
|
18
17
|
MapFeatureInfoLoadState[MapFeatureInfoLoadState["DataLoadStart"] = 0] = "DataLoadStart";
|
|
19
18
|
MapFeatureInfoLoadState[MapFeatureInfoLoadState["DataLoadEnd"] = 1] = "DataLoadEnd";
|
|
20
19
|
})(MapFeatureInfoLoadState = exports.MapFeatureInfoLoadState || (exports.MapFeatureInfoLoadState = {}));
|
|
21
|
-
class
|
|
22
|
-
constructor(
|
|
20
|
+
class SimplePropertyData {
|
|
21
|
+
constructor() {
|
|
23
22
|
this.label = appui_abstract_1.PropertyRecord.fromString("");
|
|
24
23
|
this.categories = [];
|
|
25
24
|
this.records = {};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
class FeatureInfoDataProvider {
|
|
28
|
+
constructor(onMapHit) {
|
|
26
29
|
this.onDataChanged = new components_react_1.PropertyDataChangeEvent();
|
|
27
30
|
this.onDataLoadStateChanged = new core_bentley_1.BeEvent();
|
|
28
31
|
this.onDataUpdated = new core_bentley_1.BeEvent();
|
|
29
|
-
|
|
32
|
+
this._data = new SimplePropertyData();
|
|
30
33
|
this._removeListener = onMapHit.addListener(this._handleMapHit, this);
|
|
31
34
|
}
|
|
32
35
|
onUnload() {
|
|
@@ -34,8 +37,7 @@ class FeatureInfoDataProvider {
|
|
|
34
37
|
}
|
|
35
38
|
async _handleMapHit(mapHit) {
|
|
36
39
|
var _a, _b;
|
|
37
|
-
this.
|
|
38
|
-
this.categories = [];
|
|
40
|
+
this._data = new SimplePropertyData();
|
|
39
41
|
let recordCount = 0;
|
|
40
42
|
if (mapHit === null || mapHit === void 0 ? void 0 : mapHit.isMapHit) {
|
|
41
43
|
this.onDataLoadStateChanged.raiseEvent(MapFeatureInfoLoadState.DataLoadStart);
|
|
@@ -47,7 +49,7 @@ class FeatureInfoDataProvider {
|
|
|
47
49
|
let nbRecords = 0;
|
|
48
50
|
const layerCategory = (layerCatIdx === -1 ?
|
|
49
51
|
{ name: curLayerInfo.layerName, label: curLayerInfo.layerName, expand: true, childCategories: [] }
|
|
50
|
-
: this.categories[layerCatIdx]);
|
|
52
|
+
: this._data.categories[layerCatIdx]);
|
|
51
53
|
if (curLayerInfo.info && !(curLayerInfo.info instanceof HTMLElement)) {
|
|
52
54
|
// This is not an HTMLElement, so iterate over each sub-layer info
|
|
53
55
|
for (const subLayerInfo of curLayerInfo.info) {
|
|
@@ -79,61 +81,60 @@ class FeatureInfoDataProvider {
|
|
|
79
81
|
this.onDataChanged.raiseEvent();
|
|
80
82
|
}
|
|
81
83
|
addSubCategory(categoryName) {
|
|
82
|
-
this.records[categoryName] = [];
|
|
84
|
+
this._data.records[categoryName] = [];
|
|
83
85
|
}
|
|
84
86
|
addCategory(category) {
|
|
85
|
-
const categoryIdx = this.categories.push(category) - 1;
|
|
86
|
-
this.records[this.categories[categoryIdx].name] = [];
|
|
87
|
+
const categoryIdx = this._data.categories.push(category) - 1;
|
|
88
|
+
this._data.records[this._data.categories[categoryIdx].name] = [];
|
|
87
89
|
return categoryIdx;
|
|
88
90
|
}
|
|
89
91
|
findCategoryIndex(category) {
|
|
90
|
-
const index = this.categories.findIndex((testCategory) => {
|
|
92
|
+
const index = this._data.categories.findIndex((testCategory) => {
|
|
91
93
|
return testCategory.name === category.name;
|
|
92
94
|
});
|
|
93
95
|
return index;
|
|
94
96
|
}
|
|
95
97
|
findCategoryIndexByName(name) {
|
|
96
|
-
const index = this.categories.findIndex((testCategory) => {
|
|
98
|
+
const index = this._data.categories.findIndex((testCategory) => {
|
|
97
99
|
return testCategory.name === name;
|
|
98
100
|
});
|
|
99
101
|
return index;
|
|
100
102
|
}
|
|
101
103
|
addProperty(propertyRecord, categoryName) {
|
|
102
|
-
const idx = this.records[categoryName].findIndex((prop) => prop.property.name === propertyRecord.property.name);
|
|
104
|
+
const idx = this._data.records[categoryName].findIndex((prop) => prop.property.name === propertyRecord.property.name);
|
|
103
105
|
if (idx === -1) {
|
|
104
|
-
this.records[categoryName].push(propertyRecord);
|
|
106
|
+
this._data.records[categoryName].push(propertyRecord);
|
|
105
107
|
}
|
|
106
108
|
else {
|
|
107
|
-
this.records[categoryName][idx].isMerged = true;
|
|
108
|
-
this.records[categoryName][idx].isReadonly = true;
|
|
109
|
+
this._data.records[categoryName][idx].isMerged = true;
|
|
110
|
+
this._data.records[categoryName][idx].isReadonly = true;
|
|
109
111
|
}
|
|
110
112
|
}
|
|
111
113
|
removeProperty(propertyRecord, categoryIdx) {
|
|
112
|
-
const index = this.records[this.categories[categoryIdx].name].findIndex((record) => {
|
|
114
|
+
const index = this._data.records[this._data.categories[categoryIdx].name].findIndex((record) => {
|
|
113
115
|
return record === propertyRecord;
|
|
114
116
|
});
|
|
115
117
|
let result = false;
|
|
116
118
|
if (index >= 0) {
|
|
117
|
-
this.records[this.categories[categoryIdx].name].splice(index, 1);
|
|
119
|
+
this._data.records[this._data.categories[categoryIdx].name].splice(index, 1);
|
|
118
120
|
this.onDataChanged.raiseEvent();
|
|
119
121
|
result = true;
|
|
120
122
|
}
|
|
121
123
|
return result;
|
|
122
124
|
}
|
|
123
125
|
replaceProperty(propertyRecord, categoryIdx, newRecord) {
|
|
124
|
-
const index = this.records[this.categories[categoryIdx].name].findIndex((record) => {
|
|
126
|
+
const index = this._data.records[this._data.categories[categoryIdx].name].findIndex((record) => {
|
|
125
127
|
return record === propertyRecord;
|
|
126
128
|
});
|
|
127
129
|
let result = false;
|
|
128
|
-
// istanbul ignore else
|
|
129
130
|
if (index >= 0) {
|
|
130
|
-
this.records[this.categories[categoryIdx].name].splice(index, 1, newRecord);
|
|
131
|
+
this._data.records[this._data.categories[categoryIdx].name].splice(index, 1, newRecord);
|
|
131
132
|
result = true;
|
|
132
133
|
}
|
|
133
134
|
return result;
|
|
134
135
|
}
|
|
135
136
|
async getData() {
|
|
136
|
-
return this;
|
|
137
|
+
return this._data;
|
|
137
138
|
}
|
|
138
139
|
}
|
|
139
140
|
exports.FeatureInfoDataProvider = FeatureInfoDataProvider;
|
|
@@ -1 +1 @@
|
|
|
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;QA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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
|
+
{"version":3,"file":"FeatureInfoDataProvider.js","sourceRoot":"","sources":["../../../../src/ui/widget/FeatureInfoDataProvider.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,0DAAuD;AACvD,8DAAyH;AACzH,sDAA8C;AAI9C;;;GAGG;AAEH,IAAY,uBAAsD;AAAlE,WAAY,uBAAuB;IAAG,uFAAa,CAAA;IAAE,mFAAW,CAAA;AAAC,CAAC,EAAtD,uBAAuB,GAAvB,+BAAuB,KAAvB,+BAAuB,QAA+B;AAQlE,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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;AAjID,0DAiIC","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,
|
|
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"}
|
|
@@ -18,6 +18,7 @@ function MapFeatureInfoWidget({ featureInfoOpts }) {
|
|
|
18
18
|
const [loadingData, setLoadingData] = React.useState(false);
|
|
19
19
|
const [hasData, setHasData] = React.useState(false);
|
|
20
20
|
const [noRecordsMessage] = React.useState(mapLayers_1.MapLayersUI.localization.getLocalizedString("mapLayers:FeatureInfoWidget.NoRecords"));
|
|
21
|
+
const [{ width, height }, setSize] = React.useState({ width: 0, height: 0 });
|
|
21
22
|
const handleLoadStateChange = (state) => {
|
|
22
23
|
setLoadingData(state === FeatureInfoDataProvider_1.MapFeatureInfoLoadState.DataLoadStart);
|
|
23
24
|
};
|
|
@@ -52,6 +53,9 @@ function MapFeatureInfoWidget({ featureInfoOpts }) {
|
|
|
52
53
|
}
|
|
53
54
|
return;
|
|
54
55
|
}, [featureInfoOpts === null || featureInfoOpts === void 0 ? void 0 : featureInfoOpts.showLoadProgressAnimation]);
|
|
56
|
+
const handleResize = React.useCallback((w, h) => {
|
|
57
|
+
setSize({ width: w, height: h });
|
|
58
|
+
}, []);
|
|
55
59
|
if (loadingData) {
|
|
56
60
|
return (React.createElement(core_react_1.FillCentered, null,
|
|
57
61
|
React.createElement(itwinui_react_1.ProgressRadial, { indeterminate: true })));
|
|
@@ -63,7 +67,8 @@ function MapFeatureInfoWidget({ featureInfoOpts }) {
|
|
|
63
67
|
}
|
|
64
68
|
else {
|
|
65
69
|
if (dataProvider.current)
|
|
66
|
-
return (React.createElement(
|
|
70
|
+
return (React.createElement(core_react_1.ResizableContainerObserver, { onResize: handleResize },
|
|
71
|
+
React.createElement(components_react_1.VirtualizedPropertyGridWithDataProvider, { width: width, height: height, 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
72
|
else
|
|
68
73
|
return (React.createElement(React.Fragment, null));
|
|
69
74
|
}
|
|
@@ -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,
|
|
1
|
+
{"version":3,"file":"FeatureInfoWidget.js","sourceRoot":"","sources":["../../../../src/ui/widget/FeatureInfoWidget.tsx"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,+BAA+B;AAE/B,8DAAkF;AAClF,kDAA0F;AAE1F,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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E,mBAAmB,0CAAE,0BAA0B,GAAI,CACvE,CAC9B,CAAC;;YAEF,OAAO,CAAC,yCAAK,CAAC,CAAC;KAClB;AACH,CAAC;AApED,oDAoEC","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"]}
|
|
@@ -15,17 +15,12 @@ export interface MapFeatureInfoDataUpdate {
|
|
|
15
15
|
recordCount: number;
|
|
16
16
|
}
|
|
17
17
|
export declare type MapFeatureInfoDataUpdatedListener = (data: MapFeatureInfoDataUpdate) => void;
|
|
18
|
-
export declare class FeatureInfoDataProvider implements IPropertyDataProvider
|
|
18
|
+
export declare class FeatureInfoDataProvider implements IPropertyDataProvider {
|
|
19
19
|
private _removeListener;
|
|
20
|
-
label: PropertyRecord;
|
|
21
|
-
description?: string;
|
|
22
|
-
categories: PropertyCategory[];
|
|
23
|
-
records: {
|
|
24
|
-
[categoryName: string]: PropertyRecord[];
|
|
25
|
-
};
|
|
26
20
|
onDataChanged: PropertyDataChangeEvent;
|
|
27
21
|
onDataLoadStateChanged: BeEvent<MapFeatureInfoLoadListener>;
|
|
28
22
|
onDataUpdated: BeEvent<MapFeatureInfoDataUpdatedListener>;
|
|
23
|
+
private _data;
|
|
29
24
|
constructor(onMapHit: MapHitEvent);
|
|
30
25
|
onUnload(): void;
|
|
31
26
|
private _handleMapHit;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FeatureInfoDataProvider.d.ts","sourceRoot":"","sources":["../../../../src/ui/widget/FeatureInfoDataProvider.ts"],"names":[],"mappings":"AAKA,OAAO,
|
|
1
|
+
{"version":3,"file":"FeatureInfoDataProvider.d.ts","sourceRoot":"","sources":["../../../../src/ui/widget/FeatureInfoDataProvider.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AACzH,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;GAGG;AAEH,oBAAY,uBAAuB;IAAG,aAAa,IAAA;IAAE,WAAW,IAAA;CAAE;AAClE,MAAM,CAAC,OAAO,MAAM,0BAA0B,GAAG,CAAC,KAAK,EAAE,uBAAuB,KAAK,IAAI,CAAC;AAE1F,MAAM,WAAW,wBAAwB;IACvC,WAAW,EAAE,MAAM,CAAC;CACrB;AACD,MAAM,CAAC,OAAO,MAAM,iCAAiC,GAAG,CAAC,IAAI,EAAE,wBAAwB,KAAK,IAAI,CAAC;AASjG,qBAAa,uBAAwB,YAAW,qBAAqB;IACnE,OAAO,CAAC,eAAe,CAAa;IAC7B,aAAa,0BAAiC;IAC9C,sBAAsB,sCAA6C;IACnE,aAAa,6CAAoD;IACxE,OAAO,CAAC,KAAK,CAA4B;gBAC7B,QAAQ,EAAE,WAAW;IAI1B,QAAQ;YAID,aAAa;IAkDpB,cAAc,CAAC,YAAY,EAAE,MAAM;IAGnC,WAAW,CAAC,QAAQ,EAAE,gBAAgB,GAAG,MAAM;IAO/C,iBAAiB,CAAC,QAAQ,EAAE,gBAAgB,GAAG,MAAM;IAMrD,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAO7C,WAAW,CAAC,cAAc,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI;IAUvE,cAAc,CAAC,cAAc,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO;IAe5E,eAAe,CAAC,cAAc,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,GAAG,OAAO;IAclG,OAAO,IAAI,OAAO,CAAC,YAAY,CAAC;CAG9C"}
|
|
@@ -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,15 +14,19 @@ export var MapFeatureInfoLoadState;
|
|
|
15
14
|
MapFeatureInfoLoadState[MapFeatureInfoLoadState["DataLoadStart"] = 0] = "DataLoadStart";
|
|
16
15
|
MapFeatureInfoLoadState[MapFeatureInfoLoadState["DataLoadEnd"] = 1] = "DataLoadEnd";
|
|
17
16
|
})(MapFeatureInfoLoadState || (MapFeatureInfoLoadState = {}));
|
|
18
|
-
|
|
19
|
-
constructor(
|
|
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
|
-
|
|
29
|
+
this._data = new SimplePropertyData();
|
|
27
30
|
this._removeListener = onMapHit.addListener(this._handleMapHit, this);
|
|
28
31
|
}
|
|
29
32
|
onUnload() {
|
|
@@ -31,8 +34,7 @@ export class FeatureInfoDataProvider {
|
|
|
31
34
|
}
|
|
32
35
|
async _handleMapHit(mapHit) {
|
|
33
36
|
var _a, _b;
|
|
34
|
-
this.
|
|
35
|
-
this.categories = [];
|
|
37
|
+
this._data = new SimplePropertyData();
|
|
36
38
|
let recordCount = 0;
|
|
37
39
|
if (mapHit === null || mapHit === void 0 ? void 0 : mapHit.isMapHit) {
|
|
38
40
|
this.onDataLoadStateChanged.raiseEvent(MapFeatureInfoLoadState.DataLoadStart);
|
|
@@ -44,7 +46,7 @@ export class FeatureInfoDataProvider {
|
|
|
44
46
|
let nbRecords = 0;
|
|
45
47
|
const layerCategory = (layerCatIdx === -1 ?
|
|
46
48
|
{ name: curLayerInfo.layerName, label: curLayerInfo.layerName, expand: true, childCategories: [] }
|
|
47
|
-
: this.categories[layerCatIdx]);
|
|
49
|
+
: this._data.categories[layerCatIdx]);
|
|
48
50
|
if (curLayerInfo.info && !(curLayerInfo.info instanceof HTMLElement)) {
|
|
49
51
|
// This is not an HTMLElement, so iterate over each sub-layer info
|
|
50
52
|
for (const subLayerInfo of curLayerInfo.info) {
|
|
@@ -76,61 +78,60 @@ export class FeatureInfoDataProvider {
|
|
|
76
78
|
this.onDataChanged.raiseEvent();
|
|
77
79
|
}
|
|
78
80
|
addSubCategory(categoryName) {
|
|
79
|
-
this.records[categoryName] = [];
|
|
81
|
+
this._data.records[categoryName] = [];
|
|
80
82
|
}
|
|
81
83
|
addCategory(category) {
|
|
82
|
-
const categoryIdx = this.categories.push(category) - 1;
|
|
83
|
-
this.records[this.categories[categoryIdx].name] = [];
|
|
84
|
+
const categoryIdx = this._data.categories.push(category) - 1;
|
|
85
|
+
this._data.records[this._data.categories[categoryIdx].name] = [];
|
|
84
86
|
return categoryIdx;
|
|
85
87
|
}
|
|
86
88
|
findCategoryIndex(category) {
|
|
87
|
-
const index = this.categories.findIndex((testCategory) => {
|
|
89
|
+
const index = this._data.categories.findIndex((testCategory) => {
|
|
88
90
|
return testCategory.name === category.name;
|
|
89
91
|
});
|
|
90
92
|
return index;
|
|
91
93
|
}
|
|
92
94
|
findCategoryIndexByName(name) {
|
|
93
|
-
const index = this.categories.findIndex((testCategory) => {
|
|
95
|
+
const index = this._data.categories.findIndex((testCategory) => {
|
|
94
96
|
return testCategory.name === name;
|
|
95
97
|
});
|
|
96
98
|
return index;
|
|
97
99
|
}
|
|
98
100
|
addProperty(propertyRecord, categoryName) {
|
|
99
|
-
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);
|
|
100
102
|
if (idx === -1) {
|
|
101
|
-
this.records[categoryName].push(propertyRecord);
|
|
103
|
+
this._data.records[categoryName].push(propertyRecord);
|
|
102
104
|
}
|
|
103
105
|
else {
|
|
104
|
-
this.records[categoryName][idx].isMerged = true;
|
|
105
|
-
this.records[categoryName][idx].isReadonly = true;
|
|
106
|
+
this._data.records[categoryName][idx].isMerged = true;
|
|
107
|
+
this._data.records[categoryName][idx].isReadonly = true;
|
|
106
108
|
}
|
|
107
109
|
}
|
|
108
110
|
removeProperty(propertyRecord, categoryIdx) {
|
|
109
|
-
const index = this.records[this.categories[categoryIdx].name].findIndex((record) => {
|
|
111
|
+
const index = this._data.records[this._data.categories[categoryIdx].name].findIndex((record) => {
|
|
110
112
|
return record === propertyRecord;
|
|
111
113
|
});
|
|
112
114
|
let result = false;
|
|
113
115
|
if (index >= 0) {
|
|
114
|
-
this.records[this.categories[categoryIdx].name].splice(index, 1);
|
|
116
|
+
this._data.records[this._data.categories[categoryIdx].name].splice(index, 1);
|
|
115
117
|
this.onDataChanged.raiseEvent();
|
|
116
118
|
result = true;
|
|
117
119
|
}
|
|
118
120
|
return result;
|
|
119
121
|
}
|
|
120
122
|
replaceProperty(propertyRecord, categoryIdx, newRecord) {
|
|
121
|
-
const index = this.records[this.categories[categoryIdx].name].findIndex((record) => {
|
|
123
|
+
const index = this._data.records[this._data.categories[categoryIdx].name].findIndex((record) => {
|
|
122
124
|
return record === propertyRecord;
|
|
123
125
|
});
|
|
124
126
|
let result = false;
|
|
125
|
-
// istanbul ignore else
|
|
126
127
|
if (index >= 0) {
|
|
127
|
-
this.records[this.categories[categoryIdx].name].splice(index, 1, newRecord);
|
|
128
|
+
this._data.records[this._data.categories[categoryIdx].name].splice(index, 1, newRecord);
|
|
128
129
|
result = true;
|
|
129
130
|
}
|
|
130
131
|
return result;
|
|
131
132
|
}
|
|
132
133
|
async getData() {
|
|
133
|
-
return this;
|
|
134
|
+
return this._data;
|
|
134
135
|
}
|
|
135
136
|
}
|
|
136
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,uBAAuB,CAAC;AACxD,OAAO,EAAyD,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AACzH,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAG9C,oGAAoG;AAEpG;;;GAGG;AAEH,MAAM,CAAN,IAAY,uBAAoD;AAAhE,WAAY,uBAAuB;IAAE,uFAAa,CAAA;IAAE,mFAAW,CAAA;AAAA,CAAC,EAApD,uBAAuB,KAAvB,uBAAuB,QAA6B;AAQhE,MAAM,OAAO,uBAAuB;IASlC,YAAY,QAAqB;QAP1B,UAAK,GAAmB,cAAc,CAAC,UAA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AAC,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/widget/FeatureInfoDataProvider.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAyD,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AACzH,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAI9C;;;GAGG;AAEH,MAAM,CAAN,IAAY,uBAAsD;AAAlE,WAAY,uBAAuB;IAAG,uFAAa,CAAA;IAAE,mFAAW,CAAA;AA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E,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,
|
|
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,8 +3,8 @@
|
|
|
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 {
|
|
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";
|
|
@@ -15,6 +15,7 @@ export function MapFeatureInfoWidget({ featureInfoOpts }) {
|
|
|
15
15
|
const [loadingData, setLoadingData] = React.useState(false);
|
|
16
16
|
const [hasData, setHasData] = React.useState(false);
|
|
17
17
|
const [noRecordsMessage] = React.useState(MapLayersUI.localization.getLocalizedString("mapLayers:FeatureInfoWidget.NoRecords"));
|
|
18
|
+
const [{ width, height }, setSize] = React.useState({ width: 0, height: 0 });
|
|
18
19
|
const handleLoadStateChange = (state) => {
|
|
19
20
|
setLoadingData(state === MapFeatureInfoLoadState.DataLoadStart);
|
|
20
21
|
};
|
|
@@ -49,6 +50,9 @@ export function MapFeatureInfoWidget({ featureInfoOpts }) {
|
|
|
49
50
|
}
|
|
50
51
|
return;
|
|
51
52
|
}, [featureInfoOpts === null || featureInfoOpts === void 0 ? void 0 : featureInfoOpts.showLoadProgressAnimation]);
|
|
53
|
+
const handleResize = React.useCallback((w, h) => {
|
|
54
|
+
setSize({ width: w, height: h });
|
|
55
|
+
}, []);
|
|
52
56
|
if (loadingData) {
|
|
53
57
|
return (React.createElement(FillCentered, null,
|
|
54
58
|
React.createElement(ProgressRadial, { indeterminate: true })));
|
|
@@ -60,7 +64,8 @@ export function MapFeatureInfoWidget({ featureInfoOpts }) {
|
|
|
60
64
|
}
|
|
61
65
|
else {
|
|
62
66
|
if (dataProvider.current)
|
|
63
|
-
return (React.createElement(
|
|
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 })));
|
|
64
69
|
else
|
|
65
70
|
return (React.createElement(React.Fragment, null));
|
|
66
71
|
}
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
1
|
+
{"version":3,"file":"FeatureInfoWidget.js","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AC,CAAS,EAAE,CAAS,EAAE,EAAE;QAC9D,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;IACnC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,IAAI,WAAW,EAAE;QACf,OAAO,CAAC,oBAAC,YAAY;YAAC,oBAAC,cAAc,IAAC,aAAa,EAAE,IAAI,GAAmB,CAAe,CAAC,CAAC;KAC9F;SAAM,IAAI,CAAC,OAAO,EAAE;QACnB,OAAO,CAAC,oBAAC,YAAY;YAAC;gBAAM,+BAAI,gBAAgB,CAAK,CAAO,CAAe,CAAC,CAAC;KAC9E;SAAM;QACL,IAAI,YAAY,CAAC,OAAO;YACtB,OAAO,CACL,oBAAC,0BAA0B,IAAC,QAAQ,EAAE,YAAY;gBAChD,oBAAC,uCAAuC,IACtC,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,YAAY,CAAC,OAAO,EAClC,WAAW,EAAE,WAAW,CAAC,QAAQ,EACjC,0BAA0B,EAAE,MAAA,eAAe,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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/map-layers",
|
|
3
|
-
"version": "4.0.0-dev.
|
|
3
|
+
"version": "4.0.0-dev.50",
|
|
4
4
|
"description": "Extension that adds a Map Layers Widget",
|
|
5
5
|
"main": "lib/cjs/map-layers.js",
|
|
6
6
|
"module": "lib/esm/map-layers.js",
|
|
@@ -27,20 +27,20 @@
|
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@itwin/appui-abstract": "^3.7.1",
|
|
30
|
-
"@itwin/appui-layout-react": "^4.0.0-dev.
|
|
31
|
-
"@itwin/appui-react": "^4.0.0-dev.
|
|
30
|
+
"@itwin/appui-layout-react": "^4.0.0-dev.20",
|
|
31
|
+
"@itwin/appui-react": "^4.0.0-dev.20",
|
|
32
32
|
"@itwin/build-tools": "^3.7.1",
|
|
33
|
-
"@itwin/components-react": "^4.0.0-dev.
|
|
33
|
+
"@itwin/components-react": "^4.0.0-dev.20",
|
|
34
34
|
"@itwin/core-bentley": "^3.7.1",
|
|
35
35
|
"@itwin/core-common": "^3.7.1",
|
|
36
36
|
"@itwin/core-frontend": "^3.7.1",
|
|
37
37
|
"@itwin/core-geometry": "^3.7.1",
|
|
38
38
|
"@itwin/core-orbitgt": "^3.7.1",
|
|
39
39
|
"@itwin/core-quantity": "^3.7.1",
|
|
40
|
-
"@itwin/core-react": "^4.0.0-dev.
|
|
40
|
+
"@itwin/core-react": "^4.0.0-dev.20",
|
|
41
41
|
"@itwin/core-telemetry": "^3.7.1",
|
|
42
42
|
"@itwin/eslint-plugin": "^3.7.1",
|
|
43
|
-
"@itwin/imodel-components-react": "^4.0.0-dev.
|
|
43
|
+
"@itwin/imodel-components-react": "^4.0.0-dev.20",
|
|
44
44
|
"@itwin/itwinui-variables": "^2.0.0",
|
|
45
45
|
"@itwin/itwinui-react": "^2.7.0",
|
|
46
46
|
"@itwin/webgl-compatibility": "^3.7.1",
|
|
@@ -79,14 +79,14 @@
|
|
|
79
79
|
},
|
|
80
80
|
"peerDependencies": {
|
|
81
81
|
"@itwin/appui-abstract": "^3.7.1",
|
|
82
|
-
"@itwin/appui-layout-react": "^4.0.0-dev.
|
|
83
|
-
"@itwin/appui-react": "^4.0.0-dev.
|
|
84
|
-
"@itwin/components-react": "^4.0.0-dev.
|
|
82
|
+
"@itwin/appui-layout-react": "^4.0.0-dev.20",
|
|
83
|
+
"@itwin/appui-react": "^4.0.0-dev.20",
|
|
84
|
+
"@itwin/components-react": "^4.0.0-dev.20",
|
|
85
85
|
"@itwin/core-bentley": "^3.7.1",
|
|
86
86
|
"@itwin/core-common": "^3.7.1",
|
|
87
87
|
"@itwin/core-frontend": "^3.7.1",
|
|
88
|
-
"@itwin/core-react": "^4.0.0-dev.
|
|
89
|
-
"@itwin/imodel-components-react": "^4.0.0-dev.
|
|
88
|
+
"@itwin/core-react": "^4.0.0-dev.20",
|
|
89
|
+
"@itwin/imodel-components-react": "^4.0.0-dev.20",
|
|
90
90
|
"react": "^17.0.0",
|
|
91
91
|
"react-dom": "^17.0.0"
|
|
92
92
|
},
|