@vitessce/styles 3.9.2 → 3.9.3

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.
@@ -0,0 +1,31 @@
1
+ export interface AutocompleteItem {
2
+ label: string;
3
+ data: any;
4
+ }
5
+ export interface SimpleAutocompleteProps {
6
+ /**
7
+ * Async function that takes a search string and returns matching items.
8
+ */
9
+ getMatches: (inputValue: string) => Promise<AutocompleteItem[]>;
10
+ /**
11
+ * Callback fired when the user selects an item from the dropdown.
12
+ */
13
+ onChange: (item: AutocompleteItem | null) => void;
14
+ /**
15
+ * Label for the text input.
16
+ */
17
+ textInputLabel?: string;
18
+ /**
19
+ * Function to get the label for an option, used in rendering the dropdown.
20
+ */
21
+ getItemLabel?: (option: AutocompleteItem) => string;
22
+ }
23
+ /**
24
+ * A reusable virtualized autocomplete for searching genes (and other
25
+ * ontology nodes such as proteins, pathways, or cell types).
26
+ *
27
+ * The caller supplies an async `getMatches` function that receives
28
+ * the current input value and returns matching `AutocompleteItem[]`.
29
+ */
30
+ export declare function SimpleAutocomplete(props: SimpleAutocompleteProps): import("react/jsx-runtime").JSX.Element;
31
+ //# sourceMappingURL=SimpleAutocomplete.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SimpleAutocomplete.d.ts","sourceRoot":"","sources":["../src/SimpleAutocomplete.tsx"],"names":[],"mappings":"AAaA,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,GAAG,CAAC;CACX;AAED,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,UAAU,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAChE;;OAEG;IACH,QAAQ,EAAE,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI,KAAK,IAAI,CAAC;IAClD;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,gBAAgB,KAAK,MAAM,CAAC;CACrD;AAoFD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,uBAAuB,2CA6ChE"}
@@ -0,0 +1,77 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import React, { useRef, useEffect, useState } from 'react';
3
+ import { VariableSizeList as _VariableSizeList, } from 'react-window'; // TODO: upgrade to v2
4
+ import Autocomplete from '@mui/material/Autocomplete';
5
+ import TextField from '@mui/material/TextField';
6
+ import Typography from '@mui/material/Typography';
7
+ import { makeStyles } from 'tss-react/mui';
8
+ // Cast to work around react-window types being incompatible with React 18 types.
9
+ const VariableSizeList = _VariableSizeList;
10
+ const LIST_ROW_HEIGHT = 48;
11
+ const useStyles = makeStyles()(() => ({
12
+ searchInput: {
13
+ lineHeight: 'initial',
14
+ height: 'auto !important',
15
+ },
16
+ }));
17
+ // Context to forward outer element props for the virtualized listbox.
18
+ const OuterElementContext = React.createContext({});
19
+ const OuterElementType = React.forwardRef((props, ref) => {
20
+ const outerProps = React.useContext(OuterElementContext);
21
+ return _jsx("div", { ref: ref, ...props, ...outerProps });
22
+ });
23
+ function ListRow(props) {
24
+ const { data, index, style } = props;
25
+ const dataSet = data[index];
26
+ const inlineStyle = {
27
+ ...style,
28
+ top: style.top + 8,
29
+ };
30
+ // This array is created by the renderOption function in the Autocomplete component.
31
+ const [props0, option, getItemLabel] = dataSet;
32
+ const { key, ...optionProps } = props0;
33
+ return (_jsx(Typography, { component: "li", ...optionProps, noWrap: true, style: inlineStyle, children: getItemLabel(option) }, key));
34
+ }
35
+ function useResetCache(itemCount) {
36
+ const ref = useRef(null);
37
+ useEffect(() => {
38
+ if (ref.current != null) {
39
+ ref.current.resetAfterIndex(0, true);
40
+ }
41
+ }, [itemCount]);
42
+ return ref;
43
+ }
44
+ // Virtualized listbox based on:
45
+ // https://mui.com/material-ui/react-autocomplete/#virtualization
46
+ const ListboxComponent = React.forwardRef((props, ref) => {
47
+ const { children, ...other } = props;
48
+ const items = children;
49
+ const itemCount = items.length;
50
+ const gridRef = useResetCache(itemCount);
51
+ return (_jsx("div", { ref: ref, children: _jsx(OuterElementContext.Provider, { value: other, children: _jsx(VariableSizeList, { height: Math.min(8, itemCount) * LIST_ROW_HEIGHT, itemSize: () => LIST_ROW_HEIGHT, width: "100%", innerElementType: "ul", outerElementType: OuterElementType, overscanCount: 5, ref: gridRef, itemCount: itemCount, itemData: items, children: ListRow }) }) }));
52
+ });
53
+ /**
54
+ * A reusable virtualized autocomplete for searching genes (and other
55
+ * ontology nodes such as proteins, pathways, or cell types).
56
+ *
57
+ * The caller supplies an async `getMatches` function that receives
58
+ * the current input value and returns matching `AutocompleteItem[]`.
59
+ */
60
+ export function SimpleAutocomplete(props) {
61
+ const { getMatches, onChange, textInputLabel = 'Enter a gene', getItemLabel = (option) => option.label, } = props;
62
+ const { classes } = useStyles();
63
+ const [potentialItems, setPotentialItems] = useState([]);
64
+ const handleInputChange = async (_event, value) => {
65
+ if (!value) {
66
+ setPotentialItems([]);
67
+ return;
68
+ }
69
+ const results = await getMatches(value);
70
+ setPotentialItems(results);
71
+ };
72
+ return (_jsx(Autocomplete, { options: potentialItems, autoComplete: true, includeInputInList: true, onInputChange: handleInputChange, onChange: (_event, item) => onChange(item), classes: { input: classes.searchInput }, renderInput: params => (_jsx(TextField, { label: textInputLabel, variant: "outlined", ...params })), getOptionLabel: option => option.label, renderOption: (props0, option, state) => [props0, option, getItemLabel, state.index], slotProps: {
73
+ listbox: {
74
+ component: ListboxComponent,
75
+ },
76
+ } }));
77
+ }
@@ -17,6 +17,11 @@ export { default as Checkbox } from '@mui/material/Checkbox';
17
17
  export { default as Chip } from '@mui/material/Chip';
18
18
  export { default as CircularProgress } from '@mui/material/CircularProgress';
19
19
  export { default as ClickAwayListener } from '@mui/material/ClickAwayListener';
20
+ export { default as Dialog } from '@mui/material/Dialog';
21
+ export { default as DialogActions } from '@mui/material/DialogActions';
22
+ export { default as DialogContent } from '@mui/material/DialogContent';
23
+ export { default as DialogContentText } from '@mui/material/DialogContentText';
24
+ export { default as DialogTitle } from '@mui/material/DialogTitle';
20
25
  export { default as Fade } from '@mui/material/Fade';
21
26
  export { default as FormControl } from '@mui/material/FormControl';
22
27
  export { default as FormControlLabel } from '@mui/material/FormControlLabel';
@@ -98,4 +103,6 @@ export { default as Palette } from '@mui/icons-material/Palette';
98
103
  export { DataGrid } from '@mui/x-data-grid/DataGrid';
99
104
  export { Popper as PopperV4 } from './Popper.js';
100
105
  export { ScopedGlobalStyles } from './ScopedGlobalStyles.js';
106
+ export { SimpleAutocomplete } from './SimpleAutocomplete.js';
107
+ export type { SimpleAutocompleteProps, AutocompleteItem } from './SimpleAutocomplete.js';
101
108
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,SAAS,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC;AAKlE,OAAO,EACL,WAAW,EACX,aAAa,GACd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAM5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAGvD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAC7E,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAC7E,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM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E,MAAM,yBAAyB,CAAC;AAC7D,YAAY,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC"}
package/dist-tsc/index.js CHANGED
@@ -28,6 +28,11 @@ export { default as Checkbox } from '@mui/material/Checkbox';
28
28
  export { default as Chip } from '@mui/material/Chip';
29
29
  export { default as CircularProgress } from '@mui/material/CircularProgress';
30
30
  export { default as ClickAwayListener } from '@mui/material/ClickAwayListener';
31
+ export { default as Dialog } from '@mui/material/Dialog';
32
+ export { default as DialogActions } from '@mui/material/DialogActions';
33
+ export { default as DialogContent } from '@mui/material/DialogContent';
34
+ export { default as DialogContentText } from '@mui/material/DialogContentText';
35
+ export { default as DialogTitle } from '@mui/material/DialogTitle';
31
36
  export { default as Fade } from '@mui/material/Fade';
32
37
  export { default as FormControl } from '@mui/material/FormControl';
33
38
  export { default as FormControlLabel } from '@mui/material/FormControlLabel';
@@ -112,3 +117,4 @@ export { DataGrid } from '@mui/x-data-grid/DataGrid';
112
117
  // Local exports
113
118
  export { Popper as PopperV4 } from './Popper.js';
114
119
  export { ScopedGlobalStyles } from './ScopedGlobalStyles.js';
120
+ export { SimpleAutocomplete } from './SimpleAutocomplete.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitessce/styles",
3
- "version": "3.9.2",
3
+ "version": "3.9.3",
4
4
  "author": "HIDIVE Lab at HMS",
5
5
  "homepage": "http://vitessce.io",
6
6
  "repository": {
@@ -24,12 +24,14 @@
24
24
  "@emotion/styled": "^11.14.0",
25
25
  "@emotion/react": "^11.14.0",
26
26
  "@emotion/cache": "^11.14.0",
27
- "popper.js": "^1.16.1"
27
+ "popper.js": "^1.16.1",
28
+ "react-window": "^1.8.10"
28
29
  },
29
30
  "devDependencies": {
30
31
  "react": "18.3.1",
31
32
  "react-dom": "18.3.1",
32
33
  "@types/react": "^18.0.28",
34
+ "@types/react-window": "1.8.5",
33
35
  "vite": "^7.0.0",
34
36
  "vitest": "^3.1.4"
35
37
  },
@@ -0,0 +1,172 @@
1
+ import React, { useRef, useEffect, useState, type ComponentType } from 'react';
2
+ import {
3
+ VariableSizeList as _VariableSizeList,
4
+ type VariableSizeList as VariableSizeListType,
5
+ } from 'react-window'; // TODO: upgrade to v2
6
+ import Autocomplete from '@mui/material/Autocomplete';
7
+ import TextField from '@mui/material/TextField';
8
+ import Typography from '@mui/material/Typography';
9
+ import { makeStyles } from 'tss-react/mui';
10
+
11
+ // Cast to work around react-window types being incompatible with React 18 types.
12
+ const VariableSizeList = _VariableSizeList as unknown as ComponentType<any>;
13
+
14
+ export interface AutocompleteItem {
15
+ label: string;
16
+ data: any; // Additional data can be included as needed
17
+ }
18
+
19
+ export interface SimpleAutocompleteProps {
20
+ /**
21
+ * Async function that takes a search string and returns matching items.
22
+ */
23
+ getMatches: (inputValue: string) => Promise<AutocompleteItem[]>;
24
+ /**
25
+ * Callback fired when the user selects an item from the dropdown.
26
+ */
27
+ onChange: (item: AutocompleteItem | null) => void;
28
+ /**
29
+ * Label for the text input.
30
+ */
31
+ textInputLabel?: string;
32
+ /**
33
+ * Function to get the label for an option, used in rendering the dropdown.
34
+ */
35
+ getItemLabel?: (option: AutocompleteItem) => string;
36
+ }
37
+
38
+ const LIST_ROW_HEIGHT = 48;
39
+
40
+ const useStyles = makeStyles()(() => ({
41
+ searchInput: {
42
+ lineHeight: 'initial',
43
+ height: 'auto !important',
44
+ },
45
+ }));
46
+
47
+ // Context to forward outer element props for the virtualized listbox.
48
+ const OuterElementContext = React.createContext({});
49
+
50
+ const OuterElementType = React.forwardRef<
51
+ HTMLDivElement,
52
+ React.HTMLAttributes<HTMLDivElement>
53
+ >((props, ref) => {
54
+ const outerProps = React.useContext(OuterElementContext);
55
+ return <div ref={ref} {...props} {...outerProps} />;
56
+ });
57
+
58
+ function ListRow(props: { data: any[]; index: number; style: React.CSSProperties }) {
59
+ const { data, index, style } = props;
60
+ const dataSet = data[index];
61
+ const inlineStyle = {
62
+ ...style,
63
+ top: (style.top as number) + 8,
64
+ };
65
+
66
+ // This array is created by the renderOption function in the Autocomplete component.
67
+ const [props0, option, getItemLabel] = dataSet;
68
+ const { key, ...optionProps } = props0;
69
+
70
+ return (
71
+ <Typography key={key} component="li" {...optionProps} noWrap style={inlineStyle}>
72
+ {getItemLabel(option)}
73
+ </Typography>
74
+ );
75
+ }
76
+
77
+ function useResetCache(itemCount: number) {
78
+ const ref = useRef<VariableSizeListType>(null);
79
+ useEffect(() => {
80
+ if (ref.current != null) {
81
+ ref.current.resetAfterIndex(0, true);
82
+ }
83
+ }, [itemCount]);
84
+ return ref;
85
+ }
86
+
87
+ // Virtualized listbox based on:
88
+ // https://mui.com/material-ui/react-autocomplete/#virtualization
89
+ const ListboxComponent = React.forwardRef<
90
+ HTMLDivElement,
91
+ React.HTMLAttributes<HTMLDivElement>
92
+ >((props, ref) => {
93
+ const { children, ...other } = props;
94
+
95
+ const items = children as any[];
96
+ const itemCount = items.length;
97
+ const gridRef = useResetCache(itemCount);
98
+
99
+ return (
100
+ <div ref={ref}>
101
+ <OuterElementContext.Provider value={other}>
102
+ <VariableSizeList
103
+ height={Math.min(8, itemCount) * LIST_ROW_HEIGHT}
104
+ itemSize={() => LIST_ROW_HEIGHT}
105
+ width="100%"
106
+ innerElementType="ul"
107
+ outerElementType={OuterElementType as any}
108
+ overscanCount={5}
109
+ ref={gridRef}
110
+ itemCount={itemCount}
111
+ itemData={items}
112
+ >
113
+ {ListRow}
114
+ </VariableSizeList>
115
+ </OuterElementContext.Provider>
116
+ </div>
117
+ );
118
+ });
119
+
120
+ /**
121
+ * A reusable virtualized autocomplete for searching genes (and other
122
+ * ontology nodes such as proteins, pathways, or cell types).
123
+ *
124
+ * The caller supplies an async `getMatches` function that receives
125
+ * the current input value and returns matching `AutocompleteItem[]`.
126
+ */
127
+ export function SimpleAutocomplete(props: SimpleAutocompleteProps) {
128
+ const {
129
+ getMatches,
130
+ onChange,
131
+ textInputLabel = 'Enter a gene',
132
+ getItemLabel = (option: AutocompleteItem) => option.label,
133
+ } = props;
134
+ const { classes } = useStyles();
135
+
136
+ const [potentialItems, setPotentialItems] = useState<AutocompleteItem[]>([]);
137
+
138
+ const handleInputChange = async (
139
+ _event: React.SyntheticEvent,
140
+ value: string,
141
+ ) => {
142
+ if (!value) {
143
+ setPotentialItems([]);
144
+ return;
145
+ }
146
+ const results = await getMatches(value);
147
+ setPotentialItems(results);
148
+ };
149
+
150
+ return (
151
+ <Autocomplete
152
+ options={potentialItems}
153
+ autoComplete
154
+ includeInputInList
155
+ onInputChange={handleInputChange}
156
+ onChange={(_event, item) => onChange(item)}
157
+ classes={{ input: classes.searchInput }}
158
+ renderInput={params => (
159
+ <TextField label={textInputLabel} variant="outlined" {...params} />
160
+ )}
161
+ getOptionLabel={option => option.label}
162
+ renderOption={(props0, option, state) => (
163
+ [props0, option, getItemLabel, state.index] as React.ReactNode
164
+ )}
165
+ slotProps={{
166
+ listbox: {
167
+ component: ListboxComponent,
168
+ },
169
+ }}
170
+ />
171
+ );
172
+ }
package/src/index.ts CHANGED
@@ -34,6 +34,11 @@ export { default as Checkbox } from '@mui/material/Checkbox';
34
34
  export { default as Chip } from '@mui/material/Chip';
35
35
  export { default as CircularProgress } from '@mui/material/CircularProgress';
36
36
  export { default as ClickAwayListener } from '@mui/material/ClickAwayListener';
37
+ export { default as Dialog } from '@mui/material/Dialog';
38
+ export { default as DialogActions } from '@mui/material/DialogActions';
39
+ export { default as DialogContent } from '@mui/material/DialogContent';
40
+ export { default as DialogContentText } from '@mui/material/DialogContentText';
41
+ export { default as DialogTitle } from '@mui/material/DialogTitle';
37
42
  export { default as Fade } from '@mui/material/Fade';
38
43
  export { default as FormControl } from '@mui/material/FormControl';
39
44
  export { default as FormControlLabel } from '@mui/material/FormControlLabel';
@@ -121,3 +126,5 @@ export { DataGrid } from '@mui/x-data-grid/DataGrid';
121
126
  // Local exports
122
127
  export { Popper as PopperV4 } from './Popper.js';
123
128
  export { ScopedGlobalStyles } from './ScopedGlobalStyles.js';
129
+ export { SimpleAutocomplete } from './SimpleAutocomplete.js';
130
+ export type { SimpleAutocompleteProps, AutocompleteItem } from './SimpleAutocomplete.js';