@itwin/presentation-frontend 4.0.0-dev.8 → 4.0.0-dev.81

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 (122) hide show
  1. package/CHANGELOG.md +45 -1
  2. package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.d.ts +29 -29
  3. package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.js +47 -47
  4. package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.js.map +1 -1
  5. package/lib/cjs/presentation-frontend/Diagnostics.d.ts +14 -14
  6. package/lib/cjs/presentation-frontend/Diagnostics.js +61 -61
  7. package/lib/cjs/presentation-frontend/FrontendLoggerCategory.d.ts +12 -12
  8. package/lib/cjs/presentation-frontend/FrontendLoggerCategory.js +20 -20
  9. package/lib/cjs/presentation-frontend/IpcRequestsHandler.d.ts +9 -10
  10. package/lib/cjs/presentation-frontend/IpcRequestsHandler.d.ts.map +1 -1
  11. package/lib/cjs/presentation-frontend/IpcRequestsHandler.js +32 -41
  12. package/lib/cjs/presentation-frontend/IpcRequestsHandler.js.map +1 -1
  13. package/lib/cjs/presentation-frontend/LocalizationHelper.d.ts +10 -10
  14. package/lib/cjs/presentation-frontend/LocalizationHelper.js +31 -31
  15. package/lib/cjs/presentation-frontend/LocalizationHelper.js.map +1 -1
  16. package/lib/cjs/presentation-frontend/Presentation.d.ts +73 -75
  17. package/lib/cjs/presentation-frontend/Presentation.d.ts.map +1 -1
  18. package/lib/cjs/presentation-frontend/Presentation.js +159 -162
  19. package/lib/cjs/presentation-frontend/Presentation.js.map +1 -1
  20. package/lib/cjs/presentation-frontend/PresentationManager.d.ts +207 -186
  21. package/lib/cjs/presentation-frontend/PresentationManager.d.ts.map +1 -1
  22. package/lib/cjs/presentation-frontend/PresentationManager.js +442 -436
  23. package/lib/cjs/presentation-frontend/PresentationManager.js.map +1 -1
  24. package/lib/cjs/presentation-frontend/RulesetManager.d.ts +63 -63
  25. package/lib/cjs/presentation-frontend/RulesetManager.js +85 -85
  26. package/lib/cjs/presentation-frontend/RulesetVariablesManager.d.ts +143 -143
  27. package/lib/cjs/presentation-frontend/RulesetVariablesManager.js +195 -195
  28. package/lib/cjs/presentation-frontend/RulesetVariablesManager.js.map +1 -1
  29. package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts +132 -132
  30. package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts.map +1 -1
  31. package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.js +520 -518
  32. package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.js.map +1 -1
  33. package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.d.ts +111 -111
  34. package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js +290 -293
  35. package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js.map +1 -1
  36. package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.d.ts +52 -52
  37. package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.js +97 -97
  38. package/lib/cjs/presentation-frontend/selection/ISelectionProvider.d.ts +19 -19
  39. package/lib/cjs/presentation-frontend/selection/ISelectionProvider.js +9 -9
  40. package/lib/cjs/presentation-frontend/selection/SelectionChangeEvent.d.ts +52 -52
  41. package/lib/cjs/presentation-frontend/selection/SelectionChangeEvent.js +33 -33
  42. package/lib/cjs/presentation-frontend/selection/SelectionHandler.d.ts +103 -103
  43. package/lib/cjs/presentation-frontend/selection/SelectionHandler.js +108 -108
  44. package/lib/cjs/presentation-frontend/selection/SelectionHelper.d.ts +17 -14
  45. package/lib/cjs/presentation-frontend/selection/SelectionHelper.d.ts.map +1 -1
  46. package/lib/cjs/presentation-frontend/selection/SelectionHelper.js +40 -37
  47. package/lib/cjs/presentation-frontend/selection/SelectionHelper.js.map +1 -1
  48. package/lib/cjs/presentation-frontend/selection/SelectionManager.d.ts +139 -139
  49. package/lib/cjs/presentation-frontend/selection/SelectionManager.js +414 -414
  50. package/lib/cjs/presentation-frontend/selection/SelectionManager.js.map +1 -1
  51. package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.d.ts +59 -59
  52. package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.js +91 -91
  53. package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.js.map +1 -1
  54. package/lib/cjs/presentation-frontend.d.ts +33 -34
  55. package/lib/cjs/presentation-frontend.d.ts.map +1 -1
  56. package/lib/cjs/presentation-frontend.js +53 -50
  57. package/lib/cjs/presentation-frontend.js.map +1 -1
  58. package/lib/esm/presentation-frontend/ConnectivityInformationProvider.d.ts +29 -29
  59. package/lib/esm/presentation-frontend/ConnectivityInformationProvider.js +43 -43
  60. package/lib/esm/presentation-frontend/ConnectivityInformationProvider.js.map +1 -1
  61. package/lib/esm/presentation-frontend/Diagnostics.d.ts +14 -14
  62. package/lib/esm/presentation-frontend/Diagnostics.js +56 -56
  63. package/lib/esm/presentation-frontend/FrontendLoggerCategory.d.ts +12 -12
  64. package/lib/esm/presentation-frontend/FrontendLoggerCategory.js +17 -17
  65. package/lib/esm/presentation-frontend/IpcRequestsHandler.d.ts +9 -10
  66. package/lib/esm/presentation-frontend/IpcRequestsHandler.d.ts.map +1 -1
  67. package/lib/esm/presentation-frontend/IpcRequestsHandler.js +28 -37
  68. package/lib/esm/presentation-frontend/IpcRequestsHandler.js.map +1 -1
  69. package/lib/esm/presentation-frontend/LocalizationHelper.d.ts +10 -10
  70. package/lib/esm/presentation-frontend/LocalizationHelper.js +27 -27
  71. package/lib/esm/presentation-frontend/LocalizationHelper.js.map +1 -1
  72. package/lib/esm/presentation-frontend/Presentation.d.ts +73 -75
  73. package/lib/esm/presentation-frontend/Presentation.d.ts.map +1 -1
  74. package/lib/esm/presentation-frontend/Presentation.js +155 -158
  75. package/lib/esm/presentation-frontend/Presentation.js.map +1 -1
  76. package/lib/esm/presentation-frontend/PresentationManager.d.ts +207 -186
  77. package/lib/esm/presentation-frontend/PresentationManager.d.ts.map +1 -1
  78. package/lib/esm/presentation-frontend/PresentationManager.js +437 -431
  79. package/lib/esm/presentation-frontend/PresentationManager.js.map +1 -1
  80. package/lib/esm/presentation-frontend/RulesetManager.d.ts +63 -63
  81. package/lib/esm/presentation-frontend/RulesetManager.js +81 -81
  82. package/lib/esm/presentation-frontend/RulesetVariablesManager.d.ts +143 -143
  83. package/lib/esm/presentation-frontend/RulesetVariablesManager.js +191 -191
  84. package/lib/esm/presentation-frontend/RulesetVariablesManager.js.map +1 -1
  85. package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts +132 -132
  86. package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts.map +1 -1
  87. package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.js +515 -512
  88. package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.js.map +1 -1
  89. package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.d.ts +111 -111
  90. package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js +282 -285
  91. package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js.map +1 -1
  92. package/lib/esm/presentation-frontend/selection/HiliteSetProvider.d.ts +52 -52
  93. package/lib/esm/presentation-frontend/selection/HiliteSetProvider.js +93 -93
  94. package/lib/esm/presentation-frontend/selection/ISelectionProvider.d.ts +19 -19
  95. package/lib/esm/presentation-frontend/selection/ISelectionProvider.js +8 -8
  96. package/lib/esm/presentation-frontend/selection/SelectionChangeEvent.d.ts +52 -52
  97. package/lib/esm/presentation-frontend/selection/SelectionChangeEvent.js +29 -29
  98. package/lib/esm/presentation-frontend/selection/SelectionHandler.d.ts +103 -103
  99. package/lib/esm/presentation-frontend/selection/SelectionHandler.js +104 -104
  100. package/lib/esm/presentation-frontend/selection/SelectionHelper.d.ts +17 -14
  101. package/lib/esm/presentation-frontend/selection/SelectionHelper.d.ts.map +1 -1
  102. package/lib/esm/presentation-frontend/selection/SelectionHelper.js +36 -33
  103. package/lib/esm/presentation-frontend/selection/SelectionHelper.js.map +1 -1
  104. package/lib/esm/presentation-frontend/selection/SelectionManager.d.ts +139 -139
  105. package/lib/esm/presentation-frontend/selection/SelectionManager.js +409 -409
  106. package/lib/esm/presentation-frontend/selection/SelectionManager.js.map +1 -1
  107. package/lib/esm/presentation-frontend/selection/SelectionScopesManager.d.ts +59 -59
  108. package/lib/esm/presentation-frontend/selection/SelectionScopesManager.js +85 -85
  109. package/lib/esm/presentation-frontend/selection/SelectionScopesManager.js.map +1 -1
  110. package/lib/esm/presentation-frontend.d.ts +33 -34
  111. package/lib/esm/presentation-frontend.d.ts.map +1 -1
  112. package/lib/esm/presentation-frontend.js +37 -38
  113. package/lib/esm/presentation-frontend.js.map +1 -1
  114. package/package.json +22 -20
  115. package/lib/cjs/presentation-frontend/StateTracker.d.ts +0 -39
  116. package/lib/cjs/presentation-frontend/StateTracker.d.ts.map +0 -1
  117. package/lib/cjs/presentation-frontend/StateTracker.js +0 -130
  118. package/lib/cjs/presentation-frontend/StateTracker.js.map +0 -1
  119. package/lib/esm/presentation-frontend/StateTracker.d.ts +0 -39
  120. package/lib/esm/presentation-frontend/StateTracker.d.ts.map +0 -1
  121. package/lib/esm/presentation-frontend/StateTracker.js +0 -126
  122. package/lib/esm/presentation-frontend/StateTracker.js.map +0 -1
@@ -1,30 +1,30 @@
1
- /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
- * See LICENSE.md in the project root for license terms and full copyright notice.
4
- *--------------------------------------------------------------------------------------------*/
5
- /** @packageDocumentation
6
- * @module UnifiedSelection
7
- */
8
- import { BeEvent } from "@itwin/core-bentley";
9
- /**
10
- * An event broadcasted on selection changes
11
- * @public
12
- */
13
- export class SelectionChangeEvent extends BeEvent {
14
- }
15
- /**
16
- * The type of selection change
17
- * @public
18
- */
19
- export var SelectionChangeType;
20
- (function (SelectionChangeType) {
21
- /** Added to selection. */
22
- SelectionChangeType[SelectionChangeType["Add"] = 0] = "Add";
23
- /** Removed from selection. */
24
- SelectionChangeType[SelectionChangeType["Remove"] = 1] = "Remove";
25
- /** Selection was replaced. */
26
- SelectionChangeType[SelectionChangeType["Replace"] = 2] = "Replace";
27
- /** Selection was cleared. */
28
- SelectionChangeType[SelectionChangeType["Clear"] = 3] = "Clear";
29
- })(SelectionChangeType || (SelectionChangeType = {}));
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ /** @packageDocumentation
6
+ * @module UnifiedSelection
7
+ */
8
+ import { BeEvent } from "@itwin/core-bentley";
9
+ /**
10
+ * An event broadcasted on selection changes
11
+ * @public
12
+ */
13
+ export class SelectionChangeEvent extends BeEvent {
14
+ }
15
+ /**
16
+ * The type of selection change
17
+ * @public
18
+ */
19
+ export var SelectionChangeType;
20
+ (function (SelectionChangeType) {
21
+ /** Added to selection. */
22
+ SelectionChangeType[SelectionChangeType["Add"] = 0] = "Add";
23
+ /** Removed from selection. */
24
+ SelectionChangeType[SelectionChangeType["Remove"] = 1] = "Remove";
25
+ /** Selection was replaced. */
26
+ SelectionChangeType[SelectionChangeType["Replace"] = 2] = "Replace";
27
+ /** Selection was cleared. */
28
+ SelectionChangeType[SelectionChangeType["Clear"] = 3] = "Clear";
29
+ })(SelectionChangeType || (SelectionChangeType = {}));
30
30
  //# sourceMappingURL=SelectionChangeEvent.js.map
@@ -1,104 +1,104 @@
1
- /** @packageDocumentation
2
- * @module UnifiedSelection
3
- */
4
- import { IDisposable } from "@itwin/core-bentley";
5
- import { IModelConnection } from "@itwin/core-frontend";
6
- import { Keys, KeySet } from "@itwin/presentation-common";
7
- import { ISelectionProvider } from "./ISelectionProvider";
8
- import { SelectionChangeEventArgs, SelectionChangesListener } from "./SelectionChangeEvent";
9
- import { SelectionManager } from "./SelectionManager";
10
- /**
11
- * Properties for creating a `SelectionHandler` instance.
12
- * @public
13
- */
14
- export interface SelectionHandlerProps {
15
- /** SelectionManager used to store overall selection. */
16
- manager: SelectionManager;
17
- /** iModel connection the selection changes will be associated with. */
18
- imodel: IModelConnection;
19
- /**
20
- * Name of the selection handler. This is an identifier of what caused the
21
- * selection to change, set as `SelectionChangeEventArgs.source` when firing
22
- * selection change events. `SelectionHandler.shouldHandle` uses `name` to filter
23
- * events that it doesn't need to handle.
24
- */
25
- name: string;
26
- /**
27
- * ID of presentation ruleset used by the component using this handler. The ID is set as
28
- * `SelectionChangeEventArgs.rulesetId` when making selection changes and event
29
- * listeners can use or ignore this information.
30
- */
31
- rulesetId?: string;
32
- /** Callback function called when selection changes. */
33
- onSelect?: SelectionChangesListener;
34
- }
35
- /**
36
- * A class that handles selection changes and helps to change
37
- * internal the selection state.
38
- *
39
- * @public
40
- */
41
- export declare class SelectionHandler implements IDisposable {
42
- private _inSelect;
43
- private _disposables;
44
- /** Selection manager used by this handler to manage selection */
45
- readonly manager: SelectionManager;
46
- /** Name that's used as `SelectionChangeEventArgs.source` when making selection changes */
47
- name: string;
48
- /** iModel whose selection is being handled */
49
- imodel: IModelConnection;
50
- /**
51
- * Id of a ruleset selection changes will be associated with.
52
- * @see `SelectionHandlerProps.rulesetId`
53
- */
54
- rulesetId?: string;
55
- /** Callback function called when selection changes */
56
- onSelect?: SelectionChangesListener;
57
- /**
58
- * Constructor.
59
- */
60
- constructor(props: SelectionHandlerProps);
61
- /**
62
- * Destructor. Must be called before disposing this object to make sure it cleans
63
- * up correctly.
64
- */
65
- dispose(): void;
66
- /**
67
- * Called when the selection changes. Handles this callback by first checking whether
68
- * the event should be handled at all (using the `shouldHandle` method) and then calling `onSelect`
69
- */
70
- protected onSelectionChanged: (evt: SelectionChangeEventArgs, provider: ISelectionProvider) => void;
71
- /** Called to check whether the event should be handled by this handler */
72
- protected shouldHandle(evt: SelectionChangeEventArgs): boolean;
73
- /** Get selection levels for the imodel managed by this handler */
74
- getSelectionLevels(): number[];
75
- /**
76
- * Get selection for the imodel managed by this handler.
77
- * @param level Level of the selection to get. Defaults to 0.
78
- */
79
- getSelection(level?: number): Readonly<KeySet>;
80
- /**
81
- * Add to selection.
82
- * @param keys The keys to add to selection.
83
- * @param level Level of the selection.
84
- */
85
- addToSelection(keys: Keys, level?: number): void;
86
- /**
87
- * Remove from selection.
88
- * @param keys The keys to remove from selection.
89
- * @param level Level of the selection.
90
- */
91
- removeFromSelection(keys: Keys, level?: number): void;
92
- /**
93
- * Change selection.
94
- * @param keys The keys indicating the new selection.
95
- * @param level Level of the selection.
96
- */
97
- replaceSelection(keys: Keys, level?: number): void;
98
- /**
99
- * Clear selection.
100
- * @param level Level of the selection.
101
- */
102
- clearSelection(level?: number): void;
103
- }
1
+ /** @packageDocumentation
2
+ * @module UnifiedSelection
3
+ */
4
+ import { IDisposable } from "@itwin/core-bentley";
5
+ import { IModelConnection } from "@itwin/core-frontend";
6
+ import { Keys, KeySet } from "@itwin/presentation-common";
7
+ import { ISelectionProvider } from "./ISelectionProvider";
8
+ import { SelectionChangeEventArgs, SelectionChangesListener } from "./SelectionChangeEvent";
9
+ import { SelectionManager } from "./SelectionManager";
10
+ /**
11
+ * Properties for creating a `SelectionHandler` instance.
12
+ * @public
13
+ */
14
+ export interface SelectionHandlerProps {
15
+ /** SelectionManager used to store overall selection. */
16
+ manager: SelectionManager;
17
+ /** iModel connection the selection changes will be associated with. */
18
+ imodel: IModelConnection;
19
+ /**
20
+ * Name of the selection handler. This is an identifier of what caused the
21
+ * selection to change, set as `SelectionChangeEventArgs.source` when firing
22
+ * selection change events. `SelectionHandler.shouldHandle` uses `name` to filter
23
+ * events that it doesn't need to handle.
24
+ */
25
+ name: string;
26
+ /**
27
+ * ID of presentation ruleset used by the component using this handler. The ID is set as
28
+ * `SelectionChangeEventArgs.rulesetId` when making selection changes and event
29
+ * listeners can use or ignore this information.
30
+ */
31
+ rulesetId?: string;
32
+ /** Callback function called when selection changes. */
33
+ onSelect?: SelectionChangesListener;
34
+ }
35
+ /**
36
+ * A class that handles selection changes and helps to change
37
+ * internal the selection state.
38
+ *
39
+ * @public
40
+ */
41
+ export declare class SelectionHandler implements IDisposable {
42
+ private _inSelect;
43
+ private _disposables;
44
+ /** Selection manager used by this handler to manage selection */
45
+ readonly manager: SelectionManager;
46
+ /** Name that's used as `SelectionChangeEventArgs.source` when making selection changes */
47
+ name: string;
48
+ /** iModel whose selection is being handled */
49
+ imodel: IModelConnection;
50
+ /**
51
+ * Id of a ruleset selection changes will be associated with.
52
+ * @see `SelectionHandlerProps.rulesetId`
53
+ */
54
+ rulesetId?: string;
55
+ /** Callback function called when selection changes */
56
+ onSelect?: SelectionChangesListener;
57
+ /**
58
+ * Constructor.
59
+ */
60
+ constructor(props: SelectionHandlerProps);
61
+ /**
62
+ * Destructor. Must be called before disposing this object to make sure it cleans
63
+ * up correctly.
64
+ */
65
+ dispose(): void;
66
+ /**
67
+ * Called when the selection changes. Handles this callback by first checking whether
68
+ * the event should be handled at all (using the `shouldHandle` method) and then calling `onSelect`
69
+ */
70
+ protected onSelectionChanged: (evt: SelectionChangeEventArgs, provider: ISelectionProvider) => void;
71
+ /** Called to check whether the event should be handled by this handler */
72
+ protected shouldHandle(evt: SelectionChangeEventArgs): boolean;
73
+ /** Get selection levels for the imodel managed by this handler */
74
+ getSelectionLevels(): number[];
75
+ /**
76
+ * Get selection for the imodel managed by this handler.
77
+ * @param level Level of the selection to get. Defaults to 0.
78
+ */
79
+ getSelection(level?: number): Readonly<KeySet>;
80
+ /**
81
+ * Add to selection.
82
+ * @param keys The keys to add to selection.
83
+ * @param level Level of the selection.
84
+ */
85
+ addToSelection(keys: Keys, level?: number): void;
86
+ /**
87
+ * Remove from selection.
88
+ * @param keys The keys to remove from selection.
89
+ * @param level Level of the selection.
90
+ */
91
+ removeFromSelection(keys: Keys, level?: number): void;
92
+ /**
93
+ * Change selection.
94
+ * @param keys The keys indicating the new selection.
95
+ * @param level Level of the selection.
96
+ */
97
+ replaceSelection(keys: Keys, level?: number): void;
98
+ /**
99
+ * Clear selection.
100
+ * @param level Level of the selection.
101
+ */
102
+ clearSelection(level?: number): void;
103
+ }
104
104
  //# sourceMappingURL=SelectionHandler.d.ts.map
@@ -1,105 +1,105 @@
1
- /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
- * See LICENSE.md in the project root for license terms and full copyright notice.
4
- *--------------------------------------------------------------------------------------------*/
5
- /** @packageDocumentation
6
- * @module UnifiedSelection
7
- */
8
- import { DisposableList } from "@itwin/core-bentley";
9
- /**
10
- * A class that handles selection changes and helps to change
11
- * internal the selection state.
12
- *
13
- * @public
14
- */
15
- export class SelectionHandler {
16
- /**
17
- * Constructor.
18
- */
19
- constructor(props) {
20
- /**
21
- * Called when the selection changes. Handles this callback by first checking whether
22
- * the event should be handled at all (using the `shouldHandle` method) and then calling `onSelect`
23
- */
24
- // eslint-disable-next-line @typescript-eslint/naming-convention
25
- this.onSelectionChanged = (evt, provider) => {
26
- if (!this.onSelect || !this.shouldHandle(evt))
27
- return;
28
- this._inSelect = true;
29
- this.onSelect(evt, provider);
30
- this._inSelect = false;
31
- };
32
- this._inSelect = false;
33
- this.manager = props.manager;
34
- this._disposables = new DisposableList();
35
- this.name = props.name;
36
- this.rulesetId = props.rulesetId;
37
- this.imodel = props.imodel;
38
- this.onSelect = props.onSelect;
39
- this._disposables.add(this.manager.selectionChange.addListener(this.onSelectionChanged));
40
- }
41
- /**
42
- * Destructor. Must be called before disposing this object to make sure it cleans
43
- * up correctly.
44
- */
45
- dispose() {
46
- this._disposables.dispose();
47
- }
48
- /** Called to check whether the event should be handled by this handler */
49
- shouldHandle(evt) {
50
- if (this.name === evt.source)
51
- return false;
52
- return true;
53
- }
54
- /** Get selection levels for the imodel managed by this handler */
55
- getSelectionLevels() {
56
- return this.manager.getSelectionLevels(this.imodel);
57
- }
58
- /**
59
- * Get selection for the imodel managed by this handler.
60
- * @param level Level of the selection to get. Defaults to 0.
61
- */
62
- getSelection(level) {
63
- return this.manager.getSelection(this.imodel, level);
64
- }
65
- /**
66
- * Add to selection.
67
- * @param keys The keys to add to selection.
68
- * @param level Level of the selection.
69
- */
70
- addToSelection(keys, level = 0) {
71
- if (this._inSelect)
72
- return;
73
- return this.manager.addToSelection(this.name, this.imodel, keys, level, this.rulesetId);
74
- }
75
- /**
76
- * Remove from selection.
77
- * @param keys The keys to remove from selection.
78
- * @param level Level of the selection.
79
- */
80
- removeFromSelection(keys, level = 0) {
81
- if (this._inSelect)
82
- return;
83
- return this.manager.removeFromSelection(this.name, this.imodel, keys, level, this.rulesetId);
84
- }
85
- /**
86
- * Change selection.
87
- * @param keys The keys indicating the new selection.
88
- * @param level Level of the selection.
89
- */
90
- replaceSelection(keys, level = 0) {
91
- if (this._inSelect)
92
- return;
93
- return this.manager.replaceSelection(this.name, this.imodel, keys, level, this.rulesetId);
94
- }
95
- /**
96
- * Clear selection.
97
- * @param level Level of the selection.
98
- */
99
- clearSelection(level = 0) {
100
- if (this._inSelect)
101
- return;
102
- return this.manager.clearSelection(this.name, this.imodel, level, this.rulesetId);
103
- }
104
- }
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ /** @packageDocumentation
6
+ * @module UnifiedSelection
7
+ */
8
+ import { DisposableList } from "@itwin/core-bentley";
9
+ /**
10
+ * A class that handles selection changes and helps to change
11
+ * internal the selection state.
12
+ *
13
+ * @public
14
+ */
15
+ export class SelectionHandler {
16
+ /**
17
+ * Constructor.
18
+ */
19
+ constructor(props) {
20
+ /**
21
+ * Called when the selection changes. Handles this callback by first checking whether
22
+ * the event should be handled at all (using the `shouldHandle` method) and then calling `onSelect`
23
+ */
24
+ // eslint-disable-next-line @typescript-eslint/naming-convention
25
+ this.onSelectionChanged = (evt, provider) => {
26
+ if (!this.onSelect || !this.shouldHandle(evt))
27
+ return;
28
+ this._inSelect = true;
29
+ this.onSelect(evt, provider);
30
+ this._inSelect = false;
31
+ };
32
+ this._inSelect = false;
33
+ this.manager = props.manager;
34
+ this._disposables = new DisposableList();
35
+ this.name = props.name;
36
+ this.rulesetId = props.rulesetId;
37
+ this.imodel = props.imodel;
38
+ this.onSelect = props.onSelect;
39
+ this._disposables.add(this.manager.selectionChange.addListener(this.onSelectionChanged));
40
+ }
41
+ /**
42
+ * Destructor. Must be called before disposing this object to make sure it cleans
43
+ * up correctly.
44
+ */
45
+ dispose() {
46
+ this._disposables.dispose();
47
+ }
48
+ /** Called to check whether the event should be handled by this handler */
49
+ shouldHandle(evt) {
50
+ if (this.name === evt.source)
51
+ return false;
52
+ return true;
53
+ }
54
+ /** Get selection levels for the imodel managed by this handler */
55
+ getSelectionLevels() {
56
+ return this.manager.getSelectionLevels(this.imodel);
57
+ }
58
+ /**
59
+ * Get selection for the imodel managed by this handler.
60
+ * @param level Level of the selection to get. Defaults to 0.
61
+ */
62
+ getSelection(level) {
63
+ return this.manager.getSelection(this.imodel, level);
64
+ }
65
+ /**
66
+ * Add to selection.
67
+ * @param keys The keys to add to selection.
68
+ * @param level Level of the selection.
69
+ */
70
+ addToSelection(keys, level = 0) {
71
+ if (this._inSelect)
72
+ return;
73
+ return this.manager.addToSelection(this.name, this.imodel, keys, level, this.rulesetId);
74
+ }
75
+ /**
76
+ * Remove from selection.
77
+ * @param keys The keys to remove from selection.
78
+ * @param level Level of the selection.
79
+ */
80
+ removeFromSelection(keys, level = 0) {
81
+ if (this._inSelect)
82
+ return;
83
+ return this.manager.removeFromSelection(this.name, this.imodel, keys, level, this.rulesetId);
84
+ }
85
+ /**
86
+ * Change selection.
87
+ * @param keys The keys indicating the new selection.
88
+ * @param level Level of the selection.
89
+ */
90
+ replaceSelection(keys, level = 0) {
91
+ if (this._inSelect)
92
+ return;
93
+ return this.manager.replaceSelection(this.name, this.imodel, keys, level, this.rulesetId);
94
+ }
95
+ /**
96
+ * Clear selection.
97
+ * @param level Level of the selection.
98
+ */
99
+ clearSelection(level = 0) {
100
+ if (this._inSelect)
101
+ return;
102
+ return this.manager.clearSelection(this.name, this.imodel, level, this.rulesetId);
103
+ }
104
+ }
105
105
  //# sourceMappingURL=SelectionHandler.js.map
@@ -1,15 +1,18 @@
1
- /** @packageDocumentation
2
- * @module UnifiedSelection
3
- */
4
- import { Key, Keys } from "@itwin/presentation-common";
5
- /** @internal */
6
- export declare class SelectionHelper {
7
- private constructor();
8
- /**
9
- * Re-map the given keyset for selection. This means all instance node keys get converted
10
- * to instance keys, because in that case we want to select instances instead of nodes. All
11
- * other types of keys ar left as is.
12
- */
13
- static getKeysForSelection(keys: Readonly<Keys>): Key[];
14
- }
1
+ /** @packageDocumentation
2
+ * @module UnifiedSelection
3
+ */
4
+ import { Key, Keys } from "@itwin/presentation-common";
5
+ /**
6
+ * Helper class for working with selection.
7
+ * @public
8
+ */
9
+ export declare class SelectionHelper {
10
+ private constructor();
11
+ /**
12
+ * Re-map the given keyset for selection. This means all instance node keys get converted
13
+ * to instance keys, because in that case we want to select instances instead of nodes. All
14
+ * other types of keys ar left as is.
15
+ */
16
+ static getKeysForSelection(keys: Readonly<Keys>): Key[];
17
+ }
15
18
  //# sourceMappingURL=SelectionHelper.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SelectionHelper.d.ts","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionHelper.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,GAAG,EAAE,IAAI,EAAW,MAAM,4BAA4B,CAAC;AAEhE,gBAAgB;AAChB,qBAAa,eAAe;IAG1B,OAAO;IAEP;;;;OAIG;WACW,mBAAmB,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,GAAG,EAAE;CAe/D"}
1
+ {"version":3,"file":"SelectionHelper.d.ts","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionHelper.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,GAAG,EAAE,IAAI,EAAW,MAAM,4BAA4B,CAAC;AAEhE;;;GAGG;AACH,qBAAa,eAAe;IAG1B,OAAO;IAEP;;;;OAIG;WACW,mBAAmB,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,GAAG,EAAE;CAe/D"}
@@ -1,34 +1,37 @@
1
- /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
- * See LICENSE.md in the project root for license terms and full copyright notice.
4
- *--------------------------------------------------------------------------------------------*/
5
- /** @packageDocumentation
6
- * @module UnifiedSelection
7
- */
8
- import { Key, NodeKey } from "@itwin/presentation-common";
9
- /** @internal */
10
- export class SelectionHelper {
11
- // istanbul ignore next
12
- constructor() { }
13
- /**
14
- * Re-map the given keyset for selection. This means all instance node keys get converted
15
- * to instance keys, because in that case we want to select instances instead of nodes. All
16
- * other types of keys ar left as is.
17
- */
18
- static getKeysForSelection(keys) {
19
- const result = new Array();
20
- keys.forEach((key) => {
21
- if (Key.isNodeKey(key)) {
22
- if (NodeKey.isInstancesNodeKey(key))
23
- result.push(...key.instanceKeys);
24
- else
25
- result.push(key);
26
- }
27
- else {
28
- result.push(key);
29
- }
30
- });
31
- return result;
32
- }
33
- }
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ /** @packageDocumentation
6
+ * @module UnifiedSelection
7
+ */
8
+ import { Key, NodeKey } from "@itwin/presentation-common";
9
+ /**
10
+ * Helper class for working with selection.
11
+ * @public
12
+ */
13
+ export class SelectionHelper {
14
+ // istanbul ignore next
15
+ constructor() { }
16
+ /**
17
+ * Re-map the given keyset for selection. This means all instance node keys get converted
18
+ * to instance keys, because in that case we want to select instances instead of nodes. All
19
+ * other types of keys ar left as is.
20
+ */
21
+ static getKeysForSelection(keys) {
22
+ const result = new Array();
23
+ keys.forEach((key) => {
24
+ if (Key.isNodeKey(key)) {
25
+ if (NodeKey.isInstancesNodeKey(key))
26
+ result.push(...key.instanceKeys);
27
+ else
28
+ result.push(key);
29
+ }
30
+ else {
31
+ result.push(key);
32
+ }
33
+ });
34
+ return result;
35
+ }
36
+ }
34
37
  //# sourceMappingURL=SelectionHelper.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SelectionHelper.js","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionHelper.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,GAAG,EAAQ,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAEhE,gBAAgB;AAChB,MAAM,OAAO,eAAe;IAE1B,uBAAuB;IACvB,gBAAwB,CAAC;IAEzB;;;;OAIG;IACI,MAAM,CAAC,mBAAmB,CAAC,IAAoB;QACpD,MAAM,MAAM,GAAG,IAAI,KAAK,EAAO,CAAC;QAChC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAQ,EAAE,EAAE;YACxB,IAAI,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE;gBACtB,IAAI,OAAO,CAAC,kBAAkB,CAAC,GAAG,CAAC;oBACjC,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,YAAY,CAAC,CAAC;;oBAEjC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;aACpB;iBAAM;gBACL,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;aAClB;QACH,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC;CAEF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module UnifiedSelection\r\n */\r\n\r\nimport { Key, Keys, NodeKey } from \"@itwin/presentation-common\";\r\n\r\n/** @internal */\r\nexport class SelectionHelper {\r\n\r\n // istanbul ignore next\r\n private constructor() { }\r\n\r\n /**\r\n * Re-map the given keyset for selection. This means all instance node keys get converted\r\n * to instance keys, because in that case we want to select instances instead of nodes. All\r\n * other types of keys ar left as is.\r\n */\r\n public static getKeysForSelection(keys: Readonly<Keys>): Key[] {\r\n const result = new Array<Key>();\r\n keys.forEach((key: Key) => {\r\n if (Key.isNodeKey(key)) {\r\n if (NodeKey.isInstancesNodeKey(key))\r\n result.push(...key.instanceKeys);\r\n else\r\n result.push(key);\r\n } else {\r\n result.push(key);\r\n }\r\n });\r\n return result;\r\n }\r\n\r\n}\r\n"]}
1
+ {"version":3,"file":"SelectionHelper.js","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionHelper.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,GAAG,EAAQ,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAEhE;;;GAGG;AACH,MAAM,OAAO,eAAe;IAE1B,uBAAuB;IACvB,gBAAwB,CAAC;IAEzB;;;;OAIG;IACI,MAAM,CAAC,mBAAmB,CAAC,IAAoB;QACpD,MAAM,MAAM,GAAG,IAAI,KAAK,EAAO,CAAC;QAChC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAQ,EAAE,EAAE;YACxB,IAAI,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE;gBACtB,IAAI,OAAO,CAAC,kBAAkB,CAAC,GAAG,CAAC;oBACjC,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,YAAY,CAAC,CAAC;;oBAEjC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;aACpB;iBAAM;gBACL,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;aAClB;QACH,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC;CAEF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module UnifiedSelection\r\n */\r\n\r\nimport { Key, Keys, NodeKey } from \"@itwin/presentation-common\";\r\n\r\n/**\r\n * Helper class for working with selection.\r\n * @public\r\n */\r\nexport class SelectionHelper {\r\n\r\n // istanbul ignore next\r\n private constructor() { }\r\n\r\n /**\r\n * Re-map the given keyset for selection. This means all instance node keys get converted\r\n * to instance keys, because in that case we want to select instances instead of nodes. All\r\n * other types of keys ar left as is.\r\n */\r\n public static getKeysForSelection(keys: Readonly<Keys>): Key[] {\r\n const result = new Array<Key>();\r\n keys.forEach((key: Key) => {\r\n if (Key.isNodeKey(key)) {\r\n if (NodeKey.isInstancesNodeKey(key))\r\n result.push(...key.instanceKeys);\r\n else\r\n result.push(key);\r\n } else {\r\n result.push(key);\r\n }\r\n });\r\n return result;\r\n }\r\n\r\n}\r\n"]}