@jbrowse/plugin-grid-bookmark 2.8.0 → 2.10.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 (65) hide show
  1. package/dist/GridBookmarkWidget/components/BookmarkGrid.js +57 -48
  2. package/dist/GridBookmarkWidget/components/GridBookmarkWidget.js +110 -15
  3. package/dist/GridBookmarkWidget/components/Highlight/Highlight.d.ts +7 -0
  4. package/dist/GridBookmarkWidget/components/Highlight/Highlight.js +92 -0
  5. package/dist/GridBookmarkWidget/components/Highlight/index.d.ts +2 -0
  6. package/dist/GridBookmarkWidget/components/Highlight/index.js +19 -0
  7. package/dist/GridBookmarkWidget/components/{DeleteBookmarksDialog.d.ts → dialogs/DeleteBookmarksDialog.d.ts} +1 -1
  8. package/{esm/GridBookmarkWidget/components → dist/GridBookmarkWidget/components/dialogs}/EditBookmarkLabelDialog.d.ts +1 -1
  9. package/dist/GridBookmarkWidget/components/dialogs/EditHighlightColorDialog.d.ts +7 -0
  10. package/dist/GridBookmarkWidget/components/dialogs/EditHighlightColorDialog.js +48 -0
  11. package/dist/GridBookmarkWidget/components/{ExportBookmarksDialog.d.ts → dialogs/ExportBookmarksDialog.d.ts} +1 -1
  12. package/dist/GridBookmarkWidget/components/{ExportBookmarksDialog.js → dialogs/ExportBookmarksDialog.js} +12 -6
  13. package/dist/GridBookmarkWidget/components/dialogs/HighlightSettingsDialog.d.ts +7 -0
  14. package/dist/GridBookmarkWidget/components/dialogs/HighlightSettingsDialog.js +27 -0
  15. package/{esm/GridBookmarkWidget/components → dist/GridBookmarkWidget/components/dialogs}/ImportBookmarksDialog.d.ts +1 -1
  16. package/dist/GridBookmarkWidget/components/{ImportBookmarksDialog.js → dialogs/ImportBookmarksDialog.js} +2 -2
  17. package/dist/GridBookmarkWidget/components/{ShareBookmarksDialog.d.ts → dialogs/ShareBookmarksDialog.d.ts} +1 -1
  18. package/dist/GridBookmarkWidget/components/{ShareBookmarksDialog.js → dialogs/ShareBookmarksDialog.js} +1 -1
  19. package/dist/GridBookmarkWidget/index.js +3 -0
  20. package/dist/GridBookmarkWidget/model.d.ts +101 -0
  21. package/dist/GridBookmarkWidget/model.js +109 -5
  22. package/dist/index.js +55 -7
  23. package/esm/GridBookmarkWidget/components/BookmarkGrid.js +58 -49
  24. package/esm/GridBookmarkWidget/components/GridBookmarkWidget.js +87 -15
  25. package/esm/GridBookmarkWidget/components/Highlight/Highlight.d.ts +7 -0
  26. package/esm/GridBookmarkWidget/components/Highlight/Highlight.js +64 -0
  27. package/esm/GridBookmarkWidget/components/Highlight/index.d.ts +2 -0
  28. package/esm/GridBookmarkWidget/components/Highlight/index.js +13 -0
  29. package/esm/GridBookmarkWidget/components/{DeleteBookmarksDialog.d.ts → dialogs/DeleteBookmarksDialog.d.ts} +1 -1
  30. package/{dist/GridBookmarkWidget/components → esm/GridBookmarkWidget/components/dialogs}/EditBookmarkLabelDialog.d.ts +1 -1
  31. package/esm/GridBookmarkWidget/components/dialogs/EditHighlightColorDialog.d.ts +7 -0
  32. package/esm/GridBookmarkWidget/components/dialogs/EditHighlightColorDialog.js +23 -0
  33. package/esm/GridBookmarkWidget/components/{ExportBookmarksDialog.d.ts → dialogs/ExportBookmarksDialog.d.ts} +1 -1
  34. package/esm/GridBookmarkWidget/components/{ExportBookmarksDialog.js → dialogs/ExportBookmarksDialog.js} +12 -6
  35. package/esm/GridBookmarkWidget/components/dialogs/HighlightSettingsDialog.d.ts +7 -0
  36. package/esm/GridBookmarkWidget/components/dialogs/HighlightSettingsDialog.js +22 -0
  37. package/{dist/GridBookmarkWidget/components → esm/GridBookmarkWidget/components/dialogs}/ImportBookmarksDialog.d.ts +1 -1
  38. package/esm/GridBookmarkWidget/components/{ImportBookmarksDialog.js → dialogs/ImportBookmarksDialog.js} +2 -2
  39. package/esm/GridBookmarkWidget/components/{ShareBookmarksDialog.d.ts → dialogs/ShareBookmarksDialog.d.ts} +1 -1
  40. package/esm/GridBookmarkWidget/components/{ShareBookmarksDialog.js → dialogs/ShareBookmarksDialog.js} +1 -1
  41. package/esm/GridBookmarkWidget/index.js +3 -0
  42. package/esm/GridBookmarkWidget/model.d.ts +101 -0
  43. package/esm/GridBookmarkWidget/model.js +109 -5
  44. package/esm/index.js +55 -7
  45. package/package.json +2 -2
  46. package/dist/GridBookmarkWidget/components/DeleteBookmarks.d.ts +0 -6
  47. package/dist/GridBookmarkWidget/components/DeleteBookmarks.js +0 -41
  48. package/dist/GridBookmarkWidget/components/ExportBookmarks.d.ts +0 -6
  49. package/dist/GridBookmarkWidget/components/ExportBookmarks.js +0 -41
  50. package/dist/GridBookmarkWidget/components/ImportBookmarks.d.ts +0 -6
  51. package/dist/GridBookmarkWidget/components/ImportBookmarks.js +0 -42
  52. package/dist/GridBookmarkWidget/components/ShareBookmarks.d.ts +0 -6
  53. package/dist/GridBookmarkWidget/components/ShareBookmarks.js +0 -37
  54. package/esm/GridBookmarkWidget/components/DeleteBookmarks.d.ts +0 -6
  55. package/esm/GridBookmarkWidget/components/DeleteBookmarks.js +0 -13
  56. package/esm/GridBookmarkWidget/components/ExportBookmarks.d.ts +0 -6
  57. package/esm/GridBookmarkWidget/components/ExportBookmarks.js +0 -13
  58. package/esm/GridBookmarkWidget/components/ImportBookmarks.d.ts +0 -6
  59. package/esm/GridBookmarkWidget/components/ImportBookmarks.js +0 -14
  60. package/esm/GridBookmarkWidget/components/ShareBookmarks.d.ts +0 -6
  61. package/esm/GridBookmarkWidget/components/ShareBookmarks.js +0 -12
  62. /package/dist/GridBookmarkWidget/components/{DeleteBookmarksDialog.js → dialogs/DeleteBookmarksDialog.js} +0 -0
  63. /package/dist/GridBookmarkWidget/components/{EditBookmarkLabelDialog.js → dialogs/EditBookmarkLabelDialog.js} +0 -0
  64. /package/esm/GridBookmarkWidget/components/{DeleteBookmarksDialog.js → dialogs/DeleteBookmarksDialog.js} +0 -0
  65. /package/esm/GridBookmarkWidget/components/{EditBookmarkLabelDialog.js → dialogs/EditBookmarkLabelDialog.js} +0 -0
@@ -1,6 +1,7 @@
1
1
  import { Instance, SnapshotIn, IMSTArray } from 'mobx-state-tree';
2
2
  import PluginManager from '@jbrowse/core/PluginManager';
3
3
  import { Region } from '@jbrowse/core/util/types';
4
+ import { LinearGenomeViewModel } from '@jbrowse/plugin-linear-genome-view';
4
5
  declare const LabeledRegionModel: import("mobx-state-tree").IModelType<{
5
6
  refName: import("mobx-state-tree").ISimpleType<string>;
6
7
  start: import("mobx-state-tree").ISimpleType<number>;
@@ -10,25 +11,38 @@ declare const LabeledRegionModel: import("mobx-state-tree").IModelType<{
10
11
  assemblyName: import("mobx-state-tree").ISimpleType<string>;
11
12
  } & {
12
13
  label: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
14
+ highlight: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
13
15
  }, {
14
16
  setRefName(newRefName: string): void;
15
17
  } & {
16
18
  setLabel(label: string): void;
19
+ setHighlight(color: string): void;
17
20
  }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>;
21
+ export interface IExtendedLGV extends LinearGenomeViewModel {
22
+ showBookmarkHighlights: boolean;
23
+ showBookmarkLabels: boolean;
24
+ toggleShowBookmarkHighlights: (arg: boolean) => {};
25
+ toggleShowBookmarkLabels: (arg: boolean) => {};
26
+ }
18
27
  export interface ILabeledRegionModel extends SnapshotIn<typeof LabeledRegionModel> {
19
28
  refName: string;
20
29
  start: number;
21
30
  end: number;
22
31
  reversed: boolean;
32
+ highlight: string;
23
33
  assemblyName: string;
24
34
  label: string;
25
35
  setRefName: (newRefName: string) => void;
26
36
  setLabel: (label: string) => void;
37
+ setHighlight: (color: string) => void;
27
38
  }
28
39
  export interface IExtendedLabeledRegionModel extends ILabeledRegionModel {
29
40
  id: number;
30
41
  correspondingObj: ILabeledRegionModel;
31
42
  }
43
+ /**
44
+ * #stateModel GridBookmarkWidgetModel
45
+ */
32
46
  export default function f(_pluginManager: PluginManager): import("mobx-state-tree").IModelType<{
33
47
  /**
34
48
  * #property
@@ -51,18 +65,37 @@ export default function f(_pluginManager: PluginManager): import("mobx-state-tre
51
65
  assemblyName: import("mobx-state-tree").ISimpleType<string>;
52
66
  } & {
53
67
  label: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
68
+ highlight: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
54
69
  }, {
55
70
  setRefName(newRefName: string): void;
56
71
  } & {
57
72
  setLabel(label: string): void;
73
+ setHighlight(color: string): void;
58
74
  }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>, [undefined]>;
59
75
  }, {
60
76
  selectedBookmarks: IExtendedLabeledRegionModel[];
61
77
  selectedAssembliesPre: string[] | undefined;
62
78
  } & {
79
+ /**
80
+ * #getter
81
+ */
63
82
  readonly bookmarkAssemblies: string[];
83
+ /**
84
+ * #getter
85
+ */
64
86
  readonly validAssemblies: Set<string>;
87
+ /**
88
+ * #getter
89
+ */
90
+ readonly areBookmarksHighlightedOnAllOpenViews: boolean;
91
+ /**
92
+ * #getter
93
+ */
94
+ readonly areBookmarksHighlightLabelsOnAllOpenViews: boolean;
65
95
  } & {
96
+ /**
97
+ * #getter
98
+ */
66
99
  readonly bookmarksWithValidAssemblies: ({
67
100
  refName: string;
68
101
  start: number;
@@ -70,10 +103,12 @@ export default function f(_pluginManager: PluginManager): import("mobx-state-tre
70
103
  reversed: boolean;
71
104
  assemblyName: string;
72
105
  label: string;
106
+ highlight: string;
73
107
  } & import("mobx-state-tree/dist/internal").NonEmptyObject & {
74
108
  setRefName(newRefName: string): void;
75
109
  } & {
76
110
  setLabel(label: string): void;
111
+ setHighlight(color: string): void;
77
112
  } & import("mobx-state-tree").IStateTreeNode<import("mobx-state-tree").IModelType<{
78
113
  refName: import("mobx-state-tree").ISimpleType<string>;
79
114
  start: import("mobx-state-tree").ISimpleType<number>;
@@ -83,12 +118,17 @@ export default function f(_pluginManager: PluginManager): import("mobx-state-tre
83
118
  assemblyName: import("mobx-state-tree").ISimpleType<string>;
84
119
  } & {
85
120
  label: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
121
+ highlight: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
86
122
  }, {
87
123
  setRefName(newRefName: string): void;
88
124
  } & {
89
125
  setLabel(label: string): void;
126
+ setHighlight(color: string): void;
90
127
  }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>)[];
91
128
  } & {
129
+ /**
130
+ * #getter
131
+ */
92
132
  readonly sharedBookmarksModel: {
93
133
  sharedBookmarks: (IMSTArray<import("mobx-state-tree").IModelType<{
94
134
  refName: import("mobx-state-tree").ISimpleType<string>;
@@ -99,10 +139,12 @@ export default function f(_pluginManager: PluginManager): import("mobx-state-tre
99
139
  assemblyName: import("mobx-state-tree").ISimpleType<string>;
100
140
  } & {
101
141
  label: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
142
+ highlight: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
102
143
  }, {
103
144
  setRefName(newRefName: string): void;
104
145
  } & {
105
146
  setLabel(label: string): void;
147
+ setHighlight(color: string): void;
106
148
  }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>> & import("mobx-state-tree").IStateTreeNode<import("mobx-state-tree").IMaybe<import("mobx-state-tree").IArrayType<import("mobx-state-tree").IModelType<{
107
149
  refName: import("mobx-state-tree").ISimpleType<string>;
108
150
  start: import("mobx-state-tree").ISimpleType<number>;
@@ -112,10 +154,12 @@ export default function f(_pluginManager: PluginManager): import("mobx-state-tre
112
154
  assemblyName: import("mobx-state-tree").ISimpleType<string>;
113
155
  } & {
114
156
  label: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
157
+ highlight: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
115
158
  }, {
116
159
  setRefName(newRefName: string): void;
117
160
  } & {
118
161
  setLabel(label: string): void;
162
+ setHighlight(color: string): void;
119
163
  }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>>>) | undefined;
120
164
  } & import("mobx-state-tree/dist/internal").NonEmptyObject & import("mobx-state-tree").IStateTreeNode<import("mobx-state-tree").IModelType<{
121
165
  sharedBookmarks: import("mobx-state-tree").IMaybe<import("mobx-state-tree").IArrayType<import("mobx-state-tree").IModelType<{
@@ -127,12 +171,17 @@ export default function f(_pluginManager: PluginManager): import("mobx-state-tre
127
171
  assemblyName: import("mobx-state-tree").ISimpleType<string>;
128
172
  } & {
129
173
  label: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
174
+ highlight: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
130
175
  }, {
131
176
  setRefName(newRefName: string): void;
132
177
  } & {
133
178
  setLabel(label: string): void;
179
+ setHighlight(color: string): void;
134
180
  }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>>;
135
181
  }, {}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>;
182
+ /**
183
+ * #getter
184
+ */
136
185
  readonly allBookmarksModel: {
137
186
  sharedBookmarks: (IMSTArray<import("mobx-state-tree").IModelType<{
138
187
  refName: import("mobx-state-tree").ISimpleType<string>;
@@ -143,10 +192,12 @@ export default function f(_pluginManager: PluginManager): import("mobx-state-tre
143
192
  assemblyName: import("mobx-state-tree").ISimpleType<string>;
144
193
  } & {
145
194
  label: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
195
+ highlight: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
146
196
  }, {
147
197
  setRefName(newRefName: string): void;
148
198
  } & {
149
199
  setLabel(label: string): void;
200
+ setHighlight(color: string): void;
150
201
  }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>> & import("mobx-state-tree").IStateTreeNode<import("mobx-state-tree").IMaybe<import("mobx-state-tree").IArrayType<import("mobx-state-tree").IModelType<{
151
202
  refName: import("mobx-state-tree").ISimpleType<string>;
152
203
  start: import("mobx-state-tree").ISimpleType<number>;
@@ -156,10 +207,12 @@ export default function f(_pluginManager: PluginManager): import("mobx-state-tre
156
207
  assemblyName: import("mobx-state-tree").ISimpleType<string>;
157
208
  } & {
158
209
  label: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
210
+ highlight: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
159
211
  }, {
160
212
  setRefName(newRefName: string): void;
161
213
  } & {
162
214
  setLabel(label: string): void;
215
+ setHighlight(color: string): void;
163
216
  }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>>>) | undefined;
164
217
  } & import("mobx-state-tree/dist/internal").NonEmptyObject & import("mobx-state-tree").IStateTreeNode<import("mobx-state-tree").IModelType<{
165
218
  sharedBookmarks: import("mobx-state-tree").IMaybe<import("mobx-state-tree").IArrayType<import("mobx-state-tree").IModelType<{
@@ -171,25 +224,73 @@ export default function f(_pluginManager: PluginManager): import("mobx-state-tre
171
224
  assemblyName: import("mobx-state-tree").ISimpleType<string>;
172
225
  } & {
173
226
  label: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
227
+ highlight: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
174
228
  }, {
175
229
  setRefName(newRefName: string): void;
176
230
  } & {
177
231
  setLabel(label: string): void;
232
+ setHighlight(color: string): void;
178
233
  }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>>;
179
234
  }, {}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>;
180
235
  } & {
236
+ /**
237
+ * #action
238
+ */
181
239
  setSelectedAssemblies(assemblies?: string[]): void;
182
240
  } & {
241
+ /**
242
+ * #getter
243
+ */
183
244
  readonly selectedAssemblies: string[];
184
245
  } & {
246
+ /**
247
+ * #action
248
+ */
185
249
  importBookmarks(regions: Region[]): void;
250
+ /**
251
+ * #action
252
+ */
186
253
  addBookmark(region: Region): void;
254
+ /**
255
+ * #action
256
+ */
187
257
  removeBookmark(index: number): void;
258
+ /**
259
+ * #action
260
+ */
188
261
  updateBookmarkLabel(bookmark: IExtendedLabeledRegionModel, label: string): void;
262
+ /**
263
+ * #action
264
+ */
265
+ updateBookmarkHighlight(bookmark: IExtendedLabeledRegionModel, color: string): void;
266
+ /**
267
+ * #action
268
+ */
269
+ updateBulkBookmarkHighlights(color: string): void;
270
+ /**
271
+ * #action
272
+ */
189
273
  setSelectedBookmarks(bookmarks: IExtendedLabeledRegionModel[]): void;
274
+ /**
275
+ * #action
276
+ */
190
277
  setBookmarkedRegions(regions: IMSTArray<typeof LabeledRegionModel>): void;
278
+ /**
279
+ * #action
280
+ */
281
+ setHighlightToggle(toggle: boolean): void;
282
+ /**
283
+ * #action
284
+ */
285
+ setLabelToggle(toggle: boolean): void;
191
286
  } & {
287
+ /**
288
+ * #action
289
+ */
192
290
  clearAllBookmarks(): void;
291
+ /**
292
+ * #action
293
+ */
193
294
  clearSelectedBookmarks(): void;
194
295
  } & {
195
296
  afterAttach(): void;
@@ -5,11 +5,15 @@ import { autorun } from 'mobx';
5
5
  const LabeledRegionModel = types
6
6
  .compose(RegionModel, types.model('Label', {
7
7
  label: types.optional(types.string, ''),
8
+ highlight: types.optional(types.string, 'rgba(247, 129, 192, 0.35)'),
8
9
  }))
9
10
  .actions(self => ({
10
11
  setLabel(label) {
11
12
  self.label = label;
12
13
  },
14
+ setHighlight(color) {
15
+ self.highlight = color;
16
+ },
13
17
  }));
14
18
  const SharedBookmarksModel = types.model('SharedBookmarksModel', {
15
19
  sharedBookmarks: types.maybe(types.array(LabeledRegionModel)),
@@ -17,6 +21,9 @@ const SharedBookmarksModel = types.model('SharedBookmarksModel', {
17
21
  const localStorageKeyF = () => typeof window !== undefined
18
22
  ? `bookmarks-${[window.location.host + window.location.pathname].join('-')}`
19
23
  : 'empty';
24
+ /**
25
+ * #stateModel GridBookmarkWidgetModel
26
+ */
20
27
  export default function f(_pluginManager) {
21
28
  return types
22
29
  .model('GridBookmarkModel', {
@@ -39,20 +46,46 @@ export default function f(_pluginManager) {
39
46
  selectedAssembliesPre: undefined,
40
47
  }))
41
48
  .views(self => ({
49
+ /**
50
+ * #getter
51
+ */
42
52
  get bookmarkAssemblies() {
43
53
  return [...new Set(self.bookmarks.map(r => r.assemblyName))];
44
54
  },
55
+ /**
56
+ * #getter
57
+ */
45
58
  get validAssemblies() {
46
59
  const { assemblyManager } = getSession(self);
47
60
  return new Set(this.bookmarkAssemblies.filter(a => assemblyManager.get(a)));
48
61
  },
62
+ /**
63
+ * #getter
64
+ */
65
+ get areBookmarksHighlightedOnAllOpenViews() {
66
+ const { views } = getSession(self);
67
+ return views.every(v => 'showBookmarkHighlights' in v ? v.showBookmarkHighlights : true);
68
+ },
69
+ /**
70
+ * #getter
71
+ */
72
+ get areBookmarksHighlightLabelsOnAllOpenViews() {
73
+ const { views } = getSession(self);
74
+ return views.every(v => 'showBookmarkLabels' in v ? v.showBookmarkLabels : true);
75
+ },
49
76
  }))
50
77
  .views(self => ({
78
+ /**
79
+ * #getter
80
+ */
51
81
  get bookmarksWithValidAssemblies() {
52
82
  return self.bookmarks.filter(e => self.validAssemblies.has(e.assemblyName));
53
83
  },
54
84
  }))
55
85
  .views(self => ({
86
+ /**
87
+ * #getter
88
+ */
56
89
  get sharedBookmarksModel() {
57
90
  // requires cloning bookmarks with JSON.stringify/parse to avoid duplicate
58
91
  // reference to same object in the same state tree, will otherwise error
@@ -61,6 +94,9 @@ export default function f(_pluginManager) {
61
94
  sharedBookmarks: JSON.parse(JSON.stringify(self.selectedBookmarks)),
62
95
  });
63
96
  },
97
+ /**
98
+ * #getter
99
+ */
64
100
  get allBookmarksModel() {
65
101
  // requires cloning bookmarks with JSON.stringify/parse to avoid duplicate
66
102
  // reference to same object in the same state tree, will otherwise error
@@ -71,44 +107,102 @@ export default function f(_pluginManager) {
71
107
  },
72
108
  }))
73
109
  .actions(self => ({
110
+ /**
111
+ * #action
112
+ */
74
113
  setSelectedAssemblies(assemblies) {
75
114
  self.selectedAssembliesPre = assemblies;
76
115
  },
77
116
  }))
78
117
  .views(self => ({
118
+ /**
119
+ * #getter
120
+ */
79
121
  get selectedAssemblies() {
80
122
  var _a, _b;
81
123
  return ((_b = (_a = self.selectedAssembliesPre) === null || _a === void 0 ? void 0 : _a.filter(f => self.validAssemblies.has(f))) !== null && _b !== void 0 ? _b : [...self.validAssemblies]);
82
124
  },
83
125
  }))
84
126
  .actions(self => ({
127
+ /**
128
+ * #action
129
+ */
85
130
  importBookmarks(regions) {
86
131
  self.bookmarks = cast([...self.bookmarks, ...regions]);
87
132
  },
133
+ /**
134
+ * #action
135
+ */
88
136
  addBookmark(region) {
89
137
  self.bookmarks.push(region);
90
138
  },
139
+ /**
140
+ * #action
141
+ */
91
142
  removeBookmark(index) {
92
143
  self.bookmarks.splice(index, 1);
93
144
  },
145
+ /**
146
+ * #action
147
+ */
94
148
  updateBookmarkLabel(bookmark, label) {
95
149
  bookmark.correspondingObj.setLabel(label);
96
150
  },
151
+ /**
152
+ * #action
153
+ */
154
+ updateBookmarkHighlight(bookmark, color) {
155
+ bookmark.correspondingObj.setHighlight(color);
156
+ },
157
+ /**
158
+ * #action
159
+ */
160
+ updateBulkBookmarkHighlights(color) {
161
+ self.selectedBookmarks.forEach(bookmark => this.updateBookmarkHighlight(bookmark, color));
162
+ },
163
+ /**
164
+ * #action
165
+ */
97
166
  setSelectedBookmarks(bookmarks) {
98
167
  self.selectedBookmarks = bookmarks;
99
168
  },
169
+ /**
170
+ * #action
171
+ */
100
172
  setBookmarkedRegions(regions) {
101
173
  self.bookmarks = cast(regions);
102
174
  },
175
+ /**
176
+ * #action
177
+ */
178
+ setHighlightToggle(toggle) {
179
+ const { views } = getSession(self);
180
+ views.forEach(view => {
181
+ var _a;
182
+ (_a = view.toggleShowBookmarkHighlights) === null || _a === void 0 ? void 0 : _a.call(view, toggle);
183
+ });
184
+ },
185
+ /**
186
+ * #action
187
+ */
188
+ setLabelToggle(toggle) {
189
+ const { views } = getSession(self);
190
+ views.forEach(view => {
191
+ var _a;
192
+ (_a = view.toggleShowBookmarkLabels) === null || _a === void 0 ? void 0 : _a.call(view, toggle);
193
+ });
194
+ },
103
195
  }))
104
196
  .actions(self => ({
197
+ /**
198
+ * #action
199
+ */
105
200
  clearAllBookmarks() {
106
- for (const bookmark of self.bookmarks) {
107
- if (self.validAssemblies.has(bookmark.assemblyName)) {
108
- self.bookmarks.remove(bookmark);
109
- }
110
- }
201
+ self.setBookmarkedRegions(self.bookmarks.filter(bookmark => !self.validAssemblies.has(bookmark.assemblyName)));
111
202
  },
203
+ /**
204
+ * #action
205
+ */
112
206
  clearSelectedBookmarks() {
113
207
  for (const bookmark of self.selectedBookmarks) {
114
208
  self.bookmarks.remove(bookmark.correspondingObj);
@@ -119,6 +213,16 @@ export default function f(_pluginManager) {
119
213
  .actions(self => ({
120
214
  afterAttach() {
121
215
  const key = localStorageKeyF();
216
+ function handler(e) {
217
+ if (e.key === key) {
218
+ const localStorage = JSON.parse(localStorageGetItem(key) || '[]');
219
+ self.setBookmarkedRegions(localStorage);
220
+ }
221
+ }
222
+ window.addEventListener('storage', handler);
223
+ addDisposer(self, () => {
224
+ window.removeEventListener('storage', handler);
225
+ });
122
226
  addDisposer(self, autorun(() => {
123
227
  localStorageSetItem(key, JSON.stringify(self.bookmarks));
124
228
  }));
package/esm/index.js CHANGED
@@ -3,6 +3,8 @@ import { getSession, isAbstractMenuManager, isSessionModelWithWidgets, } from '@
3
3
  // icons
4
4
  import BookmarkIcon from '@mui/icons-material/Bookmark';
5
5
  import BookmarksIcon from '@mui/icons-material/Bookmarks';
6
+ import HighlightIcon from '@mui/icons-material/Highlight';
7
+ import LabelIcon from '@mui/icons-material/Label';
6
8
  import GridBookmarkWidgetF from './GridBookmarkWidget';
7
9
  export default class extends Plugin {
8
10
  constructor() {
@@ -16,7 +18,33 @@ export default class extends Plugin {
16
18
  const { stateModel } = pluggableElement;
17
19
  const lgv = stateModel;
18
20
  const newStateModel = lgv
21
+ .props({
22
+ /**
23
+ * #property
24
+ * show the bookmark highlights on this track
25
+ */
26
+ showBookmarkHighlights: true,
27
+ /**
28
+ * #property
29
+ * show the bookmark labels on this track
30
+ */
31
+ showBookmarkLabels: true,
32
+ })
19
33
  .actions(self => ({
34
+ /**
35
+ * #action
36
+ */
37
+ toggleShowBookmarkHighlights(toggle) {
38
+ self.showBookmarkHighlights =
39
+ toggle !== undefined ? toggle : !self.showBookmarkHighlights;
40
+ },
41
+ /**
42
+ * #action
43
+ */
44
+ toggleShowBookmarkLabels(toggle) {
45
+ self.showBookmarkLabels =
46
+ toggle !== undefined ? toggle : !self.showBookmarkLabels;
47
+ },
20
48
  activateBookmarkWidget() {
21
49
  const session = getSession(self);
22
50
  if (isSessionModelWithWidgets(session)) {
@@ -59,14 +87,34 @@ export default class extends Plugin {
59
87
  ...superMenuItems(),
60
88
  { type: 'divider' },
61
89
  {
62
- label: 'Open bookmark widget',
90
+ label: 'Bookmarks',
63
91
  icon: BookmarksIcon,
64
- onClick: () => self.activateBookmarkWidget(),
65
- },
66
- {
67
- label: 'Bookmark current region',
68
- icon: BookmarkIcon,
69
- onClick: () => self.bookmarkCurrentRegion(),
92
+ subMenu: [
93
+ {
94
+ label: 'Open bookmark widget',
95
+ icon: BookmarksIcon,
96
+ onClick: () => self.activateBookmarkWidget(),
97
+ },
98
+ {
99
+ label: 'Bookmark current region',
100
+ icon: BookmarkIcon,
101
+ onClick: () => self.bookmarkCurrentRegion(),
102
+ },
103
+ {
104
+ label: 'Toggle bookmark highlights',
105
+ icon: HighlightIcon,
106
+ type: 'checkbox',
107
+ checked: self.showBookmarkHighlights,
108
+ onClick: () => self.toggleShowBookmarkHighlights(),
109
+ },
110
+ {
111
+ label: 'Toggle bookmark labels',
112
+ icon: LabelIcon,
113
+ type: 'checkbox',
114
+ checked: self.showBookmarkLabels,
115
+ onClick: () => self.toggleShowBookmarkLabels(),
116
+ },
117
+ ],
70
118
  },
71
119
  ];
72
120
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jbrowse/plugin-grid-bookmark",
3
- "version": "2.8.0",
3
+ "version": "2.10.0",
4
4
  "description": "JBrowse 2 grid bookmark widget",
5
5
  "keywords": [
6
6
  "jbrowse",
@@ -59,5 +59,5 @@
59
59
  "distModule": "esm/index.js",
60
60
  "srcModule": "src/index.ts",
61
61
  "module": "esm/index.js",
62
- "gitHead": "ee8c2bdc8bd4f1a70b1eefda984f04a2830d9ca0"
62
+ "gitHead": "223d8bfb68fd1bacaf22852639ad5920f1b7f43b"
63
63
  }
@@ -1,6 +0,0 @@
1
- import React from 'react';
2
- import { GridBookmarkModel } from '../model';
3
- declare function DeleteBookmarks({ model }: {
4
- model: GridBookmarkModel;
5
- }): React.JSX.Element;
6
- export default DeleteBookmarks;
@@ -1,41 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- const react_1 = __importStar(require("react"));
30
- const material_1 = require("@mui/material");
31
- // icons
32
- const Delete_1 = __importDefault(require("@mui/icons-material/Delete"));
33
- const DeleteBookmarksDialog = (0, react_1.lazy)(() => Promise.resolve().then(() => __importStar(require('./DeleteBookmarksDialog'))));
34
- function DeleteBookmarks({ model }) {
35
- const [open, setOpen] = (0, react_1.useState)(false);
36
- return (react_1.default.createElement(react_1.default.Fragment, null,
37
- react_1.default.createElement(material_1.Button, { startIcon: react_1.default.createElement(Delete_1.default, null), "aria-label": "clear bookmarks", onClick: () => setOpen(true) }, "Delete"),
38
- open ? (react_1.default.createElement(react_1.Suspense, { fallback: react_1.default.createElement(react_1.default.Fragment, null) },
39
- react_1.default.createElement(DeleteBookmarksDialog, { model: model, onClose: () => setOpen(false) }))) : null));
40
- }
41
- exports.default = DeleteBookmarks;
@@ -1,6 +0,0 @@
1
- import React from 'react';
2
- import { GridBookmarkModel } from '../model';
3
- declare const ExportBookmarks: ({ model, }: {
4
- model: GridBookmarkModel;
5
- }) => React.JSX.Element;
6
- export default ExportBookmarks;
@@ -1,41 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- const react_1 = __importStar(require("react"));
30
- const mobx_react_1 = require("mobx-react");
31
- const material_1 = require("@mui/material");
32
- const GetApp_1 = __importDefault(require("@mui/icons-material/GetApp"));
33
- const ExportBookmarksDialog = (0, react_1.lazy)(() => Promise.resolve().then(() => __importStar(require('./ExportBookmarksDialog'))));
34
- const ExportBookmarks = (0, mobx_react_1.observer)(function ExportBookmarks({ model, }) {
35
- const [open, setOpen] = (0, react_1.useState)(false);
36
- return (react_1.default.createElement(react_1.default.Fragment, null,
37
- react_1.default.createElement(material_1.Button, { startIcon: react_1.default.createElement(GetApp_1.default, null), onClick: () => setOpen(true), "data-testid": "export_button" }, "Export"),
38
- open ? (react_1.default.createElement(react_1.Suspense, { fallback: react_1.default.createElement(react_1.default.Fragment, null) },
39
- react_1.default.createElement(ExportBookmarksDialog, { onClose: () => setOpen(false), model: model }))) : null));
40
- });
41
- exports.default = ExportBookmarks;
@@ -1,6 +0,0 @@
1
- import React from 'react';
2
- import { GridBookmarkModel } from '../model';
3
- declare const ImportBookmarks: ({ model, }: {
4
- model: GridBookmarkModel;
5
- }) => React.JSX.Element;
6
- export default ImportBookmarks;