@itwin/map-layers 3.0.0-dev.78 → 3.0.0-dev.82

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 (198) hide show
  1. package/lib/{map-layers.d.ts → cjs/map-layers.d.ts} +0 -0
  2. package/lib/cjs/map-layers.d.ts.map +1 -0
  3. package/lib/{map-layers.js → cjs/map-layers.js} +0 -0
  4. package/lib/cjs/map-layers.js.map +1 -0
  5. package/lib/{mapLayers.d.ts → cjs/mapLayers.d.ts} +0 -0
  6. package/lib/cjs/mapLayers.d.ts.map +1 -0
  7. package/lib/{mapLayers.js → cjs/mapLayers.js} +0 -0
  8. package/lib/cjs/mapLayers.js.map +1 -0
  9. package/lib/{public → cjs/public}/locales/en/mapLayers.json +0 -0
  10. package/lib/{ui → cjs/ui}/Interfaces.d.ts +0 -0
  11. package/lib/cjs/ui/Interfaces.d.ts.map +1 -0
  12. package/lib/{ui → cjs/ui}/Interfaces.js +0 -0
  13. package/lib/cjs/ui/Interfaces.js.map +1 -0
  14. package/lib/{ui → cjs/ui}/MapLayersUiItemsProvider.d.ts +0 -0
  15. package/lib/cjs/ui/MapLayersUiItemsProvider.d.ts.map +1 -0
  16. package/lib/{ui → cjs/ui}/MapLayersUiItemsProvider.js +0 -0
  17. package/lib/cjs/ui/MapLayersUiItemsProvider.js.map +1 -0
  18. package/lib/{ui → cjs/ui}/widget/AttachLayerPopupButton.d.ts +0 -0
  19. package/lib/cjs/ui/widget/AttachLayerPopupButton.d.ts.map +1 -0
  20. package/lib/{ui → cjs/ui}/widget/AttachLayerPopupButton.js +0 -0
  21. package/lib/cjs/ui/widget/AttachLayerPopupButton.js.map +1 -0
  22. package/lib/{ui → cjs/ui}/widget/BasemapPanel.d.ts +0 -0
  23. package/lib/cjs/ui/widget/BasemapPanel.d.ts.map +1 -0
  24. package/lib/{ui → cjs/ui}/widget/BasemapPanel.js +0 -0
  25. package/lib/cjs/ui/widget/BasemapPanel.js.map +1 -0
  26. package/lib/{ui → cjs/ui}/widget/BasemapPanel.scss +1 -1
  27. package/lib/{ui → cjs/ui}/widget/ConfirmMessageDialog.d.ts +0 -0
  28. package/lib/cjs/ui/widget/ConfirmMessageDialog.d.ts.map +1 -0
  29. package/lib/{ui → cjs/ui}/widget/ConfirmMessageDialog.js +0 -0
  30. package/lib/cjs/ui/widget/ConfirmMessageDialog.js.map +1 -0
  31. package/lib/{ui → cjs/ui}/widget/MapLayerDroppable.d.ts +0 -0
  32. package/lib/cjs/ui/widget/MapLayerDroppable.d.ts.map +1 -0
  33. package/lib/{ui → cjs/ui}/widget/MapLayerDroppable.js +0 -0
  34. package/lib/cjs/ui/widget/MapLayerDroppable.js.map +1 -0
  35. package/lib/{ui → cjs/ui}/widget/MapLayerManager.d.ts +0 -0
  36. package/lib/cjs/ui/widget/MapLayerManager.d.ts.map +1 -0
  37. package/lib/{ui → cjs/ui}/widget/MapLayerManager.js +0 -0
  38. package/lib/cjs/ui/widget/MapLayerManager.js.map +1 -0
  39. package/lib/{ui → cjs/ui}/widget/MapLayerManager.scss +1 -1
  40. package/lib/{ui → cjs/ui}/widget/MapLayerSettingsMenu.d.ts +0 -0
  41. package/lib/cjs/ui/widget/MapLayerSettingsMenu.d.ts.map +1 -0
  42. package/lib/{ui → cjs/ui}/widget/MapLayerSettingsMenu.js +0 -0
  43. package/lib/cjs/ui/widget/MapLayerSettingsMenu.js.map +1 -0
  44. package/lib/{ui → cjs/ui}/widget/MapLayerSettingsPopupButton.d.ts +0 -0
  45. package/lib/cjs/ui/widget/MapLayerSettingsPopupButton.d.ts.map +1 -0
  46. package/lib/{ui → cjs/ui}/widget/MapLayerSettingsPopupButton.js +0 -0
  47. package/lib/cjs/ui/widget/MapLayerSettingsPopupButton.js.map +1 -0
  48. package/lib/{ui → cjs/ui}/widget/MapLayerSettingsPopupButton.scss +1 -1
  49. package/lib/{ui → cjs/ui}/widget/MapLayersWidget.d.ts +0 -0
  50. package/lib/cjs/ui/widget/MapLayersWidget.d.ts.map +1 -0
  51. package/lib/{ui → cjs/ui}/widget/MapLayersWidget.js +0 -0
  52. package/lib/cjs/ui/widget/MapLayersWidget.js.map +1 -0
  53. package/lib/{ui → cjs/ui}/widget/MapManagerSettings.d.ts +0 -0
  54. package/lib/cjs/ui/widget/MapManagerSettings.d.ts.map +1 -0
  55. package/lib/{ui → cjs/ui}/widget/MapManagerSettings.js +0 -0
  56. package/lib/cjs/ui/widget/MapManagerSettings.js.map +1 -0
  57. package/lib/{ui → cjs/ui}/widget/MapManagerSettings.scss +1 -1
  58. package/lib/{ui → cjs/ui}/widget/MapUrlDialog.d.ts +0 -0
  59. package/lib/cjs/ui/widget/MapUrlDialog.d.ts.map +1 -0
  60. package/lib/{ui → cjs/ui}/widget/MapUrlDialog.js +0 -0
  61. package/lib/cjs/ui/widget/MapUrlDialog.js.map +1 -0
  62. package/lib/{ui → cjs/ui}/widget/MapUrlDialog.scss +1 -1
  63. package/lib/{ui → cjs/ui}/widget/SubLayersDataProvider.d.ts +0 -0
  64. package/lib/cjs/ui/widget/SubLayersDataProvider.d.ts.map +1 -0
  65. package/lib/{ui → cjs/ui}/widget/SubLayersDataProvider.js +0 -0
  66. package/lib/cjs/ui/widget/SubLayersDataProvider.js.map +1 -0
  67. package/lib/{ui → cjs/ui}/widget/SubLayersPopupButton.d.ts +0 -0
  68. package/lib/cjs/ui/widget/SubLayersPopupButton.d.ts.map +1 -0
  69. package/lib/{ui → cjs/ui}/widget/SubLayersPopupButton.js +0 -0
  70. package/lib/cjs/ui/widget/SubLayersPopupButton.js.map +1 -0
  71. package/lib/{ui → cjs/ui}/widget/SubLayersTree.d.ts +0 -0
  72. package/lib/cjs/ui/widget/SubLayersTree.d.ts.map +1 -0
  73. package/lib/{ui → cjs/ui}/widget/SubLayersTree.js +0 -0
  74. package/lib/cjs/ui/widget/SubLayersTree.js.map +1 -0
  75. package/lib/{ui → cjs/ui}/widget/SubLayersTree.scss +1 -1
  76. package/lib/{ui → cjs/ui}/widget/TransparencyPopupButton.d.ts +0 -0
  77. package/lib/cjs/ui/widget/TransparencyPopupButton.d.ts.map +1 -0
  78. package/lib/{ui → cjs/ui}/widget/TransparencyPopupButton.js +0 -0
  79. package/lib/cjs/ui/widget/TransparencyPopupButton.js.map +1 -0
  80. package/lib/{ui → cjs/ui}/widget/TransparencyPopupButton.scss +1 -1
  81. package/lib/esm/map-layers.d.ts +5 -0
  82. package/lib/esm/map-layers.d.ts.map +1 -0
  83. package/lib/esm/map-layers.js +9 -0
  84. package/lib/esm/map-layers.js.map +1 -0
  85. package/lib/esm/mapLayers.d.ts +29 -0
  86. package/lib/esm/mapLayers.d.ts.map +1 -0
  87. package/lib/esm/mapLayers.js +50 -0
  88. package/lib/esm/mapLayers.js.map +1 -0
  89. package/lib/esm/public/locales/en/mapLayers.json +113 -0
  90. package/lib/esm/ui/Interfaces.d.ts +32 -0
  91. package/lib/esm/ui/Interfaces.d.ts.map +1 -0
  92. package/lib/esm/ui/Interfaces.js +2 -0
  93. package/lib/esm/ui/Interfaces.js.map +1 -0
  94. package/lib/esm/ui/MapLayersUiItemsProvider.d.ts +23 -0
  95. package/lib/esm/ui/MapLayersUiItemsProvider.d.ts.map +1 -0
  96. package/lib/esm/ui/MapLayersUiItemsProvider.js +50 -0
  97. package/lib/esm/ui/MapLayersUiItemsProvider.js.map +1 -0
  98. package/lib/esm/ui/widget/AttachLayerPopupButton.d.ts +14 -0
  99. package/lib/esm/ui/widget/AttachLayerPopupButton.d.ts.map +1 -0
  100. package/lib/esm/ui/widget/AttachLayerPopupButton.js +308 -0
  101. package/lib/esm/ui/widget/AttachLayerPopupButton.js.map +1 -0
  102. package/lib/esm/ui/widget/BasemapPanel.d.ts +5 -0
  103. package/lib/esm/ui/widget/BasemapPanel.d.ts.map +1 -0
  104. package/lib/esm/ui/widget/BasemapPanel.js +141 -0
  105. package/lib/esm/ui/widget/BasemapPanel.js.map +1 -0
  106. package/lib/esm/ui/widget/BasemapPanel.scss +98 -0
  107. package/lib/esm/ui/widget/ConfirmMessageDialog.d.ts +22 -0
  108. package/lib/esm/ui/widget/ConfirmMessageDialog.d.ts.map +1 -0
  109. package/lib/esm/ui/widget/ConfirmMessageDialog.js +22 -0
  110. package/lib/esm/ui/widget/ConfirmMessageDialog.js.map +1 -0
  111. package/lib/esm/ui/widget/MapLayerDroppable.d.ts +19 -0
  112. package/lib/esm/ui/widget/MapLayerDroppable.d.ts.map +1 -0
  113. package/lib/esm/ui/widget/MapLayerDroppable.js +80 -0
  114. package/lib/esm/ui/widget/MapLayerDroppable.js.map +1 -0
  115. package/lib/esm/ui/widget/MapLayerManager.d.ts +27 -0
  116. package/lib/esm/ui/widget/MapLayerManager.d.ts.map +1 -0
  117. package/lib/esm/ui/widget/MapLayerManager.js +347 -0
  118. package/lib/esm/ui/widget/MapLayerManager.js.map +1 -0
  119. package/lib/esm/ui/widget/MapLayerManager.scss +525 -0
  120. package/lib/esm/ui/widget/MapLayerSettingsMenu.d.ts +10 -0
  121. package/lib/esm/ui/widget/MapLayerSettingsMenu.d.ts.map +1 -0
  122. package/lib/esm/ui/widget/MapLayerSettingsMenu.js +79 -0
  123. package/lib/esm/ui/widget/MapLayerSettingsMenu.js.map +1 -0
  124. package/lib/esm/ui/widget/MapLayerSettingsPopupButton.d.ts +5 -0
  125. package/lib/esm/ui/widget/MapLayerSettingsPopupButton.d.ts.map +1 -0
  126. package/lib/esm/ui/widget/MapLayerSettingsPopupButton.js +31 -0
  127. package/lib/esm/ui/widget/MapLayerSettingsPopupButton.js.map +1 -0
  128. package/lib/esm/ui/widget/MapLayerSettingsPopupButton.scss +31 -0
  129. package/lib/esm/ui/widget/MapLayersWidget.d.ts +12 -0
  130. package/lib/esm/ui/widget/MapLayersWidget.d.ts.map +1 -0
  131. package/lib/esm/ui/widget/MapLayersWidget.js +23 -0
  132. package/lib/esm/ui/widget/MapLayersWidget.js.map +1 -0
  133. package/lib/esm/ui/widget/MapManagerSettings.d.ts +4 -0
  134. package/lib/esm/ui/widget/MapManagerSettings.d.ts.map +1 -0
  135. package/lib/esm/ui/widget/MapManagerSettings.js +168 -0
  136. package/lib/esm/ui/widget/MapManagerSettings.js.map +1 -0
  137. package/lib/esm/ui/widget/MapManagerSettings.scss +23 -0
  138. package/lib/esm/ui/widget/MapUrlDialog.d.ts +23 -0
  139. package/lib/esm/ui/widget/MapUrlDialog.d.ts.map +1 -0
  140. package/lib/esm/ui/widget/MapUrlDialog.js +346 -0
  141. package/lib/esm/ui/widget/MapUrlDialog.js.map +1 -0
  142. package/lib/esm/ui/widget/MapUrlDialog.scss +85 -0
  143. package/lib/esm/ui/widget/SubLayersDataProvider.d.ts +21 -0
  144. package/lib/esm/ui/widget/SubLayersDataProvider.d.ts.map +1 -0
  145. package/lib/esm/ui/widget/SubLayersDataProvider.js +73 -0
  146. package/lib/esm/ui/widget/SubLayersDataProvider.js.map +1 -0
  147. package/lib/esm/ui/widget/SubLayersPopupButton.d.ts +11 -0
  148. package/lib/esm/ui/widget/SubLayersPopupButton.d.ts.map +1 -0
  149. package/lib/esm/ui/widget/SubLayersPopupButton.js +36 -0
  150. package/lib/esm/ui/widget/SubLayersPopupButton.js.map +1 -0
  151. package/lib/esm/ui/widget/SubLayersTree.d.ts +16 -0
  152. package/lib/esm/ui/widget/SubLayersTree.d.ts.map +1 -0
  153. package/lib/esm/ui/widget/SubLayersTree.js +374 -0
  154. package/lib/esm/ui/widget/SubLayersTree.js.map +1 -0
  155. package/lib/esm/ui/widget/SubLayersTree.scss +64 -0
  156. package/lib/esm/ui/widget/TransparencyPopupButton.d.ts +14 -0
  157. package/lib/esm/ui/widget/TransparencyPopupButton.d.ts.map +1 -0
  158. package/lib/esm/ui/widget/TransparencyPopupButton.js +44 -0
  159. package/lib/esm/ui/widget/TransparencyPopupButton.js.map +1 -0
  160. package/lib/esm/ui/widget/TransparencyPopupButton.scss +53 -0
  161. package/lib/public/en/mapLayers.json +113 -0
  162. package/package.json +45 -39
  163. package/lib/map-layers.d.ts.map +0 -1
  164. package/lib/map-layers.js.map +0 -1
  165. package/lib/mapLayers.d.ts.map +0 -1
  166. package/lib/mapLayers.js.map +0 -1
  167. package/lib/ui/Interfaces.d.ts.map +0 -1
  168. package/lib/ui/Interfaces.js.map +0 -1
  169. package/lib/ui/MapLayersUiItemsProvider.d.ts.map +0 -1
  170. package/lib/ui/MapLayersUiItemsProvider.js.map +0 -1
  171. package/lib/ui/widget/AttachLayerPopupButton.d.ts.map +0 -1
  172. package/lib/ui/widget/AttachLayerPopupButton.js.map +0 -1
  173. package/lib/ui/widget/BasemapPanel.d.ts.map +0 -1
  174. package/lib/ui/widget/BasemapPanel.js.map +0 -1
  175. package/lib/ui/widget/ConfirmMessageDialog.d.ts.map +0 -1
  176. package/lib/ui/widget/ConfirmMessageDialog.js.map +0 -1
  177. package/lib/ui/widget/MapLayerDroppable.d.ts.map +0 -1
  178. package/lib/ui/widget/MapLayerDroppable.js.map +0 -1
  179. package/lib/ui/widget/MapLayerManager.d.ts.map +0 -1
  180. package/lib/ui/widget/MapLayerManager.js.map +0 -1
  181. package/lib/ui/widget/MapLayerSettingsMenu.d.ts.map +0 -1
  182. package/lib/ui/widget/MapLayerSettingsMenu.js.map +0 -1
  183. package/lib/ui/widget/MapLayerSettingsPopupButton.d.ts.map +0 -1
  184. package/lib/ui/widget/MapLayerSettingsPopupButton.js.map +0 -1
  185. package/lib/ui/widget/MapLayersWidget.d.ts.map +0 -1
  186. package/lib/ui/widget/MapLayersWidget.js.map +0 -1
  187. package/lib/ui/widget/MapManagerSettings.d.ts.map +0 -1
  188. package/lib/ui/widget/MapManagerSettings.js.map +0 -1
  189. package/lib/ui/widget/MapUrlDialog.d.ts.map +0 -1
  190. package/lib/ui/widget/MapUrlDialog.js.map +0 -1
  191. package/lib/ui/widget/SubLayersDataProvider.d.ts.map +0 -1
  192. package/lib/ui/widget/SubLayersDataProvider.js.map +0 -1
  193. package/lib/ui/widget/SubLayersPopupButton.d.ts.map +0 -1
  194. package/lib/ui/widget/SubLayersPopupButton.js.map +0 -1
  195. package/lib/ui/widget/SubLayersTree.d.ts.map +0 -1
  196. package/lib/ui/widget/SubLayersTree.js.map +0 -1
  197. package/lib/ui/widget/TransparencyPopupButton.d.ts.map +0 -1
  198. package/lib/ui/widget/TransparencyPopupButton.js.map +0 -1
@@ -0,0 +1,141 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ /* eslint-disable deprecation/deprecation */
6
+ // cSpell:ignore droppable Sublayer Basemap
7
+ import * as React from "react";
8
+ import { BaseMapLayerSettings, ColorByName, ColorDef, MapLayerSettings } from "@itwin/core-common";
9
+ import { ColorPickerDialog, ColorSwatch } from "@itwin/imodel-components-react";
10
+ import { ThemedSelect, WebFontIcon } from "@itwin/core-react";
11
+ import { ModalDialogManager } from "@itwin/appui-react";
12
+ import { TransparencyPopupButton } from "./TransparencyPopupButton";
13
+ import { useSourceMapContext } from "./MapLayerManager";
14
+ import "./BasemapPanel.scss";
15
+ import { MapLayersUiItemsProvider } from "../MapLayersUiItemsProvider";
16
+ function getBaseMapFromStyle(displayStyle) {
17
+ if (!displayStyle)
18
+ return undefined;
19
+ if (displayStyle.settings.mapImagery.backgroundBase instanceof MapLayerSettings || displayStyle.settings.mapImagery.backgroundBase instanceof ColorDef)
20
+ return displayStyle.settings.mapImagery.backgroundBase.toJSON();
21
+ return undefined;
22
+ }
23
+ /** @internal */
24
+ // eslint-disable-next-line @typescript-eslint/naming-convention
25
+ export function BasemapPanel() {
26
+ const [useColorLabel] = React.useState(MapLayersUiItemsProvider.localization.getLocalizedString("mapLayers:Basemap.ColorFill"));
27
+ const { activeViewport, bases } = useSourceMapContext();
28
+ const [baseMapTransparencyValue, setBaseMapTransparencyValue] = React.useState(() => {
29
+ if (activeViewport)
30
+ return activeViewport.displayStyle.baseMapTransparency;
31
+ return 0;
32
+ });
33
+ const handleBasemapTransparencyChange = React.useCallback((transparency) => {
34
+ if (activeViewport) {
35
+ activeViewport.displayStyle.changeBaseMapTransparency(transparency);
36
+ activeViewport.invalidateRenderPlan();
37
+ setBaseMapTransparencyValue(transparency);
38
+ }
39
+ }, [activeViewport]);
40
+ const baseMapOptions = React.useMemo(() => {
41
+ const baseOptions = [];
42
+ baseOptions.push({ value: useColorLabel, label: useColorLabel });
43
+ if (bases)
44
+ baseOptions.push(...bases.map((value) => ({ value: value.name, label: value.name })));
45
+ return baseOptions;
46
+ }, [bases, useColorLabel]);
47
+ const [presetColors] = React.useState([
48
+ ColorDef.create(ColorByName.grey),
49
+ ColorDef.create(ColorByName.lightGrey),
50
+ ColorDef.create(ColorByName.darkGrey),
51
+ ColorDef.create(ColorByName.lightBlue),
52
+ ColorDef.create(ColorByName.lightGreen),
53
+ ColorDef.create(ColorByName.darkGreen),
54
+ ColorDef.create(ColorByName.tan),
55
+ ColorDef.create(ColorByName.darkBrown),
56
+ ]);
57
+ const [selectedBaseMap, setSelectedBaseMap] = React.useState(getBaseMapFromStyle(activeViewport === null || activeViewport === void 0 ? void 0 : activeViewport.displayStyle));
58
+ const baseIsColor = React.useMemo(() => typeof selectedBaseMap === "number", [selectedBaseMap]);
59
+ const baseIsMap = React.useMemo(() => !baseIsColor && (selectedBaseMap !== undefined), [baseIsColor, selectedBaseMap]);
60
+ const bgColor = React.useMemo(() => baseIsColor ? selectedBaseMap : presetColors[0].toJSON(), [baseIsColor, selectedBaseMap, presetColors]);
61
+ const [colorDialogTitle] = React.useState(MapLayersUiItemsProvider.localization.getLocalizedString("mapLayers:ColorDialog.Title"));
62
+ const selectedBaseMapValue = React.useMemo(() => {
63
+ if (baseIsMap) {
64
+ const mapName = selectedBaseMap.name;
65
+ const foundItem = baseMapOptions.find((value) => value.label === mapName);
66
+ if (foundItem)
67
+ return foundItem;
68
+ }
69
+ return baseMapOptions[0];
70
+ }, [selectedBaseMap, baseMapOptions, baseIsMap]);
71
+ const handleBackgroundColorDialogOk = React.useCallback((bgColorDef) => {
72
+ ModalDialogManager.closeDialog();
73
+ if (activeViewport) {
74
+ // change color and make sure previously set transparency is not lost.
75
+ const curTransparency = activeViewport.displayStyle.backgroundMapBase instanceof ColorDef ? activeViewport.displayStyle.backgroundMapBase.getTransparency() : 0;
76
+ activeViewport.displayStyle.backgroundMapBase = bgColorDef.withTransparency(curTransparency);
77
+ activeViewport.invalidateRenderPlan();
78
+ setSelectedBaseMap(bgColorDef.toJSON());
79
+ }
80
+ }, [activeViewport]);
81
+ const handleBackgroundColorDialogCancel = React.useCallback(() => {
82
+ ModalDialogManager.closeDialog();
83
+ }, []);
84
+ const handleBgColorClick = React.useCallback((newColor, e) => {
85
+ e.preventDefault();
86
+ ModalDialogManager.openDialog(React.createElement(ColorPickerDialog, { dialogTitle: colorDialogTitle, color: newColor, colorPresets: presetColors, onOkResult: handleBackgroundColorDialogOk, onCancelResult: handleBackgroundColorDialogCancel }));
87
+ }, [presetColors, handleBackgroundColorDialogOk]); // eslint-disable-line react-hooks/exhaustive-deps
88
+ const handleBaseMapSelection = React.useCallback((value, action) => {
89
+ if (bases && activeViewport && action.action === "select-option" && value) {
90
+ const baseMap = bases.find((map) => map.name === value.label);
91
+ if (baseMap) {
92
+ const baseProps = baseMap.toJSON();
93
+ if (activeViewport.displayStyle.backgroundMapBase instanceof BaseMapLayerSettings) {
94
+ activeViewport.displayStyle.backgroundMapBase = activeViewport.displayStyle.backgroundMapBase.clone(baseProps);
95
+ }
96
+ else {
97
+ activeViewport.displayStyle.backgroundMapBase = BaseMapLayerSettings.fromJSON(baseProps);
98
+ }
99
+ activeViewport.invalidateRenderPlan();
100
+ setSelectedBaseMap(baseProps);
101
+ }
102
+ else {
103
+ const bgColorDef = ColorDef.fromJSON(bgColor);
104
+ const curTransparency = activeViewport.displayStyle.backgroundMapBase instanceof ColorDef ? activeViewport.displayStyle.backgroundMapBase.getTransparency() : 0;
105
+ activeViewport.displayStyle.backgroundMapBase = bgColorDef.withTransparency(curTransparency);
106
+ activeViewport.invalidateRenderPlan();
107
+ setSelectedBaseMap(bgColorDef.toJSON());
108
+ }
109
+ }
110
+ }, [bases, activeViewport, bgColor]);
111
+ const [baseMapVisible, setBaseMapVisible] = React.useState(() => {
112
+ if (activeViewport && activeViewport.displayStyle.backgroundMapBase instanceof MapLayerSettings) {
113
+ return activeViewport.displayStyle.backgroundMapBase.visible;
114
+ }
115
+ return false;
116
+ });
117
+ const handleVisibilityChange = React.useCallback(() => {
118
+ if (activeViewport) {
119
+ const newState = !baseMapVisible;
120
+ // BaseMap visibility is only support when backgroundBase is an instance of BaseMapLayerSettings (i.e not a color)...
121
+ if (activeViewport.displayStyle.backgroundMapBase instanceof BaseMapLayerSettings) {
122
+ activeViewport.displayStyle.backgroundMapBase = activeViewport.displayStyle.backgroundMapBase.clone({ visible: newState });
123
+ activeViewport.invalidateRenderPlan();
124
+ }
125
+ setBaseMapVisible(newState);
126
+ }
127
+ }, [baseMapVisible, activeViewport]);
128
+ const [baseLayerLabel] = React.useState(MapLayersUiItemsProvider.localization.getLocalizedString("mapLayers:Basemap.BaseLayer"));
129
+ const [selectBaseMapLabel] = React.useState(MapLayersUiItemsProvider.localization.getLocalizedString("mapLayers:Basemap.SelectBaseMap"));
130
+ const [toggleVisibility] = React.useState(MapLayersUiItemsProvider.localization.getLocalizedString("mapLayers:Widget.ToggleVisibility"));
131
+ return (React.createElement(React.Fragment, null,
132
+ React.createElement("div", { className: "map-manager-base-item" },
133
+ React.createElement("button", { className: "map-manager-item-visibility", title: toggleVisibility, onClick: handleVisibilityChange },
134
+ React.createElement(WebFontIcon, { iconName: baseMapVisible ? "icon-visibility" : "icon-visibility-hide-2" })),
135
+ React.createElement("span", { className: "map-manager-base-label" }, baseLayerLabel),
136
+ React.createElement(ThemedSelect, { options: baseMapOptions, closeMenuOnSelect: true, placeholder: selectBaseMapLabel, value: selectedBaseMapValue, onChange: handleBaseMapSelection }),
137
+ baseIsColor &&
138
+ React.createElement(ColorSwatch, { className: "map-manager-base-item-color", colorDef: ColorDef.fromJSON(bgColor), round: false, onColorPick: handleBgColorClick }),
139
+ React.createElement(TransparencyPopupButton, { transparency: baseMapTransparencyValue, onTransparencyChange: handleBasemapTransparencyChange }))));
140
+ }
141
+ //# sourceMappingURL=BasemapPanel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BasemapPanel.js","sourceRoot":"","sources":["../../../../src/ui/widget/BasemapPanel.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,4CAA4C;AAC5C,2CAA2C;AAE3C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,QAAQ,EAAiB,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAElH,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAChF,OAAO,EAAc,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAE1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,qBAAqB,CAAC;AAC7B,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AAEvE,SAAS,mBAAmB,CAAC,YAA2C;IACtE,IAAI,CAAC,YAAY;QACf,OAAO,SAAS,CAAC;IAEnB,IAAI,YAAY,CAAC,QAAQ,CAAC,UAAU,CAAC,cAAc,YAAY,gBAAgB,IAAI,YAAY,CAAC,QAAQ,CAAC,UAAU,CAAC,cAAc,YAAY,QAAQ;QACpJ,OAAO,YAAY,CAAC,QAAQ,CAAC,UAAU,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC;IAElE,OAAO,SAAS,CAAC;AACnB,CAAC;AAMD,gBAAgB;AAChB,gEAAgE;AAChE,MAAM,UAAU,YAAY;IAC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B,CAAC,YAAY,CAAC,kBAAkB,CAAC,6BAA6B,CAAC,CAAC,CAAC;IACjI,MAAM,CAAC,kBAAkB,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,wBAAwB,CAAC,YAAY,CAAC,kBAAkB,CAAC,iCAAiC,CAAC,CAAC,CAAC;IACzI,MAAM,CAAC,gBAAgB,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,wBAAwB,CAAC,YAAY,CAAC,kBAAkB,CAAC,mCAAmC,CAAC,CAAC,CAAC;IAEzI,OAAO,CACL;QACE,6BAAK,SAAS,EAAC,uBAAuB;YACpC,gCAAQ,SAAS,EAAC,6BAA6B,EAAC,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,sBAAsB;gBACtG,oBAAC,WAAW,IAAC,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,wBAAwB,GAAI,CACjF;YACT,8BAAM,SAAS,EAAC,wBAAwB,IAAE,cAAc,CAAQ;YAChE,oBAAC,YAAY,IAAC,OAAO,EAAE,cAAc,EAAE,iBAAiB,QAAC,WAAW,EAAE,kBAAkB,EAAE,KAAK,EAAE,oBAAoB,EAAE,QAAQ,EAAE,sBAAsB,GAAI;YAEzJ,WAAW;gBACX,oBAAC,WAAW,IAAC,SAAS,EAAC,6BAA6B,EAAC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,kBAAkB,GAAI;YAE9I,oBAAC,uBAAuB,IAAC,YAAY,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,+BAA+B,GAAI,CACtH,CACL,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\n/* eslint-disable deprecation/deprecation */\r\n// cSpell:ignore droppable Sublayer Basemap\r\n\r\nimport * as React from \"react\";\r\nimport { BaseMapLayerSettings, ColorByName, ColorDef, MapLayerProps, MapLayerSettings } from \"@itwin/core-common\";\r\nimport { DisplayStyleState } from \"@itwin/core-frontend\";\r\nimport { ColorPickerDialog, ColorSwatch } from \"@itwin/imodel-components-react\";\r\nimport { OptionType, ThemedSelect, WebFontIcon } from \"@itwin/core-react\";\r\nimport { ActionMeta, ValueType } from \"react-select/src/types\";\r\nimport { ModalDialogManager } from \"@itwin/appui-react\";\r\nimport { TransparencyPopupButton } from \"./TransparencyPopupButton\";\r\nimport { useSourceMapContext } from \"./MapLayerManager\";\r\nimport \"./BasemapPanel.scss\";\r\nimport { MapLayersUiItemsProvider } from \"../MapLayersUiItemsProvider\";\r\n\r\nfunction getBaseMapFromStyle(displayStyle: DisplayStyleState | undefined) {\r\n if (!displayStyle)\r\n return undefined;\r\n\r\n if (displayStyle.settings.mapImagery.backgroundBase instanceof MapLayerSettings || displayStyle.settings.mapImagery.backgroundBase instanceof ColorDef)\r\n return displayStyle.settings.mapImagery.backgroundBase.toJSON();\r\n\r\n return undefined;\r\n}\r\n\r\ninterface BaseOption extends OptionType {\r\n color?: string;\r\n}\r\n\r\n/** @internal */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function BasemapPanel() {\r\n const [useColorLabel] = React.useState(MapLayersUiItemsProvider.localization.getLocalizedString(\"mapLayers:Basemap.ColorFill\"));\r\n const { activeViewport, bases } = useSourceMapContext();\r\n\r\n const [baseMapTransparencyValue, setBaseMapTransparencyValue] = React.useState(() => {\r\n if (activeViewport)\r\n return activeViewport.displayStyle.baseMapTransparency;\r\n return 0;\r\n });\r\n\r\n const handleBasemapTransparencyChange = React.useCallback((transparency: number) => {\r\n if (activeViewport) {\r\n activeViewport.displayStyle.changeBaseMapTransparency(transparency);\r\n activeViewport.invalidateRenderPlan();\r\n setBaseMapTransparencyValue(transparency);\r\n }\r\n }, [activeViewport]);\r\n\r\n const baseMapOptions = React.useMemo<BaseOption[]>(() => {\r\n const baseOptions: BaseOption[] = [];\r\n\r\n baseOptions.push({ value: useColorLabel, label: useColorLabel });\r\n\r\n if (bases)\r\n baseOptions.push(...bases.map((value) => ({ value: value.name, label: value.name })));\r\n return baseOptions;\r\n }, [bases, useColorLabel]);\r\n\r\n const [presetColors] = React.useState([\r\n ColorDef.create(ColorByName.grey),\r\n ColorDef.create(ColorByName.lightGrey),\r\n ColorDef.create(ColorByName.darkGrey),\r\n ColorDef.create(ColorByName.lightBlue),\r\n ColorDef.create(ColorByName.lightGreen),\r\n ColorDef.create(ColorByName.darkGreen),\r\n ColorDef.create(ColorByName.tan),\r\n ColorDef.create(ColorByName.darkBrown),\r\n ]);\r\n\r\n const [selectedBaseMap, setSelectedBaseMap] = React.useState<MapLayerProps | number | undefined>(getBaseMapFromStyle(activeViewport?.displayStyle));\r\n const baseIsColor = React.useMemo(() => typeof selectedBaseMap === \"number\", [selectedBaseMap]);\r\n const baseIsMap = React.useMemo(() => !baseIsColor && (selectedBaseMap !== undefined), [baseIsColor, selectedBaseMap]);\r\n const bgColor = React.useMemo(() => baseIsColor ? selectedBaseMap as number : presetColors[0].toJSON(), [baseIsColor, selectedBaseMap, presetColors]);\r\n const [colorDialogTitle] = React.useState(MapLayersUiItemsProvider.localization.getLocalizedString(\"mapLayers:ColorDialog.Title\"));\r\n const selectedBaseMapValue = React.useMemo(() => {\r\n if (baseIsMap) {\r\n const mapName = (selectedBaseMap! as MapLayerProps).name;\r\n const foundItem = baseMapOptions.find((value) => value.label === mapName);\r\n if (foundItem)\r\n return foundItem;\r\n }\r\n return baseMapOptions[0];\r\n }, [selectedBaseMap, baseMapOptions, baseIsMap]);\r\n\r\n const handleBackgroundColorDialogOk = React.useCallback((bgColorDef: ColorDef) => {\r\n ModalDialogManager.closeDialog();\r\n if (activeViewport) {\r\n // change color and make sure previously set transparency is not lost.\r\n const curTransparency = activeViewport.displayStyle.backgroundMapBase instanceof ColorDef ? activeViewport.displayStyle.backgroundMapBase.getTransparency() : 0;\r\n activeViewport.displayStyle.backgroundMapBase = bgColorDef.withTransparency(curTransparency);\r\n activeViewport.invalidateRenderPlan();\r\n setSelectedBaseMap(bgColorDef.toJSON());\r\n }\r\n }, [activeViewport]);\r\n\r\n const handleBackgroundColorDialogCancel = React.useCallback(() => {\r\n ModalDialogManager.closeDialog();\r\n }, []);\r\n\r\n const handleBgColorClick = React.useCallback((newColor: ColorDef, e: React.MouseEvent<Element, MouseEvent>) => {\r\n e.preventDefault();\r\n ModalDialogManager.openDialog(<ColorPickerDialog dialogTitle={colorDialogTitle} color={newColor} colorPresets={presetColors}\r\n onOkResult={handleBackgroundColorDialogOk} onCancelResult={handleBackgroundColorDialogCancel} />);\r\n }, [presetColors, handleBackgroundColorDialogOk]); // eslint-disable-line react-hooks/exhaustive-deps\r\n\r\n const handleBaseMapSelection = React.useCallback((value: ValueType<BaseOption>, action: ActionMeta<BaseOption>) => {\r\n if (bases && activeViewport && action.action === \"select-option\" && value) {\r\n const baseMap = bases.find((map) => map.name === (value as BaseOption).label);\r\n if (baseMap) {\r\n const baseProps: MapLayerProps = baseMap.toJSON();\r\n if (activeViewport.displayStyle.backgroundMapBase instanceof BaseMapLayerSettings) {\r\n activeViewport.displayStyle.backgroundMapBase = activeViewport.displayStyle.backgroundMapBase.clone(baseProps);\r\n } else {\r\n activeViewport.displayStyle.backgroundMapBase = BaseMapLayerSettings.fromJSON(baseProps);\r\n }\r\n activeViewport.invalidateRenderPlan();\r\n setSelectedBaseMap(baseProps);\r\n } else {\r\n const bgColorDef = ColorDef.fromJSON(bgColor);\r\n const curTransparency = activeViewport.displayStyle.backgroundMapBase instanceof ColorDef ? activeViewport.displayStyle.backgroundMapBase.getTransparency() : 0;\r\n activeViewport.displayStyle.backgroundMapBase = bgColorDef.withTransparency(curTransparency);\r\n activeViewport.invalidateRenderPlan();\r\n setSelectedBaseMap(bgColorDef.toJSON());\r\n }\r\n }\r\n }, [bases, activeViewport, bgColor]);\r\n\r\n const [baseMapVisible, setBaseMapVisible] = React.useState(() => {\r\n if (activeViewport && activeViewport.displayStyle.backgroundMapBase instanceof MapLayerSettings) {\r\n return activeViewport.displayStyle.backgroundMapBase.visible;\r\n }\r\n return false;\r\n });\r\n\r\n const handleVisibilityChange = React.useCallback(() => {\r\n if (activeViewport) {\r\n const newState = !baseMapVisible;\r\n // BaseMap visibility is only support when backgroundBase is an instance of BaseMapLayerSettings (i.e not a color)...\r\n if (activeViewport.displayStyle.backgroundMapBase instanceof BaseMapLayerSettings) {\r\n activeViewport.displayStyle.backgroundMapBase = activeViewport.displayStyle.backgroundMapBase.clone({ visible: newState });\r\n activeViewport.invalidateRenderPlan();\r\n }\r\n setBaseMapVisible(newState);\r\n }\r\n }, [baseMapVisible, activeViewport]);\r\n\r\n const [baseLayerLabel] = React.useState(MapLayersUiItemsProvider.localization.getLocalizedString(\"mapLayers:Basemap.BaseLayer\"));\r\n const [selectBaseMapLabel] = React.useState(MapLayersUiItemsProvider.localization.getLocalizedString(\"mapLayers:Basemap.SelectBaseMap\"));\r\n const [toggleVisibility] = React.useState(MapLayersUiItemsProvider.localization.getLocalizedString(\"mapLayers:Widget.ToggleVisibility\"));\r\n\r\n return (\r\n <>\r\n <div className=\"map-manager-base-item\" >\r\n <button className=\"map-manager-item-visibility\" title={toggleVisibility} onClick={handleVisibilityChange}>\r\n <WebFontIcon iconName={baseMapVisible ? \"icon-visibility\" : \"icon-visibility-hide-2\"} />\r\n </button>\r\n <span className=\"map-manager-base-label\">{baseLayerLabel}</span>\r\n <ThemedSelect options={baseMapOptions} closeMenuOnSelect placeholder={selectBaseMapLabel} value={selectedBaseMapValue} onChange={handleBaseMapSelection} />\r\n {\r\n baseIsColor &&\r\n <ColorSwatch className=\"map-manager-base-item-color\" colorDef={ColorDef.fromJSON(bgColor)} round={false} onColorPick={handleBgColorClick} />\r\n }\r\n <TransparencyPopupButton transparency={baseMapTransparencyValue} onTransparencyChange={handleBasemapTransparencyChange} />\r\n </div>\r\n </>\r\n );\r\n}\r\n"]}
@@ -0,0 +1,98 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ @import "~@itwin/core-react/lib/cjs/core-react/index";
6
+
7
+ $divider-color: $buic-background-toolbutton-stroke;
8
+ $hovered-icon-color: $buic-foreground-primary-tone;
9
+
10
+ .map-manager-basemap {
11
+ display: flex;
12
+ flex-direction: column;
13
+ width: 100%;
14
+ align-items: flex-start;
15
+ margin-bottom: 15px;
16
+
17
+ * {
18
+ box-sizing: border-box;
19
+ }
20
+
21
+ .map-manager-base-header {
22
+ display: flex;
23
+ align-items: center;
24
+ width: 100%;
25
+ margin-top: 5px;
26
+
27
+ .map-transparency-popup-button {
28
+ background-color: transparent;
29
+ margin-left: 5px;
30
+ width: 40px;
31
+ border: none;
32
+ color: $buic-foreground-body;
33
+
34
+ &:hover {
35
+ color: $hovered-icon-color;
36
+ }
37
+ }
38
+ }
39
+
40
+ .map-manager-base-label {
41
+ padding-right: 10px;
42
+ }
43
+
44
+ .map-manager-base-item {
45
+ display: flex;
46
+ flex-direction: row;
47
+ align-items: center;
48
+ width: 100%;
49
+
50
+ button.map-manager-base-item-visibility {
51
+ border: none;
52
+ margin-right: 4px;
53
+ background-color: transparent;
54
+ color: $buic-foreground-body;
55
+
56
+ &:hover {
57
+ color: $hovered-icon-color;
58
+ }
59
+ }
60
+
61
+ button.map-manager-base-settings-button {
62
+ border: none;
63
+ margin-left: 4px;
64
+ background-color: transparent;
65
+ color: $buic-foreground-body;
66
+
67
+ &:hover {
68
+ color: $hovered-icon-color;
69
+ }
70
+ }
71
+
72
+ .uicore-reactSelectTop {
73
+ width: 100%;
74
+ line-height: inherit;
75
+ }
76
+
77
+ .map-manager-base-item-select {
78
+ height: 2.0em;
79
+ width: 100%;
80
+ min-width: 100px;
81
+ margin-right: 6px;
82
+ }
83
+
84
+ .map-manager-base-item-transparency {
85
+ max-width: 160px;
86
+ width: 160px;
87
+ display: flex;
88
+ justify-content: center;
89
+ margin-right: 6px;
90
+ }
91
+
92
+ .map-manager-base-item-color.components-color-swatch {
93
+ margin-left: 6px;
94
+ width: 2em;
95
+ height: 2em;
96
+ }
97
+ }
98
+ }
@@ -0,0 +1,22 @@
1
+ /// <reference types="react" />
2
+ import { CommonProps } from "@itwin/core-react";
3
+ import "./MapUrlDialog.scss";
4
+ interface ConfirmMessageDialogProps extends CommonProps {
5
+ /** Title to show in title bar of dialog */
6
+ title?: string | JSX.Element;
7
+ message?: string | JSX.Element;
8
+ onYesResult?: () => void;
9
+ onNoResult?: () => void;
10
+ onClose?: () => void;
11
+ onEscape?: () => void;
12
+ minWidth?: string | number;
13
+ /** Minimum height that the dialog may be resized to. Displayed in px if value is a number; otherwise, displayed in specified CSS unit. Default: 100px */
14
+ minHeight?: string | number;
15
+ /** Maximum width that the dialog may be resized to. Displayed in px if value is a number; otherwise, displayed in specified CSS unit. */
16
+ maxWidth?: string | number;
17
+ /** Maximum height that the dialog may be resized to. Displayed in px if value is a number; otherwise, displayed in specified CSS unit. */
18
+ maxHeight?: string | number;
19
+ }
20
+ export declare function ConfirmMessageDialog(props: ConfirmMessageDialogProps): JSX.Element;
21
+ export {};
22
+ //# sourceMappingURL=ConfirmMessageDialog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConfirmMessageDialog.d.ts","sourceRoot":"","sources":["../../../../src/ui/widget/ConfirmMessageDialog.tsx"],"names":[],"mappings":";AAOA,OAAO,EAAE,WAAW,EAAU,MAAM,mBAAmB,CAAC;AAExD,OAAO,qBAAqB,CAAC;AAG7B,UAAU,yBAA0B,SAAQ,WAAW;IAErD,2CAA2C;IAC3C,KAAK,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC;IAC/B,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B,yJAAyJ;IACzJ,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,yIAAyI;IACzI,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B,0IAA0I;IAC1I,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC7B;AAGD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,eA2BpE"}
@@ -0,0 +1,22 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ // cSpell:ignore Modeless WMTS
6
+ import * as React from "react";
7
+ import { Dialog } from "@itwin/core-react";
8
+ import "./MapUrlDialog.scss";
9
+ import { DialogButtonType } from "@itwin/appui-abstract";
10
+ // eslint-disable-next-line @typescript-eslint/naming-convention
11
+ export function ConfirmMessageDialog(props) {
12
+ const buttonCluster = React.useMemo(() => {
13
+ var _a, _b;
14
+ return [
15
+ { type: DialogButtonType.Yes, onClick: (_a = props.onYesResult) !== null && _a !== void 0 ? _a : (() => { }) },
16
+ { type: DialogButtonType.No, onClick: (_b = props.onNoResult) !== null && _b !== void 0 ? _b : (() => { }) },
17
+ ];
18
+ }, [props.onYesResult, props.onNoResult]);
19
+ return (React.createElement(Dialog, { className: props.className, title: props.title, opened: true, resizable: false, movable: true, modal: true, buttonCluster: buttonCluster, onClose: props.onClose, onEscape: props.onEscape, minHeight: props.minHeight, maxHeight: props.maxHeight, minWidth: props.minWidth, maxWidth: props.maxWidth, trapFocus: false },
20
+ React.createElement("div", null, props.message)));
21
+ }
22
+ //# sourceMappingURL=ConfirmMessageDialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConfirmMessageDialog.js","sourceRoot":"","sources":["../../../../src/ui/widget/ConfirmMessageDialog.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,8BAA8B;AAE9B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAe,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAExD,OAAO,qBAAqB,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAoBzD,gEAAgE;AAChE,MAAM,UAAU,oBAAoB,CAAC,KAAgC;IAEnE,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;;QAAC,OAAA;YACxC,EAAE,IAAI,EAAE,gBAAgB,CAAC,GAAG,EAAE,OAAO,EAAE,MAAA,KAAK,CAAC,WAAW,mCAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,EAAE;YACzE,EAAE,IAAI,EAAE,gBAAgB,CAAC,EAAE,EAAE,OAAO,EAAE,MAAA,KAAK,CAAC,UAAU,mCAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,EAAE;SACxE,CAAA;KAAA,EAAE,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;IAE1C,OAAO,CACL,oBAAC,MAAM,IACL,SAAS,EAAE,KAAK,CAAC,SAAS,EAC1B,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,MAAM,EAAE,IAAI,EACZ,SAAS,EAAE,KAAK,EAChB,OAAO,EAAE,IAAI,EACb,KAAK,EAAE,IAAI,EACX,aAAa,EAAE,aAAa,EAC5B,OAAO,EAAE,KAAK,CAAC,OAAO,EACtB,QAAQ,EAAE,KAAK,CAAC,QAAQ,EACxB,SAAS,EAAE,KAAK,CAAC,SAAS,EAC1B,SAAS,EAAE,KAAK,CAAC,SAAS,EAC1B,QAAQ,EAAE,KAAK,CAAC,QAAQ,EACxB,QAAQ,EAAE,KAAK,CAAC,QAAQ,EACxB,SAAS,EAAE,KAAK;QAEhB,iCAAM,KAAK,CAAC,OAAO,CAAO,CACnB,CACV,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 Modeless WMTS\n\nimport * as React from \"react\";\nimport { CommonProps, Dialog } from \"@itwin/core-react\";\n\nimport \"./MapUrlDialog.scss\";\nimport { DialogButtonType } from \"@itwin/appui-abstract\";\n\ninterface ConfirmMessageDialogProps extends CommonProps {\n\n /** Title to show in title bar of dialog */\n title?: string | JSX.Element;\n message?: string | JSX.Element;\n onYesResult?: () => void;\n onNoResult?: () => void;\n onClose?: () => void;\n onEscape?: () => void;\n minWidth?: string | number;\n /** Minimum height that the dialog may be resized to. Displayed in px if value is a number; otherwise, displayed in specified CSS unit. Default: 100px */\n minHeight?: string | number;\n /** Maximum width that the dialog may be resized to. Displayed in px if value is a number; otherwise, displayed in specified CSS unit. */\n maxWidth?: string | number;\n /** Maximum height that the dialog may be resized to. Displayed in px if value is a number; otherwise, displayed in specified CSS unit. */\n maxHeight?: string | number;\n}\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport function ConfirmMessageDialog(props: ConfirmMessageDialogProps) {\n\n const buttonCluster = React.useMemo(() => [\n { type: DialogButtonType.Yes, onClick: props.onYesResult ?? (() => { }) },\n { type: DialogButtonType.No, onClick: props.onNoResult ?? (() => { }) },\n ], [props.onYesResult, props.onNoResult]);\n\n return (\n <Dialog\n className={props.className}\n title={props.title}\n opened={true}\n resizable={false}\n movable={true}\n modal={true}\n buttonCluster={buttonCluster}\n onClose={props.onClose}\n onEscape={props.onEscape}\n minHeight={props.minHeight}\n maxHeight={props.maxHeight}\n minWidth={props.minWidth}\n maxWidth={props.maxWidth}\n trapFocus={false}\n >\n <div>{props.message}</div>\n </Dialog>\n );\n}\n"]}
@@ -0,0 +1,19 @@
1
+ /// <reference types="react" />
2
+ import { ScreenViewport } from "@itwin/core-frontend";
3
+ import { MapTypesOptions, StyleMapLayerSettings } from "../Interfaces";
4
+ import "./MapLayerManager.scss";
5
+ /** @internal */
6
+ interface MapLayerDroppableProps {
7
+ isOverlay: boolean;
8
+ layersList?: StyleMapLayerSettings[];
9
+ mapTypesOptions?: MapTypesOptions;
10
+ getContainerForClone: () => HTMLElement;
11
+ activeViewport: ScreenViewport;
12
+ onMenuItemSelected: (action: string, mapLayerSettings: StyleMapLayerSettings) => void;
13
+ onItemVisibilityToggleClicked: (mapLayerSettings: StyleMapLayerSettings) => void;
14
+ onItemEdited: () => void;
15
+ }
16
+ /** @internal */
17
+ export declare function MapLayerDroppable(props: MapLayerDroppableProps): JSX.Element;
18
+ export {};
19
+ //# sourceMappingURL=MapLayerDroppable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MapLayerDroppable.d.ts","sourceRoot":"","sources":["../../../../src/ui/widget/MapLayerDroppable.tsx"],"names":[],"mappings":";AAWA,OAAO,EAAiC,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAQrF,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAGvE,OAAO,wBAAwB,CAAC;AAEhC,gBAAgB;AAChB,UAAU,sBAAsB;IAC9B,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,qBAAqB,EAAE,CAAC;IACrC,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,oBAAoB,EAAE,MAAM,WAAW,CAAC;IACxC,cAAc,EAAE,cAAc,CAAC;IAC/B,kBAAkB,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,qBAAqB,KAAK,IAAI,CAAC;IACtF,6BAA6B,EAAE,CAAC,gBAAgB,EAAE,qBAAqB,KAAK,IAAI,CAAC;IACjF,YAAY,EAAE,MAAM,IAAI,CAAC;CAC1B;AAED,gBAAgB;AAEhB,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,eAqG9D"}
@@ -0,0 +1,80 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ // cSpell:ignore droppable Sublayer Basemap
6
+ // the following quiet warning caused by react-beautiful-dnd package
7
+ /* eslint-disable @typescript-eslint/unbound-method */
8
+ import * as React from "react";
9
+ import { Draggable, Droppable } from "react-beautiful-dnd";
10
+ import { MapLayerImageryProviderStatus } from "@itwin/core-frontend";
11
+ import { Icon } from "@itwin/core-react";
12
+ import { assert } from "@itwin/core-bentley";
13
+ import { ModalDialogManager } from "@itwin/appui-react";
14
+ import { Button } from "@itwin/itwinui-react";
15
+ import { SubLayersPopupButton } from "./SubLayersPopupButton";
16
+ import { AttachLayerButtonType, AttachLayerPopupButton } from "./AttachLayerPopupButton";
17
+ import { MapLayersUiItemsProvider } from "../MapLayersUiItemsProvider";
18
+ import { MapLayerSettingsMenu } from "./MapLayerSettingsMenu";
19
+ import { MapUrlDialog } from "./MapUrlDialog";
20
+ import "./MapLayerManager.scss";
21
+ /** @internal */
22
+ // eslint-disable-next-line @typescript-eslint/naming-convention
23
+ export function MapLayerDroppable(props) {
24
+ const containsLayer = props.layersList && props.layersList.length > 0;
25
+ const droppableId = props.isOverlay ? "overlayMapLayers" : "backgroundMapLayers";
26
+ const [toggleVisibility] = React.useState(MapLayersUiItemsProvider.localization.getLocalizedString("mapLayers:Widget.ToggleVisibility"));
27
+ const [requireAuthTooltip] = React.useState(MapLayersUiItemsProvider.localization.getLocalizedString("mapLayers:Widget.RequireAuthTooltip"));
28
+ const [noBackgroundMapsSpecifiedLabel] = React.useState(MapLayersUiItemsProvider.localization.getLocalizedString("mapLayers:Widget.NoBackgroundLayers"));
29
+ const [noUnderlaysSpecifiedLabel] = React.useState(MapLayersUiItemsProvider.localization.getLocalizedString("mapLayers:Widget.NoOverlayLayers"));
30
+ const [dropLayerLabel] = React.useState(MapLayersUiItemsProvider.localization.getLocalizedString("mapLayers:Widget.DropLayerLabel"));
31
+ const renderItem = (dragProvided, _, rubric) => {
32
+ var _a;
33
+ assert(props.layersList !== undefined);
34
+ const activeLayer = props.layersList[rubric.source.index];
35
+ return (React.createElement("div", Object.assign({ className: "map-manager-source-item", "data-id": rubric.source.index, key: activeLayer.name }, dragProvided.draggableProps, { ref: dragProvided.innerRef }),
36
+ React.createElement("button", { className: "map-manager-item-visibility", title: toggleVisibility, onClick: () => { props.onItemVisibilityToggleClicked(activeLayer); } },
37
+ React.createElement(Icon, { iconSpec: activeLayer.visible ? "icon-visibility" : "icon-visibility-hide-2" })),
38
+ React.createElement("span", Object.assign({ className: "map-manager-item-label" }, dragProvided.dragHandleProps), activeLayer.name),
39
+ React.createElement("div", { className: "map-manager-item-sub-layer-container" }, activeLayer.subLayers && activeLayer.subLayers.length > 1 &&
40
+ React.createElement(SubLayersPopupButton, { mapLayerSettings: activeLayer, activeViewport: props.activeViewport })),
41
+ ((_a = activeLayer.provider) === null || _a === void 0 ? void 0 : _a.status) === MapLayerImageryProviderStatus.RequireAuth &&
42
+ React.createElement(Button, { className: "map-manager-item-requireAuth", onClick: () => {
43
+ var _a;
44
+ const indexInDisplayStyle = (_a = props.activeViewport) === null || _a === void 0 ? void 0 : _a.displayStyle.findMapLayerIndexByNameAndUrl(activeLayer.name, activeLayer.url, activeLayer.isOverlay);
45
+ if (indexInDisplayStyle !== undefined && indexInDisplayStyle >= 0) {
46
+ const layerSettings = props.activeViewport.displayStyle.mapLayerAtIndex(indexInDisplayStyle, activeLayer.isOverlay);
47
+ ModalDialogManager.openDialog(React.createElement(MapUrlDialog, { activeViewport: props.activeViewport, isOverlay: props.isOverlay, layerRequiringCredentials: layerSettings === null || layerSettings === void 0 ? void 0 : layerSettings.toJSON(), onOkResult: props.onItemEdited, mapTypesOptions: props.mapTypesOptions }));
48
+ }
49
+ }, title: requireAuthTooltip },
50
+ React.createElement(Icon, { iconSpec: "icon-status-warning" })),
51
+ React.createElement(MapLayerSettingsMenu, { activeViewport: props.activeViewport, mapLayerSettings: activeLayer, onMenuItemSelection: props.onMenuItemSelected })));
52
+ };
53
+ function renderDraggableContent(snapshot) {
54
+ var _a;
55
+ let node;
56
+ if (containsLayer) {
57
+ // Render a <Draggable>
58
+ node = ((_a = props.layersList) === null || _a === void 0 ? void 0 : _a.map((mapLayerSettings, i) => React.createElement(Draggable, { key: mapLayerSettings.name, draggableId: mapLayerSettings.name, index: i }, renderItem)));
59
+ }
60
+ else {
61
+ // Render a label that provide a 'Drop here' hint
62
+ const label = props.isOverlay ? noUnderlaysSpecifiedLabel : noBackgroundMapsSpecifiedLabel;
63
+ node =
64
+ React.createElement("div", { title: label, className: "map-manager-no-layers-container" }, snapshot.isDraggingOver ?
65
+ React.createElement("span", { className: "map-manager-no-layers-label" }, dropLayerLabel)
66
+ :
67
+ React.createElement(React.Fragment, null,
68
+ React.createElement("span", { className: "map-manager-no-layers-label" }, label),
69
+ React.createElement(AttachLayerPopupButton, { buttonType: AttachLayerButtonType.Blue, isOverlay: props.isOverlay })));
70
+ }
71
+ return node;
72
+ }
73
+ function renderDraggable(dropProvided, dropSnapshot) {
74
+ return (React.createElement("div", Object.assign({ className: `map-manager-attachments${dropSnapshot.isDraggingOver && containsLayer ? " is-dragging-map-over" : ""}`, ref: dropProvided.innerRef }, dropProvided.droppableProps),
75
+ renderDraggableContent(dropSnapshot),
76
+ React.createElement("div", { style: containsLayer ? undefined : { display: "none" } }, dropProvided.placeholder)));
77
+ }
78
+ return (React.createElement(Droppable, { droppableId: droppableId, renderClone: renderItem, getContainerForClone: props.getContainerForClone }, renderDraggable));
79
+ }
80
+ //# sourceMappingURL=MapLayerDroppable.js.map
@@ -0,0 +1 @@
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sBAAsB,CAAC,YAAY,CAAC;YAOrC,6BAAK,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,IAAG,YAAY,CAAC,WAAW,CAAO,CACzF,CAAC,CAAC;IACZ,CAAC;IAED,OAAO,CACL,oBAAC,SAAS,IACR,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,UAAU,EACvB,oBAAoB,EAAE,KAAK,CAAC,oBAA2B,IAEtD,eAAe,CACN,CACb,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\n// the following quiet warning caused by react-beautiful-dnd package\n/* eslint-disable @typescript-eslint/unbound-method */\n\nimport * as React from \"react\";\nimport { Draggable, DraggableChildrenFn, Droppable, DroppableProvided, DroppableStateSnapshot } from \"react-beautiful-dnd\";\nimport { MapLayerImageryProviderStatus, ScreenViewport } from \"@itwin/core-frontend\";\nimport { Icon } from \"@itwin/core-react\";\nimport { assert } from \"@itwin/core-bentley\";\nimport { ModalDialogManager } from \"@itwin/appui-react\";\nimport { Button } from \"@itwin/itwinui-react\";\nimport { SubLayersPopupButton } from \"./SubLayersPopupButton\";\nimport { AttachLayerButtonType, AttachLayerPopupButton } from \"./AttachLayerPopupButton\";\nimport { MapLayersUiItemsProvider } from \"../MapLayersUiItemsProvider\";\nimport { MapTypesOptions, StyleMapLayerSettings } from \"../Interfaces\";\nimport { MapLayerSettingsMenu } from \"./MapLayerSettingsMenu\";\nimport { MapUrlDialog } from \"./MapUrlDialog\";\nimport \"./MapLayerManager.scss\";\n\n/** @internal */\ninterface MapLayerDroppableProps {\n isOverlay: boolean;\n layersList?: StyleMapLayerSettings[];\n mapTypesOptions?: MapTypesOptions;\n getContainerForClone: () => HTMLElement;\n activeViewport: ScreenViewport;\n onMenuItemSelected: (action: string, mapLayerSettings: StyleMapLayerSettings) => void;\n onItemVisibilityToggleClicked: (mapLayerSettings: StyleMapLayerSettings) => void;\n onItemEdited: () => void;\n}\n\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport function MapLayerDroppable(props: MapLayerDroppableProps) {\n const containsLayer = props.layersList && props.layersList.length > 0;\n const droppableId = props.isOverlay ? \"overlayMapLayers\" : \"backgroundMapLayers\";\n const [toggleVisibility] = React.useState(MapLayersUiItemsProvider.localization.getLocalizedString(\"mapLayers:Widget.ToggleVisibility\"));\n const [requireAuthTooltip] = React.useState(MapLayersUiItemsProvider.localization.getLocalizedString(\"mapLayers:Widget.RequireAuthTooltip\"));\n const [noBackgroundMapsSpecifiedLabel] = React.useState(MapLayersUiItemsProvider.localization.getLocalizedString(\"mapLayers:Widget.NoBackgroundLayers\"));\n const [noUnderlaysSpecifiedLabel] = React.useState(MapLayersUiItemsProvider.localization.getLocalizedString(\"mapLayers:Widget.NoOverlayLayers\"));\n const [dropLayerLabel] = React.useState(MapLayersUiItemsProvider.localization.getLocalizedString(\"mapLayers:Widget.DropLayerLabel\"));\n\n const renderItem: DraggableChildrenFn = (dragProvided, _, rubric) => {\n assert(props.layersList !== undefined);\n const activeLayer = props.layersList[rubric.source.index];\n\n return (\n <div className=\"map-manager-source-item\" data-id={rubric.source.index} key={activeLayer.name}\n {...dragProvided.draggableProps}\n ref={dragProvided.innerRef} >\n <button className=\"map-manager-item-visibility\" title={toggleVisibility} onClick={() => { props.onItemVisibilityToggleClicked(activeLayer); }}>\n <Icon iconSpec={activeLayer.visible ? \"icon-visibility\" : \"icon-visibility-hide-2\"} /></button>\n <span className=\"map-manager-item-label\" {...dragProvided.dragHandleProps}>{activeLayer.name}</span>\n <div className=\"map-manager-item-sub-layer-container\">\n {activeLayer.subLayers && activeLayer.subLayers.length > 1 &&\n <SubLayersPopupButton mapLayerSettings={activeLayer} activeViewport={props.activeViewport} />\n }\n </div>\n {activeLayer.provider?.status === MapLayerImageryProviderStatus.RequireAuth &&\n <Button\n className=\"map-manager-item-requireAuth\"\n onClick={() => {\n const indexInDisplayStyle = props.activeViewport?.displayStyle.findMapLayerIndexByNameAndUrl(activeLayer.name, activeLayer.url, activeLayer.isOverlay);\n if (indexInDisplayStyle !== undefined && indexInDisplayStyle >= 0) {\n const layerSettings = props.activeViewport.displayStyle.mapLayerAtIndex(indexInDisplayStyle, activeLayer.isOverlay);\n\n ModalDialogManager.openDialog(<MapUrlDialog activeViewport={props.activeViewport}\n isOverlay={props.isOverlay}\n layerRequiringCredentials={layerSettings?.toJSON()}\n onOkResult={props.onItemEdited}\n mapTypesOptions={props.mapTypesOptions}></MapUrlDialog>);\n }\n\n }}\n title={requireAuthTooltip}\n >\n <Icon iconSpec=\"icon-status-warning\" />\n </Button>\n }\n <MapLayerSettingsMenu activeViewport={props.activeViewport} mapLayerSettings={activeLayer} onMenuItemSelection={props.onMenuItemSelected} />\n </div>\n );\n };\n\n function renderDraggableContent(snapshot: DroppableStateSnapshot): React.ReactNode {\n let node: React.ReactNode;\n if (containsLayer) {\n // Render a <Draggable>\n node = (props.layersList?.map((mapLayerSettings, i) =>\n <Draggable key={mapLayerSettings.name} draggableId={mapLayerSettings.name} index={i}>\n {renderItem}\n </Draggable>));\n } else {\n // Render a label that provide a 'Drop here' hint\n const label = props.isOverlay ? noUnderlaysSpecifiedLabel : noBackgroundMapsSpecifiedLabel;\n node =\n <div title={label} className=\"map-manager-no-layers-container\">\n {snapshot.isDraggingOver ?\n <span className=\"map-manager-no-layers-label\">{dropLayerLabel}</span>\n :\n <>\n <span className=\"map-manager-no-layers-label\">{label}</span>\n <AttachLayerPopupButton buttonType={AttachLayerButtonType.Blue} isOverlay={props.isOverlay} />\n </>\n }\n </div>;\n }\n return node;\n }\n\n function renderDraggable(dropProvided: DroppableProvided, dropSnapshot: DroppableStateSnapshot): React.ReactElement<HTMLElement> {\n return (\n <div className={`map-manager-attachments${dropSnapshot.isDraggingOver && containsLayer ? \" is-dragging-map-over\" : \"\"}`} ref={dropProvided.innerRef} {...dropProvided.droppableProps} >\n\n {renderDraggableContent(dropSnapshot)}\n\n {\n /* We don't want a placeholder when displaying the 'Drop here' message\n Unfortunately, if don't add it, 'react-beautiful-dnd' show an error message in the console.\n So I simply make it hidden. See https://github.com/atlassian/react-beautiful-dnd/issues/518 */\n }\n <div style={containsLayer ? undefined : { display: \"none\" }}>{dropProvided.placeholder}</div>\n </div>);\n }\n\n return (\n <Droppable\n droppableId={droppableId}\n renderClone={renderItem}\n getContainerForClone={props.getContainerForClone as any}\n >\n {renderDraggable}\n </Droppable>\n );\n}\n"]}
@@ -0,0 +1,27 @@
1
+ import { MapLayerSource, ScreenViewport } from "@itwin/core-frontend";
2
+ import * as React from "react";
3
+ import { MapLayerOptions, MapTypesOptions, StyleMapLayerSettings } from "../Interfaces";
4
+ import "./MapLayerManager.scss";
5
+ /** @internal */
6
+ export interface SourceMapContextProps {
7
+ readonly sources: MapLayerSource[];
8
+ readonly loadingSources: boolean;
9
+ readonly bases: MapLayerSource[];
10
+ readonly refreshFromStyle: () => void;
11
+ readonly activeViewport?: ScreenViewport;
12
+ readonly backgroundLayers?: StyleMapLayerSettings[];
13
+ readonly overlayLayers?: StyleMapLayerSettings[];
14
+ readonly mapTypesOptions?: MapTypesOptions;
15
+ }
16
+ /** @internal */
17
+ export declare const SourceMapContext: React.Context<SourceMapContextProps>;
18
+ /** @internal */
19
+ export declare function useSourceMapContext(): SourceMapContextProps;
20
+ interface MapLayerManagerProps {
21
+ getContainerForClone: () => HTMLElement;
22
+ activeViewport: ScreenViewport;
23
+ mapLayerOptions?: MapLayerOptions;
24
+ }
25
+ export declare function MapLayerManager(props: MapLayerManagerProps): JSX.Element;
26
+ export {};
27
+ //# sourceMappingURL=MapLayerManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MapLayerManager.d.ts","sourceRoot":"","sources":["../../../../src/ui/widget/MapLayerManager.tsx"],"names":[],"mappings":"AAUA,OAAO,EAC4E,cAAc,EACjC,cAAc,EAC7E,MAAM,sBAAsB,CAAC;AAG9B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAKxF,OAAO,wBAAwB,CAAC;AAGhC,gBAAgB;AAChB,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,OAAO,EAAE,cAAc,EAAE,CAAC;IACnC,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IACjC,QAAQ,CAAC,KAAK,EAAE,cAAc,EAAE,CAAC;IACjC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,IAAI,CAAC;IACtC,QAAQ,CAAC,cAAc,CAAC,EAAE,cAAc,CAAC;IACzC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,qBAAqB,EAAE,CAAC;IACpD,QAAQ,CAAC,aAAa,CAAC,EAAE,qBAAqB,EAAE,CAAC;IACjD,QAAQ,CAAC,eAAe,CAAC,EAAE,eAAe,CAAC;CAC5C;AAED,gBAAgB;AAChB,eAAO,MAAM,gBAAgB,sCAK3B,CAAC;AAEH,gBAAgB;AAChB,wBAAgB,mBAAmB,IAAI,qBAAqB,CAE3D;AAmCD,UAAU,oBAAoB;IAC5B,oBAAoB,EAAE,MAAM,WAAW,CAAC;IACxC,cAAc,EAAE,cAAc,CAAC;IAC/B,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC;AAGD,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,eA6W1D"}