@arkyn/components 3.0.1-beta.102 → 3.0.1-beta.104

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,12 +1,14 @@
1
- import { HtmlHTMLAttributes } from "react";
1
+ import { HtmlHTMLAttributes, ReactNode } from "react";
2
2
  import "./styles.css";
3
+ type Coordinate = {
4
+ lat: number;
5
+ lng: number;
6
+ children?: ReactNode;
7
+ };
3
8
  type MapViewProps = {
4
9
  zoom?: number;
5
10
  draggable?: boolean;
6
- coordinates?: {
7
- lat: number;
8
- lng: number;
9
- };
11
+ coordinates?: Coordinate | Coordinate[];
10
12
  } & HtmlHTMLAttributes<HTMLDivElement>;
11
13
  declare function MapView(props: MapViewProps): import("react/jsx-runtime").JSX.Element;
12
14
  export { MapView };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/mapView/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAE3C,OAAO,cAAc,CAAC;AAEtB,KAAK,YAAY,GAAG;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;CAC5C,GAAG,kBAAkB,CAAC,cAAc,CAAC,CAAC;AAEvC,iBAAS,OAAO,CAAC,KAAK,EAAE,YAAY,2CAgCnC;AAED,OAAO,EAAE,OAAO,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/mapView/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEtD,OAAO,cAAc,CAAC;AAEtB,KAAK,UAAU,GAAG;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,CAAC;AAEF,KAAK,YAAY,GAAG;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,UAAU,GAAG,UAAU,EAAE,CAAC;CACzC,GAAG,kBAAkB,CAAC,cAAc,CAAC,CAAC;AAEvC,iBAAS,OAAO,CAAC,KAAK,EAAE,YAAY,2CAqDnC;AAED,OAAO,EAAE,OAAO,EAAE,CAAC"}
@@ -4,13 +4,20 @@ import { MapPinned } from "lucide-react";
4
4
  import "./styles.css";
5
5
  function MapView(props) {
6
6
  const { coordinates, zoom = 18, draggable = false, className, ...rest } = props;
7
- if (!coordinates) {
7
+ function hasValidCoordinates() {
8
+ if (Array.isArray(coordinates) && coordinates.length <= 0)
9
+ return false;
10
+ if (!coordinates)
11
+ return false;
12
+ return true;
13
+ }
14
+ if (!hasValidCoordinates()) {
8
15
  return (_jsx("div", { className: "arkynMapViewPinnedEmpty " + className, ...rest, children: _jsx(MapPinned, {}) }));
9
16
  }
10
- return (_jsx("div", { className: "arkynMapViewPinned " + className, ...rest, children: _jsx(Map, { zoom: zoom, center: coordinates, mapContainerStyle: {
17
+ return (_jsx("div", { className: "arkynMapViewPinned " + className, ...rest, children: _jsx(Map, { zoom: zoom, center: Array.isArray(coordinates) ? coordinates[0] : coordinates, mapContainerStyle: {
11
18
  borderRadius: "8px",
12
19
  width: "100%",
13
20
  height: "100%",
14
- }, children: _jsx(Marker, { draggable: draggable, position: coordinates }) }) }));
21
+ }, children: Array.isArray(coordinates) ? (coordinates.map((coordinate, index) => (_jsx(Marker, { draggable: draggable, position: coordinate, children: coordinate.children }, index)))) : (_jsx(Marker, { draggable: draggable, position: coordinates, children: coordinates?.children })) }) }));
15
22
  }
16
23
  export { MapView };
@@ -48,8 +48,8 @@ function SearchPlaces(props) {
48
48
  const [searchBox, setSearchBox] = useState(null);
49
49
  const handleLoad = (ref) => setSearchBox(ref);
50
50
  const handlePlacesChanged = () => {
51
- const places = searchBox.getPlaces();
52
- const place = places[0];
51
+ const places = searchBox?.getPlaces();
52
+ const place = places ? places[0] : null;
53
53
  const address_components = place?.address_components;
54
54
  function findData(key) {
55
55
  const data = address_components.find((item) => item.types[0] === key);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkyn/components",
3
- "version": "3.0.1-beta.102",
3
+ "version": "3.0.1-beta.104",
4
4
  "main": "./dist/bundle.js",
5
5
  "module": "./dist/bundle.js",
6
6
  "types": "./dist/index.d.ts",