@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.
Files changed (44) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/dist/components/Button.js +74 -58
  3. package/dist/components/CaptchaComponent.js +224 -86
  4. package/dist/components/CaptchaWidget.js +135 -70
  5. package/dist/components/Modal.js +20 -16
  6. package/dist/components/Procaptcha.js +6 -5
  7. package/dist/components/ProcaptchaWidget.js +119 -71
  8. package/dist/components/index.js +9 -6
  9. package/dist/index.js +10 -3
  10. package/dist/util/index.js +16 -9
  11. package/package.json +19 -16
  12. package/vite.cjs.config.ts +2 -2
  13. package/vite.esm.config.ts +20 -0
  14. package/dist/components/Button.d.ts +0 -11
  15. package/dist/components/Button.d.ts.map +0 -1
  16. package/dist/components/Button.js.map +0 -1
  17. package/dist/components/CaptchaComponent.d.ts +0 -15
  18. package/dist/components/CaptchaComponent.d.ts.map +0 -1
  19. package/dist/components/CaptchaComponent.js.map +0 -1
  20. package/dist/components/CaptchaWidget.d.ts +0 -9
  21. package/dist/components/CaptchaWidget.d.ts.map +0 -1
  22. package/dist/components/CaptchaWidget.js.map +0 -1
  23. package/dist/components/Modal.d.ts +0 -8
  24. package/dist/components/Modal.d.ts.map +0 -1
  25. package/dist/components/Modal.js.map +0 -1
  26. package/dist/components/Procaptcha.d.ts +0 -14
  27. package/dist/components/Procaptcha.d.ts.map +0 -1
  28. package/dist/components/Procaptcha.js.map +0 -1
  29. package/dist/components/ProcaptchaWidget.d.ts +0 -4
  30. package/dist/components/ProcaptchaWidget.d.ts.map +0 -1
  31. package/dist/components/ProcaptchaWidget.js.map +0 -1
  32. package/dist/components/collector.d.ts +0 -9
  33. package/dist/components/collector.d.ts.map +0 -1
  34. package/dist/components/collector.js +0 -26
  35. package/dist/components/collector.js.map +0 -1
  36. package/dist/components/index.d.ts +0 -6
  37. package/dist/components/index.d.ts.map +0 -1
  38. package/dist/components/index.js.map +0 -1
  39. package/dist/index.d.ts +0 -3
  40. package/dist/index.d.ts.map +0 -1
  41. package/dist/index.js.map +0 -1
  42. package/dist/util/index.d.ts +0 -9
  43. package/dist/util/index.d.ts.map +0 -1
  44. 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 as _jsx } from "@emotion/react/jsx-runtime";
2
- import { darkTheme, lightTheme } from "@prosopo/widget-skeleton";
3
- import { useMemo, useState, } from "react";
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
- 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: undefined,
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",
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 = ({ themeColor, buttonType, text, onClick, }) => {
30
- const theme = useMemo(() => (themeColor === "light" ? lightTheme : darkTheme), [themeColor]);
31
- const [hover, setHover] = useState(false);
32
- const buttonStyle = useMemo(() => {
33
- const baseStyle = {
34
- ...buttonStyleBase,
35
- border: `1px solid ${theme.palette.grey[500]}`,
36
- boxShadow: `0px 1px 3px 0px ${theme.palette.grey[500]}`,
37
- fontFamily: theme.font.fontFamily,
38
- width: "100%",
39
- color: hover
40
- ? theme.palette.primary.contrastText
41
- : theme.palette.background.contrastText,
42
- };
43
- if (buttonType === "cancel") {
44
- return {
45
- ...baseStyle,
46
- backgroundColor: hover ? theme.palette.grey[600] : "transparent",
47
- };
48
- }
49
- return {
50
- ...baseStyle,
51
- backgroundColor: hover
52
- ? theme.palette.primary.main
53
- : theme.palette.background.default,
54
- };
55
- }, [buttonType, hover, theme]);
56
- return (_jsx("button", { ...addDataAttr({ dev: { cy: `button-${buttonType}` } }), onMouseEnter: () => setHover(true), onMouseLeave: () => setHover(false), style: buttonStyle, onClick: (e) => {
57
- e.preventDefault();
58
- onClick();
59
- }, "aria-label": text, children: text }));
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 as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
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 { darkTheme, lightTheme } from "@prosopo/widget-skeleton";
6
- import { Suspense, useMemo } from "react";
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 = ({ challenge, index, solutions, onSubmit, onCancel, onClick, onNext, onReload, themeColor, }) => {
11
- const { t } = useTranslation();
12
- const captcha = challenge.captchas ? at(challenge.captchas, index) : null;
13
- const solution = solutions ? at(solutions, index) : [];
14
- const theme = useMemo(() => (themeColor === "light" ? lightTheme : darkTheme), [themeColor]);
15
- const doubleSpacing = `${theme.spacing.unit * 2}px`;
16
- const fullSpacing = `${theme.spacing.unit}px`;
17
- const halfSpacing = `${theme.spacing.half}px`;
18
- return (_jsx(Suspense, { fallback: _jsx("div", { children: "Loading..." }), children: _jsx("div", { style: {
19
- overflowX: "auto",
20
- overflowY: "auto",
21
- maxWidth: "500px",
22
- maxHeight: "100%",
23
- display: "flex",
24
- flexDirection: "column",
25
- border: "1px solid #dddddd",
26
- boxShadow: "rgba(255, 255, 255, 0.2) 0px 0px 4px",
27
- borderRadius: "4px",
28
- backgroundColor: theme.palette.background.default,
29
- userSelect: "none",
30
- touchAction: "none",
31
- overscrollBehavior: "none",
32
- }, children: _jsxs("div", { style: {
33
- backgroundColor: theme.palette.background.default,
34
- display: "flex",
35
- flexDirection: "column",
36
- minWidth: "300px",
37
- marginLeft: fullSpacing,
38
- marginRight: fullSpacing,
39
- justifyContent: "center",
40
- }, children: [_jsx("div", { style: {
41
- display: "flex",
42
- alignItems: "center",
43
- width: "100%",
44
- }, children: _jsx("div", { style: {
45
- backgroundColor: theme.palette.primary.main,
46
- width: "100%",
47
- marginTop: fullSpacing,
48
- }, children: _jsxs("div", { style: {
49
- padding: `${theme.spacing.half}px`,
50
- fontFamily: theme.font.fontFamily,
51
- }, children: [_jsxs("p", { style: {
52
- color: "#ffffff",
53
- fontWeight: 700,
54
- lineHeight: 1.5,
55
- }, children: [t("WIDGET.SELECT_ALL"), ":", "\u00A0", _jsx("span", { children: `${at(challenge.captchas, index).target} ` })] }), _jsx("p", { style: {
56
- color: "#ffffff",
57
- fontWeight: 500,
58
- lineHeight: 0.8,
59
- fontSize: "0.8rem",
60
- }, children: t("WIDGET.IF_NONE_CLICK_NEXT") })] }) }) }), _jsx("div", { ...addDataAttr({ dev: { cy: `captcha-${index}` } }), style: { overflow: "hidden" }, children: captcha && (_jsx(CaptchaWidget, { challenge: captcha, solution: solution, onClick: onClick, themeColor: themeColor })) }), _jsx("div", { style: {
61
- display: "flex",
62
- alignItems: "center",
63
- justifyContent: "space-between",
64
- lineHeight: 1.75,
65
- padding: `${fullSpacing} 0 ${doubleSpacing} 0`,
66
- }, children: _jsxs("div", { style: {
67
- width: "100%",
68
- height: "100%",
69
- display: "flex",
70
- flexDirection: "row",
71
- flexWrap: "wrap",
72
- justifyContent: "space-between",
73
- gap: "10px",
74
- }, children: [_jsx("div", { style: {
75
- position: "relative",
76
- flexGrow: 1,
77
- flexBasis: "calc(33.333% - 10px)",
78
- }, children: _jsx(Button, { themeColor: themeColor, buttonType: "cancel", onClick: onCancel, text: t("WIDGET.CANCEL"), "aria-label": t("WIDGET.CANCEL") }) }), _jsx("div", { style: {
79
- position: "relative",
80
- flexGrow: 1,
81
- flexBasis: "calc(33.333% - 10px)",
82
- }, children: _jsx(ReloadButton, { themeColor: themeColor, onReload: onReload }) }), _jsx("div", { style: {
83
- position: "relative",
84
- flexGrow: 1,
85
- flexBasis: "calc(33.333% - 10px)",
86
- }, children: _jsx(Button, { themeColor: themeColor, buttonType: "next", text: index < challenge.captchas.length - 1
87
- ? t("WIDGET.NEXT")
88
- : t("WIDGET.SUBMIT"), onClick: index < challenge.captchas.length - 1 ? onNext : onSubmit, "aria-label": index < challenge.captchas.length - 1
89
- ? t("WIDGET.NEXT")
90
- : t("WIDGET.SUBMIT"), "data-cy": "button-next" }) })] }) })] }) }) }));
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