@prosopo/procaptcha-react 2.9.96 → 2.9.97

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.
@@ -1,161 +1,115 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const jsxRuntime = require("@emotion/react/jsx-runtime");
4
- const common = require("@prosopo/common");
5
- const widgetSkeleton = require("@prosopo/widget-skeleton");
6
- const React = require("react");
7
- const getHash = (item) => {
8
- if (!item.hash) {
9
- throw new common.ProsopoDatasetError("CAPTCHA.MISSING_ITEM_HASH", {
10
- context: { item }
11
- });
12
- }
13
- return item.hash;
1
+ let _prosopo_common = require("@prosopo/common");
2
+ let _prosopo_widget_skeleton = require("@prosopo/widget-skeleton");
3
+ let react = require("react");
4
+ let _emotion_react_jsx_runtime = require("@emotion/react/jsx-runtime");
5
+ //#region src/components/CaptchaWidget.tsx
6
+ var getHash = (item) => {
7
+ if (!item.hash) throw new _prosopo_common.ProsopoDatasetError("CAPTCHA.MISSING_ITEM_HASH", { context: { item } });
8
+ return item.hash;
14
9
  };
15
- const CaptchaWidget = ({
16
- challenge,
17
- solution,
18
- onClick,
19
- themeColor
20
- }) => {
21
- const items = challenge.items;
22
- const theme = React.useMemo(
23
- () => themeColor === "light" ? widgetSkeleton.lightTheme : widgetSkeleton.darkTheme,
24
- [themeColor]
25
- );
26
- const fullSpacing = `${theme.spacing.unit}px`;
27
- const halfSpacing = `${theme.spacing.half}px`;
28
- return /* @__PURE__ */ jsxRuntime.jsx(
29
- "div",
30
- {
31
- style: {
32
- // expand to full height / width of parent
33
- width: "100%",
34
- height: "100%",
35
- // display children in flex, spreading them evenly and wrapping when row length exceeded
36
- display: "flex",
37
- flexDirection: "row",
38
- flexWrap: "wrap",
39
- justifyContent: "space-between",
40
- paddingBottom: fullSpacing,
41
- paddingTop: fullSpacing,
42
- gap: "10px"
43
- },
44
- children: items.map((item, index) => {
45
- const hash = getHash(item);
46
- const imageStyle = {
47
- // enable the items in the grid to grow in width to use up excess space
48
- flexGrow: 1,
49
- // make the width of each item 1/3rd of the width overall, i.e. 3 columns
50
- flexBasis: "calc(33.333% - 10px)",
51
- // include the padding / margin / border in the width
52
- boxSizing: "border-box"
53
- };
54
- return /* @__PURE__ */ jsxRuntime.jsx("div", { style: imageStyle, children: /* @__PURE__ */ jsxRuntime.jsxs(
55
- "div",
56
- {
57
- style: {
58
- position: "relative",
59
- cursor: "pointer",
60
- height: "100%",
61
- width: "100%",
62
- padding: 0,
63
- margin: 0
64
- },
65
- onClick: (e) => {
66
- if (!e.isTrusted) {
67
- return;
68
- }
69
- if ("touches" in e && e.touches.length > 0 && e.touches[0]) {
70
- onClick(hash, e.touches[0].clientX, e.touches[0].clientY);
71
- return;
72
- }
73
- if ("clientX" in e && "clientY" in e) {
74
- onClick(hash, e.clientX, e.clientY);
75
- return;
76
- }
77
- onClick(hash, 0, 0);
78
- },
79
- children: [
80
- /* @__PURE__ */ jsxRuntime.jsx(
81
- "img",
82
- {
83
- style: {
84
- width: "100%",
85
- // image should be full width / height of the item
86
- display: "block",
87
- // removes whitespace below imgs
88
- objectFit: "cover",
89
- // contain the entire image in the img tag
90
- aspectRatio: "1/1",
91
- // force AR to be 1, letterboxing images with different aspect ratios
92
- height: "auto",
93
- // make the img tag responsive to its container
94
- overflow: "hidden",
95
- borderStyle: "solid",
96
- borderWidth: "1px",
97
- borderColor: theme.palette.grey[300]
98
- },
99
- src: item.data,
100
- alt: `Captcha image ${index + 1}`,
101
- onError: (e) => {
102
- const target = e.currentTarget;
103
- target._retryCount = (target._retryCount || 0) + 1;
104
- if (target._retryCount <= 3) {
105
- target.src = `${item.data}?retry=${Date.now()}`;
106
- }
107
- }
108
- }
109
- ),
110
- /* @__PURE__ */ jsxRuntime.jsx(
111
- "div",
112
- {
113
- style: {
114
- position: "absolute",
115
- top: 0,
116
- left: 0,
117
- bottom: 0,
118
- right: 0,
119
- height: "100%",
120
- width: "100%",
121
- // display overlays in center
122
- display: "flex",
123
- alignItems: "center",
124
- justifyContent: "center",
125
- // make bg half opacity, i.e. shadowing the item's img
126
- backgroundColor: "rgba(0,0,0,0.5)",
127
- visibility: solution.some((s) => s[0] === hash) ? "visible" : "hidden"
128
- },
129
- children: /* @__PURE__ */ jsxRuntime.jsx(
130
- "svg",
131
- {
132
- style: {
133
- backgroundColor: "transparent",
134
- // img must be displayed as block otherwise gets a bottom whitespace border
135
- display: "block",
136
- // how big the overlay icon is
137
- width: "35%",
138
- height: "35%",
139
- transition: "fill 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms",
140
- userSelect: "none",
141
- fill: "currentcolor"
142
- },
143
- focusable: "false",
144
- color: "#fff",
145
- "aria-hidden": "true",
146
- viewBox: "0 0 24 24",
147
- "data-testid": "CheckIcon",
148
- "aria-label": "Check icon",
149
- children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z" })
150
- }
151
- )
152
- }
153
- )
154
- ]
155
- }
156
- ) }, item.hash);
157
- })
158
- }
159
- );
10
+ var CaptchaWidget = ({ challenge, solution, onClick, themeColor }) => {
11
+ const items = challenge.items;
12
+ const theme = (0, react.useMemo)(() => themeColor === "light" ? _prosopo_widget_skeleton.lightTheme : _prosopo_widget_skeleton.darkTheme, [themeColor]);
13
+ const fullSpacing = `${theme.spacing.unit}px`;
14
+ `${theme.spacing.half}`;
15
+ return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {
16
+ style: {
17
+ width: "100%",
18
+ height: "100%",
19
+ display: "flex",
20
+ flexDirection: "row",
21
+ flexWrap: "wrap",
22
+ justifyContent: "space-between",
23
+ paddingBottom: fullSpacing,
24
+ paddingTop: fullSpacing,
25
+ gap: "10px"
26
+ },
27
+ children: items.map((item, index) => {
28
+ const hash = getHash(item);
29
+ return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {
30
+ style: {
31
+ flexGrow: 1,
32
+ flexBasis: "calc(33.333% - 10px)",
33
+ boxSizing: "border-box"
34
+ },
35
+ children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)("div", {
36
+ style: {
37
+ position: "relative",
38
+ cursor: "pointer",
39
+ height: "100%",
40
+ width: "100%",
41
+ padding: 0,
42
+ margin: 0
43
+ },
44
+ onClick: (e) => {
45
+ if (!e.isTrusted) return;
46
+ if ("touches" in e && e.touches.length > 0 && e.touches[0]) {
47
+ onClick(hash, e.touches[0].clientX, e.touches[0].clientY);
48
+ return;
49
+ }
50
+ if ("clientX" in e && "clientY" in e) {
51
+ onClick(hash, e.clientX, e.clientY);
52
+ return;
53
+ }
54
+ onClick(hash, 0, 0);
55
+ },
56
+ children: [/* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("img", {
57
+ style: {
58
+ width: "100%",
59
+ display: "block",
60
+ objectFit: "cover",
61
+ aspectRatio: "1/1",
62
+ height: "auto",
63
+ overflow: "hidden",
64
+ borderStyle: "solid",
65
+ borderWidth: "1px",
66
+ borderColor: theme.palette.grey[300]
67
+ },
68
+ src: item.data,
69
+ alt: `Captcha image ${index + 1}`,
70
+ onError: (e) => {
71
+ const target = e.currentTarget;
72
+ target._retryCount = (target._retryCount || 0) + 1;
73
+ if (target._retryCount <= 3) target.src = `${item.data}?retry=${Date.now()}`;
74
+ }
75
+ }), /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {
76
+ style: {
77
+ position: "absolute",
78
+ top: 0,
79
+ left: 0,
80
+ bottom: 0,
81
+ right: 0,
82
+ height: "100%",
83
+ width: "100%",
84
+ display: "flex",
85
+ alignItems: "center",
86
+ justifyContent: "center",
87
+ backgroundColor: "rgba(0,0,0,0.5)",
88
+ visibility: solution.some((s) => s[0] === hash) ? "visible" : "hidden"
89
+ },
90
+ children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("svg", {
91
+ style: {
92
+ backgroundColor: "transparent",
93
+ display: "block",
94
+ width: "35%",
95
+ height: "35%",
96
+ transition: "fill 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms",
97
+ userSelect: "none",
98
+ fill: "currentcolor"
99
+ },
100
+ focusable: "false",
101
+ color: "#fff",
102
+ "aria-hidden": "true",
103
+ viewBox: "0 0 24 24",
104
+ "data-testid": "CheckIcon",
105
+ "aria-label": "Check icon",
106
+ 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" })
107
+ })
108
+ })]
109
+ })
110
+ }, item.hash);
111
+ })
112
+ });
160
113
  };
114
+ //#endregion
161
115
  exports.CaptchaWidget = CaptchaWidget;
@@ -1,9 +1,11 @@
1
- "use strict";
2
- const jsxRuntime = require("@emotion/react/jsx-runtime");
3
- const react = require("@emotion/react");
4
- const React = require("react");
5
- const reactDom = require("react-dom");
6
- const ModalInnerDivCSS = react.css`
1
+ const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
2
+ let react = require("react");
3
+ react = require_runtime.__toESM(react, 1);
4
+ let _emotion_react_jsx_runtime = require("@emotion/react/jsx-runtime");
5
+ let _emotion_react = require("@emotion/react");
6
+ let react_dom = require("react-dom");
7
+ //#region src/components/Modal.tsx
8
+ var ModalInnerDivCSS = _emotion_react.css`
7
9
  position: absolute;
8
10
  top: 50%;
9
11
  left: 50%;
@@ -23,21 +25,26 @@ const ModalInnerDivCSS = react.css`
23
25
  transform: translate(-50%, -100%);
24
26
  }
25
27
  `;
26
- const ModalComponent = React.memo((props) => {
27
- const { show, children } = props;
28
- const display = show ? "flex" : "none";
29
- const ModalOuterDivCss = {
30
- position: "fixed",
31
- zIndex: 2147483646,
32
- inset: 0,
33
- display,
34
- alignItems: "center",
35
- justifyContent: "center",
36
- minHeight: "100vh"
37
- };
38
- return reactDom.createPortal(
39
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "prosopo-modalOuter", style: ModalOuterDivCss, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "prosopo-modalInner", css: ModalInnerDivCSS, children }) }),
40
- document.body
41
- );
28
+ var ModalComponent = react.default.memo((props) => {
29
+ const { show, children } = props;
30
+ const ModalOuterDivCss = {
31
+ position: "fixed",
32
+ zIndex: 2147483646,
33
+ inset: 0,
34
+ display: show ? "flex" : "none",
35
+ alignItems: "center",
36
+ justifyContent: "center",
37
+ minHeight: "100vh"
38
+ };
39
+ return (0, react_dom.createPortal)(/* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {
40
+ className: "prosopo-modalOuter",
41
+ style: ModalOuterDivCss,
42
+ children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {
43
+ className: "prosopo-modalInner",
44
+ css: ModalInnerDivCSS,
45
+ children
46
+ })
47
+ }), document.body);
42
48
  });
43
- module.exports = ModalComponent;
49
+ //#endregion
50
+ exports.default = ModalComponent;
@@ -1,7 +1,7 @@
1
- "use strict";
2
- const jsxRuntime = require("@emotion/react/jsx-runtime");
3
- const React = require("react");
4
- const _interopNamespaceDefaultOnly = (e) => Object.freeze(Object.defineProperty({ __proto__: null, default: e }, Symbol.toStringTag, { value: "Module" }));
5
- const ProcaptchaWidget = React.lazy(async () => Promise.resolve().then(() => /* @__PURE__ */ _interopNamespaceDefaultOnly(require("./ProcaptchaWidget.cjs"))));
6
- const Procaptcha = (props) => /* @__PURE__ */ jsxRuntime.jsx(React.Suspense, { children: /* @__PURE__ */ jsxRuntime.jsx(ProcaptchaWidget, { ...props }) });
7
- module.exports = Procaptcha;
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;