@colabcommerce/elements 0.0.2 → 0.0.4

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,7 +1,7 @@
1
1
  import { jsx as t, jsxs as g } from "react/jsx-runtime";
2
2
  import { createContext as Q, useState as c } from "react";
3
- import { i as R, u as z, d as Y, S as V, l as K, b as W, k as X, g as J } from "./addressComponentsToAddress-f0L6qfjZ.js";
4
- import { d as $, a as U, Q as H, c as u, B as ee } from "./globals-C3lGVSJ0.js";
3
+ import { i as R, u as z, d as Y, S as V, l as K, b as W, k as X, g as J } from "./addressComponentsToAddress-DCL-K8mn.js";
4
+ import { d as $, a as U, Q as H, c as u, B as ee } from "./globals-B8-hYoIU.js";
5
5
  /**
6
6
  * @license lucide-react v0.542.0 - ISC
7
7
  *
@@ -0,0 +1,100 @@
1
+ import { jsxs as v, jsx as C } from "react/jsx-runtime";
2
+ import { useState as I, useEffect as b, useCallback as x } from "react";
3
+ import { j as z, A as E, o as j, a as D, k as N, M as P } from "./globals-B8-hYoIU.js";
4
+ import { u as B } from "./addressComponentsToAddress-DCL-K8mn.js";
5
+ const T = "lzEEu", _ = {
6
+ label: T
7
+ }, U = ({ location: r, onClick: o = () => {
8
+ } }) => {
9
+ var n, d, m, h, k;
10
+ const { setSelectedLocationId: w, selectedLocationId: L, setShowDetails: c, settings: a } = B(), i = ((n = a == null ? void 0 : a.entity) == null ? void 0 : n.store_type_icons) || [], l = (d = a == null ? void 0 : a.entity) == null ? void 0 : d.store_locator_default_store_icon, [S, u] = I(!1), e = () => {
11
+ o(r);
12
+ }, f = () => {
13
+ u(!0);
14
+ }, M = () => {
15
+ u(!1);
16
+ }, p = z(), g = L === r.id, y = (r == null ? void 0 : r.store_type) === "Palliser Studio", t = i == null ? void 0 : i.find((Z) => Z.name === r.store_type);
17
+ return t != null && t.url || (y ? p.studioSelected : p.standardSelected), /* @__PURE__ */ v(
18
+ E,
19
+ {
20
+ onClick: e,
21
+ onMouseEnter: f,
22
+ onMouseLeave: M,
23
+ zIndex: g ? S ? 3 : 2 : S ? 1 : 0,
24
+ position: { lat: ((m = r == null ? void 0 : r.address) == null ? void 0 : m.latitude) * 1, lng: ((h = r.address) == null ? void 0 : h.longitude) * 1 },
25
+ children: [
26
+ S && /* @__PURE__ */ C("div", { className: _.label, children: r.retailer_name }),
27
+ /* @__PURE__ */ C("img", { src: ((k = t == null ? void 0 : t.icon) == null ? void 0 : k.url) || (l == null ? void 0 : l.url), width: g ? 32 : 24, className: j("markerIcon", _, "map-marker") })
28
+ ]
29
+ }
30
+ );
31
+ }, $ = "wdRt8", A = {
32
+ map: $
33
+ }, F = ({ onMarkerClick: r = () => {
34
+ } }) => {
35
+ const {
36
+ locations: o,
37
+ selectedLocationId: w,
38
+ searchCenter: L,
39
+ mapCenter: c,
40
+ setMapCenter: a,
41
+ zoom: i,
42
+ setZoom: l
43
+ } = B(), { t: S } = D(), u = N(), [e, f] = I(null);
44
+ b(() => {
45
+ u && f(u);
46
+ }, [u, f]);
47
+ const M = x((t) => {
48
+ var n, d, m, h;
49
+ if (!e) return;
50
+ a({ lat: (n = e == null ? void 0 : e.getCenter()) == null ? void 0 : n.lat(), lng: (d = e == null ? void 0 : e.getCenter()) == null ? void 0 : d.lng() });
51
+ const s = new URLSearchParams(window.location.search);
52
+ s.set("lat", ((m = e == null ? void 0 : e.getCenter()) == null ? void 0 : m.lat()) * 1), s.set("lng", ((h = e == null ? void 0 : e.getCenter()) == null ? void 0 : h.lng()) * 1), window.history.replaceState({}, "", `?${s.toString()}`);
53
+ }, [e, a]), p = x((t) => {
54
+ if (!e) return;
55
+ l(e == null ? void 0 : e.getZoom());
56
+ const s = new URLSearchParams(window.location.search);
57
+ s.set("zoom", (e == null ? void 0 : e.getZoom()) * 1), window.history.replaceState({}, "", `?${s.toString()}`);
58
+ }, [e, l]), g = () => {
59
+ if (!e) return;
60
+ let t = 0;
61
+ if (o.forEach((n) => {
62
+ var d;
63
+ (d = e == null ? void 0 : e.getBounds()) != null && d.contains({ lat: n.address.latitude * 1, lng: n.address.longitude * 1 }) && t++;
64
+ }), t >= 2) return;
65
+ const s = new window.google.maps.LatLngBounds();
66
+ o.slice(0, 2).map((n) => {
67
+ s.extend({ lat: n.address.latitude * 1, lng: n.address.longitude * 1 });
68
+ }), s.extend(c), e.fitBounds(s, 15);
69
+ }, y = (t) => {
70
+ var n;
71
+ if (!e) return;
72
+ const s = new window.google.maps.LatLngBounds();
73
+ (n = e == null ? void 0 : e.getBounds()) != null && n.contains({ lat: t.address.latitude * 1, lng: t.address.longitude * 1 }) || (s.extend({ lat: t.address.latitude * 1, lng: t.address.longitude * 1 }), s.extend(L), e.fitBounds(s, 150));
74
+ };
75
+ return b(() => {
76
+ if (w && o.length > 0) {
77
+ const t = o.find((s) => s.id === w);
78
+ t && y(t);
79
+ } else o.length > 0 && g();
80
+ }, [w, o, e]), b(() => {
81
+ o.length > 0 && g();
82
+ }, [o]), !c.lat || !c.lng ? null : /* @__PURE__ */ C(
83
+ P,
84
+ {
85
+ className: [A.map, "cc-map-map"].join(" "),
86
+ defaultZoom: i,
87
+ defaultCenter: c,
88
+ mapId: "fb10c7a27b297863",
89
+ gestureHandling: "greedy",
90
+ disableDefaultUI: !0,
91
+ zoomControl: !0,
92
+ onDragend: M,
93
+ onZoomChanged: p,
94
+ children: o == null ? void 0 : o.map((t) => /* @__PURE__ */ C(U, { location: t, onClick: r }, t.id))
95
+ }
96
+ );
97
+ };
98
+ export {
99
+ F as S
100
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colabcommerce/elements",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "license": "UNLICENSED",
5
5
  "type": "module",
6
6
  "exports": {
@@ -1,98 +0,0 @@
1
- import { jsxs as Z, jsx as p } from "react/jsx-runtime";
2
- import { useState as k, useEffect as y, useCallback as x } from "react";
3
- import { j as v, A as z, o as E, a as j, k as D, M as N } from "./globals-C3lGVSJ0.js";
4
- import { u as I } from "./addressComponentsToAddress-f0L6qfjZ.js";
5
- const P = "lzEEu", _ = {
6
- label: P
7
- }, T = ({ location: t }) => {
8
- var r, a, m, h, b;
9
- const { setSelectedLocationId: u, selectedLocationId: L, setShowDetails: c, settings: o } = I(), i = ((r = o == null ? void 0 : o.entity) == null ? void 0 : r.store_type_icons) || [], d = (a = o == null ? void 0 : o.entity) == null ? void 0 : a.store_locator_default_store_icon, [w, l] = k(!1), e = () => {
10
- u(t.id);
11
- }, S = () => {
12
- l(!0);
13
- }, M = () => {
14
- l(!1);
15
- }, f = v(), g = L === t.id, C = (t == null ? void 0 : t.store_type) === "Palliser Studio", s = i == null ? void 0 : i.find((B) => B.name === t.store_type);
16
- return s != null && s.url || (C ? f.studioSelected : f.standardSelected), /* @__PURE__ */ Z(
17
- z,
18
- {
19
- onClick: e,
20
- onMouseEnter: S,
21
- onMouseLeave: M,
22
- zIndex: g ? w ? 3 : 2 : w ? 1 : 0,
23
- position: { lat: ((m = t == null ? void 0 : t.address) == null ? void 0 : m.latitude) * 1, lng: ((h = t.address) == null ? void 0 : h.longitude) * 1 },
24
- children: [
25
- w && /* @__PURE__ */ p("div", { className: _.label, children: t.retailer_name }),
26
- /* @__PURE__ */ p("img", { src: ((b = s == null ? void 0 : s.icon) == null ? void 0 : b.url) || (d == null ? void 0 : d.url), width: g ? 32 : 24, className: E("markerIcon", _, "map-marker") })
27
- ]
28
- }
29
- );
30
- }, U = "wdRt8", $ = {
31
- map: U
32
- }, q = () => {
33
- const {
34
- locations: t,
35
- selectedLocationId: u,
36
- searchCenter: L,
37
- mapCenter: c,
38
- setMapCenter: o,
39
- zoom: i,
40
- setZoom: d
41
- } = I(), { t: w } = j(), l = D(), [e, S] = k(null);
42
- y(() => {
43
- l && S(l);
44
- }, [l, S]);
45
- const M = x((s) => {
46
- var r, a, m, h;
47
- if (!e) return;
48
- o({ lat: (r = e == null ? void 0 : e.getCenter()) == null ? void 0 : r.lat(), lng: (a = e == null ? void 0 : e.getCenter()) == null ? void 0 : a.lng() });
49
- const n = new URLSearchParams(window.location.search);
50
- n.set("lat", ((m = e == null ? void 0 : e.getCenter()) == null ? void 0 : m.lat()) * 1), n.set("lng", ((h = e == null ? void 0 : e.getCenter()) == null ? void 0 : h.lng()) * 1), window.history.replaceState({}, "", `?${n.toString()}`);
51
- }, [e, o]), f = x((s) => {
52
- if (!e) return;
53
- d(e == null ? void 0 : e.getZoom());
54
- const n = new URLSearchParams(window.location.search);
55
- n.set("zoom", (e == null ? void 0 : e.getZoom()) * 1), window.history.replaceState({}, "", `?${n.toString()}`);
56
- }, [e, d]), g = () => {
57
- if (!e) return;
58
- let s = 0;
59
- if (t.forEach((r) => {
60
- var a;
61
- (a = e == null ? void 0 : e.getBounds()) != null && a.contains({ lat: r.address.latitude * 1, lng: r.address.longitude * 1 }) && s++;
62
- }), s >= 2) return;
63
- const n = new window.google.maps.LatLngBounds();
64
- t.slice(0, 2).map((r) => {
65
- n.extend({ lat: r.address.latitude * 1, lng: r.address.longitude * 1 });
66
- }), n.extend(c), e.fitBounds(n, 15);
67
- }, C = (s) => {
68
- var r;
69
- if (!e) return;
70
- const n = new window.google.maps.LatLngBounds();
71
- (r = e == null ? void 0 : e.getBounds()) != null && r.contains({ lat: s.address.latitude * 1, lng: s.address.longitude * 1 }) || (n.extend({ lat: s.address.latitude * 1, lng: s.address.longitude * 1 }), n.extend(L), e.fitBounds(n, 150));
72
- };
73
- return y(() => {
74
- if (u && t.length > 0) {
75
- const s = t.find((n) => n.id === u);
76
- s && C(s);
77
- } else t.length > 0 && g();
78
- }, [u, t, e]), y(() => {
79
- t.length > 0 && g();
80
- }, [t]), !c.lat || !c.lng ? null : /* @__PURE__ */ p(
81
- N,
82
- {
83
- className: [$.map, "cc-map-map"].join(" "),
84
- defaultZoom: i,
85
- defaultCenter: c,
86
- mapId: "fb10c7a27b297863",
87
- gestureHandling: "greedy",
88
- disableDefaultUI: !0,
89
- zoomControl: !0,
90
- onDragend: M,
91
- onZoomChanged: f,
92
- children: t == null ? void 0 : t.map((s) => /* @__PURE__ */ p(T, { location: s }, s.id))
93
- }
94
- );
95
- };
96
- export {
97
- q as S
98
- };