Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Checklist: rename values prop to value #558

Merged
merged 6 commits into from
May 31, 2019
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
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
### Changed
- Changed `dcc.Checklist` prop `values` to `value`, to match all the other input components [#558](https://github.com/plotly/dash-core-components/pull/558). Also improved prop types for `Dropdown` and `RadioItems` `value` props to consistently accept both strings and numbers.

## [0.48.0] - 2019-05-15
### Added
- `figure` prop in `dcc.Graph` now accepts a `frames` key
- Improved the `Dropdown` options description for dash-docs #547
- Added `optionHeight` prop to `Dropdown` #552
- Improved the `Dropdown` options description for dash-docs [#547](https://github.com/plotly/dash-core-components/pull/547)
- Added `optionHeight` prop to `Dropdown` [#552](https://github.com/plotly/dash-core-components/pull/552)

### Removed
- Removed unused `key` prop from `dcc.ConfirmDialog`
Expand Down
4 changes: 2 additions & 2 deletions demo/Demo.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ class Controller extends Component {
constructor() {
super();
this.state = {
values: ['melons', 'apples']
value: ['melons', 'apples']
};
}

Expand All @@ -288,7 +288,7 @@ class Controller extends Component {
setProps={(props) => {
this.setState(props);
}}
values={this.state.values}
value={this.state.value}
{...properties}
/>);
}
Expand Down
4 changes: 3 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ module.exports = {
// ],

// A map from regular expressions to module names that allow to stub out resources with a single module
// moduleNameMapper: {},
moduleNameMapper: {
"\\.(css|less)$": "identity-obj-proxy"
},

// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
// modulePathIgnorePatterns: [],
Expand Down
49 changes: 35 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"babel-eslint": "^10.0.1",
"babel-jest": "^24.5.0",
"babel-loader": "^8.0.5",
"check-prop-types": "^1.1.2",
"component-playground": "^3.0.0",
"copyfiles": "^2.0.0",
"css-loader": "^1.0.1",
Expand All @@ -64,6 +65,7 @@
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-react": "^7.11.1",
"exec-sh": "^0.3.0",
"identity-obj-proxy": "^3.0.0",
"jest": "^24.5.0",
"npm-run-all": "^4.1.5",
"prettier": "^1.14.2",
Expand Down
23 changes: 12 additions & 11 deletions src/components/Checklist.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import React, {Component} from 'react';

/**
* Checklist is a component that encapsulates several checkboxes.
* The values and labels of the checklist is specified in the `options`
* property and the checked items are specified with the `values` property.
* The values and labels of the checklist are specified in the `options`
* property and the checked items are specified with the `value` property.
* Each checkbox is rendered as an input with a surrounding label.
*/
export default class Checklist extends Component {
Expand All @@ -21,7 +21,7 @@ export default class Checklist extends Component {
setProps,
style,
loading_state,
values,
value,
} = this.props;

return (
Expand All @@ -40,19 +40,19 @@ export default class Checklist extends Component {
className={labelClassName}
>
<input
checked={contains(option.value, values)}
checked={contains(option.value, value)}
className={inputClassName}
disabled={Boolean(option.disabled)}
style={inputStyle}
type="checkbox"
onChange={() => {
let newValues;
if (contains(option.value, values)) {
newValues = without([option.value], values);
let newValue;
if (contains(option.value, value)) {
newValue = without([option.value], value);
} else {
newValues = append(option.value, values);
newValue = append(option.value, value);
}
setProps({values: newValues});
setProps({value: newValue});
}}
/>
{option.label}
Expand Down Expand Up @@ -85,7 +85,7 @@ Checklist.propTypes = {
/**
* The value of the checkbox. This value
* corresponds to the items specified in the
* `values` property.
* `value` property.
*/
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
.isRequired,
Expand All @@ -100,7 +100,7 @@ Checklist.propTypes = {
/**
* The currently selected value
*/
values: PropTypes.arrayOf(
value: PropTypes.arrayOf(
PropTypes.oneOfType([PropTypes.string, PropTypes.number])
),

Expand Down Expand Up @@ -166,4 +166,5 @@ Checklist.defaultProps = {
labelStyle: {},
labelClassName: '',
options: [],
value: [],
};
11 changes: 6 additions & 5 deletions src/components/Dropdown.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@ Dropdown.propTypes = {
/**
* The value of the dropdown. This value
* corresponds to the items specified in the
* `values` property.
* `value` property.
*/
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
.isRequired,

/**
* If true, this dropdown is disabled and items can't be selected.
* If true, this option is disabled and cannot be selected.
*/
disabled: PropTypes.bool,
})
Expand All @@ -152,9 +152,10 @@ Dropdown.propTypes = {
*/
value: PropTypes.oneOfType([
PropTypes.string,
PropTypes.arrayOf(PropTypes.string),
PropTypes.number,
PropTypes.arrayOf(PropTypes.number),
PropTypes.arrayOf(
PropTypes.oneOfType([PropTypes.string, PropTypes.number])
),
]),

/**
Expand All @@ -175,7 +176,7 @@ Dropdown.propTypes = {
clearable: PropTypes.bool,

/**
* If true, the option is disabled
* If true, this dropdown is disabled and the selection cannot be changed.
*/
disabled: PropTypes.bool,

Expand Down
4 changes: 2 additions & 2 deletions src/components/RadioItems.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ RadioItems.propTypes = {
/**
* The value of the radio item. This value
* corresponds to the items specified in the
* `values` property.
* `value` property.
*/
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
.isRequired,
Expand All @@ -99,7 +99,7 @@ RadioItems.propTypes = {
/**
* The currently selected value
*/
value: PropTypes.string,
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),

/**
* The style of the container (div)
Expand Down
2 changes: 1 addition & 1 deletion test/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ def test_gallery(self):
{'label': 'San Francisco', 'value': 'SF'},
{'label': u'北京', 'value': u'北京'}
Copy link
Contributor

@byronz byronz May 31, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should leave an easter egg here with {'label': u'北京', 'value': u'帝都'}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I liked your original comment - it would be an eastern egg indeed 😉 feel free to add it!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but you might not get the egg? or you level of mandarin is beyond my imagination :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My mandarin is only as good as google translate's. But I have no problem with spreading the fun around to more languages - we have plenty of little English jokes scattered around our tests!

],
values=['MTL', 'SF']
value=['MTL', 'SF']
),

html.Label('Text Input'),
Expand Down
Loading