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

ultimate-react-form-renderer

v1.9.76

Published

A form renderer for React, compatible with the output of the [`ultimate-react-form-builder`](https://www.npmjs.com/package/ultimate-react-form-builder) Package. Easily manage form fields, field values, and handle save functions, all in TypeScript.

Downloads

593

Readme

Ultimate React Form Renderer

A form renderer for React, compatible with the output of the ultimate-react-form-builder Package. Easily manage form fields, field values, and handle save functions, all in TypeScript.

Installation

Install the package using npm:

npm install ultimate-react-form-renderer

Usage Example

import React, {useState} from 'react';
import TreeRenderer, {TreeRenderer_Helper, TreeRenderer_Models} from 'ultimate-react-form-renderer';

export default function ContactUsPage(props: {data: string}) {
  // props.data is output from ultimate-react-form-builder
  const [field_values, set_field_values] = useState<TreeRenderer_Models.request_data_object[]>([]);
  const [saving, set_saving] = useState<boolean>(false);
  const [req_sent, set_req_sent] = useState<boolean>(false);

  const handle_save = async () => {
    set_saving(true);
    try {
      //check if field_values are valid
      if (!TreeRenderer_Helper.are_field_values_valid(props.data, field_values))
        throw new Error('لطفا مقادیر پر شده را بررسی کنید');
      // Save form data in database
    } catch (e: any) {
      // Handle error
    }
    set_saving(false);
  };

  return (
    <div>
      <TreeRenderer
        data={props.data} // data is output from ultimate-react-form-builder
        field_values={field_values}
        set_field_values={set_field_values}
        handle_save={handle_save}
        saving={saving}
      />
    </div>
  );
}

Props

| Prop Name | Type | Required | Description | | ------------------------- | ------------------------------------------------------------- | -------- | -------------------------------------------------------------------------------- | | data | string | true | JSON string of the form structure, typically from ultimate-react-form-builder. | | field_values | request_data_object[] | false | Current state of the form field values. | | set_field_values | React.Dispatch<React.SetStateAction<request_data_object[]>> | false | Function to update the state of field_values. | | handle_save | () => Promise<void> | false | Function triggered when the form is submitted. | | saving | boolean | false | Controls the loading state during form submission. | | handle_uploadMediaFile | (formData: FormData) => Promise<any> | false | Handle file uploads inside the form. | | outSide_fields_settings | TreeRenderer_Models.fields_settings_model | false | Customize field suffixes and prefixes. | | disable_security | boolean | false | Disable security features like dangerouslySetInnerHTML. |

request_data_object model

interface request_data_object {
  field_id: string;
  field_en_key: string;
  field_fa_key: string;
  field_value: string;
  field_type: string;
  field_label?: string;
}