@colabcommerce/elements 0.0.1 → 0.0.2

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.
@@ -1,932 +0,0 @@
1
- import { jsx as a, Fragment as xe, jsxs as N } from "react/jsx-runtime";
2
- import * as b from "react";
3
- import { useState as D, useRef as g, useEffect as C, useCallback as R, useContext as Xe, createContext as mt, useMemo as Ye, useLayoutEffect as ht, cloneElement as ke, forwardRef as gt, useImperativeHandle as pt } from "react";
4
- import { p as re, q as Be, s as ne, l as pe, r as Ge, v as Et, w as yt, T as vt, t as bt, k as w, n as Rt, E as Tt, j as z, P as Ce, x as Ct, y as Nt, z as _e, D as wt, F as Mt, a as Ot, G as xt, H as St, J as me, K as kt, c as v, L as h, B as Bt } from "./globals-D3YPIcjZ.js";
5
- import At from "react-dom";
6
- var he;
7
- function He(e) {
8
- if ((!he && he !== 0 || e) && re) {
9
- var t = document.createElement("div");
10
- t.style.position = "absolute", t.style.top = "-9999px", t.style.width = "50px", t.style.height = "50px", t.style.overflow = "scroll", document.body.appendChild(t), he = t.offsetWidth - t.clientWidth, document.body.removeChild(t);
11
- }
12
- return he;
13
- }
14
- function Lt() {
15
- return D(null);
16
- }
17
- function It(e) {
18
- const t = g(e);
19
- return C(() => {
20
- t.current = e;
21
- }, [e]), t;
22
- }
23
- function Se(e) {
24
- const t = It(e);
25
- return R(function(...n) {
26
- return t.current && t.current(...n);
27
- }, [t]);
28
- }
29
- function Ft(e) {
30
- const t = g(e);
31
- return t.current = e, t;
32
- }
33
- function Dt(e) {
34
- const t = Ft(e);
35
- C(() => () => t.current(), []);
36
- }
37
- function Ne(e) {
38
- e === void 0 && (e = Be());
39
- try {
40
- var t = e.activeElement;
41
- return !t || !t.nodeName ? null : t;
42
- } catch {
43
- return e.body;
44
- }
45
- }
46
- function Ue(e, t) {
47
- if (e.contains) return e.contains(t);
48
- if (e.compareDocumentPosition) return e === t || !!(e.compareDocumentPosition(t) & 16);
49
- }
50
- function $t() {
51
- const e = g(!0), t = g(() => e.current);
52
- return C(() => (e.current = !0, () => {
53
- e.current = !1;
54
- }), []), t.current;
55
- }
56
- function Wt(e) {
57
- const t = g(e);
58
- return t.current = e, t;
59
- }
60
- function jt(e) {
61
- const t = Wt(e);
62
- C(() => () => t.current(), []);
63
- }
64
- function Gt(e) {
65
- const t = g(null);
66
- return C(() => {
67
- t.current = e;
68
- }), t.current;
69
- }
70
- function _t(e) {
71
- const t = g(e);
72
- return C(() => {
73
- t.current = e;
74
- }, [e]), t;
75
- }
76
- function F(e) {
77
- const t = _t(e);
78
- return R(function(...n) {
79
- return t.current && t.current(...n);
80
- }, [t]);
81
- }
82
- const Ht = "data-rr-ui-";
83
- function Ut(e) {
84
- return `${Ht}${e}`;
85
- }
86
- function Kt(e = document) {
87
- const t = e.defaultView;
88
- return Math.abs(t.innerWidth - e.documentElement.clientWidth);
89
- }
90
- const Ke = Ut("modal-open");
91
- class Ae {
92
- constructor({
93
- ownerDocument: t,
94
- handleContainerOverflow: n = !0,
95
- isRTL: r = !1
96
- } = {}) {
97
- this.handleContainerOverflow = n, this.isRTL = r, this.modals = [], this.ownerDocument = t;
98
- }
99
- getScrollbarWidth() {
100
- return Kt(this.ownerDocument);
101
- }
102
- getElement() {
103
- return (this.ownerDocument || document).body;
104
- }
105
- setModalAttributes(t) {
106
- }
107
- removeModalAttributes(t) {
108
- }
109
- setContainerStyle(t) {
110
- const n = {
111
- overflow: "hidden"
112
- }, r = this.isRTL ? "paddingLeft" : "paddingRight", o = this.getElement();
113
- t.style = {
114
- overflow: o.style.overflow,
115
- [r]: o.style[r]
116
- }, t.scrollBarWidth && (n[r] = `${parseInt(ne(o, r) || "0", 10) + t.scrollBarWidth}px`), o.setAttribute(Ke, ""), ne(o, n);
117
- }
118
- reset() {
119
- [...this.modals].forEach((t) => this.remove(t));
120
- }
121
- removeContainerStyle(t) {
122
- const n = this.getElement();
123
- n.removeAttribute(Ke), Object.assign(n.style, t.style);
124
- }
125
- add(t) {
126
- let n = this.modals.indexOf(t);
127
- return n !== -1 || (n = this.modals.length, this.modals.push(t), this.setModalAttributes(t), n !== 0) || (this.state = {
128
- scrollBarWidth: this.getScrollbarWidth(),
129
- style: {}
130
- }, this.handleContainerOverflow && this.setContainerStyle(this.state)), n;
131
- }
132
- remove(t) {
133
- const n = this.modals.indexOf(t);
134
- n !== -1 && (this.modals.splice(n, 1), !this.modals.length && this.handleContainerOverflow && this.removeContainerStyle(this.state), this.removeModalAttributes(t));
135
- }
136
- isTopModal(t) {
137
- return !!this.modals.length && this.modals[this.modals.length - 1] === t;
138
- }
139
- }
140
- const Je = /* @__PURE__ */ mt(re ? window : void 0);
141
- Je.Provider;
142
- function Le() {
143
- return Xe(Je);
144
- }
145
- const we = (e, t) => re ? e == null ? (t || Be()).body : (typeof e == "function" && (e = e()), e && "current" in e && (e = e.current), e && ("nodeType" in e || e.getBoundingClientRect) ? e : null) : null;
146
- function qt(e, t) {
147
- const n = Le(), [r, o] = D(() => we(e, n == null ? void 0 : n.document));
148
- if (!r) {
149
- const s = we(e);
150
- s && o(s);
151
- }
152
- return C(() => {
153
- }, [t, r]), C(() => {
154
- const s = we(e);
155
- s !== r && o(s);
156
- }, [e, r]), r;
157
- }
158
- const qe = (e) => !e || typeof e == "function" ? e : (t) => {
159
- e.current = t;
160
- };
161
- function Vt(e, t) {
162
- const n = qe(e), r = qe(t);
163
- return (o) => {
164
- n && n(o), r && r(o);
165
- };
166
- }
167
- function Ie(e, t) {
168
- return Ye(() => Vt(e, t), [e, t]);
169
- }
170
- const zt = typeof global < "u" && // @ts-ignore
171
- global.navigator && // @ts-ignore
172
- global.navigator.product === "ReactNative", Pt = typeof document < "u", Ve = Pt || zt ? ht : C;
173
- function Xt({
174
- children: e,
175
- in: t,
176
- onExited: n,
177
- mountOnEnter: r,
178
- unmountOnExit: o
179
- }) {
180
- const s = g(null), f = g(t), m = F(n);
181
- C(() => {
182
- t ? f.current = !0 : m(s.current);
183
- }, [t, m]);
184
- const c = Ie(s, pe(e)), d = /* @__PURE__ */ ke(e, {
185
- ref: c
186
- });
187
- return t ? d : o || !f.current && r ? null : d;
188
- }
189
- const Yt = ["onEnter", "onEntering", "onEntered", "onExit", "onExiting", "onExited", "addEndListener", "children"];
190
- function Jt(e, t) {
191
- if (e == null) return {};
192
- var n = {};
193
- for (var r in e) if ({}.hasOwnProperty.call(e, r)) {
194
- if (t.indexOf(r) >= 0) continue;
195
- n[r] = e[r];
196
- }
197
- return n;
198
- }
199
- function Qt(e) {
200
- let {
201
- onEnter: t,
202
- onEntering: n,
203
- onEntered: r,
204
- onExit: o,
205
- onExiting: s,
206
- onExited: f,
207
- addEndListener: m,
208
- children: c
209
- } = e, d = Jt(e, Yt);
210
- const i = g(null), T = Ie(i, pe(c)), p = (S) => (L) => {
211
- S && i.current && S(i.current, L);
212
- }, O = R(p(t), [t]), A = R(p(n), [n]), $ = R(p(r), [r]), P = R(p(o), [o]), x = R(p(s), [s]), X = R(p(f), [f]), W = R(p(m), [m]);
213
- return Object.assign({}, d, {
214
- nodeRef: i
215
- }, t && {
216
- onEnter: O
217
- }, n && {
218
- onEntering: A
219
- }, r && {
220
- onEntered: $
221
- }, o && {
222
- onExit: P
223
- }, s && {
224
- onExiting: x
225
- }, f && {
226
- onExited: X
227
- }, m && {
228
- addEndListener: W
229
- }, {
230
- children: typeof c == "function" ? (S, L) => (
231
- // TODO: Types for RTG missing innerProps, so need to cast.
232
- c(S, Object.assign({}, L, {
233
- ref: T
234
- }))
235
- ) : /* @__PURE__ */ ke(c, {
236
- ref: T
237
- })
238
- });
239
- }
240
- const Zt = ["component"];
241
- function en(e, t) {
242
- if (e == null) return {};
243
- var n = {};
244
- for (var r in e) if ({}.hasOwnProperty.call(e, r)) {
245
- if (t.indexOf(r) >= 0) continue;
246
- n[r] = e[r];
247
- }
248
- return n;
249
- }
250
- const tn = /* @__PURE__ */ b.forwardRef((e, t) => {
251
- let {
252
- component: n
253
- } = e, r = en(e, Zt);
254
- const o = Qt(r);
255
- return /* @__PURE__ */ a(n, Object.assign({
256
- ref: t
257
- }, o));
258
- });
259
- function nn({
260
- in: e,
261
- onTransition: t
262
- }) {
263
- const n = g(null), r = g(!0), o = F(t);
264
- return Ve(() => {
265
- if (!n.current)
266
- return;
267
- let s = !1;
268
- return o({
269
- in: e,
270
- element: n.current,
271
- initial: r.current,
272
- isStale: () => s
273
- }), () => {
274
- s = !0;
275
- };
276
- }, [e, o]), Ve(() => (r.current = !1, () => {
277
- r.current = !0;
278
- }), []), n;
279
- }
280
- function rn({
281
- children: e,
282
- in: t,
283
- onExited: n,
284
- onEntered: r,
285
- transition: o
286
- }) {
287
- const [s, f] = D(!t);
288
- t && s && f(!1);
289
- const m = nn({
290
- in: !!t,
291
- onTransition: (d) => {
292
- const i = () => {
293
- d.isStale() || (d.in ? r == null || r(d.element, d.initial) : (f(!0), n == null || n(d.element)));
294
- };
295
- Promise.resolve(o(d)).then(i, (T) => {
296
- throw d.in || f(!0), T;
297
- });
298
- }
299
- }), c = Ie(m, pe(e));
300
- return s && !t ? null : /* @__PURE__ */ ke(e, {
301
- ref: c
302
- });
303
- }
304
- function ze(e, t, n) {
305
- return e ? /* @__PURE__ */ a(tn, Object.assign({}, n, {
306
- component: e
307
- })) : t ? /* @__PURE__ */ a(rn, Object.assign({}, n, {
308
- transition: t
309
- })) : /* @__PURE__ */ a(Xt, Object.assign({}, n));
310
- }
311
- const on = ["show", "role", "className", "style", "children", "backdrop", "keyboard", "onBackdropClick", "onEscapeKeyDown", "transition", "runTransition", "backdropTransition", "runBackdropTransition", "autoFocus", "enforceFocus", "restoreFocus", "restoreFocusOptions", "renderDialog", "renderBackdrop", "manager", "container", "onShow", "onHide", "onExit", "onExited", "onExiting", "onEnter", "onEntering", "onEntered"];
312
- function sn(e, t) {
313
- if (e == null) return {};
314
- var n = {};
315
- for (var r in e) if ({}.hasOwnProperty.call(e, r)) {
316
- if (t.indexOf(r) >= 0) continue;
317
- n[r] = e[r];
318
- }
319
- return n;
320
- }
321
- let Me;
322
- function an(e) {
323
- return Me || (Me = new Ae({
324
- ownerDocument: e == null ? void 0 : e.document
325
- })), Me;
326
- }
327
- function ln(e) {
328
- const t = Le(), n = e || an(t), r = g({
329
- dialog: null,
330
- backdrop: null
331
- });
332
- return Object.assign(r.current, {
333
- add: () => n.add(r.current),
334
- remove: () => n.remove(r.current),
335
- isTopModal: () => n.isTopModal(r.current),
336
- setDialogRef: R((o) => {
337
- r.current.dialog = o;
338
- }, []),
339
- setBackdropRef: R((o) => {
340
- r.current.backdrop = o;
341
- }, [])
342
- });
343
- }
344
- const Qe = /* @__PURE__ */ gt((e, t) => {
345
- let {
346
- show: n = !1,
347
- role: r = "dialog",
348
- className: o,
349
- style: s,
350
- children: f,
351
- backdrop: m = !0,
352
- keyboard: c = !0,
353
- onBackdropClick: d,
354
- onEscapeKeyDown: i,
355
- transition: T,
356
- runTransition: p,
357
- backdropTransition: O,
358
- runBackdropTransition: A,
359
- autoFocus: $ = !0,
360
- enforceFocus: P = !0,
361
- restoreFocus: x = !0,
362
- restoreFocusOptions: X,
363
- renderDialog: W,
364
- renderBackdrop: S = (u) => /* @__PURE__ */ a("div", Object.assign({}, u)),
365
- manager: L,
366
- container: Ee,
367
- onShow: oe,
368
- onHide: Y = () => {
369
- },
370
- onExit: ye,
371
- onExited: J,
372
- onExiting: se,
373
- onEnter: ae,
374
- onEntering: ie,
375
- onEntered: le
376
- } = e, ve = sn(e, on);
377
- const k = Le(), j = qt(Ee), E = ln(L), be = $t(), ce = Gt(n), [I, G] = D(!n), M = g(null);
378
- pt(t, () => E, [E]), re && !ce && n && (M.current = Ne(k == null ? void 0 : k.document)), n && I && G(!1);
379
- const B = F(() => {
380
- if (E.add(), _.current = Ge(document, "keydown", Te), Z.current = Ge(
381
- document,
382
- "focus",
383
- // the timeout is necessary b/c this will run before the new modal is mounted
384
- // and so steals focus from it
385
- () => setTimeout(Re),
386
- !0
387
- ), oe && oe(), $) {
388
- var u, fe;
389
- const te = Ne((u = (fe = E.dialog) == null ? void 0 : fe.ownerDocument) != null ? u : k == null ? void 0 : k.document);
390
- E.dialog && te && !Ue(E.dialog, te) && (M.current = te, E.dialog.focus());
391
- }
392
- }), Q = F(() => {
393
- if (E.remove(), _.current == null || _.current(), Z.current == null || Z.current(), x) {
394
- var u;
395
- (u = M.current) == null || u.focus == null || u.focus(X), M.current = null;
396
- }
397
- });
398
- C(() => {
399
- !n || !j || B();
400
- }, [
401
- n,
402
- j,
403
- /* should never change: */
404
- B
405
- ]), C(() => {
406
- I && Q();
407
- }, [I, Q]), jt(() => {
408
- Q();
409
- });
410
- const Re = F(() => {
411
- if (!P || !be() || !E.isTopModal())
412
- return;
413
- const u = Ne(k == null ? void 0 : k.document);
414
- E.dialog && u && !Ue(E.dialog, u) && E.dialog.focus();
415
- }), de = F((u) => {
416
- u.target === u.currentTarget && (d == null || d(u), m === !0 && Y());
417
- }), Te = F((u) => {
418
- c && Et(u) && E.isTopModal() && (i == null || i(u), u.defaultPrevented || Y());
419
- }), Z = g(), _ = g(), ue = (...u) => {
420
- G(!0), J == null || J(...u);
421
- };
422
- if (!j)
423
- return null;
424
- const H = Object.assign({
425
- role: r,
426
- ref: E.setDialogRef,
427
- // apparently only works on the dialog role element
428
- "aria-modal": r === "dialog" ? !0 : void 0
429
- }, ve, {
430
- style: s,
431
- className: o,
432
- tabIndex: -1
433
- });
434
- let ee = W ? W(H) : /* @__PURE__ */ a("div", Object.assign({}, H, {
435
- children: /* @__PURE__ */ b.cloneElement(f, {
436
- role: "document"
437
- })
438
- }));
439
- ee = ze(T, p, {
440
- unmountOnExit: !0,
441
- mountOnEnter: !0,
442
- appear: !0,
443
- in: !!n,
444
- onExit: ye,
445
- onExiting: se,
446
- onExited: ue,
447
- onEnter: ae,
448
- onEntering: ie,
449
- onEntered: le,
450
- children: ee
451
- });
452
- let U = null;
453
- return m && (U = S({
454
- ref: E.setBackdropRef,
455
- onClick: de
456
- }), U = ze(O, A, {
457
- in: !!n,
458
- appear: !0,
459
- mountOnEnter: !0,
460
- unmountOnExit: !0,
461
- children: U
462
- })), /* @__PURE__ */ a(xe, {
463
- children: /* @__PURE__ */ At.createPortal(/* @__PURE__ */ N(xe, {
464
- children: [U, ee]
465
- }), j)
466
- });
467
- });
468
- Qe.displayName = "Modal";
469
- const cn = Object.assign(Qe, {
470
- Manager: Ae
471
- });
472
- function dn(e, t) {
473
- return e.classList ? e.classList.contains(t) : (" " + (e.className.baseVal || e.className) + " ").indexOf(" " + t + " ") !== -1;
474
- }
475
- function un(e, t) {
476
- e.classList ? e.classList.add(t) : dn(e, t) || (typeof e.className == "string" ? e.className = e.className + " " + t : e.setAttribute("class", (e.className && e.className.baseVal || "") + " " + t));
477
- }
478
- var fn = Function.prototype.bind.call(Function.prototype.call, [].slice);
479
- function q(e, t) {
480
- return fn(e.querySelectorAll(t));
481
- }
482
- function Pe(e, t) {
483
- return e.replace(new RegExp("(^|\\s)" + t + "(?:\\s|$)", "g"), "$1").replace(/\s+/g, " ").replace(/^\s*|\s*$/g, "");
484
- }
485
- function mn(e, t) {
486
- e.classList ? e.classList.remove(t) : typeof e.className == "string" ? e.className = Pe(e.className, t) : e.setAttribute("class", Pe(e.className && e.className.baseVal || "", t));
487
- }
488
- const V = {
489
- FIXED_CONTENT: ".fixed-top, .fixed-bottom, .is-fixed, .sticky-top",
490
- STICKY_CONTENT: ".sticky-top",
491
- NAVBAR_TOGGLER: ".navbar-toggler"
492
- };
493
- class hn extends Ae {
494
- adjustAndStore(t, n, r) {
495
- const o = n.style[t];
496
- n.dataset[t] = o, ne(n, {
497
- [t]: `${parseFloat(ne(n, t)) + r}px`
498
- });
499
- }
500
- restore(t, n) {
501
- const r = n.dataset[t];
502
- r !== void 0 && (delete n.dataset[t], ne(n, {
503
- [t]: r
504
- }));
505
- }
506
- setContainerStyle(t) {
507
- super.setContainerStyle(t);
508
- const n = this.getElement();
509
- if (un(n, "modal-open"), !t.scrollBarWidth) return;
510
- const r = this.isRTL ? "paddingLeft" : "paddingRight", o = this.isRTL ? "marginLeft" : "marginRight";
511
- q(n, V.FIXED_CONTENT).forEach((s) => this.adjustAndStore(r, s, t.scrollBarWidth)), q(n, V.STICKY_CONTENT).forEach((s) => this.adjustAndStore(o, s, -t.scrollBarWidth)), q(n, V.NAVBAR_TOGGLER).forEach((s) => this.adjustAndStore(o, s, t.scrollBarWidth));
512
- }
513
- removeContainerStyle(t) {
514
- super.removeContainerStyle(t);
515
- const n = this.getElement();
516
- mn(n, "modal-open");
517
- const r = this.isRTL ? "paddingLeft" : "paddingRight", o = this.isRTL ? "marginLeft" : "marginRight";
518
- q(n, V.FIXED_CONTENT).forEach((s) => this.restore(r, s)), q(n, V.STICKY_CONTENT).forEach((s) => this.restore(o, s)), q(n, V.NAVBAR_TOGGLER).forEach((s) => this.restore(o, s));
519
- }
520
- }
521
- let Oe;
522
- function gn(e) {
523
- return Oe || (Oe = new hn(e)), Oe;
524
- }
525
- const pn = {
526
- [Tt]: "show",
527
- [Rt]: "show"
528
- }, Fe = /* @__PURE__ */ b.forwardRef(({
529
- className: e,
530
- children: t,
531
- transitionClasses: n = {},
532
- onEnter: r,
533
- ...o
534
- }, s) => {
535
- const f = {
536
- in: !1,
537
- timeout: 300,
538
- mountOnEnter: !1,
539
- unmountOnExit: !1,
540
- appear: !1,
541
- ...o
542
- }, m = R((c, d) => {
543
- yt(c), r == null || r(c, d);
544
- }, [r]);
545
- return /* @__PURE__ */ a(vt, {
546
- ref: s,
547
- addEndListener: bt,
548
- ...f,
549
- onEnter: m,
550
- childRef: pe(t),
551
- children: (c, d) => /* @__PURE__ */ b.cloneElement(t, {
552
- ...d,
553
- className: w("fade", e, t.props.className, pn[c], n[c])
554
- })
555
- });
556
- });
557
- Fe.displayName = "Fade";
558
- const Ze = /* @__PURE__ */ b.forwardRef(({
559
- className: e,
560
- bsPrefix: t,
561
- as: n = "div",
562
- ...r
563
- }, o) => (t = z(t, "modal-body"), /* @__PURE__ */ a(n, {
564
- ref: o,
565
- className: w(e, t),
566
- ...r
567
- })));
568
- Ze.displayName = "ModalBody";
569
- const et = /* @__PURE__ */ b.createContext({
570
- onHide() {
571
- }
572
- }), De = /* @__PURE__ */ b.forwardRef(({
573
- bsPrefix: e,
574
- className: t,
575
- contentClassName: n,
576
- centered: r,
577
- size: o,
578
- fullscreen: s,
579
- children: f,
580
- scrollable: m,
581
- ...c
582
- }, d) => {
583
- e = z(e, "modal");
584
- const i = `${e}-dialog`, T = typeof s == "string" ? `${e}-fullscreen-${s}` : `${e}-fullscreen`;
585
- return /* @__PURE__ */ a("div", {
586
- ...c,
587
- ref: d,
588
- className: w(i, t, o && `${e}-${o}`, r && `${i}-centered`, m && `${i}-scrollable`, s && T),
589
- children: /* @__PURE__ */ a("div", {
590
- className: w(`${e}-content`, n),
591
- children: f
592
- })
593
- });
594
- });
595
- De.displayName = "ModalDialog";
596
- const tt = /* @__PURE__ */ b.forwardRef(({
597
- className: e,
598
- bsPrefix: t,
599
- as: n = "div",
600
- ...r
601
- }, o) => (t = z(t, "modal-footer"), /* @__PURE__ */ a(n, {
602
- ref: o,
603
- className: w(e, t),
604
- ...r
605
- })));
606
- tt.displayName = "ModalFooter";
607
- const En = {
608
- /** An accessible label indicating the relevant information about the Close Button. */
609
- "aria-label": Ce.string,
610
- /** A callback fired after the Close Button is clicked. */
611
- onClick: Ce.func,
612
- /**
613
- * Render different color variant for the button.
614
- *
615
- * Omitting this will render the default dark color.
616
- */
617
- variant: Ce.oneOf(["white"])
618
- }, $e = /* @__PURE__ */ b.forwardRef(({
619
- className: e,
620
- variant: t,
621
- "aria-label": n = "Close",
622
- ...r
623
- }, o) => /* @__PURE__ */ a("button", {
624
- ref: o,
625
- type: "button",
626
- className: w("btn-close", t && `btn-close-${t}`, e),
627
- "aria-label": n,
628
- ...r
629
- }));
630
- $e.displayName = "CloseButton";
631
- $e.propTypes = En;
632
- const nt = /* @__PURE__ */ b.forwardRef(({
633
- closeLabel: e = "Close",
634
- closeVariant: t,
635
- closeButton: n = !1,
636
- onHide: r,
637
- children: o,
638
- ...s
639
- }, f) => {
640
- const m = Xe(et), c = Se(() => {
641
- m == null || m.onHide(), r == null || r();
642
- });
643
- return /* @__PURE__ */ N("div", {
644
- ref: f,
645
- ...s,
646
- children: [o, n && /* @__PURE__ */ a($e, {
647
- "aria-label": e,
648
- variant: t,
649
- onClick: c
650
- })]
651
- });
652
- });
653
- nt.displayName = "AbstractModalHeader";
654
- const rt = /* @__PURE__ */ b.forwardRef(({
655
- bsPrefix: e,
656
- className: t,
657
- closeLabel: n = "Close",
658
- closeButton: r = !1,
659
- ...o
660
- }, s) => (e = z(e, "modal-header"), /* @__PURE__ */ a(nt, {
661
- ref: s,
662
- ...o,
663
- className: w(t, e),
664
- closeLabel: n,
665
- closeButton: r
666
- })));
667
- rt.displayName = "ModalHeader";
668
- const yn = (e) => (
669
- // eslint-disable-next-line react/display-name
670
- /* @__PURE__ */ b.forwardRef((t, n) => /* @__PURE__ */ a("div", {
671
- ...t,
672
- ref: n,
673
- className: w(t.className, e)
674
- }))
675
- ), vn = yn("h4"), ot = /* @__PURE__ */ b.forwardRef(({
676
- className: e,
677
- bsPrefix: t,
678
- as: n = vn,
679
- ...r
680
- }, o) => (t = z(t, "modal-title"), /* @__PURE__ */ a(n, {
681
- ref: o,
682
- className: w(e, t),
683
- ...r
684
- })));
685
- ot.displayName = "ModalTitle";
686
- function bn(e) {
687
- return /* @__PURE__ */ a(Fe, {
688
- ...e,
689
- timeout: null
690
- });
691
- }
692
- function Rn(e) {
693
- return /* @__PURE__ */ a(Fe, {
694
- ...e,
695
- timeout: null
696
- });
697
- }
698
- const st = /* @__PURE__ */ b.forwardRef(({
699
- bsPrefix: e,
700
- className: t,
701
- style: n,
702
- dialogClassName: r,
703
- contentClassName: o,
704
- children: s,
705
- dialogAs: f = De,
706
- "data-bs-theme": m,
707
- "aria-labelledby": c,
708
- "aria-describedby": d,
709
- "aria-label": i,
710
- /* BaseModal props */
711
- show: T = !1,
712
- animation: p = !0,
713
- backdrop: O = !0,
714
- keyboard: A = !0,
715
- onEscapeKeyDown: $,
716
- onShow: P,
717
- onHide: x,
718
- container: X,
719
- autoFocus: W = !0,
720
- enforceFocus: S = !0,
721
- restoreFocus: L = !0,
722
- restoreFocusOptions: Ee,
723
- onEntered: oe,
724
- onExit: Y,
725
- onExiting: ye,
726
- onEnter: J,
727
- onEntering: se,
728
- onExited: ae,
729
- backdropClassName: ie,
730
- manager: le,
731
- ...ve
732
- }, k) => {
733
- const [j, E] = D({}), [be, ce] = D(!1), I = g(!1), G = g(!1), M = g(null), [B, Q] = Lt(), Re = Ct(k, Q), de = Se(x), Te = Nt();
734
- e = z(e, "modal");
735
- const Z = Ye(() => ({
736
- onHide: de
737
- }), [de]);
738
- function _() {
739
- return le || gn({
740
- isRTL: Te
741
- });
742
- }
743
- function ue(l) {
744
- if (!re) return;
745
- const K = _().getScrollbarWidth() > 0, je = l.scrollHeight > Be(l).documentElement.clientHeight;
746
- E({
747
- paddingRight: K && !je ? He() : void 0,
748
- paddingLeft: !K && je ? He() : void 0
749
- });
750
- }
751
- const H = Se(() => {
752
- B && ue(B.dialog);
753
- });
754
- Dt(() => {
755
- _e(window, "resize", H), M.current == null || M.current();
756
- });
757
- const ee = () => {
758
- I.current = !0;
759
- }, U = (l) => {
760
- I.current && B && l.target === B.dialog && (G.current = !0), I.current = !1;
761
- }, u = () => {
762
- ce(!0), M.current = Mt(B.dialog, () => {
763
- ce(!1);
764
- });
765
- }, fe = (l) => {
766
- l.target === l.currentTarget && u();
767
- }, te = (l) => {
768
- if (O === "static") {
769
- fe(l);
770
- return;
771
- }
772
- if (G.current || l.target !== l.currentTarget) {
773
- G.current = !1;
774
- return;
775
- }
776
- x == null || x();
777
- }, at = (l) => {
778
- A ? $ == null || $(l) : (l.preventDefault(), O === "static" && u());
779
- }, it = (l, K) => {
780
- l && ue(l), J == null || J(l, K);
781
- }, lt = (l) => {
782
- M.current == null || M.current(), Y == null || Y(l);
783
- }, ct = (l, K) => {
784
- se == null || se(l, K), wt(window, "resize", H);
785
- }, dt = (l) => {
786
- l && (l.style.display = ""), ae == null || ae(l), _e(window, "resize", H);
787
- }, ut = R((l) => /* @__PURE__ */ a("div", {
788
- ...l,
789
- className: w(`${e}-backdrop`, ie, !p && "show")
790
- }), [p, ie, e]), We = {
791
- ...n,
792
- ...j
793
- };
794
- We.display = "block";
795
- const ft = (l) => /* @__PURE__ */ a("div", {
796
- role: "dialog",
797
- ...l,
798
- style: We,
799
- className: w(t, e, be && `${e}-static`, !p && "show"),
800
- onClick: O ? te : void 0,
801
- onMouseUp: U,
802
- "data-bs-theme": m,
803
- "aria-label": i,
804
- "aria-labelledby": c,
805
- "aria-describedby": d,
806
- children: /* @__PURE__ */ a(f, {
807
- ...ve,
808
- onMouseDown: ee,
809
- className: r,
810
- contentClassName: o,
811
- children: s
812
- })
813
- });
814
- return /* @__PURE__ */ a(et.Provider, {
815
- value: Z,
816
- children: /* @__PURE__ */ a(cn, {
817
- show: T,
818
- ref: Re,
819
- backdrop: O,
820
- container: X,
821
- keyboard: !0,
822
- autoFocus: W,
823
- enforceFocus: S,
824
- restoreFocus: L,
825
- restoreFocusOptions: Ee,
826
- onEscapeKeyDown: at,
827
- onShow: P,
828
- onHide: x,
829
- onEnter: it,
830
- onEntering: ct,
831
- onEntered: oe,
832
- onExit: lt,
833
- onExiting: ye,
834
- onExited: dt,
835
- manager: _(),
836
- transition: p ? bn : void 0,
837
- backdropTransition: p ? Rn : void 0,
838
- renderBackdrop: ut,
839
- renderDialog: ft
840
- })
841
- });
842
- });
843
- st.displayName = "Modal";
844
- const ge = Object.assign(st, {
845
- Body: Ze,
846
- Header: rt,
847
- Title: ot,
848
- Footer: tt,
849
- Dialog: De,
850
- TRANSITION_DURATION: 300,
851
- BACKDROP_TRANSITION_DURATION: 150
852
- }), Tn = "qhCFp", Cn = "b5DbC", Nn = "As4TB", wn = "_7Sbgn", Mn = "rNiD8", On = "WvNbK", y = {
853
- title: Tn,
854
- formGroup: Cn,
855
- optIn: Nn,
856
- submit: wn,
857
- error: Mn,
858
- success: On
859
- }, An = ({ messageModalOpen: e, setMessageModalOpen: t, selectedLocation: n, locale: r }) => {
860
- const { t: o } = Ot("default"), [s, f] = D(!1), m = /^((\\+[1-9]{1,4}[ \\-]*)|(\\([0-9]{2,3}\\)[ \\-]*)|([0-9]{2,4})[ \\-]*)*?[0-9]{3,4}?[ \\-]*[0-9]{3,4}?$/, c = xt({
861
- name: me().required(o("message.validation.name")),
862
- email: me().email(o("message.validation.email")).required(o("message.validation.email")),
863
- phone: me().matches(m, "Phone number is not valid"),
864
- message: me().required(o("message.validation.message")),
865
- optIn: St().oneOf([!0], o("message.validation.optIn"))
866
- }), i = kt({
867
- initialValues: {
868
- name: "",
869
- email: "",
870
- phone: "",
871
- message: "",
872
- optIn: !1
873
- },
874
- validationSchema: c,
875
- onSubmit: async (O) => {
876
- await new Promise((A) => setTimeout(A, 1e3)), f(!0);
877
- }
878
- }), T = () => {
879
- t(!1), f(!1), i.resetForm();
880
- }, p = document.querySelector(".cc") || null;
881
- return /* @__PURE__ */ N(ge, { container: p, show: e, onHide: T, children: [
882
- /* @__PURE__ */ a(ge.Header, { closeButton: !0, children: /* @__PURE__ */ N(ge.Title, { className: v(y.title), children: [
883
- o("message.title"),
884
- " ",
885
- n == null ? void 0 : n.retailer_name
886
- ] }) }),
887
- /* @__PURE__ */ a(ge.Body, { children: /* @__PURE__ */ N(h, { onSubmit: i.handleSubmit, children: [
888
- /* @__PURE__ */ N(h.Group, { className: v(y.formGroup), children: [
889
- /* @__PURE__ */ a(h.Label, { children: o("message.name") }),
890
- /* @__PURE__ */ a(h.Control, { type: "text", name: "name", value: i.values.name, onChange: i.handleChange }),
891
- i.errors.name && i.touched.name && /* @__PURE__ */ a(h.Text, { className: v(y.error), children: i.errors.name })
892
- ] }),
893
- /* @__PURE__ */ N(h.Group, { className: v(y.formGroup), children: [
894
- /* @__PURE__ */ a(h.Label, { children: o("message.email") }),
895
- /* @__PURE__ */ a(h.Control, { type: "email", name: "email", value: i.values.email, onChange: i.handleChange }),
896
- i.errors.email && /* @__PURE__ */ a(h.Text, { className: v(y.error), children: i.errors.email })
897
- ] }),
898
- /* @__PURE__ */ N(h.Group, { className: v(y.formGroup), children: [
899
- /* @__PURE__ */ a(h.Label, { children: o("message.phone") }),
900
- /* @__PURE__ */ a(h.Control, { type: "tel", name: "phone", value: i.values.phone, onChange: i.handleChange }),
901
- i.errors.phone && /* @__PURE__ */ a(h.Text, { className: v(y.error), children: i.errors.phone })
902
- ] }),
903
- /* @__PURE__ */ N(h.Group, { className: v(y.formGroup), children: [
904
- /* @__PURE__ */ a(h.Label, { children: o("message.message") }),
905
- /* @__PURE__ */ a(h.Control, { as: "textarea", name: "message", value: i.values.message, onChange: i.handleChange }),
906
- i.errors.message && /* @__PURE__ */ a(h.Text, { className: v(y.error), children: i.errors.message })
907
- ] }),
908
- /* @__PURE__ */ N(h.Group, { className: v(y.formGroup, y.optIn), children: [
909
- /* @__PURE__ */ a(h.Check, { type: "checkbox", name: "optIn", label: o("message.optIn"), checked: i.values.optIn, onChange: i.handleChange }),
910
- i.errors.optIn && /* @__PURE__ */ a(h.Text, { className: v(y.error), children: i.errors.optIn })
911
- ] }),
912
- /* @__PURE__ */ N(Bt, { className: v(y.submit), type: "submit", disabled: i.isSubmitting || s, children: [
913
- !s && /* @__PURE__ */ a(xe, { children: i.isSubmitting ? o("message.sending") : o("message.send") }),
914
- s && o("message.sent"),
915
- i.isSubmitting && /* @__PURE__ */ a("img", { src: "https://images.sofasandsectionals.com/cc/pal-loader.svg", alt: "Loading", width: 20, height: 20 })
916
- ] }),
917
- /* @__PURE__ */ a(h.Text, { className: v(y.success), children: s && o("message.success") }),
918
- /* @__PURE__ */ a(h.Text, { className: v(y.error), children: i.errors.general })
919
- ] }) })
920
- ] });
921
- };
922
- export {
923
- nt as A,
924
- cn as B,
925
- Fe as F,
926
- An as M,
927
- et as a,
928
- hn as b,
929
- yn as d,
930
- gn as g,
931
- Se as u
932
- };