@itwin/map-layers 4.0.0-dev.4 → 4.0.0-dev.40

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 (82) hide show
  1. package/CHANGELOG.md +21 -5
  2. package/lib/cjs/MapLayerPreferences.js +1 -2
  3. package/lib/cjs/MapLayerPreferences.js.map +1 -1
  4. package/lib/cjs/mapLayers.js +10 -12
  5. package/lib/cjs/mapLayers.js.map +1 -1
  6. package/lib/cjs/ui/FeatureInfoUiItemsProvider.js +1 -2
  7. package/lib/cjs/ui/FeatureInfoUiItemsProvider.js.map +1 -1
  8. package/lib/cjs/ui/MapFeatureInfoTool.d.ts.map +1 -1
  9. package/lib/cjs/ui/MapFeatureInfoTool.js +1 -1
  10. package/lib/cjs/ui/MapFeatureInfoTool.js.map +1 -1
  11. package/lib/cjs/ui/MapLayersUiItemsProvider.js +1 -1
  12. package/lib/cjs/ui/MapLayersUiItemsProvider.js.map +1 -1
  13. package/lib/cjs/ui/widget/AttachLayerPopupButton.js +20 -23
  14. package/lib/cjs/ui/widget/AttachLayerPopupButton.js.map +1 -1
  15. package/lib/cjs/ui/widget/BasemapPanel.js +4 -4
  16. package/lib/cjs/ui/widget/BasemapPanel.js.map +1 -1
  17. package/lib/cjs/ui/widget/ConfirmMessageDialog.js +4 -7
  18. package/lib/cjs/ui/widget/ConfirmMessageDialog.js.map +1 -1
  19. package/lib/cjs/ui/widget/FeatureInfoDataProvider.js +3 -4
  20. package/lib/cjs/ui/widget/FeatureInfoDataProvider.js.map +1 -1
  21. package/lib/cjs/ui/widget/FeatureInfoWidget.js +10 -16
  22. package/lib/cjs/ui/widget/FeatureInfoWidget.js.map +1 -1
  23. package/lib/cjs/ui/widget/MapLayerDroppable.js +4 -7
  24. package/lib/cjs/ui/widget/MapLayerDroppable.js.map +1 -1
  25. package/lib/cjs/ui/widget/MapLayerManager.js +17 -19
  26. package/lib/cjs/ui/widget/MapLayerManager.js.map +1 -1
  27. package/lib/cjs/ui/widget/MapLayerSettingsMenu.js +2 -3
  28. package/lib/cjs/ui/widget/MapLayerSettingsMenu.js.map +1 -1
  29. package/lib/cjs/ui/widget/MapLayerSettingsPopupButton.js +2 -2
  30. package/lib/cjs/ui/widget/MapLayerSettingsPopupButton.js.map +1 -1
  31. package/lib/cjs/ui/widget/MapLayersWidget.js +4 -4
  32. package/lib/cjs/ui/widget/MapLayersWidget.js.map +1 -1
  33. package/lib/cjs/ui/widget/MapUrlDialog.d.ts.map +1 -1
  34. package/lib/cjs/ui/widget/MapUrlDialog.js +35 -32
  35. package/lib/cjs/ui/widget/MapUrlDialog.js.map +1 -1
  36. package/lib/cjs/ui/widget/SelectMapFormat.js +7 -12
  37. package/lib/cjs/ui/widget/SelectMapFormat.js.map +1 -1
  38. package/lib/cjs/ui/widget/SubLayersDataProvider.js +4 -5
  39. package/lib/cjs/ui/widget/SubLayersDataProvider.js.map +1 -1
  40. package/lib/cjs/ui/widget/SubLayersTree.js +28 -34
  41. package/lib/cjs/ui/widget/SubLayersTree.js.map +1 -1
  42. package/lib/esm/MapLayerPreferences.js +1 -2
  43. package/lib/esm/MapLayerPreferences.js.map +1 -1
  44. package/lib/esm/mapLayers.js +10 -12
  45. package/lib/esm/mapLayers.js.map +1 -1
  46. package/lib/esm/ui/FeatureInfoUiItemsProvider.js +1 -2
  47. package/lib/esm/ui/FeatureInfoUiItemsProvider.js.map +1 -1
  48. package/lib/esm/ui/MapFeatureInfoTool.d.ts.map +1 -1
  49. package/lib/esm/ui/MapFeatureInfoTool.js +2 -2
  50. package/lib/esm/ui/MapFeatureInfoTool.js.map +1 -1
  51. package/lib/esm/ui/MapLayersUiItemsProvider.js +1 -1
  52. package/lib/esm/ui/MapLayersUiItemsProvider.js.map +1 -1
  53. package/lib/esm/ui/widget/AttachLayerPopupButton.js +21 -24
  54. package/lib/esm/ui/widget/AttachLayerPopupButton.js.map +1 -1
  55. package/lib/esm/ui/widget/BasemapPanel.js +5 -5
  56. package/lib/esm/ui/widget/BasemapPanel.js.map +1 -1
  57. package/lib/esm/ui/widget/ConfirmMessageDialog.js +4 -7
  58. package/lib/esm/ui/widget/ConfirmMessageDialog.js.map +1 -1
  59. package/lib/esm/ui/widget/FeatureInfoDataProvider.js +3 -4
  60. package/lib/esm/ui/widget/FeatureInfoDataProvider.js.map +1 -1
  61. package/lib/esm/ui/widget/FeatureInfoWidget.js +10 -16
  62. package/lib/esm/ui/widget/FeatureInfoWidget.js.map +1 -1
  63. package/lib/esm/ui/widget/MapLayerDroppable.js +5 -8
  64. package/lib/esm/ui/widget/MapLayerDroppable.js.map +1 -1
  65. package/lib/esm/ui/widget/MapLayerManager.js +17 -19
  66. package/lib/esm/ui/widget/MapLayerManager.js.map +1 -1
  67. package/lib/esm/ui/widget/MapLayerSettingsMenu.js +2 -3
  68. package/lib/esm/ui/widget/MapLayerSettingsMenu.js.map +1 -1
  69. package/lib/esm/ui/widget/MapLayerSettingsPopupButton.js +2 -2
  70. package/lib/esm/ui/widget/MapLayerSettingsPopupButton.js.map +1 -1
  71. package/lib/esm/ui/widget/MapLayersWidget.js +4 -4
  72. package/lib/esm/ui/widget/MapLayersWidget.js.map +1 -1
  73. package/lib/esm/ui/widget/MapUrlDialog.d.ts.map +1 -1
  74. package/lib/esm/ui/widget/MapUrlDialog.js +36 -33
  75. package/lib/esm/ui/widget/MapUrlDialog.js.map +1 -1
  76. package/lib/esm/ui/widget/SelectMapFormat.js +7 -12
  77. package/lib/esm/ui/widget/SelectMapFormat.js.map +1 -1
  78. package/lib/esm/ui/widget/SubLayersDataProvider.js +4 -5
  79. package/lib/esm/ui/widget/SubLayersDataProvider.js.map +1 -1
  80. package/lib/esm/ui/widget/SubLayersTree.js +28 -34
  81. package/lib/esm/ui/widget/SubLayersTree.js.map +1 -1
  82. package/package.json +27 -27
@@ -14,14 +14,13 @@ export class MapLayersUI {
14
14
  }
15
15
  /** Used to initialize the Map Layers */
16
16
  static async initialize(config) {
17
- var _a;
18
17
  // register namespace containing localized strings for this package
19
- MapLayersUI.localization = (_a = config === null || config === void 0 ? void 0 : config.localization) !== null && _a !== void 0 ? _a : IModelApp.localization;
18
+ MapLayersUI.localization = config?.localization ?? IModelApp.localization;
20
19
  await MapLayersUI.localization.registerNamespace(MapLayersUI.localizationNamespace);
21
- MapLayersUI._iTwinConfig = config === null || config === void 0 ? void 0 : config.iTwinConfig;
22
- MapLayersUI._featureInfoOpts = config === null || config === void 0 ? void 0 : config.featureInfoOpts;
23
- MapLayersUI._mapLayerOptions = config === null || config === void 0 ? void 0 : config.mapLayerOptions;
24
- if (!(config === null || config === void 0 ? void 0 : config.delayItemsProviderRegister))
20
+ MapLayersUI._iTwinConfig = config?.iTwinConfig;
21
+ MapLayersUI._featureInfoOpts = config?.featureInfoOpts;
22
+ MapLayersUI._mapLayerOptions = config?.mapLayerOptions;
23
+ if (!config?.delayItemsProviderRegister)
25
24
  MapLayersUI.registerUiItemsProviders();
26
25
  }
27
26
  /** Registers the UiItemsProviders for MapLayers with optional overrides
@@ -30,17 +29,16 @@ export class MapLayersUI {
30
29
  * @beta
31
30
  */
32
31
  static registerUiItemsProviders(config) {
33
- var _a, _b, _c, _d, _e;
34
32
  const mlProvider = new MapLayersUiItemsProvider({ ...MapLayersUI._mapLayerOptions });
35
- const mlProviderId = (_b = (_a = config === null || config === void 0 ? void 0 : config.mapLayerProviderOverrides) === null || _a === void 0 ? void 0 : _a.providerId) !== null && _b !== void 0 ? _b : mlProvider.id;
33
+ const mlProviderId = config?.mapLayerProviderOverrides?.providerId ?? mlProvider.id;
36
34
  MapLayersUI._uiItemsProvidersId.push(mlProviderId);
37
- UiItemsManager.register(mlProvider, config === null || config === void 0 ? void 0 : config.mapLayerProviderOverrides); // eslint-disable-line deprecation/deprecation
35
+ UiItemsManager.register(mlProvider, config?.mapLayerProviderOverrides); // eslint-disable-line deprecation/deprecation
38
36
  // Register the FeatureInfo widget only if MapHit was provided.
39
- if ((_c = MapLayersUI._featureInfoOpts) === null || _c === void 0 ? void 0 : _c.onMapHit) {
37
+ if (MapLayersUI._featureInfoOpts?.onMapHit) {
40
38
  const fiProvider = new FeatureInfoUiItemsProvider({ ...MapLayersUI._featureInfoOpts });
41
- const fiProviderId = (_e = (_d = config === null || config === void 0 ? void 0 : config.featureInfoProviderOverrides) === null || _d === void 0 ? void 0 : _d.providerId) !== null && _e !== void 0 ? _e : fiProvider.id;
39
+ const fiProviderId = config?.featureInfoProviderOverrides?.providerId ?? fiProvider.id;
42
40
  MapLayersUI._uiItemsProvidersId.push(fiProviderId);
43
- UiItemsManager.register(fiProvider, config === null || config === void 0 ? void 0 : config.featureInfoProviderOverrides); // eslint-disable-line deprecation/deprecation
41
+ UiItemsManager.register(fiProvider, config?.featureInfoProviderOverrides); // eslint-disable-line deprecation/deprecation
44
42
  }
45
43
  }
46
44
  /** Unregisters internationalization service namespace and UiItemManager */
@@ -1 +1 @@
1
- {"version":3,"file":"mapLayers.js","sourceRoot":"","sources":["../../src/mapLayers.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAyB,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAA2B,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAChF,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAiB7E;;;;;GAKG;AACH,MAAM,OAAO,WAAW;IAQf,MAAM,KAAK,WAAW;QAC3B,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED,wCAAwC;IACjC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,MAAwB;;QACrD,mEAAmE;QACnE,WAAW,CAAC,YAAY,GAAG,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,YAAY,mCAAI,SAAS,CAAC,YAAY,CAAC;QAC1E,MAAM,WAAW,CAAC,YAAY,CAAC,iBAAiB,CAC9C,WAAW,CAAC,qBAAqB,CAClC,CAAC;QAEF,WAAW,C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AM,uBAAN,MAAM,CAAE,4BAA4B,CAAC,CAAC,CAAC,8CAA8C;SAC3H;IACH,CAAC;IAED,4EAA4E;IACrE,MAAM,CAAC,SAAS;QACrB,SAAS,CAAC,YAAY,CAAC,mBAAmB,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC;QAE9E,WAAW,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC,YAAY,EAAE,EAAE;YACvD,cAAc,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,8CAA8C;QACzF,CAAC,CAAC,CAAC;IACL,CAAC;IAED,kDAAkD;IAC3C,MAAM,KAAK,qBAAqB;QACrC,OAAO,WAAW,CAAC,UAAU,CAAC;IAChC,CAAC;;AA3Dc,sBAAU,GAAG,WAAW,CAAC;AAEzB,+BAAmB,GAAa,EAAE,CAAC","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\nimport { Localization } from \"@itwin/core-common\";\r\nimport { IModelApp, UserPreferencesAccess } from \"@itwin/core-frontend\";\r\nimport { MapLayersUiItemsProvider } from \"./ui/MapLayersUiItemsProvider\";\r\nimport { UiItemProviderOverrides, UiItemsManager } from \"@itwin/appui-abstract\";\r\nimport { FeatureInfoUiItemsProvider } from \"./ui/FeatureInfoUiItemsProvider\";\r\nimport { MapFeatureInfoOptions, MapLayerOptions } from \"./ui/Interfaces\";\r\n\r\nexport interface MapLayersConfig {\r\n localization?: Localization;\r\n /** If an iTwinConfig is provided, it will be used to load the MapLayerSources that are stored. */\r\n iTwinConfig?: UserPreferencesAccess;\r\n mapLayerOptions?: MapLayerOptions;\r\n featureInfoOpts?: MapFeatureInfoOptions;\r\n delayItemsProviderRegister?: boolean;\r\n}\r\n/** Configuration for registering UiItemsProviders for the MapLayers package */\r\nexport interface MapLayersUiProviderConfig {\r\n mapLayerProviderOverrides?: UiItemProviderOverrides; // eslint-disable-line deprecation/deprecation\r\n featureInfoProviderOverrides?: UiItemProviderOverrides; // eslint-disable-line deprecation/deprecation\r\n}\r\n\r\n/** MapLayersUI is use when the package is used as a dependency to another app.\r\n * '''ts\r\n * await MapLayersUI.initialize({...MapLayersInitProps});\r\n * '''\r\n * @beta\r\n */\r\nexport class MapLayersUI {\r\n private static _defaultNs = \"mapLayers\";\r\n public static localization: Localization;\r\n private static _uiItemsProvidersId: string[] = [];\r\n private static _iTwinConfig?: UserPreferencesAccess;\r\n private static _featureInfoOpts?: MapFeatureInfoOptions;\r\n private static _mapLayerOptions?: MapLayerOptions;\r\n\r\n public static get iTwinConfig(): UserPreferencesAccess | undefined {\r\n return this._iTwinConfig;\r\n }\r\n\r\n /** Used to initialize the Map Layers */\r\n public static async initialize(config?: MapLayersConfig): Promise<void> {\r\n // register namespace containing localized strings for this package\r\n MapLayersUI.localization = config?.localization ?? IModelApp.localization;\r\n await MapLayersUI.localization.registerNamespace(\r\n MapLayersUI.localizationNamespace\r\n );\r\n\r\n MapLayersUI._iTwinConfig = config?.iTwinConfig;\r\n MapLayersUI._featureInfoOpts = config?.featureInfoOpts;\r\n MapLayersUI._mapLayerOptions = config?.mapLayerOptions;\r\n\r\n if (!config?.delayItemsProviderRegister)\r\n MapLayersUI.registerUiItemsProviders();\r\n }\r\n\r\n /** Registers the UiItemsProviders for MapLayers with optional overrides\r\n * This is useful for an app that wants to defer UiItemsProvider registration so that it\r\n * may limit the MapLayers widgets to a specific workflow\r\n * @beta\r\n */\r\n public static registerUiItemsProviders(config?: MapLayersUiProviderConfig) {\r\n const mlProvider = new MapLayersUiItemsProvider({ ...MapLayersUI._mapLayerOptions });\r\n const mlProviderId = config?.mapLayerProviderOverrides?.providerId ?? mlProvider.id;\r\n MapLayersUI._uiItemsProvidersId.push(mlProviderId);\r\n UiItemsManager.register(mlProvider, config?.mapLayerProviderOverrides); // eslint-disable-line deprecation/deprecation\r\n\r\n // Register the FeatureInfo widget only if MapHit was provided.\r\n if (MapLayersUI._featureInfoOpts?.onMapHit) {\r\n const fiProvider = new FeatureInfoUiItemsProvider({ ...MapLayersUI._featureInfoOpts });\r\n const fiProviderId = config?.featureInfoProviderOverrides?.providerId ?? fiProvider.id;\r\n MapLayersUI._uiItemsProvidersId.push(fiProviderId);\r\n UiItemsManager.register(fiProvider, config?.featureInfoProviderOverrides); // eslint-disable-line deprecation/deprecation\r\n }\r\n }\r\n\r\n /** Unregisters internationalization service namespace and UiItemManager */\r\n public static terminate() {\r\n IModelApp.localization.unregisterNamespace(MapLayersUI.localizationNamespace);\r\n\r\n MapLayersUI._uiItemsProvidersId.forEach((uiProviderId) => {\r\n UiItemsManager.unregister(uiProviderId); // eslint-disable-line deprecation/deprecation\r\n });\r\n }\r\n\r\n /** The internationalization service namespace. */\r\n public static get localizationNamespace(): string {\r\n return MapLayersUI._defaultNs;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"mapLayers.js","sourceRoot":"","sources":["../../src/mapLayers.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAyB,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAA2B,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAChF,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAiB7E;;;;;GAKG;AACH,MAAM,OAAO,WAAW;IAQf,MAAM,KAAK,WAAW;QAC3B,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED,wCAAwC;IACjC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,MAAwB;QACrD,mEAAmE;QACnE,WAAW,CAAC,YAAY,GAAG,MAAM,EAAE,YAAY,IAAI,SAAS,CAAC,YAAY,CAAC;QAC1E,MAAM,WAAW,CAAC,YAAY,CAAC,iBAAiB,CAC9C,WAAW,CAAC,qBAAqB,CAClC,CAAC;QAEF,WAAW,CAAC,YAAY,GA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,cAAc,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,8CAA8C;QACzF,CAAC,CAAC,CAAC;IACL,CAAC;IAED,kDAAkD;IAC3C,MAAM,KAAK,qBAAqB;QACrC,OAAO,WAAW,CAAC,UAAU,CAAC;IAChC,CAAC;;AA3Dc,sBAAU,GAAG,WAAW,CAAC;AAEzB,+BAAmB,GAAa,EAAE,CAAC","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\nimport { Localization } from \"@itwin/core-common\";\r\nimport { IModelApp, UserPreferencesAccess } from \"@itwin/core-frontend\";\r\nimport { MapLayersUiItemsProvider } from \"./ui/MapLayersUiItemsProvider\";\r\nimport { UiItemProviderOverrides, UiItemsManager } from \"@itwin/appui-abstract\";\r\nimport { FeatureInfoUiItemsProvider } from \"./ui/FeatureInfoUiItemsProvider\";\r\nimport { MapFeatureInfoOptions, MapLayerOptions } from \"./ui/Interfaces\";\r\n\r\nexport interface MapLayersConfig {\r\n localization?: Localization;\r\n /** If an iTwinConfig is provided, it will be used to load the MapLayerSources that are stored. */\r\n iTwinConfig?: UserPreferencesAccess;\r\n mapLayerOptions?: MapLayerOptions;\r\n featureInfoOpts?: MapFeatureInfoOptions;\r\n delayItemsProviderRegister?: boolean;\r\n}\r\n/** Configuration for registering UiItemsProviders for the MapLayers package */\r\nexport interface MapLayersUiProviderConfig {\r\n mapLayerProviderOverrides?: UiItemProviderOverrides; // eslint-disable-line deprecation/deprecation\r\n featureInfoProviderOverrides?: UiItemProviderOverrides; // eslint-disable-line deprecation/deprecation\r\n}\r\n\r\n/** MapLayersUI is use when the package is used as a dependency to another app.\r\n * '''ts\r\n * await MapLayersUI.initialize({...MapLayersInitProps});\r\n * '''\r\n * @beta\r\n */\r\nexport class MapLayersUI {\r\n private static _defaultNs = \"mapLayers\";\r\n public static localization: Localization;\r\n private static _uiItemsProvidersId: string[] = [];\r\n private static _iTwinConfig?: UserPreferencesAccess;\r\n private static _featureInfoOpts?: MapFeatureInfoOptions;\r\n private static _mapLayerOptions?: MapLayerOptions;\r\n\r\n public static get iTwinConfig(): UserPreferencesAccess | undefined {\r\n return this._iTwinConfig;\r\n }\r\n\r\n /** Used to initialize the Map Layers */\r\n public static async initialize(config?: MapLayersConfig): Promise<void> {\r\n // register namespace containing localized strings for this package\r\n MapLayersUI.localization = config?.localization ?? IModelApp.localization;\r\n await MapLayersUI.localization.registerNamespace(\r\n MapLayersUI.localizationNamespace\r\n );\r\n\r\n MapLayersUI._iTwinConfig = config?.iTwinConfig;\r\n MapLayersUI._featureInfoOpts = config?.featureInfoOpts;\r\n MapLayersUI._mapLayerOptions = config?.mapLayerOptions;\r\n\r\n if (!config?.delayItemsProviderRegister)\r\n MapLayersUI.registerUiItemsProviders();\r\n }\r\n\r\n /** Registers the UiItemsProviders for MapLayers with optional overrides\r\n * This is useful for an app that wants to defer UiItemsProvider registration so that it\r\n * may limit the MapLayers widgets to a specific workflow\r\n * @beta\r\n */\r\n public static registerUiItemsProviders(config?: MapLayersUiProviderConfig) {\r\n const mlProvider = new MapLayersUiItemsProvider({ ...MapLayersUI._mapLayerOptions });\r\n const mlProviderId = config?.mapLayerProviderOverrides?.providerId ?? mlProvider.id;\r\n MapLayersUI._uiItemsProvidersId.push(mlProviderId);\r\n UiItemsManager.register(mlProvider, config?.mapLayerProviderOverrides); // eslint-disable-line deprecation/deprecation\r\n\r\n // Register the FeatureInfo widget only if MapHit was provided.\r\n if (MapLayersUI._featureInfoOpts?.onMapHit) {\r\n const fiProvider = new FeatureInfoUiItemsProvider({ ...MapLayersUI._featureInfoOpts });\r\n const fiProviderId = config?.featureInfoProviderOverrides?.providerId ?? fiProvider.id;\r\n MapLayersUI._uiItemsProvidersId.push(fiProviderId);\r\n UiItemsManager.register(fiProvider, config?.featureInfoProviderOverrides); // eslint-disable-line deprecation/deprecation\r\n }\r\n }\r\n\r\n /** Unregisters internationalization service namespace and UiItemManager */\r\n public static terminate() {\r\n IModelApp.localization.unregisterNamespace(MapLayersUI.localizationNamespace);\r\n\r\n MapLayersUI._uiItemsProvidersId.forEach((uiProviderId) => {\r\n UiItemsManager.unregister(uiProviderId); // eslint-disable-line deprecation/deprecation\r\n });\r\n }\r\n\r\n /** The internationalization service namespace. */\r\n public static get localizationNamespace(): string {\r\n return MapLayersUI._defaultNs;\r\n }\r\n}\r\n"]}
@@ -15,8 +15,7 @@ export class FeatureInfoUiItemsProvider {
15
15
  }
16
16
  provideToolbarButtonItems(_stageId, stageUsage, toolbarUsage, // eslint-disable-line deprecation/deprecation
17
17
  toolbarOrientation) {
18
- var _a;
19
- if (!((_a = this._featureInfoOpts) === null || _a === void 0 ? void 0 : _a.disableDefaultFeatureInfoTool) &&
18
+ if (!this._featureInfoOpts?.disableDefaultFeatureInfoTool &&
20
19
  stageUsage === StageUsage.General && // eslint-disable-line deprecation/deprecation
21
20
  toolbarUsage === ToolbarUsage.ContentManipulation && // eslint-disable-line deprecation/deprecation
22
21
  toolbarOrientation === ToolbarOrientation.Vertical // eslint-disable-line deprecation/deprecation
@@ -1 +1 @@
1
- {"version":3,"file":"FeatureInfoUiItemsProvider.js","sourceRoot":"","sources":["../../../src/ui/FeatureInfoUiItemsProvider.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAuB,oBAAoB,EAAqB,kBAAkB,EAAE,iBAAiB,EAAE,UAAU,EAAE,kBAAkB,EAAE,YAAY,EAAmB,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACxN,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,yBAAyB,EA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KAAK,EAAE,WAAW,CAAC,YAAY,CAAC,kBAAkB,CAAC,mCAAmC,CAAC;gBACvF,IAAI,EAAE,UAAU;gBAChB,gBAAgB,EAAE,GAAG,EAAE,CAAC,oBAAC,oBAAoB,IAAC,eAAe,EAAE,IAAI,CAAC,gBAAgB,GAAI;gBACxF,YAAY,EAAE,WAAW,CAAC,MAAM,EAAE,8CAA8C;aACjF,CAAC,CAAC;SACJ;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;;AA1CsB,mCAAQ,GAAG,iCAAiC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport * as React from \"react\";\r\nimport { AbstractWidgetProps, AbstractZoneLocation, CommonToolbarItem, StagePanelLocation, StagePanelSection, StageUsage, ToolbarOrientation, ToolbarUsage, UiItemsProvider, WidgetState } from \"@itwin/appui-abstract\";\r\nimport { ToolbarHelper, UiFramework } from \"@itwin/appui-react\";\r\nimport { MapFeatureInfoWidget } from \"./widget/FeatureInfoWidget\";\r\nimport { MapFeatureInfoOptions } from \"./Interfaces\";\r\nimport { MapLayersUI } from \"../mapLayers\";\r\nimport { DefaultMapFeatureInfoTool, getDefaultMapFeatureInfoToolItemDef } from \"./MapFeatureInfoTool\";\r\n\r\nexport class FeatureInfoUiItemsProvider implements UiItemsProvider { // eslint-disable-line deprecation/deprecation\r\n public readonly id = \"FeatureInfoUiItemsProvider\";\r\n public static readonly widgetId = \"map-layers:mapFeatureInfoWidget\";\r\n\r\n public constructor(private _featureInfoOpts: MapFeatureInfoOptions) { }\r\n\r\n public provideToolbarButtonItems(\r\n _stageId: string,\r\n stageUsage: string,\r\n toolbarUsage: ToolbarUsage, // eslint-disable-line deprecation/deprecation\r\n toolbarOrientation: ToolbarOrientation, // eslint-disable-line deprecation/deprecation\r\n ): CommonToolbarItem[] {\r\n if (\r\n !this._featureInfoOpts?.disableDefaultFeatureInfoTool &&\r\n stageUsage === StageUsage.General && // eslint-disable-line deprecation/deprecation\r\n toolbarUsage === ToolbarUsage.ContentManipulation && // eslint-disable-line deprecation/deprecation\r\n toolbarOrientation === ToolbarOrientation.Vertical // eslint-disable-line deprecation/deprecation\r\n ) {\r\n DefaultMapFeatureInfoTool.register(MapLayersUI.localizationNamespace);\r\n return [\r\n ToolbarHelper.createToolbarItemFromItemDef(60, getDefaultMapFeatureInfoToolItemDef()),\r\n ];\r\n }\r\n\r\n return [];\r\n }\r\n\r\n // eslint-disable-next-line deprecation/deprecation\r\n public provideWidgets(_stageId: string, stageUsage: string, location: StagePanelLocation, section?: StagePanelSection, zoneLocation?: AbstractZoneLocation): ReadonlyArray<AbstractWidgetProps> {\r\n const widgets: AbstractWidgetProps[] = []; // eslint-disable-line deprecation/deprecation\r\n\r\n // eslint-disable-next-line deprecation/deprecation\r\n if ((undefined === section && stageUsage === StageUsage.General && zoneLocation === AbstractZoneLocation.BottomRight) ||\r\n (stageUsage === StageUsage.General && location === StagePanelLocation.Right && section === StagePanelSection.End && \"1\" !== UiFramework.uiVersion)) { // eslint-disable-line deprecation/deprecation\r\n widgets.push({\r\n id: FeatureInfoUiItemsProvider.widgetId,\r\n label: MapLayersUI.localization.getLocalizedString(\"mapLayers:FeatureInfoWidget.Label\"),\r\n icon: \"icon-map\",\r\n getWidgetContent: () => <MapFeatureInfoWidget featureInfoOpts={this._featureInfoOpts} />, // eslint-disable-line react/display-name\r\n defaultState: WidgetState.Closed, // eslint-disable-line deprecation/deprecation\r\n });\r\n }\r\n\r\n return widgets;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"FeatureInfoUiItemsProvider.js","sourceRoot":"","sources":["../../../src/ui/FeatureInfoUiItemsProvider.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAuB,oBAAoB,EAAqB,kBA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AAW,CAAC;YACnH,CAAC,UAAU,KAAK,UAAU,CAAC,OAAO,IAAI,QAAQ,KAAK,kBAAkB,CAAC,KAAK,IAAI,OAAO,KAAK,iBAAiB,CAAC,GAAG,IAAI,GAAG,KAAK,WAAW,CAAC,SAAS,CAAC,EAAE,EAAE,8CAA8C;YACpM,OAAO,CAAC,IAAI,CAAC;gBACX,EAAE,EAAE,0BAA0B,CAAC,QAAQ;gBACvC,KAAK,EAAE,WAAW,CAAC,YAAY,CAAC,kBAAkB,CAAC,mCAAmC,CAAC;gBACvF,IAAI,EAAE,UAAU;gBAChB,gBAAgB,EAAE,GAAG,EAAE,CAAC,oBAAC,oBAAoB,IAAC,eAAe,EAAE,IAAI,CAAC,gBAAgB,GAAI;gBACxF,YAAY,EAAE,WAAW,CAAC,MAAM,EAAE,8CAA8C;aACjF,CAAC,CAAC;SACJ;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;;AA1CsB,mCAAQ,GAAG,iCAAiC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport * as React from \"react\";\r\nimport { AbstractWidgetProps, AbstractZoneLocation, CommonToolbarItem, StagePanelLocation, StagePanelSection, StageUsage, ToolbarOrientation, ToolbarUsage, UiItemsProvider, WidgetState } from \"@itwin/appui-abstract\";\r\nimport { ToolbarHelper, UiFramework } from \"@itwin/appui-react\";\r\nimport { MapFeatureInfoWidget } from \"./widget/FeatureInfoWidget\";\r\nimport { MapFeatureInfoOptions } from \"./Interfaces\";\r\nimport { MapLayersUI } from \"../mapLayers\";\r\nimport { DefaultMapFeatureInfoTool, getDefaultMapFeatureInfoToolItemDef } from \"./MapFeatureInfoTool\";\r\n\r\nexport class FeatureInfoUiItemsProvider implements UiItemsProvider { // eslint-disable-line deprecation/deprecation\r\n public readonly id = \"FeatureInfoUiItemsProvider\";\r\n public static readonly widgetId = \"map-layers:mapFeatureInfoWidget\";\r\n\r\n public constructor(private _featureInfoOpts: MapFeatureInfoOptions) { }\r\n\r\n public provideToolbarButtonItems(\r\n _stageId: string,\r\n stageUsage: string,\r\n toolbarUsage: ToolbarUsage, // eslint-disable-line deprecation/deprecation\r\n toolbarOrientation: ToolbarOrientation, // eslint-disable-line deprecation/deprecation\r\n ): CommonToolbarItem[] {\r\n if (\r\n !this._featureInfoOpts?.disableDefaultFeatureInfoTool &&\r\n stageUsage === StageUsage.General && // eslint-disable-line deprecation/deprecation\r\n toolbarUsage === ToolbarUsage.ContentManipulation && // eslint-disable-line deprecation/deprecation\r\n toolbarOrientation === ToolbarOrientation.Vertical // eslint-disable-line deprecation/deprecation\r\n ) {\r\n DefaultMapFeatureInfoTool.register(MapLayersUI.localizationNamespace);\r\n return [\r\n ToolbarHelper.createToolbarItemFromItemDef(60, getDefaultMapFeatureInfoToolItemDef()),\r\n ];\r\n }\r\n\r\n return [];\r\n }\r\n\r\n // eslint-disable-next-line deprecation/deprecation\r\n public provideWidgets(_stageId: string, stageUsage: string, location: StagePanelLocation, section?: StagePanelSection, zoneLocation?: AbstractZoneLocation): ReadonlyArray<AbstractWidgetProps> {\r\n const widgets: AbstractWidgetProps[] = []; // eslint-disable-line deprecation/deprecation\r\n\r\n // eslint-disable-next-line deprecation/deprecation\r\n if ((undefined === section && stageUsage === StageUsage.General && zoneLocation === AbstractZoneLocation.BottomRight) ||\r\n (stageUsage === StageUsage.General && location === StagePanelLocation.Right && section === StagePanelSection.End && \"1\" !== UiFramework.uiVersion)) { // eslint-disable-line deprecation/deprecation\r\n widgets.push({\r\n id: FeatureInfoUiItemsProvider.widgetId,\r\n label: MapLayersUI.localization.getLocalizedString(\"mapLayers:FeatureInfoWidget.Label\"),\r\n icon: \"icon-map\",\r\n getWidgetContent: () => <MapFeatureInfoWidget featureInfoOpts={this._featureInfoOpts} />, // eslint-disable-line react/display-name\r\n defaultState: WidgetState.Closed, // eslint-disable-line deprecation/deprecation\r\n });\r\n }\r\n\r\n return widgets;\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"MapFeatureInfoTool.d.ts","sourceRoot":"","sources":["../../../src/ui/MapFeatureInfoTool.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,aAAa,EACb,YAAY,EACZ,SAAS,EAGT,aAAa,EACd,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAqB,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAG9C,eAAO,MAAM,mCAAmC,QAAO,WAOnD,CAAC;AAEL,qBAAa,yBAA0B,SAAQ,aAAa;IAC1D,gBAAuB,QAAQ,gBAAqB,SAAS,KAAK,IAAI,EAAI;IAC1E,OAAuB,MAAM,SAAwB;IACrD,OAAuB,QAAQ,SAAc;IAE7B,sBAAsB,IAAI,OAAO;IAI3B,gBAAgB,CACpC,EAAE,EAAE,aAAa,GAChB,OAAO,CAAC,YAAY,CAAC;IAsBF,eAAe,CACnC,GAAG,EAAE,aAAa,GACjB,OAAO,CAAC,YAAY,CAAC;IAMX,aAAa;CAK3B"}
1
+ {"version":3,"file":"MapFeatureInfoTool.d.ts","sourceRoot":"","sources":["../../../src/ui/MapFeatureInfoTool.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,aAAa,EACb,YAAY,EACZ,SAAS,EAGT,aAAa,EACd,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,WAAW,EAAe,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAG9C,eAAO,MAAM,mCAAmC,QAAO,WAOnD,CAAC;AAEL,qBAAa,yBAA0B,SAAQ,aAAa;IAC1D,gBAAuB,QAAQ,gBAAqB,SAAS,KAAK,IAAI,EAAI;IAC1E,OAAuB,MAAM,SAAwB;IACrD,OAAuB,QAAQ,SAAc;IAE7B,sBAAsB,IAAI,OAAO;IAI3B,gBAAgB,CACpC,EAAE,EAAE,aAAa,GAChB,OAAO,CAAC,YAAY,CAAC;IAsBF,eAAe,CACnC,GAAG,EAAE,aAAa,GACjB,OAAO,CAAC,YAAY,CAAC;IAMX,aAAa;CAK3B"}
@@ -4,7 +4,7 @@
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
  import { EventHandled, IModelApp, LocateResponse, PrimitiveTool, } from "@itwin/core-frontend";
6
6
  import { WidgetState } from "@itwin/appui-abstract";
7
- import { FrontstageManager, ToolItemDef } from "@itwin/appui-react";
7
+ import { ToolItemDef, UiFramework } from "@itwin/appui-react";
8
8
  import { BeEvent } from "@itwin/core-bentley";
9
9
  import { FeatureInfoUiItemsProvider } from "./FeatureInfoUiItemsProvider";
10
10
  export const getDefaultMapFeatureInfoToolItemDef = () => new ToolItemDef({
@@ -21,7 +21,7 @@ export class DefaultMapFeatureInfoTool extends PrimitiveTool {
21
21
  async onDataButtonDown(ev) {
22
22
  const hit = await IModelApp.locateManager.doLocate(new LocateResponse(), true, ev.point, ev.viewport, ev.inputSource);
23
23
  if (hit !== undefined) {
24
- const widgetDef = FrontstageManager.findWidget(FeatureInfoUiItemsProvider.widgetId);
24
+ const widgetDef = UiFramework.frontstages.findWidget(FeatureInfoUiItemsProvider.widgetId);
25
25
  if (widgetDef && widgetDef.state !== WidgetState.Open) // eslint-disable-line deprecation/deprecation
26
26
  widgetDef.setWidgetState(WidgetState.Open); // eslint-disable-line deprecation/deprecation
27
27
  DefaultMapFeatureInfoTool.onMapHit.raiseEvent(hit);
@@ -1 +1 @@
1
- {"version":3,"file":"MapFeatureInfoTool.js","sourceRoot":"","sources":["../../../src/ui/MapFeatureInfoTool.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,EAEL,YAAY,EAEZ,SAAS,EACT,cAAc,EACd,aAAa,GACd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,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YACnD,OAAO,YAAY,CAAC,GAAG,CAAC;SACzB;QAED,OAAO,YAAY,CAAC,EAAE,CAAC;IACzB,CAAC;IAEe,KAAK,CAAC,eAAe,CACnC,GAAkB;QAElB,8GAA8G;QAC9G,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QAC5B,OAAO,YAAY,CAAC,EAAE,CAAC;IACzB,CAAC;IAEM,KAAK,CAAC,aAAa;QACxB,MAAM,IAAI,GAAG,IAAI,yBAAyB,EAAE,CAAC;QAC7C,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,GAAG,EAAE,CAAC;YACrB,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC;;AA5CsB,kCAAQ,GAAG,IAAI,OAAO,EAA4B,CAAC;AACnD,gCAAM,GAAG,oBAAoB,CAAC;AAC9B,kCAAQ,GAAG,UAAU,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport {\r\n BeButtonEvent,\r\n EventHandled,\r\n HitDetail,\r\n IModelApp,\r\n LocateResponse,\r\n PrimitiveTool,\r\n} from \"@itwin/core-frontend\";\r\nimport { WidgetState } from \"@itwin/appui-abstract\";\r\nimport { FrontstageManager, ToolItemDef } from \"@itwin/appui-react\";\r\nimport { BeEvent } from \"@itwin/core-bentley\";\r\nimport { FeatureInfoUiItemsProvider } from \"./FeatureInfoUiItemsProvider\";\r\n\r\nexport const getDefaultMapFeatureInfoToolItemDef = (): ToolItemDef =>\r\n new ToolItemDef({\r\n toolId: DefaultMapFeatureInfoTool.toolId,\r\n iconSpec: DefaultMapFeatureInfoTool.iconSpec,\r\n label: () => DefaultMapFeatureInfoTool.flyover,\r\n description: () => DefaultMapFeatureInfoTool.description,\r\n execute: async () => { await IModelApp.tools.run(DefaultMapFeatureInfoTool.toolId); },\r\n });\r\n\r\nexport class DefaultMapFeatureInfoTool extends PrimitiveTool {\r\n public static readonly onMapHit = new BeEvent<(hit: HitDetail) => void>();\r\n public static override toolId = \"MapFeatureInfoTool\";\r\n public static override iconSpec = \"icon-map\";\r\n\r\n public override requireWriteableTarget(): boolean {\r\n return false;\r\n }\r\n\r\n public override async onDataButtonDown(\r\n ev: BeButtonEvent\r\n ): Promise<EventHandled> {\r\n const hit = await IModelApp.locateManager.doLocate(\r\n new LocateResponse(),\r\n true,\r\n ev.point,\r\n ev.viewport,\r\n ev.inputSource\r\n );\r\n if (hit !== undefined) {\r\n const widgetDef = FrontstageManager.findWidget(\r\n FeatureInfoUiItemsProvider.widgetId\r\n );\r\n if (widgetDef && widgetDef.state !== WidgetState.Open) // eslint-disable-line deprecation/deprecation\r\n widgetDef.setWidgetState(WidgetState.Open); // eslint-disable-line deprecation/deprecation\r\n\r\n DefaultMapFeatureInfoTool.onMapHit.raiseEvent(hit);\r\n return EventHandled.Yes;\r\n }\r\n\r\n return EventHandled.No;\r\n }\r\n\r\n public override async onResetButtonUp(\r\n _ev: BeButtonEvent\r\n ): Promise<EventHandled> {\r\n /* Common reset behavior for primitive tools is calling onReinitialize to restart or exitTool to terminate. */\r\n await this.onReinitialize();\r\n return EventHandled.No;\r\n }\r\n\r\n public async onRestartTool() {\r\n const tool = new DefaultMapFeatureInfoTool();\r\n if (!(await tool.run()))\r\n return this.exitTool();\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"MapFeatureInfoTool.js","sourceRoot":"","sources":["../../../src/ui/MapFeatureInfoTool.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,EAEL,YAAY,EAEZ,SAAS,EACT,cAAc,EACd,aAAa,GACd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAA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AAC;IAEe,KAAK,CAAC,eAAe,CACnC,GAAkB;QAElB,8GAA8G;QAC9G,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QAC5B,OAAO,YAAY,CAAC,EAAE,CAAC;IACzB,CAAC;IAEM,KAAK,CAAC,aAAa;QACxB,MAAM,IAAI,GAAG,IAAI,yBAAyB,EAAE,CAAC;QAC7C,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,GAAG,EAAE,CAAC;YACrB,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC3B,CAAC;;AA5CsB,kCAAQ,GAAG,IAAI,OAAO,EAA4B,CAAC;AACnD,gCAAM,GAAG,oBAAoB,CAAC;AAC9B,kCAAQ,GAAG,UAAU,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport {\r\n BeButtonEvent,\r\n EventHandled,\r\n HitDetail,\r\n IModelApp,\r\n LocateResponse,\r\n PrimitiveTool,\r\n} from \"@itwin/core-frontend\";\r\nimport { WidgetState } from \"@itwin/appui-abstract\";\r\nimport { ToolItemDef, UiFramework } from \"@itwin/appui-react\";\r\nimport { BeEvent } from \"@itwin/core-bentley\";\r\nimport { FeatureInfoUiItemsProvider } from \"./FeatureInfoUiItemsProvider\";\r\n\r\nexport const getDefaultMapFeatureInfoToolItemDef = (): ToolItemDef =>\r\n new ToolItemDef({\r\n toolId: DefaultMapFeatureInfoTool.toolId,\r\n iconSpec: DefaultMapFeatureInfoTool.iconSpec,\r\n label: () => DefaultMapFeatureInfoTool.flyover,\r\n description: () => DefaultMapFeatureInfoTool.description,\r\n execute: async () => { await IModelApp.tools.run(DefaultMapFeatureInfoTool.toolId); },\r\n });\r\n\r\nexport class DefaultMapFeatureInfoTool extends PrimitiveTool {\r\n public static readonly onMapHit = new BeEvent<(hit: HitDetail) => void>();\r\n public static override toolId = \"MapFeatureInfoTool\";\r\n public static override iconSpec = \"icon-map\";\r\n\r\n public override requireWriteableTarget(): boolean {\r\n return false;\r\n }\r\n\r\n public override async onDataButtonDown(\r\n ev: BeButtonEvent\r\n ): Promise<EventHandled> {\r\n const hit = await IModelApp.locateManager.doLocate(\r\n new LocateResponse(),\r\n true,\r\n ev.point,\r\n ev.viewport,\r\n ev.inputSource\r\n );\r\n if (hit !== undefined) {\r\n const widgetDef = UiFramework.frontstages.findWidget(\r\n FeatureInfoUiItemsProvider.widgetId\r\n );\r\n if (widgetDef && widgetDef.state !== WidgetState.Open) // eslint-disable-line deprecation/deprecation\r\n widgetDef.setWidgetState(WidgetState.Open); // eslint-disable-line deprecation/deprecation\r\n\r\n DefaultMapFeatureInfoTool.onMapHit.raiseEvent(hit);\r\n return EventHandled.Yes;\r\n }\r\n\r\n return EventHandled.No;\r\n }\r\n\r\n public override async onResetButtonUp(\r\n _ev: BeButtonEvent\r\n ): Promise<EventHandled> {\r\n /* Common reset behavior for primitive tools is calling onReinitialize to restart or exitTool to terminate. */\r\n await this.onReinitialize();\r\n return EventHandled.No;\r\n }\r\n\r\n public async onRestartTool() {\r\n const tool = new DefaultMapFeatureInfoTool();\r\n if (!(await tool.run()))\r\n return this.exitTool();\r\n }\r\n}\r\n"]}
@@ -10,7 +10,7 @@ import { MapLayersUI } from "../mapLayers";
10
10
  export class MapLayersUiItemsProvider {
11
11
  constructor(mapLayerOptions) {
12
12
  this.id = "MapLayersUiItemsProvider";
13
- this._mapLayerOptions = mapLayerOptions !== null && mapLayerOptions !== void 0 ? mapLayerOptions : {
13
+ this._mapLayerOptions = mapLayerOptions ?? {
14
14
  hideExternalMapLayers: false,
15
15
  mapTypeOptions: { supportTileUrl: false, supportWmsAuthentication: true },
16
16
  fetchPublicMapLayerSources: false,
@@ -1 +1 @@
1
- {"version":3,"file":"MapLayersUiItemsProvider.js","sourceRoot":"","sources":["../../../src/ui/MapLayersUiItemsProvider.tsx"],"names":[],"mappings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gBAChB,gBAAgB,EAAE,GAAG,EAAE,CAAC,oBAAC,eAAe,IAAC,eAAe,EAAE,IAAI,CAAC,gBAAgB,GAAI,EAAE,yCAAyC;aAC/H,CAAC,CAAC;SACJ;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport * as React from \"react\";\r\nimport { AbstractWidgetProps, AbstractZoneLocation, StagePanelLocation, StagePanelSection, StageUsage, UiItemsProvider } from \"@itwin/appui-abstract\";\r\nimport { MapLayersWidget } from \"./widget/MapLayersWidget\";\r\nimport { UiFramework } from \"@itwin/appui-react\";\r\nimport { MapLayerOptions } from \"./Interfaces\";\r\nimport { MapLayersUI } from \"../mapLayers\";\r\n\r\nexport class MapLayersUiItemsProvider implements UiItemsProvider { // eslint-disable-line deprecation/deprecation\r\n public readonly id = \"MapLayersUiItemsProvider\";\r\n private _mapLayerOptions?: MapLayerOptions;\r\n\r\n public constructor(mapLayerOptions?: MapLayerOptions) {\r\n this._mapLayerOptions = mapLayerOptions ?? {\r\n hideExternalMapLayers: false,\r\n mapTypeOptions: { supportTileUrl: false, supportWmsAuthentication: true },\r\n fetchPublicMapLayerSources: false,\r\n };\r\n }\r\n\r\n // eslint-disable-next-line deprecation/deprecation\r\n public provideWidgets(_stageId: string, stageUsage: string, location: StagePanelLocation, section: StagePanelSection | undefined, zoneLocation?: AbstractZoneLocation): ReadonlyArray<AbstractWidgetProps> {\r\n const widgets: AbstractWidgetProps[] = []; // eslint-disable-line deprecation/deprecation\r\n\r\n // eslint-disable-next-line deprecation/deprecation\r\n if ((undefined === section && stageUsage === StageUsage.General && zoneLocation === AbstractZoneLocation.CenterRight) ||\r\n (stageUsage === StageUsage.General && location === StagePanelLocation.Right && section === StagePanelSection.Start && \"1\" !== UiFramework.uiVersion)) { // eslint-disable-line deprecation/deprecation\r\n widgets.push({\r\n id: \"map-layers:mapLayersWidget\",\r\n label: MapLayersUI.localization.getLocalizedString(\"mapLayers:Widget.Label\"),\r\n icon: \"icon-map\",\r\n getWidgetContent: () => <MapLayersWidget mapLayerOptions={this._mapLayerOptions} />, // eslint-disable-line react/display-name\r\n });\r\n }\r\n\r\n return widgets;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"MapLayersUiItemsProvider.js","sourceRoot":"","sources":["../../../src/ui/MapLayersUiItemsProvider.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAuB,oBAAoB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,UAAU,EAAmB,MAAM,uBAAuB,CAAC;AACtJ,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,MAAM,OAAO,wBAAwB;IAInC,YAAmB,eAAiC;QAHpC,OAAE,GAAG,0BAA0B,CAAC;QAI9C,IAAI,CAAC,gBAAgB,GAAG,eAAe,IAAI;YACzC,qBAAqB,EAAE,KAAK;YAC5B,cAAc,EAAE,EAAE,cAAc,EAAE,KAAK,EAAE,wBAAwB,EAAE,IAAI,EAAE;YACzE,0BAA0B,EAAE,KAAK;SAClC,CAAC;IACJ,CAAC;IAED,mDAAmD;IAC5C,cAAc,CAAC,QAAgB,EAAE,UAAkB,EAAE,QAA4B,EAAE,OAAsC,EAAE,YAAmC;QACnK,MAAM,OAAO,GAA0B,EAAE,CAAC,CAAC,8CAA8C;QAEzF,mDAAmD;QACnD,IAAI,CAAC,SAAS,KAAK,OAAO,IAAI,UAAU,KAAK,UAAU,CAAC,OAAO,IAAI,YAAY,KAAK,oBAAoB,CAAC,WAAW,CAAC;YACnH,CAAC,UAAU,KAAK,UAAU,CAAC,OAAO,IAAI,QAAQ,KAAK,kBAAkB,CAAC,KAAK,IAAI,OAAO,KAAK,iBAAiB,CAAC,KAAK,IAAI,GAAG,KAAK,WAAW,CAAC,SAAS,CAAC,EAAE,EAAE,8CAA8C;YACtM,OAAO,CAAC,IAAI,CAAC;gBACX,EAAE,EAAE,4BAA4B;gBAChC,KAAK,EAAE,WAAW,CAAC,YAAY,CAAC,kBAAkB,CAAC,wBAAwB,CAAC;gBAC5E,IAAI,EAAE,UAAU;gBAChB,gBAAgB,EAAE,GAAG,EAAE,CAAC,oBAAC,eAAe,IAAC,eAAe,EAAE,IAAI,CAAC,gBAAgB,GAAI,EAAE,yCAAyC;aAC/H,CAAC,CAAC;SACJ;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport * as React from \"react\";\r\nimport { AbstractWidgetProps, AbstractZoneLocation, StagePanelLocation, StagePanelSection, StageUsage, UiItemsProvider } from \"@itwin/appui-abstract\";\r\nimport { MapLayersWidget } from \"./widget/MapLayersWidget\";\r\nimport { UiFramework } from \"@itwin/appui-react\";\r\nimport { MapLayerOptions } from \"./Interfaces\";\r\nimport { MapLayersUI } from \"../mapLayers\";\r\n\r\nexport class MapLayersUiItemsProvider implements UiItemsProvider { // eslint-disable-line deprecation/deprecation\r\n public readonly id = \"MapLayersUiItemsProvider\";\r\n private _mapLayerOptions?: MapLayerOptions;\r\n\r\n public constructor(mapLayerOptions?: MapLayerOptions) {\r\n this._mapLayerOptions = mapLayerOptions ?? {\r\n hideExternalMapLayers: false,\r\n mapTypeOptions: { supportTileUrl: false, supportWmsAuthentication: true },\r\n fetchPublicMapLayerSources: false,\r\n };\r\n }\r\n\r\n // eslint-disable-next-line deprecation/deprecation\r\n public provideWidgets(_stageId: string, stageUsage: string, location: StagePanelLocation, section: StagePanelSection | undefined, zoneLocation?: AbstractZoneLocation): ReadonlyArray<AbstractWidgetProps> {\r\n const widgets: AbstractWidgetProps[] = []; // eslint-disable-line deprecation/deprecation\r\n\r\n // eslint-disable-next-line deprecation/deprecation\r\n if ((undefined === section && stageUsage === StageUsage.General && zoneLocation === AbstractZoneLocation.CenterRight) ||\r\n (stageUsage === StageUsage.General && location === StagePanelLocation.Right && section === StagePanelSection.Start && \"1\" !== UiFramework.uiVersion)) { // eslint-disable-line deprecation/deprecation\r\n widgets.push({\r\n id: \"map-layers:mapLayersWidget\",\r\n label: MapLayersUI.localization.getLocalizedString(\"mapLayers:Widget.Label\"),\r\n icon: \"icon-map\",\r\n getWidgetContent: () => <MapLayersWidget mapLayerOptions={this._mapLayerOptions} />, // eslint-disable-line react/display-name\r\n });\r\n }\r\n\r\n return widgets;\r\n }\r\n}\r\n"]}
@@ -6,7 +6,7 @@ import * as React from "react";
6
6
  import { IModelApp, MapLayerSourceStatus, NotifyMessageDetails, OutputMessagePriority } from "@itwin/core-frontend";
7
7
  import { RelativePosition } from "@itwin/appui-abstract";
8
8
  import * as UiCore from "@itwin/core-react";
9
- import { ModalDialogManager } from "@itwin/appui-react";
9
+ import { UiFramework } from "@itwin/appui-react";
10
10
  import { useSourceMapContext } from "./MapLayerManager";
11
11
  import { MapUrlDialog } from "./MapUrlDialog";
12
12
  import { ConfirmMessageDialog } from "./ConfirmMessageDialog";
@@ -21,7 +21,6 @@ var LayerAction;
21
21
  })(LayerAction || (LayerAction = {}));
22
22
  // eslint-disable-next-line @typescript-eslint/naming-convention
23
23
  function AttachLayerPanel({ isOverlay, onLayerAttached, onHandleOutsideClick }) {
24
- var _a, _b;
25
24
  const [layerNameToAdd, setLayerNameToAdd] = React.useState();
26
25
  const [sourceFilterString, setSourceFilterString] = React.useState();
27
26
  const { placeholderLabel, addCustomLayerLabel, addCustomLayerToolTip, loadingMapSources, removeLayerDefButtonTitle, editLayerDefButtonTitle, removeLayerDefDialogTitle } = React.useMemo(() => {
@@ -51,16 +50,16 @@ function AttachLayerPanel({ isOverlay, onLayerAttached, onHandleOutsideClick })
51
50
  isMounted.current = false;
52
51
  // We close any open dialogs that we might have opened
53
52
  // This was added because the modal dialog remained remained displayed after the session expired.
54
- ModalDialogManager.closeDialog();
53
+ UiFramework.dialogs.modal.close();
55
54
  };
56
55
  }, []);
57
56
  const handleFilterTextChanged = React.useCallback((event) => {
58
57
  setSourceFilterString(event.target.value);
59
58
  }, []);
60
59
  const { loadingSources, sources, activeViewport, backgroundLayers, overlayLayers, mapLayerOptions } = useSourceMapContext();
61
- const mapTypesOptions = mapLayerOptions === null || mapLayerOptions === void 0 ? void 0 : mapLayerOptions.mapTypeOptions;
62
- const iTwinId = (_a = activeViewport === null || activeViewport === void 0 ? void 0 : activeViewport.iModel) === null || _a === void 0 ? void 0 : _a.iTwinId;
63
- const iModelId = (_b = activeViewport === null || activeViewport === void 0 ? void 0 : activeViewport.iModel) === null || _b === void 0 ? void 0 : _b.iModelId;
60
+ const mapTypesOptions = mapLayerOptions?.mapTypeOptions;
61
+ const iTwinId = activeViewport?.iModel?.iTwinId;
62
+ const iModelId = activeViewport?.iModel?.iModelId;
64
63
  const styleContainsLayer = React.useCallback((name) => {
65
64
  if (backgroundLayers) {
66
65
  if (-1 !== backgroundLayers.findIndex((layer) => layer.name === name))
@@ -82,15 +81,15 @@ function AttachLayerPanel({ isOverlay, onLayerAttached, onHandleOutsideClick })
82
81
  const handleModalUrlDialogCancel = React.useCallback(() => {
83
82
  // close popup and refresh UI
84
83
  setLoading(false);
85
- ModalDialogManager.closeDialog();
84
+ UiFramework.dialogs.modal.close();
86
85
  resumeOutsideClick();
87
86
  }, [resumeOutsideClick]);
88
87
  React.useEffect(() => {
89
88
  async function attemptToAddLayer(layerName) {
90
89
  if (layerName && activeViewport) {
91
90
  // if the layer is not in the style add it now.
92
- if (undefined === (backgroundLayers === null || backgroundLayers === void 0 ? void 0 : backgroundLayers.find((layer) => layerName === layer.name)) && undefined === (overlayLayers === null || overlayLayers === void 0 ? void 0 : overlayLayers.find((layer) => layerName === layer.name))) {
93
- const mapLayerSettings = sources === null || sources === void 0 ? void 0 : sources.find((source) => source.name === layerName);
91
+ if (undefined === backgroundLayers?.find((layer) => layerName === layer.name) && undefined === overlayLayers?.find((layer) => layerName === layer.name)) {
92
+ const mapLayerSettings = sources?.find((source) => source.name === layerName);
94
93
  if (mapLayerSettings === undefined) {
95
94
  return;
96
95
  }
@@ -116,7 +115,7 @@ function AttachLayerPanel({ isOverlay, onLayerAttached, onHandleOutsideClick })
116
115
  }
117
116
  }
118
117
  else if (status === MapLayerSourceStatus.RequireAuth && isMounted.current) {
119
- ModalDialogManager.openDialog(React.createElement(MapUrlDialog, { activeViewport: activeViewport, isOverlay: isOverlay, layerRequiringCredentials: mapLayerSettings.toJSON(), onOkResult: () => handleModalUrlDialogOk(LayerAction.Attached), onCancelResult: handleModalUrlDialogCancel, mapTypesOptions: mapTypesOptions }));
118
+ UiFramework.dialogs.modal.open(React.createElement(MapUrlDialog, { activeViewport: activeViewport, isOverlay: isOverlay, layerRequiringCredentials: mapLayerSettings.toJSON(), onOkResult: () => handleModalUrlDialogOk(LayerAction.Attached), onCancelResult: handleModalUrlDialogCancel, mapTypesOptions: mapTypesOptions }));
120
119
  if (onHandleOutsideClick) {
121
120
  onHandleOutsideClick(false);
122
121
  }
@@ -148,17 +147,17 @@ function AttachLayerPanel({ isOverlay, onLayerAttached, onHandleOutsideClick })
148
147
  }
149
148
  }
150
149
  }, [setLayerNameToAdd, layerNameToAdd, activeViewport, sources, backgroundLayers, isOverlay, overlayLayers, onLayerAttached, handleModalUrlDialogOk, mapTypesOptions, handleModalUrlDialogCancel, onHandleOutsideClick]);
151
- const options = React.useMemo(() => sources === null || sources === void 0 ? void 0 : sources.filter((source) => !styleContainsLayer(source.name)), [sources, styleContainsLayer]);
150
+ const options = React.useMemo(() => sources?.filter((source) => !styleContainsLayer(source.name)), [sources, styleContainsLayer]);
152
151
  const filteredOptions = React.useMemo(() => {
153
152
  if (undefined === sourceFilterString || 0 === sourceFilterString.length) {
154
153
  return options;
155
154
  }
156
155
  else {
157
- return options === null || options === void 0 ? void 0 : options.filter((option) => option.name.toLowerCase().includes(sourceFilterString === null || sourceFilterString === void 0 ? void 0 : sourceFilterString.toLowerCase()));
156
+ return options?.filter((option) => option.name.toLowerCase().includes(sourceFilterString?.toLowerCase()));
158
157
  }
159
158
  }, [options, sourceFilterString]);
160
159
  const handleAddNewMapSource = React.useCallback(() => {
161
- ModalDialogManager.openDialog(React.createElement(MapUrlDialog, { activeViewport: activeViewport, isOverlay: isOverlay, onOkResult: () => handleModalUrlDialogOk(LayerAction.Attached), onCancelResult: handleModalUrlDialogCancel, mapTypesOptions: mapTypesOptions }));
160
+ UiFramework.dialogs.modal.open(React.createElement(MapUrlDialog, { activeViewport: activeViewport, isOverlay: isOverlay, onOkResult: () => handleModalUrlDialogOk(LayerAction.Attached), onCancelResult: handleModalUrlDialogCancel, mapTypesOptions: mapTypesOptions }));
162
161
  if (onHandleOutsideClick) {
163
162
  onHandleOutsideClick(false);
164
163
  }
@@ -168,11 +167,10 @@ function AttachLayerPanel({ isOverlay, onLayerAttached, onHandleOutsideClick })
168
167
  setLayerNameToAdd(mapName);
169
168
  }, []);
170
169
  const handleKeypressOnSourceList = React.useCallback((event) => {
171
- var _a, _b;
172
170
  const key = event.key;
173
171
  if (key === "Enter") {
174
172
  event.preventDefault();
175
- const mapName = (_b = (_a = event.currentTarget) === null || _a === void 0 ? void 0 : _a.dataset) === null || _b === void 0 ? void 0 : _b.value;
173
+ const mapName = event.currentTarget?.dataset?.value;
176
174
  if (mapName && mapName.length) {
177
175
  handleAttach(mapName);
178
176
  }
@@ -182,7 +180,7 @@ function AttachLayerPanel({ isOverlay, onLayerAttached, onHandleOutsideClick })
182
180
  setLayerNameToAdd(mapName);
183
181
  }, []);
184
182
  const handleNoConfirmation = React.useCallback((_layerName) => {
185
- ModalDialogManager.closeDialog();
183
+ UiFramework.dialogs.modal.close();
186
184
  resumeOutsideClick();
187
185
  }, [resumeOutsideClick]);
188
186
  const handleYesConfirmation = React.useCallback(async (source) => {
@@ -198,7 +196,7 @@ function AttachLayerPanel({ isOverlay, onLayerAttached, onHandleOutsideClick })
198
196
  IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Error, msg));
199
197
  }
200
198
  }
201
- ModalDialogManager.closeDialog();
199
+ UiFramework.dialogs.modal.close();
202
200
  resumeOutsideClick();
203
201
  }, [iTwinId, iModelId, resumeOutsideClick]);
204
202
  /*
@@ -208,7 +206,7 @@ function AttachLayerPanel({ isOverlay, onLayerAttached, onHandleOutsideClick })
208
206
  event.stopPropagation(); // We don't want the owning ListBox to react on mouse click.
209
207
  const layerName = source.name;
210
208
  const msg = MapLayersUI.localization.getLocalizedString("mapLayers:CustomAttach.RemoveLayerDefDialogMessage", { layerName });
211
- ModalDialogManager.openDialog(React.createElement(ConfirmMessageDialog, { className: "map-sources-delete-confirmation", title: removeLayerDefDialogTitle, message: msg, maxWidth: 400, onClose: () => handleNoConfirmation(layerName), onEscape: () => handleNoConfirmation(layerName), onYesResult: async () => handleYesConfirmation(source), onNoResult: () => handleNoConfirmation(layerName) }));
209
+ UiFramework.dialogs.modal.open(React.createElement(ConfirmMessageDialog, { className: "map-sources-delete-confirmation", title: removeLayerDefDialogTitle, message: msg, maxWidth: 400, onClose: () => handleNoConfirmation(layerName), onEscape: () => handleNoConfirmation(layerName), onYesResult: async () => handleYesConfirmation(source), onNoResult: () => handleNoConfirmation(layerName) }));
212
210
  if (onHandleOutsideClick) {
213
211
  onHandleOutsideClick(false);
214
212
  }
@@ -217,15 +215,14 @@ function AttachLayerPanel({ isOverlay, onLayerAttached, onHandleOutsideClick })
217
215
  Handle Edit layer button clicked
218
216
  */
219
217
  const onItemEditButtonClicked = React.useCallback((event) => {
220
- var _a, _b, _c;
221
218
  event.stopPropagation(); // We don't want the owning ListBox to react on mouse click.
222
- const targetLayerName = (_c = (_b = (_a = event === null || event === void 0 ? void 0 : event.currentTarget) === null || _a === void 0 ? void 0 : _a.parentNode) === null || _b === void 0 ? void 0 : _b.dataset) === null || _c === void 0 ? void 0 : _c.value;
219
+ const targetLayerName = event?.currentTarget?.parentNode?.dataset?.value;
223
220
  const matchingSource = sources.find((layerSource) => layerSource.name === targetLayerName);
224
221
  // we expect a single layer source matching this name
225
222
  if (matchingSource === undefined) {
226
223
  return;
227
224
  }
228
- ModalDialogManager.openDialog(React.createElement(MapUrlDialog, { activeViewport: activeViewport, isOverlay: isOverlay, mapLayerSourceToEdit: matchingSource, onOkResult: () => handleModalUrlDialogOk(LayerAction.Edited), onCancelResult: handleModalUrlDialogCancel, mapTypesOptions: mapTypesOptions }));
225
+ UiFramework.dialogs.modal.open(React.createElement(MapUrlDialog, { activeViewport: activeViewport, isOverlay: isOverlay, mapLayerSourceToEdit: matchingSource, onOkResult: () => handleModalUrlDialogOk(LayerAction.Edited), onCancelResult: handleModalUrlDialogCancel, mapTypesOptions: mapTypesOptions }));
229
226
  if (onHandleOutsideClick) {
230
227
  onHandleOutsideClick(false);
231
228
  }
@@ -236,7 +233,7 @@ function AttachLayerPanel({ isOverlay, onLayerAttached, onHandleOutsideClick })
236
233
  React.createElement(Input, { type: "text", className: "map-manager-source-list-filter", placeholder: placeholderLabel, value: sourceFilterString, onChange: handleFilterTextChanged, size: "small" }),
237
234
  React.createElement(Button, { className: "map-manager-add-source-button", title: addCustomLayerToolTip, onClick: handleAddNewMapSource }, addCustomLayerLabel)),
238
235
  React.createElement("div", { className: "map-manager-sources" },
239
- React.createElement(UiCore.Listbox, { id: "map-sources", selectedValue: layerNameToAdd, className: "map-manager-source-list", onKeyPress: handleKeypressOnSourceList, onListboxValueChange: onListboxValueChange }, filteredOptions === null || filteredOptions === void 0 ? void 0 : filteredOptions.map((source) => React.createElement(UiCore.ListboxItem, { key: source.name, className: "map-source-list-entry", value: source.name, onMouseEnter: () => setLayerNameUnderCursor(source.name), onMouseLeave: () => setLayerNameUnderCursor(undefined) },
236
+ React.createElement(UiCore.Listbox, { id: "map-sources", selectedValue: layerNameToAdd, className: "map-manager-source-list", onKeyPress: handleKeypressOnSourceList, onListboxValueChange: onListboxValueChange }, filteredOptions?.map((source) => React.createElement(UiCore.ListboxItem, { key: source.name, className: "map-source-list-entry", value: source.name, onMouseEnter: () => setLayerNameUnderCursor(source.name), onMouseLeave: () => setLayerNameUnderCursor(undefined) },
240
237
  React.createElement("span", { className: "map-source-list-entry-name", title: source.name }, source.name),
241
238
  // otherwise list feels cluttered.
242
239
  (!!iTwinId && layerNameUnderCursor && layerNameUnderCursor === source.name) &&
@@ -287,11 +284,11 @@ export function AttachLayerPopupButton(props) {
287
284
  return;
288
285
  }
289
286
  // If clicking on button that open panel - don't trigger outside click processing
290
- if ((buttonRef === null || buttonRef === void 0 ? void 0 : buttonRef.current) && (buttonRef === null || buttonRef === void 0 ? void 0 : buttonRef.current.contains(event.target))) {
287
+ if (buttonRef?.current && buttonRef?.current.contains(event.target)) {
291
288
  return;
292
289
  }
293
290
  // If clicking the panel, this is not an outside clicked
294
- if (panelRef.current && (panelRef === null || panelRef === void 0 ? void 0 : panelRef.current.contains(event.target))) {
291
+ if (panelRef.current && panelRef?.current.contains(event.target)) {
295
292
  return;
296
293
  }
297
294
  // If we reach this point, we got an outside clicked, no close the popup
@@ -1 +1 @@
1
- {"version":3,"file":"AttachLayerPopupButton.js","sourceRoot":"","sources":["../../../../src/ui/widget/AttachLayerPopupButton.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAkB,oBAAoB,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AACpI,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO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AK,IACX,MAAM,EAAE,SAAS,EACjB,QAAQ,EAAE,gBAAgB,CAAC,WAAW,EACtC,OAAO,EAAE,gBAAgB,EACzB,cAAc,EAAE,oBAAoB,EACpC,MAAM,EAAE,SAAS,CAAC,OAAO,EACzB,YAAY,EAAE,KAAK,EACnB,kBAAkB,EAAE,KAAK;YAEzB,6BAAK,GAAG,EAAE,QAAQ,EAAE,SAAS,EAAC,yBAAyB;gBACrD,oBAAC,gBAAgB,IACf,SAAS,EAAE,KAAK,CAAC,SAAS,EAC1B,eAAe,EAAE,mBAAmB,EACpC,oBAAoB,EAAE,qBAAqB,GAAG,CAC5C,CACQ,CACf,CACJ,CAAC;AACJ,CAAC","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\nimport * as React from \"react\";\r\nimport { IModelApp, MapLayerSource, MapLayerSourceStatus, NotifyMessageDetails, OutputMessagePriority } from \"@itwin/core-frontend\";\r\nimport { RelativePosition } from \"@itwin/appui-abstract\";\r\nimport * as UiCore from \"@itwin/core-react\";\r\nimport { ModalDialogManager } from \"@itwin/appui-react\";\r\nimport { useSourceMapContext } from \"./MapLayerManager\";\r\nimport { MapUrlDialog } from \"./MapUrlDialog\";\r\nimport { ConfirmMessageDialog } from \"./ConfirmMessageDialog\";\r\nimport { Button, Input } from \"@itwin/itwinui-react\";\r\nimport { MapLayerPreferences } from \"../../MapLayerPreferences\";\r\nimport { MapLayersUI } from \"../../mapLayers\";\r\n\r\n// cSpell:ignore droppable Sublayer\r\n\r\nenum LayerAction {\r\n Attached,\r\n Edited\r\n}\r\n\r\ninterface AttachLayerPanelProps {\r\n isOverlay: boolean;\r\n onLayerAttached: () => void;\r\n onHandleOutsideClick?: (shouldHandle: boolean) => void;\r\n}\r\n\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nfunction AttachLayerPanel({ isOverlay, onLayerAttached, onHandleOutsideClick }: AttachLayerPanelProps) {\r\n const [layerNameToAdd, setLayerNameToAdd] = React.useState<string | undefined>();\r\n const [sourceFilterString, setSourceFilterString] = React.useState<string | undefined>();\r\n\r\n const { placeholderLabel, addCustomLayerLabel, addCustomLayerToolTip, loadingMapSources, removeLayerDefButtonTitle, editLayerDefButtonTitle, removeLayerDefDialogTitle } = React.useMemo(() => {\r\n return {\r\n placeholderLabel: MapLayersUI.localization.getLocalizedString(\"mapLayers:CustomAttach.SearchPlaceholder\"),\r\n addCustomLayerLabel: MapLayersUI.localization.getLocalizedString(\"mapLayers:CustomAttach.Custom\"),\r\n addCustomLayerToolTip: MapLayersUI.localization.getLocalizedString(\"mapLayers:CustomAttach.AttachCustomLayer\"),\r\n loadingMapSources: MapLayersUI.localization.getLocalizedString(\"mapLayers:CustomAttach.LoadingMapSources\"),\r\n removeLayerDefButtonTitle: MapLayersUI.localization.getLocalizedString(\"mapLayers:CustomAttach.RemoveLayerDefButtonTitle\"),\r\n editLayerDefButtonTitle: MapLayersUI.localization.getLocalizedString(\"mapLayers:CustomAttach.EditLayerDefButtonTitle\"),\r\n removeLayerDefDialogTitle: MapLayersUI.localization.getLocalizedString(\"mapLayers:CustomAttach.RemoveLayerDefDialogTitle\"),\r\n };\r\n }, []);\r\n\r\n const [loading, setLoading] = React.useState(false);\r\n const [layerNameUnderCursor, setLayerNameUnderCursor] = React.useState<string | undefined>();\r\n\r\n const resumeOutsideClick = React.useCallback(() => {\r\n if (onHandleOutsideClick) {\r\n onHandleOutsideClick(true);\r\n }\r\n }, [onHandleOutsideClick]);\r\n\r\n // 'isMounted' is used to prevent any async operation once the hook has been\r\n // unloaded. Otherwise we get a 'Can't perform a React state update on an unmounted component.' warning in the console.\r\n const isMounted = React.useRef(false);\r\n React.useEffect(() => {\r\n isMounted.current = true;\r\n return () => {\r\n isMounted.current = false;\r\n\r\n // We close any open dialogs that we might have opened\r\n // This was added because the modal dialog remained remained displayed after the session expired.\r\n ModalDialogManager.closeDialog();\r\n };\r\n }, []);\r\n\r\n const handleFilterTextChanged = React.useCallback((event: React.ChangeEvent<HTMLInputElement>) => {\r\n setSourceFilterString(event.target.value);\r\n }, []);\r\n\r\n const { loadingSources, sources, activeViewport, backgroundLayers, overlayLayers, mapLayerOptions } = useSourceMapContext();\r\n const mapTypesOptions = mapLayerOptions?.mapTypeOptions;\r\n const iTwinId = activeViewport?.iModel?.iTwinId;\r\n const iModelId = activeViewport?.iModel?.iModelId;\r\n\r\n const styleContainsLayer = React.useCallback((name: string) => {\r\n if (backgroundLayers) {\r\n if (-1 !== backgroundLayers.findIndex((layer) => layer.name === name))\r\n return true;\r\n }\r\n if (overlayLayers) {\r\n if (-1 !== overlayLayers.findIndex((layer) => layer.name === name))\r\n return true;\r\n }\r\n return false;\r\n }, [backgroundLayers, overlayLayers]);\r\n\r\n const handleModalUrlDialogOk = React.useCallback((action: LayerAction) => {\r\n if (LayerAction.Attached === action) {\r\n // close popup and refresh UI\r\n onLayerAttached();\r\n }\r\n\r\n resumeOutsideClick();\r\n }, [onLayerAttached, resumeOutsideClick]);\r\n\r\n const handleModalUrlDialogCancel = React.useCallback(() => {\r\n // close popup and refresh UI\r\n setLoading(false);\r\n ModalDialogManager.closeDialog();\r\n resumeOutsideClick();\r\n }, [resumeOutsideClick]);\r\n\r\n React.useEffect(() => {\r\n async function attemptToAddLayer(layerName: string) {\r\n if (layerName && activeViewport) {\r\n // if the layer is not in the style add it now.\r\n if (undefined === backgroundLayers?.find((layer) => layerName === layer.name) && undefined === overlayLayers?.find((layer) => layerName === layer.name)) {\r\n const mapLayerSettings = sources?.find((source) => source.name === layerName);\r\n if (mapLayerSettings === undefined) {\r\n return;\r\n }\r\n\r\n try {\r\n if (isMounted.current) {\r\n setLoading(true);\r\n }\r\n\r\n const { status, subLayers } = await mapLayerSettings.validateSource();\r\n if (status === MapLayerSourceStatus.Valid || status === MapLayerSourceStatus.RequireAuth) {\r\n\r\n if (status === MapLayerSourceStatus.Valid) {\r\n const settings = mapLayerSettings.toLayerSettings(subLayers);\r\n\r\n if (settings) {\r\n activeViewport.displayStyle.attachMapLayer({settings, isOverlay});\r\n\r\n activeViewport.invalidateRenderPlan();\r\n\r\n const msg = IModelApp.localization.getLocalizedString(\"mapLayers:Messages.MapLayerAttached\", { sourceName: settings.name, sourceUrl: settings.url });\r\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, msg));\r\n }\r\n\r\n if (isMounted.current) {\r\n setLoading(false);\r\n }\r\n if (onLayerAttached) {\r\n onLayerAttached();\r\n }\r\n\r\n } else if (status === MapLayerSourceStatus.RequireAuth && isMounted.current) {\r\n ModalDialogManager.openDialog(\r\n <MapUrlDialog\r\n activeViewport={activeViewport}\r\n isOverlay={isOverlay}\r\n layerRequiringCredentials={mapLayerSettings.toJSON()}\r\n onOkResult={()=>handleModalUrlDialogOk(LayerAction.Attached)}\r\n onCancelResult={handleModalUrlDialogCancel}\r\n mapTypesOptions={mapTypesOptions} />\r\n );\r\n if (onHandleOutsideClick) {\r\n onHandleOutsideClick(false);\r\n }\r\n }\r\n\r\n } else {\r\n const msg = IModelApp.localization.getLocalizedString(\"mapLayers:Messages.MapLayerValidationFailed\", { sourceUrl: mapLayerSettings.url });\r\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Error, msg));\r\n if (isMounted.current) {\r\n setLoading(false);\r\n }\r\n }\r\n } catch (err) {\r\n if (isMounted.current) {\r\n setLoading(false);\r\n }\r\n const msg = IModelApp.localization.getLocalizedString(\"mapLayers:Messages.MapLayerAttachError\", { error: err, sourceUrl: mapLayerSettings.url });\r\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Error, msg));\r\n }\r\n }\r\n\r\n }\r\n return;\r\n }\r\n\r\n if (layerNameToAdd) {\r\n attemptToAddLayer(layerNameToAdd); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n\r\n if (isMounted.current) {\r\n setLayerNameToAdd(undefined);\r\n }\r\n }\r\n }, [setLayerNameToAdd, layerNameToAdd, activeViewport, sources, backgroundLayers, isOverlay, overlayLayers, onLayerAttached, handleModalUrlDialogOk, mapTypesOptions, handleModalUrlDialogCancel, onHandleOutsideClick]);\r\n\r\n const options = React.useMemo(() => sources?.filter((source) => !styleContainsLayer(source.name)), [sources, styleContainsLayer]);\r\n const filteredOptions = React.useMemo(() => {\r\n if (undefined === sourceFilterString || 0 === sourceFilterString.length) {\r\n return options;\r\n } else {\r\n return options?.filter((option) => option.name.toLowerCase().includes(sourceFilterString?.toLowerCase()));\r\n }\r\n }, [options, sourceFilterString]);\r\n\r\n const handleAddNewMapSource = React.useCallback(() => {\r\n ModalDialogManager.openDialog(<MapUrlDialog\r\n activeViewport={activeViewport}\r\n isOverlay={isOverlay}\r\n onOkResult={()=>handleModalUrlDialogOk(LayerAction.Attached)}\r\n onCancelResult={handleModalUrlDialogCancel}\r\n mapTypesOptions={mapTypesOptions} />);\r\n if (onHandleOutsideClick) {\r\n onHandleOutsideClick(false);\r\n }\r\n return;\r\n }, [activeViewport, handleModalUrlDialogCancel, handleModalUrlDialogOk, isOverlay, mapTypesOptions, onHandleOutsideClick]);\r\n\r\n const handleAttach = React.useCallback((mapName: string) => {\r\n setLayerNameToAdd(mapName);\r\n }, []);\r\n\r\n const handleKeypressOnSourceList = React.useCallback((event: React.KeyboardEvent<HTMLUListElement>) => {\r\n const key = event.key;\r\n if (key === \"Enter\") {\r\n event.preventDefault();\r\n const mapName = event.currentTarget?.dataset?.value;\r\n if (mapName && mapName.length) {\r\n handleAttach(mapName);\r\n }\r\n }\r\n }, [handleAttach]);\r\n\r\n const onListboxValueChange = React.useCallback((mapName: string) => {\r\n setLayerNameToAdd(mapName);\r\n }, []);\r\n\r\n const handleNoConfirmation = React.useCallback((_layerName: string) => {\r\n ModalDialogManager.closeDialog();\r\n resumeOutsideClick();\r\n }, [resumeOutsideClick]);\r\n\r\n const handleYesConfirmation = React.useCallback(async (source: MapLayerSource) => {\r\n const layerName = source.name;\r\n if (!!iTwinId) {\r\n try {\r\n await MapLayerPreferences.deleteByName(source, iTwinId, iModelId);\r\n const msg = MapLayersUI.localization.getLocalizedString(\"mapLayers:CustomAttach.RemoveLayerDefSuccess\", { layerName });\r\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, msg));\r\n } catch (err: any) {\r\n const msg = MapLayersUI.localization.getLocalizedString(\"mapLayers:CustomAttach.RemoveLayerDefError\", { layerName });\r\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Error, msg));\r\n }\r\n }\r\n\r\n ModalDialogManager.closeDialog();\r\n resumeOutsideClick();\r\n }, [iTwinId, iModelId, resumeOutsideClick]);\r\n\r\n /*\r\n Handle Remove layer button clicked\r\n */\r\n const onItemRemoveButtonClicked = React.useCallback((source, event) => {\r\n event.stopPropagation(); // We don't want the owning ListBox to react on mouse click.\r\n\r\n const layerName = source.name;\r\n\r\n const msg = MapLayersUI.localization.getLocalizedString(\"mapLayers:CustomAttach.RemoveLayerDefDialogMessage\", { layerName });\r\n ModalDialogManager.openDialog(\r\n <ConfirmMessageDialog\r\n className=\"map-sources-delete-confirmation\"\r\n title={removeLayerDefDialogTitle}\r\n message={msg}\r\n maxWidth={400}\r\n onClose={() => handleNoConfirmation(layerName)}\r\n onEscape={() => handleNoConfirmation(layerName)}\r\n onYesResult={async () => handleYesConfirmation(source)}\r\n onNoResult={() => handleNoConfirmation(layerName)}\r\n />\r\n );\r\n if (onHandleOutsideClick) {\r\n onHandleOutsideClick(false);\r\n }\r\n }, [handleNoConfirmation, handleYesConfirmation, onHandleOutsideClick, removeLayerDefDialogTitle]);\r\n\r\n /*\r\n Handle Edit layer button clicked\r\n */\r\n const onItemEditButtonClicked = React.useCallback((event) => {\r\n event.stopPropagation(); // We don't want the owning ListBox to react on mouse click.\r\n\r\n const targetLayerName = event?.currentTarget?.parentNode?.dataset?.value;\r\n const matchingSource = sources.find((layerSource) => layerSource.name === targetLayerName);\r\n\r\n // we expect a single layer source matching this name\r\n if (matchingSource === undefined) {\r\n return;\r\n }\r\n ModalDialogManager.openDialog(<MapUrlDialog\r\n activeViewport={activeViewport}\r\n isOverlay={isOverlay}\r\n mapLayerSourceToEdit={matchingSource}\r\n onOkResult={()=>handleModalUrlDialogOk(LayerAction.Edited)}\r\n onCancelResult={handleModalUrlDialogCancel}\r\n mapTypesOptions={mapTypesOptions} />);\r\n\r\n if (onHandleOutsideClick) {\r\n onHandleOutsideClick(false);\r\n }\r\n }, [activeViewport, handleModalUrlDialogCancel, handleModalUrlDialogOk, isOverlay, mapTypesOptions, onHandleOutsideClick, sources]);\r\n\r\n return (\r\n <div className=\"map-manager-header\">\r\n {(loading || loadingSources) && <UiCore.LoadingSpinner message={loadingMapSources} />}\r\n <div className=\"map-manager-source-listbox-header\">\r\n <Input type=\"text\" className=\"map-manager-source-list-filter\"\r\n placeholder={placeholderLabel}\r\n value={sourceFilterString}\r\n onChange={handleFilterTextChanged}\r\n size=\"small\" />\r\n <Button className=\"map-manager-add-source-button\" title={addCustomLayerToolTip} onClick={handleAddNewMapSource}>\r\n {addCustomLayerLabel}</Button>\r\n </div>\r\n <div className=\"map-manager-sources\">\r\n <UiCore.Listbox\r\n id=\"map-sources\"\r\n selectedValue={layerNameToAdd}\r\n className=\"map-manager-source-list\"\r\n onKeyPress={handleKeypressOnSourceList}\r\n onListboxValueChange={onListboxValueChange} >\r\n {\r\n filteredOptions?.map((source) =>\r\n <UiCore.ListboxItem\r\n key={source.name}\r\n className=\"map-source-list-entry\"\r\n value={source.name}\r\n onMouseEnter={() => setLayerNameUnderCursor(source.name)}\r\n onMouseLeave={() => setLayerNameUnderCursor(undefined)}>\r\n <span className=\"map-source-list-entry-name\" title={source.name}>{source.name}</span>\r\n\r\n { // Display the delete icon only when the mouse over a specific item\r\n // otherwise list feels cluttered.\r\n (!!iTwinId && layerNameUnderCursor && layerNameUnderCursor === source.name) &&\r\n <>\r\n <Button\r\n size=\"small\"\r\n styleType=\"borderless\"\r\n className=\"map-source-list-entry-button\"\r\n title={editLayerDefButtonTitle}\r\n onClick={onItemEditButtonClicked}>\r\n <UiCore.Icon iconSpec=\"icon-edit\" />\r\n </Button>\r\n <Button\r\n size=\"small\"\r\n styleType=\"borderless\"\r\n className=\"map-source-list-entry-button\"\r\n title={removeLayerDefButtonTitle}\r\n onClick={(event: React.MouseEvent) => { onItemRemoveButtonClicked(source, event); }}>\r\n <UiCore.Icon iconSpec=\"icon-delete\" />\r\n </Button>\r\n </>}\r\n\r\n </UiCore.ListboxItem>\r\n )\r\n }\r\n </UiCore.Listbox>\r\n </div>\r\n </div>\r\n\r\n );\r\n}\r\n\r\n/** @internal */\r\nexport enum AttachLayerButtonType {\r\n Primary,\r\n Blue,\r\n Icon\r\n}\r\nexport interface AttachLayerPopupButtonProps {\r\n isOverlay: boolean;\r\n buttonType?: AttachLayerButtonType;\r\n disabled?: boolean;\r\n}\r\n\r\n/** @internal */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function AttachLayerPopupButton(props: AttachLayerPopupButtonProps) {\r\n const { showAttachLayerLabel, hideAttachLayerLabel, addCustomLayerButtonLabel } = React.useMemo(() => {\r\n return {\r\n showAttachLayerLabel: MapLayersUI.localization.getLocalizedString(\"mapLayers:AttachLayerPopup.Attach\"),\r\n hideAttachLayerLabel: MapLayersUI.localization.getLocalizedString(\"mapLayers:AttachLayerPopup.Close\"),\r\n addCustomLayerButtonLabel: MapLayersUI.localization.getLocalizedString(\"mapLayers:CustomAttach.AddCustomLayerButtonLabel\"),\r\n };\r\n }, []);\r\n\r\n const [handleOutsideClick, setHandleOutsideClick] = React.useState(true);\r\n const [popupOpen, setPopupOpen] = React.useState(false);\r\n const buttonRef = React.useRef<HTMLButtonElement>(null);\r\n const panelRef = React.useRef<HTMLDivElement>(null);\r\n\r\n // 'isMounted' is used to prevent any async operation once the hook has been\r\n // unloaded. Otherwise we get a 'Can't perform a React state update on an unmounted component.' warning in the console.\r\n const isMounted = React.useRef(false);\r\n React.useEffect(() => {\r\n isMounted.current = true;\r\n return () => {\r\n isMounted.current = false;\r\n };\r\n }, []);\r\n\r\n const togglePopup = React.useCallback(() => {\r\n setPopupOpen(!popupOpen);\r\n }, [popupOpen]);\r\n\r\n const handleClosePopup = React.useCallback(() => {\r\n setPopupOpen(false);\r\n }, []);\r\n\r\n const onHandleOutsideClick = React.useCallback((event: MouseEvent) => {\r\n if (!handleOutsideClick) {\r\n return;\r\n }\r\n\r\n // If clicking on button that open panel - don't trigger outside click processing\r\n if (buttonRef?.current && buttonRef?.current.contains(event.target as Node)) {\r\n return;\r\n }\r\n\r\n // If clicking the panel, this is not an outside clicked\r\n if (panelRef.current && panelRef?.current.contains(event.target as Node)) {\r\n return;\r\n }\r\n\r\n // If we reach this point, we got an outside clicked, no close the popup\r\n setPopupOpen(false);\r\n\r\n }, [handleOutsideClick]);\r\n\r\n const { refreshFromStyle } = useSourceMapContext();\r\n\r\n const handleLayerAttached = React.useCallback(() => {\r\n if (!isMounted.current) {\r\n return;\r\n }\r\n setPopupOpen(false);\r\n refreshFromStyle();\r\n }, [refreshFromStyle]);\r\n\r\n function renderButton(): React.ReactNode {\r\n let button: React.ReactNode;\r\n\r\n if (props.buttonType === undefined || props.buttonType === AttachLayerButtonType.Icon) {\r\n button = (\r\n <Button disabled={props.disabled} size=\"small\" styleType=\"borderless\" ref={buttonRef} className=\"map-manager-attach-layer-button\" title={popupOpen ? hideAttachLayerLabel : showAttachLayerLabel}\r\n onClick={togglePopup}>\r\n <UiCore.WebFontIcon iconName=\"icon-add\" />\r\n </Button>\r\n );\r\n } else {\r\n const determineStyleType = () => {\r\n switch (props.buttonType) {\r\n case AttachLayerButtonType.Blue:\r\n return \"high-visibility\";\r\n case AttachLayerButtonType.Primary:\r\n default:\r\n return \"cta\";\r\n }\r\n };\r\n const styleType = determineStyleType();\r\n button = (\r\n <Button disabled={props.disabled} ref={buttonRef} styleType={styleType} title={popupOpen ? hideAttachLayerLabel : showAttachLayerLabel}\r\n onClick={togglePopup}>{addCustomLayerButtonLabel}</Button>\r\n );\r\n }\r\n\r\n return button;\r\n }\r\n\r\n return (\r\n <>\r\n {renderButton()}\r\n <UiCore.Popup\r\n isOpen={popupOpen}\r\n position={RelativePosition.BottomRight}\r\n onClose={handleClosePopup}\r\n onOutsideClick={onHandleOutsideClick}\r\n target={buttonRef.current}\r\n closeOnEnter={false}\r\n closeOnContextMenu={false}\r\n >\r\n <div ref={panelRef} className=\"map-sources-popup-panel\" >\r\n <AttachLayerPanel\r\n isOverlay={props.isOverlay}\r\n onLayerAttached={handleLayerAttached}\r\n onHandleOutsideClick={setHandleOutsideClick}/>\r\n </div>\r\n </UiCore.Popup >\r\n </>\r\n );\r\n}\r\n"]}
1
+ {"version":3,"file":"AttachLayerPopupButton.js","sourceRoot":"","sources":["../../../../src/ui/widget/AttachLayerPopupButton.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAkB,oBAAoB,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AACpI,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,mCAAmC;AAEnC,IAAK,WAGJ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,KAAK,qBAAqB,CAAC,IAAI;wBAC7B,OAAO,iBAAiB,CAAC;oBAC3B,KAAK,qBAAqB,CAAC,OAAO,CAAC;oBACnC;wBACE,OAAO,KAAK,CAAC;iBAChB;YACH,CAAC,CAAC;YACF,MAAM,SAAS,GAAG,kBAAkB,EAAE,CAAC;YACvC,MAAM,GAAG,CACP,oBAAC,MAAM,IAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,oBAAoB,EACpI,OAAO,EAAE,WAAW,IAAG,yBAAyB,CAAU,CAC7D,CAAC;SACH;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,OAAO,CACL;QACG,YAAY,EAAE;QACf,oBAAC,MAAM,CAAC,KAAK,IACX,MAAM,EAAE,SAAS,EACjB,QAAQ,EAAE,gBAAgB,CAAC,WAAW,EACtC,OAAO,EAAE,gBAAgB,EACzB,cAAc,EAAE,oBAAoB,EACpC,MAAM,EAAE,SAAS,CAAC,OAAO,EACzB,YAAY,EAAE,KAAK,EACnB,kBAAkB,EAAE,KAAK;YAEzB,6BAAK,GAAG,EAAE,QAAQ,EAAE,SAAS,EAAC,yBAAyB;gBACrD,oBAAC,gBAAgB,IACf,SAAS,EAAE,KAAK,CAAC,SAAS,EAC1B,eAAe,EAAE,mBAAmB,EACpC,oBAAoB,EAAE,qBAAqB,GAAG,CAC5C,CACQ,CACf,CACJ,CAAC;AACJ,CAAC","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\nimport * as React from \"react\";\r\nimport { IModelApp, MapLayerSource, MapLayerSourceStatus, NotifyMessageDetails, OutputMessagePriority } from \"@itwin/core-frontend\";\r\nimport { RelativePosition } from \"@itwin/appui-abstract\";\r\nimport * as UiCore from \"@itwin/core-react\";\r\nimport { UiFramework } from \"@itwin/appui-react\";\r\nimport { useSourceMapContext } from \"./MapLayerManager\";\r\nimport { MapUrlDialog } from \"./MapUrlDialog\";\r\nimport { ConfirmMessageDialog } from \"./ConfirmMessageDialog\";\r\nimport { Button, Input } from \"@itwin/itwinui-react\";\r\nimport { MapLayerPreferences } from \"../../MapLayerPreferences\";\r\nimport { MapLayersUI } from \"../../mapLayers\";\r\n\r\n// cSpell:ignore droppable Sublayer\r\n\r\nenum LayerAction {\r\n Attached,\r\n Edited\r\n}\r\n\r\ninterface AttachLayerPanelProps {\r\n isOverlay: boolean;\r\n onLayerAttached: () => void;\r\n onHandleOutsideClick?: (shouldHandle: boolean) => void;\r\n}\r\n\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nfunction AttachLayerPanel({ isOverlay, onLayerAttached, onHandleOutsideClick }: AttachLayerPanelProps) {\r\n const [layerNameToAdd, setLayerNameToAdd] = React.useState<string | undefined>();\r\n const [sourceFilterString, setSourceFilterString] = React.useState<string | undefined>();\r\n\r\n const { placeholderLabel, addCustomLayerLabel, addCustomLayerToolTip, loadingMapSources, removeLayerDefButtonTitle, editLayerDefButtonTitle, removeLayerDefDialogTitle } = React.useMemo(() => {\r\n return {\r\n placeholderLabel: MapLayersUI.localization.getLocalizedString(\"mapLayers:CustomAttach.SearchPlaceholder\"),\r\n addCustomLayerLabel: MapLayersUI.localization.getLocalizedString(\"mapLayers:CustomAttach.Custom\"),\r\n addCustomLayerToolTip: MapLayersUI.localization.getLocalizedString(\"mapLayers:CustomAttach.AttachCustomLayer\"),\r\n loadingMapSources: MapLayersUI.localization.getLocalizedString(\"mapLayers:CustomAttach.LoadingMapSources\"),\r\n removeLayerDefButtonTitle: MapLayersUI.localization.getLocalizedString(\"mapLayers:CustomAttach.RemoveLayerDefButtonTitle\"),\r\n editLayerDefButtonTitle: MapLayersUI.localization.getLocalizedString(\"mapLayers:CustomAttach.EditLayerDefButtonTitle\"),\r\n removeLayerDefDialogTitle: MapLayersUI.localization.getLocalizedString(\"mapLayers:CustomAttach.RemoveLayerDefDialogTitle\"),\r\n };\r\n }, []);\r\n\r\n const [loading, setLoading] = React.useState(false);\r\n const [layerNameUnderCursor, setLayerNameUnderCursor] = React.useState<string | undefined>();\r\n\r\n const resumeOutsideClick = React.useCallback(() => {\r\n if (onHandleOutsideClick) {\r\n onHandleOutsideClick(true);\r\n }\r\n }, [onHandleOutsideClick]);\r\n\r\n // 'isMounted' is used to prevent any async operation once the hook has been\r\n // unloaded. Otherwise we get a 'Can't perform a React state update on an unmounted component.' warning in the console.\r\n const isMounted = React.useRef(false);\r\n React.useEffect(() => {\r\n isMounted.current = true;\r\n return () => {\r\n isMounted.current = false;\r\n\r\n // We close any open dialogs that we might have opened\r\n // This was added because the modal dialog remained remained displayed after the session expired.\r\n UiFramework.dialogs.modal.close();\r\n };\r\n }, []);\r\n\r\n const handleFilterTextChanged = React.useCallback((event: React.ChangeEvent<HTMLInputElement>) => {\r\n setSourceFilterString(event.target.value);\r\n }, []);\r\n\r\n const { loadingSources, sources, activeViewport, backgroundLayers, overlayLayers, mapLayerOptions } = useSourceMapContext();\r\n const mapTypesOptions = mapLayerOptions?.mapTypeOptions;\r\n const iTwinId = activeViewport?.iModel?.iTwinId;\r\n const iModelId = activeViewport?.iModel?.iModelId;\r\n\r\n const styleContainsLayer = React.useCallback((name: string) => {\r\n if (backgroundLayers) {\r\n if (-1 !== backgroundLayers.findIndex((layer) => layer.name === name))\r\n return true;\r\n }\r\n if (overlayLayers) {\r\n if (-1 !== overlayLayers.findIndex((layer) => layer.name === name))\r\n return true;\r\n }\r\n return false;\r\n }, [backgroundLayers, overlayLayers]);\r\n\r\n const handleModalUrlDialogOk = React.useCallback((action: LayerAction) => {\r\n if (LayerAction.Attached === action) {\r\n // close popup and refresh UI\r\n onLayerAttached();\r\n }\r\n\r\n resumeOutsideClick();\r\n }, [onLayerAttached, resumeOutsideClick]);\r\n\r\n const handleModalUrlDialogCancel = React.useCallback(() => {\r\n // close popup and refresh UI\r\n setLoading(false);\r\n UiFramework.dialogs.modal.close();\r\n resumeOutsideClick();\r\n }, [resumeOutsideClick]);\r\n\r\n React.useEffect(() => {\r\n async function attemptToAddLayer(layerName: string) {\r\n if (layerName && activeViewport) {\r\n // if the layer is not in the style add it now.\r\n if (undefined === backgroundLayers?.find((layer) => layerName === layer.name) && undefined === overlayLayers?.find((layer) => layerName === layer.name)) {\r\n const mapLayerSettings = sources?.find((source) => source.name === layerName);\r\n if (mapLayerSettings === undefined) {\r\n return;\r\n }\r\n\r\n try {\r\n if (isMounted.current) {\r\n setLoading(true);\r\n }\r\n\r\n const { status, subLayers } = await mapLayerSettings.validateSource();\r\n if (status === MapLayerSourceStatus.Valid || status === MapLayerSourceStatus.RequireAuth) {\r\n\r\n if (status === MapLayerSourceStatus.Valid) {\r\n const settings = mapLayerSettings.toLayerSettings(subLayers);\r\n\r\n if (settings) {\r\n activeViewport.displayStyle.attachMapLayer({settings, isOverlay});\r\n\r\n activeViewport.invalidateRenderPlan();\r\n\r\n const msg = IModelApp.localization.getLocalizedString(\"mapLayers:Messages.MapLayerAttached\", { sourceName: settings.name, sourceUrl: settings.url });\r\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, msg));\r\n }\r\n\r\n if (isMounted.current) {\r\n setLoading(false);\r\n }\r\n if (onLayerAttached) {\r\n onLayerAttached();\r\n }\r\n\r\n } else if (status === MapLayerSourceStatus.RequireAuth && isMounted.current) {\r\n UiFramework.dialogs.modal.open(\r\n <MapUrlDialog\r\n activeViewport={activeViewport}\r\n isOverlay={isOverlay}\r\n layerRequiringCredentials={mapLayerSettings.toJSON()}\r\n onOkResult={()=>handleModalUrlDialogOk(LayerAction.Attached)}\r\n onCancelResult={handleModalUrlDialogCancel}\r\n mapTypesOptions={mapTypesOptions} />\r\n );\r\n if (onHandleOutsideClick) {\r\n onHandleOutsideClick(false);\r\n }\r\n }\r\n\r\n } else {\r\n const msg = IModelApp.localization.getLocalizedString(\"mapLayers:Messages.MapLayerValidationFailed\", { sourceUrl: mapLayerSettings.url });\r\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Error, msg));\r\n if (isMounted.current) {\r\n setLoading(false);\r\n }\r\n }\r\n } catch (err) {\r\n if (isMounted.current) {\r\n setLoading(false);\r\n }\r\n const msg = IModelApp.localization.getLocalizedString(\"mapLayers:Messages.MapLayerAttachError\", { error: err, sourceUrl: mapLayerSettings.url });\r\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Error, msg));\r\n }\r\n }\r\n\r\n }\r\n return;\r\n }\r\n\r\n if (layerNameToAdd) {\r\n attemptToAddLayer(layerNameToAdd); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n\r\n if (isMounted.current) {\r\n setLayerNameToAdd(undefined);\r\n }\r\n }\r\n }, [setLayerNameToAdd, layerNameToAdd, activeViewport, sources, backgroundLayers, isOverlay, overlayLayers, onLayerAttached, handleModalUrlDialogOk, mapTypesOptions, handleModalUrlDialogCancel, onHandleOutsideClick]);\r\n\r\n const options = React.useMemo(() => sources?.filter((source) => !styleContainsLayer(source.name)), [sources, styleContainsLayer]);\r\n const filteredOptions = React.useMemo(() => {\r\n if (undefined === sourceFilterString || 0 === sourceFilterString.length) {\r\n return options;\r\n } else {\r\n return options?.filter((option) => option.name.toLowerCase().includes(sourceFilterString?.toLowerCase()));\r\n }\r\n }, [options, sourceFilterString]);\r\n\r\n const handleAddNewMapSource = React.useCallback(() => {\r\n UiFramework.dialogs.modal.open(<MapUrlDialog\r\n activeViewport={activeViewport}\r\n isOverlay={isOverlay}\r\n onOkResult={()=>handleModalUrlDialogOk(LayerAction.Attached)}\r\n onCancelResult={handleModalUrlDialogCancel}\r\n mapTypesOptions={mapTypesOptions} />);\r\n if (onHandleOutsideClick) {\r\n onHandleOutsideClick(false);\r\n }\r\n return;\r\n }, [activeViewport, handleModalUrlDialogCancel, handleModalUrlDialogOk, isOverlay, mapTypesOptions, onHandleOutsideClick]);\r\n\r\n const handleAttach = React.useCallback((mapName: string) => {\r\n setLayerNameToAdd(mapName);\r\n }, []);\r\n\r\n const handleKeypressOnSourceList = React.useCallback((event: React.KeyboardEvent<HTMLUListElement>) => {\r\n const key = event.key;\r\n if (key === \"Enter\") {\r\n event.preventDefault();\r\n const mapName = event.currentTarget?.dataset?.value;\r\n if (mapName && mapName.length) {\r\n handleAttach(mapName);\r\n }\r\n }\r\n }, [handleAttach]);\r\n\r\n const onListboxValueChange = React.useCallback((mapName: string) => {\r\n setLayerNameToAdd(mapName);\r\n }, []);\r\n\r\n const handleNoConfirmation = React.useCallback((_layerName: string) => {\r\n UiFramework.dialogs.modal.close();\r\n resumeOutsideClick();\r\n }, [resumeOutsideClick]);\r\n\r\n const handleYesConfirmation = React.useCallback(async (source: MapLayerSource) => {\r\n const layerName = source.name;\r\n if (!!iTwinId) {\r\n try {\r\n await MapLayerPreferences.deleteByName(source, iTwinId, iModelId);\r\n const msg = MapLayersUI.localization.getLocalizedString(\"mapLayers:CustomAttach.RemoveLayerDefSuccess\", { layerName });\r\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, msg));\r\n } catch (err: any) {\r\n const msg = MapLayersUI.localization.getLocalizedString(\"mapLayers:CustomAttach.RemoveLayerDefError\", { layerName });\r\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Error, msg));\r\n }\r\n }\r\n\r\n UiFramework.dialogs.modal.close();\r\n resumeOutsideClick();\r\n }, [iTwinId, iModelId, resumeOutsideClick]);\r\n\r\n /*\r\n Handle Remove layer button clicked\r\n */\r\n const onItemRemoveButtonClicked = React.useCallback((source, event) => {\r\n event.stopPropagation(); // We don't want the owning ListBox to react on mouse click.\r\n\r\n const layerName = source.name;\r\n\r\n const msg = MapLayersUI.localization.getLocalizedString(\"mapLayers:CustomAttach.RemoveLayerDefDialogMessage\", { layerName });\r\n UiFramework.dialogs.modal.open(\r\n <ConfirmMessageDialog\r\n className=\"map-sources-delete-confirmation\"\r\n title={removeLayerDefDialogTitle}\r\n message={msg}\r\n maxWidth={400}\r\n onClose={() => handleNoConfirmation(layerName)}\r\n onEscape={() => handleNoConfirmation(layerName)}\r\n onYesResult={async () => handleYesConfirmation(source)}\r\n onNoResult={() => handleNoConfirmation(layerName)}\r\n />\r\n );\r\n if (onHandleOutsideClick) {\r\n onHandleOutsideClick(false);\r\n }\r\n }, [handleNoConfirmation, handleYesConfirmation, onHandleOutsideClick, removeLayerDefDialogTitle]);\r\n\r\n /*\r\n Handle Edit layer button clicked\r\n */\r\n const onItemEditButtonClicked = React.useCallback((event) => {\r\n event.stopPropagation(); // We don't want the owning ListBox to react on mouse click.\r\n\r\n const targetLayerName = event?.currentTarget?.parentNode?.dataset?.value;\r\n const matchingSource = sources.find((layerSource) => layerSource.name === targetLayerName);\r\n\r\n // we expect a single layer source matching this name\r\n if (matchingSource === undefined) {\r\n return;\r\n }\r\n UiFramework.dialogs.modal.open(<MapUrlDialog\r\n activeViewport={activeViewport}\r\n isOverlay={isOverlay}\r\n mapLayerSourceToEdit={matchingSource}\r\n onOkResult={()=>handleModalUrlDialogOk(LayerAction.Edited)}\r\n onCancelResult={handleModalUrlDialogCancel}\r\n mapTypesOptions={mapTypesOptions} />);\r\n\r\n if (onHandleOutsideClick) {\r\n onHandleOutsideClick(false);\r\n }\r\n }, [activeViewport, handleModalUrlDialogCancel, handleModalUrlDialogOk, isOverlay, mapTypesOptions, onHandleOutsideClick, sources]);\r\n\r\n return (\r\n <div className=\"map-manager-header\">\r\n {(loading || loadingSources) && <UiCore.LoadingSpinner message={loadingMapSources} />}\r\n <div className=\"map-manager-source-listbox-header\">\r\n <Input type=\"text\" className=\"map-manager-source-list-filter\"\r\n placeholder={placeholderLabel}\r\n value={sourceFilterString}\r\n onChange={handleFilterTextChanged}\r\n size=\"small\" />\r\n <Button className=\"map-manager-add-source-button\" title={addCustomLayerToolTip} onClick={handleAddNewMapSource}>\r\n {addCustomLayerLabel}</Button>\r\n </div>\r\n <div className=\"map-manager-sources\">\r\n <UiCore.Listbox\r\n id=\"map-sources\"\r\n selectedValue={layerNameToAdd}\r\n className=\"map-manager-source-list\"\r\n onKeyPress={handleKeypressOnSourceList}\r\n onListboxValueChange={onListboxValueChange} >\r\n {\r\n filteredOptions?.map((source) =>\r\n <UiCore.ListboxItem\r\n key={source.name}\r\n className=\"map-source-list-entry\"\r\n value={source.name}\r\n onMouseEnter={() => setLayerNameUnderCursor(source.name)}\r\n onMouseLeave={() => setLayerNameUnderCursor(undefined)}>\r\n <span className=\"map-source-list-entry-name\" title={source.name}>{source.name}</span>\r\n\r\n { // Display the delete icon only when the mouse over a specific item\r\n // otherwise list feels cluttered.\r\n (!!iTwinId && layerNameUnderCursor && layerNameUnderCursor === source.name) &&\r\n <>\r\n <Button\r\n size=\"small\"\r\n styleType=\"borderless\"\r\n className=\"map-source-list-entry-button\"\r\n title={editLayerDefButtonTitle}\r\n onClick={onItemEditButtonClicked}>\r\n <UiCore.Icon iconSpec=\"icon-edit\" />\r\n </Button>\r\n <Button\r\n size=\"small\"\r\n styleType=\"borderless\"\r\n className=\"map-source-list-entry-button\"\r\n title={removeLayerDefButtonTitle}\r\n onClick={(event: React.MouseEvent) => { onItemRemoveButtonClicked(source, event); }}>\r\n <UiCore.Icon iconSpec=\"icon-delete\" />\r\n </Button>\r\n </>}\r\n\r\n </UiCore.ListboxItem>\r\n )\r\n }\r\n </UiCore.Listbox>\r\n </div>\r\n </div>\r\n\r\n );\r\n}\r\n\r\n/** @internal */\r\nexport enum AttachLayerButtonType {\r\n Primary,\r\n Blue,\r\n Icon\r\n}\r\nexport interface AttachLayerPopupButtonProps {\r\n isOverlay: boolean;\r\n buttonType?: AttachLayerButtonType;\r\n disabled?: boolean;\r\n}\r\n\r\n/** @internal */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function AttachLayerPopupButton(props: AttachLayerPopupButtonProps) {\r\n const { showAttachLayerLabel, hideAttachLayerLabel, addCustomLayerButtonLabel } = React.useMemo(() => {\r\n return {\r\n showAttachLayerLabel: MapLayersUI.localization.getLocalizedString(\"mapLayers:AttachLayerPopup.Attach\"),\r\n hideAttachLayerLabel: MapLayersUI.localization.getLocalizedString(\"mapLayers:AttachLayerPopup.Close\"),\r\n addCustomLayerButtonLabel: MapLayersUI.localization.getLocalizedString(\"mapLayers:CustomAttach.AddCustomLayerButtonLabel\"),\r\n };\r\n }, []);\r\n\r\n const [handleOutsideClick, setHandleOutsideClick] = React.useState(true);\r\n const [popupOpen, setPopupOpen] = React.useState(false);\r\n const buttonRef = React.useRef<HTMLButtonElement>(null);\r\n const panelRef = React.useRef<HTMLDivElement>(null);\r\n\r\n // 'isMounted' is used to prevent any async operation once the hook has been\r\n // unloaded. Otherwise we get a 'Can't perform a React state update on an unmounted component.' warning in the console.\r\n const isMounted = React.useRef(false);\r\n React.useEffect(() => {\r\n isMounted.current = true;\r\n return () => {\r\n isMounted.current = false;\r\n };\r\n }, []);\r\n\r\n const togglePopup = React.useCallback(() => {\r\n setPopupOpen(!popupOpen);\r\n }, [popupOpen]);\r\n\r\n const handleClosePopup = React.useCallback(() => {\r\n setPopupOpen(false);\r\n }, []);\r\n\r\n const onHandleOutsideClick = React.useCallback((event: MouseEvent) => {\r\n if (!handleOutsideClick) {\r\n return;\r\n }\r\n\r\n // If clicking on button that open panel - don't trigger outside click processing\r\n if (buttonRef?.current && buttonRef?.current.contains(event.target as Node)) {\r\n return;\r\n }\r\n\r\n // If clicking the panel, this is not an outside clicked\r\n if (panelRef.current && panelRef?.current.contains(event.target as Node)) {\r\n return;\r\n }\r\n\r\n // If we reach this point, we got an outside clicked, no close the popup\r\n setPopupOpen(false);\r\n\r\n }, [handleOutsideClick]);\r\n\r\n const { refreshFromStyle } = useSourceMapContext();\r\n\r\n const handleLayerAttached = React.useCallback(() => {\r\n if (!isMounted.current) {\r\n return;\r\n }\r\n setPopupOpen(false);\r\n refreshFromStyle();\r\n }, [refreshFromStyle]);\r\n\r\n function renderButton(): React.ReactNode {\r\n let button: React.ReactNode;\r\n\r\n if (props.buttonType === undefined || props.buttonType === AttachLayerButtonType.Icon) {\r\n button = (\r\n <Button disabled={props.disabled} size=\"small\" styleType=\"borderless\" ref={buttonRef} className=\"map-manager-attach-layer-button\" title={popupOpen ? hideAttachLayerLabel : showAttachLayerLabel}\r\n onClick={togglePopup}>\r\n <UiCore.WebFontIcon iconName=\"icon-add\" />\r\n </Button>\r\n );\r\n } else {\r\n const determineStyleType = () => {\r\n switch (props.buttonType) {\r\n case AttachLayerButtonType.Blue:\r\n return \"high-visibility\";\r\n case AttachLayerButtonType.Primary:\r\n default:\r\n return \"cta\";\r\n }\r\n };\r\n const styleType = determineStyleType();\r\n button = (\r\n <Button disabled={props.disabled} ref={buttonRef} styleType={styleType} title={popupOpen ? hideAttachLayerLabel : showAttachLayerLabel}\r\n onClick={togglePopup}>{addCustomLayerButtonLabel}</Button>\r\n );\r\n }\r\n\r\n return button;\r\n }\r\n\r\n return (\r\n <>\r\n {renderButton()}\r\n <UiCore.Popup\r\n isOpen={popupOpen}\r\n position={RelativePosition.BottomRight}\r\n onClose={handleClosePopup}\r\n onOutsideClick={onHandleOutsideClick}\r\n target={buttonRef.current}\r\n closeOnEnter={false}\r\n closeOnContextMenu={false}\r\n >\r\n <div ref={panelRef} className=\"map-sources-popup-panel\" >\r\n <AttachLayerPanel\r\n isOverlay={props.isOverlay}\r\n onLayerAttached={handleLayerAttached}\r\n onHandleOutsideClick={setHandleOutsideClick}/>\r\n </div>\r\n </UiCore.Popup >\r\n </>\r\n );\r\n}\r\n"]}
@@ -4,7 +4,7 @@
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
  /* eslint-disable deprecation/deprecation */
6
6
  // cSpell:ignore droppable Sublayer Basemap
7
- import { ModalDialogManager } from "@itwin/appui-react";
7
+ import { UiFramework } from "@itwin/appui-react";
8
8
  import { BaseMapLayerSettings, ColorByName, ColorDef, ImageMapLayerSettings } from "@itwin/core-common";
9
9
  import { WebFontIcon } from "@itwin/core-react";
10
10
  import { ColorPickerDialog, ColorSwatch } from "@itwin/imodel-components-react";
@@ -26,7 +26,7 @@ function getBaseMapFromStyle(displayStyle) {
26
26
  export function BasemapPanel(props) {
27
27
  const [useColorLabel] = React.useState(MapLayersUI.localization.getLocalizedString("mapLayers:Basemap.ColorFill"));
28
28
  const { activeViewport, bases } = useSourceMapContext();
29
- const [selectedBaseMap, setSelectedBaseMap] = React.useState(getBaseMapFromStyle(activeViewport === null || activeViewport === void 0 ? void 0 : activeViewport.displayStyle));
29
+ const [selectedBaseMap, setSelectedBaseMap] = React.useState(getBaseMapFromStyle(activeViewport?.displayStyle));
30
30
  const [baseMapTransparencyValue, setBaseMapTransparencyValue] = React.useState(() => {
31
31
  if (activeViewport)
32
32
  return activeViewport.displayStyle.baseMapTransparency;
@@ -87,7 +87,7 @@ export function BasemapPanel(props) {
87
87
  return baseMapOptions[0];
88
88
  }, [selectedBaseMap, baseMapOptions, baseIsMap]);
89
89
  const handleBackgroundColorDialogOk = React.useCallback((bgColorDef) => {
90
- ModalDialogManager.closeDialog();
90
+ UiFramework.dialogs.modal.close();
91
91
  if (activeViewport) {
92
92
  // change color and make sure previously set transparency is not lost.
93
93
  const curTransparency = activeViewport.displayStyle.backgroundMapBase instanceof ColorDef ? activeViewport.displayStyle.backgroundMapBase.getTransparency() : 0;
@@ -97,11 +97,11 @@ export function BasemapPanel(props) {
97
97
  }
98
98
  }, [activeViewport]);
99
99
  const handleBackgroundColorDialogCancel = React.useCallback(() => {
100
- ModalDialogManager.closeDialog();
100
+ UiFramework.dialogs.modal.close();
101
101
  }, []);
102
102
  const handleBgColorClick = React.useCallback((newColor, e) => {
103
103
  e.preventDefault();
104
- ModalDialogManager.openDialog(React.createElement(ColorPickerDialog, { dialogTitle: colorDialogTitle, color: newColor, colorPresets: presetColors, colorInputType: "rgb", onOkResult: handleBackgroundColorDialogOk, onCancelResult: handleBackgroundColorDialogCancel }));
104
+ UiFramework.dialogs.modal.open(React.createElement(ColorPickerDialog, { dialogTitle: colorDialogTitle, color: newColor, colorPresets: presetColors, colorInputType: "rgb", onOkResult: handleBackgroundColorDialogOk, onCancelResult: handleBackgroundColorDialogCancel }));
105
105
  }, [presetColors, handleBackgroundColorDialogOk]); // eslint-disable-line react-hooks/exhaustive-deps
106
106
  const handleBaseMapSelection = React.useCallback((value) => {
107
107
  if (bases && activeViewport && value) {