@coinbase/cdp-react 0.0.85 → 0.0.86

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,57 +1,58 @@
1
- import { jsx as o, jsxs as a, Fragment as d } from "react/jsx-runtime";
2
- import { useIsInitialized as O, useCurrentUser as B, useInitiateMfaEnrollment as P, useSubmitMfaEnrollment as b, useRecordMfaEnrollmentPrompted as D } from "@coinbase/cdp-hooks";
3
- import { u as $ } from "../../chunks/useSendComponentCallOnce.BHZMuo6E.js";
4
- import { useMemo as k, useRef as p, useEffect as L, useCallback as E, useLayoutEffect as V } from "react";
5
- import { c as j } from "../../chunks/lite.1fxw3LjI.js";
6
- import { u as z } from "../../chunks/CDPReactProvider.CIQm4C4z.js";
7
- import { isApiError as J } from "../../utils/isApiError.js";
1
+ import { jsx as o, jsxs as a, Fragment as E } from "react/jsx-runtime";
2
+ import { useIsInitialized as B, useCurrentUser as P, useInitiateMfaEnrollment as b, useSubmitMfaEnrollment as D, useRecordMfaEnrollmentPrompted as $ } from "@coinbase/cdp-hooks";
3
+ import { u as k } from "../../chunks/useSendComponentCallOnce.BHZMuo6E.js";
4
+ import { useMemo as V, useRef as p, useEffect as R, useCallback as d, useLayoutEffect as j } from "react";
5
+ import { c as z } from "../../chunks/lite.1fxw3LjI.js";
6
+ import { u as J } from "../../chunks/CDPReactProvider.CIQm4C4z.js";
7
+ import { useTimeout as K } from "../../hooks/useTimeout.js";
8
+ import { isApiError as q } from "../../utils/isApiError.js";
8
9
  import "libphonenumber-js";
9
- import { EnrollMfaDescription as R } from "./EnrollMfaDescription.js";
10
- import { EnrollMfaFlow as K } from "./EnrollMfaFlow.js";
11
- import { EnrollMfaFlowBackButton as q } from "./EnrollMfaFlowBackButton.js";
12
- import { EnrollMfaFlowProvider as G } from "./EnrollMfaFlowProvider.js";
13
- import { useEnrollMfaFlow as ge } from "./EnrollMfaFlowProvider.js";
14
- import { EnrollMfaFooter as X } from "./EnrollMfaFooter.js";
15
- import { EnrollMfaImage as Y } from "./EnrollMfaImage.js";
16
- import { EnrollMfaItem as Re } from "./EnrollMfaItem.js";
17
- import { EnrollMfaItems as Ce } from "./EnrollMfaItems.js";
18
- import { EnrollMfaProvider as Z, useEnrollMfaContext as C } from "./EnrollMfaProvider.js";
19
- import { EnrollMfaTitle as x } from "./EnrollMfaTitle.js";
20
- import { Banner as H } from "../ui/Banner/index.js";
21
- import '../../assets/EnrollMfa.css';const Q = "EnrollMfa-module__img___JmjV1", W = "EnrollMfa-module__centered___YxB8I", ee = "EnrollMfa-module__footer___Zro3u", l = {
10
+ import { EnrollMfaDescription as x } from "./EnrollMfaDescription.js";
11
+ import { EnrollMfaFlow as G } from "./EnrollMfaFlow.js";
12
+ import { EnrollMfaFlowBackButton as X } from "./EnrollMfaFlowBackButton.js";
13
+ import { EnrollMfaFlowProvider as Y } from "./EnrollMfaFlowProvider.js";
14
+ import { useEnrollMfaFlow as xe } from "./EnrollMfaFlowProvider.js";
15
+ import { EnrollMfaFooter as Z } from "./EnrollMfaFooter.js";
16
+ import { EnrollMfaImage as H } from "./EnrollMfaImage.js";
17
+ import { EnrollMfaItem as Ue } from "./EnrollMfaItem.js";
18
+ import { EnrollMfaItems as Fe } from "./EnrollMfaItems.js";
19
+ import { EnrollMfaProvider as Q, useEnrollMfaContext as U } from "./EnrollMfaProvider.js";
20
+ import { EnrollMfaTitle as C } from "./EnrollMfaTitle.js";
21
+ import { Banner as W } from "../ui/Banner/index.js";
22
+ import '../../assets/EnrollMfa.css';const ee = "EnrollMfa-module__img___JmjV1", te = "EnrollMfa-module__centered___YxB8I", re = "EnrollMfa-module__footer___Zro3u", l = {
22
23
  "mfa-enrollment": "EnrollMfa-module__mfa-enrollment___80xnL",
23
- img: Q,
24
+ img: ee,
24
25
  "flex-container": "EnrollMfa-module__flex-container___9Dazs",
25
26
  "gap-2": "EnrollMfa-module__gap-2___BKEqR",
26
27
  "gap-3": "EnrollMfa-module__gap-3___JKVyF",
27
- centered: W,
28
- footer: ee
29
- }, te = 5 * 60 * 1e3, re = ({ role: c = "alert", ...i }) => {
30
- const { state: s } = C(), { error: m } = s;
31
- return m ? /* @__PURE__ */ o(H, { variant: "error", role: c, ...i, children: J(m) ? m.message : m }) : null;
32
- }, oe = ({
28
+ centered: te,
29
+ footer: re
30
+ }, oe = 5 * 60 * 1e3, ne = ({ role: c = "alert", ...i }) => {
31
+ const { state: s } = U(), { error: m } = s;
32
+ return m ? /* @__PURE__ */ o(W, { variant: "error", role: c, ...i, children: q(m) ? m.message : m }) : null;
33
+ }, le = ({
33
34
  className: c = "",
34
35
  children: i,
35
36
  resetOnSuccess: s = !0,
36
37
  ...m
37
38
  }) => {
38
- const { isInitialized: f } = O(), { currentUser: u } = B(), { state: e, dispatch: n, onEnrollSuccess: _ } = C(), { initiateMfaEnrollment: M } = P(), { submitMfaEnrollment: h } = b(), { recordMfaEnrollmentPrompted: I } = D(), { showCoinbaseFooter: U } = z(), N = p(!1);
39
- L(() => {
39
+ const { isInitialized: f } = B(), { currentUser: u } = P(), { state: e, dispatch: n, onEnrollSuccess: _ } = U(), { initiateMfaEnrollment: M } = b(), { submitMfaEnrollment: h } = D(), { recordMfaEnrollmentPrompted: I } = $(), { showCoinbaseFooter: v } = J(), N = p(!1);
40
+ R(() => {
40
41
  !f || !u || N.current || (I(), N.current = !0);
41
- }, [I, f, u]), L(() => {
42
+ }, [I, f, u]), R(() => {
42
43
  if (!e.initiatedAt) return;
43
44
  const t = () => {
44
- e.initiatedAt && Date.now() - e.initiatedAt >= te && n({ type: "ENROLLMENT_SESSION_EXPIRED" });
45
+ e.initiatedAt && Date.now() - e.initiatedAt >= oe && n({ type: "ENROLLMENT_SESSION_EXPIRED" });
45
46
  };
46
47
  t();
47
48
  const r = setInterval(t, 1e3);
48
49
  return () => clearInterval(r);
49
50
  }, [e.initiatedAt, n]);
50
- const S = p(e.step), T = p(null), y = E((t) => {
51
+ const S = p(e.step), T = p(null), { schedule: y } = K(), g = d((t) => {
51
52
  S.current !== t && (S.current = t, T.current?.transition.toggle(t));
52
- }, []), v = E(() => {
53
+ }, []), F = d(() => {
53
54
  n({ type: "GO_TO_PREVIOUS_STEP" });
54
- }, [n]), F = E(
55
+ }, [n]), w = d(
55
56
  async (t) => {
56
57
  if (f) {
57
58
  n({ type: "INITIATE_ENROLLMENT", payload: { method: t } });
@@ -75,14 +76,14 @@ import '../../assets/EnrollMfa.css';const Q = "EnrollMfa-module__img___JmjV1", W
75
76
  }
76
77
  },
77
78
  [n, M, f]
78
- ), w = E(
79
+ ), A = d(
79
80
  async (t) => {
80
81
  t.preventDefault(), n({ type: "SUBMIT_ENROLLMENT" });
81
82
  try {
82
83
  await h({
83
84
  mfaMethod: e.method,
84
85
  mfaCode: e.mfaCode
85
- }), n({ type: "SUBMIT_ENROLLMENT_SUCCESS" }), _?.(), s && setTimeout(() => {
86
+ }), n({ type: "SUBMIT_ENROLLMENT_SUCCESS" }), _?.(), s && y(() => {
86
87
  n({ type: "SET_STEP", payload: { step: "list", flowDirection: "left" } });
87
88
  }, 800);
88
89
  } catch (r) {
@@ -94,41 +95,49 @@ import '../../assets/EnrollMfa.css';const Q = "EnrollMfa-module__img___JmjV1", W
94
95
  });
95
96
  }
96
97
  },
97
- [n, e.method, e.mfaCode, h, _, s]
98
+ [
99
+ n,
100
+ e.method,
101
+ e.mfaCode,
102
+ h,
103
+ _,
104
+ s,
105
+ y
106
+ ]
98
107
  );
99
- V(() => {
100
- y(e.step);
101
- }, [e.step, y]);
102
- const g = typeof i == "function" ? i(e) : i;
108
+ j(() => {
109
+ g(e.step);
110
+ }, [e.step, g]);
111
+ const L = typeof i == "function" ? i(e) : i;
103
112
  return /* @__PURE__ */ o(
104
- G,
113
+ Y,
105
114
  {
106
- onBack: v,
107
- onStartEnrollment: F,
108
- onSubmit: w,
115
+ onBack: F,
116
+ onStartEnrollment: w,
117
+ onSubmit: A,
109
118
  transitionRef: T,
110
119
  children: /* @__PURE__ */ a("div", { className: `${l["mfa-enrollment"]} ${c}`, ...m, children: [
111
- g,
112
- !g && /* @__PURE__ */ a(d, { children: [
120
+ L,
121
+ !L && /* @__PURE__ */ a(E, { children: [
113
122
  /* @__PURE__ */ a(
114
123
  "div",
115
124
  {
116
- className: j(
125
+ className: z(
117
126
  l["flex-container"],
118
127
  e.step === "list" ? l["gap-3"] : ""
119
128
  ),
120
129
  children: [
121
- e.step === "list" ? /* @__PURE__ */ a(d, { children: [
130
+ e.step === "list" ? /* @__PURE__ */ a(E, { children: [
122
131
  /* @__PURE__ */ a("div", { children: [
123
- /* @__PURE__ */ o(x, { step: "list", method: e.method }),
124
- /* @__PURE__ */ o(R, { step: "list", method: e.method })
132
+ /* @__PURE__ */ o(C, { step: "list", method: e.method }),
133
+ /* @__PURE__ */ o(x, { step: "list", method: e.method })
125
134
  ] }),
126
- /* @__PURE__ */ o(re, {})
127
- ] }) : /* @__PURE__ */ o("div", { children: /* @__PURE__ */ o(q, { step: e.step }) }),
128
- /* @__PURE__ */ o(K, { children: ({ step: t, method: r, Content: A }) => /* @__PURE__ */ a("div", { className: `${l["flex-container"]} ${l["gap-2"]}`, children: [
129
- t !== "list" && /* @__PURE__ */ a(d, { children: [
135
+ /* @__PURE__ */ o(ne, {})
136
+ ] }) : /* @__PURE__ */ o("div", { children: /* @__PURE__ */ o(X, { step: e.step }) }),
137
+ /* @__PURE__ */ o(G, { children: ({ step: t, method: r, Content: O }) => /* @__PURE__ */ a("div", { className: `${l["flex-container"]} ${l["gap-2"]}`, children: [
138
+ t !== "list" && /* @__PURE__ */ a(E, { children: [
130
139
  /* @__PURE__ */ o(
131
- Y,
140
+ H,
132
141
  {
133
142
  className: `${l.img} ${l.centered}`,
134
143
  step: t,
@@ -136,36 +145,36 @@ import '../../assets/EnrollMfa.css';const Q = "EnrollMfa-module__img___JmjV1", W
136
145
  }
137
146
  ),
138
147
  /* @__PURE__ */ a("div", { className: l.centered, children: [
139
- /* @__PURE__ */ o(x, { step: t, method: r }),
140
- /* @__PURE__ */ o(R, { step: t, method: r })
148
+ /* @__PURE__ */ o(C, { step: t, method: r }),
149
+ /* @__PURE__ */ o(x, { step: t, method: r })
141
150
  ] })
142
151
  ] }),
143
- A
152
+ O
144
153
  ] }) })
145
154
  ]
146
155
  }
147
156
  ),
148
- U && /* @__PURE__ */ o(X, { className: l.footer })
157
+ v && /* @__PURE__ */ o(Z, { className: l.footer })
149
158
  ] })
150
159
  ] })
151
160
  }
152
161
  );
153
- }, Se = ({ onEnrollSuccess: c, ...i }) => {
154
- $("enroll_mfa");
155
- const s = k(() => ["totp"], []);
156
- return /* @__PURE__ */ o(Z, { methods: s, onEnrollSuccess: c, children: /* @__PURE__ */ o(oe, { ...i }) });
162
+ }, ge = ({ onEnrollSuccess: c, ...i }) => {
163
+ k("enroll_mfa");
164
+ const s = V(() => ["totp"], []);
165
+ return /* @__PURE__ */ o(Q, { methods: s, onEnrollSuccess: c, children: /* @__PURE__ */ o(le, { ...i }) });
157
166
  };
158
167
  export {
159
- Se as EnrollMfa,
160
- R as EnrollMfaDescription,
161
- re as EnrollMfaError,
162
- K as EnrollMfaFlow,
163
- q as EnrollMfaFlowBackButton,
164
- X as EnrollMfaFooter,
165
- Y as EnrollMfaImage,
166
- Re as EnrollMfaItem,
167
- Ce as EnrollMfaItems,
168
- x as EnrollMfaTitle,
169
- C as useEnrollMfaContext,
170
- ge as useEnrollMfaFlow
168
+ ge as EnrollMfa,
169
+ x as EnrollMfaDescription,
170
+ ne as EnrollMfaError,
171
+ G as EnrollMfaFlow,
172
+ X as EnrollMfaFlowBackButton,
173
+ Z as EnrollMfaFooter,
174
+ H as EnrollMfaImage,
175
+ Ue as EnrollMfaItem,
176
+ Fe as EnrollMfaItems,
177
+ C as EnrollMfaTitle,
178
+ U as useEnrollMfaContext,
179
+ xe as useEnrollMfaFlow
171
180
  };
@@ -1,93 +1,92 @@
1
- import { jsx as r, jsxs as h, Fragment as w } from "react/jsx-runtime";
2
- import { useLinkOAuth as C } from "@coinbase/cdp-hooks";
3
- import { u as I } from "../../chunks/useSendComponentCallOnce.BHZMuo6E.js";
4
- import { useRef as d, useState as N, useCallback as u } from "react";
1
+ import { jsx as r, jsxs as h, Fragment as C } from "react/jsx-runtime";
2
+ import { useLinkOAuth as I } from "@coinbase/cdp-hooks";
3
+ import { u as N } from "../../chunks/useSendComponentCallOnce.BHZMuo6E.js";
4
+ import { useRef as d, useState as P, useCallback as a } from "react";
5
5
  import "../../chunks/CDPReactProvider.CIQm4C4z.js";
6
- import { useOauthStatusModal as P } from "../OAuthStatusModal/index.js";
7
- import { Banner as U } from "../ui/Banner/index.js";
8
- import { getMessageFromUnknownError as D } from "../../utils/getMessageFromUnknownError.js";
6
+ import { useOauthStatusModal as U } from "../OAuthStatusModal/index.js";
7
+ import { Banner as D } from "../ui/Banner/index.js";
8
+ import { useTimeout as H } from "../../hooks/useTimeout.js";
9
+ import { getMessageFromUnknownError as M } from "../../utils/getMessageFromUnknownError.js";
9
10
  import "libphonenumber-js";
10
- import { toOAuthProviderType as H } from "../../utils/toOAuthProviderType.js";
11
- import { L as M, a as v } from "../../chunks/LinkAuthFlow.BaUSMzGH.js";
12
- import { u as mt } from "../../chunks/LinkAuthFlow.BaUSMzGH.js";
13
- import { LinkAuthFlowBackButton as V } from "./LinkAuthFlowBackButton.js";
14
- import { LinkAuthItem as dt } from "./LinkAuthItem.js";
15
- import { LinkAuthItems as ft } from "./LinkAuthItems.js";
16
- import { useLinkAuthContext as y, LinkAuthProvider as j } from "./LinkAuthProvider.js";
17
- import { LinkAuthTitle as K } from "./LinkAuthTitle.js";
18
- import { methodToView as g } from "./utils.js";
19
- import '../../assets/LinkAuth.css';const W = "LinkAuth-module__header___0UuxP", $ = "LinkAuth-module__error___XUo4W", k = {
11
+ import { toOAuthProviderType as v } from "../../utils/toOAuthProviderType.js";
12
+ import { L as V, a as j } from "../../chunks/LinkAuthFlow.BaUSMzGH.js";
13
+ import { u as kt } from "../../chunks/LinkAuthFlow.BaUSMzGH.js";
14
+ import { LinkAuthFlowBackButton as K } from "./LinkAuthFlowBackButton.js";
15
+ import { LinkAuthItem as pt } from "./LinkAuthItem.js";
16
+ import { LinkAuthItems as At } from "./LinkAuthItems.js";
17
+ import { useLinkAuthContext as O, LinkAuthProvider as W } from "./LinkAuthProvider.js";
18
+ import { LinkAuthTitle as $ } from "./LinkAuthTitle.js";
19
+ import { methodToView as y } from "./utils.js";
20
+ import '../../assets/LinkAuth.css';const b = "LinkAuth-module__header___0UuxP", G = "LinkAuth-module__error___XUo4W", k = {
20
21
  "link-auth": "LinkAuth-module__link-auth___kPJao",
21
- header: W,
22
- error: $
23
- }, b = ({ role: o = "alert", ...c }) => {
24
- const { state: i } = y(), { error: s } = i;
25
- return s ? /* @__PURE__ */ r(U, { variant: "error", role: o, ...c, children: s }) : null;
26
- }, G = ({ children: o, className: c = "", onLinkSuccess: i, ...s }) => {
27
- const { linkOAuth: f } = C(), { persistOAuthState: p } = P(), { state: a, dispatch: n } = y(), { methodToLink: O } = a, L = d(null), l = d(null), x = g(O), A = d(x), [E, m] = N("left"), e = u(
22
+ header: b,
23
+ error: G
24
+ }, J = ({ role: o = "alert", ...c }) => {
25
+ const { state: i } = O(), { error: s } = i;
26
+ return s ? /* @__PURE__ */ r(D, { variant: "error", role: o, ...c, children: s }) : null;
27
+ }, X = ({ children: o, className: c = "", onLinkSuccess: i, ...s }) => {
28
+ const { linkOAuth: f } = I(), { persistOAuthState: p } = U(), { state: u, dispatch: n } = O(), { methodToLink: x } = u, L = d(null), l = d(null), { schedule: A } = H(), E = y(x), _ = d(E), [B, m] = P("left"), e = a(
28
29
  (t) => {
29
- A.current !== t && (A.current = t, L.current?.transition.toggle(t), t === "list" && n({ type: "RESET_STATE" }), (t === "email" || t === "sms") && n({ type: "LINK_AUTH_METHOD", payload: { method: t } }));
30
+ _.current !== t && (_.current = t, L.current?.transition.toggle(t), t === "list" && n({ type: "RESET_STATE" }), (t === "email" || t === "sms") && n({ type: "LINK_AUTH_METHOD", payload: { method: t } }));
30
31
  },
31
32
  [n]
32
- ), B = u(() => {
33
+ ), F = a(() => {
33
34
  if (m("right"), l.current?.canGoBack) {
34
35
  l.current.goBack();
35
36
  return;
36
37
  }
37
38
  e("list");
38
- }, [e]), F = u(() => {
39
- m("left"), i?.(a.methodToLink), setTimeout(() => {
40
- e("list");
41
- }, 800);
42
- }, [e, a.methodToLink, i]), R = u(
39
+ }, [e]), R = a(() => {
40
+ m("left"), i?.(u.methodToLink), A(() => e("list"), 800);
41
+ }, [e, u.methodToLink, i, A]), S = a(
43
42
  async (t) => {
44
43
  if (m("left"), t?.startsWith("oauth:")) {
45
- const T = H(t);
46
- if (T)
44
+ const g = v(t);
45
+ if (g)
47
46
  try {
48
- await f(T), p(!0);
49
- } catch (S) {
47
+ await f(g), p(!0);
48
+ } catch (w) {
50
49
  n({
51
50
  type: "LINK_AUTH_METHOD_ERROR",
52
- payload: { error: D(S) }
51
+ payload: { error: M(w) }
53
52
  });
54
53
  }
55
54
  } else
56
- e(g(t));
55
+ e(y(t));
57
56
  },
58
57
  [f, e, p, n]
59
- ), _ = typeof o == "function" ? o(a) : o;
58
+ ), T = typeof o == "function" ? o(u) : o;
60
59
  return /* @__PURE__ */ r("div", { className: `${k["link-auth"]} ${c}`, ...s, children: /* @__PURE__ */ h(
61
- M,
60
+ V,
62
61
  {
63
- direction: E,
64
- onBack: B,
65
- onLink: R,
66
- onLinkSuccess: F,
62
+ direction: B,
63
+ onBack: F,
64
+ onLink: S,
65
+ onLinkSuccess: R,
67
66
  signInRef: l,
68
67
  transitionRef: L,
69
68
  children: [
70
- _,
71
- !_ && /* @__PURE__ */ h(w, { children: [
69
+ T,
70
+ !T && /* @__PURE__ */ h(C, { children: [
72
71
  /* @__PURE__ */ h("div", { className: k.header, children: [
73
- /* @__PURE__ */ r(K, {}),
74
- /* @__PURE__ */ r(V, {})
72
+ /* @__PURE__ */ r($, {}),
73
+ /* @__PURE__ */ r(K, {})
75
74
  ] }),
76
- /* @__PURE__ */ r("div", { className: k.error, children: /* @__PURE__ */ r(b, {}) }),
77
- /* @__PURE__ */ r(v, {})
75
+ /* @__PURE__ */ r("div", { className: k.error, children: /* @__PURE__ */ r(J, {}) }),
76
+ /* @__PURE__ */ r(j, {})
78
77
  ] })
79
78
  ]
80
79
  }
81
80
  ) });
82
- }, ut = (o) => (I("manage_auth"), /* @__PURE__ */ r(j, { children: /* @__PURE__ */ r(G, { ...o }) }));
81
+ }, mt = (o) => (N("manage_auth"), /* @__PURE__ */ r(W, { children: /* @__PURE__ */ r(X, { ...o }) }));
83
82
  export {
84
- ut as LinkAuth,
85
- b as LinkAuthError,
86
- v as LinkAuthFlow,
87
- V as LinkAuthFlowBackButton,
88
- dt as LinkAuthItem,
89
- ft as LinkAuthItems,
90
- K as LinkAuthTitle,
91
- y as useLinkAuthContext,
92
- mt as useLinkAuthFlow
83
+ mt as LinkAuth,
84
+ J as LinkAuthError,
85
+ j as LinkAuthFlow,
86
+ K as LinkAuthFlowBackButton,
87
+ pt as LinkAuthItem,
88
+ At as LinkAuthItems,
89
+ $ as LinkAuthTitle,
90
+ O as useLinkAuthContext,
91
+ kt as useLinkAuthFlow
93
92
  };
@@ -0,0 +1,4 @@
1
+ export declare const useTimeout: () => {
2
+ schedule: (callback: () => void, delay: number) => void;
3
+ cancel: () => void;
4
+ };
@@ -0,0 +1,16 @@
1
+ import { useRef as o, useEffect as l, useCallback as r } from "react";
2
+ const s = () => {
3
+ const e = o(null);
4
+ l(() => () => {
5
+ e.current && clearTimeout(e.current);
6
+ }, []);
7
+ const t = r((c, n) => {
8
+ e.current && clearTimeout(e.current), e.current = setTimeout(c, n);
9
+ }, []), u = r(() => {
10
+ e.current && (clearTimeout(e.current), e.current = null);
11
+ }, []);
12
+ return { schedule: t, cancel: u };
13
+ };
14
+ export {
15
+ s as useTimeout
16
+ };
@@ -1,92 +1,98 @@
1
- import { useState as F, useRef as h, useCallback as u } from "react";
2
- import { getTimeout as q, getEndStatus as z, getState as B, PRE_EXIT as D, nextTick as H, PRE_ENTER as C, EXITING as V, ENTERING as j, ENTERED as A, startOrEnd as G } from "../utils/transition.js";
3
- const w = (f, s, l, c, o, E) => {
1
+ import { useState as $, useRef as h, useCallback as f, useEffect as q } from "react";
2
+ import { getTimeout as z, getEndStatus as B, getState as H, PRE_EXIT as D, nextTick as J, PRE_ENTER as A, EXITING as C, ENTERING as V, ENTERED as j, startOrEnd as F } from "../utils/transition.js";
3
+ const w = (l, s, m, c, o, E) => {
4
4
  o && (clearTimeout(o), cancelAnimationFrame(o));
5
- const p = B(s), a = new Map(c.current);
6
- a.set(f, p), l(a), c.current = a, E?.({ key: f, current: p });
7
- }, L = (f = {}) => {
5
+ const p = H(s), i = new Map(c.current);
6
+ i.set(l, p), m(i), c.current = i, E?.({ key: l, current: p });
7
+ }, Q = (l = {}) => {
8
8
  const {
9
9
  allowMultiple: s,
10
- enter: l = !0,
10
+ enter: m = !0,
11
11
  exit: c = !0,
12
12
  preEnter: o,
13
13
  preExit: E,
14
14
  timeout: p = 200,
15
- initialEntered: a,
15
+ initialEntered: i,
16
16
  mountOnEnter: _,
17
- unmountOnExit: m,
18
- onStateChange: d
19
- } = f, [x, g] = F(/* @__PURE__ */ new Map()), n = h(x), T = h(/* @__PURE__ */ new Map()), [I, O] = q(p), P = u(
17
+ unmountOnExit: d,
18
+ onStateChange: g
19
+ } = l, [v, T] = $(/* @__PURE__ */ new Map()), n = h(v), u = h(/* @__PURE__ */ new Map()), [S, O] = z(p), G = f(
20
20
  (t, e) => {
21
- const { initialEntered: i = a } = e || {}, r = i ? A : G(_ ?? !1);
22
- w(t, r, g, n), T.current.set(t, {});
21
+ const { initialEntered: a = i } = e || {}, r = a ? j : F(_ ?? !1);
22
+ w(t, r, T, n), u.current.set(t, {});
23
23
  },
24
- [a, _]
25
- ), X = u((t) => {
24
+ [i, _]
25
+ ), P = f((t) => {
26
26
  const e = new Map(n.current);
27
- return e.delete(t) ? (g(e), n.current = e, T.current.delete(t), !0) : !1;
28
- }, []), M = u(
27
+ return e.delete(t) ? (T(e), n.current = e, u.current.delete(t), !0) : !1;
28
+ }, []), I = f(
29
29
  (t) => {
30
30
  const e = n.current.get(t);
31
31
  if (!e) {
32
32
  process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test" && console.error(`[React-Transition-State] invalid key: ${t}`);
33
33
  return;
34
34
  }
35
- const { timerId: i } = T.current.get(t) ?? {}, r = z(e._s, m ?? !1);
36
- r && w(t, r, g, n, i, d);
35
+ const { timerId: a } = u.current.get(t) ?? {}, r = B(e._s, d ?? !1);
36
+ r && w(t, r, T, n, a, g);
37
37
  },
38
- [d, m]
39
- ), N = u(
38
+ [g, d]
39
+ ), M = f(
40
40
  (t, e) => {
41
- const i = n.current.get(t);
42
- if (!i) {
41
+ const a = n.current.get(t);
42
+ if (!a) {
43
43
  process.env.NODE_ENV !== "production" && console.error(`[React-Transition-State] invalid key: ${t}`);
44
44
  return;
45
45
  }
46
- const r = T.current.get(t), R = (S) => {
47
- switch (w(t, S, g, n, r.timerId, d), S) {
48
- case j:
49
- I >= 0 && (r.timerId = setTimeout(() => M(t), I));
50
- break;
46
+ const r = u.current.get(t), R = (N) => {
47
+ switch (w(t, N, T, n, r.timerId, g), N) {
51
48
  case V:
52
- O >= 0 && (r.timerId = setTimeout(() => M(t), O));
49
+ S >= 0 && (r.timerId = setTimeout(() => I(t), S));
53
50
  break;
54
51
  case C:
52
+ O >= 0 && (r.timerId = setTimeout(() => I(t), O));
53
+ break;
54
+ case A:
55
55
  case D:
56
- r.timerId = H(R, S);
56
+ r.timerId = J(R, N);
57
57
  break;
58
58
  }
59
- }, b = i.isEnter;
60
- typeof e != "boolean" && (e = !b), e ? b || (R(l ? o ? C : j : A), s || n.current.forEach((S, v) => v !== t && N(v, !1))) : b && R(c ? E ? D : V : G(m ?? !1));
59
+ }, b = a.isEnter;
60
+ typeof e != "boolean" && (e = !b), e ? b || (R(m ? o ? A : V : j), s || n.current.forEach((N, x) => x !== t && M(x, !1))) : b && R(c ? E ? D : C : F(d ?? !1));
61
61
  },
62
62
  [
63
- d,
64
- M,
63
+ g,
64
+ I,
65
65
  s,
66
- l,
66
+ m,
67
67
  c,
68
68
  o,
69
69
  E,
70
- I,
70
+ S,
71
71
  O,
72
- m
72
+ d
73
73
  ]
74
- ), $ = u(
74
+ ), X = f(
75
75
  (t) => {
76
76
  if (!(!s && t !== !1))
77
- for (const e of n.current.keys()) N(e, t);
77
+ for (const e of n.current.keys()) M(e, t);
78
78
  },
79
- [s, N]
79
+ [s, M]
80
80
  );
81
- return {
82
- stateMap: x,
83
- toggle: N,
84
- toggleAll: $,
85
- endTransition: M,
86
- setItem: P,
87
- deleteItem: X
81
+ return q(() => {
82
+ const t = u.current;
83
+ return () => {
84
+ for (const e of t.values())
85
+ e.timerId && (clearTimeout(e.timerId), cancelAnimationFrame(e.timerId));
86
+ };
87
+ }, []), {
88
+ stateMap: v,
89
+ toggle: M,
90
+ toggleAll: X,
91
+ endTransition: I,
92
+ setItem: G,
93
+ deleteItem: P
88
94
  };
89
95
  };
90
96
  export {
91
- L as useTransitionMap
97
+ Q as useTransitionMap
92
98
  };
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "0.0.85";
1
+ export declare const VERSION = "0.0.86";
package/dist/version.js CHANGED
@@ -1,4 +1,4 @@
1
- const o = "0.0.85";
1
+ const o = "0.0.86";
2
2
  export {
3
3
  o as VERSION
4
4
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coinbase/cdp-react",
3
- "version": "0.0.85",
3
+ "version": "0.0.86",
4
4
  "type": "module",
5
5
  "dependencies": {
6
6
  "@internationalized/number": "3.6.4",
@@ -16,8 +16,8 @@
16
16
  },
17
17
  "peerDependencies": {
18
18
  "react": ">=18.2.0 <19.2.0",
19
- "@coinbase/cdp-core": "^0.0.85",
20
- "@coinbase/cdp-hooks": "^0.0.85"
19
+ "@coinbase/cdp-core": "^0.0.86",
20
+ "@coinbase/cdp-hooks": "^0.0.86"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@size-limit/preset-big-lib": "^11.2.0",
@@ -49,8 +49,8 @@
49
49
  "vite": "^7.0.4",
50
50
  "vite-plugin-dts": "^4.5.4",
51
51
  "vite-plugin-lib-inject-css": "^2.2.2",
52
- "@coinbase/cdp-core": "^0.0.85",
53
- "@coinbase/cdp-hooks": "^0.0.85"
52
+ "@coinbase/cdp-core": "^0.0.86",
53
+ "@coinbase/cdp-hooks": "^0.0.86"
54
54
  },
55
55
  "size-limit": [
56
56
  {