npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

svelte-smart-form

v0.0.2

Published

A smart form builder for Svelte applications

Downloads

8

Readme

Svelte Smart Form

Svelte Smart Form is a powerful, flexible, and easy-to-use form builder component for Svelte applications. It allows you to dynamically generate forms based on a configuration object, handling validation and submission with minimal effort.

Features

  • 🚀 Dynamic field generation
  • ✅ Built-in validation
  • 🎨 Custom validation support
  • ⚡ Real-time error handling
  • 💅 Flexible styling
  • ♿ Accessibility-friendly
  • 🔌 Easy integration with existing Svelte projects

Usage

To use Svelte Smart Form in your project:

  1. Copy the SmartForm.svelte component into your project's components directory.

  2. Import and use the SmartForm component in your Svelte file:

<script>
import SmartForm from './path/to/SmartForm.svelte';

const fields = [
  { name: 'username', type: 'text', label: 'Username', required: true },
  { name: 'email', type: 'email', label: 'Email', required: true },
  // Add more fields as needed
];

function handleSubmit(event) {
  console.log('Form submitted:', event.detail);
}
</script>

<SmartForm {fields} on:submit={handleSubmit} />
  1. Customize your form by modifying the fields array.

  2. Handle form submission in the handleSubmit function.

Field Configuration

Each field in the fields array can have the following properties:

  • name (required): The name of the field
  • type (required): The type of input (e.g., 'text', 'email', 'password', 'checkbox', 'radio', 'select', 'textarea')
  • label (required): The label for the field
  • required (optional): Whether the field is required
  • options (required for 'radio' and 'select'): An array of options for radio buttons or select dropdowns
  • validate (optional): A custom validation function
  • minLength (optional): Minimum length for text inputs
  • maxLength (optional): Maximum length for text inputs
  • pattern (optional): A regex pattern for validation

Form Builder

Svelte Smart Form also includes a Form Builder component that allows you to create forms visually and generate the corresponding code:

  1. Copy the SmartFormBuilder.svelte component into your project's components directory.

  2. Import and use the SmartFormBuilder component in your Svelte file:

<script>
import SmartFormBuilder from './path/to/SmartFormBuilder.svelte';
</script>

<SmartFormBuilder />

Styling

Svelte Smart Form comes with basic styling out of the box. You can easily customize the appearance by overriding the CSS classes in your Svelte component.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Support

If you encounter any problems or have any questions, please open an issue on the GitHub repository.

Acknowledgements


Made with ❤️ by Leon Kalema