@phila/phila-ui-map-core 0.0.1-beta.2 → 0.0.1-beta.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.
@@ -1,30 +1,45 @@
1
1
  import { IControl } from 'maplibre-gl';
2
- import { Map as Map_2 } from 'maplibre-gl';
3
2
  import { Ref } from 'vue';
4
3
 
5
- declare interface ButtonControl extends IControl {
6
- _map?: Map_2;
7
- _container?: HTMLDivElement;
8
- _button?: HTMLButtonElement;
9
- }
4
+ /** Common position type for map controls */
5
+ declare type MapControlPosition = "top-left" | "top-right" | "bottom-left" | "bottom-right";
10
6
 
11
7
  /**
12
- * Factory for creating standard button controls
8
+ * Composable for adding MapLibre controls to the map.
9
+ *
10
+ * This composable handles positioning controls in MapLibre's corner containers
11
+ * (top-left, top-right, etc.) and automatic cleanup on unmount.
12
+ *
13
+ * ## What is IControl?
14
+ *
15
+ * IControl is MapLibre's interface for map controls. It's not a class you extend -
16
+ * it's a TypeScript interface that uses "duck typing": any object with the right
17
+ * methods qualifies. The required methods are:
18
+ *
19
+ * - onAdd(map): Called when control is added. Must return an HTMLElement.
20
+ * - onRemove(): Called when control is removed. Handle any cleanup here.
21
+ *
22
+ * So this plain object is a valid IControl:
23
+ *
24
+ * { onAdd() { return myDiv; }, onRemove() {} }
25
+ *
26
+ * ## Usage
27
+ *
28
+ * For Vue template-based controls (MapButton, MapSearchControl, BasemapDropdown),
29
+ * pass a ref to the container element. The composable creates the IControl internally,
30
+ * returning your Vue template's DOM element from onAdd():
31
+ *
32
+ * const containerRef = ref<HTMLElement | null>(null);
33
+ * useMapControl(props, containerRef);
34
+ *
35
+ * For MapLibre's built-in controls (like NavigationControl), pass a function that
36
+ * returns the control. These already implement IControl internally:
37
+ *
38
+ * useMapControl(props, () => new maplibregl.NavigationControl());
13
39
  */
14
- export declare function createButtonControl(icon?: string, image?: string, title?: string, iconSize?: number, clickHandler?: (this: GlobalEventHandlers, ev: MouseEvent) => void): ButtonControl;
15
-
16
- declare interface MapControlProps {
17
- position?: "top-left" | "top-right" | "bottom-left" | "bottom-right";
18
- }
19
-
20
- /**
21
- * Composable for creating MapLibre IControl components
22
- * Handles the boilerplate of adding/removing controls
23
- */
24
- export declare function useMapControl(props: MapControlProps, createControlFn: (map: Map_2) => IControl | Promise<IControl>): {
25
- map: Ref<Map_2 | null, Map_2 | null> | undefined;
26
- control: null;
27
- };
40
+ export declare function useMapControl(props: {
41
+ position?: MapControlPosition;
42
+ }, controlOrContainer: Ref<HTMLElement | null> | (() => IControl)): void;
28
43
 
29
44
  export { }
30
45
 
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index-K0bKFr5g.cjs");exports.createButtonControl=o.createButtonControl;exports.useMapControl=o.useMapControl;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./useMapControl-CGjWu6ME.cjs");exports.useMapControl=e.useMapControl;
@@ -1,5 +1,4 @@
1
- import { q as r, u as a } from "./index-DJPTWX6O.js";
1
+ import { u as a } from "./useMapControl-CmoJ03wJ.js";
2
2
  export {
3
- r as createButtonControl,
4
3
  a as useMapControl
5
4
  };