@colabcommerce/elements 0.0.4 → 0.9.1
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/.pnp.cjs +16484 -0
- package/.pnp.loader.mjs +2126 -0
- package/.yarn/install-state.gz +0 -0
- package/.yarn/releases/yarn-4.12.0.cjs +942 -0
- package/.yarnrc.yml +1 -0
- package/README.md +60 -41
- package/cypress/fixtures/example.json +5 -0
- package/cypress/support/commands.js +25 -0
- package/cypress/support/component-index.html +15 -0
- package/cypress/support/component.js +26 -0
- package/cypress.config.js +10 -0
- package/eslint.config.js +32 -0
- package/index.html +13 -0
- package/package.json +91 -67
- package/playground/index.html +14 -0
- package/playground/main.jsx +36 -0
- package/public/vite.svg +1 -0
- package/src/App.css +0 -0
- package/src/App.jsx +65 -0
- package/src/components/CollapsibleStoreHours/index.jsx +269 -0
- package/src/components/HoursList/index.jsx +225 -0
- package/src/components/LeadForm/index.jsx +241 -0
- package/src/components/MessageDialog/index.jsx +169 -0
- package/src/components/QuoteForm/index.jsx +82 -0
- package/src/components/QuoteFormSearch/index.jsx +276 -0
- package/src/components/QuoteFormStoreList/index.jsx +65 -0
- package/src/components/QuoteFormStoreListItem/index.jsx +134 -0
- package/src/components/QuoteLeadForm/index.jsx +16 -0
- package/src/components/QuoteMap/index.jsx +96 -0
- package/src/components/QuoteMapMarker/index.jsx +56 -0
- package/src/components/StaticMap/index.jsx +24 -0
- package/src/components/Store/index.jsx +44 -0
- package/src/components/StoreContact/index.jsx +96 -0
- package/src/components/StoreInfo/index.jsx +50 -0
- package/src/components/StoreList/index.jsx +59 -0
- package/src/components/StoreListItem/index.jsx +99 -0
- package/src/components/StoreListItem/indexStoreListItem.cy.jsx +30 -0
- package/src/components/StoreListNoneFound/index.jsx +16 -0
- package/src/components/StoreLocator/index.jsx +43 -0
- package/src/components/StoreLocatorMap/index.jsx +93 -0
- package/src/components/StoreLocatorMapMarker/index.jsx +55 -0
- package/src/components/StoreLocatorMessageDialog/index.jsx +20 -0
- package/src/components/StoreLocatorSearch/index.jsx +316 -0
- package/src/components/StoreMap/index.jsx +30 -0
- package/src/components/StoreMeta/index.jsx +7 -0
- package/src/components/StoreProducts/index.jsx +112 -0
- package/src/components/ui/Badge/index.jsx +46 -0
- package/src/components/ui/Button/index.jsx +56 -0
- package/src/components/ui/Button/indexButton.cy.jsx +9 -0
- package/src/components/ui/Card/index.jsx +90 -0
- package/src/components/ui/Input/index.jsx +19 -0
- package/src/components/ui/Input/indexInput.cy.jsx +9 -0
- package/src/components/ui/LoadingPuff/index.jsx +10 -0
- package/src/components/ui/Panel/index.jsx +23 -0
- package/src/components/ui/PhoneNumberInput/index.jsx +17 -0
- package/src/contexts/quote-form.jsx +94 -0
- package/src/contexts/store-locator.jsx +83 -0
- package/src/contexts/store.jsx +59 -0
- package/src/contexts/translations.jsx +11 -0
- package/src/dist.css +229 -0
- package/src/entries/QuoteForm.js +2 -0
- package/src/entries/Store.js +2 -0
- package/src/entries/StoreLocator.js +2 -0
- package/src/entries/StoreLocatorProvider.js +2 -0
- package/src/entries/styles.js +2 -0
- package/src/entries/useStoreLocator.js +2 -0
- package/src/i18n/defaultResources.js +19 -0
- package/src/i18n/index.js +44 -0
- package/src/i18n/mergeResources.js +22 -0
- package/src/index.css +214 -0
- package/src/lib/addressComponentsToAddress.js +43 -0
- package/src/lib/productSchema.js +6 -0
- package/src/lib/useGeolocation.js +266 -0
- package/src/lib/useHours.js +205 -0
- package/src/lib/usePlacesAutocomplete.js +288 -0
- package/src/lib/useProductAvailability.js +38 -0
- package/src/lib/useRudderAnalytics.js +50 -0
- package/src/lib/useSearchResults.js +102 -0
- package/src/lib/useStoreLocatorConfig.js +50 -0
- package/src/lib/utils/cn.js +6 -0
- package/src/lib/utils/measure.js +31 -0
- package/src/locales/en/default.json +58 -0
- package/src/locales/es/default.json +58 -0
- package/src/locales/fr/default.json +58 -0
- package/src/locales/it/default.json +58 -0
- package/src/main.jsx +10 -0
- package/vite.config.js +60 -53
- package/dist/CartForm.js +0 -617
- package/dist/Container-CU_WrBOi.js +0 -22
- package/dist/Modal-DTBKy_6d.js +0 -863
- package/dist/ProductForm.js +0 -343
- package/dist/Retailer.js +0 -3637
- package/dist/StoreLocator.js +0 -797
- package/dist/addressComponentsToAddress-DCL-K8mn.js +0 -1932
- package/dist/browser-ponyfill-DcK7_cJB.js +0 -339
- package/dist/globals-B8-hYoIU.js +0 -8518
- package/dist/index-CqSfhXDd.js +0 -137
- package/dist/index-FM02Uq_P.js +0 -100
- package/dist/style.css +0 -1
package/dist/index-CqSfhXDd.js
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import { jsx as t, jsxs as g } from "react/jsx-runtime";
|
|
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-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
|
-
/**
|
|
6
|
-
* @license lucide-react v0.542.0 - ISC
|
|
7
|
-
*
|
|
8
|
-
* This source code is licensed under the ISC license.
|
|
9
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
10
|
-
*/
|
|
11
|
-
const se = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]], te = $("check", se);
|
|
12
|
-
/**
|
|
13
|
-
* @license lucide-react v0.542.0 - ISC
|
|
14
|
-
*
|
|
15
|
-
* This source code is licensed under the ISC license.
|
|
16
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/
|
|
18
|
-
const ne = [
|
|
19
|
-
["path", { d: "M18 6 6 18", key: "1bl5f8" }],
|
|
20
|
-
["path", { d: "m6 6 12 12", key: "d8bk6v" }]
|
|
21
|
-
], j = $("x", ne), oe = Q(), we = ({ product: e, children: l }) => {
|
|
22
|
-
const [n, d] = c(0), m = {
|
|
23
|
-
currentStep: n,
|
|
24
|
-
setCurrentStep: d,
|
|
25
|
-
product: e
|
|
26
|
-
};
|
|
27
|
-
return /* @__PURE__ */ t(oe.Provider, { value: m, children: l });
|
|
28
|
-
}, ae = Q(), ye = ({ children: e }) => {
|
|
29
|
-
const [l, n] = c(null), [d, m] = c(null), [_, r] = c(null), [C, N] = c(null), [k, v] = c(null), [D, x] = c(null), [L, S] = c(""), [I, o] = c(!1), [a, f] = c(!1), { coords: w, isGeolocationAvailable: y, isGeolocationEnabled: O, getPosition: B } = R({ suppressLocationOnMount: !0, onError: () => f(!1), onSuccess: () => f(!1), positionOptions: { enableHighAccuracy: !1 }, userDecisionTimeout: 5e3 }), F = {
|
|
30
|
-
lat: l,
|
|
31
|
-
lng: d,
|
|
32
|
-
isLoading: I,
|
|
33
|
-
setIsLoading: o,
|
|
34
|
-
locationName: L,
|
|
35
|
-
setLocationName: S,
|
|
36
|
-
setLocation: ({ lat: h, lng: p }) => {
|
|
37
|
-
n(h), m(p);
|
|
38
|
-
},
|
|
39
|
-
mapCenter: { lat: _, lng: C },
|
|
40
|
-
setMapCenter: ({ lat: h, lng: p }) => {
|
|
41
|
-
r(h), N(p);
|
|
42
|
-
},
|
|
43
|
-
searchCenter: { lat: k, lng: D },
|
|
44
|
-
setSearchCenter: ({ lat: h, lng: p }) => {
|
|
45
|
-
v(h), x(p);
|
|
46
|
-
},
|
|
47
|
-
loadingGeo: a,
|
|
48
|
-
geoCoords: w,
|
|
49
|
-
isGeolocationAvailable: y,
|
|
50
|
-
isGeolocationEnabled: O,
|
|
51
|
-
getPosition: B
|
|
52
|
-
};
|
|
53
|
-
return /* @__PURE__ */ t(ae.Provider, { value: F, children: e });
|
|
54
|
-
}, ce = "oHxQR", re = "ggY6v", ie = "B-vL7", de = "xpYRZ", le = "PD0AO", ue = "i1mIs", me = "TOu1q", he = "BYI6o", pe = "_8Athb", ge = "wpcV2", s = {
|
|
55
|
-
header: ce,
|
|
56
|
-
name: re,
|
|
57
|
-
address: ie,
|
|
58
|
-
distance: de,
|
|
59
|
-
selectBtn: le,
|
|
60
|
-
productList: ue,
|
|
61
|
-
productHeader: me,
|
|
62
|
-
productItem: he,
|
|
63
|
-
inStock: pe,
|
|
64
|
-
outOfStock: ge
|
|
65
|
-
}, De = ({ location: e, showProducts: l = !1 }) => {
|
|
66
|
-
var P, T, A;
|
|
67
|
-
const { t: n, i18n: d } = U(), m = d.language, _ = K(m), { products: r, searchCenter: C, setSelectedLocationId: N, selectedLocationId: k, setFocusedLocationId: v, setShowMap: D, setShowDetails: x } = z(), L = Y({ lat: (P = e == null ? void 0 : e.address) == null ? void 0 : P.latitude, lng: (T = e.address) == null ? void 0 : T.longitude }, C), S = _ === "km" ? L : X(L), I = Math.round(S * 10) / 10, o = e.retailer_location_hours.find((i) => i.day === (/* @__PURE__ */ new Date()).getDay()), a = /* @__PURE__ */ new Date();
|
|
68
|
-
let f = /* @__PURE__ */ new Date();
|
|
69
|
-
o && (f = new H(a.getUTCFullYear(), a.getMonth(), a.getDate(), o.open_at_hour, o.open_at_minute, 0, 0, o.timezone));
|
|
70
|
-
let w = /* @__PURE__ */ new Date();
|
|
71
|
-
o && (w = new H(a.getUTCFullYear(), a.getMonth(), a.getDate(), o.close_at_hour, o.close_at_minute, 0, 0, o.timezone));
|
|
72
|
-
const y = o && a >= f && a <= w, O = o && !y && a - f > 30 * 6e4 * -1, B = o && y && w - a < 30 * 6e4;
|
|
73
|
-
y ? B ? (u(s.hours, s.soon), n("store.closingSoon")) : (u(s.hours, s.open), n("store.openNow")) : O ? (u(s.hours, s.soon), n("store.openingSoon")) : (u(s.hours, s.closed), n("store.closedNow"));
|
|
74
|
-
const F = () => {
|
|
75
|
-
N(e.id);
|
|
76
|
-
}, h = () => {
|
|
77
|
-
v(e.id);
|
|
78
|
-
}, p = e.id === k ? u(s.wrapper, s.selected) : u(s.wrapper), q = (A = e == null ? void 0 : e.store_type) != null && A.includes("Studio") ? "studio" : "retailer", E = r == null ? void 0 : r.map((i) => {
|
|
79
|
-
var G;
|
|
80
|
-
const Z = (G = e == null ? void 0 : e.retailer_location_products) == null ? void 0 : G.some((M) => (M.sku === i.sku || M.external_id === i.external_id || M.collection_id === i.collection_id) && M.stocked);
|
|
81
|
-
return { ...i, isStocked: Z };
|
|
82
|
-
});
|
|
83
|
-
return /* @__PURE__ */ g("div", { className: p, onClick: h, children: [
|
|
84
|
-
/* @__PURE__ */ g("div", { className: s.header, children: [
|
|
85
|
-
/* @__PURE__ */ t("h4", { className: s.name, children: e.retailer_name }),
|
|
86
|
-
/* @__PURE__ */ t("div", { className: "text-end", children: /* @__PURE__ */ t(V, { type: q }) })
|
|
87
|
-
] }),
|
|
88
|
-
/* @__PURE__ */ g("div", { className: u(s.distance), children: [
|
|
89
|
-
I,
|
|
90
|
-
" ",
|
|
91
|
-
_,
|
|
92
|
-
" ",
|
|
93
|
-
n("away")
|
|
94
|
-
] }),
|
|
95
|
-
/* @__PURE__ */ t("section", { className: `${s.hoursWrapper} d-flex justify-content-between align-items-center pe-3`, children: /* @__PURE__ */ t(W, { hours: e == null ? void 0 : e.retailer_location_hours }) }),
|
|
96
|
-
/* @__PURE__ */ t("address", { className: u(s.address), children: /* @__PURE__ */ g("div", { children: [
|
|
97
|
-
e.address.street_line_one,
|
|
98
|
-
e.address.street_line_two && `, ${e.address.street_line_two}`,
|
|
99
|
-
" ",
|
|
100
|
-
e.address.city,
|
|
101
|
-
", ",
|
|
102
|
-
e.address.province,
|
|
103
|
-
" ",
|
|
104
|
-
e.address.postal_code
|
|
105
|
-
] }) }),
|
|
106
|
-
(r == null ? void 0 : r.length) > 0 && l && /* @__PURE__ */ g("div", { children: [
|
|
107
|
-
/* @__PURE__ */ t("div", { className: s.productHeader, children: n("quote.location.product_availability") }),
|
|
108
|
-
/* @__PURE__ */ t("div", { className: s.productList, children: E.map((i) => /* @__PURE__ */ g("div", { className: s.productItem, children: [
|
|
109
|
-
/* @__PURE__ */ t("div", { className: s.productStatus, children: i.isStocked ? /* @__PURE__ */ t(te, { className: s.inStock, size: 20 }) : /* @__PURE__ */ t(j, { className: s.outOfStock, size: 20 }) }),
|
|
110
|
-
/* @__PURE__ */ t("div", { className: s.productName, children: i.name })
|
|
111
|
-
] }, i.name)) })
|
|
112
|
-
] }),
|
|
113
|
-
/* @__PURE__ */ t(ee, { variant: "dark", size: "sm", onClick: F, className: `d-flex align-items-center px-3 py-2 ${s.selectBtn}`, children: n("quote.location.select_location") })
|
|
114
|
-
] });
|
|
115
|
-
}, _e = "QMwKB", Le = "tlZ-O", Se = "NQEG7", fe = "MGV0F", b = {
|
|
116
|
-
wrapper: _e,
|
|
117
|
-
message: Le,
|
|
118
|
-
dismiss: Se,
|
|
119
|
-
cta: fe
|
|
120
|
-
}, xe = ({ onSelect: e, onDismiss: l }) => {
|
|
121
|
-
const { t: n } = U(), { locations: d, searchCenter: m, setSelectedLocationId: _, isLoading: r } = z(), { cc_company_retailer_location_id: C } = J(), [N, k] = c(!1), v = d.length > 0 ? Math.min(...d.map((S) => Y({ lat: S.address.latitude, lng: S.address.longitude }, m))) : null, D = !N && (d.length === 0 || v > 100) && !r, x = () => {
|
|
122
|
-
_(C);
|
|
123
|
-
}, L = () => {
|
|
124
|
-
k(!0), l && l();
|
|
125
|
-
};
|
|
126
|
-
return D ? /* @__PURE__ */ g("div", { className: b.wrapper, children: [
|
|
127
|
-
/* @__PURE__ */ t("button", { className: b.dismiss, onClick: L, children: /* @__PURE__ */ t(j, { size: 20 }) }),
|
|
128
|
-
/* @__PURE__ */ t("p", { className: b.message, children: n("form_out_of_area.message") }),
|
|
129
|
-
/* @__PURE__ */ t("button", { className: b.cta, onClick: x, children: n("form_out_of_area.cta") })
|
|
130
|
-
] }) : null;
|
|
131
|
-
};
|
|
132
|
-
export {
|
|
133
|
-
xe as F,
|
|
134
|
-
De as L,
|
|
135
|
-
we as Q,
|
|
136
|
-
ye as a
|
|
137
|
-
};
|
package/dist/index-FM02Uq_P.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
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
|
-
};
|