Skip to content

Commit db4602b

Browse files
committed
Updated Types
1 parent 0bac5e9 commit db4602b

File tree

4 files changed

+96
-85
lines changed

4 files changed

+96
-85
lines changed

package/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
"./schema": "./src/schema.ts",
3030
"./client": "./lib/client.ts",
3131
"./server": "./lib/server.ts",
32-
"./components/TurnstileWidget": "./lib/components/TurnstileWidget",
33-
"./components/TurnstileForm": "./lib/components/TurnstileForm"
32+
"./components/TurnstileWidget": "./lib/components/TurnstileWidget.astro",
33+
"./components/TurnstileForm": "./lib/components/TurnstileForm.astro"
3434
},
3535
"scripts": {},
3636
"type": "module",

package/src/integration.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ export const astroTurnstile = defineIntegration({
148148
"virtual:astro-turnstile/config": `export default ${JSON.stringify(
149149
options,
150150
)}`,
151-
"astro-turnstile:components/TurnstileWidget": `export * from '${name}/components';`,
152-
"astro-turnstile:components/TurnstileForm": `export * from '${name}/components';`,
151+
"astro-turnstile:components/TurnstileWidget": `import Widget from '${name}/components/TurnstileWidget'; export default Widget;`,
152+
"astro-turnstile:components/TurnstileForm": `import Form from '${name}/components/TurnstileForm'; export default Form;`,
153153
},
154154
});
155155

package/src/stubs.ts

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -26,45 +26,45 @@ components.addSingleLineNote(
2626
);
2727

2828
// Add the module to the file
29-
components.addModule("astro-turnstile:components", {
30-
namedExports: [
31-
{
32-
name: "TurnstileWidget",
33-
typeDef: `typeof import('${name}/components/TurnstileWidget.astro').TurnstileWidget`,
34-
multiLineDescription: [
35-
"# Turnstile Verification Widget",
36-
"@description An [Astro](https://astro.build) component that is used to render a Turnstile verification widget. This widget is used to verify that a user is human.",
37-
`@param {"auto"|"light"|"dark"} theme - The theme for the widget. (default: "auto")`,
38-
`@param {"normal"|"compact"|"flexible"} size - The size for the widget. (default: "normal")`,
39-
`@param {string} margin - The margin for the widget element. (default: '0.5rem')`,
40-
"@example",
41-
"```tsx",
42-
"---",
43-
`import { TurnstileWidget } from '${name}:components';`,
44-
"---",
45-
"<form action='/your/api/endpoint' method='POST'>",
46-
"<TurnstileWidget theme='light' size='compact' margin='1rem' />",
47-
"<button type='submit'>Submit</button>",
48-
"</form>",
49-
],
50-
},
51-
{
52-
name: "TurnstileForm",
53-
typeDef: `typeof import('${name}/components/TurnstileForm.astro').TurnstileForm`,
54-
multiLineDescription: [
55-
"# Turnstile Verification Form",
56-
"@description An [Astro](https://astro.build) component that is used to render a Turnstile verification form. This form includes a Turnstile verification widget and a submit button.",
57-
"@slot default - Any unassigned content will be placed here.",
58-
"@slot header - `<div slot='header'>...</div>`",
59-
"@slot buttons - `<div slot='buttons'>...</div>`",
60-
"@slot footer - `<div slot='footer'>...</div>`",
61-
`@param {"auto"|"light"|"dark"} theme - The theme for the widget. (default: "auto")`,
62-
`@param {"normal"|"compact"|"flexible"} size - The size for the widget. (default: "normal")`,
63-
`@param {string} margin - The margin for the widget element. (default: '0.5rem')`,
64-
`@param {"multipart/form-data"|"application/x-www-form-urlencoded"|"submit"} enctype - The form enctype. (default: 'application/x-www-form-urlencoded')`,
65-
],
66-
},
67-
],
29+
components.addModule("astro-turnstile:components/TurnstileWidget", {
30+
defaultExport: {
31+
typeDef: `typeof import('${name}/components/TurnstileWidget.astro').TurnstileWidget`,
32+
multiLineDescription: [
33+
"# Turnstile Verification Widget",
34+
"@description An [Astro](https://astro.build) component that is used to render a Turnstile verification widget. This widget is used to verify that a user is human.",
35+
`@param {"auto"|"light"|"dark"} theme - The theme for the widget. (default: "auto")`,
36+
`@param {"normal"|"compact"|"flexible"} size - The size for the widget. (default: "normal")`,
37+
`@param {string} margin - The margin for the widget element. (default: '0.5rem')`,
38+
"@example",
39+
"```tsx",
40+
"---",
41+
`import TurnstileWidget from '${name}:components/TurnstileWidget';`,
42+
"---",
43+
"<form action='/your/api/endpoint' method='POST'>",
44+
"<TurnstileWidget theme='light' size='compact' margin='1rem' />",
45+
"<button type='submit'>Submit</button>",
46+
"</form>",
47+
],
48+
},
49+
});
50+
51+
// Add the module to the file
52+
components.addModule("astro-turnstile:components/TurnstileForm", {
53+
defaultExport: {
54+
typeDef: `typeof import('${name}/components/TurnstileForm.astro').TurnstileForm`,
55+
multiLineDescription: [
56+
"# Turnstile Verification Form",
57+
"@description An [Astro](https://astro.build) component that is used to render a Turnstile verification form. This form includes a Turnstile verification widget and a submit button.",
58+
"@slot default - Any unassigned content will be placed here.",
59+
"@slot header - `<div slot='header'>...</div>`",
60+
"@slot buttons - `<div slot='buttons'>...</div>`",
61+
"@slot footer - `<div slot='footer'>...</div>`",
62+
`@param {"auto"|"light"|"dark"} theme - The theme for the widget. (default: "auto")`,
63+
`@param {"normal"|"compact"|"flexible"} size - The size for the widget. (default: "normal")`,
64+
`@param {string} margin - The margin for the widget element. (default: '0.5rem')`,
65+
`@param {"multipart/form-data"|"application/x-www-form-urlencoded"|"submit"} enctype - The form enctype. (default: 'application/x-www-form-urlencoded')`,
66+
],
67+
},
6868
});
6969

7070
// Export the DTS files

playground/src/pages/index.astro

Lines changed: 53 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,68 @@
11
---
2-
import TurnstileForm from "astro-turnstile/components/TurnstileForm";
3-
import Layout from "../layouts/Layout.astro";
2+
import TurnstileForm from 'astro-turnstile/components/TurnstileForm';
3+
import Layout from '../layouts/Layout.astro';
4+
import TurnstileWidget from 'astro-turnstile:components/TurnstileWidget';
45
5-
if (Astro.request.method === "POST") {
6-
console.log("success");
6+
if (Astro.request.method === 'POST') {
7+
console.log('success');
78
}
89
---
910

1011
<Layout title="Welcome to Astro.">
1112
<main>
13+
<form>
14+
<label>
15+
Username:
16+
<input type="text" name="username" required />
17+
</label>
18+
<button type="submit">Submit</button>
19+
<TurnstileWidget />
20+
</form>
21+
<!-- <main>
1222
<TurnstileForm action="/" method={'POST'} enctype={'submit'}>
1323
<label>
1424
Username:
1525
<input type="text" name="username" required />
1626
</label>
1727
</TurnstileForm>
28+
</main> -->
1829
</main>
19-
</Layout>
2030

21-
<style is:global>
22-
main {
23-
max-width: 600px;
24-
margin: 0 auto;
25-
padding: 20px;
26-
}
27-
28-
form {
29-
display: flex;
30-
flex-direction: column;
31-
}
32-
33-
label {
34-
margin-bottom: 10px;
35-
}
36-
37-
input[type='text'] {
38-
padding: 8px;
39-
font-size: 16px;
40-
border: 1px solid #ccc;
41-
border-radius: 4px;
42-
}
43-
44-
button {
45-
padding: 10px 20px;
46-
background-color: #007bff;
47-
color: white;
48-
border: none;
49-
border-radius: 4px;
50-
cursor: pointer;
51-
font-size: 16px;
52-
}
53-
54-
button:hover {
55-
background-color: #0056b3;
56-
}
57-
</style>
31+
<style is:global>
32+
main {
33+
max-width: 600px;
34+
margin: 0 auto;
35+
padding: 20px;
36+
}
37+
38+
form {
39+
display: flex;
40+
flex-direction: column;
41+
}
42+
43+
label {
44+
margin-bottom: 10px;
45+
}
46+
47+
input[type='text'] {
48+
padding: 8px;
49+
font-size: 16px;
50+
border: 1px solid #ccc;
51+
border-radius: 4px;
52+
}
53+
54+
button {
55+
padding: 10px 20px;
56+
background-color: #007bff;
57+
color: white;
58+
border: none;
59+
border-radius: 4px;
60+
cursor: pointer;
61+
font-size: 16px;
62+
}
63+
64+
button:hover {
65+
background-color: #0056b3;
66+
}
67+
</style>
68+
</Layout>

0 commit comments

Comments
 (0)