@tanstack/cta-framework-solid 0.10.0-alpha.20
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/ADD-ON-AUTHORING.md +129 -0
- package/LICENSE +21 -0
- package/add-ons/form/assets/src/routes/demo.form.tsx.ejs +352 -0
- package/add-ons/form/info.json +16 -0
- package/add-ons/form/package.json +5 -0
- package/add-ons/module-federation/assets/module-federation.config.js.ejs +27 -0
- package/add-ons/module-federation/assets/src/demo-mf-component.tsx +3 -0
- package/add-ons/module-federation/assets/src/demo-mf-self-contained.tsx +9 -0
- package/add-ons/module-federation/info.json +8 -0
- package/add-ons/module-federation/package.json +5 -0
- package/add-ons/sentry/assets/_dot_cursorrules.append +22 -0
- package/add-ons/sentry/assets/_dot_env.local.append +2 -0
- package/add-ons/sentry/assets/src/routes/demo.sentry.bad-event-handler.tsx +20 -0
- package/add-ons/sentry/info.json +16 -0
- package/add-ons/sentry/package.json +5 -0
- package/add-ons/solid-ui/README.md +9 -0
- package/add-ons/solid-ui/assets/src/lib/utils.ts +6 -0
- package/add-ons/solid-ui/assets/src/styles.css +138 -0
- package/add-ons/solid-ui/assets/ui.config.json +13 -0
- package/add-ons/solid-ui/info.json +12 -0
- package/add-ons/solid-ui/package.json +9 -0
- package/add-ons/start/assets/app.config.ts.ejs +19 -0
- package/add-ons/start/assets/src/api.ts +6 -0
- package/add-ons/start/assets/src/client.tsx +7 -0
- package/add-ons/start/assets/src/router.tsx.ejs +24 -0
- package/add-ons/start/assets/src/routes/demo.start.server-funcs.tsx +49 -0
- package/add-ons/start/assets/src/ssr.tsx +12 -0
- package/add-ons/start/info.json +17 -0
- package/add-ons/start/package.json +12 -0
- package/add-ons/store/assets/src/lib/demo-store.ts +13 -0
- package/add-ons/store/assets/src/routes/demo.store.tsx.ejs +77 -0
- package/add-ons/store/info.json +16 -0
- package/add-ons/store/package.json +6 -0
- package/add-ons/t3env/README.md +16 -0
- package/add-ons/t3env/assets/src/env.ts +39 -0
- package/add-ons/t3env/info.json +8 -0
- package/add-ons/t3env/package.json +6 -0
- package/add-ons/tanstack-query/assets/src/integrations/tanstack-query/header-user.tsx +5 -0
- package/add-ons/tanstack-query/assets/src/integrations/tanstack-query/provider.tsx +15 -0
- package/add-ons/tanstack-query/assets/src/routes/demo.tanstack-query.tsx +24 -0
- package/add-ons/tanstack-query/info.json +28 -0
- package/add-ons/tanstack-query/package.json +6 -0
- package/dist/index.js +18 -0
- package/dist/types/index.d.ts +1 -0
- package/examples/tanchat/README.md +52 -0
- package/examples/tanchat/assets/ai-streaming-server/README.md +110 -0
- package/examples/tanchat/assets/ai-streaming-server/_dot_env.example +1 -0
- package/examples/tanchat/assets/ai-streaming-server/package.json +26 -0
- package/examples/tanchat/assets/ai-streaming-server/src/index.ts +102 -0
- package/examples/tanchat/assets/ai-streaming-server/tsconfig.json +15 -0
- package/examples/tanchat/assets/src/components/demo.SettingsDialog.tsx +149 -0
- package/examples/tanchat/assets/src/demo.index.css +227 -0
- package/examples/tanchat/assets/src/lib/demo-store.ts +13 -0
- package/examples/tanchat/assets/src/routes/example.chat.tsx +435 -0
- package/examples/tanchat/assets/src/store/demo.hooks.ts +17 -0
- package/examples/tanchat/assets/src/store/demo.store.ts +133 -0
- package/examples/tanchat/info.json +15 -0
- package/examples/tanchat/package.json +7 -0
- package/package.json +33 -0
- package/project/base/README.md.ejs +215 -0
- package/project/base/_dot_cursorrules.append +35 -0
- package/project/base/_dot_gitignore +5 -0
- package/project/base/_dot_vscode/settings.json.ejs +35 -0
- package/project/base/index.html.ejs +20 -0
- package/project/base/package.json +23 -0
- package/project/base/public/favicon.ico +0 -0
- package/project/base/public/logo192.png +0 -0
- package/project/base/public/logo512.png +0 -0
- package/project/base/public/manifest.json +25 -0
- package/project/base/public/robots.txt +3 -0
- package/project/base/src/App.css.ejs +38 -0
- package/project/base/src/App.tsx.ejs +34 -0
- package/project/base/src/components/Header.tsx.ejs +26 -0
- package/project/base/src/logo.svg +120 -0
- package/project/base/src/main.tsx.ejs +126 -0
- package/project/base/src/routes/__root.tsx.ejs +38 -0
- package/project/base/src/routes/index.tsx.ejs +41 -0
- package/project/base/src/styles.css.ejs +15 -0
- package/project/base/tsconfig.json.ejs +31 -0
- package/project/base/vite.config.js.ejs +22 -0
- package/project/packages.json +18 -0
- package/src/index.ts +26 -0
- package/tests/snapshots/solid/solid-cr-js-npm.json +22 -0
- package/tests/snapshots/solid/solid-cr-ts-npm.json +23 -0
- package/tests/snapshots/solid/solid-cr-ts-start-npm.json +27 -0
- package/tests/snapshots/solid/solid-fr-ts-npm.json +24 -0
- package/tests/snapshots/solid/solid-fr-ts-tw-npm.json +23 -0
- package/tests/solid.test.ts +119 -0
- package/tests/test-utilities.ts +44 -0
- package/toolchains/biome/assets/biome.json.ejs +31 -0
- package/toolchains/biome/info.json +8 -0
- package/toolchains/biome/package.json +10 -0
- package/toolchains/eslint/assets/_dot_prettierignore +3 -0
- package/toolchains/eslint/assets/eslint.config.js +5 -0
- package/toolchains/eslint/assets/prettier.config.js +10 -0
- package/toolchains/eslint/info.json +8 -0
- package/toolchains/eslint/package.json +11 -0
- package/tsconfig.json +17 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# Add-on Authoring for the CTA Framework for Solid
|
|
2
|
+
|
|
3
|
+
# Available Integrations
|
|
4
|
+
|
|
5
|
+
These are the available integration points for the Solid Framework.
|
|
6
|
+
|
|
7
|
+
## header-user
|
|
8
|
+
|
|
9
|
+
Integrates into the `Header` component shared by all routes. These components are placed in the right hand side of the header bar.
|
|
10
|
+
|
|
11
|
+
The code is always integrated into the `src/components/Header.(tsx|jsx)` file.
|
|
12
|
+
|
|
13
|
+
### Examples
|
|
14
|
+
|
|
15
|
+
Code in `assets/src/components/my-header.tsx`:
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
export default function MyHeader() {
|
|
19
|
+
return <div>Header User</div>
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Configuration in `info.json`:
|
|
24
|
+
|
|
25
|
+
```json
|
|
26
|
+
"integrations": [
|
|
27
|
+
{
|
|
28
|
+
"type": "header-user",
|
|
29
|
+
"jsName": "MyHeader",
|
|
30
|
+
"path": "src/components/my-header.tsx"
|
|
31
|
+
},
|
|
32
|
+
]
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## layout
|
|
36
|
+
|
|
37
|
+
Handles injecting a component into the layout of the page:
|
|
38
|
+
|
|
39
|
+
The code is integrated into these locations with these application architectures:
|
|
40
|
+
|
|
41
|
+
- `code-router` - In the `src/main.tsx` (or `src/main.jsx`) file
|
|
42
|
+
- `file-router` - In the `src/__root.tsx` file
|
|
43
|
+
- `file-router` with `start` - In the `src/main.tsx` file
|
|
44
|
+
|
|
45
|
+
### Examples
|
|
46
|
+
|
|
47
|
+
Code in `assets/src/components/my-layout.tsx`:
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
export default function MyLayout() {
|
|
51
|
+
return <div>Hi from MyLayout!</div>
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Configuration in `info.json`:
|
|
56
|
+
|
|
57
|
+
```json
|
|
58
|
+
"integrations": [
|
|
59
|
+
{
|
|
60
|
+
"type": "layout",
|
|
61
|
+
"jsName": "MyLayout",
|
|
62
|
+
"path": "src/components/my-layout.tsx"
|
|
63
|
+
},
|
|
64
|
+
]
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## provider
|
|
68
|
+
|
|
69
|
+
Handles placing UI style provider wrappers into the right spot in three different applicatin setups:
|
|
70
|
+
|
|
71
|
+
The code is integrated into these locations with these application architectures:
|
|
72
|
+
|
|
73
|
+
- `code-router` - In the `src/main.tsx` (or `src/main.jsx`) file
|
|
74
|
+
- `file-router` - In the `src/__root.tsx` file
|
|
75
|
+
- `file-router` with `start` - In the `src/main.tsx` file
|
|
76
|
+
|
|
77
|
+
### Examples
|
|
78
|
+
|
|
79
|
+
Code in `assets/src/components/my-provider.tsx`:
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
export default function MyProvider({ children }: { children: React.ReactNode }) {
|
|
83
|
+
return <SomeKindOfProvider>{children}</SomeKindOfProvider>
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Configuration in `info.json`:
|
|
88
|
+
|
|
89
|
+
```json
|
|
90
|
+
"integrations": [
|
|
91
|
+
{
|
|
92
|
+
"type": "provider",
|
|
93
|
+
"jsName": "MyProvider",
|
|
94
|
+
"path": "src/components/my-provider.tsx"
|
|
95
|
+
},
|
|
96
|
+
]
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
# Routes
|
|
100
|
+
|
|
101
|
+
If your add-on creates routes you need to specify those in the `info.json` file.
|
|
102
|
+
|
|
103
|
+
This example will define a route at `/demo/my-demo-route` that will be rendered by the `DemoMyDemoRoute` component. There will be a `Demo Route` link in the header to this route.
|
|
104
|
+
|
|
105
|
+
```json
|
|
106
|
+
"routes": [
|
|
107
|
+
{
|
|
108
|
+
"url": "/demo/my-demo-route",
|
|
109
|
+
"name": "Demo Route",
|
|
110
|
+
"path": "src/routes/demo.my-demo-route.tsx",
|
|
111
|
+
"jsName": "DemoMyDemoRoute"
|
|
112
|
+
}
|
|
113
|
+
],
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
If you don't want a header link you can omit the `url` and `name` properties.
|
|
117
|
+
|
|
118
|
+
```json
|
|
119
|
+
"routes": [
|
|
120
|
+
{
|
|
121
|
+
"path": "src/routes/demo.my-hidden-demo-route.tsx",
|
|
122
|
+
"jsName": "DemoMyHiddenDemoRoute"
|
|
123
|
+
}
|
|
124
|
+
],
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
You **MUST** specify routes in the `info.json` file if your add-on supports the `code-router` mode. This is because the `code-routers` setup needs to import the routes in order to add them to the router.
|
|
128
|
+
|
|
129
|
+
By convension you should prefix demo routes with `demo` to make it clear that they are demo routes so they can be easily identified and removed.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021-present Tanner Linsley
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
import { <% if (fileRouter) { %>createFileRoute<% } else { %>createRoute<% } %> } from '@tanstack/solid-router'
|
|
2
|
+
import { createForm } from '@tanstack/solid-form'
|
|
3
|
+
|
|
4
|
+
import type { JSX } from 'solid-js/jsx-runtime'
|
|
5
|
+
import type { ValidationError } from '@tanstack/solid-form'
|
|
6
|
+
|
|
7
|
+
<% if (codeRouter) { %>
|
|
8
|
+
import type { RootRoute } from '@tanstack/solid-router'
|
|
9
|
+
<% } else { %>
|
|
10
|
+
export const Route = createFileRoute('/demo/form')({
|
|
11
|
+
component: FormExample,
|
|
12
|
+
})
|
|
13
|
+
<% } %>
|
|
14
|
+
function FieldWrapper(props: {
|
|
15
|
+
children: JSX.Element
|
|
16
|
+
errors: Array<ValidationError>
|
|
17
|
+
label: string
|
|
18
|
+
}) {
|
|
19
|
+
return (
|
|
20
|
+
<div>
|
|
21
|
+
<label for={props.label} class="block font-bold mb-1 text-xl">
|
|
22
|
+
{props.label}
|
|
23
|
+
</label>
|
|
24
|
+
{props.children}
|
|
25
|
+
{props.errors.length ? (
|
|
26
|
+
<div class="text-red-500 mt-1 font-bold">{props.errors.join(', ')}</div>
|
|
27
|
+
) : null}
|
|
28
|
+
</div>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function FormExample() {
|
|
33
|
+
const form = createForm(() => ({
|
|
34
|
+
defaultValues: {
|
|
35
|
+
fullName: '',
|
|
36
|
+
email: '',
|
|
37
|
+
address: {
|
|
38
|
+
street: '',
|
|
39
|
+
city: '',
|
|
40
|
+
state: '',
|
|
41
|
+
zipCode: '',
|
|
42
|
+
country: '',
|
|
43
|
+
},
|
|
44
|
+
phone: '',
|
|
45
|
+
},
|
|
46
|
+
onSubmit: ({ value }) => {
|
|
47
|
+
console.log(value)
|
|
48
|
+
// Show success message
|
|
49
|
+
alert('Form submitted successfully!')
|
|
50
|
+
},
|
|
51
|
+
}))
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<div
|
|
55
|
+
class="flex items-center justify-center min-h-screen bg-gradient-to-br from-purple-100 to-blue-100 p-4 text-white"
|
|
56
|
+
style={{
|
|
57
|
+
'background-image':
|
|
58
|
+
'radial-gradient(50% 50% at 5% 40%, #f4a460 0%, #8b4513 70%, #1a0f0a 100%)',
|
|
59
|
+
}}
|
|
60
|
+
>
|
|
61
|
+
<div class="w-full max-w-2xl p-8 rounded-xl backdrop-blur-md bg-black/50 shadow-xl border-8 border-black/10">
|
|
62
|
+
<form
|
|
63
|
+
onSubmit={(e) => {
|
|
64
|
+
e.preventDefault()
|
|
65
|
+
e.stopPropagation()
|
|
66
|
+
form.handleSubmit()
|
|
67
|
+
}}
|
|
68
|
+
class="space-y-6"
|
|
69
|
+
>
|
|
70
|
+
{/* Full Name Field */}
|
|
71
|
+
<div>
|
|
72
|
+
<form.Field
|
|
73
|
+
name="fullName"
|
|
74
|
+
validators={{
|
|
75
|
+
onBlur: ({ value }) => {
|
|
76
|
+
if (value.trim().length === 0) {
|
|
77
|
+
return 'Full name is required'
|
|
78
|
+
}
|
|
79
|
+
if (value.length < 3) {
|
|
80
|
+
return 'Name must be at least 3 characters'
|
|
81
|
+
}
|
|
82
|
+
return undefined
|
|
83
|
+
},
|
|
84
|
+
}}
|
|
85
|
+
children={(field) => (
|
|
86
|
+
<FieldWrapper
|
|
87
|
+
label="Full Name"
|
|
88
|
+
errors={field().state.meta.errors}
|
|
89
|
+
>
|
|
90
|
+
<input
|
|
91
|
+
id="fullName"
|
|
92
|
+
name="fullName"
|
|
93
|
+
value={field().state.value}
|
|
94
|
+
onBlur={field().handleBlur}
|
|
95
|
+
onChange={(e) => field().handleChange(e.target.value)}
|
|
96
|
+
class="w-full px-4 py-2 rounded-md border border-gray-300 focus:outline-none focus:ring-2 focus:ring-indigo-500"
|
|
97
|
+
/>
|
|
98
|
+
</FieldWrapper>
|
|
99
|
+
)}
|
|
100
|
+
/>
|
|
101
|
+
</div>
|
|
102
|
+
|
|
103
|
+
{/* Email Field */}
|
|
104
|
+
<div>
|
|
105
|
+
<form.Field
|
|
106
|
+
name="email"
|
|
107
|
+
validators={{
|
|
108
|
+
onBlur: ({ value }) => {
|
|
109
|
+
if (!value || value.trim().length === 0) {
|
|
110
|
+
return 'Email is required'
|
|
111
|
+
}
|
|
112
|
+
if (!/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i.test(value)) {
|
|
113
|
+
return 'Invalid email address'
|
|
114
|
+
}
|
|
115
|
+
return undefined
|
|
116
|
+
},
|
|
117
|
+
}}
|
|
118
|
+
children={(field) => (
|
|
119
|
+
<FieldWrapper
|
|
120
|
+
label="Email Address"
|
|
121
|
+
errors={field().state.meta.errors}
|
|
122
|
+
>
|
|
123
|
+
<input
|
|
124
|
+
id="email"
|
|
125
|
+
name="email"
|
|
126
|
+
type="email"
|
|
127
|
+
value={field().state.value}
|
|
128
|
+
onBlur={field().handleBlur}
|
|
129
|
+
onChange={(e) => field().handleChange(e.target.value)}
|
|
130
|
+
class="w-full px-4 py-2 rounded-md border border-gray-300 focus:outline-none focus:ring-2 focus:ring-indigo-500"
|
|
131
|
+
/>
|
|
132
|
+
</FieldWrapper>
|
|
133
|
+
)}
|
|
134
|
+
/>
|
|
135
|
+
</div>
|
|
136
|
+
|
|
137
|
+
{/* Street Address */}
|
|
138
|
+
<div>
|
|
139
|
+
<form.Field
|
|
140
|
+
name="address.street"
|
|
141
|
+
validators={{
|
|
142
|
+
onBlur: ({ value }) => {
|
|
143
|
+
if (!value || value.trim().length === 0) {
|
|
144
|
+
return 'Street address is required'
|
|
145
|
+
}
|
|
146
|
+
return undefined
|
|
147
|
+
},
|
|
148
|
+
}}
|
|
149
|
+
children={(field) => (
|
|
150
|
+
<FieldWrapper
|
|
151
|
+
label="Street Address"
|
|
152
|
+
errors={field().state.meta.errors}
|
|
153
|
+
>
|
|
154
|
+
<input
|
|
155
|
+
id="street"
|
|
156
|
+
name="street"
|
|
157
|
+
value={field().state.value}
|
|
158
|
+
onBlur={field().handleBlur}
|
|
159
|
+
onChange={(e) => field().handleChange(e.target.value)}
|
|
160
|
+
class="w-full px-4 py-2 rounded-md border border-gray-300 focus:outline-none focus:ring-2 focus:ring-indigo-500"
|
|
161
|
+
/>
|
|
162
|
+
</FieldWrapper>
|
|
163
|
+
)}
|
|
164
|
+
/>
|
|
165
|
+
</div>
|
|
166
|
+
|
|
167
|
+
{/* City, State, Zip in a row */}
|
|
168
|
+
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
|
|
169
|
+
{/* City */}
|
|
170
|
+
<form.Field
|
|
171
|
+
name="address.city"
|
|
172
|
+
validators={{
|
|
173
|
+
onBlur: ({ value }) => {
|
|
174
|
+
if (!value || value.trim().length === 0) {
|
|
175
|
+
return 'City is required'
|
|
176
|
+
}
|
|
177
|
+
return undefined
|
|
178
|
+
},
|
|
179
|
+
}}
|
|
180
|
+
children={(field) => (
|
|
181
|
+
<FieldWrapper label="City" errors={field().state.meta.errors}>
|
|
182
|
+
<input
|
|
183
|
+
id="city"
|
|
184
|
+
name="city"
|
|
185
|
+
value={field().state.value}
|
|
186
|
+
onBlur={field().handleBlur}
|
|
187
|
+
onChange={(e) => field().handleChange(e.target.value)}
|
|
188
|
+
class="w-full px-4 py-2 rounded-md border border-gray-300 focus:outline-none focus:ring-2 focus:ring-indigo-500"
|
|
189
|
+
/>
|
|
190
|
+
</FieldWrapper>
|
|
191
|
+
)}
|
|
192
|
+
/>
|
|
193
|
+
|
|
194
|
+
{/* State */}
|
|
195
|
+
<form.Field
|
|
196
|
+
name="address.state"
|
|
197
|
+
validators={{
|
|
198
|
+
onBlur: ({ value }) => {
|
|
199
|
+
if (!value || value.trim().length === 0) {
|
|
200
|
+
return 'State is required'
|
|
201
|
+
}
|
|
202
|
+
return undefined
|
|
203
|
+
},
|
|
204
|
+
}}
|
|
205
|
+
children={(field) => (
|
|
206
|
+
<FieldWrapper label="State" errors={field().state.meta.errors}>
|
|
207
|
+
<input
|
|
208
|
+
id="state"
|
|
209
|
+
name="state"
|
|
210
|
+
value={field().state.value}
|
|
211
|
+
onBlur={field().handleBlur}
|
|
212
|
+
onChange={(e) => field().handleChange(e.target.value)}
|
|
213
|
+
class="w-full px-4 py-2 rounded-md border border-gray-300 focus:outline-none focus:ring-2 focus:ring-indigo-500"
|
|
214
|
+
/>
|
|
215
|
+
</FieldWrapper>
|
|
216
|
+
)}
|
|
217
|
+
/>
|
|
218
|
+
|
|
219
|
+
{/* Zip Code */}
|
|
220
|
+
<form.Field
|
|
221
|
+
name="address.zipCode"
|
|
222
|
+
validators={{
|
|
223
|
+
onBlur: ({ value }) => {
|
|
224
|
+
if (!value || value.trim().length === 0) {
|
|
225
|
+
return 'Zip code is required'
|
|
226
|
+
}
|
|
227
|
+
if (!/^\d{5}(-\d{4})?$/.test(value)) {
|
|
228
|
+
return 'Invalid zip code format'
|
|
229
|
+
}
|
|
230
|
+
return undefined
|
|
231
|
+
},
|
|
232
|
+
}}
|
|
233
|
+
children={(field) => (
|
|
234
|
+
<FieldWrapper
|
|
235
|
+
label="Zip Code"
|
|
236
|
+
errors={field().state.meta.errors}
|
|
237
|
+
>
|
|
238
|
+
<input
|
|
239
|
+
id="zipCode"
|
|
240
|
+
name="zipCode"
|
|
241
|
+
value={field().state.value}
|
|
242
|
+
onBlur={field().handleBlur}
|
|
243
|
+
onChange={(e) => field().handleChange(e.target.value)}
|
|
244
|
+
class="w-full px-4 py-2 rounded-md border border-gray-300 focus:outline-none focus:ring-2 focus:ring-indigo-500"
|
|
245
|
+
/>
|
|
246
|
+
</FieldWrapper>
|
|
247
|
+
)}
|
|
248
|
+
/>
|
|
249
|
+
</div>
|
|
250
|
+
|
|
251
|
+
{/* Country */}
|
|
252
|
+
<div>
|
|
253
|
+
<form.Field
|
|
254
|
+
name="address.country"
|
|
255
|
+
validators={{
|
|
256
|
+
onBlur: ({ value }) => {
|
|
257
|
+
if (!value || value.trim().length === 0) {
|
|
258
|
+
return 'Country is required'
|
|
259
|
+
}
|
|
260
|
+
return undefined
|
|
261
|
+
},
|
|
262
|
+
}}
|
|
263
|
+
children={(field) => (
|
|
264
|
+
<FieldWrapper
|
|
265
|
+
label="Country"
|
|
266
|
+
errors={field().state.meta.errors}
|
|
267
|
+
>
|
|
268
|
+
<select
|
|
269
|
+
id="country"
|
|
270
|
+
name="country"
|
|
271
|
+
value={field().state.value}
|
|
272
|
+
onBlur={field().handleBlur}
|
|
273
|
+
onChange={(e) => field().handleChange(e.target.value)}
|
|
274
|
+
class="w-full px-4 py-2 rounded-md border border-gray-300 focus:outline-none focus:ring-2 focus:ring-indigo-500"
|
|
275
|
+
>
|
|
276
|
+
<option value="">Select a country</option>
|
|
277
|
+
<option value="US">United States</option>
|
|
278
|
+
<option value="CA">Canada</option>
|
|
279
|
+
<option value="UK">United Kingdom</option>
|
|
280
|
+
<option value="AU">Australia</option>
|
|
281
|
+
<option value="DE">Germany</option>
|
|
282
|
+
<option value="FR">France</option>
|
|
283
|
+
<option value="JP">Japan</option>
|
|
284
|
+
</select>
|
|
285
|
+
</FieldWrapper>
|
|
286
|
+
)}
|
|
287
|
+
/>
|
|
288
|
+
</div>
|
|
289
|
+
|
|
290
|
+
{/* Phone Number */}
|
|
291
|
+
<div>
|
|
292
|
+
<form.Field
|
|
293
|
+
name="phone"
|
|
294
|
+
validators={{
|
|
295
|
+
onBlur: ({ value }) => {
|
|
296
|
+
if (!value || value.trim().length === 0) {
|
|
297
|
+
return 'Phone number is required'
|
|
298
|
+
}
|
|
299
|
+
if (
|
|
300
|
+
!/^(\+\d{1,3})?\s?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}$/.test(
|
|
301
|
+
value,
|
|
302
|
+
)
|
|
303
|
+
) {
|
|
304
|
+
return 'Invalid phone number format'
|
|
305
|
+
}
|
|
306
|
+
return undefined
|
|
307
|
+
},
|
|
308
|
+
}}
|
|
309
|
+
children={(field) => (
|
|
310
|
+
<FieldWrapper
|
|
311
|
+
label="Phone Number"
|
|
312
|
+
errors={field().state.meta.errors}
|
|
313
|
+
>
|
|
314
|
+
<input
|
|
315
|
+
id="phone"
|
|
316
|
+
name="phone"
|
|
317
|
+
type="tel"
|
|
318
|
+
value={field().state.value}
|
|
319
|
+
onBlur={field().handleBlur}
|
|
320
|
+
onChange={(e) => field().handleChange(e.target.value)}
|
|
321
|
+
class="w-full px-4 py-2 rounded-md border border-gray-300 focus:outline-none focus:ring-2 focus:ring-indigo-500"
|
|
322
|
+
placeholder="(123) 456-7890"
|
|
323
|
+
/>
|
|
324
|
+
</FieldWrapper>
|
|
325
|
+
)}
|
|
326
|
+
/>
|
|
327
|
+
</div>
|
|
328
|
+
|
|
329
|
+
{/* Submit Button */}
|
|
330
|
+
<div class="flex justify-end">
|
|
331
|
+
<button
|
|
332
|
+
type="submit"
|
|
333
|
+
disabled={form.state.isSubmitting}
|
|
334
|
+
class="px-6 py-2 bg-indigo-600 text-white rounded-md hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 transition-colors disabled:opacity-50"
|
|
335
|
+
>
|
|
336
|
+
{form.state.isSubmitting ? 'Submitting...' : 'Submit'}
|
|
337
|
+
</button>
|
|
338
|
+
</div>
|
|
339
|
+
</form>
|
|
340
|
+
</div>
|
|
341
|
+
</div>
|
|
342
|
+
)
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
<% if (codeRouter) { %>
|
|
346
|
+
export default (parentRoute: RootRoute) => createRoute({
|
|
347
|
+
path: '/demo/form',
|
|
348
|
+
component: FormExample,
|
|
349
|
+
getParentRoute: () => parentRoute,
|
|
350
|
+
})
|
|
351
|
+
<% } %>
|
|
352
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "Form",
|
|
3
|
+
"description": "TanStack Form",
|
|
4
|
+
"phase": "add-on",
|
|
5
|
+
"link": "https://tanstack.com/form/latest",
|
|
6
|
+
"modes": ["file-router", "code-router"],
|
|
7
|
+
"type": "add-on",
|
|
8
|
+
"routes": [
|
|
9
|
+
{
|
|
10
|
+
"url": "/demo/form",
|
|
11
|
+
"name": "Form",
|
|
12
|
+
"path": "src/routes/demo.form.tsx",
|
|
13
|
+
"jsName": "FormDemo"
|
|
14
|
+
}
|
|
15
|
+
]
|
|
16
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import packageJSON from './package.json'
|
|
2
|
+
|
|
3
|
+
function remoteConfig(name, url) {
|
|
4
|
+
return {
|
|
5
|
+
type: 'module',
|
|
6
|
+
name,
|
|
7
|
+
entry: url,
|
|
8
|
+
entryGlobalName: 'remote',
|
|
9
|
+
shareScope: 'default',
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default {
|
|
14
|
+
filename: 'remoteEntry.js',
|
|
15
|
+
name: '<%= projectName %>',
|
|
16
|
+
exposes: {
|
|
17
|
+
'./DemoMfComponent': './src/demo-mf-component.tsx',
|
|
18
|
+
'./DemoMfSelfContained': './src/demo-mf-self-contained.tsx',
|
|
19
|
+
},
|
|
20
|
+
remotes: {},
|
|
21
|
+
shared: {
|
|
22
|
+
'solid-js': {
|
|
23
|
+
singleton: true,
|
|
24
|
+
requiredVersion: packageJSON.dependencies['solid-js'],
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
We use Sentry for watching for errors in our deployed application, as well as for instrumentation of our application.
|
|
2
|
+
|
|
3
|
+
## Error collection
|
|
4
|
+
|
|
5
|
+
Error collection is automatic and configured in `src/router.tsx`.
|
|
6
|
+
|
|
7
|
+
## Instrumentation
|
|
8
|
+
|
|
9
|
+
We want our server functions intstrumented. So if you see a function name like `createServerFn`, you can instrument it with Sentry. You'll need to import `Sentry`:
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import * as Sentry from '@sentry/browser'
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
And then wrap the implementation of the server function with `Sentry.startSpan`, liks so:
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
Sentry.startSpan({ name: 'Requesting all the pokemon' }, async () => {
|
|
19
|
+
// Some lengthy operation here
|
|
20
|
+
await fetch('https://api.pokemon.com/data/')
|
|
21
|
+
})
|
|
22
|
+
```
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createFileRoute } from '@tanstack/solid-router'
|
|
2
|
+
|
|
3
|
+
export const Route = createFileRoute('/demo/sentry/bad-event-handler')({
|
|
4
|
+
component: RouteComponent,
|
|
5
|
+
})
|
|
6
|
+
|
|
7
|
+
function RouteComponent() {
|
|
8
|
+
return (
|
|
9
|
+
<div className="p-4">
|
|
10
|
+
<button
|
|
11
|
+
type="button"
|
|
12
|
+
onClick={() => {
|
|
13
|
+
throw new Error('Sentry Frontend Error')
|
|
14
|
+
}}
|
|
15
|
+
>
|
|
16
|
+
Throw error
|
|
17
|
+
</button>
|
|
18
|
+
</div>
|
|
19
|
+
)
|
|
20
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "Sentry",
|
|
3
|
+
"phase": "setup",
|
|
4
|
+
"description": "Add Sentry for error monitoring and crash reporting (requires Start).",
|
|
5
|
+
"link": "https://sentry.com/",
|
|
6
|
+
"modes": ["file-router"],
|
|
7
|
+
"type": "add-on",
|
|
8
|
+
"routes": [
|
|
9
|
+
{
|
|
10
|
+
"url": "/demo/sentry/bad-event-handler",
|
|
11
|
+
"name": "Sentry",
|
|
12
|
+
"path": "src/routes/demo.sentry.bad-event-handler.tsx",
|
|
13
|
+
"jsName": "SentryBadEventHandlerDemo"
|
|
14
|
+
}
|
|
15
|
+
]
|
|
16
|
+
}
|