|
| 1 | +[](https://badge.fury.io/js/%40data-driven-forms%2Fcarbon-component-mapper) |
| 2 | +[](https://twitter.com/intent/tweet?text=Check%20DataDrivenForms%20React%20library%21%20https%3A%2F%2Fdata-driven-forms.org%2F&hashtags=react,opensource,datadrivenforms) |
| 3 | +[](https://twitter.com/DataDrivenForms) |
| 4 | + |
| 5 | +[](https://data-driven-forms.org/) |
| 6 | + |
| 7 | +carbon component mapper for [Data Driven Forms](https://github.com/data-driven-forms/react-forms). |
| 8 | + |
| 9 | +:book: For more information please visit the [documentation](https://data-driven-forms.org/). :book: |
| 10 | + |
| 11 | +**Table of Contents** |
| 12 | + |
| 13 | +- [Installation](#installation) |
| 14 | + - [React Form Renderer](#react-form-renderer) |
| 15 | + - [Carbon Mapper](#carbon-mapper) |
| 16 | +- [Usage](#usage) |
| 17 | +- [Basic provided components](#basic-provided-components) |
| 18 | +- [Useful links](#useful-links) |
| 19 | +- [Development setup](#development-setup) |
| 20 | + - [Tests](#tests) |
| 21 | + - [Commits](#commits) |
| 22 | + - [Changes to documentation](#changes-to-documentation) |
| 23 | +- [Contribution](#contribution) |
| 24 | +- [LICENSE](#license) |
| 25 | + |
| 26 | +### Installation |
| 27 | + |
| 28 | +You neet to add React Form Renderer |
| 29 | + |
| 30 | +#### [React Form Renderer](https://www.npmjs.com/package/@data-driven-forms/react-form-renderer) |
| 31 | + |
| 32 | +```console |
| 33 | +$ npm install @data-driven-forms/react-form-renderer -S |
| 34 | +``` |
| 35 | + |
| 36 | +```console |
| 37 | +$ yarn add @data-driven-forms/react-form-renderer |
| 38 | +``` |
| 39 | + |
| 40 | +#### [Carbon Mapper](https://data-driven-forms.org/mappers/carbon-component-mapper) |
| 41 | + |
| 42 | +```console |
| 43 | +$ npm install @data-driven-forms/carbon-component-mapper -S |
| 44 | +``` |
| 45 | + |
| 46 | +```console |
| 47 | +$ yarn add @data-driven-forms/carbon-component-mapper |
| 48 | +``` |
| 49 | + |
| 50 | + |
| 51 | +### Usage |
| 52 | + |
| 53 | +For using Data Driven Forms in your component you need the renderer and a component mapper, which provides formFields components and layoutFields components. |
| 54 | + |
| 55 | +```jsx |
| 56 | +import React from 'react'; |
| 57 | +import FormRenderer, { componentTypes } from '@data-driven-forms/react-form-renderer'; |
| 58 | +import { componentMapper, FormTemplate } from '@data-driven-forms/carbon-component-mapper'; |
| 59 | + |
| 60 | +const schema = { |
| 61 | + fields: [{ |
| 62 | + component: componentTypes.TEXT_FIELD, |
| 63 | + name: 'name', |
| 64 | + label: 'Your name' |
| 65 | + }] |
| 66 | +} |
| 67 | + |
| 68 | +const Form = () => ( |
| 69 | + <FormRenderer |
| 70 | + schema={schema} |
| 71 | + componentMapper={componentMapper} |
| 72 | + FormTemplate={FormTemplate} |
| 73 | + onSubmit={console.log} |
| 74 | + /> |
| 75 | +) |
| 76 | +``` |
| 77 | + |
| 78 | +### Basic provided components |
| 79 | + |
| 80 | +Data Driven Forms supports all kinds of component, basic set is consisted of: |
| 81 | + |
| 82 | +- Text input |
| 83 | +- Text area |
| 84 | +- Checkbox (Multiple checkboxes) |
| 85 | +- Select (dropdown) |
| 86 | +- Dual list select |
| 87 | +- Field array |
| 88 | +- Switch |
| 89 | +- Radio buttons |
| 90 | +- Date picker |
| 91 | +- Time picker |
| 92 | +- Tabs |
| 93 | +- Slider |
| 94 | +- Sub-form |
| 95 | +- Wizard |
| 96 | + |
| 97 | +### Useful links |
| 98 | + |
| 99 | +- [Data Driven Forms documentation](https://data-driven-forms.org/) |
| 100 | +- [React Form Renderer](https://www.npmjs.com/package/@data-driven-forms/react-form-renderer) |
| 101 | +- [Carbon Mapper NPM](https://www.npmjs.com/package/@data-driven-forms/carbon-component-mapper) |
| 102 | +- [Carbon Design System documentation](https://www.carbondesignsystem.com/) |
| 103 | +- [Carbon React Compononents storybook](https://react.carbondesignsystem.com/) |
| 104 | + |
| 105 | +### Development setup |
| 106 | + |
| 107 | +Data Driven Forms is a monorepo that uses [Lerna](https://github.com/lerna/lerna) and [yarn workspaces](https://classic.yarnpkg.com/blog/2017/08/02/introducing-workspaces/), so you can use all its commands as well. |
| 108 | + |
| 109 | +1. Install |
| 110 | + |
| 111 | +```console |
| 112 | +yarn install |
| 113 | +``` |
| 114 | + |
| 115 | +2. Build |
| 116 | + |
| 117 | +```console |
| 118 | +yarn build |
| 119 | +``` |
| 120 | + |
| 121 | +3. Run a package |
| 122 | + |
| 123 | +Each package has a small playground `package/demo`, where you can test your changes. |
| 124 | + |
| 125 | +```console |
| 126 | +cd packages/carbon-component-mapper |
| 127 | +yarn start |
| 128 | +``` |
| 129 | + |
| 130 | +4. How to clean? |
| 131 | + |
| 132 | +```console |
| 133 | +yarn lerna clean # will delete all node_modules |
| 134 | +``` |
| 135 | + |
| 136 | +All packages are linked together by default, so if you run a `yarn build` in a package, all other packages are updated to the latest version of that package. |
| 137 | + |
| 138 | +#### Tests |
| 139 | + |
| 140 | +Tests needed to be run from the core folder. |
| 141 | + |
| 142 | +```console |
| 143 | +yarn test |
| 144 | + |
| 145 | +yarn test packages/carbon-component-mapper |
| 146 | +``` |
| 147 | + |
| 148 | +#### Commits |
| 149 | + |
| 150 | +Data Driven Forms uses [Semantic Release](https://github.com/semantic-release/commit-analyzer) |
| 151 | + |
| 152 | +Format: |
| 153 | + |
| 154 | +``` |
| 155 | +[type]([package]): message |
| 156 | +
|
| 157 | +fix(carbon): title accepts node |
| 158 | +``` |
| 159 | + |
| 160 | +Types: |
| 161 | +- `feat`: a new feature, will trigger new `_.X._` release |
| 162 | +- `fix`: a fix, will trigger new `_._.X` release |
| 163 | + |
| 164 | +Packages: |
| 165 | +- Please describe which package is being changed `carbon`, `renderer`, ... |
| 166 | + |
| 167 | +Please, do not use Semantic Release, if you update only the demo. |
| 168 | + |
| 169 | +All packages are releasing together and they share the version number. |
| 170 | + |
| 171 | +#### Changes to documentation |
| 172 | + |
| 173 | +If your changes influence API or add new features, you should describe these new options in the `react-renderer-demo` repository. Thanks! |
| 174 | + |
| 175 | +### Contribution |
| 176 | + |
| 177 | +We welcome any community contribution. Don't be afraid to report bug or to create issues and pull-requests! :trophy: |
| 178 | + |
| 179 | +### LICENSE |
| 180 | + |
| 181 | +Apache License 2.0 |
0 commit comments