ts-maps 0.2.5 → 0.2.6

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 (59) hide show
  1. package/dist/components/base.d.ts +5 -7
  2. package/dist/components/concerns/interactable.d.ts +0 -6
  3. package/dist/components/line.d.ts +11 -11
  4. package/dist/components/marker.d.ts +24 -5
  5. package/dist/components/region.d.ts +28 -3
  6. package/dist/components/tooltip.d.ts +18 -76
  7. package/dist/core/apply-transform.d.ts +7 -47
  8. package/dist/core/coords-to-point.d.ts +9 -25
  9. package/dist/core/create-lines.d.ts +2 -39
  10. package/dist/core/create-markers.d.ts +2 -50
  11. package/dist/core/create-regions.d.ts +2 -22
  12. package/dist/core/create-series.d.ts +2 -19
  13. package/dist/core/get-inset-for-point.d.ts +3 -30
  14. package/dist/core/get-marker-position.d.ts +3 -12
  15. package/dist/core/index.d.ts +0 -23
  16. package/dist/core/reposition-labels.d.ts +2 -23
  17. package/dist/core/reposition-lines.d.ts +2 -32
  18. package/dist/core/reposition-markers.d.ts +2 -23
  19. package/dist/core/resize.d.ts +0 -2
  20. package/dist/core/set-focus.d.ts +2 -58
  21. package/dist/core/set-scale.d.ts +2 -80
  22. package/dist/core/setup-container-events.d.ts +2 -49
  23. package/dist/core/setup-container-touch-events.d.ts +2 -68
  24. package/dist/core/setup-element-events.d.ts +1 -131
  25. package/dist/core/setup-zoom-buttons.d.ts +2 -21
  26. package/dist/core/update-size.d.ts +2 -7
  27. package/dist/data-visualization.d.ts +14 -96
  28. package/dist/defaults/events.d.ts +0 -13
  29. package/dist/defaults/options.d.ts +0 -4
  30. package/dist/event-handler.d.ts +0 -11
  31. package/dist/index.d.ts +2 -10
  32. package/dist/legend.d.ts +8 -5
  33. package/dist/map.d.ts +78 -425
  34. package/dist/maps/brasil.d.ts +1 -0
  35. package/dist/maps/canada.d.ts +1 -0
  36. package/dist/maps/iraq.d.ts +0 -3
  37. package/dist/maps/italy.d.ts +1 -0
  38. package/dist/maps/russia.d.ts +0 -3
  39. package/dist/maps/spain.d.ts +1 -0
  40. package/dist/maps/us-aea-en.d.ts +0 -3
  41. package/dist/maps/us-lcc-en.d.ts +0 -3
  42. package/dist/maps/us-merc-en.d.ts +0 -3
  43. package/dist/maps/us-mill-en.d.ts +0 -3
  44. package/dist/maps/world-merc.d.ts +1 -0
  45. package/dist/maps/world.d.ts +1 -0
  46. package/dist/projection.d.ts +0 -17
  47. package/dist/scales/ordinal-scale.d.ts +4 -24
  48. package/dist/series.d.ts +13 -3
  49. package/dist/svg/base-element.d.ts +16 -2
  50. package/dist/svg/canvas-element.d.ts +20 -7
  51. package/dist/svg/image-element.d.ts +10 -5
  52. package/dist/svg/shape-element.d.ts +11 -2
  53. package/dist/svg/text-element.d.ts +6 -0
  54. package/dist/types.d.ts +32 -17
  55. package/dist/util/deep-merge.d.ts +1 -43
  56. package/dist/util/index.d.ts +6 -13
  57. package/dist/utils.d.ts +67 -3
  58. package/dist/vector-map.d.ts +2 -12
  59. package/package.json +1 -2
@@ -1,8 +1,21 @@
1
- declare const path: unknown;
2
- declare const circle: unknown;
3
- declare const line: unknown;
4
- declare const text: unknown;
5
- declare const image: unknown;
6
- declare const group: unknown;
7
-
1
+ import SVGElement from './base-element';
2
+ import SVGImageElement from './image-element';
3
+ import SVGShapeElement from './shape-element';
4
+ import SVGTextElement from './text-element';
5
+ import type { ShapeStyle } from './shape-element';
6
+ declare class SVGCanvasElement extends SVGElement {
7
+ protected _container: HTMLElement;
8
+ protected _defsElement: SVGElement;
9
+ protected _rootElement: SVGElement;
10
+ constructor(container: HTMLElement);
11
+ setSize(width: number, height: number): void;
12
+ applyTransformParams(scale: number, transX: number, transY: number): void;
13
+ createPath(config: Record<string, string | number>, style: ShapeStyle, group?: SVGElement): SVGShapeElement;
14
+ createCircle(config: Record<string, string | number>, style: ShapeStyle, group?: SVGElement): SVGShapeElement;
15
+ createLine(config: Record<string, string | number>, style: ShapeStyle, group?: SVGElement): SVGShapeElement;
16
+ createText(config: Record<string, string | number>, style: ShapeStyle, group?: SVGElement): SVGTextElement;
17
+ createImage(config: Record<string, string | number>, style: ShapeStyle, group?: SVGElement): SVGImageElement;
18
+ createGroup(id?: string): SVGElement;
19
+ protected _add<T extends SVGElement>(element: T, group?: SVGElement): T;
20
+ }
8
21
  export default SVGCanvasElement;
@@ -1,7 +1,12 @@
1
- declare interface ImageConfig {
2
- url?: string
3
- offset?: [number, number]
1
+ import SVGShapeElement from './shape-element';
2
+ import type { ShapeStyle } from './shape-element';
3
+ declare class SVGImageElement extends SVGShapeElement {
4
+ protected width: number;
5
+ protected height: number;
6
+ protected cx: number;
7
+ protected cy: number;
8
+ protected offset: [number, number];
9
+ constructor(config: Record<string, string | number>, style: ShapeStyle);
10
+ applyAttr(attr: string, value: string | number | ImageConfig): void;
4
11
  }
5
- declare const config: unknown;
6
-
7
12
  export default SVGImageElement;
@@ -1,3 +1,4 @@
1
+ import SVGElement from './base-element';
1
2
  export declare interface ShapeStyle {
2
3
  initial: Record<string, string | number>
3
4
  current?: Record<string, string | number>
@@ -5,6 +6,14 @@ export declare interface ShapeStyle {
5
6
  selected?: Record<string, string | number>
6
7
  selectedHover?: Record<string, string | number>
7
8
  }
8
- declare const attrs: Record<string, string | number>;
9
-
9
+ declare class SVGShapeElement extends SVGElement {
10
+ protected isHovered: boolean;
11
+ protected isSelected: boolean;
12
+ protected style: ShapeStyle;
13
+ constructor(name: string, config?: Record<string, string | number>, style?: ShapeStyle);
14
+ hover(state: boolean): void;
15
+ select(state: boolean): void;
16
+ setStyle(property: string | Record<string, string | number>, value?: string | number): void;
17
+ updateStyle(): void;
18
+ }
10
19
  export default SVGShapeElement;
@@ -1 +1,7 @@
1
+ import SVGShapeElement from './shape-element';
2
+ import type { ShapeStyle } from './shape-element';
3
+ declare class SVGTextElement extends SVGShapeElement {
4
+ constructor(config: Record<string, string | number>, style: ShapeStyle);
5
+ applyAttr(attr: string, value: string | number): void;
6
+ }
1
7
  export default SVGTextElement;
package/dist/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Tooltip } from './components/tooltip';
2
-
2
+ import type { VectorMap } from 'ts-maps';
3
3
  export declare interface MapOptions {
4
4
  selector: string
5
5
  map: {
@@ -51,7 +51,6 @@ export declare interface MapOptions {
51
51
  onMarkerSelected?: (event: MouseEvent, index: string, isSelected: boolean, selectedMarkers: string[]) => void
52
52
  onRegionTooltipShow?: (event: MouseEvent, tooltip: HTMLElement, code: string) => void
53
53
  onMarkerTooltipShow?: (event: MouseEvent, tooltip: HTMLElement, code: string) => void
54
- [key: string]: any
55
54
  }
56
55
  export declare interface FocusOnOptions {
57
56
  region?: string
@@ -72,7 +71,6 @@ export declare interface MarkerConfig {
72
71
  r?: number
73
72
  [key: string]: any
74
73
  }
75
- [key: string]: any
76
74
  }
77
75
  export declare interface MarkerConstructorConfig {
78
76
  index: string
@@ -128,38 +126,57 @@ export declare interface LineConfig {
128
126
  strokeLinecap?: string
129
127
  [key: string]: any
130
128
  }
131
- [key: string]: any
132
129
  }
133
130
  export declare interface SeriesConfig {
134
131
  attribute: string
135
132
  scale?: string[]
136
133
  values?: Record<string, number>
137
- [key: string]: any
138
134
  }
139
135
  export declare interface DataVisualizationOptions {
140
- scale: [string, string]
141
- values: Record<string, number | string>
136
+ scale: [string, string]
137
+ values: Record<string, number | string>
142
138
  }
139
+ /**
140
+ * Type definitions for Italy map data
141
+ */
142
+ /**
143
+ * Geographic coordinate point
144
+ */
143
145
  export declare interface GeoPoint {
144
146
  x: number
145
147
  y: number
146
148
  }
149
+ /**
150
+ * Bounding box coordinates
151
+ */
147
152
  export declare interface BBox {
148
153
  bbox: [GeoPoint, GeoPoint]
149
154
  }
155
+ /**
156
+ * Inset properties for the map
157
+ */
150
158
  export declare interface Inset extends BBox {
151
159
  width: number
152
160
  top: number
153
161
  height: number
154
162
  left: number
155
163
  }
164
+ /**
165
+ * Region properties
166
+ */
156
167
  export declare interface RegionMapData {
157
168
  path: string
158
169
  name: string
159
170
  }
171
+ /**
172
+ * Map of regions by their code
173
+ */
160
174
  export declare interface RegionMap {
161
- [regionCode: string]: RegionMapData
175
+
162
176
  }
177
+ /**
178
+ * Map data properties
179
+ */
163
180
  export declare interface MapData {
164
181
  insets?: Inset[]
165
182
  paths: RegionMap
@@ -187,19 +204,16 @@ export declare interface MapInterface {
187
204
  regions?: SeriesConfig[]
188
205
  }
189
206
  }
190
-
191
207
  series: {
192
208
  markers: any[]
193
209
  regions: any[]
194
210
  }
195
-
196
211
  mercator: {
197
212
  convert: (lat: number, lng: number) => { x: number, y: number } | false
198
213
  }
199
214
  miller: {
200
215
  convert: (lat: number, lng: number) => { x: number, y: number } | false
201
216
  }
202
-
203
217
  _width: number
204
218
  _height: number
205
219
  _defaultWidth: number
@@ -215,7 +229,6 @@ export declare interface MapInterface {
215
229
  _regionLabelsGroup?: any
216
230
  _mapData: MapData
217
231
  _tooltip?: Tooltip
218
-
219
232
  setBackgroundColor: (color: string) => void
220
233
  getSelectedRegions: () => string[]
221
234
  clearSelectedRegions: (regions?: string[] | undefined) => void
@@ -235,7 +248,6 @@ export declare interface MapInterface {
235
248
  getInsetForPoint: (x: number, y: number) => any
236
249
  getMarkerPosition: (config: MarkerConfig) => { x: number, y: number } | false
237
250
  coordsToPoint: (lat: number, lng: number) => { x: number, y: number } | false
238
-
239
251
  _repositionMarkers: () => void
240
252
  _repositionLines: () => void
241
253
  _repositionLabels: () => void
@@ -271,10 +283,7 @@ export declare interface Line {
271
283
  setStyle: (style: Record<string, string | number>) => void
272
284
  }
273
285
  export declare interface EventRegistry {
274
- [uid: string]: {
275
- selector: HTMLElement
276
- handler: EventListenerOrEventListenerObject
277
- }
286
+
278
287
  }
279
288
  export declare interface SVGCanvasElement {
280
289
  createGroup: (id: string) => SVGElement
@@ -400,4 +409,10 @@ export declare interface SeriesInstance {
400
409
  scale: string[]
401
410
  values: Record<string, number>
402
411
  attribute: string
412
+ }
413
+ // Add to window object if in browser environment
414
+ declare namespace global {
415
+ interface Window {
416
+ VectorMap: typeof VectorMap
417
+ }
403
418
  }
@@ -1,44 +1,2 @@
1
- declare interface Options {
2
- arrayMerge?: (target: any[], source: any[], options: Options) => any[]
3
- clone?: boolean
4
- customMerge?: (key: string) => ((x: any, y: any) => any) | undefined
5
- isMergeableObject?: (value: any) => boolean
6
- cloneUnlessOtherwiseSpecified?: (value: any, options: Options) => any
7
- }
8
1
  declare type DeepMergeResult = Record<string | symbol, any>
9
-
10
- const deepmerge: {
11
- <T>(target: T, source: T, options?: Options): T
12
- } = function deepmerge<T>(target: T, source: T, options: Options = {}): T {
13
- options.arrayMerge = options.arrayMerge || defaultArrayMerge
14
- options.isMergeableObject = options.isMergeableObject || isMergeableObject
15
- options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified
16
-
17
- const sourceIsArray = Array.isArray(source)
18
- const targetIsArray = Array.isArray(target)
19
- const sourceAndTargetTypesMatch = sourceIsArray === targetIsArray
20
-
21
- if (!sourceAndTargetTypesMatch) {
22
- return cloneUnlessOtherwiseSpecified(source, options) as T
23
- }
24
-
25
- if (sourceIsArray) {
26
- return options.arrayMerge(target as any[], source as any[], options) as T
27
- }
28
-
29
- return mergeObject(target as Record<string | symbol, any>, source as Record<string | symbol, any>, options) as T
30
- }
31
- declare function isMergeableObject(value: any): boolean;
32
- declare function isNonNullObject(value: any): boolean;
33
- declare function isSpecial(value: any): boolean;
34
- declare function isReactElement(value: any): boolean;
35
- declare function isNode(value: any): boolean;
36
- declare function emptyTarget(val: any): any[] | Record<string | symbol, any>;
37
- declare function cloneUnlessOtherwiseSpecified(value: any, options: Options): any;
38
- declare function defaultArrayMerge(target: any[], source: any[], options: Options): any[];
39
- declare function getMergeFunction(key: string, options: Options): (x: any, y: any, options: Options) => any;
40
- declare function getEnumerableOwnPropertySymbols(target: Record<string | symbol, any>): symbol[];
41
- declare function getKeys(target: Record<string | symbol, any>): (string | symbol)[];
42
- declare function propertyIsOnObject(object: Record<string | symbol, any>, property: string | symbol): boolean;
43
- declare function propertyIsUnsafe(target: Record<string | symbol, any>, key: string | symbol): boolean;
44
- declare function mergeObject(target: Record<string | symbol, any>, source: Record<string | symbol, any>, options: Options): DeepMergeResult;
2
+ export default deepmerge;
@@ -1,16 +1,9 @@
1
+ /**
2
+ * --------------------------------------------------------------------------
3
+ * Public Util Api
4
+ * --------------------------------------------------------------------------
5
+ */
1
6
  declare type ElementType = Element | null
2
- interface Constructor { prototype: Record<string, any> }
3
- declare function getElement(selector: string | Element): ElementType;
4
- declare function createElement(type: string, classes?: string, content?: string, html?: boolean): HTMLElement;
5
- declare function findElement(parentElement: Element, selector: string): Element | null;
6
- declare function removeElement(target: Element): void;
7
- declare function isImageUrl(url: string): boolean;
8
- declare function hyphenate(str: string): string;
9
- declare function merge<T extends Record<string, any>>(target: T, source: Record<string, any>, deep?: boolean): T;
10
- declare function keys<T extends Record<string, any>>(object: T): Array<keyof T>;
11
- declare function getLineUid(from: string, to: string): string;
12
- declare function inherit(target: Constructor, source: Record<string, any>): void;
13
-
14
7
  export {
15
8
  createElement,
16
9
  findElement,
@@ -22,4 +15,4 @@ export {
22
15
  keys,
23
16
  merge,
24
17
  removeElement,
25
- }
18
+ };
package/dist/utils.d.ts CHANGED
@@ -1,23 +1,87 @@
1
+ /**
2
+ * Common utility functions for the ts-maps library
3
+ */
4
+ /**
5
+ * Check if a value is undefined
6
+ */
1
7
  export declare function isUndefined(value: any): boolean;
8
+ /**
9
+ * Check if a value is null
10
+ */
2
11
  export declare function isNull(value: any): boolean;
12
+ /**
13
+ * Check if a value is null or undefined
14
+ */
3
15
  export declare function isNullOrUndefined(value: any): boolean;
16
+ /**
17
+ * Check if a value is a string
18
+ */
4
19
  export declare function isString(value: any): value is string;
20
+ /**
21
+ * Check if a value is a number
22
+ */
5
23
  export declare function isNumber(value: any): value is number;
6
- export declare function isFunction(value: any): value is (...args: any[]) => any {
7
- return typeof value === 'function'
8
- };
24
+ /**
25
+ * Check if a value is a function
26
+ */
27
+ export declare function isFunction(value: any): value is (...args: any[]) => any;
28
+ /**
29
+ * Check if a value is an object
30
+ */
9
31
  export declare function isObject(value: any): value is object;
32
+ /**
33
+ * Check if a value is an array
34
+ */
10
35
  export declare function isArray(value: any): value is any[];
36
+ /**
37
+ * Check if a value is a boolean
38
+ */
11
39
  export declare function isBoolean(value: any): value is boolean;
40
+ /**
41
+ * Check if a value is a DOM element
42
+ */
12
43
  export declare function isElement(value: any): value is Element;
44
+ /**
45
+ * Check if a value is a DOM node
46
+ */
13
47
  export declare function isNode(value: any): value is Node;
48
+ /**
49
+ * Check if a value is a DOM event
50
+ */
14
51
  export declare function isEvent(value: any): value is Event;
52
+ /**
53
+ * Check if a value is a RegExp
54
+ */
15
55
  export declare function isRegExp(value: any): value is RegExp;
56
+ /**
57
+ * Check if a value is a Date
58
+ */
16
59
  export declare function isDate(value: any): value is Date;
60
+ /**
61
+ * Check if a value is a Map
62
+ */
17
63
  export declare function isMap(value: any): value is Map<any, any>;
64
+ /**
65
+ * Check if a value is a Set
66
+ */
18
67
  export declare function isSet(value: any): value is Set<any>;
68
+ /**
69
+ * Check if a value is a Promise
70
+ */
19
71
  export declare function isPromise(value: any): value is Promise<any>;
72
+ /**
73
+ * Check if a value is a Symbol
74
+ */
20
75
  export declare function isSymbol(value: any): value is symbol;
76
+ /**
77
+ * Check if a value is a BigInt
78
+ */
21
79
  export declare function isBigInt(value: any): value is bigint;
80
+ /**
81
+ * Check if a value is empty (null, undefined, empty string, empty array, empty object)
82
+ */
22
83
  export declare function isEmpty(value: any): boolean;
84
+ /**
85
+ * Get the type of a value
86
+ */
23
87
  export declare function getType(value: any): string;
@@ -1,15 +1,5 @@
1
1
  import type { MapOptions } from './types';
2
-
3
2
  export declare class VectorMap {
4
- constructor(options: MapOptions = {} as MapOptions) {
5
- if (!options.selector) {
6
- throw new Error('Selector is not given.')
7
- }
8
-
9
- return new Map(options)
10
- }
11
-
12
- static addMap(name: string, map: any): void {
13
- Map.maps[name] = map
14
- }
3
+ constructor(options?: MapOptions);
4
+ static addMap(name: string, map: any): void;
15
5
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ts-maps",
3
3
  "type": "module",
4
- "version": "0.2.5",
4
+ "version": "0.2.6",
5
5
  "description": "A modern vector map library.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",
@@ -97,7 +97,6 @@
97
97
  "typecheck": "bun --bun tsc --noEmit"
98
98
  },
99
99
  "devDependencies": {
100
- "bun-plugin-dtsx": "^0.21.12",
101
100
  "bunfig": "^0.15.0",
102
101
  "lint-staged": "^16.2.3",
103
102
  "typescript": "^5.9.3"