Skip to content

Shorthand supports for dash-core-components #1747

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

Closed
wants to merge 90 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
97789e7
update Checklist, Dropdown, RangeSlider to accept optional shorthands
Sep 6, 2021
c4cedfe
update Checklist, RadioItems - added inline props and shorthand optio…
Sep 6, 2021
aee8ebd
fill component id if not given
Sep 6, 2021
3614b69
fix Dropdown props to accept array of string
Sep 6, 2021
bf43845
remove comments
Sep 6, 2021
4875ab9
fix lint issues
Sep 6, 2021
9deee71
generating seed for component id
Sep 6, 2021
effc6ef
Merge pull request #1 from workaholicpanda/feat/component-id-auto-fill
workaholicAB Sep 6, 2021
ab3dfae
lint fix in dash-table
Sep 6, 2021
e986f5d
lint fix
Sep 6, 2021
405bf72
remove inline props and lint fix
Sep 6, 2021
37a34c7
broken eslint :grimacing:
Sep 6, 2021
2582056
prettier fix
Sep 6, 2021
82ef2b7
set random id inside dash dependency
Sep 8, 2021
7cde3a6
Merge pull request #2 from workaholicpanda/dcc/set-random-id
workaholicAB Sep 8, 2021
1c1faf2
lint fixes
Sep 9, 2021
38ed9bf
bug fix
Sep 9, 2021
49cbaa2
add inline styling support
Sep 9, 2021
c4c54bc
fix bugs
Sep 9, 2021
6b1b4b5
add column populating in dash-table
Sep 9, 2021
e172ef8
disable restricting dependency type
Sep 9, 2021
c443e67
fix radio options type check
Sep 10, 2021
286ace8
add comments to inline props
Sep 10, 2021
bd7a9e3
add tests for shorthands
Sep 10, 2021
e5335ce
remove unused imports
Sep 10, 2021
22d2020
remove tests, refactor assign
Sep 10, 2021
7497eb2
use ramda.type instead of typeof
Sep 10, 2021
cdd6d18
backup commit
Sep 11, 2021
df24223
add auto generating marks to RangeSlider & Slider
Sep 11, 2021
74c25af
add number support for shorthanded options - Checklist, Dropdown
Sep 11, 2021
4a10694
some refactor to get react-docgen working, slider props re-arrange
Sep 11, 2021
5ab6618
fix unit test - remove outdated part
Sep 11, 2021
d90461e
update props comment
workaholicAB Sep 11, 2021
63ced02
fix feedback comments
Sep 11, 2021
f990b43
fix some issues in Checklist, DataTable props
Sep 12, 2021
f3e7893
pylint fix
Sep 12, 2021
67d0836
Apply suggestions from code review
workaholicAB Sep 13, 2021
6188289
copy paste ProTypes to get doc-gen working
Sep 13, 2021
f7fd107
Merge commit
Sep 13, 2021
1d4479d
Test Slider and RangeSlider shorthand properties
akksi Sep 13, 2021
1add4e2
Test Dropdown shorthand properties
akksi Sep 13, 2021
becdba9
Remove unnecessary imports
akksi Sep 13, 2021
9fe2f78
random seed moved out to global scope, the test for set_random_id was…
Sep 13, 2021
cf0ebb5
Merge pull request #3 from workaholicpanda/dcc/fix-issue960-tests
workaholicAB Sep 13, 2021
20d79c1
fix slider markers - respect steps given
Sep 13, 2021
f8bdf26
assert comparision is fixed
Sep 13, 2021
f052bbd
fix slider issues
Sep 14, 2021
348c88f
Merge branch 'dcc/fix-issue960' into dcc/fix-issue960-tests
akksi Sep 14, 2021
83cea43
Add dropdown option sanitization to some additional required places
akksi Sep 14, 2021
2ba81c6
Convert labels to strings when an Ojbect is passed as options
akksi Sep 14, 2021
780bc32
Add more variants to Dropdown shorthand test
akksi Sep 14, 2021
4d4b07e
Extend Slider tests
akksi Sep 14, 2021
21b3bc6
Add test for Dropdown array value type
akksi Sep 14, 2021
f06fe08
Merge pull request #4 from akksi/dcc/fix-issue960-tests
workaholicAB Sep 14, 2021
a440ec6
fix: update inline description & style
Sep 14, 2021
8519619
chore: pass black format
Sep 14, 2021
45cded7
chore: react doc-gen fix & flake fix
Sep 14, 2021
c922427
chore: rename test file names to avoid conflict
Sep 14, 2021
6727574
Handle undefined options in Dropdown
akksi Sep 14, 2021
6ecb2bc
Merge branch 'dcc/fix-issue960' into dcc/fix-issue960-tests
akksi Sep 14, 2021
4ac85da
Merge pull request #5 from akksi/dcc/fix-issue960-tests
workaholicAB Sep 14, 2021
7d85f2b
fix: the case when truncated out input marks handled
Sep 14, 2021
f835c0f
fix: correct step calculations implemented for sliders
Sep 15, 2021
8e5e6cf
fix: removed Start and End prefix / suffix from labels on Slider
Sep 15, 2021
5f569c9
chore: add labels to dropdown tests
Sep 15, 2021
d6e994a
chore: lint fix
Sep 15, 2021
d47a0b2
fix: dropdown options for test
Sep 15, 2021
24f6cd5
chore: prettier :sleepy:
Sep 15, 2021
d022d2b
fix: removed a test file which was causing percy tests fail
Sep 15, 2021
9ccdec3
fix: defining emptiness of dictionary implemented correctly, which fi…
Sep 16, 2021
edaea38
fix: omit 'step' from props
Sep 16, 2021
e54495e
chore: update props description
Sep 16, 2021
c8947e7
chore: remove unnecessary prop type checker
Sep 16, 2021
9485e50
fix: range slider test corrected, formatted to have some margins
Sep 16, 2021
a39a24e
Merge branch 'dcc/fix-issue960' of github.com:workaholicpanda/dash in…
Sep 16, 2021
07edc14
fix: the test_ddsh001_dropdown_shorthand_properties test restored bac…
Sep 16, 2021
ab8f4fb
fix: added bool type to CheckList label/value and RadioItem label/value
Sep 16, 2021
12e96e2
fix: the edited JS files are reformatted using lint
Sep 16, 2021
e49d34b
feat: implemented SI Units format for unit values of slider
Sep 17, 2021
487717b
feat: added tests to cover slider SI Units format for unit values
Sep 17, 2021
362929d
chore: eslint fix
Sep 17, 2021
1e7011e
fix: the test adopted to propsTypes which now accepts bool for severa…
Sep 17, 2021
9d77277
Merge branch 'dev' of github.com:plotly/dash into dcc/fix-issue960
Sep 17, 2021
6153bd0
fix: slider numbers whose ten factor is less than 3 and bigger than -…
Sep 17, 2021
a3e78b1
fix: lint issue fixed
Sep 17, 2021
23f5e79
fix: explicit null prevents auto generating marks in sliders
Sep 18, 2021
13e008f
fix: add snapshot for set_auto_id dependency link and asserts
Sep 18, 2021
d34453f
fix: test marks=None and SI units format
Sep 18, 2021
bea6c4c
fix: test_persistence - give step=1 to expect integer value output, o…
Sep 18, 2021
edf6042
fix: checking RadioItems and Checklist to accept new propTypes added …
Sep 18, 2021
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
170 changes: 114 additions & 56 deletions components/dash-core-components/src/components/Checklist.react.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import PropTypes from 'prop-types';
import {append, includes, without} from 'ramda';
import React, {Component} from 'react';
import {sanitizeOptions} from '../utils/optionTypes';

/**
* Checklist is a component that encapsulates several checkboxes.
Expand All @@ -22,8 +23,8 @@ export default class Checklist extends Component {
style,
loading_state,
value,
inline,
} = this.props;

return (
<div
data-dash-is-loading={
Expand All @@ -33,77 +34,126 @@ export default class Checklist extends Component {
style={style}
className={className}
>
{options.map(option => (
<label
key={option.value}
style={labelStyle}
className={labelClassName}
>
<input
checked={includes(option.value, value)}
className={inputClassName}
disabled={Boolean(option.disabled)}
style={inputStyle}
type="checkbox"
onChange={() => {
let newValue;
if (includes(option.value, value)) {
newValue = without([option.value], value);
} else {
newValue = append(option.value, value);
}
setProps({value: newValue});
}}
/>
{option.label}
</label>
))}
{sanitizeOptions(options).map(option => {
return (
<label
key={option.value}
style={Object.assign(
{},
labelStyle,
inline ? {display: 'inline-block'} : {}
)}
className={labelClassName}
>
<input
checked={includes(option.value, value)}
className={inputClassName}
disabled={Boolean(option.disabled)}
style={inputStyle}
type="checkbox"
onChange={() => {
let newValue;
if (includes(option.value, value)) {
newValue = without(
[option.value],
value
);
} else {
newValue = append(option.value, value);
}
setProps({value: newValue});
}}
/>
{option.label}
</label>
);
})}
</div>
);
}
}

Checklist.propTypes = {
/**
* The ID of this component, used to identify dash components
* in callbacks. The ID needs to be unique across all of the
* components in an app.
*/
id: PropTypes.string,

/**
* An array of options
*/
options: PropTypes.arrayOf(
PropTypes.exact({
/**
* The checkbox's label
*/
label: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
.isRequired,

/**
* The value of the checkbox. This value
* corresponds to the items specified in the
* `value` property.
*/
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
.isRequired,

/**
* If true, this checkbox is disabled and can't be clicked on.
*/
disabled: PropTypes.bool,
})
),
options: PropTypes.oneOfType([
/**
* Array of options where the label and the value are the same thing - [string|number|bool]
*/
PropTypes.arrayOf(
PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
PropTypes.bool,
])
),
/**
* Simpler `options` representation in dictionary format. The order is not guaranteed.
* {`value1`: `label1`, `value2`: `label2`, ... }
* which is equal to
* [{label: `label1`, value: `value1`}, {label: `label2`, value: `value2`}, ...]
*/
PropTypes.object,
/**
* An array of options {label: [string|number], value: [string|number]},
* an optional disabled field can be used for each option
*/
PropTypes.arrayOf(
PropTypes.exact({
/**
* The option's label
*/
label: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
PropTypes.bool,
]).isRequired,

/**
* The value of the option. This value
* corresponds to the items specified in the
* `value` property.
*/
value: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
PropTypes.bool,
]).isRequired,

/**
* If true, this option is disabled and cannot be selected.
*/
disabled: PropTypes.bool,

/**
* The HTML 'title' attribute for the option. Allows for
* information on hover. For more information on this attribute,
* see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/title
*/
title: PropTypes.string,
})
),
]),

/**
* The currently selected value
*/
value: PropTypes.arrayOf(
PropTypes.oneOfType([PropTypes.string, PropTypes.number])
PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
PropTypes.bool,
])
),

/**
* The ID of this component, used to identify dash components
* in callbacks. The ID needs to be unique across all of the
* components in an app.
*/
id: PropTypes.string,

/**
* The class of the container (div)
*/
Expand Down Expand Up @@ -187,6 +237,13 @@ Checklist.propTypes = {
* session: window.sessionStorage, data is cleared once the browser quit.
*/
persistence_type: PropTypes.oneOf(['local', 'session', 'memory']),

/**
* Indicates whether labelStyle should be inline or not
* True: Automatically set { 'display': 'inline-block' } to labelStyle
* False: No additional styles are passed into labelStyle.
*/
inline: PropTypes.bool,
};

Checklist.defaultProps = {
Expand All @@ -198,4 +255,5 @@ Checklist.defaultProps = {
value: [],
persisted_props: ['value'],
persistence_type: 'local',
inline: false,
};
105 changes: 68 additions & 37 deletions components/dash-core-components/src/components/Dropdown.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,46 +25,65 @@ export default class Dropdown extends Component {
}

Dropdown.propTypes = {
/**
* The ID of this component, used to identify dash components
* in callbacks. The ID needs to be unique across all of the
* components in an app.
*/
id: PropTypes.string,

/**
* An array of options {label: [string|number], value: [string|number]},
* an optional disabled field can be used for each option
*/
options: PropTypes.arrayOf(
PropTypes.exact({
/**
* The dropdown's label
*/
label: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
.isRequired,

/**
* The value of the dropdown. This value
* corresponds to the items specified in the
* `value` property.
*/
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
.isRequired,

/**
* If true, this option is disabled and cannot be selected.
*/
disabled: PropTypes.bool,

/**
* The HTML 'title' attribute for the option. Allows for
* information on hover. For more information on this attribute,
* see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/title
*/
title: PropTypes.string,
})
),
options: PropTypes.oneOfType([
/**
* Array of options where the label and the value are the same thing - [string|number|bool]
*/
PropTypes.arrayOf(
PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
PropTypes.bool,
])
),
/**
* Simpler `options` representation in dictionary format. The order is not guaranteed.
* {`value1`: `label1`, `value2`: `label2`, ... }
* which is equal to
* [{label: `label1`, value: `value1`}, {label: `label2`, value: `value2`}, ...]
*/
PropTypes.object,
/**
* An array of options {label: [string|number], value: [string|number]},
* an optional disabled field can be used for each option
*/
PropTypes.arrayOf(
PropTypes.exact({
/**
* The option's label
*/
label: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
.isRequired,

/**
* The value of the option. This value
* corresponds to the items specified in the
* `value` property.
*/
value: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
PropTypes.bool,
]).isRequired,

/**
* If true, this option is disabled and cannot be selected.
*/
disabled: PropTypes.bool,

/**
* The HTML 'title' attribute for the option. Allows for
* information on hover. For more information on this attribute,
* see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/title
*/
title: PropTypes.string,
})
),
]),

/**
* The value of the input. If `multi` is false (the default)
Expand All @@ -77,11 +96,23 @@ Dropdown.propTypes = {
value: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
PropTypes.bool,
PropTypes.arrayOf(
PropTypes.oneOfType([PropTypes.string, PropTypes.number])
PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
PropTypes.bool,
])
),
]),

/**
* The ID of this component, used to identify dash components
* in callbacks. The ID needs to be unique across all of the
* components in an app.
*/
id: PropTypes.string,

/**
* height of each option. Can be increased when label lengths would wrap around
*/
Expand Down
Loading