dash-core-components 4.0.0-rc2 → 4.0.0-rc4
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 -2
- 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-mathjax.js +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/dash_core_components/proptypes.js +153 -14
- package/lib/components/Button.tsx +48 -0
- package/lib/components/Clipboard.react.js +1 -1
- package/lib/components/DatePickerRange.tsx +70 -0
- package/lib/components/DatePickerSingle.tsx +72 -0
- package/lib/components/Input.tsx +12 -233
- package/lib/components/RadioItems.tsx +3 -1
- package/lib/components/Tab.tsx +19 -0
- package/lib/components/Tabs.tsx +311 -0
- package/lib/components/css/button.css +55 -0
- package/lib/components/css/calendar.css +66 -0
- package/lib/components/css/datepickers.css +239 -0
- package/lib/components/css/dcc.css +1 -0
- package/lib/components/css/dropdown.css +19 -6
- package/lib/components/css/input.css +9 -3
- package/lib/components/css/sliders.css +41 -1
- package/lib/components/css/tabs.css +113 -0
- package/lib/fragments/DatePickerRange.tsx +448 -0
- package/lib/fragments/DatePickerSingle.tsx +248 -0
- package/lib/fragments/Dropdown.tsx +44 -19
- package/lib/fragments/Graph.react.js +18 -45
- package/lib/fragments/RangeSlider.tsx +24 -66
- package/lib/index.ts +6 -6
- package/lib/types.ts +660 -28
- package/lib/utils/DatePickerPersistence.ts +14 -0
- package/lib/utils/LazyLoader/datePickerRange.ts +4 -0
- package/lib/utils/LazyLoader/datePickerSingle.ts +4 -0
- package/lib/utils/calendar/Calendar.tsx +382 -0
- package/lib/utils/calendar/CalendarDay.tsx +75 -0
- package/lib/utils/calendar/CalendarDayPadding.tsx +15 -0
- package/lib/utils/calendar/CalendarMonth.tsx +247 -0
- package/lib/utils/calendar/CalendarMonthHeader.tsx +23 -0
- package/lib/utils/calendar/createMonthGrid.ts +28 -0
- package/lib/utils/calendar/helpers.ts +272 -0
- package/lib/utils/computeSliderMarkers.ts +71 -116
- package/lib/utils/optionRendering.tsx +22 -15
- package/lib/utils/sliderRendering.tsx +40 -2
- package/package.json +16 -13
- package/lib/components/DatePickerRange.react.js +0 -244
- package/lib/components/DatePickerSingle.react.js +0 -209
- package/lib/components/Dropdown.react.js.old +0 -228
- package/lib/components/Tab.react.js +0 -80
- package/lib/components/Tab.react.js.old +0 -79
- package/lib/components/Tabs.react.js +0 -295
- package/lib/components/Textarea.react.js.old +0 -287
- package/lib/fragments/DatePickerRange.react.js +0 -188
- package/lib/fragments/DatePickerSingle.react.js +0 -132
- package/lib/utils/DatePickerPersistence.js +0 -18
- package/lib/utils/LazyLoader/datePickerRange.js +0 -8
- package/lib/utils/LazyLoader/datePickerSingle.js +0 -8
- package/lib/utils/convertToMoment.js +0 -30
- package/lib/utils/optionTypes.js +0 -39
|
@@ -1,295 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
-
var _ramda = require("ramda");
|
|
10
|
-
var _style = _interopRequireDefault(require("styled-jsx/style"));
|
|
11
|
-
var _LoadingElement = _interopRequireDefault(require("../utils/LoadingElement"));
|
|
12
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
14
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
15
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
16
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
17
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
18
|
-
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
|
|
19
|
-
// see https://github.com/vercel/styled-jsx/pull/716
|
|
20
|
-
// eslint-disable-line no-unused-vars
|
|
21
|
-
// EnhancedTab is defined here instead of in Tab.react.js because if exported there,
|
|
22
|
-
// it will mess up the Python imports and metadata.json
|
|
23
|
-
var EnhancedTab = _ref => {
|
|
24
|
-
var id = _ref.id,
|
|
25
|
-
label = _ref.label,
|
|
26
|
-
selected = _ref.selected,
|
|
27
|
-
className = _ref.className,
|
|
28
|
-
style = _ref.style,
|
|
29
|
-
selectedClassName = _ref.selectedClassName,
|
|
30
|
-
selected_style = _ref.selected_style,
|
|
31
|
-
selectHandler = _ref.selectHandler,
|
|
32
|
-
value = _ref.value,
|
|
33
|
-
_ref$disabled = _ref.disabled,
|
|
34
|
-
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
35
|
-
_ref$disabled_style = _ref.disabled_style,
|
|
36
|
-
disabled_style = _ref$disabled_style === void 0 ? {
|
|
37
|
-
color: '#d6d6d6'
|
|
38
|
-
} : _ref$disabled_style,
|
|
39
|
-
disabled_className = _ref.disabled_className,
|
|
40
|
-
mobile_breakpoint = _ref.mobile_breakpoint,
|
|
41
|
-
amountOfTabs = _ref.amountOfTabs,
|
|
42
|
-
colors = _ref.colors,
|
|
43
|
-
vertical = _ref.vertical,
|
|
44
|
-
componentPath = _ref.componentPath;
|
|
45
|
-
var ctx = window.dash_component_api.useDashContext();
|
|
46
|
-
// We use the raw path here since it's up one level from
|
|
47
|
-
// the tabs child.
|
|
48
|
-
var isLoading = ctx.useLoading({
|
|
49
|
-
rawPath: componentPath
|
|
50
|
-
});
|
|
51
|
-
var tabStyle = style;
|
|
52
|
-
if (disabled) {
|
|
53
|
-
tabStyle = _objectSpread({
|
|
54
|
-
tabStyle
|
|
55
|
-
}, disabled_style);
|
|
56
|
-
}
|
|
57
|
-
if (selected) {
|
|
58
|
-
tabStyle = _objectSpread({
|
|
59
|
-
tabStyle
|
|
60
|
-
}, selected_style);
|
|
61
|
-
}
|
|
62
|
-
var tabClassName = "tab ".concat(className || '');
|
|
63
|
-
if (disabled) {
|
|
64
|
-
tabClassName += " tab--disabled ".concat(disabled_className || '');
|
|
65
|
-
}
|
|
66
|
-
if (selected) {
|
|
67
|
-
tabClassName += " tab--selected ".concat(selectedClassName || '');
|
|
68
|
-
}
|
|
69
|
-
var labelDisplay;
|
|
70
|
-
if ((0, _ramda.is)(Array, label)) {
|
|
71
|
-
// label is an array, so it has children that we want to render
|
|
72
|
-
labelDisplay = label[0].props.children;
|
|
73
|
-
} else {
|
|
74
|
-
// else it is a string, so we just want to render that
|
|
75
|
-
labelDisplay = label;
|
|
76
|
-
}
|
|
77
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
78
|
-
"data-dash-is-loading": isLoading,
|
|
79
|
-
className: tabClassName,
|
|
80
|
-
id: id,
|
|
81
|
-
style: tabStyle,
|
|
82
|
-
onClick: () => {
|
|
83
|
-
if (!disabled) {
|
|
84
|
-
selectHandler(value);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}, /*#__PURE__*/_react.default.createElement("span", null, labelDisplay), /*#__PURE__*/_react.default.createElement("style", {
|
|
88
|
-
jsx: true
|
|
89
|
-
}, "\n .tab {\n display: inline-block;\n background-color: ".concat(colors.background, ";\n border: 1px solid ").concat(colors.border, ";\n border-bottom: none;\n padding: 20px 25px;\n transition: background-color, color 200ms;\n width: 100%;\n text-align: center;\n box-sizing: border-box;\n }\n .tab:last-of-type {\n border-right: 1px solid ").concat(colors.border, ";\n border-bottom: 1px solid ").concat(colors.border, ";\n }\n .tab:hover {\n cursor: pointer;\n }\n .tab--selected {\n border-top: 2px solid ").concat(colors.primary, ";\n color: black;\n background-color: white;\n }\n .tab--selected:hover {\n background-color: white;\n }\n .tab--disabled {\n color: #d6d6d6;\n }\n\n @media screen and (min-width: ").concat(mobile_breakpoint, "px) {\n .tab {\n border: 1px solid ").concat(colors.border, ";\n border-right: none;\n ").concat(vertical ? '' : "width: calc(100% / ".concat(amountOfTabs, ");"), ";\n }\n .tab--selected,\n .tab:last-of-type.tab--selected {\n border-bottom: none;\n ").concat(vertical ? "border-left: 2px solid ".concat(colors.primary, ";") : "border-top: 2px solid ".concat(colors.primary, ";"), ";\n }\n }\n ")));
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* A Dash component that lets you render pages with tabs - the Tabs component's children
|
|
94
|
-
* can be dcc.Tab components, which can hold a label that will be displayed as a tab, and can in turn hold
|
|
95
|
-
* children components that will be that tab's content.
|
|
96
|
-
*/
|
|
97
|
-
class Tabs extends _react.Component {
|
|
98
|
-
constructor(props) {
|
|
99
|
-
super(props);
|
|
100
|
-
this.selectHandler = this.selectHandler.bind(this);
|
|
101
|
-
if (!(0, _ramda.has)('value', this.props)) {
|
|
102
|
-
this.props.setProps({
|
|
103
|
-
value: this.valueOrDefault()
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
valueOrDefault() {
|
|
108
|
-
if ((0, _ramda.has)('value', this.props)) {
|
|
109
|
-
return this.props.value;
|
|
110
|
-
}
|
|
111
|
-
var children = this.parseChildrenToArray();
|
|
112
|
-
if (children && children.length) {
|
|
113
|
-
var firstChildren = window.dash_component_api.getLayout([...children[0].props.componentPath, 'props', 'value']);
|
|
114
|
-
return firstChildren || 'tab-1';
|
|
115
|
-
}
|
|
116
|
-
return 'tab-1';
|
|
117
|
-
}
|
|
118
|
-
parseChildrenToArray() {
|
|
119
|
-
if (this.props.children && !(0, _ramda.is)(Array, this.props.children)) {
|
|
120
|
-
// if dcc.Tabs.children contains just one single element, it gets passed as an object
|
|
121
|
-
// instead of an array - so we put it in an array ourselves!
|
|
122
|
-
return [this.props.children];
|
|
123
|
-
}
|
|
124
|
-
return this.props.children;
|
|
125
|
-
}
|
|
126
|
-
selectHandler(value) {
|
|
127
|
-
this.props.setProps({
|
|
128
|
-
value: value
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
render() {
|
|
132
|
-
var EnhancedTabs;
|
|
133
|
-
var selectedTab;
|
|
134
|
-
var value = this.valueOrDefault();
|
|
135
|
-
if (this.props.children) {
|
|
136
|
-
var children = this.parseChildrenToArray();
|
|
137
|
-
var amountOfTabs = children.length;
|
|
138
|
-
EnhancedTabs = children.map((child, index) => {
|
|
139
|
-
// TODO: handle components that are not dcc.Tab components (throw error)
|
|
140
|
-
// enhance Tab components coming from Dash (as dcc.Tab) with methods needed for handling logic
|
|
141
|
-
var childProps;
|
|
142
|
-
if (/*#__PURE__*/_react.default.isValidElement(child)) {
|
|
143
|
-
childProps = window.dash_component_api.getLayout([...child.props.componentPath, 'props']);
|
|
144
|
-
} else {
|
|
145
|
-
// In case the selected tab is a string.
|
|
146
|
-
childProps = {};
|
|
147
|
-
}
|
|
148
|
-
if (!childProps.value) {
|
|
149
|
-
childProps = _objectSpread(_objectSpread({}, childProps), {}, {
|
|
150
|
-
value: "tab-".concat(index + 1)
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// check if this child/Tab is currently selected
|
|
155
|
-
if (childProps.value === value) {
|
|
156
|
-
selectedTab = child;
|
|
157
|
-
}
|
|
158
|
-
return /*#__PURE__*/_react.default.createElement(EnhancedTab, {
|
|
159
|
-
key: index,
|
|
160
|
-
id: childProps.id,
|
|
161
|
-
label: childProps.label,
|
|
162
|
-
selected: value === childProps.value,
|
|
163
|
-
selectHandler: this.selectHandler,
|
|
164
|
-
className: childProps.className,
|
|
165
|
-
style: childProps.style,
|
|
166
|
-
selectedClassName: childProps.selected_className,
|
|
167
|
-
selected_style: childProps.selected_style,
|
|
168
|
-
value: childProps.value,
|
|
169
|
-
disabled: childProps.disabled,
|
|
170
|
-
disabled_style: childProps.disabled_style,
|
|
171
|
-
disabled_className: childProps.disabled_className,
|
|
172
|
-
mobile_breakpoint: this.props.mobile_breakpoint,
|
|
173
|
-
vertical: this.props.vertical,
|
|
174
|
-
amountOfTabs: amountOfTabs,
|
|
175
|
-
colors: this.props.colors,
|
|
176
|
-
componentPath: child.componentPath
|
|
177
|
-
});
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
var selectedTabContent = !(0, _ramda.isNil)(selectedTab) ? selectedTab : '';
|
|
181
|
-
var tabContainerClass = this.props.vertical ? 'tab-container tab-container--vert' : 'tab-container';
|
|
182
|
-
var tabContentClass = this.props.vertical ? 'tab-content tab-content--vert' : 'tab-content';
|
|
183
|
-
var tabParentClass = this.props.vertical ? 'tab-parent tab-parent--vert' : 'tab-parent';
|
|
184
|
-
return /*#__PURE__*/_react.default.createElement(_LoadingElement.default, {
|
|
185
|
-
className: "".concat(tabParentClass, " ").concat(this.props.parent_className || ''),
|
|
186
|
-
style: this.props.parent_style,
|
|
187
|
-
id: "".concat(this.props.id, "-parent")
|
|
188
|
-
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
189
|
-
className: "".concat(tabContainerClass, " ").concat(this.props.className || ''),
|
|
190
|
-
style: this.props.style,
|
|
191
|
-
id: this.props.id
|
|
192
|
-
}, EnhancedTabs), /*#__PURE__*/_react.default.createElement("div", {
|
|
193
|
-
className: "".concat(tabContentClass, " ").concat(this.props.content_className || ''),
|
|
194
|
-
style: this.props.content_style
|
|
195
|
-
}, selectedTabContent || ''), /*#__PURE__*/_react.default.createElement("style", {
|
|
196
|
-
jsx: true
|
|
197
|
-
}, "\n .tab-parent {\n display: flex;\n flex-direction: column;\n }\n .tab-container {\n display: flex;\n flex-direction: column;\n }\n .tab-container--vert {\n display: inline-flex;\n }\n .tab-content--vert {\n display: inline-flex;\n flex-direction: column;\n }\n @media screen and (min-width: ".concat(this.props.mobile_breakpoint, "px) {\n :global(.tab-container--vert .tab) {\n width: auto;\n border-right: none !important;\n border-bottom: none !important;\n }\n :global(.tab-container--vert .tab:last-of-type) {\n border-bottom: 1px solid ").concat(this.props.colors.border, " !important;\n }\n :global(.tab-container--vert .tab--selected) {\n border-top: 1px solid ").concat(this.props.colors.border, ";\n border-left: 2px solid ").concat(this.props.colors.primary, ";\n border-right: none;\n }\n .tab-container {\n flex-direction: row;\n }\n .tab-container--vert {\n flex-direction: column;\n }\n .tab-parent--vert {\n display: inline-flex;\n flex-direction: row;\n }\n }\n ")));
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
exports.default = Tabs;
|
|
201
|
-
Tabs.defaultProps = {
|
|
202
|
-
mobile_breakpoint: 800,
|
|
203
|
-
colors: {
|
|
204
|
-
border: '#d6d6d6',
|
|
205
|
-
primary: '#1975FA',
|
|
206
|
-
background: '#f9f9f9'
|
|
207
|
-
},
|
|
208
|
-
vertical: false,
|
|
209
|
-
persisted_props: ['value'],
|
|
210
|
-
persistence_type: 'local'
|
|
211
|
-
};
|
|
212
|
-
Tabs.propTypes = {
|
|
213
|
-
/**
|
|
214
|
-
* The ID of this component, used to identify dash components
|
|
215
|
-
* in callbacks. The ID needs to be unique across all of the
|
|
216
|
-
* components in an app.
|
|
217
|
-
*/
|
|
218
|
-
id: _propTypes.default.string,
|
|
219
|
-
/**
|
|
220
|
-
* The value of the currently selected Tab
|
|
221
|
-
*/
|
|
222
|
-
value: _propTypes.default.string,
|
|
223
|
-
/**
|
|
224
|
-
* Appends a class to the Tabs container holding the individual Tab components.
|
|
225
|
-
*/
|
|
226
|
-
className: _propTypes.default.string,
|
|
227
|
-
/**
|
|
228
|
-
* Appends a class to the Tab content container holding the children of the Tab that is selected.
|
|
229
|
-
*/
|
|
230
|
-
content_className: _propTypes.default.string,
|
|
231
|
-
/**
|
|
232
|
-
* Appends a class to the top-level parent container holding both the Tabs container and the content container.
|
|
233
|
-
*/
|
|
234
|
-
parent_className: _propTypes.default.string,
|
|
235
|
-
/**
|
|
236
|
-
* Appends (inline) styles to the Tabs container holding the individual Tab components.
|
|
237
|
-
*/
|
|
238
|
-
style: _propTypes.default.object,
|
|
239
|
-
/**
|
|
240
|
-
* Appends (inline) styles to the top-level parent container holding both the Tabs container and the content container.
|
|
241
|
-
*/
|
|
242
|
-
parent_style: _propTypes.default.object,
|
|
243
|
-
/**
|
|
244
|
-
* Appends (inline) styles to the tab content container holding the children of the Tab that is selected.
|
|
245
|
-
*/
|
|
246
|
-
content_style: _propTypes.default.object,
|
|
247
|
-
/**
|
|
248
|
-
* Renders the tabs vertically (on the side)
|
|
249
|
-
*/
|
|
250
|
-
vertical: _propTypes.default.bool,
|
|
251
|
-
/**
|
|
252
|
-
* Breakpoint at which tabs are rendered full width (can be 0 if you don't want full width tabs on mobile)
|
|
253
|
-
*/
|
|
254
|
-
mobile_breakpoint: _propTypes.default.number,
|
|
255
|
-
/**
|
|
256
|
-
* Array that holds Tab components
|
|
257
|
-
*/
|
|
258
|
-
children: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.node), _propTypes.default.node]),
|
|
259
|
-
/**
|
|
260
|
-
* Holds the colors used by the Tabs and Tab components. If you set these, you should specify colors for all properties, so:
|
|
261
|
-
* colors: {
|
|
262
|
-
* border: '#d6d6d6',
|
|
263
|
-
* primary: '#1975FA',
|
|
264
|
-
* background: '#f9f9f9'
|
|
265
|
-
* }
|
|
266
|
-
*/
|
|
267
|
-
colors: _propTypes.default.exact({
|
|
268
|
-
border: _propTypes.default.string,
|
|
269
|
-
primary: _propTypes.default.string,
|
|
270
|
-
background: _propTypes.default.string
|
|
271
|
-
}),
|
|
272
|
-
/**
|
|
273
|
-
* Used to allow user interactions in this component to be persisted when
|
|
274
|
-
* the component - or the page - is refreshed. If `persisted` is truthy and
|
|
275
|
-
* hasn't changed from its previous value, a `value` that the user has
|
|
276
|
-
* changed while using the app will keep that change, as long as
|
|
277
|
-
* the new `value` also matches what was given originally.
|
|
278
|
-
* Used in conjunction with `persistence_type`.
|
|
279
|
-
*/
|
|
280
|
-
persistence: _propTypes.default.oneOfType([_propTypes.default.bool, _propTypes.default.string, _propTypes.default.number]),
|
|
281
|
-
/**
|
|
282
|
-
* Properties whose user interactions will persist after refreshing the
|
|
283
|
-
* component or the page. Since only `value` is allowed this prop can
|
|
284
|
-
* normally be ignored.
|
|
285
|
-
*/
|
|
286
|
-
persisted_props: _propTypes.default.arrayOf(_propTypes.default.oneOf(['value'])),
|
|
287
|
-
/**
|
|
288
|
-
* Where persisted user changes will be stored:
|
|
289
|
-
* memory: only kept in memory, reset on page refresh.
|
|
290
|
-
* local: window.localStorage, data is kept after the browser quit.
|
|
291
|
-
* session: window.sessionStorage, data is cleared once the browser quit.
|
|
292
|
-
*/
|
|
293
|
-
persistence_type: _propTypes.default.oneOf(['local', 'session', 'memory'])
|
|
294
|
-
};
|
|
295
|
-
Tabs.dashChildrenUpdate = true;
|
|
@@ -1,287 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-unused-vars */
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
import {pick} from 'ramda';
|
|
5
|
-
|
|
6
|
-
const textAreaProps = [
|
|
7
|
-
'id',
|
|
8
|
-
'autoFocus',
|
|
9
|
-
'cols',
|
|
10
|
-
'disabled',
|
|
11
|
-
'form',
|
|
12
|
-
'maxLength',
|
|
13
|
-
'minLength',
|
|
14
|
-
'name',
|
|
15
|
-
'placeholder',
|
|
16
|
-
'readOnly',
|
|
17
|
-
'required',
|
|
18
|
-
'rows',
|
|
19
|
-
'wrap',
|
|
20
|
-
'accessKey',
|
|
21
|
-
'className',
|
|
22
|
-
'contentEditable',
|
|
23
|
-
'contextMenu',
|
|
24
|
-
'dir',
|
|
25
|
-
'draggable',
|
|
26
|
-
'hidden',
|
|
27
|
-
'lang',
|
|
28
|
-
'spellCheck',
|
|
29
|
-
'style',
|
|
30
|
-
'tabIndex',
|
|
31
|
-
'title',
|
|
32
|
-
];
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* A basic HTML textarea for entering multiline text.
|
|
36
|
-
*
|
|
37
|
-
*/
|
|
38
|
-
const Textarea = ({
|
|
39
|
-
setProps,
|
|
40
|
-
value,
|
|
41
|
-
n_blur = 0,
|
|
42
|
-
n_blur_timestamp = -1,
|
|
43
|
-
n_clicks,
|
|
44
|
-
n_clicks_timestamp = -1,
|
|
45
|
-
persisted_props,
|
|
46
|
-
persistence_type,
|
|
47
|
-
...props
|
|
48
|
-
}) => {
|
|
49
|
-
const ctx = window.dash_component_api.useDashContext();
|
|
50
|
-
const isLoading = ctx.useLoading();
|
|
51
|
-
|
|
52
|
-
return (
|
|
53
|
-
<textarea
|
|
54
|
-
data-dash-is-loading={isLoading || undefined}
|
|
55
|
-
value={value}
|
|
56
|
-
onChange={e => {
|
|
57
|
-
setProps({value: e.target.value});
|
|
58
|
-
}}
|
|
59
|
-
onBlur={() => {
|
|
60
|
-
setProps({
|
|
61
|
-
n_blur: n_blur + 1,
|
|
62
|
-
n_blur_timestamp: Date.now(),
|
|
63
|
-
});
|
|
64
|
-
}}
|
|
65
|
-
onClick={() => {
|
|
66
|
-
setProps({
|
|
67
|
-
n_clicks: n_clicks + 1,
|
|
68
|
-
n_clicks_timestamp: Date.now(),
|
|
69
|
-
});
|
|
70
|
-
}}
|
|
71
|
-
{...pick(textAreaProps, props)}
|
|
72
|
-
/>
|
|
73
|
-
);
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
Textarea.dashPersistence = {
|
|
77
|
-
persisted_props: ['value'],
|
|
78
|
-
persistence_type: 'local',
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
Textarea.propTypes = {
|
|
82
|
-
/**
|
|
83
|
-
* The ID of this component, used to identify dash components
|
|
84
|
-
* in callbacks. The ID needs to be unique across all of the
|
|
85
|
-
* components in an app.
|
|
86
|
-
*/
|
|
87
|
-
id: PropTypes.string,
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* The value of the textarea
|
|
91
|
-
*/
|
|
92
|
-
value: PropTypes.string,
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* The element should be automatically focused after the page loaded.
|
|
96
|
-
*/
|
|
97
|
-
autoFocus: PropTypes.string,
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Defines the number of columns in a textarea.
|
|
101
|
-
*/
|
|
102
|
-
cols: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Indicates whether the user can interact with the element.
|
|
106
|
-
*/
|
|
107
|
-
disabled: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Indicates the form that is the owner of the element.
|
|
111
|
-
*/
|
|
112
|
-
form: PropTypes.string,
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Defines the maximum number of characters allowed in the element.
|
|
116
|
-
*/
|
|
117
|
-
maxLength: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Defines the minimum number of characters allowed in the element.
|
|
121
|
-
*/
|
|
122
|
-
minLength: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Name of the element. For example used by the server to identify the fields in form submits.
|
|
126
|
-
*/
|
|
127
|
-
name: PropTypes.string,
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Provides a hint to the user of what can be entered in the field.
|
|
131
|
-
*/
|
|
132
|
-
placeholder: PropTypes.string,
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Indicates whether the element can be edited.
|
|
136
|
-
* readOnly is an HTML boolean attribute - it is enabled by a boolean or
|
|
137
|
-
* 'readOnly'. Alternative capitalizations `readonly` & `READONLY`
|
|
138
|
-
* are also acccepted.
|
|
139
|
-
*/
|
|
140
|
-
readOnly: PropTypes.oneOfType([
|
|
141
|
-
PropTypes.bool,
|
|
142
|
-
PropTypes.oneOf(['readOnly', 'readonly', 'READONLY']),
|
|
143
|
-
]),
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* Indicates whether this element is required to fill out or not.
|
|
147
|
-
* required is an HTML boolean attribute - it is enabled by a boolean or
|
|
148
|
-
* 'required'. Alternative capitalizations `REQUIRED`
|
|
149
|
-
* are also acccepted.
|
|
150
|
-
*/
|
|
151
|
-
required: PropTypes.oneOfType([
|
|
152
|
-
PropTypes.oneOf(['required', 'REQUIRED']),
|
|
153
|
-
PropTypes.bool,
|
|
154
|
-
]),
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Defines the number of rows in a text area.
|
|
158
|
-
*/
|
|
159
|
-
rows: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Indicates whether the text should be wrapped.
|
|
163
|
-
*/
|
|
164
|
-
wrap: PropTypes.string,
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Defines a keyboard shortcut to activate or add focus to the element.
|
|
168
|
-
*/
|
|
169
|
-
accessKey: PropTypes.string,
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Often used with CSS to style elements with common properties.
|
|
173
|
-
*/
|
|
174
|
-
className: PropTypes.string,
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* Indicates whether the element's content is editable.
|
|
178
|
-
*/
|
|
179
|
-
contentEditable: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* Defines the ID of a <menu> element which will serve as the element's context menu.
|
|
183
|
-
*/
|
|
184
|
-
contextMenu: PropTypes.string,
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Defines the text direction. Allowed values are ltr (Left-To-Right) or rtl (Right-To-Left)
|
|
188
|
-
*/
|
|
189
|
-
dir: PropTypes.string,
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Defines whether the element can be dragged.
|
|
193
|
-
*/
|
|
194
|
-
draggable: PropTypes.oneOfType([
|
|
195
|
-
// enumerated property, not a boolean property: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/draggable
|
|
196
|
-
PropTypes.oneOf(['true', 'false']),
|
|
197
|
-
PropTypes.bool,
|
|
198
|
-
]),
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* Prevents rendering of given element, while keeping child elements, e.g. script elements, active.
|
|
202
|
-
*/
|
|
203
|
-
hidden: PropTypes.string,
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* Defines the language used in the element.
|
|
207
|
-
*/
|
|
208
|
-
lang: PropTypes.string,
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* Indicates whether spell checking is allowed for the element.
|
|
212
|
-
*/
|
|
213
|
-
spellCheck: PropTypes.oneOfType([
|
|
214
|
-
// enumerated property, not a boolean property: https://www.w3.org/TR/html51/editing.html#spelling-and-grammar-checking
|
|
215
|
-
PropTypes.oneOf(['true', 'false']),
|
|
216
|
-
PropTypes.bool,
|
|
217
|
-
]),
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* Defines CSS styles which will override styles previously set.
|
|
221
|
-
*/
|
|
222
|
-
style: PropTypes.object,
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* Overrides the browser's default tab order and follows the one specified instead.
|
|
226
|
-
*/
|
|
227
|
-
tabIndex: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
228
|
-
|
|
229
|
-
/**
|
|
230
|
-
* Text to be displayed in a tooltip when hovering over the element.
|
|
231
|
-
*/
|
|
232
|
-
title: PropTypes.string,
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* Number of times the textarea lost focus.
|
|
236
|
-
*/
|
|
237
|
-
n_blur: PropTypes.number,
|
|
238
|
-
/**
|
|
239
|
-
* Last time the textarea lost focus.
|
|
240
|
-
*/
|
|
241
|
-
n_blur_timestamp: PropTypes.number,
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* Number of times the textarea has been clicked.
|
|
245
|
-
*/
|
|
246
|
-
n_clicks: PropTypes.number,
|
|
247
|
-
/**
|
|
248
|
-
* Last time the textarea was clicked.
|
|
249
|
-
*/
|
|
250
|
-
n_clicks_timestamp: PropTypes.number,
|
|
251
|
-
|
|
252
|
-
/**
|
|
253
|
-
* Dash-assigned callback that gets fired when the value changes.
|
|
254
|
-
*/
|
|
255
|
-
setProps: PropTypes.func,
|
|
256
|
-
|
|
257
|
-
/**
|
|
258
|
-
* Used to allow user interactions in this component to be persisted when
|
|
259
|
-
* the component - or the page - is refreshed. If `persisted` is truthy and
|
|
260
|
-
* hasn't changed from its previous value, a `value` that the user has
|
|
261
|
-
* changed while using the app will keep that change, as long as
|
|
262
|
-
* the new `value` also matches what was given originally.
|
|
263
|
-
* Used in conjunction with `persistence_type`.
|
|
264
|
-
*/
|
|
265
|
-
persistence: PropTypes.oneOfType([
|
|
266
|
-
PropTypes.bool,
|
|
267
|
-
PropTypes.string,
|
|
268
|
-
PropTypes.number,
|
|
269
|
-
]),
|
|
270
|
-
|
|
271
|
-
/**
|
|
272
|
-
* Properties whose user interactions will persist after refreshing the
|
|
273
|
-
* component or the page. Since only `value` is allowed this prop can
|
|
274
|
-
* normally be ignored.
|
|
275
|
-
*/
|
|
276
|
-
persisted_props: PropTypes.arrayOf(PropTypes.oneOf(['value'])),
|
|
277
|
-
|
|
278
|
-
/**
|
|
279
|
-
* Where persisted user changes will be stored:
|
|
280
|
-
* memory: only kept in memory, reset on page refresh.
|
|
281
|
-
* local: window.localStorage, data is kept after the browser quit.
|
|
282
|
-
* session: window.sessionStorage, data is cleared once the browser quit.
|
|
283
|
-
*/
|
|
284
|
-
persistence_type: PropTypes.oneOf(['local', 'session', 'memory']),
|
|
285
|
-
};
|
|
286
|
-
|
|
287
|
-
export default Textarea;
|