Derive forms from structs.

Overview

leptos_form: Derive leptos forms from rust structs

Documentation

Features

  • Automatic form parsing -- focus on how your data is represented and not on how to get it in and out of html
  • Easy specification of label and input classes, great for Tailwind integration
  • Labels are derived from struct fields and can be given form-wide casing
  • DOM layout customization through attributes
  • Integration with popular crates

Crate features

This crate offers the following features, all of which are not activated by default:

  • bigdecimal: Provides impls for BigDecimal
  • cache-local-storage: Provides support for writing intermediate form data to/from local storage.
  • cache-serde_json: Provides support for (de)serializing form state as JSON.
  • chrono: Provides impls for DateTime, NaiveDate, NaiveDateTime
  • num-bigint: Provides impls for BigInt and BigUint
  • uuid: Provides impls for Uuid

Example

mod my_crate {
    use leptos::*;
    use leptos_form::prelude::*;
    use serde::*;

    #[derive(Clone, Debug, Default, Deserialize, Form, Serialize)]
    #[form(
        component(
            action = create_my_data(my_data),
            on_success = |DbMyData { id, .. }, _| view!(<div>{format!("Created {id}")}</div>),
            reset_on_success,
        ),
        label(wrap(class = "my-class", rename_all = "Title Case")),
    )]
    pub struct MyData {
        pub my_name: String,
    }

    #[derive(Clone, Debug, Deserialize, Serialize)]
    pub struct DbMyData {
        pub id: i32,
        pub name: String,
    }

    #[component]
    pub fn MyComponent() -> impl IntoView {
        view! {
            <MyData
                initial={MyData::default()}
                top=|| view!(<input type="button" value="Submit" />)
            />
        }
    }

    #[server]
    async fn create_my_data(my_data: MyData) -> Result<DbMyData, ServerFnError> {
        todo!()
    }
}
Comments
  • chore: release

    chore: release

    🤖 New release

    • leptos_form: 0.1.7 -> 0.1.8
    • leptos_form_core: 0.1.7 -> 0.1.8
    • leptos_form_proc_macros: 0.1.7 -> 0.1.8
    • leptos_form_proc_macros_core: 0.1.7 -> 0.1.8
    Changelog

    leptos_form

    [0.1.3] - 2023-11-01

    Miscellaneous Tasks

    • Release

    leptos_form_proc_macros

    [0.1.2] - 2023-11-01

    Miscellaneous Tasks

    • Release

    leptos_form_proc_macros_core

    [0.1.8] - 2023-11-19

    Bug Fixes

    • Parse_error_handler used in Form derive macro compiled correctly in debug but not release mode


    This PR was generated with release-plz.

    release 
    opened by tlowerison 1
  • chore: release

    chore: release

    🤖 New release

    • leptos_form: 0.1.5 -> 0.1.6
    • leptos_form_core: 0.1.5 -> 0.1.6
    • leptos_form_proc_macros: 0.1.5 -> 0.1.6
    • leptos_form_proc_macros_core: 0.1.5 -> 0.1.6
    Changelog

    leptos_form

    [0.1.3] - 2023-11-01

    Miscellaneous Tasks

    • Release

    leptos_form_proc_macros

    [0.1.2] - 2023-11-01

    Miscellaneous Tasks

    • Release

    leptos_form_proc_macros_core

    [0.1.2] - 2023-11-01

    Miscellaneous Tasks

    • Release


    This PR was generated with release-plz.

    release 
    opened by tlowerison 1
  • support for style attribute and general improvements

    support for style attribute and general improvements

    • add support for specifying style in multiple places in Form macro improved container inheritance of attributes in macro
    • fix item notation / removal bug for Vec fields by using IndexMap instead of storing index in the VecSignalItem
    • improve documenation and add UI screenshots to Form macro docs
    opened by tlowerison 1
  • chore: release

    chore: release

    🤖 New release

    • leptos_form: 0.1.2 -> 0.1.3
    • leptos_form_core: 0.1.2 -> 0.1.3
    • leptos_form_proc_macros: 0.1.2 -> 0.1.3
    • leptos_form_proc_macros_core: 0.1.2 -> 0.1.3
    Changelog

    leptos_form

    [0.1.3] - 2023-11-01

    Miscellaneous Tasks

    • Release

    leptos_form_proc_macros

    [0.1.2] - 2023-11-01

    Miscellaneous Tasks

    • Release

    leptos_form_proc_macros_core

    [0.1.2] - 2023-11-01

    Miscellaneous Tasks

    • Release


    This PR was generated with release-plz.

    release 
    opened by tlowerison 1
  • chore: release

    chore: release

    🤖 New release

    • leptos_form: 0.1.1 -> 0.1.2
    • leptos_form_core: 0.1.1 -> 0.1.2
    • leptos_form_proc_macros: 0.1.1 -> 0.1.2
    • leptos_form_proc_macros_core: 0.1.1 -> 0.1.2
    Changelog

    leptos_form

    [0.1.1] - 2023-11-01

    Miscellaneous Tasks

    • Release

    leptos_form_proc_macros

    [0.1.2] - 2023-11-01

    Miscellaneous Tasks

    • Release

    leptos_form_proc_macros_core

    [0.1.2] - 2023-11-01

    Miscellaneous Tasks

    • Release


    This PR was generated with release-plz.

    release 
    opened by tlowerison 1
  • chore: release

    chore: release

    🤖 New release

    • leptos_form: 0.1.7 -> 0.1.8
    • leptos_form_core: 0.1.7 -> 0.1.8
    • leptos_form_proc_macros: 0.1.7 -> 0.1.8
    • leptos_form_proc_macros_core: 0.1.7 -> 0.1.8
    Changelog

    leptos_form

    [0.1.3] - 2023-11-01

    Miscellaneous Tasks

    • Release

    leptos_form_proc_macros

    [0.1.2] - 2023-11-01

    Miscellaneous Tasks

    • Release

    leptos_form_proc_macros_core

    [0.1.8] - 2023-11-16

    Miscellaneous Tasks

    • Update dependencies


    This PR was generated with release-plz.

    release 
    opened by tlowerison 0
  • Update itertools requirement from ~0.11 to ~0.12

    Update itertools requirement from ~0.11 to ~0.12

    Updates the requirements on itertools to permit the latest version.

    Changelog

    Sourced from itertools's changelog.

    0.11.0

    Breaking

    • Make Itertools::merge_join_by also accept functions returning bool (#704)
    • Implement PeekingNext transitively over mutable references (#643)
    • Change with_position to yield (Position, Item) instead of Position<Item> (#699)

    Added

    • Add Itertools::take_while_inclusive (#616)
    • Implement PeekingNext for PeekingTakeWhile (#644)
    • Add EitherOrBoth::{just_left, just_right, into_left, into_right, as_deref, as_deref_mut, left_or_insert, right_or_insert, left_or_insert_with, right_or_insert_with, insert_left, insert_right, insert_both} (#629)
    • Implement Clone for CircularTupleWindows (#686)
    • Implement Clone for Chunks (#683)
    • Add Itertools::process_results (#680)

    Changed

    • Use Cell instead of RefCell in Format and FormatWith (#608)
    • CI tweaks (#674, #675)
    • Document and test the difference between stable and unstable sorts (#653)
    • Fix documentation error on Itertools::max_set_by_key (#692)
    • Move MSRV metadata to Cargo.toml (#672)
    • Implement equal with Iterator::eq (#591)

    0.10.5

    • Maintenance

    0.10.4

    0.10.3

    • Maintenance

    0.10.2

    • Add Itertools::multiunzip (#362, #565)
    • Add intersperse and intersperse_with free functions (#555)
    • Add Itertools::sorted_by_cached_key (#424, #575)
    • Specialize ProcessResults::fold (#563)
    • Fix subtraction overflow in DuplicatesBy::size_hint (#552)
    • Fix specialization tests (#574)
    • More Debug impls (#573)
    • Deprecate fold1 (use reduce instead) (#580)
    • Documentation fixes (HomogenousTuple, into_group_map, into_group_map_by, MultiPeek::peek) (#543 et al.)

    0.10.1

    • Add Itertools::contains (#514)
    • Add Itertools::counts_by (#515)

    ... (truncated)

    Commits

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies rust 
    opened by dependabot[bot] 0
  • chore: release

    chore: release

    🤖 New release

    • leptos_form: 0.1.3 -> 0.1.4
    • leptos_form_core: 0.1.3 -> 0.1.4
    • leptos_form_proc_macros: 0.1.3 -> 0.1.4
    • leptos_form_proc_macros_core: 0.1.3 -> 0.1.4
    Changelog

    leptos_form

    [0.1.3] - 2023-11-01

    Miscellaneous Tasks

    • Release

    leptos_form_proc_macros

    [0.1.2] - 2023-11-01

    Miscellaneous Tasks

    • Release

    leptos_form_proc_macros_core

    [0.1.2] - 2023-11-01

    Miscellaneous Tasks

    • Release


    This PR was generated with release-plz.

    release 
    opened by tlowerison 0
  • Bump actions/checkout from 3 to 4

    Bump actions/checkout from 3 to 4

    Bumps actions/checkout from 3 to 4.

    Release notes

    Sourced from actions/checkout's releases.

    v4.0.0

    What's Changed

    New Contributors

    Full Changelog: https://github.com/actions/checkout/compare/v3...v4.0.0

    v3.6.0

    What's Changed

    New Contributors

    Full Changelog: https://github.com/actions/checkout/compare/v3.5.3...v3.6.0

    v3.5.3

    What's Changed

    New Contributors

    Full Changelog: https://github.com/actions/checkout/compare/v3...v3.5.3

    v3.5.2

    What's Changed

    Full Changelog: https://github.com/actions/checkout/compare/v3.5.1...v3.5.2

    v3.5.1

    What's Changed

    New Contributors

    ... (truncated)

    Changelog

    Sourced from actions/checkout's changelog.

    Changelog

    v4.1.0

    v4.0.0

    v3.6.0

    v3.5.3

    v3.5.2

    v3.5.1

    v3.5.0

    v3.4.0

    v3.3.0

    v3.2.0

    v3.1.0

    v3.0.2

    ... (truncated)

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies github_actions 
    opened by dependabot[bot] 0
  • chore: release

    chore: release

    🤖 New release

    • leptos_form: 0.1.0 -> 0.1.1
    • leptos_form_core: 0.1.0 -> 0.1.1
    • leptos_form_proc_macros: 0.1.0 -> 0.1.1
    • leptos_form_proc_macros_core: 0.1.0 -> 0.1.1
    Changelog

    leptos_form

    [0.1.1] - 2023-11-01

    Miscellaneous Tasks

    • Release


    This PR was generated with release-plz.

    release 
    opened by tlowerison 0
  • Update typed-builder requirement from ~0.16 to ~0.18

    Update typed-builder requirement from ~0.16 to ~0.18

    Updates the requirements on typed-builder to permit the latest version.

    Changelog

    Sourced from typed-builder's changelog.

    0.16.2 - 2023-09-22

    Fixed

    • Use generics with the constructor in build method (see issue #118)

    0.16.1 - 2023-09-18

    Fixed

    • Add #[allow(clippy::exhaustive_enums)] to generated empty enums used for error "reporting" (see issue #112)
    • Add #[automatically_derived] to generated impls (see issue #114)
    • Add #[allow(clippy::used_underscore_binding)] to build method and setter methods (see issue #113)

    0.16.0 - 2023-08-26

    Added

    • #[builder(crate_module_path = ...)] for overcoming cases where the derive macro is used in another crate's macro (see issue #109)

    0.15.2 - 2023-08-03

    Fixed

    • Fix const generics generating "empty" entries in some lists, resulting in consecutive commas (see issue #106)

    0.15.1 - 2023-07-10

    Fixed

    • no-std build.

    0.15.0 - 2023-07-06

    Changed

    • [BREAKING] Split the derive macro out to a separate procmacro crate. This is considered a breaking change because reexporting and/or renmaing the crate can now prevent the generated code from finding the types it needs (see issue #101)

    Fixed

    • Marking a field as #[deprecated] now behaves properly - TypedBuilder generated code itself does trigger the deprecation warning, and instead the setter for that field now does.
    • The "fake" build method when required fields are not provided now returns the never type ("!"). Refer to PR #97 for more thorough explanation.

    Added

    • Support for setter method prefixes and suffixes #[builder(field_defaults(setter(prefix = "...", suffix = "...")))]. This either prepends or appends the provided string to the setter method. This allows method names like: set_x(), with_y(), or set_z_value().

    0.14.0 - 2023-03-08

    Added

    • build_method(into) and build_method(into = ...).

    0.13.0 - 2023-03-05

    ... (truncated)

    Commits

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies rust 
    opened by dependabot[bot] 0
  • Redirects from server functions

    Redirects from server functions

    I like the idea of your crate, one of the least fun things about making UIs is having to deal with forms and processing them.

    That being said, your current implementation does not use the backing

    component which is where all the nice 302 redirect handling is done. When trying out your crate I immediately ran into this.

    I opened an issue in the Leptos repository (https://github.com/leptos-rs/leptos/issues/2069) to talk about more ergonomic handling of this, but an immediate solution would be to use the backing Form component from leptos_router as it allows you to delegate the redirects and handle the response and data validation.

    opened by WIGGLES-dev 0
Releases(leptos_form_proc_macros_core-v0.1.8)
An easy to use library for pretty print tables of Rust structs and enums.

tabled An easy to use library for pretty printing tables of Rust structs and enums. Table of Contents Usage Settings Style Themes ASCII Psql Github Ma

Maxim Zhiburt 1.3k Jan 9, 2023
Solving context limits when working with AI LLM models by implementing a "chunkable" attribute on your prompt structs.

Promptize Promptize attempts to solve the issues with context limits when working with AI systems. It allows a user to add an attribute to their struc

Dan Nelson 5 Jul 18, 2023
Rust derive-based argument parsing optimized for code size

Argh Argh is an opinionated Derive-based argument parser optimized for code size Derive-based argument parsing optimized for code size and conformance

Google 1.3k Dec 28, 2022
This library provides a convenient derive macro for the standard library's std::error::Error trait.

derive(Error) This library provides a convenient derive macro for the standard library's std::error::Error trait. [dependencies] therror = "1.0" Compi

Sebastian Thiel 5 Oct 23, 2023
Derive macro implementing 'From' for structs

derive-from-ext A derive macro that auto implements 'std::convert::From' for structs. The default behaviour is to create an instance of the structure

Andrew Lowndes 4 Sep 18, 2022
A rewrite of Phonelink for Windows Forms written in Rust, with cross-platform support.

phonelink-rs A rewrite of Phonelink for Windows Forms written in Rust, with cross-platform support. Usage Clone the repository and build, or download

ahsan-a 4 Aug 6, 2022
Easy to use multipart forms for actix-web

Actix Easy Multipart Easy to use Multipart Forms for actix-web. File uploads are written to disk as temporary files similar to the way the $_FILES var

Jacob Halsey 17 Jan 3, 2023
Scriptable tool to read and write UEFI variables from EFI shell. View, save, edit and restore hidden UEFI (BIOS) Setup settings faster than with the OEM menu forms.

UEFI Variable Tool (UVT) UEFI Variable Tool (UVT) is a command-line application that runs from the UEFI shell. It can be launched in seconds from any

null 4 Dec 11, 2023
Easy reading and writing of `serde` structs to/from Google Sheets

serde_sheets Read and write structs directly from google sheets using serde and csv Implement serde::Serialize to write and serde::Deserialize to read

null 5 Jul 20, 2022
Simple validation for Rust structs

validator Macros 1.1 custom derive to simplify struct validation inspired by marshmallow and Django validators. The minimum supported version is Rust

Vincent Prouillet 1.3k Jan 4, 2023
A Rust proc-macro crate which derives functions to compile and parse back enums and structs to and from a bytecode representation

Bytecode A simple way to derive bytecode for you Enums and Structs. What is this This is a crate that provides a proc macro which will derive bytecode

null 4 Sep 3, 2022
A rust library that provides pseudo-reflection for structs and enums

Treeflection treeflection_derive Treeflection runs a command stored as a string on a tree of structs, collections and primitive types. Commands A comm

Lucas Kent 21 Nov 17, 2022
General basic key-value structs for Key-Value based storages

General basic key-value structs for Key-Value based storages

Al Liu 0 Dec 3, 2022
Helper functions and structs for working with 2D space in Bevy.

About Baffled by quaternions? Want to accelerate an object in 2D? Wish that there was a simple way to work with grids? Just want to know if two axis-a

Leafwing Studios 11 May 9, 2022
An easy to use library for pretty print tables of Rust structs and enums.

tabled An easy to use library for pretty printing tables of Rust structs and enums. Table of Contents Usage Settings Style Themes ASCII Psql Github Ma

Maxim Zhiburt 1.3k Jan 9, 2023
Loads environment variables into your structs in one shot.

econf Loads environment variables into your structs in one shot. econf allows to override struct fields with environment variables easily. This is use

Yushi OMOTE 6 Jul 14, 2022
A Rust crate to expressively declare bitfield-like structs

proc-bitfield A Rust crate to expressively declare bitfield-like structs, automatically ensuring their correctness at compile time and declaring acces

null 36 Dec 3, 2022
Static-checked parsing of regexes into structs

Statically-checked regex parsing into structs. This avoids common regex pitfalls like Off by one capture indexes Trying to get nonexistent captures De

Andrew Baxter 4 Dec 18, 2022
Generate rust structs & query functions from diesel schema files

dsync A utility to generate database structs and querying code from diesel schema files. Primarily built for create-rust-app. Currently, it's more adv

Haris 20 Feb 12, 2023
Deserialize (potentially nested) environment variables into your custom structs

envious allows you to deserialize your serde enabled structs from environment variables. See it in action: use serde::{Deserialize, Serialize}; #[der

Marcel Müller 46 Feb 19, 2023