react-science 0.36.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/drop-zone/DropZone.d.ts +2 -4
- package/lib/components/drop-zone/DropZone.d.ts.map +1 -1
- package/lib/components/drop-zone/DropZone.js +4 -14
- package/lib/components/drop-zone/DropZone.js.map +1 -1
- package/lib/components/header/PanelHeader.d.ts.map +1 -1
- package/lib/components/header/PanelHeader.js +13 -16
- package/lib/components/header/PanelHeader.js.map +1 -1
- package/lib/components/hooks/useSelect.d.ts +14 -3
- package/lib/components/hooks/useSelect.d.ts.map +1 -1
- package/lib/components/hooks/useSelect.js +33 -7
- package/lib/components/hooks/useSelect.js.map +1 -1
- package/lib-esm/components/drop-zone/DropZone.d.ts +2 -4
- package/lib-esm/components/drop-zone/DropZone.d.ts.map +1 -1
- package/lib-esm/components/drop-zone/DropZone.js +4 -14
- package/lib-esm/components/drop-zone/DropZone.js.map +1 -1
- package/lib-esm/components/header/PanelHeader.d.ts.map +1 -1
- package/lib-esm/components/header/PanelHeader.js +13 -16
- package/lib-esm/components/header/PanelHeader.js.map +1 -1
- package/lib-esm/components/hooks/useSelect.d.ts +14 -3
- package/lib-esm/components/hooks/useSelect.d.ts.map +1 -1
- package/lib-esm/components/hooks/useSelect.js +33 -7
- package/lib-esm/components/hooks/useSelect.js.map +1 -1
- package/package.json +1 -1
- package/src/components/drop-zone/DropZone.tsx +8 -27
- package/src/components/header/PanelHeader.tsx +15 -16
- package/src/components/hooks/useSelect.tsx +72 -21
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { IconName } from '@blueprintjs/icons';
|
|
3
|
-
import {
|
|
4
|
-
export interface DropZoneProps {
|
|
3
|
+
import { DropzoneOptions } from 'react-dropzone';
|
|
4
|
+
export interface DropZoneProps extends DropzoneOptions {
|
|
5
5
|
borderColor?: string;
|
|
6
|
-
onDrop?: <T extends File>(acceptedFiles: T[], rejectedFiles?: FileRejection[]) => void;
|
|
7
|
-
fileValidator?: <T extends File>(file: T) => FileError | FileError[] | null;
|
|
8
6
|
emptyIcon?: IconName;
|
|
9
7
|
emptyTitle?: string;
|
|
10
8
|
emptyDescription?: string;
|
|
@@ -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;AAGnD,OAAO,EAAE,
|
|
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;AAGnD,OAAO,EAAE,eAAe,EAAe,MAAM,gBAAgB,CAAC;AAG9D,MAAM,WAAW,aAAc,SAAQ,eAAe;IACpD,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;CAC5B;AA0CD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,2CAE5C;AAED,MAAM,WAAW,sBAAuB,SAAQ,aAAa;IAC3D,QAAQ,EAAE,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC;CAC9B;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,2CAE9D"}
|
|
@@ -7,7 +7,6 @@ exports.DropZoneContainer = exports.DropZone = void 0;
|
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
8
|
const core_1 = require("@blueprintjs/core");
|
|
9
9
|
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
10
|
-
const react_1 = require("react");
|
|
11
10
|
const react_dropzone_1 = require("react-dropzone");
|
|
12
11
|
const tinycolor2_1 = __importDefault(require("tinycolor2"));
|
|
13
12
|
const DropzoneRoot = styled_1.default.div `
|
|
@@ -51,21 +50,12 @@ function DropZoneContainer(props) {
|
|
|
51
50
|
}
|
|
52
51
|
exports.DropZoneContainer = DropZoneContainer;
|
|
53
52
|
function DropZoneContent(props) {
|
|
54
|
-
const { borderColor = core_1.Colors.GRAY3, children = null,
|
|
53
|
+
const { borderColor = core_1.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;
|
|
55
54
|
const hasChildren = children !== null;
|
|
56
|
-
const handleOnDrop = (0, react_1.useCallback)((acceptedFiles, rejectedFiles) => {
|
|
57
|
-
onDrop?.(acceptedFiles, rejectedFiles);
|
|
58
|
-
}, [onDrop]);
|
|
59
55
|
const { getRootProps, getInputProps, isDragActive } = (0, react_dropzone_1.useDropzone)({
|
|
60
|
-
noClick: hasChildren,
|
|
61
|
-
|
|
62
|
-
onDrop: handleOnDrop,
|
|
56
|
+
noClick: noClick ?? hasChildren,
|
|
57
|
+
...otherProps,
|
|
63
58
|
});
|
|
64
|
-
|
|
65
|
-
if (onClick) {
|
|
66
|
-
return { onClick };
|
|
67
|
-
}
|
|
68
|
-
}, [onClick]);
|
|
69
|
-
return ((0, jsx_runtime_1.jsxs)(DropzoneRoot, { ...getRootProps(getPropsOptions), children: [children, isDragActive ? ((0, jsx_runtime_1.jsx)(DropzoneDragActive, { borderColor: borderColor, children: (0, jsx_runtime_1.jsx)(core_1.NonIdealState, { icon: "cloud-upload", title: "Drop the files here" }) })) : !hasChildren ? ((0, jsx_runtime_1.jsx)(DropzoneEmpty, { borderColor: borderColor, children: (0, jsx_runtime_1.jsx)(core_1.NonIdealState, { icon: emptyIcon, title: emptyTitle, description: emptyDescription, action: (0, jsx_runtime_1.jsx)(core_1.Button, { className: "dropzone-button", outlined: true, text: emptyButtonText, icon: emptyButtonIcon, intent: "primary" }) }) })) : null, (0, jsx_runtime_1.jsx)("input", { ...getInputProps() })] }));
|
|
59
|
+
return ((0, jsx_runtime_1.jsxs)(DropzoneRoot, { ...getRootProps({ onClick }), children: [children, isDragActive ? ((0, jsx_runtime_1.jsx)(DropzoneDragActive, { borderColor: borderColor, children: (0, jsx_runtime_1.jsx)(core_1.NonIdealState, { icon: "cloud-upload", title: "Drop the files here" }) })) : !hasChildren ? ((0, jsx_runtime_1.jsx)(DropzoneEmpty, { borderColor: borderColor, children: (0, jsx_runtime_1.jsx)(core_1.NonIdealState, { icon: emptyIcon, title: emptyTitle, description: emptyDescription, action: (0, jsx_runtime_1.jsx)(core_1.Button, { className: "dropzone-button", outlined: true, text: emptyButtonText, icon: emptyButtonIcon, intent: "primary" }) }) })) : null, (0, jsx_runtime_1.jsx)("input", { ...getInputProps() })] }));
|
|
70
60
|
}
|
|
71
61
|
//# sourceMappingURL=DropZone.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropZone.js","sourceRoot":"","sources":["../../../src/components/drop-zone/DropZone.tsx"],"names":[],"mappings":";;;;;;;AAAA,4CAAkE;AAElE,6DAAqC;
|
|
1
|
+
{"version":3,"file":"DropZone.js","sourceRoot":"","sources":["../../../src/components/drop-zone/DropZone.tsx"],"names":[],"mappings":";;;;;;;AAAA,4CAAkE;AAElE,6DAAqC;AAErC,mDAA8D;AAC9D,4DAAmC;AAWnC,MAAM,YAAY,GAAG,gBAAM,CAAC,GAAG,CAAA;;;;CAI9B,CAAC;AAMF,MAAM,kBAAkB,GAAG,gBAAM,CAAC,GAAG,CAAoB;;;;;;;;;;;;;kBAavC,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,CAClC,WAAW,IAAI,IAAA,oBAAS,EAAC,WAAW,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,WAAW,EA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AAC,WAAW,CAAC,CAAC,CAAC,CACjB,uBAAC,aAAa,IAAC,WAAW,EAAE,WAAW,YACrC,uBAAC,oBAAa,IACZ,IAAI,EAAE,SAAS,EACf,KAAK,EAAE,UAAU,EACjB,WAAW,EAAE,gBAAgB,EAC7B,MAAM,EACJ,uBAAC,aAAM,IACL,SAAS,EAAC,iBAAiB,EAC3B,QAAQ,QACR,IAAI,EAAE,eAAe,EACrB,IAAI,EAAE,eAAe,EACrB,MAAM,EAAC,SAAS,GAChB,GAEJ,GACY,CACjB,CAAC,CAAC,CAAC,IAAI,EACR,qCAAW,aAAa,EAAE,GAAI,IACjB,CAChB,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PanelHeader.d.ts","sourceRoot":"","sources":["../../../src/components/header/PanelHeader.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"PanelHeader.d.ts","sourceRoot":"","sources":["../../../src/components/header/PanelHeader.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AA6BlC,UAAU,gBAAgB;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;IAC7B,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,OAAO,EACP,QAAQ,EACR,eAAe,GAChB,EAAE,gBAAgB,oDAUlB"}
|
|
@@ -4,7 +4,6 @@ exports.PanelHeader = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
5
|
/** @jsxImportSource @emotion/react */
|
|
6
6
|
const react_1 = require("@emotion/react");
|
|
7
|
-
const react_2 = require("react");
|
|
8
7
|
const Button_1 = require("../button/Button");
|
|
9
8
|
const styles = {
|
|
10
9
|
container: (0, react_1.css)({
|
|
@@ -31,21 +30,19 @@ const styles = {
|
|
|
31
30
|
}),
|
|
32
31
|
};
|
|
33
32
|
function PanelHeader({ total, current, children, onClickSettings, }) {
|
|
34
|
-
|
|
35
|
-
(0, react_2.useEffect)(() => {
|
|
36
|
-
if (!labelRef.current)
|
|
37
|
-
return;
|
|
38
|
-
if (current !== undefined && total !== undefined) {
|
|
39
|
-
labelRef.current.textContent = `${current} / ${total}`;
|
|
40
|
-
}
|
|
41
|
-
else if (current !== undefined) {
|
|
42
|
-
labelRef.current.textContent = `[ ${current} ]`;
|
|
43
|
-
}
|
|
44
|
-
else if (total !== undefined) {
|
|
45
|
-
labelRef.current.textContent = `[ ${total} ]`;
|
|
46
|
-
}
|
|
47
|
-
}, [current, total]);
|
|
48
|
-
return ((0, jsx_runtime_1.jsxs)("div", { css: styles.container, children: [(0, jsx_runtime_1.jsx)("div", { css: styles.leftContainer, children: children }), (0, jsx_runtime_1.jsx)("p", { ref: labelRef, css: styles.counterLabel }), onClickSettings && ((0, jsx_runtime_1.jsx)(Button_1.Button, { color: "black", minimal: true, onClick: onClickSettings, icon: "cog" }))] }));
|
|
33
|
+
return ((0, jsx_runtime_1.jsxs)("div", { css: styles.container, children: [(0, jsx_runtime_1.jsx)("div", { css: styles.leftContainer, children: children }), (0, jsx_runtime_1.jsx)("p", { css: styles.counterLabel, children: formatCounterLabel(current, total) }), onClickSettings && ((0, jsx_runtime_1.jsx)(Button_1.Button, { color: "black", minimal: true, onClick: onClickSettings, icon: "cog" }))] }));
|
|
49
34
|
}
|
|
50
35
|
exports.PanelHeader = PanelHeader;
|
|
36
|
+
function formatCounterLabel(current, total) {
|
|
37
|
+
if (current !== undefined && total !== undefined) {
|
|
38
|
+
return `${current} / ${total}`;
|
|
39
|
+
}
|
|
40
|
+
if (current !== undefined) {
|
|
41
|
+
return `[ ${current} ]`;
|
|
42
|
+
}
|
|
43
|
+
if (total !== undefined) {
|
|
44
|
+
return `[ ${total} ]`;
|
|
45
|
+
}
|
|
46
|
+
return '';
|
|
47
|
+
}
|
|
51
48
|
//# sourceMappingURL=PanelHeader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PanelHeader.js","sourceRoot":"","sources":["../../../src/components/header/PanelHeader.tsx"],"names":[],"mappings":";;;;AAAA,sCAAsC;AACtC,0CAAqC;
|
|
1
|
+
{"version":3,"file":"PanelHeader.js","sourceRoot":"","sources":["../../../src/components/header/PanelHeader.tsx"],"names":[],"mappings":";;;;AAAA,sCAAsC;AACtC,0CAAqC;AAGrC,6CAA0C;AAE1C,MAAM,MAAM,GAAG;IACb,SAAS,EAAE,IAAA,WAAG,EAAC;QACb,OAAO,EAAE,MAAM;QACf,aAAa,EAAE,KAAK;QACpB,UAAU,EAAE,QAAQ;QACpB,cAAc,EAAE,eAAe;QAC/B,YAAY,EAAE,iCAAiC;KAChD,CAAC;IACF,aAAa,EAAE,IAAA,WAAG,EAAC;QACjB,OAAO,EAAE,MAAM;QACf,aAAa,EAAE,KAAK;QACpB,IAAI,EAAE,CAAC;QACP,YAAY,EAAE;YACZ,OAAO,EAAE,OAAO;YAChB,QAAQ,EAAE,MAAM;SACjB;KACF,CAAC;IACF,YAAY,EAAE,IAAA,WAAG,EAAC;QAChB,MAAM,EAAE,CAAC;QACT,SAAS,EAAE,OAAO;QAClB,UAAU,EAAE,MAAM;QAClB,UAAU,EAAE,QAAQ;KACrB,CAAC;CACH,CAAC;AASF,SAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,OAAO,EACP,QAAQ,EACR,eAAe,GACE;IACjB,OAAO,CACL,iCAAK,GAAG,EAAE,MAAM,CAAC,SAAS,aACxB,gCAAK,GAAG,EAAE,MAAM,CAAC,aAAa,YAAG,QAAQ,GAAO,EAChD,8BAAG,GAAG,EAAE,MAAM,CAAC,YAAY,YAAG,kBAAkB,CAAC,OAAO,EAAE,KAAK,CAAC,GAAK,EACpE,eAAe,IAAI,CAClB,uBAAC,eAAM,IAAC,KAAK,EAAC,OAAO,EAAC,OAAO,QAAC,OAAO,EAAE,eAAe,EAAE,IAAI,EAAC,KAAK,GAAG,CACtE,IACG,CACP,CAAC;AACJ,CAAC;AAfD,kCAeC;AAED,SAAS,kBAAkB,CAAC,OAAgB,EAAE,KAAc;IAC1D,IAAI,OAAO,KAAK,SAAS,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACjD,OAAO,GAAG,OAAO,MAAM,KAAK,EAAE,CAAC;IACjC,CAAC;IACD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,OAAO,KAAK,OAAO,IAAI,CAAC;IAC1B,CAAC;IACD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,KAAK,KAAK,IAAI,CAAC;IACxB,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ItemRenderer } from '@blueprintjs/select';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
3
|
+
type FilterType<SourceType, Type> = Pick<SourceType, {
|
|
4
|
+
[K in keyof SourceType]: SourceType[K] extends Type ? K : never;
|
|
5
|
+
}[keyof SourceType]>;
|
|
6
|
+
interface BaseOptions<T> {
|
|
7
|
+
itemTextKey: keyof FilterType<T, string>;
|
|
8
|
+
defaultSelectedItem?: T;
|
|
9
|
+
}
|
|
10
|
+
interface RenderOptions<T> {
|
|
11
|
+
getItemText: (item: T) => string;
|
|
12
|
+
defaultSelectedItem?: T;
|
|
13
|
+
}
|
|
14
|
+
type SelectOptions<T> = BaseOptions<T> | RenderOptions<T>;
|
|
15
|
+
export declare function useSelect<T>(options: SelectOptions<T>): {
|
|
6
16
|
value: T | null;
|
|
7
17
|
setValue: import("react").Dispatch<import("react").SetStateAction<T | null>>;
|
|
8
18
|
itemRenderer: ItemRenderer<T>;
|
|
@@ -18,4 +28,5 @@ export declare function useSelect<T extends {
|
|
|
18
28
|
itemPredicate: (query: string, item: T) => boolean;
|
|
19
29
|
itemListPredicate: (query: string, items: T[]) => T[];
|
|
20
30
|
};
|
|
31
|
+
export {};
|
|
21
32
|
//# sourceMappingURL=useSelect.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSelect.d.ts","sourceRoot":"","sources":["../../../src/components/hooks/useSelect.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGnD,
|
|
1
|
+
{"version":3,"file":"useSelect.d.ts","sourceRoot":"","sources":["../../../src/components/hooks/useSelect.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGnD,KAAK,UAAU,CAAC,UAAU,EAAE,IAAI,IAAI,IAAI,CACtC,UAAU,EACV;KACG,CAAC,IAAI,MAAM,UAAU,GAAG,UAAU,CAAC,CAAC,CAAC,SAAS,IAAI,GAAG,CAAC,GAAG,KAAK;CAChE,CAAC,MAAM,UAAU,CAAC,CACpB,CAAC;AAEF,UAAU,WAAW,CAAC,CAAC;IACrB,WAAW,EAAE,MAAM,UAAU,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IACzC,mBAAmB,CAAC,EAAE,CAAC,CAAC;CACzB;AAED,UAAU,aAAa,CAAC,CAAC;IACvB,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;IACjC,mBAAmB,CAAC,EAAE,CAAC,CAAC;CACzB;AAED,KAAK,aAAa,CAAC,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;AAsB1D,wBAAgB,SAAS,CAAC,CAAC,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC;;;;;;yBAOjC,WAAW;;;;;;;2BAWA,MAAM,QAAQ,CAAC;+BAKX,MAAM,SAAS,CAAC,EAAE;EAiBrD"}
|
|
@@ -4,9 +4,23 @@ exports.useSelect = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const core_1 = require("@blueprintjs/core");
|
|
6
6
|
const react_1 = require("react");
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
function isAccessLabelByKey(options) {
|
|
8
|
+
return 'itemTextKey' in options;
|
|
9
|
+
}
|
|
10
|
+
function getLabel(item, options) {
|
|
11
|
+
const isAccessLByLabelKey = isAccessLabelByKey(options);
|
|
12
|
+
if (!item || (isAccessLByLabelKey && !options.itemTextKey)) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
if (isAccessLByLabelKey) {
|
|
16
|
+
return item[options.itemTextKey];
|
|
17
|
+
}
|
|
18
|
+
return options.getItemText(item);
|
|
19
|
+
}
|
|
20
|
+
function useSelect(options) {
|
|
21
|
+
const { defaultSelectedItem = null } = options;
|
|
22
|
+
const [value, setValue] = (0, react_1.useState)(defaultSelectedItem);
|
|
23
|
+
const itemRenderer = getItemRenderer(value, options);
|
|
10
24
|
const onItemSelect = setValue;
|
|
11
25
|
const popoverProps = {
|
|
12
26
|
onOpened: (node) => {
|
|
@@ -21,10 +35,18 @@ function useSelect() {
|
|
|
21
35
|
style: { display: 'inline-block' },
|
|
22
36
|
};
|
|
23
37
|
const itemPredicate = (query, item) => {
|
|
24
|
-
|
|
38
|
+
const label = getLabel(item, options);
|
|
39
|
+
if (!label)
|
|
40
|
+
return false;
|
|
41
|
+
return label.toLowerCase().includes(query.toLowerCase());
|
|
25
42
|
};
|
|
26
43
|
const itemListPredicate = (query, items) => {
|
|
27
|
-
return items.filter((item) =>
|
|
44
|
+
return items.filter((item) => {
|
|
45
|
+
const label = getLabel(item, options);
|
|
46
|
+
if (!label)
|
|
47
|
+
return false;
|
|
48
|
+
return label.toLowerCase().includes(query.toLowerCase());
|
|
49
|
+
});
|
|
28
50
|
};
|
|
29
51
|
return {
|
|
30
52
|
value,
|
|
@@ -38,8 +60,12 @@ function useSelect() {
|
|
|
38
60
|
};
|
|
39
61
|
}
|
|
40
62
|
exports.useSelect = useSelect;
|
|
41
|
-
function getItemRenderer(value) {
|
|
42
|
-
const
|
|
63
|
+
function getItemRenderer(value, options) {
|
|
64
|
+
const selectedLabel = getLabel(value, options);
|
|
65
|
+
const render = (item, { handleClick, handleFocus, modifiers, index }) => {
|
|
66
|
+
const label = getLabel(item, options);
|
|
67
|
+
return ((0, jsx_runtime_1.jsx)(core_1.MenuItem, { active: modifiers.active, disabled: modifiers.disabled, selected: selectedLabel === label, onClick: handleClick, onFocus: handleFocus, roleStructure: "listoption", text: label }, index));
|
|
68
|
+
};
|
|
43
69
|
return render;
|
|
44
70
|
}
|
|
45
71
|
//# sourceMappingURL=useSelect.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSelect.js","sourceRoot":"","sources":["../../../src/components/hooks/useSelect.tsx"],"names":[],"mappings":";;;;AAAA,4CAA6C;AAE7C,iCAAiC;
|
|
1
|
+
{"version":3,"file":"useSelect.js","sourceRoot":"","sources":["../../../src/components/hooks/useSelect.tsx"],"names":[],"mappings":";;;;AAAA,4CAA6C;AAE7C,iCAAiC;AAqBjC,SAAS,kBAAkB,CACzB,OAAyB;IAEzB,OAAO,aAAa,IAAI,OAAO,CAAC;AAClC,CAAC;AAED,SAAS,QAAQ,CAAI,IAAO,EAAE,OAAyB;IACrD,MAAM,mBAAmB,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAExD,IAAI,CAAC,IAAI,IAAI,CAAC,mBAAmB,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;QAC3D,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,mBAAmB,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAW,CAAC;IAC7C,CAAC;IAED,OAAO,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;AACnC,CAAC;AAED,SAAgB,SAAS,CAAI,OAAyB;IACp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C,CAAC;QAC3D,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IACF,OAAO;QACL,KAAK;QACL,QAAQ;QACR,YAAY;QACZ,YAAY;QACZ,YAAY;QACZ,kBAAkB;QAClB,aAAa;QACb,iBAAiB;KAClB,CAAC;AACJ,CAAC;AAxCD,8BAwCC;AAED,SAAS,eAAe,CAAI,KAAQ,EAAE,OAAyB;IAC7D,MAAM,aAAa,GAAG,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAE/C,MAAM,MAAM,GAAoB,CAC9B,IAAI,EACJ,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,EAC9C,EAAE;QACF,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACtC,OAAO,CACL,uBAAC,eAAQ,IACP,MAAM,EAAE,SAAS,CAAC,MAAM,EACxB,QAAQ,EAAE,SAAS,CAAC,QAAQ,EAC5B,QAAQ,EAAE,aAAa,KAAK,KAAK,EAEjC,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,WAAW,EACpB,aAAa,EAAC,YAAY,EAC1B,IAAI,EAAE,KAAK,IAJN,KAAK,CAKV,CACH,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { IconName } from '@blueprintjs/icons';
|
|
3
|
-
import {
|
|
4
|
-
export interface DropZoneProps {
|
|
3
|
+
import { DropzoneOptions } from 'react-dropzone';
|
|
4
|
+
export interface DropZoneProps extends DropzoneOptions {
|
|
5
5
|
borderColor?: string;
|
|
6
|
-
onDrop?: <T extends File>(acceptedFiles: T[], rejectedFiles?: FileRejection[]) => void;
|
|
7
|
-
fileValidator?: <T extends File>(file: T) => FileError | FileError[] | null;
|
|
8
6
|
emptyIcon?: IconName;
|
|
9
7
|
emptyTitle?: string;
|
|
10
8
|
emptyDescription?: string;
|
|
@@ -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;AAGnD,OAAO,EAAE,
|
|
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;AAGnD,OAAO,EAAE,eAAe,EAAe,MAAM,gBAAgB,CAAC;AAG9D,MAAM,WAAW,aAAc,SAAQ,eAAe;IACpD,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;CAC5B;AA0CD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,2CAE5C;AAED,MAAM,WAAW,sBAAuB,SAAQ,aAAa;IAC3D,QAAQ,EAAE,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC;CAC9B;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,2CAE9D"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Button, Colors, NonIdealState } from '@blueprintjs/core';
|
|
3
3
|
import styled from '@emotion/styled';
|
|
4
|
-
import { useCallback, useMemo } from 'react';
|
|
5
4
|
import { useDropzone } from 'react-dropzone';
|
|
6
5
|
import tinycolor from 'tinycolor2';
|
|
7
6
|
const DropzoneRoot = styled.div `
|
|
@@ -43,21 +42,12 @@ export function DropZoneContainer(props) {
|
|
|
43
42
|
return _jsx(DropZoneContent, { ...props });
|
|
44
43
|
}
|
|
45
44
|
function DropZoneContent(props) {
|
|
46
|
-
const { borderColor = Colors.GRAY3, children = null,
|
|
45
|
+
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;
|
|
47
46
|
const hasChildren = children !== null;
|
|
48
|
-
const handleOnDrop = useCallback((acceptedFiles, rejectedFiles) => {
|
|
49
|
-
onDrop?.(acceptedFiles, rejectedFiles);
|
|
50
|
-
}, [onDrop]);
|
|
51
47
|
const { getRootProps, getInputProps, isDragActive } = useDropzone({
|
|
52
|
-
noClick: hasChildren,
|
|
53
|
-
|
|
54
|
-
onDrop: handleOnDrop,
|
|
48
|
+
noClick: noClick ?? hasChildren,
|
|
49
|
+
...otherProps,
|
|
55
50
|
});
|
|
56
|
-
|
|
57
|
-
if (onClick) {
|
|
58
|
-
return { onClick };
|
|
59
|
-
}
|
|
60
|
-
}, [onClick]);
|
|
61
|
-
return (_jsxs(DropzoneRoot, { ...getRootProps(getPropsOptions), 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", outlined: true, text: emptyButtonText, icon: emptyButtonIcon, intent: "primary" }) }) })) : null, _jsx("input", { ...getInputProps() })] }));
|
|
51
|
+
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", outlined: true, text: emptyButtonText, icon: emptyButtonIcon, intent: "primary" }) }) })) : null, _jsx("input", { ...getInputProps() })] }));
|
|
62
52
|
}
|
|
63
53
|
//# 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;AAErC,OAAO,EAAmB,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,SAAS,MAAM,YAAY,CAAC;AAWnC,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAA;;;;CAI9B,CAAC;AAMF,MAAM,kBAAkB,GAAG,MAAM,CAAC,GAAG,CAAoB;;;;;;;;;;;;;kBAavC,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,CAClC,WAAW,IAAI,SAAS,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE;CACpE,CAAC;AAEF,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAoB;;wBAE5B,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE;;;;;;;;kBAQ1D,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,WAAW;CACjD,CAAC;AAEF,MAAM,UAAU,QAAQ,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,GAChB,GAEJ,GACY,CACjB,CAAC,CAAC,CAAC,IAAI,EACR,mBAAW,aAAa,EAAE,GAAI,IACjB,CAChB,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PanelHeader.d.ts","sourceRoot":"","sources":["../../../src/components/header/PanelHeader.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"PanelHeader.d.ts","sourceRoot":"","sources":["../../../src/components/header/PanelHeader.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AA6BlC,UAAU,gBAAgB;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;IAC7B,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,OAAO,EACP,QAAQ,EACR,eAAe,GAChB,EAAE,gBAAgB,oDAUlB"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
2
|
/** @jsxImportSource @emotion/react */
|
|
3
3
|
import { css } from '@emotion/react';
|
|
4
|
-
import { useEffect, useRef } from 'react';
|
|
5
4
|
import { Button } from '../button/Button';
|
|
6
5
|
const styles = {
|
|
7
6
|
container: css({
|
|
@@ -28,20 +27,18 @@ const styles = {
|
|
|
28
27
|
}),
|
|
29
28
|
};
|
|
30
29
|
export function PanelHeader({ total, current, children, onClickSettings, }) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}, [current, total]);
|
|
45
|
-
return (_jsxs("div", { css: styles.container, children: [_jsx("div", { css: styles.leftContainer, children: children }), _jsx("p", { ref: labelRef, css: styles.counterLabel }), onClickSettings && (_jsx(Button, { color: "black", minimal: true, onClick: onClickSettings, icon: "cog" }))] }));
|
|
30
|
+
return (_jsxs("div", { css: styles.container, children: [_jsx("div", { css: styles.leftContainer, children: children }), _jsx("p", { css: styles.counterLabel, children: formatCounterLabel(current, total) }), onClickSettings && (_jsx(Button, { color: "black", minimal: true, onClick: onClickSettings, icon: "cog" }))] }));
|
|
31
|
+
}
|
|
32
|
+
function formatCounterLabel(current, total) {
|
|
33
|
+
if (current !== undefined && total !== undefined) {
|
|
34
|
+
return `${current} / ${total}`;
|
|
35
|
+
}
|
|
36
|
+
if (current !== undefined) {
|
|
37
|
+
return `[ ${current} ]`;
|
|
38
|
+
}
|
|
39
|
+
if (total !== undefined) {
|
|
40
|
+
return `[ ${total} ]`;
|
|
41
|
+
}
|
|
42
|
+
return '';
|
|
46
43
|
}
|
|
47
44
|
//# sourceMappingURL=PanelHeader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PanelHeader.js","sourceRoot":"","sources":["../../../src/components/header/PanelHeader.tsx"],"names":[],"mappings":";AAAA,sCAAsC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"PanelHeader.js","sourceRoot":"","sources":["../../../src/components/header/PanelHeader.tsx"],"names":[],"mappings":";AAAA,sCAAsC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAGrC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,MAAM,MAAM,GAAG;IACb,SAAS,EAAE,GAAG,CAAC;QACb,OAAO,EAAE,MAAM;QACf,aAAa,EAAE,KAAK;QACpB,UAAU,EAAE,QAAQ;QACpB,cAAc,EAAE,eAAe;QAC/B,YAAY,EAAE,iCAAiC;KAChD,CAAC;IACF,aAAa,EAAE,GAA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js/select';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
3
|
+
type FilterType<SourceType, Type> = Pick<SourceType, {
|
|
4
|
+
[K in keyof SourceType]: SourceType[K] extends Type ? K : never;
|
|
5
|
+
}[keyof SourceType]>;
|
|
6
|
+
interface BaseOptions<T> {
|
|
7
|
+
itemTextKey: keyof FilterType<T, string>;
|
|
8
|
+
defaultSelectedItem?: T;
|
|
9
|
+
}
|
|
10
|
+
interface RenderOptions<T> {
|
|
11
|
+
getItemText: (item: T) => string;
|
|
12
|
+
defaultSelectedItem?: T;
|
|
13
|
+
}
|
|
14
|
+
type SelectOptions<T> = BaseOptions<T> | RenderOptions<T>;
|
|
15
|
+
export declare function useSelect<T>(options: SelectOptions<T>): {
|
|
6
16
|
value: T | null;
|
|
7
17
|
setValue: import("react").Dispatch<import("react").SetStateAction<T | null>>;
|
|
8
18
|
itemRenderer: ItemRenderer<T>;
|
|
@@ -18,4 +28,5 @@ export declare function useSelect<T extends {
|
|
|
18
28
|
itemPredicate: (query: string, item: T) => boolean;
|
|
19
29
|
itemListPredicate: (query: string, items: T[]) => T[];
|
|
20
30
|
};
|
|
31
|
+
export {};
|
|
21
32
|
//# sourceMappingURL=useSelect.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSelect.d.ts","sourceRoot":"","sources":["../../../src/components/hooks/useSelect.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGnD,
|
|
1
|
+
{"version":3,"file":"useSelect.d.ts","sourceRoot":"","sources":["../../../src/components/hooks/useSelect.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGnD,KAAK,UAAU,CAAC,UAAU,EAAE,IAAI,IAAI,IAAI,CACtC,UAAU,EACV;KACG,CAAC,IAAI,MAAM,UAAU,GAAG,UAAU,CAAC,CAAC,CAAC,SAAS,IAAI,GAAG,CAAC,GAAG,KAAK;CAChE,CAAC,MAAM,UAAU,CAAC,CACpB,CAAC;AAEF,UAAU,WAAW,CAAC,CAAC;IACrB,WAAW,EAAE,MAAM,UAAU,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IACzC,mBAAmB,CAAC,EAAE,CAAC,CAAC;CACzB;AAED,UAAU,aAAa,CAAC,CAAC;IACvB,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;IACjC,mBAAmB,CAAC,EAAE,CAAC,CAAC;CACzB;AAED,KAAK,aAAa,CAAC,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;AAsB1D,wBAAgB,SAAS,CAAC,CAAC,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC;;;;;;yBAOjC,WAAW;;;;;;;2BAWA,MAAM,QAAQ,CAAC;+BAKX,MAAM,SAAS,CAAC,EAAE;EAiBrD"}
|
|
@@ -1,9 +1,23 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { MenuItem } from '@blueprintjs/core';
|
|
3
3
|
import { useState } from 'react';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
function isAccessLabelByKey(options) {
|
|
5
|
+
return 'itemTextKey' in options;
|
|
6
|
+
}
|
|
7
|
+
function getLabel(item, options) {
|
|
8
|
+
const isAccessLByLabelKey = isAccessLabelByKey(options);
|
|
9
|
+
if (!item || (isAccessLByLabelKey && !options.itemTextKey)) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
if (isAccessLByLabelKey) {
|
|
13
|
+
return item[options.itemTextKey];
|
|
14
|
+
}
|
|
15
|
+
return options.getItemText(item);
|
|
16
|
+
}
|
|
17
|
+
export function useSelect(options) {
|
|
18
|
+
const { defaultSelectedItem = null } = options;
|
|
19
|
+
const [value, setValue] = useState(defaultSelectedItem);
|
|
20
|
+
const itemRenderer = getItemRenderer(value, options);
|
|
7
21
|
const onItemSelect = setValue;
|
|
8
22
|
const popoverProps = {
|
|
9
23
|
onOpened: (node) => {
|
|
@@ -18,10 +32,18 @@ export function useSelect() {
|
|
|
18
32
|
style: { display: 'inline-block' },
|
|
19
33
|
};
|
|
20
34
|
const itemPredicate = (query, item) => {
|
|
21
|
-
|
|
35
|
+
const label = getLabel(item, options);
|
|
36
|
+
if (!label)
|
|
37
|
+
return false;
|
|
38
|
+
return label.toLowerCase().includes(query.toLowerCase());
|
|
22
39
|
};
|
|
23
40
|
const itemListPredicate = (query, items) => {
|
|
24
|
-
return items.filter((item) =>
|
|
41
|
+
return items.filter((item) => {
|
|
42
|
+
const label = getLabel(item, options);
|
|
43
|
+
if (!label)
|
|
44
|
+
return false;
|
|
45
|
+
return label.toLowerCase().includes(query.toLowerCase());
|
|
46
|
+
});
|
|
25
47
|
};
|
|
26
48
|
return {
|
|
27
49
|
value,
|
|
@@ -34,8 +56,12 @@ export function useSelect() {
|
|
|
34
56
|
itemListPredicate,
|
|
35
57
|
};
|
|
36
58
|
}
|
|
37
|
-
function getItemRenderer(value) {
|
|
38
|
-
const
|
|
59
|
+
function getItemRenderer(value, options) {
|
|
60
|
+
const selectedLabel = getLabel(value, options);
|
|
61
|
+
const render = (item, { handleClick, handleFocus, modifiers, index }) => {
|
|
62
|
+
const label = getLabel(item, options);
|
|
63
|
+
return (_jsx(MenuItem, { active: modifiers.active, disabled: modifiers.disabled, selected: selectedLabel === label, onClick: handleClick, onFocus: handleFocus, roleStructure: "listoption", text: label }, index));
|
|
64
|
+
};
|
|
39
65
|
return render;
|
|
40
66
|
}
|
|
41
67
|
//# sourceMappingURL=useSelect.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSelect.js","sourceRoot":"","sources":["../../../src/components/hooks/useSelect.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAAE,QAAQ,EAAE,MA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,EAAE,SAAS,CAAC,MAAM,EACxB,QAAQ,EAAE,SAAS,CAAC,QAAQ,EAC5B,QAAQ,EAAE,aAAa,KAAK,KAAK,EAEjC,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,WAAW,EACpB,aAAa,EAAC,YAAY,EAC1B,IAAI,EAAE,KAAK,IAJN,KAAK,CAKV,CACH,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
import { Button, Colors, NonIdealState } from '@blueprintjs/core';
|
|
2
2
|
import type { IconName } from '@blueprintjs/icons';
|
|
3
3
|
import styled from '@emotion/styled';
|
|
4
|
-
import { CSSProperties, MouseEventHandler
|
|
5
|
-
import {
|
|
4
|
+
import { CSSProperties, MouseEventHandler } from 'react';
|
|
5
|
+
import { DropzoneOptions, useDropzone } from 'react-dropzone';
|
|
6
6
|
import tinycolor from 'tinycolor2';
|
|
7
7
|
|
|
8
|
-
export interface DropZoneProps {
|
|
8
|
+
export interface DropZoneProps extends DropzoneOptions {
|
|
9
9
|
borderColor?: string;
|
|
10
|
-
onDrop?: <T extends File>(
|
|
11
|
-
acceptedFiles: T[],
|
|
12
|
-
rejectedFiles?: FileRejection[],
|
|
13
|
-
) => void;
|
|
14
|
-
fileValidator?: <T extends File>(file: T) => FileError | FileError[] | null;
|
|
15
10
|
emptyIcon?: IconName;
|
|
16
11
|
emptyTitle?: string;
|
|
17
12
|
emptyDescription?: string;
|
|
@@ -85,39 +80,25 @@ function DropZoneContent(
|
|
|
85
80
|
const {
|
|
86
81
|
borderColor = Colors.GRAY3,
|
|
87
82
|
children = null,
|
|
88
|
-
onDrop,
|
|
89
83
|
onClick,
|
|
90
|
-
fileValidator,
|
|
91
84
|
emptyIcon = 'import',
|
|
92
85
|
emptyTitle = 'No data loaded',
|
|
93
86
|
emptyDescription = 'You can load data by drag-and-dropping files here',
|
|
94
87
|
emptyButtonText = 'Select files',
|
|
95
88
|
emptyButtonIcon = 'plus',
|
|
89
|
+
noClick,
|
|
90
|
+
...otherProps
|
|
96
91
|
} = props;
|
|
97
92
|
|
|
98
93
|
const hasChildren = children !== null;
|
|
99
94
|
|
|
100
|
-
const handleOnDrop = useCallback(
|
|
101
|
-
<T extends File>(acceptedFiles: T[], rejectedFiles: FileRejection[]) => {
|
|
102
|
-
onDrop?.(acceptedFiles, rejectedFiles);
|
|
103
|
-
},
|
|
104
|
-
[onDrop],
|
|
105
|
-
);
|
|
106
|
-
|
|
107
95
|
const { getRootProps, getInputProps, isDragActive } = useDropzone({
|
|
108
|
-
noClick: hasChildren,
|
|
109
|
-
|
|
110
|
-
onDrop: handleOnDrop,
|
|
96
|
+
noClick: noClick ?? hasChildren,
|
|
97
|
+
...otherProps,
|
|
111
98
|
});
|
|
112
99
|
|
|
113
|
-
const getPropsOptions = useMemo(() => {
|
|
114
|
-
if (onClick) {
|
|
115
|
-
return { onClick };
|
|
116
|
-
}
|
|
117
|
-
}, [onClick]);
|
|
118
|
-
|
|
119
100
|
return (
|
|
120
|
-
<DropzoneRoot {...getRootProps(
|
|
101
|
+
<DropzoneRoot {...getRootProps({ onClick })}>
|
|
121
102
|
{children}
|
|
122
103
|
{isDragActive ? (
|
|
123
104
|
<DropzoneDragActive borderColor={borderColor}>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** @jsxImportSource @emotion/react */
|
|
2
2
|
import { css } from '@emotion/react';
|
|
3
|
-
import { ReactNode
|
|
3
|
+
import { ReactNode } from 'react';
|
|
4
4
|
|
|
5
5
|
import { Button } from '../button/Button';
|
|
6
6
|
|
|
@@ -42,27 +42,26 @@ export function PanelHeader({
|
|
|
42
42
|
children,
|
|
43
43
|
onClickSettings,
|
|
44
44
|
}: PanelHeaderProps) {
|
|
45
|
-
const labelRef = useRef<HTMLParagraphElement>(null);
|
|
46
|
-
|
|
47
|
-
useEffect(() => {
|
|
48
|
-
if (!labelRef.current) return;
|
|
49
|
-
|
|
50
|
-
if (current !== undefined && total !== undefined) {
|
|
51
|
-
labelRef.current.textContent = `${current} / ${total}`;
|
|
52
|
-
} else if (current !== undefined) {
|
|
53
|
-
labelRef.current.textContent = `[ ${current} ]`;
|
|
54
|
-
} else if (total !== undefined) {
|
|
55
|
-
labelRef.current.textContent = `[ ${total} ]`;
|
|
56
|
-
}
|
|
57
|
-
}, [current, total]);
|
|
58
|
-
|
|
59
45
|
return (
|
|
60
46
|
<div css={styles.container}>
|
|
61
47
|
<div css={styles.leftContainer}>{children}</div>
|
|
62
|
-
<p
|
|
48
|
+
<p css={styles.counterLabel}>{formatCounterLabel(current, total)}</p>
|
|
63
49
|
{onClickSettings && (
|
|
64
50
|
<Button color="black" minimal onClick={onClickSettings} icon="cog" />
|
|
65
51
|
)}
|
|
66
52
|
</div>
|
|
67
53
|
);
|
|
68
54
|
}
|
|
55
|
+
|
|
56
|
+
function formatCounterLabel(current?: number, total?: number) {
|
|
57
|
+
if (current !== undefined && total !== undefined) {
|
|
58
|
+
return `${current} / ${total}`;
|
|
59
|
+
}
|
|
60
|
+
if (current !== undefined) {
|
|
61
|
+
return `[ ${current} ]`;
|
|
62
|
+
}
|
|
63
|
+
if (total !== undefined) {
|
|
64
|
+
return `[ ${total} ]`;
|
|
65
|
+
}
|
|
66
|
+
return '';
|
|
67
|
+
}
|
|
@@ -2,9 +2,50 @@ import { MenuItem } from '@blueprintjs/core';
|
|
|
2
2
|
import { ItemRenderer } from '@blueprintjs/select';
|
|
3
3
|
import { useState } from 'react';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
type FilterType<SourceType, Type> = Pick<
|
|
6
|
+
SourceType,
|
|
7
|
+
{
|
|
8
|
+
[K in keyof SourceType]: SourceType[K] extends Type ? K : never;
|
|
9
|
+
}[keyof SourceType]
|
|
10
|
+
>;
|
|
11
|
+
|
|
12
|
+
interface BaseOptions<T> {
|
|
13
|
+
itemTextKey: keyof FilterType<T, string>;
|
|
14
|
+
defaultSelectedItem?: T;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface RenderOptions<T> {
|
|
18
|
+
getItemText: (item: T) => string;
|
|
19
|
+
defaultSelectedItem?: T;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
type SelectOptions<T> = BaseOptions<T> | RenderOptions<T>;
|
|
23
|
+
|
|
24
|
+
function isAccessLabelByKey<T>(
|
|
25
|
+
options: SelectOptions<T>,
|
|
26
|
+
): options is BaseOptions<T> {
|
|
27
|
+
return 'itemTextKey' in options;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function getLabel<T>(item: T, options: SelectOptions<T>) {
|
|
31
|
+
const isAccessLByLabelKey = isAccessLabelByKey(options);
|
|
32
|
+
|
|
33
|
+
if (!item || (isAccessLByLabelKey && !options.itemTextKey)) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (isAccessLByLabelKey) {
|
|
38
|
+
return item[options.itemTextKey] as string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return options.getItemText(item);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function useSelect<T>(options: SelectOptions<T>) {
|
|
45
|
+
const { defaultSelectedItem = null } = options;
|
|
46
|
+
|
|
47
|
+
const [value, setValue] = useState<T | null>(defaultSelectedItem);
|
|
48
|
+
const itemRenderer = getItemRenderer(value as T, options);
|
|
8
49
|
const onItemSelect = setValue;
|
|
9
50
|
const popoverProps = {
|
|
10
51
|
onOpened: (node: HTMLElement) => {
|
|
@@ -19,12 +60,16 @@ export function useSelect<T extends { label: string }>() {
|
|
|
19
60
|
style: { display: 'inline-block' },
|
|
20
61
|
};
|
|
21
62
|
const itemPredicate = (query: string, item: T) => {
|
|
22
|
-
|
|
63
|
+
const label = getLabel(item, options);
|
|
64
|
+
if (!label) return false;
|
|
65
|
+
return label.toLowerCase().includes(query.toLowerCase());
|
|
23
66
|
};
|
|
24
67
|
const itemListPredicate = (query: string, items: T[]) => {
|
|
25
|
-
return items.filter((item) =>
|
|
26
|
-
|
|
27
|
-
|
|
68
|
+
return items.filter((item) => {
|
|
69
|
+
const label = getLabel(item, options);
|
|
70
|
+
if (!label) return false;
|
|
71
|
+
return label.toLowerCase().includes(query.toLowerCase());
|
|
72
|
+
});
|
|
28
73
|
};
|
|
29
74
|
return {
|
|
30
75
|
value,
|
|
@@ -38,21 +83,27 @@ export function useSelect<T extends { label: string }>() {
|
|
|
38
83
|
};
|
|
39
84
|
}
|
|
40
85
|
|
|
41
|
-
function getItemRenderer<T
|
|
86
|
+
function getItemRenderer<T>(value: T, options: SelectOptions<T>) {
|
|
87
|
+
const selectedLabel = getLabel(value, options);
|
|
88
|
+
|
|
42
89
|
const render: ItemRenderer<T> = (
|
|
43
|
-
|
|
90
|
+
item,
|
|
44
91
|
{ handleClick, handleFocus, modifiers, index },
|
|
45
|
-
) =>
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
92
|
+
) => {
|
|
93
|
+
const label = getLabel(item, options);
|
|
94
|
+
return (
|
|
95
|
+
<MenuItem
|
|
96
|
+
active={modifiers.active}
|
|
97
|
+
disabled={modifiers.disabled}
|
|
98
|
+
selected={selectedLabel === label}
|
|
99
|
+
key={index}
|
|
100
|
+
onClick={handleClick}
|
|
101
|
+
onFocus={handleFocus}
|
|
102
|
+
roleStructure="listoption"
|
|
103
|
+
text={label}
|
|
104
|
+
/>
|
|
105
|
+
);
|
|
106
|
+
};
|
|
107
|
+
|
|
57
108
|
return render;
|
|
58
109
|
}
|