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