@itwin/map-layers 5.0.0-dev.3 → 5.0.0

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 (60) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/lib/cjs/MapLayerPreferences.js +1 -1
  3. package/lib/cjs/MapLayerPreferences.js.map +1 -1
  4. package/lib/cjs/MapLayersPrefBrowserStorage.d.ts +5 -0
  5. package/lib/cjs/MapLayersPrefBrowserStorage.d.ts.map +1 -0
  6. package/lib/cjs/MapLayersPrefBrowserStorage.js +16 -0
  7. package/lib/cjs/MapLayersPrefBrowserStorage.js.map +1 -0
  8. package/lib/cjs/PreferencesBrowserStorage.d.ts +36 -0
  9. package/lib/cjs/PreferencesBrowserStorage.d.ts.map +1 -0
  10. package/lib/cjs/PreferencesBrowserStorage.js +92 -0
  11. package/lib/cjs/PreferencesBrowserStorage.js.map +1 -0
  12. package/lib/cjs/map-layers.d.ts +1 -0
  13. package/lib/cjs/map-layers.d.ts.map +1 -1
  14. package/lib/cjs/map-layers.js +1 -0
  15. package/lib/cjs/map-layers.js.map +1 -1
  16. package/lib/cjs/ui/widget/MapLayerDroppable.d.ts.map +1 -1
  17. package/lib/cjs/ui/widget/MapLayerDroppable.js +6 -1
  18. package/lib/cjs/ui/widget/MapLayerDroppable.js.map +1 -1
  19. package/lib/cjs/ui/widget/SubLayersDataProvider.d.ts +1 -3
  20. package/lib/cjs/ui/widget/SubLayersDataProvider.d.ts.map +1 -1
  21. package/lib/cjs/ui/widget/SubLayersDataProvider.js +2 -3
  22. package/lib/cjs/ui/widget/SubLayersDataProvider.js.map +1 -1
  23. package/lib/cjs/ui/widget/SubLayersPopupButton.d.ts +3 -7
  24. package/lib/cjs/ui/widget/SubLayersPopupButton.d.ts.map +1 -1
  25. package/lib/cjs/ui/widget/SubLayersPopupButton.js +2 -2
  26. package/lib/cjs/ui/widget/SubLayersPopupButton.js.map +1 -1
  27. package/lib/cjs/ui/widget/SubLayersTree.d.ts +12 -9
  28. package/lib/cjs/ui/widget/SubLayersTree.d.ts.map +1 -1
  29. package/lib/cjs/ui/widget/SubLayersTree.js +50 -79
  30. package/lib/cjs/ui/widget/SubLayersTree.js.map +1 -1
  31. package/lib/esm/MapLayerPreferences.js +1 -1
  32. package/lib/esm/MapLayerPreferences.js.map +1 -1
  33. package/lib/esm/MapLayersPrefBrowserStorage.d.ts +5 -0
  34. package/lib/esm/MapLayersPrefBrowserStorage.d.ts.map +1 -0
  35. package/lib/esm/MapLayersPrefBrowserStorage.js +12 -0
  36. package/lib/esm/MapLayersPrefBrowserStorage.js.map +1 -0
  37. package/lib/esm/PreferencesBrowserStorage.d.ts +36 -0
  38. package/lib/esm/PreferencesBrowserStorage.d.ts.map +1 -0
  39. package/lib/esm/PreferencesBrowserStorage.js +88 -0
  40. package/lib/esm/PreferencesBrowserStorage.js.map +1 -0
  41. package/lib/esm/map-layers.d.ts +1 -0
  42. package/lib/esm/map-layers.d.ts.map +1 -1
  43. package/lib/esm/map-layers.js +1 -0
  44. package/lib/esm/map-layers.js.map +1 -1
  45. package/lib/esm/ui/widget/MapLayerDroppable.d.ts.map +1 -1
  46. package/lib/esm/ui/widget/MapLayerDroppable.js +6 -1
  47. package/lib/esm/ui/widget/MapLayerDroppable.js.map +1 -1
  48. package/lib/esm/ui/widget/SubLayersDataProvider.d.ts +1 -3
  49. package/lib/esm/ui/widget/SubLayersDataProvider.d.ts.map +1 -1
  50. package/lib/esm/ui/widget/SubLayersDataProvider.js +2 -3
  51. package/lib/esm/ui/widget/SubLayersDataProvider.js.map +1 -1
  52. package/lib/esm/ui/widget/SubLayersPopupButton.d.ts +3 -7
  53. package/lib/esm/ui/widget/SubLayersPopupButton.d.ts.map +1 -1
  54. package/lib/esm/ui/widget/SubLayersPopupButton.js +2 -2
  55. package/lib/esm/ui/widget/SubLayersPopupButton.js.map +1 -1
  56. package/lib/esm/ui/widget/SubLayersTree.d.ts +12 -9
  57. package/lib/esm/ui/widget/SubLayersTree.d.ts.map +1 -1
  58. package/lib/esm/ui/widget/SubLayersTree.js +50 -79
  59. package/lib/esm/ui/widget/SubLayersTree.js.map +1 -1
  60. package/package.json +21 -21
package/CHANGELOG.md CHANGED
@@ -1,6 +1,14 @@
1
1
  # Change Log - @itwin/map-layers
2
2
 
3
- This log was last generated on Thu, 04 May 2023 23:59:19 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 06 Jun 2023 10:57:06 GMT and should not be manually modified.
4
+
5
+ ## 5.0.0
6
+ Tue, 06 Jun 2023 10:57:06 GMT
7
+
8
+ ### Patches
9
+
10
+ - Fix an issue with MapLayerPreferences that would not save with the proper key with replacing an existing source. Also also added MapLayersPrefBrowserStorage as a simple/testing implementation of UserPreferencesAccess.
11
+ - Refactored SubLayers tree panel and made it independent from viewport
4
12
 
5
13
  ## 4.0.0
6
14
  Thu, 04 May 2023 23:59:19 GMT
@@ -98,7 +98,7 @@ class MapLayerPreferences {
98
98
  await mapLayers_1.MapLayersUI.iTwinConfig.save({
99
99
  accessToken,
100
100
  namespace: MapLayerPreferences._preferenceNamespace,
101
- key: `${MapLayerPreferences._preferenceNamespace}.${newSource.name}`,
101
+ key: newSource.name,
102
102
  iTwinId,
103
103
  iModelId: storeOnIModel ? iModelId : undefined,
104
104
  content: mapLayerSetting,
@@ -1 +1 @@
1
- {"version":3,"file":"MapLayerPreferences.js","sourceRoot":"","sources":["../../src/MapLayerPreferences.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,wDAA8G;AAC9G,sDAA0D;AAC1D,2CAA0C;AAU1C,gBAAgB;AAChB,IAAY,wBAIX;AAJD,WAAY,wBAAwB;IAClC,yEAAS,CAAA;IACT,6EAAW,CAAA;IACX,+EAAY,CAAA;AACd,CAAC,EAJW,wBAAwB,GAAxB,gCAAwB,KAAxB,gCAAwB,QAInC;AASD;;;;;GAKG;AACH,MAAa,mBAAmB;IAU9B;;;;;;OAMG;IACI,MAAM,CAAC,KAAK,CAAC,WAAW,C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AE,EAAE,YAAY,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;SACtI;QAED,IAAI;YACF,MAAM,kBAAkB,GAAG,MAAM,uBAAW,CAAC,WAAW,CAAC,GAAG,CAAC;gBAC3D,WAAW;gBACX,SAAS,EAAE,mBAAmB,CAAC,oBAAoB;gBACnD,GAAG,EAAE,EAAE;gBACP,OAAO;gBACP,QAAQ;aACT,CAAC,CAAC;YACH,IAAI,SAAS,KAAK,kBAAkB;gBAClC,YAAY,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;SACzC;QAAC,OAAO,GAAQ,EAAE;YACjB,MAAM,IAAI,KAAK,CAAC,yBAAS,CAAC,YAAY,CAAC,kBAAkB,CAAC,iDAAiD,EAAE,EAAE,YAAY,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;SACtI;QAED,MAAM,oBAAoB,GAAqB,EAAE,CAAC;QAClD,KAAK,MAAM,QAAQ,IAAI,YAAY,EAAE;YACnC,QAAQ,CAAC,OAAO,CAAC,CAAC,UAAe,EAAE,EAAE;gBACnC,MAAM,cAAc,GAAG,8BAAc,CAAC,QAAQ,CAAC,UAAwC,CAAC,CAAC;gBACzF,IAAI,cAAc;oBAChB,oBAAoB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;YAC9C,CAAC,CAAC,CAAC;SACJ;QACD,OAAO,oBAAoB,CAAC;IAC9B,CAAC;IAEO,MAAM,KAAK,oBAAoB;QACrC,OAAO,gCAAgC,CAAC;IAC1C,CAAC;;AAjTH,kDAkTC;AAjTC;;;;;;GAMG;AACoB,wCAAoB,GAAG,IAAI,sBAAO,EAA0G,CAAC,CAAC,mFAAmF","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 { IModelApp, MapLayerSource, NotifyMessageDetails, OutputMessagePriority } from \"@itwin/core-frontend\";\nimport { BeEvent, GuidString } from \"@itwin/core-bentley\";\nimport { MapLayersUI } from \"./mapLayers\";\n\n/** @internal */\nexport interface MapLayerPreferencesContent {\n url: string;\n name: string;\n formatId: string;\n transparentBackground: boolean | undefined;\n}\n\n/** @internal */\nexport enum MapLayerSourceChangeType {\n Added = 0,\n Removed = 1,\n Replaced = 2,\n}\n\n/** @internal */\nexport interface MapLayerSourceArg {\n readonly source: MapLayerSource;\n readonly iTwinId: GuidString;\n readonly iModelId: GuidString;\n}\n\n/** A wrapper around user preferences to provide a way to store [[MapLayerSettings]].\n *\n * Note: This is currently internal only and used directly by the MapLayersExtension. It makes use of the IModelApp.authorizationClient if it exists.\n *\n * @internal\n */\nexport class MapLayerPreferences {\n /** Event raised whenever a source is added, replaced or removed:\n * changeType : Type of changed occurred.\n * oldSource : Source that was removed or replaced.\n * newSource : Source that was added or replacement of oldSource.\n *\n * @see [[MapLayerSourceChangeType]]\n */\n public static readonly onLayerSourceChanged = new BeEvent<(changeType: MapLayerSourceChangeType, oldSource?: MapLayerSource, newSource?: MapLayerSource) => void>(); // Used to notify the frontend that it needs to update its list of available layers\n\n /** Store the Map Layer source preference. If the same setting exists at a higher level, an error will be thrown and the setting will not be updated.\n *\n * Returns false if the settings object would override some other settings object in a larger scope i.e. storing settings on model when\n * a project setting exists with same name or map layer url.\n * @param source source to be stored on the setting service\n * @param storeOnIModel if true store the settings object on the model, if false store it on the project\n */\n public static async storeSource(source: MapLayerSource, iTwinId: GuidString, iModelId?: GuidString, storeOnIModel?: boolean): Promise<boolean> {\n if (!MapLayersUI.iTwinConfig)\n return false;\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\n\n const sourceJSON = source.toJSON();\n const mapLayerSetting: MapLayerPreferencesContent = {\n url: sourceJSON.url,\n name: sourceJSON.name,\n formatId: sourceJSON.formatId,\n transparentBackground: sourceJSON.transparentBackground,\n };\n\n const result: boolean = await MapLayerPreferences.delete(sourceJSON.url, sourceJSON.name, iTwinId, iModelId, storeOnIModel);\n if (result) {\n await MapLayersUI.iTwinConfig.save({\n accessToken,\n content: mapLayerSetting,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: sourceJSON.name,\n iTwinId,\n iModelId: storeOnIModel ? iModelId : undefined,\n });\n MapLayerPreferences.onLayerSourceChanged.raiseEvent(MapLayerSourceChangeType.Added, undefined, MapLayerSource.fromJSON(mapLayerSetting));\n return true;\n } else {\n return false;\n }\n }\n\n /** Replace the old map layer source with a new map layer source.\n *\n * The source is replaced at the same level that the original source is defined. (i.e. if the old source is defined at a project level, the new source will also be defined there.)\n *\n * @param oldSource\n * @param newSource\n * @param iTwinId\n * @param iModelId\n */\n public static async replaceSource(oldSource: MapLayerSource, newSource: MapLayerSource, iTwinId: GuidString, iModelId?: GuidString): Promise<void> {\n if (!MapLayersUI.iTwinConfig)\n return;\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\n\n let storeOnIModel = false;\n try {\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: oldSource.name,\n iTwinId,\n iModelId,\n });\n } catch (_err) {\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: oldSource.name,\n iTwinId,\n });\n storeOnIModel = true;\n }\n\n const mapLayerSetting: MapLayerPreferencesContent = {\n url: newSource.url,\n name: newSource.name,\n formatId: newSource.formatId,\n transparentBackground: newSource.transparentBackground,\n };\n\n await MapLayersUI.iTwinConfig.save({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: `${MapLayerPreferences._preferenceNamespace}.${newSource.name}`,\n iTwinId,\n iModelId: storeOnIModel ? iModelId : undefined,\n content: mapLayerSetting,\n });\n\n MapLayerPreferences.onLayerSourceChanged.raiseEvent(MapLayerSourceChangeType.Replaced, oldSource, newSource);\n }\n\n /** Deletes the provided MapLayerSource by name from both the iTwin or iModel level.\n *\n * @param source The source to delete. The name is used to identify the source.\n * @param iTwinId\n * @param iModelId\n */\n public static async deleteByName(source: MapLayerSource, iTwinId: GuidString, iModelId?: GuidString): Promise<void> {\n if (!MapLayersUI.iTwinConfig)\n return;\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\n\n try {\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: source.name,\n iTwinId,\n iModelId,\n });\n } catch (_err) {\n // failed to store based on iModelId, attempt using iTwinId\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: source.name,\n iTwinId,\n });\n }\n\n MapLayerPreferences.onLayerSourceChanged.raiseEvent(MapLayerSourceChangeType.Removed, source, undefined);\n }\n\n /** Deletes the current setting with the provided key if it is defined at the same preference level.\n *\n * If the preference is defined within a different level, false will be returned indicating the setting should not be overriden.\n *\n * The two potential preference levels are iTwin and iModel.\n *\n * @param url\n * @param name\n * @param iTwinId\n * @param iModelId\n * @param storeOnIModel\n */\n private static async delete(url: string, name: string, iTwinId: GuidString, iModelId?: GuidString, storeOnIModel?: boolean): Promise<boolean> {\n if (!MapLayersUI.iTwinConfig)\n return true;\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\n\n const iTwinPreferenceByName = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: name,\n iTwinId,\n });\n\n if (undefined !== iTwinPreferenceByName && storeOnIModel) {\n const errorMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerExistsAsProjectSetting\", { layer: iTwinPreferenceByName.name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Error, errorMessage));\n return false;\n } else if (iTwinPreferenceByName) {\n const infoMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerExistsOverwriting\", { layer: iTwinPreferenceByName.name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, infoMessage));\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: iTwinPreferenceByName.name,\n iTwinId,\n });\n }\n\n // check if setting with url already exists, if it does, delete it\n const settingFromUrl = await MapLayerPreferences.getByUrl(url, iTwinId, undefined);\n if (settingFromUrl && storeOnIModel) {\n const errorMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerWithUrlExistsAsProjectSetting\", { url: settingFromUrl.url, name: settingFromUrl.name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Error, errorMessage));\n return false;\n } else if (settingFromUrl) {\n const infoMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerWithUrlExistsOverwriting\", { url: settingFromUrl.url, oldName: settingFromUrl.name, newName: name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, infoMessage));\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: settingFromUrl.name,\n iTwinId,\n });\n }\n\n if (iModelId) { // delete any settings on model so user can update them if theres collisions\n const settingOnIModelFromName = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: name,\n iTwinId,\n iModelId,\n });\n const settingFromUrlOnIModel = await MapLayerPreferences.getByUrl(url, iTwinId, iModelId);\n if (settingOnIModelFromName) {\n const infoMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerExistsOverwriting\", { layer: settingOnIModelFromName.name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, infoMessage));\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: settingOnIModelFromName.name,\n iTwinId,\n iModelId,\n });\n }\n if (settingFromUrlOnIModel) {\n const infoMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerWithUrlExistsOverwriting\", { url: settingFromUrlOnIModel.url, oldName: settingFromUrlOnIModel.name, newName: name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, infoMessage));\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: settingFromUrlOnIModel.name,\n iTwinId,\n iModelId,\n });\n }\n }\n return true;\n }\n\n /** Attempts to get a map layer based off a specific url.\n * @param url\n * @param iTwinId\n * @param iModelId\n */\n public static async getByUrl(url: string, iTwinId: string, iModelId?: string): Promise<MapLayerPreferencesContent | undefined> {\n if (!MapLayersUI.iTwinConfig)\n return undefined;\n\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\n\n const settingResponse = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: \"\",\n iTwinId,\n iModelId,\n });\n\n if (undefined === settingResponse || 0 === settingResponse.length)\n return undefined;\n\n let savedMapLayer;\n settingResponse.settingsMap?.forEach((savedLayer: any) => {\n if (savedLayer.url === url) {\n savedMapLayer = savedLayer;\n }\n });\n return savedMapLayer;\n }\n\n /** Get all MapLayerSources from the user's preferences, iTwin setting and iModel settings.\n * @param iTwinId id of the iTwin\n * @param iModelId id of the iModel\n * @throws if any of the calls to grab settings fail.\n */\n public static async getSources(iTwinId: GuidString, iModelId?: GuidString): Promise<MapLayerSource[]> {\n if (!MapLayersUI.iTwinConfig)\n return [];\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\n\n const mapLayerList = [];\n\n try {\n const userResultByProject = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: \"\",\n iTwinId,\n });\n if (undefined !== userResultByProject)\n mapLayerList.push(userResultByProject);\n } catch (err: any) {\n throw new Error(IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.ErrorRetrieveUserProject\", { errorMessage: err }));\n }\n\n try {\n const userResultByIModel = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: \"\",\n iTwinId,\n iModelId,\n });\n if (undefined !== userResultByIModel)\n mapLayerList.push(userResultByIModel);\n } catch (err: any) {\n throw new Error(IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.ErrorRetrieveUserProject\", { errorMessage: err }));\n }\n\n const savedMapLayerSources: MapLayerSource[] = [];\n for (const mapLayer of mapLayerList) {\n mapLayer.forEach((savedLayer: any) => {\n const mapLayerSource = MapLayerSource.fromJSON(savedLayer as MapLayerPreferencesContent);\n if (mapLayerSource)\n savedMapLayerSources.push(mapLayerSource);\n });\n }\n return savedMapLayerSources;\n }\n\n private static get _preferenceNamespace() {\n return \"MapLayerSource-SettingsService\";\n }\n}\n"]}
1
+ {"version":3,"file":"MapLayerPreferences.js","sourceRoot":"","sources":["../../src/MapLayerPreferences.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,wDAA8G;AAC9G,sDAA0D;AAC1D,2CAA0C;AAU1C,gBAAgB;AAChB,IAAY,wBAIX;AAJD,WAAY,wBAAwB;IAClC,yEAAS,CAAA;IACT,6EAAW,CAAA;IACX,+EAAY,CAAA;AACd,CAAC,EAJW,wBAAwB,GAAxB,gCAAwB,KAAxB,gCAAwB,QAInC;AASD;;;;;GAKG;AACH,MAAa,mBAAmB;IAU9B;;;;;;OAMG;IACI,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,MAAsB,EAAE,OAAmB,EAAE,QAAqB,EAAE,aAAuB;QACzH,IAAI,CAAC,uBAAW,CAAC,WAAW;YAC1B,OAAO,KAAK,CAAC;QACf,MAAM,WAAW,GAAG,SAAS,KAAK,yBAAS,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,MAAM,yBAAS,CAAC,mBA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;YACH,IAAI,SAAS,KAAK,kBAAkB;gBAClC,YAAY,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;SACzC;QAAC,OAAO,GAAQ,EAAE;YACjB,MAAM,IAAI,KAAK,CAAC,yBAAS,CAAC,YAAY,CAAC,kBAAkB,CAAC,iDAAiD,EAAE,EAAE,YAAY,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;SACtI;QAED,MAAM,oBAAoB,GAAqB,EAAE,CAAC;QAClD,KAAK,MAAM,QAAQ,IAAI,YAAY,EAAE;YACnC,QAAQ,CAAC,OAAO,CAAC,CAAC,UAAe,EAAE,EAAE;gBACnC,MAAM,cAAc,GAAG,8BAAc,CAAC,QAAQ,CAAC,UAAwC,CAAC,CAAC;gBACzF,IAAI,cAAc;oBAChB,oBAAoB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;YAC9C,CAAC,CAAC,CAAC;SACJ;QACD,OAAO,oBAAoB,CAAC;IAC9B,CAAC;IAEO,MAAM,KAAK,oBAAoB;QACrC,OAAO,gCAAgC,CAAC;IAC1C,CAAC;;AAjTH,kDAkTC;AAjTC;;;;;;GAMG;AACoB,wCAAoB,GAAG,IAAI,sBAAO,EAA0G,CAAC,CAAC,mFAAmF","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 { IModelApp, MapLayerSource, NotifyMessageDetails, OutputMessagePriority } from \"@itwin/core-frontend\";\nimport { BeEvent, GuidString } from \"@itwin/core-bentley\";\nimport { MapLayersUI } from \"./mapLayers\";\n\n/** @internal */\nexport interface MapLayerPreferencesContent {\n url: string;\n name: string;\n formatId: string;\n transparentBackground: boolean | undefined;\n}\n\n/** @internal */\nexport enum MapLayerSourceChangeType {\n Added = 0,\n Removed = 1,\n Replaced = 2,\n}\n\n/** @internal */\nexport interface MapLayerSourceArg {\n readonly source: MapLayerSource;\n readonly iTwinId: GuidString;\n readonly iModelId: GuidString;\n}\n\n/** A wrapper around user preferences to provide a way to store [[MapLayerSettings]].\n *\n * Note: This is currently internal only and used directly by the MapLayersExtension. It makes use of the IModelApp.authorizationClient if it exists.\n *\n * @internal\n */\nexport class MapLayerPreferences {\n /** Event raised whenever a source is added, replaced or removed:\n * changeType : Type of changed occurred.\n * oldSource : Source that was removed or replaced.\n * newSource : Source that was added or replacement of oldSource.\n *\n * @see [[MapLayerSourceChangeType]]\n */\n public static readonly onLayerSourceChanged = new BeEvent<(changeType: MapLayerSourceChangeType, oldSource?: MapLayerSource, newSource?: MapLayerSource) => void>(); // Used to notify the frontend that it needs to update its list of available layers\n\n /** Store the Map Layer source preference. If the same setting exists at a higher level, an error will be thrown and the setting will not be updated.\n *\n * Returns false if the settings object would override some other settings object in a larger scope i.e. storing settings on model when\n * a project setting exists with same name or map layer url.\n * @param source source to be stored on the setting service\n * @param storeOnIModel if true store the settings object on the model, if false store it on the project\n */\n public static async storeSource(source: MapLayerSource, iTwinId: GuidString, iModelId?: GuidString, storeOnIModel?: boolean): Promise<boolean> {\n if (!MapLayersUI.iTwinConfig)\n return false;\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\n\n const sourceJSON = source.toJSON();\n const mapLayerSetting: MapLayerPreferencesContent = {\n url: sourceJSON.url,\n name: sourceJSON.name,\n formatId: sourceJSON.formatId,\n transparentBackground: sourceJSON.transparentBackground,\n };\n\n const result: boolean = await MapLayerPreferences.delete(sourceJSON.url, sourceJSON.name, iTwinId, iModelId, storeOnIModel);\n if (result) {\n await MapLayersUI.iTwinConfig.save({\n accessToken,\n content: mapLayerSetting,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: sourceJSON.name,\n iTwinId,\n iModelId: storeOnIModel ? iModelId : undefined,\n });\n MapLayerPreferences.onLayerSourceChanged.raiseEvent(MapLayerSourceChangeType.Added, undefined, MapLayerSource.fromJSON(mapLayerSetting));\n return true;\n } else {\n return false;\n }\n }\n\n /** Replace the old map layer source with a new map layer source.\n *\n * The source is replaced at the same level that the original source is defined. (i.e. if the old source is defined at a project level, the new source will also be defined there.)\n *\n * @param oldSource\n * @param newSource\n * @param iTwinId\n * @param iModelId\n */\n public static async replaceSource(oldSource: MapLayerSource, newSource: MapLayerSource, iTwinId: GuidString, iModelId?: GuidString): Promise<void> {\n if (!MapLayersUI.iTwinConfig)\n return;\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\n\n let storeOnIModel = false;\n try {\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: oldSource.name,\n iTwinId,\n iModelId,\n });\n } catch (_err) {\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: oldSource.name,\n iTwinId,\n });\n storeOnIModel = true;\n }\n\n const mapLayerSetting: MapLayerPreferencesContent = {\n url: newSource.url,\n name: newSource.name,\n formatId: newSource.formatId,\n transparentBackground: newSource.transparentBackground,\n };\n\n await MapLayersUI.iTwinConfig.save({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: newSource.name,\n iTwinId,\n iModelId: storeOnIModel ? iModelId : undefined,\n content: mapLayerSetting,\n });\n\n MapLayerPreferences.onLayerSourceChanged.raiseEvent(MapLayerSourceChangeType.Replaced, oldSource, newSource);\n }\n\n /** Deletes the provided MapLayerSource by name from both the iTwin or iModel level.\n *\n * @param source The source to delete. The name is used to identify the source.\n * @param iTwinId\n * @param iModelId\n */\n public static async deleteByName(source: MapLayerSource, iTwinId: GuidString, iModelId?: GuidString): Promise<void> {\n if (!MapLayersUI.iTwinConfig)\n return;\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\n\n try {\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: source.name,\n iTwinId,\n iModelId,\n });\n } catch (_err) {\n // failed to store based on iModelId, attempt using iTwinId\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: source.name,\n iTwinId,\n });\n }\n\n MapLayerPreferences.onLayerSourceChanged.raiseEvent(MapLayerSourceChangeType.Removed, source, undefined);\n }\n\n /** Deletes the current setting with the provided key if it is defined at the same preference level.\n *\n * If the preference is defined within a different level, false will be returned indicating the setting should not be overriden.\n *\n * The two potential preference levels are iTwin and iModel.\n *\n * @param url\n * @param name\n * @param iTwinId\n * @param iModelId\n * @param storeOnIModel\n */\n private static async delete(url: string, name: string, iTwinId: GuidString, iModelId?: GuidString, storeOnIModel?: boolean): Promise<boolean> {\n if (!MapLayersUI.iTwinConfig)\n return true;\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\n\n const iTwinPreferenceByName = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: name,\n iTwinId,\n });\n\n if (undefined !== iTwinPreferenceByName && storeOnIModel) {\n const errorMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerExistsAsProjectSetting\", { layer: iTwinPreferenceByName.name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Error, errorMessage));\n return false;\n } else if (iTwinPreferenceByName) {\n const infoMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerExistsOverwriting\", { layer: iTwinPreferenceByName.name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, infoMessage));\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: iTwinPreferenceByName.name,\n iTwinId,\n });\n }\n\n // check if setting with url already exists, if it does, delete it\n const settingFromUrl = await MapLayerPreferences.getByUrl(url, iTwinId, undefined);\n if (settingFromUrl && storeOnIModel) {\n const errorMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerWithUrlExistsAsProjectSetting\", { url: settingFromUrl.url, name: settingFromUrl.name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Error, errorMessage));\n return false;\n } else if (settingFromUrl) {\n const infoMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerWithUrlExistsOverwriting\", { url: settingFromUrl.url, oldName: settingFromUrl.name, newName: name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, infoMessage));\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: settingFromUrl.name,\n iTwinId,\n });\n }\n\n if (iModelId) { // delete any settings on model so user can update them if theres collisions\n const settingOnIModelFromName = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: name,\n iTwinId,\n iModelId,\n });\n const settingFromUrlOnIModel = await MapLayerPreferences.getByUrl(url, iTwinId, iModelId);\n if (settingOnIModelFromName) {\n const infoMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerExistsOverwriting\", { layer: settingOnIModelFromName.name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, infoMessage));\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: settingOnIModelFromName.name,\n iTwinId,\n iModelId,\n });\n }\n if (settingFromUrlOnIModel) {\n const infoMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerWithUrlExistsOverwriting\", { url: settingFromUrlOnIModel.url, oldName: settingFromUrlOnIModel.name, newName: name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, infoMessage));\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: settingFromUrlOnIModel.name,\n iTwinId,\n iModelId,\n });\n }\n }\n return true;\n }\n\n /** Attempts to get a map layer based off a specific url.\n * @param url\n * @param iTwinId\n * @param iModelId\n */\n public static async getByUrl(url: string, iTwinId: string, iModelId?: string): Promise<MapLayerPreferencesContent | undefined> {\n if (!MapLayersUI.iTwinConfig)\n return undefined;\n\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\n\n const settingResponse = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: \"\",\n iTwinId,\n iModelId,\n });\n\n if (undefined === settingResponse || 0 === settingResponse.length)\n return undefined;\n\n let savedMapLayer;\n settingResponse.settingsMap?.forEach((savedLayer: any) => {\n if (savedLayer.url === url) {\n savedMapLayer = savedLayer;\n }\n });\n return savedMapLayer;\n }\n\n /** Get all MapLayerSources from the user's preferences, iTwin setting and iModel settings.\n * @param iTwinId id of the iTwin\n * @param iModelId id of the iModel\n * @throws if any of the calls to grab settings fail.\n */\n public static async getSources(iTwinId: GuidString, iModelId?: GuidString): Promise<MapLayerSource[]> {\n if (!MapLayersUI.iTwinConfig)\n return [];\n const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;\n\n const mapLayerList = [];\n\n try {\n const userResultByProject = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: \"\",\n iTwinId,\n });\n if (undefined !== userResultByProject)\n mapLayerList.push(userResultByProject);\n } catch (err: any) {\n throw new Error(IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.ErrorRetrieveUserProject\", { errorMessage: err }));\n }\n\n try {\n const userResultByIModel = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: \"\",\n iTwinId,\n iModelId,\n });\n if (undefined !== userResultByIModel)\n mapLayerList.push(userResultByIModel);\n } catch (err: any) {\n throw new Error(IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.ErrorRetrieveUserProject\", { errorMessage: err }));\n }\n\n const savedMapLayerSources: MapLayerSource[] = [];\n for (const mapLayer of mapLayerList) {\n mapLayer.forEach((savedLayer: any) => {\n const mapLayerSource = MapLayerSource.fromJSON(savedLayer as MapLayerPreferencesContent);\n if (mapLayerSource)\n savedMapLayerSources.push(mapLayerSource);\n });\n }\n return savedMapLayerSources;\n }\n\n private static get _preferenceNamespace() {\n return \"MapLayerSource-SettingsService\";\n }\n}\n"]}
@@ -0,0 +1,5 @@
1
+ import { PreferencesBrowserStorage } from "./PreferencesBrowserStorage";
2
+ export declare class MapLayersPrefBrowserStorage extends PreferencesBrowserStorage {
3
+ constructor();
4
+ }
5
+ //# sourceMappingURL=MapLayersPrefBrowserStorage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MapLayersPrefBrowserStorage.d.ts","sourceRoot":"","sources":["../../src/MapLayersPrefBrowserStorage.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAExE,qBAAa,2BAA4B,SAAQ,yBAAyB;;CAMzE"}
@@ -0,0 +1,16 @@
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.MapLayersPrefBrowserStorage = void 0;
8
+ const PreferencesBrowserStorage_1 = require("./PreferencesBrowserStorage");
9
+ class MapLayersPrefBrowserStorage extends PreferencesBrowserStorage_1.PreferencesBrowserStorage {
10
+ constructor() {
11
+ super("itwinjs.mapLayers", { throwOnDeleteMissingKey: true } // 'MapLayerPreferences.replaceSource' expect 'delete' to throw when there is no match for the provided key.
12
+ );
13
+ }
14
+ }
15
+ exports.MapLayersPrefBrowserStorage = MapLayersPrefBrowserStorage;
16
+ //# sourceMappingURL=MapLayersPrefBrowserStorage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MapLayersPrefBrowserStorage.js","sourceRoot":"","sources":["../../src/MapLayersPrefBrowserStorage.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,2EAAwE;AAExE,MAAa,2BAA4B,SAAQ,qDAAyB;IACxE;QACE,KAAK,CAAC,mBAAmB,EACvB,EAAE,uBAAuB,EAAE,IAAI,EAAE,CAAG,4GAA4G;SACjJ,CAAC;IACJ,CAAC;CACF;AAND,kEAMC","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 { PreferencesBrowserStorage } from \"./PreferencesBrowserStorage\";\n\nexport class MapLayersPrefBrowserStorage extends PreferencesBrowserStorage {\n constructor() {\n super(\"itwinjs.mapLayers\",\n { throwOnDeleteMissingKey: true } // 'MapLayerPreferences.replaceSource' expect 'delete' to throw when there is no match for the provided key.\n );\n }\n}\n"]}
@@ -0,0 +1,36 @@
1
+ import { ITwinIdArg, PreferenceArg, PreferenceKeyArg, UserPreferencesAccess } from "@itwin/core-frontend";
2
+ /**
3
+ * @beta
4
+ */
5
+ export interface PreferencesBrowserStorageOptions {
6
+ /** indicate whether or not delete function should throw an error if the provided key cannot be found. */
7
+ throwOnDeleteMissingKey?: boolean;
8
+ }
9
+ /** User preferences implementation using browser's local storage.
10
+ * It creates storage item key in the form of:
11
+ * <storageItemKeyPrefix>.<itwin_guid?>.<imodel_guid?>
12
+ *
13
+ * <itwin_guid> and <imodel_guid> being optional.
14
+ *
15
+ * Each entry in the storage is a serialized JSON of the following index signature:
16
+ * {
17
+ * "<preference_namespace?>.<preference_key>": {
18
+ * ...
19
+ * <preferences_json_content>
20
+ * },
21
+ * ...
22
+ * }
23
+ * @beta
24
+ */
25
+ export declare class PreferencesBrowserStorage implements UserPreferencesAccess {
26
+ private readonly _options;
27
+ private readonly _storageItemKeyPrefix;
28
+ constructor(storageItemKeyPrefix: string, opts?: PreferencesBrowserStorageOptions);
29
+ private getStorageItemKey;
30
+ private static getPreferenceKey;
31
+ private loadFromStorage;
32
+ get(arg: PreferenceKeyArg & ITwinIdArg): Promise<any[] | undefined>;
33
+ delete(arg: PreferenceKeyArg & ITwinIdArg): Promise<void>;
34
+ save(arg: PreferenceArg & ITwinIdArg): Promise<void>;
35
+ }
36
+ //# sourceMappingURL=PreferencesBrowserStorage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PreferencesBrowserStorage.d.ts","sourceRoot":"","sources":["../../src/PreferencesBrowserStorage.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAU1G;;EAEE;AACF,MAAM,WAAW,gCAAgC;IAC/C,yGAAyG;IACzG,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC;AAED;;;;;;;;;;;;;;;EAeE;AACF,qBAAa,yBAA0B,YAAW,qBAAqB;IAErE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA+C;IACxE,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAS;gBAEnC,oBAAoB,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,gCAAgC;IAKjF,OAAO,CAAC,iBAAiB;IAMzB,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAK/B,OAAO,CAAC,eAAe;IAeV,GAAG,CAAC,GAAG,EAAE,gBAAgB,GAAG,UAAU;IAoBtC,MAAM,CAAC,GAAG,EAAE,gBAAgB,GAAG,UAAU;IAoBzC,IAAI,CAAC,GAAG,EAAE,aAAa,GAAG,UAAU;CAUlD"}
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PreferencesBrowserStorage = void 0;
4
+ /** User preferences implementation using browser's local storage.
5
+ * It creates storage item key in the form of:
6
+ * <storageItemKeyPrefix>.<itwin_guid?>.<imodel_guid?>
7
+ *
8
+ * <itwin_guid> and <imodel_guid> being optional.
9
+ *
10
+ * Each entry in the storage is a serialized JSON of the following index signature:
11
+ * {
12
+ * "<preference_namespace?>.<preference_key>": {
13
+ * ...
14
+ * <preferences_json_content>
15
+ * },
16
+ * ...
17
+ * }
18
+ * @beta
19
+ */
20
+ class PreferencesBrowserStorage {
21
+ constructor(storageItemKeyPrefix, opts) {
22
+ this._options = opts;
23
+ this._storageItemKeyPrefix = storageItemKeyPrefix;
24
+ }
25
+ getStorageItemKey(arg) {
26
+ const itwinIdStr = arg.iTwinId ? `.${arg.iTwinId}` : "";
27
+ const imodelIdStr = arg.iModelId ? `.${arg.iModelId}` : "";
28
+ return `${this._storageItemKeyPrefix}${itwinIdStr}${imodelIdStr}`;
29
+ }
30
+ static getPreferenceKey(arg) {
31
+ const nsStr = arg.namespace ? `${arg.namespace}.` : "";
32
+ return `${nsStr}${arg.key}`;
33
+ }
34
+ loadFromStorage(arg) {
35
+ const storage = window.localStorage;
36
+ let map = {};
37
+ const itemStr = storage.getItem(this.getStorageItemKey(arg));
38
+ if (itemStr === null) {
39
+ return undefined;
40
+ }
41
+ if (!itemStr || itemStr === "{}")
42
+ return map;
43
+ map = JSON.parse(itemStr);
44
+ return map;
45
+ }
46
+ async get(arg) {
47
+ const map = this.loadFromStorage(arg);
48
+ if (map === undefined)
49
+ return undefined;
50
+ if (arg.key) {
51
+ if (!Object.keys(map).includes(arg.key))
52
+ return undefined;
53
+ const nsStr = arg.namespace ? `${arg.namespace}.` : "";
54
+ const prefKey = `${nsStr}${arg.key}`;
55
+ return [map[prefKey]];
56
+ }
57
+ else { // No key provided, return all objects
58
+ const values = [];
59
+ for (const [_key, value] of Object.entries(map))
60
+ values.push(value);
61
+ return values;
62
+ }
63
+ }
64
+ async delete(arg) {
65
+ const map = this.loadFromStorage(arg);
66
+ if (map === undefined) {
67
+ if (this._options?.throwOnDeleteMissingKey)
68
+ throw new Error("Could not find key from storage.");
69
+ else
70
+ return;
71
+ }
72
+ const prefKey = PreferencesBrowserStorage.getPreferenceKey(arg);
73
+ if (!Object.keys(map).includes(prefKey)) {
74
+ if (this._options?.throwOnDeleteMissingKey)
75
+ throw Error("Could not find key from storage.");
76
+ else
77
+ return;
78
+ }
79
+ delete map[prefKey];
80
+ window.localStorage.setItem(this.getStorageItemKey(arg), JSON.stringify(map));
81
+ }
82
+ async save(arg) {
83
+ let map = this.loadFromStorage(arg);
84
+ if (map === undefined)
85
+ map = {};
86
+ map[PreferencesBrowserStorage.getPreferenceKey(arg)] = arg.content;
87
+ const itemValue = JSON.stringify(map);
88
+ window.localStorage.setItem(this.getStorageItemKey(arg), itemValue);
89
+ }
90
+ }
91
+ exports.PreferencesBrowserStorage = PreferencesBrowserStorage;
92
+ //# sourceMappingURL=PreferencesBrowserStorage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PreferencesBrowserStorage.js","sourceRoot":"","sources":["../../src/PreferencesBrowserStorage.ts"],"names":[],"mappings":";;;AAsBA;;;;;;;;;;;;;;;EAeE;AACF,MAAa,yBAAyB;IAKpC,YAAY,oBAA4B,EAAE,IAAuC;QAC/E,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,qBAAqB,GAAG,oBAAoB,CAAC;IACpD,CAAC;IAEO,iBAAiB,CAAC,GAAe;QACvC,MAAM,UAAU,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACxD,MAAM,WAAW,GAAG,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3D,OAAO,GAAG,IAAI,CAAC,qBAAqB,GAAG,UAAU,GAAG,WAAW,EAAE,CAAC;IACpE,CAAC;IAEO,MAAM,CAAC,gBA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,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QACtC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,EAAE,SAAS,CAAC,CAAC;IACtE,CAAC;CACF;AAtFD,8DAsFC","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 { ITwinIdArg, PreferenceArg, PreferenceKeyArg, UserPreferencesAccess } from \"@itwin/core-frontend\";\n\n/** Index signature holding preferences content\n *\n * @internal\n */\ninterface KeyContentProps {\n [preferenceKey: string]: any;\n}\n\n/**\n* @beta\n*/\nexport interface PreferencesBrowserStorageOptions {\n /** indicate whether or not delete function should throw an error if the provided key cannot be found. */\n throwOnDeleteMissingKey?: boolean;\n}\n\n/** User preferences implementation using browser's local storage.\n * It creates storage item key in the form of:\n * <storageItemKeyPrefix>.<itwin_guid?>.<imodel_guid?>\n *\n * <itwin_guid> and <imodel_guid> being optional.\n *\n * Each entry in the storage is a serialized JSON of the following index signature:\n * {\n * \"<preference_namespace?>.<preference_key>\": {\n * ...\n * <preferences_json_content>\n * },\n * ...\n * }\n * @beta\n*/\nexport class PreferencesBrowserStorage implements UserPreferencesAccess {\n\n private readonly _options: PreferencesBrowserStorageOptions | undefined;\n private readonly _storageItemKeyPrefix: string;\n\n constructor(storageItemKeyPrefix: string, opts?: PreferencesBrowserStorageOptions) {\n this._options = opts;\n this._storageItemKeyPrefix = storageItemKeyPrefix;\n }\n\n private getStorageItemKey(arg: ITwinIdArg) {\n const itwinIdStr = arg.iTwinId ? `.${arg.iTwinId}` : \"\";\n const imodelIdStr = arg.iModelId ? `.${arg.iModelId}` : \"\";\n return `${this._storageItemKeyPrefix}${itwinIdStr}${imodelIdStr}`;\n }\n\n private static getPreferenceKey(arg: PreferenceKeyArg) {\n const nsStr = arg.namespace ? `${arg.namespace}.` : \"\";\n return `${nsStr}${arg.key}`;\n }\n\n private loadFromStorage(arg: PreferenceKeyArg & ITwinIdArg) {\n const storage = window.localStorage;\n\n let map: KeyContentProps = {};\n const itemStr = storage.getItem(this.getStorageItemKey(arg));\n if (itemStr === null) {\n return undefined;\n }\n if (!itemStr || itemStr === \"{}\")\n return map;\n\n map = JSON.parse(itemStr);\n return map;\n }\n\n public async get(arg: PreferenceKeyArg & ITwinIdArg) {\n const map = this.loadFromStorage(arg);\n if (map === undefined)\n return undefined;\n\n if (arg.key) {\n if (!Object.keys(map).includes(arg.key))\n return undefined;\n\n const nsStr = arg.namespace ? `${arg.namespace}.` : \"\";\n const prefKey = `${nsStr}${arg.key}`;\n return [map[prefKey]];\n } else { // No key provided, return all objects\n const values = [];\n for (const [_key, value] of Object.entries(map))\n values.push(value);\n return values;\n }\n }\n\n public async delete(arg: PreferenceKeyArg & ITwinIdArg) {\n const map = this.loadFromStorage(arg);\n if (map === undefined) {\n if (this._options?.throwOnDeleteMissingKey)\n throw new Error(\"Could not find key from storage.\");\n else\n return;\n }\n\n const prefKey = PreferencesBrowserStorage.getPreferenceKey(arg);\n if (!Object.keys(map).includes(prefKey)) {\n if (this._options?.throwOnDeleteMissingKey)\n throw Error(\"Could not find key from storage.\");\n else\n return;\n }\n delete map[prefKey];\n window.localStorage.setItem(this.getStorageItemKey(arg), JSON.stringify(map));\n }\n\n public async save(arg: PreferenceArg & ITwinIdArg) {\n let map = this.loadFromStorage(arg);\n if (map === undefined)\n map = {};\n\n map[PreferencesBrowserStorage.getPreferenceKey(arg)] = arg.content;\n\n const itemValue = JSON.stringify(map);\n window.localStorage.setItem(this.getStorageItemKey(arg), itemValue);\n }\n}\n"]}
@@ -1,4 +1,5 @@
1
1
  export * from "./mapLayers";
2
+ export * from "./MapLayersPrefBrowserStorage";
2
3
  export * from "./ui/Interfaces";
3
4
  export * from "./ui/MapLayersUiItemsProvider";
4
5
  export * from "./ui/FeatureInfoUiItemsProvider";
@@ -1 +1 @@
1
- {"version":3,"file":"map-layers.d.ts","sourceRoot":"","sources":["../../src/map-layers.ts"],"names":[],"mappings":"AAIA,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iCAAiC,CAAC;AAChD,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC"}
1
+ {"version":3,"file":"map-layers.d.ts","sourceRoot":"","sources":["../../src/map-layers.ts"],"names":[],"mappings":"AAIA,cAAc,aAAa,CAAC;AAC5B,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iBAAiB,CAAC;AAChC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iCAAiC,CAAC;AAChD,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC"}
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  * See LICENSE.md in the project root for license terms and full copyright notice.
16
16
  *--------------------------------------------------------------------------------------------*/
17
17
  __exportStar(require("./mapLayers"), exports);
18
+ __exportStar(require("./MapLayersPrefBrowserStorage"), exports);
18
19
  __exportStar(require("./ui/Interfaces"), exports);
19
20
  __exportStar(require("./ui/MapLayersUiItemsProvider"), exports);
20
21
  __exportStar(require("./ui/FeatureInfoUiItemsProvider"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"map-layers.js","sourceRoot":"","sources":["../../src/map-layers.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,8CAA4B;AAC5B,kDAAgC;AAChC,gEAA8C;AAC9C,kEAAgD;AAChD,0DAAwC;AACxC,8DAA4C","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\nexport * from \"./mapLayers\";\r\nexport * from \"./ui/Interfaces\";\r\nexport * from \"./ui/MapLayersUiItemsProvider\";\r\nexport * from \"./ui/FeatureInfoUiItemsProvider\";\r\nexport * from \"./ui/MapFeatureInfoTool\";\r\nexport * from \"./ui/widget/MapLayersWidget\";\r\n"]}
1
+ {"version":3,"file":"map-layers.js","sourceRoot":"","sources":["../../src/map-layers.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F,8CAA4B;AAC5B,gEAA8C;AAC9C,kDAAgC;AAChC,gEAA8C;AAC9C,kEAAgD;AAChD,0DAAwC;AACxC,8DAA4C","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\nexport * from \"./mapLayers\";\r\nexport * from \"./MapLayersPrefBrowserStorage\";\r\nexport * from \"./ui/Interfaces\";\r\nexport * from \"./ui/MapLayersUiItemsProvider\";\r\nexport * from \"./ui/FeatureInfoUiItemsProvider\";\r\nexport * from \"./ui/MapFeatureInfoTool\";\r\nexport * from \"./ui/widget/MapLayersWidget\";\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"MapLayerDroppable.d.ts","sourceRoot":"","sources":["../../../../src/ui/widget/MapLayerDroppable.tsx"],"names":[],"mappings":"AAWA,OAAO,EAAkE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAOtH,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAGvE,OAAO,wBAAwB,CAAC;AAIhC,gBAAgB;AAChB,UAAU,sBAAsB;IAC9B,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,qBAAqB,EAAE,CAAC;IACrC,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,oBAAoB,EAAE,MAAM,WAAW,CAAC;IACxC,cAAc,EAAE,cAAc,CAAC;IAC/B,kBAAkB,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,qBAAqB,KAAK,IAAI,CAAC;IACtF,6BAA6B,EAAE,CAAC,gBAAgB,EAAE,qBAAqB,KAAK,IAAI,CAAC;IACjF,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,gBAAgB;AAEhB,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,eAmH9D"}
1
+ {"version":3,"file":"MapLayerDroppable.d.ts","sourceRoot":"","sources":["../../../../src/ui/widget/MapLayerDroppable.tsx"],"names":[],"mappings":"AAWA,OAAO,EAAkE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAOtH,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAGvE,OAAO,wBAAwB,CAAC;AAIhC,gBAAgB;AAChB,UAAU,sBAAsB;IAC9B,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,qBAAqB,EAAE,CAAC;IACrC,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,oBAAoB,EAAE,MAAM,WAAW,CAAC;IACxC,cAAc,EAAE,cAAc,CAAC;IAC/B,kBAAkB,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,qBAAqB,KAAK,IAAI,CAAC;IACtF,6BAA6B,EAAE,CAAC,gBAAgB,EAAE,qBAAqB,KAAK,IAAI,CAAC;IACjF,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,gBAAgB;AAEhB,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,eA4H9D"}
@@ -33,6 +33,11 @@ function MapLayerDroppable(props) {
33
33
  const [noUnderlaysSpecifiedLabel] = React.useState(mapLayers_1.MapLayersUI.localization.getLocalizedString("mapLayers:Widget.NoOverlayLayers"));
34
34
  const [dropLayerLabel] = React.useState(mapLayers_1.MapLayersUI.localization.getLocalizedString("mapLayers:Widget.DropLayerLabel"));
35
35
  const [outOfRangeTitle] = React.useState(mapLayers_1.MapLayersUI.localization.getLocalizedString("mapLayers:Widget.layerOutOfRange"));
36
+ const onSubLayerStateChange = (activeLayer, subLayerId, isSelected) => {
37
+ const mapLayerStyleIdx = props.activeViewport.displayStyle.findMapLayerIndexByNameAndSource(activeLayer.name, activeLayer.source, activeLayer.isOverlay);
38
+ if (mapLayerStyleIdx !== -1 && activeLayer.subLayers)
39
+ props.activeViewport.displayStyle.changeMapSubLayerProps({ visible: isSelected }, subLayerId, { index: mapLayerStyleIdx, isOverlay: activeLayer.isOverlay });
40
+ };
36
41
  const renderItem = (dragProvided, _, rubric) => {
37
42
  (0, core_bentley_1.assert)(props.layersList !== undefined);
38
43
  const activeLayer = props.layersList[rubric.source.index];
@@ -42,7 +47,7 @@ function MapLayerDroppable(props) {
42
47
  React.createElement(core_react_1.Icon, { iconSpec: activeLayer.visible ? "icon-visibility" : "icon-visibility-hide-2" })),
43
48
  React.createElement("span", { className: props.disabled || outOfRange ? "map-manager-item-label-disabled" : "map-manager-item-label", title: outOfRange ? outOfRangeTitle : undefined, ...dragProvided.dragHandleProps }, activeLayer.name),
44
49
  React.createElement("div", { className: "map-manager-item-sub-layer-container" }, activeLayer.subLayers && activeLayer.subLayers.length > 1 &&
45
- React.createElement(SubLayersPopupButton_1.SubLayersPopupButton, { mapLayerSettings: activeLayer, activeViewport: props.activeViewport })),
50
+ React.createElement(SubLayersPopupButton_1.SubLayersPopupButton, { subLayers: props.activeViewport ? activeLayer.subLayers : undefined, singleVisibleSubLayer: activeLayer.provider?.mutualExclusiveSubLayer, onSubLayerStateChange: (subLayerId, isSelected) => { onSubLayerStateChange(activeLayer, subLayerId, isSelected); } })),
46
51
  activeLayer.provider?.status === core_frontend_1.MapLayerImageryProviderStatus.RequireAuth &&
47
52
  React.createElement(itwinui_react_1.Button, { disabled: props.disabled, size: "small", styleType: "borderless", onClick: () => {
48
53
  const indexInDisplayStyle = props.activeViewport?.displayStyle.findMapLayerIndexByNameAndSource(activeLayer.name, activeLayer.source, activeLayer.isOverlay);
@@ -1 +1 @@
1
- {"version":3,"file":"MapLayerDroppable.js","sourceRoot":"","sources":["../../../../src/ui/widget/MapLayerDroppable.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F,2CAA2C;;;AAE3C,oEAAoE;AACpE,sDAAsD;AAEtD,+BAA+B;AAC/B,6DAA2H;AAC3H,wDAAsH;AACtH,kDAAyC;AACzC,sDAA6C;AAC7C,oDAAiD;AACjD,wDAA8C;AAC9C,iEAA8D;AAC9D,qEAAyF;AAEzF,iEAA8D;AAC9D,iDAA8C;AAC9C,kCAAgC;AAChC,+CAA8C;AAC9C,oDAA2D;AAe3D,gBAAgB;AAChB,gEAAgE;AAChE,SAAgB,iBAAiB,CAAC,KAA6B;IAC7D,MAAM,aAAa,GAAG,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC;IACtE,MAAM,WAAW,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,qBAAqB,CAAC;IACjF,MAAM,CAAC,gBAAgB,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,uBAAW,CAAC,YAAY,CAAC,kBAAkB,CAAC,mCAAmC,CAAC,CAAC,CAAC;IAC5H,MAAM,CAAC,kBAAkB,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,uBAAW,CAAC,YAAY,CAAC,kBAAkB,CAAC,qCAAqC,CAAC,CAAC,CAAC;IAChI,MAAM,CAAC,8BAA8B,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,uBAAW,CAAC,YAAY,CAAC,kBAAkB,CAAC,qCAAqC,CAAC,CAAC,CAAC;IAC5I,MAAM,CAAC,yBAAyB,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,uBAAW,CAAC,YAAY,CAAC,kBAAkB,CAAC,kCAAkC,CAAC,CAAC,CAAC;IACpI,MAAM,CAAC,cAAc,CAAC,G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;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,SAAS,eAAe,CAAC,YAA+B,EAAE,YAAoC;QAC5F,OAAO,CACL,6BAAK,SAAS,EAAE,0BAA0B,YAAY,CAAC,cAAc,IAAI,aAAa,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,YAAY,CAAC,QAAQ,KAAM,YAAY,CAAC,cAAc;YAEjL,sBAAsB,CAAC,YAAY,CAAC;YAOrC,6BAAK,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,IAAG,YAAY,CAAC,WAAW,CAAO,CACzF,CAAC,CAAC;IACZ,CAAC;IAED,OAAO,CACL,oBAAC,+BAAS,IACR,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,UAAU,EACvB,oBAAoB,EAAE,KAAK,CAAC,oBAA2B,IAEtD,eAAe,CACN,CACb,CAAC;AACJ,CAAC;AAnHD,8CAmHC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n// cSpell:ignore droppable Sublayer Basemap\n\n// the following quiet warning caused by react-beautiful-dnd package\n/* eslint-disable @typescript-eslint/unbound-method */\n\nimport * as React from \"react\";\nimport { Draggable, DraggableChildrenFn, Droppable, DroppableProvided, DroppableStateSnapshot } from \"react-beautiful-dnd\";\nimport { MapLayerImageryProviderStatus, MapTileTreeScaleRangeVisibility, ScreenViewport } from \"@itwin/core-frontend\";\nimport { Icon } from \"@itwin/core-react\";\nimport { assert } from \"@itwin/core-bentley\";\nimport { UiFramework } from \"@itwin/appui-react\";\nimport { Button } from \"@itwin/itwinui-react\";\nimport { SubLayersPopupButton } from \"./SubLayersPopupButton\";\nimport { AttachLayerButtonType, AttachLayerPopupButton } from \"./AttachLayerPopupButton\";\nimport { MapTypesOptions, StyleMapLayerSettings } from \"../Interfaces\";\nimport { MapLayerSettingsMenu } from \"./MapLayerSettingsMenu\";\nimport { MapUrlDialog } from \"./MapUrlDialog\";\nimport \"./MapLayerManager.scss\";\nimport { MapLayersUI } from \"../../mapLayers\";\nimport { ImageMapLayerSettings } from \"@itwin/core-common\";\n\n/** @internal */\ninterface MapLayerDroppableProps {\n isOverlay: boolean;\n layersList?: StyleMapLayerSettings[];\n mapTypesOptions?: MapTypesOptions;\n getContainerForClone: () => HTMLElement;\n activeViewport: ScreenViewport;\n onMenuItemSelected: (action: string, mapLayerSettings: StyleMapLayerSettings) => void;\n onItemVisibilityToggleClicked: (mapLayerSettings: StyleMapLayerSettings) => void;\n onItemEdited: () => void;\n disabled?: boolean;\n}\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport function MapLayerDroppable(props: MapLayerDroppableProps) {\n const containsLayer = props.layersList && props.layersList.length > 0;\n const droppableId = props.isOverlay ? \"overlayMapLayers\" : \"backgroundMapLayers\";\n const [toggleVisibility] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Widget.ToggleVisibility\"));\n const [requireAuthTooltip] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Widget.RequireAuthTooltip\"));\n const [noBackgroundMapsSpecifiedLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Widget.NoBackgroundLayers\"));\n const [noUnderlaysSpecifiedLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Widget.NoOverlayLayers\"));\n const [dropLayerLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Widget.DropLayerLabel\"));\n const [outOfRangeTitle] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Widget.layerOutOfRange\"));\n\n const renderItem: DraggableChildrenFn = (dragProvided, _, rubric) => {\n assert(props.layersList !== undefined);\n const activeLayer = props.layersList[rubric.source.index];\n const outOfRange = activeLayer.treeVisibility === MapTileTreeScaleRangeVisibility.Hidden;\n\n return (\n <div className=\"map-manager-source-item\" data-id={rubric.source.index} key={activeLayer.name}\n {...dragProvided.draggableProps}\n ref={dragProvided.innerRef} >\n {/* Visibility icon */}\n <Button disabled={props.disabled} size=\"small\" styleType=\"borderless\" className=\"map-manager-item-visibility\" title={toggleVisibility} onClick={() => { props.onItemVisibilityToggleClicked(activeLayer); }}>\n <Icon iconSpec={activeLayer.visible ? \"icon-visibility\" : \"icon-visibility-hide-2\"} />\n </Button>\n {/* Label */}\n <span className={props.disabled||outOfRange ? \"map-manager-item-label-disabled\" : \"map-manager-item-label\"}\n title = {outOfRange ? outOfRangeTitle : undefined }\n {...dragProvided.dragHandleProps}\n\n >\n {activeLayer.name}\n </span>\n <div className=\"map-manager-item-sub-layer-container\">\n {activeLayer.subLayers && activeLayer.subLayers.length > 1 &&\n <SubLayersPopupButton mapLayerSettings={activeLayer} activeViewport={props.activeViewport} />\n }\n </div>\n {activeLayer.provider?.status === MapLayerImageryProviderStatus.RequireAuth &&\n <Button\n disabled={props.disabled}\n size=\"small\"\n styleType=\"borderless\"\n onClick={() => {\n const indexInDisplayStyle = props.activeViewport?.displayStyle.findMapLayerIndexByNameAndSource(activeLayer.name, activeLayer.source, activeLayer.isOverlay);\n if (indexInDisplayStyle !== undefined && indexInDisplayStyle >= 0) {\n const layerSettings = props.activeViewport.displayStyle.mapLayerAtIndex({index: indexInDisplayStyle, isOverlay: activeLayer.isOverlay});\n if (layerSettings instanceof ImageMapLayerSettings) {\n UiFramework.dialogs.modal.open(<MapUrlDialog activeViewport={props.activeViewport}\n isOverlay={props.isOverlay}\n layerRequiringCredentials={layerSettings?.toJSON()}\n onOkResult={props.onItemEdited}\n mapTypesOptions={props.mapTypesOptions}></MapUrlDialog>);\n }\n }\n\n }}\n title={requireAuthTooltip}\n >\n <Icon className=\"map-layer-source-item-warnMessage-icon\" iconSpec=\"icon-status-warning\" />\n </Button>\n }\n <MapLayerSettingsMenu activeViewport={props.activeViewport} mapLayerSettings={activeLayer} onMenuItemSelection={props.onMenuItemSelected} disabled={props.disabled} />\n </div>\n );\n };\n\n function renderDraggableContent(snapshot: DroppableStateSnapshot): React.ReactNode {\n let node: React.ReactNode;\n if (containsLayer) {\n // Render a <Draggable>\n node = (props.layersList?.map((mapLayerSettings, i) =>\n <Draggable isDragDisabled={props.disabled} key={mapLayerSettings.name} draggableId={mapLayerSettings.name} index={i}>\n {renderItem}\n </Draggable>));\n } else {\n // Render a label that provide a 'Drop here' hint\n const label = props.isOverlay ? noUnderlaysSpecifiedLabel : noBackgroundMapsSpecifiedLabel;\n node =\n <div title={label} className=\"map-manager-no-layers-container\">\n {snapshot.isDraggingOver ?\n <span className=\"map-manager-no-layers-label\">{dropLayerLabel}</span>\n :\n <>\n <span className=\"map-manager-no-layers-label\">{label}</span>\n <AttachLayerPopupButton disabled={props.disabled} buttonType={AttachLayerButtonType.Blue} isOverlay={props.isOverlay} />\n </>\n }\n </div>;\n }\n return node;\n }\n\n function renderDraggable(dropProvided: DroppableProvided, dropSnapshot: DroppableStateSnapshot): React.ReactElement<HTMLElement> {\n return (\n <div className={`map-manager-attachments${dropSnapshot.isDraggingOver && containsLayer ? \" is-dragging-map-over\" : \"\"}`} ref={dropProvided.innerRef} {...dropProvided.droppableProps} >\n\n {renderDraggableContent(dropSnapshot)}\n\n {\n /* We don't want a placeholder when displaying the 'Drop here' message\n Unfortunately, if don't add it, 'react-beautiful-dnd' show an error message in the console.\n So I simply make it hidden. See https://github.com/atlassian/react-beautiful-dnd/issues/518 */\n }\n <div style={containsLayer ? undefined : { display: \"none\" }}>{dropProvided.placeholder}</div>\n </div>);\n }\n\n return (\n <Droppable\n droppableId={droppableId}\n renderClone={renderItem}\n getContainerForClone={props.getContainerForClone as any}\n >\n {renderDraggable}\n </Droppable>\n );\n}\n"]}
1
+ {"version":3,"file":"MapLayerDroppable.js","sourceRoot":"","sources":["../../../../src/ui/widget/MapLayerDroppable.tsx"],"names":[],"mappings":";AAAA;;;+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/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n// cSpell:ignore droppable Sublayer Basemap\n\n// the following quiet warning caused by react-beautiful-dnd package\n/* eslint-disable @typescript-eslint/unbound-method */\n\nimport * as React from \"react\";\nimport { Draggable, DraggableChildrenFn, Droppable, DroppableProvided, DroppableStateSnapshot } from \"react-beautiful-dnd\";\nimport { MapLayerImageryProviderStatus, MapTileTreeScaleRangeVisibility, ScreenViewport } from \"@itwin/core-frontend\";\nimport { Icon } from \"@itwin/core-react\";\nimport { assert } from \"@itwin/core-bentley\";\nimport { UiFramework } from \"@itwin/appui-react\";\nimport { Button } from \"@itwin/itwinui-react\";\nimport { SubLayersPopupButton } from \"./SubLayersPopupButton\";\nimport { AttachLayerButtonType, AttachLayerPopupButton } from \"./AttachLayerPopupButton\";\nimport { MapTypesOptions, StyleMapLayerSettings } from \"../Interfaces\";\nimport { MapLayerSettingsMenu } from \"./MapLayerSettingsMenu\";\nimport { MapUrlDialog } from \"./MapUrlDialog\";\nimport \"./MapLayerManager.scss\";\nimport { MapLayersUI } from \"../../mapLayers\";\nimport { ImageMapLayerSettings, SubLayerId } from \"@itwin/core-common\";\n\n/** @internal */\ninterface MapLayerDroppableProps {\n isOverlay: boolean;\n layersList?: StyleMapLayerSettings[];\n mapTypesOptions?: MapTypesOptions;\n getContainerForClone: () => HTMLElement;\n activeViewport: ScreenViewport;\n onMenuItemSelected: (action: string, mapLayerSettings: StyleMapLayerSettings) => void;\n onItemVisibilityToggleClicked: (mapLayerSettings: StyleMapLayerSettings) => void;\n onItemEdited: () => void;\n disabled?: boolean;\n}\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport function MapLayerDroppable(props: MapLayerDroppableProps) {\n const containsLayer = props.layersList && props.layersList.length > 0;\n const droppableId = props.isOverlay ? \"overlayMapLayers\" : \"backgroundMapLayers\";\n const [toggleVisibility] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Widget.ToggleVisibility\"));\n const [requireAuthTooltip] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Widget.RequireAuthTooltip\"));\n const [noBackgroundMapsSpecifiedLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Widget.NoBackgroundLayers\"));\n const [noUnderlaysSpecifiedLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Widget.NoOverlayLayers\"));\n const [dropLayerLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Widget.DropLayerLabel\"));\n const [outOfRangeTitle] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Widget.layerOutOfRange\"));\n\n const onSubLayerStateChange = (activeLayer: StyleMapLayerSettings, subLayerId: SubLayerId, isSelected: boolean) => {\n const mapLayerStyleIdx = props.activeViewport.displayStyle.findMapLayerIndexByNameAndSource(activeLayer.name, activeLayer.source, activeLayer.isOverlay);\n if (mapLayerStyleIdx !== -1 && activeLayer.subLayers)\n props.activeViewport.displayStyle.changeMapSubLayerProps({ visible: isSelected }, subLayerId, { index: mapLayerStyleIdx, isOverlay: activeLayer.isOverlay });\n };\n\n const renderItem: DraggableChildrenFn = (dragProvided, _, rubric) => {\n assert(props.layersList !== undefined);\n const activeLayer = props.layersList[rubric.source.index];\n const outOfRange = activeLayer.treeVisibility === MapTileTreeScaleRangeVisibility.Hidden;\n\n return (\n <div className=\"map-manager-source-item\" data-id={rubric.source.index} key={activeLayer.name}\n {...dragProvided.draggableProps}\n ref={dragProvided.innerRef} >\n {/* Visibility icon */}\n <Button disabled={props.disabled} size=\"small\" styleType=\"borderless\" className=\"map-manager-item-visibility\" title={toggleVisibility} onClick={() => { props.onItemVisibilityToggleClicked(activeLayer); }}>\n <Icon iconSpec={activeLayer.visible ? \"icon-visibility\" : \"icon-visibility-hide-2\"} />\n </Button>\n {/* Label */}\n <span className={props.disabled || outOfRange ? \"map-manager-item-label-disabled\" : \"map-manager-item-label\"}\n title={outOfRange ? outOfRangeTitle : undefined}\n {...dragProvided.dragHandleProps}\n\n >\n {activeLayer.name}\n </span>\n <div className=\"map-manager-item-sub-layer-container\">\n {activeLayer.subLayers && activeLayer.subLayers.length > 1 &&\n <SubLayersPopupButton\n subLayers={props.activeViewport ? activeLayer.subLayers : undefined}\n singleVisibleSubLayer={activeLayer.provider?.mutualExclusiveSubLayer}\n onSubLayerStateChange={(subLayerId: SubLayerId, isSelected: boolean) => { onSubLayerStateChange(activeLayer, subLayerId, isSelected); }} />\n }\n </div>\n {activeLayer.provider?.status === MapLayerImageryProviderStatus.RequireAuth &&\n <Button\n disabled={props.disabled}\n size=\"small\"\n styleType=\"borderless\"\n onClick={() => {\n const indexInDisplayStyle = props.activeViewport?.displayStyle.findMapLayerIndexByNameAndSource(activeLayer.name, activeLayer.source, activeLayer.isOverlay);\n if (indexInDisplayStyle !== undefined && indexInDisplayStyle >= 0) {\n const layerSettings = props.activeViewport.displayStyle.mapLayerAtIndex({ index: indexInDisplayStyle, isOverlay: activeLayer.isOverlay });\n if (layerSettings instanceof ImageMapLayerSettings) {\n UiFramework.dialogs.modal.open(<MapUrlDialog activeViewport={props.activeViewport}\n isOverlay={props.isOverlay}\n layerRequiringCredentials={layerSettings?.toJSON()}\n onOkResult={props.onItemEdited}\n mapTypesOptions={props.mapTypesOptions}></MapUrlDialog>);\n }\n }\n\n }}\n title={requireAuthTooltip}\n >\n <Icon className=\"map-layer-source-item-warnMessage-icon\" iconSpec=\"icon-status-warning\" />\n </Button>\n }\n <MapLayerSettingsMenu activeViewport={props.activeViewport} mapLayerSettings={activeLayer} onMenuItemSelection={props.onMenuItemSelected} disabled={props.disabled} />\n </div>\n );\n };\n\n function renderDraggableContent(snapshot: DroppableStateSnapshot): React.ReactNode {\n let node: React.ReactNode;\n if (containsLayer) {\n // Render a <Draggable>\n node = (props.layersList?.map((mapLayerSettings, i) =>\n <Draggable isDragDisabled={props.disabled} key={mapLayerSettings.name} draggableId={mapLayerSettings.name} index={i}>\n {renderItem}\n </Draggable>));\n } else {\n // Render a label that provide a 'Drop here' hint\n const label = props.isOverlay ? noUnderlaysSpecifiedLabel : noBackgroundMapsSpecifiedLabel;\n node =\n <div title={label} className=\"map-manager-no-layers-container\">\n {snapshot.isDraggingOver ?\n <span className=\"map-manager-no-layers-label\">{dropLayerLabel}</span>\n :\n <>\n <span className=\"map-manager-no-layers-label\">{label}</span>\n <AttachLayerPopupButton disabled={props.disabled} buttonType={AttachLayerButtonType.Blue} isOverlay={props.isOverlay} />\n </>\n }\n </div>;\n }\n return node;\n }\n\n function renderDraggable(dropProvided: DroppableProvided, dropSnapshot: DroppableStateSnapshot): React.ReactElement<HTMLElement> {\n return (\n <div className={`map-manager-attachments${dropSnapshot.isDraggingOver && containsLayer ? \" is-dragging-map-over\" : \"\"}`} ref={dropProvided.innerRef} {...dropProvided.droppableProps} >\n\n {renderDraggableContent(dropSnapshot)}\n\n {\n /* We don't want a placeholder when displaying the 'Drop here' message\n Unfortunately, if don't add it, 'react-beautiful-dnd' show an error message in the console.\n So I simply make it hidden. See https://github.com/atlassian/react-beautiful-dnd/issues/518 */\n }\n <div style={containsLayer ? undefined : { display: \"none\" }}>{dropProvided.placeholder}</div>\n </div>);\n }\n\n return (\n <Droppable\n droppableId={droppableId}\n renderClone={renderItem}\n getContainerForClone={props.getContainerForClone as any}\n >\n {renderDraggable}\n </Droppable>\n );\n}\n"]}
@@ -1,13 +1,11 @@
1
1
  import { MapSubLayerProps } from "@itwin/core-common";
2
2
  import { ITreeDataProvider, TreeNodeItem } from "@itwin/components-react";
3
- import { StyleMapLayerSettings } from "../Interfaces";
4
3
  /**
5
4
  * Data provider that returns some fake nodes to show in tree.
6
5
  */
7
6
  export declare class SubLayersDataProvider implements ITreeDataProvider {
8
7
  private readonly _nodeMap;
9
- private readonly _mapLayer;
10
- constructor(mapLayer: StyleMapLayerSettings);
8
+ constructor(subLayers: MapSubLayerProps[]);
11
9
  static isUnnamedGroup(subLayer: MapSubLayerProps | undefined): boolean;
12
10
  private createId;
13
11
  private createNode;
@@ -1 +1 @@
1
- {"version":3,"file":"SubLayersDataProvider.d.ts","sourceRoot":"","sources":["../../../../src/ui/widget/SubLayersDataProvider.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAc,MAAM,oBAAoB,CAAC;AAElE,OAAO,EAA2B,iBAAiB,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEnG,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAEtD;;GAEG;AACH,qBAAa,qBAAsB,YAAW,iBAAiB;IAC7D,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAqC;IAC9D,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAwB;gBAEtC,QAAQ,EAAE,qBAAqB;WAK7B,cAAc,CAAC,QAAQ,EAAE,gBAAgB,GAAG,SAAS,GAAG,OAAO;IAO7E,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,UAAU;IAclB,OAAO,CAAC,cAAc;IAqBtB,OAAO,CAAC,SAAS;IAOJ,aAAa,CAAC,MAAM,CAAC,EAAE,YAAY;IAQnC,QAAQ,CAAC,MAAM,CAAC,EAAE,YAAY;CAO5C"}
1
+ {"version":3,"file":"SubLayersDataProvider.d.ts","sourceRoot":"","sources":["../../../../src/ui/widget/SubLayersDataProvider.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAc,MAAM,oBAAoB,CAAC;AAElE,OAAO,EAA2B,iBAAiB,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAGnG;;GAEG;AACH,qBAAa,qBAAsB,YAAW,iBAAiB;IAC7D,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAqC;gBAElD,SAAS,EAAE,gBAAgB,EAAE;WAI3B,cAAc,CAAC,QAAQ,EAAE,gBAAgB,GAAG,SAAS,GAAG,OAAO;IAO7E,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,UAAU;IAclB,OAAO,CAAC,cAAc;IAqBtB,OAAO,CAAC,SAAS;IAOJ,aAAa,CAAC,MAAM,CAAC,EAAE,YAAY;IAQnC,QAAQ,CAAC,MAAM,CAAC,EAAE,YAAY;CAO5C"}
@@ -12,10 +12,9 @@ const core_react_1 = require("@itwin/core-react");
12
12
  * Data provider that returns some fake nodes to show in tree.
13
13
  */
14
14
  class SubLayersDataProvider {
15
- constructor(mapLayer) {
15
+ constructor(subLayers) {
16
16
  this._nodeMap = new Map();
17
- this._mapLayer = mapLayer;
18
- this.loadNodes(mapLayer.subLayers);
17
+ this.loadNodes(subLayers);
19
18
  }
20
19
  static isUnnamedGroup(subLayer) {
21
20
  if (!subLayer)
@@ -1 +1 @@
1
- {"version":3,"file":"SubLayersDataProvider.js","sourceRoot":"","sources":["../../../../src/ui/widget/SubLayersDataProvider.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,sDAAgE;AAEhE,0DAAuD;AAEvD,kDAAkD;AAGlD;;GAEG;AACH,MAAa,qBAAqB;IAIhC,YAAY,QAA+B;QAH1B,aAAQ,GAAG,IAAI,GAAG,EAA0B,CAAC;QAI5D,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IACrC,CAAC;IAEM,MAAM,CAAC,cAAc,CAAC,QAAsC;QACjE,IAAI,CAAC,QAAQ;YACX,OAAO,KAAK,CAAC;QAEf,OAAO,CAAC,CAAC,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,KAAK,SAAS,IAAI,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC7H,CAAC;IAEO,QAAQ,CAAC,KAAuB;QACtC,OAAO,SAAS,KAAK,KAAK,CAAC,EAAE,CAAC,CAAC,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C,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC5G,IAAI,SAAS;YACX,OAAO,SAAS,CAAC;QAEnB,OAAO,EAAE,CAAC;IACZ,CAAC;CACF;AA7ED,sDA6EC","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 { compareStringsOrUndefined } from \"@itwin/core-bentley\";\nimport { MapSubLayerProps, SubLayerId } from \"@itwin/core-common\";\nimport { PropertyRecord } from \"@itwin/appui-abstract\";\nimport { DelayLoadedTreeNodeItem, ITreeDataProvider, TreeNodeItem } from \"@itwin/components-react\";\nimport { CheckBoxState } from \"@itwin/core-react\";\nimport { StyleMapLayerSettings } from \"../Interfaces\";\n\n/**\n * Data provider that returns some fake nodes to show in tree.\n */\nexport class SubLayersDataProvider implements ITreeDataProvider {\n private readonly _nodeMap = new Map<string, TreeNodeItem[]>();\n private readonly _mapLayer: StyleMapLayerSettings;\n\n constructor(mapLayer: StyleMapLayerSettings) {\n this._mapLayer = mapLayer;\n this.loadNodes(mapLayer.subLayers);\n }\n\n public static isUnnamedGroup(subLayer: MapSubLayerProps | undefined): boolean {\n if (!subLayer)\n return false;\n\n return (!subLayer.name || subLayer.name.length === 0) && (subLayer.children !== undefined && subLayer.children.length > 0);\n }\n\n private createId(props: MapSubLayerProps): string {\n return undefined !== props.id ? `${props.id}` : props.name ? props.name : \"no-id\";\n }\n\n private createNode(props: MapSubLayerProps, expanded?: boolean, isCheckboxDisabled?: boolean, icon?: string): DelayLoadedTreeNodeItem {\n return {\n id: this.createId(props),\n label: PropertyRecord.fromString(props.title ?? props.name ?? \"unknown\"),\n hasChildren: !!props.children,\n isCheckboxVisible: true,\n checkBoxState: props.visible && !isCheckboxDisabled ? CheckBoxState.On : CheckBoxState.Off,\n extendedData: { subLayerId: props.id },\n isCheckboxDisabled,\n autoExpand: expanded,\n icon,\n };\n }\n\n private loadChildNodes(allSubLayers: MapSubLayerProps[], parentId?: SubLayerId) {\n const filteredProps = allSubLayers.filter((props) => parentId === props.parent);\n if (filteredProps.length) {\n filteredProps?.sort((a: MapSubLayerProps, b: MapSubLayerProps) => compareStringsOrUndefined(a.title, b.title));\n const treeNodes: TreeNodeItem[] = [];\n\n filteredProps.forEach((props) => {\n treeNodes.push(this.createNode(props,\n (!parentId && props?.children !== undefined) ? true : undefined, // expand root group only (i.e. not the entire tree),\n undefined,\n SubLayersDataProvider.isUnnamedGroup(props) ? \"icon-folder\" : \"icon-layers\"\n\n ));\n if (props.children)\n this.loadChildNodes(allSubLayers, props.id);\n });\n\n this._nodeMap.set(undefined !== parentId ? `${parentId}` : \"\", treeNodes);\n }\n }\n\n private loadNodes(subLayerNodes: MapSubLayerProps[] | undefined) {\n subLayerNodes?.sort((a: MapSubLayerProps, b: MapSubLayerProps) => compareStringsOrUndefined(a.title, b.title));\n if (subLayerNodes) {\n this.loadChildNodes(subLayerNodes, undefined);\n }\n }\n\n public async getNodesCount(parent?: TreeNodeItem) {\n const nodeArray: TreeNodeItem[] | undefined = parent ? this._nodeMap.get(parent.id) : this._nodeMap.get(\"\");\n if (nodeArray)\n return nodeArray.length;\n\n return 0;\n }\n\n public async getNodes(parent?: TreeNodeItem) {\n const nodeArray: TreeNodeItem[] | undefined = parent ? this._nodeMap.get(parent.id) : this._nodeMap.get(\"\");\n if (nodeArray)\n return nodeArray;\n\n return [];\n }\n}\n"]}
1
+ {"version":3,"file":"SubLayersDataProvider.js","sourceRoot":"","sources":["../../../../src/ui/widget/SubLayersDataProvider.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,sDAAgE;AAEhE,0DAAuD;AAEvD,kDAAkD;AAElD;;GAEG;AACH,MAAa,qBAAqB;IAGhC,YAAY,SAA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;QAC/G,IAAI,aAAa,EAAE;YACjB,IAAI,CAAC,cAAc,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;SAC/C;IACH,CAAC;IAEM,KAAK,CAAC,aAAa,CAAC,MAAqB;QAC9C,MAAM,SAAS,GAA+B,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC5G,IAAI,SAAS;YACX,OAAO,SAAS,CAAC,MAAM,CAAC;QAE1B,OAAO,CAAC,CAAC;IACX,CAAC;IAEM,KAAK,CAAC,QAAQ,CAAC,MAAqB;QACzC,MAAM,SAAS,GAA+B,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC5G,IAAI,SAAS;YACX,OAAO,SAAS,CAAC;QAEnB,OAAO,EAAE,CAAC;IACZ,CAAC;CACF;AA3ED,sDA2EC","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 { compareStringsOrUndefined } from \"@itwin/core-bentley\";\nimport { MapSubLayerProps, SubLayerId } from \"@itwin/core-common\";\nimport { PropertyRecord } from \"@itwin/appui-abstract\";\nimport { DelayLoadedTreeNodeItem, ITreeDataProvider, TreeNodeItem } from \"@itwin/components-react\";\nimport { CheckBoxState } from \"@itwin/core-react\";\n\n/**\n * Data provider that returns some fake nodes to show in tree.\n */\nexport class SubLayersDataProvider implements ITreeDataProvider {\n private readonly _nodeMap = new Map<string, TreeNodeItem[]>();\n\n constructor(subLayers: MapSubLayerProps[]) {\n this.loadNodes(subLayers);\n }\n\n public static isUnnamedGroup(subLayer: MapSubLayerProps | undefined): boolean {\n if (!subLayer)\n return false;\n\n return (!subLayer.name || subLayer.name.length === 0) && (subLayer.children !== undefined && subLayer.children.length > 0);\n }\n\n private createId(props: MapSubLayerProps): string {\n return undefined !== props.id ? `${props.id}` : props.name ? props.name : \"no-id\";\n }\n\n private createNode(props: MapSubLayerProps, expanded?: boolean, isCheckboxDisabled?: boolean, icon?: string): DelayLoadedTreeNodeItem {\n return {\n id: this.createId(props),\n label: PropertyRecord.fromString(props.title ?? props.name ?? \"unknown\"),\n hasChildren: !!props.children,\n isCheckboxVisible: true,\n checkBoxState: props.visible && !isCheckboxDisabled ? CheckBoxState.On : CheckBoxState.Off,\n extendedData: { subLayerId: props.id },\n isCheckboxDisabled,\n autoExpand: expanded,\n icon,\n };\n }\n\n private loadChildNodes(allSubLayers: MapSubLayerProps[], parentId?: SubLayerId) {\n const filteredProps = allSubLayers.filter((props) => parentId === props.parent);\n if (filteredProps.length) {\n filteredProps?.sort((a: MapSubLayerProps, b: MapSubLayerProps) => compareStringsOrUndefined(a.title, b.title));\n const treeNodes: TreeNodeItem[] = [];\n\n filteredProps.forEach((props) => {\n treeNodes.push(this.createNode(props,\n (!parentId && props?.children !== undefined) ? true : undefined, // expand root group only (i.e. not the entire tree),\n undefined,\n SubLayersDataProvider.isUnnamedGroup(props) ? \"icon-folder\" : \"icon-layers\"\n\n ));\n if (props.children)\n this.loadChildNodes(allSubLayers, props.id);\n });\n\n this._nodeMap.set(undefined !== parentId ? `${parentId}` : \"\", treeNodes);\n }\n }\n\n private loadNodes(subLayerNodes: MapSubLayerProps[] | undefined) {\n subLayerNodes?.sort((a: MapSubLayerProps, b: MapSubLayerProps) => compareStringsOrUndefined(a.title, b.title));\n if (subLayerNodes) {\n this.loadChildNodes(subLayerNodes, undefined);\n }\n }\n\n public async getNodesCount(parent?: TreeNodeItem) {\n const nodeArray: TreeNodeItem[] | undefined = parent ? this._nodeMap.get(parent.id) : this._nodeMap.get(\"\");\n if (nodeArray)\n return nodeArray.length;\n\n return 0;\n }\n\n public async getNodes(parent?: TreeNodeItem) {\n const nodeArray: TreeNodeItem[] | undefined = parent ? this._nodeMap.get(parent.id) : this._nodeMap.get(\"\");\n if (nodeArray)\n return nodeArray;\n\n return [];\n }\n}\n"]}
@@ -1,10 +1,6 @@
1
- import { ScreenViewport } from "@itwin/core-frontend";
2
- import { StyleMapLayerSettings } from "../Interfaces";
1
+ import { SubLayersPanelProps } from "./SubLayersTree";
3
2
  /** @internal */
4
- export interface SubLayersPopupButtonProps {
5
- mapLayerSettings: StyleMapLayerSettings;
6
- activeViewport: ScreenViewport;
7
- }
3
+ export declare type SubLayersPopupButtonProps = SubLayersPanelProps;
8
4
  /** @internal */
9
- export declare function SubLayersPopupButton({ mapLayerSettings, activeViewport }: SubLayersPopupButtonProps): JSX.Element;
5
+ export declare function SubLayersPopupButton(props: SubLayersPopupButtonProps): JSX.Element;
10
6
  //# sourceMappingURL=SubLayersPopupButton.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SubLayersPopupButton.d.ts","sourceRoot":"","sources":["../../../../src/ui/widget/SubLayersPopupButton.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAItD,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAMtD,gBAAgB;AAChB,MAAM,WAAW,yBAAyB;IACxC,gBAAgB,EAAE,qBAAqB,CAAC;IACxC,cAAc,EAAE,cAAc,CAAC;CAChC;AAED,gBAAgB;AAEhB,wBAAgB,oBAAoB,CAAC,EAAE,gBAAgB,EAAE,cAAc,EAAE,EAAE,yBAAyB,eA0CnG"}
1
+ {"version":3,"file":"SubLayersPopupButton.d.ts","sourceRoot":"","sources":["../../../../src/ui/widget/SubLayersPopupButton.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAkB,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAMtE,gBAAgB;AAEhB,oBAAY,yBAAyB,GAAG,mBAAmB,CAAC;AAE5D,gBAAgB;AAEhB,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,eA0CpE"}
@@ -13,7 +13,7 @@ const mapLayers_1 = require("../../mapLayers");
13
13
  const itwinui_react_1 = require("@itwin/itwinui-react");
14
14
  /** @internal */
15
15
  // eslint-disable-next-line @typescript-eslint/naming-convention
16
- function SubLayersPopupButton({ mapLayerSettings, activeViewport }) {
16
+ function SubLayersPopupButton(props) {
17
17
  const [showSubLayersLabel] = React.useState(mapLayers_1.MapLayersUI.localization.getLocalizedString("mapLayers:SubLayers.Show"));
18
18
  const [hideSubLayersLabel] = React.useState(mapLayers_1.MapLayersUI.localization.getLocalizedString("mapLayers:SubLayers.Hide"));
19
19
  const [popupOpen, setPopupOpen] = React.useState(false);
@@ -35,7 +35,7 @@ function SubLayersPopupButton({ mapLayerSettings, activeViewport }) {
35
35
  React.createElement(core_react_1.Popup, { isOpen: popupOpen, position: appui_abstract_1.RelativePosition.BottomRight, onClose: onOutsideClick, target: buttonRef.current },
36
36
  React.createElement("div", { className: "map-transparency-popup-panel" },
37
37
  React.createElement("div", { ref: panelRef, className: "map-manager-sublayer-panel" },
38
- React.createElement(SubLayersTree_1.SubLayersPanel, { mapLayer: mapLayerSettings, viewport: activeViewport }))))));
38
+ React.createElement(SubLayersTree_1.SubLayersPanel, { ...props }))))));
39
39
  }
40
40
  exports.SubLayersPopupButton = SubLayersPopupButton;
41
41
  //# sourceMappingURL=SubLayersPopupButton.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SubLayersPopupButton.js","sourceRoot":"","sources":["../../../../src/ui/widget/SubLayersPopupButton.tsx"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,+BAA+B;AAE/B,0DAAyD;AACzD,kDAA6F;AAC7F,mDAAiD;AAEjD,+CAA8C;AAC9C,wDAA8C;AAU9C,gBAAgB;AAChB,gEAAgE;AAChE,SAAgB,oBAAoB,CAAC,EAAE,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CAAmC,EAAC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,kBAAkB,EAClK,OAAO,EAAE,WAAW;YACpB,oBAAC,wBAAW,IAAC,QAAQ,EAAC,aAAa,GAAG,CAC/B;QACT,oBAAC,kBAAK,IACJ,MAAM,EAAE,SAAS,EACjB,QAAQ,EAAE,iCAAgB,CAAC,WAAW,EACtC,OAAO,EAAE,cAAc,EACvB,MAAM,EAAE,SAAS,CAAC,OAAO;YAEzB,6BAAK,SAAS,EAAC,8BAA8B;gBAC3C,6BAAK,GAAG,EAAE,QAAQ,EAAE,SAAS,EAAC,4BAA4B;oBACxD,oBAAC,8BAAc,IAAC,QAAQ,EAAE,gBAAgB,EAAE,QAAQ,EAAE,cAAc,GAAI,CACpE,CACF,CACC,CACR,CACJ,CAAC;AACJ,CAAC;AA1CD,oDA0CC","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\";\nimport { ScreenViewport } from \"@itwin/core-frontend\";\nimport { RelativePosition } from \"@itwin/appui-abstract\";\nimport { OutsideClickEvent, Popup, useOnOutsideClick, WebFontIcon } from \"@itwin/core-react\";\nimport { SubLayersPanel } from \"./SubLayersTree\";\nimport { StyleMapLayerSettings } from \"../Interfaces\";\nimport { MapLayersUI } from \"../../mapLayers\";\nimport { Button } from \"@itwin/itwinui-react\";\n\n// cSpell:ignore droppable Sublayer\n\n/** @internal */\nexport interface SubLayersPopupButtonProps {\n mapLayerSettings: StyleMapLayerSettings;\n activeViewport: ScreenViewport;\n}\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport function SubLayersPopupButton({ mapLayerSettings, activeViewport }: SubLayersPopupButtonProps) {\n\n const [showSubLayersLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:SubLayers.Show\"));\n const [hideSubLayersLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:SubLayers.Hide\"));\n const [popupOpen, setPopupOpen] = React.useState(false);\n const buttonRef = React.useRef<HTMLButtonElement>(null);\n\n const togglePopup = React.useCallback(() => {\n setPopupOpen(!popupOpen);\n }, [popupOpen]);\n\n const onOutsideClick = React.useCallback(() => {\n setPopupOpen(false);\n }, []);\n\n const isOutsideEvent = React.useCallback((e: OutsideClickEvent) => {\n // if clicking on button that open panel - don't trigger outside click processing\n return !!buttonRef.current && (e.target instanceof Node) && !buttonRef.current.contains(e.target);\n }, []);\n\n const panelRef = useOnOutsideClick<HTMLDivElement>(onOutsideClick, isOutsideEvent);\n\n return (\n <>\n <Button size=\"small\" styleType=\"borderless\" ref={buttonRef} className=\"map-manager-item-sub-layer-button\" title={popupOpen ? hideSubLayersLabel : showSubLayersLabel}\n onClick={togglePopup}>\n <WebFontIcon iconName=\"icon-layers\" />\n </Button>\n <Popup\n isOpen={popupOpen}\n position={RelativePosition.BottomRight}\n onClose={onOutsideClick}\n target={buttonRef.current}\n >\n <div className=\"map-transparency-popup-panel\">\n <div ref={panelRef} className=\"map-manager-sublayer-panel\">\n <SubLayersPanel mapLayer={mapLayerSettings} viewport={activeViewport} />\n </div>\n </div>\n </Popup >\n </>\n );\n}\n"]}
1
+ {"version":3,"file":"SubLayersPopupButton.js","sourceRoot":"","sources":["../../../../src/ui/widget/SubLayersPopupButton.tsx"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,+BAA+B;AAE/B,0DAAyD;AACzD,kDAA6F;AAC7F,mDAAsE;AACtE,+CAA8C;AAC9C,wDAA8C;AAQ9C,gBAAgB;AAChB,gEAAgE;AAChE,SAAgB,oBAAoB,CAAC,KAAgC;IAEnE,MAAM,CAAC,kBAAkB,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,uBAAW,CAAC,YAAY,CAAC,kBAAkB,CAAC,0BAA0B,CAAC,CAAC,CAAC;IACrH,MAAM,CAA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BAAC,kBAAK,IACJ,MAAM,EAAE,SAAS,EACjB,QAAQ,EAAE,iCAAgB,CAAC,WAAW,EACtC,OAAO,EAAE,cAAc,EACvB,MAAM,EAAE,SAAS,CAAC,OAAO;YAEzB,6BAAK,SAAS,EAAC,8BAA8B;gBAC3C,6BAAK,GAAG,EAAE,QAAQ,EAAE,SAAS,EAAC,4BAA4B;oBACxD,oBAAC,8BAAc,OAAK,KAAK,GAAI,CACzB,CACF,CACC,CACR,CACJ,CAAC;AACJ,CAAC;AA1CD,oDA0CC","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 { RelativePosition } from \"@itwin/appui-abstract\";\nimport { OutsideClickEvent, Popup, useOnOutsideClick, WebFontIcon } from \"@itwin/core-react\";\nimport { SubLayersPanel, SubLayersPanelProps } from \"./SubLayersTree\";\nimport { MapLayersUI } from \"../../mapLayers\";\nimport { Button } from \"@itwin/itwinui-react\";\n\n// cSpell:ignore droppable Sublayer\n\n/** @internal */\n\nexport type SubLayersPopupButtonProps = SubLayersPanelProps;\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport function SubLayersPopupButton(props: SubLayersPopupButtonProps) {\n\n const [showSubLayersLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:SubLayers.Show\"));\n const [hideSubLayersLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:SubLayers.Hide\"));\n const [popupOpen, setPopupOpen] = React.useState(false);\n const buttonRef = React.useRef<HTMLButtonElement>(null);\n\n const togglePopup = React.useCallback(() => {\n setPopupOpen(!popupOpen);\n }, [popupOpen]);\n\n const onOutsideClick = React.useCallback(() => {\n setPopupOpen(false);\n }, []);\n\n const isOutsideEvent = React.useCallback((e: OutsideClickEvent) => {\n // if clicking on button that open panel - don't trigger outside click processing\n return !!buttonRef.current && (e.target instanceof Node) && !buttonRef.current.contains(e.target);\n }, []);\n\n const panelRef = useOnOutsideClick<HTMLDivElement>(onOutsideClick, isOutsideEvent);\n\n return (\n <>\n <Button size=\"small\" styleType=\"borderless\" ref={buttonRef} className=\"map-manager-item-sub-layer-button\" title={popupOpen ? hideSubLayersLabel : showSubLayersLabel}\n onClick={togglePopup}>\n <WebFontIcon iconName=\"icon-layers\" />\n </Button>\n <Popup\n isOpen={popupOpen}\n position={RelativePosition.BottomRight}\n onClose={onOutsideClick}\n target={buttonRef.current}\n >\n <div className=\"map-transparency-popup-panel\">\n <div ref={panelRef} className=\"map-manager-sublayer-panel\">\n <SubLayersPanel {...props} />\n </div>\n </div>\n </Popup >\n </>\n );\n}\n"]}