@rivm-loculus-tools/sequence-editor 0.1.4 → 0.1.5

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.
Files changed (144) hide show
  1. package/dist/_chunks/Box.js +6737 -0
  2. package/dist/_chunks/Box.js.map +1 -0
  3. package/dist/_chunks/Close.js +7 -0
  4. package/dist/_chunks/Close.js.map +1 -0
  5. package/dist/_chunks/EditorWorkerService.js +126 -0
  6. package/dist/_chunks/EditorWorkerService.js.map +1 -0
  7. package/dist/_chunks/KeyboardArrowDown.js +1023 -0
  8. package/dist/_chunks/KeyboardArrowDown.js.map +1 -0
  9. package/dist/_chunks/Redo.js +2559 -0
  10. package/dist/_chunks/Redo.js.map +1 -0
  11. package/dist/_chunks/SequenceEditor.js +860 -0
  12. package/dist/_chunks/SequenceEditor.js.map +1 -0
  13. package/dist/_chunks/SequenceEditorEventBusService.js +102 -0
  14. package/dist/_chunks/SequenceEditorEventBusService.js.map +1 -0
  15. package/dist/_chunks/SequenceEditorMainPage.js +552 -0
  16. package/dist/_chunks/SequenceEditorMainPage.js.map +1 -0
  17. package/dist/_chunks/SequenceEditorPageDrawer.js +49842 -0
  18. package/dist/_chunks/SequenceEditorPageDrawer.js.map +1 -0
  19. package/dist/_chunks/SequenceEditorPageHeader.js +236 -0
  20. package/dist/_chunks/SequenceEditorPageHeader.js.map +1 -0
  21. package/dist/_chunks/SequenceEditorSearchBar.js +143 -0
  22. package/dist/_chunks/SequenceEditorSearchBar.js.map +1 -0
  23. package/dist/_chunks/TestIdUtil.js +4695 -0
  24. package/dist/_chunks/TestIdUtil.js.map +1 -0
  25. package/dist/_chunks/TextField.js +3083 -0
  26. package/dist/_chunks/TextField.js.map +1 -0
  27. package/dist/_chunks/rolldown-runtime.js +13 -0
  28. package/dist/_chunks/sequenceEditorStore.js +407 -0
  29. package/dist/_chunks/sequenceEditorStore.js.map +1 -0
  30. package/dist/_chunks/sequence_editor.js +517 -0
  31. package/dist/_chunks/sequence_editor.js.map +1 -0
  32. package/dist/_chunks/withDialog.js +289 -0
  33. package/dist/_chunks/withDialog.js.map +1 -0
  34. package/dist/assets/index-C5rc-pJV.js +8 -0
  35. package/dist/assets/index-C5rc-pJV.js.map +1 -0
  36. package/dist/classes/services/EditorWorkerService/EditorWorkerService.d.ts +27 -0
  37. package/dist/classes/services/EditorWorkerService/index.js +2 -0
  38. package/dist/classes/services/SequenceEditorEventBusService/SequenceEditorEventBusService.d.ts +25 -0
  39. package/dist/classes/services/SequenceEditorEventBusService/index.js +2 -0
  40. package/dist/classes/workers/EngineWorker/EngineWorker.d.ts +46 -0
  41. package/dist/classes/workers/EngineWorker/index.js +110 -0
  42. package/dist/classes/workers/EngineWorker/index.js.map +1 -0
  43. package/dist/components/app/App/App.d.ts +1 -0
  44. package/dist/components/app/App/index.js +957 -0
  45. package/dist/components/app/App/index.js.map +1 -0
  46. package/dist/components/pages/EmptyWorkspace.d.ts +3 -0
  47. package/dist/components/pages/SequenceEditorErrorPage/SequenceEditorErrorPage.d.ts +3 -0
  48. package/dist/components/pages/SequenceEditorErrorPage/index.js +12 -0
  49. package/dist/components/pages/SequenceEditorErrorPage/index.js.map +1 -0
  50. package/dist/components/pages/SequenceEditorMainPage/SequenceEditorMainPage.d.ts +1 -0
  51. package/dist/components/pages/SequenceEditorMainPage/index.js +2 -0
  52. package/dist/components/ui/SequenceEditor/SequenceEditor.d.ts +1 -0
  53. package/dist/components/ui/SequenceEditor/SequenceEditorGotoPositionDialog.d.ts +8 -0
  54. package/dist/components/ui/SequenceEditor/SequenceEditorStatusBar.d.ts +1 -0
  55. package/dist/components/ui/SequenceEditor/index.js +2 -0
  56. package/dist/components/ui/SequenceEditorPage/SequenceEditorPage.d.ts +5 -0
  57. package/dist/components/ui/SequenceEditorPage/index.js +15 -0
  58. package/dist/components/ui/SequenceEditorPage/index.js.map +1 -0
  59. package/dist/components/ui/SequenceEditorPageDrawer/SequenceEditorPageDrawer.d.ts +1 -0
  60. package/dist/components/ui/SequenceEditorPageDrawer/SequenceEditorPageDrawerColorForm.d.ts +7 -0
  61. package/dist/components/ui/SequenceEditorPageDrawer/SequenceEditorPageDrawerKeyboardShortcuts.d.ts +1 -0
  62. package/dist/components/ui/SequenceEditorPageDrawer/index.js +2 -0
  63. package/dist/components/ui/SequenceEditorPageHeader/SequenceEditorPageHeader.d.ts +1 -0
  64. package/dist/components/ui/SequenceEditorPageHeader/index.js +2 -0
  65. package/dist/components/ui/SequenceEditorSearchBar/SequenceEditorSearchBar.d.ts +1 -0
  66. package/dist/components/ui/SequenceEditorSearchBar/index.js +2 -0
  67. package/dist/constants/editor.d.ts +4 -0
  68. package/dist/constants/editor.js +14 -0
  69. package/dist/constants/editor.js.map +1 -0
  70. package/dist/constants/index.js +4 -0
  71. package/dist/constants/keyboard.d.ts +10 -0
  72. package/dist/constants/keyboard.js +179 -0
  73. package/dist/constants/keyboard.js.map +1 -0
  74. package/dist/constants/palette.d.ts +15 -0
  75. package/dist/constants/palette.js +196 -0
  76. package/dist/constants/palette.js.map +1 -0
  77. package/dist/models/editor.d.ts +6 -0
  78. package/dist/models/editor.js +8 -0
  79. package/dist/models/editor.js.map +1 -0
  80. package/dist/models/model.d.ts +250 -0
  81. package/dist/models/model.js +10 -0
  82. package/dist/models/model.js.map +1 -0
  83. package/dist/models/palette.d.ts +61 -0
  84. package/dist/models/palette.js +10 -0
  85. package/dist/models/palette.js.map +1 -0
  86. package/dist/stores/sequenceEditorStore/index.js +2 -0
  87. package/dist/stores/sequenceEditorStore/sequenceEditorStore.d.ts +36 -0
  88. package/dist/utils/EditorUtil/EditorUtil.d.ts +96 -0
  89. package/dist/utils/EditorUtil/index.js +544 -0
  90. package/dist/utils/EditorUtil/index.js.map +1 -0
  91. package/dist/utils/EngineErrorUtil/EngineErrorUtil.d.ts +4 -0
  92. package/dist/utils/PaletteUtil/PaletteUtil.d.ts +6 -0
  93. package/dist/utils/PaletteUtil/index.js +19 -0
  94. package/dist/utils/PaletteUtil/index.js.map +1 -0
  95. package/package.json +5 -2
  96. package/.gitkeep +0 -0
  97. package/CHANGELOG.md +0 -37
  98. package/eslint.config.js +0 -16
  99. package/scripts/update-exports.js +0 -9
  100. package/src/classes/services/EditorWorkerService/EditorWorkerService.ts +0 -163
  101. package/src/classes/services/SequenceEditorEventBusService/SequenceEditorEventBusService.ts +0 -37
  102. package/src/classes/workers/EngineWorker/EngineWorker.ts +0 -196
  103. package/src/components/app/App/App.tsx +0 -22
  104. package/src/components/pages/EmptyWorkspace.tsx +0 -43
  105. package/src/components/pages/SequenceEditorErrorPage/SequenceEditorErrorPage.tsx +0 -16
  106. package/src/components/pages/SequenceEditorMainPage/SequenceEditorMainPage.tsx +0 -76
  107. package/src/components/ui/SequenceEditor/SequenceEditor.tsx +0 -896
  108. package/src/components/ui/SequenceEditor/SequenceEditorGotoPositionDialog.tsx +0 -108
  109. package/src/components/ui/SequenceEditor/SequenceEditorStatusBar.tsx +0 -72
  110. package/src/components/ui/SequenceEditorPage/SequenceEditorPage.tsx +0 -23
  111. package/src/components/ui/SequenceEditorPageDrawer/SequenceEditorPageDrawer.tsx +0 -234
  112. package/src/components/ui/SequenceEditorPageDrawer/SequenceEditorPageDrawerColorForm.tsx +0 -73
  113. package/src/components/ui/SequenceEditorPageDrawer/SequenceEditorPageDrawerKeyboardShortcuts.tsx +0 -230
  114. package/src/components/ui/SequenceEditorPageHeader/SequenceEditorPageHeader.tsx +0 -71
  115. package/src/components/ui/SequenceEditorSearchBar/SequenceEditorSearchBar.tsx +0 -35
  116. package/src/constants/editor.ts +0 -15
  117. package/src/constants/keyboard.ts +0 -154
  118. package/src/constants/palette.ts +0 -227
  119. package/src/models/editor.ts +0 -6
  120. package/src/models/model.ts +0 -295
  121. package/src/models/palette.ts +0 -68
  122. package/src/stores/sequenceEditorStore/sequenceEditorStore.ts +0 -103
  123. package/src/utils/EditorUtil/EditorUtil.ts +0 -892
  124. package/src/utils/EngineErrorUtil/EngineErrorUtil.ts +0 -25
  125. package/src/utils/PaletteUtil/PaletteUtil.ts +0 -31
  126. package/tsconfig.build.json +0 -14
  127. package/tsconfig.json +0 -32
  128. package/vite.config.ts +0 -177
  129. /package/{src/classes/services/EditorWorkerService/index.ts → dist/classes/services/EditorWorkerService/index.d.ts} +0 -0
  130. /package/{src/classes/services/SequenceEditorEventBusService/index.ts → dist/classes/services/SequenceEditorEventBusService/index.d.ts} +0 -0
  131. /package/{src/classes/workers/EngineWorker/index.ts → dist/classes/workers/EngineWorker/index.d.ts} +0 -0
  132. /package/{src/components/app/App/index.ts → dist/components/app/App/index.d.ts} +0 -0
  133. /package/{src/components/pages/SequenceEditorErrorPage/index.ts → dist/components/pages/SequenceEditorErrorPage/index.d.ts} +0 -0
  134. /package/{src/components/pages/SequenceEditorMainPage/index.ts → dist/components/pages/SequenceEditorMainPage/index.d.ts} +0 -0
  135. /package/{src/components/ui/SequenceEditor/index.ts → dist/components/ui/SequenceEditor/index.d.ts} +0 -0
  136. /package/{src/components/ui/SequenceEditorPage/index.ts → dist/components/ui/SequenceEditorPage/index.d.ts} +0 -0
  137. /package/{src/components/ui/SequenceEditorPageDrawer/index.ts → dist/components/ui/SequenceEditorPageDrawer/index.d.ts} +0 -0
  138. /package/{src/components/ui/SequenceEditorPageHeader/index.ts → dist/components/ui/SequenceEditorPageHeader/index.d.ts} +0 -0
  139. /package/{src/components/ui/SequenceEditorSearchBar/index.ts → dist/components/ui/SequenceEditorSearchBar/index.d.ts} +0 -0
  140. /package/{src/constants/index.ts → dist/constants/index.d.ts} +0 -0
  141. /package/{src/models/index.ts → dist/models/index.d.ts} +0 -0
  142. /package/{src/stores/sequenceEditorStore/index.ts → dist/stores/sequenceEditorStore/index.d.ts} +0 -0
  143. /package/{src/utils/EditorUtil/index.ts → dist/utils/EditorUtil/index.d.ts} +0 -0
  144. /package/{src/utils/PaletteUtil/index.ts → dist/utils/PaletteUtil/index.d.ts} +0 -0
@@ -1,108 +0,0 @@
1
- import { TextField } from '@mui/material';
2
- import type {
3
- WithDialogRefMethods,
4
- WithDialogRenderProps,
5
- } from '@gen-epix/ui-core-components/hoc/withDialog';
6
- import { withDialog } from '@gen-epix/ui-core-components/hoc/withDialog';
7
- import type { DialogAction } from '@gen-epix/ui-core-components/components/Dialog';
8
- import type {
9
- ChangeEvent,
10
- KeyboardEvent,
11
- ReactElement,
12
- } from 'react';
13
- import {
14
- useCallback,
15
- useEffect,
16
- useRef,
17
- useState,
18
- } from 'react';
19
-
20
- const GOTO_POSITION_REGEX = /^(?:\d+|,\d+|\d+,\d+)$/;
21
-
22
- export interface SequenceEditorGotoPositionDialogOpenProps {
23
- //
24
- }
25
-
26
- export interface SequenceEditorGotoPositionDialogProps extends WithDialogRenderProps<SequenceEditorGotoPositionDialogOpenProps> {
27
- onGotoPosition: (x: null | number, y: null | number) => void;
28
- }
29
-
30
- export type SequenceEditorGotoPositionDialogRefMethods = WithDialogRefMethods<SequenceEditorGotoPositionDialogProps, SequenceEditorGotoPositionDialogOpenProps>;
31
-
32
- export const SequenceEditorGotoPositionDialog = withDialog<SequenceEditorGotoPositionDialogProps, SequenceEditorGotoPositionDialogOpenProps>((
33
- {
34
- onActionsChange,
35
- onClose,
36
- onGotoPosition,
37
- }: SequenceEditorGotoPositionDialogProps,
38
- ): ReactElement => {
39
- const [value, setValue] = useState('');
40
- const inputRef = useRef<HTMLInputElement>(null);
41
- const isValid = value === '' || GOTO_POSITION_REGEX.test(value);
42
-
43
- useEffect(() => {
44
- inputRef.current?.focus();
45
- }, []);
46
-
47
- const onChange = useCallback((event: ChangeEvent<HTMLInputElement>) => {
48
- setValue(event.target.value);
49
- }, []);
50
-
51
- const onSubmit = useCallback(() => {
52
- if (!isValid) {
53
- return;
54
- }
55
- const [x, y] = value.split(',');
56
- onGotoPosition(x ? Number(x) : null, y ? Number(y) : null);
57
- onClose?.();
58
- }, [isValid, onClose, onGotoPosition, value]);
59
-
60
- const onKeyDown = useCallback((event: KeyboardEvent<HTMLInputElement>) => {
61
- if (event.key === 'Enter') {
62
- event.preventDefault();
63
- onSubmit();
64
- }
65
- }, [onSubmit]);
66
-
67
- useEffect(() => {
68
- const actions: DialogAction[] = [];
69
- actions.push(
70
- {
71
- color: 'secondary',
72
- label: 'Close',
73
- onClick: onClose,
74
- variant: 'outlined',
75
- },
76
- );
77
- actions.push(
78
- {
79
- color: 'primary',
80
- disabled: !isValid,
81
- label: 'Ok',
82
- onClick: onSubmit,
83
- variant: 'contained',
84
- },
85
- );
86
- onActionsChange?.(actions);
87
- }, [isValid, onActionsChange, onClose, onSubmit]);
88
-
89
- return (
90
- <TextField
91
- error={!isValid}
92
- fullWidth
93
- helperText={'Use x, ,y, or x,y.'}
94
- inputRef={inputRef}
95
- label={'Position'}
96
- onChange={onChange}
97
- onKeyDown={onKeyDown}
98
- placeholder={'x or ,y or x,y'}
99
- value={value}
100
- />
101
- );
102
-
103
- }, {
104
- defaultTitle: 'Goto position (x) or (,y) or (x,y)',
105
- fullWidth: true,
106
- maxWidth: 'xs',
107
- testId: 'SequenceEditorGotoPositionDialog',
108
- });
@@ -1,72 +0,0 @@
1
- import {
2
- Box,
3
- darken,
4
- useTheme,
5
- } from '@mui/material';
6
- import { useMemo } from 'react';
7
- import { useStore } from 'zustand';
8
-
9
- import { sequenceEditorStore } from '../../../stores/sequenceEditorStore';
10
- import { EditorUtil } from '../../../utils/EditorUtil';
11
-
12
- export const SequenceEditorStatusBar = () => {
13
- const theme = useTheme();
14
- const latestMessage = useStore(sequenceEditorStore, (state) => state.latestMessage);
15
- const meta = useStore(sequenceEditorStore, (state) => state.meta);
16
- const selection = useStore(sequenceEditorStore, (state) => state.selection);
17
-
18
- const normalizedSelection = useMemo(
19
- () => EditorUtil.getStatusBarSelectionStats(selection, meta),
20
- [meta, selection],
21
- );
22
-
23
- return (
24
- <Box
25
- sx={{
26
- backgroundColor: darken(theme.palette.background.paper, 0.1),
27
- borderTop: `1px solid ${darken(theme.palette.background.paper, 0.2)}`,
28
- fontSize: theme.typography.caption,
29
- height: '100%',
30
- width: '100%',
31
- }}
32
- >
33
- <Box
34
- sx={{
35
- '& > div': {
36
- alignItems: 'center',
37
- borderLeft: `1px solid ${darken(theme.palette.background.paper, 0.2)}`,
38
- display: 'flex',
39
- paddingLeft: theme.spacing(1),
40
- },
41
- '& > div:first-of-type': {
42
- borderLeft: 'none',
43
- },
44
- display: 'grid',
45
- gap: 4,
46
- gridTemplateColumns: '1fr repeat(5, max-content)',
47
- paddingLeft: theme.spacing(1),
48
- paddingRight: theme.spacing(1),
49
- }}
50
- >
51
- <Box>
52
- {latestMessage ?? ''}
53
- </Box>
54
- <Box>
55
- {`Pos: ${normalizedSelection.pos}`}
56
- </Box>
57
- <Box>
58
- {`Selected seqs: ${normalizedSelection.selectedSeqs}`}
59
- </Box>
60
- <Box>
61
- {`Cols: ${normalizedSelection.cols}`}
62
- </Box>
63
- <Box>
64
- {`Total selected chars: ${normalizedSelection.totalSelectedChars}`}
65
- </Box>
66
- <Box>
67
- {`Alignment: ${meta?.alignmentWidth ?? '0'} sequences ${meta?.sequenceCount ?? '0'} pos.`}
68
- </Box>
69
- </Box>
70
- </Box>
71
- );
72
- };
@@ -1,23 +0,0 @@
1
- import { PageCommon } from '@rivm-loculus-tools/common-frontend/components/page';
2
- import type { PropsWithChildren } from 'react';
3
-
4
- import { SequenceEditorPageDrawer } from '../SequenceEditorPageDrawer';
5
- import { SequenceEditorPageHeader } from '../SequenceEditorPageHeader';
6
-
7
-
8
- export type SequenceEditorPageProps = PropsWithChildren<{
9
- isNoInteraction: boolean;
10
- }>;
11
-
12
- export const SequenceEditorPage = ({ children, isNoInteraction }: SequenceEditorPageProps) => {
13
- return (
14
- <PageCommon
15
- drawerComponent={<SequenceEditorPageDrawer />}
16
- headerComponent={<SequenceEditorPageHeader />}
17
- isNoInteraction={isNoInteraction}
18
- >
19
- {children}
20
- </PageCommon>
21
- );
22
-
23
- };
@@ -1,234 +0,0 @@
1
- import {
2
- useCallback,
3
- useEffect,
4
- useMemo,
5
- useState,
6
- } from 'react';
7
- import {
8
- Accordion,
9
- AccordionDetails,
10
- AccordionSummary,
11
- Box,
12
- Typography,
13
- } from '@mui/material';
14
- import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
15
- import TuneOutlinedIcon from '@mui/icons-material/TuneOutlined';
16
- import PaletteOutlinedIcon from '@mui/icons-material/PaletteOutlined';
17
- import InvertColorsIcon from '@mui/icons-material/InvertColors';
18
- import KeyboardOutlinedIcon from '@mui/icons-material/KeyboardOutlined';
19
- import { useStore } from 'zustand';
20
- import { PageCommonDrawer } from '@rivm-loculus-tools/common-frontend/components/page';
21
-
22
- import { sequenceEditorStore } from '../../../stores/sequenceEditorStore';
23
- import type {
24
- AminoAcidPalette,
25
- NucleotidePalette,
26
- } from '../../../models';
27
- import {
28
- ALI_VIEW_CLUSTAL_X_AMINO_ACID_PALETTE,
29
- ALI_VIEW_DEFAULT_AMINO_ACID_PALETTE,
30
- ALI_VIEW_DEFAULT_NUCLEOTIDE_PALETTE,
31
- ALI_VIEW_FAST_NUCLEOTIDE_PALETTE,
32
- ALI_VIEW_SEA_VIEW_AMINO_ACID_PALETTE,
33
- ALI_VIEW_SEA_VIEW_NUCLEOTIDE_PALETTE,
34
- } from '../../../constants';
35
-
36
- import { SequenceEditorPageDrawerColorForm } from './SequenceEditorPageDrawerColorForm';
37
- import { SequenceEditorPageDrawerKeyboardShortcuts } from './SequenceEditorPageDrawerKeyboardShortcuts';
38
-
39
- enum ACCORDIONS {
40
- AMINO_ACID_COLORS = 'AMINO_ACID_COLORS',
41
- KEYBOARD_SHORTCUTS = 'KEYBOARD_SHORTCUTS',
42
- METADATA = 'METADATA',
43
- NUCLEOTIDE_COLORS = 'NUCLEOTIDE_COLORS',
44
- }
45
-
46
- export const SequenceEditorPageDrawer = () => {
47
- const parsedMetadata = useStore(sequenceEditorStore, (state) => state.parsedMetadata);
48
- const aminoAcidPalette = useStore(sequenceEditorStore, (state) => state.aminoAcidPalette);
49
- const nucleotidePalette = useStore(sequenceEditorStore, (state) => state.nucleotidePalette);
50
- const setAminoAcidPalette = useStore(sequenceEditorStore, (state) => state.setAminoAcidPalette);
51
- const setNucleotidePalette = useStore(sequenceEditorStore, (state) => state.setNucleotidePalette);
52
- const meta = useStore(sequenceEditorStore, (state) => state.meta);
53
- const [expandedAccordions, setExpandedAccordions] = useState<ACCORDIONS[]>([]);
54
-
55
- const toggleAccordion = useCallback((panel: ACCORDIONS) => {
56
- setExpandedAccordions((prev) =>
57
- prev.includes(panel) ? prev.filter((p) => p !== panel) : [...prev, panel]);
58
- }, []);
59
-
60
- const collapseAccordion = useCallback((panel: ACCORDIONS) => {
61
- setExpandedAccordions((prev) => prev.filter((p) => p !== panel));
62
- }, []);
63
-
64
- const onColorsAccordionChange = useCallback(() => toggleAccordion(ACCORDIONS.NUCLEOTIDE_COLORS), [toggleAccordion]);
65
- const onAminoAcidColorsAccordionChange = useCallback(() => toggleAccordion(ACCORDIONS.AMINO_ACID_COLORS), [toggleAccordion]);
66
- const onMetaDataAccordionChange = useCallback(() => toggleAccordion(ACCORDIONS.METADATA), [toggleAccordion]);
67
- const onKeyboardShortcutsAccordionChange = useCallback(() => toggleAccordion(ACCORDIONS.KEYBOARD_SHORTCUTS), [toggleAccordion]);
68
-
69
- useEffect(() => {
70
- if (!parsedMetadata) {
71
- collapseAccordion(ACCORDIONS.METADATA);
72
- }
73
- }, [collapseAccordion, parsedMetadata]);
74
-
75
- const onNucleotidePaletteChange = useCallback((palette: NucleotidePalette) => {
76
- setNucleotidePalette(palette);
77
- }, [setNucleotidePalette]);
78
-
79
- const onAminoAcidPaletteChange = useCallback((palette: AminoAcidPalette) => {
80
- setAminoAcidPalette(palette);
81
- }, [setAminoAcidPalette]);
82
-
83
- const nucleotidePalettes = useMemo(() => {
84
- return [
85
- ALI_VIEW_DEFAULT_NUCLEOTIDE_PALETTE,
86
- ALI_VIEW_FAST_NUCLEOTIDE_PALETTE,
87
- ALI_VIEW_SEA_VIEW_NUCLEOTIDE_PALETTE,
88
- ];
89
- }, []);
90
-
91
- const aminoAcidPalettes = useMemo(() => {
92
- return [
93
- ALI_VIEW_DEFAULT_AMINO_ACID_PALETTE,
94
- ALI_VIEW_SEA_VIEW_AMINO_ACID_PALETTE,
95
- ALI_VIEW_CLUSTAL_X_AMINO_ACID_PALETTE,
96
- ];
97
- }, []);
98
-
99
-
100
- return (
101
- <PageCommonDrawer>
102
- {/* Header with Close and Data Load trigger */}
103
- <Box sx={{ borderBottom: '1px solid', borderColor: 'divider', display: 'flex', flexDirection: 'column', gap: 1.5, p: 2 }}>
104
- {meta && (
105
- <>
106
- <Typography
107
- sx={{ fontWeight: 600 }}
108
- variant={'body2'}
109
- >
110
- {'Alignment dimensions'}
111
- </Typography>
112
- <Typography
113
- sx={{ fontWeight: 400 }}
114
- variant={'body2'}
115
- >
116
- {`${meta.sequenceCount} sequences x ${meta.alignmentWidth} bases`}
117
- </Typography>
118
- </>
119
- )}
120
- </Box>
121
- <Box sx={{ pb: 3 }}>
122
- <Accordion
123
- disableGutters
124
- elevation={0}
125
- expanded={expandedAccordions.includes(ACCORDIONS.KEYBOARD_SHORTCUTS)}
126
- onChange={onKeyboardShortcutsAccordionChange}
127
- sx={{ borderBottom: '1px solid', borderColor: 'divider' }}
128
- >
129
- <AccordionSummary expandIcon={<ExpandMoreIcon />}>
130
- <Box sx={{ alignItems: 'center', display: 'flex', gap: 1 }}>
131
- <KeyboardOutlinedIcon
132
- color={'primary'}
133
- fontSize={'small'}
134
- />
135
- <Typography
136
- sx={{ fontWeight: 600 }}
137
- variant={'body2'}
138
- >
139
- {'Keyboard shortcuts'}
140
- </Typography>
141
- </Box>
142
- </AccordionSummary>
143
- <AccordionDetails sx={{ p: 0 }}>
144
- <SequenceEditorPageDrawerKeyboardShortcuts />
145
- </AccordionDetails>
146
- </Accordion>
147
- <Accordion
148
- disableGutters
149
- elevation={0}
150
- expanded={expandedAccordions.includes(ACCORDIONS.NUCLEOTIDE_COLORS)}
151
- onChange={onColorsAccordionChange}
152
- sx={{ borderBottom: '1px solid', borderColor: 'divider' }}
153
- >
154
- <AccordionSummary expandIcon={<ExpandMoreIcon />}>
155
- <Box sx={{ alignItems: 'center', display: 'flex', gap: 1 }}>
156
- <PaletteOutlinedIcon
157
- color={'primary'}
158
- fontSize={'small'}
159
- />
160
- <Typography
161
- sx={{ fontWeight: 600 }}
162
- variant={'body2'}
163
- >
164
- {'Nucleotide Colors'}
165
- </Typography>
166
- </Box>
167
- </AccordionSummary>
168
- <AccordionDetails sx={{ pb: 2, pt: 0, px: 2 }}>
169
- <SequenceEditorPageDrawerColorForm
170
- currentPalette={nucleotidePalette}
171
- onPaletteChange={onNucleotidePaletteChange}
172
- palettes={nucleotidePalettes}
173
- />
174
- </AccordionDetails>
175
- </Accordion>
176
- <Accordion
177
- disableGutters
178
- elevation={0}
179
- expanded={expandedAccordions.includes(ACCORDIONS.AMINO_ACID_COLORS)}
180
- onChange={onAminoAcidColorsAccordionChange}
181
- sx={{ borderBottom: '1px solid', borderColor: 'divider' }}
182
- >
183
- <AccordionSummary expandIcon={<ExpandMoreIcon />}>
184
- <Box sx={{ alignItems: 'center', display: 'flex', gap: 1 }}>
185
- <InvertColorsIcon
186
- color={'primary'}
187
- fontSize={'small'}
188
- />
189
- <Typography
190
- sx={{ fontWeight: 600 }}
191
- variant={'body2'}
192
- >
193
- {'Amino-acid colors'}
194
- </Typography>
195
- </Box>
196
- </AccordionSummary>
197
- <AccordionDetails sx={{ pb: 2, pt: 0, px: 2 }}>
198
- <SequenceEditorPageDrawerColorForm
199
- currentPalette={aminoAcidPalette}
200
- onPaletteChange={onAminoAcidPaletteChange}
201
- palettes={aminoAcidPalettes}
202
- />
203
- </AccordionDetails>
204
- </Accordion>
205
- <Accordion
206
- disabled={!parsedMetadata}
207
- disableGutters
208
- elevation={0}
209
- expanded={expandedAccordions.includes(ACCORDIONS.METADATA)}
210
- onChange={onMetaDataAccordionChange}
211
- sx={{ borderBottom: '1px solid', borderColor: 'divider' }}
212
- >
213
- <AccordionSummary expandIcon={<ExpandMoreIcon />}>
214
- <Box sx={{ alignItems: 'center', display: 'flex', gap: 1 }}>
215
- <TuneOutlinedIcon
216
- color={'primary'}
217
- fontSize={'small'}
218
- />
219
- <Typography
220
- sx={{ fontWeight: 600 }}
221
- variant={'body2'}
222
- >
223
- {'Metadata'}
224
- </Typography>
225
- </Box>
226
- </AccordionSummary>
227
- <AccordionDetails sx={{ pb: 2, pt: 0, px: 2 }}>
228
- {'Metadata'}
229
- </AccordionDetails>
230
- </Accordion>
231
- </Box>
232
- </PageCommonDrawer>
233
- );
234
- };
@@ -1,73 +0,0 @@
1
- import {
2
- useCallback,
3
- useId,
4
- useMemo,
5
- } from 'react';
6
- import { useForm } from 'react-hook-form';
7
- import { GenericForm } from '@gen-epix/ui-core-form/components/helpers/GenericForm';
8
- import type { FormFieldDefinition } from '@gen-epix/ui-core-form/models/form';
9
- import { FORM_FIELD_DEFINITION_TYPE } from '@gen-epix/ui-core-form/models/form';
10
-
11
- import type {
12
- AminoAcidPalette,
13
- NucleotidePalette,
14
- } from '../../../models';
15
-
16
- export type SequenceEditorPageDrawerColorFormProps<TPalette extends AminoAcidPalette | NucleotidePalette> = {
17
- currentPalette: TPalette;
18
- onPaletteChange: (palettes: TPalette) => void;
19
- palettes: Array<TPalette>;
20
- };
21
-
22
- type FormFields = {
23
- palette?: string;
24
- };
25
-
26
- export const SequenceEditorPageDrawerColorForm = <TPalette extends AminoAcidPalette | NucleotidePalette, >({ currentPalette, onPaletteChange, palettes }: SequenceEditorPageDrawerColorFormProps<TPalette>) => {
27
- const formId = useId();
28
-
29
- const onChangePalette = useCallback((paletteName: string) => {
30
- const palette = palettes.find((candidate) => candidate.name === paletteName);
31
- if (palette) {
32
- onPaletteChange(palette);
33
- }
34
- }, [onPaletteChange, palettes]);
35
-
36
- const paletteOptions = useMemo(() => palettes.map((palette) => ({
37
- label: palette.name,
38
- value: palette.name,
39
- })), [palettes]);
40
-
41
- const formFieldDefinitions = useMemo<FormFieldDefinition<FormFields>[]>(() => [
42
- {
43
- definition: FORM_FIELD_DEFINITION_TYPE.RADIO_GROUP,
44
- label: 'Color palette',
45
- name: 'palette',
46
- onChange: onChangePalette,
47
- options: paletteOptions,
48
- required: true,
49
- } as const satisfies FormFieldDefinition<FormFields>,
50
- ] as const, [onChangePalette, paletteOptions]);
51
-
52
- const values = useMemo<FormFields>(() => ({
53
- palette: currentPalette.name,
54
- }), [currentPalette.name]);
55
-
56
- const formMethods = useForm<FormFields>({
57
- values,
58
- });
59
- const { handleSubmit } = formMethods;
60
-
61
- const onFormSubmit = useCallback((_formValues: FormFields) => {
62
- // do nothing
63
- }, []);
64
-
65
- return (
66
- <GenericForm<FormFields>
67
- formFieldDefinitions={formFieldDefinitions}
68
- formId={formId}
69
- formMethods={formMethods}
70
- onSubmit={handleSubmit(onFormSubmit)}
71
- />
72
- );
73
- };