@rivm-loculus-tools/sequence-editor 1.7.0 → 1.8.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.
Files changed (33) hide show
  1. package/dist/_chunks/SequenceEditor.js +138 -120
  2. package/dist/_chunks/SequenceEditor.js.map +1 -1
  3. package/dist/_chunks/SequenceEditorEventBusService.js.map +1 -1
  4. package/dist/_chunks/SequenceEditorPageDrawer.js +97 -96
  5. package/dist/_chunks/SequenceEditorPageDrawer.js.map +1 -1
  6. package/dist/_chunks/SequenceEditorPageHeader.js +120 -0
  7. package/dist/_chunks/SequenceEditorPageHeader.js.map +1 -0
  8. package/dist/classes/services/SequenceEditorEventBusService/SequenceEditorEventBusService.d.ts +1 -0
  9. package/dist/components/app/SequenceEditorApp/index.js +4 -1
  10. package/dist/components/app/SequenceEditorApp/index.js.map +1 -1
  11. package/dist/components/ui/SequenceEditorPageHeader/SequenceEditorUndoRedoButtons.d.ts +1 -0
  12. package/dist/components/ui/SequenceEditorPageHeader/index.js +1 -109
  13. package/dist/components/ui/SequenceEditorRealignModal/index.js +2 -2
  14. package/dist/components/ui/SequenceEditorRealignModal/index.js.map +1 -1
  15. package/dist/constants/index.js +5 -4
  16. package/dist/constants/keyboard.js +2 -2
  17. package/dist/constants/keyboard.js.map +1 -1
  18. package/dist/constants/palette.d.ts +1 -2
  19. package/dist/constants/palette.js +162 -204
  20. package/dist/constants/palette.js.map +1 -1
  21. package/dist/constants/paletteSchemaData.d.ts +4 -0
  22. package/dist/constants/paletteSchemaData.js +48 -0
  23. package/dist/constants/paletteSchemaData.js.map +1 -0
  24. package/dist/pages/SequenceEditorMainPage/index.js +1 -0
  25. package/dist/pages/SequenceEditorMainPage/index.js.map +1 -1
  26. package/dist/utils/EditorUtil/index.js +83 -83
  27. package/dist/utils/EditorUtil/index.js.map +1 -1
  28. package/dist/utils/SequenceEditorStandardConfigUtil/index.js +1 -1
  29. package/dist/vite/paletteSchemaPlugin/index.d.ts +1 -1
  30. package/dist/vite/paletteSchemaPlugin/index.js +1 -1
  31. package/dist/vite/paletteSchemaPlugin/index.js.map +1 -1
  32. package/package.json +6 -2
  33. package/dist/components/ui/SequenceEditorPageHeader/index.js.map +0 -1
@@ -1,9 +1,10 @@
1
- import { CUSTOM_PALETTE_NAME as e } from "../models/palette.models.js";
2
- import { HEX_COLOR_REGEX as t, PaletteUtil as n } from "../utils/PaletteUtil/index.js";
3
- import { ALI_VIEW_CLUSTAL_X_AMINO_ACID_PALETTE as r, ALI_VIEW_DEFAULT_AMINO_ACID_PALETTE as i, ALI_VIEW_DEFAULT_NUCLEOTIDE_PALETTE as a, ALI_VIEW_FAST_NUCLEOTIDE_PALETTE as o, ALI_VIEW_SEA_VIEW_AMINO_ACID_PALETTE as s, ALI_VIEW_SEA_VIEW_NUCLEOTIDE_PALETTE as c, AMINO_ACID_SYMBOLS as l, AMINO_ACID_SYMBOL_LABELS as u, NUCLEOTIDE_SYMBOLS as d, NUCLEOTIDE_SYMBOL_LABELS as f, PALETTE_SCHEMA_URL_PATH as p } from "../constants/palette.js";
4
- import { t as m } from "./sequenceEditorStore.js";
5
- import { t as h } from "./react.js";
6
- import { KEYBOARD_SHORTCUTS as g } from "../constants/keyboard.js";
1
+ import { PALETTE_SCHEMA_URL_PATH as e } from "../constants/paletteSchemaData.js";
2
+ import { t } from "./sequenceEditorStore.js";
3
+ import { t as n } from "./react.js";
4
+ import { KEYBOARD_SHORTCUTS as r } from "../constants/keyboard.js";
5
+ import { CUSTOM_PALETTE_NAME as i } from "../models/palette.models.js";
6
+ import { HEX_COLOR_REGEX as a, PaletteUtil as o } from "../utils/PaletteUtil/index.js";
7
+ import { ALI_VIEW_CLUSTAL_X_AMINO_ACID_PALETTE as s, ALI_VIEW_DEFAULT_AMINO_ACID_PALETTE as c, ALI_VIEW_DEFAULT_NUCLEOTIDE_PALETTE as l, ALI_VIEW_FAST_NUCLEOTIDE_PALETTE as u, ALI_VIEW_SEA_VIEW_AMINO_ACID_PALETTE as d, ALI_VIEW_SEA_VIEW_NUCLEOTIDE_PALETTE as f, AMINO_ACID_SYMBOLS as p, AMINO_ACID_SYMBOL_LABELS as m, NUCLEOTIDE_SYMBOLS as h, NUCLEOTIDE_SYMBOL_LABELS as g } from "../constants/palette.js";
7
8
  import "../constants/index.js";
8
9
  import _, { useCallback as v, useEffect as y, useId as b, useMemo as x, useRef as S, useState as C } from "react";
9
10
  import { Accordion as w, AccordionDetails as T, AccordionSummary as E, Alert as D, Box as O, Button as k, ListItemButton as A, ListItemText as j, Typography as M } from "@mui/material";
@@ -1118,68 +1119,68 @@ var dt = _.forwardRef(({ value: e, format: t, onChange: n, adornmentPosition: r
1118
1119
  backgroundSelected: "Selected background",
1119
1120
  foreground: "Text",
1120
1121
  foregroundSelected: "Selected text"
1121
- }, ht = ({ currentPalette: n, customPalette: r, exportFileName: i, label: a, onPaletteChange: o, palettes: s, parsePalette: c, symbolLabels: l, symbols: u }) => {
1122
- let d = b(), f = S(null), [m, h] = C(null), g = v((e) => {
1123
- let t = e === "Custom" ? r : s.find((t) => t.name === e);
1124
- t && o(t);
1122
+ }, ht = ({ currentPalette: t, customPalette: n, exportFileName: r, label: o, onPaletteChange: s, palettes: c, parsePalette: l, symbolLabels: u, symbols: d }) => {
1123
+ let f = b(), p = S(null), [m, h] = C(null), g = v((e) => {
1124
+ let t = e === "Custom" ? n : c.find((t) => t.name === e);
1125
+ t && s(t);
1125
1126
  }, [
1126
- r,
1127
- o,
1128
- s
1129
- ]), _ = x(() => [...s.map((e) => ({
1127
+ n,
1128
+ s,
1129
+ c
1130
+ ]), _ = x(() => [...c.map((e) => ({
1130
1131
  label: e.name,
1131
1132
  value: e.name
1132
1133
  })), {
1133
- label: e,
1134
- value: e
1135
- }], [s]), y = x(() => [{
1134
+ label: i,
1135
+ value: i
1136
+ }], [c]), y = x(() => [{
1136
1137
  definition: F.RADIO_GROUP,
1137
- label: a,
1138
+ label: o,
1138
1139
  name: "palette",
1139
1140
  onChange: g,
1140
1141
  options: _,
1141
1142
  required: !0
1142
1143
  }], [
1143
- a,
1144
+ o,
1144
1145
  g,
1145
1146
  _
1146
- ]), w = x(() => ({ palette: n.name }), [n.name]), T = I({ values: w }), { handleSubmit: E } = T, A = v((e) => {}, []), j = v((e, n, i) => {
1147
- t.test(i) && o({
1148
- ...r,
1147
+ ]), w = x(() => ({ palette: t.name }), [t.name]), T = I({ values: w }), { handleSubmit: E } = T, A = v((e) => {}, []), j = v((e, t, r) => {
1148
+ a.test(r) && s({
1149
+ ...n,
1149
1150
  paletteColors: {
1150
- ...r.paletteColors,
1151
+ ...n.paletteColors,
1151
1152
  [e]: {
1152
- ...r.paletteColors[e],
1153
- [n]: i
1153
+ ...n.paletteColors[e],
1154
+ [t]: r
1154
1155
  }
1155
1156
  }
1156
1157
  });
1157
- }, [r, o]), N = v(async (t) => {
1158
- let n = t.currentTarget, r = n.files?.[0];
1159
- if (n.value = "", r) try {
1160
- o({
1161
- ...c(JSON.parse(await r.text())),
1162
- name: e
1158
+ }, [n, s]), N = v(async (e) => {
1159
+ let t = e.currentTarget, n = t.files?.[0];
1160
+ if (t.value = "", n) try {
1161
+ s({
1162
+ ...l(JSON.parse(await n.text())),
1163
+ name: i
1163
1164
  }), h(null);
1164
1165
  } catch (e) {
1165
1166
  let t = e instanceof Error ? e.message : "Unexpected error while reading the file.";
1166
1167
  h(`Could not import palette: ${t}`);
1167
1168
  }
1168
- }, [o, c]), ee = v(() => {
1169
- let e = {
1170
- ...n,
1171
- $schema: new URL(p, ie.getBaseURLWithPath()).href
1172
- }, t = new Blob([JSON.stringify(e, null, 2)], { type: "application/json" }), r = URL.createObjectURL(t);
1173
- ae.createDownloadUrl(r, i), URL.revokeObjectURL(r);
1174
- }, [n, i]), te = v(() => {
1175
- f.current?.click();
1169
+ }, [s, l]), ee = v(() => {
1170
+ let n = {
1171
+ ...t,
1172
+ $schema: ie.getBaseURLWithPath() + e
1173
+ }, i = new Blob([JSON.stringify(n, null, 2)], { type: "application/json" }), a = URL.createObjectURL(i);
1174
+ ae.createDownloadUrl(a, r), URL.revokeObjectURL(a);
1175
+ }, [t, r]), te = v(() => {
1176
+ p.current?.click();
1176
1177
  }, []);
1177
1178
  return /* @__PURE__ */ z(O, {
1178
1179
  sx: { "& + &": { mt: 2 } },
1179
1180
  children: [
1180
1181
  /* @__PURE__ */ R(P, {
1181
1182
  formFieldDefinitions: y,
1182
- formId: d,
1183
+ formId: f,
1183
1184
  formMethods: T,
1184
1185
  onSubmit: E(A)
1185
1186
  }),
@@ -1204,9 +1205,9 @@ var dt = _.forwardRef(({ value: e, format: t, onChange: n, adornmentPosition: r
1204
1205
  }),
1205
1206
  /* @__PURE__ */ R("input", {
1206
1207
  accept: ".json,application/json",
1207
- "aria-label": `Import ${a} JSON`,
1208
+ "aria-label": `Import ${o} JSON`,
1208
1209
  onChange: N,
1209
- ref: f,
1210
+ ref: p,
1210
1211
  style: { display: "none" },
1211
1212
  type: "file"
1212
1213
  })
@@ -1217,15 +1218,15 @@ var dt = _.forwardRef(({ value: e, format: t, onChange: n, adornmentPosition: r
1217
1218
  sx: { mt: 1 },
1218
1219
  children: m
1219
1220
  }),
1220
- n.name === "Custom" && /* @__PURE__ */ R(O, {
1221
+ t.name === "Custom" && /* @__PURE__ */ R(O, {
1221
1222
  sx: {
1222
1223
  display: "flex",
1223
1224
  flexDirection: "column",
1224
1225
  gap: 1,
1225
1226
  mt: 2
1226
1227
  },
1227
- children: u.map((e) => {
1228
- let t = String(e), n = `${l[e]} (${t})`, i = r.paletteColors[e];
1228
+ children: d.map((e) => {
1229
+ let t = String(e), r = `${u[e]} (${t})`, i = n.paletteColors[e];
1229
1230
  return /* @__PURE__ */ z(O, {
1230
1231
  sx: {
1231
1232
  borderBottom: "1px solid",
@@ -1238,7 +1239,7 @@ var dt = _.forwardRef(({ value: e, format: t, onChange: n, adornmentPosition: r
1238
1239
  mb: 1
1239
1240
  },
1240
1241
  variant: "body2",
1241
- children: n
1242
+ children: r
1242
1243
  }), /* @__PURE__ */ R(O, {
1243
1244
  sx: {
1244
1245
  display: "grid",
@@ -1247,7 +1248,7 @@ var dt = _.forwardRef(({ value: e, format: t, onChange: n, adornmentPosition: r
1247
1248
  },
1248
1249
  children: pt.map((t) => /* @__PURE__ */ R(ft, {
1249
1250
  field: t,
1250
- label: `${n} ${mt[t]}`,
1251
+ label: `${r} ${mt[t]}`,
1251
1252
  onColorChange: j,
1252
1253
  symbol: e,
1253
1254
  value: i[t]
@@ -1295,50 +1296,50 @@ var dt = _.forwardRef(({ value: e, format: t, onChange: n, adornmentPosition: r
1295
1296
  icon: ye,
1296
1297
  label: "Space"
1297
1298
  }]
1298
- ]), yt = typeof navigator < "u" && /Mac|iPhone|iPad|iPod/.test(navigator.platform), bt = [
1299
+ ]), yt = typeof navigator < "u" && /^(Mac|iPhone|iPad|iPod)/.test(navigator.userAgentData?.platform ?? navigator.platform), bt = [
1299
1300
  {
1300
1301
  name: "Selection",
1301
1302
  shortcuts: [
1302
- g.moveSelectionLeft,
1303
- g.moveSelectionRight,
1304
- g.moveSelectionUp,
1305
- g.moveSelectionDown,
1306
- g.expandSelectionLeft,
1307
- g.expandSelectionRight,
1308
- g.expandSelectionUp,
1309
- g.expandSelectionDown,
1310
- g.moveCellLeft,
1311
- g.moveCellRight
1303
+ r.moveSelectionLeft,
1304
+ r.moveSelectionRight,
1305
+ r.moveSelectionUp,
1306
+ r.moveSelectionDown,
1307
+ r.expandSelectionLeft,
1308
+ r.expandSelectionRight,
1309
+ r.expandSelectionUp,
1310
+ r.expandSelectionDown,
1311
+ r.moveCellLeft,
1312
+ r.moveCellRight
1312
1313
  ]
1313
1314
  },
1314
1315
  {
1315
1316
  name: "Rows",
1316
1317
  shortcuts: [
1317
- g.moveRowUp,
1318
- g.moveRowDown,
1319
- g.moveRowToStart,
1320
- g.moveRowToEnd
1318
+ r.moveRowUp,
1319
+ r.moveRowDown,
1320
+ r.moveRowToStart,
1321
+ r.moveRowToEnd
1321
1322
  ]
1322
1323
  },
1323
1324
  {
1324
1325
  name: "Navigation",
1325
1326
  shortcuts: [
1326
- g.scrollToLineStart,
1327
- g.scrollToLineEnd,
1328
- g.scrollPageUp,
1329
- g.scrollPageDown,
1330
- g.gotoPosition
1327
+ r.scrollToLineStart,
1328
+ r.scrollToLineEnd,
1329
+ r.scrollPageUp,
1330
+ r.scrollPageDown,
1331
+ r.gotoPosition
1331
1332
  ]
1332
1333
  },
1333
1334
  {
1334
1335
  name: "Editing",
1335
1336
  shortcuts: [
1336
- g.insertGap,
1337
- g.deleteBackward,
1338
- g.deleteSelection,
1339
- g.deleteBase,
1340
- g.undo,
1341
- g.redo
1337
+ r.insertGap,
1338
+ r.deleteBackward,
1339
+ r.deleteSelection,
1340
+ r.deleteBase,
1341
+ r.undo,
1342
+ r.redo
1342
1343
  ]
1343
1344
  }
1344
1345
  ], xt = (e) => {
@@ -1398,16 +1399,16 @@ var dt = _.forwardRef(({ value: e, format: t, onChange: n, adornmentPosition: r
1398
1399
  })
1399
1400
  });
1400
1401
  }, wt = (e) => {
1401
- let t = Object.values(g).find(({ description: t }) => t === e.currentTarget.dataset.shortcut);
1402
+ let t = Object.values(r).find(({ description: t }) => t === e.currentTarget.dataset.shortcut);
1402
1403
  if (!t) return;
1403
- let { code: n, key: r, modifiers: i = [] } = t.shortcut, a = xt(i);
1404
+ let { code: n, key: i, modifiers: a = [] } = t.shortcut, o = xt(a);
1404
1405
  t.callback(new KeyboardEvent("keydown", {
1405
- altKey: a.includes("Alt"),
1406
+ altKey: o.includes("Alt"),
1406
1407
  code: n ?? "",
1407
- ctrlKey: a.includes("Control"),
1408
- key: r ?? n ?? "",
1409
- metaKey: a.includes("Meta"),
1410
- shiftKey: a.includes("Shift")
1408
+ ctrlKey: o.includes("Control"),
1409
+ key: i ?? n ?? "",
1410
+ metaKey: o.includes("Meta"),
1411
+ shiftKey: o.includes("Shift")
1411
1412
  }));
1412
1413
  }, Tt = () => /* @__PURE__ */ R(O, {
1413
1414
  sx: {
@@ -1449,7 +1450,7 @@ var dt = _.forwardRef(({ value: e, format: t, onChange: n, adornmentPosition: r
1449
1450
  }, e.description))
1450
1451
  })] }, e.name))
1451
1452
  }), Et = () => {
1452
- let e = h(m, (e) => e.parsedMetadata), t = h(m, (e) => e.aminoAcidPalette), p = h(m, (e) => e.customAminoAcidPalette), g = h(m, (e) => e.customNucleotidePalette), _ = h(m, (e) => e.nucleotidePalette), b = h(m, (e) => e.setAminoAcidPalette), S = h(m, (e) => e.setCustomAminoAcidPalette), D = h(m, (e) => e.setCustomNucleotidePalette), k = h(m, (e) => e.setNucleotidePalette), A = h(m, (e) => e.meta), [j, P] = C([]), F = v((e) => {
1453
+ let e = n(t, (e) => e.parsedMetadata), r = n(t, (e) => e.aminoAcidPalette), i = n(t, (e) => e.customAminoAcidPalette), a = n(t, (e) => e.customNucleotidePalette), _ = n(t, (e) => e.nucleotidePalette), b = n(t, (e) => e.setAminoAcidPalette), S = n(t, (e) => e.setCustomAminoAcidPalette), D = n(t, (e) => e.setCustomNucleotidePalette), k = n(t, (e) => e.setNucleotidePalette), A = n(t, (e) => e.meta), [j, P] = C([]), F = v((e) => {
1453
1454
  P((t) => t.includes(e) ? t.filter((t) => t !== e) : [...t, e]);
1454
1455
  }, []), I = v((e) => {
1455
1456
  P((t) => t.filter((t) => t !== e));
@@ -1462,13 +1463,13 @@ var dt = _.forwardRef(({ value: e, format: t, onChange: n, adornmentPosition: r
1462
1463
  }, [D, k]), ce = v((e) => {
1463
1464
  b(e), e.name === "Custom" && S(e);
1464
1465
  }, [b, S]), le = x(() => [
1465
- a,
1466
- o,
1467
- c
1466
+ l,
1467
+ u,
1468
+ f
1468
1469
  ], []), B = x(() => [
1469
- i,
1470
- s,
1471
- r
1470
+ c,
1471
+ d,
1472
+ s
1472
1473
  ], []);
1473
1474
  return /* @__PURE__ */ z(re, { children: [/* @__PURE__ */ R(O, {
1474
1475
  sx: {
@@ -1556,24 +1557,24 @@ var dt = _.forwardRef(({ value: e, format: t, onChange: n, adornmentPosition: r
1556
1557
  },
1557
1558
  children: [/* @__PURE__ */ R(ht, {
1558
1559
  currentPalette: _,
1559
- customPalette: g,
1560
+ customPalette: a,
1560
1561
  exportFileName: "nucleotide-palette.json",
1561
1562
  label: "Nucleotide colors",
1562
1563
  onPaletteChange: L,
1563
1564
  palettes: le,
1564
- parsePalette: n.parseNucleotidePalette,
1565
- symbolLabels: f,
1566
- symbols: d
1565
+ parsePalette: o.parseNucleotidePalette,
1566
+ symbolLabels: g,
1567
+ symbols: h
1567
1568
  }), /* @__PURE__ */ R(ht, {
1568
- currentPalette: t,
1569
- customPalette: p,
1569
+ currentPalette: r,
1570
+ customPalette: i,
1570
1571
  exportFileName: "amino-acid-palette.json",
1571
1572
  label: "Amino-acid colors",
1572
1573
  onPaletteChange: ce,
1573
1574
  palettes: B,
1574
- parsePalette: n.parseAminoAcidPalette,
1575
- symbolLabels: u,
1576
- symbols: l
1575
+ parsePalette: o.parseAminoAcidPalette,
1576
+ symbolLabels: m,
1577
+ symbols: p
1577
1578
  })]
1578
1579
  })]
1579
1580
  }),