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

treege-consumer

v1.42.3

Published

A React library to consume easily form generated from Tree

Downloads

756

Readme

Treege consumer

npm version

A React library to consume easily form generated from Treege

Installation

npm:

npm install treege-consumer

bun:

bun add treege-consumer

yarn:

yarn add treege-consumer

pnpm:

pnpm add treege-consumer

Usage

Provide tree data

Give tree data to <TreegeForm> component.
Data can be fetched from your API.

import tree from "./tree.json";
import { TreegeConsumer } from "treege-consumer ";

const App = () => {
  const handleSubmit = (data: [string, FormDataEntryValue][]) => {
    console.log(data);
  };

  return <TreegeConsumer tree={tree} onSubmit={handleSubmit}/>;
};

export default App;

Provide options

Some options can be provided. For example if you want to use place predictions from address field.

import tree from "./tree.json";
import { TreegeConsumer } from "treege-consumer ";

const App = () => {
  const handleSubmit = (data: [string, FormDataEntryValue][]) => {
    console.log(data);
  };

  return (
    <TreegeConsumer
      tree={tree}
      variant={variant}
      onSubmit={handleSubmit}
      options={{ googleApiKey: "YOUR_API_KEY" }}/>
  );
};

export default App;

Components

TreegeConsumer

Render a form based on Treege data

| Props | Type | Default | Required | Detail | |----------------------|------------------------------------------------------------------------------------------------------------------------|-----------|----------|----------------------------------------| | tree | TreeNode | undefined | false | Treege data | | variant | "standard" "stepper" | "stepper" | false | The variant to use | | theme | "light" "dark" ThemeOptions | "light" | false | Theme color mode | | onSubmit | data: JsonFormValue[];formData: [string, FormDataEntryValue][];fieldValues: FieldValues; | undefined | false | Callback fired form is validate | | options | "countryAutocompleteService""googleApiKey" "prefixResponseImageUriAutocomplete" | undefined | false | Consumer options | | style | CSSProperties | undefined | false | Custom form style | | initialValues | { [key: string]: unknown; } | undefined | false | Set initial value to form | | ignoreFields | string[] | undefined | false | Ignored fields to render | | debug | boolean | undefined | false | Debug in console on form submit | | readOnly | boolean | undefined | false | Read only mode | | disabledSubmitButton | boolean | undefined | false | Disable submit button | | isSubmitting | boolean | undefined | false | Disable submit button while submitting | | renderFormValidation | function({ disabled, isLoading }: RenderFormValidationParams): ReactElement | undefined | false | Custom form validation renderer |

Options

| Options | Type | Default | Required | Detail | |------------------------------------|--------------------|---------|----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | countryAutocompleteService | string or string[] | | false | Define country restrictions for autocomplete | | googleApiKey | string | | false | If you want use some google service like autocomplete address, then you want provide Google Api Key | | prefixResponseImageUriAutocomplete | string | | false | Prefix response image uri for autocomplete image | | licenseMuiX | string | | false | License MUI X to enable pro and premium feature | | disablePastDatePicker | boolean | | false | Disable past for date picker | | disablePastDateRangePicker | boolean | | false | Disable past for date range picker | | adapterLocale | string | | false | Adapter local for locale format |

TreegeConsumerResponse

Render values from form based on Treege

| Props | Type | Default | Required | Detail | |---------------------------|---------------------------------------------------------------------------------------------------------------------------------------------|-----------|----------|------------------------------------------------------------------------| | values | {label: string;name: string;type: string;tag?: string;value: string; | { label: string; value: string }} | undefined | true | Object of data | | renderInputs | function(input: JsonFormValue): ReactElement | undefined | undefined | false | Custom inputs rendering | | ignoreFields | string[] | undefined | false | Ignored fiels to render | | collapse | boolean | undefined | false | Enable collapse or note | | collapseVisibleItemNumber | number | 4 | false | Number of visible item before collapse. Works only if collapse is true | | disabledSubmitButton | boolean | undefined | false | Boolean to disable submit button |

Provider

Provide options

You can provide options to the consumer by using the TreegeConsumerProvider provider.

import tree from "./tree.json";
import { TreegeConsumer, TreegeConsumerProvider } from "treege-consumer ";

const App = () => {
  const handleSubmit = (data: [string, FormDataEntryValue][]) => {
    console.log(data);
  };

  return (
    <TreegeConsumerProvider licenseMuiX={"YOUR_LICENCE"}>
      <TreegeConsumer
        tree={tree}
        variant={variant}
        onSubmit={handleSubmit}
        options={{googleApiKey: "YOUR_API_KEY"}}/>
    </TreegeConsumerProvider>
  );
};

export default App;