@itwin/presentation-frontend
Version:
Frontend of iModel.js Presentation library
39 lines • 1.37 kB
JavaScript
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
* @module UnifiedSelection
*/
import { Key, NodeKey } from "@itwin/presentation-common";
/**
* Helper class for working with selection.
* @public
*/
export class SelectionHelper {
// istanbul ignore next
constructor() { }
/**
* Re-map the given keyset for selection. This means all instance node keys get converted
* to instance keys, because in that case we want to select instances instead of nodes. All
* other types of keys ar left as is.
*/
static getKeysForSelection(keys) {
const result = new Array();
keys.forEach((key) => {
if (Key.isNodeKey(key)) {
if (NodeKey.isInstancesNodeKey(key)) {
result.push(...key.instanceKeys);
}
else {
result.push(key);
}
}
else {
result.push(key);
}
});
return result;
}
}
//# sourceMappingURL=SelectionHelper.js.map