@zerohash-sdk/crypto-buy-react 1.7.0 → 1.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.
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { CryptoBuyFilters } from '@zerohash-sdk/crypto-buy';
1
2
  import { default as default_2 } from 'react';
2
3
 
3
4
  /**
@@ -111,6 +112,23 @@ declare interface CryptoBuyProps {
111
112
  * ```
112
113
  */
113
114
  theme?: Theme;
115
+ /**
116
+ * Optional filters that narrow the list of assets shown in the widget.
117
+ *
118
+ * - `getAssets.stablecoin`: pass `false` to hide stablecoins, `true` to show
119
+ * only stablecoins, or omit to include both.
120
+ * - `getAssets.deposit_address_creation`: restrict assets by their deposit
121
+ * address creation policy.
122
+ *
123
+ * @example
124
+ * ```tsx
125
+ * <CryptoBuy
126
+ * jwt={token}
127
+ * filters={{ getAssets: { stablecoin: false } }}
128
+ * />
129
+ * ```
130
+ */
131
+ filters?: CryptoBuyFilters;
114
132
  /**
115
133
  * Callback invoked when the crypto sell flow is successfully completed.
116
134
  *
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { jsxs as W, jsx as y } from "react/jsx-runtime";
1
+ import { jsxs as W, jsx as b } from "react/jsx-runtime";
2
2
  import j, { useEffect as A, useState as z, useCallback as D, useRef as M } from "react";
3
3
  const $ = {
4
4
  dev: "https://grafana-faro-collector.dev.0hash.com/collect",
@@ -91,49 +91,49 @@ const $ = {
91
91
  } catch {
92
92
  }
93
93
  }, Z = (e) => {
94
- const { webComponentTag: t, appName: o, appVersion: r, scriptUrls: a, fallbackScriptUrls: i, collectorUrls: c, env: n, jwt: s, timeoutMs: u = 15e3, onLoad: b, onError: m } = e;
94
+ const { webComponentTag: t, appName: o, appVersion: r, scriptUrls: a, fallbackScriptUrls: i, collectorUrls: c, env: n, jwt: s, timeoutMs: m = 15e3, onLoad: g, onError: h } = e;
95
95
  if (typeof document > "u")
96
96
  return x;
97
- const g = `${t}-script-${n}`;
98
- if (customElements.get(t) || document.getElementById(g))
97
+ const d = `${t}-script-${n}`;
98
+ if (customElements.get(t) || document.getElementById(d))
99
99
  return x;
100
- const S = P(s), v = e.report ?? ((d) => G(c && J(c, n, s), d, r));
100
+ const S = P(s), v = e.report ?? ((p) => G(c && J(c, n, s), p, r));
101
101
  let f = !1, w = 0, C;
102
102
  const R = () => {
103
103
  C !== void 0 && clearTimeout(C);
104
- }, k = (d, h, l) => {
104
+ }, k = (p, y, l) => {
105
105
  if (f)
106
106
  return;
107
107
  const U = Math.round(performance.now() - w), T = {
108
108
  webComponentTag: t,
109
109
  appName: o,
110
110
  env: n,
111
- scriptUrl: h,
112
- reason: d,
111
+ scriptUrl: y,
112
+ reason: p,
113
113
  triedFallback: l,
114
114
  elapsedMs: U,
115
115
  claims: S
116
116
  };
117
117
  v(T);
118
118
  const O = l ? void 0 : L(i ?? {}, n, s);
119
- if (O && O !== h) {
119
+ if (O && O !== y) {
120
120
  E(O, !0);
121
121
  return;
122
122
  }
123
- f = !0, R(), document.getElementById(g)?.remove(), m?.(T);
124
- }, E = (d, h) => {
123
+ f = !0, R(), document.getElementById(d)?.remove(), h?.(T);
124
+ }, E = (p, y) => {
125
125
  R(), w = performance.now();
126
126
  const l = document.createElement("script");
127
- l.id = g, l.src = d, l.type = "module", l.async = !0, l.onload = () => {
127
+ l.id = d, l.src = p, l.type = "module", l.async = !0, l.onload = () => {
128
128
  setTimeout(() => {
129
- f || (customElements.get(t) ? (f = !0, R(), b?.()) : k("not-defined", d, h));
129
+ f || (customElements.get(t) ? (f = !0, R(), g?.()) : k("not-defined", p, y));
130
130
  }, 0);
131
- }, l.onerror = () => k("network", d, h), C = setTimeout(() => k("timeout", d, h), u), document.getElementById(g)?.remove(), document.head.appendChild(l);
131
+ }, l.onerror = () => k("network", p, y), C = setTimeout(() => k("timeout", p, y), m), document.getElementById(d)?.remove(), document.head.appendChild(l);
132
132
  }, N = L(a, n, s);
133
133
  return N ? (E(N, !1), () => {
134
134
  f = !0, R();
135
135
  }) : x;
136
- }, p = {
136
+ }, u = {
137
137
  local: "http://localhost:5173",
138
138
  dev: "https://sdk-cdn.dev.0hash.com",
139
139
  cert: "https://sdk-cdn.cert.zerohash.com",
@@ -141,13 +141,13 @@ const $ = {
141
141
  "eu-cert": "https://sdk-cdn.cert.zerohash.eu",
142
142
  "eu-prod": "https://sdk-cdn.zerohash.eu"
143
143
  }, q = (e, t, o = {}) => {
144
- const { eu: r = !1, legacyAliases: a = !1, local: i = p.local } = o, c = (s) => `${s}/${e}/${t}`, n = {
144
+ const { eu: r = !1, legacyAliases: a = !1, local: i = u.local } = o, c = (s) => `${s}/${e}/${t}`, n = {
145
145
  local: c(i),
146
- dev: c(p.dev),
147
- cert: c(p.cert),
148
- prod: c(p.prod)
146
+ dev: c(u.dev),
147
+ cert: c(u.cert),
148
+ prod: c(u.prod)
149
149
  };
150
- return a && (n.sandbox = c(p.cert), n.production = c(p.prod)), r && (n["eu-cert"] = c(p["eu-cert"]), n["eu-prod"] = c(p["eu-prod"])), n;
150
+ return a && (n.sandbox = c(u.cert), n.production = c(u.prod)), r && (n["eu-cert"] = c(u["eu-cert"]), n["eu-prod"] = c(u["eu-prod"])), n;
151
151
  };
152
152
  var F;
153
153
  (function(e) {
@@ -172,7 +172,7 @@ const _ = {
172
172
  background: "#FFFFFF",
173
173
  border: `1px solid ${_.grayLight}`,
174
174
  borderRadius: "12px"
175
- }, children: [y("svg", { width: "32", height: "32", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: y("path", { d: "M12 9v4m0 4h.01M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z", stroke: _.evergreen, strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }), y("p", { style: { margin: 0, fontSize: "16px", fontWeight: 600 }, children: "Something went wrong" }), y("p", { style: { margin: 0, fontSize: "14px", opacity: 0.75 }, children: "We couldn't load this content. Please check your internet connection and try again." }), y("button", { type: "button", onClick: e, style: {
175
+ }, children: [b("svg", { width: "32", height: "32", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: b("path", { d: "M12 9v4m0 4h.01M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z", stroke: _.evergreen, strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }), b("p", { style: { margin: 0, fontSize: "16px", fontWeight: 600 }, children: "Something went wrong" }), b("p", { style: { margin: 0, fontSize: "14px", opacity: 0.75 }, children: "We couldn't load this content. Please check your internet connection and try again." }), b("button", { type: "button", onClick: e, style: {
176
176
  marginTop: "8px",
177
177
  padding: "8px 20px",
178
178
  fontSize: "14px",
@@ -191,8 +191,8 @@ const _ = {
191
191
  a !== void 0 && (o[r] = a);
192
192
  });
193
193
  }, Y = (e) => {
194
- const { webComponentTag: t, appName: o, appVersion: r, scriptUrls: a, fallbackScriptUrls: i, collectorUrls: c, env: n, jwt: s, timeoutMs: u } = e, [b, m] = z(!1), [g, S] = z(0);
195
- A(() => (m(!1), Z({
194
+ const { webComponentTag: t, appName: o, appVersion: r, scriptUrls: a, fallbackScriptUrls: i, collectorUrls: c, env: n, jwt: s, timeoutMs: m } = e, [g, h] = z(!1), [d, S] = z(0);
195
+ A(() => (h(!1), Z({
196
196
  webComponentTag: t,
197
197
  appName: o ?? t,
198
198
  appVersion: r,
@@ -201,8 +201,8 @@ const _ = {
201
201
  collectorUrls: c ?? $,
202
202
  env: n,
203
203
  jwt: s,
204
- timeoutMs: u,
205
- onError: () => m(!0)
204
+ timeoutMs: m,
205
+ onError: () => h(!0)
206
206
  })), [
207
207
  t,
208
208
  o,
@@ -212,36 +212,38 @@ const _ = {
212
212
  c,
213
213
  n,
214
214
  s,
215
- u,
216
- g
215
+ m,
216
+ d
217
217
  ]);
218
218
  const v = D(() => S((f) => f + 1), []);
219
- return { loadFailed: b, retry: v };
219
+ return { loadFailed: g, retry: v };
220
220
  }, ee = q("crypto-buy-web", "index.js"), B = "zerohash-crypto-buy", re = ({
221
221
  jwt: e,
222
222
  env: t = "prod",
223
223
  theme: o,
224
- onCompleted: r,
225
- onError: a,
226
- onClose: i,
227
- onLoaded: c,
228
- onEvent: n,
229
- ...s
224
+ filters: r,
225
+ onCompleted: a,
226
+ onError: i,
227
+ onClose: c,
228
+ onLoaded: n,
229
+ onEvent: s,
230
+ ...m
230
231
  }) => {
231
- const u = M(null);
232
- X(u, { theme: o, onCompleted: r, onError: a, onClose: i, onLoaded: c, onEvent: n });
233
- const { loadFailed: b, retry: m } = Y({
232
+ const g = M(null);
233
+ X(g, { theme: o, filters: r, onCompleted: a, onError: i, onClose: c, onLoaded: n, onEvent: s });
234
+ const { loadFailed: h, retry: d } = Y({
234
235
  webComponentTag: B,
235
236
  scriptUrls: ee,
236
237
  env: t,
237
238
  jwt: e
238
239
  });
239
- return b ? /* @__PURE__ */ y(Q, { onRetry: m }) : j.createElement(B, {
240
- ref: u,
240
+ return h ? /* @__PURE__ */ b(Q, { onRetry: d }) : j.createElement(B, {
241
+ ref: g,
241
242
  jwt: e,
242
243
  env: t,
243
244
  theme: o,
244
- ...s
245
+ filters: r,
246
+ ...m
245
247
  });
246
248
  };
247
249
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zerohash-sdk/crypto-buy-react",
3
- "version": "1.7.0",
3
+ "version": "1.9.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",