@captchafox/react 1.4.0 → 1.5.1

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 CHANGED
@@ -34,18 +34,19 @@ function Example() {
34
34
 
35
35
  ### Props
36
36
 
37
- | **Prop** | **Type** | **Description** | **Required** |
38
- | -------- | --------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ------------ |
39
- | sitekey | `string` | The sitekey for the widget | ✅ |
40
- | lang | `string` | The language the widget should display. Defaults to automatically detecting it. | |
41
- | mode | `inline\|popup\|hidden` | The mode the widget should be displayed in . | |
42
- | theme | `light` | `dark` | [`ThemeDefinition`](https://docs.captchafox.com/theming#custom-theme) | The theme of the widget. Defaults to light. | |
43
- | nonce | `string` | Randomly generated nonce | |
44
- | onVerify | `function` | Called with the response token after successful verification. | |
45
- | onFail | `function` | Called after unsuccessful verification. | |
46
- | onError | `function` | Called when an error occured. | |
47
- | onExpire | `function` | Called when the challenge expires. | |
48
- | onClose | `function` | Called when the challenge was closed. | |
37
+ | **Prop** | **Type** | **Description** | **Required** |
38
+ | -------- | -------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ------------ |
39
+ | sitekey | `string` | The sitekey for the widget | ✅ |
40
+ | lang | `string` | The language the widget should display. Defaults to automatically detecting it. | |
41
+ | mode | `inline\|popup\|hidden` | The mode the widget should be displayed in . | |
42
+ | theme | `light` | `dark` | [`ThemeDefinition`](https://docs.captchafox.com/theming#custom-theme) | The theme of the widget. Defaults to light. | |
43
+ | nonce | `string` | Randomly generated nonce . | |
44
+ | i18n | `object` | Custom i18n configuration. | |
45
+ | onVerify | `function` | Called with the response token after successful verification. | |
46
+ | onFail | `function` | Called after unsuccessful verification. | |
47
+ | onError | `function` | Called when an error occured. | |
48
+ | onExpire | `function` | Called when the challenge expires. | |
49
+ | onClose | `function` | Called when the challenge was closed. | |
49
50
 
50
51
  ### Using the verification callback
51
52
 
package/dist/index.cjs CHANGED
@@ -87,7 +87,20 @@ var isApiReady = () => typeof (window == null ? void 0 : window.captchafox) !==
87
87
  // src/CaptchaFox.tsx
88
88
  var import_react = __toESM(require("react"), 1);
89
89
  var CaptchaFox = (0, import_react.forwardRef)(
90
- ({ sitekey, lang, mode, theme, className, nonce, onError, onVerify, onLoad, onFail, onClose }, ref) => {
90
+ ({
91
+ sitekey,
92
+ lang,
93
+ mode,
94
+ theme,
95
+ className,
96
+ nonce,
97
+ i18n,
98
+ onError,
99
+ onVerify,
100
+ onLoad,
101
+ onFail,
102
+ onClose
103
+ }, ref) => {
91
104
  const [containerRef, setContainerRef] = (0, import_react.useState)();
92
105
  const [widgetId, setWidgetId] = (0, import_react.useState)();
93
106
  const firstRendered = (0, import_react.useRef)(false);
@@ -114,7 +127,7 @@ var CaptchaFox = (0, import_react.forwardRef)(
114
127
  console.warn("[CaptchaFox] Widget has not been loaded");
115
128
  return;
116
129
  }
117
- setWidgetId("");
130
+ setWidgetId(void 0);
118
131
  window.captchafox.remove(widgetId);
119
132
  },
120
133
  execute: () => {
@@ -127,6 +140,11 @@ var CaptchaFox = (0, import_react.forwardRef)(
127
140
  },
128
141
  [widgetId]
129
142
  );
143
+ (0, import_react.useEffect)(() => {
144
+ if (widgetId) {
145
+ onLoad == null ? void 0 : onLoad();
146
+ }
147
+ }, [widgetId]);
130
148
  const renderCaptcha = () => __async(void 0, null, function* () {
131
149
  var _a, _b, _c;
132
150
  (_a = window.captchafox) == null ? void 0 : _a.remove(widgetId);
@@ -137,13 +155,13 @@ var CaptchaFox = (0, import_react.forwardRef)(
137
155
  sitekey,
138
156
  mode,
139
157
  theme,
158
+ i18n,
140
159
  onError,
141
160
  onFail,
142
161
  onClose,
143
162
  onVerify
144
163
  });
145
164
  setWidgetId(newWidgetId);
146
- onLoad == null ? void 0 : onLoad();
147
165
  });
148
166
  (0, import_react.useEffect)(() => {
149
167
  if (!containerRef)
package/dist/index.js CHANGED
@@ -51,7 +51,20 @@ var isApiReady = () => typeof (window == null ? void 0 : window.captchafox) !==
51
51
  // src/CaptchaFox.tsx
52
52
  import React, { forwardRef, useEffect, useImperativeHandle, useRef, useState } from "react";
53
53
  var CaptchaFox = forwardRef(
54
- ({ sitekey, lang, mode, theme, className, nonce, onError, onVerify, onLoad, onFail, onClose }, ref) => {
54
+ ({
55
+ sitekey,
56
+ lang,
57
+ mode,
58
+ theme,
59
+ className,
60
+ nonce,
61
+ i18n,
62
+ onError,
63
+ onVerify,
64
+ onLoad,
65
+ onFail,
66
+ onClose
67
+ }, ref) => {
55
68
  const [containerRef, setContainerRef] = useState();
56
69
  const [widgetId, setWidgetId] = useState();
57
70
  const firstRendered = useRef(false);
@@ -78,7 +91,7 @@ var CaptchaFox = forwardRef(
78
91
  console.warn("[CaptchaFox] Widget has not been loaded");
79
92
  return;
80
93
  }
81
- setWidgetId("");
94
+ setWidgetId(void 0);
82
95
  window.captchafox.remove(widgetId);
83
96
  },
84
97
  execute: () => {
@@ -91,6 +104,11 @@ var CaptchaFox = forwardRef(
91
104
  },
92
105
  [widgetId]
93
106
  );
107
+ useEffect(() => {
108
+ if (widgetId) {
109
+ onLoad == null ? void 0 : onLoad();
110
+ }
111
+ }, [widgetId]);
94
112
  const renderCaptcha = () => __async(void 0, null, function* () {
95
113
  var _a, _b, _c;
96
114
  (_a = window.captchafox) == null ? void 0 : _a.remove(widgetId);
@@ -101,13 +119,13 @@ var CaptchaFox = forwardRef(
101
119
  sitekey,
102
120
  mode,
103
121
  theme,
122
+ i18n,
104
123
  onError,
105
124
  onFail,
106
125
  onClose,
107
126
  onVerify
108
127
  });
109
128
  setWidgetId(newWidgetId);
110
- onLoad == null ? void 0 : onLoad();
111
129
  });
112
130
  useEffect(() => {
113
131
  if (!containerRef)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@captchafox/react",
3
- "version": "1.4.0",
3
+ "version": "1.5.1",
4
4
  "main": "./dist/index.cjs",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -35,7 +35,7 @@
35
35
  "react-dom": ">=16.8.0"
36
36
  },
37
37
  "dependencies": {
38
- "@captchafox/types": "^1.2.0"
38
+ "@captchafox/types": "^1.3.0"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@captchafox/tsconfig": "*",