@aifeatures/react 0.1.5 → 0.1.7
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/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -31,7 +31,7 @@ var import_react_turnstile = require("@marsidev/react-turnstile");
|
|
|
31
31
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
32
32
|
function AifeaturesCaptcha({
|
|
33
33
|
formId,
|
|
34
|
-
apiUrl = "https://
|
|
34
|
+
apiUrl = "https://aifeatures.dev",
|
|
35
35
|
onVerify,
|
|
36
36
|
onError,
|
|
37
37
|
className
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/AifeaturesCaptcha.tsx"],"sourcesContent":["export { AifeaturesCaptcha } from './AifeaturesCaptcha';\nexport type { AifeaturesCaptchaProps } from './AifeaturesCaptcha';\n","import { useState, useEffect } from 'react';\nimport { Turnstile } from '@marsidev/react-turnstile';\n\nexport interface AifeaturesCaptchaProps {\n /** Form ID from aifeatures - used to fetch the Turnstile sitekey */\n formId: string;\n /** Base URL for the aifeatures API (defaults to https://
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/AifeaturesCaptcha.tsx"],"sourcesContent":["export { AifeaturesCaptcha } from './AifeaturesCaptcha';\nexport type { AifeaturesCaptchaProps } from './AifeaturesCaptcha';\n","import { useState, useEffect } from 'react';\nimport { Turnstile } from '@marsidev/react-turnstile';\n\nexport interface AifeaturesCaptchaProps {\n /** Form ID from aifeatures - used to fetch the Turnstile sitekey */\n formId: string;\n /** Base URL for the aifeatures API (defaults to https://aifeatures.dev) */\n apiUrl?: string;\n /** Called when CAPTCHA verification succeeds */\n onVerify?: (token: string) => void;\n /** Called when CAPTCHA verification fails or expires */\n onError?: () => void;\n /** Additional class name for the container */\n className?: string;\n}\n\ninterface FormConfig {\n id: string;\n name: string;\n endpoint_url: string;\n turnstile_sitekey: string | null;\n}\n\n/**\n * A CAPTCHA component that handles Turnstile verification for aifeatures forms.\n *\n * Drop this into any form to add CAPTCHA protection. It renders:\n * - A hidden input field named \"cf-turnstile-response\" with the verification token\n * - The Turnstile widget (only if CAPTCHA is enabled for the form)\n *\n * @example\n * ```tsx\n * <form action={`https://aifeatures.dev/f/${formId}`} method=\"POST\">\n * <input name=\"email\" type=\"email\" required />\n * <textarea name=\"message\" />\n * <AifeaturesCaptcha formId={formId} />\n * <button type=\"submit\">Send</button>\n * </form>\n * ```\n */\nexport function AifeaturesCaptcha({\n formId,\n apiUrl = 'https://aifeatures.dev',\n onVerify,\n onError,\n className,\n}: AifeaturesCaptchaProps) {\n const [sitekey, setSitekey] = useState<string | null>(null);\n const [token, setToken] = useState('');\n const [isLoading, setIsLoading] = useState(true);\n\n useEffect(() => {\n setIsLoading(true);\n fetch(`${apiUrl}/f/${formId}/config`)\n .then((r) => r.json())\n .then((config: FormConfig) => {\n setSitekey(config.turnstile_sitekey);\n setIsLoading(false);\n })\n .catch(() => {\n setIsLoading(false);\n });\n }, [formId, apiUrl]);\n\n const handleSuccess = (newToken: string) => {\n setToken(newToken);\n onVerify?.(newToken);\n };\n\n const handleError = () => {\n setToken('');\n onError?.();\n };\n\n const handleExpire = () => {\n setToken('');\n onError?.();\n };\n\n // Don't render anything while loading or if CAPTCHA is disabled\n if (isLoading) {\n return <input type=\"hidden\" name=\"aifeatures-captcha-token\" value=\"\" />;\n }\n\n return (\n <div className={className}>\n <input type=\"hidden\" name=\"aifeatures-captcha-token\" value={token} />\n {sitekey && (\n <Turnstile\n siteKey={sitekey}\n onSuccess={handleSuccess}\n onError={handleError}\n onExpire={handleExpire}\n options={{ theme: 'light' }}\n />\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;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HANGED
|
@@ -3,7 +3,7 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
|
3
3
|
interface AifeaturesCaptchaProps {
|
|
4
4
|
/** Form ID from aifeatures - used to fetch the Turnstile sitekey */
|
|
5
5
|
formId: string;
|
|
6
|
-
/** Base URL for the aifeatures API (defaults to https://
|
|
6
|
+
/** Base URL for the aifeatures API (defaults to https://aifeatures.dev) */
|
|
7
7
|
apiUrl?: string;
|
|
8
8
|
/** Called when CAPTCHA verification succeeds */
|
|
9
9
|
onVerify?: (token: string) => void;
|
|
@@ -21,7 +21,7 @@ interface AifeaturesCaptchaProps {
|
|
|
21
21
|
*
|
|
22
22
|
* @example
|
|
23
23
|
* ```tsx
|
|
24
|
-
* <form action={`https://
|
|
24
|
+
* <form action={`https://aifeatures.dev/f/${formId}`} method="POST">
|
|
25
25
|
* <input name="email" type="email" required />
|
|
26
26
|
* <textarea name="message" />
|
|
27
27
|
* <AifeaturesCaptcha formId={formId} />
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
|
3
3
|
interface AifeaturesCaptchaProps {
|
|
4
4
|
/** Form ID from aifeatures - used to fetch the Turnstile sitekey */
|
|
5
5
|
formId: string;
|
|
6
|
-
/** Base URL for the aifeatures API (defaults to https://
|
|
6
|
+
/** Base URL for the aifeatures API (defaults to https://aifeatures.dev) */
|
|
7
7
|
apiUrl?: string;
|
|
8
8
|
/** Called when CAPTCHA verification succeeds */
|
|
9
9
|
onVerify?: (token: string) => void;
|
|
@@ -21,7 +21,7 @@ interface AifeaturesCaptchaProps {
|
|
|
21
21
|
*
|
|
22
22
|
* @example
|
|
23
23
|
* ```tsx
|
|
24
|
-
* <form action={`https://
|
|
24
|
+
* <form action={`https://aifeatures.dev/f/${formId}`} method="POST">
|
|
25
25
|
* <input name="email" type="email" required />
|
|
26
26
|
* <textarea name="message" />
|
|
27
27
|
* <AifeaturesCaptcha formId={formId} />
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/AifeaturesCaptcha.tsx"],"sourcesContent":["import { useState, useEffect } from 'react';\nimport { Turnstile } from '@marsidev/react-turnstile';\n\nexport interface AifeaturesCaptchaProps {\n /** Form ID from aifeatures - used to fetch the Turnstile sitekey */\n formId: string;\n /** Base URL for the aifeatures API (defaults to https://
|
|
1
|
+
{"version":3,"sources":["../src/AifeaturesCaptcha.tsx"],"sourcesContent":["import { useState, useEffect } from 'react';\nimport { Turnstile } from '@marsidev/react-turnstile';\n\nexport interface AifeaturesCaptchaProps {\n /** Form ID from aifeatures - used to fetch the Turnstile sitekey */\n formId: string;\n /** Base URL for the aifeatures API (defaults to https://aifeatures.dev) */\n apiUrl?: string;\n /** Called when CAPTCHA verification succeeds */\n onVerify?: (token: string) => void;\n /** Called when CAPTCHA verification fails or expires */\n onError?: () => void;\n /** Additional class name for the container */\n className?: string;\n}\n\ninterface FormConfig {\n id: string;\n name: string;\n endpoint_url: string;\n turnstile_sitekey: string | null;\n}\n\n/**\n * A CAPTCHA component that handles Turnstile verification for aifeatures forms.\n *\n * Drop this into any form to add CAPTCHA protection. It renders:\n * - A hidden input field named \"cf-turnstile-response\" with the verification token\n * - The Turnstile widget (only if CAPTCHA is enabled for the form)\n *\n * @example\n * ```tsx\n * <form action={`https://aifeatures.dev/f/${formId}`} method=\"POST\">\n * <input name=\"email\" type=\"email\" required />\n * <textarea name=\"message\" />\n * <AifeaturesCaptcha formId={formId} />\n * <button type=\"submit\">Send</button>\n * </form>\n * ```\n */\nexport function AifeaturesCaptcha({\n formId,\n apiUrl = 'https://aifeatures.dev',\n onVerify,\n onError,\n className,\n}: AifeaturesCaptchaProps) {\n const [sitekey, setSitekey] = useState<string | null>(null);\n const [token, setToken] = useState('');\n const [isLoading, setIsLoading] = useState(true);\n\n useEffect(() => {\n setIsLoading(true);\n fetch(`${apiUrl}/f/${formId}/config`)\n .then((r) => r.json())\n .then((config: FormConfig) => {\n setSitekey(config.turnstile_sitekey);\n setIsLoading(false);\n })\n .catch(() => {\n setIsLoading(false);\n });\n }, [formId, apiUrl]);\n\n const handleSuccess = (newToken: string) => {\n setToken(newToken);\n onVerify?.(newToken);\n };\n\n const handleError = () => {\n setToken('');\n onError?.();\n };\n\n const handleExpire = () => {\n setToken('');\n onError?.();\n };\n\n // Don't render anything while loading or if CAPTCHA is disabled\n if (isLoading) {\n return <input type=\"hidden\" name=\"aifeatures-captcha-token\" value=\"\" />;\n }\n\n return (\n <div className={className}>\n <input type=\"hidden\" name=\"aifeatures-captcha-token\" value={token} />\n {sitekey && (\n <Turnstile\n siteKey={sitekey}\n onSuccess={handleSuccess}\n onError={handleError}\n onExpire={handleExpire}\n options={{ theme: 'light' }}\n />\n )}\n </div>\n );\n}\n"],"mappings":";;;AAAA,SAAS,UAAU,iBAAiB;AACpC,SAAS,iBAAiB;AAgFf,cAIP,YAJO;AAzCJ,SAAS,kBAAkB;AAAA,EAChC;AAAA,EACA,SAAS;AAAA,EACT;AAAA,EACA;AAAA,EACA;AACF,GAA2B;AACzB,QAAM,CAAC,SAAS,UAAU,IAAI,SAAwB,IAAI;AAC1D,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAS,EAAE;AACrC,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,IAAI;AAE/C,YAAU,MAAM;AACd,iBAAa,IAAI;AACjB,UAAM,GAAG,MAAM,MAAM,MAAM,SAAS,EACjC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,EACpB,KAAK,CAAC,WAAuB;AAC5B,iBAAW,OAAO,iBAAiB;AACnC,mBAAa,KAAK;AAAA,IACpB,CAAC,EACA,MAAM,MAAM;AACX,mBAAa,KAAK;AAAA,IACpB,CAAC;AAAA,EACL,GAAG,CAAC,QAAQ,MAAM,CAAC;AAEnB,QAAM,gBAAgB,CAAC,aAAqB;AAC1C,aAAS,QAAQ;AACjB,eAAW,QAAQ;AAAA,EACrB;A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