@weng-lab/genomebrowser-ui 0.1.1
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/dist/TrackSelect/Data/modifiedHumanTracks.json.d.ts +37222 -0
- package/dist/TrackSelect/DataGrid/CustomToolbar.d.ts +12 -0
- package/dist/TrackSelect/DataGrid/DataGridWrapper.d.ts +2 -0
- package/dist/TrackSelect/DataGrid/columns.d.ts +4 -0
- package/dist/TrackSelect/DataGrid/dataGridHelpers.d.ts +30 -0
- package/dist/TrackSelect/TrackSelect.d.ts +5 -0
- package/dist/TrackSelect/TreeView/TreeViewWrapper.d.ts +2 -0
- package/dist/TrackSelect/TreeView/treeViewHelpers.d.ts +49 -0
- package/dist/TrackSelect/consts.d.ts +21 -0
- package/dist/TrackSelect/store.d.ts +4 -0
- package/dist/TrackSelect/types.d.ts +123 -0
- package/dist/genomebrowser-ui.es.js +2299 -0
- package/dist/genomebrowser-ui.es.js.map +1 -0
- package/dist/lib.d.ts +4 -0
- package/eslint.config.js +30 -0
- package/index.html +14 -0
- package/package.json +47 -0
- package/src/TrackSelect/Data/humanTracks.json +35711 -0
- package/src/TrackSelect/Data/human_chromhmm_biosamples_with_all_urls.json +35716 -0
- package/src/TrackSelect/Data/modifiedHumanTracks.json +37220 -0
- package/src/TrackSelect/DataGrid/CustomToolbar.tsx +160 -0
- package/src/TrackSelect/DataGrid/DataGridWrapper.tsx +119 -0
- package/src/TrackSelect/DataGrid/columns.tsx +134 -0
- package/src/TrackSelect/DataGrid/dataGridHelpers.tsx +114 -0
- package/src/TrackSelect/TrackSelect.tsx +258 -0
- package/src/TrackSelect/TreeView/TreeViewWrapper.tsx +115 -0
- package/src/TrackSelect/TreeView/treeViewHelpers.tsx +428 -0
- package/src/TrackSelect/bug.md +4 -0
- package/src/TrackSelect/consts.ts +92 -0
- package/src/TrackSelect/store.ts +26 -0
- package/src/TrackSelect/types.ts +139 -0
- package/src/lib.ts +8 -0
- package/test/main.tsx +13 -0
- package/tsconfig.app.json +25 -0
- package/tsconfig.json +4 -0
- package/tsconfig.node.json +25 -0
- package/vite.config.ts +66 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { GridToolbarProps, ToolbarPropsOverrides } from '@mui/x-data-grid-premium';
|
|
2
|
+
import { DataGridProps } from '../types';
|
|
3
|
+
type CustomToolbarProps = {
|
|
4
|
+
label: DataGridProps["label"];
|
|
5
|
+
downloadFileName: DataGridProps["downloadFileName"];
|
|
6
|
+
labelTooltip: DataGridProps["labelTooltip"];
|
|
7
|
+
toolbarSlot?: DataGridProps["toolbarSlot"];
|
|
8
|
+
toolbarStyle?: DataGridProps["toolbarStyle"];
|
|
9
|
+
toolbarIconColor?: DataGridProps["toolbarIconColor"];
|
|
10
|
+
} & GridToolbarProps & ToolbarPropsOverrides;
|
|
11
|
+
export declare function CustomToolbar({ label, downloadFileName, labelTooltip, toolbarSlot, toolbarStyle, toolbarIconColor, ...restToolbarProps }: CustomToolbarProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { FuseResult } from 'fuse.js';
|
|
2
|
+
import { RowInfo, SearchTracksProps, TrackInfo } from '../types';
|
|
3
|
+
export declare function getTracksByAssayAndOntology(assay: string, ontology: string): TrackInfo[];
|
|
4
|
+
/** Flatten TrackInfo or FuseResult into RowInfo for DataGrid display.
|
|
5
|
+
* @param track TrackInfo object or FuseResult containing information from JSON file
|
|
6
|
+
* @returns Flattened RowInfo object
|
|
7
|
+
*/
|
|
8
|
+
export declare function flattenIntoRow(track: TrackInfo): RowInfo;
|
|
9
|
+
/**
|
|
10
|
+
* Fuzzy search in tracks stored in a JSON file.
|
|
11
|
+
*
|
|
12
|
+
* @param jsonStructure - Dot-separated path to the data array in the JSON structure.
|
|
13
|
+
* @param query - The search query string.
|
|
14
|
+
* @param keyWeightMap - Array of keys to search within each track object.
|
|
15
|
+
* Can look like ["name", "author"] or if weighted, [
|
|
16
|
+
{
|
|
17
|
+
name: 'title',
|
|
18
|
+
weight: 0.3
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: 'author',
|
|
22
|
+
weight: 0.7
|
|
23
|
+
}
|
|
24
|
+
].
|
|
25
|
+
* @param threshold - (Optional) Threshold for the fuzzy search (default is 0.5).
|
|
26
|
+
* Smaller = stricter match, larger = fuzzier since 0 is perfect match and 1 is worst match.
|
|
27
|
+
* @param limit - (Optional) Maximum number of results to return (default is 10).
|
|
28
|
+
* @returns FuseResult object containing the search results.
|
|
29
|
+
*/
|
|
30
|
+
export declare function searchTracks({ jsonStructure, query, keyWeightMap, threshold, }: SearchTracksProps): FuseResult<TrackInfo>[];
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { TreeViewBaseItem } from '@mui/x-tree-view';
|
|
2
|
+
import { default as React } from 'react';
|
|
3
|
+
import { CustomTreeItemProps, ExtendedTreeItemProps, RowInfo, SearchTracksProps } from '../types';
|
|
4
|
+
import { FuseResult } from 'fuse.js';
|
|
5
|
+
/**
|
|
6
|
+
* Builds tree in the sorted by assay view
|
|
7
|
+
* @param selectedIds: list of ids (from useSelectionStore)
|
|
8
|
+
* @param root: Root TreeViewBaseItem
|
|
9
|
+
* @param rowById: Mapping between an id (experimentAccession) and its RowInfo object
|
|
10
|
+
* @returns all of the items for the RichTreeView in TreeViewWrapper
|
|
11
|
+
*/
|
|
12
|
+
export declare function buildSortedAssayTreeView(selectedIds: string[], root: TreeViewBaseItem<ExtendedTreeItemProps>, rowById: Map<string, RowInfo>): TreeViewBaseItem<ExtendedTreeItemProps>[];
|
|
13
|
+
/**
|
|
14
|
+
* Builds tree in the sorted by assay view
|
|
15
|
+
* @param selectedIds: list of ids (from useSelectionStore)
|
|
16
|
+
* @param root: Root TreeViewBaseItem
|
|
17
|
+
* @param rowById: Mapping between an id (experimentAccession) and its RowInfo object
|
|
18
|
+
* @returns all of the items for the RichTreeView in TreeViewWrapper
|
|
19
|
+
*/
|
|
20
|
+
export declare function buildTreeView(selectedIds: string[], root: TreeViewBaseItem<ExtendedTreeItemProps>, rowById: Map<string, RowInfo>): TreeViewBaseItem<ExtendedTreeItemProps>[];
|
|
21
|
+
/**
|
|
22
|
+
* Fuzzy search of active tracks.
|
|
23
|
+
*
|
|
24
|
+
* @param treeItems - TreeBaseViewItems from the tree.
|
|
25
|
+
* @param query - The search query string.
|
|
26
|
+
* @param keyWeightMap - Array of keys to search within each track object.
|
|
27
|
+
* Can look like ["name", "author"] or if weighted, [
|
|
28
|
+
{
|
|
29
|
+
name: 'title',
|
|
30
|
+
weight: 0.3
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: 'author',
|
|
34
|
+
weight: 0.7
|
|
35
|
+
}
|
|
36
|
+
].
|
|
37
|
+
* @param threshold - (Optional) Threshold for the fuzzy search (default is 0.5).
|
|
38
|
+
* Smaller = stricter match, larger = fuzzier since 0 is perfect match and 1 is worst match.
|
|
39
|
+
* @param limit - (Optional) Maximum number of results to return (default is 10).
|
|
40
|
+
* @returns FuseResult object containing the search results.
|
|
41
|
+
*/
|
|
42
|
+
export declare function searchTreeItems({ treeItems, query, keyWeightMap, threshold, limit }: SearchTracksProps): FuseResult<RowInfo>[];
|
|
43
|
+
/**
|
|
44
|
+
* Creates the assay icon for DataGrid and RichTreeView
|
|
45
|
+
* @param type: assay type
|
|
46
|
+
* @returns an icon of the assay's respective color
|
|
47
|
+
*/
|
|
48
|
+
export declare function AssayIcon(type: string): import("react/jsx-runtime").JSX.Element;
|
|
49
|
+
export declare const CustomTreeItem: React.ForwardRefExoticComponent<CustomTreeItemProps & React.RefAttributes<HTMLLIElement>>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { RowInfo } from './types';
|
|
2
|
+
export declare const assayTypes: string[];
|
|
3
|
+
export declare const ontologyTypes: string[];
|
|
4
|
+
export declare const rows: {
|
|
5
|
+
assay: string;
|
|
6
|
+
ontology: string;
|
|
7
|
+
lifeStage: string;
|
|
8
|
+
sampleType: string;
|
|
9
|
+
displayname: string;
|
|
10
|
+
experimentAccession: string;
|
|
11
|
+
fileAccession: string;
|
|
12
|
+
}[];
|
|
13
|
+
export declare const rowById: Map<string, RowInfo>;
|
|
14
|
+
/**
|
|
15
|
+
* Check if an ID is a real track (exists in rowById) vs an auto-generated group ID
|
|
16
|
+
*/
|
|
17
|
+
export declare const isTrackId: (id: string) => boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Filter a set of IDs to return only real track IDs (no auto-generated group IDs)
|
|
20
|
+
*/
|
|
21
|
+
export declare const getActiveTracks: (selectedIds: Set<string>) => Set<string>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { StoreApi, UseBoundStore } from 'zustand';
|
|
2
|
+
import { SelectionState, SelectionAction } from './types';
|
|
3
|
+
export type SelectionStoreInstance = UseBoundStore<StoreApi<SelectionState & SelectionAction>>;
|
|
4
|
+
export declare function createSelectionStore(): UseBoundStore<StoreApi<SelectionState & SelectionAction>>;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { FuseOptionKey } from 'fuse.js';
|
|
2
|
+
import { UseTreeItemParameters } from '@mui/x-tree-view/useTreeItem';
|
|
3
|
+
import { TreeViewBaseItem } from '@mui/x-tree-view';
|
|
4
|
+
import { DataGridPremiumProps, GridRowSelectionModel } from '@mui/x-data-grid-premium';
|
|
5
|
+
import { ReactElement, ReactNode } from 'react';
|
|
6
|
+
import { SvgIconOwnProps } from '@mui/material';
|
|
7
|
+
import { SelectionStoreInstance } from './store';
|
|
8
|
+
export interface SearchTracksProps {
|
|
9
|
+
query: string;
|
|
10
|
+
keyWeightMap: FuseOptionKey<any>[];
|
|
11
|
+
jsonStructure?: string;
|
|
12
|
+
treeItems?: TreeViewBaseItem<ExtendedTreeItemProps>[];
|
|
13
|
+
threshold?: number;
|
|
14
|
+
limit?: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Types for the JSON-formatted tracks fomr modifiedHumanTracks.json
|
|
18
|
+
*/
|
|
19
|
+
export type AssayInfo = {
|
|
20
|
+
assay: string;
|
|
21
|
+
url: string;
|
|
22
|
+
experimentAccession: string;
|
|
23
|
+
fileAccession: string;
|
|
24
|
+
};
|
|
25
|
+
export type TrackInfo = {
|
|
26
|
+
name: string;
|
|
27
|
+
ontology: string;
|
|
28
|
+
lifeStage: string;
|
|
29
|
+
sampleType: string;
|
|
30
|
+
displayname: string;
|
|
31
|
+
assays: AssayInfo[];
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Row format for DataGrid
|
|
35
|
+
*/
|
|
36
|
+
export type RowInfo = {
|
|
37
|
+
ontology: string;
|
|
38
|
+
lifeStage: string;
|
|
39
|
+
sampleType: string;
|
|
40
|
+
displayname: string;
|
|
41
|
+
assay: string;
|
|
42
|
+
experimentAccession: string;
|
|
43
|
+
fileAccession: string;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Custom Tree Props for RichTreeView Panel
|
|
47
|
+
*/
|
|
48
|
+
export type ExtendedTreeItemProps = {
|
|
49
|
+
id: string;
|
|
50
|
+
label: string;
|
|
51
|
+
icon: string;
|
|
52
|
+
isAssayItem?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* list of all the experimentAccession values in the children/grandchildren of the item, or the accession of the item itself
|
|
55
|
+
* this is used in updating the rowSelectionModel when removing items from the Tree View panel
|
|
56
|
+
*/
|
|
57
|
+
allExpAccessions?: string[];
|
|
58
|
+
allRowInfo?: RowInfo[];
|
|
59
|
+
};
|
|
60
|
+
export type TreeViewWrapperProps = {
|
|
61
|
+
store: SelectionStoreInstance;
|
|
62
|
+
items: TreeViewBaseItem<ExtendedTreeItemProps>[];
|
|
63
|
+
selectedIds: Set<string>;
|
|
64
|
+
activeTracks: Set<string>;
|
|
65
|
+
isSearchResult: boolean;
|
|
66
|
+
};
|
|
67
|
+
export interface CustomLabelProps {
|
|
68
|
+
id: string;
|
|
69
|
+
children: React.ReactNode;
|
|
70
|
+
isAssayItem?: boolean;
|
|
71
|
+
icon: React.ElementType | React.ReactElement;
|
|
72
|
+
}
|
|
73
|
+
export interface CustomTreeItemProps extends Omit<UseTreeItemParameters, "rootRef">, Omit<React.HTMLAttributes<HTMLLIElement>, "onFocus"> {
|
|
74
|
+
onRemove?: (item: TreeViewBaseItem<ExtendedTreeItemProps>) => void;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Types for useSelectionStore to keep track of selected DataGrid row ids/tracks
|
|
78
|
+
*/
|
|
79
|
+
export type SelectionState = {
|
|
80
|
+
maxTracks: number;
|
|
81
|
+
selectedIds: Set<string>;
|
|
82
|
+
};
|
|
83
|
+
export type SelectionAction = {
|
|
84
|
+
setSelected: (ids: Set<string>) => void;
|
|
85
|
+
removeIds: (removedIds: Set<string>) => void;
|
|
86
|
+
clear: () => void;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* DataGrid Props
|
|
90
|
+
*/
|
|
91
|
+
interface BaseTableProps extends Omit<DataGridPremiumProps, "columns"> {
|
|
92
|
+
toolbarSlot?: ReactNode;
|
|
93
|
+
/**
|
|
94
|
+
* If anything besides an element, renders tooltip icon to the right of the table label with specified string as tooltip contents.
|
|
95
|
+
* If an element, renders the element to the right of the table label.
|
|
96
|
+
*/
|
|
97
|
+
labelTooltip?: ReactNode;
|
|
98
|
+
/**
|
|
99
|
+
* Styling object for the toolbar
|
|
100
|
+
*/
|
|
101
|
+
toolbarStyle?: React.CSSProperties;
|
|
102
|
+
/**
|
|
103
|
+
* Color passed as `htmlColor` to columns, filter, download and search icons
|
|
104
|
+
*/
|
|
105
|
+
toolbarIconColor?: SvgIconOwnProps["htmlColor"];
|
|
106
|
+
}
|
|
107
|
+
type DataGridWrapperProps = {
|
|
108
|
+
rows: RowInfo[];
|
|
109
|
+
selectedIds: Set<string>;
|
|
110
|
+
handleSelection: (newSelection: GridRowSelectionModel) => void;
|
|
111
|
+
sortedAssay: boolean;
|
|
112
|
+
};
|
|
113
|
+
export type DataGridProps = DataGridWrapperProps & BaseTableProps & ({
|
|
114
|
+
label?: string;
|
|
115
|
+
downloadFileName?: string;
|
|
116
|
+
} | {
|
|
117
|
+
label: ReactElement;
|
|
118
|
+
downloadFileName: string;
|
|
119
|
+
} | {
|
|
120
|
+
label?: undefined;
|
|
121
|
+
downloadFileName?: string;
|
|
122
|
+
});
|
|
123
|
+
export {};
|