@equinor/echo-framework 1.0.0 → 1.1.1

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 (71) hide show
  1. package/index.cjs.js +8 -8
  2. package/package.json +5 -5
  3. package/src/index.d.ts +2 -2
  4. package/src/lib/components/fullScreenButtons/index.d.ts +0 -2
  5. package/src/lib/components/prepview/panels/tagInformation/TagInformation.d.ts +1 -1
  6. package/src/lib/coreApplication/BarComponents/SelectionStatusDotIndicator.d.ts +1 -0
  7. package/src/lib/coreApplication/EchoContentPanels.d.ts +1 -5
  8. package/src/lib/feature/equipment/components/equipmentItemHeader/showEquipmentIn3dButton.d.ts +1 -1
  9. package/src/lib/feature/globalSelection/globalSelection.api.d.ts +30 -4
  10. package/src/lib/feature/globalSelection/globalSelection.internal.d.ts +1 -1
  11. package/src/lib/feature/globalSelection/globalSelectionColorService.d.ts +57 -0
  12. package/src/lib/feature/globalSelection/globalSelectionColorService.types.d.ts +3 -0
  13. package/src/lib/feature/globalSelection/globalSelectionStore/actions/addEquipmentsToSelection.action.d.ts +1 -0
  14. package/src/lib/feature/globalSelection/globalSelectionStore/actions/addItemsToSelectionFactory.d.ts +1 -0
  15. package/src/lib/feature/globalSelection/globalSelectionStore/actions/addMeasuringPointsToSelection.action.d.ts +1 -0
  16. package/src/lib/feature/globalSelection/globalSelectionStore/actions/addTagsToSelection.action.d.ts +1 -0
  17. package/src/lib/feature/globalSelection/globalSelectionStore/actions/addWorkOrdersToSelection.action.d.ts +1 -0
  18. package/src/lib/feature/globalSelection/globalSelectionStore/globalSelectionStore.repository.d.ts +2 -2
  19. package/src/lib/feature/globalSelection/globalSelectionStore/globalSelectionStore.types.d.ts +7 -5
  20. package/src/lib/feature/globalSelection/globalSelectionStore/globalSelectionStore.utils.d.ts +24 -4
  21. package/src/lib/feature/globalSelection/globalSelectionStore/globalSelectionStoreHelpers.d.ts +12 -2
  22. package/src/lib/feature/globalSelection/hooks/useGlobalSelectionLists.d.ts +0 -2
  23. package/src/lib/feature/globalSelection/index.d.ts +5 -2
  24. package/src/lib/feature/globalSelection/selectionMenu/hooks/useGlobalSelectionGroups.d.ts +24 -1
  25. package/src/lib/feature/globalSelection/selectionMenu/hooks/useSelectionColorFrequency.d.ts +18 -0
  26. package/src/lib/feature/globalSelection/selectionMenu/selectionTreeStore/actions/addItems.action.d.ts +16 -0
  27. package/src/lib/feature/globalSelection/selectionMenu/selectionTreeStore/actions/addItemsToSelectionTreeFactory.d.ts +1 -1
  28. package/src/lib/feature/globalSelection/selectionMenu/selectionTreeStore/actions/common.action.types.d.ts +5 -0
  29. package/src/lib/feature/globalSelection/selectionMenu/selectionTreeStore/actions/createGroup.action.d.ts +20 -0
  30. package/src/lib/feature/globalSelection/selectionMenu/selectionTreeStore/actions/moveItems.action.d.ts +31 -0
  31. package/src/lib/feature/globalSelection/selectionMenu/selectionTreeStore/actions/removeGroupById.action.d.ts +21 -0
  32. package/src/lib/feature/globalSelection/selectionMenu/selectionTreeStore/actions/removeItemsById.action.d.ts +24 -0
  33. package/src/lib/feature/globalSelection/selectionMenu/selectionTreeStore/actions/selectionTree.action.types.d.ts +14 -15
  34. package/src/lib/feature/globalSelection/selectionMenu/selectionTreeStore/actions/setVisibility.action.d.ts +21 -0
  35. package/src/lib/feature/globalSelection/selectionMenu/selectionTreeStore/api/selectionTree.api.d.ts +14 -4
  36. package/src/lib/feature/globalSelection/selectionMenu/selectionTreeStore/api/selectionTree.equipment.d.ts +5 -0
  37. package/src/lib/feature/globalSelection/selectionMenu/selectionTreeStore/colorConflictHandling/SelectionColorConflictDialog.d.ts +11 -0
  38. package/src/lib/feature/globalSelection/selectionMenu/selectionTreeStore/colorConflictHandling/selectionColorConflict.store.d.ts +27 -0
  39. package/src/lib/feature/globalSelection/selectionMenu/selectionTreeStore/persist/devOnlySimulateOffline.d.ts +7 -0
  40. package/src/lib/feature/globalSelection/selectionMenu/selectionTreeStore/persist/diskId.type.d.ts +2 -0
  41. package/src/lib/feature/globalSelection/selectionMenu/selectionTreeStore/persist/persistError.d.ts +5 -0
  42. package/src/lib/feature/globalSelection/selectionMenu/selectionTreeStore/persist/selectionTree.diskBackup.d.ts +45 -0
  43. package/src/lib/feature/globalSelection/selectionMenu/selectionTreeStore/persist/selectionTree.diskBackupStatus.d.ts +19 -0
  44. package/src/lib/feature/globalSelection/selectionMenu/selectionTreeStore/persist/selectionTree.load.d.ts +8 -0
  45. package/src/lib/feature/globalSelection/selectionMenu/selectionTreeStore/persist/selectionTree.load.utils.d.ts +42 -0
  46. package/src/lib/feature/globalSelection/selectionMenu/selectionTreeStore/persist/selectionTree.save.d.ts +1 -0
  47. package/src/lib/feature/globalSelection/selectionMenu/selectionTreeStore/persist/selectionTreeLoader.service.d.ts +42 -0
  48. package/src/lib/feature/globalSelection/selectionMenu/selectionTreeStore/{useSelectionTreeAutoSave.d.ts → persist/useSelectionTreeAutoSave.d.ts} +2 -0
  49. package/src/lib/feature/globalSelection/selectionMenu/selectionTreeStore/selectionTree.api.types.d.ts +8 -3
  50. package/src/lib/feature/globalSelection/selectionMenu/selectionTreeStore/selectionTree.store.d.ts +15 -0
  51. package/src/lib/feature/globalSelection/selectionMenu/selectionTreeStore/selectionTree.store.types.d.ts +15 -3
  52. package/src/lib/feature/globalSelection/selectionMenu/selectionTreeStore/selectionTree.store.utils.d.ts +64 -2
  53. package/src/lib/feature/legacyLegend/legend.d.ts +1 -0
  54. package/src/lib/feature/legend/components/legendTextSelector/LegendTextSelector.d.ts +21 -0
  55. package/src/lib/feature/legend/components/popover/LegendPopoverContent.d.ts +4 -0
  56. package/src/lib/feature/legend/components/popover/LegendPopoverContent.logic.d.ts +1 -1
  57. package/src/lib/feature/legend/index.d.ts +6 -0
  58. package/src/lib/feature/legend/types/legendMarkerBadge.type.d.ts +9 -2
  59. package/src/lib/feature/legend/types/legendStrategy.type.d.ts +1 -0
  60. package/src/lib/feature/legend/types/legendType.d.ts +1 -0
  61. package/src/lib/services/api/api-plants.d.ts +4 -0
  62. package/src/lib/services/echoViewService/echoView.type.d.ts +2 -1
  63. package/src/lib/services/echoViewService/loadEchoViewIdAndSelectionIdFromUrl.d.ts +5 -4
  64. package/src/lib/utils/startup.d.ts +1 -0
  65. package/src/lib/components/fullScreenButtons/FullScreenChip.d.ts +0 -7
  66. package/src/lib/components/fullScreenButtons/FullScreenModeChip.d.ts +0 -14
  67. package/src/lib/feature/globalSelection/selectionMenu/hooks/useGlobalSelectionColorsSortedByFrequency.d.ts +0 -10
  68. package/src/lib/feature/globalSelection/selectionMenu/hooks/useMoveSelectionTreeItems.d.ts +0 -10
  69. package/src/lib/feature/globalSelection/selectionMenu/selectionTreeStore/selectionTree.store.repository.d.ts +0 -5
  70. /package/src/lib/feature/globalSelection/selectionMenu/selectionTreeStore/{currentSelectionId.repository.d.ts → persist/currentSelectionId.repository.d.ts} +0 -0
  71. /package/src/lib/feature/globalSelection/selectionMenu/selectionTreeStore/{legacyPersistedSelection.d.ts → persist/legacyPersistedSelection.d.ts} +0 -0
@@ -1,27 +1,26 @@
1
1
  import { ResultArray } from '@equinor/echo-search';
2
2
  import { Guid } from '@equinor/echo-utils';
3
3
  import { GlobalSelectionItemType, GlobalSelectionItemTypeToDataMap, GlobalSelectionTypes, SelectionItemTypeToItemIdMap } from '../../../globalSelectionStore/globalSelectionStore.types';
4
- /**
5
- * @deprecated A group should not be created with label and subLabel.
6
- * Use `groupId` instead to specify the group.
7
- * This type will be removed in the future.
8
- */
9
- export type AddByGroupIdAndLabel = {
10
- label: string;
11
- subLabel: string;
12
- } | {
13
- label?: undefined;
14
- subLabel?: undefined;
15
- };
16
- export type AddItemArgs<ItemIdType extends GlobalSelectionTypes.ItemId> = {
4
+ type AddItemArgsBase<ItemIdType extends GlobalSelectionTypes.ItemId> = {
17
5
  itemIds: Readonly<ItemIdType[]>;
18
6
  replaceItems?: boolean;
19
7
  getActionResult?: boolean;
20
- groupId?: Guid;
21
- } & AddByGroupIdAndLabel;
8
+ };
9
+ type AddItemArgsExclusive = {
10
+ groupId: Guid;
11
+ label?: undefined;
12
+ subLabel?: undefined;
13
+ } | {
14
+ groupId?: undefined;
15
+ label: string;
16
+ subLabel: string;
17
+ } | {};
18
+ export type AddItemArgs<ItemIdType extends GlobalSelectionTypes.ItemId> = AddItemArgsBase<ItemIdType> & AddItemArgsExclusive;
22
19
  export type AddItemsResponse<T extends GlobalSelectionItemType> = {
23
20
  fetchResults: ResultArray<GlobalSelectionItemTypeToDataMap[T]>[];
24
21
  itemsAdded: Readonly<SelectionItemTypeToItemIdMap[T][]>;
25
22
  actionResult: SelectionTreeActionResult;
23
+ affectedGroupId?: Guid;
26
24
  };
27
25
  export type SelectionTreeActionResult = 'ItemsUpdated' | 'ItemsAdded' | 'NewGroupCreated' | 'NoChanges';
26
+ export {};
@@ -0,0 +1,21 @@
1
+ import { Guid } from '@equinor/echo-utils';
2
+ import { GlobalSelectionCategoryId, SelectionTreeStore } from '../selectionTree.store.types';
3
+ /**
4
+ * Sets the visibility of selection items within a specified group and category.
5
+ *
6
+ * This function locates the relevant selection category and updates the visibility
7
+ * of all items within that category, or all items in the group if no category is specified.
8
+ * Only unique item IDs are processed for visibility changes.
9
+ *
10
+ * @param get - A function that returns the current `SelectionTreeStore` state.
11
+ * @param args - The arguments for the action, including:
12
+ * - `groupId`: The ID of the group containing the items.
13
+ * - `isVisible`: The desired visibility state to set for the items.
14
+ * - `categoryId` (optional): The ID of the category within the group. If omitted, all categories in the group are affected.
15
+ */
16
+ export declare function setVisibilityById(get: () => SelectionTreeStore, args: SetVisibilityActionArgs): void;
17
+ export type SetVisibilityActionArgs = {
18
+ groupId: Guid;
19
+ categoryId?: GlobalSelectionCategoryId;
20
+ isVisible: boolean;
21
+ };
@@ -1,9 +1,19 @@
1
1
  import { Guid } from '@equinor/echo-utils';
2
- import { ApiSelectionTreeRoot } from '../selectionTree.api.types';
2
+ import { ApiSelectionTreeRoot, ApiSelectionTreeRootBase } from '../selectionTree.api.types';
3
3
  import { SelectionGroup } from '../selectionTree.store.types';
4
- export declare function saveSelectionTreeToApi(id: string | undefined, data: {
5
- data: SelectionGroup[];
6
- }): Promise<void>;
4
+ /**
5
+ * Maps the selection tree data to the API format.
6
+ * @param data The selection tree data to map
7
+ * @param lifetime The lifetime of the selection
8
+ * @returns The mapped API selection tree root
9
+ */
10
+ export declare function mapToApiSelectionRoot(data: {
11
+ args: SelectionGroup[];
12
+ }, lifetime: 'Short' | 'Long'): ApiSelectionTreeRootBase;
13
+ export declare function saveSelectionTreeToApi(args: {
14
+ id: string | undefined;
15
+ itemToSave: ApiSelectionTreeRootBase;
16
+ }): Promise<Guid | undefined>;
7
17
  export declare function fetchSelectionTreeById(id: string): Promise<ApiSelectionTreeRoot | undefined>;
8
18
  export declare function fetchUserSelectionIds(): Promise<Guid[]>;
9
19
  export declare function deleteSelectionId(id: string): Promise<void>;
@@ -0,0 +1,5 @@
1
+ import { EquipmentData } from '@equinor/echo-search';
2
+ import { Guid } from '@equinor/echo-utils';
3
+ import { SelectionGroup } from '../selectionTree.store.types';
4
+ export declare function saveEquipmentAsNewSelectionToApi(equipmentsToSend: ReadonlyArray<EquipmentData>, selectionGroupLabel?: string): Promise<Guid | undefined>;
5
+ export declare function createSelectionGroupsFromEquipment(equipmentIds: string[], selectionGroupLabel: string): SelectionGroup[];
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ /**
3
+ * Displays a dialog when there is a color conflict during selection list import.
4
+ *
5
+ * This dialog informs the user that one or more items being added to the selection already exist and have assigned colors.
6
+ * It notifies the user that the latest (incoming) color will be assigned to these items.
7
+ * The dialog is rendered via a portal and adapts its width for mobile devices.
8
+ *
9
+ * @returns {JSX.Element} The portal-rendered dialog component.
10
+ */
11
+ export declare const SelectionColorConflictDialog: React.FC;
@@ -0,0 +1,27 @@
1
+ import { GlobalSelectionTypes } from '../../../globalSelectionStore/globalSelectionStore.types';
2
+ export type SelectionColorConflict = {
3
+ itemId: GlobalSelectionTypes.ItemId;
4
+ existingColor: string;
5
+ };
6
+ /**
7
+ * Zustand store for managing global selection color conflicts.
8
+ *
9
+ * @remarks
10
+ * This store keeps track of color conflicts that occur in selection trees,
11
+ * providing methods to set and clear the list of conflicts.
12
+ *
13
+ * @returns
14
+ * - `conflicts`: An array of `SelectionColorConflict` objects representing current conflicts.
15
+ * - `setConflicts`: Function to update the conflicts array.
16
+ * - `clearConflicts`: Function to reset the conflicts array to empty.
17
+ */
18
+ export declare const useSelectionColorConflictStore: import("zustand").UseBoundStore<import("zustand").StoreApi<{
19
+ conflicts: SelectionColorConflict[];
20
+ setConflicts: (conflicts: SelectionColorConflict[]) => void;
21
+ clearConflicts: () => void;
22
+ }>>;
23
+ export declare const getSelectionColorConflictState: () => {
24
+ conflicts: SelectionColorConflict[];
25
+ setConflicts: (conflicts: SelectionColorConflict[]) => void;
26
+ clearConflicts: () => void;
27
+ };
@@ -0,0 +1,7 @@
1
+ declare function setSimulateSelectionTreeApiError(enabled: boolean): void;
2
+ declare function getSimulateSelectionTreeApiError(): boolean;
3
+ export declare const simulatedSelectionTreeApiError: Readonly<{
4
+ get: typeof getSimulateSelectionTreeApiError;
5
+ set: typeof setSimulateSelectionTreeApiError;
6
+ }>;
7
+ export {};
@@ -0,0 +1,2 @@
1
+ import { Brand } from '@equinor/echo-utils';
2
+ export type DiskId = Brand<string, 'DiskId'>;
@@ -0,0 +1,5 @@
1
+ import { BaseError } from '@equinor/echo-base';
2
+ export declare function createPersistError(args: {
3
+ userFriendlyMessage: string;
4
+ error: unknown;
5
+ }): BaseError;
@@ -0,0 +1,45 @@
1
+ import { Guid } from '@equinor/echo-utils';
2
+ import { ApiSelectionTreeRootBase } from '../selectionTree.api.types';
3
+ import { DiskId } from './diskId.type';
4
+ export interface OfflineSelectionTreeData {
5
+ diskId: DiskId;
6
+ apiId?: Guid;
7
+ apiSelectionTreeRoot: ApiSelectionTreeRootBase;
8
+ timestamp: Date;
9
+ isSavedToApi: boolean;
10
+ }
11
+ declare function backupSelectionTreeToDisk(apiId: Guid | undefined, apiSelectionTreeRoot: ApiSelectionTreeRootBase): Promise<DiskId>;
12
+ interface SelectionTreeBackup {
13
+ apiId: Guid | undefined;
14
+ apiSelectionTreeRoot: ApiSelectionTreeRootBase;
15
+ timestamp: Date;
16
+ }
17
+ declare function getBackupSelectionTreeFromDisk(id: Guid | DiskId): Promise<SelectionTreeBackup | undefined>;
18
+ /**
19
+ * Sets the API ID for a disk backup and marks it as saved to the API.
20
+ * @param diskId The disk ID of the backup.
21
+ * @param apiId The API ID to set.
22
+ */
23
+ declare function setSavedToApi(diskId: DiskId | undefined, apiId: Guid): Promise<void>;
24
+ /**
25
+ * Tries to save any unsaved backup selection trees to the API, and deletes all that are saved to API except current apiId.
26
+ * These backups are created by starting a new selection in offline mode (clear selection, or remove all groups).
27
+ */
28
+ declare function saveAllBackupsToApiAndDeleteThemExceptFor(apiId: Guid): Promise<void>;
29
+ /**
30
+ * Checks if a disk backup exists for the given API ID and deletes it if it has been saved to the API.
31
+ * @param apiId The API ID of the selection tree to check and possibly delete.
32
+ */
33
+ declare function deleteDiskBackupIfAlreadySavedToApi(apiId: Guid): Promise<void>;
34
+ export declare const selectionTreeDiskBackup: Readonly<{
35
+ save: typeof backupSelectionTreeToDisk;
36
+ load: typeof getBackupSelectionTreeFromDisk;
37
+ setSavedToApi: typeof setSavedToApi;
38
+ saveAllBackupsToApiAndDeleteThemExceptFor: typeof saveAllBackupsToApiAndDeleteThemExceptFor;
39
+ deleteDiskBackupIfAlreadySavedToApi: typeof deleteDiskBackupIfAlreadySavedToApi;
40
+ /**
41
+ * TEST-ONLY: Returns all disk backups for testing purposes.
42
+ */
43
+ getAllBackupsForTest: () => Promise<OfflineSelectionTreeData[]>;
44
+ }>;
45
+ export {};
@@ -0,0 +1,19 @@
1
+ import { Guid } from '@equinor/echo-utils';
2
+ import { DiskId } from './diskId.type';
3
+ /**
4
+ * Since both disk (indexDb) and api can fail/throw, we need to track what has been saved where. Local storage is most reliable for this.
5
+ * This is used when loading, to determine where to load from, disk or api. Disk is prioritized if it's upto date because of performance.
6
+ */
7
+ export interface BackupStatus {
8
+ readonly savedToApiId: Guid | undefined;
9
+ readonly savedToDiskId: DiskId | undefined;
10
+ }
11
+ declare function updateSaveStatus(saveStatus: BackupStatus): void;
12
+ declare function getSaveStatus(): BackupStatus | undefined;
13
+ declare function clearSaveStatus(): void;
14
+ export declare const selectionTreeDiskBackupStatus: Readonly<{
15
+ update: typeof updateSaveStatus;
16
+ get: typeof getSaveStatus;
17
+ clear: typeof clearSaveStatus;
18
+ }>;
19
+ export {};
@@ -0,0 +1,8 @@
1
+ import { Guid } from '@equinor/echo-utils';
2
+ export declare const selectionTreeRepository: Readonly<{
3
+ loadAndPopulateLatestSelection: typeof loadAndPopulateLatestSelection;
4
+ loadAndPopulateStoreFromApi: typeof loadAndPopulateStoreFromApi;
5
+ }>;
6
+ declare function loadAndPopulateLatestSelection(): Promise<void>;
7
+ declare function loadAndPopulateStoreFromApi(idToLoad: Guid): Promise<boolean>;
8
+ export {};
@@ -0,0 +1,42 @@
1
+ import { ApiSelectionGroup, ApiSelectionTreeRootBase } from '../selectionTree.api.types';
2
+ import { GlobalSelectionItemType, GlobalSelectionObject, GlobalSelectionTypes } from '../../../globalSelectionStore/globalSelectionStore.types';
3
+ /**
4
+ * Processes API selection tree data and organizes item IDs by their types.
5
+ *
6
+ * This function takes the `data` property from an API selection tree root object,
7
+ * extracts all items from the nested structure, and groups their normalized IDs
8
+ * by their corresponding `GlobalSelectionItemType`. It then creates selection lists
9
+ * for each type using the `selectionTreeLoader.createListByType` utility.
10
+ *
11
+ * @param param0 - An object containing the `data` array from the API selection tree root.
12
+ * @returns An object containing:
13
+ * - `lists`: A `GlobalSelectionObject` with lists of items grouped by type.
14
+ * - `idsByType`: An object mapping each `GlobalSelectionItemType` to an array of item IDs.
15
+ */
16
+ export declare function createListsByTypeFromApiData({ data }: {
17
+ data: ApiSelectionTreeRootBase['data'];
18
+ }): {
19
+ lists: GlobalSelectionObject;
20
+ idsByType: {
21
+ [K in GlobalSelectionItemType]: GlobalSelectionTypes.ItemId[];
22
+ };
23
+ };
24
+ /**
25
+ * Applies color assignments to selection API data groups.
26
+ * Used when loading selection data from the API or disk to ensure consistent color usage.
27
+ *
28
+ * This function ensures that each group in the provided selection data has a color assigned.
29
+ * If any item within a group is missing a color (as determined by `getHexOrOriginalOrUndefined`),
30
+ * a color is assigned to the group using the color service. The function then returns a new array
31
+ * of groups where each item's `metaData.color` is set either from the API or from the assigned color.
32
+ *
33
+ * The color assignment process:
34
+ * 1. Resets the color service to release previous color assignments.
35
+ * 2. Identifies group IDs that require color assignment (where at least one item is missing a color).
36
+ * 3. Assigns colors to these group IDs using the color service.
37
+ * 4. Returns a new structure with colors applied to all items.
38
+ *
39
+ * @param groups - The array of selection groups from the API to process.
40
+ * @returns A new array of selection groups with colors assigned to items as needed.
41
+ */
42
+ export declare function applyColorsOnSelectionApiData(groups: ApiSelectionGroup[]): ApiSelectionGroup[];
@@ -0,0 +1 @@
1
+ export declare function saveCurrentSelectionTree(): Promise<void>;
@@ -0,0 +1,42 @@
1
+ import { ResultArray } from '@equinor/echo-search';
2
+ import { GlobalSelectionItemType, GlobalSelectionItemTypeToDataMap, GlobalSelectionTypes, SelectionItemTypeToItemIdMap } from '../../../globalSelectionStore/globalSelectionStore.types';
3
+ type ListCreatorParams<T extends GlobalSelectionItemType> = {
4
+ nullItemGenerator: (itemId: SelectionItemTypeToItemIdMap[T]) => GlobalSelectionItemTypeToDataMap[T];
5
+ };
6
+ /**
7
+ * Service responsible for managing the registration and execution of list creators and API loaders
8
+ * for different global selection item types within the selection tree.
9
+ *
10
+ * Mainly used for loading and setting huge amount of data when loading selections from API and or from disk.
11
+ *
12
+ * This service allows dynamic registration of functions that can create selection lists or fetch
13
+ * and update selection data for specific item types. It provides methods to register these handlers,
14
+ * create lists, and fetch/store data by type.
15
+ *
16
+ * @remarks
17
+ * - `registerListCreator` associates a list creation function with a specific item type.
18
+ * - `registerApiLoader` associates an asynchronous data loader with a specific item type.
19
+ * - `createListByType` uses the registered creator to generate a selection list for the given type and item IDs.
20
+ * - `fetchAndStoreDataByType` uses the registered loader to fetch and update data for the given type and item IDs.
21
+ *
22
+ * @template T - The global selection item type.
23
+ */
24
+ declare class SelectionTreeLoaderService {
25
+ private listCreators;
26
+ private apiLoaders;
27
+ registerGroupCreator<T extends GlobalSelectionItemType>(type: T, params: ListCreatorParams<T>): void;
28
+ registerApiLoader<T extends GlobalSelectionItemType>(type: T, fetchFunction: (itemIds: SelectionItemTypeToItemIdMap[T][]) => Promise<{
29
+ result: ResultArray<GlobalSelectionItemTypeToDataMap[T]>;
30
+ itemIdsUsed: SelectionItemTypeToItemIdMap[T][];
31
+ }[]>): void;
32
+ createListByType<T extends GlobalSelectionItemType>(type: T, itemIds: SelectionItemTypeToItemIdMap[T][]): GlobalSelectionTypes.List<T>;
33
+ fetchAndStoreDataByType<T extends GlobalSelectionItemType>(type: T, itemIds: SelectionItemTypeToItemIdMap[T][]): Promise<void>;
34
+ }
35
+ /**
36
+ * Service responsible for managing the registration and execution of list creators and API loaders
37
+ * for different global selection item types within the selection tree.
38
+ *
39
+ * Used for loading and setting huge amount of data when loading selections from API and or from disk.
40
+ */
41
+ export declare const selectionTreeLoader: SelectionTreeLoaderService;
42
+ export {};
@@ -1,5 +1,7 @@
1
+ export declare const autoSaveDebounceDelayMilliseconds = 250;
1
2
  /**
2
3
  * Auto saves if the selection tree or global selection change by: Add/remove/rename items/groups, or metadata.color/isHiddenByUser
3
4
  * Ignores saving if only data object changes, or metadata.error/status
5
+ * Falls back to disk storage when API is unavailable
4
6
  */
5
7
  export declare function useSelectionTreeAutoSave(): void;
@@ -2,16 +2,21 @@ import { Guid } from '@equinor/echo-utils';
2
2
  import { GlobalSelectionItemType, GlobalSelectionMetaData, SelectionItemTypeToItemIdMap } from '../../globalSelectionStore/globalSelectionStore.types';
3
3
  export type ApiSelectionTreeItemId = SelectionItemTypeToItemIdMap[GlobalSelectionItemType];
4
4
  export type ApiGlobalSelectionMetaData = Partial<Pick<GlobalSelectionMetaData, 'color' | 'isHiddenByUser'>>;
5
- export interface ApiSelectionTreeRoot {
6
- id?: Guid;
5
+ export interface ApiSelectionTreeRootBase {
7
6
  data: ApiSelectionGroup[];
8
- versionNo?: string;
9
7
  /**
10
8
  * Short is used by 3rd party apps, it should not be visible/selectable by user
11
9
  * Long will show up in recent sessions in UI.
12
10
  */
13
11
  lifetime: 'Short' | 'Long';
14
12
  }
13
+ /**
14
+ * Represents the root of the selection tree in the API.
15
+ */
16
+ export interface ApiSelectionTreeRoot extends ApiSelectionTreeRootBase {
17
+ id: Guid;
18
+ versionNo: string;
19
+ }
15
20
  export interface ApiSelectionGroup {
16
21
  readonly groupId: Guid;
17
22
  readonly label: string;
@@ -1,4 +1,19 @@
1
1
  import { SelectionTreeStore } from './selectionTree.store.types';
2
+ /**
3
+ * Zustand store hook for managing the selection tree state in the global selection feature.
4
+ *
5
+ * It is responsible for storing and handling the tree structure of the selection.
6
+ * All the data for the selection items are stored in the global selection store.
7
+ * This store only stores item ids.
8
+ *
9
+ * @returns {SelectionTreeStore} The selection tree store API.
10
+ *
11
+ * @example
12
+ * const selectionTree = useSelectionTreeStore();
13
+ * selectionTree.addTags({ ... });
14
+ *
15
+ * @see SelectionTreeStore
16
+ */
2
17
  export declare const useSelectionTreeStore: import("zustand").UseBoundStore<Omit<Omit<Omit<import("zustand").StoreApi<SelectionTreeStore>, "setState"> & {
3
18
  setState<A extends string | {
4
19
  type: string;
@@ -1,6 +1,6 @@
1
1
  import { Guid } from '@equinor/echo-utils';
2
2
  import { GlobalSelectionItemType, GlobalSelectionTypes, SelectionItemTypeToItemIdMap } from '../../globalSelectionStore/globalSelectionStore.types';
3
- import { AddByGroupIdAndLabel, AddItemArgs, AddItemsResponse, SelectionTreeActionResult } from './actions/selectionTree.action.types';
3
+ import { AddItemArgs, AddItemsResponse, SelectionTreeActionResult } from './actions/selectionTree.action.types';
4
4
  export declare enum GlobalSelectionCategoryId {
5
5
  Tags = "DEFAULT_TAG_LIST_ID",
6
6
  WorkOrders = "DEFAULT_WORK_ORDER_LIST_ID",
@@ -30,11 +30,13 @@ export interface SelectionTreeData {
30
30
  readonly groups: SelectionGroup[];
31
31
  }
32
32
  export interface SelectionTreeStore extends SelectionTreeData {
33
- setCurrentSelectionId: (id: Guid) => void;
33
+ setCurrentSelectionId: (args: {
34
+ guid: Guid | undefined;
35
+ }) => void;
34
36
  addItems: (args: {
35
37
  itemIds: GlobalSelectionTypes.ItemId[];
36
38
  groupId?: Guid;
37
- } & AddByGroupIdAndLabel) => Promise<void>;
39
+ }) => Promise<void>;
38
40
  addTags: (args: AddItemArgs<GlobalSelectionTypes.TagId>) => AddTagsReturnType;
39
41
  addWorkOrders: (args: AddItemArgs<GlobalSelectionTypes.WorkOrderId>) => AddWorkOrdersReturnType;
40
42
  addEquipments: (args: AddItemArgs<GlobalSelectionTypes.EquipmentId>) => AddEquipmentsReturnType;
@@ -62,12 +64,22 @@ export interface SelectionTreeStore extends SelectionTreeData {
62
64
  removeAllItemsById: (args: {
63
65
  itemIds: GlobalSelectionTypes.ItemId[];
64
66
  }) => void;
67
+ moveItems: (args: {
68
+ sourceGroupId: Guid;
69
+ sourceCategoryId?: GlobalSelectionCategoryId;
70
+ sourceItemId?: GlobalSelectionTypes.ItemId;
71
+ targetGroupId: Guid;
72
+ }) => void;
65
73
  setVisibilityById: (args: {
66
74
  groupId: Guid;
67
75
  categoryId?: GlobalSelectionCategoryId;
68
76
  isVisible: boolean;
69
77
  }) => void;
70
78
  resetState: () => void;
79
+ setWholeState: (args: {
80
+ selectionId: Guid | undefined;
81
+ groups: SelectionGroup[];
82
+ }) => void;
71
83
  }
72
84
  export declare namespace SelectionTreeTypes {
73
85
  type Category = SelectionCategory;
@@ -1,6 +1,6 @@
1
1
  import { Guid } from '@equinor/echo-utils';
2
2
  import { GlobalSelectionItemType, GlobalSelectionTypes } from '../../globalSelectionStore/globalSelectionStore.types';
3
- import { GlobalSelectionCategoryId, SelectionTreeTypes } from './selectionTree.store.types';
3
+ import { GlobalSelectionCategoryId, SelectionTreeStore, SelectionTreeTypes } from './selectionTree.store.types';
4
4
  /**
5
5
  * Check if an item ID is present in the selection tree.
6
6
  *
@@ -95,6 +95,7 @@ export declare function areItemsTheSameInGroup<ItemType extends GlobalSelectionT
95
95
  * @returns {void}
96
96
  */
97
97
  export declare function removeGroupIfEmpty(allGroups: SelectionTreeTypes.Group[], targetGroup: SelectionTreeTypes.Group): void;
98
+ export declare function isSelectionEmpty(groups: SelectionTreeTypes.Group[]): boolean;
98
99
  /**
99
100
  * Removes items from the global selection if they are not present in the tree store anymore.
100
101
  *
@@ -102,5 +103,66 @@ export declare function removeGroupIfEmpty(allGroups: SelectionTreeTypes.Group[]
102
103
  * @param {GlobalSelectionTypes.ItemId[]} itemIds - The list of item IDs to be checked and potentially removed.
103
104
  * @returns {void}
104
105
  */
105
- export declare function removeItemsFromGlobalSelection(groups: SelectionTreeTypes.Group[], itemIds: GlobalSelectionTypes.ItemId[]): void;
106
+ export declare function removeStaleItemsFromGlobalSelection(groups: SelectionTreeTypes.Group[], itemIds: GlobalSelectionTypes.ItemId[]): void;
106
107
  export declare function getItemsByIdsFromGlobalSelectionStore(itemIds: GlobalSelectionTypes.ItemId[]): GlobalSelectionTypes.GenericItem<GlobalSelectionItemType>[];
108
+ /**
109
+ * Returns an array of selection colors sorted by their frequency for the specified item IDs within a group.
110
+ *
111
+ * This function filters the provided item IDs to include only those that belong to the specified group
112
+ * and are not present elsewhere in the selection tree. It then counts the occurrence of each color
113
+ * (excluding placeholder colors) associated with these items in the selection lists, and returns the colors
114
+ * sorted by their frequency in descending order.
115
+ *
116
+ * @param args - The arguments for the function.
117
+ * @param args.groupId - The ID of the group to filter items by.
118
+ * @param args.itemIds - The array of item IDs to consider for color frequency.
119
+ * @param args.selectionLists - (Optional) The selection lists to use. If not provided, the global selection store state is used.
120
+ * @param args.treeState - (Optional) The selection tree state to use. If not provided, the current selection tree store snapshot is used.
121
+ * @returns An array of color strings, sorted by frequency (most frequent first).
122
+ */
123
+ export declare function getSelectionColorFrequencyByIds(args: {
124
+ groupId: string;
125
+ itemIds: GlobalSelectionTypes.ItemId[];
126
+ allGroups: ReadonlyArray<SelectionTreeTypes.Group>;
127
+ }): string[];
128
+ /**
129
+ * Handles the colorization of selection items within a group in the selection tree.
130
+ *
131
+ * This function optionally detects color conflicts among the specified items,
132
+ * and then assigns a color to the items in the affected group.
133
+ *
134
+ * @param args - The arguments for colorizing items.
135
+ * @param args.itemType - The type of the selection items to colorize.
136
+ * @param args.treeState - The current state of the selection tree.
137
+ * @param args.affectedGroupId - (Optional) The ID of the group whose items are affected. If not provided, a default group is used.
138
+ * @param args.itemIds - The IDs of the items to colorize.
139
+ * @param args.handleColorConflicts - (Optional) Whether to detect and handle color conflicts before assigning colors.
140
+ * @returns The color assigned to the items, or `undefined` if no color was assigned.
141
+ */
142
+ export declare function handleItemColorization(args: {
143
+ itemType: GlobalSelectionItemType;
144
+ treeState: SelectionTreeStore;
145
+ affectedGroupId?: Guid;
146
+ itemIds: GlobalSelectionTypes.ItemId[];
147
+ handleColorConflicts?: boolean;
148
+ }): string | undefined;
149
+ /**
150
+ * Assigns a color to a set of items within a specified group in the selection tree.
151
+ *
152
+ * - If the group is the default (local) selection group, a fixed color is assigned based on the item type.
153
+ * - For other groups, the function determines the most frequently used color among the group's items.
154
+ * If no color is found (e.g., for a new or imported group), a new color is assigned using the color service.
155
+ *
156
+ * @param args - The arguments for color assignment.
157
+ * @param args.itemType - The type of the items to assign a color to.
158
+ * @param args.allGroups - All available selection groups.
159
+ * @param args.groupId - The ID of the group containing the items.
160
+ * @param args.itemIdsToColor - The IDs of the items to assign a color to.
161
+ * @returns The assigned color as a string, or `undefined` if no color could be assigned.
162
+ */
163
+ export declare function assignColorToItemsInGroup(args: {
164
+ itemType: GlobalSelectionItemType;
165
+ allGroups: ReadonlyArray<SelectionTreeTypes.Group>;
166
+ groupId: string;
167
+ itemIdsToColor: GlobalSelectionTypes.ItemId[];
168
+ }): string | undefined;
@@ -34,6 +34,7 @@ export declare enum LegendStatus {
34
34
  PM20 = "PM20",
35
35
  LC = "LC",
36
36
  LO = "LO",
37
+ NoValvePositionInSAP = "No Valve Position in SAP",
37
38
  OnWatch = "On watch",
38
39
  InProgress = "In progress",
39
40
  IocAnnotationError = "IocAnnotationError",
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ interface LegendTextSelectorProps {
3
+ options: ReadonlyArray<string>;
4
+ selectedOption: string;
5
+ onOptionSelected?: (option: string) => void;
6
+ }
7
+ /**
8
+ * LegendTextSelector renders a group of selectable buttons for legend text options.
9
+ *
10
+ * Displays each option as a button, highlights the currently selected option, and calls the `onSelect` callback when a different option is chosen.
11
+ * Uses Echo UI components and compact density for consistent styling.
12
+ *
13
+ * @component
14
+ * @param {object} props - Component props
15
+ * @param {ReadonlyArray<string>} props.options - List of selectable options.
16
+ * @param {string} props.selectedOption - The currently selected option.
17
+ * @param {(option: string) => void} [props.onOptionSelected] - Callback invoked when a new option is selected.
18
+ * @returns {JSX.Element | null} The rendered button group, or null if no options are provided.
19
+ */
20
+ export declare const LegendTextSelector: React.FC<LegendTextSelectorProps>;
21
+ export {};
@@ -1,4 +1,5 @@
1
1
  import { FC } from 'react';
2
+ import { Marker } from '../../types/legendMarkerBadge.type';
2
3
  import { LegendDataId, LegendId } from '../../types/legendType';
3
4
  export interface LegendPopoverContentProps {
4
5
  legendId: LegendId;
@@ -10,6 +11,7 @@ export interface LegendPopoverContentProps {
10
11
  children?: React.ReactNode;
11
12
  excludedLegendTitles?: ReadonlyArray<string>;
12
13
  showAddToSelectionButton?: boolean;
14
+ getMarkersForChipsCreation?: () => ReadonlyArray<Marker>;
13
15
  }
14
16
  export type LegendPopoverTertiaryLabels = {
15
17
  first: string;
@@ -22,6 +24,7 @@ export type LegendPopoverTertiaryLabels = {
22
24
  * Uses `legendId` and `legendDataId` to look up and render relevant `LegendChip` components for the given legend item.
23
25
  * Displays a title, description, and optional tertiary content (either a structured object with up to three strings, or a custom ReactNode).
24
26
  * Additional custom content can be rendered via `children`.
27
+ * Optionally, chips can be created from markers provided by the `getMarkersForChipsCreation` callback.
25
28
  *
26
29
  * @component
27
30
  * @param {object} props - Component props
@@ -33,5 +36,6 @@ export type LegendPopoverTertiaryLabels = {
33
36
  * @param {() => void} [props.onPopoverClicked] - Optional callback for popover click events.
34
37
  * @param {React.ReactNode} [props.children] - Optional custom content to render below the predefined main content.
35
38
  * @param {ReadonlyArray<string>} [props.excludedLegendTitles] - Optional array of titles to exclude from the legend chips.
39
+ * @param {() => ReadonlyArray<Marker>} [props.getMarkersForChipsCreation] - Optional callback that returns the markers to be used for chip creation.
36
40
  */
37
41
  export declare const LegendPopoverContent: FC<LegendPopoverContentProps>;
@@ -13,7 +13,7 @@ import { Marker } from './../../types/legendMarkerBadge.type';
13
13
  * @param {ReadonlyArray<string>} [params.excludedLegendTitles] - Optional array of titles to exclude from the chips (case-insensitive).
14
14
  * @returns {LegendChipProps[]} The filtered and mapped array of LegendChipProps for rendering.
15
15
  */
16
- export declare function getVisibleLegendChips({ markers, legend, excludedLegendTitles }: {
16
+ export declare function getLegendChipsFromMarkers({ markers, legend, excludedLegendTitles }: {
17
17
  markers: ReadonlyArray<Marker>;
18
18
  legend: LegendState;
19
19
  excludedLegendTitles?: ReadonlyArray<string>;
@@ -1,10 +1,16 @@
1
1
  import './legendStrategies/workOrderStrategy/WorkOrderLegend';
2
+ export { getBadgeChips, getMarkerChips } from './components/basicLegendRenderer.logic';
2
3
  export { LegendList } from './components/LegendList';
4
+ export { LegendTextSelector } from './components/legendTextSelector/LegendTextSelector';
3
5
  export { PositionalItem } from './components/pdfMarkers/PositionalItem';
4
6
  export { MultipleMarkersByLegends } from './components/pdfMarkers/subComponents/MultipleMarkersByLegends';
5
7
  export { LegendPopoverContent } from './components/popover/LegendPopoverContent';
6
8
  export type { LegendPopoverContentProps, LegendPopoverTertiaryLabels } from './components/popover/LegendPopoverContent';
7
9
  export { legendFacade } from './legendFacade';
10
+ export { legendSnapShot } from './legendStore';
11
+ export { getLegendStrategy } from './legendStrategies/legendCollections';
8
12
  export type { Badge, Marker } from './types/legendMarkerBadge.type';
9
13
  export type { LegendStrategy } from './types/legendStrategy.type';
10
14
  export type { LegendId, LegendOptionConfig } from './types/legendType';
15
+ export { useLegendVisibleDataStore } from './../legend/legendVisibleDataStore';
16
+ export { useLegendUniqueBadges, useLegendUniqueMarkers } from './hooks/useLegendMarkers';
@@ -2,11 +2,18 @@ export interface Marker {
2
2
  getTitle: () => string;
3
3
  getColor: () => string;
4
4
  getIcon: () => string;
5
- getMarkerKey: () => string;
5
+ /**
6
+ * Returns a key that can be used for clustering or grouping markers together if they share the same key.
7
+ */
8
+ getGroupKey: () => string;
6
9
  badges: Badge[];
7
10
  showAsPlainLabel?: boolean;
8
11
  }
9
12
  export interface Badge {
10
- getColor: () => string;
11
13
  getTitle: () => string;
14
+ getColor: () => string;
15
+ /**
16
+ * Returns a key that can be used for clustering or grouping badges together if they share the same key.
17
+ */
18
+ getGroupKey: () => string;
12
19
  }
@@ -17,6 +17,7 @@ export interface LegendStrategy {
17
17
  * Badge options that is selectable by the user.
18
18
  */
19
19
  badgeOptions?: ReadonlyArray<LegendOptionConfig>;
20
+ getBadgeTextOptions?: (selectedBadgeOption: LegendOptionConfig) => ReadonlyArray<string> | undefined;
20
21
  /**
21
22
  * Returns ONE marker per itemId.
22
23
  */
@@ -17,6 +17,7 @@ export interface LegendState {
17
17
  hiddenBadges: string[];
18
18
  selectedMarkerOption: LegendOptionConfig;
19
19
  selectedBadgeOption: LegendOptionConfig;
20
+ selectedBadgeTextOptions: Record<string, string>;
20
21
  isExpanded: boolean;
21
22
  }
22
23
  export type LegendTagId = GlobalSelectionTypes.TagId;