@itwin/map-layers 6.0.7 → 6.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,12 +1,28 @@
1
1
  # Change Log - @itwin/map-layers
2
2
 
3
- <!-- This log was last generated on Tue, 23 Sep 2025 14:41:33 GMT and should not be manually modified. -->
3
+ <!-- This log was last generated on Mon, 03 Nov 2025 14:36:13 GMT and should not be manually modified. -->
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 6.0.9
8
+
9
+ Mon, 03 Nov 2025 14:36:13 GMT
10
+
11
+ ### Patches
12
+
13
+ - Store user selected solid fill color to use as session default and add as new preset in picker ([#1481](https://github.com/iTwin/viewer-components-react/pull/1481))
14
+
15
+ ## 6.0.8
16
+
17
+ Wed, 08 Oct 2025 20:11:56 GMT
18
+
19
+ ### Patches
20
+
21
+ - Remove Dynamically Created Inline Styles ([#1463](https://github.com/iTwin/viewer-components-react/pull/1463))
22
+
7
23
  ## 6.0.7
8
24
 
9
- Tue, 23 Sep 2025 14:41:33 GMT
25
+ Tue, 23 Sep 2025 14:41:43 GMT
10
26
 
11
27
  ### Patches
12
28
 
@@ -0,0 +1,53 @@
1
+ import type { GuidString } from "@itwin/core-bentley";
2
+ /** @internal */
3
+ export interface BasemapColorPreferencesContent {
4
+ customColor?: string;
5
+ activeColor?: string;
6
+ }
7
+ /** A wrapper around user preferences to store basemap solid fill colors.
8
+ * Supports both user-selected custom colors and active colors (which may be preset or custom).
9
+ * @internal
10
+ */
11
+ export declare class BasemapColorPreferences {
12
+ private static readonly _preferenceNamespace;
13
+ private static readonly _preferenceKey;
14
+ /** Store the user-selected custom basemap color preference.
15
+ * This preserves the user's custom color choice even when they switch to presets.
16
+ * @param color TBGR color value as string
17
+ * @param iTwinId iTwin identifier
18
+ * @param iModelId iModel identifier (optional, if not provided stores at iTwin level)
19
+ */
20
+ static saveCustomColor(color: string, iTwinId: GuidString, iModelId?: GuidString): Promise<boolean>;
21
+ /** Store the currently active basemap color.
22
+ * This tracks what color is currently being used, whether it's custom or preset.
23
+ * @param color TBGR color value as string
24
+ * @param iTwinId iTwin identifier
25
+ * @param iModelId iModel identifier (optional, if not provided stores at iTwin level)
26
+ */
27
+ static saveActiveColor(color: string, iTwinId: GuidString, iModelId?: GuidString): Promise<boolean>;
28
+ /** Get the user's selected custom color.
29
+ * @param iTwinId iTwin identifier
30
+ * @param iModelId iModel identifier (optional)
31
+ * @returns The stored user-selected color as TBGR string, or undefined if not found
32
+ */
33
+ static getCustomColor(iTwinId: GuidString, iModelId?: GuidString): Promise<string | undefined>;
34
+ /** Get the currently active color.
35
+ * @param iTwinId iTwin identifier
36
+ * @param iModelId iModel identifier (optional)
37
+ * @returns The stored active color as TBGR string, or undefined if not found
38
+ */
39
+ static getActiveColor(iTwinId: GuidString, iModelId?: GuidString): Promise<string | undefined>;
40
+ /** Get all color preferences.
41
+ * @param iTwinId iTwin identifier
42
+ * @param iModelId iModel identifier (optional)
43
+ * @returns The stored preferences, or undefined if not found
44
+ */
45
+ static getPreferences(iTwinId: GuidString, iModelId?: GuidString): Promise<BasemapColorPreferencesContent | undefined>;
46
+ /** Save color preferences.
47
+ * @param preferences The preferences to save
48
+ * @param iTwinId iTwin identifier
49
+ * @param iModelId iModel identifier (optional)
50
+ */
51
+ private static savePreferences;
52
+ }
53
+ //# sourceMappingURL=BasemapColorPreferences.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BasemapColorPreferences.d.ts","sourceRoot":"","sources":["../../src/BasemapColorPreferences.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,gBAAgB;AAChB,MAAM,WAAW,8BAA8B;IAC7C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,qBAAa,uBAAuB;IAClC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,oBAAoB,CAAkC;IAC9E,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAqB;IAE3D;;;;;OAKG;WACiB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC;IAahH;;;;;OAKG;WACiB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC;IAahH;;;;OAIG;WACiB,cAAc,CAAC,OAAO,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAK3G;;;;OAIG;WACiB,cAAc,CAAC,OAAO,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAK3G;;;;OAIG;WACiB,cAAc,CAAC,OAAO,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,8BAA8B,GAAG,SAAS,CAAC;IAyCnI;;;;OAIG;mBACkB,eAAe;CAsBrC"}
@@ -0,0 +1,142 @@
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.BasemapColorPreferences = void 0;
8
+ const core_frontend_1 = require("@itwin/core-frontend");
9
+ const mapLayers_1 = require("./mapLayers");
10
+ /** A wrapper around user preferences to store basemap solid fill colors.
11
+ * Supports both user-selected custom colors and active colors (which may be preset or custom).
12
+ * @internal
13
+ */
14
+ class BasemapColorPreferences {
15
+ static _preferenceNamespace = "BasemapColor-SettingsService";
16
+ static _preferenceKey = "solidFillColors";
17
+ /** Store the user-selected custom basemap color preference.
18
+ * This preserves the user's custom color choice even when they switch to presets.
19
+ * @param color TBGR color value as string
20
+ * @param iTwinId iTwin identifier
21
+ * @param iModelId iModel identifier (optional, if not provided stores at iTwin level)
22
+ */
23
+ static async saveCustomColor(color, iTwinId, iModelId) {
24
+ try {
25
+ const existing = await BasemapColorPreferences.getPreferences(iTwinId, iModelId);
26
+ const colorPreference = {
27
+ customColor: color,
28
+ activeColor: existing?.activeColor ?? color, // Keep existing active or set to this color
29
+ };
30
+ return await BasemapColorPreferences.savePreferences(colorPreference, iTwinId, iModelId);
31
+ }
32
+ catch {
33
+ return false;
34
+ }
35
+ }
36
+ /** Store the currently active basemap color.
37
+ * This tracks what color is currently being used, whether it's custom or preset.
38
+ * @param color TBGR color value as string
39
+ * @param iTwinId iTwin identifier
40
+ * @param iModelId iModel identifier (optional, if not provided stores at iTwin level)
41
+ */
42
+ static async saveActiveColor(color, iTwinId, iModelId) {
43
+ try {
44
+ const existing = await BasemapColorPreferences.getPreferences(iTwinId, iModelId);
45
+ const colorPreference = {
46
+ customColor: existing?.customColor, // Preserve user's custom color
47
+ activeColor: color,
48
+ };
49
+ return await BasemapColorPreferences.savePreferences(colorPreference, iTwinId, iModelId);
50
+ }
51
+ catch {
52
+ return false;
53
+ }
54
+ }
55
+ /** Get the user's selected custom color.
56
+ * @param iTwinId iTwin identifier
57
+ * @param iModelId iModel identifier (optional)
58
+ * @returns The stored user-selected color as TBGR string, or undefined if not found
59
+ */
60
+ static async getCustomColor(iTwinId, iModelId) {
61
+ const preferences = await BasemapColorPreferences.getPreferences(iTwinId, iModelId);
62
+ return preferences?.customColor;
63
+ }
64
+ /** Get the currently active color.
65
+ * @param iTwinId iTwin identifier
66
+ * @param iModelId iModel identifier (optional)
67
+ * @returns The stored active color as TBGR string, or undefined if not found
68
+ */
69
+ static async getActiveColor(iTwinId, iModelId) {
70
+ const preferences = await BasemapColorPreferences.getPreferences(iTwinId, iModelId);
71
+ return preferences?.activeColor;
72
+ }
73
+ /** Get all color preferences.
74
+ * @param iTwinId iTwin identifier
75
+ * @param iModelId iModel identifier (optional)
76
+ * @returns The stored preferences, or undefined if not found
77
+ */
78
+ static async getPreferences(iTwinId, iModelId) {
79
+ if (!mapLayers_1.MapLayersUI.iTwinConfig) {
80
+ return undefined;
81
+ }
82
+ try {
83
+ const accessToken = undefined !== core_frontend_1.IModelApp.authorizationClient ? await core_frontend_1.IModelApp.authorizationClient.getAccessToken() : undefined;
84
+ // Try to get from iModel level first (more specific)
85
+ if (iModelId) {
86
+ try {
87
+ const iModelResult = await mapLayers_1.MapLayersUI.iTwinConfig.get({
88
+ accessToken,
89
+ namespace: BasemapColorPreferences._preferenceNamespace,
90
+ key: BasemapColorPreferences._preferenceKey,
91
+ iTwinId,
92
+ iModelId,
93
+ });
94
+ if (iModelResult) {
95
+ return iModelResult;
96
+ }
97
+ }
98
+ catch {
99
+ // Fall through to try iTwin level
100
+ }
101
+ }
102
+ // Try iTwin level
103
+ const iTwinResult = await mapLayers_1.MapLayersUI.iTwinConfig.get({
104
+ accessToken,
105
+ namespace: BasemapColorPreferences._preferenceNamespace,
106
+ key: BasemapColorPreferences._preferenceKey,
107
+ iTwinId,
108
+ });
109
+ return iTwinResult;
110
+ }
111
+ catch {
112
+ return undefined;
113
+ }
114
+ }
115
+ /** Save color preferences.
116
+ * @param preferences The preferences to save
117
+ * @param iTwinId iTwin identifier
118
+ * @param iModelId iModel identifier (optional)
119
+ */
120
+ static async savePreferences(preferences, iTwinId, iModelId) {
121
+ if (!mapLayers_1.MapLayersUI.iTwinConfig) {
122
+ return false;
123
+ }
124
+ try {
125
+ const accessToken = undefined !== core_frontend_1.IModelApp.authorizationClient ? await core_frontend_1.IModelApp.authorizationClient.getAccessToken() : undefined;
126
+ await mapLayers_1.MapLayersUI.iTwinConfig.save({
127
+ accessToken,
128
+ content: preferences,
129
+ namespace: BasemapColorPreferences._preferenceNamespace,
130
+ key: BasemapColorPreferences._preferenceKey,
131
+ iTwinId,
132
+ iModelId,
133
+ });
134
+ return true;
135
+ }
136
+ catch {
137
+ return false;
138
+ }
139
+ }
140
+ }
141
+ exports.BasemapColorPreferences = BasemapColorPreferences;
142
+ //# sourceMappingURL=BasemapColorPreferences.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BasemapColorPreferences.js","sourceRoot":"","sources":["../../src/BasemapColorPreferences.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,wDAAiD;AACjD,2CAA0C;AAU1C;;;GAGG;AACH,MAAa,uBAAuB;IAC1B,MAAM,CAAU,oBAAoB,GAAG,8BAA8B,CAAC;IACtE,MAAM,CAAU,cAAc,GAAG,iBAAiB,CAAC;IAE3D;;;;;OAKG;IACI,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,KAAa,EAAE,OAAmB,EAAE,QAAqB;QAC3F,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,uBAAuB,CAAC,cAAc,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;YACjF,MAAM,eAAe,GAAmC;gBACtD,WAAW,EAAE,KAAK;gBAClB,WAAW,EAAE,QAAQ,EAAE,WAAW,IAAI,KAAK,EAAE,4CAA4C;aAC1F,CAAC;YACF,OAAO,MAAM,uBAAuB,CAAC,eAAe,CAAC,eAAe,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;QAC3F,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,KAAa,EAAE,OAAmB,EAAE,QAAqB;QAC3F,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,uBAAuB,CAAC,cAAc,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;YACjF,MAAM,eAAe,GAAmC;gBACtD,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,+BAA+B;gBACn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AAI,YAAY,EAAE,CAAC;wBACjB,OAAO,YAAY,CAAC;oBACtB,CAAC;gBACH,CAAC;gBAAC,MAAM,CAAC;oBACP,kCAAkC;gBACpC,CAAC;YACH,CAAC;YAED,kBAAkB;YAClB,MAAM,WAAW,GAAG,MAAM,uBAAW,CAAC,WAAW,CAAC,GAAG,CAAC;gBACpD,WAAW;gBACX,SAAS,EAAE,uBAAuB,CAAC,oBAAoB;gBACvD,GAAG,EAAE,uBAAuB,CAAC,cAAc;gBAC3C,OAAO;aACR,CAAC,CAAC;YAEH,OAAO,WAAW,CAAC;QACrB,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;IAED;;;;OAIG;IACK,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,WAA2C,EAAE,OAAmB,EAAE,QAAqB;QAC1H,IAAI,CAAC,uBAAW,CAAC,WAAW,EAAE,CAAC;YAC7B,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,CAAC;YACH,MAAM,WAAW,GAAG,SAAS,KAAK,yBAAS,CAAC,mBAAmB,CAAC,CAAC,CAAC,MAAM,yBAAS,CAAC,mBAAmB,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;YAEnI,MAAM,uBAAW,CAAC,WAAW,CAAC,IAAI,CAAC;gBACjC,WAAW;gBACX,OAAO,EAAE,WAAW;gBACpB,SAAS,EAAE,uBAAuB,CAAC,oBAAoB;gBACvD,GAAG,EAAE,uBAAuB,CAAC,cAAc;gBAC3C,OAAO;gBACP,QAAQ;aACT,CAAC,CAAC;YAEH,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;;AAtIH,0DAuIC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { MapLayersUI } from \"./mapLayers\";\n\nimport type { GuidString } from \"@itwin/core-bentley\";\n\n/** @internal */\nexport interface BasemapColorPreferencesContent {\n customColor?: string; // TBGR color value as string - user's custom color choice\n activeColor?: string; // TBGR color value as string - currently active color\n}\n\n/** A wrapper around user preferences to store basemap solid fill colors.\n * Supports both user-selected custom colors and active colors (which may be preset or custom).\n * @internal\n */\nexport class BasemapColorPreferences {\n private static readonly _preferenceNamespace = \"BasemapColor-SettingsService\";\n private static readonly _preferenceKey = \"solidFillColors\";\n\n /** Store the user-selected custom basemap color preference.\n * This preserves the user's custom color choice even when they switch to presets.\n * @param color TBGR color value as string\n * @param iTwinId iTwin identifier\n * @param iModelId iModel identifier (optional, if not provided stores at iTwin level)\n */\n public static async saveCustomColor(color: string, iTwinId: GuidString, iModelId?: GuidString): Promise<boolean> {\n try {\n const existing = await BasemapColorPreferences.getPreferences(iTwinId, iModelId);\n const colorPreference: BasemapColorPreferencesContent = {\n customColor: color,\n activeColor: existing?.activeColor ?? color, // Keep existing active or set to this color\n };\n return await BasemapColorPreferences.savePreferences(colorPreference, iTwinId, iModelId);\n } catch {\n return false;\n }\n }\n\n /** Store the currently active basemap color.\n * This tracks what color is currently being used, whether it's custom or preset.\n * @param color TBGR color value as string\n * @param iTwinId iTwin identifier\n * @param iModelId iModel identifier (optional, if not provided stores at iTwin level)\n */\n public static async saveActiveColor(color: string, iTwinId: GuidString, iModelId?: GuidString): Promise<boolean> {\n try {\n const existing = await BasemapColorPreferences.getPreferences(iTwinId, iModelId);\n const colorPreference: BasemapColorPreferencesContent = {\n customColor: existing?.customColor, // Preserve user's custom color\n activeColor: color,\n };\n return await BasemapColorPreferences.savePreferences(colorPreference, iTwinId, iModelId);\n } catch {\n return false;\n }\n }\n\n /** Get the user's selected custom color.\n * @param iTwinId iTwin identifier\n * @param iModelId iModel identifier (optional)\n * @returns The stored user-selected color as TBGR string, or undefined if not found\n */\n public static async getCustomColor(iTwinId: GuidString, iModelId?: GuidString): Promise<string | undefined> {\n const preferences = await BasemapColorPreferences.getPreferences(iTwinId, iModelId);\n return preferences?.customColor;\n }\n\n /** Get the currently active color.\n * @param iTwinId iTwin identifier\n * @param iModelId iModel identifier (optional)\n * @returns The stored active color as TBGR string, or undefined if not found\n */\n public static async getActiveColor(iTwinId: GuidString, iModelId?: GuidString): Promise<string | undefined> {\n const preferences = await BasemapColorPreferences.getPreferences(iTwinId, iModelId);\n return preferences?.activeColor;\n }\n\n /** Get all color preferences.\n * @param iTwinId iTwin identifier\n * @param iModelId iModel identifier (optional)\n * @returns The stored preferences, or undefined if not found\n */\n public static async getPreferences(iTwinId: GuidString, iModelId?: GuidString): Promise<BasemapColorPreferencesContent | undefined> {\n if (!MapLayersUI.iTwinConfig) {\n return undefined;\n }\n\n try {\n const accessToken = undefined !== IModelApp.authorizationClient ? await IModelApp.authorizationClient.getAccessToken() : undefined;\n\n // Try to get from iModel level first (more specific)\n if (iModelId) {\n try {\n const iModelResult = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: BasemapColorPreferences._preferenceNamespace,\n key: BasemapColorPreferences._preferenceKey,\n iTwinId,\n iModelId,\n });\n\n if (iModelResult) {\n return iModelResult;\n }\n } catch {\n // Fall through to try iTwin level\n }\n }\n\n // Try iTwin level\n const iTwinResult = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: BasemapColorPreferences._preferenceNamespace,\n key: BasemapColorPreferences._preferenceKey,\n iTwinId,\n });\n\n return iTwinResult;\n } catch {\n return undefined;\n }\n }\n\n /** Save color preferences.\n * @param preferences The preferences to save\n * @param iTwinId iTwin identifier\n * @param iModelId iModel identifier (optional)\n */\n private static async savePreferences(preferences: BasemapColorPreferencesContent, iTwinId: GuidString, iModelId?: GuidString): Promise<boolean> {\n if (!MapLayersUI.iTwinConfig) {\n return false;\n }\n\n try {\n const accessToken = undefined !== IModelApp.authorizationClient ? await IModelApp.authorizationClient.getAccessToken() : undefined;\n\n await MapLayersUI.iTwinConfig.save({\n accessToken,\n content: preferences,\n namespace: BasemapColorPreferences._preferenceNamespace,\n key: BasemapColorPreferences._preferenceKey,\n iTwinId,\n iModelId,\n });\n\n return true;\n } catch {\n return false;\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"BasemapPanel.d.ts","sourceRoot":"","sources":["../../../../src/ui/widget/BasemapPanel.tsx"],"names":[],"mappings":"AAMA,OAAO,qBAAqB,CAAC;AAmB7B,UAAU,iBAAiB;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,gBAAgB;AAChB,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,2CAsVpD"}
1
+ {"version":3,"file":"BasemapPanel.d.ts","sourceRoot":"","sources":["../../../../src/ui/widget/BasemapPanel.tsx"],"names":[],"mappings":"AAMA,OAAO,qBAAqB,CAAC;AAiC7B,UAAU,iBAAiB;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,gBAAgB;AAChB,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,2CAwYpD"}
@@ -36,9 +36,21 @@ const core_common_1 = require("@itwin/core-common");
36
36
  const core_frontend_1 = require("@itwin/core-frontend");
37
37
  const itwinui_icons_react_1 = require("@itwin/itwinui-icons-react");
38
38
  const itwinui_react_1 = require("@itwin/itwinui-react");
39
+ const BasemapColorPreferences_1 = require("../../BasemapColorPreferences");
39
40
  const mapLayers_1 = require("../../mapLayers");
40
41
  const MapLayerManager_1 = require("./MapLayerManager");
41
42
  const TransparencyPopupButton_1 = require("./TransparencyPopupButton");
43
+ // Define preset colors in a single place to avoid duplication
44
+ const PRESET_COLORS = [
45
+ itwinui_react_1.ColorValue.fromTbgr(core_common_1.ColorByName.grey),
46
+ itwinui_react_1.ColorValue.fromTbgr(core_common_1.ColorByName.lightGrey),
47
+ itwinui_react_1.ColorValue.fromTbgr(core_common_1.ColorByName.darkGrey),
48
+ itwinui_react_1.ColorValue.fromTbgr(core_common_1.ColorByName.lightBlue),
49
+ itwinui_react_1.ColorValue.fromTbgr(core_common_1.ColorByName.lightGreen),
50
+ itwinui_react_1.ColorValue.fromTbgr(core_common_1.ColorByName.darkGreen),
51
+ itwinui_react_1.ColorValue.fromTbgr(core_common_1.ColorByName.tan),
52
+ itwinui_react_1.ColorValue.fromTbgr(core_common_1.ColorByName.darkBrown),
53
+ ];
42
54
  const customBaseMapValue = "customBaseMap";
43
55
  /** @internal */
44
56
  function BasemapPanel(props) {
@@ -82,7 +94,7 @@ function BasemapPanel(props) {
82
94
  return mapImagery.backgroundBase.transparency;
83
95
  }
84
96
  else if (mapImagery.backgroundBase instanceof core_common_1.ColorDef) {
85
- return mapImagery.backgroundBase.getAlpha() / 255;
97
+ return 1.0 - (mapImagery.backgroundBase.getAlpha() / 255);
86
98
  }
87
99
  else {
88
100
  return 0;
@@ -147,8 +159,9 @@ function BasemapPanel(props) {
147
159
  }
148
160
  }
149
161
  else if (baseMap instanceof core_common_1.ColorDef) {
150
- if (baseMap.getAlpha() !== baseMapTransparencyValue) {
151
- setBaseMapTransparencyValue(baseMap.getAlpha() / 255);
162
+ const transparency = 1.0 - (baseMap.getAlpha() / 255);
163
+ if (transparency !== baseMapTransparencyValue) {
164
+ setBaseMapTransparencyValue(transparency);
152
165
  }
153
166
  }
154
167
  }, [baseMapTransparencyValue, baseMapVisible, selectedBaseMap, updateBaseMapOptions]);
@@ -183,16 +196,55 @@ function BasemapPanel(props) {
183
196
  setCustomBaseMap(selectedBaseMap);
184
197
  }
185
198
  }, [baseMapOptions, extraFormats, selectedBaseMap]);
186
- const [presetColors] = React.useState([
187
- itwinui_react_1.ColorValue.fromTbgr(core_common_1.ColorByName.grey),
188
- itwinui_react_1.ColorValue.fromTbgr(core_common_1.ColorByName.lightGrey),
189
- itwinui_react_1.ColorValue.fromTbgr(core_common_1.ColorByName.darkGrey),
190
- itwinui_react_1.ColorValue.fromTbgr(core_common_1.ColorByName.lightBlue),
191
- itwinui_react_1.ColorValue.fromTbgr(core_common_1.ColorByName.lightGreen),
192
- itwinui_react_1.ColorValue.fromTbgr(core_common_1.ColorByName.darkGreen),
193
- itwinui_react_1.ColorValue.fromTbgr(core_common_1.ColorByName.tan),
194
- itwinui_react_1.ColorValue.fromTbgr(core_common_1.ColorByName.darkBrown),
195
- ]);
199
+ const getPresetColorsWithSaved = React.useCallback(async () => {
200
+ const defaultColors = [...PRESET_COLORS];
201
+ // Add saved custom color from preferences as the first color if available
202
+ try {
203
+ const iModel = activeViewport?.iModel;
204
+ if (iModel?.iTwinId) {
205
+ const savedColor = await BasemapColorPreferences_1.BasemapColorPreferences.getCustomColor(iModel.iTwinId, iModel.iModelId);
206
+ if (savedColor) {
207
+ const savedColorValue = itwinui_react_1.ColorValue.fromTbgr(Number(savedColor));
208
+ // Remove the saved color from default colors if it exists there
209
+ const filteredColors = defaultColors.filter(color => color.toTbgr() !== savedColorValue.toTbgr());
210
+ // Always put the saved color as the first color
211
+ return [savedColorValue, ...filteredColors];
212
+ }
213
+ }
214
+ }
215
+ catch {
216
+ // Silently ignore preferences errors
217
+ }
218
+ return defaultColors;
219
+ }, [activeViewport]);
220
+ const [presetColors, setPresetColors] = React.useState(() => [...PRESET_COLORS]);
221
+ // Load saved color on component mount and when activeViewport changes
222
+ React.useEffect(() => {
223
+ const loadSavedColor = async () => {
224
+ const colors = await getPresetColorsWithSaved();
225
+ setPresetColors(colors);
226
+ };
227
+ void loadSavedColor();
228
+ }, [activeViewport, getPresetColorsWithSaved]);
229
+ // Persist a custom (non-preset) basemap color to user preferences and refresh preset list
230
+ const saveCustomBasemapColorPreference = React.useCallback(async (selectedColorTbgr, isPresetColor) => {
231
+ // Only save custom colors to preferences - preset colors don't overwrite user's custom color
232
+ if (isPresetColor)
233
+ return;
234
+ try {
235
+ const iModel = activeViewport?.iModel;
236
+ if (iModel?.iTwinId) {
237
+ const saved = await BasemapColorPreferences_1.BasemapColorPreferences.saveCustomColor(selectedColorTbgr.toString(), iModel.iTwinId, iModel.iModelId);
238
+ if (saved) {
239
+ const colors = await getPresetColorsWithSaved();
240
+ setPresetColors(colors);
241
+ }
242
+ }
243
+ }
244
+ catch {
245
+ // Silently ignore preferences errors
246
+ }
247
+ }, [activeViewport, getPresetColorsWithSaved]);
196
248
  const baseIsColor = React.useMemo(() => selectedBaseMap instanceof core_common_1.ColorDef, [selectedBaseMap]);
197
249
  const baseIsMap = React.useMemo(() => !baseIsColor && selectedBaseMap !== undefined, [baseIsColor, selectedBaseMap]);
198
250
  // bgColor is a 32 bit number represented in TBGR format
@@ -238,9 +290,14 @@ function BasemapPanel(props) {
238
290
  // change color and make sure previously set transparency is not lost.
239
291
  const curTransparency = activeViewport.displayStyle.backgroundMapBase instanceof core_common_1.ColorDef ? activeViewport.displayStyle.backgroundMapBase.getTransparency() : 0;
240
292
  activeViewport.displayStyle.backgroundMapBase = bgColorDef.withTransparency(curTransparency);
293
+ // Determine if this is a preset color or a custom color
294
+ const selectedColorTbgr = bgColorValue.toTbgr();
295
+ const isPresetColor = presetColors.some((presetColor) => presetColor.toTbgr() === selectedColorTbgr);
296
+ // Persist custom color (no-op if preset)
297
+ void saveCustomBasemapColorPreference(selectedColorTbgr, isPresetColor);
241
298
  setSelectedBaseMap(bgColorDef);
242
299
  }
243
- }, [activeViewport]);
300
+ }, [activeViewport, presetColors, saveCustomBasemapColorPreference]);
244
301
  const handleBaseMapSelection = React.useCallback((value) => {
245
302
  if (activeViewport && value) {
246
303
  if (value === customBaseMapValue && customBaseMap) {
@@ -1 +1 @@
1
- {"version":3,"file":"BasemapPanel.js","sourceRoot":"","sources":["../../../../src/ui/widget/BasemapPanel.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,oCAsVC;;AApXD;;;gGAGgG;AAChG,2CAA2C;AAE3C,+BAA6B;AAC7B,6CAA+B;AAC/B,oDAA8I;AAC9I,wDAAiD;AACjD,oEAAkF;AAClF,wDAAsJ;AACtJ,+CAA8C;AAC9C,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,EAAC,SAAS,EAAC,qDAAqD,YAC1H,uBAAC,2BAAW,IAAC,KAAK,EAAE,0BAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAI,GACzC,GACL,CACX,EACD,uBAAC,iDAAuB,IAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,YAAY,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,+BAA+B,GAAI,IAChJ,IACL,CACJ,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n// cSpell:ignore droppable Sublayer Basemap\n\nimport \"./BasemapPanel.scss\";\nimport * as React from \"react\";\nimport { BackgroundMapType, BaseLayerSettings, BaseMapLayerSettings, ColorByName, ColorDef, ImageMapLayerSettings } from \"@itwin/core-common\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { SvgVisibilityHide, SvgVisibilityShow } from \"@itwin/itwinui-icons-react\";\nimport { ColorBuilder, ColorInputPanel, ColorPalette, ColorPicker, ColorSwatch, ColorValue, IconButton, Popover, Select } from \"@itwin/itwinui-react\";\nimport { MapLayersUI } from \"../../mapLayers\";\nimport { useSourceMapContext } from \"./MapLayerManager\";\nimport { TransparencyPopupButton } from \"./TransparencyPopupButton\";\n\nimport type {\n MapImagerySettings} from \"@itwin/core-common\";\nimport type { Viewport } from \"@itwin/core-frontend\";\nimport type { SelectOption } from \"@itwin/itwinui-react\";\nconst customBaseMapValue = \"customBaseMap\";\ninterface ExtraFormat {\n selectKeyFromSetting: (base: BaseMapLayerSettings) => string;\n}\n\ninterface BasemapPanelProps {\n disabled?: boolean;\n}\n\n/** @internal */\nexport function BasemapPanel(props: BasemapPanelProps) {\n const [useColorLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Basemap.ColorFill\"));\n const { activeViewport, bases } = useSourceMapContext();\n const [selectedBaseMap, setSelectedBaseMap] = React.useState<BaseLayerSettings | undefined>(() => {\n return activeViewport?.displayStyle.settings.mapImagery.backgroundBase;\n });\n\n const [extraFormats] = React.useState<{[formatId: string]:ExtraFormat}>(()=>{\n const extras: {[formatId: string]:ExtraFormat} = {};\n // TODO: Use format string from format class instead of hardcoded string.\n if (IModelApp.mapLayerFormatRegistry.isRegistered(\"GoogleMaps\")) {\n extras.GoogleMaps = {\n selectKeyFromSetting: (base: BaseMapLayerSettings) => {\n let key = base.formatId;\n if (base.properties?.mapType !== undefined) {\n key = `${key}.${base.properties?.mapType.toString()}`;\n if (base.properties?.layerTypes) {\n key = `${key}-${base.properties?.layerTypes.toString()}`;\n }\n }\n return key;\n }\n }\n }\n return extras;\n });\n\n const getSelectKeyFromProvider = React.useCallback(\n (base: BaseMapLayerSettings) => {\n if (base.provider) {\n return `${base.formatId}.${BackgroundMapType[base.provider.type]}`;\n }\n if (extraFormats[base.formatId]) {\n return extraFormats[base.formatId].selectKeyFromSetting(base);\n }\n return base.name;\n },\n [extraFormats],\n );\n\n const [baseMapTransparencyValue, setBaseMapTransparencyValue] = React.useState(() => {\n if (activeViewport) {\n const mapImagery = activeViewport.displayStyle.settings.mapImagery;\n if (mapImagery.backgroundBase instanceof ImageMapLayerSettings) {\n return mapImagery.backgroundBase.transparency;\n } else if (mapImagery.backgroundBase instanceof ColorDef) {\n return mapImagery.backgroundBase.getAlpha() / 255;\n } else {\n return 0;\n }\n } else {\n return 0;\n }\n });\n\n const [customBaseMap, setCustomBaseMap] = React.useState<BaseMapLayerSettings | undefined>();\n const [baseMapVisible, setBaseMapVisible] = React.useState(() => {\n if (activeViewport && activeViewport.displayStyle.backgroundMapBase instanceof ImageMapLayerSettings) {\n return activeViewport.displayStyle.backgroundMapBase.visible;\n }\n return false;\n });\n\n const getBaseMapOptions = React.useCallback(\n (baseMap: BaseLayerSettings | undefined) => {\n const baseOptions: SelectOption<string>[] = [];\n\n baseOptions.push({ value: useColorLabel, label: useColorLabel });\n\n if (bases) {\n baseOptions.push(\n ...bases.map((base) => {\n const value = getSelectKeyFromProvider(base);\n const label = MapLayersUI.translate(`WellKnownBaseMaps.${value}`);\n return { value, label };\n }),\n );\n }\n\n const baseMapSelectKey = baseMap ? getSelectKeyFromProvider(baseMap as BaseMapLayerSettings) : \"\";\n\n // Add new custom base map definition (avoid adding duplicate entry)\n if (baseMap instanceof BaseMapLayerSettings\n && baseOptions.find((opt) => opt.value === baseMapSelectKey) === undefined\n && !extraFormats[baseMap.formatId]) {\n // Add new option for the custom base map\n if (undefined === baseOptions.find((opt) => opt.label === baseMap.name)) {\n setCustomBaseMap(baseMap);\n baseOptions.push({ value: customBaseMapValue, label: baseMap.name });\n }\n } else if (customBaseMap) {\n // Add previously defined custom map definition\n baseOptions.push({ value: customBaseMapValue, label: customBaseMap.name });\n }\n return baseOptions;\n },\n [bases, customBaseMap, extraFormats, getSelectKeyFromProvider, useColorLabel],\n );\n\n const [baseMapOptions, setBaseMapOptions] = React.useState<SelectOption<string>[]>(() => getBaseMapOptions(selectedBaseMap));\n\n const updateBaseMapOptions = React.useCallback(\n (baseMap: BaseLayerSettings | undefined) => {\n setBaseMapOptions(getBaseMapOptions(baseMap));\n },\n [getBaseMapOptions],\n );\n\n\n const handleMapImageryChanged = React.useCallback(\n (args: Readonly<MapImagerySettings>) => {\n const baseMap = args.backgroundBase;\n\n // Optimization: If serialized 'backgroundBase' objects are identical, skip refresh\n if (JSON.stringify(baseMap.toJSON()) === JSON.stringify(selectedBaseMap?.toJSON())) {\n return;\n }\n\n setSelectedBaseMap(baseMap); // cache current base map objects\n updateBaseMapOptions(baseMap);\n\n if (baseMap instanceof ImageMapLayerSettings) {\n if (baseMap.transparency !== baseMapTransparencyValue) {\n setBaseMapTransparencyValue(baseMap.transparency);\n }\n\n if (baseMap.visible !== baseMapVisible) {\n setBaseMapVisible(baseMap.visible);\n }\n } else if (baseMap instanceof ColorDef) {\n if (baseMap.getAlpha() !== baseMapTransparencyValue) {\n setBaseMapTransparencyValue(baseMap.getAlpha() / 255);\n }\n }\n },\n [baseMapTransparencyValue, baseMapVisible, selectedBaseMap, updateBaseMapOptions],\n );\n\n React.useEffect(() => {\n const handleDisplayStyleChange = (vp: Viewport) => {\n handleMapImageryChanged(vp.displayStyle.settings.mapImagery);\n };\n return activeViewport?.onDisplayStyleChanged.addListener(handleDisplayStyleChange);\n }, [activeViewport, handleMapImageryChanged]);\n\n // Monitor display style's onMapImageryChanged event\n React.useEffect(() => {\n return activeViewport?.displayStyle.settings.onMapImageryChanged.addListener(handleMapImageryChanged);\n }, [activeViewport, handleMapImageryChanged]);\n\n // Monitor viewport updates, and refresh the widget accordingly .\n // Note: This is needed for multiple viewport applications.\n React.useEffect(() => {\n if (activeViewport) {\n handleMapImageryChanged(activeViewport.displayStyle.settings.mapImagery);\n }\n }, [activeViewport, handleMapImageryChanged]);\n\n const handleBasemapTransparencyChange = React.useCallback(\n (transparency: number) => {\n if (activeViewport) {\n activeViewport.displayStyle.changeBaseMapTransparency(transparency);\n setBaseMapTransparencyValue(transparency);\n }\n },\n [activeViewport],\n );\n\n // This effect is only to keep a custom base map option when a 'default' base map is picked.\n React.useEffect(() => {\n if (\n selectedBaseMap instanceof BaseMapLayerSettings\n && undefined === baseMapOptions.find((opt) => opt.label === selectedBaseMap.name)\n && undefined === extraFormats[selectedBaseMap.formatId]\n ) {\n setCustomBaseMap(selectedBaseMap);\n }\n }, [baseMapOptions, extraFormats, selectedBaseMap]);\n\n const [presetColors] = React.useState([\n ColorValue.fromTbgr(ColorByName.grey),\n ColorValue.fromTbgr(ColorByName.lightGrey),\n ColorValue.fromTbgr(ColorByName.darkGrey),\n ColorValue.fromTbgr(ColorByName.lightBlue),\n ColorValue.fromTbgr(ColorByName.lightGreen),\n ColorValue.fromTbgr(ColorByName.darkGreen),\n ColorValue.fromTbgr(ColorByName.tan),\n ColorValue.fromTbgr(ColorByName.darkBrown),\n ]);\n\n const baseIsColor = React.useMemo(() => selectedBaseMap instanceof ColorDef, [selectedBaseMap]);\n const baseIsMap = React.useMemo(() => !baseIsColor && selectedBaseMap !== undefined, [baseIsColor, selectedBaseMap]);\n // bgColor is a 32 bit number represented in TBGR format\n const bgColor = React.useMemo(\n () => (baseIsColor ? (selectedBaseMap as ColorDef).toJSON() : presetColors[0].toTbgr()),\n [baseIsColor, selectedBaseMap, presetColors],\n );\n const [selectedBaseMapValue, setSelectedBaseMapValue] = React.useState<SelectOption<string>>({ value: \"\", label: \"\" });\n\n React.useEffect(() => {\n if (baseIsMap) {\n if (selectedBaseMap instanceof BaseMapLayerSettings\n && (selectedBaseMap.provider || extraFormats[selectedBaseMap.formatId])) {\n const mapName = getSelectKeyFromProvider(selectedBaseMap);\n const foundItem = baseMapOptions.find((value) => value.value === mapName);\n if (foundItem) {\n setSelectedBaseMapValue(foundItem);\n return;\n }\n }\n\n if (selectedBaseMap instanceof BaseMapLayerSettings) {\n // We got a custom base map\n\n // First check if the name matches a label of existing base map.\n // If it matches, we assume it's a legacy base map definition missing the provider information.\n let foundItem = baseMapOptions.find((opt) => opt.value !== customBaseMapValue && opt.label === selectedBaseMap.name);\n if (foundItem) {\n setSelectedBaseMapValue(foundItem);\n return;\n }\n\n // Use custom base map entry\n foundItem = baseMapOptions.find((opt) => opt.value === customBaseMapValue);\n if (foundItem) {\n setSelectedBaseMapValue(foundItem);\n return;\n }\n }\n } else if (baseIsColor) {\n setSelectedBaseMapValue(baseMapOptions[0]);\n return;\n }\n setSelectedBaseMapValue({ value: \"\", label: \"\" });\n }, [baseIsColor, baseIsMap, baseMapOptions, extraFormats, getSelectKeyFromProvider, selectedBaseMap]);\n\n const handleBackgroundColorDialogOk = React.useCallback(\n (bgColorValue: ColorValue) => {\n if (activeViewport) {\n const bgColorDef = ColorDef.fromTbgr(bgColorValue.toTbgr());\n // change color and make sure previously set transparency is not lost.\n const curTransparency =\n activeViewport.displayStyle.backgroundMapBase instanceof ColorDef ? activeViewport.displayStyle.backgroundMapBase.getTransparency() : 0;\n activeViewport.displayStyle.backgroundMapBase = bgColorDef.withTransparency(curTransparency);\n\n setSelectedBaseMap(bgColorDef);\n }\n },\n [activeViewport],\n );\n\n const handleBaseMapSelection = React.useCallback(\n (value: string) => {\n if (activeViewport && value) {\n if (value === customBaseMapValue && customBaseMap) {\n activeViewport.displayStyle.backgroundMapBase = customBaseMap;\n } else if (bases) {\n const baseMap = bases.find((provider) => getSelectKeyFromProvider(provider) === value);\n if (baseMap) {\n const baseProps = baseMap.toJSON();\n if (activeViewport.displayStyle.backgroundMapBase instanceof BaseMapLayerSettings) {\n activeViewport.displayStyle.backgroundMapBase = BaseLayerSettings.fromJSON({ ...baseProps, visible: baseMapVisible });\n } else {\n activeViewport.displayStyle.backgroundMapBase = BaseLayerSettings.fromJSON(baseProps)\n }\n } else {\n const bgColorDef = ColorDef.fromJSON(bgColor);\n const curTransparency =\n activeViewport.displayStyle.backgroundMapBase instanceof ColorDef ? activeViewport.displayStyle.backgroundMapBase.getTransparency() : 0;\n activeViewport.displayStyle.backgroundMapBase = bgColorDef.withTransparency(curTransparency);\n }\n }\n }\n },\n [activeViewport, customBaseMap, bases, getSelectKeyFromProvider, baseMapVisible, bgColor],\n );\n\n const handleVisibilityChange = React.useCallback(() => {\n if (activeViewport) {\n const newState = !baseMapVisible;\n // BaseMap visibility is only support when backgroundBase is an instance of BaseMapLayerSettings (i.e not a color)...\n if (activeViewport.displayStyle.backgroundMapBase instanceof BaseMapLayerSettings) {\n activeViewport.displayStyle.backgroundMapBase = activeViewport.displayStyle.backgroundMapBase.clone({ visible: newState });\n }\n setBaseMapVisible(newState);\n }\n }, [baseMapVisible, activeViewport]);\n\n const [baseLayerLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Basemap.BaseLayer\"));\n const [selectBaseMapLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Basemap.SelectBaseMap\"));\n const [toggleVisibility] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Widget.ToggleVisibility\"));\n\n return (\n <>\n <span className=\"map-manager-base-label\">{baseLayerLabel}</span>\n <div className=\"map-manager-base-item\">\n <IconButton\n data-testid=\"base-map-visibility-icon-button\"\n className=\"map-manager-basemap-visibility\"\n styleType=\"borderless\"\n size=\"small\" label={toggleVisibility}\n onClick={handleVisibilityChange}\n disabled={props.disabled || !activeViewport || !(activeViewport.displayStyle.backgroundMapBase instanceof ImageMapLayerSettings)}>\n {baseMapVisible\n ? <SvgVisibilityShow data-testid=\"layer-visibility-icon-show\" />\n : <SvgVisibilityHide data-testid=\"layer-visibility-icon-hide\" />}\n </IconButton>\n <Select\n data-testid=\"base-map-select\"\n className=\"map-manager-base-item-select\"\n options={baseMapOptions}\n placeholder={selectBaseMapLabel}\n value={selectedBaseMapValue.value}\n onChange={handleBaseMapSelection}\n size=\"small\"\n disabled={props.disabled}\n />\n {baseIsColor && (\n <Popover\n content={\n <ColorPicker\n selectedColor={ColorValue.fromTbgr(bgColor)}\n onChangeComplete={handleBackgroundColorDialogOk}\n >\n <ColorBuilder />\n <ColorInputPanel defaultColorFormat='rgb' />\n <ColorPalette\n label=\"Preset Colors\"\n colors={presetColors}\n />\n </ColorPicker>\n }\n >\n <IconButton label='Show color picker' styleType='borderless' className='map-manager-base-item-color components-color-swatch'>\n <ColorSwatch color={ColorValue.fromTbgr(bgColor)} />\n </IconButton>\n </Popover>\n )}\n <TransparencyPopupButton disabled={props.disabled} transparency={baseMapTransparencyValue} onTransparencyChange={handleBasemapTransparencyChange} />\n </div>\n </>\n );\n}\n"]}
1
+ {"version":3,"file":"BasemapPanel.js","sourceRoot":"","sources":["../../../../src/ui/widget/BasemapPanel.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,oCAwYC;;AApbD;;;gGAGgG;AAChG,2CAA2C;AAE3C,+BAA6B;AAC7B,6CAA+B;AAC/B,oDAA8I;AAC9I,wDAAiD;AACjD,oEAAkF;AAClF,wDAAsJ;AACtJ,2EAAwE;AACxE,+CAA8C;AAC9C,u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AAK,CAAC,QAAQ,EAAE,YAAY,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,+BAA+B,GAAI,IAChJ,IACL,CACJ,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n// cSpell:ignore droppable Sublayer Basemap\n\nimport \"./BasemapPanel.scss\";\nimport * as React from \"react\";\nimport { BackgroundMapType, BaseLayerSettings, BaseMapLayerSettings, ColorByName, ColorDef, ImageMapLayerSettings } from \"@itwin/core-common\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { SvgVisibilityHide, SvgVisibilityShow } from \"@itwin/itwinui-icons-react\";\nimport { ColorBuilder, ColorInputPanel, ColorPalette, ColorPicker, ColorSwatch, ColorValue, IconButton, Popover, Select } from \"@itwin/itwinui-react\";\nimport { BasemapColorPreferences } from \"../../BasemapColorPreferences\";\nimport { MapLayersUI } from \"../../mapLayers\";\nimport { useSourceMapContext } from \"./MapLayerManager\";\nimport { TransparencyPopupButton } from \"./TransparencyPopupButton\";\n\nimport type {\n MapImagerySettings} from \"@itwin/core-common\";\nimport type { Viewport } from \"@itwin/core-frontend\";\nimport type { SelectOption } from \"@itwin/itwinui-react\";\n\n// Define preset colors in a single place to avoid duplication\nconst PRESET_COLORS = [\n ColorValue.fromTbgr(ColorByName.grey),\n ColorValue.fromTbgr(ColorByName.lightGrey),\n ColorValue.fromTbgr(ColorByName.darkGrey),\n ColorValue.fromTbgr(ColorByName.lightBlue),\n ColorValue.fromTbgr(ColorByName.lightGreen),\n ColorValue.fromTbgr(ColorByName.darkGreen),\n ColorValue.fromTbgr(ColorByName.tan),\n ColorValue.fromTbgr(ColorByName.darkBrown),\n];\n\nconst customBaseMapValue = \"customBaseMap\";\ninterface ExtraFormat {\n selectKeyFromSetting: (base: BaseMapLayerSettings) => string;\n}\n\ninterface BasemapPanelProps {\n disabled?: boolean;\n}\n\n/** @internal */\nexport function BasemapPanel(props: BasemapPanelProps) {\n const [useColorLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Basemap.ColorFill\"));\n const { activeViewport, bases } = useSourceMapContext();\n const [selectedBaseMap, setSelectedBaseMap] = React.useState<BaseLayerSettings | undefined>(() => {\n return activeViewport?.displayStyle.settings.mapImagery.backgroundBase;\n });\n\n const [extraFormats] = React.useState<{[formatId: string]:ExtraFormat}>(()=>{\n const extras: {[formatId: string]:ExtraFormat} = {};\n // TODO: Use format string from format class instead of hardcoded string.\n if (IModelApp.mapLayerFormatRegistry.isRegistered(\"GoogleMaps\")) {\n extras.GoogleMaps = {\n selectKeyFromSetting: (base: BaseMapLayerSettings) => {\n let key = base.formatId;\n if (base.properties?.mapType !== undefined) {\n key = `${key}.${base.properties?.mapType.toString()}`;\n if (base.properties?.layerTypes) {\n key = `${key}-${base.properties?.layerTypes.toString()}`;\n }\n }\n return key;\n }\n }\n }\n return extras;\n });\n\n const getSelectKeyFromProvider = React.useCallback(\n (base: BaseMapLayerSettings) => {\n if (base.provider) {\n return `${base.formatId}.${BackgroundMapType[base.provider.type]}`;\n }\n if (extraFormats[base.formatId]) {\n return extraFormats[base.formatId].selectKeyFromSetting(base);\n }\n return base.name;\n },\n [extraFormats],\n );\n\n const [baseMapTransparencyValue, setBaseMapTransparencyValue] = React.useState(() => {\n if (activeViewport) {\n const mapImagery = activeViewport.displayStyle.settings.mapImagery;\n if (mapImagery.backgroundBase instanceof ImageMapLayerSettings) {\n return mapImagery.backgroundBase.transparency;\n } else if (mapImagery.backgroundBase instanceof ColorDef) {\n return 1.0 - (mapImagery.backgroundBase.getAlpha() / 255);\n } else {\n return 0;\n }\n } else {\n return 0;\n }\n });\n\n const [customBaseMap, setCustomBaseMap] = React.useState<BaseMapLayerSettings | undefined>();\n const [baseMapVisible, setBaseMapVisible] = React.useState(() => {\n if (activeViewport && activeViewport.displayStyle.backgroundMapBase instanceof ImageMapLayerSettings) {\n return activeViewport.displayStyle.backgroundMapBase.visible;\n }\n return false;\n });\n\n const getBaseMapOptions = React.useCallback(\n (baseMap: BaseLayerSettings | undefined) => {\n const baseOptions: SelectOption<string>[] = [];\n\n baseOptions.push({ value: useColorLabel, label: useColorLabel });\n\n if (bases) {\n baseOptions.push(\n ...bases.map((base) => {\n const value = getSelectKeyFromProvider(base);\n const label = MapLayersUI.translate(`WellKnownBaseMaps.${value}`);\n return { value, label };\n }),\n );\n }\n\n const baseMapSelectKey = baseMap ? getSelectKeyFromProvider(baseMap as BaseMapLayerSettings) : \"\";\n\n // Add new custom base map definition (avoid adding duplicate entry)\n if (baseMap instanceof BaseMapLayerSettings\n && baseOptions.find((opt) => opt.value === baseMapSelectKey) === undefined\n && !extraFormats[baseMap.formatId]) {\n // Add new option for the custom base map\n if (undefined === baseOptions.find((opt) => opt.label === baseMap.name)) {\n setCustomBaseMap(baseMap);\n baseOptions.push({ value: customBaseMapValue, label: baseMap.name });\n }\n } else if (customBaseMap) {\n // Add previously defined custom map definition\n baseOptions.push({ value: customBaseMapValue, label: customBaseMap.name });\n }\n return baseOptions;\n },\n [bases, customBaseMap, extraFormats, getSelectKeyFromProvider, useColorLabel],\n );\n\n const [baseMapOptions, setBaseMapOptions] = React.useState<SelectOption<string>[]>(() => getBaseMapOptions(selectedBaseMap));\n\n const updateBaseMapOptions = React.useCallback(\n (baseMap: BaseLayerSettings | undefined) => {\n setBaseMapOptions(getBaseMapOptions(baseMap));\n },\n [getBaseMapOptions],\n );\n\n\n const handleMapImageryChanged = React.useCallback(\n (args: Readonly<MapImagerySettings>) => {\n const baseMap = args.backgroundBase;\n\n // Optimization: If serialized 'backgroundBase' objects are identical, skip refresh\n if (JSON.stringify(baseMap.toJSON()) === JSON.stringify(selectedBaseMap?.toJSON())) {\n return;\n }\n\n setSelectedBaseMap(baseMap); // cache current base map objects\n updateBaseMapOptions(baseMap);\n\n if (baseMap instanceof ImageMapLayerSettings) {\n if (baseMap.transparency !== baseMapTransparencyValue) {\n setBaseMapTransparencyValue(baseMap.transparency);\n }\n\n if (baseMap.visible !== baseMapVisible) {\n setBaseMapVisible(baseMap.visible);\n }\n } else if (baseMap instanceof ColorDef) {\n const transparency = 1.0 - (baseMap.getAlpha() / 255);\n if (transparency !== baseMapTransparencyValue) {\n setBaseMapTransparencyValue(transparency);\n }\n }\n },\n [baseMapTransparencyValue, baseMapVisible, selectedBaseMap, updateBaseMapOptions],\n );\n\n React.useEffect(() => {\n const handleDisplayStyleChange = (vp: Viewport) => {\n handleMapImageryChanged(vp.displayStyle.settings.mapImagery);\n };\n return activeViewport?.onDisplayStyleChanged.addListener(handleDisplayStyleChange);\n }, [activeViewport, handleMapImageryChanged]);\n\n // Monitor display style's onMapImageryChanged event\n React.useEffect(() => {\n return activeViewport?.displayStyle.settings.onMapImageryChanged.addListener(handleMapImageryChanged);\n }, [activeViewport, handleMapImageryChanged]);\n\n // Monitor viewport updates, and refresh the widget accordingly .\n // Note: This is needed for multiple viewport applications.\n React.useEffect(() => {\n if (activeViewport) {\n handleMapImageryChanged(activeViewport.displayStyle.settings.mapImagery);\n }\n }, [activeViewport, handleMapImageryChanged]);\n\n const handleBasemapTransparencyChange = React.useCallback(\n (transparency: number) => {\n if (activeViewport) {\n activeViewport.displayStyle.changeBaseMapTransparency(transparency);\n setBaseMapTransparencyValue(transparency);\n }\n },\n [activeViewport],\n );\n\n // This effect is only to keep a custom base map option when a 'default' base map is picked.\n React.useEffect(() => {\n if (\n selectedBaseMap instanceof BaseMapLayerSettings\n && undefined === baseMapOptions.find((opt) => opt.label === selectedBaseMap.name)\n && undefined === extraFormats[selectedBaseMap.formatId]\n ) {\n setCustomBaseMap(selectedBaseMap);\n }\n }, [baseMapOptions, extraFormats, selectedBaseMap]);\n\n const getPresetColorsWithSaved = React.useCallback(async () => {\n const defaultColors = [...PRESET_COLORS];\n\n // Add saved custom color from preferences as the first color if available\n try {\n const iModel = activeViewport?.iModel;\n if (iModel?.iTwinId) {\n const savedColor = await BasemapColorPreferences.getCustomColor(iModel.iTwinId, iModel.iModelId);\n if (savedColor) {\n const savedColorValue = ColorValue.fromTbgr(Number(savedColor));\n // Remove the saved color from default colors if it exists there\n const filteredColors = defaultColors.filter(color => color.toTbgr() !== savedColorValue.toTbgr());\n // Always put the saved color as the first color\n return [savedColorValue, ...filteredColors];\n }\n }\n } catch {\n // Silently ignore preferences errors\n }\n\n return defaultColors;\n }, [activeViewport]);\n\n const [presetColors, setPresetColors] = React.useState<ColorValue[]>(() => [...PRESET_COLORS]);\n\n // Load saved color on component mount and when activeViewport changes\n React.useEffect(() => {\n const loadSavedColor = async () => {\n const colors = await getPresetColorsWithSaved();\n setPresetColors(colors);\n };\n void loadSavedColor();\n }, [activeViewport, getPresetColorsWithSaved]);\n\n // Persist a custom (non-preset) basemap color to user preferences and refresh preset list\n const saveCustomBasemapColorPreference = React.useCallback(async (selectedColorTbgr: number, isPresetColor: boolean) => {\n // Only save custom colors to preferences - preset colors don't overwrite user's custom color\n if (isPresetColor)\n return;\n\n try {\n const iModel = activeViewport?.iModel;\n if (iModel?.iTwinId) {\n const saved = await BasemapColorPreferences.saveCustomColor(selectedColorTbgr.toString(), iModel.iTwinId, iModel.iModelId);\n if (saved) {\n const colors = await getPresetColorsWithSaved();\n setPresetColors(colors);\n }\n }\n } catch {\n // Silently ignore preferences errors\n }\n }, [activeViewport, getPresetColorsWithSaved]);\n\n const baseIsColor = React.useMemo(() => selectedBaseMap instanceof ColorDef, [selectedBaseMap]);\n const baseIsMap = React.useMemo(() => !baseIsColor && selectedBaseMap !== undefined, [baseIsColor, selectedBaseMap]);\n // bgColor is a 32 bit number represented in TBGR format\n const bgColor = React.useMemo(\n () => (baseIsColor ? (selectedBaseMap as ColorDef).toJSON() : presetColors[0].toTbgr()),\n [baseIsColor, selectedBaseMap, presetColors],\n );\n const [selectedBaseMapValue, setSelectedBaseMapValue] = React.useState<SelectOption<string>>({ value: \"\", label: \"\" });\n\n React.useEffect(() => {\n if (baseIsMap) {\n if (selectedBaseMap instanceof BaseMapLayerSettings\n && (selectedBaseMap.provider || extraFormats[selectedBaseMap.formatId])) {\n const mapName = getSelectKeyFromProvider(selectedBaseMap);\n const foundItem = baseMapOptions.find((value) => value.value === mapName);\n if (foundItem) {\n setSelectedBaseMapValue(foundItem);\n return;\n }\n }\n\n if (selectedBaseMap instanceof BaseMapLayerSettings) {\n // We got a custom base map\n\n // First check if the name matches a label of existing base map.\n // If it matches, we assume it's a legacy base map definition missing the provider information.\n let foundItem = baseMapOptions.find((opt) => opt.value !== customBaseMapValue && opt.label === selectedBaseMap.name);\n if (foundItem) {\n setSelectedBaseMapValue(foundItem);\n return;\n }\n\n // Use custom base map entry\n foundItem = baseMapOptions.find((opt) => opt.value === customBaseMapValue);\n if (foundItem) {\n setSelectedBaseMapValue(foundItem);\n return;\n }\n }\n } else if (baseIsColor) {\n setSelectedBaseMapValue(baseMapOptions[0]);\n return;\n }\n setSelectedBaseMapValue({ value: \"\", label: \"\" });\n }, [baseIsColor, baseIsMap, baseMapOptions, extraFormats, getSelectKeyFromProvider, selectedBaseMap]);\n\n const handleBackgroundColorDialogOk = React.useCallback(\n (bgColorValue: ColorValue) => {\n if (activeViewport) {\n const bgColorDef = ColorDef.fromTbgr(bgColorValue.toTbgr());\n // change color and make sure previously set transparency is not lost.\n const curTransparency =\n activeViewport.displayStyle.backgroundMapBase instanceof ColorDef ? activeViewport.displayStyle.backgroundMapBase.getTransparency() : 0;\n activeViewport.displayStyle.backgroundMapBase = bgColorDef.withTransparency(curTransparency);\n\n // Determine if this is a preset color or a custom color\n const selectedColorTbgr = bgColorValue.toTbgr();\n const isPresetColor = presetColors.some((presetColor: ColorValue) => presetColor.toTbgr() === selectedColorTbgr);\n\n // Persist custom color (no-op if preset)\n void saveCustomBasemapColorPreference(selectedColorTbgr, isPresetColor);\n setSelectedBaseMap(bgColorDef);\n }\n },\n [activeViewport, presetColors, saveCustomBasemapColorPreference],\n );\n\n const handleBaseMapSelection = React.useCallback(\n (value: string) => {\n if (activeViewport && value) {\n if (value === customBaseMapValue && customBaseMap) {\n activeViewport.displayStyle.backgroundMapBase = customBaseMap;\n } else if (bases) {\n const baseMap = bases.find((provider) => getSelectKeyFromProvider(provider) === value);\n if (baseMap) {\n const baseProps = baseMap.toJSON();\n if (activeViewport.displayStyle.backgroundMapBase instanceof BaseMapLayerSettings) {\n activeViewport.displayStyle.backgroundMapBase = BaseLayerSettings.fromJSON({ ...baseProps, visible: baseMapVisible });\n } else {\n activeViewport.displayStyle.backgroundMapBase = BaseLayerSettings.fromJSON(baseProps)\n }\n } else {\n const bgColorDef = ColorDef.fromJSON(bgColor);\n const curTransparency =\n activeViewport.displayStyle.backgroundMapBase instanceof ColorDef ? activeViewport.displayStyle.backgroundMapBase.getTransparency() : 0;\n activeViewport.displayStyle.backgroundMapBase = bgColorDef.withTransparency(curTransparency);\n }\n }\n }\n },\n [activeViewport, customBaseMap, bases, getSelectKeyFromProvider, baseMapVisible, bgColor],\n );\n\n const handleVisibilityChange = React.useCallback(() => {\n if (activeViewport) {\n const newState = !baseMapVisible;\n // BaseMap visibility is only support when backgroundBase is an instance of BaseMapLayerSettings (i.e not a color)...\n if (activeViewport.displayStyle.backgroundMapBase instanceof BaseMapLayerSettings) {\n activeViewport.displayStyle.backgroundMapBase = activeViewport.displayStyle.backgroundMapBase.clone({ visible: newState });\n }\n setBaseMapVisible(newState);\n }\n }, [baseMapVisible, activeViewport]);\n\n const [baseLayerLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Basemap.BaseLayer\"));\n const [selectBaseMapLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Basemap.SelectBaseMap\"));\n const [toggleVisibility] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:Widget.ToggleVisibility\"));\n\n return (\n <>\n <span className=\"map-manager-base-label\">{baseLayerLabel}</span>\n <div className=\"map-manager-base-item\">\n <IconButton\n data-testid=\"base-map-visibility-icon-button\"\n className=\"map-manager-basemap-visibility\"\n styleType=\"borderless\"\n size=\"small\" label={toggleVisibility}\n onClick={handleVisibilityChange}\n disabled={props.disabled || !activeViewport || !(activeViewport.displayStyle.backgroundMapBase instanceof ImageMapLayerSettings)}>\n {baseMapVisible\n ? <SvgVisibilityShow data-testid=\"layer-visibility-icon-show\" />\n : <SvgVisibilityHide data-testid=\"layer-visibility-icon-hide\" />}\n </IconButton>\n <Select\n data-testid=\"base-map-select\"\n className=\"map-manager-base-item-select\"\n options={baseMapOptions}\n placeholder={selectBaseMapLabel}\n value={selectedBaseMapValue.value}\n onChange={handleBaseMapSelection}\n size=\"small\"\n disabled={props.disabled}\n />\n {baseIsColor && (\n <Popover\n content={\n <ColorPicker\n selectedColor={ColorValue.fromTbgr(bgColor)}\n onChangeComplete={handleBackgroundColorDialogOk}\n >\n <ColorBuilder />\n <ColorInputPanel defaultColorFormat='rgb' />\n <ColorPalette\n label=\"Preset Colors\"\n colors={presetColors}\n />\n </ColorPicker>\n }\n >\n <IconButton label='Show color picker' styleType='borderless' className='map-manager-base-item-color components-color-swatch'>\n <ColorSwatch color={ColorValue.fromTbgr(bgColor)} />\n </IconButton>\n </Popover>\n )}\n <TransparencyPopupButton disabled={props.disabled} transparency={baseMapTransparencyValue} onTransparencyChange={handleBasemapTransparencyChange} />\n </div>\n </>\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"MapLayerDroppable.d.ts","sourceRoot":"","sources":["../../../../src/ui/widget/MapLayerDroppable.tsx"],"names":[],"mappings":"AAQA,OAAO,0BAA0B,CAAC;AAiBlC,OAAO,KAAK,EAAiB,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAI5E,gBAAgB;AAChB,UAAU,sBAAsB;IAC9B,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,qBAAqB,EAAE,CAAC;IACrC,eAAe,CAAC,EAAE,e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IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAmBD,gBAAgB;AAChB,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,2CAkP9D"}
@@ -60,11 +60,6 @@ const StrictModeDroppable = ({ children, ...props }) => {
60
60
  }
61
61
  return (0, jsx_runtime_1.jsx)(react_beautiful_dnd_1.Droppable, { ...props, children: children });
62
62
  };
63
- const changeVisibilityByElementId = (element, visible) => {
64
- if (element) {
65
- element.setAttribute("style", `visibility: ${visible ? "visible" : "hidden"}`);
66
- }
67
- };
68
63
  /** @internal */
69
64
  function MapLayerDroppable(props) {
70
65
  const containsLayer = props.layersList && props.layersList.length > 0;
@@ -106,15 +101,11 @@ function MapLayerDroppable(props) {
106
101
  vp.resetMapLayer(index);
107
102
  props.onItemEdited();
108
103
  }, [props]);
109
- const changeSettingsMenuVisibility = (event, visible) => {
110
- changeVisibilityByElementId(event.currentTarget.querySelector("#MapLayerSettingsMenuWrapper"), visible);
111
- changeVisibilityByElementId(event.currentTarget.querySelector("#MapLayerSettingsSubLayersMenu"), visible);
112
- };
113
104
  const renderItem = (dragProvided, _, rubric) => {
114
105
  (0, core_bentley_1.assert)(props.layersList !== undefined);
115
106
  const activeLayer = props.layersList[rubric.source.index];
116
107
  const outOfRange = activeLayer.treeVisibility === core_frontend_1.MapTileTreeScaleRangeVisibility.Hidden;
117
- return ((0, jsx_runtime_1.jsxs)("div", { className: "map-manager-source-item", "data-id": rubric.source.index, ...dragProvided.draggableProps, ref: dragProvided.innerRef, onMouseEnter: (event) => changeSettingsMenuVisibility(event, true), onMouseLeave: (event) => changeSettingsMenuVisibility(event, false), children: [(0, jsx_runtime_1.jsx)(itwinui_react_1.Checkbox, { "data-testid": "select-item-checkbox", checked: activeLayer.selected, onChange: (event) => {
108
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "map-manager-source-item", "data-id": rubric.source.index, ...dragProvided.draggableProps, ref: dragProvided.innerRef, children: [(0, jsx_runtime_1.jsx)(itwinui_react_1.Checkbox, { "data-testid": "select-item-checkbox", checked: activeLayer.selected, onChange: (event) => {
118
109
  activeLayer.selected = event.target.checked;
119
110
  props.onItemSelected(props.isOverlay, rubric.source.index);
120
111
  } }), (0, jsx_runtime_1.jsx)(itwinui_react_1.IconButton, { disabled: props.disabled, size: "small", styleType: "borderless", className: "map-manager-item-visibility", label: toggleVisibility, onClick: () => {
@@ -130,7 +121,7 @@ function MapLayerDroppable(props) {
130
121
  }, mapLayerOptions: props.mapLayerOptions }));
131
122
  }
132
123
  }
133
- }, label: requireAuthTooltip, children: (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgStatusWarning, {}) }))] }), (0, jsx_runtime_1.jsx)("div", { id: "MapLayerSettingsSubLayersMenu", className: "map-manager-item-sub-layer-container map-manager-hidden", children: activeLayer.subLayers && activeLayer.subLayers.length > 1 && ((0, jsx_runtime_1.jsx)(SubLayersPopupButton_1.SubLayersPopupButton, { checkboxStyle: "eye", expandMode: "rootGroupOnly", subLayers: props.activeViewport ? activeLayer.subLayers : undefined, singleVisibleSubLayer: activeLayer.provider?.mutualExclusiveSubLayer, onSubLayerStateChange: (subLayerId, isSelected) => {
124
+ }, label: requireAuthTooltip, children: (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgStatusWarning, {}) }))] }), (0, jsx_runtime_1.jsx)("div", { className: "map-manager-item-sub-layer-container map-layer-settings-sublayers-menu", children: activeLayer.subLayers && activeLayer.subLayers.length > 1 && ((0, jsx_runtime_1.jsx)(SubLayersPopupButton_1.SubLayersPopupButton, { checkboxStyle: "eye", expandMode: "rootGroupOnly", subLayers: props.activeViewport ? activeLayer.subLayers : undefined, singleVisibleSubLayer: activeLayer.provider?.mutualExclusiveSubLayer, onSubLayerStateChange: (subLayerId, isSelected) => {
134
125
  onSubLayerStateChange(activeLayer, subLayerId, isSelected);
135
126
  } })) }), activeLayer.provider?.status === core_frontend_1.MapLayerImageryProviderStatus.RequireAuth && ((0, jsx_runtime_1.jsx)(itwinui_react_1.IconButton, { disabled: props.disabled, size: "small", styleType: "borderless", onClick: () => {
136
127
  const indexInDisplayStyle = props.activeViewport?.displayStyle.findMapLayerIndexByNameAndSource(activeLayer.name, activeLayer.source, activeLayer.isOverlay);
@@ -143,7 +134,7 @@ function MapLayerDroppable(props) {
143
134
  }, mapLayerOptions: props.mapLayerOptions }));
144
135
  }
145
136
  }
146
- }, label: requireAuthTooltip, children: (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgStatusWarning, {}) })), (0, jsx_runtime_1.jsx)("div", { id: "MapLayerSettingsMenuWrapper", className: "map-manager-hidden", children: (0, jsx_runtime_1.jsx)(MapLayerSettingsMenu_1.MapLayerSettingsMenu, { activeViewport: props.activeViewport, mapLayerSettings: activeLayer, onMenuItemSelection: props.onMenuItemSelected, disabled: props.disabled }) })] }, activeLayer.name));
137
+ }, label: requireAuthTooltip, children: (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgStatusWarning, {}) })), (0, jsx_runtime_1.jsx)("div", { className: "map-layer-settings-menu-wrapper", children: (0, jsx_runtime_1.jsx)(MapLayerSettingsMenu_1.MapLayerSettingsMenu, { activeViewport: props.activeViewport, mapLayerSettings: activeLayer, onMenuItemSelection: props.onMenuItemSelected, disabled: props.disabled }) })] }, activeLayer.name));
147
138
  };
148
139
  function renderDraggableContent(snapshot) {
149
140
  let node;