@colabcommerce/elements 0.0.3 → 0.9.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.
Files changed (99) hide show
  1. package/.pnp.cjs +16484 -0
  2. package/.pnp.loader.mjs +2126 -0
  3. package/.yarn/install-state.gz +0 -0
  4. package/.yarn/releases/yarn-4.12.0.cjs +942 -0
  5. package/.yarnrc.yml +1 -0
  6. package/README.md +60 -41
  7. package/cypress/fixtures/example.json +5 -0
  8. package/cypress/support/commands.js +25 -0
  9. package/cypress/support/component-index.html +15 -0
  10. package/cypress/support/component.js +26 -0
  11. package/cypress.config.js +10 -0
  12. package/eslint.config.js +32 -0
  13. package/index.html +13 -0
  14. package/package.json +91 -67
  15. package/playground/index.html +14 -0
  16. package/playground/main.jsx +36 -0
  17. package/public/vite.svg +1 -0
  18. package/src/App.css +0 -0
  19. package/src/App.jsx +65 -0
  20. package/src/components/CollapsibleStoreHours/index.jsx +269 -0
  21. package/src/components/HoursList/index.jsx +225 -0
  22. package/src/components/LeadForm/index.jsx +241 -0
  23. package/src/components/MessageDialog/index.jsx +169 -0
  24. package/src/components/QuoteForm/index.jsx +82 -0
  25. package/src/components/QuoteFormSearch/index.jsx +276 -0
  26. package/src/components/QuoteFormStoreList/index.jsx +65 -0
  27. package/src/components/QuoteFormStoreListItem/index.jsx +134 -0
  28. package/src/components/QuoteLeadForm/index.jsx +16 -0
  29. package/src/components/QuoteMap/index.jsx +96 -0
  30. package/src/components/QuoteMapMarker/index.jsx +56 -0
  31. package/src/components/StaticMap/index.jsx +24 -0
  32. package/src/components/Store/index.jsx +44 -0
  33. package/src/components/StoreContact/index.jsx +96 -0
  34. package/src/components/StoreInfo/index.jsx +50 -0
  35. package/src/components/StoreList/index.jsx +59 -0
  36. package/src/components/StoreListItem/index.jsx +99 -0
  37. package/src/components/StoreListItem/indexStoreListItem.cy.jsx +30 -0
  38. package/src/components/StoreListNoneFound/index.jsx +16 -0
  39. package/src/components/StoreLocator/index.jsx +43 -0
  40. package/src/components/StoreLocatorMap/index.jsx +93 -0
  41. package/src/components/StoreLocatorMapMarker/index.jsx +55 -0
  42. package/src/components/StoreLocatorMessageDialog/index.jsx +20 -0
  43. package/src/components/StoreLocatorSearch/index.jsx +316 -0
  44. package/src/components/StoreMap/index.jsx +30 -0
  45. package/src/components/StoreMeta/index.jsx +7 -0
  46. package/src/components/StoreProducts/index.jsx +112 -0
  47. package/src/components/ui/Badge/index.jsx +46 -0
  48. package/src/components/ui/Button/index.jsx +56 -0
  49. package/src/components/ui/Button/indexButton.cy.jsx +9 -0
  50. package/src/components/ui/Card/index.jsx +90 -0
  51. package/src/components/ui/Input/index.jsx +19 -0
  52. package/src/components/ui/Input/indexInput.cy.jsx +9 -0
  53. package/src/components/ui/LoadingPuff/index.jsx +10 -0
  54. package/src/components/ui/Panel/index.jsx +23 -0
  55. package/src/components/ui/PhoneNumberInput/index.jsx +17 -0
  56. package/src/contexts/quote-form.jsx +94 -0
  57. package/src/contexts/store-locator.jsx +83 -0
  58. package/src/contexts/store.jsx +59 -0
  59. package/src/contexts/translations.jsx +11 -0
  60. package/src/dist.css +229 -0
  61. package/src/entries/QuoteForm.js +2 -0
  62. package/src/entries/Store.js +2 -0
  63. package/src/entries/StoreLocator.js +2 -0
  64. package/src/entries/StoreLocatorProvider.js +2 -0
  65. package/src/entries/styles.js +2 -0
  66. package/src/entries/useStoreLocator.js +2 -0
  67. package/src/i18n/defaultResources.js +19 -0
  68. package/src/i18n/index.js +44 -0
  69. package/src/i18n/mergeResources.js +22 -0
  70. package/src/index.css +214 -0
  71. package/src/lib/addressComponentsToAddress.js +43 -0
  72. package/src/lib/productSchema.js +6 -0
  73. package/src/lib/useGeolocation.js +266 -0
  74. package/src/lib/useHours.js +205 -0
  75. package/src/lib/usePlacesAutocomplete.js +288 -0
  76. package/src/lib/useProductAvailability.js +38 -0
  77. package/src/lib/useRudderAnalytics.js +50 -0
  78. package/src/lib/useSearchResults.js +102 -0
  79. package/src/lib/useStoreLocatorConfig.js +50 -0
  80. package/src/lib/utils/cn.js +6 -0
  81. package/src/lib/utils/measure.js +31 -0
  82. package/src/locales/en/default.json +58 -0
  83. package/src/locales/es/default.json +58 -0
  84. package/src/locales/fr/default.json +58 -0
  85. package/src/locales/it/default.json +58 -0
  86. package/src/main.jsx +10 -0
  87. package/vite.config.js +60 -53
  88. package/dist/CartForm.js +0 -617
  89. package/dist/Container-7bFgo-eP.js +0 -22
  90. package/dist/Modal-BqRDRCTs.js +0 -863
  91. package/dist/ProductForm.js +0 -348
  92. package/dist/Retailer.js +0 -3637
  93. package/dist/StoreLocator.js +0 -793
  94. package/dist/addressComponentsToAddress-CNK2WJ24.js +0 -1932
  95. package/dist/browser-ponyfill-BEmK0BQJ.js +0 -339
  96. package/dist/globals-C3lGVSJ0.js +0 -8520
  97. package/dist/index-DqABFy0O.js +0 -137
  98. package/dist/index-TPy0P4tu.js +0 -98
  99. package/dist/style.css +0 -1
@@ -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-CNK2WJ24.js";
4
- import { d as $, a as U, Q as H, c as u, B as ee } from "./globals-C3lGVSJ0.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
- };
@@ -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-CNK2WJ24.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
- };