@prosopo/procaptcha-react 0.2.17 → 0.2.19
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.
- package/README.md +4 -9
- package/dist/cjs/components/Button.cjs +68 -0
- package/dist/cjs/components/CaptchaComponent.cjs +64 -41
- package/dist/cjs/components/CaptchaWidget.cjs +41 -36
- package/dist/cjs/components/Checkbox.cjs +56 -0
- package/dist/cjs/components/ExtensionAccountSelect.cjs +26 -26
- package/dist/cjs/components/LoadingSpinner.cjs +30 -0
- package/dist/cjs/components/Modal.cjs +35 -0
- package/dist/cjs/components/Procaptcha.cjs +140 -134
- package/dist/cjs/components/collector.cjs +25 -0
- package/dist/cjs/components/theme.cjs +27 -12
- package/dist/components/Button.d.ts +10 -0
- package/dist/components/Button.d.ts.map +1 -0
- package/dist/components/Button.js +59 -0
- package/dist/components/Button.js.map +1 -0
- package/dist/components/CaptchaComponent.d.ts +1 -1
- package/dist/components/CaptchaComponent.d.ts.map +1 -1
- package/dist/components/CaptchaComponent.js +23 -11
- package/dist/components/CaptchaComponent.js.map +1 -1
- package/dist/components/CaptchaWidget.d.ts +2 -1
- package/dist/components/CaptchaWidget.d.ts.map +1 -1
- package/dist/components/CaptchaWidget.js +40 -35
- package/dist/components/CaptchaWidget.js.map +1 -1
- package/dist/components/Checkbox.d.ts +9 -0
- package/dist/components/Checkbox.d.ts.map +1 -0
- package/dist/components/Checkbox.js +43 -0
- package/dist/components/Checkbox.js.map +1 -0
- package/dist/components/ExtensionAccountSelect.d.ts +1 -1
- package/dist/components/ExtensionAccountSelect.d.ts.map +1 -1
- package/dist/components/ExtensionAccountSelect.js +7 -6
- package/dist/components/ExtensionAccountSelect.js.map +1 -1
- package/dist/components/LoadingSpinner.d.ts +6 -0
- package/dist/components/LoadingSpinner.d.ts.map +1 -0
- package/dist/components/LoadingSpinner.js +28 -0
- package/dist/components/LoadingSpinner.js.map +1 -0
- package/dist/components/Modal.d.ts +8 -0
- package/dist/components/Modal.d.ts.map +1 -0
- package/dist/components/Modal.js +35 -0
- package/dist/components/Modal.js.map +1 -0
- package/dist/components/Procaptcha.d.ts.map +1 -1
- package/dist/components/Procaptcha.js +48 -47
- package/dist/components/Procaptcha.js.map +1 -1
- package/dist/components/collector.d.ts +8 -0
- package/dist/components/collector.d.ts.map +1 -0
- package/dist/components/collector.js +25 -0
- package/dist/components/collector.js.map +1 -0
- package/dist/components/theme.d.ts +50 -2
- package/dist/components/theme.d.ts.map +1 -1
- package/dist/components/theme.js +23 -8
- package/dist/components/theme.js.map +1 -1
- package/package.json +9 -5
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ See the [client example](https://github.com/prosopo/client-example) for a minima
|
|
|
19
19
|
in a frontend app.
|
|
20
20
|
|
|
21
21
|
```jsx
|
|
22
|
-
<Procaptcha config={config} callbacks={{ onAccountNotFound, onError, onHuman, onExpired }}/>
|
|
22
|
+
<Procaptcha config={config} callbacks={{ onAccountNotFound, onError, onHuman, onExpired }} />
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
### Callbacks
|
|
@@ -48,7 +48,7 @@ The `onHuman` callback is called when the user has successfully completed the ca
|
|
|
48
48
|
object contains the following fields:
|
|
49
49
|
|
|
50
50
|
| Key | Type | Description |
|
|
51
|
-
|
|
51
|
+
| ------------ | ------ | ----------------------------------------------------------------------------------------------------------------------------- |
|
|
52
52
|
| commitmentId | string | The commitment ID of the captcha challenge. This is used to verify the user's response on-chain. |
|
|
53
53
|
| providerUrl | string | The URL of the provider that the user used to solve the captcha challenge. |
|
|
54
54
|
| dapp | string | The SITE_KEY of your application / website |
|
|
@@ -83,12 +83,7 @@ our [React Demo](https://github.com/prosopo/captcha/blob/main/demos/client-examp
|
|
|
83
83
|
The Procaptcha component is called as follows:
|
|
84
84
|
|
|
85
85
|
```tsx
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
<Procaptcha
|
|
89
|
-
config={config}
|
|
90
|
-
callbacks={{onAccountNotFound, onError, onHuman, onExpired}}
|
|
91
|
-
/>
|
|
86
|
+
<Procaptcha config={config} callbacks={{ onAccountNotFound, onError, onHuman, onExpired }} />
|
|
92
87
|
```
|
|
93
88
|
|
|
94
89
|
A config object is required and must contain your SITE_KEY. The callbacks are optional and can be used to handle the
|
|
@@ -119,7 +114,7 @@ const config: ProcaptchaConfigOptional = {
|
|
|
119
114
|
### Config Options
|
|
120
115
|
|
|
121
116
|
| Key | Type | Description |
|
|
122
|
-
|
|
117
|
+
| ------------------ | ------ | --------------------------------------------------------------------------------------- |
|
|
123
118
|
| account | string | The SITE_KEY you received when you signed up |
|
|
124
119
|
| web2 | string | Set to `true` to enable web2 support |
|
|
125
120
|
| dappName | string | The name of your application / website |
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
3
|
+
const theme = require("./theme.cjs");
|
|
4
|
+
const React = require("react");
|
|
5
|
+
const index = require("../util/index.cjs");
|
|
6
|
+
const buttonStyleBase = {
|
|
7
|
+
display: "inline-flex",
|
|
8
|
+
alignItems: "center",
|
|
9
|
+
justifyContent: "center",
|
|
10
|
+
position: "relative",
|
|
11
|
+
boxSizing: "border-box",
|
|
12
|
+
outline: "0px",
|
|
13
|
+
border: "0px",
|
|
14
|
+
margin: "0px",
|
|
15
|
+
cursor: "pointer",
|
|
16
|
+
userSelect: "none",
|
|
17
|
+
verticalAlign: "middle",
|
|
18
|
+
appearance: void 0,
|
|
19
|
+
textDecoration: "none",
|
|
20
|
+
fontWeight: "500",
|
|
21
|
+
fontSize: "0.875rem",
|
|
22
|
+
lineHeight: "1.75",
|
|
23
|
+
letterSpacing: "0.02857em",
|
|
24
|
+
textTransform: "uppercase",
|
|
25
|
+
minWidth: "64px",
|
|
26
|
+
padding: "6px 16px",
|
|
27
|
+
borderRadius: "4px",
|
|
28
|
+
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",
|
|
29
|
+
color: "rgb(0, 0, 0)",
|
|
30
|
+
backgroundColor: "#ffffff",
|
|
31
|
+
boxShadow: "rgba(0, 0, 0, 0.2) 0px 3px 1px -2px, rgba(0, 0, 0, 0.14) 0px 2px 2px 0px, rgba(0, 0, 0, 0.12) 0px 1px 5px 0px"
|
|
32
|
+
};
|
|
33
|
+
const Button = ({ themeColor, buttonType, text, onClick }) => {
|
|
34
|
+
const theme$1 = React.useMemo(() => themeColor === "light" ? theme.lightTheme : theme.darkTheme, [themeColor]);
|
|
35
|
+
const [hover, setHover] = React.useState(false);
|
|
36
|
+
const buttonStyle = React.useMemo(() => {
|
|
37
|
+
const baseStyle = {
|
|
38
|
+
...buttonStyleBase,
|
|
39
|
+
color: hover ? theme$1.palette.primary.contrastText : theme$1.palette.background.contrastText
|
|
40
|
+
};
|
|
41
|
+
if (buttonType === "cancel") {
|
|
42
|
+
return {
|
|
43
|
+
...baseStyle,
|
|
44
|
+
backgroundColor: hover ? theme$1.palette.grey[600] : "transparent"
|
|
45
|
+
};
|
|
46
|
+
} else {
|
|
47
|
+
return {
|
|
48
|
+
...baseStyle,
|
|
49
|
+
backgroundColor: hover ? theme$1.palette.primary.main : theme$1.palette.background.default
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}, [buttonType, hover, theme$1]);
|
|
53
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
54
|
+
"button",
|
|
55
|
+
{
|
|
56
|
+
...index({ dev: { cy: `button-${buttonType}` } }),
|
|
57
|
+
onMouseEnter: () => setHover(true),
|
|
58
|
+
onMouseLeave: () => setHover(false),
|
|
59
|
+
style: buttonStyle,
|
|
60
|
+
onClick: (e) => {
|
|
61
|
+
e.preventDefault();
|
|
62
|
+
onClick();
|
|
63
|
+
},
|
|
64
|
+
children: text
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
};
|
|
68
|
+
module.exports = Button;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const jsxRuntime = require("react/jsx-runtime");
|
|
3
|
-
const material = require("@mui/material");
|
|
2
|
+
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
4
3
|
const CaptchaWidget = require("./CaptchaWidget.cjs");
|
|
5
4
|
const util = require("@prosopo/util");
|
|
6
5
|
const theme = require("./theme.cjs");
|
|
7
|
-
const
|
|
6
|
+
const React = require("react");
|
|
8
7
|
const common = require("@prosopo/common");
|
|
8
|
+
const Button = require("./Button.cjs");
|
|
9
9
|
const index = require("../util/index.cjs");
|
|
10
10
|
const CaptchaComponent = ({
|
|
11
11
|
challenge,
|
|
@@ -20,46 +20,48 @@ const CaptchaComponent = ({
|
|
|
20
20
|
const { t } = common.useTranslation();
|
|
21
21
|
const captcha = challenge.captchas ? util.at(challenge.captchas, index$1) : null;
|
|
22
22
|
const solution = solutions ? util.at(solutions, index$1) : [];
|
|
23
|
-
const theme$1 =
|
|
23
|
+
const theme$1 = React.useMemo(() => themeColor === "light" ? theme.lightTheme : theme.darkTheme, [themeColor]);
|
|
24
24
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
25
|
-
|
|
25
|
+
"div",
|
|
26
26
|
{
|
|
27
|
-
|
|
27
|
+
style: {
|
|
28
28
|
// introduce scroll bars when screen < minWidth of children
|
|
29
29
|
overflowX: "auto",
|
|
30
30
|
overflowY: "auto",
|
|
31
31
|
width: "100%",
|
|
32
32
|
maxWidth: "500px",
|
|
33
|
-
maxHeight: "100%"
|
|
33
|
+
maxHeight: "100%",
|
|
34
|
+
display: "flex",
|
|
35
|
+
flexDirection: "column"
|
|
34
36
|
},
|
|
35
37
|
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
36
|
-
|
|
38
|
+
"div",
|
|
37
39
|
{
|
|
38
|
-
|
|
39
|
-
|
|
40
|
+
style: {
|
|
41
|
+
backgroundColor: theme$1.palette.background.default,
|
|
40
42
|
display: "flex",
|
|
41
43
|
flexDirection: "column",
|
|
42
44
|
minWidth: "300px"
|
|
43
45
|
},
|
|
44
46
|
children: [
|
|
45
47
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
46
|
-
|
|
48
|
+
"div",
|
|
47
49
|
{
|
|
48
|
-
|
|
49
|
-
py: 3,
|
|
50
|
-
sx: {
|
|
50
|
+
style: {
|
|
51
51
|
display: "flex",
|
|
52
52
|
alignItems: "center",
|
|
53
|
-
width: "100%"
|
|
53
|
+
width: "100%",
|
|
54
|
+
backgroundColor: theme$1.palette.primary.main,
|
|
55
|
+
padding: "24px 16px"
|
|
54
56
|
},
|
|
55
|
-
bgcolor: theme$1.palette.primary.main,
|
|
56
57
|
children: [
|
|
57
58
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
58
|
-
|
|
59
|
+
"p",
|
|
59
60
|
{
|
|
60
|
-
|
|
61
|
+
style: {
|
|
61
62
|
color: "#ffffff",
|
|
62
|
-
fontWeight: 700
|
|
63
|
+
fontWeight: 700,
|
|
64
|
+
lineHeight: 1.5
|
|
63
65
|
},
|
|
64
66
|
children: [
|
|
65
67
|
t("WIDGET.SELECT_ALL"),
|
|
@@ -68,14 +70,13 @@ const CaptchaComponent = ({
|
|
|
68
70
|
}
|
|
69
71
|
),
|
|
70
72
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
71
|
-
|
|
73
|
+
"p",
|
|
72
74
|
{
|
|
73
|
-
|
|
74
|
-
sx: {
|
|
75
|
+
style: {
|
|
75
76
|
color: "#ffffff",
|
|
76
77
|
fontWeight: 700,
|
|
77
78
|
textTransform: "capitalize",
|
|
78
|
-
|
|
79
|
+
lineHeight: 1.5
|
|
79
80
|
},
|
|
80
81
|
children: `${util.at(challenge.captchas, index$1).captcha.target}`
|
|
81
82
|
}
|
|
@@ -83,13 +84,19 @@ const CaptchaComponent = ({
|
|
|
83
84
|
]
|
|
84
85
|
}
|
|
85
86
|
),
|
|
86
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
87
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { ...index({ dev: { cy: "captcha-" + index$1 } }), children: captcha && /* @__PURE__ */ jsxRuntime.jsx(
|
|
88
|
+
CaptchaWidget.CaptchaWidget,
|
|
89
|
+
{
|
|
90
|
+
challenge: captcha,
|
|
91
|
+
solution,
|
|
92
|
+
onClick,
|
|
93
|
+
themeColor
|
|
94
|
+
}
|
|
95
|
+
) }),
|
|
87
96
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
88
|
-
|
|
97
|
+
"div",
|
|
89
98
|
{
|
|
90
|
-
|
|
91
|
-
py: 1,
|
|
92
|
-
sx: {
|
|
99
|
+
style: {
|
|
93
100
|
display: "flex",
|
|
94
101
|
alignItems: "center",
|
|
95
102
|
justifyContent: "center",
|
|
@@ -98,27 +105,43 @@ const CaptchaComponent = ({
|
|
|
98
105
|
...index({ dev: { cy: "dots-captcha" } })
|
|
99
106
|
}
|
|
100
107
|
),
|
|
108
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
109
|
+
"div",
|
|
110
|
+
{
|
|
111
|
+
style: {
|
|
112
|
+
padding: "8px 16px",
|
|
113
|
+
display: "flex",
|
|
114
|
+
width: "100%"
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
),
|
|
101
118
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
102
|
-
|
|
119
|
+
"div",
|
|
103
120
|
{
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
pb: 2,
|
|
107
|
-
sx: {
|
|
121
|
+
style: {
|
|
122
|
+
padding: "0 16px 16px",
|
|
108
123
|
display: "flex",
|
|
109
124
|
alignItems: "center",
|
|
110
|
-
justifyContent: "space-between"
|
|
125
|
+
justifyContent: "space-between",
|
|
126
|
+
lineHeight: 1.75
|
|
111
127
|
},
|
|
112
128
|
children: [
|
|
113
|
-
/* @__PURE__ */ jsxRuntime.jsx(material.Button, { onClick: onCancel, variant: "text", children: t("WIDGET.CANCEL") }),
|
|
114
129
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
115
|
-
|
|
130
|
+
Button,
|
|
131
|
+
{
|
|
132
|
+
themeColor,
|
|
133
|
+
buttonType: "cancel",
|
|
134
|
+
onClick: onCancel,
|
|
135
|
+
text: t("WIDGET.CANCEL")
|
|
136
|
+
}
|
|
137
|
+
),
|
|
138
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
139
|
+
Button,
|
|
116
140
|
{
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
children: index$1 < challenge.captchas.length - 1 ? t("WIDGET.NEXT") : t("WIDGET.SUBMIT")
|
|
141
|
+
themeColor,
|
|
142
|
+
buttonType: "next",
|
|
143
|
+
text: index$1 < challenge.captchas.length - 1 ? t("WIDGET.NEXT") : t("WIDGET.SUBMIT"),
|
|
144
|
+
onClick: index$1 < challenge.captchas.length - 1 ? onNext : onSubmit
|
|
122
145
|
}
|
|
123
146
|
)
|
|
124
147
|
]
|
|
@@ -1,29 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const normalizeIcon = (Icon) => {
|
|
7
|
-
return Icon.default ? Icon.default : Icon;
|
|
8
|
-
};
|
|
9
|
-
const CheckIconNormalized = normalizeIcon(CheckIcon);
|
|
3
|
+
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
4
|
+
const theme = require("./theme.cjs");
|
|
5
|
+
const React = require("react");
|
|
10
6
|
const getHash = (item) => {
|
|
11
7
|
if (!item.hash) {
|
|
12
8
|
throw new Error("item.hash is undefined");
|
|
13
9
|
}
|
|
14
10
|
return item.hash;
|
|
15
11
|
};
|
|
16
|
-
const CaptchaWidget = ({ challenge, solution, onClick }) => {
|
|
12
|
+
const CaptchaWidget = ({ challenge, solution, onClick, themeColor }) => {
|
|
17
13
|
const items = challenge.captcha.items;
|
|
18
|
-
const theme =
|
|
14
|
+
const theme$1 = React.useMemo(() => themeColor === "light" ? theme.lightTheme : theme.darkTheme, [themeColor]);
|
|
19
15
|
const isTouchDevice = "ontouchstart" in window;
|
|
20
16
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
21
|
-
|
|
17
|
+
"div",
|
|
22
18
|
{
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
sx: {
|
|
19
|
+
style: {
|
|
20
|
+
paddingRight: 0.5,
|
|
21
|
+
paddingBottom: 0.5,
|
|
27
22
|
// expand to full height / width of parent
|
|
28
23
|
width: "100%",
|
|
29
24
|
height: "100%",
|
|
@@ -35,11 +30,11 @@ const CaptchaWidget = ({ challenge, solution, onClick }) => {
|
|
|
35
30
|
children: items.map((item, index) => {
|
|
36
31
|
const hash = getHash(item);
|
|
37
32
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
38
|
-
|
|
33
|
+
"div",
|
|
39
34
|
{
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
35
|
+
style: {
|
|
36
|
+
paddingTop: "4px",
|
|
37
|
+
paddingLeft: "4px",
|
|
43
38
|
// enable the items in the grid to grow in width to use up excess space
|
|
44
39
|
flexGrow: 1,
|
|
45
40
|
// make the width of each item 1/3rd of the width overall, i.e. 3 columns
|
|
@@ -48,19 +43,19 @@ const CaptchaWidget = ({ challenge, solution, onClick }) => {
|
|
|
48
43
|
boxSizing: "border-box"
|
|
49
44
|
},
|
|
50
45
|
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
51
|
-
|
|
46
|
+
"div",
|
|
52
47
|
{
|
|
53
|
-
|
|
48
|
+
style: { cursor: "pointer", height: "100%", width: "100%" },
|
|
54
49
|
onClick: isTouchDevice ? void 0 : () => onClick(hash),
|
|
55
50
|
onTouchStart: isTouchDevice ? () => onClick(hash) : void 0,
|
|
56
51
|
children: [
|
|
57
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
52
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { border: 1, borderColor: theme$1.palette.grey[300] }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
58
53
|
"img",
|
|
59
54
|
{
|
|
60
55
|
style: {
|
|
61
56
|
width: "100%",
|
|
62
57
|
// image should be full width / height of the item
|
|
63
|
-
backgroundColor: theme.palette.grey[300],
|
|
58
|
+
backgroundColor: theme$1.palette.grey[300],
|
|
64
59
|
// colour of the bands when letterboxing and image
|
|
65
60
|
opacity: solution.includes(hash) && isTouchDevice ? "50%" : "100%",
|
|
66
61
|
// iphone workaround
|
|
@@ -75,10 +70,10 @@ const CaptchaWidget = ({ challenge, solution, onClick }) => {
|
|
|
75
70
|
alt: `Captcha image ${index + 1}`
|
|
76
71
|
}
|
|
77
72
|
) }),
|
|
78
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
79
|
-
|
|
73
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
74
|
+
"div",
|
|
80
75
|
{
|
|
81
|
-
|
|
76
|
+
style: {
|
|
82
77
|
// relative to where the element _should_ be positioned
|
|
83
78
|
position: "relative",
|
|
84
79
|
// make the overlay the full height/width of an item
|
|
@@ -86,14 +81,15 @@ const CaptchaWidget = ({ challenge, solution, onClick }) => {
|
|
|
86
81
|
height: "100%",
|
|
87
82
|
// shift it up 100% to overlay the item element
|
|
88
83
|
top: "-100%",
|
|
84
|
+
visibility: solution.includes(hash) ? "visible" : "hidden",
|
|
89
85
|
// transition on opacity upon (de)selection
|
|
90
|
-
|
|
91
|
-
|
|
86
|
+
transition: "opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms",
|
|
87
|
+
opacity: 1
|
|
92
88
|
},
|
|
93
89
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
94
|
-
|
|
90
|
+
"div",
|
|
95
91
|
{
|
|
96
|
-
|
|
92
|
+
style: {
|
|
97
93
|
// make the overlay absolute positioned compare to its container
|
|
98
94
|
position: "absolute",
|
|
99
95
|
// spread across 100% width/height of the item box
|
|
@@ -111,22 +107,31 @@ const CaptchaWidget = ({ challenge, solution, onClick }) => {
|
|
|
111
107
|
backgroundColor: "rgba(0,0,0,0.5)"
|
|
112
108
|
},
|
|
113
109
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
114
|
-
|
|
110
|
+
"svg",
|
|
115
111
|
{
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
// img must be displayed as block otherwise
|
|
112
|
+
style: {
|
|
113
|
+
backgroundColor: "transparent",
|
|
114
|
+
// img must be displayed as block otherwise gets a bottom whitespace border
|
|
119
115
|
display: "block",
|
|
120
116
|
// how big the overlay icon is
|
|
121
117
|
width: "35%",
|
|
122
|
-
height: "35%"
|
|
123
|
-
|
|
118
|
+
height: "35%",
|
|
119
|
+
transition: "fill 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms",
|
|
120
|
+
userSelect: "none",
|
|
121
|
+
fill: "currentcolor"
|
|
122
|
+
},
|
|
123
|
+
focusable: "false",
|
|
124
|
+
color: "#fff",
|
|
125
|
+
"aria-hidden": "true",
|
|
126
|
+
viewBox: "0 0 24 24",
|
|
127
|
+
"data-testid": "CheckIcon",
|
|
128
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z" })
|
|
124
129
|
}
|
|
125
130
|
)
|
|
126
131
|
}
|
|
127
132
|
)
|
|
128
133
|
}
|
|
129
|
-
)
|
|
134
|
+
)
|
|
130
135
|
]
|
|
131
136
|
}
|
|
132
137
|
)
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
3
|
+
const react = require("@emotion/react");
|
|
4
|
+
const theme = require("./theme.cjs");
|
|
5
|
+
const React = require("react");
|
|
6
|
+
const checkboxBefore = react.css`{
|
|
7
|
+
&:before {
|
|
8
|
+
content: '""';
|
|
9
|
+
position: absolute;
|
|
10
|
+
height: 100%;
|
|
11
|
+
width: 100%;
|
|
12
|
+
}
|
|
13
|
+
}`;
|
|
14
|
+
const baseStyle = {
|
|
15
|
+
width: "2.2em",
|
|
16
|
+
height: "2.2em",
|
|
17
|
+
top: "auto",
|
|
18
|
+
left: "auto",
|
|
19
|
+
opacity: "1",
|
|
20
|
+
borderRadius: "12.5%",
|
|
21
|
+
appearance: "none",
|
|
22
|
+
cursor: "pointer",
|
|
23
|
+
margin: "0",
|
|
24
|
+
borderStyle: "solid",
|
|
25
|
+
borderWidth: "1px"
|
|
26
|
+
};
|
|
27
|
+
const Checkbox = ({ themeColor, onChange, checked }) => {
|
|
28
|
+
const theme$1 = React.useMemo(() => themeColor === "light" ? theme.lightTheme : theme.darkTheme, [themeColor]);
|
|
29
|
+
const checkboxStyleBase = {
|
|
30
|
+
...baseStyle,
|
|
31
|
+
border: `1px solid ${theme$1.palette.background.contrastText}`
|
|
32
|
+
};
|
|
33
|
+
const [hover, setHover] = React.useState(false);
|
|
34
|
+
const checkboxStyle = React.useMemo(() => {
|
|
35
|
+
return {
|
|
36
|
+
...checkboxStyleBase,
|
|
37
|
+
borderColor: hover ? theme$1.palette.background.contrastText : theme$1.palette.grey[400],
|
|
38
|
+
appearance: checked ? "auto" : "none"
|
|
39
|
+
};
|
|
40
|
+
}, [hover, theme$1, checked]);
|
|
41
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
42
|
+
"input",
|
|
43
|
+
{
|
|
44
|
+
onMouseEnter: () => setHover(true),
|
|
45
|
+
onMouseLeave: () => setHover(false),
|
|
46
|
+
css: checkboxBefore,
|
|
47
|
+
type: "checkbox",
|
|
48
|
+
"aria-live": "assertive",
|
|
49
|
+
"aria-haspopup": "true",
|
|
50
|
+
onChange,
|
|
51
|
+
checked,
|
|
52
|
+
style: checkboxStyle
|
|
53
|
+
}
|
|
54
|
+
);
|
|
55
|
+
};
|
|
56
|
+
module.exports = Checkbox;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
-
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
-
const
|
|
5
|
-
const react = require("react");
|
|
3
|
+
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
4
|
+
const React = require("react");
|
|
6
5
|
const common = require("@prosopo/common");
|
|
7
6
|
const extensionDapp = require("@polkadot/extension-dapp");
|
|
8
7
|
const ExtensionAccountSelect = ({
|
|
@@ -11,8 +10,8 @@ const ExtensionAccountSelect = ({
|
|
|
11
10
|
onChange
|
|
12
11
|
}) => {
|
|
13
12
|
const { t } = common.useTranslation();
|
|
14
|
-
const [accounts, setAccounts] =
|
|
15
|
-
|
|
13
|
+
const [accounts, setAccounts] = React.useState([]);
|
|
14
|
+
React.useEffect(() => {
|
|
16
15
|
const prom = extensionDapp.web3Enable(dappName).then(() => {
|
|
17
16
|
return extensionDapp.web3AccountsSubscribe(setAccounts);
|
|
18
17
|
});
|
|
@@ -21,27 +20,28 @@ const ExtensionAccountSelect = ({
|
|
|
21
20
|
};
|
|
22
21
|
}, []);
|
|
23
22
|
const account = accounts.find((a) => a.address === value) || null;
|
|
24
|
-
return
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
23
|
+
return (
|
|
24
|
+
// react select box
|
|
25
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
26
|
+
"select",
|
|
27
|
+
{
|
|
28
|
+
id: "select-account",
|
|
29
|
+
onChange: (e) => {
|
|
30
|
+
const value2 = e.target.value;
|
|
31
|
+
const account2 = accounts.find((a) => a.address === value2) || null;
|
|
32
|
+
if (account2) {
|
|
33
|
+
console.log("Selected account:", value2);
|
|
34
|
+
onChange(account2.address);
|
|
35
|
+
} else {
|
|
36
|
+
console.log("Deselected account");
|
|
37
|
+
onChange("");
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
value: accounts.length > 0 && account ? account.address : void 0,
|
|
41
|
+
style: { width: "550px" },
|
|
42
|
+
children: accounts.map(({ address, meta: { name } }) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: address, children: name }))
|
|
43
|
+
}
|
|
44
|
+
)
|
|
45
45
|
);
|
|
46
46
|
};
|
|
47
47
|
exports.ExtensionAccountSelect = ExtensionAccountSelect;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
4
|
+
const theme = require("./theme.cjs");
|
|
5
|
+
const React = require("react");
|
|
6
|
+
const styled = require("@emotion/styled");
|
|
7
|
+
const LoadingSpinner = ({ themeColor }) => {
|
|
8
|
+
const theme$1 = React.useMemo(() => themeColor === "light" ? theme.lightTheme : theme.darkTheme, [themeColor]);
|
|
9
|
+
const StyledDiv = styled.div`
|
|
10
|
+
width: 2em;
|
|
11
|
+
height: 2em;
|
|
12
|
+
border: 4px solid ${theme$1.palette.primary.contrastText};
|
|
13
|
+
border-bottom-color: transparent;
|
|
14
|
+
border-radius: 50%;
|
|
15
|
+
display: inherit;
|
|
16
|
+
box-sizing: border-box;
|
|
17
|
+
animation: rotation 1s linear infinite;
|
|
18
|
+
@keyframes rotation {
|
|
19
|
+
0% {
|
|
20
|
+
transform: rotate(0deg);
|
|
21
|
+
}
|
|
22
|
+
100% {
|
|
23
|
+
transform: rotate(360deg);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
`;
|
|
27
|
+
return /* @__PURE__ */ jsxRuntime.jsx(StyledDiv, {});
|
|
28
|
+
};
|
|
29
|
+
exports.LoadingSpinner = LoadingSpinner;
|
|
30
|
+
exports.default = LoadingSpinner;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const ModalComponent = React.memo((props, nextProps) => {
|
|
5
|
+
const { show, children } = props;
|
|
6
|
+
console.log("rendering modal with show: ", show);
|
|
7
|
+
const display = show ? "flex" : "none";
|
|
8
|
+
const ModalOuterDivCss = {
|
|
9
|
+
overflow: "auto",
|
|
10
|
+
width: "100%",
|
|
11
|
+
maxHeight: "100%",
|
|
12
|
+
position: "fixed",
|
|
13
|
+
top: "0",
|
|
14
|
+
left: "0",
|
|
15
|
+
height: "100%",
|
|
16
|
+
background: "rgba(0, 0, 0, 0.6)",
|
|
17
|
+
zIndex: "2147483646",
|
|
18
|
+
transition: "all 0.5s",
|
|
19
|
+
display
|
|
20
|
+
};
|
|
21
|
+
const ModalInnerDivCSS = {
|
|
22
|
+
maxWidth: "500px",
|
|
23
|
+
margin: "auto",
|
|
24
|
+
position: "fixed",
|
|
25
|
+
background: "white",
|
|
26
|
+
height: "auto",
|
|
27
|
+
top: "50%",
|
|
28
|
+
left: "50%",
|
|
29
|
+
transform: "translate(-50%, -50%)",
|
|
30
|
+
zIndex: "2147483647",
|
|
31
|
+
transition: "all 0.5s"
|
|
32
|
+
};
|
|
33
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { style: ModalOuterDivCss, children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: ModalInnerDivCSS, children }) });
|
|
34
|
+
});
|
|
35
|
+
module.exports = ModalComponent;
|