Skip to content

Commit 3c1bda0

Browse files
committed
Update default props
1 parent c847882 commit 3c1bda0

File tree

6 files changed

+40
-55
lines changed

6 files changed

+40
-55
lines changed

components/dash-core-components/src/components/Link.react.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ CustomEvent.prototype = window.Event.prototype;
3232
* For links with destinations outside the current app, `html.A` is a better
3333
* component to use.
3434
*/
35-
const Link = props => {
35+
const Link = ({refresh = false, ...props}) => {
3636
const {
3737
className,
3838
style,
@@ -42,7 +42,6 @@ const Link = props => {
4242
children,
4343
title,
4444
target,
45-
refresh,
4645
setProps,
4746
} = props;
4847
const cleanUrl = window.dash_clientside.clean_url;
@@ -155,7 +154,4 @@ Link.propTypes = {
155154
setProps: PropTypes.func,
156155
};
157156

158-
Link.defaultProps = {
159-
refresh: false,
160-
};
161157
export default Link;

components/dash-core-components/src/components/Loading.react.js

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ const getSpinner = spinnerType =>
2222
const Loading = ({
2323
children,
2424
loading_state,
25-
display,
26-
color,
25+
display = 'auto',
26+
color = '#119DFF',
2727
id,
2828
className,
2929
style,
@@ -32,10 +32,10 @@ const Loading = ({
3232
overlay_style,
3333
fullscreen,
3434
debug,
35-
show_initially,
35+
show_initially = true,
3636
type: spinnerType,
37-
delay_hide,
38-
delay_show,
37+
delay_hide = 0,
38+
delay_show = 0,
3939
target_components,
4040
custom_spinner,
4141
}) => {
@@ -164,15 +164,6 @@ const Loading = ({
164164

165165
Loading._dashprivate_isLoadingComponent = true;
166166

167-
Loading.defaultProps = {
168-
type: 'default',
169-
color: '#119DFF',
170-
delay_show: 0,
171-
delay_hide: 0,
172-
show_initially: true,
173-
display: 'auto',
174-
};
175-
176167
Loading.propTypes = {
177168
/**
178169
* The ID of this component, used to identify dash components

components/dash-core-components/src/components/Tab.react.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,17 @@ import PropTypes from 'prop-types';
55
* Part of dcc.Tabs - this is the child Tab component used to render a tabbed page.
66
* Its children will be set as the content of that tab, which if clicked will become visible.
77
*/
8-
const Tab = ({children}) => <Fragment>{children}</Fragment>;
8+
9+
/* eslint-disable no-unused-vars */
10+
const Tab = ({
11+
children,
12+
disabled = false,
13+
disabled_style = {color: '#d6d6d6'},
14+
}) => <Fragment>{children}</Fragment>;
15+
/* eslint-enable no-unused-vars */
16+
17+
// Default props are defined above for proper docstring generation in React 18.
18+
// The actual default values are set in Tabs.react.js.
919

1020
Tab.propTypes = {
1121
/**
@@ -84,11 +94,4 @@ Tab.propTypes = {
8494
}),
8595
};
8696

87-
Tab.defaultProps = {
88-
disabled: false,
89-
disabled_style: {
90-
color: '#d6d6d6',
91-
},
92-
};
93-
9497
export default Tab;

components/dash-core-components/src/components/Tabs.react.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ const EnhancedTab = ({
1919
selected_style,
2020
selectHandler,
2121
value,
22-
disabled,
23-
disabled_style,
22+
disabled = false,
23+
disabled_style = {color: '#d6d6d6'},
2424
disabled_className,
2525
mobile_breakpoint,
2626
amountOfTabs,

components/dash-core-components/src/components/Tooltip.react.js

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,35 @@ import _JSXStyle from 'styled-jsx/style'; // eslint-disable-line no-unused-vars
66
/**
77
* A tooltip with an absolute position.
88
*/
9-
const Tooltip = props => {
10-
const {bbox, border_color, background_color, id, loading_state} = props;
9+
const Tooltip = ({
10+
show = true,
11+
targetable = false,
12+
direction = 'right',
13+
border_color = '#d6d6d6',
14+
background_color = 'white',
15+
className = '',
16+
zindex = 1,
17+
loading_text = 'Loading...',
18+
...props
19+
}) => {
20+
const {bbox, id, loading_state} = props;
1121
const is_loading = loading_state?.is_loading;
12-
const show = props.show && bbox;
22+
const show_tooltip = show && bbox;
1323

1424
return (
1525
<>
1626
<div className="dcc-tooltip-bounding-box">
1727
<span
1828
data-dash-is-loading={is_loading || undefined}
19-
className={`hover hover-${props.direction}`}
29+
className={`hover hover-${direction}`}
2030
>
2131
<span
2232
id={id}
23-
className={`hover-content ${props.className}`}
33+
className={`hover-content ${className}`}
2434
style={props.style}
2535
>
2636
{is_loading ? (
27-
<span>{props.loading_text}</span>
37+
<span>{loading_text}</span>
2838
) : (
2939
props.children
3040
)}
@@ -38,8 +48,8 @@ const Tooltip = props => {
3848
left: ${bbox?.x0 || 0}px;
3949
width: ${bbox?.x1 - bbox?.x0 || 0}px;
4050
height: ${bbox?.y1 - bbox?.y0 || 0}px;
41-
display: ${show ? 'inline-block' : 'none'};
42-
pointer-events: ${props.targetable ? 'auto' : 'none'};
51+
display: ${show_tooltip ? 'inline-block' : 'none'};
52+
pointer-events: ${targetable ? 'auto' : 'none'};
4353
}
4454
.hover {
4555
position: absolute;
@@ -70,7 +80,7 @@ const Tooltip = props => {
7080
padding: 5px 10px;
7181
background: ${background_color};
7282
white-space: nowrap;
73-
z-index: ${props.zindex};
83+
z-index: ${zindex};
7484
pointer-events: none;
7585
}
7686
.hover .hover-content,
@@ -95,7 +105,7 @@ const Tooltip = props => {
95105
position: absolute;
96106
border-style: solid;
97107
top: -6px;
98-
z-index: ${props.zindex};
108+
z-index: ${zindex};
99109
}
100110
.hover:before,
101111
.hover:after,
@@ -167,17 +177,6 @@ const Tooltip = props => {
167177
);
168178
};
169179

170-
Tooltip.defaultProps = {
171-
show: true,
172-
targetable: false,
173-
direction: 'right',
174-
border_color: '#d6d6d6',
175-
background_color: 'white',
176-
className: '',
177-
zindex: 1,
178-
loading_text: 'Loading...',
179-
};
180-
181180
Tooltip.propTypes = {
182181
/**
183182
* The contents of the tooltip

components/dash-html-components/scripts/generate-components.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ ${customImport}
298298
* For detailed attribute info see:
299299
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/${element}
300300
*/
301-
const ${Component} = (props) => {
301+
const ${Component} = ({n_clicks = 0, n_clicks_timestamp = -1, ...props}) => {
302302
const extraProps = {};
303303
if(props.loading_state && props.loading_state.is_loading) {
304304
extraProps['data-dash-is-loading'] = true;
@@ -322,10 +322,6 @@ ${customCode}
322322
);
323323
};
324324
325-
${Component}.defaultProps = {
326-
n_clicks: 0,
327-
n_clicks_timestamp: -1,
328-
};
329325
330326
${Component}.propTypes = {${propTypes}
331327
};

0 commit comments

Comments
 (0)