@captchafox/react 1.0.1 → 1.0.3
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 +7 -7
- package/dist/index.js +3 -4
- package/dist/index.mjs +3 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -33,13 +33,13 @@ function Example() {
|
|
|
33
33
|
| **Prop** | **Type** | **Description** | **Required** |
|
|
34
34
|
| -------- | ----------------------- | ------------------------------------------------------------------------------- | ------------ |
|
|
35
35
|
| sitekey | `string` | The sitekey for the widget | ✅ |
|
|
36
|
-
|
|
|
37
|
-
| mode | `inline\|popup\|hidden` | The mode the widget should be displayed in
|
|
38
|
-
| onVerify | `function` | Called with the response token after successful verification
|
|
39
|
-
| onFail | `function` | Called after unsuccessful verification
|
|
40
|
-
| onError | `function` | Called
|
|
41
|
-
| onExpire | `function` | Called
|
|
42
|
-
| onClose | `function` | Called
|
|
36
|
+
| lang | `string` | The language the widget should display. Defaults to automatically detecting it. | |
|
|
37
|
+
| mode | `inline\|popup\|hidden` | The mode the widget should be displayed in . | |
|
|
38
|
+
| onVerify | `function` | Called with the response token after successful verification. | |
|
|
39
|
+
| onFail | `function` | Called after unsuccessful verification. | |
|
|
40
|
+
| onError | `function` | Called when an error occured. | |
|
|
41
|
+
| onExpire | `function` | Called when the challenge expires. | |
|
|
42
|
+
| onClose | `function` | Called when the challenge was closed. | |
|
|
43
43
|
|
|
44
44
|
### Using the verification callback
|
|
45
45
|
|
package/dist/index.js
CHANGED
|
@@ -63,7 +63,6 @@ function loadCaptchaScript() {
|
|
|
63
63
|
script.src = SCRIPT_SRC;
|
|
64
64
|
script.async = true;
|
|
65
65
|
script.defer = true;
|
|
66
|
-
script.type = "module";
|
|
67
66
|
script.onerror = rejectFn;
|
|
68
67
|
document.body.appendChild(script);
|
|
69
68
|
return mountInstance;
|
|
@@ -75,7 +74,7 @@ var isApiReady = () => typeof (window == null ? void 0 : window.captchafox) !==
|
|
|
75
74
|
var import_react = require("react");
|
|
76
75
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
77
76
|
var CaptchaFox = (0, import_react.forwardRef)(
|
|
78
|
-
({ sitekey,
|
|
77
|
+
({ sitekey, lang, mode, className, onError, onVerify, onLoad, onFail, onClose }, ref) => {
|
|
79
78
|
const [containerRef, setContainerRef] = (0, import_react.useState)();
|
|
80
79
|
const [widgetId, setWidgetId] = (0, import_react.useState)();
|
|
81
80
|
const firstRendered = (0, import_react.useRef)(false);
|
|
@@ -121,7 +120,7 @@ var CaptchaFox = (0, import_react.forwardRef)(
|
|
|
121
120
|
if (!containerRef || ((_b = containerRef == null ? void 0 : containerRef.children) == null ? void 0 : _b.length) === 1)
|
|
122
121
|
return;
|
|
123
122
|
const newWidgetId = yield (_c = window.captchafox) == null ? void 0 : _c.render(containerRef, {
|
|
124
|
-
|
|
123
|
+
lang,
|
|
125
124
|
sitekey,
|
|
126
125
|
mode,
|
|
127
126
|
onError,
|
|
@@ -150,7 +149,7 @@ var CaptchaFox = (0, import_react.forwardRef)(
|
|
|
150
149
|
console.error("[CaptchaFox] Could not load script:", err);
|
|
151
150
|
});
|
|
152
151
|
}
|
|
153
|
-
}, [containerRef, sitekey,
|
|
152
|
+
}, [containerRef, sitekey, lang, mode]);
|
|
154
153
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: setContainerRef, id: widgetId, className });
|
|
155
154
|
}
|
|
156
155
|
);
|
package/dist/index.mjs
CHANGED
|
@@ -37,7 +37,6 @@ function loadCaptchaScript() {
|
|
|
37
37
|
script.src = SCRIPT_SRC;
|
|
38
38
|
script.async = true;
|
|
39
39
|
script.defer = true;
|
|
40
|
-
script.type = "module";
|
|
41
40
|
script.onerror = rejectFn;
|
|
42
41
|
document.body.appendChild(script);
|
|
43
42
|
return mountInstance;
|
|
@@ -49,7 +48,7 @@ var isApiReady = () => typeof (window == null ? void 0 : window.captchafox) !==
|
|
|
49
48
|
import { forwardRef, useEffect, useImperativeHandle, useRef, useState } from "react";
|
|
50
49
|
import { jsx } from "react/jsx-runtime";
|
|
51
50
|
var CaptchaFox = forwardRef(
|
|
52
|
-
({ sitekey,
|
|
51
|
+
({ sitekey, lang, mode, className, onError, onVerify, onLoad, onFail, onClose }, ref) => {
|
|
53
52
|
const [containerRef, setContainerRef] = useState();
|
|
54
53
|
const [widgetId, setWidgetId] = useState();
|
|
55
54
|
const firstRendered = useRef(false);
|
|
@@ -95,7 +94,7 @@ var CaptchaFox = forwardRef(
|
|
|
95
94
|
if (!containerRef || ((_b = containerRef == null ? void 0 : containerRef.children) == null ? void 0 : _b.length) === 1)
|
|
96
95
|
return;
|
|
97
96
|
const newWidgetId = yield (_c = window.captchafox) == null ? void 0 : _c.render(containerRef, {
|
|
98
|
-
|
|
97
|
+
lang,
|
|
99
98
|
sitekey,
|
|
100
99
|
mode,
|
|
101
100
|
onError,
|
|
@@ -124,7 +123,7 @@ var CaptchaFox = forwardRef(
|
|
|
124
123
|
console.error("[CaptchaFox] Could not load script:", err);
|
|
125
124
|
});
|
|
126
125
|
}
|
|
127
|
-
}, [containerRef, sitekey,
|
|
126
|
+
}, [containerRef, sitekey, lang, mode]);
|
|
128
127
|
return /* @__PURE__ */ jsx("div", { ref: setContainerRef, id: widgetId, className });
|
|
129
128
|
}
|
|
130
129
|
);
|