dash-core-components 2.14.3 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dash_core_components/async-datepicker.js +1 -1
- package/dash_core_components/async-datepicker.js.map +1 -1
- package/dash_core_components/async-dropdown.js +1 -1
- package/dash_core_components/async-dropdown.js.map +1 -1
- package/dash_core_components/async-graph.js +1 -1
- package/dash_core_components/async-graph.js.map +1 -1
- package/dash_core_components/async-markdown.js +1 -1
- package/dash_core_components/async-markdown.js.map +1 -1
- package/dash_core_components/async-slider.js +1 -1
- package/dash_core_components/async-slider.js.map +1 -1
- package/dash_core_components/async-upload.js +1 -1
- package/dash_core_components/async-upload.js.map +1 -1
- package/dash_core_components/dash_core_components-shared.js +1 -1
- package/dash_core_components/dash_core_components-shared.js.map +1 -1
- package/dash_core_components/dash_core_components.js +1 -1
- package/dash_core_components/dash_core_components.js.map +1 -1
- package/lib/components/Checklist.react.js +2 -20
- package/lib/components/Clipboard.react.js +10 -27
- package/lib/components/ConfirmDialogProvider.react.js +12 -31
- package/lib/components/DatePickerRange.react.js +0 -17
- package/lib/components/DatePickerSingle.react.js +0 -17
- package/lib/components/Dropdown.react.js +0 -17
- package/lib/components/Graph.react.js +1 -18
- package/lib/components/Input.react.js +3 -20
- package/lib/components/Link.react.js +3 -2
- package/lib/components/Loading.react.js +105 -114
- package/lib/components/Markdown.react.js +0 -17
- package/lib/components/RadioItems.react.js +2 -21
- package/lib/components/RangeSlider.react.js +0 -17
- package/lib/components/Slider.react.js +0 -17
- package/lib/components/Tab.react.js +1 -18
- package/lib/components/Tabs.react.js +27 -39
- package/lib/components/Textarea.react.js +44 -75
- package/lib/components/Tooltip.react.js +8 -26
- package/lib/components/Upload.react.js +1 -18
- package/lib/fragments/DatePickerRange.react.js +3 -4
- package/lib/fragments/DatePickerSingle.react.js +3 -4
- package/lib/fragments/Dropdown.react.js +3 -2
- package/lib/fragments/Graph.react.js +19 -23
- package/lib/fragments/Loading/spinners/CircleSpinner.js +5 -4
- package/lib/fragments/Loading/spinners/CubeSpinner.js +5 -4
- package/lib/fragments/Loading/spinners/DebugTitle.js +15 -0
- package/lib/fragments/Loading/spinners/DefaultSpinner.js +5 -4
- package/lib/fragments/Loading/spinners/DotSpinner.js +5 -4
- package/lib/fragments/Loading/spinners/GraphSpinner.js +5 -4
- package/lib/fragments/Markdown.react.js +3 -4
- package/lib/fragments/RangeSlider.react.js +2 -3
- package/lib/fragments/Slider.react.js +2 -3
- package/lib/fragments/Upload.react.js +4 -5
- package/lib/index.js +0 -7
- package/lib/utils/LoadingElement.js +39 -0
- package/lib/utils/ResizeDetector.js +52 -0
- package/package.json +3 -7
- package/lib/components/LogoutButton.react.js +0 -135
- package/lib/components/css/logout.css +0 -20
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _ramda = require("ramda");
|
|
8
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
10
|
var _GraphSpinner = _interopRequireDefault(require("../fragments/Loading/spinners/GraphSpinner.jsx"));
|
|
10
11
|
var _DefaultSpinner = _interopRequireDefault(require("../fragments/Loading/spinners/DefaultSpinner.jsx"));
|
|
@@ -34,112 +35,122 @@ var spinnerComponentOptions = {
|
|
|
34
35
|
var getSpinner = function getSpinner(spinnerType) {
|
|
35
36
|
return spinnerComponentOptions[spinnerType] || _DefaultSpinner.default;
|
|
36
37
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
/* Overrides default Loading behavior if target_components is set. By default,
|
|
77
|
-
* Loading fires when any recursive child enters loading state. This makes loading
|
|
78
|
-
* opt-in: Loading animation only enabled when one of target components enters loading state.
|
|
79
|
-
*/
|
|
80
|
-
var isTarget = function isTarget() {
|
|
81
|
-
if (!target_components) {
|
|
82
|
-
return true;
|
|
38
|
+
var coveringSpinner = {
|
|
39
|
+
visibility: 'visible',
|
|
40
|
+
position: 'absolute',
|
|
41
|
+
top: '0',
|
|
42
|
+
height: '100%',
|
|
43
|
+
width: '100%',
|
|
44
|
+
display: 'flex',
|
|
45
|
+
justifyContent: 'center',
|
|
46
|
+
alignItems: 'center'
|
|
47
|
+
};
|
|
48
|
+
var loadingSelector = function loadingSelector(componentPath, targetComponents) {
|
|
49
|
+
return function (state) {
|
|
50
|
+
var stringPath = JSON.stringify(componentPath);
|
|
51
|
+
// Remove the last ] for easy match
|
|
52
|
+
stringPath = stringPath.substring(0, stringPath.length - 1);
|
|
53
|
+
var loadingChildren = (0, _ramda.toPairs)(state.loading).reduce(function (acc, _ref) {
|
|
54
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
55
|
+
path = _ref2[0],
|
|
56
|
+
load = _ref2[1];
|
|
57
|
+
if (path.startsWith(stringPath) && load.length) {
|
|
58
|
+
if (targetComponents && !(0, _ramda.any)(function (l) {
|
|
59
|
+
var target = targetComponents[l.id];
|
|
60
|
+
if (!target) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
if (Array.isArray(target)) {
|
|
64
|
+
return (0, _ramda.includes)(l.property, target);
|
|
65
|
+
}
|
|
66
|
+
return l.property === target;
|
|
67
|
+
}, load)) {
|
|
68
|
+
return acc;
|
|
69
|
+
}
|
|
70
|
+
return (0, _ramda.concat)(acc, load);
|
|
71
|
+
}
|
|
72
|
+
return acc;
|
|
73
|
+
}, []);
|
|
74
|
+
if (loadingChildren.length) {
|
|
75
|
+
return loadingChildren;
|
|
83
76
|
}
|
|
84
|
-
|
|
85
|
-
return Object.entries(target_components).some(function (_ref2) {
|
|
86
|
-
var _ref3 = _slicedToArray(_ref2, 2),
|
|
87
|
-
component_name = _ref3[0],
|
|
88
|
-
prop_names = _ref3[1];
|
|
89
|
-
// Convert prop_names to an array if it's not already
|
|
90
|
-
var prop_names_array = Array.isArray(prop_names) ? prop_names : [prop_names];
|
|
91
|
-
return loading_state.component_name === component_name && (prop_names_array.includes('*') || prop_names_array.some(function (prop_name) {
|
|
92
|
-
return loading_state.prop_name === prop_name;
|
|
93
|
-
}));
|
|
94
|
-
});
|
|
95
|
-
};
|
|
96
|
-
return isMatchingComponent;
|
|
77
|
+
return null;
|
|
97
78
|
};
|
|
79
|
+
};
|
|
80
|
+
function Loading(_ref3) {
|
|
81
|
+
var children = _ref3.children,
|
|
82
|
+
_ref3$display = _ref3.display,
|
|
83
|
+
display = _ref3$display === void 0 ? 'auto' : _ref3$display,
|
|
84
|
+
_ref3$color = _ref3.color,
|
|
85
|
+
color = _ref3$color === void 0 ? '#119DFF' : _ref3$color,
|
|
86
|
+
id = _ref3.id,
|
|
87
|
+
className = _ref3.className,
|
|
88
|
+
style = _ref3.style,
|
|
89
|
+
parent_className = _ref3.parent_className,
|
|
90
|
+
parent_style = _ref3.parent_style,
|
|
91
|
+
overlay_style = _ref3.overlay_style,
|
|
92
|
+
fullscreen = _ref3.fullscreen,
|
|
93
|
+
debug = _ref3.debug,
|
|
94
|
+
_ref3$show_initially = _ref3.show_initially,
|
|
95
|
+
show_initially = _ref3$show_initially === void 0 ? true : _ref3$show_initially,
|
|
96
|
+
spinnerType = _ref3.type,
|
|
97
|
+
_ref3$delay_hide = _ref3.delay_hide,
|
|
98
|
+
delay_hide = _ref3$delay_hide === void 0 ? 0 : _ref3$delay_hide,
|
|
99
|
+
_ref3$delay_show = _ref3.delay_show,
|
|
100
|
+
delay_show = _ref3$delay_show === void 0 ? 0 : _ref3$delay_show,
|
|
101
|
+
target_components = _ref3.target_components,
|
|
102
|
+
custom_spinner = _ref3.custom_spinner;
|
|
103
|
+
var ctx = window.dash_component_api.useDashContext();
|
|
104
|
+
var loading = ctx.useSelector(loadingSelector(ctx.componentPath, target_components), _ramda.equals);
|
|
98
105
|
var _useState = (0, _react.useState)(show_initially),
|
|
99
106
|
_useState2 = _slicedToArray(_useState, 2),
|
|
100
107
|
showSpinner = _useState2[0],
|
|
101
108
|
setShowSpinner = _useState2[1];
|
|
102
109
|
var dismissTimer = (0, _react.useRef)();
|
|
103
110
|
var showTimer = (0, _react.useRef)();
|
|
104
|
-
|
|
105
|
-
|
|
111
|
+
var containerStyle = (0, _react.useMemo)(function () {
|
|
112
|
+
if (showSpinner) {
|
|
113
|
+
return _objectSpread(_objectSpread({
|
|
114
|
+
visibility: 'hidden'
|
|
115
|
+
}, overlay_style), parent_style);
|
|
116
|
+
}
|
|
117
|
+
return parent_style;
|
|
118
|
+
}, [showSpinner, parent_style]);
|
|
106
119
|
(0, _react.useEffect)(function () {
|
|
107
120
|
if (display === 'show' || display === 'hide') {
|
|
108
121
|
setShowSpinner(display === 'show');
|
|
109
122
|
return;
|
|
110
123
|
}
|
|
111
|
-
if (
|
|
112
|
-
if
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}, delay_hide);
|
|
139
|
-
}
|
|
124
|
+
if (loading) {
|
|
125
|
+
// if component is currently loading and there's a dismiss timer active
|
|
126
|
+
// we need to clear it.
|
|
127
|
+
if (dismissTimer.current) {
|
|
128
|
+
dismissTimer.current = clearTimeout(dismissTimer.current);
|
|
129
|
+
}
|
|
130
|
+
// if component is currently loading but the spinner is not showing and
|
|
131
|
+
// there is no timer set to show, then set a timeout to show
|
|
132
|
+
if (!showSpinner && !showTimer.current) {
|
|
133
|
+
showTimer.current = setTimeout(function () {
|
|
134
|
+
setShowSpinner(true);
|
|
135
|
+
showTimer.current = null;
|
|
136
|
+
}, delay_show);
|
|
137
|
+
}
|
|
138
|
+
} else {
|
|
139
|
+
// if component is not currently loading and there's a show timer
|
|
140
|
+
// active we need to clear it
|
|
141
|
+
if (showTimer.current) {
|
|
142
|
+
showTimer.current = clearTimeout(showTimer.current);
|
|
143
|
+
}
|
|
144
|
+
// if component is not currently loading and the spinner is showing and
|
|
145
|
+
// there's no timer set to dismiss it, then set a timeout to hide it
|
|
146
|
+
if (showSpinner && !dismissTimer.current) {
|
|
147
|
+
dismissTimer.current = setTimeout(function () {
|
|
148
|
+
setShowSpinner(false);
|
|
149
|
+
dismissTimer.current = null;
|
|
150
|
+
}, delay_hide);
|
|
140
151
|
}
|
|
141
152
|
}
|
|
142
|
-
}, [delay_hide, delay_show,
|
|
153
|
+
}, [delay_hide, delay_show, loading, display, showSpinner]);
|
|
143
154
|
var Spinner = showSpinner && getSpinner(spinnerType);
|
|
144
155
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
145
156
|
style: _objectSpread({
|
|
@@ -148,22 +159,19 @@ var Loading = function Loading(_ref) {
|
|
|
148
159
|
className: parent_className
|
|
149
160
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
150
161
|
className: parent_className,
|
|
151
|
-
style:
|
|
152
|
-
visibility: 'hidden'
|
|
153
|
-
}, overlay_style), parent_style) : parent_style
|
|
162
|
+
style: containerStyle
|
|
154
163
|
}, children), /*#__PURE__*/_react.default.createElement("div", {
|
|
155
164
|
id: id,
|
|
156
165
|
style: showSpinner ? coveringSpinner : {}
|
|
157
166
|
}, showSpinner && (custom_spinner || /*#__PURE__*/_react.default.createElement(Spinner, {
|
|
158
167
|
className: className,
|
|
159
168
|
style: style,
|
|
160
|
-
status:
|
|
169
|
+
status: loading,
|
|
161
170
|
color: color,
|
|
162
171
|
debug: debug,
|
|
163
172
|
fullscreen: fullscreen
|
|
164
173
|
}))));
|
|
165
|
-
}
|
|
166
|
-
Loading._dashprivate_isLoadingComponent = true;
|
|
174
|
+
}
|
|
167
175
|
Loading.propTypes = {
|
|
168
176
|
/**
|
|
169
177
|
* The ID of this component, used to identify dash components
|
|
@@ -214,23 +222,6 @@ Loading.propTypes = {
|
|
|
214
222
|
* Primary color used for the built-in loading spinners
|
|
215
223
|
*/
|
|
216
224
|
color: _propTypes.default.string,
|
|
217
|
-
/**
|
|
218
|
-
* Object that holds the loading state object coming from dash-renderer
|
|
219
|
-
*/
|
|
220
|
-
loading_state: _propTypes.default.shape({
|
|
221
|
-
/**
|
|
222
|
-
* Determines if the component is loading or not
|
|
223
|
-
*/
|
|
224
|
-
is_loading: _propTypes.default.bool,
|
|
225
|
-
/**
|
|
226
|
-
* Holds which property is loading
|
|
227
|
-
*/
|
|
228
|
-
prop_name: _propTypes.default.string,
|
|
229
|
-
/**
|
|
230
|
-
* Holds the name of the component that is loading
|
|
231
|
-
*/
|
|
232
|
-
component_name: _propTypes.default.string
|
|
233
|
-
}),
|
|
234
225
|
/**
|
|
235
226
|
* Setting display to "show" or "hide" will override the loading state coming from dash-renderer
|
|
236
227
|
*/
|
|
@@ -102,23 +102,6 @@ DashMarkdown.propTypes = {
|
|
|
102
102
|
*/
|
|
103
103
|
theme: _propTypes.default.oneOf(['dark', 'light'])
|
|
104
104
|
}),
|
|
105
|
-
/**
|
|
106
|
-
* Object that holds the loading state object coming from dash-renderer
|
|
107
|
-
*/
|
|
108
|
-
loading_state: _propTypes.default.shape({
|
|
109
|
-
/**
|
|
110
|
-
* Determines if the component is loading or not
|
|
111
|
-
*/
|
|
112
|
-
is_loading: _propTypes.default.bool,
|
|
113
|
-
/**
|
|
114
|
-
* Holds which property is loading
|
|
115
|
-
*/
|
|
116
|
-
prop_name: _propTypes.default.string,
|
|
117
|
-
/**
|
|
118
|
-
* Holds the name of the component that is loading
|
|
119
|
-
*/
|
|
120
|
-
component_name: _propTypes.default.string
|
|
121
|
-
}),
|
|
122
105
|
/**
|
|
123
106
|
* User-defined inline styles for the rendered Markdown
|
|
124
107
|
*/
|
|
@@ -8,6 +8,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
require("./css/react-select@1.0.0-rc.3.min.css");
|
|
10
10
|
var _optionTypes = require("../utils/optionTypes");
|
|
11
|
+
var _LoadingElement = _interopRequireDefault(require("../utils/LoadingElement"));
|
|
11
12
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
12
13
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
13
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -52,7 +53,6 @@ var RadioItems = exports.default = /*#__PURE__*/function (_Component) {
|
|
|
52
53
|
labelStyle = _this$props.labelStyle,
|
|
53
54
|
options = _this$props.options,
|
|
54
55
|
setProps = _this$props.setProps,
|
|
55
|
-
loading_state = _this$props.loading_state,
|
|
56
56
|
value = _this$props.value,
|
|
57
57
|
inline = _this$props.inline;
|
|
58
58
|
var ids = {};
|
|
@@ -62,9 +62,7 @@ var RadioItems = exports.default = /*#__PURE__*/function (_Component) {
|
|
|
62
62
|
key: id
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
66
|
-
"data-dash-is-loading": loading_state && loading_state.is_loading || undefined
|
|
67
|
-
}, ids, {
|
|
65
|
+
return /*#__PURE__*/_react.default.createElement(_LoadingElement.default, _extends({}, ids, {
|
|
68
66
|
className: className,
|
|
69
67
|
style: style
|
|
70
68
|
}), (0, _optionTypes.sanitizeOptions)(options).map(function (option) {
|
|
@@ -177,23 +175,6 @@ RadioItems.propTypes = {
|
|
|
177
175
|
* Dash-assigned callback that gets fired when the value changes.
|
|
178
176
|
*/
|
|
179
177
|
setProps: _propTypes.default.func,
|
|
180
|
-
/**
|
|
181
|
-
* Object that holds the loading state object coming from dash-renderer
|
|
182
|
-
*/
|
|
183
|
-
loading_state: _propTypes.default.shape({
|
|
184
|
-
/**
|
|
185
|
-
* Determines if the component is loading or not
|
|
186
|
-
*/
|
|
187
|
-
is_loading: _propTypes.default.bool,
|
|
188
|
-
/**
|
|
189
|
-
* Holds which property is loading
|
|
190
|
-
*/
|
|
191
|
-
prop_name: _propTypes.default.string,
|
|
192
|
-
/**
|
|
193
|
-
* Holds the name of the component that is loading
|
|
194
|
-
*/
|
|
195
|
-
component_name: _propTypes.default.string
|
|
196
|
-
}),
|
|
197
178
|
/**
|
|
198
179
|
* Used to allow user interactions in this component to be persisted when
|
|
199
180
|
* the component - or the page - is refreshed. If `persisted` is truthy and
|
|
@@ -181,23 +181,6 @@ RangeSlider.propTypes = {
|
|
|
181
181
|
* Dash-assigned callback that gets fired when the value or drag_value changes.
|
|
182
182
|
*/
|
|
183
183
|
setProps: _propTypes.default.func,
|
|
184
|
-
/**
|
|
185
|
-
* Object that holds the loading state object coming from dash-renderer
|
|
186
|
-
*/
|
|
187
|
-
loading_state: _propTypes.default.shape({
|
|
188
|
-
/**
|
|
189
|
-
* Determines if the component is loading or not
|
|
190
|
-
*/
|
|
191
|
-
is_loading: _propTypes.default.bool,
|
|
192
|
-
/**
|
|
193
|
-
* Holds which property is loading
|
|
194
|
-
*/
|
|
195
|
-
prop_name: _propTypes.default.string,
|
|
196
|
-
/**
|
|
197
|
-
* Holds the name of the component that is loading
|
|
198
|
-
*/
|
|
199
|
-
component_name: _propTypes.default.string
|
|
200
|
-
}),
|
|
201
184
|
/**
|
|
202
185
|
* Used to allow user interactions in this component to be persisted when
|
|
203
186
|
* the component - or the page - is refreshed. If `persisted` is truthy and
|
|
@@ -166,23 +166,6 @@ Slider.propTypes = {
|
|
|
166
166
|
* Dash-assigned callback that gets fired when the value or drag_value changes.
|
|
167
167
|
*/
|
|
168
168
|
setProps: _propTypes.default.func,
|
|
169
|
-
/**
|
|
170
|
-
* Object that holds the loading state object coming from dash-renderer
|
|
171
|
-
*/
|
|
172
|
-
loading_state: _propTypes.default.shape({
|
|
173
|
-
/**
|
|
174
|
-
* Determines if the component is loading or not
|
|
175
|
-
*/
|
|
176
|
-
is_loading: _propTypes.default.bool,
|
|
177
|
-
/**
|
|
178
|
-
* Holds which property is loading
|
|
179
|
-
*/
|
|
180
|
-
prop_name: _propTypes.default.string,
|
|
181
|
-
/**
|
|
182
|
-
* Holds the name of the component that is loading
|
|
183
|
-
*/
|
|
184
|
-
component_name: _propTypes.default.string
|
|
185
|
-
}),
|
|
186
169
|
/**
|
|
187
170
|
* Used to allow user interactions in this component to be persisted when
|
|
188
171
|
* the component - or the page - is refreshed. If `persisted` is truthy and
|
|
@@ -76,23 +76,6 @@ Tab.propTypes = {
|
|
|
76
76
|
/**
|
|
77
77
|
* Overrides the default (inline) styles for the Tab component when it is selected.
|
|
78
78
|
*/
|
|
79
|
-
selected_style: _propTypes.default.object
|
|
80
|
-
/**
|
|
81
|
-
* Object that holds the loading state object coming from dash-renderer
|
|
82
|
-
*/
|
|
83
|
-
loading_state: _propTypes.default.shape({
|
|
84
|
-
/**
|
|
85
|
-
* Determines if the component is loading or not
|
|
86
|
-
*/
|
|
87
|
-
is_loading: _propTypes.default.bool,
|
|
88
|
-
/**
|
|
89
|
-
* Holds which property is loading
|
|
90
|
-
*/
|
|
91
|
-
prop_name: _propTypes.default.string,
|
|
92
|
-
/**
|
|
93
|
-
* Holds the name of the component that is loading
|
|
94
|
-
*/
|
|
95
|
-
component_name: _propTypes.default.string
|
|
96
|
-
})
|
|
79
|
+
selected_style: _propTypes.default.object
|
|
97
80
|
};
|
|
98
81
|
var _default = exports.default = Tab;
|
|
@@ -8,9 +8,16 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
var _ramda = require("ramda");
|
|
10
10
|
var _style = _interopRequireDefault(require("styled-jsx/style"));
|
|
11
|
+
var _LoadingElement = _interopRequireDefault(require("../utils/LoadingElement"));
|
|
11
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
13
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
13
14
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
15
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
16
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
17
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
18
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
19
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
20
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
14
21
|
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
15
22
|
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
16
23
|
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
@@ -28,7 +35,6 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
28
35
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /* eslint-disable react/prop-types */ // some weird interaction btwn styled-jsx 3.4 and babel
|
|
29
36
|
// see https://github.com/vercel/styled-jsx/pull/716
|
|
30
37
|
// eslint-disable-line no-unused-vars
|
|
31
|
-
|
|
32
38
|
// EnhancedTab is defined here instead of in Tab.react.js because if exported there,
|
|
33
39
|
// it will mess up the Python imports and metadata.json
|
|
34
40
|
var EnhancedTab = function EnhancedTab(_ref) {
|
|
@@ -52,7 +58,13 @@ var EnhancedTab = function EnhancedTab(_ref) {
|
|
|
52
58
|
amountOfTabs = _ref.amountOfTabs,
|
|
53
59
|
colors = _ref.colors,
|
|
54
60
|
vertical = _ref.vertical,
|
|
55
|
-
|
|
61
|
+
componentPath = _ref.componentPath;
|
|
62
|
+
var ctx = window.dash_component_api.useDashContext();
|
|
63
|
+
// We use the raw path here since it's up one level from
|
|
64
|
+
// the tabs child.
|
|
65
|
+
var isLoading = ctx.useLoading({
|
|
66
|
+
rawPath: componentPath
|
|
67
|
+
});
|
|
56
68
|
var tabStyle = style;
|
|
57
69
|
if (disabled) {
|
|
58
70
|
tabStyle = _objectSpread({
|
|
@@ -80,7 +92,7 @@ var EnhancedTab = function EnhancedTab(_ref) {
|
|
|
80
92
|
labelDisplay = label;
|
|
81
93
|
}
|
|
82
94
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
83
|
-
"data-dash-is-loading":
|
|
95
|
+
"data-dash-is-loading": isLoading,
|
|
84
96
|
className: tabClassName,
|
|
85
97
|
id: id,
|
|
86
98
|
style: tabStyle,
|
|
@@ -112,8 +124,6 @@ var Tabs = exports.default = /*#__PURE__*/function (_Component) {
|
|
|
112
124
|
_classCallCheck(this, Tabs);
|
|
113
125
|
_this = _callSuper(this, Tabs, [props]);
|
|
114
126
|
_this.selectHandler = _this.selectHandler.bind(_this);
|
|
115
|
-
_this.parseChildrenToArray = _this.parseChildrenToArray.bind(_this);
|
|
116
|
-
_this.valueOrDefault = _this.valueOrDefault.bind(_this);
|
|
117
127
|
if (!(0, _ramda.has)('value', _this.props)) {
|
|
118
128
|
_this.props.setProps({
|
|
119
129
|
value: _this.valueOrDefault()
|
|
@@ -129,8 +139,9 @@ var Tabs = exports.default = /*#__PURE__*/function (_Component) {
|
|
|
129
139
|
return this.props.value;
|
|
130
140
|
}
|
|
131
141
|
var children = this.parseChildrenToArray();
|
|
132
|
-
if (children && children
|
|
133
|
-
|
|
142
|
+
if (children && children.length) {
|
|
143
|
+
var firstChildren = window.dash_component_api.getLayout([].concat(_toConsumableArray(children[0].props.componentPath), ['props', 'value']));
|
|
144
|
+
return firstChildren || 'tab-1';
|
|
134
145
|
}
|
|
135
146
|
return 'tab-1';
|
|
136
147
|
}
|
|
@@ -157,6 +168,7 @@ var Tabs = exports.default = /*#__PURE__*/function (_Component) {
|
|
|
157
168
|
var _this2 = this;
|
|
158
169
|
var EnhancedTabs;
|
|
159
170
|
var selectedTab;
|
|
171
|
+
var value = this.valueOrDefault();
|
|
160
172
|
if (this.props.children) {
|
|
161
173
|
var children = this.parseChildrenToArray();
|
|
162
174
|
var amountOfTabs = children.length;
|
|
@@ -164,17 +176,11 @@ var Tabs = exports.default = /*#__PURE__*/function (_Component) {
|
|
|
164
176
|
// TODO: handle components that are not dcc.Tab components (throw error)
|
|
165
177
|
// enhance Tab components coming from Dash (as dcc.Tab) with methods needed for handling logic
|
|
166
178
|
var childProps;
|
|
167
|
-
if (
|
|
168
|
-
|
|
169
|
-
// meaning that if it's not set on child.props, the actual
|
|
170
|
-
// props we want are lying a bit deeper - which means they
|
|
171
|
-
// are coming from Dash
|
|
172
|
-
(0, _ramda.isNil)(child.props.disabled) && child.props._dashprivate_layout && child.props._dashprivate_layout.props) {
|
|
173
|
-
// props are coming from Dash
|
|
174
|
-
childProps = child.props._dashprivate_layout.props;
|
|
179
|
+
if (/*#__PURE__*/_react.default.isValidElement(child)) {
|
|
180
|
+
childProps = window.dash_component_api.getLayout([].concat(_toConsumableArray(child.props.componentPath), ['props']));
|
|
175
181
|
} else {
|
|
176
|
-
//
|
|
177
|
-
childProps =
|
|
182
|
+
// In case the selected tab is a string.
|
|
183
|
+
childProps = {};
|
|
178
184
|
}
|
|
179
185
|
if (!childProps.value) {
|
|
180
186
|
childProps = _objectSpread(_objectSpread({}, childProps), {}, {
|
|
@@ -183,14 +189,14 @@ var Tabs = exports.default = /*#__PURE__*/function (_Component) {
|
|
|
183
189
|
}
|
|
184
190
|
|
|
185
191
|
// check if this child/Tab is currently selected
|
|
186
|
-
if (childProps.value ===
|
|
192
|
+
if (childProps.value === value) {
|
|
187
193
|
selectedTab = child;
|
|
188
194
|
}
|
|
189
195
|
return /*#__PURE__*/_react.default.createElement(EnhancedTab, {
|
|
190
196
|
key: index,
|
|
191
197
|
id: childProps.id,
|
|
192
198
|
label: childProps.label,
|
|
193
|
-
selected:
|
|
199
|
+
selected: value === childProps.value,
|
|
194
200
|
selectHandler: _this2.selectHandler,
|
|
195
201
|
className: childProps.className,
|
|
196
202
|
style: childProps.style,
|
|
@@ -204,7 +210,7 @@ var Tabs = exports.default = /*#__PURE__*/function (_Component) {
|
|
|
204
210
|
vertical: _this2.props.vertical,
|
|
205
211
|
amountOfTabs: amountOfTabs,
|
|
206
212
|
colors: _this2.props.colors,
|
|
207
|
-
|
|
213
|
+
componentPath: child.componentPath
|
|
208
214
|
});
|
|
209
215
|
});
|
|
210
216
|
}
|
|
@@ -212,8 +218,7 @@ var Tabs = exports.default = /*#__PURE__*/function (_Component) {
|
|
|
212
218
|
var tabContainerClass = this.props.vertical ? 'tab-container tab-container--vert' : 'tab-container';
|
|
213
219
|
var tabContentClass = this.props.vertical ? 'tab-content tab-content--vert' : 'tab-content';
|
|
214
220
|
var tabParentClass = this.props.vertical ? 'tab-parent tab-parent--vert' : 'tab-parent';
|
|
215
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
216
|
-
"data-dash-is-loading": this.props.loading_state && this.props.loading_state.is_loading || undefined,
|
|
221
|
+
return /*#__PURE__*/_react.default.createElement(_LoadingElement.default, {
|
|
217
222
|
className: "".concat(tabParentClass, " ").concat(this.props.parent_className || ''),
|
|
218
223
|
style: this.props.parent_style,
|
|
219
224
|
id: "".concat(this.props.id, "-parent")
|
|
@@ -301,23 +306,6 @@ Tabs.propTypes = {
|
|
|
301
306
|
primary: _propTypes.default.string,
|
|
302
307
|
background: _propTypes.default.string
|
|
303
308
|
}),
|
|
304
|
-
/**
|
|
305
|
-
* Object that holds the loading state object coming from dash-renderer
|
|
306
|
-
*/
|
|
307
|
-
loading_state: _propTypes.default.shape({
|
|
308
|
-
/**
|
|
309
|
-
* Determines if the component is loading or not
|
|
310
|
-
*/
|
|
311
|
-
is_loading: _propTypes.default.bool,
|
|
312
|
-
/**
|
|
313
|
-
* Holds which property is loading
|
|
314
|
-
*/
|
|
315
|
-
prop_name: _propTypes.default.string,
|
|
316
|
-
/**
|
|
317
|
-
* Holds the name of the component that is loading
|
|
318
|
-
*/
|
|
319
|
-
component_name: _propTypes.default.string
|
|
320
|
-
}),
|
|
321
309
|
/**
|
|
322
310
|
* Used to allow user interactions in this component to be persisted when
|
|
323
311
|
* the component - or the page - is refreshed. If `persisted` is truthy and
|