@teselagen/ove 0.7.28 → 0.7.29

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 (285) hide show
  1. package/index.cjs.js +1055 -996
  2. package/index.es.js +1055 -996
  3. package/index.umd.js +189036 -0
  4. package/ove.css +1 -1
  5. package/package.json +2 -6
  6. package/src/helperComponents/PropertiesDialog/TranslationProperties.js +1 -1
  7. package/AASliver.js +0 -187
  8. package/AddLaddersDialog.js +0 -82
  9. package/AdditionalCutsiteInfoDialog.js +0 -599
  10. package/AlignmentVisibilityTool.js +0 -105
  11. package/AnnotationContainerHolder.js +0 -20
  12. package/AnnotationPositioner.js +0 -27
  13. package/AutoAnnotate.js +0 -501
  14. package/AutoAnnotateBpMatchingDialog.js +0 -208
  15. package/Axis.js +0 -151
  16. package/AxisNumbers.js +0 -35
  17. package/Browser.js +0 -106
  18. package/Caret.js +0 -63
  19. package/Chromatogram.js +0 -293
  20. package/CircularDnaSequence.js +0 -73
  21. package/CircularZoomMinimap.js +0 -16
  22. package/ColorPicker.js +0 -30
  23. package/CommandHotkeyHandler.js +0 -44
  24. package/CreateAnnotationsPage.js +0 -98
  25. package/Cutsite.js +0 -18
  26. package/CutsiteProperties.js +0 -176
  27. package/CutsiteSelectionLayers.js +0 -47
  28. package/Cutsites.js +0 -271
  29. package/DeletionLayer.js +0 -28
  30. package/DropHandler.css +0 -21
  31. package/DropHandler.js +0 -64
  32. package/EditCaretPosition.js +0 -234
  33. package/EditTrackNameDialog.js +0 -30
  34. package/Feature.js +0 -83
  35. package/FeatureProperties.js +0 -6
  36. package/FillWindow.js +0 -47
  37. package/GenbankView.js +0 -74
  38. package/GeneralProperties.js +0 -117
  39. package/GenericAnnotationProperties.js +0 -406
  40. package/GlobalDialog.js +0 -73
  41. package/GlobalDialogUtils.js +0 -110
  42. package/GoToDialog.js +0 -25
  43. package/HorizontalPanelDragHandle.js +0 -35
  44. package/Keyboard.js +0 -85
  45. package/Labels.js +0 -327
  46. package/Ladder.css +0 -20
  47. package/Ladder.js +0 -303
  48. package/MeltingTemp.js +0 -85
  49. package/Menlo.ttf +0 -0
  50. package/Minimap.js +0 -515
  51. package/Mismatches.js +0 -134
  52. package/Monaco.ttf +0 -0
  53. package/MultipleSeqsDetectedOnImportDialog.js +0 -74
  54. package/Orf.js +0 -109
  55. package/OrfProperties.js +0 -117
  56. package/Orfs.js +0 -35
  57. package/PCRTool.js +0 -179
  58. package/PairwiseAlignmentView.js +0 -68
  59. package/Part.js +0 -34
  60. package/PartProperties.js +0 -9
  61. package/PassThrough.js +0 -3
  62. package/PerformantSelectionLayer.js +0 -32
  63. package/PinchHelper.js +0 -24
  64. package/PointedAnnotation.js +0 -347
  65. package/PositionAnnotationOnCircle.js +0 -26
  66. package/Primer.js +0 -41
  67. package/PrimerProperties.js +0 -19
  68. package/ReflexContainer.js +0 -802
  69. package/ReflexElement.js +0 -160
  70. package/ReflexEvents.js +0 -77
  71. package/ReflexSplitter.js +0 -205
  72. package/RenameSequenceDialog.js +0 -7
  73. package/RotateCircularViewSlider.js +0 -93
  74. package/SelectDialog.js +0 -150
  75. package/SequenceName.js +0 -15
  76. package/SimpleCircularOrLinearView.js +0 -381
  77. package/SimpleOligoPreview.js +0 -39
  78. package/SingleEnzymeCutsiteInfo.js +0 -139
  79. package/ToolbarItem.js +0 -192
  80. package/Translation.js +0 -198
  81. package/TranslationProperties.js +0 -149
  82. package/UncontrolledSliderWithPlusMinusBtns.css +0 -5
  83. package/UncontrolledSliderWithPlusMinusBtns.js +0 -134
  84. package/VeTopRightContainer.js +0 -12
  85. package/ZoomCircularViewSlider.js +0 -62
  86. package/ZoomLinearView.js +0 -47
  87. package/addAlignment.js +0 -6
  88. package/addMetaToActionCreators.js +0 -12
  89. package/addWrappedAddons.js +0 -20
  90. package/alignmentTool.js +0 -503
  91. package/alignments.js +0 -379
  92. package/annotationLabelVisibility.js +0 -2
  93. package/annotationSearchSelector.js +0 -24
  94. package/annotationTypes.js +0 -35
  95. package/annotationVisibility.js +0 -196
  96. package/annotationsToSupport.js +0 -104
  97. package/arrayToObjWithIds.js +0 -17
  98. package/arrayUtils.js +0 -19
  99. package/array_move.js +0 -10
  100. package/calculateTickMarkPositionsForGivenRange.js +0 -47
  101. package/caretPosition.js +0 -27
  102. package/cdsFeaturesSelector.js +0 -9
  103. package/charWidth.js +0 -22
  104. package/circular.js +0 -19
  105. package/circularSelector.js +0 -4
  106. package/clickAndDragUtils.js +0 -576
  107. package/coerceInitialValue.js +0 -7
  108. package/combineReducersDontIgnoreKeys.js +0 -12
  109. package/commandUtils.js +0 -20
  110. package/constants.js +0 -2
  111. package/copyOptions.js +0 -34
  112. package/createFragmentLines.js +0 -120
  113. package/createMergedDefaultStateReducer.js +0 -30
  114. package/createMetaAction.js +0 -12
  115. package/createSequenceInputPopup.js +0 -290
  116. package/createSequenceInputPopupStyle.css +0 -87
  117. package/createSimpleDialog.js +0 -89
  118. package/createYourOwnEnzyme.js +0 -39
  119. package/cutsiteLabelColorSelector.js +0 -6
  120. package/cutsiteTool.js +0 -88
  121. package/cutsitesByRangeSelector.js +0 -5
  122. package/cutsitesSelector.js +0 -61
  123. package/darkmode.css +0 -98
  124. package/defaultConfig.js +0 -150
  125. package/deletionLayers.js +0 -36
  126. package/description.js +0 -21
  127. package/digestTool.js +0 -34
  128. package/dnaToColor.js +0 -17
  129. package/downloadTool.js +0 -39
  130. package/draggableClassnames.js +0 -5
  131. package/drawAnnotations.js +0 -440
  132. package/drawDirectedPiePiece.js +0 -142
  133. package/editTool.js +0 -49
  134. package/editorSelector.js +0 -2
  135. package/editorUtils.js +0 -205
  136. package/estimateRowHeight.js +0 -184
  137. package/featureLengthsToHide.js +0 -27
  138. package/featureTool.js +0 -34
  139. package/features.js +0 -19
  140. package/featuresSelector.js +0 -8
  141. package/filteredCutsitesSelector.js +0 -136
  142. package/filteredFeaturesSelector.js +0 -32
  143. package/filteredPartsSelector.js +0 -57
  144. package/filteredPrimersSelector.js +0 -27
  145. package/filteredRestrictionEnzymesSelector.js +0 -1
  146. package/find.png +0 -0
  147. package/findTool.js +0 -79
  148. package/findToolConstants.js +0 -1
  149. package/frameTranslations.js +0 -52
  150. package/fullscreen.png +0 -0
  151. package/getAdditionalEnzymesSelector.js +0 -46
  152. package/getAngleForPositionMidpoint.js +0 -3
  153. package/getAnnotationClassnames.js +0 -12
  154. package/getAnnotationNameAndStartStopString.js +0 -61
  155. package/getBpsPerRow.js +0 -19
  156. package/getCutsiteLabelHeights.js +0 -56
  157. package/getGapMap.js +0 -12
  158. package/getGaps.js +0 -27
  159. package/getInternalLabel.js +0 -40
  160. package/getOveHotkeyDefs.js +0 -12
  161. package/getPairwiseOverviewLinearViewOptions.js +0 -38
  162. package/getRangeAnglesSpecial.js +0 -12
  163. package/getStructuredBases.js +0 -97
  164. package/getTrackFromEvent.js +0 -25
  165. package/getVisibleStartEnd.js +0 -7
  166. package/getXStartAndWidthFromNonCircularRange.js +0 -12
  167. package/getXStartAndWidthOfRangeWrtRow.js +0 -27
  168. package/getXStartAndWidthOfRowAnnotation.js +0 -19
  169. package/getYOffset.js +0 -15
  170. package/hoveredAnnotation.js +0 -24
  171. package/importTool.js +0 -27
  172. package/index.js +0 -71
  173. package/inlineFindTool.js +0 -38
  174. package/isElementInViewport.js +0 -29
  175. package/isEnzymeFilterAndSelector.js +0 -1
  176. package/isTargetWithinEl.js +0 -6
  177. package/labelLineIntensity.js +0 -25
  178. package/labelSize.js +0 -23
  179. package/ladderDefaults.js +0 -25
  180. package/lastSavedId.js +0 -20
  181. package/lineageLines.js +0 -11
  182. package/linear.png +0 -0
  183. package/makeStore.js +0 -34
  184. package/massageTickSpacing.js +0 -19
  185. package/materiallyAvailable.js +0 -19
  186. package/middleware.js +0 -112
  187. package/minimumOrfSize.js +0 -24
  188. package/minimumOrfSizeSelector.js +0 -2
  189. package/modalActions.js +0 -3
  190. package/moveCaret.js +0 -58
  191. package/name.js +0 -19
  192. package/normalizeAngle.js +0 -3
  193. package/normalizeAngleRange.js +0 -9
  194. package/oligoTool.js +0 -30
  195. package/onlyUpdateForKeysDeep.js +0 -31
  196. package/orfFrameToColorMap.js +0 -10
  197. package/orfTool.js +0 -136
  198. package/orfsSelector.js +0 -15
  199. package/panelsShown.js +0 -294
  200. package/partLengthsToHide.js +0 -23
  201. package/partOverhangs.js +0 -6
  202. package/partTagSearch.js +0 -69
  203. package/partTool.js +0 -45
  204. package/parts.js +0 -19
  205. package/partsSelector.js +0 -8
  206. package/pie.png +0 -0
  207. package/polarToSpecialCartesian.js +0 -7
  208. package/positionCutsites.js +0 -6
  209. package/prepareRowData.js +0 -64
  210. package/primerBases.js +0 -221
  211. package/primerLengthsToHide.js +0 -27
  212. package/primers.js +0 -19
  213. package/primersSelector.js +0 -8
  214. package/print.png +0 -0
  215. package/printTool.js +0 -31
  216. package/propertiesTool.js +0 -40
  217. package/proteinUtils.js +0 -3
  218. package/pureNoFunc.js +0 -18
  219. package/readOnly.js +0 -25
  220. package/redoTool.js +0 -30
  221. package/reflex-styles.css +0 -128
  222. package/reflex-styles.css.map +0 -9
  223. package/relaxLabelAngles.js +0 -157
  224. package/relaxLabels_DEPRECATED.js +0 -105
  225. package/replacementLayers.js +0 -36
  226. package/restrictionEnzymes.js +0 -52
  227. package/restrictionEnzymesSelector.js +0 -34
  228. package/rowviewContants.js +0 -3
  229. package/ruler.css +0 -89
  230. package/save.png +0 -0
  231. package/saveTool.js +0 -44
  232. package/searchLayersSelector.js +0 -71
  233. package/selectedAnnotations.js +0 -89
  234. package/selectedAnnotationsSelector.js +0 -1
  235. package/selectedCutsitesSelector.js +0 -21
  236. package/selectedPartTags.js +0 -21
  237. package/selectionLayer.js +0 -25
  238. package/sequence.js +0 -12
  239. package/sequenceDataHistory.js +0 -43
  240. package/sequenceDataSelector.js +0 -2
  241. package/sequenceLengthSelector.js +0 -5
  242. package/sequenceSelector.js +0 -4
  243. package/sharedActionCreators.js +0 -0
  244. package/shouldFlipText.js +0 -4
  245. package/shouldRerender.js +0 -27
  246. package/showFileDialog.js +0 -25
  247. package/showGCContent.js +0 -23
  248. package/show_cut_sites.png +0 -0
  249. package/show_features.png +0 -0
  250. package/show_orfs.png +0 -0
  251. package/show_primers.png +0 -0
  252. package/simpleDialog.css +0 -13
  253. package/specialCutsiteFilterOptions.js +0 -22
  254. package/style.css +0 -10
  255. package/tagsToBoldSelector.js +0 -2
  256. package/toggle_views.svg +0 -1
  257. package/toolBar.js +0 -23
  258. package/translationSearchMatchesSelector.js +0 -14
  259. package/translations.js +0 -20
  260. package/translationsRawSelector.js +0 -8
  261. package/translationsSelector.js +0 -137
  262. package/typeField.js +0 -24
  263. package/undoTool.js +0 -30
  264. package/updateEditor.js +0 -200
  265. package/updateLabelsForInViewFeatures.js +0 -55
  266. package/updateLabelsForInViewFeaturesCircView.js +0 -41
  267. package/updateTrackHelper.js +0 -58
  268. package/uppercaseSequenceMapFont.js +0 -25
  269. package/upsertDeleteActionGenerator.js +0 -31
  270. package/useAAColorType.js +0 -8
  271. package/useAdditionalOrfStartCodons.js +0 -24
  272. package/useAnnotationLimits.js +0 -42
  273. package/useChromatogramPrefs.js +0 -31
  274. package/useFormValue.js +0 -7
  275. package/useLadders.js +0 -6
  276. package/useMeltingTemp.js +0 -7
  277. package/useTmType.js +0 -10
  278. package/userDefinedHandlersAndOpts.js +0 -61
  279. package/utils.js +0 -37
  280. package/versionHistory.js +0 -26
  281. package/versionHistoryTool.js +0 -21
  282. package/viewSubmenu.js +0 -479
  283. package/visibilityTool.js +0 -39
  284. package/withHover.js +0 -113
  285. package/withRestrictionEnzymes.js +0 -15
@@ -1,576 +0,0 @@
1
- import { noop } from "lodash-es";
2
- import {
3
- getRangeLength,
4
- trimRangeByAnotherRange,
5
- trimNumberToFitWithin0ToAnotherNumber,
6
- normalizePositionByRangeLength,
7
- expandOrContractRangeToPosition
8
- } from "@teselagen/range-utils";
9
-
10
- let dragInProgress = false;
11
- let selectionStartOrEndGrabbed;
12
-
13
- let caretPositionOnDragStart;
14
- export const editorDragged = function ({
15
- nearestCaretPos,
16
- doNotWrapOrigin,
17
- caretPosition = -1,
18
- easyStore,
19
- caretPositionUpdate = noop,
20
- selectionLayerUpdate = noop,
21
- selectionLayer = { start: -1, end: -1 },
22
- sequenceLength
23
- }) {
24
- if (easyStore && easyStore.selectionLayer) {
25
- caretPosition = easyStore.caretPosition;
26
- selectionLayer = easyStore.selectionLayer;
27
- }
28
- if (!dragInProgress) {
29
- //we're starting the drag, so update the caret position!
30
- dragInProgress = new Date().getTime();
31
- return;
32
- }
33
-
34
- if (selectionLayer.start > -1 && selectionStartOrEndGrabbed === "start") {
35
- handleSelectionStartGrabbed({
36
- caretPosition,
37
- selectionLayer,
38
- caretPositionUpdate: caretPositionUpdate,
39
- selectionLayerUpdate: selectionLayerUpdate,
40
- nearestCaretPos,
41
- sequenceLength,
42
- doNotWrapOrigin
43
- });
44
- } else if (
45
- selectionLayer.start > -1 &&
46
- selectionStartOrEndGrabbed === "end"
47
- ) {
48
- handleSelectionEndGrabbed({
49
- caretPosition,
50
- selectionLayer,
51
- caretPositionUpdate: caretPositionUpdate,
52
- selectionLayerUpdate: selectionLayerUpdate,
53
- nearestCaretPos,
54
- sequenceLength,
55
- doNotWrapOrigin
56
- });
57
- } else {
58
- handleNoSelectionLayerYet({
59
- caretPosition: caretPositionOnDragStart,
60
- selectionLayer: caretPositionOnDragStart
61
- ? { start: -1, end: -1 }
62
- : selectionLayer,
63
- selectionLayerUpdate: selectionLayerUpdate,
64
- nearestCaretPos,
65
- sequenceLength,
66
- doNotWrapOrigin
67
- });
68
- }
69
- };
70
-
71
- export const editorClicked = function ({
72
- nearestCaretPos,
73
- shiftHeld,
74
- updateSelectionOrCaret
75
- }) {
76
- const timeDif = new Date().getTime() - dragInProgress;
77
- if (!dragInProgress || 200 > timeDif) {
78
- //if the drag is less than 200 ms it probably isn't a real drag!
79
- //we're not dragging the caret or selection handles
80
- updateSelectionOrCaret(shiftHeld, nearestCaretPos);
81
- }
82
- };
83
-
84
- export const editorDragStarted = function (opts) {
85
- document?.body.classList.add("sequenceDragging"); //needed to prevent the input bubble from losing focus post user drag
86
- window.__veDragging = true;
87
-
88
- caretPositionOnDragStart = opts.nearestCaretPos; //bump the drag counter
89
- selectionStartOrEndGrabbed = opts.selectionStartGrabbed
90
- ? "start"
91
- : opts.selectionEndGrabbed
92
- ? "end"
93
- : null;
94
- };
95
- export const editorDragStopped = function () {
96
- document.body.classList.remove("sequenceDragging"); //needed to prevent the input bubble from losing focus post user drag
97
- window.__veDragging = false;
98
- caretPositionOnDragStart = null;
99
- setTimeout(function () {
100
- dragInProgress = false;
101
- });
102
- };
103
-
104
- export function handleCaretMoved({
105
- moveBy,
106
- circular,
107
- sequenceLength,
108
- caretPosition,
109
- selectionLayer,
110
- shiftHeld,
111
- type,
112
- caretPositionUpdate,
113
- selectionLayerUpdate
114
- }) {
115
- let newCaretPosition;
116
- if (selectionLayer.start > -1) {
117
- if (shiftHeld) {
118
- newCaretPosition = normalizeNewCaretPos(
119
- Number(
120
- (selectionLayer.cursorAtEnd
121
- ? selectionLayer.end + 1
122
- : selectionLayer.start) + moveBy
123
- ),
124
- sequenceLength,
125
- circular
126
- );
127
- // newCaretPosition = normalizeNewCaretPos(Number(caretPosition + moveBy), sequenceLength, circular);
128
- let anchorPos;
129
- if (selectionLayer.start <= selectionLayer.end) {
130
- //non-circular selection
131
- //define an anchor pos
132
- if (selectionLayer.cursorAtEnd) {
133
- if (newCaretPosition === selectionLayer.start && moveBy < 0) {
134
- return caretPositionUpdate(newCaretPosition);
135
- }
136
- anchorPos = selectionLayer.start;
137
- } else {
138
- if (newCaretPosition === selectionLayer.end + 1 && moveBy > 0) {
139
- return caretPositionUpdate(newCaretPosition);
140
- }
141
- anchorPos = selectionLayer.end + 1;
142
- }
143
- if (newCaretPosition > anchorPos) {
144
- if (circular && selectionLayer.start + moveBy < 0) {
145
- //we've gone around the origin in this case
146
- selectionLayerUpdate({
147
- start: newCaretPosition,
148
- end: anchorPos - 1,
149
- cursorAtEnd: false
150
- });
151
- } else {
152
- selectionLayerUpdate({
153
- start: anchorPos,
154
- end: normalizePositionByRangeLength(
155
- newCaretPosition - 1,
156
- sequenceLength
157
- ),
158
- cursorAtEnd: true
159
- });
160
- }
161
- } else {
162
- if (circular && selectionLayer.end + moveBy >= sequenceLength) {
163
- //we've gone around the origin in this case
164
- selectionLayerUpdate({
165
- start: anchorPos,
166
- end: normalizePositionByRangeLength(
167
- newCaretPosition - 1,
168
- sequenceLength
169
- ),
170
- cursorAtEnd: true
171
- });
172
- } else {
173
- selectionLayerUpdate({
174
- start: newCaretPosition,
175
- end: normalizePositionByRangeLength(
176
- anchorPos - 1,
177
- sequenceLength
178
- ),
179
- cursorAtEnd: false
180
- });
181
- }
182
- }
183
- } else {
184
- //circular selection
185
- if (selectionLayer.cursorAtEnd) {
186
- anchorPos = selectionLayer.start;
187
- } else {
188
- anchorPos = selectionLayer.end + 1;
189
- }
190
-
191
- if (
192
- (newCaretPosition <= anchorPos &&
193
- !(!selectionLayer.cursorAtEnd && newCaretPosition - moveBy < 0)) || // if the move by is crossing the origin then we should make the new selection non circular
194
- (selectionLayer.cursorAtEnd && selectionLayer.end + moveBy < 0)
195
- ) {
196
- selectionLayerUpdate({
197
- start: anchorPos,
198
- end: normalizePositionByRangeLength(
199
- newCaretPosition - 1,
200
- sequenceLength
201
- ),
202
- cursorAtEnd: true
203
- });
204
- } else {
205
- selectionLayerUpdate({
206
- start: normalizePositionByRangeLength(
207
- newCaretPosition,
208
- sequenceLength
209
- ),
210
- end: normalizePositionByRangeLength(anchorPos - 1, sequenceLength),
211
- cursorAtEnd: false
212
- });
213
- }
214
- }
215
- } else {
216
- //no shiftHeld
217
- //handle special cases
218
- if (moveBy === 0) {
219
- if (type === "moveCaretRightOne") {
220
- return caretPositionUpdate(selectionLayer.end + 1);
221
- } else if (type === "moveCaretLeftOne") {
222
- return caretPositionUpdate(selectionLayer.start);
223
- } else {
224
- throw new Error("this case should not be hit...");
225
- }
226
- } else if (moveBy > 0) {
227
- newCaretPosition = normalizeNewCaretPos(
228
- Number(selectionLayer.end + moveBy),
229
- sequenceLength,
230
- circular
231
- );
232
- caretPositionUpdate(1);
233
- } else {
234
- newCaretPosition = normalizeNewCaretPos(
235
- Number(selectionLayer.start + moveBy),
236
- sequenceLength,
237
- circular
238
- );
239
- caretPositionUpdate(newCaretPosition);
240
- }
241
- }
242
- } else {
243
- //no selection layer
244
- newCaretPosition = normalizeNewCaretPos(
245
- Number(caretPosition + moveBy),
246
- sequenceLength,
247
- circular
248
- );
249
- if (shiftHeld) {
250
- if (moveBy > 0) {
251
- if (newCaretPosition === caretPosition) {
252
- caretPositionUpdate(newCaretPosition);
253
- } else {
254
- selectionLayerUpdate({
255
- start: caretPosition,
256
- end: normalizePositionByRangeLength(
257
- newCaretPosition - 1,
258
- sequenceLength
259
- ),
260
- cursorAtEnd: true
261
- });
262
- }
263
- } else {
264
- //moving to the left
265
- if (newCaretPosition === caretPosition) {
266
- caretPositionUpdate(newCaretPosition);
267
- } else {
268
- selectionLayerUpdate({
269
- start: newCaretPosition,
270
- end: normalizePositionByRangeLength(
271
- caretPosition - 1,
272
- sequenceLength
273
- ),
274
- cursorAtEnd: false
275
- });
276
- }
277
- }
278
- } else {
279
- //no shiftHeld
280
- caretPositionUpdate(newCaretPosition);
281
- }
282
- }
283
- }
284
-
285
- export function normalizeNewCaretPos(caretPosition, sequenceLength, circular) {
286
- if (circular) {
287
- return normalizePositionByRangeLength(caretPosition, sequenceLength, true);
288
- } else {
289
- return trimNumberToFitWithin0ToAnotherNumber(caretPosition, sequenceLength);
290
- }
291
- }
292
-
293
- export function handleSelectionStartGrabbed({
294
- caretPosition,
295
- selectionLayer,
296
- selectionLayerUpdate,
297
- nearestCaretPos,
298
- sequenceLength,
299
- doNotWrapOrigin,
300
- caretPositionUpdate
301
- }) {
302
- if (selectionLayer.start < 0) {
303
- handleNoSelectionLayerYet({
304
- caretPosition,
305
- selectionLayer,
306
- selectionLayerUpdate,
307
- nearestCaretPos,
308
- sequenceLength,
309
- doNotWrapOrigin
310
- });
311
- } else {
312
- if (
313
- doNotWrapOrigin &&
314
- selectionLayer.end > -1 &&
315
- nearestCaretPos === selectionLayer.end + 1
316
- ) {
317
- caretPositionUpdate(nearestCaretPos);
318
- caretPositionOnDragStart = nearestCaretPos;
319
- } else if (doNotWrapOrigin && nearestCaretPos > selectionLayer.end + 1) {
320
- caretPositionOnDragStart = selectionLayer.end + 1;
321
- selectionLayerUpdate({
322
- start: selectionLayer.end + 1,
323
- end: nearestCaretPos
324
- });
325
- selectionStartOrEndGrabbed = "end";
326
- } else {
327
- selectionStartOrEndGrabbed = "start";
328
- //there must be a selection layer
329
- //we need to move the selection layer
330
- selectionLayerUpdate({
331
- start: nearestCaretPos,
332
- end: selectionLayer.end
333
- });
334
- }
335
- }
336
- }
337
-
338
- export function handleSelectionEndGrabbed({
339
- caretPosition,
340
- selectionLayer,
341
- selectionLayerUpdate,
342
- nearestCaretPos,
343
- sequenceLength,
344
- doNotWrapOrigin,
345
- caretPositionUpdate
346
- }) {
347
- if (selectionLayer.start < 0) {
348
- handleNoSelectionLayerYet({
349
- caretPosition,
350
- selectionLayerUpdate,
351
- nearestCaretPos,
352
- sequenceLength,
353
- doNotWrapOrigin
354
- });
355
- } else {
356
- if (
357
- doNotWrapOrigin &&
358
- selectionLayer.start > -1 &&
359
- nearestCaretPos === selectionLayer.start
360
- ) {
361
- caretPositionUpdate(nearestCaretPos);
362
- caretPositionOnDragStart = nearestCaretPos;
363
- } else if (doNotWrapOrigin && nearestCaretPos < selectionLayer.start) {
364
- selectionLayerUpdate({
365
- start: nearestCaretPos,
366
- end: selectionLayer.start - 1
367
- });
368
- caretPositionOnDragStart = selectionLayer.start;
369
- selectionStartOrEndGrabbed = "start";
370
- } else {
371
- selectionStartOrEndGrabbed = "end";
372
- //there must be a selection layer
373
- //we need to move the selection layer
374
- const newEnd = Math.min(nearestCaretPos - 1, sequenceLength - 1);
375
- selectionLayerUpdate({
376
- start: selectionLayer.start,
377
- end: newEnd,
378
- cursorAtEnd: true
379
- });
380
- }
381
- }
382
- }
383
- export function handleNoSelectionLayerYet({
384
- caretPosition,
385
- selectionLayerUpdate,
386
- nearestCaretPos,
387
- sequenceLength,
388
- doNotWrapOrigin
389
- }) {
390
- //no selection layer yet, so we'll start one if necessary
391
- // 0 1 2 3 4 5 6 7 8 9
392
- // c
393
- // n
394
- //
395
-
396
- const dragEnd = {
397
- start: caretPosition,
398
- end: normalizePositionByRangeLength(
399
- nearestCaretPos - 1,
400
- sequenceLength,
401
- true
402
- )
403
- };
404
- const dragStart = {
405
- start: nearestCaretPos,
406
- end: normalizePositionByRangeLength(caretPosition - 1, sequenceLength, true)
407
- };
408
- if (caretPosition === nearestCaretPos) {
409
- return; // do nothing because nearestCaretPos === caretPosition
410
- } else if (
411
- (doNotWrapOrigin && caretPosition < nearestCaretPos) ||
412
- (!doNotWrapOrigin &&
413
- getRangeLength(dragEnd, sequenceLength) <
414
- getRangeLength(dragStart, sequenceLength))
415
- ) {
416
- selectionStartOrEndGrabbed = "end";
417
- selectionLayerUpdate(dragEnd);
418
- caretPositionOnDragStart = null;
419
- } else {
420
- selectionStartOrEndGrabbed = "start";
421
- selectionLayerUpdate(dragStart);
422
- caretPositionOnDragStart = null;
423
- }
424
- }
425
-
426
- export function updateSelectionOrCaret({
427
- shiftHeld,
428
- sequenceLength,
429
- newRangeOrCaret,
430
- caretPosition,
431
- selectionLayer,
432
- selectionLayerUpdate = noop,
433
- caretPositionUpdate = noop,
434
- doNotWrapOrigin
435
- }) {
436
- let newCaret;
437
- let newRange;
438
- if (typeof newRangeOrCaret !== "object") {
439
- newCaret = newRangeOrCaret;
440
- } else {
441
- newRange = {
442
- isFromRowView: newRangeOrCaret.isFromRowView,
443
- start: newRangeOrCaret.start,
444
- end: newRangeOrCaret.end,
445
- forward: newRangeOrCaret.forward,
446
- forceUpdate: newRangeOrCaret.forceUpdate,
447
- overlapsSelf: newRangeOrCaret.overlapsSelf,
448
- isWrappedAddon: newRangeOrCaret.isWrappedAddon
449
- };
450
- }
451
- if (shiftHeld) {
452
- if (caretPosition > 0) {
453
- //there is a caret already down
454
- if (newCaret > -1) {
455
- //a new caret is being passed
456
- handleNoSelectionLayerYet({
457
- caretPosition,
458
- selectionLayer,
459
- selectionLayerUpdate,
460
- nearestCaretPos: newCaret,
461
- sequenceLength,
462
- doNotWrapOrigin
463
- });
464
- } else {
465
- simpleUpdate();
466
- }
467
- } else if (selectionLayer.start > -1) {
468
- //there is already a selection layer
469
- if (newCaret > -1) {
470
- //new caret passed
471
- const distanceFromStart = getMinRangeLength(
472
- selectionLayer.start,
473
- newCaret,
474
- sequenceLength,
475
- doNotWrapOrigin
476
- );
477
- const distanceFromEnd = getMinRangeLength(
478
- selectionLayer.end,
479
- newCaret,
480
- sequenceLength,
481
- doNotWrapOrigin
482
- );
483
- if (distanceFromStart < distanceFromEnd) {
484
- selectionLayerUpdate({
485
- start: newCaret,
486
- end: selectionLayer.end
487
- });
488
- } else {
489
- selectionLayerUpdate({
490
- start: selectionLayer.start,
491
- end: normalizePositionByRangeLength(
492
- newCaret - 1,
493
- sequenceLength,
494
- true
495
- )
496
- });
497
- }
498
- } else {
499
- //new range passed
500
- // return selectionLayerUpdate(newRange);
501
- const selectionFullyContained = !trimRangeByAnotherRange(
502
- selectionLayer,
503
- newRange
504
- );
505
- if (selectionFullyContained) {
506
- return selectionLayerUpdate(newRange);
507
- }
508
-
509
- const newRangeFullyContained = !trimRangeByAnotherRange(
510
- newRange,
511
- selectionLayer
512
- );
513
-
514
- const { newRange: range1 } = expandOrContractRangeToPosition(
515
- selectionLayer,
516
- newRange.start,
517
- sequenceLength
518
- );
519
- const { newRange: range2 } = expandOrContractRangeToPosition(
520
- selectionLayer,
521
- newRange.end + 1,
522
- sequenceLength
523
- ); //+1 to go from range end to position
524
- const range1Shorter =
525
- getRangeLength(range1, sequenceLength) <
526
- getRangeLength(range2, sequenceLength);
527
-
528
- if (newRangeFullyContained) {
529
- range1Shorter
530
- ? selectionLayerUpdate(range1)
531
- : selectionLayerUpdate(range2);
532
- } else {
533
- selectionLayerUpdate({
534
- forward: newRange.forward,
535
- start: selectionLayer.start,
536
- end: newRange.end
537
- });
538
- }
539
- }
540
- } else {
541
- //no caret, no selection, so just do a simple update
542
- simpleUpdate();
543
- }
544
- } else {
545
- //no shift held, so just update the selection or caret
546
- simpleUpdate();
547
- }
548
- function simpleUpdate() {
549
- //shift not held, so just make a new selection layer or move the caret
550
- if (newCaret > -1) {
551
- caretPositionUpdate(newCaret);
552
- } else {
553
- selectionLayerUpdate(newRange);
554
- }
555
- }
556
- }
557
-
558
- // function isRangeShorterIfFlipped(start, end, sequenceLength) {
559
- // return !(
560
- // getRangeLength({ start, end }, sequenceLength) <
561
- // getRangeLength({ start: end, end: start }, sequenceLength)
562
- // );
563
- // }
564
-
565
- function getMinRangeLength(start, end, sequenceLength, doNotWrapOrigin) {
566
- const range1 = getRangeLength({ start, end }, sequenceLength);
567
- const range2 = getRangeLength({ start: end, end: start }, sequenceLength);
568
- if (doNotWrapOrigin) {
569
- if (start < end) {
570
- return range1;
571
- } else {
572
- return range2;
573
- }
574
- }
575
- return range1 < range2 ? range1 : range2;
576
- }
@@ -1,7 +0,0 @@
1
- export function coerceInitialValue({ initialValue, minCharWidth }) {
2
- const scaleFactor = Math.pow(12 / minCharWidth, 1 / 10);
3
-
4
- const zoomLvl = Math.log(initialValue / minCharWidth) / Math.log(scaleFactor);
5
-
6
- return zoomLvl;
7
- }
@@ -1,12 +0,0 @@
1
- export default function combineReducersDontIgnoreKeys(reducers) {
2
- return function (state = {}, action) {
3
- const newState = Object.keys(reducers).reduce((acc, key) => {
4
- acc[key] = reducers[key](state[key], action);
5
- return acc;
6
- }, {});
7
- return {
8
- ...state,
9
- ...newState
10
- };
11
- };
12
- }
package/commandUtils.js DELETED
@@ -1,20 +0,0 @@
1
- import { genericCommandFactory } from "@teselagen/ui";
2
- import { noop } from "lodash-es";
3
-
4
- export function oveCommandFactory(instance, commandDefs) {
5
- return genericCommandFactory({
6
- getArguments(cmdId, [ctxInfo]) {
7
- const args = [instance.props];
8
- const { store, editorName } = instance.props;
9
- if (store && editorName) {
10
- args.push(store.getState().VectorEditor[editorName]);
11
- }
12
- args.push(ctxInfo);
13
- return args;
14
- },
15
- handleReturn: noop,
16
- commandDefs: instance.props.massageCmds
17
- ? instance.props.massageCmds(commandDefs)
18
- : commandDefs
19
- });
20
- }
package/constants.js DELETED
@@ -1,2 +0,0 @@
1
- export const SLIDER_NORM_WIDTH = 120;
2
- export const SLIDER_SMALL_WIDTH = 80;
package/copyOptions.js DELETED
@@ -1,34 +0,0 @@
1
- //./caretPosition.js
2
- import { createReducer } from "redux-act";
3
- import createAction from "./utils/createMetaAction";
4
-
5
- // ------------------------------------
6
- // Actions
7
- // ------------------------------------
8
- export const toggleCopyOption = createAction("TOGGLE_COPY_OPTION"); //NOTE!!:: second argument sanitizes actions so no payload is passed
9
-
10
- export const defaultCopyOptions = {
11
- features: true,
12
- partialFeatures: false,
13
- parts: true,
14
- partialParts: false
15
- };
16
-
17
- // ------------------------------------
18
- // Reducer
19
- // ------------------------------------
20
- export default createReducer(
21
- {
22
- [toggleCopyOption]: (state, type) => {
23
- return {
24
- ...state,
25
- ...(type === "partialFeatures" && !state[type] && { features: true }),
26
- ...(type === "partialParts" && !state[type] && { parts: true }),
27
- ...(type === "features" && { partialFeatures: !state[type] }),
28
- ...(type === "parts" && { partialParts: !state[type] }),
29
- [type]: !state[type]
30
- };
31
- }
32
- },
33
- defaultCopyOptions
34
- );