@itwin/unified-selection 1.8.2 → 2.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +1 -1
  3. package/lib/{cjs/unified-selection → unified-selection}/CachingHiliteSetProvider.d.ts +3 -3
  4. package/lib/unified-selection/CachingHiliteSetProvider.d.ts.map +1 -0
  5. package/lib/unified-selection/CachingHiliteSetProvider.js.map +1 -0
  6. package/lib/unified-selection/DisposePolyfill.d.ts.map +1 -0
  7. package/lib/unified-selection/DisposePolyfill.js.map +1 -0
  8. package/lib/{cjs/unified-selection → unified-selection}/EnableUnifiedSelectionSyncWithIModel.d.ts +7 -7
  9. package/lib/unified-selection/EnableUnifiedSelectionSyncWithIModel.d.ts.map +1 -0
  10. package/lib/{esm/unified-selection → unified-selection}/EnableUnifiedSelectionSyncWithIModel.js +1 -1
  11. package/lib/unified-selection/EnableUnifiedSelectionSyncWithIModel.js.map +1 -0
  12. package/lib/{cjs/unified-selection → unified-selection}/HiliteSetProvider.d.ts +3 -3
  13. package/lib/unified-selection/HiliteSetProvider.d.ts.map +1 -0
  14. package/lib/{esm/unified-selection → unified-selection}/HiliteSetProvider.js +2 -2
  15. package/lib/unified-selection/HiliteSetProvider.js.map +1 -0
  16. package/lib/{esm/unified-selection → unified-selection}/IModelHiliteSetProvider.d.ts +4 -3
  17. package/lib/unified-selection/IModelHiliteSetProvider.d.ts.map +1 -0
  18. package/lib/unified-selection/IModelHiliteSetProvider.js.map +1 -0
  19. package/lib/{esm/unified-selection → unified-selection}/Selectable.d.ts +1 -1
  20. package/lib/unified-selection/Selectable.d.ts.map +1 -0
  21. package/lib/unified-selection/Selectable.js.map +1 -0
  22. package/lib/{cjs/unified-selection → unified-selection}/SelectionChangeEvent.d.ts +2 -2
  23. package/lib/unified-selection/SelectionChangeEvent.d.ts.map +1 -0
  24. package/lib/unified-selection/SelectionChangeEvent.js.map +1 -0
  25. package/lib/{cjs/unified-selection → unified-selection}/SelectionScope.d.ts +3 -3
  26. package/lib/unified-selection/SelectionScope.d.ts.map +1 -0
  27. package/lib/unified-selection/SelectionScope.js.map +1 -0
  28. package/lib/{esm/unified-selection → unified-selection}/SelectionStorage.d.ts +4 -3
  29. package/lib/unified-selection/SelectionStorage.d.ts.map +1 -0
  30. package/lib/unified-selection/SelectionStorage.js.map +1 -0
  31. package/lib/{esm/unified-selection → unified-selection}/Utils.d.ts +3 -3
  32. package/lib/unified-selection/Utils.d.ts.map +1 -0
  33. package/lib/{esm/unified-selection → unified-selection}/Utils.js +1 -1
  34. package/lib/unified-selection/Utils.js.map +1 -0
  35. package/lib/{esm/unified-selection → unified-selection}/types/IModel.d.ts +2 -2
  36. package/lib/unified-selection/types/IModel.d.ts.map +1 -0
  37. package/lib/unified-selection/types/IModel.js.map +1 -0
  38. package/lib/unified-selection.d.ts +16 -0
  39. package/lib/unified-selection.d.ts.map +1 -0
  40. package/lib/{esm/unified-selection.js → unified-selection.js} +2 -3
  41. package/lib/unified-selection.js.map +1 -0
  42. package/package.json +17 -19
  43. package/lib/cjs/package.json +0 -1
  44. package/lib/cjs/unified-selection/CachingHiliteSetProvider.d.ts.map +0 -1
  45. package/lib/cjs/unified-selection/CachingHiliteSetProvider.js +0 -27
  46. package/lib/cjs/unified-selection/CachingHiliteSetProvider.js.map +0 -1
  47. package/lib/cjs/unified-selection/DisposePolyfill.d.ts +0 -1
  48. package/lib/cjs/unified-selection/DisposePolyfill.d.ts.map +0 -1
  49. package/lib/cjs/unified-selection/DisposePolyfill.js +0 -11
  50. package/lib/cjs/unified-selection/DisposePolyfill.js.map +0 -1
  51. package/lib/cjs/unified-selection/EnableUnifiedSelectionSyncWithIModel.d.ts.map +0 -1
  52. package/lib/cjs/unified-selection/EnableUnifiedSelectionSyncWithIModel.js +0 -392
  53. package/lib/cjs/unified-selection/EnableUnifiedSelectionSyncWithIModel.js.map +0 -1
  54. package/lib/cjs/unified-selection/HiliteSetProvider.d.ts.map +0 -1
  55. package/lib/cjs/unified-selection/HiliteSetProvider.js +0 -382
  56. package/lib/cjs/unified-selection/HiliteSetProvider.js.map +0 -1
  57. package/lib/cjs/unified-selection/IModelHiliteSetProvider.d.ts +0 -51
  58. package/lib/cjs/unified-selection/IModelHiliteSetProvider.d.ts.map +0 -1
  59. package/lib/cjs/unified-selection/IModelHiliteSetProvider.js +0 -66
  60. package/lib/cjs/unified-selection/IModelHiliteSetProvider.js.map +0 -1
  61. package/lib/cjs/unified-selection/Selectable.d.ts +0 -150
  62. package/lib/cjs/unified-selection/Selectable.d.ts.map +0 -1
  63. package/lib/cjs/unified-selection/Selectable.js +0 -238
  64. package/lib/cjs/unified-selection/Selectable.js.map +0 -1
  65. package/lib/cjs/unified-selection/SelectionChangeEvent.d.ts.map +0 -1
  66. package/lib/cjs/unified-selection/SelectionChangeEvent.js +0 -7
  67. package/lib/cjs/unified-selection/SelectionChangeEvent.js.map +0 -1
  68. package/lib/cjs/unified-selection/SelectionScope.d.ts.map +0 -1
  69. package/lib/cjs/unified-selection/SelectionScope.js +0 -252
  70. package/lib/cjs/unified-selection/SelectionScope.js.map +0 -1
  71. package/lib/cjs/unified-selection/SelectionStorage.d.ts +0 -105
  72. package/lib/cjs/unified-selection/SelectionStorage.d.ts.map +0 -1
  73. package/lib/cjs/unified-selection/SelectionStorage.js +0 -153
  74. package/lib/cjs/unified-selection/SelectionStorage.js.map +0 -1
  75. package/lib/cjs/unified-selection/Utils.d.ts +0 -39
  76. package/lib/cjs/unified-selection/Utils.d.ts.map +0 -1
  77. package/lib/cjs/unified-selection/Utils.js +0 -82
  78. package/lib/cjs/unified-selection/Utils.js.map +0 -1
  79. package/lib/cjs/unified-selection/types/IModel.d.ts +0 -133
  80. package/lib/cjs/unified-selection/types/IModel.d.ts.map +0 -1
  81. package/lib/cjs/unified-selection/types/IModel.js +0 -24
  82. package/lib/cjs/unified-selection/types/IModel.js.map +0 -1
  83. package/lib/cjs/unified-selection.d.ts +0 -10
  84. package/lib/cjs/unified-selection.d.ts.map +0 -1
  85. package/lib/cjs/unified-selection.js +0 -27
  86. package/lib/cjs/unified-selection.js.map +0 -1
  87. package/lib/esm/unified-selection/CachingHiliteSetProvider.d.ts +0 -56
  88. package/lib/esm/unified-selection/CachingHiliteSetProvider.d.ts.map +0 -1
  89. package/lib/esm/unified-selection/CachingHiliteSetProvider.js.map +0 -1
  90. package/lib/esm/unified-selection/DisposePolyfill.d.ts.map +0 -1
  91. package/lib/esm/unified-selection/DisposePolyfill.js.map +0 -1
  92. package/lib/esm/unified-selection/EnableUnifiedSelectionSyncWithIModel.d.ts +0 -119
  93. package/lib/esm/unified-selection/EnableUnifiedSelectionSyncWithIModel.d.ts.map +0 -1
  94. package/lib/esm/unified-selection/EnableUnifiedSelectionSyncWithIModel.js.map +0 -1
  95. package/lib/esm/unified-selection/HiliteSetProvider.d.ts +0 -48
  96. package/lib/esm/unified-selection/HiliteSetProvider.d.ts.map +0 -1
  97. package/lib/esm/unified-selection/HiliteSetProvider.js.map +0 -1
  98. package/lib/esm/unified-selection/IModelHiliteSetProvider.d.ts.map +0 -1
  99. package/lib/esm/unified-selection/IModelHiliteSetProvider.js.map +0 -1
  100. package/lib/esm/unified-selection/Selectable.d.ts.map +0 -1
  101. package/lib/esm/unified-selection/Selectable.js.map +0 -1
  102. package/lib/esm/unified-selection/SelectionChangeEvent.d.ts +0 -60
  103. package/lib/esm/unified-selection/SelectionChangeEvent.d.ts.map +0 -1
  104. package/lib/esm/unified-selection/SelectionChangeEvent.js.map +0 -1
  105. package/lib/esm/unified-selection/SelectionScope.d.ts +0 -54
  106. package/lib/esm/unified-selection/SelectionScope.d.ts.map +0 -1
  107. package/lib/esm/unified-selection/SelectionScope.js.map +0 -1
  108. package/lib/esm/unified-selection/SelectionStorage.d.ts.map +0 -1
  109. package/lib/esm/unified-selection/SelectionStorage.js.map +0 -1
  110. package/lib/esm/unified-selection/Utils.d.ts.map +0 -1
  111. package/lib/esm/unified-selection/Utils.js.map +0 -1
  112. package/lib/esm/unified-selection/types/IModel.d.ts.map +0 -1
  113. package/lib/esm/unified-selection/types/IModel.js.map +0 -1
  114. package/lib/esm/unified-selection.d.ts +0 -10
  115. package/lib/esm/unified-selection.d.ts.map +0 -1
  116. package/lib/esm/unified-selection.js.map +0 -1
  117. /package/lib/{esm/unified-selection → unified-selection}/CachingHiliteSetProvider.js +0 -0
  118. /package/lib/{esm/unified-selection → unified-selection}/DisposePolyfill.d.ts +0 -0
  119. /package/lib/{esm/unified-selection → unified-selection}/DisposePolyfill.js +0 -0
  120. /package/lib/{esm/unified-selection → unified-selection}/IModelHiliteSetProvider.js +0 -0
  121. /package/lib/{esm/unified-selection → unified-selection}/Selectable.js +0 -0
  122. /package/lib/{esm/unified-selection → unified-selection}/SelectionChangeEvent.js +0 -0
  123. /package/lib/{esm/unified-selection → unified-selection}/SelectionScope.js +0 -0
  124. /package/lib/{esm/unified-selection → unified-selection}/SelectionStorage.js +0 -0
  125. /package/lib/{esm/unified-selection → unified-selection}/types/IModel.js +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"file":"IModelHiliteSetProvider.js","sourceRoot":"","sources":["../../../src/unified-selection/IModelHiliteSetProvider.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;AA8DhG,sEAEC;AA9DD,gCAA8B;AAE9B,+BAAqD;AACrD,mDAA+C;AAE/C,iEAA+F;AAE/F,+DAAyF;AA6CzF;;;;;;;GAOG;AACH,SAAgB,6BAA6B,CAAC,KAAmC;IAC/E,OAAO,IAAI,2BAA2B,CAAC,KAAK,CAAC,CAAC;AAChD,CAAC;AAED,MAAM,2BAA2B;IACvB,iBAAiB,CAAmB;IACpC,mBAAmB,GAAG,IAAI,GAAG,EAA6B,CAAC;IAC3D,MAAM,GAAG,IAAI,GAAG,EAAiC,CAAC;IAClD,eAAe,CAAa;IAC5B,eAAe,CAAwE;IACvF,wBAAwB,CAAiC;IAEjE,YAAY,KAAmC;QAC7C,IAAI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AAC;YACvE,SAAS,GAAG,IAAA,WAAI,EAAC,IAAI,CAAC,oBAAoB,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,YAAY,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,IAAI,CAC3F,IAAA,kBAAW,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAChC,CAAC;YACF,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QACxC,CAAC;QACD,OAAO,IAAA,8BAAa,EAAC,SAAS,CAAC,CAAC;IAClC,CAAC;IAEM,CAAC,MAAM,CAAC,OAAO,CAAC;QACrB,IAAI,CAAC,eAAe,EAAE,CAAC;QACvB,IAAI,CAAC,mBAAmB,GAAG,IAAI,GAAG,EAAE,CAAC;QACrC,IAAI,CAAC,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;IAC1B,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\nimport \"./DisposePolyfill.js\";\n\nimport { from, Observable, shareReplay } from \"rxjs\";\nimport { eachValueFrom } from \"rxjs-for-await\";\nimport { ECClassHierarchyInspector, ECSqlQueryExecutor } from \"@itwin/presentation-shared\";\nimport { createHiliteSetProvider, HiliteSet, HiliteSetProvider } from \"./HiliteSetProvider.js\";\nimport { StorageSelectionChangeEventArgs } from \"./SelectionChangeEvent.js\";\nimport { CLEAR_SELECTION_STORAGE_SOURCE, SelectionStorage } from \"./SelectionStorage.js\";\n\n/**\n * Props for creating an `IModelHiliteSetProvider` instance.\n * @public\n */\nexport interface IModelHiliteSetProviderProps {\n /** Selection storage to use for retrieving the hilite set. */\n selectionStorage: SelectionStorage;\n\n /** A callback that should return iModel access by iModel key. */\n imodelProvider: (imodelKey: string) => ECClassHierarchyInspector & ECSqlQueryExecutor;\n\n /** An optional hilite set provider factory. If not provided, defaults to `createHiliteSetProvider` from this package. */\n createHiliteSetProvider?: typeof createHiliteSetProvider;\n}\n\n/**\n * Defines return value of `createIModelHiliteSetProvider`.\n *\n * **Warning:** Used in public API as a return value. Not expected to be created / extended by package\n * consumers, may be supplemented with required attributes any time.\n *\n * @see `createIModelHiliteSetProvider`\n * @public\n */\nexport interface IModelHiliteSetProvider {\n /** Get the hilite set provider for the specified iModel. */\n getHiliteSetProvider(props: {\n /** iModel to get hilite set provider for */\n imodelKey: string;\n }): HiliteSetProvider;\n\n /** Get the hilite set iterator for active selection in the specified iModel. */\n getCurrentHiliteSet(props: {\n /** iModel to get hilite set for */\n imodelKey: string;\n }): AsyncIterableIterator<HiliteSet>;\n\n /**\n * Disposes the cache.\n */\n [Symbol.dispose]: () => void;\n}\n\n/**\n * Creates a hilite set provider that can efficiently get a hilite set for the \"active\" selection in an iModel.\n *\n * This specific implementation caches the hilite set for the current selection, so subsequent hilite set\n * requests for the same iModel, don't cost until selection changes.\n *\n * @public\n */\nexport function createIModelHiliteSetProvider(props: IModelHiliteSetProviderProps): IModelHiliteSetProvider {\n return new IModelHiliteSetProviderImpl(props);\n}\n\nclass IModelHiliteSetProviderImpl implements IModelHiliteSetProvider {\n private _selectionStorage: SelectionStorage;\n private _hiliteSetProviders = new Map<string, HiliteSetProvider>();\n private _cache = new Map<string, Observable<HiliteSet>>();\n private _removeListener: () => void;\n private _imodelProvider: (imodelKey: string) => ECClassHierarchyInspector & ECSqlQueryExecutor;\n private _createHiliteSetProvider: typeof createHiliteSetProvider;\n\n constructor(props: IModelHiliteSetProviderProps) {\n this._selectionStorage = props.selectionStorage;\n this._imodelProvider = props.imodelProvider;\n this._removeListener = this._selectionStorage.selectionChangeEvent.addListener(\n (args: StorageSelectionChangeEventArgs) => {\n this._cache.delete(args.imodelKey);\n if (args.changeType === \"clear\" && args.source === CLEAR_SELECTION_STORAGE_SOURCE) {\n this._hiliteSetProviders.delete(args.imodelKey);\n }\n },\n );\n /* v8 ignore next -- @preserve */\n this._createHiliteSetProvider = props.createHiliteSetProvider ?? createHiliteSetProvider;\n }\n\n public getHiliteSetProvider({ imodelKey }: { imodelKey: string }): HiliteSetProvider {\n let provider = this._hiliteSetProviders.get(imodelKey);\n if (!provider) {\n provider = this._createHiliteSetProvider({ imodelAccess: this._imodelProvider(imodelKey) });\n this._hiliteSetProviders.set(imodelKey, provider);\n }\n return provider;\n }\n\n public getCurrentHiliteSet({ imodelKey }: { imodelKey: string }): AsyncIterableIterator<HiliteSet> {\n let hiliteSet = this._cache.get(imodelKey);\n if (!hiliteSet) {\n const selectables = this._selectionStorage.getSelection({ imodelKey });\n hiliteSet = from(this.getHiliteSetProvider({ imodelKey }).getHiliteSet({ selectables })).pipe(\n shareReplay({ refCount: true }),\n );\n this._cache.set(imodelKey, hiliteSet);\n }\n return eachValueFrom(hiliteSet);\n }\n\n public [Symbol.dispose](): void {\n this._removeListener();\n this._hiliteSetProviders = new Map();\n this._cache = new Map();\n }\n}\n"]}
@@ -1,150 +0,0 @@
1
- import { Id64String } from "@itwin/core-bentley";
2
- /**
3
- * ECInstance selectable
4
- * @public
5
- */
6
- export interface SelectableInstanceKey {
7
- /**
8
- * Full class name in format `SchemaName:ClassName` or `SchemaName.ClassName` for
9
- * persistent instances or `TRANSIENT_ELEMENT_CLASSNAME` for transient instances.
10
- */
11
- className: string;
12
- /** ECInstance ID */
13
- id: string;
14
- }
15
- /**
16
- * A custom selectable, which has an identifier, knows how to loads its associated selectable instance keys
17
- * and has custom data associated with it.
18
- *
19
- * An example of such selectable could be an instance grouping node:
20
- * - `identifier` could be a GUID, associated with the node,
21
- * - `loadInstanceKeys` would know how to load grouped instance keys from the node,
22
- * - `data` could be set to the node itself.
23
- *
24
- * @public
25
- */
26
- export interface CustomSelectable {
27
- /** Unique identifier of the selectable. */
28
- identifier: string;
29
- /** Asynchronous function for loading instance keys associated with this selectable. */
30
- loadInstanceKeys: () => AsyncIterableIterator<SelectableInstanceKey>;
31
- /** Custom data associated with the selectable. */
32
- data: unknown;
33
- }
34
- /**
35
- * A single selectable that identifies something that can be selected in an iTwin.js application.
36
- * @public
37
- */
38
- export type Selectable = SelectableInstanceKey | CustomSelectable;
39
- /**
40
- * A type of identifier that can be used to identify a selectable in selection storage.
41
- * @public
42
- */
43
- export type SelectableIdentifier = SelectableInstanceKey | Pick<CustomSelectable, "identifier">;
44
- /** @public */
45
- export declare namespace Selectable {
46
- /** Check if the supplied selectable is a `SelectableInstanceKey` */
47
- function isInstanceKey(selectable: Selectable | SelectableIdentifier): selectable is SelectableInstanceKey;
48
- /** Check if the supplied selectable is a `CustomSelectable` */
49
- function isCustom(selectable: Selectable): selectable is CustomSelectable;
50
- }
51
- /**
52
- * A collection of selectables that identify something that can be selected in an iTwin.js application
53
- * @public
54
- */
55
- export interface Selectables {
56
- /**
57
- * A map between `SelectableInstanceKey.className` and a set of selected instance IDs.
58
- */
59
- instanceKeys: Map<string, Set<Id64String>>;
60
- /**
61
- * A map between `CustomSelectable.identifier` and the selectable itself.
62
- */
63
- custom: Map<string, CustomSelectable>;
64
- }
65
- /**
66
- * Class name used to create `SelectableInstanceKey` for transient elements.
67
- * @public
68
- */
69
- export declare const TRANSIENT_ELEMENT_CLASSNAME = "/TRANSIENT";
70
- /** @public */
71
- export declare namespace Selectables {
72
- /**
73
- * Creates `Selectables` from array of selectable
74
- * @param source Source to create selectables from
75
- * @public
76
- */
77
- function create(source: Selectable[]): Selectables;
78
- /**
79
- * Get the number of selectables stored in a `Selectables` object.
80
- * @param selectables `Selectables` object to get size for
81
- * @public
82
- */
83
- function size(selectables: Selectables): number;
84
- /**
85
- * Is a `Selectables` object currently empty.
86
- * @param selectables `Selectables` object to check
87
- * @public
88
- */
89
- function isEmpty(selectables: Selectables): boolean;
90
- /**
91
- * Check if a `Selectables` object contains the specified selectable.
92
- * @param selectables `Selectables` object to check
93
- * @param value The selectable to check for.
94
- * @public
95
- */
96
- function has(selectables: Selectables, value: SelectableIdentifier): boolean;
97
- /**
98
- * Check if a `Selectables` object contains all the specified selectables.
99
- * @param selectables `Selectables` object to check
100
- * @param values The selectables to check for.
101
- * @public
102
- */
103
- function hasAll(selectables: Selectables, values: SelectableIdentifier[]): boolean;
104
- /**
105
- * Check if a `Selectables` object contains any of the specified selectables.
106
- * @param selectables `Selectables` object to check
107
- * @param values The selectables to check for.
108
- * @public
109
- */
110
- function hasAny(selectables: Selectables, values: SelectableIdentifier[]): boolean;
111
- /**
112
- * Add a one or more selectables to a `Selectables`
113
- * @param selectables `Selectables` object to add selectables for
114
- * @param values Selectables to add.
115
- * @public
116
- */
117
- function add(selectables: Selectables, values: Selectable[]): boolean;
118
- /**
119
- * Removes one or more selectables from a `Selectables` object.
120
- * @param selectables `Selectables` object to remove selectables for
121
- * @param values Selectables to remove.
122
- * @public
123
- */
124
- function remove(selectables: Selectables, values: Selectable[]): boolean;
125
- /**
126
- * Clear a `Selectables` object.
127
- * @param selectables `Selectables` object to clear selectables for
128
- * @public
129
- */
130
- function clear(selectables: Selectables): boolean;
131
- /**
132
- * Check whether at least one selectable passes a condition in a `Selectables` object.
133
- * @param selectables `Selectables` object to check
134
- * @public
135
- */
136
- function some(selectables: Selectables, callback: (selectable: Selectable) => boolean): boolean;
137
- /**
138
- * Iterate over all keys in a `Selectables` object.
139
- * @param selectables `Selectables` object to iterate over
140
- * @public
141
- */
142
- function forEach(selectables: Selectables, callback: (selectable: Selectable, index: number) => void): void;
143
- /**
144
- * Load all instance keys from the given `Selectables` object.
145
- * @param selectables `Selectables` object to load instance keys from
146
- * @public
147
- */
148
- function load(selectables: Selectables): AsyncIterableIterator<SelectableInstanceKey>;
149
- }
150
- //# sourceMappingURL=Selectable.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Selectable.d.ts","sourceRoot":"","sources":["../../../src/unified-selection/Selectable.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAIjD;;;GAGG;AACH,MAAM,WAAW,qBAAq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AAW,EAAE,WAAW,GAAG,OAAO,CAEzD;IAED;;;;;OAKG;IACH,SAAgB,GAAG,CAAC,WAAW,EAAE,WAAW,EAAE,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAOlF;IAED;;;;;OAKG;IACH,SAAgB,MAAM,CAAC,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,oBAAoB,EAAE,GAAG,OAAO,CAUxF;IAED;;;;;OAKG;IACH,SAAgB,MAAM,CAAC,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,oBAAoB,EAAE,GAAG,OAAO,CAOxF;IAED;;;;;OAKG;IACH,SAAgB,GAAG,CAAC,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAoB3E;IAED;;;;;OAKG;IACH,SAAgB,MAAM,CAAC,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAmB9E;IAED;;;;OAIG;IACH,SAAgB,KAAK,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAOvD;IAED;;;;OAIG;IACH,SAAgB,IAAI,CAAC,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,OAAO,WAc3F;IAED;;;;OAIG;IACH,SAAgB,OAAO,CAAC,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,QAQ1G;IAED;;;;OAIG;IACH,SAAgB,IAAI,CAAC,WAAW,EAAE,WAAW,GAAG,qBAAqB,CAAC,qBAAqB,CAAC,CAc3F;CACF"}
@@ -1,238 +0,0 @@
1
- "use strict";
2
- /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
- * See LICENSE.md in the project root for license terms and full copyright notice.
5
- *--------------------------------------------------------------------------------------------*/
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.Selectables = exports.TRANSIENT_ELEMENT_CLASSNAME = exports.Selectable = void 0;
8
- const rxjs_1 = require("rxjs");
9
- const rxjs_for_await_1 = require("rxjs-for-await");
10
- const presentation_shared_1 = require("@itwin/presentation-shared");
11
- const Utils_js_1 = require("./Utils.js");
12
- /** @public */
13
- // eslint-disable-next-line @typescript-eslint/no-redeclare
14
- var Selectable;
15
- (function (Selectable) {
16
- /** Check if the supplied selectable is a `SelectableInstanceKey` */
17
- function isInstanceKey(selectable) {
18
- const instanceKey = selectable;
19
- return !!instanceKey.className && !!instanceKey.id;
20
- }
21
- Selectable.isInstanceKey = isInstanceKey;
22
- /** Check if the supplied selectable is a `CustomSelectable` */
23
- function isCustom(selectable) {
24
- return !!selectable.identifier;
25
- }
26
- Selectable.isCustom = isCustom;
27
- })(Selectable || (exports.Selectable = Selectable = {}));
28
- /**
29
- * Class name used to create `SelectableInstanceKey` for transient elements.
30
- * @public
31
- */
32
- exports.TRANSIENT_ELEMENT_CLASSNAME = "/TRANSIENT";
33
- /** @public */
34
- var Selectables;
35
- (function (Selectables) {
36
- /**
37
- * Creates `Selectables` from array of selectable
38
- * @param source Source to create selectables from
39
- * @public
40
- */
41
- function create(source) {
42
- const newSelectables = {
43
- instanceKeys: new Map(),
44
- custom: new Map(),
45
- };
46
- Selectables.add(newSelectables, source);
47
- return newSelectables;
48
- }
49
- Selectables.create = create;
50
- /**
51
- * Get the number of selectables stored in a `Selectables` object.
52
- * @param selectables `Selectables` object to get size for
53
- * @public
54
- */
55
- function size(selectables) {
56
- let instanceCount = 0;
57
- selectables.instanceKeys.forEach((set) => (instanceCount += set.size));
58
- return instanceCount + selectables.custom.size;
59
- }
60
- Selectables.size = size;
61
- /**
62
- * Is a `Selectables` object currently empty.
63
- * @param selectables `Selectables` object to check
64
- * @public
65
- */
66
- function isEmpty(selectables) {
67
- return Selectables.size(selectables) === 0;
68
- }
69
- Selectables.isEmpty = isEmpty;
70
- /**
71
- * Check if a `Selectables` object contains the specified selectable.
72
- * @param selectables `Selectables` object to check
73
- * @param value The selectable to check for.
74
- * @public
75
- */
76
- function has(selectables, value) {
77
- if (Selectable.isInstanceKey(value)) {
78
- const normalizedClassName = normalizeClassName(value.className);
79
- const set = selectables.instanceKeys.get(normalizedClassName);
80
- return !!(set && set.has(value.id));
81
- }
82
- return selectables.custom.has(value.identifier);
83
- }
84
- Selectables.has = has;
85
- /**
86
- * Check if a `Selectables` object contains all the specified selectables.
87
- * @param selectables `Selectables` object to check
88
- * @param values The selectables to check for.
89
- * @public
90
- */
91
- function hasAll(selectables, values) {
92
- if (Selectables.size(selectables) < values.length) {
93
- return false;
94
- }
95
- for (const selectable of values) {
96
- if (!Selectables.has(selectables, selectable)) {
97
- return false;
98
- }
99
- }
100
- return true;
101
- }
102
- Selectables.hasAll = hasAll;
103
- /**
104
- * Check if a `Selectables` object contains any of the specified selectables.
105
- * @param selectables `Selectables` object to check
106
- * @param values The selectables to check for.
107
- * @public
108
- */
109
- function hasAny(selectables, values) {
110
- for (const selectable of values) {
111
- if (Selectables.has(selectables, selectable)) {
112
- return true;
113
- }
114
- }
115
- return false;
116
- }
117
- Selectables.hasAny = hasAny;
118
- /**
119
- * Add a one or more selectables to a `Selectables`
120
- * @param selectables `Selectables` object to add selectables for
121
- * @param values Selectables to add.
122
- * @public
123
- */
124
- function add(selectables, values) {
125
- let hasChanged = false;
126
- for (const selectable of values) {
127
- if (Selectable.isInstanceKey(selectable)) {
128
- const normalizedClassName = normalizeClassName(selectable.className);
129
- let set = selectables.instanceKeys.get(normalizedClassName);
130
- if (!set) {
131
- set = new Set();
132
- }
133
- if (!set.has(selectable.id)) {
134
- set.add(selectable.id);
135
- selectables.instanceKeys.set(normalizedClassName, set);
136
- hasChanged = true;
137
- }
138
- }
139
- else if (!selectables.custom.has(selectable.identifier)) {
140
- selectables.custom.set(selectable.identifier, selectable);
141
- hasChanged = true;
142
- }
143
- }
144
- return hasChanged;
145
- }
146
- Selectables.add = add;
147
- /**
148
- * Removes one or more selectables from a `Selectables` object.
149
- * @param selectables `Selectables` object to remove selectables for
150
- * @param values Selectables to remove.
151
- * @public
152
- */
153
- function remove(selectables, values) {
154
- let hasChanged = false;
155
- for (const selectable of values) {
156
- if (Selectable.isInstanceKey(selectable)) {
157
- const normalizedClassName = normalizeClassName(selectable.className);
158
- const set = selectables.instanceKeys.get(normalizedClassName);
159
- if (set && set.has(selectable.id)) {
160
- set.delete(selectable.id);
161
- hasChanged = true;
162
- if (set.size === 0) {
163
- selectables.instanceKeys.delete(normalizedClassName);
164
- }
165
- }
166
- }
167
- else if (selectables.custom.has(selectable.identifier)) {
168
- selectables.custom.delete(selectable.identifier);
169
- hasChanged = true;
170
- }
171
- }
172
- return hasChanged;
173
- }
174
- Selectables.remove = remove;
175
- /**
176
- * Clear a `Selectables` object.
177
- * @param selectables `Selectables` object to clear selectables for
178
- * @public
179
- */
180
- function clear(selectables) {
181
- if (Selectables.size(selectables) === 0) {
182
- return false;
183
- }
184
- selectables.instanceKeys = new Map();
185
- selectables.custom = new Map();
186
- return true;
187
- }
188
- Selectables.clear = clear;
189
- /**
190
- * Check whether at least one selectable passes a condition in a `Selectables` object.
191
- * @param selectables `Selectables` object to check
192
- * @public
193
- */
194
- function some(selectables, callback) {
195
- for (const entry of selectables.instanceKeys) {
196
- for (const item of entry[1]) {
197
- if (callback({ className: entry[0], id: item })) {
198
- return true;
199
- }
200
- }
201
- }
202
- for (const entry of selectables.custom) {
203
- if (callback(entry[1])) {
204
- return true;
205
- }
206
- }
207
- return false;
208
- }
209
- Selectables.some = some;
210
- /**
211
- * Iterate over all keys in a `Selectables` object.
212
- * @param selectables `Selectables` object to iterate over
213
- * @public
214
- */
215
- function forEach(selectables, callback) {
216
- let index = 0;
217
- selectables.instanceKeys.forEach((ids, className) => {
218
- ids.forEach((id) => callback({ className, id }, index++));
219
- });
220
- selectables.custom.forEach((data) => {
221
- callback(data, index++);
222
- });
223
- }
224
- Selectables.forEach = forEach;
225
- /**
226
- * Load all instance keys from the given `Selectables` object.
227
- * @param selectables `Selectables` object to load instance keys from
228
- * @public
229
- */
230
- function load(selectables) {
231
- return (0, rxjs_for_await_1.eachValueFrom)((0, rxjs_1.merge)((0, rxjs_1.from)(selectables.instanceKeys).pipe((0, rxjs_1.mergeMap)(([className, ids]) => (0, rxjs_1.from)(ids).pipe((0, Utils_js_1.releaseMainThreadOnItemsCount)(1000), (0, rxjs_1.map)((id) => ({ className, id }))))), (0, rxjs_1.from)(selectables.custom).pipe((0, rxjs_1.mergeMap)(([_, selectable]) => (0, rxjs_1.from)(selectable.loadInstanceKeys())))));
232
- }
233
- Selectables.load = load;
234
- })(Selectables || (exports.Selectables = Selectables = {}));
235
- function normalizeClassName(fullClassName) {
236
- return fullClassName === exports.TRANSIENT_ELEMENT_CLASSNAME ? fullClassName : (0, presentation_shared_1.normalizeFullClassName)(fullClassName);
237
- }
238
- //# sourceMappingURL=Selectable.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Selectable.js","sourceRoot":"","sources":["../../../src/unified-selection/Selectable.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,+BAAkD;AAClD,mDAA+C;AAE/C,oEAAoE;AACpE,yCAA2D;AAiD3D,cAAc;AACd,2DAA2D;AAC3D,IAAiB,UAAU,CAW1B;AAXD,WAAiB,UAAU;IACzB,oEAAoE;IACpE,SAAgB,aAAa,CAAC,UAA6C;QACzE,MAAM,WAAW,GAAG,UAAmC,CAAC;QACxD,OAAO,CAAC,CAAC,WAAW,CAAC,SAAS,IAAI,CAAC,CAAC,WAAW,CAAC,EAAE,CAAC;IACrD,CAAC;IAHe,wBAAa,gBAG5B,CAAA;IAED,+DAA+D;IAC/D,SAAgB,QAAQ,CAAC,UAAsB;QAC7C,OAAO,CAAC,CAAE,UAA+B,CAAC,UAAU,CAAC;IACvD,CAAC;IAFe,mBAAQ,WAEvB,CAAA;AACH,CAAC,EAXgB,UAAU,0BAAV,UAAU,QAW1B;AAiBD;;;GAGG;AACU,QAAA,2BAA2B,GAAG,YAAY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AX,WAAW,QAgN3B;AAED,SAAS,kBAAkB,CAAC,aAAqB;IAC/C,OAAO,aAAa,KAAK,mCAA2B,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,IAAA,4CAAsB,EAAC,aAAa,CAAC,CAAC;AAC/G,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 { from, map, merge, mergeMap } from \"rxjs\";\nimport { eachValueFrom } from \"rxjs-for-await\";\nimport { Id64String } from \"@itwin/core-bentley\";\nimport { normalizeFullClassName } from \"@itwin/presentation-shared\";\nimport { releaseMainThreadOnItemsCount } from \"./Utils.js\";\n\n/**\n * ECInstance selectable\n * @public\n */\nexport interface SelectableInstanceKey {\n /**\n * Full class name in format `SchemaName:ClassName` or `SchemaName.ClassName` for\n * persistent instances or `TRANSIENT_ELEMENT_CLASSNAME` for transient instances.\n */\n className: string;\n\n /** ECInstance ID */\n id: string;\n}\n\n/**\n * A custom selectable, which has an identifier, knows how to loads its associated selectable instance keys\n * and has custom data associated with it.\n *\n * An example of such selectable could be an instance grouping node:\n * - `identifier` could be a GUID, associated with the node,\n * - `loadInstanceKeys` would know how to load grouped instance keys from the node,\n * - `data` could be set to the node itself.\n *\n * @public\n */\nexport interface CustomSelectable {\n /** Unique identifier of the selectable. */\n identifier: string;\n /** Asynchronous function for loading instance keys associated with this selectable. */\n loadInstanceKeys: () => AsyncIterableIterator<SelectableInstanceKey>;\n /** Custom data associated with the selectable. */\n data: unknown;\n}\n\n/**\n * A single selectable that identifies something that can be selected in an iTwin.js application.\n * @public\n */\nexport type Selectable = SelectableInstanceKey | CustomSelectable;\n\n/**\n * A type of identifier that can be used to identify a selectable in selection storage.\n * @public\n */\nexport type SelectableIdentifier = SelectableInstanceKey | Pick<CustomSelectable, \"identifier\">;\n\n/** @public */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace Selectable {\n /** Check if the supplied selectable is a `SelectableInstanceKey` */\n export function isInstanceKey(selectable: Selectable | SelectableIdentifier): selectable is SelectableInstanceKey {\n const instanceKey = selectable as SelectableInstanceKey;\n return !!instanceKey.className && !!instanceKey.id;\n }\n\n /** Check if the supplied selectable is a `CustomSelectable` */\n export function isCustom(selectable: Selectable): selectable is CustomSelectable {\n return !!(selectable as CustomSelectable).identifier;\n }\n}\n\n/**\n * A collection of selectables that identify something that can be selected in an iTwin.js application\n * @public\n */\nexport interface Selectables {\n /**\n * A map between `SelectableInstanceKey.className` and a set of selected instance IDs.\n */\n instanceKeys: Map<string, Set<Id64String>>;\n /**\n * A map between `CustomSelectable.identifier` and the selectable itself.\n */\n custom: Map<string, CustomSelectable>;\n}\n\n/**\n * Class name used to create `SelectableInstanceKey` for transient elements.\n * @public\n */\nexport const TRANSIENT_ELEMENT_CLASSNAME = \"/TRANSIENT\";\n\n/** @public */\nexport namespace Selectables {\n /**\n * Creates `Selectables` from array of selectable\n * @param source Source to create selectables from\n * @public\n */\n export function create(source: Selectable[]): Selectables {\n const newSelectables = {\n instanceKeys: new Map<string, Set<string>>(),\n custom: new Map<string, CustomSelectable>(),\n };\n Selectables.add(newSelectables, source);\n return newSelectables;\n }\n\n /**\n * Get the number of selectables stored in a `Selectables` object.\n * @param selectables `Selectables` object to get size for\n * @public\n */\n export function size(selectables: Selectables): number {\n let instanceCount = 0;\n selectables.instanceKeys.forEach((set: Set<string>) => (instanceCount += set.size));\n return instanceCount + selectables.custom.size;\n }\n\n /**\n * Is a `Selectables` object currently empty.\n * @param selectables `Selectables` object to check\n * @public\n */\n export function isEmpty(selectables: Selectables): boolean {\n return Selectables.size(selectables) === 0;\n }\n\n /**\n * Check if a `Selectables` object contains the specified selectable.\n * @param selectables `Selectables` object to check\n * @param value The selectable to check for.\n * @public\n */\n export function has(selectables: Selectables, value: SelectableIdentifier): boolean {\n if (Selectable.isInstanceKey(value)) {\n const normalizedClassName = normalizeClassName(value.className);\n const set = selectables.instanceKeys.get(normalizedClassName);\n return !!(set && set.has(value.id));\n }\n return selectables.custom.has(value.identifier);\n }\n\n /**\n * Check if a `Selectables` object contains all the specified selectables.\n * @param selectables `Selectables` object to check\n * @param values The selectables to check for.\n * @public\n */\n export function hasAll(selectables: Selectables, values: SelectableIdentifier[]): boolean {\n if (Selectables.size(selectables) < values.length) {\n return false;\n }\n for (const selectable of values) {\n if (!Selectables.has(selectables, selectable)) {\n return false;\n }\n }\n return true;\n }\n\n /**\n * Check if a `Selectables` object contains any of the specified selectables.\n * @param selectables `Selectables` object to check\n * @param values The selectables to check for.\n * @public\n */\n export function hasAny(selectables: Selectables, values: SelectableIdentifier[]): boolean {\n for (const selectable of values) {\n if (Selectables.has(selectables, selectable)) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Add a one or more selectables to a `Selectables`\n * @param selectables `Selectables` object to add selectables for\n * @param values Selectables to add.\n * @public\n */\n export function add(selectables: Selectables, values: Selectable[]): boolean {\n let hasChanged = false;\n for (const selectable of values) {\n if (Selectable.isInstanceKey(selectable)) {\n const normalizedClassName = normalizeClassName(selectable.className);\n let set = selectables.instanceKeys.get(normalizedClassName);\n if (!set) {\n set = new Set<string>();\n }\n if (!set.has(selectable.id)) {\n set.add(selectable.id);\n selectables.instanceKeys.set(normalizedClassName, set);\n hasChanged = true;\n }\n } else if (!selectables.custom.has(selectable.identifier)) {\n selectables.custom.set(selectable.identifier, selectable);\n hasChanged = true;\n }\n }\n return hasChanged;\n }\n\n /**\n * Removes one or more selectables from a `Selectables` object.\n * @param selectables `Selectables` object to remove selectables for\n * @param values Selectables to remove.\n * @public\n */\n export function remove(selectables: Selectables, values: Selectable[]): boolean {\n let hasChanged = false;\n for (const selectable of values) {\n if (Selectable.isInstanceKey(selectable)) {\n const normalizedClassName = normalizeClassName(selectable.className);\n const set = selectables.instanceKeys.get(normalizedClassName);\n if (set && set.has(selectable.id)) {\n set.delete(selectable.id);\n hasChanged = true;\n if (set.size === 0) {\n selectables.instanceKeys.delete(normalizedClassName);\n }\n }\n } else if (selectables.custom.has(selectable.identifier)) {\n selectables.custom.delete(selectable.identifier);\n hasChanged = true;\n }\n }\n return hasChanged;\n }\n\n /**\n * Clear a `Selectables` object.\n * @param selectables `Selectables` object to clear selectables for\n * @public\n */\n export function clear(selectables: Selectables): boolean {\n if (Selectables.size(selectables) === 0) {\n return false;\n }\n selectables.instanceKeys = new Map<string, Set<string>>();\n selectables.custom = new Map<string, CustomSelectable>();\n return true;\n }\n\n /**\n * Check whether at least one selectable passes a condition in a `Selectables` object.\n * @param selectables `Selectables` object to check\n * @public\n */\n export function some(selectables: Selectables, callback: (selectable: Selectable) => boolean) {\n for (const entry of selectables.instanceKeys) {\n for (const item of entry[1]) {\n if (callback({ className: entry[0], id: item })) {\n return true;\n }\n }\n }\n for (const entry of selectables.custom) {\n if (callback(entry[1])) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Iterate over all keys in a `Selectables` object.\n * @param selectables `Selectables` object to iterate over\n * @public\n */\n export function forEach(selectables: Selectables, callback: (selectable: Selectable, index: number) => void) {\n let index = 0;\n selectables.instanceKeys.forEach((ids: Set<string>, className: string) => {\n ids.forEach((id: string) => callback({ className, id }, index++));\n });\n selectables.custom.forEach((data) => {\n callback(data, index++);\n });\n }\n\n /**\n * Load all instance keys from the given `Selectables` object.\n * @param selectables `Selectables` object to load instance keys from\n * @public\n */\n export function load(selectables: Selectables): AsyncIterableIterator<SelectableInstanceKey> {\n return eachValueFrom(\n merge(\n from(selectables.instanceKeys).pipe(\n mergeMap(([className, ids]) =>\n from(ids).pipe(\n releaseMainThreadOnItemsCount(1000),\n map((id) => ({ className, id })),\n ),\n ),\n ),\n from(selectables.custom).pipe(mergeMap(([_, selectable]) => from(selectable.loadInstanceKeys()))),\n ),\n );\n }\n}\n\nfunction normalizeClassName(fullClassName: string) {\n return fullClassName === TRANSIENT_ELEMENT_CLASSNAME ? fullClassName : normalizeFullClassName(fullClassName);\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"SelectionChangeEvent.d.ts","sourceRoot":"","sources":["../../../src/unified-selection/SelectionChangeEvent.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD;;;GAGG;AACH,MAAM,MAAM,0BAA0B;AACpC,0BAA0B;AACxB,KAAK;AACP,8BAA8B;GAC5B,QAAQ;AACV,8BAA8B;GAC5B,SAAS;AACX,6BAA6B;GAC3B,OAAO,CAAC;AAEZ;;;;;;;;GAQG;AACH,MAAM,WAAW,+BAA+B;IAC9C,0EAA0E;IAC1E,MAAM,EAAE,MAAM,CAAC;IACf,8BAA8B;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,iCAAiC;IACjC,UAAU,EAAE,0BAA0B,CAAC;IACvC,2DAA2D;IAC3D,WAAW,EAAE,WAAW,CAAC;IACzB;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;;;;OAKG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB,2DAA2D;IAC3D,SAAS,EAAE,IAAI,CAAC;IAChB,sDAAsD;IACtD,OAAO,EAAE,gBAAgB,CAAC;CAC3B;AAED;;;GAGG;AACH,MAAM,MAAM,+BAA+B,GAAG;AAC5C,+CAA+C;AAC/C,IAAI,EAAE,+BAA+B;AACrC,2DAA2D;AAC3D,CAAC,CAAC,EAAE,GAAG,KACJ,IAAI,CAAC"}
@@ -1,7 +0,0 @@
1
- "use strict";
2
- /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
- * See LICENSE.md in the project root for license terms and full copyright notice.
5
- *--------------------------------------------------------------------------------------------*/
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- //# sourceMappingURL=SelectionChangeEvent.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SelectionChangeEvent.js","sourceRoot":"","sources":["../../../src/unified-selection/SelectionChangeEvent.ts"],"names":[],"mappings":";AAAA;;;gGAGgG","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 { Selectables } from \"./Selectable.js\";\nimport { SelectionStorage } from \"./SelectionStorage.js\";\n\n/**\n * The type of selection change.\n * @public\n */\nexport type StorageSelectionChangeType =\n /** Added to selection. */\n | \"add\"\n /** Removed from selection. */\n | \"remove\"\n /** Selection was replaced. */\n | \"replace\"\n /** Selection was cleared. */\n | \"clear\";\n\n/**\n * The event object that is sent when the selection changes.\n *\n * **Warning:** Used in public API as an input to consumer-supplied callback. Not expected to be created / extended\n * by package consumers, may be supplemented with required attributes any time.\n *\n * @see `StorageSelectionChangesListener`\n * @public\n */\nexport interface StorageSelectionChangeEventArgs {\n /** The name of the selection source which caused the selection change. */\n source: string;\n /** Level of the selection. */\n level: number;\n /** The selection change type. */\n changeType: StorageSelectionChangeType;\n /** Selectables affected by this selection change event. */\n selectables: Selectables;\n /**\n * iModel key with which the selection is associated with.\n * Set to an empty string if the selection change is not associated with any iModel.\n */\n imodelKey: string;\n /**\n * iModel key with which the selection is associated with.\n * Set to an empty string if the selection change is not associated with any iModel.\n *\n * @deprecated in 0.2. Use `imodelKey` instead.\n */\n iModelKey: string;\n /** The timestamp of when the selection change happened. */\n timestamp: Date;\n /** The selection storage where the event happened. */\n storage: SelectionStorage;\n}\n\n/**\n * An interface for selection change listeners.\n * @public\n */\nexport type StorageSelectionChangesListener = (\n /** Arguments for the selection change event */\n args: StorageSelectionChangeEventArgs,\n /** Unused. Temporarily left to avoid a breaking change. */\n _?: any,\n) => void;\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"SelectionScope.d.ts","sourceRoot":"","sources":["../../../src/unified-selection/SelectionScope.ts"],"names":[],"mappings":"AAKA,OAAO,EAAc,OAAO,EAAsB,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAGL,kBAAkB,EAGnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,qBAAqB,EAA+B,MAAM,iBAAiB,CAAC;AAGrF;;;GAGG;AACH,KAAK,wBAAwB,GAAG,SAAS,GAAG,OAAO,GAAG,UAAU,GAAG,YAAY,CAAC;AAEhF;;;GAGG;AACH,MAAM,WAAW,0BAA0B;IACzC,0EAA0E;IAC1E,EAAE,EAAE,SAAS,GAAG,YAAY,CAAC;IAC7B;;;;;;;OAOG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,0BAA0B,GAAG;IAAE,EAAE,EAAE,wBAAwB,CAAA;CAAE,GAAG,wBAAwB,CAAC;AAEtH;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,6BAA6B;IAC7B,aAAa,EAAE,kBAAkB,CAAC;IAClC,gDAAgD;IAChD,UAAU,EAAE,OAAO,CAAC;IACpB,iDAAiD;IACjD,KAAK,EAAE,cAAc,CAAC;IACtB,sJAAsJ;IACtJ,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,wBAAuB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,qBAAqB,CAAC,qBAAqB,CAAC,CAyClH"}