@prosopo/procaptcha-react 2.11.2 → 2.12.0

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 (117) hide show
  1. package/.turbo/turbo-build$colon$cjs.log +13 -13
  2. package/.turbo/turbo-build$colon$tsc.log +21 -21
  3. package/.turbo/turbo-build.log +14 -13
  4. package/CHANGELOG.md +50 -0
  5. package/dist/cjs/components/button.cjs +100 -0
  6. package/dist/cjs/components/captchaComponent.cjs +210 -0
  7. package/dist/cjs/components/captchaWidget.cjs +203 -0
  8. package/dist/cjs/components/collector.cjs +49 -0
  9. package/dist/cjs/components/index.cjs +15 -6
  10. package/dist/cjs/components/modal.cjs +35 -0
  11. package/dist/cjs/components/procaptcha.cjs +23 -0
  12. package/dist/cjs/components/procaptchaWidget.cjs +166 -0
  13. package/dist/cjs/index.cjs +15 -6
  14. package/dist/cjs/util/index.cjs +6 -4
  15. package/dist/components/button.d.ts +9 -0
  16. package/dist/components/button.d.ts.map +1 -0
  17. package/dist/components/button.js +100 -0
  18. package/dist/components/button.js.map +1 -0
  19. package/dist/components/{CaptchaComponent.d.ts → captchaComponent.d.ts} +5 -3
  20. package/dist/components/captchaComponent.d.ts.map +1 -0
  21. package/dist/components/captchaComponent.js +210 -0
  22. package/dist/components/captchaComponent.js.map +1 -0
  23. package/dist/components/{CaptchaWidget.d.ts → captchaWidget.d.ts} +3 -2
  24. package/dist/components/captchaWidget.d.ts.map +1 -0
  25. package/dist/components/captchaWidget.js +203 -0
  26. package/dist/components/captchaWidget.js.map +1 -0
  27. package/dist/components/collector.d.ts +5 -4
  28. package/dist/components/collector.d.ts.map +1 -1
  29. package/dist/components/collector.js +46 -24
  30. package/dist/components/collector.js.map +1 -1
  31. package/dist/components/index.d.ts +7 -5
  32. package/dist/components/index.d.ts.map +1 -1
  33. package/dist/components/index.js +8 -4
  34. package/dist/components/index.js.map +1 -1
  35. package/dist/components/modal.d.ts +14 -0
  36. package/dist/components/modal.d.ts.map +1 -0
  37. package/dist/components/modal.js +35 -0
  38. package/dist/components/modal.js.map +1 -0
  39. package/dist/components/procaptcha.d.ts +7 -0
  40. package/dist/components/procaptcha.d.ts.map +1 -0
  41. package/dist/components/procaptcha.js +22 -0
  42. package/dist/components/procaptcha.js.map +1 -0
  43. package/dist/components/procaptchaWidget.d.ts +7 -0
  44. package/dist/components/procaptchaWidget.d.ts.map +1 -0
  45. package/dist/components/procaptchaWidget.js +166 -0
  46. package/dist/components/procaptchaWidget.js.map +1 -0
  47. package/dist/index.js +8 -4
  48. package/dist/tests/button.unit.test.d.ts.map +1 -1
  49. package/dist/tests/button.unit.test.js +69 -49
  50. package/dist/tests/button.unit.test.js.map +1 -1
  51. package/dist/tests/captchaComponent.unit.test.d.ts.map +1 -1
  52. package/dist/tests/captchaComponent.unit.test.js +31 -9
  53. package/dist/tests/captchaComponent.unit.test.js.map +1 -1
  54. package/dist/tests/captchaWidget.unit.test.d.ts.map +1 -1
  55. package/dist/tests/captchaWidget.unit.test.js +55 -9
  56. package/dist/tests/captchaWidget.unit.test.js.map +1 -1
  57. package/dist/tests/collector.unit.test.d.ts.map +1 -1
  58. package/dist/tests/collector.unit.test.js +43 -10
  59. package/dist/tests/collector.unit.test.js.map +1 -1
  60. package/dist/tests/harness.d.ts +2 -0
  61. package/dist/tests/harness.d.ts.map +1 -1
  62. package/dist/tests/harness.js +7 -0
  63. package/dist/tests/harness.js.map +1 -1
  64. package/dist/tests/modal.unit.test.d.ts.map +1 -1
  65. package/dist/tests/modal.unit.test.js +20 -7
  66. package/dist/tests/modal.unit.test.js.map +1 -1
  67. package/dist/tests/procaptcha.unit.test.d.ts.map +1 -1
  68. package/dist/tests/procaptcha.unit.test.js +37 -15
  69. package/dist/tests/procaptcha.unit.test.js.map +1 -1
  70. package/dist/tests/procaptchaReact.test-d.js +8 -6
  71. package/dist/tests/procaptchaReact.test-d.js.map +1 -1
  72. package/dist/tests/procaptchaWidget.unit.test.d.ts.map +1 -1
  73. package/dist/tests/procaptchaWidget.unit.test.js +112 -89
  74. package/dist/tests/procaptchaWidget.unit.test.js.map +1 -1
  75. package/dist/tests/render.d.ts +6 -7
  76. package/dist/tests/render.d.ts.map +1 -1
  77. package/dist/tests/render.js +23 -30
  78. package/dist/tests/render.js.map +1 -1
  79. package/dist/util/index.d.ts +8 -7
  80. package/dist/util/index.d.ts.map +1 -1
  81. package/dist/util/index.js +6 -4
  82. package/dist/util/index.js.map +1 -1
  83. package/package.json +8 -13
  84. package/vite.test.config.ts +1 -2
  85. package/dist/cjs/_virtual/_rolldown/runtime.cjs +0 -23
  86. package/dist/cjs/components/Button.cjs +0 -81
  87. package/dist/cjs/components/CaptchaComponent.cjs +0 -171
  88. package/dist/cjs/components/CaptchaWidget.cjs +0 -129
  89. package/dist/cjs/components/Modal.cjs +0 -35
  90. package/dist/cjs/components/Procaptcha.cjs +0 -7
  91. package/dist/cjs/components/ProcaptchaWidget.cjs +0 -168
  92. package/dist/components/Button.d.ts +0 -11
  93. package/dist/components/Button.d.ts.map +0 -1
  94. package/dist/components/Button.js +0 -81
  95. package/dist/components/Button.js.map +0 -1
  96. package/dist/components/CaptchaComponent.d.ts.map +0 -1
  97. package/dist/components/CaptchaComponent.js +0 -171
  98. package/dist/components/CaptchaComponent.js.map +0 -1
  99. package/dist/components/CaptchaWidget.d.ts.map +0 -1
  100. package/dist/components/CaptchaWidget.js +0 -129
  101. package/dist/components/CaptchaWidget.js.map +0 -1
  102. package/dist/components/Modal.d.ts +0 -13
  103. package/dist/components/Modal.d.ts.map +0 -1
  104. package/dist/components/Modal.js +0 -33
  105. package/dist/components/Modal.js.map +0 -1
  106. package/dist/components/Procaptcha.d.ts +0 -4
  107. package/dist/components/Procaptcha.d.ts.map +0 -1
  108. package/dist/components/Procaptcha.js +0 -7
  109. package/dist/components/Procaptcha.js.map +0 -1
  110. package/dist/components/ProcaptchaWidget.d.ts +0 -4
  111. package/dist/components/ProcaptchaWidget.d.ts.map +0 -1
  112. package/dist/components/ProcaptchaWidget.js +0 -168
  113. package/dist/components/ProcaptchaWidget.js.map +0 -1
  114. package/dist/tests/setup.d.ts +0 -5
  115. package/dist/tests/setup.d.ts.map +0 -1
  116. package/dist/tests/setup.js +0 -3
  117. package/dist/tests/setup.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"render.js","sourceRoot":"","sources":["../../src/tests/render.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAa,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAezD,MAAM,CAAC,MAAM,KAAK,GAAG,GAAY,EAAE;IAClC,MAAM,SAAS,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAChD,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IACrC,IAAI,IAAsB,CAAC;IAC3B,GAAG,CAAC,GAAG,EAAE;QACR,IAAI,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;IACH,IAAI,CAAC,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;IACpD,MAAM,OAAO,GAAG,IAAI,CAAC;IACrB,OAAO;QACN,SAAS;QACT,IAAI,EAAE,OAAO;QACb,MAAM,EAAE,CAAC,OAAqB,EAAE,EAAE;YACjC,GAAG,CAAC,GAAG,EAAE;gBACR,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YACzB,CAAC,CAAC,CAAC;QACJ,CAAC;QACD,OAAO,EAAE,GAAG,EAAE;YACb,GAAG,CAAC,GAAG,EAAE;gBACR,OAAO,CAAC,OAAO,EAAE,CAAC;YACnB,CAAC,CAAC,CAAC;YACH,SAAS,CAAC,MAAM,EAAE,CAAC;QACpB,CAAC;KACD,CAAC;AACH,CAAC,CAAC;AAeF,MAAM,UAAU,GAAG,CAAC,KAAY,EAAE,OAAgB,EAAQ,EAAE;IAC3D,KAA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K,GAAG,CAAC,GAAW,EAAU,EAAE;IAC5C,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IAEnC,MAAM,KAAK,GACV,KAAK,CAAC,MAAM,KAAK,CAAC;QACjB,CAAC,CAAC,KAAK;aACJ,KAAK,CAAC,EAAE,CAAC;aACT,GAAG,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;aACzB,IAAI,CAAC,EAAE,CAAC;QACX,CAAC,CAAC,KAAK,CAAC;IACV,MAAM,OAAO,GAAG,CAAC,KAAa,EAAU,EAAE,CACzC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACpD,OAAO,OAAO,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;AAC3D,CAAC,CAAC"}
@@ -1,9 +1,10 @@
1
+ import type { AttributeMap } from "@prosopo/procaptcha-common";
2
+ type DataValues = {
3
+ [key: string]: string;
4
+ };
1
5
  export default function addDataAttr({ general, dev, }: {
2
- general?: {
3
- [key: string]: string;
4
- };
5
- dev?: {
6
- [key: string]: string;
7
- };
8
- }): {};
6
+ general?: DataValues;
7
+ dev?: DataValues;
8
+ }): AttributeMap;
9
+ export {};
9
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":"AA0BA,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EACnC,OAAO,EACP,GAAG,GACH,EAAE;IACF,OAAO,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IACpC,GAAG,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;CAChC,MAOA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE/D,KAAK,UAAU,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC;AAkB5C,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EACnC,OAAO,EACP,GAAG,GACH,EAAE;IACF,OAAO,CAAC,EAAE,UAAU,CAAC;IACrB,GAAG,CAAC,EAAE,UAAU,CAAC;CACjB,GAAG,YAAY,CAOf"}
@@ -1,9 +1,11 @@
1
1
  //#region src/util/index.ts
2
2
  function renameKeysForDataAttr(data = {}) {
3
- return Object.keys(data).reduce((prev, curr) => ({
4
- ...prev,
5
- [`data-${curr}`]: data[curr]
6
- }), {});
3
+ const renamed = {};
4
+ for (const key of Object.keys(data)) {
5
+ const value = data[key];
6
+ if (void 0 !== value) renamed[`data-${key}`] = value;
7
+ }
8
+ return renamed;
7
9
  }
8
10
  /**
9
11
  * maps any data to data attributes (mapped to { data-[key]: value })
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":"AAaA,SAAS,qBAAqB,CAAC,OAAkC,EAAE;IAClE,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,CAE9B,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,QAAQ,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,EAC3D,EAAE,CACF,CAAC;AACH,CAAC;AAOD,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EACnC,OAAO,EACP,GAAG,GAIH;IACA,OAAO;QACN,GAAG,qBAAqB,CAAC,OAAO,CAAC;QACjC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY;YACxC,CAAC,CAAC,qBAAqB,CAAC,GAAG,CAAC;YAC5B,CAAC,CAAC,EAAE,CAAC;KACN,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":"AAiBA,SAAS,qBAAqB,CAAC,OAAmB,EAAE;IACnD,MAAM,OAAO,GAAe,EAAE,CAAC;IAC/B,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACrC,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;QACxB,IAAI,SAAS,KAAK,KAAK,EAAE,CAAC;YACzB,OAAO,CAAC,QAAQ,GAAG,EAAE,CAAC,GAAG,KAAK,CAAC;QAChC,CAAC;IACF,CAAC;IACD,OAAO,OAAO,CAAC;AAChB,CAAC;AAOD,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EACnC,OAAO,EACP,GAAG,GAIH;IACA,OAAO;QACN,GAAG,qBAAqB,CAAC,OAAO,CAAC;QACjC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY;YACxC,CAAC,CAAC,qBAAqB,CAAC,GAAG,CAAC;YAC5B,CAAC,CAAC,EAAE,CAAC;KACN,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prosopo/procaptcha-react",
3
- "version": "2.11.2",
3
+ "version": "2.12.0",
4
4
  "author": "PROSOPO LIMITED <info@prosopo.io>",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/index.js",
@@ -32,22 +32,17 @@
32
32
  },
33
33
  "browserslist": ["> 0.5%, last 2 versions, not dead"],
34
34
  "dependencies": {
35
- "@prosopo/common": "3.1.56",
36
- "@prosopo/locale": "3.4.3",
37
- "@prosopo/procaptcha": "2.11.14",
38
- "@prosopo/procaptcha-common": "2.14.2",
39
- "@prosopo/types": "5.8.5",
35
+ "@prosopo/common": "3.1.58",
36
+ "@prosopo/locale": "3.5.0",
37
+ "@prosopo/procaptcha": "2.11.17",
38
+ "@prosopo/procaptcha-common": "2.16.0",
39
+ "@prosopo/types": "5.9.2",
40
40
  "@prosopo/util": "3.3.10",
41
- "@prosopo/widget-skeleton": "2.8.7",
42
- "csstype": "3.2.3",
43
- "react": "19.3.0",
44
- "react-dom": "19.3.0"
41
+ "@prosopo/widget-skeleton": "2.8.7"
45
42
  },
46
43
  "devDependencies": {
47
- "@emotion/react": "11.14.0",
48
- "@prosopo/config": "3.3.17",
44
+ "@prosopo/config": "3.4.0",
49
45
  "@types/node": "22.10.2",
50
- "@types/react-dom": "19.3.0",
51
46
  "@vitest/coverage-v8": "4.1.11",
52
47
  "concurrently": "9.0.1",
53
48
  "del-cli": "6.0.0",
@@ -16,13 +16,12 @@ import { defineConfig, mergeConfig } from "vitest/config";
16
16
 
17
17
  process.env.NODE_ENV = "test";
18
18
 
19
- // Everything here is a React component, so the suite renders into a real DOM.
19
+ // Every component here builds real DOM, so the suite runs against jsdom.
20
20
  export default mergeConfig(
21
21
  ViteTestConfig(),
22
22
  defineConfig({
23
23
  test: {
24
24
  environment: "jsdom",
25
- setupFiles: ["./src/tests/setup.ts"],
26
25
  },
27
26
  }),
28
27
  );
@@ -1,23 +0,0 @@
1
- //#region \0rolldown/runtime.js
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
- key = keys[i];
11
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
- get: ((k) => from[k]).bind(null, key),
13
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
- });
15
- }
16
- return to;
17
- };
18
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
- value: mod,
20
- enumerable: true
21
- }) : target, mod));
22
- //#endregion
23
- exports.__toESM = __toESM;
@@ -1,81 +0,0 @@
1
- const require_index = require("../util/index.cjs");
2
- let _prosopo_procaptcha_common = require("@prosopo/procaptcha-common");
3
- let _prosopo_widget_skeleton = require("@prosopo/widget-skeleton");
4
- let react = require("react");
5
- let _emotion_react_jsx_runtime = require("@emotion/react/jsx-runtime");
6
- //#region src/components/Button.tsx
7
- var buttonStyleBase = {
8
- display: "inline-flex",
9
- alignItems: "center",
10
- justifyContent: "center",
11
- position: "relative",
12
- boxSizing: "border-box",
13
- outline: "0px",
14
- margin: "0px",
15
- cursor: "pointer",
16
- userSelect: "none",
17
- verticalAlign: "middle",
18
- appearance: void 0,
19
- textDecoration: "none",
20
- textTransform: "none",
21
- minWidth: "64px",
22
- minHeight: "40px",
23
- borderRadius: "100px",
24
- border: "none",
25
- 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, filter 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms",
26
- backgroundColor: "transparent"
27
- };
28
- var Button = ({ themeColor, buttonType, text, onClick }) => {
29
- const theme = (0, react.useMemo)(() => themeColor === "light" ? _prosopo_widget_skeleton.lightTheme : _prosopo_widget_skeleton.darkTheme, [themeColor]);
30
- const [hover, setHover] = (0, react.useState)(false);
31
- const [focusVisible, setFocusVisible] = (0, react.useState)(false);
32
- const buttonStyle = (0, react.useMemo)(() => {
33
- const baseStyle = {
34
- ...buttonStyleBase,
35
- ...theme.typography.labelLarge,
36
- borderRadius: theme.shape.button,
37
- fontFamily: theme.font.fontFamily,
38
- width: "100%"
39
- };
40
- if (buttonType === "cancel") return {
41
- ...baseStyle,
42
- padding: "8px 12px",
43
- backgroundColor: hover ? (0, _prosopo_widget_skeleton.withAlpha)(theme.palette.primary.main, theme.stateLayer.hover) : "transparent",
44
- color: theme.palette.primary.main
45
- };
46
- return {
47
- ...baseStyle,
48
- padding: "8px 24px",
49
- backgroundColor: theme.palette.primary.main,
50
- color: theme.palette.primary.contrastText,
51
- boxShadow: hover ? `inset 0 0 0 100px ${(0, _prosopo_widget_skeleton.withAlpha)(theme.palette.primary.contrastText, theme.stateLayer.hover)}` : theme.elevation.buttonPrimary
52
- };
53
- }, [
54
- buttonType,
55
- hover,
56
- theme
57
- ]);
58
- return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("button", {
59
- ...require_index.default({ dev: { cy: `button-${buttonType}` } }),
60
- onMouseEnter: () => setHover(true),
61
- onMouseLeave: () => setHover(false),
62
- onFocus: (e) => setFocusVisible(e.target.matches(":focus-visible")),
63
- onBlur: () => setFocusVisible(false),
64
- style: {
65
- ...buttonStyle,
66
- ...focusVisible ? {
67
- outline: `3px solid ${theme.palette.primary.main}`,
68
- outlineOffset: "2px"
69
- } : {}
70
- },
71
- onClick: (e) => {
72
- if (!(0, _prosopo_procaptcha_common.isEventTrusted)(e)) return;
73
- e.preventDefault();
74
- onClick();
75
- },
76
- "aria-label": text,
77
- children: text
78
- });
79
- };
80
- //#endregion
81
- exports.default = Button;
@@ -1,171 +0,0 @@
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_procaptcha_common = require("@prosopo/procaptcha-common");
5
- let _prosopo_widget_skeleton = require("@prosopo/widget-skeleton");
6
- let react = require("react");
7
- let _emotion_react_jsx_runtime = require("@emotion/react/jsx-runtime");
8
- let _prosopo_locale = require("@prosopo/locale");
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 ${theme.palette.border}`,
29
- boxShadow: theme.elevation.card,
30
- borderRadius: theme.shape.card,
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.primaryContainer.main,
56
- borderRadius: theme.shape.header,
57
- width: "100%",
58
- marginTop: fullSpacing
59
- },
60
- children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)("div", {
61
- style: {
62
- padding: "12px 14px",
63
- fontFamily: theme.font.fontFamily
64
- },
65
- children: [/* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)("p", {
66
- style: {
67
- ...theme.typography.titleMedium,
68
- color: theme.palette.primaryContainer.contrastText,
69
- margin: 0
70
- },
71
- children: [
72
- t("WIDGET.SELECT_ALL"),
73
- ":",
74
- "\xA0",
75
- /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("span", {
76
- style: {
77
- color: theme.palette.titleAccent,
78
- fontWeight: 700
79
- },
80
- children: `${captcha.target} `
81
- })
82
- ]
83
- }), /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("p", {
84
- style: {
85
- ...theme.typography.bodyMedium,
86
- color: theme.palette.onSurfaceVariant,
87
- margin: "4px 0 0 0"
88
- },
89
- children: t("WIDGET.IF_NONE_CLICK_NEXT")
90
- })]
91
- })
92
- })
93
- }),
94
- /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {
95
- ...require_index.default({ dev: { cy: `captcha-${index}` } }),
96
- style: { overflow: "hidden" },
97
- children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(require_CaptchaWidget.CaptchaWidget, {
98
- challenge: captcha,
99
- solution,
100
- onClick,
101
- themeColor
102
- })
103
- }),
104
- /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {
105
- style: {
106
- display: "flex",
107
- alignItems: "center",
108
- justifyContent: "space-between",
109
- lineHeight: 1.75,
110
- padding: `${fullSpacing} 0 ${doubleSpacing} 0`
111
- },
112
- children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)("div", {
113
- style: {
114
- width: "100%",
115
- height: "100%",
116
- display: "flex",
117
- flexDirection: "row",
118
- justifyContent: "space-between",
119
- gap: "10px"
120
- },
121
- children: [
122
- /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {
123
- style: {
124
- position: "relative",
125
- flexGrow: 1,
126
- flexBasis: "calc(33.333% - 10px)"
127
- },
128
- children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(require_Button.default, {
129
- themeColor,
130
- buttonType: "cancel",
131
- onClick: onCancel,
132
- text: t("WIDGET.CANCEL"),
133
- "aria-label": t("WIDGET.CANCEL")
134
- })
135
- }),
136
- /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {
137
- style: {
138
- position: "relative",
139
- flexGrow: 1,
140
- flexBasis: "calc(33.333% - 10px)"
141
- },
142
- children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(_prosopo_procaptcha_common.ReloadButton, {
143
- themeColor,
144
- onReload
145
- })
146
- }),
147
- /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {
148
- style: {
149
- position: "relative",
150
- flexGrow: 1,
151
- flexBasis: "calc(33.333% - 10px)"
152
- },
153
- children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(require_Button.default, {
154
- themeColor,
155
- buttonType: "next",
156
- text: index < challenge.captchas.length - 1 ? t("WIDGET.NEXT") : t("WIDGET.SUBMIT"),
157
- onClick: index < challenge.captchas.length - 1 ? onNext : onSubmit,
158
- "aria-label": index < challenge.captchas.length - 1 ? t("WIDGET.NEXT") : t("WIDGET.SUBMIT"),
159
- "data-cy": "button-next"
160
- })
161
- })
162
- ]
163
- })
164
- })
165
- ]
166
- })
167
- })
168
- });
169
- };
170
- //#endregion
171
- exports.default = CaptchaComponent;
@@ -1,129 +0,0 @@
1
- let _prosopo_common = require("@prosopo/common");
2
- let _prosopo_procaptcha_common = require("@prosopo/procaptcha-common");
3
- let _prosopo_widget_skeleton = require("@prosopo/widget-skeleton");
4
- let react = require("react");
5
- let _emotion_react_jsx_runtime = require("@emotion/react/jsx-runtime");
6
- //#region src/components/CaptchaWidget.tsx
7
- var getHash = (item) => {
8
- if (!item.hash) throw new _prosopo_common.ProsopoDatasetError("CAPTCHA.MISSING_ITEM_HASH", { context: { item } });
9
- return item.hash;
10
- };
11
- var CaptchaWidget = ({ challenge, solution, onClick, themeColor }) => {
12
- const items = challenge.items;
13
- const theme = (0, react.useMemo)(() => themeColor === "light" ? _prosopo_widget_skeleton.lightTheme : _prosopo_widget_skeleton.darkTheme, [themeColor]);
14
- const [focusedHash, setFocusedHash] = (0, react.useState)(null);
15
- const fullSpacing = `${theme.spacing.unit}px`;
16
- return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {
17
- style: {
18
- width: "100%",
19
- height: "100%",
20
- display: "flex",
21
- flexDirection: "row",
22
- flexWrap: "wrap",
23
- justifyContent: "space-between",
24
- paddingBottom: fullSpacing,
25
- paddingTop: fullSpacing,
26
- gap: "10px"
27
- },
28
- children: items.map((item, index) => {
29
- const hash = getHash(item);
30
- const selected = solution.some((s) => s[0] === hash);
31
- return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {
32
- style: {
33
- flexGrow: 1,
34
- flexBasis: "calc(33.333% - 10px)",
35
- boxSizing: "border-box"
36
- },
37
- children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)("button", {
38
- type: "button",
39
- "aria-pressed": selected,
40
- style: {
41
- position: "relative",
42
- cursor: "pointer",
43
- height: "100%",
44
- width: "100%",
45
- padding: 0,
46
- margin: 0,
47
- border: "none",
48
- background: "none",
49
- appearance: "none",
50
- display: "block",
51
- ...focusedHash === hash ? {
52
- outline: `3px solid ${theme.palette.primary.main}`,
53
- outlineOffset: "2px"
54
- } : { outline: "none" }
55
- },
56
- onFocus: (e) => setFocusedHash(e.target.matches(":focus-visible") ? hash : null),
57
- onBlur: () => setFocusedHash(null),
58
- onClick: (e) => {
59
- if (!(0, _prosopo_procaptcha_common.isEventTrusted)(e)) return;
60
- onClick(hash, e.clientX, e.clientY);
61
- },
62
- children: [/* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("img", {
63
- style: {
64
- width: "100%",
65
- display: "block",
66
- objectFit: "cover",
67
- aspectRatio: "1/1",
68
- height: "auto",
69
- overflow: "hidden",
70
- borderStyle: "solid",
71
- borderWidth: "1px",
72
- borderColor: theme.palette.tile.border,
73
- borderRadius: selected ? theme.shape.tileSelected : theme.shape.tile,
74
- transform: selected ? "scale(0.9)" : "none",
75
- transition: "transform 200ms cubic-bezier(0.2, 0, 0, 1), border-radius 200ms"
76
- },
77
- src: item.data,
78
- alt: `Captcha image ${index + 1}`,
79
- onError: (e) => {
80
- const target = e.currentTarget;
81
- const retryCount = Number(target.dataset.retryCount ?? "0") + 1;
82
- target.dataset.retryCount = String(retryCount);
83
- if (retryCount <= 3) target.src = `${item.data}?retry=${Date.now()}`;
84
- }
85
- }), /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {
86
- style: {
87
- position: "absolute",
88
- top: 0,
89
- left: 0,
90
- bottom: 0,
91
- right: 0,
92
- height: "100%",
93
- width: "100%",
94
- display: "flex",
95
- alignItems: "center",
96
- justifyContent: "center",
97
- backgroundColor: theme.palette.overlay,
98
- borderRadius: theme.shape.tileSelected,
99
- visibility: selected ? "visible" : "hidden"
100
- },
101
- children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("svg", {
102
- style: {
103
- backgroundColor: theme.palette.checkbox.fill,
104
- display: "block",
105
- width: "34px",
106
- height: "34px",
107
- padding: "7px",
108
- borderRadius: "50%",
109
- boxSizing: "border-box",
110
- transition: "fill 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms",
111
- userSelect: "none",
112
- fill: theme.palette.checkbox.tick
113
- },
114
- focusable: "false",
115
- color: "#fff",
116
- "aria-hidden": "true",
117
- viewBox: "0 0 24 24",
118
- "data-testid": "CheckIcon",
119
- "aria-label": "Check icon",
120
- children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("path", { d: "M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z" })
121
- })
122
- })]
123
- })
124
- }, item.hash);
125
- })
126
- });
127
- };
128
- //#endregion
129
- exports.CaptchaWidget = CaptchaWidget;
@@ -1,35 +0,0 @@
1
- const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
2
- let _prosopo_procaptcha_common = require("@prosopo/procaptcha-common");
3
- let react = require("react");
4
- react = require_runtime.__toESM(react, 1);
5
- let _emotion_react_jsx_runtime = require("@emotion/react/jsx-runtime");
6
- //#region src/components/Modal.tsx
7
- /** The image captcha's dialog frame; positioning lives in `ChallengeSurface`. */
8
- var ModalComponent = react.default.memo((props) => {
9
- const { show, children, placement, anchor, onDismiss, dialogLabel } = props;
10
- return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(_prosopo_procaptcha_common.ChallengeSurface, {
11
- show,
12
- placement,
13
- anchor,
14
- onDismiss,
15
- scrim: "none",
16
- className: "prosopo-modalOuter",
17
- dialogLabel,
18
- children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {
19
- className: "prosopo-modalInner",
20
- style: {
21
- maxWidth: "500px",
22
- maxHeight: "100%",
23
- backgroundColor: "transparent",
24
- border: "none",
25
- borderRadius: "28px",
26
- alignSelf: "center",
27
- boxSizing: "border-box"
28
- },
29
- children
30
- })
31
- });
32
- });
33
- ModalComponent.displayName = "ModalComponent";
34
- //#endregion
35
- exports.default = ModalComponent;
@@ -1,7 +0,0 @@
1
- let react = require("react");
2
- let _emotion_react_jsx_runtime = require("@emotion/react/jsx-runtime");
3
- //#region src/components/Procaptcha.tsx
4
- var ProcaptchaWidget = (0, react.lazy)(async () => Promise.resolve().then(() => require("./ProcaptchaWidget.cjs")));
5
- var Procaptcha = (props) => /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(react.Suspense, { children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(ProcaptchaWidget, { ...props }) });
6
- //#endregion
7
- exports.default = Procaptcha;