@prosopo/procaptcha-react 2.9.96 → 2.9.98

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 (80) hide show
  1. package/.turbo/turbo-build$colon$cjs.log +20 -35
  2. package/.turbo/turbo-build$colon$tsc.log +21 -21
  3. package/.turbo/turbo-build.log +21 -36
  4. package/CHANGELOG.md +41 -0
  5. package/dist/_virtual/_rolldown/runtime.js +3 -0
  6. package/dist/cjs/_virtual/_rolldown/runtime.cjs +23 -0
  7. package/dist/cjs/components/Button.cjs +68 -78
  8. package/dist/cjs/components/CaptchaComponent.cjs +164 -228
  9. package/dist/cjs/components/CaptchaWidget.cjs +104 -158
  10. package/dist/cjs/components/Modal.cjs +30 -23
  11. package/dist/cjs/components/Procaptcha.cjs +7 -7
  12. package/dist/cjs/components/ProcaptchaWidget.cjs +147 -163
  13. package/dist/cjs/components/index.cjs +6 -9
  14. package/dist/cjs/index.cjs +6 -9
  15. package/dist/cjs/util/index.cjs +17 -15
  16. package/dist/components/Button.js +67 -78
  17. package/dist/components/CaptchaComponent.d.ts.map +1 -1
  18. package/dist/components/CaptchaComponent.js +160 -225
  19. package/dist/components/CaptchaComponent.js.map +1 -1
  20. package/dist/components/CaptchaWidget.d.ts.map +1 -1
  21. package/dist/components/CaptchaWidget.js +103 -157
  22. package/dist/components/CaptchaWidget.js.map +1 -1
  23. package/dist/components/Modal.js +24 -21
  24. package/dist/components/Procaptcha.js +6 -6
  25. package/dist/components/ProcaptchaWidget.d.ts.map +1 -1
  26. package/dist/components/ProcaptchaWidget.js +146 -162
  27. package/dist/components/ProcaptchaWidget.js.map +1 -1
  28. package/dist/components/index.js +3 -8
  29. package/dist/index.js +4 -9
  30. package/dist/tests/button.unit.test.d.ts +2 -0
  31. package/dist/tests/button.unit.test.d.ts.map +1 -0
  32. package/dist/tests/button.unit.test.js +113 -0
  33. package/dist/tests/button.unit.test.js.map +1 -0
  34. package/dist/tests/captchaComponent.unit.test.d.ts +2 -0
  35. package/dist/tests/captchaComponent.unit.test.d.ts.map +1 -0
  36. package/dist/tests/captchaComponent.unit.test.js +141 -0
  37. package/dist/tests/captchaComponent.unit.test.js.map +1 -0
  38. package/dist/tests/captchaWidget.unit.test.d.ts +2 -0
  39. package/dist/tests/captchaWidget.unit.test.d.ts.map +1 -0
  40. package/dist/tests/captchaWidget.unit.test.js +191 -0
  41. package/dist/tests/captchaWidget.unit.test.js.map +1 -0
  42. package/dist/tests/collector.unit.test.d.ts +2 -0
  43. package/dist/tests/collector.unit.test.d.ts.map +1 -0
  44. package/dist/tests/collector.unit.test.js +109 -0
  45. package/dist/tests/collector.unit.test.js.map +1 -0
  46. package/dist/tests/harness.d.ts +12 -0
  47. package/dist/tests/harness.d.ts.map +1 -0
  48. package/dist/tests/harness.js +69 -0
  49. package/dist/tests/harness.js.map +1 -0
  50. package/dist/tests/modal.unit.test.d.ts +2 -0
  51. package/dist/tests/modal.unit.test.d.ts.map +1 -0
  52. package/dist/tests/modal.unit.test.js +72 -0
  53. package/dist/tests/modal.unit.test.js.map +1 -0
  54. package/dist/tests/procaptcha.unit.test.d.ts +2 -0
  55. package/dist/tests/procaptcha.unit.test.d.ts.map +1 -0
  56. package/dist/tests/procaptcha.unit.test.js +57 -0
  57. package/dist/tests/procaptcha.unit.test.js.map +1 -0
  58. package/dist/tests/procaptchaReact.test-d.d.ts +2 -0
  59. package/dist/tests/procaptchaReact.test-d.d.ts.map +1 -0
  60. package/dist/tests/procaptchaReact.test-d.js +72 -0
  61. package/dist/tests/procaptchaReact.test-d.js.map +1 -0
  62. package/dist/tests/procaptchaWidget.unit.test.d.ts +2 -0
  63. package/dist/tests/procaptchaWidget.unit.test.d.ts.map +1 -0
  64. package/dist/tests/procaptchaWidget.unit.test.js +403 -0
  65. package/dist/tests/procaptchaWidget.unit.test.js.map +1 -0
  66. package/dist/tests/render.d.ts +23 -0
  67. package/dist/tests/render.d.ts.map +1 -0
  68. package/dist/tests/render.js +77 -0
  69. package/dist/tests/render.js.map +1 -0
  70. package/dist/tests/setup.d.ts +5 -0
  71. package/dist/tests/setup.d.ts.map +1 -0
  72. package/dist/tests/setup.js +3 -0
  73. package/dist/tests/setup.js.map +1 -0
  74. package/dist/tests/util.unit.test.d.ts +2 -0
  75. package/dist/tests/util.unit.test.d.ts.map +1 -0
  76. package/dist/tests/util.unit.test.js +84 -0
  77. package/dist/tests/util.unit.test.js.map +1 -0
  78. package/dist/util/index.js +17 -16
  79. package/package.json +16 -12
  80. package/vite.test.config.ts +28 -0
@@ -1,229 +1,165 @@
1
- "use strict";
2
- const jsxRuntime = require("@emotion/react/jsx-runtime");
3
- const locale = require("@prosopo/locale");
4
- const procaptchaCommon = require("@prosopo/procaptcha-common");
5
- const util = require("@prosopo/util");
6
- const widgetSkeleton = require("@prosopo/widget-skeleton");
7
- const React = require("react");
8
- const index = require("../util/index.cjs");
9
- const Button = require("./Button.cjs");
10
- const CaptchaWidget = require("./CaptchaWidget.cjs");
11
- const CaptchaComponent = ({
12
- challenge,
13
- index: index$1,
14
- solutions,
15
- onSubmit,
16
- onCancel,
17
- onClick,
18
- onNext,
19
- onReload,
20
- themeColor
21
- }) => {
22
- const { t } = locale.useTranslation();
23
- const captcha = challenge.captchas ? util.at(challenge.captchas, index$1) : null;
24
- const solution = solutions ? util.at(solutions, index$1) : [];
25
- const theme = React.useMemo(
26
- () => themeColor === "light" ? widgetSkeleton.lightTheme : widgetSkeleton.darkTheme,
27
- [themeColor]
28
- );
29
- const doubleSpacing = `${theme.spacing.unit * 2}px`;
30
- const fullSpacing = `${theme.spacing.unit}px`;
31
- const halfSpacing = `${theme.spacing.half}px`;
32
- return /* @__PURE__ */ jsxRuntime.jsx(React.Suspense, { fallback: /* @__PURE__ */ jsxRuntime.jsx("div", { children: "Loading..." }), children: /* @__PURE__ */ jsxRuntime.jsx(
33
- "div",
34
- {
35
- style: {
36
- // introduce scroll bars when screen < minWidth of children
37
- overflowX: "auto",
38
- overflowY: "auto",
39
- maxWidth: "500px",
40
- maxHeight: "100%",
41
- display: "flex",
42
- flexDirection: "column",
43
- border: "1px solid #dddddd",
44
- boxShadow: "rgba(255, 255, 255, 0.2) 0px 0px 4px",
45
- borderRadius: "4px",
46
- backgroundColor: theme.palette.background.default,
47
- userSelect: "none",
48
- touchAction: "none",
49
- overscrollBehavior: "none"
50
- },
51
- children: /* @__PURE__ */ jsxRuntime.jsxs(
52
- "div",
53
- {
54
- style: {
55
- backgroundColor: theme.palette.background.default,
56
- display: "flex",
57
- flexDirection: "column",
58
- minWidth: "300px",
59
- marginLeft: fullSpacing,
60
- marginRight: fullSpacing,
61
- justifyContent: "center"
62
- },
63
- children: [
64
- /* @__PURE__ */ jsxRuntime.jsx(
65
- "div",
66
- {
67
- style: {
68
- display: "flex",
69
- alignItems: "center",
70
- width: "100%"
71
- },
72
- children: /* @__PURE__ */ jsxRuntime.jsx(
73
- "div",
74
- {
75
- style: {
76
- backgroundColor: theme.palette.primary.main,
77
- width: "100%",
78
- marginTop: fullSpacing
79
- },
80
- children: /* @__PURE__ */ jsxRuntime.jsxs(
81
- "div",
82
- {
83
- style: {
84
- padding: `${theme.spacing.half}px`,
85
- fontFamily: theme.font.fontFamily
86
- },
87
- children: [
88
- /* @__PURE__ */ jsxRuntime.jsxs(
89
- "p",
90
- {
91
- style: {
92
- color: "#ffffff",
93
- fontWeight: 700,
94
- lineHeight: 1.5
95
- },
96
- children: [
97
- t("WIDGET.SELECT_ALL"),
98
- ":",
99
- " ",
100
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: `${util.at(challenge.captchas, index$1).target} ` })
101
- ]
102
- }
103
- ),
104
- /* @__PURE__ */ jsxRuntime.jsx(
105
- "p",
106
- {
107
- style: {
108
- color: "#ffffff",
109
- fontWeight: 500,
110
- lineHeight: 0.8,
111
- fontSize: "0.8rem"
112
- },
113
- children: t("WIDGET.IF_NONE_CLICK_NEXT")
114
- }
115
- )
116
- ]
117
- }
118
- )
119
- }
120
- )
121
- }
122
- ),
123
- /* @__PURE__ */ jsxRuntime.jsx(
124
- "div",
125
- {
126
- ...index({ dev: { cy: `captcha-${index$1}` } }),
127
- style: { overflow: "hidden" },
128
- children: captcha && /* @__PURE__ */ jsxRuntime.jsx(
129
- CaptchaWidget.CaptchaWidget,
130
- {
131
- challenge: captcha,
132
- solution,
133
- onClick,
134
- themeColor
135
- }
136
- )
137
- }
138
- ),
139
- /* @__PURE__ */ jsxRuntime.jsx(
140
- "div",
141
- {
142
- style: {
143
- display: "flex",
144
- alignItems: "center",
145
- justifyContent: "space-between",
146
- lineHeight: 1.75,
147
- padding: `${fullSpacing} 0 ${doubleSpacing} 0`
148
- },
149
- children: /* @__PURE__ */ jsxRuntime.jsxs(
150
- "div",
151
- {
152
- style: {
153
- // expand to full height / width of parent
154
- width: "100%",
155
- height: "100%",
156
- // display children in flex, spreading them evenly
157
- display: "flex",
158
- flexDirection: "row",
159
- justifyContent: "space-between",
160
- gap: "10px"
161
- },
162
- children: [
163
- /* @__PURE__ */ jsxRuntime.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__ */ jsxRuntime.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__ */ jsxRuntime.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__ */ jsxRuntime.jsx(procaptchaCommon.ReloadButton, { themeColor, onReload })
194
- }
195
- ),
196
- /* @__PURE__ */ jsxRuntime.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__ */ jsxRuntime.jsx(
206
- Button,
207
- {
208
- themeColor,
209
- buttonType: "next",
210
- text: index$1 < challenge.captchas.length - 1 ? t("WIDGET.NEXT") : t("WIDGET.SUBMIT"),
211
- onClick: index$1 < challenge.captchas.length - 1 ? onNext : onSubmit,
212
- "aria-label": index$1 < 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
- ) });
1
+ const require_CaptchaWidget = require("./CaptchaWidget.cjs");
2
+ const require_index = require("../util/index.cjs");
3
+ const require_Button = require("./Button.cjs");
4
+ let _prosopo_widget_skeleton = require("@prosopo/widget-skeleton");
5
+ let react = require("react");
6
+ let _emotion_react_jsx_runtime = require("@emotion/react/jsx-runtime");
7
+ let _prosopo_locale = require("@prosopo/locale");
8
+ let _prosopo_procaptcha_common = require("@prosopo/procaptcha-common");
9
+ let _prosopo_util = require("@prosopo/util");
10
+ //#region src/components/CaptchaComponent.tsx
11
+ var CaptchaComponent = ({ challenge, index, solutions, onSubmit, onCancel, onClick, onNext, onReload, themeColor }) => {
12
+ const { t } = (0, _prosopo_locale.useTranslation)();
13
+ const captcha = (0, _prosopo_util.at)(challenge.captchas, index, { noWrap: true });
14
+ const solution = (0, _prosopo_util.at)(solutions, index, { noWrap: true });
15
+ const theme = (0, react.useMemo)(() => themeColor === "light" ? _prosopo_widget_skeleton.lightTheme : _prosopo_widget_skeleton.darkTheme, [themeColor]);
16
+ const doubleSpacing = `${theme.spacing.unit * 2}px`;
17
+ const fullSpacing = `${theme.spacing.unit}px`;
18
+ return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(react.Suspense, {
19
+ fallback: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", { children: "Loading..." }),
20
+ children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {
21
+ style: {
22
+ overflowX: "auto",
23
+ overflowY: "auto",
24
+ maxWidth: "500px",
25
+ maxHeight: "100%",
26
+ display: "flex",
27
+ flexDirection: "column",
28
+ border: "1px solid #dddddd",
29
+ boxShadow: "rgba(255, 255, 255, 0.2) 0px 0px 4px",
30
+ borderRadius: "4px",
31
+ backgroundColor: theme.palette.background.default,
32
+ userSelect: "none",
33
+ touchAction: "none",
34
+ overscrollBehavior: "none"
35
+ },
36
+ children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)("div", {
37
+ style: {
38
+ backgroundColor: theme.palette.background.default,
39
+ display: "flex",
40
+ flexDirection: "column",
41
+ minWidth: "300px",
42
+ marginLeft: fullSpacing,
43
+ marginRight: fullSpacing,
44
+ justifyContent: "center"
45
+ },
46
+ children: [
47
+ /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {
48
+ style: {
49
+ display: "flex",
50
+ alignItems: "center",
51
+ width: "100%"
52
+ },
53
+ children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {
54
+ style: {
55
+ backgroundColor: theme.palette.primary.main,
56
+ width: "100%",
57
+ marginTop: fullSpacing
58
+ },
59
+ children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)("div", {
60
+ style: {
61
+ padding: `${theme.spacing.half}px`,
62
+ fontFamily: theme.font.fontFamily
63
+ },
64
+ children: [/* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)("p", {
65
+ style: {
66
+ color: "#ffffff",
67
+ fontWeight: 700,
68
+ lineHeight: 1.5
69
+ },
70
+ children: [
71
+ t("WIDGET.SELECT_ALL"),
72
+ ":",
73
+ "\xA0",
74
+ /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("span", { children: `${captcha.target} ` })
75
+ ]
76
+ }), /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("p", {
77
+ style: {
78
+ color: "#ffffff",
79
+ fontWeight: 500,
80
+ lineHeight: .8,
81
+ fontSize: "0.8rem"
82
+ },
83
+ children: t("WIDGET.IF_NONE_CLICK_NEXT")
84
+ })]
85
+ })
86
+ })
87
+ }),
88
+ /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {
89
+ ...require_index.default({ dev: { cy: `captcha-${index}` } }),
90
+ style: { overflow: "hidden" },
91
+ children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(require_CaptchaWidget.CaptchaWidget, {
92
+ challenge: captcha,
93
+ solution,
94
+ onClick,
95
+ themeColor
96
+ })
97
+ }),
98
+ /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {
99
+ style: {
100
+ display: "flex",
101
+ alignItems: "center",
102
+ justifyContent: "space-between",
103
+ lineHeight: 1.75,
104
+ padding: `${fullSpacing} 0 ${doubleSpacing} 0`
105
+ },
106
+ children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)("div", {
107
+ style: {
108
+ width: "100%",
109
+ height: "100%",
110
+ display: "flex",
111
+ flexDirection: "row",
112
+ justifyContent: "space-between",
113
+ gap: "10px"
114
+ },
115
+ children: [
116
+ /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {
117
+ style: {
118
+ position: "relative",
119
+ flexGrow: 1,
120
+ flexBasis: "calc(33.333% - 10px)"
121
+ },
122
+ children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(require_Button.default, {
123
+ themeColor,
124
+ buttonType: "cancel",
125
+ onClick: onCancel,
126
+ text: t("WIDGET.CANCEL"),
127
+ "aria-label": t("WIDGET.CANCEL")
128
+ })
129
+ }),
130
+ /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {
131
+ style: {
132
+ position: "relative",
133
+ flexGrow: 1,
134
+ flexBasis: "calc(33.333% - 10px)"
135
+ },
136
+ children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(_prosopo_procaptcha_common.ReloadButton, {
137
+ themeColor,
138
+ onReload
139
+ })
140
+ }),
141
+ /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {
142
+ style: {
143
+ position: "relative",
144
+ flexGrow: 1,
145
+ flexBasis: "calc(33.333% - 10px)"
146
+ },
147
+ children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(require_Button.default, {
148
+ themeColor,
149
+ buttonType: "next",
150
+ text: index < challenge.captchas.length - 1 ? t("WIDGET.NEXT") : t("WIDGET.SUBMIT"),
151
+ onClick: index < challenge.captchas.length - 1 ? onNext : onSubmit,
152
+ "aria-label": index < challenge.captchas.length - 1 ? t("WIDGET.NEXT") : t("WIDGET.SUBMIT"),
153
+ "data-cy": "button-next"
154
+ })
155
+ })
156
+ ]
157
+ })
158
+ })
159
+ ]
160
+ })
161
+ })
162
+ });
228
163
  };
229
- module.exports = CaptchaComponent;
164
+ //#endregion
165
+ exports.default = CaptchaComponent;