@thecb/components 11.3.2-beta.0 → 11.3.2-beta.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/dist/index.cjs.js +61 -40
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +9 -5
- package/dist/index.esm.js +61 -40
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/molecules/turnstile-widget/TurnstileWidget.js +50 -42
- package/src/hooks/use-turnstile-script/index.js +9 -5
package/dist/index.cjs.js
CHANGED
|
@@ -24414,10 +24414,14 @@ var useTurnstileScript = function useTurnstileScript(verifyURL) {
|
|
|
24414
24414
|
_useState2 = _slicedToArray(_useState, 2),
|
|
24415
24415
|
scriptLoaded = _useState2[0],
|
|
24416
24416
|
setScriptLoaded = _useState2[1];
|
|
24417
|
-
var _useState3 = React.useState(
|
|
24417
|
+
var _useState3 = React.useState(false),
|
|
24418
24418
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
24419
24419
|
scriptError = _useState4[0],
|
|
24420
24420
|
setScriptError = _useState4[1];
|
|
24421
|
+
var handleScriptError = function handleScriptError() {
|
|
24422
|
+
setScriptError(true);
|
|
24423
|
+
setScriptLoaded(false);
|
|
24424
|
+
};
|
|
24421
24425
|
React.useEffect(function () {
|
|
24422
24426
|
if (typeof window === "undefined") {
|
|
24423
24427
|
setScriptLoaded(false);
|
|
@@ -24433,17 +24437,16 @@ var useTurnstileScript = function useTurnstileScript(verifyURL) {
|
|
|
24433
24437
|
setScriptLoaded(true);
|
|
24434
24438
|
};
|
|
24435
24439
|
script.onerror = function () {
|
|
24436
|
-
|
|
24437
|
-
setScriptLoaded(false);
|
|
24440
|
+
handleScriptError();
|
|
24438
24441
|
};
|
|
24439
24442
|
script.onabort = function () {
|
|
24440
|
-
|
|
24441
|
-
setScriptLoaded(false);
|
|
24443
|
+
handleScriptError();
|
|
24442
24444
|
};
|
|
24443
24445
|
script.defer = true;
|
|
24444
24446
|
document.getElementsByTagName("head")[0].appendChild(script);
|
|
24445
24447
|
return function () {
|
|
24446
24448
|
setScriptLoaded(false);
|
|
24449
|
+
setScriptError(false);
|
|
24447
24450
|
};
|
|
24448
24451
|
}, [verifyURL]);
|
|
24449
24452
|
return {
|
|
@@ -50003,15 +50006,15 @@ var HeroImage$1 = withWindowSize(themeComponent(HeroImage, "HeroImage", fallback
|
|
|
50003
50006
|
var TurnstileWidgetContainer = styled__default(Box).withConfig({
|
|
50004
50007
|
displayName: "TurnstileWidget__TurnstileWidgetContainer",
|
|
50005
50008
|
componentId: "sc-btaugr-0"
|
|
50006
|
-
})(["display:flex;flex-direction:column;
|
|
50009
|
+
})(["display:flex;flex-direction:column;padding:", ";justify-content:", ";align-items:", ";width:100%;"], function (_ref) {
|
|
50007
50010
|
var padding = _ref.padding;
|
|
50008
50011
|
return padding;
|
|
50009
50012
|
}, function (_ref2) {
|
|
50010
50013
|
var justify = _ref2.justify;
|
|
50011
50014
|
return justify;
|
|
50012
50015
|
}, function (_ref3) {
|
|
50013
|
-
var
|
|
50014
|
-
return
|
|
50016
|
+
var align = _ref3.align;
|
|
50017
|
+
return align;
|
|
50015
50018
|
});
|
|
50016
50019
|
var FATAL_ERROR_CODES = [
|
|
50017
50020
|
// Configuration errors
|
|
@@ -50033,6 +50036,8 @@ var TurnstileWidget = /*#__PURE__*/React.forwardRef(function (_ref4, ref) {
|
|
|
50033
50036
|
padding = _ref4$padding === void 0 ? "1rem" : _ref4$padding,
|
|
50034
50037
|
_ref4$justify = _ref4.justify,
|
|
50035
50038
|
justify = _ref4$justify === void 0 ? "flex-end" : _ref4$justify,
|
|
50039
|
+
_ref4$align = _ref4.align,
|
|
50040
|
+
align = _ref4$align === void 0 ? "flex-end" : _ref4$align,
|
|
50036
50041
|
_ref4$size = _ref4.size,
|
|
50037
50042
|
size = _ref4$size === void 0 ? "normal" : _ref4$size,
|
|
50038
50043
|
_ref4$tabindex = _ref4.tabindex,
|
|
@@ -50091,40 +50096,59 @@ var TurnstileWidget = /*#__PURE__*/React.forwardRef(function (_ref4, ref) {
|
|
|
50091
50096
|
return "Something went wrong. Please refresh and try again.";
|
|
50092
50097
|
};
|
|
50093
50098
|
|
|
50099
|
+
// Reset the Turnstile widget when requested
|
|
50100
|
+
var resetWidget = React.useCallback(function () {
|
|
50101
|
+
if (widgetIdRef.current && window.turnstile) {
|
|
50102
|
+
window.turnstile.reset(widgetIdRef.current);
|
|
50103
|
+
clearError();
|
|
50104
|
+
}
|
|
50105
|
+
}, [clearError]);
|
|
50106
|
+
|
|
50094
50107
|
// Allow the parent component to reset the Turnstile widget
|
|
50095
50108
|
React.useImperativeHandle(ref, function () {
|
|
50096
50109
|
return {
|
|
50097
|
-
reset:
|
|
50098
|
-
if (widgetIdRef.current && window.turnstile) {
|
|
50099
|
-
window.turnstile.reset(widgetIdRef.current);
|
|
50100
|
-
clearError();
|
|
50101
|
-
}
|
|
50102
|
-
}
|
|
50110
|
+
reset: resetWidget
|
|
50103
50111
|
};
|
|
50104
|
-
}, []);
|
|
50112
|
+
}, [resetWidget]);
|
|
50105
50113
|
React.useEffect(function () {
|
|
50114
|
+
if (scriptError) {
|
|
50115
|
+
setError("Unable to load security verification. Please refresh the page.");
|
|
50116
|
+
onError === null || onError === void 0 || onError({
|
|
50117
|
+
type: "script_load_failed",
|
|
50118
|
+
error: scriptError
|
|
50119
|
+
});
|
|
50120
|
+
return;
|
|
50121
|
+
}
|
|
50106
50122
|
if (widgetIdRef.current || !window.turnstile || !scriptLoaded) return;
|
|
50107
|
-
|
|
50108
|
-
|
|
50109
|
-
|
|
50110
|
-
|
|
50111
|
-
|
|
50112
|
-
|
|
50113
|
-
|
|
50114
|
-
|
|
50115
|
-
|
|
50116
|
-
|
|
50117
|
-
|
|
50118
|
-
|
|
50119
|
-
|
|
50123
|
+
try {
|
|
50124
|
+
widgetIdRef.current = window.turnstile.render(widgetRef.current, {
|
|
50125
|
+
sitekey: siteKey,
|
|
50126
|
+
size: size,
|
|
50127
|
+
retry: retry,
|
|
50128
|
+
tabindex: tabindex,
|
|
50129
|
+
theme: theme,
|
|
50130
|
+
callback: function callback(token) {
|
|
50131
|
+
clearError();
|
|
50132
|
+
onSuccess(token);
|
|
50133
|
+
},
|
|
50134
|
+
"error-callback": function errorCallback(errorCode) {
|
|
50135
|
+
if (retry === "never") {
|
|
50136
|
+
handleError(errorCode);
|
|
50137
|
+
}
|
|
50138
|
+
onError === null || onError === void 0 || onError(errorCode);
|
|
50139
|
+
},
|
|
50140
|
+
"expired-callback": function expiredCallback() {
|
|
50141
|
+
clearError();
|
|
50142
|
+
onExpired === null || onExpired === void 0 || onExpired();
|
|
50120
50143
|
}
|
|
50121
|
-
|
|
50122
|
-
|
|
50123
|
-
"
|
|
50124
|
-
|
|
50125
|
-
|
|
50126
|
-
|
|
50127
|
-
|
|
50144
|
+
});
|
|
50145
|
+
} catch (error) {
|
|
50146
|
+
setError("Unable to load security verification. Please refresh the page.");
|
|
50147
|
+
onError === null || onError === void 0 || onError({
|
|
50148
|
+
type: "render_failed",
|
|
50149
|
+
error: error
|
|
50150
|
+
});
|
|
50151
|
+
}
|
|
50128
50152
|
return function () {
|
|
50129
50153
|
if (widgetIdRef.current && window.turnstile) {
|
|
50130
50154
|
window.turnstile.remove(widgetIdRef.current);
|
|
@@ -50136,6 +50160,7 @@ var TurnstileWidget = /*#__PURE__*/React.forwardRef(function (_ref4, ref) {
|
|
|
50136
50160
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(TurnstileWidgetContainer, {
|
|
50137
50161
|
padding: padding,
|
|
50138
50162
|
justify: justify,
|
|
50163
|
+
align: align,
|
|
50139
50164
|
extraStyles: extraStyles
|
|
50140
50165
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
50141
50166
|
ref: widgetRef
|
|
@@ -50143,11 +50168,7 @@ var TurnstileWidget = /*#__PURE__*/React.forwardRef(function (_ref4, ref) {
|
|
|
50143
50168
|
color: ERROR_COLOR,
|
|
50144
50169
|
variant: "pXS",
|
|
50145
50170
|
extraStyles: "\n word-break: break-word;\n text-align: end;\n "
|
|
50146
|
-
}, error)
|
|
50147
|
-
color: ERROR_COLOR,
|
|
50148
|
-
variant: "pXS",
|
|
50149
|
-
extraStyles: "\n word-break: break-word;\n text-align: end;\n "
|
|
50150
|
-
}, "Unable to load security verification. Please refresh the page.")));
|
|
50171
|
+
}, error)));
|
|
50151
50172
|
});
|
|
50152
50173
|
|
|
50153
50174
|
var pageBackground = "#FBFCFD";
|