Giter Site home page Giter Site logo

networknt / react-schema-form-rc-select Goto Github PK

View Code? Open in Web Editor NEW
11.0 3.0 8.0 6.76 MB

An add-on of react-schema-form that support multiple select and a demo for extending react-schema-form with new components.

License: MIT License

JavaScript 89.37% HTML 7.63% CSS 3.00%

react-schema-form-rc-select's Introduction

react-schema-form-rc-select

Join the chat at https://gitter.im/networknt/react-schema-form CircleCI npm package

The RcSelect is an add-on of react-schema-form, and it supports both single and multiple select with async retrieval data from the Internet APIs. It is a demo for extending react-schema-form with new components externally.

It is a react-schema-form field component that wraps around rc-select

Features

  1. Single select or multiple select with an option to add new items
  2. Static dropdown values defined in schema or form
  3. Dynamic dropdown values in JSON format load from the same server or Internet by get or post request
  4. Dynamic dropdown values enriched on the API server when schema/form is loaded.

To run the example locally

Clone the project and run

git clone https://github.com/networknt/react-schema-form-rc-select.git
cd react-schema-form-rc-select/example
npm install
npm start

A browser tab will be automatically opened with http://localhost:3000.

Installation

npm install react-schema-form-rc-select

This module is an extension of react-schema-form, and it must be called from react-schema-form to handle rc-select form type. It shows how to customize the react-schema-form to add a new field and map a new form type to it. Please see App.js in the example folder for the details.

import RcSelect from "react-schema-form-rc-select";
...

        var schemaForm = '';
        if (this.state.form.length > 0) {
            schemaForm = (
                <SchemaForm schema={this.state.schema} form={this.state.form} model={this.state.model} onModelChange={this.onModelChange} mapper={{"rc-select": RcSelect}} />
            );
        }

Documentation

For more detailed document, please visit the networknt document site

Contributing

See our CONTRIBUTING.md for information on how to contribute.

License

MIT Licensed. Copyright (c) Network New Technologies Inc. 2016-2020.

react-schema-form-rc-select's People

Contributors

dependabot[bot] avatar devel-pa avatar stevehu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

react-schema-form-rc-select's Issues

Refresh array items

The items in the select dropdown are different depending on the answer of the previous question. Is there any way to update the items in the select dropdown on the fly?

interested

Wanted to check out the live demo but the url for the API is down. Do you know if it is still compatible with the newer versions of Mozilla's lib?

handle the model is undefined when calling the replacer

In most of the cases, the form will pass in an empty model. However, this is not guaranteed. If null is passed in, the replacer will fail. To prevent the problem, we need to avoid calling replacer if the passed in data is undefined.

Clean up dependencies

I think this add-on project should be cleaned up to contain nothing else than the add-on. Not react, not babel or webpack. The demos that make use of can all reside in the main repository (https://github.com/networknt/react-schema-form) and have the addons as dev dependencies.

If you think this is a good idea I'm willing to PR

update the remote data format to reduce the size

The JSON response from API has been changed from

[
    {"value": "json-value1", "label": "json-label1"},
    {"value": "json-value2", "label": "json-label2"},
    {"value": "json-value3", "label": "json-label3"}
]

to

[
    {"json-value1": "json-label1"},
    {"json-value2": "json-label2"},
    {"json-value3": "json-label3"}
]

add support to the cascade select between multiple selects

For example, you have a country, province, and city in a form and all three are loaded from the remote reference website. When you select a country, you need to ensure that the province is reloaded based on the country selected in the model. After you select a province, you need to make sure that the city is reloaded dynamically.

The above is only part of the deal. If you select another country, you need to make sure that the province is cleared out and reloaded with the provinces belong to the selected country.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.