Skip to content

Revert "New JSX transform" + version bump #1118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
{
"presets": [
[
"@babel/preset-react",
{
"runtime": "automatic"
}
],
"@babel/env"
],
"presets": ["@babel/react", "@babel/env"],
"plugins": [
"@babel/plugin-proposal-object-rest-spread",
[
Expand Down
5 changes: 2 additions & 3 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,14 @@
"radix": ["error"],
"react/jsx-no-duplicate-props": ["error"],
"react/jsx-no-undef": ["error"],
"react/jsx-uses-react": ["off"],
"react/jsx-uses-react": ["error"],
"react/jsx-uses-vars": ["error"],
"react/no-did-update-set-state": ["error"],
"react/no-direct-mutation-state": ["error"],
"react/no-is-mounted": ["error"],
"react/no-unknown-property": ["error"],
"react/prefer-es6-class": ["error", "always"],
"react/prop-types": ["error"],
"react/react-in-jsx-scope": ["off"],
"react/prop-types": "error",
"valid-jsdoc": ["error"],
"yoda": ["error"],
"spaced-comment": ["error", "always", {
Expand Down
18 changes: 0 additions & 18 deletions .storybook/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,5 @@ module.exports = async ({config, mode}) => {
use: ['style-loader', 'css-loader', 'sass-loader'],
include: path.resolve(__dirname, '../'),
});
config.module.rules.push({
test: /\.js?$/,
use: {
loader: 'babel-loader',
options: {
presets: [
[
'@babel/preset-react',
{
runtime: 'automatic',
},
],
'@babel/env',
],
},
},
exclude: [/node_modules/],
});
return config;
};
22 changes: 9 additions & 13 deletions dev/App.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component} from 'react';
import React, {Component} from 'react';
import {hot} from 'react-hot-loader/root';
import plotly from 'plotly.js/dist/plotly-with-meta';
import '../src/styles/main.scss';
Expand All @@ -16,16 +16,15 @@ import ACCESS_TOKENS from '../accessTokens';

// import {customConfigTest} from '../src/__stories__';

const dataSourceOptions = Object.keys(dataSources).map((name) => ({
const dataSourceOptions = Object.keys(dataSources).map(name => ({
value: name,
label: name,
}));

const config = {mapboxAccessToken: ACCESS_TOKENS.MAPBOX, editable: true};

// eslint-disable-next-line no-unused-vars
const traceTypesConfig = {
traces: (_) => [
traces: _ => [
{
value: 'scatter',
icon: 'scatter',
Expand Down Expand Up @@ -67,19 +66,16 @@ const traceTypesConfig = {
complex: true,
};

// eslint-disable-next-line no-unused-vars
const chartHelp = {
area: {
helpDoc: 'https://help.plot.ly/make-an-area-graph/',
examplePlot: () => {
// eslint-disable-next-line no-console
console.log('example bar plot!');
},
},
bar: {
helpDoc: 'https://help.plot.ly/stacked-bar-chart/',
examplePlot: () => {
// eslint-disable-next-line no-console
console.log('example bar plot!');
},
},
Expand Down Expand Up @@ -126,8 +122,8 @@ class App extends Component {
// curl https://api.github.com/repos/plotly/plotly.js/contents/test/image/mocks \
// | jq '[.[] | .name ]' > mocks.json
fetch('/mocks.json')
.then((response) => response.json())
.then((mocks) => this.setState({mocks}));
.then(response => response.json())
.then(mocks => this.setState({mocks}));
}

loadMock(mockIndex) {
Expand All @@ -139,8 +135,8 @@ class App extends Component {
fetch(prefix + mockName, {
headers: new Headers({Accept: 'application/vnd.github.v3.raw'}),
})
.then((response) => response.json())
.then((figure) => {
.then(response => response.json())
.then(figure => {
const {data, layout, frames} = figure;
this.updateState(data, layout, frames, mockIndex);
});
Expand Down Expand Up @@ -223,7 +219,7 @@ class App extends Component {
}))}
searchable={true}
searchPromptText="Search for a mock"
onChange={(option) => this.loadMock(option.value)}
onChange={option => this.loadMock(option.value)}
noResultsText={'No Results'}
placeholder={'Search for a mock'}
/>
Expand All @@ -238,7 +234,7 @@ class App extends Component {
<AceEditor
mode="json"
theme="textmate"
onChange={(json_string) => this.setState({json_string})}
onChange={json_string => this.setState({json_string})}
value={this.state.json_string}
name="UNIQUE_ID_OF_DIV"
style={{height: '80vh'}}
Expand Down
1 change: 1 addition & 0 deletions dev/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from 'react';
import ReactDOM from 'react-dom';
import './styles.css';
import App from './App';
Expand Down
4 changes: 2 additions & 2 deletions examples/custom/src/App.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component} from 'react';
import React, {Component} from 'react';
import plotly from 'plotly.js/dist/plotly';
import PlotlyEditor from 'react-chart-editor';
import CustomEditor from './CustomEditor';
Expand All @@ -9,7 +9,7 @@ const dataSources = {
col2: [4, 3, 2], // eslint-disable-line no-magic-numbers
col3: [17, 13, 9], // eslint-disable-line no-magic-numbers
};
const dataSourceOptions = Object.keys(dataSources).map((name) => ({
const dataSourceOptions = Object.keys(dataSources).map(name => ({
value: name,
label: name,
}));
Expand Down
17 changes: 4 additions & 13 deletions examples/custom/src/CustomEditor.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component} from 'react';
import React, {Component} from 'react';
import {
Flaglist,
ColorPicker,
Expand Down Expand Up @@ -47,28 +47,19 @@ export default class CustomEditor extends Component {
label="Dropdown"
attr="xaxis.title"
show
options={[
{label: 'Yes', value: 'yes'},
{label: 'No', value: 'no'},
]}
options={[{label: 'Yes', value: 'yes'}, {label: 'No', value: 'no'}]}
/>
<Radio
label="Radio"
attr="yaxis.title"
show
options={[
{label: 'Yes', value: 'yes'},
{label: 'No', value: 'no'},
]}
options={[{label: 'Yes', value: 'yes'}, {label: 'No', value: 'no'}]}
/>
<Flaglist
label="Flaglist"
attr="title.font.family"
show
options={[
{label: 'Yes', value: 'y'},
{label: 'No', value: 'n'},
]}
options={[{label: 'Yes', value: 'y'}, {label: 'No', value: 'n'}]}
/>
<ColorPicker label="ColorPicker" attr="plot_bgcolor" show />
<TextEditor attr="title" label="TextEditor default" />
Expand Down
1 change: 1 addition & 0 deletions examples/custom/src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
Expand Down
12 changes: 6 additions & 6 deletions examples/demo/src/App.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {Component} from 'react';
import React, {Component} from 'react';
import plotly from 'plotly.js/dist/plotly';
import PlotlyEditor from 'react-chart-editor';
import 'react-chart-editor/lib/react-chart-editor.css';
import Nav from './Nav';
import dataSources from './dataSources';

const dataSourceOptions = Object.keys(dataSources).map((name) => ({
const dataSourceOptions = Object.keys(dataSources).map(name => ({
value: name,
label: name,
}));
Expand All @@ -29,17 +29,17 @@ class App extends Component {

UNSAFE_componentWillMount() {
fetch('https://api.github.com/repos/plotly/plotly.js/contents/test/image/mocks')
.then((response) => response.json())
.then((mocks) => this.setState({mocks}));
.then(response => response.json())
.then(mocks => this.setState({mocks}));
}

loadMock(mockIndex) {
const mock = this.state.mocks[mockIndex];
fetch(mock.url, {
headers: new Headers({Accept: 'application/vnd.github.v3.raw'}),
})
.then((response) => response.json())
.then((figure) => {
.then(response => response.json())
.then(figure => {
this.setState({
currentMockIndex: mockIndex,
data: figure.data,
Expand Down
3 changes: 2 additions & 1 deletion examples/demo/src/Nav.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import PropTypes from 'prop-types';
import React from 'react';
import Dropdown from 'react-chart-editor/lib/components/widgets/Dropdown';

const Nav = ({mocks, currentMockIndex, loadMock}) => (
Expand All @@ -19,7 +20,7 @@ const Nav = ({mocks, currentMockIndex, loadMock}) => (
value: i,
}))}
value={currentMockIndex}
onChange={(option) => loadMock(option)}
onChange={option => loadMock(option)}
/>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions examples/demo/src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
Expand Down
17 changes: 12 additions & 5 deletions examples/redux/src/App.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'react-chart-editor/lib/react-chart-editor.css';
import PlotlyEditor from 'react-chart-editor';
import PropTypes from 'prop-types';
import {Component} from 'react';
import React, {Component} from 'react';
import plotly from 'plotly.js/dist/plotly';
import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';
Expand All @@ -12,7 +12,7 @@ const dataSources = {
col2: [4, 3, 2], // eslint-disable-line no-magic-numbers
col3: [17, 13, 9], // eslint-disable-line no-magic-numbers
};
const dataSourceOptions = Object.keys(dataSources).map((name) => ({
const dataSourceOptions = Object.keys(dataSources).map(name => ({
value: name,
label: name,
}));
Expand All @@ -29,7 +29,14 @@ class App extends Component {
}

render() {
const {actions, dataSources, dataSourceOptions, data, layout, frames} = this.props;
const {
actions,
dataSources,
dataSourceOptions,
data,
layout,
frames,
} = this.props;

return (
<div className="app">
Expand Down Expand Up @@ -60,15 +67,15 @@ App.propTypes = {
frames: PropTypes.array,
};

const mapStateToProps = (state) => ({
const mapStateToProps = state => ({
dataSourceOptions: state.dataSourceOptions,
dataSources: state.dataSources,
data: state.data,
layout: state.layout,
frames: state.frames,
});

const mapDispatchToProps = (dispatch) => ({
const mapDispatchToProps = dispatch => ({
actions: bindActionCreators(actions, dispatch),
});

Expand Down
1 change: 1 addition & 0 deletions examples/redux/src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import './index.css';
import App from './App';
import React from 'react';
import ReactDOM from 'react-dom';
import reducer from './reducer';
import {Provider} from 'react-redux';
Expand Down
8 changes: 5 additions & 3 deletions examples/simple/src/App.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component} from 'react';
import React, {Component} from 'react';
import plotly from 'plotly.js/dist/plotly';
import PlotlyEditor from 'react-chart-editor';
import 'react-chart-editor/lib/react-chart-editor.css';
Expand All @@ -9,7 +9,7 @@ const dataSources = {
col3: [17, 13, 9], // eslint-disable-line no-magic-numbers
};

const dataSourceOptions = Object.keys(dataSources).map((name) => ({
const dataSourceOptions = Object.keys(dataSources).map(name => ({
value: name,
label: name,
}));
Expand All @@ -33,7 +33,9 @@ class App extends Component {
dataSources={dataSources}
dataSourceOptions={dataSourceOptions}
plotly={plotly}
onUpdate={(data, layout, frames) => this.setState({data, layout, frames})}
onUpdate={(data, layout, frames) =>
this.setState({data, layout, frames})
}
useResizeHandler
debug
advancedTraceTypeSelector
Expand Down
1 change: 1 addition & 0 deletions examples/simple/src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
Expand Down
Loading