@prosopo/procaptcha-react 2.6.27 → 2.6.29
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/CHANGELOG.md +31 -0
- package/dist/components/Button.js +74 -58
- package/dist/components/CaptchaComponent.js +224 -86
- package/dist/components/CaptchaWidget.js +135 -70
- package/dist/components/Modal.js +20 -16
- package/dist/components/Procaptcha.js +6 -5
- package/dist/components/ProcaptchaWidget.js +119 -71
- package/dist/components/index.js +9 -6
- package/dist/index.js +10 -3
- package/dist/util/index.js +16 -9
- package/package.json +19 -16
- package/vite.cjs.config.ts +2 -2
- package/vite.esm.config.ts +20 -0
- package/dist/components/Button.d.ts +0 -11
- package/dist/components/Button.d.ts.map +0 -1
- package/dist/components/Button.js.map +0 -1
- package/dist/components/CaptchaComponent.d.ts +0 -15
- package/dist/components/CaptchaComponent.d.ts.map +0 -1
- package/dist/components/CaptchaComponent.js.map +0 -1
- package/dist/components/CaptchaWidget.d.ts +0 -9
- package/dist/components/CaptchaWidget.d.ts.map +0 -1
- package/dist/components/CaptchaWidget.js.map +0 -1
- package/dist/components/Modal.d.ts +0 -8
- package/dist/components/Modal.d.ts.map +0 -1
- package/dist/components/Modal.js.map +0 -1
- package/dist/components/Procaptcha.d.ts +0 -14
- package/dist/components/Procaptcha.d.ts.map +0 -1
- package/dist/components/Procaptcha.js.map +0 -1
- package/dist/components/ProcaptchaWidget.d.ts +0 -4
- package/dist/components/ProcaptchaWidget.d.ts.map +0 -1
- package/dist/components/ProcaptchaWidget.js.map +0 -1
- package/dist/components/collector.d.ts +0 -9
- package/dist/components/collector.d.ts.map +0 -1
- package/dist/components/collector.js +0 -26
- package/dist/components/collector.js.map +0 -1
- package/dist/components/index.d.ts +0 -6
- package/dist/components/index.d.ts.map +0 -1
- package/dist/components/index.js.map +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/util/index.d.ts +0 -9
- package/dist/util/index.d.ts.map +0 -1
- package/dist/util/index.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
# @prosopo/procaptcha-react
|
|
2
2
|
|
|
3
|
+
## 2.6.29
|
|
4
|
+
### Patch Changes
|
|
5
|
+
|
|
6
|
+
- 3573f0b: fix npm scripts bundle command
|
|
7
|
+
- 3573f0b: build using vite, typecheck using tsc
|
|
8
|
+
- efd8102: Add tests for unwrap error helper
|
|
9
|
+
- 3573f0b: standardise all vite based npm scripts for bundling
|
|
10
|
+
- Updated dependencies [52dbf21]
|
|
11
|
+
- Updated dependencies [93d5e50]
|
|
12
|
+
- Updated dependencies [3573f0b]
|
|
13
|
+
- Updated dependencies [3573f0b]
|
|
14
|
+
- Updated dependencies [efd8102]
|
|
15
|
+
- Updated dependencies [93d5e50]
|
|
16
|
+
- Updated dependencies [63519d7]
|
|
17
|
+
- Updated dependencies [f29fc7e]
|
|
18
|
+
- Updated dependencies [3573f0b]
|
|
19
|
+
- Updated dependencies [2d0dd8a]
|
|
20
|
+
- @prosopo/util@3.0.3
|
|
21
|
+
- @prosopo/widget-skeleton@2.6.1
|
|
22
|
+
- @prosopo/locale@3.1.0
|
|
23
|
+
- @prosopo/types@3.0.4
|
|
24
|
+
- @prosopo/procaptcha-common@2.7.10
|
|
25
|
+
- @prosopo/procaptcha@2.7.15
|
|
26
|
+
- @prosopo/common@3.1.0
|
|
27
|
+
- @prosopo/config@3.1.1
|
|
28
|
+
|
|
29
|
+
## 2.6.28
|
|
30
|
+
### Patch Changes
|
|
31
|
+
|
|
32
|
+
- @prosopo/procaptcha@2.7.14
|
|
33
|
+
|
|
3
34
|
## 2.6.27
|
|
4
35
|
### Patch Changes
|
|
5
36
|
|
|
@@ -1,62 +1,78 @@
|
|
|
1
|
-
import { jsx
|
|
2
|
-
import {
|
|
3
|
-
import { useMemo, useState
|
|
1
|
+
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { lightTheme, darkTheme } from "@prosopo/widget-skeleton";
|
|
3
|
+
import { useMemo, useState } from "react";
|
|
4
4
|
import addDataAttr from "../util/index.js";
|
|
5
5
|
const buttonStyleBase = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
6
|
+
display: "inline-flex",
|
|
7
|
+
alignItems: "center",
|
|
8
|
+
justifyContent: "center",
|
|
9
|
+
position: "relative",
|
|
10
|
+
boxSizing: "border-box",
|
|
11
|
+
outline: "0px",
|
|
12
|
+
margin: "0px",
|
|
13
|
+
cursor: "pointer",
|
|
14
|
+
userSelect: "none",
|
|
15
|
+
verticalAlign: "middle",
|
|
16
|
+
appearance: void 0,
|
|
17
|
+
textDecoration: "none",
|
|
18
|
+
fontWeight: "500",
|
|
19
|
+
fontSize: "0.875rem",
|
|
20
|
+
lineHeight: "1.75",
|
|
21
|
+
letterSpacing: "0.02857em",
|
|
22
|
+
textTransform: "uppercase",
|
|
23
|
+
minWidth: "64px",
|
|
24
|
+
padding: "6px 16px",
|
|
25
|
+
borderRadius: "4px",
|
|
26
|
+
transition: "background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, box-shadow 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, border-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms",
|
|
27
|
+
backgroundColor: "#ffffff"
|
|
28
28
|
};
|
|
29
|
-
const Button = ({
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
29
|
+
const Button = ({
|
|
30
|
+
themeColor,
|
|
31
|
+
buttonType,
|
|
32
|
+
text,
|
|
33
|
+
onClick
|
|
34
|
+
}) => {
|
|
35
|
+
const theme = useMemo(
|
|
36
|
+
() => themeColor === "light" ? lightTheme : darkTheme,
|
|
37
|
+
[themeColor]
|
|
38
|
+
);
|
|
39
|
+
const [hover, setHover] = useState(false);
|
|
40
|
+
const buttonStyle = useMemo(() => {
|
|
41
|
+
const baseStyle = {
|
|
42
|
+
...buttonStyleBase,
|
|
43
|
+
border: `1px solid ${theme.palette.grey[500]}`,
|
|
44
|
+
boxShadow: `0px 1px 3px 0px ${theme.palette.grey[500]}`,
|
|
45
|
+
fontFamily: theme.font.fontFamily,
|
|
46
|
+
width: "100%",
|
|
47
|
+
color: hover ? theme.palette.primary.contrastText : theme.palette.background.contrastText
|
|
48
|
+
};
|
|
49
|
+
if (buttonType === "cancel") {
|
|
50
|
+
return {
|
|
51
|
+
...baseStyle,
|
|
52
|
+
backgroundColor: hover ? theme.palette.grey[600] : "transparent"
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
...baseStyle,
|
|
57
|
+
backgroundColor: hover ? theme.palette.primary.main : theme.palette.background.default
|
|
58
|
+
};
|
|
59
|
+
}, [buttonType, hover, theme]);
|
|
60
|
+
return /* @__PURE__ */ jsx(
|
|
61
|
+
"button",
|
|
62
|
+
{
|
|
63
|
+
...addDataAttr({ dev: { cy: `button-${buttonType}` } }),
|
|
64
|
+
onMouseEnter: () => setHover(true),
|
|
65
|
+
onMouseLeave: () => setHover(false),
|
|
66
|
+
style: buttonStyle,
|
|
67
|
+
onClick: (e) => {
|
|
68
|
+
e.preventDefault();
|
|
69
|
+
onClick();
|
|
70
|
+
},
|
|
71
|
+
"aria-label": text,
|
|
72
|
+
children: text
|
|
73
|
+
}
|
|
74
|
+
);
|
|
75
|
+
};
|
|
76
|
+
export {
|
|
77
|
+
Button as default
|
|
60
78
|
};
|
|
61
|
-
export default Button;
|
|
62
|
-
//# sourceMappingURL=Button.js.map
|
|
@@ -1,93 +1,231 @@
|
|
|
1
|
-
import { jsx
|
|
1
|
+
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
2
2
|
import { useTranslation } from "@prosopo/locale";
|
|
3
3
|
import { ReloadButton } from "@prosopo/procaptcha-common";
|
|
4
4
|
import { at } from "@prosopo/util";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { lightTheme, darkTheme } from "@prosopo/widget-skeleton";
|
|
6
|
+
import { useMemo, Suspense } from "react";
|
|
7
7
|
import addDataAttr from "../util/index.js";
|
|
8
8
|
import Button from "./Button.js";
|
|
9
9
|
import { CaptchaWidget } from "./CaptchaWidget.js";
|
|
10
|
-
const CaptchaComponent = ({
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
10
|
+
const CaptchaComponent = ({
|
|
11
|
+
challenge,
|
|
12
|
+
index,
|
|
13
|
+
solutions,
|
|
14
|
+
onSubmit,
|
|
15
|
+
onCancel,
|
|
16
|
+
onClick,
|
|
17
|
+
onNext,
|
|
18
|
+
onReload,
|
|
19
|
+
themeColor
|
|
20
|
+
}) => {
|
|
21
|
+
const { t } = useTranslation();
|
|
22
|
+
const captcha = challenge.captchas ? at(challenge.captchas, index) : null;
|
|
23
|
+
const solution = solutions ? at(solutions, index) : [];
|
|
24
|
+
const theme = useMemo(
|
|
25
|
+
() => themeColor === "light" ? lightTheme : darkTheme,
|
|
26
|
+
[themeColor]
|
|
27
|
+
);
|
|
28
|
+
const doubleSpacing = `${theme.spacing.unit * 2}px`;
|
|
29
|
+
const fullSpacing = `${theme.spacing.unit}px`;
|
|
30
|
+
const halfSpacing = `${theme.spacing.half}px`;
|
|
31
|
+
return /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: /* @__PURE__ */ jsx(
|
|
32
|
+
"div",
|
|
33
|
+
{
|
|
34
|
+
style: {
|
|
35
|
+
// introduce scroll bars when screen < minWidth of children
|
|
36
|
+
overflowX: "auto",
|
|
37
|
+
overflowY: "auto",
|
|
38
|
+
maxWidth: "500px",
|
|
39
|
+
maxHeight: "100%",
|
|
40
|
+
display: "flex",
|
|
41
|
+
flexDirection: "column",
|
|
42
|
+
border: "1px solid #dddddd",
|
|
43
|
+
boxShadow: "rgba(255, 255, 255, 0.2) 0px 0px 4px",
|
|
44
|
+
borderRadius: "4px",
|
|
45
|
+
backgroundColor: theme.palette.background.default,
|
|
46
|
+
userSelect: "none",
|
|
47
|
+
touchAction: "none",
|
|
48
|
+
overscrollBehavior: "none"
|
|
49
|
+
},
|
|
50
|
+
children: /* @__PURE__ */ jsxs(
|
|
51
|
+
"div",
|
|
52
|
+
{
|
|
53
|
+
style: {
|
|
54
|
+
backgroundColor: theme.palette.background.default,
|
|
55
|
+
display: "flex",
|
|
56
|
+
flexDirection: "column",
|
|
57
|
+
minWidth: "300px",
|
|
58
|
+
marginLeft: fullSpacing,
|
|
59
|
+
marginRight: fullSpacing,
|
|
60
|
+
justifyContent: "center"
|
|
61
|
+
},
|
|
62
|
+
children: [
|
|
63
|
+
/* @__PURE__ */ jsx(
|
|
64
|
+
"div",
|
|
65
|
+
{
|
|
66
|
+
style: {
|
|
67
|
+
display: "flex",
|
|
68
|
+
alignItems: "center",
|
|
69
|
+
width: "100%"
|
|
70
|
+
},
|
|
71
|
+
children: /* @__PURE__ */ jsx(
|
|
72
|
+
"div",
|
|
73
|
+
{
|
|
74
|
+
style: {
|
|
75
|
+
backgroundColor: theme.palette.primary.main,
|
|
76
|
+
width: "100%",
|
|
77
|
+
marginTop: fullSpacing
|
|
78
|
+
},
|
|
79
|
+
children: /* @__PURE__ */ jsxs(
|
|
80
|
+
"div",
|
|
81
|
+
{
|
|
82
|
+
style: {
|
|
83
|
+
padding: `${theme.spacing.half}px`,
|
|
84
|
+
fontFamily: theme.font.fontFamily
|
|
85
|
+
},
|
|
86
|
+
children: [
|
|
87
|
+
/* @__PURE__ */ jsxs(
|
|
88
|
+
"p",
|
|
89
|
+
{
|
|
90
|
+
style: {
|
|
91
|
+
color: "#ffffff",
|
|
92
|
+
fontWeight: 700,
|
|
93
|
+
lineHeight: 1.5
|
|
94
|
+
},
|
|
95
|
+
children: [
|
|
96
|
+
t("WIDGET.SELECT_ALL"),
|
|
97
|
+
":",
|
|
98
|
+
" ",
|
|
99
|
+
/* @__PURE__ */ jsx("span", { children: `${at(challenge.captchas, index).target} ` })
|
|
100
|
+
]
|
|
101
|
+
}
|
|
102
|
+
),
|
|
103
|
+
/* @__PURE__ */ jsx(
|
|
104
|
+
"p",
|
|
105
|
+
{
|
|
106
|
+
style: {
|
|
107
|
+
color: "#ffffff",
|
|
108
|
+
fontWeight: 500,
|
|
109
|
+
lineHeight: 0.8,
|
|
110
|
+
fontSize: "0.8rem"
|
|
111
|
+
},
|
|
112
|
+
children: t("WIDGET.IF_NONE_CLICK_NEXT")
|
|
113
|
+
}
|
|
114
|
+
)
|
|
115
|
+
]
|
|
116
|
+
}
|
|
117
|
+
)
|
|
118
|
+
}
|
|
119
|
+
)
|
|
120
|
+
}
|
|
121
|
+
),
|
|
122
|
+
/* @__PURE__ */ jsx(
|
|
123
|
+
"div",
|
|
124
|
+
{
|
|
125
|
+
...addDataAttr({ dev: { cy: `captcha-${index}` } }),
|
|
126
|
+
style: { overflow: "hidden" },
|
|
127
|
+
children: captcha && /* @__PURE__ */ jsx(
|
|
128
|
+
CaptchaWidget,
|
|
129
|
+
{
|
|
130
|
+
challenge: captcha,
|
|
131
|
+
solution,
|
|
132
|
+
onClick,
|
|
133
|
+
themeColor
|
|
134
|
+
}
|
|
135
|
+
)
|
|
136
|
+
}
|
|
137
|
+
),
|
|
138
|
+
/* @__PURE__ */ jsx(
|
|
139
|
+
"div",
|
|
140
|
+
{
|
|
141
|
+
style: {
|
|
142
|
+
display: "flex",
|
|
143
|
+
alignItems: "center",
|
|
144
|
+
justifyContent: "space-between",
|
|
145
|
+
lineHeight: 1.75,
|
|
146
|
+
padding: `${fullSpacing} 0 ${doubleSpacing} 0`
|
|
147
|
+
},
|
|
148
|
+
children: /* @__PURE__ */ jsxs(
|
|
149
|
+
"div",
|
|
150
|
+
{
|
|
151
|
+
style: {
|
|
152
|
+
// expand to full height / width of parent
|
|
153
|
+
width: "100%",
|
|
154
|
+
height: "100%",
|
|
155
|
+
// display children in flex, spreading them evenly and wrapping when row length exceeded
|
|
156
|
+
display: "flex",
|
|
157
|
+
flexDirection: "row",
|
|
158
|
+
flexWrap: "wrap",
|
|
159
|
+
justifyContent: "space-between",
|
|
160
|
+
gap: "10px"
|
|
161
|
+
},
|
|
162
|
+
children: [
|
|
163
|
+
/* @__PURE__ */ jsx(
|
|
164
|
+
"div",
|
|
165
|
+
{
|
|
166
|
+
style: {
|
|
167
|
+
position: "relative",
|
|
168
|
+
flexGrow: 1,
|
|
169
|
+
// make the width of each item 1/3rd of the width overall, i.e. 3 columns
|
|
170
|
+
flexBasis: "calc(33.333% - 10px)"
|
|
171
|
+
},
|
|
172
|
+
children: /* @__PURE__ */ jsx(
|
|
173
|
+
Button,
|
|
174
|
+
{
|
|
175
|
+
themeColor,
|
|
176
|
+
buttonType: "cancel",
|
|
177
|
+
onClick: onCancel,
|
|
178
|
+
text: t("WIDGET.CANCEL"),
|
|
179
|
+
"aria-label": t("WIDGET.CANCEL")
|
|
180
|
+
}
|
|
181
|
+
)
|
|
182
|
+
}
|
|
183
|
+
),
|
|
184
|
+
/* @__PURE__ */ jsx(
|
|
185
|
+
"div",
|
|
186
|
+
{
|
|
187
|
+
style: {
|
|
188
|
+
position: "relative",
|
|
189
|
+
flexGrow: 1,
|
|
190
|
+
// make the width of each item 1/3rd of the width overall, i.e. 3 columns
|
|
191
|
+
flexBasis: "calc(33.333% - 10px)"
|
|
192
|
+
},
|
|
193
|
+
children: /* @__PURE__ */ jsx(ReloadButton, { themeColor, onReload })
|
|
194
|
+
}
|
|
195
|
+
),
|
|
196
|
+
/* @__PURE__ */ jsx(
|
|
197
|
+
"div",
|
|
198
|
+
{
|
|
199
|
+
style: {
|
|
200
|
+
position: "relative",
|
|
201
|
+
flexGrow: 1,
|
|
202
|
+
// make the width of each item 1/3rd of the width overall, i.e. 3 columns
|
|
203
|
+
flexBasis: "calc(33.333% - 10px)"
|
|
204
|
+
},
|
|
205
|
+
children: /* @__PURE__ */ jsx(
|
|
206
|
+
Button,
|
|
207
|
+
{
|
|
208
|
+
themeColor,
|
|
209
|
+
buttonType: "next",
|
|
210
|
+
text: index < challenge.captchas.length - 1 ? t("WIDGET.NEXT") : t("WIDGET.SUBMIT"),
|
|
211
|
+
onClick: index < challenge.captchas.length - 1 ? onNext : onSubmit,
|
|
212
|
+
"aria-label": index < challenge.captchas.length - 1 ? t("WIDGET.NEXT") : t("WIDGET.SUBMIT"),
|
|
213
|
+
"data-cy": "button-next"
|
|
214
|
+
}
|
|
215
|
+
)
|
|
216
|
+
}
|
|
217
|
+
)
|
|
218
|
+
]
|
|
219
|
+
}
|
|
220
|
+
)
|
|
221
|
+
}
|
|
222
|
+
)
|
|
223
|
+
]
|
|
224
|
+
}
|
|
225
|
+
)
|
|
226
|
+
}
|
|
227
|
+
) });
|
|
228
|
+
};
|
|
229
|
+
export {
|
|
230
|
+
CaptchaComponent as default
|
|
91
231
|
};
|
|
92
|
-
export default CaptchaComponent;
|
|
93
|
-
//# sourceMappingURL=CaptchaComponent.js.map
|