@fanfare-io/fanfare-sdk-react 0.21.0 → 0.23.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.
- package/README.md +12 -0
- package/dist/components/checkout/card-brand.d.ts +2 -0
- package/dist/components/checkout/checkout-processing-panel.d.ts +2 -1
- package/dist/components/checkout/payment-collection-panel.d.ts +3 -3
- package/dist/components/checkout/payment-method-list.d.ts +18 -0
- package/dist/components/checkout/receipt-panel.d.ts +4 -3
- package/dist/components/primitives/countdown.d.ts +53 -14
- package/dist/components/primitives/spinner.d.ts +5 -0
- package/dist/components/widgets/experience-widget.d.ts +23 -0
- package/dist/components/widgets/internal/auction-ledger.d.ts +1 -12
- package/dist/components/widgets/internal/selection-branches.d.ts +0 -2
- package/dist/index-DbLojDF1.js +8337 -0
- package/dist/index.js +4 -4
- package/dist/stripe-card-field-DIxqCt1r.js +186 -0
- package/dist/styles/base.css +1 -1
- package/dist/styles/index.d.ts +0 -1
- package/dist/styles/theme.css +583 -1
- package/dist/theme/font-loader.d.ts +58 -0
- package/dist/theme/theme-context.d.ts +8 -0
- package/package.json +6 -7
- package/dist/index-DWJSw9N8.js +0 -7861
- package/dist/stripe-card-field-CPZoyAm1.js +0 -170
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsxs as E, Fragment as F, jsx as g } from "react/jsx-runtime";
|
|
3
|
-
import * as r from "react";
|
|
4
|
-
import { createPortal as M } from "react-dom";
|
|
5
|
-
import { u as B, a as D, d as N, S as I, B as O, g as _ } from "./index-DWJSw9N8.js";
|
|
6
|
-
const j = [
|
|
7
|
-
"--ff-color-foreground",
|
|
8
|
-
"--ff-font-sans",
|
|
9
|
-
"--ff-color-muted-foreground",
|
|
10
|
-
"--ff-color-danger"
|
|
11
|
-
], H = [
|
|
12
|
-
"ar",
|
|
13
|
-
"bg",
|
|
14
|
-
"cs",
|
|
15
|
-
"da",
|
|
16
|
-
"de",
|
|
17
|
-
"el",
|
|
18
|
-
"en",
|
|
19
|
-
"en-AU",
|
|
20
|
-
"en-CA",
|
|
21
|
-
"en-NZ",
|
|
22
|
-
"en-GB",
|
|
23
|
-
"es",
|
|
24
|
-
"es-ES",
|
|
25
|
-
"es-419",
|
|
26
|
-
"et",
|
|
27
|
-
"fi",
|
|
28
|
-
"fil",
|
|
29
|
-
"fr",
|
|
30
|
-
"fr-CA",
|
|
31
|
-
"fr-FR",
|
|
32
|
-
"he",
|
|
33
|
-
"hu",
|
|
34
|
-
"hr",
|
|
35
|
-
"id",
|
|
36
|
-
"it",
|
|
37
|
-
"it-IT",
|
|
38
|
-
"ja",
|
|
39
|
-
"ko",
|
|
40
|
-
"lt",
|
|
41
|
-
"lv",
|
|
42
|
-
"ms",
|
|
43
|
-
"mt",
|
|
44
|
-
"nb",
|
|
45
|
-
"nl",
|
|
46
|
-
"no",
|
|
47
|
-
"pl",
|
|
48
|
-
"pt",
|
|
49
|
-
"pt-BR",
|
|
50
|
-
"ro",
|
|
51
|
-
"ru",
|
|
52
|
-
"sk",
|
|
53
|
-
"sl",
|
|
54
|
-
"sv",
|
|
55
|
-
"th",
|
|
56
|
-
"tr",
|
|
57
|
-
"vi",
|
|
58
|
-
"zh",
|
|
59
|
-
"zh-HK",
|
|
60
|
-
"zh-TW"
|
|
61
|
-
];
|
|
62
|
-
function $(a) {
|
|
63
|
-
return H.find((u) => u === a) ?? "auto";
|
|
64
|
-
}
|
|
65
|
-
function K(a, u) {
|
|
66
|
-
let l = a;
|
|
67
|
-
for (; l; ) {
|
|
68
|
-
const c = getComputedStyle(l).getPropertyValue(u).trim();
|
|
69
|
-
if (c) return c;
|
|
70
|
-
if (l.parentElement) {
|
|
71
|
-
l = l.parentElement;
|
|
72
|
-
continue;
|
|
73
|
-
}
|
|
74
|
-
const m = l.getRootNode();
|
|
75
|
-
l = m instanceof ShadowRoot && m.host instanceof HTMLElement ? m.host : null;
|
|
76
|
-
}
|
|
77
|
-
return "";
|
|
78
|
-
}
|
|
79
|
-
function Y(a) {
|
|
80
|
-
return a.isConnected ? a.ownerDocument.body : null;
|
|
81
|
-
}
|
|
82
|
-
function X({ config: a, onController: u, onChange: l }) {
|
|
83
|
-
const { t: c, locale: m } = B(), k = D(), p = r.useRef(null), w = r.useRef(null), C = r.useRef(null), [n, b] = r.useState(null), [R, h] = r.useState("loading"), [T, A] = r.useState(0), f = r.useRef(u), L = r.useRef(l), P = r.useRef(c);
|
|
84
|
-
r.useEffect(() => {
|
|
85
|
-
f.current = u, L.current = l, P.current = c;
|
|
86
|
-
});
|
|
87
|
-
const { publishableKey: S, stripeAccount: x } = a, z = $(m);
|
|
88
|
-
r.useEffect(() => {
|
|
89
|
-
const e = p.current, o = e ? Y(e) : null;
|
|
90
|
-
if (!o) {
|
|
91
|
-
h("unsupported"), f.current(null);
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
const t = document.createElement("div");
|
|
95
|
-
return t.dataset.fanfareField = "stripe-card-portal", t.style.position = "absolute", t.style.zIndex = "1000", o.appendChild(t), b(t), () => {
|
|
96
|
-
t.remove(), b(null);
|
|
97
|
-
};
|
|
98
|
-
}, []);
|
|
99
|
-
const s = r.useCallback(() => {
|
|
100
|
-
const e = p.current, o = w.current;
|
|
101
|
-
if (!e || !n) return;
|
|
102
|
-
const t = e.getBoundingClientRect();
|
|
103
|
-
if (n.style.left = `${t.left + window.scrollX}px`, n.style.top = `${t.top + window.scrollY}px`, n.style.width = `${t.width}px`, !!o)
|
|
104
|
-
for (const v of j) {
|
|
105
|
-
const i = K(e, v);
|
|
106
|
-
i ? o.style.setProperty(v, i) : o.style.removeProperty(v);
|
|
107
|
-
}
|
|
108
|
-
}, [n]);
|
|
109
|
-
return r.useEffect(() => {
|
|
110
|
-
if (!n) return;
|
|
111
|
-
s(), window.addEventListener("resize", s), window.addEventListener("scroll", s, !0);
|
|
112
|
-
const e = typeof ResizeObserver > "u" ? null : new ResizeObserver(s);
|
|
113
|
-
return e && p.current && e.observe(p.current), () => {
|
|
114
|
-
window.removeEventListener("resize", s), window.removeEventListener("scroll", s, !0), e?.disconnect();
|
|
115
|
-
};
|
|
116
|
-
}, [n, R, s]), r.useLayoutEffect(() => {
|
|
117
|
-
s();
|
|
118
|
-
}), r.useEffect(() => {
|
|
119
|
-
if (!n) return;
|
|
120
|
-
const e = w.current;
|
|
121
|
-
if (!e) return;
|
|
122
|
-
if (n.getRootNode() !== n.ownerDocument || e.getRootNode() !== e.ownerDocument) {
|
|
123
|
-
h("unsupported"), f.current(null);
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
let o = !1, t = null;
|
|
127
|
-
return h("loading"), s(), (async () => {
|
|
128
|
-
let i;
|
|
129
|
-
try {
|
|
130
|
-
i = await _(x ? { publishableKey: S, stripeAccount: x } : { publishableKey: S });
|
|
131
|
-
} catch {
|
|
132
|
-
if (o) return;
|
|
133
|
-
h("failed"), f.current(null);
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
if (o) return;
|
|
137
|
-
const y = i.elements({ locale: z }).create("card", { style: N(e) });
|
|
138
|
-
t = y, C.current = y, y.on("change", (d) => {
|
|
139
|
-
L.current?.({ complete: d.complete, errorMessage: d.error?.message ?? null });
|
|
140
|
-
}), y.mount(e), h("ready"), f.current({
|
|
141
|
-
createPaymentMethod: async () => {
|
|
142
|
-
const d = await i.createPaymentMethod({ type: "card", card: y });
|
|
143
|
-
if (d.error) throw new Error(d.error.message ?? P.current("checkout.error.generic"));
|
|
144
|
-
return d.paymentMethod.id;
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
})(), () => {
|
|
148
|
-
o = !0, t && (t.off("change"), t.unmount(), t.destroy()), C.current = null, f.current(null);
|
|
149
|
-
};
|
|
150
|
-
}, [n, S, x, z, T, s]), r.useEffect(() => {
|
|
151
|
-
const e = C.current, o = w.current;
|
|
152
|
-
!e || !o || (s(), e.update({ style: N(o) }));
|
|
153
|
-
}, [k, s]), /* @__PURE__ */ E(F, { children: [
|
|
154
|
-
/* @__PURE__ */ E("div", { ref: p, "data-fanfare-field": "stripe-card-anchor", className: "ff:min-h-10", children: [
|
|
155
|
-
R === "loading" ? /* @__PURE__ */ E("span", { className: "ff:flex ff:items-center ff:gap-2 ff:text-sm ff:text-muted", children: [
|
|
156
|
-
/* @__PURE__ */ g(I, { size: "sm" }),
|
|
157
|
-
c("checkout.newCard.loading")
|
|
158
|
-
] }) : null,
|
|
159
|
-
R === "unsupported" ? /* @__PURE__ */ g("p", { role: "status", className: "ff:text-sm ff:text-muted", children: c("checkout.newCard.unavailable") }) : null,
|
|
160
|
-
R === "failed" ? /* @__PURE__ */ E("div", { role: "alert", className: "ff:flex ff:flex-col ff:items-start ff:gap-2", children: [
|
|
161
|
-
/* @__PURE__ */ g("p", { className: "ff:text-sm ff:text-danger", children: c("checkout.newCard.loadFailed") }),
|
|
162
|
-
/* @__PURE__ */ g(O, { type: "button", variant: "outline", size: "sm", onClick: () => A((e) => e + 1), children: c("checkout.newCard.reload") })
|
|
163
|
-
] }) : null
|
|
164
|
-
] }),
|
|
165
|
-
n ? M(/* @__PURE__ */ g("div", { ref: w, "data-fanfare-field": "stripe-card" }), n) : null
|
|
166
|
-
] });
|
|
167
|
-
}
|
|
168
|
-
export {
|
|
169
|
-
X as StripeCardField
|
|
170
|
-
};
|