@itwin/map-layers 5.3.0 → 5.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. package/CHANGELOG.md +25 -2
  2. package/lib/cjs/BrowserStorage.d.ts +25 -0
  3. package/lib/cjs/BrowserStorage.d.ts.map +1 -0
  4. package/lib/cjs/BrowserStorage.js +80 -0
  5. package/lib/cjs/BrowserStorage.js.map +1 -0
  6. package/lib/cjs/CustomParamUtils.d.ts +5 -0
  7. package/lib/cjs/CustomParamUtils.d.ts.map +1 -0
  8. package/lib/cjs/CustomParamUtils.js +26 -0
  9. package/lib/cjs/CustomParamUtils.js.map +1 -0
  10. package/lib/cjs/CustomParamsMappingStorage.d.ts +6 -0
  11. package/lib/cjs/CustomParamsMappingStorage.d.ts.map +1 -0
  12. package/lib/cjs/CustomParamsMappingStorage.js +15 -0
  13. package/lib/cjs/CustomParamsMappingStorage.js.map +1 -0
  14. package/lib/cjs/CustomParamsStorage.d.ts +6 -0
  15. package/lib/cjs/CustomParamsStorage.d.ts.map +1 -0
  16. package/lib/cjs/CustomParamsStorage.js +15 -0
  17. package/lib/cjs/CustomParamsStorage.js.map +1 -0
  18. package/lib/cjs/MapLayerPreferences.d.ts.map +1 -1
  19. package/lib/cjs/MapLayerPreferences.js +2 -0
  20. package/lib/cjs/MapLayerPreferences.js.map +1 -1
  21. package/lib/cjs/PreferencesBrowserStorage.d.ts +9 -2
  22. package/lib/cjs/PreferencesBrowserStorage.d.ts.map +1 -1
  23. package/lib/cjs/PreferencesBrowserStorage.js +11 -51
  24. package/lib/cjs/PreferencesBrowserStorage.js.map +1 -1
  25. package/lib/cjs/public/locales/en/mapLayers.json +29 -3
  26. package/lib/cjs/ui/FeatureInfoUiItemsProvider.d.ts +1 -1
  27. package/lib/cjs/ui/FeatureInfoUiItemsProvider.js +1 -1
  28. package/lib/cjs/ui/FeatureInfoUiItemsProvider.js.map +1 -1
  29. package/lib/cjs/ui/Interfaces.d.ts +11 -0
  30. package/lib/cjs/ui/Interfaces.d.ts.map +1 -1
  31. package/lib/cjs/ui/Interfaces.js.map +1 -1
  32. package/lib/cjs/ui/widget/AttachLayerPopupButton.d.ts.map +1 -1
  33. package/lib/cjs/ui/widget/AttachLayerPopupButton.js +20 -18
  34. package/lib/cjs/ui/widget/AttachLayerPopupButton.js.map +1 -1
  35. package/lib/cjs/ui/widget/CustomParamEditDialog.d.ts +11 -0
  36. package/lib/cjs/ui/widget/CustomParamEditDialog.d.ts.map +1 -0
  37. package/lib/cjs/ui/widget/CustomParamEditDialog.js +57 -0
  38. package/lib/cjs/ui/widget/CustomParamEditDialog.js.map +1 -0
  39. package/lib/cjs/ui/widget/CustomParamEditDialog.scss +26 -0
  40. package/lib/cjs/ui/widget/CustomParamsSettings.d.ts +4 -0
  41. package/lib/cjs/ui/widget/CustomParamsSettings.d.ts.map +1 -0
  42. package/lib/cjs/ui/widget/CustomParamsSettings.js +116 -0
  43. package/lib/cjs/ui/widget/CustomParamsSettings.js.map +1 -0
  44. package/lib/cjs/ui/widget/CustomParamsSettings.scss +67 -0
  45. package/lib/cjs/ui/widget/MapLayerDroppable.d.ts +3 -3
  46. package/lib/cjs/ui/widget/MapLayerDroppable.d.ts.map +1 -1
  47. package/lib/cjs/ui/widget/MapLayerDroppable.js +23 -10
  48. package/lib/cjs/ui/widget/MapLayerDroppable.js.map +1 -1
  49. package/lib/cjs/ui/widget/MapLayerManager.d.ts +2 -2
  50. package/lib/cjs/ui/widget/MapLayerManager.d.ts.map +1 -1
  51. package/lib/cjs/ui/widget/MapLayerManager.js +19 -11
  52. package/lib/cjs/ui/widget/MapLayerManager.js.map +1 -1
  53. package/lib/cjs/ui/widget/MapLayerSettingsPopupButton.d.ts.map +1 -1
  54. package/lib/cjs/ui/widget/MapLayerSettingsPopupButton.js +1 -1
  55. package/lib/cjs/ui/widget/MapLayerSettingsPopupButton.js.map +1 -1
  56. package/lib/cjs/ui/widget/MapLayerSettingsPopupButton.scss +4 -1
  57. package/lib/cjs/ui/widget/MapManagerSettings.d.ts.map +1 -1
  58. package/lib/cjs/ui/widget/MapManagerSettings.js +37 -29
  59. package/lib/cjs/ui/widget/MapManagerSettings.js.map +1 -1
  60. package/lib/cjs/ui/widget/MapUrlDialog.d.ts +15 -5
  61. package/lib/cjs/ui/widget/MapUrlDialog.d.ts.map +1 -1
  62. package/lib/cjs/ui/widget/MapUrlDialog.js +129 -58
  63. package/lib/cjs/ui/widget/MapUrlDialog.js.map +1 -1
  64. package/lib/cjs/ui/widget/MapUrlDialog.scss +12 -1
  65. package/lib/cjs/ui/widget/SelectApiKey.d.ts +10 -0
  66. package/lib/cjs/ui/widget/SelectApiKey.d.ts.map +1 -0
  67. package/lib/cjs/ui/widget/SelectApiKey.js +39 -0
  68. package/lib/cjs/ui/widget/SelectApiKey.js.map +1 -0
  69. package/lib/cjs/ui/widget/SelectCustomParam.d.ts +10 -0
  70. package/lib/cjs/ui/widget/SelectCustomParam.d.ts.map +1 -0
  71. package/lib/cjs/ui/widget/SelectCustomParam.js +49 -0
  72. package/lib/cjs/ui/widget/SelectCustomParam.js.map +1 -0
  73. package/lib/cjs/ui/widget/SelectMapFormat.d.ts +11 -2
  74. package/lib/cjs/ui/widget/SelectMapFormat.d.ts.map +1 -1
  75. package/lib/cjs/ui/widget/SelectMapFormat.js +5 -6
  76. package/lib/cjs/ui/widget/SelectMapFormat.js.map +1 -1
  77. package/lib/cjs/ui/widget/UserPreferencesStorageOptions.d.ts +10 -0
  78. package/lib/cjs/ui/widget/UserPreferencesStorageOptions.d.ts.map +1 -0
  79. package/lib/cjs/ui/widget/UserPreferencesStorageOptions.js +17 -0
  80. package/lib/cjs/ui/widget/UserPreferencesStorageOptions.js.map +1 -0
  81. package/lib/esm/BrowserStorage.d.ts +25 -0
  82. package/lib/esm/BrowserStorage.d.ts.map +1 -0
  83. package/lib/esm/BrowserStorage.js +76 -0
  84. package/lib/esm/BrowserStorage.js.map +1 -0
  85. package/lib/esm/CustomParamUtils.d.ts +5 -0
  86. package/lib/esm/CustomParamUtils.d.ts.map +1 -0
  87. package/lib/esm/CustomParamUtils.js +22 -0
  88. package/lib/esm/CustomParamUtils.js.map +1 -0
  89. package/lib/esm/CustomParamsMappingStorage.d.ts +6 -0
  90. package/lib/esm/CustomParamsMappingStorage.d.ts.map +1 -0
  91. package/lib/esm/CustomParamsMappingStorage.js +11 -0
  92. package/lib/esm/CustomParamsMappingStorage.js.map +1 -0
  93. package/lib/esm/CustomParamsStorage.d.ts +6 -0
  94. package/lib/esm/CustomParamsStorage.d.ts.map +1 -0
  95. package/lib/esm/CustomParamsStorage.js +11 -0
  96. package/lib/esm/CustomParamsStorage.js.map +1 -0
  97. package/lib/esm/MapLayerPreferences.d.ts.map +1 -1
  98. package/lib/esm/MapLayerPreferences.js +2 -0
  99. package/lib/esm/MapLayerPreferences.js.map +1 -1
  100. package/lib/esm/PreferencesBrowserStorage.d.ts +9 -2
  101. package/lib/esm/PreferencesBrowserStorage.d.ts.map +1 -1
  102. package/lib/esm/PreferencesBrowserStorage.js +11 -51
  103. package/lib/esm/PreferencesBrowserStorage.js.map +1 -1
  104. package/lib/esm/public/locales/en/mapLayers.json +29 -3
  105. package/lib/esm/ui/FeatureInfoUiItemsProvider.d.ts +1 -1
  106. package/lib/esm/ui/FeatureInfoUiItemsProvider.js +1 -1
  107. package/lib/esm/ui/FeatureInfoUiItemsProvider.js.map +1 -1
  108. package/lib/esm/ui/Interfaces.d.ts +11 -0
  109. package/lib/esm/ui/Interfaces.d.ts.map +1 -1
  110. package/lib/esm/ui/Interfaces.js.map +1 -1
  111. package/lib/esm/ui/widget/AttachLayerPopupButton.d.ts.map +1 -1
  112. package/lib/esm/ui/widget/AttachLayerPopupButton.js +20 -18
  113. package/lib/esm/ui/widget/AttachLayerPopupButton.js.map +1 -1
  114. package/lib/esm/ui/widget/CustomParamEditDialog.d.ts +11 -0
  115. package/lib/esm/ui/widget/CustomParamEditDialog.d.ts.map +1 -0
  116. package/lib/esm/ui/widget/CustomParamEditDialog.js +53 -0
  117. package/lib/esm/ui/widget/CustomParamEditDialog.js.map +1 -0
  118. package/lib/esm/ui/widget/CustomParamEditDialog.scss +26 -0
  119. package/lib/esm/ui/widget/CustomParamsSettings.d.ts +4 -0
  120. package/lib/esm/ui/widget/CustomParamsSettings.d.ts.map +1 -0
  121. package/lib/esm/ui/widget/CustomParamsSettings.js +112 -0
  122. package/lib/esm/ui/widget/CustomParamsSettings.js.map +1 -0
  123. package/lib/esm/ui/widget/CustomParamsSettings.scss +67 -0
  124. package/lib/esm/ui/widget/MapLayerDroppable.d.ts +3 -3
  125. package/lib/esm/ui/widget/MapLayerDroppable.d.ts.map +1 -1
  126. package/lib/esm/ui/widget/MapLayerDroppable.js +24 -11
  127. package/lib/esm/ui/widget/MapLayerDroppable.js.map +1 -1
  128. package/lib/esm/ui/widget/MapLayerManager.d.ts +2 -2
  129. package/lib/esm/ui/widget/MapLayerManager.d.ts.map +1 -1
  130. package/lib/esm/ui/widget/MapLayerManager.js +20 -12
  131. package/lib/esm/ui/widget/MapLayerManager.js.map +1 -1
  132. package/lib/esm/ui/widget/MapLayerSettingsPopupButton.d.ts.map +1 -1
  133. package/lib/esm/ui/widget/MapLayerSettingsPopupButton.js +1 -1
  134. package/lib/esm/ui/widget/MapLayerSettingsPopupButton.js.map +1 -1
  135. package/lib/esm/ui/widget/MapLayerSettingsPopupButton.scss +4 -1
  136. package/lib/esm/ui/widget/MapManagerSettings.d.ts.map +1 -1
  137. package/lib/esm/ui/widget/MapManagerSettings.js +38 -30
  138. package/lib/esm/ui/widget/MapManagerSettings.js.map +1 -1
  139. package/lib/esm/ui/widget/MapUrlDialog.d.ts +15 -5
  140. package/lib/esm/ui/widget/MapUrlDialog.d.ts.map +1 -1
  141. package/lib/esm/ui/widget/MapUrlDialog.js +129 -58
  142. package/lib/esm/ui/widget/MapUrlDialog.js.map +1 -1
  143. package/lib/esm/ui/widget/MapUrlDialog.scss +12 -1
  144. package/lib/esm/ui/widget/SelectApiKey.d.ts +10 -0
  145. package/lib/esm/ui/widget/SelectApiKey.d.ts.map +1 -0
  146. package/lib/esm/ui/widget/SelectApiKey.js +35 -0
  147. package/lib/esm/ui/widget/SelectApiKey.js.map +1 -0
  148. package/lib/esm/ui/widget/SelectCustomParam.d.ts +10 -0
  149. package/lib/esm/ui/widget/SelectCustomParam.d.ts.map +1 -0
  150. package/lib/esm/ui/widget/SelectCustomParam.js +45 -0
  151. package/lib/esm/ui/widget/SelectCustomParam.js.map +1 -0
  152. package/lib/esm/ui/widget/SelectMapFormat.d.ts +11 -2
  153. package/lib/esm/ui/widget/SelectMapFormat.d.ts.map +1 -1
  154. package/lib/esm/ui/widget/SelectMapFormat.js +5 -6
  155. package/lib/esm/ui/widget/SelectMapFormat.js.map +1 -1
  156. package/lib/esm/ui/widget/UserPreferencesStorageOptions.d.ts +10 -0
  157. package/lib/esm/ui/widget/UserPreferencesStorageOptions.d.ts.map +1 -0
  158. package/lib/esm/ui/widget/UserPreferencesStorageOptions.js +13 -0
  159. package/lib/esm/ui/widget/UserPreferencesStorageOptions.js.map +1 -0
  160. package/lib/public/locales/en/mapLayers.json +29 -3
  161. package/package.json +6 -6
@@ -17,6 +17,11 @@ $default-font-size: --iui-font-size-1;
17
17
  padding-left: 5px;
18
18
  }
19
19
 
20
+ .map-layer-source-previewBadge-icon {
21
+ margin-left: 4px;
22
+ display:inline;
23
+ vertical-align: middle;
24
+ }
20
25
  .map-layer-source-select-previewBadge {
21
26
  margin-right: 10px;
22
27
  }
@@ -126,4 +131,10 @@ display: flex;
126
131
  color: var(--iui-color-icon-warning);
127
132
  background-color: transparent;
128
133
  }
129
- }
134
+ }
135
+
136
+ .map-layer-custom-param-select {
137
+ .map-layer-custom-param-select-add-button {
138
+ margin-bottom: 0.5rem;
139
+ }
140
+ }
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ import "./MapUrlDialog.scss";
3
+ interface SelectApiKeyProps {
4
+ value?: string;
5
+ disabled?: boolean;
6
+ onChange?: (value: string) => void;
7
+ }
8
+ export declare function SelectApiKey(props: SelectApiKeyProps): JSX.Element;
9
+ export {};
10
+ //# sourceMappingURL=SelectApiKey.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SelectApiKey.d.ts","sourceRoot":"","sources":["../../../../src/ui/widget/SelectApiKey.tsx"],"names":[],"mappings":";AASA,OAAO,qBAAqB,CAAC;AAC7B,UAAU,iBAAiB;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC;AAGD,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,eAyCpD"}
@@ -0,0 +1,39 @@
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
+ // cSpell:ignore Modeless WMTS
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.SelectApiKey = void 0;
9
+ const itwinui_react_1 = require("@itwin/itwinui-react");
10
+ const React = require("react");
11
+ const CustomParamsStorage_1 = require("../../CustomParamsStorage");
12
+ require("./MapUrlDialog.scss");
13
+ // eslint-disable-next-line @typescript-eslint/naming-convention
14
+ function SelectApiKey(props) {
15
+ const [keyValue, setKeyValue] = React.useState(props.value);
16
+ const [apiKeys] = React.useState(() => {
17
+ const storage = new CustomParamsStorage_1.CustomParamsStorage();
18
+ const keys = storage.get(undefined);
19
+ if (keys)
20
+ return keys.map((keyItem) => { return { value: keyItem.name, label: keyItem.name }; });
21
+ return [];
22
+ });
23
+ React.useEffect(() => {
24
+ setKeyValue(props.value);
25
+ }, [props.value]);
26
+ const handleOnChange = React.useCallback((value) => {
27
+ setKeyValue(value);
28
+ if (props.onChange)
29
+ props.onChange(value);
30
+ }, [props]);
31
+ const handleKeyDown = React.useCallback((e) => {
32
+ if (e.code === "Delete" || e.key === "Backspace") {
33
+ setKeyValue(undefined);
34
+ }
35
+ }, []);
36
+ return (React.createElement(itwinui_react_1.Select, { className: "map-layer-source-select", options: apiKeys, value: keyValue, disabled: props.disabled, onChange: handleOnChange, size: "small", onKeyDown: handleKeyDown }));
37
+ }
38
+ exports.SelectApiKey = SelectApiKey;
39
+ //# sourceMappingURL=SelectApiKey.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SelectApiKey.js","sourceRoot":"","sources":["../../../../src/ui/widget/SelectApiKey.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F,8BAA8B;;;AAE9B,wDAA8C;AAC9C,+BAA+B;AAC/B,mEAAgE;AAChE,+BAA6B;AAO7B,gEAAgE;AAChE,SAAgB,YAAY,CAAC,KAAwB;IAEnD,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAmB,KAAK,CAAC,KAAK,CAAC,CAAC;IAE9E,MAAM,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE;QACpC,MAAM,OAAO,GAAG,IAAI,yCAAmB,EAAE,CAAC;QAC1C,MAAM,IAAI,GAAI,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACrC,IAAI,IAAI;YACN,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,GAAE,OAAO,EAAC,KAAK,EAAE,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,IAAI,EAAC,CAAC,CAAA,CAAC,CAAC,CAAC;QACrF,OAAO,EAAE,CAAC;IACZ,CAAC,CACA,CAAC;IAEF,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IAElB,MAAM,cAAc,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,KAAa,EAAE,EAAE;QACzD,WAAW,CAAC,KAAK,CAAC,CAAC;QACnB,IAAI,KAAK,CAAC,QAAQ;YAChB,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,MAAM,aAAa,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,EAAE;QAC5C,IAAI,CAAC,CAAC,IAAI,KAAK,QAAQ,IAAK,CAAC,CAAC,GAAG,KAAK,WAAW,EAAE;YACjD,WAAW,CAAC,SAAS,CAAC,CAAC;SACxB;IACH,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CAEL,oBAAC,sBAAM,IACL,SAAS,EAAC,yBAAyB,EACnC,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,QAAQ,EACf,QAAQ,EAAE,KAAK,CAAC,QAAQ,EACxB,QAAQ,EAAE,cAAc,EACxB,IAAI,EAAC,OAAO,EACZ,SAAS,EAAE,aAAa,GACxB,CACH,CAAC;AACJ,CAAC;AAzCD,oCAyCC","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 { Select } from \"@itwin/itwinui-react\";\nimport * as React from \"react\";\nimport { CustomParamsStorage } from \"../../CustomParamsStorage\";\nimport \"./MapUrlDialog.scss\";\ninterface SelectApiKeyProps {\n value?: string;\n disabled?: boolean;\n onChange?: (value: string) => void;\n}\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport function SelectApiKey(props: SelectApiKeyProps) {\n\n const [keyValue, setKeyValue] = React.useState<string|undefined>(props.value);\n\n const [apiKeys] = React.useState(() => {\n const storage = new CustomParamsStorage();\n const keys = storage.get(undefined);\n if (keys)\n return keys.map((keyItem) => {return {value: keyItem.name, label: keyItem.name};});\n return [];\n }\n );\n\n React.useEffect(() => {\n setKeyValue(props.value);\n }, [props.value]);\n\n const handleOnChange = React.useCallback((value: string) => {\n setKeyValue(value);\n if (props.onChange)\n props.onChange(value);\n }, [props]);\n\n const handleKeyDown = React.useCallback((e) => {\n if (e.code === \"Delete\" || e.key === \"Backspace\") {\n setKeyValue(undefined);\n }\n }, []);\n\n return (\n\n <Select\n className=\"map-layer-source-select\"\n options={apiKeys}\n value={keyValue}\n disabled={props.disabled}\n onChange={handleOnChange}\n size=\"small\"\n onKeyDown={handleKeyDown}\n />\n );\n}\n"]}
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ import "./MapUrlDialog.scss";
3
+ interface SelectCustomParamProps {
4
+ value?: string[];
5
+ disabled?: boolean;
6
+ onChange?: (value: string[]) => void;
7
+ }
8
+ export declare function SelectCustomParam(props: SelectCustomParamProps): JSX.Element;
9
+ export {};
10
+ //# sourceMappingURL=SelectCustomParam.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SelectCustomParam.d.ts","sourceRoot":"","sources":["../../../../src/ui/widget/SelectCustomParam.tsx"],"names":[],"mappings":";AASA,OAAO,qBAAqB,CAAC;AAE7B,UAAU,sBAAsB;IAC9B,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;CACtC;AAGD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,eAuD9D"}
@@ -0,0 +1,49 @@
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
+ // cSpell:ignore Modeless WMTS
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.SelectCustomParam = void 0;
9
+ const itwinui_react_1 = require("@itwin/itwinui-react");
10
+ const React = require("react");
11
+ const CustomParamsStorage_1 = require("../../CustomParamsStorage");
12
+ require("./MapUrlDialog.scss");
13
+ const mapLayers_1 = require("../../mapLayers");
14
+ // eslint-disable-next-line @typescript-eslint/naming-convention
15
+ function SelectCustomParam(props) {
16
+ const [storage] = React.useState(() => new CustomParamsStorage_1.CustomParamsStorage());
17
+ const [paramValues, setParamValues] = React.useState(props.value);
18
+ const getCustomParamsFromStorage = React.useCallback(() => {
19
+ const params = storage.get(undefined);
20
+ return (params ? params.map((item) => { return { value: item.name, label: item.name }; }) : []);
21
+ }, [storage]);
22
+ const [customParams] = React.useState(() => getCustomParamsFromStorage());
23
+ React.useEffect(() => {
24
+ setParamValues(props.value);
25
+ }, [props.value]);
26
+ const handleOnChange = React.useCallback((val, event) => {
27
+ const stateSetter = (prev) => {
28
+ const getValue = () => {
29
+ if (!prev)
30
+ return [val];
31
+ return event === "removed" ? prev.filter((v) => val !== v) : [...prev, val];
32
+ };
33
+ const value = getValue();
34
+ if (props.onChange)
35
+ props.onChange(value);
36
+ return value;
37
+ };
38
+ setParamValues(stateSetter);
39
+ }, [props]);
40
+ const handleKeyDown = React.useCallback((e) => {
41
+ if (e.code === "Delete" || e.key === "Backspace") {
42
+ setParamValues(undefined);
43
+ }
44
+ }, []);
45
+ return (React.createElement("div", { className: "map-layer-custom-param-select", title: customParams.length === 0 ? mapLayers_1.MapLayersUI.translate("CustomParamSelect.DisabledTitle") : undefined },
46
+ React.createElement(itwinui_react_1.Select, { className: "map-layer-source-select", options: customParams, value: paramValues, disabled: props.disabled || customParams.length === 0, onChange: handleOnChange, size: "small", onKeyDown: handleKeyDown, multiple: true })));
47
+ }
48
+ exports.SelectCustomParam = SelectCustomParam;
49
+ //# sourceMappingURL=SelectCustomParam.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Select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AAE,aAAa,EACxB,QAAQ,SAED,CACL,CACP,CAAC;AACJ,CAAC;AAvDD,8CAuDC","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 { Select } from \"@itwin/itwinui-react\";\nimport * as React from \"react\";\nimport { CustomParamsStorage } from \"../../CustomParamsStorage\";\nimport \"./MapUrlDialog.scss\";\nimport { MapLayersUI } from \"../../mapLayers\";\ninterface SelectCustomParamProps {\n value?: string[];\n disabled?: boolean;\n onChange?: (value: string[]) => void;\n}\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport function SelectCustomParam(props: SelectCustomParamProps) {\n const [storage] = React.useState(() => new CustomParamsStorage());\n\n const [paramValues, setParamValues] = React.useState<string[]|undefined>(props.value);\n\n const getCustomParamsFromStorage = React.useCallback(() => {\n const params = storage.get(undefined);\n return (params ? params.map((item) => {return {value: item.name, label: item.name};}) : []);\n }, [storage]);\n\n const [customParams] = React.useState(() => getCustomParamsFromStorage());\n\n React.useEffect(() => {\n setParamValues(props.value);\n }, [props.value]);\n\n const handleOnChange = React.useCallback((val, event) => {\n const stateSetter = (prev: string[] | undefined) => {\n const getValue = (): string[] => {\n if (!prev)\n return [val];\n\n return event === \"removed\" ? prev.filter((v) => val !== v) : [...prev, val];\n };\n const value = getValue();\n if (props.onChange)\n props.onChange(value);\n return value;\n\n };\n setParamValues(stateSetter);\n\n }, [props]);\n\n const handleKeyDown = React.useCallback((e) => {\n if (e.code === \"Delete\" || e.key === \"Backspace\") {\n setParamValues(undefined);\n }\n }, []);\n\n return (\n <div className=\"map-layer-custom-param-select\" title={customParams.length === 0 ? MapLayersUI.translate(\"CustomParamSelect.DisabledTitle\") : undefined}>\n <Select<string>\n className=\"map-layer-source-select\"\n options={customParams}\n value={paramValues}\n disabled={props.disabled || customParams.length === 0 }\n onChange={handleOnChange}\n size=\"small\"\n onKeyDown={handleKeyDown}\n multiple\n >\n </Select>\n </div>\n );\n}\n"]}
@@ -1,6 +1,6 @@
1
- /// <reference types="react" />
2
- import { MapTypesOptions } from "../Interfaces";
3
1
  import "./MapUrlDialog.scss";
2
+ import * as React from "react";
3
+ import { MapTypesOptions } from "../Interfaces";
4
4
  export declare const MAP_TYPES: {
5
5
  wms: string;
6
6
  arcGis: string;
@@ -13,6 +13,15 @@ interface SelectMapFormatProps {
13
13
  disabled?: boolean;
14
14
  mapTypesOptions?: MapTypesOptions;
15
15
  onChange?: (mapType: string) => void;
16
+ /**
17
+ * Message below the select. Does not apply to 'inline' select.
18
+ */
19
+ message?: React.ReactNode;
20
+ /**
21
+ * Status of the select.
22
+ * @default ''
23
+ */
24
+ status?: "positive" | "warning" | "negative";
16
25
  }
17
26
  export declare function SelectMapFormat(props: SelectMapFormatProps): JSX.Element;
18
27
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"SelectMapFormat.d.ts","sourceRoot":"","sources":["../../../../src/ui/widget/SelectMapFormat.tsx"],"names":[],"mappings":";AAQA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,qBAAqB,CAAC;AAS7B,eAAO,MAAM,SAAS;;;;;;CAMrB,CAAC;AAEF,UAAU,oBAAoB;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACtC;AAGD,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,eAgD1D"}
1
+ {"version":3,"file":"SelectMapFormat.d.ts","sourceRoot":"","sources":["../../../../src/ui/widget/SelectMapFormat.tsx"],"names":[],"mappings":"AAMA,OAAO,qBAAqB,CAAC;AAC7B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAMhD,eAAO,MAAM,SAAS;;;;;;CAMrB,CAAC;AAEF,UAAU,oBAAoB;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC;;SAEK;IACL,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B;;;OAGG;IACH,MAAM,CAAC,EAAE,UAAU,GAAG,SAAS,GAAG,UAAU,CAAC;CAC9C;AAGD,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,eA+C1D"}
@@ -6,12 +6,12 @@
6
6
  // cSpell:ignore Modeless WMTS
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
8
  exports.SelectMapFormat = exports.MAP_TYPES = void 0;
9
- const itwinui_react_1 = require("@itwin/itwinui-react");
10
- const React = require("react");
11
9
  require("./MapUrlDialog.scss");
10
+ const React = require("react");
11
+ const core_frontend_1 = require("@itwin/core-frontend");
12
12
  const itwinui_icons_color_react_1 = require("@itwin/itwinui-icons-color-react");
13
+ const itwinui_react_1 = require("@itwin/itwinui-react");
13
14
  const mapLayers_1 = require("../../mapLayers");
14
- const core_frontend_1 = require("@itwin/core-frontend");
15
15
  // TODO:
16
16
  // Remove this structure and iterate over the registry's active formats.
17
17
  // Still need a proper way to exclude some format, like we currently do with
@@ -26,7 +26,6 @@ exports.MAP_TYPES = {
26
26
  // eslint-disable-next-line @typescript-eslint/naming-convention
27
27
  function SelectMapFormat(props) {
28
28
  const [mapFormat, setMapFormat] = React.useState(props.value ?? exports.MAP_TYPES.arcGis);
29
- const [techPreviewTooltip] = React.useState(mapLayers_1.MapLayersUI.localization.getLocalizedString("mapLayers:CustomAttach.TechPreviewBadgeTooltip"));
30
29
  const [mapFormats] = React.useState(() => {
31
30
  const formats = [
32
31
  { value: exports.MAP_TYPES.arcGis, label: exports.MAP_TYPES.arcGis },
@@ -45,8 +44,8 @@ function SelectMapFormat(props) {
45
44
  props.onChange(value);
46
45
  }
47
46
  }, [props]);
48
- return (React.createElement(itwinui_react_1.Select, { className: "map-layer-source-select", options: mapFormats, value: mapFormat, disabled: props.disabled, onChange: handleOnChange, size: "small", itemRenderer: (option) => (React.createElement(itwinui_react_1.MenuItem, { badge: option.id?.includes("techPreview") ?
49
- React.createElement("div", { title: techPreviewTooltip, className: "map-layer-source-select-previewBadge" },
47
+ return (React.createElement(itwinui_react_1.LabeledSelect, { className: "map-layer-source-select", options: mapFormats, value: mapFormat, disabled: props.disabled, onChange: handleOnChange, size: "small", itemRenderer: (option) => (React.createElement(itwinui_react_1.MenuItem, { badge: option.id?.includes("techPreview") ?
48
+ React.createElement("div", { title: mapLayers_1.MapLayersUI.translate("Labels.TechPreviewBadgeTooltip"), className: "map-layer-source-select-previewBadge" },
50
49
  React.createElement(itwinui_react_1.Icon, { size: "small" },
51
50
  React.createElement(itwinui_icons_color_react_1.SvgTechnicalPreviewMini, null)))
52
51
  : undefined }, option.label)) }));
@@ -1 +1 @@
1
- {"version":3,"file":"SelectMapFormat.js","sourceRoot":"","sources":["../../../../src/ui/widget/SelectMapFormat.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F,8BAA8B;;;AAE9B,wDAA4E;AAC5E,+BAA+B;AAE/B,+BAA6B;AAC7B,gFAAyE;AACzE,+CAA8C;AAC9C,wDAAiD;AAEjD,QAAQ;AACR,wEAAwE;AACxE,4EAA4E;AAC5E,wDAAwD;AAC3C,QAAA,SAAS,GAAG;IACvB,GAAG,EAAE,KAAK;IACV,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,SAAS;IAClB,aAAa,EAAE,eAAe;CAC/B,CAAC;AASF,gEAAgE;AAChE,SAAgB,eAAe,CAAC,KAA2B;IAEzD,MAAM,CA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AC,KAAK,CAAC,CAAC;SACvB;IACH,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,OAAO,CAEL,oBAAC,sBAAM,IACL,SAAS,EAAC,yBAAyB,EACnC,OAAO,EAAE,UAAU,EACnB,KAAK,EAAE,SAAS,EAChB,QAAQ,EAAE,KAAK,CAAC,QAAQ,EACxB,QAAQ,EAAE,cAAc,EACxB,IAAI,EAAC,OAAO,EACZ,YAAY,EACV,CAAC,MAAM,EAAE,EAAE,CAAC,CACV,oBAAC,wBAAQ,IACP,KAAK,EAAE,MAAM,CAAC,EAAE,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC;gBACzC,6BAAK,KAAK,EAAE,kBAAkB,EAAE,SAAS,EAAC,sCAAsC;oBAC9E,oBAAC,oBAAI,IAAC,IAAI,EAAC,OAAO;wBAAC,oBAAC,mDAAuB,OAAG,CAAO,CACjD;gBACN,CAAC,CAAC,SAAS,IACZ,MAAM,CAAC,KAAK,CACJ,CAAC,GAChB,CACH,CAAC;AACJ,CAAC;AAhDD,0CAgDC","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 { Icon, MenuItem, Select, SelectOption } from \"@itwin/itwinui-react\";\nimport * as React from \"react\";\nimport { MapTypesOptions } from \"../Interfaces\";\nimport \"./MapUrlDialog.scss\";\nimport {SvgTechnicalPreviewMini} from \"@itwin/itwinui-icons-color-react\";\nimport { MapLayersUI } from \"../../mapLayers\";\nimport { IModelApp } from \"@itwin/core-frontend\";\n\n// TODO:\n// Remove this structure and iterate over the registry's active formats.\n// Still need a proper way to exclude some format, like we currently do with\n// 'TileUrl' without the need to hardcode any format Id.\nexport const MAP_TYPES = {\n wms: \"WMS\",\n arcGis: \"ArcGIS\",\n wmts: \"WMTS\",\n tileUrl: \"TileURL\",\n arcGisFeature: \"ArcGISFeature\",\n};\n\ninterface SelectMapFormatProps {\n value?: string;\n disabled?: boolean;\n mapTypesOptions?: MapTypesOptions;\n onChange?: (mapType: string) => void;\n}\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport function SelectMapFormat(props: SelectMapFormatProps) {\n\n const [mapFormat, setMapFormat] = React.useState(props.value ?? MAP_TYPES.arcGis);\n const [techPreviewTooltip] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:CustomAttach.TechPreviewBadgeTooltip\"));\n\n const [mapFormats] = React.useState((): SelectOption<string>[] => {\n const formats: SelectOption<string>[] = [\n { value: MAP_TYPES.arcGis, label: MAP_TYPES.arcGis },\n { value: MAP_TYPES.wms, label: MAP_TYPES.wms },\n { value: MAP_TYPES.wmts, label: MAP_TYPES.wmts },\n ];\n if (props.mapTypesOptions?.supportTileUrl)\n formats.push({ value: MAP_TYPES.tileUrl, label: MAP_TYPES.tileUrl });\n\n if (IModelApp.mapLayerFormatRegistry.isRegistered(MAP_TYPES.arcGisFeature))\n formats.push( { value: MAP_TYPES.arcGisFeature, label: MAP_TYPES.arcGisFeature, id:\"techPreview\" });\n\n return formats;\n });\n\n const handleOnChange = React.useCallback((value: string) => {\n setMapFormat(value);\n if (props.onChange) {\n props.onChange(value);\n }\n }, [props]);\n\n return (\n\n <Select\n className=\"map-layer-source-select\"\n options={mapFormats}\n value={mapFormat}\n disabled={props.disabled}\n onChange={handleOnChange}\n size=\"small\"\n itemRenderer={\n (option) => (\n <MenuItem\n badge={option.id?.includes(\"techPreview\") ?\n <div title={techPreviewTooltip} className=\"map-layer-source-select-previewBadge\">\n <Icon size=\"small\"><SvgTechnicalPreviewMini /></Icon>\n </div>\n : undefined}>\n {option.label}\n </MenuItem>) }\n />\n );\n}\n"]}
1
+ {"version":3,"file":"SelectMapFormat.js","sourceRoot":"","sources":["../../../../src/ui/widget/SelectMapFormat.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F,8BAA8B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Aa,EAAE,CAAC,CAAC;QAEtG,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC,CAAC;IAEH,MAAM,cAAc,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,KAAa,EAAE,EAAE;QACzD,YAAY,CAAC,KAAK,CAAC,CAAC;QACpB,IAAI,KAAK,CAAC,QAAQ,EAAE;YAClB,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;SACvB;IACH,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,OAAO,CAEL,oBAAC,6BAAa,IACZ,SAAS,EAAC,yBAAyB,EACnC,OAAO,EAAE,UAAU,EACnB,KAAK,EAAE,SAAS,EAChB,QAAQ,EAAE,KAAK,CAAC,QAAQ,EACxB,QAAQ,EAAE,cAAc,EACxB,IAAI,EAAC,OAAO,EACZ,YAAY,EACV,CAAC,MAAM,EAAE,EAAE,CAAC,CACV,oBAAC,wBAAQ,IACP,KAAK,EAAE,MAAM,CAAC,EAAE,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC;gBACzC,6BAAK,KAAK,EAAE,uBAAW,CAAC,SAAS,CAAC,gCAAgC,CAAC,EAAE,SAAS,EAAC,sCAAsC;oBACnH,oBAAC,oBAAI,IAAC,IAAI,EAAC,OAAO;wBAAC,oBAAC,mDAAuB,OAAG,CAAO,CACjD;gBACN,CAAC,CAAC,SAAS,IACZ,MAAM,CAAC,KAAK,CACJ,CAAC,GAChB,CACH,CAAC;AACJ,CAAC;AA/CD,0CA+CC","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 \"./MapUrlDialog.scss\";\nimport * as React from \"react\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { SvgTechnicalPreviewMini } from \"@itwin/itwinui-icons-color-react\";\nimport { Icon, LabeledSelect, MenuItem, SelectOption } from \"@itwin/itwinui-react\";\nimport { MapLayersUI } from \"../../mapLayers\";\nimport { MapTypesOptions } from \"../Interfaces\";\n\n// TODO:\n// Remove this structure and iterate over the registry's active formats.\n// Still need a proper way to exclude some format, like we currently do with\n// 'TileUrl' without the need to hardcode any format Id.\nexport const MAP_TYPES = {\n wms: \"WMS\",\n arcGis: \"ArcGIS\",\n wmts: \"WMTS\",\n tileUrl: \"TileURL\",\n arcGisFeature: \"ArcGISFeature\",\n};\n\ninterface SelectMapFormatProps {\n value?: string;\n disabled?: boolean;\n mapTypesOptions?: MapTypesOptions;\n onChange?: (mapType: string) => void;\n /**\n * Message below the select. Does not apply to 'inline' select.\n */\n message?: React.ReactNode;\n /**\n * Status of the select.\n * @default ''\n */\n status?: \"positive\" | \"warning\" | \"negative\";\n}\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport function SelectMapFormat(props: SelectMapFormatProps) {\n\n const [mapFormat, setMapFormat] = React.useState(props.value ?? MAP_TYPES.arcGis);\n\n const [mapFormats] = React.useState((): SelectOption<string>[] => {\n const formats: SelectOption<string>[] = [\n { value: MAP_TYPES.arcGis, label: MAP_TYPES.arcGis },\n { value: MAP_TYPES.wms, label: MAP_TYPES.wms },\n { value: MAP_TYPES.wmts, label: MAP_TYPES.wmts },\n ];\n if (props.mapTypesOptions?.supportTileUrl)\n formats.push({ value: MAP_TYPES.tileUrl, label: MAP_TYPES.tileUrl });\n\n if (IModelApp.mapLayerFormatRegistry.isRegistered(MAP_TYPES.arcGisFeature))\n formats.push( { value: MAP_TYPES.arcGisFeature, label: MAP_TYPES.arcGisFeature, id:\"techPreview\" });\n\n return formats;\n });\n\n const handleOnChange = React.useCallback((value: string) => {\n setMapFormat(value);\n if (props.onChange) {\n props.onChange(value);\n }\n }, [props]);\n\n return (\n\n <LabeledSelect\n className=\"map-layer-source-select\"\n options={mapFormats}\n value={mapFormat}\n disabled={props.disabled}\n onChange={handleOnChange}\n size=\"small\"\n itemRenderer={\n (option) => (\n <MenuItem\n badge={option.id?.includes(\"techPreview\") ?\n <div title={MapLayersUI.translate(\"Labels.TechPreviewBadgeTooltip\")} className=\"map-layer-source-select-previewBadge\">\n <Icon size=\"small\"><SvgTechnicalPreviewMini /></Icon>\n </div>\n : undefined}>\n {option.label}\n </MenuItem>) }\n />\n );\n}\n"]}
@@ -0,0 +1,10 @@
1
+ import * as React from "react";
2
+ interface UserPreferencesStorageOptionsProps {
3
+ disabled?: boolean;
4
+ itwinChecked?: boolean;
5
+ modelChecked?: boolean;
6
+ onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
7
+ }
8
+ export declare function UserPreferencesStorageOptions(props: UserPreferencesStorageOptionsProps): JSX.Element;
9
+ export {};
10
+ //# sourceMappingURL=UserPreferencesStorageOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UserPreferencesStorageOptions.d.ts","sourceRoot":"","sources":["../../../../src/ui/widget/UserPreferencesStorageOptions.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,UAAU,kCAAkC;IAC1C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;CACjE;AAED,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,kCAAkC,eAqBtF"}
@@ -0,0 +1,17 @@
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.UserPreferencesStorageOptions = void 0;
8
+ const React = require("react");
9
+ const itwinui_react_1 = require("@itwin/itwinui-react");
10
+ const mapLayers_1 = require("../../mapLayers");
11
+ function UserPreferencesStorageOptions(props) {
12
+ return (React.createElement("div", null,
13
+ React.createElement(itwinui_react_1.Radio, { disabled: props.disabled, name: "settingsStorage", value: "iTwin", label: mapLayers_1.MapLayersUI.translate("CustomAttach.StoreOnITwinSettings"), checked: props.itwinChecked, onChange: props.onChange }),
14
+ React.createElement(itwinui_react_1.Radio, { disabled: props.disabled, name: "settingsStorage", value: "Model", label: mapLayers_1.MapLayersUI.translate("CustomAttach.StoreOnModelSettings"), checked: props.modelChecked, onChange: props.onChange })));
15
+ }
16
+ exports.UserPreferencesStorageOptions = UserPreferencesStorageOptions;
17
+ //# sourceMappingURL=UserPreferencesStorageOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UserPreferencesStorageOptions.js","sourceRoot":"","sources":["../../../../src/ui/widget/UserPreferencesStorageOptions.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,+BAA+B;AAC/B,wDAA6C;AAC7C,+CAA8C;AAS9C,SAAgB,6BAA6B,CAAC,KAAyC;IACrF,OAAO,CACL;QACE,oBAAC,qBAAK,IACJ,QAAQ,EAAE,KAAK,CAAC,QAAQ,EACxB,IAAI,EAAC,iBAAiB,EACtB,KAAK,EAAC,OAAO,EACb,KAAK,EAAE,uBAAW,CAAC,SAAS,CAAC,mCAAmC,CAAC,EACjE,OAAO,EAAE,KAAK,CAAC,YAAY,EAC3B,QAAQ,EAAE,KAAK,CAAC,QAAQ,GACxB;QACF,oBAAC,qBAAK,IACJ,QAAQ,EAAE,KAAK,CAAC,QAAQ,EACxB,IAAI,EAAC,iBAAiB,EACtB,KAAK,EAAC,OAAO,EACb,KAAK,EAAE,uBAAW,CAAC,SAAS,CAAC,mCAAmC,CAAC,EACjE,OAAO,EAAE,KAAK,CAAC,YAAY,EAC3B,QAAQ,EAAE,KAAK,CAAC,QAAQ,GACxB,CACE,CACP,CAAC;AACJ,CAAC;AArBD,sEAqBC","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 * as React from \"react\";\nimport { Radio } from \"@itwin/itwinui-react\";\nimport { MapLayersUI } from \"../../mapLayers\";\n\ninterface UserPreferencesStorageOptionsProps {\n disabled?: boolean;\n itwinChecked?: boolean;\n modelChecked?: boolean;\n onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;\n}\n\nexport function UserPreferencesStorageOptions(props: UserPreferencesStorageOptionsProps) {\n return (\n <div>\n <Radio\n disabled={props.disabled}\n name=\"settingsStorage\"\n value=\"iTwin\"\n label={MapLayersUI.translate(\"CustomAttach.StoreOnITwinSettings\")}\n checked={props.itwinChecked}\n onChange={props.onChange}\n />\n <Radio\n disabled={props.disabled}\n name=\"settingsStorage\"\n value=\"Model\"\n label={MapLayersUI.translate(\"CustomAttach.StoreOnModelSettings\")}\n checked={props.modelChecked}\n onChange={props.onChange}\n />\n </div>\n );\n}\n"]}
@@ -0,0 +1,25 @@
1
+ /** Index signature holding preferences content
2
+ *
3
+ * @internal
4
+ */
5
+ interface KeyContentProps<Type> {
6
+ [preferenceKey: string]: Type;
7
+ }
8
+ export interface BrowserStorageOptions {
9
+ /** indicate whether or not delete function should throw an error if the provided key cannot be found. */
10
+ throwOnDeleteMissingKey?: boolean;
11
+ itemKeyName: string;
12
+ }
13
+ export declare class BrowserStorage<Type> {
14
+ private readonly _itemKeyName;
15
+ private readonly _throwOnDeleteMissingKey;
16
+ constructor(opts: BrowserStorageOptions);
17
+ private loadFromStorage;
18
+ get(key: string | undefined): Type[] | undefined;
19
+ getContent(): KeyContentProps<Type> | undefined;
20
+ delete(key: string): void;
21
+ deleteMatchingContent(content: Type): void;
22
+ save(key: string, content: Type): void;
23
+ }
24
+ export {};
25
+ //# sourceMappingURL=BrowserStorage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BrowserStorage.d.ts","sourceRoot":"","sources":["../../src/BrowserStorage.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,UAAU,eAAe,CAAC,IAAI;IAC5B,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAED,MAAM,WAAW,qBAAqB;IACpC,yGAAyG;IACzG,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,qBAAa,cAAc,CAAC,IAAI;IAE9B,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC;IAC9B,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAAC;gBAE9B,IAAI,EAAE,qBAAqB;IAKvC,OAAO,CAAC,eAAe;IAehB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAC,SAAS;IAezB,UAAU;IAIV,MAAM,CAAC,GAAG,EAAE,MAAM;IAmBlB,qBAAqB,CAAC,OAAO,EAAE,IAAI;IAcnC,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI;CAUvC"}
@@ -0,0 +1,76 @@
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
+ export class BrowserStorage {
6
+ constructor(opts) {
7
+ this._itemKeyName = opts.itemKeyName;
8
+ this._throwOnDeleteMissingKey = opts.throwOnDeleteMissingKey ?? true;
9
+ }
10
+ loadFromStorage() {
11
+ const storage = window.localStorage;
12
+ let map = {};
13
+ const itemStr = storage.getItem(this._itemKeyName);
14
+ if (itemStr === null) {
15
+ return undefined;
16
+ }
17
+ if (!itemStr || itemStr === "{}")
18
+ return map;
19
+ map = JSON.parse(itemStr);
20
+ return map;
21
+ }
22
+ get(key) {
23
+ const map = this.loadFromStorage();
24
+ if (map === undefined)
25
+ return undefined;
26
+ if (key) {
27
+ if (!Object.keys(map).includes(key))
28
+ return undefined;
29
+ return [map[key]];
30
+ }
31
+ else { // No key provided, return all objects
32
+ return Object.entries(map).map(([_key, value]) => value);
33
+ }
34
+ }
35
+ getContent() {
36
+ return this.loadFromStorage();
37
+ }
38
+ delete(key) {
39
+ const map = this.loadFromStorage();
40
+ if (map === undefined) {
41
+ if (this._throwOnDeleteMissingKey)
42
+ throw new Error("Could not find key from storage.");
43
+ else
44
+ return;
45
+ }
46
+ if (!Object.keys(map).includes(key)) {
47
+ if (this._throwOnDeleteMissingKey)
48
+ throw Error("Could not find key from storage.");
49
+ else
50
+ return;
51
+ }
52
+ delete map[key];
53
+ window.localStorage.setItem(this._itemKeyName, JSON.stringify(map));
54
+ }
55
+ deleteMatchingContent(content) {
56
+ const map = this.loadFromStorage();
57
+ if (map === undefined) {
58
+ return;
59
+ }
60
+ const contentJson = JSON.stringify(content);
61
+ for (const [key, value] of Object.entries(map)) {
62
+ if (JSON.stringify(value) === contentJson)
63
+ delete map[key];
64
+ }
65
+ window.localStorage.setItem(this._itemKeyName, JSON.stringify(map));
66
+ }
67
+ save(key, content) {
68
+ let map = this.loadFromStorage();
69
+ if (map === undefined)
70
+ map = {};
71
+ map[key] = content;
72
+ const itemValue = JSON.stringify(map);
73
+ window.localStorage.setItem(this._itemKeyName, itemValue);
74
+ }
75
+ }
76
+ //# sourceMappingURL=BrowserStorage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BrowserStorage.js","sourceRoot":"","sources":["../../src/BrowserStorage.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAgB/F,MAAM,OAAO,cAAc;IAKzB,YAAY,IAA2B;QACrC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC;QACrC,IAAI,CAAC,wBAAwB,GAAG,IAAI,CAAC,uBAAuB,IAAI,IAAI,CAAC;IACvE,CAAC;IAEO,eAAe;QACrB,MAAM,OAAO,GAAG,MAAM,CAAC,YAAY,CAAC;QAEpC,IAAI,GAAG,GAA0B,EAAE,CAAC;QACp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B,MAAM,KAAK,CAAC,kCAAkC,CAAC,CAAC;;gBAEhD,OAAO;SACV;QACD,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC;QAChB,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;IACtE,CAAC;IAEM,qBAAqB,CAAC,OAAa;QACxC,MAAM,GAAG,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;QACnC,IAAI,GAAG,KAAK,SAAS,EAAE;YACrB,OAAO;SACR;QACD,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QAC5C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YAC9C,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,WAAW;gBACvC,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC;SACnB;QAED,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;IACtE,CAAC;IAEM,IAAI,CAAC,GAAW,EAAE,OAAa;QACpC,IAAI,GAAG,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;QACjC,IAAI,GAAG,KAAK,SAAS;YACnB,GAAG,GAAG,EAAE,CAAC;QAEX,GAAG,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC;QAEnB,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QACtC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;IAC5D,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\n/** Index signature holding preferences content\n *\n * @internal\n */\ninterface KeyContentProps<Type> {\n [preferenceKey: string]: Type;\n}\n\nexport interface BrowserStorageOptions {\n /** indicate whether or not delete function should throw an error if the provided key cannot be found. */\n throwOnDeleteMissingKey?: boolean;\n itemKeyName: string;\n}\n\nexport class BrowserStorage<Type> {\n\n private readonly _itemKeyName;\n private readonly _throwOnDeleteMissingKey;\n\n constructor(opts: BrowserStorageOptions) {\n this._itemKeyName = opts.itemKeyName;\n this._throwOnDeleteMissingKey = opts.throwOnDeleteMissingKey ?? true;\n }\n\n private loadFromStorage() {\n const storage = window.localStorage;\n\n let map: KeyContentProps<Type> = {};\n const itemStr = storage.getItem(this._itemKeyName);\n if (itemStr === null) {\n return undefined;\n }\n if (!itemStr || itemStr === \"{}\")\n return map;\n\n map = JSON.parse(itemStr);\n return map;\n }\n\n public get(key: string|undefined) {\n const map = this.loadFromStorage();\n if (map === undefined)\n return undefined;\n\n if (key) {\n if (!Object.keys(map).includes(key))\n return undefined;\n\n return [map[key]];\n } else { // No key provided, return all objects\n return Object.entries(map).map(([_key, value]) => value);\n }\n }\n\n public getContent() {\n return this.loadFromStorage();\n }\n\n public delete(key: string) {\n const map = this.loadFromStorage();\n if (map === undefined) {\n if (this._throwOnDeleteMissingKey)\n throw new Error(\"Could not find key from storage.\");\n else\n return;\n }\n\n if (!Object.keys(map).includes(key)) {\n if (this._throwOnDeleteMissingKey)\n throw Error(\"Could not find key from storage.\");\n else\n return;\n }\n delete map[key];\n window.localStorage.setItem(this._itemKeyName, JSON.stringify(map));\n }\n\n public deleteMatchingContent(content: Type) {\n const map = this.loadFromStorage();\n if (map === undefined) {\n return;\n }\n const contentJson = JSON.stringify(content);\n for (const [key, value] of Object.entries(map)) {\n if (JSON.stringify(value) === contentJson)\n delete map[key];\n }\n\n window.localStorage.setItem(this._itemKeyName, JSON.stringify(map));\n }\n\n public save(key: string, content: Type) {\n let map = this.loadFromStorage();\n if (map === undefined)\n map = {};\n\n map[key] = content;\n\n const itemValue = JSON.stringify(map);\n window.localStorage.setItem(this._itemKeyName, itemValue);\n }\n}\n"]}
@@ -0,0 +1,5 @@
1
+ import { MapLayerSource } from "@itwin/core-frontend";
2
+ export declare class CustomParamUtils {
3
+ static setSourceCustomParams(source: MapLayerSource, customParamNames: string[]): void;
4
+ }
5
+ //# sourceMappingURL=CustomParamUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CustomParamUtils.d.ts","sourceRoot":"","sources":["../../src/CustomParamUtils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD,qBAAa,gBAAgB;WACb,qBAAqB,CAAC,MAAM,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,EAAE;CAiBvF"}
@@ -0,0 +1,22 @@
1
+ import { CustomParamsStorage } from "./CustomParamsStorage";
2
+ export class CustomParamUtils {
3
+ static setSourceCustomParams(source, customParamNames) {
4
+ const cpStorage = new CustomParamsStorage();
5
+ customParamNames.forEach((paramName) => {
6
+ const customParam = cpStorage.get(paramName);
7
+ if (customParam && customParam.length > 0 && source) {
8
+ if (customParam[0].secret) {
9
+ if (!source.unsavedQueryParams)
10
+ source.unsavedQueryParams = {};
11
+ source.unsavedQueryParams[customParam[0].key] = customParam[0].value;
12
+ }
13
+ else {
14
+ if (!source.savedQueryParams)
15
+ source.savedQueryParams = {};
16
+ source.savedQueryParams[customParam[0].key] = customParam[0].value;
17
+ }
18
+ }
19
+ });
20
+ }
21
+ }
22
+ //# sourceMappingURL=CustomParamUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CustomParamUtils.js","sourceRoot":"","sources":["../../src/CustomParamUtils.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,MAAM,OAAO,gBAAgB;IACpB,MAAM,CAAC,qBAAqB,CAAC,MAAsB,EAAE,gBAA0B;QACpF,MAAM,SAAS,GAAG,IAAI,mBAAmB,EAAE,CAAC;QAC5C,gBAAgB,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE;YACrC,MAAM,WAAW,GAAG,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YAC7C,IAAI,WAAW,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,IAAI,MAAM,EAAE;gBACnD,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE;oBACzB,IAAI,CAAC,MAAM,CAAC,kBAAkB;wBAC5B,MAAM,CAAC,kBAAkB,GAAG,EAAE,CAAC;oBACjC,MAAM,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;iBACtE;qBAAM;oBACL,IAAI,CAAC,MAAM,CAAC,gBAAgB;wBAC1B,MAAM,CAAC,gBAAgB,GAAG,EAAE,CAAC;oBAC/B,MAAM,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;iBACpE;aACF;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { MapLayerSource } from \"@itwin/core-frontend\";\nimport { CustomParamsStorage } from \"./CustomParamsStorage\";\n\nexport class CustomParamUtils {\n public static setSourceCustomParams(source: MapLayerSource, customParamNames: string[]) {\n const cpStorage = new CustomParamsStorage();\n customParamNames.forEach((paramName) => {\n const customParam = cpStorage.get(paramName);\n if (customParam && customParam.length > 0 && source) {\n if (customParam[0].secret) {\n if (!source.unsavedQueryParams)\n source.unsavedQueryParams = {};\n source.unsavedQueryParams[customParam[0].key] = customParam[0].value;\n } else {\n if (!source.savedQueryParams)\n source.savedQueryParams = {};\n source.savedQueryParams[customParam[0].key] = customParam[0].value;\n }\n }\n });\n }\n}\n"]}
@@ -0,0 +1,6 @@
1
+ import { BrowserStorage } from "./BrowserStorage";
2
+ import { CustomParamsMappingItem } from "./ui/Interfaces";
3
+ export declare class CustomParamsMappingStorage extends BrowserStorage<CustomParamsMappingItem> {
4
+ constructor();
5
+ }
6
+ //# sourceMappingURL=CustomParamsMappingStorage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CustomParamsMappingStorage.d.ts","sourceRoot":"","sources":["../../src/CustomParamsMappingStorage.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAE1D,qBAAa,0BAA2B,SAAQ,cAAc,CAAC,uBAAuB,CAAC;;CAItF"}
@@ -0,0 +1,11 @@
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 { BrowserStorage } from "./BrowserStorage";
6
+ export class CustomParamsMappingStorage extends BrowserStorage {
7
+ constructor() {
8
+ super({ itemKeyName: "itwinjs.mapLayers.customParamsMapping" });
9
+ }
10
+ }
11
+ //# sourceMappingURL=CustomParamsMappingStorage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CustomParamsMappingStorage.js","sourceRoot":"","sources":["../../src/CustomParamsMappingStorage.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD,MAAM,OAAO,0BAA2B,SAAQ,cAAuC;IACrF;QACE,KAAK,CAAC,EAAC,WAAW,EAAE,uCAAuC,EAAC,CAAC,CAAC;IAChE,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { BrowserStorage } from \"./BrowserStorage\";\nimport { CustomParamsMappingItem } from \"./ui/Interfaces\";\n\nexport class CustomParamsMappingStorage extends BrowserStorage<CustomParamsMappingItem> {\n constructor() {\n super({itemKeyName: \"itwinjs.mapLayers.customParamsMapping\"});\n }\n}\n"]}
@@ -0,0 +1,6 @@
1
+ import { BrowserStorage } from "./BrowserStorage";
2
+ import { CustomParamItem } from "./ui/Interfaces";
3
+ export declare class CustomParamsStorage extends BrowserStorage<CustomParamItem> {
4
+ constructor();
5
+ }
6
+ //# sourceMappingURL=CustomParamsStorage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CustomParamsStorage.d.ts","sourceRoot":"","sources":["../../src/CustomParamsStorage.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,qBAAa,mBAAoB,SAAQ,cAAc,CAAC,eAAe,CAAC;;CAIvE"}
@@ -0,0 +1,11 @@
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 { BrowserStorage } from "./BrowserStorage";
6
+ export class CustomParamsStorage extends BrowserStorage {
7
+ constructor() {
8
+ super({ itemKeyName: "itwinjs.mapLayers.customParams" });
9
+ }
10
+ }
11
+ //# sourceMappingURL=CustomParamsStorage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CustomParamsStorage.js","sourceRoot":"","sources":["../../src/CustomParamsStorage.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD,MAAM,OAAO,mBAAoB,SAAQ,cAA+B;IACtE;QACE,KAAK,CAAC,EAAC,WAAW,EAAE,gCAAgC,EAAC,CAAC,CAAC;IACzD,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\nimport { BrowserStorage } from \"./BrowserStorage\";\nimport { CustomParamItem } from \"./ui/Interfaces\";\n\nexport class CustomParamsStorage extends BrowserStorage<CustomParamItem> {\n constructor() {\n super({itemKeyName: \"itwinjs.mapLayers.customParams\"});\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"MapLayerPreferences.d.ts","sourceRoot":"","sources":["../../src/MapLayerPreferences.ts"],"names":[],"mappings":"AAKA,OAAO,EAAa,cAAc,EAA+C,MAAM,sBAAsB,CAAC;AAC9G,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAG1D,gBAAgB;AAChB,MAAM,WAAW,0BAA0B;IACzC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,qBAAqB,EAAE,OAAO,GAAG,SAAS,CAAC;CAC5C;AAED,gBAAgB;AAChB,oBAAY,wBAAwB;IAClC,KAAK,IAAI;IACT,OAAO,IAAI;IACX,QAAQ,IAAI;CACb;AAED,gBAAgB;AAChB,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC;CAC/B;AAED;;;;;GAKG;AACH,qBAAa,mBAAmB;IAC9B;;;;;;OAMG;IACH,gBAAuB,oBAAoB,uBAA4B,wBAAwB,qFAA6D,IAAI,EAAI;IAEpK;;;;;;OAMG;WACiB,WAAW,CAA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MapLayerPreferences {
31
31
  return false;
32
32
  const accessToken = undefined !== IModelApp.authorizationClient ? (await IModelApp.authorizationClient.getAccessToken()) : undefined;
33
33
  const sourceJSON = source.toJSON();
34
+ if (!sourceJSON.formatId)
35
+ return false;
34
36
  const mapLayerSetting = {
35
37
  url: sourceJSON.url,
36
38
  name: sourceJSON.name,