-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6632 from primefaces/v4.2.0-form
PrimeVue Forms
- Loading branch information
Showing
220 changed files
with
11,889 additions
and
2,115 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
|
@@ -248,7 +248,6 @@ export default { | |
selectedRows: [] | ||
}; | ||
}, | ||
methods: { | ||
displayPopover(event) { | ||
this.hidePopover(); | ||
|
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,202 @@ | ||
<template> | ||
<DocSectionText v-bind="$attrs"> | ||
<p>AutoComplete can be used with the <NuxtLink to="/forms">PrimeVue Forms</NuxtLink> library.</p> | ||
</DocSectionText> | ||
<div class="card flex justify-center"> | ||
<Form v-slot="$form" :resolver="resolver" :initialValues="initialValues" @submit="onFormSubmit" class="flex justify-center flex-col gap-4 w-full md:w-56"> | ||
<div class="flex flex-col gap-2"> | ||
<AutoComplete name="country" optionLabel="name" :suggestions="filteredCountries" @complete="search" fluid /> | ||
<Message v-if="$form.country?.invalid" severity="error">{{ $form.country.error?.message }}</Message> | ||
</div> | ||
<Button type="submit" severity="secondary" label="Submit" /> | ||
</Form> | ||
</div> | ||
<DocSectionCode :code="code" :dependencies="{ zod: '3.23.8' }" /> | ||
</template> | ||
<script> | ||
import { CountryService } from '@/service/CountryService'; | ||
import { zodResolver } from '@primevue/form/resolvers'; | ||
import { z } from 'zod'; | ||
export default { | ||
data() { | ||
return { | ||
initialValues: { | ||
country: { name: '' } | ||
}, | ||
countries: null, | ||
filteredCountries: null, | ||
resolver: zodResolver( | ||
z.object({ | ||
country: z.union([ | ||
z.object({ | ||
name: z.string().min(1, 'Country required.') | ||
}), | ||
z.any().refine((val) => false, { message: 'Country required.' }) | ||
]) | ||
}) | ||
), | ||
code: { | ||
basic: ` | ||
<Form v-slot="$form" :resolver="resolver" :initialValues="initialValues" @submit="onFormSubmit" class="flex justify-center flex-col gap-4 w-full md:w-56"> | ||
<div class="flex flex-col gap-2"> | ||
<AutoComplete name="country" optionLabel="name" :suggestions="filteredCountries" @complete="search" /> | ||
<Message v-if="$form.country?.invalid" severity="error">{{ $form.country.error?.message }}</Message> | ||
</div> | ||
<Button type="submit" severity="secondary" label="Submit" /> | ||
</Form> | ||
`, | ||
options: ` | ||
<template> | ||
<div class="card flex justify-center"> | ||
<Form v-slot="$form" :resolver="resolver" :initialValues="initialValues" @submit="onFormSubmit" class="flex justify-center flex-col gap-4 w-full md:w-56"> | ||
<div class="flex flex-col gap-2"> | ||
<AutoComplete name="country" optionLabel="name" :suggestions="filteredCountries" @complete="search" /> | ||
<Message v-if="$form.country?.invalid" severity="error">{{ $form.country.error?.message }}</Message> | ||
</div> | ||
<Button type="submit" severity="secondary" label="Submit" /> | ||
</Form> | ||
<Toast /> | ||
</div> | ||
</template> | ||
<script> | ||
import { CountryService } from '@/service/CountryService'; | ||
import { zodResolver } from '@primevue/form/resolvers'; | ||
import { z } from 'zod'; | ||
export default { | ||
data() { | ||
return { | ||
initialValues: { | ||
country: { name: '' } | ||
}, | ||
countries: null, | ||
filteredCountries: null, | ||
resolver: zodResolver( | ||
z.object({ | ||
country: z.union([ | ||
z.object({ | ||
name: z.string().min(1, 'Country required.') | ||
}), | ||
z.any().refine((val) => false, { message: 'Country required.' }) | ||
]) | ||
}) | ||
) | ||
} | ||
}, | ||
mounted() { | ||
CountryService.getCountries().then((data) => (this.countries = data)); | ||
}, | ||
methods: { | ||
search(event) { | ||
setTimeout(() => { | ||
if (!event.query.trim().length) { | ||
this.filteredCountries = [...this.countries]; | ||
} else { | ||
this.filteredCountries = this.countries.filter((country) => { | ||
return country.name.toLowerCase().startsWith(event.query.toLowerCase()); | ||
}); | ||
} | ||
}, 250); | ||
}, | ||
onFormSubmit({ valid }) { | ||
if (valid) { | ||
this.$toast.add({ severity: 'success', summary: 'Form is submitted.', life: 3000 }); | ||
} | ||
} | ||
} | ||
} | ||
<\/script> | ||
`, | ||
composition: ` | ||
<template> | ||
<div class="card flex justify-center"> | ||
<Form v-slot="$form" :resolver="resolver" :initialValues="initialValues" @submit="onFormSubmit" class="flex justify-center flex-col gap-4 w-full md:w-56"> | ||
<div class="flex flex-col gap-2"> | ||
<AutoComplete name="country" optionLabel="name" :suggestions="filteredCountries" @complete="search" /> | ||
<Message v-if="$form.country?.invalid" severity="error">{{ $form.country.error?.message }}</Message> | ||
</div> | ||
<Button type="submit" severity="secondary" label="Submit" /> | ||
</Form> | ||
<Toast /> | ||
</div> | ||
</template> | ||
<script setup> | ||
import { ref, onMounted } from "vue"; | ||
import { zodResolver } from '@primevue/form/resolvers'; | ||
import { useToast } from "primevue/usetoast"; | ||
import { z } from 'zod'; | ||
import { CountryService } from "@/service/CountryService"; | ||
onMounted(() => { | ||
CountryService.getCountries().then((data) => (countries.value = data)); | ||
}); | ||
const initialValues = ref({ | ||
country: { name: '' } | ||
}); | ||
const resolver = ref( | ||
zodResolver( | ||
z.object({ | ||
country: z.union([ | ||
z.object({ | ||
name: z.string().min(1, 'Country required.') | ||
}), | ||
z.any().refine((val) => false, { message: 'Country required.' }) | ||
]) | ||
}) | ||
)); | ||
const countries = ref(); | ||
const selectedCountry = ref(); | ||
const filteredCountries = ref(); | ||
const toast = useToast(); | ||
const search = (event) => { | ||
setTimeout(() => { | ||
if (!event.query.trim().length) { | ||
filteredCountries.value = [...countries.value]; | ||
} else { | ||
filteredCountries.value = countries.value.filter((country) => { | ||
return country.name.toLowerCase().startsWith(event.query.toLowerCase()); | ||
}); | ||
} | ||
}, 250); | ||
}; | ||
const onFormSubmit = ({ valid }) => { | ||
if (valid) { | ||
toast.add({ severity: 'success', summary: 'Form is submitted.', life: 3000 }); | ||
} | ||
}; | ||
<\/script> | ||
` | ||
} | ||
}; | ||
}, | ||
mounted() { | ||
CountryService.getCountries().then((data) => (this.countries = data)); | ||
}, | ||
methods: { | ||
search(event) { | ||
setTimeout(() => { | ||
if (!event.query.trim().length) { | ||
this.filteredCountries = [...this.countries]; | ||
} else { | ||
this.filteredCountries = this.countries.filter((country) => { | ||
return country.name.toLowerCase().startsWith(event.query.toLowerCase()); | ||
}); | ||
} | ||
}, 250); | ||
}, | ||
onFormSubmit({ valid }) { | ||
if (valid) { | ||
this.$toast.add({ severity: 'success', summary: 'Form is submitted.', life: 3000 }); | ||
} | ||
} | ||
} | ||
}; | ||
</script> |
Oops, something went wrong.