Skip to content

Commit abc05fb

Browse files
author
Shammamah Hossain
authored
Use dash generate components (#67)
* Update styled-components, webpack, and babel-loader. * Remove builder and use dash-generate-components. * Add webpack config. * Update bundle location and .eslintignore. * Remove old build artefacts. * Fix tests. Change shallow mount to full mount; call render(); check props and not state of components. * Split exponentials and regular digits for PrecisionInput test. * Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps. * Add default value for required precision prop in PrecisionInput. * Comply with prop type for min in GraduatedBar test. * Comply with prop type for secondary in Indicator component. * Add jest-canvas-mock for Chrome colorpicker. See: hustcc/jest-canvas-mock#2 (comment) * Update requirements. * Move jest-canvas-mock to dev dependencies. * Update CHANGELOG. * Update version in package.json. * Add back build artifacts.
1 parent c2071e3 commit abc05fb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+16277
-9511
lines changed

.babelrc

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
{
2-
"extends": "./node_modules/dash-components-archetype/config/babel/babelrc"
2+
"presets": [["@babel/preset-env", {
3+
"useBuiltIns": "usage",
4+
"corejs": 3
5+
}], "@babel/preset-react"]
36
}

.builderrc

-3
This file was deleted.

.eslintignore

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ build/
22
coverage/
33
dist/
44
lib/
5-
lib/bundle.js*
5+
lib/*.js*
66
node_modules/
77
dash_daq/metadata.json
8-
dash_daq/bundle.js*
9-
inst/deps/bundle.js*
8+
dash_daq/*.js*
9+
inst/deps/*.js*
10+
webpack.config.js
1011
.npm
1112
vv/
1213
venv/

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ The format is based on [Keep a
66
Changelog](http://keepachangelog.com/en/1.0.0/) and this project
77
adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
88

9+
## [0.2.2] - 2019-10-04
10+
11+
### Fixed
12+
* Fixed ThemeProvider warning by updating `styled-components` to `v4.4.0`.
13+
914
## [0.2.1] - 2019-09-24
1015

1116
### Fixed

DESCRIPTION

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
Package: dashDaq
22
Title: DAQ components for Dash
3-
Version: 0.1.5
3+
Version: 0.2.2
44
Authors @R: as.person(c(The Plotly Team <[email protected]>))
55
Description: DAQ components for Dash
66
Depends: R (>= 3.0.2)
7-
Imports: dash
7+
Imports:
88
Suggests:
99
License: MIT + file LICENSE
1010
URL: https://github.com/plotly/dash-daq

MANIFEST.in

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
include dash_daq/bundle.js
2-
include dash_daq/bundle.js.map
1+
include dash_daq/dash_daq.min.js
2+
include dash_daq/dash_daq.min.js.map
33
include dash_daq/metadata.json
44
include dash_daq/[email protected]
55
include dash_daq/package-info.json

NAMESPACE

-2
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,3 @@ export(daqStopButton)
1717
export(daqTank)
1818
export(daqThermometer)
1919
export(daqToggleSwitch)
20-
21-
import(dash)

R/daqTank.R

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# AUTO GENERATED FILE - DO NOT EDIT
22

3-
daqTank <- function(id=NULL, value=NULL, size=NULL, color=NULL, min=NULL, max=NULL, base=NULL, logarithmic=NULL, showCurrentValue=NULL, units=NULL, label=NULL, labelPosition=NULL, scale=NULL, className=NULL, style=NULL) {
3+
daqTank <- function(id=NULL, value=NULL, height=NULL, width=NULL, color=NULL, min=NULL, max=NULL, base=NULL, logarithmic=NULL, showCurrentValue=NULL, units=NULL, label=NULL, labelPosition=NULL, scale=NULL, className=NULL, style=NULL) {
44

5-
props <- list(id=id, value=value, size=size, color=color, min=min, max=max, base=base, logarithmic=logarithmic, showCurrentValue=showCurrentValue, units=units, label=label, labelPosition=labelPosition, scale=scale, className=className, style=style)
5+
props <- list(id=id, value=value, height=height, width=width, color=color, min=min, max=max, base=base, logarithmic=logarithmic, showCurrentValue=showCurrentValue, units=units, label=label, labelPosition=labelPosition, scale=scale, className=className, style=style)
66
if (length(props) > 0) {
77
props <- props[!vapply(props, is.null, logical(1))]
88
}
99
component <- list(
1010
props = props,
1111
type = 'Tank',
1212
namespace = 'dash_daq',
13-
propNames = c('id', 'value', 'size', 'color', 'min', 'max', 'base', 'logarithmic', 'showCurrentValue', 'units', 'label', 'labelPosition', 'scale', 'className', 'style'),
13+
propNames = c('id', 'value', 'height', 'width', 'color', 'min', 'max', 'base', 'logarithmic', 'showCurrentValue', 'units', 'label', 'labelPosition', 'scale', 'className', 'style'),
1414
package = 'dashDaq'
1515
)
1616

R/daqThermometer.R

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# AUTO GENERATED FILE - DO NOT EDIT
22

3-
daqThermometer <- function(id=NULL, value=NULL, size=NULL, color=NULL, min=NULL, max=NULL, base=NULL, logarithmic=NULL, showCurrentValue=NULL, units=NULL, theme=NULL, label=NULL, labelPosition=NULL, scale=NULL, className=NULL, style=NULL) {
3+
daqThermometer <- function(id=NULL, value=NULL, height=NULL, width=NULL, color=NULL, min=NULL, max=NULL, base=NULL, logarithmic=NULL, showCurrentValue=NULL, units=NULL, theme=NULL, label=NULL, labelPosition=NULL, scale=NULL, className=NULL, style=NULL) {
44

5-
props <- list(id=id, value=value, size=size, color=color, min=min, max=max, base=base, logarithmic=logarithmic, showCurrentValue=showCurrentValue, units=units, theme=theme, label=label, labelPosition=labelPosition, scale=scale, className=className, style=style)
5+
props <- list(id=id, value=value, height=height, width=width, color=color, min=min, max=max, base=base, logarithmic=logarithmic, showCurrentValue=showCurrentValue, units=units, theme=theme, label=label, labelPosition=labelPosition, scale=scale, className=className, style=style)
66
if (length(props) > 0) {
77
props <- props[!vapply(props, is.null, logical(1))]
88
}
99
component <- list(
1010
props = props,
1111
type = 'Thermometer',
1212
namespace = 'dash_daq',
13-
propNames = c('id', 'value', 'size', 'color', 'min', 'max', 'base', 'logarithmic', 'showCurrentValue', 'units', 'theme', 'label', 'labelPosition', 'scale', 'className', 'style'),
13+
propNames = c('id', 'value', 'height', 'width', 'color', 'min', 'max', 'base', 'logarithmic', 'showCurrentValue', 'units', 'theme', 'label', 'labelPosition', 'scale', 'className', 'style'),
1414
package = 'dashDaq'
1515
)
1616

R/internal.R

+2-19
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,9 @@
11
.dashDaq_js_metadata <- function() {
22
deps_metadata <- list(`dash_daq` = structure(list(name = "dash_daq",
3-
version = "0.1.5", src = list(href = NULL,
3+
version = "0.2.2", src = list(href = NULL,
44
file = "deps"), meta = NULL,
5-
script = 'bundle.js',
5+
script = 'dash_daq.min.js',
66
stylesheet = NULL, head = NULL, attachment = NULL, package = "dashDaq",
77
all_files = FALSE), class = "html_dependency"))
88
return(deps_metadata)
99
}
10-
11-
dash_assert_valid_wildcards <- function (attrib = list("data", "aria"), ...)
12-
{
13-
args <- list(...)
14-
validation_results <- lapply(names(args), function(x) {
15-
grepl(paste0("^", attrib, "-[a-zA-Z0-9]{1,}$", collapse = "|"),
16-
x)
17-
})
18-
if (FALSE %in% validation_results) {
19-
stop(sprintf("The following wildcards are not currently valid in Dash: '%s'",
20-
paste(names(args)[grepl(FALSE, unlist(validation_results))],
21-
collapse = ", ")), call. = FALSE)
22-
}
23-
else {
24-
return(args)
25-
}
26-
}

dash_daq/BooleanSwitch.py

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# AUTO GENERATED FILE - DO NOT EDIT
2+
3+
from dash.development.base_component import Component, _explicitize_args
4+
5+
6+
class BooleanSwitch(Component):
7+
"""A BooleanSwitch component.
8+
A switch component that toggles
9+
between on and off.
10+
11+
Keyword arguments:
12+
- id (string; optional): The ID used to identify this compnent in Dash callbacks
13+
- on (boolean; default False): Whether or not the switch is on
14+
- color (string; optional): Color to highlight active switch background
15+
- vertical (boolean; default False): If true, switch will be vertical instead
16+
of horizontal
17+
- disabled (boolean; optional): If true, switch cannot be clicked
18+
- theme (dict; default light): Theme configuration to be set by a ThemeProvider
19+
- label (dict; optional): Description to be displayed alongside the control. To control styling,
20+
pass an object with label and style properties. label has the following type: string | dict containing keys 'style', 'label'.
21+
Those keys have the following types:
22+
- style (dict; optional)
23+
- label (string; optional)
24+
- labelPosition (a value equal to: 'top', 'bottom'; default 'top'): Where the component label is positioned.
25+
- className (string; optional): Class to apply to the root component element.
26+
- style (dict; optional): Style to apply to the root object."""
27+
@_explicitize_args
28+
def __init__(self, id=Component.UNDEFINED, on=Component.UNDEFINED, color=Component.UNDEFINED, vertical=Component.UNDEFINED, disabled=Component.UNDEFINED, theme=Component.UNDEFINED, label=Component.UNDEFINED, labelPosition=Component.UNDEFINED, className=Component.UNDEFINED, style=Component.UNDEFINED, **kwargs):
29+
self._prop_names = ['id', 'on', 'color', 'vertical', 'disabled', 'theme', 'label', 'labelPosition', 'className', 'style']
30+
self._type = 'BooleanSwitch'
31+
self._namespace = 'dash_daq'
32+
self._valid_wildcard_attributes = []
33+
self.available_properties = ['id', 'on', 'color', 'vertical', 'disabled', 'theme', 'label', 'labelPosition', 'className', 'style']
34+
self.available_wildcard_properties = []
35+
36+
_explicit_args = kwargs.pop('_explicit_args')
37+
_locals = locals()
38+
_locals.update(kwargs) # For wildcard attrs
39+
args = {k: _locals[k] for k in _explicit_args if k != 'children'}
40+
41+
for k in []:
42+
if k not in args:
43+
raise TypeError(
44+
'Required argument `' + k + '` was not specified.')
45+
super(BooleanSwitch, self).__init__(**args)

dash_daq/ColorPicker.py

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# AUTO GENERATED FILE - DO NOT EDIT
2+
3+
from dash.development.base_component import Component, _explicitize_args
4+
5+
6+
class ColorPicker(Component):
7+
"""A ColorPicker component.
8+
A color picker.
9+
10+
Keyword arguments:
11+
- id (string; optional): The ID used to identify the color picker in Dash callbacks
12+
- value (dict; optional): Color value of the picker. value has the following type: dict containing keys 'hex', 'rbg'.
13+
Those keys have the following types:
14+
- hex (string; optional): Hex string
15+
- rbg (dict; optional): RGB/RGBA object. rbg has the following type: dict containing keys 'r', 'g', 'b', 'a'.
16+
Those keys have the following types:
17+
- r (number; optional)
18+
- g (number; optional)
19+
- b (number; optional)
20+
- a (number; optional)
21+
- disabled (boolean; optional): If true, color cannot be picked.
22+
- size (number; default 225): Size (width) of the component in pixels
23+
- theme (dict; default light): Theme configuration to be set by a ThemeProvider
24+
- label (dict; optional): Description to be displayed alongside the control. To control styling,
25+
pass an object with label and style properties. label has the following type: string | dict containing keys 'style', 'label'.
26+
Those keys have the following types:
27+
- style (dict; optional)
28+
- label (string; optional)
29+
- labelPosition (a value equal to: 'top', 'bottom'; default 'top'): Where the indicator label is positioned
30+
- className (string; optional): Class to apply to the root component element
31+
- style (dict; optional): Style to apply to the root component element"""
32+
@_explicitize_args
33+
def __init__(self, id=Component.UNDEFINED, value=Component.UNDEFINED, disabled=Component.UNDEFINED, size=Component.UNDEFINED, theme=Component.UNDEFINED, label=Component.UNDEFINED, labelPosition=Component.UNDEFINED, className=Component.UNDEFINED, style=Component.UNDEFINED, **kwargs):
34+
self._prop_names = ['id', 'value', 'disabled', 'size', 'theme', 'label', 'labelPosition', 'className', 'style']
35+
self._type = 'ColorPicker'
36+
self._namespace = 'dash_daq'
37+
self._valid_wildcard_attributes = []
38+
self.available_properties = ['id', 'value', 'disabled', 'size', 'theme', 'label', 'labelPosition', 'className', 'style']
39+
self.available_wildcard_properties = []
40+
41+
_explicit_args = kwargs.pop('_explicit_args')
42+
_locals = locals()
43+
_locals.update(kwargs) # For wildcard attrs
44+
args = {k: _locals[k] for k in _explicit_args if k != 'children'}
45+
46+
for k in []:
47+
if k not in args:
48+
raise TypeError(
49+
'Required argument `' + k + '` was not specified.')
50+
super(ColorPicker, self).__init__(**args)

dash_daq/DarkThemeProvider.py

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# AUTO GENERATED FILE - DO NOT EDIT
2+
3+
from dash.development.base_component import Component, _explicitize_args
4+
5+
6+
class DarkThemeProvider(Component):
7+
"""A DarkThemeProvider component.
8+
DarkThemeProvider is a component that is placed at the root of
9+
the component tree to make all components match the dark theme
10+
11+
Keyword arguments:
12+
- children (list of a list of or a singular dash component, string or numbers | a list of or a singular dash component, string or number; optional): The children of this component
13+
- theme (dict; optional): Theme object to override with a custom theme. theme has the following type: dict containing keys 'primary', 'secondary', 'detail', 'dark'.
14+
Those keys have the following types:
15+
- primary (string; optional): Highlight color
16+
- secondary (string; optional): Supporting color
17+
- detail (string; optional): Color used for UI details, like borders
18+
- dark (boolean; optional): True for Dark mode, false for Light"""
19+
@_explicitize_args
20+
def __init__(self, children=None, theme=Component.UNDEFINED, **kwargs):
21+
self._prop_names = ['children', 'theme']
22+
self._type = 'DarkThemeProvider'
23+
self._namespace = 'dash_daq'
24+
self._valid_wildcard_attributes = []
25+
self.available_properties = ['children', 'theme']
26+
self.available_wildcard_properties = []
27+
28+
_explicit_args = kwargs.pop('_explicit_args')
29+
_locals = locals()
30+
_locals.update(kwargs) # For wildcard attrs
31+
args = {k: _locals[k] for k in _explicit_args if k != 'children'}
32+
33+
for k in []:
34+
if k not in args:
35+
raise TypeError(
36+
'Required argument `' + k + '` was not specified.')
37+
super(DarkThemeProvider, self).__init__(children=children, **args)

dash_daq/Gauge.py

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# AUTO GENERATED FILE - DO NOT EDIT
2+
3+
from dash.development.base_component import Component, _explicitize_args
4+
5+
6+
class Gauge(Component):
7+
"""A Gauge component.
8+
A Gauge component that points to
9+
a value between some range.
10+
11+
Keyword arguments:
12+
- id (string; optional): The ID used to identify this compnent in Dash callbacks
13+
- value (number; optional): The value of gauge. If logarithmic, the displayed
14+
value will be the logarithm of the inputted value.
15+
- size (number; optional): The size (diameter) of the gauge in pixels
16+
- min (number; default 0): The minimum value of the gauge. If logarithmic,
17+
represents the minimum exponent.
18+
- max (number; default 10): The maximum value of the gauge. If logarithmic,
19+
represents the maximum exponent.
20+
- base (number; default 10): Base to be used in logarithmic scale.
21+
- logarithmic (boolean; optional): If set to true, a logarithmic scale will be
22+
used.
23+
- showCurrentValue (boolean; optional): If true, the current value of the gauge
24+
will be displayed
25+
- units (string; optional): Label for the current value
26+
- theme (dict; default light): Theme configuration to be set by a ThemeProvider
27+
- label (dict; optional): Description to be displayed alongside the control. To control styling, pass an object with label and style properties. label has the following type: string | dict containing keys 'style', 'label'.
28+
Those keys have the following types:
29+
- style (dict; optional)
30+
- label (string; optional)
31+
- labelPosition (a value equal to: 'top', 'bottom'; default 'top'): Where the component label is positioned.
32+
- scale (dict; optional): Configuration for the component scale. scale has the following type: dict containing keys 'start', 'interval', 'labelInterval', 'custom'.
33+
Those keys have the following types:
34+
- start (number; optional): Value to start the scale from. Defaults
35+
to min.
36+
- interval (number; optional): Interval by which the scale goes up. Attempts
37+
to dynamically divide min-max range by
38+
default.
39+
- labelInterval (number; optional): Interval by which labels are added to
40+
scale marks. Defaults to 2 (every other
41+
mark has a label).
42+
- custom (dict; optional): Custom scale marks. The key determines the position
43+
and the value determines what will show. If you want
44+
to set the style of a specific mark point, the value
45+
should be an object which contains style and label
46+
properties. custom has the following type: number | dict containing keys 'style', 'label'.
47+
Those keys have the following types:
48+
- style (string; optional)
49+
- label (string; optional)
50+
- color (dict; optional): Color configuration for the gauge's track. color has the following type: string | dict containing keys 'default', 'gradient', 'ranges'.
51+
Those keys have the following types:
52+
- default (string; optional): Color used for current value text and other minor accents
53+
- gradient (boolean; optional): Display ranges as a gradient between given colors.
54+
- ranges (dict; optional): Define multiple color ranges on the gauge's track.
55+
The key determines the color of the range and
56+
the value is the start,end of the range itself.
57+
Ranges must be contiguous along the entirety
58+
of the gauge's range of values. ranges has the following type: dict containing keys 'color'.
59+
Those keys have the following types:
60+
- color (list of numbers; optional)
61+
- className (string; optional): Class to apply to the root component element.
62+
- style (dict; optional): Style to apply to the root component element."""
63+
@_explicitize_args
64+
def __init__(self, id=Component.UNDEFINED, value=Component.UNDEFINED, size=Component.UNDEFINED, min=Component.UNDEFINED, max=Component.UNDEFINED, base=Component.UNDEFINED, logarithmic=Component.UNDEFINED, showCurrentValue=Component.UNDEFINED, units=Component.UNDEFINED, theme=Component.UNDEFINED, label=Component.UNDEFINED, labelPosition=Component.UNDEFINED, scale=Component.UNDEFINED, color=Component.UNDEFINED, className=Component.UNDEFINED, style=Component.UNDEFINED, **kwargs):
65+
self._prop_names = ['id', 'value', 'size', 'min', 'max', 'base', 'logarithmic', 'showCurrentValue', 'units', 'theme', 'label', 'labelPosition', 'scale', 'color', 'className', 'style']
66+
self._type = 'Gauge'
67+
self._namespace = 'dash_daq'
68+
self._valid_wildcard_attributes = []
69+
self.available_properties = ['id', 'value', 'size', 'min', 'max', 'base', 'logarithmic', 'showCurrentValue', 'units', 'theme', 'label', 'labelPosition', 'scale', 'color', 'className', 'style']
70+
self.available_wildcard_properties = []
71+
72+
_explicit_args = kwargs.pop('_explicit_args')
73+
_locals = locals()
74+
_locals.update(kwargs) # For wildcard attrs
75+
args = {k: _locals[k] for k in _explicit_args if k != 'children'}
76+
77+
for k in []:
78+
if k not in args:
79+
raise TypeError(
80+
'Required argument `' + k + '` was not specified.')
81+
super(Gauge, self).__init__(**args)

0 commit comments

Comments
 (0)