@partbot/stockist-map 0.1.0
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.
- package/dist/StockistMap.d.ts +2 -0
- package/dist/StockistSearch.d.ts +6 -0
- package/dist/client.d.ts +9 -0
- package/dist/components/ui.d.ts +32 -0
- package/dist/distance.d.ts +3 -0
- package/dist/geolocation.d.ts +1 -0
- package/dist/index.d.ts +29 -0
- package/dist/links.d.ts +5 -0
- package/dist/search.d.ts +28 -0
- package/dist/stockist-map.js +46797 -0
- package/dist/stockist-map.umd.js +1044 -0
- package/dist/stockist-search.js +405 -0
- package/dist/stockist-search.umd.js +241 -0
- package/dist/types.d.ts +94 -0
- package/package.json +43 -0
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
var ae = Object.defineProperty;
|
|
2
|
+
var ie = (e, t, r) => t in e ? ae(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
|
+
var O = (e, t, r) => ie(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
+
import { jsxs as y, jsx as l } from "react/jsx-runtime";
|
|
5
|
+
import { createRoot as Y } from "react-dom/client";
|
|
6
|
+
import * as s from "react";
|
|
7
|
+
import { createContext as le } from "react";
|
|
8
|
+
const ce = le({
|
|
9
|
+
color: "currentColor",
|
|
10
|
+
size: "1em",
|
|
11
|
+
weight: "regular",
|
|
12
|
+
mirrored: !1
|
|
13
|
+
}), Q = s.forwardRef(
|
|
14
|
+
(e, t) => {
|
|
15
|
+
const {
|
|
16
|
+
alt: r,
|
|
17
|
+
color: n,
|
|
18
|
+
size: c,
|
|
19
|
+
weight: M,
|
|
20
|
+
mirrored: z,
|
|
21
|
+
children: i,
|
|
22
|
+
weights: R,
|
|
23
|
+
...w
|
|
24
|
+
} = e, {
|
|
25
|
+
color: S = "currentColor",
|
|
26
|
+
size: A,
|
|
27
|
+
weight: m = "regular",
|
|
28
|
+
mirrored: N = !1,
|
|
29
|
+
...v
|
|
30
|
+
} = s.useContext(ce);
|
|
31
|
+
return /* @__PURE__ */ s.createElement(
|
|
32
|
+
"svg",
|
|
33
|
+
{
|
|
34
|
+
ref: t,
|
|
35
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
36
|
+
width: c ?? A,
|
|
37
|
+
height: c ?? A,
|
|
38
|
+
fill: n ?? S,
|
|
39
|
+
viewBox: "0 0 256 256",
|
|
40
|
+
transform: z || N ? "scale(-1, 1)" : void 0,
|
|
41
|
+
...v,
|
|
42
|
+
...w
|
|
43
|
+
},
|
|
44
|
+
!!r && /* @__PURE__ */ s.createElement("title", null, r),
|
|
45
|
+
i,
|
|
46
|
+
R.get(M ?? m)
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
);
|
|
50
|
+
Q.displayName = "IconBase";
|
|
51
|
+
const ue = /* @__PURE__ */ new Map([
|
|
52
|
+
[
|
|
53
|
+
"bold",
|
|
54
|
+
/* @__PURE__ */ s.createElement(s.Fragment, null, /* @__PURE__ */ s.createElement("path", { d: "M238.7,102.46,62.81,37.21l-.25-.09A20,20,0,0,0,37.12,62.56l.09.25L102.46,238.7A20,20,0,0,0,121.3,252h.35a20,20,0,0,0,18.77-14.12l.09-.29,21.23-75.85,75.85-21.23.29-.09a20,20,0,0,0,.82-38Zm-89.93,38a12,12,0,0,0-8.32,8.32l-19.68,70.29L62.8,62.8l156.26,58Z" }))
|
|
55
|
+
],
|
|
56
|
+
[
|
|
57
|
+
"duotone",
|
|
58
|
+
/* @__PURE__ */ s.createElement(s.Fragment, null, /* @__PURE__ */ s.createElement(
|
|
59
|
+
"path",
|
|
60
|
+
{
|
|
61
|
+
d: "M234.35,129,152,152,129,234.35a8,8,0,0,1-15.21.27l-65.28-176A8,8,0,0,1,58.63,48.46l176,65.28A8,8,0,0,1,234.35,129Z",
|
|
62
|
+
opacity: "0.2"
|
|
63
|
+
}
|
|
64
|
+
), /* @__PURE__ */ s.createElement("path", { d: "M237.33,106.21,61.41,41l-.16-.05A16,16,0,0,0,40.9,61.25a1,1,0,0,0,.05.16l65.26,175.92A15.77,15.77,0,0,0,121.28,248h.3a15.77,15.77,0,0,0,15-11.29l.06-.2,21.84-78,78-21.84.2-.06a16,16,0,0,0,.62-30.38ZM149.84,144.3a8,8,0,0,0-5.54,5.54L121.3,232l-.06-.17L56,56l175.82,65.22.16.06Z" }))
|
|
65
|
+
],
|
|
66
|
+
[
|
|
67
|
+
"fill",
|
|
68
|
+
/* @__PURE__ */ s.createElement(s.Fragment, null, /* @__PURE__ */ s.createElement("path", { d: "M248,121.58a15.76,15.76,0,0,1-11.29,15l-.2.06-78,21.84-21.84,78-.06.2a15.77,15.77,0,0,1-15,11.29h-.3a15.77,15.77,0,0,1-15.07-10.67L41,61.41a1,1,0,0,1-.05-.16A16,16,0,0,1,61.25,40.9l.16.05,175.92,65.26A15.78,15.78,0,0,1,248,121.58Z" }))
|
|
69
|
+
],
|
|
70
|
+
[
|
|
71
|
+
"light",
|
|
72
|
+
/* @__PURE__ */ s.createElement(s.Fragment, null, /* @__PURE__ */ s.createElement("path", { d: "M236.65,108.1,60.72,42.83l-.13,0A14,14,0,0,0,42.78,60.59s0,.09,0,.13L108.1,236.65A13.77,13.77,0,0,0,121.28,246h.26a13.8,13.8,0,0,0,13.14-9.88l0-.15,22.14-79.1L236,134.73l.15,0a14,14,0,0,0,.53-26.58Zm-4,15.1-82.26,23a6,6,0,0,0-4.16,4.16l-23,82.26a1.85,1.85,0,0,1-1.86,1.36,1.82,1.82,0,0,1-1.92-1.35.61.61,0,0,0,0-.12L54.11,56.62a2,2,0,0,1,2.51-2.51l175.91,65.26.12,0a2,2,0,0,1,0,3.79Z" }))
|
|
73
|
+
],
|
|
74
|
+
[
|
|
75
|
+
"regular",
|
|
76
|
+
/* @__PURE__ */ s.createElement(s.Fragment, null, /* @__PURE__ */ s.createElement("path", { d: "M237.33,106.21,61.41,41l-.16-.05A16,16,0,0,0,40.9,61.25a1,1,0,0,0,.05.16l65.26,175.92A15.77,15.77,0,0,0,121.28,248h.3a15.77,15.77,0,0,0,15-11.29l.06-.2,21.84-78,78-21.84.2-.06a16,16,0,0,0,.62-30.38ZM149.84,144.3a8,8,0,0,0-5.54,5.54L121.3,232l-.06-.17L56,56l175.82,65.22.16.06Z" }))
|
|
77
|
+
],
|
|
78
|
+
[
|
|
79
|
+
"thin",
|
|
80
|
+
/* @__PURE__ */ s.createElement(s.Fragment, null, /* @__PURE__ */ s.createElement("path", { d: "M236,110,59.93,44.67A12,12,0,0,0,44.69,60L110,235.93A11.83,11.83,0,0,0,121.28,244h.22a11.82,11.82,0,0,0,11.26-8.47l0-.1,22.45-80.19,80.19-22.44.1,0A12,12,0,0,0,236,110Zm-2.79,15.12-82.3,23a4,4,0,0,0-2.78,2.77l-23,82.3a3.88,3.88,0,0,1-3.74,2.78,4,4,0,0,1-3.88-2.77L52.22,57.32a3.93,3.93,0,0,1,1-4.14A4,4,0,0,1,56,52a3.86,3.86,0,0,1,1.25.21l176.08,65.32a4,4,0,0,1-.09,7.59Z" }))
|
|
81
|
+
]
|
|
82
|
+
]), W = s.forwardRef((e, t) => /* @__PURE__ */ s.createElement(Q, { ref: t, ...e, weights: ue }));
|
|
83
|
+
W.displayName = "NavigationArrowIcon";
|
|
84
|
+
const de = "https://tile.openstreetmap.org/{z}/{x}/{y}.png", J = "https://basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}@2x.png", X = "OpenStreetMap contributors, CARTO", ee = "https://basemaps.cartocdn.com/gl/voyager-gl-style/style.json", F = {
|
|
85
|
+
primaryColor: "#111111",
|
|
86
|
+
markerColor: "#111111",
|
|
87
|
+
borderRadius: 8,
|
|
88
|
+
radiusUnit: "km",
|
|
89
|
+
defaultZoom: 5,
|
|
90
|
+
defaultCenter: { lat: -25.2744, lng: 133.7751 },
|
|
91
|
+
darkMode: !1,
|
|
92
|
+
styleUrl: ee,
|
|
93
|
+
mapPalette: "monotone",
|
|
94
|
+
tileUrl: J,
|
|
95
|
+
tileAttribution: X
|
|
96
|
+
};
|
|
97
|
+
function pe(e = {}) {
|
|
98
|
+
return {
|
|
99
|
+
...F,
|
|
100
|
+
...e,
|
|
101
|
+
defaultCenter: {
|
|
102
|
+
...F.defaultCenter,
|
|
103
|
+
...e.defaultCenter || {}
|
|
104
|
+
},
|
|
105
|
+
styleUrl: e.styleUrl || ee,
|
|
106
|
+
mapPalette: e.mapPalette || "monotone",
|
|
107
|
+
borderRadius: Number.isFinite(Number(e.borderRadius)) ? Number(e.borderRadius) : F.borderRadius,
|
|
108
|
+
tileUrl: !e.tileUrl || e.tileUrl === de ? J : e.tileUrl,
|
|
109
|
+
tileAttribution: e.tileAttribution || X,
|
|
110
|
+
radiusUnit: "km"
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
function be(e, t) {
|
|
114
|
+
return `/v1/stockist_maps/${encodeURIComponent(e)}/config`;
|
|
115
|
+
}
|
|
116
|
+
function fe(e, t = {}) {
|
|
117
|
+
const r = typeof window > "u" ? "http://localhost" : window.location.href, n = new URL(e, r);
|
|
118
|
+
return t.query && n.searchParams.set("q", t.query), t.limit && n.searchParams.set("limit", String(t.limit)), t.center && (n.searchParams.set("lat", String(t.center.lat)), n.searchParams.set("lng", String(t.center.lng))), t.radiusKm && n.searchParams.set("radius_km", String(t.radiusKm)), t.category && n.searchParams.set("category", t.category), t.locationSearch && n.searchParams.set("location_search", "true"), n.toString();
|
|
119
|
+
}
|
|
120
|
+
async function he(e) {
|
|
121
|
+
const t = await fetch(e, { headers: { Accept: "application/json" } });
|
|
122
|
+
if (!t.ok) throw new Error(`Could not load stockist map config (${t.status})`);
|
|
123
|
+
return t.json();
|
|
124
|
+
}
|
|
125
|
+
async function me(e, t = {}) {
|
|
126
|
+
const r = await fetch(fe(e, t), { headers: { Accept: "application/json" } });
|
|
127
|
+
if (!r.ok) throw new Error(`Could not search stockists (${r.status})`);
|
|
128
|
+
const n = await r.json();
|
|
129
|
+
return {
|
|
130
|
+
hits: Array.isArray(n.hits) ? n.hits : [],
|
|
131
|
+
estimatedTotalHits: Number(n.estimatedTotalHits || 0),
|
|
132
|
+
center: n.center || null,
|
|
133
|
+
resolvedQuery: n.resolvedQuery || null
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
const ge = 6371;
|
|
137
|
+
function H(e) {
|
|
138
|
+
return e * Math.PI / 180;
|
|
139
|
+
}
|
|
140
|
+
function xe(e, t) {
|
|
141
|
+
const r = H(t.lat - e.lat), n = H(t.lng - e.lng), c = Math.sin(r / 2) ** 2 + Math.cos(H(e.lat)) * Math.cos(H(t.lat)) * Math.sin(n / 2) ** 2;
|
|
142
|
+
return 2 * ge * Math.atan2(Math.sqrt(c), Math.sqrt(1 - c));
|
|
143
|
+
}
|
|
144
|
+
function ye(e) {
|
|
145
|
+
return `${e.toFixed(1)} km`;
|
|
146
|
+
}
|
|
147
|
+
function we(e) {
|
|
148
|
+
const t = ["localhost", "127.0.0.1", "::1"].includes(window.location.hostname);
|
|
149
|
+
return window.location.protocol !== "https:" && !t ? "Browser location is blocked on this local Partbot domain. Chrome and Brave only allow location access on HTTPS, localhost, or origins manually trusted in browser flags." : e.code === e.PERMISSION_DENIED ? "Location permission is blocked for this site. Allow location access in your browser settings, then try again." : e.code === e.POSITION_UNAVAILABLE ? "Your browser could not determine your location. Try again, or search by suburb or postcode." : e.code === e.TIMEOUT ? "Finding your location timed out. Try again, or search by suburb or postcode." : `Browser location failed with error code ${e.code}. Try again, or search by suburb or postcode.`;
|
|
150
|
+
}
|
|
151
|
+
const q = 3, $ = 50, ve = 350;
|
|
152
|
+
function Ee(e, t) {
|
|
153
|
+
return t ? e.map((r) => ({ ...r, distanceKm: xe(t, r._geo) })).sort((r, n) => (r.distanceKm || 0) - (n.distanceKm || 0)).slice(0, q) : e.slice(0, q);
|
|
154
|
+
}
|
|
155
|
+
function te({
|
|
156
|
+
token: e,
|
|
157
|
+
configUrl: t,
|
|
158
|
+
config: r,
|
|
159
|
+
theme: n,
|
|
160
|
+
initialQuery: c = "",
|
|
161
|
+
viewAllUrl: M = "/pages/stockists",
|
|
162
|
+
className: z = ""
|
|
163
|
+
}) {
|
|
164
|
+
const [i, R] = s.useState(r || null), [w, S] = s.useState(c), [A, m] = s.useState(
|
|
165
|
+
c.trim() ? "typed" : null
|
|
166
|
+
), [N, v] = s.useState([]), [L, I] = s.useState(!1), [E, k] = s.useState(!1), [re, d] = s.useState(!1), [K, g] = s.useState(!1), [_, b] = s.useState(null), T = s.useRef(null), f = s.useRef(0), x = s.useRef(0), C = s.useRef(null), Z = s.useId(), B = s.useMemo(
|
|
167
|
+
() => pe({ ...(i == null ? void 0 : i.theme) || {}, ...n || {} }),
|
|
168
|
+
[i == null ? void 0 : i.theme, n]
|
|
169
|
+
), p = s.useCallback(() => {
|
|
170
|
+
C.current && (clearTimeout(C.current), C.current = null);
|
|
171
|
+
}, []), U = s.useCallback(() => {
|
|
172
|
+
f.current += 1, p(), v([]), I(!1), g(!1), b(null), d(!1);
|
|
173
|
+
}, [p]), P = s.useCallback(
|
|
174
|
+
async ({ activeQuery: o, center: a }) => {
|
|
175
|
+
if (!i) return;
|
|
176
|
+
const u = f.current + 1;
|
|
177
|
+
f.current = u, p(), I(!0), g(!0), b(null), d(!0);
|
|
178
|
+
try {
|
|
179
|
+
const h = await me(i.search.url, {
|
|
180
|
+
query: o,
|
|
181
|
+
center: a,
|
|
182
|
+
radiusKm: $,
|
|
183
|
+
limit: q,
|
|
184
|
+
locationSearch: !a && !!o
|
|
185
|
+
});
|
|
186
|
+
if (u !== f.current) return;
|
|
187
|
+
v(Ee(h.hits, h.center || a));
|
|
188
|
+
} catch (h) {
|
|
189
|
+
if (u !== f.current) return;
|
|
190
|
+
v([]), b(h instanceof Error ? h.message : "Could not search stockists");
|
|
191
|
+
} finally {
|
|
192
|
+
u === f.current && I(!1);
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
[p, i]
|
|
196
|
+
);
|
|
197
|
+
s.useEffect(() => {
|
|
198
|
+
if (x.current += 1, f.current += 1, p(), R(r || null), S(c), m(c.trim() ? "typed" : null), v([]), I(!1), k(!1), g(!1), d(!1), b(null), r) return;
|
|
199
|
+
const o = t || (e ? be(e) : null);
|
|
200
|
+
if (!o) return;
|
|
201
|
+
let a = !1;
|
|
202
|
+
return he(o).then((u) => {
|
|
203
|
+
a || R(u);
|
|
204
|
+
}).catch((u) => {
|
|
205
|
+
a || (b(u instanceof Error ? u.message : "Could not load stockist search"), g(!0), d(!0));
|
|
206
|
+
}), () => {
|
|
207
|
+
a = !0;
|
|
208
|
+
};
|
|
209
|
+
}, [p, t, c, r, e]), s.useEffect(() => {
|
|
210
|
+
if (!i || A !== "typed") return;
|
|
211
|
+
const o = w.trim();
|
|
212
|
+
if (!o) {
|
|
213
|
+
U();
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
return p(), C.current = setTimeout(() => {
|
|
217
|
+
C.current = null, P({ activeQuery: o, center: null });
|
|
218
|
+
}, ve), p;
|
|
219
|
+
}, [p, i, w, U, P, A]), s.useEffect(() => {
|
|
220
|
+
const o = (a) => {
|
|
221
|
+
const u = typeof a.composedPath == "function" ? a.composedPath() : [], h = a.target instanceof Node ? a.target : null;
|
|
222
|
+
T.current && u.includes(T.current) || T.current && h && T.current.contains(h) || d(!1);
|
|
223
|
+
};
|
|
224
|
+
return document.addEventListener("pointerdown", o), () => document.removeEventListener("pointerdown", o);
|
|
225
|
+
}, []), s.useEffect(
|
|
226
|
+
() => () => {
|
|
227
|
+
x.current += 1, f.current += 1, p();
|
|
228
|
+
},
|
|
229
|
+
[p]
|
|
230
|
+
);
|
|
231
|
+
const oe = () => {
|
|
232
|
+
if (x.current += 1, U(), m(null), k(!1), typeof window < "u" && window.isSecureContext === !1) {
|
|
233
|
+
b("Browser location is blocked on this site. Search by suburb or postcode instead."), g(!0), d(!0);
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
if (!navigator.geolocation) {
|
|
237
|
+
b(
|
|
238
|
+
"This browser does not support location search. Search by suburb or postcode instead."
|
|
239
|
+
), g(!0), d(!0);
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
m("location"), k(!0), b(null), d(!0);
|
|
243
|
+
const o = x.current;
|
|
244
|
+
navigator.geolocation.getCurrentPosition(
|
|
245
|
+
(a) => {
|
|
246
|
+
if (o !== x.current) return;
|
|
247
|
+
const u = { lat: a.coords.latitude, lng: a.coords.longitude };
|
|
248
|
+
S(""), k(!1), P({ activeQuery: "", center: u });
|
|
249
|
+
},
|
|
250
|
+
(a) => {
|
|
251
|
+
o === x.current && (k(!1), g(!0), b(we(a)), d(!0));
|
|
252
|
+
},
|
|
253
|
+
{ enableHighAccuracy: !1, timeout: 8e3 }
|
|
254
|
+
);
|
|
255
|
+
}, ne = () => {
|
|
256
|
+
const o = w.trim();
|
|
257
|
+
o && (m("typed"), P({ activeQuery: o, center: null }));
|
|
258
|
+
}, D = re && (L || E || K || !!_);
|
|
259
|
+
return /* @__PURE__ */ y(
|
|
260
|
+
"div",
|
|
261
|
+
{
|
|
262
|
+
ref: T,
|
|
263
|
+
className: `pbss-root ${B.darkMode ? "is-dark" : ""} ${z}`.trim(),
|
|
264
|
+
style: {
|
|
265
|
+
"--pbss-primary": B.primaryColor,
|
|
266
|
+
"--pbss-radius": `${Math.max(0, B.borderRadius)}px`
|
|
267
|
+
},
|
|
268
|
+
onKeyDown: (o) => {
|
|
269
|
+
o.key === "Escape" && d(!1);
|
|
270
|
+
},
|
|
271
|
+
children: [
|
|
272
|
+
/* @__PURE__ */ y("div", { className: "pbss-search-control", children: [
|
|
273
|
+
/* @__PURE__ */ l(
|
|
274
|
+
"input",
|
|
275
|
+
{
|
|
276
|
+
"aria-controls": D ? Z : void 0,
|
|
277
|
+
"aria-expanded": D,
|
|
278
|
+
"aria-label": "Search stockists",
|
|
279
|
+
autoComplete: "postal-code",
|
|
280
|
+
className: "pbss-input",
|
|
281
|
+
name: "stockist-search",
|
|
282
|
+
placeholder: "Search suburb or postcode",
|
|
283
|
+
type: "search",
|
|
284
|
+
value: w,
|
|
285
|
+
onChange: (o) => {
|
|
286
|
+
const a = o.target.value;
|
|
287
|
+
x.current += 1, U(), k(!1), S(a), m(a.trim() ? "typed" : null);
|
|
288
|
+
},
|
|
289
|
+
onFocus: () => {
|
|
290
|
+
(L || E || K || _) && d(!0);
|
|
291
|
+
},
|
|
292
|
+
onKeyDown: (o) => {
|
|
293
|
+
o.key === "Enter" && (o.preventDefault(), ne());
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
),
|
|
297
|
+
/* @__PURE__ */ y(
|
|
298
|
+
"button",
|
|
299
|
+
{
|
|
300
|
+
"aria-label": E ? "Finding your location" : "Use my location",
|
|
301
|
+
className: "pbss-location-button",
|
|
302
|
+
disabled: E || L || !i,
|
|
303
|
+
type: "button",
|
|
304
|
+
onClick: oe,
|
|
305
|
+
children: [
|
|
306
|
+
E ? /* @__PURE__ */ l("span", { "aria-hidden": "true", className: "pbss-spinner" }) : /* @__PURE__ */ l(W, { "aria-hidden": "true", "data-slot": "icon", weight: "bold" }),
|
|
307
|
+
/* @__PURE__ */ l("span", { "aria-hidden": "true", className: "pbss-touch-target" })
|
|
308
|
+
]
|
|
309
|
+
}
|
|
310
|
+
)
|
|
311
|
+
] }),
|
|
312
|
+
D && /* @__PURE__ */ y(
|
|
313
|
+
"div",
|
|
314
|
+
{
|
|
315
|
+
"aria-label": "Nearest stockists",
|
|
316
|
+
className: "pbss-results-panel",
|
|
317
|
+
id: Z,
|
|
318
|
+
role: "region",
|
|
319
|
+
children: [
|
|
320
|
+
/* @__PURE__ */ l("div", { "aria-live": "polite", className: "pbss-results-status", children: L || E ? /* @__PURE__ */ l("div", { className: "pbss-loading", children: "Finding nearby stockists." }) : _ ? /* @__PURE__ */ l("div", { className: "pbss-error", children: _ }) : N.length > 0 ? /* @__PURE__ */ l("ul", { className: "pbss-results", role: "list", children: N.map((o) => /* @__PURE__ */ y("li", { className: "pbss-result", children: [
|
|
321
|
+
/* @__PURE__ */ y("div", { className: "pbss-result-heading", children: [
|
|
322
|
+
/* @__PURE__ */ l("div", { className: "pbss-result-name", children: o.name }),
|
|
323
|
+
typeof o.distanceKm == "number" && /* @__PURE__ */ l("div", { className: "pbss-result-distance", children: ye(o.distanceKm) })
|
|
324
|
+
] }),
|
|
325
|
+
o.address && /* @__PURE__ */ l("div", { className: "pbss-result-address", children: o.address })
|
|
326
|
+
] }, o.id)) }) : /* @__PURE__ */ y("div", { className: "pbss-empty", children: [
|
|
327
|
+
"No stockists found within ",
|
|
328
|
+
$,
|
|
329
|
+
" km. Try another location."
|
|
330
|
+
] }) }),
|
|
331
|
+
/* @__PURE__ */ l("a", { className: "pbss-view-all", href: M || "/pages/stockists", children: "View All Stockists" })
|
|
332
|
+
]
|
|
333
|
+
}
|
|
334
|
+
)
|
|
335
|
+
]
|
|
336
|
+
}
|
|
337
|
+
);
|
|
338
|
+
}
|
|
339
|
+
const ke = ":host{display:block}partbot-stockist-search{display:block}.pbss-root{--pbss-primary: #111111;--pbss-action-color: var(--pbss-primary);--pbss-radius: 8px;--pbss-surface: #ffffff;--pbss-control-surface: #ffffff;--pbss-border: rgb(28 25 23 / .14);--pbss-divider: rgb(28 25 23 / .09);--pbss-text: #1c1917;--pbss-muted-text: #78716c;--pbss-placeholder-text: #57534e;--pbss-danger-surface: #fff1f2;--pbss-danger-text: #9f1239;color:var(--pbss-text);container-type:inline-size;font-family:inherit;isolation:isolate;position:relative;width:100%;-webkit-font-smoothing:antialiased}.pbss-search-control{align-items:center;display:flex;min-width:0;position:relative}.pbss-input{-webkit-appearance:none;-moz-appearance:none;appearance:none;background:var(--pbss-control-surface);border:0;border-radius:var(--pbss-radius);box-shadow:inset 0 0 0 1px var(--pbss-border);color:var(--pbss-text);font:inherit;font-size:16px;line-height:1.5;min-height:48px;min-width:0;padding:10px 56px 10px 14px;width:100%}.pbss-input::-webkit-search-cancel-button{margin-right:4px}.pbss-input::placeholder{color:var(--pbss-placeholder-text);opacity:1}.pbss-input:focus{box-shadow:inset 0 0 0 2px color-mix(in srgb,var(--pbss-action-color) 70%,transparent),0 0 0 3px color-mix(in srgb,var(--pbss-action-color) 14%,transparent);outline:none}.pbss-location-button{align-items:center;background:transparent;border:0;border-radius:max(4px,calc(var(--pbss-radius) - 4px));color:var(--pbss-action-color);cursor:pointer;display:inline-flex;height:40px;justify-content:center;padding:0;position:absolute;right:4px;width:40px}.pbss-location-button [data-slot=icon]{flex:0 0 auto;height:16px;width:16px}.pbss-location-button:hover{background:color-mix(in srgb,var(--pbss-action-color) 8%,transparent)}.pbss-location-button:focus-visible{outline:2px solid var(--pbss-action-color);outline-offset:-2px}.pbss-location-button:disabled{cursor:not-allowed;opacity:.5}.pbss-touch-target{height:max(100%,48px);left:50%;position:absolute;top:50%;transform:translate(-50%,-50%);width:max(100%,48px)}.pbss-spinner{animation:pbss-spin .7s linear infinite;border:2px solid color-mix(in srgb,var(--pbss-action-color) 22%,transparent);border-radius:999px;border-top-color:var(--pbss-action-color);height:16px;width:16px}.pbss-results-panel{background:var(--pbss-surface);border-radius:var(--pbss-radius);box-shadow:0 16px 36px #1c191729,0 2px 8px #1c191714,0 0 0 1px #1c19170f;display:grid;left:0;margin-top:6px;overflow:hidden;position:absolute;right:0;z-index:20}.pbss-results-status{min-width:0}.pbss-results{list-style:none;margin:0;padding:0}.pbss-result{display:grid;gap:4px;padding:14px}.pbss-result+.pbss-result{border-top:1px solid var(--pbss-divider)}.pbss-result-heading{align-items:baseline;display:flex;gap:12px;justify-content:space-between;min-width:0}.pbss-result-name{font-size:16px;font-weight:600;line-height:1.35;min-width:0}.pbss-result-distance{color:var(--pbss-action-color);flex:0 0 auto;font-size:14px;font-variant-numeric:tabular-nums;font-weight:600;line-height:1.35}.pbss-result-address,.pbss-loading,.pbss-empty,.pbss-error{font-size:16px;line-height:1.45}.pbss-result-address{color:var(--pbss-muted-text)}.pbss-loading,.pbss-empty,.pbss-error{padding:16px 14px}.pbss-loading,.pbss-empty{color:var(--pbss-muted-text)}.pbss-error{background:var(--pbss-danger-surface);color:var(--pbss-danger-text)}.pbss-view-all{border-top:1px solid var(--pbss-divider);color:var(--pbss-action-color);font-size:16px;font-weight:600;line-height:1.4;padding:13px 14px;text-align:center;text-decoration:none}.pbss-view-all:hover{background:color-mix(in srgb,var(--pbss-action-color) 6%,var(--pbss-surface));text-decoration:underline;text-underline-offset:3px}.pbss-view-all:focus-visible{outline:2px solid var(--pbss-action-color);outline-offset:-3px}@container (min-width: 480px){.pbss-result-name,.pbss-result-address,.pbss-loading,.pbss-empty,.pbss-error,.pbss-view-all{font-size:14px}.pbss-result-distance{font-size:12px}}.pbss-root.is-dark{--pbss-action-color: #f5f3f0;--pbss-surface: #1c1917;--pbss-control-surface: #292524;--pbss-border: rgb(255 255 255 / .16);--pbss-divider: rgb(255 255 255 / .1);--pbss-text: #f5f3f0;--pbss-muted-text: #d6d3d1;--pbss-placeholder-text: #d6d3d1;--pbss-danger-surface: #4c0519;--pbss-danger-text: #fecdd3}.pbss-root.is-dark .pbss-results-panel{box-shadow:0 18px 38px #0000006b,0 0 0 1px #ffffff1a}@media(prefers-reduced-motion:reduce){.pbss-spinner{animation-duration:1.4s}}@keyframes pbss-spin{to{transform:rotate(360deg)}}";
|
|
340
|
+
function Se(e, t) {
|
|
341
|
+
const r = Y(e);
|
|
342
|
+
return r.render(/* @__PURE__ */ l(te, { ...t })), r;
|
|
343
|
+
}
|
|
344
|
+
const j = "data-partbot-stockist-search-styles", G = "data-partbot-stockist-search-root";
|
|
345
|
+
function Ae(e) {
|
|
346
|
+
return e.shadowRoot || e.attachShadow({ mode: "open" });
|
|
347
|
+
}
|
|
348
|
+
function Te(e) {
|
|
349
|
+
if (e.querySelector(`style[${j}]`)) return;
|
|
350
|
+
const t = document.createElement("style");
|
|
351
|
+
t.setAttribute(j, ""), t.textContent = ke, e.prepend(t);
|
|
352
|
+
}
|
|
353
|
+
function Ce(e) {
|
|
354
|
+
const t = e.querySelector(
|
|
355
|
+
`div[${G}]`
|
|
356
|
+
);
|
|
357
|
+
if (t) return t;
|
|
358
|
+
const r = document.createElement("div");
|
|
359
|
+
return r.setAttribute(G, ""), e.appendChild(r), r;
|
|
360
|
+
}
|
|
361
|
+
const Me = typeof HTMLElement > "u" ? class {
|
|
362
|
+
} : HTMLElement;
|
|
363
|
+
class se extends Me {
|
|
364
|
+
constructor() {
|
|
365
|
+
super(...arguments);
|
|
366
|
+
O(this, "root");
|
|
367
|
+
O(this, "mountElement");
|
|
368
|
+
}
|
|
369
|
+
connectedCallback() {
|
|
370
|
+
this.renderStockistSearch();
|
|
371
|
+
}
|
|
372
|
+
disconnectedCallback() {
|
|
373
|
+
var r;
|
|
374
|
+
(r = this.root) == null || r.unmount(), this.root = void 0;
|
|
375
|
+
}
|
|
376
|
+
attributeChangedCallback() {
|
|
377
|
+
this.isConnected && this.renderStockistSearch();
|
|
378
|
+
}
|
|
379
|
+
renderStockistSearch() {
|
|
380
|
+
const r = Ae(this);
|
|
381
|
+
Te(r), this.mountElement || (this.mountElement = Ce(r)), this.root || (this.root = Y(this.mountElement)), this.root.render(/* @__PURE__ */ l(te, { ...this.stockistSearchProps() }));
|
|
382
|
+
}
|
|
383
|
+
stockistSearchProps() {
|
|
384
|
+
return {
|
|
385
|
+
token: this.getAttribute("token") || void 0,
|
|
386
|
+
configUrl: this.getAttribute("config-url") || void 0,
|
|
387
|
+
initialQuery: this.getAttribute("initial-query") || "",
|
|
388
|
+
viewAllUrl: this.getAttribute("view-all-url") || "/pages/stockists"
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
O(se, "observedAttributes", ["token", "config-url", "initial-query", "view-all-url"]);
|
|
393
|
+
function V() {
|
|
394
|
+
typeof window > "u" || !window.customElements || window.customElements.get("partbot-stockist-search") || window.customElements.define("partbot-stockist-search", se);
|
|
395
|
+
}
|
|
396
|
+
typeof window < "u" && (V(), window.PartbotStockistSearch = {
|
|
397
|
+
defineCustomElement: V,
|
|
398
|
+
mount: Se
|
|
399
|
+
});
|
|
400
|
+
export {
|
|
401
|
+
se as PartbotStockistSearchElement,
|
|
402
|
+
te as StockistSearch,
|
|
403
|
+
V as defineStockistSearchElement,
|
|
404
|
+
Se as mountStockistSearch
|
|
405
|
+
};
|