@teselagen/ove 0.7.26 → 0.7.28

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 (304) hide show
  1. package/AASliver.js +187 -0
  2. package/AddLaddersDialog.js +82 -0
  3. package/AdditionalCutsiteInfoDialog.js +599 -0
  4. package/AlignmentView/Mismatches.d.ts +3 -3
  5. package/AlignmentVisibilityTool.js +105 -0
  6. package/AnnotationContainerHolder.js +20 -0
  7. package/AnnotationPositioner.js +27 -0
  8. package/AutoAnnotate.js +501 -0
  9. package/AutoAnnotateBpMatchingDialog.js +208 -0
  10. package/Axis.js +151 -0
  11. package/AxisNumbers.js +35 -0
  12. package/Browser.js +106 -0
  13. package/Caret.js +63 -0
  14. package/Chromatogram.js +293 -0
  15. package/CircularDnaSequence.js +73 -0
  16. package/CircularView/Labels/index.d.ts +1 -1
  17. package/CircularView/index.d.ts +0 -1
  18. package/CircularZoomMinimap.js +16 -0
  19. package/ColorPicker.js +30 -0
  20. package/CommandHotkeyHandler.js +44 -0
  21. package/CreateAnnotationsPage.d.ts +4 -4
  22. package/CreateAnnotationsPage.js +98 -0
  23. package/Cutsite.js +18 -0
  24. package/CutsiteProperties.js +176 -0
  25. package/CutsiteSelectionLayers.js +47 -0
  26. package/Cutsites.js +271 -0
  27. package/DeletionLayer.js +28 -0
  28. package/DigestTool/Ladder.d.ts +1 -1
  29. package/DropHandler.css +21 -0
  30. package/DropHandler.js +64 -0
  31. package/EditCaretPosition.js +234 -0
  32. package/EditTrackNameDialog.js +30 -0
  33. package/Feature.js +83 -0
  34. package/FeatureProperties.js +6 -0
  35. package/FillWindow.js +47 -0
  36. package/GenbankView.js +74 -0
  37. package/GeneralProperties.js +117 -0
  38. package/GenericAnnotationProperties.js +406 -0
  39. package/GlobalDialog.js +73 -0
  40. package/GlobalDialogUtils.js +110 -0
  41. package/GoToDialog.js +25 -0
  42. package/HorizontalPanelDragHandle.js +35 -0
  43. package/Keyboard.js +85 -0
  44. package/Labels.js +327 -0
  45. package/Ladder.css +20 -0
  46. package/Ladder.js +303 -0
  47. package/MeltingTemp.js +85 -0
  48. package/Menlo.ttf +0 -0
  49. package/Minimap.js +515 -0
  50. package/Mismatches.js +134 -0
  51. package/Monaco.ttf +0 -0
  52. package/MultipleSeqsDetectedOnImportDialog.js +74 -0
  53. package/Orf.js +109 -0
  54. package/OrfProperties.js +117 -0
  55. package/Orfs.js +35 -0
  56. package/PCRTool.js +179 -0
  57. package/PairwiseAlignmentView.js +68 -0
  58. package/Part.js +34 -0
  59. package/PartProperties.js +9 -0
  60. package/PassThrough.js +3 -0
  61. package/PerformantSelectionLayer.js +32 -0
  62. package/PinchHelper.js +24 -0
  63. package/PointedAnnotation.js +347 -0
  64. package/PositionAnnotationOnCircle.js +26 -0
  65. package/Primer.js +41 -0
  66. package/PrimerProperties.js +19 -0
  67. package/Reflex/index.d.ts +0 -1
  68. package/ReflexContainer.js +802 -0
  69. package/ReflexElement.js +160 -0
  70. package/ReflexEvents.js +77 -0
  71. package/ReflexSplitter.js +205 -0
  72. package/RenameSequenceDialog.js +7 -0
  73. package/RotateCircularViewSlider.js +93 -0
  74. package/RowView/index.d.ts +0 -1
  75. package/SelectDialog.js +150 -0
  76. package/SequenceName.js +15 -0
  77. package/SimpleCircularOrLinearView.js +381 -0
  78. package/SimpleOligoPreview.js +39 -0
  79. package/SingleEnzymeCutsiteInfo.js +139 -0
  80. package/ToolBar/ToolbarItem.d.ts +1 -3
  81. package/ToolbarItem.js +192 -0
  82. package/Translation.js +198 -0
  83. package/TranslationProperties.js +149 -0
  84. package/UncontrolledSliderWithPlusMinusBtns.css +5 -0
  85. package/UncontrolledSliderWithPlusMinusBtns.js +134 -0
  86. package/VeTopRightContainer.js +12 -0
  87. package/ZoomCircularViewSlider.js +62 -0
  88. package/ZoomLinearView.js +47 -0
  89. package/addAlignment.js +6 -0
  90. package/addMetaToActionCreators.js +12 -0
  91. package/addWrappedAddons.js +20 -0
  92. package/alignmentTool.js +503 -0
  93. package/alignments.js +379 -0
  94. package/annotationLabelVisibility.js +2 -0
  95. package/annotationSearchSelector.js +24 -0
  96. package/annotationTypes.js +35 -0
  97. package/annotationVisibility.js +196 -0
  98. package/annotationsToSupport.js +104 -0
  99. package/arrayToObjWithIds.js +17 -0
  100. package/arrayUtils.js +19 -0
  101. package/array_move.js +10 -0
  102. package/calculateTickMarkPositionsForGivenRange.js +47 -0
  103. package/caretPosition.js +27 -0
  104. package/cdsFeaturesSelector.js +9 -0
  105. package/charWidth.js +22 -0
  106. package/circular.js +19 -0
  107. package/circularSelector.js +4 -0
  108. package/clickAndDragUtils.js +576 -0
  109. package/coerceInitialValue.js +7 -0
  110. package/combineReducersDontIgnoreKeys.js +12 -0
  111. package/commandUtils.js +20 -0
  112. package/constants.js +2 -0
  113. package/copyOptions.js +34 -0
  114. package/createFragmentLines.js +120 -0
  115. package/createMergedDefaultStateReducer.js +30 -0
  116. package/createMetaAction.js +12 -0
  117. package/createSequenceInputPopup.js +290 -0
  118. package/createSequenceInputPopupStyle.css +87 -0
  119. package/createSimpleDialog.js +89 -0
  120. package/createYourOwnEnzyme.js +39 -0
  121. package/cutsiteLabelColorSelector.js +6 -0
  122. package/cutsiteTool.js +88 -0
  123. package/cutsitesByRangeSelector.js +5 -0
  124. package/cutsitesSelector.js +61 -0
  125. package/darkmode.css +98 -0
  126. package/defaultConfig.js +150 -0
  127. package/deletionLayers.js +36 -0
  128. package/description.js +21 -0
  129. package/digestTool.js +34 -0
  130. package/dnaToColor.js +17 -0
  131. package/downloadTool.js +39 -0
  132. package/draggableClassnames.js +5 -0
  133. package/drawAnnotations.js +440 -0
  134. package/drawDirectedPiePiece.js +142 -0
  135. package/editTool.js +49 -0
  136. package/editorSelector.js +2 -0
  137. package/editorUtils.js +205 -0
  138. package/estimateRowHeight.js +184 -0
  139. package/featureLengthsToHide.js +27 -0
  140. package/featureTool.js +34 -0
  141. package/features.js +19 -0
  142. package/featuresSelector.js +8 -0
  143. package/filteredCutsitesSelector.js +136 -0
  144. package/filteredFeaturesSelector.js +32 -0
  145. package/filteredPartsSelector.js +57 -0
  146. package/filteredPrimersSelector.js +27 -0
  147. package/filteredRestrictionEnzymesSelector.js +1 -0
  148. package/find.png +0 -0
  149. package/findTool.js +79 -0
  150. package/findToolConstants.js +1 -0
  151. package/frameTranslations.js +52 -0
  152. package/fullscreen.png +0 -0
  153. package/getAdditionalEnzymesSelector.js +46 -0
  154. package/getAngleForPositionMidpoint.js +3 -0
  155. package/getAnnotationClassnames.js +12 -0
  156. package/getAnnotationNameAndStartStopString.js +61 -0
  157. package/getBpsPerRow.js +19 -0
  158. package/getCutsiteLabelHeights.js +56 -0
  159. package/getGapMap.js +12 -0
  160. package/getGaps.js +27 -0
  161. package/getInternalLabel.js +40 -0
  162. package/getOveHotkeyDefs.js +12 -0
  163. package/getPairwiseOverviewLinearViewOptions.js +38 -0
  164. package/getRangeAnglesSpecial.js +12 -0
  165. package/getStructuredBases.js +97 -0
  166. package/getTrackFromEvent.js +25 -0
  167. package/getVisibleStartEnd.js +7 -0
  168. package/getXStartAndWidthFromNonCircularRange.js +12 -0
  169. package/getXStartAndWidthOfRangeWrtRow.js +27 -0
  170. package/getXStartAndWidthOfRowAnnotation.js +19 -0
  171. package/getYOffset.js +15 -0
  172. package/hoveredAnnotation.js +24 -0
  173. package/{html2canvas.esm--JN4fLQL.js → html2canvas.esm-DiGWN1gP.js} +187 -229
  174. package/{html2canvas.esm-B7d7VJmQ.cjs → html2canvas.esm-J1esNpMJ.cjs} +187 -229
  175. package/importTool.js +27 -0
  176. package/index.cjs.js +48165 -47142
  177. package/index.es.js +47699 -46676
  178. package/index.js +71 -0
  179. package/inlineFindTool.js +38 -0
  180. package/isElementInViewport.js +29 -0
  181. package/isEnzymeFilterAndSelector.js +1 -0
  182. package/isTargetWithinEl.js +6 -0
  183. package/labelLineIntensity.js +25 -0
  184. package/labelSize.js +23 -0
  185. package/ladderDefaults.js +25 -0
  186. package/lastSavedId.js +20 -0
  187. package/lineageLines.js +11 -0
  188. package/linear.png +0 -0
  189. package/makeStore.js +34 -0
  190. package/massageTickSpacing.js +19 -0
  191. package/materiallyAvailable.js +19 -0
  192. package/middleware.js +112 -0
  193. package/minimumOrfSize.js +24 -0
  194. package/minimumOrfSizeSelector.js +2 -0
  195. package/modalActions.js +3 -0
  196. package/moveCaret.js +58 -0
  197. package/name.js +19 -0
  198. package/normalizeAngle.js +3 -0
  199. package/normalizeAngleRange.js +9 -0
  200. package/oligoTool.js +30 -0
  201. package/onlyUpdateForKeysDeep.js +31 -0
  202. package/orfFrameToColorMap.js +10 -0
  203. package/orfTool.js +136 -0
  204. package/orfsSelector.js +15 -0
  205. package/ove.css +12107 -0
  206. package/package.json +8 -7
  207. package/panelsShown.js +294 -0
  208. package/partLengthsToHide.js +23 -0
  209. package/partOverhangs.js +6 -0
  210. package/partTagSearch.js +69 -0
  211. package/partTool.js +45 -0
  212. package/parts.js +19 -0
  213. package/partsSelector.js +8 -0
  214. package/pie.png +0 -0
  215. package/polarToSpecialCartesian.js +7 -0
  216. package/positionCutsites.js +6 -0
  217. package/prepareRowData.js +64 -0
  218. package/primerBases.js +221 -0
  219. package/primerLengthsToHide.js +27 -0
  220. package/primers.js +19 -0
  221. package/primersSelector.js +8 -0
  222. package/print.png +0 -0
  223. package/printTool.js +31 -0
  224. package/propertiesTool.js +40 -0
  225. package/proteinUtils.js +3 -0
  226. package/pureNoFunc.js +18 -0
  227. package/readOnly.js +25 -0
  228. package/redoTool.js +30 -0
  229. package/reflex-styles.css +128 -0
  230. package/reflex-styles.css.map +9 -0
  231. package/relaxLabelAngles.js +157 -0
  232. package/relaxLabels_DEPRECATED.js +105 -0
  233. package/replacementLayers.js +36 -0
  234. package/restrictionEnzymes.js +52 -0
  235. package/restrictionEnzymesSelector.js +34 -0
  236. package/rowviewContants.js +3 -0
  237. package/ruler.css +89 -0
  238. package/save.png +0 -0
  239. package/saveTool.js +44 -0
  240. package/searchLayersSelector.js +71 -0
  241. package/selectedAnnotations.js +89 -0
  242. package/selectedAnnotationsSelector.js +1 -0
  243. package/selectedCutsitesSelector.js +21 -0
  244. package/selectedPartTags.js +21 -0
  245. package/selectionLayer.js +25 -0
  246. package/selectors/annotationSearchSelector.d.ts +1 -1
  247. package/sequence.js +12 -0
  248. package/sequenceDataHistory.js +43 -0
  249. package/sequenceDataSelector.js +2 -0
  250. package/sequenceLengthSelector.js +5 -0
  251. package/sequenceSelector.js +4 -0
  252. package/sharedActionCreators.js +0 -0
  253. package/shouldFlipText.js +4 -0
  254. package/shouldRerender.js +27 -0
  255. package/showFileDialog.js +25 -0
  256. package/showGCContent.js +23 -0
  257. package/show_cut_sites.png +0 -0
  258. package/show_features.png +0 -0
  259. package/show_orfs.png +0 -0
  260. package/show_primers.png +0 -0
  261. package/simpleDialog.css +13 -0
  262. package/specialCutsiteFilterOptions.js +22 -0
  263. package/src/Editor/DropHandler.js +2 -1
  264. package/src/Editor/index.js +0 -2
  265. package/src/RowItem/StackedAnnotations/getStructuredBases.js +20 -6
  266. package/src/ToolBar/cutsiteTool.js +1 -1
  267. package/src/helperComponents/PropertiesDialog/TranslationProperties.js +2 -1
  268. package/style.css +3 -12100
  269. package/tagsToBoldSelector.js +2 -0
  270. package/toggle_views.svg +1 -0
  271. package/toolBar.js +23 -0
  272. package/translationSearchMatchesSelector.js +14 -0
  273. package/translations.js +20 -0
  274. package/translationsRawSelector.js +8 -0
  275. package/translationsSelector.js +137 -0
  276. package/typeField.js +24 -0
  277. package/undoTool.js +30 -0
  278. package/updateEditor.d.ts +1 -3
  279. package/updateEditor.js +200 -0
  280. package/updateLabelsForInViewFeatures.js +55 -0
  281. package/updateLabelsForInViewFeaturesCircView.js +41 -0
  282. package/updateTrackHelper.js +58 -0
  283. package/uppercaseSequenceMapFont.js +25 -0
  284. package/upsertDeleteActionGenerator.js +31 -0
  285. package/useAAColorType.js +8 -0
  286. package/useAdditionalOrfStartCodons.js +24 -0
  287. package/useAnnotationLimits.js +42 -0
  288. package/useChromatogramPrefs.js +31 -0
  289. package/useFormValue.js +7 -0
  290. package/useLadders.js +6 -0
  291. package/useMeltingTemp.js +7 -0
  292. package/useTmType.js +10 -0
  293. package/userDefinedHandlersAndOpts.js +61 -0
  294. package/utils/getAnnotationNameAndStartStopString.d.ts +1 -5
  295. package/utils/selectionLayer.d.ts +2 -2
  296. package/utils.js +37 -0
  297. package/versionHistory.js +26 -0
  298. package/versionHistoryTool.js +21 -0
  299. package/viewSubmenu.js +479 -0
  300. package/visibilityTool.js +39 -0
  301. package/withEditorInteractions/getBpsPerRow.d.ts +1 -3
  302. package/withHover.js +113 -0
  303. package/withRestrictionEnzymes.js +15 -0
  304. package/index.umd.js +0 -188322
@@ -0,0 +1,576 @@
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
+ }
@@ -0,0 +1,7 @@
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
+ }
@@ -0,0 +1,12 @@
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
+ }
@@ -0,0 +1,20 @@
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 ADDED
@@ -0,0 +1,2 @@
1
+ export const SLIDER_NORM_WIDTH = 120;
2
+ export const SLIDER_SMALL_WIDTH = 80;
package/copyOptions.js ADDED
@@ -0,0 +1,34 @@
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
+ );