@prosopo/procaptcha-react 2.11.3 → 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 +41 -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,5 +1,5 @@
1
1
 
2
- > @prosopo/procaptcha-react@2.11.3 build:cjs
2
+ > @prosopo/procaptcha-react@2.12.0 build:cjs
3
3
  > NODE_ENV=${NODE_ENV:-development}; vite build --config vite.cjs.config.ts --mode $NODE_ENV
4
4
 
5
5
  ViteCommonJSConfig: .
@@ -47,18 +47,18 @@ ViteCommonJSConfig: .
47
47
  vite v8.1.5 building ssr environment for production...
48
48
  Bundle build started
49
49
  
50
- ✓ 10 modules transformed.
50
+ ✓ 11 modules transformed.
51
51
  rendering chunks...
52
52
  computing gzip size...
53
- dist/cjs/components/index.cjs 0.35 kB │ gzip: 0.12 kB
54
- dist/cjs/index.cjs 0.46 kB │ gzip: 0.18 kB
55
- dist/cjs/components/Procaptcha.cjs 0.49 kB │ gzip: 0.27 kB
56
- dist/cjs/util/index.cjs 0.50 kB │ gzip: 0.32 kB
57
- dist/cjs/_virtual/_rolldown/runtime.cjs 1.00 kB │ gzip: 0.50 kB
58
- dist/cjs/components/Modal.cjs 1.18 kB │ gzip: 0.60 kB
59
- dist/cjs/components/Button.cjs 2.86 kB │ gzip: 1.18 kB
60
- dist/cjs/components/CaptchaWidget.cjs 4.52 kB │ gzip: 1.68 kB
61
- dist/cjs/components/CaptchaComponent.cjs 6.18 kB │ gzip: 1.57 kB
62
- dist/cjs/components/ProcaptchaWidget.cjs 6.95 kB │ gzip: 2.02 kB
53
+ dist/cjs/util/index.cjs 0.56 kB │ gzip: 0.35 kB
54
+ dist/cjs/components/procaptcha.cjs 0.75 kB │ gzip: 0.41 kB
55
+ dist/cjs/components/index.cjs 0.89 kB │ gzip: 0.22 kB
56
+ dist/cjs/index.cjs 1.04 kB │ gzip: 0.28 kB
57
+ dist/cjs/components/modal.cjs 1.10 kB │ gzip: 0.55 kB
58
+ dist/cjs/components/collector.cjs 1.53 kB │ gzip: 0.68 kB
59
+ dist/cjs/components/button.cjs 3.31 kB │ gzip: 1.23 kB
60
+ dist/cjs/components/procaptchaWidget.cjs 6.33 kB │ gzip: 2.06 kB
61
+ dist/cjs/components/captchaWidget.cjs 6.47 kB │ gzip: 2.29 kB
62
+ dist/cjs/components/captchaComponent.cjs 7.25 kB │ gzip: 1.89 kB
63
63
 
64
- ✓ built in 60ms
64
+ ✓ built in 48ms
@@ -1,8 +1,8 @@
1
1
 
2
- > @prosopo/procaptcha-react@2.11.3 build:tsc
2
+ > @prosopo/procaptcha-react@2.12.0 build:tsc
3
3
  > tsc --build --verbose
4
4
 
5
- 2:43:00 PM - Projects in this build:
5
+ 11:04:34 AM - Projects in this build:
6
6
  * ../../dev/config/tsconfig.json
7
7
  * ../locale/tsconfig.json
8
8
  * ../util/tsconfig.json
@@ -22,41 +22,41 @@
22
22
  * ../procaptcha/tsconfig.json
23
23
  * tsconfig.json
24
24
 
25
- 2:43:01 PM - Project '../../dev/config/tsconfig.json' is up to date because newest input '../../dev/config/src/webpack/webpack.config.ts' is older than output '../../dev/config/tsconfig.tsbuildinfo'
25
+ 11:04:34 AM - Project '../../dev/config/tsconfig.json' is up to date because newest input '../../dev/config/src/vite/NodejsPolarsDirnamePlugin.ts' is older than output '../../dev/config/tsconfig.tsbuildinfo'
26
26
 
27
- 2:43:01 PM - Project '../locale/tsconfig.json' is up to date because newest input '../locale/src/translationKey.ts' is older than output '../locale/tsconfig.tsbuildinfo'
27
+ 11:04:34 AM - Project '../locale/tsconfig.json' is up to date because newest input '../locale/src/process.ts' is older than output '../locale/tsconfig.tsbuildinfo'
28
28
 
29
- 2:43:01 PM - Project '../util/tsconfig.json' is up to date because newest input '../util/src/url.ts' is older than output '../util/tsconfig.tsbuildinfo'
29
+ 11:04:34 AM - Project '../util/tsconfig.json' is up to date because newest input '../util/src/ofLen.ts' is older than output '../util/tsconfig.tsbuildinfo'
30
30
 
31
- 2:43:01 PM - Project '../logger/tsconfig.json' is up to date because newest input '../logger/src/index.ts' is older than output '../logger/tsconfig.tsbuildinfo'
31
+ 11:04:34 AM - Project '../logger/tsconfig.json' is up to date because newest input '../logger/src/index.ts' is older than output '../logger/tsconfig.tsbuildinfo'
32
32
 
33
- 2:43:01 PM - Project '../util-crypto/tsconfig.json' is up to date because newest input '../util-crypto/src/types.ts' is older than output '../util-crypto/tsconfig.tsbuildinfo'
33
+ 11:04:34 AM - Project '../util-crypto/tsconfig.json' is up to date because newest input '../util-crypto/src/types.ts' is older than output '../util-crypto/tsconfig.tsbuildinfo'
34
34
 
35
- 2:43:01 PM - Project '../types/tsconfig.json' is up to date because newest input '../types/src/types.test-d.ts' is older than output '../types/tsconfig.tsbuildinfo'
35
+ 11:04:34 AM - Project '../types/tsconfig.json' is up to date because newest input '../types/src/types.test-d.ts' is older than output '../types/tsconfig.tsbuildinfo'
36
36
 
37
- 2:43:01 PM - Project '../common/tsconfig.json' is up to date because newest input '../common/src/utils/batches.ts' is older than output '../common/tsconfig.tsbuildinfo'
37
+ 11:04:34 AM - Project '../common/tsconfig.json' is up to date because newest input '../common/src/utils/batches.ts' is older than output '../common/tsconfig.tsbuildinfo'
38
38
 
39
- 2:43:01 PM - Project '../datasets/tsconfig.json' is up to date because newest input '../datasets/src/index.ts' is older than output '../datasets/tsconfig.tsbuildinfo'
39
+ 11:04:34 AM - Project '../datasets/tsconfig.json' is up to date because newest input '../datasets/src/index.ts' is older than output '../datasets/tsconfig.tsbuildinfo'
40
40
 
41
- 2:43:01 PM - Project '../api/tsconfig.json' is up to date because newest input '../api/src/index.ts' is older than output '../api/tsconfig.tsbuildinfo'
41
+ 11:04:34 AM - Project '../api/tsconfig.json' is up to date because newest input '../api/src/index.ts' is older than output '../api/tsconfig.tsbuildinfo'
42
42
 
43
- 2:43:01 PM - Project '../load-balancer/tsconfig.json' is up to date because newest input '../load-balancer/src/tests/productionProviderList.unit.test.ts' is older than output '../load-balancer/tsconfig.tsbuildinfo'
43
+ 11:04:34 AM - Project '../load-balancer/tsconfig.json' is up to date because newest input '../load-balancer/src/balancer.ts' is older than output '../load-balancer/tsconfig.tsbuildinfo'
44
44
 
45
- 2:43:01 PM - Project '../widget-skeleton/tsconfig.json' is up to date because newest input '../widget-skeleton/src/webComponent/createWebComponent.ts' is older than output '../widget-skeleton/tsconfig.tsbuildinfo'
45
+ 11:04:34 AM - Project '../widget-skeleton/tsconfig.json' is up to date because newest input '../widget-skeleton/src/index.ts' is older than output '../widget-skeleton/tsconfig.tsbuildinfo'
46
46
 
47
- 2:43:01 PM - Project '../fingerprintjs/tsconfig.json' is up to date because newest input '../fingerprintjs/src/utils/browser.ts' is older than output '../fingerprintjs/tsconfig.tsbuildinfo'
47
+ 11:04:34 AM - Project '../fingerprintjs/tsconfig.json' is up to date because newest input '../fingerprintjs/src/utils/async.ts' is older than output '../fingerprintjs/tsconfig.tsbuildinfo'
48
48
 
49
- 2:43:01 PM - Project '../fingerprint/tsconfig.json' is up to date because newest input '../fingerprint/src/index.ts' is older than output '../fingerprint/tsconfig.tsbuildinfo'
49
+ 11:04:34 AM - Project '../fingerprint/tsconfig.json' is up to date because newest input '../fingerprint/src/index.ts' is older than output '../fingerprint/tsconfig.tsbuildinfo'
50
50
 
51
- 2:43:01 PM - Project '../keyring/tsconfig.json' is up to date because newest input '../keyring/src/pair/decode.ts' is older than output '../keyring/tsconfig.tsbuildinfo'
51
+ 11:04:34 AM - Project '../keyring/tsconfig.json' is up to date because newest input '../keyring/src/keyring/keyring.test.ts' is older than output '../keyring/tsconfig.tsbuildinfo'
52
52
 
53
- 2:43:01 PM - Project '../account/tsconfig.json' is up to date because newest input '../account/src/workers/cryptoWorker.ts' is older than output '../account/tsconfig.tsbuildinfo'
53
+ 11:04:34 AM - Project '../account/tsconfig.json' is up to date because newest input '../account/src/custom.d.ts' is older than output '../account/tsconfig.tsbuildinfo'
54
54
 
55
- 2:43:01 PM - Project '../procaptcha-common/tsconfig.json' is up to date because newest input '../procaptcha-common/src/tests/challengeSurfaceRender.unit.test.tsx' is older than output '../procaptcha-common/tsconfig.tsbuildinfo'
55
+ 11:04:34 AM - Project '../procaptcha-common/tsconfig.json' is up to date because newest input '../procaptcha-common/src/tests/challengeSurfaceRender.unit.test.ts' is older than output '../procaptcha-common/tsconfig.tsbuildinfo'
56
56
 
57
- 2:43:01 PM - Project '../procaptcha/tsconfig.json' is up to date because newest input '../procaptcha/src/modules/Manager.ts' is older than output '../procaptcha/tsconfig.tsbuildinfo'
57
+ 11:04:34 AM - Project '../procaptcha/tsconfig.json' is up to date because newest input '../procaptcha/src/modules/Manager.ts' is older than output '../procaptcha/tsconfig.tsbuildinfo'
58
58
 
59
- 2:43:01 PM - Project 'tsconfig.json' is out of date because output file 'tsconfig.tsbuildinfo' does not exist
59
+ 11:04:34 AM - Project 'tsconfig.json' is out of date because output file 'tsconfig.tsbuildinfo' does not exist
60
60
 
61
- 2:43:01 PM - Building project '/home/runner/work/captcha/captcha/packages/procaptcha-react/tsconfig.json'...
61
+ 11:04:34 AM - Building project '/home/runner/work/captcha/captcha/packages/procaptcha-react/tsconfig.json'...
62
62
 
@@ -1,9 +1,9 @@
1
1
 
2
- > @prosopo/procaptcha-react@2.11.3 build
2
+ > @prosopo/procaptcha-react@2.12.0 build
3
3
  > npm run build:cross-env -- --mode ${NODE_ENV:-development}
4
4
 
5
5
 
6
- > @prosopo/procaptcha-react@2.11.3 build:cross-env
6
+ > @prosopo/procaptcha-react@2.12.0 build:cross-env
7
7
  > vite build --config vite.esm.config.ts --mode production
8
8
 
9
9
  ViteEsmConfig: .
@@ -51,18 +51,19 @@ ViteEsmConfig: .
51
51
  vite v8.1.5 building ssr environment for production...
52
52
  Bundle build started
53
53
  
54
- ✓ 10 modules transformed.
54
+ ✓ 11 modules transformed.
55
55
  rendering chunks...
56
56
  computing gzip size...
57
57
  dist/_virtual/_rolldown/runtime.js 0.04 kB │ gzip: 0.06 kB
58
- dist/components/index.js 0.20 kB │ gzip: 0.09 kB
59
- dist/index.js 0.27 kB │ gzip: 0.13 kB
60
- dist/components/Procaptcha.js 0.37 kB │ gzip: 0.24 kB
61
- dist/util/index.js 0.50 kB │ gzip: 0.33 kB
62
- dist/components/Modal.js 0.93 kB │ gzip: 0.53 kB
63
- dist/components/Button.js 2.62 kB │ gzip: 1.15 kB
64
- dist/components/CaptchaWidget.js 4.16 kB │ gzip: 1.64 kB
65
- dist/components/CaptchaComponent.js 5.27 kB │ gzip: 1.52 kB
66
- dist/components/ProcaptchaWidget.js 6.20 kB │ gzip: 1.97 kB
58
+ dist/components/index.js 0.53 kB │ gzip: 0.19 kB
59
+ dist/util/index.js 0.56 kB │ gzip: 0.35 kB
60
+ dist/index.js 0.65 kB │ gzip: 0.21 kB
61
+ dist/components/procaptcha.js 0.68 kB │ gzip: 0.38 kB
62
+ dist/components/modal.js 1.01 kB │ gzip: 0.53 kB
63
+ dist/components/collector.js 1.44 kB │ gzip: 0.66 kB
64
+ dist/components/button.js 3.07 kB │ gzip: 1.21 kB
65
+ dist/components/captchaWidget.js 5.98 kB │ gzip: 2.27 kB
66
+ dist/components/procaptchaWidget.js 6.00 kB │ gzip: 2.05 kB
67
+ dist/components/captchaComponent.js 6.34 kB │ gzip: 1.85 kB
67
68
 
68
- ✓ built in 71ms
69
+ ✓ built in 45ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,46 @@
1
1
  # @prosopo/procaptcha-react
2
2
 
3
+ ## 2.12.0
4
+ ### Minor Changes
5
+
6
+ - 59c02da: Replace React with vanilla TS/DOM in the widget.
7
+
8
+ The widget packages no longer depend on react, react-dom, @emotion or
9
+ react-i18next: every component is now a `mount*` function returning a handle
10
+ with `update`/`destroy`. `useTranslation` is replaced by `createTranslator`,
11
+ which exposes i18next's `t` plus the events that used to trigger a re-render.
12
+ The rendered markup, styling and behaviour are unchanged — only the
13
+ implementation is.
14
+
15
+ Everything the widget has gained since this rewrite started is carried over,
16
+ so nothing is lost by dropping React: the shared challenge surface (popup and
17
+ float placement, escape/outside-click dismissal and the dialog focus trap),
18
+ the image-tile and puzzle-piece keyboard paths, the checkbox's focus handover
19
+ across the loading swap, the server-rendered puzzle imagery, `startMode:
20
+ "manual"` with `window.procaptcha.start()`, `data-bind` / targeted
21
+ `execute(widgetId)`, the Web Bot Auth "authenticated" badge, the client
22
+ session id, and the bounded session re-mint and reload handling in the
23
+ frictionless wrapper.
24
+
25
+ ### Patch Changes
26
+
27
+ - Updated dependencies [59c02da]
28
+ - @prosopo/procaptcha-common@2.16.0
29
+ - @prosopo/locale@3.5.0
30
+ - @prosopo/procaptcha@2.11.17
31
+ - @prosopo/common@3.1.58
32
+ - @prosopo/types@5.9.2
33
+
34
+ ## 2.11.4
35
+ ### Patch Changes
36
+
37
+ - Updated dependencies [a22069d]
38
+ - @prosopo/types@5.9.1
39
+ - @prosopo/locale@3.4.4
40
+ - @prosopo/common@3.1.57
41
+ - @prosopo/procaptcha@2.11.16
42
+ - @prosopo/procaptcha-common@2.15.1
43
+
3
44
  ## 2.11.3
4
45
  ### Patch Changes
5
46
 
@@ -0,0 +1,100 @@
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
+ //#region src/components/button.ts
5
+ var 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
+ textDecoration: "none",
17
+ textTransform: "none",
18
+ minWidth: "64px",
19
+ minHeight: "40px",
20
+ borderRadius: "100px",
21
+ border: "none",
22
+ 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",
23
+ backgroundColor: "transparent"
24
+ };
25
+ var mountButton = (container, initialProps) => {
26
+ const teardown = new _prosopo_procaptcha_common.Teardown();
27
+ let props = initialProps;
28
+ let hover = false;
29
+ let focusVisible = false;
30
+ const button = (0, _prosopo_procaptcha_common.createElement)("button");
31
+ const buttonStyle = () => {
32
+ const theme = "light" === props.themeColor ? _prosopo_widget_skeleton.lightTheme : _prosopo_widget_skeleton.darkTheme;
33
+ const baseStyle = {
34
+ ...buttonStyleBase,
35
+ ...theme.typography.labelLarge,
36
+ borderRadius: theme.shape.button,
37
+ fontFamily: theme.font.fontFamily,
38
+ width: "100%",
39
+ outline: focusVisible ? `3px solid ${theme.palette.primary.main}` : "0px",
40
+ outlineOffset: focusVisible ? "2px" : void 0
41
+ };
42
+ if ("cancel" === props.buttonType) return {
43
+ ...baseStyle,
44
+ padding: "8px 12px",
45
+ backgroundColor: hover ? (0, _prosopo_widget_skeleton.withAlpha)(theme.palette.primary.main, theme.stateLayer.hover) : "transparent",
46
+ color: theme.palette.primary.main,
47
+ boxShadow: void 0
48
+ };
49
+ return {
50
+ ...baseStyle,
51
+ padding: "8px 24px",
52
+ backgroundColor: theme.palette.primary.main,
53
+ color: theme.palette.primary.contrastText,
54
+ boxShadow: hover ? `inset 0 0 0 100px ${(0, _prosopo_widget_skeleton.withAlpha)(theme.palette.primary.contrastText, theme.stateLayer.hover)}` : theme.elevation.buttonPrimary
55
+ };
56
+ };
57
+ const render = () => {
58
+ (0, _prosopo_procaptcha_common.applyStyles)(button, buttonStyle());
59
+ (0, _prosopo_procaptcha_common.applyAttributes)(button, {
60
+ ...require_index.default({ dev: { cy: `button-${props.buttonType}` } }),
61
+ "aria-label": props.text
62
+ });
63
+ button.textContent = props.text;
64
+ };
65
+ teardown.addEventListener(button, "mouseenter", () => {
66
+ hover = true;
67
+ render();
68
+ });
69
+ teardown.addEventListener(button, "mouseleave", () => {
70
+ hover = false;
71
+ render();
72
+ });
73
+ teardown.addEventListener(button, "focus", () => {
74
+ focusVisible = button.matches(":focus-visible");
75
+ render();
76
+ });
77
+ teardown.addEventListener(button, "blur", () => {
78
+ focusVisible = false;
79
+ render();
80
+ });
81
+ teardown.addEventListener(button, "click", (event) => {
82
+ if (!(0, _prosopo_procaptcha_common.isEventTrusted)(event)) return;
83
+ event.preventDefault();
84
+ props.onClick();
85
+ });
86
+ render();
87
+ container.appendChild(button);
88
+ return {
89
+ update: (nextProps) => {
90
+ props = nextProps;
91
+ render();
92
+ },
93
+ destroy: () => {
94
+ teardown.run();
95
+ button.parentNode?.removeChild(button);
96
+ }
97
+ };
98
+ };
99
+ //#endregion
100
+ exports.mountButton = mountButton;
@@ -0,0 +1,210 @@
1
+ const require_index = require("../util/index.cjs");
2
+ const require_button = require("./button.cjs");
3
+ const require_captchaWidget = require("./captchaWidget.cjs");
4
+ let _prosopo_procaptcha_common = require("@prosopo/procaptcha-common");
5
+ let _prosopo_widget_skeleton = require("@prosopo/widget-skeleton");
6
+ let _prosopo_util = require("@prosopo/util");
7
+ //#region src/components/captchaComponent.ts
8
+ var outerStyle = (theme) => ({
9
+ overflowX: "auto",
10
+ overflowY: "auto",
11
+ maxWidth: "500px",
12
+ maxHeight: "100%",
13
+ display: "flex",
14
+ flexDirection: "column",
15
+ border: `1px solid ${theme.palette.border}`,
16
+ boxShadow: theme.elevation.card,
17
+ borderRadius: theme.shape.card,
18
+ backgroundColor: theme.palette.background.default,
19
+ userSelect: "none",
20
+ touchAction: "none",
21
+ overscrollBehavior: "none"
22
+ });
23
+ var promptStyle = (theme) => ({
24
+ ...theme.typography.titleMedium,
25
+ color: theme.palette.primaryContainer.contrastText,
26
+ margin: 0
27
+ });
28
+ var hintStyle = (theme) => ({
29
+ ...theme.typography.bodyMedium,
30
+ color: theme.palette.onSurfaceVariant,
31
+ margin: "4px 0 0 0"
32
+ });
33
+ var targetStyle = (theme) => ({
34
+ color: theme.palette.titleAccent,
35
+ fontWeight: 700
36
+ });
37
+ var columnStyle = {
38
+ position: "relative",
39
+ flexGrow: 1,
40
+ flexBasis: "calc(33.333% - 10px)"
41
+ };
42
+ var mountCaptchaComponent = (container, initialProps) => {
43
+ let props = initialProps;
44
+ const themeOf = (themeColor) => "light" === themeColor ? _prosopo_widget_skeleton.lightTheme : _prosopo_widget_skeleton.darkTheme;
45
+ const currentCaptcha = () => (0, _prosopo_util.at)(props.challenge.captchas, props.index, { noWrap: true });
46
+ const currentSolution = () => (0, _prosopo_util.at)(props.solutions, props.index, { noWrap: true });
47
+ const isLastRound = () => props.index >= props.challenge.captchas.length - 1;
48
+ const theme = themeOf(props.themeColor);
49
+ const doubleSpacing = `${theme.spacing.unit * 2}px`;
50
+ const fullSpacing = `${theme.spacing.unit}px`;
51
+ const targetLabel = (0, _prosopo_procaptcha_common.createElement)("span", { style: targetStyle(theme) });
52
+ const promptText = (0, _prosopo_procaptcha_common.createElement)("p", { style: promptStyle(theme) });
53
+ const hintText = (0, _prosopo_procaptcha_common.createElement)("p", { style: hintStyle(theme) });
54
+ const header = (0, _prosopo_procaptcha_common.createElement)("div", {
55
+ style: {
56
+ padding: "12px 14px",
57
+ fontFamily: theme.font.fontFamily
58
+ },
59
+ children: [promptText, hintText]
60
+ });
61
+ const headerBar = (0, _prosopo_procaptcha_common.createElement)("div", {
62
+ style: {
63
+ backgroundColor: theme.palette.primaryContainer.main,
64
+ borderRadius: theme.shape.header,
65
+ width: "100%",
66
+ marginTop: fullSpacing
67
+ },
68
+ children: [header]
69
+ });
70
+ const headerRow = (0, _prosopo_procaptcha_common.createElement)("div", {
71
+ style: {
72
+ display: "flex",
73
+ alignItems: "center",
74
+ width: "100%"
75
+ },
76
+ children: [headerBar]
77
+ });
78
+ const gridHost = (0, _prosopo_procaptcha_common.createElement)("div", {
79
+ style: { overflow: "hidden" },
80
+ attributes: require_index.default({ dev: { cy: `captcha-${props.index}` } })
81
+ });
82
+ const cancelHost = (0, _prosopo_procaptcha_common.createElement)("div", { style: columnStyle });
83
+ const reloadHost = (0, _prosopo_procaptcha_common.createElement)("div", { style: columnStyle });
84
+ const nextHost = (0, _prosopo_procaptcha_common.createElement)("div", { style: columnStyle });
85
+ const controls = (0, _prosopo_procaptcha_common.createElement)("div", {
86
+ style: {
87
+ width: "100%",
88
+ height: "100%",
89
+ display: "flex",
90
+ flexDirection: "row",
91
+ justifyContent: "space-between",
92
+ gap: "10px"
93
+ },
94
+ children: [
95
+ cancelHost,
96
+ reloadHost,
97
+ nextHost
98
+ ]
99
+ });
100
+ const controlsRow = (0, _prosopo_procaptcha_common.createElement)("div", {
101
+ style: {
102
+ display: "flex",
103
+ alignItems: "center",
104
+ justifyContent: "space-between",
105
+ lineHeight: 1.75,
106
+ padding: `${fullSpacing} 0 ${doubleSpacing} 0`
107
+ },
108
+ children: [controls]
109
+ });
110
+ const inner = (0, _prosopo_procaptcha_common.createElement)("div", {
111
+ style: {
112
+ backgroundColor: theme.palette.background.default,
113
+ display: "flex",
114
+ flexDirection: "column",
115
+ minWidth: "300px",
116
+ marginLeft: fullSpacing,
117
+ marginRight: fullSpacing,
118
+ justifyContent: "center"
119
+ },
120
+ children: [
121
+ headerRow,
122
+ gridHost,
123
+ controlsRow
124
+ ]
125
+ });
126
+ const root = (0, _prosopo_procaptcha_common.createElement)("div", {
127
+ style: outerStyle(theme),
128
+ children: [inner]
129
+ });
130
+ const grid = require_captchaWidget.mountCaptchaWidget(gridHost, {
131
+ challenge: currentCaptcha(),
132
+ solution: currentSolution(),
133
+ onClick: props.onClick,
134
+ themeColor: props.themeColor
135
+ });
136
+ const cancelButton = require_button.mountButton(cancelHost, {
137
+ themeColor: props.themeColor,
138
+ buttonType: "cancel",
139
+ onClick: () => props.onCancel(),
140
+ text: props.translator.t("WIDGET.CANCEL")
141
+ });
142
+ const reloadButton = (0, _prosopo_procaptcha_common.mountReloadButton)(reloadHost, {
143
+ themeColor: props.themeColor,
144
+ onReload: () => props.onReload()
145
+ });
146
+ const nextButton = require_button.mountButton(nextHost, {
147
+ themeColor: props.themeColor,
148
+ buttonType: "next",
149
+ onClick: () => isLastRound() ? props.onSubmit() : props.onNext(),
150
+ text: props.translator.t("WIDGET.SUBMIT")
151
+ });
152
+ const render = () => {
153
+ const activeTheme = themeOf(props.themeColor);
154
+ (0, _prosopo_procaptcha_common.applyStyles)(root, outerStyle(activeTheme));
155
+ (0, _prosopo_procaptcha_common.applyStyles)(inner, { backgroundColor: activeTheme.palette.background.default });
156
+ (0, _prosopo_procaptcha_common.applyStyles)(headerBar, {
157
+ backgroundColor: activeTheme.palette.primaryContainer.main,
158
+ borderRadius: activeTheme.shape.header
159
+ });
160
+ (0, _prosopo_procaptcha_common.applyStyles)(header, { fontFamily: activeTheme.font.fontFamily });
161
+ (0, _prosopo_procaptcha_common.applyStyles)(promptText, promptStyle(activeTheme));
162
+ (0, _prosopo_procaptcha_common.applyStyles)(hintText, hintStyle(activeTheme));
163
+ (0, _prosopo_procaptcha_common.applyStyles)(targetLabel, targetStyle(activeTheme));
164
+ const t = props.translator.t;
165
+ targetLabel.textContent = `${currentCaptcha().target} `;
166
+ promptText.textContent = `${t("WIDGET.SELECT_ALL")}:\u00a0`;
167
+ promptText.appendChild(targetLabel);
168
+ hintText.textContent = t("WIDGET.IF_NONE_CLICK_NEXT");
169
+ (0, _prosopo_procaptcha_common.applyAttributes)(gridHost, require_index.default({ dev: { cy: `captcha-${props.index}` } }));
170
+ grid.update({
171
+ challenge: currentCaptcha(),
172
+ solution: currentSolution(),
173
+ onClick: props.onClick,
174
+ themeColor: props.themeColor
175
+ });
176
+ cancelButton.update({
177
+ themeColor: props.themeColor,
178
+ buttonType: "cancel",
179
+ onClick: () => props.onCancel(),
180
+ text: t("WIDGET.CANCEL")
181
+ });
182
+ reloadButton.update({
183
+ themeColor: props.themeColor,
184
+ onReload: () => props.onReload()
185
+ });
186
+ nextButton.update({
187
+ themeColor: props.themeColor,
188
+ buttonType: "next",
189
+ onClick: () => isLastRound() ? props.onSubmit() : props.onNext(),
190
+ text: isLastRound() ? t("WIDGET.SUBMIT") : t("WIDGET.NEXT")
191
+ });
192
+ };
193
+ render();
194
+ container.appendChild(root);
195
+ return {
196
+ update: (nextProps) => {
197
+ props = nextProps;
198
+ render();
199
+ },
200
+ destroy: () => {
201
+ grid.destroy();
202
+ cancelButton.destroy();
203
+ reloadButton.destroy();
204
+ nextButton.destroy();
205
+ root.parentNode?.removeChild(root);
206
+ }
207
+ };
208
+ };
209
+ //#endregion
210
+ exports.mountCaptchaComponent = mountCaptchaComponent;