https://github.com/StudyResearchProjects/manzana
🍏 Build forms on Svelte as easy as eating apple.
https://github.com/StudyResearchProjects/manzana
forms svelte
Last synced: 4 months ago
JSON representation
🍏 Build forms on Svelte as easy as eating apple.
- Host: GitHub
- URL: https://github.com/StudyResearchProjects/manzana
- Owner: StudyResearchProjects
- License: mit
- Archived: true
- Created: 2022-03-02T23:32:38.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-10-14T11:53:56.000Z (over 3 years ago)
- Last Synced: 2025-09-12T22:25:21.959Z (5 months ago)
- Topics: forms, svelte
- Language: TypeScript
- Homepage: https://manzana.estebanborai.com
- Size: 387 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
manzana
🍏 Build forms on Svelte as easy as eating apple.
## Installation
```bash
# npm
npm install manzana
# yarn
yarn add manzana
# pnpm
pnpm add manzana
```
## Examples
### Creating a new form
```svelte
import { newForm } from 'manzana';
import * as Sentry from '@sentry/browser';
import * as Yup from 'yup';
import { EmailAlreadyTaken } from '$lib/errors';
import { agentService } from '$lib/services/agent';
import { notificationStore } from '$lib/stores/notification';
const { handleSubmit, values, errors, isSubmitting } = newForm({
initialValues: {
name: 'James'
lastName: 'Bond',
nickname: 'Agent 007',
email: 'james.bond@agent007.com',
},
validationSchema: Yup.object({
name: Yup.string().required(),
lastName: Yup.string().required(),
nickname: Yup.string().required(),
email: Yup.string().email().required(),
}),
onSubmit: async (values, helpers) => {
try {
await agentService.register(values);
} catch (error) {
if (error instanceof EmailAlreadyTaken) {
helpers.setFieldError(
'email',
'The email is already taken!');
return;
}
Sentry.captureException(error);
notificationStore.displayError({
text: 'An error ocurred registering an agent.'
});
}
},
});
Name
Last Name
Nickname
Email
Create Account
```
## Releasing
Whenever a tag is pushed a new release is created an the package is
published to the NPM registry using GitHub Actions.
Bump the current version using `npm` as follows:
```sh
# for versions with breaking changes use `major`
npm version major
# for versions with non-breaking changes use `minor`
npm version minor
# for patch versions use `patch`
npm version patch
```
Then push the repository including tag metadata as follows
```sh
git push origin main --follow-tags
```
## Contributions
Any contribution to this package is welcome! Don't hesitate on opening a
PR or creating an issue!