-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Shorthand supports for dash-core-components #1763
Conversation
* update Checklist, Dropdown, RangeSlider to accept optional shorthands * update Checklist, RadioItems - added inline props and shorthand options data, update DataTable - params order changed for shorthand support, added TODO * fill component id if not given * fix Dropdown props to accept array of string * remove comments * fix lint issues * generating seed for component id * lint fix in dash-table * lint fix * remove inline props and lint fix * broken eslint 😬 * prettier fix * set random id inside dash dependency * lint fixes * bug fix * add inline styling support * fix bugs * add column populating in dash-table * disable restricting dependency type * fix radio options type check * add comments to inline props * add tests for shorthands * remove unused imports * remove tests, refactor assign * use ramda.type instead of typeof * backup commit * add auto generating marks to RangeSlider & Slider * add number support for shorthanded options - Checklist, Dropdown * some refactor to get react-docgen working, slider props re-arrange * fix unit test - remove outdated part * update props comment Co-authored-by: Chris Parmer <chris@plot.ly> * fix feedback comments * fix some issues in Checklist, DataTable props * pylint fix * Apply suggestions from code review Co-authored-by: Chris Parmer <chris@plot.ly> * copy paste ProTypes to get doc-gen working * Test Slider and RangeSlider shorthand properties * Test Dropdown shorthand properties * Remove unnecessary imports * random seed moved out to global scope, the test for set_random_id was implemented * fix slider markers - respect steps given * assert comparision is fixed * fix slider issues * Add dropdown option sanitization to some additional required places * Convert labels to strings when an Ojbect is passed as options * Add more variants to Dropdown shorthand test * Extend Slider tests * Add test for Dropdown array value type * fix: update inline description & style * chore: pass black format * chore: react doc-gen fix & flake fix * chore: rename test file names to avoid conflict * Handle undefined options in Dropdown * fix: the case when truncated out input marks handled * fix: correct step calculations implemented for sliders * fix: removed Start and End prefix / suffix from labels on Slider * chore: add labels to dropdown tests * chore: lint fix * fix: dropdown options for test * chore: prettier 😪 * bump dash-renderer to v1.11.0 This new version is not important for most dash users, only dash-embedded, and they get the renderer elsewhere; but as is there's a mismatch between the local and CDN versions of the renderer * fix: removed a test file which was causing percy tests fail * fix: defining emptiness of dictionary implemented correctly, which fixes the disappearing of explicitely given marks * fix: omit 'step' from props * chore: update props description * chore: remove unnecessary prop type checker * fix: range slider test corrected, formatted to have some margins * fix: the test_ddsh001_dropdown_shorthand_properties test restored back and the DropDowns propTypes are fixed * fix: added bool type to CheckList label/value and RadioItem label/value * fix: the edited JS files are reformatted using lint * feat: implemented SI Units format for unit values of slider * feat: added tests to cover slider SI Units format for unit values * chore: eslint fix * fix: the test adopted to propsTypes which now accepts bool for several components * fix: slider numbers whose ten factor is less than 3 and bigger than -3 are not formatted, so that they can have floating numebrs * fix: lint issue fixed * fix: explicit null prevents auto generating marks in sliders * fix: add snapshot for set_auto_id dependency link and asserts * fix: test marks=None and SI units format * fix: test_persistence - give step=1 to expect integer value output, otherwise 0.1 will be auto assigned * fix: checking RadioItems and Checklist to accept new propTypes added in tests Co-authored-by: workaholicpanda <> Co-authored-by: Chris Parmer <chris@plot.ly> Co-authored-by: Szabolcs Markó <akksi@akksi.eu> Co-authored-by: alexcjohnson <alex@plot.ly>
ChangelogDash and Dash Renderer
Dash Core ComponentsRearranged Keyword Arguments & Flexible Types
Before: dcc.Dropdown(
options=[
{'label': 'New York', 'value': 'New York'},
{'label': 'Montreal', 'value': 'Montreal'},
],
value='New York'
) or dcc.Dropdown(
options=[
{'label': 'New York', 'value': 'NYC'},
{'label': 'Montreal', 'value': 'MTL'},
],
value='New York'
) After: dcc.Dropdown(['New York', 'Montreal'], 'New York') Or dcc.Dropdown({'NYC': 'New York', 'MTL': 'Montreal'}, 'New York')
Before: dcc.Slider(marks={1: 2, 2: 2, 3: 3}) After: dcc.Slider(min=1, max=3, step=1) Or equivalently: dcc.Slider(1, 3, 1) Step can also be omitted and the dcc.Slider(0, 100) The SI units used in
Before: dash_table.DataTable(data=df.to_dict('records'), columns=[{'name': i, 'id': i} for i in df.columns]) After: dash_table.DataTable(data=df.to_dict('records')) New Component Properties
|
components/dash-core-components/tests/integration/sliders/test_sliders_shorthands.py
Outdated
Show resolved
Hide resolved
…_sliders_shorthands.py Co-authored-by: Chris Parmer <chris@plot.ly>
Co-authored-by: Chris Parmer <chris@plot.ly>
… RangeSlider, lint issues fixed
… Slider, RangeSlider, lint issues fixed" This reverts commit a363691.
…r, RangeSlider, tests updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💃🏼 Great work! Let's do it.
(this PR replaces PR #1747 with one squashed commit)
Implements this issue to support optional shorthand supports for below components.
You can compare old format and new format.
Dependency Update
Input
Output
State
can now accept component object as well as string value of the component keyUpdated Components with change notes
Dropdown
options
props can now be passed without being a keyword argumentoptions
can now accept array of string as well as previous format (array of dictionary)RangeSlider
min
max
step
Checklist
options
props becomes first argument, can be passed without keywordinline
props to specify ifoptions
are array of string or dictionary (previous format)RadioItems
options
props becomes first argument, can be passed without keywordinline
props to specify ifoptions
are array of string or dictionary (previous format)DataTable
data
andcolumns
props becomes first 2 arguments, can be passed without keywordcolumns
automatically from givendata