-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Form): update and migrate valibot to v0.31.0
- Loading branch information
1 parent
d3294cb
commit 852437c
Showing
7 changed files
with
342 additions
and
293 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<script setup lang="ts"> | ||
import {reactive} from "vue"; | ||
const state = reactive({ | ||
email: undefined, | ||
password: undefined | ||
}) | ||
const validate = (state: any) => { | ||
const errors = [] | ||
if (!state.email) errors.push({path: 'email', message: 'Required'}) | ||
if (!state.password) errors.push({path: 'password', message: 'Required'}) | ||
return errors | ||
} | ||
async function onSubmit(event) { | ||
// Do something with data | ||
console.log(event.data) | ||
} | ||
</script> | ||
|
||
<template> | ||
<SForm :validate="validate" :state="state" class="space-y-4" @submit="onSubmit"> | ||
<SFormGroup label="Email" name="email"> | ||
<SInput v-model="state.email"/> | ||
</SFormGroup> | ||
|
||
<SFormGroup label="Password" name="password"> | ||
<SInput v-model="state.password" type="password"/> | ||
</SFormGroup> | ||
|
||
<SButton type="submit"> | ||
Submit | ||
</SButton> | ||
</SForm> | ||
</template> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,38 @@ | ||
<script setup lang="ts"> | ||
import { ref } from 'vue' | ||
import { string, object, email, minLength, Input } from 'valibot' | ||
import * as v from 'valibot' | ||
import {reactive} from "vue"; | ||
const schema = object({ | ||
email: string([email('Invalid email')]), | ||
password: string([minLength(8, 'Must be at least 8 characters')]) | ||
const schema = v.object({ | ||
email: v.pipe(v.string(), v.email('Invalid email')), | ||
password: v.pipe(v.string(), v.minLength(8, 'Must be at least 8 characters')) | ||
}) | ||
type Schema = Input<typeof schema> | ||
type Schema = v.InferOutput<typeof schema> | ||
const state = ref({ | ||
email: undefined, | ||
password: undefined | ||
const state = reactive({ | ||
email: '', | ||
password: '' | ||
}) | ||
async function submit (event) { | ||
async function onSubmit (event) { | ||
// Do something with event.data | ||
console.log(event.data) | ||
} | ||
</script> | ||
|
||
<template> | ||
<s-form | ||
:schema="schema" | ||
:state="state" | ||
@submit="submit" | ||
class="space-y-4" | ||
> | ||
<s-form-group label="Email" name="email"> | ||
<s-input v-model="state.email" /> | ||
</s-form-group> | ||
|
||
<s-form-group label="Password" name="password"> | ||
<s-input v-model="state.password" type="password" /> | ||
</s-form-group> | ||
|
||
<s-button type="submit"> | ||
<SForm :schema="v.safeParser(schema)" :state="state" class="space-y-4" @submit="onSubmit"> | ||
<SFormGroup label="Email" name="email"> | ||
<SInput v-model="state.email" /> | ||
</SFormGroup> | ||
|
||
<SFormGroup label="Password" name="password"> | ||
<SInput v-model="state.password" type="password" /> | ||
</SFormGroup> | ||
|
||
<SButton type="submit"> | ||
Submit | ||
</s-button> | ||
</s-form> | ||
</SButton> | ||
</SForm> | ||
</template> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "stellar-ui", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"license": "MIT", | ||
"scripts": { | ||
"build": "rimraf dist && run-p build:stellar build:helpers", | ||
|
@@ -21,10 +21,10 @@ | |
"eslint-plugin-import": "^2.29.1", | ||
"npm-run-all": "^4.1.5", | ||
"rimraf": "^5.0.7", | ||
"sass": "^1.77.4", | ||
"sass": "^1.77.5", | ||
"tailwindcss": "^3.4.4", | ||
"typescript": "latest", | ||
"vite": "^5.2.13", | ||
"vite": "^5.3.1", | ||
"vitepress": "^1.2.3", | ||
"vue-tsc": "^2.0.21" | ||
}, | ||
|
@@ -69,19 +69,19 @@ | |
"@docsearch/js": "^3.6.0", | ||
"@headlessui/vue": "^1.7.22", | ||
"@iconify-json/heroicons": "^1.1.21", | ||
"@iconify-json/lucide": "^1.1.191", | ||
"@iconify-json/lucide": "^1.1.192", | ||
"@iconify-json/mdi": "^1.1.66", | ||
"@iconify/json": "^2.2.218", | ||
"@iconify/json": "^2.2.219", | ||
"@iconify/tailwind": "^1.1.1", | ||
"@popperjs/core": "^2.11.8", | ||
"@tailwindcss/aspect-ratio": "^0.4.2", | ||
"@tailwindcss/container-queries": "^0.1.1", | ||
"@tailwindcss/forms": "^0.5.7", | ||
"@tailwindcss/typography": "^0.5.13", | ||
"@vueuse/core": "^10.10.0", | ||
"@vueuse/integrations": "^10.10.0", | ||
"@vueuse/math": "^10.10.0", | ||
"@vueuse/shared": "^10.10.0", | ||
"@vueuse/core": "^10.11.0", | ||
"@vueuse/integrations": "^10.11.0", | ||
"@vueuse/math": "^10.11.0", | ||
"@vueuse/shared": "^10.11.0", | ||
"autoprefixer": "^10.4.19", | ||
"cssnano": "^7.0.2", | ||
"defu": "^6.1.4", | ||
|
@@ -95,7 +95,8 @@ | |
"rollup-plugin-pure": "^0.2.1", | ||
"scule": "^1.3.0", | ||
"tailwind-merge": "^2.3.0", | ||
"valibot": "^0.30.0", | ||
"valibot30": "npm:[email protected]", | ||
"valibot": "^0.31.1", | ||
"vite-plugin-dts": "^3.9.1", | ||
"vue-demi": "^0.14.8", | ||
"yup": "^1.4.0", | ||
|
Oops, something went wrong.