@prosopo/procaptcha-react 2.6.28 → 2.6.29

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 (44) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/components/Button.js +74 -58
  3. package/dist/components/CaptchaComponent.js +224 -86
  4. package/dist/components/CaptchaWidget.js +135 -70
  5. package/dist/components/Modal.js +20 -16
  6. package/dist/components/Procaptcha.js +6 -5
  7. package/dist/components/ProcaptchaWidget.js +119 -71
  8. package/dist/components/index.js +9 -6
  9. package/dist/index.js +10 -3
  10. package/dist/util/index.js +16 -9
  11. package/package.json +19 -16
  12. package/vite.cjs.config.ts +2 -2
  13. package/vite.esm.config.ts +20 -0
  14. package/dist/components/Button.d.ts +0 -11
  15. package/dist/components/Button.d.ts.map +0 -1
  16. package/dist/components/Button.js.map +0 -1
  17. package/dist/components/CaptchaComponent.d.ts +0 -15
  18. package/dist/components/CaptchaComponent.d.ts.map +0 -1
  19. package/dist/components/CaptchaComponent.js.map +0 -1
  20. package/dist/components/CaptchaWidget.d.ts +0 -9
  21. package/dist/components/CaptchaWidget.d.ts.map +0 -1
  22. package/dist/components/CaptchaWidget.js.map +0 -1
  23. package/dist/components/Modal.d.ts +0 -8
  24. package/dist/components/Modal.d.ts.map +0 -1
  25. package/dist/components/Modal.js.map +0 -1
  26. package/dist/components/Procaptcha.d.ts +0 -14
  27. package/dist/components/Procaptcha.d.ts.map +0 -1
  28. package/dist/components/Procaptcha.js.map +0 -1
  29. package/dist/components/ProcaptchaWidget.d.ts +0 -4
  30. package/dist/components/ProcaptchaWidget.d.ts.map +0 -1
  31. package/dist/components/ProcaptchaWidget.js.map +0 -1
  32. package/dist/components/collector.d.ts +0 -9
  33. package/dist/components/collector.d.ts.map +0 -1
  34. package/dist/components/collector.js +0 -26
  35. package/dist/components/collector.js.map +0 -1
  36. package/dist/components/index.d.ts +0 -6
  37. package/dist/components/index.d.ts.map +0 -1
  38. package/dist/components/index.js.map +0 -1
  39. package/dist/index.d.ts +0 -3
  40. package/dist/index.d.ts.map +0 -1
  41. package/dist/index.js.map +0 -1
  42. package/dist/util/index.d.ts +0 -9
  43. package/dist/util/index.d.ts.map +0 -1
  44. package/dist/util/index.js.map +0 -1
@@ -1,76 +1,141 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
1
+ import { jsx, jsxs } from "@emotion/react/jsx-runtime";
2
2
  import { ProsopoDatasetError } from "@prosopo/common";
3
- import { darkTheme, lightTheme } from "@prosopo/widget-skeleton";
3
+ import { lightTheme, darkTheme } from "@prosopo/widget-skeleton";
4
4
  import { useMemo } from "react";
5
5
  const getHash = (item) => {
6
- if (!item.hash) {
7
- throw new ProsopoDatasetError("CAPTCHA.MISSING_ITEM_HASH", {
8
- context: { item },
9
- });
6
+ if (!item.hash) {
7
+ throw new ProsopoDatasetError("CAPTCHA.MISSING_ITEM_HASH", {
8
+ context: { item }
9
+ });
10
+ }
11
+ return item.hash;
12
+ };
13
+ const CaptchaWidget = ({
14
+ challenge,
15
+ solution,
16
+ onClick,
17
+ themeColor
18
+ }) => {
19
+ const items = challenge.items;
20
+ const theme = useMemo(
21
+ () => themeColor === "light" ? lightTheme : darkTheme,
22
+ [themeColor]
23
+ );
24
+ const fullSpacing = `${theme.spacing.unit}px`;
25
+ const halfSpacing = `${theme.spacing.half}px`;
26
+ return /* @__PURE__ */ jsx(
27
+ "div",
28
+ {
29
+ style: {
30
+ // expand to full height / width of parent
31
+ width: "100%",
32
+ height: "100%",
33
+ // display children in flex, spreading them evenly and wrapping when row length exceeded
34
+ display: "flex",
35
+ flexDirection: "row",
36
+ flexWrap: "wrap",
37
+ justifyContent: "space-between",
38
+ paddingBottom: fullSpacing,
39
+ paddingTop: fullSpacing,
40
+ gap: "10px"
41
+ },
42
+ children: items.map((item, index) => {
43
+ const hash = getHash(item);
44
+ const imageStyle = {
45
+ // enable the items in the grid to grow in width to use up excess space
46
+ flexGrow: 1,
47
+ // make the width of each item 1/3rd of the width overall, i.e. 3 columns
48
+ flexBasis: "calc(33.333% - 10px)",
49
+ // include the padding / margin / border in the width
50
+ boxSizing: "border-box"
51
+ };
52
+ return /* @__PURE__ */ jsx("div", { style: imageStyle, children: /* @__PURE__ */ jsxs(
53
+ "div",
54
+ {
55
+ style: {
56
+ position: "relative",
57
+ cursor: "pointer",
58
+ height: "100%",
59
+ width: "100%",
60
+ padding: 0,
61
+ margin: 0
62
+ },
63
+ onClick: () => onClick(hash),
64
+ children: [
65
+ /* @__PURE__ */ jsx(
66
+ "img",
67
+ {
68
+ style: {
69
+ width: "100%",
70
+ // image should be full width / height of the item
71
+ display: "block",
72
+ // removes whitespace below imgs
73
+ objectFit: "cover",
74
+ // contain the entire image in the img tag
75
+ aspectRatio: "1/1",
76
+ // force AR to be 1, letterboxing images with different aspect ratios
77
+ height: "auto",
78
+ // make the img tag responsive to its container
79
+ overflow: "hidden",
80
+ borderStyle: "solid",
81
+ borderWidth: "1px",
82
+ borderColor: theme.palette.grey[300]
83
+ },
84
+ src: item.data,
85
+ alt: `Captcha image ${index + 1}`
86
+ }
87
+ ),
88
+ /* @__PURE__ */ jsx(
89
+ "div",
90
+ {
91
+ style: {
92
+ position: "absolute",
93
+ top: 0,
94
+ left: 0,
95
+ bottom: 0,
96
+ right: 0,
97
+ height: "100%",
98
+ width: "100%",
99
+ // display overlays in center
100
+ display: "flex",
101
+ alignItems: "center",
102
+ justifyContent: "center",
103
+ // make bg half opacity, i.e. shadowing the item's img
104
+ backgroundColor: "rgba(0,0,0,0.5)",
105
+ visibility: solution.includes(hash) ? "visible" : "hidden"
106
+ },
107
+ children: /* @__PURE__ */ jsx(
108
+ "svg",
109
+ {
110
+ style: {
111
+ backgroundColor: "transparent",
112
+ // img must be displayed as block otherwise gets a bottom whitespace border
113
+ display: "block",
114
+ // how big the overlay icon is
115
+ width: "35%",
116
+ height: "35%",
117
+ transition: "fill 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms",
118
+ userSelect: "none",
119
+ fill: "currentcolor"
120
+ },
121
+ focusable: "false",
122
+ color: "#fff",
123
+ "aria-hidden": "true",
124
+ viewBox: "0 0 24 24",
125
+ "data-testid": "CheckIcon",
126
+ "aria-label": "Check icon",
127
+ children: /* @__PURE__ */ jsx("path", { d: "M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z" })
128
+ }
129
+ )
130
+ }
131
+ )
132
+ ]
133
+ }
134
+ ) }, item.hash);
135
+ })
10
136
  }
11
- return item.hash;
137
+ );
12
138
  };
13
- export const CaptchaWidget = ({ challenge, solution, onClick, themeColor, }) => {
14
- const items = challenge.items;
15
- const theme = useMemo(() => (themeColor === "light" ? lightTheme : darkTheme), [themeColor]);
16
- const fullSpacing = `${theme.spacing.unit}px`;
17
- const halfSpacing = `${theme.spacing.half}px`;
18
- return (_jsx("div", { style: {
19
- width: "100%",
20
- height: "100%",
21
- display: "flex",
22
- flexDirection: "row",
23
- flexWrap: "wrap",
24
- justifyContent: "space-between",
25
- paddingBottom: fullSpacing,
26
- paddingTop: fullSpacing,
27
- gap: "10px",
28
- }, children: items.map((item, index) => {
29
- const hash = getHash(item);
30
- const imageStyle = {
31
- flexGrow: 1,
32
- flexBasis: "calc(33.333% - 10px)",
33
- boxSizing: "border-box",
34
- };
35
- return (_jsx("div", { style: imageStyle, children: _jsxs("div", { style: {
36
- position: "relative",
37
- cursor: "pointer",
38
- height: "100%",
39
- width: "100%",
40
- padding: 0,
41
- margin: 0,
42
- }, onClick: () => onClick(hash), children: [_jsx("img", { style: {
43
- width: "100%",
44
- display: "block",
45
- objectFit: "cover",
46
- aspectRatio: "1/1",
47
- height: "auto",
48
- overflow: "hidden",
49
- borderStyle: "solid",
50
- borderWidth: "1px",
51
- borderColor: theme.palette.grey[300],
52
- }, src: item.data, alt: `Captcha image ${index + 1}` }), _jsx("div", { style: {
53
- position: "absolute",
54
- top: 0,
55
- left: 0,
56
- bottom: 0,
57
- right: 0,
58
- height: "100%",
59
- width: "100%",
60
- display: "flex",
61
- alignItems: "center",
62
- justifyContent: "center",
63
- backgroundColor: "rgba(0,0,0,0.5)",
64
- visibility: solution.includes(hash) ? "visible" : "hidden",
65
- }, children: _jsx("svg", { style: {
66
- backgroundColor: "transparent",
67
- display: "block",
68
- width: "35%",
69
- height: "35%",
70
- transition: "fill 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms",
71
- userSelect: "none",
72
- fill: "currentcolor",
73
- }, focusable: "false", color: "#fff", "aria-hidden": "true", viewBox: "0 0 24 24", "data-testid": "CheckIcon", "aria-label": "Check icon", children: _jsx("path", { d: "M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z" }) }) })] }) }, item.hash));
74
- }) }));
139
+ export {
140
+ CaptchaWidget
75
141
  };
76
- //# sourceMappingURL=CaptchaWidget.js.map
@@ -1,8 +1,8 @@
1
- import { jsx as _jsx } from "@emotion/react/jsx-runtime";
1
+ import { jsx } from "@emotion/react/jsx-runtime";
2
2
  import { css } from "@emotion/react";
3
3
  import React from "react";
4
4
  import { createPortal } from "react-dom";
5
- const ModalInnerDivCSS = css `
5
+ const ModalInnerDivCSS = css`
6
6
  position: absolute;
7
7
  top: 50%;
8
8
  left: 50%;
@@ -23,18 +23,22 @@ const ModalInnerDivCSS = css `
23
23
  }
24
24
  `;
25
25
  const ModalComponent = React.memo((props) => {
26
- const { show, children } = props;
27
- const display = show ? "flex" : "none";
28
- const ModalOuterDivCss = {
29
- position: "fixed",
30
- zIndex: 2147483646,
31
- inset: 0,
32
- display,
33
- alignItems: "center",
34
- justifyContent: "center",
35
- minHeight: "100vh",
36
- };
37
- return createPortal(_jsx("div", { className: "prosopo-modalOuter", style: ModalOuterDivCss, children: _jsx("div", { className: "prosopo-modalInner", css: ModalInnerDivCSS, children: children }) }), document.body);
26
+ const { show, children } = props;
27
+ const display = show ? "flex" : "none";
28
+ const ModalOuterDivCss = {
29
+ position: "fixed",
30
+ zIndex: 2147483646,
31
+ inset: 0,
32
+ display,
33
+ alignItems: "center",
34
+ justifyContent: "center",
35
+ minHeight: "100vh"
36
+ };
37
+ return createPortal(
38
+ /* @__PURE__ */ jsx("div", { className: "prosopo-modalOuter", style: ModalOuterDivCss, children: /* @__PURE__ */ jsx("div", { className: "prosopo-modalInner", css: ModalInnerDivCSS, children }) }),
39
+ document.body
40
+ );
38
41
  });
39
- export default ModalComponent;
40
- //# sourceMappingURL=Modal.js.map
42
+ export {
43
+ ModalComponent as default
44
+ };
@@ -1,6 +1,7 @@
1
- import { jsx as _jsx } from "@emotion/react/jsx-runtime";
2
- import { Suspense, lazy } from "react";
1
+ import { jsx } from "@emotion/react/jsx-runtime";
2
+ import { lazy, Suspense } from "react";
3
3
  const ProcaptchaWidget = lazy(async () => import("./ProcaptchaWidget.js"));
4
- const Procaptcha = (props) => (_jsx(Suspense, { children: _jsx(ProcaptchaWidget, { ...props }) }));
5
- export default Procaptcha;
6
- //# sourceMappingURL=Procaptcha.js.map
4
+ const Procaptcha = (props) => /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(ProcaptchaWidget, { ...props }) });
5
+ export {
6
+ Procaptcha as default
7
+ };
@@ -1,79 +1,127 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
- import { loadI18next, useTranslation } from "@prosopo/locale";
1
+ import { jsx, jsxs } from "@emotion/react/jsx-runtime";
2
+ import { useTranslation, loadI18next } from "@prosopo/locale";
3
3
  import { Manager } from "@prosopo/procaptcha";
4
- import { Checkbox, useProcaptcha } from "@prosopo/procaptcha-common";
4
+ import { useProcaptcha, Checkbox } from "@prosopo/procaptcha-common";
5
5
  import { ProcaptchaConfigSchema } from "@prosopo/types";
6
- import { darkTheme, lightTheme } from "@prosopo/widget-skeleton";
7
- import { useEffect, useRef, useState } from "react";
6
+ import { lightTheme, darkTheme } from "@prosopo/widget-skeleton";
7
+ import { useState, useRef, useEffect } from "react";
8
8
  import CaptchaComponent from "./CaptchaComponent.js";
9
- import Modal from "./Modal.js";
9
+ import ModalComponent from "./Modal.js";
10
10
  const PROCAPTCHA_EXECUTE_EVENT = "procaptcha:execute";
11
11
  const ProcaptchaWidget = (props) => {
12
- const { t, ready: isTranslationReady } = useTranslation();
13
- const config = ProcaptchaConfigSchema.parse(props.config);
14
- const frictionlessState = props.frictionlessState;
15
- const i18n = props.i18n;
16
- const callbacks = props.callbacks || {};
17
- const [state, updateState] = useProcaptcha(useState, useRef);
18
- const [loading, setLoading] = useState(false);
19
- const manager = Manager(config, state, updateState, callbacks, frictionlessState);
20
- const theme = "light" === props.config.theme ? lightTheme : darkTheme;
21
- useEffect(() => {
22
- if (config.language) {
23
- if (i18n) {
24
- if (i18n.language !== config.language) {
25
- i18n.changeLanguage(config.language).then((r) => r);
26
- }
27
- }
28
- else {
29
- loadI18next(false).then((i18n) => {
30
- if (i18n.language !== config.language)
31
- i18n.changeLanguage(config.language).then((r) => r);
32
- });
33
- }
12
+ const { t, ready: isTranslationReady } = useTranslation();
13
+ const config = ProcaptchaConfigSchema.parse(props.config);
14
+ const frictionlessState = props.frictionlessState;
15
+ const i18n = props.i18n;
16
+ const callbacks = props.callbacks || {};
17
+ const [state, updateState] = useProcaptcha(useState, useRef);
18
+ const [loading, setLoading] = useState(false);
19
+ const manager = Manager(
20
+ config,
21
+ state,
22
+ updateState,
23
+ callbacks,
24
+ frictionlessState
25
+ );
26
+ const theme = "light" === props.config.theme ? lightTheme : darkTheme;
27
+ useEffect(() => {
28
+ if (config.language) {
29
+ if (i18n) {
30
+ if (i18n.language !== config.language) {
31
+ i18n.changeLanguage(config.language).then((r) => r);
34
32
  }
35
- }, [i18n, config.language]);
36
- useEffect(() => {
37
- if (state.error) {
38
- setLoading(false);
39
- if (state.error.key === "CAPTCHA.NO_SESSION_FOUND" && frictionlessState) {
40
- setTimeout(() => {
41
- frictionlessState.restart();
42
- }, 3000);
43
- }
44
- }
45
- }, [state.error, frictionlessState]);
46
- useEffect(() => {
47
- const handleExecuteEvent = (event) => {
48
- updateState({
49
- showModal: true,
50
- });
51
- if (!state.challenge && manager.start) {
52
- console.log("No challenge set, attempting to start verification");
53
- try {
54
- manager.start();
55
- }
56
- catch (error) {
57
- console.error("Error starting verification:", error);
58
- }
59
- }
60
- };
61
- document.addEventListener(PROCAPTCHA_EXECUTE_EVENT, handleExecuteEvent);
62
- return () => {
63
- document.removeEventListener(PROCAPTCHA_EXECUTE_EVENT, handleExecuteEvent);
64
- };
65
- }, [manager, state.challenge, updateState]);
66
- if (config.mode === "invisible") {
67
- return (_jsx(Modal, { show: state.showModal, children: state.challenge ? (_jsx(CaptchaComponent, { challenge: state.challenge, index: state.index, solutions: state.solutions, onSubmit: manager.submit, onCancel: manager.cancel, onClick: manager.select, onNext: manager.nextRound, onReload: manager.reload, themeColor: config.theme ?? "light" })) : null }));
33
+ } else {
34
+ loadI18next(false).then((i18n2) => {
35
+ if (i18n2.language !== config.language)
36
+ i18n2.changeLanguage(config.language).then((r) => r);
37
+ });
38
+ }
39
+ }
40
+ }, [i18n, config.language]);
41
+ useEffect(() => {
42
+ if (state.error) {
43
+ setLoading(false);
44
+ if (state.error.key === "CAPTCHA.NO_SESSION_FOUND" && frictionlessState) {
45
+ setTimeout(() => {
46
+ frictionlessState.restart();
47
+ }, 3e3);
48
+ }
68
49
  }
69
- return (_jsxs("div", { className: "image-captcha", children: [_jsx(Modal, { show: state.showModal, children: state.challenge ? (_jsx(CaptchaComponent, { challenge: state.challenge, index: state.index, solutions: state.solutions, onSubmit: manager.submit, onCancel: manager.cancel, onClick: manager.select, onNext: manager.nextRound, onReload: manager.reload, themeColor: config.theme ?? "light" })) : (_jsx("div", { children: "No challenge set." })) }), _jsx(Checkbox, { theme: theme, onChange: async () => {
70
- if (loading) {
71
- return;
72
- }
73
- setLoading(true);
74
- await manager.start();
75
- setLoading(false);
76
- }, checked: state.isHuman, labelText: isTranslationReady ? t("WIDGET.I_AM_HUMAN") : "", error: state.error?.message, "aria-label": "human checkbox", loading: loading })] }));
50
+ }, [state.error, frictionlessState]);
51
+ useEffect(() => {
52
+ const handleExecuteEvent = (event) => {
53
+ updateState({
54
+ showModal: true
55
+ });
56
+ if (!state.challenge && manager.start) {
57
+ console.log("No challenge set, attempting to start verification");
58
+ try {
59
+ manager.start();
60
+ } catch (error) {
61
+ console.error("Error starting verification:", error);
62
+ }
63
+ }
64
+ };
65
+ document.addEventListener(PROCAPTCHA_EXECUTE_EVENT, handleExecuteEvent);
66
+ return () => {
67
+ document.removeEventListener(
68
+ PROCAPTCHA_EXECUTE_EVENT,
69
+ handleExecuteEvent
70
+ );
71
+ };
72
+ }, [manager, state.challenge, updateState]);
73
+ if (config.mode === "invisible") {
74
+ return /* @__PURE__ */ jsx(ModalComponent, { show: state.showModal, children: state.challenge ? /* @__PURE__ */ jsx(
75
+ CaptchaComponent,
76
+ {
77
+ challenge: state.challenge,
78
+ index: state.index,
79
+ solutions: state.solutions,
80
+ onSubmit: manager.submit,
81
+ onCancel: manager.cancel,
82
+ onClick: manager.select,
83
+ onNext: manager.nextRound,
84
+ onReload: manager.reload,
85
+ themeColor: config.theme ?? "light"
86
+ }
87
+ ) : null });
88
+ }
89
+ return /* @__PURE__ */ jsxs("div", { className: "image-captcha", children: [
90
+ /* @__PURE__ */ jsx(ModalComponent, { show: state.showModal, children: state.challenge ? /* @__PURE__ */ jsx(
91
+ CaptchaComponent,
92
+ {
93
+ challenge: state.challenge,
94
+ index: state.index,
95
+ solutions: state.solutions,
96
+ onSubmit: manager.submit,
97
+ onCancel: manager.cancel,
98
+ onClick: manager.select,
99
+ onNext: manager.nextRound,
100
+ onReload: manager.reload,
101
+ themeColor: config.theme ?? "light"
102
+ }
103
+ ) : /* @__PURE__ */ jsx("div", { children: "No challenge set." }) }),
104
+ /* @__PURE__ */ jsx(
105
+ Checkbox,
106
+ {
107
+ theme,
108
+ onChange: async () => {
109
+ if (loading) {
110
+ return;
111
+ }
112
+ setLoading(true);
113
+ await manager.start();
114
+ setLoading(false);
115
+ },
116
+ checked: state.isHuman,
117
+ labelText: isTranslationReady ? t("WIDGET.I_AM_HUMAN") : "",
118
+ error: state.error?.message,
119
+ "aria-label": "human checkbox",
120
+ loading
121
+ }
122
+ )
123
+ ] });
124
+ };
125
+ export {
126
+ ProcaptchaWidget as default
77
127
  };
78
- export default ProcaptchaWidget;
79
- //# sourceMappingURL=ProcaptchaWidget.js.map
@@ -1,6 +1,9 @@
1
- export * from "./CaptchaWidget.js";
2
- export * from "./CaptchaComponent.js";
3
- export { default as ProcaptchaWidget } from "./ProcaptchaWidget.js";
4
- export { default as Procaptcha } from "./Procaptcha.js";
5
- export * from "./Procaptcha.js";
6
- //# sourceMappingURL=index.js.map
1
+ import { CaptchaWidget } from "./CaptchaWidget.js";
2
+ import "./CaptchaComponent.js";
3
+ import { default as default2 } from "./ProcaptchaWidget.js";
4
+ import { default as default3 } from "./Procaptcha.js";
5
+ export {
6
+ CaptchaWidget,
7
+ default3 as Procaptcha,
8
+ default2 as ProcaptchaWidget
9
+ };
package/dist/index.js CHANGED
@@ -1,3 +1,10 @@
1
- export * from "./components/index.js";
2
- export * from "./util/index.js";
3
- //# sourceMappingURL=index.js.map
1
+ import "./components/index.js";
2
+ import "./util/index.js";
3
+ import { default as default2 } from "./components/ProcaptchaWidget.js";
4
+ import { default as default3 } from "./components/Procaptcha.js";
5
+ import { CaptchaWidget } from "./components/CaptchaWidget.js";
6
+ export {
7
+ CaptchaWidget,
8
+ default3 as Procaptcha,
9
+ default2 as ProcaptchaWidget
10
+ };
@@ -1,12 +1,19 @@
1
1
  function renameKeysForDataAttr(data = {}) {
2
- return Object.keys(data).reduce((prev, curr) => ({ ...prev, [`data-${curr}`]: data[curr] }), {});
2
+ return Object.keys(data).reduce(
3
+ // biome-ignore lint/performance/noAccumulatingSpread: TODO fix
4
+ (prev, curr) => ({ ...prev, [`data-${curr}`]: data[curr] }),
5
+ {}
6
+ );
3
7
  }
4
- export default function addDataAttr({ general, dev, }) {
5
- return {
6
- ...renameKeysForDataAttr(general),
7
- ...(process.env.NODE_ENV !== "production"
8
- ? renameKeysForDataAttr(dev)
9
- : {}),
10
- };
8
+ function addDataAttr({
9
+ general,
10
+ dev
11
+ }) {
12
+ return {
13
+ ...renameKeysForDataAttr(general),
14
+ ...process.env.NODE_ENV !== "production" ? renameKeysForDataAttr(dev) : {}
15
+ };
11
16
  }
12
- //# sourceMappingURL=index.js.map
17
+ export {
18
+ addDataAttr as default
19
+ };
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@prosopo/procaptcha-react",
3
- "version": "2.6.28",
3
+ "version": "2.6.29",
4
4
  "author": "PROSOPO LIMITED <info@prosopo.io>",
5
5
  "license": "Apache-2.0",
6
- "main": "./dist/index.js",
6
+ "main": "dist/index.js",
7
7
  "type": "module",
8
8
  "sideEffects": false,
9
9
  "engines": {
@@ -13,31 +13,35 @@
13
13
  "exports": {
14
14
  ".": {
15
15
  "import": "./dist/index.js",
16
- "require": "./dist/cjs/index.cjs"
16
+ "require": "./dist/cjs/index.cjs",
17
+ "types": "./dist/index.d.ts"
17
18
  }
18
19
  },
19
- "types": "./dist/index.d.ts",
20
+ "types": "dist/index.d.ts",
20
21
  "source": "./src/index.ts",
21
22
  "scripts": {
22
- "test": "echo \"No test specified\"",
23
- "clean": "tsc --build --clean",
24
- "build": "tsc --build --verbose",
25
- "build:cjs": "npx vite --config vite.cjs.config.ts build"
23
+ "clean": "del-cli --verbose dist tsconfig.tsbuildinfo",
24
+ "build": "NODE_ENV=${NODE_ENV:-production}; vite build --config vite.esm.config.ts --mode $NODE_ENV",
25
+ "build:tsc": "tsc --build --verbose",
26
+ "build:cjs": "NODE_ENV=${NODE_ENV:-production}; vite build --config vite.cjs.config.ts --mode $NODE_ENV",
27
+ "typecheck": "tsc --build --declaration --emitDeclarationOnly",
28
+ "test": "echo no tests"
26
29
  },
27
30
  "browserslist": ["> 0.5%, last 2 versions, not dead"],
28
31
  "dependencies": {
29
- "@prosopo/common": "3.0.2",
30
- "@prosopo/locale": "3.0.2",
31
- "@prosopo/procaptcha": "2.7.14",
32
- "@prosopo/procaptcha-common": "2.7.9",
33
- "@prosopo/types": "3.0.3",
34
- "@prosopo/util": "3.0.2",
35
- "@prosopo/widget-skeleton": "2.6.0",
32
+ "@prosopo/common": "3.1.0",
33
+ "@prosopo/locale": "3.1.0",
34
+ "@prosopo/procaptcha": "2.7.15",
35
+ "@prosopo/procaptcha-common": "2.7.10",
36
+ "@prosopo/types": "3.0.4",
37
+ "@prosopo/util": "3.0.3",
38
+ "@prosopo/widget-skeleton": "2.6.1",
36
39
  "@typegoose/auto-increment": "4.13.0",
37
40
  "axios": "1.10.0",
38
41
  "csstype": "3.1.3",
39
42
  "esbuild": "0.25.6",
40
43
  "express": "4.21.2",
44
+ "@prosopo/config": "3.1.1",
41
45
  "openpgp": "5.11.3",
42
46
  "react": "18.3.1",
43
47
  "webpack-dev-server": "5.2.2"
@@ -55,7 +59,6 @@
55
59
  }
56
60
  },
57
61
  "devDependencies": {
58
- "@prosopo/config": "3.1.0",
59
62
  "@vitest/coverage-v8": "3.0.9",
60
63
  "concurrently": "9.0.1",
61
64
  "del-cli": "6.0.0",
@@ -16,7 +16,7 @@ import { ViteCommonJSConfig } from "@prosopo/config";
16
16
 
17
17
  export default function () {
18
18
  return ViteCommonJSConfig(
19
- "procaptcha-react",
20
- path.resolve("./tsconfig.cjs.json"),
19
+ path.basename("."),
20
+ path.resolve("./tsconfig.json"),
21
21
  );
22
22
  }
@@ -0,0 +1,20 @@
1
+ // Copyright 2021-2025 Prosopo (UK) Ltd.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ import path from "node:path";
16
+ import { ViteEsmConfig } from "@prosopo/config";
17
+
18
+ export default function () {
19
+ return ViteEsmConfig(path.basename("."), path.resolve("./tsconfig.json"));
20
+ }
@@ -1,11 +0,0 @@
1
- import type React from "react";
2
- import { type ButtonHTMLAttributes } from "react";
3
- interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
4
- themeColor: "light" | "dark";
5
- buttonType: "cancel" | "next";
6
- onClick: () => void;
7
- text: string;
8
- }
9
- declare const Button: React.FC<ButtonProps>;
10
- export default Button;
11
- //# sourceMappingURL=Button.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../src/components/Button.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACN,KAAK,oBAAoB,EAIzB,MAAM,OAAO,CAAC;AAGf,UAAU,WAAY,SAAQ,oBAAoB,CAAC,iBAAiB,CAAC;IACpE,UAAU,EAAE,OAAO,GAAG,MAAM,CAAC;IAC7B,UAAU,EAAE,QAAQ,GAAG,MAAM,CAAC;IAC9B,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACb;AA4BD,QAAA,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAmDjC,CAAC;AACF,eAAe,MAAM,CAAC"}