@equinor/echo-framework 2.2.1 → 2.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs.js +3 -3
- package/package.json +6 -6
- package/src/index.d.ts +3 -2
- package/src/lib/feature/globalSelection/index.d.ts +1 -0
- package/src/lib/feature/legend/components/BasicLegendRenderer.d.ts +0 -1
- package/src/lib/feature/legend/components/LegendRendererWrapper.d.ts +6 -0
- package/src/lib/feature/legend/components/basicLegendRenderer.logic.d.ts +2 -2
- package/src/lib/feature/legend/components/pdfMarkers/subComponents/LegendColoredMarkerIcon.d.ts +24 -4
- package/src/lib/feature/legend/components/pdfMarkers/subComponents/LegendMarkersRenderer.d.ts +2 -0
- package/src/lib/feature/legend/components/pdfMarkers/subComponents/MultipleMarkersByLegends.d.ts +4 -27
- package/src/lib/feature/legend/components/pdfMarkers/subComponents/MultipleMarkersBySingleLegend.d.ts +10 -0
- package/src/lib/feature/legend/components/pdfMarkers/subComponents/hooks/usePopoverHandler.d.ts +2 -2
- package/src/lib/feature/legend/components/pdfMarkers/subComponents/hooks/usePopoverHandler.types.d.ts +14 -0
- package/src/lib/feature/legend/components/pdfMarkers/utils/splitMarkerByBadgeSelectionGroup.d.ts +22 -0
- package/src/lib/feature/legend/components/pdfMarkers/utils/splitMarkerByBadgeSelectionGroup.types.d.ts +19 -0
- package/src/lib/feature/legend/components/popover/LegendPopoverContent.logic.d.ts +3 -2
- package/src/lib/feature/legend/components/selectionLegend/SelectionLegend.d.ts +1 -0
- package/src/lib/feature/legend/components/selectionLegend/SelectionLegendChip.d.ts +7 -0
- package/src/lib/feature/legend/components/selectionLegend/hooks/useAllGroupedMarkersForLegends.d.ts +5 -0
- package/src/lib/feature/legend/components/selectionLegend/hooks/useIsSelectionLegendVisible.d.ts +6 -0
- package/src/lib/feature/legend/components/selectionLegend/selectionLegend.utils.d.ts +34 -0
- package/src/lib/feature/legend/hooks/useGroupedMarkers.d.ts +16 -0
- package/src/lib/feature/legend/hooks/useLegendMarker/useLegendMarker.d.ts +11 -0
- package/src/lib/feature/legend/hooks/useLegendMarker/useLegendMarker.utils.d.ts +21 -0
- package/src/lib/feature/legend/hooks/useLegendUniqueBadges.d.ts +9 -0
- package/src/lib/feature/legend/hooks/useLegendUniqueMarkers.d.ts +9 -0
- package/src/lib/feature/legend/index.d.ts +7 -3
- package/src/lib/feature/legend/legendFacade.d.ts +44 -35
- package/src/lib/feature/legend/legendStrategies/workOrderStrategy/WorkOrderLegend.d.ts +1 -1
- package/src/lib/feature/legend/logic/normalizeBadges.d.ts +33 -0
- package/src/lib/feature/legend/stores/initializeLegendInStores.d.ts +2 -0
- package/src/lib/feature/legend/{legendStore.d.ts → stores/legendDataStore/legendStore.d.ts} +48 -13
- package/src/lib/feature/legend/stores/legendUIStore/legendUIStore.d.ts +32 -0
- package/src/lib/feature/legend/stores/legendUIStore/legendUIStore.types.d.ts +25 -0
- package/src/lib/feature/legend/{legendVisibleDataAsTagsStore.logic.d.ts → stores/legendVisibleDataAsTagsStore/legendVisibleDataAsTagsStore.logic.d.ts} +1 -1
- package/src/lib/feature/legend/{legendVisibleDataStore.d.ts → stores/legendVisibleDataStore/legendVisibleDataStore.d.ts} +1 -1
- package/src/lib/feature/legend/types/legendMarkerBadge.type.d.ts +6 -6
- package/src/lib/feature/legend/types/legendStrategy.type.d.ts +7 -2
- package/src/lib/feature/legend/types/legendType.d.ts +7 -13
- package/src/lib/feature/legend/hooks/useLegendMarkers.d.ts +0 -19
- /package/src/lib/feature/legend/{legendVisibleDataAsTagsStore.d.ts → stores/legendVisibleDataAsTagsStore/legendVisibleDataAsTagsStore.d.ts} +0 -0
- /package/src/lib/feature/legend/{legendVisibleDataAsTagsStore.type.d.ts → stores/legendVisibleDataAsTagsStore/legendVisibleDataAsTagsStore.type.d.ts} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PersistOptions } from 'zustand/middleware';
|
|
2
|
-
import { LegendId, LegendState } from '
|
|
2
|
+
import { LegendId, LegendState } from '../../types/legendType';
|
|
3
3
|
type LegendsDictionary = Record<LegendId, LegendState>;
|
|
4
4
|
export interface LegendStoreData {
|
|
5
5
|
legends: LegendsDictionary;
|
|
@@ -8,20 +8,11 @@ export interface LegendStoreActions {
|
|
|
8
8
|
updateLegend: (legendId: LegendId, updates: Partial<Omit<LegendState, 'isLoading'>>) => void;
|
|
9
9
|
startLoading: (legendId: LegendId) => void;
|
|
10
10
|
finishLoading: (legendId: LegendId) => void;
|
|
11
|
-
setHiddenMarker: (args: {
|
|
12
|
-
legendId: LegendId;
|
|
13
|
-
marker: string;
|
|
14
|
-
isHidden: boolean;
|
|
15
|
-
}) => void;
|
|
16
|
-
setHiddenBadge: (args: {
|
|
17
|
-
legendId: LegendId;
|
|
18
|
-
badge: string;
|
|
19
|
-
isHidden: boolean;
|
|
20
|
-
}) => void;
|
|
21
11
|
getLegendById: (legendId: LegendId) => LegendState | undefined;
|
|
12
|
+
initializeLegendInStore: (legendId: LegendId) => void;
|
|
22
13
|
}
|
|
23
14
|
type LegendStore = LegendStoreData & LegendStoreActions;
|
|
24
|
-
type PersistedLegendState = Omit<LegendState, 'isLoading'
|
|
15
|
+
type PersistedLegendState = Omit<LegendState, 'isLoading'>;
|
|
25
16
|
type PersistedLegendStoreData = {
|
|
26
17
|
legends: Record<LegendId, PersistedLegendState>;
|
|
27
18
|
};
|
|
@@ -52,8 +43,52 @@ export declare const useLegendStore: import("zustand").UseBoundStore<Omit<Omit<O
|
|
|
52
43
|
type: string;
|
|
53
44
|
} | undefined): void;
|
|
54
45
|
}>;
|
|
55
|
-
|
|
46
|
+
/**
|
|
47
|
+
* Hook to access a legend by ID with optional property selection for optimized re-renders.
|
|
48
|
+
*
|
|
49
|
+
* @param legendId - The ID of the legend to access
|
|
50
|
+
* @param selector - Optional selector function to pick specific properties from the legend
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* // Watch all properties (triggers re-render on any change):
|
|
54
|
+
* const legend = useLegendById('Tag Legend');
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* // Watch only isEnabled (triggers re-render only when isEnabled changes):
|
|
58
|
+
* const isEnabled = useLegendById('Tag Legend', (legend) => legend?.isEnabled);
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* // Watch multiple specific properties:
|
|
62
|
+
* const { isEnabled, isLoading } = useLegendById('Tag Legend', useShallow((legend) => ({
|
|
63
|
+
* isEnabled: legend?.isEnabled,
|
|
64
|
+
* isLoading: legend?.isLoading
|
|
65
|
+
* })));
|
|
66
|
+
*/
|
|
67
|
+
export declare function useLegendById(legendId: LegendId): LegendState | undefined;
|
|
68
|
+
export declare function useLegendById<T>(legendId: LegendId, selector: (legend: LegendState | undefined) => T): T;
|
|
69
|
+
export declare function legendExistsInLegendStore(legendId: LegendId): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Hook to access all legends with optional property selection for optimized re-renders.
|
|
72
|
+
*
|
|
73
|
+
* @param selector - Optional selector function to transform the legends array
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* // Watch all properties (triggers re-render on any change):
|
|
77
|
+
* const legends = useAllLegends();
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* // Watch only specific properties with useShallow for optimal performance:
|
|
81
|
+
* import { useShallow } from 'zustand/react/shallow';
|
|
82
|
+
* const legendsMinimal = useAllLegends(
|
|
83
|
+
* useShallow((legends) => legends.map(l => ({ legendId: l.legendId, isEnabled: l.isEnabled })))
|
|
84
|
+
* );
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* // Get only enabled legends:
|
|
88
|
+
* const enabledLegends = useAllLegends((legends) => legends.filter(l => l.isEnabled));
|
|
89
|
+
*/
|
|
56
90
|
export declare function useAllLegends(): LegendState[];
|
|
91
|
+
export declare function useAllLegends<T>(selector: (legends: LegendState[]) => T): T;
|
|
57
92
|
export declare function legendSnapShot(): LegendStore;
|
|
58
93
|
export declare const legendStoreSubscribe: {
|
|
59
94
|
(listener: (selectedState: LegendStore, previousSelectedState: LegendStore) => void): () => void;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { LegendId } from '../../types/legendType';
|
|
2
|
+
import { LegendUIState, LegendUIStore } from './legendUIStore.types';
|
|
3
|
+
/**
|
|
4
|
+
* Non-persisted store for managing UI state of legends, such as accordion expansion and hidden markers/badges.
|
|
5
|
+
*/
|
|
6
|
+
export declare const useLegendUIStore: import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<LegendUIStore>, "setState"> & {
|
|
7
|
+
setState(nextStateOrUpdater: LegendUIStore | Partial<LegendUIStore> | ((state: import("immer").WritableDraft<LegendUIStore>) => void), shouldReplace?: boolean | undefined): void;
|
|
8
|
+
}>;
|
|
9
|
+
/**
|
|
10
|
+
* Hook to access a legend by ID with optional property selection for optimized re-renders.
|
|
11
|
+
*
|
|
12
|
+
* @param legendId - The ID of the legend to access
|
|
13
|
+
* @param selector - Optional selector function to pick specific properties from the legend
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // Watch all properties (triggers re-render on any change):
|
|
17
|
+
* const legend = useLegendUIById('Tag Legend');
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // Watch only isAccordionExpanded (triggers re-render only when isAccordionExpanded changes):
|
|
21
|
+
* const isAccordionExpanded = useLegendUIById('Tag Legend', (legend) => legend?.isAccordionExpanded);
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* // Watch multiple specific properties:
|
|
25
|
+
* const { isAccordionExpanded, hiddenMarkers } = useLegendUIById('Tag Legend', useShallow((legend) => ({
|
|
26
|
+
* isAccordionExpanded: legend?.isAccordionExpanded,
|
|
27
|
+
* hiddenMarkers: legend?.hiddenMarkers
|
|
28
|
+
* })));
|
|
29
|
+
*/
|
|
30
|
+
export declare function useLegendUIById(legendId: LegendId): LegendUIState | undefined;
|
|
31
|
+
export declare function useLegendUIById<T>(legendId: LegendId, selector: (legend: LegendUIState | undefined) => T): T;
|
|
32
|
+
export declare function legendExistsInLegendUIStore(legendId: LegendId): boolean;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { LegendId } from '../../types/legendType';
|
|
2
|
+
export interface LegendUIState {
|
|
3
|
+
readonly isAccordionExpanded: boolean;
|
|
4
|
+
readonly hiddenMarkers: string[];
|
|
5
|
+
readonly hiddenBadges: string[];
|
|
6
|
+
}
|
|
7
|
+
export type LegendUIDictionary = Record<LegendId, LegendUIState>;
|
|
8
|
+
export type LegendUIStoreValues = {
|
|
9
|
+
legends: LegendUIDictionary;
|
|
10
|
+
};
|
|
11
|
+
export interface LegendUIStoreActions {
|
|
12
|
+
toggleAccordion: (legendId: LegendId, newValue: boolean) => void;
|
|
13
|
+
setHiddenMarker: (args: {
|
|
14
|
+
legendId: LegendId;
|
|
15
|
+
marker: string;
|
|
16
|
+
isHidden: boolean;
|
|
17
|
+
}) => void;
|
|
18
|
+
setHiddenBadge: (args: {
|
|
19
|
+
legendId: LegendId;
|
|
20
|
+
badge: string;
|
|
21
|
+
isHidden: boolean;
|
|
22
|
+
}) => void;
|
|
23
|
+
initializeLegendInStore: (legendId: LegendId) => void;
|
|
24
|
+
}
|
|
25
|
+
export type LegendUIStore = LegendUIStoreValues & LegendUIStoreActions;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
+
import { LegendEquipmentId } from '../../types/legendType';
|
|
1
2
|
import { TagWithEquipmentId } from './legendVisibleDataAsTagsStore.type';
|
|
2
|
-
import { LegendEquipmentId } from './types/legendType';
|
|
3
3
|
export declare function fetchTagsByEquipment(equipmentIds: ReadonlyArray<LegendEquipmentId>, abortController: AbortController): Promise<TagWithEquipmentId[] | undefined>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LegendDataId, LegendEquipmentId, LegendTagId } from '
|
|
1
|
+
import { LegendDataId, LegendEquipmentId, LegendTagId } from '../../types/legendType';
|
|
2
2
|
/**
|
|
3
3
|
* Maps (string) keyword to the data type.
|
|
4
4
|
* We don't have any other sources so far, pdf has TagNo and EquipmentId (ecm)
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
+
import { GlobalSelectionTypes } from '../../globalSelection';
|
|
1
2
|
export interface Marker {
|
|
2
3
|
getTitle: () => string;
|
|
3
4
|
getColor: () => string;
|
|
4
5
|
getIcon: () => string;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
getGroupKey: () => string;
|
|
9
|
-
badges: Badge[];
|
|
6
|
+
getDisplayKey: () => string;
|
|
7
|
+
getHighlightColor: () => string;
|
|
8
|
+
badges: ReadonlyArray<Badge>;
|
|
10
9
|
showAsPlainLabel?: boolean;
|
|
11
10
|
}
|
|
12
11
|
export interface Badge {
|
|
@@ -15,5 +14,6 @@ export interface Badge {
|
|
|
15
14
|
/**
|
|
16
15
|
* Returns a key that can be used for clustering or grouping badges together if they share the same key.
|
|
17
16
|
*/
|
|
18
|
-
|
|
17
|
+
getDisplayKey: () => string;
|
|
18
|
+
getItemId: () => GlobalSelectionTypes.ItemId;
|
|
19
19
|
}
|
|
@@ -19,9 +19,14 @@ export interface LegendStrategy {
|
|
|
19
19
|
badgeOptions?: ReadonlyArray<LegendOptionConfig>;
|
|
20
20
|
getBadgeTextOptions?: (selectedBadgeOption: LegendOptionConfig) => ReadonlyArray<string> | undefined;
|
|
21
21
|
/**
|
|
22
|
-
* Returns
|
|
22
|
+
* Returns 1 marker with badges for each incoming itemId. The viewport will make them unique when needed, and
|
|
23
|
+
* also split into groups based on (global) selection tree
|
|
24
|
+
*
|
|
25
|
+
* @param itemIds - The legend data IDs to create markers for
|
|
26
|
+
* @param isViewport - Optional use this for rendering different markers/badges in viewport compared to legendRenderer. For example equipmentLegend, where we render part-type name in legendRenderer, but id in viewport.
|
|
27
|
+
* @returns Array of markers with badges, 1 marker with badges for each incoming itemId
|
|
23
28
|
*/
|
|
24
|
-
useMarkers: (itemIds: ReadonlyArray<LegendDataId
|
|
29
|
+
useMarkers: (itemIds: ReadonlyArray<LegendDataId>, isViewport?: boolean) => ReadonlyArray<Marker>;
|
|
25
30
|
/**
|
|
26
31
|
* Returns popover content that supports pagination for the given itemId.
|
|
27
32
|
*
|
|
@@ -1,24 +1,19 @@
|
|
|
1
1
|
import { Brand } from '@equinor/echo-utils';
|
|
2
2
|
import { GlobalSelectionTypes } from '../../globalSelection';
|
|
3
|
-
type
|
|
4
|
-
export type KnownLegendIds = 'Equipment' | 'Tag Legend' | TemporaryLegendIdsForTesting;
|
|
3
|
+
export type KnownLegendIds = 'Equipment Legend' | 'Tag Legend' | 'Work Order Legend';
|
|
5
4
|
export type LegendId = KnownLegendIds | Brand<string, 'LegendId'>;
|
|
6
|
-
export declare function createLegendId(id: string): LegendId;
|
|
7
5
|
export declare const knownLegendIds: {
|
|
8
6
|
equipmentLegendId: LegendId;
|
|
9
7
|
tagLegendId: LegendId;
|
|
10
8
|
workOrderLegendId: LegendId;
|
|
11
9
|
};
|
|
12
10
|
export interface LegendState {
|
|
13
|
-
legendId: LegendId;
|
|
14
|
-
isEnabled: boolean;
|
|
15
|
-
isLoading: boolean;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
selectedBadgeOption: LegendOptionConfig;
|
|
20
|
-
selectedBadgeTextOptions: Record<string, string>;
|
|
21
|
-
isExpanded: boolean;
|
|
11
|
+
readonly legendId: LegendId;
|
|
12
|
+
readonly isEnabled: boolean;
|
|
13
|
+
readonly isLoading: boolean;
|
|
14
|
+
readonly selectedMarkerOption: LegendOptionConfig;
|
|
15
|
+
readonly selectedBadgeOption: LegendOptionConfig;
|
|
16
|
+
readonly selectedBadgeTextOptions: Record<string, string>;
|
|
22
17
|
}
|
|
23
18
|
export type LegendTagId = GlobalSelectionTypes.TagId;
|
|
24
19
|
export type LegendEquipmentId = GlobalSelectionTypes.EquipmentId;
|
|
@@ -36,4 +31,3 @@ export interface LegendOptionConfig<T = string> {
|
|
|
36
31
|
displayName: string;
|
|
37
32
|
showChipsInViewportOnly?: boolean;
|
|
38
33
|
}
|
|
39
|
-
export {};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Badge, Marker } from '../types/legendMarkerBadge.type';
|
|
2
|
-
import { LegendDataId, LegendId } from '../types/legendType';
|
|
3
|
-
/**
|
|
4
|
-
* Returns the marker for the given legendId and itemId.
|
|
5
|
-
*/
|
|
6
|
-
export declare function useLegendMarker(args: {
|
|
7
|
-
legendId: LegendId;
|
|
8
|
-
itemId: LegendDataId;
|
|
9
|
-
}): Marker | undefined;
|
|
10
|
-
/**
|
|
11
|
-
* Returns all unique markers for the given legendId, determined by unique markerKey (title + color).
|
|
12
|
-
*/
|
|
13
|
-
export declare function useLegendUniqueMarkers(args: {
|
|
14
|
-
legendId: LegendId;
|
|
15
|
-
}): ReadonlyArray<Marker>;
|
|
16
|
-
/**
|
|
17
|
-
* Returns all unique badges for the given legendId, determined by unique title + color.
|
|
18
|
-
*/
|
|
19
|
-
export declare function useLegendUniqueBadges(legendId: LegendId): ReadonlyArray<Badge>;
|
|
File without changes
|