+
{children}
@@ -151,7 +152,7 @@ const Loading = ({
);
-};
-
-Loading._dashprivate_isLoadingComponent = true;
+}
Loading.propTypes = {
/**
@@ -227,24 +226,6 @@ Loading.propTypes = {
*/
color: PropTypes.string,
- /**
- * Object that holds the loading state object coming from dash-renderer
- */
- loading_state: PropTypes.shape({
- /**
- * Determines if the component is loading or not
- */
- is_loading: PropTypes.bool,
- /**
- * Holds which property is loading
- */
- prop_name: PropTypes.string,
- /**
- * Holds the name of the component that is loading
- */
- component_name: PropTypes.string,
- }),
-
/**
* Setting display to "show" or "hide" will override the loading state coming from dash-renderer
*/
diff --git a/components/dash-core-components/src/components/Markdown.react.js b/components/dash-core-components/src/components/Markdown.react.js
index 322c9d68b8..a2daa0538d 100644
--- a/components/dash-core-components/src/components/Markdown.react.js
+++ b/components/dash-core-components/src/components/Markdown.react.js
@@ -84,24 +84,6 @@ DashMarkdown.propTypes = {
theme: PropTypes.oneOf(['dark', 'light']),
}),
- /**
- * Object that holds the loading state object coming from dash-renderer
- */
- loading_state: PropTypes.shape({
- /**
- * Determines if the component is loading or not
- */
- is_loading: PropTypes.bool,
- /**
- * Holds which property is loading
- */
- prop_name: PropTypes.string,
- /**
- * Holds the name of the component that is loading
- */
- component_name: PropTypes.string,
- }),
-
/**
* User-defined inline styles for the rendered Markdown
*/
diff --git a/components/dash-core-components/src/components/RadioItems.react.js b/components/dash-core-components/src/components/RadioItems.react.js
index a62e2293ff..f7b263d92d 100644
--- a/components/dash-core-components/src/components/RadioItems.react.js
+++ b/components/dash-core-components/src/components/RadioItems.react.js
@@ -2,6 +2,7 @@ import PropTypes from 'prop-types';
import React, {Component} from 'react';
import './css/react-select@1.0.0-rc.3.min.css';
import {sanitizeOptions} from '../utils/optionTypes';
+import LoadingElement from '../utils/LoadingElement';
/**
* RadioItems is a component that encapsulates several radio item inputs.
@@ -22,7 +23,6 @@ export default class RadioItems extends Component {
labelStyle,
options,
setProps,
- loading_state,
value,
inline,
} = this.props;
@@ -32,14 +32,7 @@ export default class RadioItems extends Component {
ids = {id, key: id};
}
return (
-
+
{sanitizeOptions(options).map(option => (
+
);
}
}
@@ -185,24 +178,6 @@ RadioItems.propTypes = {
*/
setProps: PropTypes.func,
- /**
- * Object that holds the loading state object coming from dash-renderer
- */
- loading_state: PropTypes.shape({
- /**
- * Determines if the component is loading or not
- */
- is_loading: PropTypes.bool,
- /**
- * Holds which property is loading
- */
- prop_name: PropTypes.string,
- /**
- * Holds the name of the component that is loading
- */
- component_name: PropTypes.string,
- }),
-
/**
* Used to allow user interactions in this component to be persisted when
* the component - or the page - is refreshed. If `persisted` is truthy and
diff --git a/components/dash-core-components/src/components/RangeSlider.react.js b/components/dash-core-components/src/components/RangeSlider.react.js
index 93dbf015d6..0fe3341379 100644
--- a/components/dash-core-components/src/components/RangeSlider.react.js
+++ b/components/dash-core-components/src/components/RangeSlider.react.js
@@ -190,24 +190,6 @@ RangeSlider.propTypes = {
*/
setProps: PropTypes.func,
- /**
- * Object that holds the loading state object coming from dash-renderer
- */
- loading_state: PropTypes.shape({
- /**
- * Determines if the component is loading or not
- */
- is_loading: PropTypes.bool,
- /**
- * Holds which property is loading
- */
- prop_name: PropTypes.string,
- /**
- * Holds the name of the component that is loading
- */
- component_name: PropTypes.string,
- }),
-
/**
* Used to allow user interactions in this component to be persisted when
* the component - or the page - is refreshed. If `persisted` is truthy and
diff --git a/components/dash-core-components/src/components/Slider.react.js b/components/dash-core-components/src/components/Slider.react.js
index 7e642591c2..2bdfb8e958 100644
--- a/components/dash-core-components/src/components/Slider.react.js
+++ b/components/dash-core-components/src/components/Slider.react.js
@@ -173,24 +173,6 @@ Slider.propTypes = {
*/
setProps: PropTypes.func,
- /**
- * Object that holds the loading state object coming from dash-renderer
- */
- loading_state: PropTypes.shape({
- /**
- * Determines if the component is loading or not
- */
- is_loading: PropTypes.bool,
- /**
- * Holds which property is loading
- */
- prop_name: PropTypes.string,
- /**
- * Holds the name of the component that is loading
- */
- component_name: PropTypes.string,
- }),
-
/**
* Used to allow user interactions in this component to be persisted when
* the component - or the page - is refreshed. If `persisted` is truthy and
diff --git a/components/dash-core-components/src/components/Tab.react.js b/components/dash-core-components/src/components/Tab.react.js
index 1985b884c7..273ea16286 100644
--- a/components/dash-core-components/src/components/Tab.react.js
+++ b/components/dash-core-components/src/components/Tab.react.js
@@ -74,24 +74,6 @@ Tab.propTypes = {
* Overrides the default (inline) styles for the Tab component when it is selected.
*/
selected_style: PropTypes.object,
-
- /**
- * Object that holds the loading state object coming from dash-renderer
- */
- loading_state: PropTypes.shape({
- /**
- * Determines if the component is loading or not
- */
- is_loading: PropTypes.bool,
- /**
- * Holds which property is loading
- */
- prop_name: PropTypes.string,
- /**
- * Holds the name of the component that is loading
- */
- component_name: PropTypes.string,
- }),
};
export default Tab;
diff --git a/components/dash-core-components/src/components/Tabs.react.js b/components/dash-core-components/src/components/Tabs.react.js
index 0857ed1c12..994d1bd410 100644
--- a/components/dash-core-components/src/components/Tabs.react.js
+++ b/components/dash-core-components/src/components/Tabs.react.js
@@ -6,6 +6,7 @@ import {has, is, isNil} from 'ramda';
// some weird interaction btwn styled-jsx 3.4 and babel
// see https://github.com/vercel/styled-jsx/pull/716
import _JSXStyle from 'styled-jsx/style'; // eslint-disable-line no-unused-vars
+import LoadingElement from '../utils/LoadingElement';
// EnhancedTab is defined here instead of in Tab.react.js because if exported there,
// it will mess up the Python imports and metadata.json
@@ -135,8 +136,6 @@ export default class Tabs extends Component {
super(props);
this.selectHandler = this.selectHandler.bind(this);
- this.parseChildrenToArray = this.parseChildrenToArray.bind(this);
- this.valueOrDefault = this.valueOrDefault.bind(this);
if (!has('value', this.props)) {
this.props.setProps({
@@ -150,8 +149,13 @@ export default class Tabs extends Component {
return this.props.value;
}
const children = this.parseChildrenToArray();
- if (children && children[0].props.children) {
- return children[0].props.children.props.value || 'tab-1';
+ if (children && children.length) {
+ const firstChildren = window.dash_clientside.get_layout([
+ ...children[0].props.componentPath,
+ 'props',
+ 'value',
+ ]);
+ return firstChildren || 'tab-1';
}
return 'tab-1';
}
@@ -173,6 +177,8 @@ export default class Tabs extends Component {
let EnhancedTabs;
let selectedTab;
+ const value = this.valueOrDefault();
+
if (this.props.children) {
const children = this.parseChildrenToArray();
@@ -183,20 +189,14 @@ export default class Tabs extends Component {
// enhance Tab components coming from Dash (as dcc.Tab) with methods needed for handling logic
let childProps;
- if (
- // disabled is a defaultProp (so it's always set)
- // meaning that if it's not set on child.props, the actual
- // props we want are lying a bit deeper - which means they
- // are coming from Dash
- isNil(child.props.disabled) &&
- child.props._dashprivate_layout &&
- child.props._dashprivate_layout.props
- ) {
- // props are coming from Dash
- childProps = child.props._dashprivate_layout.props;
+ if (React.isValidElement(child)) {
+ childProps = window.dash_clientside.get_layout([
+ ...child.props.componentPath,
+ 'props',
+ ]);
} else {
- // else props are coming from React (Demo.react.js, or Tabs.test.js)
- childProps = child.props;
+ // In case the selected tab is a string.
+ childProps = {};
}
if (!childProps.value) {
@@ -204,7 +204,7 @@ export default class Tabs extends Component {
}
// check if this child/Tab is currently selected
- if (childProps.value === this.valueOrDefault()) {
+ if (childProps.value === value) {
selectedTab = child;
}
@@ -213,7 +213,7 @@ export default class Tabs extends Component {
key={index}
id={childProps.id}
label={childProps.label}
- selected={this.valueOrDefault() === childProps.value}
+ selected={value === childProps.value}
selectHandler={this.selectHandler}
className={childProps.className}
style={childProps.style}
@@ -248,12 +248,7 @@ export default class Tabs extends Component {
: 'tab-parent';
return (
-
-
+
);
}
}
@@ -412,24 +407,6 @@ Tabs.propTypes = {
background: PropTypes.string,
}),
- /**
- * Object that holds the loading state object coming from dash-renderer
- */
- loading_state: PropTypes.shape({
- /**
- * Determines if the component is loading or not
- */
- is_loading: PropTypes.bool,
- /**
- * Holds which property is loading
- */
- prop_name: PropTypes.string,
- /**
- * Holds the name of the component that is loading
- */
- component_name: PropTypes.string,
- }),
-
/**
* Used to allow user interactions in this component to be persisted when
* the component - or the page - is refreshed. If `persisted` is truthy and
diff --git a/components/dash-core-components/src/components/Tooltip.react.js b/components/dash-core-components/src/components/Tooltip.react.js
index 1d2fcb7b0c..3c5505df43 100644
--- a/components/dash-core-components/src/components/Tooltip.react.js
+++ b/components/dash-core-components/src/components/Tooltip.react.js
@@ -2,6 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import _JSXStyle from 'styled-jsx/style'; // eslint-disable-line no-unused-vars
+import LoadingElement from '../utils/LoadingElement';
/**
* A tooltip with an absolute position.
@@ -17,15 +18,17 @@ const Tooltip = ({
loading_text = 'Loading...',
...props
}) => {
- const {bbox, id, loading_state} = props;
- const is_loading = loading_state?.is_loading;
+ const {bbox, id} = props;
const show_tooltip = show && bbox;
+ const ctx = window.dash_component_api.useDashContext();
+ const is_loading = ctx.useLoading();
+
return (
<>
-
-
+