@connect-xyz/auth-react 0.13.0 → 0.15.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
@@ -18,6 +18,7 @@ declare type AppEvent<TType extends string = string, TData = Record<string, unkn
18
18
  * @param props - Component properties
19
19
  * @param jwt - JWT token for authentication (required)
20
20
  * @param env - Target environment ("sandbox" | "production", defaults to "production")
21
+ * @param theme - Theme mode ("auto" | "light" | "dark", defaults to "auto")
21
22
  * @param onError - Callback function for error handling
22
23
  * @param onClose - Callback function for close events
23
24
  * @param onDeposit - Callback function for deposit events
@@ -31,9 +32,13 @@ declare type AppEvent<TType extends string = string, TData = Record<string, unkn
31
32
  * // Using sandbox environment for testing
32
33
  * <Auth jwt="your-jwt-token" env="sandbox" />
33
34
  *
35
+ * // Force dark theme
36
+ * <Auth jwt="your-jwt-token" theme="dark" />
37
+ *
34
38
  * // With callback functions
35
39
  * <Auth
36
40
  * jwt="your-jwt-token"
41
+ * theme="auto"
37
42
  * onError={({ errorCode, reason }) => console.error('Auth error:', errorCode, 'Reason:', reason)}
38
43
  * onClose={() => console.log('Auth closed')}
39
44
  * onDeposit={({ data }) => console.log('Deposit completed:', data.depositId, 'Status:', data.status.value)}
@@ -95,6 +100,29 @@ declare interface AuthWrapperProps extends AuthCallbacks {
95
100
  * ```
96
101
  */
97
102
  env?: Environment;
103
+ /**
104
+ * Theme mode for the Connect Auth interface.
105
+ *
106
+ * @default "auto"
107
+ *
108
+ * Available themes:
109
+ * - `"auto"` - Automatically detect system preference (light/dark mode)
110
+ * - `"light"` - Force light theme
111
+ * - `"dark"` - Force dark theme
112
+ *
113
+ * @example
114
+ * ```tsx
115
+ * // Auto-detect system preference (default)
116
+ * <Auth jwt={token} />
117
+ *
118
+ * // Force dark theme
119
+ * <Auth jwt={token} theme="dark" />
120
+ *
121
+ * // Force light theme
122
+ * <Auth jwt={token} theme="light" />
123
+ * ```
124
+ */
125
+ theme?: Theme;
98
126
  }
99
127
 
100
128
  /**
@@ -187,4 +215,13 @@ declare type ErrorPayload = {
187
215
  reason: string;
188
216
  };
189
217
 
218
+ /**
219
+ * Theme mode for the Connect Auth interface.
220
+ *
221
+ * - `"auto"` - Automatically detect system preference (light/dark mode)
222
+ * - `"light"` - Force light theme
223
+ * - `"dark"` - Force dark theme
224
+ */
225
+ declare type Theme = 'auto' | 'light' | 'dark';
226
+
190
227
  export { }
package/dist/index.js CHANGED
@@ -1,35 +1,37 @@
1
- import l, { useRef as m, useEffect as p } from "react";
2
- const h = {
1
+ import m, { useRef as h, useEffect as p } from "react";
2
+ const x = {
3
3
  sandbox: "https://sdk.sandbox.connect.xyz/auth-web/index.js",
4
4
  production: "https://sdk.connect.xyz/auth-web/index.js"
5
- }, x = "connect-auth-script", a = "connect-auth", y = (n = "production") => h[n], R = ({
5
+ }, y = "connect-auth-script", a = "connect-auth", I = (n = "production") => x[n], b = ({
6
6
  jwt: n,
7
7
  env: c = "production",
8
+ theme: f,
8
9
  onError: r,
9
10
  onClose: o,
10
11
  onDeposit: s,
11
12
  onEvent: i,
12
- ...f
13
+ ...l
13
14
  }) => {
14
- const d = m(null);
15
+ const d = h(null);
15
16
  return p(() => {
16
17
  const t = d.current;
17
18
  t && (r && (t.onError = r), o && (t.onClose = o), s && (t.onDeposit = s), i && (t.onEvent = i));
18
19
  }, [r, o, s, i]), p(() => {
19
- const t = y(c), u = `${x}-${c}`;
20
+ const t = I(c), u = `${y}-${c}`;
20
21
  if (document.getElementById(u))
21
22
  return;
22
23
  const e = document.createElement("script");
23
24
  e.id = u, e.src = t, e.type = "module", e.async = !0, e.onerror = () => {
24
25
  console.error(`Failed to load the script for ${a} from ${c} environment.`);
25
26
  }, document.head.appendChild(e);
26
- }, [c]), l.createElement(a, {
27
+ }, [c]), m.createElement(a, {
27
28
  ref: d,
28
29
  jwt: n,
29
30
  env: c,
30
- ...f
31
+ theme: f,
32
+ ...l
31
33
  });
32
34
  };
33
35
  export {
34
- R as Auth
36
+ b as Auth
35
37
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@connect-xyz/auth-react",
3
- "version": "0.13.0",
3
+ "version": "0.15.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",