1.42.0 • Published 8 months ago

treege-consumer v1.42.0

Weekly downloads
-
License
ISC*
Repository
github
Last release
8 months ago

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

PropsTypeDefaultRequiredDetail
treeTreeNodeundefinedfalseTreege data
variant"standard" "stepper""stepper"falseThe variant to use
theme"light" "dark" ThemeOptions"light"falseTheme color mode
onSubmitdata: JsonFormValue[];formData: [string, FormDataEntryValue][];fieldValues: FieldValues;undefinedfalseCallback fired form is validate
options"countryAutocompleteService""googleApiKey" "prefixResponseImageUriAutocomplete"undefinedfalseConsumer options
styleCSSPropertiesundefinedfalseCustom form style
initialValues{ key: string: unknown; }undefinedfalseSet initial value to form
ignoreFieldsstring[]undefinedfalseIgnored fields to render
debugbooleanundefinedfalseDebug in console on form submit
readOnlybooleanundefinedfalseRead only mode
disabledSubmitButtonbooleanundefinedfalseDisable submit button
isSubmittingbooleanundefinedfalseDisable submit button while submitting
renderFormValidationfunction({ disabled, isLoading }: RenderFormValidationParams): ReactElementundefinedfalseCustom form validation renderer

Options

OptionsTypeDefaultRequiredDetail
countryAutocompleteServicestring"fr"falseDefine country restrictions for autocomplete
googleApiKeystringfalseIf you want use some google service like autocomplete address, then you want provide Google Api Key
prefixResponseImageUriAutocompletestringfalsePrefix response image uri for autocomplete image
licenseMuiXstringfalseLicense MUI X to enable pro and premium feature
disablePastDatePickerbooleanfalseDisable past for date picker
disablePastDateRangePickerbooleanfalseDisable past for date range picker
adapterLocalestringfalseAdapter local for locale format

TreegeConsumerResponse

Render values from form based on Treege

PropsTypeDefaultRequiredDetail
values{label: string;name: string;type: string;tag?: string;value: string; | { label: string; value: string }}undefinedtrueObject of data
renderInputsfunction(input: JsonFormValue): ReactElement | undefinedundefinedfalseCustom inputs rendering
ignoreFieldsstring[]undefinedfalseIgnored fiels to render
collapsebooleanundefinedfalseEnable collapse or note
collapseVisibleItemNumbernumber4falseNumber of visible item before collapse. Works only if collapse is true
disabledSubmitButtonbooleanundefinedfalseBoolean 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;
1.42.0

8 months ago

1.41.3

8 months ago

1.37.0

9 months ago

1.37.1

9 months ago

1.37.2

9 months ago

1.40.0

8 months ago

1.38.2

9 months ago

1.38.3

9 months ago

1.38.0

9 months ago

1.38.1

9 months ago

1.38.4

8 months ago

1.41.1

8 months ago

1.41.0

8 months ago

1.41.2

8 months ago

1.39.0

8 months ago

1.36.0

9 months ago

1.29.0

1 year ago

1.29.1

1 year ago

1.29.2

1 year ago

1.32.0

1 year ago

1.32.1

1 year ago

1.34.2

12 months ago

1.34.3

12 months ago

1.34.0

1 year ago

1.30.4

1 year ago

1.34.1

1 year ago

1.30.5

1 year ago

1.34.6

12 months ago

1.34.7

12 months ago

1.34.4

12 months ago

1.34.10

11 months ago

1.34.5

12 months ago

1.34.8

11 months ago

1.34.9

11 months ago

1.34.11

11 months ago

1.34.12

11 months ago

1.34.13

11 months ago

1.34.14

11 months ago

1.33.0

1 year ago

1.35.1

11 months ago

1.30.2

1 year ago

1.30.3

1 year ago

1.30.0

1 year ago

1.30.1

1 year ago

1.32.2

1 year ago

1.28.5

1 year ago

1.28.4

1 year ago

1.31.0

1 year ago

1.28.1

1 year ago

1.28.2

1 year ago

1.28.0

1 year ago

1.28.3

1 year ago

1.27.2

1 year ago

1.27.1

1 year ago

1.27.0

1 year ago

1.26.3

1 year ago

1.26.4

1 year ago

1.26.2

1 year ago

1.26.1

1 year ago

1.26.0

1 year ago

1.25.0

1 year ago

1.24.1

1 year ago

1.24.2

1 year ago

1.24.3

1 year ago

1.23.0

1 year ago

1.24.0

1 year ago

1.22.0

1 year ago

1.21.0

1 year ago

1.21.1

1 year ago

1.20.0

1 year ago

1.18.0

2 years ago

1.19.0

2 years ago

1.19.1

2 years ago

1.17.2

2 years ago

1.17.1

2 years ago

1.17.4

2 years ago

1.17.3

2 years ago

1.14.1

2 years ago

1.15.0

2 years ago

1.16.1

2 years ago

1.16.0

2 years ago

1.14.2

2 years ago

1.13.2

2 years ago

1.14.0

2 years ago

1.13.1

2 years ago

1.13.0

2 years ago

1.12.1

2 years ago

1.12.0

2 years ago

1.13.3

2 years ago

1.11.0

2 years ago

1.9.0

2 years ago

1.8.0

2 years ago

1.7.0

2 years ago

1.6.0

2 years ago

1.4.2

2 years ago

1.5.0

2 years ago

1.4.1

2 years ago

1.10.1

2 years ago

1.10.0

2 years ago

1.2.0

3 years ago

1.1.1

3 years ago

1.2.6

3 years ago

1.2.5

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.4.0

3 years ago

1.2.2

3 years ago

1.1.3

3 years ago

1.3.0

3 years ago

1.2.1

3 years ago

1.1.2

3 years ago

1.1.0

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago