@mappedin/viewer 0.16.4 → 0.16.5-405d2d3.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.
@@ -1,6 +1,8 @@
1
1
  /// <reference types="react" />
2
+ import { Annotation } from '../../lib/sdk';
2
3
  type TAnnotationMarkerProps = {
3
- annotationId: string;
4
+ annotation: Annotation;
5
+ backgroundColor: string;
4
6
  annotationSrc: string | undefined;
5
7
  size?: number;
6
8
  };
@@ -1 +1,55 @@
1
+ import { Place } from '../../lib/sdk';
2
+ import { E_APP_STATE } from '../../lib/types/state';
1
3
  export declare const id: (...values: string[]) => string;
4
+ type TGenerateGlobalClassNamesOptions = {
5
+ state: E_APP_STATE;
6
+ selectedPlaces: Place[];
7
+ departures: Place[];
8
+ };
9
+ export declare const generateGlobalClassNames: ({ state, selectedPlaces, departures, }: TGenerateGlobalClassNamesOptions) => string;
10
+ /**
11
+ * A utility function returning css that only applies when the provided {@link Place} is selected. Requires
12
+ * {@link generateGlobalClassNames} to be used to apply the correct class names to the root element.
13
+ *
14
+ * @example
15
+ * ```tsx
16
+ * const MyComponent = styled.div<{ place: Place }>`
17
+ * // Change the background color when "place" is selected
18
+ * ${({place}) => isSelected(place)`
19
+ * background-color: red;
20
+ * `}
21
+ * `;
22
+ * ```
23
+ */
24
+ export declare const isSelected: (place: Place) => (...args: any[]) => string;
25
+ /**
26
+ * A utility function returning css that only applies when the provided {@link Place} is a departure. Requires
27
+ * {@link generateGlobalClassNames} to be used to apply the correct class names to the root element.
28
+ *
29
+ * @example
30
+ * ```tsx
31
+ * const MyComponent = styled.div<{ place: Place }>`
32
+ * // Change the background color when "place" is a departure
33
+ * ${({place}) => isDeparture(place)`
34
+ * background-color: red;
35
+ * `}
36
+ * `;
37
+ * ```
38
+ */
39
+ export declare const isDeparture: (place: Place) => (...args: any[]) => string;
40
+ /**
41
+ * A utility function returning css that only applies when the app is in the provided {@link E_APP_STATE}. Requires
42
+ * {@link generateGlobalClassNames} to be used to apply the correct class names to the root element.
43
+ *
44
+ * @example
45
+ * ```tsx
46
+ * const MyComponent = styled.div`
47
+ * // Change the background color when the app is in the "DIRECTIONS" state
48
+ * ${isState(E_APP_STATE.DIRECTIONS)`
49
+ * background-color: red;
50
+ * `}
51
+ * `;
52
+ * ```
53
+ */
54
+ export declare const isState: (state: E_APP_STATE) => (...args: any[]) => string;
55
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -2,6 +2,7 @@
2
2
  import { E_DEPARTURE_MODE } from '../../lib/types/directions';
3
3
  type TDepartureModes = {
4
4
  mode: E_DEPARTURE_MODE;
5
+ modes?: E_DEPARTURE_MODE[];
5
6
  onModeClick?: (mode: E_DEPARTURE_MODE) => void;
6
7
  };
7
8
  declare const DepartureModes: React.FC<TDepartureModes>;
@@ -4,6 +4,7 @@ import { ComponentProps } from 'react';
4
4
  import DirectionsSearchBar from './directions-search-bar';
5
5
  type TDirectionsProps = {
6
6
  departureMode?: ComponentProps<typeof DepartureModes>['mode'];
7
+ departureModes?: ComponentProps<typeof DepartureModes>['modes'];
7
8
  departureQuery?: ComponentProps<typeof DirectionsSearchBar>['query'];
8
9
  onDepartureQueryChange?: ComponentProps<typeof DirectionsSearchBar>['onQueryChange'];
9
10
  onDepartureModeChange?: (mode: E_DEPARTURE_MODE) => void;
@@ -14,6 +14,7 @@ type TMainUIProps = {
14
14
  onSearchBarBlur?: ComponentProps<typeof SearchBar>['onBlur'];
15
15
  maxHeight?: number;
16
16
  departureMode?: ComponentProps<typeof Directions>['departureMode'];
17
+ departureModes?: ComponentProps<typeof Directions>['departureModes'];
17
18
  onDepartureModeChange?: ComponentProps<typeof Directions>['onDepartureModeChange'];
18
19
  departureQuery?: ComponentProps<typeof Directions>['departureQuery'];
19
20
  onDepartureQueryChange?: ComponentProps<typeof Directions>['onDepartureQueryChange'];
@@ -0,0 +1 @@
1
+ export declare const MAIN_UI_DEFAULT_WIDTH_DESKTOP = 320;
@@ -1,11 +1,12 @@
1
1
  import { FocusEvent } from 'react';
2
2
  type TUseDeepFocusProps = {
3
3
  onBlur?: () => void;
4
+ debug?: boolean;
4
5
  };
5
6
  /**
6
7
  * Control when the focus is deep (i.e. when the focus is on the container or any of its children).
7
8
  */
8
- declare const useDeepFocus: ({ onBlur }?: TUseDeepFocusProps) => {
9
+ declare const useDeepFocus: ({ onBlur, debug }?: TUseDeepFocusProps) => {
9
10
  isFocused: boolean;
10
11
  onContainerBlur: (event?: FocusEvent) => void;
11
12
  onContainerFocus: () => void;
@@ -1,11 +1,13 @@
1
1
  type TUseResizeProps = {
2
2
  resizeWidth?: boolean;
3
3
  resizeHeight?: boolean;
4
+ maxHeight?: number;
5
+ maxWidth?: number;
4
6
  };
5
7
  /**
6
8
  * Update the width and height of a wrapper element based on the size of its children.
7
9
  */
8
- declare const useResize: ({ resizeWidth, resizeHeight }?: TUseResizeProps) => {
10
+ declare const useResize: ({ resizeWidth, resizeHeight, maxHeight, maxWidth }?: TUseResizeProps) => {
9
11
  contentRef: (ref: unknown) => void;
10
12
  wrapperRef: (ref: unknown) => void;
11
13
  };
@@ -1,8 +1,8 @@
1
1
  import { MapData, Space, MapObject, PointOfInterest, Connection, Annotation, Coordinate, Door } from '@mappedin/mappedin-js';
2
2
  export declare const loadData: (mapId: string, url?: string) => Promise<MapData>;
3
3
  export declare const loadAnnotationAsset: (annotation: Annotation) => string | undefined;
4
- export declare const isOneOf: <T extends typeof Space | typeof PointOfInterest | typeof Connection | typeof MapObject | typeof Door | typeof Coordinate>(types: T[], object: object) => object is InstanceType<T>;
5
- export declare const PLACE_TYPES: (typeof Space | typeof PointOfInterest | typeof Connection | typeof MapObject | typeof Door | typeof Coordinate)[];
4
+ export declare const isOneOf: <T extends typeof Space | typeof PointOfInterest | typeof Connection | typeof MapObject | typeof Door | typeof Coordinate | typeof Annotation>(types: T[], object: object) => object is InstanceType<T>;
5
+ export declare const PLACE_TYPES: (typeof Space | typeof PointOfInterest | typeof Connection | typeof MapObject | typeof Door | typeof Coordinate | typeof Annotation)[];
6
6
  export type PlaceType = (typeof PLACE_TYPES)[number];
7
7
  export type Place = InstanceType<PlaceType>;
8
8
  export declare const GEOMETRY_TYPES: (typeof Space | typeof MapObject)[];
@@ -1,5 +1,5 @@
1
- export declare const ANIMATION_DURATION_MS = 125;
2
- export declare const SCHEDULER_TIMEOUT_MS = 2000;
1
+ export declare let ANIMATION_DURATION_MS: number;
2
+ export declare const SCHEDULER_TIMEOUT_MS = 500;
3
3
  /**
4
4
  * Simple class to help with scheduling expensive functions against high priority
5
5
  * UI animations.
@@ -31,7 +31,9 @@ declare class AnimationScheduler {
31
31
  * {@link AnimationScheduler} instance to be used throughout the application.
32
32
  */
33
33
  export declare const animationScheduler: AnimationScheduler;
34
- export declare const getTransitionPropsForTaskScheduler: (animationName: string) => {
34
+ export declare const getTransitionPropsForTaskScheduler: (animationName: string, options?: {
35
+ debug?: boolean;
36
+ }) => {
35
37
  onEnter: () => void;
36
38
  onEntered: () => void;
37
39
  onExit: () => void;
@@ -2,3 +2,4 @@ export declare const hexToRGB: (hex: string) => [number, number, number];
2
2
  export declare const RGBToHex: (color: [number, number, number]) => string;
3
3
  export declare const mixColors: (color1: string, color2: string, ratio: number) => string;
4
4
  export declare const opacityToHex: (opacity: number) => string;
5
+ export declare const extractTopLeftPixelColor: (src: string) => Promise<string>;
@@ -1,4 +1,4 @@
1
- import { Place, Coordinate, MapData, Geometry } from '../sdk';
1
+ import { Annotation, Place, Coordinate, MapData, Geometry, TNavigationTarget } from '../sdk';
2
2
  /**
3
3
  * Whether the location can be assumed to be a washroom
4
4
  */
@@ -9,6 +9,7 @@ export declare const isWashroom: (place: Place) => boolean;
9
9
  */
10
10
  export declare const hasMetaData: (place: Place) => boolean;
11
11
  export declare const getCategoryName: (place: Place) => string;
12
+ export declare const getAnnotationName: (annotation: Annotation) => string;
12
13
  type TGetDisplayNameForPlaceOptions = {
13
14
  fallbackToCategoryName?: boolean;
14
15
  };
@@ -26,6 +27,12 @@ export declare const getDisplayNameForPlaces: (places: Place[]) => string;
26
27
  * that is exactly 0,0 is the result of some sort of invalid data.
27
28
  */
28
29
  export declare const isValidPlace: (place: Place) => boolean;
30
+ /**
31
+ * Abstraction for getting navigation target for places. Any place should technically be fine to use
32
+ * as a navigation target, but sometimes the SDK types are stale, and sometimes certain behaviours
33
+ * yield better results.
34
+ */
35
+ export declare const getNavigationTargetForPlaces: (places: Place[]) => TNavigationTarget | TNavigationTarget[];
29
36
  type TProcessedPlaces = {
30
37
  places: Exclude<Place, Coordinate>[];
31
38
  placesById: Record<string, Exclude<Place, Coordinate>>;
@@ -0,0 +1,9 @@
1
+ type ArrayKeys<T> = Exclude<{
2
+ [K in keyof T]: Required<T>[K] extends Array<unknown> ? K : never;
3
+ }[keyof T], undefined>;
4
+ type ArrayValues<T> = Required<T>[ArrayKeys<T>] extends Array<infer U> ? U : never;
5
+ /**
6
+ * Push a value to an array property of an object, creating the array if it doesn't exist.
7
+ */
8
+ export declare const safePush: <T extends object>(object: T, key: Exclude<{ [K in keyof T]: Required<T>[K] extends unknown[] ? K : never; }[keyof T], undefined>, value: ArrayValues<T>) => void;
9
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -1,6 +1,6 @@
1
1
  import type RootStore from '../../root-store';
2
2
  import type MapStore from '..';
3
- import { MapView, TCameraAnimationOptions, TEvents } from '../../../lib/sdk';
3
+ import { MapView, Place, TCameraAnimationOptions, TEvents } from '../../../lib/sdk';
4
4
  export declare const ZOOM_FACTOR = 1.025;
5
5
  export declare const TILT_FACTOR = 1.05;
6
6
  export declare const CAMERA_ANIMATION_OPTIONS: TCameraAnimationOptions;
@@ -20,7 +20,7 @@ declare class CameraController {
20
20
  handleCameraChange(payload?: TEvents['camera-change']): void;
21
21
  handleUserInteractionStart(): void;
22
22
  handleUserInteractionEnd(): void;
23
- focusOn(...[targets, options]: Parameters<MapView['Camera']['focusOn']>): Promise<void>;
23
+ focusOn(targets: Place | Place[], options?: Parameters<MapView['Camera']['focusOn']>[1]): Promise<void>;
24
24
  zoomIn(): Promise<void>;
25
25
  zoomOut(): Promise<void>;
26
26
  resetZoom(): Promise<void>;
@@ -6,7 +6,7 @@ declare class LabelsController {
6
6
  private mapStore;
7
7
  private reactionDisposers;
8
8
  private state;
9
- locationByLabelId: Record<string, Place>;
9
+ placeByLabelId: Record<string, Place>;
10
10
  constructor({ rootStore, mapStore }: {
11
11
  rootStore: RootStore;
12
12
  mapStore: MapStore;
@@ -4,17 +4,21 @@ declare class MarkersController {
4
4
  private rootStore;
5
5
  private mapStore;
6
6
  private reactionDisposers;
7
- markersVisible: boolean;
7
+ private markersVisible;
8
8
  private sdkMarkersByKey;
9
9
  constructor({ rootStore, mapStore }: {
10
10
  rootStore: RootStore;
11
11
  mapStore: MapStore;
12
12
  });
13
13
  private get annotationMarkers();
14
+ private get meMarkers();
14
15
  private get selectionMarkers();
16
+ private get directionsMarkers();
15
17
  private get currentMarkers();
16
18
  private getMarkerColor;
17
19
  private handleZoomChange;
20
+ private addMarker;
21
+ private removeMarker;
18
22
  private updateMarkers;
19
23
  cleanup(): void;
20
24
  }
@@ -25,17 +25,18 @@ declare class RootStore {
25
25
  uiStore: UIStore;
26
26
  mapStore: MapStore;
27
27
  departureMode: E_DEPARTURE_MODE;
28
- isAppMobile: boolean;
28
+ isAppMobile: any;
29
29
  readonly places: Exclude<Place, Coordinate>[];
30
30
  readonly placesById: Record<string, Exclude<Place, Coordinate>>;
31
31
  readonly placesByNames: Record<string, Exclude<Place, Coordinate>[]>;
32
32
  readonly placesByFloorId: Record<string, Exclude<Place, Coordinate>[]>;
33
33
  readonly geometries: Geometry[];
34
34
  readonly geometriesById: Record<string, Geometry>;
35
- constructor({ router, data, startupOptions, }: {
35
+ constructor({ router, data, startupOptions, isMobile, }: {
36
36
  router: RouterStore;
37
37
  data: MapData;
38
38
  startupOptions: TStartViewerOptions | TStartViewerWithLocalDataOptions;
39
+ isMobile: boolean;
39
40
  });
40
41
  private getInitialDepartureMode;
41
42
  private syncState;
@@ -34,11 +34,12 @@ declare class UIStore {
34
34
  get openAppButtonVisible(): boolean;
35
35
  get tiltControlsVisible(): boolean;
36
36
  get zoomControlsVisible(): boolean;
37
- get shareButtonVisible(): boolean;
37
+ get shareButtonVisible(): any;
38
38
  get mainUIVisible(): boolean;
39
39
  get appPadding(): 20 | 0 | 15;
40
40
  get makerPopUpVisible(): boolean;
41
41
  get metadataCardVisible(): boolean;
42
+ get availableDepartureModes(): E_DEPARTURE_MODE[];
42
43
  dismissMakerPopUp(): void;
43
44
  setTheme(theme: TTheme): void;
44
45
  setOverrideShareButtonHandler(handler?: () => void): void;
@@ -4,5 +4,6 @@ export type TMapViewWithTestUtilities = MapView & {
4
4
  __test: {
5
5
  subscribers: Record<string, ((...args: any[]) => void)[]>;
6
6
  labels: SDK.Label[];
7
+ markers: SDK.Marker[];
7
8
  };
8
9
  };
@@ -1,12 +1,12 @@
1
1
  /// <reference types="@mappedin/mappedin-js" />
2
2
  import RootStore from '../stores/root-store';
3
- import { InitialEntry } from 'history';
4
3
  import { ParsedMVF } from '@mappedin/mvf';
5
4
  import { MapData } from '../lib/sdk';
6
5
  import { TStartViewerOptions, TStartViewerWithLocalDataOptions } from '../lib/types/options';
7
6
  type TTestWithMapOptions = {
8
7
  startupOptions?: TStartViewerOptions | TStartViewerWithLocalDataOptions;
9
- initialState?: InitialEntry | ((data: MapData) => InitialEntry);
8
+ initialState?: string | ((data: MapData) => string);
9
+ isMobile?: boolean;
10
10
  };
11
11
  export declare const testWithMap: (venueFileName?: string, options?: TTestWithMapOptions) => Promise<{
12
12
  rootStore: RootStore;
@@ -14,6 +14,7 @@ export declare const testWithMap: (venueFileName?: string, options?: TTestWithMa
14
14
  mapViewTestUtilities: {
15
15
  subscribers: Record<string, ((...args: any[]) => void)[]>;
16
16
  labels: import("@mappedin/mappedin-js/maker/src/map-view-objects/label").Label[];
17
+ markers: import("@mappedin/mappedin-js/maker/src/map-view-objects/marker").Marker[];
17
18
  };
18
19
  mapEl: HTMLDivElement;
19
20
  data: MapData;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mappedin/viewer",
3
- "version": "0.16.4",
3
+ "version": "0.16.5-405d2d3.0",
4
4
  "type": "module",
5
5
  "browser": "./dist/index.js",
6
6
  "license": "UNLICENSED",
@@ -19,9 +19,11 @@
19
19
  "devDependencies": {
20
20
  "@ladle/react": "^2.17.2",
21
21
  "@mappedin/maker-icons": "1.0.0-fe4ca2f",
22
- "@mappedin/mappedin-js": "6.0.1-alpha.7-canary-V5.ddcba63d",
22
+ "@mappedin/mappedin-js": "6.0.1-alpha.11-canary-V5.26bada14",
23
23
  "@mappedin/mvf": "2.0.1-c7526c3.0",
24
+ "@testing-library/react": "^14.2.2",
24
25
  "@testing-library/react-hooks": "^8.0.1",
26
+ "@types/lodash.isequal": "^4.5.8",
25
27
  "@types/react": "^18.2.15",
26
28
  "@types/react-dom": "^18.2.7",
27
29
  "@types/react-transition-group": "^4.4.10",