@itwin/unified-selection 1.6.5 → 1.6.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.
- package/CHANGELOG.md +8 -0
- package/README.md +14 -10
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -23,21 +23,24 @@ The API consists of a few very basic concepts:
|
|
|
23
23
|
|
|
24
24
|
## Usage example
|
|
25
25
|
|
|
26
|
+
<!-- [[include: [Presentation.UnifiedSelection.Example.Imports, Presentation.UnifiedSelection.Example.CreateStorage, Presentation.UnifiedSelection.Example.CleanupOnClose, Presentation.UnifiedSelection.Example.SelectionListener, Presentation.UnifiedSelection.Example.InteractiveComponent], ts]] -->
|
|
27
|
+
<!-- BEGIN EXTRACTION -->
|
|
28
|
+
|
|
26
29
|
```ts
|
|
30
|
+
import { IModelConnection } from "@itwin/core-frontend";
|
|
31
|
+
import { createIModelKey } from "@itwin/presentation-core-interop";
|
|
32
|
+
import { createStorage, Selectables } from "@itwin/unified-selection";
|
|
33
|
+
|
|
27
34
|
// Create a global selection store (generally, somewhere in main.ts or similar). This store
|
|
28
35
|
// must be shared across all the application's components to ensure unified selection experience.
|
|
29
|
-
import { createStorage } from "@itwin/unified-selection";
|
|
30
36
|
const unifiedSelection = createStorage();
|
|
31
37
|
|
|
32
38
|
// The store should to be cleaned up when iModels are closed to free up memory, e.g.:
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
IModelConnection.onClose.addListener((imodel) => {
|
|
36
|
-
unifiedSelection.clearStorage({ imodelKey: createIModelKey(imodel) });
|
|
39
|
+
IModelConnection.onClose.addListener((iModelConnection) => {
|
|
40
|
+
unifiedSelection.clearStorage({ imodelKey: createIModelKey(iModelConnection) });
|
|
37
41
|
});
|
|
38
42
|
|
|
39
43
|
// A demo selection listener logs selection changes to the console:
|
|
40
|
-
import { Selectables } from "@itwin/unified-selection";
|
|
41
44
|
unifiedSelection.selectionChangeEvent.addListener(({ imodelKey, source, changeType, selectables }) => {
|
|
42
45
|
const suffix = `in ${imodelKey} iModel from ${source} component`;
|
|
43
46
|
const numSelectables = Selectables.size(selectables);
|
|
@@ -58,12 +61,13 @@ unifiedSelection.selectionChangeEvent.addListener(({ imodelKey, source, changeTy
|
|
|
58
61
|
});
|
|
59
62
|
|
|
60
63
|
// An interactive component that allows selecting elements, representing something in an iModel, may want to
|
|
61
|
-
// add that something to unified selection:
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
});
|
|
64
|
+
// add that something to unified selection. For example:
|
|
65
|
+
const elementKey = { className: "BisCore.PhysicalElement", id: "0x1" };
|
|
66
|
+
unifiedSelection.addToSelection({ imodelKey: createIModelKey(imodel), source: "MyComponent", selectables: [elementKey] });
|
|
65
67
|
```
|
|
66
68
|
|
|
69
|
+
<!-- END EXTRACTION -->
|
|
70
|
+
|
|
67
71
|
## Learning
|
|
68
72
|
|
|
69
73
|
Are you migrating from `SelectionManager` in `@itwin/presentation-frontend`? Check out our [Migrating from `SelectionManager`](./learning/MigrationGuide.md) learning page!
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/unified-selection",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.6",
|
|
4
4
|
"description": "Package for managing unified selection in iTwin.js applications.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -36,18 +36,18 @@
|
|
|
36
36
|
"./package.json": "./package.json"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@itwin/core-bentley": "^5.5.
|
|
39
|
+
"@itwin/core-bentley": "^5.5.2",
|
|
40
40
|
"rxjs": "^7.8.2",
|
|
41
41
|
"rxjs-for-await": "^1.0.0",
|
|
42
|
-
"@itwin/presentation-shared": "^1.2.
|
|
42
|
+
"@itwin/presentation-shared": "^1.2.8"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@itwin/build-tools": "^5.5.
|
|
45
|
+
"@itwin/build-tools": "^5.5.2",
|
|
46
46
|
"@itwin/eslint-plugin": "5.1.0",
|
|
47
47
|
"@types/chai": "^5.2.3",
|
|
48
48
|
"@types/chai-as-promised": "^8.0.2",
|
|
49
49
|
"@types/mocha": "^10.0.10",
|
|
50
|
-
"@types/node": "^22.19.
|
|
50
|
+
"@types/node": "^22.19.8",
|
|
51
51
|
"@types/sinon": "^17.0.4",
|
|
52
52
|
"@types/sinon-chai": "^4.0.0",
|
|
53
53
|
"c8": "^10.1.3",
|