@itwin/map-layers 6.0.0-dev.5 → 6.0.0-dev.6

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 (98) hide show
  1. package/lib/cjs/BrowserStorage.js +2 -0
  2. package/lib/cjs/BrowserStorage.js.map +1 -1
  3. package/lib/cjs/MapLayerPreferences.js +8 -8
  4. package/lib/cjs/MapLayerPreferences.js.map +1 -1
  5. package/lib/cjs/PreferencesBrowserStorage.js +2 -0
  6. package/lib/cjs/PreferencesBrowserStorage.js.map +1 -1
  7. package/lib/cjs/mapLayers.js +4 -2
  8. package/lib/cjs/mapLayers.js.map +1 -1
  9. package/lib/cjs/public/locales/en/mapLayers.json +6 -1
  10. package/lib/cjs/ui/FeatureInfoUiItemsProvider.js +3 -2
  11. package/lib/cjs/ui/FeatureInfoUiItemsProvider.js.map +1 -1
  12. package/lib/cjs/ui/MapLayersUiItemsProvider.js +2 -1
  13. package/lib/cjs/ui/MapLayersUiItemsProvider.js.map +1 -1
  14. package/lib/cjs/ui/hooks/useCrossOriginPopup.js +1 -2
  15. package/lib/cjs/ui/hooks/useCrossOriginPopup.js.map +1 -1
  16. package/lib/cjs/ui/hooks/useInterval.js +1 -2
  17. package/lib/cjs/ui/hooks/useInterval.js.map +1 -1
  18. package/lib/cjs/ui/hooks/useResizeObserver.d.ts.map +1 -1
  19. package/lib/cjs/ui/widget/AttachLayerPopupButton.js +2 -2
  20. package/lib/cjs/ui/widget/AttachLayerPopupButton.js.map +1 -1
  21. package/lib/cjs/ui/widget/BasemapPanel.d.ts.map +1 -1
  22. package/lib/cjs/ui/widget/BasemapPanel.js +46 -18
  23. package/lib/cjs/ui/widget/BasemapPanel.js.map +1 -1
  24. package/lib/cjs/ui/widget/ConfirmMessageDialog.js +1 -2
  25. package/lib/cjs/ui/widget/ConfirmMessageDialog.js.map +1 -1
  26. package/lib/cjs/ui/widget/CustomParamEditDialog.js +1 -2
  27. package/lib/cjs/ui/widget/CustomParamEditDialog.js.map +1 -1
  28. package/lib/cjs/ui/widget/CustomParamsSettings.js +1 -2
  29. package/lib/cjs/ui/widget/CustomParamsSettings.js.map +1 -1
  30. package/lib/cjs/ui/widget/FeatureInfoDataProvider.js +34 -33
  31. package/lib/cjs/ui/widget/FeatureInfoDataProvider.js.map +1 -1
  32. package/lib/cjs/ui/widget/FeatureInfoWidget.js +2 -3
  33. package/lib/cjs/ui/widget/FeatureInfoWidget.js.map +1 -1
  34. package/lib/cjs/ui/widget/MapLayerDroppable.js +3 -4
  35. package/lib/cjs/ui/widget/MapLayerDroppable.js.map +1 -1
  36. package/lib/cjs/ui/widget/MapLayerManager.d.ts.map +1 -1
  37. package/lib/cjs/ui/widget/MapLayerManager.js +19 -4
  38. package/lib/cjs/ui/widget/MapLayerManager.js.map +1 -1
  39. package/lib/cjs/ui/widget/MapLayerSettingsMenu.js +1 -2
  40. package/lib/cjs/ui/widget/MapLayerSettingsMenu.js.map +1 -1
  41. package/lib/cjs/ui/widget/MapLayerSettingsPopupButton.js +1 -2
  42. package/lib/cjs/ui/widget/MapLayerSettingsPopupButton.js.map +1 -1
  43. package/lib/cjs/ui/widget/MapLayersWidget.js +1 -2
  44. package/lib/cjs/ui/widget/MapLayersWidget.js.map +1 -1
  45. package/lib/cjs/ui/widget/MapManagerMapLayersHeader.js +1 -2
  46. package/lib/cjs/ui/widget/MapManagerMapLayersHeader.js.map +1 -1
  47. package/lib/cjs/ui/widget/MapManagerSettings.js +1 -2
  48. package/lib/cjs/ui/widget/MapManagerSettings.js.map +1 -1
  49. package/lib/cjs/ui/widget/MapSelectFeaturesDialog.js +1 -2
  50. package/lib/cjs/ui/widget/MapSelectFeaturesDialog.js.map +1 -1
  51. package/lib/cjs/ui/widget/MapUrlDialog.js +2 -2
  52. package/lib/cjs/ui/widget/MapUrlDialog.js.map +1 -1
  53. package/lib/cjs/ui/widget/SelectApiKey.js +1 -2
  54. package/lib/cjs/ui/widget/SelectApiKey.js.map +1 -1
  55. package/lib/cjs/ui/widget/SelectCustomParam.js +1 -2
  56. package/lib/cjs/ui/widget/SelectCustomParam.js.map +1 -1
  57. package/lib/cjs/ui/widget/SelectMapFormat.js +2 -2
  58. package/lib/cjs/ui/widget/SelectMapFormat.js.map +1 -1
  59. package/lib/cjs/ui/widget/SubLayersDataProvider.js +2 -1
  60. package/lib/cjs/ui/widget/SubLayersDataProvider.js.map +1 -1
  61. package/lib/cjs/ui/widget/SubLayersPopupButton.js +1 -2
  62. package/lib/cjs/ui/widget/SubLayersPopupButton.js.map +1 -1
  63. package/lib/cjs/ui/widget/SubLayersTree.js +35 -26
  64. package/lib/cjs/ui/widget/SubLayersTree.js.map +1 -1
  65. package/lib/cjs/ui/widget/TransparencyPopupButton.js +1 -2
  66. package/lib/cjs/ui/widget/TransparencyPopupButton.js.map +1 -1
  67. package/lib/cjs/ui/widget/UserPreferencesStorageOptions.js +1 -2
  68. package/lib/cjs/ui/widget/UserPreferencesStorageOptions.js.map +1 -1
  69. package/lib/esm/BrowserStorage.js +2 -0
  70. package/lib/esm/BrowserStorage.js.map +1 -1
  71. package/lib/esm/MapLayerPreferences.js +8 -8
  72. package/lib/esm/MapLayerPreferences.js.map +1 -1
  73. package/lib/esm/PreferencesBrowserStorage.js +2 -0
  74. package/lib/esm/PreferencesBrowserStorage.js.map +1 -1
  75. package/lib/esm/mapLayers.js +4 -2
  76. package/lib/esm/mapLayers.js.map +1 -1
  77. package/lib/esm/public/locales/en/mapLayers.json +6 -1
  78. package/lib/esm/ui/FeatureInfoUiItemsProvider.js +3 -2
  79. package/lib/esm/ui/FeatureInfoUiItemsProvider.js.map +1 -1
  80. package/lib/esm/ui/MapLayersUiItemsProvider.js +2 -1
  81. package/lib/esm/ui/MapLayersUiItemsProvider.js.map +1 -1
  82. package/lib/esm/ui/hooks/useResizeObserver.d.ts.map +1 -1
  83. package/lib/esm/ui/widget/BasemapPanel.d.ts.map +1 -1
  84. package/lib/esm/ui/widget/BasemapPanel.js +46 -17
  85. package/lib/esm/ui/widget/BasemapPanel.js.map +1 -1
  86. package/lib/esm/ui/widget/FeatureInfoDataProvider.js +34 -33
  87. package/lib/esm/ui/widget/FeatureInfoDataProvider.js.map +1 -1
  88. package/lib/esm/ui/widget/MapLayerDroppable.js +2 -2
  89. package/lib/esm/ui/widget/MapLayerDroppable.js.map +1 -1
  90. package/lib/esm/ui/widget/MapLayerManager.d.ts.map +1 -1
  91. package/lib/esm/ui/widget/MapLayerManager.js +16 -1
  92. package/lib/esm/ui/widget/MapLayerManager.js.map +1 -1
  93. package/lib/esm/ui/widget/SubLayersDataProvider.js +2 -1
  94. package/lib/esm/ui/widget/SubLayersDataProvider.js.map +1 -1
  95. package/lib/esm/ui/widget/SubLayersTree.js +33 -23
  96. package/lib/esm/ui/widget/SubLayersTree.js.map +1 -1
  97. package/lib/public/locales/en/mapLayers.json +6 -1
  98. package/package.json +35 -33
@@ -23,7 +23,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.SubLayersTree = exports.SubLayersPanel = void 0;
26
+ exports.SubLayersPanel = SubLayersPanel;
27
+ exports.SubLayersTree = SubLayersTree;
27
28
  const jsx_runtime_1 = require("react/jsx-runtime");
28
29
  /*---------------------------------------------------------------------------------------------
29
30
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
@@ -50,7 +51,6 @@ function SubLayersPanel(props) {
50
51
  return (0, jsx_runtime_1.jsx)(SubLayersTree, { subLayers: props.subLayers, ...props });
51
52
  }
52
53
  }
53
- exports.SubLayersPanel = SubLayersPanel;
54
54
  /**
55
55
  * Tree Control that displays sub-layer hierarchy
56
56
  * @internal
@@ -109,32 +109,14 @@ function SubLayersTree(props) {
109
109
  (0, jsx_runtime_1.jsx)(itwinui_react_1.IconButton, { style: { marginLeft: "5px" }, size: "small", label: props.checkboxStyle === "eye" ? mapLayers_1.MapLayersUI.translate("SubLayers.AllOff") : mapLayers_1.MapLayersUI.translate("SelectFeaturesDialog.AllOff"), onClick: async () => changeAll(false), children: props.checkboxStyle === "eye" ? (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgVisibilityHide, {}) : (0, jsx_runtime_1.jsx)(itwinui_icons_react_1.SvgCheckboxDeselect, {}) }, "hide-all-btn"),
110
110
  ] }), (0, jsx_runtime_1.jsx)("div", { className: "map-manager-sublayer-tree-content", ref: elementRef, children: width !== undefined && height !== undefined && ((0, jsx_runtime_1.jsx)(components_react_1.ControlledTree, { nodeLoader: nodeLoader, selectionMode: components_react_1.SelectionMode.None, eventsHandler: eventHandler, model: treeModel, treeRenderer: props.checkboxStyle === "eye" ? nodeWithEyeCheckboxTreeRenderer : undefined, nodeHighlightingProps: nodeHighlightingProps, width: width, height: height, noDataRenderer: () => (0, jsx_runtime_1.jsx)("p", { className: "components-controlledTree-errorMessage", children: noResults }) })) })] }) }));
111
111
  }
112
- exports.SubLayersTree = SubLayersTree;
113
112
  /** TreeEventHandler derived class that handler processing changes to subLayer visibility */
114
113
  class SubLayerCheckboxHandler extends components_react_1.TreeEventHandler {
114
+ _removeModelChangedListener;
115
+ _onSubLayerStateChange;
116
+ _subLayers;
117
+ _singleVisibleSubLayer;
115
118
  constructor(subLayers, singleVisibleSubLayer, nodeLoader, onSubLayerStateChange) {
116
119
  super({ modelSource: nodeLoader.modelSource, nodeLoader, collapsedChildrenDisposalEnabled: true });
117
- //-----------------------------------------------------------------------
118
- // Listen to model changes
119
- //------------------------------------------------------------------------
120
- // This is required because nodes are delay loaded in the model until
121
- // they are made visible (i.e. parent node is expanded). So even though
122
- // you might have created nodes in the data provided with a proper
123
- // initial state, by the time it gets loaded, their state might have became
124
- // out of date in the TreeView's active model. So whenever a node
125
- // is added, when must confirm its state matches the current model
126
- // (i.e. state of their parent.)
127
- this.onModelChanged = (args) => {
128
- this.modelSource.modifyModel((model) => {
129
- const addedNodes = args[1].addedNodeIds.map((id) => model.getNode(id));
130
- addedNodes.forEach((node) => {
131
- if (!node) {
132
- return;
133
- }
134
- this.syncNodeStateWithParent(model, node);
135
- });
136
- });
137
- };
138
120
  this._subLayers = subLayers;
139
121
  this._singleVisibleSubLayer = singleVisibleSubLayer;
140
122
  this._onSubLayerStateChange = onSubLayerStateChange;
@@ -175,6 +157,27 @@ class SubLayerCheckboxHandler extends components_react_1.TreeEventHandler {
175
157
  }
176
158
  }
177
159
  }
160
+ //-----------------------------------------------------------------------
161
+ // Listen to model changes
162
+ //------------------------------------------------------------------------
163
+ // This is required because nodes are delay loaded in the model until
164
+ // they are made visible (i.e. parent node is expanded). So even though
165
+ // you might have created nodes in the data provided with a proper
166
+ // initial state, by the time it gets loaded, their state might have became
167
+ // out of date in the TreeView's active model. So whenever a node
168
+ // is added, when must confirm its state matches the current model
169
+ // (i.e. state of their parent.)
170
+ onModelChanged = (args) => {
171
+ this.modelSource.modifyModel((model) => {
172
+ const addedNodes = args[1].addedNodeIds.map((id) => model.getNode(id));
173
+ addedNodes.forEach((node) => {
174
+ if (!node) {
175
+ return;
176
+ }
177
+ this.syncNodeStateWithParent(model, node);
178
+ });
179
+ });
180
+ };
178
181
  static isUnnamedGroup(subLayer) {
179
182
  if (!subLayer) {
180
183
  return false;
@@ -303,8 +306,10 @@ function useNodeHighlightingProps(filter) {
303
306
  return nodeHighlightingProps;
304
307
  }
305
308
  class FullTreeHierarchy {
309
+ _dataProvider;
310
+ _hierarchy = new Map();
311
+ _init;
306
312
  constructor(dataProvider) {
307
- this._hierarchy = new Map();
308
313
  this._dataProvider = dataProvider;
309
314
  this._init = (async () => {
310
315
  await this.initNode();
@@ -323,8 +328,11 @@ class FullTreeHierarchy {
323
328
  }
324
329
  }
325
330
  class FilteredTreeHierarchy {
331
+ _fullHierarchy;
332
+ _filter;
333
+ _filtered = new Map();
334
+ _init;
326
335
  constructor(dataProvider, filter) {
327
- this._filtered = new Map();
328
336
  this._fullHierarchy = new FullTreeHierarchy(dataProvider);
329
337
  this._filter = filter;
330
338
  this._init = (async () => {
@@ -383,6 +391,7 @@ class FilteredTreeHierarchy {
383
391
  }
384
392
  }
385
393
  class FilteredTreeDataProvider {
394
+ _hierarchy;
386
395
  constructor(parentDataProvider, filter) {
387
396
  this._hierarchy = new FilteredTreeHierarchy(parentDataProvider, filter);
388
397
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SubLayersTree.js","sourceRoot":"","sources":["../../../../src/ui/widget/SubLayersTree.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;;gGAGgG;AAChG,0DAA4D;AAC5D,gCAA8B;AAC9B,6CAA+B;AAC/B,8DAWiC;AACjC,oEAA0H;AAC1H,wDAAmE;AACnE,+CAA8C;AAC9C,mEAAgE;AAChE,kEAA+D;AA+B/D,SAAS,OAAO,CAAC,KAAmB;IAClC,OAAO,CACL,iCAAK,SAAS,EAAC,mCAAmC,aAChD,gCAAK,SAAS,EAAC,6BAA6B,YAAE,KAAK,CAAC,QAAQ,GAAO,EAClE,KAAK,CAAC,WAAW,IAAI,gCAAK,SAAS,EAAC,wBAAwB,YAAE,KAAK,CAAC,WAAW,GAAO,IACnF,CACP,CAAC;AACJ,CAAC;AAOD,SAAgB,cAAc,CAAC,KAA0B;IACvD,MAAM,CAAC,kBAAkB,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,uBAAW,CAAC,YAAY,CAAC,kBAAkB,CAAC,iCAAiC,CAAC,CAAC,CAAC;IAC5H,IAAI,SAAS,KAAK,KAAK,CAAC,SAAS,IAAI,CAAC,KAAK,KAAK,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;QAClE,OAAO,CACL,gCAAK,SAAS,EAAC,4BAA4B,YACzC,0CAAM,kBAAkB,GAAO,GAC3B,CACP,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,OAAO,uBAAC,aAAa,IAAC,SAAS,EAAE,KAAK,CAAC,SAAS,KAAM,KAAK,GAAI,CAAC;IAClE,CAAC;AACH,CAAC;AAXD,wCAWC;AAYD;;;GAGG;AACH,SAA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,MAAqB;QACzC,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,YAAY,EAAE,CAAC;QACvD,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QACxC,OAAO,KAAK,IAAI,EAAE,CAAC;IACrB,CAAC;IAEM,KAAK,CAAC,aAAa,CAAC,MAAqB;QAC9C,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,YAAY,EAAE,CAAC;QACvD,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QACxC,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC,CAAC;IAC5B,CAAC;CACF","sourcesContent":["\n/*---------------------------------------------------------------------------------------------\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 { PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport \"./SubLayersTree.scss\";\nimport * as React from \"react\";\nimport {\n CheckBoxState,\n ControlledTree,\n SelectionMode,\n TreeEventHandler,\n TreeImageLoader,\n TreeModelSource,\n TreeNodeLoader,\n TreeNodeRenderer,\n TreeRenderer,\n useTreeModel,\n} from \"@itwin/components-react\";\nimport { SvgCheckboxDeselect, SvgCheckboxSelect, SvgVisibilityHide, SvgVisibilityShow } from \"@itwin/itwinui-icons-react\";\nimport { Checkbox, IconButton, Input } from \"@itwin/itwinui-react\";\nimport { MapLayersUI } from \"../../mapLayers\";\nimport { SubLayersDataProvider } from \"./SubLayersDataProvider\";\nimport { useResizeObserver } from \"../hooks/useResizeObserver\";\n\nimport type {\n AbstractTreeNodeLoaderWithProvider,\n DelayLoadedTreeNodeItem,\n HighlightableTreeProps,\n ITreeDataProvider,\n MutableTreeModel,\n MutableTreeModelNode,\n TreeCheckboxStateChangeEventArgs,\n TreeDataProvider,\n TreeModel,\n TreeModelChanges,\n TreeNodeItem,\n TreeNodeRendererProps,\n TreeRendererProps,\n} from \"@itwin/components-react\";\nimport type { MapSubLayerProps, SubLayerId } from \"@itwin/core-common\";\nimport type { SubLayersTreeExpandMode } from \"./SubLayersDataProvider\";\n\ntype CheckboxProps = React.ComponentPropsWithoutRef<typeof Checkbox>;\ntype CheckboxRendererProps = Omit<CheckboxProps, \"onChange\" | \"onClick\"> & {\n onChange: (checked: boolean) => void;\n onClick: (e: React.MouseEvent) => void;\n};\n\ninterface ToolbarProps {\n searchField?: React.ReactNode;\n children?: React.ReactNode[];\n}\n\nfunction Toolbar(props: ToolbarProps) {\n return (\n <div className=\"map-manager-sublayer-tree-toolbar\">\n <div className=\"tree-toolbar-action-buttons\">{props.children}</div>\n {props.searchField && <div className=\"tree-toolbar-searchbox\">{props.searchField}</div>}\n </div>\n );\n}\n\nexport type OnSubLayerStateChangeType = (subLayerId: SubLayerId, isSelected: boolean) => void;\nexport interface SubLayersPanelProps extends Omit<SubLayersTreeProps, \"subLayers\"> {\n subLayers?: MapSubLayerProps[];\n}\n\nexport function SubLayersPanel(props: SubLayersPanelProps) {\n const [noneAvailableLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:SubLayers.NoSubLayers\"));\n if (undefined === props.subLayers || 0 === props.subLayers.length) {\n return (\n <div className=\"map-manager-sublayer-panel\">\n <div>{noneAvailableLabel}</div>\n </div>\n );\n } else {\n return <SubLayersTree subLayers={props.subLayers} {...props} />;\n }\n}\n\nexport interface SubLayersTreeProps {\n checkboxStyle: \"standard\" | \"eye\";\n expandMode: SubLayersTreeExpandMode;\n subLayers: MapSubLayerProps[];\n singleVisibleSubLayer?: boolean;\n onSubLayerStateChange?: OnSubLayerStateChangeType;\n height?: number;\n width?: number;\n}\n\n/**\n * Tree Control that displays sub-layer hierarchy\n * @internal\n */\nexport function SubLayersTree(props: SubLayersTreeProps) {\n const [width, setWidth] = React.useState<number | undefined>(props.width);\n const [height, setHeight] = React.useState<number | undefined>(props.height);\n\n const [placeholderLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:SubLayers.SearchPlaceholder\"));\n const [noResults] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:SubLayers.NoResults\"));\n const [subLayers, setSubLayers] = React.useState(props.subLayers);\n const [layerFilterString, setLayerFilterString] = React.useState<string>(\"\");\n\n // create data provider to get some nodes to show in tree\n // `React.useMemo' is used avoid creating new object on each render cycle\n // We DO want a dependency on 'layerFilterString' (event though eslint doesn't like it)..\n // each time the filter is updated the provider must be refreshed otherwise the state of model is out of synch.\n const dataProvider = React.useMemo(\n () => new SubLayersDataProvider(subLayers, props.expandMode),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [subLayers, props.expandMode, layerFilterString],\n );\n\n const { modelSource, nodeLoader, nodeHighlightingProps } = useTreeFiltering(dataProvider, layerFilterString);\n\n // create custom event handler. It handles all tree event same as `TreeEventHandler` but additionally\n // it selects/deselects node when checkbox is checked/unchecked and vice versa.\n const [eventHandler, setEventHandler] = React.useState<SubLayerCheckboxHandler | undefined>(undefined);\n\n const [elementRef] = useResizeObserver<HTMLDivElement>((size) => {\n setWidth(size.width);\n setHeight(size.height);\n });\n\n React.useEffect(() => {\n const handler = new SubLayerCheckboxHandler(subLayers, props.singleVisibleSubLayer ?? false, nodeLoader, props.onSubLayerStateChange);\n setEventHandler(handler);\n return () => {\n handler.dispose();\n };\n }, [nodeLoader, subLayers, props.onSubLayerStateChange, props.singleVisibleSubLayer]);\n\n // Get an immutable tree model from the model source. The model is regenerated every time the model source\n // emits the `onModelChanged` event.\n const treeModel = useTreeModel(modelSource);\n const changeAll = React.useCallback(\n async (visible: boolean) => {\n const tmpSubLayers = [...subLayers]; // deep copy to trigger state change\n if (tmpSubLayers) {\n tmpSubLayers?.forEach((subLayer: MapSubLayerProps) => {\n subLayer.visible = visible;\n });\n\n setSubLayers(tmpSubLayers);\n }\n\n if (props.onSubLayerStateChange) {\n props.onSubLayerStateChange(-1, visible);\n }\n },\n [subLayers, props],\n );\n\n const handleFilterTextChanged = React.useCallback((event: React.ChangeEvent<HTMLInputElement>) => {\n setLayerFilterString(event.target.value);\n }, []);\n\n return (\n <>\n <div className=\"map-manager-sublayer-tree\">\n <Toolbar\n searchField={\n <Input\n type=\"text\"\n className=\"map-manager-sublayer-tree-searchbox\"\n placeholder={placeholderLabel}\n value={layerFilterString}\n onChange={handleFilterTextChanged}\n size=\"small\"\n />\n }\n >\n {props.singleVisibleSubLayer\n ? undefined\n : [\n <IconButton\n key=\"show-all-btn\"\n size=\"small\"\n label={props.checkboxStyle === \"eye\" ? MapLayersUI.translate(\"SubLayers.AllOn\") : MapLayersUI.translate(\"SelectFeaturesDialog.AllOn\")}\n onClick={async () => changeAll(true)}\n >\n {props.checkboxStyle === \"eye\" ? <SvgVisibilityShow /> : <SvgCheckboxSelect />}\n </IconButton>,\n <IconButton\n style={{ marginLeft: \"5px\" }}\n key=\"hide-all-btn\"\n size=\"small\"\n label={props.checkboxStyle === \"eye\" ? MapLayersUI.translate(\"SubLayers.AllOff\") : MapLayersUI.translate(\"SelectFeaturesDialog.AllOff\")}\n onClick={async () => changeAll(false)}\n >\n {props.checkboxStyle === \"eye\" ? <SvgVisibilityHide /> : <SvgCheckboxDeselect />}\n </IconButton>,\n ]}\n </Toolbar>\n <div className=\"map-manager-sublayer-tree-content\" ref={elementRef}>\n {width !== undefined && height !== undefined && (\n <ControlledTree\n nodeLoader={nodeLoader}\n selectionMode={SelectionMode.None}\n eventsHandler={eventHandler!}\n model={treeModel}\n treeRenderer={props.checkboxStyle === \"eye\" ? nodeWithEyeCheckboxTreeRenderer : undefined}\n nodeHighlightingProps={nodeHighlightingProps}\n width={width}\n height={height}\n noDataRenderer={() => <p className=\"components-controlledTree-errorMessage\">{noResults}</p>}\n />\n )}\n </div>\n </div>\n </>\n );\n}\n\n/** TreeEventHandler derived class that handler processing changes to subLayer visibility */\nclass SubLayerCheckboxHandler extends TreeEventHandler {\n private _removeModelChangedListener: () => void;\n private _onSubLayerStateChange?: OnSubLayerStateChangeType;\n private _subLayers: MapSubLayerProps[];\n private _singleVisibleSubLayer?: boolean;\n\n constructor(\n subLayers: MapSubLayerProps[],\n singleVisibleSubLayer: boolean,\n nodeLoader: AbstractTreeNodeLoaderWithProvider<TreeDataProvider>,\n onSubLayerStateChange?: OnSubLayerStateChangeType,\n ) {\n super({ modelSource: nodeLoader.modelSource, nodeLoader, collapsedChildrenDisposalEnabled: true });\n this._subLayers = subLayers;\n this._singleVisibleSubLayer = singleVisibleSubLayer;\n this._onSubLayerStateChange = onSubLayerStateChange;\n this._removeModelChangedListener = this.modelSource.onModelChanged.addListener(this.onModelChanged);\n }\n\n public override dispose() {\n this._removeModelChangedListener();\n super.dispose();\n }\n\n // Cascade state\n // Children on unnamed groups must get disabled in the tree view, because\n // they get rendered anyway.\n private cascadeStateToAllChildren(model: MutableTreeModel, parentId?: string) {\n const children = model.getChildren(parentId);\n if (children === undefined) {\n return;\n }\n\n for (const childID of children) {\n const childNode = childID ? model.getNode(childID) : undefined;\n\n if (childNode) {\n this.syncNodeStateWithParent(model, childNode);\n }\n\n // Drill down the tree.\n this.cascadeStateToAllChildren(model, childID);\n }\n }\n\n private applyMutualExclusiveState(model: MutableTreeModel, nodeId: string) {\n const changedNode = model.getNode(nodeId);\n if (changedNode?.checkbox.state === CheckBoxState.Off) {\n return;\n }\n\n for (const node of model.iterateTreeModelNodes()) {\n if (node.id === changedNode?.id) {\n continue;\n }\n\n if (node && node.checkbox.state === CheckBoxState.On) {\n node.checkbox.state = CheckBoxState.Off;\n }\n }\n }\n\n //-----------------------------------------------------------------------\n // Listen to model changes\n //------------------------------------------------------------------------\n // This is required because nodes are delay loaded in the model until\n // they are made visible (i.e. parent node is expanded). So even though\n // you might have created nodes in the data provided with a proper\n // initial state, by the time it gets loaded, their state might have became\n // out of date in the TreeView's active model. So whenever a node\n // is added, when must confirm its state matches the current model\n // (i.e. state of their parent.)\n public onModelChanged = (args: [TreeModel, TreeModelChanges]) => {\n this.modelSource.modifyModel((model) => {\n const addedNodes = args[1].addedNodeIds.map((id) => model.getNode(id));\n addedNodes.forEach((node) => {\n if (!node) {\n return;\n }\n\n this.syncNodeStateWithParent(model, node);\n });\n });\n };\n\n private static isUnnamedGroup(subLayer: MapSubLayerProps | undefined): boolean {\n if (!subLayer) {\n return false;\n }\n\n return (!subLayer.name || subLayer.name.length === 0) && subLayer.children !== undefined && subLayer.children.length > 0;\n }\n\n // Ensure the state of changed node matches the state of its parent.\n private syncNodeStateWithParent(model: MutableTreeModel, changedNode: MutableTreeModelNode) {\n // Lookup node parent. If non exists, I assume thats the root node,\n // and it must have a proper initial state.\n const parentNode = changedNode.parentId ? model.getNode(changedNode.parentId) : undefined;\n if (!parentNode) {\n return;\n }\n\n if (!changedNode.checkbox) {\n return;\n } // don't see why this would happen, but if there is no checkbox, we cant do much here.\n\n const parentLayerId = undefined !== parentNode.item.extendedData?.subLayerId ? parentNode.item.extendedData?.subLayerId : parentNode.item.id;\n const parentSubLayer = this._subLayers?.find((subLayer) => subLayer.id === parentLayerId);\n\n // If parent is disabled, then children must be too.\n // Also, Non-visible unnamed group must have their children disabled (unamed groups have visibility inherence)\n if (parentNode.checkbox.isDisabled || (SubLayerCheckboxHandler.isUnnamedGroup(parentSubLayer) && parentNode.checkbox.state === CheckBoxState.Off)) {\n changedNode.checkbox.isDisabled = true;\n changedNode.checkbox.state = CheckBoxState.Off;\n } else {\n // Visibility state from StyleMapLayerSettings applies\n const subLayerId = undefined !== changedNode.item.extendedData?.subLayerId ? changedNode.item.extendedData?.subLayerId : changedNode.item.id;\n const foundSubLayer = this._subLayers?.find((subLayer) => subLayer.id === subLayerId);\n changedNode.checkbox.isDisabled = false;\n changedNode.checkbox.state = foundSubLayer?.visible ? CheckBoxState.On : CheckBoxState.Off;\n }\n }\n\n /** Changes nodes checkboxes states until event is handled or handler is disposed */\n public override onCheckboxStateChanged({ stateChanges }: TreeCheckboxStateChangeEventArgs) {\n // call base checkbox handling\n const baseHandling = super.onCheckboxStateChanged({ stateChanges });\n\n // subscribe to checkbox state changes to new checkbox states and do some additional work with them\n const selectionHandling = stateChanges.subscribe({\n next: (changes) => {\n changes.forEach((change) => {\n const isSelected = change.newState === CheckBoxState.On;\n const subLayerId = undefined !== change.nodeItem.extendedData?.subLayerId ? change.nodeItem.extendedData?.subLayerId : change.nodeItem.id;\n\n // Get the previously visible node if we are in 'singleVisibleSubLayer' node\n let prevVisibleSubLayers: SubLayerId[] = [];\n if (this._singleVisibleSubLayer) {\n prevVisibleSubLayers = this._subLayers.reduce((filtered: SubLayerId[], subLayer) => {\n if (subLayer.visible && subLayer.id !== undefined) {\n filtered.push(subLayer.id);\n }\n return filtered;\n }, []);\n }\n\n // Inform caller that subLayer state is going to change (i.e. update display style state)\n if (this._onSubLayerStateChange) {\n for (const slId of prevVisibleSubLayers) {\n this._onSubLayerStateChange(slId, false);\n }\n\n this._onSubLayerStateChange(subLayerId, isSelected);\n }\n\n // Update sublayer object, otherwise state would get out of sync with DisplayStyle each time the TreeView is re-rendered\n this._subLayers?.forEach((curSubLayer) => {\n if (curSubLayer.id !== undefined) {\n if (curSubLayer.id === subLayerId) {\n curSubLayer.visible = isSelected;\n } else if (prevVisibleSubLayers.includes(curSubLayer.id)) {\n curSubLayer.visible = false;\n }\n }\n });\n\n // Cascade state\n this.modelSource.modifyModel((model) => {\n if (this._singleVisibleSubLayer) {\n this.applyMutualExclusiveState(model, change.nodeItem.id);\n }\n this.cascadeStateToAllChildren(model, change.nodeItem.id);\n });\n });\n },\n });\n // stop handling selection when checkboxes handling is stopped\n baseHandling?.add(selectionHandling);\n return baseHandling;\n }\n}\n\n/** Custom checkbox renderer that renders checkbox as an eye */\nconst eyeCheckboxRenderer = (props: CheckboxRendererProps) => (\n <Checkbox\n className=\"core-image-checkbox\"\n variant=\"eyeball\"\n checked={props.checked}\n disabled={props.disabled}\n onChange={(e) => {\n props.onChange(e.target.checked);\n }}\n />\n);\n\n/** Custom node renderer. It uses default 'TreeNodeRenderer' but overrides default checkbox renderer to render checkbox as an eye */\nconst imageLoader = new TreeImageLoader();\nconst nodeWithEyeCheckboxRenderer = (props: TreeNodeRendererProps) => (\n <TreeNodeRenderer {...props} checkboxRenderer={eyeCheckboxRenderer} imageLoader={imageLoader} />\n);\n\n/** Custom tree renderer. It uses default `TreeRenderer` but overrides default node renderer to render node with custom checkbox */\nconst nodeWithEyeCheckboxTreeRenderer = (props: TreeRendererProps) => <TreeRenderer {...props} nodeRenderer={nodeWithEyeCheckboxRenderer} />;\n\nfunction useTreeFiltering(dataProvider: ITreeDataProvider, filter: string) {\n const nodeLoader = useFilteredProvider(dataProvider, filter);\n const nodeHighlightingProps = useNodeHighlightingProps(filter);\n return {\n nodeLoader,\n modelSource: nodeLoader.modelSource,\n nodeHighlightingProps,\n };\n}\n\nfunction useFilteredProvider(dataProvider: ITreeDataProvider, filter: string) {\n const filteredProvider = React.useMemo(() => {\n return new FilteredTreeDataProvider(dataProvider, filter);\n }, [dataProvider, filter]);\n\n const nodeLoader = React.useMemo(() => {\n return new TreeNodeLoader(filteredProvider, new TreeModelSource());\n }, [filteredProvider]);\n\n return nodeLoader;\n}\n\nfunction useNodeHighlightingProps(filter: string) {\n const [nodeHighlightingProps, setNodeHighlightingProps] = React.useState<HighlightableTreeProps>();\n\n React.useEffect(() => {\n if (filter === \"\") {\n setNodeHighlightingProps(undefined);\n return;\n }\n setNodeHighlightingProps({\n searchText: filter,\n activeMatch: undefined,\n });\n }, [filter]);\n\n return nodeHighlightingProps;\n}\n\nclass FullTreeHierarchy {\n private _dataProvider: ITreeDataProvider;\n private _hierarchy = new Map<string | undefined, DelayLoadedTreeNodeItem[]>();\n private _init: Promise<void>;\n\n public constructor(dataProvider: ITreeDataProvider) {\n this._dataProvider = dataProvider;\n\n this._init = (async () => {\n await this.initNode();\n })();\n }\n\n private async initNode(parent?: TreeNodeItem) {\n const nodes = await this._dataProvider.getNodes(parent);\n this._hierarchy.set(parent?.id, nodes);\n for (const node of nodes) {\n await this.initNode(node);\n }\n }\n\n public async getHierarchy() {\n await this._init;\n return this._hierarchy;\n }\n}\n\nclass FilteredTreeHierarchy {\n private _fullHierarchy: FullTreeHierarchy;\n private _filter: string;\n private _filtered = new Map<string | undefined, DelayLoadedTreeNodeItem[]>();\n private _init: Promise<void>;\n\n public constructor(dataProvider: ITreeDataProvider, filter: string) {\n this._fullHierarchy = new FullTreeHierarchy(dataProvider);\n this._filter = filter;\n\n this._init = (async () => {\n await this.init();\n })();\n }\n\n private async init() {\n const hierarchy = await this._fullHierarchy.getHierarchy();\n if (this._filter === \"\") {\n this._filtered = hierarchy;\n return;\n }\n this.filterNodes(hierarchy);\n }\n\n /** Initializes `this._filtered` field. Returns a node if it matches a filter. */\n private filterNodes(hierarchy: Map<string | undefined, DelayLoadedTreeNodeItem[]>, current?: DelayLoadedTreeNodeItem): DelayLoadedTreeNodeItem | undefined {\n const matches = current ? this.matchesFilter(current) : false;\n const children = hierarchy.get(current?.id);\n if (!children) {\n return matches ? current : undefined;\n }\n\n const matchedChildren = new Array<DelayLoadedTreeNodeItem>();\n for (const child of children) {\n const matchedChild = this.filterNodes(hierarchy, child);\n matchedChild && matchedChildren.push(matchedChild);\n }\n\n const hasChildren = matchedChildren.length > 0;\n const included = matches || hasChildren;\n let filtered: DelayLoadedTreeNodeItem | undefined;\n if (included) {\n this._filtered.set(current?.id, matchedChildren);\n\n // Return a modified copy of current node (to persist initial hierarchy when filter is cleared).\n if (current) {\n filtered = {\n ...current,\n hasChildren,\n autoExpand: hasChildren ? true : current.autoExpand,\n };\n }\n }\n return filtered;\n }\n\n private matchesFilter(node: TreeNodeItem) {\n if (node.label.value.valueFormat !== PropertyValueFormat.Primitive) {\n return false;\n }\n\n const value = node.label.value.displayValue?.toLowerCase();\n if (!value) {\n return false;\n }\n return value.includes(this._filter.toLowerCase());\n }\n\n public async getHierarchy() {\n await this._init;\n return this._filtered;\n }\n}\n\nclass FilteredTreeDataProvider implements ITreeDataProvider {\n private _hierarchy: FilteredTreeHierarchy;\n\n public constructor(parentDataProvider: ITreeDataProvider, filter: string) {\n this._hierarchy = new FilteredTreeHierarchy(parentDataProvider, filter);\n }\n\n public async getNodes(parent?: TreeNodeItem) {\n const hierarchy = await this._hierarchy.getHierarchy();\n const nodes = hierarchy.get(parent?.id);\n return nodes || [];\n }\n\n public async getNodesCount(parent?: TreeNodeItem) {\n const hierarchy = await this._hierarchy.getHierarchy();\n const nodes = hierarchy.get(parent?.id);\n return nodes?.length || 0;\n }\n}\n"]}
1
+ {"version":3,"file":"SubLayersTree.js","sourceRoot":"","sources":["../../../../src/ui/widget/SubLayersTree.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAqEA,wCAWC;AAgBD,sCAsHC;;AArND;;;gGAGgG;AAChG,0DAA4D;AAC5D,gCAA8B;AAC9B,6CAA+B;AAC/B,8DAWiC;AACjC,oEAA0H;AAC1H,wDAAmE;AACnE,+CAA8C;AAC9C,mEAAgE;AAChE,kEAA+D;AA+B/D,SAAS,OAAO,CAAC,KAAmB;IAClC,OAAO,CACL,iCAAK,SAAS,EAAC,mCAAmC,aAChD,gCAAK,SAAS,EAAC,6BAA6B,YAAE,KAAK,CAAC,QAAQ,GAAO,EAClE,KAAK,CAAC,WAAW,IAAI,gCAAK,SAAS,EAAC,wBAAwB,YAAE,KAAK,CAAC,WAAW,GAAO,IACnF,CACP,CAAC;AACJ,CAAC;AAOD,SAAgB,cAAc,CAAC,KAA0B;IACvD,MAAM,CAAC,kBAAkB,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,uBAAW,CAAC,YAAY,CAAC,kBAAkB,CAAC,iCAAiC,CAAC,CAAC,CAAC;IAC5H,IAAI,SAAS,KAAK,KAAK,CAAC,SAAS,IAAI,CAAC,KAAK,KAAK,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;QAClE,OAAO,CACL,gCAAK,SAAS,EAAC,4BAA4B,YACzC,0CAAM,kBAAkB,GAAO,GAC3B,CACP,CAAC;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,CAAC;IAEM,KAAK,CAAC,YAAY;QACvB,MAAM,IAAI,CAAC,KAAK,CAAC;QACjB,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;CACF;AAED,MAAM,wBAAwB;IACpB,UAAU,CAAwB;IAE1C,YAAmB,kBAAqC,EAAE,MAAc;QACtE,IAAI,CAAC,UAAU,GAAG,IAAI,qBAAqB,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;IAC1E,CAAC;IAEM,KAAK,CAAC,QAAQ,CAAC,MAAqB;QACzC,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,YAAY,EAAE,CAAC;QACvD,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QACxC,OAAO,KAAK,IAAI,EAAE,CAAC;IACrB,CAAC;IAEM,KAAK,CAAC,aAAa,CAAC,MAAqB;QAC9C,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,YAAY,EAAE,CAAC;QACvD,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QACxC,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC,CAAC;IAC5B,CAAC;CACF","sourcesContent":["\n/*---------------------------------------------------------------------------------------------\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 { PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport \"./SubLayersTree.scss\";\nimport * as React from \"react\";\nimport {\n CheckBoxState,\n ControlledTree,\n SelectionMode,\n TreeEventHandler,\n TreeImageLoader,\n TreeModelSource,\n TreeNodeLoader,\n TreeNodeRenderer,\n TreeRenderer,\n useTreeModel,\n} from \"@itwin/components-react\";\nimport { SvgCheckboxDeselect, SvgCheckboxSelect, SvgVisibilityHide, SvgVisibilityShow } from \"@itwin/itwinui-icons-react\";\nimport { Checkbox, IconButton, Input } from \"@itwin/itwinui-react\";\nimport { MapLayersUI } from \"../../mapLayers\";\nimport { SubLayersDataProvider } from \"./SubLayersDataProvider\";\nimport { useResizeObserver } from \"../hooks/useResizeObserver\";\n\nimport type {\n AbstractTreeNodeLoaderWithProvider,\n DelayLoadedTreeNodeItem,\n HighlightableTreeProps,\n ITreeDataProvider,\n MutableTreeModel,\n MutableTreeModelNode,\n TreeCheckboxStateChangeEventArgs,\n TreeDataProvider,\n TreeModel,\n TreeModelChanges,\n TreeNodeItem,\n TreeNodeRendererProps,\n TreeRendererProps,\n} from \"@itwin/components-react\";\nimport type { MapSubLayerProps, SubLayerId } from \"@itwin/core-common\";\nimport type { SubLayersTreeExpandMode } from \"./SubLayersDataProvider\";\n\ntype CheckboxProps = React.ComponentPropsWithoutRef<typeof Checkbox>;\ntype CheckboxRendererProps = Omit<CheckboxProps, \"onChange\" | \"onClick\"> & {\n onChange: (checked: boolean) => void;\n onClick: (e: React.MouseEvent) => void;\n};\n\ninterface ToolbarProps {\n searchField?: React.ReactNode;\n children?: React.ReactNode[];\n}\n\nfunction Toolbar(props: ToolbarProps) {\n return (\n <div className=\"map-manager-sublayer-tree-toolbar\">\n <div className=\"tree-toolbar-action-buttons\">{props.children}</div>\n {props.searchField && <div className=\"tree-toolbar-searchbox\">{props.searchField}</div>}\n </div>\n );\n}\n\nexport type OnSubLayerStateChangeType = (subLayerId: SubLayerId, isSelected: boolean) => void;\nexport interface SubLayersPanelProps extends Omit<SubLayersTreeProps, \"subLayers\"> {\n subLayers?: MapSubLayerProps[];\n}\n\nexport function SubLayersPanel(props: SubLayersPanelProps) {\n const [noneAvailableLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:SubLayers.NoSubLayers\"));\n if (undefined === props.subLayers || 0 === props.subLayers.length) {\n return (\n <div className=\"map-manager-sublayer-panel\">\n <div>{noneAvailableLabel}</div>\n </div>\n );\n } else {\n return <SubLayersTree subLayers={props.subLayers} {...props} />;\n }\n}\n\nexport interface SubLayersTreeProps {\n checkboxStyle: \"standard\" | \"eye\";\n expandMode: SubLayersTreeExpandMode;\n subLayers: MapSubLayerProps[];\n singleVisibleSubLayer?: boolean;\n onSubLayerStateChange?: OnSubLayerStateChangeType;\n height?: number;\n width?: number;\n}\n\n/**\n * Tree Control that displays sub-layer hierarchy\n * @internal\n */\nexport function SubLayersTree(props: SubLayersTreeProps) {\n const [width, setWidth] = React.useState<number | undefined>(props.width);\n const [height, setHeight] = React.useState<number | undefined>(props.height);\n\n const [placeholderLabel] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:SubLayers.SearchPlaceholder\"));\n const [noResults] = React.useState(MapLayersUI.localization.getLocalizedString(\"mapLayers:SubLayers.NoResults\"));\n const [subLayers, setSubLayers] = React.useState(props.subLayers);\n const [layerFilterString, setLayerFilterString] = React.useState<string>(\"\");\n\n // create data provider to get some nodes to show in tree\n // `React.useMemo' is used avoid creating new object on each render cycle\n // We DO want a dependency on 'layerFilterString' (event though eslint doesn't like it)..\n // each time the filter is updated the provider must be refreshed otherwise the state of model is out of synch.\n const dataProvider = React.useMemo(\n () => new SubLayersDataProvider(subLayers, props.expandMode),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [subLayers, props.expandMode, layerFilterString],\n );\n\n const { modelSource, nodeLoader, nodeHighlightingProps } = useTreeFiltering(dataProvider, layerFilterString);\n\n // create custom event handler. It handles all tree event same as `TreeEventHandler` but additionally\n // it selects/deselects node when checkbox is checked/unchecked and vice versa.\n const [eventHandler, setEventHandler] = React.useState<SubLayerCheckboxHandler | undefined>(undefined);\n\n const [elementRef] = useResizeObserver<HTMLDivElement>((size) => {\n setWidth(size.width);\n setHeight(size.height);\n });\n\n React.useEffect(() => {\n const handler = new SubLayerCheckboxHandler(subLayers, props.singleVisibleSubLayer ?? false, nodeLoader, props.onSubLayerStateChange);\n setEventHandler(handler);\n return () => {\n handler.dispose();\n };\n }, [nodeLoader, subLayers, props.onSubLayerStateChange, props.singleVisibleSubLayer]);\n\n // Get an immutable tree model from the model source. The model is regenerated every time the model source\n // emits the `onModelChanged` event.\n const treeModel = useTreeModel(modelSource);\n const changeAll = React.useCallback(\n async (visible: boolean) => {\n const tmpSubLayers = [...subLayers]; // deep copy to trigger state change\n if (tmpSubLayers) {\n tmpSubLayers?.forEach((subLayer: MapSubLayerProps) => {\n subLayer.visible = visible;\n });\n\n setSubLayers(tmpSubLayers);\n }\n\n if (props.onSubLayerStateChange) {\n props.onSubLayerStateChange(-1, visible);\n }\n },\n [subLayers, props],\n );\n\n const handleFilterTextChanged = React.useCallback((event: React.ChangeEvent<HTMLInputElement>) => {\n setLayerFilterString(event.target.value);\n }, []);\n\n return (\n <>\n <div className=\"map-manager-sublayer-tree\">\n <Toolbar\n searchField={\n <Input\n type=\"text\"\n className=\"map-manager-sublayer-tree-searchbox\"\n placeholder={placeholderLabel}\n value={layerFilterString}\n onChange={handleFilterTextChanged}\n size=\"small\"\n />\n }\n >\n {props.singleVisibleSubLayer\n ? undefined\n : [\n <IconButton\n key=\"show-all-btn\"\n size=\"small\"\n label={props.checkboxStyle === \"eye\" ? MapLayersUI.translate(\"SubLayers.AllOn\") : MapLayersUI.translate(\"SelectFeaturesDialog.AllOn\")}\n onClick={async () => changeAll(true)}\n >\n {props.checkboxStyle === \"eye\" ? <SvgVisibilityShow /> : <SvgCheckboxSelect />}\n </IconButton>,\n <IconButton\n style={{ marginLeft: \"5px\" }}\n key=\"hide-all-btn\"\n size=\"small\"\n label={props.checkboxStyle === \"eye\" ? MapLayersUI.translate(\"SubLayers.AllOff\") : MapLayersUI.translate(\"SelectFeaturesDialog.AllOff\")}\n onClick={async () => changeAll(false)}\n >\n {props.checkboxStyle === \"eye\" ? <SvgVisibilityHide /> : <SvgCheckboxDeselect />}\n </IconButton>,\n ]}\n </Toolbar>\n <div className=\"map-manager-sublayer-tree-content\" ref={elementRef}>\n {width !== undefined && height !== undefined && (\n <ControlledTree\n nodeLoader={nodeLoader}\n selectionMode={SelectionMode.None}\n eventsHandler={eventHandler!}\n model={treeModel}\n treeRenderer={props.checkboxStyle === \"eye\" ? nodeWithEyeCheckboxTreeRenderer : undefined}\n nodeHighlightingProps={nodeHighlightingProps}\n width={width}\n height={height}\n noDataRenderer={() => <p className=\"components-controlledTree-errorMessage\">{noResults}</p>}\n />\n )}\n </div>\n </div>\n </>\n );\n}\n\n/** TreeEventHandler derived class that handler processing changes to subLayer visibility */\nclass SubLayerCheckboxHandler extends TreeEventHandler {\n private _removeModelChangedListener: () => void;\n private _onSubLayerStateChange?: OnSubLayerStateChangeType;\n private _subLayers: MapSubLayerProps[];\n private _singleVisibleSubLayer?: boolean;\n\n constructor(\n subLayers: MapSubLayerProps[],\n singleVisibleSubLayer: boolean,\n nodeLoader: AbstractTreeNodeLoaderWithProvider<TreeDataProvider>,\n onSubLayerStateChange?: OnSubLayerStateChangeType,\n ) {\n super({ modelSource: nodeLoader.modelSource, nodeLoader, collapsedChildrenDisposalEnabled: true });\n this._subLayers = subLayers;\n this._singleVisibleSubLayer = singleVisibleSubLayer;\n this._onSubLayerStateChange = onSubLayerStateChange;\n this._removeModelChangedListener = this.modelSource.onModelChanged.addListener(this.onModelChanged);\n }\n\n public override dispose() {\n this._removeModelChangedListener();\n super.dispose();\n }\n\n // Cascade state\n // Children on unnamed groups must get disabled in the tree view, because\n // they get rendered anyway.\n private cascadeStateToAllChildren(model: MutableTreeModel, parentId?: string) {\n const children = model.getChildren(parentId);\n if (children === undefined) {\n return;\n }\n\n for (const childID of children) {\n const childNode = childID ? model.getNode(childID) : undefined;\n\n if (childNode) {\n this.syncNodeStateWithParent(model, childNode);\n }\n\n // Drill down the tree.\n this.cascadeStateToAllChildren(model, childID);\n }\n }\n\n private applyMutualExclusiveState(model: MutableTreeModel, nodeId: string) {\n const changedNode = model.getNode(nodeId);\n if (changedNode?.checkbox.state === CheckBoxState.Off) {\n return;\n }\n\n for (const node of model.iterateTreeModelNodes()) {\n if (node.id === changedNode?.id) {\n continue;\n }\n\n if (node && node.checkbox.state === CheckBoxState.On) {\n node.checkbox.state = CheckBoxState.Off;\n }\n }\n }\n\n //-----------------------------------------------------------------------\n // Listen to model changes\n //------------------------------------------------------------------------\n // This is required because nodes are delay loaded in the model until\n // they are made visible (i.e. parent node is expanded). So even though\n // you might have created nodes in the data provided with a proper\n // initial state, by the time it gets loaded, their state might have became\n // out of date in the TreeView's active model. So whenever a node\n // is added, when must confirm its state matches the current model\n // (i.e. state of their parent.)\n public onModelChanged = (args: [TreeModel, TreeModelChanges]) => {\n this.modelSource.modifyModel((model) => {\n const addedNodes = args[1].addedNodeIds.map((id) => model.getNode(id));\n addedNodes.forEach((node) => {\n if (!node) {\n return;\n }\n\n this.syncNodeStateWithParent(model, node);\n });\n });\n };\n\n private static isUnnamedGroup(subLayer: MapSubLayerProps | undefined): boolean {\n if (!subLayer) {\n return false;\n }\n\n return (!subLayer.name || subLayer.name.length === 0) && subLayer.children !== undefined && subLayer.children.length > 0;\n }\n\n // Ensure the state of changed node matches the state of its parent.\n private syncNodeStateWithParent(model: MutableTreeModel, changedNode: MutableTreeModelNode) {\n // Lookup node parent. If non exists, I assume thats the root node,\n // and it must have a proper initial state.\n const parentNode = changedNode.parentId ? model.getNode(changedNode.parentId) : undefined;\n if (!parentNode) {\n return;\n }\n\n if (!changedNode.checkbox) {\n return;\n } // don't see why this would happen, but if there is no checkbox, we cant do much here.\n\n const parentLayerId = undefined !== parentNode.item.extendedData?.subLayerId ? parentNode.item.extendedData?.subLayerId : parentNode.item.id;\n const parentSubLayer = this._subLayers?.find((subLayer) => subLayer.id === parentLayerId);\n\n // If parent is disabled, then children must be too.\n // Also, Non-visible unnamed group must have their children disabled (unamed groups have visibility inherence)\n if (parentNode.checkbox.isDisabled || (SubLayerCheckboxHandler.isUnnamedGroup(parentSubLayer) && parentNode.checkbox.state === CheckBoxState.Off)) {\n changedNode.checkbox.isDisabled = true;\n changedNode.checkbox.state = CheckBoxState.Off;\n } else {\n // Visibility state from StyleMapLayerSettings applies\n const subLayerId = undefined !== changedNode.item.extendedData?.subLayerId ? changedNode.item.extendedData?.subLayerId : changedNode.item.id;\n const foundSubLayer = this._subLayers?.find((subLayer) => subLayer.id === subLayerId);\n changedNode.checkbox.isDisabled = false;\n changedNode.checkbox.state = foundSubLayer?.visible ? CheckBoxState.On : CheckBoxState.Off;\n }\n }\n\n /** Changes nodes checkboxes states until event is handled or handler is disposed */\n public override onCheckboxStateChanged({ stateChanges }: TreeCheckboxStateChangeEventArgs) {\n // call base checkbox handling\n const baseHandling = super.onCheckboxStateChanged({ stateChanges });\n\n // subscribe to checkbox state changes to new checkbox states and do some additional work with them\n const selectionHandling = stateChanges.subscribe({\n next: (changes) => {\n changes.forEach((change) => {\n const isSelected = change.newState === CheckBoxState.On;\n const subLayerId = undefined !== change.nodeItem.extendedData?.subLayerId ? change.nodeItem.extendedData?.subLayerId : change.nodeItem.id;\n\n // Get the previously visible node if we are in 'singleVisibleSubLayer' node\n let prevVisibleSubLayers: SubLayerId[] = [];\n if (this._singleVisibleSubLayer) {\n prevVisibleSubLayers = this._subLayers.reduce((filtered: SubLayerId[], subLayer) => {\n if (subLayer.visible && subLayer.id !== undefined) {\n filtered.push(subLayer.id);\n }\n return filtered;\n }, []);\n }\n\n // Inform caller that subLayer state is going to change (i.e. update display style state)\n if (this._onSubLayerStateChange) {\n for (const slId of prevVisibleSubLayers) {\n this._onSubLayerStateChange(slId, false);\n }\n\n this._onSubLayerStateChange(subLayerId, isSelected);\n }\n\n // Update sublayer object, otherwise state would get out of sync with DisplayStyle each time the TreeView is re-rendered\n this._subLayers?.forEach((curSubLayer) => {\n if (curSubLayer.id !== undefined) {\n if (curSubLayer.id === subLayerId) {\n curSubLayer.visible = isSelected;\n } else if (prevVisibleSubLayers.includes(curSubLayer.id)) {\n curSubLayer.visible = false;\n }\n }\n });\n\n // Cascade state\n this.modelSource.modifyModel((model) => {\n if (this._singleVisibleSubLayer) {\n this.applyMutualExclusiveState(model, change.nodeItem.id);\n }\n this.cascadeStateToAllChildren(model, change.nodeItem.id);\n });\n });\n },\n });\n // stop handling selection when checkboxes handling is stopped\n baseHandling?.add(selectionHandling);\n return baseHandling;\n }\n}\n\n/** Custom checkbox renderer that renders checkbox as an eye */\nconst eyeCheckboxRenderer = (props: CheckboxRendererProps) => (\n <Checkbox\n className=\"core-image-checkbox\"\n variant=\"eyeball\"\n checked={props.checked}\n disabled={props.disabled}\n onChange={(e) => {\n props.onChange(e.target.checked);\n }}\n />\n);\n\n/** Custom node renderer. It uses default 'TreeNodeRenderer' but overrides default checkbox renderer to render checkbox as an eye */\nconst imageLoader = new TreeImageLoader();\nconst nodeWithEyeCheckboxRenderer = (props: TreeNodeRendererProps) => (\n <TreeNodeRenderer {...props} checkboxRenderer={eyeCheckboxRenderer} imageLoader={imageLoader} />\n);\n\n/** Custom tree renderer. It uses default `TreeRenderer` but overrides default node renderer to render node with custom checkbox */\nconst nodeWithEyeCheckboxTreeRenderer = (props: TreeRendererProps) => <TreeRenderer {...props} nodeRenderer={nodeWithEyeCheckboxRenderer} />;\n\nfunction useTreeFiltering(dataProvider: ITreeDataProvider, filter: string) {\n const nodeLoader = useFilteredProvider(dataProvider, filter);\n const nodeHighlightingProps = useNodeHighlightingProps(filter);\n return {\n nodeLoader,\n modelSource: nodeLoader.modelSource,\n nodeHighlightingProps,\n };\n}\n\nfunction useFilteredProvider(dataProvider: ITreeDataProvider, filter: string) {\n const filteredProvider = React.useMemo(() => {\n return new FilteredTreeDataProvider(dataProvider, filter);\n }, [dataProvider, filter]);\n\n const nodeLoader = React.useMemo(() => {\n return new TreeNodeLoader(filteredProvider, new TreeModelSource());\n }, [filteredProvider]);\n\n return nodeLoader;\n}\n\nfunction useNodeHighlightingProps(filter: string) {\n const [nodeHighlightingProps, setNodeHighlightingProps] = React.useState<HighlightableTreeProps>();\n\n React.useEffect(() => {\n if (filter === \"\") {\n setNodeHighlightingProps(undefined);\n return;\n }\n setNodeHighlightingProps({\n searchText: filter,\n activeMatch: undefined,\n });\n }, [filter]);\n\n return nodeHighlightingProps;\n}\n\nclass FullTreeHierarchy {\n private _dataProvider: ITreeDataProvider;\n private _hierarchy = new Map<string | undefined, DelayLoadedTreeNodeItem[]>();\n private _init: Promise<void>;\n\n public constructor(dataProvider: ITreeDataProvider) {\n this._dataProvider = dataProvider;\n\n this._init = (async () => {\n await this.initNode();\n })();\n }\n\n private async initNode(parent?: TreeNodeItem) {\n const nodes = await this._dataProvider.getNodes(parent);\n this._hierarchy.set(parent?.id, nodes);\n for (const node of nodes) {\n await this.initNode(node);\n }\n }\n\n public async getHierarchy() {\n await this._init;\n return this._hierarchy;\n }\n}\n\nclass FilteredTreeHierarchy {\n private _fullHierarchy: FullTreeHierarchy;\n private _filter: string;\n private _filtered = new Map<string | undefined, DelayLoadedTreeNodeItem[]>();\n private _init: Promise<void>;\n\n public constructor(dataProvider: ITreeDataProvider, filter: string) {\n this._fullHierarchy = new FullTreeHierarchy(dataProvider);\n this._filter = filter;\n\n this._init = (async () => {\n await this.init();\n })();\n }\n\n private async init() {\n const hierarchy = await this._fullHierarchy.getHierarchy();\n if (this._filter === \"\") {\n this._filtered = hierarchy;\n return;\n }\n this.filterNodes(hierarchy);\n }\n\n /** Initializes `this._filtered` field. Returns a node if it matches a filter. */\n private filterNodes(hierarchy: Map<string | undefined, DelayLoadedTreeNodeItem[]>, current?: DelayLoadedTreeNodeItem): DelayLoadedTreeNodeItem | undefined {\n const matches = current ? this.matchesFilter(current) : false;\n const children = hierarchy.get(current?.id);\n if (!children) {\n return matches ? current : undefined;\n }\n\n const matchedChildren = new Array<DelayLoadedTreeNodeItem>();\n for (const child of children) {\n const matchedChild = this.filterNodes(hierarchy, child);\n matchedChild && matchedChildren.push(matchedChild);\n }\n\n const hasChildren = matchedChildren.length > 0;\n const included = matches || hasChildren;\n let filtered: DelayLoadedTreeNodeItem | undefined;\n if (included) {\n this._filtered.set(current?.id, matchedChildren);\n\n // Return a modified copy of current node (to persist initial hierarchy when filter is cleared).\n if (current) {\n filtered = {\n ...current,\n hasChildren,\n autoExpand: hasChildren ? true : current.autoExpand,\n };\n }\n }\n return filtered;\n }\n\n private matchesFilter(node: TreeNodeItem) {\n if (node.label.value.valueFormat !== PropertyValueFormat.Primitive) {\n return false;\n }\n\n const value = node.label.value.displayValue?.toLowerCase();\n if (!value) {\n return false;\n }\n return value.includes(this._filter.toLowerCase());\n }\n\n public async getHierarchy() {\n await this._init;\n return this._filtered;\n }\n}\n\nclass FilteredTreeDataProvider implements ITreeDataProvider {\n private _hierarchy: FilteredTreeHierarchy;\n\n public constructor(parentDataProvider: ITreeDataProvider, filter: string) {\n this._hierarchy = new FilteredTreeHierarchy(parentDataProvider, filter);\n }\n\n public async getNodes(parent?: TreeNodeItem) {\n const hierarchy = await this._hierarchy.getHierarchy();\n const nodes = hierarchy.get(parent?.id);\n return nodes || [];\n }\n\n public async getNodesCount(parent?: TreeNodeItem) {\n const hierarchy = await this._hierarchy.getHierarchy();\n const nodes = hierarchy.get(parent?.id);\n return nodes?.length || 0;\n }\n}\n"]}
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.TransparencyPopupButton = void 0;
26
+ exports.TransparencyPopupButton = TransparencyPopupButton;
27
27
  const jsx_runtime_1 = require("react/jsx-runtime");
28
28
  /*---------------------------------------------------------------------------------------------
29
29
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
@@ -54,5 +54,4 @@ function TransparencyPopupButton({ transparency, onTransparencyChange, buttonToo
54
54
  }, [onTransparencyChange, transparency]);
55
55
  return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(itwinui_react_1.Popover, { content: (0, jsx_runtime_1.jsx)("div", { className: "map-transparency-popup-panel", children: (0, jsx_runtime_1.jsx)("div", { className: "map-transparency-slider-container", children: (0, jsx_runtime_1.jsx)(itwinui_react_1.Slider, { min: 0, max: 100, values: [transparency * 100], step: 1, onChange: handleTransparencyChange }) }) }), visible: isSettingsOpen, onVisibleChange: setIsSettingsOpen, placement: "bottom-end", applyBackground: true, positionReference: buttonRef.current ?? undefined, children: (0, jsx_runtime_1.jsx)(itwinui_react_1.Button, { disabled: disabled, size: "small", styleType: "borderless", title: toolTipLabel, className: "map-transparency-popup-button", onClick: togglePopupDisplay, ref: buttonRef, children: (0, jsx_runtime_1.jsx)("div", { className: "transparent-button", children: (0, jsx_runtime_1.jsx)("svg", { className: disabled ? "checkered-disabled" : "checkered", viewBox: "0 0 24 24", children: (0, jsx_runtime_1.jsx)("path", { d: "m21.00427 0h-18.00854a2.9957 2.9957 0 0 0 -2.99573 2.99567v18.0086a2.99575 2.99575 0 0 0 2.99573 2.99573h18.00854a2.99575 2.99575 0 0 0 2.99573-2.99573v-18.0086a2.9957 2.9957 0 0 0 -2.99573-2.99567zm-20.00427 21.00427v-9.00427h11v-11h9.00427a1.998 1.998 0 0 1 1.99573 1.99567v9.00433h-11v11h-9.00427a1.998 1.998 0 0 1 -1.99573-1.99573z" }) }) }) }) }) }));
56
56
  }
57
- exports.TransparencyPopupButton = TransparencyPopupButton;
58
57
  //# sourceMappingURL=TransparencyPopupButton.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TransparencyPopupButton.js","sourceRoot":"","sources":["../../../../src/ui/widget/TransparencyPopupButton.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;gGAGgG;AAEhG,0CAAwC;AACxC,6CAA+B;AAC/B,wDAAiD;AACjD,wDAA+D;AAa/D,aAAa;AACb,SAAgB,uBAAuB,CAAC,EAAE,YAAY,EAAE,oBAAoB,EAAE,aAAa,EAAE,QAAQ,EAAgC;IACnI,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAClE,MAAM,CAAC,wBAAwB,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,yBA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,EAAC,YAAY,EACtB,eAAe,QACf,iBAAiB,EAAE,SAAS,CAAC,OAAO,IAAI,SAAS,YAEjD,uBAAC,sBAAM,IACL,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAC,OAAO,EACZ,SAAS,EAAC,YAAY,EACtB,KAAK,EAAE,YAAY,EACnB,SAAS,EAAC,+BAA+B,EACzC,OAAO,EAAE,kBAAkB,EAC3B,GAAG,EAAE,SAAS,YAEd,gCAAK,SAAS,EAAC,oBAAoB,YACjC,gCAAK,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,WAAW,EAAE,OAAO,EAAC,WAAW,YAChF,iCAAM,CAAC,EAAC,iVAAiV,GAAG,GACxV,GACF,GACC,GACD,GACT,CACJ,CAAC;AACJ,CAAC;AA5DD,0DA4DC","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 \"./TransparencyPopupButton.scss\";\nimport * as React from \"react\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { Button, Popover, Slider } from \"@itwin/itwinui-react\";\n\n/** @alpha */\nexport interface TransparencyPopupButtonProps {\n /** initialValue range 0-1 */\n transparency: number;\n /** function called when value changes. Returned value range 0-1 */\n onTransparencyChange: (value: number) => void;\n /** optional tooltip */\n buttonToolTip?: string;\n disabled?: boolean;\n}\n\n/** @alpha */\nexport function TransparencyPopupButton({ transparency, onTransparencyChange, buttonToolTip, disabled }: TransparencyPopupButtonProps) {\n const [isSettingsOpen, setIsSettingsOpen] = React.useState(false);\n const [defaultTransparencyLabel] = React.useState(IModelApp.localization.getLocalizedString(\"mapLayers:TransparencyPopup.SetTransparency\"));\n const toolTipLabel = React.useMemo(() => (buttonToolTip ? buttonToolTip : defaultTransparencyLabel), [buttonToolTip, defaultTransparencyLabel]);\n\n const buttonRef = React.useRef<HTMLButtonElement>(null);\n const togglePopupDisplay = React.useCallback(() => {\n setIsSettingsOpen(!isSettingsOpen);\n },\n [isSettingsOpen],\n );\n\n const handleTransparencyChange = React.useCallback(\n (values: readonly number[]) => {\n if (values.length) {\n const newTransparency = values[0];\n if (newTransparency !== transparency) {\n if (onTransparencyChange) {\n onTransparencyChange(newTransparency / 100);\n }\n }\n }\n },\n [onTransparencyChange, transparency],\n );\n\n return (\n <>\n <Popover\n content={\n <div className=\"map-transparency-popup-panel\">\n <div className=\"map-transparency-slider-container\">\n <Slider min={0} max={100} values={[transparency * 100]} step={1} onChange={handleTransparencyChange} />\n </div>\n </div>\n }\n visible={isSettingsOpen}\n onVisibleChange={setIsSettingsOpen}\n placement=\"bottom-end\"\n applyBackground\n positionReference={buttonRef.current ?? undefined}\n >\n <Button\n disabled={disabled}\n size=\"small\"\n styleType=\"borderless\"\n title={toolTipLabel}\n className=\"map-transparency-popup-button\"\n onClick={togglePopupDisplay}\n ref={buttonRef}\n >\n <div className=\"transparent-button\">\n <svg className={disabled ? \"checkered-disabled\" : \"checkered\"} viewBox=\"0 0 24 24\">\n <path d=\"m21.00427 0h-18.00854a2.9957 2.9957 0 0 0 -2.99573 2.99567v18.0086a2.99575 2.99575 0 0 0 2.99573 2.99573h18.00854a2.99575 2.99575 0 0 0 2.99573-2.99573v-18.0086a2.9957 2.9957 0 0 0 -2.99573-2.99567zm-20.00427 21.00427v-9.00427h11v-11h9.00427a1.998 1.998 0 0 1 1.99573 1.99567v9.00433h-11v11h-9.00427a1.998 1.998 0 0 1 -1.99573-1.99573z\" />\n </svg>\n </div>\n </Button>\n </Popover>\n </>\n );\n}\n"]}
1
+ {"version":3,"file":"TransparencyPopupButton.js","sourceRoot":"","sources":["../../../../src/ui/widget/TransparencyPopupButton.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,0DA4DC;;AAlFD;;;gGAGgG;AAEhG,0CAAwC;AACxC,6CAA+B;AAC/B,wDAAiD;AACjD,w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,SAAS,EAAC,mCAAmC,YAChD,uBAAC,sBAAM,IAAC,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,YAAY,GAAG,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,wBAAwB,GAAI,GACnG,GACF,EAER,OAAO,EAAE,cAAc,EACvB,eAAe,EAAE,iBAAiB,EAClC,SAAS,EAAC,YAAY,EACtB,eAAe,QACf,iBAAiB,EAAE,SAAS,CAAC,OAAO,IAAI,SAAS,YAEjD,uBAAC,sBAAM,IACL,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAC,OAAO,EACZ,SAAS,EAAC,YAAY,EACtB,KAAK,EAAE,YAAY,EACnB,SAAS,EAAC,+BAA+B,EACzC,OAAO,EAAE,kBAAkB,EAC3B,GAAG,EAAE,SAAS,YAEd,gCAAK,SAAS,EAAC,oBAAoB,YACjC,gCAAK,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,WAAW,EAAE,OAAO,EAAC,WAAW,YAChF,iCAAM,CAAC,EAAC,iVAAiV,GAAG,GACxV,GACF,GACC,GACD,GACT,CACJ,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport \"./TransparencyPopupButton.scss\";\nimport * as React from \"react\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { Button, Popover, Slider } from \"@itwin/itwinui-react\";\n\n/** @alpha */\nexport interface TransparencyPopupButtonProps {\n /** initialValue range 0-1 */\n transparency: number;\n /** function called when value changes. Returned value range 0-1 */\n onTransparencyChange: (value: number) => void;\n /** optional tooltip */\n buttonToolTip?: string;\n disabled?: boolean;\n}\n\n/** @alpha */\nexport function TransparencyPopupButton({ transparency, onTransparencyChange, buttonToolTip, disabled }: TransparencyPopupButtonProps) {\n const [isSettingsOpen, setIsSettingsOpen] = React.useState(false);\n const [defaultTransparencyLabel] = React.useState(IModelApp.localization.getLocalizedString(\"mapLayers:TransparencyPopup.SetTransparency\"));\n const toolTipLabel = React.useMemo(() => (buttonToolTip ? buttonToolTip : defaultTransparencyLabel), [buttonToolTip, defaultTransparencyLabel]);\n\n const buttonRef = React.useRef<HTMLButtonElement>(null);\n const togglePopupDisplay = React.useCallback(() => {\n setIsSettingsOpen(!isSettingsOpen);\n },\n [isSettingsOpen],\n );\n\n const handleTransparencyChange = React.useCallback(\n (values: readonly number[]) => {\n if (values.length) {\n const newTransparency = values[0];\n if (newTransparency !== transparency) {\n if (onTransparencyChange) {\n onTransparencyChange(newTransparency / 100);\n }\n }\n }\n },\n [onTransparencyChange, transparency],\n );\n\n return (\n <>\n <Popover\n content={\n <div className=\"map-transparency-popup-panel\">\n <div className=\"map-transparency-slider-container\">\n <Slider min={0} max={100} values={[transparency * 100]} step={1} onChange={handleTransparencyChange} />\n </div>\n </div>\n }\n visible={isSettingsOpen}\n onVisibleChange={setIsSettingsOpen}\n placement=\"bottom-end\"\n applyBackground\n positionReference={buttonRef.current ?? undefined}\n >\n <Button\n disabled={disabled}\n size=\"small\"\n styleType=\"borderless\"\n title={toolTipLabel}\n className=\"map-transparency-popup-button\"\n onClick={togglePopupDisplay}\n ref={buttonRef}\n >\n <div className=\"transparent-button\">\n <svg className={disabled ? \"checkered-disabled\" : \"checkered\"} viewBox=\"0 0 24 24\">\n <path d=\"m21.00427 0h-18.00854a2.9957 2.9957 0 0 0 -2.99573 2.99567v18.0086a2.99575 2.99575 0 0 0 2.99573 2.99573h18.00854a2.99575 2.99575 0 0 0 2.99573-2.99573v-18.0086a2.9957 2.9957 0 0 0 -2.99573-2.99567zm-20.00427 21.00427v-9.00427h11v-11h9.00427a1.998 1.998 0 0 1 1.99573 1.99567v9.00433h-11v11h-9.00427a1.998 1.998 0 0 1 -1.99573-1.99573z\" />\n </svg>\n </div>\n </Button>\n </Popover>\n </>\n );\n}\n"]}
@@ -1,11 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UserPreferencesStorageOptions = void 0;
3
+ exports.UserPreferencesStorageOptions = UserPreferencesStorageOptions;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const itwinui_react_1 = require("@itwin/itwinui-react");
6
6
  const mapLayers_1 = require("../../mapLayers");
7
7
  function UserPreferencesStorageOptions(props) {
8
8
  return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(itwinui_react_1.Radio, { disabled: props.disabled, name: "settingsStorage", value: "iTwin", label: mapLayers_1.MapLayersUI.translate("CustomAttach.StoreOnITwinSettings"), checked: props.itwinChecked, onChange: props.onChange }), (0, jsx_runtime_1.jsx)(itwinui_react_1.Radio, { disabled: props.disabled, name: "settingsStorage", value: "Model", label: mapLayers_1.MapLayersUI.translate("CustomAttach.StoreOnModelSettings"), checked: props.modelChecked, onChange: props.onChange })] }));
9
9
  }
10
- exports.UserPreferencesStorageOptions = UserPreferencesStorageOptions;
11
10
  //# sourceMappingURL=UserPreferencesStorageOptions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"UserPreferencesStorageOptions.js","sourceRoot":"","sources":["../../../../src/ui/widget/UserPreferencesStorageOptions.tsx"],"names":[],"mappings":";;;;AAMA,wDAA6C;AAC7C,+CAA8C;AAS9C,SAAgB,6BAA6B,CAAC,KAAyC;IACrF,OAAO,CACL,4CACE,uBAAC,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,EACF,uBAAC,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,IACE,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 type * 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"]}
1
+ {"version":3,"file":"UserPreferencesStorageOptions.js","sourceRoot":"","sources":["../../../../src/ui/widget/UserPreferencesStorageOptions.tsx"],"names":[],"mappings":";;AAgBA,sEAqBC;;AA/BD,wDAA6C;AAC7C,+CAA8C;AAS9C,SAAgB,6BAA6B,CAAC,KAAyC;IACrF,OAAO,CACL,4CACE,uBAAC,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,EACF,uBAAC,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,IACE,CACP,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\nimport type * 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"]}
@@ -3,6 +3,8 @@
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
  export class BrowserStorage {
6
+ _itemKeyName;
7
+ _throwOnDeleteMissingKey;
6
8
  constructor(opts) {
7
9
  this._itemKeyName = opts.itemKeyName;
8
10
  this._throwOnDeleteMissingKey = opts.throwOnDeleteMissingKey ?? true;
@@ -1 +1 @@
1
- {"version":3,"file":"BrowserStorage.js","sourceRoot":"","sources":["../../src/BrowserStorage.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAgBhG,MAAM,OAAO,cAAc;IAIzB,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;QACpC,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACnD,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;YACrB,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,IAAI,CAAC,OAAO,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;YACjC,OAAO,GAAG,CAAC;QACb,CAAC;QAED,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC1B,OAAO,GAAG,CAAC;IACb,CAAC;IAEM,GAAG,CAAC,GAAuB;QAChC,MAAM,GAAG,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;QACnC,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACtB,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,IAAI,GAAG,EAAE,CAAC;YACR,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;gBACpC,OAAO,SAAS,CAAC;YACnB,CAAC;YAED,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC;QAClB,CAAC;aAAM,CAAC;YACN,sCAAsC;YACtC,OAAO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IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,WAAW,EAAE,CAAC;gBAC1C,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC;YAClB,CAAC;QACH,CAAC;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,EAAE,CAAC;YACtB,GAAG,GAAG,EAAE,CAAC;QACX,CAAC;QAED,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 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\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\n if (key) {\n if (!Object.keys(map).includes(key)) {\n return undefined;\n }\n\n return map[key];\n } else {\n // 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\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 }\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\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\n map[key] = content;\n\n const itemValue = JSON.stringify(map);\n window.localStorage.setItem(this._itemKeyName, itemValue);\n }\n}\n"]}
1
+ {"version":3,"file":"BrowserStorage.js","sourceRoot":"","sources":["../../src/BrowserStorage.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAgBhG,MAAM,OAAO,cAAc;IACR,YAAY,CAAC;IACb,wBAAwB,CAAC;IAE1C,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,MAA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,CAAC;QAED,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 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\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\n if (key) {\n if (!Object.keys(map).includes(key)) {\n return undefined;\n }\n\n return map[key];\n } else {\n // 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\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 }\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\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\n map[key] = content;\n\n const itemValue = JSON.stringify(map);\n window.localStorage.setItem(this._itemKeyName, itemValue);\n }\n}\n"]}
@@ -19,6 +19,14 @@ export var MapLayerSourceChangeType;
19
19
  * @internal
20
20
  */
21
21
  export class MapLayerPreferences {
22
+ /** Event raised whenever a source is added, replaced or removed:
23
+ * changeType : Type of changed occurred.
24
+ * oldSource : Source that was removed or replaced.
25
+ * newSource : Source that was added or replacement of oldSource.
26
+ *
27
+ * @see [[MapLayerSourceChangeType]]
28
+ */
29
+ static onLayerSourceChanged = new BeEvent(); // Used to notify the frontend that it needs to update its list of available layers
22
30
  /** Store the Map Layer source preference. If the same setting exists at a higher level, an error will be thrown and the setting will not be updated.
23
31
  *
24
32
  * Returns false if the settings object would override some other settings object in a larger scope i.e. storing settings on model when
@@ -324,12 +332,4 @@ export class MapLayerPreferences {
324
332
  return "MapLayerSource-SettingsService";
325
333
  }
326
334
  }
327
- /** Event raised whenever a source is added, replaced or removed:
328
- * changeType : Type of changed occurred.
329
- * oldSource : Source that was removed or replaced.
330
- * newSource : Source that was added or replacement of oldSource.
331
- *
332
- * @see [[MapLayerSourceChangeType]]
333
- */
334
- MapLayerPreferences.onLayerSourceChanged = new BeEvent(); // Used to notify the frontend that it needs to update its list of available layers
335
335
  //# sourceMappingURL=MapLayerPreferences.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MapLayerPre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,KAAK,CAAC,SAAS,CAAC,YAAY,CAAC,kBAAkB,CAAC,iDAAiD,EAAE,EAAE,YAAY,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;QACvI,CAAC;QAED,MAAM,oBAAoB,GAAqB,EAAE,CAAC;QAClD,KAAK,MAAM,QAAQ,IAAI,YAAY,EAAE,CAAC;YACpC,QAAQ,CAAC,OAAO,CAAC,CAAC,UAAe,EAAE,EAAE;gBACnC,MAAM,cAAc,GAAG,cAAc,CAAC,QAAQ,CAAC,UAAwC,CAAC,CAAC;gBACzF,IAAI,cAAc,EAAE,CAAC;oBACnB,oBAAoB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;gBAC5C,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;QACD,OAAO,oBAAoB,CAAC;IAC9B,CAAC;IAEO,MAAM,KAAK,oBAAoB;QACrC,OAAO,gCAAgC,CAAC;IAC1C,CAAC;;AA7UD;;;;;;GAMG;AACoB,wCAAoB,GAAG,IAAI,OAAO,EAEtD,CAAC,CAAC,mFAAmF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { BeEvent } from \"@itwin/core-bentley\";\nimport { IModelApp, MapLayerSource, NotifyMessageDetails, OutputMessagePriority } from \"@itwin/core-frontend\";\nimport { MapLayersUI } from \"./mapLayers\";\n\nimport type { GuidString } from \"@itwin/core-bentley\";\n/** @internal */\nexport interface MapLayerPreferencesContent {\n url: string;\n name: string;\n formatId: string;\n transparentBackground: boolean | undefined;\n}\n\n/** @internal */\nexport enum MapLayerSourceChangeType {\n Added = 0,\n Removed = 1,\n Replaced = 2,\n}\n\n/** @internal */\nexport interface MapLayerSourceArg {\n readonly source: MapLayerSource;\n readonly iTwinId: GuidString;\n readonly iModelId: GuidString;\n}\n\n/** A wrapper around user preferences to provide a way to store [[MapLayerSettings]].\n *\n * Note: This is currently internal only and used directly by the MapLayersExtension. It makes use of the IModelApp.authorizationClient if it exists.\n *\n * @internal\n */\nexport class MapLayerPreferences {\n /** Event raised whenever a source is added, replaced or removed:\n * changeType : Type of changed occurred.\n * oldSource : Source that was removed or replaced.\n * newSource : Source that was added or replacement of oldSource.\n *\n * @see [[MapLayerSourceChangeType]]\n */\n public static readonly onLayerSourceChanged = new BeEvent<\n (changeType: MapLayerSourceChangeType, oldSource?: MapLayerSource, newSource?: MapLayerSource) => void\n >(); // Used to notify the frontend that it needs to update its list of available layers\n\n /** Store the Map Layer source preference. If the same setting exists at a higher level, an error will be thrown and the setting will not be updated.\n *\n * Returns false if the settings object would override some other settings object in a larger scope i.e. storing settings on model when\n * a project setting exists with same name or map layer url.\n * @param source source to be stored on the setting service\n * @param storeOnIModel if true store the settings object on the model, if false store it on the project\n */\n public static async storeSource(source: MapLayerSource, iTwinId: GuidString, iModelId?: GuidString, storeOnIModel?: boolean): Promise<boolean> {\n if (!MapLayersUI.iTwinConfig) {\n return false;\n }\n const accessToken = undefined !== IModelApp.authorizationClient ? await IModelApp.authorizationClient.getAccessToken() : undefined;\n\n const sourceJSON = source.toJSON();\n if (!sourceJSON.formatId) {\n return false;\n }\n const mapLayerSetting: MapLayerPreferencesContent = {\n url: sourceJSON.url,\n name: sourceJSON.name,\n formatId: sourceJSON.formatId,\n transparentBackground: sourceJSON.transparentBackground,\n };\n\n const result: boolean = await MapLayerPreferences.delete(sourceJSON.url, sourceJSON.name, iTwinId, iModelId, storeOnIModel);\n if (result) {\n await MapLayersUI.iTwinConfig.save({\n accessToken,\n content: mapLayerSetting,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: sourceJSON.name,\n iTwinId,\n iModelId: storeOnIModel ? iModelId : undefined,\n });\n MapLayerPreferences.onLayerSourceChanged.raiseEvent(MapLayerSourceChangeType.Added, undefined, MapLayerSource.fromJSON(mapLayerSetting));\n return true;\n } else {\n return false;\n }\n }\n\n /** Replace the old map layer source with a new map layer source.\n *\n * The source is replaced at the same level that the original source is defined. (i.e. if the old source is defined at a project level, the new source will also be defined there.)\n *\n * @param oldSource\n * @param newSource\n * @param iTwinId\n * @param iModelId\n */\n public static async replaceSource(oldSource: MapLayerSource, newSource: MapLayerSource, iTwinId: GuidString, iModelId?: GuidString): Promise<void> {\n if (!MapLayersUI.iTwinConfig) {\n return;\n }\n const accessToken = undefined !== IModelApp.authorizationClient ? await IModelApp.authorizationClient.getAccessToken() : undefined;\n\n let storeOnIModel = false;\n try {\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: oldSource.name,\n iTwinId,\n iModelId,\n });\n } catch {\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: oldSource.name,\n iTwinId,\n });\n storeOnIModel = true;\n }\n\n const mapLayerSetting: MapLayerPreferencesContent = {\n url: newSource.url,\n name: newSource.name,\n formatId: newSource.formatId,\n transparentBackground: newSource.transparentBackground,\n };\n\n await MapLayersUI.iTwinConfig.save({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: newSource.name,\n iTwinId,\n iModelId: storeOnIModel ? iModelId : undefined,\n content: mapLayerSetting,\n });\n\n MapLayerPreferences.onLayerSourceChanged.raiseEvent(MapLayerSourceChangeType.Replaced, oldSource, newSource);\n }\n\n /** Deletes the provided MapLayerSource by name from both the iTwin or iModel level.\n *\n * @param source The source to delete. The name is used to identify the source.\n * @param iTwinId\n * @param iModelId\n */\n public static async deleteByName(source: MapLayerSource, iTwinId: GuidString, iModelId?: GuidString): Promise<void> {\n if (!MapLayersUI.iTwinConfig) {\n return;\n }\n const accessToken = undefined !== IModelApp.authorizationClient ? await IModelApp.authorizationClient.getAccessToken() : undefined;\n\n try {\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: source.name,\n iTwinId,\n iModelId,\n });\n } catch {\n // failed to store based on iModelId, attempt using iTwinId\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: source.name,\n iTwinId,\n });\n }\n\n MapLayerPreferences.onLayerSourceChanged.raiseEvent(MapLayerSourceChangeType.Removed, source, undefined);\n }\n\n /** Deletes the current setting with the provided key if it is defined at the same preference level.\n *\n * If the preference is defined within a different level, false will be returned indicating the setting should not be overriden.\n *\n * The two potential preference levels are iTwin and iModel.\n *\n * @param url\n * @param name\n * @param iTwinId\n * @param iModelId\n * @param storeOnIModel\n */\n private static async delete(url: string, name: string, iTwinId: GuidString, iModelId?: GuidString, storeOnIModel?: boolean): Promise<boolean> {\n if (!MapLayersUI.iTwinConfig) {\n return true;\n }\n const accessToken = undefined !== IModelApp.authorizationClient ? await IModelApp.authorizationClient.getAccessToken() : undefined;\n\n const iTwinPreferenceByName = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: name,\n iTwinId,\n });\n\n if (undefined !== iTwinPreferenceByName && storeOnIModel) {\n const errorMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerExistsAsProjectSetting\", {\n layer: iTwinPreferenceByName.name,\n });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Error, errorMessage));\n return false;\n } else if (iTwinPreferenceByName) {\n const infoMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerExistsOverwriting\", { layer: iTwinPreferenceByName.name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, infoMessage));\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: iTwinPreferenceByName.name,\n iTwinId,\n });\n }\n\n // check if setting with url already exists, if it does, delete it\n const settingFromUrl = await MapLayerPreferences.getByUrl(url, iTwinId, undefined);\n if (settingFromUrl && storeOnIModel) {\n const errorMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerWithUrlExistsAsProjectSetting\", {\n url: settingFromUrl.url,\n name: settingFromUrl.name,\n });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Error, errorMessage));\n return false;\n } else if (settingFromUrl) {\n const infoMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerWithUrlExistsOverwriting\", {\n url: settingFromUrl.url,\n oldName: settingFromUrl.name,\n newName: name,\n });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, infoMessage));\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: settingFromUrl.name,\n iTwinId,\n });\n }\n\n if (iModelId) {\n // delete any settings on model so user can update them if theres collisions\n const settingOnIModelFromName = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: name,\n iTwinId,\n iModelId,\n });\n const settingFromUrlOnIModel = await MapLayerPreferences.getByUrl(url, iTwinId, iModelId);\n if (settingOnIModelFromName) {\n const infoMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerExistsOverwriting\", { layer: settingOnIModelFromName.name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, infoMessage));\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: settingOnIModelFromName.name,\n iTwinId,\n iModelId,\n });\n }\n if (settingFromUrlOnIModel) {\n const infoMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerWithUrlExistsOverwriting\", {\n url: settingFromUrlOnIModel.url,\n oldName: settingFromUrlOnIModel.name,\n newName: name,\n });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, infoMessage));\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: settingFromUrlOnIModel.name,\n iTwinId,\n iModelId,\n });\n }\n }\n return true;\n }\n\n /** Attempts to get a map layer based off a specific url.\n * @param url\n * @param iTwinId\n * @param iModelId\n */\n public static async getByUrl(url: string, iTwinId: string, iModelId?: string): Promise<MapLayerPreferencesContent | undefined> {\n if (!MapLayersUI.iTwinConfig) {\n return undefined;\n }\n\n const accessToken = undefined !== IModelApp.authorizationClient ? await IModelApp.authorizationClient.getAccessToken() : undefined;\n\n const settingResponse = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: \"\",\n iTwinId,\n iModelId,\n });\n\n if (undefined === settingResponse || 0 === settingResponse.length) {\n return undefined;\n }\n\n let savedMapLayer;\n settingResponse.settingsMap?.forEach((savedLayer: any) => {\n if (savedLayer.url === url) {\n savedMapLayer = savedLayer;\n }\n });\n return savedMapLayer;\n }\n\n /** Get all MapLayerSources from the user's preferences, iTwin setting and iModel settings.\n * @param iTwinId id of the iTwin\n * @param iModelId id of the iModel\n * @throws if any of the calls to grab settings fail.\n */\n public static async getSources(iTwinId: GuidString, iModelId?: GuidString): Promise<MapLayerSource[]> {\n if (!MapLayersUI.iTwinConfig) {\n return [];\n }\n const accessToken = undefined !== IModelApp.authorizationClient ? await IModelApp.authorizationClient.getAccessToken() : undefined;\n\n const mapLayerList = [];\n\n try {\n const userResultByProject = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: \"\",\n iTwinId,\n });\n if (undefined !== userResultByProject) {\n mapLayerList.push(userResultByProject);\n }\n } catch (err: any) {\n throw new Error(IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.ErrorRetrieveUserProject\", { errorMessage: err }));\n }\n\n try {\n const userResultByIModel = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: \"\",\n iTwinId,\n iModelId,\n });\n if (undefined !== userResultByIModel) {\n mapLayerList.push(userResultByIModel);\n }\n } catch (err: any) {\n throw new Error(IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.ErrorRetrieveUserProject\", { errorMessage: err }));\n }\n\n const savedMapLayerSources: MapLayerSource[] = [];\n for (const mapLayer of mapLayerList) {\n mapLayer.forEach((savedLayer: any) => {\n const mapLayerSource = MapLayerSource.fromJSON(savedLayer as MapLayerPreferencesContent);\n if (mapLayerSource) {\n savedMapLayerSources.push(mapLayerSource);\n }\n });\n }\n return savedMapLayerSources;\n }\n\n private static get _preferenceNamespace() {\n return \"MapLayerSource-SettingsService\";\n }\n}\n"]}
1
+ {"version":3,"file":"MapLayerPreferences.js","sourceRoot":"","sources":["../../src/MapLayerPreferences.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC9G,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAW1C,gBAAgB;AAChB,MAAM,CAAN,IAAY,wBAIX;AAJD,WAAY,wBAAwB;IAClC,yEAAS,CAAA;IACT,6EAAW,CAAA;IACX,+EAAY,CAAA;AACd,CAAC,EAJW,wBAAwB,KAAxB,wBAAwB,QAInC;AASD;;;;;GAKG;AACH,MAAM,OAAO,mBAAmB;IAC9B;;;;;;OAMG;IACI,MAAM,CAAU,oBAAoB,GAAG,IAAI,OAAO,EAEtD,CAAC,CAAC,mFAAmF;IAExF;;;;;;OAMG;IACI,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,MAAsB,EAAE,OAAmB,EAAE,QAAqB,EAAE,aAAuB;QACzH,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC;YAC7B,OAAO,KAAK,CAAC;QACf,CAAC;QACD,MAAM,WAAW,GAAG,SAAS,KAAK,SAAS,CAAC,mBAAmB,CAAC,CAAC,CAAC,MAAM,SAAS,CAAC,mBAAmB,CAAC,cAAc,EAAE,CAAC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,EAAE,EAAE,YAAY,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;QACvI,CAAC;QAED,IAAI,CAAC;YACH,MAAM,kBAAkB,GAAG,MAAM,WAAW,CAAC,WAAW,CAAC,GAAG,CAAC;gBAC3D,WAAW;gBACX,SAAS,EAAE,mBAAmB,CAAC,oBAAoB;gBACnD,GAAG,EAAE,EAAE;gBACP,OAAO;gBACP,QAAQ;aACT,CAAC,CAAC;YACH,IAAI,SAAS,KAAK,kBAAkB,EAAE,CAAC;gBACrC,YAAY,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;YACxC,CAAC;QACH,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CAAC,SAAS,CAAC,YAAY,CAAC,kBAAkB,CAAC,iDAAiD,EAAE,EAAE,YAAY,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;QACvI,CAAC;QAED,MAAM,oBAAoB,GAAqB,EAAE,CAAC;QAClD,KAAK,MAAM,QAAQ,IAAI,YAAY,EAAE,CAAC;YACpC,QAAQ,CAAC,OAAO,CAAC,CAAC,UAAe,EAAE,EAAE;gBACnC,MAAM,cAAc,GAAG,cAAc,CAAC,QAAQ,CAAC,UAAwC,CAAC,CAAC;gBACzF,IAAI,cAAc,EAAE,CAAC;oBACnB,oBAAoB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;gBAC5C,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;QACD,OAAO,oBAAoB,CAAC;IAC9B,CAAC;IAEO,MAAM,KAAK,oBAAoB;QACrC,OAAO,gCAAgC,CAAC;IAC1C,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\nimport { BeEvent } from \"@itwin/core-bentley\";\nimport { IModelApp, MapLayerSource, NotifyMessageDetails, OutputMessagePriority } from \"@itwin/core-frontend\";\nimport { MapLayersUI } from \"./mapLayers\";\n\nimport type { GuidString } from \"@itwin/core-bentley\";\n/** @internal */\nexport interface MapLayerPreferencesContent {\n url: string;\n name: string;\n formatId: string;\n transparentBackground: boolean | undefined;\n}\n\n/** @internal */\nexport enum MapLayerSourceChangeType {\n Added = 0,\n Removed = 1,\n Replaced = 2,\n}\n\n/** @internal */\nexport interface MapLayerSourceArg {\n readonly source: MapLayerSource;\n readonly iTwinId: GuidString;\n readonly iModelId: GuidString;\n}\n\n/** A wrapper around user preferences to provide a way to store [[MapLayerSettings]].\n *\n * Note: This is currently internal only and used directly by the MapLayersExtension. It makes use of the IModelApp.authorizationClient if it exists.\n *\n * @internal\n */\nexport class MapLayerPreferences {\n /** Event raised whenever a source is added, replaced or removed:\n * changeType : Type of changed occurred.\n * oldSource : Source that was removed or replaced.\n * newSource : Source that was added or replacement of oldSource.\n *\n * @see [[MapLayerSourceChangeType]]\n */\n public static readonly onLayerSourceChanged = new BeEvent<\n (changeType: MapLayerSourceChangeType, oldSource?: MapLayerSource, newSource?: MapLayerSource) => void\n >(); // Used to notify the frontend that it needs to update its list of available layers\n\n /** Store the Map Layer source preference. If the same setting exists at a higher level, an error will be thrown and the setting will not be updated.\n *\n * Returns false if the settings object would override some other settings object in a larger scope i.e. storing settings on model when\n * a project setting exists with same name or map layer url.\n * @param source source to be stored on the setting service\n * @param storeOnIModel if true store the settings object on the model, if false store it on the project\n */\n public static async storeSource(source: MapLayerSource, iTwinId: GuidString, iModelId?: GuidString, storeOnIModel?: boolean): Promise<boolean> {\n if (!MapLayersUI.iTwinConfig) {\n return false;\n }\n const accessToken = undefined !== IModelApp.authorizationClient ? await IModelApp.authorizationClient.getAccessToken() : undefined;\n\n const sourceJSON = source.toJSON();\n if (!sourceJSON.formatId) {\n return false;\n }\n const mapLayerSetting: MapLayerPreferencesContent = {\n url: sourceJSON.url,\n name: sourceJSON.name,\n formatId: sourceJSON.formatId,\n transparentBackground: sourceJSON.transparentBackground,\n };\n\n const result: boolean = await MapLayerPreferences.delete(sourceJSON.url, sourceJSON.name, iTwinId, iModelId, storeOnIModel);\n if (result) {\n await MapLayersUI.iTwinConfig.save({\n accessToken,\n content: mapLayerSetting,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: sourceJSON.name,\n iTwinId,\n iModelId: storeOnIModel ? iModelId : undefined,\n });\n MapLayerPreferences.onLayerSourceChanged.raiseEvent(MapLayerSourceChangeType.Added, undefined, MapLayerSource.fromJSON(mapLayerSetting));\n return true;\n } else {\n return false;\n }\n }\n\n /** Replace the old map layer source with a new map layer source.\n *\n * The source is replaced at the same level that the original source is defined. (i.e. if the old source is defined at a project level, the new source will also be defined there.)\n *\n * @param oldSource\n * @param newSource\n * @param iTwinId\n * @param iModelId\n */\n public static async replaceSource(oldSource: MapLayerSource, newSource: MapLayerSource, iTwinId: GuidString, iModelId?: GuidString): Promise<void> {\n if (!MapLayersUI.iTwinConfig) {\n return;\n }\n const accessToken = undefined !== IModelApp.authorizationClient ? await IModelApp.authorizationClient.getAccessToken() : undefined;\n\n let storeOnIModel = false;\n try {\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: oldSource.name,\n iTwinId,\n iModelId,\n });\n } catch {\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: oldSource.name,\n iTwinId,\n });\n storeOnIModel = true;\n }\n\n const mapLayerSetting: MapLayerPreferencesContent = {\n url: newSource.url,\n name: newSource.name,\n formatId: newSource.formatId,\n transparentBackground: newSource.transparentBackground,\n };\n\n await MapLayersUI.iTwinConfig.save({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: newSource.name,\n iTwinId,\n iModelId: storeOnIModel ? iModelId : undefined,\n content: mapLayerSetting,\n });\n\n MapLayerPreferences.onLayerSourceChanged.raiseEvent(MapLayerSourceChangeType.Replaced, oldSource, newSource);\n }\n\n /** Deletes the provided MapLayerSource by name from both the iTwin or iModel level.\n *\n * @param source The source to delete. The name is used to identify the source.\n * @param iTwinId\n * @param iModelId\n */\n public static async deleteByName(source: MapLayerSource, iTwinId: GuidString, iModelId?: GuidString): Promise<void> {\n if (!MapLayersUI.iTwinConfig) {\n return;\n }\n const accessToken = undefined !== IModelApp.authorizationClient ? await IModelApp.authorizationClient.getAccessToken() : undefined;\n\n try {\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: source.name,\n iTwinId,\n iModelId,\n });\n } catch {\n // failed to store based on iModelId, attempt using iTwinId\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: source.name,\n iTwinId,\n });\n }\n\n MapLayerPreferences.onLayerSourceChanged.raiseEvent(MapLayerSourceChangeType.Removed, source, undefined);\n }\n\n /** Deletes the current setting with the provided key if it is defined at the same preference level.\n *\n * If the preference is defined within a different level, false will be returned indicating the setting should not be overriden.\n *\n * The two potential preference levels are iTwin and iModel.\n *\n * @param url\n * @param name\n * @param iTwinId\n * @param iModelId\n * @param storeOnIModel\n */\n private static async delete(url: string, name: string, iTwinId: GuidString, iModelId?: GuidString, storeOnIModel?: boolean): Promise<boolean> {\n if (!MapLayersUI.iTwinConfig) {\n return true;\n }\n const accessToken = undefined !== IModelApp.authorizationClient ? await IModelApp.authorizationClient.getAccessToken() : undefined;\n\n const iTwinPreferenceByName = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: name,\n iTwinId,\n });\n\n if (undefined !== iTwinPreferenceByName && storeOnIModel) {\n const errorMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerExistsAsProjectSetting\", {\n layer: iTwinPreferenceByName.name,\n });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Error, errorMessage));\n return false;\n } else if (iTwinPreferenceByName) {\n const infoMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerExistsOverwriting\", { layer: iTwinPreferenceByName.name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, infoMessage));\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: iTwinPreferenceByName.name,\n iTwinId,\n });\n }\n\n // check if setting with url already exists, if it does, delete it\n const settingFromUrl = await MapLayerPreferences.getByUrl(url, iTwinId, undefined);\n if (settingFromUrl && storeOnIModel) {\n const errorMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerWithUrlExistsAsProjectSetting\", {\n url: settingFromUrl.url,\n name: settingFromUrl.name,\n });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Error, errorMessage));\n return false;\n } else if (settingFromUrl) {\n const infoMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerWithUrlExistsOverwriting\", {\n url: settingFromUrl.url,\n oldName: settingFromUrl.name,\n newName: name,\n });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, infoMessage));\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: settingFromUrl.name,\n iTwinId,\n });\n }\n\n if (iModelId) {\n // delete any settings on model so user can update them if theres collisions\n const settingOnIModelFromName = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: name,\n iTwinId,\n iModelId,\n });\n const settingFromUrlOnIModel = await MapLayerPreferences.getByUrl(url, iTwinId, iModelId);\n if (settingOnIModelFromName) {\n const infoMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerExistsOverwriting\", { layer: settingOnIModelFromName.name });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, infoMessage));\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: settingOnIModelFromName.name,\n iTwinId,\n iModelId,\n });\n }\n if (settingFromUrlOnIModel) {\n const infoMessage = IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.LayerWithUrlExistsOverwriting\", {\n url: settingFromUrlOnIModel.url,\n oldName: settingFromUrlOnIModel.name,\n newName: name,\n });\n IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Info, infoMessage));\n await MapLayersUI.iTwinConfig.delete({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: settingFromUrlOnIModel.name,\n iTwinId,\n iModelId,\n });\n }\n }\n return true;\n }\n\n /** Attempts to get a map layer based off a specific url.\n * @param url\n * @param iTwinId\n * @param iModelId\n */\n public static async getByUrl(url: string, iTwinId: string, iModelId?: string): Promise<MapLayerPreferencesContent | undefined> {\n if (!MapLayersUI.iTwinConfig) {\n return undefined;\n }\n\n const accessToken = undefined !== IModelApp.authorizationClient ? await IModelApp.authorizationClient.getAccessToken() : undefined;\n\n const settingResponse = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: \"\",\n iTwinId,\n iModelId,\n });\n\n if (undefined === settingResponse || 0 === settingResponse.length) {\n return undefined;\n }\n\n let savedMapLayer;\n settingResponse.settingsMap?.forEach((savedLayer: any) => {\n if (savedLayer.url === url) {\n savedMapLayer = savedLayer;\n }\n });\n return savedMapLayer;\n }\n\n /** Get all MapLayerSources from the user's preferences, iTwin setting and iModel settings.\n * @param iTwinId id of the iTwin\n * @param iModelId id of the iModel\n * @throws if any of the calls to grab settings fail.\n */\n public static async getSources(iTwinId: GuidString, iModelId?: GuidString): Promise<MapLayerSource[]> {\n if (!MapLayersUI.iTwinConfig) {\n return [];\n }\n const accessToken = undefined !== IModelApp.authorizationClient ? await IModelApp.authorizationClient.getAccessToken() : undefined;\n\n const mapLayerList = [];\n\n try {\n const userResultByProject = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: \"\",\n iTwinId,\n });\n if (undefined !== userResultByProject) {\n mapLayerList.push(userResultByProject);\n }\n } catch (err: any) {\n throw new Error(IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.ErrorRetrieveUserProject\", { errorMessage: err }));\n }\n\n try {\n const userResultByIModel = await MapLayersUI.iTwinConfig.get({\n accessToken,\n namespace: MapLayerPreferences._preferenceNamespace,\n key: \"\",\n iTwinId,\n iModelId,\n });\n if (undefined !== userResultByIModel) {\n mapLayerList.push(userResultByIModel);\n }\n } catch (err: any) {\n throw new Error(IModelApp.localization.getLocalizedString(\"mapLayers:CustomAttach.ErrorRetrieveUserProject\", { errorMessage: err }));\n }\n\n const savedMapLayerSources: MapLayerSource[] = [];\n for (const mapLayer of mapLayerList) {\n mapLayer.forEach((savedLayer: any) => {\n const mapLayerSource = MapLayerSource.fromJSON(savedLayer as MapLayerPreferencesContent);\n if (mapLayerSource) {\n savedMapLayerSources.push(mapLayerSource);\n }\n });\n }\n return savedMapLayerSources;\n }\n\n private static get _preferenceNamespace() {\n return \"MapLayerSource-SettingsService\";\n }\n}\n"]}
@@ -16,6 +16,8 @@ import { BrowserStorage } from "./BrowserStorage";
16
16
  * @beta
17
17
  */
18
18
  export class PreferencesBrowserStorage {
19
+ _options;
20
+ _storageItemKeyPrefix;
19
21
  constructor(storageItemKeyPrefix, opts) {
20
22
  this._options = opts;
21
23
  this._storageItemKeyPrefix = storageItemKeyPrefix;
@@ -1 +1 @@
1
- {"version":3,"file":"PreferencesBrowserStorage.js","sourceRoot":"","sources":["../../src/PreferencesBrowserStorage.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAkBlD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,yBAAyB;IAIpC,YAAY,oBAA4B,EAAE,IAAuC;QAC/E,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,qBAAqB,GAAG,oBAAoB,CAAC;IAC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M,OAAO,GAAG,IAAI,cAAc,CAAkB,EAAE,WAAW,EAAE,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAClG,OAAO,CAAC,IAAI,CAAC,yBAAyB,CAAC,gBAAgB,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IAC7E,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 type { ITwinIdArg, PreferenceArg, PreferenceKeyArg, UserPreferencesAccess } from \"@itwin/core-frontend\";\nimport { BrowserStorage } from \"./BrowserStorage\";\n\n/** Index signature holding preferences content\n *\n * @internal\n */\ninterface KeyContentProps {\n [preferenceKey: string]: any;\n}\n\n/**\n * @beta\n */\nexport interface PreferencesBrowserStorageOptions {\n /** indicate whether or not delete function should throw an error if the provided key cannot be found. */\n throwOnDeleteMissingKey?: boolean;\n}\n\n/** User preferences implementation using browser's local storage.\n * It creates storage item key in the form of:\n * <storageItemKeyPrefix>.<itwin_guid?>.<imodel_guid?>\n *\n * <itwin_guid> and <imodel_guid> being optional.\n *\n * Each entry in the storage is a serialized JSON of the following index signature:\n * {\n * \"<preference_namespace?>.<preference_key>\": {\n * ...\n * <preferences_json_content>\n * },\n * ...\n * }\n * @beta\n */\nexport class PreferencesBrowserStorage implements UserPreferencesAccess {\n private readonly _options: PreferencesBrowserStorageOptions | undefined;\n private readonly _storageItemKeyPrefix: string;\n\n constructor(storageItemKeyPrefix: string, opts?: PreferencesBrowserStorageOptions) {\n this._options = opts;\n this._storageItemKeyPrefix = storageItemKeyPrefix;\n }\n\n private getStorageItemKey(arg: ITwinIdArg) {\n const itwinIdStr = arg.iTwinId ? `.${arg.iTwinId}` : \"\";\n const imodelIdStr = arg.iModelId ? `.${arg.iModelId}` : \"\";\n return `${this._storageItemKeyPrefix}${itwinIdStr}${imodelIdStr}`;\n }\n\n private static getPreferenceKey(arg: PreferenceKeyArg) {\n if (arg.key) {\n const nsStr = arg.namespace ? `${arg.namespace}.` : \"\";\n return `${nsStr}${arg.key}`;\n }\n\n return \"\";\n }\n\n public async get(arg: PreferenceKeyArg & ITwinIdArg) {\n const storage = new BrowserStorage<KeyContentProps>({ itemKeyName: this.getStorageItemKey(arg) });\n return storage.get(PreferencesBrowserStorage.getPreferenceKey(arg));\n }\n\n public async delete(arg: PreferenceKeyArg & ITwinIdArg) {\n const storage = new BrowserStorage<KeyContentProps>({ itemKeyName: this.getStorageItemKey(arg) });\n storage.delete(PreferencesBrowserStorage.getPreferenceKey(arg));\n }\n\n public async save(arg: PreferenceArg & ITwinIdArg) {\n const storage = new BrowserStorage<KeyContentProps>({ itemKeyName: this.getStorageItemKey(arg) });\n storage.save(PreferencesBrowserStorage.getPreferenceKey(arg), arg.content);\n }\n}\n"]}
1
+ {"version":3,"file":"PreferencesBrowserStorage.js","sourceRoot":"","sources":["../../src/PreferencesBrowserStorage.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAkBlD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,yBAAyB;IACnB,QAAQ,CAA+C;IACvD,qBAAqB,CAAS;IAE/C,YAAY,oBAA4B,EAAE,IAAuC;QAC/E,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,qBAAqB,GAAG,oBAAoB,CAAC;IACpD,CAAC;IAEO,iBAAiB,CAAC,GAAe;QACvC,MAAM,UAAU,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACxD,MAAM,WAAW,GAAG,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3D,OAAO,GAAG,IAAI,CAAC,qBAAqB,GAAG,UAAU,GAAG,WAAW,EAAE,CAAC;IACpE,CAAC;IAEO,MAAM,CAAC,gBAAgB,CAAC,GAAqB;QACnD,IAAI,GAAG,CAAC,GAAG,EAAE,CAAC;YACZ,MAAM,KAAK,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;YACvD,OAAO,GAAG,KAAK,GAAG,GAAG,CAAC,GAAG,EAAE,CAAC;QAC9B,CAAC;QAED,OAAO,EAAE,CAAC;IACZ,CAAC;IAEM,KAAK,CAAC,GAAG,CAAC,GAAkC;QACjD,MAAM,OAAO,GAAG,IAAI,cAAc,CAAkB,EAAE,WAAW,EAAE,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAClG,OAAO,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC;IACtE,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,GAAkC;QACpD,MAAM,OAAO,GAAG,IAAI,cAAc,CAAkB,EAAE,WAAW,EAAE,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAClG,OAAO,CAAC,MAAM,CAAC,yBAAyB,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC;IAClE,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,GAA+B;QAC/C,MAAM,OAAO,GAAG,IAAI,cAAc,CAAkB,EAAE,WAAW,EAAE,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAClG,OAAO,CAAC,IAAI,CAAC,yBAAyB,CAAC,gBAAgB,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IAC7E,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 type { ITwinIdArg, PreferenceArg, PreferenceKeyArg, UserPreferencesAccess } from \"@itwin/core-frontend\";\nimport { BrowserStorage } from \"./BrowserStorage\";\n\n/** Index signature holding preferences content\n *\n * @internal\n */\ninterface KeyContentProps {\n [preferenceKey: string]: any;\n}\n\n/**\n * @beta\n */\nexport interface PreferencesBrowserStorageOptions {\n /** indicate whether or not delete function should throw an error if the provided key cannot be found. */\n throwOnDeleteMissingKey?: boolean;\n}\n\n/** User preferences implementation using browser's local storage.\n * It creates storage item key in the form of:\n * <storageItemKeyPrefix>.<itwin_guid?>.<imodel_guid?>\n *\n * <itwin_guid> and <imodel_guid> being optional.\n *\n * Each entry in the storage is a serialized JSON of the following index signature:\n * {\n * \"<preference_namespace?>.<preference_key>\": {\n * ...\n * <preferences_json_content>\n * },\n * ...\n * }\n * @beta\n */\nexport class PreferencesBrowserStorage implements UserPreferencesAccess {\n private readonly _options: PreferencesBrowserStorageOptions | undefined;\n private readonly _storageItemKeyPrefix: string;\n\n constructor(storageItemKeyPrefix: string, opts?: PreferencesBrowserStorageOptions) {\n this._options = opts;\n this._storageItemKeyPrefix = storageItemKeyPrefix;\n }\n\n private getStorageItemKey(arg: ITwinIdArg) {\n const itwinIdStr = arg.iTwinId ? `.${arg.iTwinId}` : \"\";\n const imodelIdStr = arg.iModelId ? `.${arg.iModelId}` : \"\";\n return `${this._storageItemKeyPrefix}${itwinIdStr}${imodelIdStr}`;\n }\n\n private static getPreferenceKey(arg: PreferenceKeyArg) {\n if (arg.key) {\n const nsStr = arg.namespace ? `${arg.namespace}.` : \"\";\n return `${nsStr}${arg.key}`;\n }\n\n return \"\";\n }\n\n public async get(arg: PreferenceKeyArg & ITwinIdArg) {\n const storage = new BrowserStorage<KeyContentProps>({ itemKeyName: this.getStorageItemKey(arg) });\n return storage.get(PreferencesBrowserStorage.getPreferenceKey(arg));\n }\n\n public async delete(arg: PreferenceKeyArg & ITwinIdArg) {\n const storage = new BrowserStorage<KeyContentProps>({ itemKeyName: this.getStorageItemKey(arg) });\n storage.delete(PreferencesBrowserStorage.getPreferenceKey(arg));\n }\n\n public async save(arg: PreferenceArg & ITwinIdArg) {\n const storage = new BrowserStorage<KeyContentProps>({ itemKeyName: this.getStorageItemKey(arg) });\n storage.save(PreferencesBrowserStorage.getPreferenceKey(arg), arg.content);\n }\n}\n"]}