dash-core-components 4.1.0 → 4.3.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 +2 -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 +1 -0
- package/lib/components/Clipboard.react.js +220 -126
- package/lib/components/ConfirmDialog.react.js +62 -35
- package/lib/components/ConfirmDialogProvider.react.js +45 -22
- package/lib/components/Download.react.js +46 -24
- package/lib/components/Geolocation.react.js +92 -64
- package/lib/components/Graph.react.js +112 -75
- package/lib/components/Input.tsx +2 -2
- package/lib/components/Interval.react.js +88 -57
- package/lib/components/Link.react.js +16 -18
- package/lib/components/Location.react.js +127 -101
- package/lib/components/Markdown.react.js +43 -15
- package/lib/components/Store.react.js +177 -131
- package/lib/components/Upload.react.js +28 -8
- package/lib/components/css/dropdown.css +6 -0
- package/lib/components/css/sliders.css +1 -0
- package/lib/fragments/DatePickerRange.tsx +147 -148
- package/lib/fragments/DatePickerSingle.tsx +115 -116
- package/lib/fragments/Dropdown.tsx +42 -2
- package/lib/fragments/Graph.privateprops.js +9 -3
- package/lib/fragments/Graph.react.js +418 -322
- package/lib/fragments/Markdown.react.js +163 -112
- package/lib/fragments/Math.react.js +49 -24
- package/lib/fragments/Upload.react.js +344 -220
- package/lib/types.ts +7 -0
- package/lib/utils/LazyLoader/graph.js +3 -2
- package/lib/utils/LazyLoader/hljs.js +5 -2
- package/lib/utils/LazyLoader/markdown.js +3 -2
- package/lib/utils/LazyLoader/mathjax.js +5 -2
- package/lib/utils/LazyLoader/plotly.js +6 -7
- package/lib/utils/LazyLoader/upload.js +3 -2
- package/lib/utils/LoadingElement.js +5 -5
- package/lib/utils/MarkdownHighlighter.js +6 -5
- package/lib/utils/ResizeDetector.js +17 -14
- package/lib/utils/dropdownSearch.ts +32 -12
- package/lib/utils/optionRendering.tsx +3 -0
- package/package.json +3 -3
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
@@ -15,130 +16,180 @@ var _Markdown = require("../components/Markdown.react");
|
|
|
15
16
|
var _Link = _interopRequireDefault(require("./../components/Link.react"));
|
|
16
17
|
var _LoadingElement = _interopRequireDefault(require("../utils/LoadingElement"));
|
|
17
18
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
|
-
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" !=
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
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); }
|
|
20
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
21
|
+
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; } }
|
|
22
|
+
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; }
|
|
23
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
24
|
+
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); } }
|
|
25
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
26
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
27
|
+
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); }
|
|
28
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
29
|
+
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
|
|
30
|
+
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
31
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
32
|
+
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
33
|
+
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
34
|
+
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
35
|
+
var DashMarkdown = exports.default = /*#__PURE__*/function (_Component) {
|
|
36
|
+
function DashMarkdown(props) {
|
|
37
|
+
var _this;
|
|
38
|
+
_classCallCheck(this, DashMarkdown);
|
|
39
|
+
_this = _callSuper(this, DashMarkdown, [props]);
|
|
22
40
|
if (_MarkdownHighlighter.default.isReady !== true) {
|
|
23
|
-
_MarkdownHighlighter.default.isReady.then(()
|
|
24
|
-
|
|
41
|
+
_MarkdownHighlighter.default.isReady.then(function () {
|
|
42
|
+
_this.setState({});
|
|
25
43
|
});
|
|
26
44
|
}
|
|
27
|
-
|
|
28
|
-
|
|
45
|
+
_this.highlightCode = _this.highlightCode.bind(_this);
|
|
46
|
+
_this.dedent = _this.dedent.bind(_this);
|
|
47
|
+
return _this;
|
|
29
48
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
_inherits(DashMarkdown, _Component);
|
|
50
|
+
return _createClass(DashMarkdown, [{
|
|
51
|
+
key: "componentDidMount",
|
|
52
|
+
value: function componentDidMount() {
|
|
53
|
+
this.highlightCode();
|
|
54
|
+
}
|
|
55
|
+
}, {
|
|
56
|
+
key: "componentDidUpdate",
|
|
57
|
+
value: function componentDidUpdate() {
|
|
58
|
+
this.highlightCode();
|
|
59
|
+
}
|
|
60
|
+
}, {
|
|
61
|
+
key: "highlightCode",
|
|
62
|
+
value: function highlightCode() {
|
|
63
|
+
var isHighlighted = function isHighlighted(node) {
|
|
64
|
+
// a highlighted node will have <span> children which are what color the text
|
|
65
|
+
return node.children.length > 0;
|
|
66
|
+
};
|
|
67
|
+
if (this.mdContainer) {
|
|
68
|
+
var nodes = this.mdContainer.querySelectorAll('pre code');
|
|
69
|
+
if (_MarkdownHighlighter.default.hljs) {
|
|
70
|
+
for (var i = 0; i < nodes.length; i++) {
|
|
71
|
+
if (!isHighlighted(nodes[i])) {
|
|
72
|
+
nodes[i].removeAttribute('data-highlighted');
|
|
73
|
+
_MarkdownHighlighter.default.hljs.highlightElement(nodes[i]);
|
|
74
|
+
}
|
|
48
75
|
}
|
|
76
|
+
} else {
|
|
77
|
+
_MarkdownHighlighter.default.loadhljs();
|
|
49
78
|
}
|
|
50
|
-
} else {
|
|
51
|
-
_MarkdownHighlighter.default.loadhljs();
|
|
52
79
|
}
|
|
53
80
|
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
var
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
81
|
+
}, {
|
|
82
|
+
key: "dedent",
|
|
83
|
+
value: function dedent(text) {
|
|
84
|
+
var lines = text.split(/\r\n|\r|\n/);
|
|
85
|
+
var commonPrefix = null;
|
|
86
|
+
var _iterator = _createForOfIteratorHelper(lines),
|
|
87
|
+
_step;
|
|
88
|
+
try {
|
|
89
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
90
|
+
var line = _step.value;
|
|
91
|
+
var preMatch = line && line.match(/^\s*(?=\S)/);
|
|
92
|
+
if (preMatch) {
|
|
93
|
+
var prefix = preMatch[0];
|
|
94
|
+
if (commonPrefix !== null) {
|
|
95
|
+
for (var i = 0; i < commonPrefix.length; i++) {
|
|
96
|
+
// Like Python's textwrap.dedent, we'll remove both
|
|
97
|
+
// space and tab characters, but only if they match
|
|
98
|
+
if (prefix[i] !== commonPrefix[i]) {
|
|
99
|
+
commonPrefix = commonPrefix.substr(0, i);
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
} else {
|
|
104
|
+
commonPrefix = prefix;
|
|
105
|
+
}
|
|
106
|
+
if (!commonPrefix) {
|
|
68
107
|
break;
|
|
69
108
|
}
|
|
70
109
|
}
|
|
71
|
-
} else {
|
|
72
|
-
commonPrefix = prefix;
|
|
73
|
-
}
|
|
74
|
-
if (!commonPrefix) {
|
|
75
|
-
break;
|
|
76
110
|
}
|
|
111
|
+
} catch (err) {
|
|
112
|
+
_iterator.e(err);
|
|
113
|
+
} finally {
|
|
114
|
+
_iterator.f();
|
|
77
115
|
}
|
|
116
|
+
var commonLen = commonPrefix ? commonPrefix.length : 0;
|
|
117
|
+
return lines.map(function (line) {
|
|
118
|
+
return line.match(/\S/) ? line.substr(commonLen) : '';
|
|
119
|
+
}).join('\n');
|
|
78
120
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
children
|
|
94
|
-
dedent
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
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
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
121
|
+
}, {
|
|
122
|
+
key: "render",
|
|
123
|
+
value: function render() {
|
|
124
|
+
var _this2 = this;
|
|
125
|
+
var _this$props = this.props,
|
|
126
|
+
id = _this$props.id,
|
|
127
|
+
style = _this$props.style,
|
|
128
|
+
className = _this$props.className,
|
|
129
|
+
highlight_config = _this$props.highlight_config,
|
|
130
|
+
dangerously_allow_html = _this$props.dangerously_allow_html,
|
|
131
|
+
link_target = _this$props.link_target,
|
|
132
|
+
mathjax = _this$props.mathjax,
|
|
133
|
+
children = _this$props.children,
|
|
134
|
+
dedent = _this$props.dedent;
|
|
135
|
+
var textProp = (0, _ramda.type)(children) === 'Array' ? children.join('\n') : children;
|
|
136
|
+
var displayText = dedent && textProp ? this.dedent(textProp) : textProp;
|
|
137
|
+
var componentTransforms = {
|
|
138
|
+
dccLink: function dccLink(props) {
|
|
139
|
+
return /*#__PURE__*/_react.default.createElement(_Link.default, props);
|
|
140
|
+
},
|
|
141
|
+
dccMarkdown: function dccMarkdown(props) {
|
|
142
|
+
return /*#__PURE__*/_react.default.createElement(_reactMarkdown.default, (0, _ramda.mergeDeepRight)((0, _ramda.pick)(['dangerously_allow_html', 'dedent'], _this2.props), (0, _ramda.pick)(['children'], props)));
|
|
143
|
+
},
|
|
144
|
+
dashMathjax: function dashMathjax(props) {
|
|
145
|
+
return /*#__PURE__*/_react.default.createElement(_Math.default, {
|
|
146
|
+
tex: props.value,
|
|
147
|
+
inline: props.inline
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
var regexMath = function regexMath(value) {
|
|
152
|
+
var newValue = value.replace(/(\${1,2})((?:\\.|[^$])+)\1/g, function (m, tag, src) {
|
|
153
|
+
var inline = tag.length === 1 || src.indexOf('\n') === -1;
|
|
154
|
+
return "<dashMathjax value='".concat(src, "' inline='").concat(inline, "'/>");
|
|
155
|
+
});
|
|
156
|
+
return newValue;
|
|
157
|
+
};
|
|
158
|
+
return /*#__PURE__*/_react.default.createElement(_LoadingElement.default, {
|
|
159
|
+
id: id,
|
|
160
|
+
ref: function ref(node) {
|
|
161
|
+
_this2.mdContainer = node;
|
|
162
|
+
},
|
|
163
|
+
style: style,
|
|
164
|
+
className: (highlight_config && highlight_config.theme || className) && "".concat(className ? className : '', " ").concat(highlight_config && highlight_config.theme && highlight_config.theme === 'dark' ? 'hljs-dark' : '')
|
|
165
|
+
}, /*#__PURE__*/_react.default.createElement(_reactMarkdown.default, {
|
|
166
|
+
source: displayText,
|
|
167
|
+
escapeHtml: !dangerously_allow_html,
|
|
168
|
+
linkTarget: link_target,
|
|
169
|
+
plugins: mathjax ? [_remarkMath.default] : [],
|
|
170
|
+
renderers: {
|
|
171
|
+
math: function math(props) {
|
|
172
|
+
return /*#__PURE__*/_react.default.createElement(_Math.default, {
|
|
173
|
+
tex: props.value,
|
|
174
|
+
inline: false
|
|
175
|
+
});
|
|
176
|
+
},
|
|
177
|
+
inlineMath: function inlineMath(props) {
|
|
178
|
+
return /*#__PURE__*/_react.default.createElement(_Math.default, {
|
|
179
|
+
tex: props.value,
|
|
180
|
+
inline: true
|
|
181
|
+
});
|
|
182
|
+
},
|
|
183
|
+
html: function html(props) {
|
|
184
|
+
return props.escapeHtml ? props.value : /*#__PURE__*/_react.default.createElement(_reactJsxParser.default, {
|
|
185
|
+
jsx: mathjax ? regexMath(props.value) : props.value,
|
|
186
|
+
components: componentTransforms,
|
|
187
|
+
renderInWrapper: false
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}));
|
|
192
|
+
}
|
|
193
|
+
}]);
|
|
194
|
+
}(_react.Component);
|
|
144
195
|
DashMarkdown.propTypes = _Markdown.propTypes;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
@@ -7,34 +8,58 @@ exports.propTypes = exports.defaultProps = exports.default = void 0;
|
|
|
7
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
10
|
var _mathjax = _interopRequireDefault(require("../utils/LazyLoader/mathjax"));
|
|
10
|
-
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" !=
|
|
11
|
+
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); }
|
|
11
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
-
class
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
14
|
+
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); } }
|
|
15
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
16
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
17
|
+
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); }
|
|
18
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
19
|
+
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
|
|
20
|
+
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
21
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
22
|
+
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
23
|
+
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
24
|
+
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
25
|
+
var DashMath = exports.default = /*#__PURE__*/function (_Component) {
|
|
26
|
+
function DashMath(props) {
|
|
27
|
+
var _this;
|
|
28
|
+
_classCallCheck(this, DashMath);
|
|
29
|
+
_this = _callSuper(this, DashMath, [props]);
|
|
30
|
+
_this.span_element = /*#__PURE__*/_react.default.createRef();
|
|
31
|
+
return _this;
|
|
16
32
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (prevProps.tex !== this.props.tex || prevProps.inline !== this.props.inline) {
|
|
33
|
+
_inherits(DashMath, _Component);
|
|
34
|
+
return _createClass(DashMath, [{
|
|
35
|
+
key: "componentDidMount",
|
|
36
|
+
value: function componentDidMount() {
|
|
22
37
|
this.renderMath();
|
|
23
38
|
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
39
|
+
}, {
|
|
40
|
+
key: "componentDidUpdate",
|
|
41
|
+
value: function componentDidUpdate(prevProps) {
|
|
42
|
+
if (prevProps.tex !== this.props.tex || prevProps.inline !== this.props.inline) {
|
|
43
|
+
this.renderMath();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}, {
|
|
47
|
+
key: "renderMath",
|
|
48
|
+
value: function renderMath() {
|
|
49
|
+
var current = this.span_element.current;
|
|
50
|
+
(0, _mathjax.default)().then(function () {
|
|
51
|
+
window.MathJax.typeset([current]);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}, {
|
|
55
|
+
key: "render",
|
|
56
|
+
value: function render() {
|
|
57
|
+
return /*#__PURE__*/_react.default.createElement("span", {
|
|
58
|
+
ref: this.span_element
|
|
59
|
+
}, this.props.inline ? '\\(' : '\\[', this.props.tex, this.props.inline ? '\\)' : '\\]');
|
|
60
|
+
}
|
|
61
|
+
}]);
|
|
62
|
+
}(_react.Component);
|
|
38
63
|
DashMath.propTypes = {
|
|
39
64
|
tex: _propTypes.default.string,
|
|
40
65
|
inline: _propTypes.default.bool
|