@mappable-world/mappable-types 0.0.12 → 0.0.13

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.
@@ -19,7 +19,7 @@ type VectorCustomizationStyler = {
19
19
  };
20
20
  type VectorCustomizationTypes = 'point' | 'polyline' | 'polygon';
21
21
  type VectorCustomizationElements = 'geometry' | 'geometry.fill' | 'geometry.fill.pattern' | 'geometry.outline' | 'label' | 'label.icon' | 'label.text' | 'label.text.fill' | 'label.text.outline';
22
- type VectorCustomization = {
22
+ type VectorCustomizationItem = {
23
23
  tags?: {
24
24
  all?: string | string[];
25
25
  any?: string | string[];
@@ -28,7 +28,8 @@ type VectorCustomization = {
28
28
  types?: VectorCustomizationTypes | VectorCustomizationTypes[];
29
29
  elements?: VectorCustomizationElements | VectorCustomizationElements[];
30
30
  stylers?: VectorCustomizationStyler | VectorCustomizationStyler[];
31
- }[];
31
+ };
32
+ type VectorCustomization = VectorCustomizationItem[];
32
33
  interface WorldHotspot {
33
34
  readonly type: 'world';
34
35
  readonly feature: HotspotFeature<unknown>;
@@ -134,4 +135,4 @@ interface VectorTileDataSourceDescription {
134
135
  /** Defines how hotspots of type should be treated: enabled/disabled or use custom hotspots instead. */
135
136
  hotspots?: Record<string, boolean | FetchHotspotsFunction | HotspotsOptions>;
136
137
  }
137
- export { VectorCustomization, RasterTileDataSourceDescription, FetchHotspotsFunction, VectorTileDataSourceDescription, VectorTileSize, VectorObjectsCollisionPriority, VectorDataSourcePriority, HotspotsOptions, FetchTileFunction, ComposeTileUrlFunction, Hotspot, WorldHotspot, RenderedHotspot, FetchedTile, MapTheme };
138
+ export { VectorCustomizationTypes, VectorCustomizationElements, VectorCustomizationItem, VectorCustomization, RasterTileDataSourceDescription, FetchHotspotsFunction, VectorTileDataSourceDescription, VectorTileSize, VectorObjectsCollisionPriority, VectorDataSourcePriority, HotspotsOptions, FetchTileFunction, ComposeTileUrlFunction, Hotspot, WorldHotspot, RenderedHotspot, FetchedTile, MapTheme };
@@ -15,8 +15,15 @@ export declare function createDomContext(containerEntity: GenericComplexEntity<u
15
15
  DomContext,
16
16
  DomContextDestroy
17
17
  ];
18
- export declare function useDomContext(entity: GenericComplexEntity<unknown>, element: Element, container: Element | null): () => void;
19
- /** @deprecated Use `useDomContext` instead. */
18
+ /**
19
+ * Hook for providing DOM context in entity
20
+ * @param entity - Entity to provide the DomContext
21
+ * @param element - Dom element that is passed to DomContext
22
+ * @param container - Inner DOM element that is passed to the DOMContext
23
+ * @returns Function that detaches the DOM element and DomContext from the entity
24
+ */
25
+ export declare function useDomContext(entity: GenericComplexEntity<unknown>, element: Element, container: Element | null): DomDetach;
26
+ /** @deprecated Use {@link useDomContext} instead. */
20
27
  export declare abstract class DomEntity<TProps, TElement extends Element = HTMLElement, DefaultProps extends {} = {}> extends MMapGroupEntity<TProps, DefaultProps> {
21
28
  protected _element?: TElement;
22
29
  private _detachDom?;
@@ -12,39 +12,177 @@ declare class ContextProvider<T> {
12
12
  type WithDefaults<Props, DefaultProps extends Partial<Props>> = Props & {
13
13
  [K in keyof DefaultProps]: K extends keyof Props ? NonNullable<Props[K]> : never;
14
14
  };
15
+ /**
16
+ * Entity Base Class. It has event handlers for attaching, detaching and updating props. Has a method for providing and using context.
17
+ * @typeParam Props - Type of input props of the Entity.
18
+ * @typeParam DefaultProps - Type of default input props of the Entity.
19
+ * @typeParam Root - Root Entity Class.
20
+ * @example
21
+ * ```ts
22
+ * type MMapSomeEntityProps = {
23
+ * name?: string;
24
+ * };
25
+ * const defaultProps = {
26
+ * name: 'entity'
27
+ * };
28
+ * class MMapSomeEntity extends GenericEntity<MMapSomeEntityProps, typeof defaultProps> {
29
+ * public isAttached: boolean;
30
+ * constructor(props: MMapSomeEntityProps) {
31
+ * super(props);
32
+ * this.isAttached = false
33
+ * // Additional actions can be taken in the constructor of a class.
34
+ * }
35
+ * protected _onAttach(): void {
36
+ * this.isAttached = true;
37
+ * // Additional actions can be taken when an Entity is attached.
38
+ * }
39
+ * // ...
40
+ * }
41
+ * ```
42
+ */
15
43
  declare abstract class GenericEntity<Props, DefaultProps extends {} = {}, Root extends GenericRootEntity<unknown> = GenericRootEntity<unknown>> {
44
+ /**
45
+ * The value of input props.
46
+ */
16
47
  protected _props: WithDefaults<Props, DefaultProps>;
17
48
  /**
18
- * @param {Props} props
19
- * @param {DefaultProps} defaultProps
49
+ * @param props - The value of input props.
20
50
  */
21
51
  constructor(props: Props);
52
+ /**
53
+ * Method for updating props of Entity.
54
+ * @param changedProps - New props values.
55
+ */
22
56
  update(changedProps: Partial<Props>): void;
57
+ /**
58
+ * Handler of the attachment event to the parent Entity.
59
+ * @virtual
60
+ */
23
61
  protected _onAttach?(): void;
62
+ /**
63
+ * Handler of the detachment event to the parent Entity.
64
+ * @virtual
65
+ */
24
66
  protected _onDetach?(): void;
67
+ /**
68
+ * Handler of the update event to the current Entity.
69
+ * @param props - New props values.
70
+ * @param oldProps - Previous props values.
71
+ * @virtual
72
+ */
25
73
  protected _onUpdate?(props: Partial<Props>, oldProps: Props): void;
74
+ /**
75
+ * Get parent entity.
76
+ */
26
77
  get parent(): GenericComplexEntity<unknown> | null;
78
+ /**
79
+ * Get root entity.
80
+ */
27
81
  get root(): Root | null;
82
+ /**
83
+ * Provides context in the Entity.
84
+ * @param consumer - The context that provides access to the context value.
85
+ * @param ctx - The value passed to the context.
86
+ */
28
87
  protected _provideContext<T>(consumer: Context<T>, ctx: T): void;
88
+ /**
89
+ * Gets the value from the passed context.
90
+ * @param consumer - The context that provides access to the context value.
91
+ * @returns Context value.
92
+ */
29
93
  protected _consumeContext<T>(consumer: Context<T>): T | undefined;
30
94
  }
31
95
  interface ComplexOptions<Root extends GenericRootEntity<unknown> = GenericRootEntity<unknown>> {
32
96
  children?: GenericEntity<unknown, {}, Root>[];
33
97
  container?: boolean;
34
98
  }
99
+ /**
100
+ * Entity that aggregates multiple Entities but looks basic from the outside.
101
+ * @typeParam Props - Type of input props of the Entity.
102
+ * @typeParam DefaultProps - Type of default input props of the Entity.
103
+ * @typeParam Root - Root Entity Class.
104
+ * @example
105
+ * ```ts
106
+ * type MMapSomeComplexEntityProps = {
107
+ * name?: string;
108
+ * };
109
+ * const defaultProps = {
110
+ * name: 'entity'
111
+ * };
112
+ * class MMapSomeComplexEntity extends GenericComplexEntity<MMapSomeComplexEntityProps, typeof defaultProps> {
113
+ * private _someEntity?: MMapSomeEntity; // MMapSomeEntity extends GenericEntity
114
+ * protected _onAttach(): void {
115
+ * this._someEntity = new MMapSomeEntity();
116
+ * this.addChild(this._someEntity); // add someEntity as children
117
+ * // ...
118
+ * }
119
+ * // ...
120
+ * }
121
+ * ```
122
+ */
35
123
  declare class GenericComplexEntity<Props, DefaultProps extends {} = {}, Root extends GenericRootEntity<unknown> = GenericRootEntity<unknown>> extends GenericEntity<Props, DefaultProps, Root> {
124
+ /**
125
+ * Array of child Entities of the current ComplexEntity.
126
+ */
36
127
  protected readonly children: readonly GenericEntity<unknown, {}, Root>[];
37
128
  protected readonly _childContainer: GenericComplexEntity<unknown, {}, Root>;
129
+ /**
130
+ * @param props - The value of input props.
131
+ * @param options - Optional options object.
132
+ * @param children - Array of child Entities of the current ComplexEntity.
133
+ * @param options.children - Array of child Entities of the current ComplexEntity.
134
+ * @param options.container - Creating a proxy container inside ComplexEntity.
135
+ */
38
136
  constructor(props: Props, options?: ComplexOptions<Root>);
137
+ constructor(props: Props, children?: GenericEntity<unknown, {}, Root>[], options?: Omit<ComplexOptions<Root>, "children">);
39
138
  protected __makeProxyContainer(): GenericComplexEntity<unknown, {}, Root>;
40
139
  /**
41
- * Adds a child directly to __implChildren, without _childContainer
140
+ * Adds a child directly to __implChildren, without _childContainer.
141
+ * @param child - Child Entity to be added
142
+ * @param index - 0-based ordinal number of the entity being added
42
143
  */
43
144
  protected _addDirectChild(child: GenericEntity<unknown, {}, Root>, index?: number): void;
145
+ /**
146
+ * Adds a child directly to _childContainer
147
+ * @param child - Child Entity to be added
148
+ * @param index - 0-based ordinal number of the entity being added
149
+ * @returns Current ComplexEntity
150
+ */
44
151
  protected addChild(child: GenericEntity<unknown, {}, Root>, index?: number): this;
152
+ /**
153
+ * Deletes a child element directly in __implChildren, without _childContainer.
154
+ * @param child - Child Entity to be removed
155
+ */
45
156
  protected _removeDirectChild(child: GenericEntity<unknown, {}, Root>): void;
157
+ /**
158
+ * Deletes a child directly to _childContainer
159
+ * @param child - Child Entity to be removed
160
+ * @returns Current ComplexEntity
161
+ */
46
162
  protected removeChild(child: GenericEntity<unknown, {}, Root>): this;
47
163
  }
164
+ /**
165
+ * Entity that aggregates multiple Entities, and allows you to publicly add and remove entities to a subtree.
166
+ * @typeParam Props - Type of input props of the Entity.
167
+ * @typeParam DefaultProps - Type of default input props of the Entity.
168
+ * @typeParam Root - Root Entity Class.
169
+ * @example
170
+ * ```ts
171
+ * type MMapSomeGroupEntityProps = {
172
+ * name?: string;
173
+ * };
174
+ * const defaultProps = {
175
+ * name: 'entity'
176
+ * };
177
+ * class MMapSomeGroupEntity extends GenericGroupEntity<MMapSomeGroupEntityProps, typeof defaultProps> {
178
+ * // ...
179
+ * }
180
+ * const groupEntity = new MMapSomeGroupEntity()
181
+ * const someEntity = new MMapSomeEntity(); // MMapSomeEntity extends GenericEntity
182
+ * groupEntity.addChild(someEntity); // add someEntity in MMapSomeGroupEntity object
183
+ * groupEntity.removeChild(someEntity); // remove someEntity from MMapSomeGroupEntity object
184
+ * ```
185
+ */
48
186
  declare class GenericGroupEntity<Props, DefaultProps extends {} = {}, Root extends GenericRootEntity<unknown> = GenericRootEntity<unknown>> extends GenericComplexEntity<Props, DefaultProps, Root> {
49
187
  readonly children: readonly GenericEntity<unknown, {}, Root>[];
50
188
  protected readonly _childContainer: GenericGroupEntity<unknown, {}, Root>;
@@ -52,10 +190,29 @@ declare class GenericGroupEntity<Props, DefaultProps extends {} = {}, Root exten
52
190
  addChild(child: GenericEntity<unknown, {}, Root>, index?: number): this;
53
191
  removeChild(child: GenericEntity<unknown, {}, Root>): this;
54
192
  }
193
+ /**
194
+ * Entity that is root and cannot be added anywhere
195
+ * @typeParam Props - Type of input props of the Entity.
196
+ * @typeParam DefaultProps - Type of default input props of the Entity.
197
+ * @example
198
+ * type MMapProps = {
199
+ * name?: string;
200
+ * };
201
+ * class MMap extends GenericRootEntity<MMapProps, typeof defaultProps> {
202
+ * // ...
203
+ * }
204
+ * // Now we can specify their root element for the Entity
205
+ * class MMapSomeEntity extends GenericEntity<MMapSomeEntityProps, typeof defaultProps, MMap> {
206
+ * // ...
207
+ * }
208
+ */
55
209
  declare abstract class GenericRootEntity<Props, DefaultProps extends {} = {}> extends GenericGroupEntity<Props, DefaultProps> {
56
210
  get root(): this;
57
211
  protected _onAttach: undefined;
58
212
  protected _onDetach: undefined;
213
+ /**
214
+ * Completely destroys the entity tree including the current entity
215
+ */
59
216
  abstract destroy(): void;
60
217
  }
61
218
  type EntityProps<T extends GenericEntity<unknown>> = T extends GenericEntity<infer P> ? P : never;
@@ -3,6 +3,7 @@ import type { MMapEntity } from "../MMapEnities";
3
3
  import { GenericRootEntity } from "../Entities";
4
4
  import { MMapCopyrightsPosition } from "../MMapCopyrights";
5
5
  import { Config } from "../config";
6
+ import { MMapTheme } from "../ThemeContext";
6
7
  import { overrideKeyReactify } from "../wrappers";
7
8
  /**
8
9
  * Sets map center.
@@ -92,6 +93,8 @@ export type MMapProps = {
92
93
  * Whether to repeat the world in X and Y
93
94
  */
94
95
  worldOptions?: WorldOptions;
96
+ /** Theme applied to the scheme */
97
+ theme?: MMapTheme;
95
98
  };
96
99
  declare const defaultProps: Readonly<{
97
100
  className: "";
@@ -115,6 +118,7 @@ declare const defaultProps: Readonly<{
115
118
  restrictMapArea: false;
116
119
  readonly config: Config;
117
120
  projection: Projection;
121
+ theme: "light";
118
122
  }>;
119
123
  type DefaultProps = typeof defaultProps;
120
124
  /**
@@ -160,6 +164,7 @@ declare class MMap extends GenericRootEntity<MMapProps, DefaultProps> {
160
164
  restrictMapArea: false;
161
165
  readonly config: Config;
162
166
  projection: Projection;
167
+ theme: "light";
163
168
  }>;
164
169
  static [overrideKeyReactify]: import("../../reactify/reactify").CustomReactify<MMap, import("react").ForwardRefExoticComponent<{
165
170
  className?: string | undefined;
@@ -178,6 +183,7 @@ declare class MMap extends GenericRootEntity<MMapProps, DefaultProps> {
178
183
  copyrightsPosition?: MMapCopyrightsPosition | undefined;
179
184
  projection?: Projection | undefined;
180
185
  worldOptions?: WorldOptions | undefined;
186
+ theme?: MMapTheme | undefined;
181
187
  children?: import("react").ReactNode;
182
188
  ref?: import("react").Ref<MMap> | undefined;
183
189
  key?: import("react").Key | null | undefined;
@@ -238,6 +244,14 @@ declare class MMap extends GenericRootEntity<MMapProps, DefaultProps> {
238
244
  * getter for {@link MMapProps}.config prop
239
245
  */
240
246
  get config(): Readonly<Config>;
247
+ /**
248
+ * getter for {@link MMapProps}.restrictMapArea prop
249
+ */
250
+ get restrictMapArea(): Readonly<LngLatBounds | false>;
251
+ /**
252
+ * getter for {@link MMapProps}.theme prop
253
+ */
254
+ get theme(): "light" | "dark";
241
255
  /**
242
256
  * setter for {@link MMapProps}.location prop
243
257
  * @param location
@@ -279,6 +293,11 @@ declare class MMap extends GenericRootEntity<MMapProps, DefaultProps> {
279
293
  * @param {Projection} projection
280
294
  */
281
295
  setProjection(projection: Projection): void;
296
+ /**
297
+ * setter for {@link MMapProps}.config prop
298
+ * @param {LngLatBounds} restrictMapArea
299
+ */
300
+ setRestrictMapArea(restrictMapArea: LngLatBounds): void;
282
301
  /**
283
302
  * Destroy map and remove it from user DOM-element
284
303
  */
@@ -290,5 +309,6 @@ declare class MMap extends GenericRootEntity<MMapProps, DefaultProps> {
290
309
  private __onVectorInitFailed;
291
310
  private __loadVectorEngine;
292
311
  private __toggleCopyrights;
312
+ private setTheme;
293
313
  }
294
314
  export { MMap };
@@ -1,5 +1,5 @@
1
- import { DomEntity } from "../DomContext";
2
1
  import { overrideKeyReactify } from "../wrappers";
2
+ import { MMapGroupEntity } from "../MMapEnities";
3
3
  /**
4
4
  * MMapControl props
5
5
  */
@@ -9,7 +9,7 @@ export type MMapControlProps = {};
9
9
  *
10
10
  * @example
11
11
  * ```javascript
12
- * const control = new MMapControl({});
12
+ * const control = new MMapControl();
13
13
  * class MMapSomeController extends DomEntity {
14
14
  * _createDom() {
15
15
  * const element = document.createElement('button');
@@ -30,7 +30,7 @@ export type MMapControlProps = {};
30
30
  *
31
31
  * @module MMapControl
32
32
  */
33
- export declare class MMapControl<T extends MMapControlProps = MMapControlProps> extends DomEntity<T> {
33
+ export declare class MMapControl<T extends MMapControlProps = MMapControlProps> extends MMapGroupEntity<T> {
34
34
  static [overrideKeyReactify]: import("../../reactify/reactify").CustomReactify<MMapControl<MMapControlProps>, import("react").ForwardRefExoticComponent<{
35
35
  children?: import("react").ReactNode;
36
36
  ref?: import("react").Ref<import("../Entities").GenericEntity<{
@@ -38,9 +38,12 @@ export declare class MMapControl<T extends MMapControlProps = MMapControlProps>
38
38
  }, {}, import("../Entities").GenericRootEntity<unknown, {}>>> | undefined;
39
39
  key?: import("react").Key | null | undefined;
40
40
  }>>;
41
- protected _createDom(): {
42
- element: HTMLElement;
43
- container: HTMLElement;
44
- };
45
- protected _updateDom(element: HTMLElement): void;
41
+ private _detachDom?;
42
+ private _element?;
43
+ private _unwatchThemeContext?;
44
+ constructor();
45
+ protected _createDom(): HTMLElement;
46
+ protected _onAttach(): void;
47
+ protected _onDetach(): void;
48
+ private _updateTheme;
46
49
  }
@@ -1,5 +1,4 @@
1
- import { DomEntity } from "../DomContext";
2
- import { MMapComplexEntity } from "../MMapEnities";
1
+ import { MMapComplexEntity, MMapGroupEntity } from "../MMapEnities";
3
2
  import { overrideKeyReactify } from "../wrappers";
4
3
  /**
5
4
  * MMapControlButton props
@@ -23,12 +22,15 @@ export type MMapControlButtonProps = MMapControlCommonButtonProps;
23
22
  /**
24
23
  * Default control button.
25
24
  */
26
- export declare class MMapControlCommonButton extends DomEntity<MMapControlCommonButtonProps, HTMLButtonElement> {
27
- protected _createDom(): {
28
- element: HTMLButtonElement;
29
- container: HTMLElement;
30
- };
31
- protected _updateDom(element: HTMLButtonElement, props: Partial<MMapControlCommonButtonProps>, init?: boolean): void;
25
+ export declare class MMapControlCommonButton extends MMapGroupEntity<MMapControlCommonButtonProps> {
26
+ private _element?;
27
+ private _detachDom?;
28
+ private _unwatchThemeContext?;
29
+ protected _onAttach(): void;
30
+ private _updateElement;
31
+ protected _onUpdate(props: Partial<MMapControlCommonButtonProps>): void;
32
+ protected _onDetach(): void;
33
+ private _updateTheme;
32
34
  }
33
35
  /**
34
36
  * The control element - button.
@@ -62,7 +64,8 @@ export declare class MMapControlButton extends MMapComplexEntity<MMapControlButt
62
64
  }>>;
63
65
  private _control;
64
66
  private _button;
65
- constructor(props: MMapControlButtonProps);
67
+ protected _onAttach(): void;
66
68
  protected _onUpdate(props: Partial<MMapControlButtonProps>): void;
69
+ protected _onDetach(): void;
67
70
  get text(): string | undefined;
68
71
  }
@@ -1,4 +1,4 @@
1
- import { DomEntity } from "../DomContext";
1
+ import { MMapEntity, MMapGroupEntity } from "../MMapEnities";
2
2
  type VerlicalPosition = "top" | "bottom";
3
3
  type HorizontalPosition = "left" | "right";
4
4
  type Orientation = "horizontal" | "vertical";
@@ -33,11 +33,12 @@ export type MMapControlsProps = {
33
33
  * map.addChild(controls);
34
34
  * ```
35
35
  */
36
- export declare class MMapControls extends DomEntity<MMapControlsProps> {
37
- protected _createDom(): {
38
- element: HTMLElement;
39
- container: HTMLElement;
40
- };
41
- protected _updateDom(element: HTMLElement): void;
36
+ export declare class MMapControls extends MMapGroupEntity<MMapControlsProps> {
37
+ private _element?;
38
+ private _detachDom?;
39
+ constructor(props: MMapControlsProps, children?: MMapEntity<unknown>[]);
40
+ protected _onAttach(): void;
41
+ protected _onUpdate(): void;
42
+ protected _onDetach(): void;
42
43
  }
43
44
  export {};
@@ -1,4 +1,4 @@
1
- import { DomEntity } from "../DomContext";
1
+ import { MMapGroupEntity } from "../MMapEnities";
2
2
  type MMapCopyrightsPosition = "top left" | "top right" | "bottom left" | "bottom right";
3
3
  type MMapCopyrightsProps = {
4
4
  /** Position of copyright on the map */
@@ -12,7 +12,7 @@ type DefaultProps = typeof defaultProps;
12
12
  * The copyright display component on the map.
13
13
  * Data for display uses from the `MMapCoverage` component
14
14
  */
15
- declare class MMapCopyrights extends DomEntity<MMapCopyrightsProps, HTMLElement, DefaultProps> {
15
+ declare class MMapCopyrights extends MMapGroupEntity<MMapCopyrightsProps, DefaultProps> {
16
16
  static defaultProps: Readonly<{
17
17
  position: MMapCopyrightsPosition;
18
18
  }>;
@@ -20,19 +20,23 @@ declare class MMapCopyrights extends DomEntity<MMapCopyrightsProps, HTMLElement,
20
20
  private _copyrightsTextElement;
21
21
  private _linkElement;
22
22
  private _logoElement;
23
+ private _copyrightsContainer;
23
24
  private _mapWidth;
24
25
  private _copyrights;
25
26
  private _fixedCopyrights;
26
27
  private _userAgreementText;
27
28
  private _userAgreementState;
28
29
  private _unwatchMapContext?;
30
+ private _unwatchThemeContext?;
31
+ private _detachDom?;
29
32
  constructor(props?: MMapCopyrightsProps);
30
33
  protected _updateDom(): void;
31
34
  protected _onAttach(): void;
32
35
  protected _onDetach(): void;
33
- protected _createDom(): HTMLDivElement;
36
+ private _createDom;
34
37
  private _syncDom;
35
38
  private _syncMapWidth;
39
+ private _syncTheme;
36
40
  private _setUserAgreementText;
37
41
  private _setUserAgreementState;
38
42
  private _setCopyrights;
@@ -40,4 +44,4 @@ declare class MMapCopyrights extends DomEntity<MMapCopyrightsProps, HTMLElement,
40
44
  private _copyrightsChangeHandler;
41
45
  private _adjustText;
42
46
  }
43
- export { MMapCopyrights, MMapCopyrightsProps, MMapCopyrightsPosition };
47
+ export { MMapCopyrights, MMapCopyrightsPosition, MMapCopyrightsProps };
@@ -6,9 +6,12 @@ import { MMapComplexEntity } from "../MMapEnities";
6
6
  type MMapDefaultSchemeLayerProps = {
7
7
  /** Should show layer */
8
8
  visible?: boolean;
9
- /** Vector tiles customization. Not allowed on a free tariff. */
9
+ /** Vector tiles customization. */
10
10
  customization?: VectorCustomization;
11
- /** Theme applied to the scheme */
11
+ /**
12
+ * Theme applied to the scheme
13
+ * @deprecated use {@link MMapProps}.theme prop in {@link MMap} instead
14
+ * */
12
15
  theme?: "dark" | "light";
13
16
  };
14
17
  declare const defaultProps: {
@@ -72,11 +75,13 @@ declare class MMapDefaultSchemeLayer extends MMapComplexEntity<MMapDefaultScheme
72
75
  private _dataSource?;
73
76
  private _layers;
74
77
  private _unwatchMapContext?;
78
+ private _unwatchThemeContext?;
75
79
  protected _onAttach(): void;
76
80
  protected _onDetach(): void;
77
81
  protected _onUpdate(propsDiff: Partial<MMapDefaultSchemeLayerProps>): void;
78
82
  private _createTileUrl;
79
83
  private _getProjectionQuery;
80
84
  private _getDataSourceDescription;
85
+ private _updateTheme;
81
86
  }
82
87
  export { MMapDefaultSchemeLayer, MMapDefaultSchemeLayerProps };
@@ -1,13 +1,86 @@
1
1
  import type { MMap } from "./MMap";
2
2
  import { GenericComplexEntity, GenericEntity, GenericGroupEntity, Context } from "./Entities";
3
+ /**
4
+ * Entity Base Class. It has event handlers for attaching, detaching and updating props. Has a method for providing and using context.
5
+ * @typeParam Props - Type of input props of the Entity.
6
+ * @typeParam DefaultProps - Type of default input props of the Entity.
7
+ * @example
8
+ * ```ts
9
+ * type MMapSomeEntityProps = {
10
+ * name?: string;
11
+ * };
12
+ * const defaultProps = {
13
+ * name: 'entity'
14
+ * };
15
+ * class MMapSomeEntity extends MMapEntity<MMapSomeEntityProps, typeof defaultProps> {
16
+ * public isAttached: boolean;
17
+ * constructor(props: MMapSomeEntityProps) {
18
+ * super(props);
19
+ * this.isAttached = false
20
+ * // Additional actions can be taken in the constructor of a class.
21
+ * }
22
+ * protected _onAttach(): void {
23
+ * this.isAttached = true;
24
+ * // Additional actions can be taken when an Entity is attached.
25
+ * }
26
+ * // ...
27
+ * }
28
+ * ```
29
+ */
3
30
  declare abstract class MMapEntity<Props, DefaultProps extends {} = {}> extends GenericEntity<Props, DefaultProps, MMap> {
4
31
  get root(): null | MMap;
5
32
  get parent(): null | MMapComplexEntity<unknown>;
6
33
  }
34
+ /**
35
+ * Entity that aggregates multiple Entities but looks basic from the outside.
36
+ * @typeParam Props - Type of input props of the Entity.
37
+ * @typeParam DefaultProps - Type of default input props of the Entity.
38
+ * @typeParam Root - Root Entity Class.
39
+ * @example
40
+ * ```ts
41
+ * type MMapSomeComplexEntityProps = {
42
+ * name?: string;
43
+ * };
44
+ * const defaultProps = {
45
+ * name: 'entity'
46
+ * };
47
+ * class MMapSomeComplexEntity extends MMapComplexEntity<MMapSomeComplexEntityProps, typeof defaultProps> {
48
+ * private _someEntity?: MMapSomeEntity; // MMapSomeEntity extends GenericEntity
49
+ * protected _onAttach(): void {
50
+ * this._someEntity = new MMapSomeEntity();
51
+ * this.addChild(this._someEntity); // add someEntity as children
52
+ * // ...
53
+ * }
54
+ * // ...
55
+ * }
56
+ * ```
57
+ */
7
58
  declare abstract class MMapComplexEntity<Props, DefaultProps extends {} = {}> extends GenericComplexEntity<Props, DefaultProps, MMap> implements MMapEntity<Props, DefaultProps> {
8
59
  get root(): null | MMap;
9
60
  get parent(): null | MMapComplexEntity<unknown>;
10
61
  }
62
+ /**
63
+ * Entity that aggregates multiple Entities, and allows you to publicly add and remove entities to a subtree.
64
+ * @typeParam Props - Type of input props of the Entity.
65
+ * @typeParam DefaultProps - Type of default input props of the Entity.
66
+ * @typeParam Root - Root Entity Class.
67
+ * @example
68
+ * ```ts
69
+ * type MMapSomeGroupEntityProps = {
70
+ * name?: string;
71
+ * };
72
+ * const defaultProps = {
73
+ * name: 'entity'
74
+ * };
75
+ * class MMapSomeGroupEntity extends MMapGroupEntity<MMapSomeGroupEntityProps, typeof defaultProps> {
76
+ * // ...
77
+ * }
78
+ * const groupEntity = new MMapSomeGroupEntity()
79
+ * const someEntity = new MMapSomeEntity(); // MMapSomeEntity extends GenericEntity
80
+ * groupEntity.addChild(someEntity); // add someEntity in MMapSomeGroupEntity object
81
+ * groupEntity.removeChild(someEntity); // remove someEntity from MMapSomeGroupEntity object
82
+ * ```
83
+ */
11
84
  declare abstract class MMapGroupEntity<Props, DefaultProps extends {} = {}> extends GenericGroupEntity<Props, DefaultProps, MMap> implements MMapComplexEntity<Props, DefaultProps> {
12
85
  get root(): null | MMap;
13
86
  get parent(): null | MMapComplexEntity<unknown>;
@@ -0,0 +1,9 @@
1
+ import { Context } from "./Entities";
2
+ /**
3
+ * Sets map theme
4
+ */
5
+ export type MMapTheme = "light" | "dark";
6
+ export type MMapThemeContext = {
7
+ theme: MMapTheme;
8
+ };
9
+ export declare const ThemeContext: Context<MMapThemeContext>;
@@ -1,4 +1,5 @@
1
1
  export { MMap, MMapProps, MMapCenterLocation, MMapZoomLocation, MMapBoundsLocation, MMapCenterZoomLocation, MMapLocationRequest, MMapCameraRequest } from "./MMap";
2
+ export { MMapThemeContext, ThemeContext, MMapTheme } from "./ThemeContext";
2
3
  export { MMapCopyrightsPosition } from "./MMapCopyrights";
3
4
  export { MMapEntity, MMapComplexEntity, MMapGroupEntity, MMapContext } from "./MMapEnities";
4
5
  export { MMapDefaultFeaturesLayer, MMapDefaultFeaturesLayerProps } from "./MMapDefaultFeaturesLayer";
@@ -20,10 +21,10 @@ export * from "./search";
20
21
  export * from "./suggest";
21
22
  export * from "./route";
22
23
  export { geolocation } from "./geolocation";
23
- export { useDomContext } from "./DomContext";
24
+ export { useDomContext, DomDetach } from "./DomContext";
24
25
  export { Config, getDefaultConfig } from "./config";
25
26
  export { fetchConfig, FetchConfigOptions } from "./fetchConfig";
26
27
  export * as projections from "./utils/projections";
27
28
  /** Toggle this to enable/disable strict mode. */
28
29
  export declare let strictMode: boolean;
29
- export type { LngLat, ReadonlyLngLat, LngLatBounds, BehaviorType, MapMode, Margin, ZoomRange, ZoomStrategy, ZoomRounding, VectorCustomization, RasterTileDataSourceDescription, VectorTileDataSourceDescription, RasterLayerOptions, EasingFunctionDescription, EasingPresetName, EasingBezierPreset, EasingFunction, DrawingStyle, DrawingStyleIcon, VectorTileSize, VectorObjectsCollisionPriority, VectorDataSourcePriority } from "../common/types";
30
+ export type { LngLat, ReadonlyLngLat, LngLatBounds, BehaviorType, MapMode, Margin, ZoomRange, ZoomStrategy, ZoomRounding, VectorCustomizationTypes, VectorCustomizationElements, VectorCustomizationItem, VectorCustomization, RasterTileDataSourceDescription, VectorTileDataSourceDescription, RasterLayerOptions, EasingFunctionDescription, EasingPresetName, EasingBezierPreset, EasingFunction, DrawingStyle, DrawingStyleIcon, VectorTileSize, VectorObjectsCollisionPriority, VectorDataSourcePriority } from "../common/types";
@@ -1,9 +1,8 @@
1
- import { DomEntity } from "../../../imperative/DomContext";
2
- declare class MMapFeatureEditorDefaultPoint extends DomEntity<{}> {
3
- protected _createDom(): {
4
- element: HTMLElement;
5
- container: HTMLElement;
6
- };
7
- protected _updateDom(): void;
1
+ import { MMapGroupEntity } from "../../../imperative";
2
+ declare class MMapFeatureEditorDefaultPoint extends MMapGroupEntity<{}> {
3
+ private _detachDom?;
4
+ private _element?;
5
+ protected _onAttach(): void;
6
+ protected _onDetach(): void;
8
7
  }
9
8
  export { MMapFeatureEditorDefaultPoint };
@@ -1,6 +1,8 @@
1
- import { DomEntity } from "../../../imperative/DomContext";
2
- declare class MMapFeatureEditorDefaultPreviewPoint extends DomEntity<{}> {
3
- protected _createDom(): HTMLElement;
4
- protected _updateDom(): void;
1
+ import { MMapGroupEntity } from "../../../imperative";
2
+ declare class MMapFeatureEditorDefaultPreviewPoint extends MMapGroupEntity<{}> {
3
+ private _detachDom?;
4
+ private _element?;
5
+ protected _onAttach(): void;
6
+ protected _onDetach(): void;
5
7
  }
6
8
  export { MMapFeatureEditorDefaultPreviewPoint };
@@ -1,5 +1,5 @@
1
1
  import type { LngLat, DrawingStyle, GenericLineStringGeometry, GenericPolygonGeometry } from "../../../common/types";
2
- import type { DomEntity } from "../../../imperative/DomContext";
2
+ import type { MMapEntity } from "../../../imperative";
3
3
  export type Geometry = GenericPolygonGeometry<LngLat> | GenericLineStringGeometry<LngLat>;
4
4
  export interface DraggingPoint {
5
5
  point: LngLat;
@@ -14,8 +14,8 @@ export type MMapFeatureEditorProps = {
14
14
  points: LngLat[];
15
15
  geometry: Geometry;
16
16
  featureStyle?: DrawingStyle;
17
- renderPoint?: (index: number) => HTMLElement | DomEntity<unknown>;
18
- previewPointElement?: false | HTMLElement | DomEntity<unknown>;
17
+ renderPoint?: (index: number) => HTMLElement | MMapEntity<unknown>;
18
+ previewPointElement?: false | HTMLElement | MMapEntity<unknown>;
19
19
  onLayerClick?: (coordinates: LngLat, index: number) => void;
20
20
  onPointClick?: (index: number) => void;
21
21
  onPointDblClick?: (index: number) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mappable-world/mappable-types",
3
- "version": "0.0.12",
3
+ "version": "0.0.13",
4
4
  "description": "Types for mappable maps library",
5
5
  "main": "",
6
6
  "types": "index.d.ts",
@@ -17,6 +17,11 @@ type MMapClustererProps = {
17
17
  tickTimeout?: number;
18
18
  /** Return false, if you want to override the render */
19
19
  onRender?: (clusters: ClustererObject[]) => void | false;
20
+ /**
21
+ * Maximum zoom for clusterisation.
22
+ * If map zoom is bigger, markers will be displayed as is.
23
+ **/
24
+ maxZoom?: number;
20
25
  };
21
26
  type DefaultProps = typeof defaultProps;
22
27
  declare const defaultProps: Readonly<{
@@ -52,6 +57,7 @@ declare class MMapClusterer extends mappable.MMapComplexEntity<MMapClustererProp
52
57
  }>;
53
58
  static [mappable.overrideKeyReactify]: import("../../../reactify/reactify").CustomReactify<MMapClusterer, import("react").ForwardRefExoticComponent<{
54
59
  features: Feature[];
60
+ maxZoom?: number | undefined;
55
61
  method: IClusterMethod;
56
62
  tickTimeout?: number | undefined;
57
63
  onRender?: ((clusters: ClustererObject[]) => false | void) | undefined;
@@ -59,6 +65,7 @@ declare class MMapClusterer extends mappable.MMapComplexEntity<MMapClustererProp
59
65
  cluster: (coordinates: LngLat, features: Feature[]) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
60
66
  ref?: import("react").Ref<MMapEntity<{
61
67
  features: Feature[];
68
+ maxZoom?: number | undefined;
62
69
  method: IClusterMethod;
63
70
  tickTimeout?: number | undefined;
64
71
  onRender?: ((clusters: ClustererObject[]) => false | void) | undefined;
@@ -1,6 +1,8 @@
1
1
  declare class MMapControlSpinner extends mappable.MMapComplexEntity<{}> {
2
2
  private _detachDom?;
3
+ private _unwatchThemeContext?;
3
4
  protected _onAttach(): void;
4
5
  protected _onDetach(): void;
6
+ private _updateTheme;
5
7
  }
6
8
  export { MMapControlSpinner };
@@ -40,6 +40,7 @@ declare class MMapGeolocationControl extends mappable.MMapGroupEntity<MMapGeoloc
40
40
  private _loading;
41
41
  private _element;
42
42
  private _unwatchMapContext?;
43
+ private _unwatchThemeContext?;
43
44
  constructor(props: MMapGeolocationControlProps);
44
45
  private _timeout;
45
46
  private _setLoading;
@@ -51,5 +52,6 @@ declare class MMapGeolocationControl extends mappable.MMapGroupEntity<MMapGeoloc
51
52
  protected _onUpdate(props: Partial<MMapGeolocationControlProps>): void;
52
53
  private _initMarker;
53
54
  private _updateMarkerIcon;
55
+ private _updateTheme;
54
56
  }
55
57
  export { MMapGeolocationControl, MMapGeolocationControlProps };
@@ -1,6 +1,7 @@
1
1
  import type { EasingFunctionDescription } from "../../../common/types";
2
2
  import type { MMapControlCommonButton } from "../../../imperative/MMapControl";
3
3
  import type { MMapListener } from "../../../imperative/MMapListener";
4
+ import type { DomDetach } from "../../../imperative";
4
5
  import type { CustomVuefyOptions } from "../../../modules/vuefy";
5
6
  /**
6
7
  * MMapZoomControl props
@@ -27,7 +28,7 @@ type DefaultProps = typeof defaultProps;
27
28
  * map.addChild(controls);
28
29
  * ```
29
30
  */
30
- declare class MMapZoomControl extends mappable.MMapControl<MMapZoomControlProps> {
31
+ declare class MMapZoomControl extends mappable.MMapGroupEntity<MMapZoomControlProps> {
31
32
  static defaultProps: Readonly<{
32
33
  duration: 200;
33
34
  }>;
@@ -36,11 +37,15 @@ declare class MMapZoomControl extends mappable.MMapControl<MMapZoomControlProps>
36
37
  protected _zoomOut: MMapControlCommonButton;
37
38
  protected _listener: MMapListener;
38
39
  private _currentZoom;
40
+ protected _detachDom?: DomDetach;
41
+ protected _element?: HTMLElement;
42
+ private _unwatchThemeContext?;
39
43
  constructor(props: MMapZoomControlProps);
40
44
  private _onMapUpdate;
41
45
  private _changeZoom;
42
46
  protected _onAttach(): void;
43
47
  protected _onDetach(): void;
44
- protected _onUpdate(props: MMapZoomControlProps): void;
48
+ protected _onUpdate(): void;
49
+ private _updateTheme;
45
50
  }
46
51
  export { MMapZoomControl, MMapZoomControlProps };
@@ -35,6 +35,7 @@ declare const MMapHintContext: import("../../../imperative/Entities").Context<un
35
35
  *
36
36
  * _onDetach() {
37
37
  * this._detachDom();
38
+ * this._detachDom = undefined;
38
39
  * }
39
40
  * });
40
41
  * ```
@@ -43,7 +44,7 @@ declare class MMapHint extends mappable.MMapGroupEntity<MMapHintProps> {
43
44
  static [overrideKeyReactify]: CustomReactify<MMapHint, TReact.FC<MMapHintProps>>;
44
45
  static [overrideKeyVuefy]: CustomVuefyFn<MMapHint>;
45
46
  static [optionsKeyVuefy]: CustomVuefyOptions<MMapHint>;
46
- private _detachDom;
47
+ private _detachDom?;
47
48
  private _element;
48
49
  private _hintElement;
49
50
  constructor(props: MMapHintProps);