react-science 24.0.0 → 24.1.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/lib/components/drop-zone/DropZone.d.ts +8 -0
- package/lib/components/drop-zone/DropZone.d.ts.map +1 -1
- package/lib/components/drop-zone/DropZone.js +5 -2
- package/lib/components/drop-zone/DropZone.js.map +1 -1
- package/lib/components/split_pane/split_pane_helpers.d.ts.map +1 -1
- package/lib/components/split_pane/split_pane_helpers.js +6 -2
- package/lib/components/split_pane/split_pane_helpers.js.map +1 -1
- package/package.json +1 -1
- package/src/components/drop-zone/DropZone.tsx +18 -6
- package/src/components/split_pane/split_pane_helpers.ts +8 -3
|
@@ -8,6 +8,14 @@ export interface DropZoneProps extends dropzone.DropzoneOptions {
|
|
|
8
8
|
emptyDescription?: string;
|
|
9
9
|
emptyButtonText?: string;
|
|
10
10
|
emptyButtonIcon?: IconName;
|
|
11
|
+
/**
|
|
12
|
+
* Note this mode is not standard but widely supported.
|
|
13
|
+
* Also note, if you enable this mode, you must not use `useFsAccessApi` flag.
|
|
14
|
+
*
|
|
15
|
+
* @see https://react-dropzone.js.org/examples/directory
|
|
16
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/file#webkitdirectory
|
|
17
|
+
*/
|
|
18
|
+
folderMode?: boolean;
|
|
11
19
|
}
|
|
12
20
|
export declare function DropZone(props: DropZoneProps): import("react").JSX.Element;
|
|
13
21
|
export interface DropZoneContainerProps extends DropZoneProps {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropZone.d.ts","sourceRoot":"","sources":["../../../src/components/drop-zone/DropZone.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,KAAK,EAAoC,YAAY,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"DropZone.d.ts","sourceRoot":"","sources":["../../../src/components/drop-zone/DropZone.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,KAAK,EAAoC,YAAY,EAAE,MAAM,OAAO,CAAC;AAE5E,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAM3C,MAAM,WAAW,aAAc,SAAQ,QAAQ,CAAC,eAAe;IAC7D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,QAAQ,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,CAAC,EAAE,QAAQ,CAAC;IAC3B;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAsCD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,+BAE5C;AAED,MAAM,WAAW,sBAAuB,SAAQ,aAAa;IAC3D,QAAQ,EAAE,YAAY,GAAG,IAAI,CAAC;CAC/B;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,+BAE9D"}
|
|
@@ -38,12 +38,15 @@ export function DropZoneContainer(props) {
|
|
|
38
38
|
return _jsx(DropZoneContent, { ...props });
|
|
39
39
|
}
|
|
40
40
|
function DropZoneContent(props) {
|
|
41
|
-
const { borderColor = Colors.GRAY3, children = null, onClick, emptyIcon = 'import', emptyTitle = 'No data loaded', emptyDescription = 'You can load data by drag-and-dropping files here', emptyButtonText = 'Select files', emptyButtonIcon = 'plus', noClick, ...otherProps } = props;
|
|
41
|
+
const { borderColor = Colors.GRAY3, children = null, onClick, emptyIcon = 'import', emptyTitle = 'No data loaded', emptyDescription = 'You can load data by drag-and-dropping files here', emptyButtonText = 'Select files', emptyButtonIcon = 'plus', noClick, folderMode = false, ...otherProps } = props;
|
|
42
42
|
const hasChildren = children !== null;
|
|
43
43
|
const { getRootProps, getInputProps, isDragActive } = dropzone.useDropzone({
|
|
44
44
|
noClick: noClick ?? hasChildren,
|
|
45
45
|
...otherProps,
|
|
46
46
|
});
|
|
47
|
-
|
|
47
|
+
const extraInputProps = folderMode
|
|
48
|
+
? { webkitdirectory: 'true' }
|
|
49
|
+
: {};
|
|
50
|
+
return (_jsxs(DropzoneRoot, { ...getRootProps({ onClick }), children: [children, isDragActive ? (_jsx(DropzoneDragActive, { borderColor: borderColor, children: _jsx(NonIdealState, { icon: "cloud-upload", title: "Drop the files here" }) })) : !hasChildren ? (_jsx(DropzoneEmpty, { borderColor: borderColor, children: _jsx(NonIdealState, { icon: emptyIcon, title: emptyTitle, description: emptyDescription, action: _jsx(Button, { className: "dropzone-button", variant: "outlined", text: emptyButtonText, icon: emptyButtonIcon, intent: "primary" }) }) })) : null, _jsx("input", { ...getInputProps(extraInputProps) })] }));
|
|
48
51
|
}
|
|
49
52
|
//# sourceMappingURL=DropZone.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropZone.js","sourceRoot":"","sources":["../../../src/components/drop-zone/DropZone.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElE,OAAO,MAAM,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"DropZone.js","sourceRoot":"","sources":["../../../src/components/drop-zone/DropZone.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElE,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAGrC,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,SAAS,MAAM,YAAY,CAAC;AAsBnC,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAA;;;;CAI9B,CAAC;AAMF,MAAM,kBAAkB,GAAG,MAAM,CAAC,GAAG,CAAoB;;;;;;;;;kBASvC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AK,YAAY,CAAC,EAAE,OAAO,EAAE,CAAC,aACxC,QAAQ,EACR,YAAY,CAAC,CAAC,CAAC,CACd,KAAC,kBAAkB,IAAC,WAAW,EAAE,WAAW,YAC1C,KAAC,aAAa,IAAC,IAAI,EAAC,cAAc,EAAC,KAAK,EAAC,qBAAqB,GAAG,GAC9C,CACtB,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CACjB,KAAC,aAAa,IAAC,WAAW,EAAE,WAAW,YACrC,KAAC,aAAa,IACZ,IAAI,EAAE,SAAS,EACf,KAAK,EAAE,UAAU,EACjB,WAAW,EAAE,gBAAgB,EAC7B,MAAM,EACJ,KAAC,MAAM,IACL,SAAS,EAAC,iBAAiB,EAC3B,OAAO,EAAC,UAAU,EAClB,IAAI,EAAE,eAAe,EACrB,IAAI,EAAE,eAAe,EACrB,MAAM,EAAC,SAAS,GAChB,GAEJ,GACY,CACjB,CAAC,CAAC,CAAC,IAAI,EACR,mBAAW,aAAa,CAAC,eAAe,CAAC,GAAI,IAChC,CAChB,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"split_pane_helpers.d.ts","sourceRoot":"","sources":["../../../src/components/split_pane/split_pane_helpers.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,GAAG,MAAM,GAAG,GAAG,GAAG,MAAM,IAAI,CAAC;AACzD,MAAM,MAAM,aAAa,GAAG,GAAG,GAAG,IAAI,CAAC;AAEvC,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,aAAa,CAAC;CACrB;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,mBAAmB,
|
|
1
|
+
{"version":3,"file":"split_pane_helpers.d.ts","sourceRoot":"","sources":["../../../src/components/split_pane/split_pane_helpers.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,GAAG,MAAM,GAAG,GAAG,GAAG,MAAM,IAAI,CAAC;AACzD,MAAM,MAAM,aAAa,GAAG,GAAG,GAAG,IAAI,CAAC;AAEvC,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,aAAa,CAAC;CACrB;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,mBAAmB,CAW3D;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,mBAAmB,GAAG,aAAa,CAEtE"}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
export function parseSize(size) {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
// eslint-disable-next-line unicorn/prefer-number-coercion
|
|
3
|
+
const value = Number.parseFloat(size);
|
|
4
|
+
// Remove numbers and dots from the string.
|
|
4
5
|
const type = size.replaceAll(/[\d .]/g, '');
|
|
6
|
+
if (Number.isNaN(value) || (type !== '%' && type !== 'px')) {
|
|
7
|
+
throw new Error('SplitPane size must be a number with "%" or "px" unit.');
|
|
8
|
+
}
|
|
5
9
|
return { value, type };
|
|
6
10
|
}
|
|
7
11
|
export function serializeSize(size) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"split_pane_helpers.js","sourceRoot":"","sources":["../../../src/components/split_pane/split_pane_helpers.ts"],"names":[],"mappings":"AAQA,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"split_pane_helpers.js","sourceRoot":"","sources":["../../../src/components/split_pane/split_pane_helpers.ts"],"names":[],"mappings":"AAQA,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,0DAA0D;IAC1D,MAAM,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACtC,2CAA2C;IAC3C,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IAE5C,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,IAAI,CAAC,EAAE,CAAC;QAC3D,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;IAC5E,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AACzB,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,IAAyB;IACrD,OAAO,GAAG,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;AACrC,CAAC"}
|
package/package.json
CHANGED
|
@@ -2,9 +2,13 @@ import { Button, Colors, NonIdealState } from '@blueprintjs/core';
|
|
|
2
2
|
import type { IconName } from '@blueprintjs/icons';
|
|
3
3
|
import styled from '@emotion/styled';
|
|
4
4
|
import type { CSSProperties, MouseEventHandler, ReactElement } from 'react';
|
|
5
|
+
import type { DropzoneInputProps } from 'react-dropzone';
|
|
5
6
|
import * as dropzone from 'react-dropzone';
|
|
6
7
|
import tinycolor from 'tinycolor2';
|
|
7
8
|
|
|
9
|
+
// https://react-dropzone.js.org/examples/directory
|
|
10
|
+
type InputProps = DropzoneInputProps & { webkitdirectory?: 'true' };
|
|
11
|
+
|
|
8
12
|
export interface DropZoneProps extends dropzone.DropzoneOptions {
|
|
9
13
|
borderColor?: string;
|
|
10
14
|
emptyIcon?: IconName;
|
|
@@ -12,6 +16,14 @@ export interface DropZoneProps extends dropzone.DropzoneOptions {
|
|
|
12
16
|
emptyDescription?: string;
|
|
13
17
|
emptyButtonText?: string;
|
|
14
18
|
emptyButtonIcon?: IconName;
|
|
19
|
+
/**
|
|
20
|
+
* Note this mode is not standard but widely supported.
|
|
21
|
+
* Also note, if you enable this mode, you must not use `useFsAccessApi` flag.
|
|
22
|
+
*
|
|
23
|
+
* @see https://react-dropzone.js.org/examples/directory
|
|
24
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/file#webkitdirectory
|
|
25
|
+
*/
|
|
26
|
+
folderMode?: boolean;
|
|
15
27
|
}
|
|
16
28
|
|
|
17
29
|
const DropzoneRoot = styled.div`
|
|
@@ -66,11 +78,6 @@ function DropZoneContent(
|
|
|
66
78
|
props: DropZoneProps & {
|
|
67
79
|
children?: ReactElement | null;
|
|
68
80
|
onClick?: MouseEventHandler<HTMLDivElement>;
|
|
69
|
-
emptyIcon?: IconName;
|
|
70
|
-
emptyTitle?: string;
|
|
71
|
-
emptyDescription?: string;
|
|
72
|
-
emptyButtonText?: string;
|
|
73
|
-
emptyButtonIcon?: IconName;
|
|
74
81
|
},
|
|
75
82
|
) {
|
|
76
83
|
const {
|
|
@@ -83,6 +90,7 @@ function DropZoneContent(
|
|
|
83
90
|
emptyButtonText = 'Select files',
|
|
84
91
|
emptyButtonIcon = 'plus',
|
|
85
92
|
noClick,
|
|
93
|
+
folderMode = false,
|
|
86
94
|
...otherProps
|
|
87
95
|
} = props;
|
|
88
96
|
|
|
@@ -93,6 +101,10 @@ function DropZoneContent(
|
|
|
93
101
|
...otherProps,
|
|
94
102
|
});
|
|
95
103
|
|
|
104
|
+
const extraInputProps: InputProps = folderMode
|
|
105
|
+
? { webkitdirectory: 'true' }
|
|
106
|
+
: {};
|
|
107
|
+
|
|
96
108
|
return (
|
|
97
109
|
<DropzoneRoot {...getRootProps({ onClick })}>
|
|
98
110
|
{children}
|
|
@@ -118,7 +130,7 @@ function DropZoneContent(
|
|
|
118
130
|
/>
|
|
119
131
|
</DropzoneEmpty>
|
|
120
132
|
) : null}
|
|
121
|
-
<input {...getInputProps()} />
|
|
133
|
+
<input {...getInputProps(extraInputProps)} />
|
|
122
134
|
</DropzoneRoot>
|
|
123
135
|
);
|
|
124
136
|
}
|
|
@@ -7,9 +7,14 @@ export interface ParsedSplitPaneSize {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export function parseSize(size: string): ParsedSplitPaneSize {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
// eslint-disable-next-line unicorn/prefer-number-coercion
|
|
11
|
+
const value = Number.parseFloat(size);
|
|
12
|
+
// Remove numbers and dots from the string.
|
|
13
|
+
const type = size.replaceAll(/[\d .]/g, '');
|
|
14
|
+
|
|
15
|
+
if (Number.isNaN(value) || (type !== '%' && type !== 'px')) {
|
|
16
|
+
throw new Error('SplitPane size must be a number with "%" or "px" unit.');
|
|
17
|
+
}
|
|
13
18
|
|
|
14
19
|
return { value, type };
|
|
15
20
|
}
|