dash-core-components 2.14.2 → 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-highlight.js +1 -1
- package/dash_core_components/async-highlight.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 +10 -7
- package/lib/components/Loading.react.js +105 -117
- 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 +15 -25
- package/lib/components/Tabs.react.js +33 -41
- package/lib/components/Textarea.react.js +44 -75
- package/lib/components/Tooltip.react.js +33 -43
- 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 +10 -13
- 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,107 +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
|
-
var isTarget = function isTarget() {
|
|
76
|
-
if (!target_components) {
|
|
77
|
-
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;
|
|
78
76
|
}
|
|
79
|
-
|
|
80
|
-
return Object.entries(target_components).some(function (_ref2) {
|
|
81
|
-
var _ref3 = _slicedToArray(_ref2, 2),
|
|
82
|
-
component_name = _ref3[0],
|
|
83
|
-
prop_names = _ref3[1];
|
|
84
|
-
// Convert prop_names to an array if it's not already
|
|
85
|
-
var prop_names_array = Array.isArray(prop_names) ? prop_names : [prop_names];
|
|
86
|
-
return loading_state.component_name === component_name && (prop_names_array.includes('*') || prop_names_array.some(function (prop_name) {
|
|
87
|
-
return loading_state.prop_name === prop_name;
|
|
88
|
-
}));
|
|
89
|
-
});
|
|
90
|
-
};
|
|
91
|
-
return isMatchingComponent;
|
|
77
|
+
return null;
|
|
92
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);
|
|
93
105
|
var _useState = (0, _react.useState)(show_initially),
|
|
94
106
|
_useState2 = _slicedToArray(_useState, 2),
|
|
95
107
|
showSpinner = _useState2[0],
|
|
96
108
|
setShowSpinner = _useState2[1];
|
|
97
109
|
var dismissTimer = (0, _react.useRef)();
|
|
98
110
|
var showTimer = (0, _react.useRef)();
|
|
99
|
-
|
|
100
|
-
|
|
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]);
|
|
101
119
|
(0, _react.useEffect)(function () {
|
|
102
120
|
if (display === 'show' || display === 'hide') {
|
|
103
121
|
setShowSpinner(display === 'show');
|
|
104
122
|
return;
|
|
105
123
|
}
|
|
106
|
-
if (
|
|
107
|
-
if
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}, delay_hide);
|
|
134
|
-
}
|
|
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);
|
|
135
151
|
}
|
|
136
152
|
}
|
|
137
|
-
}, [delay_hide, delay_show,
|
|
153
|
+
}, [delay_hide, delay_show, loading, display, showSpinner]);
|
|
138
154
|
var Spinner = showSpinner && getSpinner(spinnerType);
|
|
139
155
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
140
156
|
style: _objectSpread({
|
|
@@ -143,30 +159,19 @@ var Loading = function Loading(_ref) {
|
|
|
143
159
|
className: parent_className
|
|
144
160
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
145
161
|
className: parent_className,
|
|
146
|
-
style:
|
|
147
|
-
visibility: 'hidden'
|
|
148
|
-
}, overlay_style), parent_style) : parent_style
|
|
162
|
+
style: containerStyle
|
|
149
163
|
}, children), /*#__PURE__*/_react.default.createElement("div", {
|
|
150
164
|
id: id,
|
|
151
165
|
style: showSpinner ? coveringSpinner : {}
|
|
152
166
|
}, showSpinner && (custom_spinner || /*#__PURE__*/_react.default.createElement(Spinner, {
|
|
153
167
|
className: className,
|
|
154
168
|
style: style,
|
|
155
|
-
status:
|
|
169
|
+
status: loading,
|
|
156
170
|
color: color,
|
|
157
171
|
debug: debug,
|
|
158
172
|
fullscreen: fullscreen
|
|
159
173
|
}))));
|
|
160
|
-
}
|
|
161
|
-
Loading._dashprivate_isLoadingComponent = true;
|
|
162
|
-
Loading.defaultProps = {
|
|
163
|
-
type: 'default',
|
|
164
|
-
color: '#119DFF',
|
|
165
|
-
delay_show: 0,
|
|
166
|
-
delay_hide: 0,
|
|
167
|
-
show_initially: true,
|
|
168
|
-
display: 'auto'
|
|
169
|
-
};
|
|
174
|
+
}
|
|
170
175
|
Loading.propTypes = {
|
|
171
176
|
/**
|
|
172
177
|
* The ID of this component, used to identify dash components
|
|
@@ -217,23 +222,6 @@ Loading.propTypes = {
|
|
|
217
222
|
* Primary color used for the built-in loading spinners
|
|
218
223
|
*/
|
|
219
224
|
color: _propTypes.default.string,
|
|
220
|
-
/**
|
|
221
|
-
* Object that holds the loading state object coming from dash-renderer
|
|
222
|
-
*/
|
|
223
|
-
loading_state: _propTypes.default.shape({
|
|
224
|
-
/**
|
|
225
|
-
* Determines if the component is loading or not
|
|
226
|
-
*/
|
|
227
|
-
is_loading: _propTypes.default.bool,
|
|
228
|
-
/**
|
|
229
|
-
* Holds which property is loading
|
|
230
|
-
*/
|
|
231
|
-
prop_name: _propTypes.default.string,
|
|
232
|
-
/**
|
|
233
|
-
* Holds the name of the component that is loading
|
|
234
|
-
*/
|
|
235
|
-
component_name: _propTypes.default.string
|
|
236
|
-
}),
|
|
237
225
|
/**
|
|
238
226
|
* Setting display to "show" or "hide" will override the loading state coming from dash-renderer
|
|
239
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
|
|
@@ -13,10 +13,23 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
13
13
|
* Part of dcc.Tabs - this is the child Tab component used to render a tabbed page.
|
|
14
14
|
* Its children will be set as the content of that tab, which if clicked will become visible.
|
|
15
15
|
*/
|
|
16
|
+
|
|
17
|
+
/* eslint-disable no-unused-vars */
|
|
16
18
|
var Tab = function Tab(_ref) {
|
|
17
|
-
var children = _ref.children
|
|
19
|
+
var children = _ref.children,
|
|
20
|
+
_ref$disabled = _ref.disabled,
|
|
21
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
22
|
+
_ref$disabled_style = _ref.disabled_style,
|
|
23
|
+
disabled_style = _ref$disabled_style === void 0 ? {
|
|
24
|
+
color: '#d6d6d6'
|
|
25
|
+
} : _ref$disabled_style;
|
|
18
26
|
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, children);
|
|
19
27
|
};
|
|
28
|
+
/* eslint-enable no-unused-vars */
|
|
29
|
+
|
|
30
|
+
// Default props are defined above for proper docstring generation in React 18.
|
|
31
|
+
// The actual default values are set in Tabs.react.js.
|
|
32
|
+
|
|
20
33
|
Tab.propTypes = {
|
|
21
34
|
/**
|
|
22
35
|
* The ID of this component, used to identify dash components
|
|
@@ -63,29 +76,6 @@ Tab.propTypes = {
|
|
|
63
76
|
/**
|
|
64
77
|
* Overrides the default (inline) styles for the Tab component when it is selected.
|
|
65
78
|
*/
|
|
66
|
-
selected_style: _propTypes.default.object
|
|
67
|
-
/**
|
|
68
|
-
* Object that holds the loading state object coming from dash-renderer
|
|
69
|
-
*/
|
|
70
|
-
loading_state: _propTypes.default.shape({
|
|
71
|
-
/**
|
|
72
|
-
* Determines if the component is loading or not
|
|
73
|
-
*/
|
|
74
|
-
is_loading: _propTypes.default.bool,
|
|
75
|
-
/**
|
|
76
|
-
* Holds which property is loading
|
|
77
|
-
*/
|
|
78
|
-
prop_name: _propTypes.default.string,
|
|
79
|
-
/**
|
|
80
|
-
* Holds the name of the component that is loading
|
|
81
|
-
*/
|
|
82
|
-
component_name: _propTypes.default.string
|
|
83
|
-
})
|
|
84
|
-
};
|
|
85
|
-
Tab.defaultProps = {
|
|
86
|
-
disabled: false,
|
|
87
|
-
disabled_style: {
|
|
88
|
-
color: '#d6d6d6'
|
|
89
|
-
}
|
|
79
|
+
selected_style: _propTypes.default.object
|
|
90
80
|
};
|
|
91
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) {
|
|
@@ -41,14 +47,24 @@ var EnhancedTab = function EnhancedTab(_ref) {
|
|
|
41
47
|
selected_style = _ref.selected_style,
|
|
42
48
|
selectHandler = _ref.selectHandler,
|
|
43
49
|
value = _ref.value,
|
|
44
|
-
disabled = _ref.disabled,
|
|
45
|
-
|
|
50
|
+
_ref$disabled = _ref.disabled,
|
|
51
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
52
|
+
_ref$disabled_style = _ref.disabled_style,
|
|
53
|
+
disabled_style = _ref$disabled_style === void 0 ? {
|
|
54
|
+
color: '#d6d6d6'
|
|
55
|
+
} : _ref$disabled_style,
|
|
46
56
|
disabled_className = _ref.disabled_className,
|
|
47
57
|
mobile_breakpoint = _ref.mobile_breakpoint,
|
|
48
58
|
amountOfTabs = _ref.amountOfTabs,
|
|
49
59
|
colors = _ref.colors,
|
|
50
60
|
vertical = _ref.vertical,
|
|
51
|
-
|
|
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
|
+
});
|
|
52
68
|
var tabStyle = style;
|
|
53
69
|
if (disabled) {
|
|
54
70
|
tabStyle = _objectSpread({
|
|
@@ -76,7 +92,7 @@ var EnhancedTab = function EnhancedTab(_ref) {
|
|
|
76
92
|
labelDisplay = label;
|
|
77
93
|
}
|
|
78
94
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
79
|
-
"data-dash-is-loading":
|
|
95
|
+
"data-dash-is-loading": isLoading,
|
|
80
96
|
className: tabClassName,
|
|
81
97
|
id: id,
|
|
82
98
|
style: tabStyle,
|
|
@@ -108,8 +124,6 @@ var Tabs = exports.default = /*#__PURE__*/function (_Component) {
|
|
|
108
124
|
_classCallCheck(this, Tabs);
|
|
109
125
|
_this = _callSuper(this, Tabs, [props]);
|
|
110
126
|
_this.selectHandler = _this.selectHandler.bind(_this);
|
|
111
|
-
_this.parseChildrenToArray = _this.parseChildrenToArray.bind(_this);
|
|
112
|
-
_this.valueOrDefault = _this.valueOrDefault.bind(_this);
|
|
113
127
|
if (!(0, _ramda.has)('value', _this.props)) {
|
|
114
128
|
_this.props.setProps({
|
|
115
129
|
value: _this.valueOrDefault()
|
|
@@ -125,8 +139,9 @@ var Tabs = exports.default = /*#__PURE__*/function (_Component) {
|
|
|
125
139
|
return this.props.value;
|
|
126
140
|
}
|
|
127
141
|
var children = this.parseChildrenToArray();
|
|
128
|
-
if (children && children
|
|
129
|
-
|
|
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';
|
|
130
145
|
}
|
|
131
146
|
return 'tab-1';
|
|
132
147
|
}
|
|
@@ -153,6 +168,7 @@ var Tabs = exports.default = /*#__PURE__*/function (_Component) {
|
|
|
153
168
|
var _this2 = this;
|
|
154
169
|
var EnhancedTabs;
|
|
155
170
|
var selectedTab;
|
|
171
|
+
var value = this.valueOrDefault();
|
|
156
172
|
if (this.props.children) {
|
|
157
173
|
var children = this.parseChildrenToArray();
|
|
158
174
|
var amountOfTabs = children.length;
|
|
@@ -160,17 +176,11 @@ var Tabs = exports.default = /*#__PURE__*/function (_Component) {
|
|
|
160
176
|
// TODO: handle components that are not dcc.Tab components (throw error)
|
|
161
177
|
// enhance Tab components coming from Dash (as dcc.Tab) with methods needed for handling logic
|
|
162
178
|
var childProps;
|
|
163
|
-
if (
|
|
164
|
-
|
|
165
|
-
// meaning that if it's not set on child.props, the actual
|
|
166
|
-
// props we want are lying a bit deeper - which means they
|
|
167
|
-
// are coming from Dash
|
|
168
|
-
(0, _ramda.isNil)(child.props.disabled) && child.props._dashprivate_layout && child.props._dashprivate_layout.props) {
|
|
169
|
-
// props are coming from Dash
|
|
170
|
-
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']));
|
|
171
181
|
} else {
|
|
172
|
-
//
|
|
173
|
-
childProps =
|
|
182
|
+
// In case the selected tab is a string.
|
|
183
|
+
childProps = {};
|
|
174
184
|
}
|
|
175
185
|
if (!childProps.value) {
|
|
176
186
|
childProps = _objectSpread(_objectSpread({}, childProps), {}, {
|
|
@@ -179,14 +189,14 @@ var Tabs = exports.default = /*#__PURE__*/function (_Component) {
|
|
|
179
189
|
}
|
|
180
190
|
|
|
181
191
|
// check if this child/Tab is currently selected
|
|
182
|
-
if (childProps.value ===
|
|
192
|
+
if (childProps.value === value) {
|
|
183
193
|
selectedTab = child;
|
|
184
194
|
}
|
|
185
195
|
return /*#__PURE__*/_react.default.createElement(EnhancedTab, {
|
|
186
196
|
key: index,
|
|
187
197
|
id: childProps.id,
|
|
188
198
|
label: childProps.label,
|
|
189
|
-
selected:
|
|
199
|
+
selected: value === childProps.value,
|
|
190
200
|
selectHandler: _this2.selectHandler,
|
|
191
201
|
className: childProps.className,
|
|
192
202
|
style: childProps.style,
|
|
@@ -200,7 +210,7 @@ var Tabs = exports.default = /*#__PURE__*/function (_Component) {
|
|
|
200
210
|
vertical: _this2.props.vertical,
|
|
201
211
|
amountOfTabs: amountOfTabs,
|
|
202
212
|
colors: _this2.props.colors,
|
|
203
|
-
|
|
213
|
+
componentPath: child.componentPath
|
|
204
214
|
});
|
|
205
215
|
});
|
|
206
216
|
}
|
|
@@ -208,8 +218,7 @@ var Tabs = exports.default = /*#__PURE__*/function (_Component) {
|
|
|
208
218
|
var tabContainerClass = this.props.vertical ? 'tab-container tab-container--vert' : 'tab-container';
|
|
209
219
|
var tabContentClass = this.props.vertical ? 'tab-content tab-content--vert' : 'tab-content';
|
|
210
220
|
var tabParentClass = this.props.vertical ? 'tab-parent tab-parent--vert' : 'tab-parent';
|
|
211
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
212
|
-
"data-dash-is-loading": this.props.loading_state && this.props.loading_state.is_loading || undefined,
|
|
221
|
+
return /*#__PURE__*/_react.default.createElement(_LoadingElement.default, {
|
|
213
222
|
className: "".concat(tabParentClass, " ").concat(this.props.parent_className || ''),
|
|
214
223
|
style: this.props.parent_style,
|
|
215
224
|
id: "".concat(this.props.id, "-parent")
|
|
@@ -297,23 +306,6 @@ Tabs.propTypes = {
|
|
|
297
306
|
primary: _propTypes.default.string,
|
|
298
307
|
background: _propTypes.default.string
|
|
299
308
|
}),
|
|
300
|
-
/**
|
|
301
|
-
* Object that holds the loading state object coming from dash-renderer
|
|
302
|
-
*/
|
|
303
|
-
loading_state: _propTypes.default.shape({
|
|
304
|
-
/**
|
|
305
|
-
* Determines if the component is loading or not
|
|
306
|
-
*/
|
|
307
|
-
is_loading: _propTypes.default.bool,
|
|
308
|
-
/**
|
|
309
|
-
* Holds which property is loading
|
|
310
|
-
*/
|
|
311
|
-
prop_name: _propTypes.default.string,
|
|
312
|
-
/**
|
|
313
|
-
* Holds the name of the component that is loading
|
|
314
|
-
*/
|
|
315
|
-
component_name: _propTypes.default.string
|
|
316
|
-
}),
|
|
317
309
|
/**
|
|
318
310
|
* Used to allow user interactions in this component to be persisted when
|
|
319
311
|
* the component - or the page - is refreshed. If `persisted` is truthy and
|