@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,348 +0,0 @@
1
- import { jsx as e, jsxs as s } from "react/jsx-runtime";
2
- import { useEffect as j, useState as E, Suspense as z } from "react";
3
- import { u as F, L as H, g as $, d as D, S as Q, b as U, k as J, f as V, A as K, c as G, w as X, h as Y, e as Z } from "./addressComponentsToAddress-CNK2WJ24.js";
4
- import { L as ee, F as te, Q as ae } from "./index-DqABFy0O.js";
5
- import { a as M, c as k, e as oe, h as b, i as ne, B as R, F as d, R as se, C as _, O as y, l as W, I as re, m as ie } from "./globals-C3lGVSJ0.js";
6
- import { S as le } from "./index-TPy0P4tu.js";
7
- const ce = () => {
8
- const { locationName: m, setLocationName: l, setSearchCenter: c, setMapCenter: t, setLoadingGeo: f, getPosition: n } = F();
9
- return /* @__PURE__ */ e(
10
- H,
11
- {
12
- locationName: m,
13
- setLocationName: l,
14
- setSearchCenter: c,
15
- setMapCenter: t,
16
- handleLocate: () => {
17
- f(!0), n();
18
- }
19
- }
20
- );
21
- }, de = "_5BvSp", me = "NnCF-", ue = "OxA-3", he = "fIWeh", C = {
22
- loading: de,
23
- itemWrapper: me,
24
- selected: ue,
25
- wrapper: he
26
- }, pe = () => {
27
- const { t: m } = M(), { locations: l, isLoading: c, focusedLocationId: t } = F();
28
- function f(n, u) {
29
- if (!n || !u) return;
30
- const h = n.getBoundingClientRect(), i = u.getBoundingClientRect().top - h.top + n.scrollTop;
31
- n.scrollTo({
32
- top: i,
33
- behavior: "smooth"
34
- });
35
- }
36
- return j(() => {
37
- const n = document.getElementById(`location-${t}`);
38
- if (n) {
39
- const u = document.getElementById("llw");
40
- f(u, n);
41
- }
42
- }, [t]), c ? /* @__PURE__ */ e("div", { className: k(C.loading), children: /* @__PURE__ */ e("img", { src: "https://images.sofasandsectionals.com/cc/pal-loader.svg", width: "50", height: "50", alt: m("store_locator.loading") }) }) : /* @__PURE__ */ e("div", { className: k(C.wrapper), id: "llw", children: l.map((n) => /* @__PURE__ */ e("div", { className: t === n.id ? k(C.itemWrapper, C.selected) : k(C.itemWrapper), id: `location-${n.id}`, children: /* @__PURE__ */ e(ee, { id: n.id, location: n }) }, n.id)) });
43
- }, fe = "NQ6-h", _e = "_4wmyC", ge = "_9dVCP", P = {
44
- wrapper: fe,
45
- name: _e,
46
- address: ge
47
- }, ve = () => {
48
- var I, q, x, w, L, a, B;
49
- const { cc_company_retailer_location_id: m } = $(), { distanceUnit: l, searchCenter: c, selectedLocation: t, setSelectedLocationId: f, selectedLocationId: n, setMessageModalOpen: u, setShowMap: h, setShowDetails: v } = F(), i = D({ lat: (I = t == null ? void 0 : t.address) == null ? void 0 : I.latitude, lng: (q = t == null ? void 0 : t.address) == null ? void 0 : q.longitude }, c), o = l === "km" ? i : J(i), N = Math.round(o * 10) / 10, S = (x = t == null ? void 0 : t.store_type) != null && x.includes("Studio") ? "studio" : "retailer";
50
- return !t || t.location_id === m ? null : /* @__PURE__ */ e("div", { children: /* @__PURE__ */ s("div", { className: P.wrapper, children: [
51
- /* @__PURE__ */ s("div", { className: "d-flex align-items-center justify-content-between", children: [
52
- /* @__PURE__ */ e("h3", { className: P.name, children: t == null ? void 0 : t.retailer_name }),
53
- /* @__PURE__ */ e("div", { className: "text-end", children: /* @__PURE__ */ e(Q, { type: S }) })
54
- ] }),
55
- /* @__PURE__ */ s("div", { className: "text-muted fs-6 fw-normal mt-1", children: [
56
- N,
57
- " ",
58
- l
59
- ] }),
60
- /* @__PURE__ */ e("div", { children: /* @__PURE__ */ e(U, { hours: t == null ? void 0 : t.retailer_location_hours }) }),
61
- /* @__PURE__ */ s("address", { className: P.address, children: [
62
- /* @__PURE__ */ e("div", { children: (w = t == null ? void 0 : t.address) == null ? void 0 : w.street_line_one }),
63
- /* @__PURE__ */ s("div", { children: [
64
- (L = t == null ? void 0 : t.address) == null ? void 0 : L.city,
65
- ", ",
66
- (a = t == null ? void 0 : t.address) == null ? void 0 : a.province,
67
- " ",
68
- (B = t == null ? void 0 : t.address) == null ? void 0 : B.postal_code
69
- ] })
70
- ] })
71
- ] }) });
72
- }, Ne = "KsfpB", be = "t-v-7", ye = "UFm9T", Ce = "c3v8k", g = {
73
- changeLocationBtn: Ne,
74
- submitButton: be,
75
- successContainer: ye,
76
- successBtn: Ce
77
- }, Se = ({ id: m, product: l = null, onSuccess: c, onCancel: t, onClose: f, optInText: n }) => {
78
- l || console.warn("Colab Commerce: No product(s) provided to the ProductForm component.");
79
- const { cc_company_retailer_location_id: u } = $(), { selectedLocationId: h, setSelectedLocationId: v, searchCenter: i } = F(), { t: o } = M("default"), [N, S] = E(!1), [I, q] = E(!1), x = {
80
- firstName: "",
81
- lastName: "",
82
- email: "",
83
- phone: "",
84
- notes: ""
85
- }, w = oe().shape({
86
- firstName: b().required(o("quote_form.first_name_required")),
87
- lastName: b().required(o("quote_form.last_name_required")),
88
- email: b().email(o("quote_form.invalid_email")).required(o("quote_form.email_required")),
89
- phone: b().required(o("quote_form.phone_required")),
90
- notes: b()
91
- }), a = ne({
92
- initialValues: x,
93
- validationSchema: w,
94
- onSubmit: async (p) => {
95
- X("AIzaSyAnJmWEU1r63DiRWHkjczxzHyIEq3dhj4M");
96
- const T = await K(i == null ? void 0 : i.lat, i == null ? void 0 : i.lng), r = G(T.results[0].address_components), A = await fetch("https://api.colabcommerce.com/widget_api/leads", {
97
- method: "POST",
98
- headers: {
99
- "Content-Type": "application/json"
100
- },
101
- body: JSON.stringify({
102
- id: m,
103
- lead: {
104
- name: `${p.firstName} ${p.lastName}`,
105
- emails_attributes: [{ email: p.email }],
106
- phone_numbers_attributes: [{ phone_number: p.phone, country_code: "US" }],
107
- message: p.message,
108
- opt_in: p.optIn,
109
- location_attributes: {
110
- street_line_one: r == null ? void 0 : r.addressLine1,
111
- street_line_two: r == null ? void 0 : r.addressLine2,
112
- city: r == null ? void 0 : r.city,
113
- province: r == null ? void 0 : r.province,
114
- postal_code: r == null ? void 0 : r.postalCode,
115
- country: r == null ? void 0 : r.country,
116
- latitude: (i == null ? void 0 : i.lat) || null,
117
- longitude: (i == null ? void 0 : i.lng) || null
118
- },
119
- assignee_id: h || null,
120
- assignee_type: "CompanyRetailerLocation",
121
- lead_activities_attributes: [{
122
- type: "LeadActivity::QuoteRequest",
123
- products: [l],
124
- notes: p.notes,
125
- source_type: "Company",
126
- source_id: m
127
- }]
128
- }
129
- })
130
- });
131
- if (!A.ok) {
132
- q(!0);
133
- return;
134
- }
135
- const O = await A.json();
136
- S(!0), c && c(O);
137
- }
138
- });
139
- j(() => {
140
- const p = document.getElementById("cc-accordion-anchor");
141
- p && p.scrollIntoView({ behavior: "instant" });
142
- }, [h]);
143
- const B = () => {
144
- S(!1), v(null), f && f();
145
- };
146
- return /* @__PURE__ */ s("div", { className: "cc", children: [
147
- N && /* @__PURE__ */ e("div", { className: g.successContainer, children: /* @__PURE__ */ s("div", { className: "text-center", children: [
148
- /* @__PURE__ */ e("h2", { className: "fw-bold fs-2", style: { marginBottom: "3.2rem" }, children: o("cart_form.success_title") }),
149
- /* @__PURE__ */ e("div", { className: "fs-6", style: { fontWeight: 600, marginBottom: "3.2rem" }, children: o("cart_form.success_message") }),
150
- /* @__PURE__ */ e(R, { variant: "dark", className: g.successBtn, onClick: B, children: o("cart_form.success_button") })
151
- ] }) }),
152
- !N && /* @__PURE__ */ s("div", { id: "cc-accordion-anchor", children: [
153
- !h && /* @__PURE__ */ s("div", { children: [
154
- /* @__PURE__ */ e("div", { className: "mb-3", children: /* @__PURE__ */ e(ce, {}) }),
155
- /* @__PURE__ */ s("div", { className: "position-relative", children: [
156
- /* @__PURE__ */ e(V, {}),
157
- /* @__PURE__ */ e(le, {})
158
- ] }),
159
- /* @__PURE__ */ e(te, {}),
160
- /* @__PURE__ */ e(pe, {})
161
- ] }),
162
- h && /* @__PURE__ */ s("div", { children: [
163
- /* @__PURE__ */ s("div", { children: [
164
- /* @__PURE__ */ s("div", { className: "d-flex align-items-center justify-content-between px-3 mb-2 fs-6", children: [
165
- /* @__PURE__ */ e("span", { className: "fw-bold", children: u === h ? "" : o("quote.selected_location.title") }),
166
- /* @__PURE__ */ e("button", { onClick: () => v(null), className: g.changeLocationBtn, children: o("quote.change_location") })
167
- ] }),
168
- /* @__PURE__ */ e("div", { className: g.selectedLocation, children: /* @__PURE__ */ e(ve, {}) })
169
- ] }),
170
- /* @__PURE__ */ e("div", { className: "p-3", children: /* @__PURE__ */ e(d, { onSubmit: a.handleSubmit, className: g.form, children: /* @__PURE__ */ s(se, { children: [
171
- /* @__PURE__ */ e(_, { xs: 12, md: 12, children: /* @__PURE__ */ s(
172
- y,
173
- {
174
- controlId: "floatingInput",
175
- label: o("quote_form.first_name"),
176
- className: "mb-3",
177
- children: [
178
- /* @__PURE__ */ e(
179
- d.Control,
180
- {
181
- type: "text",
182
- name: "firstName",
183
- placeholder: o("quote_form.first_name_placeholder"),
184
- onChange: a.handleChange,
185
- value: a.values.firstName,
186
- className: "rounded-0",
187
- isInvalid: !!a.errors.firstName
188
- }
189
- ),
190
- /* @__PURE__ */ e(d.Control.Feedback, { type: "invalid", children: a.errors.firstName })
191
- ]
192
- }
193
- ) }),
194
- /* @__PURE__ */ e(_, { xs: 12, md: 12, children: /* @__PURE__ */ s(
195
- y,
196
- {
197
- controlId: "floatingInput",
198
- label: o("quote_form.last_name"),
199
- className: "mb-3",
200
- children: [
201
- /* @__PURE__ */ e(
202
- d.Control,
203
- {
204
- type: "text",
205
- name: "lastName",
206
- className: "rounded-0",
207
- placeholder: o("quote_form.last_name_placeholder"),
208
- onChange: a.handleChange,
209
- value: a.values.lastName,
210
- isInvalid: !!a.errors.lastName
211
- }
212
- ),
213
- /* @__PURE__ */ e(d.Control.Feedback, { type: "invalid", children: a.errors.lastName })
214
- ]
215
- }
216
- ) }),
217
- /* @__PURE__ */ e(_, { xs: 12, md: 12, children: /* @__PURE__ */ s(
218
- y,
219
- {
220
- controlId: "floatingInput",
221
- label: o("quote_form.email"),
222
- className: "mb-3",
223
- children: [
224
- /* @__PURE__ */ e(
225
- d.Control,
226
- {
227
- type: "email",
228
- name: "email",
229
- className: "rounded-0",
230
- placeholder: o("quote_form.email_placeholder"),
231
- onChange: a.handleChange,
232
- value: a.values.email,
233
- isInvalid: !!a.errors.email
234
- }
235
- ),
236
- /* @__PURE__ */ e(d.Control.Feedback, { type: "invalid", children: a.errors.email })
237
- ]
238
- }
239
- ) }),
240
- /* @__PURE__ */ e(_, { xs: 12, md: 12, children: /* @__PURE__ */ s(
241
- y,
242
- {
243
- controlId: "floatingInput",
244
- label: o("quote_form.phone"),
245
- className: "mb-3",
246
- children: [
247
- /* @__PURE__ */ e(
248
- d.Control,
249
- {
250
- type: "text",
251
- name: "phone",
252
- className: "rounded-0",
253
- placeholder: o("quote_form.phone_placeholder"),
254
- onChange: a.handleChange,
255
- value: a.values.phone,
256
- isInvalid: !!a.errors.phone
257
- }
258
- ),
259
- /* @__PURE__ */ e(d.Control.Feedback, { type: "invalid", children: a.errors.phone })
260
- ]
261
- }
262
- ) }),
263
- /* @__PURE__ */ e(_, { xs: 12, children: /* @__PURE__ */ s(
264
- y,
265
- {
266
- controlId: "floatingTextarea",
267
- label: o("quote_form.notes"),
268
- className: ["mb-3", g.textarea].join(" "),
269
- children: [
270
- /* @__PURE__ */ e(
271
- d.Control,
272
- {
273
- as: "textarea",
274
- name: "notes",
275
- className: "rounded-0",
276
- placeholder: o("quote_form.notes_placeholder"),
277
- onChange: a.handleChange,
278
- value: a.values.notes,
279
- isInvalid: !!a.errors.notes,
280
- style: { height: "100px" }
281
- }
282
- ),
283
- /* @__PURE__ */ e(d.Control.Feedback, { type: "invalid", children: a.errors.notes })
284
- ]
285
- }
286
- ) }),
287
- n && /* @__PURE__ */ s(_, { xs: 12, children: [
288
- /* @__PURE__ */ e(
289
- d.Check,
290
- {
291
- name: "optIn",
292
- type: "checkbox",
293
- label: n,
294
- className: "mb-3 fs-6",
295
- onChange: a.handleChange,
296
- isInvalid: !!a.errors.optIn
297
- }
298
- ),
299
- /* @__PURE__ */ e(d.Control.Feedback, { type: "invalid", children: a.errors.optIn })
300
- ] }),
301
- /* @__PURE__ */ s(_, { xs: 12, className: "text-start d-flex align-items-center", children: [
302
- /* @__PURE__ */ e(R, { type: "submit", variant: "dark", className: g.submitButton, disabled: N, children: a.isSubmitting ? o("quote.submitting") : o("quote_form.submit") }),
303
- I && /* @__PURE__ */ e("div", { className: "text-danger ms-2", children: o("quote_form.error") }),
304
- N && /* @__PURE__ */ e("div", { className: "text-success ms-2", children: o("quote_form.success") })
305
- ] })
306
- ] }) }) })
307
- ] })
308
- ] })
309
- ] });
310
- }, Fe = ({
311
- id: m,
312
- // The entity ID for the Store Locator.
313
- locale: l,
314
- product: c,
315
- filterRetailerByStockedProduct: t = !1,
316
- filterRetailerByAvailableProduct: f = !1,
317
- optInText: n = null,
318
- onCancel: u,
319
- onClose: h,
320
- onSuccess: v
321
- }) => (j(() => {
322
- W.changeLanguage(l);
323
- }, [l]), c || (console.warn("Colab Commerce: No product(s) provided to the ProductForm component."), c = []), /* @__PURE__ */ e(z, { children: /* @__PURE__ */ e(re, { i18n: W, children: /* @__PURE__ */ e(ie, { apiKey: "AIzaSyAnJmWEU1r63DiRWHkjczxzHyIEq3dhj4M", libraries: ["places"], children: /* @__PURE__ */ e(Y, { id: m, children: /* @__PURE__ */ e(
324
- Z,
325
- {
326
- id: m,
327
- locale: l,
328
- filterRetailerByStockedProduct: t,
329
- filterRetailerByAvailableProduct: f,
330
- optInText: n,
331
- autoLocate: !0,
332
- products: [c],
333
- children: /* @__PURE__ */ e(ae, { children: /* @__PURE__ */ e(
334
- Se,
335
- {
336
- id: m,
337
- product: c,
338
- onSuccess: v,
339
- optInText: n,
340
- onCancel: u,
341
- onClose: h
342
- }
343
- ) })
344
- }
345
- ) }) }) }) }));
346
- export {
347
- Fe as default
348
- };