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

3.1 issue143 props typing #158

Merged
merged 7 commits into from
Oct 23, 2018
Merged

Conversation

Marc-Andre-Rivet
Copy link
Contributor

@Marc-Andre-Rivet Marc-Andre-Rivet commented Oct 22, 2018

For #143.

  • improve external facing props types

    • columns
    • data_timestamp
    • setProps
    • required props
  • improve internal facing props types

    • dropdown props

PropTypes.number
]),
hidden: PropTypes.bool,
id: PropTypes.string.isRequired,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only the id is required

Copy link
Member

Choose a reason for hiding this comment

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

what happens if name isn't supplied? I think we should make both id and name required to force our users to supply both and standardize on a convention

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We currently revert to 'id' when there is no name

@@ -99,7 +121,7 @@ export const propTypes = {
row_selectable: PropTypes.oneOf(['single', 'multi', false]),
selected_cell: PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.number)),
selected_rows: PropTypes.arrayOf(PropTypes.number),
setProps: PropTypes.any,
setProps: PropTypes.func,
start_cell: PropTypes.arrayOf(PropTypes.number),
style_as_list_view: PropTypes.bool,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

dropdown_properties can not be typed better as it is a lightweight dictionary object for columns.

value: PropTypes.oneOfType([
PropTypes.number,
PropTypes.string
])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The only dropdown values that make sense at the moment are strings and numbers. We may expand on that later.

type?: ColumnType;
}

interface IDatumObject {
[key: string]: any;
}

interface IDropdownValue {
label: string;
value: string | number;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Matching props dropdown value typing

@chriddyp chriddyp temporarily deployed to dash-table-review-pr-158 October 22, 2018 21:16 Inactive
@@ -77,7 +77,32 @@ export const defaultProps = {

export const propTypes = {
active_cell: PropTypes.array,
columns: PropTypes.arrayOf(PropTypes.object),
columns: PropTypes.arrayOf(PropTypes.shape({
clearable: PropTypes.bool,
Copy link
Member

Choose a reason for hiding this comment

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

could we add docstrings to all of these as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. I'll create another issue, mark it as P1, and link it to the example below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here #163

columns: PropTypes.arrayOf(PropTypes.object),
columns: PropTypes.arrayOf(PropTypes.shape({
clearable: PropTypes.bool,
deletable: PropTypes.oneOfType([
Copy link
Member

@chriddyp chriddyp Oct 23, 2018

Choose a reason for hiding this comment

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

For example:

/**
 * If True, the user can delete the column by clicking on a little `x` button on the
 * column.
 * If there are multi-header columns (via setting `name` to an array of strings)
 * with merged column headers, then you can choose which column header row
 * to display the "x" in by supplying a column row index. For example, `0` will
 * display the "x" on the first row, `1` on the second row. If the "x" appears on
 * a merged column, then deleting the column will delete all of the merged columns
 * associated with it.
 */

@chriddyp chriddyp temporarily deployed to dash-table-review-pr-158 October 23, 2018 15:41 Inactive
@chriddyp chriddyp temporarily deployed to dash-table-review-pr-158 October 23, 2018 15:43 Inactive
selector: PropTypes.string,
rule: PropTypes.string
selector: PropTypes.string.isRequired,
rule: PropTypes.string.isRequired
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added 'isRequired' to nested props that absolutely need to be present

Copy link
Contributor

@valentijnnieman valentijnnieman left a comment

Choose a reason for hiding this comment

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

Looks good to me, not approving so that @chriddyp can continue discussing name prop if he wants

@chriddyp chriddyp temporarily deployed to dash-table-review-pr-158 October 23, 2018 19:51 Inactive
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants