dash-core-components 4.4.1 → 4.5.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 +2 -1
- package/dash_core_components/async-datepicker.js.map +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-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 -2
- 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 +19 -0
- package/lib/components/Graph.react.js +1 -1
- package/lib/components/Input.tsx +3 -3
- package/lib/components/Link.tsx +74 -0
- package/lib/components/Markdown.tsx +35 -0
- package/lib/fragments/Graph.react.js +6 -7
- package/lib/fragments/Markdown.tsx +101 -0
- package/lib/fragments/Upload.react.js +39 -27
- package/lib/index.ts +2 -2
- package/lib/types.ts +127 -0
- package/lib/utils/LazyLoader/markdown.ts +2 -0
- package/lib/utils/LazyLoader/third-party/highlight.ts +42 -0
- package/lib/utils/LazyLoader/third-party/hljs.ts +18 -0
- package/lib/utils/LazyLoader/third-party/mathjax.ts +23 -0
- package/lib/utils/LazyLoader/third-party/tex-svg.ts +5 -0
- package/lib/utils/markdown/components/Code.tsx +37 -0
- package/lib/utils/markdown/components/DccLink.tsx +25 -0
- package/lib/utils/markdown/components/DccMarkdown.tsx +13 -0
- package/lib/utils/markdown/components/MathJax.tsx +26 -0
- package/lib/utils/markdown/components/index.ts +13 -0
- package/lib/utils/markdown/components/jsx-renderers.d.ts +14 -0
- package/lib/utils/markdown/components/types.ts +15 -0
- package/lib/utils/markdown/context.ts +18 -0
- package/lib/utils/markdown/plugins/index.ts +28 -0
- package/lib/utils/markdown/plugins/rehypeDashMath.ts +69 -0
- package/lib/utils/markdown/plugins/rehypeDccComponents.ts +33 -0
- package/lib/utils/markdown/plugins/rehypeStripTags.ts +23 -0
- package/lib/utils/markdown/text.ts +64 -0
- package/package.json +9 -6
- package/lib/components/Link.react.js +0 -150
- package/lib/components/Markdown.react.js +0 -124
- package/lib/fragments/Markdown.react.js +0 -195
- package/lib/fragments/Math.react.js +0 -72
- package/lib/third-party/highlight.js +0 -46
- package/lib/utils/LazyLoader/hljs.js +0 -11
- package/lib/utils/LazyLoader/markdown.js +0 -9
- package/lib/utils/LazyLoader/mathjax.js +0 -11
- package/lib/utils/MarkdownHighlighter.js +0 -23
- package/lib/utils/mathjax.js +0 -4
|
@@ -173,6 +173,16 @@ pk.Input.propTypes = {value:pt.oneOfType([pt.string,pt.number]),
|
|
|
173
173
|
persistence_type:pt.oneOf(['local','session','memory']),
|
|
174
174
|
id:pt.oneOfType([pt.string]),
|
|
175
175
|
componentPath:pt.any};
|
|
176
|
+
pk.Link.propTypes = {children:pt.node,
|
|
177
|
+
href:pt.string,
|
|
178
|
+
target:pt.oneOfType([pt.string]),
|
|
179
|
+
refresh:pt.oneOfType([pt.bool]),
|
|
180
|
+
title:pt.oneOfType([pt.string]),
|
|
181
|
+
className:pt.oneOfType([pt.string]),
|
|
182
|
+
style:pt.any,
|
|
183
|
+
id:pt.oneOfType([pt.string]),
|
|
184
|
+
loading_state:pt.oneOfType([pt.shape({is_loading:pt.oneOfType([pt.bool]),prop_name:pt.oneOfType([pt.string]),component_name:pt.oneOfType([pt.string])})]),
|
|
185
|
+
setProps:pt.oneOfType([pt.any])};
|
|
176
186
|
pk.Loading.propTypes = {children:pt.node,
|
|
177
187
|
type:pt.oneOf(['graph','cube','circle','dot','default']),
|
|
178
188
|
fullscreen:pt.oneOfType([pt.bool]),
|
|
@@ -195,6 +205,15 @@ pk.Loading.propTypes = {children:pt.node,
|
|
|
195
205
|
persistence_type:pt.oneOf(['local','session','memory']),
|
|
196
206
|
id:pt.oneOfType([pt.string]),
|
|
197
207
|
componentPath:pt.any};
|
|
208
|
+
pk.Markdown.propTypes = {id:pt.oneOfType([pt.string]),
|
|
209
|
+
className:pt.oneOfType([pt.string]),
|
|
210
|
+
children:pt.oneOfType([pt.string,pt.arrayOf(pt.string)]),
|
|
211
|
+
highlight_config:pt.oneOfType([pt.shape({theme:pt.oneOf(['dark','light'])})]),
|
|
212
|
+
style:pt.any,
|
|
213
|
+
mathjax:pt.oneOfType([pt.bool]),
|
|
214
|
+
dangerously_allow_html:pt.oneOfType([pt.bool]),
|
|
215
|
+
link_target:pt.oneOfType([pt.string]),
|
|
216
|
+
dedent:pt.oneOfType([pt.bool])};
|
|
198
217
|
pk.RadioItems.propTypes = {options:pt.any,
|
|
199
218
|
value:pt.oneOfType([pt.string,pt.number,pt.bool]),
|
|
200
219
|
inline:pt.oneOfType([pt.bool]),
|
|
@@ -10,7 +10,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
10
10
|
var _dashComponentPlugins = require("@plotly/dash-component-plugins");
|
|
11
11
|
var _graph = _interopRequireDefault(require("../utils/LazyLoader/graph"));
|
|
12
12
|
var _plotly = _interopRequireDefault(require("../utils/LazyLoader/plotly"));
|
|
13
|
-
var _mathjax = _interopRequireDefault(require("../utils/LazyLoader/mathjax"));
|
|
13
|
+
var _mathjax = _interopRequireDefault(require("../utils/LazyLoader/third-party/mathjax"));
|
|
14
14
|
var _Graph = require("../fragments/Graph.privateprops");
|
|
15
15
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
16
|
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); }
|
package/lib/components/Input.tsx
CHANGED
|
@@ -128,7 +128,7 @@ function Input({
|
|
|
128
128
|
setValue(value);
|
|
129
129
|
}, []);
|
|
130
130
|
|
|
131
|
-
const
|
|
131
|
+
const onKeyDown: KeyboardEventHandler<HTMLInputElement> = useCallback(
|
|
132
132
|
(e: KeyboardEvent) => {
|
|
133
133
|
if (e.key === 'Enter') {
|
|
134
134
|
props.setProps({
|
|
@@ -194,7 +194,7 @@ function Input({
|
|
|
194
194
|
parseFloat(props.min as string)
|
|
195
195
|
);
|
|
196
196
|
}
|
|
197
|
-
if (props.max !== null && props.
|
|
197
|
+
if (props.max !== null && props.max !== undefined) {
|
|
198
198
|
constrainedValue = Math.min(
|
|
199
199
|
constrainedValue,
|
|
200
200
|
parseFloat(props.max as string)
|
|
@@ -288,7 +288,7 @@ function Input({
|
|
|
288
288
|
className="dash-input-element"
|
|
289
289
|
onBlur={onBlur}
|
|
290
290
|
onChange={onChange}
|
|
291
|
-
|
|
291
|
+
onKeyDown={onKeyDown}
|
|
292
292
|
{...valprops}
|
|
293
293
|
{...pickedInputs}
|
|
294
294
|
{...loadingProps}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import React, {useEffect, useMemo} from 'react';
|
|
2
|
+
import {isNil} from 'ramda';
|
|
3
|
+
|
|
4
|
+
import LoadingElement from '../utils/_LoadingElement';
|
|
5
|
+
import {LinkProps} from '../types';
|
|
6
|
+
|
|
7
|
+
type LinkComponentProps = LinkProps & {
|
|
8
|
+
setProps?: (props: Record<string, unknown>) => void;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Link allows you to create a clickable link within a multi-page app.
|
|
13
|
+
*
|
|
14
|
+
* For links with destinations outside the current app, `html.A` is a better
|
|
15
|
+
* component to use.
|
|
16
|
+
*/
|
|
17
|
+
const Link = ({refresh = false, ...props}: LinkComponentProps) => {
|
|
18
|
+
const {className, style, id, href, children, title, target, setProps} =
|
|
19
|
+
props;
|
|
20
|
+
const cleanUrl = window.dash_clientside.clean_url;
|
|
21
|
+
const sanitizedUrl = useMemo(() => {
|
|
22
|
+
return href ? cleanUrl(href) : undefined;
|
|
23
|
+
}, [href]);
|
|
24
|
+
|
|
25
|
+
const updateLocation = (e: React.MouseEvent<HTMLAnchorElement>) => {
|
|
26
|
+
const hasModifiers = e.metaKey || e.shiftKey || e.altKey || e.ctrlKey;
|
|
27
|
+
|
|
28
|
+
if (hasModifiers) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (target !== '_self' && !isNil(target)) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
// prevent anchor from updating location
|
|
35
|
+
e.preventDefault();
|
|
36
|
+
if (refresh) {
|
|
37
|
+
window.location.href = sanitizedUrl as string;
|
|
38
|
+
} else {
|
|
39
|
+
window.history.pushState({}, '', sanitizedUrl);
|
|
40
|
+
window.dispatchEvent(new CustomEvent('_dashprivate_pushstate'));
|
|
41
|
+
}
|
|
42
|
+
// scroll back to top
|
|
43
|
+
window.scrollTo(0, 0);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (sanitizedUrl && sanitizedUrl !== href) {
|
|
48
|
+
setProps?.({
|
|
49
|
+
_dash_error: new Error(`Dangerous link detected:: ${href}`),
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}, [href, sanitizedUrl]);
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<LoadingElement>
|
|
56
|
+
{loadingProps => (
|
|
57
|
+
<a
|
|
58
|
+
id={id}
|
|
59
|
+
className={className}
|
|
60
|
+
style={style}
|
|
61
|
+
href={sanitizedUrl}
|
|
62
|
+
onClick={updateLocation}
|
|
63
|
+
title={title}
|
|
64
|
+
target={target}
|
|
65
|
+
{...loadingProps}
|
|
66
|
+
>
|
|
67
|
+
{isNil(children) ? sanitizedUrl : children}
|
|
68
|
+
</a>
|
|
69
|
+
)}
|
|
70
|
+
</LoadingElement>
|
|
71
|
+
);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export default Link;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React, {lazy, Suspense, useEffect} from 'react';
|
|
2
|
+
import {MarkdownProps} from '../types';
|
|
3
|
+
import markdown from '../utils/LazyLoader/markdown';
|
|
4
|
+
import lazyLoadMathJax from '../utils/LazyLoader/third-party/mathjax';
|
|
5
|
+
|
|
6
|
+
const RealMarkdown = lazy(markdown);
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A component that renders Markdown text as specified by the
|
|
10
|
+
* GitHub Markdown spec. These component uses
|
|
11
|
+
* [react-markdown](https://github.com/remarkjs/react-markdown) under the hood.
|
|
12
|
+
*/
|
|
13
|
+
export default function Markdown({
|
|
14
|
+
mathjax = false,
|
|
15
|
+
dangerously_allow_html = false,
|
|
16
|
+
dedent = true,
|
|
17
|
+
...props
|
|
18
|
+
}: MarkdownProps) {
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (mathjax) {
|
|
21
|
+
lazyLoadMathJax();
|
|
22
|
+
}
|
|
23
|
+
}, [mathjax]);
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<Suspense fallback={null}>
|
|
27
|
+
<RealMarkdown
|
|
28
|
+
mathjax={mathjax}
|
|
29
|
+
dangerously_allow_html={dangerously_allow_html}
|
|
30
|
+
dedent={dedent}
|
|
31
|
+
{...props}
|
|
32
|
+
/>
|
|
33
|
+
</Suspense>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _mathjax = _interopRequireDefault(require("../utils/LazyLoader/mathjax"));
|
|
7
|
+
var _mathjax = _interopRequireDefault(require("../utils/LazyLoader/third-party/mathjax"));
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _ramda = require("ramda");
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
@@ -121,12 +121,11 @@ var filterEventData = function filterEventData(gd, eventData, event) {
|
|
|
121
121
|
};
|
|
122
122
|
var includeXYVals = event === 'hover' && gd._fullLayout.hoveranywhere === true || event === 'click' && gd._fullLayout.clickanywhere === true;
|
|
123
123
|
if (includeXYVals) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
124
|
+
['xvals', 'yvals', 'xPixel', 'yPixel'].forEach(function (key) {
|
|
125
|
+
if ((0, _ramda.has)(key, eventData)) {
|
|
126
|
+
filteredEventData[key] = eventData[key];
|
|
127
|
+
}
|
|
128
|
+
});
|
|
130
129
|
if ((0, _ramda.has)('xaxes', eventData)) {
|
|
131
130
|
filteredEventData.xaxes_id = eventData.xaxes[0]._id;
|
|
132
131
|
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import React, {useCallback, useMemo} from 'react';
|
|
2
|
+
import ReactMarkdown from 'react-markdown';
|
|
3
|
+
import type {PluggableList} from 'unified';
|
|
4
|
+
|
|
5
|
+
import LoadingElement from '../utils/_LoadingElement';
|
|
6
|
+
import {MarkdownContentProps, MarkdownProps} from '../types';
|
|
7
|
+
import {components} from '../utils/markdown/components';
|
|
8
|
+
import {MarkdownContext} from '../utils/markdown/context';
|
|
9
|
+
import {
|
|
10
|
+
rawHtmlPlugins,
|
|
11
|
+
rehypeMathPlugins,
|
|
12
|
+
remarkMathPlugins,
|
|
13
|
+
remarkGfmPlugins,
|
|
14
|
+
} from '../utils/markdown/plugins';
|
|
15
|
+
import {dedentText} from '../utils/markdown/text';
|
|
16
|
+
|
|
17
|
+
const MarkdownContent = React.memo(function MarkdownContent({
|
|
18
|
+
children,
|
|
19
|
+
dedent,
|
|
20
|
+
dangerously_allow_html,
|
|
21
|
+
mathjax,
|
|
22
|
+
link_target,
|
|
23
|
+
}: MarkdownContentProps & {children: string}) {
|
|
24
|
+
const displayText = dedent && children ? dedentText(children) : children;
|
|
25
|
+
|
|
26
|
+
const remarkPlugins: PluggableList = [...remarkGfmPlugins];
|
|
27
|
+
const rehypePlugins: PluggableList = [];
|
|
28
|
+
if (mathjax) {
|
|
29
|
+
remarkPlugins.push(...remarkMathPlugins);
|
|
30
|
+
rehypePlugins.push(...rehypeMathPlugins);
|
|
31
|
+
}
|
|
32
|
+
if (dangerously_allow_html) {
|
|
33
|
+
rehypePlugins.push(...rawHtmlPlugins);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<ReactMarkdown
|
|
38
|
+
linkTarget={link_target}
|
|
39
|
+
remarkPlugins={remarkPlugins}
|
|
40
|
+
rehypePlugins={rehypePlugins}
|
|
41
|
+
components={components}
|
|
42
|
+
>
|
|
43
|
+
{displayText}
|
|
44
|
+
</ReactMarkdown>
|
|
45
|
+
);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
function MarkdownContainer({
|
|
49
|
+
id,
|
|
50
|
+
style,
|
|
51
|
+
className,
|
|
52
|
+
highlight_config,
|
|
53
|
+
dangerously_allow_html,
|
|
54
|
+
link_target,
|
|
55
|
+
mathjax,
|
|
56
|
+
children,
|
|
57
|
+
dedent,
|
|
58
|
+
}: MarkdownProps) {
|
|
59
|
+
const textProp = Array.isArray(children) ? children.join('\n') : children;
|
|
60
|
+
|
|
61
|
+
const classNames = [
|
|
62
|
+
className,
|
|
63
|
+
highlight_config?.theme === 'dark' ? 'hljs-dark' : '',
|
|
64
|
+
].filter(Boolean);
|
|
65
|
+
|
|
66
|
+
// provides a recursive method to render nested markdown elements
|
|
67
|
+
const renderMarkdown = useCallback(
|
|
68
|
+
(text: string) => (
|
|
69
|
+
<MarkdownContent
|
|
70
|
+
dedent={dedent}
|
|
71
|
+
dangerously_allow_html={dangerously_allow_html}
|
|
72
|
+
mathjax={mathjax}
|
|
73
|
+
link_target={link_target}
|
|
74
|
+
>
|
|
75
|
+
{text}
|
|
76
|
+
</MarkdownContent>
|
|
77
|
+
),
|
|
78
|
+
[dedent, dangerously_allow_html, mathjax, link_target]
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
const markdownContext = useMemo(() => ({renderMarkdown}), [renderMarkdown]);
|
|
82
|
+
|
|
83
|
+
return (
|
|
84
|
+
<LoadingElement>
|
|
85
|
+
{loadingProps => (
|
|
86
|
+
<div
|
|
87
|
+
id={id}
|
|
88
|
+
style={style}
|
|
89
|
+
className={classNames.join(' ')}
|
|
90
|
+
{...loadingProps}
|
|
91
|
+
>
|
|
92
|
+
<MarkdownContext.Provider value={markdownContext}>
|
|
93
|
+
{renderMarkdown(textProp ?? '')}
|
|
94
|
+
</MarkdownContext.Provider>
|
|
95
|
+
</div>
|
|
96
|
+
)}
|
|
97
|
+
</LoadingElement>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export default MarkdownContainer;
|
|
@@ -195,7 +195,7 @@ var Upload = exports.default = /*#__PURE__*/function (_Component) {
|
|
|
195
195
|
key: "getDataTransferItems",
|
|
196
196
|
value: function () {
|
|
197
197
|
var _getDataTransferItems = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(event) {
|
|
198
|
-
var multiple, items, files, _i, _items, item, entry,
|
|
198
|
+
var multiple, items, entries, files, _i, _items, item, entry, file, _i2, _entries, _entry, entryFiles;
|
|
199
199
|
return _regenerator().w(function (_context3) {
|
|
200
200
|
while (1) switch (_context3.n) {
|
|
201
201
|
case 0:
|
|
@@ -219,59 +219,71 @@ var Upload = exports.default = /*#__PURE__*/function (_Component) {
|
|
|
219
219
|
return _context3.a(2, []);
|
|
220
220
|
case 3:
|
|
221
221
|
if (!(event.dataTransfer && event.dataTransfer.items)) {
|
|
222
|
-
_context3.n =
|
|
222
|
+
_context3.n = 12;
|
|
223
223
|
break;
|
|
224
224
|
}
|
|
225
|
-
items = Array.from(event.dataTransfer.items);
|
|
225
|
+
items = Array.from(event.dataTransfer.items); // Get all entries synchronously before the first await
|
|
226
|
+
entries = [];
|
|
226
227
|
files = [];
|
|
227
228
|
_i = 0, _items = items;
|
|
228
229
|
case 4:
|
|
229
230
|
if (!(_i < _items.length)) {
|
|
230
|
-
_context3.n =
|
|
231
|
+
_context3.n = 7;
|
|
231
232
|
break;
|
|
232
233
|
}
|
|
233
234
|
item = _items[_i];
|
|
234
|
-
if (!(item.kind
|
|
235
|
-
_context3.n =
|
|
235
|
+
if (!(item.kind !== 'file')) {
|
|
236
|
+
_context3.n = 5;
|
|
236
237
|
break;
|
|
237
238
|
}
|
|
239
|
+
return _context3.a(3, 6);
|
|
240
|
+
case 5:
|
|
238
241
|
entry = item.webkitGetAsEntry ? item.webkitGetAsEntry() : null;
|
|
239
|
-
if (
|
|
240
|
-
|
|
241
|
-
|
|
242
|
+
if (entry) {
|
|
243
|
+
entries.push(entry);
|
|
244
|
+
} else {
|
|
245
|
+
// Fallback for browsers without webkitGetAsEntry
|
|
246
|
+
file = item.getAsFile();
|
|
247
|
+
if (file) {
|
|
248
|
+
files.push(file);
|
|
249
|
+
}
|
|
242
250
|
}
|
|
243
|
-
_context3.n = 5;
|
|
244
|
-
return this.traverseFileTree(entry);
|
|
245
|
-
case 5:
|
|
246
|
-
entryFiles = _context3.v;
|
|
247
|
-
files.push.apply(files, _toConsumableArray(entryFiles));
|
|
248
|
-
_context3.n = 7;
|
|
249
|
-
break;
|
|
250
251
|
case 6:
|
|
251
|
-
// Fallback for browsers without webkitGetAsEntry
|
|
252
|
-
file = item.getAsFile();
|
|
253
|
-
if (file) {
|
|
254
|
-
files.push(file);
|
|
255
|
-
}
|
|
256
|
-
case 7:
|
|
257
252
|
_i++;
|
|
258
253
|
_context3.n = 4;
|
|
259
254
|
break;
|
|
255
|
+
case 7:
|
|
256
|
+
_i2 = 0, _entries = entries;
|
|
260
257
|
case 8:
|
|
261
|
-
|
|
258
|
+
if (!(_i2 < _entries.length)) {
|
|
259
|
+
_context3.n = 11;
|
|
260
|
+
break;
|
|
261
|
+
}
|
|
262
|
+
_entry = _entries[_i2];
|
|
263
|
+
_context3.n = 9;
|
|
264
|
+
return this.traverseFileTree(_entry);
|
|
262
265
|
case 9:
|
|
266
|
+
entryFiles = _context3.v;
|
|
267
|
+
files.push.apply(files, _toConsumableArray(entryFiles));
|
|
268
|
+
case 10:
|
|
269
|
+
_i2++;
|
|
270
|
+
_context3.n = 8;
|
|
271
|
+
break;
|
|
272
|
+
case 11:
|
|
273
|
+
return _context3.a(2, files);
|
|
274
|
+
case 12:
|
|
263
275
|
if (!(event.target && event.target.files)) {
|
|
264
|
-
_context3.n =
|
|
276
|
+
_context3.n = 13;
|
|
265
277
|
break;
|
|
266
278
|
}
|
|
267
279
|
return _context3.a(2, Array.from(event.target.files));
|
|
268
|
-
case
|
|
280
|
+
case 13:
|
|
269
281
|
if (!(event.dataTransfer && event.dataTransfer.files)) {
|
|
270
|
-
_context3.n =
|
|
282
|
+
_context3.n = 14;
|
|
271
283
|
break;
|
|
272
284
|
}
|
|
273
285
|
return _context3.a(2, Array.from(event.dataTransfer.files));
|
|
274
|
-
case
|
|
286
|
+
case 14:
|
|
275
287
|
return _context3.a(2, []);
|
|
276
288
|
}
|
|
277
289
|
}, _callee3, this);
|
package/lib/index.ts
CHANGED
|
@@ -12,10 +12,10 @@ import Geolocation from './components/Geolocation.react';
|
|
|
12
12
|
import Graph from './components/Graph.react';
|
|
13
13
|
import Input from './components/Input';
|
|
14
14
|
import Interval from './components/Interval.react';
|
|
15
|
-
import Link from './components/Link
|
|
15
|
+
import Link from './components/Link';
|
|
16
16
|
import Loading from './components/Loading';
|
|
17
17
|
import Location from './components/Location.react';
|
|
18
|
-
import Markdown from './components/Markdown
|
|
18
|
+
import Markdown from './components/Markdown';
|
|
19
19
|
import RadioItems from './components/RadioItems';
|
|
20
20
|
import RangeSlider from './components/RangeSlider';
|
|
21
21
|
import Slider from './components/Slider';
|
package/lib/types.ts
CHANGED
|
@@ -1492,3 +1492,130 @@ export interface DatePickerRangeProps
|
|
|
1492
1492
|
|
|
1493
1493
|
setProps: (props: Partial<DatePickerRangeProps>) => void;
|
|
1494
1494
|
}
|
|
1495
|
+
|
|
1496
|
+
export interface LinkProps {
|
|
1497
|
+
/**
|
|
1498
|
+
* The children of this component
|
|
1499
|
+
*/
|
|
1500
|
+
children?: React.ReactNode;
|
|
1501
|
+
|
|
1502
|
+
/**
|
|
1503
|
+
* The URL of a linked resource.
|
|
1504
|
+
*/
|
|
1505
|
+
href: string;
|
|
1506
|
+
|
|
1507
|
+
/**
|
|
1508
|
+
* Specifies where to open the link reference.
|
|
1509
|
+
*/
|
|
1510
|
+
target?: string;
|
|
1511
|
+
|
|
1512
|
+
/**
|
|
1513
|
+
* Controls whether or not the page will refresh when the link is clicked
|
|
1514
|
+
*/
|
|
1515
|
+
refresh?: boolean;
|
|
1516
|
+
|
|
1517
|
+
/**
|
|
1518
|
+
* Adds the title attribute to your link, which can contain supplementary
|
|
1519
|
+
* information.
|
|
1520
|
+
*/
|
|
1521
|
+
title?: string;
|
|
1522
|
+
|
|
1523
|
+
/**
|
|
1524
|
+
* Often used with CSS to style elements with common properties.
|
|
1525
|
+
*/
|
|
1526
|
+
className?: string;
|
|
1527
|
+
|
|
1528
|
+
/**
|
|
1529
|
+
* Defines CSS styles which will override styles previously set.
|
|
1530
|
+
*/
|
|
1531
|
+
style?: React.CSSProperties;
|
|
1532
|
+
|
|
1533
|
+
/**
|
|
1534
|
+
* The ID of this component, used to identify dash components
|
|
1535
|
+
* in callbacks. The ID needs to be unique across all of the
|
|
1536
|
+
* components in an app.
|
|
1537
|
+
*/
|
|
1538
|
+
id?: string;
|
|
1539
|
+
|
|
1540
|
+
/**
|
|
1541
|
+
* Object that holds the loading state object coming from dash-renderer
|
|
1542
|
+
*/
|
|
1543
|
+
loading_state?: {
|
|
1544
|
+
/**
|
|
1545
|
+
* Determines if the component is loading or not
|
|
1546
|
+
*/
|
|
1547
|
+
is_loading?: boolean;
|
|
1548
|
+
/**
|
|
1549
|
+
* Holds which property is loading
|
|
1550
|
+
*/
|
|
1551
|
+
prop_name?: string;
|
|
1552
|
+
/**
|
|
1553
|
+
* Holds the name of the component that is loading
|
|
1554
|
+
*/
|
|
1555
|
+
component_name?: string;
|
|
1556
|
+
};
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1559
|
+
export interface MarkdownContentProps {
|
|
1560
|
+
/**
|
|
1561
|
+
* If true, loads mathjax v3 (tex-svg) into the page and use it in the markdown
|
|
1562
|
+
*/
|
|
1563
|
+
mathjax?: boolean;
|
|
1564
|
+
|
|
1565
|
+
/**
|
|
1566
|
+
* A boolean to control raw HTML escaping.
|
|
1567
|
+
* Setting HTML from code is risky because it's easy to
|
|
1568
|
+
* inadvertently expose your users to a cross-site scripting (XSS)
|
|
1569
|
+
* (https://en.wikipedia.org/wiki/Cross-site_scripting) attack.
|
|
1570
|
+
*/
|
|
1571
|
+
dangerously_allow_html?: boolean;
|
|
1572
|
+
|
|
1573
|
+
/**
|
|
1574
|
+
* A string for the target attribute to use on links (such as "_blank")
|
|
1575
|
+
*/
|
|
1576
|
+
link_target?: string;
|
|
1577
|
+
|
|
1578
|
+
/**
|
|
1579
|
+
* Remove matching leading whitespace from all lines.
|
|
1580
|
+
* Lines that are empty, or contain *only* whitespace, are ignored.
|
|
1581
|
+
* Both spaces and tab characters are removed, but only if they match;
|
|
1582
|
+
* we will not convert tabs to spaces or vice versa.
|
|
1583
|
+
*/
|
|
1584
|
+
dedent?: boolean;
|
|
1585
|
+
}
|
|
1586
|
+
|
|
1587
|
+
// Markdown is a display-only component: it has no persistence and does not
|
|
1588
|
+
// call `setProps`, so it deliberately does not extend `BaseDccProps`.
|
|
1589
|
+
export interface MarkdownProps extends MarkdownContentProps {
|
|
1590
|
+
/**
|
|
1591
|
+
* The ID of this component, used to identify dash components
|
|
1592
|
+
* in callbacks. The ID needs to be unique across all of the
|
|
1593
|
+
* components in an app.
|
|
1594
|
+
*/
|
|
1595
|
+
id?: string;
|
|
1596
|
+
|
|
1597
|
+
/**
|
|
1598
|
+
* Class name of the container element
|
|
1599
|
+
*/
|
|
1600
|
+
className?: string;
|
|
1601
|
+
|
|
1602
|
+
/**
|
|
1603
|
+
* A markdown string (or array of strings) that adheres to the CommonMark spec
|
|
1604
|
+
*/
|
|
1605
|
+
children?: string | string[];
|
|
1606
|
+
|
|
1607
|
+
/**
|
|
1608
|
+
* Config options for syntax highlighting.
|
|
1609
|
+
*/
|
|
1610
|
+
highlight_config?: {
|
|
1611
|
+
/**
|
|
1612
|
+
* Color scheme; default 'light'
|
|
1613
|
+
*/
|
|
1614
|
+
theme?: 'dark' | 'light';
|
|
1615
|
+
};
|
|
1616
|
+
|
|
1617
|
+
/**
|
|
1618
|
+
* User-defined inline styles for the rendered Markdown
|
|
1619
|
+
*/
|
|
1620
|
+
style?: React.CSSProperties;
|
|
1621
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import highlightjs from 'highlight.js/lib/core';
|
|
2
|
+
import 'highlight.js/styles/github.css';
|
|
3
|
+
|
|
4
|
+
import bash from 'highlight.js/lib/languages/bash';
|
|
5
|
+
import csharp from 'highlight.js/lib/languages/csharp';
|
|
6
|
+
import css from 'highlight.js/lib/languages/css';
|
|
7
|
+
import fsharp from 'highlight.js/lib/languages/fsharp';
|
|
8
|
+
import http from 'highlight.js/lib/languages/http';
|
|
9
|
+
import javascript from 'highlight.js/lib/languages/javascript';
|
|
10
|
+
import json from 'highlight.js/lib/languages/json';
|
|
11
|
+
import julia from 'highlight.js/lib/languages/julia';
|
|
12
|
+
import markdown from 'highlight.js/lib/languages/markdown';
|
|
13
|
+
import matlab from 'highlight.js/lib/languages/matlab';
|
|
14
|
+
import plaintext from 'highlight.js/lib/languages/plaintext';
|
|
15
|
+
import python from 'highlight.js/lib/languages/python';
|
|
16
|
+
import r from 'highlight.js/lib/languages/r';
|
|
17
|
+
import ruby from 'highlight.js/lib/languages/ruby';
|
|
18
|
+
import shell from 'highlight.js/lib/languages/shell';
|
|
19
|
+
import sql from 'highlight.js/lib/languages/sql';
|
|
20
|
+
import xml from 'highlight.js/lib/languages/xml';
|
|
21
|
+
import yaml from 'highlight.js/lib/languages/yaml';
|
|
22
|
+
|
|
23
|
+
highlightjs.registerLanguage('bash', bash);
|
|
24
|
+
highlightjs.registerLanguage('csharp', csharp);
|
|
25
|
+
highlightjs.registerLanguage('css', css);
|
|
26
|
+
highlightjs.registerLanguage('fsharp', fsharp);
|
|
27
|
+
highlightjs.registerLanguage('http', http);
|
|
28
|
+
highlightjs.registerLanguage('javascript', javascript);
|
|
29
|
+
highlightjs.registerLanguage('json', json);
|
|
30
|
+
highlightjs.registerLanguage('julia', julia);
|
|
31
|
+
highlightjs.registerLanguage('markdown', markdown);
|
|
32
|
+
highlightjs.registerLanguage('matlab', matlab);
|
|
33
|
+
highlightjs.registerLanguage('plaintext', plaintext);
|
|
34
|
+
highlightjs.registerLanguage('python', python);
|
|
35
|
+
highlightjs.registerLanguage('r', r);
|
|
36
|
+
highlightjs.registerLanguage('ruby', ruby);
|
|
37
|
+
highlightjs.registerLanguage('shell', shell);
|
|
38
|
+
highlightjs.registerLanguage('sql', sql);
|
|
39
|
+
highlightjs.registerLanguage('xml', xml);
|
|
40
|
+
highlightjs.registerLanguage('yaml', yaml);
|
|
41
|
+
|
|
42
|
+
export default highlightjs;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type {HLJSApi} from 'highlight.js';
|
|
2
|
+
|
|
3
|
+
declare global {
|
|
4
|
+
interface Window {
|
|
5
|
+
hljs?: HLJSApi;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// Reuse a highlight.js instance already on `window` (e.g. supplied by the host
|
|
10
|
+
// page), otherwise lazily load the bundled third-party build.
|
|
11
|
+
export default function lazyLoadHljs(): Promise<HLJSApi> {
|
|
12
|
+
return Promise.resolve(
|
|
13
|
+
window.hljs ??
|
|
14
|
+
import(/* webpackChunkName: "highlight" */ './highlight').then(
|
|
15
|
+
mod => mod.default as HLJSApi
|
|
16
|
+
)
|
|
17
|
+
);
|
|
18
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
interface MathJaxObject {
|
|
2
|
+
typeset: (elements?: (HTMLElement | null)[]) => void;
|
|
3
|
+
config: {startup: {typeset: boolean}};
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
declare global {
|
|
7
|
+
interface Window {
|
|
8
|
+
MathJax?: MathJaxObject;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export default function lazyLoadMathJax(
|
|
13
|
+
mathjax?: boolean
|
|
14
|
+
): Promise<MathJaxObject | undefined> {
|
|
15
|
+
return Promise.resolve(
|
|
16
|
+
window.MathJax ||
|
|
17
|
+
(mathjax === false
|
|
18
|
+
? undefined
|
|
19
|
+
: import(/* webpackChunkName: "mathjax" */ './tex-svg').then(
|
|
20
|
+
() => window.MathJax
|
|
21
|
+
))
|
|
22
|
+
);
|
|
23
|
+
}
|