Skip to content

Commit

Permalink
Enable antd (ant-design) support (#1561)
Browse files Browse the repository at this point in the history
* Enable antd (ant-design) support

* Change name of package in local package.json for consistency

* Add local readme file

* Tidy the package dependencies

* Change README.md references to rjsf npm organisation

* Update package.json an dimports to reflect the new rjsf organization

* Deprecate antd custom withTheme as core now has forwardRef

* Ensure Theme is not default export for consistency

* Add scripts for building dist and lib in package.json

* Fix test to use non-default import

* Add babel-plugin-import to ensure styles are imported on demand

* Add rjsf-antd theme to the playground

* Migrate rjsf-antd code to antd v4 support

* Implement EmailWidget and URLWidget for rjsf-antd

* Reimplement rjsf-antd tests based on latest

* Enable rjsf-antd support in the playground

* Finalise rjsf-antd packages files

* Remove useless build:lib script

* Enable support for additionalProperties schemas

* Update the test snapshots

* Fix minor styling issues with descriptions

* Ensure popups are rendered next to fields (even when used with iframes)

* Implement AltDate/AltDateTimeWidgets for antd theme

* update package-lock

* Fix SelectWidget placeholder never being shown

* Fix issue with the alternative date pickers

* Fix issue with additionalProperties blanking out

* Change license for consistency

* Add semicolon

* build cjs, es, and umd

* antd - switch to new build process, fix global styles

Co-authored-by: Ashwin Ramaswami <[email protected]>
  • Loading branch information
delyanr and epicfaace authored Jun 23, 2020
1 parent 13ea8f4 commit 959f9b3
Show file tree
Hide file tree
Showing 53 changed files with 14,384 additions and 102 deletions.
33 changes: 33 additions & 0 deletions packages/antd/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"parser": "babel-eslint",
"rules": {
"react/jsx-uses-react": 2,
"react/jsx-uses-vars": 2,
"react/react-in-jsx-scope": 2,
"react/jsx-tag-spacing": [1, {
"beforeSelfClosing": "always"
}],
"curly": [2],
"linebreak-style": [2, "unix"],
"semi": [2, "always"],
"comma-dangle": [0],
"no-unused-vars": [2, {
"vars": "all",
"args": "none",
"ignoreRestSiblings": true
}],
"no-console": [0],
"object-curly-spacing": [2, "always"],
"keyword-spacing": ["error"]
},
"env": {
"es6": true,
"browser": true,
"node": true
},
"extends": "eslint:recommended",
"plugins": [
"jsx-a11y",
"react"
]
}
83 changes: 83 additions & 0 deletions packages/antd/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
[![npm][npm-shield]][npm-url]
[![npm downloads][npm-dl-shield]][npm-dl-url]

<br />
<p align="center">
<h3 align="center">@rjsf/antd</h3>

<p align="center">
Ant Design theme, fields and widgets for <a href="https://github.com/rjsf-team/react-jsonschema-form"><code>react-jsonschema-form</code></a>.
<br />
<a href="https://react-jsonschema-form.readthedocs.io/"><strong>Explore the docs »</strong></a>
<br />
<br />
<a href="https://rjsf-team.github.io/react-jsonschema-form/">View Playground (TBD)</a>
·
<a href="https://github.com/rjsf-team/react-jsonschema-form/issues">Report Bug</a>
·
<a href="https://github.com/rjsf-team/react-jsonschema-form/issues">Request Feature</a>
</p>
</p>

## Table of Contents

- [Getting Started](#getting-started)
- [Prerequisites](#prerequisites)
- [Installation](#installation)
- [Usage](#usage)
- [Roadmap](#roadmap)
- [Contributing](#contributing)
- [License](#license)

## Getting Started

### Prerequisites

- `antd >= 4.0.0`
- `react-jsonschema-form >= 2.0.0`

```sh
npm install antd @rjsf/core
```

### Installation

```sh
npm install @rjsf/antd
```

## Usage

```javascript
import Form from '@rjsf/antd';
```

or

```javascript
import { withTheme } from '@rjsf/core';
import { Theme } from '@rjsf/antd';

// Make modifications to the Theme with your own fields and widgets

const Form = withTheme(Theme);
```

## Roadmap

See the general [open issues](https://github.com/rjsf-team/react-jsonschema-form/issues).

## Contributing

Read the general [contributors' guide](https://react-jsonschema-form.readthedocs.io/en/latest/#contributing) to get started.

## License

Apache 2

<!-- MARKDOWN LINKS & IMAGES -->

[npm-shield]: https://img.shields.io/npm/v/react-jsonschema-form/latest.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/react-jsonschema-form
[npm-dl-shield]: https://img.shields.io/npm/dm/react-jsonschema-form.svg?style=flat-square
[npm-dl-url]: https://www.npmjs.com/package/react-jsonschema-form
13 changes: 13 additions & 0 deletions packages/antd/__mocks__/matchMedia.mock
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Object.defineProperty(window, 'matchMedia', {
writable: true,
value: jest.fn().mockImplementation(query => ({
matches: false,
media: query,
onchange: null,
addListener: jest.fn(),
removeListener: jest.fn(),
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
dispatchEvent: jest.fn(),
})),
});
1 change: 1 addition & 0 deletions packages/antd/__mocks__/styleMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {};
55 changes: 55 additions & 0 deletions packages/antd/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
const BABEL_ENV = process.env.BABEL_ENV;

const defaultPlugins = [];

module.exports = {
"presets": [
[
"@babel/preset-env",
{
modules: ["cjs", "test"].includes(BABEL_ENV) ? "commonjs" : false,
targets:
BABEL_ENV === "test" ? { node: "current" } : { browsers: "defaults" },
},
],
"@babel/preset-react"
],
"plugins": [
[
"import",
{
"libraryName": "antd",
"style": true
}
],
"@babel/plugin-proposal-object-rest-spread",
"@babel/plugin-proposal-class-properties",
[
"@babel/plugin-transform-runtime",
{
"corejs": 2
}
]
],
"env": {
cjs: {
plugins: defaultPlugins,
ignore: ['test/**/*.js']
},
umd: {
plugins: defaultPlugins,
ignore: ['test/**/*.js']
},
es: {
plugins: [
...defaultPlugins,
['@babel/plugin-transform-runtime', { useESModules: true, corejs: 2 }]
],
ignore: ['test/**/*.js']
},
test: {
plugins: defaultPlugins,
ignore: []
}
}
};
Loading

0 comments on commit 959f9b3

Please sign in to comment.